(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(y){var Q_=Object.defineProperty,eP=Object.defineProperties;var tP=Object.getOwnPropertyDescriptors;var Aa=Object.getOwnPropertySymbols;var tm=Object.prototype.hasOwnProperty,nm=Object.prototype.propertyIsEnumerable;var le=Math.pow,em=(y,He,Ge)=>He in y?Q_(y,He,{enumerable:!0,configurable:!0,writable:!0,value:Ge}):y[He]=Ge,he=(y,He)=>{for(var Ge in He||(He={}))tm.call(He,Ge)&&em(y,Ge,He[Ge]);if(Aa)for(var Ge of Aa(He))nm.call(He,Ge)&&em(y,Ge,He[Ge]);return y},Me=(y,He)=>eP(y,tP(He));var im=(y,He)=>{var Ge={};for(var It in y)tm.call(y,It)&&He.indexOf(It)<0&&(Ge[It]=y[It]);if(y!=null&&Aa)for(var It of Aa(y))He.indexOf(It)<0&&nm.call(y,It)&&(Ge[It]=y[It]);return Ge};var Pe=(y,He,Ge)=>new Promise((It,br)=>{var xa=un=>{try{bs(Ge.next(un))}catch(Is){br(Is)}},_a=un=>{try{bs(Ge.throw(un))}catch(Is){br(Is)}},bs=un=>un.done?It(un.value):Promise.resolve(un.value).then(xa,_a);bs((Ge=Ge.apply(y,He)).next())});"use strict";const He="tile{subdomain}.maps.2gis.com",Ge="jam.api.2gis.com",It="https://styles.api.2gis.com",br="https://disk.2gis.com/styles/assets/icons",xa="https://disk.2gis.com/styles/assets/models",_a="https://mapgl.2gis.com/api/fonts",bs="https://keys.api.2gis.com/public/v1/keys/{keyID}/services/mapgl-js-api",un="https://mapgl.2gis.com/api/js/plugins/rtl-v1.1.1.js",Is="sha512-IyuCqmcNBfZyrExDMisGi0Xhp4PXupx6AMp4cjpKcAzJo+kSmOtRTLbL1xZsfxnsIqci9Q0piqY+kcwl1hCPyw==",rm="https://mapgl.2gis.com/api/js/plugins",om=107.17318798131565,Ms=le(2,20),ne=le(2,15),Ze=le(2,16)-1,Oi=ne/Ze,V=16383,Gu=2.54,Ts=96,Vu=4294967296/(256/Ts*Gu),Be=.7071067811865475,am=4294967295,lm=1175494351e-47,cm=3402823466e29,Ir=["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"],Fi="Noto_Sans",ju=1/2,Hu=-4,Pa=2147483647,um="c080bb6a-8134-4993-93a1-5b4d8c36a59b",dm=5,Mr=4,La=40,fm=65e3,$u="byModel",hm=65536,Yu="empty",pm=75,Ca={minZoom:2,maxZoom:20},si={protocol:"https",server:He,subdomains:"0123",tileSet:"vector_a",tileKey:Yu,appId:"empty",cacheRatio:2,maxUniverseZoom:8,maxRegionalZoom:15,maxDetailLevel:17},Da={minZoom:10,maxZoom:14,tileSet:"com_poi_web",rasterSizes:[96,84,72,60,48,36,24]},Wu={minZoom:15,maxZoom:15,tileSet:"vector_immersive"},Zu={tileSet:"dem"},Xu=100,Oa=13.5,dn=[2048,2048],Tr={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}"},qu={protocol:"https",host:Ge,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)},Ut={defaultUrl:_a,gamma:.08,baseSize:24,baseLineHeight:1.2,bomCharCode:65279},Ju={defaultUrl:br},Ku={url:It,path:"styles/{id}"},Qu={doubleClickTime:185,dragThreshold:2,pitchWaitingTime:200,pitchThreshold:7},ed=1e3,Ss={inAnimationTime:180,inAnimationType:"linear",outAnimationTime:800,outAnimationType:"linear"},Fa={time:300,type:"linear"},td={minStyleZoom:16,duration:500,easing:"easeOutQuint"},nd={bounceType:"easeOutElastic",bounceTime:1200,growType:"easeInOutQuad",growTime:1200,stagger:0,iterationCount:1/0},Ra={pixelDensity:.5,sceneOpacity:0,cacheRefreshTime:300,pickDistance:3},Sr={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},id={0:Sr.commercialMargins.city,11:{topBottom:250,leftRight:250},12:{topBottom:170,leftRight:170}},sd={alwaysRerender:!1,autoResizeInterval:50},rd="en",od={macWheelDeltaToZoomDelta:.0018,notMacTrackpadDeltaToZoomDelta:.0018*3,wheelZoomDelta:.65,animDuration:400,throttleDelay:100,mouseRotateDelta:2.5,mousePitchDelta:2.5,mobilePinchDelta:1,mobileTapDelta:10},Na={duration:1300,maxSpeed:8,minSpeed:.02,nonLinearity:5},zt={fov:60*Math.PI/180,useDynamicNearFar:!1,near:1e3,far:le(2,34),viewportLimitRatio:2.1,minTrapezeHeight:2*131072,perspectiveDistanceLimitRatio:10,minFogDistance:2e4,fogHorizonPadFactor:.15,pitchInterStartZoom:17,pitchInterEndZoom:19},Rn={globeMaxZoom:8,globeInterStartZoom:7,globeInterEndZoom:16},ad=1e3,ld=16,Ba={enabled:!0,displayStyleZoom:{default:18,metro:16},detailLevel:16,wallMinBrightness:.8265,wallMaxBrightness:.95,viewportPadding:.2,maxStackHeight:40},cd={fpsCaveat:10},ud=3e4,ka=["Commercial_poi_city"],Ua=["Commercial_poi_premium"],dd=["Commercial_poi_default","Commercial_poi_custom","Commercial_poi_navi",...ka,...Ua],fd=["Commercial_model","Commercial_model_animated","Commercial_model_on_click"],hd=["s_personal_poi"],pd=["Landmark_poi","Landmark_point"],md=[105,84,63,42,21],yd="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzBweCIgaGVpZ2h0PSI0OHB4IiB2aWV3Qm94PSIwIDAgMzAgNDgiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PCEtLSBHZW5lcmF0b3I6IFNrZXRjaCA1MS4yICg1NzUxOSkgLSBodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2ggLS0+PHRpdGxlPlBhZ2UgMSBDb3B5PC90aXRsZT48ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz48ZGVmcz48bGluZWFyR3JhZGllbnQgeDE9IjUwJSIgeTE9IjUwJSIgeDI9IjUwJSIgeTI9IjAlIiBpZD0ibGluZWFyR3JhZGllbnQtMSI+PHN0b3Agc3RvcC1jb2xvcj0iIzFCODlFRSIgb2Zmc2V0PSIwJSI+PC9zdG9wPjxzdG9wIHN0b3AtY29sb3I9IiMzMTk4RUMiIG9mZnNldD0iMTAwJSI+PC9zdG9wPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGlkPSJSZWNvdmVyeS0wMSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTgzOS4wMDAwMDAsIC00MjUuMDAwMDAwKSI+PGcgaWQ9IlBhZ2UtMS1Db3B5IiB0cmFuc2Zvcm09InRyYW5zbGF0ZSg4MzkuMDAwMDAwLCA0MjUuMDAwMDAwKSI+PGVsbGlwc2UgaWQ9Ik92YWwtMyIgZmlsbD0iIzAwMDAwMCIgb3BhY2l0eT0iMC4wMzYzODA1OTciIGN4PSIxNSIgY3k9IjQ1LjUiIHJ4PSIzIiByeT0iMS41Ij48L2VsbGlwc2U+PGVsbGlwc2UgaWQ9Ik92YWwtMy1Db3B5IiBmaWxsPSIjMDAwMDAwIiBvcGFjaXR5PSIwLjAzNjM4MDU5NyIgY3g9IjE1IiBjeT0iNDUuNSIgcng9IjQuNSIgcnk9IjIuNSI+PC9lbGxpcHNlPjxwYXRoIGQ9Ik0xNSw0NS44ODM2MzUzIEwxNS44ODIzNTI5LDQ1Ljg4MzYzNTMgQzE1Ljg4MjM1MjksMjkuMjE3NzUyOSAyMC43NzY3NjQ3LDIzLjc5NzQ1ODggMjcuOTg3MzUyOSwyMy43OTc0NTg4IEwyOC4zMjk3MDU5LDIzLjc5NzQ1ODggQzI5LjA3Nzk0MTIsMjEuNTkwNjk0MSAzMCwxNy45OTE1NzY1IDMwLDE1LjAwMDQgQzMwLDcuMTQzOTI5NDEgMjMuNzY3OTQxMiwwLjAwMDQgMTUsMC4wMDA0IEM2LjIzMjA1ODgyLDAuMDAwNCAwLDcuMTQzOTI5NDEgMCwxNS4wMDA0IEMwLDE3Ljk5MTU3NjUgMC45MjIwNTg4MjQsMjEuNTkwNjk0MSAxLjY3MDI5NDEyLDIzLjc5NzQ1ODggTDIuMDEyNjQ3MDYsMjMuNzk3NDU4OCBDOS4yMjQxMTc2NSwyMy43OTc0NTg4IDE0LjExNzY0NzEsMjkuMjE3NzUyOSAxNC4xMTc2NDcxLDQ1Ljg4MzYzNTMgTDE1LDQ1Ljg4MzYzNTMgWiIgaWQ9IkZpbGwtMSIgZmlsbD0idXJsKCNsaW5lYXJHcmFkaWVudC0xKSI+PC9wYXRoPjwvZz48L2c+PC9nPjwvc3ZnPg==",gd=[15,46],vd=16,wd={bias:100,textureSize:[2048,2048],shadowRadius:3},mm=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MIN_TIERS_STYLE_ZOOM:vd,MAP_DEFAULTS:Ca,atlasSize:dn,buildingAnimation:td,cityCommPoiLabelingConfig:id,commercialCitySublayers:ka,commercialModelSublayers:fd,commercialPoi:Da,commercialPremiumSublayers:Ua,commercialSublayers:dd,defaultCameraConfig:zt,defaultLang:rd,defaultMarkerAnchor:gd,defaultMarkerIcon:yd,defaultShadowsSettings:wd,dem:Zu,entranceAnimation:nd,events:Qu,floors:Ba,fonts:Ut,globeConfig:Rn,houseHover:Ss,icons:Ju,identify:Ra,inertia:Na,labeling:Sr,landmarkPoiSublayers:pd,landmarkRasterSizes:md,loadModelsInfoStyleZoom:Oa,maxZoomForDynamicNear:ld,metricsTimeout:ud,minCalculationScreenHeight:ad,modelCacheSize:Xu,models:Wu,performanceCheck:cd,personalSublayers:hd,render:sd,styles:Ku,tileAnimation:Fa,tiles:si,traffic:qu,urls:Tr,workerResetInterval:ed,zoom:od},Symbol.toStringTag,{value:"Module"}));function xe(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 ym(e,t){return[t[0]/e[0]*2-1,-(t[1]/e[1])*2+1]}function Te(e){return e*Math.PI/180}function ri(e){return e/Math.PI*180}function bd(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 Nn(e,t){const n=he({},t);for(const i in e)e[i]!==void 0&&(n[i]=e[i]);return n}function za(e){const t={};for(const n in e){const i=e[n];t[i]=n}return t}function Id(e,t){const n=[];for(const i in e)t[i]||n.push(e[i]);return n}function Ga(e,t,n){return xe((n-e)/(t-e),0,1)}function gm(e){return e%1}function Va(e,t,n){return e>=t&&e<=n}function vm(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 wm(e,t){return e===t?!0:e.length!==t.length?!1:!e.some((n,i)=>n!==t[i])}function Ri(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(!Ri(e[s],t[s]))return!1;return!0}if(n!==i)return!1;const a=e instanceof Date,l=t instanceof Date;if(a!==l)return!1;if(a&&l)return e.getTime()===t.getTime();const c=e instanceof RegExp,u=t instanceof RegExp;if(c!==u)return!1;if(c&&u)return e.toString()===t.toString();const d=Object.keys(e);if(r=d.length,r!==Object.keys(t).length)return!1;for(s=r;s--!==0;)if(!Object.prototype.hasOwnProperty.call(t,d[s]))return!1;for(s=r;s--!==0;)if(o=d[s],!Ri(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}function bm(e,t){const n=e.indexOf(t);return n!==-1?(e.splice(n,1),!0):!1}function Ni(e,t,n){return e+(t-e)*n}function Im(e){return e==null}function Ar(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 Md{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 Mm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Td(e){const t=xe((e>>24&255)/255,0,1),n=xe((e>>16&255)/255,0,1),i=xe((e>>8&255)/255,0,1),s=xe((e&255)/255,0,1);return[t,n,i,s]}const Mt=1e-6;let Tt=typeof Float64Array!="undefined"?Float64Array:Array;function Oe(){let e=new Tt(2);return e[0]=0,e[1]=0,e}function Tm(e){let t=new Tt(2);return t[0]=e[0],t[1]=e[1],t}function ja(e,t){let n=new Tt(2);return n[0]=e,n[1]=t,n}function xr(e,t){return e[0]=t[0],e[1]=t[1],e}function Ve(e,t,n){return e[0]=t,e[1]=n,e}function Gt(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e}function Ha(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function Sm(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e}function Em(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e}function _t(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e}function Es(e,t){var n=t[0]-e[0],i=t[1]-e[1];return Math.sqrt(n*n+i*i)}function _r(e){var t=e[0],n=e[1];return Math.sqrt(t*t+n*n)}function Am(e){var t=e[0],n=e[1];return t*t+n*n}function Bn(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 kn(e,t){return e[0]*t[0]+e[1]*t[1]}function $a(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 Pr(e,t){return e[0]===t[0]&&e[1]===t[1]}function xm(e,t){let n=e[0],i=e[1],s=t[0],r=t[1];return Math.abs(n-s)<=Mt*Math.max(1,Math.abs(n),Math.abs(s))&&Math.abs(i-r)<=Mt*Math.max(1,Math.abs(i),Math.abs(r))}const Sd=_r,fn=Ha,Un=Es;(function(){let e=Oe();return function(t,n,i,s,r,o){let a,l;for(n||(n=2),i||(i=0),s?l=Math.min(s*n+i,t.length):l=t.length,a=i;a<l;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 Ed(){let e=new Tt(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 _m(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 Pm(e,t,n,i,s,r,o,a,l,c,u,d,f,h,g,v){let p=new Tt(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]=l,p[9]=c,p[10]=u,p[11]=d,p[12]=f,p[13]=h,p[14]=g,p[15]=v,p}function Lm(e,t,n,i,s,r,o,a,l,c,u,d,f,h,g,v,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]=l,e[8]=c,e[9]=u,e[10]=d,e[11]=f,e[12]=h,e[13]=g,e[14]=v,e[15]=p,e}function Ya(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 Cm(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 As(e,t){let n=t[0],i=t[1],s=t[2],r=t[3],o=t[4],a=t[5],l=t[6],c=t[7],u=t[8],d=t[9],f=t[10],h=t[11],g=t[12],v=t[13],p=t[14],m=t[15],b=n*a-i*o,w=n*l-s*o,I=n*c-r*o,x=i*l-s*a,E=i*c-r*a,C=s*c-r*l,T=u*v-d*g,D=u*p-f*g,B=u*m-h*g,k=d*p-f*v,j=d*m-h*v,U=f*m-h*p,A=b*U-w*j+I*k+x*B-E*D+C*T;return A?(A=1/A,e[0]=(a*U-l*j+c*k)*A,e[1]=(s*j-i*U-r*k)*A,e[2]=(v*C-p*E+m*x)*A,e[3]=(f*E-d*C-h*x)*A,e[4]=(l*B-o*U-c*D)*A,e[5]=(n*U-s*B+r*D)*A,e[6]=(p*I-g*C-m*w)*A,e[7]=(u*C-f*I+h*w)*A,e[8]=(o*j-a*B+c*T)*A,e[9]=(i*B-n*j-r*T)*A,e[10]=(g*E-v*I+m*b)*A,e[11]=(d*I-u*E-h*b)*A,e[12]=(a*D-o*k-l*T)*A,e[13]=(n*k-i*D+s*T)*A,e[14]=(v*w-g*x-p*b)*A,e[15]=(u*x-d*w+f*b)*A,e):null}function Wa(e,t,n){let i=t[0],s=t[1],r=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],d=t[8],f=t[9],h=t[10],g=t[11],v=t[12],p=t[13],m=t[14],b=t[15],w=n[0],I=n[1],x=n[2],E=n[3];return e[0]=w*i+I*a+x*d+E*v,e[1]=w*s+I*l+x*f+E*p,e[2]=w*r+I*c+x*h+E*m,e[3]=w*o+I*u+x*g+E*b,w=n[4],I=n[5],x=n[6],E=n[7],e[4]=w*i+I*a+x*d+E*v,e[5]=w*s+I*l+x*f+E*p,e[6]=w*r+I*c+x*h+E*m,e[7]=w*o+I*u+x*g+E*b,w=n[8],I=n[9],x=n[10],E=n[11],e[8]=w*i+I*a+x*d+E*v,e[9]=w*s+I*l+x*f+E*p,e[10]=w*r+I*c+x*h+E*m,e[11]=w*o+I*u+x*g+E*b,w=n[12],I=n[13],x=n[14],E=n[15],e[12]=w*i+I*a+x*d+E*v,e[13]=w*s+I*l+x*f+E*p,e[14]=w*r+I*c+x*h+E*m,e[15]=w*o+I*u+x*g+E*b,e}function Ad(e,t,n){let i=n[0],s=n[1],r=n[2],o,a,l,c,u,d,f,h,g,v,p,m;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],l=t[2],c=t[3],u=t[4],d=t[5],f=t[6],h=t[7],g=t[8],v=t[9],p=t[10],m=t[11],e[0]=o,e[1]=a,e[2]=l,e[3]=c,e[4]=u,e[5]=d,e[6]=f,e[7]=h,e[8]=g,e[9]=v,e[10]=p,e[11]=m,e[12]=o*i+u*s+g*r+t[12],e[13]=a*i+d*s+v*r+t[13],e[14]=l*i+f*s+p*r+t[14],e[15]=c*i+h*s+m*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 Za(e,t,n){let i=Math.sin(n),s=Math.cos(n),r=t[4],o=t[5],a=t[6],l=t[7],c=t[8],u=t[9],d=t[10],f=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+c*i,e[5]=o*s+u*i,e[6]=a*s+d*i,e[7]=l*s+f*i,e[8]=c*s-r*i,e[9]=u*s-o*i,e[10]=d*s-a*i,e[11]=f*s-l*i,e}function xd(e,t,n){let i=Math.sin(n),s=Math.cos(n),r=t[0],o=t[1],a=t[2],l=t[3],c=t[8],u=t[9],d=t[10],f=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-c*i,e[1]=o*s-u*i,e[2]=a*s-d*i,e[3]=l*s-f*i,e[8]=r*i+c*s,e[9]=o*i+u*s,e[10]=a*i+d*s,e[11]=l*i+f*s,e}function Lr(e,t,n){let i=Math.sin(n),s=Math.cos(n),r=t[0],o=t[1],a=t[2],l=t[3],c=t[4],u=t[5],d=t[6],f=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+c*i,e[1]=o*s+u*i,e[2]=a*s+d*i,e[3]=l*s+f*i,e[4]=c*s-r*i,e[5]=u*s-o*i,e[6]=d*s-a*i,e[7]=f*s-l*i,e}function Dm(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 _d(e,t,n){let i=n[0],s=n[1],r=n[2],o=Math.sqrt(i*i+s*s+r*r),a,l,c;return Math.abs(o)<Mt?null:(o=1/o,i*=o,s*=o,r*=o,a=Math.sin(t),l=Math.cos(t),c=1-l,e[0]=i*i*c+l,e[1]=s*i*c+r*a,e[2]=r*i*c-s*a,e[3]=0,e[4]=i*s*c-r*a,e[5]=s*s*c+l,e[6]=r*s*c+i*a,e[7]=0,e[8]=i*r*c+s*a,e[9]=s*r*c-i*a,e[10]=r*r*c+l,e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e)}function Om(e,t,n,i){let s=t[0],r=t[1],o=t[2],a=t[3],l=s+s,c=r+r,u=o+o,d=s*l,f=s*c,h=s*u,g=r*c,v=r*u,p=o*u,m=a*l,b=a*c,w=a*u,I=i[0],x=i[1],E=i[2];return e[0]=(1-(g+p))*I,e[1]=(f+w)*I,e[2]=(h-b)*I,e[3]=0,e[4]=(f-w)*x,e[5]=(1-(d+p))*x,e[6]=(v+m)*x,e[7]=0,e[8]=(h+b)*E,e[9]=(v-m)*E,e[10]=(1-(d+g))*E,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function Fm(e,t,n,i,s,r,o){let a=1/(t-n),l=1/(i-s),c=1/(r-o);return e[0]=-2*a,e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=-2*l,e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=2*c,e[11]=0,e[12]=(t+n)*a,e[13]=(s+i)*l,e[14]=(o+r)*c,e[15]=1,e}function Xa(e,t,n,i){let s,r,o,a,l,c,u,d,f,h,g=t[0],v=t[1],p=t[2],m=i[0],b=i[1],w=i[2],I=n[0],x=n[1],E=n[2];return Math.abs(g-I)<Mt&&Math.abs(v-x)<Mt&&Math.abs(p-E)<Mt?mat4.identity(e):(u=g-I,d=v-x,f=p-E,h=1/Math.sqrt(u*u+d*d+f*f),u*=h,d*=h,f*=h,s=b*f-w*d,r=w*u-m*f,o=m*d-b*u,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=d*o-f*r,l=f*s-u*o,c=u*r-d*s,h=Math.sqrt(a*a+l*l+c*c),h?(h=1/h,a*=h,l*=h,c*=h):(a=0,l=0,c=0),e[0]=s,e[1]=a,e[2]=u,e[3]=0,e[4]=r,e[5]=l,e[6]=d,e[7]=0,e[8]=o,e[9]=c,e[10]=f,e[11]=0,e[12]=-(s*g+r*v+o*p),e[13]=-(a*g+l*v+c*p),e[14]=-(u*g+d*v+f*p),e[15]=1,e)}function Rm(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 ki=Wa;function Cr(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 Pd=6378137,qa=2*Math.PI*Pd,ve=4294967296/qa,Nm=Cr([],[-1,-1,0],[2,2,1]),Bm=Cr([],[.5,.5,0],[.5,.5,1]),oi=Pd*(Math.PI/2),km=le(2,16)/4294967296;function Ja(e){return Math.max(e,ad)}function Ui(e,t){const n=zt,i=Ja(t[1])/2,s=4294967296/le(2,e),r=i/256*s,o=Math.tan(n.fov/2);return r/o}function Um(e,t){const n=zt;return Math.log(Ja(t[1])*4294967296/(2*256*Math.tan(n.fov/2)*e))/Math.LN2}function zm(e){return Vu*Math.pow(2,-e)}function Gm(e,t){return Gu*(e/Ts)/t}function Ka(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),l=o*o+Math.cos(s)*Math.cos(r)*a*a,c=2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l));return Math.round(6371e3*c)}function Vm(e){let t=0;if(e.length>1)for(let n=0;n<e.length-1;n++)t+=Ka(e[n],e[n+1]);return t}const jm={min:[-2147483648,-2147483648],max:[4294967296/2,4294967296/2]},Hm={min:[-214748364800,-2147483648],max:[4294967296*100/2,4294967296/2]};function xs(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 Ld(e,t){return e*Math.pow(2,-t)*4294967296/256}function $m(e,t){return e*Math.pow(2,t)*256/4294967296}function Cd(e,t){return e===0?-1/0:-Math.log(t*256/(e*4294967296))/Math.LN2}const Qa=Oe(),Dd=Oe();function Ym(e,t,n){Ha(Qa,n,e),Ha(Dd,t,e);const i=kn(Qa,Dd)/_r(Qa);return Math.atan2(i,e[2])}function Wm(e){const t=e[0],n=e[1];return Va(t,-2147483648,2147483648)&&Va(n,-2147483648,2147483648)}function Zm(e){const t=[...e];return Wm(t)||(t[0]=(4294967296+(t[0]+2147483648)%4294967296)%4294967296-2147483648),t}function Dr(e,t){const n=Math.cos(Te(t[0]-e[0])),i=Math.sin(Te(t[1])),s=Math.sin(Te(e[1])),r=Math.cos(Te(t[1])),o=Math.cos(Te(e[1]));return Math.acos(i*s+r*o*n)}function Xm(e,t,n){const i=Te(e[0]),s=Te(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])),[ri(r[0]),ri(r[1])]}function ot(){let e=new Tt(3);return e[0]=0,e[1]=0,e[2]=0,e}function Od(e){var t=new Tt(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function zn(e){let t=e[0],n=e[1],i=e[2];return Math.sqrt(t*t+n*n+i*i)}function at(e,t,n){let i=new Tt(3);return i[0]=e,i[1]=t,i[2]=n,i}function el(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e}function De(e,t,n,i){return e[0]=t,e[1]=n,e[2]=i,e}function ai(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function Fd(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function Gn(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function qm(e,t,n,i){return e[0]=t[0]+n[0]*i,e[1]=t[1]+n[1]*i,e[2]=t[2]+n[2]*i,e}function Rd(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 Jm(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 Km(e){let t=e[0],n=e[1],i=e[2];return t*t+n*n+i*i}function Nd(e,t){return e[0]=-t[0],e[1]=-t[1],e[2]=-t[2],e}function Kt(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 tl(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function _s(e,t,n){let i=t[0],s=t[1],r=t[2],o=n[0],a=n[1],l=n[2];return e[0]=s*l-r*a,e[1]=r*o-i*l,e[2]=i*a-s*o,e}function li(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 Ps(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 Qm(e,t,n){let i=t[0],s=t[1],r=t[2],o=n[0],a=n[1],l=n[2],c=n[3],u=c*i+a*r-l*s,d=c*s+l*i-o*r,f=c*r+o*s-a*i,h=-o*i-a*s-l*r;return e[0]=u*c+h*-o+d*-l-f*-a,e[1]=d*c+h*-a+f*-o-u*-l,e[2]=f*c+h*-l+u*-a-d*-o,e}function ey(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 ty(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 ny(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 iy(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function sy(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)<=Mt*Math.max(1,Math.abs(n),Math.abs(r))&&Math.abs(i-o)<=Mt*Math.max(1,Math.abs(i),Math.abs(o))&&Math.abs(s-a)<=Mt*Math.max(1,Math.abs(s),Math.abs(a))}const Qt=Fd,nl=Rd,ry=Jm,Or=zn;(function(){let e=ot();return function(t,n,i,s,r,o){let a,l;for(n||(n=3),i||(i=0),s?l=Math.min(s*n+i,t.length):l=t.length,a=i;a<l;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 Ls(){let e=new Tt(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e}function oy(e,t,n,i){let s=new Tt(4);return s[0]=e,s[1]=t,s[2]=n,s[3]=i,s}function Bd(e,t){return e[0]=t[0],e[1]=t[1],e[2]=t[2],e[3]=t[3],e}function ay(e,t,n,i,s){return e[0]=t,e[1]=n,e[2]=i,e[3]=s,e}function ly(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 cy(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 uy(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 dy(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 Fr(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 fy(e,t){let n=e[0],i=e[1],s=e[2],r=e[3],o=t[0],a=t[1],l=t[2],c=t[3];return Math.abs(n-o)<=Mt*Math.max(1,Math.abs(n),Math.abs(o))&&Math.abs(i-a)<=Mt*Math.max(1,Math.abs(i),Math.abs(a))&&Math.abs(s-l)<=Mt*Math.max(1,Math.abs(s),Math.abs(l))&&Math.abs(r-c)<=Mt*Math.max(1,Math.abs(r),Math.abs(c))}const hy=ly;(function(){let e=Ls();return function(t,n,i,s,r,o){let a,l;for(n||(n=4),i||(i=0),s?l=Math.min(s*n+i,t.length):l=t.length,a=i;a<l;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 ci=Ls();class oe{constructor(t,n){this.state=t,this.camera=n,this.position=[0,0,0]}static fromGeo(t,n=[0,0]){var l;const s=Math.sin(Te(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=((l=t[2])!=null?l:0)*ve*c}return n[0]=r,n[1]=xe(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*ri(Math.atan(Math.exp(t[1]*i))),t[2]){const s=oe.scaleFactor(n[1]);n[2]=t[2]/ve/s}return n}static scaleFactor(t){return 1/Math.cos(Te(t))}update(){const{center:t,rotation:n,zoom:i,pitch:s,size:r}=this.state,o=Ui(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;ci[0]=t[0],ci[1]=t[1],ci[2]=t[2],ci[3]=1,Fr(ci,ci,this.camera.viewProjectionMatrix);const[o,a,l,c]=ci,u=c*2;if(n&&(l>u||l<-u||o>u||o<-u||a>u||a<-u))return i;const f=s[0]/2,h=s[1]/2;return i[0]=f+r.left+o*f/c,i[1]=h+r.top-a*h/c,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,Ps(n,n,this.camera.viewProjectionMatrixInverse),n[0]-=this.position[0],n[1]-=this.position[1],n[2]-=this.position[2],Kt(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 ui=Ls();function kd(e){return[e[2],e[0],e[1]]}class lt{constructor(t,n){this.state=t,this.camera=n,this.position=[0,0,0],this.ivpMatrix=[],this.cachedVisibleArc=new Md(()=>{const i=Ui(this.state.zoom,this.state.size)/ve;return Math.acos(oi/(oi+i))},()=>[this.state.zoom]),this.cachedPixelRadius=new Md(()=>{const i=oe.toGeo(this.state.center),s=Xm(i,0,this.visibleArc),r=this.project(lt.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,Sd(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=Te(t[0]),s=Te(t[1]),r=Math.cos(i),o=Math.sin(i),a=Math.cos(s),l=Math.sin(s),c=oi*ve;return n[0]=o*a*c,n[1]=l*c,n[2]=r*a*c,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),l=Math.atan2(s,i);return n[0]=ri(l),n[1]=ri(a),n}update(){const{state:t}=this,n=oe.toGeo(t.center),i=Ui(t.zoom,t.size)+oi*ve,s=Te(n[0]),r=Te(n[1]),o=Math.cos(s),a=Math.sin(s),l=Math.cos(r),c=Math.sin(r);this.position=[a*l*i,c*i,o*l*i];const u=[0,0,1];Xa(this.ivpMatrix,kd(this.position),[0,0,0],u),ki(this.ivpMatrix,this.camera.projectionMatrix,this.ivpMatrix),As(this.ivpMatrix,this.ivpMatrix)}project(t,n=!1,i=[NaN,NaN]){const{size:s,viewport:r}=this.state,o=Ls();ui[0]=t[0],ui[1]=t[1],ui[2]=t[2],ui[3]=1,Fr(ui,ui,this.camera.globeMatrix),Fr(o,ui,this.camera.viewProjectionMatrix);const[a,l,c,u]=o,d=u*2;if(n&&(c>d||c<-d||a>d||a<-d||l>d||l<-d))return i[0]=NaN,i[1]=NaN,i;const h=s[0]/2,g=s[1]/2;return i[0]=h+r.left+a*h/u,i[1]=g+r.top-l*g/u,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=kd(this.position),l=[0,0,0,1];Ps(l,o,this.ivpMatrix);const c=Kt([],Qt([],l,a)),u=Nd([],a),d=tl(u,c),f=Km(u)-le(d,2),h=le(oi*ve,2);if(f>h){if(n)return lt.fromGeo(oe.toGeo(this.state.center));const{left:b,bottom:w,top:I,right:x}=this.state.padding,E=t[0]-r.left-s[0]/2-(b-x)/2,C=t[1]-r.top-s[1]/2-(I-w)/2,T=_t([],Bn([],[E,C]),this.pixelRadius-1);return T[0]=T[0]+r.left+s[0]/2+(b-x)/2,T[1]=T[1]+r.top+s[1]/2+(I-w)/2,this.unproject(T,!0,i)}const g=Math.sqrt(h-f),v=d-g,p=d+g,m=Math.min(v,p);return i[0]=a[0]+c[0]*m,i[1]=a[1]+c[1]*m,i[2]=a[2]+c[2]*m,i}setState(t){this.state=t}canSee(t){const n=oe.toGeo(this.state.center);return Dr(n,t)<this.visibleArc}}const py=[0,0,1],my=ot(),Pt=[0,0,0],yy=1e-5,gy=500;class Cs{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.globeRatio=0,this.fogDistance=0,this.correctedPitch=0,this.correctedRotation=0,this.horizonPixelOffset=0,this.prevZoom=0,this.prevTime=0,this.horizonPixelOffset=0,this.flat=new oe(t,this),this.ecef=new lt(t,this),this.update()}setState(t){this.state=t,this.flat.setState(t),this.ecef.setState(t),this.update()}update(){this.updateGlobeRatio(),this.limitPitchRotation(),this.updatePosition(),this.updateViewMatrix(),this.updateProjectionMatrices(),this.state.pitch=this.correctedPitch,this.state.rotation=this.correctedRotation,this.flat.update(),this.ecef.update(),Wa(this.viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),As(this.viewProjectionMatrixInverse,this.viewProjectionMatrix),As(this.projectionMatrixInverse,this.projectionMatrix),Cm(this.viewMatrixTranspose,this.viewMatrix),this.globeRatio>Number.EPSILON&&this.updateGlobeMatrix(),ki(this.ecefMvpMatrix,this.viewProjectionMatrix,this.globeMatrix),this.updateHorizonPixelOffset(),this.updateFogDistance()}project(t,n=!1,i=[NaN,NaN]){if(this.globeRatio<Number.EPSILON)return this.flat.project(oe.fromGeo(t),n,i);if(this.globeRatio>1-Number.EPSILON)return this.ecef.project(lt.fromGeo(t),n,i);{const s=this.flat.project(oe.fromGeo(t),n),r=this.ecef.project(lt.fromGeo(t),n);return Array.from(li(i,s,r,this.globeRatio))}}unproject(t,n=[0,0],i=!1){if(this.globeRatio<Number.EPSILON){const s=[0,0,0];return this.flat.unproject(t,s),oe.toGeo(s,n),n}else if(this.globeRatio>1-Number.EPSILON){const s=[0,0,0];return this.ecef.unproject(t,!1,s),lt.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),lt.toGeo(r,r),i?(il(this,t,r,s,n,2),n[2]=0,n):(li(n,s,r,this.globeRatio),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=Ui(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,lowZoomMaxPitch:o,styleState:a,maxPitch:l}=t,{pitchInterStartZoom:c,pitchInterEndZoom:u}=r,{globeInterEndZoom:d,globeMaxZoom:f}=Rn;if(this.correctedPitch=i,this.correctedRotation=s,n<u){const h=Math.max(0,n-c)/(u-c);this.correctedPitch=Math.min(i,Ni(o!=null?o:90,l!=null?l:90,h))}if(a.globeEnabled&&n<d){const h=Math.max(0,n-f)/(d-f);if(this.correctedPitch=Math.min(this.correctedPitch,Ni(0,l!=null?l:90,h)),n<=f)this.correctedRotation=0;else if(n!==this.prevZoom){const g=0-s,v=(this.prevZoom-n)/(n-f);v>0&&(this.correctedRotation+=g*v%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 l=i*Math.tan(n/2),c=2*l,u=a*c,d=-u/2;d+=o.x*u/r[0],l-=o.y*c/r[1],u*=o.width/r[0],c*=o.height/r[1];const f=d+u,h=l-c,g=this.projectionMatrix;g[0]=2*i/(f-d),g[5]=2*i/(l-h),g[8]=(f+d)/(f-d),g[9]=(l+h)/(l-h),g[10]=-(s+i)/(s-i),g[11]=-1,g[14]=-2*s*i/(s-i),g[1]=g[2]=g[3]=g[4]=g[6]=g[7]=g[12]=g[13]=g[15]=0,As(this.projectionMatrixInverse,this.projectionMatrix)}updateNearFarState(){const{zoom:t,cameraConfig:n}=this.state,i=this.position;if(t>ld)n.near=zt.near;else{const o=.25*i[2],a=Math.min(16-t,1);n.near=o*a+zt.near*(1-a)}const s=le(1-Math.min(t,20.5)/21,2);n.far=zt.far*s}restoreFixedNearFar(){const{cameraConfig:t}=this.state;t.near=zt.near,t.far=zt.far}correctViewAndSize(){const{size:t,padding:n}=this.state,i=Math.max(0,n.top-n.bottom)*Math.tan(this.correctedPitch),s=Ja(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=nl(this.position,t);this.fogDistance=Math.max(n.minFogDistance,i)}updateViewMatrix(){Xa(this.viewMatrix,this.position,this.state.center,py)}updateGlobeMatrix(){const t=this.globeMatrix,n=[0,0,0];Ya(t);const i=oe.toGeo(this.state.center);De(n,this.state.center[0],this.state.center[1],-this.state.center[2]-oi*ve),Ad(this.globeMatrix,t,n),Za(t,t,Te(i[1])),xd(t,t,-Te(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]);Qt(Pt,o,s),ny(Pt,Pt,my,Te(90)),Kt(Pt,Pt);const a=Ld(n[1]*this.state.cameraConfig.perspectiveDistanceLimitRatio,i);Gn(Pt,Pt,a),ai(Pt,r,Pt),this.flat.project(Pt,!1,Pt),this.horizonPixelOffset=Math.max(0,Math.ceil(Pt[1]))}updateGlobeRatio(){var r;const t=(r=this.state.globeRatioTarget)!=null?r:this.state.globeMode?1:0;if(!Number.isFinite(t)){this.globeRatio=0,this.prevTime=Date.now();return}const n=Date.now(),i=Math.max(0,n-this.prevTime);this.prevTime=n;const s=Math.min(1,gy*i/1e3);this.globeRatio+=(t-this.globeRatio)*s,Math.abs(this.globeRatio-t)<yy&&(this.globeRatio=t)}}function il(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),l=e.project(i),c=e.project(s),u=Un(c,t),d=Un(a,t),f=Un(l,t);if(u<r)return s;if(d<r)return n;if(f<r)return i;if(o>=10)return s;const h=d+u,g=f+u;return h>g?il(e,t,i,s,s,r,o+1):il(e,t,n,s,s,r,o+1)}function vy(e,t,n){n.zoom!==void 0&&(n.zoom=xe(n.zoom,e.minZoom,e.maxZoom));const i=he({},e);xs(i.center);const s=new Cs(i),r=s.unproject(t),o=oe.fromGeo(r);n.center&&xs(n.center),s.setState(he(he({},e),n));const a=oe.fromGeo(s.unproject(t));Math.abs(o[0]-a[0])>le(2,31)&&(a[0]+=(o[0]>0?1:-1)*le(2,32));const l=ot();if(Qt(l,o,a),e.globeMode&&Math.abs(r[1])>70&&e.zoom>Rn.globeInterStartZoom&&e.zoom<Rn.globeMaxZoom){const c=Math.abs(e.zoom-n.zoom);if(c>1e-4){const u=Math.abs(o[0]-a[0]),d=Math.log10(u/c),f=Math.min(1,le(10,6-d));Number.isNaN(f)||Gn(l,l,f)}}return l}function Ud(e){const n=oe.toGeo(e)[1],i=1/(2*Math.cos(Te(n)));return Math.log(i)/Math.log(2)}function wy(e,t){const n=oe.scaleFactor(t[1]);return 1+e*(n-1)}function zd(e,t){const n=Ud(t)*Ga(9,10,e);return e+xe(n,-1,0)}function by(e,t){const n=Ud(t),i=n*Ga(9,10+n,e);return e-xe(i,-1,0)}function Iy(e,t,n,i,s,r,o={top:0,right:0,bottom:0,left:0},a={top:0,right:0,bottom:0,left:0},l,c){const u=zt,d=new Cs({center:oe.fromGeo(e),zoom:t,rotation:Te(n),size:i,pitch:Te(s),viewport:o,padding:a,cameraConfig:u,globeMode:!1,styleState:{}}),f=oe.toGeo(d.flat.unproject(r)),h=oe.toGeo(d.flat.unproject([r[0]+l,r[1]+c]));return Math.max(1,Ka(f,h))}function Rr(e,t){return t*ve*oe.scaleFactor(e[1])}function Ds(e,t){return{min:e||ja(1/0,1/0),max:t||ja(-1/0,-1/0)}}function My(e){return Ds(oe.fromGeo(e.southWest),oe.fromGeo(e.northEast))}function di(e,t){Sm(e.min,e.min,t),Em(e.max,e.max,t)}function Gd(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 sl(e){e.min[0]=1/0,e.max[0]=-1/0,e.min[1]=1/0,e.max[1]=-1/0}function Nr(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 Ty(e,t,n){e[0]=xe(n[0],t.min[0],t.max[0]),e[1]=xe(n[1],t.min[1],t.max[1])}function Sy(e,t,n){e[1]=xe(n[1],t.min[1],t.max[1])}function Ey(e,t){return t[0]<=e.max[0]&&t[0]>=e.min[0]&&t[1]<=e.max[1]&&t[1]>=e.min[1]}function Ay(e,t){return t[1]<=e.max[1]&&t[1]>=e.min[1]}function Vd(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 xy(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 _y(e,t){const n=Nr([],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 rl(){let e=new Tt(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 Py(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 Ly(e,t,n){let i=t[0],s=t[1],r=t[2],o=t[3],a=t[4],l=t[5],c=t[6],u=t[7],d=t[8],f=n[0],h=n[1],g=n[2],v=n[3],p=n[4],m=n[5],b=n[6],w=n[7],I=n[8];return e[0]=f*i+h*o+g*c,e[1]=f*s+h*a+g*u,e[2]=f*r+h*l+g*d,e[3]=v*i+p*o+m*c,e[4]=v*s+p*a+m*u,e[5]=v*r+p*l+m*d,e[6]=b*i+w*o+I*c,e[7]=b*s+w*a+I*u,e[8]=b*r+w*l+I*d,e}function Br(){let e=new Tt(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Cy(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Dy(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 Oy(e,t,n){n*=.5;let i=t[0],s=t[1],r=t[2],o=t[3],a=Math.sin(n),l=Math.cos(n);return e[0]=i*l-r*a,e[1]=s*l+o*a,e[2]=r*l+i*a,e[3]=o*l-s*a,e}function Fy(e,t,n){n*=.5;let i=t[0],s=t[1],r=t[2],o=t[3],a=Math.sin(n),l=Math.cos(n);return e[0]=i*l+s*a,e[1]=s*l-i*a,e[2]=r*l+o*a,e[3]=o*l-r*a,e}function kr(e,t,n,i){let s=t[0],r=t[1],o=t[2],a=t[3],l=n[0],c=n[1],u=n[2],d=n[3],f,h,g,v,p;return h=s*l+r*c+o*u+a*d,h<0&&(h=-h,l=-l,c=-c,u=-u,d=-d),1-h>1e-6?(f=Math.acos(h),g=Math.sin(f),v=Math.sin((1-i)*f)/g,p=Math.sin(i*f)/g):(v=1-i,p=i),e[0]=v*s+p*l,e[1]=v*r+p*c,e[2]=v*o+p*u,e[3]=v*a+p*d,e}function Ry(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=uy;(function(){let e=ot(),t=at(1,0,0),n=at(0,1,0);return function(i,s,r){let o=tl(s,r);return o<-.999999?(_s(e,t,s),Or(e)<1e-6&&_s(e,n,s),Kt(e,e),Dy(i,e,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(_s(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=Br(),t=Br();return function(n,i,s,r,o,a){return kr(e,i,o,a),kr(t,s,r,a),kr(n,e,t,2*a*(1-a)),n}})(),(function(){let e=rl();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,Ry(t,e))}})();const en=[0,0,0],tn=[0,0,0],ol=ot();rl();function Vt(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 Hd(e,t,n,i){return Qt(en,n,t),Qt(tn,n,i),_s(e,tn,en),Kt(e,e),e}function nn(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 $d(e,t,n,i,s){const r=t+i,o=n+s,a=t*r+n*o,l=5;if(a!==0){const c=1/a;e[0]=r*c,e[1]=o*c,_r(e)>l&&Bn(e,e)}else e[0]=0,e[1]=0}function $e(e){return xe(e*127,-127,127)}function al(e,t=e){return e[0]=$e(t[0]),e[1]=$e(t[1]),e}function Ny(e,t,n,i,s){e[0]=t*i+n*s,e[1]=n*i-t*s}function Vn(e,t){const n=t[0];e[0]=-t[1],e[1]=n}function ll(e,t){const n=t[0];e[0]=t[1],e[1]=-n}function By(e){return e[0]===0&&e[1]===0}function ky(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])}function Uy(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}function zy(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];Ve(e,s,r)}function Gy(e,t,n,i,s=!0){if(Pr(t,n)||Pr(n,i)){Ve(e,0,0);return}fn(en,n,t),fn(tn,i,n),s?(Vn(en,en),Vn(tn,tn)):(ll(en,en),ll(tn,tn)),Bn(en,en),Bn(tn,tn),Gt(e,en,tn),Bn(e,e)}function Vy(e,t,n){t[0]=zn(De(ol,e[0],e[1],e[2])),t[1]=zn(De(ol,e[3],e[4],e[5])),t[2]=zn(De(ol,e[6],e[7],e[8]))}function jy(e,t,n,i){t[0]=zn(at(e[0],e[1],e[2])),t[1]=zn(at(e[4],e[5],e[6])),t[2]=zn(at(e[8],e[9],e[10])),n[0]=e[12],n[1]=e[13],n[2]=e[14]}function Hy(e,t,n,i){const[s,r]=e,[o,a]=t,[l,c]=n;return i[0]=Math.min(Math.max(s,o),l),i[1]=Math.min(Math.max(r,a),c),i[2]=0,i}const cl=/\{(\w+)\}/g;function zi(e,t){return e.replace(cl,(n,i)=>t[i])}function Yd(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 $y(e,t){return(typeof e=="object"?e.url:Tr[e]).replace(cl,(n,i)=>{var s;return(s=t[i])!=null?s:n}).replace(cl,(n,i)=>{var s;return(s=t[i])!=null?s:n})}function Os(e,t){const n=zi(t.host,{subdomain:t.subdomain}),i=zi(typeof e=="object"?e.url:Tr[e],Me(he({},t),{host:n}));return Yd(i)}function Fs(e,t){const n=zi(e,t);return Yd(n)}function ul(e,t){let n=0;for(let i=0;i<t.length;i++)n+=t.charCodeAt(i);return e[n%e.length]}function Yy(e,t){const n=new URL(t);return e.startsWith("//")?`${n.protocol}${e}`:e.startsWith("/")?`${n.origin}${e}`:e}for(var Gi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Wy=typeof Uint8Array=="undefined"?[]:new Uint8Array(256),Ur=0;Ur<Gi.length;Ur++)Wy[Gi.charCodeAt(Ur)]=Ur;var Wd=function(e){var t=new Uint8Array(e),n,i=t.length,s="";for(n=0;n<i;n+=3)s+=Gi[t[n]>>2],s+=Gi[(t[n]&3)<<4|t[n+1]>>4],s+=Gi[(t[n+1]&15)<<2|t[n+2]>>6],s+=Gi[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 Zy(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*le(256,e.length-1-n);return t}function Zd(e){const t=new Uint8Array(6);for(let n=0;n<6;n++)t[n]=Math.floor(e/le(256,5-n))&255;return encodeURIComponent(Wd(t.buffer))}function Xy(e,t){var s,r,o,a,l,c;const n={};e.forEach((u,d)=>{n[u]=d});let i=e.length;n.selected=(s=n.selected)!=null?s:i++,n.hovered=(r=n.hovered)!=null?r:i++,n.dpi=(o=n.dpi)!=null?o:i++,n.isRealtime=(a=n.isRealtime)!=null?a:i++,n.pixelDensityPreset=(l=n.pixelDensityPreset)!=null?l:i++,n.tier=(c=n.tier)!=null?c:i++;for(const u in t)n[u]===void 0&&(n[u]=i++);return n}function Xd(e){const t=Xy(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]=za(e.enumerationValues[s]),i),{}),tileProps:t,tilePropsByIndex:za(t),defaultProps:n,vertexPropsLegacy:fl(e.vertexProps)?qy(e):{},vertexProps:fl(e.vertexProps)?[]:e.vertexProps}}function qy(e){const t=e.vertexProps,n={point:["x","y","z"],polygon:["x","y","cut","signed_z"],polyline:["x","y"]};if(!t)return n;if(!fl(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=="undefined"){console.warn(`Неизвестный тип геометрии "${s}", нужно его поддержать`);return}n[r]=t[parseInt(s,10)]}),n}function qd(e,t){const n={};if(t)for(let i=0;i<t.length;i++)n[t[i]]=i;return Xd({enumerationValues:{db_sublayer:n},version:"7.0.0",defaultProps:{},tileProps:e,vertexProps:[]})}function Vi(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 ye=0;const fi={beginningIsCut:ye++,class:ye++,componentDistanceEnd:ye++,componentDistanceStart:ye++,db_icon_priority:ye++,db_label_priority:ye++,db_label2_priority:ye++,dpi:ye++,endingIsCut:ye++,height:ye++,db_hidden_by_plan_building_id:ye++,db_hidden_by_plan_id:ye++,id:ye++,isRealtime:ye++,db_label:ye++,db_label2:ye++,nextPointX:ye++,nextPointY:ye++,db_object_class:ye++,objectLength:ye++,pixelDensityPreset:ye++,previousPointX:ye++,previousPointY:ye++,db_region:ye++,selected:ye++,hovered:ye++,db_sublayer:ye++,traffic_color:ye++,traffic_road_class:ye++,traffic_road_z_level:ye++,db_tiers:ye++,model_src:ye++,linkedIds:ye++,db_model_rotation_angle:ye++,db_plan_id:ye++,traffic_color2:ye++},Jy={version:"5.0.0",tileProps:fi,tilePropsByIndex:za(fi),defaultProps:{},dictionaries:{},reverseDictionaries:{},vertexPropsLegacy:{},vertexProps:[]},Jd=[],dl={},Kd={sourceName:"zenith"};function fl(e){return!Array.isArray(e)}class hl{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 Ky=1;function pl(){return Ky++}let Qy=1;const ml=()=>++Qy,eg=ml(),tg=ml(),yl=65536*65536,Qd=1/yl,ng=12,ef=typeof TextDecoder=="undefined"?null:new TextDecoder("utf-8"),gl=0,zr=1,Rs=2,Gr=5;class Vr{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)*yl;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*yl;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,ig(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>=ng&&ef?ef.decode(this.buf.subarray(n,t)):yg(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===Rs?this.readVarint()+this.pos:this.pos+1}skip(t){const n=t&7;if(n===gl)for(;this.buf[this.pos++]>127;);else if(n===Rs)this.pos=this.readVarint()+this.pos;else if(n===Gr)this.pos+=4;else if(n===zr)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*Qd),!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*Qd),!0),this.pos+=8}writeVarint(t){if(t=+t||0,t>268435455||t<0){sg(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=gg(this.buf,t,this.pos);const i=this.pos-n;i>=128&&tf(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&&tf(i,s,this),this.pos=i-1,this.writeVarint(s),this.pos+=s}writeMessage(t,n,i){this.writeTag(t,Rs),this.writeRawMessage(n,i)}writePackedVarint(t,n){n.length&&this.writeMessage(t,ag,n)}writePackedSVarint(t,n){n.length&&this.writeMessage(t,lg,n)}writePackedBoolean(t,n){n.length&&this.writeMessage(t,dg,n)}writePackedFloat(t,n){n.length&&this.writeMessage(t,cg,n)}writePackedDouble(t,n){n.length&&this.writeMessage(t,ug,n)}writePackedFixed32(t,n){n.length&&this.writeMessage(t,fg,n)}writePackedSFixed32(t,n){n.length&&this.writeMessage(t,hg,n)}writePackedFixed64(t,n){n.length&&this.writeMessage(t,pg,n)}writePackedSFixed64(t,n){n.length&&this.writeMessage(t,mg,n)}writeBytesField(t,n){this.writeTag(t,Rs),this.writeBytes(n)}writeFixed32Field(t,n){this.writeTag(t,Gr),this.writeFixed32(n)}writeSFixed32Field(t,n){this.writeTag(t,Gr),this.writeSFixed32(n)}writeFixed64Field(t,n){this.writeTag(t,zr),this.writeFixed64(n)}writeSFixed64Field(t,n){this.writeTag(t,zr),this.writeSFixed64(n)}writeVarintField(t,n){this.writeTag(t,gl),this.writeVarint(n)}writeSVarintField(t,n){this.writeTag(t,gl),this.writeSVarint(n)}writeStringField(t,n){this.writeTag(t,Rs),this.writeString(n)}writeFloatField(t,n){this.writeTag(t,Gr),this.writeFloat(n)}writeDoubleField(t,n){this.writeTag(t,zr),this.writeDouble(n)}writeBooleanField(t,n){this.writeVarintField(t,+n)}}function ig(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 ji(e,s,t);throw new Error("Expected varint not more than 10 bytes")}function ji(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function sg(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),rg(n,i,t),og(i,t)}function rg(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 og(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 tf(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 ag(e,t){for(let n=0;n<e.length;n++)t.writeVarint(e[n])}function lg(e,t){for(let n=0;n<e.length;n++)t.writeSVarint(e[n])}function cg(e,t){for(let n=0;n<e.length;n++)t.writeFloat(e[n])}function ug(e,t){for(let n=0;n<e.length;n++)t.writeDouble(e[n])}function dg(e,t){for(let n=0;n<e.length;n++)t.writeBoolean(e[n])}function fg(e,t){for(let n=0;n<e.length;n++)t.writeFixed32(e[n])}function hg(e,t){for(let n=0;n<e.length;n++)t.writeSFixed32(e[n])}function pg(e,t){for(let n=0;n<e.length;n++)t.writeFixed64(e[n])}function mg(e,t){for(let n=0;n<e.length;n++)t.writeSFixed64(e[n])}function yg(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 l,c,u;a===1?r<128&&(o=r):a===2?(l=e[s+1],(l&192)===128&&(o=(r&31)<<6|l&63,o<=127&&(o=null))):a===3?(l=e[s+1],c=e[s+2],(l&192)===128&&(c&192)===128&&(o=(r&15)<<12|(l&63)<<6|c&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):a===4&&(l=e[s+1],c=e[s+2],u=e[s+3],(l&192)===128&&(c&192)===128&&(u&192)===128&&(o=(r&15)<<18|(l&63)<<12|(c&63)<<6|u&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 gg(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 hi(e,t){return{a:e[1]-t[1],b:t[0]-e[0],c:e[0]*t[1]-t[0]*e[1]}}function vg(e,t){return Math.abs(nf(e,t))}function nf(e,t){return(t.a*e[0]+t.b*e[1]+t.c)/Math.sqrt(t.a*t.a+t.b*t.b)}function wg(e,t,n){const{a:i,b:s,c:r}=hi(e,t);return at(n,-(i*n+r)/s,0)}function bg(e,t,n){const{a:i,b:s,c:r}=hi(e,t);return at(-(s*n+r)/i,n,0)}const pi=Ds(),yt=Ds();function Ig(e,t,n){const i=t[t.length-1]*n;let s=e[0],r=0;const o=[s];let a=1,l;for(;a<e.length&&!l;){const c=e[a],u=t[a];let d=c;if(u>i){if(!l){const f=(i-r)/(u-r);l=[],$a(l,s,c,f)}d=l}o.push(d),s=d,r=t[a],a++}return o}function Mg(e,t){let n=e[0];sl(pi),di(pi,n);let i=[n];const s=[i];let r=1;for(;r<e.length;){const o=e[r];let a=!1,l=o;if(Gd(yt,pi),di(yt,l),yt.max[0]-yt.min[0]>t){const c=yt.max[0]===l[0]?yt.min[0]+t:yt.max[0]-t;l=wg(n,l,c),a=!0}if(a&&(Gd(yt,pi),di(yt,l)),yt.max[1]-yt.min[1]>t){const c=yt.max[1]===l[1]?yt.min[1]+t:yt.max[1]-t;l=bg(n,l,c),a=!0}a?(i.push(l),sl(pi),di(pi,l),i=[l],s.push(i),n=l):(i.push(o),di(pi,o),n=o,r++)}return s}function Tg(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,l=r*r+o*o,c=l!==0?a/l:0;return c<0?t:c>1?n:[t[0]+c*r,t[1]+c*o]}function jr(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],l=e[3][1];return{min:[Math.min(t,i,r,a),Math.min(n,s,o,l)],max:[Math.max(t,i,r,a),Math.max(n,s,o,l)]}}function Sg(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 sf(e,t){const n=jr(e);if(!Vd(t,n))return!1;const i=[hi(e[3],e[2]),hi(e[1],e[0]),hi(e[0],e[3]),hi(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 l=s[a];if(r.a*l[0]+r.b*l[1]+r.c<0){o=!1;break}}if(o)return!1}return!0}function Eg(e,t,n){e.forEach(i=>{const s=1+t/Rd(n,i);li(i,n,i,s)})}function Ag(e,t){if(e.tiles)for(const n of e.tiles)t.writeMessage(1,xg,n)}function xg(e,t){e.x&&t.writeVarintField(1,e.x),e.y&&t.writeVarintField(2,e.y),e.zoom&&t.writeVarintField(3,e.zoom)}function _g(e,t){return e.readFields(Pg,{tileGroups:[]},t)}function Pg(e,t,n){e===1&&t.tileGroups.push(Lg(n,n.readVarint()+n.pos))}function Lg(e,t){return e.readFields(Cg,{x:0,y:0,zoom:0,tiles:[]},t)}function Cg(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(Dg(n,n.readVarint()+n.pos))}function Dg(e,t){return e.readFields(Og,{regionId:0,hash:void 0,data:void 0},t)}function Og(e,t,n){e===1?t.regionId=n.readVarint():e===2?t.hash=n.readBytes():e===3&&(t.data=n.readBytes())}const jn=[0,0,0];function gt(e){return{coords:e,size:jt(e[2]),offset:$i(e)}}function Le(e){return rf(e[0],e[1],e[2],e[3])}function rf(e,t,n,i){return`${e}_${t}_${n}_${i}`}function Fg(e,t){return`${Le(e)}_${t.stringify()}`}function vl(e){const t=e.split("_");return[parseInt(t[0],10),parseInt(t[1],10),parseInt(t[2],10),parseInt(t[3],10)]}function of(e){return si.subdomains[Math.abs(e[0]+e[1])%si.subdomains.length]}function Rg(e){const t=new Vr(e),n=_g(t),{x:i,y:s,zoom:r,tiles:o}=n.tileGroups[0];return o.map(({regionId:a,hash:l,data:c})=>(c||(console.warn(`Tile ${r}_${i}_${s} from region ${a} is corrupt (has no data)`),c=new Uint8Array(0)),{data:c,regionId:a,metatileHash:Zy(l)}))}function Ng(e){return e.map(t=>({regionId:t.regionId,metatileHash:t.metatileHash}))}function Bg(e){const t=Math.ceil(e.byteLength/4)*4,n=new ArrayBuffer(t);return new Uint8Array(n).set(e),n}function af(e){const[t,n,i]=e;return{min:$i([t,n,i,i]),max:$i([t+1,n+1,i,i])}}function Hr(e,t,n,i=0){const s=af(e);return s.min[0]-=i,s.min[1]-=i,s.max[0]+=i,s.max[1]+=i,n.environmentManager.isAABBInFog(s)?!1:sf(t,s)}function kg(e){return Math.trunc(e/2)*2+1}function wl(e,t=1,n=3,i=!1){let s=1/Math.cos(Te(e));return i&&(s=Math.log2(s)),xe(Math.ceil(s),t,n)-1}const Ug=(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 zg(e,t,n){const i=Gg(t,e.size),s=Math.trunc(t),r=Array.from(e.center);xs(r);const o=oe.toGeo(r),a={min:[o[0]-xe(i*2,0,90),xe(o[1]-i,-85,85)],max:[o[0]+xe(i*2,0,90),xe(o[1]+i,-85,85)]},l=Math.max(wl(a.min[1],2,4),wl(a.max[1],2,4)),c=Math.max(n,s-l),u=Il(r,c,!0);u[0]=Math.round(u[0]),u[1]=Math.round(u[1]);const d=new Cs(e),f=lf(e,d,o),h=nv(u,o,f,d,e),g=[];return h.forEach(v=>{Ug([NaN,2,2,NaN],v)?g.push(...df(v,1)):g.push(v)}),g.filter(v=>Zr(e,d,v))}function Gg(e,t){const n=oi*ve,i=Ui(e,t)+n,s=zt.fov/2,r=Math.sin(s),o=Math.cos(s),a=n/i;let l=ri(Math.acos(le(r,2)/a+o*Math.sqrt(1-le(r,2)/le(a,2))));return Number.isNaN(l)&&(l=90),l}function lf(e,t,n){const i=lt.toGeo(t.ecef.unproject([e.viewport.left,e.viewport.top]));return Math.min(3*Math.max(Dr(i,n)),t.ecef.visibleArc)}function Vg(e,t,n,i,s,r){const[,,o]=e,a=Hg(e),l=i>=5?2:1,c=wl((a.max[1]+a.min[1])/2,l,3,!0),u=Math.max(Math.abs(a.min[1]),Math.abs(a.max[1])),d=Math.max(n,i-c);return o>=d||u>70&&r>0||u>82||Dr(t,[(a.max[0]+a.min[0])/2,(a.max[1]+a.min[1])/2])>.75*s}function jg(e,t){const i=Math.trunc(e.zoom),s=Array.from(e.center);xs(s),oe.toGeo(s,s);const r=[],o=new Cs(e),a=lf(e,o,s);function l(c,u=0){if(gf(s,a,c)&&Zr(e,o,c))if(Vg(c,s,2,i,o.ecef.visibleArc,u))r.push(c);else for(const d of df(c,1))l(d,u+1)}return zg(e,Math.trunc(e.zoom),2).map(([c,u,d])=>{l([c,u,d,t])}),r}function Hg(e){return{min:cf(e),max:cf([e[0]+1,e[1]+1,e[2],e[3]])}}function cf(e){const t=$i(e);return oe.toGeo(t)}function uf(e,t,n,i,s,r=0,o=1/0,a=!1,l=!1){if(e.globeMode)return jg(e,s);a&&(n=kg(n),n>o&&(n-=2));const c=t.floorManager.visibleComplexIsMetro?rv(e.tilesBounds,e.center,t.camera.position):e.tilesBounds,u=jr(c),d=jt(n),f=le(2,n),h=Math.floor((u.min[0]+2147483648-r)/d),g=Math.floor((u.max[0]+2147483648+r)/d),v=Math.max(Math.floor((u.min[1]+2147483648-r)/d),0),p=Math.min(Math.floor((u.max[1]+2147483648+r)/d),f-1),m=[],b=new Set;for(let w=h;w<=g;w++)for(let I=v;I<=p;I++){const x=[w,I,n,s];if(Hr(x,c,t,r)){x[0]=(f+x[0]%f)%f;const E=Le(x);b.has(E)||(b.add(E),m.push(x))}}return l===!0&&$g(m,b,e,t,n,i,s),m}function $g(e,t,n,i,s,r,o){const a=new Set,l=Sg(n.tilesBounds);let c=e;for(let u=s;u>=r;u--){let d=0;const f=[];c.forEach(I=>{const x=Yg(I),E=Le(x);a.has(E)||(f.push(x),a.add(E),Wg(x,C=>{const T=Le(C);!t.has(T)&&!a.has(T)&&Hr(C,n.extendedTilesBounds,i)&&(e.push(C),t.add(T),d++)}))});const h=jt(u-1);Eg(l,h,n.center);const g=jr(l),v=le(2,u-1),p=Math.floor((g.min[0]+2147483648)/h),m=Math.floor((g.max[0]+2147483648)/h),b=Math.max(Math.floor((g.min[1]+2147483648)/h),0),w=Math.min(Math.floor((g.max[1]+2147483648)/h),v-1);for(let I=p;I<=m;I++)for(let x=b;x<=w;x++){const E=[I,x,u-1,o];E[0]=(v+E[0]%v)%v;const C=Le(E);!a.has(C)&&Hr(E,l,i)&&(f.push(E),d++)}if(!d)break;c=f}}function Yg(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 df(e,t){const[n,i,s,r]=e,o=Math.pow(2,t),a=[];for(let l=0;l<o;l++)for(let c=0;c<o;c++)a.push([n*o+l,i*o+c,s+t,r]);return a}function Wg(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 Zg(e,t,n,i,s,r,o,a,l,c,u,d){const f=new Vr,h={tiles:[{x:s[0],y:s[1],zoom:s[2]}]};Ag(h,f);const g={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:u,defaultLang:c,dt:d==null?void 0:d.join(","),request:encodeURIComponent(Wd(f.finish()))};return Os(l?{url:l}:"tiles",g)}function Xg(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?ff(e,t):ff(t,e)}function ff(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],l=t.coords[1];return a>=i&&a<s&&l>=r&&l<o}function $r(e,t,n){return Es(e,yf(t.coords,jn))-Es(e,yf(n.coords,jn))}function vt(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]}function qg(e,t){e[0]=t.offset[0]/4294967296,e[1]=t.offset[1]/4294967296,e[2]=t.size/4294967296}const Yr=ot();function hf(e,t,n,i){var s;Yr[0]=t[0][n],Yr[1]=t[1][n],Yr[2]=((s=t[2])!=null?s:[])[n],vt(e,Yr,i)}function Lt(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 jt(e){return le(2,32-e)}function bl(e){return e[0]>=0&&e[0]<=ne&&e[1]>=0&&e[1]<=ne}function Hi(e,t){return e*4294967296/(ne*Math.pow(2,t))}function wt(e){return xe(e/Ms*ne,0,Ze)}const pf=ne/Ms;function mf(e){return e/ne*Ms}function $i(e){const t=jt(e[2]),n=2147483648;return at(e[0]*t-n,e[1]*t-n,0)}function Jg(e){return[e[0]+2147483648,e[1]+2147483648,32,32]}function yf(e,t){const n=jt(e[2]),i=2147483648;return De(t,(e[0]+.5)*n-i,(e[1]+.5)*n-i,0)}function Il(e,t,n=!1){const s=jt(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 Kg(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=Oe();return Nr(s,e),Il(s,i)}const Wr=e=>{const[t,n,i,s]=e;return[t,le(2,i)-1-n,i,s]},Ct=(e,t)=>{vt(jn,t,e);const n=oe.toGeo(jn);return oe.scaleFactor(n[1])};function Ns(e,t,n){return vt(jn,[e,t],n),oe.toGeo(jn)}function Qg(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 ev(e,t){return lt.fromGeo(Ns(t[0],t[1],e))}function Hn(e,t,n,i){const s=[];return vt(s,i,n),Dr(oe.toGeo(s),e)<t}function gf(e,t,n){const i=gt(n),s=ne;return Hn(e,t,i,[0,s/2,0])||Hn(e,t,i,[s,s/2,0])||Hn(e,t,i,[s/2,s,0])||Hn(e,t,i,[s/2,0,0])||Hn(e,t,i,[0,0,0])||Hn(e,t,i,[0,s,0])||Hn(e,t,i,[s,s,0])||Hn(e,t,i,[s,0,0])}const Fe={mapPoint:[0,0,0],geoPoint:[0,0],ecefPoint:[NaN,NaN,NaN],pixel:[NaN,NaN],corner:[0,0,0],bbox:{min:[0,0],max:[0,0]},viewport:{min:[0,0],max:[0,0]}};function tv(e,t,n,i){const{mapPoint:s,geoPoint:r,ecefPoint:o}=Fe;vt(s,n,t),oe.toGeo(s,r),lt.fromGeo(r,o),e.ecef.project(o,!1,i)}function Zr(e,t,n){const[,i,s]=n;if(i===0||i===le(2,s)-1)return!0;const r=gt(n);let o=1/0,a=1/0,l=-1/0,c=-1/0;for(let u=0;u<4;u++)Fe.corner[0]=u>=2?ne:0,Fe.corner[1]=u===1||u===2?ne:0,tv(t,r,Fe.corner,Fe.pixel),Fe.pixel[0]<o&&(o=Fe.pixel[0]),Fe.pixel[1]<a&&(a=Fe.pixel[1]),Fe.pixel[0]>l&&(l=Fe.pixel[0]),Fe.pixel[1]>c&&(c=Fe.pixel[1]);return Fe.bbox.min[0]=o,Fe.bbox.min[1]=a,Fe.bbox.max[0]=l,Fe.bbox.max[1]=c,Fe.viewport.min[0]=e.viewport.left,Fe.viewport.min[1]=e.viewport.top,Fe.viewport.max[0]=e.viewport.left+e.size[0],Fe.viewport.max[1]=e.viewport.top+e.size[1],Vd(Fe.bbox,Fe.viewport)}function nv(e,t,n,i,s){const a=new Map,l=[e],c=[];for(c.push(e);l.length;){if(c.length>300){console.warn("collectVisibleGlobeTiles: too many tiles",c.length);break}if(l.length>500){console.warn("collectVisibleGlobeTiles: queue overflow");break}const u=l.shift();if(u){const[d,f,h]=u;a.set(d+"."+f+"."+h,!0),iv(u,a,t,n).filter(v=>Zr(s,i,v)).forEach(v=>{const[p,m,b]=v;a.set(p+"."+m+"."+b,!0),c.push(v),l.push(v)})}}return c}function iv(e,t,n,i){const[s,r,o,a]=e,l=le(2,o)-1,c=p=>p>l?0:p<0?l:p,u=([p,m,b,w])=>((m>l||m<0)&&(m=m>l?l:0,p=b===0?p:(p+le(2,b-1))%le(2,b)),[p,m,b,w]),d=[c(s-1),r,o,a],f=[c(s+1),r,o,a],h=u([s,r-1,o,a]),g=u([s,r+1,o,a]);return[f,g,h,d].filter(p=>{const[m,b,w]=p;return!t.has(m+"."+b+"."+w)}).filter(p=>gf(n,i,p))}function sv(e,t,n,i=0){return""}function rv(e,t,n){const i=oe.toGeo(t),s=oe.scaleFactor(i[1]),r=pm*ve*s,o=(n[2]+r)/n[2];return e.map((a,l)=>{if(l<2)return Od(a);Fd(jn,a,n);const c=ot();return qm(c,n,jn,o),c})}var Ml=(e=>(e[e.Tile=0]="Tile",e[e.Custom=1]="Custom",e))(Ml||{});class ov{constructor(t){var n;this._enable=!1,this.name=t.name,this.index=t.index,this.location=t.location!==void 0?t.location:-1,this.locationsCount=(n=t.locationsCount)!=null?n:1,vf(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 vf(e){if(e<0||e>4)throw new Error("[WebGl] Invalid attribute location count. Must be 1, 2, 3 or 4")}const ae=class ae{constructor(t,n,i,s=!1,r=!1){var a;this.elementsType=null,this.isDirty=!0,this._glBuffer=null,this._gl=t,this._initData=n,this.byteLength=n.byteLength,this.type=s?ae.ElementArrayBuffer:ae.ArrayBuffer,this.options=Object.assign({},ae.defaultOptions,i),this.drawType=(a=i==null?void 0:i.drawType)!=null?a:ae.StaticDraw;const o=[ae.UnsignedByte,ae.UnsignedShort,ae.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=ae.UnsignedInt),this._preserveData=r}static _dataTypeSize(t){switch(t){case ae.Byte:case ae.UnsignedByte:return 1;case ae.UnsignedShort:case ae.Short:return 2;case ae.Float:case ae.Int:case ae.UnsignedInt:return 4}throw new Error(`[WebGl] Unsupported Buffer data type: ${String(t)}`)}memSizeJs(){var t,n;return(n=(t=this._initData)==null?void 0:t.byteLength)!=null?n:0}memSizeGPU(){return this.byteLength}bind(t,n,i,s){const r=this._gl;if(this._glBuffer||this.prepare(),this.type===ae.ArrayBuffer){r.bindBuffer(r.ARRAY_BUFFER,this._glBuffer),t=t||0,n=n||this.options,s=s!=null?s:1,vf(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=ae._dataTypeSize(n.dataType);for(let l=0;l<s;l++)r.vertexAttribPointer(t+l,s,o,n.normalized,n.stride,n.offset+l*s*a),this.bindVertexAttribDivisor(t+l,n,i)}}else this.type===ae.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===ae.ArrayBuffer?n.ARRAY_BUFFER:t===ae.ElementArrayBuffer?n.ELEMENT_ARRAY_BUFFER:t===ae.StaticDraw?n.STATIC_DRAW:t===ae.DynamicDraw?n.DYNAMIC_DRAW:t===ae.Byte?n.BYTE:t===ae.Short?n.SHORT:t===ae.Int?n.INT:t===ae.Float?n.FLOAT:t===ae.UnsignedByte?n.UNSIGNED_BYTE:t===ae.UnsignedShort?n.UNSIGNED_SHORT:t===ae.UnsignedInt?n.UNSIGNED_INT:null}_hasRealWebGLContext(){return typeof window!="undefined"&&("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))}};ae.ArrayBuffer=1,ae.ElementArrayBuffer=2,ae.StaticDraw=10,ae.DynamicDraw=11,ae.Float=20,ae.UnsignedByte=21,ae.UnsignedShort=22,ae.UnsignedInt=23,ae.Byte=24,ae.Short=25,ae.Int=26,ae.defaultOptions={itemSize:3,dataType:ae.Float,stride:0,offset:0,normalized:!1,instanceDivisor:0,drawType:ae.StaticDraw};let Xe=ae;function av(e){if(e===void 0)return;const t=window.WebGLRenderingContext,i={[t.UNSIGNED_BYTE]:Xe.UnsignedByte,[t.UNSIGNED_SHORT]:Xe.UnsignedShort,[t.UNSIGNED_INT]:Xe.UnsignedInt,[t.BYTE]:Xe.Byte,[t.SHORT]:Xe.Short,[t.INT]:Xe.Int,[t.FLOAT]:Xe.Float}[e];return i===void 0?(console.error(`Cannot translate ${e} gltf componentType`),NaN):i}function lv(e){return e}var mi=(e=>(e[e.Striped=1]="Striped",e[e.Entrance=2]="Entrance",e[e.Patterned=3]="Patterned",e))(mi||{}),Bs=(e=>(e[e.Line=0]="Line",e[e.Arrow=1]="Arrow",e[e.StartBorder=2]="StartBorder",e[e.LineEnding=3]="LineEnding",e))(Bs||{}),ge=(e=>(e[e.TileCut=0]="TileCut",e[e.Butt=1]="Butt",e[e.Round=2]="Round",e))(ge||{});const qe=Oe(),Xr=Oe(),Yi=Oe(),$n=Oe(),ks=Oe(),hn=Oe(),Tl=Oe(),Dt=Oe();let Wi=0,Yn=0;function Sl(e,t,n,i,s,r,o,a,l,c,u,d){var f,h,g,v;if(!(r<2)){if(nn(qe,t[0],n[0],t[1],n[1]),Wi=0,o===ge.Round){const p=c!==void 0?c[0]:0,m=u!==void 0?u[0]:0;El(e,t[0],n[0],(f=i==null?void 0:i[0])!=null?f:0,(h=s==null?void 0:s[0])!=null?h:0,-qe[0],-qe[1],p,m,l,d)}for(let p=1;p<r;p++)cv(e,t,n,i,s,p,r,l,c,u,d);if(a===ge.Round){const p=c!==void 0?c[r-1]:0,m=u!==void 0?u[r-1]:0;El(e,t[r-1],n[r-1],(g=i==null?void 0:i[r-1])!=null?g:0,(v=s==null?void 0:s[r-1])!=null?v:0,qe[0],qe[1],p,m,l,d)}}}function cv(e,t,n,i,s,r,o,a,l,c,u){var g,v,p,m,b,w,I,x,E,C;const d=r===o-1;if(Ve(ks,t[r-1],n[r-1]),Ve(hn,t[r],n[r]),l!==void 0&&c!==void 0?(Ve(Yi,l[r-1],c[r-1]),Ve($n,l[r],c[r])):(Ve(Yi,0,0),Ve($n,0,0)),Vn(Dt,qe),d)Yn=0;else{Ve(Tl,t[r+1],n[r+1]),nn(Xr,hn[0],hn[1],Tl[0],Tl[1]);const T=xe(kn(qe,Xr),-1,1);if(T<=0)Yn=0,El(e,hn[0],hn[1],(g=i==null?void 0:i[r])!=null?g:0,(v=s==null?void 0:s[r])!=null?v:0,qe[0],qe[1],$n[0],$n[1],a,u);else{const B=Math.sqrt((1-T)/(1+T)),k=Er(kn(Dt,Xr));Yn=B*k}}uv(e,0,1,3,3,1,2);const f=Dt[0]*Be,h=Dt[1]*Be;yi(e,ks[0],ks[1],(p=i==null?void 0:i[r-1])!=null?p:0,(m=s==null?void 0:s[r-1])!=null?m:0,(Dt[0]+qe[0]*Wi)*Be,(Dt[1]+qe[1]*Wi)*Be,f,h,Yi[0],Yi[1],a,u),yi(e,ks[0],ks[1],(b=i==null?void 0:i[r-1])!=null?b:0,(w=s==null?void 0:s[r-1])!=null?w:0,(-Dt[0]-qe[0]*Wi)*Be,(-Dt[1]-qe[1]*Wi)*Be,-f,-h,Yi[0],Yi[1],a,u),yi(e,hn[0],hn[1],(I=i==null?void 0:i[r])!=null?I:0,(x=s==null?void 0:s[r])!=null?x:0,(-Dt[0]+qe[0]*Yn)*Be,(-Dt[1]+qe[1]*Yn)*Be,-f,-h,$n[0],$n[1],a,u),yi(e,hn[0],hn[1],(E=i==null?void 0:i[r])!=null?E:0,(C=s==null?void 0:s[r])!=null?C:0,(Dt[0]-qe[0]*Yn)*Be,(Dt[1]-qe[1]*Yn)*Be,f,h,$n[0],$n[1],a,u),d||(xr(qe,Xr),Wi=Yn)}function El(e,t,n,i,s,r,o,a,l,c,u){dv(e,0,1,2);const d=-r*.01,f=-o*.01;yi(e,t,n,i,s,r+d,o+f,r,o,a,l,c,u),yi(e,t,n,i,s,-o+d,r+f,-o,r,a,l,c,u),yi(e,t,n,i,s,o+d,-r+f,o,-r,a,l,c,u)}function yi(e,t,n,i,s,r,o,a,l,c,u,d,f){const h=e.elements.offset*e.elements.stride,g=h>>1,v=h>>2;if(f){const{x:p,y:m,z:b}=f(t,n);e.views.position[g]=p,e.views.position[g+1]=m,e.views.position[g+2]=b}else e.views.position[g]=V+t,e.views.position[g+1]=V+n;e.views.extender[h]=r*127,e.views.extender[h+1]=o*127,e.views.normal[h]=a*127,e.views.normal[h+1]=l*127,"height"in e.views&&(e.views.height[v]=i),"absZ"in e.views&&(e.views.absZ[v]=s),"shift"in e.views&&(e.views.shift[v]=c,e.views.shift[v+1]=u),"localID"in e.views&&(e.views.localID[v]=d),e.elements.offset++}function uv(e,t,n,i,s,r,o){const a=e.indices.buffer,l=e.indices.offset,c=e.elements.offset;a[l]=c+t,a[l+1]=c+n,a[l+2]=c+i,a[l+3]=c+s,a[l+4]=c+r,a[l+5]=c+o,e.indices.offset=l+6}function dv(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 Al(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var qr={exports:{}},wf;function fv(){if(wf)return qr.exports;wf=1,qr.exports=e,qr.exports.default=e;function e(S,L,_){_=_||2;var F=L&&L.length,O=F?L[0]*_:S.length,N=t(S,0,O,_,!0),R=[];if(!N||N.next===N.prev)return R;var z,Z,Y,ee,K,G,q;if(F&&(N=l(S,L,N,_)),S.length>80*_){z=Y=S[0],Z=ee=S[1];for(var J=_;J<O;J+=_)K=S[J],G=S[J+1],K<z&&(z=K),G<Z&&(Z=G),K>Y&&(Y=K),G>ee&&(ee=G);q=Math.max(Y-z,ee-Z),q=q!==0?32767/q:0}return i(N,R,_,z,Z,q,0),R}function t(S,L,_,F,O){var N,R;if(O===M(S,L,_,F)>0)for(N=L;N<_;N+=F)R=j(N,S[N],S[N+1],R);else for(N=_-F;N>=L;N-=F)R=j(N,S[N],S[N+1],R);return R&&I(R,R.next)&&(U(R),R=R.next),R}function n(S,L){if(!S)return S;L||(L=S);var _=S,F;do if(F=!1,!_.steiner&&(I(_,_.next)||w(_.prev,_,_.next)===0)){if(U(_),_=L=_.prev,_===_.next)break;F=!0}else _=_.next;while(F||_!==L);return L}function i(S,L,_,F,O,N,R){if(S){!R&&N&&h(S,F,O,N);for(var z=S,Z,Y;S.prev!==S.next;){if(Z=S.prev,Y=S.next,N?r(S,F,O,N):s(S)){L.push(Z.i/_|0),L.push(S.i/_|0),L.push(Y.i/_|0),U(S),S=Y.next,z=Y.next;continue}if(S=Y,S===z){R?R===1?(S=o(n(S),L,_),i(S,L,_,F,O,N,2)):R===2&&a(S,L,_,F,O,N):i(n(S),L,_,F,O,N,1);break}}}}function s(S){var L=S.prev,_=S,F=S.next;if(w(L,_,F)>=0)return!1;for(var O=L.x,N=_.x,R=F.x,z=L.y,Z=_.y,Y=F.y,ee=O<N?O<R?O:R:N<R?N:R,K=z<Z?z<Y?z:Y:Z<Y?Z:Y,G=O>N?O>R?O:R:N>R?N:R,q=z>Z?z>Y?z:Y:Z>Y?Z:Y,J=F.next;J!==L;){if(J.x>=ee&&J.x<=G&&J.y>=K&&J.y<=q&&m(O,z,N,Z,R,Y,J.x,J.y)&&w(J.prev,J,J.next)>=0)return!1;J=J.next}return!0}function r(S,L,_,F){var O=S.prev,N=S,R=S.next;if(w(O,N,R)>=0)return!1;for(var z=O.x,Z=N.x,Y=R.x,ee=O.y,K=N.y,G=R.y,q=z<Z?z<Y?z:Y:Z<Y?Z:Y,J=ee<K?ee<G?ee:G:K<G?K:G,X=z>Z?z>Y?z:Y:Z>Y?Z:Y,se=ee>K?ee>G?ee:G:K>G?K:G,me=v(q,J,L,_,F),re=v(X,se,L,_,F),W=S.prevZ,$=S.nextZ;W&&W.z>=me&&$&&$.z<=re;){if(W.x>=q&&W.x<=X&&W.y>=J&&W.y<=se&&W!==O&&W!==R&&m(z,ee,Z,K,Y,G,W.x,W.y)&&w(W.prev,W,W.next)>=0||(W=W.prevZ,$.x>=q&&$.x<=X&&$.y>=J&&$.y<=se&&$!==O&&$!==R&&m(z,ee,Z,K,Y,G,$.x,$.y)&&w($.prev,$,$.next)>=0))return!1;$=$.nextZ}for(;W&&W.z>=me;){if(W.x>=q&&W.x<=X&&W.y>=J&&W.y<=se&&W!==O&&W!==R&&m(z,ee,Z,K,Y,G,W.x,W.y)&&w(W.prev,W,W.next)>=0)return!1;W=W.prevZ}for(;$&&$.z<=re;){if($.x>=q&&$.x<=X&&$.y>=J&&$.y<=se&&$!==O&&$!==R&&m(z,ee,Z,K,Y,G,$.x,$.y)&&w($.prev,$,$.next)>=0)return!1;$=$.nextZ}return!0}function o(S,L,_){var F=S;do{var O=F.prev,N=F.next.next;!I(O,N)&&x(O,F,F.next,N)&&D(O,N)&&D(N,O)&&(L.push(O.i/_|0),L.push(F.i/_|0),L.push(N.i/_|0),U(F),U(F.next),F=S=N),F=F.next}while(F!==S);return n(F)}function a(S,L,_,F,O,N){var R=S;do{for(var z=R.next.next;z!==R.prev;){if(R.i!==z.i&&b(R,z)){var Z=k(R,z);R=n(R,R.next),Z=n(Z,Z.next),i(R,L,_,F,O,N,0),i(Z,L,_,F,O,N,0);return}z=z.next}R=R.next}while(R!==S)}function l(S,L,_,F){var O=[],N,R,z,Z,Y;for(N=0,R=L.length;N<R;N++)z=L[N]*F,Z=N<R-1?L[N+1]*F:S.length,Y=t(S,z,Z,F,!1),Y===Y.next&&(Y.steiner=!0),O.push(p(Y));for(O.sort(c),N=0;N<O.length;N++)_=u(O[N],_);return _}function c(S,L){return S.x-L.x}function u(S,L){var _=d(S,L);if(!_)return L;var F=k(_,S);return n(F,F.next),n(_,_.next)}function d(S,L){var _=L,F=S.x,O=S.y,N=-1/0,R;do{if(O<=_.y&&O>=_.next.y&&_.next.y!==_.y){var z=_.x+(O-_.y)*(_.next.x-_.x)/(_.next.y-_.y);if(z<=F&&z>N&&(N=z,R=_.x<_.next.x?_:_.next,z===F))return R}_=_.next}while(_!==L);if(!R)return null;var Z=R,Y=R.x,ee=R.y,K=1/0,G;_=R;do F>=_.x&&_.x>=Y&&F!==_.x&&m(O<ee?F:N,O,Y,ee,O<ee?N:F,O,_.x,_.y)&&(G=Math.abs(O-_.y)/(F-_.x),D(_,S)&&(G<K||G===K&&(_.x>R.x||_.x===R.x&&f(R,_)))&&(R=_,K=G)),_=_.next;while(_!==Z);return R}function f(S,L){return w(S.prev,S,L.prev)<0&&w(L.next,S,S.next)<0}function h(S,L,_,F){var O=S;do O.z===0&&(O.z=v(O.x,O.y,L,_,F)),O.prevZ=O.prev,O.nextZ=O.next,O=O.next;while(O!==S);O.prevZ.nextZ=null,O.prevZ=null,g(O)}function g(S){var L,_,F,O,N,R,z,Z,Y=1;do{for(_=S,S=null,N=null,R=0;_;){for(R++,F=_,z=0,L=0;L<Y&&(z++,F=F.nextZ,!!F);L++);for(Z=Y;z>0||Z>0&&F;)z!==0&&(Z===0||!F||_.z<=F.z)?(O=_,_=_.nextZ,z--):(O=F,F=F.nextZ,Z--),N?N.nextZ=O:S=O,O.prevZ=N,N=O;_=F}N.nextZ=null,Y*=2}while(R>1);return S}function v(S,L,_,F,O){return S=(S-_)*O|0,L=(L-F)*O|0,S=(S|S<<8)&16711935,S=(S|S<<4)&252645135,S=(S|S<<2)&858993459,S=(S|S<<1)&1431655765,L=(L|L<<8)&16711935,L=(L|L<<4)&252645135,L=(L|L<<2)&858993459,L=(L|L<<1)&1431655765,S|L<<1}function p(S){var L=S,_=S;do(L.x<_.x||L.x===_.x&&L.y<_.y)&&(_=L),L=L.next;while(L!==S);return _}function m(S,L,_,F,O,N,R,z){return(O-R)*(L-z)>=(S-R)*(N-z)&&(S-R)*(F-z)>=(_-R)*(L-z)&&(_-R)*(N-z)>=(O-R)*(F-z)}function b(S,L){return S.next.i!==L.i&&S.prev.i!==L.i&&!T(S,L)&&(D(S,L)&&D(L,S)&&B(S,L)&&(w(S.prev,S,L.prev)||w(S,L.prev,L))||I(S,L)&&w(S.prev,S,S.next)>0&&w(L.prev,L,L.next)>0)}function w(S,L,_){return(L.y-S.y)*(_.x-L.x)-(L.x-S.x)*(_.y-L.y)}function I(S,L){return S.x===L.x&&S.y===L.y}function x(S,L,_,F){var O=C(w(S,L,_)),N=C(w(S,L,F)),R=C(w(_,F,S)),z=C(w(_,F,L));return!!(O!==N&&R!==z||O===0&&E(S,_,L)||N===0&&E(S,F,L)||R===0&&E(_,S,F)||z===0&&E(_,L,F))}function E(S,L,_){return L.x<=Math.max(S.x,_.x)&&L.x>=Math.min(S.x,_.x)&&L.y<=Math.max(S.y,_.y)&&L.y>=Math.min(S.y,_.y)}function C(S){return S>0?1:S<0?-1:0}function T(S,L){var _=S;do{if(_.i!==S.i&&_.next.i!==S.i&&_.i!==L.i&&_.next.i!==L.i&&x(_,_.next,S,L))return!0;_=_.next}while(_!==S);return!1}function D(S,L){return w(S.prev,S,S.next)<0?w(S,L,S.next)>=0&&w(S,S.prev,L)>=0:w(S,L,S.prev)<0||w(S,S.next,L)<0}function B(S,L){var _=S,F=!1,O=(S.x+L.x)/2,N=(S.y+L.y)/2;do _.y>N!=_.next.y>N&&_.next.y!==_.y&&O<(_.next.x-_.x)*(N-_.y)/(_.next.y-_.y)+_.x&&(F=!F),_=_.next;while(_!==S);return F}function k(S,L){var _=new A(S.i,S.x,S.y),F=new A(L.i,L.x,L.y),O=S.next,N=L.prev;return S.next=L,L.prev=S,_.next=O,O.prev=_,F.next=_,_.prev=F,N.next=F,F.prev=N,F}function j(S,L,_,F){var O=new A(S,L,_);return F?(O.next=F.next,O.prev=F,F.next.prev=O,F.next=O):(O.prev=O,O.next=O),O}function U(S){S.next.prev=S.prev,S.prev.next=S.next,S.prevZ&&(S.prevZ.nextZ=S.nextZ),S.nextZ&&(S.nextZ.prevZ=S.prevZ)}function A(S,L,_){this.i=S,this.x=L,this.y=_,this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1}e.deviation=function(S,L,_,F){var O=L&&L.length,N=O?L[0]*_:S.length,R=Math.abs(M(S,0,N,_));if(O)for(var z=0,Z=L.length;z<Z;z++){var Y=L[z]*_,ee=z<Z-1?L[z+1]*_:S.length;R-=Math.abs(M(S,Y,ee,_))}var K=0;for(z=0;z<F.length;z+=3){var G=F[z]*_,q=F[z+1]*_,J=F[z+2]*_;K+=Math.abs((S[G]-S[J])*(S[q+1]-S[G+1])-(S[G]-S[q])*(S[J+1]-S[G+1]))}return R===0&&K===0?0:Math.abs((K-R)/R)};function M(S,L,_,F){for(var O=0,N=L,R=_-F;N<_;N+=F)O+=(S[R]-S[N])*(S[N+1]+S[R+1]),R=N;return O}return e.flatten=function(S){for(var L=S[0][0].length,_={vertices:[],holes:[],dimensions:L},F=0,O=0;O<S.length;O++){for(var N=0;N<S[O].length;N++)for(var R=0;R<L;R++)_.vertices.push(S[O][N][R]);O>0&&(F+=S[O-1].length,_.holes.push(F))}return _},qr.exports}var hv=fv();const Jr=Al(hv),xl=le(2,15),Zi=-32768,Us=32767;class pv{constructor(t,n){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=xl/t,this._canonical=n}subdividePolygonInternal(t,n){if(this._used)throw new Error("Subdivision: multiple use not allowed.");this._used=!0;const{flattened:i,holeIndices:s}=yv(t);this._initializeVertices(i);let r=[];try{const a=Jr(i,s),l=this._convertIndices(i,a);r=this._subdivideTrianglesScanline(l)}catch(a){console.error(a)}let o=[];return n&&(o=this._generateOutline(t)),this._ensureNoPoleVertices(),this._handlePoles(r),{verticesFlattened:this._vertexBuffer,indicesTriangles:r,indicesLineList:o}}_getKey(t,n){return t=t+32768,n=n+32768,t<<16|n<<0}_vertexToIndex(t,n){if(t<-32768||n<-32768||t>32767||n>32767)throw new Error("Vertex coordinates are out of signed 16 bit integer range.");const i=Math.round(t)|0,s=Math.round(n)|0,r=this._getKey(i,s);if(this._vertexDictionary.has(r))return this._vertexDictionary.get(r);const o=this._vertexBuffer.length/2;return this._vertexDictionary.set(r,o),this._vertexBuffer.push(i,s),o}_subdivideTrianglesScanline(t){if(this._granularity<2)return gv(this._vertexBuffer,t);const n=[],i=t.length;for(let s=0;s<i;s+=3){const r=[t[s+0],t[s+1],t[s+2]],o=[this._vertexBuffer[t[s+0]*2+0],this._vertexBuffer[t[s+0]*2+1],this._vertexBuffer[t[s+1]*2+0],this._vertexBuffer[t[s+1]*2+1],this._vertexBuffer[t[s+2]*2+0],this._vertexBuffer[t[s+2]*2+1]];let a=1/0,l=1/0,c=-1/0,u=-1/0;for(let v=0;v<3;v++){const p=o[v*2],m=o[v*2+1];a=Math.min(a,p),c=Math.max(c,p),l=Math.min(l,m),u=Math.max(u,m)}if(a===c||l===u)continue;const d=Math.floor(a/this._granularityCellSize),f=Math.ceil(c/this._granularityCellSize),h=Math.floor(l/this._granularityCellSize),g=Math.ceil(u/this._granularityCellSize);if(d===f&&h===g){n.push(...r);continue}for(let v=h;v<g;v++){const p=this._scanlineGenerateVertexRingForCellRow(v,o,r);vv(this._vertexBuffer,p,n)}}return n}_scanlineGenerateVertexRingForCellRow(t,n,i){const s=t*this._granularityCellSize,r=s+this._granularityCellSize,o=[];for(let a=0;a<3;a++){const l=n[a*2],c=n[a*2+1],u=n[(a+1)*2%6],d=n[((a+1)*2+1)%6],f=n[(a+2)*2%6],h=n[((a+2)*2+1)%6],g=u-l,v=d-c,p=g===0,m=v===0,b=(s-c)/v,w=(r-c)/v,I=Math.min(b,w),x=Math.max(b,w);if(!m&&(I>=1||x<=0)||m&&(c<s||c>r)){d>=s&&d<=r&&o.push(i[(a+1)%3]);continue}if(!m&&I>0){const T=l+g*I,D=c+v*I;o.push(this._vertexToIndex(T,D))}const E=l+g*Math.max(I,0),C=l+g*Math.min(x,1);if(p||this._generateIntraEdgeVertices(o,l,c,u,d,E,C),!m&&x<1){const T=l+g*x,D=c+v*x;o.push(this._vertexToIndex(T,D))}(m||d>=s&&d<=r)&&o.push(i[(a+1)%3]),!m&&(d<=s||d>=r)&&this._generateInterEdgeVertices(o,l,c,u,d,f,h,C,s,r)}return o}_generateIntraEdgeVertices(t,n,i,s,r,o,a){const l=s-n,c=r-i,u=c===0,d=u?Math.min(n,s):Math.min(o,a),f=u?Math.max(n,s):Math.max(o,a),h=Math.floor(d/this._granularityCellSize)+1,g=Math.ceil(f/this._granularityCellSize)-1;if(u?n<s:o<a)for(let p=h;p<=g;p++){const m=p*this._granularityCellSize,b=i+c*(m-n)/l;t.push(this._vertexToIndex(m,b))}else for(let p=g;p>=h;p--){const m=p*this._granularityCellSize,b=i+c*(m-n)/l;t.push(this._vertexToIndex(m,b))}}_generateInterEdgeVertices(t,n,i,s,r,o,a,l,c,u){const d=r-i,f=o-s,h=a-r,g=(c-r)/h,v=(u-r)/h,p=Math.min(g,v),m=Math.max(g,v),b=s+f*p;let w=Math.floor(Math.min(b,l)/this._granularityCellSize)+1,I=Math.ceil(Math.max(b,l)/this._granularityCellSize)-1,x=l<b;const E=h===0;if(E&&(a===c||a===u))return;if(E||p>=1||m<=0){const T=n-o,D=i-a,B=(c-a)/D,k=(u-a)/D,j=Math.min(B,k),U=o+T*j;w=Math.floor(Math.min(U,l)/this._granularityCellSize)+1,I=Math.ceil(Math.max(U,l)/this._granularityCellSize)-1,x=l<U}const C=d>0?u:c;if(x)for(let T=w;T<=I;T++){const D=T*this._granularityCellSize;t.push(this._vertexToIndex(D,C))}else for(let T=I;T>=w;T--){const D=T*this._granularityCellSize;t.push(this._vertexToIndex(D,C))}}_generateOutline(t){const n=[];for(const i of t){const s=_l(i,this._granularity,!0),r=this._pointArrayToIndices(s),o=[];for(let a=1;a<r.length;a++)o.push(r[a-1]),o.push(r[a]);n.push(o)}return n}_handlePoles(t){let n=!1,i=!1;this._canonical&&(this._canonical.y===0&&(n=!0),this._canonical.y===(1<<this._canonical.z)-1&&(i=!0)),(n||i)&&this._fillPoles(t,n,i)}_ensureNoPoleVertices(){const t=this._vertexBuffer;for(let n=0;n<t.length;n+=2){const i=t[n+1];i===Zi&&(t[n+1]=Zi+1),i===Us&&(t[n+1]=Us-1)}}_generatePoleQuad(t,n,i,s,r,o){s>r!=(o===Zi)?(t.push(n),t.push(this._vertexToIndex(s,o)),t.push(i),t.push(i),t.push(this._vertexToIndex(s,o)),t.push(this._vertexToIndex(r,o))):(t.push(i),t.push(this._vertexToIndex(s,o)),t.push(n),t.push(this._vertexToIndex(r,o)),t.push(this._vertexToIndex(s,o)),t.push(i))}_fillPoles(t,n,i){const s=this._vertexBuffer,r=0,o=xl,a=t.length;for(let l=2;l<a;l+=3){const c=t[l-2],u=t[l-1],d=t[l],f=s[c*2],h=s[c*2+1],g=s[u*2],v=s[u*2+1],p=s[d*2],m=s[d*2+1];n&&(h===r&&v===r&&this._generatePoleQuad(t,c,u,f,g,Zi),v===r&&m===r&&this._generatePoleQuad(t,u,d,g,p,Zi),m===r&&h===r&&this._generatePoleQuad(t,d,c,p,f,Zi)),i&&(h===o&&v===o&&this._generatePoleQuad(t,c,u,f,g,Us),v===o&&m===o&&this._generatePoleQuad(t,u,d,g,p,Us),m===o&&h===o&&this._generatePoleQuad(t,d,c,p,f,Us))}}_initializeVertices(t){for(let n=0;n<t.length;n+=2)this._vertexToIndex(t[n],t[n+1])}_convertIndices(t,n){const i=[];for(let s=0;s<n.length;s++){const r=t[n[s]*2],o=t[n[s]*2+1];i.push(this._vertexToIndex(r,o))}return i}_pointArrayToIndices(t){const n=[];for(let i=0;i<t.length;i++){const s=t[i];n.push(this._vertexToIndex(s[0],s[1]))}return n}}function mv(e,t,n,i=!0){return new pv(n,t).subdividePolygonInternal(e,i)}function _l(e,t,n=!1){if(!e||e.length<1)return[];if(e.length<2)return[];const i=e[0],s=e[e.length-1],r=n&&(i[0]!==s[0]||i[1]!==s[1]);if(t<2)return r?[...e,e[0]]:[...e];const o=Math.floor(xl/t),a=[];a.push([e[0][0],e[0][1]]);const l=e.length,c=r?l:l-1;for(let u=0;u<c;u++){const d=e[u],f=u<l-1?e[u+1]:e[0],h=d[0],g=d[1],v=f[0],p=f[1],m=h!==v,b=g!==p;if(!m&&!b)continue;const w=v-h,I=p-g,x=Math.abs(w),E=Math.abs(I);let C=h,T=g;for(;;){const B=w>0?(Math.floor(C/o)+1)*o:(Math.ceil(C/o)-1)*o,k=I>0?(Math.floor(T/o)+1)*o:(Math.ceil(T/o)-1)*o,j=Math.abs(C-B),U=Math.abs(T-k),A=Math.abs(C-v),M=Math.abs(T-p),S=m?j/x:Number.POSITIVE_INFINITY,L=b?U/E:Number.POSITIVE_INFINITY;if((A<=j||!m)&&(M<=U||!b))break;if(S<L&&m||!b){C=B,T=T+I*S;const _=[C,Math.round(T)];(a[a.length-1][0]!==_[0]||a[a.length-1][1]!==_[1])&&a.push(_)}else{C=C+w*L,T=k;const _=[Math.round(C),T];(a[a.length-1][0]!==_[0]||a[a.length-1][1]!==_[1])&&a.push(_)}}const D=[v,p];(a[a.length-1][0]!==D[0]||a[a.length-1][1]!==D[1])&&a.push(D)}return a}function yv(e){const t=[],n=[];for(const i of e)if(i.length!==0){i!==e[0]&&t.push(n.length/2);for(let s=0;s<i.length;s++)n.push(i[s][0]),n.push(i[s][1])}return{flattened:n,holeIndices:t}}function gv(e,t){const n=[];for(let i=0;i<t.length;i+=3){const s=t[i],r=t[i+1],o=t[i+2],a=e[s*2],l=e[s*2+1],c=e[r*2],u=e[r*2+1],d=e[o*2],f=e[o*2+1],h=c-a,g=u-l,v=d-a,p=f-l;h*p-g*v>0?(n.push(s),n.push(r),n.push(o)):(n.push(s),n.push(o),n.push(r))}return n}function vv(e,t,n){if(t.length===0)throw new Error("Subdivision vertex ring is empty.");let i=0,s=e[t[0]*2];for(let l=1;l<t.length;l++){const c=e[t[l]*2];c<s&&(s=c,i=l)}const r=t.length;let o=i,a=(o+1)%r;for(;;){const l=o-1>=0?o-1:r-1,c=(a+1)%r,u=e[t[l]*2],d=e[t[l]*2+1],f=e[t[c]*2],h=e[t[c]*2+1],g=e[t[o]*2],v=e[t[o]*2+1],p=e[t[a]*2],m=e[t[a]*2+1];let b=!1;if(u<f)b=!0;else if(u>f)b=!1;else{const w=p-g,x=m-v,E=-w,C=v<m?1:-1,T=((u-g)*x+(d-v)*E)*C,D=((f-g)*x+(h-v)*E)*C;T>D&&(b=!0)}if(b){const w=t[l],I=t[o],x=t[a];w!==I&&w!==x&&I!==x&&n.push(x,w,I),o--,o<0&&(o=r-1)}else{const w=t[c],I=t[o],x=t[a];w!==I&&w!==x&&I!==x&&n.push(x,w,I),a++,a>=r&&(a=0)}if(l===c)break}}function Re(e,t,n){return t.precomputes.forEach((i,s)=>{e.push(n.tileData[s])}),e}function zs(e,t){for(let n=0,i=t.length;n<i;n++)e.push(t[n]);return e}const wv={x:0,y:1};function bv(e){const t={};for(const n in e)e[n]&&(t[n]=Array.from(e[n]));return t}function Gs(e,t){for(const n in e){const i=wv[n];i!==void 0?e[n].push(t[i]):e[n].push(NaN)}}const bf=32,If=512;function Iv(e,t,n,i,s){const r=[e[0][0],e[1][0]],o=Te(90+i),a=[];vt(a,r,s);const l=oe.toGeo(a),c=Rr(l,t),u=Rr(l,n),d=Math.sqrt(le(c,2)+le(u,2))/2,f=Math.atan(c/-u)+Math.PI+o,h=d*Math.cos(f),g=d*Math.sin(f),v=Math.atan(-c/-u)+Math.PI+o,p=d*Math.cos(v),m=d*Math.sin(v),b=Math.atan(-c/u)+2*Math.PI+o,w=d*Math.cos(b),I=d*Math.sin(b),x=Math.atan(c/u)+o,E=d*Math.cos(x),C=d*Math.sin(x),T=[],D=[],B=[],k=[];return Lt(T,[a[0]+h,a[1]+g],s),Lt(D,[a[0]+p,a[1]+m],s),Lt(B,[a[0]+w,a[1]+I],s),Lt(k,[a[0]+E,a[1]+C],s),[[T[0],D[0],B[0],k[0]],[T[1],D[1],B[1],k[1]]]}function Kr(e,t){const n=Math.max(e,t);return n*bf>If?If/n:bf}function Mf(e){const t=Ct(e,[0,0]);return ne/jt(e.coords[2])*ve*t}function Mv(e,t,n,i){if(isNaN(e.step)||isNaN(e.width))return n;const{tileProps:s,tileAttrs:r}=i,o=Mf(t);let a=e.step*o;if(isNaN(a)&&(a=0),a===0)return n;const l=e.width*o,c={},u=n.x,d=n.y,f=u.length;for(const C in n)c[C]=[];let h=0;const g=[h];for(let C=1;C<f;C++)h+=Un([u[C-1],d[C-1]],[u[C],d[C]]),g.push(h);const v=Oe(),p=Oe(),m=[0,0],b=Math.abs(h/Math.trunc(h/a)),w=[u[0],d[0]];let I=(e.stopLines?1:-1)*Math.sign(e.width),x=0,E=0;for(Gs(c,w),e.stopLines&&!r[s.beginningIsCut]&&(nn(v,u[E],d[E],u[E+1],d[E+1]),Vn(p,v),_t(m,p,I*l),Gt(w,w,m),Gs(c,w),x+=b/2,I=-I);x<=h;){for(;x>g[E+1];)E++;if(nn(v,u[E],d[E],u[E+1],d[E+1]),Vn(p,v),I>0)_t(m,p,I*l),Gt(w,w,m),_t(m,v,b/2),Gt(w,w,m),Gs(c,w);else{const C=Math.min(1,(x-g[E])/(g[E+1]-g[E]));$a(w,[u[E],d[E]],[u[E+1],d[E+1]],C),Gs(c,w)}I=-I,x+=b/2}return e.stopLines&&!r[s.endingIsCut]&&(_t(m,p,I*l),Gt(w,w,m),Gs(c,w)),c}function Tv(e,t,n,i){const s=Mf(t),r=Ct(t,[0,0]),{tileProps:o,tileAttrs:a}=i,l=n.x.length,c=s*e.modelLength,u=s*(e.edgeMarging||0),d={x:[],y:[],xScaleDirection:[],yScaleDirection:[],scaleCorrection:[]};for(let f=1;f<l;f++){const h=[n.x[f],n.y[f]],g=[n.x[f-1],n.y[f-1]];f===1&&u>0&&!a[o.beginningIsCut]&&Tf(g,h,u),f===l-1&&u>0&&!a[o.endingIsCut]&&Tf(h,g,u),Sv(d,g,h,c,r)}return d}function Tf(e,t,n){const i=Un(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 Sv(e,t,n,i,s){const[r,o]=t,[a,l]=n,c=Un(t,n),u=Math.max(Math.round(c/i),1),d=c/(u*i),f=a-r,h=l-o,g=f/c,v=h/c,p=c/u/2;for(let m=1;m<=u;m++){const b=m*(c/u),w=r+g*(b-p),I=o+v*(b-p),x=r+g*b,E=o+v*b;e.x.push(w),e.y.push(I),e.xScaleDirection.push(x),e.yScaleDirection.push(E),e.scaleCorrection.push(d*s)}return e}function Qr(e,t,n,i){if(!Ev(e)||e.length===0)return n;let s=bv(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=Mv(r,t,s,i);break;case"to-points-modifier":s=Tv(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 Ev(e){return!!e&&Array.isArray(e)}const Av=new Set(["bottomCenter","bottomRight","bottomLeft","topCenter","topRight","topLeft","rightBottom","rightCenter","rightTop","leftBottom","leftCenter","leftTop","centerCenter"]);function xv(e){return Av.has(e)}function _v(e){return typeof e=="number"||typeof e=="boolean"||typeof e=="string"||e===null}function Pl(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,"object-attr":!0,step:!0,interpolate:!0,all:!0,get:!0,"source-attr":!0,"feature-state":!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,"is-behind-objects":!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,"read-from-target":!0,"vertex-attribute":!0,has:!0,"vertex-color":!0,"color-desaturate":!0,"color-grayscale":!0,"color-lighten":!0,"color-lightness":!0,"color-darken":!0,"color-whiten":!0,"color-blacken":!0,"color-saturate":!0,"color-opacity":!0,concat:!0,"color-effect":!0}[t[0]])return!0}return!1}function Sf(e){return Pl(e)&&e[0]==="literal"}function sn(e){return!Array.isArray(e)&&typeof e=="object"&&e!==null&&e.type!==void 0&&e.type!=="color"}function Pv(e){return!Array.isArray(e)&&typeof e=="object"&&e!==null&&e.type==="color"}function Ef(e,t){return Array.isArray(e)?e.length>0&&e.every(n=>typeof n===t):!1}function Lv(e){return Ef(e,"string")}function pn(e){return Ef(e,"number")}function Af(e){return!Array.isArray(e)&&typeof e=="object"&&e!==null&&e.type==="object"}function Cv(e){const t=typeof e;return e===null||t==="string"||t==="number"||t==="boolean"||Lv(e)||pn(e)}function xf(e){return Cv(e)||Pv(e)||Af(e)}function Dv(e){return sn(e)&&e.type==="get"}function ct(e,t){return t!==void 0?{type:"color",value:e,mixFactor:t}:{type:"color",value:e}}function Ov(e){return{type:"mix-color",color1:e.value1,color2:e.value2,factor:e.factor,factorInterpolate:e.factorInterpolate}}function Xi(e,t,n){return`${e}_${t}_${n}`}function eo(e){return`texture-${e}`}function Ll(e,t){return e+"-"+t}function Je(e){return Sf(e)&&Array.isArray(e[1])?e[1][0]:Array.isArray(e)?Pl(e)?e:e[0]:e}function mn(e){if(Sf(e)&&Array.isArray(e[1]))return e[1][1];if(Array.isArray(e)&&!Pl(e)&&e[1]!==void 0)return e[1]}function st(e){if(typeof e=="number"||pn(e))return e;if(e.type==="literal-array"&&pn(e.array))return e.array;throw new Error("Unsupported simple literal expression. Can't resolve.")}function Vs(e,t=0){const n=Number(e);return isNaN(n)?t:n}function _f(e){return!!e&&typeof e=="object"&&e.type==="mix-options"}const Pf=ct([0,0,0,0]);function Lf(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 yn(e){return!!e&&typeof e=="object"&&e.type==="color"}function Fv(e){return!!e&&typeof e=="object"&&e.type==="mix-color"}function to(e){return!!e&&typeof e=="object"&&e.type==="gradient-color"}function js(e){const t=e.toLowerCase();let n=Pf;switch(t[0]){case"#":n=Nv(t);break;case"h":n=qi(t);break;case"r":n=Bv(t);break}return n}function Rv(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 Nv(e){if(!new RegExp(`^#[a-f0-9]{${e.length-1}}$`).test(e)||![4,5,7,9].includes(e.length))return Pf;const n=Rv(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 ct([i,s,r,o])}function qi(e,t){const n=Cf(e);n[0]/=360,n[1]/=100,n[2]/=100;const[i,s,r]=kv(n[0],n[1],n[2]),o=t!==void 0?t:n[3]!==void 0?n[3]*255:255;return ct([Math.round(i),Math.round(s),Math.round(r),Math.round(o)])}function Bv(e){const[t,n,i,s]=Cf(e),r=s!==void 0?s*255:255;return ct([Math.round(t),Math.round(n),Math.round(i),Math.round(r)])}function Cf(e){return e.split("(")[1].split(")")[0].split(",").map(n=>parseFloat(n))}function Cl(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 kv(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[Cl(s,i,e+1/3)*255,Cl(s,i,e)*255,Cl(s,i,e-1/3)*255]}function Df(e){const t=e[0],n=e[1];let i=e[2];const s=Ji(e)[0],r=1/255*Math.min(t,Math.min(n,i));return i=1-1/255*Math.max(t,Math.max(n,i)),[s,r*100,i*100]}function Ji(e){const t=e[0]/255,n=e[1]/255,i=e[2]/255,s=Math.min(t,n,i),r=Math.max(t,n,i),o=r-s;let a,l;r===s?a=0:t===r?a=(n-i)/o:n===r?a=2+(i-t)/o:i===r&&(a=4+(t-n)/o),a=Math.min((a||0)*60,360),a<0&&(a+=360);const c=(s+r)/2;return r===s?l=0:c<=.5?l=o/(r+s):l=o/(2-r-s),[a,l*100,c*100]}function Of(e){const t=e[1]/100,i=1-e[2]/100,s=i-t;let r=0;return s<1&&(r=(i-s)/(1-s)),[e[0],s*100,r*100]}function Ff(e){const t=e[0]/360,n=e[1]/100,i=e[2]/100;if(n===0)return[i*255,i*255,i*255];const s=[0,0,0],r=t%1*6,o=r%1,a=1-o;let l=0;switch(Math.floor(r)){case 0:s[0]=1,s[1]=o,s[2]=0;break;case 1:s[0]=a,s[1]=1,s[2]=0;break;case 2:s[0]=0,s[1]=1,s[2]=o;break;case 3:s[0]=0,s[1]=a,s[2]=1;break;case 4:s[0]=o,s[1]=0,s[2]=1;break;default:s[0]=1,s[1]=0,s[2]=a}return l=(1-n)*i,[(n*s[0]+l)*255,(n*s[1]+l)*255,(n*s[2]+l)*255]}function Uv(e,t){const n=Ji(e.value);return n[2]+=n[2]*t,qi(`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`,e.value[3])}function zv(e,t){const n=Ji(e.value);return n[2]-=n[2]*t,qi(`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`,e.value[3])}function Gv(e,t){const n=Ji(e.value);return n[1]+=n[1]*t,qi(`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`,e.value[3])}function Vv(e,t){const n=Ji(e.value);return n[1]-=n[1]*t,qi(`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`,e.value[3])}function jv(e,t){const n=Ji(e.value);return n[2]=Math.min(100,Math.max(0,100*t)),qi(`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`,e.value[3])}function Hv(e,t){const n=Df(e.value);n[1]+=n[1]*t;const i=Ff(Of(n));return{type:"color",value:[i[0],i[1],i[2],e.value[3]||255]}}function $v(e,t){const n=Df(e.value);n[2]+=n[2]*t;const i=Ff(Of(n));return{type:"color",value:[i[0],i[1],i[2],e.value[3]||255]}}function Yv(e){const t=e.value,n=t[0]*.3+t[1]*.59+t[2]*.11;return{type:"color",value:[n,n,n,e.value[3]||255]}}function no(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 Dl(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 Ol(e){return Math.floor(e/256)}function Wv(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!==Ut.bomCharCode&&t.add(Ol(s))}}),Array.from(t)}function Zv(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 Xv(e){return typeof e!="string"?e:e.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}function qv(e,t){ke(`No glyph for character ${e} (code = ${t}, range = ${Ol(t)})`)}const Rf=new Set;function Jv(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 Nf(e){ke(`Got an empty response from the "${e}" tile generation.`)}function ke(e){Rf.has(e)||(console.log(e),Rf.add(e))}const Kv=2166136261,Qv=16777619;function Bf(e,t){let n=Kv;for(const i of t)n=n^i,n=n*Qv;e.randomSeed=Math.abs(n)}function Hs(e,t,n){let i=.5;return e.randomSeed?(e.randomSeed=e.randomSeed*16807%2147483647,i=(e.randomSeed-1)/2147483646):ke("Resolve 'random': random seed is absent, the mean value between start and end will be used."),i*(n-t)+t}function ew(e=128){const t=[],n=[];for(let i=0;i<e;i++)t.push(kf(i,2)),n.push(kf(i,3));return{base2:t,base3:n}}function kf(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 tw(e,t){const n=[];for(let i=0;i<t;i++){const s=Hs(e,0,2*Math.PI),r=Math.acos(Hs(e,0,2)-1),o=Math.sin(r)*Math.cos(s),a=Math.sin(r)*Math.sin(s),l=Math.cos(r);n.push(at(o,a,l))}return n}var tt=(e=>(e[e.Uniform=1]="Uniform",e[e.Labeling=2]="Labeling",e[e.Generator=3]="Generator",e))(tt||{});const io=-1;var $s=(e=>(e.global="global",e.none="none",e))($s||{}),Wn=(e=>(e[e.Pixels=0]="Pixels",e[e.Meters=1]="Meters",e))(Wn||{});const Uf="bottomCenter";function nt(e,t){for(const n in t)t[n]!==void 0&&(e[n]=t[n])}function nw(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,colorEffect:null,floorCulling:"all-floors"};if(nt(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(pn(n.textureSize))n.textureSize.length===1&&(n.textureSize=n.textureSize[0]);else return n;return n}function iw(e){const n={color:"#000000",textureImage:"",textureSize:16,textureOpacity:1,strokeColor:"#00000000",strokeWidth:1,nearCameraFade:2500,visibility:"visible",elevation:0};if(nt(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(pn(n.textureSize))n.textureSize.length===1&&(n.textureSize=n.textureSize[0]);else return n;return n}function sw(e){const t={iconImage:"",color:"#FFFFFF",rotation:0,width:1,visibility:"visible"};return nt(t,e),e.height===void 0&&(t.height=t.width),t}function rw(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:[],colorEffect:null,floorCulling:"all-floors"};return nt(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 ow(e){const t={color:"#000000",width:1,shift:0,geometryModifier:["geometry-modifier"],pattern:["pattern","none"],startCap:"round",endCap:"round",mode:"2d",visibility:"visible",floorCulling:"all-floors"};return nt(t,e),t}function aw(e){const t={color:"#000000",strokeColor:"#000000",strokeWidth:1,nearCameraFade:2500,visibility:"visible"};return nt(t,e),e.strokeColor===void 0&&(t.strokeColor=t.color),t}function lw(e){const t={sideColor:"#000000",strokeColor:"#000000",strokeWidth:1,sideStrokeColor:"#000000",height:0,visibility:"visible",nearCameraFade:2500};return nt(t,e),e.strokeColor===void 0&&(t.strokeColor=t.sideColor),e.sideStrokeColor===void 0&&(t.sideStrokeColor=t.sideColor),t}function cw(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:Xn,colorEffect:null,floorCulling:"all-floors"};return nt(t,e),t}function uw(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:Xn,colorEffect:null,floorCulling:"all-floors"};return nt(t,e),t}function dw(e){const t={color:"#000000",gapColor:"#00000000",width:1,shift:0,gapLength:1,dashLength:1,gapTurnsOnly:!1,geometryModifier:["geometry-modifier"],mode:"2d",visibility:"visible",floorCulling:"all-floors"};return nt(t,e),t}function fw(e){const t={color:"#000000",width:1,shift:0,visibility:"visible"};return nt(t,e),t}function hw(e){const t={color:"#ffffff",strokeColor:"#3388ff",strokeColor2:"#00000000",width:20,strokeWidth:3,strokeWidth2:0,visibility:"visible"};return nt(t,e),t}function pw(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:Xn,iconLabelingMargin:{topBottom:0,leftRight:0},textField:[["get","db_label"],["get","db_label2"]],textFont:"",textColor:"#000000",textFontSize:16,textLineHeight:1.2,textLetterSpacing:0,textPlacement:Uf,textOffset:0,textHaloColor:"rgba(0, 0, 0, 0)",textHaloWidth:0,textLabelingMargin:{topBottom:0,leftRight:0},textPriority:0,textMaxLengthPerLine:30,visibility:"visible",textLabelingGroup:Xn,duplicationSpacing:100,endingOffsets:0,floorCulling:"active-floor"};return nt(t,e),t}function mw(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),nt(t,e),t}function yw(e){const t={opacity:1,visibility:"visible"};return nt(t,e),t}function gw(e){return Nn(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 vw(e){return Nn(e,{shadingIntensity:["interpolate",["linear"],["zoom"],12,0,14.5,.7],verticalScale:1,shadingPalette:["interpolate",["linear"],["shading-intensity"],0,0,1,1],lightingDirection:322})}function ww(e){return Nn(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"],colorEffect:null,floorCulling:"all-floors"})}function bw(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 nt(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 Iw(e){const t={visibility:"visible",sideColor:"#000000",topColor:"#000000",bottomColor:"#000000",strokeColor:"#000000",strokeWidth:1,color:"#ffffff",nearCameraFade:0};return nt(t,e),t}function Mw(e){return Nn(e,{skyColor:"#6EC0FF00",fogColor:"#FAFDFF00",starsIntensity:1})}function Tw(e){const t={sources:{sun:{type:"directional",altitude:50,azimuth:230,color:"#FFFFFF",intensity:.2},atmosphere:{type:"ambient",color:"#FFFFFF",intensity:.85}},lightingModes:{[$s.global]:["sun","atmosphere"]},defaultLightingMode:"global"},n=Nn(e!=null?e:{},t);return n.lightingModes[$s.none]=[],n}function Sw(e){const t={light:{},normal:{},immersive:{}},n=Nn(e!=null?e:{},t);return n.light.transparentBuildingsOff=!0,n.light.AALinesOff=!0,n}const Zn="__overlapped",zf="__commercial",Xn="default",Fl={groups:[Xn,Zn,zf],overlay:[[Xn,Zn]],intersect:[[]]},Ew="#F5F2E0",Aw=3.5,xw=5,gi=e=>{e&&Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]})},_w=e=>{var t;gi(e),e.type==="group"?(gi(e.commonDefaults),gi((t=e.commonDefaults)==null?void 0:t.style),gi(e.layerTypeDefaults),e.layerTypeDefaults&&Object.values(e.layerTypeDefaults).forEach(n=>{gi(n),gi(n==null?void 0:n.style)})):e.type!=="custom"&&gi(e.style)},Rl=(e,t=!1)=>{t||console.warn("assertUnreachable: ",e)},vi=null,Gf=[0,0,0];function H(e,t){var n,i,s;if(!sn(e))return e;if(t.allowedExpressions&&!t.allowedExpressions.has(e.type))return ke(`Expression of type ${e.type} is not allowed here`),vi;switch(e.type){case"schedule":return jw(e,t);case"time":return Ow(e,t);case"object-attr":return Nw(e,t);case"coalesce":return jf(e,t);case"concat":return Fw(e,t);case"all":return Pw(e,t);case"any":return Dw(e,t);case"feature-state":return kw(e,t);case"get":return Yf(e,t);case"global":return Uw(e,t);case"source-attr":return Rw(e,t);case"in":return qw(e,t);case"has":return Jw(e,t);case"interpolate":return zw(e,t);case"match":return Gw(e,t);case"step":return Vw(e,t);case"to-boolean":return Yw(e,t);case"to-color":return Wf(e,t);case"mappoints-to-meters":return Hw(e,t);case"meters-to-pixels":return $w(e,t);case"!":return Ww(e,t);case"==":case"!=":return Zw(e,t);case">":case"<":case">=":case"<=":return Xw(e,t);case"zoom":if(t.type==="binder"||t.type==="labeling")return t.styleZoom;if(t.type==="generator")return(i=(n=t.tileInfo)==null?void 0:n.coords[3])!=null?i:0;const{type:r}=t;return Rl(r),vi;case"distance":if(t.type==="binder"){const a=oe.toGeo(t.objectCenter),l=oe.scaleFactor(a[1])*ve;return nl(t.objectCenter,t.cameraCenter)/l}else return ke(`Distance expression can't be resolved in the ${t.type} context`),vi;case"height":return 1;case"+":return Kw(e,t);case"*":return Qw(e,t);case"^":return e2(e,t);case"log10":return t2(e,t);case"random":return n2(e,t);case"literal-array":return i2(e,t);case"literal-object":return{type:"object",value:e.object};case"is-behind-objects":return t.type==="binder"?t.isBehind:(ke(`is-behind-objects expression cannot be used in ${t.type} context`),vi);case"geometry-modifier":return e.modifiers;case"line-pattern":return[e.patternType,...e.parameters.map(a=>H(a,t))];case"precompute":return(s=t.tileData[e.precomputeIndex])!=null?s:null;case"gltf-animation":return Hf(e,t);case"local-time":return Vf(e,t);case"utc-time":return Vf(e,t);case"texture-animation":return $f(e,t);case"easing":return e.options;case"mix":return Bw(e,t);case"vertex-color":return Lw(e,t);case"color-saturate":return gn(e,t,"saturate");case"color-desaturate":return gn(e,t,"desaturate");case"color-grayscale":return gn(e,t,"grayscale");case"color-lighten":return gn(e,t,"lighten");case"color-lightness":return gn(e,t,"lightness");case"color-darken":return gn(e,t,"darken");case"color-whiten":return gn(e,t,"whiten");case"color-blacken":return gn(e,t,"blacken");case"color-opacity":return gn(e,t,"opacity");case"color-effect":return Cw(e,t);default:return ke(`Not supported expression type <<${e.type}>> in ${JSON.stringify(e)}`),vi}}function Pw(e,t){return e.array.every(n=>H(n,t)===!0)}function Lw(e,t){if(t.type==="generator"){const i=H(e.vertexValue,t);if(yn(i))return i.isVertexColor=!0,i;const s=ct([0,0,0,0]);return s.isVertexColor=!0,s}const n=H(e.uniformValue,t);return yn(n)||to(n)?(n.mixFactor=e.mixValue?H(e.mixValue,t):1,n):ct([0,0,0,255],1)}function Cw(e,t){switch(e.effect.type){case"mix":return{type:"color-effect-options",effect:{type:e.effect.type,color:vn(e.effect.color,t),factor:ce(e.effect.factor,t)}}}}function Dw(e,t){return e.array.some(n=>H(n,t)===!0)}function Vf(e,t){const n=Date.now()+ +(t.styleState._customUserTimeOffset||0);if(e.type==="local-time"){const i=e.offset?+(H(e.offset,t)||0)*6e4:0;return n+i}if(e.type==="utc-time"){const i=e.offset?+(H(e.offset,t)||0)*6e4:0;return n+new Date().getTimezoneOffset()*6e4+i}return n}function Ow(e,t){const n=i=>{const s=H(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 jf(e,t){for(const n of e.array){const i=H(n,t);if(i!==null)return i}return null}function Fw(e,t){const n=[];for(const i of e.array){const s=H(i,t);if(typeof s=="string")n.push(s);else if(typeof s=="boolean")n.push(String(s));else if(typeof s=="number"&&!Number.isNaN(s))n.push(String(s));else return null}return n.join("")}function Rw(e,t){var n;return t.type==="generator"&&(n=t.sourceAttrs[e.property])!=null?n:null}function Nw(e,t){return t.type==="binder"&&t.dynamicObject&&t.dynamicObject[e.property]||null}function Hf(e,t){const n={type:"animation-options"};return e.options?e.options.forEach((i,s)=>n[s]=H(i,t)):sn(e)||(n[0]=e),n}function $f(e,t){const n={type:"texture-animation-options"};return e.options?e.options.forEach((i,s)=>n[s]=H(i,t)):sn(e)||(n[0]=e),n}function Bw(e,t){const{factorInterpolate:n}=e,i={type:"mix-options",value1:H(e.value1,t),value2:H(e.value2,t),factor:e.factor};if(n){const{steps:s,base:r}=n;i.factorInterpolate={base:r,steps:[ce(s[0].key,t,0),ce(s[0].value,t,0),ce(s[1].key,t,1),ce(s[1].value,t,1)]}}return i}function kw(e,t){var n;if(t.type==="generator"){const i=(n=t.featureAttrs[t.tileProps[e.property]])!=null?n:null;return Number.isNaN(i)?null:i}else throw new Error("Feature state expression can be resolved only in generator context")}function Yf(e,t){var n;if(t.type==="generator"){let i=(n=t.tileAttrs[t.tileProps[e.property]])!=null?n:null;return typeof i=="object"&&i!==null&&!Array.isArray(i)&&(i={type:"object",value:i}),Number.isNaN(i)?null:i}else throw new Error("Get expression can be resolved only in generator context")}function Uw(e,t){const n=t.styleState[e.property];return n==null?null:typeof n=="object"&&!Array.isArray(n)?{type:"object",value:n}:n}function zw(e,t){if(e.steps.length===0)return ke("Interpolate expression contains 0 steps, cannot interpolate"),vi;const n=H(e.steps[0].value,t),i=H(e.argument,t);if(typeof i!="number")return ke(`Interpolate value resolved to non-number value: ${i} ${e.argument}`),0;if(yn(n)){if(sn(e.argument)&&e.argument.type==="height"){const s={type:"gradient-color",values:[],steps:[]};return e.steps.forEach(r=>{const o=ce(r.key,t),a=H(r.value,t);yn(a)&&!Number.isNaN(o)&&(s.values.push({type:"color",value:a.value}),s.steps.push(o))}),s.steps.length!==2?(ke("Gradient expression must resolve 2 steps"),vi):s}return Xf(e,i,t)}return Zf(e,i,t)}function Gw(e,t){var s;const n=H(e.input,t),i=e.cases.find(r=>r.values.has(n));return H((s=i==null?void 0:i.output)!=null?s:e.defaultOutput,t)}function Vw(e,t){const n=Number(H(e.value,t)),i=Ws(e,n,t)-1;return H(e.steps[i].value,t)}function jw(e,t){var v,p;const s=(m,b)=>{const w=Date.now()+ +(b.styleState._customUserTimeOffset||0);return Math.floor(w/6e4)*6e4+m*6e4},r=e.detailResult||!1,o=m=>{if(t.type==="binder"&&t.callBackFn){const b=s(m,t);t.callBackFn(b)}};let a=H(e.steps,t);typeof a=="string"&&(a=JSON.parse(a));const l=new Array,c=new Array;if(Array.isArray(a)){l.push({key:0,value:a[0]});for(let m=1;m<a.length;m+=3){const w={key:Math.trunc(a[m]/1440)*1440,value:a[0]};c.push(w);const I={key:a[m],value:a[m+2]};l.push(I);const x={key:a[m+1],value:a[0]};l.push(x)}}for(const m of c)l.find(b=>b.key===m.key)||l.push(m);l.sort((m,b)=>m.key<b.key?-1:1);const u=Number(H(e.time,t)),d=new Date(u),f=d.getHours()*60+d.getMinutes()+(d.getDay()||7)*1440,h=Ws({steps:l},f%1440,t)-1,g=Ws({steps:l},f,t)-1;if(l[g]&&Math.trunc(l[g]&&l[g].key/1440)===Math.trunc(f/1440)){const m=Math.min((((v=l[g+1])==null?void 0:v.key)||11519)-f,1439-f%1440);o(m);const b=H(l[g].value,t)||NaN;return r?{type:"schedule-detailed-result",value:b,nextStepStartsAt:s(m,t),currentStepElapsed:(f-l[g].key)*6e4}:b}if(l[h]){const m=Math.min(((p=l[h+1])==null?void 0:p.key)||1439,1439)-f%1440;o(m);const b=H(l[h].value,t)||NaN;return r?{type:"schedule-detailed-result",value:b,nextStepStartsAt:s(m,t),currentStepElapsed:(f%1440-l[h].key)*6e4}:b}return r?{type:"schedule-detailed-result",value:NaN,nextStepStartsAt:NaN,currentStepElapsed:NaN}:NaN}function Wf(e,t){const n=H(e.value,t);if(Lf(n))return js(n);if(yn(n))return n;if(typeof n=="number"&&Number.isInteger(n)){const i=n>>>24&255,s=n>>>16&255,r=n>>>8&255,o=n&255;return ct([s,r,o,i])}return n&&console.warn(`Can't resolve expression. Must be color, but got ${n}`),ct([0,0,0,0])}function gn(e,t,n){const i=H(e.color,t),s=Wf({value:i},t);return a2(s,n,e.value)}function Hw(e,t){if(t.type!=="generator"||!t.tileInfo)throw new Error("Выражение `mappoints-to-meters` можно резолвить только в контексте генератора");return H(e.value,t)/(ve*Ct(t.tileInfo,[0,0]))}function $w(e,t){const n=ce(e.value,t);let i,s=n*256/qa;if(t.type==="generator"){if(!t.tileInfo)return null;i=t.tileInfo.coords[3],s*=Ct(t.tileInfo,[0,0])}else i=t.styleZoom;return s*le(2,i+1)}function Yw(e,t){return!!H(e.value,t)}function Ww(e,t){return!H(e.value,t)}function Zw(e,t){const n=H(e.leftValue,t),i=H(e.rightValue,t);switch(e.type){case"==":return n===i;case"!=":return n!==i}}function Xw(e,t){const n=H(e.leftValue,t);if(n===null)return null;const i=H(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 qw(e,t){const n=H(e.item,t),i=H(e.collection,t);return i===null?!1:typeof i!="object"?(ke(`InExpression second argument resolved to non-object/non-array value: ${i}`),null):Array.isArray(i)?i.some(s=>s===n):Af(i)?Object.prototype.hasOwnProperty.call(i.value,n):(ke(`InExpression second argument resolved incorrectly: ${i}`),null)}function Jw(e,t){if(t.type==="generator"){const n=t.tileProps[e.property];return n===void 0||!(n in t.tileAttrs)?!1:!Number.isNaN(t.tileAttrs[n])}else throw new Error("Has expression can be resolved only in generator context")}function Kw(e,t){const n=e.array.map(i=>H(i,t));return pn(n)?n.reduce((i,s)=>i+s,0):(ke(`Resolve AdditionExpression: arguments are not resolved as an array of numbers: ${n}`),null)}function Qw(e,t){const n=e.array.map(i=>H(i,t));return pn(n)?n.reduce((i,s)=>i*s,1):(ke(`Resolve MultiplicationExpression: arguments are not resolved as an array of numbers: ${n}`),null)}function e2(e,t){const n=H(e.base,t);if(typeof n!="number")return ke(`Resolve PowExpression: base resolved as non-number value: ${n}`),null;const i=H(e.exponent,t);return typeof i!="number"?(ke(`Resolve PowExpression: exponent resolved as non-number value: ${i}`),null):Math.pow(n,i)}function t2(e,t){const n=H(e.value,t);return typeof n!="number"?(ke(`Resolve Log10Expression: value resolved as non-number value: ${n}`),null):Math.log10(n)}function n2(e,t){const n=H(e.start,t);if(typeof n!="number")return ke(`Resolve RandomizationExpression: start resolved as non-number value: ${n}`),null;const i=H(e.end,t);return typeof i!="number"?(ke(`Resolve RandomizationExpression: end resolved as non-number value: ${i}`),null):i<n?(ke("Resolve RandomizationExpression: end cannot be less than start."),null):Hs(t,n,i)}function i2(e,t){return e.array.map(n=>H(n,t))}function Zf(e,t,n){const i=Ws(e,t,n);if(i===0)return Number(H(e.steps[0].value,n));if(i===e.steps.length)return r2(e,n,t);const s=Number(H(e.steps[i-1].value,n));if(n.type==="labeling"&&n.interpolateExpressionAsStep)return s;const r=Jf(e,t,i,n),o=Number(H(e.steps[i].value,n));return(1-r)*s+r*o}function vn(e,t,n=!1){const i=H(e,t);return yn(i)?i:to(i)?i.values[1]:_f(i)?yn(i.value1)&&yn(i.value2)?n?Ov(i):(console.warn("Mixing color is not supported here."),ct([0,0,0,0])):(console.warn(`Mix values cannot be converted to colors in ${JSON.stringify(i)}`),ct([0,0,0,0])):(console.warn(`Can't resolve expression. Must be color, but got ${i}`),ct([0,0,0,0]))}function s2(e,t){const n=H(e,t);return to(n)?n:null}function ce(e,t,n=NaN){const i=H(e,t);return typeof i=="number"?i:n}function ut(e,t,n=""){const i=H(e,t);return typeof i=="string"?i:n}function so(e,t,n=Uf){const i=H(e,t);return xv(i)?i:n}function Xf(e,t,n){const i=Ws(e,t,n);if(i===0)return vn(e.steps[0].value,n);if(i===e.steps.length)return vn(e.steps[e.steps.length-1].value,n);const s=Jf(e,t,i,n),r=vn(e.steps[i-1].value,n).value,o=vn(e.steps[i].value,n).value;return ct([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 r2(e,t,n){const i=e.steps[e.steps.length-1],s=e.base;return s===1?ce(i.value,t):ce(i.value,t)*Math.pow(s,n-ce(i.key,t))}function qf(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!=null?r:Gf,objectCenter:o!=null?o:Gf}}function Ht(e,t,n,i){return{type:"labeling",styleZoom:e,styleState:t,interpolateExpressionAsStep:n,randomSeed:0,tileData:i}}function Ys(e,t,n,i,s,r,o,a){return{type:"generator",styleState:e,tileProps:n,tileAttrs:i,id:r,tileData:[],featureAttrs:s,sourceAttrs:t,randomSeed:0,tileInfo:o,ecefDataState:a}}function Ws(e,t,n){let i=0;for(;i<e.steps.length&&!(t<ce(e.steps[i].key,n));)i++;return i}function Jf(e,t,n,i){const s=e.base,r=ce(e.steps[n].key,i)-ce(e.steps[n-1].key,i),o=t-ce(e.steps[n-1].key,i);return s===1?o/r:(Math.pow(s,o)-1)/(Math.pow(s,r)-1)}function o2(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 a2(e,t="",n){const[i,s,r,o]=e.value;switch(t){case"opacity":return ct([i,s,r,n]);case"saturate":return Gv(e,n);case"desaturate":return Vv(e,n);case"grayscale":return Yv(e);case"lighten":return Uv(e,n);case"darken":return zv(e,n);case"whiten":return Hv(e,n);case"blacken":return $v(e,n);case"lightness":return jv(e,n)}return{type:"color",value:[i,s,r,o]}}function ro(e){const[t,n,i,s]=e.value;return s<<24|i<<16|n<<8|t}function wi(e,t,n,i=!1){const s=[];return bi(s,e,t,n),i?s:Array.from(new Set(s))}function l2(e,t){const n={};return Object.keys(e).forEach(i=>{n[i]=c2(e[i],t)}),n}const Ki=Br();function Kf(e,t){const n=new Float32Array(3);return De(n,1,0,0),Cy(Ki),Fy(Ki,Ki,-Te(t-90)),Oy(Ki,Ki,-Te(e)),Qm(n,n,Ki),Kt(n,n),Nd(n,n),n}function c2(e,t){var i,s;const n={ambientColorIntensity:new Float32Array(vn(e.ambientColor,t).value.map(r=>r/255)),dir1ColorIntensity:new Float32Array(vn(e.dir1Color,t).value.map(r=>r/255)),dir1Direction:Kf(H(e.dir1Altitude,t),H(e.dir1Azimuth,t)),dir2ColorIntensity:new Float32Array(vn(e.dir2Color,t).value.map(r=>r/255)),dir2Direction:Kf(H(e.dir2Altitude,t),H(e.dir2Azimuth,t)),shadowLightIndex:(i=e.shadowLightIndex)!=null?i:-1,shadowRadius:(s=e.shadowRadius)!=null?s:1};return n.ambientColorIntensity[3]=H(e.ambientIntensity,t),n.dir1ColorIntensity[3]=H(e.dir1Intensity,t),n.dir2ColorIntensity[3]=H(e.dir2Intensity,t),n}function bi(e,t,n,i){if(!sn(t)){e.push(t);return}switch(t.type){case"all":return u2(e,t,n,i);case"match":return d2(e,t,n,i);case"step":return f2(e,t,n,i);case"interpolate":return h2(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=jf(t,n);e.push(s);return}case"precompute":if(i){const s=i.precomputes[t.precomputeIndex].expr;bi(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=Yf(t,n);e.push(s);return}}}function u2(e,t,n,i){t.array.forEach(s=>bi(e,s,n,i))}function d2(e,t,n,i){bi(e,t.defaultOutput),t.cases.forEach(s=>bi(e,s.output,n,i))}function f2(e,t,n,i){t.steps.forEach(s=>bi(e,s.value,n,i))}function h2(e,t,n,i){t.steps.forEach(s=>bi(e,s.value,n,i))}function Nl(e){return Ts*e}function Bl(e){return e/Ts}function p2(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 m2={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 y2(e){return m2[e]}function g2(e){return e!=="group"&&e!=="custom"}function v2(e){return e==="model"?"gltfModel":e!=="group"?e:void 0}function w2(){let e=new Tt(4);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e}function b2(e,t,n,i,s){return e[0]=t,e[1]=n,e[2]=i,e[3]=s,e}function I2(e){return e[0]*e[3]-e[2]*e[1]}var oo={exports:{}},ao={exports:{}},M2=ao.exports,Qf;function T2(){return Qf||(Qf=1,(function(e,t){(function(n,i){e.exports=i()})(M2,(function(){function n(o,a,l,c,u){i(o,a,l||0,c||o.length-1,u||r)}function i(o,a,l,c,u){for(;c>l;){if(c-l>600){var d=c-l+1,f=a-l+1,h=Math.log(d),g=.5*Math.exp(2*h/3),v=.5*Math.sqrt(h*g*(d-g)/d)*(f-d/2<0?-1:1),p=Math.max(l,Math.floor(a-f*g/d+v)),m=Math.min(c,Math.floor(a+(d-f)*g/d+v));i(o,a,p,m,u)}var b=o[a],w=l,I=c;for(s(o,l,a),u(o[c],b)>0&&s(o,l,c);w<I;){for(s(o,w,I),w++,I--;u(o[w],b)<0;)w++;for(;u(o[I],b)>0;)I--}u(o[l],b)===0?s(o,l,I):(I++,s(o,I,c)),I<=a&&(l=I+1),a<=I&&(c=I-1)}}function s(o,a,l){var c=o[a];o[a]=o[l],o[l]=c}function r(o,a){return o<a?-1:o>a?1:0}return n}))})(ao)),ao.exports}var eh;function S2(){if(eh)return oo.exports;eh=1,oo.exports=t,oo.exports.default=t;var e=T2();function t(p,m){if(!(this instanceof t))return new t(p,m);this._maxEntries=Math.max(4,p||9),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),m&&this._initFormat(m),this.clear()}t.prototype={all:function(){return this._all(this.data,[])},search:function(p){var m=this.data,b=[],w=this.toBBox;if(!h(p,m))return b;for(var I=[],x,E,C,T;m;){for(x=0,E=m.children.length;x<E;x++)C=m.children[x],T=m.leaf?w(C):C,h(p,T)&&(m.leaf?b.push(C):f(p,T)?this._all(C,b):I.push(C));m=I.pop()}return b},collides:function(p){var m=this.data,b=this.toBBox;if(!h(p,m))return!1;for(var w=[],I,x,E,C;m;){for(I=0,x=m.children.length;I<x;I++)if(E=m.children[I],C=m.leaf?b(E):E,h(p,C)){if(m.leaf||f(p,C))return!0;w.push(E)}m=w.pop()}return!1},load:function(p){if(!(p&&p.length))return this;if(p.length<this._minEntries){for(var m=0,b=p.length;m<b;m++)this.insert(p[m]);return this}var w=this._build(p.slice(),0,p.length-1,0);if(!this.data.children.length)this.data=w;else if(this.data.height===w.height)this._splitRoot(this.data,w);else{if(this.data.height<w.height){var I=this.data;this.data=w,w=I}this._insert(w,this.data.height-w.height-1,!0)}return this},insert:function(p){return p&&this._insert(p,this.data.height-1),this},clear:function(){return this.data=g([]),this},remove:function(p,m){if(!p)return this;for(var b=this.data,w=this.toBBox(p),I=[],x=[],E,C,T,D;b||I.length;){if(b||(b=I.pop(),C=I[I.length-1],E=x.pop(),D=!0),b.leaf&&(T=n(p,b.children,m),T!==-1))return b.children.splice(T,1),I.push(b),this._condense(I),this;!D&&!b.leaf&&f(b,w)?(I.push(b),x.push(E),E=0,C=b,b=b.children[0]):C?(E++,b=C.children[E],D=!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,m){for(var b=[];p;)p.leaf?m.push.apply(m,p.children):b.push.apply(b,p.children),p=b.pop();return m},_build:function(p,m,b,w){var I=b-m+1,x=this._maxEntries,E;if(I<=x)return E=g(p.slice(m,b+1)),i(E,this.toBBox),E;w||(w=Math.ceil(Math.log(I)/Math.log(x)),x=Math.ceil(I/Math.pow(x,w-1))),E=g([]),E.leaf=!1,E.height=w;var C=Math.ceil(I/x),T=C*Math.ceil(Math.sqrt(x)),D,B,k,j;for(v(p,m,b,T,this.compareMinX),D=m;D<=b;D+=T)for(k=Math.min(D+T-1,b),v(p,D,k,C,this.compareMinY),B=D;B<=k;B+=C)j=Math.min(B+C-1,k),E.children.push(this._build(p,B,j,w-1));return i(E,this.toBBox),E},_chooseSubtree:function(p,m,b,w){for(var I,x,E,C,T,D,B,k;w.push(m),!(m.leaf||w.length-1===b);){for(B=k=1/0,I=0,x=m.children.length;I<x;I++)E=m.children[I],T=l(E),D=u(p,E)-T,D<k?(k=D,B=T<B?T:B,C=E):D===k&&T<B&&(B=T,C=E);m=C||m.children[0]}return m},_insert:function(p,m,b){var w=this.toBBox,I=b?p:w(p),x=[],E=this._chooseSubtree(I,this.data,m,x);for(E.children.push(p),r(E,I);m>=0&&x[m].children.length>this._maxEntries;)this._split(x,m),m--;this._adjustParentBBoxes(I,x,m)},_split:function(p,m){var b=p[m],w=b.children.length,I=this._minEntries;this._chooseSplitAxis(b,I,w);var x=this._chooseSplitIndex(b,I,w),E=g(b.children.splice(x,b.children.length-x));E.height=b.height,E.leaf=b.leaf,i(b,this.toBBox),i(E,this.toBBox),m?p[m-1].children.push(E):this._splitRoot(b,E)},_splitRoot:function(p,m){this.data=g([p,m]),this.data.height=p.height+1,this.data.leaf=!1,i(this.data,this.toBBox)},_chooseSplitIndex:function(p,m,b){var w,I,x,E,C,T,D,B;for(T=D=1/0,w=m;w<=b-m;w++)I=s(p,0,w,this.toBBox),x=s(p,w,b,this.toBBox),E=d(I,x),C=l(I)+l(x),E<T?(T=E,B=w,D=C<D?C:D):E===T&&C<D&&(D=C,B=w);return B},_chooseSplitAxis:function(p,m,b){var w=p.leaf?this.compareMinX:o,I=p.leaf?this.compareMinY:a,x=this._allDistMargin(p,m,b,w),E=this._allDistMargin(p,m,b,I);x<E&&p.children.sort(w)},_allDistMargin:function(p,m,b,w){p.children.sort(w);var I=this.toBBox,x=s(p,0,m,I),E=s(p,b-m,b,I),C=c(x)+c(E),T,D;for(T=m;T<b-m;T++)D=p.children[T],r(x,p.leaf?I(D):D),C+=c(x);for(T=b-m-1;T>=m;T--)D=p.children[T],r(E,p.leaf?I(D):D),C+=c(E);return C},_adjustParentBBoxes:function(p,m,b){for(var w=b;w>=0;w--)r(m[w],p)},_condense:function(p){for(var m=p.length-1,b;m>=0;m--)p[m].children.length===0?m>0?(b=p[m-1].children,b.splice(b.indexOf(p[m]),1)):this.clear():i(p[m],this.toBBox)},_initFormat:function(p){var m=["return a"," - b",";"];this.compareMinX=new Function("a","b",m.join(p[0])),this.compareMinY=new Function("a","b",m.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,m,b){if(!b)return m.indexOf(p);for(var w=0;w<m.length;w++)if(b(p,m[w]))return w;return-1}function i(p,m){s(p,0,p.children.length,m,p)}function s(p,m,b,w,I){I||(I=g(null)),I.minX=1/0,I.minY=1/0,I.maxX=-1/0,I.maxY=-1/0;for(var x=m,E;x<b;x++)E=p.children[x],r(I,p.leaf?w(E):E);return I}function r(p,m){return p.minX=Math.min(p.minX,m.minX),p.minY=Math.min(p.minY,m.minY),p.maxX=Math.max(p.maxX,m.maxX),p.maxY=Math.max(p.maxY,m.maxY),p}function o(p,m){return p.minX-m.minX}function a(p,m){return p.minY-m.minY}function l(p){return(p.maxX-p.minX)*(p.maxY-p.minY)}function c(p){return p.maxX-p.minX+(p.maxY-p.minY)}function u(p,m){return(Math.max(m.maxX,p.maxX)-Math.min(m.minX,p.minX))*(Math.max(m.maxY,p.maxY)-Math.min(m.minY,p.minY))}function d(p,m){var b=Math.max(p.minX,m.minX),w=Math.max(p.minY,m.minY),I=Math.min(p.maxX,m.maxX),x=Math.min(p.maxY,m.maxY);return Math.max(0,I-b)*Math.max(0,x-w)}function f(p,m){return p.minX<=m.minX&&p.minY<=m.minY&&m.maxX<=p.maxX&&m.maxY<=p.maxY}function h(p,m){return m.minX<=p.maxX&&m.minY<=p.maxY&&m.maxX>=p.minX&&m.maxY>=p.minY}function g(p){return{children:p,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function v(p,m,b,w,I){for(var x=[m,b],E;x.length;)b=x.pop(),m=x.pop(),!(b-m<=w)&&(E=m+Math.ceil((b-m)/w/2)*w,e(p,E,m,b,I),x.push(m,E,E,b))}return oo.exports}var E2=S2();const lo=Al(E2);var kl,th;function A2(){if(th)return kl;th=1,kl=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 kl}var Ul,nh;function x2(){if(nh)return Ul;nh=1,Ul=n;var e=128,t=127;function n(i,o){var r=0,o=o||0,a=0,l=o,c,u=i.length;do{if(l>=u||a>49)throw n.bytes=0,new RangeError("Could not decode varint");c=i[l++],r+=a<28?(c&t)<<a:(c&t)*Math.pow(2,a),a+=7}while(c>=e);return n.bytes=l-o,r}return Ul}var zl,ih;function _2(){if(ih)return zl;ih=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),l=Math.pow(2,63);return zl=function(c){return c<e?1:c<t?2:c<n?3:c<i?4:c<s?5:c<r?6:c<o?7:c<a?8:c<l?9:10},zl}var Gl,sh;function P2(){return sh||(sh=1,Gl={encode:A2(),decode:x2(),encodingLength:_2()}),Gl}var L2=P2();const rh=Al(L2);class oh{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(){var n;const t=rh.decode(this.buf,this.pos);return this.pos+=(n=rh.decode.bytes)!=null?n:0,t}readSVarint(){const t=this.readVarint();return t%2===1?(t+1)/-2:t/2}skip(t){this.pos+=t}}function C2(e){const t=new oh(e);t.readUint32(),t.readUint16(),t.readUint16(),t.readUint16(),t.readUint16();const n=Vl(t.readInt32()),i=Vl(t.readInt32()),s=t.readUint32(),r=[];for(let o=0;o<s;o++){const a=t.readUint32(),l=new Uint16Array(a*2);for(let v=0;v<a;v++)l[v*2]=t.readUint16(),l[v*2+1]=t.readUint16();const c=new Float32Array(a);ah(t,c,a,Vl);const u=t.readUint32(),d=a>Ze?new Uint32Array(u):new Uint16Array(u);ah(t,d,u);const f={positions:l,heights:c,indices:d},h=t.readUint32();if(h>0){const v=[];new Int8Array(t.readBytes(h*3)).forEach(p=>v.push(D2(p)))}const g=t.readUint32();if(g>0){const v={};for(let p=0;p<g;p++){const m=t.readUint16(),b=t.readInt32();v[m]=b}f.attributes=v}r.push(f)}return{dataGroups:r,minZ:n,maxZ:i}}function ah(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 Vl(e){return e/ve}function D2(e){return e/127}function O2(e){const t=new Vr(e),n=jl(t.readFixed32()),i=jl(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 d=0;d<s;d++)a[d]=jl(t.readSVarint());let l=0;const c=t.readFixed32(),u=s>Ze?new Uint32Array(c):new Uint16Array(c);for(let d=0;d<c;d++){const f=t.readSVarint(),h=l+f;l+=f,u[d]=h}return{dataGroups:[{positions:o,heights:a,indices:u}],minZ:n,maxZ:i}}function jl(e){return e/100}function F2(e){const t=Math.log(e)*256;return t+(t<0?-.5:.5)<<16>>16}function St(e){return e*32768+.5<<16>>>16}function R2(e){return Math.log(e)*256+.5<<16>>16}let N2=0;function Zs(){return N2++}const Xs=Zs(),Hl=Zs(),lh=128,Ot={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",Ot.sinks.mesh2.packObjectAttributes(n,i),Ot.sinks.mesh2.binder);U2(s,t)},generateHillshade(e,t,n,i){const s=new Uint16Array(t.reduce((o,a)=>{const[l,c,u,d]=a;return o.push(l*ne,c*ne,St(u),St(d)),o},[]));return{symbol:Ot.symbol,sink:"hillshade",buffer:s.buffer,generatedObjects:[{drawMode:Mr,attributes:Ot.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],l=n[0].length,c=Ot.sinks.flatBottom.packObjectAttributes(t,Xs,r),u=e.getBucket("dem","flatBottom",c,Ot.sinks.flatBottom.binder);B2(u,l,o,a,i,s,!!r)}};function B2(e,t,n,i,s,r,o){let a=e.elements.offset;const l=a;if(!(t<3)){$l(e,a++,n[0],i[0],r,s[0],o),$l(e,a++,n[1],i[1],r,s[1],o);for(let c=2;c<t;c++)k2(e,l,c),$l(e,a++,n[c],i[c],r,s[c],o);e.elements.offset=a}}function $l(e,t,n,i,s,r,o){const a=t*(e.elements.stride/e.views.position.BYTES_PER_ELEMENT),l=t*(e.elements.stride/e.views.extender.BYTES_PER_ELEMENT);e.views.position[a]=o?n:V+n,e.views.position[a+1]=o?i:V+i,e.views.demPosition[a]=(o?s[0]:V+s[0])/8,e.views.demPosition[a+1]=(o?s[1]:V+s[1])/8,e.views.extender[l]=r[0]*127,e.views.extender[l+1]=r[1]*127}function k2(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 U2(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]=V+(n?ch(o):o),e.views.position[r+1]=V+(n?ch(a):a);const l=e.elements.offset*(e.elements.stride/e.views.height.BYTES_PER_ELEMENT);e.views.height[l]=t.heights[s],e.elements.offset++,e.indices.buffer[e.indices.offset]=i,e.indices.offset++}}function ch(e){return e===0?e-=lh:e===ne&&(e+=lh),e}const z2=(()=>{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 G2(e,t){const n=new oh(e),i=[];return uh(n,t,i),i}function uh(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 l=e.readUint8(),c=(l&1)===1,u=l>>1;for(let d=0;d<u;d++)c?V2(e,t,n):uh(e,t,n)}function V2(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(),l=e.readUint8(),c=e.readUint8();n.push({posOffset:a,bucketIndex:l,batchIndex:c,minX:i,minY:s,maxX:r,maxY:o})}const qs=ot(),dh=ot(),j2=Oe(),H2=Oe(),fh=w2(),$2=64,hh=9,ph=(e,t,n,i,s)=>{const r=Fs(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 Y2(e){const t=[];return e.forEach((n,i)=>{n.symbol!=="dem"||n.sink!=="mesh2"||n.generatedObjects.forEach((s,r)=>{const o=Ot.sinks.mesh2.stride/Uint16Array.BYTES_PER_ELEMENT,a=new Uint16Array(n.buffer,s.rangeStart,(s.rangeEnd-s.rangeStart)/Uint16Array.BYTES_PER_ELEMENT);for(let l=0;l<a.length;l+=o*3){const c=l,u=l+o,d=l+o*2;t.push({minX:Math.min(a[c],a[u],a[d])-V,maxX:Math.max(a[c],a[u],a[d])-V,minY:Math.min(a[c+1],a[u+1],a[d+1])-V,maxY:Math.max(a[c+1],a[u+1],a[d+1])-V,posOffset:l,bucketIndex:i,batchIndex:r})}})}),t.length?z2(lo(hh).load(t)):null}function Yl(e,t,n){const i=n/(Float32Array.BYTES_PER_ELEMENT/Uint16Array.BYTES_PER_ELEMENT);return[e[n]-V,e[n+1]-V,t[i]]}function W2(e,t){var l;if(!e.tree)return;const n=De(qs,t[0],t[1],0),i=vl(e.key),s=gt(i),r=new Uint16Array(3),o=Ot.sinks.mesh2.stride/Uint16Array.BYTES_PER_ELEMENT;Lt(r,n,s);const a=G2(e.tree,r);for(const c of a){const u=(l=e.generated[0])==null?void 0:l.collectorOutput.data[c.bucketIndex];if(!u||u.sink!=="mesh2")continue;const d=u.generatedObjects[c.bucketIndex],f=new Uint16Array(u.buffer,d.rangeStart,(d.rangeEnd-d.rangeStart)/Uint16Array.BYTES_PER_ELEMENT),h=new Float32Array(u.buffer,d.rangeStart+4,(d.rangeEnd-d.rangeStart)/Float32Array.BYTES_PER_ELEMENT-1),g=Yl(f,h,c.posOffset),v=Yl(f,h,c.posOffset+o),p=Yl(f,h,c.posOffset+o*2),m=Z2(g,v,p,r,qs);if(!m)continue;return g[2]*m[0]+v[2]*m[1]+p[2]*m[2]}}function Z2(e,t,n,i,s){const r=Wl(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 c=null;if(Zl(e,t,i)){const u=co(e,t,i);c=li(qs,e,t,u),s[0]=1-u,s[1]=u,s[2]=0}if(Zl(t,n,i)){const u=co(t,n,i),d=li(dh,t,n,u);(!c||d[2]>c[2])&&(s[0]=0,s[1]=1-u,s[2]=u,c||(c=qs),el(c,d))}if(Zl(n,e,i)){const u=co(n,e,i),d=li(dh,n,e,u);(!c||d[2]>c[2])&&(s[0]=u,s[1]=0,s[2]=1-u,c||(c=qs),el(c,d))}if(c)return s}const o=Wl(i,t,n)/r,a=Wl(i,n,e)/r,l=1-o-a;return o<0||a<0||l<0||o>1||a>1||l>1?null:(s[0]=o,s[1]=a,s[2]=l,s)}function Wl(e,t,n){return b2(fh,t[0]-e[0],n[0]-e[0],t[1]-e[1],n[1]-e[1]),I2(fh)}function Zl(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 co(e,t,n){const i=fn(j2,t,e),s=fn(H2,n,e);return kn(s,i)/Am(i)}function X2(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?C2(e):O2(e),{positions:r,heights:o,indices:a}=n[0];return{positions:r,heights:o,indices:a,maxZ:s,minZ:i}}function Xl(e,t,n,i,s){const r=Bl(s);wi(i.textureImage).forEach(o=>{if(!o.length)return;const a=n.byKey[eo(o)];if(!a){console.error(`Not found raster set with texture ${o}`);return}const l=q2(i.textureSize),c=i.lengthUnits===Wn.Meters;l.forEach(u=>{let[d,f]=Array.isArray(u)?u:[u,u];c&&(d=d*Kr(d,d),f=f*Kr(f,f)),a.isSvg?e.atlasPacker.packSvg(a,[{w:d,h:f}],r):e.atlasPacker.packPng(a,[{w:d,h:f}],r),a.rasters.forEach(h=>e.atlasPacker.addRastersToLoad(t,h))})})}function q2(e){return sn(e)?e.type==="step"?e.steps.map(t=>Array.isArray(t.value)||typeof t.value=="number"?t.value:t.value.type==="literal-array"?t.value.array:(console.warn("textureSize only supports shallow step expression"),[0])):e.type==="literal-array"?[st(e)]:(ke(`Unsupported texture size expression of type "${e.type}". Can't resovle.`),[0]):[e]}function ql(e,t){var g,v,p,m,b;const{tileAttrs:n,tileProps:i}=e,s=Number.isNaN(n[i.db_begin_nominal_height])?0:(g=n[i.db_begin_nominal_height])!=null?g:0,r=Number.isNaN(n[i.db_end_nominal_height])?0:(v=n[i.db_end_nominal_height])!=null?v:0,o=(p=n[i.objectLength])!=null?p:1,a=(m=n[i.componentDistanceStart])!=null?m:0,l=(b=n[i.componentDistanceEnd])!=null?b:0,c=Ni(s,r,a/o),u=Ni(s,r,l/o),d=e.tileInfo?Ct(e.tileInfo,[0,0]):1,f=Array.from({length:t.x.length});if(c===u)return f.fill(c*ve*d),f;const h=t.x.length;for(let w=0;w<h;w++)f[w]=ve*d*Ni(c,u,co([t.x[0],t.y[0]],[t.x[h-1],t.y[h-1]],[t.x[w],t.y[w]]));return f}const Jl=e=>{for(let t=0;t<e.length;t++)if(e[t]!==0)return!0;return!1},uo=(e,t)=>!!e.globeEnabled&&t!==void 0&&t.coords[2]<Rn.globeMaxZoom,wn=e=>le(2,15)+e*km,rn=(e,t,n)=>{const[i,s,r]=ev(e,[t,n]);return{x:wn(i),y:wn(s),z:wn(r)}};function Qi(e){return e-32768}function es(e){return e+32768}function mh(e){return Math.max(-32768,Math.min(32767,Math.round(e)))}const $t=1,Yt=-1,Wt=[.5,.5],Ft=[.5,.5],Se=[.5,.5],ts=[.5,.5],Kl=[0,0];let Et,we,be,Ee=0,At=0,Ke=0,rt=0;const J2={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]},K2=1-1e-4,Q2=0,yh=-.9;function eb(e,t,n,i,s,r,o,a){const l=J2;l.x=e,l.y=t,l.z=n,l.xn2=i,l.yn2=s,l.xn1=r,l.yn1=o,l.patternedLine=a;const c=i*r+s*o;return be.globeMode?l.noTurn=!1:l.noTurn=c>K2,l.leftTurn=i*-o+s*r<0,l.sharpTurn=c<Q2&&c>yh,l.reverseTurn=c<yh,l}function fo(e,t,n,i,s,r,o,a,l,c,u,d,f=!1){var B,k,j,U,A,M,S;let h,g,v,p,m,b,w,I,x,E,C,T,D;if(i!==0)if(be=u,we=d,Et=we.indices,At=we.elements.offset,Ee=0,Ke=0,rt=0,e[0],t[0],i===1)h=e[0],g=t[0],v=(B=n==null?void 0:n[0])!=null?B:0,D=0,bn(Et,At,0,2,1,1,2,3),_e(we,be,0,h,g,v,1,-1,1,-1,D,!1,Yt),_e(we,be,0,h,g,v,-1,-1,-1,-1,D,!1,$t),_e(we,be,0,h,g,v,1,1,1,1,D,!1,Yt),_e(we,be,0,h,g,v,-1,1,-1,1,D,!1,$t),Ee=Ee+4;else{switch(p=e[0],m=t[0],b=(k=n==null?void 0:n[0])!=null?k:0,w=e[1],I=t[1],x=(j=n==null?void 0:n[1])!=null?j:0,D=f?be.cDist:0,s){case ge.TileCut:Vt(Wt,p,m,o,a),Vt(Se,w,I,p,m),T=Ql(w,I,x,Wt[0],Wt[1],Se[0],Se[1],f),T.noTurn?gh(p,m,b,Se[0],Se[1],D):ho(0,p,m,b,Wt[0],Wt[1],Se[0],Se[1],D,f);break;case ge.Butt:case ge.Round:Vt(Se,w,I,p,m),gh(p,m,b,Se[0],Se[1],D),s===ge.Round&&ho(0,p,m,b,Se[0],Se[1],Se[0],Se[1],D,f);break;default:throw new Error("LoftedLine: unknown Ending Type")}const L=i-1;for(let O=1;O<L;O++){p=e[O-1],m=t[O-1],b=(U=n==null?void 0:n[O-1])!=null?U:0,w=e[O],I=t[O],x=(A=n==null?void 0:n[O])!=null?A:0,E=e[O+1],C=t[O+1];const N=w-p,R=I-m;D+=Math.sqrt(N*N+R*R)/ne,Vt(Wt,w,I,p,m),Vt(Se,E,C,w,I),ho(O,w,I,x,Wt[0],Wt[1],Se[0],Se[1],D,f)}p=e[i-2],m=t[i-2],b=(M=n==null?void 0:n[i-2])!=null?M:0,w=e[L],I=t[L],x=(S=n==null?void 0:n[L])!=null?S:0;const _=w-p,F=I-m;switch(D+=Math.sqrt(_*_+F*F)/ne,r){case ge.TileCut:Vt(Wt,w,I,p,m),Vt(Se,l,c,w,I),T=Ql(w,I,x,Wt[0],Wt[1],Se[0],Se[1],f),T.noTurn?vh(L,w,I,x,Se[0],Se[1],D):wh(L,D,T);break;case ge.Butt:case ge.Round:Vt(Se,w,I,p,m),vh(L,w,I,x,Se[0],Se[1],D),r===ge.Round&&ho(L,w,I,x,Se[0],Se[1],-Se[0],-Se[1],D,f);break;default:throw new Error("LoftedLine: unknown Ending Type")}}}function Ql(e,t,n,i,s,r,o,a){const l=eb(e,t,n,i,s,r,o,a);if(!l.noTurn&&!l.reverseTurn){$d(Ft,i,s,r,o);const c=Ft[0],u=Ft[1];l.extender[0]=c,l.extender[1]=u,l.faExtender[0]=c-i*2,l.faExtender[1]=u-s*2,l.saExtender[0]=c-r*2,l.saExtender[1]=u-o*2}else l.extender[0]=0,l.extender[1]=0,l.faExtender[0]=0,l.faExtender[1]=0,l.saExtender[0]=0,l.saExtender[1]=0;return l}function ec(e,t,n,i,s,r,o,a,l,c){$d(Ft,s,r,o,a),s*-a+r*o<0?_e(we,be,e,t,n,i,-Ft[0],-Ft[1],-Ft[0],-Ft[1],l,!1,c):_e(we,be,e,t,n,i,Ft[0],Ft[1],Ft[0],Ft[1],l,!1,c),Ee++}function ho(e,t,n,i,s,r,o,a,l,c){const u=Ql(t,n,i,s,r,o,a,c);wh(e,l,u),tb(e,l,u),nb(e,l,u)}function gh(e,t,n,i,s,r){_e(we,be,0,e,t,n,-i,-s,-i,-s,r,!1,$t),_e(we,be,0,e,t,n,i,s,i,s,r,!1,Yt),Ee=Ee+2,Ke=1,rt=0}function vh(e,t,n,i,s,r,o){const a=Ee+1,l=Ee;_e(we,be,e,t,n,i,-s,-r,-s,-r,o,!1,$t),_e(we,be,e,t,n,i,s,r,s,r,o,!1,Yt),Ee=Ee+2,bn(Et,At,rt,l,Ke,Ke,l,a),Ke=a,rt=l}function tb(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=rt,r=Ke):n.leftTurn?(s=Ke,r=Ee+i):(s=Ee+i,r=rt);const o=Ee;if(tc(Et,At,Ke,rt,o),n.sharpTurn){const l=Ee+1;n.leftTurn?bn(Et,At,o,l,s,s,l,r):bn(Et,At,o,r,l,l,r,s)}else n.leftTurn,tc(Et,At,o,r,s);const a=n.leftTurn?$t:Yt;n.sharpTurn?(n.leftTurn?Vt(ts,n.xn2,n.yn2,n.xn1,n.yn1):Vt(ts,n.xn1,n.yn1,n.xn2,n.yn2),ec(e,n.x,n.y,n.z,n.xn2,n.yn2,ts[0],ts[1],t,a),ec(e,n.x,n.y,n.z,ts[0],ts[1],n.xn1,n.yn1,t,a)):ec(e,n.x,n.y,n.z,n.xn2,n.yn2,n.xn1,n.yn1,t,a),n.reverseTurn||(n.leftTurn?_e(we,be,e,n.x,n.y,n.z,-n.xn1,-n.yn1,-n.xn1,-n.yn1,t,!1,a):_e(we,be,e,n.x,n.y,n.z,n.xn1,n.yn1,n.xn1,n.yn1,t,!1,a),Ee++),rt=r,Ke=s}function wh(e,t,n){if(n.noTurn)return;const i=Ee+1,s=Ee;if(n.reverseTurn||n.patternedLine&&n.sharpTurn?(_e(we,be,e,n.x,n.y,n.z,-n.xn2,-n.yn2,-n.xn2,-n.yn2,t,!1,$t),_e(we,be,e,n.x,n.y,n.z,n.xn2,n.yn2,n.xn2,n.yn2,t,!1,Yt)):n.leftTurn?(_e(we,be,e,n.x,n.y,n.z,-n.xn2,-n.yn2,n.faExtender[0],n.faExtender[1],t,!0,$t),_e(we,be,e,n.x,n.y,n.z,n.xn2,n.yn2,n.extender[0],n.extender[1],t,!0,Yt)):(_e(we,be,e,n.x,n.y,n.z,-n.xn2,-n.yn2,-n.extender[0],-n.extender[1],t,!0,$t),_e(we,be,e,n.x,n.y,n.z,n.xn2,n.yn2,-n.faExtender[0],-n.faExtender[1],t,!0,Yt)),Ee=Ee+2,bn(Et,At,rt,s,Ke,Ke,s,i),rt=s,Ke=i,!n.patternedLine&&!n.reverseTurn){const r=Ee+1,o=Ee;n.leftTurn?(_e(we,be,e,n.x,n.y,n.z,-n.xn2,-n.yn2,-n.xn2,-n.yn2,t,!1,0),_e(we,be,e,n.x,n.y,n.z,0,0,0,0,t,!1,0),bn(Et,At,i,s,r,r,s,o)):(_e(we,be,e,n.x,n.y,n.z,0,0,0,0,t,!1,0),_e(we,be,e,n.x,n.y,n.z,n.xn2,n.yn2,n.xn2,n.yn2,t,!1,0),bn(Et,At,s,o,i,i,o,r)),Ee=Ee+2,rt=o,Ke=r}}function nb(e,t,n){if(n.noTurn||n.reverseTurn)return;const i=Ee+1,s=Ee;if(n.patternedLine&&n.sharpTurn){_e(we,be,e,n.x,n.y,n.z,-n.xn1,-n.yn1,-n.xn1,-n.yn1,t,!1,$t),_e(we,be,e,n.x,n.y,n.z,n.xn1,n.yn1,n.xn1,n.yn1,t,!1,Yt),Ee=Ee+2,rt=s,Ke=i;return}else n.leftTurn?(_e(we,be,e,n.x,n.y,n.z,-n.xn1,-n.yn1,n.saExtender[0],n.saExtender[1],t,!1,$t),_e(we,be,e,n.x,n.y,n.z,n.xn1,n.yn1,n.extender[0],n.extender[1],t,!1,Yt)):(_e(we,be,e,n.x,n.y,n.z,-n.xn1,-n.yn1,-n.extender[0],-n.extender[1],t,!1,$t),_e(we,be,e,n.x,n.y,n.z,n.xn1,n.yn1,-n.saExtender[0],-n.saExtender[1],t,!1,Yt));Ee=Ee+2,n.leftTurn?bn(Et,At,rt,s,Ke,Ke,s,i):bn(Et,At,Ke,rt,i,i,rt,s),rt=s,Ke=i}function _e(e,t,n,i,s,r,o,a,l,c,u,d,f){const h=e.elements.offset*t.offsetMultiplier,g=h>>1,v=h<<1;if(t.globeMode&&t.tileInfo){const{x:p,y:m,z:b}=rn(t.tileInfo,i,s);e.views.position[h]=p,e.views.position[h+1]=m,e.views.position[h+2]=b}else e.views.position[h]=V+i,e.views.position[h+1]=V+s;if(e.views.extender[h]=Math.floor(l*Be*127+.5),e.views.extender[h+1]=Math.floor(c*Be*127+.5),t.type===mi.Patterned){const p=e,m=1e-5;p.views.texture[g]=(m+u)*Math.sign(f)}else if(t.type===mi.Striped){const p=e;p.views.texExtender[v]=$e(o*Be),p.views.texExtender[v+1]=$e(a*Be),p.views.vertexDistance[g]=u,p.views.objectLength[g]=t.oLen,"componentDistance"in e.views&&(e.views.componentDistance[g]=t.cDist)}else if(t.type===mi.Entrance){const p=e,{px:m,py:b,count:w}=t,I=n===0,x=n===w-1,E=I?n:n-1,C=I?n+1:n;nn(Kl,m[E],b[E],m[C],b[C]),p.views.direction[h]=Math.round(Kl[0]*127),p.views.direction[h+1]=Math.round(Kl[1]*127),p.views.type[g]=x?Bs.LineEnding:Bs.Line,p.views.texExtender[v]=$e(o*(d||x?-1:1)*Be),p.views.texExtender[v+1]=$e(a*(d||x?-1:1)*Be),p.views.vertexDistance[g]=u,p.views.objectLength[g]=t.oLen}e.views.localID[g]=t.localID,"height"in e.views&&(e.views.height[g]=r),e.elements.offset++}function tc(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 bn(e,t,n,i,s,r,o,a){const l=e.buffer,c=e.offset;l[c]=t+n,l[c+1]=t+i,l[c+2]=t+s,l[c+3]=t+r,l[c+4]=t+o,l[c+5]=t+a,e.offset=c+6}const ib=8,dt={symbol:"line",sinks:{solid:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int8Array(t,8),e.views.normal=new Int8Array(t,10),e.views.localID=new Uint32Array(t,12)},packObjectAttributes(e,t,n,i,s,r){return Re([e,t.innerId,n,i,s],t,r)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tiers:e[2],hiddenByFloorComplexId:e[3],floorId:e[4],tileData:e.slice(5)}}},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 Re([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 Re([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 Re([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){var w,I;const o=Qr(H(n.style.geometryModifier,i),s,r,i);if(o===null)return;const{tileAttrs:a,tileProps:l}=i;let c=n.style.mode==="3d";const u=c?(w=o.z)!=null?w:ql(i,o):void 0;c&&(!u||!Jl(u))&&(c=!1);const d=e.idIndexer.getIndex(i,t,n),f=H(n.ignoreTier,i)?null:i.tileAttrs[l.db_tiers],h=a[l.db_hidden_by_metro_building_id]||"",g=c?e.getBucket(n.type,"solid3d",dt.sinks.solid3d.packObjectAttributes(t,n,!!o.abs_z,i),dt.sinks.solid3d.binder):e.getBucket(n.type,"solid",dt.sinks.solid.packObjectAttributes(t,n,f,h,(I=a[l.floorId])!=null?I:"",i),dt.sinks.solid.binder),v=Number.isNaN(a[l.beginningIsCut])?!1:a[l.beginningIsCut]!==0,p=Number.isNaN(a[l.endingIsCut])?!1:a[l.endingIsCut]!==0,m=ut(n.style.startCap,i),b=ut(n.style.endCap,i);!c&&(uo(i.styleState,i.tileInfo)||i.ecefDataState===ta.Present)&&i.tileInfo!==void 0?rb(g,o.x,o.y,i.tileInfo,v?ge.TileCut:is(m),p?ge.TileCut:is(b),d):Sl(g,o.x,o.y,u,o.abs_z,o.x.length,v?ge.TileCut:is(m),p?ge.TileCut:is(b),d)},generatePatterned(e,t,n,i,s,r){var I,x;const o=Qr(H(n.style.geometryModifier,i),s,r,i);if(o===null)return;const{tileAttrs:a,tileProps:l}=i,c=H(n.ignoreTier,i)?null:i.tileAttrs[l.db_tiers],u=(I=a[l.db_hidden_by_metro_building_id])!=null?I:"";let d=n.style.mode==="3d";const f=d?(x=o.z)!=null?x:ql(i,o):void 0;d&&(!f||!Jl(f))&&(d=!1);const h=d?e.getBucket("line","patterned3d",dt.sinks.patterned3d.packObjectAttributes(t,n,i),dt.sinks.patterned3d.binder):e.getBucket("line","patterned",dt.sinks.patterned.packObjectAttributes(t,n,c,u,i),dt.sinks.patterned.binder),g=e.idIndexer.getIndex(i,t,n),v=sb(a[l.componentDistanceStart]/ne,a[l.componentDistanceEnd]/ne,a[l.objectLength]/ne,g,d?dt.sinks.patterned3d.stride/2:dt.sinks.patterned.stride/2),p=Number.isNaN(a[l.beginningIsCut])?!1:a[l.beginningIsCut]!==0,m=Number.isNaN(a[l.endingIsCut])?!1:a[l.endingIsCut]!==0,b=ut(n.style.startCap,i),w=ut(n.style.endCap,i);fo(o.x,o.y,f,o.x.length,p?ge.TileCut:is(b),m?ge.TileCut:is(w),a[l.previousPointX],a[l.previousPointY],a[l.nextPointX],a[l.nextPointY],v,h,!0)}},ns={type:mi.Patterned,cDist:0,sLen:0,oLen:0,localID:0,offsetMultiplier:8,px:[],py:[],count:0};function sb(e,t,n,i,s){return ns.cDist=e,ns.sLen=t-e,ns.oLen=n,ns.localID=i,ns.offsetMultiplier=s,ns}function is(e){switch(e){case"round":return ge.Round;case"tilecut":return ge.TileCut;case"butt":default:return ge.Butt}}function rb(e,t,n,i,s,r,o){if(t.length<2)return;const a=[];for(let d=0;d<t.length;d++)a.push([Qi(t[d]),Qi(n[d])]);const l=_l(a,ib,!1),c=new Uint16Array(l.length),u=new Uint16Array(l.length);for(let d=0;d<l.length;d++)c[d]=es(l[d][0]),u[d]=es(l[d][1]);Sl(e,c,u,void 0,void 0,c.length,s,r,o,void 0,void 0,(d,f)=>rn(i,d,f))}const Js={symbol:"shiftedLine",sinks:{solid:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int8Array(t,8),e.views.normal=new Int8Array(t,10),e.views.shift=new Float32Array(t,12)},packObjectAttributes(e,t,n,i){return Re([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,styleState:a,tileInfo:l}=i,c=Number.isNaN(r[o.beginningIsCut])?!1:r[o.beginningIsCut]!==0,u=Number.isNaN(r[o.endingIsCut])?!1:r[o.endingIsCut]!==0,d=H(n.ignoreTier,i)?null:i.tileAttrs[o.db_tiers],f=e.getBucket(n.type,"solid",Js.sinks.solid.packObjectAttributes(t,n,d,i),Js.sinks.solid.binder),h=uo(a,l)?(g,v)=>rn(l,g,v):void 0;Sl(f,s.x,s.y,void 0,void 0,s.x.length,c?ge.TileCut:ge.Round,u?ge.TileCut:ge.Round,0,s.normal_x,s.normal_y,h)}};function Qe(e,t){return e===0?0:Math.min(e*2-1,(t-e)*2)}function po(e,t,n,i,s,r,o=0,a,l,c,u,d,f=!1){let h=e.elements.offset;for(let g=0;g<t;g++){const v=Qe(g,t),p=g===t-1;if((!s||s[v]!==1)&&(s||p))continue;const m=n[v],b=i[v],w=(g+1)%t,I=Qe(w,t),x=n[I],E=i[I];if(u){const C=Math.hypot(x-m,E-b)*u.tileSizeMapPoints/ne;if(C<u.wallPaddingMapPoints[1]+u.wallPaddingMapPoints[3]+u.textureWidthMapPoints)continue;switch(u.config.horizontal.mode){case"repeat-with-stretch":{const T=u.config.horizontal.slicesCount,D=(C-(u.wallPaddingMapPoints[1]+u.wallPaddingMapPoints[3]))/u.textureWidthMapPoints,B=Math.round(D*T);if(B<u.config.horizontal.minSliceRepeats)continue;const j=B/T/D;if(u.config.horizontal.maxResizeFactor&&j>u.config.horizontal.maxResizeFactor||u.config.horizontal.minResizeFactor&&j<u.config.horizontal.minResizeFactor)continue;break}case"repeat-with-max-interval":break;default:continue}switch(u.config.vertical.mode){case"repeat-with-stretch":{const T=u.config.vertical.slicesCount,D=(r-(u.wallPaddingMapPoints[0]+u.wallPaddingMapPoints[2]))/u.textureHeightMapPoints,B=Math.round(D*T);if(B<u.config.vertical.minSliceRepeats)continue;const j=B/T/D;if(j>u.config.vertical.maxResizeFactor||j<u.config.vertical.minResizeFactor)continue;break}case"repeat-with-max-interval":break;case"stripe-top":break;default:continue}Th(e,h),bh(e,h,m,b,x,E,r,o),ab(e,h,r-o,C)}else Th(e,h,f),bh(e,h,m,b,x,E,r,o);c?Ih(e,h,c[0],c[1],c[0],c[1]):Ih(e,h,m,b,x,E),a!==void 0&&"localID"in e.views&&e.views.localID!==void 0&&Mh(e.views.localID,h,a,e.elements.stride),l!==void 0&&"labelingTextureID"in e.views&&e.views.labelingTextureID!==void 0&&Mh(e.views.labelingTextureID,h,l,e.elements.stride),d!==void 0&&ob(e.views.innerColor,h,d,e.elements.stride),h=h+4}e.elements.offset=h}function ob(e,t,n,i){const s=i/e.BYTES_PER_ELEMENT;t=t*s,e[t]=n,t+=s,e[t]=n,t+=s,e[t]=n,t+=s,e[t]=n}function bh(e,t,n,i,s,r,o,a){const l=e.views.position,c=e.views.height,u=e.elements.stride/l.BYTES_PER_ELEMENT,d="elevation"in e.views?e.views.elevation:void 0,f=d?e.elements.stride/d.BYTES_PER_ELEMENT:0;let h=t*f,g=t*u;const v=o<0,p=wt(Math.abs(o)),m=(v?-p:p)/Ze,b=wt(a)/Ze;l[g]=V+n,l[g+1]=V+i,c[g>>1]=v?m:b,d&&(d[h]=a/o),g+=u,l[g]=V+n,l[g+1]=V+i,c[g>>1]=v?b:m,d&&(h+=f,d[h]=1),g+=u,l[g]=V+s,l[g+1]=V+r,c[g>>1]=v?m:b,d&&(h+=f,d[h]=a/o),g+=u,l[g]=V+s,l[g+1]=V+r,c[g>>1]=v?b:m,d&&(h+=f,d[h]=1)}function ab(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 l=t*o,c=t*a;s[l]=0,s[l+1]=1,r[c]=i,r[c+1]=n,l+=o,c+=a,s[l]=0,s[l+1]=0,r[c]=i,r[c+1]=n,l+=o,c+=a,s[l]=1,s[l+1]=1,r[c]=i,r[c+1]=n,l+=o,c+=a,s[l]=1,s[l+1]=0,r[c]=i,r[c+1]=n}function Ih(e,t,n,i,s,r){const o=e.views.demPosition,a=e.elements.stride/o.BYTES_PER_ELEMENT;t=t*a,n=(n+V)/8,i=(i+V)/8,s=(s+V)/8,r=(r+V)/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 Mh(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 Th(e,t,n=!1){const i=e.indices.buffer;let s=e.indices.offset;i[s++]=t,i[s++]=t+(n?1:3),i[s++]=t+(n?3:1),i[s++]=t,i[s++]=t+(n?3:2),i[s++]=t+(n?2:3),e.indices.offset=s}const In=[.5,.5],Mn=[.5,.5];function nc(e,t,n,i,s,r){let o=e.elements.offset;const a=Qe(t-1,t);let l=n[a],c=i[a],u=s?s[a]:0;const d=o;for(let f=0;f<t;f++){const h=Qe(f,t),g=f===t-1,v=n[h],p=i[h],m=s?s[h]:g?0:1;u!==0&&(nn(Mn,l,c,v,p),Eh(e,o,m,g?d:o+4),cb(e,o,l,c,v,p),r?Sh(e,o,r[0],r[1],r[0],r[1]):Sh(e,o,l,c,v,p),al(Mn),ub(e,o,Mn),db(e,o,Mn),o=o+4),l=v,c=p,u=m}e.elements.offset=o}function ic(e,t,n,i,s,r,o,a){let l=e.elements.offset;const c=Qe(t-2,t),u=Qe(t-1,t);let d=n[u],f=i[u],h=s?s[c]:1,g=s?s[u]:0;Vt(In,n[c],i[c],d,f);let v=In[0],p=In[1];for(let m=0;m<t;m++){const b=Qe(m,t),w=m===t-1,I=n[b],x=i[b],E=s?s[b]:w?0:1;nn(Mn,d,f,I,x);const C=Mn[1],T=-Mn[0];h!==0&&(g===0?(In[0]=v,In[1]=p):lb(In,v,p,C,T),Ny(Mn,v,p,In[0],In[1]),Eh(e,l,0,0),fb(e,l,d,f,r,o!=null?o:[d,f]),hb(e,l,al(In),al(Mn)),pb(e,l),l=l+4),d=I,f=x,h=g,g=E,v=C,p=T}e.elements.offset=l}function lb(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 Sh(e,t,n,i,s,r){const o=e.views.demPosition,a=e.elements.stride/o.BYTES_PER_ELEMENT;t=t*a,n=(n+V)/8,i=(i+V)/8,s=(s+V)/8,r=(r+V)/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 cb(e,t,n,i,s,r){const{position:o,distance:a,height:l}=e.views,c=e.elements.stride/o.BYTES_PER_ELEMENT;t=t*c,o[t]=V+n,o[t+1]=V+i,l[t>>1]=0,a[t<<1]=0,t+=c,o[t]=V+n,o[t+1]=V+i,l[t>>1]=0,a[t<<1]=-1,t+=c,o[t]=V+s,o[t+1]=V+r,l[t>>1]=0,a[t<<1]=-1,t+=c,o[t]=V+s,o[t+1]=V+r,l[t>>1]=0,a[t<<1]=0}function ub(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 db(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 fb(e,t,n,i,s,r){const o=e.elements.stride/e.views.position.BYTES_PER_ELEMENT;t=t*o,e.views.position[t]=V+n,e.views.position[t+1]=V+i,e.views.height[t>>1]=0,e.views.distance[t<<1]=1,e.views.demPosition[t]=(V+r[0])/8,e.views.demPosition[t+1]=(V+r[1])/8,t+=o,e.views.position[t]=V+n,e.views.position[t+1]=V+i,e.views.height[t>>1]=0,e.views.distance[t<<1]=-1,e.views.demPosition[t]=(V+r[0])/8,e.views.demPosition[t+1]=(V+r[1])/8,t+=o,e.views.position[t]=V+n,e.views.position[t+1]=V+i,e.views.height[t>>1]=wt(s)/Ze,e.views.distance[t<<1]=-1,e.views.demPosition[t]=(V+r[0])/8,e.views.demPosition[t+1]=(V+r[1])/8,t+=o,e.views.position[t]=V+n,e.views.position[t+1]=V+i,e.views.height[t>>1]=wt(s)/Ze,e.views.distance[t<<1]=1,e.views.demPosition[t]=(V+r[0])/8,e.views.demPosition[t+1]=(V+r[1])/8}function hb(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 pb(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 Eh(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 Ks=ot(),Qs=ot(),Tn=ot();function ss(e,t,n,i,s,r,o,a){De(Ks,t,n,i),De(Qs,s,r,o),Qt(Tn,Qs,Ks),sy(Qs,Ks)||(Kt(Tn,Tn),Gn(Tn,Tn,127)),mb(e,0,1,3,3,1,2);const l=a==null?void 0:a.absZCurr,c=a==null?void 0:a.absZNext,u=a==null?void 0:a.isPivotCurr,d=a==null?void 0:a.isPivotNext;mo(e,Ks,Tn,1,a,l,u),mo(e,Ks,Tn,-1,a,l,u),mo(e,Qs,Tn,-1,a,c,d),mo(e,Qs,Tn,1,a,c,d)}function mo(e,t,n,i,s,r,o){const a=s==null?void 0:s.demPosition,l=s==null?void 0:s.isModel,c=s==null?void 0:s.isMesh,u=s==null?void 0:s.isEcef,d=s==null?void 0:s.innerColor,f=e.elements.offset*e.elements.stride,h=f/e.views.position.BYTES_PER_ELEMENT;if(u?(e.views.position[h]=t[0],e.views.position[h+1]=t[1],e.views.position[h+2]=t[2]):(e.views.position[h]=l?t[0]:V+t[0],e.views.position[h+1]=l?t[1]:V+t[1]),"height"in e.views){const g=f/e.views.height.BYTES_PER_ELEMENT;e.views.height[g]=(l?t[2]:c?t[2]*pf:wt(t[2]))/Ze}if(e.views.directionDistance[f]=n[0],e.views.directionDistance[f+1]=n[1],e.views.directionDistance[f+2]=n[2],e.views.directionDistance[f+3]=i,"demPosition"in e.views){const g=f/e.views.demPosition.BYTES_PER_ELEMENT,v=a!=null?a:t;e.views.demPosition[g]=(l?v[0]:V+v[0])/8,e.views.demPosition[g+1]=(l?v[1]:V+v[1])/8}"absZ"in e.views&&r!==void 0&&(e.views.absZ[f/e.views.absZ.BYTES_PER_ELEMENT]=r),"isPivot"in e.views&&(e.views.isPivot[f/e.views.isPivot.BYTES_PER_ELEMENT]=o!=null?o:0),"innerColor"in e.views&&d!==void 0&&(e.views.innerColor[f/e.views.innerColor.BYTES_PER_ELEMENT]=d),e.elements.offset++}function mb(e,t,n,i,s,r,o){const a=e.indices.buffer,l=e.indices.offset,c=e.elements.offset;a[l]=c+t,a[l+1]=c+n,a[l+2]=c+i,a[l+3]=c+s,a[l+4]=c+r,a[l+5]=c+o,e.indices.offset=l+6}const yb=/\.png$/i;function gb(e){return!!e&&e.type==="polygon"}function vb(e){return!!e&&e.type==="line"}function Ah(e){return e.reduce((t,n,i)=>(t[n]=i,t),{})}function wb(e){return!(e!=null&&e.url.match(yb))}function xh(e,t){return Ri(H(e.style.sideColor,t),H(e.style.sideStrokeColor,t))}const ft=4294967295,Zt=4294967040,bb=Zt-1,sc={},Ib=1e6,_h=["main","parser","labeling","models"];let rc=0;_h.forEach(e=>{const t=rc+Math.floor(bb/_h.length);sc[e]={min:rc,max:t-Ib},rc=t});class Mb{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=sc[t].min,this.maxIdentifyIndex=sc[t].max,this.index=this.minIdentifyIndex}getIndex(t,n,i,s={}){const{id:r,tileProps:o,tileAttrs:a}=t,l=i.interactive,c=s.ignoreHover?!1:a[o.hovered],u=c&&i.type!=="polygon3d"||i.type==="embankment";return!!r&&l&&!c&&!u?this.getIndexInternal(he({id:r,styleId:n,layer:i,sublayer:a[o.db_sublayer]},s)):ft}getIndexInternal(t){var r,o,a,l,c,u,d;const n=this.index+this.ids.length;this.ids.push(t.id),this.floorIds.push((r=t.floorId)!=null?r:""),this.phases.push(t.layer.renderIndex),this.sublayers.push((l=(a=(o=t.metatile)==null?void 0:o.dictionaries.db_sublayer)==null?void 0:a[t.sublayer])!=null?l:NaN),this.styleIds.push(t.styleId),this.layerIds.push(t.layer.innerId),this.instanceIds.push((c=t.instanceId)!=null?c:0);const{center:i,objectClass:s}=t;if(i?this.center.push(Math.round(i[0]),Math.round(i[1])):this.center.push(Pa,Pa),typeof s=="string"){const f=(d=(u=t.metatile)==null?void 0:u.dictionaries.db_object_class)==null?void 0:d[s];f?this.objectClasses.push(f):(this.objectClasses.push(0),this.strings[n]={objectClass:s})}else this.objectClasses.push(ft);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,l=new Uint8Array(this.instanceIds).buffer,c=new Uint32Array(this.objectClasses).buffer,u=new Int32Array(this.center).buffer,d=this.index,f=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:d,endIndex:f,phaseBuffer:s,sublayerBuffer:r,styleIdBuffer:o,layerIdBuffer:a,instanceIdBuffer:l,objectClassBuffer:c,centerBuffer:u,strings:h}}}var te=(e=>(e[e.side=0]="side",e[e.top=1]="top",e[e.bottom=2]="bottom",e))(te||{});const er=[0,0,0],tr=[0,0,0],nr=[0,0,0],yo=[0,0,0],Ph=(e,t,n,i,s)=>Re([e,t.innerId,n,i],t,s),Lh=(e,t,n,i,s,r)=>Re([e,t.innerId,n,i,s],t,r),Ch=e=>({styleId:e[0],layerId:e[1],side:e[2],absZ:e[3],tileData:e.slice(4)}),Dh=e=>({styleId:e[0],layerId:e[1],absZ:e[2],floorId:e[3],isHole:e[4],tileData:e.slice(5)}),Q={symbol:"mesh",sinks:{fill:{stride:32,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),e.views.innerColor=new Uint32Array(t,28)},packObjectAttributes:Ph,unpackObjectAttributes:Ch},inverse:{stride:20,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),e.views.labelingTextureID=new Uint32Array(t,16)},packObjectAttributes:Lh,unpackObjectAttributes:Dh},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:Lh,unpackObjectAttributes:Dh},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:Ph,unpackObjectAttributes:Ch}},generate(e,t,n,i,s,r,o,a,l,c,u="fill",d=!1,f,h,g=!1){var j,U,A,M;const v=r.x,p=r.y,m=r.signed_z;let b=0;if(n.type==="polygon3d"||n.type==="embankment"){const S=H(n.style.elevation,s),L=s.tileInfo?Ct(s.tileInfo,[0,0]):1;b=S*ve*L}const w=r.gradient,I=r.abs_z,x=r.is_pivot,E=v.length,C=s.tileAttrs[s.tileProps.hovered],T=(j=s.id)!=null?j:"",D=e.pointIndexer.getIndex(h||T);let B=Zt;switch(n.type){case"polygon3d":{n.interactive?(B=C?ft:e.idIndexer.getIndex(s,t,n),!C&&B===ft&&(B=Zt)):B=n.interactiveOcclusion?Zt:ft;break}case"overpass":case"tunnel":{B=e.idIndexer.getIndex(s,t,n),B===ft&&(B=Zt);break}case"polygon":case"polygonExtrusion":case"embankment":{B=Zt;break}default:{const{type:S}=n}}(n.type==="embankment"||n.type==="polygon3d")&&l&&a!==void 0&&Xl(e,t,l,n.style,a);let k;if(u==="inverse")k=e.getBucket("mesh","inverse",Q.sinks.inverse.packObjectAttributes(t,n,!!I,h!=null?h:"",!!g,s),Q.sinks.inverse.binder);else if(u==="fill")k=e.getBucket("mesh","fill",Q.sinks.fill.packObjectAttributes(t,n,i,!!I,s),Q.sinks.fill.binder);else if(u==="depthClear")k=e.getBucket("mesh","depthClear",Q.sinks.depthClear.packObjectAttributes(t,n,!!I,"",!!g,s),Q.sinks.depthClear.binder);else return;for(let S=0;S<E-2;S++){const L=!(S%2);Tb(k);const _=d?2:1,F=d?1:2,O=L?S+_:S+F,N=L?S+F:S+_,R=ne/o.size;De(er,v[S],p[S],((U=m==null?void 0:m[S])!=null?U:0)*R),De(tr,v[O],p[O],((A=m==null?void 0:m[O])!=null?A:0)*R),De(nr,v[N],p[N],((M=m==null?void 0:m[N])!=null?M:0)*R),Hd(yo,er,tr,nr),er[2]/=R,tr[2]/=R,nr[2]/=R,er[2]+=b,tr[2]+=b,nr[2]+=b;const z=k.elements.offset;oc(k,er,yo,w==null?void 0:w[S],B,D,c,I==null?void 0:I[S],x==null?void 0:x[S],f),oc(k,tr,yo,w==null?void 0:w[O],B,D,c,I==null?void 0:I[O],x==null?void 0:x[O],f),oc(k,nr,yo,w==null?void 0:w[N],B,D,c,I==null?void 0:I[N],x==null?void 0:x[N],f),k.objectsData[z]={objectId:T,size:k.elements.offset-z}}}};function oc(e,t,n,i,s,r,o,a,l,c){var h,g;const u=e.elements.stride*e.elements.offset,d=u/e.views.position.BYTES_PER_ELEMENT;e.views.position[d]=V+t[0],e.views.position[d+1]=V+t[1],e.views.height[u/e.views.height.BYTES_PER_ELEMENT]=t[2];const f=u/e.views.demPosition.BYTES_PER_ELEMENT;if(e.views.demPosition[f]=(((h=o==null?void 0:o[0])!=null?h:t[0])+V)/8,e.views.demPosition[f+1]=(((g=o==null?void 0:o[1])!=null?g:t[1])+V)/8,a!==void 0&&(e.views.absZ[u/e.views.absZ.BYTES_PER_ELEMENT]=a),e.views.isPivot[u/e.views.isPivot.BYTES_PER_ELEMENT]=l!=null?l:0,"normal"in e.views){const v=u/e.views.normal.BYTES_PER_ELEMENT,p=u/e.views.localID.BYTES_PER_ELEMENT,m=u/e.views.gradient.BYTES_PER_ELEMENT;e.views.normal[v]=$e(n[0]),e.views.normal[v+1]=$e(n[1]),e.views.normal[v+2]=$e(n[2]),e.views.gradient[m]=$e(i!=null?i:0),e.views.localID[p]=s,e.views.labelingTextureID[p]=r}else"labelingTextureID"in e.views&&(e.views.labelingTextureID[u/e.views.labelingTextureID.BYTES_PER_ELEMENT]=r);if("innerColor"in e.views&&c!==void 0){const v=u/e.views.innerColor.BYTES_PER_ELEMENT;e.views.innerColor[v]=c}e.elements.offset++}function Tb(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 go=ne/2,Sb=1/wt(1),qn=(e,t,n,i,s,r,o,a)=>Re([e,t.innerId,n,i,s,r,o],t,a),ir=e=>({styleId:e[0],layerId:e[1],hiddenByFloorComplexId:e[2],floorId:e[3],isFloorStack:e[4],textureIndex:e[5],isHole:e[6],tileData:e.slice(7)}),on={symbol:"polygonExtrusion",sinks:{sideFill:{stride:28,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),e.views.innerColor=new Uint32Array(t,20),e.views.elevation=new Float32Array(t,24)},packObjectAttributes:qn,unpackObjectAttributes:ir},sideTexture:{stride:28,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),e.views.innerColor=new Uint32Array(t,24)},packObjectAttributes:qn,unpackObjectAttributes:ir},topFill:{stride:24,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),e.views.innerColor=new Uint32Array(t,20)},packObjectAttributes:qn,unpackObjectAttributes:ir},sideStroke:{stride:24,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),e.views.innerColor=new Uint32Array(t,20)},packObjectAttributes:qn,unpackObjectAttributes:ir},topStroke:{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.innerColor=new Uint32Array(t,16)},packObjectAttributes:qn,unpackObjectAttributes:ir}},generate(e,t,n,i,s,r,o){var U,A;const a=s.x,l=s.y,c=(U=s.cut)!=null?U:[],u=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",h=a.length,g=(A=i.id)!=null?A:"";let v;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])?v=[i.tileAttrs[i.tileProps.db_centroid_x],i.tileAttrs[i.tileProps.db_centroid_y]]:v=_b(a,l,c);const p=H(n.style.height,i),m=Number.isNaN(i.tileAttrs[i.tileProps.db_basis_height])?0:i.tileAttrs[i.tileProps.db_basis_height],b=i.tileInfo?Ct(i.tileInfo,[0,0]):1,w=p<0;let I=Math.max(Math.abs(p)*ve*b,Sb);w&&(I=-I);const x=e.idIndexer.getIndex(i,t,n,{floorId:Number.isNaN(u)?void 0:u}),E=e.pointIndexer.getIndex(g),C=H(n.style.topColor,i),T=H(n.style.strokeColor,i),D=H(n.style.sideColor,i),B=D&&D.isVertexColor?ro(D):void 0,k=T&&T.isVertexColor?ro(T):void 0,j=C&&C.isVertexColor?ro(C):void 0;if(w){const M=qn(t,n,d,u,!1,NaN,!0,i);Q.generate(e,t,n,te.top,i,s,o,void 0,void 0,void 0,"depthClear");const S=e.getBucket("polygonExtrusion","sideFill",M,on.sinks.sideFill.binder);po(S,h,a,l,c,I,0,Zt,E,v,void 0,void 0,!0),i.styleState.terrainEnabled!==!0&&Pb(s,I).forEach(_=>Q.generate(e,t,n,te.side,i,_,o,void 0,void 0,void 0,"inverse",!1,void 0,void 0,!0));const L=e.getBucket("polygonExtrusion","topFill",M,on.sinks.topFill.binder);Oh(L,h,a,l,I,Zt,E,v)}else{const M=qn(t,n,d,u,f,NaN,!1,i);if(I>0){const F=e.getBucket("polygonExtrusion","sideFill",M,on.sinks.sideFill.binder);let O=F.indices.offset;if(po(F,h,a,l,c,I,m,x,E,v,void 0,B),F.objectsData[O]={objectId:g,size:F.indices.offset-O},n.style.sideTextures.forEach((N,R)=>{var X,se;if(p<N.minWallHeight)return;const z=N.sliceSize[0]*ve*b,Z=N.sliceSize[1]*ve*b,Y=N.wallPadding.map(me=>me*ve*b),ee=jt((se=(X=i.tileInfo)==null?void 0:X.coords[2])!=null?se:15),K=qn(t,n,d,u,f,R,!1,i),G=e.getBucket("polygonExtrusion","sideTexture",K,on.sinks.sideTexture.binder),q=G.indices.offset,J=N.vertical.mode==="stripe-top"?I-Z:0;po(G,h,a,l,c,I,J,void 0,void 0,v,{config:N,textureWidthMapPoints:z,textureHeightMapPoints:Z,wallPaddingMapPoints:Y,tileSizeMapPoints:ee},B),G.objectsData[q]={objectId:g,size:G.indices.offset-q}}),!u&&(!r.AALinesOff||!xh(n,i))){const N=e.getBucket("polygonExtrusion","sideStroke",M,on.sinks.sideStroke.binder);O=N.indices.offset,nc(N,h,a,l,c,v),ic(N,h,a,l,c,I,v),N.objectsData[O]={objectId:g,size:N.indices.offset-O}}}const S=e.getBucket("polygonExtrusion","topFill",M,on.sinks.topFill.binder);let L=S.indices.offset;Oh(S,h,a,l,I,x,E,v,j),S.objectsData[L]={objectId:g,size:S.indices.offset-L};const _=e.getBucket("polygonExtrusion","topStroke",M,on.sinks.topStroke.binder);L=_.indices.offset,Eb(_,h,a,l,c,I,v,k),_.objectsData[L]={objectId:g,size:_.indices.offset-L}}}};function Oh(e,t,n,i,s,r,o,a,l){let c=e.elements.offset;const u=c;ac(e,c++,n[0],i[0],s,r,o,a,l),ac(e,c++,n[1],i[1],s,r,o,a,l);for(let d=2;d<t;d++)Ab(e,u,d),ac(e,c++,n[d],i[d],s,r,o,a,l);e.elements.offset=c}function Eb(e,t,n,i,s,r,o,a){const l={demPosition:o,innerColor:a};for(let c=0;c<t;c++){const u=Qe(c,t);if(s&&s[u]===1){const d=Qe((c+1)%t,t);ss(e,n[u],i[u],r,n[d],i[d],r,l)}}}function ac(e,t,n,i,s,r,o,a,l){const c=e.elements.stride,u=t*(c/e.views.position.BYTES_PER_ELEMENT),d=u>>1,f=s<0,h=wt(Math.abs(s)),g=(f?-h:h)/Ze;e.views.position[u]=V+n,e.views.position[u+1]=V+i,e.views.height[d]=g,e.views.demPosition[u]=(V+a[0])/8,e.views.demPosition[u+1]=(V+a[1])/8,"localID"in e.views&&(e.views.localID[d]=r),"labelingTextureID"in e.views&&(e.views.labelingTextureID[d]=o),l!==void 0&&(e.views.innerColor[d]=l)}function Ab(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 Fh(e){return le(go-Math.abs(e[0]-go),2)+le(go-Math.abs(e[1]-go),2)}function xb(e){return e[0]===0||e[0]===ne||e[1]===0||e[1]===ne}function _b(e,t,n){let i,s=le(ne,2);const r=e.length,o=Ds();for(let a=0;a<r;a++){i||di(o,[e[a],t[a]]);const l=Qe(a,r);if(n[l]===0){const c=[e[l],t[l]],u=Qe((a+1)%r,r),d=[e[u],t[u]];if(xb(c)){const f=Fh(c);f<s&&(i=c,s=f);const h=Fh(d);h<s&&(i=d,s=h)}else i=[(e[l]+e[u])/2,(t[l]+t[u])/2]}}return i||(i=[],Nr(i,o)),i}function Pb(e,t){const n=e.x,i=e.y,s=e.cut,r=n.length,o=[];for(let a=0;a<r;a++){const l=Qe(a,r),c=a===r-1;if((!s||s[l]!==1)&&(s||c))continue;const u=n[l],d=i[l],f=(a+1)%r,h=Qe(f,r),g=n[h],v=i[h];o.push({x:[u,u,g,g],y:[d,d,v,v],signed_z:[0,t,0,t]})}return o}const rs={type:mi.Striped,cDist:0,oLen:0,sLen:0,localID:0,offsetMultiplier:14,px:[],py:[],count:0};function Lb(e,t,n,i){return rs.cDist=e,rs.oLen=t,rs.localID=n,rs.offsetMultiplier=i,rs.globeMode=!1,rs}const Sn={symbol:"dashedLine",sinks:{stroke:{stride:28,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.texExtender=new Int8Array(t,6),e.views.extender=new Int16Array(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,r){return Re([e,t.innerId,n,i,s],t,r)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tiers:e[2],hiddenByFloorComplexId:e[3],floorId:e[4],tileData:e.slice(5)}}},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 Re([e,t.innerId],t,n)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(2)}}}},generate(e,t,n,i,s){var b,w;const r=i.tileInfo;if(!r)return;const o=Qr(H(n.style.geometryModifier,i),r,s,i);if(o===null)return;const{tileAttrs:a,tileProps:l}=i,c=H(n.ignoreTier,i)?null:i.tileAttrs[l.db_tiers],u=a[l.db_hidden_by_metro_building_id]||"";let d=n.style.mode==="3d";const f=d?(b=o.z)!=null?b:ql(i,o):void 0;d&&(!f||!Jl(f))&&(d=!1);const h=d?e.getBucket(n.type,"stroke3d",Sn.sinks.stroke3d.packObjectAttributes(t,n,i),Sn.sinks.stroke3d.binder):e.getBucket(n.type,"stroke",Sn.sinks.stroke.packObjectAttributes(t,n,c,u,(w=a[l.floorId])!=null?w:"",i),Sn.sinks.stroke.binder),g=e.idIndexer.getIndex(i,t,n),v=Lb(a[l.componentDistanceStart]/ne,a[l.objectLength]/ne,g,d?Sn.sinks.stroke3d.stride/2:Sn.sinks.stroke.stride/2),p=Number.isNaN(a[l.beginningIsCut])?!1:a[l.beginningIsCut]!==0,m=Number.isNaN(a[l.endingIsCut])?!1:a[l.endingIsCut]!==0;!d&&i.styleState.globeEnabled&&r&&r.coords[2]<Rn.globeMaxZoom?Db(h,o.x,o.y,r,p?ge.TileCut:ge.Butt,m?ge.TileCut:ge.Butt,a[l.previousPointX],a[l.previousPointY],a[l.nextPointX],a[l.nextPointY],v):fo(o.x,o.y,f,o.x.length,p?ge.TileCut:ge.Butt,m?ge.TileCut:ge.Butt,a[l.previousPointX],a[l.previousPointY],a[l.nextPointX],a[l.nextPointY],v,h)}},Cb=32;function Db(e,t,n,i,s,r,o,a,l,c,u){if(t.length<2)return;const d=[];for(let v=0;v<t.length;v++)d.push([Qi(t[v]),Qi(n[v])]);const f=_l(d,Cb,!1),h=new Uint16Array(f.length),g=new Uint16Array(f.length);for(let v=0;v<f.length;v++)h[v]=es(f[v][0]),g[v]=es(f[v][1]);u.globeMode=!0,u.tileInfo=i,fo(h,g,void 0,h.length,s,r,o,a,l,c,u,e,!1)}const vo=[Ze/2,Ze/2],En={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)=>Re([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: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)},packObjectAttributes:(e,t,n,i,s)=>Re([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,l){var h;const c=(h=n.id)!=null?h:"",u=i.idIndexer.getIndex(n,e,t),d=i.pointIndexer.getIndex(c),f=i.getBucket(t.type,"fill",En.sinks.fill.packObjectAttributes(e,t,a,l,c,n),En.sinks.fill.binder,o);Fb(f,r);for(let g=0;g<s.length;g++)Ob(f,s,g,u,d)},processOuterEdge(e,t,n,i,s,r,o){var c;const a=(c=n.id)!=null?c:"",l=i.getBucket(t.type,"stroke",En.sinks.stroke.packObjectAttributes(e,t,o,a,n),En.sinks.stroke.binder);for(let u=0;u<r.length;u+=2){const d=r[u]*5,f=r[u+1]*5;ss(l,s[d],s[d+1],s[d+2],s[f],s[f+1],s[f+2],{demPosition:vo,isModel:!0})}}};function Ob(e,t,n,i,s){const r=e.elements.offset,o=En.sinks.fill.stride,a=n*5,l=r*(o/e.views.position.BYTES_PER_ELEMENT),c=r*(o/e.views.localID.BYTES_PER_ELEMENT);e.views.position[l]=t[a],e.views.position[l+1]=t[a+1],e.views.height[c]=t[a+2]/Ze,e.views.texCoords[l]=t[a+3],e.views.texCoords[l+1]=t[a+4],e.views.localID[c]=i,e.views.demPosition[l]=vo[0]/8,e.views.demPosition[l+1]=vo[1]/8,e.views.labelingTextureID[c]=s,e.elements.offset++}function Fb(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 os=Oe(),sr=Oe(),as={type:mi.Entrance,offsetMultiplier:18,cDist:0,oLen:0,sLen:0,px:[],py:[],count:0,localID:0};function Rb(e,t,n,i){return as.px=e.x,as.py=e.y,as.oLen=n/ne,as.count=t,as.localID=i,as}const rr={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 Re([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,l=Nb(r,o,a),c=e.getBucket(n.type,"stroke",rr.sinks.stroke.packObjectAttributes(t,n,a,i),rr.sinks.stroke.binder),u=e.idIndexer.getIndex(i,t,n),d=Rb(s,a,l,u);fo(s.x,s.y,void 0,a,ge.Butt,ge.Butt,0,0,0,0,d,c);let f=0;Rh(c,Bs.StartBorder,r[0],o[0],r[1],o[1],0,0,f,l,u);for(let h=0;h<a-1;h++){if(h!==0){const g=r[h]-r[h-1],v=o[h]-o[h-1];f+=Math.sqrt(g*g+v*v)}Rh(c,Bs.Arrow,r[h],o[h],r[h+1],o[h+1],-1,0,f,l,u)}}};function Nb(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 Rh(e,t,n,i,s,r,o,a,l,c,u){Bb(e,1,2,0,0,2,3),wo(e,t,n,i,s,r,o,a,-1,-1,l,c,!0,u),wo(e,t,n,i,s,r,o,a,1,-1,l,c,!1,u),wo(e,t,n,i,s,r,o,a,1,1,l,c,!1,u),wo(e,t,n,i,s,r,o,a,-1,1,l,c,!0,u)}function wo(e,t,n,i,s,r,o,a,l,c,u,d,f,h){const g=e.elements,v=g.stride*g.offset,p=v>>1,m=p>>1;nn(os,n,i,s,r),Vn(sr,os),e.views.position[p]=V+n,e.views.position[p+1]=V+i,e.views.segmentEnd[p]=V+s,e.views.segmentEnd[p+1]=V+r,e.views.texExtender[v]=$e(sr[0]*c*(f?-1:1)*Be),e.views.texExtender[v+1]=$e(sr[1]*c*(f?-1:1)*Be),e.views.arrowExtender[v]=$e(l*Be),e.views.arrowExtender[v+1]=$e(c*Be);const b=l+o,w=c+a,I=os[0]*b+sr[0]*w,x=os[1]*b+sr[1]*w;e.views.extender[p]=Math.round(I*Be*127),e.views.extender[p+1]=Math.round(x*Be*127),e.views.direction[p]=Math.round(os[0]*127),e.views.direction[p+1]=Math.round(os[1]*127),e.views.vertexDistance[m]=u/Ze,e.views.objectLength[m]=d/Ze,e.views.type[m]=t,e.views.localID[m]=h,e.elements.offset++}function Bb(e,t,n,i,s,r,o){const{elements:a,indices:l}=e,{buffer:c,offset:u}=l,d=a.offset;c[u]=d+t,c[u+1]=d+n,c[u+2]=d+i,c[u+3]=d+s,c[u+4]=d+r,c[u+5]=d+o,l.offset=u+6}const bo={symbol:"circle",sinks:{fill:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int16Array(t,8),e.views.localID=new Uint32Array(t,12)},packObjectAttributes:(e,t,n)=>Re([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",bo.sinks.fill.packObjectAttributes(t,n,i),bo.sinks.fill.binder),o=e.idIndexer.getIndex(i,t,n),a=[s.x[0],s.y[0],s.z?s.z[0]:0];let l,c,u;if(i.styleState.globeEnabled&&i.tileInfo!==void 0){const d=rn(i.tileInfo,a[0],a[1]);l=d.x,c=d.y,u=d.z}else l=V+a[0],c=V+a[1],u=wt(a[2]);kb(r,0,2,1,0,3,2),Io(r,l,c,u,-1,-1,o),Io(r,l,c,u,-1,1,o),Io(r,l,c,u,1,1,o),Io(r,l,c,u,1,-1,o)}};function Io(e,t,n,i,s,r,o){const l=e.elements.offset*e.elements.stride>>1,c=l>>1;e.views.position[l]=t,e.views.position[l+1]=n,e.views.position[l+2]=i,e.views.extender[l]=s,e.views.extender[l+1]=r,e.views.localID[c]=o,e.elements.offset++}function kb(e,t,n,i,s,r,o){const{elements:a,indices:l}=e,{buffer:c,offset:u}=l,d=a.offset;c[u]=d+t,c[u+1]=d+n,c[u+2]=d+i,c[u+3]=d+s,c[u+4]=d+r,c[u+5]=d+o,l.offset=u+6}const ls=Oe(),cs=Oe(),Nh=Oe(),Bh=Oe(),lc=(e,t,n,i)=>Re([e,t.innerId,n],t,i),cc=e=>({styleId:e[0],layerId:e[1],hiddenByFloorComplexId:e[2],tileData:e.slice(3)}),or=mf(1),An={symbol:"lineExtrusion",sinks:{fill:{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.innerColor=new Uint32Array(t,12)},packObjectAttributes:lc,unpackObjectAttributes:cc},topStroke:{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.innerColor=new Uint32Array(t,16)},packObjectAttributes:lc,unpackObjectAttributes:cc},sideStroke:{stride:24,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:lc,unpackObjectAttributes:cc}},generate(e,t,n,i,s,r){const o=s.x,a=s.y,l=o.length,c=i.tileAttrs[i.tileProps.db_hidden_by_metro_building_id]||"",u=e.getBucket(n.type,"fill",An.sinks.fill.packObjectAttributes(t,n,c,i),An.sinks.fill.binder),d=e.getBucket(n.type,"topStroke",An.sinks.topStroke.packObjectAttributes(t,n,c,i),An.sinks.topStroke.binder),f=e.getBucket(n.type,"sideStroke",An.sinks.sideStroke.packObjectAttributes(t,n,c,i),An.sinks.sideStroke.binder),h=!r.AALinesOff||!xh(n,i);for(let g=0;g<l-1;g++){const v=o[g],p=a[g],m=o[g+1],b=a[g+1];Ve(ls,v,m),Ve(cs,p,b),Ve(Nh,m,v),Ve(Bh,b,p),po(u,2,ls,cs,void 0,or,void 0,void 0,void 0,void 0,void 0,0),ss(d,v,p,or,m,b,or),h&&(nc(f,2,ls,cs,void 0),nc(f,2,Nh,Bh,void 0),ic(f,2,ls,cs,void 0,or))}h&&(Ve(ls,o[l-1],o[0]),Ve(cs,a[l-1],a[0]),ic(f,2,ls,cs,void 0,or))}},Mo={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 Re([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,l=t.y,c=e.getBucket(s.type,"fill",Mo.sinks.fill.packObjectAttributes(n,s,i,r,o),Mo.sinks.fill.binder);let u=c.elements.offset;Ub(c.indices,u,0,1,2,2,1,3),To(c,u++,a[0],l[0],0,1),To(c,u++,a[1],l[1],1,1),To(c,u++,a[2],l[2],0,0),To(c,u++,a[3],l[3],1,0),c.elements.offset=u}};function To(e,t,n,i,s,r){t=t*4,e.views.position[t]=V+n,e.views.position[t+1]=V+i,e.views.txtrCoords[t]=St(s),e.views.txtrCoords[t+1]=St(r)}function Ub(e,t,n,i,s,r,o,a){const l=e.buffer,c=e.offset;l[c]=t+n,l[c+1]=t+i,l[c+2]=t+s,l[c+3]=t+r,l[c+4]=t+o,l[c+5]=t+a,e.offset=c+6}const zb=8;function uc(e,t,n,i,s,r){return Re([e,t.innerId,n,i,s],t,r)}const Gb=(e,t,n,i,s)=>Re([e,t.innerId,n,i],t,s),dc=e=>({styleId:e[0],layerId:e[1],tiers:e[2],floorId:e[3],hiddenByFloorComplexId:e[4],tileData:e.slice(5)}),Vb=e=>({styleId:e[0],layerId:e[1],tiers:e[2],floorId:e[3],tileData:e.slice(4)}),jb=(e,t)=>{const n=e.type==="polygon"&&H(e.style.color,t),i=_f(n)&&n.factor.type==="vertex-attribute";return i?{withMixFactor:i,mixFactorAttributeName:n.factor.name}:{withMixFactor:i,mixFactorAttributeName:void 0}},Xt={symbol:"polygon",sinks:{fill:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.localID=new Uint32Array(t,8)},packObjectAttributes:uc,unpackObjectAttributes:dc},stroke:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.directionDistance=new Int8Array(t,8)},packObjectAttributes:uc,unpackObjectAttributes:dc},shadow:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t)},packObjectAttributes:Gb,unpackObjectAttributes:Vb},fillWithMixFactor:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.mixFactor=new Uint16Array(t,8)},packObjectAttributes:uc,unpackObjectAttributes:dc}},generate(e,t,n,i,s,r,o,a){var B;if(i.tileAttrs[i.tileProps.db_geometry_type]==="polyline")return;const{withMixFactor:c,mixFactorAttributeName:u}=jb(n,i),d=s.x,f=s.y,h=s.cut,g=i.tileAttrs[i.tileProps.db_plan_id]||"",v=i.tileAttrs[i.tileProps.db_sublayer];Array.isArray(i.styleState._backgroundFloorIds)&&i.styleState._backgroundFloorIds.length>0&&(v==="Hall_ground"||v==="Hall_underground_ground")&&Q.generate(e,t,n,te.top,i,s,o,r,a,void 0,"inverse",!1,void 0,g);const m=c?s[u]:void 0;if(gb(n)&&a&&(Xl(e,t,a,n.style,r),n.style.normalMapTextureImage)){const k={textureImage:n.style.normalMapTextureImage,textureSize:n.style.normalMapTextureSize,lengthUnits:n.style.normalMapTextureLengthUnits};Xl(e,t,a,k,r)}const b=e.idIndexer.getIndex(i,t,n,{floorId:g||void 0}),w=(B=i.id)!=null?B:"",I=n.type==="polygon"&&!H(n.ignoreTier,i)?i.tileAttrs[i.tileProps.db_tiers]:null,x=i.tileAttrs[i.tileProps.db_hidden_by_metro_building_id]||"",E=c?e.getBucket("polygon","fillWithMixFactor",Xt.sinks.fillWithMixFactor.packObjectAttributes(t,n,I,g,x,i),Xt.sinks.fillWithMixFactor.binder):e.getBucket("polygon","fill",Xt.sinks.fill.packObjectAttributes(t,n,I,g,x,i),Xt.sinks.fill.binder),C=E.indices.offset,T=(uo(i.styleState,i.tileInfo)||i.ecefDataState===ta.Present)&&i.tileInfo!==void 0;T?Xb(E,d,f,i.tileInfo,b):kh(E,d.length,d,f,b,m),E.objectsData[C]={objectId:w,size:E.indices.offset-C};const D=e.getBucket("polygon","stroke",Xt.sinks.stroke.packObjectAttributes(t,n,I,g,x,i),Xt.sinks.stroke.binder);if(h){const k=D.indices.offset;Hb(D,d.length,d,f,h,T?i.tileInfo:void 0),D.objectsData[k]={objectId:w,size:D.indices.offset-k}}}};function kh(e,t,n,i,s,r){const o=e.indices.buffer;let a=e.indices.offset,l=e.elements.offset;const c=l;fc(e,l++,n[0],i[0],s,r==null?void 0:r[0]),fc(e,l++,n[1],i[1],s,r==null?void 0:r[1]);for(let u=2;u<t;u++)Yb(o,a,c,u),fc(e,l++,n[u],i[u],s,r==null?void 0:r[u]),a=a+3;e.elements.offset=l,e.indices.offset=a}function Hb(e,t,n,i,s,r){const o=r!==void 0?{isEcef:!0}:void 0;for(let a=0;a<t;a++){const l=Qe(a,t);if(s[l]===1){const c=Qe((a+1)%t,t);if(r){const u=rn(r,n[l],i[l]),d=rn(r,n[c],i[c]);ss(e,u.x,u.y,u.z,d.x,d.y,d.z,o)}else ss(e,n[l],i[l],0,n[c],i[c],0)}}}function $b(e,t,n,i,s,r,o){t=t*e.elements.stride/e.views.position.BYTES_PER_ELEMENT,e.views.position[t]=n,e.views.position[t+1]=i,e.views.position[t+2]=s,t=t>>1,"localID"in e.views&&(e.views.localID[t]=r)}function fc(e,t,n,i,s,r){t=t*e.elements.stride/e.views.position.BYTES_PER_ELEMENT,e.views.position[t]=V+n,e.views.position[t+1]=V+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 Yb(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)}const hc=lt.fromGeo([0,90]),pc=lt.fromGeo([0,-90]),Wb={x:wn(hc[0]),y:wn(hc[1]),z:wn(hc[2])},Zb={x:wn(pc[0]),y:wn(pc[1]),z:wn(pc[2])};function Xb(e,t,n,i,s,r){if(t.length<3)return;const o=i.coords,a=o[1]===le(2,o[2])-1,l=o[1]===0,c=[],u=[],d=t.length;for(let w=0;w<d;w++){const I=Qe(w,d);u.push([mh(Qi(t[I])),mh(Qi(n[I]))])}c.push(u);const f=mv(c,{x:2,y:2,z:2},zb*le(2,o[3]-o[2]),!1),h=e.indices.buffer;let g=e.indices.offset,v=e.elements.offset;const p=v,m=f.verticesFlattened,b=f.indicesTriangles;for(let w=0;w<m.length;w+=2){const I=es(m[w]),x=es(m[w+1]);let E;a&&x>=le(2,15)-10?E=Wb:l&&x<=10?E=Zb:E=rn(i,I,x),$b(e,v,E.x,E.y,E.z,s),v++}for(let w=0;w<b.length;w++)h[g]=p+b[w],g++;e.elements.offset=v,e.indices.offset=g}function qb(e,t,n=[],i=[]){return{x:Uh(n,e),y:Uh(i,t)}}function Uh(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:Jb(e)}}function Jb(e){var t;return!((t=e==null?void 0:e[0])!=null&&t[0])}function Kb(e,t,n,i,s){return[zh(e.x,t,i[0],s),zh(e.y,n,i[1],s)]}function zh(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 Qb(e,t,n,i,s=0,r=0){return[Vh(Gh(e.x,t),i,s),Vh(Gh(e.y,n),i,r)]}function Gh(e,t){const{stretchSize:n,fixSize:i}=eI(e),{coords:s,isOddStretchable:r}=e,o=t<i?i:t,a=[s[0]];for(let l=1;l<s.length;l++){const c=s[l-1],u=s[l],d=l%2===(r?1:0),f=a[a.length-1];if(!d){a.push(f+u-c);continue}a.push(Math.round((o-i)*(u-c)/n)+f)}return a}function eI({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 Vh(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 tI(e,t,n,i,s,r,o,a,l){const c=qb(n.w,n.h,a,l),u=Kb(c,n.x,n.y,t,ju),d=Qb(c,i,s,ju,r,o);e.set(d,u)}function nI(e,t,n,i,s,r,o,a,l,c,u,d){const{textureX:f,textureY:h,stretchedX:g,stretchedY:v,countX:p,countY:m}=i,b=r!==-1/0?r:lm,w=o!==1/0?o:cm,[I,x]=u;for(let E=0;E<p-1;E++){const C=f[E],T=f[E+1],D=g[E],B=g[E+1];for(let k=0;k<m-1;k++){const j=h[k],U=h[k+1],A=v[k],M=v[k+1];jh(s,0,2,1,1,2,3),So(s,e,t,n,D,A,C,j,I,x,b,w,a,l,c,d),So(s,e,t,n,B,A,T,j,I,x,b,w,a,l,c,d),So(s,e,t,n,D,M,C,U,I,x,b,w,a,l,c,d),So(s,e,t,n,B,M,T,U,I,x,b,w,a,l,c,d)}}}const Ii=[0,0];function iI(e,t,n,i,s,r,o){const{stretchedX:a,stretchedY:l}=i,c=Math.ceil((a[a.length-1]-a[0])/2),u=Math.ceil((l[l.length-1]-l[0])/2),d=r*La/2;Ii[0]=a[0]+c,Ii[1]=l[0]+u;const f=Ii[0]-d,h=Ii[0]+d,g=Ii[1]-d,v=Ii[1]+d;return jh(s,0,2,1,1,2,3),Eo(s,e,t,n,f,g,o),Eo(s,e,t,n,h,g,o),Eo(s,e,t,n,f,v,o),Eo(s,e,t,n,h,v,o),Ii}function So(e,t,n,i,s,r,o,a,l,c,u,d,f,h,g,v){let p=e.elements.offset*18;if(v!==void 0){const{x:m,y:b,z:w}=v(t,n);e.views.position[p]=m,e.views.position[p+1]=b,e.views.position[p+2]=w}else e.views.position[p]=V+t,e.views.position[p+1]=V+n,e.views.position[p+2]=wt(i);e.views.cornerOffset[p]=s,e.views.cornerOffset[p+1]=-r,e.views.checkPointOffset[p]=l,e.views.checkPointOffset[p+1]=c,e.views.texCoords[p]=St(o),e.views.texCoords[p+1]=St(a),e.views.scales[p]=R2(u),e.views.scales[p+1]=F2(d),p=p>>1,e.views.localID[p]=f,e.views.labelingTextureID[p]=h,e.views.spritePointTextureID[p]=g,e.elements.offset++}function Eo(e,t,n,i,s,r,o){const a=e.elements,l=a.stride*a.offset>>1;e.views.position[l]=V+t,e.views.position[l+1]=V+n,e.views.position[l+2]=wt(i),e.views.cornerOffset[l]=s,e.views.cornerOffset[l+1]=-r,e.views.labelingTextureID[l>>1]=o,a.offset++}function jh(e,t,n,i,s,r,o){const{elements:a,indices:l}=e,{buffer:c,offset:u}=l,d=a.offset;c[u]=d+t,c[u+1]=d+n,c[u+2]=d+i,c[u+3]=d+s,c[u+4]=d+r,c[u+5]=d+o,l.offset=u+6}class sI{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 ht=(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))(ht||{}),Mi=(e=>(e[e.Point=0]="Point",e[e.Line=1]="Line",e))(Mi||{}),ar=(e=>(e[e.Tile=0]="Tile",e[e.Floor=1]="Floor",e[e.DynamicObject=2]="DynamicObject",e[e.PersonalPoi=3]="PersonalPoi",e))(ar||{}),Rt=(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))(Rt||{}),Ye=(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))(Ye||{});let Hh=Math.random;const rI=e=>{const t={randomSeed:0};Bf(t,[e]),Hh=()=>Hs(t,0,1)};function oI(e,t,n,i){const s=$h(e,n,i),r=$h(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 $h(e,t,n){const i=e[t];if(i!==void 0)return i[n]}var xn=(e=>(e[e.Point=0]="Point",e[e.Line=1]="Line",e[e.OneWayLine=2]="OneWayLine",e))(xn||{});function pt(e,t){return Number.isNaN(e)?t:e}function Ao(e,t){if(!e)return"";const n=H(e,t);return!Number.isNaN(n)&&(n||n===0)?String(n):""}function aI(e){return e.type==="labelLine"||e.type==="point"||e.type==="oneWayLine"}function lI(e,t,n,i,s){const r=[];for(const o of e)for(const a of o.labels){const l=n.getStyle(a.styleId);if(!l){console.error(`Not found style ${a.styleId} in unpackPreLabelingResult`);continue}const c=l.layersById[a.layerId];if(!c||!aI(c)){console.error(`Not found layer: ${a.layerId} in style ${a.styleId} in unpackPreLabelingResult`);continue}const u=new mc(a,c,t,o.metatileHash,!!i.floorStackOn||!!i._activeFloorIsMetro);switch(a.type){case xn.Point:u.setSpecificPointAttributes(a,i,s);break;case xn.Line:u.setSpecificLineAttributes(a,i,s);break;case xn.OneWayLine:u.setSpecificOneWayAttributes(a);break}r.push(u)}return r}class mc{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=ht.Common,this.iconPriority=0,this.styleIconPriority=0,this.styleTextPriority=0,this.identifyIndex=ft,this.identifyPoiLabelIndex=ft,this.labelingTextureIndex=ft,this.spritePointTextureIndex=ft,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===xn.Point?t.geometryType:Mi.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=Ht(i,n,!0,t.tileData);this.label=Dl(Ao(s.textField,r),s.textMaxLengthPerLine),s.textField2&&(this.label2=Dl(Ao(s.textField2,r),s.textMaxLengthPerLine)),this.layer.type==="point"&&s.iconTextField&&(this.iconLabel=Dl(Ao(s.iconTextField,r),s.textMaxLengthPerLine));const o=gt(t.tileCoords);this.mapPointVertices=[];const a=[0,0,0],l=[0,0,0];if(t.geometryType===Mi.Point)hf(this.mapPointVertices,t.vertices,0,o),this.geoPoint=oe.toGeo(this.mapPointVertices),this.layer.style.allowElevation||(this.mapPointVertices[2]=0);else{for(let c=0;c<t.vertices[0].length;c++)a[0]=t.vertices[0][c],a[1]=t.vertices[1][c],vt(l,a,o),this.mapPointVertices.push(l[0],l[1],l[2]);this.componentDistanceStart=t.componentDistanceStart,this.componentDistanceEnd=t.componentDistanceEnd,this.componentDistanceStartWorld=Hi(this.componentDistanceStart,t.tileCoords[2]),this.objectLengthWorld=Hi(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=Ht(i,n,!0,t.tileData);this.label=Ao(this.layer.style.textField,s);const r=gt(t.tileCoords);this.mapPointVertices=[];const o=[0,0,0],a=[0,0,0];for(let l=0;l<t.vertices[0].length;l++)o[0]=t.vertices[0][l],o[1]=t.vertices[1][l],vt(a,o,r),this.mapPointVertices.push(a[0],a[1],a[2]);this.componentDistanceStart=t.componentDistanceStart,this.componentDistanceEnd=t.componentDistanceEnd,this.componentDistanceStartWorld=Hi(this.componentDistanceStart,t.tileCoords[2]),this.objectLengthWorld=Hi(t.objectLength,t.tileCoords[2]),this.tiers=H(this.layer.ignoreTier,s)?void 0:t.tiers}setSpecificOneWayAttributes(t){const n=gt(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],vt(s,i,n),this.mapPointVertices.push(s[0],s[1],s[2]);this.componentDistanceStart=t.componentDistanceStart,this.componentDistanceEnd=t.componentDistanceEnd,this.componentDistanceStartWorld=Hi(this.componentDistanceStart,t.tileCoords[2]),this.objectLengthWorld=Hi(t.objectLength,t.tileCoords[2]),this.tiers=t.tiers}updateRanges(){this.ranges=Wv([this.label,this.label2,this.iconLabel])}}function Jn(e,t,n){const{minX:i,maxX:s,minY:r,maxY:o}=n;e.push(i,r,s-i,o-r,t)}function _n(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 cI(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 oI(s,r,n,i)}function yc(e,t,n,i,s,r){const o=_n(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 l=0;l<a.length;l++)if(cI(t,a[l].element))return!0;return!1}function Yh(e,t,n,i,s){if(e.placementIndex===-1){s&&Jn(s,Rt.CommercialDead,_n(e,0,i.leftRight,i.topBottom));return}if(yc(t,e,0,i.leftRight,i.topBottom,n))e.placementIndex=-1,s&&Jn(s,Rt.CommercialDead,_n(e,0,i.leftRight,i.topBottom));else{e.placementIndex=0;const o=_n(e,0,i.leftRight,i.topBottom);t.insert(o),s&&Jn(s,Rt.CommercialAlive,o)}}function gc(e,t,n,i){let s=!0;for(let r=0;r<e.boxes.length;r++)if(yc(t,e,r,e.marginLeftRight,e.marginTopBottom,n)){if(s=!1,i)for(let o=0;o<e.boxes.length;o++){const a=_n(e,o,e.marginLeftRight,e.marginTopBottom);let l;o===r?l=Rt.Dead:o<r?l=Rt.Alive:l=Rt.Unused,Jn(i,l,a)}break}if(s)for(let r=0;r<e.boxes.length;r++){const o=_n(e,r,e.marginLeftRight,e.marginTopBottom);t.insert(o),i&&Jn(i,Rt.Alive,o)}e.placementIndex=s?0:-1}function uI(e,t,n,i){e.placementIndex=-1;for(let s=0;s<e.boxes.length;s++)if(!(e.firstLabel&&e.firstLabel.placementIndex!==s))if(yc(t,e,s,e.marginLeftRight,e.marginTopBottom,n))i&&Jn(i,Rt.Dead,_n(e,s,e.marginLeftRight,e.marginTopBottom));else{const r=_n(e,s,e.marginLeftRight,e.marginTopBottom);if(t.insert(r),e.placementIndex=s,i){Jn(i,Rt.Alive,r);for(let o=s+1;o<e.boxes.length;o++)Jn(i,Rt.Unused,_n(e,o,e.marginLeftRight,e.marginTopBottom))}break}}function Wh(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 Ti(e){return e.type!==Ye.Box&&!Number.isNaN(e.commPriorityRandomFactor)}function Zh(e){return e.label.pointType===ht.CommercialCity}function dI(e){return Ti(e)&&Zh(e)}function fI(e){return Ti(e)&&e.label.pointType===ht.CommercialPremium}function lr(e){return e.pointType===ht.Commercial||e.pointType===ht.CommercialCity||e.pointType===ht.CommercialPremium}function hI(e){return e.label.pointType!==ht.CommercialCity||e.placementIndex!==-1&&e.label.pointType===ht.CommercialCity}function pI(e,t){return t.size===0?!1:e.filter(i=>mI(i,t)?(i.adsType=0,!0):!1).length>0}function mI(e,t){return e.type===Ye.Icon&&t.has(e.label.id)}function yI(e){return e.type===Ye.Box&&e.labelingGroup==="markerText"&&e.parent!==void 0}function gI(e,t,n,i,s){const r=lo();Wh(e.filter(Zh),n).forEach(a=>{Yh(a,r,t,i.city,s)}),r.clear(),Wh(e.filter(hI),n).forEach(a=>{Yh(a,r,t,i.default,s)})}function Xh(e,t,n,i,s){switch(e.type){case Ye.LineText:case Ye.Icon:if(e.placementIndex===-1&&Ti(e))break;if(gc(e,n,i,s),e.adsType===0){const o=t.get(e.label.id);if(!o)break;e.placementIndex!==-1&&(o.parent=e,gc(o,n,i,s),t.delete(e.label.id))}break;case Ye.Box:if(!e.parent){gc(e,n,i,s);break}e.placementIndex=-1;break;case Ye.PoiText:case Ye.PoiText2:(!e.parent||e.parent.placementIndex!==-1)&&(!e.firstLabel||e.firstLabel.placementIndex!==-1)?uI(e,n,i,s):e.placementIndex=-1;break}}function vI(e,t,n,i,s,r){const o=[],a=new Map;t.forEach(T=>{if(yI(T)){a.set(T.parent.label.id,T),T.placementIndex=-1;return}o.push(T)});const l=new Set(a.keys());let c=[];if(n.globeMode){for(const T of e)r.ecef.canSee(T.anchorGeo)?c.push(T):T.placementIndex=-1;for(const T of o)r.ecef.canSee(T.anchorGeo)?c.push(T):T.placementIndex=-1}else c=e.concat(o);const u=n.debugLabels?[]:void 0,{size:d,viewport:f}=n,h=d[0],g=d[1],v=(Sr.tileMultiplier-1)/2,p=Math.round(h*v),m=Math.round(g*v),b={minX:f.left-p,maxX:f.left+h+p,minY:f.top-m,maxY:f.top+g+m},w=lo(),I=pI(c,l),x=c.sort((T,D)=>{const B=T.label instanceof mc?T.label.hovered:0,k=D.label instanceof mc?D.label.hovered:0,j=i.has(T.id),U=i.has(D.id),A=n.disableSurvivedPoiPrevalence?0:(U?1:0)-(j?1:0),M=I?(D.adsType===0?1:0)-(T.adsType===0?1:0):0;return D.groupPriority-T.groupPriority||(Ti(D)?D.commPriorityRandomFactor+ +U:0)-(Ti(T)?T.commPriorityRandomFactor+ +j:0)||M||A||k-B||D.itemPriority-T.itemPriority||(D.label.id>T.label.id?1:D.label.id===T.label.id?0:-1)||D.label.layer.innerId-T.label.layer.innerId||D.anchorWorld[0]-T.anchorWorld[0]||D.anchorWorld[1]-T.anchorWorld[1]||T.type-D.type});let E=-1;const C=x.filter((T,D)=>Ti(T)?(E=D,!0):!1);if(E!==-1){for(let T=0;T<=E;T++)Xh(x[T],a,w,b,u);w.clear(),gI(C,b,i,s,u)}for(let T=0;T<x.length;T++)Xh(x[T],a,w,b,u);return u}const vc=new Map;class xo{constructor(t,n,i,s,r,o,a,l){if(this.anchorWorld=[0,0,0,0],this.anchorGeo=[0,0],this.groupPriority=0,this.labelingGroup=Xn,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*Rr(t.geoPoint,l)),this.id=t.id+"_"+n+"_"+Math.floor(i[0]/1e3)+"_"+Math.floor(i[1]/1e3)+this.getIconLabelPriorityToId(t),Bd(this.anchorWorld,i),this.anchorGeo=t.geoPoint,s!==0&&(this.anchorWorld[2]*=s),a){const c=lt.fromGeo(this.anchorGeo);this.anchorScreen=r.ecef.project(c,!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===Ye.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(lr(t))if(vc.has(this.label.id))this.commPriorityRandomFactor=vc.get(this.label.id);else{const c=Hh();this.commPriorityRandomFactor=c,vc.set(this.label.id,c)}n===Ye.PoiText?(this.labelingGroup=this.layer.style.allowOverlap?Zn: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===Ye.PoiText2?(this.labelingGroup=this.layer.style.allowOverlap?Zn: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?Zn: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(lr(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 qh(e,t,n,i,s,r){if(!e||s&&!r)return[0,0];if(!r)return[e.w/t,e.h/t];const o=wc(n,i,r),a=st(n.style.iconTextPadding);return[a[3]+a[1]+o[0],a[0]+a[2]+o[1]]}function _o(e,t,n){return bc(ce(e.style.textFontSize,t),e.style.textLineHeight,n)}function Jh(e,t,n){return bc(ce(e.style.textFontSize2,t),e.style.textLineHeight,n)}function wc(e,t,n){return bc(ce(e.style.iconTextFontSize,t),e.style.iconTextLineHeight,n)}function bc(e,t,n){const s=e/Ut.baseSize*n.maxWidth,r=e*t*n.lines.length;return[s,r]}function Kh(e,t,n){var r,o;const i=(r=n[0])!=null?r:0,s=(o=n[1])!=null?o:0;return[(.5-e.anchorX)*t[0]+i,(.5-e.anchorY)*t[1]+s]}function wI(e,t,n){var a,l,c,u;const i=(a=t[0])!=null?a:.5,s=(l=t[1])!=null?l:.5,r=(c=n[0])!=null?c:0,o=(u=n[1])!=null?u:0;return[(.5-i)*e[0]+r,(.5-s)*e[1]+o]}function Qh(e,t,n,i,s){var c,u,d,f;const r=(c=n[0])!=null?c:.5,o=(u=n[1])!=null?u:.5,a=(d=s[0])!=null?d:0,l=(f=s[1])!=null?f:0;return[e[0]/2-r*t[0]-i[3]+a,e[1]/2-o*t[1]-i[0]+l]}function Po(e,t,n,i,s){const r=t[0],o=t[1],a=n[0],l=n[1];let c=0,u=0;const d=l/2+o/2,f=l/2-o/2,h=-d,g=-f,v=a/2+r/2,p=a/2-r/2,m=-v,b=-p;switch(e){case"bottomCenter":u=d+s;break;case"rightCenter":c=v+s;break;case"topCenter":u=h-s;break;case"leftCenter":c=m-s;break;case"bottomRight":c=p,u=d+s;break;case"topRight":c=p,u=h-s;break;case"bottomLeft":c=b,u=d+s;break;case"rightBottom":c=v+s,u=g;break;case"rightTop":c=v+s,u=f;break;case"topLeft":c=b,u=h-s;break;case"leftTop":c=m-s,u=f;break;case"leftBottom":c=m-s,u=g;break}return[c+i[0],u+i[1]]}var Si=(e=>(e[e.Static=0]="Static",e[e.Unique=1]="Unique",e[e.Loaded=2]="Loaded",e))(Si||{});let e0=1e4+1;const bI={w:0,h:0,x:0,y:0,atlasIndex:0,isPacked:!1},Ic={};function II(e,t,n,i,s,r){const o=Ll(e,s);if(!Ic[o]){const a=e0++;Ic[o]={type:Si.Unique,isSvg:!1,index:a,key:o,name:"",fileName:"",id:e,regionId:n,url:r,rasters:t.map((l,c)=>Me(he({},bI),{rasterSetIndex:a,rasterIndex:c,w:l,h:l,anchorX:i[0],anchorY:i[1]}))}}return Ic[o]}function MI(e){const t=e0++;return{type:Si.Loaded,isSvg:!1,index:t,key:`loaded-${t}`,name:"",fileName:"",rasters:e.map((n,i)=>Me(he({},n),{rasterIndex:i,rasterSetIndex:t}))}}function cr(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 Mc(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 Tc(e,t){const n=t.precomputes;return e.map((i,s)=>{const r=n[s];return r&&r.usage===tt.Uniform?i:null})}var Sc=(e=>(e[e.Icon=0]="Icon",e[e.First=1]="First",e[e.Second=2]="Second",e))(Sc||{});const Ec=new sI,us=[0,0,0],an={symbol:"point",sinks:{raster:{stride:36,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.cornerOffset=new Int16Array(t,8),e.views.texCoords=new Uint16Array(t,12),e.views.scales=new Int16Array(t,16),e.views.checkPointOffset=new Int16Array(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)=>zs([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:32,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.cornerOffset=new Int16Array(t,8),e.views.texCoords=new Uint16Array(t,12),e.views.checkPointOffset=new Int16Array(t,16),e.views.localID=new Uint32Array(t,20),e.views.labelingTextureID=new Uint32Array(t,24),e.views.spritePointTextureID=new Uint32Array(t,28)},packObjectAttributes:(e,t,n,i,s,r,o,a)=>zs([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])=>zs([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:l}=n;if(a.type!=="point")return;const c=Ht(r.styleZoom,r.styleState,!0,l.tileData),u=r.styleState._activeFloorIds.length>0,d=lr(l)&&!u?"":l.floorId,f=t0(c,e,s,l),h=e.icons[ut(a.style.iconImage,c)],g=Mc(h),v=qh(f,s,a,c,g,l.iconTextMetrics),p=st(a.style.iconTextOffset),m=st(a.style.iconTextPadding);let b,w=[0,0];if(f)if(l.iconTextMetrics){const C=st(a.style.iconTextAnchor);b=wc(a,c,l.iconTextMetrics),w=Qh(v,b,C,m,p)}else{const C=st(a.style.iconOffset);w=Kh(f,v,C)}Lt(us,n.anchorWorld,o);const{globeInterStartZoom:I}=Rn;if(!(r.globeMode&&r.zoom<I)&&!bl(us))return;const E=uo(r.styleState,o)?(C,T)=>rn(o,C,T):void 0;switch(n.type){case Ye.Icon:if(!f||g&&!l.iconTextMetrics)return;const C=g?h.stretchX:void 0,T=g?h.stretchY:void 0;if(Ac(t,l,d,us,i,f,v[0]*s,v[1]*s,w[0]*s,w[1]*s,s,C==null?void 0:C.map(([B,k])=>[B*s,k*s]),T==null?void 0:T.map(([B,k])=>[B*s,k*s]),E),!b)return;const D=st(a.style.iconTextAnchor);TI(e,t,l,d,us,r,i,wI(b,D,p),a,s,E);return;case Ye.PoiText:SI(e,t,n,d,us,v,r,i,w,a,s,E);return;case Ye.PoiText2:EI(e,t,n,d,us,v,r,i,w,a,s,E);return}},getLabelingInfo(e,t,n,i,s,r){const{layer:o}=e;if(o.type!=="point")return;e.labelingElements.length=0;const a=Ht(i.styleZoom,i.styleState,!0,e.tileData),l=t0(a,n,r,e),c=n.icons[ut(o.style.iconImage,a)],u=Mc(c),d=qh(l,r,o,a,u,e.iconTextMetrics);let f,h=[0,0];if(l&&(!u||e.iconTextMetrics)){if(e.iconTextMetrics){const m=st(o.style.iconTextAnchor),b=st(o.style.iconTextOffset),w=st(o.style.iconTextPadding);f=wc(o,a,e.iconTextMetrics),h=Qh(d,f,m,w,b)}else{const m=st(o.style.iconOffset);h=Kh(l,d,m)}const p=new xo(e,Ye.Icon,t,i.buildingHeight,s,n,i.globeMode,i.styleState._floorHeight);p.boxes.push([-d[0]/2+h[0],-d[1]/2+h[1],d[0]/2+h[0],d[1]/2+h[1]]),e.labelingElements.push(p)}const g=ut(o.style.textFont,a);e.label.length>0&&g.length&&(xI(e,t,n,d,i,s,h,o),e.label2&&_I(e,t,n,d,i,s,h,o))}};function TI(e,t,n,i,s,r,o,a,l,c,u){var v;const{iconTextMetrics:d}=n;if(!d||!l.style.iconTextFont)return;const f=Ht(r.styleZoom,r.styleState,!1,n.tileData),h=ut(l.style.iconTextFont,f),g=(v=e.fontNameToIndex[h])!=null?v:e.fontNameToIndex[Fi];Lo(t,n,i,0,d,s,o,a,l,g,c,u)}function SI(e,t,n,i,s,r,o,a,l,c,u,d){var x;const{label:f}=n,{textMetrics:h}=f,g=Ht(o.styleZoom,o.styleState,!1,f.tileData),v=ut(c.style.textFont,g);if(!v.length)return;const p=_o(c,g,h),m=(x=e.fontNameToIndex[v])!=null?x:e.fontNameToIndex[Fi],b=n.parent?so(c.style.textPlacement,g):"centerCenter",w=ce(c.style.textOffset,g),I=Po(b,r,p,l,w);Lo(t,f,i,1,f.textMetrics,s,a,I,c,m,u,d)}function EI(e,t,n,i,s,r,o,a,l,c,u,d){var C,T;const{label:f}=n,{textMetrics:h,textMetrics2:g}=f;if(!g||!c.style.textFont2)return;const v=Ht(o.styleZoom,o.styleState,!1,f.tileData),p=ut(c.style.textFont2,v);if(!p.length)return;const m=_o(c,v,h),b=Jh(c,v,g),w=ce(c.style.textOffset,v),I=ce((C=c.style.textOffset2)!=null?C:0,v,0),x=(T=e.fontNameToIndex[p])!=null?T:e.fontNameToIndex[Fi],E=Po(so(c.style.textPlacement,v),r,[b[0],m[1]],l,w);E[1]+=(m[1]+b[1])/2+I,Lo(t,f,i,2,g,s,a,E,c,x,u,d)}function Lo(e,t,n,i,s,r,o,a,l,c,u,d){if(i===1&&t.labelingElements.length===1){const h=e.getBucket("point","labelingTexture",an.sinks.labelingTexture.packObjectAttributes(t),an.sinks.labelingTexture.binder);t.checkPointOffset=LI(h,r,s,l,u,t.labelingTextureIndex)}const f={};for(const h of t.ranges)f[h]=e.getBucket("point","text",an.sinks.text.packObjectAttributes(t,o,h,a,i,c,n,Tc(t.tileData,l)),an.sinks.text.binder);PI(f,t,r,s,l,i,t.checkPointOffset,d)}function AI(e,t,n,i,s,r,o,a){return Ac(e,t,n,i,s,r,r.w,r.h,r.w*(.5-r.anchorX),r.h*(.5-r.anchorY),o,void 0,void 0,a)}function Ac(e,t,n,i,s,r,o,a,l,c,u,d,f,h){if(o<=0||a<=0)return;const g=t.layer;if(g.type!=="point")return;tI(Ec,dn,r,o,a,l,c,d,f),e.atlasPacker.addRastersToLoad(t.styleId,r);const v=e.getBucket("point","labelingTexture",an.sinks.labelingTexture.packObjectAttributes(t),an.sinks.labelingTexture.binder);t.checkPointOffset=iI(i[0],i[1],i[2],Ec,v,u,t.labelingTextureIndex);const p=e.getBucket("point","raster",an.sinks.raster.packObjectAttributes(t,s,r.atlasIndex,d!==void 0||f!==void 0,n,Tc(t.tileData,g)),an.sinks.raster.binder);nI(i[0],i[1],i[2],Ec,p,-1/0,1/0,t.identifyIndex,t.labelingTextureIndex,t.spritePointTextureIndex,t.checkPointOffset,h)}function xI(e,t,n,i,s,r,o,a){const{textMetrics:l}=e;if(!l)return;const c=Ht(s.styleZoom,s.styleState,!1,e.tileData),u=ce(a.style.textOffset,c),d=_o(a,c,l),f=new xo(e,Ye.PoiText,t,s.buildingHeight,r,n,s.globeMode,s.styleState._floorHeight);e.labelingElements.length>0&&(f.parent=e.labelingElements[0]);const h=f.parent?so(a.style.textPlacement,c):"centerCenter",g=Po(h,i,d,o,u);f.boxes.push([g[0]-d[0]/2,g[1]-d[1]/2,g[0]+d[0]/2,g[1]+d[1]/2]),e.labelingElements.push(f)}function _I(e,t,n,i,s,r,o,a){var m;const{textMetrics:l,textMetrics2:c}=e;if(!c)return;const u=Ht(s.styleZoom,s.styleState,!1,e.tileData),d=_o(a,u,l),f=Jh(a,u,c),h=ce(a.style.textOffset,u),g=ce((m=a.style.textOffset2)!=null?m:0,u,0),v=new xo(e,Ye.PoiText2,t,s.buildingHeight,r,n,s.globeMode,s.styleState._floorHeight);e.labelingElements.length>1?(v.parent=e.labelingElements[0],v.firstLabel=e.labelingElements[1]):e.labelingElements.length>0&&(v.parent=e.labelingElements[0],v.firstLabel=e.labelingElements[0]);const p=Po(so(a.style.textPlacement,u),i,[f[0],d[1]],o,h);p[1]+=(d[1]+f[1])/2+g,v.boxes.push([p[0]-f[0]/2,p[1]-f[1]/2,p[0]+f[0]/2,p[1]+f[1]/2]),e.labelingElements.push(v)}function t0(e,t,n,i){const{rasterSets:s}=t,{layer:r}=i;if(r.type!=="point")return;let o;const a=lr(i);if(a||i.pointType===ht.Landmark)o=s.byKey[Ll(i.id,a?"commercial":"landmark")];else{const l=ut(r.style.iconImage,e);if(l.length){const c=st(r.style.iconAnchor);o=s.byKey[Xi(l,c[0],c[1])]}}if(o){const l=ce(r.style.iconWidth,e),c=cr(o.rasters,l*n,!0);if(c!==void 0)return o.rasters[c]}}const Co=[0,0];function PI(e,t,n,i,s,r,o,a){let{textLineHeight:u,textLetterSpacing:d}=s.style;r===Sc.Icon&&(u=s.style.iconTextLineHeight,d=s.style.iconTextLetterSpacing);const{identifyPoiLabelIndex:f,labelingTextureIndex:h,spritePointTextureIndex:g}=t,{lines:v,maxWidth:p}=i,m=u*Ut.baseSize;let b=n0(1,m,v.length);for(let w=0;w<v.length;w++){const I=v[w].width;let x=0;x=-I/2,Co[0]=x,Co[1]=b;const E=v[w].glyphs;for(let C=0;C<E.length;C++){const T=E[C];T.bitmap!==void 0&&OI(e[T.range],n,Co,T,f,h,g,o,a),Co[0]+=T.advance+Ut.baseSize*d}b-=m}}const ln=[0,0];function LI(e,t,n,i,s,r){const{lines:o,maxWidth:a}=n;if(!o.length)return ln[0]=0,ln[1]=0,ln;const{textLineHeight:l}=i.style,c=l*Ut.baseSize,u=-a/2,d=n0(1,c,o.length),f=a/2,h=d-(o.length-1)*c;ln[0]=s*(u+f)/2,ln[1]=s*(d+h)/2;const g=s*La/2,v=ln[0]-g,p=ln[0]+g,m=ln[1]+g,b=ln[1]-g,w=e.elements.offset;return No(e.indices,w,1,0,3,2,3,0),Oo(e,t,v,m,r),Oo(e,t,p,m,r),Oo(e,t,v,b,r),Oo(e,t,p,b,r),ln}function CI(e,t,n,i,s,r,o){const a=n[1]+i.top,l=n[0]+i.left,c=a-i.height,u=l+i.width,d=Math.sin(s),f=Math.cos(s),h=l*f-a*d,g=l*d+a*f,v=u*f-a*d,p=u*d+a*f,m=l*f-c*d,b=l*d+c*f,w=u*f-c*d,I=u*d+c*f,x=e.elements.offset;Fo(e,t,h,g,i.texLeft,i.texTop,r,o),Fo(e,t,v,p,i.texRight,i.texTop,r,o),Fo(e,t,m,b,i.texLeft,i.texBottom,r,o),Fo(e,t,w,I,i.texRight,i.texBottom,r,o),No(e.indices,x,1,0,3,2,3,0)}function DI(e,t,n){const i=e.elements.offset,s=$e(Math.cos(n)),r=$e(Math.sin(n));Ro(e,t,s,r,-1,-1),Ro(e,t,s,r,1,-1),Ro(e,t,s,r,1,1),Ro(e,t,s,r,-1,1),No(e.indices,i,0,1,2,2,3,0)}function n0(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 OI(e,t,n,i,s,r,o,a,l){const c=n[1]+i.top,u=n[0]+i.left,d=c-i.height,f=u+i.width,[h,g]=a,v=e.elements.offset;Do(e,t,u,c,i.texLeft,i.texTop,h,g,s,r,o,l),Do(e,t,f,c,i.texRight,i.texTop,h,g,s,r,o,l),Do(e,t,u,d,i.texLeft,i.texBottom,h,g,s,r,o,l),Do(e,t,f,d,i.texRight,i.texBottom,h,g,s,r,o,l),No(e.indices,v,1,0,3,2,3,0)}function Do(e,t,n,i,s,r,o,a,l,c,u,d){const f=e.elements,h=f.stride*f.offset>>1,g=h>>1;if(d!==void 0){const{x:v,y:p,z:m}=d(t[0],t[1]);e.views.position[h]=v,e.views.position[h+1]=p,e.views.position[h+2]=m}else e.views.position[h]=V+t[0],e.views.position[h+1]=V+t[1],e.views.position[h+2]=wt(t[2]);e.views.cornerOffset[h]=n,e.views.cornerOffset[h+1]=i,e.views.checkPointOffset[h]=o,e.views.checkPointOffset[h+1]=a,e.views.texCoords[h]=s,e.views.texCoords[h+1]=r,e.views.localID[g]=l,e.views.labelingTextureID[g]=c,e.views.spritePointTextureID[g]=u,f.offset++}function Oo(e,t,n,i,s){const r=e.elements,o=r.stride*r.offset>>1;e.views.position[o]=V+t[0],e.views.position[o+1]=V+t[1],e.views.position[o+2]=wt(t[2]),e.views.cornerOffset[o]=n,e.views.cornerOffset[o+1]=i,e.views.labelingTextureID[o>>1]=s,r.offset++}function Fo(e,t,n,i,s,r,o,a){const l=e.elements;let c=l.stride*l.offset>>1;e.views.position[c]=V+t[0],e.views.position[c+1]=V+t[1],e.views.position[c+2]=wt(t[2]),e.views.texCoords[c]=s,e.views.texCoords[c+1]=r,c=c>>1,e.views.cornerOffset[c]=n,e.views.cornerOffset[c+1]=i,e.views.styleZoomLimits[c]=o,e.views.styleZoomLimits[c+1]=a,l.offset++}function Ro(e,t,n,i,s,r){const o=e.elements.stride*e.elements.offset,a=o/e.views.position.BYTES_PER_ELEMENT,l=o/e.views.direction.BYTES_PER_ELEMENT;e.views.position[a]=V+t[0],e.views.position[a+1]=V+t[1],e.views.direction[l]=n,e.views.direction[l+1]=i,e.views.widenDirection[l]=s,e.views.widenDirection[l+1]=r,e.elements.offset++}function No(e,t,n,i,s,r,o,a){const l=e.buffer,c=e.offset;l[c]=t+n,l[c+1]=t+i,l[c+2]=t+s,l[c+3]=t+r,l[c+4]=t+o,l[c+5]=t+a,e.offset=c+6}const xc=[0,0,0],ur=[0,0],Bo={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)=>zs([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){var T;const{label:a,anchorPosition:l,anchorSegmentIndex:c,halfLabelWidth:u,layer:d}=n;if(d.type!=="labelLine")return;const{axis:f}=a,{center:h,styleZoom:g}=r,v=Ht(g,r.styleState,!1,a.tileData),p=ut(d.style.textFont,v),m=(T=e.fontNameToIndex[p])!=null?T:e.fontNameToIndex[Fi],b={},w=H(d.ignoreTier,v)?null:a.tiers;for(const D of a.ranges)b[D]=t.getBucket("labelLine","raster",Bo.sinks.raster.packObjectAttributes(a,i,D,m,w!=null?w:null,Tc(a.tileData,d)),Bo.sinks.raster.binder);const I=a.textMetrics.lines[0],x=ce(d.style.textFontSize,v)/Ut.baseSize,E=I.glyphs,C=FI(f,l,u,r.rotation);ur[0]=-I.width/2,ur[1]=0;for(let D=0;D<E.length;D++){const B=E[D],k=(ur[0]+B.left+B.width/2)*x*(C?-1:1),j=Er(k)||1;let U=-1/0,A=1/0;for(let M=c;M>=1&&M<f.vertexCount&&!(A<n.overflowStyleZoom);M+=j,A=U){const S=j===1?M:M-1;U=zd(Cd(k,f.lengths[S]-l),h);const L=f.interpolate(l,M);Lt(xc,L,o),bl(xc)&&B.bitmap!==void 0&&CI(b[B.range],xc,ur,B,L[3]+(C?Math.PI:0),Math.max(U,n.overflowStyleZoom),A)}ur[0]+=B.advance+Ut.baseSize*d.style.textLetterSpacing}},getLabelingInfo(){}};function FI(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 _c=[0,0,0],ko={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)=>zs([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){var u;const{label:a,anchorWorld:l}=n;if(Lt(_c,l,o),!bl(_c))return;const c=t.getBucket("oneWayLine","raster",ko.sinks.raster.packObjectAttributes(a,i,(u=a.tiers)!=null?u:null),ko.sinks.raster.binder);DI(c,_c,l[3])},getLabelingInfo(){}},Ei={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(H(n.style.weight,s));if(Number.isNaN(a)){console.error("Can't resolve style.weight to number");return}const l=e.getBucket(n.type,"framebuffer",Ei.sinks.framebuffer.packObjectAttributes(t,n.innerId),Ei.sinks.framebuffer.binder);for(let c=0;c<r.length;c++)NI(l,0,1,2,2,1,3),zo(l,r[c],o[c],-1,-1,a),zo(l,r[c],o[c],1,-1,a),zo(l,r[c],o[c],-1,1,a),zo(l,r[c],o[c],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",Ei.sinks.fill.packObjectAttributes(t,n,i,s),Ei.sinks.fill.binder);let l=a.elements.offset;RI(a.indices,l,0,1,2,0,2,3),Uo(a,l++,r[0],o[0]),Uo(a,l++,r[1],o[1]),Uo(a,l++,r[2],o[2]),Uo(a,l++,r[3],o[3]),a.elements.offset=l}};function Uo(e,t,n,i){const s=t*2;e.views.position[s]=n,e.views.position[s+1]=i}function RI(e,t,n,i,s,r,o,a){const l=e.buffer,c=e.offset;l[c]=t+n,l[c+1]=t+i,l[c+2]=t+s,l[c+3]=t+r,l[c+4]=t+o,l[c+5]=t+a,e.offset=c+6}function zo(e,t,n,i,s,r){const o=e.elements.offset*e.elements.stride,a=o>>1,l=a>>1;e.views.position[a]=V+t,e.views.position[a+1]=V+n,e.views.weight[l]=r,e.views.widen[o]=i,e.views.widen[o+1]=s,e.elements.offset++}function NI(e,t,n,i,s,r,o){const{elements:a,indices:l}=e,{buffer:c,offset:u}=l,d=a.offset;c[u]=d+t,c[u+1]=d+n,c[u+2]=d+i,c[u+3]=d+s,c[u+4]=d+r,c[u+5]=d+o,l.offset=u+6}const BI=new Set(dd),kI=new Set(ka),UI=new Set(Ua),zI=new Set(hd),GI=new Set(pd),VI=new Set(fd);function Go(e){return BI.has(e)}function i0(e){return kI.has(e)}function s0(e){return UI.has(e)}function jI(e){return zI.has(e)}function r0(e){return GI.has(e)}function HI(e){return VI.has(e)}const o0=(e,t,n,i,s,r,o,a,l,c,u)=>{var k,j,U,A;const{tileProps:d,tileAttrs:f}=i;if($I(e,t,n,i,c,u),u)return;let h=ht.Common;const g=f[d.db_sublayer];i0(g)?h=ht.CommercialCity:s0(g)?h=ht.CommercialPremium:Go(g)?h=ht.Commercial:r0(g)&&(h=ht.Landmark);const v=l.x.length===1?Mi.Point:Mi.Line;let p=[],m;if(v===Mi.Point){if(i&&n.style.allowElevation){const M=ce(n.style.elevation,i);if(Number.isNaN(M))typeof l.z!="undefined"&&(l.z=[r<4?mf(l.z[0]):l.z[0]]);else{const S=M*ve*Ct(gt(o),[l.x[0],l.y[0]]);l.z=[S]}}p=[[l.x[0]],[l.y[0]],typeof l.z!="undefined"?[l.z[0]]:[0]],m=[0,0,0],vt(m,[p[0][0],p[1][0],p[2][0]],gt(o))}else p=[l.x,l.y];const b=(k=i.id)!=null?k:"",w=(j=f[d.db_plan_id])!=null?j:"",I=(U=f[d.db_plan_level])!=null?U:NaN;let x=ft,E=ft;Number.isNaN(b)||(x=e.idIndexer.getIndex(i,t.id,n,{objectClass:f[d.db_object_class],instanceId:0,metatile:s,center:m,floorId:w,ignoreHover:!0}),E=e.idIndexer.getIndex(i,t.id,n,{objectClass:f[d.db_object_class],instanceId:1,metatile:s,center:m,floorId:w,ignoreHover:!0}));const C=f[d.db_point_building_id],T=e.pointIndexer.getIndex(w||C),D=e.pointIndexer.getIndex(b),B={type:xn.Point,pointType:h,geometryType:v,styleId:t.id,layerId:n.innerId,sourceId:a,tileCoords:o,id:(A=i.id)!=null?A:"",floorId:w,planLevel:I,identifyIndex:x,identifyPoiLabelIndex:E,labelingTextureIndex:T,spritePointTextureIndex:D,labelPriority:pt(f[d.db_label_priority],0),label2Priority:pt(f[d.db_label2_priority],0),styleIconPriority:ce(n.style.iconPriority,i),styleTextPriority:ce(n.style.textPriority,i),iconPriority:pt(f[d.db_icon_priority],0),hovered:pt(f[d.hovered],0),componentDistanceStart:pt(f[d.componentDistanceStart],0),componentDistanceEnd:pt(f[d.componentDistanceEnd],0),objectLength:pt(f[d.objectLength],0),vertices:p,demElevation:NaN,tileData:[...i.tileData]};e.addLabel(B)};function $I(e,t,n,i,s,r){var v;const{tileProps:o,tileAttrs:a}=i,{rasterSets:l,icons:c}=t,u=Bl(s),d=wi(n.style.iconWidth),f=Go(a[o.db_sublayer]),h=r0(a[o.db_sublayer]),g=st(n.style.iconAnchor);if(f||h){if(r)return;const p=f?Da.rasterSizes:md,m=II((v=i.id)!=null?v:"",p,a[o.db_region],g,f?"commercial":"landmark",o.url_src?a[o.url_src]:void 0);e.atlasPacker.addNewRasterSet(t.id,m),e.atlasPacker.pack(m,d,u)}else wi(n.style.iconImage).forEach(p=>{if(!p.length)return;const m=l.byKey[Xi(p,g[0],g[1])];if(!m){console.error(`Not found raster set with image ${p}, anchorX: ${g[0]}, anchorY: ${g[1]}`);return}if(!m.isSvg)return;const b=c[p],w=b&&Mc(b)?[{w:b.width,h:b.height}]:d.map(I=>({w:I,h:I}));e.atlasPacker.packSvg(m,w,u),r&&m.rasters.forEach(I=>e.atlasPacker.addRastersToLoad(t.id,I))})}const YI=(e,t,n,i,s,r,o)=>{var l;const a={type:xn.Line,styleId:t,layerId:n.innerId,sourceId:s,tileCoords:i,id:(l=r.id)!=null?l:"",floorId:r.tileAttrs[r.tileProps.db_plan_id]||"",planLevel:r.tileAttrs[r.tileProps.db_plan_level]||NaN,componentDistanceStart:pt(r.tileAttrs[r.tileProps.componentDistanceStart],0),componentDistanceEnd:pt(r.tileAttrs[r.tileProps.componentDistanceEnd],0),objectLength:pt(r.tileAttrs[r.tileProps.objectLength],0),labelPriority:pt(r.tileAttrs[r.tileProps.db_label_priority],0),styleIconPriority:ce(n.style.textPriority,r),styleTextPriority:ce(n.style.textPriority,r),vertices:[o.x,o.y],tileData:[...r.tileData],tiers:H(n.ignoreTier,r)?void 0:r.tileAttrs[r.tileProps.db_tiers]};e.addLabel(a)},WI=(e,t,n,i,s,r,o)=>{var d;const{tileProps:a,tileAttrs:l}=r,c=H(n.ignoreTier,r)?null:l[a.db_tiers],u={type:xn.OneWayLine,styleId:t,layerId:n.innerId,sourceId:s,tileCoords:i,id:(d=r.id)!=null?d:"",floorId:r.tileAttrs[r.tileProps.db_plan_id]||"",planLevel:r.tileAttrs[r.tileProps.db_plan_level]||NaN,componentDistanceStart:pt(r.tileAttrs[r.tileProps.componentDistanceStart],0),componentDistanceEnd:pt(r.tileAttrs[r.tileProps.componentDistanceEnd],0),objectLength:pt(r.tileAttrs[r.tileProps.objectLength],0),labelPriority:pt(r.tileAttrs[r.tileProps.db_label_priority],0),styleIconPriority:ce(n.style.priority,r),styleTextPriority:0,vertices:[o.x,o.y],tileData:[...r.tileData],tiers:c};e.addLabel(u)};function ZI(e,t,n){return Fs(n.fontUrlTemplate,{name:e,range:String(t)})}function Pc(e,t,n){const i=Pn(e)?e:Kn(t.iconBaseUrl,e);return Fs(i,{subdomain:n,appHost:window.location.host})}function XI(e,t){return Pn(e)?e:Kn(t.modelsBaseUrl,e)}function qI(e,t,n,i){return Pn(e)?e:u0(e)?n?zi(e,{sharedModelsPath:n}):"":t?u0(t)?zi(t,{modelSrc:e,subdomain:of(i)}):Kn(t,e):e}function a0(e,t,n){return e.replace("image",`image_${t}x${n}`)}const l0=/_i$/;function JI(e){return l0.test(e)}function c0(e){return e.replace(l0,"")}function KI(e,t){const n=Pn(t.fontsPath)?t.fontsPath:Kn(t.rootUrl,t.fontsPath),i="{name}_{range}.pbf";e.fontUrlTemplate=Kn(n,i),e.iconBaseUrl=Pn(t.iconsPath)?t.iconsPath:Kn(t.rootUrl,t.iconsPath),e.modelsBaseUrl=Pn(t.modelsPath)?t.modelsPath:Kn(t.rootUrl,t.modelsPath)}function QI(e){return Pn(e.stylePath)?e.stylePath:Kn(e.rootUrl,e.stylePath)}const eM=new RegExp("^(?:(?:[a-z]+:)?(?:[a-z]+:)?//|data:)","i");function Pn(e){return eM.test(e)}function u0(e){return/{\w+}/g.test(e)}function Kn(...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 d0(e,t,n){const i=st(n.style.iconAnchor),s=Xi(e,i[0],i[1]);return t.rasterSets.byKey[s]}function tM(e,t,n,i){const s=t.icons[n.name];if(!s)return;const r=cr(n.rasters,i*window.devicePixelRatio,!0);if(r===void 0)return;const o=Pc(s.url,t,ul(e.map.state.subdomains,n.name)),{w:a,h:l}=n.rasters[r];return{fullUrl:o,name:n.name,width:a,height:l}}function nM(e,t,n,i){const s=c0(i),r=d0(s,t,n);if(!r)return;const o=t.icons[r.name];if(o)return Pc(o.url,t,ul(e.map.state.subdomains,r.name))}function iM(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=qf(e.map.state.styleZoom,e.map.state.styleState,[]);let o;const a=s.style.iconWidth,l=ce(a,r);if(n.isCommercial){o=i.rasterSets.byKey[Ll(t.id,"commercial")];const f=o.url;if(!f)return;const h=cr(o.rasters,l*window.devicePixelRatio,!0);if(h===void 0)return;const{w:g,h:v}=o.rasters[h],p=a0(f,g,v);return{baseUrl:f,fullUrl:p,width:g,height:v}}const c=s.style.iconImage;if(!c)return;const u=ut(c,r);if(o=d0(u,i,s),!o)return;const d=tM(e,i,o,l);if(d){if(JI(u)){const f=nM(e,i,s,u);f!==void 0&&(d.fullUrlUnhovered=f,d.nameUnhovered=c0(u))}return d}}function sM(e){return Array.isArray(e)?e:[e]}function rM(e){return e&&e.buffer instanceof ArrayBuffer}var Ai=(e=>(e[e.None=0]="None",e[e.Zoom=1]="Zoom",e[e.Distance=2]="Distance",e))(Ai||{}),f0=(e=>(e[e.default=0]="default",e[e.flat=1]="flat",e[e.axis=2]="axis",e[e.centroid=3]="centroid",e))(f0||{});const Ln=[0,0,0],Ne=new Array(16),Lc=new Float32Array(9),Cn=[0,0,0],Cc=[0,0,0],Dc=[0,0,0],xi=[0,0,0],Vo=[0,0,0],h0=[0,0,0],oM=ot(),aM=Or([1,1,1]),Qn={symbol:"gltfModel",sinks:{instances:{stride:64,binder:(e,t)=>{e.views.position=new Uint16Array(t,0),e.views.matrix=new Float32Array(t,8),e.views.absZ=new Float32Array(t,44),e.views.flatHeight=new Float32Array(t,48),e.views.localID=new Uint32Array(t,52),e.views.labelingTextureID=new Uint32Array(t,56)},packObjectAttributes(e,t,n,i,s,r,o,a,l,c=[],u,d,f,h,g,v,p,m){return Re([e,t.innerId,n,c,l,r,o,i,s,u,d,f,h,g,v,p,m],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,l,c,u=0,d){var K,G,q,J;let f=Qr(H(n.style.geometryModifier,i),r,s,i);if(f===null)return;const{tileAttrs:h,tileProps:g}=i;if(h[g.db_geometry_type]==="polygon"){if(isNaN(h[g.tech_db_model_pos_x])||isNaN(h[g.tech_db_model_pos_y]))return;f={x:[h[g.tech_db_model_pos_x]],y:[h[g.tech_db_model_pos_y]],z:[0]}}const v=H(n.style.linkedIds,i),p=v===""?[]:sM(v),m=n.style.modelSrc,b=[];let w=Ai.None;const I=wi(m,i,n,!0),x=H(n.style.scene,i);if(I.length===1)b.push(0);else if(I.length>1){if(!sn(m)||m.type!=="step"||!sn(m.value)){console.error(`Only step-expression is allowed as 'modelSrc' style property. Models won't be displayed for layer ${n.id}`);return}switch(m.value.type){case"zoom":w=Ai.Zoom;break;case"distance":w=Ai.Distance;break;default:console.error(`'${m.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}m.steps.forEach(({key:X})=>{b.push(X)})}w===Ai.Distance&&I.reverse(),I.forEach((X,se)=>{X===null&&se!==0&&(I[se]=I[se-1])}),w===Ai.Distance&&I.reverse();const E=I.map(X=>X===null?"":X).map(X=>{let se=t.modelIndex[X];return se===void 0&&(X=qI(X,a!=null?a:"",d!=null?d:"",r.coords),se=e.addUsedModelByUrl(X)),e.addUsedModel(se),se});let C=Zt;n.interactive?i.id&&(C=h[g.hovered]?ft:e.idIndexer.getIndex(i,t.id,n,{metatile:c,objectClass:h[g.db_object_class]})):C=n.interactiveOcclusion?Zt:ft;const T=(K=i.id)!=null?K:"-1",D=h[g.db_point_building_id],B=h[g.db_hidden_by_metro_building_id]||"",k=h[g.db_plan_id];let j=Zt;i.id&&(j=e.pointIndexer.getIndex((G=k!=null?k:D)!=null?G:i.id));const U=l!=null&&l.has(h[g.db_sublayer])&&T!=="-1"?1:0,A=f.abs_z!==void 0&&Array.from(f.abs_z).some(X=>X)?f.abs_z:void 0,M=i.styleState.terrainEnabled===!0,S=i.tileAttrs[i.tileProps.db_extension_to_relief_surface],L=M&&!!A&&!Number.isNaN(S),_=!!i.tileAttrs[i.tileProps.db_ignore_z]&&!!A&&M,F=typeof i.sourceAttrs.sourceName=="string"?i.sourceAttrs.sourceName:"",O=e.getBucket("gltfModel","instances",Qn.sinks.instances.packObjectAttributes(t.id,n,E,b,w,o,F,i,U,U?Ns(f.x[0],f.y[0],r):void 0,D,!!A,h[g.db_plan_id]||"",B,sv(r,f.x[0],f.y[0],u),L,_,x),Qn.sinks.instances.binder);let N=O.meta;if(N)N.linkedIds.push(...p);else{const X=g.db_plan_id?h[g.db_plan_id]:void 0;N=O.meta={linkedIds:p.slice(),modelsPath:a!=null?a:"",sharedModelsPath:d!=null?d:"",buildingId:T,planId:X}}U&&(N.sublayer=h[g.db_sublayer]),D&&(N.childrenIds||(N.childrenIds=[]),N.childrenIds.push(T));let R;const z=uM(h,i);if(z){const X=f.x[0],se=f.y[0];vt(Vo,[X,se],r),R=[Vo,oe.fromGeo(z)]}const Z=dM(h,i),Y=fM(h,i);let ee=0;for(let X=0;X<f.x.length;X++){if(De(Cc,0,0,0),Ar(H(n.style.rotation,i),Cc),De(Cn,1,1,1),Ar(H(n.style.scale,i),Cn),De(Dc,0,0,0),Ar(H(n.style.offset,i),Dc),f.xScaleDirection&&f.yScaleDirection&&f.scaleCorrection){const se=f.x[X],me=f.y[X];vt(Vo,[se,me],r);const re=f.xScaleDirection[X],W=f.yScaleDirection[X];vt(h0,[re,W],r),R=[Vo,h0],ee=f.scaleCorrection[X]}p0(f.x[X],f.y[X],(J=(q=f.z)==null?void 0:q[X])!=null?J:0,Dc,Cn,Cc,R,ee,Z,Y,r),hM(O,Ln,Lc,C,j,A==null?void 0:A[X])}},patchBuffer(e,t,n,i,s,r,o,a){const l=Qn.sinks.instances.stride*t;if(p0(i[0],i[1],i[2],s,r,o,void 0,void 0,void 0,void 0,n),a){const u=rn(n,Ln[0],Ln[1]);e.subData(l+0,new Uint16Array([u.x,u.y,u.z]))}else{const u=Ln[0]+V,d=Ln[1]+V;e.subData(l+0,new Uint16Array([u,d,0]))}e.subData(l+8,Lc);const c=Ln[2]/(32*Ze);e.subData(l+48,new Float32Array([c]))}};function lM(e,t,n,i){const s=n*ne/jt(i.coords[2]);_t(t,t,s),t[2]*=n,ai(e,e,t)}function p0(e,t,n,i,s,r,o,a,l,c,u){De(Ln,e,t,n);const d=Ct(u,Ln)*ve;if(Ya(Ne),Lr(Ne,Ne,Te(r[2])),xd(Ne,Ne,Te(r[1])),Za(Ne,Ne,Te(r[0])),Bi(Ne,Ne,s),o)if(a)cM(Ne,o[0],o[1]),De(Cn,a*ve,a*ve,d),Bi(Ne,Ne,Cn);else{fn(xi,o[1],o[0]),l?Lr(Ne,Ne,l):Lr(Ne,Ne,Math.atan2(xi[1],xi[0]));const f=c!=null?c:_r(xi);De(Cn,f,f,f),Bi(Ne,Ne,Cn)}else De(Cn,d,d,d),Bi(Ne,Ne,Cn);Za(Ne,Ne,Math.PI/2),Py(Lc,Ne),lM(Ln,i,d,u)}function cM(e,t,n){fn(xi,n,t),Lr(e,e,Math.atan2(xi[1],xi[0]))}function uM(e,t){const n=e[t.tileProps.direction];return n===void 0?null:Array.isArray(n)?n:n.type==="Point"?n.coordinates:null}function dM(e,t){return e[t.tileProps.angle]}function fM(e,t){return e[t.tileProps.scale]}function hM(e,t,n,i,s,r){const o=e.elements.offset*Qn.sinks.instances.stride,a=e.views,l=o/a.position.BYTES_PER_ELEMENT,c=V+t[0],u=V+t[1],d=t[2]*pf;if(a.position[l]=c,a.position[l+1]=u,a.position[l+2]=0,a.flatHeight[o/a.flatHeight.BYTES_PER_ELEMENT]=d/Ze,e.elements.offset>e.elements.maximum-1)return;a.matrix.set(n,o/a.matrix.BYTES_PER_ELEMENT),a.localID[o/a.localID.BYTES_PER_ELEMENT]=i,a.labelingTextureID[o/a.labelingTextureID.BYTES_PER_ELEMENT]=s,a.absZ[o/a.absZ.BYTES_PER_ELEMENT]=r!=null?r:0,pM(e,c,u,d,n);const f=e.indices;f.buffer[f.offset]=e.elements.offset,f.offset++,e.elements.offset++}function pM(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=oM;Vy(s,o);const a=Or(o)/aM;a>e.maxDiag&&(e.maxDiag=a)}const m0=[0,0,0],y0=[0,0,0],g0=[0,0,0],jo=[0,0,0],ds={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)=>Re([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){var E;const l=s.x,c=s.y,u=(E=s.signed_z)!=null?E:[],d=s.gradient,f=s.is_pivot,h=s.abs_z,g=l.length,v=a==null?void 0:a[0],p=a==null?void 0:a[1];if(g<3)return;const m=ne/o.size,b=e.getBucket("mapMesh","fill",ds.sinks.fill.packObjectAttributes(t,n,r,!!h,i),ds.sinks.fill.binder),w=b.indices.buffer;let I=b.indices.offset;const x=b.elements.offset;for(let C=2;C<g;C++){const T=!(C%2),D=T?C-2:C-1,B=T?C-1:C-2;mM(w,I,x,(C-2)*3+2),De(g0,l[D],c[D],u[D]*m),De(y0,l[B],c[B],u[B]*m),De(m0,l[C],c[C],u[C]*m),Hd(jo,g0,y0,m0),Oc(b,l[D],c[D],u[D],d==null?void 0:d[D],f==null?void 0:f[D],h==null?void 0:h[D],jo,v,p),Oc(b,l[B],c[B],u[B],d==null?void 0:d[B],f==null?void 0:f[B],h==null?void 0:h[B],jo,v,p),Oc(b,l[C],c[C],u[C],d==null?void 0:d[C],f==null?void 0:f[C],h==null?void 0:h[C],jo,v,p),I+=3}b.indices.offset=I}};function mM(e,t,n,i){e[t]=n+i-2,e[t+1]=n+i-1,e[t+2]=n+i}function Oc(e,t,n,i,s,r,o,a,l=t,c=n){const u=e.elements.offset*e.elements.stride,d=u/e.views.position.BYTES_PER_ELEMENT,f=u/e.views.normal.BYTES_PER_ELEMENT,h=u/e.views.demPosition.BYTES_PER_ELEMENT;e.views.position[d]=V+t,e.views.position[d+1]=V+n,e.views.height[u/e.views.height.BYTES_PER_ELEMENT]=i,e.views.normal[f]=$e(a[0]),e.views.normal[f+1]=$e(a[1]),e.views.normal[f+2]=$e(a[2]),e.views.gradient[u/e.views.gradient.BYTES_PER_ELEMENT]=s!=null?s:0,e.views.isPivot[u/e.views.isPivot.BYTES_PER_ELEMENT]=r!=null?r:0,e.views.demPosition[h]=(V+l)/8,e.views.demPosition[h+1]=(V+c)/8,o!==void 0&&(e.views.absZ[u/e.views.absZ.BYTES_PER_ELEMENT]=o),e.elements.offset++}const yM=1,Fc=-1,gM=1.3,v0=-200,w0=-300,vM=Math.tan(Te(175/2)),Nt=[0,0,0],ei=[0,0,0],wM=[0,0,0],dr=[0,0,0],Rc=[0,0,0],Ue=[0,0,0];let Ho=0,fr=0;const bM=(e,t)=>e<0||t<0?Math.floor(Math.min(e,t)):Math.ceil(Math.max(e,t)),b0={symbol:"overpass",sinks:{},generate(e,t,n,i,s,r,o,a){var _,F,O,N;let l=s.signed_z;if(!l)return;const c=s.abs_z!==void 0&&Array.from(s.abs_z).some(R=>R)?s.abs_z:void 0,u=i.styleState.terrainEnabled===!0,d=!c,f=i.tileAttrs[i.tileProps.db_road_part],h=i.tileAttrs[i.tileProps.db_geometry_type],g=(_=i.tileAttrs[i.tileProps.db_tiers])==null?void 0:_[0],v=!1;if(f==="roadbed_flat"||f==="border_tunnel_descent"&&v)return;const m=i.tileProps,b=i.tileAttrs.slice();i.id=void 0,b[m.db_tiers]=void 0;const w=t.id,I=s.x.length,x=s.x,E=s.y,C=(F=s.cut)!=null?F:[],T=new Uint8Array(I);l.forEach((R,z)=>{T[z]=R?0:1});const D=f==="roadbed_tunnel"||f==="roadbed_tunnel_descent"||f==="border_tunnel"||f==="border_tunnel_descent";let B=!1;D?B=!1:B=!!i.tileAttrs[i.tileProps.db_ignore_z]&&!!c&&u,B&&(l=new Int32Array(l.length));const k=d?gM:1;u&&D&&(l=new Int32Array(l).map(R=>R*k)),Ve(dr,0,0);const U=Ct(r,dr)*ve,A=ne/r.size*U,M=Math.max(ce(n.style.borderWidth,i,0),0)*A,S=Math.max(ce(n.style.thickness,i,0),0)*U,L=M>0?Math.max(-S,ce(n.style.borderHeight,i,0)*U):0;if(Math.max(ce(n.style.tunnelHeight,i,0),0)*U,h==="polygon"){if(g===void 0)return;const R=[x,E,C,l,new Int8Array(I),T];c&&R.push(c);const z=f==="roadbed_tunnel_descent",Z=f==="roadbed_tunnel"||z;ds.generate(e,w,n,i,de(R),g,r,void 0);const Y=R.map(G=>Array.from(G));for(let G=0;G<Y[3].length;G++)z?Y[3][G]-=S*.01:Y[3][G]-=S,Y[4][G]=0;Q.generate(e,w,n,te.bottom,i,de(Y),r,o,a,void 0,Z?"inverse":"fill",!0);const ee=[];for(let G=0;G<g;G++)ee.push(G);const K=e.getBucket("polygon","shadow",Xt.sinks.shadow.packObjectAttributes(w,n,ee,"",i),Xt.sinks.shadow.binder);if(kh(K,R[0].length,R[0],R[1],ft),Z&&!z){const G=R.slice();G[3]=Array.from(R[3]).map(q=>q+Math.abs(q/k)-1),G.length=4,Q.generate(e,w,n,te.top,i,de(G),r,o,a,void 0,"inverse")}if(z&&u&&!v){const G=R.slice();G[3]=new Array(R[0].length).fill(Math.max(0,L)),G[5]=new Array(R[0].length).fill(1),Q.generate(e,w,n,te.top,i,de(G),r,o,a,void 0,"depthClear")}}else if(h==="polyline"){const R=Q.sinks.stroke.packObjectAttributes(w,n,te.top,!!c,i),z=Q.sinks.stroke.packObjectAttributes(w,n,te.side,!!c,i),Z=Q.sinks.stroke.packObjectAttributes(w,n,te.bottom,!!c,i),Y=IM({x,y:E,cut:C,signed_z:l,is_pivot:T,abs_z:c});if(f==="tunnel_arch"&&!v){const ee=Math.max(L,0),K=$o(Y),G=SM(Y,M),q=Y.map($=>{const ie=$.slice();return ie[2]=d?w0:v0,c&&(ie[5]=0),ie[4]=0,ie});ue(e,Z,q);const J=Bt(G,K,M).map($=>($[2]=ee,$[4]=1,$)),X=G.map($=>{const ie=$.slice();return ie[2]=ee,ie[4]=1,ie}),se=Ae(J,X);do Q.generate(e,w,n,te.top,i,de(se),r,o,a,void 0,ee?"fill":"inverse");while(e.isOverloaded());const me=Y.map($=>{const ie=$.slice();return ie[2]=ee,ie[4]=1,ie});ue(e,R,me);const re=Ae(me,q);do Q.generate(e,w,n,te.side,i,de(re),r,o,a);while(e.isOverloaded());const W=Ae(me.map($=>{const ie=$.slice();return ie[2]=d?w0:v0,ie[4]=0,c&&(ie[5]=0),ie}),me.map($=>{const ie=$.slice();return ie[2]=0,ie}));do Q.generate(e,w,n,te.side,i,de(W),r,o,a,void 0,"inverse");while(e.isOverloaded());if(ee){const $=Bt(G,K,M).map(it=>(it[2]=0,it[4]=0,it));ue(e,Z,$),ue(e,R,J);const ie=Ae($,J);do Q.generate(e,w,n,te.side,i,de(ie),r,o,a,void 0,"fill");while(e.isOverloaded());const Ce=G.map(it=>{const mt=it.slice();return mt[2]=0,mt[4]=0,mt}),fe=Ae([X[0],Ce[0]],[J[0],$[0]]);do Q.generate(e,w,n,te.side,i,de(fe),r,o,a,void 0,"fill");while(e.isOverloaded());ue(e,R,[X[0],J[0]]),ue(e,z,[J[0],$[0]]),ue(e,Z,[$[0],Ce[0]]);const pe=X.length-1,Jt=Ae([Ce[pe],X[pe]],[$[pe],J[pe]]);do Q.generate(e,w,n,te.side,i,de(Jt),r,o,a,void 0,"fill");while(e.isOverloaded());if(ue(e,R,[X[pe],J[pe]]),ue(e,z,[J[pe],$[pe]]),ue(e,Z,[$[pe],Ce[pe]]),u){do Q.generate(e,w,n,te.top,i,de(se),r,o,a,void 0,"depthClear");while(e.isOverloaded());do Q.generate(e,w,n,te.side,i,de(ie),r,o,a,void 0,"depthClear");while(e.isOverloaded());do Q.generate(e,w,n,te.side,i,de(fe),r,o,a,void 0,"depthClear");while(e.isOverloaded());do Q.generate(e,w,n,te.side,i,de(Jt),r,o,a,void 0,"depthClear");while(e.isOverloaded())}}}else if(f==="border_overpass"||f==="border_flat"){const ee=[b[m.previousPointX],b[m.previousPointY],(O=l[0])!=null?O:0,0],K=!!b[m.beginningIsCut]&&I0(Y[1],Y[0],ee);K&&Y.splice(0,0,ee);const G=Y.length-1,q=[b[m.nextPointX],b[m.nextPointY],(N=l[l.length-1])!=null?N:0,0],J=!!b[m.endingIsCut]&&I0(Y[G-1],Y[G],q);J&&Y.push(q);const X=$o(Y);K&&(X.shift(),Y.shift()),J&&(X.pop(),Y.pop());const se=Y.map(fe=>{const pe=fe.slice();return pe[2]=Math.max(pe[2]-S,0),pe[4]=0,pe});ue(e,z,Y);const me=Bt(Y,X,M).map(fe=>{const pe=fe.slice();return pe[2]=Math.max(fe[2]-S,0),pe[4]=0,pe}),re=Bt(Y,X,M).map(fe=>{const pe=fe.slice();return pe[2]=Math.max(fe[2]+L,0),pe[4]=1,pe}),W=Y.map(fe=>{const pe=fe.slice();return L>0&&(pe[2]=Math.max(pe[2]+L,0)),pe[4]=1,pe});if(L>0){ue(e,R,W);const fe=Ae(W,Y.map(pe=>{const Jt=pe.slice();return Jt[4]=0,Jt}));do Q.generate(e,w,n,te.side,i,de(fe),r,o,a);while(e.isOverloaded())}ue(e,Z,me),ue(e,R,re);const $=Ae(re,W);do Q.generate(e,w,n,te.top,i,de($),r,o,a);while(e.isOverloaded());const ie=Ae(se,me);do Q.generate(e,w,n,te.bottom,i,de(ie),r,o,a,void 0,"fill");while(e.isOverloaded());const Ce=Ae(me,re);do Q.generate(e,w,n,te.side,i,de(Ce),r,o,a,void 0,"fill");while(e.isOverloaded());if(l[0]===0){const fe=Ae([W[0],se[0]],[re[0],me[0]]);do Q.generate(e,w,n,te.side,i,de(fe),r,o,a,void 0,"fill");while(e.isOverloaded());ue(e,R,[re[0],W[0]]),ue(e,z,[W[0],se[0]]),ue(e,z,[me[0],re[0]]),ue(e,Z,[se[0],me[0]])}if(l[l.length-1]===0){const fe=se.length-1,pe=Ae([se[fe],W[fe]],[me[fe],re[fe]]);do Q.generate(e,w,n,te.side,i,de(pe),r,o,a,void 0,"fill");while(e.isOverloaded());ue(e,R,[W[fe],re[fe]]),ue(e,z,[se[fe],W[fe]]),ue(e,z,[re[fe],me[fe]]),ue(e,Z,[me[fe],se[fe]])}}else{const ee=$o(Y),K=f==="border_tunnel_descent",G=f==="border_tunnel"||K,q=G?Math.max(L,0):L,J=Y.map(re=>{const W=re.slice();return W[2]-=S,K?(W[2]=0,W[5]=1):G&&(W[2]=Math.max(W[2],Fc)),W[4]=0,W}),X=Bt(Y,ee,M).map(re=>(re[2]-=S,K&&(re[2]=0,re[5]=1),re[4]=0,re)),se=Bt(Y,ee,M).map(re=>(re[2]+=q,K?(re[2]=q,re[5]=1):G&&(re[2]=Math.max(re[2],Fc)),re[4]=1,re)),me=Y.map(re=>{const W=re.slice();if(W[4]=1,K)W[2]=q,W[5]=1;else if(G){const $=Math.abs(W[2]/k),ie=q-W[2],Ce=W[2]+$-1;W[4]=(Ce+Math.abs(W[2]))/ie,W[2]=Ce}else W[2]+=q;return W});if(G){K&&ue(e,R,me);const re=Ae(me,Y.map(ie=>{const Ce=ie.slice();return Ce[4]=0,Ce}));do Q.generate(e,w,n,te.side,i,de(re),r,o,a);while(e.isOverloaded());const W=me.map(ie=>{const Ce=ie.slice();return Ce[2]=Math.min(ie[2],Fc),Ce}),$=Ae(W,Y);do Q.generate(e,w,n,te.side,i,de($),r,o,a,void 0,"inverse",!0);while(e.isOverloaded())}if(L>0&&(!G||K)){ue(e,Z,X),ue(e,R,se);const re=Ae(se,me);do Q.generate(e,w,n,te.top,i,de(re),r,o,a);while(e.isOverloaded());if(K&&u)do Q.generate(e,w,n,te.top,i,de(re),r,o,a,void 0,"depthClear");while(e.isOverloaded())}if(!G||K){const re=Ae(J,X);do Q.generate(e,w,n,te.bottom,i,de(re),r,o,a,void 0,"fill");while(e.isOverloaded());const W=Ae(X,se);do Q.generate(e,w,n,te.side,i,de(W),r,o,a,void 0,"fill");while(e.isOverloaded());if(K&&u)do Q.generate(e,w,n,te.side,i,de(W),r,o,a,void 0,"depthClear");while(e.isOverloaded());if(l[0]===0){const $=Ae([me[0],J[0]],[se[0],X[0]]);do Q.generate(e,w,n,te.side,i,de($),r,o,a,void 0,"fill");while(e.isOverloaded());if(K&&u)do Q.generate(e,w,n,te.side,i,de($),r,o,a,void 0,"depthClear");while(e.isOverloaded());ue(e,R,[se[0],me[0]]),ue(e,z,[me[0],J[0]]),ue(e,z,[X[0],se[0]]),ue(e,Z,[J[0],X[0]])}if(l[l.length-1]===0){const $=J.length-1,ie=Ae([J[$],me[$]],[X[$],se[$]]);do Q.generate(e,w,n,te.side,i,de(ie),r,o,a,void 0,"fill");while(e.isOverloaded());if(K&&u)do Q.generate(e,w,n,te.side,i,de(ie),r,o,a,void 0,"depthClear");while(e.isOverloaded());ue(e,R,[me[$],se[$]]),ue(e,z,[J[$],me[$]]),ue(e,z,[se[$],X[$]]),ue(e,Z,[X[$],J[$]])}}}}}};function IM(e){var i,s,r,o,a,l;const t=[],n=e.x.length;for(let c=0;c<n;c++){const u=[e.x[c],e.y[c],(s=(i=e.signed_z)==null?void 0:i[c])!=null?s:0,(o=(r=e.cut)==null?void 0:r[c])!=null?o:0,0,(l=(a=e.is_pivot)==null?void 0:a[c])!=null?l:0];e.abs_z&&u.push(e.abs_z[c]),t.push(u)}return t}function $o(e){const t=[];nn(Nt,e[0][0],e[0][1],e[1][0],e[1][1]),Ho=0;for(let n=1;n<e.length;n++)MM(t,e,n);return t}function MM(e,t,n){const i=n===t.length-1;if(Ve(wM,t[n-1][0],t[n-1][1]),Ve(dr,t[n][0],t[n][1]),ll(Ue,Nt),i)fr=0;else{Ve(Rc,t[n+1][0],t[n+1][1]),nn(ei,dr[0],dr[1],Rc[0],Rc[1]);const o=xe(kn(Nt,ei),-1,1),a=Math.min(Math.sqrt((1-o)/(1+o)),vM),l=Er(kn(Ue,ei));fr=a*l}let s=Ue[0]+Nt[0]*Ho,r=Ue[1]+Nt[1]*Ho;e.push([s,r]),i&&(s=Ue[0]+Nt[0]*fr,r=Ue[1]+Nt[1]*fr,e.push([s,r])),i||(xr(Nt,ei),Ho=fr)}function Bt(e,t,n){const i=[];for(let s=0;s<e.length;s++){const r=e[s].slice();xr(Ue,t[s]),_t(Ue,Ue,n),Gt(r,r,Ue),i.push(r)}return i}function ue(e,t,n){do{const i=e.getBucket("mesh","stroke",t,Q.sinks.stroke.binder),s=n.length,r={isMesh:!0,isModel:!1,absZCurr:0,absZNext:0,isPivotCurr:0,isPivotNext:0};for(let o=0;o<s-1;o++){const a=o+1;r.absZCurr=n[o][6],r.absZNext=n[a][6],r.isPivotCurr=n[o][5],r.isPivotNext=n[a][5],ss(i,n[o][0],n[o][1],n[o][2],n[a][0],n[a][1],n[a][2],r)}}while(e.isOverloaded())}function Ae(e,t){return TM([e[0]].concat(e,t.slice().reverse()))}function TM(e){var i,s,r;const t=e.length,n=[[],[],[],[],[],[]];e[0][6]!==void 0&&n.push([]);for(let o=0;o<t;o++){const a=Qe(o,t),l=e[o];n[0][a]=l[0],n[1][a]=l[1],n[2][a]=l[3],n[3][a]=l[2],n[4][a]=(i=l[4])!=null?i:0,n[5][a]=(s=l[5])!=null?s:0,n[6]&&(n[6][a]=(r=l[6])!=null?r:0)}return n}function de(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 SM(e,t){return e=e.map(n=>n.slice()),Qt(Ue,e[0],e[1]),Kt(Ue,Ue),Gn(Ue,Ue,t),ai(e[0],e[0],Ue),Qt(Ue,e[e.length-1],e[e.length-2]),Kt(Ue,Ue),Gn(Ue,Ue,t),ai(e[e.length-1],e[e.length-1],Ue),e}const I0=(function(){const e=Math.cos(Te(yM));return(t,n,i)=>(fn(Nt,n,t),Bn(Nt,Nt),fn(ei,n,i),Bn(ei,ei),kn(Nt,ei)<=e)})();function EM(e,t,n,i){return Re([e,t.innerId,n],t,i)}const Yo={symbol:"metricPoint",sinks:{fill:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.texCoords=new Uint16Array(t,4)},packObjectAttributes:EM,unpackObjectAttributes:e=>({styleId:e[0],layerId:e[1],tiers:e[2],tileData:e.slice(3)})}},generate(e,t,n,i,s,r,o){xM(e,i,s,n,r);const a=ce(s.style.width,r),l=ce(s.style.height,r),c=ce(s.style.rotation,r),[u,d]=Iv([t.x,t.y],a,l,c,o),f=H(s.ignoreTier,r)?null:r.tileAttrs[r.tileProps.db_tiers],h=e.getBucket("metricPoint","fill",Yo.sinks.fill.packObjectAttributes(i.id,s,f,r),Yo.sinks.fill.binder);let g=h.elements.offset;AM(h.indices,g,0,1,2,0,2,3),Wo(h,g++,u[0],d[0],0,0),Wo(h,g++,u[1],d[1],1,0),Wo(h,g++,u[2],d[2],1,1),Wo(h,g++,u[3],d[3],0,1),h.elements.offset=g}};function Wo(e,t,n,i,s,r){t=t*4,e.views.position[t]=V+n,e.views.position[t+1]=V+i,e.views.texCoords[t]=St(s),e.views.texCoords[t+1]=St(r)}function AM(e,t,n,i,s,r,o,a){const l=e.buffer,c=e.offset;l[c]=t+n,l[c+1]=t+i,l[c+2]=t+s,l[c+3]=t+r,l[c+4]=t+o,l[c+5]=t+a,e.offset=c+6}function xM(e,t,n,i,s){const{rasterSets:r}=t,o=Bl(i);wi(n.style.iconImage).forEach(a=>{if(!a.length)return;const l=r.byKey[eo(a)];if(!l){console.error(`Not found raster set with texture ${a}`);return}if(!l.isSvg)return;const c=ce(n.style.width,s),u=ce(n.style.height,s),d=Kr(c,u),f=c*d,h=u*d;e.atlasPacker.packSvg(l,[{w:f,h}],o),l.rasters.forEach(g=>e.atlasPacker.addRastersToLoad(t.id,g))})}const _M=64,_i=1e5,Nc=4;function PM(e){return e!==null&&typeof e=="object"&&e.type===_M}function M0(e){return S0(e.lo,e.hi)}function T0(e){return[e%_i,Math.floor(e/_i)%_i,0,0]}function LM(e){let n=0;for(let i=0;i<Nc;i++){const s=e[i]*4294967296+n;n=Math.floor(s/_i),e[i]=s%_i}}function CM(e,t){let n=0;for(let i=0;i<Nc;i++){const s=e[i]+t[i]+n;n=Math.floor(s/_i),e[i]=s%_i}}function DM(e){const t="00000";let n=!0,i=Nc,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 S0(e,t){const n=T0(e),i=T0(t);return LM(i),CM(i,n),DM(i)}const et=[0,0,0],Zo=[0,0,0],Xo=new Float64Array(16),E0={symbol:"tunnel",sinks:{},generate(e,t,n,i,s,r,o,a){var Y,ee,K;const{tileProps:l,tileAttrs:c}=i,u=(Y=c[l.db_tiers])==null?void 0:Y[0];if(M0(c[l.id])!=="70030076221371399"||!u)return;const f=t.id;Ve(et,0,0);const g=Ct(r,et)*ve,v=ne/r.size*g,p=1/(ne/r.size),m=c[l.objectLength],b=(ee=c[l.componentDistanceStart])!=null?ee:0,w=(K=c[l.componentDistanceEnd])!=null?K:0,I=b===0?0:-5,x=175,E=243,C=w===m?0:-5;if(Number.isNaN(m)||Number.isNaN(b)||m===0)return;const T=E-x,D=x+T*b/m,B=x+T*w/m,k=3.5*v,j=5*v,U=[];let A=0;for(let G=0;G<s.x.length;G++){const q=[s.x[G],s.y[G],0];G>0&&(A+=Un(q,U[G-1]),q[2]=A),U.push(q)}const M=OM(U),S=$o(U);U.forEach(G=>{const q=G[2]/M;G[2]=(I+q*(C-I))*g,G[5]=(D+q*(B-D))*g});const L=Q.sinks.stroke.packObjectAttributes(f,n,te.side,!0,i),_=Bt(U,S,k),F=Bt(U,S,-k),O=Ae(_,F),N=Bt(U,S,j),R=N.map(G=>{const q=G.slice();return q[2]=Math.max(0,q[2]),q});Q.generate(e,f,n,te.side,i,de(Ae(N,R)),r,o,a,void 0,"inverse");const z=Bt(U,S,-j),Z=z.map(G=>{const q=G.slice();return q[2]=Math.max(0,q[2]),q});Q.generate(e,f,n,te.side,i,de(Ae(Z,z)),r,o,a,void 0,"inverse"),U[0][2]!==0&&U[U.length-1][2]!==0&&Q.generate(e,f,n,te.side,i,de(Ae(R,Z)),r,o,a,void 0,"inverse");do ds.generate(e,f,n,i,de(O),u,r,void 0);while(e.isOverloaded());for(let G=1;G<U.length;G++){const q=[],J=[],X=U[G-1],se=U[G],me=S[G-1],re=S[G];for(let $=0;$<=181;$+=15){const ie=Te($),Ce=X.slice();De(et,me[0],me[1],0),Gn(et,et,k),Vn(Zo,et),_d(Xo,-ie,Zo),Ps(et,et,Xo),et[2]*=p,ai(Ce,Ce,et),q.push(Ce);const fe=se.slice();De(et,re[0],re[1],0),Gn(et,et,k),Vn(Zo,et),_d(Xo,-ie,Zo),Ps(et,et,Xo),et[2]*=p,ai(fe,fe,et),J.push(fe)}const W=Ae(q,J);if(Q.generate(e,f,n,te.side,i,de(W),r,o,a,void 0,"fill"),G===1&&U[0][2]===0){ue(e,L,q);const $=U[0].slice(),ie=U[0].slice(),Ce=S[0].slice(),fe=S[0].slice();_t(Ce,Ce,j),_t(fe,fe,-j),Gt($,$,Ce),Gt(ie,ie,fe);const pe=$.slice(),Jt=ie.slice();pe[2]+=j*p,Jt[2]+=j*p;const it=[$];for(let mt=0;mt<5;mt++)it.push(pe);for(let mt=0;mt<5;mt++)it.push(Jt);it.push(ie),ue(e,L,it),Q.generate(e,f,n,te.side,i,de(Ae(it,q)),r,o,a,void 0,"fill")}else if(G===U.length-1&&U[U.length-1][2]===0){ue(e,L,J);const $=U[U.length-1].slice(),ie=U[U.length-1].slice(),Ce=S[U.length-1].slice(),fe=S[U.length-1].slice();_t(Ce,Ce,j),_t(fe,fe,-j),Gt($,$,Ce),Gt(ie,ie,fe);const pe=$.slice(),Jt=ie.slice();pe[2]+=j*p,Jt[2]+=j*p;const it=[$];for(let mt=0;mt<5;mt++)it.push(pe);for(let mt=0;mt<5;mt++)it.push(Jt);it.push(ie),ue(e,L,it),Q.generate(e,f,n,te.side,i,de(Ae(J,it)),r,o,a,void 0,"fill")}}if(U[0][2]===0||U[U.length-1][2]===0){const G=Bt(U,S,j),q=Bt(U,S,-j),J=G.map(W=>{const $=W.slice();return $[2]=Math.max(0,$[2]+j*p),$}),X=q.map(W=>{const $=W.slice();return $[2]=Math.max(0,$[2]+j*p),$});G.forEach(W=>{W[2]=Math.max(0,W[2])}),q.forEach(W=>{W[2]=Math.max(0,W[2])});const se=Ae(G,J),me=Ae(X,q);ue(e,L,G),ue(e,L,q),ue(e,L,J),ue(e,L,X),Q.generate(e,f,n,te.side,i,de(se),r,o,a,void 0,"fill"),Q.generate(e,f,n,te.side,i,de(me),r,o,a,void 0,"fill");const re=Ae(J,X);Q.generate(e,f,n,te.top,i,de(re),r,o,a,void 0,"fill")}}};function OM(e){let t=0;for(let n=0;n<e.length-1;n++)t+=Es(e[n],e[n+1]);return t}var Bc=(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))(Bc||{});function A0(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 FM={symbol:"simpleMesh",sinks:{fill:{stride:24,binder:()=>{},packObjectAttributes(e,t,n){return Re([e,t.innerId],t,n)},unpackObjectAttributes(e){return{styleId:e[0],layerId:e[1],tileData:e.slice(2)}}}}},kc={symbol:"polygon3d",sinks:{},generate(e,t,n,i,s,r,o,a){let l;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])&&(l=[i.tileAttrs[i.tileProps.db_centroid_x],i.tileAttrs[i.tileProps.db_centroid_y]]);const c=H(n.style.color,i),u=c&&c.isVertexColor?ro(c):void 0;Q.generate(e,t,n,te.top,i,s,r,o,a,l,"fill",void 0,u)}};var x0=(e=>(e[e.none=0]="none",e[e.fadeIn=1]="fadeIn",e[e.fadeOut=-1]="fadeOut",e))(x0||{});function _0({collector:e,generator:t,args:n}){do t(e,...n);while(e.isOverloaded())}const P0={arrow:rr,line:dt,polygon:Xt,embankment:kc,polygon3d:kc,metricPoint:Yo,labelLine:Bo,lineExtrusion:An,polygonExtrusion:on,oneWayLine:ko,dashedLine:Sn,shiftedLine:Js,circle:bo,buildingModel:En,gltfModel:Qn,point:an,raster:Mo,heatmap:Ei,dem:Ot,mesh:Q,mapMesh:ds,overpass:b0,tunnel:E0,simpleMesh:FM},L0={labelLine:Bo,oneWayLine:ko,point:an};function hr(e,t){const n=P0[e];return n?n.sinks[t].stride:0}function Uc(e,t){e.precomputes.forEach((n,i)=>{t.tileData[i]=H(n.expr,t)})}function zc(e,t,n,i,s,r,o,a,l,c,u,d,f,h,g){const v=i.styleState.graphicsPreset?t.graphicsPresets[i.styleState.graphicsPreset]||{}:{};n.forEach(p=>{if(Bf(i,[u.x[0],u.y[0]]),!(o!==void 0&&(p.maxzoom<=o||p.minzoom>=o+1&&o!==si.maxDetailLevel))&&!(i.tileProps.hovered&&!Number.isNaN(i.tileAttrs[i.tileProps.hovered])&&i.tileAttrs[i.tileProps.hovered]===1&&p.type!=="polygon"&&p.type!=="polygonExtrusion"&&p.type!=="point"&&p.type!=="polygon3d")){Uc(p,i);do switch(p.type){case"line":const m=H(p.style.pattern,i);m&&m[0]!==Bc.None?dt.generatePatterned(e,t.id,p,i,l,u):dt.generate(e,t.id,p,i,l,u);break;case"dashedLine":Sn.generate(e,t.id,p,i,u);break;case"shiftedLine":Js.generate(e,t.id,p,i,u);break;case"polygon":Xt.generate(e,t.id,p,i,u,c,l,t.rasterSets);break;case"polygon3d":case"embankment":kc.generate(e,t.id,p,i,u,l,c,t.rasterSets);break;case"metricPoint":{Yo.generate(e,u,c,t,p,i,l);break}case"polygonExtrusion":on.generate(e,t.id,p,i,u,v,l);break;case"labelLine":YI(e,t.id,p,l.coords,a,i,u);break;case"oneWayLine":WI(e,t.id,p,l.coords,a,i,u);break;case"point":{o0(e,t,p,i,s,r,l.coords,a,u,c,d);break}case"lineExtrusion":An.generate(e,t.id,p,i,u,v);break;case"arrow":rr.generate(e,t.id,p,i,u);break;case"heatmap":{Ei.generate(e,t.id,p,u,i);break}case"gltfModel":{Qn.generateInstances(e,t,p,i,u,l,a,f,h,s,2,g);break}case"overpass":b0.generate(e,t,p,i,u,l,c,t.rasterSets);break;case"tunnel":E0.generate(e,t,p,i,u,l,c,t.rasterSets);break}while(e.isOverloaded())}})}function RM(e,t,n,i,s,r,o,a){const l=L0[t.type];if(l)do l.processElement(e,n,i,s,r,o,a);while(n.isOverloaded())}function NM(e,t,n,i,s,r,o){const a=L0[i.type];a&&a.getLabelingInfo(e,t,n,s,r,o)}class C0{constructor(t,n={}){this._buffer=t,this.options=Object.assign({},Xe.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 BM(e,t){const n=new Set;return e.forEach(i=>{t.has(i)||n.add(i)}),n}function kM(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 UM(e,t){const n=new Set;for(const i of t)e.has(i)&&n.add(i);return n}function zM(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)||!kM(i,t.get(n)))return!1;return!0}const Gc="default",GM="floor",VM="dynamicModel";var fs=(e=>(e[e.PolygonExtrusion=1]="PolygonExtrusion",e[e.FloorPolygons=2]="FloorPolygons",e[e.All=3]="All",e))(fs||{});class jM{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){var s;return((s=this.hidden.get(t))!=null?s: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!=null&&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 zM(i,n)?!1:(i&&i.forEach((s,r)=>{const o=this.parentChildrenMap.get(r);s.forEach(a=>{o==null||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!=null&&r.size&&r.forEach(n.add,n)}}),Array.from(n)}}class Vc{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 HM(e){const t=$M(e),{groups:n,table:i}=YM(t),s={};for(let o=0;o<i.length;o++){const a=i[o],l=n[o];s[l]={};for(let c=0;c<a.length;c++){const u=n[c];s[l][u]=i[o][c]}}const r=n.reduce((o,a,l)=>(o[a]=l,o),{});return{indexToGroup:n,groupToIndex:r,table:s}}function $M(e){const t=(e.groups||[]).concat(Fl.groups).reduce((i,s)=>(i.includes(s)||i.push(s),i),[]),n=(e.overlay||[]).concat(Fl.overlay).concat(t.reduce((i,s)=>(s===Xn||s===Zn||s===zf||i.push([s,Zn]),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:Fl.intersect}}function YM(e){const{groups:t,overlay:n,intersect:i}=e,s=t.reduce((o,a,l)=>(o[a]=l,o),{}),r=[];for(let o=0;o<t.length;o++){const a=[];for(let l=0;l<t.length;l++)a.push(!0);r.push(a)}for(let o=0;o<n.length;o++){const a=n[o];for(let l=0;l<a.length;l++)for(let c=l+1;c<a.length;c++){const u=s[a[l]],d=s[a[c]];r[u][d]=!1,r[d][u]=!1}}for(let o=0;o<i.length;o++){const a=i[o];for(let l=0;l<a.length;l++)for(let c=l+1;c<a.length;c++){const u=s[a[l]],d=s[a[c]];r[u][d]=!0,r[d][u]=!0}}return{groups:t,table:r}}const WM={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"},ZM=e=>{var t;return(t=WM[e])!=null?t:e},XM={objectClass:"db_object_class",sublayer:"db_sublayer",db_id:"id"};function qM(e){var t;return(t=XM[e])!=null?t:e}const JM={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"},KM=e=>{var t;e.enumerationValues=Object.keys((t=e.enumerationValues)!=null?t:{}).reduce((n,i)=>{const s=JM[i];return s&&(n[s]=e.enumerationValues[i]),n},{})};class QM{constructor(t,n,i){var s;this.id=t,this.modules=n,this.options=i,this.type="zenith",this.worker=new n.workers.parser.ZenithSource,this.sourceAttrs=Nn((s=i.sourceAttributes)!=null?s:{},Kd),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,l)=>a.catch(()=>Promise.resolve()).then(c=>{if(!c)return;const{metadata:u,err:d}=c;return u.forEach(f=>{const h=this.constructMetaTileUrl(f);i.loadMetatile(h,f.metatileHash,f.regionId),s.emit("tileload",{tileCoords:r[l].coords,regionId:f.regionId}),n.shownRegionIds.add(f.regionId)}),(d==null?void 0:d.status)===403&&s.emit("error",{type:"invalidtilekey"}),u}))}generateTile(u,d,f,h,g){return Pe(this,arguments,function*(t,n,i,s,r,o={},a,l=this.id,c){const v=yield this.worker.generateTile(Me(he({styleId:i,tileInfo:gt(n),pixelRatio:r,selectedIds:s,styleState:t.styleState,floorsEnabled:t.floorsEnabled,sourceAttrs:this.sourceAttrs,hoverId:a,sourceId:l,isDefaultSource:this.options.isDefaultSource,modelsPath:this.options.modelsPath,sharedModelsPath:this.options.sharedModelsPath,promoteAttributes:this.options.promoteAttributes,promoteId:this.options.promoteId,isCustomZenithSource:!this.options.isDefaultSource,dataFilter:this.dataFilter},o),{modelShowHideEventsSublayers:t.modelShowHideEventsSublayers}),c);return v.promotedAttrs&&(this.objectAttributes[Le(n)]=v.promotedAttrs),v})}getObjectAttributes(t,n){var i;return(i=this.objectAttributes[t])==null?void 0:i[n]}generateModel(t){return this.worker.generateModel(t)}abortTileFetches(t){const n=t.map(Le);this.worker.abortTileRequests(n)}deleteTiles(t){const n=t.map(Le);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=P(t,{precomputes:[]},tt.Generator):this.dataFilter=void 0}constructTileUrl(t,n){return Zg(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:Zd(t.metatileHash)};return Os(n?{url:n}:"metatile",i)}}function eT(e){const t={};let n=0;for(const i in e)t[i]=n,n+=1;return t}let tT=Number.MIN_SAFE_INTEGER;function D0(){return tT++}const nT=D0(),iT=D0(),O0={NEVER:512,LESS:513,EQUAL:514,LEQUAL:515,GREATER:516,NOTEQUAL:517,GEQUAL:518,ALWAYS:519},sT={FRONT:1028,BACK:1029,FRONT_AND_BACK:1032},rT={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},oT={FUNC_ADD:32774,FUNC_SUBTRACT:32778,FUNC_REVERSE_SUBTRACT:32779,MIN:32775,MAX:32776},F0={type:"color-effect",effect:{type:"mix",color:ct([0,0,0,0]),factor:0}},R0="__JAKARTA__DEM__LIGHTING__";class jc extends Error{constructor(t){super(`Unknown expression type '${t[0]}' in '${JSON.stringify(t)}'`),this.name="UnknownExpressionTypeError",Object.setPrototypeOf(this,new.target.prototype)}}function P(e,t,n=tt.Uniform){if(_v(e))return Lf(e)?js(e):e;switch(e[0]=Xv(e[0]),e[0]){case"coalesce":return IT(e,t,n);case"concat":return MT(e,t,n);case"all":return bT(e,t,n);case"any":return TT(e,t,n);case"match":return aT(e,t,n);case"in":return hT(e,t,n);case"interpolate":return N0(e,t,n);case"step":return wT(e,t,n);case"feature-state":case"get":case"source-attr":case"has":return B0(e,t,n);case"object-attr":return{type:"object-attr",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:P(e[1]||0,t,n)};case"utc-time":return{type:"utc-time",offset:P(e[1]||0,t,n)};case"time":return AT(e,t,n);case"schedule":return xT(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 lT(e,t,n);case"uint64":return P(e[1],t,n);case"==":case"!=":case"<":case"<=":case">":case">=":return cT(e,t,n);case"+":return uT(e,t,n);case"*":return dT(e,t,n);case"^":return fT(e,t,n);case"random":return _T(e,t,n);case"literal":return Array.isArray(e[1])?PT(e,t,n):typeof e[1]=="object"&&e[1]!==null?LT(e):e[1];case"is-behind-objects":return{type:"is-behind-objects"};case"geometry-modifier":const i=[];return e.slice(1).forEach(s=>{const r=CT(s);r&&i.push(r)}),{type:"geometry-modifier",modifiers:i};case"pattern":return{type:"line-pattern",patternType:A0(e[1]),parameters:e.slice(2).map(s=>P(s,t,n))};case"precompute":{if(!t)throw new jc(e);const s=t.precomputes.length;return t.precomputes.push({expr:P(e[1],void 0,n),usage:n}),{type:"precompute",precomputeIndex:s}}case"color-saturate":case"color-desaturate":case"color-grayscale":case"color-lighten":case"color-lightness":case"color-darken":case"color-whiten":case"color-blacken":case"color-opacity":return pT(e,t,n);case"gltf-animation":return mT(e,t,n);case"texture-animation":return yT(e,t,n);case"easing":return gT(e);case"mix":return vT(e,t,n);case"read-from-target":return{type:"read-from-target",name:e[1]};case"vertex-attribute":return{type:"vertex-attribute",name:e[1]};case"vertex-color":return ST(e,t,tt.Generator);case"color-effect":return ET(e,t,n);default:throw new jc(e)}}function ti(e,t,n=tt.Uniform){return pn(e)||Array.isArray(e)&&e.length===0?e:P(e,t,n)}function Pi(e,t,n){return e===void 0?e:P(e,t,n)}function aT(e,t,n){const i={type:"match",input:P(e[1],t,n),cases:[],defaultOutput:P(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((l,c)=>{typeof c=="boolean"&&l.push(Number(c));const u=P(c,t,n);return xf(u)?l.push(u):console.warn("MatchExpression supports only simple types: string, number, boolean or null",c),l},[]),a={values:new Set(o),output:P(s[r+1],t,n)};i.cases.push(a)}return i}function N0(e,t,n){const i={type:"interpolate",base:1,argument:P(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:P(s[r],t,n),value:P(s[r+1],t,n)};i.steps.push(o)}return i}function lT(e,t,n){return{type:e[0],value:P(e[1],t,n)}}function cT(e,t,n){const i=P(e[1],t,n),s=P(e[2],t,n);return{type:e[0],leftValue:i,rightValue:s}}function uT(e,t,n){return{type:"+",array:e.slice(1).map(i=>P(i,t,n))}}function dT(e,t,n){return{type:"*",array:e.slice(1).map(i=>P(i,t,n))}}function fT(e,t,n){const i=P(e[1],t,n),s=P(e[2],t,n);return{type:"^",base:i,exponent:s}}function hT(e,t,n){const i=P(e[1],t,n),s=e[2][0];if(s!=="get"&&s!=="global"&&s!=="source-attr"&&s!=="literal")throw new Error("InExpression supports only the get, global, source attr and literal expressions as a second argument");const r=P(e[2],t,n);return{type:"in",item:i,collection:r}}function pT(e,t,n){return{type:e[0],color:P(e[1],t,n),value:P(e[2],t,n)}}function mT(e,t,n){const i={type:"gltf-animation",options:[]},s=e.slice(1);for(let r=0;r<s.length;r++)i.options.push(P(s[r],t,n));return i}function yT(e,t,n){const i={type:"texture-animation",options:[]},s=e.slice(1);for(let r=0;r<s.length;r++)i.options.push(P(s[r],t,n));return i}function gT(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(s){console.warn("Invalid texture animation easing expression:",e),console.warn('Fallback to ["easing", "linear"].')}return t}function vT(e,t,n){const i=e.slice(1),s=P(i[2],t,n);if(s.type==="interpolate"){const{argument:r}=s;return s.argument.type==="read-from-target"?{type:"mix",value1:P(i[0],t,n),value2:P(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:P(i[0],t,n),value2:P(i[1],t,n),factor:s}}function wT(e,t,n){const i={type:"step",steps:[],value:P(e[1],t,n)},s={key:0,value:P(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:P(r[o+1],t,n)};i.steps.push(a)}return i}function B0(e,t,n){var o;const i=e[0],s=qM(e[1]),r={type:i,property:s};if(n!==tt.Generator&&t){const a=(o=t.precomputes.length)!=null?o:NaN;return t.precomputes.push({expr:r,usage:n}),s==="selected"&&"selectedIdx"in t&&(t.selectedIdx=a),{type:"precompute",precomputeIndex:a}}else return r}function bT(e,t,n){return{type:"all",array:e.slice(1).map(i=>P(i,t,n))}}function IT(e,t,n){return{type:"coalesce",array:e.slice(1).map(i=>{try{return P(i,t,n)}catch(s){return console.debug(`Unknown expression in coalesce: ${s}`),null}})}}function MT(e,t,n){return{type:"concat",array:e.slice(1).map(i=>P(i,t,n))}}function TT(e,t,n){return{type:"any",array:e.slice(1).map(i=>P(i,t,n))}}function ST(e,t,n){return{type:"vertex-color",vertexValue:P(e[1],t,n),uniformValue:P(e[2],t,n),mixValue:P(e[3]||1,t,n)}}function ET(e,t,n){if(!e)return F0;switch(e[1]){case"mix":return{type:"color-effect",effect:{type:"mix",color:P(e[2],t,n),factor:P(e[3],t,n)}};default:return Rl(e[1]),F0}}function AT(e,t,n){return{type:"time",timeSource:P(e[1],t,n),format:e[2]}}function xT(e,t,n){return{type:"schedule",time:P(e[1],t,n),steps:P(e[2],t,n),detailResult:e[3]}}function _T(e,t,n){const i=P(e[1],t,n),s=P(e[2],t,n);return{type:"random",start:i,end:s}}function PT(e,t,n){return{type:"literal-array",array:e[1].map(i=>P(i,t,n))}}function LT(e){return{type:"literal-object",object:{type:"object",value:e[1]}}}function CT(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 DT(e){return e?e.map(t=>{var o,a,l,c,u,d,f,h,g,v,p,m,b,w,I,x,E,C,T,D,B,k,j,U,A,M,S;const n=(o=t.wallPadding)!=null?o:0,i=(a=t.texturePadding)!=null?a:0,s=t.sliceSize,r={image:t.image,minWallHeight:(l=t.minWallHeight)!=null?l: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:(u=(c=t.vertical)==null?void 0:c.mode)!=null?u:"stripe-top",slicesCount:(f=(d=t.vertical)==null?void 0:d.slicesCount)!=null?f:1,minSliceRepeats:(g=(h=t.vertical)==null?void 0:h.minSliceRepeats)!=null?g:1,minResizeFactor:(p=(v=t.vertical)==null?void 0:v.minResizeFactor)!=null?p:0,maxResizeFactor:(b=(m=t.vertical)==null?void 0:m.maxResizeFactor)!=null?b:9999,maxInterval:(I=(w=t.vertical)==null?void 0:w.maxInterval)!=null?I:0},horizontal:{mode:(E=(x=t.horizontal)==null?void 0:x.mode)!=null?E:"repeat-with-stretch",slicesCount:(T=(C=t.horizontal)==null?void 0:C.slicesCount)!=null?T:1,minSliceRepeats:(B=(D=t.horizontal)==null?void 0:D.minSliceRepeats)!=null?B:1,minResizeFactor:(j=(k=t.horizontal)==null?void 0:k.minResizeFactor)!=null?j:0,maxResizeFactor:(A=(U=t.horizontal)==null?void 0:U.maxResizeFactor)!=null?A:9999,maxInterval:(S=(M=t.horizontal)==null?void 0:M.maxInterval)!=null?S:0}};return r.sliceSize[0]<=0||r.sliceSize[1]<=0?null:r}).filter(t=>t!==null):[]}function OT(e,t){var c,u,d,f,h,g,v;const n=$c((c=e.terrain)!=null?c:{}),i=V0((u=e.environment)!=null?u:{}),s=j0(e.light,n),r=NT(e.graphicsPresets),o={id:t,revision:0,background:{color:js((f=(d=e.background)==null?void 0:d.color)!=null?f:Ew)},light:s,layers:[],layersById:{[Xs]:n,[Hl]:i},layerIdToInnerId:{},groupsById:{},iconBaseUrl:"",fontUrlTemplate:"",modelsBaseUrl:"",fonts:Ir,fontNameToIndex:Ah(Ir),rasterSets:{byIndex:{},byKey:{}},icons:e.icons||{},models:Object.values((h=e.models)!=null?h:{}),modelIndex:eT(e.models||{}),labelingGroups:HM((g=e.labelingGroups)!=null?g:{}),dem:n,graphicsPresets:r,environment:i,targets:{_TMP_SHORELINE_GRADIENT:{channels:{r:!0},title:"Градиент береговой линии"}}},a=new Vc,l=(v=e.layers)!=null?v:[];for(const p of l){const m=k0(p);if(!m)continue;m.type==="group"&&(o.groupsById[m.innerId]=m,o.layerIdToInnerId[m.id]=m.innerId),(m.type==="group"?m.layers:[m]).forEach(w=>{var E;const I=(E=w.lightingMode)!=null?E:s.defaultLightMode;s.lightingModes[I]||console.warn(`Не найден режим освещения ${I} для слоя ${w.type}. Будет использован режим освещения по умолчанию.`),o.layers.push(w),o.layersById[w.innerId]=w,o.layerIdToInnerId[w.id]=w.innerId,(w.type==="point"||w.type==="polygon"||w.type==="metricPoint"||w.type==="embankment"||w.type==="polygon3d")&&U0(w,a,o.icons).forEach(T=>{o.rasterSets.byKey[T.key]||(o.rasterSets.byIndex[T.index]=T,o.rasterSets.byKey[T.key]=T)})})}return o}function k0(e){return e.type==="group"?RT(e):qo(e)}function U0(e,t,n){const i=[];return G0(e).forEach(({image:s,imageType:r,anchor:o})=>{s&&wi(s).forEach(a=>{typeof a!="string"||!a.length||i.push(z0(a,r,t,o,n))})}),i}function z0(e,t,n,i,s){const r=t==="icon"?Xi(e,i[0],i[1]):eo(e);return{type:Si.Static,index:n.getUniqueIndex(r),key:r,isSvg:wb(s[e]),name:e,fileName:e,anchorX:i[0],anchorY:i[1],rasters:[]}}function G0(e){if(e.type==="point"){const n=st(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 Hc=new Vc;function FT(e,t){return e.type==="appearance"?{type:e.type,tipMovementAmplitude:P(e.tipMovementAmplitude,t)}:e.type==="repeat"?{type:e.type,tipMovementAmplitude:P(e.tipMovementAmplitude,t),iterationCount:e.iterationCount}:e}function qo(e,t){var i,s,r,o,a,l,c,u,d,f,h,g,v,p,m,b,w,I,x,E,C,T,D,B,k,j,U;if(e.type==="custom")return{type:"custom",id:e.id,innerId:Zs(),renderIndex:Hc.getIndex(),filter:!1,minzoom:-1/0,maxzoom:1/0,precomputes:[],style:{}};if(!e.style||e.style.visibility==="none")return;let n;try{const A={id:e.id,innerId:Zs(),renderIndex:Hc.getIndex(),filter:P(e.filter||!1,void 0),minzoom:H0(e.minzoom,-1/0),maxzoom:H0(e.maxzoom,1/0),precomputes:t?t.precomputes.slice(0):[],gpuState:e.gpuState,lightingMode:e.lightingMode,castShadows:(i=e.castShadows)!=null?i:!0,receiveShadows:(s=e.receiveShadows)!=null?s:!0,drawToTarget:e.drawToTarget};switch(e.type){case"line":{const M=ow(e.style);n=Me(he({},A),{type:e.type,interactive:(r=e.interactive)!=null?r:!0,ignoreTier:P((o=e.ignoreTier)!=null?o:!1,A),style:{visibility:We(M.visibility),color:P(M.color,A),width:P(M.width,A),shift:P(M.shift,A),pattern:P(M.pattern,A),startCap:P(M.startCap,A),endCap:P(M.endCap,A),geometryModifier:P(M.geometryModifier,A),mode:M.mode,lengthUnits:BT(e.style.pattern),floorCulling:M.floorCulling}});break}case"lineExtrusion":{const M=lw(e.style);n=Me(he({},A),{type:e.type,style:{visibility:We(M.visibility),sideColor:P(M.sideColor,A),strokeWidth:P(M.strokeWidth,A),strokeColor:P(M.strokeColor,A),sideStrokeColor:P(M.sideStrokeColor,A),height:P(M.height,A),nearCameraFade:P(M.nearCameraFade,A)}});break}case"polygon":{const M=nw(e.style),S=pr(M.textureSize)?Y0(M.textureSize):M.textureSize,L=pr(M.normalMapTextureSize)?Y0(M.normalMapTextureSize):M.normalMapTextureSize;A.drawToTarget==="_TMP_SHORELINE_GRADIENT"&&(M.strokeWidth=0,M.strokeColor="#00000000",M.color=["mix","#000000","#FF0000",["vertexAttribute","denormalized_distance_to_line"]]),n=Me(he({},A),{type:e.type,interactive:(a=e.interactive)!=null?a:!0,ignoreTier:P((l=e.ignoreTier)!=null?l:!1,A),style:{visibility:We(M.visibility),color:P(M.color,A),textureImage:P(M.textureImage,A),textureSize:ti(S,A),textureOpacity:P(M.textureOpacity,A),strokeColor:P(M.strokeColor,A),strokeWidth:P(M.strokeWidth,A),lengthUnits:$0(M.textureSize),metallic:P(M.metallic,A),roughness:P(M.roughness,A),normalMapTextureImage:P(M.normalMapTextureImage,A),normalMapTextureSize:ti(L,A),normalMapTextureAnimation:P(M.normalMapTextureAnimation,A),normalMapTextureLengthUnits:$0(M.normalMapTextureSize),colorEffect:P(M.colorEffect,A),floorCulling:M.floorCulling}});break}case"polygon3d":case"embankment":{const M=iw(e.style),S=e.type==="polygon3d"?{depthFunc:O0.LEQUAL}:{};n=Me(he({},A),{type:e.type,interactive:(c=e.interactive)!=null?c:!0,style:{visibility:We(M.visibility),color:P(M.color,A),textureImage:P(M.textureImage,A),textureSize:ti(M.textureSize,A),textureOpacity:P(M.textureOpacity,A),strokeColor:P(M.strokeColor,A),strokeWidth:P(M.strokeWidth,A),nearCameraFade:P(M.nearCameraFade,A),elevation:P(M.elevation,A)},gpuState:he(he({},S),A.gpuState)}),e.type==="polygon3d"&&(n.interactiveOcclusion=(u=e.interactiveOcclusion)!=null?u:!0);break}case"metricPoint":{const M=sw(e.style);n=Me(he({},A),{type:e.type,interactive:(d=e.interactive)!=null?d:!0,ignoreTier:P((f=e.ignoreTier)!=null?f:!1,A),style:{visibility:We(M.visibility),iconImage:P(M.iconImage,A),color:P(M.color,A),rotation:P(M.rotation,A),width:P(M.width,A),height:P(M.height,A)}});break}case"polygonExtrusion":{const M=rw(e.style);n=Me(he({},A),{type:e.type,interactive:(h=e.interactive)!=null?h:!0,sideTextureIndices:[],style:{visibility:We(M.visibility),topColor:P(M.topColor,A),sideColor:P(M.sideColor,A),strokeColor:P(M.strokeColor,A),strokeWidth:P(M.strokeWidth,A),sideStrokeColor:P(M.sideStrokeColor,A),height:P(M.height,A,tt.Generator),nearCameraFade:P(M.nearCameraFade,A),sideTextures:DT(M.sideTextures),colorEffect:P(M.colorEffect,A),floorCulling:M.floorCulling}});break}case"dashedLine":{const M=dw(e.style);n=Me(he({},A),{type:e.type,interactive:(g=e.interactive)!=null?g:!0,ignoreTier:P((v=e.ignoreTier)!=null?v:!1,A),style:{visibility:We(M.visibility),color:P(M.color,A),gapColor:P(M.gapColor,A),width:P(M.width,A),shift:P(M.shift,A),gapLength:P(M.gapLength,A),dashLength:P(M.dashLength,A),gapTurnsOnly:M.gapTurnsOnly,geometryModifier:P(M.geometryModifier,A),mode:M.mode,floorCulling:M.floorCulling}});break}case"shiftedLine":{const M=fw(e.style);n=Me(he({},A),{type:e.type,interactive:(p=e.interactive)!=null?p:!0,ignoreTier:P((m=e.ignoreTier)!=null?m:!1,A),style:{visibility:We(M.visibility),color:P(M.color,A),width:P(M.width,A),shift:P(M.shift,A)}});break}case"oneWayLine":{const M=uw(e.style);n=Me(he({},A),{type:e.type,ignoreTier:P((b=e.ignoreTier)!=null?b:!1,A),interactive:(w=e.interactive)!=null?w:!1,style:{visibility:We(M.visibility),color:P(M.color,A),lineWidth:P(M.lineWidth,A),lineLength:P(M.lineLength,A),tipWidth:M.tipWidth,tipHeight:M.tipHeight,roundingRadius:P(M.roundingRadius,A),priority:M.priority,duplicationSpacing:P(M.duplicationSpacing,A),endingOffsets:M.endingOffsets,labelingGroup:M.labelingGroup,colorEffect:P(M.colorEffect,A),floorCulling:M.floorCulling}});break}case"buildingModel":{const M=aw(e.style);n=Me(he({},A),{type:e.type,interactive:(I=e.interactive)!=null?I:!0,style:{visibility:We(M.visibility),color:P(M.color,A),strokeColor:P(M.strokeColor,A),strokeWidth:P(M.strokeWidth,A),nearCameraFade:P(M.nearCameraFade,A)}});break}case"labelLine":{const M=cw(e.style);n=Me(he({},A),{type:e.type,interactive:(x=e.interactive)!=null?x:!1,ignoreTier:P((E=e.ignoreTier)!=null?E:!1,A),style:{visibility:We(M.visibility),textField:P(M.textField,A,tt.Labeling),textFont:M.textFont,textColor:P(M.textColor,A),textFontSize:P(M.textFontSize,A),textLetterSpacing:M.textLetterSpacing,textHaloColor:P(M.textHaloColor,A),textHaloWidth:M.textHaloWidth,textPriority:P(M.textPriority,A),textLabelingSideMargin:M.textLabelingSideMargin,textDuplicationSpacing:P(M.textDuplicationSpacing,A),labelingGroup:M.labelingGroup,lineEndingOffsets:M.lineEndingOffsets,colorEffect:P(M.colorEffect,A),floorCulling:M.floorCulling}});break}case"point":{const M=pw(e.style);n=Me(he({},A),{type:e.type,interactive:(C=e.interactive)!=null?C:!0,style:{visibility:We(M.visibility),allowOverlap:M.allowOverlap,allowElevation:M.allowElevation,elevation:P(M.elevation,A),iconImage:P(M.iconImage,A),iconAnchor:ti(M.iconAnchor,A),iconOffset:ti(M.iconOffset,A),iconWidth:P(M.iconWidth,A),iconTextField:P(M.iconTextField,A,tt.Labeling),iconTextFont:Pi(M.iconTextFont,A),iconTextAnchor:ti(M.iconTextAnchor,A),iconTextOffset:ti(M.iconTextOffset,A),iconTextColor:P(M.iconTextColor,A),iconTextFontSize:P(M.iconTextFontSize,A),iconTextLineHeight:M.iconTextLineHeight,iconTextLetterSpacing:M.iconTextLetterSpacing,iconTextPadding:ti(M.iconTextPadding,A),iconTextHaloWidth:Vs(Je(M.iconTextHaloWidth)),iconTextHaloColor:P(M.iconTextHaloColor,A),iconOpacity:P(M.iconOpacity,A),iconPriority:P(M.iconPriority,A),iconLabelingMargin:M.iconLabelingMargin,iconLabelingGroup:M.iconLabelingGroup,iconRotation:P(M.iconRotation,A),textField:P(Je(M.textField),A,tt.Labeling),textFont:P(Je(M.textFont),A),textColor:P(Je(M.textColor),A),textFontSize:P(Je(M.textFontSize),A),textLineHeight:Vs(Je(M.textLineHeight),1.2),textLetterSpacing:Vs(Je(M.textLetterSpacing)),textField2:Pi(mn(M.textField),A,tt.Labeling),textFont2:Pi(mn(M.textFont),A),textColor2:Pi(mn(M.textColor),A)||P(Je(M.textColor),A),textFontSize2:Pi(mn(M.textFontSize),A)||P(Je(M.textFontSize),A),textMaxLengthPerLine:M.textMaxLengthPerLine,textPlacement:P(M.textPlacement,A),textPriority:P(M.textPriority,A),textOffset:P(Je(M.textOffset),A),textOffset2:Pi(mn(M.textOffset),A),textHaloColor:P(Je(M.textHaloColor),A),textHaloColor2:Pi(mn(M.textHaloColor),A)||P(Je(M.textHaloColor),A),textHaloWidth:Vs(Je(M.textHaloWidth)),textHaloWidth2:Vs(mn(M.textHaloWidth)||Je(M.textHaloWidth)),textLabelingMargin:Je(M.textLabelingMargin),textLabelingMargin2:mn(M.textLabelingMargin)||Je(M.textLabelingMargin),textLabelingGroup:Je(M.textLabelingGroup),textLabelingGroup2:mn(M.textLabelingGroup)||Je(M.textLabelingGroup),duplicationSpacing:P(M.duplicationSpacing,A),endingOffsets:M.endingOffsets,floorCulling:M.floorCulling}});break}case"arrow":{const M=mw(e.style);n=Me(he({},A),{type:e.type,interactive:(T=e.interactive)!=null?T:!1,ignoreTier:P((D=e.ignoreTier)!=null?D:!1,A),style:{visibility:We(M.visibility),color:P(M.color,A),strokeColor:P(M.strokeColor,A),lineWidth:P(M.lineWidth,A),strokeWidth:P(M.strokeWidth,A),tipWidth:P(M.tipWidth,A),tipHeight:P(M.tipHeight,A),roundingRadius:P(M.roundingRadius,A),animation:FT(M.animation,A)}});break}case"raster":{const M=yw(e.style);n=Me(he({},A),{type:e.type,ignoreTier:P((B=e.ignoreTier)!=null?B:!1,A),style:{visibility:We(M.visibility),opacity:P(M.opacity,A)}});break}case"circle":{const M=hw(e.style);n=Me(he({},A),{type:e.type,interactive:(k=e.interactive)!=null?k:!0,style:{visibility:We(M.visibility),color:P(M.color,A),strokeColor:P(M.strokeColor,A),strokeColor2:P(M.strokeColor2,A),width:P(M.width,A),strokeWidth:P(M.strokeWidth,A),strokeWidth2:P(M.strokeWidth2,A)}});break}case"heatmap":{const M=gw(e.style);n=Me(he({},A),{type:e.type,style:{visibility:We(M.visibility),color:P(M.color,A),radius:P(M.radius,A),opacity:P(M.opacity,A),intensity:P(M.intensity,A),weight:P(M.weight,A),downscale:M.downscale},framebufferId:{framebuffer:io}});break}case"model":{const M=ww(e.style);n=Me(he({},A),{interactive:(j=e.interactive)!=null?j:!0,interactiveOcclusion:(U=e.interactiveOcclusion)!=null?U:!0,type:"gltfModel",style:{visibility:We(M.visibility),modelSrc:P(M.modelSrc,A),offset:P(M.offset,A,tt.Generator),scale:P(M.scale,A,tt.Generator),rotation:P(M.rotation,A,tt.Generator),scene:P(M.scene,A),color:P(M.color,A),linkedIds:P(M.linkedIds,A),colorTextureUvIndex:M.colorTextureUvIndex,roughness:M.roughness,metallic:M.metallic,preventObjectsHiding:M.preventObjectsHiding,nearCameraFade:P(M.nearCameraFade,A),ignoreGlobalLighting:M.ignoreGlobalLighting,showRatio:P(M.showRatio,A),lightingModel:M.lightingModel,playAnimation:P(M.playAnimation,A),geometryModifier:P(M.geometryModifier,A),colorEffect:P(M.colorEffect,A),floorCulling:M.floorCulling}});break}case"overpass":{const M=bw(e.style);n=Me(he({},A),{type:e.type,style:{visibility:We(M.visibility),debug:M.debug,sideColor:P(M.sideColor,A),bottomColor:P(M.bottomColor,A),topColor:P(M.borderTopColor,A),strokeColor:P(M.strokeColor,A),strokeWidth:P(M.strokeWidth,A),thickness:P(M.thickness,A),borderHeight:P(M.borderHeight,A),borderWidth:P(M.borderWidth,A),color:P(M.color,A),nearCameraFade:P(M.nearCameraFade,A),tunnelHeight:P(M.tunnelHeight,A)}});break}case"tunnel":{const M=Iw(e.style);n=Me(he({},A),{type:e.type,style:{visibility:We(M.visibility),sideColor:P(M.sideColor,A),bottomColor:P(M.bottomColor,A),topColor:P(M.topColor,A),strokeColor:P(M.strokeColor,A),strokeWidth:P(M.strokeWidth,A),color:P(M.color,A),nearCameraFade:P(M.nearCameraFade,A)}});break}}}catch(A){if(A instanceof jc){console.warn(`Problem with layer #${e.id}: ${A}`);return}throw A}return n}function RT(e){var n,i;const t={id:e.id,innerId:Zs(),renderIndex:Hc.getIndex(),type:e.type,layers:[],orderBy:[],precomputes:[]};return t.orderBy=(i=(n=e.orderBy)==null?void 0:n.map(s=>B0(s,t,tt.Uniform)))!=null?i:[],e.layers.forEach((s,r)=>{const o=qo(s,t);o&&(o.groupId=t.innerId,o.groupIndex=r,o.renderIndex=t.renderIndex,t.layers.push(o))}),t}function $c(e){const t=vw(e),n={id:"dem",type:"dem",innerId:Xs,filter:!0,precomputes:[],minzoom:-1/0,maxzoom:1/0,renderIndex:nT,style:{},framebufferId:{hillshade:io,flatBottom:io},lightingMode:R0};return n.style={visibility:"visible",lightingDirection:typeof t.lightingDirection!="undefined"?P(t.lightingDirection,n):null,shadingIntensity:P(t.shadingIntensity,n),shadingPalette:N0(t.shadingPalette,n),verticalScale:P(t.verticalScale,n)},n}function V0(e){const t=Mw(e),n={id:"sky",type:"custom",innerId:Hl,filter:!0,precomputes:[],minzoom:-1/0,maxzoom:1/0,renderIndex:iT,style:{}};return n.style={visibility:"visible",skyColor:P(t.skyColor,n),fogColor:P(t.fogColor,n),starsIntensity:P(t.starsIntensity,n)},n}function j0(e,t){var r,o;const n=Tw(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:(r=n.shadows)==null?void 0:r.radius};for(const a in n.lightingModes){const l={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:(o=n.shadows)==null?void 0:o.radius},c=n.lightingModes[a].map(f=>n.sources[f]).filter(Boolean),u=n.shadows?n.sources[n.shadows.source]:void 0;let d=0;c.forEach(f=>{f.color||(f.color="#FFFFFF"),f.type==="ambient"?(l.ambientColor=P(f.color,void 0),l.ambientIntensity=P(f.intensity,void 0),a===n.defaultLightingMode&&(s.ambientColor=l.ambientColor,s.ambientIntensity=l.ambientIntensity)):f.type==="directional"&&(f===u&&(l.shadowLightIndex=d),d===0?(d++,l.dir1Color=P(f.color,void 0),l.dir1Altitude=P(f.altitude,void 0),l.dir1Azimuth=P(f.azimuth,void 0),l.dir1Intensity=P(f.intensity,void 0),a===n.defaultLightingMode&&(s.dir1Color=l.dir1Color,s.dir1Intensity=l.dir1Intensity,s.dir1Azimuth=t.style.lightingDirection===null?l.dir1Azimuth:t.style.lightingDirection,s.dir1Intensity=P(f.intensity,void 0),s.dir1Altitude=l.dir1Altitude)):d===1&&(d++,l.dir2Color=P(f.color,void 0),l.dir2Altitude=P(f.altitude,void 0),l.dir2Azimuth=P(f.azimuth,void 0),l.dir2Intensity=P(f.intensity,void 0)))}),i[a]=l}return i[R0]=s,{defaultLightMode:n.defaultLightingMode,lightingModes:i}}function NT(e){return Sw(e)}function H0(e,t){return typeof e=="number"&&!Number.isNaN(e)?e:t}function BT(e){return e&&pr(e[2])?Wn.Meters:Wn.Pixels}function $0(e){return pr(e)?Wn.Meters:Wn.Pixels}function pr(e,t=!1){return Array.isArray(e)&&(e[0]==="meters-to-pixels"||e[0]==="literal"&&!t&&Array.isArray(e[1])&&e[1].some(n=>pr(n,!0)))}function Y0(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 We(e){return e==="none"?"hidden":e}const Jo=0,kT=1,UT={type:Si.Loaded,index:-1,key:Xi("",.5,.5),isSvg:!1,name:"",fileName:"",rasters:[]},zT=["default","marker","markerText","htmlLabel"],GT={default:0,marker:1,markerText:2,htmlLabel:3,pointLabel:4},VT={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 W0(e){const t=[],n=Object.keys(fi).length;for(let i=0;i<n;i++)t[i]=NaN;for(const i in e){if(fi[i]===void 0)throw new Error(`No such tile prop '${i}'`);t[fi[i]]=e[i]}return t}class jT{constructor(){this.needRenderIndexRebuild=!1,this.style={id:Jo,revision:0,background:{color:js("#f6f2de")},light:{defaultLightMode:"global",lightingModes:{}},layers:[],layersById:{},layerIdToInnerId:{},groupsById:{},iconBaseUrl:"",fontUrlTemplate:"",modelsBaseUrl:"",rasterSets:{byIndex:{},byKey:{}},labelingGroups:{indexToGroup:zT,groupToIndex:GT,table:VT},fonts:Ir,fontNameToIndex:Ah(Ir),icons:{},models:[],modelIndex:{},dem:$c({}),environment:V0({}),graphicsPresets:{light:{},normal:{},immersive:{}},targets:{}},this.zIndexById={};const t=qo({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){var n;return((n=this.style.layersById[t])==null?void 0:n.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]=UT}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)=>{var r,o;const i=(r=this.zIndexById[t.innerId])!=null?r:0,s=(o=this.zIndexById[n.innerId])!=null?o:0;return i-s});for(let t=0;t<this.style.layers.length;t++)this.style.layers[t].renderIndex=t}}function HT(e,t,n){const i="identify-scene",s=document.getElementById(i),r=parseInt(Ra.sceneOpacity.toString(),10);if(r===0){s&&s.parentNode&&s.parentNode.removeChild(s);return}const o=t[0],a=t[1],l=document.createElement("canvas");l.id=i,l.width=o,l.height=a;const c=l.style;c.imageRendering="pixelated",c.pointerEvents="none",c.position="absolute",c.width=n.size[0]+"px",c.height=n.size[1]+"px",c.top=`${n.viewport.top}px`,c.left=`${n.viewport.left}px`;const u=l.getContext("2d");u.clearRect(0,0,o,a);const d=u.createImageData(o,a);for(let f=0;f<o;f++)for(let h=0;h<a;h++)for(let g=0;g<4;g++){const v=(f+h*o)*4+g,p=(f+(a-1-h)*o)*4+g;d.data[v]=g===3?r:e[p]}u.putImageData(d,0,0),s&&s.parentNode?s.parentNode.replaceChild(l,s):document.body.appendChild(l)}function Z0(e,t,n){const s=ne,r={x:new Uint16Array([0,s,s,0,0]),y:new Uint16Array([0,0,s,s,0])},o=W0({}),a=Ys(n,dl,fi,o,Jd);_0({collector:e,generator:dt.generate,args:[Jo,t,a,gt([0,0,0,0]),r]})}function X0(){try{return!!localStorage.getItem("debugStatusCompile")}catch(e){return console.warn("Error accessing localStorage in forceGlStatusCheck:",e),!1}}const Yc={defines:[],hash:""},Di=class Di{constructor(t,n,i=Yc,s=Yc){this.shader=null,this.type=t==="vertex"?Di.Vertex:Di.Fragment,this.sourceCode=n,this.commonDefinitions=i,this.definitions=s}static createShaderDefinitions(t){return{defines:t,hash:t.map(i=>{var s;return`${i.type}:${(s=i.value)!=null?s:""}`}).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===Di.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),X0()&&!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,l,c,u){const d=o[Number(c)-1];return d?`ERROR ${l}:${c}: ${u}
Erroneous line: <<${d}>>
`: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(`
`)}};Di.Vertex=1,Di.Fragment=2;let Ko=Di;function q0(e,t,n,i){for(const s of t)WT(e,n,s,i)}function $T(e,t,n){var r;const i=t.buffer,s=[];for(const o of t.generatedObjects){let a=o.rangeEnd-o.rangeStart===n;!a&&((r=o.meta)==null?void 0:r.buildingId)>0&&o.attributes.includes(String(o.meta.buildingId))&&(o.rangeEnd=o.rangeStart+n,a=!0);const l=new DataView(i,o.rangeStart,o.rangeEnd-o.rangeStart),c=e.createBuffer(l);c.purpose="instanced",c.drawType=Xe.StaticDraw,o.buffer=c,a&&(o.tMatrix3x3=new Float32Array(l.buffer,o.rangeStart+8,9)),s.push(c)}return s}function YT(e,t,n,i,s){const r=e.createBuffer(n);r.purpose="attributes",r.drawType=Xe.StaticDraw;const o=[];let a,l,c;return s&&(c=e.createBuffer(s,{itemSize:1,dataType:Xe.UnsignedShort},!0),c.elementsType=Xe.UnsignedShort),t.forEach(u=>{const d=e.getShaderProgram(u.programName),f=u.vaoCreator(r,d,c);if(u.needsVisibilityBuffer){if(!a||!l){const h=new Uint8Array(new Array(i).fill(1));a=e.createBuffer(h,void 0,!1,!0),a.purpose="visibility",l=new C0(a,{itemSize:1,dataType:Xe.UnsignedByte})}f.setAttribute("a_float_visibility",l)}o.push(f)}),{buffer:r,visibilityBuffer:a,vaos:o}}function WT(e,t,n,i){const{renderer:s,instanceLinker:r,map:o}=e,{symbol:a,sink:l,generatedObjects:c,buffer:u,elementsBuffer:d,elementSize:f}=n;if(s.symbolSettingsList[a]===void 0)return;const g=J0(s,a,l);if(g.length===0)return;const v=hr(a,l);if(g[0].instanceBinder){const x=$T(s,n,v);t.buffers.push(...x),r.enqueue(n,t);return}let p=0;d&&f?p=d.byteLength/f:p=u.byteLength/v;const{buffer:m,vaos:b,visibilityBuffer:w}=YT(s,g,u,p,d);t.pushBuffer(m),w&&t.pushBuffer(w);const I=a==="polygonExtrusion"&&!o.getFeatureFlag("transparentBuildingsOff")||a==="lineExtrusion";for(let x=0;x<c.length;x++){const{rangeStart:E,rangeEnd:C,attributes:T,drawMode:D,meta:B,objectsData:k}=c[x],j=P0[a].sinks[l].unpackObjectAttributes(T),U=[];for(let A=0;A<g.length;A++){const M=g[A],S=b[A],L=M.uniformSet||"fill",_={id:pl(),type:Ml.Tile,layerSettings:M,start:E/v,count:(C-E)/v,attributes:j,renderingProperties:{},attributesHash:JSON.stringify(T)+"_"+L+"_"+t.detailLevel,vao:S,drawMode:D,tile:t,symbol:a,sink:l,meta:B,canRender:!0};I&&(_.shaderDefinitions=Ko.createShaderDefinitions([{type:"BLEND"}])),t.push(_),M.needsVisibilityBuffer&&U.push(S)}i&&U.length>0&&k&&t instanceof na&&ZT(k,t,U,i,!!j.floorId)}}function ZT(e,t,n,i,s){const r=s?t.floorObjectsMap:t.objectsMap,o=[];for(const a in e){const l=e[a];let c=r[a];c||(c=new Map,r[a]=c);let u=c.get(n);u||(u=[],c.set(n,u));for(const d of l)u.push(d);i.isHidden(a,fs.PolygonExtrusion)&&o.push(a)}i.triggerIdUpdate(o)}function J0(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 XT=4,qT=.001,JT=1e-7,KT=10,mr=11,Qo=1/(mr-1),QT=typeof Float32Array=="function";function K0(e,t){return 1-3*t+3*e}function Q0(e,t){return 3*t-6*e}function ep(e){return 3*e}function ea(e,t,n){return((K0(t,n)*e+Q0(t,n))*e+ep(t))*e}function tp(e,t,n){return 3*K0(t,n)*e*e+2*Q0(t,n)*e+ep(t)}function eS(e,t,n,i,s){let r,o,a=0;do o=t+(n-t)/2,r=ea(o,i,s)-e,r>0?n=o:t=o;while(Math.abs(r)>JT&&++a<KT);return o}function tS(e,t,n,i){for(let s=0;s<XT;++s){const r=tp(t,n,i);if(r===0)return t;const o=ea(t,n,i)-e;t-=o/r}return t}function nS(e){return e}function np(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 nS;const s=QT?new Float32Array(mr):new Array(mr);for(let o=0;o<mr;++o)s[o]=ea(o*Qo,e,n);function r(o){let a=0,l=1;const c=mr-1;for(;l!==c&&s[l]<=o;++l)a+=Qo;--l;const u=(o-s[l])/(s[l+1]-s[l]),d=a+u*Qo,f=tp(d,e,n);return f>=qT?tS(o,d,e,n):f===0?d:eS(o,a,a+Qo,e,n)}return function(a){return a===0?0:a===1?1:ea(r(a),t,i)}}function ip(e,t,n,i){return t+n/i*e}const iS=np(.25,.1,.25,1);function sp(e,t,n,i){return t+n*iS(e/i)}function sS(e,t,n,i){return n*(e/=i)*e+t}function rS(e,t,n,i){return-n*(e/=i)*(e-2)+t}function oS(e,t,n,i){return(e/=i/2)<1?n/2*e*e+t:-n/2*(--e*(e-2)-1)+t}function aS(e,t,n,i){return n*(e/=i)*e*e+t}function lS(e,t,n,i){return n*((e=e/i-1)*e*e+1)+t}function cS(e,t,n,i){return(e/=i/2)<1?n/2*e*e*e+t:n/2*((e-=2)*e*e+2)+t}function uS(e,t,n,i){return n*(e/=i)*e*e*e+t}function dS(e,t,n,i){return-n*((e=e/i-1)*e*e*e-1)+t}function fS(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 hS(e,t,n,i){return n*(e/=i)*e*e*e*e+t}function pS(e,t,n,i){return n*((e=e/i-1)*e*e*e*e+1)+t}function mS(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 yS(e,t,n,i){return-n*Math.cos(e/i*(Math.PI/2))+n+t}function gS(e,t,n,i){return n*Math.sin(e/i*(Math.PI/2))+t}function vS(e,t,n,i){return-n/2*(Math.cos(Math.PI*e/i)-1)+t}function wS(e,t,n,i){return e==0?t:n*Math.pow(2,10*(e/i-1))+t}function bS(e,t,n,i){return e==i?t+n:n*(-Math.pow(2,-10*e/i)+1)+t}function IS(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 MS(e,t,n,i){return-n*(Math.sqrt(1-(e/=i)*e)-1)+t}function TS(e,t,n,i){return n*Math.sqrt(1-(e=e/i-1)*e)+t}function SS(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 ES(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 AS(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 xS(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 _S(e,t,n,i,s){return s==null&&(s=1.70158),n*(e/=i)*e*((s+1)*e-s)+t}function PS(e,t,n,i,s){return s==null&&(s=1.70158),n*((e=e/i-1)*e*((s+1)*e+s)+1)+t}function LS(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 CS(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 DS(e,t,n,i){return n*(1-Math.pow(1-e/i,Na.nonLinearity+1))+t}const OS=Object.freeze(Object.defineProperty({__proto__:null,ease:sp,easeInBack:_S,easeInCirc:MS,easeInCubic:aS,easeInElastic:ES,easeInExpo:wS,easeInOutBack:LS,easeInOutCirc:SS,easeInOutCubic:cS,easeInOutElastic:xS,easeInOutExpo:IS,easeInOutQuad:oS,easeInOutQuart:fS,easeInOutQuint:mS,easeInOutSine:vS,easeInQuad:sS,easeInQuart:uS,easeInQuint:hS,easeInSine:yS,easeOutBack:PS,easeOutBounce:CS,easeOutCirc:TS,easeOutCubic:lS,easeOutElastic:AS,easeOutExpo:bS,easeOutQuad:rS,easeOutQuart:dS,easeOutQuint:pS,easeOutSine:gS,inertia:DS,linear:ip},Symbol.toStringTag,{value:"Module"})),FS={easing:"easeInOutQuad",forceFinalValue:!0,renderAfterUpdate:!0};function RS(e,t){return t.tickers[e]}function rp(e,t,n,i,s,r,o,a){let l;t.animationGroup&&(l=Object.keys(n.tickers).filter(c=>n.tickers[c].animationGroup===t.animationGroup)),n.tickers[e]=Me(he(he({},FS),t),{from:i,to:s,duration:r,attributes:a,startTime:n.time,alreadyStartedGroupTickers:l,iterationCount:o})}function Wc(e,t){delete t.tickers[e]}function op(e,t){return!!t.tickers[e]}function ap(e,t,n){var l;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 u=lp(i.easing,i.from[c],i.to[c],i.duration,s);r.push(u)}}else r=lp(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||Wc(e,n),t.complete&&t.complete(n)),(typeof i.renderAfterUpdate=="function"?i.renderAfterUpdate():i.renderAfterUpdate)&&((l=i.attributes)!=null&&l.layerId?n.rerenderEvents.push({type:"layerAnimationTicker",layerId:i.attributes.layerId,styleId:i.attributes.styleId}):n.rerenderEvents.push({type:"coreAnimationTicker"}))}function lp(e,t,n,i,s){return typeof e=="string"?OS[e](s,t,n-t,i):e(s,t,n-t,i)}var ta=(e=>(e[e.DerivedFromTile=0]="DerivedFromTile",e[e.Present=1]="Present",e[e.Absent=2]="Absent",e))(ta||{});function NS(e){return e?1:2}let BS=0;class cp{constructor(t,n){this.isDestroyed=!1,this.id=BS++,this.ids=n,this.tickerName=`tile-fade-${t}-${this.id}`,this.readiness=1,this.needSync=!1,this.ecefDataState=0,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)=>{var a,l,c;const o=(a=this.mvpMatrices.get(r))!=null?a:new Float32Array(16);if(ki(o,t,s),this.mvpMatrices.set(r,o),n){const u=(l=this.demMatrices.get(r))!=null?l:new Float32Array(16);ki(u,n,s),this.demMatrices.set(r,u)}if(i){const u=(c=this.flatMapTexMatrices.get(r))!=null?c:new Float32Array(16);ki(u,i,s),this.flatMapTexMatrices.set(r,u)}})}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=[],Wc(this.tickerName,t),this.isDestroyed=!0}updateTicker(t){ap(this.tickerName,{step:(n,i)=>{this.readiness=i}},t)}startTicker(t,n,i,s,r){rp(this.tickerName,{easing:n},t,s,r,i,1)}tickerFinished(t){return!op(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 na extends cp{constructor(t,n,i,s,r=[0,0,0,0],o,a,l){super(t,a),this.objectsMap={},this.floorObjectsMap={},this.dynamicObject=o,this.sourceId=l,q0(i,n,this,a),this.setTileCoords(r,s)}setTileCoords(t,n){const i=t[2],s=t[3],r=jt(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){const n=[...t.visibleMapReplicas];if(this.dynamicObject&&this.dynamicObject.isOutOfMainReplica()){const r=n[0],o=n[n.length-1];n.push(r-1,o+1)}const i=V/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=$i(o);this.bounds.set(r,{min:[a[0],a[1]],max:[a[0]+this.size,a[1]+this.size]});const l=Ed();Cr(l,[a[0]-i,a[1]-i,0],at(this.size/Oi,this.size/Oi,Ms/Oi)),this.modelMatrices.set(r,l)}),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 c=a[0].getBuffer("a_float_visibility").getData();if(!(c instanceof Uint8Array))return;let u=!1;for(const{offset:d,size:f}of o)if(c[d]!==n){for(let h=d;h<d+f;++h)c[h]=n;u=!0}if(u){a[0].rewriteData("a_float_visibility");for(const d of a)d.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 kt=(e=>(e[e.Stationary=0]="Stationary",e[e.ZoomingIn=1]="ZoomingIn",e[e.ZoomingOut=2]="ZoomingOut",e))(kt||{}),xt=(e=>(e[e.ByOne=0]="ByOne",e[e.WaitingLayer=1]="WaitingLayer",e[e.GlobalWaiting=2]="GlobalWaiting",e))(xt||{});function kS(e,t,n){return{key:t,labelsKey:`${e.labelsKey}_${t}`,useful:!0,ready:!1,needGenerate:!1,tile:e,status:0,params:n.clone()}}function up(e,t,n){e.generatedData=t,n&&e.params.setTileIds(n)}function dp(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 Zc(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 fp(e){return e.status===0}function hp(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:US(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 na(e.tile.type,o,i,n,e.tile.coords,void 0,s,e.tile.sourceId)}),t.add(e.key,e));break}}function US(e,t,n){switch(e.tile.type){case"zenith":return!!(e.useful&&e.tile.serverMetadata&&zS(e.tile.serverMetadata,t,n));case"traffic":return!!(e.useful&&e.tile.serverMetadata);case"raster":case"geojson":case"dem":return!!e.useful;default:return!1}}function zS(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>Oa&&!s.isModelsInfoLoaded(o))return!1}return!0}class yr{constructor(t,n,i,s,r,o){this.selectedIds=t.slice(),this.styleState=he({},n),this.tileRevision=i,this.styleRevision=r,this.styleId=s,this.globeMode=o}static equal(t,n){return t.globeMode===n.globeMode&&t.tileRevision===n.tileRevision&&t.styleId===n.styleId&&t.styleRevision===n.styleRevision&&Ri(t.getSelectedIds(),n.getSelectedIds())&&Ri(t.styleState,n.styleState)}clone(){return new yr(this.selectedIds,this.styleState,this.tileRevision,this.styleId,this.styleRevision,this.globeMode)}stringify(){const t=this.selectedIds.join("|");return`sId=${this.styleId}_sRev=${this.styleRevision}_tRev=${this.tileRevision}_sel=${t}_sSt=${JSON.stringify(this.styleState)}_globe=${this.globeMode}`}getSelectedIds(){return this.tileIds?this.selectedIds.filter(t=>{var n;return(n=this.tileIds)==null?void 0:n.has(t)}):this.selectedIds.slice()}setTileIds(t){this.tileIds=t}}var Xc=(e=>(e[e.Initial=0]="Initial",e[e.Loading=1]="Loading",e[e.Loaded=2]="Loaded",e))(Xc||{});function GS(e,t,n,i){return{type:e,sourceId:n,key:Le(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 pp(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){qc(e,n,t);return}t.performanceCaveatEmitted||(r||!n.hover||n.hover.id===s)&&jS(e,t,n,s,i)}function VS(e,t){const n=Math.min(Math.floor(e.styleZoom),si.maxDetailLevel),i=t.coords[3];return n===i}function jS(e,t,n,i,s){if(!n.idSet||!n.idSet.has(i)||!VS(t,n)){qc(e,n,t);return}const r=e.identifier.getIdScope(Gc);r.isHidden(i,fs.PolygonExtrusion)||HS(e,n,i,s).then(o=>{qc(e,n,t);const a={id:i,tileObjects:[],generatedData:[]},l=[];o.results.forEach(c=>{const u=new na("hover",c.collectorOutput.data,e,t,n.coords,void 0,r),{packedRasters:d,rastersToLoad:f}=c.collectorOutput;d!==void 0&&e.assetManager.prepareRasters(c.styleId,d),e.assetManager.loadRasters(f),a.tileObjects.push(u),e.tileManager.addObject(u),u.startTicker(t,Ss.inAnimationType,Ss.inAnimationTime,0,1),c.collectorOutput.labels.length&&l.push({metatileHash:c.metatileHash,labels:c.collectorOutput.labels,styleId:c.styleId})}),a.generatedData=o.results,e.labeler.addLabels("label_hover",ar.Tile,l),e.identifier.queryFillCache(),n.hover=a})}function qc(e,t,n){t.hover&&(t.hover.tileObjects.forEach(i=>{t.oldHoverTileObjects.push(i),i.startTicker(n,Ss.outAnimationType,Ss.outAnimationTime,1,0)}),t.hover=void 0,e.labeler.removeLabels("label_hover"),e.identifier.queryFillCache())}function HS(e,t,n,i){const s=t.newMod||t.currentMod,r=(s==null?void 0:s.params.getSelectedIds())||[],o=e.map.state;return e.defaultSource.generateHoverTile(o,t.coords,o.handyStyleId,r,self.devicePixelRatio,{},n,i)}function mp(e){if(e.newMod&&e.newMod.needGenerate)return e.newMod.needGenerate=!1,e.newMod}function $S(e){return(!e.currentMod||fp(e.currentMod))&&(!e.newMod||fp(e.newMod))}function YS(e,t){e.currentMod&&Zc(e.currentMod,t),e.newMod&&Zc(e.newMod,t)}function WS(e){e.currentMod=void 0}function ia(e){if(e.currentMod&&e.currentMod.useful)return e.currentMod;if(e.newMod&&e.newMod.useful)return e.newMod}function ZS(e){e.currentMod&&(e.currentMod.useful=!1),e.newMod&&(e.newMod.useful=!1)}function XS(e,t,n){if(e.idSet&&t.setTileIds(e.idSet),!e.currentMod&&!e.newMod){Jc(e,t,n);return}if(e.currentMod&&yr.equal(e.currentMod.params,t)){e.currentMod.useful=!0,e.newMod=void 0;return}if(e.newMod){yr.equal(e.newMod.params,t)?e.newMod.useful=!0:Jc(e,t,n);return}Jc(e,t,n)}function Jc(e,t,n){const i=Fg(e.coords,t),s=n.get(i);s?(e.newMod=s,e.newMod.useful=!0):(e.newMod=kS(e,i,t),e.idSet&&e.newMod.params.setTileIds(e.idSet))}function qS(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&&hp(e.currentMod,t,n,i,s),e.newMod&&(hp(e.newMod,t,n,i,s),e.newMod.needGenerate&&(e.needGenerate=!0))}function JS(e){e.newMod&&e.newMod.ready&&(e.currentMod=e.newMod,e.newMod=void 0)}function KS(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 QS(e){e.status===1&&(e.needAbortFetch=!0),e.status=0,e.serverMetadata=void 0,e.revision++}function eE(e){e.revision++}const tE=()=>{};class yp{constructor(t,n=tE){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 hs(e){const t=e.viewportTiles;for(const n in e.tiles)ZS(e.tiles[n]);for(const n of t){let i=e.tiles[n];i||(i=e.tiles[n]=GS(e.type,vl(n),e.sourceId,e.tileLayerId));const s=new yr(e.selectedIds,e.styleState,i.revision,e.styleId,e.styleRevision,e.globeMode);XS(i,s,e.tileModsCache)}}function Kc(e,t){for(const n of t){const i=e[n],s=ia(i);if(!s||!s.ready)return!1}return!0}function gp(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 vp(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 wp(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 bp(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];$S(r)&&!t.has(s)&&e.zoomDirection===kt.Stationary&&!n.has(r)&&i.push(r)}return i}function Ip(e,t,n,i,s,r,o,a,l,c,u=0,d=!1,f=!1){return{type:e,sourceId:t,tileLayerId:n,styleId:l.handyStyleId,styleRevision:a.styleManager.getStyleRevision(l.handyStyleId),styleState:l.styleState,minZoomLevel:i,maxZoomLevel:s,minDetailLevel:r,maxDetailLevel:o,tiles:{},viewportTiles:new Set,zoomLevel:Mp(e,l.zoom,l.styleZoom),zoomDirection:kt.Stationary,zoomStartZoom:0,tileModsCache:new yp(0,(h,g)=>{var v;a.labeler.removeLabels(g.labelsKey),(v=g.objects)==null||v.forEach(p=>a.tileManager.removeObject(p)),Zc(g,l)}),tileModsCacheMaxCount:0,selectedIds:[],displayedMods:{},tilesAppearance:xt.ByOne,mapState:l,stopLabelAnimation:!1,viewportPadding:u,displayStats:{matched:0,shifted:0,parent:0,children:0},requestOddTiles:d,ids:c,useExtendedTilesBounds:f,globeMode:l.globeMode}}function Mp(e,t,n){return e==="raster"?Math.round(t):Math.floor(n)}function Qc(e){for(const t in e.tiles)YS(e.tiles[t],e.mapState);e.tiles={},e.viewportTiles=new Set,e.zoomDirection=kt.Stationary,e.tileModsCache.reset(),e.displayedMods={},e.tilesAppearance=xt.ByOne}function Tp(e,t,n,i,s=!1){const{tileManager:r,renderer:o}=e,a=n.displayedMods,l=Id(a,i);l.forEach(d=>{if(d.objects!==void 0){let f=!s;for(const h in i)if(Xg(d.tile,i[h].tile)){f=!1;break}d.objects.forEach(h=>{r.addObject(h),f&&h.startTicker(t,Fa.type,Fa.time,0,1)})}});const c=Id(i,a);c.forEach(d=>{var f;d.objects!==void 0&&(d.objects.forEach(h=>{r.removeObject(h)}),(f=d.tile.hover)==null||f.tileObjects.forEach(h=>r.removeObject(h)))});const u=l.length>0||c.length>0;return u&&(t.needLabeling=!0,o.addRerenderEvent()),u}function eu(e){e.viewportTiles.forEach(t=>JS(e.tiles[t]))}function nE(e){switch(e){case"geojson":return 3;case"raster":return 1/0;case"dem":return 1}return 2}function tu(e,t,n){iE(e,t.styleZoom,t.zoom),sE(e,t,n),rE(e),hs(e)}function iE(e,t,n){const i=Mp(e.type,n,t),s=i-e.zoomLevel;e.zoomDirection===kt.Stationary&&(s>0?(e.zoomDirection=kt.ZoomingIn,e.zoomStartZoom=e.zoomLevel):s<0&&(e.zoomDirection=kt.ZoomingOut,e.zoomStartZoom=e.zoomLevel)),e.zoomLevel=i}function sE(e,t,n){if(e.zoomLevel<e.minZoomLevel){e.viewportTiles=new Set;return}const i=xe(e.zoomLevel,e.minZoomLevel,e.maxZoomLevel),s=xe(e.zoomLevel,e.minDetailLevel,e.maxDetailLevel);let r;switch(e.type){default:r=uf(t,n,i,e.minZoomLevel,s,e.viewportPadding,e.maxZoomLevel,e.requestOddTiles,e.useExtendedTilesBounds).map(Le),t.stats.foundVisibleTilesCount=e.viewportTiles.size}e.viewportTiles=new Set(r)}function rE(e){const t=Math.round((Object.keys(e.displayedMods).length+e.viewportTiles.size)*si.cacheRatio);e.tileModsCacheMaxCount<t&&(e.tileModsCacheMaxCount=t),t>e.tileModsCacheMaxCount/2&&e.tileModsCache.setSize(t)}function oE(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 l=ra(r,o,a),c=n[l];c?c.push(s):n[l]=[s],r=Math.floor(r/2),o=Math.floor(o/2)}}return n}function aE(e,t,n){const i=uE(e),s=Object.keys(i).reduce((d,f)=>{const h=i[f],g=ra(h.coords[0],h.coords[1],h.coords[2]);return d[g]=h,d},{}),r=Math.min(...Object.values(i).map(d=>d.coords[2])),o=Math.min(...Array.from(t).map(d=>e[d].coords[2])),a=oE(i,o),l={},c=new Set;for(const d of t){const f=i[d];if(f){sa(l,f),n.matched++;continue}const h=e[d],g=lE(h,i,3);if(g){n.shifted++,sa(l,g);continue}const v=ra(h.coords[0],h.coords[1],h.coords[2]),p=Sp(h,r,s);if(p){n.parent++,sa(l,p),c.add(p);continue}const m=a[v];if(m)for(const b of m)n.children++,sa(l,b)}function u(d){const f=Sp(d,r,s);f&&c.has(f)&&(delete l[d.currentMod.key],u(f))}for(const d in l)u(l[d].tile);return l}function lE(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=rf(i[0],i[1],i[2],o),l=t[a];if(l)return l}}function cE(e){const t=e.currentMod;return t===void 0?!1:t.ready}function sa(e,t){const n=t.currentMod;e[n.key]=n}function uE(e){const t={};for(const n in e){const i=e[n];cE(i)&&(t[n]=i)}return t}function Sp(e,t,n){let[i,s,r]=e.coords;for(;r-->=t;){i=Math.floor(i/2),s=Math.floor(s/2);const o=ra(i,s,r);if(n[o])return n[o]}}function ra(e,t,n){return`${e}_${t}_${n}`}function Ep(e,t,n){dE(e,t,n),fE(e),hE(e);for(const i in e.displayedMods)e.tileModsCache.get(i);pE(e),mE(e)}function dE(e,t,n){for(const i in e.tiles)qS(e.tiles[i],e.tileModsCache,t,n,e.ids)}function fE(e){switch(e.tilesAppearance){case xt.ByOne:eu(e);break;case xt.WaitingLayer:Kc(e.tiles,e.viewportTiles)&&(e.tilesAppearance=xt.ByOne,eu(e));break;case xt.GlobalWaiting:break}}function hE(e){const{tiles:t,viewportTiles:n,displayStats:i}=e;e.displayedMods=aE(t,n,i)}function pE({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]&&WS(s)}}function mE(e){switch(e.zoomDirection){case kt.ZoomingIn:(e.zoomLevel<=e.zoomStartZoom||Ap(e))&&(e.zoomDirection=kt.Stationary,e.zoomStartZoom=e.zoomLevel);break;case kt.ZoomingOut:(e.zoomLevel>=e.zoomStartZoom||Ap(e))&&(e.zoomDirection=kt.Stationary,e.zoomStartZoom=e.zoomLevel);break}}function Ap(e){const{tiles:t,viewportTiles:n,displayedMods:i}=e;for(const s of n){const r=t[s],o=ia(r);if(!o||i[o.key]===void 0)return!1}return!0}function yE(e,t,n,i){var s;n.selectedIds=i,n.tilesAppearance=xt.WaitingLayer,hs(n);for(const r in n.tiles){const o=n.tiles[r];pp(e,t,o,n.sourceId,(s=o.hover)==null?void 0:s.id,!0)}}function xp(e,t,n,i){if(!t.disableHoverStyles){for(const s in n.tiles){const r=n.tiles[s];pp(e,t,r,n.sourceId,i)}e.labeler.disableThrottleUpdateOnce()}}function gE(e,t){e.styleState=t,hs(e)}function _p(e,t,n,i){i?e.tilesAppearance=xt.ByOne:e.tilesAppearance=xt.GlobalWaiting,e.styleId=t,e.styleRevision=n,hs(e)}function Pp(e){e.tilesAppearance=xt.ByOne,eu(e)}function vE(e){e.tilesAppearance=xt.WaitingLayer,e.stopLabelAnimation=!0,Object.keys(e.tiles).forEach(t=>{QS(e.tiles[t])}),hs(e)}function wE(e){e.tilesAppearance=xt.WaitingLayer,Object.keys(e.tiles).forEach(t=>{eE(e.tiles[t])}),hs(e)}function bE(e,t,n){for(const i of e.viewportTiles){const s=e.tiles[i],r=ia(s);if(!r)continue;const o=dp(r);if(o.length===0)continue;const a=t.getLabelsDemKey(o);r.demKey!==a&&(r.demKey=a,n.addTileLabels(r.labelsKey,ar.Tile,o))}}function nu(e){return{_src:e.memSizeJs()}}function IE(e){return{_texture:e.memSizeGPU()}}function Lp(e){return{[String(e.purpose)]:{_initData:e.memSizeJs()}}}function ME(e){return{[String(e.purpose)]:{_glBuffer:e.memSizeGPU()}}}function iu(e){var n;const t={};return e.generatedData&&(t.generatedData={collectorOutput:(n=e.generatedData)==null?void 0:n.map(i=>EE(i.collectorOutput))}),e.objects&&(t.objects=e.objects.map(i=>Cp(i))),t}function su(e){return{objects:e.objects?e.objects.map(t=>Dp(t)):0}}function Cp(e){return{buffers:e.buffers.map(Lp)}}function Dp(e){return{children:e.children.map(t=>{var n;return{[`${t.symbol}_${t.sink}`]:((n=t.instanceCount)!=null?n:t.count)*hr(t.symbol,t.sink)}}),buffers:e.buffers.filter(t=>t.purpose!=="attributes"&&t.purpose!=="instanced").map(t=>({[String(t.purpose)]:t.byteLength}))}}function TE(e){return{buffers:e.buffers.filter(t=>t instanceof Xe).map(Lp).filter(t=>t._initData),textures:e.textures.map(nu)}}function SE(e){return{buffers:e.buffers.filter(t=>t instanceof Xe).map(ME),textures:e.textures.map(nu)}}function ru(e){if(typeof e=="number")return e;let t=0;if(Array.isArray(e))for(const n of e)t+=ru(n);else for(const n in e){const i=e[n];typeof i=="number"?t+=i:t+=ru(i)}return t}function EE(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}}}function AE(e){return Pe(this,null,function*(){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:yield e.workers.parser.getMemoryFootprint(),labelingThread:yield e.workers.labeling.getMemoryFootprint(),renderer:e.renderer.getMemoryFootprint(),labeler:e.labeler.getMemoryFootprint(),postEffectsManager:e.postEffectsManager.getMemoryFootprint(),shadowManager:e.shadowManager.getMemoryFootprint()}})}class Op{constructor(t,n,i,s,r,o,a,l={}){var c;this.disabledRegions=null,this.generatingCount=0,this.tilesGenerationQueue=[],this.disableTilesAnimation=!1,this.idsToUpdate=new Set,this.destroyed=!1,l=Object.assign({viewportPadding:0,disableTilesAnimation:!1,requestOddTiles:!1},l),this.ids=r.identifier.getIdScope((c=l.idScope)!=null?c:Gc),this.ids.registerTileLayer(this),this.modules=r,this.mapState=o,this.prevStyleState=o.styleState,this.sourceCore=a,this.id=pl(),this.disableTilesAnimation=!!l.disableTilesAnimation,this.gridState=Ip(a.type,a.id,this.id,t,n,i,s,r,this.mapState,this.ids,l.viewportPadding,l.requestOddTiles,l.useExtendedTilesBounds),this.maxGeneratingCount=nE(a.type)}memSizeJs(){const t=this.gridState;return{gridState:{displayedMods:Object.keys(t.displayedMods).map(n=>iu(t.displayedMods[n])),tileModsCache:t.tileModsCache.keys().filter(n=>!t.displayedMods[n]).map(n=>iu(t.tileModsCache.get(n)))}}}memSizeGpu(){const t=this.gridState;return{gridState:{displayedMods:Object.keys(t.displayedMods).map(n=>su(t.displayedMods[n])),tileModsCache:t.tileModsCache.keys().filter(n=>!t.displayedMods[n]).map(n=>su(t.tileModsCache.get(n)))}}}destroy(){this.destroyed=!0,Qc(this.gridState),this.modules.modelsScene.clearSourceTileMapBySource(this.sourceCore.id),this.ids.unregisterTileLayer(this)}redraw(){Qc(this.gridState),this.modules.modelsScene.clearSourceTileMapBySource(this.sourceCore.id),tu(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(){var n,i;const t=[];for(const s in this.gridState.displayedMods){const r=this.gridState.displayedMods[s];(i=r.generatedData)==null||i.concat(((n=r.tile.hover)==null?void 0:n.generatedData)||[]).forEach(o=>t.push({ids:o.collectorOutput.identifyIds,metatileHash:o.metatileHash,sourceId:r.tile.sourceId,tileKey:r.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}getViewportTileCount(){return this.gridState.viewportTiles.size}getDisplayedTileCount(){return Object.keys(this.gridState.displayedMods).length}viewportTilesReady(){return Kc(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(){_p(this.gridState,this.mapState.handyStyleId,this.modules.styleManager.getStyleRevision(this.mapState.handyStyleId),this.modules.map.core.getIsFirstStyleUpdate())}finishStyleUpdating(){Pp(this.gridState)}setSelectedIds(t){yE(this.modules,this.mapState,this.gridState,t)}setHoverId(t){xp(this.modules,this.mapState,this.gridState,t)}resetHoverId(){xp(this.modules,this.mapState,this.gridState)}onSourceDataChange(){vE(this.gridState)}onFeatureStateMapChange(){wE(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=ia(n);if(s&&s.ready)return!1}return!0}updateViewport(){tu(this.gridState,this.mapState,this.modules)}update(){this.mapState.needReplicasUpdate&&this.setModObjectsSyncNecessity();const t=he({},this.gridState.displayedMods);this.mapState.styleState!==this.prevStyleState&&(gE(this.gridState,this.mapState.styleState),this.prevStyleState=this.mapState.styleState,this.modules.identifier.queryFillCache()),this.gridState.globeMode=this.mapState.globeMode,Ep(this.gridState,this.mapState,this.modules);const{demManager:n,labeler:i}=this.modules;bE(this.gridState,n,i),this.fetch(gp(this.gridState)),this.abortFetch(vp(this.gridState)),this.generate(wp(this.gridState)),this.clearTiles(bp(this.gridState)),Tp(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)=>$r(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===Xc.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){Nf(this.sourceCore.type);return}if(!Array.isArray(a.results))return;let{results:l}=a;r&&(l=l.filter(u=>!r.includes(u.regionId)));const c=new Map;if(l.forEach(u=>{u.collectorOutput.data.forEach(d=>{d.symbol!=="gltfModel"||d.sink!=="instances"||d.generatedObjects.forEach(f=>{var m;const h=Qn.sinks.instances.unpackObjectAttributes(f.attributes),g=(m=f.meta)==null?void 0:m.childrenIds,v=h.parentId;if(!g||!v)return;let p=c.get(v);p||(p=new Set,c.set(v,p));for(const b of g)p.add(b)})})}),c.size){const u=Le(s.tileCoords);this.ids.updateParentChildrenData(u,c)}l.forEach(u=>{const{styleId:d,metatileHash:f,regionId:h,collectorOutput:g}=u,{packedRasters:v,rastersToLoad:p,floorHidingMap:m,dataModelsUrls:b}=g;v!==void 0&&this.modules.assetManager.prepareRasters(d,v),this.modules.assetManager.fillDataModelUrlMap(b),this.modules.assetManager.loadRasters(p),this.modules.floorManager.prepareFloors(h,f,m,this.sourceCore.type)}),n.idSet=KS(l),up(i,l,n.idSet),this.modules.labeler.addTileLabels(i.labelsKey,ar.Tile,dp(i))}).finally(()=>{this.generatingCount=this.generatingCount-1,this.updateGenerationQueue()})}getTileToGenerate(){this.tilesGenerationQueue.sort((n,i)=>$r(this.mapState.center,n,i));let t=this.tilesGenerationQueue.shift();for(;t;){const n=mp(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)=>$r(this.mapState.center,i,s)).forEach(i=>{var s;(s=i.newMod)!=null&&s.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,fs.PolygonExtrusion),r=+!this.ids.isHidden(i,fs.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(),this.mapState.needLabeling=!0)}setModObjectsSyncNecessity(){this.gridState.tileModsCache.getData().forEach(n=>{var i;(i=n.objects)==null||i.forEach(s=>{s.needSync=!0})})}}class Fp{constructor(t,n,i,s){var r;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((r=s==null?void 0:s.modelShowHideEventsSublayers)!=null?r: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}]))}generateTile(t,n,i,s,r){return Pe(this,null,function*(){const o=this.options.modelsPath,a=yield 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[Le(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[Le(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)}setData(t){return Pe(this,null,function*(){return this.idToIndex={},this.options=typeof t=="string"?this.options=Me(he({},this.options),{url:t}):this.options=Me(he({},this.options),{data:t}),yield this.worker.setData(t)})}getComponentIndex(t,n){var i;return n?(i=this.idToIndex[n])==null?void 0:i[t]:(console.warn("Нет tileKey при идентификации объекта из GeoJsonSource. Пытаемся получить index из id по-старому."),Number.isNaN(+t)?void 0:+t%le(2,32))}setDataFilter(t){t?this.dataFilter=P(t,{precomputes:[]},tt.Generator):this.dataFilter=void 0}}let xE=1;function Rp(){return xE++}class Np{constructor(t){this.defs=t.map(n=>new _E(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 _E{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 Bp(e,t,n){let i,s,r,o;const a=function(){const u=Date.now()-r;u<t&&u>=0?i=setTimeout(a,t-u):(i=null,n||(o=e(...s),i||(s=null)))};function l(){i!==void 0&&(clearTimeout(i),i=null)}function c(...u){s=u,r=Date.now();const d=n&&!i;return i||(i=setTimeout(a,t)),d&&(o=e(...s),s=null),o}return c.cancel=l,c}const kp=15,ou=17;class Up{constructor(t,n,i){var o,a,l;this.type="geojson",this.isCustomPromoteId=!1,this.id=Rp(),this.modelsAppearStrategy=(o=n.modelsAppearStrategy)!=null?o:$u,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 Fp(this.id,this.modules,n);const s=(a=n.minZoom)!=null?a:Ca.minZoom,r=Math.min((l=n.maxZoom)!=null?l:kp,ou);this.layer=new Op(s,r,s,ou,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 oa={type:"FeatureCollection",features:[]};let zp=class sm extends Up{constructor(t,n,i){n.generateId=!0,super(t,n,i),this.subtype="internal",this.data=n.data,this instanceof sm&&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=oa}setData(t){return Pe(this,null,function*(){(yield this.sourceCore.setData(t))&&(this.data=t,this.layer.onSourceDataChange(),this.modules.identifier.resetCache())})}setDataFilter(t){this.sourceCore.setDataFilter(t)}};class PE extends Up{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)}setDataUrl(t){return Pe(this,null,function*(){(yield this.sourceCore.setData(t))&&(this.layer.onSourceDataChange(),this.modules.identifier.resetCache())})}}let LE=class extends zp{constructor(t,n,i){super(t,n,i),this.subtype="viewport-internal",this.destroyed=!1,this.viewportDiffer=new Np([{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)}setDataFn(t){return Pe(this,null,function*(){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(oa),this.viewportHandler=void 0;return}this.viewportHandler=Bp(()=>Pe(this,null,function*(){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=oa;try{const l=yield fetch(o);l.ok||console.error(`Failed to fetch a tile by url "${o}", status: ${l.status}`);const c=l.headers.get("content-type");(!c||!c.includes("application/json"))&&console.error(`Failed to fetch a tile by url "${o}", expected the "application/json" data but got "${c}"`),a=yield l.json()}catch(l){console.error(`Failed to fetch a tile by url "${o}", message: ${l.message}`)}this.destroyed||this.setData(a)}),500),this.viewportHandler()}};function aa(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 Gp(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(s){t({status:0,message:`Json parse data error from url ${e.url}`},{})}}else t({status:n.status,message:n.statusText},{})},n.send(),n}function Vp(e){return e?e>=500&&e<=599:!1}function jp(e){return new Promise(t=>setTimeout(t,e))}class CE{constructor(){this.cache=new Map,this.pendingRequests=new Map}fetch(t,n=3,i=300){return Pe(this,null,function*(){var o;let s=0,r;for(;s<=n;)try{if(r=yield this.fetchAttempt(t),!r)return;if(!r.err||!Vp((o=r.err)==null?void 0:o.status))return r;throw new Error(`Fetching ${JSON.stringify(t.coords)} attempt ${s} failed.`)}catch(a){if(s>=n)return{metadata:[]};yield jp(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=Le(n),r=aa({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 l=Rg(a),c=Ng(l);this.cache.set(s,l),i({metadata:c,err:o})});this.pendingRequests.set(s,{xhr:r,resolve:i})})}}class au extends Map{constructor(t){super(t),this.featureAttrs=(t==null?void 0: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 lu(e){for(let t=1;t<e.length;t++)e[t]=e[t]+e[t-1]}function DE(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 Hp={1:lu,2:lu,4:lu,8:DE};class $p{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 ze(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&&Hp[s](r),r}function la(e,t,n){e.offset+=-e.offset&7;const i=new Uint32Array(e.buffer,e.offset,t*2);return e.offset+=8*t,n&&Hp[8](i),i}function Yp(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 Wp(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 OE(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 FE(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 l=r[a];n+=-n&7,o.push(new Uint8Array(s,n,l)),n+=l}return e.offset=n,o}function RE(e,t,n){switch(n){case 2:return ze(e,Uint8Array,t);case 3:return ze(e,Uint8Array,t,!0);case 4:return ze(e,Uint16Array,t);case 5:return ze(e,Uint16Array,t,!0);case 6:return ze(e,Uint32Array,t);case 7:return ze(e,Uint32Array,t,!0);case 8:return la(e,t);case 9:return la(e,t,!0);case 10:return ze(e,Uint8Array,t);case 11:return OE(e,t);case 12:return FE(e,t);case 13:return ze(e,Int8Array,t);case 14:return ze(e,Int8Array,t,!0);case 15:return ze(e,Int16Array,t);case 16:return ze(e,Int16Array,t,!0);case 17:return ze(e,Int32Array,t);case 18:return ze(e,Int32Array,t,!0);case 19:return la(e,t);case 20:return la(e,t,!0);case 21:return Yp(e,t);case 22:return Yp(e,t,!0);case 23:return Wp(e,t);case 24:return Wp(e,t,!0);case 25:return ze(e,Uint32Array,t);default:throw new Error("Unknown stream type "+n)}}function cu(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n];return t}function NE(e,t,n){return new e.constructor(e.buffer,e.byteOffset+t*e.BYTES_PER_ELEMENT,n)}let ni;const ps=[],qt=new Int32Array(256);let uu;const du=[],Zp=[],Xp=[],fu=[0,0,0,0,0];let qp=0,hu=0,pu=0,ms={};function BE(e,t,n,i,s,r,o,a,l=!1,c,u,d,f){const{styleState:h,sourceId:g,sourceAttrs:v,tileInfo:p,pixelRatio:m,selectedIds:b,dataFilter:w,floorsEnabled:I,hoverId:x,generateOnlySelectedPoi:E,generateOnlyHoveredPoi:C,modelsPath:T,sharedModelsPath:D}=s,{data:B}=r,k=new Set(b),j=Bg(B);if(j.byteLength<8)return i.getAccumulatedData();ps.length=0;const U=new $p(j);if(U.readU32()!==1279676242)return i.getAccumulatedData();const M=U.readU16();if(M!==2&&M!==3&&M!==4)return console.error(`Unsupported tile format version: "${M}"`),i.getAccumulatedData();ni=M,U.readU16();const S=Nl(m);return kE(U),UE(U),zE(ni,e,t,h,n,i,U,p,S,k,w,o,a,I,g,v,l,x,E,C,T,c,u,d,f,D),i.getAccumulatedData()}function kE(e){const t=ni===4?2:1,n=e.u8;let i=e.offset,s=e.u32[i>>2];for(i+=4,qp=s,hu=i;s--;)i=n[i++]*2+i,i=n[i++]*t+i;e.offset=i+(-i&3)}function UE(e){const t=e.u32[e.offset>>2];e.offset+=4,uu=ze(e,Uint8Array,t);const n=ze(e,Uint32Array,t);for(let i=0;i<t;i++){const s=uu[i];ps[i]=RE(e,n[i],s),qt[i]=0}}function zE(e,t,n,i,s,r,o,a,l,c,u,d,f,h,g,v,p=!1,m,b,w,I,x,E,C,T,D){const B=Array.from(s.featureAttrs);Vi(d,B);const k=qp,j=ze(o,Int32Array,k),U=cu(j),A=ze(o,Uint8Array,U,!0),M=ze(o,Uint8Array,cu(A),!0),S=ze(o,Uint8Array,U,!0),L=ze(o,Uint8Array,cu(S),!0),_=ze(o,Uint16Array,U,!0);let F=0,O=0,N=0,R=!0;for(let z=0;z<k;z++){const Z=j[z];HE(o,d,f);for(let Y=0;Y<Z;Y++){const ee=A[F];ee>0&&(GE(f,ee,M,O,d,e,p),O+=ee);const K=S[F];if(K>0&&(VE(f,K,L,N),N+=K),!f[d.tileProps.db_geometry_type]){console.error(`Geometry type not specified for data source ${g}. Metatile version ${d.version}`);return}R=ee>0||K>0;const G=d.tileProps;let q=f[G[C!=null?C:""]];Number.isNaN(q)&&(q=void 0);const J=Ys(i,v,G,f,[],q,a),X=_[F];X>0&&jE(e,t,n,i,J,s,r,X,a,l,c,u,d,h,g,m,b,w,I,x,R,E,T,D),F++}}Jp()}function GE(e,t,n,i,s,r,o=!1){var a,l;for(;t--;){const c=n[i++],u=Zp[c],d=du[c],f=uu[u];if(f===8||f===9||f===19||f===20)e[d]=S0(ps[u][qt[u]],ps[u][qt[u]+1]),qt[u]+=2;else{const h=ps[u][qt[u]];switch(d){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[d]=r===2?h*Oi:h;break;case s.tileProps.db_label:e[d]=no(h);break;case s.tileProps.db_label2:e[d]=no(h);break;case s.tileProps.db_schedule:e[d]=JSON.parse(no(h));break;case s.tileProps.db_tiers:const g=h.byteLength/Int32Array.BYTES_PER_ELEMENT,v=new DataView(h.buffer,h.byteOffset,h.byteLength),p=v.getInt32(0,!0);if(g===1&&!p)e[d]=void 0;else{const m=new Array(g);m[0]=p;for(let b=1;b<g;b++)m[b]=v.getInt32(b*Int32Array.BYTES_PER_ELEMENT,!0);e[d]=m}break;case s.tileProps.db_shared_model_id:Vi(s,["db_model_theme1_src","db_model_theme2_src"]),e[s.tileProps.db_model_theme1_src]=`{sharedModelsPath}${h}_d.glb`,e[s.tileProps.db_model_theme2_src]=`{sharedModelsPath}${h}_n.glb`;break;default:if(o&&f===11)e[d]=no(h);else{const m=s.tilePropsByIndex[d];e[d]=(l=(a=s.reverseDictionaries[m])==null?void 0:a[h])!=null?l:h}}qt[u]++}}}function VE(e,t,n,i){for(;t--;){const s=n[i++],r=du[s];e[r]=NaN}}let ca=[];function jE(e,t,n,i,s,r,o,a,l,c,u,d,f,h,g,v,p,m,b,w=[],I,x,E,C){var L;const{tileProps:T,defaultProps:D}=f,{tileAttrs:B,featureAttrs:k,id:j}=s,U=l.coords[3],A=T.db_hidden_by_plan_id!==void 0;if(!I&&ca.length===0){for(let _=0;_<pu;_++){const F=fu[_];qt[F]=qt[F]+a}return}const M=B[T.db_geometry_type],S=ni===4?f.vertexProps:f.vertexPropsLegacy[M];if(!S){console.error(`Couldn't get vertex keys for tile ${Le(l.coords)} source ${g}. Metatile version ${f.version}`);return}for(let _=0;_<pu;_++){const F=ni===4?Xp[_]:_,O=fu[_],N=(L=S[F])!=null?L:"signed_z";ms[N]=$E(NE(ps[O],qt[O],a),_,e),ni===4&&N==="z"&&(ms.signed_z=ms.z),qt[O]=qt[O]+a}if(!(T.db_sublayer!==void 0&&!Number.isNaN(B[T.db_sublayer])&&Go(B[T.db_sublayer]))&&!(A&&i._activeFloorIds&&B[T.db_hidden_by_plan_id]&&(i._activeFloorIds.includes(B[T.db_hidden_by_plan_id])||i._backgroundFloorIds.includes(B[T.db_hidden_by_plan_id])))){for(const _ in D){const F=D[_];Number.isNaN(B[F.index])&&(B[F.index]=F.value)}if(!(v&&v!==j)){if(j!==void 0){let _=u.has(j);p&&(_=!0);const F=!!m||!!v&&v===j;if(B[T.selected]=_?1:0,B[T.hovered]=F?1:0,w.length>0){const O={};w.forEach(N=>{O[N]=B[T[N]]}),o.addPromotedObjectAttributes(j,O)}h&&U>=Ba.detailLevel&&(B[T.db_hidden_by_plan_building_id]&&o.addFloorHidingMap(j,B[T.db_hidden_by_plan_building_id]),B[T.db_hidden_by_metro_building_id]&&o.addFloorHidingMap(j,B[T.db_hidden_by_metro_building_id]))}else B[T.selected]=0,B[T.hovered]=0;if(r.featureAttrs.size>0){const _=j!==void 0&&r.get(j);if(_)for(const F of r.featureAttrs)r.clearAttrs=!1,k[T[F]]=_[F];else if(r.clearAttrs===!1){r.clearAttrs=!0;for(const F in T)k[T[F]]!==void 0&&(k[T[F]]=void 0)}}if(x){const _=YE(ms,M,l);if(_){const F=WE(s,Le(l.coords));o.addFeature({type:"Feature",properties:F,geometry:_})}return}I&&(ca=n.getLayers(t.id,T,B).filter(_=>H(_.filter,s)&&(d?H(d,s):!0))),ca.length===0&&s.id&&o.idIndexer.addOrphanId(s.id),zc(o,t,ca,s,f,ni,U,g,l,c,ms,p||m,b,E,C)}}}function HE(e,t,n){const i=Object.keys(t.tileProps).length,s=e.u8;let r,o,a=hu;for(o=1;o<i;o++)n[o]=NaN;for(r=s[a++],o=0;o<r;o++)du[o]=s[a++],Zp[o]=s[a++];for(r=s[a++],o=0;o<r;o++)ni===4&&(Xp[o]=s[a++]),fu[o]=s[a++];pu=r,hu=a,Jp()}function Jp(){ms={}}function $E(e,t,n){if(n===2&&t<3&&e instanceof Uint16Array)for(let i=0;i<e.length;i++)e[i]*=Oi;return e}function YE(e,t,n){var l;const i=[],{x:s,y:r,z:o,signed_z:a}=e;for(let c=0;c<e.x.length;c++){const u=Ns(s[c],r[c],n),d=oe.scaleFactor(u[1]),f=o?o[c]*32:void 0;u[2]=(l=f!=null?f:a==null?void 0:a[c])!=null?l:0,u[2]/=ve*d,i.push(u)}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,u)=>i[Qe(u,i.length)])]};default:return}}function WE(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 ZE=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},XE=e=>ZE(e)>0;function qE(e){e=e.slice().sort(JE);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&&Kp(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&&Kp(n[i-2],n[i-1],o)<=0;)i--;n[i++]=o}return n.slice(0,i-1)}function Kp(e,t,n){return(t[1]-e[1])*(n[0]-e[0])-(t[0]-e[0])*(n[1]-e[1])}function JE(e,t){return e[0]===t[0]?e[1]-t[1]:e[0]-t[0]}function KE(e){const t=[],n=XE(e),i=Pr(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 l=[];Gy(l,e[r],e[o],e[a],n),t.push(l)}return i&&t.push(t[0]),t}const ua=[[0],[0],[0]],Qp=[];function QE(e,t,n,i,s,r,o,a,l){const{matrix:c,offset:u,id:d,selected:f}=r,h=new $p(s),g=[];if(!e)return{objects:i.getAccumulatedData(),textures:g};if(h.readU32()!==1296191066||h.readU16()!==1)return{objects:i.getAccumulatedData(),textures:[]};h.readU16();const v=h.readU32();for(let T=0;T<v;T++)g.push(h.readU8Vector());const{tileProps:p}=o,m=[],b=Object.keys(p).length;for(let T=0;T<b;T++)m[T]=NaN;if(m[p.db_sublayer]="Building_model",m[p.selected]=f?1:0,m[p.db_region]=a,l.featureAttrs.size>0){const T=Array.from(l.featureAttrs);Vi(o,T)}const w=[],I=typeof d!="number"&&l.get(d);if(I)for(const T of l.featureAttrs)l.clearAttrs=!1,w[p[T]]=I[T];else if(l.clearAttrs===!1){l.clearAttrs=!0;for(const T in p)w[p[T]]!==void 0&&(w[p[T]]=void 0)}const x=h.offset,E=Ys(n,dl,p,m,w,d),C=t.getLayers(e.id,p,m).filter(T=>H(T.filter,E));return C.length===0&&E.id&&i.idIndexer.addOrphanId(E.id),C.forEach(T=>{T.type!=="buildingModel"||(Uc(T,E),!H(T.filter,E))||(h.offset=x,eA(e,T,E,i,h,c,u))}),{objects:i.getAccumulatedData(),textures:g}}function eA(e,t,n,i,s,r,o){const a=s.readU32();for(let l=0;l<a;l++){const c=s.readU32(),u=at(s.readF32(),s.readF32(),s.readF32()),d=at(s.readF32(),s.readF32(),s.readF32()),f=Qt(ot(),d,u),h=[];Ad(h,r,u),Bi(h,h,f),h[12]+=o[0],h[13]+=o[1];const g=s.readU16Vector(5),v=s.readU32();for(let w=0;w<v;w++){const I=s.readU32()===1?dm:Mr,x=s.readU16Vector();do En.processSubmesh(e.id,t,n,i,g,x,I,c,h);while(i.isOverloaded())}const p=s.readU16Vector();do En.processOuterEdge(e.id,t,n,i,g,p,h);while(i.isOverloaded());const m=qE(tA(g)),b=KE(m);for(let w=0;w<m.length-2;w++){for(let I=0;I<3;I++){const x=nA(w+I,m.length);ua[0][I]=m[x][0],ua[1][I]=m[x][1],ua[2][I]=0,Qp[I]=b[x]}do Ot.generateFloorsBottomFill(i,e.id,ua,Qp,vo,h);while(i.isOverloaded())}}}function tA(e){const t=[];for(let n=0;n<e.length;n+=5)t.push([e[n],e[n+1]]);return t}function nA(e,t){return e===0?0:e%2?(e+1)/2:t-e/2}function iA(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var mu={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */mu.read=function(e,t,n,i,s){var r,o,a=s*8-i-1,l=(1<<a)-1,c=l>>1,u=-7,d=n?s-1:0,f=n?-1:1,h=e[t+d];for(d+=f,r=h&(1<<-u)-1,h>>=-u,u+=a;u>0;r=r*256+e[t+d],d+=f,u-=8);for(o=r&(1<<-u)-1,r>>=-u,u+=i;u>0;o=o*256+e[t+d],d+=f,u-=8);if(r===0)r=1-c;else{if(r===l)return o?NaN:(h?-1:1)*(1/0);o=o+Math.pow(2,i),r=r-c}return(h?-1:1)*o*Math.pow(2,r-i)},mu.write=function(e,t,n,i,s,r){var o,a,l,c=r*8-s-1,u=(1<<c)-1,d=u>>1,f=s===23?Math.pow(2,-24)-Math.pow(2,-77):0,h=i?0:r-1,g=i?1:-1,v=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=u):(o=Math.floor(Math.log(t)/Math.LN2),t*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+d>=1?t+=f/l:t+=f*Math.pow(2,1-d),t*l>=2&&(o++,l/=2),o+d>=u?(a=0,o=u):o+d>=1?(a=(t*l-1)*Math.pow(2,s),o=o+d):(a=t*Math.pow(2,d-1)*Math.pow(2,s),o=0));s>=8;e[n+h]=a&255,h+=g,a/=256,s-=8);for(o=o<<s|a,c+=s;c>0;e[n+h]=o&255,h+=g,o/=256,c-=8);e[n+h-g]|=v*128};var sA=Ie,da=mu;function Ie(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}Ie.Varint=0,Ie.Fixed64=1,Ie.Bytes=2,Ie.Fixed32=5;var yu=65536*65536,e1=1/yu,rA=12,t1=typeof TextDecoder>"u"?null:new TextDecoder("utf8");Ie.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=fa(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=i1(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=fa(this.buf,this.pos)+fa(this.buf,this.pos+4)*yu;return this.pos+=8,e},readSFixed64:function(){var e=fa(this.buf,this.pos)+i1(this.buf,this.pos+4)*yu;return this.pos+=8,e},readFloat:function(){var e=da.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=da.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,oA(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>=rA&&t1?IA(this.buf,t,e):bA(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!==Ie.Bytes)return e.push(this.readVarint(t));var n=Dn(this);for(e=e||[];this.pos<n;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==Ie.Bytes)return e.push(this.readSVarint());var t=Dn(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==Ie.Bytes)return e.push(this.readBoolean());var t=Dn(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==Ie.Bytes)return e.push(this.readFloat());var t=Dn(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==Ie.Bytes)return e.push(this.readDouble());var t=Dn(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==Ie.Bytes)return e.push(this.readFixed32());var t=Dn(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==Ie.Bytes)return e.push(this.readSFixed32());var t=Dn(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==Ie.Bytes)return e.push(this.readFixed64());var t=Dn(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==Ie.Bytes)return e.push(this.readSFixed64());var t=Dn(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=e&7;if(t===Ie.Varint)for(;this.buf[this.pos++]>127;);else if(t===Ie.Bytes)this.pos=this.readVarint()+this.pos;else if(t===Ie.Fixed32)this.pos+=4;else if(t===Ie.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),ys(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),ys(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),ys(this.buf,e&-1,this.pos),ys(this.buf,Math.floor(e*e1),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),ys(this.buf,e&-1,this.pos),ys(this.buf,Math.floor(e*e1),this.pos+4),this.pos+=8},writeVarint:function(e){if(e=+e||0,e>268435455||e<0){lA(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=MA(this.buf,e,this.pos);var n=this.pos-t;n>=128&&n1(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),da.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),da.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&&n1(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i},writeMessage:function(e,t,n){this.writeTag(e,Ie.Bytes),this.writeRawMessage(t,n)},writePackedVarint:function(e,t){t.length&&this.writeMessage(e,dA,t)},writePackedSVarint:function(e,t){t.length&&this.writeMessage(e,fA,t)},writePackedBoolean:function(e,t){t.length&&this.writeMessage(e,mA,t)},writePackedFloat:function(e,t){t.length&&this.writeMessage(e,hA,t)},writePackedDouble:function(e,t){t.length&&this.writeMessage(e,pA,t)},writePackedFixed32:function(e,t){t.length&&this.writeMessage(e,yA,t)},writePackedSFixed32:function(e,t){t.length&&this.writeMessage(e,gA,t)},writePackedFixed64:function(e,t){t.length&&this.writeMessage(e,vA,t)},writePackedSFixed64:function(e,t){t.length&&this.writeMessage(e,wA,t)},writeBytesField:function(e,t){this.writeTag(e,Ie.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,Ie.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,Ie.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,Ie.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,Ie.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,Ie.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,Ie.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,Ie.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,Ie.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,Ie.Fixed64),this.writeDouble(t)},writeBooleanField:function(e,t){this.writeVarintField(e,!!t)}};function oA(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 aA(e,s,t);throw new Error("Expected varint not more than 10 bytes")}function Dn(e){return e.type===Ie.Bytes?e.readVarint()+e.pos:e.pos+1}function aA(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function lA(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),cA(n,i,t),uA(i,t)}function cA(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 uA(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 n1(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 dA(e,t){for(var n=0;n<e.length;n++)t.writeVarint(e[n])}function fA(e,t){for(var n=0;n<e.length;n++)t.writeSVarint(e[n])}function hA(e,t){for(var n=0;n<e.length;n++)t.writeFloat(e[n])}function pA(e,t){for(var n=0;n<e.length;n++)t.writeDouble(e[n])}function mA(e,t){for(var n=0;n<e.length;n++)t.writeBoolean(e[n])}function yA(e,t){for(var n=0;n<e.length;n++)t.writeFixed32(e[n])}function gA(e,t){for(var n=0;n<e.length;n++)t.writeSFixed32(e[n])}function vA(e,t){for(var n=0;n<e.length;n++)t.writeFixed64(e[n])}function wA(e,t){for(var n=0;n<e.length;n++)t.writeSFixed64(e[n])}function fa(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function ys(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function i1(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+(e[t+3]<<24)}function bA(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 l,c,u;a===1?r<128&&(o=r):a===2?(l=e[s+1],(l&192)===128&&(o=(r&31)<<6|l&63,o<=127&&(o=null))):a===3?(l=e[s+1],c=e[s+2],(l&192)===128&&(c&192)===128&&(o=(r&15)<<12|(l&63)<<6|c&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):a===4&&(l=e[s+1],c=e[s+2],u=e[s+3],(l&192)===128&&(c&192)===128&&(u&192)===128&&(o=(r&15)<<18|(l&63)<<12|(c&63)<<6|u&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 IA(e,t,n){return t1.decode(e.subarray(t,n))}function MA(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 TA=iA(sA),SA=1,gu={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]=vu(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]]=vu(e,s&7)}return i},6:e=>null};function vu(e,t){const n=e.pbf;if(n.pos<n.length){const i=gu[t];if(!i)throw new Error(`Type ${t} is not supported`);return i(e)}}function s1(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 EA(e,t){if(!e||!e.byteLength||e.byteLength<4)throw new Error("Bad array or insufficient array length.");const n=new TA(e),i=n.readFixed32(),s=i>>24&255;if(s>SA)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 l=n.pos;n.pos=a;const c=n.readVarint(),u=new Array(c);for(let f=0;f<c;f++)u[f]=n.readString();n.pos=l;const d=n.readVarint();return vu({keys:u,pbf:n},d);case 2:{const f={keys:[],pbf:n},h=n.readFixed32(),g=s1(n),v={};for(const{key:p,type:m}of g){const b=gu[m],w=[];for(let I=0;I<h;I++)w.push(b(f));v[p]=w}return v}case 3:{const f={keys:[],pbf:n},h=n.readFixed32(),g=s1(n),v=new Array(h);for(let p=0;p<h;p++)v[p]={};for(const{key:p,type:m}of g){const b=gu[m];for(let w=0;w<h;w++)v[w][p]=b(f)}return v}default:throw new Error(`Method ${o} is not supported`)}}function r1(e){const t=new au;if(e instanceof ArrayBuffer){const s=EA(e);if(Array.isArray(s))for(const n of s){const i=n,{id:r}=i,o=im(i,["id"]);t.set(r,o)}else for(const r in s)t.set(r,s[r])}else for(const s in e)t.set(s,e[s]);return t}class AA{constructor(t){this.scope=t,this.tileLoader=new CE,this.tileAttrs=[],this.models={},this.featureStateMap=new au}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:l,isCustomZenithSource:c,modelShowHideEventsSublayers:u}=t,d=Le(o.coords),f=this.tileLoader.get(d),h=[],g=[],v=[],p={};return f.forEach(m=>{var E;const{regionId:b,metatileHash:w}=m,I=this.scope.styleManager.getStyle(t.styleId);if(!I)return;if(t.areTileBoundsVisible&&t.isDefaultSource){const T=i.getStyle(Jo).layers.find(D=>D.id==="debug-tile-bounds");Z0(s,T,t.styleState)}const x=BE(I,i,this.featureStateMap,s,t,m,r[w],this.tileAttrs,c,a,n,l,u);Object.assign(p,x.promotedObjectAttributes),h.push({regionId:b,metatileHash:w,collectorOutput:x,styleId:I.id}),v.push(...x.transferable),(E=x.debugGeoJsonData)==null||E.forEach(C=>g.push(C))}),this.scope.resetCollector(),this.scope.syncRasterSets(),Promise.resolve({results:h,transferable:v,promotedAttrs:Object.keys(p).length>0?p:void 0,geoJsonData:n?g:void 0})}deleteTiles(t){for(const n of t)this.tileLoader.delete(n)}setFeatureStateMap(t){this.featureStateMap=r1(t)}generateModel(t){const{regionId:n,metatileHash:i,styleId:s,url:r,id:o}=t,{styleManager:a}=this.scope;return new Promise(l=>{const c=this.models[o];(c?Promise.resolve(c):new Promise(d=>{aa({url:r},(f,h)=>{if(f||h.byteLength===0){const g=this.models[o]=new ArrayBuffer(0);d(g)}else this.models[o]=h,d(h)})})).then(d=>{if(d.byteLength===0){l({objects:this.scope.collector.getAccumulatedData(),textures:{isBitmap:!1,data:[]}});return}const f=this.scope.styleManager.getStyle(s);if(!f){l({objects:this.scope.collector.getAccumulatedData(),textures:{isBitmap:!1,data:[]}});return}const{objects:h,textures:g}=QE(f,a,t.styleState,this.scope.collector,d,t,this.scope.metatiles[i],n,this.featureStateMap);if(this.scope.createImageBitmap){const v=g.map(p=>{const m=new Blob([p],{type:"image/png"});return createImageBitmap(m)});Promise.all(v).then(p=>{l({objects:h,textures:{isBitmap:!0,data:p},transferable:[...h.transferable,...p]}),this.scope.resetCollector()})}else l({objects:h,textures:{isBitmap:!1,data:g},transferable:[...h.transferable,d]}),this.scope.resetCollector()})})}destroy(){this.tileLoader.destroy(),this.tileAttrs=[],this.models={}}}function xA(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 ha=.8;class _A{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*ha}extend(){const t=this.buffer.byteLength*2;this.maximum=t/this.stride,this.watermark=this.maximum*ha;const n=new ArrayBuffer(t),i=new Int32Array(n);return i.set(this.view),this.buffer=n,this.view=i,n}}class PA{constructor(t){this.offset=0,this.buffer=new Int32Array(t),this.comittedOffsets=0,this.watermark=t*ha}extend(){const t=this.buffer.length*2;this.watermark=t*ha;const n=new Int32Array(t);n.set(this.buffer),this.buffer=n}}class o1{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,l=hr(t,n);this.elements=new _A(a,l),this.indices=new PA(a*2/l),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 bt(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}bt.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},bt.prototype.packOne=function(e,t,n){var i={freebin:-1,shelf:-1,waste:1/0},s=0,r,o,a,l;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(l=0;l<this.freebins.length;l++){if(r=this.freebins[l],t===r.maxh&&e===r.maxw)return this.allocFreebin(l,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=l))}for(l=0;l<this.shelves.length;l++)if(o=this.shelves[l],s+=o.h,!(e>o.free)){if(t===o.h)return this.allocShelf(l,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=l))}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 wu(s,this.w,t),this.allocShelf(this.shelves.push(o)-1,e,t,n);if(this.autoResize){var c,u,d,f;return c=u=this.h,d=f=this.w,(d<=c||e>d)&&(f=Math.max(e,d)*2),(c<d||t>c)&&(u=Math.max(t,c)*2),this.resize(f,u),this.packOne(e,t,n)}return null},bt.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},bt.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},bt.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)}},bt.prototype.getBin=function(e){return this.bins[e]},bt.prototype.ref=function(e){if(++e.refcount===1){var t=e.h;this.stats[t]=(this.stats[t]|0)+1}return e.refcount},bt.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)},bt.prototype.clear=function(){this.shelves=[],this.freebins=[],this.stats={},this.bins={},this.maxId=0},bt.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 wu(e,t,n){this.x=0,this.y=e,this.w=this.free=t,this.h=n}wu.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 LA(n,i,this.y,e,t,e,this.h)},wu.prototype.resize=function(e){return this.free+=e-this.w,this.w=e,!0};function LA(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 CA{constructor(){this.packer=new bt(dn[0],dn[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,l=o.h*i;if(r.has(`${a}_${l}`))continue;let c=this.packer.packOne(a+2,l+2);c===null&&(this.packer=new bt(dn[0],dn[1]),this.currentAtlasIndex++,c=this.packer.packOne(a+2,l+2));const u=s.length,d={rasterSetIndex:t.index,rasterIndex:u,w:a,h:l,x:c.x+1,y:c.y+1,anchorX:t.anchorX,anchorY:t.anchorY,atlasIndex:this.currentAtlasIndex,isPacked:!0};s.push(d),this.packedRasters.push(t.index,u,d.x,d.y,d.w,d.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===Si.Static)continue;const a=o.w*i,l=o.h*i;let c=cr(s,a,!1),u;if(c===void 0)c=s.length,u={rasterSetIndex:t.index,rasterIndex:c,w:a,h:l,x:0,y:0,anchorX:0,anchorY:0,atlasIndex:this.currentAtlasIndex,isPacked:!1},s.push(u);else if(u=t.rasters[c],u.isPacked)continue;let d=this.packer.packOne(u.w+2,u.h+2);d===null&&(this.packer=new bt(dn[0],dn[1]),this.currentAtlasIndex++,d=this.packer.packOne(u.w+2,u.h+2)),u.x=d.x+1,u.y=d.y+1,u.atlasIndex=this.currentAtlasIndex,u.isPacked=!0,this.packedRasters.push(t.index,c,u.x,u.y,u.w,u.h,this.currentAtlasIndex)}}}const DA=le(2,32)-2,OA=Td(le(2,32)-1),FA=Td(le(2,32)-2);class RA{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%DA}}const a1=le(2,20),l1=["main","parser","labeling","models"],bu={};for(let e=0;e<l1.length;e++){const t=l1[e];bu[t]={min:1+e*a1,max:(e+1)*a1}}class NA{constructor(t){this.atlasPacker=new CA,this.pointIndexer=new RA,this.innerColors=new Map,this.floorHidingMap=new Map,this.usedModels=new Set,this.dataModels={},this.promotedObjectAttributes={},this.addedBuckets=[],this.labels=[],this.idIndexer=new Mb(t),this.workerName=t,this.dataModelsIndex=bu[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 l=r[a];if(l&&l.elements&&l.elements.buffer)return{elementsBuffer:l.elements.buffer.byteLength,indices:l.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}=bu[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=Mr){let o=this.buckets[t];o===void 0&&(o={},this.buckets[t]=o);let a=o[n];a===void 0&&(a=o[n]={});const l=o1.generateKey(i),c=a[l];if(c)return this.addedBuckets.push(c),c;const u=new o1(t,n,i,s,r,l);return a[l]=u,this.addedBuckets.push(u),u}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 f in t){const h=f,g=t[h];for(const v in g){const p=v,m=g[p],b=hr(h,p)/4;let w=0;for(const C in m)w+=m[C].indices.offset;if(w===0)continue;const I=[],x=new Int32Array(w*b);let E=0;for(const C in m){const T=m[C],{elements:D,indices:B,attributes:k,meta:j,objectsData:U,extents:A,maxDiag:M}=T,{view:S}=D,{buffer:L}=B;if(D.offset===0)continue;const _=E,F={};for(let O=0;O<B.offset;O++){const N=U?U[O]:null;if(N){const z=E/b;BA(N,z,F)}const R=L[O]*b;for(let z=0;z<b;z++)x[E++]=S[R+z]}I.push({attributes:k,drawMode:T.drawMode,rangeStart:_*4,rangeEnd:E*4,meta:j,objectsData:Object.keys(F).length>0?F:void 0,extents:new Float32Array(A),maxDiag:M}),T.resetOffsets(),T.resetBuildingsData(),T.resetInstancesExtents(),T.meta=void 0}n.push({symbol:h,sink:p,buffer:x.buffer,generatedObjects:I}),i.push(x.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 l=this.floorHidingMap;this.floorHidingMap=new Map,this.innerColors=new Map;const c=this.labels;this.labels=[];const u=this.promotedObjectAttributes;this.promotedObjectAttributes={};const d=this.geoJsonData.length?this.geoJsonData:void 0;return this.geoJsonData=[],{data:n,labels:c,floorHidingMap:l,packedRasters:r,rastersToLoad:o,dataModelsUrls:a,identifyIds:s,transferable:i,promotedObjectAttributes:u,debugGeoJsonData:d}}}function BA(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 kA={[$s.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}},UA=2;class Iu{constructor(t,n=!1){this.dataType=t,this.pendingRequests=new Map,this.ignoredStatusCodes=n?[204,404]:[204]}fetch(t,n,i=3,s=300){return Pe(this,null,function*(){var o;let r=0;for(;r<=i;)try{const a=yield this.fetchAttempt(t,n);if(!a.error||!Vp((o=a.error)==null?void 0:o.status))return a;throw new Error(`Fetching ${t} attempt ${r} failed.`)}catch(a){if(r>=i)return{rejected:!0};yield jp(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=Le(t),a=(this.dataType==="json"?Gp:aa)({url:s},(l,c)=>{if(this.pendingRequests.delete(r),l!==void 0){this.ignoredStatusCodes.includes(l.status)||console.error(`Failed to fetch a tile by url "${s}" Error: status "${l.status}", message: ${l.message}`),i({error:l});return}i({data:c})});this.pendingRequests.set(r,{xhr:a,resolve:i})})}}/**
 * @license
 * Copyright 2019 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */const c1=Symbol("Comlink.proxy"),zA=Symbol("Comlink.endpoint"),GA=Symbol("Comlink.releaseProxy"),Mu=Symbol("Comlink.finalizer"),pa=Symbol("Comlink.thrown"),u1=e=>typeof e=="object"&&e!==null||typeof e=="function",VA={canHandle:e=>u1(e)&&e[c1],serialize(e){const{port1:t,port2:n}=new MessageChannel;return Tu(e,t),[n,[n]]},deserialize(e){return e.start(),h1(e)}},jA={canHandle:e=>u1(e)&&pa in e,serialize({value:e}){let t;return e instanceof Error?t={isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:t={isError:!1,value:e},[t,[]]},deserialize(e){throw e.isError?Object.assign(new Error(e.value.message),e.value):e.value}},d1=new Map([["proxy",VA],["throw",jA]]);function HA(e,t){for(const n of e)if(t===n||n==="*"||n instanceof RegExp&&n.test(t))return!0;return!1}function Tu(e,t=globalThis,n=["*"]){t.addEventListener("message",function i(s){if(!s||!s.data)return;if(!HA(n,s.origin)){console.warn(`Invalid origin '${s.origin}' for comlink proxy`);return}const{id:r,type:o,path:a}=Object.assign({path:[]},s.data),l=(s.data.argumentList||[]).map(Li);let c;try{const u=a.slice(0,-1).reduce((f,h)=>f[h],e),d=a.reduce((f,h)=>f[h],e);switch(o){case"GET":c=d;break;case"SET":u[a.slice(-1)[0]]=Li(s.data.value),c=!0;break;case"APPLY":c=d.apply(u,l);break;case"CONSTRUCT":{const f=new d(...l);c=v1(f)}break;case"ENDPOINT":{const{port1:f,port2:h}=new MessageChannel;Tu(e,h),c=g1(f,[f])}break;case"RELEASE":c=void 0;break;default:return}}catch(u){c={value:u,[pa]:0}}Promise.resolve(c).catch(u=>({value:u,[pa]:0})).then(u=>{const[d,f]=va(u);t.postMessage(Object.assign(Object.assign({},d),{id:r}),f),o==="RELEASE"&&(t.removeEventListener("message",i),f1(t),Mu in e&&typeof e[Mu]=="function"&&e[Mu]())}).catch(u=>{const[d,f]=va({value:new TypeError("Unserializable return value"),[pa]:0});t.postMessage(Object.assign(Object.assign({},d),{id:r}),f)})}),t.start&&t.start()}function $A(e){return e.constructor.name==="MessagePort"}function f1(e){$A(e)&&e.close()}function h1(e,t){const n=new Map;return e.addEventListener("message",function(s){const{data:r}=s;if(!r||!r.id)return;const o=n.get(r.id);if(o)try{o(r)}finally{n.delete(r.id)}}),Su(e,n,[],t)}function ma(e){if(e)throw new Error("Proxy has been released and is not useable")}function p1(e){return gs(e,new Map,{type:"RELEASE"}).then(()=>{f1(e)})}const ya=new WeakMap,ga="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(ya.get(e)||0)-1;ya.set(e,t),t===0&&p1(e)});function YA(e,t){const n=(ya.get(t)||0)+1;ya.set(t,n),ga&&ga.register(e,t,e)}function WA(e){ga&&ga.unregister(e)}function Su(e,t,n=[],i=function(){}){let s=!1;const r=new Proxy(i,{get(o,a){if(ma(s),a===GA)return()=>{WA(r),p1(e),t.clear(),s=!0};if(a==="then"){if(n.length===0)return{then:()=>r};const l=gs(e,t,{type:"GET",path:n.map(c=>c.toString())}).then(Li);return l.then.bind(l)}return Su(e,t,[...n,a])},set(o,a,l){ma(s);const[c,u]=va(l);return gs(e,t,{type:"SET",path:[...n,a].map(d=>d.toString()),value:c},u).then(Li)},apply(o,a,l){ma(s);const c=n[n.length-1];if(c===zA)return gs(e,t,{type:"ENDPOINT"}).then(Li);if(c==="bind")return Su(e,t,n.slice(0,-1));const[u,d]=m1(l);return gs(e,t,{type:"APPLY",path:n.map(f=>f.toString()),argumentList:u},d).then(Li)},construct(o,a){ma(s);const[l,c]=m1(a);return gs(e,t,{type:"CONSTRUCT",path:n.map(u=>u.toString()),argumentList:l},c).then(Li)}});return YA(r,e),r}function ZA(e){return Array.prototype.concat.apply([],e)}function m1(e){const t=e.map(va);return[t.map(n=>n[0]),ZA(t.map(n=>n[1]))]}const y1=new WeakMap;function g1(e,t){return y1.set(e,t),e}function v1(e){return Object.assign(e,{[c1]:!0})}function va(e){for(const[t,n]of d1)if(n.canHandle(e)){const[i,s]=n.serialize(e);return[{type:"HANDLER",name:t,value:i},s]}return[{type:"RAW",value:e},y1.get(e)||[]]}function Li(e){switch(e.type){case"HANDLER":return d1.get(e.name).deserialize(e.value);case"RAW":return e.value}}function gs(e,t,n,i){return new Promise(s=>{const r=XA();t.set(r,s),e.start&&e.start(),e.postMessage(Object.assign({id:r},n),i)})}function XA(){return new Array(4).fill(0).map(()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16)).join("-")}var ii=(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))(ii||{}),gr=(e=>(e[e.FunctionUse=0]="FunctionUse",e[e.FunctionResult=1]="FunctionResult",e))(gr||{});class qA extends hl{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:ii.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:ii.Main,msg:t};n.postMessage(s)})}routeMessage(t){const{from:n,to:i,transferable:s,msg:{type:r}}=t;if(i===ii.Main)this.emit("message",t);else if(i===ii.All)n!==ii.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 JA extends hl{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:ii.All,msg:t};this.worker.postMessage(n)}}class KA{constructor(t){this.onMessage=n=>{const{from:i,msg:s}=n;switch(s.type){case gr.FunctionUse:this.onFunctionUse(s,i);break;case gr.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:gr.FunctionUse,data:{id:r,name:n,args:s,subids:i}};let a;return i?a=i.map(l=>new Promise(c=>{this.pendingFunctions.set(String(r)+`-${l}`,c)})):a=new Promise(l=>{this.pendingFunctions.set(String(r),l)}),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)&&w1(a[0]))for(let l=0;l<a.length;l++)Promise.resolve(a[l]).then(c=>{this.sendFunctionResult(n,r,c,l)});else a&&w1(a)?Promise.resolve(a).then(l=>this.sendFunctionResult(n,r,l)):this.sendFunctionResult(n,r,a)}else console.error(`FnRegistry#onFunctionUse: function ${i} not found`)}sendFunctionResult(t,n,i,s){const r={type:gr.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 w1(e){return typeof e=="object"&&typeof e.then=="function"}class QA{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 l{constructor(...d){this.id=r.idCounter++,r.fnRegistry.get(a,"createClass")({id:this.id,args:d,name:t})}}return Object.getOwnPropertyNames(n.prototype).forEach(u=>{u!=="constructor"&&typeof n.prototype[u]=="function"&&(l.prototype[u]=function(...d){const f=s&&s.includes(u)&&Array.isArray(d[0])?[...Array(d[0].length).keys()].map(h=>h):void 0;return r.fnRegistry.get(a,"classMethodUse",f)({id:this.id,name:t,method:u,args:d})})}),l}}}}const ex={point:{point:!0,heatmap:!0,gltfModel:!0,metricPoint:!0},polygon:{polygon:!0,polygonExtrusion:!0,mesh:!0,embankment:!0,polygon3d:!0,overpass:!0,gltfModel:!0},line:{line:!0,lineExtrusion:!0,labelLine:!0,dashedLine:!0,oneWayLine:!0,metricPoint:!0,overpass:!0}};function tx(e,t){return!!ex[e][t]}function nx(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 Eu(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 ix(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 b1(e,t){const n=Eu([e[0][0],e[1][0]],t),i=Eu([e[0][1],e[1][1]],t),s=Eu([e[0][2],e[1][2]],t);n.forEach(r=>i.forEach(o=>s.forEach(a=>{ix(e,r,o,a)})))}function I1(e){const t=["GEOJSON_METATILE_UNKNOWN_SUBLAYER","Commercial_poi_default","Commercial_poi_city","Commercial_poi_premium","Commercial_model","Commercial_model_animated","Commercial_model_on_click","Immersive_model","Immersive_model_multipart","Animated_immersive_model"],n=Array.from(new Set([...t,...e])).filter(i=>typeof i=="string"&&i.length>0);return qd(["id","db_label","db_label2","selected","hovered","componentDistanceStart","componentDistanceEnd","objectLength","beginningIsCut","endingIsCut","db_geometry_type","db_plan_id"],n)}function Au(e,t,n,i,s=2){const r=s+2;let o=i;const a=n-t>>1;let l=n-t,c;const u=e[t],d=e[t+1],f=e[n],h=e[n+1];for(let g=t+r;g<n;g+=r){const v=sx(e[g],e[g+1],u,d,f,h);if(v>o)c=g,o=v;else if(v===o){const p=Math.abs(g-a);p<l&&(c=g,l=p)}}o>i&&(c-t>r&&Au(e,t,c,i,s),e[c+2]=o,n-c>r&&Au(e,c,n,i,s))}function sx(e,t,n,i,s,r){let o=s-n,a=r-i;if(o!==0||a!==0){const l=((e-n)*o+(t-i)*a)/(o*o+a*a);l>1?(n=s,i=r):l>0&&(n+=o*l,i+=a*l)}return o=e-n,a=t-i,o*o+a*a}function vr(e,t,n,i,s,r=4){const o={id:e==null?null:e,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")wa(o,n,r);else if(t==="Polygon")wa(o,n[0],r);else if(t==="MultiLineString")for(const a of n)wa(o,a,r);else if(t==="MultiPolygon")for(const a of n)wa(o,a[0],r);return o}function wa(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 rx(e,t){const n=[];if(e.type==="FeatureCollection")for(let i=0;i<e.features.length;i++)ba(n,e.features[i],t,i);else e.type==="Feature"?ba(n,e,t,0):ba(n,{geometry:e},t,0);return n}function ba(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=[],l=t.id;if(n.promoteId?l=t.properties[n.promoteId]:n.generateId&&(l=i||0),r==="Point")M1(s,a,n.dimensions);else if(r==="MultiPoint")for(const c of s)M1(c,a,n.dimensions);else if(r==="LineString")xu(s,a,o,!1,n.dimensions);else if(r==="MultiLineString")if(n.lineMetrics){for(const c of s)a=[],xu(c,a,o,!1,n.dimensions),e.push(vr(l,"LineString",a,t.properties,i,n.dimensions+2));return}else _u(s,a,o,!1,n.dimensions);else if(r==="Polygon")_u(s,a,o,!0,n.dimensions);else if(r==="MultiPolygon")for(const c of s){const u=[];_u(c,u,o,!0,n.dimensions),a.push(u)}else if(r==="GeometryCollection"){for(const c of t.geometry.geometries)ba(e,{id:l,geometry:c,properties:t.properties},n,i);return}else throw new Error("Input data is not a valid GeoJSON object.");e.push(vr(l,r,a,t.properties,i,n.dimensions+2))}function M1(e,t,n=2){t.push(T1(e[0]),S1(e[1]),0,1);for(let i=2;i<n;i++)t.push(e[i])}function xu(e,t,n,i,s=2){let r,o,a=0;for(let c=0;c<e.length;c++){const u=T1(e[c][0]),d=S1(e[c][1]);t.push(u,d,0,1);for(let f=2;f<s;f++)t.push(e[c][f]);c>0&&(i?a+=(r*d-u*o)/2:a+=Math.sqrt(Math.pow(u-r,2)+Math.pow(d-o,2))),r=u,o=d}const l=t.length-(s+2);t[2]=1,Au(t,0,l,n,s),t[l+2]=1,t.size=Math.abs(a),t.start=0,t.end=t.size}function _u(e,t,n,i,s=2){for(let r=0;r<e.length;r++){const o=[];xu(e[r],o,n,i,s),t.push(o)}}function T1(e){return e/360+.5}function S1(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 On(e,t,n,i,s,r,o,a){const l=(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 c=[];for(const u of e){const d=u.geometry;let f=u.type;const h=s===0?u.minX:u.minY,g=s===0?u.maxX:u.maxY;if(h>=n&&g<i){c.push(u);continue}else if(g<n||h>=i)continue;let v=[];if(f==="Point"||f==="MultiPoint")ox(d,v,n,i,s,l);else if(f==="LineString")E1(d,v,n,i,s,!1,a.lineMetrics,l);else if(f==="MultiLineString")Pu(d,v,n,i,s,!1,l);else if(f==="Polygon")Pu(d,v,n,i,s,!0,l);else if(f==="MultiPolygon")for(const p of d){const m=[];Pu(p,m,n,i,s,!0,l),m.length&&v.push(m)}if(v.length){if(a.lineMetrics&&f==="LineString"){for(const p of v)c.push(vr(u.id,f,p,u.tags,u.index,l));continue}(f==="LineString"||f==="MultiLineString")&&(v.length===1?(f="LineString",v=v[0]):f="MultiLineString"),(f==="Point"||f==="MultiPoint")&&(f=v.length===l?"Point":"MultiPoint"),c.push(vr(u.id,f,v,u.tags,u.index,l))}}return c.length?c:null}function ox(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){vs(t,e[o],e[o+1],e[o+2]);for(let l=3;l<r;l++)t.push(e[o+l])}}}function E1(e,t,n,i,s,r,o,a=4){let l=A1(e);const c=s===0?ax:lx;let u=e.start,d,f;for(let b=0;b<e.length-a;b+=a){const w=e[b],I=e[b+1],x=e[b+2],E=e[b+a],C=e[b+a+1],T=s===0?w:I,D=s===0?E:C;let B=!1;if(o&&(d=Math.sqrt(Math.pow(w-E,2)+Math.pow(I-C,2))),T<n){if(D>n){f=c(l,w,I,E,C,n),l.push(0);for(let k=4;k<a;k++){const j=e[b+k];l.push((e[b+a+k]-j)*f+j)}o&&(l.start=u+d*f)}}else if(T>i){if(D<i){f=c(l,w,I,E,C,i),l.push(0);for(let k=4;k<a;k++){const j=e[b+k];l.push((e[b+a+k]-j)*f+j)}o&&(l.start=u+d*f)}}else{vs(l,w,I,x);for(let k=3;k<a;k++)l.push(e[b+k])}if(D<n&&T>=n){f=c(l,w,I,E,C,n),l.push(0);for(let k=4;k<a;k++){const j=e[b+k];l.push((e[b+a+k]-j)*f+j)}B=!0}if(D>i&&T<=i){f=c(l,w,I,E,C,i),l.push(0);for(let k=4;k<a;k++){const j=e[b+k];l.push((e[b+a+k]-j)*f+j)}B=!0}!r&&B&&(o&&(l.end=u+d*f),t.push(l),l=A1(e)),o&&(u+=d)}let h=e.length-a;const g=e[h],v=e[h+1],p=e[h+2],m=s===0?g:v;if(m>=n&&m<=i){vs(l,g,v,p);for(let b=3;b<a;b++)l.push(e[h+b])}if(h=l.length-a,r&&h>=3&&(l[h]!==l[0]||l[h+1]!==l[1])){vs(l,l[0],l[1],l[2]);for(let b=3;b<a;b++)l.push(l[b])}l.length&&t.push(l)}function A1(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function Pu(e,t,n,i,s,r,o){for(const a of e)E1(a,t,n,i,s,r,!1,o)}function vs(e,t,n,i){e.push(t,n,i)}function ax(e,t,n,i,s,r){const o=(r-t)/(i-t);return vs(e,r,n+(s-n)*o,1),o}function lx(e,t,n,i,s,r){const o=(r-n)/(s-n);return vs(e,t+(i-t)*o,r,1),o}function cx(e,t){const n=t.buffer/t.extent,i=t.dimensions+2;let s=e;const r=On(e,1,-1-n,n,0,-1,2,t),o=On(e,1,1-n,2+n,0,-1,2,t);return(r||o)&&(s=On(e,1,-n,1+n,0,-1,2,t)||[],r&&(s=x1(r,1,i).concat(s)),o&&(s=s.concat(x1(o,-1,i)))),s}function x1(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=Lu(r.geometry,t,n);else if(o==="MultiLineString"||o==="Polygon"){a=[];for(const l of r.geometry)a.push(Lu(l,t,n))}else if(o==="MultiPolygon"){a=[];for(const l of r.geometry){const c=[];for(const u of l)c.push(Lu(u,t,n));a.push(c)}}i.push(vr(r.id,o,a,r.tags,r.index,n))}return i}function Lu(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 _1(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,l=o.type;o.geometry=[];const c=n.cuts&&l!==1?1:0,u=n.dimensions+c;if(l===1)for(let d=0;d<a.length;d+=u)o.geometry.push(L1(a,d,u,t,i,s,r));else if(l===2)o.geometry=P1(a,t,i,s,r,u);else for(let d=0;d<a.length;d++)o.geometry.push(P1(a[d],t,i,s,r,u))}return e.transformed=!0,e}function P1(e,t,n,i,s,r=3){const o=[];for(let a=0;a<e.length;a++){const l=[];for(let c=0;c<e[a].length;c+=r)l.push(L1(e[a],c,r,t,n,i,s));o.push(l)}return o}function L1(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 l=2;l<n;l++)a.push(e[t+l]);return a}function ux(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)dx(o,a,r,s);return o}function dx(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 l=0;l<s.length;l+=o){a.push(s[l],s[l+1]);for(let c=4;c<o;c++)a.push(s[l+c]);e.numPoints++,e.numSimplified++}else if(r==="LineString")Cu(a,s,e,n,!1,!1,i);else if(r==="MultiLineString"||r==="Polygon"){for(let l=0;l<s.length;l++)Cu(a,s[l],e,n,r==="Polygon",l===0,i);r==="Polygon"&&a.length&&(a=[a])}else if(r==="MultiPolygon")for(let l=0;l<s.length;l++){const c=s[l],u=[];for(let d=0;d<c.length;d++)Cu(u,c[d],e,n,!0,d===0,i);u.length&&a.push(u)}if(a.length){let l=t.tags||null;if(r==="LineString"&&i.lineMetrics){l={};for(const u in t.tags)l[u]=t.tags[u];l.mapbox_clip_start=s.start/s.size,l.mapbox_clip_end=s.end/s.size}const c={geometry:a,type:r==="Polygon"||r==="MultiPolygon"?3:r==="LineString"||r==="MultiLineString"?2:1,tags:l};t.id!==null&&(c.id=t.id),i.generateIndex&&(c.index=t.index),e.features.push(c)}}function Cu(e,t,n,i,s,r,o){const a=i*i,l=o&&!!o.cuts,c=o.dimensions+2;if(i>0&&t.size<(s?a:i)){n.numPoints+=t.length/c;return}const u=[];for(let d=0;d<t.length;d+=c){if(i===0||t[d+2]>a){n.numSimplified++,u.push(t[d],t[d+1]);for(let f=4;f<c;f++)u.push(t[d+f]);l&&u.push(t[d+3])}n.numPoints++}s&&fx(u,r,c-(l?1:2)),e.push(u)}function fx(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],l=r-s-(n-o);e[s+o]=e[l],e[l]=a}return e}const hx={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 px{constructor(t,n){n=this.options=mx(Object.create(hx),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=rx(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=cx(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 l=[t,n,i,s],c=this.options,u=c.debug;for(;l.length;){s=l.pop(),i=l.pop(),n=l.pop(),t=l.pop();const d=1<<n,f=Du(n,i,s);let h=this.tiles[f];if(!h&&(u>1&&console.time("creation"),h=this.tiles[f]=ux(t,n,i,s,c),this.tileCoords.push({z:n,x:i,y:s}),u)){u>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 T=`z${n}`;this.stats[T]=(this.stats[T]||0)+1,this.total++}if(h.source=t,r==null){if(n===c.indexMaxZoom||h.numPoints<=c.indexMaxPoints)continue}else{if(n===c.maxZoom||n===r)continue;if(r!=null){const T=r-n;if(i!==o>>T||s!==a>>T)continue}}if(h.source=null,t.length===0)continue;u>1&&console.time("clipping");const g=.5*c.buffer/c.extent,v=.5-g,p=.5+g,m=1+g;let b=null,w=null,I=null,x=null,E=On(t,d,i-g,i+p,0,h.minX,h.maxX,c),C=On(t,d,i+v,i+m,0,h.minX,h.maxX,c);t=null,E&&(b=On(E,d,s-g,s+p,1,h.minY,h.maxY,c),w=On(E,d,s+v,s+m,1,h.minY,h.maxY,c),E=null),C&&(I=On(C,d,s-g,s+p,1,h.minY,h.maxY,c),x=On(C,d,s+v,s+m,1,h.minY,h.maxY,c),C=null),u>1&&console.timeEnd("clipping"),l.push(b||[],n+1,i*2,s*2),l.push(w||[],n+1,i*2,s*2+1),l.push(I||[],n+1,i*2+1,s*2),l.push(x||[],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 l=Du(t,n,i);if(this.tiles[l])return _1(this.tiles[l],r,s);o>1&&console.log("drilling down to z%d-%d-%d",t,n,i);let c=t,u=n,d=i,f;for(;!f&&c>0;)c--,u=u>>1,d=d>>1,f=this.tiles[Du(c,u,d)];return!f||!f.source?null:(o>1&&(console.log("found parent tile z%d-%d-%d",c,u,d),console.time("drilling down")),this.splitTile(f.source,c,u,d,t,n,i),o>1&&console.timeEnd("drilling down"),this.tiles[l]?_1(this.tiles[l],r,s):null)}}function Du(e,t,n){return((1<<e)*n+t)*32+e}function mx(e,t){for(const n in t)e[n]=t[n];return e}function yx(e,t){return new px(e,t)}function gx(e){const t=gt(e),n=oe.scaleFactor(Ns(0,0,t)[1]),i=oe.scaleFactor(Ns(0,ne,t)[1]);return{min:n,max:i,range:i-n}}function vx(e,t,n,i){const s=[];return e.geometry.forEach(r=>{const o=[],a=[],l=[];r.forEach(f=>{l.push(...Tx(f,t)),o.length&&a.push(o.length),o.push(...f)});const c=[];for(let f=0;f<o.length;f++)for(let h=0;h<n;h++)c.push(o[f][h]);const u=Jr(c,a,n),d=new Array(n);for(let f=0;f<u.length;f+=3){const h=[];for(let g=0;g<n+1;g++)h.push([]);for(let g=0;g<3;g++)Ou(d,o[u[f+2-g]],t,i),h[0][g]=d[0],h[1][g]=d[1],h[2][g]=0,n>2&&(h[3][g]=d[2]),n>3&&(h[4][g]=d[3]);l.forEach(g=>{const v=[[],[],[]];g.forEach((p,m)=>{v[0][m]=p[0],v[1][m]=p[1]}),b1(h,v)}),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 wx(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,l)=>{Ou(s,a,t,i),o[0][l]=s[0],o[1][l]=s[1],n>2&&(o[2][l]=s[2]),n>3&&(o[3][l]=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 bx(e,t,n,i){const s=Array(n);return e.geometry.map(r=>{var a;Ou(s,r,t,i);const o={x:[s[0]],y:[s[1]],z:n>2?[(a=s[2])!=null?a: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 Ou(e,t,n,i){const s=C1(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]*ve*r,t[3]!==void 0&&(e[3]=t[3]*ve*r)}function C1(e,t){return[xe(e[0]/t*ne,0,ne),xe((t-e[1])/t*ne,0,ne)]}function Ix(e,t){return e[0]<0||e[0]>t||e[1]<0||e[1]>t}function Mx(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 Tx(e,t){const n=[];let i=[];for(let s=0;s<e.length;s++){const r=e[s];if(i.push(C1(r,t)),!Ix(r,t))continue;const o=e[s+1];if(!o)break;Mx(r,o,t)&&(i.length>1&&n.push(i),i=[])}return i.length>1&&n.push(i),n}const D1=4096,O1=2,ws={maxZoom:kp,tolerance:3,extent:D1,buffer:1,debug:0,lineMetrics:!1,promoteId:null,generateId:!1,generateIndex:!0,indexMaxZoom:0,indexMaxPoints:1e5,dimensions:O1};class Fu{constructor(t){this.options=t}get geoJsonVtInstance(){var t,n,i,s,r;return this.geoJsonVT||(this.geoJsonVT=yx(this.options.data,Me(he({},ws),{maxZoom:(t=this.options.maxZoom)!=null?t:ws.maxZoom,dimensions:(n=this.options.dimensions)!=null?n:ws.dimensions,extent:(i=this.options.extent)!=null?i:ws.extent,buffer:(s=this.options.buffer)!=null?s:ws.buffer,promoteId:this.options.promoteId,tolerance:(r=this.options.tolerance)!=null?r:ws.tolerance}))),this.geoJsonVT}fetchTile(t){var u,d;const[n,i,s]=Wr(t),r={components:[],byId:new Map},o=this.geoJsonVtInstance.getTile(s,n,i),a=(u=this.options.dimensions)!=null?u:O1,l=(d=this.options.extent)!=null?d:D1,c=gx(t);if(!o)return Promise.resolve(r);for(const f of o.features)switch(f.type){case 1:r.components=r.components.concat(bx(f,l,a,c));break;case 2:r.components=r.components.concat(wx(f,l,a,c));break;case 3:r.components=r.components.concat(vx(f,l,a,c));break;default:console.warn("unsupported type ",o);break}return Promise.resolve(r)}destroy(){this.geoJsonVT=void 0}}function Sx(e,t,n){const i={components:[],byId:new Map};return e.features.forEach((s,r)=>{i.components.push(...F1(s.geometry,t).map(o=>Me(he({},o),{index:r,id:s.id,tags:s.properties||{}})))}),i}function F1(e,t,n){switch(e.type){case"GeometryCollection":{let i=[];return e.geometries.forEach(s=>{i=i.concat(F1(s,t))}),i}case"Point":case"MultiPoint":return Ex(e,t);case"LineString":case"MultiLineString":return Ax(e,t);case"Polygon":case"MultiPolygon":return xx(e,t)}}function Ex(e,t){return e.type==="Point"?[R1(e.coordinates,t)]:e.coordinates.map(n=>R1(n,t))}function Ax(e,t){return e.type==="LineString"?[N1(e.coordinates,t)]:e.coordinates.map(n=>N1(n,t))}function xx(e,t,n){return e.type==="Polygon"?B1(e.coordinates,t):e.coordinates.reduce((i,s)=>i.concat(B1(s,t)),[])}function R1(e,t){const n=[0,0,0];return Lt(n,oe.fromGeo(e),t),{type:"point",vertices:{x:[n[0]],y:[n[1]]}}}function N1(e,t){const n=[[],[]],i=[0,0,0];return e.forEach((s,r)=>{Lt(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 B1(e,t,n){const i=[],s=[],r=[],o=[],a=[];e.forEach(u=>{const d=u.map(f=>(Lt(a,oe.fromGeo(f),t),[xe(a[0],0,ne),xe(a[1],0,ne)]));o.push(d),s.length&&r.push(s.length),s.push(...d)});const l=[];for(let u=0;u<s.length;u++)l.push(s[u][0]),l.push(s[u][1]);const c=Jr(l,r);for(let u=0;u<c.length;u+=3){const d=[[],[],[],[]];for(let h=0;h<3;h++)d[0][h]=s[c[u+h]][0],d[1][h]=s[c[u+h]][1],d[2][h]=0,d[3][h]=s[c[u+h]][2];o.forEach(h=>{const g=[[],[],[]];h.forEach((v,p)=>{g[0][p]=v[0],g[1][p]=v[1]}),b1(d,g)});const f={type:"polygon",vertices:{x:d[0],y:d[1],cut:d[2]}};i.push(f)}return i}class Ia{constructor(t){this.tileLoader=new Iu("json",t.ignoreMissingTiles),this.options=t,this.url=n=>{const i=this.options.flipY?n:Wr(n);return Fs(this.options.url,{x:i[0].toString(),y:i[1].toString(),z:i[2].toString(),subdomain:of(i)})}}fetchTile(t){return this.tileLoader.fetch(t,this.url).then(n=>n.data?Sx(n.data,gt(t)):{components:[],byId:new Map})}abortTile(t){this.tileLoader.abortRequests([Le(t)])}destroy(){this.tileLoader.destroy()}}const k1=4;class _x{constructor(t,n,i,s){this.scope=t,this.options=n,this.id=i,this.featureStateMap=new au,t.sources[i]=this,this.tileData={},this.styleManager=t.styleManager,this.collector=t.collector,this.sourceAttrs=this.options.attributes||{},this.metatile=I1(s),this.tileServer="url"in n?new Ia(n):new Fu(n)}fetchTiles(t){const n=[];for(const i of t)n.push(this.fetchTile(i));return n}abortTileFetches(t){if(this.tileServer instanceof Ia)for(const n of t)this.tileServer.abortTile(n)}generateTile(t,n,i,s,r,o,a,l){const c=Le(n),u=this.tileData[c],d=gt(n),f=[],h=[],g=this.styleManager.getStyle(i),v=new Set(s),{promoteId:p}=this.options,m={},b="generateId"in this.options?this.options.generateId:!1;if(!g)return Promise.resolve({results:f,transferable:h});u&&u.components.forEach((E,C)=>{const{tileProps:T}=this.metatile,D=[],B=[];if(E.tags){const O=Object.keys(E.tags);Vi(this.metatile,O);for(const N of O)D[T[N]]=E.tags[N]}const k=Object.keys(this.sourceAttrs);Vi(this.metatile,k);const j=Array.from(this.featureStateMap.featureAttrs);Vi(this.metatile,j);for(const O of k)D[T[O]]=this.sourceAttrs[O];const U=D[T.db_hidden_by_plan_id];if(U&&(t._activeFloorIds.includes(U)||t._backgroundFloorIds.includes(U)))return;const A=b?String(E.index+this.id*le(2,32)):p?D[T[p]]:void 0;if(A!==void 0){const O=v.has(A);if(D[T.selected]=O?1:0,u.byId.set(A,C),m[A]=E.index,this.featureStateMap.featureAttrs.size>0){const N=A!==void 0&&this.featureStateMap.get(A);if(N)for(const R of this.featureStateMap.featureAttrs)this.featureStateMap.clearAttrs=!1,B[T[R]]=N[R];else if(this.featureStateMap.clearAttrs===!1){this.featureStateMap.clearAttrs=!0;for(const R in T)B[T[R]]!==void 0&&(B[T[R]]=void 0)}}}const{coords:M}=d,S=M[3],L=Nl(r),_=Ys(t,this.sourceAttrs,T,D,B,A,d),F=this.styleManager.getLayers(g.id,T,D).filter(O=>tx(E.type,O.type)&&H(O.filter,_)&&(a?H(a,_):!0));if(F.length===0&&_.id&&this.collector.idIndexer.addOrphanId(_.id),D[T.db_geometry_type]=E.type==="line"?"polyline":E.type,(E.type==="point"||E.type==="line")&&(D[T.db_label]===void 0&&(D[T.db_label]=NaN),D[T.db_label2]===void 0&&(D[T.db_label2]=NaN)),E.type==="line"){const O=nx(E);D[T.componentDistanceStart]=0,D[T.componentDistanceEnd]=O,D[T.objectLength]=O,typeof D[T.beginningIsCut]!="number"&&(D[T.beginningIsCut]=0),typeof D[T.endingIsCut]!="number"&&(D[T.endingIsCut]=0)}zc(this.collector,g,F,_,this.metatile,k1,S,this.id,d,L,E.vertices,void 0,o,l)});const w=this.collector.getAccumulatedData(),I={regionId:0,metatileHash:Hu,collectorOutput:w,styleId:g.id};Object.keys(m).length>0&&(I.idToIndex=m),f.push(I),h.push(...w.transferable),this.scope.debouncedResetCollector(),this.scope.syncNewRasterSets();const x={results:f,transferable:h};return Promise.resolve(x)}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[Le(n)]}setSourceAttrs(t){this.sourceAttrs=t}destroy(){delete this.scope.sources[this.id],this.tileData={},this.sourceAttrs={},this.tileServer.destroy()}setFeatureStateMap(t){this.featureStateMap=r1(t)}setData(t){if(typeof t=="string"){if(this.tileServer instanceof Ia)return this.tileServer.destroy(),this.options=Me(he({},this.options),{url:t}),this.tileServer=new Ia(this.options),this.tileData={},Promise.resolve(!0)}else if(this.tileServer instanceof Fu)return this.tileServer.destroy(),this.options=Me(he({},this.options),{data:t}),this.tileServer=new Fu(this.options),this.tileData={},Promise.resolve(!0);return Promise.resolve(!1)}fetchTile(t){const n=Le(t);return this.tileData[n]?Promise.resolve(this.tileData[n]):this.tileServer.fetchTile(t).then(i=>(this.tileData[n]=i,i))}}function Px(e,t){var n,i,s;return{path:t,extensions:e.extensions,extensionsRequired:(n=e.extensionsRequired)!=null?n:[],extensionsUsed:(i=e.extensionsUsed)!=null?i:[],extras:e.extras,accessors:Cx(e.accessors),buffers:Ox(e.buffers),bufferViews:Fx(e.bufferViews),cameras:Rx(e.cameras),scene:(s=e.scene)!=null?s:0,scenes:kx(e.scenes),nodes:Ux(e.nodes),materials:Bx(e.materials),meshes:Nx(e.meshes),asset:Lx(e.asset),animations:Dx(e.animations),images:zx(e.images),textures:Gx(e.textures),samplers:Vx(e.samplers),skins:jx(e.skins)}}function Lx(e){return{copyright:e.copyright,generator:e.generator,version:e.version,minVersion:e.minVersion}}function Cx(e=[]){return e.map(t=>{var n;return{bufferView:t.bufferView,byteOffset:(n=t.byteOffset)!=null?n: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 Dx(e=[]){return e.map(t=>({channels:t.channels,samplers:t.samplers,name:t.name,extensions:t.extensions,extras:t.extras}))}function Ox(e=[]){return e.map(t=>({uri:t.uri,byteLength:t.byteLength,name:t.name,extensions:t.extensions,extras:t.extras,buffer:void 0}))}function Fx(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 Rx(e=[]){return e.map(t=>({type:t.type,orthographic:t.orthographic,perspective:t.perspective,name:t.name,extensions:t.extensions,extras:t.extras}))}function Nx(e=[]){return e.map(t=>({primitives:t.primitives,name:t.name,weights:t.weights,extensions:t.extensions,extras:t.extras}))}function Bx(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 kx(e=[]){return e.map(t=>({nodes:t.nodes,extensions:t.extensions,extras:t.extras,name:t.name}))}function Ux(e=[]){return e.map(t=>{var r,o,a;const n=(r=t.rotation)!=null?r:[0,0,0,1],i=(o=t.scale)!=null?o:[1,1,1],s=(a=t.translation)!=null?a:[0,0,0];return{camera:t.camera,children:t.children,matrix:t.matrix?Pm(...t.matrix):void 0,rotation:oy(...n),scale:at(...i),translation:at(...s),name:t.name,mesh:t.mesh,skin:t.skin,extras:t.extras,extensions:t.extensions}})}function zx(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 Gx(e=[]){return e.map(t=>({extensions:t.extensions,extras:t.extras,name:t.name,sampler:t.sampler,source:t.source}))}function Vx(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 jx(e=[]){return e.map(t=>({joints:t.joints,extensions:t.extensions,extras:t.extras,inverseBindMatrices:t.inverseBindMatrices,name:t.name,skeleton:t.skeleton}))}const wr={JPEG:"image/jpeg",PNG:"image/png",GLTEXTURE:"image/texture"};function U1(e){return e.substring(0,e.lastIndexOf("/")+1)}function Hx(e){if(e.startsWith("data:image"))return e.split(";")[0].split(":")[1];switch(e.substring(e.lastIndexOf("."))){case".png":return wr.PNG;case".jpg":case".jpeg":default:return wr.JPEG}}function z1(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 je=class je{constructor(t){this.data=t}static isGlb(t){const n=new Uint32Array(t,0,je.glbHeaderInts),i=n[0],s=n[1];return i===this.glbMagic&&s===this.glbVersion}extractGlbData(){if(this.getCheckedGlbInfo()===void 0)return{json:Bu,buffers:[]};let n;const i=[],s=this.getAllChunkInfos();for(const r of s)r.type===je.jsonChunkType&&!n?n=this.getJsonFromChunk(r):r.type===je.binaryChunkType&&i.push(this.getBufferFromChunk(r));return{json:n||Bu,buffers:i}}getCheckedGlbInfo(){const t=new Uint32Array(this.data,0,je.glbHeaderInts),n=t[0],i=t[1],s=t[2];if(!(!this.checkEquality(n,je.glbMagic,"glb magic")||!this.checkEquality(i,je.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=je.glbHeaderInts*4;for(;n<this.data.byteLength;){const i=this.getChunkInfo(n);t.push(i),n+=i.length+je.glbChunkHeaderInts*4}return t}getChunkInfo(t){const n=new Uint32Array(this.data,t,je.glbChunkHeaderInts),i=t+je.glbChunkHeaderInts*4,s=n[0],r=n[1];return{start:i,length:s,type:r}}getJsonFromChunk(t){const n=t.length,i=(je.glbHeaderInts+je.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)}};je.glbHeaderInts=3,je.glbChunkHeaderInts=2,je.glbMagic=1179937895,je.glbVersion=2,je.jsonChunkType=1313821514,je.binaryChunkType=5130562;let Ma=je;const G1=5120,$x=5121,Yx=5122,Wx=5123,Zx=5124,V1=5125,Xx=5126,qx=4,Jx="draco_decoder_gltf.js",Kx="draco_wasm_wrapper_gltf.js",j1="draco_decoder_gltf.wasm";let Ru;function Qx(e){Ru=n_(e).catch(t=>{const n="Draco decoder module failed to initialize"+(t!=null&&t.message?` with the following error: ${t.message}`:".");throw new Error(n)})}function e_(e){return Pe(this,null,function*(){let t=yield 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})}function t_(e){return Pe(this,null,function*(){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;"))})}function n_(e){return Pe(this,null,function*(){if(typeof WebAssembly!="object"){const t=yield e_(`${e}/${Jx}`);return new Function(t)()()}else return t_(`${e}/${Kx}`).then(t=>{const n=new Function(t)();return fetch(`${e}/${j1}`).then(i=>i.arrayBuffer()).then(i=>n({wasmBinary:i,wasmBinaryFile:j1}))})})}function i_(e){switch(e){case G1:return"Int8Array";case $x:return"Uint8Array";case Yx:return"Int16Array";case Wx:return"Uint16Array";case Zx:return"Int32Array";case V1:return"Uint32Array";case Xx:return"Float32Array";default:return"Float32Array"}}function s_(e,t,n,i,s,r){const o=s.num_components(),l=n.num_points()*o;let c,u,d;switch(r){case"Float32Array":d=l*4,c=e._malloc(d),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_FLOAT32,d,c),u=new Float32Array(e.HEAPF32.buffer,c,l).slice(),e._free(c);break;case"Int8Array":c=e._malloc(l),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_INT8,l,c),u=new Int8Array(e.HEAP8.buffer,c,l).slice(),e._free(c);break;case"Int16Array":d=l*2,c=e._malloc(d),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_INT16,d,c),u=new Int16Array(e.HEAP16.buffer,c,l).slice(),e._free(c);break;case"Int32Array":d=l*4,c=e._malloc(d),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_INT32,d,c),u=new Int32Array(e.HEAP32.buffer,c,l).slice(),e._free(c);break;case"Uint8Array":c=e._malloc(l),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_UINT8,l,c),u=new Uint8Array(e.HEAPU8.buffer,c,l).slice(),e._free(c);break;case"Uint16Array":d=l*2,c=e._malloc(d),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_UINT16,d,c),u=new Uint16Array(e.HEAPU16.buffer,c,l).slice(),e._free(c);break;case"Uint32Array":d=l*4,c=e._malloc(d),t.GetAttributeDataArrayForAllPoints(n,s,e.DT_UINT32,d,c),u=new Uint32Array(e.HEAPU32.buffer,c,l).slice(),e._free(c);break;default:throw new Error("DRACOLoader: Unexpected attribute type.")}return{name:i,array:u,itemSize:o,componentType:r}}function r_(e,t,n,i,s,r){let o,a;const l=t.GetEncodedGeometryType(n);if(l===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 c={index:null,attributes:{}},u=o.num_points();for(const d in i){let f=G1,h;for(const[p,m]of Object.entries(r))if(p===d){f=s.accessors[m].componentType,h=s.accessors[m].count;break}if(u!==h)throw new Error(`DRACOLoader: Accessor vertex count ${h} does not match draco decoder vertex count  ${u}`);f=i_(f);const g=t.GetAttributeByUniqueId(o,i[d]),v=s_(e,t,o,d,g,f);c.attributes[v.name]=v}if(l===e.TRIANGULAR_MESH){const f=o.num_faces()*3,h=f*4,g=e._malloc(h);t.GetTrianglesUInt32Array(o,h,g);const v=new Uint32Array(e.HEAPU32.buffer,g,f).slice();e._free(g),c.index={array:v,itemSize:1}}return e.destroy(o),c}function o_(e,t,n,i){const s=e.bufferView,r=t.bufferViews[s],o=t.buffers[r.buffer],l=new Int8Array(o.buffer).slice(r.byteOffset,r.byteOffset+r.byteLength),c=new n.Decoder,u=new n.DecoderBuffer;u.Init(l,r.byteLength);const d=r_(n,c,u,e.attributes,t,i);return n.destroy(u),d}function cn(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 Fn(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 a_(e,t,n,i){const s=t.index.array;if(i!==void 0&&(cn(s,e,i,34963,"index buffer view"),e.accessors[i].componentType=V1),t.attributes.POSITION!==void 0){const r=Fn(t.attributes.POSITION.array,t.attributes.POSITION.componentType);cn(r,e,n.POSITION,34962,"position buffer view")}if(t.attributes.NORMAL!==void 0){const r=Fn(t.attributes.NORMAL.array,t.attributes.NORMAL.componentType);cn(r,e,n.NORMAL,34962,"normal buffer view")}for(let r=0;r<qx;++r){const o=`TEXCOORD_${r}`;if(t.attributes[o]!==void 0){const a=Fn(t.attributes[o].array,t.attributes[o].componentType);cn(a,e,n[o],34962,`${o} buffer view`)}}if(t.attributes.TANGENT!==void 0){const r=Fn(t.attributes.TANGENT.array,t.attributes.TANGENT.componentType);cn(r,e,n.TANGENT,34962,"Tangent buffer view")}if(t.attributes.COLOR_0!==void 0){const r=Fn(t.attributes.COLOR_0.array,t.attributes.COLOR_0.componentType);cn(r,e,n.COLOR_0,34962,"color buffer view")}if(t.attributes.JOINTS_0!==void 0){const r=Fn(t.attributes.JOINTS_0.array,t.attributes.JOINTS_0.componentType);cn(r,e,n.JOINTS_0,34963,"JOINTS_0 buffer view")}if(t.attributes.WEIGHTS_0!==void 0){const r=Fn(t.attributes.WEIGHTS_0.array,t.attributes.WEIGHTS_0.componentType);cn(r,e,n.WEIGHTS_0,34963,"WEIGHTS_0 buffer view")}if(t.attributes.JOINTS_1!==void 0){const r=Fn(t.attributes.JOINTS_1.array,t.attributes.JOINTS_1.componentType);cn(r,e,n.JOINTS_1,34963,"JOINTS_1 buffer view")}if(t.attributes.WEIGHTS_1!==void 0){const r=Fn(t.attributes.WEIGHTS_1.array,t.attributes.WEIGHTS_1.componentType);cn(r,e,n.WEIGHTS_1,34963,"WEIGHTS_1 buffer view")}}function l_(e,t){return Pe(this,null,function*(){var n;if(!Array.isArray(e.meshes))return Promise.resolve();for(const i of e.meshes)if(Array.isArray(i.primitives))for(const s of i.primitives){if(((n=s.extensions)==null?void 0:n.KHR_draco_mesh_compression)===void 0)continue;Ru||Qx(t);const r=yield Ru;if(!r)continue;const o=o_(s.extensions.KHR_draco_mesh_compression,e,r,s.attributes);a_(e,o,s.attributes,s.indices)}})}function Nu(e){return Pe(this,null,function*(){const t=yield self.fetch(e);if(!t.ok)throw new Error(`${t.status} ${t.statusText}: ${t.url}`);return t})}const Bu={asset:{version:""}};function c_(e,t){return Pe(this,null,function*(){if(t){e.buffers[0].buffer=t[0]||[];return}yield Promise.all(e.buffers.map(n=>Pe(null,null,function*(){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=z1(n.uri);else{const i=Pn(n.uri)?n.uri:U1(e.path)+n.uri,s=yield Nu(i).then(r=>r.arrayBuffer());n.buffer=s}})))})}function u_(e,t,n){return Pe(this,null,function*(){var o;if(!t.bufferView)return!1;const i=e.bufferViews[t.bufferView];if(i===void 0)return!1;yield n;const s=e.buffers[i.buffer].buffer;if(!s)return!1;const r=new Uint8Array(s,i.byteOffset,i.byteLength);if(typeof createImageBitmap!="undefined")if(p_(r)){const a=new Blob([r],{type:t.mimeType});t.image=yield createImageBitmap(a)}else return console.error(`Unsupported image type ${(o=t.mimeType)!=null?o:""}`),!1;else return!1;return!0})}function d_(e,t){return Pe(this,null,function*(){if(t.uri===void 0)return!1;const n=t.mimeType||Hx(t.uri);if(t.mimeType=n,typeof createImageBitmap!="undefined"&&(n===wr.JPEG||n===wr.PNG))if(t.uri.startsWith("data:image")){const i=z1(t.uri);t.image=yield createImageBitmap(new Blob([i],{type:n}))}else{const i=Pn(t.uri)?t.uri:`${U1(e.path)}${t.uri}`,r=yield(yield Nu(i)).arrayBuffer();t.image=yield createImageBitmap(new Blob([r],{type:n}))}else return console.error(`Unsupported image type ${n}`),!1;return!0})}function f_(e,t){return Pe(this,null,function*(){yield Promise.all(e.images.map(n=>Pe(null,null,function*(){if(n.image){n.mimeType!==wr.GLTEXTURE&&console.error("Image has already been loaded");return}(yield u_(e,n,t))||(yield d_(e,n))||console.error(`Was not able to resolve image with uri ${n.uri}`)})))})}function h_(e,t){return Pe(this,null,function*(){const n=Yy(e,self.origin);try{const i=yield Nu(n);let s=Bu,r;try{const o=yield i.arrayBuffer();if(Ma.isGlb(o)){const f=new Ma(o).extractGlbData();s=f.json,r=f.buffers}else{const d=new TextDecoder("utf-8"),f=new Uint8Array(o);s=JSON.parse(d.decode(f))}const a=Px(s,n),l=c_(a,r),c=f_(a,l),u=l_(a,t);return yield Promise.all([l,c,u]),{type:"ok",result:a}}catch(o){return{type:"error",layer:"parsing",originalError:o}}}catch(i){return{type:"error",layer:"network",originalError:i}}})}function p_(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 m_{loadModel(t,n){return Pe(this,null,function*(){return yield h_(t,n)})}}class y_{constructor(t,n){this.scope=t,this.options=n,this.tileLoader=new Iu("arrayBuffer"),this.tiles=new Map,this.url=i=>{const[s,r,o]=Wr(i);return ph(this.options,s,r,o,this.options.tileSet)}}abortTileFetches(t){this.tileLoader.abortRequests(t.map(Le))}deleteTiles(t){t.forEach(n=>this.tiles.delete(Le(n)))}generateTile(t,n){return Pe(this,null,function*(){const i=[],s=[],r=Le(n),o=this.tiles.get(r);if(!o)return Promise.resolve({results:i,transferable:s,minZ:0,maxZ:0,tree:null});const a=X2(o);do Ot.generateMeshElevation(this.scope.collector,a,t,Xs);while(this.scope.collector.isOverloaded());const l=this.scope.collector.getAccumulatedData();this.scope.resetCollector();const c=Y2(l.data);return i.push({regionId:0,metatileHash:-1,styleId:t,collectorOutput:l}),s.push(...l.transferable),c&&s.push(c),Promise.resolve({results:i,tree:c,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=Le(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))}}const g_=1246122573,v_=1,w_=3,ku=2048*1024;var Ta=(e=>(e[e.Magic=0]="Magic",e[e.Version=4]="Version",e[e.FrameMailbox=8]="FrameMailbox",e[e._Size=16]="_Size",e))(Ta||{});const b_=16+w_*ku;var Uu=(e=>(e[e.Magic=0]="Magic",e[e.FrameId=4]="FrameId",e[e.CreateTime=8]="CreateTime",e[e.SubmitTime=16]="SubmitTime",e[e.CommandCount=24]="CommandCount",e[e._Size=28]="_Size",e))(Uu||{});function I_(e){e[0]=g_,e[1]=v_,e[2]=0}function H1(e,t,n){if(typeof SharedArrayBuffer!="undefined"&&e.buffer instanceof SharedArrayBuffer)return Atomics.exchange(e,t>>2,n);const i=t>>2,s=e[i];return e[i]=n,s}var $1=(e=>(e[e.WebGPU=0]="WebGPU",e))($1||{}),zu=(e=>(e[e.WebGPU=0]="WebGPU",e))(zu||{}),Sa=(e=>(e[e.Test=0]="Test",e))(Sa||{}),Ci=(e=>(e[e.Vertex=0]="Vertex",e[e.Fragment=1]="Fragment",e))(Ci||{});function Y1(e,t,n){const i=JSON.stringify(n!=null?n:{});return`${e}:${t}:${i}`}const M_=`/**
 * Test vertex shader
 * Простой треугольник для проверки работы WebGPU pipeline
 */

@vertex
fn main(@builtin(vertex_index) vertexIndex: u32) -> @builtin(position) vec4f {
    var positions = array<vec2f, 3>(
        vec2f(0.0, 0.5),
        vec2f(-0.5, -0.5),
        vec2f(0.5, -0.5)
    );
    return vec4f(positions[vertexIndex], 0.0, 1.0);
}
`,T_=`/**
 * Test fragment shader
 * Красный цвет для проверки работы WebGPU pipeline
 */

@fragment
fn main() -> @location(0) vec4f {
    return vec4f(1.0, 0.0, 0.0, 1.0); // Red color
}
`,W1=new WeakMap;function Z1(e){let t=W1.get(e);return t||(t=new Map,W1.set(e,t)),t}const S_={[Sa.Test]:{[Ci.Vertex]:M_,[Ci.Fragment]:T_}};function X1(e,t,n){const i=S_[e];if(!i)throw new Error(`No shaders registered for material type: ${e}`);const s=i[t];if(!s)throw new Error(`No ${t} shader for material type: ${e}`);return s}function q1(e,t,n){return e.createShaderModule({label:n,code:t})}function E_(e,t,n={}){const i=Z1(e),s=Y1(t,Ci.Vertex,n);let r=i.get(s);if(!r){const o=X1(t,Ci.Vertex);r=q1(e,o,`${t} vertex shader`),i.set(s,r)}return r}function A_(e,t,n={}){const i=Z1(e),s=Y1(t,Ci.Fragment,n);let r=i.get(s);if(!r){const o=X1(t,Ci.Fragment);r=q1(e,o,`${t} fragment shader`),i.set(s,r)}return r}class x_{}class __ extends x_{constructor(){super(...arguments),this.renderFamily=$1.WebGPU,this.pipeline=null}drawFrame(t,n,i){const{device:s,format:r,context:o}=n;if(this.pipeline||(this.pipeline=s.createRenderPipeline({layout:"auto",vertex:{module:E_(s,Sa.Test),entryPoint:"main"},fragment:{module:A_(s,Sa.Test),entryPoint:"main",targets:[{format:r}]},primitive:{topology:"triangle-list"}})),t.byteLength===0)return;const a=s.createCommandEncoder(),l=a.beginRenderPass({colorAttachments:[{view:o.getCurrentTexture().createView(),clearValue:{r:0,g:0,b:0,a:1},loadOp:"clear",storeOp:"store"}]});l.setPipeline(this.pipeline),l.draw(3),l.end(),s.queue.submit([a.finish()])}}class P_{constructor(t,n,i){this.frameReadSlot=2,this.lastFrameId=0,this.renderLoop=()=>{this.frameReadSlot=H1(this.transportI32,Ta.FrameMailbox,this.frameReadSlot);const s=Ta._Size+this.frameReadSlot*ku,r=this.transportU32[s+Uu.FrameId>>2];if(r<this.lastFrameId){this.renderLoop();return}this.lastFrameId=r,this.render.drawFrame(this.transportBuffer,this.webGPUState,this.frameReadSlot),this.requestedFrame=self.requestAnimationFrame(this.renderLoop)},this.canvasSize={width:1,height:1,pixelRatio:1},this.webGPUState=n,this.requestedFrame=0,this.render=this.createRender(t),this.transportBuffer=i,this.transportI32=new Int32Array(i),this.transportU32=new Uint32Array(i)}resize(t,n,i){if(this.canvasSize.width===t&&this.canvasSize.height===n&&this.canvasSize.pixelRatio===i)return;this.canvasSize.width=t,this.canvasSize.height=n,this.canvasSize.pixelRatio=i;const s=Math.floor(t*i),r=Math.floor(n*i),o=this.webGPUState.canvas;o.width!==s&&(o.width=s),o.height!==r&&(o.height=r)}start(){this.requestedFrame===0&&(this.requestedFrame=self.requestAnimationFrame(this.renderLoop))}stop(){this.requestedFrame!==0&&(self.cancelAnimationFrame(this.requestedFrame),this.requestedFrame=0)}destroy(){}createRender(t){switch(t){case zu.WebGPU:return new __;default:throw new Error(`Unknown backend: ${t}`)}}}function L_(e){return Pe(this,null,function*(){if(!navigator.gpu)throw new Error("WebGPU is not available in this environment");const t=yield navigator.gpu.requestAdapter({powerPreference:"high-performance"});if(!t)throw new Error("Failed to acquire WebGPU adapter");const n=yield t.requestDevice(),i=e.getContext("webgpu");if(!i)throw new Error("Failed to acquire WebGPU canvas context");const s=navigator.gpu.getPreferredCanvasFormat();return i.configure({device:n,format:s}),{canvas:e,device:n,context:i,format:s}})}function J1(e,t,n){return Pe(this,null,function*(){const i=yield L_(t);return new P_(e,i,n)})}function C_(e,t,n){return Pe(this,null,function*(){const i=yield J1(e,t,n);return v1(i)})}class D_{constructor(t){this.map=(t==null?void 0: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,l)=>t(r,o,a,l),i),n)}}const O_=17,Ea=6;class F_{constructor(){this.name="",this.range="",this.glyphs={}}}class R_{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 N_{constructor(t,n){this.stacks=t.readFields(B_,[],n)}}function B_(e,t,n){if(e===1){const i=n.readMessage(k_,new F_);t.push(i)}}function k_(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(U_,new R_);t.glyphs[i.id]=i;break}}}function U_(e,t,n){switch(e){case 1:t.id=n.readVarint(),t.range=Ol(t.id);break;case 2:t.bitmap=n.readBytes();break;case 3:t.width=n.readVarint()+Ea;break;case 4:t.height=n.readVarint()+Ea;break;case 5:t.left=n.readSVarint()-Ea/2;break;case 6:t.top=n.readSVarint()+O_+Ea/2;break;case 7:t.advance=n.readVarint();break}}class z_{constructor(t,n,i){const s=[];let r=0;for(let o=0;o<t.length;o++){const a=t.charCodeAt(o),l=n&&n[a];l?(s.push(l),r=r+l.advance):a!==Ut.bomCharCode&&qv(t[o],a)}this.glyphs=s,this.width=r+Ut.baseSize*i*(t.length-1)}}function G_(e,t,n){const i={lines:[],maxWidth:0},s=e.split(`
`);for(let r=0;r<s.length;r++){const o=new z_(s[r],n,t);i.lines.push(o),o.width>i.maxWidth&&(i.maxWidth=o.width)}return i}function V_(e,t,n){for(const i of t)if(!n.has(e,i))return!1;return!0}function j_(e,t,n){if(e===void 0)return;const i=ut(e,t);if(i!=="")return n.fontNameToIndex[i]===void 0?Fi:i}function H_(e){const t=new N_(new Vr(new Uint8Array(e))).stacks[0].glyphs,{width:n,height:i}=$_(t);Y_(t,n,i);const s=W_(t,n,i);return{glyphData:t,bitmap:s,width:n,height:i}}function $_(e){const t=[],n=new bt(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:bd(n.w),height:bd(n.h)}}function Y_(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=St(r.y/n),r.texLeft=St(r.x/t),r.texBottom=St((r.y+r.height)/n),r.texRight=St((r.x+r.width)/t))}}function W_(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 l=t*(o.y+a)+o.x,c=o.width*a;for(let u=0;u<o.width;u++)i[l+u]=o.bitmap[c+u]}}return i.buffer}function Z_(e){let t=!1,n;return function(...i){return t||(t=!0,n=e.apply(this,i)),n}}y.processRTLTextIfNeeded=e=>e,y.markAsReady=null,y.rtlAdapterReady=!1;const X_=new Promise(e=>{y.markAsReady=()=>{y.rtlAdapterReady=!0,e()}}),q_=new Set(["ar"]);function K1(e,t){return e==="always-on"||e==="depends-on-language"&&q_.has(t)}function J_(e,t,n){const i=t.workers.labeling;function s(){i.markRtlPluginLoaded().then(()=>{y.markAsReady!==null&&y.markAsReady()})}return K1(e.scenario,n)?fetch(e.url,{integrity:e.hash}).then(r=>r.text()).then(r=>Promise.all([i.loadRtlPlugin(r),Promise.resolve(Q1(r))])).catch(r=>{s();const o=new Error,a="[RTL Plugin]: loading failed.";throw o.message=K_(r)?`${a} ${r.message}`:a,o}):(s(),Promise.resolve())}const Q1=Z_(function(e){new Function(e)(),y.processRTLTextIfNeeded=self.mapglRtlPlugin.processRtl,y.markAsReady&&y.markAsReady()});function K_(e){return typeof e=="object"&&!!e&&"message"in e}y.ArrowGenerator=rr,y.BBoxType=Rt,y.BLEND_EQUATION=oT,y.BLEND_FUNC=rT,y.BaseTileLoader=Iu,y.Buffer=Xe,y.BufferChannel=C0,y.BuildingModelGenerator=En,y.CULL_FACE_MODE=sT,y.Camera=Cs,y.CircleMarkerGenerator=bo,y.ClassRegistry=QA,y.Collector=NA,y.DEFAULT_EMPTY_KEY=Yu,y.DEFAULT_FLOORS_FLOOR_HEIGHT=Aw,y.DEFAULT_FLOORS_METRO_FLOOR_HEIGHT=xw,y.DEFAULT_FONT=Fi,y.DEFAULT_FRAME_SIZE=ku,y.DEFAULT_ID_SCOPE=Gc,y.DEFAULT_LIGHTING_MODES=kA,y.DEFAULT_MAPGL_STYLE=um,y.DEFAULT_MIN_TIERS_STYLE_ZOOM=vd,y.DEFAULT_MODELS_APPEAR_STRATEGY=$u,y.DEM_ELEVATION_TILE_SIZE=$2,y.DEM_STYLE_LAYER_ID=Xs,y.DEM_TILE_URL_FUNCTION=ph,y.DEM_TREE_SIZE=hh,y.DEPTH_FUNC=O0,y.DYNAMIC_MODEL_ID_SCOPE=VM,y.DYNAMIC_STYLE_ID=Jo,y.DashedLineGenerator=Sn,y.DemGenerator=Ot,y.Differ=Np,y.DynamicStyle=jT,y.EARTH_CIRCUMFERENCE=qa,y.EMPTY_FEATURE_COLLECTION=oa,y.EMPTY_SHADER_DEFINITIONS=Yc,y.ENVIRONMENT_STYLE_LAYER_ID=Hl,y.Ecef=lt,y.EcefDataState=ta,y.Evented=hl,y.FLOOR_ID_SCOPE=GM,y.FnRegistry=KA,y.FrameHeader=Uu,y.GEOJSON_DEFAULT_MAX_DETAIL_LEVEL=ou,y.GL_TRIANGLES=Mr,y.GeoJsonSource=zp,y.GeoJsonSourceCore=Fp,y.GeoJsonSourceWorker=_x,y.GeoJsonTileSource=PE,y.GeoJsonViewportSource=LE,y.GltfDemPosition=f0,y.GltfModelGenerator=Qn,y.HALF_WORLD_SIZE=2147483648,y.HandyIndexer=Vc,y.HeatmapGenerator=Ei,y.HideLevel=fs,y.INVALID_FRAMEBUFFER_ID=io,y.INVALID_IDENTIFY_CENTER_COORD=Pa,y.IdScope=jM,y.LABELING_TEXTURE_BACKGROUND_COLOR=OA,y.LABELING_TEXTURE_DEM_MESH_COLOR=FA,y.LATEST_TILE_VERSION=k1,y.LRU=yp,y.LabelGeometryType=Mi,y.LabelIndex=Sc,y.LabelSource=ar,y.LabelingAnimation=x0,y.LabelingElementType=Ye,y.LabelingTileElement=xo,y.LengthUnits=Wn,y.LineExtrusionGenerator=An,y.LineGenerator=dt,y.LinePatternType=Bc,y.MAP_DEFAULTS=Ca,y.MAP_MESH_TEXTURE_INDEX=tg,y.MAP_POINTS_IN_METER=ve,y.MODELS_TILES_VIEWPORT_PADDING=fm,y.MainConnector=qA,y.MapMeshGenerator=ds,y.Mercator=oe,y.MeshElevationWorker=y_,y.MeshFillSide=te,y.MeshGenerator=Q,y.ModelStepSource=Ai,y.ModelsWorker=m_,y.PBR_TEXTURE_INDEX=eg,y.POINT_CENTER_SIZE=La,y.PolygonExtrusionGenerator=on,y.PolygonGenerator=Xt,y.PreLabelType=xn,y.RasterGenerator=Mo,y.RasterSetType=Si,y.RenderBackendType=zu,y.ReservedLightingMode=$s,y.SIMPLE_MESH_STYLE_LAYER_ID=kT,y.SceneObjectType=Ml,y.Shader=Ko,y.ShaderAttribute=ov,y.ShiftedLineGenerator=Js,y.TEXTURE_COORDS_TO_WEBGL=Nm,y.TRANSPORT_SIZE=b_,y.ThreadName=ii,y.TileLayer=Op,y.TileObject=na,y.TileObjectBase=cp,y.TileStatus=Xc,y.TransportHeader=Ta,y.TwoKeyMap=D_,y.UNIVERSE_REGION_ID=hm,y.UNUSED_STYLE_ID_SHIFT=UA,y.WEBGL_COORDS_TO_TEXTURE=Bm,y.WEB_MERCATOR_TO_WORLD_SIZE_MULTIPLIER=om,y.WorkerConnector=JA,y.ZenithSourceCore=QM,y.ZenithWorker=AA,y.ZoomDirection=kt,y.add=Gt,y.add$1=ai,y.addGeneratedDataToTileMod=up,y.adjustGlobeDragSpeed=wy,y.affineStep=Ga,y.allFontGlyphsLoaded=V_,y.applyDefaults=Nn,y.applyStyleOptions=KI,y.assertUnreachable=Rl,y.atlasSize=dn,y.bezier=np,y.bindUrl=$y,y.buildingAnimation=td,y.calcAngle=ky,y.calcMidpoint=Uy,y.center=Nr,y.cityCommPoiLabelingConfig=id,y.clamp=xe,y.clampLat=Sy,y.clampPoint=Ty,y.clone=Tm,y.clone$1=Od,y.commercialPoi=Da,y.compare=$r,y.compileRtlPlugin=Q1,y.componentTypeToWebGl=av,y.contains=Ey,y.convertStyleLayerTypeToHandy=v2,y.coordsToKey=Le,y.copy=_m,y.copy$1=Bd,y.copy$2=el,y.copy$3=xr,y.create=Ds,y.create$1=ot,y.create$2=Ed,y.create$3=Ls,y.create$4=rl,y.create$5=Br,y.create$6=Oe,y.createGeoJsonMetatile=I1,y.createGridState=Ip,y.createLoadedRasterSet=MI,y.createMetatile=qd,y.createObjectAttributesArray=Re,y.createRemoteRenderRunner=C_,y.createRenderRunner=J1,y.createTileInfo=gt,y.cross=_s,y.debounce=Bp,y.decomposeMat4=jy,y.deepEqual=Ri,y.defaultCameraConfig=zt,y.defaultLang=rd,y.defaultMarkerAnchor=gd,y.defaultMarkerIcon=yd,y.defaultModelsPath=xa,y.defaultShadowsSettings=wd,y.degToRad=Te,y.dem=Zu,y.dist=Un,y.dist$1=nl,y.distance=Es,y.dot=tl,y.dot$1=kn,y.dracoDecoderUrl=rm,y.drawIdentifyScene=HT,y.earcut=Jr,y.ease=sp,y.ecefDataStateFromBool=NS,y.emptyFeatureAttrs=Jd,y.emptySourceAttrs=dl,y.encodeTilePointToEcefU16=rn,y.entranceAnimation=nd,y.equalArrays=wm,y.equalSets=vm,y.equals=fy,y.equals$1=xm,y.events=Qu,y.exactEquals=Rm,y.exactEquals$1=Pr,y.exactEquals$2=iy,y.excludeItemFromArray=bm,y.exist=op,y.expandByPoint=di,y.expose=Tu,y.expressionValues=wi,y.findVisibleTiles=uf,y.finishStyleUpdatingAction=Pp,y.fixedMetatile=Jy,y.fixedTileProps=fi,y.floors=Ba,y.fonts=Ut,y.forceGlStatusCheck=X0,y.fromGeo=My,y.fromRotationTranslationScale=Om,y.fromScaling=Dm,y.fromTranslationScale=Cr,y.fromValues=at,y.fromValues$1=ja,y.generalize=vI,y.generateHaltonSequence=ew,y.generateHandyLayers=zc,y.generateIconElement=Ac,y.generateNotStretchableIconElement=AI,y.generatePointsOnSphere=tw,y.generateSafely=_0,y.generateTextElement=Lo,y.generateTileBounds=Z0,y.geoJsonMetatileHash=Hu,y.geoLineDistance=Vm,y.geoPointsDistance=Ka,y.geoToMapDistance=Rr,y.get=RS,y.getArrayBuffer=aa,y.getBoundsTileCoords=Kg,y.getCenterCorrection=vy,y.getClosestPointOnLineSegment=Tg,y.getColorForShaders=o2,y.getElevationFromTile=W2,y.getFontNameWithFallback=j_,y.getFontUrl=ZI,y.getFractionalPart=gm,y.getJson=Gp,y.getLabelingInfo=NM,y.getLayerImageProps=G0,y.getLineConstants=hi,y.getMetersFromPixelsXY=Iy,y.getModelUrl=XI,y.getPixelsPerMeter=Kr,y.getPoiIconData=iM,y.getRandomValue=Hs,y.getRawMemoryStats=AE,y.getSizeDependentImageUrl=a0,y.getStaticIconRasterSetKey=Xi,y.getStaticTextureRasterSetKey=eo,y.getStyleUrl=QI,y.getStyleZoom=zd,y.getSubdomainFromString=ul,y.getSymbolLayers=J0,y.getTextMetrics=G_,y.getTierFromLevels=bM,y.getTileBounds=af,y.getTileCoordsByCenterAndZoom=Il,y.getTileModToGenerate=mp,y.getTilesToAbortFetch=vp,y.getTilesToFetch=gp,y.getTilesToGenerate=wp,y.getTilesToRemove=bp,y.getTotalMemory=ru,y.getTriple=Ar,y.getUrl=Os,y.getUrlForIconMapIcon=Pc,y.getUrlFromTemplate=Fs,y.getVisibleMapReplicas=Qg,y.getZoomFromStyleZoom=by,y.globeConfig=Rn,y.handyColor=js,y.hashToString=Zd,y.heightToZoom=Um,y.icons=Ju,y.identify=Ra,y.identity=Ya,y.index=mm,y.inertia=Na,y.inferGeneratorType=lv,y.initTransportHeader=I_,y.int64ToString=M0,y.intersection=xy,y.intersection$1=UM,y.invert=As,y.isArrayOfNumbers=pn,y.isBetween=Va,y.isCommercialCityPoi=i0,y.isCommercialModel=HI,y.isCommercialPoi=Go,y.isCommercialPoi$1=Ti,y.isCommercialPoiCity=dI,y.isCommercialPoiLabel=lr,y.isCommercialPoiPremium=fI,y.isCommercialPremiumPoi=s0,y.isExtractableHandyExpression=Dv,y.isHandyExpression=sn,y.isHandySimpleType=xf,y.isInt64=PM,y.isLatValid=Ay,y.isLineStyleLayer=vb,y.isNullVector=By,y.isNullish=Im,y.isObject=Mm,y.isPersonalPoi=jI,y.isRtlPluginRequired=K1,y.isStyleColor=yn,y.isStyleGradient=to,y.isStyleId=p2,y.isStyleLayerHidable=g2,y.isStyleLayerType=y2,y.isStyleMixColor=Fv,y.isTileOnSphereInViewport=Zr,y.isTileVisible=Hr,y.isTypedArray=rM,y.keyServerPath=bs,y.keyToCoords=vl,y.labeling=Sr,y.len=Sd,y.len$1=Or,y.length=zn,y.lerp=li,y.lerp$1=$a,y.lerp$2=Ni,y.lerp$3=dy,y.limitString=Zv,y.linePatternFromString=A0,y.linear=ip,y.loadModelsInfoStyleZoom=Oa,y.log=ke,y.logEmptyTileGenerationResponse=Nf,y.logGltfError=Jv,y.lookAt=Xa,y.mailboxSwap=H1,y.makeBinderContext=qf,y.makeGeneratorContext=Ys,y.makeHandyDemLayer=$c,y.makeHandyGroupOrLayer=k0,y.makeHandyLightStyle=j0,y.makeHandyRasterSet=z0,y.makeHandyRasterSets=U0,y.makeHandyStyle=OT,y.makeHandyStyleLayer=qo,y.makeLabelingContext=Ht,y.mapHeightToTileHeight=wt,y.mapPointPitch=Ym,y.mapPointTo32ZoomTileCoords=Jg,y.mapPointToTilePoint=Lt,y.mapToPixelDistance=$m,y.maxTilePoint=ne,y.maxU32=am,y.maxUint16Value=Ze,y.metricsTimeout=ud,y.modStatsGpu=su,y.modStatsJs=iu,y.modelCacheSize=Xu,y.modelSizeGpu=SE,y.modelSizeJs=TE,y.models=Wu,y.mul=hy,y.mul$1=ki,y.multiply=Wa,y.multiply$1=Ly,y.newFrameAction=Ep,y.normalize=Kt,y.normalize$1=Bn,y.normalizeMapPoint=Zm,y.normalizeMousePosition=ym,y.optionsToTileAttrs=W0,y.ortho=Fm,y.overlappedGroupName=Zn,y.packTexCoords=St,y.performanceCheck=cd,y.pixelRatioToDpi=Nl,y.pixelToMapDistance=Ld,y.pixelsAndMapDistanceToZoom=Cd,y.pointToLineDistance=vg,y.pointToLineSignedDistance=nf,y.preLabelingPoint=o0,y.prepareMetatile=Xd,y.processElement=RM,y.processFont=H_,y.projectToXyRect=Hy,y.radToDeg=ri,y.rbush=lo,y.removeUndefined=_w,y.renameZenithEnumerationValues=KM,y.render=sd,y.reserveTextureIndex=ml,y.reset=sl,y.resetGridState=Qc,y.resolveAnimationExpression=Hf,y.resolveColor=vn,y.resolveExpression=H,y.resolveGradient=s2,y.resolveLightingModes=l2,y.resolveNumber=ce,y.resolveSimpleLiteralExpression=st,y.resolveString=ut,y.resolveTextureAnimationExpression=$f,y.rotateVec2=zy,y.rotateX=ey,y.rotateY=ty,y.rtlAdapterPromise=X_,y.rtlPluginHash=Is,y.rtlPluginUrl=un,y.runPrecomputes=Uc,y.sample=Zf,y.sampleColor=Xf,y.scale=Gn,y.scale$1=_y,y.scale$2=_t,y.scale$3=Bi,y.scale$4=cy,y.selectRaster=cr,y.set=De,y.set$1=ay,y.set$2=Lm,y.setSeed=rI,y.setupMapboxRtlAdapterIfNeeded=J_,y.sign=Er,y.slerp=kr,y.sourceUuid=Rp,y.splitPolylineByLength=Ig,y.splitPolylineByMaxSize=Mg,y.spreadTileObjects=q0,y.sqrDist=ry,y.start=rp,y.startStyleUpdatingAction=_p,y.stop=Wc,y.stride=hr,y.styles=Ku,y.sub=fn,y.sub$1=Qt,y.subtract=BM,y.template=zi,y.tetragonBounds=jr,y.tetragonIntersectsBounds=sf,y.textureSizeGpu=IE,y.textureSizeJs=nu,y.throttle=xA,y.tileCoordOffset=V,y.tileCoordsToMapPoint=$i,y.tileCoordsToOSM=Wr,y.tileHeight=Ms,y.tileObjectStatsGpu=Dp,y.tileObjectStatsJS=Cp,y.tilePointScaleFactor=Ct,y.tilePointToMapPoint=vt,y.tilePointToOffsetSize=qg,y.tileSizeZpt=256,y.tileZoomToSize=jt,y.tiles=si,y.toStyleColor=ct,y.traffic=qu,y.transfer=g1,y.transformMat4=Fr,y.transformMat4$1=Ps,y.uint16ToTileCoords=Oi,y.uniqId=pl,y.unpackPreLabelingResult=lI,y.update=ap,y.updateScene=Tp,y.urls=Tr,y.vertexTilePointToMapPoint=hf,y.viewportChangeAction=tu,y.viewportTilesReady=Kc,y.workerResetInterval=ed,y.worldBounds=jm,y.worldLoopBounds=Hm,y.worldSize=4294967296,y.worldWrapX=xs,y.wrap=h1,y.z0Scale=Vu,y.zenithSourceAttrs=Kd,y.zenithToJakartaPropKey=ZM,y.zoom=od,y.zoomToHeight=Ui,y.zoomToScale=zm,y.zptPerInch=Ts,y.zptToSceneDistance=Gm}));

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

_mapgl_d("index",["exports","./shared"],(function(J,n){var Aw=Object.defineProperty,e0=Object.defineProperties;var t0=Object.getOwnPropertyDescriptors;var Kc=Object.getOwnPropertySymbols;var i0=Object.prototype.hasOwnProperty,n0=Object.prototype.propertyIsEnumerable;var qe=Math.pow,qc=(J,n,Oe)=>n in J?Aw(J,n,{enumerable:!0,configurable:!0,writable:!0,value:Oe}):J[n]=Oe,I=(J,n)=>{for(var Oe in n||(n={}))i0.call(n,Oe)&&qc(J,Oe,n[Oe]);if(Kc)for(var Oe of Kc(n))n0.call(n,Oe)&&qc(J,Oe,n[Oe]);return J},ce=(J,n)=>e0(J,t0(n));var K=(J,n,Oe)=>new Promise((Vi,ji)=>{var uo=ut=>{try{_t(Oe.next(ut))}catch(gi){ji(gi)}},Ee=ut=>{try{_t(Oe.throw(ut))}catch(gi){ji(gi)}},_t=ut=>ut.done?Vi(ut.value):Promise.resolve(ut.value).then(uo,Ee);_t((Oe=Oe.apply(J,n)).next())});"use strict";var Tt,At;var Oe=document.createElement("style");Oe.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_GbM3JIwbvBI-{overflow:hidden;display:flex}.mapgl_GbM3JIwbvBI- .mapgl_MX6K1s-5thI-{transform:scale(.7);margin-top:10px}.mapgl_GbM3JIwbvBI- .mapgl_aMwUNIDCavU-{transform:scale(.6);margin-left:-10px;margin-top:-10px;width:100%}.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(Oe);function Vi(s,e,t){if(s.length===0)return;const i=n.degToRad(e),o=n.create();for(const a of s){const l=n.Mercator.fromGeo(a);n.rotateVec2(l,-i),n.expandByPoint(o,l)}const r=n.create$1();return n.center(r,o),n.rotateVec2(r,i),{center:r,zoom:ji(o,t)}}function ji(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 uo(s,e,t){const i=Vi(s,e,t);if(i)return{zoom:i.zoom,center:n.Mercator.toGeo(i.center)}}function Ee(s,e,t){const i=s.getBoundingClientRect();return[e-i.left-s.clientLeft,t-i.top-s.clientTop]}function _t(s,e){const t=[];for(let i=0;i<s.length;i++)t[i]=Ee(e,s[i].clientX,s[i].clientY);return t}function ut(s){return s.touches.length>1}const gi=n.Mercator.fromGeo,Yc=n.Mercator.toGeo;function Qc(s,e,t,i,o,r,a={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:a,padding:l,cameraConfig:n.defaultCameraConfig,globeMode:c,styleState:{}}).project(r)}function Jc(s,e,t,i,o,r,a={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:a,padding:l,cameraConfig:n.defaultCameraConfig,globeMode:c,styleState:{}}).unproject(r)}function Ac(s,e,t,i,o,r,a={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,r,a,l,c,c)}function ed(s,e){return new n.Camera(s).project(n.Mercator.toGeo(e))}const td=Object.freeze(Object.defineProperty({__proto__:null,geoLineDistance:n.geoLineDistance,geoToMapDistance:n.geoToMapDistance,getCenterZoomByPoints:uo,getMetersFromPixels:Ac,getMousePositionInContainer:Ee,projectGeoToMap:gi,projectGeoToScreen:Qc,projectMapToGeo:Yc,projectMapToScreen:ed,projectScreenToGeo:Jc},Symbol.toStringTag,{value:"Module"})),id=Object.freeze(Object.defineProperty({__proto__:null,getMetersFromPixelsXY:n.getMetersFromPixelsXY,getUrl:n.getUrl,hashToString:n.hashToString},Symbol.toStringTag,{value:"Module"}));class Ye extends n.Evented{constructor(e,t,i){var o;super(),this.visibleOnGlobe=!0,this.interactive=(o=t.interactive)!=null?o:!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}updateGlobeVisibility(e){if(this.mapState.globeMode){const t=this.modules.camera.ecef.canSee(e);return this.visibleOnGlobe&&!t?this.tileObjects.forEach(i=>this.modules.tileManager.removeObject(i)):!this.visibleOnGlobe&&t&&this.tileObjects.forEach(i=>this.modules.tileManager.addObject(i)),this.visibleOnGlobe=t,t}return this.visibleOnGlobe||(this.tileObjects.forEach(t=>this.modules.tileManager.addObject(t)),this.visibleOnGlobe=!0),!0}}function xe(s){return!!s.styleState.globeEnabled&&s.globeMode}const Js=["disableDragging","enableTrackResize","loopWorld","disableHidingPois","enableTwoFingerDragging"];let ho=class{constructor(e,t,i){var o,r,a,l,c,d;this.options=t,this.type="zenith",this.id=n.sourceUuid(),this.identifyAsDefaultSource=(o=t.identifyAsDefaultSource)!=null?o:!0,this.identifyAsDefaultSource&&!t.promoteId&&(t.promoteId="id"),this.sourceOptions=t,this.modelsAppearStrategy=(r=t.modelsAppearStrategy)!=null?r: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((a=t.minZoom)!=null?a:n.tiles.maxUniverseZoom+1,(l=t.maxZoom)!=null?l:n.tiles.maxRegionalZoom,(c=t.minZoom)!=null?c:n.tiles.maxUniverseZoom+1,(d=t.maxDetailLevel)!=null?d: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,I({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}};const Ht=[0,0,0];function As(s,e){if(e===void 0)return;if(e.sourceId){const i=s.getSourceById(e.sourceId);if(!(i!=null&&i.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 nd(s,e){var i;if(e===void 0)return;if(e.sourceId){const o=s.getSourceById(e.sourceId);if(o)switch(o.type){case"geojson":{if(o.subtype==="internal"&&o instanceof n.GeoJsonSource||o.subtype==="viewport-internal"&&o instanceof n.GeoJsonViewportSource)return{type:"geojson",id:e.id,feature:o.getFeatureById(e.id,e.tileKey),source:o};if(o.subtype==="external"&&o instanceof n.GeoJsonTileSource)return{type:"geojsonTile",getFeatureProperties:()=>e.tileKey===void 0?Promise.resolve():o.getObjectAttributes(e.id,e.tileKey),source:o}}case"zenith":if(o instanceof ho)return{type:"zenith",id:e.id,source:o,attributes:o.getObjectAttributes((i=e.tileKey)!=null?i:"",e.id)}}}const t={type:"default",id:e.id};return e.floorId&&(t.floorId=e.floorId),t}function ht(s,e,t,i,o){const r=o.camera,a=[0,0];if(r.unproject(i,a,!0),o.floorManager.visibleComplexIsMetro&&(e!=null&&e.floorId)&&s==="click"&&od(a,i,e.floorId,o),e&&e.dynamicObjectId!==void 0){const h=s;let f=o.layers.getDynamicObjectLayers().find(p=>p.uniqId===e.dynamicObjectId);if(f!=null&&f.parentObject&&(f=f==null?void 0:f.parentObject),!f)return;const m={lngLat:a,originalEvent:t,point:i,targetData:f};f.emit(h,m);return}const l=As(o.sourceStorage,e),c=nd(o.sourceStorage,e);if((s==="mousedown"||s==="click")&&e!==void 0&&(l==null?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:a,originalEvent:t,point:i,target:l,targetData:c},u=s;o.map.emit(u,_)}function od(s,e,t,i){const o=i.floorManager.getFloorObjectElevation(t),r=[0,0,0];i.camera.flat.unproject(e,r);const a=i.camera.position;r.forEach((c,d)=>Ht[d]=c-a[d]),n.normalize(Ht,Ht);const l=o;if(Math.abs(Ht[2])>=1e-4){const c=(l-a[2])/Ht[2],d=[a[0]+Ht[0]*c,a[1]+Ht[1]*c,l];n.Mercator.toGeo(d,s)}}class er extends Ye{constructor(e,t,i){super(e,t),this.start=o=>{const{modules:r,container:a}=this,{camera:l}=r;if(o.button!==0)return;const c=Ee(a,o.clientX,o.clientY);this.contains(c)&&(r.handler.block(),r.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:r}=this.modules,{dragStartAnchorPoint:a,dragStartCursorPoint:l,container:c}=this;if(a===void 0||l===void 0)return;const d=Ee(c,o.clientX,o.clientY),_=n.clone(a);n.add(_,_,d),n.sub(_,_,l),this.setPosition(n.Mercator.fromGeo(r.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:r}=this;r.handler.unblock(),r.mouseMoveHandler.unblock(),this.emitEvent("dragend",o),this.interactive&&r.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),r=this.modules.camera.flat.project(i),a=this.modules.identifier.searchSync(r),l=a!==void 0&&a.dynamicObjectId===void 0?As(this.modules.sourceStorage,a):void 0;this.emit(e,{originalEvent:t,target:l,targetData:this,lngLat:o,point:r})}}const sd=!1;let tr=class extends er{constructor(e,t){var a;super(e,t,(a=t.draggable)!=null?a:sd),this.generatedAsEcef=!1,this.options=t;const i=n.Mercator.fromGeo(this.options.coordinates);this.position={userValue:i,normalizedValue:n.normalizeMapPoint(i)};const{dynamicStyle:o,layers:r}=this.modules;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&&(o.addLayer(this.layer,this.options.zIndex),this.generate(),r.addLayer(this))}remove(){this.layer&&this.modules.dynamicStyle.removeLayer(this.layer.innerId),this.interactive&&this.modules.identifier.resetCache(),super.destroy()}update(){super.update();const e=xe(this.mapState);e!==this.generatedAsEcef&&(this.regenerate(),this.generatedAsEcef=e),this.updateGlobeVisibility(this.options.coordinates)}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)),r=n.resolveNumber(t.style.width,n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[])),a=n.resolveNumber(t.style.strokeWidth,n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[])),l=r/2+a;return n.dist(o,e)<=l}generate(){var p;if(!this.layer)return;const{dynamicStyle:e,collector:t,tileManager:i,identifier:o}=this.modules,a=(p=this.position.userValue[2])!=null?p:0,l=n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),c=n.optionsToTileAttrs({}),d={x:[0],y:[0],z:[a]},_=n.createTileInfo(l),u=xe(this.mapState),h=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,c,n.emptyFeatureAttrs,this.interactive?"0":"",u?_:void 0);n.runPrecomputes(this.layer,h),n.generateSafely({collector:t,generator:n.CircleMarkerGenerator.generate,args:[e.getStyle().id,this.layer,h,d]});const f=t.getAccumulatedData(),m=new n.TileObject("dynamicObject",f.data,this.modules,this.mapState,l);m.ecefDataState=n.ecefDataStateFromBool(u),i.addObject(m),this.tileObjects.push(m),this.interactive&&this.identifyIds.push(f.identifyIds),t.reset(),this.modules.renderer.addRerenderEvent(),this.interactive&&o.resetCache()}regenerate(){const{tileManager:e}=this.modules;for(const t of this.tileObjects)t.clean(this.mapState),e.removeObject(t);this.tileObjects=[],this.identifyIds=[],this.generate()}};function ir(s,e,t){const{top:i,right:o,bottom:r,left:a}=s.viewport,{clientWidth:l,clientHeight:c}=e;s.size=[Math.max(1,l-a-o),Math.max(1,c-i-r)],t.updateFrameBuffersSize()}const rd=(s,e,t,i,o={})=>{const r=I({top:0,right:0,bottom:0,left:0},i);if(o.animate===!1||o.duration===0)s.viewport=r,ir(s,e,t);else{const a=s.viewport,l=o.easing!==void 0?o.easing:"easeOutCubic",c=o.duration!==void 0?o.duration:300;n.start("viewport",{easing:l},s,[a.top,a.right,a.bottom,a.left],[r.top,r.right,r.bottom,r.left],c,1)}},ad=(s,e,t)=>{n.update("viewport",{step:(i,o)=>{i.viewport={top:o[0],right:o[1],bottom:o[2],left:o[3]},ir(i,e,t)}},s)};function ld(s,e){return{top:s.top+e.top,bottom:s.bottom+e.bottom,left:s.left+e.left,right:s.right+e.right}}function cd(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 dd(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 _d(s,e){return dd(cd(s),e)}function nr(s,e){const{top:t,right:i,bottom:o,left:r}=s.padding;s.padding={top:t,right:i,bottom:o,left:r},e.addRerenderEvent(),e.updateFrameBuffersSize()}const ud=(s,e,t,i={})=>{const o=_d(t,s.size);if(i.animate===!1||i.duration===0)s.padding=o,nr(s,e);else{const r=s.padding,a=i.easing!==void 0?i.easing:"easeOutCubic",l=i.duration!==void 0?i.duration:300;n.start("padding",{easing:a},s,[r.top,r.right,r.bottom,r.left],[o.top,o.right,o.bottom,o.left],l,1)}},hd=(s,e)=>{n.update("padding",{step:(t,i)=>{t.padding={top:i[0],right:i[1],bottom:i[2],left:i[3]},nr(t,e)}},s)},Zi="inertia",fd=(s,e,t)=>s*Math.pow(1-(t-e)/n.inertia.duration,n.inertia.nonLinearity),md=(s,e,t,i,o)=>{n.start(Zi,{easing:"inertia"},s,0,o,n.inertia.duration,1,{startPoint:e,startSpeed:t,direction:i,startTime:s.time})},fo=n.stop.bind(null,Zi),pd=(s,e)=>{n.update(Zi,{step:(t,i,o)=>{const{startPoint:r,startSpeed:a,startTime:l,direction:c}=o,d=n.clone$1(c);n.scale(d,d,i),n.add$1(d,d,r),t.loopWorld||t.globeMode?n.isLatValid(t.maxBounds,d)||(mo(e,t),n.clampPoint(d,t.maxBounds,d)):n.contains(t.maxBounds,d)||(mo(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 _=fd(a,l,t.time);n.mapToPixelDistance(_,t.zoom)<n.inertia.minSpeed&&mo(e,t)}},s)},mo=(s,e)=>{n.stop(Zi,e),s.classList.remove("mapgl-inertia")},$i="center",Gt=(s,e,t={})=>{if(n.stop($i,s),fo(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($i,{easing:i},s,s.center,e,o,1)}},vd=n.stop.bind(null,$i),gd=n.update.bind(null,$i,{step:(s,e)=>{s.center=e,s.zoomTypePreserving==="zoom"?s.styleZoom=n.getStyleZoom(s.zoom,e):s.zoom=n.getZoomFromStyleZoom(s.styleZoom,e)}}),Wi="rotation";function po(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 yi(s,e,t={}){if(n.stop(Wi,s),t.animate===!1||t.duration===0)s.rotation=po(e,0);else{const i=t.normalize!==void 0?t.normalize:!0;n.start(Wi,{easing:t.easing||"linear"},s,s.rotation,i?po(e,s.rotation):e,t.duration||250,1)}}const yd=n.stop.bind(null,Wi),xd=n.update.bind(null,Wi,{step:(s,e)=>s.rotation=po(e,0)}),Xi="pitch";function Ki(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 bd=n.stop.bind(null,Xi),wd=n.update.bind(null,Xi,{step:(s,e)=>s.pitch=e}),qi="zoom",Et=(s,e,t={})=>{n.stop(qi,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,r=t.useHeightForAnimation?n.zoomToHeight(i,s.size):i,a=t.easing!==void 0?t.easing:"easeOutCubic",l=t.duration!==void 0?t.duration:250;n.start(qi,{easing:a},s,o,r,l,1,{zoomPoint:t.zoomPoint,useHeightForAnimation:!!t.useHeightForAnimation})}},or=n.stop.bind(null,qi),Sd=n.update.bind(null,qi,{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)}}),Td=navigator.msPointerEnabled&&navigator.msMaxTouchPoints&&!window.PointerEvent,Md=window.PointerEvent&&navigator.pointerEnabled&&navigator.maxTouchPoints||Td||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch,Ed=Vt("webkit"),Id=Vt("chrome")||Vt("crios"),Cd="ActiveXObject"in window,Ld=!Id&&Vt("safari");Vt("gecko")&&!Ed&&window.opera;const Yi=navigator.platform.toUpperCase().indexOf("MAC")>=0,Pd=Vt("windows"),Bd=Vt("firefox");function Vt(s){return navigator.userAgent.toLowerCase().indexOf(s)>=0}function xt(s){or(s),vd(s),yd(s),bd(s),fo(s)}class zd{constructor(e,t){this.onWheelScroll=i=>{this.isBlocked||(i.preventDefault(),!(i.deltaMode===void 0&&i.deltaY===void 0)&&(this.state.userHasInteracted=!0,this.screenPoint=Ee(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();Yi?o*=n.zoom.macWheelDeltaToZoomDelta:Number.isInteger(o)?o=n.sign(o)*n.zoom.wheelZoomDelta:o*=n.zoom.notMacTrackpadDeltaToZoomDelta;const r=i.zoom+o,a=n.clamp(r,i.minZoom,i.maxZoom);a!==i.zoom&&(xt(i),Et(i,a,{duration:n.zoom.animDuration,animate:!Yi,zoomPoint:i.keepCenterWhileUserZoomRotate?void 0:this.screenPoint}))},this.stop=()=>{this.state.userHasInteracted=!0,or(this.state)},this.state=e,this.container=t,Yi||(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 Rd{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),r=n.length(o);if(n.mapToPixelDistance(r,i.zoom)<=n.inertia.minSpeed)return;const l=n.pixelToMapDistance(n.inertia.maxSpeed,i.zoom),c=Math.min(r,l),d=this.calcDistanceByStartSpeed(c),_=n.clone$1(i.center),u=n.create$1();n.normalize(u,o),md(i,_,c,u,d),this.container.classList.add("mapgl-inertia")},this.stop=()=>{fo(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),Md&&(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 Fd{constructor(e){this.emitMouseEvent=t=>{if(this.isBlocked)return;const i=Ee(this.container,t.clientX,t.clientY);this.emitEvent(t,i)},this.emitTouchEvent=t=>{if(this.isBlocked)return;const i=Ee(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=>{ht(i,o,e,t,this.modules)})}}class Dd{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=Ee(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 r=n.degToRad(o.rotation);!this.rotationDetected&&Math.abs(r)>this.state.touchRotationThreshold&&(this.rotationDetected=!0,this.startRotation=this.state.rotation-r),this.rotationDetected&&(this.gestureRotation=r)},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(),r=e.keepCenterWhileUserZoomRotate?n.create$1():n.getCenterCorrection(e,this.screenPoint,{zoom:t,rotation:i});n.add$1(o,e.center,r),xt(e),Gt(e,o,{animate:!1}),Et(e,t,{animate:!1}),e.disableRotationByUserInteraction||yi(e,i,{animate:!1}),this.gestureRotation=0,this.gestureZoom=0}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}}class Od extends n.Evented{constructor(e,t){super(),this.startRenderTime=0,this.catchNextUpdate=!1,this.fpsStats=Qi(),this.badFpsStats=Qi(),this.caveatFpsStats=Qi(),this.checkBadFrameCount=0,this.countToCheck=75,this.slowFrameTime=1e3/n.performanceCheck.fpsCaveat,this.badFrameRatioToCheck=.25,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{needRerender:e,rerenderEvents:t}=this.mapState,i=performance.now(),o=i-this.startRenderTime;if(this.catchNextUpdate){if(o>0){const r=1e3/o;vo(this.fpsStats,r),vo(this.caveatFpsStats,r),o>=this.slowFrameTime&&vo(this.badFpsStats,r),r<n.performanceCheck.fpsCaveat&&this.checkBadFrameCount++}this.catchNextUpdate=!1}(e||t.length>0)&&(this.startRenderTime=i,this.catchNextUpdate=!0),this.caveatFpsStats.count>this.countToCheck&&this.check()}getFpsStats(){const e=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:go(this.fpsStats),bad:go(this.badFpsStats),isStatic:e}}hasFpsStats(){return this.fpsStats.count>0}getMemoryStats(){return K(this,null,function*(){const e=yield this.getJsMemoryStats(),t=yield this.getGpuMemoryStats();return{cpu:e,gpu:t}})}check(){const e=go(this.caveatFpsStats).avg;this.emit("fps",e),this.checkBadFrameCount/this.caveatFpsStats.count>=this.badFrameRatioToCheck&&(this.mapState.performanceCaveatEmitted=!0,this.emit("performancecaveat")),this.caveatFpsStats=Qi(),this.checkBadFrameCount=0,this.countToCheck=Math.min(1e3,this.countToCheck*2)}getJsMemoryStats(){return K(this,null,function*(){const e=yield n.getRawMemoryStats(this.mapModules);return Object.values(e).filter(o=>!!o.js).map(o=>o.js).reduce((o,r)=>o+r["--sum"],0)})}getGpuMemoryStats(){return K(this,null,function*(){const e=yield n.getRawMemoryStats(this.mapModules);return Object.values(e).filter(o=>!!o.gpu).map(o=>o.gpu).reduce((o,r)=>o+r["--sum"],0)})}}function Qi(){return{min:1/0,max:0,sum:0,count:0}}function vo(s,e){s.min=Math.min(s.min,e),s.max=Math.max(s.max,e),s.sum+=e,s.count++}function go(s){return s.count===0?{min:0,max:0,avg:0,count:0}:{min:s.min,max:s.max,avg:s.sum/s.count,count:s.count}}const Ji={Point:0,Start:1,End:2},Ai="fps",sr="frame",rr="skipped",ar=5e5,Nd=.15;class kd{constructor(e=[]){this.startTime=performance.now(),this.activeScenarios=new Set,this.entries=[],this.overflowed=!1,this.captureMode="timeline",this.aggregateStarts=new Map,this.aggregates=new Map,this.lastStartIndex=new Map;for(const t of e)this.activeScenarios.add(t)}startScenarios(e){for(const t of e)this.activeScenarios.add(t)}stopScenarios(e){for(const t of e)this.activeScenarios.delete(t)}isScenarioActive(e){return this.activeScenarios.has(e)}setCaptureMode(e){this.captureMode=e}getCaptureMode(){return this.captureMode}logTime(e,t){this.activeScenarios.has(e)&&this.shouldCaptureTimeline()&&this.push(e,t,Ji.Point)}logStartTime(e,t){var l,c;if(!this.activeScenarios.has(e))return;const i=performance.now()-this.startTime,o=`${e}/${t}`;if(this.shouldCaptureSummary()){const d=(l=this.aggregateStarts.get(o))!=null?l:[];d.push(i),this.aggregateStarts.set(o,d)}if(!this.shouldCaptureTimeline())return;const r=this.entries,a=r.length;if(a>0){const d=r[a-1];if(d[3]===Ji.End&&d[0]===e&&d[1]===t&&i-d[2]<=Nd){r.length=a-1;const _=this.lastStartIndex.get(o);if(_!==void 0){const u=r[_];u[4]=((c=u[4])!=null?c:1)+1}return}}this.push(e,t,Ji.Start,i),this.lastStartIndex.set(o,this.entries.length-1)}logEndTime(e,t){if(!this.activeScenarios.has(e))return;const i=performance.now()-this.startTime;this.shouldCaptureSummary()&&this.recordAggregate(e,t,i),this.shouldCaptureTimeline()&&this.push(e,t,Ji.End,i)}getLogTimes(){return this.entries}getLogTimeAggregates(){return Array.from(this.aggregates.values(),e=>I({},e))}clearLogTimes(){this.entries.length=0,this.overflowed=!1,this.lastStartIndex.clear(),this.aggregateStarts.clear(),this.aggregates.clear()}getStartTime(){return this.startTime}destroy(){this.activeScenarios.clear(),this.entries.length=0,this.overflowed=!1,this.lastStartIndex.clear(),this.aggregateStarts.clear(),this.aggregates.clear()}push(e,t,i,o){if(this.entries.length>=ar){this.overflowed||(this.overflowed=!0,console.warn(`[Profiler] entries buffer reached ${ar}, further samples dropped. Call clearLogTimes() to reset.`));return}this.entries.push([e,t,o!=null?o:performance.now()-this.startTime,i])}shouldCaptureTimeline(){return this.captureMode==="timeline"}shouldCaptureSummary(){return this.captureMode==="summary"}recordAggregate(e,t,i){var c,d;const o=`${e}/${t}`,r=(c=this.aggregateStarts.get(o))==null?void 0:c.pop();if(r===void 0)return;const a=i-r,l=(d=this.aggregates.get(o))!=null?d:{scenario:e,name:t,totalMs:0,count:0,maxMs:0};l.totalMs+=a,l.count++,l.maxMs=Math.max(l.maxMs,a),this.aggregates.set(o,l)}}class Ud{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 Hd{constructor(e){this.onTouchStart=()=>{this.isTouchStartEmitted=!0},this.onMouseOut=t=>{if(!this.prevGeo)return;const i=Ee(this.container,t.clientX,t.clientY);ht("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=Ee(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 r=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||r)&&(ht("mouseout",this.prevGeo,t,i,this.modules),this.prevGeo=void 0,this.container.classList.remove("mapgl-hover"),this.modules.defaultSource.resetHoverId()),o&&(!this.prevGeo||r)&&(this.prevGeo=o,this.container.classList.add("mapgl-hover"),ht("mouseover",o,t,i,this.modules),this.modules.defaultSource.setHoverId(o.id)),ht("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 lr=(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)},Gd=(s,e,t)=>n.update.call(null,"buildingHeight"+t,{step:(i,o)=>e.set(t,o),complete:i=>i.needLabeling=!0},s),Vd=16;class jd{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()&&Gd(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:Vd;return this.state.styleZoom<e?0:1}updateByZoom(e,t){const i=this.state,o=n.get("buildingHeight"+e,i),r=o!==void 0?o.to:t;i.styleZoom>=e&&this.modules.tileManager.viewportTilesReady()&&r!==1?lr(i,this.buildingHeights,{animate:!0,easing:n.buildingAnimation.easing,from:t,to:1,duration:n.buildingAnimation.duration*(1-t)},e):i.styleZoom<e&&r!==0&&lr(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 Z=class Z{constructor(e=null,t={}){this._src=null,this._glContext=null,this._texture=null,this._src=e,this.options=Object.assign({},Z.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){var l;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 r=this._toGlParam(o,this.options.format),a=this._toGlParam(o,(l=this.options.type)!=null?l:Z.UnsignedByte);return r===null||a===null?this:(o.texSubImage2D(o.TEXTURE_2D,0,t,i,r,a,e),this.options.generateMipmaps&&this.options.minFilter!==Z.NearestFilter&&this.options.minFilter!==Z.LinearFilter&&(console.warn("[WebGL] Generating mipmaps for texture after subImage update"),o.generateMipmap(o.TEXTURE_2D)),this)}prepare(e){var d,_,u;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,(d=this.options.type)!=null?d:Z.UnsignedByte),o=this._toGlParam(e,this.options.wrapS),r=this._toGlParam(e,this.options.wrapT),a=this._toGlParam(e,(_=this.options.magFilter)!=null?_:Z.LinearFilter),l=this._toGlParam(e,(u=this.options.minFilter)!=null?u:Z.LinearMipMapLinearFilter),c=this.options.compareFunc?this._toGlParam(e,this.options.compareFunc):null;if(t!==null&&i!==null){const h=this.hookInternalFormat(t,i,e);ArrayBuffer.isView(this._src)||this._src===null?this.options.size&&e.texImage2D(e.TEXTURE_2D,0,h,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&&r!==null&&(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,o),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,r)),a!==null&&l!==null&&(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,a),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!==Z.NearestFilter&&this.options.minFilter!==Z.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(){var t,i,o,r;if(!this._texture)return 0;const e=((i=(t=this.options.size)==null?void 0:t[0])!=null?i:0)*((r=(o=this.options.size)==null?void 0:o[1])!=null?r:0)*4;return e>0?e:this._src!==null?this.memSizeJs():0}_toGlParam(e,t){return t===Z.ClampToEdgeWrapping?e.CLAMP_TO_EDGE:t===Z.Repeat?e.REPEAT:t===Z.MirroredRepeat?e.MIRRORED_REPEAT:t===Z.NearestFilter?e.NEAREST:t===Z.NearestMipMapNearestFilter?e.NEAREST_MIPMAP_NEAREST:t===Z.NearestMipMapLinearFilter?e.NEAREST_MIPMAP_LINEAR:t===Z.LinearFilter?e.LINEAR:t===Z.LinearMipMapNearestFilter?e.LINEAR_MIPMAP_NEAREST:t===Z.LinearMipMapLinearFilter?e.LINEAR_MIPMAP_LINEAR:t===Z.RgbaFormat?e.RGBA:t===Z.AlphaFormat?e.ALPHA:t===Z.RgbFormat?e.RGB:t===Z.DepthComponentFormat?e.DEPTH_COMPONENT:t===Z.UnsignedByte?e.UNSIGNED_BYTE:t===Z.UnsignedShort?e.UNSIGNED_SHORT:t===Z.Float?e.FLOAT:t===Z.UnsignedInt?e.UNSIGNED_INT:e instanceof WebGLRenderingContext?null:t===Z.RedFormat?e.RED:t===Z.CompareRefToTexture?e.COMPARE_REF_TO_TEXTURE:t===Z.CompareNone?e.NONE:t===Z.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}};Z.ClampToEdgeWrapping=1,Z.Repeat=2,Z.MirroredRepeat=3,Z.NearestFilter=4,Z.NearestMipMapNearestFilter=5,Z.NearestMipMapLinearFilter=6,Z.LinearFilter=7,Z.LinearMipMapNearestFilter=8,Z.LinearMipMapLinearFilter=9,Z.DepthComponentFormat=10,Z.DepthComponentFormat32=11,Z.RgbaFormat=14,Z.AlphaFormat=15,Z.RgbFormat=16,Z.UnsignedByte=17,Z.Float=18,Z.UnsignedShort=19,Z.UnsignedInt=20,Z.RedFormat=21,Z.CompareNone=22,Z.CompareRefToTexture=23,Z.defaultOptions={magFilter:Z.LinearFilter,minFilter:Z.LinearMipMapLinearFilter,wrapS:Z.ClampToEdgeWrapping,wrapT:Z.ClampToEdgeWrapping,format:Z.RgbaFormat,generateMipmaps:!0,flipY:!0,premultiplyAlpha:!0,type:Z.UnsignedByte};let w=Z;function en(s){if(s===void 0)return;const e=window.WebGLRenderingContext,i={[e.CLAMP_TO_EDGE]:w.ClampToEdgeWrapping,[e.REPEAT]:w.Repeat,[e.MIRRORED_REPEAT]:w.MirroredRepeat,[e.NEAREST]:w.NearestFilter,[e.NEAREST_MIPMAP_NEAREST]:w.NearestMipMapNearestFilter,[e.NEAREST_MIPMAP_LINEAR]:w.NearestMipMapLinearFilter,[e.LINEAR]:w.LinearFilter,[e.LINEAR_MIPMAP_NEAREST]:w.LinearMipMapNearestFilter,[e.LINEAR_MIPMAP_LINEAR]:w.LinearMipMapLinearFilter,[e.RGBA]:w.RgbaFormat,[e.ALPHA]:w.AlphaFormat,[e.RGB]:w.RgbFormat,[e.UNSIGNED_BYTE]:w.UnsignedByte,[e.FLOAT]:w.Float}[s];return i===void 0?(console.error(`Failed to translate texture parameter ${s}`),NaN):i}const co=class co{constructor(e={}){this._texture=null,this._glContext=null,this._frameBuffer=null,this._depthAttachment=null,this.options=Object.assign({},co.defaultOptions,e),this.options.hasColorOutput&&(this._texture=new w(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){var t,i;if(this._glContext=e,!this._texture&&this.options.hasColorOutput&&(this._texture=new w(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 o=this._depthAttachment=new w(null,{magFilter:(t=this.options.magFilter)!=null?t:w.NearestFilter,minFilter:(i=this.options.minFilter)!=null?i:w.NearestFilter,format:w.DepthComponentFormat,size:this.options.size,premultiplyAlpha:!1,generateMipmaps:!1,type:w.UnsignedInt,compareFunc:this.options.compareFunc});o.prepare(e),e.framebufferTexture2D(e.FRAMEBUFFER,e.DEPTH_ATTACHMENT,e.TEXTURE_2D,o.getTexture(),0)}else{const o=this.options.useHighDepthPrecision?e.DEPTH_STENCIL:this.options.depthInternalFormat,r=this.options.useHighDepthPrecision?e.DEPTH_STENCIL_ATTACHMENT:e.DEPTH_ATTACHMENT;this._depthAttachment=e.createRenderbuffer(),e.bindRenderbuffer(e.RENDERBUFFER,this._depthAttachment),e.renderbufferStorage(e.RENDERBUFFER,o,this.options.size[0],this.options.size[1]),e.framebufferRenderbuffer(e.FRAMEBUFFER,r,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 w?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}`)}}};co.defaultOptions=Object.assign({},w.defaultOptions,{size:[0,0],generateMipmaps:!1,depthTexture:!1,hasColorOutput:!0,useHighDepthPrecision:!1,depthInternalFormat:WebGLRenderingContext.DEPTH_COMPONENT16});let Ce=co;function tn(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 yo={};function Zd(s){const e=String(s);return yo[e]===void 0&&(yo[e]=$d(s)),yo[e]}function $d(s){const e=tn(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(i){return{ok:!1,msg:"readPixels is not supported"}}let t;try{t=e.createShader(e.VERTEX_SHADER)}catch(i){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 jt;function cr(){jt=void 0;const s=new Float32Array([-1,-1,1,-1,-1,1]),e=2,t=tn(!1);if(!t)return jt="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 jt=`Absent ${m} extension`,!1;const i=new Ce({size:[e,e]});i.bind(t);const o=new w(new Float32Array([1,0,1,0]),{size:[2,2],format:w.AlphaFormat,type:w.Float,magFilter:w.LinearFilter,minFilter:w.LinearFilter}).prepare(t),r=`attribute vec2 pos;
    void main () {
        gl_Position = vec4(pos, 0, 1);
    }`,a=`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 jt="Cannot create shaders",!1;t.shaderSource(l,r),t.compileShader(l),t.shaderSource(c,a),t.compileShader(c);const d=t.createProgram();if(!d)return jt="Cannot compile shader program",!1;t.attachShader(d,l),t.attachShader(d,c),t.linkProgram(d),t.useProgram(d);const _=t.createBuffer();if(!_)return jt="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 Wd(){return jt}let rt=null;function ti(){if(rt!==null)return rt;const s=tn(!1);if(!s)return rt=!0,rt;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 rt=!0,rt;s.shaderSource(i,e),s.compileShader(i),s.shaderSource(o,t),s.compileShader(o);const r=s.createProgram();return!r||(s.attachShader(r,i),s.attachShader(r,o),s.linkProgram(r),!r||!s.getProgramParameter(r,s.LINK_STATUS))?(rt=!0,rt):(rt=!1,rt)}function Xd(){const s=tn(!1);if(!s)return!1;if(!Pd)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 dr(s){return s instanceof WebGLRenderingContext?!!s.getExtension("WEBGL_depth_texture"):!0}function Kd(s){return!_r(s)}function _r(s){if(!qd())return"not a browser";if(!Qd())return"insufficient Function support";if(!Ad())return"insufficient JSON support";if(!e_())return"insufficient worker support";if(!i_())return"insufficient ArrayBuffer support";if(!n_())return"insufficient Canvas/getImageData support";const e=Zd(s&&s.failIfMajorPerformanceCaveat||!1);if(!e.ok)return`insufficient WebGL support${e.msg?`: ${e.msg}`:""}`;if(!Yd())return"insufficient Array support";if(!Jd())return"insufficient Object support";if(!t_())return"insufficient DOM support";if(!o_())return"insufficient ECMAScript 6 support"}function qd(){return typeof window!="undefined"&&typeof document!="undefined"}function Yd(){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 Qd(){var s;return typeof((s=Function.prototype)==null?void 0:s.bind)=="function"}function Jd(){return!!(Object.keys&&Object.assign&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.freeze)}function Ad(){return"JSON"in window&&"parse"in JSON&&"stringify"in JSON}function e_(){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(o){t=!1}return i&&i.terminate(),URL.revokeObjectURL(e),t}function t_(){const s=document.createElement("div");return s&&typeof s.after=="function"}function i_(){return!!ArrayBuffer.isView}function n_(){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 o_(){return!("documentMode"in document)}function s_(){return Wd()}const r_=Xd,a_=()=>K(null,null,function*(){if(!navigator)return!1;try{const s=navigator.gpu;if(typeof(s==null?void 0:s.requestAdapter)!="function"||!(yield s.requestAdapter({powerPreference:"high-performance"}))||!document.createElement("canvas").getContext("webgpu",{}))return!1}catch(s){return!1}return!0});class ft{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 l_{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 dr(this._gl)}isShadowSamplerSupported(){return!(this._gl instanceof WebGLRenderingContext)&&this.isDepthTextureSupported()}isContextLost(){return this._gl.isContextLost()}storeGpuState(e){var i,o,r,a;const t=this._gl;this._storedStates[e]={depthMask:(i=this._lastState.depthMask)!=null?i:t.getParameter(t.DEPTH_WRITEMASK),depthTest:(o=this._lastState.depthTest)!=null?o:t.getParameter(t.DEPTH_TEST),depthFunc:(r=this._lastState.depthFunc)!=null?r:t.getParameter(t.DEPTH_FUNC),clearDepth:(a=this._lastState.clearDepth)!=null?a: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,r){const a=this._gl,l=this.webGlExtensions.ANGLE_instanced_arrays;if(a instanceof WebGLRenderingContext){if(!l)return;l.drawElementsInstancedANGLE(e,t,i,o,r)}else a.drawElementsInstanced(e,t,i,o,r)}drawInstancedArrays(e,t,i,o){const r=this._gl,a=this.webGlExtensions.ANGLE_instanced_arrays;if(r instanceof WebGLRenderingContext){if(!a)return;a.drawArraysInstancedANGLE(e,t,i,o)}else r.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){var r,a,l,c,d,_,u,h,f,m,p,v,x,g,y,b,S,T;const i=this._gl;if(i.depthMask((r=t==null?void 0:t.depthMask)!=null?r:e.depthMask),((a=t==null?void 0:t.depthTest)!=null?a:e.depthTest)?(i.enable(i.DEPTH_TEST),this.setDepthFunc((l=t==null?void 0:t.depthFunc)!=null?l:e.depthFunc)):i.disable(i.DEPTH_TEST),((c=t==null?void 0:t.cullFace)!=null?c:e.cullFace)?(i.enable(i.CULL_FACE),this.setCullFaceMode((d=t==null?void 0:t.cullFaceMode)!=null?d:e.cullFaceMode)):i.disable(i.CULL_FACE),(_=t==null?void 0:t.blend)!=null?_:e.blend){i.enable(i.BLEND),this.setBlendEquation((u=t==null?void 0:t.blendEquation)!=null?u:e.blendEquation);const z=(h=t==null?void 0:t.blendFuncSeparate)!=null?h:e.blendFuncSeparate;z?this.setBlendFuncSeparate(z.srcRgb,z.dstRgb,z.srcAlpha,z.dstAlpha):this.setBlendFunc((m=(f=t==null?void 0:t.blendFunc)==null?void 0:f.sfactor)!=null?m:e.blendFunc.sfactor,(v=(p=t==null?void 0:t.blendFunc)==null?void 0:p.dfactor)!=null?v:e.blendFunc.dfactor)}else i.disable(i.BLEND);const o=(x=t==null?void 0:t.colorMask)!=null?x:e.colorMask;i.colorMask(o[0],o[1],o[2],o[3]),((g=t==null?void 0:t.polygonOffsetFill)!=null?g:e.polygonOffsetFill)?(i.enable(i.POLYGON_OFFSET_FILL),i.polygonOffset((b=(y=t==null?void 0:t.polygonOffset)==null?void 0:y.factor)!=null?b:e.polygonOffset.factor,(T=(S=t==null?void 0:t.polygonOffset)==null?void 0:S.units)!=null?T:e.polygonOffset.units)):i.disable(i.POLYGON_OFFSET_FILL)}setDepthFunc(e){const t=ft.depthFuncToWebGL(this._gl,e);this._gl.depthFunc(t)}setCullFaceMode(e){const t=ft.cullFaceModeToWebGL(this._gl,e);this._gl.cullFace(t)}setBlendFunc(e,t){const i=ft.blendFuncToWebGL(this._gl,e),o=ft.blendFuncToWebGL(this._gl,t);this._gl.blendFunc(i,o)}setBlendFuncSeparate(e,t,i,o){const r=ft.blendFuncToWebGL(this._gl,e),a=ft.blendFuncToWebGL(this._gl,t),l=ft.blendFuncToWebGL(this._gl,i),c=ft.blendFuncToWebGL(this._gl,o);this._gl.blendFuncSeparate(r,a,l,c)}setBlendEquation(e){const t=ft.blendEquationToWebGL(this._gl,e);this._gl.blendEquation(t)}setBlendEquationSeparate(e,t){const i=ft.blendEquationToWebGL(this._gl,e),o=ft.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=a=>(this._lastState.depthMask=a,e(a));const t=this._gl.enable.bind(this._gl);this._gl.enable=a=>(a===this._gl.DEPTH_TEST&&(this._lastState.depthTest=!0),t(a));const i=this._gl.disable.bind(this._gl);this._gl.disable=a=>(a===this._gl.DEPTH_TEST&&(this._lastState.depthTest=!1),i(a));const o=this._gl.depthFunc.bind(this._gl);this._gl.depthFunc=a=>(this._lastState.depthFunc=a,o(a));const r=this._gl.clearDepth.bind(this._gl);this._gl.clearDepth=a=>(this._lastState.clearDepth=a,r(a))}}class c_{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")}}const Hi=class Hi{constructor(e,t,i){this._gl=e,this.uniforms={},this.attributes={},this._webglProgram=null,this._linked=!1,this._located=!1,this._error=!1,this._uniformBlocksIndices={},this._uboBindings={},this._uniformBlocksMap=null,t=t||{},t.uniforms=t.uniforms||[],t.uniforms.forEach(o=>{this.uniforms[o.name]=new c_(o)}),t.attributes=t.attributes||[],t.attributes.forEach(o=>{this.attributes[o.name]=new n.ShaderAttribute(o)}),i=i!=null?i:n.EMPTY_SHADER_DEFINITIONS,this._vertexShader=t.buildVertex(i),this._fragmentShader=t.buildFragment(i)}static getStableUboBinding(e){const t=Hi.fixedUboBindings[e];if(t!==void 0)return t;console.error(`Unknown UBO block "${e}". Add a fixed binding for it.`)}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 r=o.filter(c=>c!==t.INVALID_INDEX),a=t.getActiveUniforms(i,r,t.UNIFORM_OFFSET);if(a===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 _=r.indexOf(d);l[e[c]]=a[_]}}return l}getUniformBlocksMap(){if(this._uniformBlocksMap)return this._uniformBlocksMap;if(this._gl instanceof WebGLRenderingContext)return null;const e=this._gl;let t=this._webglProgram;if(t||(this.link(),this.locate()),t=this._webglProgram,!t)return null;this._uniformBlocksMap={};const i=e.getProgramParameter(t,e.ACTIVE_UNIFORM_BLOCKS);for(let o=0;o<i;o++){const r=e.getActiveUniformBlockName(t,o);if(!r)continue;const a=e.getActiveUniformBlockParameter(t,o,e.UNIFORM_BLOCK_ACTIVE_UNIFORMS);if(a===null){console.error("Couldn't get number of uniforms in UBO.");continue}const l=e.getActiveUniformBlockParameter(t,o,e.UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES);if(!l){console.error("Couldn't get uniforms indices in UBO.");continue}const c=[];for(let d=0;d<a;d++){const _=e.getActiveUniform(t,l[d]);_&&c.push(_.name)}this._uniformBlocksMap[r]=c}return this._uniformBlocksMap}locateUniformBlocks(e){const t=this._gl;if(t instanceof WebGLRenderingContext)return;const i=this.getUniformBlocksMap();if(i)for(const o in i){const r=t.getUniformBlockIndex(e,o);if(r!==t.INVALID_INDEX){const a=Hi.getStableUboBinding(o);if(a===void 0)continue;this._uniformBlocksIndices[o]=r,this._uboBindings[o]=a,t.uniformBlockBinding(e,r,a)}}}};Hi.fixedUboBindings={CommonSettings:0,LightSettings:1};let xo=Hi;const ur=[1,1,1,1],d_=3.7,__=n.create$1(),u_=n.create$1(),hr=n.create$2(),h_=n.create$2(),f_=n.create$1(),m_=n.fromValues(0,1,0),fr=(s,e,t,i)=>{mt(t,s,{u_float_rounding_factor:e.stillness},i)},xi=(s,e,t,i)=>{mt(t,s,{u_float_border_width_offset:1/window.devicePixelRatio},i)},nn=(s,e,t,i)=>{const o=(n.POINT_CENTER_SIZE-.5)/2,{size:r}=e;mt(t,s,{u_vec2_depth_test_half_point_size:[o/r[0],o/r[1]]},i)},W=(s,e,t,i)=>{if(!t.environmentManager.isFogEnabled())return;const o=t.styleManager.getStyle(e.handyStyleId);let r=ur,a=ur;if(o){const _=n.makeBinderContext(e.styleZoom,e.styleState,[]);r=n.getColorForShaders(n.resolveColor(o.environment.style.skyColor,_)),a=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),d_);mt(t,s,{u_sky_color:e.globeMode?[0,0,0,0]:r,u_fog_color:e.globeMode?[0,0,0,0]:a,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)},$=(s,e,t,i)=>{mt(t,s,{u_cam_pos:t.camera.position},i)},A=(s,e,t,i)=>{t.shadowManager.texture&&mt(t,s,{u_shadow_map_params:t.shadowManager.shadowMapParams,u_shadow_bias:t.shadowManager.bias,u_mat4_clip_to_shadow:t.shadowManager.clipToShadowMatrix},i)},bi=(s,e,t,i)=>{mt(t,s,{u_vec2_scale_limits:[0,n.z0Scale]},i)},mr=(s,e,t,i)=>{const o=t.camera.viewMatrixTranspose,r=t.camera.projectionMatrixInverse;mt(t,s,{u_mat4_view_transposed:o,u_mat4_proj_inverted:r},i)},bo=(s,e,t,i)=>{const o=window.devicePixelRatio,r=t.camera.ecef.pixelRadius*o,{left:a,bottom:l,top:c,right:d}=e.padding,[_,u]=e.size,h=[_*o,u*o],f=[(a-d)*o/2,(l-c)*o/2],m=t.environmentManager.globHaloStops.map(b=>(r+b*o)/h[1]),p=t.styleManager.getStyle(e.handyStyleId);if(!p)return;const v=p==null?void 0:p.environment;if(!v)return;const x=n.makeBinderContext(e.styleZoom,e.styleState,[]),g=n.resolveColor(v.style.fogColor,x),y=n.resolveColor(p.background.color,x);mt(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(g),u_float_halo_exp_factor:t.environmentManager.globeHaloExpFactor,u_vec4_default_background_color:n.getColorForShaders(y)},i)},pr=(s,e,t,i)=>{const o=e.size,r=Math.max(o[0],o[1]),a=o[0]/r,l=o[1]/r;n.ortho(hr,-a/2,a/2,-l/2,l/2,.001,1);const c=n.Mercator.toGeo(e.center),d=n.set(u_,0,0,0),_=n.set(__,0,0,1);n.rotateX(_,_,d,n.degToRad(c[1])),n.rotateY(_,_,d,n.degToRad(c[0]));const u=n.lookAt(h_,f_,_,m_);n.multiply(u,hr,u);const h=t.styleManager.getStyle(e.handyStyleId);if(!h)return;const f=h==null?void 0:h.environment;if(!f)return;const m=n.makeBinderContext(e.styleZoom,e.styleState,[]),p=n.resolveNumber(f.style.starsIntensity,m);mt(t,s,{u_float_pixelratio:window.devicePixelRatio,u_float_stars_intensity:p,u_mat4_stars:u},i)},ue=(s,e,t,i)=>{const{size:o}=e,r=window.devicePixelRatio;mt(t,s,{u_vec2_vpt_size:[o[0]*r,o[1]*r]},i)};function mt(s,e,t,i){i?i.updateData(e,t):s.renderer.bindShaderProgram(e,t)}function X(...s){return(e,t,i,o)=>{s.forEach(r=>r(e,t,i,o))}}const p_=X(fr,xi,nn,W,$,A,bi,mr,bo,pr,ue),vr=X($,W),gr=(s,e,t)=>{const{size:i}=e,o=window.devicePixelRatio;if(e.demMode){const r=t.renderer.getFramebuffer(t.demManager.getFlatFramebufferId());if(!r)return;t.renderer.bindShaderProgram(s,{u_vec2_vpt_size:[Math.trunc(r.renderTarget.options.size[0]),Math.trunc(r.renderTarget.options.size[1])]})}else t.renderer.bindShaderProgram(s,{u_vec2_vpt_size:[i[0]*o,i[1]*o]})},wi=(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]})},yr=(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]})},on=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_height_factor:t.buildingHeightAnimator.getDefaultBuildingHeight()})},sn=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_z_offset:0})},v_=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_z_offset:-1e-5})},pt=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_sr2d_texture:0})},xr=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_sr2d_texture1:1})},br=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_vec4_border_color:[0,0,0,0]})},wr=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_vec4_space_color:[0,0,0,0]})},g_=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_identify_opacity:e.iconIdentifyOpacity})},Sr=(s,e,t)=>{const{renderer:i}=t,{labelingTextureBuffer:o,spriteLabelingTextureBuffer:r}=i;let a=e.isLabelingDepthTestDisabled;if(!a){const c=o.getDepthAttachment(),d=o.getTexture();!(c instanceof w)||!d?a=!0:(t.renderer.enableTexture(d,Ml),t.renderer.enableTexture(c,El))}const l=r.getTexture();l&&(t.renderer.enableTexture(l,Il),t.renderer.bindShaderProgram(s,{u_color_text_sprite_labeling:Il})),t.renderer.bindShaderProgram(s,{u_bool_depth_test_disable:a}),a||t.renderer.bindShaderProgram(s,{u_color_tex_labeling:Ml,u_depth_tex_labeling:El})};function Si(...s){return(e,t,i)=>{s.forEach(o=>o(e,t,i))}}function Pe(...s){return(e,t,i,o,r)=>{s.forEach(a=>a(e,t,i,o,r))}}const y_=1,x_=2,b_=4,re=(s,e,t,i,o)=>{let r=n.ReservedLightingMode.none,a=n.DEFAULT_LIGHTING_MODES[r],l=0;const c=Tr(i,t,e);c&&(a=c.lightConfig,r=c.lightingMode,l=(r===n.ReservedLightingMode.none||o?0:y_)+(i.receiveShadows!==!1&&a.shadowLightIndex===0?x_:0)+(i.receiveShadows!==!1&&a.shadowLightIndex===1?b_:0));const d=t.renderer.getUbo(r);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:a.dir1Direction,u_vec4_light_dir1_color:a.dir1ColorIntensity,u_vec3_light_dir2_direction:a.dir2Direction,u_vec4_light_dir2_color:a.dir2ColorIntensity,u_vec4_ambient_color:a.ambientColorIntensity})},vt=(s,e,t,i)=>{const o=n.makeBinderContext(e.styleZoom,e.styleState,[],!1),r=n.resolveNumber(i.style.nearCameraFade,o);t.renderer.bindShaderProgram(s,{u_sdtr_distance:r})},rn=(s,e,t,i)=>{const o=n.makeBinderContext(e.styleZoom,e.styleState,[],!1),r=i.style.showRatio,a=n.resolveExpression(r,o);t.renderer.bindShaderProgram(s,{u_float_show_ratio:a})};function Tr(s,e,t){var a;const i=e.styleManager.getStyle(t.handyStyleId);if(!i||!i.light.lightingModesResolved)return null;let o=(a=s.lightingMode)!=null?a:i.light.defaultLightMode;s.type==="gltfModel"&&s.style.ignoreGlobalLighting&&(o=n.ReservedLightingMode.none);let r=i.light.lightingModesResolved[o];return r||(r=i.light.lightingModesResolved[i.light.defaultLightMode]),{lightingMode:o,lightConfig:r}}class H{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 a of e)Object.assign(i,a._attributes),Object.assign(o,a.attributesAliases);const r=new H(t._shaderProgram,i,t.indicesBuffer);return r.setAttributesAliases(o),r}copy(){const e=new H(this._shaderProgram,I({},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 r in i){const l=this.attributesAliases[r]||r,c=o[l];if(!c)continue;const d=i[r];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!="undefined"&&"WebGL2RenderingContext"in window&&e instanceof WebGL2RenderingContext}updateDirtyBuffers(){const e=this._shaderProgram.attributes,t=this._attributes,i=this.attributesAliases;for(const o in e){const r=i[o]||o,a=t[r];a!=null&&a.isDirty&&a.commitData()}this.isDirty=!1}}const w_=(s,e)=>{const t=n.PolygonGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0});return new H(e,{a_vec3_vertex:i})},S_=(s,e)=>{const t=n.PolygonGenerator.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:1,dataType:n.Buffer.UnsignedShort,stride:t,offset:8,normalized:!1});return new H(e,{a_vec3_vertex:i,a_float_mix_factor:o})},T_=(s,e)=>{const t=n.PolygonGenerator.sinks.shadow.stride,i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0});return new H(e,{a_vec3_vertex:i})},M_=(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 H(e,{a_vec2_vertex:i,a_vec2_texcoord:o})},E_=(s,e)=>{const t=n.PolygonGenerator.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:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:8,normalized:!0});return new H(e,{a_vec3_vertex:i,a_vec4_identifier:o})},I_=(s,e)=>{const t=n.LineGenerator.sinks.solid.stride,i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1});return new H(e,{a_vec3_vertex:i,a_vec4_normals:o})},C_=(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}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1});return new H(e,{a_vec3_vertex:i,a_vec4_normals:o,a_float_height:r,a_float_abs_z:a})},L_=(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}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8,normalized:!1}),a=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 H(e,{a_vec2_vertex:i,a_vec4_normals:o,a_float_height:r,a_float_abs_z:a,a_vec4_identifier:l})},P_=(s,e)=>{const t=n.ShiftedLineGenerator.sinks.solid.stride,i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=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.Float,stride:t,offset:12,normalized:!1});return new H(e,{a_vec3_vertex:i,a_vec4_normals:o,a_vec2_shift:r})},B_=(s,e)=>{const t=n.LineGenerator.sinks.solid.stride,i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0});return new H(e,{a_vec3_vertex:i,a_vec4_normals:o,a_vec4_identifier:r})},z_=(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}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0});return new H(e,{a_vec2_vertex:i,a_vec2_widen:o,a_float_texture:r,a_vec4_identifier:a})},R_=(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}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8}),a=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 H(e,{a_vec2_vertex:i,a_vec2_widen:o,a_float_texture:r,a_float_height:a,a_vec4_identifier:l})},Mr=(s,e)=>{const t=n.DashedLineGenerator.sinks.stroke.stride,i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:6,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),a=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:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:24,normalized:!0});return new H(e,{a_vec3_vertex:i,a_vec2_texture_widen:o,a_vec2_widen:r,a_float_vertex_distance:a,a_float_component_distance:l,a_float_object_length:c,a_vec4_identifier:d})},Er=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),a=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 H(e,{a_vec3_vertex:i,a_vec2_texture_widen:r,a_vec2_widen:o,a_float_vertex_distance:a,a_float_component_distance:l,a_float_object_length:c,a_float_height:d,a_vec4_identifier:_})},Ir=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:32,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:32,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:32,offset:12,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:32,offset:16,normalized:!1}),l=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:32,offset:24,normalized:!0}),c=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:32,offset:28,normalized:!0});return new H(e,{a_vec3_vertex:i,a_vec2_offset:o,a_vec2_texcoord:r,a_vec2_check_offset:a,a_vec4_tex_identifier:l,a_vec4_sprite_identifier:c})},F_=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:32,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:32,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:32,offset:20,normalized:!0});return new H(e,{a_vec3_vertex:i,a_vec2_offset:o,a_vec4_identifier:r})},an=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:28,offset:12,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:28,offset:20,normalized:!1});return new H(e,{a_vec4_position:i,a_vec2_offset:r,a_vec2_texcoord:o,a_vec2_style_zoom_limits:a})},Cr=(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}),r=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),a=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}),u=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:28,normalized:!0});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec3_normal:r,a_float_gradient:a,a_vec2_dem_position:l,a_float_abs_z:c,a_vec4_identifier:d,a_float_is_pivot:_,a_vec4_color:u})},D_=(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}),r=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),a=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 H(e,{a_vec2_vertex:i,a_float_z:o,a_vec3_normal:r,a_float_gradient:a,a_vec2_dem_position:l,a_float_abs_z:c,a_vec4_identifier:_,a_float_is_pivot:d})},Lr=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),a=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 H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r,a_float_abs_z:a,a_float_is_pivot:l})},ln=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),a=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}),c=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:16,normalized:!0});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r,a_float_abs_z:a,a_float_is_pivot:l,a_vec4_identifier:c})},O_=(s,e)=>{const t=n.MeshGenerator.sinks.depthClear.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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),a=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 H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r,a_float_abs_z:a,a_float_is_pivot:l})},N_=(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}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),a=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 H(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_direction_distance:r,a_vec2_dem_position:a,a_float_abs_z:l,a_float_is_pivot:c})},Pr=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1}),a=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:24,normalized:!1}),l=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!0});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r,a_vec4_color:l,a_float_elevation:a})},k_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),a=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}),c=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:24,normalized:!0});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r,a_vec2_wall_size:a,a_vec2_quad_fraction:l,a_vec4_color:c})},Br=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!0});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r,a_vec4_color:a})},zr=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}),r=new n.BufferChannel(e,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:s,offset:8,normalized:!0}),a=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.Short,stride:s,offset:12,normalized:!1});return new H(t,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:r,a_vec2_dem_position:a})},Rr=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}),r=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.Short,stride:s,offset:12,normalized:!1}),a=new n.BufferChannel(e,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:s,offset:16,normalized:!0});return new H(t,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:a,a_vec2_dem_position:r})},Fr=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}),r=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.Short,stride:s,offset:12,normalized:!1});return new H(t,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r})},U_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r,a_vec4_color:a})},H_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r})},Dr=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:24,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:24,offset:4,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:24,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:24,offset:10,normalized:!1}),l=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:24,offset:12,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Byte,stride:24,offset:15,normalized:!1}),d=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:24,offset:16,normalized:!1}),_=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:24,offset:20,normalized:!0});return new H(e,{a_vec3_vertex:i,a_float_z:o,a_vec2_normal:r,a_vec2_normal_delta:a,a_vec3_direction:l,a_float_distance:c,a_vec2_dem_position:d,a_vec4_color:_})},G_=(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:2,dataType:n.Buffer.Short,stride:36,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:36,offset:12,normalized:!1}),a=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.Short,stride:36,offset:20,normalized:!1}),c=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:28,normalized:!0});return new H(e,{a_vec3_vertex:i,a_vec2_offset:o,a_vec2_texcoord:r,a_vec2_range:a,a_vec2_check_offset:l,a_vec4_tex_identifier:c})},V_=(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:2,dataType:n.Buffer.Short,stride:36,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:36,offset:12,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:16,normalized:!1}),l=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:32,normalized:!0});return new H(e,{a_vec3_vertex:i,a_vec2_offset:o,a_vec2_texcoord:r,a_vec2_range:a,a_vec4_identifier:l})},j_=(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:2,dataType:n.Buffer.Short,stride:36,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:36,offset:12,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:16,normalized:!1}),l=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:24,normalized:!0});return new H(e,{a_vec3_vertex:i,a_vec2_offset:o,a_vec2_texcoord:r,a_vec2_range:a,a_vec4_identifier:l})},Z_=(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}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:16,offset:12,normalized:!0});return new H(e,{a_vec4_position:i,a_vec2_offset:o,a_vec4_identifier:r})},Or=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:12,offset:10,normalized:!1});return new H(e,{a_vec2_position:i,a_vec2_direction:o,a_vec2_widen_direction:r})},$_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_texcoord:r,a_vec2_dem_position:a})},W_=(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}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:r,a_vec2_dem_position:a})},X_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!0});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:a,a_vec2_dem_position:r})},K_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:r})},q_=(s,e)=>{const t=n.PolygonGenerator.sinks.stroke.stride,i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1});return new H(e,{a_vec3_vertex:i,a_vec4_direction_distance:o})},wo=(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}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:20,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:20,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:20,offset:16,normalized:!0});return new H(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_direction_distance:r,a_vec2_dem_position:a,a_vec4_color:l})},Nr=(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}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:36,offset:8,normalized:!1}),a=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 H(e,{a_vec2_vertex:i,a_vec2_segment_end:o,a_vec4_texture_widen_arrow_widen:r,a_vec2_widen:a,a_vec2_direction:l,a_float_distance_from_start:c,a_float_object_length:d,a_float_type:_,a_vec4_identifier:u})},So=(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:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1});return new H(e,{a_vec3_vertex:i,a_vec2_widen:o})},Y_=(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:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0});return new H(e,{a_vec3_vertex:i,a_vec2_widen:o,a_vec4_identifier:r})},Q_=(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 H(e,{a_vec2_vertex:i,a_vec2_texcoord:o})},J_=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1});return new H(e,{a_vec2_position:i,a_vec2_widen:r,a_float_weight:o})},A_=(s,e)=>{const t=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:0,offset:0,normalized:!1});return new H(e,{a_vec2_position:t})},kr=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Float,stride:12,offset:0});return new H(e,{a_vec3_position:i})},cn=(s,e)=>new H(e,{a_vec2_position:s}),Ti=(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 H(e,{a_vec2_vertex:i,a_float_height:o})},eu=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!0});return new H(e,{a_vec2_vertex:i,a_vec2_centroid:o,a_vec2_extender:r})},To=(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 H(e,{a_vec2_vertex:i,a_vec2_texcoord:o})},dn=s=>(e,t,i,o)=>{const r=n.GltfModelGenerator.sinks.instances.stride,a=new n.BufferChannel(e,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:r,offset:0,normalized:!0,instanceDivisor:1}),l=new n.BufferChannel(e,{itemSize:9,dataType:n.Buffer.Float,stride:r,offset:8,instanceDivisor:1}),c=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:r,offset:44,normalized:!1,instanceDivisor:1}),d=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:r,offset:48,normalized:!1,instanceDivisor:1}),_=new n.BufferChannel(e,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:r,offset:s?56:52,normalized:!0,instanceDivisor:1});return new H(t,I({a_vec3_instance_position:a,a_float_instance_height:d,a_mat3_instance_matrix:l,a_vec4_instance_localid:_,a_float_abs_z:c},o),i)},Mo=(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}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),a=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 H(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_extender:r,a_vec3_normal:a,a_float_gradient:l,a_vec2_dem_position:c,a_float_abs_z:d,a_float_is_pivot:_})},tu=(s,e)=>{const t=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:0,offset:0,normalized:!1});return new H(e,{a_vec2_vertex:t})},Mi=(s,e)=>{const t=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:0,offset:0,normalized:!1});return new H(e,{a_vec2_vertex:t})},iu=(s,e)=>new H(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})}),ii=32,Ur=1/0,nu="raster";class Hr extends n.TileObjectBase{constructor(e,t,i){var r;super(nu),this.children=[],this.identifyChildren=[];const o=this;this.setTileCoords(e,t.map.state),(r=t.renderer.symbolSettingsList.dem.mesh)==null||r.forEach(a=>{const l={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:ii*ii*6,attributesHash:"",layerSettings:a,vao:i.mesh,canRender:!0,renderingProperties:{flatTexture:null,hillshadeTexture:null,flatIdentifyTexture:null}};a.identify?o.identifyChildren.push(l):a.depthTest?o.depthTestChildren.push(l):a.shadow?o.shadowChildren.push(l):a.dem?o.demChildren.push(l):a.demGround?o.demGroundChildren.push(l):o.children.push(l)})}setTileCoords(e,t){const i=e[2],o=e[3],r=n.tileZoomToSize(i);this.coords=e,this.size=r,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/ii;this.bounds.clear(),this.modelMatrices.clear(),e.forEach(o=>{const r=[this.coords[0]+o*t,this.coords[1],this.coords[2],this.coords[3]],a=n.tileCoordsToMapPoint(r);a[0]-=i,a[1]-=i,this.bounds.set(o,{min:[a[0],a[1]],max:[a[0]+this.size,a[1]+this.size]});const l=n.create$2();n.fromTranslationScale(l,a,n.fromValues(this.size+i,this.size+i,n.tileHeight)),this.modelMatrices.set(o,l)}),this.needSync=!1}}class ou{constructor(e,t){var r;this.meshTiles=new Map,this.destroyed=!1,this.modules=e.modules,this.maxZoom=(r=t==null?void 0:t.maxZoom)!=null?r:Ur;const i=[];for(let a=0;a<ii;a++)for(let l=0;l<ii;l++)i.push(l,a,l+1,a,l,a+1),i.push(l,a+1,l+1,a,l+1,a+1);const o=n.maxUint16Value/ii;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:cn(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=Ur){e!==this.maxZoom&&(this.maxZoom=e,this.update())}update(){if(this.destroyed)return;const e=this.modules.map.state;e.needReplicasUpdate&&this.meshTiles.forEach(r=>{r.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((r,a)=>(r.set(n.coordsToKey(a),a),r),new Map);this.meshTiles.forEach((r,a)=>{o.has(a)||this.meshTiles.delete(a)}),o.forEach((r,a)=>{this.meshTiles.has(a)||this.meshTiles.set(a,new Hr(r,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 su{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[r,a,l]=n.tileCoordsToOSM(o);return this.options.url(r,a,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 r=n.getTileBounds(t);this.tree.remove({minX:r.min[0],minY:r.min[1],maxX:r.max[0],maxY:r.max[1]},(a,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))}generateTile(e,t){return K(this,null,function*(){const i=[],o=[],r=n.coordsToKey(t),a=this.tiles.get(r);if(!a)return Promise.resolve({results:i,transferable:o});const l=this.modules.map.state.handyStyleId,{collector:c}=this.modules,d=n.tileZoomToSize(t[2]),_=a.bounds;this.tree.insert(ce(I({key:r,minX:_.min[0],minY:_.min[1],maxX:_.max[0],maxY:_.max[1],cellSize:d/n.DEM_ELEVATION_TILE_SIZE},a),{tree:null,bounds:_,generated:i})),this.updateMinElevation(),this.updateRevision();do n.DemGenerator.generateMeshElevation(c,a.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,r,a]=t,l=new Uint8Array(e),c=new Float32Array(qe(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),r,a])),p=n.Mercator.scaleFactor(m[1]);for(let v=0;v<u;v++){const x=v+f*u,g=(l[x]+l[qe(u,2)+x]*256-1e4)*p;d=Math.min(g,d),_=Math.max(g,_),c[x]=g}}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,r,a])}}}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,r)=>!o||o.cellSize>r.cellSize?r: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 r=e.elevation*n.MAP_POINTS_IN_METER/t+1,a=Math.max(e.pitch/e.maxPitch*30,4);n.scale$1(i,Math.min(r,a))}const o=this.tree.search({minX:i.min[0],minY:i.min[1],maxX:i.max[0],maxY:i.max[1]});e.styleZoom-No>1?this.minElevation=o.reduce((r,a)=>{if(a.data){const l=n.intersection(i,a.bounds);n.sub(l.min,l.min,a.bounds.min),n.sub(l.max,l.max,a.bounds.min),n.scale$2(l.min,l.min,1/a.cellSize),n.scale$2(l.max,l.max,1/a.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=a.data[_];r=r===void 0?u:Math.min(r,u)}}return r},void 0):this.minElevation=o.reduce((r,a)=>r===void 0?a.minZ:Math.min(r,a.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(r=>(r.rejected||this.tiles.set(t,r.data&&r.data.byteLength?this.unpackRaw(r.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),r=new Uint16Array(i*6);let a=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&&(r[a++]=d+1,r[a++]=d,r[a++]=d+t,r[a++]=d+1,r[a++]=d+t,r[a++]=d+t+1)}return{positions:o,heights:e,indices:r}}}class ru{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,(r,a)=>i===a.key),this.tiles.delete(i))}this.updateMinElevation()}fetchTiles(e){return this.worker.fetchTiles(e)}generateTile(e,t){return K(this,null,function*(){const i=n.coordsToKey(t),{tree:o,results:r,minZ:a,maxZ:l}=yield this.worker.generateTile(e.handyStyleId,t),c=n.getTileBounds(t),d={generated:r,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:a,maxZ:l,tree:o};return this.tiles.set(i,d),this.tree.insert(d),this.updateMinElevation(),this.updateRevision(),{results:r}})}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,r)=>!o||o.cellSize>r.cellSize?r: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,r)=>o===void 0?r.minZ:Math.min(o,r.minZ),void 0)}getRevision(){return this.revision}updateRevision(){this.revision++}}const We=new Float64Array(16);class Eo{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(We,this.texMatrix),this.viewport.forEach(o=>{n.transformMat4$1(o,o,We),o[0]-=t[0],o[1]-=t[1],o[2]-=t[2],o[2]>=0&&(o[2]=-1),n.normalize(o,o);const r=-t[2]/o[2];o[0]=t[0]+o[0]*r,o[1]=t[1]+o[1]*r,o[2]=t[2]+o[2]*r})}}class au{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:r,extendedTilesBounds:a,zoom:l,cameraConfig:c,globeMode:d}=this.modules.map.state,_=n.getLineConstants(a[0],a[1]),u=n.pointToLineDistance(a[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:r,zoom:l,cameraConfig:c,globeMode:d,styleState:{}}),p=n.clamp(Math.pow(this.modules.map.state.pitch/h,3),0,1),[v,x]=this.modules.camera.position,g=n.transformMat4([],[v,x,0,1],m.viewProjectionMatrix),y=Math.min(g[1]/g[3]+1,-.5);let b=Math.max(y,-1);if(n.fromTranslationScale(We,[0,-b,0],[1/Ne[0],1/Ne[1],1]),n.multiply(We,We,m.viewProjectionMatrix),this.textures.push(new Eo(We,m.position,0)),n.pointToLineDistance(this.textures[0].viewport[2],_)>=u)return!0;if(y<b){const T=Math.max(Math.abs(y-b)/2,1);n.fromTranslationScale(We,[0,2/T+1,0],[1/Ne[0],Ne[1]/T,1]),n.multiply(We,We,m.viewProjectionMatrix),this.textures.push(new Eo(We,m.position,1))}b+=1;const S=Math.pow(o[1]/749,2);[1.4,3.2,12,31].some((T,z)=>{T=(T-1)*p*S+1,n.fromTranslationScale(We,[0,-(b*T+1),0],[1/Ne[0],T/Ne[1],1]),n.multiply(We,We,m.viewProjectionMatrix),b+=2/T;const E=this.textures.push(new Eo(We,m.position,z));if(n.pointToLineDistance(this.textures[E-1].viewport[2],_)>=u)return!0})}destroy(){this.textures=[]}}const Io={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}},ae=s=>{if(typeof s=="function")return(t,i)=>{const o=s(t,i);return Object.assign({},Io,o)};const e=Object.assign({},Io,s);return()=>e},Te=ae({}),Co=ae({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),lu=ae({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}}),ni=ae({depthMask:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),cu=ae({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA},cullFace:!1}),Qe=ae({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),_n=ae((s,e)=>{const{_activeFloorIsMetro:t}=s.map.getStyleState();return{depthMask:!1,depthTest:!!(t&&(e==null?void 0:e.attributes.floorId)),blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}}),du=ae({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}),_u=ae({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.SRC_ALPHA,dfactor:n.BLEND_FUNC.ONE}}),Gr=ae({depthMask:!1,depthTest:!1,colorMask:[!0,!1,!1,!0]}),uu=ae({depthMask:!1,depthTest:!1}),Zt=ae({depthMask:!1,depthTest:!1}),Lo=ae((s,e)=>{const{_activeFloorIsMetro:t}=s.map.getStyleState();return{depthMask:!1,depthTest:!!(t&&(e==null?void 0:e.attributes.floorId))}}),hu=ae({depthMask:!1}),un=ae({colorMask:[!1,!1,!1,!1]}),fu=ae({colorMask:[!1,!1,!1,!1],depthFunc:n.DEPTH_FUNC.ALWAYS}),Vr=ae({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),mu=ae({depthFunc:n.DEPTH_FUNC.EQUAL,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),Po=ae({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),Bo=ae({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}}),zo=ae({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}}),jr=ae({polygonOffsetFill:!0,polygonOffset:{factor:1,units:2},blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),hn=ae({cullFaceMode:n.CULL_FACE_MODE.BACK}),fn=ae({cullFace:!1}),Zr=ae({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE}}),pu=ae({depthTest:!1,cullFace:!1}),vu=ae({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}}),$r=ae({colorMask:[!0,!0,!0,!0],depthMask:!0}),gu=ae({colorMask:[!0,!0,!0,!0],depthMask:!1}),yu=ae({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}}),xu=ae({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}}),bu=ae({depthMask:!0,depthTest:!0}),Wr=ae(s=>s.map.getFeatureFlag("transparentBuildingsOff")?Te(s):mu(s)),wu=ae(()=>({depthFunc:n.DEPTH_FUNC.LEQUAL,depthMask:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}})),Ro=n.reserveTextureIndex(),Fo=n.reserveTextureIndex(),Do=n.reserveTextureIndex(),Oo=n.reserveTextureIndex(),It=64,Xr=5,No=12,Kr=5,qr=15,Su=18,Tu=12,Mu=18,Eu=.1,Iu=.3,Ne=[1.7,1],Cu=300,ko=.001,Yr=1,Lu=n.tileZoomToSize(n.tiles.maxRegionalZoom),Pu={localhost:{tileServer:"127.0.0.1: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"]},dem_pre_prod:{tileServer:"tileserver.web-staging.2gis.ru",tileProtocol:"https",subdomains:["0","1","2"]},dem_staging:{tileServer:"tileserver.web-staging.2gis.ru",tileProtocol:"https",subdomains:["0","1","2"]}},mn=n.create$1(),He=new Float64Array(16);class Bu{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=ko,this.reliefTileType="vector",this.elevationSourceType="irregular",this.groundBuffer=new Float32Array,this.differ=new n.Differ([])}enable(){if(this.isTerrainSupported===void 0&&(this.isTerrainSupported=cr()),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,r,a,l]=i;return t.push(o*n.maxUint16Value,r*n.maxUint16Value,n.packTexCoords(a),n.packTexCoords(l)),t},[]))),this.hillshadeVao=To(this.fullscreenBuffer,this.modules.renderer.getShaderProgram("demHillshade"));const e=this.modules.renderer.getShaderProgram("demElevationCopy");this.copyDemVao=To(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(){var t,i,o,r;if(!this.enabled)return;this.dangerouslyDestroySourcesAndLayers(),(t=this.flatMapSource)==null||t.destroy(),this.flatMapSource=void 0,(i=this.hillshadeVao)==null||i.unbind(),(o=this.hillshadeVao)==null||o.remove(),(r=this.fullscreenBuffer)==null||r.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=ko,this.isAnimationStarted=!1,n.exist("changeScale",e)&&n.stop("changeScale",e)}update(){var o,r,a,l;if(!this.enabled)return;const e=this.modules.map.state;this.lastStyleId!==e.handyStyleId&&(this.updateRampTextureId(),(o=this.meshSource)==null||o.updateStyleId(),(r=this.hillshadeTile)==null||r.children.forEach(c=>{c.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(),(a=this.flatMapSource)==null||a.update(),(l=this.meshSource)==null||l.update(),this.updateDemFramebufferMatrix(),this.modules.renderer.addRerenderEvent()),this.disableAnimation||(this.isAnimationStarted?n.update("changeScale",{step:(c,d)=>{d===Yr&&n.stop("changeScale",e),this.terrainAnimationScaleCoef=d}},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(r=>r.type===n.PreLabelType.Point),t)break;if(!t)return;n.vertexTilePointToMapPoint(mn,t.vertices,0,n.createTileInfo(t.tileCoords));let i;for(let o=this.sources.length-1;o>=0;o--){const a=this.sources[o].getElevationTile(mn);if(a!==void 0){i=a;break}}if(i)return i.key}enrichWithElevation(e){var t;if(this.enabled)for(const i of e){let o=null;for(const r of i.labels)r.type===n.PreLabelType.Point&&(o||(o=n.createTileInfo(r.tileCoords)),n.vertexTilePointToMapPoint(mn,r.vertices,0,o),r.demElevation=(t=this.getElevation(mn))!=null?t: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(Ro),this.modules.renderer.disableTexture(Oo),this.modules.renderer.disableTexture(Fo),this.modules.renderer.disableTexture(Do)}setMeshMaxZoom(e){var t;this.meshMaxZoom=e,(t=this.meshSource)==null||t.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,r=e[1]-this.modules.map.state.viewport.top;if(o<0||o>i[0]-1||r<0||r>i[1]-1)return;const l=((i[1]-r-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,ko,Yr,Cu,1))}dangerouslyDestroySourcesAndLayers(){var e;this.sources.forEach(t=>t.destroy()),this.sources=[],this.sourcesRevision=[],(e=this.meshSource)==null||e.destroy(),this.meshSource=void 0,this.tileLayers.forEach(t=>{this.modules.tileManager.removeTileLayer(t),t.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!=null&&e.dem){const t=zu(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!=null&&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 au(this.modules.map)}addRegularElevationSources(){var a;const e=this.modules.map.state,t=(l,c,d)=>n.DEM_TILE_URL_FUNCTION(e,l,c,d,this.tileSet==="dem"?"relief":this.tileSet),i=this.reliefTileType==="raster";i&&this.addElevationSource({url:t,minZoom:Xr,maxZoom:8,attributes:{}}),this.addElevationSource({url:t,minZoom:i?9:Xr,maxZoom:No,attributes:{}}),this.meshSource=new ou(this.modules.map,{maxZoom:this.meshMaxZoom});const o=this.hillshadeVao,r=(a=this.modules.renderer.symbolSettingsList.dem.hillshade)==null?void 0:a[0];if(o&&r){this.hillshadeTile=new n.TileObject("raster",[],this.modules,this.modules.map.state);const l={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:r,vao:o,canRender:!0,renderingProperties:{}};this.hillshadeTile.children.push(l),this.modules.tileManager.addObject(this.hillshadeTile)}}addIrregularElevationSources(){var o;const{tileServer:e,tileProtocol:t,subdomains:i}=(o=Pu[this.tileSet])!=null?o:this.modules.map.state;this.addIrregularElevationSource({tileServer:e,tileProtocol:t,subdomains:i,tileSet:this.tileSet,minZoom:Kr,maxZoom:qr})}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 su(n.sourceUuid(),this.modules,e);this.sources.push(t),this.sourcesRevision.push(t.getRevision());const{minZoom:i,maxZoom:o}=e,r=new n.TileLayer(i,o,i,o,this.modules,this.modules.map.state,t);this.modules.tileManager.addTileLayer(r),this.tileLayers.push(r)}addIrregularElevationSource(e){const t=new ru(n.sourceUuid(),this.modules,e);this.sources.push(t),this.sourcesRevision.push(t.getRevision());const{minZoom:i,maxZoom:o}=e,r=new n.TileLayer(i,o,i,o,this.modules,this.modules.map.state,t,{useExtendedTilesBounds:!0});this.modules.tileManager.addTileLayer(r),this.tileLayers.push(r)}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),It)}createGroundFramebuffer(){const e=this.modules.map.state.size,t=[0,0,0,0],i=new Ce({size:e,magFilter:w.NearestFilter,minFilter:w.NearestFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,flipY:!0,type:w.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()*It;const t=new Ce({size:[e,e],magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,flipY:!0,type:w.Float,format:w.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()*It;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()*It;const i=new Ce({size:[t,t],magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,flipY:!0,type:w.Float});return e.bindRenderTarget(i),e.clearWithColor([0,0,0,1]),e.bindRenderTarget(null),this.modules.renderer.addFramebuffer({onResize:()=>{const o=this.getDemTextureSize()*It;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:()=>{var l;const o=(l=this.modules.renderer.getFramebuffer(this.demFramebufferId))==null?void 0:l.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(Gr);const r=0;this.modules.renderer.enableTexture(o,r);const a=this.modules.renderer.getShaderProgram("demElevationCopy");this.modules.renderer.enableShaderProgram(a),this.modules.renderer.bindShaderProgram(a,{u_mat4_mvp:n.TEXTURE_COORDS_TO_WEBGL,u_sr2d_texture:r,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()*It;const t=new Ce({size:[e,e],magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,format:w.RgbFormat,flipY:!0});return this.modules.renderer.addFramebuffer({clearColor:[0,0,0,0],onResize:()=>{const i=this.getDemTextureSize()*It;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 Ce({size:[Math.trunc(t[0]*Ne[0]*e),Math.trunc(t[1]*Ne[1]*e)],magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.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]*Ne[0]*e),Math.trunc(o[1]*Ne[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 Ce({size:[Math.trunc(e[0]*Ne[0]*n.identify.pixelDensity),Math.trunc(e[1]*Ne[1]*n.identify.pixelDensity)],magFilter:w.NearestFilter,minFilter:w.NearestFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping});return this.modules.renderer.addFramebuffer({clearColor:qt,onResize:()=>{const i=this.modules.map.state.size;t.setSize([Math.trunc(i[0]*Ne[0]*n.identify.pixelDensity),Math.trunc(i[1]*Ne[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"?Tu:Su),o=n.tileZoomToSize(i),r=o*this.getDemTextureSize(),a=o/It,l=[Math.trunc(e.center[0]/a)*a+a/2,Math.trunc(e.center[1]/a)*a+a/2],c=[l[0]-r/2,l[1]-r/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(r/2-_-a-Lu/2,0),h=Math.min(u,(r/2-_-a)*Math.sin(e.pitch/e.maxPitch*(Math.PI/2)));h>0&&(n.scale$2(d,d,h),d[0]=Math.trunc(d[0]/a)*a,d[1]=Math.trunc(d[1]/a)*a,n.sub(c,c,d)),n.fromTranslationScale(He,c,[r,r,n.tileHeight]),n.invert(this.demTextureMatrix,He),n.multiply(this.demFbVpMatrix,n.TEXTURE_COORDS_TO_WEBGL,this.demTextureMatrix);const f=Math.min(t,Mu);this.demCorrectedScale=qe(2,f-i);const p=n.tileZoomToSize(f)*this.getDemTextureSize(),v=[l[0]-p/2,l[1]-p/2,0];n.fromTranslationScale(He,v,[p,p,n.tileHeight]),n.invert(He,He),n.multiply(this.demCorrectedFbVpMatrix,n.TEXTURE_COORDS_TO_WEBGL,He),n.fromScaling(He,[1/this.demCorrectedScale,1/this.demCorrectedScale,1]),n.multiply(this.demCorrectedFbVpToDemTex,n.WEBGL_COORDS_TO_TEXTURE,He),n.fromScaling(He,[1/this.demCorrectedScale,1/this.demCorrectedScale,1]),n.multiply(He,He,n.TEXTURE_COORDS_TO_WEBGL),n.multiply(this.correctedTexToDemTex,n.WEBGL_COORDS_TO_TEXTURE,He),n.fromScaling(He,[this.demCorrectedScale,this.demCorrectedScale,1]),n.multiply(He,He,n.TEXTURE_COORDS_TO_WEBGL),n.multiply(this.demTexToCorrectedTex,n.WEBGL_COORDS_TO_TEXTURE,He)}validateGroundBufferSize(e){const t=e[0]*e[1]*4;this.groundBuffer.length!==t&&(this.groundBuffer=new Float32Array(t))}}function zu(s,e,t){const i=n.makeBinderContext(s.styleZoom,s.styleState,[]),o=[],r=t-1;for(let a=0;a<t;a++){const l=a/r,c=n.sample(e,l,i)*256;o.push(c)}return new w(new Uint8Array(o),{size:[t,1],format:w.AlphaFormat,magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping})}const Ct=(s,e,t,i)=>{t=Vo(t,s,e),t.length>0&&s.metrics.firstcontent===void 0&&(s.metrics.firstcontent=performance.now()-s.metrics.start);const{environmentManager:o}=e;Ar(t,i),s.globeMode&&(o.renderStars(),o.renderGlobeHaloBackground()),Ho(s,e,t,i)};let Uo=!1;const Ho=(s,e,t,i)=>{Uo=!1,Hu(t,s,e).forEach(o=>Ru(s,e,o,i))},Ru=(s,e,t,i)=>{Zu(e.styleManager,t,s,e).forEach(o=>{Jr(e.styleManager,o[0])?Fu(s,e,o,i):Qr(s,e,o,i)})},Fu=(s,e,t,i)=>{const o=Jr(e.styleManager,t[0]);if(!o)return;const r=(a,l)=>{l>=o.orderBy.length?Qr(s,e,a,i):Wu(o.orderBy[l],a,s,e).forEach(c=>r(c,l+1))};r(t,0)},Qr=(s,e,t,i)=>{t.sort((o,r)=>o.tile.zoomLevel-r.tile.zoomLevel),ju(e.styleManager,t,s,e).forEach(o=>Du(s,e,o,i))},Du=(s,e,t,i)=>{$u(t,s,e).forEach(o=>Ou(s,e,o,i))},Ou=(s,e,t,i)=>{var l;const o=t[0],r=Qu(e.styleManager,o);if(!r||((l=r==null?void 0:r.style)==null?void 0:l.visibility)==="hidden")return;const a=r.selectedIdx;a!==void 0&&t.sort((c,d)=>{var h,f;const _=Number((h=c.attributes.tileData[a])!=null?h:0),u=Number((f=d.attributes.tileData[a])!=null?f:0);return _-u}),o.type===n.SceneObjectType.Custom?(i.useCustomLayerState(r),e.styleManager.callCustomLayerRender(o.attributes.layerId),i.resetAfterCustomLayer()):Xu(t,s,e).forEach(c=>Nu(s,e,c,i,r))},Nu=(s,e,t,i,o)=>{o.type==="point"&&!Uo&&s.globeMode&&(Uo=!0,e.environmentManager.renderGlobeHalo()),i.useProgram(t[0],o),Ku(t,s,e).forEach(r=>{ku(s,e,r,i,o)})},ku=(s,e,t,i,o)=>{i.useState(t[0],o),qu(t,s,e).forEach(r=>{i.drawSymbol(r,o,s,e)})};function Jr(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 Uu=(s,e)=>Number(s)-Number(e),oi=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 r=Object.keys(o);r.sort(Uu);const a=[];for(let l=0;l<r.length;l++)a.push(o[r[l]]);return a},Go=s=>(e,t,i)=>{const o=new Map;for(let r=0;r<e.length;r++){const a=e[r],l=s(a,t,i);o.has(l)?o.get(l).push(a):o.set(l,[a])}return o},Hu=oi(s=>{const{styleId:e}=s.attributes;return e===n.DYNAMIC_STYLE_ID?1:-e}),Gu=(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},Vu=(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},ju=(s,e,t,i)=>oi(o=>Vu(s,o.attributes.styleId,o.attributes.layerId))(e,t,i),Zu=(s,e,t,i)=>oi(o=>Gu(s,o.attributes.styleId,o.attributes.layerId))(e,t,i),$u=oi(s=>s.type===n.SceneObjectType.Custom?0:s.layerSettings.subRenderIndex||0),Ar=(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))})},Wu=(s,e,t,i)=>oi((o,r)=>{const a=n.makeBinderContext(r.styleZoom,r.styleState,o.attributes.tileData);return n.resolveNumber(s,a,0)})(e,t,i),Xu=Go(s=>{var e;return(e=s.shaderDefinitions)!=null&&e.hash?s.layerSettings.programName+"_"+s.shaderDefinitions.hash:s.layerSettings.programName}),Ku=Go(s=>s.layerSettings.stateBinder),qu=Go(s=>s.sink+"_"+s.attributesHash+"_"+s.tile.readiness),Yu=oi(s=>s.tile.zoomLevel);function Qu(s,e){const t=s.getStyle(e.attributes.styleId);if(t)return t.layersById[e.attributes.layerId]}function Vo(s,e,t){for(const i of s)i.type!==n.SceneObjectType.Custom&&(i.canRender=Ju(i,t,e));return s.filter(i=>i.canRender)}function Ju(s,e,t){var o;if(!s.layerSettings.cullMethod)return!0;const i=e.styleManager.getStyleLayerForObject(s);return!(!i||((o=i==null?void 0:i.style)==null?void 0:o.visibility)==="hidden"||!s.layerSettings.cullMethod(s,e,t,i))}const ea=[0,0,0,0],bt=(s,e,t,i,o,r)=>{let a;const l={terrain3d:!!o,noEffects:!!r,drawSymbol:(c,d,_,u)=>{const h=c[0];if(h)if(Au(h)&&(d.type==="overpass"||d.type==="tunnel"||d.type==="gltfModel")&&!h.layerSettings.shadow){let f;d.type==="gltfModel"&&(f=ea),l.renderTierTexture(h,d,!1,f),l.useProgram(h,d),l.useState(h),jo(c,d,_,u,l),_.hiddenImmersiveRoutesEnabled&&!h.layerSettings.identify&&d.type!=="gltfModel"&&(l.renderTierTexture(h,d,!0),l.useProgram(h,d),u.renderer.applyGpuState(lu,d),jo(c,d,_,u,l))}else jo(c,d,_,u,l)},useProgram:(c,d)=>{const{layerBinder:_,programName:u,programBinder:h,commonBinder:f}=c.layerSettings,m=e.renderer.getShaderProgram(u,c.shaderDefinitions);e.renderer.enableShaderProgram(m),f&&!e.renderer.isUboSupported()&&f(m,s,e),h==null||h(m,s,e,o,r),_==null||_(m,s,e,d,r)},setProgramBinder:c=>{const d=c.layerSettings.programBinder,_=e.renderer.isUboSupported()?void 0:c.layerSettings.commonBinder;if(c.layerSettings.programBinder||_){const u=e.renderer.getShaderProgram(c.layerSettings.programName,c.shaderDefinitions);e.renderer.enableShaderProgram(u),_==null||_(u,s,e),d==null||d(u,s,e,o,r)}},useState:(c,d)=>{e.renderer.applyGpuState(c.layerSettings.stateBinder,d,c)},useCustomLayerState:c=>{e.renderer.applyGpuState(pu,c)},resetAfterCustomLayer:()=>{e.renderer.resetStateAfterExternalRender(),e.renderer.setRenderTarget(i)},useCanvas:()=>{e.renderer.setRenderTarget(i)},renderTierTexture:(c,d,_,u)=>{const{viewport:h,size:f}=s,m=window.devicePixelRatio,p=!!c.layerSettings.identify,v=c.attributes.meshTier,x=_?"hidden":"visible";let g="depth",y;if(_)p&&(g="identify-depth");else if(p)g="identify";else{const P=n.makeBinderContext(s.styleZoom,s.styleState,c.attributes.tileData);y=u!=null?u:n.resolveColor(d.style.color,P).value,g=y.join(":")}const b=p?e.renderer.getMapMeshIdFramebufferId():e.renderer.getMapMeshFramebufferId(),S=e.renderer.getFramebuffer(b),T=`${x}|tier:${v}|fb:${b}|clear:${g}|${i?"target":"canvas"}`;if(!S||T===a)return;a=T;const z=bt(s,e,void 0,i,!1,!0);if(e.renderer.disableTexture(0),e.renderer.bindRenderTarget(S.renderTarget),e.renderer.setViewport(0,0,S.renderTarget.options.size[0],S.renderTarget.options.size[1]),_){const P=p?qt:ea;e.renderer.clearWithColor(P,!0,-1)}else if(p)e.renderer.clearWithColor(qt,!0);else{const P=y;e.renderer.clearWithColor([P[0]/255,P[1]/255,P[2]/255,P[3]/255],!0)}const E=t==null?void 0:t[v];if(E){E.tileObjects.forEach(R=>{var C,F;R.updateMvpMatrix((F=(C=S.getViewProjectionMatrix)==null?void 0:C.call(S))!=null?F:e.camera.viewProjectionMatrix,void 0)});const P=_?E.objects.filter(R=>{var C;if(R.type!==n.SceneObjectType.Custom){if(R.layerSettings.stateBinder(e,R).depthTest&&!R.layerSettings.isOverlappedObject)return!0;const F=e.styleManager.getStyleLayer(R.attributes.styleId,R.attributes.layerId);if(F)return((C=F.gpuState)==null?void 0:C.depthTest)===!0}return!1}):E.objects,k=Vo(P,s,e);Ho(s,e,k,z),E.tileObjects.forEach(R=>R.updateMvpMatrix(e.camera.viewProjectionMatrix)),Ar(E.objects,l)}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(h.left*m,h.bottom*m,f[0]*m,f[1]*m))},copy:(c,d,_)=>bt(s,e,t,c,d,_)};return l},jo=(s,e,t,i,o)=>{const r=s[0],a=r.layerSettings,l=i.renderer.getShaderProgram(a.programName,r.shaderDefinitions);a.objectBinder(l,t,i,r,e,o.terrain3d),r.layerSettings.zoomBinder?Yu(s,t,i).forEach(c=>{var d,_;l&&((_=(d=r.layerSettings).zoomBinder)==null||_.call(d,l,t,i,c[0],e,o.terrain3d)),c.forEach(u=>ta(u,i,l,t,o,e))}):s.forEach(c=>ta(c,i,l,t,o,e))},ta=(s,e,t,i,o,r)=>{var c;const{renderer:a}=e,l=s.tile;for(const d of l.modelMatrices.keys()){if(l.renderModelMatrix=l.modelMatrices.get(d),l.renderMvpMatrix=l.mvpMatrices.get(d),l.renderDemMatrix=l.demMatrices.get(d),l.renderFlatMapTexMatrix=l.flatMapTexMatrices.get(d),!s.layerSettings.tileBinder(t,i,e,s,r,o))continue;a.bindVao(s.vao);const{start:u,count:h,instanceCount:f}=s,m=(c=s.drawMode)!=null?c:n.GL_TRIANGLES,p=s.vao.getElementsGLType();if(p!==null?f?a.drawInstancedElements(m,h,p,u,f):a.drawElements(m,h,p,u):f?a.drawInstancedArrays(m,u,h,f):a.drawArrays(m,u,h),i.collectStats){i.stats.drawCount++,i.stats.vertexCount+=(f!=null?f:1)*h,i.stats.drawCountBySymbol[s.symbol]?i.stats.drawCountBySymbol[s.symbol]++:i.stats.drawCountBySymbol[s.symbol]=1;const v=a.triangleCountByDrawMode(m,h);i.stats.triangleCount+=(f!=null?f:1)*v}}};function Au(s){return s.symbol==="mapMesh"||s.symbol==="gltfModel"&&s.attributes.meshTier!==void 0}const ia=n.create$1(),eh=n.create$1(),na=n.create$2(),Zo=n.create$1(),th=n.fromValues(0,0,1),ih=n.create$1(),nh=.3,oh=1/2e7,sh=.01,rh=[1,1,1,1],oa=n.reserveTextureIndex();class ah{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=qe(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 w?e:this.renderTarget.getTexture()}setShadowResolution(e,t){this.shadowMapParams[0]=e,this.shadowMapParams[1]=t,this.renderTarget&&this.renderTarget.setSize([e,t])}update(){if(ti())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 E in o){const P=o[E];if(P.shadowLightIndex===0){this.shadowLightDir=P.dir1Direction,this.shadowMapParams[2]=P.shadowRadius;break}else if(P.shadowLightIndex===1){this.shadowLightDir=P.dir2Direction,this.shadowMapParams[2]=P.shadowRadius;break}}const r=this.shadowLightDir&&!this.modules.map.getFeatureFlag("shadowsOff");if(r?this.renderTarget||(this.renderTarget=this.createRenderTarget()):this.renderTarget&&this.renderTarget.remove(),!r||!this.shadowLightDir||!this.renderTarget||this.modules.renderCacheManager.hasReadyCache())return;const a=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*oh*Math.sqrt(c),this.bias=Math.min(this.bias,sh);let _=1;if(this.adaptiveVerticalSize){const E=Math.abs(n.dot(this.shadowLightDir,th));_=Math.max(E,nh)}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(Zo,m,this.shadowLightDir);const p=na;n.lookAt(p,ih,this.shadowLightDir,Zo);const v=n.transformMat4$1(ia,a,p),x=2*u/this.shadowMapParams[0],g=2*h/this.shadowMapParams[1],y=n.fromValues(v[0]-v[0]%x,v[1]-v[1]%g,v[2]),b=n.invert(p,p),S=n.transformMat4$1(eh,y,b!=null?b:n.identity(na)),T=n.add$1(ia,S,this.shadowLightDir);n.lookAt(this.shadowMatrix,S,T,Zo),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;this.modules.renderer.resetStateAfterExternalRender();const t=this.modules.map.state.demMode,i=bt(this.mapState,this.modules,void 0,this.renderTarget,t),o=new Set,r=[];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 _=Tr(d,this.modules,this.mapState);!_||_.lightConfig.shadowLightIndex===-1||(r.push(c),o.add(l))}const a=t?this.modules.demManager.demTextureMatrix:void 0;o.forEach(l=>{l.updateMvpMatrix(this.shadowMatrix,a)}),this.modules.renderer.bindRenderTarget(this.renderTarget),this.modules.renderer.applyGpuState($r),this.modules.renderer.clearWithColor(rh,!0),this.modules.renderer.setViewport(0,0,this.renderTarget.options.size[0],this.renderTarget.options.size[1]),Ct(this.mapState,this.modules,r,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.modules.renderer.resetStateAfterExternalRender(),(!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=Mi(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(Zt),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(){var t,i;const e={renderTarget:(i=(t=this.renderTarget)==null?void 0:t.memSizeGPU())!=null?i:0};return{gpu:ce(I({},e),{"--sum":n.getTotalMemory(e)})}}createRenderTarget(){const e=[this.shadowMapParams[0],this.shadowMapParams[1]];return this.modules.renderer.isDepthTextureSupported()?new Ce({size:e,magFilter:w.LinearFilter,minFilter:w.LinearFilter,depthTexture:!0,hasColorOutput:!1,compareFunc:w.CompareRefToTexture}):new Ce({size:e,magFilter:w.NearestFilter,minFilter:w.NearestFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,flipY:!1,type:w.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 sa{constructor(e,t,i){this.output=e,this.input=t,this.modules=i,this.enabled=!0}}class lh extends sa{constructor(e,t,i,o){super(e,t,i),this.name=si.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!==ri.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(){var o;const e=1/(this.numMixedFrames+1),t=this.modules.renderer.getShaderProgram("taa");this.vao||(this.vao=Mi(this.buffer,t)),this.modules.renderer.bindRenderTarget(this.output),this.modules.renderer.bindVao(this.vao);const i=(o=this.input)==null?void 0:o.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!=null&&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,r=i.base3;t.push([0,0]);for(let a=0;a<o.length;++a)t.push([2*o[a]-1,2*r[a]-1]);return t}}class ch extends sa{constructor(e,t,i,o){super(e,t,i),this.name=si.FXAA,this.vao=null,this.buffer=o}onBeforeRender(e){this.enabled=e.aaMode===ri.FXAA&&e.stillness>0}render(){var i;const e=(i=this.input)==null?void 0:i.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=Mi(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 o=this.modules.map.state;ue(t,o,this.modules)}this.modules.renderer.drawTrianglesFan(0,4)}onAfterRender(){}resize(e){this.output.setSize(e)}isReady(){return!0}}var si=(s=>(s.TAA="TAA",s.FXAA="FXAA",s))(si||{}),ri=(s=>(s[s.TAA=0]="TAA",s[s.FXAA=1]="FXAA",s))(ri||{});class dh{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 r=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=Mi(r,this.copyColorProgram),this.copyColorDepthVao=Mi(r,this.copyColorDepthProgram);const a=this.createRenderTarget(this.renderTargetSize,{useHighDepthPrecision:!0});this.mainFrameBufferWrapper={renderTarget:a,onResize:()=>{},clearColor:n.getColorForShaders(e.defaultBackgroundColor),clearDepth:!0};const l=e.aaMode===0,c=e.aaMode===1,d=l?lh:c?ch:null;if(d){const _=this.createRenderTarget(this.renderTargetSize),u=new d(_,a,t,r);this.effectsByType[l?"TAA":"FXAA"]=u,this.renderGraph.push(u)}}update(){this.renderGraph.forEach(e=>e.onBeforeRender(this.state))}render(){this.modules.renderer.applyGpuState(vu),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(){var t,i;const e={mainFrameBufferWrapper:{renderTarget:(i=(t=this.mainFrameBufferWrapper)==null?void 0:t.renderTarget.memSizeGPU())!=null?i:0}};return{gpu:ce(I({},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,r=window.devicePixelRatio,a=this.modules.renderer.getViewportSize();this.modules.renderer.bindRenderTarget(null),this.modules.renderer.setViewport(o.left*r,o.bottom*r,a[0],a[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 w&&(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 Ce(Object.assign({minFilter:w.NearestFilter,magFilter:w.NearestFilter,size:e},t))}}const _h=[0,0];function ve(...s){return(e,t,i,o,r)=>{s.forEach(a=>a(e,t,i,o,r))}}const oe=(s,e,t,i)=>{var m,p,v;if(!i){aa(s,e,t);return}const o=(m=t.renderer.getFramebuffer(t.demManager.getDemFramebufferId()))==null?void 0:m.renderTarget.getTexture(),r=(p=t.renderer.getFramebuffer(t.demManager.getCorrectedDemFramebufferId()))==null?void 0:p.renderTarget.getTexture(),a=t.imageManager.getTexture(t.demManager.getHillshadeRampTextureId()),l=o==null?void 0:o.options.size,c=t.styleManager.getStyle(e.handyStyleId);if(!o||!r||!a||!c||!l){aa(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"?No:qr))*It);t.renderer.enableTexture(o,Ro),t.renderer.enableTexture(a,Do),t.renderer.enableTexture(r,Oo);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:Ro,u_tex_corrected_dem:Oo,u_tex_hillshade_ramp:Do,u_float_corrected_interval:t.demManager.isDemCorrectionEnabled&&f!==1?.5/f:0,u_mat4_dem_corrected:t.demManager.demTexToCorrectedTex,u_float_map_center_elevation:(v=e.elevation)!=null?v:0})},ra=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_dem_shading_intensity:0})},aa=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_dem_scale:0})},pn=oe,vn=ve(pt,on),la=wi,uh=ve(yr,on,pt,Sr,oe),ca=ve(yr,on,g_,oe),da=ve(pt,on,Sr,oe),hh=wi,at=(s,e,t,i,o)=>{const r=t.postEffectsManager.getEffectByName(si.TAA),a=!o&&(r!=null&&r.jitter)?r.jitter:_h;t.renderer.bindShaderProgram(s,{u_vec2_camera_jitter:a})},Ve=(s,e,t)=>{const i=t.shadowManager.texture;i&&(t.renderer.enableTexture(i,oa),t.renderer.bindShaderProgram(s,{u_texture_shadow:oa}))},fh=(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)})},mh=ve(oe,at,Ve),ph=ve(at,Ve),gn=ve(oe,at,Ve),vh=wi,gh=ve(oe,at,Ve),_a=ve(at,Ve),lt=ve(oe,at,Ve),ua=ve(oe,Ve),ai=ve(oe,at,Ve),ha=ve(wi,br,wr),fa=ve(wi,br,wr,Ve),yh=ve(oe,fa),xh=ve(oe,ha),$o=ve(Ve,oe),bh=ve(oe,at,Ve),wh=ve(at,Ve),ma=ve(at,Ve),Sh=ve(oe,ma),Ei=new Float32Array(2),Ii=new Float32Array(2),Th=[0,0],Mh=[0,0,0,0],li=.01,Be=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_float_opacity:1})},Wo=(s,e,{renderer:t},i,o)=>{const r=ke(e,i),a=n.resolveNumber(o.style.textureOpacity,r);t.bindShaderProgram(s,{u_float_texture_opacity:i.tile.readiness*a})},Lt=(s,e,{renderer:t},i)=>{i.renderingProperties.mixFactorColor&&t.bindShaderProgram(s,{u_float_mix_color:i.renderingProperties.mixFactorColor})},me=(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})},pa=(s,e,{renderer:t},i)=>{var c;if(!i.renderingProperties.mixColor)return;const{color2:o,factor:r,factorInterpolate:a}=i.renderingProperties.mixColor,l=n.getColorForShaders(o);switch(n.scale$4(l,l,i.tile.readiness),r.type){case"read-from-target":{const d=(c=t.getDrawTargetFramebuffer(r.name))==null?void 0:c.renderTarget.getTexture();if(!d)return;t.enableTexture(d,2),a?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:a.base,u_vec4_factor_interpolate_ranges:a.steps}):t.bindShaderProgram(s,{u_vec4_color2:l,u_sr2d_read_from_target_texture:2,u_int_factor_use_interpolate:0});break}case"vertex-attribute":{t.bindShaderProgram(s,{u_vec4_color2:l});break}default:{const{type:d}=r;n.assertUnreachable(d)}}},Ci=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_mat4_gradient:i.renderingProperties.mat4_gradient})},Eh=(s,e,{renderer:t},i,o)=>{const r=n.getColorForShaders(n.resolveColor(o.style.strokeColor,ke(e,i)));n.scale$4(r,r,i.tile.readiness),t.bindShaderProgram(s,{u_vec4_border_color:r})},Ge=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.widthResolved||0;t.bindShaderProgram(s,{u_float_width:o*window.devicePixelRatio})},va=(s,e,{renderer:t},i,o)=>{t.bindShaderProgram(s,{u_float_shift:n.resolveNumber(o.style.shift,ke(e,i))*window.devicePixelRatio})},Ih=(s,e,{renderer:t},i,o)=>{const r=i.renderingProperties.opacityResolved||0,a=n.makeBinderContext(e.styleZoom,e.styleState,i.attributes.tileData,!1),l=o.style.iconOpacity,c=n.resolveNumber(l,a);a.isBehind=!0;const d=e.styleState.graphicsPreset==="light"?1:n.resolveNumber(l,a);t.bindShaderProgram(s,{u_vec2_opacity:[r*c,r*d]})},Ot=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.opacityResolved||0;t.bindShaderProgram(s,{u_float_opacity:o})},Xo=(s,e,{renderer:t},i,o)=>{const r=n.resolveNumber(o.style.iconRotation,ke(e,i));t.bindShaderProgram(s,{u_vec2_rotation:[Math.cos(r),Math.sin(r)]})},Ch=(s,e,{renderer:t},i,o)=>{const r=n.resolveNumber(o.style.opacity,ke(e,i));t.bindShaderProgram(s,{u_float_opacity:i.tile.readiness*r})},Lh=(s,e,{renderer:t},i,o)=>{const r=n.resolveNumber(o.style.opacity,ke(e,i));t.bindShaderProgram(s,{u_float_opacity:r})},Ko=(s,e,{assetManager:t,renderer:i},o)=>{const r=t.textures[o.attributes.atlasIndex];i.enableTexture(r,0)},ci=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.fontTexture;o&&t.enableTexture(o,0)},ga=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.texture;o&&t.enableTexture(o,0)},Ph=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.rampTexture;o&&(t.enableTexture(o,1),t.bindShaderProgram(s,{u_sr2d_ramp_texture:1}))},yn=(s,e,{renderer:t},i,o)=>{const{tile:r}=i,a=n.resolveColor(o.style.gapColor,ke(e,i));if(!a)return;const l=n.getColorForShaders(n.resolveColor(a,ke(e,i)));n.scale$4(l,l,r.readiness),t.bindShaderProgram(s,{u_vec4_space_color:l})},xn=(s,e,{renderer:t},i,o)=>{const{styleZoom:r}=e,a=ke(e,i),{tile:l}=i,c=n.getColorForShaders(n.resolveColor(o.style.color,a));n.scale$4(c,c,l.readiness),a.styleZoom=Math.floor(r);const d=Math.pow(2,n.getFractionalPart(r)),_=n.resolveNumber(o.style.dashLength,a)*d,u=n.resolveNumber(o.style.gapLength,a)*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})},he=n.create$3(),ya=(s,e,{renderer:t},i,o)=>{const r=ke(e,i),{tile:a}=i,{pattern:l,width:c}=i.renderingProperties;if(!l||!c)return;const d=n.getColorForShaders(n.resolveColor(o.style.color,r));switch(n.scale$4(d,d,a.readiness),l[0]){case n.LinePatternType.Chess:{const _=l[1];he[0]=_,he[1]=.5,he[2]=.25,he[3]=-.25;break}case n.LinePatternType.DoubleDash:{const _=l[1];he[0]=_,he[1]=l[2]/c,he[2]=.5*l[3]/_,he[3]=.5*l[4]/_,he[2]>=.5-Number.EPSILON&&(he[2]=.6),he[3]>=.5-Number.EPSILON&&(he[3]=.6);break}case n.LinePatternType.Stripe:{const _=l[1]+l[2];he[0]=_,he[1]=.55,he[2]=.5*l[1]/_,he[3]=.5*l[1]/_,he[2]>=.5-Number.EPSILON&&(he[2]=.6),he[3]>=.5-Number.EPSILON&&(he[3]=.6);break}case n.LinePatternType.Circle:{const _=l[1]+l[2];he[0]=_,he[1]=.5*l[1]/_;break}case n.LinePatternType.Triangles:{const _=l[1]+l[2];he[0]=_,he[1]=l[1]/_,he[2]=String(l[3])==="right"?-1:1;break}case n.LinePatternType.Chevron:{const _=l[1]+l[2];he[0]=_,he[1]=l[1]/_,he[2]=l[3]/_,he[3]=l[4]/c;break}}t.bindShaderProgram(s,{u_vec4_color:d,u_int_pattern_type:l[0],u_vec4_pattern_params:he})},bn=(s,e,{renderer:t},i,o)=>{const r=ke(e,i),a=n.resolveNumber(o.style.tipWidth,r),l=n.resolveNumber(o.style.tipHeight,r),c=a,d=0;Ei[0]=-c,Ei[1]=-d,n.normalize$1(Ei,Ei),Ii[0]=a,Ii[1]=l,n.normalize$1(Ii,Ii);const _=n.resolveNumber(o.style.roundingRadius,r);t.bindShaderProgram(s,{u_vec2_wing_normal:Ei,u_vec2_tip_normal:Ii,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:_})},xa=(s,e,{renderer:t},i,o)=>{const r=ke(e,i),a=n.resolveNumber(o.style.lineLength,r),l=n.resolveNumber(o.style.lineWidth,r);t.bindShaderProgram(s,{u_float_length:a,u_float_width:l,u_float_border_width:0})},ba=(s,e,{renderer:t},i,o)=>{const r=ke(e,i),{tile:a,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,r));const m=n.resolveNumber(o.style.roundingRadius,r);t.bindShaderProgram(s,{u_float_width_zpt:n.resolveNumber(o.style.lineWidth,r),u_float_border_width_zpt:n.resolveNumber(o.style.strokeWidth,r),u_float_tip_movement_amplitude:n.zptToSceneDistance(h,a.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})},Bh=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.modelTexture;o&&t.enableTexture(o,0)},qo=(s,e,{renderer:t},i)=>{var o,r;return t.bindShaderProgram(s,{u_int_gltf_dem_pos:i.attributes.demPosition,u_vec2_anchor:(o=i.attributes.centroid)!=null?o:Th,u_vec4_axis:(r=i.attributes.axis)!=null?r:Mh}),!0},zh=(s,e,{assetManager:t,renderer:i},o)=>{const{styleId:r}=o.attributes,{renderingProperties:a}=o,{resolvedColorTexture:l,resolvedAoTexture:c,resolvedPbrTexture:d,resolvedMetallic:_,resolvedRoughness:u}=a,{modelId:h}=a,f=t.getModel(h!=null?h:NaN,r);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 x=d!==void 0&&f.textures[d];x?(i.enableTexture(x,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)},wn=(s,e,{renderer:t},i,o)=>{let r=i.renderingProperties.resolvedHeightFactor||0;r=li+(1-li)*r,t.bindShaderProgram(s,{u_float_height_factor:r})},Sn=(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})},Yo=(s,e,{modelLayer:t,renderer:i},o,r)=>{if(o.attributes.id===void 0)return;const a=t.getOpacity(o.attributes.id,r.minzoom),c=t.getBuildingHeight(o.attributes.id)===1?1:a;i.bindShaderProgram(s,{u_float_height_factor:c})},Tn=(s,e,{renderer:t},i,o)=>{const r=ke(e,i),a=n.resolveNumber(o.style.height,r);t.bindShaderProgram(s,{u_float_height_factor:n.mapHeightToTileHeight(a)})},Je=(s,e,t,i,o)=>{const{floorManager:r,buildingHeightAnimator:a,modelsScene:l,modelLayer:c,renderer:d}=t;if(i.symbol==="polygonExtrusion"&&i.attributes.floorId&&"isFloorStack"in i.attributes&&i.attributes.isFloorStack){d.bindShaderProgram(s,{u_float_height_factor:r.getFloorStackObjectHeight(i.attributes.floorId)});return}if(i.symbol==="polygonExtrusion"&&i.attributes.isHole){d.bindShaderProgram(s,{u_float_height_factor:1});return}let _=a.getBuildingHeight(o.minzoom);_=li+(1-li)*_;const u=l.objectIdToKey(i.id);u&&c.setBuildingHeight(u,_),d.bindShaderProgram(s,{u_float_height_factor:_})};function ke(s,e){return n.makeBinderContext(s.styleZoom,s.styleState,e.attributes.tileData,!1,e.tile.dynamicObject)}const Mn=(s,e,{renderer:t},i)=>{const{tile:o}=i,r=i.renderingProperties.widthResolved||0;t.bindShaderProgram(s,{u_float_width:n.zptToSceneDistance(r,o.size)/2*n.uint16ToTileCoords,u_float_width_offset:n.zptToSceneDistance(n.uint16ToTileCoords/window.devicePixelRatio,o.size)/2})},Rh=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.resolvedRadius;t.bindShaderProgram(s,{u_float_radius:o*window.devicePixelRatio})},Fh=(s,e,{renderer:t},i,o)=>{const r=n.resolveNumber(o.style.intensity,ke(e,i));t.bindShaderProgram(s,{u_float_intensity:r})},$t=(s,e,{renderer:t},i,o)=>{const r=ke(e,i);let a=n.resolveNumber(o.style.textFontSize,r);if(i.symbol==="point"){const l=i.attributes.labelIndex;l===n.LabelIndex.Second&&o.style.textFontSize2?a=n.resolveNumber(o.style.textFontSize2,r):l===n.LabelIndex.Icon&&o.style.iconTextFontSize&&(a=n.resolveNumber(o.style.iconTextFontSize,r))}t.bindShaderProgram(s,{u_float_scale:a*window.devicePixelRatio/n.fonts.baseSize})},En=(s,e,{renderer:t},i,o)=>{const r=n.makeBinderContext(e.styleZoom,e.styleState,i.attributes.tileData,!!i.layerSettings.isOverlappedObject),{textFontSize:a,textColor:l,textHaloWidth:c,textHaloColor:d}=o.style,_=n.resolveNumber(a,r)/n.fonts.baseSize,u=_*window.devicePixelRatio,h=n.fonts.gamma/u,f=i.layerSettings.uniformSet,m=f==="fontHalo"?(6-n.resolveNumber(c,r)/_)/8:.75;let p;f==="fontHalo"?p=n.getColorForShaders(n.resolveColor(d,r)):p=n.getColorForShaders(n.resolveColor(l,r)),t.bindShaderProgram(s,{u_float_buffer:m,u_float_gamma:h,u_vec4_color:p})},wa=(s,e,{renderer:t},i,o)=>{const{layerSettings:r}=i,{uniformSet:a}=r,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}Dh(s,t,e,i,d,u,_,h,l,a)},Dh=(s,e,t,i,o,r,a,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(a,_)/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(r,_)),_.isBehind=!0,v=n.getColorForShaders(n.resolveColor(r,_))),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})},In=(s,e,{renderer:t},i)=>{const{attributes:o}=i,{offsetX:r,offsetY:a}=o,l=window.devicePixelRatio;t.bindShaderProgram(s,{u_vec2_offset:[r*l,a*l]})},Cn=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_float_style_zoom:e.styleZoom})},wt=(s,e,{renderer:t},i)=>{const{tile:o}=i,{zoom:r}=e,a=n.tileSizeZpt*Math.pow(2,r-o.zoomLevel)*window.devicePixelRatio;t.bindShaderProgram(s,{u_float_tile_to_pixel_ratio:n.uint16ToTileCoords/a})},Sa=(s,e,{renderer:t},i,o)=>{const{tile:r}=i,{zoom:a,styleZoom:l}=e,c=o.style.lengthUnits===n.LengthUnits.Meters,d=n.tilePointScaleFactor(n.createTileInfo(r.coords),[n.maxTilePoint/2,n.maxTilePoint/2]),_=n.uint16ToTileCoords/(n.tileSizeZpt*Math.pow(2,a-r.zoomLevel)*window.devicePixelRatio),u=c?l:Math.floor(l),h=n.tileSizeZpt*Math.pow(2,u-r.zoomLevel)*window.devicePixelRatio/(n.uint16ToTileCoords*d);t.bindShaderProgram(s,{u_vec2_scales:[h,_]})},Ta=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.flatTexture;o&&t.enableTexture(o,0),t.bindShaderProgram(s,{u_flat_tex:0})},Ma=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.flatIdentifyTexture;o&&t.enableTexture(o,0),t.bindShaderProgram(s,{u_flat_tex:0})},Ea=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.hillshadeTexture;o&&(t.enableTexture(o,Fo),t.bindShaderProgram(s,{u_hillshade_tex:Fo}))},Oh=(s,e,t,i)=>{const{renderer:o,demManager:r}=t,a=i.renderingProperties.demTexture;a&&(o.enableTexture(a,0),o.bindShaderProgram(s,{u_tex_dem:0,u_mat4_dem_corrected:r.demCorrectedFbVpToDemTex}))},Li=(s,e,{renderer:t},i,o)=>{let r=!0;e.globeMode||(r=!!n.resolveNumber(o.style.elevation,ke(e,i))),t.bindShaderProgram(s,{u_bool_skip_height_factor:r})},Xe=(s,e,{buildingHeightAnimator:t,renderer:i},o,r)=>{if(o.attributes.floorId||"isHole"in o.attributes&&o.attributes.isHole){i.bindShaderProgram(s,{u_float_height_factor:1});return}let a=t.getBuildingHeight(r.minzoom);a=li+(1-li)*a,i.bindShaderProgram(s,{u_float_height_factor:a})},Ae=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_int_abs_z:i.attributes.absZ?1:0})},Qo=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_int_abs_z:!1})},Jo=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_float_tile_size:n.tileZoomToSize(i.tile.zoomLevel)})},Nh=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_vec4_color:n.LABELING_TEXTURE_DEM_MESH_COLOR})},O=(s,e,{renderer:t},i,o,r)=>{t.bindShaderProgram(s,{u_float_dem_scale:r?e.elevationScale:0})},Ao=(s,e,{renderer:t},i)=>{if(!i.attributes.meshTier)return;const o=i.layerSettings.identify?t.getMapMeshIdFramebufferId():t.getMapMeshFramebufferId(),r=t.getFramebuffer(o),a=r==null?void 0:r.renderTarget.getTexture(),l=r==null?void 0:r.scale;a&&(t.enableTexture(a,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)}))},et=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_int_identify:i.layerSettings.identify||i.layerSettings.depthTest?1:0})},kh=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_float_scale:i.meta.scale,u_vec3_transform:i.meta.transform})};function M(...s){return(e,t,i,o,r,a)=>{s.forEach(l=>l(e,t,i,o,r,a))}}const di=(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),Uh=(s,e,{renderer:t},i)=>{const o=!!i.attributes.floorId,r=Array.isArray(e.styleState._backgroundFloorIds)&&e.styleState._backgroundFloorIds.length>0;t.bindShaderProgram(s,{u_int_is_3dfloor_object:o&&r})},ee=(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"&&"isFloorStack"in o.attributes&&o.attributes.isFloorStack){i.bindShaderProgram(s,{u_float_floor_elevation:t.getFloorStackObjectElevation(o.attributes.floorId)/o.tile.renderModelMatrix[10]});return}const r=o.symbol==="mesh"&&o.sink==="inverse",a=(t.getFloorObjectElevation(o.attributes.floorId)-(r?e.zoom>=17?1:3:0))/o.tile.renderModelMatrix[10];i.bindShaderProgram(s,{u_float_floor_elevation:a})},gt=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_float_floor_elevation:0})},Pi=(s,e,t,i)=>{t.renderer.bindShaderProgram(s,{u_int_is_roof:i.symbol==="polygonExtrusion"&&i.sink==="topFill"?1:0})},Pt=(s,e,t,i)=>{t.renderer.bindShaderProgram(s,{u_int_is_hole:i.attributes.isHole?1:0})},Ln=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_color_effect_mix_factor:0})},Nt=(s,e,t,i,o)=>{if(o.style.colorEffect){const r=ke(e,i),a=n.resolveExpression(o.style.colorEffect,r);if(a.effect.type==="mix"){const l=a.effect.factor;if(l>0){const c=n.getColorForShaders(a.effect.color);t.renderer.bindShaderProgram(s,{u_vec4_color_effect_mix_rgba:c,u_float_color_effect_mix_factor:l});return}}}t.renderer.bindShaderProgram(s,{u_float_color_effect_mix_factor:0})},Ia=(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]})},Hh=(s,e,t,i,o)=>{var p;const r=i.attributes.textureIndex,a=(p=o.style.sideTextures)==null?void 0:p[r],l=t.imageManager.getTexture(o.sideTextureIndices[r]),c=n.MAP_POINTS_IN_METER*n.tilePointScaleFactor(n.createTileInfo(i.tile.coords),[0,0]),d=l.options.size,_=[a.texturePadding[3]/d[0],a.texturePadding[0]/d[1],a.texturePadding[1]/d[0],a.texturePadding[2]/d[1]],u=a.wallPadding.map(v=>v*c),h=a.sliceSize.map(v=>v*c),f=[a.horizontal.maxInterval*c,a.vertical.maxInterval*c],m=[Ca(a.horizontal.mode),Ca(a.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:[a.horizontal.slicesCount,a.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 Ca(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 Gh="FRAGMENT",Vh="VERTEX",jh="FOG",Zh="SKY",$h="METALLIC_ROUGHNESS_DEBUG",Wh="PBR_TEXTURE",Xh="AO_TEXTURE",Kh="MAP_MESH_TEXTURE",qh="COLOR_TEXTURE",La="ALPHA_MODE",Yh="1",Qh="2",Pa="LIGHT_MODEL",Jh="1",Ah="2",ef="DEPTH_TEXTURE_SHADOW",tf="RENDER_SHADOWS",nf="UBO",of="SCREENDOOR",sf="ENTRANCE_ARROWS_ROUNDING",rf="MALI_GPU",af="VARYINGS_LIMIT_9",es="MIX_COLOR_MODE",lf="1",Ba="2",cf="MIX_COLOR_MODE_VERTEX_ATTRIBUTE_NAME",df="1",_f=n.Shader.createShaderDefinitions([{type:es,value:lf}]),uf=n.Shader.createShaderDefinitions([{type:es,value:Ba}]),hf=n.Shader.createShaderDefinitions([{type:es,value:Ba},{type:cf,value:df}]),ff={value:[0,0,0]};function ge(s,e){return n.makeBinderContext(s.styleZoom,s.styleState,e.attributes.tileData,!1,e.tile.dynamicObject)}const mf=(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},ts=(s,e)=>{const t=e.assetManager.textures[s.attributes.atlasIndex];return t?(s.renderingProperties.atlasTexture=t,!0):!1},za=(s,e)=>{const t=e.imageManager.getTexture(s.attributes.textureIndex);return t?(s.renderingProperties.texture=t,!0):!1},_i=(s,e)=>{const{range:t,fontIndex:i,styleId:o}=s.attributes,r=e.styleManager.getStyle(o);if(!r)return!1;const a=r.fonts[i],l=e.assetManager.getFontTextureByName(a,t);return l?(s.renderingProperties.fontTexture=l,!0):!1},is=(s,e)=>{const t=s.layerSettings.identify?e.renderer.getMapMeshIdFramebufferId():e.renderer.getMapMeshFramebufferId(),i=e.renderer.getFramebuffer(t),o=i==null?void 0:i.renderTarget.getTexture(),r=i==null?void 0:i.scale;return!(!o||!r)},pf=(s,{imageManager:e})=>{const t=e.getTexture(s.attributes.rampTextureIndex);return t?(s.renderingProperties.rampTexture=t,!0):!1},vf=(s,e)=>{var o;const t=e.demManager.getDemFramebufferId(),i=(o=e.renderer.getFramebuffer(t))==null?void 0:o.renderTarget.getTexture();return i?(s.renderingProperties.demTexture=i,!0):!1},Ra=(s,{demManager:e,renderer:t,map:i})=>{var a;if(!i.state.demMode)return!1;const o=e.getHillshadeFramebufferId(),r=(a=t.getFramebuffer(o))==null?void 0:a.renderTarget.getTexture();return r?(s.renderingProperties.hillshadeTexture=r,!0):!1},Fa=(s,{demManager:e,renderer:t,map:i})=>{if(!i.state.demMode)return!1;const o=e.getFlatFramebufferId(),r=t.getFramebuffer(o);if(!r)return!1;const a=r.renderTarget.getTexture();return a?(s.renderingProperties.flatTexture=a,!0):!1},Da=(s,{demManager:e,renderer:t,map:i})=>{if(!i.state.demMode)return!1;const o=e.getIdentifyFlatFramebufferId(),r=t.getFramebuffer(o);if(!r)return!1;const a=r.renderTarget.getTexture();return a?(s.renderingProperties.flatIdentifyTexture=a,!0):!1},gf=(s,e,t,i)=>{var l,c;const{renderingProperties:o}=s,{resolvedUvIndex:r}=o,{colorTextureUvIndex:a}=i.style;return a!==void 0&&r!==a&&(((c=(l=s.meta)==null?void 0:l.availableTextureCoords)!=null?c:[])[a]&&s.vao.setAttributesAliases({texcoord_color:`texcoord_${a}`}),o.resolvedUvIndex=a),!0},yf=(s,e,t,i)=>{var h,f;const{styleId:o,colorTexture:r,aoTexture:a,pbrTexture:l,meshTier:c}=s.attributes,{renderingProperties:d}=s,{modelId:_}=d,u=e.assetManager.getModel(_!=null?_:NaN,o);return!u||(r!==void 0&&u.textures[r]&&(d.resolvedColorTexture=r),a!==void 0&&u.textures[a]&&(d.resolvedAoTexture=a),l!==void 0&&u.textures[l]?d.resolvedPbrTexture=l:(d.resolvedMetallic=(h=s.attributes.metallic)!=null?h:i.style.metallic,d.resolvedRoughness=(f=s.attributes.roughness)!=null?f:i.style.roughness),!d.resolvedColorTexture&&!d.color)?!1:c?is(s,e):!0},Oa=(s,{modelsScene:e})=>{const t=e.getModelOpacity(s);return s.renderingProperties.resolvedOpacity=t,t!==0},Na=(s,{modelsScene:e})=>{const t=e.getModelHeightFactor(s);return s.renderingProperties.resolvedHeightFactor=t,t!==0},ka=(s,e,t,i)=>{const o=ge(t,s),r=n.resolveNumber(i.style.width,o);if(r===0)return!1;const a=n.resolveExpression(i.style.pattern,o);return!a||a[0]===n.LinePatternType.None?!1:(s.renderingProperties.width=r,s.renderingProperties.pattern=a,!0)},xf=(s,e,t)=>ds(t,s.attributes.animDirection)!==0,Ua=(s,e,t,i)=>{const o=ge(t,s);return n.resolveNumber(i.style.iconOpacity,o)*ds(t,s.attributes.animDirection)!==0},Ha=(s,e)=>!e.map.getFeatureFlag("transparentBuildingsOff")||s.attributes.isHole,U=(s,e,t,i)=>bf(s.tile,t,i),Ga=(s,e,t)=>{var o,r,a,l,c,d;if((o=s.meta)!=null&&o.planId&&(!t.styleState._activeFloorIds||!(t.styleState._activeFloorIds.includes(s.meta.planId)||t.styleState._backgroundFloorIds.includes(s.meta.planId)))||(a=(r=s.meta)==null?void 0:r.linkedIds)!=null&&a.length&&!((l=s.meta)!=null&&l.planId)&&e.floorManager.hasDisplayedFloorBuilding(s.meta.linkedIds))return!1;const i=(c=s.meta)==null?void 0:c.buildingId;return!(i&&((d=s.tile.ids)!=null&&d.isHidden(i)))},bf=(s,e,t)=>{const{purpose:i,detailLevel:o}=s,{styleZoom:r}=e;switch(i){case"zenith":case"traffic":case"geojson":const a=o<Df(i)?n.clamp(r,o,o+.99999):r;return t.minzoom<=a&&a<t.maxzoom;case"dynamicObject":return t.minzoom<=r&&r<=t.maxzoom;default:return t.minzoom<=r&&r<t.maxzoom}},wf=(s,e,t)=>{var a;const{styleZoom:i}=t,{tile:o}=s;if(o.purpose!=="zenith"||i>n.tiles.maxUniverseZoom)return!0;let r=n.tiles.maxUniverseZoom;if(o.sourceId){const l=e.sourceStorage.getSourceById(o.sourceId);r=(l==null?void 0:l.type)==="zenith"&&(a=l.getOptions().strokeMinZoom)!=null?a:n.tiles.maxUniverseZoom}return i>r},tt=(s,e,t,i)=>{const{styleZoom:o}=t;return o>=i.minzoom&&o<i.maxzoom},Pn=s=>!s.attributes.isHole,ns=(s,e)=>s.attributes.id===void 0?!0:!e.modelLayer.isHidden(s.attributes.id),os=(s,e,t,i)=>{const o=ge(t,s);return n.resolveNumber(i.style.iconWidth,o)>0},Va=(s,e,t,i)=>{const{layerSettings:o}=s,{uniformSet:r}=o,a=s.attributes.labelIndex,l=i.style;if(r==="fontHalo"){let{textHaloColor:c}=l;switch(a){case n.LabelIndex.Icon:c=l.iconTextHaloColor;break;case n.LabelIndex.Second:c=l.textHaloColor2;break}if(!c)return!1}return!0},Bn=(s,e,t,i)=>!(s.layerSettings.uniformSet==="fontHalo"&&!i.style.textHaloColor),ss=(s,e,t,i)=>{var l,c,d,_,u,h;const o=ge(t,s),r=i.style;if(s.symbol==="point")switch(s.attributes.labelIndex){case n.LabelIndex.Second:return((c=n.resolveNumber((l=r.textHaloWidth2)!=null?l:null,o))!=null?c:0)>0&&!!r.textHaloColor2;case n.LabelIndex.Icon:return((_=n.resolveNumber((d=r.iconTextHaloWidth)!=null?d:null,o))!=null?_:0)>0&&!!r.iconTextHaloColor;case n.LabelIndex.First:break}return((h=n.resolveNumber((u=r.textHaloWidth)!=null?u:null,o))!=null?h:0)>0&&!!r.textHaloColor},ja=(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},ct=(s,e,t,i)=>{const o=n.resolveNumber(i.style.width,ge(t,s));return s.renderingProperties.widthResolved=o,o!==0},Bi=(s,e,t,i)=>{const o=ge(t,s),r=n.resolveNumber(i.style.strokeWidth,o);return s.renderingProperties.widthResolved=r,r!==0},Sf=(s,e,t,i)=>{const o=ge(t,s),r=n.resolveNumber(i.style.strokeWidth,o);if(r===0)return!1;const a=n.resolveNumber(i.style.width,o);return s.renderingProperties.widthResolved=a+r*2,!0},Tf=(s,e,t,i)=>{const o=ge(t,s),r=n.resolveNumber(i.style.strokeWidth2,o);if(r===0)return!1;const a=n.resolveNumber(i.style.width,o),l=n.resolveNumber(i.style.strokeWidth,o);return s.renderingProperties.widthResolved=a+l*2+r*2,!0},Mf=(s,e,t,i)=>{const o=ge(t,s),r=n.resolveNumber(i.style.width,o),a=n.resolveNumber(i.style.strokeWidth,o),l=n.resolveNumber(i.style.strokeWidth2,o),c=r+a*2+l*2;return s.renderingProperties.widthResolved=c,c!==0},Bt=(s,e,t)=>{const i=ds(t,s.attributes.animDirection);return s.renderingProperties.opacityResolved=i,i!==0},Ef=(s,e,t,i)=>(s.renderingProperties.resolvedRadius=n.resolveNumber(i.style.radius,ge(t,s)),s.renderingProperties.resolvedRadius>0),Za=(s,e,t,i)=>{var l;s.renderingProperties.mat4_gradient||(s.renderingProperties.mat4_gradient=new Float32Array(16));let o;switch(s.attributes.side){case n.MeshFillSide.top:o=(l=i.style.topColor)!=null?l:i.style.color;break;case n.MeshFillSide.side:o=i.style.sideColor;break;case n.MeshFillSide.bottom:o=i.style.bottomColor;break}const r=ge(t,s),a=n.resolveExpression(o,r);return s.renderingProperties.mat4_gradient[0]=0,n.isStyleColor(a)?nt(s,a):n.isStyleGradient(a)&&(_s(a,s.tile.readiness,s.renderingProperties.mat4_gradient),a.mixFactor&&(s.renderingProperties.mixFactorColor=a.mixFactor)),!0},rs=(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,ge(t,s));return o?(n.copy$1(s.renderingProperties.color.value,o.values[0].value),_s(o,s.tile.readiness,s.renderingProperties.mat4_gradient),o.mixFactor&&(s.renderingProperties.mixFactorColor=o.mixFactor),s.renderingProperties.color.value[3]!==0):(s.renderingProperties.mat4_gradient[0]=0,!0)},$a=(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 r=ge(t,s),a=n.resolveColor(i.style.sideColor,r).value,l=n.equals(o.value,a),c=l?i.style.sideColor:i.style.sideStrokeColor,d=n.resolveGradient(c,ge(t,s));return d?(n.copy$1(o.value,d.values[0].value),s.renderingProperties.mixFactorColor=d.mixFactor,_s(d,s.tile.readiness,s.renderingProperties.mat4_gradient)):s.renderingProperties.mat4_gradient[0]=0,l&&(o.value[3]*=t.stillness),o.value[3]!==0},fe=(s,e)=>!("hiddenByFloorComplexId"in s.attributes)||!s.attributes.hiddenByFloorComplexId?!0:!e.floorManager.hasDisplayedFloorBuilding([s.attributes.hiddenByFloorComplexId]),If=(s,e,t,i)=>!!s.attributes.floorId||!!s.attributes.isHole,Y=(s,e,t,i)=>{if(!s.attributes.floorId)return!0;if(s.symbol==="polygonExtrusion"&&"isFloorStack"in s.attributes&&s.attributes.isFloorStack)return e.floorManager.isVisibleFloorStackObject(s.attributes.floorId);const o=s.symbol==="mesh"?"all-floors":String(i.style.floorCulling);return e.floorManager.isVisibleFloorObject(s.attributes.floorId,o)},Cf=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},Wa=(s,e,t,i)=>{const o=n.makeBinderContext(t.styleZoom,t.styleState,s.attributes.tileData,!!s.layerSettings.isOverlappedObject);return nt(s,n.resolveColor(i.style.color,o)),s.renderingProperties.color.value[3]!==0},as=(s,e,t,i)=>(nt(s,n.resolveColor(i.style.topColor,ge(t,s))),s.renderingProperties.color.value[3]!==0),zn=(s,e,t,i)=>(nt(s,n.resolveColor(i.style.sideColor,ge(t,s))),s.renderingProperties.color.value[3]!==0),zi=(s,e,t,i)=>(nt(s,n.resolveColor(i.style.strokeColor,ge(t,s))),s.renderingProperties.color.value[3]!==0),Lf=(s,e,t,i)=>{switch(s.attributes.side){case n.MeshFillSide.top:nt(s,n.resolveColor(i.style.strokeColor,ge(t,s)));break;case n.MeshFillSide.side:nt(s,n.resolveColor(i.style.sideColor,ge(t,s)));break;case n.MeshFillSide.bottom:nt(s,n.resolveColor(i.style.bottomColor,ge(t,s)));break;default:nt(s,ff);break}return s.renderingProperties.color.value[3]!==0},Pf=(s,e,t,i)=>(nt(s,n.resolveColor(i.style.strokeColor2,ge(t,s))),s.renderingProperties.color.value[3]!==0),ls=(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},Xa=(s,e,t,i)=>{const o=s.renderingProperties.color;if(!o)return!1;const r=ge(t,s),a=n.resolveColor(i.style.strokeColor,r).value,l=n.resolveNumber(i.style.strokeWidth,r);return n.equals(o.value,a)&&o.value[3]===1&&l<=1&&(o.value[3]*=t.stillness),o.value[3]!==0},Bf=(s,e,t,i)=>{const o=s.renderingProperties.color;if(!o)return!1;const r=ge(t,s),a=n.resolveColor(i.style.topColor,r).value,l=n.resolveNumber(i.style.strokeWidth,r);return n.equals(o.value,a)&&o.value[3]===1&&l<=1&&(o.value[3]*=t.stillness),o.value[3]!==0},Ka=(s,e,t,i)=>{const o=n.resolveColor(i.style.sideStrokeColor,ge(t,s));return nt(s,o),s.renderingProperties.color.value[3]!==0},it=(s,e,t,i)=>{const o=n.resolveColor(i.style.color,ge(t,s),!0),r=n.isStyleMixColor(o)?o.color1:o;if(nt(s,r),n.isStyleMixColor(o)&&!(o.factor.type==="read-from-target"&&!e.renderer.doesDrawTargetFramebufferExist(o.factor.name))){if(Of(s,o),s.renderingProperties.color.value[3]===0&&s.renderingProperties.mixColor.color2.value[3]===0)return!1;const{factor:{type:a,name:l}}=s.renderingProperties.mixColor;switch(a){case"read-from-target":{s.shaderDefinitions=_f;break}case"vertex-attribute":{switch(l){case"denormalized_distance_to_line":s.shaderDefinitions=hf;break;default:s.shaderDefinitions=uf;break}break}default:n.assertUnreachable(a)}return!0}return s.renderingProperties.color.value[3]!==0},zf=(s,e,t,i)=>{nt(s,n.resolveColor(i.style.color,ge(t,s)));const{color:o,resolvedOpacity:r}=s.renderingProperties;return n.mul(o.value,o.value,s.attributes.colorFactor),o.value[3]*=r!=null?r:0,o.value[3]!==0},qa=(s,e)=>{const t=s==null?void 0:s.attributes.parentId;if(!t)return!0;const{floorManager:i}=e;if(i.hasDisplayedFloorBuilding([t])&&s.attributes.floorId)return!0;const r=s==null?void 0:s.tile.ids;return!(r!=null&&r.isHidden(t,n.HideLevel.PolygonExtrusion))},cs=B(U,qa,fe,(s,e)=>{if(!s.bboxWorld||s.tile.dynamicObject||s.renderingProperties.animationStack&&s.renderingProperties.animationStack.length>0||s.attributes.floorId&&e.floorManager.visibleComplexIsMetro)return!0;if(e.environmentManager.isAABBInFog(s.bboxWorld))return!1;const t=e.camera.getViewportVertices();return n.tetragonIntersectsBounds(t,s.bboxWorld)},Y,Ga,Oa,Na,zf),Rf=B(U,qa,fe,Ga,Oa,Na),Ya=B(gf,yf),Ff=(s,e,t,i)=>{var l;const o=s.attributes.textureIndex,r=(l=i.style.sideTextures)==null?void 0:l[o],a=e.imageManager.getTexture(i.sideTextureIndices[o]);return!!r&&!!a};function B(...s){return(e,t,i,o)=>{for(const r of s)if(!r(e,t,i,o))return!1;return!0}}function Df(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 ds(s,e){return e===n.LabelingAnimation.none?1:e===n.LabelingAnimation.fadeIn?s.labelingOpacity:1-s.labelingOpacity}function _s(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],r=n.getColorForShaders(o);n.scale$4(r,r,e),t[i+1]=s.steps[i];const a=(i+1)*4;t[a]=r[0],t[a+1]=r[1],t[a+2]=r[2],t[a+3]=r[3]}}function nt(s,e){s.renderingProperties.color||(s.renderingProperties.color=n.toStyleColor([255,255,255,255])),n.copy$1(s.renderingProperties.color.value,e.value),e.mixFactor&&(s.renderingProperties.mixFactorColor=e.mixFactor)}function Of(s,e){s.renderingProperties.mixColor=e}function Qa(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 Ja(s){let e;try{e={url:`data:image/svg+xml;base64,${btoa(s)}`}}catch(t){const i=URL.createObjectURL(new Blob([s],{type:"image/svg+xml"}));e={url:i,revokeURL:()=>URL.revokeObjectURL(i)}}return e}function Rn(s,e="image/png"){const t=new Blob([s],{type:e}),i=URL.createObjectURL(t),o=document.createElement("img");return new Promise(r=>{o.onload=()=>{URL.revokeObjectURL(i),r(o)},s.byteLength===0?o.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=":o.src=i})}function Aa(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 el(s,e,t){var _;const i=e[s.outputBufferView],o=(_=t.get(s.actionId))!=null?_:-1,r=Math.ceil(o),a=Math.floor(o),l=(o||1)%1,c=Math.round(o);return!i||t.size<=0||a<0||r<0||c<0?void 0:{outputTransforms:new Float32Array(fs(i),s.outputBufferOffset,s.outputBufferLength),selfKeyFrame:c,selfKeyFrameMin:a,selfKeyFrameMax:r,keyFrameLerp:l}}const Nf={SCALAR:1,VEC2:2,VEC3:3,VEC4:4};function tl(s,e,t){const{outputTransforms:i,selfKeyFrame:o,selfKeyFrameMin:r,selfKeyFrameMax:a,keyFrameLerp:l}=t,c=Nf[s];if(e==="STEP")return us(i,o,c);const d=us(i,r,c),_=us(i,a,c);switch(s){case"SCALAR":return[n.lerp$2(d[0]||0,_[0]||0,l)];case"VEC2":{const u=n.create$6();return n.lerp$1(u,d,_,l),Array.from(u)}case"VEC3":{const u=n.create$1();return n.lerp(u,d,_,l),Array.from(u)}case"VEC4":{const u=n.create$5();return n.slerp(u,d,_,l),Array.from(u)}}}function il(s,e,t,i){let o=[0,0],r=[1,1],a=0;i&&e.forEach(u=>{if(!u.targetPointerExtension)return;const h=el(u,t,i);if(!h)return;const f=tl(u.outputType,u.interpolation,h);u.outputType==="SCALAR"?u.targetPointerExtension==="KHR_texture_transform/rotation"&&(a=f[0]):u.outputType==="VEC2"&&(u.targetPointerExtension==="KHR_texture_transform/offset"&&(o=f),u.targetPointerExtension==="KHR_texture_transform/scale"&&(r=f))});const l=[1,0,0,0,1,0,o[0],o[1],1],c=[Math.cos(a),Math.sin(a),0,-Math.sin(a),Math.cos(a),0,0,0,1],d=[r[0],0,0,0,r[1],0,0,0,1],_=n.multiply$1(n.create$4(),l,c);s=n.multiply$1(s,_,d)}function nl(s,e,t,i,o){const r=Array();o&&e.forEach(a=>{if(a.targetPointerExtension)return;const l=el(a,i,o);if(!l)return;const c=tl(a.outputType,a.interpolation,l);(a.outputType==="VEC4"||a.outputType==="VEC3")&&(t[a.targetMatIndex[0]][a.targetMatIndex[1]]=c)});for(let a=0;a<t.length;a++){const l=t[a];if(l.length===3){const c=n.create$2();n.fromRotationTranslationScale(c,l[1],l[0],l[2]),r.push(c)}else r.push(l)}Kf(s,r)}function us(s,e,t){if(t!==3&&t!==4&&t!==2&&t!==1)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 kf(s,e,t,i){s.animations.forEach((o,r)=>{o.channels.forEach((a,l)=>{var d,_;const c=(_=(d=a.target)==null?void 0:d.extensions)==null?void 0:_.KHR_animation_pointer;if(c){const u=c.pointer,h=Hf(u);if(!h){console.warn(`Unsupported pointer target "${u}" in animation "${o.name}". Skip this animation channel.`);return}const f=u.split("/");if(f[1]==="materials"&&+f[2]===i){const m=o.samplers[a.sampler],p=o.name||"default",v=s.accessors[m.input];if(v.bufferView===void 0||s.bufferViews[v.bufferView]===void 0)return;Fn(e,s,v.bufferView,v.componentType);const g=s.accessors[m.output];if(g.bufferView===void 0)return;const y=s.bufferViews[g.bufferView];if(y===void 0)return;Fn(e,s,g.bufferView,g.componentType),(m.interpolation||"LINEAR")!=="LINEAR"&&(m.interpolation||"LINEAR")!=="STEP"&&console.warn(`Unsupported interpolation type "${m.interpolation}" in animation "${p}". Fall back to LINEAR interpolation.`);const b=ol(h);t.push({min:v.min,max:v.max,frameCount:v.count,keyFrameType:"SCALAR",interpolation:m.interpolation||"LINEAR",outputType:b.outputType,outputBufferView:g.bufferView,outputBufferOffset:y.byteOffset||0,outputBufferLength:y.byteLength/b.bufferStride,targetMatIndex:[],actionId:`${o.name}_${r}_${l}`,animationIndex:r,animationName:p,targetPointerExtension:h})}}})})}function Uf(s,e,t,i,o){s.animations.forEach((r,a)=>{r.channels.forEach((l,c)=>{if(l.target.node===t){const d=r.samplers[l.sampler],_=r.name||"default",u=s.accessors[d.input];if(u.bufferView===void 0||s.bufferViews[u.bufferView]===void 0)return;Fn(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;Fn(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=ol(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:`${r.name}_${a}_${c}`,animationIndex:a,animationName:_})}})})}function Hf(s){if(s.includes("KHR_texture_transform/offset"))return"KHR_texture_transform/offset";if(s.includes("KHR_texture_transform/rotation"))return"KHR_texture_transform/rotation";if(s.includes("KHR_texture_transform/scale"))return"KHR_texture_transform/scale"}function ol(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;break;case"KHR_texture_transform/offset":e=-1,t="VEC2";break;case"KHR_texture_transform/rotation":e=-1,t="SCALAR";break;case"KHR_texture_transform/scale":e=-1,t="VEC2";break}return{targetindex:e,outputType:t,bufferStride:i}}function Fn(s,e,t,i){const o=e.bufferViews[t];if(o===void 0)return;if(!s.buffers[t]){const a=e.buffers[o.buffer].buffer;if(!a)return;s.buffers[t]=fs(a)}const r=s.buffers[t];if(!(r instanceof n.Buffer))return r}function Gf(s,e){for(let t=s.length-1;t>=0;t--){const i=s[t];if(e(i,t,s))return i}}const Vf=new Set(["position","texcoord_0","texcoord_1","texcoord_2","texcoord_3","normal","tangent"]),jf=Array.from(n.create$2()),Zf={pbrMetallicRoughness:{baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1},emissiveFactor:[0,0,0],alphaMode:"OPAQUE",alphaCutoff:.5,doubleSided:!1};function $f(s){return sl(s,Zf),s}function sl(s,e){for(const t in e)s[t]===void 0?s[t]=e[t]:typeof s[t]=="object"&&sl(s[t],e[t])}var ot=(s=>(s[s.Pending=1]="Pending",s[s.Loaded=2]="Loaded",s[s.Failed=3]="Failed",s))(ot||{});function Wf(s){return{buffers:[],textures:[],status:1,scenes:[],defaultScene:0,preserve:s}}function Xf(s,e,t,i,o,r){var c;const a=[],l=[];for(const d of t.scenes){const _=[];rl(_,s,d.nodes,t,a,l,e,i,o,r),s.scenes.push({id:n.uniqId(),name:d.name,objects:_})}return s.defaultScene=(c=t.scene)!=null?c:0,s}function rl(s,e,t,i,o,r,a,l,c,d){var u,h,f,m,p,v;if(!t)return;const _=a.symbolSettingsList.gltfModel.instances;if(!(!_||_.length===0))for(const x of t){const g=i.nodes[x];if(n.isObject(g.extras)&&g.extras.ignore)continue;const y=[...o],b=[...r];if(g.matrix&&y.push(g.matrix),g.translation&&g.rotation&&g.scale){const S=[];S.push(g.translation,g.rotation,g.scale),y.push(S),Uf(i,e,x,b,y)}if(g.mesh!==void 0){const S=i.meshes[g.mesh];let T=d?n.GltfDemPosition.flat:n.GltfDemPosition.default;n.isObject(g.extras)&&(g.extras.dem==="flat"?T=n.GltfDemPosition.flat:g.extras.dem==="instance"&&(T=n.GltfDemPosition.default));const z=new Float32Array(16),E=new Float32Array(9);il(E,b,e.buffers),nl(z,b,y,e.buffers);let P,k;if(g.children){const R=[];for(const C of g.children){const F=i.nodes[C];Qf(F)&&R.push(F)}if(R.length){const C=R[0];if(C.extras.dem==="centroid")T=n.GltfDemPosition.centroid,P=[C.translation[0],C.translation[2]];else if(C.extras.dem==="axis"){T=n.GltfDemPosition.axis;const F=Gf(R,se=>se.extras.dem==="axis");k=[C.translation[0],C.translation[2],(F!=null?F:C).translation[0],(F!=null?F:C).translation[2]]}}}for(const R of S.primitives){const C=[],F={};let se=0,Q,le;for(const Me in R.attributes){const Dt=/TEXCOORD_(\d+)/.exec(Me);Dt&&(C[parseInt(Dt[1],10)]=!0);const Mt=Me.toLowerCase();if(!Vf.has(Mt))continue;const ei=R.attributes[Me],$e=i.accessors[ei];if($e.bufferView===void 0)continue;const vi=i.bufferViews[$e.bufferView];if(vi===void 0)continue;const Gi=al(a,e,i,$e.bufferView,$e.componentType);if(Gi){if(Mt==="position"&&(Q=$e.min,le=$e.max),Gi.purpose="gltfMesh",F[Me.toLowerCase()]=new n.BufferChannel(Gi,{itemSize:qf($e.type),dataType:n.componentTypeToWebGl($e.componentType),stride:(u=vi.byteStride)!=null?u:0,offset:(h=$e.byteOffset)!=null?h:0,normalized:!!$e.normalized}),!P&&Me.toLowerCase()==="position"){const qs=$e.min,Ys=$e.max;qs&&Ys&&(P=[(Ys[0]+qs[0])/2,(Ys[2]+qs[2])/2])}se===0&&(se=$e.count)}}Q||(Q=[0,0,0]),le||(le=[0,0,0]);let D;if(R.indices!==void 0){const Me=i.accessors[R.indices];if(Me.bufferView===void 0||(D=al(a,e,i,Me.bufferView,Me.componentType,!0),!D))continue;D.purpose="gltfIndices",se=Me.count}const Ke=R.material!==void 0?i.materials[R.material]:{},Se=$f(Ke),ye={},Ue={localMatrix:z,textureTransformMatrix:E,animationStack:b,transformStack:y,availableTextureCoords:C,attributesAliases:ye,colorFactor:[...Se.pbrMetallicRoughness.baseColorFactor],colorTexture:NaN,aoTexture:NaN,pbrTexture:NaN,centroid:P,axis:k,demPosition:T},Ze=[];Se.alphaMode==="OPAQUE"?Ze.push({type:La,value:Yh}):Se.alphaMode==="BLEND"&&Ze.push({type:La,value:Qh});const Rt=Se.pbrMetallicRoughness.baseColorTexture;Rt&&(Ze.push({type:qh}),ye.texcoord_color=`texcoord_${(f=Rt.texCoord)!=null?f:0}`,hs(e,i,Rt),Ue.colorTexture=Rt.index);const Le=Se.pbrMetallicRoughness.metallicRoughnessTexture;if(Le){Ze.push({type:Wh}),hs(e,i,Le),Ue.pbrTexture=Le.index;const Me=typeof Le.texCoord=="number"?Le.texCoord:0;ye.texcoord_pbr=`texcoord_${Me}`,C[Me]=!1}else Ue.roughness=(m=Se.pbrMetallicRoughness.roughnessFactor)!=null?m:1,Ue.metallic=(p=Se.pbrMetallicRoughness.metallicFactor)!=null?p:1;Number.isNaN(c.style.roughness)||Ze.push({type:$h}),((v=g.extras)==null?void 0:v.tier)!==void 0&&(Ue.meshTier=g.extras.tier,Ze.push({type:Kh})),c.style.lightingModel==="pbr"?Ze.push({type:Pa,value:Ah}):Ze.push({type:Pa,value:Jh});const Ft=Se.occlusionTexture;if(Ft){Ze.push({type:Xh}),hs(e,i,Ft),Ue.aoTexture=Ft.index;const Me=typeof Ft.texCoord=="number"?Ft.texCoord:0;ye.texcoord_ao=`texcoord_${Me}`,C[Me]=!1}kf(i,e,b,R.material),s.push({start:0,count:se,attributes:Ue,drawMode:R.mode,accessors:F,elementsBuffer:D,shaderDefinitions:Ze,bbox:{min:Q,max:le}})}}g.children&&rl(s,e,g.children,i,y,b,a,l,c,d)}}function hs(s,e,t){var c;const i=(c=t.index)!=null?c:0,o=e.textures[i];if(!o||o.source===void 0||o.sampler===void 0)return;const r=e.images[o.source],a=e.samplers[o.sampler];if(!a||!r)return;const l={flipY:!1};if(a.magFilter&&(l.magFilter=en(a.magFilter)),a.minFilter&&(l.minFilter=en(a.minFilter)),a.wrapS&&(l.wrapS=en(a.wrapS)),a.wrapT&&(l.wrapT=en(a.wrapT)),t.texCoord!==void 0&&(l.texcoord=t.texCoord),!r.image&&r.bufferView){Yf(e,r).then(d=>{d&&(r.image=d,s.textures[i]=new w(r.image,l))});return}s.textures[i]=new w(r.image,l)}function al(s,e,t,i,o,r=!1){const a=t.bufferViews[i];if(a===void 0)return;if(!e.buffers[i]){const c=t.buffers[a.buffer].buffer;if(!c)return;const d=new DataView(fs(c),a.byteOffset,a.byteLength),_=s.createBuffer(d,{dataType:n.componentTypeToWebGl(o)},r);e.buffers[i]=_}const l=e.buffers[i];if(!(l instanceof ArrayBuffer))return l}function Kf(s=[],e){if(e.length===0)return Array.from(jf);n.copy(s,e[0]);for(let t=1;t<e.length;t++)n.mul$1(s,s,e[t]);return s}function qf(s){switch(s[0]){case"S":return 1;case"V":return Number(s[3]);case"M":return qe(Number(s[3]),2)}return console.error(`Failed to determine channels count from accessor type = ${s}`),0}function fs(s){return s instanceof ArrayBuffer?s:s.buffer}function Yf(s,e){return K(this,null,function*(){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?Rn(new Uint8Array(i,t.byteOffset,t.byteLength),e.mimeType):!1})}function Qf(s){return s.mesh===void 0&&n.isObject(s.extras)&&(s.extras.dem==="centroid"||s.extras.dem==="axis")}const Jf=n.len$1([1,1,1]),Wt=n.create$1(),ms=n.create$1(),Af=n.create$2();function em(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 ps(s){return s.symbol==="gltfModel"&&s.sink==="instances"}function tm(s,e,t,i,o){var d;const r=s.modelMatrices.get(0);if(!r)return;const a=[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,a,r),n.transformMat4$1(c.max,l,r),o)if(i.tMatrix3x3){const _=im(o,i.tMatrix3x3,e);n.add$1(c.min,c.min,_.min),n.add$1(c.max,c.max,_.max)}else{let _=Math.max(n.len$1(o.max),n.len$1(o.min));if(e){const u=Wt,h=ms;n.decomposeMat4(e,u,h);const f=n.len$1(u)/Jf;_*=f,_+=n.len$1(h)}_*=(d=i.maxDiag)!=null?d:1,n.set(Wt,-_,-_,-_),n.add$1(c.min,c.min,Wt),n.set(Wt,_,_,_),n.add$1(c.max,c.max,Wt)}return c}function im(s,e,t){const i=n.set$2(Af,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(Wt,s.min,s.max,.5),r=n.scale(ms,n.sub$1(ms,s.max,s.min),.5),a=n.transformMat4$1(Wt,o,i),l=n.fromValues(Math.abs(i[0])*r[0]+Math.abs(i[4])*r[1]+Math.abs(i[8])*r[2],Math.abs(i[1])*r[0]+Math.abs(i[5])*r[1]+Math.abs(i[9])*r[2],Math.abs(i[2])*r[0]+Math.abs(i[6])*r[1]+Math.abs(i[10])*r[2]),c=n.sub$1(n.create$1(),a,l),d=n.add$1(n.create$1(),a,l);return{min:c,max:d}}class nm{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:r}=o,{symbol:a,sink:l}=r,c=n.getSymbolLayers(e,a,l);if(!c){console.error(`Cannot happen! Symbol ${a} 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,r,i,o.state);if(!_){this.queue.delete(i.id);continue}o.state=_}}}function om(s,e,t,i,o,r,a,l,c,d,_,u){const h=n.stride(r,a),f=n.getSymbolLayers(e,r,a),{accessors:m,elementsBuffer:p,count:v,drawMode:x,bbox:g}=i,y=n.Shader.createShaderDefinitions(i.shaderDefinitions);_.linkId=t;for(const b of f){const S=b.uniformSet||"fill",T=JSON.stringify(Object.values(c))+"_"+S+"_"+o.detailLevel,z=e.getShaderProgram(b.programName,y),E=l.buffer;if(!E){console.error(`Expected existing buffer while linking instance, but ${E} found.`);continue}const P=b.vaoCreator(E,z,p,m);_.attributesAliases&&P.setAttributesAliases(_.attributesAliases);const k={id:n.uniqId(),type:n.SceneObjectType.Tile,layerSettings:b,start:0,count:v,attributes:c,shaderDefinitions:y,renderingProperties:d,meta:_,attributesHash:T,vao:P,drawMode:x,tile:o,bbox:g,bboxWorld:u,symbol:r,sink:a,canRender:!0,instanceCount:(l.rangeEnd-l.rangeStart)/h};o.push(k),s.push(k)}s.length&&e.addRerenderEvent({type:"instanceLink"})}function ll(s,e,t){sm(e,i=>{var r;const o=((r=i.meta)==null?void 0:r.linkId)===t;return o&&s.push(i),!o})}function sm(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 rm={min:[0,0,0],max:[0,0,0]},Dn=(s,e,t,i)=>{var c,d;const{assetManager:o,modelsScene:r,renderer:a}=s;if(i||(i={}),t.destroyed){const _=[];for(const u in i){const h=i[+u];Number.isNaN(h.linkId)||ll(_,t,h.linkId)}for(const u of _)r.removeSceneObject(u.id);return}const l=[];for(let _=0;_<e.generatedObjects.length;_++){const u=e.generatedObjects[_],h=n.GltfModelGenerator.sinks.instances.unpackObjectAttributes(u.attributes),{extents:f}=u;i[_]||(i[_]={modelId:NaN,linkId:NaN});const m=i[_];let p;const v=!!m.referenceBbox;m.referenceBbox?p=m.referenceBbox:(p=rm,p.min[0]=f[0]/n.maxUint16Value,p.min[1]=f[1]/n.maxUint16Value,p.min[2]=f[2]/n.maxUint16Value,p.max[0]=f[3]/n.maxUint16Value,p.max[1]=f[4]/n.maxUint16Value,p.max[2]=f[5]/n.maxUint16Value);const{styleId:x}=h,g=m.modelId,y=m.sceneId;r.updateModelId(m,h,p,t,v);const b=m.modelId;if(b===void 0||Number.isNaN(b))continue;const S=m.sceneId;if(S===void 0||Number.isNaN(S)||g===b&&y===S)continue;const T=o.getModel(b,x);if(!T||T.status!==ot.Loaded)continue;const z=(d=(c=T==null?void 0:T.scenes.find(k=>k.id===m.sceneId))==null?void 0:c.objects)!=null?d:[];if(z.length===0)continue;const E=m.linkId;if(!Number.isNaN(E)){const k=[];ll(k,t,E);for(const R of k)r.removeSceneObject(R.id)}const P=n.uniqId();m.linkId=P;for(const k of z){const R=t.modelMatrices.get(0),C=new Float32Array(16);em(C,R);const{attributesAliases:F,availableTextureCoords:se,colorTexture:Q,colorFactor:le,aoTexture:D,pbrTexture:Ke,metallic:Se,roughness:ye,meshTier:Ue,animationStack:Ze,transformStack:Rt,localMatrix:Le,demPosition:Ft,axis:Me,centroid:Dt,textureTransformMatrix:Mt}=k.attributes,ei=tm(t,Le,f,u,k.bbox);!m.referenceBbox&&ei&&(m.referenceBbox=ei),om(l,a,P,k,t,e.symbol,e.sink,u,I({colorTexture:Q,colorFactor:le,aoTexture:D,pbrTexture:Ke,metallic:Se,roughness:ye,meshTier:Ue,demPosition:Ft,axis:Me,centroid:Dt},h),{modelId:b,animationStack:Ze,transformStack:Rt,localMatrix:new Float32Array(Le!=null?Le:[]),textureTransformMatrix:new Float32Array(Mt!=null?Mt:[]),transformMatrix:C},ce(I({},u.meta),{attributesAliases:F,availableTextureCoords:se}),ei)}}return l.forEach(_=>{r.addSceneObject(_)}),i},On=new Float32Array(16),cl=1e-4;let ze,Re;function L(...s){return(t,i,o,r,a,l)=>{for(const c of s)if(!c(t,i,o,r,a,l))return!1;return!0}}const j=(s,e,t,i)=>(t.renderer.bindShaderProgram(s,{u_mat4_mvp:i.tile.renderMvpMatrix}),!0);function dl(s,e){return!!s.styleState.globeEnabled&&(e.coords[2]<n.globeConfig.globeMaxZoom&&e.ecefDataState===n.EcefDataState.DerivedFromTile||e.ecefDataState===n.EcefDataState.Present)}const vs=[0,0],_l=new Float32Array(4),ul=n.create$3(),gs=[0,0],ys=new Float64Array([0,0,0,1]),pe=(s,e,t,i)=>{const{camera:{globeRatio:o,ecefMvpMatrix:r,viewProjectionMatrix:a},styleManager:l,renderer:c}=t,d=l.getStyle(e.handyStyleId);if(!(d==null?void 0:d.environment))return!1;const u=i.tile;if(!u.renderModelMatrix)return!1;const f=dl(e,u);let m=o;return f&&o<cl?m=cl:!f&&o>0&&(m=0),m===0||m===1?(c.bindShaderProgram(s,{u_mat4_flat_mvp:i.tile.renderMvpMatrix,u_mat4_ecef_mvp:r,u_float_crossfade:m}),!0):(n.Mercator.toGeo(e.center,gs),vs[0]=n.degToRad(gs[0]),vs[1]=Math.log(Math.tan(Math.PI/4+n.degToRad(gs[1])/2)),ys[0]=e.center[0],ys[1]=e.center[1],n.transformMat4(ul,ys,a),_l.set(ul),c.bindShaderProgram(s,{u_mat4_flat_mvp:i.tile.renderMvpMatrix,u_mat4_ecef_mvp:r,u_mat4_vp:a,u_vec2_camera_merc:vs,u_vec4_vp_at_center:_l,u_float_crossfade:m}),!0)},Nn=n.maxTilePoint/2,am=[Nn,Nn,0],lm=[Nn+1,Nn,0],zt=[0,0,0],kt=[0,0,0],hl=new WeakMap,cm=16,Xt=(s,e,{renderer:t},i)=>{if(!dl(e,i.tile))t.bindShaderProgram(s,{u_float_ecef_scale:0});else{let o=hl.get(i.tile);if(o===void 0){const r=n.createTileInfo(i.tile.coords);n.tilePointToMapPoint(zt,am,r),n.tilePointToMapPoint(kt,lm,r),n.Mercator.toGeo(zt,zt);const a=zt[1];n.Mercator.toGeo(kt,kt),n.Ecef.fromGeo(zt,zt),n.Ecef.fromGeo(kt,kt);const l=kt[0]-zt[0],c=kt[1]-zt[1],d=kt[2]-zt[2],_=Math.sqrt(l*l+c*c+d*d),u=Math.min(n.Mercator.scaleFactor(a),cm)/(Math.PI/2);o=_/n.worldSize*u,hl.set(i.tile,o)}t.bindShaderProgram(s,{u_float_ecef_scale:o})}return!0},kn=(s,e,t,i)=>(t.renderer.bindShaderProgram(s,{u_mat4_flat_map_mvp:i.tile.renderFlatMapTexMatrix}),!0),q=(s,e,t,i)=>i.tile.renderModelMatrix?(n.copy(On,i.tile.renderModelMatrix),t.renderer.bindShaderProgram(s,{u_mat4_model:On}),!0):!1,Un=(s,e,t,i)=>(t.renderer.bindShaderProgram(s,{u_int_abs_z:i.attributes.absZ?1:0}),!0),N=(s,e,{renderer:t},i,o,r)=>{if(r.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 ui(s,e){return n.makeBinderContext(s.styleZoom,s.styleState,e.attributes.tileData)}const xs=(s,e,t,i,o)=>{var m;ze=void 0;const r=ui(e,i),a=n.resolveString(o.style.textureImage,r);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=(m=c.rasterSets.byKey[n.getStaticTextureRasterSetKey(a)])==null?void 0:m.rasters;if(!d)return!0;const _=n.resolveExpression(o.style.textureSize,r);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||(ze=d[f]),!0},fl=(s,e,t,i,o)=>{var m;Re=void 0;const r=ui(e,i),a=n.resolveString(o.style.normalMapTextureImage,r),l=o.style.normalMapTextureLengthUnits===n.LengthUnits.Meters,c=t.styleManager.getStyle(i.attributes.styleId);if(!c)return!0;const d=(m=c.rasterSets.byKey[n.getStaticTextureRasterSetKey(a)])==null?void 0:m.rasters;if(!d)return!0;const _=n.resolveExpression(o.style.normalMapTextureSize,r);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||(Re=d[f]),!0},bs=(s,e,{assetManager:t,renderer:i},o,r)=>{if(!ze)return i.bindShaderProgram(s,{u_int_is_textured:0}),!0;let a,l,c,d;const{tile:_}=o,{zoom:u}=e,h=t.textures[ze.atlasIndex];let f=!1;if(!h)return i.bindShaderProgram(s,{u_int_is_textured:0}),!0;r.type==="polygon"&&(f=r.style.lengthUnits===n.LengthUnits.Meters),i.enableTexture(h,0);let m;if(f){const p=ui(e,o),v=n.resolveExpression(r.style.textureSize,p),[x,g]=Array.isArray(v)?v:[v,v],y=n.Mercator.toGeo(n.tileCoordsToMapPoint(_.coords)),b=n.Mercator.scaleFactor(y[1]),S=n.tileZoomToSize(_.zoomLevel)/n.MAP_POINTS_IN_METER/b,T=S/x,z=S/g,E=Math.trunc(n.atlasSize[0]/T),P=Math.trunc(n.atlasSize[1]/z);a=_.coords[0]*n.atlasSize[0]%E/E,l=_.coords[1]*n.atlasSize[1]%P/P,c=n.atlasSize[0]/E,d=n.atlasSize[1]/P}else m=n.tileSizeZpt*Math.pow(2,Math.round(u)-_.zoomLevel)*window.devicePixelRatio,a=_.coords[0]*m%ze.w/ze.w,l=_.coords[1]*m%ze.h/ze.h,c=m/ze.w,d=m/ze.h;return i.bindShaderProgram(s,{u_int_is_textured:1,u_float_texture_params:[a,l,c,d],u_float_sprite_texture_coords:[(ze.x+.5)/n.atlasSize[0],(ze.y+ze.h-1)/n.atlasSize[1],(ze.x+ze.w-1)/n.atlasSize[0],(ze.y+.5)/n.atlasSize[1]]}),!0},ml=(s,e,t,i,o)=>{var g;const{assetManager:r,styleManager:a,renderer:l}=t;if(!Re)return l.bindShaderProgram(s,{u_int_is_normal_map_textured:0}),!0;let c,d,_,u;const{tile:h}=i,{zoom:f}=e,m=r.textures[Re.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 y=ui(e,i),b=n.resolveExpression(o.style.normalMapTextureSize,y),[S,T]=Array.isArray(b)?b:[b,b],z=n.Mercator.toGeo(n.tileCoordsToMapPoint(h.coords)),E=n.Mercator.scaleFactor(z[1]),P=n.tileZoomToSize(h.zoomLevel)/n.MAP_POINTS_IN_METER/E,k=P/S,R=P/T,C=Math.trunc(n.atlasSize[0]/k),F=Math.trunc(n.atlasSize[1]/R);c=h.coords[0]*n.atlasSize[0]%C/C,d=h.coords[1]*n.atlasSize[1]%F/F,_=n.atlasSize[0]/C,u=n.atlasSize[1]/F}else v=n.tileSizeZpt*Math.pow(2,Math.round(f)-h.zoomLevel)*window.devicePixelRatio,c=h.coords[0]*v%Re.w/Re.w,d=h.coords[1]*v%Re.h/Re.h,_=v/Re.w,u=v/Re.h;const x=(g=a.getStyle(i.attributes.styleId))==null?void 0:g.rasterSets.byIndex[Re.rasterSetIndex];return!x||!x.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:[(Re.x+.5)/n.atlasSize[0],(Re.y+Re.h-1)/n.atlasSize[1],(Re.x+Re.w-1)/n.atlasSize[0],(Re.y+.5)/n.atlasSize[1]]}),!0)},dm=(s,e,{renderer:t})=>(t.bindShaderProgram(s,{u_int_is_textured:0,u_int_is_normal_map_textured:0}),!0),pl=(s,e,{renderer:t},i,o)=>{if(!Re)return!0;const r=ui(e,i),a=n.resolveExpression(o.style.metallic,r),l=n.resolveExpression(o.style.roughness,r);return t.bindShaderProgram(s,{u_float_metallic:a,u_float_roughness:l}),!0},ws=[0,0,0,0],_m=(s,e,{renderer:t},i)=>(n.tilePointToOffsetSize(ws,n.createTileInfo(i.tile.coords)),ws[3]=Number(e.globeMode),t.bindShaderProgram(s,{u_vec4_tilecoords:ws}),!0),um=(s,e,t,i)=>{if(!ze)return t.renderer.bindShaderProgram(s,{u_int_is_textured:0}),!0;const{tile:o}=i,{zoom:r}=e,a=t.assetManager.textures[ze.atlasIndex];if(!a)return t.renderer.bindShaderProgram(s,{u_int_is_textured:0}),!0;t.renderer.enableTexture(a,0);const l=n.tileSizeZpt*Math.pow(2,Math.round(r)-o.zoomLevel)*window.devicePixelRatio;return t.renderer.bindShaderProgram(s,{u_int_is_textured:1,u_float_texture_vertical_scale:ze.h*o.size/l}),!0},hm=(s,e,{styleManager:t,assetManager:i,renderer:o},r,a)=>{var y;const l=ui(e,r),c=n.resolveString(a.style.iconImage,l),d=t.getStyle(r.attributes.styleId);if(!d)return!1;const _=(y=d.rasterSets.byKey[n.getStaticTextureRasterSetKey(c)])==null?void 0:y.rasters;if(!_)return!1;const u=n.resolveNumber(a.style.width,l),h=n.resolveNumber(a.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 x=_[v],g=i.textures[x.atlasIndex];return g?(o.enableTexture(g,0),o.bindShaderProgram(s,{u_float_sprite_texture_coords:[(x.x+.5)/n.atlasSize[0],(x.y+x.h-1)/n.atlasSize[1],(x.x+x.w-1)/n.atlasSize[0],(x.y+.5)/n.atlasSize[1]]}),!0):!1},vl=new Float32Array(16);n.fromScaling(vl,[1/n.worldSize,1/n.worldSize,1/n.worldSize]);const Hn=(s,e,{animationManager:t,assetManager:i,renderer:o},r,a)=>{const{styleId:l}=r.attributes,{localMatrix:c,transformMatrix:d,modelId:_,textureTransformMatrix:u}=r.renderingProperties;if(_===void 0)return!1;const h=i.getModel(_,l);return h===void 0?!1:(t.animateGltfObject(r,a,h),o.bindShaderProgram(s,{u_mat4_localmatrix:c,u_mat3_transform_tex_matrix:u,u_mat4_instance:e.globeMode?vl:d}),!0)},fm=(s,e,{renderer:t},i)=>i.tile.renderModelMatrix?(n.copy(On,i.tile.renderModelMatrix),t.bindShaderProgram(s,{u_mat4_model:On}),!0):!1,gl=(s,e,{animationManager:t,renderer:i},o,r)=>{if(!Re)return!0;let a=[0,0,0,0],l=0;const[c,d]=t.animatePolygonNormalMapTexture(o,r);return a=d,l=c?1:0,i.bindShaderProgram(s,{u_vec4_normal_map_animated_offsets:a,u_int_normal_map_is_animated:l}),!0},mm=(s,e,t)=>!t.shadowManager.texture;function pm(){return{line:{solid:[{programName:"road",vaoCreator:I_,stateBinder:_n,needsVisibilityBuffer:!1,commonBinder:X($,W,A),programBinder:wh,objectBinder:M(va,me,Ge,ee),layerBinder:re,zoomBinder:wt,tileBinder:L(q,pe,Xt),cullMethod:B(U,fe,ct,it,Y)},{identify:!0,programName:"roadIdentify",vaoCreator:B_,stateBinder:Lo,needsVisibilityBuffer:!1,objectBinder:M(Ge,ee),zoomBinder:wt,tileBinder:L(pe,Xt),cullMethod:B(U,fe,ct,it,Y)}],patterned:[{programName:"patternedLine",vaoCreator:z_,stateBinder:Qe,needsVisibilityBuffer:!1,commonBinder:X($,W,A),programBinder:ma,layerBinder:re,objectBinder:M(ya,Ge,Be,di),zoomBinder:Sa,tileBinder:L(q,j),cullMethod:B(U,fe,ct,ka)}],solid3d:[{programName:"line3D",vaoCreator:C_,stateBinder:Co,needsVisibilityBuffer:!1,commonBinder:X($,W,A),programBinder:mh,objectBinder:M(me,Ge,Ae,O),layerBinder:re,zoomBinder:wt,tileBinder:L(q,j,N),cullMethod:B(U,ct,it),is3dMapAware:!0},{identify:!0,programName:"line3DIdentify",vaoCreator:L_,stateBinder:Te,needsVisibilityBuffer:!1,programBinder:oe,objectBinder:M(Ge,Ae,O),zoomBinder:wt,tileBinder:L(j,N),cullMethod:B(U,ct,it),is3dMapAware:!0}],patterned3d:[{programName:"patternedLine3D",vaoCreator:R_,stateBinder:Co,needsVisibilityBuffer:!1,commonBinder:X($,W,A),programBinder:Sh,layerBinder:re,objectBinder:M(ya,Ge,Be,di,O),zoomBinder:Sa,tileBinder:L(q,j,N),cullMethod:B(U,ct,ka),is3dMapAware:!0}]},polygon:{fill:[{programName:"vtxColor",vaoCreator:w_,stateBinder:_n,needsVisibilityBuffer:!0,commonBinder:X($,W,A),programBinder:_a,layerBinder:Pe(re,pt,xr),objectBinder:M(me,pa,Be,Wo,ee,Nt),tileBinder:L(xs,bs,fl,ml,pe,q,gl,pl,_m),cullMethod:B(U,Y,fe,it)},{identify:!0,programName:"vtxColorIdentify",vaoCreator:E_,stateBinder:Lo,needsVisibilityBuffer:!0,programBinder:gr,objectBinder:M(ee,Uh),tileBinder:pe,cullMethod:B(U,Y,fe)}],fillWithMixFactor:[{programName:"vtxColor",vaoCreator:S_,stateBinder:du,needsVisibilityBuffer:!0,commonBinder:X($,W,A),programBinder:_a,layerBinder:Pe(re,pt,xr),objectBinder:M(me,pa,Be,Wo,ee),tileBinder:L(xs,bs,fl,ml,pe,q,gl,pl),cullMethod:B(U,Y,fe,it)}],stroke:[{programName:"simpleLine2d",vaoCreator:q_,stateBinder:_n,needsVisibilityBuffer:!0,commonBinder:X($,W,A),programBinder:ph,layerBinder:Pe(gr,sn,re),objectBinder:M(me,Ge,ee,Nt),tileBinder:L(q,pe),cullMethod:B(wf,U,Y,fe,Bi,zi,Xa),subRenderIndex:1}],shadow:[{programName:"vtxColor",vaoCreator:T_,stateBinder:Qe,needsVisibilityBuffer:!0,commonBinder:X($,W),programBinder:at,layerBinder:pt,objectBinder:M(me,Be,ee),tileBinder:L(mm,dm,pe,q),cullMethod:B(U,Y,fe,Cf)}]},metricPoint:{fill:[{programName:"metricPoint",vaoCreator:M_,stateBinder:Qe,needsVisibilityBuffer:!1,commonBinder:X($,A,W),programBinder:Ve,layerBinder:Pe(re,pt),objectBinder:M(me,ee),tileBinder:L(hm,j,q),cullMethod:B(U,Y,it)}]},mesh:{fill:[{programName:"mesh",vaoCreator:Cr,stateBinder:Vr,needsVisibilityBuffer:!0,commonBinder:X($,W,A),programBinder:lt,layerBinder:Pe(re,vt),objectBinder:M(me,Lt,Ci,Be,Xe,gt,O,Ae,et,Wo),tileBinder:L(xs,bs,um,q,j,N),cullMethod:B(U,Za),subRenderIndex:1,is3dMapAware:!0},{identify:!0,programName:"mesh",vaoCreator:Cr,stateBinder:Te,needsVisibilityBuffer:!0,commonBinder:X($,W,A),programBinder:lt,objectBinder:M(Xe,gt,O,Ae,et),tileBinder:L(j,N),cullMethod:B(U,Za),subRenderIndex:1,is3dMapAware:!0},{depthTest:!0,programName:"mesh",vaoCreator:D_,stateBinder:Te,needsVisibilityBuffer:!0,commonBinder:X($,W,A),programBinder:lt,objectBinder:M(Xe,gt,O,Ae,et),tileBinder:L(j,N),cullMethod:U,subRenderIndex:1,is3dMapAware:!0},{programName:"meshShadow",shadow:!0,vaoCreator:Lr,stateBinder:fn,needsVisibilityBuffer:!0,programBinder:oe,objectBinder:M(Xe,gt,O,Ae),tileBinder:L(j,N),cullMethod:U,is3dMapAware:!0}],inverse:[{programName:"inverse",vaoCreator:ln,stateBinder:un,needsVisibilityBuffer:!0,commonBinder:$,programBinder:lt,objectBinder:M(Xe,ee,O,et),tileBinder:L(j,N),cullMethod:B(U,Y),subRenderIndex:-1,is3dMapAware:!0},{depthTest:!0,programName:"inverse",vaoCreator:ln,stateBinder:Te,needsVisibilityBuffer:!0,commonBinder:$,programBinder:lt,objectBinder:M(Xe,ee,O,et),tileBinder:L(j,N),cullMethod:B(U,If,Y),subRenderIndex:-1,is3dMapAware:!0},{identify:!0,programName:"inverse",vaoCreator:ln,stateBinder:un,needsVisibilityBuffer:!0,commonBinder:$,programBinder:lt,objectBinder:M(Xe,ee,O,et),tileBinder:L(j,N),cullMethod:B(U,Y),subRenderIndex:-1,is3dMapAware:!0},{programName:"meshShadow",shadow:!0,vaoCreator:ln,stateBinder:fn,needsVisibilityBuffer:!0,programBinder:oe,objectBinder:M(Xe,ee,O,Ae),tileBinder:L(j,N),cullMethod:B(U,Y),is3dMapAware:!0}],depthClear:[{programName:"meshDepthClear",vaoCreator:O_,stateBinder:fu,needsVisibilityBuffer:!0,commonBinder:X($,W,A),programBinder:lt,objectBinder:M(Xe,gt,O,et,Ae),tileBinder:L(j,N),cullMethod:U,subRenderIndex:-2,is3dMapAware:!0,forceRenderUnderCacheInDemMode:!0}],stroke:[{programName:"simpleLine3d",vaoCreator:N_,stateBinder:ni,needsVisibilityBuffer:!0,commonBinder:X(ue,$,W,A),programBinder:gn,layerBinder:Pe(sn,re),objectBinder:M(me,Ge,Xe,gt,O,Ae),tileBinder:L(q,j,N),cullMethod:B(U,Bi,mf,Lf,Xa),subRenderIndex:2,is3dMapAware:!0}]},polygonExtrusion:{sideFill:[{programName:"diffuse",vaoCreator:Pr,stateBinder:un,needsVisibilityBuffer:!0,commonBinder:X($,W,A),programBinder:ai,tileBinder:L(q,j,N),layerBinder:Pe(re,vt),objectBinder:M(me,Lt,Je,Be,O,ee,Pi,Pt,Nt),cullMethod:B(Ha,U,Y,zn,fe),is3dMapAware:!0},{programName:"gradientDiffuse",vaoCreator:Pr,stateBinder:Wr,needsVisibilityBuffer:!0,commonBinder:X($,W,A),programBinder:ai,layerBinder:Pe(re,vt),objectBinder:M(me,Ci,Lt,Je,Be,O,ee,Ia,Pi,Pt,Nt),tileBinder:L(q,j,N),cullMethod:B(U,Y,fe,zn,rs),is3dMapAware:!0},{identify:!0,programName:"buildingIdentify",vaoCreator:zr(n.PolygonExtrusionGenerator.sinks.sideFill.stride),stateBinder:Te,needsVisibilityBuffer:!0,commonBinder:ue,programBinder:pn,objectBinder:M(Pt,Je,O,ee),tileBinder:L(j,N),cullMethod:B(U,Y,fe,zn,rs),is3dMapAware:!0},{depthTest:!0,programName:"buildingIdentify",vaoCreator:Rr(n.PolygonExtrusionGenerator.sinks.sideFill.stride),stateBinder:Te,needsVisibilityBuffer:!0,commonBinder:ue,programBinder:pn,objectBinder:M(Pt,Je,O,ee),tileBinder:L(j,N),cullMethod:B(U,Pn,Y,fe),is3dMapAware:!0},{programName:"buildingShadow",shadow:!0,vaoCreator:Fr(n.PolygonExtrusionGenerator.sinks.sideFill.stride),stateBinder:hn,needsVisibilityBuffer:!0,programBinder:oe,objectBinder:M(Je,O,ee),tileBinder:L(j,N),cullMethod:B(U,Pn,Y,fe),is3dMapAware:!0}],sideTexture:[{programName:"wallTexture",vaoCreator:k_,stateBinder:wu,needsVisibilityBuffer:!0,commonBinder:X($,W,A),programBinder:ai,layerBinder:Pe(re,vt),objectBinder:M(Je,O,ee,Hh,Lt),tileBinder:L(q,j,N),cullMethod:B(U,Y,fe,Ff),is3dMapAware:!0}],topFill:[{programName:"diffuse",vaoCreator:Br,stateBinder:un,needsVisibilityBuffer:!0,commonBinder:X($,W,A),programBinder:ai,layerBinder:re,objectBinder:M(me,Lt,Je,Be,O,ee,Pi,Pt),tileBinder:L(q,j,N),cullMethod:B(Ha,U,Y,fe,as),is3dMapAware:!0},{programName:"diffuse",vaoCreator:Br,stateBinder:Wr,needsVisibilityBuffer:!0,commonBinder:X($,W,A),programBinder:ai,layerBinder:Pe(re,vt),objectBinder:M(me,Lt,Je,Be,O,ee,Pi,Pt,Nt),tileBinder:L(q,j,N),cullMethod:B(U,Y,fe,as),is3dMapAware:!0},{identify:!0,programName:"buildingIdentify",vaoCreator:zr(n.PolygonExtrusionGenerator.sinks.topFill.stride),stateBinder:Te,needsVisibilityBuffer:!0,commonBinder:ue,programBinder:pn,objectBinder:M(Pt,Je,O,ee),tileBinder:L(j,N),cullMethod:B(U,Y,fe,as),is3dMapAware:!0},{depthTest:!0,programName:"buildingIdentify",vaoCreator:Rr(n.PolygonExtrusionGenerator.sinks.topFill.stride),stateBinder:Te,needsVisibilityBuffer:!0,commonBinder:ue,programBinder:pn,objectBinder:M(Pt,Je,O,ee),tileBinder:L(j,N),cullMethod:B(U,Pn,Y,fe),is3dMapAware:!0},{programName:"buildingShadow",shadow:!0,vaoCreator:Fr(n.PolygonExtrusionGenerator.sinks.topFill.stride),stateBinder:hn,needsVisibilityBuffer:!0,programBinder:oe,objectBinder:M(Je,O,ee),tileBinder:L(j,N),cullMethod:B(U,Pn,Y,fe),is3dMapAware:!0}],sideStroke:[{programName:"line",vaoCreator:Dr,stateBinder:ni,needsVisibilityBuffer:!0,commonBinder:X($,A,W,ue),programBinder:ua,layerBinder:re,objectBinder:M(me,Ci,Lt,Je,Be,O,ee,Nt),tileBinder:L(q,pe,N),cullMethod:B(U,Y,fe,Ka,$a),is3dMapAware:!0}],topStroke:[{programName:"simpleLine3d",vaoCreator:wo,stateBinder:ni,needsVisibilityBuffer:!0,commonBinder:X(ue,$,W,A),programBinder:gn,layerBinder:Pe(re,v_),objectBinder:M(me,Lt,Ge,Je,O,ee,Qo,Nt),tileBinder:L(q,j,N),cullMethod:B(U,Y,fe,Bi,zi,Bf),is3dMapAware:!0}]},labelLine:{raster:[{programName:"labelLine",vaoCreator:an,stateBinder:Bo,needsVisibilityBuffer:!1,commonBinder:X($,W),programBinder:vn,objectBinder:M(Ot,ci,$t,En,Cn),tileBinder:L(j,q),zoomBinder:wt,cullMethod:B(Y,Bt,tt,_i,Bn,ss),uniformSet:"fontHalo"},{programName:"labelLine",vaoCreator:an,stateBinder:zo,needsVisibilityBuffer:!1,commonBinder:X($,W),programBinder:vn,objectBinder:M(Ot,ci,$t,En,Cn),tileBinder:L(j,q),zoomBinder:wt,cullMethod:B(Y,Bt,ss,tt,_i,Bn),uniformSet:"fontHalo",isOverlappedObject:!0},{programName:"labelLine",vaoCreator:an,stateBinder:Bo,needsVisibilityBuffer:!1,commonBinder:X($,W),programBinder:vn,objectBinder:M(Ot,ci,$t,En,Cn),zoomBinder:wt,tileBinder:L(j,q),cullMethod:B(Y,Bt,tt,_i,Bn),uniformSet:"fontFill",subRenderIndex:1},{programName:"labelLine",vaoCreator:an,stateBinder:zo,needsVisibilityBuffer:!1,commonBinder:X($,W),programBinder:vn,objectBinder:M(Ot,ci,$t,En,Cn),zoomBinder:wt,tileBinder:L(j,q),cullMethod:B(Y,Bt,tt,_i,Bn),uniformSet:"fontFill",subRenderIndex:1,isOverlappedObject:!0}]},dashedLine:{stroke:[{programName:"stripedLine",vaoCreator:Mr,stateBinder:_n,needsVisibilityBuffer:!1,commonBinder:X(A,$,W,ue),programBinder:fa,layerBinder:re,objectBinder:M(xn,yn,Be,di,ee),zoomBinder:Mn,tileBinder:L(q,pe,Xt),cullMethod:B(U,ct,fe,Y)},{identify:!0,programName:"stripedLineIdentify",vaoCreator:Mr,stateBinder:Lo,needsVisibilityBuffer:!1,commonBinder:ue,programBinder:ha,objectBinder:M(xn,Be,yn,di,ee),zoomBinder:Mn,tileBinder:L(pe,Xt),cullMethod:B(U,ct,fe,Y)}],stroke3d:[{programName:"stripedLine3D",vaoCreator:Er,stateBinder:Co,needsVisibilityBuffer:!1,commonBinder:X(A,$,W),programBinder:yh,layerBinder:re,objectBinder:M(xn,yn,Be,di,O),zoomBinder:Mn,tileBinder:L(q,pe,Xt,N),cullMethod:B(U,ct),is3dMapAware:!0},{identify:!0,programName:"stripedLine3DIdentify",vaoCreator:Er,stateBinder:Te,needsVisibilityBuffer:!1,programBinder:xh,objectBinder:M(xn,Be,yn,di,O),zoomBinder:Mn,tileBinder:L(pe,Xt,N),cullMethod:B(U,ct),is3dMapAware:!0}]},oneWayLine:{raster:[{programName:"oneWayLine",vaoCreator:Or,stateBinder:Bo,needsVisibilityBuffer:!1,commonBinder:X(bi,xi,ue),programBinder:la,objectBinder:M(Ot,me,bn,xa),tileBinder:j,cullMethod:B(Bt,tt,Wa)},{programName:"oneWayLine",vaoCreator:Or,stateBinder:zo,commonBinder:X(bi,xi,ue),programBinder:la,needsVisibilityBuffer:!1,objectBinder:M(Ot,me,bn,xa),tileBinder:j,cullMethod:B(Bt,tt,Wa),isOverlappedObject:!0}]},point:{raster:[{programName:"pointSprite",vaoCreator:G_,stateBinder:Po,needsVisibilityBuffer:!1,commonBinder:Si($,W,fr,nn,ue),programBinder:uh,layerBinder:pt,objectBinder:M(Ih,Ko,Xo,Li,O,ee),cullMethod:B(tt,Y,os,ts,Bt),tileBinder:L(pe,q,N),is3dMapAware:!0,forcePrerenderUnderCacheInDemMode:!0},{identify:!0,programName:"pointSpriteIdentify",vaoCreator:j_,stateBinder:Zt,needsVisibilityBuffer:!1,commonBinder:ue,programBinder:ca,objectBinder:M(Ko,Xo,Li,O,ee),tileBinder:L(pe,N),cullMethod:B(tt,Y,os,ts,Ua),is3dMapAware:!0},{labelTest:!0,programName:"pointSpriteIdentify",vaoCreator:V_,stateBinder:Zt,needsVisibilityBuffer:!1,commonBinder:ue,programBinder:ca,objectBinder:M(Ko,Xo,Li,O,ee),tileBinder:L(pe,N),cullMethod:B(tt,Y,os,ts,Ua),is3dMapAware:!0}],text:[{programName:"labelPoint",vaoCreator:Ir,stateBinder:Po,needsVisibilityBuffer:!1,commonBinder:Si($,W,nn,ue),programBinder:da,objectBinder:M(Ot,ci,$t,wa,In,Li,O,ee),tileBinder:L(pe,q,N),cullMethod:B(tt,Y,Bt,_i,Va,ss),uniformSet:"fontHalo",subRenderIndex:1,is3dMapAware:!0,forcePrerenderUnderCacheInDemMode:!0},{programName:"labelPoint",vaoCreator:Ir,stateBinder:Po,needsVisibilityBuffer:!1,commonBinder:X($,W,nn,ue),programBinder:da,objectBinder:M(Ot,ci,$t,wa,In,Li,O,ee),tileBinder:L(pe,q,N),cullMethod:B(tt,Y,Bt,_i,Va),uniformSet:"fontFill",subRenderIndex:2,is3dMapAware:!0,forcePrerenderUnderCacheInDemMode:!0},{identify:!0,programName:"labelPointIdentify",vaoCreator:F_,stateBinder:Zt,needsVisibilityBuffer:!1,commonBinder:ue,programBinder:ve(oe),objectBinder:M($t,In,O,ee),tileBinder:L(pe,N),cullMethod:B(tt,Y,xf),subRenderIndex:1,is3dMapAware:!0}],labelingTexture:[{depthTest:!0,programName:"pointDepthTest",vaoCreator:Z_,stateBinder:hu,needsVisibilityBuffer:!1,commonBinder:ue,programBinder:oe,objectBinder:M(In,O,ee),tileBinder:L(j,N),cullMethod:B(tt,Y),is3dMapAware:!0}]},buildingModel:{fill:[{programName:"zbmModel",vaoCreator:$_,stateBinder:jr,needsVisibilityBuffer:!1,commonBinder:X($,W,A),programBinder:bh,layerBinder:Pe(re,pt,vt),objectBinder:M(me,Yo,Bh,O),tileBinder:L(q,j,N),cullMethod:B(ns,U,ja,it,ls),subRenderIndex:2,is3dMapAware:!0},{programName:"zbmModelIdentify",vaoCreator:W_,stateBinder:Te,needsVisibilityBuffer:!1,commonBinder:ue,objectBinder:M(O),tileBinder:L(j,N),cullMethod:B(ns,U,ja,it,ls),subRenderIndex:2,identify:!0,is3dMapAware:!0},{programName:"zbmModelIdentify",vaoCreator:X_,stateBinder:Te,needsVisibilityBuffer:!1,commonBinder:ue,objectBinder:M(O),tileBinder:L(j,N),cullMethod:U,depthTest:!0,is3dMapAware:!0},{programName:"zbmShadow",vaoCreator:K_,stateBinder:hn,needsVisibilityBuffer:!1,programBinder:oe,objectBinder:M(Yo,O),tileBinder:L(j,N),cullMethod:U,shadow:!0,is3dMapAware:!0}],stroke:[{programName:"simpleLine3d",vaoCreator:wo,stateBinder:ni,needsVisibilityBuffer:!0,commonBinder:X(ue,$,W,A),programBinder:gn,layerBinder:Pe(re,sn),objectBinder:M(me,Ge,Yo,gt,O,Qo,Ln),tileBinder:L(j,q,N),cullMethod:B(U,ns,Bi,zi,ls),subRenderIndex:5,is3dMapAware:!0}]},shiftedLine:{solid:[{programName:"road",commonBinder:X($,W,A),programBinder:ve(at,Ve),vaoCreator:P_,stateBinder:Qe,needsVisibilityBuffer:!1,layerBinder:re,objectBinder:M(me,Ge,va),tileBinder:L(q,pe,Xt),zoomBinder:wt,cullMethod:B(U,ct,it)}]},circle:{fill:[{programName:"circleMarker",vaoCreator:So,stateBinder:Qe,needsVisibilityBuffer:!1,commonBinder:X($,A,W,ue),programBinder:$o,layerBinder:re,objectBinder:M(me,Ge,O),cullMethod:B(U,ct,it),tileBinder:L(pe,q,N),subRenderIndex:2,is3dMapAware:!0},{programName:"circleMarker",vaoCreator:So,stateBinder:Qe,needsVisibilityBuffer:!1,commonBinder:X($,A,W,ue),programBinder:$o,layerBinder:re,objectBinder:M(me,Ge,O),cullMethod:B(U,Sf,zi),tileBinder:L(pe,q,N),subRenderIndex:1,is3dMapAware:!0},{programName:"circleMarker",vaoCreator:So,stateBinder:Qe,needsVisibilityBuffer:!1,commonBinder:X($,A,W,ue),programBinder:$o,layerBinder:re,objectBinder:M(me,Ge,O),cullMethod:B(U,Tf,Pf),tileBinder:L(pe,q,N),is3dMapAware:!0},{identify:!0,programName:"circleMarkerIdentify",vaoCreator:Y_,stateBinder:Zt,programBinder:oe,needsVisibilityBuffer:!1,commonBinder:ue,objectBinder:M(Ge,O),cullMethod:B(U,Mf),tileBinder:L(pe,N),is3dMapAware:!0}]},arrow:{stroke:[{programName:"entrance",vaoCreator:Nr,stateBinder:Qe,needsVisibilityBuffer:!1,commonBinder:X(bi,xi,$,W,ue),programBinder:vh,objectBinder:M(me,bn,Eh,ba,Be),tileBinder:L(j,q),cullMethod:B(U,it)},{identify:!0,programName:"entranceIdentify",vaoCreator:Nr,stateBinder:Zt,needsVisibilityBuffer:!1,commonBinder:X(bi,xi,ue),programBinder:hh,objectBinder:M(bn,ba,Be),tileBinder:j,cullMethod:B(U,it)}]},lineExtrusion:{fill:[{programName:"gradientDiffuse",vaoCreator:U_,stateBinder:cu,needsVisibilityBuffer:!0,commonBinder:X($,W,A),programBinder:ai,layerBinder:Pe(re,vt),objectBinder:M(Tn,me,Lt,Ci,Be,O,gt,Ia,Pi,Pt,Ln),tileBinder:L(q,j,N),cullMethod:B(U,Y,fe,zn,rs),subRenderIndex:9,is3dMapAware:!0},{programName:"buildingShadow",shadow:!0,vaoCreator:H_,stateBinder:fn,needsVisibilityBuffer:!0,programBinder:oe,objectBinder:M(Tn,O,gt),tileBinder:L(j,N),cullMethod:B(U,Y,fe),is3dMapAware:!0}],sideStroke:[{programName:"line",vaoCreator:Dr,stateBinder:ni,needsVisibilityBuffer:!0,commonBinder:X($,A,W,ue),programBinder:ua,layerBinder:re,objectBinder:M(Tn,me,Ci,Be,O,gt,Ln),tileBinder:L(q,pe,N),cullMethod:B(U,Y,fe,Ka,$a),subRenderIndex:10,is3dMapAware:!0}],topStroke:[{programName:"simpleLine3d",vaoCreator:wo,stateBinder:ni,needsVisibilityBuffer:!0,commonBinder:X(ue,$,W,A),programBinder:gn,layerBinder:Pe(re,sn),objectBinder:M(Tn,me,Ge,O,gt,Qo,Ln),tileBinder:L(q,j,N),cullMethod:B(U,Y,fe,Bi,zi),subRenderIndex:11,is3dMapAware:!0}]},gltfModel:{instances:[{programName:"gltfModel",vaoCreator:dn(!1),instanceBinder:Dn,commonBinder:X($,W,A),programBinder:gh,layerBinder:Pe(re,vt,rn),stateBinder:jr,needsVisibilityBuffer:!1,objectBinder:M(me,zh,Ao,qo,O,wn,ee,Sn,Nt),tileBinder:L(pe,Hn,fm,N,Un),cullMethod:B(cs,Ya),is3dMapAware:!0},{identify:!0,programName:"gltfModelIdentify",instanceBinder:Dn,vaoCreator:dn(!1),stateBinder:Te,needsVisibilityBuffer:!1,layerBinder:rn,commonBinder:Si($,W),programBinder:oe,objectBinder:M(O,wn,et,qo,ee,Sn),tileBinder:L(pe,Hn,N,Un),cullMethod:B(cs,Ya),is3dMapAware:!0},{depthTest:!0,programName:"gltfModelIdentify",instanceBinder:Dn,vaoCreator:dn(!0),stateBinder:Te,needsVisibilityBuffer:!1,commonBinder:Si($,W),programBinder:oe,layerBinder:rn,objectBinder:M(O,wn,qo,ee,Sn),tileBinder:L(pe,Hn,N,Un),cullMethod:cs,is3dMapAware:!0},{shadow:!0,programName:"gltfModelShadow",instanceBinder:Dn,vaoCreator:dn(!1),stateBinder:hn,needsVisibilityBuffer:!1,programBinder:oe,layerBinder:rn,objectBinder:M(O,wn,Sn),tileBinder:L(pe,Hn,N,Un),cullMethod:Rf,is3dMapAware:!0}]},raster:{fill:[{programName:"rectWithTexture",vaoCreator:Q_,stateBinder:Qe,needsVisibilityBuffer:!1,commonBinder:Si($,W),layerBinder:pt,objectBinder:M(ga,Ch),tileBinder:L(j,q),cullMethod:B(za,U)}]},heatmap:{framebuffer:[{programName:"heatmap",vaoCreator:J_,stateBinder:Zr,needsVisibilityBuffer:!1,commonBinder:vr,objectBinder:M(Rh,Fh),zoomBinder:wt,tileBinder:L(j,q),cullMethod:B(U,Ef)}],fill:[{programName:"heatmapTexture",vaoCreator:A_,stateBinder:Qe,needsVisibilityBuffer:!1,layerBinder:pt,objectBinder:M(ga,Ph,Lh),tileBinder:q,cullMethod:B(U,za,pf),subRenderIndex:1}]},dem:{mesh:[{programName:"demMesh",vaoCreator:cn,commonBinder:X($,W,A),programBinder:lt,layerBinder:re,stateBinder:Te,needsVisibilityBuffer:!1,objectBinder:M(O,Ta,Ea),tileBinder:L(j,q,kn,N),cullMethod:B(Ra,Fa),is3dMapAware:!0},{programName:"demGround",demGround:!0,vaoCreator:cn,programBinder:oe,tileBinder:L(j,q,N),stateBinder:Te,needsVisibilityBuffer:!1,objectBinder:M(O)},{identify:!0,programName:"demMesh",vaoCreator:cn,programBinder:ve(oe,ra),stateBinder:Te,needsVisibilityBuffer:!1,objectBinder:M(Ma,O),tileBinder:L(j,kn,N),cullMethod:Da,is3dMapAware:!0}],mesh2:[{dem:!0,programName:"demElevation",vaoCreator:Ti,stateBinder:uu,needsVisibilityBuffer:!1,tileBinder:j,objectBinder:M()},{programName:"demGround2",demGround:!0,vaoCreator:Ti,programBinder:oe,tileBinder:L(j,q,N),stateBinder:Te,needsVisibilityBuffer:!1,objectBinder:M(O)},{programName:"demMesh2",vaoCreator:Ti,commonBinder:X($,W,A),programBinder:lt,layerBinder:re,stateBinder:Te,needsVisibilityBuffer:!1,objectBinder:M(et,Ta,Ea,O),tileBinder:L(j,q,kn,N),cullMethod:B(Ra,Fa)},{identify:!0,programName:"demMesh2",vaoCreator:Ti,programBinder:ve(oe,ra),stateBinder:Te,needsVisibilityBuffer:!1,objectBinder:M(et,Ma,O),tileBinder:L(j,kn,N),cullMethod:Da},{depthTest:!0,programName:"demMesh2DepthTest",vaoCreator:Ti,programBinder:ve(oe),stateBinder:Te,needsVisibilityBuffer:!1,objectBinder:M(Nh,O),tileBinder:L(j,N)}],hillshade:[{programName:"demHillshade",vaoCreator:To,stateBinder:Zt,needsVisibilityBuffer:!1,programBinder:oe,objectBinder:M(O),tileBinder:L(j,N)}],flatBottom:[{programName:"demFlatBottom",vaoCreator:eu,stateBinder:Gr,needsVisibilityBuffer:!1,objectBinder:M(Oh,O),tileBinder:L(j,N),cullMethod:vf}]},mapMesh:{fill:[{programName:"mapMesh",vaoCreator:Mo,stateBinder:Vr,needsVisibilityBuffer:!1,zoomBinder:M(Jo),commonBinder:X($,W,A),programBinder:lt,layerBinder:Pe(re,vt),objectBinder:M(Ao,Xe,O,Ae,et),tileBinder:L(q,j,N),cullMethod:B(U,is),subRenderIndex:Number.MAX_SAFE_INTEGER,is3dMapAware:!0},{identify:!0,programName:"mapMesh",vaoCreator:Mo,stateBinder:Te,needsVisibilityBuffer:!1,zoomBinder:M(Jo),commonBinder:X($,W,A),programBinder:lt,layerBinder:Pe(re,vt),objectBinder:M(Ao,Xe,O,Ae,et),tileBinder:L(j,N),cullMethod:B(U,is),subRenderIndex:Number.MAX_SAFE_INTEGER,is3dMapAware:!0},{depthTest:!0,programName:"mapMesh",vaoCreator:Mo,stateBinder:Te,needsVisibilityBuffer:!1,zoomBinder:M(Jo),commonBinder:X($,W,A),programBinder:lt,layerBinder:Pe(re,vt),objectBinder:M(Xe,O,Ae,et),tileBinder:L(j,N),cullMethod:U,subRenderIndex:Number.MAX_SAFE_INTEGER,is3dMapAware:!0},{programName:"meshShadow",shadow:!0,vaoCreator:Lr,stateBinder:fn,needsVisibilityBuffer:!1,programBinder:oe,objectBinder:M(Xe,O,Ae),tileBinder:L(j,N),cullMethod:U,is3dMapAware:!0}]}}}class vm{constructor(e){this.gl=e,this.ext1=e.getExtension("EXT_disjoint_timer_query"),this.ext2=e instanceof WebGL2RenderingContext?e.getExtension("EXT_disjoint_timer_query_webgl2"):null,this.queries=[]}addTimer(){if(this.ext2&&this.gl instanceof WebGL2RenderingContext){const e=this.gl.createQuery();return e?(this.queries.push({query:e}),this.gl.beginQuery(this.ext2.TIME_ELAPSED_EXT,e),!0):!1}if(this.ext1){const e=this.ext1.createQueryEXT();return this.queries.push({query:e}),this.ext1.beginQueryEXT(this.ext1.TIME_ELAPSED_EXT,e),!0}return!1}stopTimer(){if(this.queries.length){if(this.ext2&&this.gl instanceof WebGL2RenderingContext){this.gl.endQuery(this.ext2.TIME_ELAPSED_EXT);return}this.ext1&&this.ext1.endQueryEXT(this.ext1.TIME_ELAPSED_EXT)}}tryToGetFirstTimerValue(){const e=this.queries[0];if(e){if(this.ext2&&this.gl instanceof WebGL2RenderingContext){const t=this.gl;if(t.getParameter(this.ext2.GPU_DISJOINT_EXT)){this.flushAll();return}if(!t.getQueryParameter(e.query,t.QUERY_RESULT_AVAILABLE))return;const r=t.getQueryParameter(e.query,t.QUERY_RESULT);return t.deleteQuery(e.query),this.queries.shift(),{durationMs:Number(r)/1e6}}if(this.ext1){const t=this.ext1;if(this.gl.getParameter(t.GPU_DISJOINT_EXT)){this.flushAll();return}if(!t.getQueryObjectEXT(e.query,t.QUERY_RESULT_AVAILABLE_EXT))return;const r=t.getQueryObjectEXT(e.query,t.QUERY_RESULT_EXT);return t.deleteQueryEXT(e.query),this.queries.shift(),{durationMs:Number(r)/1e6}}}}destroy(){this.flushAll()}flushAll(){if(this.ext2&&this.gl instanceof WebGL2RenderingContext)for(const e of this.queries)this.gl.deleteQuery(e.query);else if(this.ext1)for(const e of this.queries)this.ext1.deleteQueryEXT(e.query);this.queries.length=0}}const gm=`
float affine_step(const float edge0, const float edge1, const float x)
{
    return clamp((x - edge0) / (edge1 - edge0), 0., 1.);
}
`,ym=`#define ALPHA_MODE_OPAQUE 1
#define ALPHA_MODE_BLEND 2
`,xm=`uniform vec4 u_vec4_color_effect_mix_rgba;
uniform float u_float_color_effect_mix_factor;
vec4 apply_color_effect(vec4 color) {
    return mix(color, u_vec4_color_effect_mix_rgba, clamp(u_float_color_effect_mix_factor, 0.0, 1.0));
}
`,yl=`
vec4 apply_opacity(const vec4 color, const float opacity)
{
return color * opacity;
}
`,bm=`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);
}
`,wm=`
#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
`,xl=`#ifndef UBO
uniform highp vec3 u_cam_pos;
#endif
`,Sm=`
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);
}
`,Tm=`
#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;
}
`,Mm=`#ifdef WEBGL1
#extension GL_OES_standard_derivatives: enable
#endif
`,Em=`
#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;
}`,Im=`#define FRAGMENT_NORMAL
vec3 calc_fragment_normal(vec3 vertex) {
    vec3 dx = dFdx(vertex);
    vec3 dy = dFdy(vertex);
    return normalize(cross(dx, dy));
}`,Cm=`precision highp float;
`,Lm=`#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);
}`,Pm=`
#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
`,Bm=`#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, float alpha) {
    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 * alpha;
    return albedo * (ambient + diffuse) + specular;
}
#endif
#endif
`,zm=`precision lowp float;
`,Rm=`precision mediump float;
`,bl=`#define MIX_COLOR_MODE_READ_FROM_TARGET 1
#define MIX_COLOR_MODE_VERTEX_ATTRIBUTE 2
#define VERTEX_ATTRIBUTE_NAME_DENORMALIZED_DISTANCE_TO_LINE 1
`,Fm=`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);
}`,Dm=`#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
`,Om=`#ifdef HAS_FRAG_DEPTH_EXT
#extension GL_EXT_frag_depth : require
#endif
`,Nm=`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;
}
`,km=`#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 `,wl=`#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
`,Um=`#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);
}
`,Hm=`#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;
}
`,Gm=`#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);
}
`,Vm=`#include <lowp_float>
#include <prelude>
#include <fog>
varying vec4 v_vec4_color;
void main()
{
    gl_FragColor = apply_fog(v_vec4_color);
}
`,jm=`#include <lowp_float>
#include <prelude>
varying vec4 v_vec4_identifier;
void main()
{
    gl_FragColor = v_vec4_identifier;
}
`,Zm=`#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>
#include <apply_color_effect>
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(apply_color_effect(color));
# ifndef BLEND
    
    gl_FragColor /= gl_FragColor.a;
# endif
}
`,$m=`#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 
}
`,Wm=`#include <mediump_float>
#include <prelude>
varying float v_float_height;
void main()
{
  gl_FragColor = vec4(v_float_height, 0., 0., 1.);
}
`,Xm=`#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);
}
`,Km=`#include <mediump_float>
#include <prelude>
varying vec4 v_vec4_color;
void main()
{
    gl_FragColor = v_vec4_color;
}
`,qm=`#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;
}
`,Ym=`#include <mediump_float>
#include <prelude>
varying vec4 v_vec4_coords;
void main()
{
    gl_FragColor = v_vec4_coords;
}
`,Qm=`#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);
    }
}
`,Jm=`#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_identify;
uniform float u_float_dem_shading_intensity;
varying vec4 v_vec4_texcoord;
varying vec3 v_vec3_position;
void main() {
    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);
    if (u_int_identify == 1) {
        gl_FragColor = flatMapColor;
        return;
    }
    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);
}
`,Am=`#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);
}
`,ep=`#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 
}
`,tp=`#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);
}
`,ip=`#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;
}
`,np=`#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;
}
`,op=`#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>
#include <alpha_mode_defs>
#include <apply_color_effect>
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;
    }
    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) {
        apply_screendoor();
        gl_FragColor = apply_fog(apply_color_effect(color));
        return;
    }
    bool skip_screendoor = false;
    #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)
            #if defined(ALPHA_MODE) && ALPHA_MODE == ALPHA_MODE_OPAQUE
                
                
                
                
                color.rgb = color_phong(fragment_normal, v_vec3_fragment_pos_world, color.rgb, roughness, metallic, color.a);
                if (color.a == 0.0) {
                    skip_screendoor = true;
                }
            #else
                color.rgb = color_phong(fragment_normal, v_vec3_fragment_pos_world, color.rgb, roughness, metallic, 1.0);
            #endif
        #endif
    #endif
    if (!skip_screendoor){
        apply_screendoor();
    }
    gl_FragColor = apply_fog(apply_color_effect(color));
}
`,sp=`#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>
#include <apply_color_effect>
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(apply_color_effect(color));
# ifndef BLEND
    
    gl_FragColor /= gl_FragColor.a;
# endif
}
`,rp=`#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);
}
`,ap=`#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
}
`,lp=`#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.);
    }
}
`,cp=`#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);
}
`,dp=`#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);
}
`,_p=`#include <mediump_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
#include <apply_color_effect>
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(apply_color_effect(color * light_factor(v_vec3_normal)));
}
`,up=`#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);
}`,hp=`#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);
}
}
}
`,fp=`#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);
    }
}
`,mp=`#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());
}
`,pp=`#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);
}
`,vp=`#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);
}
`,gp=`#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);
}
`,yp=`#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;
    }
}
`,xp=`#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);
}
`,bp=`#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;
}
`,wp=`#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;
}
`,Sp=`#include <lowp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <apply_color_effect>
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 = apply_color_effect(u_vec4_color) * clamp(
        1. + v_float_distance_offset - abs(v_float_distance * gl_FragCoord.w),
        0.,
        1.) * light;
    gl_FragColor = apply_fog(color);
}
`,Tp=`#include <lowp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
#include <apply_color_effect>
varying vec4 v_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 = apply_color_effect(v_vec4_color) * clamp(
        1. + v_float_distance_offset - abs(v_float_distance * gl_FragCoord.w),
        0.,
        1.) * light;
    gl_FragColor = apply_fog(color);
}
`,Mp=`#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);
}
`,Ep=`#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);
}
`,Ip=`#include <mediump_float>
#include <prelude>
varying mediump float v_intensity;
void main() {
    gl_FragColor = vec4(v_intensity);
}
`,Cp=`#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);
}
`,Lp=`#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);
}
`,Pp=`#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>
#include <apply_color_effect>
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, 1.0);
    } else {
        color = color * light_factor_surface();
    }
    gl_FragColor = apply_fog(apply_color_effect(color));
}
`,Bp=`#include <lowp_float>
#include <prelude>
uniform vec4 u_vec4_color;
void main()
{
    gl_FragColor = u_vec4_color;
}
`,zp=`#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);
}
`,Rp=`#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);
}
`,Fp={affine_step:gm,alpha_mode_defs:ym,apply_color_effect:xm,apply_opacity:yl,arrow_functions:bm,bit_mask:wm,cam_pos:xl,circle_functions:Sm,dem:Tm,enable_standard_derivatives:Mm,fog:Em,fragment_normal:Im,highp_float:Cm,light:Lm,light_pbr:Pm,light_phong:Bm,lowp_float:zm,mediump_float:Rm,mix_color_defs:bl,pack_depth:Fm,prelude:Dm,require_frag_depth:Om,screendoor_transparency:Nm,shadow:km,signed_distance_functions:wl},Dp={arrow_line:Um,arrow_line_identify:Hm,circle_marker:Gm,color:Vm,color_identify:jm,color_with_z_fade:Zm,copy:$m,dem_elevation:Wm,dem_elevation_copy:Xm,dem_flat_bottom:Km,dem_ground:qm,dem_ground2:Ym,dem_mesh:Qm,dem_mesh2:Jm,dem_normal:Am,depth_clear:ep,fxaa:tp,globe_halo:ip,globe_halo_background:np,gltf_model:op,gradient_with_z_fade:sp,heatmap:rp,heatmap_texture:ap,inverse:lp,label:cp,label_directional:dp,line:_p,main_shadow:up,map_mesh:hp,mesh:fp,metric_point:mp,one_way_line:pp,patterned_line:vp,pointsprite:gp,pointsprite_identify:yp,rect_with_texture:xp,road:bp,road_identify:wp,simple_line_2d:Sp,simple_line_3d:Tp,simple_mesh:Mp,sky:Ep,stars:Ip,striped_line:Cp,taa:Lp,textured_color:Pp,uniform_color:Bp,wall_texture:zp,zbm_model:Rp},Op=`vec4 apply_height_factor(in vec3 vertex, const float height_factor)
{
    vertex.z *= height_factor;
    return vec4(vertex, 1.0);
}
`,Np=`
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);
}
`,kp=`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);
}
`,Up=`
#ifdef SCREENDOOR
varying vec3 v_clipspace_pos;
#endif
void save_clipspace_pos () {
    #ifdef SCREENDOOR
    v_clipspace_pos = gl_Position.xyz;
    #endif
}
`,Hp=`
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;
}
`,Gp=`#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;
}
`,Vp=`uniform mat4 u_mat4_flat_mvp;
uniform mat4 u_mat4_ecef_mvp;
uniform float u_float_crossfade;
uniform mat4 u_mat4_vp;
uniform vec2 u_vec2_camera_merc;      
uniform vec4 u_vec4_vp_at_center;     
const float ECEF_CF_E = 2e-8;
const float ECEF_CF_NEAR = 0.01;
const float ECEF_WORLD = 4294967296.;
const float ECEF_PI = 3.14159265358979;
const float ECEF_TWO_PI = 6.28318530717959;
const float ECEF_MAX_LAT = 1.4844222;
#define DECODE_ECEF(v) ((v) - 0.5)
float ecef_wrap_pi(float angle) {
    return mod(angle + ECEF_PI, ECEF_TWO_PI) - ECEF_PI;
}
vec4 ecef_flat_clip_from_epos(const vec3 epos, const float elevation) {
    vec3 en = normalize(epos);
    float lng = atan(en.x, en.z);
    float lat = clamp(asin(clamp(en.y, -1.0, 1.0)), -ECEF_MAX_LAT, ECEF_MAX_LAT);
    float mercY = log(tan(ECEF_PI / 4.0 + lat / 2.0));
    float dLng = ecef_wrap_pi(lng - u_vec2_camera_merc.x);
    float relX = dLng / ECEF_TWO_PI * ECEF_WORLD;
    float relY = (mercY - u_vec2_camera_merc.y) / ECEF_TWO_PI * ECEF_WORLD;
    return u_mat4_vp * vec4(relX, relY, elevation, 0.0) + u_vec4_vp_at_center;
}
bool is_flat_mode() {
    return u_float_crossfade < ECEF_CF_E;
}
vec4 _get_clipspace_impl(const vec3 epos, const float elevation) {
    float R = ECEF_WORLD + elevation;
    if (u_float_crossfade < ECEF_CF_NEAR) {
        return ecef_flat_clip_from_epos(epos, elevation);
    } else if (u_float_crossfade > (1. - ECEF_CF_NEAR)) {
        return u_mat4_ecef_mvp * vec4(epos * R, 1.);
    }
    vec4 fclip = ecef_flat_clip_from_epos(epos, elevation);
    vec4 eclip = u_mat4_ecef_mvp * vec4(epos * R, 1.);
    return mix(fclip, eclip, u_float_crossfade);
}
vec4 get_clipspace(const vec3 pos) {
    if (is_flat_mode()) {
        return u_mat4_flat_mvp * vec4(pos, 1.);
    }
    return _get_clipspace_impl(pos, 0.0);
}
vec4 get_clipspace(const vec3 vertex, const float flat_z) {
    vec3 pos = is_flat_mode() ? vec3(vertex.xy, flat_z) : DECODE_ECEF(vertex);
    return get_clipspace(pos);
}
struct EcefTangentFrame {
    vec3 center; 
    vec3 up;
    vec3 east;
    vec3 north;
};
EcefTangentFrame ecef_tangent_frame(const vec3 ecef_u16) {
    EcefTangentFrame f;
    f.center = DECODE_ECEF(ecef_u16);
    f.up = normalize(f.center);
    vec3 raw_east = cross(vec3(0., 1., 0.), f.up);
    raw_east = dot(raw_east, raw_east) > 1e-12 ? raw_east : cross(vec3(1., 0., 0.), f.up);
    f.east = normalize(raw_east);
    f.north = cross(f.up, f.east);
    return f;
}
vec4 get_clipspace_from_ecef_u16(const vec3 ecef_u16, const vec3 local_vertex, const float elevation) {
    EcefTangentFrame f = ecef_tangent_frame(ecef_u16);
    vec3 ecef_vertex = f.east * local_vertex.x + f.north * local_vertex.y + f.up * local_vertex.z;
    ecef_vertex *= (ECEF_PI / 2.0);
    return _get_clipspace_impl(f.center + ecef_vertex, elevation);
}
`,jp=`#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
}`,Zp=`#ifdef TAA
uniform vec2 u_vec2_camera_jitter;
void apply_vertex_jitter(inout vec4 clipPos) {
    clipPos.xy += clipPos.w * u_vec2_camera_jitter;
}
#endif`,$p=`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;
}
`,Wp=`uniform mat4 u_mat4_mvp;
`,Xp=`
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);
}
`,Kp=`
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){
                limited_factor = sign(factor) * min(g_max_factor, abs(factor));
            }
        }
    }
    
    
    if (limited_factor == 0.) {
        vec2 screen_widen = clip_space_widen.xy / clip_space_vertex.w * half_viewport;
        float screen_widen_len = length(screen_widen);
        if (screen_widen_len > 1e-4) {
            limited_factor = shift_pixels / screen_widen_len;
        }
    }
    return limited_factor;
}
`,qp=`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));
}`,Yp=`
const float g_circle_scale_precision_factor = 1e8;
`,Qp=`#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
`,Jp=`
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;
}
`,Ap=`
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);
    }
}
`,ev=`#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 `,tv=`
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); 
}
`,iv=`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);
}
`,nv=`#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);
}
`,ov=`#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;
}`,sv=`#include <prelude>
#include <ecef_mvp_mat>
#include <pos_world>
#include <cam_pos>
#include <shadow>
#include <fog>
#include <dem>
attribute vec3 a_vec3_vertex;
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_vertex.xy);
    vec4 pos = get_clipspace(a_vec3_vertex, a_vec3_vertex.z + height);
    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(vec3(a_vec3_vertex.xy, a_vec3_vertex.z + height));
    calc_fog_pos(pos_world);
}
`,rv=`#include <prelude>
#include <ecef_mvp_mat>
#include <dem>
attribute vec3 a_vec3_vertex;
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_vertex.xy);
    v_vec2_circle = a_vec2_widen;
    v_vec4_identifier = a_vec4_identifier;
    if (vec4(1., 1., 1., 1.) != a_vec4_identifier)
    {
        vec4 pos = get_clipspace(a_vec3_vertex, a_vec3_vertex.z + height);
        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.);
    }
}
`,av=`#include <prelude>
#include <ecef_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;
uniform vec4 u_vec4_tilecoords;
attribute vec3 a_vec3_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
    gl_Position = get_clipspace(a_vec3_vertex, u_float_floor_elevation);
    vec3 pos_world = calc_pos_world(vec3(a_vec3_vertex.xy, u_float_floor_elevation));
    calc_fog_pos(pos_world);
    
    
    
    
    
    
    
    v_vec2_texcoord = fract(abs((a_vec3_vertex.xy - 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_flat_mvp);
#ifdef MIX_COLOR_MODE
# if MIX_COLOR_MODE == MIX_COLOR_MODE_READ_FROM_TARGET
    v_vec4_pos = gl_Position;
# endif
#endif
}
`,lv=`#include <prelude>
#include <ecef_mvp_mat>
#include <round_position>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_floor_elevation;
uniform int u_int_is_3dfloor_object;
attribute vec3 a_vec3_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) {
        
        if (u_int_is_3dfloor_object == 0) {
            gl_Position = round_position(get_clipspace(a_vec3_vertex, u_float_floor_elevation), .5 * u_vec2_vpt_size);
        } else {
            gl_Position = get_clipspace(a_vec3_vertex, u_float_floor_elevation);
        }
    } else {
        gl_Position = vec4(1., 1., 1., 1.);
    }
}
`,cv=`#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;
}
`,dv=`#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;
}
`,_v=`#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);
}
`,uv=`#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;
}
`,hv=`#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;
}
`,fv=`#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);
}
`,mv=`#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);
}
`,pv=`#include <prelude>
#include <mvp_mat>
#include <dem>
attribute vec2 a_vec2_vertex;
attribute float a_float_height;
void main() {
    float height_tile = meters_to_tile_height(a_float_height);
    gl_Position = u_mat4_mvp * vec4(a_vec2_vertex, height_tile, 1.0);
}
`,vv=`#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);
}
`,gv=`#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_mix_color;
uniform float u_float_floor_elevation;
uniform int u_int_is_roof;
uniform int u_int_is_hole;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute float a_float_elevation;
attribute vec2 a_vec2_dem_position;
attribute float a_float_visibility;
attribute vec4 a_vec4_color;
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 (u_int_is_hole == 1 || 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;
    if (u_int_is_hole == 0)
    {
        
        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 && u_int_is_hole == 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 (a_vec4_color[3] > 0. ) {
        v_vec4_color = apply_opacity( mix(v_vec4_color, a_vec4_color, u_float_mix_color), u_float_opacity);
    }
    if (u_mat4_gradient[0][0] !=0.)
    {
        
        
        if (u_int_is_hole == 1)
        {
            v_vec4_rotated_scaled_vertex.w = a_float_z < 0.0 ? 0. : 1.;
        }
            else
        {
            if (a_float_z > 0. && a_float_elevation == 0.) {
                v_vec4_rotated_scaled_vertex.w = 1.;
            } else {
                v_vec4_rotated_scaled_vertex.w = a_float_elevation;
            }
        }
        v_mat4_gradient = u_mat4_gradient;
        if (a_vec4_color[3] > 0. ) {
            v_mat4_gradient[1] = mix(v_mat4_gradient[1], a_vec4_color, u_float_mix_color);
            v_mat4_gradient[2] = mix(v_mat4_gradient[2], a_vec4_color, u_float_mix_color);
        }
        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);
}
`,yv=`#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;
uniform int u_int_is_hole;
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 (u_int_is_hole == 1 || 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;
    if (u_int_is_hole == 0)
    {
        
        vertex_hf.z = max(vertex_hf.z, height);
    }
    gl_Position = round_position(
        u_mat4_mvp * vertex_hf,
        .5 * u_vec2_vpt_size);
}
`,xv=`#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);
}
`,bv=`#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 mat3 u_mat3_transform_tex_matrix;
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 vec3 a_vec3_instance_position;
attribute float a_float_instance_height;
#ifndef MALI_GPU
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_vec3_instance_position.xy,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)
    vec2 uvTransformed = ( u_mat3_transform_tex_matrix * vec3(texcoord_color, 1) ).xy;
    v_vec2_texcoord_color = uvTransformed;
    #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_vec3_instance_position.xy;
        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_vec3_instance_position.xy;
        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_vec3_instance_position.xy;
        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_vec3_instance_position.xy;
        height = dem_height(pos.xy);
    } else {
#ifdef MALI_GPU 
        
        
        height = dem_height(a_vec3_instance_position.xy); 
#else
        if (u_int_abs_z == 0) {
            height = dem_height(a_vec3_instance_position.xy);
        } else {
            height = abs_height(a_float_abs_z);
        }
#endif
    }
    height += u_float_floor_elevation;
    vec3 instance_position = vec3(a_vec3_instance_position.xy, 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_vec3_instance_position.xy);
                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 = u_mat4_flat_mvp * vec4(vflat.xyz, 1.);
#else
    
    if (is_flat_mode()) {
        gl_Position = get_clipspace(vflat.xyz);
    } else {
        gl_Position = get_clipspace_from_ecef_u16(a_vec3_instance_position, vertex.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);
}
`,wv=`#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 vec3 a_vec3_instance_position;
attribute float a_float_instance_height;
#ifndef MALI_GPU
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_vec3_instance_position.xy);
#else
    if (u_int_abs_z == 0) {
        height = dem_height(a_vec3_instance_position.xy);
    } else {
        height = abs_height(a_float_abs_z);
    }
#endif
    vec3 instance_position = vec3(a_vec3_instance_position.xy, 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_vec3_instance_position.xy);
                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 = u_mat4_flat_mvp * vec4(vflat.xyz, 1.);
#else
    
    if (is_flat_mode()) {
        gl_Position = get_clipspace(vflat.xyz);
    } else {
        gl_Position = get_clipspace_from_ecef_u16(a_vec3_instance_position, vertex.xyz, a_float_abs_z);
    }
#endif
    v_depth_metric = (gl_Position.z + 1.0) / 2.0;
}
`,Sv=`#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);
}
`,Tv=`#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));
}
`,Mv=`#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);
}
`,Ev=`#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_vertex;
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_vertex.xy);
    height += u_float_floor_elevation;
    vec4 pos;
    
    
    
    if (u_bool_skip_height_factor == true) {
        pos = vec4(a_vec3_vertex, 1.0);
    } else {
        pos = apply_height_factor(a_vec3_vertex, u_float_height_factor);
    }
    pos.z += height;
    vec3 pos_world = calc_pos_world(vec3(a_vec3_vertex.xy, 0.0));
    calc_fog_pos(pos_world);
    pos = get_clipspace(a_vec3_vertex, pos.z);
    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.;
}
`,Iv=`#include <prelude>
#include <ecef_mvp_mat>
#include <dem>
attribute vec3 a_vec3_vertex;
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_vertex.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_vertex, a_vec3_vertex.z);
        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.);
    }
}
`,Cv=`#include <prelude>
#include <ecef_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_mix_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 vec3 a_vec3_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;
attribute vec4 a_vec4_color;
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_vec3_vertex.xy);
        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_flat_mvp * vec4(normalize_s08(vec3(a_vec3_direction.xy, a_vec3_direction.z + height)), 0.);
    
    vec3 flat_vertex = vec3(a_vec3_vertex.xy, a_float_z);
    
    
    
    
    
    
    vec4 vertex_hf = apply_height_factor(flat_vertex, u_float_height_factor);
    vertex_hf.z += height;
    vertex_hf.z = max(vertex_hf.z, height);
    vec4 clip_space_vertex = get_clipspace(a_vec3_vertex, vertex_hf.z);
    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_flat_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.xyz);
    v_vec4_color = u_vec4_color;
    if (a_vec4_color[3] > 0. ) {
        v_vec4_color =  mix(v_vec4_color, a_vec4_color, u_float_mix_color);
    }
    v_vec3_normal = vec3(wall_normal, 0.0);
    if (u_mat4_gradient[0][0] !=0.)
    {
        v_mat4_gradient = u_mat4_gradient;
    
        if (a_vec4_color[3] > 0. ) {
            v_mat4_gradient[1] = mix(v_mat4_gradient[1], a_vec4_color, u_float_mix_color);
            v_mat4_gradient[2] = mix(v_mat4_gradient[2], a_vec4_color, u_float_mix_color);
        }
        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);
}
`,Lv=`#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);
}
`,Pv=`#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;
}
`,Bv=`#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);
}
`,zv=`#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 float u_float_mix_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 float u_float_floor_elevation;
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;
attribute vec4 a_vec4_color;
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;
    }
    vec4 t_vec4_color = u_vec4_color;
    if (a_vec4_color[3] > 0. ) {
        t_vec4_color =  mix(u_vec4_color, a_vec4_color, u_float_mix_color);
    }
    height += u_float_floor_elevation;
    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(t_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(t_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);
}
`,Rv=`#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;
uniform float u_float_floor_elevation;
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;
    }
    height += u_float_floor_elevation;
    
    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;
}`,Fv=`#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);
}
`,Dv=`#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);
}
`,Ov=`#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;
}
`,Nv=`#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;
}
`,kv=`#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_vertex;
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_vertex.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_vertex, 1.0);
    } else {
        anchor = apply_height_factor(a_vec3_vertex, u_float_height_factor);
    }
    anchor.z += height;
    vec3 pos_world = calc_pos_world(vec3(a_vec3_vertex.xy, 0.0));
    calc_fog_pos(pos_world);
    anchor = get_clipspace(a_vec3_vertex, anchor.z);
    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);
}
`,Uv=`#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_vertex;
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_vertex.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_vertex, 1.0);
        } else {
            anchor = apply_height_factor(a_vec3_vertex, u_float_height_factor);
        }
        anchor.z += height;
        anchor = get_clipspace(a_vec3_vertex, anchor.z);
        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;
}
`,Hv=`#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;
}
`,Gv=`#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);
}
`,Vv=`#include <prelude>
#include <ecef_mvp_mat>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <jitter>
#include <shadow>
attribute vec3 a_vec3_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;
uniform float u_float_floor_elevation;
uniform float u_float_ecef_scale;
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;
    vec2 offset_pixels = shift + extender;
    vec3 shifted_vertex_flat = vec3(a_vec3_vertex.xy + offset_pixels * u_float_tile_to_pixel_ratio, u_float_floor_elevation);
    vec4 clip_space_vertex;
    if (is_flat_mode()) {
        clip_space_vertex = get_clipspace(shifted_vertex_flat);
    } else {
        EcefTangentFrame ef = ecef_tangent_frame(a_vec3_vertex);
        vec2 offset_tile_points = offset_pixels * u_float_tile_to_pixel_ratio * 65535.0;
        vec3 shifted_vertex_ecef = ef.center +
            (ef.east * offset_tile_points.x + ef.north * offset_tile_points.y) * u_float_ecef_scale;
        clip_space_vertex = get_clipspace(shifted_vertex_ecef);
    }
    gl_Position = g_w_factor * clip_space_vertex;
    v_vec2_normal = normal;
    v_float_half_width = half_width;
    vec3 pos_world = calc_pos_world(shifted_vertex_flat);
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    compute_shadow_vertex(clip_space_vertex, vec3(0.0, 0.0, 1.0), u_mat4_flat_mvp);
}
`,jv=`#include <prelude>
#include <ecef_mvp_mat>
attribute vec3 a_vec3_vertex;
attribute vec4 a_vec4_normals;
attribute vec4 a_vec4_identifier;
uniform float u_float_width;
uniform float u_float_tile_to_pixel_ratio;
uniform float u_float_floor_elevation;
uniform float u_float_ecef_scale;
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) {
        vec2 offset_pixels = extender;
        
        vec3 shifted_vertex_flat = vec3(a_vec3_vertex.xy + offset_pixels * u_float_tile_to_pixel_ratio, u_float_floor_elevation);
        vec4 clip_space_vertex;
        if (is_flat_mode()) {
            clip_space_vertex = get_clipspace(shifted_vertex_flat);
        } else {
            EcefTangentFrame ef = ecef_tangent_frame(a_vec3_vertex);
            vec2 offset_tile_points = offset_pixels * u_float_tile_to_pixel_ratio * 65535.0;
            vec3 shifted_vertex_ecef = ef.center +
                (ef.east * offset_tile_points.x + ef.north * offset_tile_points.y) * u_float_ecef_scale;
            clip_space_vertex = get_clipspace(shifted_vertex_ecef);
        }
        gl_Position = g_w_factor * clip_space_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;
}
`,Zv=`#include <prelude>
#include <ecef_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 vec3 a_vec3_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_vertex = get_clipspace(a_vec3_vertex, u_float_floor_elevation);
    mat4 mvp = is_flat_mode() ? u_mat4_flat_mvp : u_mat4_ecef_mvp;
    vec4 clip_space_direction = normalize(mvp * vec4(normalize_s08(direction), 0.));
    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(vec3(a_vec3_vertex.xy, 0.));
    calc_fog_pos(pos_world);
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    
    compute_shadow_vertex(clip_space_vertex);
}
`,$v=`#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;
uniform vec4 u_vec4_color;
uniform float u_float_mix_color;
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;
attribute vec4 a_vec4_color;
varying float v_float_distance;
varying float v_float_distance_offset;
varying vec4 v_vec4_color;
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;
    }
    v_vec4_color = u_vec4_color;
    if (a_vec4_color[3] > 0. ) {
        v_vec4_color =  mix(v_vec4_color, a_vec4_color, u_float_mix_color);
    }
    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);
}
`,Wv=`#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);
}
`,Xv=`#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);
}
`,Kv=`#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);
}
`,qv=`#include <prelude>
#include <ecef_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;
uniform float u_float_floor_elevation;
uniform float u_float_ecef_scale;
attribute vec3 a_vec3_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);
}
vec4 get_clip_direction(const vec2 dir, const vec3 east, const vec3 north)
{
    vec4 flat_clip = u_mat4_flat_mvp * vec4(dir, 0., 0.);
    if (u_float_ecef_scale <= 0.) {
        return flat_clip;
    }
    vec3 ecef_dir = (east * dir.x + north * dir.y) * u_float_ecef_scale * 65535.;
    vec4 ecef_clip = u_mat4_ecef_mvp * vec4(ecef_dir * ECEF_WORLD, 0.);
    return mix(flat_clip, ecef_clip, u_float_crossfade);
}
void main()
{
    float height = 0.;
    if (u_bool_is_3d_line == true) {
        height = dem_height(a_vec3_vertex.xy);
    }
    if (u_bool_is_3d_line == true) {
        height += a_float_height / (65535. * 32.);
    }
    
    vec3 east = vec3(0.);
    vec3 north = vec3(0.);
    if (!is_flat_mode()) {
        vec3 ecef_pos = DECODE_ECEF(a_vec3_vertex);
        vec3 n = normalize(ecef_pos);
        vec3 raw_east = cross(vec3(0., 1., 0.), n);
        raw_east = dot(raw_east, raw_east) > 1e-12 ? raw_east : cross(vec3(1., 0., 0.), n);
        east = normalize(raw_east);
        north = cross(n, east);
    }
    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 = get_clip_direction(widen, east, north);
    vec4 clip_space_widen_perp = get_clip_direction(widen_perp, east, north);
    
    vec4 clip_space_vertex = get_clipspace(a_vec3_vertex, height + u_float_floor_elevation) + 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(vec3(a_vec3_vertex.xy, 0.));
    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_flat_mvp);
}
`,Yv=`#include <prelude>
#include <ecef_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;
uniform float u_float_ecef_scale;
attribute vec3 a_vec3_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);
}
vec4 get_clip_direction(const vec2 dir, const vec3 east, const vec3 north)
{
    vec4 flat_clip = u_mat4_flat_mvp * vec4(dir, 0., 0.);
    if (u_float_ecef_scale <= 0.) {
        return flat_clip;
    }
    vec3 ecef_dir = (east * dir.x + north * dir.y) * u_float_ecef_scale * 65535.;
    vec4 ecef_clip = u_mat4_ecef_mvp * vec4(ecef_dir * ECEF_WORLD, 0.);
    return mix(flat_clip, ecef_clip, u_float_crossfade);
}
void main()
{
    float height = 0.;
    if (u_bool_is_3d_line == true) {
        height = dem_height(a_vec3_vertex.xy);
    }
    if (u_bool_is_3d_line == true) {
        height += a_float_height / (65535. * 32.);
    }
    
    vec3 east = vec3(0.);
    vec3 north = vec3(0.);
    if (!is_flat_mode()) {
        vec3 ecef_pos = DECODE_ECEF(a_vec3_vertex);
        vec3 n = normalize(ecef_pos);
        vec3 raw_east = cross(vec3(0., 1., 0.), n);
        raw_east = dot(raw_east, raw_east) > 1e-12 ? raw_east : cross(vec3(1., 0., 0.), n);
        east = normalize(raw_east);
        north = cross(n, east);
    }
    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 = get_clip_direction(widen, east, north);
    vec4 clip_space_widen_perp = get_clip_direction(widen_perp, east, north);
    
    vec4 clip_space_vertex = get_clipspace(a_vec3_vertex, height) + 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.);
    }
}
`,Qv=`#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;
}
`,Jv=`#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);
}
`,Av=`#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.);
    }
}
`,eg=`#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;
}
`,tg={apply_height_factor:Op,apply_opacity:yl,arrow_functions:Np,calculate_scale:kp,cam_pos:xl,clipspace_pos:Up,dem:Hp,depth_test:Gp,ecef_mvp_mat:Vp,fog:jp,jitter:Zp,line_width:$p,mix_color_defs:bl,mvp_mat:Wp,packed_attributes:Xp,pixel_offset:Kp,pos_world:qp,precision_constants:Yp,prelude:Qp,raster_functions:Jp,round_position:Ap,shadow:ev,show_ratio:tv,signed_distance_functions:wl,striped_line_functions:iv},ig={arrow_line_entrance:nv,building_shadow:ov,circle_marker:sv,circle_marker_identify:rv,color:av,color_identify:lv,dem_elevation:cv,dem_elevation_copy:dv,dem_flat_bottom:_v,dem_ground:uv,dem_ground2:hv,dem_mesh:fv,dem_mesh2:mv,dem_mesh2_depthtest:pv,dem_normal:vv,diffuse:gv,diffuse_identify:yv,globe_halo:xv,gltf_model:bv,gltf_shadow:wv,heatmap:Sv,heatmap_texture:Tv,label_directional:Mv,label_fixed_anchor:Ev,label_fixed_anchor_identify:Iv,line:Cv,line3d:Lv,line3d_identify:Pv,map_mesh:Bv,mesh:zv,mesh_shadow:Rv,metric_point:Fv,one_way_line:Dv,patterned_line:Ov,point_anchor:Nv,pointsprite:kv,pointsprite_identify:Uv,posteffect:Hv,rect_with_texture:Gv,road:Vv,road_identify:jv,simple_line_2d:Zv,simple_line_3d:$v,simple_mesh:Wv,sky:Xv,stars:Kv,striped_line:qv,striped_line_identify:Yv,wall_texture:Qv,zbm_model:Jv,zbm_model_identify:Av,zbm_shadow:eg},ng=/^\s*#include\s+<(.+)>.*$/gim,og=(s,e)=>(t,i)=>{const o=i.trim(),r=s==="vertex"?tg[o]:Fp[o];if(!r)throw new Error(`Cannot resolve "include <${o}>" in ${s} shader "${e}"`);return r+`
`};function Sl(s,e){return[(s==="vertex"?ig[e]:Dp[e]).replace(ng,og(s,e))]}function G(s){const e=Fi.webglVersion===2?["#version 300 es"]:[],t=n.Shader.createShaderDefinitions([{type:`WEBGL${Fi.webglVersion}`,value:""},{type:Vh,value:""}]);return i=>new n.Shader("vertex",e.concat(Sl("vertex",s)),t,i)}function V(s){const e=Fi.webglVersion===2?["#version 300 es"]:[],t=n.Shader.createShaderDefinitions([{type:`WEBGL${Fi.webglVersion}`,value:""},{type:Gh,value:""}]);return i=>new n.Shader("fragment",e.concat(Sl("fragment",s)),t,i)}const ie={name:"u_mat4_mvp",type:"mat4"},Fe=[{name:"u_mat4_flat_mvp",type:"mat4"},{name:"u_mat4_ecef_mvp",type:"mat4"},{name:"u_mat4_vp",type:"mat4"},{name:"u_vec2_camera_merc",type:"2f"},{name:"u_vec4_vp_at_center",type:"4f"},{name:"u_float_crossfade",type:"1f"}],ne={name:"u_mat4_model",type:"mat4"},Ss=[{name:"u_vec2_anchor",type:"2f"},{name:"u_vec4_axis",type:"4f"},{name:"u_int_gltf_dem_pos",type:"1i"}],te=[{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"}],yt=[{name:"u_int_abs_z",type:"1i"}],de=[{name:"u_cam_pos",type:"3f"}],be=[{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"}],we=[{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"}],_e=[{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"}],Ie=[{name:"u_vec2_camera_jitter",type:"2f"}],Kt=[{name:"u_vec4_color_effect_mix_rgba",type:"4f"},{name:"u_float_color_effect_mix_factor",type:"1f"}];function sg(){return{simpleMesh:{buildFragment:V("simple_mesh"),buildVertex:G("simple_mesh"),attributes:[{name:"a_vec3_position",location:0},{name:"a_vec3_normal",location:1}],uniforms:[ie,{name:"u_float_scale",type:"1f"},{name:"u_vec3_transform",type:"3fv"}]},diffuse:{buildVertex:G("diffuse"),buildFragment:V("color_with_z_fade"),uniforms:[ie,ne,{name:"u_vec4_color",type:"4fv"},{name:"u_float_mix_color",type:"1f"},{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"},{name:"u_int_is_hole",type:"1i"},...de,...be,...we,...te,..._e,...Ie,...Kt],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},{name:"a_vec4_color",location:5}]},gradientDiffuse:{buildVertex:G("diffuse"),buildFragment:V("gradient_with_z_fade"),uniforms:[ie,ne,{name:"u_vec4_color",type:"4fv"},{name:"u_float_mix_color",type:"1f"},{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"},{name:"u_int_is_hole",type:"1i"},...de,...be,...we,...te,..._e,...Ie,...Kt],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_vec4_color",location:4},{name:"a_float_elevation",location:5}]},wallTexture:{buildVertex:G("wall_texture"),buildFragment:V("wall_texture"),uniforms:[ie,ne,{name:"u_float_height_factor",type:"1f"},{name:"u_float_mix_color",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"},...de,...be,...we,...te,..._e,...Ie],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},{name:"a_vec4_color",location:6}]},labelLine:{buildVertex:G("label_directional"),buildFragment:V("label_directional"),uniforms:[ie,ne,{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"},...de,..._e],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:G("label_fixed_anchor"),buildFragment:V("label"),uniforms:[...Fe,ne,{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"},...de,...te,..._e],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec2_offset",location:1},{name:"a_vec2_texcoord",location:2},{name:"a_vec2_check_offset",location:3},{name:"a_vec4_tex_identifier",location:4},{name:"a_vec4_sprite_identifier",location:5}]},labelPointIdentify:{buildVertex:G("label_fixed_anchor_identify"),buildFragment:V("color_identify"),uniforms:[...Fe,{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"},...te],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec2_offset",location:1},{name:"a_vec4_identifier",location:2}]},line:{buildVertex:G("line"),buildFragment:V("line"),uniforms:[...Fe,ne,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_mix_color",type:"1f"},{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"},...de,...be,...we,...te,..._e,...Ie,...Kt],attributes:[{name:"a_vec3_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},{name:"a_vec4_color",location:8}]},pointSprite:{buildVertex:G("pointsprite"),buildFragment:V("pointsprite"),uniforms:[...Fe,ne,{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"},...de,...te,..._e],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec2_offset",location:1},{name:"a_vec2_check_offset",location:2},{name:"a_vec2_texcoord",location:3},{name:"a_vec2_range",location:4},{name:"a_vec2_rescale",location:5},{name:"a_vec4_tex_identifier",location:6}]},pointSpriteIdentify:{buildVertex:G("pointsprite_identify"),buildFragment:V("pointsprite_identify"),uniforms:[...Fe,{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"},...te],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec2_offset",location:1},{name:"a_vec2_texcoord",location:2},{name:"a_vec2_range",location:3},{name:"a_vec2_rescale",location:4},{name:"a_vec4_identifier",location:5}]},pointDepthTest:{buildVertex:G("point_anchor"),buildFragment:V("color_identify"),uniforms:[ie,{name:"u_vec2_vpt_size",type:"2f"},{name:"u_vec2_offset",type:"2f"},{name:"u_float_floor_elevation",type:"1f"},...te],attributes:[{name:"a_vec4_position",location:0},{name:"a_vec2_offset",location:1},{name:"a_vec4_identifier",location:2}]},stripedLine:{buildVertex:G("striped_line"),buildFragment:V("striped_line"),uniforms:[...Fe,ne,{name:"u_float_ecef_scale",type:"1f"},{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"},{name:"u_float_floor_elevation",type:"1f"},...de,..._e,...Ie,...be,...we],attributes:[{name:"a_vec3_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:G("striped_line"),buildFragment:V("striped_line"),uniforms:[...Fe,ne,{name:"u_float_ecef_scale",type:"1f"},{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"},...te,...de,..._e,...Ie,...be,...we],attributes:[{name:"a_vec3_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:G("patterned_line"),buildFragment:V("patterned_line"),uniforms:[ie,{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"},ne,...de,..._e,...Ie,...be,...we],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:G("patterned_line"),buildFragment:V("patterned_line"),uniforms:[ie,{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"},ne,...te,...de,..._e,...Ie,...be,...we],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:G("striped_line_identify"),buildFragment:V("color_identify"),uniforms:[...Fe,{name:"u_float_ecef_scale",type:"1f"},{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"},{name:"u_float_floor_elevation",type:"1f"}],attributes:[{name:"a_vec3_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:G("striped_line_identify"),buildFragment:V("color_identify"),uniforms:[...Fe,{name:"u_float_ecef_scale",type:"1f"},{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"},...te],attributes:[{name:"a_vec3_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:G("color"),buildFragment:V("textured_color"),uniforms:[...Fe,ne,{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"},{name:"u_vec4_tilecoords",type:"4f"},...de,...be,...we,..._e,...Ie,...Kt],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_float_visibility",location:1},{name:"a_float_mix_factor",location:2}]},vtxColorIdentify:{buildVertex:G("color_identify"),buildFragment:V("color_identify"),uniforms:[...Fe,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_int_is_3dfloor_object",type:"1i"}],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec4_identifier",location:1},{name:"a_float_visibility",location:2}]},metricPoint:{buildVertex:G("metric_point"),buildFragment:V("metric_point"),uniforms:[ie,ne,{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"},...de,..._e,...be,...we],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},zbmModelIdentify:{buildVertex:G("zbm_model_identify"),buildFragment:V("color_identify"),uniforms:[ie,{name:"u_vec2_vpt_size",type:"2fv"},...te],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:G("diffuse_identify"),buildFragment:V("color_identify"),uniforms:[ie,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},{name:"u_int_is_hole",type:"1i"},...te],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:G("one_way_line"),buildFragment:V("one_way_line"),uniforms:[ie,ne,{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"},...de,..._e,...Ie],attributes:[{name:"a_vec2_position",location:0},{name:"a_vec2_direction",location:1},{name:"a_vec2_widen_direction",location:2}]},zbmModel:{buildVertex:G("zbm_model"),buildFragment:V("zbm_model"),uniforms:[ie,ne,{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"},...de,...te,..._e,...Ie,...be,...we],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:G("zbm_shadow"),buildFragment:V("main_shadow"),uniforms:[ie,{name:"u_float_height_factor",type:"1f"},...te],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_dem_position",location:2}]},gltfModel:{buildVertex:G("gltf_model"),buildFragment:V("gltf_model"),uniforms:[...Fe,ne,{name:"u_mat4_instance",type:"mat4"},{name:"u_mat4_localmatrix",type:"mat4"},{name:"u_mat3_transform_tex_matrix",type:"mat3"},{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"},...de,...Ie,..._e,...te,...be,...we,...yt,...Ss,...Kt],attributes:[{name:"position",location:0},{name:"normal",location:1},{name:"tangent",location:2},{name:"a_vec3_instance_position",location:3},{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:G("gltf_model"),buildFragment:V("color_identify"),uniforms:[...Fe,ne,{name:"u_mat4_instance",type:"mat4"},{name:"u_mat4_localmatrix",type:"mat4"},{name:"u_mat3_transform_tex_matrix",type:"mat3"},{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"},...de,..._e,...te,...yt,...Ss],attributes:[{name:"position",location:0},{name:"normal",location:1},{name:"tangent",location:2},{name:"a_vec3_instance_position",location:3},{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:G("gltf_shadow"),buildFragment:V("main_shadow"),uniforms:[...Fe,{name:"u_mat4_instance",type:"mat4"},{name:"u_mat4_localmatrix",type:"mat4"},{name:"u_mat3_transform_tex_matrix",type:"mat3"},{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"},...te,...yt,...Ss],attributes:[{name:"position",location:0},{name:"a_vec3_instance_position",location:3},{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:G("simple_line_2d"),buildFragment:V("simple_line_2d"),uniforms:[...Fe,ne,{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"},...de,...Ie,...be,..._e,...we,...Kt],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec4_direction_distance",location:1},{name:"a_float_visibility",location:2}]},simpleLine3d:{buildVertex:G("simple_line_3d"),buildFragment:V("simple_line_3d"),uniforms:[ie,ne,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_mix_color",type:"1f"},{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"},...de,...Ie,...be,..._e,...we,...te,...yt,...Kt],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},{name:"a_vec4_color",location:7}]},road:{buildVertex:G("road"),buildFragment:V("road"),uniforms:[...Fe,ne,{name:"u_float_ecef_scale",type:"1f"},{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"},{name:"u_float_floor_elevation",type:"1f"},...de,...be,..._e,...Ie,...we],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec4_normals",location:1},{name:"a_vec2_shift",location:2}]},roadIdentify:{buildVertex:G("road_identify"),buildFragment:V("road_identify"),uniforms:[...Fe,{name:"u_float_ecef_scale",type:"1f"},{name:"u_float_width",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},{name:"u_float_floor_elevation",type:"1f"}],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec4_normals",location:1},{name:"a_vec4_identifier",location:2}]},line3D:{buildVertex:G("line3d"),buildFragment:V("road"),uniforms:[ie,ne,{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},...te,...de,...be,..._e,...Ie,...we,...yt],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:G("line3d_identify"),buildFragment:V("road_identify"),uniforms:[ie,{name:"u_float_width",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},...te,...yt],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:G("arrow_line_entrance"),buildFragment:V("arrow_line"),uniforms:[ie,ne,{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"},...de,..._e],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:G("arrow_line_entrance"),buildFragment:V("arrow_line_identify"),uniforms:[ie,ne,{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:G("circle_marker"),buildFragment:V("circle_marker"),uniforms:[...Fe,ne,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},...de,..._e,...be,...we,...te],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec2_widen",location:1}]},rectWithTexture:{buildVertex:G("rect_with_texture"),buildFragment:V("rect_with_texture"),uniforms:[ie,ne,{name:"u_sr2d_texture",type:"1i"},{name:"u_float_opacity",type:"1f"},..._e,...de],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},circleMarkerIdentify:{buildVertex:G("circle_marker_identify"),buildFragment:V("color_identify"),uniforms:[...Fe,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_float_width",type:"1f"},...te],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec2_widen",location:1},{name:"a_vec4_identifier",location:2}]},heatmap:{buildVertex:G("heatmap"),buildFragment:V("heatmap"),uniforms:[ie,ne,...de,{name:"u_float_radius",type:"1f"},{name:"u_float_intensity",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},..._e],attributes:[{name:"a_vec2_position",location:0},{name:"a_vec2_widen",location:1},{name:"a_float_weight",location:2}]},heatmapTexture:{buildVertex:G("heatmap_texture"),buildFragment:V("heatmap_texture"),uniforms:[ne,{name:"u_sr2d_texture",type:"1i"},{name:"u_sr2d_ramp_texture",type:"1i"},{name:"u_float_opacity",type:"1f"},...de,..._e],attributes:[{name:"a_vec2_position",location:0}]},demMesh:{buildVertex:G("dem_mesh"),buildFragment:V("dem_mesh"),uniforms:[ie,ne,{name:"u_mat4_flat_map_mvp",type:"mat4"},{name:"u_flat_tex",type:"1i"},{name:"u_hillshade_tex",type:"1i"},...de,...te,..._e,...Ie,...be,...we],attributes:[{name:"a_vec2_position",location:0}]},demGround:{buildVertex:G("dem_ground"),buildFragment:V("dem_ground"),uniforms:[ie,ne,...te],attributes:[{name:"a_vec2_position",location:0}]},demMesh2:{buildVertex:G("dem_mesh2"),buildFragment:V("dem_mesh2"),uniforms:[ie,ne,{name:"u_mat4_flat_map_mvp",type:"mat4"},{name:"u_flat_tex",type:"1i"},{name:"u_hillshade_tex",type:"1i"},...de,...te,..._e,...Ie,...be,...we,{name:"u_int_identify",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demMesh2DepthTest:{buildVertex:G("dem_mesh2_depthtest"),buildFragment:V("uniform_color"),uniforms:[ie,...te,{name:"u_vec4_color",type:"4fv"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demGround2:{buildVertex:G("dem_ground2"),buildFragment:V("dem_ground2"),uniforms:[ie,ne,...te],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demElevationCopy:{buildVertex:G("dem_elevation_copy"),buildFragment:V("dem_elevation_copy"),uniforms:[ie,{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:G("dem_elevation"),buildFragment:V("dem_elevation"),uniforms:[ie],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demHillshade:{buildVertex:G("dem_normal"),buildFragment:V("dem_normal"),uniforms:[...te,...be,...we,ie,{name:"u_sr2d_texture",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},demFlatBottom:{buildVertex:G("dem_flat_bottom"),buildFragment:V("dem_flat_bottom"),uniforms:[ie,...te],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_centroid",location:1},{name:"a_vec2_extender",location:2}]},mesh:{buildVertex:G("mesh"),buildFragment:V("mesh"),uniforms:[ie,ne,...de,...te,...yt,...be,...we,..._e,...Ie,{name:"u_float_opacity",type:"1f"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_mix_color",type:"1f"},{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"},{name:"u_float_floor_elevation",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},{name:"a_vec4_color",location:9}]},inverse:{buildVertex:G("mesh"),buildFragment:V("inverse"),uniforms:[ie,ne,...de,...te,...yt,...be,...we,..._e,...Ie,{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"},{name:"u_float_floor_elevation",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:G("mesh"),buildFragment:V("depth_clear"),uniforms:[ie,ne,...de,...te,...yt,...be,...we,..._e,...Ie,{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"},{name:"u_float_floor_elevation",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:G("map_mesh"),buildFragment:V("map_mesh"),uniforms:[ie,ne,...de,...te,...be,...we,...yt,..._e,...Ie,{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:G("sky"),buildFragment:V("sky"),uniforms:[ne,...de,..._e],attributes:[{name:"a_vec2_vertex",location:0}]},taa:{buildVertex:G("posteffect"),buildFragment:V("taa"),uniforms:[{name:"u_texture",type:"1i"},{name:"u_float_mix_coef",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0}]},fxaa:{buildVertex:G("posteffect"),buildFragment:V("fxaa"),uniforms:[{name:"u_texture",type:"1i"},{name:"u_vec2_vpt_size",type:"2f"}],attributes:[{name:"a_vec2_vertex",location:0}]},copy:{buildVertex:G("posteffect"),buildFragment:V("copy"),uniforms:[{name:"u_texture",type:"1i"},{name:"u_depth",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0}]},buildingShadow:{buildVertex:G("building_shadow"),buildFragment:V("main_shadow"),uniforms:[...te,ie,{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:G("mesh_shadow"),buildFragment:V("main_shadow"),uniforms:[ie,{name:"u_float_height_factor",type:"1f"},...te,...yt,{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_abs_z",location:3},{name:"a_float_visibility",location:4},{name:"a_float_is_pivot",location:5}]},globeHalo:{buildVertex:G("globe_halo"),buildFragment:V("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:G("stars"),buildFragment:V("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:G("globe_halo"),buildFragment:V("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 rg(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 Tl{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),this._lastBinding=i,t.bindBufferBase(t.UNIFORM_BUFFER,i,this._buffer))}rebind(){this._lastBinding===void 0||!this._buffer||this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER,this._lastBinding,this._buffer)}updateData(e,t){this._buffer||this.prepare(e);const i=this._data;for(const o in t)if(o in this._uniformsMap){const r=t[o],a=this._uniformsMap[o]/4,l=e.uniforms[o];if(l!=null&&l.isNonFloatType()&&n.log(`[UBO Warn]: Currenty only float uniform types are supported. Uniform "${o}" has unsupported type`),n.isTypedArray(r)||n.isArrayOfNumbers(r))for(let c=0;c<r.length;++c)i[a+c]=r[c];else i[a]=r}}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.getUniformBlocksMap();if(!i){console.error("Failed to initialize UBO. Uniform blocks are not supported.");return}const o=e.getUniformBlockSize(this.params.blockName);if(o===null){console.error("Failed to initialize UBO. Invalid UBO block is provided.");return}this._data=new Float32Array(new ArrayBuffer(o));const r=i[this.params.blockName];r||console.error(`UBO block "${this.params.blockName}" not found in shader program.`);const a=e.getUniformsIndicesOffsetsInBlock(r);if(!a){console.error("Failed to initialize UBO. Couldn't retrieve uniforms information.");return}this._uniformsMap=a}}var Ts=(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))(Ts||{});const Ri=1/0,Gn=-1/0,Vn="renderCacheManager",ag=[0,0,0,0];class lg{constructor(e,t){this.prevFrameAnimationLayerOverCacheIndex=void 0,this.prevFrameAnimationLayerUnderCacheIndex=void 0,this.cacheObjectsCount=0,this.animationLayersOverCacheMinIndex=Ri,this.animationLayersUnderCacheMaxIndex=Gn,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()}isDisabled(){return this.cacheDisabled}setDisabled(e){this.cacheDisabled!==e&&(this.cacheDisabled=e,this.state.disableRenderingCache=e,this.isReadyCache=!1,this.cacheObjectsCount=0,this.cachedLayersMap=new Map,this.animationLayersUniqueIds.clear(),this.prevFrameAnimationLayerOverCacheIndex=void 0,this.prevFrameAnimationLayerUnderCacheIndex=void 0,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=Ri,this.animationLayersUnderCacheMaxIndex=Gn,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===Ri&&this.animationLayersUnderCacheMaxIndex===Gn||this.isLowZoom||this.animationLayersUnderCacheMaxIndex>=this.animationLayersOverCacheMinIndex||o&&this.modules.renderer.hasAnimatedFlatObjectInDemMode&&t.layerSettings.forceRenderUnderCacheInDemMode)return 1;const r=this.getUniqueRenderIndex(t.attributes.styleId,t.attributes.layerId);return r>=this.animationLayersOverCacheMinIndex?2:r<=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(){var t;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=(t=this.modules.renderer.getFramebuffer(this.cacheFramebufferId))==null?void 0:t.renderTarget;e&&!this.debugSkipRenderToCanvas&&(this.modules.renderer.storeGpuState(Vn),this.debugMode?this.modules.renderer.applyGpuState(xu,void 0,void 0,!1):this.modules.renderer.applyGpuState(yu,void 0,void 0,!1),this.modules.postEffectsManager.copyRenderTargetToCanvas(e,!0,!1),this.modules.renderer.restoreGpuState(Vn))}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?Gn:Ri;const r=this.modules.styleManager.getMaxLayersCount();return-e*r+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=w.NearestFilter,r=this.modules.renderer.getViewportSize(),a=new Ce({size:[r[0],r[1]],magFilter:o,minFilter:o,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,depthTexture:!0,format:w.RgbaFormat});return this.modules.renderer.addFramebuffer({onResize:()=>{const l=this.modules.renderer.getViewportSize();a.setSize([l[0],l[1]])},renderTarget:a,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(Vn),this.modules.renderer.applyGpuState(bu,void 0,void 0,!1),this.modules.renderer.clearWithColor(ag,!0),this.modules.renderer.bindRenderTarget(null),this.modules.renderer.restoreGpuState(Vn))},onRenderEnd:()=>{},isCacheFramebuffer:!0,useDem:!0,renderIndex:Ri})}}const cg=1.3,dg=2,Ml=n.reserveTextureIndex(),El=n.reserveTextureIndex(),Il=n.reserveTextureIndex(),_g=16,ug=0,qt=[1,1,1,1],Cl=new Float64Array(16);let Fi=(Tt=class extends l_{constructor(e,t){const i=t.layout.canvas,o=e.webglVersion,r={antialias:!1,stencil:o!==2,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:e.preserveDrawingBuffer};let a=null;if((!o||o===2)&&(a=i.getContext("webgl2",r),Tt.webglVersion=2),(a===null||o===1)&&(a=i.getContext("webgl",r)||i.getContext("experimental-webgl",r),Tt.webglVersion=1),a===null||!(a instanceof WebGLRenderingContext||a instanceof WebGL2RenderingContext))throw new Error("Failed to obtain WebGL context");super({gl:a,clearColor:n.getColorForShaders(e.defaultBackgroundColor)}),this.commonShaderDefines=n.EMPTY_SHADER_DEFINITIONS,this.hasAnimatedFlatObjectInDemMode=!1,this.destroyed=!1,this.framebuffers=[],this.lastRenderedFramebuffers=[],this.mapMeshMvpMatrix=new Float64Array(16),this.drawTargetsFramebufferIds=new Map,this.ubosMap={},this.lastAppliedGpuState={state:null},this.applyGpuState=(c,d,_,u=!0)=>{const h=c(this.modules,_),f=this.lastAppliedGpuState,m=d==null?void 0:d.gpuState;f.state===h&&f.layerState===(d==null?void 0:d.gpuState)||(this.applyState(h,m),u&&(f.state=h,f.layerState=d==null?void 0: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=a.getExtension("WEBGL_debug_renderer_info");this.webglContextState={MAX_TEXTURE_SIZE:a.getParameter(a.MAX_TEXTURE_SIZE),MAX_VIEWPORT_DIMS:a.getParameter(a.MAX_VIEWPORT_DIMS),MAX_UNIFORM_BUFFER_BINDINGS:a instanceof WebGLRenderingContext?0:a.getParameter(a.MAX_UNIFORM_BUFFER_BINDINGS),MAX_COMBINED_UNIFORM_BLOCKS:a instanceof WebGLRenderingContext?0:a.getParameter(a.MAX_COMBINED_UNIFORM_BLOCKS),RENDERER:l?a.getParameter(l.UNMASKED_RENDERER_WEBGL):a.getParameter(a.RENDERER),VENDOR:l?a.getParameter(l.UNMASKED_VENDOR_WEBGL):a.getParameter(a.VENDOR)},this.identifyBuffer=new Ce({minFilter:w.NearestFilter,magFilter:w.NearestFilter,useHighDepthPrecision:!0}),this.labelingTextureBuffer=new Ce({size:this.getViewportSize(),magFilter:w.NearestFilter,minFilter:w.NearestFilter,depthTexture:!0}),this.spriteLabelingTextureBuffer=new Ce({size:this.getViewportSize(),magFilter:w.NearestFilter,minFilter:w.NearestFilter,depthTexture:!1}),this.shaderProgramOptions=sg(),this.shaderPrograms={},t.map.once("idle",()=>rg(this,this.shaderProgramOptions)),this.symbolSettingsList=pm(),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"),Tt.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 vm(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(){var i;this.framebuffers.forEach(o=>{o&&o.onResize()});const e=this.getPixelRatio(),t=this.state.size.map(o=>Math.ceil(o*e));(i=this.modules.postEffectsManager)==null||i.invalidateSize(),this.identifyBuffer.setSize(t.map(o=>Math.ceil(o*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,r=t===!0?o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT:o.COLOR_BUFFER_BIT,a=t?$r:gu;this.applyGpuState(a),o.clearDepth(i),o.clearColor(e[0],e[1],e[2],e[3]),o.clear(r)}renderTileObjects(e){this.resetStateAfterExternalRender(),this.drawTargetsFramebufferIds.forEach(r=>{const a=this.getFramebuffer(r);a&&(a.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(r=>{o.groups.some(a=>a.framebuffer===r)||this.clearFramebuffer(r)}),this.lastRenderedFramebuffers=[],o.groups.forEach(r=>{var p,v,x,g;const{objects:a,tileObjects:l,isUnderCache:c}=r;let{framebuffer:d}=r;const _=this.modules.map.state.demMode&&(d===void 0||d.useDem===!0),u=!d,h=(d==null?void 0:d.isCacheFramebuffer)&&!this.modules.renderCacheManager.hasReadyCache(),f=!d&&this.modules.postEffectsManager.hasActiveEffects();f&&(d=this.modules.postEffectsManager.mainFrameBufferWrapper);const m=bt(this.state,this.modules,o.tiers,d==null?void 0:d.renderTarget,_);if(d)(p=d.onRenderStart)==null||p.call(d),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:y,viewport:b}=this.state,S=window.devicePixelRatio;this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,null),this._gl.viewport(b.left*S,b.bottom*S,y[0]*S,y[1]*S),u&&c&&this.clear(!0)}if(u||h){u&&c&&this.modules.environmentManager.renderSky();const y=_&&u&&(!this.modules.renderCacheManager.hasCachedObjects()||this.hasAnimatedFlatObjectInDemMode)&&!t,b=_&&h&&this.modules.renderCacheManager.hasCachedObjects()&&!this.hasAnimatedFlatObjectInDemMode&&!i;o.flatObjectsGroup&&(y||b)&&(b&&(i=!0),y&&(t=!0),this.renderDemMesh(m,o.flatObjectsGroup,!1,d))}if(a.length){const y=(x=(v=d==null?void 0:d.getViewProjectionMatrix)==null?void 0:v.call(d))!=null?x:this.modules.camera.viewProjectionMatrix,b=_?this.modules.demManager.demTextureMatrix:void 0;l.forEach(S=>{S.updateMvpMatrix(y,b)}),Ct(this.state,this.modules,a,m)}u&&c&&this.modules.renderCacheManager.render(),d==null||d.renderTarget.unbind(this._gl),(g=d==null?void 0:d.onRenderEnd)==null||g.call(d),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 r=this.timers.tryToGetFirstTimerValue();r&&this.modules.map.emit("gpuRenderTime",r.durationMs*1e6)}for(const[r,a]of this.drawTargetsFramebufferIds){const l=this.getFramebuffer(a);(!l||!l.requestedInCurrentFrame)&&(this.drawTargetsFramebufferIds.delete(r),this.removeFramebuffer(a))}return this}renderElevation(e){var l,c,d,_;if(!this.state.demMode)return;this.resetStateAfterExternalRender();const t=[];if(e.forEach(u=>u.demChildren.forEach(h=>t.push(h))),!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 r=bt(this.state,this.modules,void 0,o.renderTarget);(l=o.onRenderStart)==null||l.call(o),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 a=(d=(c=o.getViewProjectionMatrix)==null?void 0:c.call(o))!=null?d:this.modules.camera.viewProjectionMatrix;e.forEach(u=>{u.updateMvpMatrix(a)}),Ct(this.state,this.modules,t,r),o.renderTarget.unbind(this._gl),(_=o.onRenderEnd)==null||_.call(o)}renderGround(e){var l,c,d,_;if(!this.state.demMode)return;const t=[];if(e.forEach(u=>u.demGroundChildren.forEach(h=>t.push(h))),!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 r=bt(this.state,this.modules,void 0,o.renderTarget,!0,!0);(l=o.onRenderStart)==null||l.call(o),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 a=(d=(c=o.getViewProjectionMatrix)==null?void 0:c.call(o))!=null?d:this.modules.camera.viewProjectionMatrix;e.forEach(u=>{u.updateMvpMatrix(a,this.modules.demManager.demTextureMatrix)}),Ct(this.state,this.modules,t,r),o.renderTarget.unbind(this._gl),(_=o.onRenderEnd)==null||_.call(o)}renderSpriteLabelingTexture(e){if(this.modules.renderCacheManager.hasReadyCache())return;this.resetStateAfterExternalRender();const t=this._gl,i=[],o=bt(this.state,this.modules,void 0,this.spriteLabelingTextureBuffer,this.modules.map.state.demMode),r=e.filter(a=>a.labelTestChildren[0]);r.forEach(a=>{a.updateMvpMatrix(this.modules.camera.viewProjectionMatrix,this.modules.demManager.demTextureMatrix)}),r.forEach(a=>{a.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]),Ct(this.state,this.modules,i,o),this.spriteLabelingTextureBuffer.unbind(t)}renderLabelingTexture(e){var a;if(this.modules.renderCacheManager.hasReadyCache()||(this.resetStateAfterExternalRender(),this.state.isLabelingDepthTestDisabled=!0,this.state.styleZoom<_g||this.state.pitch===ug&&!((a=this.modules.floorManager)!=null&&a.hasActiveFloorOrMetro())||this.state.disableHidingPois))return;const t=this._gl,i=[],o=bt(this.state,this.modules,void 0,this.labelingTextureBuffer,this.modules.map.state.demMode),r=e.filter(l=>l.depthTestChildren[0]);r.forEach(l=>{l.updateMvpMatrix(this.modules.camera.viewProjectionMatrix,this.modules.demManager.demTextureMatrix)}),r.forEach(l=>{l.depthTestChildren.forEach(c=>{const d=this.modules.styleManager.getStyleLayer(c.attributes.styleId,c.attributes.layerId);(d&&d.type!=="gltfModel"||!(d!=null&&d.style.preventObjectsHiding))&&i.push(c)})}),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]),Ct(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:r,framebuffer:a,isUnderCache:l})=>{var u,h,f;const c=this.modules.map.state.demMode&&(a===void 0||a.useDem===!0),d=a?a.renderTarget:this.identifyBuffer,_=bt(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 m=(h=(u=a==null?void 0:a.getViewProjectionMatrix)==null?void 0:u.call(a))!=null?h:this.modules.camera.viewProjectionMatrix,p=c?this.modules.demManager.demTextureMatrix:void 0;r.forEach(v=>{v.updateMvpMatrix(m,p)}),Ct(this.state,this.modules,o,_)}d.unbind(t),a==null||a.renderTarget.unbind(this._gl),(f=a==null?void 0:a.onRenderEnd)==null||f.call(a)})}waitForGpuCommandsToFinish(){const e=new Float32Array(4);this.readPixelsFloat(0,0,1,1,e)}readPixelsFloat(e,t,i,o,r){const a=this._gl;a.readPixels(e,t,i,o,a.RGBA,a.FLOAT,r)}getRenderingContext(){return this._gl}getShaderProgram(e,t){var c,d;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 r=(c=t==null?void 0:t.hash)!=null?c:"",a=(d=t==null?void 0:t.defines)!=null?d:[];let l=o[r];return l||(l=new xo(this._gl,this.shaderProgramOptions[e],n.Shader.createShaderDefinitions([...this.commonShaderDefines.defines,...a])),o[r]=l),l}enableShaderProgram(e){var t;e.enable(),this.isUboSupported()&&((t=this.ubosMap.CommonSettings)==null||t.bind(e))}bindShaderProgram(e,t,i){e.bind(t,i)}destroy(){var t;if(this.destroyed)return;this.lastRenderedFramebuffers=[],this.framebuffers.forEach(i=>{i==null||i.renderTarget.remove()}),this.modules.layout.canvas.removeEventListener("webglcontextlost",this.trackContextLost),(t=this.timers)==null||t.destroy(),this.timers=void 0;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){var t;(t=this.framebuffers[e])==null||t.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,r=window.devicePixelRatio;t.viewport(o.left*r,o.bottom*r,i[0]*r,i[1]*r)}}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(),r=this.modules.map.state.size,a=new Ce({size:i?[Math.trunc(r[0]*Ne[0]*o),Math.trunc(r[1]*Ne[1]*o)]:this.getViewportSize(),magFilter:w.LinearFilter,minFilter:w.LinearFilter,depthTexture:!0,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,generateMipmaps:!1,format:Tt.webglVersion===2?w.RedFormat:w.RgbFormat}),l={renderTarget:a,clearColor:[0,0,0,0],clearDepth:!0,onResize:()=>{const c=this.modules.map.state.demMode,d=this.modules.map.state.size;a.setSize(c?[Math.trunc(d[0]*Ne[0]*o),Math.trunc(d[1]*Ne[1]*o)]:this.getViewportSize()),this.modules.renderer.bindRenderTarget(a),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:r,tiles:a}=t;if(!r)return;let l=this.modules.demManager.getFlatMapTextures();if(i&&(l=l.filter(E=>E.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:E})=>E==="mesh"||E==="mesh2")[0];if(!u)return;const h=this.state.handyStyleId,f=this.modules.styleManager.getStyleLayer(h,n.DEM_STYLE_LAYER_ID);if(!f||ps(u))return;const{size:m,viewport:p}=this.state,v=window.devicePixelRatio,{commonBinder:x,programBinder:g,layerBinder:y,programName:b}=u.layerSettings,S=this.getShaderProgram(b),T=[];a.forEach((E,P)=>{T.push({objects:E,tile:P})});const z=e.copy(r.renderTarget,!1,!0);l.forEach(E=>{var F,se;const k=T.filter(Q=>Ll(E.viewport,Q.tile.bounds.values())).reduce((Q,le)=>(le.tile.updateMvpMatrix(E.mvpMatrix,this.modules.demManager.demTextureMatrix),Q.concat(le.objects)),[]),R=[],C=new Map;if(k.forEach(({obj:Q,framebufferId:le})=>{if(le===void 0)R.push(Q);else{const D=C.get(le);D?D.push(Q):C.set(le,[Q])}}),C.forEach((Q,le)=>{var Ke,Se;const D=this.getFramebuffer(le);D&&((Ke=D.onRenderStart)==null||Ke.call(D),D.renderTarget.bind(this._gl),this._gl.viewport(0,0,D.renderTarget.options.size[0],D.renderTarget.options.size[1]),D.clearColor&&this.clearWithColor(D.clearColor,!1),Ct(this.state,this.modules,Q,z),D.renderTarget.unbind(this._gl),(Se=D.onRenderEnd)==null||Se.call(D))}),(F=r.onRenderStart)==null||F.call(r),r.renderTarget.bind(this._gl),this._gl.viewport(0,0,r.renderTarget.options.size[0],r.renderTarget.options.size[1]),r.clearColor&&this.clearWithColor(r.clearColor,!1),Ct(this.state,this.modules,R,z),r.renderTarget.unbind(this._gl),(se=r.onRenderEnd)==null||se.call(r),i){this.identifyBuffer.bind(this._gl);const Q=this.identifyBuffer.options.size;this._gl.viewport(0,0,Q[0],Q[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(S),this._gl instanceof WebGLRenderingContext&&(x==null||x(S,this.state,this.modules)),g==null||g(S,this.state,this.modules,!0),y==null||y(S,this.state,this.modules,f),e.useState(u,f),c.forEach(Q=>{if(Q instanceof Hr&&Q.needSync&&Q.syncReplicas(this.state),Ll(E.viewport,Q.bounds.values())){Q.updateMvpMatrix(this.modules.camera.viewProjectionMatrix,this.modules.demManager.demTextureMatrix,E.texMatrix);const le=(i?Q.identifyChildren:Q.children).filter(({sink:D})=>D==="mesh"||D==="mesh2");Vo(le,this.state,this.modules),e.drawSymbol(le,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:r}=o.state,a={},l={framebuffer:void 0,objects:[],tileObjects:new Set},c={framebuffer:void 0,objects:[],tileObjects:new Set,isUnderCache:!0},d={};let _;if(r){const h=t?i.getIdentifyFlatFramebufferId():i.getFlatFramebufferId(),f=this.getFramebuffer(h);f&&(_={framebuffer:f,tiles:new Map})}this.hasAnimatedFlatObjectInDemMode=!t&&r&&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=>{var b;if(m.sink==="mesh2")return;const{ids:p,defaultId:v,isDrawTarget:x}=this.modules.styleManager.getFramebufferId(m.attributes.styleId,m.attributes.layerId),g=p?p[m.sink]:v;if(g===n.INVALID_FRAMEBUFFER_ID)return;if(g===void 0||r&&x){const S=m.attributes.tiers;if(this.state.immersiveLevel.tiers&&S){let T=!1;if(S.forEach(z=>{if(!z){T=!0;return}d[z]||(d[z]={objects:[],tileObjects:new Set}),d[z].objects.push(m),d[z].tileObjects.add(h)}),!T)return}if(r&&!m.layerSettings.is3dMapAware)_!=null&&_.tiles.has(h)?(b=_==null?void 0:_.tiles.get(h))==null||b.push({obj:m,framebufferId:g}):_==null||_.tiles.set(h,[{obj:m,framebufferId:g}]),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 T=this.modules.renderCacheManager.tryToCacheObjects(a,m,h,r);if(T===Ts.CACHED)return;T===Ts.RENDER_OVER_CACHE?(l.objects.push(m),l.tileObjects.add(h)):(c.objects.push(m),c.tileObjects.add(h))}return}a[g]||(a[g]={framebuffer:this.getFramebuffer(g),objects:[],tileObjects:new Set}),a[g].objects.push(m),a[g].tileObjects.add(h)})});const u=Object.values(a).filter(h=>!!h.framebuffer);return u.sort((h,f)=>{var v,x,g,y;const m=(x=(v=h.framebuffer)==null?void 0:v.renderIndex)!=null?x:0,p=(y=(g=f.framebuffer)==null?void 0:g.renderIndex)!=null?y:0;return m-p}),u.push(c),t||(u.findIndex(f=>{var m;return(m=f.framebuffer)==null?void 0:m.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:ce(I({},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)}resetStateAfterExternalRender(){if(this.modules.styleManager.hasCustomLayers()){const e=this._gl;if(e instanceof WebGL2RenderingContext)e.bindVertexArray(null),e.bindBuffer(e.PIXEL_PACK_BUFFER,null),e.bindBuffer(e.PIXEL_UNPACK_BUFFER,null),e.bindBuffer(e.TRANSFORM_FEEDBACK_BUFFER,null),e.disable(e.RASTERIZER_DISCARD),e.bindSampler(0,null);else{const t=this.webGlExtensions.OES_vertex_array_object;t==null||t.bindVertexArrayOES(null)}if(e.useProgram(null),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,null),e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,null),e.bindTexture(e.TEXTURE_CUBE_MAP,null),e.depthRange(0,1),e.frontFace(e.CCW),e.disable(e.SCISSOR_TEST),e.disable(e.STENCIL_TEST),e instanceof WebGL2RenderingContext)for(const t in this.ubosMap)this.ubosMap[t].rebind();this.lastAppliedGpuState={state:null}}}isWebgl2Context(){return!(this._gl instanceof WebGLRenderingContext)}fragDepthSupported(){return this.isWebgl2Context()||!!this.modules.renderer.webGlExtensions.EXT_frag_depth}updateUbos(e=!1){var c;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 Tl({gl:t,blockName:"CommonSettings"}),this.ubosMap.CommonSettings=o,o.bind(i)),p_(i,this.state,this.modules,o),o.commitData();const r=this.modules.map.state,a=!isNaN(r.handyStyleId)&&this.modules.styleManager.getStyle(r.handyStyleId)||void 0,l=(c=a==null?void 0:a.light.lightingModesResolved)!=null?c:n.DEFAULT_LIGHTING_MODES;for(const d in l){let _=this.ubosMap[d];(!_||e)&&(_=new Tl({gl:t,blockName:"LightSettings"}));const u=l[d];_.updateData(i,{u_vec3_light_dir1_direction:u.dir1Direction,u_vec4_light_dir1_color:u.dir1ColorIntensity,u_vec3_light_dir2_direction:u.dir2Direction,u_vec4_light_dir2_color:u.dir2ColorIntensity,u_vec4_ambient_color:u.ambientColorIntensity}),this.ubosMap[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(qt[0],qt[1],qt[2],qt[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?w.NearestFilter:w.LinearFilter,{scale:o,size:r}=this.calculateMapMeshParams(e),a=new Ce({size:r,magFilter:i,minFilter:i,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping}),l={getViewProjectionMatrix:()=>{var _;const c=1-Math.cos(this.modules.map.state.pitch),d=(_=l.scale)!=null?_:this.calculateMapMeshParams(e).scale;return n.fromTranslationScale(Cl,[0,c/d[1],0],[1/d[0],1/d[1],1]),n.multiply(this.mapMeshMvpMatrix,Cl,this.modules.camera.viewProjectionMatrix),this.mapMeshMvpMatrix},onResize:()=>{const c=this.calculateMapMeshParams(e);l.scale=c.scale,a.setSize(c.size),a.bind(t),a.unbind(t)},renderTarget:a,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),r=Math.min(cg,Math.min(this.webglContextState.MAX_TEXTURE_SIZE,this.webglContextState.MAX_VIEWPORT_DIMS[0])/o[0]),a=Math.min(dg,Math.min(this.webglContextState.MAX_TEXTURE_SIZE,this.webglContextState.MAX_VIEWPORT_DIMS[1])/o[1]),l=[Math.trunc(o[0]*t*r),Math.trunc(o[1]*t*a)];return{scale:[r,a],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:jh}),this.modules.environmentManager.isSkyEnabled()&&e.push({type:Zh}),this.modules.shadowManager.texture&&e.push({type:tf}),this.state.aaMode===ri.FXAA?e.push({type:si.FXAA}):this.state.aaMode===ri.TAA&&e.push({type:si.TAA}),dr(this._gl)&&e.push({type:ef}),this.webglContextState.MAX_UNIFORM_BUFFER_BINDINGS>0&&e.push({type:nf}),this.state.isDeprecatedSystem?e.push({type:af}):(e.push({type:of}),e.push({type:sf})),this.webglContextState.RENDERER.toLowerCase().includes("mali")&&this.webglContextState.VENDOR.toLowerCase().includes("arm")&&e.push({type:rf}),n.Shader.createShaderDefinitions(e)}},Tt.webglVersion=NaN,Tt);function Ll(s,e){for(const t of e)if(n.tetragonIntersectsBounds(s,t))return!0;return!1}let Di="./worker.js";function hg(s){Di=s}function fg(){return Di}function mg(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 pg(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 vg(s){return{ModelsSource:s.set("ModelsWorker",n.ModelsWorker).get(n.ThreadName.Models)}}class gg{constructor(){this.connector=new n.MainConnector,this.fnRegistry=new n.FnRegistry(this.connector),this.classRegistry=new n.ClassRegistry(this.fnRegistry),this.parserWorker=new Worker(Di),this.labelingWorker=new Worker(Di),this.modelsWorker=new Worker(Di),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=mg(this.fnRegistry,this.classRegistry),this.labeling=pg(this.fnRegistry),this.models=vg(this.classRegistry)}syncStyle(e){this.parser.syncStyle(e),this.labeling.syncStyle(e)}destroy(){this.parserWorker.terminate(),this.labelingWorker.terminate(),this.modelsWorker.terminate()}}function yg(s=!1){const e=typeof window!="undefined",t=typeof SharedArrayBuffer!="undefined",i=e&&window.crossOriginIsolated===!0,o=typeof OffscreenCanvas!="undefined",r=typeof HTMLCanvasElement!="undefined",a=r&&"transferControlToOffscreen"in HTMLCanvasElement.prototype;s&&(console.log("[render][check] hasWindow:",e),console.log("[render][check] hasSharedArrayBuffer:",t),console.log("[render][check] isCrossOriginIsolated:",i),console.log("[render][check] hasOffscreenCanvas:",o),console.log("[render][check] hasHTMLCanvasElement:",r),console.log("[render][check] hasTransferControlToOffscreen:",a));const l=e&&t&&i&&o&&r&&a;return console.log(`[render] mode: ${l?"worker":"main thread"}`),l}function xg(){const s=document.createElement("canvas");return s.style.position="absolute",s.style.bottom="100px",s.style.left="0",s.style.width="50%",s.style.height="50%",s.style.pointerEvents="none",s}class bg{constructor(e,t){var a;if(this.frameWriteSlot=1,this.frameId=0,!e.webgpu)return;const i=yg();this.transportBuffer=i?new SharedArrayBuffer(n.TRANSPORT_SIZE):new ArrayBuffer(n.TRANSPORT_SIZE),this.transportI32=new Int32Array(this.transportBuffer),this.transportU32=new Uint32Array(this.transportBuffer),this.transportF64=new Float64Array(this.transportBuffer),n.initTransportHeader(this.transportU32);const o=xg();(a=t.layout.canvas.parentElement)==null||a.appendChild(o);let r;if(i){this.worker=new Worker(fg(),{name:"Render"}),this.worker.postMessage({msg:{youare:"render"}});const l=o.transferControlToOffscreen();r=n.wrap(this.worker)(n.RenderBackendType.WebGPU,n.transfer(l,[l]),this.transportBuffer)}else r=n.createRenderRunner(n.RenderBackendType.WebGPU,o,this.transportBuffer);r.then(l=>this.runner=l).then(()=>t.map.invalidateSize()).then(()=>{var l;return(l=this.runner)==null?void 0:l.start()})}submit(e){const t=n.TransportHeader._Size+this.frameWriteSlot*n.DEFAULT_FRAME_SIZE,i=new Uint8Array(this.transportBuffer,t,e.bytesUsed),o=new Uint8Array(e.buffer,0,e.bytesUsed);i.set(o),this.frameId=this.frameId+1|0,this.transportU32[t+n.FrameHeader.FrameId>>2]=this.frameId,this.transportF64[t+n.FrameHeader.SubmitTime>>3]=performance.now(),this.frameWriteSlot=n.mailboxSwap(this.transportI32,n.TransportHeader.FrameMailbox,this.frameWriteSlot)}resize(e,t,i){return K(this,null,function*(){var o;(o=this.runner)==null||o.resize(e,t,i)})}destroy(){var e;this.worker?(this.worker.terminate(),this.worker=void 0):(e=this.runner)==null||e.destroy(),this.runner=void 0}}class wg{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(){var t,i;const e={colorBuffer:(i=(t=this.colorBuffer)==null?void 0:t.byteLength)!=null?i:0};return{js:ce(I({},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]}readIdentifyPixels(e=!1){return K(this,null,function*(){const t=this.modules.renderer.getRenderingContext(),i=this.modules.renderer.identifyBuffer,o=i.options.size,r=o[0],a=o[1];if(e||t instanceof WebGLRenderingContext||this.state.forceSyncIdentify){const l=new Uint8Array(r*a*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)=>{K(this,null,function*(){const d=new Uint8Array(r*a*4);i.bind(t);const _=r*a*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,r,a,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}yield 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((r,a)=>{function l(){const c=e.clientWaitSync(t,i,0);if(c===e.WAIT_FAILED){a();return}if(c===e.TIMEOUT_EXPIRED){setTimeout(l,o);return}r()}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 r=1/0,a,l=!1;const c=n.create$6();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);(!a||!l&&_||d.phase>a.phase||d.phase===a.phase&&u<r)&&(a=d,r=u,_&&(l=!0))}return a}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 r=Math.floor(e[0]*t),l=((i[1]-1-Math.floor(e[1]*t))*i[0]+r)*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)}fillCache(){return K(this,null,function*(){if(!this.cacheBusy)try{this.cacheBusy=!0;const e=this.modules.tileManager.getTileObjects();this.modules.renderer.renderIdentify(e),this.colorBuffer=yield 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(r=>this.identifyData.push(r))})}catch(e){console.warn(`Cannot fill cache: ${e}`)}finally{this.cacheBusy=!1}})}indexToIdentifierResponse(e){var t,i,o;for(let r=0;r<this.identifyData.length;r++){const a=this.identifyData[r],{dynamicObjectId:l,ids:c,metatileHash:d,sourceId:_,tileKey:u}=a,{startIndex:h,endIndex:f,idBuffer:m,floorIdBuffer:p,phaseBuffer:v,sublayerBuffer:x,styleIdBuffer:g,layerIdBuffer:y,instanceIdBuffer:b,objectClassBuffer:S,centerBuffer:T,strings:z}=c;if(e<h||e>f)continue;const E=e-h,P=m[E],k=new Uint32Array(x)[E],R=new Uint8Array(b)[E],C=new Uint32Array(S)[E];let F,se="";const Q=p[E],le=this.modules.assetManager.getMetatile(d);if(le){(t=le.reverseDictionaries.db_sublayer)!=null&&t[k]&&(F=le.reverseDictionaries.db_sublayer[k]);const Ue=z[e];Ue!==void 0?se=Ue.objectClass:se=(o=(i=le==null?void 0:le.reverseDictionaries.db_object_class)==null?void 0:i[C])!=null?o:""}const D=new Uint16Array(g)[E],Ke=new Uint32Array(y)[E],Se=this.modules.styleManager.getStyleLayer(D,Ke);if(!Se||Se.type==="custom")return;const ye=new Int32Array(T,E*Int32Array.BYTES_PER_ELEMENT*2,2);return{id:P,styleId:D,layerId:Ke,floorId:Q,phase:new Float32Array(v)[E],dynamicObjectId:l,sourceId:_,tileKey:u,sublayer:F,symbol:Se.type,instanceId:R,objectClass:se,center:ye[0]!==n.INVALID_IDENTIFY_CENTER_COORD||ye[1]!==n.INVALID_IDENTIFY_CENTER_COORD?[ye[0],ye[1]]:void 0}}}}function Sg(s,e,t){var r;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(l=>l&&l.id===t);if(a)i=e.layers.findIndex(l=>l.groupId===a.innerId);else{i=e.layers.findIndex(c=>c.id===t);const l=(r=e.layers[i])==null?void 0:r.groupId;if(l!==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 «${l}». 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 l=e.groupsById[a.groupId];if(!l){n.log(`Для слоя с id «${a.id}» находящегося в группе с groupId «${a.groupId}» отсутствует группа id в стиле c id «${e.id}»`);return}const c=l.layers.findIndex(d=>d.id===a.id);if(c===-1){n.log(`Слой с id «${a.id}» и groupId «${a.groupId}» отсутствует группе в стиле c id «${e.id}»`);return}s.groupId=l.innerId,l.layers.splice(c,0,s),l.layers.forEach((d,_)=>d.groupIndex=_)}}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 l=Math.max(0,...Object.keys(e.rasterSets.byIndex).map(_=>Number(_))),c=new n.HandyIndexer(l+1);n.makeHandyRasterSets(a,c,e.icons).forEach(_=>{e.rasterSets.byKey[_.key]||(e.rasterSets.byIndex[_.index]=_,e.rasterSets.byKey[_.key]=_)})}}),Pl(e)}function Tg(s,e,t){const i=e.layerIdToInnerId[s];if(i===void 0)return;e.revision++;let o=[];const r=e.groupsById[i];if(r){if(o=r.layers,delete e.groupsById[i],delete e.layerIdToInnerId[r.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 a=e.layers.findIndex(l=>l.id===o[0].id);a!==-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(a,o.length),Pl(e))}function Pl(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 Mg(s,e,t){const{map:{state:i},collector:o,imageManager:r,renderer:a,tileManager:l}=t;let c;try{c=Eg(i,s,256)}catch(g){console.error(g);return}const d=r.addPreparedTexture(c),{downscale:_}=s.style,{size:u}=i,h=new Ce({size:[Math.ceil(u[0]*window.devicePixelRatio/_),Math.ceil(u[1]*window.devicePixelRatio/_)],magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping}),f=h.getTexture();if(!f){console.error("Can't init HeatMap Layer. Missing FrameBuffer texture");return}const m=r.addPreparedTexture(f),p=a.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/_)]),a.bindRenderTarget(h),a.bindRenderTarget(null);const g=h.getTexture();g&&r.updatePreparedTexture(m,g)}});n.generateSafely({collector:o,generator:n.HeatmapGenerator.generateTexture,args:[e,s,m,d]});const v=o.getAccumulatedData(),x=new n.TileObject("dynamicObject",v.data,t,i);return l.addObject(x),o.reset(),s.framebufferId={framebuffer:p},g=>{l.removeObject(x),x.clean(g),r.deleteTexture(m),r.deleteTexture(d),a.removeFramebuffer(p)}}function Eg(s,e,t){const i=n.makeBinderContext(s.styleZoom,s.styleState,[]),o=e.style.color,r=[];if(!Ig(o.argument))throw new Error(`Heatmap color must be interpolate expression with 'heatmap-density' argument in layer ${e.id}`);const a=t-1;for(let l=0;l<t;l++){const c=l/a,d=n.sampleColor(o,c,i);r.push(...d.value)}return new w(new Uint8Array(r),{size:[t,1]})}function Ig(s){return typeof s=="object"&&s.type==="heatmap-density"}const Bl=1,zl={type:"color",value:[0,0,0,0]};class Cg{constructor(e){this.modules=e,this.customLayers=new Map,this.maxCountStyleLayers=1e4,this.styleIndex=Bl,this.handyStylesMap=new Map,this.waitingStyleRequests=new Map,this.onRemoveLayerHooks=new Map}createStyle(e,t){const{state:i}=this.modules.map;if(!Number.isNaN(i.handyStyleId)){const l=this.getStyle(i.handyStyleId);l&&(l.layers.forEach(c=>{const d=this.onRemoveLayerHooks.get(c.innerId);d&&d(i)}),this.onRemoveLayerHooks.clear())}const o=this.styleIndex++;o-n.UNUSED_STYLE_ID_SHIFT>0&&this.handyStylesMap.delete(o-n.UNUSED_STYLE_ID_SHIFT);const r=n.makeHandyStyle(e,o);n.applyStyleOptions(r,t),this.handyStylesMap.set(r.id,r),this.setMaxLayersCount(r.layers.length);const a=this.waitingStyleRequests.get(o);return a&&a.resolve(r),this.modules.workers.syncStyle(r),r.layers.forEach(l=>this.initHandyLayer(o,l)),r}hasLayer(e){const t=this.getStyle(this.modules.map.state.handyStyleId);return(t==null?void 0:t.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&&(Sg(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)),r=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,...r].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:r,imageType:a,anchor:l})=>{n.expressionValues(r).forEach(c=>{if(c===e){const d=a==="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}Tg(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){var i;return(i=this.handyStylesMap.get(e))==null?void 0:i.layersById[t]}getStyleRevision(e){var t;return((t=this.getStyle(e))==null?void 0:t.revision)||0}setFramebufferId(e,t,i){var r;const o=(r=this.handyStylesMap.get(e))==null?void 0:r.layersById[t];o&&(o.framebufferId=i)}getFramebufferId(e,t){var o;const i=(o=this.handyStylesMap.get(e))==null?void 0:o.layersById[t];return i!=null&&i.drawToTarget?{ids:void 0,defaultId:this.modules.renderer.getDrawTargetFramebufferId(i.drawToTarget),isDrawTarget:!0}:{ids:i==null?void 0: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(r=>{o.resolve=r}),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}=this.modules,{state:t}=e,i=this.handyStylesMap.get(t==null?void 0:t.handyStyleId);if(!i)return t.defaultBackgroundColor;const o=n.makeBinderContext(t.styleZoom,t.styleState,[]),r=n.resolveColor(i.environment.style.skyColor,o),a=t.globeMode?t.globeRatioTarget:0;return n.lerp$3(zl.value,i.background.color.value,r.value,a),zl}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)))}hasCustomLayers(){return this.customLayers.size>0}setLayerVisibility(e,t,i){const{id:o,type:r}=t;if(o&&i.layersById){const a=i.layerIdToInnerId[o];if(a){const l=i.layersById[a];if(l)l.style&&(l.style.visibility=e);else{const c=i.groupsById[a];c==null||c.layers.forEach(d=>{d&&d.style&&(d.style.visibility=e)})}}}r&&i.layers.forEach(a=>{a.type===r&&(a.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=Mg(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,r){const a={sceneObject:{type:n.SceneObjectType.Custom,attributes:{styleId:e,layerId:t.innerId,tileData:[]},tile:{zoomLevel:0},layerSettings:{},canRender:!0},layer:t,renderFunction:i};r==null||r(),this.customLayers.set(t.innerId,a),this.modules.styleManager.addRemoveLayerHook(t.innerId,()=>{o==null||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((r,a)=>{var _;const l=(_=i==null?void 0:i.icons[r.image])==null?void 0:_.url;if(!l){console.warn(`Texture source for polygonExtrusionSideTexture ${r.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()?w.LinearMipMapLinearFilter:w.LinearFilter,imagePadding:0,premultiplyAlpha:!0}).then(u=>{u!==void 0&&!o&&(t.sideTextureIndices[a]=u)})}),()=>{o=!0}}}class St{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 r=0;r<o.length;r++)o[r].call(this,t);return this}}const jn="gltfModels";let Rl=class{constructor(e,t){var i,o;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:(i=e.tileSessionId)!=null?i:e.sessionId,isDefaultSource:!0,modelsPath:e.defaultSourceModelsRootUrl,sharedModelsPath:e.sharedModelsPath,promoteId:"id",idScope:n.DEFAULT_ID_SCOPE,identifyAsDefaultSource:!0},this.modelsAppearStrategy=(o=e.defaultSourceModelsAppearStrategy)!=null?o: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 r=n.TileLayer.prototype.getLabelingData.call(this.universeTileLayer);return this.regionalTileLayer.isBlank()||(r.labelsKeys=[]),r},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:e.tileProtocol,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(){var e;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:this.state.tileProtocol,lang:this.state.lang}),ignoreMissingTiles:!0,identifyAsDefaultSource:!0,promoteId:"building_id",modelsPath:(e=this.state.defaultSourceModelsRootUrl)!=null?e:n.bindUrl("gltfModel",{host:this.state.tileServer,tileSet:this.state.tileSet,protocol:this.state.tileProtocol,lang:this.state.lang}),flipY:!0,attributes:{sourceName:jn}},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=I({regionalTileLayer:this.regionalTileLayer.memSizeJs(),universeTileLayer:this.universeTileLayer.memSizeJs(),modelsTileLayer:this.modelsTileLayer?this.modelsTileLayer.memSizeJs():{}},this.commercialPoiTileLayer&&{commercialPoiTileLayer:this.commercialPoiTileLayer.memSizeJs()}),t=I({regionalTileLayer:this.regionalTileLayer.memSizeGpu(),universeTileLayer:this.universeTileLayer.memSizeGpu(),modelsTileLayer:this.modelsTileLayer?this.modelsTileLayer.memSizeGpu():{}},this.commercialPoiTileLayer&&{commercialPoiTileLayer:this.commercialPoiTileLayer.memSizeGpu()});return{js:ce(I({},e),{"--sum":n.getTotalMemory(e)}),gpu:ce(I({},t),{"--sum":n.getTotalMemory(t)})}}destroy(){var e,t;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()),(e=this.commercialPoiSource)==null||e.destroy(),this.modelsTileLayer&&(this.modules.tileManager.removeTileLayer(this.modelsTileLayer),this.modelsTileLayer.destroy()),(t=this.modelsSource)==null||t.destroy(),this.modules.sourceStorage.removeSource(this.id)}setAttributes(e){var t,i,o;this.zenithSource.setAttributes(I(I({},e),n.zenithSourceAttrs)),this.universeTileLayer.redraw(),this.regionalTileLayer.redraw(),(t=this.commercialPoiSource)==null||t.setAttributes(e),(i=this.commercialPoiTileLayer)==null||i.redraw(),(o=this.modelsSource)==null||o.setAttributes(ce(I({},e),{sourceName:jn})),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){var t,i;this.zenithSource.setFeatureStateMap(e),(t=this.modelsSource)==null||t.setFeatureStateMap(e),this.universeTileLayer.onFeatureStateMapChange(),this.regionalTileLayer.onFeatureStateMapChange(),(i=this.modelsTileLayer)==null||i.onFeatureStateMapChange(),this.modules.modelLayer.onFeatureStateMapChange()}generateHoverTile(e,t,i,o,r,a,l,c){return this.zenithSource.generateTile(e,t,i,o,r,a,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){var t;this.zenithSource.setDataFilter(e),(t=this.modelsSource)==null||t.setDataFilter(e)}hasLayer(e){return this.modelsTileLayer===e||this.regionalTileLayer===e||this.universeTileLayer===e||this.commercialPoiTileLayer===e}};class Lg extends St{constructor(e,t){super(),this.loadFont=(r,a)=>{let l=this.requestFontRanges.get(r,a);return l||(l=this.createLoadFontRequest(r,a),this.requestFontRanges.set(r,a,l)),l},this.invalidateUsedGltfModels=n.throttle(()=>{var c;const r=new Set;if(this.modules.renderer.isDestroyed)return;const a=this.modules.tileManager.getTileObjects();for(const d of a)for(const _ of d.children){if(!ps(_))continue;const{styleId:u,layerId:h,modelIndices:f,sourceId:m,sourceName:p}=_.attributes,v=this.modules.styleManager.getStyleLayer(u,h);if(!v||v.type!=="gltfModel")continue;const x=this.modules.modelsScene.getCurrentLayerModelId(_.attributes,_.tile);f.forEach(g=>{const y=this.getModel(g,u);if(y){r.add(y);return}if(x===g){const b=this.dataModelIdToUrl[g];if(b){const S=m===this.modules.defaultSource.getId()&&p===jn;this.loadModel(b,g,u,!1,v,S)}else this.loadModelByIndex(g,u,v)}})}const l=this.modules.tileManager.getCachedMods();for(const d of l)(c=d.objects)==null||c.forEach(_=>{for(const u of _.children){if(!ps(u))continue;const{styleId:h,layerId:f,modelIndices:m}=u.attributes,p=this.modules.styleManager.getStyleLayer(h,f);if(!p||p.type!=="gltfModel")return;m.forEach(v=>{const x=this.getModel(v,u.attributes.styleId);x&&r.add(x)})}});for(const d in this.models){const _=this.models[d];!_.preserve&&!r.has(_)&&_.status===ot.Loaded&&_.usedEmptyScene!==!0?this.removeModel(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=(r,a,l)=>{const c=n.hashToString(a);fetch(r).then(d=>{if(!d.ok)throw new Error(`Failed to load metatile "${c}"`);return d.json()}).then(d=>this.setMetatile(a,l,d)).catch(d=>console.error(d))};const i=(r,a)=>{const l=this.modules.styleManager.getStyle(r);if(!l){console.error(`Not found style ${r} in AssetManager#addNewRasterSets`);return}const{rasterSets:c}=l;a.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((r,a)=>{var l,c;return r.push({bitmap:(c=(l=a.bitmap)==null?void 0:l.byteLength)!=null?c:0}),r},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:ce(I({},e),{"--sum":n.getTotalMemory(e)}),gpu:ce(I({},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){var c,d,_;const o=this.modules.styleManager.getStyle(e);if(!o){console.error(`Not found style ${e} in AssetManager#prepareRasters`);return}const{rasterSets:r}=o,a=7,l=t.length/a;for(let u=0;u<l;u++){const h=t[u*a],f=t[u*a+1],m=t[u*a+6],p=t[u*a+2],v=t[u*a+3],x=t[u*a+4],g=t[u*a+5],y=r.byIndex[h];if(y.isSvg){const T={rasterIndex:f,rasterSetIndex:h,x:p,y:v,w:x,h:g,anchorX:y.anchorX,anchorY:y.anchorY,atlasIndex:m,isPacked:!0};y.rasters[f]=T,(d=(c=this.requestedSvgs[o.id])==null?void 0:c[h])==null||d.then(z=>{const E=this.textures[T.atlasIndex],{url:P,revokeURL:k}=Ja(z);Qa(P,T.w,T.h).then(R=>{E.subImage(R,T.x,T.y),this.modules.renderer.addRerenderEvent(),k&&k()})})}else{const T=(_=y.rasters[f])!=null?_:{rasterIndex:f,rasterSetIndex:h,x:p,y:v,w:x,h:g,anchorX:0,anchorY:0,atlasIndex:m,isPacked:!0};y.rasters[f]=T,T.x=p,T.y=v,T.atlasIndex=m,T.isPacked=!0}this.textures[m]===void 0&&(this.textures[m]=new w(void 0,{size:n.atlasSize,flipY:!1,premultiplyAlpha:!Bd,magFilter:w.LinearFilter,minFilter:w.LinearFilter}),this.modules.renderer.prepareTexture(this.textures[m]));const b=this.textures[m],S=i&&i[u];if(S!==void 0){b.subImage(S,p,v),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 r=e[o*3],a=e[o*3+1],l=e[o*3+2],c=a<<16|l,d=this.modules.styleManager.getStyle(r);if(!d){console.error(`Not found style ${r} in AssetManager#loadRasters`);continue}if(this.loadedRasters[r]||(this.loadedRasters[r]=new Set,this.failedRasters[r]=new Set,this.requestedRasters[r]=new Set),this.requestedRasters[r].has(c))continue;const{rasterSets:_}=d,u=_.byIndex[a];if(u.rasters[l].isPacked===!1){console.error(`Try to load not packed raster ${u.key}`);continue}this.requestedRasters[r].add(c),u.isSvg?this.loadSvg(c,d,a):this.loadPng(c,d,a,l)}}removeRasterSet(e,t){const{key:i,index:o,rasters:r}=e;delete this.requestedSvgs[t][o],r.forEach(({rasterSetIndex:l,rasterIndex:c})=>{var _,u,h;const d=l<<16|c;(_=this.loadedRasters[t])==null||_.delete(d),(u=this.failedRasters[t])==null||u.delete(d),(h=this.requestedRasters[t])==null||h.delete(d)}),e.rasters.length=0;const a=this.modules.styleManager.getStyle(t);a&&(delete a.rasterSets.byIndex[o],delete a.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 r=this.modules.styleManager.getStyle(t);if(r===void 0){n.logGltfError({layer:"prepare",message:"Style not found. Can't determine url"});return}const a=r.models[e];if(a===void 0){n.logGltfError({layer:"prepare",message:`Model with index "${e}" is missing in the style.`});return}const l=n.getModelUrl(a.url,r);this.fetchModel(l,e,o,!1,i,!1)}loadModel(e,t,i,o,r,a,l){const c=this.getModelUniqueKey(t,i);if(this.models[c]!==void 0){l==null||l();return}this.fetchModel(e,t,c,o,r,a,l)}getModel(e,t){return this.models[this.getModelUniqueKey(e,t)]}allModelsLoaded(){for(const e in this.models)if(this.models[e].status===ot.Pending)return!1;return!0}isModelLoaded(e,t){const i=this.models[this.getModelUniqueKey(e,t)];return i&&i.status===ot.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,r,a,l){const{renderer:c}=this.modules,d=this.models[i]=Wf(o);this.modelsWorker.loadModel(e,this.state.dracoDecoderUrl).then(_=>{if(_.type==="ok"){if(d.status=ot.Loaded,!_.result)return;Xf(d,c,_.result,t,r,a),this.emit("modelloaded",t),this.modules.renderer.addRerenderEvent(),l==null||l()}else n.logGltfError(_),d.status=ot.Failed})}getModelUniqueKey(e,t){return e>=0?`${t},${e}`:String(e)}createLoadFontRequest(e,t){return K(this,null,function*(){this.pendingFontRanges+=1;const i=Number.isNaN(this.state.handyStyleId)?Bl:this.state.handyStyleId;try{const o=yield this.modules.styleManager.waitForStyle(i),r=yield 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()),a=n.processFont(r);return this.prepareFontAtlas(e,t,a),this.modules.workers.labeling.appendFont(e,a.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:r,height:a,glyphData:l}=i;this.fontGlyphs[e]||(this.fontGlyphs[e]={});for(const d in l)this.fontGlyphs[e][d]=l[d];const c=new w(new Uint8Array(o),{size:[r,a],magFilter:w.LinearFilter,minFilter:w.LinearFilter,format:w.AlphaFormat,premultiplyAlpha:!1,flipY:!1});this.fontTextures.set(e,t,c),this.state.needLabeling=!0}loadPng(e,t,i,o){return K(this,null,function*(){const r=t.rasterSets.byIndex[i],a=r.rasters[o],l=this.textures[a.atlasIndex];let c="";if(r.type===n.RasterSetType.Unique){const d=r.id;r.url?c=n.getSizeDependentImageUrl(r.url,a.w,a.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:a.w.toString(),height:a.h.toString(),regionId:String(r.regionId)})}else if(r.type===n.RasterSetType.Static){const d=t.icons[r.name];if(!d){console.error(`There is no appropriate icon config in the style for raster set: "${r.name}"`),this.failedRasters[t.id].add(e);return}c=n.getUrlForIconMapIcon(d.url,t,n.getSubdomainFromString(this.state.subdomains,r.name))}this.modules.workers.parser.prepareAtlas(c).then(d=>K(this,null,function*(){if(d){if(d.isBitmap){if((d.data[0].width!==a.w||d.data[0].height!==a.h)&&r.type===n.RasterSetType.Static){if(a.w<=0||a.h<=0)return;const _=document.createElement("canvas");_.width=a.w,_.height=a.h,_.getContext("2d").drawImage(d.data[0],0,0,_.width,_.height),l.subImage(_,a.x,a.y)}else l.subImage(d.data[0],a.x,a.y);this.modules.renderer.addRerenderEvent()}else Rn(d.data[0]).then(_=>{l.subImage(_,a.x,a.y),this.modules.renderer.addRerenderEvent()});this.loadedRasters[t.id].add(e),r.isReady=!0}else this.failedRasters[t.id].add(e)}))})}loadSvg(e,t,i){return K(this,null,function*(){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 r=t.icons[o.name];if(!r){console.error(`There is no appropriate icon config in the style for raster set: "${o.name}"`),this.failedRasters[t.id].add(e);return}const a=n.getUrlForIconMapIcon(r.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(a,{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=yield l,{url:d,revokeURL:_}=Ja(c),u=yield Qa(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 Pg{constructor(e,t,i,o,r,a,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=r,this.selectedIds=a,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=zg(e,this.modules),this.updateMinAndMaxStyleZoom(this.objects),this.status="generated",this.ready=!0,this.cache.add(this.key,this)}break}}}getIdentifyIds(){var e;return(e=this.processResponse)==null?void 0:e.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:r,offset:a}}}=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:a,matrix:r};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=>{var r;const o=this.modules.styleManager.getStyleLayer(i.attributes.styleId,i.attributes.layerId);return(o==null?void 0:o.type)==="dem"?1/0:(r=o==null?void 0:o.minzoom)!=null?r:-1/0})))),this.maxStyleZoom=Math.max(...e.map(t=>Math.max(...t.children.map(i=>{var r;const o=this.modules.styleManager.getStyleLayer(i.attributes.styleId,i.attributes.layerId);return(o==null?void 0:o.type)==="dem"?-1/0:(r=o==null?void 0:o.maxzoom)!=null?r:1/0}))))}}function Bg(s,e,t,i,o){const r=e.join("|");return`model=${s}_sId=${t}_sRev=${i}_mRev=${o}_sel=${r}`}function zg(s,e){var r,a,l;const t=new Dl(s,e),i=[],o=Fl((l=(a=(r=t.children[0])!=null?r:t.identifyChildren[0])!=null?a:t.depthTestChildren[0])!=null?l:t.shadowChildren[0]);return o&&["children","identifyChildren","depthTestChildren","shadowChildren"].forEach(c=>{var u;const d=(u=t.modelMatrices.get(0))!=null?u:n.create$2();n.copy(d,o),t.modelMatrices.set(0,d);let _=t[c].length;for(;_--;){const h=t[c][_],f=Fl(h);if(!f||n.exactEquals(d,f))continue;let m=i.find(p=>{const v=p.modelMatrices.get(0);return v?n.exactEquals(v,f):!1});m||(m=new Dl([],e),m.modelMatrices.set(0,n.copy(n.create$2(),f)),i.push(m)),m[c].push(h),h.tile=m,t[c].splice(_,1)}}),[t,...i]}function Fl(s){if(s&&"matrix"in s.attributes)return s.attributes.matrix}class Dl 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 Rg{constructor(e,t,i,o,r,a){var l;this.modules=e,this.mapState=t,this.cache=i,this.regionId=o,this.metatileHash=r,this.sourceModel=a,this.revision=0,this.texturesLoaded=!1,this.textures=[],this.readiness=0,this.id=a.id,this.attributes=(l=a.attributes)!=null?l:{},this.readinessTickerName=`model-readiness-${this.id}`,this.ids=e.identifier.getIdScope(n.DEFAULT_ID_SCOPE)}update(){var e,t;(e=this.currentMod)!=null&&e.useful&&this.currentMod.update(),(t=this.newMod)!=null&&t.useful&&this.newMod.update(),n.update(this.readinessTickerName,{step:(i,o)=>this.readiness=o},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 w(t,{flipY:!1})),this.texturesLoaded=!0,this.startReadinessTicker()):Promise.all(e.data.map(t=>Rn(t))).then(t=>{this.textures=t.map(i=>new w(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 r=Bg(this.id,e,t,i,o),a=this.cache.get(r);a?(this.newMod=a,this.newMod.useful=!0):this.newMod=new Pg(this.modules,this.mapState,this.cache,this,r,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 Fg{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){var i;return(i=this.models.get(e))==null?void 0:i.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){var i;return((i=this.models.get(e))==null?void 0:i.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),r=Math.min(t.sourceModel.maxZoom,i.maxStyleZoom),{styleZoom:a}=this.mapState;if(!(a<o||a>=r))return{minStyleZoom:o,maxStyleZoom:r,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:r}=t.sourceModel;if(e<o||e>=r)return;const a=this.mapState.styleState._activeFloorIds,l=t.attributes.db_hidden_by_plan_id;if(l&&a.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(r=>this.modules.tileManager.removeObject(r)),e=!0)}),t.forEach((i,o)=>{this.displayedMods.has(o)||(i.objects.length&&i.objects.forEach(r=>this.modules.tileManager.addObject(r)),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(r=>{if(!r.fileName){console.error(`ZBM source "fileName" is empty. Failed to load model by url: ${e}`);return}const a=new Rg(this.modules,this.mapState,this.cache,t,i,r);this.models.set(a.id,a)}),this.loadedModelsInfo.add(t)}).catch(o=>{this.loadedModelsInfo.add(t),console.error(o)}))}updateObjectsVisibility(){const e=this.ids;this.models.forEach(t=>{var r;const i=((r=this.getVisibleModelData(t.id))==null?void 0:r.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 Dg{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=Ol(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:r}=i,a=this.modules.map.state;this.isGenerating=!0,this.modules.workers.parser.generatePersonalPoi(t,o,r,window.devicePixelRatio,this.ids.getSelected(),a.handyStyleId,a.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:r,identifyIds:a},styleId:l}=t;this.modules.labeler.removeLabels("ppoi"),r.length&&this.modules.labeler.addLabels("ppoi",n.LabelSource.PersonalPoi,[{metatileHash:o,labels:r,styleId:l}]),this.identifyDataChunk={metatileHash:o,ids:a},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=Ol(t,e))}}function Ol(s,e){return`ppoi_${s}_${e.join("|")}`}let Ms=(At=class extends n.Evented{constructor(e,t){super(),this.fogFactorBreakpoint=.4,this.demElevation=0,this.demTilesRevision=NaN,this.options=n.applyDefaults(t,At.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=Og(this.options),this.isHidden=!0,this.targetOpacity=0,this.modules.layers.addLayer(this),this.mapState=e.state,this.rounder=Ng(!this.options.disableRounding);let{offset:o}=this.options;const{labeling:r}=this.options;r.type!=="none"&&(r.offset!==void 0&&(o=r.offset),this.modules.labeler.addLabelBox(this.labelKey,{id:this.uniqId,width:r.width,height:r.height,position:this.position.normalizedValue,offset:o,labelingGroup:this.getLabelingGroup(),parentPoiId:r.type==="pinnedToPoi"?r.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(){var e;this.demElevation=(e=this.modules.demManager.getElevation(this.position.normalizedValue))!=null?e:0,this.demTilesRevision=this.modules.demManager.getTilesRevision()}nearCenterScreenPosition(){var c;const e=this.modules.demManager,t=this.mapState;let i=0,o=0;if(t.demMode){const d=e.getTilesRevision();this.demTilesRevision!==d&&this.updateDemElevation(),i=(this.demElevation-((c=t.elevation)!=null?c:0))*t.elevationScale}this.options.floorId&&(o=this.modules.floorManager.getFloorObjectElevation(this.options.floorId,!0));const r=this.mapState.visibleMapReplicas.map(d=>{const _=[this.position.normalizedValue[0]+n.worldSize*d,this.position.normalizedValue[1],this.position.normalizedValue[2]+i*n.MAP_POINTS_IN_METER+o];return n.Mercator.toGeo(_,_),this.modules.camera.project(_,!0)}),a=r.map(d=>Math.abs(this.mapState.size[0]/2-(isNaN(d[0])?-1/0:d[0]))),l=a.findIndex(d=>d===Math.min(...a));return r[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,r=(this.position.normalizedValue[1]-i[1])/t,a=Math.sqrt(qe(o,2)+qe(r,2)),l=e[1]-e[0];return n.clamp((a-e[0])/l,0,1)<this.fogFactorBreakpoint}isInvolvedInLabeling(){return this.options.labeling.type==="full"||this.options.labeling.type==="pinnedToPoi"}},At.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:""},At);function Og(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 Ng(s){return s?kg:Ug}const kg=(s,e,t,i)=>{const o=Math.round(e),r=Math.round(t),a=o-e,l=r-t;s[0]=e+i*a,s[1]=t+i*l},Ug=(s,e,t)=>{s[0]=e,s[1]=t},Hg="#0085a0",Gg="#ffffff",Vg=4,jg=1,Zg=2,$g=1.5,Wg=2.8,Nl=6,Xg=!0,Kg=17.1,Es=n.entranceAnimation.iterationCount,Is=n.create$1();class Cs extends Ye{constructor(e,t){var p,v,x,g,y,b,S,T,z,E,P,k,R;super(e,{interactive:(p=t.interactive)!=null?p:!1}),this.options=t,this.vectors=this.options.coordinates.map(C=>C.map(F=>n.Mercator.fromGeo(F))),this.bouncePosition=0,this.growPosition=1;const{tileManager:i,dynamicStyle:o,collector:r,layers:a}=this.modules,l=(v=this.options.animate)!=null?v:Xg;let c;if(l&&!this.mapState.disableLayerAnimation){const C=(x=this.options.iterationCount)!=null?x:Es;C>1?c={type:"repeat",tipMovementAmplitude:this.options.tipMovementAmplitude||Nl,iterationCount:C}:C===1&&(c={type:"appearance",tipMovementAmplitude:this.options.tipMovementAmplitude||Nl})}const d=n.makeHandyStyleLayer({type:"arrow",id:`dynamic-entrance-${this.uniqId}`,interactive:this.interactive,minzoom:(g=this.options.minZoom)!=null?g:Kg,maxzoom:this.options.maxZoom,style:{color:(y=this.options.color)!=null?y:Hg,strokeColor:(b=this.options.borderColor)!=null?b:Gg,lineWidth:(S=this.options.width)!=null?S:Vg,strokeWidth:(T=this.options.borderWidth)!=null?T:jg,tipWidth:(z=this.options.wingWidthMultiplier)!=null?z:$g,tipHeight:(E=this.options.tipHeightMultiplier)!=null?E:Wg,roundingRadius:(P=this.options.roundingRadius)!=null?P:Zg,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,this.interactive?"0":"");n.runPrecomputes(d,h);for(let C=0;C<this.vectors.length;C++){const F=this.vectors[C],se=this.getVertices(F,_);h.id=String(C),n.generateSafely({collector:r,generator:n.ArrowGenerator.generate,args:[o.getStyle().id,d,h,se]})}const f=r.getAccumulatedData(),m=new n.TileObject("dynamicObject",f.data,this.modules,this.mapState,_.coords,this);this.tileObjects.push(m),i.addObject(m),this.interactive&&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:(C,F)=>this.bouncePosition=F,complete:()=>{this.bounceTickerUpdate=void 0}},this.mapState),this.growTickerUpdate=n.update.bind(null,this.growTickerId,{step:(C,F)=>this.growPosition=F,complete:()=>{this.growTickerUpdate=void 0}},this.mapState),n.start(this.bounceTickerId,{easing:n.entranceAnimation.bounceType},this.mapState,-1,0,n.entranceAnimation.bounceTime,(k=this.options.iterationCount)!=null?k:Es,{layerId:this.layerId,styleId:o.getStyle().id}),n.start(this.growTickerId,{easing:n.entranceAnimation.growType},this.mapState,0,1,n.entranceAnimation.growTime,(R=this.options.iterationCount)!=null?R:Es,{layerId:this.layerId,styleId:o.getStyle().id})):(this.bouncePosition=0,this.growPosition=1),a.addLayer(this),r.reset(),this.modules.renderer.addRerenderEvent(),this.interactive&&this.modules.identifier.resetCache()}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.interactive&&this.modules.identifier.resetCache(),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 r=0;r<e.length;r++)n.mapPointToTilePoint(Is,e[r],t),i[r]=Is[0],o[r]=Is[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 qg{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 Ye)}getHtmlMarkers(){return this.layers.filter(e=>e instanceof Ms)}entranceAnimationFinished(){return this.layers.every(e=>e instanceof Cs?!e.entranceAnimationInProgress():!0)}}const kl=()=>"",Yg=[.5,.5];class Qg{constructor(e){this.loadingCounter=0,this.isIdle=()=>this.loadingCounter===0,this.modules=e,this.cache={}}getRasterSet(e,t,i,o){return K(this,null,function*(){const r=this.getKey(e,i,o),a=this.getFromCache(r,t);if(a)return a;const l=yield this.loadIcon(e,t,i,o);return l&&this.storeInCache(l,r,t),l})}clear(){this.cache={}}decreaseLoadingCounter(){this.loadingCounter=Math.max(this.loadingCounter-1,0)}loadIcon(e,t,i,o){return K(this,null,function*(){const{dynamicStyle:r,workers:a,assetManager:l}=this.modules;let c=e;this.loadingCounter++,t&&(c=yield this.loadImageForTransformer(e).then(_=>t(_)).catch(()=>e));const d=yield 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]]:Yg,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]}]);r.appendRasterSet(h),a.labeling.addNewRasterSets(r.getStyle().id,[h]);const f=new Uint16Array(3);return f[0]=u[0],f[1]=u[1],f[2]=h.index,a.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(r.getStyle().id,u,[Aa(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||kl)}storeInCache(e,t,i){this.cache[t]||(this.cache[t]=new Map),this.cache[t].set(i||kl,e)}getKey(e,t,i){const o=t!==void 0?`${t[0]},${t[1]}`:"",r=i!==void 0?`${i[0]},${i[1]}`:"";return`${e}_${o}_${r}`}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 Ul={trafficOn:!1,parkingOn:!1,navigatorOn:!1,immersiveRoadsOn:!1,floorStackOn:!1,terrainEnabled:!1,graphicsPreset:ti()?"light":"immersive",_activeFloorIds:[],_activeFloorBuildingIds:[],_activeFloorIsMetro:!1,_floorHeight:n.DEFAULT_FLOORS_FLOOR_HEIGHT,_activeFloorsLevel:0,_backgroundFloorIds:[],_customUserTimeOffset:0};let Zn=!1;function Jg(){return I({},Ul)}function $n(s,e){return s=I({},s),(e==null?void 0:e.immersiveRoadsOff)===!0?(Zn=!0,s.immersiveRoadsOn=!1):Zn&&(s.immersiveRoadsOn=Zn,Zn=!1),s.graphicsPreset&&s.graphicsPreset!=="light"&&ti()&&(console.warn(`"${String(s.graphicsPreset)}" graphicsPreset is not supported in deprecated system. Using "light" instead.`),s.graphicsPreset="light"),I(I({},Ul),s)}function Hl(s,e,t){const i=ce(I(I({},s),e),{_activeFloorIds:s._activeFloorIds,_activeFloorBuildingIds:s._activeFloorBuildingIds,_activeFloorIsMetro:s._activeFloorIsMetro,_floorHeight:s._floorHeight,_backgroundFloorIds:s._backgroundFloorIds,_activeFloorsLevel:s._activeFloorsLevel});return $n(i,t)}function Gl(s,e=[],t=[],i=!1,o=[],r=0){return ce(I({},s),{_activeFloorIds:e,_activeFloorBuildingIds:t,_activeFloorIsMetro:i,_floorHeight:i?n.DEFAULT_FLOORS_METRO_FLOOR_HEIGHT:n.DEFAULT_FLOORS_FLOOR_HEIGHT,_backgroundFloorIds:o,_activeFloorsLevel:r})}const Vl=["default","metro"],Ls="floorStackTicker",Ag=500,Wn={MAX_DISTANCE_METERS:500,VERY_CLOSE_DISTANCE_METERS:500,DISTANCE_WEIGHT_MULTIPLIER:3,VERY_CLOSE_BONUS:1.5};class ey{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 visibleComplexIsMetro(){var e;return((e=this.displayedComplex)==null?void 0:e.mode)==="metro"}get isStackEnabled(){return!this.state.demMode&&(this.state.styleState.floorStackOn&&this.floorHeight>0||this.state.styleState._activeFloorIsMetro)}get maxFloorOffset(){var t;const e=(t=this.state.styleState._floorHeight)!=null?t:0;return Math.floor(n.floors.maxStackHeight/e)}get floorHeight(){var i;const e=(i=this.state.styleState._floorHeight)!=null?i: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 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 r=this.repository.descriptors[i].get(o);return e.linked_floors_ids.some(a=>r==null?void 0:r.floorIds.includes(a))}).forEach(o=>t.push(o)),t}hasActiveFloorOrMetro(){var e,t;return((e=this.displayedComplex)==null?void 0:e.mode)==="metro"||((t=this.displayedComplex)==null?void 0:t.mode)==="floor"&&this.isStackEnabled}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((r,a)=>{let l=this.repository.floorIdsToObjectIds.get(a);l===void 0&&(l=new Set,this.repository.floorIdsToObjectIds.set(a,l));for(const c of r)l.add(c);this.loadFloor(a,e,t)})}changeFloorNumber(e,t){var l,c;let i="building";const o=this.viewport.default.current,r=this.viewport.metro.current;let a=o||r;if(typeof t=="number"&&(i="floor"),typeof t=="number"&&r&&r.buildings.includes(e)&&(a=r,i="metro"),t==="metro"&&r&&(r.id===e||r.buildings.includes(e)||(o==null?void 0:o.id)===e||o!=null&&o.buildings.includes(e))&&(a=r,e=a.id,i="metro",t=0),a&&(a.id===e||a.buildings.includes(e))){if(this.needUpdate=!0,i==="metro"&&typeof t=="number"){if(!r||t<0||t>=r.floors.length)return;a.mode="metro",o&&o.mode==="floor"&&(o.mode="metro",this.modules.map.emit("floorcomplexhide",{id:o.id})),this.displayedComplex!==a&&this.modules.map.emit("floorcomplexshow",{id:a.id,mode:"metro",currentFloor:t,floorNames:a.floors.map(d=>d.name),firmsToFloorIndexMap:a.firmsToFloorIndexMap}),this.displayedComplex=a,this.setFloorIdx(t),a.selectedFloorIdx=t,this.updateStackState(),this.modules.map.emit("floorcomplexlevelchange",{id:e,floorIndex:t,floorName:a.floors[t].name,floorMode:"metro"})}else if(i==="building"){r&&(r.mode="floor"),a.mode="building";const d=(l=this.displayedComplex)==null?void 0:l.id;this.displayedComplex=null,d&&this.modules.map.emit("floorcomplexhide",{id:d})}else if(i==="floor"&&typeof t=="number"){if(t<0||t>=a.floors.length)return;this.setFloorIdx(t),a.selectedFloorIdx=t,r&&r.mode==="metro"&&(r.mode="floor",this.modules.map.emit("floorcomplexhide",{id:r.id})),this.displayedComplex!==a&&!((c=this.displayedComplex)!=null&&c.buildings.includes(a.id))&&this.modules.map.emit("floorcomplexshow",{id:a.id,mode:"floor",currentFloor:t,floorNames:a.floors.map(({name:d})=>d),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,floorMode:"floor"})}}}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!=null?e:[]),this.needUpdate=!0}isVisibleFloorObject(e,t){return this.displayedComplex?this.state.styleState._activeFloorIds.includes(e)||t==="all-floors"&&this.state.styleState._backgroundFloorIds.includes(e):!1}isVisibleFloorStackObject(e){if(!this.isStackEnabled||!this.displayedComplex||this.activeFloorIdx===void 0)return!1;let t=!1;for(const r of this.hiddenBuildingIds){if(t)break;const a=this.repository.descriptors.default.get(r);t=!!(a!=null&&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){var a,l;if(!this.isStackEnabled||!this.stack.offsets.has(e))return 0;let i=this.stack.offsets.get(e);if(((a=this.displayedComplex)==null?void 0:a.mode)==="metro"){if(i+=this.getFloorsStackShift(),i===0)return 0}else if(i<=0)return 0;if(((l=this.displayedComplex)==null?void 0:l.mode)!=="metro"&&i>this.maxFloorOffset)return this.floorHeight*this.maxFloorOffset;const o=this.floorHeight*i;return 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}}getFloorsStackShift(){var o,r,a;if(this.displayedComplex&&this.activeFloorIdx&&((o=this.displayedComplex.floors[this.activeFloorIdx])==null?void 0:o.level)>0)return 0;const e=this.stack.offsets.size,t=1+(Array.isArray(this.state.styleState._backgroundFloorIds)?this.state.styleState._backgroundFloorIds.length:0),i=(a=(r=this.displayedComplex)==null?void 0:r.floors.filter(l=>l.level>0).length)!=null?a:0;return e-t-i}getPlanLevels(){return this.isStackEnabled?Object.fromEntries(this.stack.offsets):{}}getFloorStackObjectHeight(e){return!this.isStackEnabled||this.displayedComplex.floors.findIndex(i=>{var o;return i.id===e||((o=i.linked_floors_ids)==null?void 0:o.includes(e))})<this.activeFloorIdx-1?1:this.stack.readiness}_update(){this.pendingUpdateCall=!1;const e=this.displayedComplex;this.updateViewport();const t=!!(this.viewport.default.out&&this.viewport.default.in&&this.viewport.default.in.buildings.includes(this.viewport.default.out.id));this.viewport.default.out?t||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&&(!t&&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 i=null;const o=this.viewport.default.in||this.viewport.default.current,r=this.viewport.metro.in||this.viewport.metro.current,a=!t&&this.viewport.default.in||this.viewport.metro.in||this.viewport.default.out&&this.viewport.metro.current||this.viewport.metro.out&&!this.viewport.default.out&&o;if(o){const l=this.shouldIgnoreFloorState?"building":o.mode;i={id:o.id,mode:l==="floor"?"floor":"building",currentFloor:o.selectedFloorIdx,floorNames:o.floors.map(c=>c.name),firmsToFloorIndexMap:o.firmsToFloorIndexMap},this.viewport.metro.current&&((this.shouldIgnoreFloorState?"building":this.viewport.metro.current.mode)==="metro"&&(i.mode="metro"),i.metro={id:this.viewport.metro.current.id,floorNames:this.viewport.metro.current.floors.map(d=>d.name),currentFloor:this.viewport.metro.current.selectedFloorIdx})}if(r){if(i){i.metro={id:r.id,floorNames:r.floors.map(c=>c.name),currentFloor:r.selectedFloorIdx};for(const c in r.firmsToFloorIndexMap)i.firmsToFloorIndexMap[c]=r.firmsToFloorIndexMap[c];r.mode==="metro"&&(i.mode="metro",i.currentFloor=r.selectedFloorIdx)}else i={id:r.id,mode:"building",currentFloor:r.selectedFloorIdx,floorNames:[],firmsToFloorIndexMap:r.firmsToFloorIndexMap,metro:{id:r.id,floorNames:r.floors.map(c=>c.name),currentFloor:r.selectedFloorIdx}};(this.shouldIgnoreFloorState?"building":r.mode)==="metro"&&(i.mode="metro")}i&&a&&this.modules.map.emit("floorcomplexin",i),this.displayFloorComplex(),this.needUpdate=!1,this.displayedComplex!==e&&(this.needUpdate=!0)}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(r=>{if(r.ok===!1)throw new Error(r.statusText);return r.json()}).then(r=>{var _;let a=r.default_floor_idx,l="default";"is_metro"in r&&r.is_metro&&(a=r.default_metro_floor_idx,l="metro");const c=r.floors.reduce((u,h,f)=>(h.id&&(u[h.id]=f),u),{}),d={id:e,regionId:t,metatileHash:i,center:r.center,bound:r.bound,defaultFloor:a,selectedFloorIdx:a,mode:"floor",floors:r.floors,floorIds:r.floors.map(u=>u.id).filter(Boolean),buildings:r.linked_buildings_ids?r.linked_buildings_ids.concat(e):[e],firmsToFloorIndexMap:Object.entries((_=r.firm_id_to_floor_id)!=null?_:{}).reduce((u,[h,f])=>(u[h]=c[f],u),{})};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)=>{var r;const o=i-this.displayedComplex.defaultFloor;t.id&&this.stack.offsets.set(t.id,o),o>e&&(e=o),(r=t.linked_floors_ids)==null||r.forEach(a=>{this.stack.offsets.set(a,o)})}),this.stack.maxOffset=e}updateStyleState(){var d,_;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=Gl(e,[],[],!1,[],0));return}const t=new Set,i=new Set,o=new Set(this.state.styleState._activeFloorIds),r=new Set(this.state.styleState._activeFloorBuildingIds),a=e._activeFloorIsMetro===!0,l=this.displayedComplex;if(!l||this.activeFloorIdx===void 0||l.mode==="building")return;const c=l.floors[this.activeFloorIdx];if(c&&(c.id&&t.add(c.id),(d=c.linked_floors_ids)==null||d.forEach(u=>{t.add(u)}),this.hiddenBuildingIds.forEach(u=>i.add(u)),jl(o,t)||jl(r,i)||a!==(this.displayedComplex.mode==="metro"))){let u=new Set;if(this.displayedComplex.mode==="metro"&&this.displayedComplex.floors.length>1){const f=(_=this.displayedComplex.floors.find(m=>m.id===c.id))==null?void 0:_.level;f!==void 0&&(u=new Set(this.displayedComplex.floors.filter(m=>m.id!==void 0&&m.level<f).map(m=>m.id)))}const h=c.level;this.state.styleState=Gl(e,Array.from(t),Array.from(i),this.displayedComplex.mode==="metro",Array.from(u),h)}}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 r=this.ids.floor.getHidden(),a=n.intersection$1(i,r);this.ids.default.hide(Array.from(a),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(Ls,{step:(e,t)=>this.stack.readiness=t},this.state)}setFloorIdx(e){var t;this.prevActiveFloorIdx=this.activeFloorIdx,this.activeFloorIdx=e,!Number.isNaN(e)&&this.isStackEnabled&&((t=this.displayedComplex)==null?void 0:t.mode)!=="metro"&&this.prevActiveFloorIdx!==void 0&&this.activeFloorIdx>this.prevActiveFloorIdx?(this.stack.readiness=0,n.start(Ls,{easing:"easeOutQuint"},this.state,0,1,Ag,1)):(this.stack.readiness=1,n.stop(Ls,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:r,viewport:a,padding:l,cameraConfig:c,globeMode:d}=this.state,_=new n.Camera({center:t,zoom:i,rotation:o,size:[Math.floor(r[0]*(1-n.floors.viewportPadding)),Math.floor(r[1]*(1-n.floors.viewportPadding))],styleState:{},pitch:0,viewport:a,padding:l,cameraConfig:c,globeMode:d}),u=_.getViewportVertices().map(m=>[m[0],m[1]]),h=ty(u),f=[[0,0],[0,0],[0,0],[0,0]];Vl.forEach(m=>{if(m==="default"&&!this.isDefaultEnabled||m==="metro"&&!this.isMetroEnabled)return;const p=this.viewport.index[m].search(h);let v,x;for(const g of p){if(this.allowedFloors.size>0&&!this.allowedFloors.has(g.complex.id)||!this.state.metro3dVisible&&m==="metro"&&g.complex.floors.length>1)continue;const y=g.complex.bound;if(iy(_.position,y)){if(v){const T=Zl(y);T<v.complexArea&&(v.complex=g.complex,v.complexArea=T)}else v={complex:g.complex,complexArea:Zl(y)};continue}f[0][0]=y.min[0],f[0][1]=y.min[1],f[1][0]=y.max[0],f[1][1]=y.min[1],f[2][0]=y.max[0],f[2][1]=y.max[1],f[3][0]=y.min[0],f[3][1]=y.max[1];const b=ny(f,u);if(b.length<3)continue;const S=sy({complex:g.complex,cameraPosition:_.position,intersectionPolygon:b});x?x.score<S&&(x.complex=g.complex,x.score=S):x={complex:g.complex,score:S}}v?e[m]=v.complex:x&&(e[m]=x.complex)}),Vl.forEach(m=>{const p=this.viewport[m].current,v=e[m];this.shouldIgnoreFloorState&&v&&v!==p&&(!this.displayedComplex||!this.displayedComplex.buildings.includes(v.id))&&(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(){var i;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.updateStackState(),this.setFloorIdx(t.selectedFloorIdx),this.modules.map.emit("floorcomplexshow",{id:t.id,mode:"metro",currentFloor:t.selectedFloorIdx,floorNames:t.floors.map(o=>o.name),firmsToFloorIndexMap:t.firmsToFloorIndexMap}),this.updateStyleState()}else if(e&&e.mode==="floor"){if(e===this.displayedComplex||(i=this.displayedComplex)!=null&&i.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(o=>o.name),firmsToFloorIndexMap:e.firmsToFloorIndexMap}),this.updateStyleState()}}}function jl(s,e){if(s.size!==e.size)return!0;for(const t of s)if(!e.has(t))return!0;return!1}function ty(s){let e=s[0][0],t=s[0][1],i=e,o=t;for(let r=1;r<s.length;r++){const[a,l]=s[r];a<e?e=a:a>i&&(i=a),l<t?t=l:l>o&&(o=l)}return{minX:e,minY:t,maxX:i,maxY:o}}function iy(s,e){return s[0]>=e.min[0]&&s[0]<=e.max[0]&&s[1]>=e.min[1]&&s[1]<=e.max[1]}function Zl(s){return(s.max[0]-s.min[0])*(s.max[1]-s.min[1])}function ny(s,e){let t=s;for(let r=0;r<e.length;r++){const a=e[r],l=e[(r+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,a,l)?(i(_,a,l)||t.push(o(_,u,a,l)),t.push(u)):i(_,a,l)&&t.push(o(_,u,a,l))}}return t;function i(r,a,l){return(l[0]-a[0])*(r[1]-a[1])>(l[1]-a[1])*(r[0]-a[0])}function o(r,a,l,c){const d=a[1]-r[1],_=r[0]-a[0],u=d*r[0]+_*r[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?a:[(f*u-_*m)/p,(d*m-h*u)/p]}}function oy(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 sy(s){const e=Math.sqrt(qe(s.complex.center[0]-s.cameraPosition[0],2)+qe(s.complex.center[1]-s.cameraPosition[1],2)),t=e/(Wn.MAX_DISTANCE_METERS*n.MAP_POINTS_IN_METER),i=Math.max(0,1-t),o=e<Wn.VERY_CLOSE_DISTANCE_METERS*n.MAP_POINTS_IN_METER?Wn.VERY_CLOSE_BONUS:1;return oy(s.intersectionPolygon)*o*(1+i*Wn.DISTANCE_WEIGHT_MULTIPLIER)}class ry{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"}]),this.metroDiffer=new n.Differ([{path:"visibleComplexIsMetro",type:"boolean"}])}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:ce(I({},t),{"--sum":n.getTotalMemory(t)}),gpu:ce(I({},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")):this.metroDiffer.check(this.modules.floorManager)&&this.modules.floorManager.visibleComplexIsMetro&&this.tileLayers.forEach(t=>t.updateViewport());for(const t of this.tileLayers)t.update();if(this.updateTickers(),e.collectStats){this.state.stats.tileCount=0,this.state.stats.viewportTileCount=0,this.state.stats.displayedTileCount=0;for(const t of this.tileLayers)this.state.stats.tileCount+=t.getTileCount(),this.state.stats.viewportTileCount+=t.getViewportTileCount(),this.state.stats.displayedTileCount+=t.getDisplayedTileCount();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 ay=(s,e,t,i,o)=>{n.start("labelingOpacity",{easing:e},s,t,i,o,1)},ly=n.update.bind(null,"labelingOpacity",{step:(s,e)=>s.labelingOpacity=e});function cy(s){return s?Object.keys(s).map(Number).sort((e,t)=>e-t):[]}function dy(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 _y=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 uy{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=_y(this.modules.workers.fnRegistry),this.setLabelingInterval(n.labeling.interval)}disableThrottleUpdateOnce(){this.useThrottleUpdate=!1}update(){ly(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.enrichWithElevation(i,e),this.worker.appendLabels(e,t,i,this.state.styleState,this.state.styleZoom),this.alwaysActiveLabelKeys.push(e),this.state.needLabeling=!0}addTileLabels(e,t,i){this.enrichWithElevation(i,e),this.worker.appendLabels(e,t,i,this.state.styleState,this.state.styleZoom),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:ce(I({},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 a=n.getTileBounds(e),l=qe(2,e[2]),c=a.min[0]<-n.HALF_WORLD_SIZE,d=a.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:a,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(a),cameraConfig:this.state.cameraConfig})),r=dy(this.state.styleZoom,this.state.cityCommPoiLabeling);this.worker.processLabels(i,this.alwaysActiveLabelKeys,o,window.devicePixelRatio,this.modules.floorManager.getActiveFloorHiddenIds(),I(I({},n.labeling.commercialMargins),r),this.skipHysteresisInNextLabeling,this.modules.floorManager.getPlanLevels()).then(a=>{this.survivedLabelBoxes.clear(),this.labelTiles.forEach(h=>{this.modules.tileManager.removeObject(h),h.clean(this.state)}),this.labelTiles.length=0;const l=[];a.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&&a.some(({collectorOutput:h})=>h.data.length>0)&&(c.firstlabeling=performance.now()-c.start);const{animationTime:d,animationType:_,interval:u}=n.labeling;ay(this.state,_,0,1,Math.min(d,u)),this.modules.renderer.addRerenderEvent(),a[0].labels&&e[2]>=0&&this.modules.labelsDebug.drawLabels(a[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 r=this.demKeys[t],a=i.getLabelsDemKey(e);if(a===void 0||a===r)return;i.enrichWithElevation(e),this.demKeys[t]=a}}}class hi{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=Ee(this.handler.container,e.clientX,e.clientY);return new $l(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=Ee(this.handler.container,e.clientX,e.clientY);return this.handler.modules.identifier.search("contextmenu",t,!0).then(i=>{ht("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 Xn(this.mouseDownPoint,this.handler)):this}returnToInitialState(){return this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionend",{target:"pitch/rotation"}),new st(this.handler)}}class $l{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,r=(i[1]-t[1])*n.zoom.mousePitchDelta;xt(e),e.disableRotationByUserInteraction||yi(e,e.rotation+o,{animate:!1}),e.disablePitchByUserInteraction||Ki(e,n.clamp(e.pitch+r,e.minPitch,e.maxPitch),{animate:!1}),this.mouseDownPoint=this.mouseMovePoint,this.handler.modules.renderer.addRerenderEvent()}processMouseMoveAction(e){return this.mouseMovePoint=Ee(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 Xn(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 st(this.handler)}}class Xn{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 st(this.handler)):this}processMouseMoveAction(e){const t=Ee(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 Wl(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=Ee(this.handler.container,e.clientX,e.clientY);xt(t),Et(t,i,{duration:n.zoom.animDuration,zoomPoint:t.keepCenterWhileUserZoomRotate?void 0:o}),this.handler.modules.renderer.addRerenderEvent()}}else{const t=Ee(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(()=>{ht("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 st(this.handler)}processKeyDownAction(e){return e.key==="Control"||e.key==="Meta"?(this.handler.modules.map.emit("interactionend",{target:"center"}),new hi("keyPrimary",this.mouseDownPoint,this.handler)):this}}class Wl{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 a=n.adjustGlobeDragSpeed(t.globeRatio,n.Mercator.toGeo(e.center));n.scale(i,i,a),n.scale(o,o,a)}const r=n.clone$1(e.center);n.add$1(r,r,i),n.sub$1(r,r,o),xt(e),Gt(e,r,{animate:!1}),this.dragStartPoint=this.mouseMovePoint,this.handler.modules.renderer.addRerenderEvent()}processMouseMoveAction(e){return this.mouseMovePoint=Ee(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 hi("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 st(this.handler)}}function Kn(s,e){if(!e.modules.layout.isActionWithCanvas(s))return;const t=hy(s,e.container);if(!t)return;const i=e.modules.identifier.searchSync(t);ht("touchmove",i,s,t,e.modules)}function hy(s,e){var i;const t=(i=s.changedTouches[0])!=null?i:s.touches[0];if(t)return Ee(e,t.clientX,t.clientY)}class Xl{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 fi(e,this.handler,!1)}processTouchMoveAction(e){return e.preventDefault(),this.touchMovePoints=_t(e.touches,this.handler.container),Kn(e,this.handler),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 st(this.handler)):new fi(e,this.handler,!1)}}class qn extends Xl{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]),r=i/o,a=e.zoom+Math.log(r)/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:a,rotation:d})),xt(e),Gt(e,_,{animate:!1}),Et(e,a,{animate:!1}),this.handler.mapState.disableRotationByUserInteraction||yi(e,d,{animate:!1}),this.touchStartPoints=this.touchMovePoints,this.handler.modules.renderer.addRerenderEvent()}}class Kl extends Xl{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]),a=(n.calcMidpoint(i[0],i[1])[1]-o[1])*n.zoom.mousePitchDelta;xt(e),Ki(e,n.clamp(e.pitch+a,e.minPitch,e.maxPitch),{animate:!1}),this.touchStartPoints=this.touchMovePoints,this.handler.modules.renderer.addRerenderEvent()}}class fi{constructor(e,t,i){this.handler=t,this.needClickOnTouchEnd=i,this.toZoomRotate=!1,this.touchStartPoints=_t(e.touches,this.handler.container),this.handler.mapState.userHasInteracted=!0,this.isTimerStarted=this.handler.dblClickTimer!==void 0,ut(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=_t(e.touches,this.handler.container),this}processTouchMoveAction(e){e.preventDefault();const t=_t(e.touches,this.handler.container);if(Kn(e,this.handler),!ut(e))return n.distance(this.touchStartPoints[0],t[0])<n.events.dragThreshold?(this.touchStartPoints=t,this):this.isTimerStarted?new ql(t[0],this.touchStartPoints[0],this.handler):this.handler.mapState.disableDragging?(this.touchStartPoints=t,this.needClickOnTouchEnd=!1,this):new Ps(t[0],this.touchStartPoints[0],this.handler);if(this.touchStartPoints.length<2)return this.processTouchStartAction(e);const i=n.create$6(),o=n.create$6();n.sub(i,t[0],this.touchStartPoints[0]),n.sub(o,t[1],this.touchStartPoints[1]);const r=n.dot$1(i,o);if(r>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 Ps(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 Kl(t,this.touchStartPoints,this.handler)}return r<0?new qn(t,this.touchStartPoints,this.handler):n.isNullVector(i)||n.isNullVector(o)?this.pitchWaitingTimer?this:this.toZoomRotate?(this.toZoomRotate=!1,new qn(t,this.touchStartPoints,this.handler)):(this.pitchWaitingTimer=window.setTimeout(()=>{this.toZoomRotate=!0,this.pitchWaitingTimer=void 0},n.events.pitchWaitingTime),this):new qn(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 st(this.handler)):(ut(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=_t(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),r=i.keepCenterWhileUserZoomRotate?void 0:e;xt(i),Et(i,o,{duration:n.zoom.animDuration,zoomPoint:r}),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(()=>{ht("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 st(this.handler)}}class Ps{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 a=n.adjustGlobeDragSpeed(t.globeRatio,n.Mercator.toGeo(e.center));n.scale(i,i,a),n.scale(o,o,a)}const r=n.clone$1(e.center);n.add$1(r,r,i),n.sub$1(r,r,o),xt(e),Gt(e,r,{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 fi(e,this.handler,!1)}processTouchMoveAction(e){e.preventDefault();const t=_t(e.touches,this.handler.container);return this.touchMovePoint=t[0],Kn(e,this.handler),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 st(this.handler)}}class ql{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),r=e.center;e.keepCenterWhileUserZoomRotate||n.add$1(r,e.center,n.getCenterCorrection(e,this.touchStartPoint,{zoom:o})),xt(e),Gt(e,r,{animate:!1}),Et(e,o,{animate:!1}),this.handler.modules.renderer.addRerenderEvent()}processTouchStartAction(e){return this.handler.modules.map.emit("interactionend",{target:"zoom/rotation"}),new fi(e,this.handler,!1)}processTouchMoveAction(e){e.preventDefault();const t=_t(e.touches,this.handler.container);return this.touchMovePointY=t[0][1],Kn(e,this.handler),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 st(this.handler)}}class st{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=Ee(this.handler.container,e.clientX,e.clientY);switch(e.button){case 0:if(e.ctrlKey||e.metaKey)return new hi("keyPrimary",t,this.handler);if(this.handler.modules.layout.isActionWithCanvas(e)){const i=this.handler.modules.identifier.searchSync(t);ht("mousedown",i,e,t,this.handler.modules)}return new Xn(t,this.handler);case 1:return new hi("auxiliary",t,this.handler);case 2:return new hi("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=Ee(this.handler.container,e.changedTouches[0].clientX,e.changedTouches[0].clientY),i=this.handler.modules.identifier.searchSync(t);ht("touchstart",i,e,t,this.handler.modules)}return new fi(e,this.handler,e.touches.length===1)}}class Yn{processAction(){return this}}class fy{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 Yn||(this.state=o)},this.state=new st(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 Yn)return;const{map:e}=this.modules;switch(this.container.classList.remove("mapgl-dragging"),this.container.classList.remove("mapgl-rotating"),this.state.constructor){case Xn:case Wl:case Ps:e.emit("interactionend",{target:"center"});break;case hi:case $l:e.emit("interactionend",{target:"pitch/rotation"});break;case ql:e.emit("interactionend",{target:"zoom/rotation"});break;case qn:case Kl:e.emit("interactionend",{target:"pitch/zoom/rotation"});break;case fi:{const t=this.state.getStartedInteractionTarget();e.emit("interactionend",{target:t});break}}this.state=new Yn}unblock(){this.state instanceof st||this.state instanceof Yn&&(this.state=new st(this))}}const my=new Set([n.UNIVERSE_REGION_ID]);class Bs extends Error{constructor(e,t){super(e),this.name="TrafficFetchMetaError",this.noRetry=t}}class py{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=I({},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:ce(I({},t),{"--sum":n.getTotalMemory(t)}),gpu:ce(I({},t),{"--sum":n.getTotalMemory(i)})}}fetch(e,t){e.sort((i,o)=>n.compare(this.mapState.center,i,o)).forEach(i=>vy(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,my)){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 Bs(`Request traffic timestamp error with status ${i.status}`,!1)}).then(i=>{var r,a;if(!i.length||((r=i[0])==null?void 0:r.time)===void 0||((a=i[0])==null?void 0:a.score)===void 0)throw new Bs(`Bad traffic timestamp and score response ${i.toString()}`,!0);let o=0;i.forEach(l=>o+=l.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=>{var o;!(i instanceof Bs)||!i.noRetry?this.fetchMetaRetryAttempt=(o=this.fetchMetaRetryAttempt)!=null?o:0:this.fetchMetaRetryAttempt=null,this.lastUpdateTime=Date.now(),this.isMetaLoading=!1,console.error(i)})}}function vy(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 gy{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 yy{constructor(e){this.loadingCounter=0,this.isIdle=()=>this.loadingCounter===0,this.modules=e,this.textureKeys=[],this.texturesMap=new Map}addTexture(e,t){return K(this,null,function*(){this.loadingCounter++;const i=yield Rn(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)}loadTexture(e,t){return K(this,null,function*(){this.loadingCounter++;const i=yield 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){var i;const t=this.textureKeys[e];return(i=this.texturesMap.get(t))==null||i.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:ce(I({},e),{"--sum":n.getTotalMemory(e)}),gpu:ce(I({},t),{"--sum":n.getTotalMemory(t)})}}decreaseLoadingCounter(){this.loadingCounter=Math.max(this.loadingCounter-1,0)}storeTexture(e,t){var f,m,p,v,x,g,y;const i=t==null?void 0:t.size,o=(f=t==null?void 0:t.pixelRatio)!=null?f:window.devicePixelRatio,r=(m=t==null?void 0:t.imagePadding)!=null?m:1;this.decreaseLoadingCounter();const a=e.getAttribute("src")||e.currentSrc,l=xy(a,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(b=>b*o),_=Aa(e,d);e.remove();const u=d.map(b=>b+2*r);if(!(t!=null&&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 w(void 0,{size:u,flipY:(p=t==null?void 0:t.flipY)!=null?p:!1,generateMipmaps:t==null?void 0:t.generateMipmaps,magFilter:w.LinearFilter,minFilter:(v=t==null?void 0:t.minFilter)!=null?v:w.LinearFilter,wrapS:(x=t==null?void 0:t.wrapS)!=null?x:w.defaultOptions.wrapS,wrapT:(g=t==null?void 0:t.wrapT)!=null?g:w.defaultOptions.wrapT,premultiplyAlpha:(y=t==null?void 0:t.premultiplyAlpha)!=null?y:w.defaultOptions.premultiplyAlpha});return this.modules.renderer.prepareTexture(h),h.subImage(_,r,r),_.remove(),this.texturesMap.set(l,h),this.textureKeys.push(l),this.modules.renderer.addRerenderEvent(),this.textureKeys.length-1}loadImage(e){return K(this,null,function*(){return new Promise(t=>{const i=new Image;i.crossOrigin="Anonymous",i.src=e,i.onload=()=>t(i),i.onerror=()=>t(void 0)})})}}function xy(s,e){const t=e!==void 0?`_${e[0]},${e[1]}`:"";return`${s}${t}`}const Yl=!0,Ql=!1,Jl=!1,Al=[0];class by{constructor(e){this.isLoading=!1,this.attempts=0,this.getKeyInfo=()=>K(this,null,function*(){return yield 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 r=()=>K(this,null,function*(){return Al.length>=this.attempts?(this.attempts&&(yield new Promise(a=>{this.lastTimeout=window.setTimeout(a,Al[this.attempts]*1e3)}),this.clearLastTimeout()),this.attempts++,fetch(o).then(a=>a.ok?a.json():r(),r)):(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=r().then(a=>{if(this.isLoading=!1,!a||!a.result||a.meta.code!==200)return{showCommPoi:Yl,hideCopyright:Jl,urbi:Ql,error:!0};const{showCommPoi:l,hideCopyright:c,urbi:d}=a.result.service.properties.public;return{showCommPoi:n.isNullish(l)?Yl:!!l,hideCopyright:n.isNullish(c)?Jl:!!c,urbi:n.isNullish(d)?Ql:!!d}})}}destroy(){this.clearLastTimeout()}clearLastTimeout(){this.lastTimeout!==void 0&&(clearTimeout(this.lastTimeout),this.lastTimeout=void 0)}}class wy{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 Sy={dead:!0,alive:!0,unused:!0,commercialDead:!1,commercialAlive:!1};class Ty{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=Sy){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"},r=new Int32Array(e),a={[n.BBoxType.Dead]:[],[n.BBoxType.Alive]:[],[n.BBoxType.Unused]:[],[n.BBoxType.CommercialAlive]:[],[n.BBoxType.CommercialDead]:[]};for(let d=0;d<r.length;d+=5){const _=r[d+4];a[_].push({x:r[d],y:r[d+1],width:r[d+2],height:r[d+3]})}this.clear();const l=window.devicePixelRatio,c=d=>{t.strokeStyle=o[d],a[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 My=n.create$1();class Ey{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=tu(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(Qe);const e=this.modules.renderer.getShaderProgram("sky");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||(mr(e,this.modules.map.state,this.modules),$(e,this.modules.map.state,this.modules),W(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(Qe);const e=this.modules.renderer.getShaderProgram("stars");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||pr(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(Qe);const e=this.modules.renderer.getShaderProgram("globeHaloBackground");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||bo(e,this.modules.map.state,this.modules),this.modules.renderer.bindVao(this.vao),this.modules.renderer.drawTrianglesFan(0,4)}renderGlobeHalo(){this.modules.renderer.applyGpuState(_u);const e=this.modules.renderer.getShaderProgram("globeHalo");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||bo(e,this.modules.map.state,this.modules),this.modules.renderer.bindVao(this.vao),this.modules.renderer.drawTrianglesFan(0,4)}isFogEnabled(){var r,a;if(this.modules.map.getFeatureFlag("fogOff")||!((r=this.envStyleLayer)!=null&&r.style.fogColor))return!1;const{styleZoom:e,styleState:t}=this.modules.map.state,i=n.makeBinderContext(e,t,[]),o=n.resolveColor((a=this.envStyleLayer)==null?void 0:a.style.fogColor,i);return o&&o.value[3]!==0}isSkyEnabled(){var r,a;if(this.modules.map.getFeatureFlag("skyOff")||!((r=this.envStyleLayer)!=null&&r.style.skyColor))return!1;const{styleZoom:e,styleState:t}=this.modules.map.state,i=n.makeBinderContext(e,t,[]),o=n.resolveColor((a=this.envStyleLayer)==null?void 0:a.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,My);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 a=0;a<e.length;++a){const l=e[a],c=n.getRandomValue(this.starsGenerationCtx,0,1);i[t*a]=l[0],i[t*a+1]=l[1],i[t*a+2]=l[2],i[t*a+3]=c}const o=this.modules.renderer.createBuffer(i),r=this.modules.renderer.getShaderProgram("stars");this.starsVao=iu(o,r)}updateFog(){const e=this.modules.camera;this.squaredDistMaxFog=qe(e.fogDistance*this.fogLimits[1],2)}}class Iy{constructor(e,t){this.mapState=e,this.mapModules=t,this.state={}}add(e,t=0,i=1,o=n.buildingAnimation.easing,r=n.buildingAnimation.duration){this.state[e]||(this.state[e]={tickerConfig:{start:t,end:i,duration:r,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){var t;return(t=this.state[e])==null?void 0:t.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:r,end:a,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,r,a,l,1)}i.readiness===1&&o!==1&&e.push(t)}}return e}buildTickerKey(e){return`gltf-${e}`}}const Cy=!0,zs="#ffffffff",Ly=0,Py=0,By=1,Rs=15,zy=n.tileZoomToSize(Rs)/n.MAP_POINTS_IN_METER,Qn=n.maxTilePoint/2,Ry=["coordinates","rotation","scale","offset"];let Fs=class Qs extends Ye{constructor(e,t){var T,z,E,P,k,R,C,F,se;super(e,{interactive:(T=t.interactive)!=null?T:!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=(z=t.interactiveOcclusion)!=null?z:Cy,this.disableAnimation=t.disableAnimation,this.linkedIds=t.linkedIds,this.planId=t.planId,this.tickerNames=new Map,this.generatedAsEcef=xe(this.mapState);const i=n.Mercator.fromGeo(t.coordinates);this.position={userValue:i,normalizedValue:n.normalizeMapPoint(i)};const{dynamicStyle:o,collector:r,tileManager:a,layers:l,assetManager:c}=this.modules,{ignoreGlobalLighting:d,colorTextureUvIndex:_,nearCameraFade:u,showRatio:h,playAnimation:f}=t,m=nc((E=t.rotation)!=null?E:Ly),p=(P=t.scale)!=null?P:By,v=oc((k=t.offset)!=null?k:Py,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",["object-attr","hovered"],[!0],((R=t.hover)==null?void 0:R.color)||zs,["match",["object-attr","selected"],[!0],((C=t.select)==null?void 0:C.color)||zs,t.color||zs]]},minzoom:t.minZoom,maxzoom:t.maxZoom,interactive:this.interactive,interactiveOcclusion:this.interactiveOcclusion}),!this.layer)return;(F=t.hover)!=null&&F.color&&(this.on("mouseover",this.switchToHoveredColor),this.on("mouseout",this.switchToNormalColor)),o.addLayer(this.layer,t.zIndex);const x=n.getTileCoordsByCenterAndZoom(this.position.normalizedValue,Rs),g=n.optionsToTileAttrs({model_src:t.modelSrc,linkedIds:t.linkedIds,db_plan_id:t.planId}),y=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,g,n.emptyFeatureAttrs,t.interactive?"0":"");n.runPrecomputes(this.layer,y),n.generateSafely({collector:r,generator:n.GltfModelGenerator.generateInstances,args:[o.getStyle(),this.layer,y,{x:[Qn],y:[Qn],z:[(se=this.position.userValue[2])!=null?se:0]},n.createTileInfo(x),NaN]});const b=r.getAccumulatedData(),S=new n.TileObject("dynamicObject",b.data,this.modules,this.mapState,x,this);S.ecefDataState=n.ecefDataStateFromBool(xe(this.mapState)),c.fillDataModelUrlMap(b.dataModelsUrls),this.modelId=b.dataModelsUrls[t.modelSrc],this.modelId!==void 0&&(c.loadModel(t.modelSrc,this.modelId,n.DYNAMIC_STYLE_ID,!0,this.layer,!1,()=>{this.status==="visible"&&(a.addObject(S),this.modules.renderer.addRerenderEvent(),this.linkedIds&&this.map.hideBuildingsById(this.linkedIds),this.updateIdentifier()),setTimeout(()=>this.emit("modelloaded"),0)}),this.tileObjects.push(S),t.interactive&&this.identifyIds.push(b.identifyIds),l.addLayer(this),r.reset(),this.status==="visible"&&this.hideLinkedObjects())}update(){super.update();const e=xe(this.mapState);if(e!==this.generatedAsEcef&&(this.applyTransformations(),this.generatedAsEcef=e),(this.generatedAsEcef||!this.visibleOnGlobe)&&this.updateGlobeVisibility(n.Mercator.toGeo(this.position.userValue)),!this.tickerNames.size)return;const t=[],i={};this.tickerNames.forEach((o,r)=>{n.update(o,{step:(a,l)=>{i[r]=l},complete:()=>{t.push(r)}},this.mapState)}),(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),t.forEach(o=>{this.tickerNames.delete(o)}),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 Qs&&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){var o,r;if(this.status==="destroyed"||!this.layer)return;this.stopTransformation();const t={};e.forEach(a=>{const l=Dy(a);if(!l)return;const{duration:c=0,easing:d="linear"}=a;t[l]={value:a[l],duration:c,easing:d}});const i={};for(const a in t){if(!Fy(a)||t[a]===void 0)continue;let l;if(a==="coordinates"?l=n.Mercator.fromGeo(t[a].value):a==="offset"?l=oc(t[a].value,(r=(o=t.coordinates)==null?void 0:o.value[1])!=null?r:n.Mercator.toGeo(this.position.userValue)[1]):l=t[a].value,!t[a].duration){i[a]=l;continue}const c=`dynamicGltfModel-${a}-${this.uniqId}`;let d,_;if(a==="coordinates")d=this.position.userValue,_=l;else{const u=[0,0,0];n.getTriple(this.appliedTransformations[a],u),d=u;const h=[0,0,0];n.getTriple(l,h),_=h}n.start(c,{easing:t[a].easing,renderAfterUpdate:this.needRerender},this.mapState,d,_,t[a].duration,1,{layerId:this.layer.innerId,styleId:n.DYNAMIC_STYLE_ID}),this.tickerNames.set(a,c)}(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){var c;const r=this.tileObjects[0];if(!r)return;const a=r.buffers[0];if(!a)return;if(e&&(this.position={userValue:e,normalizedValue:n.normalizeMapPoint(e)},r.setTileCoords(n.getTileCoordsByCenterAndZoom(this.position.normalizedValue,Rs),this.mapState)),t!==void 0||i!==void 0){const d=nc(t!=null?t:this.appliedTransformations.rotation),_=i!=null?i:this.appliedTransformations.scale;this.appliedTransformations.rotation=d,this.appliedTransformations.scale=_}if(o!==void 0){const d=o!=null?o:this.appliedTransformations.offset;this.appliedTransformations.offset=d}n.getTriple(this.appliedTransformations.offset,ic),n.getTriple(this.appliedTransformations.scale,ec),n.getTriple(this.appliedTransformations.rotation,tc);const l=xe(this.mapState);n.GltfModelGenerator.patchBuffer(a,0,n.createTileInfo(r.coords),[Qn,Qn,(c=this.position.userValue[2])!=null?c:0],ic,ec,tc,l),r.ecefDataState=n.ecefDataStateFromBool(l)}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 Qs&&t!==this&&t.isVisible());this.linkedIds.forEach(t=>{e.every(o=>{var r;return!((r=o.getLinkedIds())!=null&&r.includes(t))})&&this.map.showHiddenBuildingsById([t])})}};const ec=[0,0,0],tc=[0,0,0],ic=[0,0,0];function nc(s){return Array.isArray(s)?s.map(e=>e%360):s%360}function oc(s,e){const t=zy/n.Mercator.scaleFactor(e),i=["x","y"].filter((o,r)=>{const a=Array.isArray(s)?s[r]:s;return a<-t||a>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 Fy(s){return Ry.includes(s)}function Dy(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 Oy=[0,0,0],Ny=[0,0,0],ky=[0,0,0],Uy="modelshow",Hy="modelhide",Jn=0,sc=.1;class Gy{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 Iy(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=Ds(t.attributes.styleId,t.attributes.sourceId,t.tile.coords),r=this.layerModelKeyBySourceTile.get(o);r?r.add(i):this.layerModelKeyBySourceTile.set(o,new Set([i]))}clearSourceTileMapByTiles(e,t){t.map(i=>Ds(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){var o;const i=An(e);return(o=this.modelInfo[i])==null?void 0:o.modelIds[t.id]}getModelOpacity(e){var i;if(e===void 0)return Jn;const t=An(e.attributes);return t&&(i=this.modelsAnimator.getReadiness(t))!=null?i:Jn}getModelHeightFactor(e){var i;if(!e)return 1;const t=An(e.attributes);return(i=this.modelsAnimator.getReadiness(t))!=null?i: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=An(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,ce(I({},e),{key:t})),this.addLayerModelToSourceTileMap(t,e))}removeSceneObject(e){this.sceneObjects.delete(e),delete this.objectIdToLayerModelKey[e]}allObjectsHaveCurrentModelId(e,t,i){var a;const o=Ds(i,e,t),r=this.layerModelKeyBySourceTile.get(o);if(!r)return!0;for(const l of r){const c=(a=this.modelInfo[l])==null?void 0:a.modelIds;if(!c)return!1;for(const d in c)if(c[d]===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,r){var z,E,P,k;const{assetManager:a,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:x,modelStepSource:g}=t;if(!v.length)return;let y;switch(g){case n.ModelStepSource.None:y=0;break;case n.ModelStepSource.Zoom:y=rc(x,u.styleZoom);break;case n.ModelStepSource.Distance:y=Vy(o,i,d.position,x,r);break;default:return}if(y===-1)return;const b=v[y];if(b===void 0)return;const S=a.getModel(b,h);if(S)switch(S.status){case ot.Loaded:e.modelId=b;const R=(E=(z=S.scenes.find((C,F)=>typeof t.scene=="number"&&!Number.isNaN(t.scene)&&F===t.scene||typeof t.scene=="string"&&C.name===t.scene))!=null?z:S.scenes.find((C,F)=>F===S.defaultScene))!=null?E:S.scenes.find((C,F)=>F===0);e.sceneId=R==null?void 0:R.id,S.usedEmptyScene=((k=(P=S.scenes.find(C=>C.id===e.sceneId))==null?void 0:P.objects.length)!=null?k:0)===0;return;case ot.Failed:e.modelId=NaN;return}else{const R=c.getStyleLayer(h,f),C=a.getDataModelUrlById(b);if(R&&!this.disabled){if(C===void 0)a.loadModelByIndex(b,h,R);else if(C.length){const F=m===_.getId()&&p===jn;a.loadModel(C,b,h,!1,R,F)}}}if(v.length===1)return;const T=l.getSourceById(m);T&&(g===n.ModelStepSource.Zoom?e.modelId=this.getModelIdByZoom(T,t,o,y):g===n.ModelStepSource.Distance&&(e.modelId=this.getModelIdByDistance(t,o)))}getModelIdByDistance(e,t){return this.getCurrentModelId(e,t)}getModelIdByZoom(e,t,i,o){const{styleId:r,modelIndices:a}=t,l=e.getZoomDirection();if(l===n.ZoomDirection.Stationary)return this.getCurrentModelId(t,i);const c=a.slice(0,o).reverse(),d=a.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],r);if(h&&h.status===ot.Loaded)return _[u];if((h==null?void 0:h.status)===ot.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===ot.Loaded)return i;if((o==null?void 0:o.status)===ot.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 r=0;r<i.length;r++)this.processSceneObject(i[r],e,t);for(const r of t)this.sceneObjects.delete(r),delete this.objectIdToLayerModelKey[r];const o=this.mapState.styleZoom;for(const r of Object.keys(this.modelInfo)){const a=this.modelInfo[r];(!e.has(r)||o<a.layer.minzoom||o>=a.layer.maxzoom)&&this.removeLayerModel(r,a)}}processSceneObject(e,t,i){if(e.tile.destroyed){i.add(e.id);return}const o=e.key,r=this.modelInfo[o],a=this.mapState.disableModelsGrowthAnimation||e.tile.dynamicObject instanceof Fs&&e.tile.dynamicObject.isAnimationDisabled();r&&!this.modelsAnimator.has(o)&&(this.mapModules.defaultSource.createModelsSource(),this.startAnimation(o,r,a)),r?this.objectIdToLayerModelKey[e.id]||this.indexateObject(o,e,r):this.addLayerModel(e,o,!0),t.add(o)}addLayerModel(e,t,i=!1){var a,l;const o=this.mapModules.styleManager.getStyleLayer(e.attributes.styleId,e.attributes.layerId);if(!o)return;if(i){const c=this.mapState.styleZoom;if(c<o.minzoom||c>=o.maxzoom)return}const r={layer:o,ids:e.tile.ids,linkedIds:[],ownerIds:new Set,modelIds:{},buildingId:((a=e.meta)==null?void 0:a.buildingId)||""};return(l=e.meta)!=null&&l.planId&&(r.planId=e.meta.planId),this.indexateObject(t,e,r),this.modelInfo[t]=r,r}startAnimation(e,t,i){var a;if(i){this.modelsAnimator.add(e,1,1);return}const o=(a=t.layer.minzoom)!=null?a: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}),r=e.visible;o!==r&&(e.visible=o,this.emitEvent(o&&!r?Uy:Hy,e))}addNewSceneObjectsToVisibilityMap(){var i,o,r,a;const e=this.mapModules.camera.getViewportVertices(sc),t=Array.from(this.sceneObjects.values());for(let l=0;l<t.length;l++){const c=t[l];if((i=c.attributes)!=null&&i.emitShowHideEvents&&((o=c.meta)!=null&&o.buildingId)&&c.attributes.lngLat){const d=c.key,_={visible:!1,mapPoint:n.Mercator.fromGeo(c.attributes.lngLat),buildingId:((r=c.meta)==null?void 0:r.buildingId)||"",sublayer:((a=c.meta)==null?void 0:a.sublayer)||"",key:d};let u=this.sceneObjectsVisibilityMap.get(d);u||(u=new Map,this.sceneObjectsVisibilityMap.set(d,u)),u.get(c.meta.buildingId)||(u.set(c.meta.buildingId,_),this.maybeEmitModelEvent(_,{onKeyShow:!0},e))}}}checkSceneObjectsVisibilityMap(){const e=this.mapModules.camera.getViewportVertices(sc);this.sceneObjectsVisibilityMap.forEach(t=>t.forEach(i=>this.maybeEmitModelEvent(i,{},e)))}indexateObject(e,t,i){var r,a,l;this.objectIdToLayerModelKey[t.id]=e,i.ownerIds.add(t.id),i.buildingId=((r=t.meta)==null?void 0:r.buildingId)||"",i.buildingId&&this.buildingIds.add(i.buildingId);const o=(l=(a=t.meta)==null?void 0:a.linkedIds)!=null?l:[];if(i.linkedIds.push(...o),t.tile.purpose!=="c3d")for(const c of o)this.linkedIdToObjectId[c]=t.id}removeLayerModel(e,t){var o;(o=t.ids)==null||o.show(t.linkedIds);for(const r of t.ownerIds)delete this.objectIdToLayerModelKey[r];t.buildingId&&this.buildingIds.delete(t.buildingId),this.modelsAnimator.remove(e);const i=this.sceneObjectsVisibilityMap.get(e);i&&(i.forEach(r=>this.maybeEmitModelEvent(r,{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 r=n.isCommercialModel(o);this.mapModules.map.emit(e,{sublayer:o,id:i,isCommercial:r})}updateObjectsVisibility(){var i;const e=this.mapModules.identifier.getIdScope(n.DYNAMIC_MODEL_ID_SCOPE),t=this.mapModules.identifier.getIdScope(n.DEFAULT_ID_SCOPE);e.getHidden().forEach(o=>{t.hide([o],n.HideLevel.All)});for(const o in this.modelInfo){const r=this.modelInfo[o],a=r.ids;if(!a)continue;const l=(i=this.modelsAnimator.getReadiness(o))!=null?i:Jn;for(const c of r.linkedIds){if(a.isHidden(c))continue;const d=r.planId!==void 0?n.HideLevel.FloorPolygons:n.HideLevel.PolygonExtrusion,_=a.isHidden(c,d);l>.5&&!_?a.hide([c],d):l<.5&&_&&a.show([c])}}}destroy(){this.mapModules.defaultSource.destroyModelsSource();for(const e in this.modelInfo){const t=this.modelInfo[e];this.removeLayerModel(e,t)}this.sceneObjects.clear()}}function An(s){const{layerId:e,modelIndices:t}=s;return`${e}_${t.join(",")}`}function Ds(s,e,t){return`${s}_${e}_${JSON.stringify(t)}`}function Vy(s,e,t,i,o){const r=s.modelMatrices.get(0);if(!r)return-1;let a=e.min,l=e.max;o||(a=n.transformMat4$1(Ny,a,r),l=n.transformMat4$1(ky,l,r));const c=n.projectToXyRect(t,a,l,Oy),d=n.Mercator.toGeo(c),_=n.Mercator.scaleFactor(d[1]),u=n.dist$1(t,c)/n.MAP_POINTS_IN_METER/_;return rc(i,u)}function rc(s,e){let t=0;for(;t<s.length&&!(e<s[t]);)t++;return t-1}const jy=n.bezier(.42,0,1,1),Zy=(s,e,t,i)=>e+t*jy(s/i),$y=n.bezier(0,0,.58,1),Wy=(s,e,t,i)=>e+t*$y(s/i),Xy=n.bezier(.42,0,.58,1),Ky=(s,e,t,i)=>e+t*Xy(s/i);function ac(s){switch(s[0]){case"cubic-bezier":{const e=n.bezier(s[1],s[2],s[3],s[4]);return(t,i,o,r)=>i+o*e(t/r)}case"exponential":{const e=s[1];return(t,i,o,r)=>{const a=i,l=i+o,c=t/r,_=(qe(e,c)-1)/(qe(e,1)-1);return(1-_)*a+_*l}}case"ease":return n.ease;case"ease-in":return Zy;case"ease-out":return Wy;case"ease-in-out":return Ky;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 qy{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:r,transformStack:a,textureTransformMatrix:l}=e.renderingProperties;if(t.style.playAnimation===void 0||!(r!=null&&r.length)||!o||!r||!a||!l)return;const c=this.updateAnimationKeyframes(e,t);il(l,r,i.buffers,c),nl(o,r,a,i.buffers,c)}animatePolygonNormalMapTexture(e,t){var R;if(!t.style.normalMapTextureAnimation)return[!1,[0,0,0,0]];let i=1;const o=t.innerId,r=e.attributes.styleId,a=`${r}_${o}`,l=Date.now(),[[c,d],[_,u],[h,f],m,p,v,x,g]=this.resolveDoubleSampledTextureAnimationOptions(t),y=[h,f,0,0];if(this.mapState.disableLayerAnimation)return[!1,y];const b=(R=this.doubleSampledTextureAnimationStateMap.get(a))!=null?R:{lastKnownOffsets:y,animationStage:0,previousTimestamp:l},{lastKnownOffsets:S,previousTimestamp:T,animationStage:z}=b;let E=z;const P=(l-T)/1e3;switch(z){case 0:{let C=!1;const F=n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[]),se=n.resolveString(t.style.normalMapTextureImage,F),Q=this.modules.styleManager.getStyle(r);if(Q){const le=Q.rasterSets.byKey[n.getStaticTextureRasterSetKey(se)];le&&le.isReady&&(C=!0)}C&&(p?(n.start(`${a}_animationSpeedUp`,{easing:ac(v),forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,0,1,p,1),E=1):(m!==1/0&&n.start(`${a}_animationFullSpeed`,{forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,1,1,m,1),E=2));break}case 1:{n.update(`${a}_animationSpeedUp`,{keepFinished:!0,step:(C,F,se,Q)=>{Q?(i=1,n.stop(`${a}_animationSpeedUp`,this.mapState),m!==1/0&&n.start(`${a}_animationFullSpeed`,{forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,1,1,m,1),E=2):i=F}},this.mapState);break}case 2:{m===1/0||n.update(`${a}_animationFullSpeed`,{keepFinished:!0,step:(C,F,se,Q)=>{Q&&(n.stop(`${a}_animationFullSpeed`,this.mapState),x?(n.start(`${a}_animationSlowDown`,{easing:ac(g),forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,1,0,x,1),E=3):E=4)}},this.mapState);break}case 3:{n.update(`${a}_animationSlowDown`,{keepFinished:!0,step:(C,F,se,Q)=>{Q?(i=0,n.stop(`${a}_animationSlowDown`,this.mapState),E=4):i=F}},this.mapState);break}case 4:{i=0;break}}const k=[S[0]+c*i*P,S[1]+d*i*P,S[2]+_*i*P,S[3]+u*i*P].map(C=>C%1);return this.doubleSampledTextureAnimationStateMap.set(`${r}_${o}`,{animationStage:E,lastKnownOffsets:k,previousTimestamp:l,updatedOnThisFrame:!0,styleId:r,layerId:o}),E!==4&&this.rerenderEvents.push({type:"layerAnimationTicker",layerId:o,styleId:r,underCache:!0}),[!0,k]}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){var p,v,x,g,y,b,S,T,z,E,P;const t=n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[]),i=n.resolveTextureAnimationExpression(e.style.normalMapTextureAnimation,t),o=(p=i[1])!=null?p:0,r=(v=i[2])!=null?v:0,a=(x=i[3])!=null?x:0,l=(g=i[4])!=null?g:0,c=(y=i[5])!=null?y:0,d=(b=i[6])!=null?b:0,_=(S=i[7])!=null?S:1/0,u=(T=i[8])!=null?T:0,h=(z=i[9])!=null?z:["linear"],f=(E=i[10])!=null?E:0,m=(P=i[11])!=null?P:["linear"];return[[o,r],[a,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,r=this.applyAnimationState(t,e),a=r.animationStateID;let l=!1;for(const c of i){const d=n.get(a,this.mapState);if(this.isNeedAnimation(c,r)){if(!d&&r.currentCount>0){const _=r.animationDuration||(c.max?c.max[0]:0),u=r.startOffset||0;let h=r.startOffset?c.frameCount/(c.frameCount*_/u):0,f=_*(1e3/r.playSpeed)-u*(1e3/r.playSpeed);r.elapsedTime&&(h=1-r.elapsedTime,f=_*(1e3/r.playSpeed)*r.elapsedTime),n.start(a,{easing:"linear",forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,h,1,f,1)}n.update(a,{keepFinished:!0,step:(_,u,h,f)=>{const m=(c.frameCount-1)*u;o.set(c.actionId,m),f||this.rerender(e,t,r)},complete:_=>{l||(l=!0,r.currentCount>0&&r.currentCount--)}},this.mapState),this.currentObjects.set(a,r)}}return l&&r.currentCount>0&&(n.stop(a,this.mapState),this.rerender(e,t,r)),o}initObjectAnimationState(e,t){var m,p;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],r=typeof i[0]=="object"&&!Array.isArray(i[0])&&i[0].type==="schedule-detailed-result"?i[0].currentStepElapsed/1e3:void 0,a=(m=i[2])!=null?m:1/0,l=a,c=i[1]||1,d=i[4]||void 0,_=i[3]||r||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:a,playSpeed:c,animationIndex:u,animationName:h,currentCount:l,animations:f,animationDuration:d,startOffset:_,tickerByStep:!!(_&&d),animationStateID:((p=i[5])==null?void 0:p.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=a=>{o=a};const r=n.resolveAnimationExpression(e.style.playAnimation,i);return r[6]===void 0&&o&&(r[6]=o),r}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==null?void 0:o.animationIndex)!==i.animationIndex||(o==null?void 0:o.animationName)!==i.animationName)?(n.update(i.animationStateID,{keepFinished:!0,step:(r,a)=>{o.elapsedTime?(o.elapsedTime>0||o.elapsedTime<1)&&(i.elapsedTime=o.elapsedTime):(o.elapsedTime=a,i.elapsedTime=a)}},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 dt=.1,Yy={id:"simple-mesh",type:"simpleMesh",innerId:n.SIMPLE_MESH_STYLE_LAYER_ID,filter:!1,minzoom:0,maxzoom:20,precomputes:[],renderIndex:0,style:{}},Os={polygonsQty:1e4,drawCallsQty:150,iterations:7},lc=[18,34],Qy=1e3,Oi="__MAPGL_BENCH_TIME",Jy=5,mi=class mi{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=bt(this.state,this.modules),this.framebufferId=this.createFramebuffer(),this.modules.dynamicStyle.addLayer(Yy)}static mockResult(e){mi.mocked=e}run(){return K(this,arguments,function*(e=Os.polygonsQty,t=Os.drawCallsQty,i=Os.iterations,o=Qy){if(mi.mocked)return mi.mocked;const r=this.getCachedResult();if(r)return r;this.timeout=o,this.startTs=performance.now();try{return yield this._run(e,t,t*i,i)}catch(a){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.74.0",t=localStorage.getItem(Oi);if(t){const i=t.split(":"),o=i[0];if(e===o){const r=i.slice(1).join(":").split(",").map(a=>parseFloat(a)).filter(a=>!Number.isNaN(a));if(r.length>=Jy){const a=r.reduce((c,d)=>c+d,0)/r.length;return{status:"cached",tier:this.selectTier(a)}}}}}catch(e){}return null}selectTier(e){const t=lc.findIndex(i=>e<=i);return t>-1?lc.length-t:0}saveResult(e){try{const t="v1.74.0",i=localStorage.getItem(Oi);if(i){const o=i.split(":"),r=o[0];if(t!==r)localStorage.setItem(Oi,`${t}:${e.toPrecision(4)}`);else{const a=o.slice(1).join(":").split(",").map(l=>parseFloat(l)).filter(l=>!Number.isNaN(l));a.push(e),localStorage.setItem(Oi,`${t}:${a.map(l=>l.toPrecision(4)).join(",")}`)}}else localStorage.setItem(Oi,`${t}:${e.toPrecision(4)}`)}catch(t){}}_run(e,t,i,o){return K(this,null,function*(){const r=this.modules.renderer.getFramebuffer(this.framebufferId);if(!r)throw new Error("Failed to create framebuffer for benchmark.");this.modules.renderer.bindRenderTarget(r.renderTarget),this.modules.renderer.setViewport(0,0,this.modules.renderer.getViewportSize()[0],this.modules.renderer.getViewportSize()[1]);const a=this.prepareData(e,i),l=yield 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:a}})}prepareData(e,t){const i=performance.now();this.buffer=this.generateSphere(e);const o=performance.now(),r=performance.now();this.sceneObjects=this.createSceneObjects(t);const a=performance.now();return{generationTime:o-i,objectsTime:a-r}}measureRendering(e,t){return K(this,null,function*(){return new Promise(i=>{const o=[];let r=0,a=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(),Ho(this.state,this.modules,this.sceneObjects.slice(a,a+t),this.de),this.modules.renderer.waitForGpuCommandsToFinish(),o.push(performance.now()-c),r++,a+=t,r<e?Promise.resolve().then(l):i(o)};setTimeout(()=>{l()},0)})})}processResults(e){const t=e.slice();t.sort((o,r)=>o-r);const i=t.slice(0,t.length-.2*t.length);return{median:i[Math.floor(i.length/2)],mean:i.reduce((o,r)=>o+r,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 x=v*_,g=(v+1)*_,y=Math.sin(x),b=Math.cos(x),S=Math.sin(g),T=Math.cos(g);for(let z=0;z<i;z++){const E=z*u,P=(z+1)*u,k=Math.sin(E),R=Math.cos(E),C=Math.sin(P),F=Math.cos(P);h[0]=dt*y*R,h[1]=dt*b,h[2]=dt*y*k,f[0]=dt*y*F,f[1]=dt*b,f[2]=dt*y*C,m[0]=dt*S*R,m[1]=dt*T,m[2]=dt*S*k,p[0]=dt*S*F,p[1]=dt*T,p[2]=dt*S*C,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 Ce({size:this.modules.renderer.getViewportSize(),magFilter:w.NearestFilter,minFilter:w.NearestFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping,type:w.Float,flipY:!0});return this.modules.renderer.addFramebuffer({clearColor:[0,0,0,0],renderTarget:e,onResize:()=>{}})}createSceneObjects(e){const t={programName:"simpleMesh",vaoCreator:kr,stateBinder:()=>Io,programBinder:fh,tileBinder:()=>!0,objectBinder:kh,needsVisibilityBuffer:!1},i=[],o=kr(this.modules.renderer.createBuffer(this.buffer),this.modules.renderer.getShaderProgram("simpleMesh")),r=new n.TileObject("zenith",[],this.modules,this.state),a={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:r,symbol:"simpleMesh",sink:"fill",layerSettings:t,canRender:!0,attributes:a,meta:{scale:d,transform:_},renderingProperties:{}})}return i}};mi.mocked=null;let eo=mi;class Ay{constructor(e,t,i){this.benchmark=null,this.profiler=new kd,this.map=i,this.camera=new n.Camera(e),this.layout=new gy(t),this.collector=new n.Collector("main"),this.workers=new gg,this.identifier=new wg(e,this),this.styleManager=new Cg(this),this.assetManager=new Lg(e,this),this.imageManager=new yy(this),this.floorManager=new ey(e,this),this.personalPoiManager=new Dg(this),this.buildingHeightAnimator=new jd(e,this),this.modelsScene=new Gy(e,this),this.renderer=new Fi(e,this),this.newRenderer=new bg(e,this),this.layers=new qg(this),this.sourceStorage=new wy,this.tileManager=new ry(e,this),this.modelLayer=new Fg(e,this),this.dynamicStyle=new n.DynamicStyle,this.imageCache=new Qg(this),this.labeler=new uy(e,this),this.trafficTileLayer=new py(e,this),this.handler=new fy(e,this),this.mouseMoveHandler=new Hd(this),this.tileKeyInfo=new by(e),this.demManager=new Bu(this),this.environmentManager=new Ey(this),this.defaultSource=new Rl(e,this),this.labelsDebug=new Ty(e,this),this.postEffectsManager=new dh(e,this),this.renderCacheManager=new lg(e,this),this.animationManager=new qy(e,this),this.shadowManager=new ah(e,this),this.instanceLinker=new nm(this),e.graphicsPresetMode==="auto"&&(this.benchmark=new eo(e,this))}destroy(){this.profiler.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 cc=["light","normal","immersive"],ex=["immersiveRoadsOff","reliefOff","shadowsOff","fogOff","skyOff","modelsOff","globeOff","transparentBuildingsOff","AALinesOff"],tx=.3,pi=class pi{constructor(e,t={},i){var h,f,m,p,v,x,g,y,b,S,T,z,E,P,k,R,C,F,se;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=Q=>{if(this.modules.renderer.isDestroyed)return;this.requestedFrame=requestAnimationFrame(this.renderLoop),this.modules.profiler.logStartTime(Ai,sr),this.updateImmersiveLevel();const le=window.devicePixelRatio;le!==this.lastDpr?(this.lastDpr=le,this.state.dpiChanged=!0,this.modules.map.invalidateSize(),this.modules.imageCache.clear()):this.state.dpiChanged=!1,this.modules.map.emit("framestart"),this.modules.renderer.resetStateAfterExternalRender();const D=this.state;D.time=Date.now(),this.processMetrics(),this.state.enableTrackResize&&this.autoResize(Q),this.modules.mouseMoveHandler.update(),this.handlers.forEach(ye=>ye.update()),Sd(D),gd(D),xd(D),wd(D),this.stillnessUpdater.update(D),pd(D,this.modules.layout.rootContainer),ad(D,this.modules.layout.rootContainer,this.modules.renderer),hd(D,this.modules.renderer),this.checkGlobeEnabled();const Ke=this.modules.demManager.getReliefTileType()==="vector"&&D.styleZoom<Kr;D.demMode=this.checkDemEnabled()&&D.elevationScale>0&&!Ke,this.modules.camera.update(),this.updateElevation(),this.updateTilesBounds(),this.replicasDiffer.check(D)&&(D.needReplicasUpdate=!0),this.modules.demManager.update(),this.modules.environmentManager.update(),this.modules.labelsDebug.update(),this.modules.trafficTileLayer.update(),this.modules.layers.getLayers().forEach(ye=>{ye.update!==void 0&&ye.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(),D.loopWorld&&!this.modules.renderer.isNeedRerender()&&n.worldWrapX(D.center);const Se=n.render.alwaysRerender||this.modules.renderer.isNeedRerender();if(Se&&D.collectStats&&(D.stats.drawCount=0,D.stats.vertexCount=0,D.stats.triangleCount=0,D.stats.drawCountBySymbol={}),Se){const ye=this.modules.tileManager.getTileObjects();this.modules.renderer.prerenderUpdate(),D.metrics.firstdraw===void 0&&(D.metrics.firstdraw=performance.now()-D.metrics.start),ye.forEach(Ue=>{Ue.needSync&&Ue.syncReplicas(this.state)}),this.modules.renderCacheManager.frameStart(),this.modules.animationManager.frameStart(),this.modules.renderer.renderElevation(ye),this.modules.shadowManager.drawShadowMap(ye),this.modules.renderer.renderLabelingTexture(ye),this.modules.renderer.renderSpriteLabelingTexture(ye),this.modules.renderer.renderTileObjects(ye),this.modules.shadowManager.drawDebugFbIfNeeded(),D.needRerender=!1,this.state.rerenderEvents=new Array,this.modules.animationManager.frameEnd(),this.modules.renderCacheManager.frameEnd(),D.collectStats&&(this.modules.map.emit("stats",D.stats),(!D.metricsSent||this.state.metrics.graphicsPreset!==this.state.styleState.graphicsPreset)&&(D.metrics.vertexCount=D.stats.vertexCount,D.metrics.triangleCount=D.stats.triangleCount,D.metrics.drawCount=D.stats.drawCount))}this.finishStyleUpdatingCheck(),this.modules.map.update(),this.modules.assetManager.invalidateUsedGltfModels(),D.needReplicasUpdate=!1,D.shouldIsReadyWaitForUpdates=!1,D.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"),this.state.metrics.graphicsPreset=this.state.styleState.graphicsPreset,this.state.metricsSent=!1),Se||(this.modules.profiler.logStartTime(Ai,rr),this.modules.profiler.logEndTime(Ai,rr)),this.modules.profiler.logEndTime(Ai,sr)};const o=I(I({},pi.options),t),r=I(I({},pi.options.padding),o.padding),a=I(I({},pi.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"?ce(I({},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:(h=o.loopWorld)!=null?h:!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-a.left-a.right),Math.max(1,e.clientHeight-a.top-a.bottom)],tickers:{},stillness:1,needRerender:!0,needLabeling:!1,needReplicasUpdate:!1,userHasInteracted:!1,dpiChanged:!1,viewport:a,padding:r,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:(f=o.modelsTileSet)!=null?f:n.models.tileSet,modelsTilesUrl:(m=o.modelsTilesUrl)!=null?m:n.urls.models,defaultSourceModelsRootUrl:o.defaultSourceModelsRootUrl,defaultSourceModelsAppearStrategy:o.defaultSourceModelsAppearStrategy,sharedModelsPath:o.sharedModelsPath,subdomains:o.subdomains.split(""),floorsEnabled:o.floorsEnabled,collectStats:o.collectStats,stats:{tileCount:0,dynamicTileCount:0,viewportTileCount:0,displayedTileCount: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:$n(d),disableIconCache:o.disableIconCache,disableRenderingCache:o.disableRenderingCache,rtlPlugin:{scenario:(p=o.useRtlTextPlugin)!=null?p:"depends-on-language",loadFailed:!1,url:(v=o.rtlPluginUrl)!=null?v:n.rtlPluginUrl,hash:(x=o.rtlPluginHash)!=null?x:n.rtlPluginHash},mobileSdkMode:o.mobileSdkMode,dracoDecoderUrl:(g=o==null?void 0:o.dracoDecoderUrl)!=null?g:n.dracoDecoderUrl,demMode:!1,globeMode:!1,globeRatioTarget:0,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:(y=o.iconIdentifyOpacity)!=null?y:tx,disableHidingPois:(b=o.disableHidingPois)!=null?b:!1,resetFloorModeOnActivation:(S=o.resetFloorModeOnActivation)!=null?S:!1,aaMode:o.disableAntiAliasing===!1?ri.TAA:void 0,rerenderEvents:new Array,cameraConfig:Object.assign({},n.defaultCameraConfig),cityCommPoiLabeling:{config:o.cityCommPoiLabelingConfig,ascSortedZoomNumbers:cy(o.cityCommPoiLabelingConfig)},trafficMinZoom:(T=o.trafficMinZoom)!=null?T:n.traffic.minZoom,trafficMaxZoom:(z=o.trafficMaxZoom)!=null?z:n.traffic.maxZoom,trafficMaxDetailLevel:(E=o.trafficMaxDetailLevel)!=null?E:n.traffic.maxDetailLevel,bssHostAppParams:o.bssHostAppParams,disableStyleFallback:!!o.disableStyleFallback,hiddenImmersiveRoutesEnabled:r_(),modelShowHideEventsSublayers:new Set((P=o.modelShowHideEventsSublayers)!=null?P:[]),graphicsPresetMode:o.graphicsPreset,shouldEmitGraphicsPresetChangeEvent:!1,isDeprecatedSystem:ti(),disableModelsGrowthAnimation:(k=o.disableModelsGrowthAnimation)!=null?k:!1,disableLayerAnimation:(R=o.disableLayerAnimation)!=null?R:!1,allowMetro:(C=o.allowMetro)!=null?C:!1,metro3dVisible:(F=o.metro3dVisible)!=null?F:!1,forceSyncIdentify:(se=o.forceSyncIdentify)!=null?se:!1};o.cameraConfig&&Object.assign(_.cameraConfig,o.cameraConfig),this.modules=new Ay(_,e,i),typeof _.commercialPoiRandomSeed=="number"&&this.modules.workers.labeling.setCommercialPoiRandomSeed(_.commercialPoiRandomSeed),this.modules.styleManager.setDynamicStyle(this.modules.dynamicStyle.getStyle()),this.handlers=[new Rd(_,this.modules.layout.mapContainer),new Fd(this.modules)],o.disableZoomOnScroll||this.handlers.push(new zd(_,this.modules.layout.mapContainer)),Ld&&Yi&&this.handlers.push(new Dd(_,e,i)),this.performanceChecker=new Od(_,this.modules),this.stillnessUpdater=new Ud,(o.graphicsPreset==="auto"?this.measurePerformance():Promise.resolve(this.state.metrics.graphicsPreset=this.state.styleState.graphicsPreset)).finally(()=>{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}measurePerformance(){return K(this,null,function*(){performance.now();const e=yield this.modules.benchmark.run();switch(this.modules.benchmark.destroy(),this.modules.benchmark=null,e.status){case"error":case"timeout":const t=cc[0];this.state.metrics.graphicsPreset=t,this.modules.map.patchStyleState({graphicsPreset:t});break;case"part-done":case"done":case"cached":{const i=cc[e.tier];this.state.metrics.graphicsPreset=i,e.status!=="cached"&&(this.state.metrics.benchRenderTime=Math.round(e.measurements.mean),this.state.metrics.benchGenTime=Math.round(e.preparation.generationTime)),this.modules.map.patchStyleState({graphicsPreset:i});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&&this.performanceChecker.hasFpsStats()||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.map.getFeatureFlag("reliefOff")?this.modules.demManager.isEnabled()||this.modules.demManager.enable():this.modules.demManager.isEnabled()&&this.modules.demManager.disable(),this.modules.demManager.isEnabled()}checkGlobeEnabled(){const{handyStyleId:e,zoom:t}=this.state;if(!this.modules.styleManager.getStyleLayer(e,n.ENVIRONMENT_STYLE_LAYER_ID)){const r=this.state.globeMode;this.state.globeMode=!1,this.state.globeRatioTarget=0,r&&!this.state.loopWorld&&n.clampPoint(this.state.center,this.state.maxBounds,this.state.center);return}const{globeMaxZoom:o}=n.globeConfig;this.state.globeMode=!!this.state.styleState.globeEnabled&&t<o&&!this.modules.map.getFeatureFlag("globeOff"),this.state.globeMode?this.state.globeRatioTarget=n.clamp(o-t,0,1):this.state.globeRatioTarget=0,this.state.globeRatioTarget>0&&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,r,a]=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,x=Math.max(this.state.elevation-v,0)*n.MAP_POINTS_IN_METER,g=Math.min(x/p+1,2),y=(g-1)*Math.max(1-this.state.pitch/this.state.maxPitch,.1)+1;n.lerp(i,this.modules.camera.position,i,y),n.lerp(o,this.modules.camera.position,o,y),n.lerp(a,this.modules.camera.position,a,g),n.lerp(r,this.modules.camera.position,r,g)}let h=n.pointToLineDistance(r,l);if(h>u){const p=u/h;n.lerp(r,o,r,p),n.lerp(a,i,a,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],r),n.copy$2(this.state.extendedTilesBounds[3],a);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(r,o,r,p),n.lerp(a,i,a,p),h=m}if(this.state.demMode&&d){const p=(h+Math.abs(c))/h;n.lerp(i,a,i,p),n.lerp(o,r,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],r),n.copy$2(this.state.tilesBounds[3],a),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=Eu*(e-this.state.elevation);Math.abs(i)<Iu?this.state.elevation=e:this.state.elevation+=i;const o=this.modules.demManager.getElevation(this.modules.camera.position);if(o!==void 0){const r=this.state.elevationScale,a=o*r,l=this.modules.camera.position[2]/n.MAP_POINTS_IN_METER,c=Math.min(30,l*.2),d=this.state.elevation*r+l-c;a>d&&(this.state.elevation+=(a-d)/r)}}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,r=window.devicePixelRatio;(t.width!==Math.floor(i*r)||t.height!==Math.floor(o*r))&&(this.lastResizeTime=e,this.modules.map.invalidateSize())}}};pi.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:Jg(),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,sharedModelsPath:""};let Ns=pi;const ix="https://mapgl.2gis.com/api/js",to={minZoom:2,maxZoom:20},nx="tile{subdomain}-sdk.maps.2gis.com",dc="https://tile{subdomain}-sdk.maps.2gis.com/api/v3/ald",ox="https://s1.bss.2gis.com/bss/3",sx="https://disk.2gis.com/shared-models/",ks=()=>{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},rx=2;function ax(s){const e=[rx,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),r=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT);return r&&o&&i?(e.push(`[${i.rangeMin},${i.rangeMax}](${i.precision})`),e.push(`[${o.rangeMin},${o.rangeMax}](${o.precision})`),e.push(`[${r.rangeMin},${r.rangeMax}](${r.precision})`)):e.push(new Array(3).fill("Unsupported")),e.push(window.devicePixelRatio),e}function lx(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 cx(s){var r,a;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=(r=e[t])!=null?r:{},o={};for(let l=0;l<s.length;l++)o[(a=i[l])!=null?a:l]=s[l];return o}const dx=/(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,_x=/CrOS/,ux=/android|ipad|playbook|silk/i,hx=()=>{const s=typeof navigator!="undefined"?navigator.userAgent:"";if(!s)return!1;const e=dx.test(s)&&!_x.test(s),t=ux.test(s),i=navigator.maxTouchPoints>1&&s.includes("Macintosh")&&s.includes("Safari");return e||t||i},io=5e3,fx=64,mx=16;class px{constructor(e,t){var i;this.queue=[],this.commPoiMsgOrderNumber=0,this.utcOffset=gx(),this.unsentMessages=[],this.isMetricsFailed=!1,this.webglStatsValues=[],this.onCommPoiShowEvent=({commPois:o})=>{const r=Date.now(),{tileKey:a,sessionId:l}=this.map.state;for(const c of o){const d=vx(c,r,this.commPoiMsgOrderNumber++,a,this.utcOffset,l);d&&this.queue.push(d)}this.timer||(this.timer=window.setTimeout(this.sendMessages,io))},this.onContextLostEvent=()=>K(this,null,function*(){const o=Date.now(),r={cpu:0,gpu:0},a={start:0,fail:!0,contextLost:!0},l=yield this.createMetricMessage(o,a,r);this.queue.push(l),this.timer||(this.timer=window.setTimeout(this.sendMessages,io))}),this.onMetricsEvent=o=>K(this,null,function*(){this.isMetricsFailed&&(o.fail=!0);const r=Date.now(),a=yield this.getMetricsMessage(o,r);this.queue.push(a),this.timer||(this.timer=window.setTimeout(this.sendMessages,io))}),this.onSendFail=o=>{this.unsentMessages.push(...o),this.timer||(this.timer=window.setTimeout(this.sendMessages,io))},this.sendMessages=()=>{this.timer=void 0;const o=[...this.unsentMessages,...this.queue];this.queue=[],this.unsentMessages=[],o.length&&fetch(this.bssUrl,{method:"POST",body:JSON.stringify(o),headers:{"Content-Type":"application/json"}}).then(r=>{r.ok||this.onSendFail(o)},()=>this.onSendFail(o))},this.markMetricsAsFailed=()=>{this.isMetricsFailed=!0},this.map=e,this.bssUrl=(i=t.bssUrl)!=null?i:ox,this.webglStatsValues=ax(this.map.getWebGLContext()),t.disableBssStatisticsForCommPoi||e.on("commpoishow",this.onCommPoiShowEvent),e.on("metrics",this.onMetricsEvent),this.map.on("error",o=>{o.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)}getCommonStats(){return K(this,null,function*(){const e=cx(this.webglStatsValues),t=lx(e),i=this.map.performanceChecker.getFpsStats(),o=Array.from(this.map.state.center),r=this.map.state.zoom,a=this.map.state.rotation,l=this.map.state.pitch,c=this.map.state.demMode,d=yield a_();return{webglStats:t,fps:i,center:o,zoom:r,rotation:a,pitch:l,reliefEnabled:c,webGpuSupported:d}})}createMetricMessage(e,t,i){return K(this,null,function*(){const o=yield this.getCommonStats();return{type:411,eventType:"mapglCounter",eventId:ks(),timestamp:e,payload:{mapGlMapMetrics:ce(I(I({},t),o),{memory:i}),mapGlHostAppParams:yx(this.map.state.bssHostAppParams)},common:{formatVersion:3,appVersion:n.limitString(Ks,fx),product:44,deviceType:hx()?"mobile":"desktop",key:this.map.state.tileKey,styleId:this.map.state.styleId}}})}getMetricsMessage(e,t){return K(this,null,function*(){const i=yield this.map.performanceChecker.getMemoryStats(),o=yield 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 vx(s,e,t,i,o,r){const a={adsHighlight:!0,entity:{id:s.id,type:"branch"}};s.adsPriority!==void 0&&(a.adsPriority=s.adsPriority);const l={type:302,eventType:"view",eventId:ks(),eventOrdinal:t,uiElement:{name:"POI",ownerName:"map"},timestamp:e,utcOffset:o,payload:{POI:a},common:{formatVersion:3,appVersion:n.limitString(Ks,mx),product:44,apikey:i}};return r&&(l.common.sessionId=r),!i||i===n.DEFAULT_EMPTY_KEY?null:l}function gx(){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 yx(s){if(s){const e=I({},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 _c=s=>typeof s=="number"&&!isNaN(s)&&s!==Number.NEGATIVE_INFINITY&&s!==Number.POSITIVE_INFINITY;function xx(s){return Array.isArray(s)&&_c(s[0])&&_c(s[1])}var Us=(s=>(s[s.IgnoreCall=0]="IgnoreCall",s[s.UseDefault=1]="UseDefault",s))(Us||{});const bx={0:"Method call will be ignored.",1:"Method call will use default value."};class wx{constructor(e){this.options=e}isValidGeoPoint(e,t){return this.processValidationResult(e,xx(e),"Invalid GeoPoint",t)}processValidationResult(e,t,i,o){return!t&&this.options.reportToConsole&&console.warn(`${i}: ${JSON.stringify(e)}
${bx[o]}`),t}}const uc=new wx({reportToConsole:!0}),no="Style preprocessing:";function Sx(s){const e=new Map,t=i=>{i==null||i.forEach(o=>{const r={layers:i,layer:o};e.set(o.id,r),o.type==="group"&&t(o.layers)})};return t(s.layers),e}function Tx(s,e){var r,a,l;const t=new Set;performance.now(),e!=null&&e.parentStyleId&&console.warn(`${no} Parent style with id=${s.parentStyleId} have parent with id=${e.parentStyleId}. Recursive inheritance is not supported.`);const i=e!=null?e:s;if(i.layers=(r=i.layers)!=null?r:[],e){const c=Sx(i),d=(a=s.layersInserts)!=null?a:[];d.length&&d.forEach(({layer:u,beforeId:h})=>{var f;if(h){const m=c.get(h);if(m){const{layers:p,layer:v}=m,x=p.findIndex(g=>v===g);p.splice(x,0,u),u.type!=="custom"&&u.type!=="group"&&t.add(u)}else console.warn(`${no} Child style tries to insert layer with beforeId=${h}. There is no layer with such id in the parent style. Layer insertion ignored.`)}else(f=i.layers)==null||f.push(u)});const _=Object.keys((l=s.layersPatches)!=null?l:{}).reduce((u,h)=>(c.has(h)||u.push(h),u),[]);_.length&&console.warn(`${no} Child style tries to patch layers with ids which do not exist in parent style: ${_.join("; ")}`)}const o=(c,d,_,u,h)=>{var f;if(d)for(let m=0;m<d.length;m++){const p=d[m];if(p.type==="custom")continue;let v=(f=_==null?void 0:_.layersPatches)==null?void 0:f[p.id];v&&(v==null?void 0:v.type)!==p.type&&(console.warn(`${no} Layer patch ignored due type mismatch. Target layer with id=${p.id} has type=${p.type}, but the patch has type=${v.type}.`),v=void 0),n.removeUndefined(p),v&&n.removeUndefined(v),p.type==="group"?(o(c,p.layers,_,p,v),d[m]=I(I({},p),v),delete d[m].commonDefaults,delete d[m].layerTypeDefaults):d[m]=Mx(c,p,u,h,p.type===(v==null?void 0:v.type)?v:void 0)}};return o(t,i.layers,e?s:void 0),e&&(["background","models","icons","labelingGroups","light","graphicsPresets","terrain","environment"].forEach(c=>{(i[c]&&Object.values(i[c]).length||s[c]&&Object.values(s[c]).length)&&(i[c]=I(I({},i[c]),s[c]))}),i.name=s.name),["models","icons"].forEach(c=>{i[c]&&Object.keys(i[c]).forEach(d=>{i[c][d]===null&&delete i[c][d]})}),i}function Mx(s,e,t,i,o){var l,c,d,_,u,h,f,m;const r=I({},t==null?void 0:t.commonDefaults),a=I({},i==null?void 0:i.commonDefaults);switch(e.type){case"heatmap":case"overpass":case"tunnel":{delete r.interactive,delete a.interactive,delete r.ignoreTier,delete a.ignoreTier;break}case"embankment":case"polygon3d":case"buildingModel":case"model":case"lineExtrusion":case"polygonExtrusion":case"point":{delete r.ignoreTier,delete a.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 ce(I(I(I(I(I(I(I({},r),(l=t==null?void 0:t.layerTypeDefaults)==null?void 0:l[e.type]),e),a),(c=i==null?void 0:i.layerTypeDefaults)==null?void 0:c[e.type]),s.has(e)?e:void 0),o),{style:I(I(I(I(I(I(I({},(d=t==null?void 0:t.commonDefaults)==null?void 0:d.style),(u=(_=t==null?void 0:t.layerTypeDefaults)==null?void 0:_[e.type])==null?void 0:u.style),e.style),(h=i==null?void 0:i.commonDefaults)==null?void 0:h.style),(m=(f=i==null?void 0:i.layerTypeDefaults)==null?void 0:f[e.type])==null?void 0:m.style),s.has(e)?e.style:void 0),o==null?void 0:o.style)})}function Ex(s,e,t){return K(this,null,function*(){const i=new URL(n.template(s,{id:e}));i.searchParams.append("key",t);const o=yield fetch(i.toString());if(o.status===404){console.warn(`No access to style with id «${e}».`);return}if(!o.ok)return;const r=yield o.json();if(r&&r.result)return{loadedId:e,style:r.result}})}function Ix(s,e,t){return K(this,null,function*(){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}),r=yield Ex(n.getStyleUrl(o),s,e);if(!r)throw new Error;i=r.style}catch(o){throw new Error("FETCH_PARENT_STYLE_ERROR")}return i})}function Cx(s,e,t){return K(this,null,function*(){let i;return s.parentStyleId&&(i=yield Ix(s.parentStyleId,e,t)),Tx(s,i)})}const hc=["zoom","rotation","pitch","center"],Lx=150,Px=["static","immersive_roads"];class Hs extends n.Evented{constructor(e,t){var r;super();const i=this.core=new Ns(e,t,this);this.state=i.state,this.modules=i.modules,this.performanceChecker=i.performanceChecker,this.values={isMoveChanging:!1,isIdle:!1},hc.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((r=t==null?void 0:t.style)!=null?r:n.DEFAULT_MAPGL_STYLE,t==null?void 0:t.styleOptions).catch(o),this.setLang(this.state.lang),t&&!t.disableBssStatistics&&(this._bssDispatcher=new px(this,{disableBssStatisticsForCommPoi:!!t.disableBssStatisticsForCommPoi,bssUrl:t.bssUrl})),this.state.metrics.init=performance.now()-this.state.metrics.start,this.updateDataToggle()}setCenter(e,t){if(!uc.isValidGeoPoint(e,Us.IgnoreCall))return this;this.state.userHasInteracted=!1;let i=n.Mercator.fromGeo(e);return this.state.loopWorld||(i=n.normalizeMapPoint(i)),Gt(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,Et(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,Et(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,yi(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,Ki(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,rd(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){var o,r,a,l;const i={top:(o=e.top)!=null?o:0,left:(r=e.left)!=null?r:0,right:(a=e.right)!=null?a:0,bottom:(l=e.bottom)!=null?l:0};return this.state.userHasInteracted=!1,ud(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!=null&&e.skipPadding)t=new n.Camera(ce(I({},this.state),{padding:{left:0,right:0,top:0,bottom:0}}));else if(e!=null&&e.sizeExtension){const o=e.sizeExtension,[r,a]=this.state.size,l=[r+o,a+o];t=new n.Camera(ce(I({},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,o=i.getIdScope(t);return o==null||o.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(){var e;this.core.destroy(),(e=this._bssDispatcher)==null||e.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=r=>(this.modules.styleManager.hideLayers(r),this.modules.renderer.addRerenderEvent(),this);if(n.isStyleLayerType(i)&&n.isStyleLayerHidable(i)){const r=n.convertStyleLayerTypeToHandy(i);if(r)return o({type:r})}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=r=>(this.modules.styleManager.showLayers(r),this.modules.renderer.addRerenderEvent(),this);if(n.isStyleLayerType(i)&&n.isStyleLayerHidable(i)){const r=n.convertStyleLayerTypeToHandy(i);if(r)return o({type:r})}else if(t)return o({id:t});return console.warn(`[#showLayers] The layer with type "${i}" can't be shown.`),this}setStyle(e,t){return K(this,null,function*(){let i,o=!1,r=!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=yield this.setCustomStyleById(e,t)):i=yield this.setCustomStyleFromUrl(e,t):(yield this.setCustomStyleDirectly(e,t),i=e),r=!0,this.emit("styleload",{style:i}),i}catch(a){if(r)throw a;if(a instanceof Error&&this.emit("error",{type:"styleloaderror",style:e}),o&&!this.currentPendingStyle)return this.setStyle(n.DEFAULT_MAPGL_STYLE);throw a}})}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}getIconUrl(e){var o;const t=this.modules.styleManager.getStyle(this.state.handyStyleId);if(!t)return;const i=(o=t.icons[e])==null?void 0:o.url;if(i)return n.getUrlForIconMapIcon(i,t,n.getSubdomainFromString(this.modules.map.state.subdomains,i))}getExternalContainer(){return this.modules.layout.externalContainer}fitBounds({northEast:e,southWest:t},i){const o=I({top:0,left:0,right:0,bottom:0},i!=null&&i.padding?i.padding:{}),r=this.getViewport(),a=this.getPadding(),l=i!=null&&i.skipMapPadding?o:ld(a,o),c=this.getSize(),d=i!=null&&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!=null&&i.considerRotation||yi(this.state,d,{animate:!1});const _=Vi([[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+r.left,(c[1]-l.top-l.bottom)/2+l.top+r.top];let h;(i==null?void 0:i.maxZoom)!==void 0?h=Math.min(_.zoom,i==null?void 0: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 x=i!=null&&i.animation?i.animation:{};x.easing||(x.easing="easeOutCubic");const g=I({},x);return Gt(this.state,v,x),Et(this.state,h,g),Ki(this.state,0,x),this}update(){const e=this.state,{time:t,userHasInteracted:i}=e,o=this.values,r={};hc.forEach(c=>{let d=e[c];c==="zoom"&&e.zoomTypePreserving==="styleZoom"&&(d=e.styleZoom),r[`${c}start`]=!o[`is${c}Changing`]&&!this.areEqual(d,o[`${c}1`])&&this.areEqual(o[`${c}1`],o[`${c}2`]),r[`${c}start`]&&(o[`is${c}Changing`]=!0),o[`is${c}Changing`]&&(r[c]=!this.areEqual(d,o[`${c}1`]),t-o[`${c}EndTime`]>Lx&&(r[`${c}end`]=this.areEqual(d,o[`${c}End1`])&&!this.areEqual(o[`${c}End1`],o[`${c}End2`]),r[`${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`)}),r.resize=!this.areEqual(e.size,o.size),this.copyFromStateToValues(e.size,"size"),r.movestart=(r.zoomstart||r.rotationstart||r.centerstart||r.pitchstart)&&!o.isMoveChanging,r.movestart&&(o.isMoveChanging=!0),r.move=o.iszoomChanging||o.isrotationChanging||o.iscenterChanging||o.ispitchChanging,r.moveend=(r.zoomend||r.rotationend||r.centerend||r.pitchend)&&!r.move,r.moveend&&(o.isMoveChanging=!1);const a=o.isIdle,l=o.isReady;o.isIdle=this.isIdle(),o.isReady=this.isReady(),r.idle=!a&&o.isIdle,r.ready=!l&&o.isReady,e.metrics.ready===void 0&&this.isReadyForMetrics()&&(e.metrics.ready=performance.now()-e.metrics.start);for(const c in r){const d=c;r[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=ti()?"light":e.graphicsPreset;this.state.styleState=$n(e,this.getGraphicsPresetFeatures(o))}else this.state.styleState=$n(e);i(),this.updateDataToggle(),this.modules.renderer.addRerenderEvent()}getStyleState(){return I({},this.state.styleState)}patchStyleState(e){if(this.state.graphicsPresetMode){const t=ti()?"light":e.graphicsPreset;this.state.styleState=Hl(this.state.styleState,e,this.getGraphicsPresetFeatures(t))}else this.state.styleState=Hl(this.state.styleState,e);this.updateDataToggle(),this.modules.renderer.addRerenderEvent()}setOption(e,t){if(Js.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(Js.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(){var f,m,p;this.modules.renderer.addRerenderEvent();const{drawCount:e,vertexCount:t,triangleCount:i}=this.state.stats,r=598044/(this.state.size[0]*this.state.size[1]/window.devicePixelRatio),a=[{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*r,c=t*r,d=i*r,_=((f=a.find(v=>v.draws[0]<=l&&v.draws[1]>=l))==null?void 0:f.level)||0,u=((m=a.find(v=>v.vertcles[0]<=c&&v.vertcles[1]>=c))==null?void 0:m.level)||0,h=((p=a.find(v=>v.triangles[0]<=d&&v.triangles[1]>=d))==null?void 0:p.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!=null?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 ex.reduce((t,i)=>(t[i]=this.getFeatureFlag(i,e),t),{})}setCustomStyleById(e,t){return K(this,null,function*(){this.currentPendingStyle=e;const{iconUrl:i,styleServer:o,fontUrl:r,modelUrl:a}=this.state,l=n.applyDefaults(t||{},{rootUrl:o,stylePath:n.styles.path,iconsPath:i,fontsPath:r,modelsPath:a}),c=yield 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 yield this.setCustomStyle(d,l),_})}setCustomStyleFromUrl(e,t){return K(this,null,function*(){this.currentPendingStyle=e;const i=n.applyDefaults(t||{},{rootUrl:e,iconsPath:"",fontsPath:"",stylePath:"style.json",modelsPath:""}),o=yield Bx(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 yield this.setCustomStyle(o,i),e})}setCustomStyleDirectly(e,t){const i=window.location.protocol,o=window.location.host,r=n.applyDefaults(t||{},{rootUrl:`${i}//${o}`,stylePath:"",iconsPath:"",fontsPath:"",modelsPath:""});this.currentPendingStyle=`__${Date.now()}__${performance.now()}__`;const a=e&&JSON.parse(JSON.stringify(e));return this.setCustomStyle(a,r)}setCustomStyle(e,t){return K(this,null,function*(){if(!e)throw new Error("Can't set empty style");const i=this.currentPendingStyle||"";this.currentPendingStyle=void 0;const o=yield Cx(e,this.state.tileKey,t);if(this.currentPendingStyle!==void 0)return;const r=this.modules.styleManager.createStyle(o,t);this.state.handyStyleId=r.id,this.state.styleId=i,this.patchStyleState({}),this.core.activateStyleUpdating()})}copyFromStateToValues(e,t){Ni(e)?n.copy$3(this.values[t],e):this.values[t]=e}cloneFromStateToValues(e,t){const i=this.state[e];Ni(i)?this.values[t]=n.clone(i):this.values[t]=i}copyFromValuesToValues(e,t){const i=this.values[t];Ni(i)?n.copy$3(this.values[e],i):this.values[e]=i}areEqual(e,t){return Ni(e)&&Ni(t)?n.exactEquals$1(e,t):e===t}fetchStyleById(e,t){return K(this,null,function*(){const i=new URL(n.template(e,{id:t}));i.searchParams.append("key",this.state.tileKey);const o=yield fetch(i.toString());if(o.status===404){console.warn(`No access to style with id «${t}».`);return}if(!o.ok)return;const r=yield o.json();if(r&&r.result)return{loadedId:t,style:r.result}})}updateDataToggle(){this.modules.defaultSource.setDataType(this.state.styleState.immersiveRoadsOn?Px:void 0)}}function Bx(s){return fetch(s).then(e=>{if(e.ok)return e.json()})}function Ni(s){return s.length!==void 0}const fc={extraReplicas:[NaN,NaN],tile:[0,0,0,0],mapPoint:[0,0],geoPoint:[0,0]};class mc extends Ye{constructor(e,t,i){super(e,t),this.length=1,this.isGeometryOutOfMainReplica=!1,this.wasGlobeLineHidden=!1,this.tileCache={parts:void 0,zoom:NaN,length:NaN,points:void 0,objectsByPart:new Map,generatedPartsRef:void 0},this.removed=!1,this.baseOptions=t,this.dynamicStyleId=this.modules.dynamicStyle.getStyle().id,this.geoPoints=t.coordinates.filter((o,r,a)=>r===0||!n.exactEquals$2(a[r],a[r-1])),this.points=this.geoPoints.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.initDistances(),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(ce(I({beginningIsCut:0,endingIsCut:0},i),{db_tiers:t.tiers}))}get tileProps(){return n.fixedMetatile.tileProps}update(){if(!this.removed){if(super.update(),this.mapState.globeMode&&!this.hasVisibleTileParts()){this.wasGlobeLineHidden||(this.cleanTileObjects(!1),this.wasGlobeLineHidden=!0);return}this.wasGlobeLineHidden?(this.wasGlobeLineHidden=!1,this.stateDiffer.check(this.mapState),this.generate()):this.stateDiffer.check(this.mapState)&&this.debouncedGenerate(),this.animationTickerName&&this.updateShowTicker(this.animationTickerName)}}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}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.destroyCachedObjects(new Set(this.tileObjects)),this.removeStyleLayers(),super.destroy())}initDistances(){let e=0;this.distances.push(e);for(let t=1;t<this.geoPoints.length;t++)e+=n.geoPointsDistance(this.geoPoints[t-1],this.geoPoints[t]),this.distances.push(e)}initShowAnimation(e,t){const i=this.baseOptions;i.showAnimation&&i.showAnimation.animate!==!1&&this.points.length>1&&(this.distances.length||this.initDistances(),this.animationTickerName=`${e}-${this.uniqId}`,t&&this.startShowTicker(this.animationTickerName,t))}startShowTicker(e,t){var c,d,_;const r=this.baseOptions,a=((c=r.showAnimation)==null?void 0:c.easing)!==void 0?r.showAnimation.easing:"linear",l=((d=r.showAnimation)==null?void 0:d.duration)!==void 0?r.showAnimation.duration:250;n.start(e,{easing:a,animationGroup:(_=r.showAnimation)==null?void 0:_.animationGroup},this.mapState,0,1,l,1,{layerId:t,styleId:this.dynamicStyleId}),this.length=0}updateShowTicker(e){const t=this.baseOptions;n.update(e,{step:(i,o)=>{var a,l,c,d;const r=n.affineStep(((l=(a=t.showAnimation)==null?void 0:a.durationRange)==null?void 0:l.start)||0,((d=(c=t.showAnimation)==null?void 0:c.durationRange)==null?void 0:d.end)||1,o);r!==this.length&&(this.length=r,this.generate())}},this.mapState)}splitIntoTileParts(e){const t=Math.min(Math.floor(this.modules.map.getZoom()),e),i=this.tileCache;if(i.parts!==void 0&&i.zoom===t&&i.length===this.length&&i.points===this.points)return i.parts;const o=n.tileZoomToSize(t),r=n.splitPolylineByLength(this.points,this.distances,this.length),a=n.splitPolylineByMaxSize(r,o),l=n.create$1(),c=n.create(),d=[];for(const _ of a){n.reset(c);for(let p=0;p<_.length;p++)n.expandByPoint(c,_[p]);n.center(l,c);const u=n.getTileCoordsByCenterAndZoom(l,t),h=n.createTileInfo(u),f=[],m=[];for(let p=0;p<_.length;p++)n.mapPointToTilePoint(l,_[p],h),f[p]=l[0],m[p]=l[1];d.push({vertices:{x:f,y:m},tileInfo:h,mapPoints:_})}return this.tileCache.parts=d,this.tileCache.zoom=t,this.tileCache.length=this.length,this.tileCache.points=this.points,d}cleanTileObjects(e){const{tileManager:t}=this.modules;this.tileObjects.forEach(i=>{i.clean(this.mapState),t.removeObject(i,e)}),this.tileObjects=[],this.destroyCachedObjects()}tryVisibilityOnlyUpdate(e,t){if(e!==this.tileCache.generatedPartsRef||this.tileCache.objectsByPart.size===0)return!1;const{tileManager:i}=this.modules;for(const o of this.tileObjects)i.removeObject(o,t);this.tileObjects=[],this.identifyIds=[];for(let o=0;o<e.length;o++){const{tileInfo:r}=e[o];if(this.isTileReplicaVisible(r.coords)){const a=this.tileCache.objectsByPart.get(o);if(!a){for(const l of this.tileObjects)i.removeObject(l,t);return this.tileObjects=[],this.identifyIds=[],!1}i.addObject(a.tileObject,t),this.tileObjects.push(a.tileObject),this.interactive&&a.identifyIds&&this.identifyIds.push(a.identifyIds)}}return this.interactive&&this.modules.identifier.resetCache(),t||this.modules.renderer.addRerenderEvent(),!0}makeCtx(e){return n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,this.tileAttrs,n.emptyFeatureAttrs,this.interactive?"0":"",e)}collectTileObject(e,t,i){const{collector:o,tileManager:r}=this.modules,a=o.getAccumulatedData(),l=new n.TileObject("dynamicObject",a.data,this.modules,this.mapState,e.coords,this);r.addObject(l,t),this.tileObjects.push(l),i!==void 0&&this.tileCache.objectsByPart.set(i,{tileObject:l,identifyIds:this.interactive?a.identifyIds:void 0}),this.interactive&&this.identifyIds.push(a.identifyIds)}saveTilePartsCache(e){this.tileCache.generatedPartsRef=e}finishGeneration(e){this.interactive&&this.modules.identifier.resetCache(),this.modules.collector.reset(),e||this.modules.renderer.addRerenderEvent()}prepareGeneration(e){if(this.points.length<2||this.removed)return;const t=!!this.animationTickerName,i=this.splitIntoTileParts(e);if(this.mapState.globeMode&&!this.hasVisibleTileParts()){this.cleanTileObjects(t);return}if(!this.tryVisibilityOnlyUpdate(i,t))return this.cleanTileObjects(t),{tileParts:i,skipRerender:t}}isTileReplicaVisible(e){const t=Math.pow(2,e[2]),i=this.mapState.visibleMapReplicas,o=this.isOutOfMainReplica(),{extraReplicas:r,tile:a,mapPoint:l,geoPoint:c}=fc;r[0]=o?i[0]-1:NaN,r[1]=o?i[i.length-1]+1:NaN,a[1]=e[1],a[2]=e[2],a[3]=e[3];const d=n.tileZoomToSize(e[2]),_=d/2,u=e[1]*d-n.HALF_WORLD_SIZE;for(let h=-1;h<=i.length;h++){const f=h===-1?r[0]:h===i.length?r[1]:i[h];if(!Number.isNaN(f)){if(a[0]=e[0]+f*t,this.mapState.globeMode){if(l[0]=a[0]*d-n.HALF_WORLD_SIZE+_,l[1]=u+_,n.Mercator.toGeo(l,c),this.modules.camera.ecef.canSee(c)&&n.isTileOnSphereInViewport(this.mapState,this.modules.camera,a))return!0}else if(n.isTileVisible(a,this.mapState.tilesBounds,this.modules))return!0}}return!1}hasVisibleTileParts(){const e=this.tileCache.parts;if(e===void 0||e.length===0)return!0;const t=this.modules.camera.ecef,{geoPoint:i}=fc;for(const o of e){const r=o.mapPoints;if(n.Mercator.toGeo(r[0],i),t.canSee(i)||(n.Mercator.toGeo(r[r.length-1],i),t.canSee(i)))return!0}return!1}destroyCachedObjects(e){for(const t of this.tileCache.objectsByPart.values())e!=null&&e.has(t.tileObject)||t.tileObject.destroyed||t.tileObject.clean(this.mapState);this.tileCache.objectsByPart.clear(),this.tileCache.generatedPartsRef=void 0}}const pc=0,zx=-1,Rx=-2,vc=3,Fx=0,Dx=0,Ox="#3388ff",Nx="#00000000",kx="#00000000";let gc=class extends mc{constructor(e,t){var a,l,c,d,_,u,h,f,m,p,v,x,g;super(e,t,{}),this.options=t;const{dynamicStyle:i,layers:o}=this.modules;if(this.options.width!==0){this.rawStyleLayer={type:"line",id:`dynamic-polyline-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:(a=this.options.color)!=null?a:Ox,width:(l=this.options.width)!=null?l:vc},gpuState:this.options.renderingMode!=="3d"?this.options.gpuState:{depthTest:!0}};const y=n.makeHandyStyleLayer(this.rawStyleLayer);if(y&&(this.styleLayerId=y.innerId,i.addLayer(y,(c=this.options.zIndex)!=null?c:pc)),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:(d=this.options.width)!=null?d:vc},gpuState:{depthTest:!0,depthMask:!1,cullFace:!1,depthFunc:n.DEPTH_FUNC.GREATER}};const b=n.makeHandyStyleLayer(this.rawHiddenStyleLayer);b&&(this.styleHiddenLayerId=b.innerId,i.addLayer(b,(_=this.options.zIndex)!=null?_:pc))}}if(this.options.width2){this.rawStyleLayer2={type:"line",id:`dynamic-polyline2-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:(u=this.options.color2)!=null?u:Nx,width:(h=this.options.width2)!=null?h:Fx},gpuState:this.options.renderingMode!=="3d"?this.options.gpuState:{depthTest:!0}};const y=n.makeHandyStyleLayer(this.rawStyleLayer2);y&&(this.styleLayer2Id=y.innerId,i.addLayer(y,(f=this.options.zIndex2)!=null?f:zx))}if(this.options.width3){this.rawStyleLayer3={type:"line",id:`dynamic-polyline3-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:(m=this.options.color3)!=null?m:kx,width:(p=this.options.width3)!=null?p:Dx},gpuState:this.options.renderingMode!=="3d"?this.options.gpuState:{depthTest:!0}};const y=n.makeHandyStyleLayer(this.rawStyleLayer3);y&&(this.styleLayer3Id=y.innerId,i.addLayer(y,(v=this.options.zIndex3)!=null?v:Rx))}if(this.styleLayerId===void 0&&this.styleLayer2Id===void 0&&this.styleLayer3Id===void 0)return;const r=(g=(x=this.styleLayer3Id)!=null?x:this.styleLayer2Id)!=null?g:this.styleLayerId;this.initShowAnimation("polyline",r),o.addLayer(this),this.generate()}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,r=this.points.map(u=>t(u));let a=1/0,l=r[0],c=0;for(const u of o){const h=t(this.modules.camera.flat.unproject(e),u);for(let f=0;f<r.length-1;f++){const m=r[f],p=r[f+1],v=n.getClosestPointOnLineSegment(h,m,p),x=v[0]-h[0],g=v[1]-h[1],y=x*x+g*g;y<a&&(a=y,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)}removeStyleLayers(){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)}generate(){const e=this.prepareGeneration(15);if(!e)return;const{tileParts:t,skipRerender:i}=e,{dynamicStyle:o,collector:r}=this.modules,{tileProps:a}=this;for(let l=0;l<t.length;l++){const{vertices:c,tileInfo:d}=t[l];if(!this.isTileReplicaVisible(d.coords))continue;if(this.options.displayTileBounds){const f=o.getStyle().layers.find(v=>v.id==="debug-tile-bounds");n.generateTileBounds(r,f,this.mapState.styleState);const m=r.getAccumulatedData(),p=new n.TileObject("dynamicObject",m.data,this.modules,this.mapState,d.coords);this.tileObjects.push(p),this.modules.tileManager.addObject(p,i)}this.tileAttrs[a.beginningIsCut]=0,this.tileAttrs[a.endingIsCut]=0,l!==0&&(this.tileAttrs[a.beginningIsCut]=1),l+1!==t.length&&(this.tileAttrs[a.endingIsCut]=1);const _=this.makeCtx(d),u=h=>{if(h===void 0)return;const f=o.getStyle().layersById[h];n.isLineStyleLayer(f)&&(n.runPrecomputes(f,_),n.generateSafely({collector:r,generator:n.LineGenerator.generate,args:[o.getStyle().id,f,_,d,c]}))};u(this.styleLayerId),u(this.styleHiddenLayerId),u(this.styleLayer2Id),u(this.styleLayer3Id),this.collectTileObject(d,i,l)}this.saveTilePartsCache(t),this.finishGeneration(i)}setSubLayerStyle(e,t,i){if(e!==void 0&&i&&t&&i!==t.style.color){const{dynamicStyle:o}=this.modules;t.style.color=i;const r=n.makeHandyStyleLayer(t);r&&(o.updateLayerStyle(e,r),this.modules.renderer.addRerenderEvent())}}};const Ux=0,Hx=-1,yc=8,xc=12,Gx="#2480ff",Vx="#ffffff",bc=6,wc=20,jx="#ffffff00";class Sc extends mc{constructor(e,t){var o,r,a,l,c,d,_,u,h,f,m;super(e,t,{previousPointX:0,previousPointY:0,nextPointX:0,nextPointY:0,componentDistanceStart:0,objectLength:0}),this.options=t;const{layers:i}=this.modules;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||Gx,dashLength:(o=this.options.dashLength)!=null?o:bc,gapColor:this.options.gapColor||jx,gapLength:(r=this.options.gapLength)!=null?r:wc,width:(a=this.options.width)!=null?a:yc},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||Vx,width:(c=(l=this.options)==null?void 0:l.width2)!=null?c:xc},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:(d=this.options.dashLength)!=null?d:bc,gapColor:this.options.hiddenPartGapColor,gapLength:(_=this.options.gapLength)!=null?_:wc,width:(u=this.options.width)!=null?u:yc},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:(f=(h=this.options)==null?void 0:h.width2)!=null?f:xc},gpuState:{depthTest:!0,depthMask:!1,cullFace:!1,depthFunc:n.DEPTH_FUNC.GREATER}},this.hiddenBaseLayer=n.makeHandyStyleLayer(this.hiddenBaseLayerRaw))),this.initShowAnimation("dashedLine",(m=this.baseLayer)==null?void 0:m.innerId),this.generate()}setStyle(e){const{dashColor:t,dash2Color:i,gapColor:o,hiddenPartDashColor:r,hiddenPartGapColor:a,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){r!==void 0&&(this.hiddenDashLayerRaw.style.color=r),o!==void 0&&(this.hiddenDashLayerRaw.style.gapColor=a);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()}removeStyleLayers(){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)}generate(){const e=this.prepareGeneration(12);if(!e)return;const{tileParts:t,skipRerender:i}=e,{dynamicStyle:o}=this.modules,{tileProps:r}=this;let a=0;const l=[],c=n.create$1();for(const{vertices:u}of t){let h=0;const{x:f,y:m}=u;for(let p=1;p<f.length;p++){const v=f[p]-f[p-1],x=m[p]-m[p-1];h+=Math.sqrt(v*v+x*x)}l.push(h),a+=h}let d=0;const _=this.makeCtx();t.forEach((u,h)=>{const{tileInfo:f,vertices:m}=u,p=l[h];if(this.tileAttrs[r.beginningIsCut]=0,this.tileAttrs[r.endingIsCut]=0,this.tileAttrs[r.previousPointX]=0,this.tileAttrs[r.previousPointY]=0,this.tileAttrs[r.nextPointX]=0,this.tileAttrs[r.nextPointY]=0,this.tileAttrs[r.componentDistanceStart]=d,d+=p,this.tileAttrs[r.objectLength]=a,h!==0){const g=t[h-1].mapPoints,y=g[g.length-2];n.mapPointToTilePoint(c,y,f),this.tileAttrs[r.beginningIsCut]=1,this.tileAttrs[r.previousPointX]=c[0],this.tileAttrs[r.previousPointY]=c[1]}if(h!==t.length-1){const y=t[h+1].mapPoints[1];n.mapPointToTilePoint(c,y,f),this.tileAttrs[r.endingIsCut]=1,this.tileAttrs[r.nextPointX]=c[0],this.tileAttrs[r.nextPointY]=c[1]}if(!this.isTileReplicaVisible(f.coords))return;_.tileInfo=f;const v=g=>{var b;if(g===void 0)return;const y=(b=this.options.zIndex)!=null?b:Ux;o.addLayer(g,y),n.runPrecomputes(g,_),n.generateSafely({collector:this.modules.collector,generator:n.DashedLineGenerator.generate,args:[this.dynamicStyleId,g,_,m]})},x=g=>{var b;if(g===void 0)return;const y=(b=this.options.zIndex2)!=null?b:Hx;o.addLayer(g,y),n.runPrecomputes(g,_),n.generateSafely({collector:this.modules.collector,generator:n.LineGenerator.generate,args:[this.dynamicStyleId,g,_,f,m]})};v(this.dashLayer),x(this.baseLayer),v(this.hiddenDashLayer),x(this.hiddenBaseLayer),this.collectTileObject(f,i,h)}),this.saveTilePartsCache(t),this.finishGeneration(i)}}const Zx="#3388ff33",$x="#3388ff",Wx=3;let Tc=class extends Ye{constructor(e,t){if(super(e,t),this.isGeometryOutOfMainReplica=!1,this.options=t,!this.verifyCoordinates()){console.warn(`Invalid coordinates for Polygon dynamic object with id ${this.uniqId} and options:`,t,"Polygon will not be created.");return}const i=this.options.coordinates.map(v=>{const x=v.map(g=>n.Mercator.fromGeo(g));if(x.length>1){const g=x[0],y=x[x.length-1];(g[0]!==y[0]||g[1]!==y[1])&&x.push(g)}return x});let o=[];const r=[],{dynamicStyle:a,layers:l}=this.modules;i.forEach(v=>{o.length&&r.push(o.length),o=o.concat(v)}),this.isGeometryOutOfMainReplica=o.some(v=>v[0]>n.HALF_WORLD_SIZE||v[0]<-n.HALF_WORLD_SIZE);const c=n.makeHandyStyleLayer({type:"polygon",id:`dynamic-polygon-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.color||Zx}});if(!c)return;a.addLayer(c,this.options.zIndex),this.fillLayerId=c.innerId;const d=n.optionsToTileAttrs({beginningIsCut:0,endingIsCut:0,db_tiers:t.tiers});let _;if(this.options.strokeWidth!==0){const v=n.makeHandyStyleLayer({type:"line",id:`dynamic-polygon-stroke-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.strokeColor||$x,width:this.options.strokeWidth||Wx}});v&&(_=v,a.addLayer(_,this.options.zIndex),this.borderLayerId=_.innerId)}const u=n.create();for(let v=0;v<o.length;v++)n.expandByPoint(u,o[v]);const h=n.getBoundsTileCoords(u),f=n.createTileInfo(h),m=[];for(let v=0;v<o.length;v++)m.push(o[v][0]),m.push(o[v][1]);const p=n.earcut(m,r);this.generationState={polygonLayer:c,borderLayer:_,rings:i,points:o,tileAttrs:d,tileInfo:f,trianglesIndexes:p,asEcef:xe(this.mapState)},this.generate(),l.addLayer(this)}update(){if(super.update(),this.generationState===void 0)return;const e=xe(this.mapState);e!==this.generationState.asEcef&&(this.regenerate(),this.generationState.asEcef=e),this.updateGlobeVisibility(this.options.coordinates[0][0])}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()}generate(){if(this.generationState===void 0)return;const{polygonLayer:e,borderLayer:t,rings:i,points:o,trianglesIndexes:r,tileAttrs:a,tileInfo:l}=this.generationState;if(o.length===0)return;const{dynamicStyle:c,collector:d,tileManager:_,identifier:u}=this.modules,h=xe(this.mapState),f=n.ecefDataStateFromBool(h),m=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,a,n.emptyFeatureAttrs,this.interactive?"0":"",h?l:void 0,f);n.runPrecomputes(e,m);const p=n.create$1(),v=[],x=[],g=[];for(let S=0;S<r.length;S+=3){for(let T=0;T<3;T++)n.mapPointToTilePoint(p,o[r[S+T]],l),v[T]=p[0],x[T]=p[1],g[T]=0;n.generateSafely({collector:d,generator:n.PolygonGenerator.generate,args:[c.getStyle().id,e,m,{x:v,y:x,cut:g},n.pixelRatioToDpi(window.devicePixelRatio),l,c.getStyle().rasterSets]})}t&&(n.runPrecomputes(t,m),i.forEach(S=>{const T=[],z=[];S.forEach((E,P)=>{n.mapPointToTilePoint(p,E,l),T[P]=p[0],z[P]=p[1]}),n.generateSafely({collector:d,generator:n.LineGenerator.generate,args:[c.getStyle().id,t,m,l,{x:T,y:z}]})}));const y=d.getAccumulatedData(),b=new n.TileObject("dynamicObject",y.data,this.modules,this.mapState,l.coords,this);b.ecefDataState=f,this.visibleOnGlobe&&_.addObject(b),this.tileObjects.push(b),this.interactive&&this.identifyIds.push(y.identifyIds),d.reset(),this.modules.renderer.addRerenderEvent(),this.interactive&&u.resetCache()}regenerate(){const{tileManager:e}=this.modules;for(const t of this.tileObjects)t.clean(this.mapState),e.removeObject(t);this.tileObjects=[],this.identifyIds=[],this.generate()}verifyCoordinates(){var t;const e=(t=this.options)==null?void 0:t.coordinates;return Array.isArray(e)&&Array.isArray(e[0])&&e[0].length>0}};const Xx="#3388ff33",Kx="#3388ff",qx=1,Yx=150;let Mc=class extends Ye{constructor(e,t){var v,x,g,y;if(super(e,t),this.isGeometryOutOfMainReplica=!1,this.options=t,t.segments&&t.segments<=0)return;const{dynamicStyle:i,layers:o}=this.modules,r=Qx(n.Mercator.fromGeo(this.options.coordinates),n.geoToMapDistance(this.options.coordinates,this.options.radius),(v=this.options.segments)!=null?v:Yx);this.isGeometryOutOfMainReplica=r.some(b=>b[0]>n.HALF_WORLD_SIZE||b[0]<-n.HALF_WORLD_SIZE);const a=n.makeHandyStyleLayer({type:"polygon",id:`dynamic-circle-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:(x=this.options.color)!=null?x:Xx,strokeWidth:(g=this.options.borderWidth)!=null?g:qx,strokeColor:(y=this.options.borderColor)!=null?y:Kx}});if(!a)return;i.addLayer(a,this.options.zIndex),this.layerId=a.innerId;const l=n.optionsToTileAttrs({db_tiers:this.options.tiers}),c=n.create();for(let b=0;b<r.length;b++)n.expandByPoint(c,r[b]);const d=n.getBoundsTileCoords(c),_=n.createTileInfo(d),u=[],h=[],f=[],m=n.create$1(),p=this.options.borderWidth!==0?1:0;for(let b=0;b<r.length;b++)n.mapPointToTilePoint(m,r[b],_),u[b]=m[0],h[b]=m[1],f[b]=p;this.generationState={circleLayer:a,asEcef:xe(this.mapState),tileAttrs:l,tileInfo:_,tilePoints:{x:u,y:h,cut:f}},this.generate(),o.addLayer(this)}update(){if(super.update(),this.generationState===void 0)return;const e=xe(this.mapState);e!==this.generationState.asEcef&&(this.regenerate(),this.generationState.asEcef=e),this.updateGlobeVisibility(this.options.coordinates)}remove(){this.interactive&&this.modules.identifier.resetCache(),this.layerId&&this.modules.dynamicStyle.removeLayer(this.layerId),super.destroy()}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}generate(){if(this.generationState===void 0)return;const{circleLayer:e,tileAttrs:t,tileInfo:i,tilePoints:o}=this.generationState,{dynamicStyle:r,collector:a,tileManager:l,identifier:c}=this.modules,d=xe(this.mapState),_=n.ecefDataStateFromBool(d),u=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,t,n.emptyFeatureAttrs,this.interactive?"0":"",d?i:void 0,_);n.runPrecomputes(e,u),n.generateSafely({collector:a,generator:n.PolygonGenerator.generate,args:[r.getStyle().id,e,u,o,n.pixelRatioToDpi(window.devicePixelRatio),i]});const h=a.getAccumulatedData(),f=new n.TileObject("dynamicObject",h.data,this.modules,this.mapState,i.coords,this);f.ecefDataState=_,l.addObject(f),this.tileObjects.push(f),this.interactive&&this.identifyIds.push(h.identifyIds),a.reset(),this.modules.renderer.addRerenderEvent(),this.interactive&&c.resetCache()}regenerate(){const{tileManager:e}=this.modules;for(const t of this.tileObjects)t.clean(this.mapState),e.removeObject(t);this.tileObjects=[],this.identifyIds=[],this.generate()}};function Qx(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 r=o;r<Math.PI;r+=o){const a=e*Math.cos(r),l=e*Math.sin(r);i.push(n.fromValues(s[0]+a,s[1]+l,s[2]),n.fromValues(s[0]+a,s[1]-l,s[2]))}i.push(n.fromValues(s[0]-e,s[1],s[2]))}return i}function Gs(s,e,t,i,o,r){if(o-i<=t)return;const a=i+o>>1;Ec(s,e,a,i,o,r%2),Gs(s,e,t,i,a-1,r+1),Gs(s,e,t,a+1,o,r+1)}function Ec(s,e,t,i,o,r){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));Ec(s,e,t,m,p,r)}const a=e[2*t+r];let l=i,c=o;for(ki(s,e,i,t),e[2*o+r]>a&&ki(s,e,i,o);l<c;){for(ki(s,e,l,c),l++,c--;e[2*l+r]<a;)l++;for(;e[2*c+r]>a;)c--}e[2*i+r]===a?ki(s,e,i,c):(c++,ki(s,e,c,o)),c<=t&&(i=c+1),t<=c&&(o=c-1)}}function ki(s,e,t,i){Vs(s,t,i),Vs(e,2*t,2*i),Vs(e,2*t+1,2*i+1)}function Vs(s,e,t){const i=s[e];s[e]=s[t],s[t]=i}function Jx(s,e,t,i,o,r,a){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<=a){for(let v=f;v<=h;v++)d=e[2*v],_=e[2*v+1],d>=t&&d<=o&&_>=i&&_<=r&&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&&_<=r&&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:r>=_)&&(l.push(m+1),l.push(h),l.push(p))}return c}function Ax(s,e,t,i,o,r){const a=[0,s.length-1,0],l=[],c=o*o;for(;a.length;){const d=a.pop(),_=a.pop(),u=a.pop();if(_-u<=r){for(let v=u;v<=_;v++)Ic(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];Ic(f,m,t,i)<=c&&l.push(s[h]);const p=(d+1)%2;(d===0?t-o<=f:i-o<=m)&&(a.push(u),a.push(h-1),a.push(p)),(d===0?t+o>=f:i+o>=m)&&(a.push(h+1),a.push(_),a.push(p))}return l}function Ic(s,e,t,i){const o=s-t,r=e-i;return o*o+r*r}const eb=s=>s[0],tb=s=>s[1];class ib{constructor(e,t=eb,i=tb,o=64,r=Float64Array){this.nodeSize=o,this.points=e;const a=e.length<65536?Uint16Array:Uint32Array,l=this.ids=new a(e.length),c=this.coords=new r(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]);Gs(l,c,o,0,l.length-1,0)}range(e,t,i,o){return Jx(this.ids,this.coords,e,t,i,o,this.nodeSize)}within(e,t,i){return Ax(this.ids,this.coords,e,t,i,this.nodeSize)}}function nb(s,e,t){const i=[],o=[],r=[],a=n.create$1();return e.forEach(({mapCoords:l,weight:c})=>{ob(a,l,t);const d=a[0],_=a[1];for(let u=0;u<6;u++)i.push(d,_),r.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(r),{itemSize:1,dataType:n.Buffer.Float,stride:0,offset:0,normalized:!1})}}function ob(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 sb(s,e){const t=rb(s),i=ab(t,e);return new w(new Uint8Array(i),{size:[e,1]})}function rb(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 r=Math.min(...i),a=Math.max(...i);return r>0&&(o[0]=o[r]),a<1&&(o[1]=o[a]),o}function ab(s,e){const t=Object.keys(s).map(a=>Number(a)).sort((a,l)=>a-l);let i=0;const o=[],r=e-1;for(let a=0;a<e;a++){const l=a/r;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[a*4+f]=cb(s[c].value[f],s[d].value[f],h)}return o.map(a=>Math.round(a))}function lb(s,e){return s.every((t,i)=>t===e[i])}function cb(s,e,t){return s*(1-t)+e*t}const db=256,_b=.5,ub=3,hb=10,fb=1,mb=1,pb={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 vb extends Ye{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&&lb(v,this.tileCoords))return;this.resetBuffers(),this.tileCoords=v;const x=n.tileZoomToSize(v[2]),g=n.tileCoordsToMapPoint(v);n.fromTranslationScale(this.matrix,g,n.fromValues(x,x,n.tileHeight));const y=this.tree.range(g[0],g[1],g[0]+x,g[1]+x).map(S=>this.points[S]),b=n.createTileInfo(v);this.buffers=nb(this.modules.renderer,y,b),this.vertexCount=y.length*6,this.vao=new H(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:r,minZoom:a,maxZoom:l,zIndex:c,pointRadius:d,intensity:_,opacity:u}=t;this.rampTextureIndex=this.modules.imageManager.addPreparedTexture(sb(o!=null?o:pb,db)),this.downscale=i!=null?i:mb,this.frameBuffer=new Ce({size:[Math.ceil(this.mapState.size[0]*window.devicePixelRatio/this.downscale),Math.ceil(this.mapState.size[1]*window.devicePixelRatio/this.downscale)],magFilter:w.LinearFilter,minFilter:w.LinearFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.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:a,maxzoom:l,style:{opacity:u!=null?u:_b,intensity:_!=null?_:ub,radius:d!=null?d:hb}});if(!f)throw new Error("There is no correct style layer for heatmap");this.layer=f,this.modules.dynamicStyle.addLayer(f,c),r&&this.setPoints(r)}isOutOfMainReplica(){return!1}setPoints(e){if(!this.isDestroyed){if(this.points=e.map(({coordinates:t,weight:i})=>({mapCoords:n.Mercator.fromGeo(t),weight:i!=null?i:fb})),this.tree=new ib(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:r}=this.modules;n.generateSafely({collector:i,generator:n.HeatmapGenerator.generateTexture,args:[o.getStyle().id,this.layer,this.offscreenTextureIndex,this.rampTextureIndex]});const a=i.getAccumulatedData(),l=new n.TileObject("dynamicObject",a.data,this.modules,this.mapState);r.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.modules.renderer.resetStateAfterExternalRender(),this.throttledFillBuffer(e),!this.vao||!this.buffers||!this.tree||!this.tileCoords)return;const r=n.makeBinderContext(i,o,[]),a=n.resolveNumber(this.layer.style.radius,r),l=n.resolveNumber(this.layer.style.intensity,r),c=n.tileSizeZpt*Math.pow(2,t-this.tileCoords[2])*window.devicePixelRatio;this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||vr(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:a*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(Zr),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 gb="#000000",yb=0,xb="#ffffff",bb=0,Cc=[0,0],wb=0,Sb=[0,0,0,0],js=-1;class Zs extends Ye{constructor(e,t,i){var R,C,F,se,Q,le,D,Ke,Se,ye,Ue,Ze,Rt;super(e,{interactive:(R=t.interactive)!=null?R:!1},i),this.hovered=!1,this.lastLabelingRevision=js,this.imageLabelBoxAdjusted=!1,this.generationId=0,this.status="visible",this.labelingStatus=0,this.options=t,this.labelKey=`point-label-${this.uniqId}`;const o=(C=t.font)!=null?C:n.DEFAULT_FONT,r=(F=t.fontSize)!=null?F:n.fonts.baseSize,a=(se=t.letterSpacing)!=null?se:bb,l=(Q=t.lineHeight)!=null?Q:n.fonts.baseLineHeight,c=[(D=(le=this.options.offset)==null?void 0:le[0])!=null?D:Cc[0],(Se=(Ke=this.options.offset)==null?void 0:Ke[1])!=null?Se:Cc[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:r,textColor:(ye=t.color)!=null?ye:gb,textHaloWidth:(Ue=t.haloRadius)!=null?Ue:yb,textHaloColor:(Ze=t.haloColor)!=null?Ze:xb,textLetterSpacing:a,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:x}=this.modules,g=(Rt=this.options.zIndex)!=null?Rt:wb;u.addLayer(d,g);const y=n.optionsToTileAttrs({db_label:this.options.text}),b=n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),S={x:[0],y:[0]},T=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedMetatile.tileProps,y,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(d,T),n.generateSafely({collector:h,generator:n.preLabelingPoint,args:[u.getStyle(),d,T,n.fixedMetatile,n.LATEST_TILE_VERSION,b,x.getId(),S,n.pixelRatioToDpi(window.devicePixelRatio)]});const z=h.getAccumulatedData();if(!z.labels.length)return;const E=[{metatileHash:-1,labels:z.labels,styleId:u.getStyle().id}],P=n.unpackPreLabelingResult(E,n.LabelSource.DynamicObject,m,this.mapState.styleState,this.mapState.styleZoom);if(P.length!==1)return;const k=P[0];n.rtlAdapterPromise.then(()=>{var Le;k.label=(Le=n.processRTLTextIfNeeded(k.label))!=null?Le:"",k.updateRanges()}).then(()=>Promise.all(k.ranges.map(Le=>f.loadFont(o,Le)))).then(()=>{if(this.status==="destroyed")return;k.textMetrics=n.getTextMetrics(k.label,a,f.getFontGlyphs(o));const Le=Tb(t.anchor),Ft=r/n.fonts.baseSize,Me=r*l*k.textMetrics.lines.length,Dt=Ft*k.textMetrics.maxWidth,Mt=[-Dt*(Le[0]-.5),-Me*(Le[1]-.5)],[ei,$e]=c,vi=[ei+Mt[0],$e+Mt[1]];this.generationState={label:k,styleLayer:d,elementOffset:vi,textFont:o,textOffset:c,anchorOffset:Mt,labelMaxWidthInPx:Dt,labelHeightInPx:Me,asEcef:xe(this.mapState)};const Gi=this.generateTextTileObject(this.generationState);v.addLayer(this),this.interactive&&(this.identifyIds.push(z.identifyIds),this.modules.identifier.resetCache()),this.options.labeling&&this.options.labeling.type!=="none"?(this.labelBox={id:this.uniqId,width:Dt,height:Me,position:this.position.normalizedValue,offset:[vi[0]-Le[0]*Dt,vi[1]-Le[1]*Me],labelingGroup:"pointLabel"},this.addLabelToLabeler(),this.update()):this.status==="visible"&&p.addObject(Gi),this.modules.renderer.addRerenderEvent(),this.initImageIfNeed()})}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),$s(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.updateGlobeVisibility(this.options.coordinates)))return;const e=xe(this.mapState);if(this.generationState!==void 0&&e!==this.generationState.asEcef&&(this.regenerateGeometry(),this.generationState.asEcef=e),this.status!=="visible"||!this.labelBox||this.lastLabelingRevision===this.modules.labeler.getLabelingRevision())return;this.lastLabelingRevision=this.modules.labeler.getLabelingRevision();const t=this.modules.labeler.isLabelBoxSurvived(this.uniqId),i=this.labelingStatus;let o=n.LabelingAnimation.none;switch(this.labelingStatus){case 0:t?(this.addTilesToMap(),o=n.LabelingAnimation.none,this.labelingStatus=3):this.labelingStatus=1;break;case 1:t&&(this.addTilesToMap(),o=n.LabelingAnimation.fadeIn,this.labelingStatus=2);break;case 2:t?this.labelingStatus=3:(this.labelingStatus=4,o=n.LabelingAnimation.fadeOut);break;case 3:t||(o=n.LabelingAnimation.fadeOut,this.labelingStatus=4);break;case 4:t?(o=n.LabelingAnimation.fadeIn,this.labelingStatus=2):(this.removeTilesFromMap(),this.labelingStatus=1);break}i!==this.labelingStatus&&this.labelingStatus!==1&&this.tileObjects.forEach(r=>r.children.forEach(a=>{a.attributes.animDirection=o}))}regenerateGeometry(){if(this.generationState===void 0)return;const{tileManager:e}=this.modules,t=this.status==="visible"&&(!this.labelBox||this.labelingStatus===3||this.labelingStatus===2||this.labelingStatus===4);this.removeTilesFromMap(),this.tileObjects.length=0,this.imageLabelBoxAdjusted=!1;const i=++this.generationId,o=this.generateTextTileObject(this.generationState);t&&e.addObject(o),this.initImageIfNeed(i),this.modules.renderer.addRerenderEvent()}generateTextTileObject(e){const{collector:t,dynamicStyle:i}=this.modules,{label:o,elementOffset:r,styleLayer:a,textFont:l}=e,c=this.getTransformPosition();n.generateSafely({collector:t,generator:n.generateTextElement,args:[o,"",1,o.textMetrics,[0,0,0],0,r,a,i.getStyle().fontNameToIndex[l],window.devicePixelRatio,c]});const d=t.getAccumulatedData(),_=n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),u=new n.TileObject("dynamicObject",d.data,this.modules,this.mapState,_,this);return u.ecefDataState=n.ecefDataStateFromBool(xe(this.mapState)),$s(u,this.position.userValue[2]),this.tileObjects.push(u),t.reset(),u}getTransformPosition(){if(!xe(this.mapState))return;const e=n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),t=n.createTileInfo(e);return(i,o)=>n.encodeTilePointToEcefU16(t,i,o)}initImageIfNeed(e){return K(this,null,function*(){var R,C;if(!this.options.image||this.generationState===void 0)return;const{imageCache:t,dynamicStyle:i,collector:o,tileManager:r}=this.modules,a=window.devicePixelRatio,l=yield t.getRasterSet(this.options.image.url,void 0,this.options.image.size,[0,0]);if(!l||this.status==="destroyed"||e!==void 0&&e!==this.generationId)return;const c=l.rasters[0];i.appendRasterSet(l,n.getStaticIconRasterSetKey(this.options.image.url,0,0));const{labelMaxWidthInPx:d,labelHeightInPx:_,textOffset:u,anchorOffset:h,label:f}=this.generationState,[m,p,v,x]=this.options.image.padding||Sb,g=(d+x+p)*a,y=(_+m+v)*a,b=((p-x)/2+u[0]+h[0])*a,S=((v-m)/2+u[1]+h[1])*a,T=(R=this.options.image.stretchX)==null?void 0:R.map(([F,se])=>[F*a,se*a]),z=(C=this.options.image.stretchY)==null?void 0:C.map(([F,se])=>[F*a,se*a]),E=this.getTransformPosition();n.generateSafely({collector:o,generator:n.generateIconElement,args:[f,"",[0,0,0],0,c,g,y,b,S,window.devicePixelRatio,T,z,E]});const P=o.getAccumulatedData();o.reset();const k=new n.TileObject("dynamicObject",P.data,this.modules,this.mapState,n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this);k.ecefDataState=n.ecefDataStateFromBool(xe(this.mapState)),$s(k,this.position.userValue[2]),this.tileObjects.push(k),this.status!=="hidden"&&!this.labelBox&&r.addObject(k),this.labelBox&&(this.imageLabelBoxAdjusted||(this.imageLabelBoxAdjusted=!0,this.labelBox.height=_+m+v,this.labelBox.width=d+x+p,this.labelBox.offset[0]-=x,this.labelBox.offset[1]-=m,this.addLabelToLabeler()),this.labelingStatus!==1&&this.labelingStatus!==0&&(r.addObject(k),this.mapState.needRerender=!0),this.lastLabelingRevision=js)})}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=js)}removeLabelFromLabeler(){this.labelBox&&this.modules.labeler.removeLabels(this.labelKey)}}function Tb(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 $s(s,e){s.modelMatrices.forEach(t=>{t[14]=e})}const Mb=18,Eb=[.5,.5],Ib=[0,18],Cb=0,Lb=0;let Lc=class extends er{constructor(e,t){super(e,t,t.draggable),this.generatedAsEcef=!1,this.map=e,this.options=t;const{coordinates:i,size:o,zIndex:r,minZoom:a,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!=null?h:Lb),this.zIndex=r!==void 0?r:Cb,this.minZoom=a!=null?a:-1/0,this.maxZoom=l!=null?l:1/0;const v=t.icon!==void 0?t.icon:n.defaultMarkerIcon,x=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:x,size:o,opacity:f}).then(()=>{c!==void 0&&this.setHoverIconInternal({icon:c,anchor:_,size:d,opacity:m})}),this.setLabel(u)}destroy(){var e;this.status!=="destroyed"&&(this.status="destroyed",(e=this.label)==null||e.remove(),this.interactive&&this.modules.identifier.resetCache(),this.off("mouseover",this.switchToHoveredStyle),this.off("mouseout",this.switchToNormalStyle),super.destroy())}update(){super.update();const e=xe(this.mapState);(this.mapState.dpiChanged||e!==this.generatedAsEcef)&&(this.regenerate(),this.generatedAsEcef=e),this.updateGlobeVisibility(this.options.coordinates)}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"&&(Pc({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}Pc({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){var t,i,o,r,a;this.status!=="destroyed"&&((t=this.label)==null||t.remove(),e&&(this.label=new Zs(this.map,ce(I({coordinates:this.getCoordinates()},e),{minZoom:Math.max((i=e.minZoom)!=null?i:this.minZoom,this.minZoom),maxZoom:Math.min((o=e.maxZoom)!=null?o:this.maxZoom,this.maxZoom),fontSize:(r=e.fontSize)!=null?r:Mb,anchor:e.anchor||Eb,offset:e.offset||Ib,zIndex:(a=e.zIndex)!=null?a:this.zIndex+1e-5,interactive:this.interactive}),this)))}setCoordinates(e){var t;this.setPosition(n.Mercator.fromGeo(e)),(t=this.label)==null||t.setCoordinates(e)}getCoordinates(){return n.Mercator.toGeo(this.getPosition())}show(){var e;this.status==="hidden"&&((e=this.label)==null||e.show(),this.normalStateData&&(this.modules.tileManager.addObject(this.normalStateData.tileObject),this.modules.renderer.addRerenderEvent(),this.interactive&&this.modules.identifier.resetCache()),this.status="normal")}hide(){var t,i,o;if(this.status==="destroyed"||this.status==="hidden")return;(t=this.label)==null||t.hide();const e=this.status==="normal"?(i=this.normalStateData)==null?void 0:i.tileObject:(o=this.hoverStateData)==null?void 0:o.tileObject;e&&(this.modules.tileManager.removeObject(e),this.modules.renderer.addRerenderEvent(),this.interactive&&this.modules.identifier.resetCache()),this.status="hidden"}setPosition(e){if(this.position={userValue:e,normalizedValue:n.normalizeMapPoint(e)},!!this.tileObjects.length){if(xe(this.mapState)){this.regenerate();return}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,r=t!==void 0?t.anchor:i.anchor,a=this.modules.camera.flat.project(this.position.normalizedValue),l=a[0]-o[0]*r[0],c=a[0]+o[0]*(1-r[0]),d=a[1]-o[1]*r[1],_=a[1]+o[1]*(1-r[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:r}){const{zIndex:a,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:r,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,a),d.appendRasterSet(e,n.getStaticIconRasterSetKey(t,v[0],v[1]));const x=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedMetatile.tileProps,h,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(p,x),n.generateSafely({collector:c,generator:n.preLabelingPoint,args:[d.getStyle(),p,x,n.fixedMetatile,n.LATEST_TILE_VERSION,f,u.getId(),{x:[0],y:[0]},n.pixelRatioToDpi(window.devicePixelRatio)]});const{identifyIds:g,labels:y}=c.getAccumulatedData();if(!y.length)throw new Error(`Marker with icon ${t} was created with empty labels`);const b=[{metatileHash:-1,labels:y,styleId:d.getStyle().id}],S=n.unpackPreLabelingResult(b,n.LabelSource.DynamicObject,_,this.mapState.styleState,this.mapState.styleZoom);if(S.length!==1)throw new Error(`Marker with icon ${t} has empty unpacked labels`);const T=S[0],z=n.createTileInfo(f),E=xe(this.mapState)?(R,C)=>n.encodeTilePointToEcefU16(z,R,C):void 0;n.generateNotStretchableIconElement(c,T,"",[0,0,m],0,e.rasters[0],window.devicePixelRatio,E);const{data:P}=c.getAccumulatedData();c.reset();const k=new n.TileObject("dynamicObject",P,this.modules,this.mapState,f,this);return k.ecefDataState=n.ecefDataStateFromBool(xe(this.mapState)),{styleLayer:p,tileObject:k,identifyIds:g,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]}}setIconInternal(e){return K(this,null,function*(){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"&&this.visibleOnGlobe&&(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})})}setHoverIconInternal(e){return K(this,null,function*(){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"&&this.visibleOnGlobe&&(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})})}regenerate(){const{icon:e,hoverIcon:t}=this.options;e&&this.setIconInternal(I({icon:e},this.options)),e&&t&&this.setHoverIconInternal(I({icon:e,hoverIcon:t},this.options)),xe(this.mapState)!==this.generatedAsEcef&&this.setLabel(this.options.label)}};function Pc(s,e){var t,i,o,r,a,l,c,d,_,u;return!(s.icon!==e.icon||((t=s.anchor)==null?void 0:t[0])!==((i=e.anchor)==null?void 0:i[0])||((o=s.anchor)==null?void 0:o[1])!==((r=e.anchor)==null?void 0:r[1])||((a=s.size)==null?void 0:a[0])!==((l=e.size)==null?void 0:l[0])||((c=s.size)==null?void 0:c[1])!==((d=e.size)==null?void 0:d[1])||((_=s.opacity)==null?void 0:_.toString())!==((u=e.opacity)==null?void 0:u.toString()))}const Pb=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 r=o.x,a=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;Bb(d.indices,_,0,1,2,2,1,3),oo(d,_++,r[0],a[0],l),oo(d,_++,r[1],a[1],l),oo(d,_++,r[2],a[2],l),oo(d,_++,r[3],a[3],l),d.elements.offset=_}});function oo(s,e,t,i,o){const r=e*4;s.views.position[r]=n.tileCoordOffset+t,s.views.position[r+1]=n.tileCoordOffset+i;const a=e*2;s.views.localID[a]=o}function Bb(s,e,t,i,o,r,a,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+r,c[d+4]=e+a,c[d+5]=e+l,s.offset=d+6}const zb="#0085a0";class Rb extends Ye{constructor(e,t){super(e,t),this.isGeometryOutOfMainReplica=!1;const{dynamicStyle:i,collector:o,tileManager:r,identifier:a,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||zb}});if(!c)return;i.addLayer(c,this.options.zIndex),this.layerId=c.innerId;const d=n.optionsToTileAttrs({db_tiers:t.tiers});this.points=Fb(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(y=>y[0]>n.HALF_WORLD_SIZE||y[0]<-n.HALF_WORLD_SIZE);const _=n.create();for(let y=0;y<this.points.length;y++)n.expandByPoint(_,this.points[y]);const u=n.getBoundsTileCoords(_),h=n.createTileInfo(u),f=[],m=[],p=n.create$1();for(let y=0;y<this.points.length;y++)n.mapPointToTilePoint(p,this.points[y],h),f[y]=p[0],m[y]=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:Pb.generate,args:[i.getStyle().id,c,v,{x:f,y:m}]});const x=o.getAccumulatedData(),g=new n.TileObject("dynamicObject",x.data,this.modules,this.mapState,u,this);r.addObject(g),this.tileObjects.push(g),this.options.interactive&&this.identifyIds.push(x.identifyIds),l.addLayer(this),o.reset(),this.modules.renderer.addRerenderEvent(),this.options.interactive&&a.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 Fb(s,e,t){const i=e/2,o=t/2,r=s[0],a=s[1],l=s[2];return[[r-i,a-o,l],[r+i,a-o,l],[r-i,a+o,l],[r+i,a+o,l]]}let Bc=class extends Ye{constructor(e,t){super(e,{interactive:!1}),this.isGeometryOutOfMainReplica=!1;const{dynamicStyle:i}=this.modules;this.options=ce(I({},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(r=>{this.textureIndex=r,this.clean(),this.generate()}))}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}generate(){var m;if(!this.styleLayer||this.textureIndex===void 0)return;const{collector:e,dynamicStyle:t,tileManager:i,layers:o}=this.modules;this.points=Db(this.options.bounds),this.isGeometryOutOfMainReplica=this.points.some(p=>p[0]>n.HALF_WORLD_SIZE||p[0]<-n.HALF_WORLD_SIZE);const r=n.create();for(let p=0;p<this.points.length;p++)n.expandByPoint(r,this.points[p]);const a=n.getBoundsTileCoords(r),l=n.createTileInfo(a),c=[],d=[],_=n.create$1();for(let p=0;p<this.points.length;p++)n.mapPointToTilePoint(_,this.points[p],l),c[p]=_[0],d[p]=_[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,(m=this.options.tiers)!=null?m:null]});const h=e.getAccumulatedData(),f=new n.TileObject("dynamicObject",h.data,this.modules,this.mapState,a,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 Db(s){const{min:e,max:t}=n.fromGeo(s);return[e,[t[0],e[1]],[e[0],t[1]],t]}class Ob{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[r,a,l]=n.tileCoordsToOSM(o),{min:c,max:d}=n.getTileBounds(o),_={southWest:[c[0],c[1]].map(f=>f/n.WEB_MERCATOR_TO_WORLD_SIZE_MULTIPLIER),northEast:[d[0],d[1]].map(f=>f/n.WEB_MERCATOR_TO_WORLD_SIZE_MULTIPLIER)};let u=this.options.url(r,a,l,_);const h=this.modules.map.state.tileKey;return h&&(u=u.replace("{key}",h)),u}}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 a=this.modules.sourceStorage.getSourceById(this.id);(a==null?void 0:a.type)==="raster"&&this.modules.map.emit("error",{type:"rasterTileLoadError",tileCoords:n.tileCoordsToOSM(e),tileUrl:i,source:a,responseMessage:o.error.message,responseStatus:o.error.status})}return o.rejected||this.tiles.set(t,o.data),[{regionId:0,metatileHash:-1}]})}generateTile(e,t){return K(this,null,function*(){const i=[],o=[],r=this.modules.styleManager.getStyle(e.handyStyleId),a=n.coordsToKey(t),l=this.tiles.get(a);if(!l||!r)return Promise.resolve({results:i,transferable:o});const c=yield 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[a]=c;const d=[],_=[],u=n.create$1(),h=Nb(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);r.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:_},r.id,m,v,c,null]})});const p=this.modules.collector.getAccumulatedData();return i.push({regionId:0,metatileHash:0,styleId:r.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 Nb(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 zc=class{constructor(e,t,i){var a,l;this.type="raster",this.id=n.sourceUuid(),this.modules=e.modules,this.source=new Ob(this.id,this.modules,t);const o=(a=t.minZoom)!=null?a:n.MAP_DEFAULTS.minZoom,r=(l=t.maxZoom)!=null?l:n.MAP_DEFAULTS.maxZoom;this.layer=new n.TileLayer(o,r,o,r,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 kb=0;class Ub extends Ye{constructor(e,t){var a;super(e,t),this.options=t,this.generatedAsEcef=!1;const i=n.Mercator.fromGeo(t.coordinates);this.position={userValue:i,normalizedValue:n.normalizeMapPoint(i)},this.zIndex=(a=t.zIndex)!=null?a:kb,this.isDestroyed=!1,this.labelKey=`onlineMarker-${this.uniqId}`;const o=this.options.floorId?e.modules.floorManager.getFloorObjectElevation(this.options.floorId,!0):0,r=t.elevation?t.elevation*n.Mercator.scaleFactor(t.coordinates[1])*n.MAP_POINTS_IN_METER:0;this.elevation=r+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:r}=e;this.modules.imageCache.getRasterSet(t,i,o,r).then(a=>{if(this.isDestroyed||!a||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:r}}),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(a,n.getStaticIconRasterSetKey(t,m[0],m[1]));const p=n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),v={x:[0],y:[0]},x=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedMetatile.tileProps,c,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(l,x),n.generateSafely({collector:d,generator:n.preLabelingPoint,args:[_.getStyle(),l,x,n.fixedMetatile,n.LATEST_TILE_VERSION,p,h.getId(),v,n.pixelRatioToDpi(window.devicePixelRatio)]});const g=d.getAccumulatedData(),{identifyIds:y,labels:b}=g;if(!b.length)return;const S=[{metatileHash:-1,labels:b,styleId:_.getStyle().id}],T=n.unpackPreLabelingResult(S,n.LabelSource.DynamicObject,u,this.mapState.styleState,this.mapState.styleZoom);if(T.length!==1)return;const z=T[0],E=n.createTileInfo(p),P=xe(this.mapState)?(C,F)=>n.encodeTilePointToEcefU16(E,C,F):void 0;n.generateNotStretchableIconElement(d,z,"",[0,0,this.elevation],0,a.rasters[0],window.devicePixelRatio,P);const k=d.getAccumulatedData();d.reset();const R=new n.TileObject("dynamicObject",k.data,this.modules,this.mapState,n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this);R.ecefDataState=n.ecefDataStateFromBool(xe(this.mapState)),this.tileObjects.push(R),this.identifyIds=[y],this.modules.tileManager.addObject(R),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:[-r[0],-r[1]],labelingGroup:"marker"}),this.modules.renderer.addRerenderEvent()})}update(){super.update();const e=xe(this.mapState);e!==this.generatedAsEcef&&(this.setIcon(this.actualIcon),this.generatedAsEcef=e),this.updateGlobeVisibility(this.options.coordinates)}removeIcon(){const e=this.tileObjects[0];e&&(e.clean(this.mapState),this.modules.tileManager.removeObject(e),this.tileObjects=[])}}function Hb(s,e,t,i,o,r){return{type:s,maxDetailLevel:r,minDetailLevel:o,maxZoomLevel:i,minZoomLevel:t,zoomLevel:Math.floor(e),tiles:{},viewportTiles:[],useExtendedTilesBounds:!1}}function Gb(s){s.tiles={},s.viewportTiles=[]}function Vb(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 jb(s,e,t,i,o){return Hb("data",s,e,t,i,o)}function Zb(s,e,t,i){if(s.zoomLevel<s.minZoomLevel){s.viewportTiles=[];return}const o=n.clamp(s.zoomLevel,s.minZoomLevel,s.maxZoomLevel),r=n.clamp(s.zoomLevel,s.minDetailLevel,s.maxDetailLevel);s.viewportTiles=n.findVisibleTiles(e,t,o,s.minZoomLevel,r,void 0,void 0,void 0,s.useExtendedTilesBounds).map(n.coordsToKey);for(let a=0;a<s.viewportTiles.length;a++){const l=s.viewportTiles[a];let c=s.tiles[l];c||(c=s.tiles[l]=i(n.keyToCoords(l)))}}function $b(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 Wb(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 Xb(s,e){const t=new Set(s.viewportTiles),i=[];for(const o in s.tiles){const r=s.tiles[o];!t.has(o)&&!0&&i.push(r)}return i}class Kb extends n.Evented{constructor(e,t,i){super(),this.prevZoomLevel=0,this.mapState=e,this.modules=t,this.config=i,this.gridState=jb(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(){Gb(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,Zb(this.gridState,this.mapState,this.modules,Vb),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($b(this.gridState)),this.abortFetch(Wb(this.gridState)),this.clearTiles(Xb(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 qb=Object.freeze(Object.defineProperty({__proto__:null,Benchmark:eo,Circle:Mc,CircleMarker:tr,DashedPolyline:Sc,DataTileLayer:Kb,DefaultSource:Rl,DynamicObject:Ye,Entrance:Cs,GeoJsonSource:n.GeoJsonSource,GeoJsonTileSource:n.GeoJsonTileSource,GeoJsonViewportSource:n.GeoJsonViewportSource,GltfModel:Fs,Heatmap:vb,HtmlMarker:Ms,LinePatternType:n.LinePatternType,Map:Hs,MapClass:Hs,Marker:Lc,OnlineMarker:Ub,PointLabel:Zs,Polygon:Tc,Polyline:gc,Raster:Bc,RasterTileSource:zc,Rect:Rb,ZenithSource:ho,config:n.index,linePatternFromString:n.linePatternFromString,mapglUtils:id,utils:td},Symbol.toStringTag,{value:"Module"})),Yb="topRight";class Yt{constructor(e,t,i){var o;this._wrap=document.createElement("div"),this._wrap.style.userSelect="none",typeof t=="string"?this._wrap.innerHTML=t:this._wrap.appendChild(t),this._position=(o=i==null?void 0:i.position)!=null?o:Yb,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 Qt={root:"mapgl_QEdaFvncPWE-",button:"mapgl_mjx-K8iaDdc-",zoomIn:"mapgl_zKZCVsRur9c-",zoomOut:"mapgl_3t-wJELDATg-"},Qb=`
    <div class="${Qt.root}">
        <button type="button" class="${Qt.button} ${Qt.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="${Qt.button} ${Qt.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 Rc extends Yt{constructor(e,t){super(e,Qb,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(`.${Qt.zoomIn}`),this._zoomOutButton=this._wrap.querySelector(`.${Qt.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 Jt={root:"mapgl_ON-gf73kIU0-",button:"mapgl_mWyZxMObEi8-",none:"mapgl_FwnEmRmDBLg-",easy:"mapgl_uSuUHuf71nM-",medium:"mapgl_LdqAv9Ly624-",hard:"mapgl_udRZCM1quWE-"},Jb=`<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 Fc extends Yt{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()?Ab(this._score):Jt.none,t=`
            <div class="${Jt.root}">
                <button type="button" class="${Jt.button} ${e}">
                    ${this._map.isTrafficOn()&&this._score!==void 0?this._score:Jb}
                </button>
            </div>
        `;this._wrap.innerHTML=t,this._wrap.querySelector(`.${Jt.button}`).addEventListener("click",this._onClick)}}function Ab(s){return s===void 0?"":s>6?Jt.hard:s>3?Jt.medium:Jt.easy}const so={container:"mapgl_K-1Yb8HCVpQ-",logos:"mapgl_CLps5xx6CNs-"};var Dc=(s=>(s.osm="osm",s.api="api",s.license="license",s))(Dc||{});const ew=`<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>`,tw=`<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>`,Oc=s=>`
    <div class=${so.container}>
        <div class=${so.logos}>
            ${s==="2gis"?ew:tw}
        </div>
    </div>
`,iw=200,Ut=.4,nw=6.9,ow={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 sw extends Yt{constructor(e,t){super(e,Oc(t.copyrightType),t),this._copyrightType="2gis",this._isHidden=!1,this._onViewportchange=()=>{this._throttledVisibleCopyright()},this._onClick=o=>{if(o.target&&aw(o.target)){const r=o.target.dataset.type;rw(r)&&this._map.emit("copyrightclick",{type:r,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(`.${so.container}`).addEventListener("click",this._onClick),this._throttledVisibleCopyright=n.throttle(()=>{this.update()},iw)}destroy(){this._map._impl.off("viewportchange",this._onViewportchange),this._map._impl.off("idle",this._onViewportchange),this._wrap.querySelector(`.${so.container}`).removeEventListener("click",this._onClick),super.destroy()}update(){let e=!1;if(this._map.getZoom()>nw){const t=this._map.getSize(),i=this._map._impl.unproject([t[0]*Ut,t[1]*Ut]),o=this._map._impl.unproject([t[0]*(1-Ut),t[1]*Ut]),r=this._map._impl.unproject([t[0]*Ut,t[1]*(1-Ut)]),a=this._map._impl.unproject([t[0]*(1-Ut),t[1]*(1-Ut)]);e=lw([i,o,a,r,i],ow.features[0].geometry.coordinates[0])}e&&!this._isHidden&&(this._isHidden=!0,super.getContainer().innerHTML=""),!e&&this._isHidden&&(this._isHidden=!1,super.getContainer().innerHTML=Oc(this._copyrightType))}}function rw(s){return s!==void 0&&s in Dc}function aw(s){return s&&"href"in s&&"dataset"in s}function lw(s,e){for(let t=0;t<s.length-1;t++){const i=s[t],o=s[t+1];for(let r=0;r<e.length-1;r++){const a=e[r],l=e[r+1];if(cw(i,o,a,l))return!0}}return!!(Nc(s[0],e)||Nc(e[0],s))}function cw(s,e,t,i){const o=ro(t,i,s),r=ro(t,i,e),a=ro(s,e,t),l=ro(s,e,i);return!!((o>0&&r<0||o<0&&r>0)&&(a>0&&l<0||a<0&&l>0)||o===0&&ao(t,i,s)||r===0&&ao(t,i,e)||a===0&&ao(s,e,t)||l===0&&ao(s,e,i))}function ro(s,e,t){return(e[0]-s[0])*(t[1]-s[1])-(e[1]-s[1])*(t[0]-s[0])}function ao(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 Nc(s,e){const[t,i]=s;let o=!1;for(let r=0,a=e.length-1;r<e.length;a=r++){const[l,c]=e[r],[d,_]=e[a];c>i!=_>i&&t<(d-l)*(i-c)/(_-c)+l&&(o=!o)}return o}const kc={wrap:"mapgl_r8Wn2E5pGh0-",container:"mapgl_ir0vRf5QXrk-"};class dw{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 _w=` <div class=${kc.container}>Your MapGL key is invalid. Please contact api@2gis.com to get MapGL key.</div> `;class uw extends dw{constructor(e){super(e,_w),e._impl.on("error",t=>{t.type==="invalidtilekey"&&(this.isDisplayed()||this.display())})}initWrap(){const e=document.createElement("div");return e.classList.add(`${kc.wrap}`),e.innerHTML=this.content,e}}class Uc{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],r=i>=this.southWest[1]&&i<=this.northEast[1];return o&&r}containsBounds(e){const{southWest:t,northEast:i}=e,o=this.containsPoint(t),r=this.containsPoint(i);return o&&r}intersects(e){const{southWest:t,northEast:i}=e,o=this.getPointRelatedLocation(t),r=this.getPointRelatedLocation(i),a=+o.N+ +r.N,l=+o.S+ +r.S,c=+o.W+ +r.W,d=+o.E+ +r.E;return!(a===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 De={root:"mapgl_h2pl79nAYpk-",container:"mapgl_64D1bmNQN3Q-",scroller:"mapgl_jdJbkjpLO7k-",content:"mapgl_54Rmy50n6Fw-",control:"mapgl_3i1QoGerxio-",label:"mapgl_wGplqJ4hHPc-",mm:"mapgl_GbM3JIwbvBI-",icon:"mapgl_MX6K1s-5thI-",floorLevelName:"mapgl_aMwUNIDCavU-"},hw=`
    <div class="${De.root}">
        <div class="${De.container}">
            <div class="${De.scroller}">
                <div class="${De.content}" />
            </div>
        </div>
    </div>
`,fw=`<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>`,Hc=`<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 Gc extends Yt{constructor(e,t){super(e,hw,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=>{var d;const{currentFloor:o,id:r,floorNames:a,metro:l,mode:c}=i;this._floor={mode:c,currentFloorLevelIndexByMode:ce(I({},(d=this._floor)==null?void 0:d.currentFloorLevelIndexByMode),{[c]:o}),floorPlanId:r,floorNames:a,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({floorMode:i.floorMode,floorIndex:i.floorLevelIndex})},this._controlHandler=(i,o)=>r=>{var a,l;r.preventDefault(),this._switchCurrentFloorLevel({floorMode:i,floorIndex:o}),this._floor&&this._map._impl.changeFloorNumber(i==="metro"&&((a=this._floor.metro)!=null&&a.id)?(l=this._floor.metro)==null?void 0:l.id:this._floor.floorPlanId,i==="building"?"building":o)},this._map=e,this._root=this._wrap.querySelector(`.${De.root}`),this._content=this._wrap.querySelector(`.${De.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(){var r,a,l;if(!this._floor)return;this._content.innerHTML="";let e;const t=this._floor.metro&&((r=this._floor.metro)==null?void 0:r.floorNames.length)>1;(a=this._floor.metro)==null||a.floorNames.forEach((c,d)=>{const _=document.createElement("button");if(_.name=`metro-${d.toLocaleString()}`,_.type="button",_.className=De.control,!t)_.innerHTML=Hc;else{const h=document.createElement("div");h.className=`${De.label} ${De.mm}`;const f=document.createElement("div");f.className=De.icon,f.innerHTML=Hc;const m=document.createElement("div");m.className=De.floorLevelName,m.textContent=c,h.append(f,m),_.append(h)}this._floor&&this._floor.mode==="metro"&&this._floor.currentFloorLevelIndexByMode.metro===d&&(_.disabled=!0,e=_);const u=this._controlHandler("metro",d);_.addEventListener("click",u),this._handlers.set(_,u),this._content.append(_)}),this._floor.floorNames.forEach((c,d)=>{const _=document.createElement("button");_.className=De.control;const u=document.createElement("div");u.className=De.label,u.textContent=c,_.append(u),_.name=`floor-${d.toLocaleString()}`,_.type="button",this._floor&&this._floor.mode==="floor"&&this._floor.currentFloorLevelIndexByMode.floor===d&&(_.disabled=!0,e=_);const h=this._controlHandler("floor",d);_.addEventListener("click",h),this._handlers.set(_,h),this._content.append(_)});const i=document.createElement("button");i.className=`${De.control}`,i.innerHTML=`<div class="${De.label}">${fw}</div>`,i.name="building",i.type="button",this._floor&&this._floor.mode==="building"&&(i.disabled=!0,e=i);const o=this._controlHandler("building",NaN);if(i.addEventListener("click",o),this._handlers.set(i,o),this._content.append(i),e&&e.offsetTop){const c=(l=e.parentElement)==null?void 0:l.parentElement;c&&(c.scrollTop=e.offsetTop)}}_switchCurrentFloorLevel(e){if(!this._floor)return;const t=this._floor.mode==="building"?"building":this._floor.mode==="metro"?`metro-${this._floor.currentFloorLevelIndexByMode.metro}`:`floor-${this._floor.currentFloorLevelIndexByMode.floor}`,i=this._wrap.querySelector(`.${De.control}[name="${t}"]`);i&&(i.disabled=!1);const o=this._wrap.querySelector(e.floorMode==="building"?`.${De.control}[name="building"]`:e.floorMode==="metro"?`.${De.control}[name="metro-${e.floorIndex}"]`:`.${De.control}[name="floor-${e.floorIndex}"]`);o&&(o.disabled=!0),e.floorMode!=="building"?(this._floor.mode=e.floorMode,this._floor.currentFloorLevelIndexByMode[e.floorMode]=e.floorIndex):this._floor.mode="building"}}const Ws={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-"},Ui=10;class mw{constructor(e,t){this.wrap=document.createElement("div"),this.wrap.className=Ws.controlPane,this.containers={};const{rootContainer:i}=e._impl.modules.layout;i.appendChild(this.wrap),this.padding={top:Ui,right:Ui,bottom:Ui,left:Ui},this.setPadding(t.padding||{})}setPadding(e){Object.keys(this.padding).forEach(t=>{var o;const i=t;this.padding[i]=(o=e[i])!=null?o:Ui,this.wrap.style[`margin${i.replace(/^\w/,r=>r.toUpperCase())}`]=`${this.padding[i]}px`})}getPadding(){return I({},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(Ws.container,Ws[e]),this.wrap.appendChild(t),t}}const Vc={root:"mapgl_9m2ynAxdBT0-",label:"mapgl_sR4nXEQ3L2M-"},lo={meter:{en:"m",ru:"м"},kilometer:{en:"km",ru:"км"}},pw=66;class jc extends Yt{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 r=this._wrap.getBoundingClientRect(),a=this._calcSize([r.x,r.y],r.width||pw,0),l=`
            <div class="${Vc.root}">
                <div class="${Vc.label}">
                    ${vw(a,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 vw(s,e){return s<1e3?`${s} ${lo.meter[e]||lo.meter.en}`:`${(s/1e3).toFixed(1)} ${lo.kilometer[e]||lo.kilometer.en}`}class Zc{constructor(e){this._impl=e._impl.getDefaultSource()}setFeatureStateMap(e){this._impl.setFeatureStateMap(e)}}function je(s,e){const t=I({},s);for(const i in e){const o=i;t[o]===void 0&&(t[o]=e[o])}return t}const gw={center:[0,0],zoom:0,minZoom:to.minZoom,maxZoom:to.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,metro3dVisible:!1,resetFloorModeOnActivation:!1,webgpu:!1,forceSyncIdentify:!1,sharedModelsPath:sx};let yw=class extends St{constructor(e,t){var l;super();let i;if(typeof e=="string"){const c=document.getElementById(e);if(c)i=c;else throw new Error(`Could not found html element with id: ${e}`)}else i=e;const o=I({},t.styleOptions),r=je(this._validateOptions(t),gw),a=ce(I({},r),{disableHoverStyles:(l=t.disableHoverStyles)!=null?l:!0,tileServer:t.tileServer||nx,style:t.style||n.DEFAULT_MAPGL_STYLE,styleOptions:o,styleState:t.styleState,sessionId:ks(),tileSessionId:t.tileSessionId});this._impl=new Hs(i,a),this._impl.on("idle",c=>this._emitMapEvent("idle",c)).on("ready",c=>this._emitMapEvent("ready",c)).on("resize",c=>this._emitMapEvent("resize",c)).on("move",c=>this._emitMapEvent("move",c)).on("movestart",c=>this._emitMapEvent("movestart",c)).on("moveend",c=>this._emitMapEvent("moveend",c)).on("center",c=>this._emitMapEvent("center",c)).on("centerstart",c=>this._emitMapEvent("centerstart",c)).on("centerend",c=>this._emitMapEvent("centerend",c)).on("zoom",c=>this._emitMapEvent("zoom",c)).on("zoomstart",c=>this._emitMapEvent("zoomstart",c)).on("zoomend",c=>this._emitMapEvent("zoomend",c)).on("rotation",c=>this._emitMapEvent("rotation",c)).on("rotationstart",c=>this._emitMapEvent("rotationstart",c)).on("rotationend",c=>this._emitMapEvent("rotationend",c)).on("pitch",c=>this._emitMapEvent("pitch",c)).on("pitchstart",c=>this._emitMapEvent("pitchstart",c)).on("pitchend",c=>this._emitMapEvent("pitchend",c)).on("trafficshow",()=>this.emit("trafficshow")).on("traffichide",()=>this.emit("traffichide")).on("floorcomplexshow",({id:c,currentFloor:d,floorNames:_,mode:u})=>this.emit("floorplanshow",{floorPlanId:c,currentFloorLevelIndex:d,floorLevels:_.map((h,f)=>({floorLevelIndex:f,floorLevelName:h})),floorMode:u==="metro"?"metro":"floor"})).on("floorcomplexhide",c=>this.emit("floorplanhide",{floorPlanId:c.id})).on("floorcomplexlevelchange",c=>this.emit("floorlevelchange",{floorLevelName:c.floorName,floorLevelIndex:c.floorIndex,floorPlanId:c.id,floorMode:c.floorMode})).on("floorsactivegroupchange",c=>this.emit("floorsactivegroupchange",c)).on("modelshow",c=>this.emit("modelshow",c)).on("modelhide",c=>this.emit("modelhide",c)),this._impl.on("click",c=>this._emitMapPointerEvent("click",c)).on("dblclick",c=>this._emitMapPointerEvent("dblclick",c)).on("contextmenu",c=>this._emitMapPointerEvent("contextmenu",c)).on("mousemove",c=>this._emitMapPointerEvent("mousemove",c)).on("mouseover",c=>this._emitMapPointerEvent("mouseover",c)).on("mouseout",c=>this._emitMapPointerEvent("mouseout",c)).on("mousedown",c=>this._emitMapPointerEvent("mousedown",c)).on("mouseup",c=>this._emitMapPointerEvent("mouseup",c)).on("touchstart",c=>this._emitMapPointerEvent("touchstart",c)).on("touchend",c=>this._emitMapPointerEvent("touchend",c)).on("touchmove",c=>this._emitMapPointerEvent("touchmove",c)),this._impl.on("error",c=>this._emitMapErrorEvent("error",c)),this._impl.on("trafficscore",({score:c})=>this.emit("trafficscore",{score:c})),this._impl.on("styleload",({style:c})=>this.emit("styleload",{style:c})),this._impl.on("graphicspresetchange",()=>this.emit("graphicspresetchange",this._impl.getCurrentGraphicsPreset())),this._controlPane=new mw(this,{padding:t.controlsLayoutPadding}),this._initControls(t),new uw(this),this._defaultSource=new Zc(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 Uc(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}setStyleById(e){return K(this,null,function*(){return this._impl.setStyle(e)})}setStyleFromUrl(e,t){return K(this,null,function*(){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()}getIconUrl(e){return this._impl.getIconUrl(e)}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:r,responseMessage:a,responseStatus:l}=t;if((r==null?void 0:r.type)==="raster"){const c=r.mapglApiSource;this.emit(e,{type:t.type,responseMessage:a,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:r,target:a,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{poiIcon:_}=l;_&&(c.poiIcon=_);const{floorId:u}=l;u&&(c.floorId=u);break}}let d;a!==void 0&&(d={id:a.id},a.center&&(d.center=a.center)),this.emit(e,{originalEvent:i,lngLat:o,point:r,target:d,targetData:c})}_initControls(e){if(e.copyright!==!1&&this._impl.modules.tileKeyInfo.getKeyInfo().then(t=>{!t.error&&!t.hideCopyright&&new sw(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 Rc(this,{position:t})}if(e.trafficControl){const t=typeof e.trafficControl=="string"?e.trafficControl:"topRight";new Fc(this,{position:t})}if(e.scaleControl){const t=typeof e.scaleControl=="string"?e.scaleControl:"bottomLeft";new jc(this,{position:t})}if(e.floorControl){const t=typeof e.floorControl=="string"?e.floorControl:"topRight";new Gc(this,{position:t})}}_validateOptions(e){return e=I({},e),typeof e=="object"&&"center"in e&&(uc.isValidGeoPoint(e.center,Us.UseDefault)||(e.center=void 0)),e}};const xw="Noto_Sans",bw={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"},ww={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 Sw extends St{constructor(e,t){super(),t.icon||(t.anchor=[15,46]);const i=je(t,ww);this.userData=i.userData,this.rootOptions={zIndex:i.zIndex,minZoom:i.minZoom,maxZoom:i.maxZoom},this._impl=new Lc(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:$c(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)).on("touchmove",o=>this._emitPointerEvent("touchmove",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($c(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:r}=t;this.emit(e,{originalEvent:i,lngLat:o,point:r,targetData:this})}}function $c(s,e){var i,o,r;if(!e)return;e.minZoom=Math.max((i=e.minZoom)!=null?i:s.minZoom,s.minZoom),e.maxZoom=Math.min((o=e.maxZoom)!=null?o:s.maxZoom,s.maxZoom),e.zIndex=(r=e.zIndex)!=null?r:s.zIndex+1e-5;const t=je(e,bw);return e.offset===void 0&&e.anchor!==void 0&&(t.offset=e.anchor.map(a=>-a)),{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:xw}}const Tw="Noto_Sans",Mw={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 Ew extends St{constructor(e,t){super(),this.userData=t.userData;const i=je(t,Mw);t.offset===void 0&&t.anchor!==void 0&&(i.offset=t.anchor.map(o=>-o)),this._impl=new Zs(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:Tw,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:r}=t;this.emit(e,{originalEvent:i,lngLat:o,point:r,targetData:this})}}const Iw={minZoom:-1/0,maxZoom:1/0,zIndex:0,anchor:[-0,-0],preventMapInteractions:!0,userData:void 0,interactive:!0,disableRounding:!1,labeling:{type:"none"},floorId:""},Cw=!1;class Lw{constructor(e,t){this.userData=t.userData;const i=je(t,Iw);this._impl=new Ms(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:Cw,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 Pw={zIndex:0,minZoom:-1/0,maxZoom:1/0,color:"#3388ff33",strokeColor:"#3388ff",strokeWidth:1,interactive:!0,userData:void 0};class Bw extends St{constructor(e,t){super(),this.userData=t.userData;const i=je(t,Pw),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 Mc(e._impl,o),this._impl.on("click",r=>this._emitPointerEvent("click",r)).on("dblclick",r=>this._emitPointerEvent("dblclick",r)).on("mousemove",r=>this._emitPointerEvent("mousemove",r)).on("mouseover",r=>this._emitPointerEvent("mouseover",r)).on("mouseout",r=>this._emitPointerEvent("mouseout",r)).on("mousedown",r=>this._emitPointerEvent("mousedown",r)).on("mouseup",r=>this._emitPointerEvent("mouseup",r)).on("touchstart",r=>this._emitPointerEvent("touchstart",r)).on("touchend",r=>this._emitPointerEvent("touchend",r)).on("touchmove",r=>this._emitPointerEvent("touchmove",r))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:r}=t;this.emit(e,{originalEvent:i,lngLat:o,point:r,targetData:this})}}const zw={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 Rw extends St{constructor(e,t){super(),this.userData=t.userData,this.options=je(t,zw);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 tr(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)).on("touchmove",o=>this._emitPointerEvent("touchmove",o))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:r}=t;this.emit(e,{originalEvent:i,lngLat:o,point:r,targetData:this})}}const Fw={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 Dw extends St{constructor(e,t){super(),this.userData=t.userData;const i=je(t,Fw);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 Sc(e._impl,o),this._impl.on("click",r=>this._emitPointerEvent("click",r)).on("dblclick",r=>this._emitPointerEvent("dblclick",r)).on("mousemove",r=>this._emitPointerEvent("mousemove",r)).on("mouseover",r=>this._emitPointerEvent("mouseover",r)).on("mouseout",r=>this._emitPointerEvent("mouseout",r)).on("mousedown",r=>this._emitPointerEvent("mousedown",r)).on("mouseup",r=>this._emitPointerEvent("mouseup",r)).on("touchstart",r=>this._emitPointerEvent("touchstart",r)).on("touchend",r=>this._emitPointerEvent("touchend",r)).on("touchmove",r=>this._emitPointerEvent("touchmove",r))}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 gc(e._impl,o),this._impl.on("click",r=>this._emitPointerEvent("click",r)).on("dblclick",r=>this._emitPointerEvent("dblclick",r)).on("mousemove",r=>this._emitPointerEvent("mousemove",r)).on("mouseover",r=>this._emitPointerEvent("mouseover",r)).on("mouseout",r=>this._emitPointerEvent("mouseout",r)).on("mousedown",r=>this._emitPointerEvent("mousedown",r)).on("mouseup",r=>this._emitPointerEvent("mouseup",r)).on("touchstart",r=>this._emitPointerEvent("touchstart",r)).on("touchend",r=>this._emitPointerEvent("touchend",r)).on("touchmove",r=>this._emitPointerEvent("touchmove",r))}}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:r}=t;this.emit(e,{originalEvent:i,lngLat:o,point:r,targetData:this})}}const Ow={interactive:!0,maxZoom:1/0,minZoom:-1/0,color:"#3388ff33",zIndex:0,strokeWidth:3,strokeColor:"#3388ff",userData:void 0};class Nw extends St{constructor(e,t){super(),this.userData=t.userData;const i=je(t,Ow),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 Tc(e._impl,o),this._impl.on("click",r=>this._emitPointerEvent("click",r)).on("dblclick",r=>this._emitPointerEvent("dblclick",r)).on("mousemove",r=>this._emitPointerEvent("mousemove",r)).on("mouseover",r=>this._emitPointerEvent("mouseover",r)).on("mouseout",r=>this._emitPointerEvent("mouseout",r)).on("mousedown",r=>this._emitPointerEvent("mousedown",r)).on("mouseup",r=>this._emitPointerEvent("mouseup",r)).on("touchstart",r=>this._emitPointerEvent("touchstart",r)).on("touchend",r=>this._emitPointerEvent("touchend",r)).on("touchmove",r=>this._emitPointerEvent("touchmove",r))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:r}=t;this.emit(e,{originalEvent:i,lngLat:o,point:r,targetData:this})}}const kw={minZoom:-1/0,maxZoom:1/0,zIndex:0,opacity:1};class Uw{constructor(e,t){const i=je(t,kw),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 Bc(e._impl,o)}updateImage(e){return K(this,null,function*(){yield this._impl.updateImage(e)})}destroy(){this._impl.destroy()}}const Hw={zIndex:0,minZoom:-1/0,maxZoom:1/0,color:"#0085a0",strokeColor:"#ffffff",width:4,strokeWidth:1,roundingRadius:2,tipWidthMultiplier:1.5,tipHeightMultiplier:2.8,tipMovementAmplitude:6,animate:!1,iterationCount:1/0,interactive:!1,userData:void 0};class Gw extends St{constructor(e,t){super(),this.userData=t.userData;const i=je(t,Hw),a={coordinates:(l=>typeof l[0][0]=="number")(i.coordinates)?[i.coordinates]:i.coordinates,interactive:i.interactive,minZoom:i.minZoom,maxZoom:i.maxZoom,zIndex:i.zIndex,color:i.color,borderColor:i.strokeColor,width:i.width,borderWidth:i.strokeWidth,roundingRadius:i.roundingRadius,wingWidthMultiplier:i.tipWidthMultiplier,tipHeightMultiplier:i.tipHeightMultiplier,tipMovementAmplitude:i.tipMovementAmplitude,animate:i.animate,iterationCount:i.iterationCount};this._impl=new Cs(e._impl,a),this._impl.on("click",l=>this._emitPointerEvent("click",l)).on("dblclick",l=>this._emitPointerEvent("dblclick",l)).on("mousemove",l=>this._emitPointerEvent("mousemove",l)).on("mouseover",l=>this._emitPointerEvent("mouseover",l)).on("mouseout",l=>this._emitPointerEvent("mouseout",l)).on("mousedown",l=>this._emitPointerEvent("mousedown",l)).on("mouseup",l=>this._emitPointerEvent("mouseup",l)).on("touchstart",l=>this._emitPointerEvent("touchstart",l)).on("touchend",l=>this._emitPointerEvent("touchend",l)).on("touchmove",l=>this._emitPointerEvent("touchmove",l))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:r}=t;this.emit(e,{originalEvent:i,lngLat:o,point:r,targetData:this})}}const Vw={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 jw extends St{constructor(e,t){super(),this.userData=t.userData;const i=je(t,Vw),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 Fs(e._impl,o),this._impl.on("click",r=>this._emitPointerEvent("click",r)).on("dblclick",r=>this._emitPointerEvent("dblclick",r)).on("mousemove",r=>this._emitPointerEvent("mousemove",r)).on("mouseover",r=>this._emitPointerEvent("mouseover",r)).on("mouseout",r=>this._emitPointerEvent("mouseout",r)).on("mousedown",r=>this._emitPointerEvent("mousedown",r)).on("mouseup",r=>this._emitPointerEvent("mouseup",r)).on("touchstart",r=>this._emitPointerEvent("touchstart",r)).on("touchend",r=>this._emitPointerEvent("touchend",r)).on("touchmove",r=>this._emitPointerEvent("touchmove",r)).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 Wc={attributes:{},maxZoom:17,dimensions:2,modelsPath:"",modelsAppearStrategy:"byModel",promoteId:"",idScope:"default",tolerance:3};class Zw{constructor(e,t){this.options=je(t,Wc),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()}setData(e){return K(this,null,function*(){this._isDestroyed||(yield this._impl.setData(e))})}}const $w=ce(I({},Wc),{viewportPadding:0});class Ww{constructor(e,t){this.options=je(t,$w);const i=ce(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()}setData(e){return K(this,null,function*(){return this._impl.setDataFn(e)})}setViewportPadding(e){return this._impl.setViewportPadding(e),this}}const Xc={container:"mapgl_54Xq9OUdARA-",text:"mapgl_qYE18V9u8c0-"},Xw=s=>`
    <div class=${Xc.container}>
        <div class=${Xc.text}>${s}</div>
    </div>
`;class Kw extends Yt{constructor(e,t){super(e,Xw(t),{position:"bottomLeft"})}}const qw={attributes:{},attribution:"",minZoom:to.minZoom,maxZoom:to.maxZoom};class Yw{constructor(e,t){this.options=je(t,qw),this._impl=new zc(e._impl,this.options,this),this._attribution=new Kw(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 _o=class _o{constructor(e,t){this.options=t;const i=this.prepareOptions(this.options,e);this._impl=new ho(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){var o,r,a,l,c,d,_,u,h,f;const i={tileServer:(o=e.tileServer)!=null?o:"",tileSet:(r=e.tileSet)!=null?r:"",tileProtocol:(a=e.tileProtocol)!=null?a:"",tileKey:(l=e.tileKey)!=null?l:"",subdomains:(c=e.subdomains)!=null?c:e.layerId?["0,1,2,3"]:[""],appId:(d=e.appId)!=null?d: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)!=null?_:9,maxZoom:(u=e.maxZoom)!=null?u:15,maxDetailLevel:(h=e.maxGenerateZoom)!=null?h:17,strokeMinZoom:(f=e.strokeMinZoom)!=null?f:8};return e.layerId&&(i.tileTemplateUrl||(i.tileTemplateUrl=`${dc}?ts=userdata&x={x}&y={y}&z={z}&layer=${e.layerId}`),i.metatileTemplateUrl||(i.metatileTemplateUrl=`${dc}/file/{hash}?ts=userdata&layer=${e.layerId}`)),i}};_o.tileTemplateUrl="{protocol}://{host}/v2/ald?ts={tileSet}&x={x}&y={y}&z={z}&lang={lang}",_o.metatileTemplateUrl="{protocol}://{host}/v2/ald/file/{hash}.json?ts={tileSet}";let Xs=_o;function Qw(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(ix));if(!s)return;const e=Qw(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 Jw(s){hg(s)}const Ks="v1.74.0";J.API_VERSION=Ks,J.Arrow=Gw,J.Circle=Bw,J.CircleMarker=Rw,J.Control=Yt,J.DefaultSource=Zc,J.FloorControl=Gc,J.GeoJsonSource=Zw,J.GeoJsonViewportSource=Ww,J.GltfModel=jw,J.HtmlMarker=Lw,J.Label=Ew,J.LngLatBoundsClass=Uc,J.Map=yw,J.Marker=Sw,J.Polygon=Nw,J.Polyline=Dw,J.Raster=Uw,J.RasterTileSource=Yw,J.ScaleControl=jc,J.TrafficControl=Fc,J.ZenithSource=Xs,J.ZoomControl=Rc,J._J=qb,J.isSupported=Kd,J.isTerrainSupported=cr,J.notSupportedReason=_r,J.setWorkerUrl=Jw,J.terrainNotSupportedReason=s_,Object.defineProperty(J,Symbol.toStringTag,{value:"Module"})}));
