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

_mapgl_d("shared",["exports"],(function(m){var Q_=Object.defineProperty,eP=Object.defineProperties;var tP=Object.getOwnPropertyDescriptors;var Ea=Object.getOwnPropertySymbols;var em=Object.prototype.hasOwnProperty,tm=Object.prototype.propertyIsEnumerable;var oe=Math.pow,Q1=(m,$e,Ge)=>$e in m?Q_(m,$e,{enumerable:!0,configurable:!0,writable:!0,value:Ge}):m[$e]=Ge,de=(m,$e)=>{for(var Ge in $e||($e={}))em.call($e,Ge)&&Q1(m,Ge,$e[Ge]);if(Ea)for(var Ge of Ea($e))tm.call($e,Ge)&&Q1(m,Ge,$e[Ge]);return m},Ie=(m,$e)=>eP(m,tP($e));var nm=(m,$e)=>{var Ge={};for(var It in m)em.call(m,It)&&$e.indexOf(It)<0&&(Ge[It]=m[It]);if(m!=null&&Ea)for(var It of Ea(m))$e.indexOf(It)<0&&tm.call(m,It)&&(Ge[It]=m[It]);return Ge};var Pe=(m,$e,Ge)=>new Promise((It,br)=>{var Aa=ln=>{try{vs(Ge.next(ln))}catch(ws){br(ws)}},xa=ln=>{try{vs(Ge.throw(ln))}catch(ws){br(ws)}},vs=ln=>ln.done?It(ln.value):Promise.resolve(ln.value).then(Aa,xa);vs((Ge=Ge.apply(m,$e)).next())});"use strict";const $e="tile{subdomain}.maps.2gis.com",Ge="jam.api.2gis.com",It="https://styles.api.2gis.com",br="https://disk.2gis.com/styles/assets/icons",Aa="https://disk.2gis.com/styles/assets/models",xa="https://mapgl.2gis.com/api/fonts",vs="https://keys.api.2gis.com/public/v1/keys/{keyID}/services/mapgl-js-api",ln="https://mapgl.2gis.com/api/js/plugins/rtl-v1.1.1.js",ws="sha512-IyuCqmcNBfZyrExDMisGi0Xhp4PXupx6AMp4cjpKcAzJo+kSmOtRTLbL1xZsfxnsIqci9Q0piqY+kcwl1hCPyw==",sm="https://mapgl.2gis.com/api/js/plugins",rm=107.17318798131565,bs=oe(2,20),ee=oe(2,15),Ve=oe(2,16)-1,Di=ee/Ve,G=16383,ju=2.54,Is=96,Hu=4294967296/(256/Is*ju),Be=.7071067811865475,om=4294967295,am=1175494351e-47,lm=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"],Oi="Noto_Sans",$u=1/2,Yu=-4,_a=2147483647,cm="c080bb6a-8134-4993-93a1-5b4d8c36a59b",um=5,Mr=4,Pa=40,dm=65e3,Wu="byModel",fm=65536,Zu="empty",La={minZoom:2,maxZoom:20},ni={protocol:"https",server:$e,subdomains:"0123",tileSet:"vector_a",tileKey:Zu,appId:"empty",cacheRatio:2,maxUniverseZoom:8,maxRegionalZoom:15,maxDetailLevel:17},Ca={minZoom:10,maxZoom:14,tileSet:"com_poi_web",rasterSizes:[96,84,72,60,48,36,24]},Xu={minZoom:15,maxZoom:15,tileSet:"vector_immersive"},qu={tileSet:"dem"},Ju=100,Da=13.5,cn=[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}"},Ku={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:xa,gamma:.08,baseSize:24,baseLineHeight:1.2,bomCharCode:65279},Qu={defaultUrl:br},ed={url:It,path:"styles/{id}"},td={doubleClickTime:185,dragThreshold:2,pitchWaitingTime:200,pitchThreshold:7},nd=1e3,Ms={inAnimationTime:180,inAnimationType:"linear",outAnimationTime:800,outAnimationType:"linear"},Oa={time:300,type:"linear"},id={minStyleZoom:16,duration:500,easing:"easeOutQuint"},sd={bounceType:"easeOutElastic",bounceTime:1200,growType:"easeInOutQuad",growTime:1200,stagger:0,iterationCount:1/0},Fa={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},rd={0:Sr.commercialMargins.city,11:{topBottom:250,leftRight:250},12:{topBottom:170,leftRight:170}},od={alwaysRerender:!1,autoResizeInterval:50},ad="en",ld={macWheelDeltaToZoomDelta:.0018,notMacTrackpadDeltaToZoomDelta:.0018*3,wheelZoomDelta:.65,animDuration:400,throttleDelay:100,mouseRotateDelta:2.5,mousePitchDelta:2.5,mobilePinchDelta:1,mobileTapDelta:10},Ra={duration:1300,maxSpeed:8,minSpeed:.02,nonLinearity:5},zt={fov:60*Math.PI/180,useDynamicNearFar:!1,near:1e3,far:oe(2,34),viewportLimitRatio:2.1,minTrapezeHeight:2*131072,perspectiveDistanceLimitRatio:10,minFogDistance:2e4,fogHorizonPadFactor:.15,pitchInterStartZoom:17,pitchInterEndZoom:19},On={globeMaxZoom:8,globeInterStartZoom:7,globeInterEndZoom:16},cd=1e3,ud=16,Na={enabled:!0,displayStyleZoom:{default:18,metro:16},detailLevel:16,wallMinBrightness:.8265,wallMaxBrightness:.95,viewportPadding:.2,maxStackHeight:40},dd={fpsCaveat:10},fd=3e4,Ba=["Commercial_poi_city"],ka=["Commercial_poi_premium"],hd=["Commercial_poi_default","Commercial_poi_custom","Commercial_poi_navi",...Ba,...ka],pd=["Commercial_model","Commercial_model_animated","Commercial_model_on_click"],md=["s_personal_poi"],yd=["Landmark_poi","Landmark_point"],gd=[105,84,63,42,21],vd="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzBweCIgaGVpZ2h0PSI0OHB4IiB2aWV3Qm94PSIwIDAgMzAgNDgiIHZlcnNpb249IjEuMSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIiB4bWxuczp4bGluaz0iaHR0cDovL3d3dy53My5vcmcvMTk5OS94bGluayI+PCEtLSBHZW5lcmF0b3I6IFNrZXRjaCA1MS4yICg1NzUxOSkgLSBodHRwOi8vd3d3LmJvaGVtaWFuY29kaW5nLmNvbS9za2V0Y2ggLS0+PHRpdGxlPlBhZ2UgMSBDb3B5PC90aXRsZT48ZGVzYz5DcmVhdGVkIHdpdGggU2tldGNoLjwvZGVzYz48ZGVmcz48bGluZWFyR3JhZGllbnQgeDE9IjUwJSIgeTE9IjUwJSIgeDI9IjUwJSIgeTI9IjAlIiBpZD0ibGluZWFyR3JhZGllbnQtMSI+PHN0b3Agc3RvcC1jb2xvcj0iIzFCODlFRSIgb2Zmc2V0PSIwJSI+PC9zdG9wPjxzdG9wIHN0b3AtY29sb3I9IiMzMTk4RUMiIG9mZnNldD0iMTAwJSI+PC9zdG9wPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxnIGlkPSJQYWdlLTEiIHN0cm9rZT0ibm9uZSIgc3Ryb2tlLXdpZHRoPSIxIiBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxnIGlkPSJSZWNvdmVyeS0wMSIgdHJhbnNmb3JtPSJ0cmFuc2xhdGUoLTgzOS4wMDAwMDAsIC00MjUuMDAwMDAwKSI+PGcgaWQ9IlBhZ2UtMS1Db3B5IiB0cmFuc2Zvcm09InRyYW5zbGF0ZSg4MzkuMDAwMDAwLCA0MjUuMDAwMDAwKSI+PGVsbGlwc2UgaWQ9Ik92YWwtMyIgZmlsbD0iIzAwMDAwMCIgb3BhY2l0eT0iMC4wMzYzODA1OTciIGN4PSIxNSIgY3k9IjQ1LjUiIHJ4PSIzIiByeT0iMS41Ij48L2VsbGlwc2U+PGVsbGlwc2UgaWQ9Ik92YWwtMy1Db3B5IiBmaWxsPSIjMDAwMDAwIiBvcGFjaXR5PSIwLjAzNjM4MDU5NyIgY3g9IjE1IiBjeT0iNDUuNSIgcng9IjQuNSIgcnk9IjIuNSI+PC9lbGxpcHNlPjxwYXRoIGQ9Ik0xNSw0NS44ODM2MzUzIEwxNS44ODIzNTI5LDQ1Ljg4MzYzNTMgQzE1Ljg4MjM1MjksMjkuMjE3NzUyOSAyMC43NzY3NjQ3LDIzLjc5NzQ1ODggMjcuOTg3MzUyOSwyMy43OTc0NTg4IEwyOC4zMjk3MDU5LDIzLjc5NzQ1ODggQzI5LjA3Nzk0MTIsMjEuNTkwNjk0MSAzMCwxNy45OTE1NzY1IDMwLDE1LjAwMDQgQzMwLDcuMTQzOTI5NDEgMjMuNzY3OTQxMiwwLjAwMDQgMTUsMC4wMDA0IEM2LjIzMjA1ODgyLDAuMDAwNCAwLDcuMTQzOTI5NDEgMCwxNS4wMDA0IEMwLDE3Ljk5MTU3NjUgMC45MjIwNTg4MjQsMjEuNTkwNjk0MSAxLjY3MDI5NDEyLDIzLjc5NzQ1ODggTDIuMDEyNjQ3MDYsMjMuNzk3NDU4OCBDOS4yMjQxMTc2NSwyMy43OTc0NTg4IDE0LjExNzY0NzEsMjkuMjE3NzUyOSAxNC4xMTc2NDcxLDQ1Ljg4MzYzNTMgTDE1LDQ1Ljg4MzYzNTMgWiIgaWQ9IkZpbGwtMSIgZmlsbD0idXJsKCNsaW5lYXJHcmFkaWVudC0xKSI+PC9wYXRoPjwvZz48L2c+PC9nPjwvc3ZnPg==",wd=[15,46],bd=16,Id={bias:100,textureSize:[2048,2048],shadowRadius:3},hm=Object.freeze(Object.defineProperty({__proto__:null,DEFAULT_MIN_TIERS_STYLE_ZOOM:bd,MAP_DEFAULTS:La,atlasSize:cn,buildingAnimation:id,cityCommPoiLabelingConfig:rd,commercialCitySublayers:Ba,commercialModelSublayers:pd,commercialPoi:Ca,commercialPremiumSublayers:ka,commercialSublayers:hd,defaultCameraConfig:zt,defaultLang:ad,defaultMarkerAnchor:wd,defaultMarkerIcon:vd,defaultShadowsSettings:Id,dem:qu,entranceAnimation:sd,events:td,floors:Na,fonts:Ut,globeConfig:On,houseHover:Ms,icons:Qu,identify:Fa,inertia:Ra,labeling:Sr,landmarkPoiSublayers:yd,landmarkRasterSizes:gd,loadModelsInfoStyleZoom:Da,maxZoomForDynamicNear:ud,metricsTimeout:fd,minCalculationScreenHeight:cd,modelCacheSize:Ju,models:Xu,performanceCheck:dd,personalSublayers:md,render:od,styles:ed,tileAnimation:Oa,tiles:ni,traffic:Ku,urls:Tr,workerResetInterval:nd,zoom:ld},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 pm(e,t){return[t[0]/e[0]*2-1,-(t[1]/e[1])*2+1]}function Me(e){return e*Math.PI/180}function ii(e){return e/Math.PI*180}function Md(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 Fn(e,t){const n=de({},t);for(const i in e)e[i]!==void 0&&(n[i]=e[i]);return n}function Ua(e){const t={};for(const n in e){const i=e[n];t[i]=n}return t}function Td(e,t){const n=[];for(const i in e)t[i]||n.push(e[i]);return n}function za(e,t,n){return xe((n-e)/(t-e),0,1)}function mm(e){return e%1}function Ga(e,t,n){return e>=t&&e<=n}function ym(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 gm(e,t){return e===t?!0:e.length!==t.length?!1:!e.some((n,i)=>n!==t[i])}function Fi(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(!Fi(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],!Fi(e[o],t[o]))return!1;return!0}return e!==e&&t!==t}function vm(e,t){const n=e.indexOf(t);return n!==-1?(e.splice(n,1),!0):!1}function Ri(e,t,n){return e+(t-e)*n}function wm(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 Sd{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 bm(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function Ed(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 Im(e){let t=new Tt(2);return t[0]=e[0],t[1]=e[1],t}function Va(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 je(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 ja(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e}function Mm(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e}function Tm(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 Ts(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 Sm(e){var t=e[0],n=e[1];return t*t+n*n}function Rn(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 Nn(e,t){return e[0]*t[0]+e[1]*t[1]}function Ha(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 Em(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 Ad=_r,un=ja,Bn=Ts;(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 xd(){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 Am(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 xm(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 _m(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 $a(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 Pm(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 Ss(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],y=t[15],b=n*a-i*o,w=n*l-s*o,I=n*c-r*o,E=i*l-s*a,A=i*c-r*a,P=s*c-r*l,T=u*v-d*g,C=u*p-f*g,U=u*y-h*g,B=d*p-f*v,j=d*y-h*v,z=f*y-h*p,S=b*z-w*j+I*B+E*U-A*C+P*T;return S?(S=1/S,e[0]=(a*z-l*j+c*B)*S,e[1]=(s*j-i*z-r*B)*S,e[2]=(v*P-p*A+y*E)*S,e[3]=(f*A-d*P-h*E)*S,e[4]=(l*U-o*z-c*C)*S,e[5]=(n*z-s*U+r*C)*S,e[6]=(p*I-g*P-y*w)*S,e[7]=(u*P-f*I+h*w)*S,e[8]=(o*j-a*U+c*T)*S,e[9]=(i*U-n*j-r*T)*S,e[10]=(g*A-v*I+y*b)*S,e[11]=(d*I-u*A-h*b)*S,e[12]=(a*C-o*B-l*T)*S,e[13]=(n*B-i*C+s*T)*S,e[14]=(v*w-g*E-p*b)*S,e[15]=(u*E-d*w+f*b)*S,e):null}function Ya(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],y=t[14],b=t[15],w=n[0],I=n[1],E=n[2],A=n[3];return e[0]=w*i+I*a+E*d+A*v,e[1]=w*s+I*l+E*f+A*p,e[2]=w*r+I*c+E*h+A*y,e[3]=w*o+I*u+E*g+A*b,w=n[4],I=n[5],E=n[6],A=n[7],e[4]=w*i+I*a+E*d+A*v,e[5]=w*s+I*l+E*f+A*p,e[6]=w*r+I*c+E*h+A*y,e[7]=w*o+I*u+E*g+A*b,w=n[8],I=n[9],E=n[10],A=n[11],e[8]=w*i+I*a+E*d+A*v,e[9]=w*s+I*l+E*f+A*p,e[10]=w*r+I*c+E*h+A*y,e[11]=w*o+I*u+E*g+A*b,w=n[12],I=n[13],E=n[14],A=n[15],e[12]=w*i+I*a+E*d+A*v,e[13]=w*s+I*l+E*f+A*p,e[14]=w*r+I*c+E*h+A*y,e[15]=w*o+I*u+E*g+A*b,e}function _d(e,t,n){let i=n[0],s=n[1],r=n[2],o,a,l,c,u,d,f,h,g,v,p,y;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],y=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]=y,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+y*r+t[15]),e}function Ni(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 Wa(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 Pd(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 Lm(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 Ld(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 Cm(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,y=a*l,b=a*c,w=a*u,I=i[0],E=i[1],A=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)*E,e[5]=(1-(d+p))*E,e[6]=(v+y)*E,e[7]=0,e[8]=(h+b)*A,e[9]=(v-y)*A,e[10]=(1-(d+g))*A,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function Dm(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 Za(e,t,n,i){let s,r,o,a,l,c,u,d,f,h,g=t[0],v=t[1],p=t[2],y=i[0],b=i[1],w=i[2],I=n[0],E=n[1],A=n[2];return Math.abs(g-I)<Mt&&Math.abs(v-E)<Mt&&Math.abs(p-A)<Mt?mat4.identity(e):(u=g-I,d=v-E,f=p-A,h=1/Math.sqrt(u*u+d*d+f*f),u*=h,d*=h,f*=h,s=b*f-w*d,r=w*u-y*f,o=y*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 Om(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 Bi=Ya;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 Cd=6378137,Xa=2*Math.PI*Cd,Te=4294967296/Xa,Fm=Cr([],[-1,-1,0],[2,2,1]),Rm=Cr([],[.5,.5,0],[.5,.5,1]),si=Cd*(Math.PI/2),Nm=oe(2,16)/4294967296;function qa(e){return Math.max(e,cd)}function ki(e,t){const n=zt,i=qa(t[1])/2,s=4294967296/oe(2,e),r=i/256*s,o=Math.tan(n.fov/2);return r/o}function Bm(e,t){const n=zt;return Math.log(qa(t[1])*4294967296/(2*256*Math.tan(n.fov/2)*e))/Math.LN2}function km(e){return Hu*Math.pow(2,-e)}function Um(e,t){return ju*(e/Is)/t}function Ja(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 zm(e){let t=0;if(e.length>1)for(let n=0;n<e.length-1;n++)t+=Ja(e[n],e[n+1]);return t}const Gm={min:[-2147483648,-2147483648],max:[4294967296/2,4294967296/2]},Vm={min:[-214748364800,-2147483648],max:[4294967296*100/2,4294967296/2]};function Es(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 Dd(e,t){return e*Math.pow(2,-t)*4294967296/256}function jm(e,t){return e*Math.pow(2,t)*256/4294967296}function Od(e,t){return e===0?-1/0:-Math.log(t*256/(e*4294967296))/Math.LN2}const Ka=Oe(),Fd=Oe();function Hm(e,t,n){ja(Ka,n,e),ja(Fd,t,e);const i=Nn(Ka,Fd)/_r(Ka);return Math.atan2(i,e[2])}function $m(e){const t=e[0],n=e[1];return Ga(t,-2147483648,2147483648)&&Ga(n,-2147483648,2147483648)}function Ym(e){const t=[...e];return $m(t)||(t[0]=(4294967296+(t[0]+2147483648)%4294967296)%4294967296-2147483648),t}function Dr(e,t){const n=Math.cos(Me(t[0]-e[0])),i=Math.sin(Me(t[1])),s=Math.sin(Me(e[1])),r=Math.cos(Me(t[1])),o=Math.cos(Me(e[1]));return Math.acos(i*s+r*o*n)}function Wm(e,t,n){const i=Me(e[0]),s=Me(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])),[ii(r[0]),ii(r[1])]}function mt(){let e=new Tt(3);return e[0]=0,e[1]=0,e[2]=0,e}function Zm(e){var t=new Tt(3);return t[0]=e[0],t[1]=e[1],t[2]=e[2],t}function kn(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 Qa(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 ri(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e}function Xm(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e}function Un(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,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 qm(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 Jm(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 Jt(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 el(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]}function As(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 oi(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 xs(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 Km(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 Qm(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 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[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 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[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 ny(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function iy(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 Kt=Xm,tl=Rd,sy=qm,Or=kn;(function(){let e=mt();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 _s(){let e=new Tt(4);return e[0]=0,e[1]=0,e[2]=0,e[3]=0,e}function ry(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 oy(e,t,n,i,s){return e[0]=t,e[1]=n,e[2]=i,e[3]=s,e}function ay(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 ly(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 cy(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 uy(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 dy(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 fy=ay;(function(){let e=_s();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 ai=_s();class re{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(Me(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=re.scaleFactor(t[1]);a=((l=t[2])!=null?l:0)*Te*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*ii(Math.atan(Math.exp(t[1]*i))),t[2]){const s=re.scaleFactor(n[1]);n[2]=t[2]/Te/s}return n}static scaleFactor(t){return 1/Math.cos(Me(t))}update(){const{center:t,rotation:n,zoom:i,pitch:s,size:r}=this.state,o=ki(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;ai[0]=t[0],ai[1]=t[1],ai[2]=t[2],ai[3]=1,Fr(ai,ai,this.camera.viewProjectionMatrix);const[o,a,l,c]=ai,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,xs(n,n,this.camera.viewProjectionMatrixInverse),n[0]-=this.position[0],n[1]-=this.position[1],n[2]-=this.position[2],Jt(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 li=_s();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 Sd(()=>{const i=ki(this.state.zoom,this.state.size)/Te;return Math.acos(si/(si+i))},()=>[this.state.zoom]),this.cachedPixelRadius=new Sd(()=>{const i=re.toGeo(this.state.center),s=Wm(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,Ad(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=Me(t[0]),s=Me(t[1]),r=Math.cos(i),o=Math.sin(i),a=Math.cos(s),l=Math.sin(s),c=si*Te;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]=ii(l),n[1]=ii(a),n}update(){const{state:t}=this,n=re.toGeo(t.center),i=ki(t.zoom,t.size)+si*Te,s=Me(n[0]),r=Me(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];Za(this.ivpMatrix,kd(this.position),[0,0,0],u),Bi(this.ivpMatrix,this.camera.projectionMatrix,this.ivpMatrix),Ss(this.ivpMatrix,this.ivpMatrix)}project(t,n=!1,i=[NaN,NaN]){const{size:s,viewport:r}=this.state,o=_s();li[0]=t[0],li[1]=t[1],li[2]=t[2],li[3]=1,Fr(li,li,this.camera.globeMatrix),Fr(o,li,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];xs(l,o,this.ivpMatrix);const c=Jt([],Kt([],l,a)),u=Nd([],a),d=el(u,c),f=Jm(u)-oe(d,2),h=oe(si*Te,2);if(f>h){if(n)return lt.fromGeo(re.toGeo(this.state.center));const{left:b,bottom:w,top:I,right:E}=this.state.padding,A=t[0]-r.left-s[0]/2-(b-E)/2,P=t[1]-r.top-s[1]/2-(I-w)/2,T=_t([],Rn([],[A,P]),this.pixelRadius-1);return T[0]=T[0]+r.left+s[0]/2+(b-E)/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,y=Math.min(v,p);return i[0]=a[0]+c[0]*y,i[1]=a[1]+c[1]*y,i[2]=a[2]+c[2]*y,i}setState(t){this.state=t}canSee(t){const n=re.toGeo(this.state.center);return Dr(n,t)<this.visibleArc}}const hy=[0,0,1],py=mt(),Pt=[0,0,0],my=1e-5,yy=500;class Ps{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 re(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(),Ya(this.viewProjectionMatrix,this.projectionMatrix,this.viewMatrix),Ss(this.viewProjectionMatrixInverse,this.viewProjectionMatrix),Ss(this.projectionMatrixInverse,this.projectionMatrix),Pm(this.viewMatrixTranspose,this.viewMatrix),this.globeRatio>Number.EPSILON&&this.updateGlobeMatrix(),Bi(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(re.fromGeo(t),n,i);if(this.globeRatio>1-Number.EPSILON)return this.ecef.project(lt.fromGeo(t),n,i);{const s=this.flat.project(re.fromGeo(t),n),r=this.ecef.project(lt.fromGeo(t),n);return Array.from(oi(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),re.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),re.toGeo(s,s),this.ecef.unproject(t,!1,r),lt.toGeo(r,r),i?(nl(this,t,r,s,n,2),n[2]=0,n):(oi(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=ki(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}=On;if(this.correctedPitch=i,this.correctedRotation=s,n<u){const h=Math.max(0,n-c)/(u-c);this.correctedPitch=Math.min(i,Ri(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,Ri(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,Ss(this.projectionMatrixInverse,this.projectionMatrix)}updateNearFarState(){const{zoom:t,cameraConfig:n}=this.state,i=this.position;if(t>ud)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=oe(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=qa(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=tl(this.position,t);this.fogDistance=Math.max(n.minFogDistance,i)}updateViewMatrix(){Za(this.viewMatrix,this.position,this.state.center,hy)}updateGlobeMatrix(){const t=this.globeMatrix,n=[0,0,0];$a(t);const i=re.toGeo(this.state.center);De(n,this.state.center[0],this.state.center[1],-this.state.center[2]-si*Te),_d(this.globeMatrix,t,n),Wa(t,t,Me(i[1])),Pd(t,t,-Me(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]);Kt(Pt,o,s),ty(Pt,Pt,py,Me(90)),Jt(Pt,Pt);const a=Dd(n[1]*this.state.cameraConfig.perspectiveDistanceLimitRatio,i);Un(Pt,Pt,a),ri(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,yy*i/1e3);this.globeRatio+=(t-this.globeRatio)*s,Math.abs(this.globeRatio-t)<my&&(this.globeRatio=t)}}function nl(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=Bn(c,t),d=Bn(a,t),f=Bn(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?nl(e,t,i,s,s,r,o+1):nl(e,t,n,s,s,r,o+1)}function gy(e,t,n){n.zoom!==void 0&&(n.zoom=xe(n.zoom,e.minZoom,e.maxZoom));const i=de({},e);Es(i.center);const s=new Ps(i),r=s.unproject(t),o=re.fromGeo(r);n.center&&Es(n.center),s.setState(de(de({},e),n));const a=re.fromGeo(s.unproject(t));Math.abs(o[0]-a[0])>oe(2,31)&&(a[0]+=(o[0]>0?1:-1)*oe(2,32));const l=mt();if(Kt(l,o,a),e.globeMode&&Math.abs(r[1])>70&&e.zoom>On.globeInterStartZoom&&e.zoom<On.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,oe(10,6-d));Number.isNaN(f)||Un(l,l,f)}}return l}function Ud(e){const n=re.toGeo(e)[1],i=1/(2*Math.cos(Me(n)));return Math.log(i)/Math.log(2)}function vy(e,t){const n=re.scaleFactor(t[1]);return 1+e*(n-1)}function zd(e,t){const n=Ud(t)*za(9,10,e);return e+xe(n,-1,0)}function wy(e,t){const n=Ud(t),i=n*za(9,10+n,e);return e-xe(i,-1,0)}function by(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 Ps({center:re.fromGeo(e),zoom:t,rotation:Me(n),size:i,pitch:Me(s),viewport:o,padding:a,cameraConfig:u,globeMode:!1,styleState:{}}),f=re.toGeo(d.flat.unproject(r)),h=re.toGeo(d.flat.unproject([r[0]+l,r[1]+c]));return Math.max(1,Ja(f,h))}function Rr(e,t){return t*Te*re.scaleFactor(e[1])}function Ls(e,t){return{min:e||Va(1/0,1/0),max:t||Va(-1/0,-1/0)}}function Iy(e){return Ls(re.fromGeo(e.southWest),re.fromGeo(e.northEast))}function ci(e,t){Mm(e.min,e.min,t),Tm(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 il(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 My(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 Ty(e,t,n){e[1]=xe(n[1],t.min[1],t.max[1])}function Sy(e,t){return t[0]<=e.max[0]&&t[0]>=e.min[0]&&t[1]<=e.max[1]&&t[1]>=e.min[1]}function Ey(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 Ay(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 xy(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 sl(){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 _y(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 Py(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],y=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+y*c,e[4]=v*s+p*a+y*u,e[5]=v*r+p*l+y*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 Ly(e){return e[0]=0,e[1]=0,e[2]=0,e[3]=1,e}function Cy(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 Dy(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 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+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 Fy(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=cy;(function(){let e=mt(),t=at(1,0,0),n=at(0,1,0);return function(i,s,r){let o=el(s,r);return o<-.999999?(As(e,t,s),Or(e)<1e-6&&As(e,n,s),Jt(e,e),Cy(i,e,Math.PI),i):o>.999999?(i[0]=0,i[1]=0,i[2]=0,i[3]=1,i):(As(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=sl();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,Fy(t,e))}})();const Qt=[0,0,0],en=[0,0,0],rl=mt();sl();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 Kt(Qt,n,t),Kt(en,n,i),As(e,en,Qt),Jt(e,e),e}function tn(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&&Rn(e,e)}else e[0]=0,e[1]=0}function Ye(e){return xe(e*127,-127,127)}function ol(e,t=e){return e[0]=Ye(t[0]),e[1]=Ye(t[1]),e}function Ry(e,t,n,i,s){e[0]=t*i+n*s,e[1]=n*i-t*s}function zn(e,t){const n=t[0];e[0]=-t[1],e[1]=n}function al(e,t){const n=t[0];e[0]=t[1],e[1]=-n}function Ny(e){return e[0]===0&&e[1]===0}function By(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])}function ky(e,t){return[(e[0]+t[0])/2,(e[1]+t[1])/2]}function Uy(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];je(e,s,r)}function zy(e,t,n,i,s=!0){if(Pr(t,n)||Pr(n,i)){je(e,0,0);return}un(Qt,n,t),un(en,i,n),s?(zn(Qt,Qt),zn(en,en)):(al(Qt,Qt),al(en,en)),Rn(Qt,Qt),Rn(en,en),Gt(e,Qt,en),Rn(e,e)}function Gy(e,t,n){t[0]=kn(De(rl,e[0],e[1],e[2])),t[1]=kn(De(rl,e[3],e[4],e[5])),t[2]=kn(De(rl,e[6],e[7],e[8]))}function Vy(e,t,n,i){t[0]=kn(at(e[0],e[1],e[2])),t[1]=kn(at(e[4],e[5],e[6])),t[2]=kn(at(e[8],e[9],e[10])),n[0]=e[12],n[1]=e[13],n[2]=e[14]}function jy(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 ll=/\{(\w+)\}/g;function Cs(e,t){return e.replace(ll,(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 Hy(e,t){return(typeof e=="object"?e.url:Tr[e]).replace(ll,(n,i)=>{var s;return(s=t[i])!=null?s:n}).replace(ll,(n,i)=>{var s;return(s=t[i])!=null?s:n})}function Ds(e,t){const n=Cs(t.host,{subdomain:t.subdomain}),i=Cs(typeof e=="object"?e.url:Tr[e],Ie(de({},t),{host:n}));return Yd(i)}function Os(e,t){const n=Cs(e,t);return Yd(n)}function cl(e,t){let n=0;for(let i=0;i<t.length;i++)n+=t.charCodeAt(i);return e[n%e.length]}function $y(e,t){const n=new URL(t);return e.startsWith("//")?`${n.protocol}${e}`:e.startsWith("/")?`${n.origin}${e}`:e}for(var Ui="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Yy=typeof Uint8Array=="undefined"?[]:new Uint8Array(256),Ur=0;Ur<Ui.length;Ur++)Yy[Ui.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+=Ui[t[n]>>2],s+=Ui[(t[n]&3)<<4|t[n+1]>>4],s+=Ui[(t[n+1]&15)<<2|t[n+2]>>6],s+=Ui[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 Wy(e){let t=0;for(let n=0;n<e.length;n++)t+=e[n]*oe(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/oe(256,5-n))&255;return encodeURIComponent(Wd(t.buffer))}function Zy(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=Zy(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]=Ua(e.enumerationValues[s]),i),{}),tileProps:t,tilePropsByIndex:Ua(t),defaultProps:n,vertexPropsLegacy:dl(e.vertexProps)?Xy(e):{},vertexProps:dl(e.vertexProps)?[]:e.vertexProps,tileCoverage:e.tileCoverage}}function Xy(e){const t=e.vertexProps,n={point:["x","y","z"],polygon:["x","y","cut","signed_z"],polyline:["x","y"]};if(!t)return n;if(!dl(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 Fs(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 pe=0;const ui={beginningIsCut:pe++,class:pe++,componentDistanceEnd:pe++,componentDistanceStart:pe++,db_icon_priority:pe++,db_label_priority:pe++,db_label2_priority:pe++,dpi:pe++,endingIsCut:pe++,height:pe++,db_hidden_by_plan_building_id:pe++,db_hidden_by_plan_id:pe++,id:pe++,isRealtime:pe++,db_label:pe++,db_label2:pe++,nextPointX:pe++,nextPointY:pe++,db_object_class:pe++,objectLength:pe++,pixelDensityPreset:pe++,previousPointX:pe++,previousPointY:pe++,db_region:pe++,selected:pe++,hovered:pe++,db_sublayer:pe++,traffic_color:pe++,traffic_road_class:pe++,traffic_road_z_level:pe++,db_tiers:pe++,model_src:pe++,linkedIds:pe++,db_model_rotation_angle:pe++,db_plan_id:pe++,traffic_color2:pe++},qy={version:"5.0.0",tileProps:ui,tilePropsByIndex:Ua(ui),defaultProps:{},dictionaries:{},reverseDictionaries:{},vertexPropsLegacy:{},vertexProps:[]},Jd=[],ul={},Kd={sourceName:"zenith"};function dl(e){return!Array.isArray(e)}class fl{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 Jy=1;function hl(){return Jy++}let Ky=1;const pl=()=>++Ky,Qy=pl(),eg=pl(),ml=65536*65536,Qd=1/ml,tg=12,ef=typeof TextDecoder=="undefined"?null:new TextDecoder("utf-8"),yl=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)*ml;return this.pos+=8,t}readSFixed64(){const t=this.dataView.getUint32(this.pos,!0)+this.dataView.getInt32(this.pos+4,!0)*ml;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,ng(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>=tg&&ef?ef.decode(this.buf.subarray(n,t)):mg(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===yl)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){ig(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=yg(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,og,n)}writePackedSVarint(t,n){n.length&&this.writeMessage(t,ag,n)}writePackedBoolean(t,n){n.length&&this.writeMessage(t,ug,n)}writePackedFloat(t,n){n.length&&this.writeMessage(t,lg,n)}writePackedDouble(t,n){n.length&&this.writeMessage(t,cg,n)}writePackedFixed32(t,n){n.length&&this.writeMessage(t,dg,n)}writePackedSFixed32(t,n){n.length&&this.writeMessage(t,fg,n)}writePackedFixed64(t,n){n.length&&this.writeMessage(t,hg,n)}writePackedSFixed64(t,n){n.length&&this.writeMessage(t,pg,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,yl),this.writeVarint(n)}writeSVarintField(t,n){this.writeTag(t,yl),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 ng(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 zi(e,s,t);throw new Error("Expected varint not more than 10 bytes")}function zi(e,t,n){return n?t*4294967296+(e>>>0):(t>>>0)*4294967296+(e>>>0)}function ig(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),sg(n,i,t),rg(i,t)}function sg(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 rg(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 og(e,t){for(let n=0;n<e.length;n++)t.writeVarint(e[n])}function ag(e,t){for(let n=0;n<e.length;n++)t.writeSVarint(e[n])}function lg(e,t){for(let n=0;n<e.length;n++)t.writeFloat(e[n])}function cg(e,t){for(let n=0;n<e.length;n++)t.writeDouble(e[n])}function ug(e,t){for(let n=0;n<e.length;n++)t.writeBoolean(e[n])}function dg(e,t){for(let n=0;n<e.length;n++)t.writeFixed32(e[n])}function fg(e,t){for(let n=0;n<e.length;n++)t.writeSFixed32(e[n])}function hg(e,t){for(let n=0;n<e.length;n++)t.writeFixed64(e[n])}function pg(e,t){for(let n=0;n<e.length;n++)t.writeSFixed64(e[n])}function mg(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 yg(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 di(e,t){return{a:e[1]-t[1],b:t[0]-e[0],c:e[0]*t[1]-t[0]*e[1]}}function gg(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 vg(e,t,n){const{a:i,b:s,c:r}=di(e,t);return at(n,-(i*n+r)/s,0)}function wg(e,t,n){const{a:i,b:s,c:r}=di(e,t);return at(-(s*n+r)/i,n,0)}const fi=Ls(),yt=Ls();function bg(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=[],Ha(l,s,c,f)}d=l}o.push(d),s=d,r=t[a],a++}return o}function Ig(e,t){let n=e[0];il(fi),ci(fi,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,fi),ci(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=vg(n,l,c),a=!0}if(a&&(Gd(yt,fi),ci(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=wg(n,l,c),a=!0}a?(i.push(l),il(fi),ci(fi,l),i=[l],s.push(i),n=l):(i.push(o),ci(fi,o),n=o,r++)}return s}function Mg(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 Tg(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=[di(e[3],e[2]),di(e[1],e[0]),di(e[0],e[3]),di(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 Sg(e,t,n){e.forEach(i=>{const s=1+t/Rd(n,i);oi(i,n,i,s)})}function Eg(e,t){if(e.tiles)for(const n of e.tiles)t.writeMessage(1,Ag,n)}function Ag(e,t){e.x&&t.writeVarintField(1,e.x),e.y&&t.writeVarintField(2,e.y),e.zoom&&t.writeVarintField(3,e.zoom)}function xg(e,t){return e.readFields(_g,{tileGroups:[]},t)}function _g(e,t,n){e===1&&t.tileGroups.push(Pg(n,n.readVarint()+n.pos))}function Pg(e,t){return e.readFields(Lg,{x:0,y:0,zoom:0,tiles:[]},t)}function Lg(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(Cg(n,n.readVarint()+n.pos))}function Cg(e,t){return e.readFields(Dg,{regionId:0,hash:void 0,data:void 0},t)}function Dg(e,t,n){e===1?t.regionId=n.readVarint():e===2?t.hash=n.readBytes():e===3&&(t.data=n.readBytes())}const Gi=[0,0,0];function gt(e){return{coords:e,size:jt(e[2]),offset:ji(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 Og(e,t){return`${Le(e)}_${t.stringify()}`}function gl(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 ni.subdomains[Math.abs(e[0]+e[1])%ni.subdomains.length]}function Fg(e){const t=new Vr(e),n=xg(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:Wy(l)}))}function Rg(e){return e.map(t=>({regionId:t.regionId,metatileHash:t.metatileHash}))}function Ng(e){const t=Math.ceil(e.byteLength/4)*4,n=new ArrayBuffer(t);return new Uint8Array(n).set(e),n}function vl(e){const[t,n,i]=e;return{min:ji([t,n,i,i]),max:ji([t+1,n+1,i,i])}}function Hr(e,t,n,i=0){const s=vl(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 Bg(e){return Math.trunc(e/2)*2+1}function wl(e,t=1,n=3,i=!1){let s=1/Math.cos(Me(e));return i&&(s=Math.log2(s)),xe(Math.ceil(s),t,n)-1}const kg=(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 Ug(e,t,n){const i=zg(t,e.size),s=Math.trunc(t),r=Array.from(e.center);Es(r);const o=re.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 Ps(e),f=af(e,d,o),h=ev(u,o,f,d,e),g=[];return h.forEach(v=>{kg([NaN,2,2,NaN],v)?g.push(...ff(v,1)):g.push(v)}),g.filter(v=>Zr(e,d,v))}function zg(e,t){const n=si*Te,i=ki(e,t)+n,s=zt.fov/2,r=Math.sin(s),o=Math.cos(s),a=n/i;let l=ii(Math.acos(oe(r,2)/a+o*Math.sqrt(1-oe(r,2)/oe(a,2))));return Number.isNaN(l)&&(l=90),l}function af(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 Gg(e,t,n,i,s,r){const[,,o]=e,a=jg(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 Vg(e,t){const i=Math.trunc(e.zoom),s=Array.from(e.center);Es(s),re.toGeo(s,s);const r=[],o=new Ps(e),a=af(e,o,s);function l(c,u=0){if(vf(s,a,c)&&Zr(e,o,c))if(Gg(c,s,2,i,o.ecef.visibleArc,u))r.push(c);else for(const d of ff(c,1))l(d,u+1)}return Ug(e,Math.trunc(e.zoom),2).map(([c,u,d])=>{l([c,u,d,t])}),r}function jg(e){return{min:lf(e),max:lf([e[0]+1,e[1]+1,e[2],e[3]])}}function lf(e){const t=ji(e);return re.toGeo(t)}function cf(e,t){var s;if(!e)return!1;const n=(s=e.gridState)==null?void 0:s.minZoomLevel,i=n!==void 0?n+1:1/0;return t>=i}function uf(e,t,n,i,s,r=0,o=1/0,a=!1,l=!1,c){if(e.globeMode)return Vg(e,s);a&&(n=Bg(n),n>o&&(n-=2));const u=jr(e.tilesBounds),d=jt(n),f=oe(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),y=[],b=new Set,w=cf(c,e.styleZoom);for(let I=h;I<=g;I++)for(let E=v;E<=p;E++){const A=[I,E,n,s];if(Hr(A,e.tilesBounds,t,r)){if(w&&Ml(A,e.styleZoom,t))continue;A[0]=(f+A[0]%f)%f;const P=Le(A);b.has(P)||(b.add(P),y.push(A))}}return l===!0&&Hg(y,b,e,t,n,i,s,c),y}function Hg(e,t,n,i,s,r,o,a){const l=new Set,c=Tg(n.tilesBounds),u=cf(a,n.styleZoom);let d=e;for(let f=s;f>=r;f--){let h=0;const g=[];d.forEach(A=>{const P=df(A),T=Le(P);l.has(T)||(g.push(P),l.add(T),$g(P,C=>{const U=Le(C);if(!t.has(U)&&!l.has(U)&&Hr(C,n.extendedTilesBounds,i)){if(u&&Ml(C,n.styleZoom,i))return;e.push(C),t.add(U),h++}}))});const v=jt(f-1);Sg(c,v,n.center);const p=jr(c),y=oe(2,f-1),b=Math.floor((p.min[0]+2147483648)/v),w=Math.floor((p.max[0]+2147483648)/v),I=Math.max(Math.floor((p.min[1]+2147483648)/v),0),E=Math.min(Math.floor((p.max[1]+2147483648)/v),y-1);for(let A=b;A<=w;A++)for(let P=I;P<=E;P++){const T=[A,P,f-1,o];if(u&&Ml(T,n.styleZoom,i))continue;T[0]=(y+T[0]%y)%y;const C=Le(T);!l.has(C)&&Hr(T,c,i)&&(g.push(T),h++)}if(!h)break;d=g}}function df(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 ff(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 $g(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 Yg(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]}]};Eg(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 Ds(l?{url:l}:"tiles",g)}function Wg(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?hf(e,t):hf(t,e)}function hf(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 Ts(e,gf(t.coords,Gi))-Ts(e,gf(n.coords,Gi))}function vt(e,t,n){e[0]=t[0]*n.size/ee+n.offset[0],e[1]=t[1]*n.size/ee+n.offset[1],e[2]=t[2]}function Zg(e,t){e[0]=t.offset[0]/4294967296,e[1]=t.offset[1]/4294967296,e[2]=t.size/4294967296}const Yr=mt();function pf(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])*ee/n.size,e[1]=(t[1]-n.offset[1])*ee/n.size,e[2]=t[2]}function jt(e){return oe(2,32-e)}function bl(e){return e[0]>=0&&e[0]<=ee&&e[1]>=0&&e[1]<=ee}function Vi(e,t){return e*4294967296/(ee*Math.pow(2,t))}function it(e){return xe(e/bs*ee,0,Ve)}const mf=ee/bs;function yf(e){return e/ee*bs}function ji(e){const t=jt(e[2]),n=2147483648;return at(e[0]*t-n,e[1]*t-n,0)}function Xg(e){return[e[0]+2147483648,e[1]+2147483648,32,32]}function gf(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 qg(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,oe(2,i)-1-n,i,s]},Ct=(e,t)=>{vt(Gi,t,e);const n=re.toGeo(Gi);return re.scaleFactor(n[1])};function Ns(e,t,n){return vt(Gi,[e,t],n),re.toGeo(Gi)}function Jg(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 Kg(e,t){return lt.fromGeo(Ns(t[0],t[1],e))}function Gn(e,t,n,i){const s=[];return vt(s,i,n),Dr(re.toGeo(s),e)<t}function vf(e,t,n){const i=gt(n),s=ee;return Gn(e,t,i,[0,s/2,0])||Gn(e,t,i,[s,s/2,0])||Gn(e,t,i,[s/2,s,0])||Gn(e,t,i,[s/2,0,0])||Gn(e,t,i,[0,0,0])||Gn(e,t,i,[0,s,0])||Gn(e,t,i,[s,s,0])||Gn(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 Qg(e,t,n,i){const{mapPoint:s,geoPoint:r,ecefPoint:o}=Fe;vt(s,n,t),re.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===oe(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?ee:0,Fe.corner[1]=u===1||u===2?ee:0,Qg(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 ev(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),tv(u,a,t,n).filter(v=>Zr(s,i,v)).forEach(v=>{const[p,y,b]=v;a.set(p+"."+y+"."+b,!0),c.push(v),l.push(v)})}}return c}function tv(e,t,n,i){const[s,r,o,a]=e,l=oe(2,o)-1,c=p=>p>l?0:p<0?l:p,u=([p,y,b,w])=>((y>l||y<0)&&(y=y>l?l:0,p=b===0?p:(p+oe(2,b-1))%oe(2,b)),[p,y,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[y,b,w]=p;return!t.has(y+"."+b+"."+w)}).filter(p=>vf(n,i,p))}function nv(e,t,n,i=0){return""}function iv(e,t){let n=Math.trunc(t);for(;!e[n]&&n>=0;)n--;return n>=0?n:void 0}function sv(e,t){for(let n=0;n<t.length;n+=2){const i=t[n],s=t[n+1]!==void 0?t[n+1]:i;if(e>=i&&e<=s)return!0}return!1}function rv(e,t,n,i){const s=e[2],[r,o,a,l]=i.bbox_zenith;if(t.max[0]<=r||t.min[0]>=a||t.max[1]<=o||t.min[1]>=l)return!1;const c=i.tiles_covering_region,u=iv(c,Math.max(n,s));if(u===void 0)return!1;const d=c[u];if(!d)return!1;const f=s-u;if(f>=0){const b=df(e,f),w=d[b[0]];return!!w&&w.length>0&&sv(b[1],w)}const h=Math.pow(2,-f),g=e[0]*h,v=g+h,p=e[1]*h,y=p+h;for(const b in d){const w=Number(b);if(w<g||w>=v)continue;const I=d[b];if(!(!I||I.length===0))for(let E=0;E<I.length;E+=2){const A=I[E],P=I[E+1]!==void 0?I[E+1]:A;if(p<=P&&A<y)return!0}}return!1}function Ml(e,t,n){var r;const i=n.assetManager.getAllMetatiles(),s=vl(e);for(const o in i){const a=(r=i[o])==null?void 0:r.tileCoverage;if(a&&rv(e,s,t,a))return!0}return!1}var Tl=(e=>(e[e.Tile=0]="Tile",e[e.Custom=1]="Custom",e))(Tl||{});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,wf(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 wf(e){if(e<0||e>4)throw new Error("[WebGl] Invalid attribute location count. Must be 1, 2, 3 or 4")}const ie=class ie{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?ie.ElementArrayBuffer:ie.ArrayBuffer,this.options=Object.assign({},ie.defaultOptions,i),this.drawType=(a=i==null?void 0:i.drawType)!=null?a:ie.StaticDraw;const o=[ie.UnsignedByte,ie.UnsignedShort,ie.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=ie.UnsignedInt),this._preserveData=r}static _dataTypeSize(t){switch(t){case ie.Byte:case ie.UnsignedByte:return 1;case ie.UnsignedShort:case ie.Short:return 2;case ie.Float:case ie.Int:case ie.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===ie.ArrayBuffer){r.bindBuffer(r.ARRAY_BUFFER,this._glBuffer),t=t||0,n=n||this.options,s=s!=null?s:1,wf(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=ie._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===ie.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===ie.ArrayBuffer?n.ARRAY_BUFFER:t===ie.ElementArrayBuffer?n.ELEMENT_ARRAY_BUFFER:t===ie.StaticDraw?n.STATIC_DRAW:t===ie.DynamicDraw?n.DYNAMIC_DRAW:t===ie.Byte?n.BYTE:t===ie.Short?n.SHORT:t===ie.Int?n.INT:t===ie.Float?n.FLOAT:t===ie.UnsignedByte?n.UNSIGNED_BYTE:t===ie.UnsignedShort?n.UNSIGNED_SHORT:t===ie.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))}};ie.ArrayBuffer=1,ie.ElementArrayBuffer=2,ie.StaticDraw=10,ie.DynamicDraw=11,ie.Float=20,ie.UnsignedByte=21,ie.UnsignedShort=22,ie.UnsignedInt=23,ie.Byte=24,ie.Short=25,ie.Int=26,ie.defaultOptions={itemSize:3,dataType:ie.Float,stride:0,offset:0,normalized:!1,instanceDivisor:0,drawType:ie.StaticDraw};let Xe=ie;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 hi=(e=>(e[e.Striped=1]="Striped",e[e.Entrance=2]="Entrance",e[e.Patterned=3]="Patterned",e))(hi||{}),Bs=(e=>(e[e.Line=0]="Line",e[e.Arrow=1]="Arrow",e[e.StartBorder=2]="StartBorder",e[e.LineEnding=3]="LineEnding",e))(Bs||{}),me=(e=>(e[e.TileCut=0]="TileCut",e[e.Butt=1]="Butt",e[e.Round=2]="Round",e))(me||{});const qe=Oe(),Xr=Oe(),Hi=Oe(),Vn=Oe(),ks=Oe(),dn=Oe(),Sl=Oe(),Dt=Oe();let $i=0,jn=0;function El(e,t,n,i,s,r,o,a,l,c,u,d){var f,h,g,v;if(!(r<2)){if(tn(qe,t[0],n[0],t[1],n[1]),$i=0,o===me.Round){const p=c!==void 0?c[0]:0,y=u!==void 0?u[0]:0;Al(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,y,l,d)}for(let p=1;p<r;p++)cv(e,t,n,i,s,p,r,l,c,u,d);if(a===me.Round){const p=c!==void 0?c[r-1]:0,y=u!==void 0?u[r-1]:0;Al(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,y,l,d)}}}function cv(e,t,n,i,s,r,o,a,l,c,u){var g,v,p,y,b,w,I,E,A,P;const d=r===o-1;if(je(ks,t[r-1],n[r-1]),je(dn,t[r],n[r]),l!==void 0&&c!==void 0?(je(Hi,l[r-1],c[r-1]),je(Vn,l[r],c[r])):(je(Hi,0,0),je(Vn,0,0)),zn(Dt,qe),d)jn=0;else{je(Sl,t[r+1],n[r+1]),tn(Xr,dn[0],dn[1],Sl[0],Sl[1]);const T=xe(Nn(qe,Xr),-1,1);if(T<=0)jn=0,Al(e,dn[0],dn[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],Vn[0],Vn[1],a,u);else{const U=Math.sqrt((1-T)/(1+T)),B=Er(Nn(Dt,Xr));jn=U*B}}uv(e,0,1,3,3,1,2);const f=Dt[0]*Be,h=Dt[1]*Be;pi(e,ks[0],ks[1],(p=i==null?void 0:i[r-1])!=null?p:0,(y=s==null?void 0:s[r-1])!=null?y:0,(Dt[0]+qe[0]*$i)*Be,(Dt[1]+qe[1]*$i)*Be,f,h,Hi[0],Hi[1],a,u),pi(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]*$i)*Be,(-Dt[1]-qe[1]*$i)*Be,-f,-h,Hi[0],Hi[1],a,u),pi(e,dn[0],dn[1],(I=i==null?void 0:i[r])!=null?I:0,(E=s==null?void 0:s[r])!=null?E:0,(-Dt[0]+qe[0]*jn)*Be,(-Dt[1]+qe[1]*jn)*Be,-f,-h,Vn[0],Vn[1],a,u),pi(e,dn[0],dn[1],(A=i==null?void 0:i[r])!=null?A:0,(P=s==null?void 0:s[r])!=null?P:0,(Dt[0]-qe[0]*jn)*Be,(Dt[1]-qe[1]*jn)*Be,f,h,Vn[0],Vn[1],a,u),d||(xr(qe,Xr),$i=jn)}function Al(e,t,n,i,s,r,o,a,l,c,u){dv(e,0,1,2);const d=-r*.01,f=-o*.01;pi(e,t,n,i,s,r+d,o+f,r,o,a,l,c,u),pi(e,t,n,i,s,-o+d,r+f,-o,r,a,l,c,u),pi(e,t,n,i,s,o+d,-r+f,o,-r,a,l,c,u)}function pi(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,z:b}=f(t,n);e.views.position[g]=p,e.views.position[g+1]=y,e.views.position[g+2]=b}else e.views.position[g]=G+t,e.views.position[g+1]=G+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 xl(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var qr={exports:{}},bf;function fv(){if(bf)return qr.exports;bf=1,qr.exports=e,qr.exports.default=e;function e(x,L,_){_=_||2;var F=L&&L.length,O=F?L[0]*_:x.length,k=t(x,0,O,_,!0),R=[];if(!k||k.next===k.prev)return R;var V,X,Y,K,J,N,Z;if(F&&(k=l(x,L,k,_)),x.length>80*_){V=Y=x[0],X=K=x[1];for(var q=_;q<O;q+=_)J=x[q],N=x[q+1],J<V&&(V=J),N<X&&(X=N),J>Y&&(Y=J),N>K&&(K=N);Z=Math.max(Y-V,K-X),Z=Z!==0?32767/Z:0}return i(k,R,_,V,X,Z,0),R}function t(x,L,_,F,O){var k,R;if(O===M(x,L,_,F)>0)for(k=L;k<_;k+=F)R=j(k,x[k],x[k+1],R);else for(k=_-F;k>=L;k-=F)R=j(k,x[k],x[k+1],R);return R&&I(R,R.next)&&(z(R),R=R.next),R}function n(x,L){if(!x)return x;L||(L=x);var _=x,F;do if(F=!1,!_.steiner&&(I(_,_.next)||w(_.prev,_,_.next)===0)){if(z(_),_=L=_.prev,_===_.next)break;F=!0}else _=_.next;while(F||_!==L);return L}function i(x,L,_,F,O,k,R){if(x){!R&&k&&h(x,F,O,k);for(var V=x,X,Y;x.prev!==x.next;){if(X=x.prev,Y=x.next,k?r(x,F,O,k):s(x)){L.push(X.i/_|0),L.push(x.i/_|0),L.push(Y.i/_|0),z(x),x=Y.next,V=Y.next;continue}if(x=Y,x===V){R?R===1?(x=o(n(x),L,_),i(x,L,_,F,O,k,2)):R===2&&a(x,L,_,F,O,k):i(n(x),L,_,F,O,k,1);break}}}}function s(x){var L=x.prev,_=x,F=x.next;if(w(L,_,F)>=0)return!1;for(var O=L.x,k=_.x,R=F.x,V=L.y,X=_.y,Y=F.y,K=O<k?O<R?O:R:k<R?k:R,J=V<X?V<Y?V:Y:X<Y?X:Y,N=O>k?O>R?O:R:k>R?k:R,Z=V>X?V>Y?V:Y:X>Y?X:Y,q=F.next;q!==L;){if(q.x>=K&&q.x<=N&&q.y>=J&&q.y<=Z&&y(O,V,k,X,R,Y,q.x,q.y)&&w(q.prev,q,q.next)>=0)return!1;q=q.next}return!0}function r(x,L,_,F){var O=x.prev,k=x,R=x.next;if(w(O,k,R)>=0)return!1;for(var V=O.x,X=k.x,Y=R.x,K=O.y,J=k.y,N=R.y,Z=V<X?V<Y?V:Y:X<Y?X:Y,q=K<J?K<N?K:N:J<N?J:N,he=V>X?V>Y?V:Y:X>Y?X:Y,ye=K>J?K>N?K:N:J>N?J:N,ge=v(Z,q,L,_,F),se=v(he,ye,L,_,F),W=x.prevZ,$=x.nextZ;W&&W.z>=ge&&$&&$.z<=se;){if(W.x>=Z&&W.x<=he&&W.y>=q&&W.y<=ye&&W!==O&&W!==R&&y(V,K,X,J,Y,N,W.x,W.y)&&w(W.prev,W,W.next)>=0||(W=W.prevZ,$.x>=Z&&$.x<=he&&$.y>=q&&$.y<=ye&&$!==O&&$!==R&&y(V,K,X,J,Y,N,$.x,$.y)&&w($.prev,$,$.next)>=0))return!1;$=$.nextZ}for(;W&&W.z>=ge;){if(W.x>=Z&&W.x<=he&&W.y>=q&&W.y<=ye&&W!==O&&W!==R&&y(V,K,X,J,Y,N,W.x,W.y)&&w(W.prev,W,W.next)>=0)return!1;W=W.prevZ}for(;$&&$.z<=se;){if($.x>=Z&&$.x<=he&&$.y>=q&&$.y<=ye&&$!==O&&$!==R&&y(V,K,X,J,Y,N,$.x,$.y)&&w($.prev,$,$.next)>=0)return!1;$=$.nextZ}return!0}function o(x,L,_){var F=x;do{var O=F.prev,k=F.next.next;!I(O,k)&&E(O,F,F.next,k)&&C(O,k)&&C(k,O)&&(L.push(O.i/_|0),L.push(F.i/_|0),L.push(k.i/_|0),z(F),z(F.next),F=x=k),F=F.next}while(F!==x);return n(F)}function a(x,L,_,F,O,k){var R=x;do{for(var V=R.next.next;V!==R.prev;){if(R.i!==V.i&&b(R,V)){var X=B(R,V);R=n(R,R.next),X=n(X,X.next),i(R,L,_,F,O,k,0),i(X,L,_,F,O,k,0);return}V=V.next}R=R.next}while(R!==x)}function l(x,L,_,F){var O=[],k,R,V,X,Y;for(k=0,R=L.length;k<R;k++)V=L[k]*F,X=k<R-1?L[k+1]*F:x.length,Y=t(x,V,X,F,!1),Y===Y.next&&(Y.steiner=!0),O.push(p(Y));for(O.sort(c),k=0;k<O.length;k++)_=u(O[k],_);return _}function c(x,L){return x.x-L.x}function u(x,L){var _=d(x,L);if(!_)return L;var F=B(_,x);return n(F,F.next),n(_,_.next)}function d(x,L){var _=L,F=x.x,O=x.y,k=-1/0,R;do{if(O<=_.y&&O>=_.next.y&&_.next.y!==_.y){var V=_.x+(O-_.y)*(_.next.x-_.x)/(_.next.y-_.y);if(V<=F&&V>k&&(k=V,R=_.x<_.next.x?_:_.next,V===F))return R}_=_.next}while(_!==L);if(!R)return null;var X=R,Y=R.x,K=R.y,J=1/0,N;_=R;do F>=_.x&&_.x>=Y&&F!==_.x&&y(O<K?F:k,O,Y,K,O<K?k:F,O,_.x,_.y)&&(N=Math.abs(O-_.y)/(F-_.x),C(_,x)&&(N<J||N===J&&(_.x>R.x||_.x===R.x&&f(R,_)))&&(R=_,J=N)),_=_.next;while(_!==X);return R}function f(x,L){return w(x.prev,x,L.prev)<0&&w(L.next,x,x.next)<0}function h(x,L,_,F){var O=x;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!==x);O.prevZ.nextZ=null,O.prevZ=null,g(O)}function g(x){var L,_,F,O,k,R,V,X,Y=1;do{for(_=x,x=null,k=null,R=0;_;){for(R++,F=_,V=0,L=0;L<Y&&(V++,F=F.nextZ,!!F);L++);for(X=Y;V>0||X>0&&F;)V!==0&&(X===0||!F||_.z<=F.z)?(O=_,_=_.nextZ,V--):(O=F,F=F.nextZ,X--),k?k.nextZ=O:x=O,O.prevZ=k,k=O;_=F}k.nextZ=null,Y*=2}while(R>1);return x}function v(x,L,_,F,O){return x=(x-_)*O|0,L=(L-F)*O|0,x=(x|x<<8)&16711935,x=(x|x<<4)&252645135,x=(x|x<<2)&858993459,x=(x|x<<1)&1431655765,L=(L|L<<8)&16711935,L=(L|L<<4)&252645135,L=(L|L<<2)&858993459,L=(L|L<<1)&1431655765,x|L<<1}function p(x){var L=x,_=x;do(L.x<_.x||L.x===_.x&&L.y<_.y)&&(_=L),L=L.next;while(L!==x);return _}function y(x,L,_,F,O,k,R,V){return(O-R)*(L-V)>=(x-R)*(k-V)&&(x-R)*(F-V)>=(_-R)*(L-V)&&(_-R)*(k-V)>=(O-R)*(F-V)}function b(x,L){return x.next.i!==L.i&&x.prev.i!==L.i&&!T(x,L)&&(C(x,L)&&C(L,x)&&U(x,L)&&(w(x.prev,x,L.prev)||w(x,L.prev,L))||I(x,L)&&w(x.prev,x,x.next)>0&&w(L.prev,L,L.next)>0)}function w(x,L,_){return(L.y-x.y)*(_.x-L.x)-(L.x-x.x)*(_.y-L.y)}function I(x,L){return x.x===L.x&&x.y===L.y}function E(x,L,_,F){var O=P(w(x,L,_)),k=P(w(x,L,F)),R=P(w(_,F,x)),V=P(w(_,F,L));return!!(O!==k&&R!==V||O===0&&A(x,_,L)||k===0&&A(x,F,L)||R===0&&A(_,x,F)||V===0&&A(_,L,F))}function A(x,L,_){return L.x<=Math.max(x.x,_.x)&&L.x>=Math.min(x.x,_.x)&&L.y<=Math.max(x.y,_.y)&&L.y>=Math.min(x.y,_.y)}function P(x){return x>0?1:x<0?-1:0}function T(x,L){var _=x;do{if(_.i!==x.i&&_.next.i!==x.i&&_.i!==L.i&&_.next.i!==L.i&&E(_,_.next,x,L))return!0;_=_.next}while(_!==x);return!1}function C(x,L){return w(x.prev,x,x.next)<0?w(x,L,x.next)>=0&&w(x,x.prev,L)>=0:w(x,L,x.prev)<0||w(x,x.next,L)<0}function U(x,L){var _=x,F=!1,O=(x.x+L.x)/2,k=(x.y+L.y)/2;do _.y>k!=_.next.y>k&&_.next.y!==_.y&&O<(_.next.x-_.x)*(k-_.y)/(_.next.y-_.y)+_.x&&(F=!F),_=_.next;while(_!==x);return F}function B(x,L){var _=new S(x.i,x.x,x.y),F=new S(L.i,L.x,L.y),O=x.next,k=L.prev;return x.next=L,L.prev=x,_.next=O,O.prev=_,F.next=_,_.prev=F,k.next=F,F.prev=k,F}function j(x,L,_,F){var O=new S(x,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 z(x){x.next.prev=x.prev,x.prev.next=x.next,x.prevZ&&(x.prevZ.nextZ=x.nextZ),x.nextZ&&(x.nextZ.prevZ=x.prevZ)}function S(x,L,_){this.i=x,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(x,L,_,F){var O=L&&L.length,k=O?L[0]*_:x.length,R=Math.abs(M(x,0,k,_));if(O)for(var V=0,X=L.length;V<X;V++){var Y=L[V]*_,K=V<X-1?L[V+1]*_:x.length;R-=Math.abs(M(x,Y,K,_))}var J=0;for(V=0;V<F.length;V+=3){var N=F[V]*_,Z=F[V+1]*_,q=F[V+2]*_;J+=Math.abs((x[N]-x[q])*(x[Z+1]-x[N+1])-(x[N]-x[Z])*(x[q+1]-x[N+1]))}return R===0&&J===0?0:Math.abs((J-R)/R)};function M(x,L,_,F){for(var O=0,k=L,R=_-F;k<_;k+=F)O+=(x[R]-x[k])*(x[k+1]+x[R+1]),R=k;return O}return e.flatten=function(x){for(var L=x[0][0].length,_={vertices:[],holes:[],dimensions:L},F=0,O=0;O<x.length;O++){for(var k=0;k<x[O].length;k++)for(var R=0;R<L;R++)_.vertices.push(x[O][k][R]);O>0&&(F+=x[O-1].length,_.holes.push(F))}return _},qr.exports}var hv=fv();const Jr=xl(hv),_l=oe(2,15),Yi=-32768,Us=32767;class pv{constructor(t,n){this._vertexBuffer=[],this._vertexDictionary=new Map,this._used=!1,this._granularity=t,this._granularityCellSize=_l/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],y=o[v*2+1];a=Math.min(a,p),c=Math.max(c,p),l=Math.min(l,y),u=Math.max(u,y)}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,y=v===0,b=(s-c)/v,w=(r-c)/v,I=Math.min(b,w),E=Math.max(b,w);if(!y&&(I>=1||E<=0)||y&&(c<s||c>r)){d>=s&&d<=r&&o.push(i[(a+1)%3]);continue}if(!y&&I>0){const T=l+g*I,C=c+v*I;o.push(this._vertexToIndex(T,C))}const A=l+g*Math.max(I,0),P=l+g*Math.min(E,1);if(p||this._generateIntraEdgeVertices(o,l,c,u,d,A,P),!y&&E<1){const T=l+g*E,C=c+v*E;o.push(this._vertexToIndex(T,C))}(y||d>=s&&d<=r)&&o.push(i[(a+1)%3]),!y&&(d<=s||d>=r)&&this._generateInterEdgeVertices(o,l,c,u,d,f,h,P,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 y=p*this._granularityCellSize,b=i+c*(y-n)/l;t.push(this._vertexToIndex(y,b))}else for(let p=g;p>=h;p--){const y=p*this._granularityCellSize,b=i+c*(y-n)/l;t.push(this._vertexToIndex(y,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),y=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,E=l<b;const A=h===0;if(A&&(a===c||a===u))return;if(A||p>=1||y<=0){const T=n-o,C=i-a,U=(c-a)/C,B=(u-a)/C,j=Math.min(U,B),z=o+T*j;w=Math.floor(Math.min(z,l)/this._granularityCellSize)+1,I=Math.ceil(Math.max(z,l)/this._granularityCellSize)-1,E=l<z}const P=d>0?u:c;if(E)for(let T=w;T<=I;T++){const C=T*this._granularityCellSize;t.push(this._vertexToIndex(C,P))}else for(let T=I;T>=w;T--){const C=T*this._granularityCellSize;t.push(this._vertexToIndex(C,P))}}_generateOutline(t){const n=[];for(const i of t){const s=Pl(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===Yi&&(t[n+1]=Yi+1),i===Us&&(t[n+1]=Us-1)}}_generatePoleQuad(t,n,i,s,r,o){s>r!=(o===Yi)?(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=_l,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],y=s[d*2+1];n&&(h===r&&v===r&&this._generatePoleQuad(t,c,u,f,g,Yi),v===r&&y===r&&this._generatePoleQuad(t,u,d,g,p,Yi),y===r&&h===r&&this._generatePoleQuad(t,d,c,p,f,Yi)),i&&(h===o&&v===o&&this._generatePoleQuad(t,c,u,f,g,Us),v===o&&y===o&&this._generatePoleQuad(t,u,d,g,p,Us),y===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 Pl(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(_l/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],y=h!==v,b=g!==p;if(!y&&!b)continue;const w=v-h,I=p-g,E=Math.abs(w),A=Math.abs(I);let P=h,T=g;for(;;){const U=w>0?(Math.floor(P/o)+1)*o:(Math.ceil(P/o)-1)*o,B=I>0?(Math.floor(T/o)+1)*o:(Math.ceil(T/o)-1)*o,j=Math.abs(P-U),z=Math.abs(T-B),S=Math.abs(P-v),M=Math.abs(T-p),x=y?j/E:Number.POSITIVE_INFINITY,L=b?z/A:Number.POSITIVE_INFINITY;if((S<=j||!y)&&(M<=z||!b))break;if(x<L&&y||!b){P=U,T=T+I*x;const _=[P,Math.round(T)];(a[a.length-1][0]!==_[0]||a[a.length-1][1]!==_[1])&&a.push(_)}else{P=P+w*L,T=B;const _=[Math.round(P),T];(a[a.length-1][0]!==_[0]||a[a.length-1][1]!==_[1])&&a.push(_)}}const C=[v,p];(a[a.length-1][0]!==C[0]||a[a.length-1][1]!==C[1])&&a.push(C)}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],y=e[t[a]*2+1];let b=!1;if(u<f)b=!0;else if(u>f)b=!1;else{const w=p-g,E=y-v,A=-w,P=v<y?1:-1,T=((u-g)*E+(d-v)*A)*P,C=((f-g)*E+(h-v)*A)*P;T>C&&(b=!0)}if(b){const w=t[l],I=t[o],E=t[a];w!==I&&w!==E&&I!==E&&n.push(E,w,I),o--,o<0&&(o=r-1)}else{const w=t[c],I=t[o],E=t[a];w!==I&&w!==E&&I!==E&&n.push(E,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 If=32,Mf=512;function Iv(e,t,n,i,s){const r=[e[0][0],e[1][0]],o=Me(90+i),a=[];vt(a,r,s);const l=re.toGeo(a),c=Rr(l,t),u=Rr(l,n),d=Math.sqrt(oe(c,2)+oe(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),y=d*Math.sin(v),b=Math.atan(-c/u)+2*Math.PI+o,w=d*Math.cos(b),I=d*Math.sin(b),E=Math.atan(c/u)+o,A=d*Math.cos(E),P=d*Math.sin(E),T=[],C=[],U=[],B=[];return Lt(T,[a[0]+h,a[1]+g],s),Lt(C,[a[0]+p,a[1]+y],s),Lt(U,[a[0]+w,a[1]+I],s),Lt(B,[a[0]+A,a[1]+P],s),[[T[0],C[0],U[0],B[0]],[T[1],C[1],U[1],B[1]]]}function Kr(e,t){const n=Math.max(e,t);return n*If>Mf?Mf/n:If}function Tf(e){const t=Ct(e,[0,0]);return ee/jt(e.coords[2])*Te*t}function Mv(e,t,n,i){if(isNaN(e.step)||isNaN(e.width))return n;const{tileProps:s,tileAttrs:r}=i,o=Tf(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 P in n)c[P]=[];let h=0;const g=[h];for(let P=1;P<f;P++)h+=Bn([u[P-1],d[P-1]],[u[P],d[P]]),g.push(h);const v=Oe(),p=Oe(),y=[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),E=0,A=0;for(Gs(c,w),e.stopLines&&!r[s.beginningIsCut]&&(tn(v,u[A],d[A],u[A+1],d[A+1]),zn(p,v),_t(y,p,I*l),Gt(w,w,y),Gs(c,w),E+=b/2,I=-I);E<=h;){for(;E>g[A+1];)A++;if(tn(v,u[A],d[A],u[A+1],d[A+1]),zn(p,v),I>0)_t(y,p,I*l),Gt(w,w,y),_t(y,v,b/2),Gt(w,w,y),Gs(c,w);else{const P=Math.min(1,(E-g[A])/(g[A+1]-g[A]));Ha(w,[u[A],d[A]],[u[A+1],d[A+1]],P),Gs(c,w)}I=-I,E+=b/2}return e.stopLines&&!r[s.endingIsCut]&&(_t(y,p,I*l),Gt(w,w,y),Gs(c,w)),c}function Tv(e,t,n,i){const s=Tf(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]&&Sf(g,h,u),f===l-1&&u>0&&!a[o.endingIsCut]&&Sf(h,g,u),Sv(d,g,h,c,r)}return d}function Sf(e,t,n){const i=Bn(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=Bn(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 y=1;y<=u;y++){const b=y*(c/u),w=r+g*(b-p),I=o+v*(b-p),E=r+g*b,A=o+v*b;e.x.push(w),e.y.push(I),e.xScaleDirection.push(E),e.yScaleDirection.push(A),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 Ll(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}[t[0]])return!0}return!1}function Ef(e){return Ll(e)&&e[0]==="literal"}function nn(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 Af(e,t){return Array.isArray(e)?e.length>0&&e.every(n=>typeof n===t):!1}function Lv(e){return Af(e,"string")}function fn(e){return Af(e,"number")}function xf(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)||fn(e)}function _f(e){return Cv(e)||Pv(e)||xf(e)}function Dv(e){return nn(e)&&e.type==="get"}function wt(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 Wi(e,t,n){return`${e}_${t}_${n}`}function eo(e){return`texture-${e}`}function Cl(e,t){return e+"-"+t}function Je(e){return Ef(e)&&Array.isArray(e[1])?e[1][0]:Array.isArray(e)?Ll(e)?e:e[0]:e}function hn(e){if(Ef(e)&&Array.isArray(e[1]))return e[1][1];if(Array.isArray(e)&&!Ll(e)&&e[1]!==void 0)return e[1]}function st(e){if(typeof e=="number"||fn(e))return e;if(e.type==="literal-array"&&fn(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 Pf(e){return!!e&&typeof e=="object"&&e.type==="mix-options"}const Lf=wt([0,0,0,0]);function Cf(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 pn(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=Lf;switch(t[0]){case"#":n=Nv(t);break;case"h":n=Zi(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 Lf;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 wt([i,s,r,o])}function Zi(e,t){const n=Df(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 wt([Math.round(i),Math.round(s),Math.round(r),Math.round(o)])}function Bv(e){const[t,n,i,s]=Df(e),r=s!==void 0?s*255:255;return wt([Math.round(t),Math.round(n),Math.round(i),Math.round(r)])}function Df(e){return e.split("(")[1].split(")")[0].split(",").map(n=>parseFloat(n))}function Dl(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[Dl(s,i,e+1/3)*255,Dl(s,i,e)*255,Dl(s,i,e-1/3)*255]}function Of(e){const t=e[0],n=e[1];let i=e[2];const s=Xi(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 Xi(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 Ff(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 Rf(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=Xi(e.value);return n[2]+=n[2]*t,Zi(`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`,e.value[3])}function zv(e,t){const n=Xi(e.value);return n[2]-=n[2]*t,Zi(`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`,e.value[3])}function Gv(e,t){const n=Xi(e.value);return n[1]+=n[1]*t,Zi(`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`,e.value[3])}function Vv(e,t){const n=Xi(e.value);return n[1]-=n[1]*t,Zi(`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`,e.value[3])}function jv(e,t){const n=Xi(e.value);return n[2]=Math.min(100,Math.max(0,100*t)),Zi(`hsl(${n[0]}, ${n[1]}%, ${n[2]}%)`,e.value[3])}function Hv(e,t){const n=Of(e.value);n[1]+=n[1]*t;const i=Rf(Ff(n));return{type:"color",value:[i[0],i[1],i[2],e.value[3]||255]}}function $v(e,t){const n=Of(e.value);n[2]+=n[2]*t;const i=Rf(Ff(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 Ol(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 Fl(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(Fl(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 = ${Fl(t)})`)}const Nf=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 Bf(e){ke(`Got an empty response from the "${e}" tile generation.`)}function ke(e){Nf.has(e)||(console.log(e),Nf.add(e))}const Kv=2166136261,Qv=16777619;function kf(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(Uf(i,2)),n.push(Uf(i,3));return{base2:t,base3:n}}function Uf(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 et=(e=>(e[e.Uniform=1]="Uniform",e[e.Labeling=2]="Labeling",e[e.Generator=3]="Generator",e))(et||{});const io=-1;var $s=(e=>(e.global="global",e.none="none",e))($s||{}),Hn=(e=>(e[e.Pixels=0]="Pixels",e[e.Meters=1]="Meters",e))(Hn||{});const zf="bottomCenter";function tt(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};if(tt(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(fn(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(tt(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(fn(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 tt(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:[]};return tt(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"};return tt(t,e),t}function aw(e){const t={color:"#000000",strokeColor:"#000000",strokeWidth:1,nearCameraFade:2500,visibility:"visible"};return tt(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 tt(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:Yn};return tt(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:Yn};return tt(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"};return tt(t,e),t}function fw(e){const t={color:"#000000",width:1,shift:0,visibility:"visible"};return tt(t,e),t}function hw(e){const t={color:"#ffffff",strokeColor:"#3388ff",strokeColor2:"#00000000",width:20,strokeWidth:3,strokeWidth2:0,visibility:"visible"};return tt(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:Yn,iconLabelingMargin:{topBottom:0,leftRight:0},textField:[["get","db_label"],["get","db_label2"]],textFont:"",textColor:"#000000",textFontSize:16,textLineHeight:1.2,textLetterSpacing:0,textPlacement:zf,textOffset:0,textHaloColor:"rgba(0, 0, 0, 0)",textHaloWidth:0,textLabelingMargin:{topBottom:0,leftRight:0},textPriority:0,textMaxLengthPerLine:30,visibility:"visible",textLabelingGroup:Yn,duplicationSpacing:100,endingOffsets:0};return tt(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),tt(t,e),t}function yw(e){const t={opacity:1,visibility:"visible"};return tt(t,e),t}function gw(e){return Fn(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 Fn(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 Fn(e,{modelSrc:"",offset:0,scale:1,rotation:0,color:"#fff",linkedIds:"",visibility:"visible",colorTextureUvIndex:0,nearCameraFade:2500,ignoreGlobalLighting:!1,showRatio:1,metallic:NaN,roughness:NaN,preventObjectsHiding:!1,lightingModel:"phong",playAnimation:-1,scene:NaN,geometryModifier:["geometry-modifier"]})}function 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 tt(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 tt(t,e),t}function Mw(e){return Fn(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=Fn(e!=null?e:{},t);return n.lightingModes[$s.none]=[],n}function Sw(e){const t={light:{},normal:{},immersive:{}},n=Fn(e!=null?e:{},t);return n.light.transparentBuildingsOff=!0,n.light.AALinesOff=!0,n}const $n="__overlapped",Rl="__commercial",Yn="default",Nl={groups:[Yn,$n,Rl],overlay:[[Yn,$n]],intersect:[[]]},Ew="#F5F2E0",mi=e=>{e&&Object.entries(e).forEach(([t,n])=>{n===void 0&&delete e[t]})},Aw=e=>{var t;mi(e),e.type==="group"?(mi(e.commonDefaults),mi((t=e.commonDefaults)==null?void 0:t.style),mi(e.layerTypeDefaults),e.layerTypeDefaults&&Object.values(e.layerTypeDefaults).forEach(n=>{mi(n),mi(n==null?void 0:n.style)})):e.type!=="custom"&&mi(e.style)},Gf=(e,t=!1)=>{t||console.warn("assertUnreachable: ",e)},yi=null,Vf=[0,0,0];function H(e,t){var n,i,s;if(!nn(e))return e;if(t.allowedExpressions&&!t.allowedExpressions.has(e.type))return ke(`Expression of type ${e.type} is not allowed here`),yi;switch(e.type){case"schedule":return zw(e,t);case"time":return Lw(e,t);case"object-attr":return Ow(e,t);case"coalesce":return Hf(e,t);case"concat":return Cw(e,t);case"all":return xw(e,t);case"any":return Pw(e,t);case"feature-state":return Rw(e,t);case"get":return Wf(e,t);case"global":return Nw(e,t);case"source-attr":return Dw(e,t);case"in":return Ww(e,t);case"has":return Zw(e,t);case"interpolate":return Bw(e,t);case"match":return kw(e,t);case"step":return Uw(e,t);case"to-boolean":return jw(e,t);case"to-color":return Zf(e,t);case"mappoints-to-meters":return Gw(e,t);case"meters-to-pixels":return Vw(e,t);case"!":return Hw(e,t);case"==":case"!=":return $w(e,t);case">":case"<":case">=":case"<=":return Yw(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 Gf(r),yi;case"distance":if(t.type==="binder"){const a=re.toGeo(t.objectCenter),l=re.scaleFactor(a[1])*Te;return tl(t.objectCenter,t.cameraCenter)/l}else return ke(`Distance expression can't be resolved in the ${t.type} context`),yi;case"height":return 1;case"+":return Xw(e,t);case"*":return qw(e,t);case"^":return Jw(e,t);case"log10":return Kw(e,t);case"random":return Qw(e,t);case"literal-array":return e2(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`),yi);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 $f(e,t);case"local-time":return jf(e,t);case"utc-time":return jf(e,t);case"texture-animation":return Yf(e,t);case"easing":return e.options;case"mix":return Fw(e,t);case"vertex-color":return _w(e,t);case"color-saturate":return mn(e,t,"saturate");case"color-desaturate":return mn(e,t,"desaturate");case"color-grayscale":return mn(e,t,"grayscale");case"color-lighten":return mn(e,t,"lighten");case"color-lightness":return mn(e,t,"lightness");case"color-darken":return mn(e,t,"darken");case"color-whiten":return mn(e,t,"whiten");case"color-blacken":return mn(e,t,"blacken");case"color-opacity":return mn(e,t,"opacity");default:return ke(`Not supported expression type <<${e.type}>> in ${JSON.stringify(e)}`),yi}}function xw(e,t){return e.array.every(n=>H(n,t)===!0)}function _w(e,t){if(t.type==="generator"){const i=H(e.vertexValue,t);if(pn(i))return i.isVertexColor=!0,i;const s=wt([0,0,0,0]);return s.isVertexColor=!0,s}const n=H(e.uniformValue,t);return pn(n)||to(n)?(n.mixFactor=e.mixValue?H(e.mixValue,t):1,n):wt([0,0,0,255],1)}function Pw(e,t){return e.array.some(n=>H(n,t)===!0)}function jf(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 Lw(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 Hf(e,t){for(const n of e.array){const i=H(n,t);if(i!==null)return i}return null}function Cw(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 Dw(e,t){var n;return t.type==="generator"&&(n=t.sourceAttrs[e.property])!=null?n:null}function Ow(e,t){return t.type==="binder"&&t.dynamicObject&&t.dynamicObject[e.property]||null}function $f(e,t){const n={type:"animation-options"};return e.options?e.options.forEach((i,s)=>n[s]=H(i,t)):nn(e)||(n[0]=e),n}function Yf(e,t){const n={type:"texture-animation-options"};return e.options?e.options.forEach((i,s)=>n[s]=H(i,t)):nn(e)||(n[0]=e),n}function Fw(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:[ae(s[0].key,t,0),ae(s[0].value,t,0),ae(s[1].key,t,1),ae(s[1].value,t,1)]}}return i}function Rw(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 Wf(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 Nw(e,t){const n=t.styleState[e.property];return n==null?null:typeof n=="object"&&!Array.isArray(n)?{type:"object",value:n}:n}function Bw(e,t){if(e.steps.length===0)return ke("Interpolate expression contains 0 steps, cannot interpolate"),yi;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(pn(n)){if(nn(e.argument)&&e.argument.type==="height"){const s={type:"gradient-color",values:[],steps:[]};return e.steps.forEach(r=>{const o=ae(r.key,t),a=H(r.value,t);pn(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"),yi):s}return qf(e,i,t)}return Xf(e,i,t)}function kw(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 Uw(e,t){const n=Number(H(e.value,t)),i=Ws(e,n,t)-1;return H(e.steps[i].value,t)}function zw(e,t){var v,p;const s=(y,b)=>{const w=Date.now()+ +(b.styleState._customUserTimeOffset||0);return Math.floor(w/6e4)*6e4+y*6e4},r=e.detailResult||!1,o=y=>{if(t.type==="binder"&&t.callBackFn){const b=s(y,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 y=1;y<a.length;y+=3){const w={key:Math.trunc(a[y]/1440)*1440,value:a[0]};c.push(w);const I={key:a[y],value:a[y+2]};l.push(I);const E={key:a[y+1],value:a[0]};l.push(E)}}for(const y of c)l.find(b=>b.key===y.key)||l.push(y);l.sort((y,b)=>y.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 y=Math.min((((v=l[g+1])==null?void 0:v.key)||11519)-f,1439-f%1440);o(y);const b=H(l[g].value,t)||NaN;return r?{type:"schedule-detailed-result",value:b,nextStepStartsAt:s(y,t),currentStepElapsed:(f-l[g].key)*6e4}:b}if(l[h]){const y=Math.min(((p=l[h+1])==null?void 0:p.key)||1439,1439)-f%1440;o(y);const b=H(l[h].value,t)||NaN;return r?{type:"schedule-detailed-result",value:b,nextStepStartsAt:s(y,t),currentStepElapsed:(f%1440-l[h].key)*6e4}:b}return r?{type:"schedule-detailed-result",value:NaN,nextStepStartsAt:NaN,currentStepElapsed:NaN}:NaN}function Zf(e,t){const n=H(e.value,t);if(Cf(n))return js(n);if(pn(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 wt([s,r,o,i])}return n&&console.warn(`Can't resolve expression. Must be color, but got ${n}`),wt([0,0,0,0])}function mn(e,t,n){const i=H(e.color,t),s=Zf({value:i},t);return s2(s,n,e.value)}function Gw(e,t){if(t.type!=="generator"||!t.tileInfo)throw new Error("Выражение `mappoints-to-meters` можно резолвить только в контексте генератора");return H(e.value,t)/(Te*Ct(t.tileInfo,[0,0]))}function Vw(e,t){const n=ae(e.value,t);let i,s=n*256/Xa;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*oe(2,i+1)}function jw(e,t){return!!H(e.value,t)}function Hw(e,t){return!H(e.value,t)}function $w(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 Yw(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 Ww(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):xf(i)?Object.prototype.hasOwnProperty.call(i.value,n):(ke(`InExpression second argument resolved incorrectly: ${i}`),null)}function Zw(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 Xw(e,t){const n=e.array.map(i=>H(i,t));return fn(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 fn(n)?n.reduce((i,s)=>i*s,1):(ke(`Resolve MultiplicationExpression: arguments are not resolved as an array of numbers: ${n}`),null)}function Jw(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 Kw(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 Qw(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 e2(e,t){return e.array.map(n=>H(n,t))}function Xf(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 n2(e,n,t);const s=Number(H(e.steps[i-1].value,n));if(n.type==="labeling"&&n.interpolateExpressionAsStep)return s;const r=Kf(e,t,i,n),o=Number(H(e.steps[i].value,n));return(1-r)*s+r*o}function Wn(e,t,n=!1){const i=H(e,t);return pn(i)?i:to(i)?i.values[1]:Pf(i)?pn(i.value1)&&pn(i.value2)?n?Ov(i):(console.warn("Mixing color is not supported here."),wt([0,0,0,0])):(console.warn(`Mix values cannot be converted to colors in ${JSON.stringify(i)}`),wt([0,0,0,0])):(console.warn(`Can't resolve expression. Must be color, but got ${i}`),wt([0,0,0,0]))}function t2(e,t){const n=H(e,t);return to(n)?n:null}function ae(e,t,n=NaN){const i=H(e,t);return typeof i=="number"?i:n}function ct(e,t,n=""){const i=H(e,t);return typeof i=="string"?i:n}function so(e,t,n=zf){const i=H(e,t);return xv(i)?i:n}function qf(e,t,n){const i=Ws(e,t,n);if(i===0)return Wn(e.steps[0].value,n);if(i===e.steps.length)return Wn(e.steps[e.steps.length-1].value,n);const s=Kf(e,t,i,n),r=Wn(e.steps[i-1].value,n).value,o=Wn(e.steps[i].value,n).value;return wt([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 n2(e,t,n){const i=e.steps[e.steps.length-1],s=e.base;return s===1?ae(i.value,t):ae(i.value,t)*Math.pow(s,n-ae(i.key,t))}function Jf(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:Vf,objectCenter:o!=null?o:Vf}}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<ae(e.steps[i].key,n));)i++;return i}function Kf(e,t,n,i){const s=e.base,r=ae(e.steps[n].key,i)-ae(e.steps[n-1].key,i),o=t-ae(e.steps[n-1].key,i);return s===1?o/r:(Math.pow(s,o)-1)/(Math.pow(s,r)-1)}function i2(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 s2(e,t="",n){const[i,s,r,o]=e.value;switch(t){case"opacity":return wt([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 gi(e,t,n,i=!1){const s=[];return vi(s,e,t,n),i?s:Array.from(new Set(s))}function r2(e,t){const n={};return Object.keys(e).forEach(i=>{n[i]=o2(e[i],t)}),n}const qi=Br();function Qf(e,t){const n=new Float32Array(3);return De(n,1,0,0),Ly(qi),Oy(qi,qi,-Me(t-90)),Dy(qi,qi,-Me(e)),Km(n,n,qi),Jt(n,n),Nd(n,n),n}function o2(e,t){var i,s;const n={ambientColorIntensity:new Float32Array(Wn(e.ambientColor,t).value.map(r=>r/255)),dir1ColorIntensity:new Float32Array(Wn(e.dir1Color,t).value.map(r=>r/255)),dir1Direction:Qf(H(e.dir1Altitude,t),H(e.dir1Azimuth,t)),dir2ColorIntensity:new Float32Array(Wn(e.dir2Color,t).value.map(r=>r/255)),dir2Direction:Qf(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 vi(e,t,n,i){if(!nn(t)){e.push(t);return}switch(t.type){case"all":return a2(e,t,n,i);case"match":return l2(e,t,n,i);case"step":return c2(e,t,n,i);case"interpolate":return u2(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=Hf(t,n);e.push(s);return}case"precompute":if(i){const s=i.precomputes[t.precomputeIndex].expr;vi(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=Wf(t,n);e.push(s);return}}}function a2(e,t,n,i){t.array.forEach(s=>vi(e,s,n,i))}function l2(e,t,n,i){vi(e,t.defaultOutput),t.cases.forEach(s=>vi(e,s.output,n,i))}function c2(e,t,n,i){t.steps.forEach(s=>vi(e,s.value,n,i))}function u2(e,t,n,i){t.steps.forEach(s=>vi(e,s.value,n,i))}function Bl(e){return Is*e}function kl(e){return e/Is}function d2(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 f2={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 h2(e){return f2[e]}function p2(e){return e!=="group"&&e!=="custom"}function m2(e){return e==="model"?"gltfModel":e!=="group"?e:void 0}function y2(){let e=new Tt(4);return e[0]=1,e[1]=0,e[2]=0,e[3]=1,e}function g2(e,t,n,i,s){return e[0]=t,e[1]=n,e[2]=i,e[3]=s,e}function v2(e){return e[0]*e[3]-e[2]*e[1]}var oo={exports:{}},ao={exports:{}},w2=ao.exports,eh;function b2(){return eh||(eh=1,(function(e,t){(function(n,i){e.exports=i()})(w2,(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)),y=Math.min(c,Math.floor(a+(d-f)*g/d+v));i(o,a,p,y,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 th;function I2(){if(th)return oo.exports;th=1,oo.exports=t,oo.exports.default=t;var e=b2();function t(p,y){if(!(this instanceof t))return new t(p,y);this._maxEntries=Math.max(4,p||9),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),y&&this._initFormat(y),this.clear()}t.prototype={all:function(){return this._all(this.data,[])},search:function(p){var y=this.data,b=[],w=this.toBBox;if(!h(p,y))return b;for(var I=[],E,A,P,T;y;){for(E=0,A=y.children.length;E<A;E++)P=y.children[E],T=y.leaf?w(P):P,h(p,T)&&(y.leaf?b.push(P):f(p,T)?this._all(P,b):I.push(P));y=I.pop()}return b},collides:function(p){var y=this.data,b=this.toBBox;if(!h(p,y))return!1;for(var w=[],I,E,A,P;y;){for(I=0,E=y.children.length;I<E;I++)if(A=y.children[I],P=y.leaf?b(A):A,h(p,P)){if(y.leaf||f(p,P))return!0;w.push(A)}y=w.pop()}return!1},load:function(p){if(!(p&&p.length))return this;if(p.length<this._minEntries){for(var y=0,b=p.length;y<b;y++)this.insert(p[y]);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,y){if(!p)return this;for(var b=this.data,w=this.toBBox(p),I=[],E=[],A,P,T,C;b||I.length;){if(b||(b=I.pop(),P=I[I.length-1],A=E.pop(),C=!0),b.leaf&&(T=n(p,b.children,y),T!==-1))return b.children.splice(T,1),I.push(b),this._condense(I),this;!C&&!b.leaf&&f(b,w)?(I.push(b),E.push(A),A=0,P=b,b=b.children[0]):P?(A++,b=P.children[A],C=!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,y){for(var b=[];p;)p.leaf?y.push.apply(y,p.children):b.push.apply(b,p.children),p=b.pop();return y},_build:function(p,y,b,w){var I=b-y+1,E=this._maxEntries,A;if(I<=E)return A=g(p.slice(y,b+1)),i(A,this.toBBox),A;w||(w=Math.ceil(Math.log(I)/Math.log(E)),E=Math.ceil(I/Math.pow(E,w-1))),A=g([]),A.leaf=!1,A.height=w;var P=Math.ceil(I/E),T=P*Math.ceil(Math.sqrt(E)),C,U,B,j;for(v(p,y,b,T,this.compareMinX),C=y;C<=b;C+=T)for(B=Math.min(C+T-1,b),v(p,C,B,P,this.compareMinY),U=C;U<=B;U+=P)j=Math.min(U+P-1,B),A.children.push(this._build(p,U,j,w-1));return i(A,this.toBBox),A},_chooseSubtree:function(p,y,b,w){for(var I,E,A,P,T,C,U,B;w.push(y),!(y.leaf||w.length-1===b);){for(U=B=1/0,I=0,E=y.children.length;I<E;I++)A=y.children[I],T=l(A),C=u(p,A)-T,C<B?(B=C,U=T<U?T:U,P=A):C===B&&T<U&&(U=T,P=A);y=P||y.children[0]}return y},_insert:function(p,y,b){var w=this.toBBox,I=b?p:w(p),E=[],A=this._chooseSubtree(I,this.data,y,E);for(A.children.push(p),r(A,I);y>=0&&E[y].children.length>this._maxEntries;)this._split(E,y),y--;this._adjustParentBBoxes(I,E,y)},_split:function(p,y){var b=p[y],w=b.children.length,I=this._minEntries;this._chooseSplitAxis(b,I,w);var E=this._chooseSplitIndex(b,I,w),A=g(b.children.splice(E,b.children.length-E));A.height=b.height,A.leaf=b.leaf,i(b,this.toBBox),i(A,this.toBBox),y?p[y-1].children.push(A):this._splitRoot(b,A)},_splitRoot:function(p,y){this.data=g([p,y]),this.data.height=p.height+1,this.data.leaf=!1,i(this.data,this.toBBox)},_chooseSplitIndex:function(p,y,b){var w,I,E,A,P,T,C,U;for(T=C=1/0,w=y;w<=b-y;w++)I=s(p,0,w,this.toBBox),E=s(p,w,b,this.toBBox),A=d(I,E),P=l(I)+l(E),A<T?(T=A,U=w,C=P<C?P:C):A===T&&P<C&&(C=P,U=w);return U},_chooseSplitAxis:function(p,y,b){var w=p.leaf?this.compareMinX:o,I=p.leaf?this.compareMinY:a,E=this._allDistMargin(p,y,b,w),A=this._allDistMargin(p,y,b,I);E<A&&p.children.sort(w)},_allDistMargin:function(p,y,b,w){p.children.sort(w);var I=this.toBBox,E=s(p,0,y,I),A=s(p,b-y,b,I),P=c(E)+c(A),T,C;for(T=y;T<b-y;T++)C=p.children[T],r(E,p.leaf?I(C):C),P+=c(E);for(T=b-y-1;T>=y;T--)C=p.children[T],r(A,p.leaf?I(C):C),P+=c(A);return P},_adjustParentBBoxes:function(p,y,b){for(var w=b;w>=0;w--)r(y[w],p)},_condense:function(p){for(var y=p.length-1,b;y>=0;y--)p[y].children.length===0?y>0?(b=p[y-1].children,b.splice(b.indexOf(p[y]),1)):this.clear():i(p[y],this.toBBox)},_initFormat:function(p){var y=["return a"," - b",";"];this.compareMinX=new Function("a","b",y.join(p[0])),this.compareMinY=new Function("a","b",y.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,y,b){if(!b)return y.indexOf(p);for(var w=0;w<y.length;w++)if(b(p,y[w]))return w;return-1}function i(p,y){s(p,0,p.children.length,y,p)}function s(p,y,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 E=y,A;E<b;E++)A=p.children[E],r(I,p.leaf?w(A):A);return I}function r(p,y){return p.minX=Math.min(p.minX,y.minX),p.minY=Math.min(p.minY,y.minY),p.maxX=Math.max(p.maxX,y.maxX),p.maxY=Math.max(p.maxY,y.maxY),p}function o(p,y){return p.minX-y.minX}function a(p,y){return p.minY-y.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,y){return(Math.max(y.maxX,p.maxX)-Math.min(y.minX,p.minX))*(Math.max(y.maxY,p.maxY)-Math.min(y.minY,p.minY))}function d(p,y){var b=Math.max(p.minX,y.minX),w=Math.max(p.minY,y.minY),I=Math.min(p.maxX,y.maxX),E=Math.min(p.maxY,y.maxY);return Math.max(0,I-b)*Math.max(0,E-w)}function f(p,y){return p.minX<=y.minX&&p.minY<=y.minY&&y.maxX<=p.maxX&&y.maxY<=p.maxY}function h(p,y){return y.minX<=p.maxX&&y.minY<=p.maxY&&y.maxX>=p.minX&&y.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,y,b,w,I){for(var E=[y,b],A;E.length;)b=E.pop(),y=E.pop(),!(b-y<=w)&&(A=y+Math.ceil((b-y)/w/2)*w,e(p,A,y,b,I),E.push(y,A,A,b))}return oo.exports}var M2=I2();const lo=xl(M2);var Ul,nh;function T2(){if(nh)return Ul;nh=1,Ul=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 Ul}var zl,ih;function S2(){if(ih)return zl;ih=1,zl=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 zl}var Gl,sh;function E2(){if(sh)return Gl;sh=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 Gl=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},Gl}var Vl,rh;function A2(){return rh||(rh=1,Vl={encode:T2(),decode:S2(),encodingLength:E2()}),Vl}var x2=A2();const oh=xl(x2);class ah{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=oh.decode(this.buf,this.pos);return this.pos+=(n=oh.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 _2(e){const t=new ah(e);t.readUint32(),t.readUint16(),t.readUint16(),t.readUint16(),t.readUint16();const n=jl(t.readInt32()),i=jl(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);lh(t,c,a,jl);const u=t.readUint32(),d=a>Ve?new Uint32Array(u):new Uint16Array(u);lh(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(P2(p)))}const g=t.readUint32();if(g>0){const v={};for(let p=0;p<g;p++){const y=t.readUint16(),b=t.readInt32();v[y]=b}f.attributes=v}r.push(f)}return{dataGroups:r,minZ:n,maxZ:i}}function lh(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 jl(e){return e/Te}function P2(e){return e/127}function L2(e){const t=new Vr(e),n=Hl(t.readFixed32()),i=Hl(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]=Hl(t.readSVarint());let l=0;const c=t.readFixed32(),u=s>Ve?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 Hl(e){return e/100}function C2(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 D2(e){return Math.log(e)*256+.5<<16>>16}let O2=0;function Zs(){return O2++}const Xs=Zs(),$l=Zs(),ch=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);N2(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*ee,c*ee,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);F2(u,l,o,a,i,s,!!r)}};function F2(e,t,n,i,s,r,o){let a=e.elements.offset;const l=a;if(!(t<3)){Yl(e,a++,n[0],i[0],r,s[0],o),Yl(e,a++,n[1],i[1],r,s[1],o);for(let c=2;c<t;c++)R2(e,l,c),Yl(e,a++,n[c],i[c],r,s[c],o);e.elements.offset=a}}function Yl(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:G+n,e.views.position[a+1]=o?i:G+i,e.views.demPosition[a]=(o?s[0]:G+s[0])/8,e.views.demPosition[a+1]=(o?s[1]:G+s[1])/8,e.views.extender[l]=r[0]*127,e.views.extender[l+1]=r[1]*127}function R2(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 N2(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]=G+(n?uh(o):o),e.views.position[r+1]=G+(n?uh(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 uh(e){return e===0?e-=ch:e===ee&&(e+=ch),e}const B2=(()=>{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 k2(e,t){const n=new ah(e),i=[];return dh(n,t,i),i}function dh(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?U2(e,t,n):dh(e,t,n)}function U2(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=mt(),fh=mt(),z2=Oe(),G2=Oe(),hh=y2(),V2=64,ph=9,mh=(e,t,n,i,s)=>{const r=Os(e.tileServer,{subdomain:e.subdomains[Math.abs(t+n)%e.subdomains.length]});return`${e.tileProtocol}://${r}/v2/ald?ts=${s}&x=${t}&y=${n}&z=${i}`};function j2(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])-G,maxX:Math.max(a[c],a[u],a[d])-G,minY:Math.min(a[c+1],a[u+1],a[d+1])-G,maxY:Math.max(a[c+1],a[u+1],a[d+1])-G,posOffset:l,bucketIndex:i,batchIndex:r})}})}),t.length?B2(lo(ph).load(t)):null}function Wl(e,t,n){const i=n/(Float32Array.BYTES_PER_ELEMENT/Uint16Array.BYTES_PER_ELEMENT);return[e[n]-G,e[n+1]-G,t[i]]}function H2(e,t){var l;if(!e.tree)return;const n=De(qs,t[0],t[1],0),i=gl(e.key),s=gt(i),r=new Uint16Array(3),o=Ot.sinks.mesh2.stride/Uint16Array.BYTES_PER_ELEMENT;Lt(r,n,s);const a=k2(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=Wl(f,h,c.posOffset),v=Wl(f,h,c.posOffset+o),p=Wl(f,h,c.posOffset+o*2),y=$2(g,v,p,r,qs);if(!y)continue;return g[2]*y[0]+v[2]*y[1]+p[2]*y[2]}}function $2(e,t,n,i,s){const r=Zl(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(Xl(e,t,i)){const u=co(e,t,i);c=oi(qs,e,t,u),s[0]=1-u,s[1]=u,s[2]=0}if(Xl(t,n,i)){const u=co(t,n,i),d=oi(fh,t,n,u);(!c||d[2]>c[2])&&(s[0]=0,s[1]=1-u,s[2]=u,c||(c=qs),Qa(c,d))}if(Xl(n,e,i)){const u=co(n,e,i),d=oi(fh,n,e,u);(!c||d[2]>c[2])&&(s[0]=u,s[1]=0,s[2]=1-u,c||(c=qs),Qa(c,d))}if(c)return s}const o=Zl(i,t,n)/r,a=Zl(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 Zl(e,t,n){return g2(hh,t[0]-e[0],n[0]-e[0],t[1]-e[1],n[1]-e[1]),v2(hh)}function Xl(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=un(z2,t,e),s=un(G2,n,e);return Nn(s,i)/Sm(i)}function Y2(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?_2(e):L2(e),{positions:r,heights:o,indices:a}=n[0];return{positions:r,heights:o,indices:a,maxZ:s,minZ:i}}function ql(e,t,n,i,s){const r=kl(s);gi(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=W2(i.textureSize),c=i.lengthUnits===Hn.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 W2(e){return nn(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 Jl(e,t){var g,v,p,y,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=(y=n[i.componentDistanceStart])!=null?y:0,l=(b=n[i.componentDistanceEnd])!=null?b:0,c=Ri(s,r,a/o),u=Ri(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*Te*d),f;const h=t.x.length;for(let w=0;w<h;w++)f[w]=Te*d*Ri(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 Kl=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]<On.globeMaxZoom,yn=e=>oe(2,15)+e*Nm,sn=(e,t,n)=>{const[i,s,r]=Kg(e,[t,n]);return{x:yn(i),y:yn(s),z:yn(r)}};function Ji(e){return e-32768}function Ki(e){return e+32768}function yh(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],Qi=[.5,.5],Ql=[0,0];let Et,ve,we,Ee=0,At=0,Ke=0,rt=0;const Z2={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]},X2=1-1e-4,q2=0,gh=-.9;function J2(e,t,n,i,s,r,o,a){const l=Z2;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 we.globeMode?l.noTurn=!1:l.noTurn=c>X2,l.leftTurn=i*-o+s*r<0,l.sharpTurn=c<q2&&c>gh,l.reverseTurn=c<gh,l}function fo(e,t,n,i,s,r,o,a,l,c,u,d,f=!1){var U,B,j,z,S,M,x;let h,g,v,p,y,b,w,I,E,A,P,T,C;if(i!==0)if(we=u,ve=d,Et=ve.indices,At=ve.elements.offset,Ee=0,Ke=0,rt=0,e[0],t[0],i===1)h=e[0],g=t[0],v=(U=n==null?void 0:n[0])!=null?U:0,C=0,gn(Et,At,0,2,1,1,2,3),_e(ve,we,0,h,g,v,1,-1,1,-1,C,!1,Yt),_e(ve,we,0,h,g,v,-1,-1,-1,-1,C,!1,$t),_e(ve,we,0,h,g,v,1,1,1,1,C,!1,Yt),_e(ve,we,0,h,g,v,-1,1,-1,1,C,!1,$t),Ee=Ee+4;else{switch(p=e[0],y=t[0],b=(B=n==null?void 0:n[0])!=null?B:0,w=e[1],I=t[1],E=(j=n==null?void 0:n[1])!=null?j:0,C=f?we.cDist:0,s){case me.TileCut:Vt(Wt,p,y,o,a),Vt(Se,w,I,p,y),T=ec(w,I,E,Wt[0],Wt[1],Se[0],Se[1],f),T.noTurn?vh(p,y,b,Se[0],Se[1],C):ho(0,p,y,b,Wt[0],Wt[1],Se[0],Se[1],C,f);break;case me.Butt:case me.Round:Vt(Se,w,I,p,y),vh(p,y,b,Se[0],Se[1],C),s===me.Round&&ho(0,p,y,b,Se[0],Se[1],Se[0],Se[1],C,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],y=t[O-1],b=(z=n==null?void 0:n[O-1])!=null?z:0,w=e[O],I=t[O],E=(S=n==null?void 0:n[O])!=null?S:0,A=e[O+1],P=t[O+1];const k=w-p,R=I-y;C+=Math.sqrt(k*k+R*R)/ee,Vt(Wt,w,I,p,y),Vt(Se,A,P,w,I),ho(O,w,I,E,Wt[0],Wt[1],Se[0],Se[1],C,f)}p=e[i-2],y=t[i-2],b=(M=n==null?void 0:n[i-2])!=null?M:0,w=e[L],I=t[L],E=(x=n==null?void 0:n[L])!=null?x:0;const _=w-p,F=I-y;switch(C+=Math.sqrt(_*_+F*F)/ee,r){case me.TileCut:Vt(Wt,w,I,p,y),Vt(Se,l,c,w,I),T=ec(w,I,E,Wt[0],Wt[1],Se[0],Se[1],f),T.noTurn?wh(L,w,I,E,Se[0],Se[1],C):bh(L,C,T);break;case me.Butt:case me.Round:Vt(Se,w,I,p,y),wh(L,w,I,E,Se[0],Se[1],C),r===me.Round&&ho(L,w,I,E,Se[0],Se[1],-Se[0],-Se[1],C,f);break;default:throw new Error("LoftedLine: unknown Ending Type")}}}function ec(e,t,n,i,s,r,o,a){const l=J2(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 tc(e,t,n,i,s,r,o,a,l,c){$d(Ft,s,r,o,a),s*-a+r*o<0?_e(ve,we,e,t,n,i,-Ft[0],-Ft[1],-Ft[0],-Ft[1],l,!1,c):_e(ve,we,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=ec(t,n,i,s,r,o,a,c);bh(e,l,u),K2(e,l,u),Q2(e,l,u)}function vh(e,t,n,i,s,r){_e(ve,we,0,e,t,n,-i,-s,-i,-s,r,!1,$t),_e(ve,we,0,e,t,n,i,s,i,s,r,!1,Yt),Ee=Ee+2,Ke=1,rt=0}function wh(e,t,n,i,s,r,o){const a=Ee+1,l=Ee;_e(ve,we,e,t,n,i,-s,-r,-s,-r,o,!1,$t),_e(ve,we,e,t,n,i,s,r,s,r,o,!1,Yt),Ee=Ee+2,gn(Et,At,rt,l,Ke,Ke,l,a),Ke=a,rt=l}function K2(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(nc(Et,At,Ke,rt,o),n.sharpTurn){const l=Ee+1;n.leftTurn?gn(Et,At,o,l,s,s,l,r):gn(Et,At,o,r,l,l,r,s)}else n.leftTurn,nc(Et,At,o,r,s);const a=n.leftTurn?$t:Yt;n.sharpTurn?(n.leftTurn?Vt(Qi,n.xn2,n.yn2,n.xn1,n.yn1):Vt(Qi,n.xn1,n.yn1,n.xn2,n.yn2),tc(e,n.x,n.y,n.z,n.xn2,n.yn2,Qi[0],Qi[1],t,a),tc(e,n.x,n.y,n.z,Qi[0],Qi[1],n.xn1,n.yn1,t,a)):tc(e,n.x,n.y,n.z,n.xn2,n.yn2,n.xn1,n.yn1,t,a),n.reverseTurn||(n.leftTurn?_e(ve,we,e,n.x,n.y,n.z,-n.xn1,-n.yn1,-n.xn1,-n.yn1,t,!1,a):_e(ve,we,e,n.x,n.y,n.z,n.xn1,n.yn1,n.xn1,n.yn1,t,!1,a),Ee++),rt=r,Ke=s}function bh(e,t,n){if(n.noTurn)return;const i=Ee+1,s=Ee;if(n.reverseTurn||n.patternedLine&&n.sharpTurn?(_e(ve,we,e,n.x,n.y,n.z,-n.xn2,-n.yn2,-n.xn2,-n.yn2,t,!1,$t),_e(ve,we,e,n.x,n.y,n.z,n.xn2,n.yn2,n.xn2,n.yn2,t,!1,Yt)):n.leftTurn?(_e(ve,we,e,n.x,n.y,n.z,-n.xn2,-n.yn2,n.faExtender[0],n.faExtender[1],t,!0,$t),_e(ve,we,e,n.x,n.y,n.z,n.xn2,n.yn2,n.extender[0],n.extender[1],t,!0,Yt)):(_e(ve,we,e,n.x,n.y,n.z,-n.xn2,-n.yn2,-n.extender[0],-n.extender[1],t,!0,$t),_e(ve,we,e,n.x,n.y,n.z,n.xn2,n.yn2,-n.faExtender[0],-n.faExtender[1],t,!0,Yt)),Ee=Ee+2,gn(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(ve,we,e,n.x,n.y,n.z,-n.xn2,-n.yn2,-n.xn2,-n.yn2,t,!1,0),_e(ve,we,e,n.x,n.y,n.z,0,0,0,0,t,!1,0),gn(Et,At,i,s,r,r,s,o)):(_e(ve,we,e,n.x,n.y,n.z,0,0,0,0,t,!1,0),_e(ve,we,e,n.x,n.y,n.z,n.xn2,n.yn2,n.xn2,n.yn2,t,!1,0),gn(Et,At,s,o,i,i,o,r)),Ee=Ee+2,rt=o,Ke=r}}function Q2(e,t,n){if(n.noTurn||n.reverseTurn)return;const i=Ee+1,s=Ee;if(n.patternedLine&&n.sharpTurn){_e(ve,we,e,n.x,n.y,n.z,-n.xn1,-n.yn1,-n.xn1,-n.yn1,t,!1,$t),_e(ve,we,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(ve,we,e,n.x,n.y,n.z,-n.xn1,-n.yn1,n.saExtender[0],n.saExtender[1],t,!1,$t),_e(ve,we,e,n.x,n.y,n.z,n.xn1,n.yn1,n.extender[0],n.extender[1],t,!1,Yt)):(_e(ve,we,e,n.x,n.y,n.z,-n.xn1,-n.yn1,-n.extender[0],-n.extender[1],t,!1,$t),_e(ve,we,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?gn(Et,At,rt,s,Ke,Ke,s,i):gn(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,z:b}=sn(t.tileInfo,i,s);e.views.position[h]=p,e.views.position[h+1]=y,e.views.position[h+2]=b}else e.views.position[h]=G+i,e.views.position[h+1]=G+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===hi.Patterned){const p=e,y=1e-5;p.views.texture[g]=(y+u)*Math.sign(f)}else if(t.type===hi.Striped){const p=e;p.views.texExtender[v]=Ye(o*Be),p.views.texExtender[v+1]=Ye(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===hi.Entrance){const p=e,{px:y,py:b,count:w}=t,I=n===0,E=n===w-1,A=I?n:n-1,P=I?n+1:n;tn(Ql,y[A],b[A],y[P],b[P]),p.views.direction[h]=Math.round(Ql[0]*127),p.views.direction[h+1]=Math.round(Ql[1]*127),p.views.type[g]=E?Bs.LineEnding:Bs.Line,p.views.texExtender[v]=Ye(o*(d||E?-1:1)*Be),p.views.texExtender[v+1]=Ye(a*(d||E?-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 nc(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 gn(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 eb=8,ut={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){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(4)}}},solid3d:{stride:20,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int8Array(t,4),e.views.normal=new Int8Array(t,6),e.views.height=new Float32Array(t,8),e.views.absZ=new Float32Array(t,12),e.views.localID=new Uint32Array(t,16)},packObjectAttributes(e,t,n,i){return 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;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:Jl(i,o):void 0;c&&(!u||!Kl(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",ut.sinks.solid3d.packObjectAttributes(t,n,!!o.abs_z,i),ut.sinks.solid3d.binder):e.getBucket(n.type,"solid",ut.sinks.solid.packObjectAttributes(t,n,f,h,i),ut.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,y=ct(n.style.startCap,i),b=ct(n.style.endCap,i);!c&&(uo(i.styleState,i.tileInfo)||i.ecefDataState===ea.Present)&&i.tileInfo!==void 0?nb(g,o.x,o.y,i.tileInfo,v?me.TileCut:ts(y),p?me.TileCut:ts(b),d):El(g,o.x,o.y,u,o.abs_z,o.x.length,v?me.TileCut:ts(y),p?me.TileCut:ts(b),d)},generatePatterned(e,t,n,i,s,r){var I,E;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?(E=o.z)!=null?E:Jl(i,o):void 0;d&&(!f||!Kl(f))&&(d=!1);const h=d?e.getBucket("line","patterned3d",ut.sinks.patterned3d.packObjectAttributes(t,n,i),ut.sinks.patterned3d.binder):e.getBucket("line","patterned",ut.sinks.patterned.packObjectAttributes(t,n,c,u,i),ut.sinks.patterned.binder),g=e.idIndexer.getIndex(i,t,n),v=tb(a[l.componentDistanceStart]/ee,a[l.componentDistanceEnd]/ee,a[l.objectLength]/ee,g,d?ut.sinks.patterned3d.stride/2:ut.sinks.patterned.stride/2),p=Number.isNaN(a[l.beginningIsCut])?!1:a[l.beginningIsCut]!==0,y=Number.isNaN(a[l.endingIsCut])?!1:a[l.endingIsCut]!==0,b=ct(n.style.startCap,i),w=ct(n.style.endCap,i);fo(o.x,o.y,f,o.x.length,p?me.TileCut:ts(b),y?me.TileCut:ts(w),a[l.previousPointX],a[l.previousPointY],a[l.nextPointX],a[l.nextPointY],v,h,!0)}},es={type:hi.Patterned,cDist:0,sLen:0,oLen:0,localID:0,offsetMultiplier:8,px:[],py:[],count:0};function tb(e,t,n,i,s){return es.cDist=e,es.sLen=t-e,es.oLen=n,es.localID=i,es.offsetMultiplier=s,es}function ts(e){switch(e){case"round":return me.Round;case"tilecut":return me.TileCut;case"butt":default:return me.Butt}}function nb(e,t,n,i,s,r,o){if(t.length<2)return;const a=[];for(let d=0;d<t.length;d++)a.push([Ji(t[d]),Ji(n[d])]);const l=Pl(a,eb,!1),c=new Uint16Array(l.length),u=new Uint16Array(l.length);for(let d=0;d<l.length;d++)c[d]=Ki(l[d][0]),u[d]=Ki(l[d][1]);El(e,c,u,void 0,void 0,c.length,s,r,o,void 0,void 0,(d,f)=>sn(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)=>sn(l,g,v):void 0;El(f,s.x,s.y,void 0,void 0,s.x.length,c?me.TileCut:me.Round,u?me.TileCut:me.Round,0,s.normal_x,s.normal_y,h)}};function ot(e,t){return e===0?0:Math.min(e*2-1,(t-e)*2)}function ic(e,t,n,i,s,r,o=0,a,l,c,u,d){let f=e.elements.offset;for(let h=0;h<t;h++){const g=ot(h,t),v=h===t-1;if((!s||s[g]!==1)&&(s||v))continue;const p=n[g],y=i[g],b=(h+1)%t,w=ot(b,t),I=n[w],E=i[w];if(u){const A=Math.hypot(I-p,E-y)*u.tileSizeMapPoints/ee;if(A<u.wallPaddingMapPoints[1]+u.wallPaddingMapPoints[3]+u.textureWidthMapPoints)continue;switch(u.config.horizontal.mode){case"repeat-with-stretch":{const P=u.config.horizontal.slicesCount,T=(A-(u.wallPaddingMapPoints[1]+u.wallPaddingMapPoints[3]))/u.textureWidthMapPoints,C=Math.round(T*P);if(C<u.config.horizontal.minSliceRepeats)continue;const B=C/P/T;if(u.config.horizontal.maxResizeFactor&&B>u.config.horizontal.maxResizeFactor||u.config.horizontal.minResizeFactor&&B<u.config.horizontal.minResizeFactor)continue;break}case"repeat-with-max-interval":break;default:continue}switch(u.config.vertical.mode){case"repeat-with-stretch":{const P=u.config.vertical.slicesCount,T=(r-(u.wallPaddingMapPoints[0]+u.wallPaddingMapPoints[2]))/u.textureHeightMapPoints,C=Math.round(T*P);if(C<u.config.vertical.minSliceRepeats)continue;const B=C/P/T;if(B>u.config.vertical.maxResizeFactor||B<u.config.vertical.minResizeFactor)continue;break}case"repeat-with-max-interval":break;case"stripe-top":break;default:continue}Sh(e,f),Ih(e,f,p,y,I,E,r,o),sb(e,f,r-o,A)}else Sh(e,f),Ih(e,f,p,y,I,E,r,o);c?Mh(e,f,c[0],c[1],c[0],c[1]):Mh(e,f,p,y,I,E),a!==void 0&&"localID"in e.views&&e.views.localID!==void 0&&Th(e.views.localID,f,a,e.elements.stride),l!==void 0&&"labelingTextureID"in e.views&&e.views.labelingTextureID!==void 0&&Th(e.views.labelingTextureID,f,l,e.elements.stride),d!==void 0&&ib(e.views.innerColor,f,d,e.elements.stride),f=f+4}e.elements.offset=f}function ib(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 Ih(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;l[g]=G+n,l[g+1]=G+i,c[g>>1]=it(a)/Ve,d&&(d[h]=a/o),g+=u,l[g]=G+n,l[g+1]=G+i,c[g>>1]=it(o)/Ve,d&&(h+=f,d[h]=1),g+=u,l[g]=G+s,l[g+1]=G+r,c[g>>1]=it(a)/Ve,d&&(h+=f,d[h]=a/o),g+=u,l[g]=G+s,l[g+1]=G+r,c[g>>1]=it(o)/Ve,d&&(h+=f,d[h]=1)}function sb(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 Mh(e,t,n,i,s,r){const o=e.views.demPosition,a=e.elements.stride/o.BYTES_PER_ELEMENT;t=t*a,n=(n+G)/8,i=(i+G)/8,s=(s+G)/8,r=(r+G)/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 Th(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 Sh(e,t){const n=e.indices.buffer;let i=e.indices.offset;n[i++]=t,n[i++]=t+3,n[i++]=t+1,n[i++]=t,n[i++]=t+2,n[i++]=t+3,e.indices.offset=i}const vn=[.5,.5],wn=[.5,.5];function sc(e,t,n,i,s,r){let o=e.elements.offset;const a=ot(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=ot(f,t),g=f===t-1,v=n[h],p=i[h],y=s?s[h]:g?0:1;u!==0&&(tn(wn,l,c,v,p),Ah(e,o,y,g?d:o+4),ab(e,o,l,c,v,p),r?Eh(e,o,r[0],r[1],r[0],r[1]):Eh(e,o,l,c,v,p),ol(wn),lb(e,o,wn),cb(e,o,wn),o=o+4),l=v,c=p,u=y}e.elements.offset=o}function rc(e,t,n,i,s,r,o,a){let l=e.elements.offset;const c=ot(t-2,t),u=ot(t-1,t);let d=n[u],f=i[u],h=s?s[c]:1,g=s?s[u]:0;Vt(vn,n[c],i[c],d,f);let v=vn[0],p=vn[1];for(let y=0;y<t;y++){const b=ot(y,t),w=y===t-1,I=n[b],E=i[b],A=s?s[b]:w?0:1;tn(wn,d,f,I,E);const P=wn[1],T=-wn[0];h!==0&&(g===0?(vn[0]=v,vn[1]=p):rb(vn,v,p,P,T),Ry(wn,v,p,vn[0],vn[1]),Ah(e,l,0,0),ub(e,l,d,f,r,o!=null?o:[d,f]),db(e,l,ol(vn),ol(wn)),fb(e,l),a!==void 0&&"innerColor"in e.views&&e.views.innerColor!==void 0&&ob(e.views.innerColor,l,a,e.elements.stride),l=l+4),d=I,f=E,h=g,g=A,v=P,p=T}e.elements.offset=l}function rb(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 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 Eh(e,t,n,i,s,r){const o=e.views.demPosition,a=e.elements.stride/o.BYTES_PER_ELEMENT;t=t*a,n=(n+G)/8,i=(i+G)/8,s=(s+G)/8,r=(r+G)/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 ab(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]=G+n,o[t+1]=G+i,l[t>>1]=0,a[t<<1]=0,t+=c,o[t]=G+n,o[t+1]=G+i,l[t>>1]=0,a[t<<1]=-1,t+=c,o[t]=G+s,o[t+1]=G+r,l[t>>1]=0,a[t<<1]=-1,t+=c,o[t]=G+s,o[t+1]=G+r,l[t>>1]=0,a[t<<1]=0}function lb(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 cb(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 ub(e,t,n,i,s,r){const o=e.elements.stride/e.views.position.BYTES_PER_ELEMENT;t=t*o,e.views.position[t]=G+n,e.views.position[t+1]=G+i,e.views.height[t>>1]=0,e.views.distance[t<<1]=1,e.views.demPosition[t]=(G+r[0])/8,e.views.demPosition[t+1]=(G+r[1])/8,t+=o,e.views.position[t]=G+n,e.views.position[t+1]=G+i,e.views.height[t>>1]=0,e.views.distance[t<<1]=-1,e.views.demPosition[t]=(G+r[0])/8,e.views.demPosition[t+1]=(G+r[1])/8,t+=o,e.views.position[t]=G+n,e.views.position[t+1]=G+i,e.views.height[t>>1]=it(s)/Ve,e.views.distance[t<<1]=-1,e.views.demPosition[t]=(G+r[0])/8,e.views.demPosition[t+1]=(G+r[1])/8,t+=o,e.views.position[t]=G+n,e.views.position[t+1]=G+i,e.views.height[t>>1]=it(s)/Ve,e.views.distance[t<<1]=1,e.views.demPosition[t]=(G+r[0])/8,e.views.demPosition[t+1]=(G+r[1])/8}function db(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 fb(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 Ah(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=mt(),Qs=mt(),bn=mt();function ns(e,t,n,i,s,r,o,a){De(Ks,t,n,i),De(Qs,s,r,o),Kt(bn,Qs,Ks),iy(Qs,Ks)||(Jt(bn,bn),Un(bn,bn,127)),hb(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;po(e,Ks,bn,1,a,l,u),po(e,Ks,bn,-1,a,l,u),po(e,Qs,bn,-1,a,c,d),po(e,Qs,bn,1,a,c,d)}function po(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]:G+t[0],e.views.position[h+1]=l?t[1]:G+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]*mf:it(t[2]))/Ve}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]:G+v[0])/8,e.views.demPosition[g+1]=(l?v[1]:G+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 hb(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 pb=/\.png$/i;function mb(e){return!!e&&e.type==="polygon"}function yb(e){return!!e&&e.type==="line"}function xh(e){return e.reduce((t,n,i)=>(t[n]=i,t),{})}function gb(e){return e===void 0||typeof e=="boolean"?!!e:!!JSON.stringify(e).match(/\["get","(db_)?sublayer"]/)}function vb(e){return!(e!=null&&e.url.match(pb))}function _h(e,t){return Fi(H(e.style.sideColor,t),H(e.style.sideStrokeColor,t))}const mo=ee/2,wb=1/it(1),wi=(e,t,n,i,s,r,o)=>Re([e,t.innerId,n,i,s,r],t,o),er=e=>({styleId:e[0],layerId:e[1],hiddenByFloorComplexId:e[2],floorId:e[3],isFloorStack:e[4],textureIndex:e[5],tileData:e.slice(6)}),Zn={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:wi,unpackObjectAttributes:er},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:wi,unpackObjectAttributes:er},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:wi,unpackObjectAttributes:er},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:wi,unpackObjectAttributes:er},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:wi,unpackObjectAttributes:er}},generate(e,t,n,i,s,r){var M,x;const o=s.x,a=s.y,l=(M=s.cut)!=null?M:[],c=i.tileAttrs[i.tileProps.db_plan_id]||"",u=i.tileAttrs[i.tileProps.db_hidden_by_plan_building_id]||"",d=i.tileAttrs[i.tileProps.db_sublayer]==="Floor_half_walls_width_extended_ground",f=o.length,h=(x=i.id)!=null?x:"";let g;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])?g=[i.tileAttrs[i.tileProps.db_centroid_x],i.tileAttrs[i.tileProps.db_centroid_y]]:g=Sb(o,a,l);const v=H(n.style.height,i),p=Number.isNaN(i.tileAttrs[i.tileProps.db_basis_height])?0:i.tileAttrs[i.tileProps.db_basis_height],y=i.tileInfo?Ct(i.tileInfo,[0,0]):1,b=Math.max(v*Te*y,wb),w=e.idIndexer.getIndex(i,t,n,{floorId:Number.isNaN(c)?void 0:c}),I=e.pointIndexer.getIndex(h),E=wi(t,n,u,c,d,NaN,i),A=H(n.style.topColor,i),P=H(n.style.strokeColor,i),T=H(n.style.sideColor,i),C=T&&T.isVertexColor?ro(T):void 0,U=P&&P.isVertexColor?ro(P):void 0,B=A&&A.isVertexColor?ro(A):void 0;if(b>0){const L=e.getBucket("polygonExtrusion","sideFill",E,Zn.sinks.sideFill.binder);let _=L.indices.offset;if(ic(L,f,o,a,l,b,p,w,I,g,void 0,C),L.objectsData[_]={objectId:h,size:L.indices.offset-_},n.style.sideTextures.forEach((F,O)=>{var Z,q;if(v<F.minWallHeight)return;const k=F.sliceSize[0]*Te*y,R=F.sliceSize[1]*Te*y,V=F.wallPadding.map(he=>he*Te*y),X=jt((q=(Z=i.tileInfo)==null?void 0:Z.coords[2])!=null?q:15),Y=wi(t,n,u,c,d,O,i),K=e.getBucket("polygonExtrusion","sideTexture",Y,Zn.sinks.sideTexture.binder),J=K.indices.offset,N=F.vertical.mode==="stripe-top"?b-R:0;ic(K,f,o,a,l,b,N,void 0,void 0,g,{config:F,textureWidthMapPoints:k,textureHeightMapPoints:R,wallPaddingMapPoints:V,tileSizeMapPoints:X},C),K.objectsData[J]={objectId:h,size:K.indices.offset-J}}),!c&&(!r.AALinesOff||!_h(n,i))){const F=e.getBucket("polygonExtrusion","sideStroke",E,Zn.sinks.sideStroke.binder);_=F.indices.offset,sc(F,f,o,a,l,g),rc(F,f,o,a,l,b,g,U),F.objectsData[_]={objectId:h,size:F.indices.offset-_}}}const j=e.getBucket("polygonExtrusion","topFill",E,Zn.sinks.topFill.binder);let z=j.indices.offset;bb(j,f,o,a,b,w,I,g,B),j.objectsData[z]={objectId:h,size:j.indices.offset-z};const S=e.getBucket("polygonExtrusion","topStroke",E,Zn.sinks.topStroke.binder);z=S.indices.offset,Ib(S,f,o,a,l,b,g,U),S.objectsData[z]={objectId:h,size:S.indices.offset-z}}};function bb(e,t,n,i,s,r,o,a,l){let c=e.elements.offset;const u=c;oc(e,c++,n[0],i[0],s,r,o,a,l),oc(e,c++,n[1],i[1],s,r,o,a,l);for(let d=2;d<t;d++)Mb(e,u,d),oc(e,c++,n[d],i[d],s,r,o,a,l);e.elements.offset=c}function Ib(e,t,n,i,s,r,o,a){const l={demPosition:o,innerColor:a};for(let c=0;c<t;c++){const u=ot(c,t);if(s&&s[u]===1){const d=ot((c+1)%t,t);ns(e,n[u],i[u],r,n[d],i[d],r,l)}}}function oc(e,t,n,i,s,r,o,a,l){const c=e.elements.stride,u=t*(c/e.views.position.BYTES_PER_ELEMENT),d=t*(c/e.views.height.BYTES_PER_ELEMENT);e.views.position[u]=G+n,e.views.position[u+1]=G+i,e.views.height[d]=it(s)/Ve,e.views.demPosition[u]=(G+a[0])/8,e.views.demPosition[u+1]=(G+a[1])/8;const f=t*(c/e.views.localID.BYTES_PER_ELEMENT);e.views.localID[f]=r,e.views.labelingTextureID[f]=o,l!==void 0&&(e.views.innerColor[f]=l)}function Mb(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 Ph(e){return oe(mo-Math.abs(e[0]-mo),2)+oe(mo-Math.abs(e[1]-mo),2)}function Tb(e){return e[0]===0||e[0]===ee||e[1]===0||e[1]===ee}function Sb(e,t,n){let i,s=oe(ee,2);const r=e.length,o=Ls();for(let a=0;a<r;a++){i||ci(o,[e[a],t[a]]);const l=ot(a,r);if(n[l]===0){const c=[e[l],t[l]],u=ot((a+1)%r,r),d=[e[u],t[u]];if(Tb(c)){const f=Ph(c);f<s&&(i=c,s=f);const h=Ph(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}const is={type:hi.Striped,cDist:0,oLen:0,sLen:0,localID:0,offsetMultiplier:14,px:[],py:[],count:0};function Eb(e,t,n,i){return is.cDist=e,is.oLen=t,is.localID=n,is.offsetMultiplier=i,is.globeMode=!1,is}const In={symbol:"dashedLine",sinks:{stroke:{stride:28,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int16Array(t,6),e.views.texExtender=new Int8Array(t,10),e.views.vertexDistance=new Float32Array(t,12),e.views.componentDistance=new Float32Array(t,16),e.views.objectLength=new Float32Array(t,20),e.views.localID=new Uint32Array(t,24)},packObjectAttributes(e,t,n,i,s){return 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(4)}}},stroke3d:{stride:32,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int16Array(t,4),e.views.texExtender=new Int8Array(t,8),e.views.vertexDistance=new Float32Array(t,12),e.views.componentDistance=new Float32Array(t,16),e.views.objectLength=new Float32Array(t,20),e.views.height=new Float32Array(t,24),e.views.localID=new Uint32Array(t,28)},packObjectAttributes(e,t,n){return 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;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:Jl(i,o):void 0;d&&(!f||!Kl(f))&&(d=!1);const h=d?e.getBucket(n.type,"stroke3d",In.sinks.stroke3d.packObjectAttributes(t,n,i),In.sinks.stroke3d.binder):e.getBucket(n.type,"stroke",In.sinks.stroke.packObjectAttributes(t,n,c,u,i),In.sinks.stroke.binder),g=e.idIndexer.getIndex(i,t,n),v=Eb(a[l.componentDistanceStart]/ee,a[l.objectLength]/ee,g,d?In.sinks.stroke3d.stride/2:In.sinks.stroke.stride/2),p=Number.isNaN(a[l.beginningIsCut])?!1:a[l.beginningIsCut]!==0,y=Number.isNaN(a[l.endingIsCut])?!1:a[l.endingIsCut]!==0;!d&&i.styleState.globeEnabled&&r&&r.coords[2]<On.globeMaxZoom?xb(h,o.x,o.y,r,p?me.TileCut:me.Butt,y?me.TileCut:me.Butt,a[l.previousPointX],a[l.previousPointY],a[l.nextPointX],a[l.nextPointY],v):fo(o.x,o.y,f,o.x.length,p?me.TileCut:me.Butt,y?me.TileCut:me.Butt,a[l.previousPointX],a[l.previousPointY],a[l.nextPointX],a[l.nextPointY],v,h)}},Ab=32;function xb(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([Ji(t[v]),Ji(n[v])]);const f=Pl(d,Ab,!1),h=new Uint16Array(f.length),g=new Uint16Array(f.length);for(let v=0;v<f.length;v++)h[v]=Ki(f[v][0]),g[v]=Ki(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 yo=[Ve/2,Ve/2],Mn={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",Mn.sinks.fill.packObjectAttributes(e,t,a,l,c,n),Mn.sinks.fill.binder,o);Pb(f,r);for(let g=0;g<s.length;g++)_b(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",Mn.sinks.stroke.packObjectAttributes(e,t,o,a,n),Mn.sinks.stroke.binder);for(let u=0;u<r.length;u+=2){const d=r[u]*5,f=r[u+1]*5;ns(l,s[d],s[d+1],s[d+2],s[f],s[f+1],s[f+2],{demPosition:yo,isModel:!0})}}};function _b(e,t,n,i,s){const r=e.elements.offset,o=Mn.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]/Ve,e.views.texCoords[l]=t[a+3],e.views.texCoords[l+1]=t[a+4],e.views.localID[c]=i,e.views.demPosition[l]=yo[0]/8,e.views.demPosition[l+1]=yo[1]/8,e.views.labelingTextureID[c]=s,e.elements.offset++}function Pb(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 ss=Oe(),tr=Oe(),rs={type:hi.Entrance,offsetMultiplier:18,cDist:0,oLen:0,sLen:0,px:[],py:[],count:0,localID:0};function Lb(e,t,n,i){return rs.px=e.x,rs.py=e.y,rs.oLen=n/ee,rs.count=t,rs.localID=i,rs}const nr={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=Cb(r,o,a),c=e.getBucket(n.type,"stroke",nr.sinks.stroke.packObjectAttributes(t,n,a,i),nr.sinks.stroke.binder),u=e.idIndexer.getIndex(i,t,n),d=Lb(s,a,l,u);fo(s.x,s.y,void 0,a,me.Butt,me.Butt,0,0,0,0,d,c);let f=0;Lh(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)}Lh(c,Bs.Arrow,r[h],o[h],r[h+1],o[h+1],-1,0,f,l,u)}}};function Cb(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 Lh(e,t,n,i,s,r,o,a,l,c,u){Db(e,1,2,0,0,2,3),go(e,t,n,i,s,r,o,a,-1,-1,l,c,!0,u),go(e,t,n,i,s,r,o,a,1,-1,l,c,!1,u),go(e,t,n,i,s,r,o,a,1,1,l,c,!1,u),go(e,t,n,i,s,r,o,a,-1,1,l,c,!0,u)}function go(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,y=p>>1;tn(ss,n,i,s,r),zn(tr,ss),e.views.position[p]=G+n,e.views.position[p+1]=G+i,e.views.segmentEnd[p]=G+s,e.views.segmentEnd[p+1]=G+r,e.views.texExtender[v]=Ye(tr[0]*c*(f?-1:1)*Be),e.views.texExtender[v+1]=Ye(tr[1]*c*(f?-1:1)*Be),e.views.arrowExtender[v]=Ye(l*Be),e.views.arrowExtender[v+1]=Ye(c*Be);const b=l+o,w=c+a,I=ss[0]*b+tr[0]*w,E=ss[1]*b+tr[1]*w;e.views.extender[p]=Math.round(I*Be*127),e.views.extender[p+1]=Math.round(E*Be*127),e.views.direction[p]=Math.round(ss[0]*127),e.views.direction[p+1]=Math.round(ss[1]*127),e.views.vertexDistance[y]=u/Ve,e.views.objectLength[y]=d/Ve,e.views.type[y]=t,e.views.localID[y]=h,e.elements.offset++}function Db(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 vo={symbol:"circle",sinks:{fill:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.extender=new Int16Array(t,6),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",vo.sinks.fill.packObjectAttributes(t,n,i),vo.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=sn(i.tileInfo,a[0],a[1]);l=d.x,c=d.y,u=d.z}else l=G+a[0],c=G+a[1],u=it(a[2]);Ob(r,0,2,1,0,3,2),wo(r,l,c,u,-1,-1,o),wo(r,l,c,u,-1,1,o),wo(r,l,c,u,1,1,o),wo(r,l,c,u,1,-1,o)}};function wo(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 Ob(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 os=Oe(),as=Oe(),Ch=Oe(),Dh=Oe(),ac=(e,t,n,i)=>Re([e,t.innerId,n],t,i),lc=e=>({styleId:e[0],layerId:e[1],hiddenByFloorComplexId:e[2],tileData:e.slice(3)}),ir=yf(1),Tn={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:ac,unpackObjectAttributes:lc},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:ac,unpackObjectAttributes:lc},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:ac,unpackObjectAttributes:lc}},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",Tn.sinks.fill.packObjectAttributes(t,n,c,i),Tn.sinks.fill.binder),d=e.getBucket(n.type,"topStroke",Tn.sinks.topStroke.packObjectAttributes(t,n,c,i),Tn.sinks.topStroke.binder),f=e.getBucket(n.type,"sideStroke",Tn.sinks.sideStroke.packObjectAttributes(t,n,c,i),Tn.sinks.sideStroke.binder),h=!r.AALinesOff||!_h(n,i);for(let g=0;g<l-1;g++){const v=o[g],p=a[g],y=o[g+1],b=a[g+1];je(os,v,y),je(as,p,b),je(Ch,y,v),je(Dh,b,p),ic(u,2,os,as,void 0,ir,void 0,void 0,void 0,void 0,void 0,0),ns(d,v,p,ir,y,b,ir),h&&(sc(f,2,os,as,void 0),sc(f,2,Ch,Dh,void 0),rc(f,2,os,as,void 0,ir))}h&&(je(os,o[l-1],o[0]),je(as,a[l-1],a[0]),rc(f,2,os,as,void 0,ir))}},bo={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",bo.sinks.fill.packObjectAttributes(n,s,i,r,o),bo.sinks.fill.binder);let u=c.elements.offset;Fb(c.indices,u,0,1,2,2,1,3),Io(c,u++,a[0],l[0],0,1),Io(c,u++,a[1],l[1],1,1),Io(c,u++,a[2],l[2],0,0),Io(c,u++,a[3],l[3],1,0),c.elements.offset=u}};function Io(e,t,n,i,s,r){t=t*4,e.views.position[t]=G+n,e.views.position[t+1]=G+i,e.views.txtrCoords[t]=St(s),e.views.txtrCoords[t+1]=St(r)}function Fb(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 Rb=8;function cc(e,t,n,i,s,r){return Re([e,t.innerId,n,i,s],t,r)}const Nb=(e,t,n,i,s)=>Re([e,t.innerId,n,i],t,s),uc=e=>({styleId:e[0],layerId:e[1],tiers:e[2],floorId:e[3],hiddenByFloorComplexId:e[4],tileData:e.slice(5)}),Bb=e=>({styleId:e[0],layerId:e[1],tiers:e[2],floorId:e[3],tileData:e.slice(4)}),kb=(e,t)=>{const n=e.type==="polygon"&&H(e.style.color,t),i=Pf(n)&&n.factor.type==="vertex-attribute";return i?{withMixFactor:i,mixFactorAttributeName:n.factor.name}:{withMixFactor:i,mixFactorAttributeName:void 0}},Zt={symbol:"polygon",sinks:{fill:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.localID=new Uint32Array(t,8)},packObjectAttributes:cc,unpackObjectAttributes:uc},stroke:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.directionDistance=new Int8Array(t,8)},packObjectAttributes:cc,unpackObjectAttributes:uc},shadow:{stride:8,binder:(e,t)=>{e.views.position=new Uint16Array(t)},packObjectAttributes:Nb,unpackObjectAttributes:Bb},fillWithMixFactor:{stride:12,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.mixFactor=new Uint16Array(t,8)},packObjectAttributes:cc,unpackObjectAttributes:uc}},generate(e,t,n,i,s,r,o){var P;if(i.tileAttrs[i.tileProps.db_geometry_type]==="polyline")return;const{withMixFactor:l,mixFactorAttributeName:c}=kb(n,i),u=s.x,d=s.y,f=s.cut,h=i.tileAttrs[i.tileProps.db_plan_id]||"",g=l?s[c]:void 0;if(mb(n)&&o&&(ql(e,t,o,n.style,r),n.style.normalMapTextureImage)){const T={textureImage:n.style.normalMapTextureImage,textureSize:n.style.normalMapTextureSize,lengthUnits:n.style.normalMapTextureLengthUnits};ql(e,t,o,T,r)}const v=e.idIndexer.getIndex(i,t,n,{floorId:h||void 0}),p=(P=i.id)!=null?P:"",y=n.type==="polygon"&&!H(n.ignoreTier,i)?i.tileAttrs[i.tileProps.db_tiers]:null,b=i.tileAttrs[i.tileProps.db_hidden_by_metro_building_id]||"",w=l?e.getBucket("polygon","fillWithMixFactor",Zt.sinks.fillWithMixFactor.packObjectAttributes(t,n,y,h,b,i),Zt.sinks.fillWithMixFactor.binder):e.getBucket("polygon","fill",Zt.sinks.fill.packObjectAttributes(t,n,y,h,b,i),Zt.sinks.fill.binder),I=w.indices.offset,E=(uo(i.styleState,i.tileInfo)||i.ecefDataState===ea.Present)&&i.tileInfo!==void 0;E?Hb(w,u,d,i.tileInfo,v):Oh(w,u.length,u,d,v,g),w.objectsData[I]={objectId:p,size:w.indices.offset-I};const A=e.getBucket("polygon","stroke",Zt.sinks.stroke.packObjectAttributes(t,n,y,h,b,i),Zt.sinks.stroke.binder);if(f){const T=A.indices.offset;Ub(A,u.length,u,d,f,E?i.tileInfo:void 0),A.objectsData[T]={objectId:p,size:A.indices.offset-T}}}};function Oh(e,t,n,i,s,r){const o=e.indices.buffer;let a=e.indices.offset,l=e.elements.offset;const c=l;dc(e,l++,n[0],i[0],s,r==null?void 0:r[0]),dc(e,l++,n[1],i[1],s,r==null?void 0:r[1]);for(let u=2;u<t;u++)Gb(o,a,c,u),dc(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 Ub(e,t,n,i,s,r){const o=r!==void 0?{isEcef:!0}:void 0;for(let a=0;a<t;a++){const l=ot(a,t);if(s[l]===1){const c=ot((a+1)%t,t);if(r){const u=sn(r,n[l],i[l]),d=sn(r,n[c],i[c]);ns(e,u.x,u.y,u.z,d.x,d.y,d.z,o)}else ns(e,n[l],i[l],0,n[c],i[c],0)}}}function zb(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 dc(e,t,n,i,s,r){t=t*e.elements.stride/e.views.position.BYTES_PER_ELEMENT,e.views.position[t]=G+n,e.views.position[t+1]=G+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 Gb(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 fc=lt.fromGeo([0,90]),hc=lt.fromGeo([0,-90]),Vb={x:yn(fc[0]),y:yn(fc[1]),z:yn(fc[2])},jb={x:yn(hc[0]),y:yn(hc[1]),z:yn(hc[2])};function Hb(e,t,n,i,s,r){if(t.length<3)return;const o=i.coords,a=o[1]===oe(2,o[2])-1,l=o[1]===0,c=[],u=[],d=t.length;for(let w=0;w<d;w++){const I=ot(w,d);u.push([yh(Ji(t[I])),yh(Ji(n[I]))])}c.push(u);const f=mv(c,{x:2,y:2,z:2},Rb*oe(2,o[3]-o[2]),!1),h=e.indices.buffer;let g=e.indices.offset,v=e.elements.offset;const p=v,y=f.verticesFlattened,b=f.indicesTriangles;for(let w=0;w<y.length;w+=2){const I=Ki(y[w]),E=Ki(y[w+1]);let A;a&&E>=oe(2,15)-10?A=Vb:l&&E<=10?A=jb:A=sn(i,I,E),zb(e,v,A.x,A.y,A.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 $b(e,t,n=[],i=[]){return{x:Fh(n,e),y:Fh(i,t)}}function Fh(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:Yb(e)}}function Yb(e){var t;return!((t=e==null?void 0:e[0])!=null&&t[0])}function Wb(e,t,n,i,s){return[Rh(e.x,t,i[0],s),Rh(e.y,n,i[1],s)]}function Rh(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 Zb(e,t,n,i,s=0,r=0){return[Bh(Nh(e.x,t),i,s),Bh(Nh(e.y,n),i,r)]}function Nh(e,t){const{stretchSize:n,fixSize:i}=Xb(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 Xb({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 Bh(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 qb(e,t,n,i,s,r,o,a,l){const c=$b(n.w,n.h,a,l),u=Wb(c,n.x,n.y,t,$u),d=Zb(c,i,s,$u,r,o);e.set(d,u)}function Jb(e,t,n,i,s,r,o,a,l,c,u,d){const{textureX:f,textureY:h,stretchedX:g,stretchedY:v,countX:p,countY:y}=i,b=r!==-1/0?r:am,w=o!==1/0?o:lm,[I,E]=u;for(let A=0;A<p-1;A++){const P=f[A],T=f[A+1],C=g[A],U=g[A+1];for(let B=0;B<y-1;B++){const j=h[B],z=h[B+1],S=v[B],M=v[B+1];kh(s,0,2,1,1,2,3),Mo(s,e,t,n,C,S,P,j,I,E,b,w,a,l,c,d),Mo(s,e,t,n,U,S,T,j,I,E,b,w,a,l,c,d),Mo(s,e,t,n,C,M,P,z,I,E,b,w,a,l,c,d),Mo(s,e,t,n,U,M,T,z,I,E,b,w,a,l,c,d)}}}const bi=[0,0];function Kb(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*Pa/2;bi[0]=a[0]+c,bi[1]=l[0]+u;const f=bi[0]-d,h=bi[0]+d,g=bi[1]-d,v=bi[1]+d;return kh(s,0,2,1,1,2,3),To(s,e,t,n,f,g,o),To(s,e,t,n,h,g,o),To(s,e,t,n,f,v,o),To(s,e,t,n,h,v,o),bi}function Mo(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:y,y:b,z:w}=v(t,n);e.views.position[p]=y,e.views.position[p+1]=b,e.views.position[p+2]=w}else e.views.position[p]=G+t,e.views.position[p+1]=G+n,e.views.position[p+2]=it(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]=D2(u),e.views.scales[p+1]=C2(d),p=p>>1,e.views.localID[p]=f,e.views.labelingTextureID[p]=h,e.views.spritePointTextureID[p]=g,e.elements.offset++}function To(e,t,n,i,s,r,o){const a=e.elements,l=a.stride*a.offset>>1;e.views.position[l]=G+t,e.views.position[l+1]=G+n,e.views.position[l+2]=it(i),e.views.cornerOffset[l]=s,e.views.cornerOffset[l+1]=-r,e.views.labelingTextureID[l>>1]=o,a.offset++}function kh(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 Qb{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 dt=(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))(dt||{}),Ii=(e=>(e[e.Point=0]="Point",e[e.Line=1]="Line",e))(Ii||{}),sr=(e=>(e[e.Tile=0]="Tile",e[e.Floor=1]="Floor",e[e.DynamicObject=2]="DynamicObject",e[e.PersonalPoi=3]="PersonalPoi",e))(sr||{}),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||{}),We=(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))(We||{});let Uh=Math.random;const eI=e=>{const t={randomSeed:0};kf(t,[e]),Uh=()=>Hs(t,0,1)};function tI(e,t,n,i){const s=zh(e,n,i),r=zh(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 zh(e,t,n){const i=e[t];if(i!==void 0)return i[n]}var Sn=(e=>(e[e.Point=0]="Point",e[e.Line=1]="Line",e[e.OneWayLine=2]="OneWayLine",e))(Sn||{});function ft(e,t){return Number.isNaN(e)?t:e}function So(e,t){if(!e)return"";const n=H(e,t);return!Number.isNaN(n)&&(n||n===0)?String(n):""}const ht=4294967295,En=4294967040,nI=En-1,pc={},iI=1e6,Gh=["main","parser","labeling","models"];let mc=0;Gh.forEach(e=>{const t=mc+Math.floor(nI/Gh.length);pc[e]={min:mc,max:t-iI},mc=t});class sI{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=pc[t].min,this.maxIdentifyIndex=pc[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(de({id:r,styleId:n,layer:i,sublayer:a[o.db_sublayer]},s)):ht}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(_a,_a),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(ht);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}}}function rI(e){return e.type==="labelLine"||e.type==="point"||e.type==="oneWayLine"}function oI(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||!rI(c)){console.error(`Not found layer: ${a.layerId} in style ${a.styleId} in unpackPreLabelingResult`);continue}const u=new yc(a,c,t,o.metatileHash,!!i.floorStackOn);switch(a.type){case Sn.Point:u.setSpecificPointAttributes(a,i,s);break;case Sn.Line:u.setSpecificLineAttributes(a,i,s);break;case Sn.OneWayLine:u.setSpecificOneWayAttributes(a);break}r.push(u)}return r}class yc{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=dt.Common,this.iconPriority=0,this.styleIconPriority=0,this.styleTextPriority=0,this.identifyIndex=ht,this.identifyPoiLabelIndex=ht,this.labelingTextureIndex=ht,this.spritePointTextureIndex=ht,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===Sn.Point?t.geometryType:Ii.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=Ol(So(s.textField,r),s.textMaxLengthPerLine),s.textField2&&(this.label2=Ol(So(s.textField2,r),s.textMaxLengthPerLine)),this.layer.type==="point"&&s.iconTextField&&(this.iconLabel=Ol(So(s.iconTextField,r),s.textMaxLengthPerLine));const o=gt(t.tileCoords);this.mapPointVertices=[];const a=[0,0,0],l=[0,0,0];if(t.geometryType===Ii.Point)pf(this.mapPointVertices,t.vertices,0,o),this.geoPoint=re.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=Vi(this.componentDistanceStart,t.tileCoords[2]),this.objectLengthWorld=Vi(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=So(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=Vi(this.componentDistanceStart,t.tileCoords[2]),this.objectLengthWorld=Vi(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=Vi(this.componentDistanceStart,t.tileCoords[2]),this.objectLengthWorld=Vi(t.objectLength,t.tileCoords[2]),this.tiers=t.tiers}updateRanges(){this.ranges=Wv([this.label,this.label2,this.iconLabel])}}function Xn(e,t,n){const{minX:i,maxX:s,minY:r,maxY:o}=n;e.push(i,r,s-i,o-r,t)}function An(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 aI(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 tI(s,r,n,i)}function gc(e,t,n,i,s,r){const o=An(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(aI(t,a[l].element))return!0;return!1}function Vh(e,t,n,i,s){if(e.placementIndex===-1){s&&Xn(s,Rt.CommercialDead,An(e,0,i.leftRight,i.topBottom));return}if(gc(t,e,0,i.leftRight,i.topBottom,n))e.placementIndex=-1,s&&Xn(s,Rt.CommercialDead,An(e,0,i.leftRight,i.topBottom));else{e.placementIndex=0;const o=An(e,0,i.leftRight,i.topBottom);t.insert(o),s&&Xn(s,Rt.CommercialAlive,o)}}function vc(e,t,n,i){let s=!0;for(let r=0;r<e.boxes.length;r++)if(gc(t,e,r,e.marginLeftRight,e.marginTopBottom,n)){if(s=!1,i)for(let o=0;o<e.boxes.length;o++){const a=An(e,o,e.marginLeftRight,e.marginTopBottom);let l;o===r?l=Rt.Dead:o<r?l=Rt.Alive:l=Rt.Unused,Xn(i,l,a)}break}if(s)for(let r=0;r<e.boxes.length;r++){const o=An(e,r,e.marginLeftRight,e.marginTopBottom);t.insert(o),i&&Xn(i,Rt.Alive,o)}e.placementIndex=s?0:-1}function lI(e,t,n,i){e.placementIndex=-1;for(let s=0;s<e.boxes.length;s++)if(!(e.firstLabel&&e.firstLabel.placementIndex!==s))if(gc(t,e,s,e.marginLeftRight,e.marginTopBottom,n))i&&Xn(i,Rt.Dead,An(e,s,e.marginLeftRight,e.marginTopBottom));else{const r=An(e,s,e.marginLeftRight,e.marginTopBottom);if(t.insert(r),e.placementIndex=s,i){Xn(i,Rt.Alive,r);for(let o=s+1;o<e.boxes.length;o++)Xn(i,Rt.Unused,An(e,o,e.marginLeftRight,e.marginTopBottom))}break}}function jh(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 Mi(e){return e.type!==We.Box&&!Number.isNaN(e.commPriorityRandomFactor)}function Hh(e){return e.label.pointType===dt.CommercialCity}function cI(e){return Mi(e)&&Hh(e)}function uI(e){return Mi(e)&&e.label.pointType===dt.CommercialPremium}function rr(e){return e.pointType===dt.Commercial||e.pointType===dt.CommercialCity||e.pointType===dt.CommercialPremium}function dI(e){return e.label.pointType!==dt.CommercialCity||e.placementIndex!==-1&&e.label.pointType===dt.CommercialCity}function fI(e,t){return t.size===0?!1:e.filter(i=>hI(i,t)?(i.adsType=0,!0):!1).length>0}function hI(e,t){return e.type===We.Icon&&t.has(e.label.id)}function pI(e){return e.type===We.Box&&e.labelingGroup==="markerText"&&e.parent!==void 0}function mI(e,t,n,i,s){const r=lo();jh(e.filter(Hh),n).forEach(a=>{Vh(a,r,t,i.city,s)}),r.clear(),jh(e.filter(dI),n).forEach(a=>{Vh(a,r,t,i.default,s)})}function $h(e,t,n,i,s){switch(e.type){case We.LineText:case We.Icon:if(e.placementIndex===-1&&Mi(e))break;if(vc(e,n,i,s),e.adsType===0){const o=t.get(e.label.id);if(!o)break;e.placementIndex!==-1&&(o.parent=e,vc(o,n,i,s),t.delete(e.label.id))}break;case We.Box:if(!e.parent){vc(e,n,i,s);break}e.placementIndex=-1;break;case We.PoiText:case We.PoiText2:(!e.parent||e.parent.placementIndex!==-1)&&(!e.firstLabel||e.firstLabel.placementIndex!==-1)?lI(e,n,i,s):e.placementIndex=-1;break}}function yI(e,t,n,i,s,r){const o=[],a=new Map;t.forEach(T=>{if(pI(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),y=Math.round(g*v),b={minX:f.left-p,maxX:f.left+h+p,minY:f.top-y,maxY:f.top+g+y},w=lo(),I=fI(c,l),E=c.sort((T,C)=>{const U=T.label instanceof yc?T.label.hovered:0,B=C.label instanceof yc?C.label.hovered:0,j=i.has(T.id),z=i.has(C.id),S=n.disableSurvivedPoiPrevalence?0:(z?1:0)-(j?1:0),M=I?(C.adsType===0?1:0)-(T.adsType===0?1:0):0;return C.groupPriority-T.groupPriority||(Mi(C)?C.commPriorityRandomFactor+ +z:0)-(Mi(T)?T.commPriorityRandomFactor+ +j:0)||M||S||B-U||C.itemPriority-T.itemPriority||(C.label.id>T.label.id?1:C.label.id===T.label.id?0:-1)||C.label.layer.innerId-T.label.layer.innerId||C.anchorWorld[0]-T.anchorWorld[0]||C.anchorWorld[1]-T.anchorWorld[1]||T.type-C.type});let A=-1;const P=E.filter((T,C)=>Mi(T)?(A=C,!0):!1);if(A!==-1){for(let T=0;T<=A;T++)$h(E[T],a,w,b,u);w.clear(),mI(P,b,i,s,u)}for(let T=0;T<E.length;T++)$h(E[T],a,w,b,u);return u}const wc=new Map;class Eo{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=Yn,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===We.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(rr(t))if(wc.has(this.label.id))this.commPriorityRandomFactor=wc.get(this.label.id);else{const c=Uh();this.commPriorityRandomFactor=c,wc.set(this.label.id,c)}n===We.PoiText?(this.labelingGroup=this.layer.style.allowOverlap?$n: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===We.PoiText2?(this.labelingGroup=this.layer.style.allowOverlap?$n: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?$n: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(rr(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 Yh(e,t,n,i,s,r){if(!e||s&&!r)return[0,0];if(!r)return[e.w/t,e.h/t];const o=bc(n,i,r),a=st(n.style.iconTextPadding);return[a[3]+a[1]+o[0],a[0]+a[2]+o[1]]}function Ao(e,t,n){return Ic(ae(e.style.textFontSize,t),e.style.textLineHeight,n)}function Wh(e,t,n){return Ic(ae(e.style.textFontSize2,t),e.style.textLineHeight,n)}function bc(e,t,n){return Ic(ae(e.style.iconTextFontSize,t),e.style.iconTextLineHeight,n)}function Ic(e,t,n){const s=e/Ut.baseSize*n.maxWidth,r=e*t*n.lines.length;return[s,r]}function Zh(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 gI(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 Xh(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 xo(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,y=-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=y-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=y-s,u=f;break;case"leftBottom":c=y-s,u=g;break}return[c+i[0],u+i[1]]}var Ti=(e=>(e[e.Static=0]="Static",e[e.Unique=1]="Unique",e[e.Loaded=2]="Loaded",e))(Ti||{});let qh=1e4+1;const vI={w:0,h:0,x:0,y:0,atlasIndex:0,isPacked:!1},Mc={};function wI(e,t,n,i,s,r){const o=Cl(e,s);if(!Mc[o]){const a=qh++;Mc[o]={type:Ti.Unique,isSvg:!1,index:a,key:o,name:"",fileName:"",id:e,regionId:n,url:r,rasters:t.map((l,c)=>Ie(de({},vI),{rasterSetIndex:a,rasterIndex:c,w:l,h:l,anchorX:i[0],anchorY:i[1]}))}}return Mc[o]}function bI(e){const t=qh++;return{type:Ti.Loaded,isSvg:!1,index:t,key:`loaded-${t}`,name:"",fileName:"",rasters:e.map((n,i)=>Ie(de({},n),{rasterIndex:i,rasterSetIndex:t}))}}function or(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 Tc(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 Sc(e,t){const n=t.precomputes;return e.map((i,s)=>{const r=n[s];return r&&r.usage===et.Uniform?i:null})}var Ec=(e=>(e[e.Icon=0]="Icon",e[e.First=1]="First",e[e.Second=2]="Second",e))(Ec||{});const Ac=new Qb,ls=[0,0,0],rn={symbol:"point",sinks:{raster:{stride:36,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.cornerOffset=new Int16Array(t,6),e.views.texCoords=new Uint16Array(t,10),e.views.scales=new Int16Array(t,14),e.views.checkPointOffset=new Int16Array(t,18),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,6),e.views.texCoords=new Uint16Array(t,10),e.views.checkPointOffset=new Int16Array(t,14),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=rr(l)&&!u?"":l.floorId,f=Jh(c,e,s,l),h=e.icons[ct(a.style.iconImage,c)],g=Tc(h),v=Yh(f,s,a,c,g,l.iconTextMetrics),p=st(a.style.iconTextOffset),y=st(a.style.iconTextPadding);let b,w=[0,0];if(f)if(l.iconTextMetrics){const P=st(a.style.iconTextAnchor);b=bc(a,c,l.iconTextMetrics),w=Xh(v,b,P,y,p)}else{const P=st(a.style.iconOffset);w=Zh(f,v,P)}Lt(ls,n.anchorWorld,o);const{globeInterStartZoom:I}=On;if(!(r.globeMode&&r.zoom<I)&&!bl(ls))return;const A=uo(r.styleState,o)?(P,T)=>sn(o,P,T):void 0;switch(n.type){case We.Icon:if(!f||g&&!l.iconTextMetrics)return;const P=g?h.stretchX:void 0,T=g?h.stretchY:void 0;if(xc(t,l,d,ls,i,f,v[0]*s,v[1]*s,w[0]*s,w[1]*s,s,P==null?void 0:P.map(([U,B])=>[U*s,B*s]),T==null?void 0:T.map(([U,B])=>[U*s,B*s]),A),!b)return;const C=st(a.style.iconTextAnchor);II(e,t,l,d,ls,r,i,gI(b,C,p),a,s,A);return;case We.PoiText:MI(e,t,n,d,ls,v,r,i,w,a,s,A);return;case We.PoiText2:TI(e,t,n,d,ls,v,r,i,w,a,s,A);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=Jh(a,n,r,e),c=n.icons[ct(o.style.iconImage,a)],u=Tc(c),d=Yh(l,r,o,a,u,e.iconTextMetrics);let f,h=[0,0];if(l&&(!u||e.iconTextMetrics)){if(e.iconTextMetrics){const y=st(o.style.iconTextAnchor),b=st(o.style.iconTextOffset),w=st(o.style.iconTextPadding);f=bc(o,a,e.iconTextMetrics),h=Xh(d,f,y,w,b)}else{const y=st(o.style.iconOffset);h=Zh(l,d,y)}const p=new Eo(e,We.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=ct(o.style.textFont,a);e.label.length>0&&g.length&&(EI(e,t,n,d,i,s,h,o),e.label2&&AI(e,t,n,d,i,s,h,o))}};function II(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=ct(l.style.iconTextFont,f),g=(v=e.fontNameToIndex[h])!=null?v:e.fontNameToIndex[Oi];_o(t,n,i,0,d,s,o,a,l,g,c,u)}function MI(e,t,n,i,s,r,o,a,l,c,u,d){var E;const{label:f}=n,{textMetrics:h}=f,g=Ht(o.styleZoom,o.styleState,!1,f.tileData),v=ct(c.style.textFont,g);if(!v.length)return;const p=Ao(c,g,h),y=(E=e.fontNameToIndex[v])!=null?E:e.fontNameToIndex[Oi],b=n.parent?so(c.style.textPlacement,g):"centerCenter",w=ae(c.style.textOffset,g),I=xo(b,r,p,l,w);_o(t,f,i,1,f.textMetrics,s,a,I,c,y,u,d)}function TI(e,t,n,i,s,r,o,a,l,c,u,d){var P,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=ct(c.style.textFont2,v);if(!p.length)return;const y=Ao(c,v,h),b=Wh(c,v,g),w=ae(c.style.textOffset,v),I=ae((P=c.style.textOffset2)!=null?P:0,v,0),E=(T=e.fontNameToIndex[p])!=null?T:e.fontNameToIndex[Oi],A=xo(so(c.style.textPlacement,v),r,[b[0],y[1]],l,w);A[1]+=(y[1]+b[1])/2+I,_o(t,f,i,2,g,s,a,A,c,E,u,d)}function _o(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",rn.sinks.labelingTexture.packObjectAttributes(t),rn.sinks.labelingTexture.binder);t.checkPointOffset=_I(h,r,s,l,u,t.labelingTextureIndex)}const f={};for(const h of t.ranges)f[h]=e.getBucket("point","text",rn.sinks.text.packObjectAttributes(t,o,h,a,i,c,n,Sc(t.tileData,l)),rn.sinks.text.binder);xI(f,t,r,s,l,i,t.checkPointOffset,d)}function SI(e,t,n,i,s,r,o,a){return xc(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 xc(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;qb(Ac,cn,r,o,a,l,c,d,f),e.atlasPacker.addRastersToLoad(t.styleId,r);const v=e.getBucket("point","labelingTexture",rn.sinks.labelingTexture.packObjectAttributes(t),rn.sinks.labelingTexture.binder);t.checkPointOffset=Kb(i[0],i[1],i[2],Ac,v,u,t.labelingTextureIndex);const p=e.getBucket("point","raster",rn.sinks.raster.packObjectAttributes(t,s,r.atlasIndex,d!==void 0||f!==void 0,n,Sc(t.tileData,g)),rn.sinks.raster.binder);Jb(i[0],i[1],i[2],Ac,p,-1/0,1/0,t.identifyIndex,t.labelingTextureIndex,t.spritePointTextureIndex,t.checkPointOffset,h)}function EI(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=ae(a.style.textOffset,c),d=Ao(a,c,l),f=new Eo(e,We.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=xo(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 AI(e,t,n,i,s,r,o,a){var y;const{textMetrics:l,textMetrics2:c}=e;if(!c)return;const u=Ht(s.styleZoom,s.styleState,!1,e.tileData),d=Ao(a,u,l),f=Wh(a,u,c),h=ae(a.style.textOffset,u),g=ae((y=a.style.textOffset2)!=null?y:0,u,0),v=new Eo(e,We.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=xo(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 Jh(e,t,n,i){const{rasterSets:s}=t,{layer:r}=i;if(r.type!=="point")return;let o;const a=rr(i);if(a||i.pointType===dt.Landmark)o=s.byKey[Cl(i.id,a?"commercial":"landmark")];else{const l=ct(r.style.iconImage,e);if(l.length){const c=st(r.style.iconAnchor);o=s.byKey[Wi(l,c[0],c[1])]}}if(o){const l=ae(r.style.iconWidth,e),c=or(o.rasters,l*n,!0);if(c!==void 0)return o.rasters[c]}}const Po=[0,0];function xI(e,t,n,i,s,r,o,a){let{textLineHeight:u,textLetterSpacing:d}=s.style;r===Ec.Icon&&(u=s.style.iconTextLineHeight,d=s.style.iconTextLetterSpacing);const{identifyPoiLabelIndex:f,labelingTextureIndex:h,spritePointTextureIndex:g}=t,{lines:v,maxWidth:p}=i,y=u*Ut.baseSize;let b=Kh(1,y,v.length);for(let w=0;w<v.length;w++){const I=v[w].width;let E=0;E=-I/2,Po[0]=E,Po[1]=b;const A=v[w].glyphs;for(let P=0;P<A.length;P++){const T=A[P];T.bitmap!==void 0&&CI(e[T.range],n,Po,T,f,h,g,o,a),Po[0]+=T.advance+Ut.baseSize*d}b-=y}}const on=[0,0];function _I(e,t,n,i,s,r){const{lines:o,maxWidth:a}=n;if(!o.length)return on[0]=0,on[1]=0,on;const{textLineHeight:l}=i.style,c=l*Ut.baseSize,u=-a/2,d=Kh(1,c,o.length),f=a/2,h=d-(o.length-1)*c;on[0]=s*(u+f)/2,on[1]=s*(d+h)/2;const g=s*Pa/2,v=on[0]-g,p=on[0]+g,y=on[1]+g,b=on[1]-g,w=e.elements.offset;return Fo(e.indices,w,1,0,3,2,3,0),Co(e,t,v,y,r),Co(e,t,p,y,r),Co(e,t,v,b,r),Co(e,t,p,b,r),on}function PI(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,y=l*f-c*d,b=l*d+c*f,w=u*f-c*d,I=u*d+c*f,E=e.elements.offset;Do(e,t,h,g,i.texLeft,i.texTop,r,o),Do(e,t,v,p,i.texRight,i.texTop,r,o),Do(e,t,y,b,i.texLeft,i.texBottom,r,o),Do(e,t,w,I,i.texRight,i.texBottom,r,o),Fo(e.indices,E,1,0,3,2,3,0)}function LI(e,t,n){const i=e.elements.offset,s=Ye(Math.cos(n)),r=Ye(Math.sin(n));Oo(e,t,s,r,-1,-1),Oo(e,t,s,r,1,-1),Oo(e,t,s,r,1,1),Oo(e,t,s,r,-1,1),Fo(e.indices,i,0,1,2,2,3,0)}function Kh(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 CI(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;Lo(e,t,u,c,i.texLeft,i.texTop,h,g,s,r,o,l),Lo(e,t,f,c,i.texRight,i.texTop,h,g,s,r,o,l),Lo(e,t,u,d,i.texLeft,i.texBottom,h,g,s,r,o,l),Lo(e,t,f,d,i.texRight,i.texBottom,h,g,s,r,o,l),Fo(e.indices,v,1,0,3,2,3,0)}function Lo(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:y}=d(t[0],t[1]);e.views.position[h]=v,e.views.position[h+1]=p,e.views.position[h+2]=y}else e.views.position[h]=G+t[0],e.views.position[h+1]=G+t[1],e.views.position[h+2]=it(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 Co(e,t,n,i,s){const r=e.elements,o=r.stride*r.offset>>1;e.views.position[o]=G+t[0],e.views.position[o+1]=G+t[1],e.views.position[o+2]=it(t[2]),e.views.cornerOffset[o]=n,e.views.cornerOffset[o+1]=i,e.views.labelingTextureID[o>>1]=s,r.offset++}function Do(e,t,n,i,s,r,o,a){const l=e.elements;let c=l.stride*l.offset>>1;e.views.position[c]=G+t[0],e.views.position[c+1]=G+t[1],e.views.position[c+2]=it(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 Oo(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]=G+t[0],e.views.position[a+1]=G+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 Fo(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 _c=[0,0,0],ar=[0,0],Ro={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=ct(d.style.textFont,v),y=(T=e.fontNameToIndex[p])!=null?T:e.fontNameToIndex[Oi],b={},w=H(d.ignoreTier,v)?null:a.tiers;for(const C of a.ranges)b[C]=t.getBucket("labelLine","raster",Ro.sinks.raster.packObjectAttributes(a,i,C,y,w!=null?w:null,Sc(a.tileData,d)),Ro.sinks.raster.binder);const I=a.textMetrics.lines[0],E=ae(d.style.textFontSize,v)/Ut.baseSize,A=I.glyphs,P=DI(f,l,u,r.rotation);ar[0]=-I.width/2,ar[1]=0;for(let C=0;C<A.length;C++){const U=A[C],B=(ar[0]+U.left+U.width/2)*E*(P?-1:1),j=Er(B)||1;let z=-1/0,S=1/0;for(let M=c;M>=1&&M<f.vertexCount&&!(S<n.overflowStyleZoom);M+=j,S=z){const x=j===1?M:M-1;z=zd(Od(B,f.lengths[x]-l),h);const L=f.interpolate(l,M);Lt(_c,L,o),bl(_c)&&U.bitmap!==void 0&&PI(b[U.range],_c,ar,U,L[3]+(P?Math.PI:0),Math.max(z,n.overflowStyleZoom),S)}ar[0]+=U.advance+Ut.baseSize*d.style.textLetterSpacing}},getLabelingInfo(){}};function DI(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 Pc=[0,0,0],No={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(Pc,l,o),!bl(Pc))return;const c=t.getBucket("oneWayLine","raster",No.sinks.raster.packObjectAttributes(a,i,(u=a.tiers)!=null?u:null),No.sinks.raster.binder);LI(c,Pc,l[3])},getLabelingInfo(){}},Si={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",Si.sinks.framebuffer.packObjectAttributes(t,n.innerId),Si.sinks.framebuffer.binder);for(let c=0;c<r.length;c++)FI(l,0,1,2,2,1,3),ko(l,r[c],o[c],-1,-1,a),ko(l,r[c],o[c],1,-1,a),ko(l,r[c],o[c],-1,1,a),ko(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",Si.sinks.fill.packObjectAttributes(t,n,i,s),Si.sinks.fill.binder);let l=a.elements.offset;OI(a.indices,l,0,1,2,0,2,3),Bo(a,l++,r[0],o[0]),Bo(a,l++,r[1],o[1]),Bo(a,l++,r[2],o[2]),Bo(a,l++,r[3],o[3]),a.elements.offset=l}};function Bo(e,t,n,i){const s=t*2;e.views.position[s]=n,e.views.position[s+1]=i}function OI(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 ko(e,t,n,i,s,r){const o=e.elements.offset*e.elements.stride,a=o>>1,l=a>>1;e.views.position[a]=G+t,e.views.position[a+1]=G+n,e.views.weight[l]=r,e.views.widen[o]=i,e.views.widen[o+1]=s,e.elements.offset++}function FI(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 RI=new Set(hd),NI=new Set(Ba),BI=new Set(ka),kI=new Set(md),UI=new Set(yd),zI=new Set(pd);function Uo(e){return RI.has(e)}function Qh(e){return NI.has(e)}function e0(e){return BI.has(e)}function GI(e){return kI.has(e)}function t0(e){return UI.has(e)}function VI(e){return zI.has(e)}const n0=(e,t,n,i,s,r,o,a,l,c,u)=>{var B,j,z,S;const{tileProps:d,tileAttrs:f}=i;if(jI(e,t,n,i,c,u),u)return;let h=dt.Common;const g=f[d.db_sublayer];Qh(g)?h=dt.CommercialCity:e0(g)?h=dt.CommercialPremium:Uo(g)?h=dt.Commercial:t0(g)&&(h=dt.Landmark);const v=l.x.length===1?Ii.Point:Ii.Line;let p=[],y;if(v===Ii.Point){if(i&&n.style.allowElevation){const M=ae(n.style.elevation,i);if(Number.isNaN(M))typeof l.z!="undefined"&&(l.z=[r<4?yf(l.z[0]):l.z[0]]);else{const x=M*Te*Ct(gt(o),[l.x[0],l.y[0]]);l.z=[x]}}p=[[l.x[0]],[l.y[0]],typeof l.z!="undefined"?[l.z[0]]:[0]],y=[0,0,0],vt(y,[p[0][0],p[1][0],p[2][0]],gt(o))}else p=[l.x,l.y];const b=(B=i.id)!=null?B:"",w=(j=f[d.db_plan_id])!=null?j:"",I=(z=f[d.db_plan_level])!=null?z:NaN;let E=ht,A=ht;Number.isNaN(b)||(E=e.idIndexer.getIndex(i,t.id,n,{objectClass:f[d.db_object_class],instanceId:0,metatile:s,center:y,floorId:w,ignoreHover:!0}),A=e.idIndexer.getIndex(i,t.id,n,{objectClass:f[d.db_object_class],instanceId:1,metatile:s,center:y,floorId:w,ignoreHover:!0}));const P=f[d.db_point_building_id],T=e.pointIndexer.getIndex(P),C=e.pointIndexer.getIndex(b),U={type:Sn.Point,pointType:h,geometryType:v,styleId:t.id,layerId:n.innerId,sourceId:a,tileCoords:o,id:(S=i.id)!=null?S:"",floorId:w,planLevel:I,identifyIndex:E,identifyPoiLabelIndex:A,labelingTextureIndex:T,spritePointTextureIndex:C,labelPriority:ft(f[d.db_label_priority],0),label2Priority:ft(f[d.db_label2_priority],0),styleIconPriority:ae(n.style.iconPriority,i),styleTextPriority:ae(n.style.textPriority,i),iconPriority:ft(f[d.db_icon_priority],0),hovered:ft(f[d.hovered],0),componentDistanceStart:ft(f[d.componentDistanceStart],0),componentDistanceEnd:ft(f[d.componentDistanceEnd],0),objectLength:ft(f[d.objectLength],0),vertices:p,demElevation:NaN,tileData:[...i.tileData]};e.addLabel(U)};function jI(e,t,n,i,s,r){var v;const{tileProps:o,tileAttrs:a}=i,{rasterSets:l,icons:c}=t,u=kl(s),d=gi(n.style.iconWidth),f=Uo(a[o.db_sublayer]),h=t0(a[o.db_sublayer]),g=st(n.style.iconAnchor);if(f||h){if(r)return;const p=f?Ca.rasterSizes:gd,y=wI((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,y),e.atlasPacker.pack(y,d,u)}else gi(n.style.iconImage).forEach(p=>{if(!p.length)return;const y=l.byKey[Wi(p,g[0],g[1])];if(!y){console.error(`Not found raster set with image ${p}, anchorX: ${g[0]}, anchorY: ${g[1]}`);return}if(!y.isSvg)return;const b=c[p],w=b&&Tc(b)?[{w:b.width,h:b.height}]:d.map(I=>({w:I,h:I}));e.atlasPacker.packSvg(y,w,u),r&&y.rasters.forEach(I=>e.atlasPacker.addRastersToLoad(t.id,I))})}const HI=(e,t,n,i,s,r,o)=>{var l;const a={type:Sn.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:ft(r.tileAttrs[r.tileProps.componentDistanceStart],0),componentDistanceEnd:ft(r.tileAttrs[r.tileProps.componentDistanceEnd],0),objectLength:ft(r.tileAttrs[r.tileProps.objectLength],0),labelPriority:ft(r.tileAttrs[r.tileProps.db_label_priority],0),styleIconPriority:ae(n.style.textPriority,r),styleTextPriority:ae(n.style.textPriority,r),vertices:[o.x,o.y],tileData:[...r.tileData],tiers:H(n.ignoreTier,r)?void 0:r.tileAttrs[r.tileProps.db_tiers]};e.addLabel(a)},$I=(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:Sn.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:ft(r.tileAttrs[r.tileProps.componentDistanceStart],0),componentDistanceEnd:ft(r.tileAttrs[r.tileProps.componentDistanceEnd],0),objectLength:ft(r.tileAttrs[r.tileProps.objectLength],0),labelPriority:ft(r.tileAttrs[r.tileProps.db_label_priority],0),styleIconPriority:ae(n.style.priority,r),styleTextPriority:0,vertices:[o.x,o.y],tileData:[...r.tileData],tiers:c};e.addLabel(u)};function YI(e,t,n){return Os(n.fontUrlTemplate,{name:e,range:String(t)})}function Lc(e,t,n){const i=xn(e)?e:qn(t.iconBaseUrl,e);return Os(i,{subdomain:n,appHost:window.location.host})}function WI(e,t){return xn(e)?e:qn(t.modelsBaseUrl,e)}function ZI(e,t,n){return xn(e)||!t?e:QI(t)?Cs(t,{modelSrc:e,subdomain:of(n)}):qn(t,e)}function i0(e,t,n){return e.replace("image",`image_${t}x${n}`)}const s0=/_i$/;function XI(e){return s0.test(e)}function r0(e){return e.replace(s0,"")}function qI(e,t){const n=xn(t.fontsPath)?t.fontsPath:qn(t.rootUrl,t.fontsPath),i="{name}_{range}.pbf";e.fontUrlTemplate=qn(n,i),e.iconBaseUrl=xn(t.iconsPath)?t.iconsPath:qn(t.rootUrl,t.iconsPath),e.modelsBaseUrl=xn(t.modelsPath)?t.modelsPath:qn(t.rootUrl,t.modelsPath)}function JI(e){return xn(e.stylePath)?e.stylePath:qn(e.rootUrl,e.stylePath)}const KI=new RegExp("^(?:(?:[a-z]+:)?(?:[a-z]+:)?//|data:)","i");function xn(e){return KI.test(e)}function QI(e){return/{\w+}/g.test(e)}function qn(...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 o0(e,t,n){const i=st(n.style.iconAnchor),s=Wi(e,i[0],i[1]);return t.rasterSets.byKey[s]}function eM(e,t,n,i){const s=t.icons[n.name];if(!s)return;const r=or(n.rasters,i*window.devicePixelRatio,!0);if(r===void 0)return;const o=Lc(s.url,t,cl(e.map.state.subdomains,n.name)),{w:a,h:l}=n.rasters[r];return{fullUrl:o,name:n.name,width:a,height:l}}function tM(e,t,n,i){const s=r0(i),r=o0(s,t,n);if(!r)return;const o=t.icons[r.name];if(o)return Lc(o.url,t,cl(e.map.state.subdomains,r.name))}function nM(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=Jf(e.map.state.styleZoom,e.map.state.styleState,[]);let o;const a=s.style.iconWidth,l=ae(a,r);if(n.isCommercial){o=i.rasterSets.byKey[Cl(t.id,"commercial")];const f=o.url;if(!f)return;const h=or(o.rasters,l*window.devicePixelRatio,!0);if(h===void 0)return;const{w:g,h:v}=o.rasters[h],p=i0(f,g,v);return{baseUrl:f,fullUrl:p,width:g,height:v}}const c=s.style.iconImage;if(!c)return;const u=ct(c,r);if(o=o0(u,i,s),!o)return;const d=eM(e,i,o,l);if(d){if(XI(u)){const f=tM(e,i,s,u);f!==void 0&&(d.fullUrlUnhovered=f,d.nameUnhovered=r0(u))}return d}}function iM(e){return Array.isArray(e)?e:[e]}function sM(e){return e&&e.buffer instanceof ArrayBuffer}var Ei=(e=>(e[e.None=0]="None",e[e.Zoom=1]="Zoom",e[e.Distance=2]="Distance",e))(Ei||{}),a0=(e=>(e[e.default=0]="default",e[e.flat=1]="flat",e[e.axis=2]="axis",e[e.centroid=3]="centroid",e))(a0||{});const _n=[0,0,0],Ne=new Array(16),Cc=new Float32Array(9),Pn=[0,0,0],Dc=[0,0,0],Oc=[0,0,0],Ai=[0,0,0],zo=[0,0,0],l0=[0,0,0],rM=mt(),oM=Or([1,1,1]),Jn={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,y){return Re([e,t.innerId,n,c,l,r,o,i,s,u,d,f,h,g,v,p,y],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){var Y,K,J;const d=Qr(H(n.style.geometryModifier,i),r,s,i);if(d===null)return;const f=H(n.style.linkedIds,i),h=f===""?[]:iM(f),g=n.style.modelSrc,v=[];let p=Ei.None;const y=gi(g,i,n,!0),b=H(n.style.scene,i);if(y.length===1)v.push(0);else if(y.length>1){if(!nn(g)||g.type!=="step"||!nn(g.value)){console.error(`Only step-expression is allowed as 'modelSrc' style property. Models won't be displayed for layer ${n.id}`);return}switch(g.value.type){case"zoom":p=Ei.Zoom;break;case"distance":p=Ei.Distance;break;default:console.error(`'${g.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}g.steps.forEach(({key:N})=>{v.push(N)})}p===Ei.Distance&&y.reverse(),y.forEach((N,Z)=>{N===null&&Z!==0&&(y[Z]=y[Z-1])}),p===Ei.Distance&&y.reverse();const w=y.map(N=>N===null?"":N).map(N=>{let Z=t.modelIndex[N];return Z===void 0&&(N=ZI(N,a!=null?a:"",r.coords),Z=e.addUsedModelByUrl(N)),e.addUsedModel(Z),Z}),{tileProps:I,tileAttrs:E}=i;let A=En;n.interactive?i.id&&(A=E[I.hovered]?ht:e.idIndexer.getIndex(i,t.id,n,{metatile:c,objectClass:E[I.db_object_class]})):A=n.interactiveOcclusion?En:ht;const P=(Y=i.id)!=null?Y:"-1",T=E[I.db_point_building_id],C=E[I.db_hidden_by_metro_building_id]||"";let U=En;i.id&&(U=e.pointIndexer.getIndex(T!=null?T:i.id));const B=l!=null&&l.has(E[I.db_sublayer])&&P!=="-1"?1:0,j=d.abs_z!==void 0&&Array.from(d.abs_z).some(N=>N)?d.abs_z:void 0,z=i.styleState.terrainEnabled===!0,S=i.tileAttrs[i.tileProps.db_extension_to_relief_surface],M=z&&!!j&&!Number.isNaN(S),x=!!i.tileAttrs[i.tileProps.db_ignore_z]&&!!j&&z,L=typeof i.sourceAttrs.sourceName=="string"?i.sourceAttrs.sourceName:"",_=e.getBucket("gltfModel","instances",Jn.sinks.instances.packObjectAttributes(t.id,n,w,v,p,o,L,i,B,B?Ns(d.x[0],d.y[0],r):void 0,T,!!j,E[I.db_plan_id]||"",C,nv(r,d.x[0],d.y[0],u),M,x,b),Jn.sinks.instances.binder);let F=_.meta;if(F)F.linkedIds.push(...h);else{const N=I.db_plan_id?E[I.db_plan_id]:void 0;F=_.meta={linkedIds:h.slice(),modelsPath:a!=null?a:"",buildingId:P,planId:N}}B&&(F.sublayer=E[I.db_sublayer]),T&&(F.childrenIds||(F.childrenIds=[]),F.childrenIds.push(P));let O;const k=cM(E,i);if(k){const N=d.x[0],Z=d.y[0];vt(zo,[N,Z],r),O=[zo,re.fromGeo(k)]}const R=uM(E,i),V=dM(E,i);let X=0;for(let N=0;N<d.x.length;N++){if(De(Dc,0,0,0),Ar(H(n.style.rotation,i),Dc),De(Pn,1,1,1),Ar(H(n.style.scale,i),Pn),De(Oc,0,0,0),Ar(H(n.style.offset,i),Oc),d.xScaleDirection&&d.yScaleDirection&&d.scaleCorrection){const Z=d.x[N],q=d.y[N];vt(zo,[Z,q],r);const he=d.xScaleDirection[N],ye=d.yScaleDirection[N];vt(l0,[he,ye],r),O=[zo,l0],X=d.scaleCorrection[N]}c0(d.x[N],d.y[N],(J=(K=d.z)==null?void 0:K[N])!=null?J:0,Oc,Pn,Dc,O,X,R,V,r),fM(_,_n,Cc,A,U,j==null?void 0:j[N])}},patchBuffer(e,t,n,i,s,r,o,a){const l=Jn.sinks.instances.stride*t;if(c0(i[0],i[1],i[2],s,r,o,void 0,void 0,void 0,void 0,n),a){const u=sn(n,_n[0],_n[1]);e.subData(l+0,new Uint16Array([u.x,u.y,u.z]))}else{const u=_n[0]+G,d=_n[1]+G;e.subData(l+0,new Uint16Array([u,d,0]))}e.subData(l+8,Cc);const c=_n[2]/(32*Ve);e.subData(l+48,new Float32Array([c]))}};function aM(e,t,n,i){const s=n*ee/jt(i.coords[2]);_t(t,t,s),t[2]*=n,ri(e,e,t)}function c0(e,t,n,i,s,r,o,a,l,c,u){De(_n,e,t,n);const d=Ct(u,_n)*Te;if($a(Ne),Lr(Ne,Ne,Me(r[2])),Pd(Ne,Ne,Me(r[1])),Wa(Ne,Ne,Me(r[0])),Ni(Ne,Ne,s),o)if(a)lM(Ne,o[0],o[1]),De(Pn,a*Te,a*Te,d),Ni(Ne,Ne,Pn);else{un(Ai,o[1],o[0]),l?Lr(Ne,Ne,l):Lr(Ne,Ne,Math.atan2(Ai[1],Ai[0]));const f=c!=null?c:_r(Ai);De(Pn,f,f,f),Ni(Ne,Ne,Pn)}else De(Pn,d,d,d),Ni(Ne,Ne,Pn);Wa(Ne,Ne,Math.PI/2),_y(Cc,Ne),aM(_n,i,d,u)}function lM(e,t,n){un(Ai,n,t),Lr(e,e,Math.atan2(Ai[1],Ai[0]))}function cM(e,t){const n=e[t.tileProps.direction];return n===void 0?null:Array.isArray(n)?n:n.type==="Point"?n.coordinates:null}function uM(e,t){return e[t.tileProps.angle]}function dM(e,t){return e[t.tileProps.scale]}function fM(e,t,n,i,s,r){const o=e.elements.offset*Jn.sinks.instances.stride,a=e.views,l=o/a.position.BYTES_PER_ELEMENT,c=G+t[0],u=G+t[1],d=t[2]*mf;if(a.position[l]=c,a.position[l+1]=u,a.position[l+2]=0,a.flatHeight[o/a.flatHeight.BYTES_PER_ELEMENT]=d/Ve,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,hM(e,c,u,d,n);const f=e.indices;f.buffer[f.offset]=e.elements.offset,f.offset++,e.elements.offset++}function hM(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=rM;Gy(s,o);const a=Or(o)/oM;a>e.maxDiag&&(e.maxDiag=a)}var ne=(e=>(e[e.side=0]="side",e[e.top=1]="top",e[e.bottom=2]="bottom",e))(ne||{});const lr=[0,0,0],cr=[0,0,0],ur=[0,0,0],Go=[0,0,0],u0=(e,t,n,i,s)=>Re([e,t.innerId,n,i],t,s),d0=(e,t,n,i)=>Re([e,t.innerId,n],t,i),f0=e=>({styleId:e[0],layerId:e[1],side:e[2],absZ:e[3],tileData:e.slice(4)}),h0=e=>({styleId:e[0],layerId:e[1],absZ:e[2],tileData:e.slice(3)}),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:u0,unpackObjectAttributes:f0},inverse:{stride:16,binder:(e,t)=>{e.views.position=new Uint16Array(t),e.views.height=new Float32Array(t,4),e.views.demPosition=new Int16Array(t,8),e.views.absZ=new Float32Array(t,8),e.views.isPivot=new Uint8Array(t,12)},packObjectAttributes:d0,unpackObjectAttributes:h0},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:d0,unpackObjectAttributes:h0},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:u0,unpackObjectAttributes:f0}},generate(e,t,n,i,s,r,o,a,l,c,u="fill",d=!1,f){var U,B,j,z;const h=r.x,g=r.y,v=r.signed_z;let p=0;if(n.type==="polygon3d"||n.type==="embankment"){const S=H(n.style.elevation,s),M=s.tileInfo?Ct(s.tileInfo,[0,0]):1;p=S*Te*M}const y=r.gradient,b=r.abs_z,w=r.is_pivot,I=h.length,E=s.tileAttrs[s.tileProps.hovered],A=(U=s.id)!=null?U:"",P=e.pointIndexer.getIndex(A);let T=En;switch(n.type){case"polygon3d":{n.interactive?(T=E?ht:e.idIndexer.getIndex(s,t,n),!E&&T===ht&&(T=En)):T=n.interactiveOcclusion?En:ht;break}case"overpass":case"tunnel":{T=e.idIndexer.getIndex(s,t,n),T===ht&&(T=En);break}case"embankment":{T=En;break}default:{const{type:S}=n}}(n.type==="embankment"||n.type==="polygon3d")&&l&&ql(e,t,l,n.style,a);let C;if(u==="inverse")C=e.getBucket("mesh","inverse",Q.sinks.inverse.packObjectAttributes(t,n,!!b,s),Q.sinks.inverse.binder);else if(u==="fill")C=e.getBucket("mesh","fill",Q.sinks.fill.packObjectAttributes(t,n,i,!!b,s),Q.sinks.fill.binder);else if(u==="depthClear")C=e.getBucket("mesh","depthClear",Q.sinks.depthClear.packObjectAttributes(t,n,!!b,s),Q.sinks.depthClear.binder);else return;for(let S=0;S<I-2;S++){const M=!(S%2);pM(C);const x=d?2:1,L=d?1:2,_=M?S+x:S+L,F=M?S+L:S+x,O=ee/o.size;De(lr,h[S],g[S],((B=v==null?void 0:v[S])!=null?B:0)*O),De(cr,h[_],g[_],((j=v==null?void 0:v[_])!=null?j:0)*O),De(ur,h[F],g[F],((z=v==null?void 0:v[F])!=null?z:0)*O),Hd(Go,lr,cr,ur),lr[2]/=O,cr[2]/=O,ur[2]/=O,lr[2]+=p,cr[2]+=p,ur[2]+=p;const k=C.elements.offset;Fc(C,lr,Go,y==null?void 0:y[S],T,P,c,b==null?void 0:b[S],w==null?void 0:w[S],f),Fc(C,cr,Go,y==null?void 0:y[_],T,P,c,b==null?void 0:b[_],w==null?void 0:w[_],f),Fc(C,ur,Go,y==null?void 0:y[F],T,P,c,b==null?void 0:b[F],w==null?void 0:w[F],f),C.objectsData[k]={objectId:A,size:C.elements.offset-k}}}};function Fc(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]=G+t[0],e.views.position[d+1]=G+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])+G)/8,e.views.demPosition[f+1]=(((g=o==null?void 0:o[1])!=null?g:t[1])+G)/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,y=u/e.views.gradient.BYTES_PER_ELEMENT;e.views.normal[v]=Ye(n[0]),e.views.normal[v+1]=Ye(n[1]),e.views.normal[v+2]=Ye(n[2]),e.views.gradient[y]=Ye(i!=null?i:0),e.views.localID[p]=s,e.views.labelingTextureID[p]=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 pM(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 p0=[0,0,0],m0=[0,0,0],y0=[0,0,0],Vo=[0,0,0],cs={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 A;const l=s.x,c=s.y,u=(A=s.signed_z)!=null?A:[],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 y=ee/o.size,b=e.getBucket("mapMesh","fill",cs.sinks.fill.packObjectAttributes(t,n,r,!!h,i),cs.sinks.fill.binder),w=b.indices.buffer;let I=b.indices.offset;const E=b.elements.offset;for(let P=2;P<g;P++){const T=!(P%2),C=T?P-2:P-1,U=T?P-1:P-2;mM(w,I,E,(P-2)*3+2),De(y0,l[C],c[C],u[C]*y),De(m0,l[U],c[U],u[U]*y),De(p0,l[P],c[P],u[P]*y),Hd(Vo,y0,m0,p0),Rc(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],Vo,v,p),Rc(b,l[U],c[U],u[U],d==null?void 0:d[U],f==null?void 0:f[U],h==null?void 0:h[U],Vo,v,p),Rc(b,l[P],c[P],u[P],d==null?void 0:d[P],f==null?void 0:f[P],h==null?void 0:h[P],Vo,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 Rc(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]=G+t,e.views.position[d+1]=G+n,e.views.height[u/e.views.height.BYTES_PER_ELEMENT]=i,e.views.normal[f]=Ye(a[0]),e.views.normal[f+1]=Ye(a[1]),e.views.normal[f+2]=Ye(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]=(G+l)/8,e.views.demPosition[h+1]=(G+c)/8,o!==void 0&&(e.views.absZ[u/e.views.absZ.BYTES_PER_ELEMENT]=o),e.elements.offset++}const yM=1,Nc=-1,gM=1.3,g0=-200,v0=-300,vM=Math.tan(Me(175/2)),Nt=[0,0,0],Kn=[0,0,0],wM=[0,0,0],dr=[0,0,0],Bc=[0,0,0],Ue=[0,0,0];let jo=0,fr=0;const bM=(e,t)=>e<0||t<0?Math.floor(Math.min(e,t)):Math.ceil(Math.max(e,t)),w0={symbol:"overpass",sinks:{},generate(e,t,n,i,s,r,o,a){var _,F,O,k;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 y=i.tileProps,b=i.tileAttrs.slice();i.id=void 0,b[y.db_tiers]=void 0;const w=t.id,I=s.x.length,E=s.x,A=s.y,P=(F=s.cut)!=null?F:[],T=new Uint8Array(I);l.forEach((R,V)=>{T[V]=R?0:1});const C=f==="roadbed_tunnel"||f==="roadbed_tunnel_descent"||f==="border_tunnel"||f==="border_tunnel_descent";let U=!1;C?U=!1:U=!!i.tileAttrs[i.tileProps.db_ignore_z]&&!!c&&u,U&&(l=new Int32Array(l.length));const B=d?gM:1;u&&C&&(l=new Int32Array(l).map(R=>R*B)),je(dr,0,0);const z=Ct(r,dr)*Te,S=ee/r.size*z,M=Math.max(ae(n.style.borderWidth,i,0),0)*S,x=Math.max(ae(n.style.thickness,i,0),0)*z,L=M>0?Math.max(-x,ae(n.style.borderHeight,i,0)*z):0;if(Math.max(ae(n.style.tunnelHeight,i,0),0)*z,h==="polygon"){if(g===void 0)return;const R=[E,A,P,l,new Int8Array(I),T];c&&R.push(c);const V=f==="roadbed_tunnel_descent",X=f==="roadbed_tunnel"||V;cs.generate(e,w,n,i,ce(R),g,r,void 0);const Y=R.map(N=>Array.from(N));for(let N=0;N<Y[3].length;N++)V?Y[3][N]-=x*.01:Y[3][N]-=x,Y[4][N]=0;Q.generate(e,w,n,ne.bottom,i,ce(Y),r,o,a,void 0,X?"inverse":"fill",!0);const K=[];for(let N=0;N<g;N++)K.push(N);const J=e.getBucket("polygon","shadow",Zt.sinks.shadow.packObjectAttributes(w,n,K,"",i),Zt.sinks.shadow.binder);if(Oh(J,R[0].length,R[0],R[1],ht),X&&!V){const N=R.slice();N[3]=Array.from(R[3]).map(Z=>Z+Math.abs(Z/B)-1),N.length=4,Q.generate(e,w,n,ne.top,i,ce(N),r,o,a,void 0,"inverse")}if(V&&u&&!v){const N=R.slice();N[3]=new Array(R[0].length).fill(Math.max(0,L)),N[5]=new Array(R[0].length).fill(1),Q.generate(e,w,n,ne.top,i,ce(N),r,o,a,void 0,"depthClear")}}else if(h==="polyline"){const R=Q.sinks.stroke.packObjectAttributes(w,n,ne.top,!!c,i),V=Q.sinks.stroke.packObjectAttributes(w,n,ne.side,!!c,i),X=Q.sinks.stroke.packObjectAttributes(w,n,ne.bottom,!!c,i),Y=IM({x:E,y:A,cut:P,signed_z:l,is_pivot:T,abs_z:c});if(f==="tunnel_arch"&&!v){const K=Math.max(L,0),J=Ho(Y),N=SM(Y,M),Z=Y.map($=>{const te=$.slice();return te[2]=d?v0:g0,c&&(te[5]=0),te[4]=0,te});le(e,X,Z);const q=Bt(N,J,M).map($=>($[2]=K,$[4]=1,$)),he=N.map($=>{const te=$.slice();return te[2]=K,te[4]=1,te}),ye=Ae(q,he);do Q.generate(e,w,n,ne.top,i,ce(ye),r,o,a,void 0,K?"fill":"inverse");while(e.isOverloaded());const ge=Y.map($=>{const te=$.slice();return te[2]=K,te[4]=1,te});le(e,R,ge);const se=Ae(ge,Z);do Q.generate(e,w,n,ne.side,i,ce(se),r,o,a);while(e.isOverloaded());const W=Ae(ge.map($=>{const te=$.slice();return te[2]=d?v0:g0,te[4]=0,c&&(te[5]=0),te}),ge.map($=>{const te=$.slice();return te[2]=0,te}));do Q.generate(e,w,n,ne.side,i,ce(W),r,o,a,void 0,"inverse");while(e.isOverloaded());if(K){const $=Bt(N,J,M).map(nt=>(nt[2]=0,nt[4]=0,nt));le(e,X,$),le(e,R,q);const te=Ae($,q);do Q.generate(e,w,n,ne.side,i,ce(te),r,o,a,void 0,"fill");while(e.isOverloaded());const Ce=N.map(nt=>{const pt=nt.slice();return pt[2]=0,pt[4]=0,pt}),ue=Ae([he[0],Ce[0]],[q[0],$[0]]);do Q.generate(e,w,n,ne.side,i,ce(ue),r,o,a,void 0,"fill");while(e.isOverloaded());le(e,R,[he[0],q[0]]),le(e,V,[q[0],$[0]]),le(e,X,[$[0],Ce[0]]);const fe=he.length-1,qt=Ae([Ce[fe],he[fe]],[$[fe],q[fe]]);do Q.generate(e,w,n,ne.side,i,ce(qt),r,o,a,void 0,"fill");while(e.isOverloaded());if(le(e,R,[he[fe],q[fe]]),le(e,V,[q[fe],$[fe]]),le(e,X,[$[fe],Ce[fe]]),u){do Q.generate(e,w,n,ne.top,i,ce(ye),r,o,a,void 0,"depthClear");while(e.isOverloaded());do Q.generate(e,w,n,ne.side,i,ce(te),r,o,a,void 0,"depthClear");while(e.isOverloaded());do Q.generate(e,w,n,ne.side,i,ce(ue),r,o,a,void 0,"depthClear");while(e.isOverloaded());do Q.generate(e,w,n,ne.side,i,ce(qt),r,o,a,void 0,"depthClear");while(e.isOverloaded())}}}else if(f==="border_overpass"||f==="border_flat"){const K=[b[y.previousPointX],b[y.previousPointY],(O=l[0])!=null?O:0,0],J=!!b[y.beginningIsCut]&&b0(Y[1],Y[0],K);J&&Y.splice(0,0,K);const N=Y.length-1,Z=[b[y.nextPointX],b[y.nextPointY],(k=l[l.length-1])!=null?k:0,0],q=!!b[y.endingIsCut]&&b0(Y[N-1],Y[N],Z);q&&Y.push(Z);const he=Ho(Y);J&&(he.shift(),Y.shift()),q&&(he.pop(),Y.pop());const ye=Y.map(ue=>{const fe=ue.slice();return fe[2]=Math.max(fe[2]-x,0),fe[4]=0,fe});le(e,V,Y);const ge=Bt(Y,he,M).map(ue=>{const fe=ue.slice();return fe[2]=Math.max(ue[2]-x,0),fe[4]=0,fe}),se=Bt(Y,he,M).map(ue=>{const fe=ue.slice();return fe[2]=Math.max(ue[2]+L,0),fe[4]=1,fe}),W=Y.map(ue=>{const fe=ue.slice();return L>0&&(fe[2]=Math.max(fe[2]+L,0)),fe[4]=1,fe});if(L>0){le(e,R,W);const ue=Ae(W,Y.map(fe=>{const qt=fe.slice();return qt[4]=0,qt}));do Q.generate(e,w,n,ne.side,i,ce(ue),r,o,a);while(e.isOverloaded())}le(e,X,ge),le(e,R,se);const $=Ae(se,W);do Q.generate(e,w,n,ne.top,i,ce($),r,o,a);while(e.isOverloaded());const te=Ae(ye,ge);do Q.generate(e,w,n,ne.bottom,i,ce(te),r,o,a,void 0,"fill");while(e.isOverloaded());const Ce=Ae(ge,se);do Q.generate(e,w,n,ne.side,i,ce(Ce),r,o,a,void 0,"fill");while(e.isOverloaded());if(l[0]===0){const ue=Ae([W[0],ye[0]],[se[0],ge[0]]);do Q.generate(e,w,n,ne.side,i,ce(ue),r,o,a,void 0,"fill");while(e.isOverloaded());le(e,R,[se[0],W[0]]),le(e,V,[W[0],ye[0]]),le(e,V,[ge[0],se[0]]),le(e,X,[ye[0],ge[0]])}if(l[l.length-1]===0){const ue=ye.length-1,fe=Ae([ye[ue],W[ue]],[ge[ue],se[ue]]);do Q.generate(e,w,n,ne.side,i,ce(fe),r,o,a,void 0,"fill");while(e.isOverloaded());le(e,R,[W[ue],se[ue]]),le(e,V,[ye[ue],W[ue]]),le(e,V,[se[ue],ge[ue]]),le(e,X,[ge[ue],ye[ue]])}}else{const K=Ho(Y),J=f==="border_tunnel_descent",N=f==="border_tunnel"||J,Z=N?Math.max(L,0):L,q=Y.map(se=>{const W=se.slice();return W[2]-=x,J?(W[2]=0,W[5]=1):N&&(W[2]=Math.max(W[2],Nc)),W[4]=0,W}),he=Bt(Y,K,M).map(se=>(se[2]-=x,J&&(se[2]=0,se[5]=1),se[4]=0,se)),ye=Bt(Y,K,M).map(se=>(se[2]+=Z,J?(se[2]=Z,se[5]=1):N&&(se[2]=Math.max(se[2],Nc)),se[4]=1,se)),ge=Y.map(se=>{const W=se.slice();if(W[4]=1,J)W[2]=Z,W[5]=1;else if(N){const $=Math.abs(W[2]/B),te=Z-W[2],Ce=W[2]+$-1;W[4]=(Ce+Math.abs(W[2]))/te,W[2]=Ce}else W[2]+=Z;return W});if(N){J&&le(e,R,ge);const se=Ae(ge,Y.map(te=>{const Ce=te.slice();return Ce[4]=0,Ce}));do Q.generate(e,w,n,ne.side,i,ce(se),r,o,a);while(e.isOverloaded());const W=ge.map(te=>{const Ce=te.slice();return Ce[2]=Math.min(te[2],Nc),Ce}),$=Ae(W,Y);do Q.generate(e,w,n,ne.side,i,ce($),r,o,a,void 0,"inverse",!0);while(e.isOverloaded())}if(L>0&&(!N||J)){le(e,X,he),le(e,R,ye);const se=Ae(ye,ge);do Q.generate(e,w,n,ne.top,i,ce(se),r,o,a);while(e.isOverloaded());if(J&&u)do Q.generate(e,w,n,ne.top,i,ce(se),r,o,a,void 0,"depthClear");while(e.isOverloaded())}if(!N||J){const se=Ae(q,he);do Q.generate(e,w,n,ne.bottom,i,ce(se),r,o,a,void 0,"fill");while(e.isOverloaded());const W=Ae(he,ye);do Q.generate(e,w,n,ne.side,i,ce(W),r,o,a,void 0,"fill");while(e.isOverloaded());if(J&&u)do Q.generate(e,w,n,ne.side,i,ce(W),r,o,a,void 0,"depthClear");while(e.isOverloaded());if(l[0]===0){const $=Ae([ge[0],q[0]],[ye[0],he[0]]);do Q.generate(e,w,n,ne.side,i,ce($),r,o,a,void 0,"fill");while(e.isOverloaded());if(J&&u)do Q.generate(e,w,n,ne.side,i,ce($),r,o,a,void 0,"depthClear");while(e.isOverloaded());le(e,R,[ye[0],ge[0]]),le(e,V,[ge[0],q[0]]),le(e,V,[he[0],ye[0]]),le(e,X,[q[0],he[0]])}if(l[l.length-1]===0){const $=q.length-1,te=Ae([q[$],ge[$]],[he[$],ye[$]]);do Q.generate(e,w,n,ne.side,i,ce(te),r,o,a,void 0,"fill");while(e.isOverloaded());if(J&&u)do Q.generate(e,w,n,ne.side,i,ce(te),r,o,a,void 0,"depthClear");while(e.isOverloaded());le(e,R,[ge[$],ye[$]]),le(e,V,[q[$],ge[$]]),le(e,V,[ye[$],he[$]]),le(e,X,[he[$],q[$]])}}}}}};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 Ho(e){const t=[];tn(Nt,e[0][0],e[0][1],e[1][0],e[1][1]),jo=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(je(wM,t[n-1][0],t[n-1][1]),je(dr,t[n][0],t[n][1]),al(Ue,Nt),i)fr=0;else{je(Bc,t[n+1][0],t[n+1][1]),tn(Kn,dr[0],dr[1],Bc[0],Bc[1]);const o=xe(Nn(Nt,Kn),-1,1),a=Math.min(Math.sqrt((1-o)/(1+o)),vM),l=Er(Nn(Ue,Kn));fr=a*l}let s=Ue[0]+Nt[0]*jo,r=Ue[1]+Nt[1]*jo;e.push([s,r]),i&&(s=Ue[0]+Nt[0]*fr,r=Ue[1]+Nt[1]*fr,e.push([s,r])),i||(xr(Nt,Kn),jo=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 le(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],ns(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=ot(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 ce(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()),Kt(Ue,e[0],e[1]),Jt(Ue,Ue),Un(Ue,Ue,t),ri(e[0],e[0],Ue),Kt(Ue,e[e.length-1],e[e.length-2]),Jt(Ue,Ue),Un(Ue,Ue,t),ri(e[e.length-1],e[e.length-1],Ue),e}const b0=(function(){const e=Math.cos(Me(yM));return(t,n,i)=>(un(Nt,n,t),Rn(Nt,Nt),un(Kn,n,i),Rn(Kn,Kn),Nn(Nt,Kn)<=e)})();function EM(e,t,n,i){return Re([e,t.innerId,n],t,i)}const $o={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=ae(s.style.width,r),l=ae(s.style.height,r),c=ae(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",$o.sinks.fill.packObjectAttributes(i.id,s,f,r),$o.sinks.fill.binder);let g=h.elements.offset;AM(h.indices,g,0,1,2,0,2,3),Yo(h,g++,u[0],d[0],0,0),Yo(h,g++,u[1],d[1],1,0),Yo(h,g++,u[2],d[2],1,1),Yo(h,g++,u[3],d[3],0,1),h.elements.offset=g}};function Yo(e,t,n,i,s,r){t=t*4,e.views.position[t]=G+n,e.views.position[t+1]=G+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=kl(i);gi(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=ae(n.style.width,s),u=ae(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,xi=1e5,kc=4;function PM(e){return e!==null&&typeof e=="object"&&e.type===_M}function I0(e){return T0(e.lo,e.hi)}function M0(e){return[e%xi,Math.floor(e/xi)%xi,0,0]}function LM(e){let n=0;for(let i=0;i<kc;i++){const s=e[i]*4294967296+n;n=Math.floor(s/xi),e[i]=s%xi}}function CM(e,t){let n=0;for(let i=0;i<kc;i++){const s=e[i]+t[i]+n;n=Math.floor(s/xi),e[i]=s%xi}}function DM(e){const t="00000";let n=!0,i=kc,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 T0(e,t){const n=M0(e),i=M0(t);return LM(i),CM(i,n),DM(i)}const Qe=[0,0,0],Wo=[0,0,0],Zo=new Float64Array(16),S0={symbol:"tunnel",sinks:{},generate(e,t,n,i,s,r,o,a){var Y,K,J;const{tileProps:l,tileAttrs:c}=i,u=(Y=c[l.db_tiers])==null?void 0:Y[0];if(I0(c[l.id])!=="70030076221371399"||!u)return;const f=t.id;je(Qe,0,0);const g=Ct(r,Qe)*Te,v=ee/r.size*g,p=1/(ee/r.size),y=c[l.objectLength],b=(K=c[l.componentDistanceStart])!=null?K:0,w=(J=c[l.componentDistanceEnd])!=null?J:0,I=b===0?0:-5,E=175,A=243,P=w===y?0:-5;if(Number.isNaN(y)||Number.isNaN(b)||y===0)return;const T=A-E,C=E+T*b/y,U=E+T*w/y,B=3.5*v,j=5*v,z=[];let S=0;for(let N=0;N<s.x.length;N++){const Z=[s.x[N],s.y[N],0];N>0&&(S+=Bn(Z,z[N-1]),Z[2]=S),z.push(Z)}const M=OM(z),x=Ho(z);z.forEach(N=>{const Z=N[2]/M;N[2]=(I+Z*(P-I))*g,N[5]=(C+Z*(U-C))*g});const L=Q.sinks.stroke.packObjectAttributes(f,n,ne.side,!0,i),_=Bt(z,x,B),F=Bt(z,x,-B),O=Ae(_,F),k=Bt(z,x,j),R=k.map(N=>{const Z=N.slice();return Z[2]=Math.max(0,Z[2]),Z});Q.generate(e,f,n,ne.side,i,ce(Ae(k,R)),r,o,a,void 0,"inverse");const V=Bt(z,x,-j),X=V.map(N=>{const Z=N.slice();return Z[2]=Math.max(0,Z[2]),Z});Q.generate(e,f,n,ne.side,i,ce(Ae(X,V)),r,o,a,void 0,"inverse"),z[0][2]!==0&&z[z.length-1][2]!==0&&Q.generate(e,f,n,ne.side,i,ce(Ae(R,X)),r,o,a,void 0,"inverse");do cs.generate(e,f,n,i,ce(O),u,r,void 0);while(e.isOverloaded());for(let N=1;N<z.length;N++){const Z=[],q=[],he=z[N-1],ye=z[N],ge=x[N-1],se=x[N];for(let $=0;$<=181;$+=15){const te=Me($),Ce=he.slice();De(Qe,ge[0],ge[1],0),Un(Qe,Qe,B),zn(Wo,Qe),Ld(Zo,-te,Wo),xs(Qe,Qe,Zo),Qe[2]*=p,ri(Ce,Ce,Qe),Z.push(Ce);const ue=ye.slice();De(Qe,se[0],se[1],0),Un(Qe,Qe,B),zn(Wo,Qe),Ld(Zo,-te,Wo),xs(Qe,Qe,Zo),Qe[2]*=p,ri(ue,ue,Qe),q.push(ue)}const W=Ae(Z,q);if(Q.generate(e,f,n,ne.side,i,ce(W),r,o,a,void 0,"fill"),N===1&&z[0][2]===0){le(e,L,Z);const $=z[0].slice(),te=z[0].slice(),Ce=x[0].slice(),ue=x[0].slice();_t(Ce,Ce,j),_t(ue,ue,-j),Gt($,$,Ce),Gt(te,te,ue);const fe=$.slice(),qt=te.slice();fe[2]+=j*p,qt[2]+=j*p;const nt=[$];for(let pt=0;pt<5;pt++)nt.push(fe);for(let pt=0;pt<5;pt++)nt.push(qt);nt.push(te),le(e,L,nt),Q.generate(e,f,n,ne.side,i,ce(Ae(nt,Z)),r,o,a,void 0,"fill")}else if(N===z.length-1&&z[z.length-1][2]===0){le(e,L,q);const $=z[z.length-1].slice(),te=z[z.length-1].slice(),Ce=x[z.length-1].slice(),ue=x[z.length-1].slice();_t(Ce,Ce,j),_t(ue,ue,-j),Gt($,$,Ce),Gt(te,te,ue);const fe=$.slice(),qt=te.slice();fe[2]+=j*p,qt[2]+=j*p;const nt=[$];for(let pt=0;pt<5;pt++)nt.push(fe);for(let pt=0;pt<5;pt++)nt.push(qt);nt.push(te),le(e,L,nt),Q.generate(e,f,n,ne.side,i,ce(Ae(q,nt)),r,o,a,void 0,"fill")}}if(z[0][2]===0||z[z.length-1][2]===0){const N=Bt(z,x,j),Z=Bt(z,x,-j),q=N.map(W=>{const $=W.slice();return $[2]=Math.max(0,$[2]+j*p),$}),he=Z.map(W=>{const $=W.slice();return $[2]=Math.max(0,$[2]+j*p),$});N.forEach(W=>{W[2]=Math.max(0,W[2])}),Z.forEach(W=>{W[2]=Math.max(0,W[2])});const ye=Ae(N,q),ge=Ae(he,Z);le(e,L,N),le(e,L,Z),le(e,L,q),le(e,L,he),Q.generate(e,f,n,ne.side,i,ce(ye),r,o,a,void 0,"fill"),Q.generate(e,f,n,ne.side,i,ce(ge),r,o,a,void 0,"fill");const se=Ae(q,he);Q.generate(e,f,n,ne.top,i,ce(se),r,o,a,void 0,"fill")}}};function OM(e){let t=0;for(let n=0;n<e.length-1;n++)t+=Ts(e[n],e[n+1]);return t}var Uc=(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))(Uc||{});function E0(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)}}}}},zc={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,ne.top,i,s,r,o,a,l,"fill",void 0,u)}};var A0=(e=>(e[e.none=0]="none",e[e.fadeIn=1]="fadeIn",e[e.fadeOut=-1]="fadeOut",e))(A0||{});function x0({collector:e,generator:t,args:n}){do t(e,...n);while(e.isOverloaded())}const _0={arrow:nr,line:ut,polygon:Zt,embankment:zc,polygon3d:zc,metricPoint:$o,labelLine:Ro,lineExtrusion:Tn,polygonExtrusion:Zn,oneWayLine:No,dashedLine:In,shiftedLine:Js,circle:vo,buildingModel:Mn,gltfModel:Jn,point:rn,raster:bo,heatmap:Si,dem:Ot,mesh:Q,mapMesh:cs,overpass:w0,tunnel:S0,simpleMesh:FM},P0={labelLine:Ro,oneWayLine:No,point:rn};function hr(e,t){const n=_0[e];return n?n.sinks[t].stride:0}function Gc(e,t){e.precomputes.forEach((n,i)=>{t.tileData[i]=H(n.expr,t)})}function Vc(e,t,n,i,s,r,o,a,l,c,u,d,f,h){const g=i.styleState.graphicsPreset?t.graphicsPresets[i.styleState.graphicsPreset]||{}:{};n.forEach(v=>{if(kf(i,[u.x[0],u.y[0]]),!(o!==void 0&&(v.maxzoom<=o||v.minzoom>=o+1&&o!==ni.maxDetailLevel))&&!(i.tileProps.hovered&&!Number.isNaN(i.tileAttrs[i.tileProps.hovered])&&i.tileAttrs[i.tileProps.hovered]===1&&v.type!=="polygon"&&v.type!=="polygonExtrusion"&&v.type!=="point"&&v.type!=="polygon3d")){Gc(v,i);do switch(v.type){case"line":const p=H(v.style.pattern,i);p&&p[0]!==Uc.None?ut.generatePatterned(e,t.id,v,i,l,u):ut.generate(e,t.id,v,i,l,u);break;case"dashedLine":In.generate(e,t.id,v,i,u);break;case"shiftedLine":Js.generate(e,t.id,v,i,u);break;case"polygon":Zt.generate(e,t.id,v,i,u,c,t.rasterSets);break;case"polygon3d":case"embankment":zc.generate(e,t.id,v,i,u,l,c,t.rasterSets);break;case"metricPoint":{$o.generate(e,u,c,t,v,i,l);break}case"polygonExtrusion":Zn.generate(e,t.id,v,i,u,g);break;case"labelLine":HI(e,t.id,v,l.coords,a,i,u);break;case"oneWayLine":$I(e,t.id,v,l.coords,a,i,u);break;case"point":{n0(e,t,v,i,s,r,l.coords,a,u,c,d);break}case"lineExtrusion":Tn.generate(e,t.id,v,i,u,g);break;case"arrow":nr.generate(e,t.id,v,i,u);break;case"heatmap":{Si.generate(e,t.id,v,u,i);break}case"gltfModel":{Jn.generateInstances(e,t,v,i,u,l,a,f,h,s,2);break}case"overpass":w0.generate(e,t,v,i,u,l,c,t.rasterSets);break;case"tunnel":S0.generate(e,t,v,i,u,l,c,t.rasterSets);break}while(e.isOverloaded())}})}function RM(e,t,n,i,s,r,o,a){const l=P0[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=P0[i.type];a&&a.getLabelingInfo(e,t,n,s,r,o)}class L0{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 jc="default",GM="floor",VM="dynamicModel";var us=(e=>(e[e.PolygonExtrusion=1]="PolygonExtrusion",e[e.FloorPolygons=2]="FloorPolygons",e[e.All=3]="All",e))(us||{});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 Hc{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(Nl.groups).reduce((i,s)=>(i.includes(s)||i.push(s),i),[]),n=(e.overlay||[]).concat(Nl.overlay).concat(t.reduce((i,s)=>(s===Yn||s===$n||s===Rl||i.push([s,$n]),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:Nl.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=Fn((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(Ie(de({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,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=D(t,{precomputes:[]},et.Generator):this.dataFilter=void 0}constructTileUrl(t,n){return Yg(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 Ds(n?{url:n}:"metatile",i)}}const C0=[{id:"__2gis_comm_poi",type:"point",style:{textFont:["Noto_Sans_Semibold",["step",["zoom"],"Noto_Sans",16,"Noto_Sans"]],iconImage:"peak",iconWidth:["interpolate",["linear"],["zoom"],15,22,16.8,30],textColor:"#3A3A3A",visibility:"visible",textFontSize:[["interpolate",["linear"],["zoom"],15.5,11,18,13],["interpolate",["linear"],["zoom"],15.5,10,18,12]],textHaloColor:"rgba(255,255,255,0.5)",textHaloWidth:.9,iconLabelingGroup:Rl,iconLabelingMargin:{leftRight:6,topBottom:6}},filter:["all",["match",["get","db_sublayer"],["Commercial_poi_default","Commercial_poi_city","Commercial_poi_premium"],!0,!1],["any",["==",["in",["get","db_building_id"],["global","_activeFloorBuildingIds"]],!1],["in",["get","db_plan_id"],["global","_activeFloorIds"]]]]}];function 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="__JAKARTA__DEM__LIGHTING__";class $c extends Error{constructor(t){super(`Unknown expression type '${t[0]}' in '${JSON.stringify(t)}'`),this.name="UnknownExpressionTypeError",Object.setPrototypeOf(this,new.target.prototype)}}function D(e,t,n=et.Uniform){if(_v(e))return Cf(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 R0(e,t,n);case"step":return wT(e,t,n);case"feature-state":case"get":case"source-attr":case"has":return N0(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:D(e[1]||0,t,n)};case"utc-time":return{type:"utc-time",offset:D(e[1]||0,t,n)};case"time":return ET(e,t,n);case"schedule":return AT(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 D(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 xT(e,t,n);case"literal":return Array.isArray(e[1])?_T(e,t,n):typeof e[1]=="object"&&e[1]!==null?PT(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=LT(s);r&&i.push(r)}),{type:"geometry-modifier",modifiers:i};case"pattern":return{type:"line-pattern",patternType:E0(e[1]),parameters:e.slice(2).map(s=>D(s,t,n))};case"precompute":{if(!t)throw new $c(e);const s=t.precomputes.length;return t.precomputes.push({expr:D(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,et.Generator);default:throw new $c(e)}}function Qn(e,t,n=et.Uniform){return fn(e)||Array.isArray(e)&&e.length===0?e:D(e,t,n)}function _i(e,t,n){return e===void 0?e:D(e,t,n)}function aT(e,t,n){const i={type:"match",input:D(e[1],t,n),cases:[],defaultOutput:D(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=D(c,t,n);return _f(u)?l.push(u):console.warn("MatchExpression supports only simple types: string, number, boolean or null",c),l},[]),a={values:new Set(o),output:D(s[r+1],t,n)};i.cases.push(a)}return i}function R0(e,t,n){const i={type:"interpolate",base:1,argument:D(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:D(s[r],t,n),value:D(s[r+1],t,n)};i.steps.push(o)}return i}function lT(e,t,n){return{type:e[0],value:D(e[1],t,n)}}function cT(e,t,n){const i=D(e[1],t,n),s=D(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=>D(i,t,n))}}function dT(e,t,n){return{type:"*",array:e.slice(1).map(i=>D(i,t,n))}}function fT(e,t,n){const i=D(e[1],t,n),s=D(e[2],t,n);return{type:"^",base:i,exponent:s}}function hT(e,t,n){const i=D(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=D(e[2],t,n);return{type:"in",item:i,collection:r}}function pT(e,t,n){return{type:e[0],color:D(e[1],t,n),value:D(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(D(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(D(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=D(i[2],t,n);if(s.type==="interpolate"){const{argument:r}=s;return s.argument.type==="read-from-target"?{type:"mix",value1:D(i[0],t,n),value2:D(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:D(i[0],t,n),value2:D(i[1],t,n),factor:s}}function wT(e,t,n){const i={type:"step",steps:[],value:D(e[1],t,n)},s={key:0,value:D(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:D(r[o+1],t,n)};i.steps.push(a)}return i}function N0(e,t,n){var o;const i=e[0],s=qM(e[1]),r={type:i,property:s};if(n!==et.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=>D(i,t,n))}}function IT(e,t,n){return{type:"coalesce",array:e.slice(1).map(i=>{try{return D(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=>D(i,t,n))}}function TT(e,t,n){return{type:"any",array:e.slice(1).map(i=>D(i,t,n))}}function ST(e,t,n){return{type:"vertex-color",vertexValue:D(e[1],t,n),uniformValue:D(e[2],t,n),mixValue:D(e[3]||1,t,n)}}function ET(e,t,n){return{type:"time",timeSource:D(e[1],t,n),format:e[2]}}function AT(e,t,n){return{type:"schedule",time:D(e[1],t,n),steps:D(e[2],t,n),detailResult:e[3]}}function xT(e,t,n){const i=D(e[1],t,n),s=D(e[2],t,n);return{type:"random",start:i,end:s}}function _T(e,t,n){return{type:"literal-array",array:e[1].map(i=>D(i,t,n))}}function PT(e){return{type:"literal-object",object:{type:"object",value:e[1]}}}function LT(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 CT(e){return e?e.map(t=>{var o,a,l,c,u,d,f,h,g,v,p,y,b,w,I,E,A,P,T,C,U,B,j,z,S,M,x;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=(y=t.vertical)==null?void 0:y.maxResizeFactor)!=null?b:9999,maxInterval:(I=(w=t.vertical)==null?void 0:w.maxInterval)!=null?I:0},horizontal:{mode:(A=(E=t.horizontal)==null?void 0:E.mode)!=null?A:"repeat-with-stretch",slicesCount:(T=(P=t.horizontal)==null?void 0:P.slicesCount)!=null?T:1,minSliceRepeats:(U=(C=t.horizontal)==null?void 0:C.minSliceRepeats)!=null?U:1,minResizeFactor:(j=(B=t.horizontal)==null?void 0:B.minResizeFactor)!=null?j:0,maxResizeFactor:(S=(z=t.horizontal)==null?void 0:z.maxResizeFactor)!=null?S:9999,maxInterval:(x=(M=t.horizontal)==null?void 0:M.maxInterval)!=null?x:0}};return r.sliceSize[0]<=0||r.sliceSize[1]<=0?null:r}).filter(t=>t!==null):[]}function DT(e,t){let n=0;function i(s,r){s.type!=="custom"&&gb(s.filter)&&(n=r)}return e.forEach((s,r)=>{s.type==="group"?s.layers.forEach(o=>i(o,r)):i(s,r)}),t.forEach(s=>{s.type==="point"&&(s.style.iconPriority=Number.MAX_SAFE_INTEGER)}),[...e.slice(0,n+1),...t,...e.slice(n+1)]}function OT(e,t,n){var u,d,f,h,g,v,p,y;const i=Wc((u=e.terrain)!=null?u:{}),s=G0((d=e.environment)!=null?d:{}),r=V0(e.light,i),o=NT(e.graphicsPresets),a={id:t,revision:0,background:{color:js((h=(f=e.background)==null?void 0:f.color)!=null?h:Ew)},light:r,layers:[],layersById:{[Xs]:i,[$l]:s},layerIdToInnerId:{},groupsById:{},iconBaseUrl:"",fontUrlTemplate:"",modelsBaseUrl:"",fonts:Ir,fontNameToIndex:xh(Ir),rasterSets:{byIndex:{},byKey:{}},icons:e.icons||{},models:Object.values((g=e.models)!=null?g:{}),modelIndex:eT(e.models||{}),labelingGroups:HM((v=e.labelingGroups)!=null?v:{}),dem:i,graphicsPresets:o,environment:s,targets:{_TMP_SHORELINE_GRADIENT:{channels:{r:!0},title:"Градиент береговой линии"}}},l=new Hc;let c=(p=e.layers)!=null?p:[];n&&(c=DT((y=e.layers)!=null?y:[],C0));for(const b of c){const w=B0(b);if(!w)continue;w.type==="group"&&(a.groupsById[w.innerId]=w,a.layerIdToInnerId[w.id]=w.innerId),(w.type==="group"?w.layers:[w]).forEach(E=>{var T;const A=(T=E.lightingMode)!=null?T:r.defaultLightMode;r.lightingModes[A]||console.warn(`Не найден режим освещения ${A} для слоя ${E.type}. Будет использован режим освещения по умолчанию.`),a.layers.push(E),a.layersById[E.innerId]=E,a.layerIdToInnerId[E.id]=E.innerId,(E.type==="point"||E.type==="polygon"||E.type==="metricPoint"||E.type==="embankment"||E.type==="polygon3d")&&k0(E,l,a.icons).forEach(U=>{a.rasterSets.byKey[U.key]||(a.rasterSets.byIndex[U.index]=U,a.rasterSets.byKey[U.key]=U)})})}return a}function B0(e){return e.type==="group"?RT(e):Xo(e)}function k0(e,t,n){const i=[];return z0(e).forEach(({image:s,imageType:r,anchor:o})=>{s&&gi(s).forEach(a=>{typeof a!="string"||!a.length||i.push(U0(a,r,t,o,n))})}),i}function U0(e,t,n,i,s){const r=t==="icon"?Wi(e,i[0],i[1]):eo(e);return{type:Ti.Static,index:n.getUniqueIndex(r),key:r,isSvg:vb(s[e]),name:e,fileName:e,anchorX:i[0],anchorY:i[1],rasters:[]}}function z0(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 Yc=new Hc;function FT(e,t){return e.type==="appearance"?{type:e.type,tipMovementAmplitude:D(e.tipMovementAmplitude,t)}:e.type==="repeat"?{type:e.type,tipMovementAmplitude:D(e.tipMovementAmplitude,t),iterationCount:e.iterationCount}:e}function Xo(e,t){var i,s,r,o,a,l,c,u,d,f,h,g,v,p,y,b,w,I,E,A,P,T,C,U,B,j,z;if(e.type==="custom")return{type:"custom",id:e.id,innerId:Zs(),renderIndex:Yc.getIndex(),filter:!1,minzoom:-1/0,maxzoom:1/0,precomputes:[],style:{}};if(!e.style||e.style.visibility==="none")return;let n;try{const S={id:e.id,innerId:Zs(),renderIndex:Yc.getIndex(),filter:D(e.filter||!1,void 0),minzoom:j0(e.minzoom,-1/0),maxzoom:j0(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=Ie(de({},S),{type:e.type,interactive:(r=e.interactive)!=null?r:!0,ignoreTier:D((o=e.ignoreTier)!=null?o:!1,S),style:{visibility:Ze(M.visibility),color:D(M.color,S),width:D(M.width,S),shift:D(M.shift,S),pattern:D(M.pattern,S),startCap:D(M.startCap,S),endCap:D(M.endCap,S),geometryModifier:D(M.geometryModifier,S),mode:M.mode,lengthUnits:BT(e.style.pattern)}});break}case"lineExtrusion":{const M=lw(e.style);n=Ie(de({},S),{type:e.type,style:{visibility:Ze(M.visibility),sideColor:D(M.sideColor,S),strokeWidth:D(M.strokeWidth,S),strokeColor:D(M.strokeColor,S),sideStrokeColor:D(M.sideStrokeColor,S),height:D(M.height,S),nearCameraFade:D(M.nearCameraFade,S)}});break}case"polygon":{const M=nw(e.style),x=pr(M.textureSize)?$0(M.textureSize):M.textureSize,L=pr(M.normalMapTextureSize)?$0(M.normalMapTextureSize):M.normalMapTextureSize;S.drawToTarget==="_TMP_SHORELINE_GRADIENT"&&(M.strokeWidth=0,M.strokeColor="#00000000",M.color=["mix","#000000","#FF0000",["vertexAttribute","denormalized_distance_to_line"]]),n=Ie(de({},S),{type:e.type,interactive:(a=e.interactive)!=null?a:!0,ignoreTier:D((l=e.ignoreTier)!=null?l:!1,S),style:{visibility:Ze(M.visibility),color:D(M.color,S),textureImage:D(M.textureImage,S),textureSize:Qn(x,S),textureOpacity:D(M.textureOpacity,S),strokeColor:D(M.strokeColor,S),strokeWidth:D(M.strokeWidth,S),lengthUnits:H0(M.textureSize),metallic:D(M.metallic,S),roughness:D(M.roughness,S),normalMapTextureImage:D(M.normalMapTextureImage,S),normalMapTextureSize:Qn(L,S),normalMapTextureAnimation:D(M.normalMapTextureAnimation,S),normalMapTextureLengthUnits:H0(M.normalMapTextureSize)}});break}case"polygon3d":case"embankment":{const M=iw(e.style),x=e.type==="polygon3d"?{depthFunc:O0.LEQUAL}:{};n=Ie(de({},S),{type:e.type,interactive:(c=e.interactive)!=null?c:!0,style:{visibility:Ze(M.visibility),color:D(M.color,S),textureImage:D(M.textureImage,S),textureSize:Qn(M.textureSize,S),textureOpacity:D(M.textureOpacity,S),strokeColor:D(M.strokeColor,S),strokeWidth:D(M.strokeWidth,S),nearCameraFade:D(M.nearCameraFade,S),elevation:D(M.elevation,S)},gpuState:de(de({},x),S.gpuState)}),e.type==="polygon3d"&&(n.interactiveOcclusion=(u=e.interactiveOcclusion)!=null?u:!0);break}case"metricPoint":{const M=sw(e.style);n=Ie(de({},S),{type:e.type,interactive:(d=e.interactive)!=null?d:!0,ignoreTier:D((f=e.ignoreTier)!=null?f:!1,S),style:{visibility:Ze(M.visibility),iconImage:D(M.iconImage,S),color:D(M.color,S),rotation:D(M.rotation,S),width:D(M.width,S),height:D(M.height,S)}});break}case"polygonExtrusion":{const M=rw(e.style);n=Ie(de({},S),{type:e.type,interactive:(h=e.interactive)!=null?h:!0,sideTextureIndices:[],style:{visibility:Ze(M.visibility),topColor:D(M.topColor,S),sideColor:D(M.sideColor,S),strokeColor:D(M.strokeColor,S),strokeWidth:D(M.strokeWidth,S),sideStrokeColor:D(M.sideStrokeColor,S),height:D(M.height,S,et.Generator),nearCameraFade:D(M.nearCameraFade,S),sideTextures:CT(M.sideTextures)}});break}case"dashedLine":{const M=dw(e.style);n=Ie(de({},S),{type:e.type,interactive:(g=e.interactive)!=null?g:!0,ignoreTier:D((v=e.ignoreTier)!=null?v:!1,S),style:{visibility:Ze(M.visibility),color:D(M.color,S),gapColor:D(M.gapColor,S),width:D(M.width,S),shift:D(M.shift,S),gapLength:D(M.gapLength,S),dashLength:D(M.dashLength,S),gapTurnsOnly:M.gapTurnsOnly,geometryModifier:D(M.geometryModifier,S),mode:M.mode}});break}case"shiftedLine":{const M=fw(e.style);n=Ie(de({},S),{type:e.type,interactive:(p=e.interactive)!=null?p:!0,ignoreTier:D((y=e.ignoreTier)!=null?y:!1,S),style:{visibility:Ze(M.visibility),color:D(M.color,S),width:D(M.width,S),shift:D(M.shift,S)}});break}case"oneWayLine":{const M=uw(e.style);n=Ie(de({},S),{type:e.type,ignoreTier:D((b=e.ignoreTier)!=null?b:!1,S),interactive:(w=e.interactive)!=null?w:!1,style:{visibility:Ze(M.visibility),color:D(M.color,S),lineWidth:D(M.lineWidth,S),lineLength:D(M.lineLength,S),tipWidth:M.tipWidth,tipHeight:M.tipHeight,roundingRadius:D(M.roundingRadius,S),priority:M.priority,duplicationSpacing:D(M.duplicationSpacing,S),endingOffsets:M.endingOffsets,labelingGroup:M.labelingGroup}});break}case"buildingModel":{const M=aw(e.style);n=Ie(de({},S),{type:e.type,interactive:(I=e.interactive)!=null?I:!0,style:{visibility:Ze(M.visibility),color:D(M.color,S),strokeColor:D(M.strokeColor,S),strokeWidth:D(M.strokeWidth,S),nearCameraFade:D(M.nearCameraFade,S)}});break}case"labelLine":{const M=cw(e.style);n=Ie(de({},S),{type:e.type,interactive:(E=e.interactive)!=null?E:!1,ignoreTier:D((A=e.ignoreTier)!=null?A:!1,S),style:{visibility:Ze(M.visibility),textField:D(M.textField,S,et.Labeling),textFont:M.textFont,textColor:D(M.textColor,S),textFontSize:D(M.textFontSize,S),textLetterSpacing:M.textLetterSpacing,textHaloColor:D(M.textHaloColor,S),textHaloWidth:M.textHaloWidth,textPriority:D(M.textPriority,S),textLabelingSideMargin:M.textLabelingSideMargin,textDuplicationSpacing:D(M.textDuplicationSpacing,S),labelingGroup:M.labelingGroup,lineEndingOffsets:M.lineEndingOffsets}});break}case"point":{const M=pw(e.style);n=Ie(de({},S),{type:e.type,interactive:(P=e.interactive)!=null?P:!0,style:{visibility:Ze(M.visibility),allowOverlap:M.allowOverlap,allowElevation:M.allowElevation,elevation:D(M.elevation,S),iconImage:D(M.iconImage,S),iconAnchor:Qn(M.iconAnchor,S),iconOffset:Qn(M.iconOffset,S),iconWidth:D(M.iconWidth,S),iconTextField:D(M.iconTextField,S,et.Labeling),iconTextFont:_i(M.iconTextFont,S),iconTextAnchor:Qn(M.iconTextAnchor,S),iconTextOffset:Qn(M.iconTextOffset,S),iconTextColor:D(M.iconTextColor,S),iconTextFontSize:D(M.iconTextFontSize,S),iconTextLineHeight:M.iconTextLineHeight,iconTextLetterSpacing:M.iconTextLetterSpacing,iconTextPadding:Qn(M.iconTextPadding,S),iconTextHaloWidth:Vs(Je(M.iconTextHaloWidth)),iconTextHaloColor:D(M.iconTextHaloColor,S),iconOpacity:D(M.iconOpacity,S),iconPriority:D(M.iconPriority,S),iconLabelingMargin:M.iconLabelingMargin,iconLabelingGroup:M.iconLabelingGroup,iconRotation:D(M.iconRotation,S),textField:D(Je(M.textField),S,et.Labeling),textFont:D(Je(M.textFont),S),textColor:D(Je(M.textColor),S),textFontSize:D(Je(M.textFontSize),S),textLineHeight:Vs(Je(M.textLineHeight),1.2),textLetterSpacing:Vs(Je(M.textLetterSpacing)),textField2:_i(hn(M.textField),S,et.Labeling),textFont2:_i(hn(M.textFont),S),textColor2:_i(hn(M.textColor),S)||D(Je(M.textColor),S),textFontSize2:_i(hn(M.textFontSize),S)||D(Je(M.textFontSize),S),textMaxLengthPerLine:M.textMaxLengthPerLine,textPlacement:D(M.textPlacement,S),textPriority:D(M.textPriority,S),textOffset:D(Je(M.textOffset),S),textOffset2:_i(hn(M.textOffset),S),textHaloColor:D(Je(M.textHaloColor),S),textHaloColor2:_i(hn(M.textHaloColor),S)||D(Je(M.textHaloColor),S),textHaloWidth:Vs(Je(M.textHaloWidth)),textHaloWidth2:Vs(hn(M.textHaloWidth)||Je(M.textHaloWidth)),textLabelingMargin:Je(M.textLabelingMargin),textLabelingMargin2:hn(M.textLabelingMargin)||Je(M.textLabelingMargin),textLabelingGroup:Je(M.textLabelingGroup),textLabelingGroup2:hn(M.textLabelingGroup)||Je(M.textLabelingGroup),duplicationSpacing:D(M.duplicationSpacing,S),endingOffsets:M.endingOffsets}});break}case"arrow":{const M=mw(e.style);n=Ie(de({},S),{type:e.type,interactive:(T=e.interactive)!=null?T:!1,ignoreTier:D((C=e.ignoreTier)!=null?C:!1,S),style:{visibility:Ze(M.visibility),color:D(M.color,S),strokeColor:D(M.strokeColor,S),lineWidth:D(M.lineWidth,S),strokeWidth:D(M.strokeWidth,S),tipWidth:D(M.tipWidth,S),tipHeight:D(M.tipHeight,S),roundingRadius:D(M.roundingRadius,S),animation:FT(M.animation,S)}});break}case"raster":{const M=yw(e.style);n=Ie(de({},S),{type:e.type,ignoreTier:D((U=e.ignoreTier)!=null?U:!1,S),style:{visibility:Ze(M.visibility),opacity:D(M.opacity,S)}});break}case"circle":{const M=hw(e.style);n=Ie(de({},S),{type:e.type,interactive:(B=e.interactive)!=null?B:!0,style:{visibility:Ze(M.visibility),color:D(M.color,S),strokeColor:D(M.strokeColor,S),strokeColor2:D(M.strokeColor2,S),width:D(M.width,S),strokeWidth:D(M.strokeWidth,S),strokeWidth2:D(M.strokeWidth2,S)}});break}case"heatmap":{const M=gw(e.style);n=Ie(de({},S),{type:e.type,style:{visibility:Ze(M.visibility),color:D(M.color,S),radius:D(M.radius,S),opacity:D(M.opacity,S),intensity:D(M.intensity,S),weight:D(M.weight,S),downscale:M.downscale},framebufferId:{framebuffer:io}});break}case"model":{const M=ww(e.style);n=Ie(de({},S),{interactive:(j=e.interactive)!=null?j:!0,interactiveOcclusion:(z=e.interactiveOcclusion)!=null?z:!0,type:"gltfModel",style:{visibility:Ze(M.visibility),modelSrc:D(M.modelSrc,S),offset:D(M.offset,S,et.Generator),scale:D(M.scale,S,et.Generator),rotation:D(M.rotation,S,et.Generator),scene:D(M.scene,S),color:D(M.color,S),linkedIds:D(M.linkedIds,S),colorTextureUvIndex:M.colorTextureUvIndex,roughness:M.roughness,metallic:M.metallic,preventObjectsHiding:M.preventObjectsHiding,nearCameraFade:D(M.nearCameraFade,S),ignoreGlobalLighting:M.ignoreGlobalLighting,showRatio:D(M.showRatio,S),lightingModel:M.lightingModel,playAnimation:D(M.playAnimation,S),geometryModifier:D(M.geometryModifier,S)}});break}case"overpass":{const M=bw(e.style);n=Ie(de({},S),{type:e.type,style:{visibility:Ze(M.visibility),debug:M.debug,sideColor:D(M.sideColor,S),bottomColor:D(M.bottomColor,S),topColor:D(M.borderTopColor,S),strokeColor:D(M.strokeColor,S),strokeWidth:D(M.strokeWidth,S),thickness:D(M.thickness,S),borderHeight:D(M.borderHeight,S),borderWidth:D(M.borderWidth,S),color:D(M.color,S),nearCameraFade:D(M.nearCameraFade,S),tunnelHeight:D(M.tunnelHeight,S)}});break}case"tunnel":{const M=Iw(e.style);n=Ie(de({},S),{type:e.type,style:{visibility:Ze(M.visibility),sideColor:D(M.sideColor,S),bottomColor:D(M.bottomColor,S),topColor:D(M.topColor,S),strokeColor:D(M.strokeColor,S),strokeWidth:D(M.strokeWidth,S),color:D(M.color,S),nearCameraFade:D(M.nearCameraFade,S)}});break}}}catch(S){if(S instanceof $c){console.warn(`Problem with layer #${e.id}: ${S}`);return}throw S}return n}function RT(e){var n,i;const t={id:e.id,innerId:Zs(),renderIndex:Yc.getIndex(),type:e.type,layers:[],orderBy:[],precomputes:[]};return t.orderBy=(i=(n=e.orderBy)==null?void 0:n.map(s=>N0(s,t,et.Uniform)))!=null?i:[],e.layers.forEach((s,r)=>{const o=Xo(s,t);o&&(o.groupId=t.innerId,o.groupIndex=r,o.renderIndex=t.renderIndex,t.layers.push(o))}),t}function Wc(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:F0};return n.style={visibility:"visible",lightingDirection:typeof t.lightingDirection!="undefined"?D(t.lightingDirection,n):null,shadingIntensity:D(t.shadingIntensity,n),shadingPalette:R0(t.shadingPalette,n),verticalScale:D(t.verticalScale,n)},n}function G0(e){const t=Mw(e),n={id:"sky",type:"custom",innerId:$l,filter:!0,precomputes:[],minzoom:-1/0,maxzoom:1/0,renderIndex:iT,style:{}};return n.style={visibility:"visible",skyColor:D(t.skyColor,n),fogColor:D(t.fogColor,n),starsIntensity:D(t.starsIntensity,n)},n}function V0(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=D(f.color,void 0),l.ambientIntensity=D(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=D(f.color,void 0),l.dir1Altitude=D(f.altitude,void 0),l.dir1Azimuth=D(f.azimuth,void 0),l.dir1Intensity=D(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=D(f.intensity,void 0),s.dir1Altitude=l.dir1Altitude)):d===1&&(d++,l.dir2Color=D(f.color,void 0),l.dir2Altitude=D(f.altitude,void 0),l.dir2Azimuth=D(f.azimuth,void 0),l.dir2Intensity=D(f.intensity,void 0)))}),i[a]=l}return i[F0]=s,{defaultLightMode:n.defaultLightingMode,lightingModes:i}}function NT(e){return Sw(e)}function j0(e,t){return typeof e=="number"&&!Number.isNaN(e)?e:t}function BT(e){return e&&pr(e[2])?Hn.Meters:Hn.Pixels}function H0(e){return pr(e)?Hn.Meters:Hn.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 $0(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 Ze(e){return e==="none"?"hidden":e}const qo=0,kT=1,UT={type:Ti.Loaded,index:-1,key:Wi("",.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 Y0(e){const t=[],n=Object.keys(ui).length;for(let i=0;i<n;i++)t[i]=NaN;for(const i in e){if(ui[i]===void 0)throw new Error(`No such tile prop '${i}'`);t[ui[i]]=e[i]}return t}class jT{constructor(){this.needRenderIndexRebuild=!1,this.style={id:qo,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:xh(Ir),icons:{},models:[],modelIndex:{},dem:Wc({}),environment:G0({}),graphicsPresets:{light:{},normal:{},immersive:{}},targets:{}},this.zIndexById={};const t=Xo({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(Fa.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 W0(e,t,n){const s=ee,r={x:new Uint16Array([0,s,s,0,0]),y:new Uint16Array([0,0,s,s,0])},o=Y0({}),a=Ys(n,ul,ui,o,Jd);x0({collector:e,generator:ut.generate,args:[qo,t,a,gt([0,0,0,0]),r]})}function Z0(){try{return!!localStorage.getItem("debugStatusCompile")}catch(e){return console.warn("Error accessing localStorage in forceGlStatusCheck:",e),!1}}const Zc={defines:[],hash:""},Ci=class Ci{constructor(t,n,i=Zc,s=Zc){this.shader=null,this.type=t==="vertex"?Ci.Vertex:Ci.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===Ci.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),Z0()&&!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(`
`)}};Ci.Vertex=1,Ci.Fragment=2;let Jo=Ci;function X0(e,t,n,i){for(const s of t)WT(e,n,s,i)}function $T(e,t,n){const i=t.buffer,s=[];for(const r of t.generatedObjects){const o=new DataView(i,r.rangeStart,r.rangeEnd-r.rangeStart),a=e.createBuffer(o);a.purpose="instanced",a.drawType=Xe.StaticDraw,r.buffer=a,r.rangeEnd-r.rangeStart===n&&(r.tMatrix3x3=new Float32Array(o.buffer,r.rangeStart+8,9)),s.push(a)}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 L0(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=q0(s,a,l);if(g.length===0)return;const v=hr(a,l);if(g[0].instanceBinder){const E=$T(s,n,v);t.buffers.push(...E),r.enqueue(n,t);return}let p=0;d&&f?p=d.byteLength/f:p=u.byteLength/v;const{buffer:y,vaos:b,visibilityBuffer:w}=YT(s,g,u,p,d);t.pushBuffer(y),w&&t.pushBuffer(w);const I=a==="polygonExtrusion"&&!o.getFeatureFlag("transparentBuildingsOff")||a==="lineExtrusion";for(let E=0;E<c.length;E++){const{rangeStart:A,rangeEnd:P,attributes:T,drawMode:C,meta:U,objectsData:B}=c[E],j=_0[a].sinks[l].unpackObjectAttributes(T),z=[];for(let S=0;S<g.length;S++){const M=g[S],x=b[S],L=M.uniformSet||"fill",_={id:hl(),type:Tl.Tile,layerSettings:M,start:A/v,count:(P-A)/v,attributes:j,renderingProperties:{},attributesHash:JSON.stringify(T)+"_"+L+"_"+t.detailLevel,vao:x,drawMode:C,tile:t,symbol:a,sink:l,meta:U,canRender:!0};I&&(_.shaderDefinitions=Jo.createShaderDefinitions([{type:"BLEND"}])),t.push(_),M.needsVisibilityBuffer&&z.push(x)}i&&z.length>0&&B&&t instanceof ta&&ZT(B,t,z,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,us.PolygonExtrusion)&&o.push(a)}i.triggerIdUpdate(o)}function q0(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,Ko=1/(mr-1),QT=typeof Float32Array=="function";function J0(e,t){return 1-3*t+3*e}function K0(e,t){return 3*t-6*e}function Q0(e){return 3*e}function Qo(e,t,n){return((J0(t,n)*e+K0(t,n))*e+Q0(t))*e}function ep(e,t,n){return 3*J0(t,n)*e*e+2*K0(t,n)*e+Q0(t)}function eS(e,t,n,i,s){let r,o,a=0;do o=t+(n-t)/2,r=Qo(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=ep(t,n,i);if(r===0)return t;const o=Qo(t,n,i)-e;t-=o/r}return t}function nS(e){return e}function tp(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]=Qo(o*Ko,e,n);function r(o){let a=0,l=1;const c=mr-1;for(;l!==c&&s[l]<=o;++l)a+=Ko;--l;const u=(o-s[l])/(s[l+1]-s[l]),d=a+u*Ko,f=ep(d,e,n);return f>=qT?tS(o,d,e,n):f===0?d:eS(o,a,a+Ko,e,n)}return function(a){return a===0?0:a===1?1:Qo(r(a),t,i)}}function np(e,t,n,i){return t+n/i*e}const iS=tp(.25,.1,.25,1);function ip(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,Ra.nonLinearity+1))+t}const OS=Object.freeze(Object.defineProperty({__proto__:null,ease:ip,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:np},Symbol.toStringTag,{value:"Module"})),FS={easing:"easeInOutQuad",forceFinalValue:!0,renderAfterUpdate:!0};function RS(e,t){return t.tickers[e]}function sp(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]=Ie(de(de({},FS),t),{from:i,to:s,duration:r,attributes:a,startTime:n.time,alreadyStartedGroupTickers:l,iterationCount:o})}function Xc(e,t){delete t.tickers[e]}function rp(e,t){return!!t.tickers[e]}function op(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=ap(i.easing,i.from[c],i.to[c],i.duration,s);r.push(u)}}else r=ap(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||Xc(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 ap(e,t,n,i,s){return typeof e=="string"?OS[e](s,t,n-t,i):e(s,t,n-t,i)}var ea=(e=>(e[e.DerivedFromTile=0]="DerivedFromTile",e[e.Present=1]="Present",e[e.Absent=2]="Absent",e))(ea||{});function NS(e){return e?1:2}let BS=0;class lp{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(Bi(o,t,s),this.mvpMatrices.set(r,o),n){const u=(l=this.demMatrices.get(r))!=null?l:new Float32Array(16);Bi(u,n,s),this.demMatrices.set(r,u)}if(i){const u=(c=this.flatMapTexMatrices.get(r))!=null?c:new Float32Array(16);Bi(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=[],Xc(this.tickerName,t),this.isDestroyed=!0}updateTicker(t){op(this.tickerName,{step:(n,i)=>{this.readiness=i}},t)}startTicker(t,n,i,s,r){sp(this.tickerName,{easing:n},t,s,r,i,1)}tickerFinished(t){return!rp(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 ta extends lp{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,X0(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=G/ee*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=ji(o);this.bounds.set(r,{min:[a[0],a[1]],max:[a[0]+this.size,a[1]+this.size]});const l=xd();Cr(l,[a[0]-i,a[1]-i,0],at(this.size/Di,this.size/Di,bs/Di)),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 cp(e,t,n){e.generatedData=t,n&&e.params.setTileIds(n)}function up(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 qc(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 dp(e){return e.status===0}function fp(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 ta(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>Da&&!s.isModelsInfoLoaded(o))return!1}return!0}class yr{constructor(t,n,i,s,r,o){this.selectedIds=t.slice(),this.styleState=de({},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&&Fi(t.getSelectedIds(),n.getSelectedIds())&&Fi(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 Jc=(e=>(e[e.Initial=0]="Initial",e[e.Loading=1]="Loading",e[e.Loaded=2]="Loaded",e))(Jc||{});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 hp(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){Kc(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),ni.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)){Kc(e,n,t);return}const r=e.identifier.getIdScope(jc);r.isHidden(i,us.PolygonExtrusion)||HS(e,n,i,s).then(o=>{Kc(e,n,t);const a={id:i,tileObjects:[],generatedData:[]},l=[];o.results.forEach(c=>{const u=new ta("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,Ms.inAnimationType,Ms.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",sr.Tile,l),e.identifier.queryFillCache(),n.hover=a})}function Kc(e,t,n){t.hover&&(t.hover.tileObjects.forEach(i=>{t.oldHoverTileObjects.push(i),i.startTicker(n,Ms.outAnimationType,Ms.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 pp(e){if(e.newMod&&e.newMod.needGenerate)return e.newMod.needGenerate=!1,e.newMod}function $S(e){return(!e.currentMod||dp(e.currentMod))&&(!e.newMod||dp(e.newMod))}function YS(e,t){e.currentMod&&qc(e.currentMod,t),e.newMod&&qc(e.newMod,t)}function WS(e){e.currentMod=void 0}function na(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){Qc(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:Qc(e,t,n);return}Qc(e,t,n)}function Qc(e,t,n){const i=Og(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&&fp(e.currentMod,t,n,i,s),e.newMod&&(fp(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 mp{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 ds(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,gl(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 eu(e,t){for(const n of t){const i=e[n],s=na(i);if(!s||!s.ready)return!1}return!0}function yp(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 gp(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 vp(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 wp(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 bp(e,t,n,i,s,r,o,a,l,c,u=0,d=!1,f=!1,h){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:Ip(e,l.zoom,l.styleZoom),zoomDirection:kt.Stationary,zoomStartZoom:0,tileModsCache:new mp(0,(g,v)=>{var p;a.labeler.removeLabels(v.labelsKey),(p=v.objects)==null||p.forEach(y=>a.tileManager.removeObject(y)),qc(v,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,coverageTileLayer:h}}function Ip(e,t,n){return e==="raster"?Math.round(t):Math.floor(n)}function tu(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 Mp(e,t,n,i,s=!1){const{tileManager:r,renderer:o}=e,a=n.displayedMods,l=Td(a,i);l.forEach(d=>{if(d.objects!==void 0){let f=!s;for(const h in i)if(Wg(d.tile,i[h].tile)){f=!1;break}d.objects.forEach(h=>{r.addObject(h),f&&h.startTicker(t,Oa.type,Oa.time,0,1)})}});const c=Td(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 nu(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 iu(e,t,n){iE(e,t.styleZoom,t.zoom),sE(e,t,n),rE(e),ds(e)}function iE(e,t,n){const i=Ip(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,e.coverageTileLayer).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)*ni.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=sa(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=sa(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){ia(l,f),n.matched++;continue}const h=e[d],g=lE(h,i,3);if(g){n.shifted++,ia(l,g);continue}const v=sa(h.coords[0],h.coords[1],h.coords[2]),p=Tp(h,r,s);if(p){n.parent++,ia(l,p),c.add(p);continue}const y=a[v];if(y)for(const b of y)n.children++,ia(l,b)}function u(d){const f=Tp(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 ia(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 Tp(e,t,n){let[i,s,r]=e.coords;for(;r-->=t;){i=Math.floor(i/2),s=Math.floor(s/2);const o=sa(i,s,r);if(n[o])return n[o]}}function sa(e,t,n){return`${e}_${t}_${n}`}function Sp(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:nu(e);break;case xt.WaitingLayer:eu(e.tiles,e.viewportTiles)&&(e.tilesAppearance=xt.ByOne,nu(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||Ep(e))&&(e.zoomDirection=kt.Stationary,e.zoomStartZoom=e.zoomLevel);break;case kt.ZoomingOut:(e.zoomLevel>=e.zoomStartZoom||Ep(e))&&(e.zoomDirection=kt.Stationary,e.zoomStartZoom=e.zoomLevel);break}}function Ep(e){const{tiles:t,viewportTiles:n,displayedMods:i}=e;for(const s of n){const r=t[s],o=na(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,ds(n);for(const r in n.tiles){const o=n.tiles[r];hp(e,t,o,n.sourceId,(s=o.hover)==null?void 0:s.id,!0)}}function Ap(e,t,n,i){if(!t.disableHoverStyles){for(const s in n.tiles){const r=n.tiles[s];hp(e,t,r,n.sourceId,i)}e.labeler.disableThrottleUpdateOnce()}}function gE(e,t){e.styleState=t,ds(e)}function xp(e,t,n,i){i?e.tilesAppearance=xt.ByOne:e.tilesAppearance=xt.GlobalWaiting,e.styleId=t,e.styleRevision=n,ds(e)}function _p(e){e.tilesAppearance=xt.ByOne,nu(e)}function vE(e){e.tilesAppearance=xt.WaitingLayer,e.stopLabelAnimation=!0,Object.keys(e.tiles).forEach(t=>{QS(e.tiles[t])}),ds(e)}function wE(e){e.tilesAppearance=xt.WaitingLayer,Object.keys(e.tiles).forEach(t=>{eE(e.tiles[t])}),ds(e)}function bE(e,t,n){for(const i of e.viewportTiles){const s=e.tiles[i],r=na(s);if(!r)continue;const o=up(r);if(o.length===0)continue;const a=t.getLabelsDemKey(o);r.demKey!==a&&(r.demKey=a,n.addTileLabels(r.labelsKey,sr.Tile,o))}}function su(e){return{_src:e.memSizeJs()}}function IE(e){return{_texture:e.memSizeGPU()}}function Pp(e){return{[String(e.purpose)]:{_initData:e.memSizeJs()}}}function ME(e){return{[String(e.purpose)]:{_glBuffer:e.memSizeGPU()}}}function ru(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=>Lp(i))),t}function ou(e){return{objects:e.objects?e.objects.map(t=>Cp(t)):0}}function Lp(e){return{buffers:e.buffers.map(Pp)}}function Cp(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(Pp).filter(t=>t._initData),textures:e.textures.map(su)}}function SE(e){return{buffers:e.buffers.filter(t=>t instanceof Xe).map(ME),textures:e.textures.map(su)}}function au(e){if(typeof e=="number")return e;let t=0;if(Array.isArray(e))for(const n of e)t+=au(n);else for(const n in e){const i=e[n];typeof i=="number"?t+=i:t+=au(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 Dp{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.lastCoverageRevision=0,this.destroyed=!1,l=Object.assign({viewportPadding:0,disableTilesAnimation:!1,requestOddTiles:!1},l),this.ids=r.identifier.getIdScope((c=l.idScope)!=null?c:jc),this.ids.registerTileLayer(this),this.modules=r,this.mapState=o,this.prevStyleState=o.styleState,this.sourceCore=a,this.id=hl(),this.disableTilesAnimation=!!l.disableTilesAnimation,this.gridState=bp(a.type,a.id,this.id,t,n,i,s,r,this.mapState,this.ids,l.viewportPadding,l.requestOddTiles,l.useExtendedTilesBounds,l.coverageTileLayer),this.maxGeneratingCount=nE(a.type)}memSizeJs(){const t=this.gridState;return{gridState:{displayedMods:Object.keys(t.displayedMods).map(n=>ru(t.displayedMods[n])),tileModsCache:t.tileModsCache.keys().filter(n=>!t.displayedMods[n]).map(n=>ru(t.tileModsCache.get(n)))}}}memSizeGpu(){const t=this.gridState;return{gridState:{displayedMods:Object.keys(t.displayedMods).map(n=>ou(t.displayedMods[n])),tileModsCache:t.tileModsCache.keys().filter(n=>!t.displayedMods[n]).map(n=>ou(t.tileModsCache.get(n)))}}}destroy(){this.destroyed=!0,tu(this.gridState),this.modules.modelsScene.clearSourceTileMapBySource(this.sourceCore.id),this.ids.unregisterTileLayer(this)}redraw(){tu(this.gridState),this.modules.modelsScene.clearSourceTileMapBySource(this.sourceCore.id),iu(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}viewportTilesReady(){return eu(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(){xp(this.gridState,this.mapState.handyStyleId,this.modules.styleManager.getStyleRevision(this.mapState.handyStyleId),this.modules.map.core.getIsFirstStyleUpdate())}finishStyleUpdating(){_p(this.gridState)}setSelectedIds(t){yE(this.modules,this.mapState,this.gridState,t)}setHoverId(t){Ap(this.modules,this.mapState,this.gridState,t)}resetHoverId(){Ap(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=na(n);if(s&&s.ready)return!1}return!0}updateViewport(){iu(this.gridState,this.mapState,this.modules)}update(){if(this.gridState.coverageTileLayer){const s=this.modules.assetManager.coverageRevision;s!==this.lastCoverageRevision&&(this.lastCoverageRevision=s,this.updateViewport())}this.mapState.needReplicasUpdate&&this.setModObjectsSyncNecessity();const t=de({},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,Sp(this.gridState,this.mapState,this.modules);const{demManager:n,labeler:i}=this.modules;bE(this.gridState,n,i),this.fetch(yp(this.gridState)),this.abortFetch(gp(this.gridState)),this.generate(vp(this.gridState)),this.clearTiles(wp(this.gridState)),Mp(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===Jc.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){Bf(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 y;const h=Jn.sinks.instances.unpackObjectAttributes(f.attributes),g=(y=f.meta)==null?void 0:y.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:y,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,y,this.sourceCore.type)}),n.idSet=KS(l),cp(i,l,n.idSet),this.modules.labeler.addTileLabels(i.labelsKey,sr.Tile,up(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=pp(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,us.PolygonExtrusion),r=+!this.ids.isHidden(i,us.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 Op{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=Ie(de({},this.options),{url:t}):this.options=Ie(de({},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%oe(2,32))}setDataFilter(t){t?this.dataFilter=D(t,{precomputes:[]},et.Generator):this.dataFilter=void 0}}let xE=1;function Fp(){return xE++}class Rp{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 Np(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 Bp=15,lu=17;class kp{constructor(t,n,i){var o,a,l;this.type="geojson",this.isCustomPromoteId=!1,this.id=Fp(),this.modelsAppearStrategy=(o=n.modelsAppearStrategy)!=null?o:Wu,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 Op(this.id,this.modules,n);const s=(a=n.minZoom)!=null?a:La.minZoom,r=Math.min((l=n.maxZoom)!=null?l:Bp,lu);this.layer=new Dp(s,r,s,lu,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 ra={type:"FeatureCollection",features:[]};let Up=class im extends kp{constructor(t,n,i){n.generateId=!0,super(t,n,i),this.subtype="internal",this.data=n.data,this instanceof im&&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=ra}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 kp{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 Up{constructor(t,n,i){super(t,n,i),this.subtype="viewport-internal",this.destroyed=!1,this.viewportDiffer=new Rp([{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(ra),this.viewportHandler=void 0;return}this.viewportHandler=Np(()=>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=ra;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 oa(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 zp(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 Gp(e){return e?e>=500&&e<=599:!1}function Vp(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||!Gp((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 Vp(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=oa({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=Fg(a),c=Rg(l);this.cache.set(s,l),i({metadata:c,err:o})});this.pendingRequests.set(s,{xhr:r,resolve:i})})}}class cu 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 uu(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 jp={1:uu,2:uu,4:uu,8:DE};class Hp{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&&jp[s](r),r}function aa(e,t,n){e.offset+=-e.offset&7;const i=new Uint32Array(e.buffer,e.offset,t*2);return e.offset+=8*t,n&&jp[8](i),i}function $p(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 Yp(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 aa(e,t);case 9:return aa(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 aa(e,t);case 20:return aa(e,t,!0);case 21:return $p(e,t);case 22:return $p(e,t,!0);case 23:return Yp(e,t);case 24:return Yp(e,t,!0);case 25:return ze(e,Uint32Array,t);default:throw new Error("Unknown stream type "+n)}}function du(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 ei;const fs=[],Xt=new Int32Array(256);let fu;const hu=[],Wp=[],Zp=[],pu=[0,0,0,0,0];let Xp=0,mu=0,yu=0,hs={};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:y,selectedIds:b,dataFilter:w,floorsEnabled:I,hoverId:E,generateOnlySelectedPoi:A,generateOnlyHoveredPoi:P,modelsPath:T}=s,{data:C}=r,U=new Set(b),B=Ng(C);if(B.byteLength<8)return i.getAccumulatedData();fs.length=0;const j=new Hp(B);if(j.readU32()!==1279676242)return i.getAccumulatedData();const S=j.readU16();if(S!==2&&S!==3&&S!==4)return console.error(`Unsupported tile format version: "${S}"`),i.getAccumulatedData();ei=S,j.readU16();const M=Bl(y);return kE(j),UE(j),zE(ei,e,t,h,n,i,j,p,M,U,w,o,a,I,g,v,l,E,A,P,T,c,u,d,f),i.getAccumulatedData()}function kE(e){const t=ei===4?2:1,n=e.u8;let i=e.offset,s=e.u32[i>>2];for(i+=4,Xp=s,mu=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,fu=ze(e,Uint8Array,t);const n=ze(e,Uint32Array,t);for(let i=0;i<t;i++){const s=fu[i];fs[i]=RE(e,n[i],s),Xt[i]=0}}function zE(e,t,n,i,s,r,o,a,l,c,u,d,f,h,g,v,p=!1,y,b,w,I,E,A,P,T){const C=Array.from(s.featureAttrs);Fs(d,C);const U=Xp,B=ze(o,Int32Array,U),j=du(B),z=ze(o,Uint8Array,j,!0),S=ze(o,Uint8Array,du(z),!0),M=ze(o,Uint8Array,j,!0),x=ze(o,Uint8Array,du(M),!0),L=ze(o,Uint16Array,j,!0);let _=0,F=0,O=0,k=!0;for(let R=0;R<U;R++){const V=B[R];HE(o,d,f);for(let X=0;X<V;X++){const Y=z[_];Y>0&&(GE(f,Y,S,F,d,e,p),F+=Y);const K=M[_];if(K>0&&(VE(f,K,x,O),O+=K),!f[d.tileProps.db_geometry_type]){console.error(`Geometry type not specified for data source ${g}. Metatile version ${d.version}`);return}k=Y>0||K>0;const J=d.tileProps;let N=f[J[P!=null?P:""]];Number.isNaN(N)&&(N=void 0);const Z=Ys(i,v,J,f,[],N,a),q=L[_];q>0&&jE(e,t,n,i,Z,s,r,q,a,l,c,u,d,h,g,y,b,w,I,E,k,A,T),_++}}qp()}function GE(e,t,n,i,s,r,o=!1){var a,l;for(;t--;){const c=n[i++],u=Wp[c],d=hu[c],f=fu[u];if(f===8||f===9||f===19||f===20)e[d]=T0(fs[u][Xt[u]],fs[u][Xt[u]+1]),Xt[u]+=2;else{const h=fs[u][Xt[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*Di: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 y=new Array(g);y[0]=p;for(let b=1;b<g;b++)y[b]=v.getInt32(b*Int32Array.BYTES_PER_ELEMENT,!0);e[d]=y}break;default:if(o&&f===11)e[d]=no(h);else{const y=s.tilePropsByIndex[d];e[d]=(l=(a=s.reverseDictionaries[y])==null?void 0:a[h])!=null?l:h}}Xt[u]++}}}function VE(e,t,n,i){for(;t--;){const s=n[i++],r=hu[s];e[r]=NaN}}let la=[];function jE(e,t,n,i,s,r,o,a,l,c,u,d,f,h,g,v,p,y,b,w=[],I,E,A){var x;const{tileProps:P,defaultProps:T}=f,{tileAttrs:C,featureAttrs:U,id:B}=s,j=l.coords[3],z=P.db_hidden_by_plan_id!==void 0;if(!I&&la.length===0){for(let L=0;L<yu;L++){const _=pu[L];Xt[_]=Xt[_]+a}return}const S=C[P.db_geometry_type],M=ei===4?f.vertexProps:f.vertexPropsLegacy[S];if(!M){console.error(`Couldn't get vertex keys for tile ${Le(l.coords)} source ${g}. Metatile version ${f.version}`);return}for(let L=0;L<yu;L++){const _=ei===4?Zp[L]:L,F=pu[L],O=(x=M[_])!=null?x:"signed_z";hs[O]=$E(NE(fs[F],Xt[F],a),L,e),ei===4&&O==="z"&&(hs.signed_z=hs.z),Xt[F]=Xt[F]+a}if(!(P.db_sublayer!==void 0&&!Number.isNaN(C[P.db_sublayer])&&Uo(C[P.db_sublayer]))&&!(z&&i._activeFloorIds&&C[P.db_hidden_by_plan_id]&&i._activeFloorIds.includes(C[P.db_hidden_by_plan_id]))){for(const L in T){const _=T[L];Number.isNaN(C[_.index])&&(C[_.index]=_.value)}if(!(v&&v!==B)){if(B!==void 0){let L=u.has(B);p&&(L=!0);const _=!!y||!!v&&v===B;if(C[P.selected]=L?1:0,C[P.hovered]=_?1:0,w.length>0){const F={};w.forEach(O=>{F[O]=C[P[O]]}),o.addPromotedObjectAttributes(B,F)}h&&j>=Na.detailLevel&&(C[P.db_hidden_by_plan_building_id]&&o.addFloorHidingMap(B,C[P.db_hidden_by_plan_building_id]),C[P.db_hidden_by_metro_building_id]&&o.addFloorHidingMap(B,C[P.db_hidden_by_metro_building_id]))}else C[P.selected]=0,C[P.hovered]=0;if(r.featureAttrs.size>0){const L=B!==void 0&&r.get(B);if(L)for(const _ of r.featureAttrs)r.clearAttrs=!1,U[P[_]]=L[_];else if(r.clearAttrs===!1){r.clearAttrs=!0;for(const _ in P)U[P[_]]!==void 0&&(U[P[_]]=void 0)}}if(E){const L=YE(hs,S,l);if(L){const _=WE(s,Le(l.coords));o.addFeature({type:"Feature",properties:_,geometry:L})}return}I&&(la=n.getLayers(t.id,P,C).filter(L=>H(L.filter,s)&&(d?H(d,s):!0))),la.length===0&&s.id&&o.idIndexer.addOrphanId(s.id),Vc(o,t,la,s,f,ei,j,g,l,c,hs,p||y,b,A)}}}function HE(e,t,n){const i=Object.keys(t.tileProps).length,s=e.u8;let r,o,a=mu;for(o=1;o<i;o++)n[o]=NaN;for(r=s[a++],o=0;o<r;o++)hu[o]=s[a++],Wp[o]=s[a++];for(r=s[a++],o=0;o<r;o++)ei===4&&(Zp[o]=s[a++]),pu[o]=s[a++];yu=r,mu=a,qp()}function qp(){hs={}}function $E(e,t,n){if(n===2&&t<3&&e instanceof Uint16Array)for(let i=0;i<e.length;i++)e[i]*=Di;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=re.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]/=Te*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[ot(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&&Jp(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&&Jp(n[i-2],n[i-1],o)<=0;)i--;n[i++]=o}return n.slice(0,i-1)}function Jp(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=[];zy(l,e[r],e[o],e[a],n),t.push(l)}return i&&t.push(t[0]),t}const ca=[[0],[0],[0]],Kp=[];function QE(e,t,n,i,s,r,o,a,l){const{matrix:c,offset:u,id:d,selected:f}=r,h=new Hp(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,y=[],b=Object.keys(p).length;for(let T=0;T<b;T++)y[T]=NaN;if(y[p.db_sublayer]="Building_model",y[p.selected]=f?1:0,y[p.db_region]=a,l.featureAttrs.size>0){const T=Array.from(l.featureAttrs);Fs(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 E=h.offset,A=Ys(n,ul,p,y,w,d),P=t.getLayers(e.id,p,y).filter(T=>H(T.filter,A));return P.length===0&&A.id&&i.idIndexer.addOrphanId(A.id),P.forEach(T=>{T.type!=="buildingModel"||(Gc(T,A),!H(T.filter,A))||(h.offset=E,eA(e,T,A,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=Kt(mt(),d,u),h=[];_d(h,r,u),Ni(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?um:Mr,E=s.readU16Vector();do Mn.processSubmesh(e.id,t,n,i,g,E,I,c,h);while(i.isOverloaded())}const p=s.readU16Vector();do Mn.processOuterEdge(e.id,t,n,i,g,p,h);while(i.isOverloaded());const y=qE(tA(g)),b=KE(y);for(let w=0;w<y.length-2;w++){for(let I=0;I<3;I++){const E=nA(w+I,y.length);ca[0][I]=y[E][0],ca[1][I]=y[E][1],ca[2][I]=0,Kp[I]=b[E]}do Ot.generateFloorsBottomFill(i,e.id,ca,Kp,yo,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 gu={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */gu.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)},gu.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=be,ua=gu;function be(e){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(e)?e:new Uint8Array(e||0),this.pos=0,this.type=0,this.length=this.buf.length}be.Varint=0,be.Fixed64=1,be.Bytes=2,be.Fixed32=5;var vu=65536*65536,Qp=1/vu,rA=12,e1=typeof TextDecoder>"u"?null:new TextDecoder("utf8");be.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=da(this.buf,this.pos);return this.pos+=4,e},readSFixed32:function(){var e=n1(this.buf,this.pos);return this.pos+=4,e},readFixed64:function(){var e=da(this.buf,this.pos)+da(this.buf,this.pos+4)*vu;return this.pos+=8,e},readSFixed64:function(){var e=da(this.buf,this.pos)+n1(this.buf,this.pos+4)*vu;return this.pos+=8,e},readFloat:function(){var e=ua.read(this.buf,this.pos,!0,23,4);return this.pos+=4,e},readDouble:function(){var e=ua.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&&e1?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!==be.Bytes)return e.push(this.readVarint(t));var n=Ln(this);for(e=e||[];this.pos<n;)e.push(this.readVarint(t));return e},readPackedSVarint:function(e){if(this.type!==be.Bytes)return e.push(this.readSVarint());var t=Ln(this);for(e=e||[];this.pos<t;)e.push(this.readSVarint());return e},readPackedBoolean:function(e){if(this.type!==be.Bytes)return e.push(this.readBoolean());var t=Ln(this);for(e=e||[];this.pos<t;)e.push(this.readBoolean());return e},readPackedFloat:function(e){if(this.type!==be.Bytes)return e.push(this.readFloat());var t=Ln(this);for(e=e||[];this.pos<t;)e.push(this.readFloat());return e},readPackedDouble:function(e){if(this.type!==be.Bytes)return e.push(this.readDouble());var t=Ln(this);for(e=e||[];this.pos<t;)e.push(this.readDouble());return e},readPackedFixed32:function(e){if(this.type!==be.Bytes)return e.push(this.readFixed32());var t=Ln(this);for(e=e||[];this.pos<t;)e.push(this.readFixed32());return e},readPackedSFixed32:function(e){if(this.type!==be.Bytes)return e.push(this.readSFixed32());var t=Ln(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed32());return e},readPackedFixed64:function(e){if(this.type!==be.Bytes)return e.push(this.readFixed64());var t=Ln(this);for(e=e||[];this.pos<t;)e.push(this.readFixed64());return e},readPackedSFixed64:function(e){if(this.type!==be.Bytes)return e.push(this.readSFixed64());var t=Ln(this);for(e=e||[];this.pos<t;)e.push(this.readSFixed64());return e},skip:function(e){var t=e&7;if(t===be.Varint)for(;this.buf[this.pos++]>127;);else if(t===be.Bytes)this.pos=this.readVarint()+this.pos;else if(t===be.Fixed32)this.pos+=4;else if(t===be.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),ps(this.buf,e,this.pos),this.pos+=4},writeSFixed32:function(e){this.realloc(4),ps(this.buf,e,this.pos),this.pos+=4},writeFixed64:function(e){this.realloc(8),ps(this.buf,e&-1,this.pos),ps(this.buf,Math.floor(e*Qp),this.pos+4),this.pos+=8},writeSFixed64:function(e){this.realloc(8),ps(this.buf,e&-1,this.pos),ps(this.buf,Math.floor(e*Qp),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&&t1(t,n,this),this.pos=t-1,this.writeVarint(n),this.pos+=n},writeFloat:function(e){this.realloc(4),ua.write(this.buf,e,this.pos,!0,23,4),this.pos+=4},writeDouble:function(e){this.realloc(8),ua.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&&t1(n,i,this),this.pos=n-1,this.writeVarint(i),this.pos+=i},writeMessage:function(e,t,n){this.writeTag(e,be.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,be.Bytes),this.writeBytes(t)},writeFixed32Field:function(e,t){this.writeTag(e,be.Fixed32),this.writeFixed32(t)},writeSFixed32Field:function(e,t){this.writeTag(e,be.Fixed32),this.writeSFixed32(t)},writeFixed64Field:function(e,t){this.writeTag(e,be.Fixed64),this.writeFixed64(t)},writeSFixed64Field:function(e,t){this.writeTag(e,be.Fixed64),this.writeSFixed64(t)},writeVarintField:function(e,t){this.writeTag(e,be.Varint),this.writeVarint(t)},writeSVarintField:function(e,t){this.writeTag(e,be.Varint),this.writeSVarint(t)},writeStringField:function(e,t){this.writeTag(e,be.Bytes),this.writeString(t)},writeFloatField:function(e,t){this.writeTag(e,be.Fixed32),this.writeFloat(t)},writeDoubleField:function(e,t){this.writeTag(e,be.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 Ln(e){return e.type===be.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 t1(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 da(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16)+e[t+3]*16777216}function ps(e,t,n){e[n]=t,e[n+1]=t>>>8,e[n+2]=t>>>16,e[n+3]=t>>>24}function n1(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 e1.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,wu={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]=bu(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]]=bu(e,s&7)}return i},6:e=>null};function bu(e,t){const n=e.pbf;if(n.pos<n.length){const i=wu[t];if(!i)throw new Error(`Type ${t} is not supported`);return i(e)}}function i1(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 bu({keys:u,pbf:n},d);case 2:{const f={keys:[],pbf:n},h=n.readFixed32(),g=i1(n),v={};for(const{key:p,type:y}of g){const b=wu[y],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=i1(n),v=new Array(h);for(let p=0;p<h;p++)v[p]={};for(const{key:p,type:y}of g){const b=wu[y];for(let w=0;w<h;w++)v[w][p]=b(f)}return v}default:throw new Error(`Method ${o} is not supported`)}}function s1(e){const t=new cu;if(e instanceof ArrayBuffer){const s=EA(e);if(Array.isArray(s))for(const n of s){const i=n,{id:r}=i,o=nm(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 cu}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(y=>{var A;const{regionId:b,metatileHash:w}=y,I=this.scope.styleManager.getStyle(t.styleId);if(!I)return;if(t.areTileBoundsVisible&&t.isDefaultSource){const T=i.getStyle(qo).layers.find(C=>C.id==="debug-tile-bounds");W0(s,T,t.styleState)}const E=BE(I,i,this.featureStateMap,s,t,y,r[w],this.tileAttrs,c,a,n,l,u);Object.assign(p,E.promotedObjectAttributes),h.push({regionId:b,metatileHash:w,collectorOutput:E,styleId:I.id}),v.push(...E.transferable),(A=E.debugGeoJsonData)==null||A.forEach(P=>g.push(P))}),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=s1(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=>{oa({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 y=new Blob([p],{type:"image/png"});return createImageBitmap(y)});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 fa=.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*fa}extend(){const t=this.buffer.byteLength*2;this.maximum=t/this.stride,this.watermark=this.maximum*fa;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*fa}extend(){const t=this.buffer.length*2;this.watermark=t*fa;const n=new Int32Array(t);n.set(this.buffer),this.buffer=n}}class r1{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 Iu(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 Iu(e,t,n){this.x=0,this.y=e,this.w=this.free=t,this.h=n}Iu.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)},Iu.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(cn[0],cn[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(cn[0],cn[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===Ti.Static)continue;const a=o.w*i,l=o.h*i;let c=or(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(cn[0],cn[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=oe(2,32)-2,OA=Ed(oe(2,32)-1),FA=Ed(oe(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 o1=oe(2,20),a1=["main","parser","labeling","models"],Mu={};for(let e=0;e<a1.length;e++){const t=a1[e];Mu[t]={min:1+e*o1,max:(e+1)*o1}}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 sI(t),this.workerName=t,this.dataModelsIndex=Mu[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}=Mu[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=r1.generateKey(i),c=a[l];if(c)return this.addedBuckets.push(c),c;const u=new r1(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,y=g[p],b=hr(h,p)/4;let w=0;for(const P in y)w+=y[P].indices.offset;if(w===0)continue;const I=[],E=new Int32Array(w*b);let A=0;for(const P in y){const T=y[P],{elements:C,indices:U,attributes:B,meta:j,objectsData:z,extents:S,maxDiag:M}=T,{view:x}=C,{buffer:L}=U;if(C.offset===0)continue;const _=A,F={};for(let O=0;O<U.offset;O++){const k=z?z[O]:null;if(k){const V=A/b;BA(k,V,F)}const R=L[O]*b;for(let V=0;V<b;V++)E[A++]=x[R+V]}I.push({attributes:B,drawMode:T.drawMode,rangeStart:_*4,rangeEnd:A*4,meta:j,objectsData:Object.keys(F).length>0?F:void 0,extents:new Float32Array(S),maxDiag:M}),T.resetOffsets(),T.resetBuildingsData(),T.resetInstancesExtents(),T.meta=void 0}n.push({symbol:h,sink:p,buffer:E.buffer,generatedObjects:I}),i.push(E.buffer)}}const s=this.idIndexer.getPacked();i.push(s.centerBuffer),i.push(s.instanceIdBuffer),i.push(s.layerIdBuffer),i.push(s.objectClassBuffer),i.push(s.phaseBuffer),i.push(s.styleIdBuffer),i.push(s.sublayerBuffer);const r=this.atlasPacker.getPackedRasters();r!==void 0&&i.push(r.buffer);const o=this.atlasPacker.getRastersToLoad();i.push(o.buffer);const a=this.getDataModelsUrls();this.usedModels=new Set;const 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 Tu{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||!Gp((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 Vp(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"?zp:oa)({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 l1=Symbol("Comlink.proxy"),zA=Symbol("Comlink.endpoint"),GA=Symbol("Comlink.releaseProxy"),Su=Symbol("Comlink.finalizer"),ha=Symbol("Comlink.thrown"),c1=e=>typeof e=="object"&&e!==null||typeof e=="function",VA={canHandle:e=>c1(e)&&e[l1],serialize(e){const{port1:t,port2:n}=new MessageChannel;return Eu(e,t),[n,[n]]},deserialize(e){return e.start(),f1(e)}},jA={canHandle:e=>c1(e)&&ha 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}},u1=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 Eu(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(Pi);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]]=Pi(s.data.value),c=!0;break;case"APPLY":c=d.apply(u,l);break;case"CONSTRUCT":{const f=new d(...l);c=g1(f)}break;case"ENDPOINT":{const{port1:f,port2:h}=new MessageChannel;Eu(e,h),c=y1(f,[f])}break;case"RELEASE":c=void 0;break;default:return}}catch(u){c={value:u,[ha]:0}}Promise.resolve(c).catch(u=>({value:u,[ha]:0})).then(u=>{const[d,f]=ga(u);t.postMessage(Object.assign(Object.assign({},d),{id:r}),f),o==="RELEASE"&&(t.removeEventListener("message",i),d1(t),Su in e&&typeof e[Su]=="function"&&e[Su]())}).catch(u=>{const[d,f]=ga({value:new TypeError("Unserializable return value"),[ha]:0});t.postMessage(Object.assign(Object.assign({},d),{id:r}),f)})}),t.start&&t.start()}function $A(e){return e.constructor.name==="MessagePort"}function d1(e){$A(e)&&e.close()}function f1(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)}}),Au(e,n,[],t)}function pa(e){if(e)throw new Error("Proxy has been released and is not useable")}function h1(e){return ms(e,new Map,{type:"RELEASE"}).then(()=>{d1(e)})}const ma=new WeakMap,ya="FinalizationRegistry"in globalThis&&new FinalizationRegistry(e=>{const t=(ma.get(e)||0)-1;ma.set(e,t),t===0&&h1(e)});function YA(e,t){const n=(ma.get(t)||0)+1;ma.set(t,n),ya&&ya.register(e,t,e)}function WA(e){ya&&ya.unregister(e)}function Au(e,t,n=[],i=function(){}){let s=!1;const r=new Proxy(i,{get(o,a){if(pa(s),a===GA)return()=>{WA(r),h1(e),t.clear(),s=!0};if(a==="then"){if(n.length===0)return{then:()=>r};const l=ms(e,t,{type:"GET",path:n.map(c=>c.toString())}).then(Pi);return l.then.bind(l)}return Au(e,t,[...n,a])},set(o,a,l){pa(s);const[c,u]=ga(l);return ms(e,t,{type:"SET",path:[...n,a].map(d=>d.toString()),value:c},u).then(Pi)},apply(o,a,l){pa(s);const c=n[n.length-1];if(c===zA)return ms(e,t,{type:"ENDPOINT"}).then(Pi);if(c==="bind")return Au(e,t,n.slice(0,-1));const[u,d]=p1(l);return ms(e,t,{type:"APPLY",path:n.map(f=>f.toString()),argumentList:u},d).then(Pi)},construct(o,a){pa(s);const[l,c]=p1(a);return ms(e,t,{type:"CONSTRUCT",path:n.map(u=>u.toString()),argumentList:l},c).then(Pi)}});return YA(r,e),r}function ZA(e){return Array.prototype.concat.apply([],e)}function p1(e){const t=e.map(ga);return[t.map(n=>n[0]),ZA(t.map(n=>n[1]))]}const m1=new WeakMap;function y1(e,t){return m1.set(e,t),e}function g1(e){return Object.assign(e,{[l1]:!0})}function ga(e){for(const[t,n]of u1)if(n.canHandle(e)){const[i,s]=n.serialize(e);return[{type:"HANDLER",name:t,value:i},s]}return[{type:"RAW",value:e},m1.get(e)||[]]}function Pi(e){switch(e.type){case"HANDLER":return u1.get(e.name).deserialize(e.value);case"RAW":return e.value}}function ms(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 ti=(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))(ti||{}),gr=(e=>(e[e.FunctionUse=0]="FunctionUse",e[e.FunctionResult=1]="FunctionResult",e))(gr||{});class qA extends fl{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:ti.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:ti.Main,msg:t};n.postMessage(s)})}routeMessage(t){const{from:n,to:i,transferable:s,msg:{type:r}}=t;if(i===ti.Main)this.emit("message",t);else if(i===ti.All)n!==ti.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 fl{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:ti.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)&&v1(a[0]))for(let l=0;l<a.length;l++)Promise.resolve(a[l]).then(c=>{this.sendFunctionResult(n,r,c,l)});else a&&v1(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 v1(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},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 xu(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 w1(e,t){const n=xu([e[0][0],e[1][0]],t),i=xu([e[0][1],e[1][1]],t),s=xu([e[0][2],e[1][2]],t);n.forEach(r=>i.forEach(o=>s.forEach(a=>{ix(e,r,o,a)})))}function b1(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 _u(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&&_u(e,t,c,i,s),e[c+2]=o,n-c>r&&_u(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")va(o,n,r);else if(t==="Polygon")va(o,n[0],r);else if(t==="MultiLineString")for(const a of n)va(o,a,r);else if(t==="MultiPolygon")for(const a of n)va(o,a[0],r);return o}function va(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++)wa(n,e.features[i],t,i);else e.type==="Feature"?wa(n,e,t,0):wa(n,{geometry:e},t,0);return n}function wa(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")I1(s,a,n.dimensions);else if(r==="MultiPoint")for(const c of s)I1(c,a,n.dimensions);else if(r==="LineString")Pu(s,a,o,!1,n.dimensions);else if(r==="MultiLineString")if(n.lineMetrics){for(const c of s)a=[],Pu(c,a,o,!1,n.dimensions),e.push(vr(l,"LineString",a,t.properties,i,n.dimensions+2));return}else Lu(s,a,o,!1,n.dimensions);else if(r==="Polygon")Lu(s,a,o,!0,n.dimensions);else if(r==="MultiPolygon")for(const c of s){const u=[];Lu(c,u,o,!0,n.dimensions),a.push(u)}else if(r==="GeometryCollection"){for(const c of t.geometry.geometries)wa(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 I1(e,t,n=2){t.push(M1(e[0]),T1(e[1]),0,1);for(let i=2;i<n;i++)t.push(e[i])}function Pu(e,t,n,i,s=2){let r,o,a=0;for(let c=0;c<e.length;c++){const u=M1(e[c][0]),d=T1(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,_u(t,0,l,n,s),t[l+2]=1,t.size=Math.abs(a),t.start=0,t.end=t.size}function Lu(e,t,n,i,s=2){for(let r=0;r<e.length;r++){const o=[];Pu(e[r],o,n,i,s),t.push(o)}}function M1(e){return e/360+.5}function T1(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 Cn(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")S1(d,v,n,i,s,!1,a.lineMetrics,l);else if(f==="MultiLineString")Cu(d,v,n,i,s,!1,l);else if(f==="Polygon")Cu(d,v,n,i,s,!0,l);else if(f==="MultiPolygon")for(const p of d){const y=[];Cu(p,y,n,i,s,!0,l),y.length&&v.push(y)}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){ys(t,e[o],e[o+1],e[o+2]);for(let l=3;l<r;l++)t.push(e[o+l])}}}function S1(e,t,n,i,s,r,o,a=4){let l=E1(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],E=e[b+2],A=e[b+a],P=e[b+a+1],T=s===0?w:I,C=s===0?A:P;let U=!1;if(o&&(d=Math.sqrt(Math.pow(w-A,2)+Math.pow(I-P,2))),T<n){if(C>n){f=c(l,w,I,A,P,n),l.push(0);for(let B=4;B<a;B++){const j=e[b+B];l.push((e[b+a+B]-j)*f+j)}o&&(l.start=u+d*f)}}else if(T>i){if(C<i){f=c(l,w,I,A,P,i),l.push(0);for(let B=4;B<a;B++){const j=e[b+B];l.push((e[b+a+B]-j)*f+j)}o&&(l.start=u+d*f)}}else{ys(l,w,I,E);for(let B=3;B<a;B++)l.push(e[b+B])}if(C<n&&T>=n){f=c(l,w,I,A,P,n),l.push(0);for(let B=4;B<a;B++){const j=e[b+B];l.push((e[b+a+B]-j)*f+j)}U=!0}if(C>i&&T<=i){f=c(l,w,I,A,P,i),l.push(0);for(let B=4;B<a;B++){const j=e[b+B];l.push((e[b+a+B]-j)*f+j)}U=!0}!r&&U&&(o&&(l.end=u+d*f),t.push(l),l=E1(e)),o&&(u+=d)}let h=e.length-a;const g=e[h],v=e[h+1],p=e[h+2],y=s===0?g:v;if(y>=n&&y<=i){ys(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])){ys(l,l[0],l[1],l[2]);for(let b=3;b<a;b++)l.push(l[b])}l.length&&t.push(l)}function E1(e){const t=[];return t.size=e.size,t.start=e.start,t.end=e.end,t}function Cu(e,t,n,i,s,r,o){for(const a of e)S1(a,t,n,i,s,r,!1,o)}function ys(e,t,n,i){e.push(t,n,i)}function ax(e,t,n,i,s,r){const o=(r-t)/(i-t);return ys(e,r,n+(s-n)*o,1),o}function lx(e,t,n,i,s,r){const o=(r-n)/(s-n);return ys(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=Cn(e,1,-1-n,n,0,-1,2,t),o=Cn(e,1,1-n,2+n,0,-1,2,t);return(r||o)&&(s=Cn(e,1,-n,1+n,0,-1,2,t)||[],r&&(s=A1(r,1,i).concat(s)),o&&(s=s.concat(A1(o,-1,i)))),s}function A1(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=Du(r.geometry,t,n);else if(o==="MultiLineString"||o==="Polygon"){a=[];for(const l of r.geometry)a.push(Du(l,t,n))}else if(o==="MultiPolygon"){a=[];for(const l of r.geometry){const c=[];for(const u of l)c.push(Du(u,t,n));a.push(c)}}i.push(vr(r.id,o,a,r.tags,r.index,n))}return i}function Du(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 x1(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(P1(a,d,u,t,i,s,r));else if(l===2)o.geometry=_1(a,t,i,s,r,u);else for(let d=0;d<a.length;d++)o.geometry.push(_1(a[d],t,i,s,r,u))}return e.transformed=!0,e}function _1(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(P1(e[a],c,r,t,n,i,s));o.push(l)}return o}function P1(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")Ou(a,s,e,n,!1,!1,i);else if(r==="MultiLineString"||r==="Polygon"){for(let l=0;l<s.length;l++)Ou(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++)Ou(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 Ou(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=Fu(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,y=1+g;let b=null,w=null,I=null,E=null,A=Cn(t,d,i-g,i+p,0,h.minX,h.maxX,c),P=Cn(t,d,i+v,i+y,0,h.minX,h.maxX,c);t=null,A&&(b=Cn(A,d,s-g,s+p,1,h.minY,h.maxY,c),w=Cn(A,d,s+v,s+y,1,h.minY,h.maxY,c),A=null),P&&(I=Cn(P,d,s-g,s+p,1,h.minY,h.maxY,c),E=Cn(P,d,s+v,s+y,1,h.minY,h.maxY,c),P=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(E||[],n+1,i*2+1,s*2+1)}}getTile(t,n,i){t=+t,n=+n,i=+i;const s=this.options,{extent:r,debug:o}=s;if(t<0||t>24)return null;const a=1<<t;n=n+a&a-1;const l=Fu(t,n,i);if(this.tiles[l])return x1(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[Fu(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]?x1(this.tiles[l],r,s):null)}}function Fu(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=re.scaleFactor(Ns(0,0,t)[1]),i=re.scaleFactor(Ns(0,ee,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++)Ru(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,y)=>{v[0][y]=p[0],v[1][y]=p[1]}),w1(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)=>{Ru(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;Ru(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 Ru(e,t,n,i){const s=L1(t,n);e[0]=s[0],e[1]=s[1];const r=i.min+s[1]/ee*i.range;t[2]===void 0||isNaN(t[2])?e[2]=0:e[2]=t[2]*Te*r,t[3]!==void 0&&(e[3]=t[3]*Te*r)}function L1(e,t){return[xe(e[0]/t*ee,0,ee),xe((t-e[1])/t*ee,0,ee)]}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(L1(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 C1=4096,D1=2,gs={maxZoom:Bp,tolerance:3,extent:C1,buffer:1,debug:0,lineMetrics:!1,promoteId:null,generateId:!1,generateIndex:!0,indexMaxZoom:0,indexMaxPoints:1e5,dimensions:D1};class Nu{constructor(t){this.options=t}get geoJsonVtInstance(){var t,n,i,s,r;return this.geoJsonVT||(this.geoJsonVT=yx(this.options.data,Ie(de({},gs),{maxZoom:(t=this.options.maxZoom)!=null?t:gs.maxZoom,dimensions:(n=this.options.dimensions)!=null?n:gs.dimensions,extent:(i=this.options.extent)!=null?i:gs.extent,buffer:(s=this.options.buffer)!=null?s:gs.buffer,promoteId:this.options.promoteId,tolerance:(r=this.options.tolerance)!=null?r:gs.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:D1,l=(d=this.options.extent)!=null?d:C1,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(...O1(s.geometry,t).map(o=>Ie(de({},o),{index:r,id:s.id,tags:s.properties||{}})))}),i}function O1(e,t,n){switch(e.type){case"GeometryCollection":{let i=[];return e.geometries.forEach(s=>{i=i.concat(O1(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"?[F1(e.coordinates,t)]:e.coordinates.map(n=>F1(n,t))}function Ax(e,t){return e.type==="LineString"?[R1(e.coordinates,t)]:e.coordinates.map(n=>R1(n,t))}function xx(e,t,n){return e.type==="Polygon"?N1(e.coordinates,t):e.coordinates.reduce((i,s)=>i.concat(N1(s,t)),[])}function F1(e,t){const n=[0,0,0];return Lt(n,re.fromGeo(e),t),{type:"point",vertices:{x:[n[0]],y:[n[1]]}}}function R1(e,t){const n=[[],[]],i=[0,0,0];return e.forEach((s,r)=>{Lt(i,re.fromGeo(s),t),n[0][r]=i[0],n[1][r]=i[1]}),{type:"line",vertices:{x:n[0],y:n[1]}}}function N1(e,t,n){const i=[],s=[],r=[],o=[],a=[];e.forEach(u=>{const d=u.map(f=>(Lt(a,re.fromGeo(f),t),[xe(a[0],0,ee),xe(a[1],0,ee)]));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]}),w1(d,g)});const f={type:"polygon",vertices:{x:d[0],y:d[1],cut:d[2]}};i.push(f)}return i}class ba{constructor(t){this.tileLoader=new Tu("json",t.ignoreMissingTiles),this.options=t,this.url=n=>{const i=this.options.flipY?n:Wr(n);return Os(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 B1=4;class _x{constructor(t,n,i,s){this.scope=t,this.options=n,this.id=i,this.featureStateMap=new cu,t.sources[i]=this,this.tileData={},this.styleManager=t.styleManager,this.collector=t.collector,this.sourceAttrs=this.options.attributes||{},this.metatile=b1(s),this.tileServer="url"in n?new ba(n):new Nu(n)}fetchTiles(t){const n=[];for(const i of t)n.push(this.fetchTile(i));return n}abortTileFetches(t){if(this.tileServer instanceof ba)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,y={},b="generateId"in this.options?this.options.generateId:!1;if(!g)return Promise.resolve({results:f,transferable:h});u&&u.components.forEach((A,P)=>{const{tileProps:T}=this.metatile,C=[],U=[];if(A.tags){const O=Object.keys(A.tags);Fs(this.metatile,O);for(const k of O)C[T[k]]=A.tags[k]}const B=Object.keys(this.sourceAttrs);Fs(this.metatile,B);const j=Array.from(this.featureStateMap.featureAttrs);Fs(this.metatile,j);for(const O of B)C[T[O]]=this.sourceAttrs[O];const z=C[T.db_hidden_by_plan_id];if(z&&t._activeFloorIds.includes(z))return;const S=b?String(A.index+this.id*oe(2,32)):p?C[T[p]]:void 0;if(S!==void 0){const O=v.has(S);if(C[T.selected]=O?1:0,u.byId.set(S,P),y[S]=A.index,this.featureStateMap.featureAttrs.size>0){const k=S!==void 0&&this.featureStateMap.get(S);if(k)for(const R of this.featureStateMap.featureAttrs)this.featureStateMap.clearAttrs=!1,U[T[R]]=k[R];else if(this.featureStateMap.clearAttrs===!1){this.featureStateMap.clearAttrs=!0;for(const R in T)U[T[R]]!==void 0&&(U[T[R]]=void 0)}}}const{coords:M}=d,x=M[3],L=Bl(r),_=Ys(t,this.sourceAttrs,T,C,U,S,d),F=this.styleManager.getLayers(g.id,T,C).filter(O=>tx(A.type,O.type)&&H(O.filter,_)&&(a?H(a,_):!0));if(F.length===0&&_.id&&this.collector.idIndexer.addOrphanId(_.id),C[T.db_geometry_type]=A.type==="line"?"polyline":A.type,(A.type==="point"||A.type==="line")&&(C[T.db_label]===void 0&&(C[T.db_label]=NaN),C[T.db_label2]===void 0&&(C[T.db_label2]=NaN)),A.type==="line"){const O=nx(A);C[T.componentDistanceStart]=0,C[T.componentDistanceEnd]=O,C[T.objectLength]=O,typeof C[T.beginningIsCut]!="number"&&(C[T.beginningIsCut]=0),typeof C[T.endingIsCut]!="number"&&(C[T.endingIsCut]=0)}Vc(this.collector,g,F,_,this.metatile,B1,x,this.id,d,L,A.vertices,void 0,o,l)});const w=this.collector.getAccumulatedData(),I={regionId:0,metatileHash:Yu,collectorOutput:w,styleId:g.id};Object.keys(y).length>0&&(I.idToIndex=y),f.push(I),h.push(...w.transferable),this.scope.debouncedResetCollector(),this.scope.syncNewRasterSets();const E={results:f,transferable:h};return Promise.resolve(E)}getObjectAttributes(t,n){const i=this.tileData[n];if(i){const s=i.byId.get(t);if(s===void 0)return;const r=i.components[s];return r===void 0?void 0:r.tags}}deleteTiles(t){for(const n of t)delete this.tileData[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=s1(t)}setData(t){if(typeof t=="string"){if(this.tileServer instanceof ba)return this.tileServer.destroy(),this.options=Ie(de({},this.options),{url:t}),this.tileServer=new ba(this.options),this.tileData={},Promise.resolve(!0)}else if(this.tileServer instanceof Nu)return this.tileServer.destroy(),this.options=Ie(de({},this.options),{data:t}),this.tileServer=new Nu(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?xm(...t.matrix):void 0,rotation:ry(...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 k1(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 U1(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 He=class He{constructor(t){this.data=t}static isGlb(t){const n=new Uint32Array(t,0,He.glbHeaderInts),i=n[0],s=n[1];return i===this.glbMagic&&s===this.glbVersion}extractGlbData(){if(this.getCheckedGlbInfo()===void 0)return{json:Uu,buffers:[]};let n;const i=[],s=this.getAllChunkInfos();for(const r of s)r.type===He.jsonChunkType&&!n?n=this.getJsonFromChunk(r):r.type===He.binaryChunkType&&i.push(this.getBufferFromChunk(r));return{json:n||Uu,buffers:i}}getCheckedGlbInfo(){const t=new Uint32Array(this.data,0,He.glbHeaderInts),n=t[0],i=t[1],s=t[2];if(!(!this.checkEquality(n,He.glbMagic,"glb magic")||!this.checkEquality(i,He.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=He.glbHeaderInts*4;for(;n<this.data.byteLength;){const i=this.getChunkInfo(n);t.push(i),n+=i.length+He.glbChunkHeaderInts*4}return t}getChunkInfo(t){const n=new Uint32Array(this.data,t,He.glbChunkHeaderInts),i=t+He.glbChunkHeaderInts*4,s=n[0],r=n[1];return{start:i,length:s,type:r}}getJsonFromChunk(t){const n=t.length,i=(He.glbHeaderInts+He.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)}};He.glbHeaderInts=3,He.glbChunkHeaderInts=2,He.glbMagic=1179937895,He.glbVersion=2,He.jsonChunkType=1313821514,He.binaryChunkType=5130562;let Ia=He;const z1=5120,$x=5121,Yx=5122,Wx=5123,Zx=5124,G1=5125,Xx=5126,qx=4,Jx="draco_decoder_gltf.js",Kx="draco_wasm_wrapper_gltf.js",V1="draco_decoder_gltf.wasm";let Bu;function Qx(e){Bu=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}/${V1}`).then(i=>i.arrayBuffer()).then(i=>n({wasmBinary:i,wasmBinaryFile:V1}))})})}function i_(e){switch(e){case z1:return"Int8Array";case $x:return"Uint8Array";case Yx:return"Int16Array";case Wx:return"Uint16Array";case Zx:return"Int32Array";case G1: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=z1,h;for(const[p,y]of Object.entries(r))if(p===d){f=s.accessors[y].componentType,h=s.accessors[y].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 an(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 Dn(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&&(an(s,e,i,34963,"index buffer view"),e.accessors[i].componentType=G1),t.attributes.POSITION!==void 0){const r=Dn(t.attributes.POSITION.array,t.attributes.POSITION.componentType);an(r,e,n.POSITION,34962,"position buffer view")}if(t.attributes.NORMAL!==void 0){const r=Dn(t.attributes.NORMAL.array,t.attributes.NORMAL.componentType);an(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=Dn(t.attributes[o].array,t.attributes[o].componentType);an(a,e,n[o],34962,`${o} buffer view`)}}if(t.attributes.TANGENT!==void 0){const r=Dn(t.attributes.TANGENT.array,t.attributes.TANGENT.componentType);an(r,e,n.TANGENT,34962,"Tangent buffer view")}if(t.attributes.COLOR_0!==void 0){const r=Dn(t.attributes.COLOR_0.array,t.attributes.COLOR_0.componentType);an(r,e,n.COLOR_0,34962,"color buffer view")}if(t.attributes.JOINTS_0!==void 0){const r=Dn(t.attributes.JOINTS_0.array,t.attributes.JOINTS_0.componentType);an(r,e,n.JOINTS_0,34963,"JOINTS_0 buffer view")}if(t.attributes.WEIGHTS_0!==void 0){const r=Dn(t.attributes.WEIGHTS_0.array,t.attributes.WEIGHTS_0.componentType);an(r,e,n.WEIGHTS_0,34963,"WEIGHTS_0 buffer view")}if(t.attributes.JOINTS_1!==void 0){const r=Dn(t.attributes.JOINTS_1.array,t.attributes.JOINTS_1.componentType);an(r,e,n.JOINTS_1,34963,"JOINTS_1 buffer view")}if(t.attributes.WEIGHTS_1!==void 0){const r=Dn(t.attributes.WEIGHTS_1.array,t.attributes.WEIGHTS_1.componentType);an(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;Bu||Qx(t);const r=yield Bu;if(!r)continue;const o=o_(s.extensions.KHR_draco_mesh_compression,e,r,s.attributes);a_(e,o,s.attributes,s.indices)}})}function ku(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 Uu={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=U1(n.uri);else{const i=xn(n.uri)?n.uri:k1(e.path)+n.uri,s=yield ku(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=U1(t.uri);t.image=yield createImageBitmap(new Blob([i],{type:n}))}else{const i=xn(t.uri)?t.uri:`${k1(e.path)}${t.uri}`,r=yield(yield ku(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=$y(e,self.origin);try{const i=yield ku(n);let s=Uu,r;try{const o=yield i.arrayBuffer();if(Ia.isGlb(o)){const f=new Ia(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 Tu("arrayBuffer"),this.tiles=new Map,this.url=i=>{const[s,r,o]=Wr(i);return mh(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=Y2(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=j2(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,zu=2048*1024;var Ma=(e=>(e[e.Magic=0]="Magic",e[e.Version=4]="Version",e[e.FrameMailbox=8]="FrameMailbox",e[e._Size=16]="_Size",e))(Ma||{});const b_=16+w_*zu;var Gu=(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))(Gu||{});function I_(e){e[0]=g_,e[1]=v_,e[2]=0}function j1(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 H1=(e=>(e[e.WebGPU=0]="WebGPU",e))(H1||{}),Vu=(e=>(e[e.WebGPU=0]="WebGPU",e))(Vu||{}),Ta=(e=>(e[e.Test=0]="Test",e))(Ta||{}),Li=(e=>(e[e.Vertex=0]="Vertex",e[e.Fragment=1]="Fragment",e))(Li||{});function $1(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
}
`,Y1=new WeakMap;function W1(e){let t=Y1.get(e);return t||(t=new Map,Y1.set(e,t)),t}const S_={[Ta.Test]:{[Li.Vertex]:M_,[Li.Fragment]:T_}};function Z1(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 X1(e,t,n){return e.createShaderModule({label:n,code:t})}function E_(e,t,n={}){const i=W1(e),s=$1(t,Li.Vertex,n);let r=i.get(s);if(!r){const o=Z1(t,Li.Vertex);r=X1(e,o,`${t} vertex shader`),i.set(s,r)}return r}function A_(e,t,n={}){const i=W1(e),s=$1(t,Li.Fragment,n);let r=i.get(s);if(!r){const o=Z1(t,Li.Fragment);r=X1(e,o,`${t} fragment shader`),i.set(s,r)}return r}class x_{}class __ extends x_{constructor(){super(...arguments),this.renderFamily=H1.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,Ta.Test),entryPoint:"main"},fragment:{module:A_(s,Ta.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=j1(this.transportI32,Ma.FrameMailbox,this.frameReadSlot);const s=Ma._Size+this.frameReadSlot*zu,r=this.transportU32[s+Gu.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 Vu.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 q1(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 q1(e,t,n);return g1(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,Sa=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=Fl(t.id);break;case 2:t.bitmap=n.readBytes();break;case 3:t.width=n.readVarint()+Sa;break;case 4:t.height=n.readVarint()+Sa;break;case 5:t.left=n.readSVarint()-Sa/2;break;case 6:t.top=n.readSVarint()+O_+Sa/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=ct(e,t);if(i!=="")return n.fontNameToIndex[i]===void 0?Oi: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:Md(n.w),height:Md(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}}m.processRTLTextIfNeeded=e=>e,m.markAsReady=null,m.rtlAdapterReady=!1;const X_=new Promise(e=>{m.markAsReady=()=>{m.rtlAdapterReady=!0,e()}}),q_=new Set(["ar"]);function J1(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(()=>{m.markAsReady!==null&&m.markAsReady()})}return J1(e.scenario,n)?fetch(e.url,{integrity:e.hash}).then(r=>r.text()).then(r=>Promise.all([i.loadRtlPlugin(r),Promise.resolve(K1(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 K1=Z_(function(e){new Function(e)(),m.processRTLTextIfNeeded=self.mapglRtlPlugin.processRtl,m.markAsReady&&m.markAsReady()});function K_(e){return typeof e=="object"&&!!e&&"message"in e}m.ArrowGenerator=nr,m.BBoxType=Rt,m.BLEND_EQUATION=oT,m.BLEND_FUNC=rT,m.BaseTileLoader=Tu,m.Buffer=Xe,m.BufferChannel=L0,m.BuildingModelGenerator=Mn,m.CULL_FACE_MODE=sT,m.Camera=Ps,m.CircleMarkerGenerator=vo,m.ClassRegistry=QA,m.Collector=NA,m.DEFAULT_EMPTY_KEY=Zu,m.DEFAULT_FONT=Oi,m.DEFAULT_FRAME_SIZE=zu,m.DEFAULT_ID_SCOPE=jc,m.DEFAULT_LIGHTING_MODES=kA,m.DEFAULT_MAPGL_STYLE=cm,m.DEFAULT_MIN_TIERS_STYLE_ZOOM=bd,m.DEFAULT_MODELS_APPEAR_STRATEGY=Wu,m.DEM_ELEVATION_TILE_SIZE=V2,m.DEM_STYLE_LAYER_ID=Xs,m.DEM_TILE_URL_FUNCTION=mh,m.DEM_TREE_SIZE=ph,m.DEPTH_FUNC=O0,m.DYNAMIC_MODEL_ID_SCOPE=VM,m.DYNAMIC_STYLE_ID=qo,m.DashedLineGenerator=In,m.DemGenerator=Ot,m.Differ=Rp,m.DynamicStyle=jT,m.EARTH_CIRCUMFERENCE=Xa,m.EMPTY_FEATURE_COLLECTION=ra,m.EMPTY_SHADER_DEFINITIONS=Zc,m.ENVIRONMENT_STYLE_LAYER_ID=$l,m.Ecef=lt,m.EcefDataState=ea,m.Evented=fl,m.FLOOR_ID_SCOPE=GM,m.FnRegistry=KA,m.FrameHeader=Gu,m.GEOJSON_DEFAULT_MAX_DETAIL_LEVEL=lu,m.GL_TRIANGLES=Mr,m.GeoJsonSource=Up,m.GeoJsonSourceCore=Op,m.GeoJsonSourceWorker=_x,m.GeoJsonTileSource=PE,m.GeoJsonViewportSource=LE,m.GltfDemPosition=a0,m.GltfModelGenerator=Jn,m.HALF_WORLD_SIZE=2147483648,m.HandyIndexer=Hc,m.HeatmapGenerator=Si,m.HideLevel=us,m.INVALID_FRAMEBUFFER_ID=io,m.INVALID_IDENTIFY_CENTER_COORD=_a,m.IdScope=jM,m.LABELING_TEXTURE_BACKGROUND_COLOR=OA,m.LABELING_TEXTURE_DEM_MESH_COLOR=FA,m.LATEST_TILE_VERSION=B1,m.LRU=mp,m.LabelGeometryType=Ii,m.LabelIndex=Ec,m.LabelSource=sr,m.LabelingAnimation=A0,m.LabelingElementType=We,m.LabelingTileElement=Eo,m.LengthUnits=Hn,m.LineExtrusionGenerator=Tn,m.LineGenerator=ut,m.LinePatternType=Uc,m.MAP_DEFAULTS=La,m.MAP_MESH_TEXTURE_INDEX=eg,m.MAP_POINTS_IN_METER=Te,m.MODELS_TILES_VIEWPORT_PADDING=dm,m.MainConnector=qA,m.MapMeshGenerator=cs,m.Mercator=re,m.MeshElevationWorker=y_,m.MeshFillSide=ne,m.MeshGenerator=Q,m.ModelStepSource=Ei,m.ModelsWorker=m_,m.PBR_TEXTURE_INDEX=Qy,m.POINT_CENTER_SIZE=Pa,m.PolygonExtrusionGenerator=Zn,m.PolygonGenerator=Zt,m.PreLabelType=Sn,m.RasterGenerator=bo,m.RasterSetType=Ti,m.RenderBackendType=Vu,m.ReservedLightingMode=$s,m.SIMPLE_MESH_STYLE_LAYER_ID=kT,m.SceneObjectType=Tl,m.Shader=Jo,m.ShaderAttribute=ov,m.ShiftedLineGenerator=Js,m.TEXTURE_COORDS_TO_WEBGL=Fm,m.TRANSPORT_SIZE=b_,m.ThreadName=ti,m.TileLayer=Dp,m.TileObject=ta,m.TileObjectBase=lp,m.TileStatus=Jc,m.TransportHeader=Ma,m.TwoKeyMap=D_,m.UNIVERSE_REGION_ID=fm,m.UNUSED_STYLE_ID_SHIFT=UA,m.WEBGL_COORDS_TO_TEXTURE=Rm,m.WEB_MERCATOR_TO_WORLD_SIZE_MULTIPLIER=rm,m.WorkerConnector=JA,m.ZenithSourceCore=QM,m.ZenithWorker=AA,m.ZoomDirection=kt,m.add=Gt,m.add$1=ri,m.addGeneratedDataToTileMod=cp,m.adjustGlobeDragSpeed=vy,m.affineStep=za,m.allFontGlyphsLoaded=V_,m.applyDefaults=Fn,m.applyStyleOptions=qI,m.assertUnreachable=Gf,m.atlasSize=cn,m.bezier=tp,m.bindUrl=Hy,m.buildingAnimation=id,m.calcAngle=By,m.calcMidpoint=ky,m.center=Nr,m.cityCommPoiLabelingConfig=rd,m.clamp=xe,m.clampLat=Ty,m.clampPoint=My,m.clone=Im,m.clone$1=Zm,m.commPoiLayers=C0,m.commercialPoi=Ca,m.compare=$r,m.compileRtlPlugin=K1,m.componentTypeToWebGl=av,m.contains=Sy,m.convertStyleLayerTypeToHandy=m2,m.coordsToKey=Le,m.copy=Am,m.copy$1=Bd,m.copy$2=Qa,m.copy$3=xr,m.create=Ls,m.create$1=mt,m.create$2=xd,m.create$3=_s,m.create$4=sl,m.create$5=Br,m.create$6=Oe,m.createGeoJsonMetatile=b1,m.createGridState=bp,m.createLoadedRasterSet=bI,m.createMetatile=qd,m.createObjectAttributesArray=Re,m.createRemoteRenderRunner=C_,m.createRenderRunner=q1,m.createTileInfo=gt,m.cross=As,m.debounce=Np,m.decomposeMat4=Vy,m.deepEqual=Fi,m.defaultCameraConfig=zt,m.defaultLang=ad,m.defaultMarkerAnchor=wd,m.defaultMarkerIcon=vd,m.defaultModelsPath=Aa,m.defaultShadowsSettings=Id,m.degToRad=Me,m.dem=qu,m.dist=Bn,m.dist$1=tl,m.distance=Ts,m.dot=el,m.dot$1=Nn,m.dracoDecoderUrl=sm,m.drawIdentifyScene=HT,m.earcut=Jr,m.ease=ip,m.ecefDataStateFromBool=NS,m.emptyFeatureAttrs=Jd,m.emptySourceAttrs=ul,m.encodeTilePointToEcefU16=sn,m.entranceAnimation=sd,m.equalArrays=gm,m.equalSets=ym,m.equals=dy,m.equals$1=Em,m.events=td,m.exactEquals=Om,m.exactEquals$1=Pr,m.exactEquals$2=ny,m.excludeItemFromArray=vm,m.exist=rp,m.expandByPoint=ci,m.expose=Eu,m.expressionValues=gi,m.findVisibleTiles=uf,m.finishStyleUpdatingAction=_p,m.fixedMetatile=qy,m.fixedTileProps=ui,m.floors=Na,m.fonts=Ut,m.forceGlStatusCheck=Z0,m.fromGeo=Iy,m.fromRotationTranslationScale=Cm,m.fromScaling=Lm,m.fromTranslationScale=Cr,m.fromValues=at,m.fromValues$1=Va,m.generalize=yI,m.generateHaltonSequence=ew,m.generateHandyLayers=Vc,m.generateIconElement=xc,m.generateNotStretchableIconElement=SI,m.generatePointsOnSphere=tw,m.generateSafely=x0,m.generateTextElement=_o,m.generateTileBounds=W0,m.geoJsonMetatileHash=Yu,m.geoLineDistance=zm,m.geoPointsDistance=Ja,m.geoToMapDistance=Rr,m.get=RS,m.getArrayBuffer=oa,m.getBoundsTileCoords=qg,m.getCenterCorrection=gy,m.getClosestPointOnLineSegment=Mg,m.getColorForShaders=i2,m.getElevationFromTile=H2,m.getFontNameWithFallback=j_,m.getFontUrl=YI,m.getFractionalPart=mm,m.getJson=zp,m.getLabelingInfo=NM,m.getLayerImageProps=z0,m.getLineConstants=di,m.getMetersFromPixelsXY=by,m.getModelUrl=WI,m.getPixelsPerMeter=Kr,m.getPoiIconData=nM,m.getRandomValue=Hs,m.getRawMemoryStats=AE,m.getSizeDependentImageUrl=i0,m.getStaticIconRasterSetKey=Wi,m.getStaticTextureRasterSetKey=eo,m.getStyleUrl=JI,m.getStyleZoom=zd,m.getSubdomainFromString=cl,m.getSymbolLayers=q0,m.getTextMetrics=G_,m.getTierFromLevels=bM,m.getTileBounds=vl,m.getTileCoordsByCenterAndZoom=Il,m.getTileModToGenerate=pp,m.getTilesToAbortFetch=gp,m.getTilesToFetch=yp,m.getTilesToGenerate=vp,m.getTilesToRemove=wp,m.getTotalMemory=au,m.getTriple=Ar,m.getUrl=Ds,m.getUrlForIconMapIcon=Lc,m.getUrlFromTemplate=Os,m.getVisibleMapReplicas=Jg,m.getZoomFromStyleZoom=wy,m.globeConfig=On,m.handyColor=js,m.hashToString=Zd,m.heightToZoom=Bm,m.icons=Qu,m.identify=Fa,m.identity=$a,m.index=hm,m.inertia=Ra,m.inferGeneratorType=lv,m.initTransportHeader=I_,m.int64ToString=I0,m.intersection=Ay,m.intersection$1=UM,m.invert=Ss,m.isArrayOfNumbers=fn,m.isBetween=Ga,m.isCommercialCityPoi=Qh,m.isCommercialModel=VI,m.isCommercialPoi=Uo,m.isCommercialPoi$1=Mi,m.isCommercialPoiCity=cI,m.isCommercialPoiLabel=rr,m.isCommercialPoiPremium=uI,m.isCommercialPremiumPoi=e0,m.isExtractableHandyExpression=Dv,m.isHandyExpression=nn,m.isHandySimpleType=_f,m.isInt64=PM,m.isLatValid=Ey,m.isLineStyleLayer=yb,m.isNullVector=Ny,m.isNullish=wm,m.isObject=bm,m.isPersonalPoi=GI,m.isRtlPluginRequired=J1,m.isStyleColor=pn,m.isStyleGradient=to,m.isStyleId=d2,m.isStyleLayerHidable=p2,m.isStyleLayerType=h2,m.isStyleMixColor=Fv,m.isTileOnSphereInViewport=Zr,m.isTileVisible=Hr,m.isTypedArray=sM,m.keyServerPath=vs,m.keyToCoords=gl,m.labeling=Sr,m.len=Ad,m.len$1=Or,m.length=kn,m.lerp=oi,m.lerp$1=Ha,m.lerp$2=Ri,m.lerp$3=uy,m.limitString=Zv,m.linePatternFromString=E0,m.linear=np,m.loadModelsInfoStyleZoom=Da,m.log=ke,m.logEmptyTileGenerationResponse=Bf,m.logGltfError=Jv,m.lookAt=Za,m.mailboxSwap=j1,m.makeBinderContext=Jf,m.makeGeneratorContext=Ys,m.makeHandyDemLayer=Wc,m.makeHandyGroupOrLayer=B0,m.makeHandyLightStyle=V0,m.makeHandyRasterSet=U0,m.makeHandyRasterSets=k0,m.makeHandyStyle=OT,m.makeHandyStyleLayer=Xo,m.makeLabelingContext=Ht,m.mapHeightToTileHeight=it,m.mapPointPitch=Hm,m.mapPointTo32ZoomTileCoords=Xg,m.mapPointToTilePoint=Lt,m.mapToPixelDistance=jm,m.maxTilePoint=ee,m.maxU32=om,m.maxUint16Value=Ve,m.metricsTimeout=fd,m.modStatsGpu=ou,m.modStatsJs=ru,m.modelCacheSize=Ju,m.modelSizeGpu=SE,m.modelSizeJs=TE,m.models=Xu,m.mul=fy,m.mul$1=Bi,m.multiply=Ya,m.multiply$1=Py,m.newFrameAction=Sp,m.normalize=Jt,m.normalize$1=Rn,m.normalizeMapPoint=Ym,m.normalizeMousePosition=pm,m.optionsToTileAttrs=Y0,m.ortho=Dm,m.overlappedGroupName=$n,m.packTexCoords=St,m.performanceCheck=dd,m.pixelRatioToDpi=Bl,m.pixelToMapDistance=Dd,m.pixelsAndMapDistanceToZoom=Od,m.pointToLineDistance=gg,m.pointToLineSignedDistance=nf,m.preLabelingPoint=n0,m.prepareMetatile=Xd,m.processElement=RM,m.processFont=H_,m.projectToXyRect=jy,m.radToDeg=ii,m.rbush=lo,m.removeUndefined=Aw,m.renameZenithEnumerationValues=KM,m.render=od,m.reserveTextureIndex=pl,m.reset=il,m.resetGridState=tu,m.resolveAnimationExpression=$f,m.resolveColor=Wn,m.resolveExpression=H,m.resolveGradient=t2,m.resolveLightingModes=r2,m.resolveNumber=ae,m.resolveSimpleLiteralExpression=st,m.resolveString=ct,m.resolveTextureAnimationExpression=Yf,m.rotateVec2=Uy,m.rotateX=Qm,m.rotateY=ey,m.rtlAdapterPromise=X_,m.rtlPluginHash=ws,m.rtlPluginUrl=ln,m.runPrecomputes=Gc,m.sample=Xf,m.sampleColor=qf,m.scale=Un,m.scale$1=xy,m.scale$2=_t,m.scale$3=Ni,m.scale$4=ly,m.selectRaster=or,m.set=De,m.set$1=oy,m.set$2=_m,m.setSeed=eI,m.setupMapboxRtlAdapterIfNeeded=J_,m.sign=Er,m.slerp=kr,m.sourceUuid=Fp,m.splitPolylineByLength=bg,m.splitPolylineByMaxSize=Ig,m.spreadTileObjects=X0,m.sqrDist=sy,m.start=sp,m.startStyleUpdatingAction=xp,m.stop=Xc,m.stride=hr,m.styles=ed,m.sub=un,m.sub$1=Kt,m.subtract=BM,m.template=Cs,m.tetragonBounds=jr,m.tetragonIntersectsBounds=sf,m.textureSizeGpu=IE,m.textureSizeJs=su,m.throttle=xA,m.tileCoordOffset=G,m.tileCoordsToMapPoint=ji,m.tileCoordsToOSM=Wr,m.tileHeight=bs,m.tileObjectStatsGpu=Cp,m.tileObjectStatsJS=Lp,m.tilePointScaleFactor=Ct,m.tilePointToMapPoint=vt,m.tilePointToOffsetSize=Zg,m.tileSizeZpt=256,m.tileZoomToSize=jt,m.tiles=ni,m.toStyleColor=wt,m.traffic=Ku,m.transfer=y1,m.transformMat4=Fr,m.transformMat4$1=xs,m.uint16ToTileCoords=Di,m.uniqId=hl,m.unpackPreLabelingResult=oI,m.update=op,m.updateScene=Mp,m.urls=Tr,m.vertexTilePointToMapPoint=pf,m.viewportChangeAction=iu,m.viewportTilesReady=eu,m.workerResetInterval=nd,m.worldBounds=Gm,m.worldLoopBounds=Vm,m.worldSize=4294967296,m.worldWrapX=Es,m.wrap=f1,m.z0Scale=Hu,m.zenithSourceAttrs=Kd,m.zenithToJakartaPropKey=ZM,m.zoom=ld,m.zoomToHeight=ki,m.zoomToScale=km,m.zptPerInch=Is,m.zptToSceneDistance=Um}));

_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},he=(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,h=t[o*3+1]-i;r+=Math.sqrt(c*c+h*h),this.lengths.push(r),l+=c,i+=h}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],h=this.line[o*3],g=this.line[(o-1)*3+1],m=this.line[o*3+1];this.angles.push(Math.atan2(m-g,h-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],h=this.line[a*3+1],g=(t-l)/(i-l);return[(1-g)*f+g*o,(1-g)*c+g*h,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 h=c.mapPointVertices.length;(c.mapPointVertices[h-3]!==o.mapPointVertices[0]||c.mapPointVertices[h-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,h,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=h,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 ue=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,h,g){const m=[],d=[],k=[],E=[],p={},C=Re(s,r),T=new z;for(let D=0;D<s.length;D++){const W=s[D],_=r.get(W);if(_===void 0)continue;const N=t.styleState._activeFloorIds;for(let M=0;M<_.length;M++){const u=_[M];if(u.source===e.LabelSource.Tile&&c.has(u.id)&&!u.floorId||u.floorId&&(u.planLevel=g[u.floorId],!e.isCommercialPoiLabel(u)&&(N.length===0||!N.includes(u.floorId))))continue;const L=a.getStyle(u.styleId);if(!L){console.error(`Not found style ${u.styleId} in labeling#collectLabelingElements`);continue}if(!(u.source!==e.LabelSource.PersonalPoi&&C.personalPoi.has(u.id)&&!e.isCommercialPoiLabel(u))&&!(u.source===e.LabelSource.PersonalPoi&&C.commercialPoi.has(u.id)))switch(u.layer.type){case"point":{if(ge(u,i,f,t.styleState,t.styleZoom,L,h,t.elevation)&&ie(u,t.styleZoom))if(u.geometryType===e.LabelGeometryType.Line)T.add(u);else{const S=[u.mapPointVertices[0],u.mapPointVertices[1],u.mapPointVertices[2],0];ye(E,k,p,u,S,n,t,L,o)}break}case"labelLine":{ge(u,i,f,t.styleState,t.styleZoom,L,h,t.elevation)&&ie(u,t.styleZoom)&&T.add(u);break}case"oneWayLine":ie(u,t.styleZoom)&&T.add(u);break}}}const F=T.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(E,k,p,W,_,n,t,o):Fe(d,E,W,_,n,t)}return l.forEach(({id:D,width:W,height:_,position:N,offset:M,labelingGroup:u,parentPoiId:L})=>{let v;if(L&&(v=p[L],!v))return;const S=a.getStyle(e.DYNAMIC_STYLE_ID);if(!S){console.error(`Not found style ${e.DYNAMIC_STYLE_ID} in labeling#collectLabelingElements`);return}const y=new Ee(D,W,_,N,M,t.buildingHeight,n,S,u,v,v==null?void 0:v.itemPriority,v==null?void 0:v.groupPriority);m.push(y)}),{boxElements:m,oneWayTileElements:d,noLabelingElements:k,otherTileElements:E}}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 E;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=(E=e.processRTLTextIfNeeded(s.label))!=null?E:"",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(p=>{p.length&&i(p,s.ranges)}),o.type==="point"&&o.style.textFont2&&e.expressionValues(o.style.textFont2).forEach(p=>{p.length&&i(p,s.ranges)}),o.type==="point"&&o.style.iconTextFont&&e.expressionValues(o.style.iconTextFont).forEach(p=>{p.length&&i(p,s.ranges)}),s.rtlProcessed=!0),!s.rtlProcessed)return!1;const{ranges:h}=s,g=e.getFontNameWithFallback(o.style.textFont,c,l);let m;if(g&&s.label&&e.allFontGlyphsLoaded(g,h,n)&&(m=e.getTextMetrics(s.label,o.style.textLetterSpacing,t[g]),s.textMetrics=m),o.type==="labelLine")return!g||!!m;const d=e.getFontNameWithFallback(o.style.iconTextFont,c,l);d&&s.iconLabel&&e.allFontGlyphsLoaded(d,h,n)&&(s.iconTextMetrics=e.getTextMetrics(s.iconLabel,o.style.iconTextLetterSpacing,t[d]));const k=e.getFontNameWithFallback(o.style.textFont2,c,l);return g&&s.label&&k&&s.label2&&e.allFontGlyphsLoaded(k,h,n)&&(s.textMetrics2=e.getTextMetrics(s.label2,o.style.textLetterSpacing,t[k])),!g||!s.label?!d||!s.iconLabel||!!s.iconTextMetrics:!!m&&(!d||!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 h=0;h<a.labelingElements.length;h++){const g=a.labelingElements[h];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:h}=i,g=Math.floor(h),m=c+(g-h),{startLength:d,midLength:k,finishLength:E}=a.axis,p=e.makeLabelingContext(g,i.styleState,!1,a.tileData),C=Math.max(e.pixelToMapDistance(e.resolveNumber(o.style.duplicationSpacing,p),m),1),T=e.pixelToMapDistance(o.style.endingOffsets,c),F=d+(k-d)%C,D=d+T,W=E-T;for(let _=F;_<W;_+=C)if(_>D){const N=a.axis,M=_,u=N.getSegmentIndex(M),L=N.interpolate(M,u);ye(s,t,n,a,L,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),h=f+(c-o),{startLength:g,midLength:m,finishLength:d}=n.axis,k=e.makeLabelingContext(o,l.styleState,!1,n.tileData),E=e.makeLabelingContext(c,l.styleState,!1,n.tileData);let p,C,T,F;if(i.type==="labelLine"){const S=e.resolveNumber(i.style.textFontSize,k)/e.fonts.baseSize,y=e.resolveNumber(i.style.textFontSize,E)/e.fonts.baseSize;p=n.textMetrics.maxWidth*S,C=n.textMetrics.maxWidth*y,T=e.pixelToMapDistance(e.resolveNumber(i.style.textDuplicationSpacing,E),h),F=e.pixelToMapDistance(Math.max(i.style.lineEndingOffsets,i.style.textLabelingSideMargin),f)}else p=e.resolveNumber(i.style.lineLength,k),C=e.resolveNumber(i.style.lineLength,E),T=e.pixelToMapDistance(e.resolveNumber(i.style.duplicationSpacing,E),h),F=e.pixelToMapDistance(i.style.endingOffsets,f);const D=e.pixelToMapDistance(C,h),_=e.pixelToMapDistance(p,f)/2,N=T+D,M=g+(m-g)%N,u=g+_+F,L=d-_-F,v=i.type!=="labelLine"?s:t;for(let S=M;S<L;S+=N)S>u&&We(v,n,S,_,p,r,l,a)}function We(s,t,n,a,r,l,i,f){const o=t.axis,{zoom:c,styleZoom:h}=i,{startLength:g,finishLength:m}=o,d=o.getSegmentIndex(n),k=o.interpolate(n,d);if(e.mapPointPitch(l.position,k,i.center)>_e||!Ze(t,n,a,c,h,i.styleState))return;const p=t.layer.type==="oneWayLine",C=p?e.LabelingElementType.OneWayLine:e.LabelingElementType.LineText,T=new e.LabelingTileElement(t,C,k,i.buildingHeight,l,f,i.globeMode,i.styleState._floorHeight);T.anchorPosition=n,T.anchorSegmentIndex=d,T.halfLabelWidth=a,p||(T.overflowStyleZoom=e.getStyleZoom(e.pixelsAndMapDistanceToZoom(r,m-g),k),Be(T,t,n,a,i,l)),s.push(T)}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),h=i.getSegmentIndex(t+n),g=e.pixelToMapDistance(Ne*o,a);for(let m=c;m<h;m++){if(m>1&&me(i.angles[m-1],i.angles[m])>ue)return!1;const d=i.getSegmentIndex(i.lengths[m]-g);if(d!==0){const k=i.angles[d],E=i.angles[i.getSegmentIndex(i.lengths[m]+g)];if(me(k,E)>ue)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,h=e.makeLabelingContext(c,r.styleState,!1,t.tileData),g=e.resolveNumber(f.style.textFontSize,h),m=g/2,d=e.pixelToMapDistance(g,o),k=e.pixelToMapDistance(f.style.textLabelingSideMargin,o),E=Math.max(0,n-a+d/2-k),p=Math.min(i.lengths[i.lengths.length-1],n+a-d/2+k);let C=i.getSegmentIndex(E);for(let T=E;T<p;T+=d){for(;i.lengths[C]<T;)C++;de(s,i,T,C,l,m)}for(;i.lengths[C]<p;)C++;de(s,i,p,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(h=>{c.push({type:"attrs",attrs:{[l]:h}})});for(const h of o)if(Q(h))for(const g of xe([h],c))t.push(g);else if(be(h)){n.push(h);for(const g of c)t.push(g)}else if(h===!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 h of l.leafs)a.push(h);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 h=0;h<=this.orderedKeys.length;h++){if(f===i.size){c==null||c.leafs.push(n);break}const g=this.orderedKeys[h],m=this.orderedKeys[h+1]||"";if(c||(c=this.makeTreeNode(g),this.tree===null&&(this.tree=c)),i.has(g)){const d=o[g];c.children[d]||(c.children[d]=this.makeTreeNode(m)),c=c.children[d],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 h=new e.TwoKeyMap,g=new e.TwoKeyMap,m={},d=e.throttle(()=>a.reset(),e.workerResetInterval),k=y=>{e.setSeed(y)};n.set("setComPoiRandomSeed",k);const E=()=>{const y=a.getBucketsMemoryFootprint(),b=[];let I=0;Array.from(i.keys()).forEach(x=>{const Z=i.get(x);Z&&(I+=Z.length,b.push({label:{[x]:Z.map(()=>({label:1}))}}))});const P={collector:{buckets:y},labeling:b};return{js:he(se({},P),{"--labelsCount":I,"--sum":e.getTotalMemory(P)})}};n.set("getMemoryFootprint",E);const p=(y,b,I,P,x)=>{const Z=e.unpackPreLabelingResult(I,b,r,P,x);i.set(y,Z)};n.set("appendLabels",p);function C(y,b){for(const I of b)h.has(y,I)||(l(y,I),h.set(y,I,!0))}const T=(y,b)=>{f.set(y,b)};n.set("appendLabelBox",T);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,b,I){if(y.has(I.label.sourceId))return e.LabelingAnimation.none;const P=b.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,b,I,P,x,Z,G,O)=>{const K=new Set(x),H=[];let $=new Map;const U=[];return I.forEach(V=>{const A=new e.Camera(V),Y=new Set,j=[...b];y.forEach(({sourceId:w,animate:R,labelsKeys:X})=>{R||Y.add(w),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 w=0;w<ee.length;w++){const R=ee[w];R.placementIndex!==-1&&le.set(R.id,R)}for(let w=0;w<ee.length;w++){const R=ee[w],{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 w=0;w<o.length;w++){const R=o[w],{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 w of q)w.placementIndex!==-1&&Te.push(w.label.id);const ve=new Map,Xe=e.tetragonBounds(V.tilesBounds);for(const w of ae)if(w.placementIndex!==-1&&e.isCommercialPoi$1(w)&&e.contains(Xe,w.anchorWorld)){const R={};e.isCommercialPoiCity(w)?R.adsPriority="city":e.isCommercialPoiPremium(w)&&(R.adsPriority="premium"),ve.set(w.label.id,R)}const Ie={survivedLabelBoxIds:Te,survivedCommPois:Array.from(ve).map(w=>{const R={id:w[0]};return w[1].adsPriority!==void 0&&(R.adsPriority=w[1].adsPriority),R}),collectorOutput:pe,transferable:pe.transferable};if(re){const w=new Int32Array(re.length);w.set(re),Ie.labels=w.buffer}U.push(Ie)}),o=H,c=$,d(),U};n.set("processLabels",_);const N=(y,b)=>{m[y]||(m[y]={});const I=m[y];for(const P in b)I[P]=b[P]};n.set("appendFont",N);const M=(y,b)=>{g.set(y,b,!0)};n.set("markFontAsLoaded",M);const u=(y,b)=>{const I=r.getStyle(y);if(!I){console.error(`Not found style ${y} in labeling#addNewRasterSets`);return}const{rasterSets:P}=I;b.forEach(x=>{P.byIndex[x.index]=x,P.byKey[x.key]=x})};n.set("addNewRasterSets",u);const L=(y,b)=>{var G;const I=r.getStyle(y);if(!I){console.error(`Not found style ${y} in labeling#updatePackingInfo`);return}const{rasterSets:P}=I,x=7,Z=b.length/x;for(let O=0;O<Z;O++){const K=b[O*x],H=b[O*x+1],$=b[O*x+6],U=b[O*x+2],V=b[O*x+3],A=b[O*x+4],Y=b[O*x+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",L);const v=()=>{o=[],c.clear()};n.set("clearPreviousLabels",v);const S=(...y)=>r.proxySyncStyle(...y);n.set("syncStyle",S),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:h}=t,g=Object.keys(h).length,m=[],d=e.pixelRatioToDpi(l),k=e.makeGeneratorContext(r,e.emptySourceAttrs,h,m,e.emptyFeatureAttrs,void 0,f);for(const E of i.tile){const{color:p=0,color2:C=0,geo:T,road:F,normals:D,zLevel:W=0,is_immersive:_,logicalLevels:N}=E;for(let M=0;M<g;M++)m[M]=NaN;m[h.db_sublayer]="Traffic_jams",m[h.traffic_color]=p,m[h.traffic_color2]=C,m[h.traffic_road_class]=F,m[h.traffic_road_z_level]=W,m[h.db_tiers]=N?[e.getTierFromLevels(N.begin,N.end)]:void 0,m[h.db_has_immersive_counterpart]=Number(_),m[h.beginningIsCut]=0,m[h.endingIsCut]=0;for(let M=0;M<T.length;M++){const u=T[M],L=D[M],v=[],S=[],y=[],b=[];for(let x=0;x<u.length;x++)v[x]=u[x][0]*e.uint16ToTileCoords,S[x]=u[x][1]*e.uint16ToTileCoords,y[x]=L[x][0],b[x]=L[x][1];const I={x:v,y:S,normal_x:y,normal_y:b},P=a.getLayers(n.id,h,m).filter(x=>e.resolveExpression(x.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,d,I)}}return s.getAccumulatedData()}let ce=[];function Ke(s,t,n,a,r,l,i,f,o){var D,W,_;const{tileProps:c,dictionaries:h}=a,g=Object.keys(c).length,m=new Set(i),d=[];if(((D=h.db_sublayer)==null?void 0:D.s_personal_poi)===void 0)return s.getAccumulatedData();for(let N=0;N<g;N++)d[N]=NaN;const k=e.pixelRatioToDpi(l),E=e.create(),p=[];for(const N of f){const M=e.Mercator.fromGeo(N.point);e.expandByPoint(E,M),p.push(M)}const C=e.getBoundsTileCoords(E),T=e.createTileInfo(C),F=e.makeGeneratorContext(n,e.emptySourceAttrs,c,d,e.emptyFeatureAttrs,void 0,T);for(let N=0;N<f.length;N++){const M=f[N],u=e.create$1();e.mapPointToTilePoint(u,p[N],T);const L=M.id;F.id=L;const v={x:[u[0]],y:[u[1]]};for(let y=0;y<g;y++)d[y]=NaN;d[c.db_sublayer]="s_personal_poi",d[c.db_object_class]=(_=M.humanReadableClassId)!=null?_:(W=a.reverseDictionaries.db_object_class)==null?void 0:W[M.classId],d[c.db_label]=M.name,d[c.db_icon_priority]=1,d[c.db_label_priority]=0,d[c.selected]=m.has(L)?1:0,d[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,T,k,v)}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},(h,g)=>{if(this.pendingRequests.delete(o),h!==void 0){h.status!==204&&console.error(h),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),h=()=>{const u=o.atlasPacker.getNewRasterSets();u.size&&u.forEach((L,v)=>{i.main.addNewRasterSets(v,L),i.labeling.addNewRasterSets(v,L)})},g={sources:{},collector:o,styleManager:l,syncNewRasterSets:h,debouncedResetCollector:c};a.set("GeoJsonSource",e.GeoJsonSourceWorker,g,["fetchTiles"]);const m={collector:o,metatiles:f,styleManager:l,syncRasterSets:h,resetCollector:c,createImageBitmap:s.createImageBitmap?s.createImageBitmap.bind(s):void 0};a.set("ZenithWorker",e.ZenithWorker,m,["fetchTiles"]);const d={collector:o,resetCollector:c};a.set("MeshElevationWorker",e.MeshElevationWorker,d,["fetchTiles"]);const k=(u,L)=>{f[u]=L};n.set("setMetatile",k);const E=()=>{var b;const u=o.getIndexerStats(),L=o.getStatsAfterReset(),v=o.getBucketsMemoryFootprint(),S=[];(b=a.classes.get("ZenithWorker"))==null||b.hosts.forEach(I=>{I.tileLoader&&I.tileLoader.cache.size>0&&I.tileLoader.cache.forEach((P,x)=>{S.push({[x]:I.tileLoader.cache.get(x).reduce((Z,G)=>Z+G.data.byteLength,0)})})});const y={collector:{buckets:v,reset:L,idIndexer:u},zenit:{cache:S}};return{js:he(se({},y),{"--sum":e.getTotalMemory(y)})}};n.set("getMemoryFootprint",E);const p=(...u)=>l.proxySyncStyle(...u);n.set("syncStyle",p);const C=u=>new Promise(L=>{e.getArrayBuffer({url:u},(v,S)=>{if(v||S.byteLength===0){L(void 0);return}if(s.createImageBitmap){const y=new Blob([S],{type:"image/png"});createImageBitmap(y).then(b=>{L({isBitmap:!0,data:[b],transferable:[b]})})}else L({isBitmap:!1,data:[S],transferable:[S]})})});n.set("prepareAtlas",C);const T=u=>{for(let S=0;S<u.length;S+=3){const y=u[S+2],b={type:e.RasterSetType.Loaded,isSvg:!1,index:y,key:`loaded-${y}`,name:"",fileName:"",rasters:[{rasterSetIndex:y,rasterIndex:0,w:u[S],h:u[S+1],atlasIndex:0,x:0,y:0,isPacked:!1,anchorX:0,anchorY:0}]};o.atlasPacker.pack(b,[u[S]],1)}const L=o.atlasPacker.getPackedRasters(),v=[];return L!==void 0&&v.push(L.buffer),{packedRasters:L,transferable:v}};n.set("packRasters",T);const F=u=>r.fetch(u.coords,u.tileServer,u.tileProtocol,u.regionIds,u.timestamp);n.set("fetchTrafficTile",F);const D=u=>{r.delete(u)};n.set("deleteTrafficTile",D);const W=u=>{r.abortRequest(u)};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"]),N=({coords:u,pixelRatio:L,styleState:v,styleId:S,sourceId:y})=>{const b=e.coordsToKey(u),I=e.createTileInfo(u),P=[],x=[],Z=1,G=l.getStyle(S);if(!G)return Promise.resolve({results:P,transferable:x});const O=r.get(b);if(O){const K=Ge(o,_,G,l,v,L,O,I,y);P.push({regionId:Z,metatileHash:0,styleId:G.id,collectorOutput:K})}return Promise.resolve({results:P,transferable:x})};n.set("generateTrafficTile",N);const M=(u,L,v,S,y,b,I,P)=>{const x=l.getStyle(b);if(!x)return;const Z=Ke(o,x,I,f[v],L,S,y,u,P);return c(),h(),{collectorOutput:Z,transferable:Z.transferable,styleId:x.id}};n.set("generatePersonalPoi",M)}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(Q,n){var Cw=Object.defineProperty,Pw=Object.defineProperties;var Lw=Object.getOwnPropertyDescriptors;var Lc=Object.getOwnPropertySymbols;var Bw=Object.prototype.hasOwnProperty,zw=Object.prototype.propertyIsEnumerable;var qe=Math.pow,Bc=(Q,n,De)=>n in Q?Cw(Q,n,{enumerable:!0,configurable:!0,writable:!0,value:De}):Q[n]=De,I=(Q,n)=>{for(var De in n||(n={}))Bw.call(n,De)&&Bc(Q,De,n[De]);if(Lc)for(var De of Lc(n))zw.call(n,De)&&Bc(Q,De,n[De]);return Q},ce=(Q,n)=>Pw(Q,Lw(n));var K=(Q,n,De)=>new Promise((ki,Ui)=>{var eo=_t=>{try{dt(De.next(_t))}catch(fi){Ui(fi)}},Ie=_t=>{try{dt(De.throw(_t))}catch(fi){Ui(fi)}},dt=_t=>_t.done?ki(_t.value):Promise.resolve(_t.value).then(eo,Ie);dt((De=De.apply(Q,n)).next())});"use strict";var Tt,Kt;var De=document.createElement("style");De.textContent=`.mapgl-hover{cursor:pointer}.mapgl-dragging{cursor:grabbing}.mapgl-rotating{cursor:move}.mapgl_QEdaFvncPWE-{width:32px;box-shadow:0 1px 3px #26262680;border-radius:4px;display:flex;flex-direction:column;overflow:hidden;background:#fff}.mapgl_mjx-K8iaDdc-{all:revert;padding:0;outline:0;border:none;cursor:pointer;background:#fff;width:32px;height:32px;color:#262626;box-sizing:border-box}.mapgl_mjx-K8iaDdc-:hover{opacity:.7}.mapgl_mjx-K8iaDdc-:active{color:#028eff}.mapgl_mjx-K8iaDdc-:disabled{background:#f2f2f2;color:#929292;cursor:default}.mapgl_zKZCVsRur9c-{border-bottom:1px solid #e6e6e6}.mapgl_3t-wJELDATg-{border-bottom:none}.mapgl_ON-gf73kIU0-{background:#fff;box-shadow:0 1px 3px #26262680;border-radius:4px;width:32px;overflow:hidden}.mapgl_mWyZxMObEi8-{all:revert;padding:0;outline:0;border:none;cursor:pointer;box-sizing:border-box;font-size:18px;font-weight:400;width:32px;height:32px;color:#262626;background:#fff}.mapgl_FwnEmRmDBLg-:hover{opacity:.7}.mapgl_uSuUHuf71nM-{background:#299400;color:#fff}.mapgl_LdqAv9Ly624-{background:#ffb81c;color:#fff}.mapgl_udRZCM1quWE-{background:#fe5000;color:#fff}.mapgl_uSuUHuf71nM-:hover,.mapgl_LdqAv9Ly624-:hover,.mapgl_udRZCM1quWE-:hover{color:#262626b3}.mapgl_K-1Yb8HCVpQ-{display:block!important}.mapgl_K-1Yb8HCVpQ- .mapgl_CLps5xx6CNs-{height:20px!important;display:block!important}.mapgl_r8Wn2E5pGh0-{pointer-events:none;position:absolute;top:0;left:0;width:100%;height:100%;display:flex;justify-content:center;align-items:center;padding:10px;background-color:#0003;cursor:default}.mapgl_ir0vRf5QXrk-{text-align:center;font-size:24px;font-family:Helvetica,Arial,sans-serif;font-weight:700;color:#fff}.mapgl_h2pl79nAYpk-{position:relative}.mapgl_64D1bmNQN3Q-{display:flex;max-height:40vh;background:#fff;width:32px;overflow:hidden;border-radius:4px;box-shadow:0 1px 3px #26262680}.mapgl_jdJbkjpLO7k-{width:100%;overflow-x:hidden;overflow-y:auto;-moz-padding-end:17px;-webkit-padding-end:17px;-webkit-margin-end:-17px}.mapgl_54Rmy50n6Fw-{display:flex;flex-direction:column-reverse}.mapgl_3i1QoGerxio-{all:revert;padding:0;border:none;background:#fff;height:32px;width:32px;color:#262626;cursor:pointer;border-bottom:1px solid #e6e6e6;box-sizing:border-box;flex-shrink:0}.mapgl_3i1QoGerxio-:focus{outline:0}.mapgl_3i1QoGerxio-:first-child{border-bottom:none}.mapgl_3i1QoGerxio-:hover{color:#262626b3}.mapgl_3i1QoGerxio-:active{color:#028eff}.mapgl_3i1QoGerxio-:disabled{background:#f2f2f2;color:#929292;fill:#929292;cursor:default}.mapgl_wGplqJ4hHPc-{font-size:18px;line-height:32px;font-weight:400;overflow-wrap:break-word;position:relative;text-align:center;height:100%}.mapgl_wGplqJ4hHPc- svg{margin-top:3px}.mapgl_PkWXKxsq1Kc-:after{content:"";position:absolute;top:4px;bottom:4px;width:4px;height:4px;border-radius:50%;background:#028eff}.mapgl_z0m6n5pr5no-{position:absolute;pointer-events:none;inset:0}.mapgl_ITPUswrhaGk-{position:absolute;display:flex;z-index:50;pointer-events:none;width:100%;height:100%}.mapgl_ITPUswrhaGk->div>*{pointer-events:auto}.mapgl_Px-KwzXdVa0-{flex-direction:column;align-items:flex-start}.mapgl_SCX3EYsS-Cw-{flex-direction:row;justify-content:center;align-items:flex-start}.mapgl_i42TyWqpCPk-{flex-direction:column;align-items:flex-end}.mapgl_-zKby6nN-nU-{flex-direction:column;justify-content:center;align-items:flex-start}.mapgl_SlQM4-ZNKF0-{flex-direction:column;justify-content:center;align-items:flex-end}.mapgl_lNg3h7Hg-Mo-{flex-direction:column-reverse;align-items:flex-start}.mapgl_grOepPBwilk-{flex-direction:row;justify-content:center;align-items:flex-end}.mapgl_CiHYefDPhI0-{flex-direction:column-reverse;align-items:flex-end}.mapgl_Px-KwzXdVa0->div+div,.mapgl_i42TyWqpCPk->div+div,.mapgl_-zKby6nN-nU->div+div,.mapgl_SlQM4-ZNKF0->div+div{margin-top:10px}.mapgl_lNg3h7Hg-Mo->div+div,.mapgl_CiHYefDPhI0->div+div{margin-bottom:10px}.mapgl_SCX3EYsS-Cw->div+div,.mapgl_grOepPBwilk->div+div{margin-left:10px}.mapgl_9m2ynAxdBT0-{background:#ffffffad;border-width:0 1px 1px 1px;border-color:#7a7a7a;border-style:solid;border-radius:0;min-width:64px;height:16px;overflow:hidden;pointer-events:none!important}.mapgl_sR4nXEQ3L2M-{min-width:50px;height:12px;margin-top:2px;margin-left:6px;font-family:Helvetica,Arial,sans-serif!important;font-style:normal;font-weight:400;font-size:9px;line-height:12px;color:#262626}.mapgl_54Xq9OUdARA-{font-family:Helvetica,Arial,sans-serif!important;font-size:8px!important;line-height:8px!important;text-align:right!important;display:flex;align-items:flex-start;color:#6d7173!important}.mapgl_qYE18V9u8c0-{display:block}a.mapgl_wYSwIqldiqU-{color:#6d7173!important;text-decoration:none!important}a.mapgl_wYSwIqldiqU-:hover{color:#929292!important}
/*$vite$:1*/`,document.head.appendChild(De);function ki(s,e,t){if(s.length===0)return;const i=n.degToRad(e),o=n.create();for(const r of s){const l=n.Mercator.fromGeo(r);n.rotateVec2(l,-i),n.expandByPoint(o,l)}const a=n.create$1();return n.center(a,o),n.rotateVec2(a,i),{center:a,zoom:Ui(o,t)}}function Ui(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 eo(s,e,t){const i=ki(s,e,t);if(i)return{zoom:i.zoom,center:n.Mercator.toGeo(i.center)}}function Ie(s,e,t){const i=s.getBoundingClientRect();return[e-i.left-s.clientLeft,t-i.top-s.clientTop]}function dt(s,e){const t=[];for(let i=0;i<s.length;i++)t[i]=Ie(e,s[i].clientX,s[i].clientY);return t}function _t(s){return s.touches.length>1}const fi=n.Mercator.fromGeo,zc=n.Mercator.toGeo;function Rc(s,e,t,i,o,a,r={top:0,right:0,bottom:0,left:0},l={top:0,right:0,bottom:0,left:0},c=!1){return new n.Camera({center:n.Mercator.fromGeo(s),zoom:e,rotation:n.degToRad(t),size:i,pitch:n.degToRad(o),viewport:r,padding:l,cameraConfig:n.defaultCameraConfig,globeMode:c,styleState:{}}).project(a)}function Fc(s,e,t,i,o,a,r={top:0,right:0,bottom:0,left:0},l={top:0,right:0,bottom:0,left:0},c=!1){return new n.Camera({center:n.Mercator.fromGeo(s),zoom:e,rotation:n.degToRad(t),size:i,pitch:n.degToRad(o),viewport:r,padding:l,cameraConfig:n.defaultCameraConfig,globeMode:c,styleState:{}}).unproject(a)}function Dc(s,e,t,i,o,a,r={top:0,right:0,bottom:0,left:0},l={top:0,right:0,bottom:0,left:0},c){return n.getMetersFromPixelsXY(s,e,t,i,o,a,r,l,c,c)}function Oc(s,e){return new n.Camera(s).project(n.Mercator.toGeo(e))}const Nc=Object.freeze(Object.defineProperty({__proto__:null,geoLineDistance:n.geoLineDistance,geoToMapDistance:n.geoToMapDistance,getCenterZoomByPoints:eo,getMetersFromPixels:Dc,getMousePositionInContainer:Ie,projectGeoToMap:fi,projectGeoToScreen:Rc,projectMapToGeo:zc,projectMapToScreen:Oc,projectScreenToGeo:Fc},Symbol.toStringTag,{value:"Module"})),kc=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 ye(s){return!!s.styleState.globeEnabled&&s.globeMode}const Us=["disableDragging","enableTrackResize","loopWorld","disableHidingPois","enableTwoFingerDragging"];let to=class{constructor(e,t,i){var o,a,r,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=(a=t.modelsAppearStrategy)!=null?a: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((r=t.minZoom)!=null?r: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}};function Hs(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 Uc(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 to)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 gt(s,e,t,i,o){const a=o.camera,r=[0,0];if(a.unproject(i,r,!0),e&&e.dynamicObjectId!==void 0){const h=s;let f=o.layers.getDynamicObjectLayers().find(p=>p.uniqId===e.dynamicObjectId);if(f!=null&&f.parentObject&&(f=f==null?void 0:f.parentObject),!f)return;const m={lngLat:r,originalEvent:t,point:i,targetData:f};f.emit(h,m);return}const l=Hs(o.sourceStorage,e),c=Uc(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:r,originalEvent:t,point:i,target:l,targetData:c},u=s;o.map.emit(u,_)}class Gs extends Ye{constructor(e,t,i){super(e,t),this.start=o=>{const{modules:a,container:r}=this,{camera:l}=a;if(o.button!==0)return;const c=Ie(r,o.clientX,o.clientY);this.contains(c)&&(a.handler.block(),a.mouseMoveHandler.block(),this.dragStartCursorPoint=c,this.dragStartAnchorPoint=l.project(n.Mercator.toGeo(this.getPosition())),document.addEventListener("mouseup",this.stop),document.addEventListener("mousemove",this.move),this.emitEvent("dragstart",o))},this.move=o=>{const{camera:a}=this.modules,{dragStartAnchorPoint:r,dragStartCursorPoint:l,container:c}=this;if(r===void 0||l===void 0)return;const d=Ie(c,o.clientX,o.clientY),_=n.clone(r);n.add(_,_,d),n.sub(_,_,l),this.setPosition(n.Mercator.fromGeo(a.unproject(_))),this.emitEvent("drag",o)},this.stop=o=>{if(o.button!==0)return;this.dragStartCursorPoint=void 0,this.dragStartAnchorPoint=void 0,document.removeEventListener("mouseup",this.stop),document.removeEventListener("mousemove",this.move);const{modules:a}=this;a.handler.unblock(),a.mouseMoveHandler.unblock(),this.emitEvent("dragend",o),this.interactive&&a.identifier.resetCache()},this.container=e.modules.layout.mapContainer,i&&this.container.addEventListener("mousedown",this.start,!0)}destroy(){super.destroy(),this.container.removeEventListener("mousedown",this.start,!0),document.removeEventListener("mouseup",this.stop),document.removeEventListener("mousemove",this.move)}emitEvent(e,t){const i=this.getPosition(),o=n.Mercator.toGeo(i),a=this.modules.camera.flat.project(i),r=this.modules.identifier.searchSync(a),l=r!==void 0&&r.dynamicObjectId===void 0?Hs(this.modules.sourceStorage,r):void 0;this.emit(e,{originalEvent:t,target:l,targetData:this,lngLat:o,point:a})}}const Hc=!1;let Vs=class extends Gs{constructor(e,t){var r;super(e,t,(r=t.draggable)!=null?r:Hc),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:a}=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(),a.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=ye(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)),a=n.resolveNumber(t.style.width,n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[])),r=n.resolveNumber(t.style.strokeWidth,n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[])),l=a/2+r;return n.dist(o,e)<=l}generate(){var p;if(!this.layer)return;const{dynamicStyle:e,collector:t,tileManager:i,identifier:o}=this.modules,r=(p=this.position.userValue[2])!=null?p:0,l=n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),c=n.optionsToTileAttrs({}),d={x:[0],y:[0],z:[r]},_=n.createTileInfo(l),u=ye(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 js(s,e,t){const{top:i,right:o,bottom:a,left:r}=s.viewport,{clientWidth:l,clientHeight:c}=e;s.size=[Math.max(1,l-r-o),Math.max(1,c-i-a)],t.updateFrameBuffersSize()}const Gc=(s,e,t,i,o={})=>{const a=I({top:0,right:0,bottom:0,left:0},i);if(o.animate===!1||o.duration===0)s.viewport=a,js(s,e,t);else{const r=s.viewport,l=o.easing!==void 0?o.easing:"easeOutCubic",c=o.duration!==void 0?o.duration:300;n.start("viewport",{easing:l},s,[r.top,r.right,r.bottom,r.left],[a.top,a.right,a.bottom,a.left],c,1)}},Vc=(s,e,t)=>{n.update("viewport",{step:(i,o)=>{i.viewport={top:o[0],right:o[1],bottom:o[2],left:o[3]},js(i,e,t)}},s)};function jc(s,e){return{top:s.top+e.top,bottom:s.bottom+e.bottom,left:s.left+e.left,right:s.right+e.right}}function Zc(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 Wc(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 $c(s,e){return Wc(Zc(s),e)}function Zs(s,e){const{top:t,right:i,bottom:o,left:a}=s.padding;s.padding={top:t,right:i,bottom:o,left:a},e.addRerenderEvent(),e.updateFrameBuffersSize()}const Xc=(s,e,t,i={})=>{const o=$c(t,s.size);if(i.animate===!1||i.duration===0)s.padding=o,Zs(s,e);else{const a=s.padding,r=i.easing!==void 0?i.easing:"easeOutCubic",l=i.duration!==void 0?i.duration:300;n.start("padding",{easing:r},s,[a.top,a.right,a.bottom,a.left],[o.top,o.right,o.bottom,o.left],l,1)}},Kc=(s,e)=>{n.update("padding",{step:(t,i)=>{t.padding={top:i[0],right:i[1],bottom:i[2],left:i[3]},Zs(t,e)}},s)},Hi="inertia",qc=(s,e,t)=>s*Math.pow(1-(t-e)/n.inertia.duration,n.inertia.nonLinearity),Yc=(s,e,t,i,o)=>{n.start(Hi,{easing:"inertia"},s,0,o,n.inertia.duration,1,{startPoint:e,startSpeed:t,direction:i,startTime:s.time})},io=n.stop.bind(null,Hi),Qc=(s,e)=>{n.update(Hi,{step:(t,i,o)=>{const{startPoint:a,startSpeed:r,startTime:l,direction:c}=o,d=n.clone$1(c);n.scale(d,d,i),n.add$1(d,d,a),t.loopWorld||t.globeMode?n.isLatValid(t.maxBounds,d)||(no(e,t),n.clampPoint(d,t.maxBounds,d)):n.contains(t.maxBounds,d)||(no(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 _=qc(r,l,t.time);n.mapToPixelDistance(_,t.zoom)<n.inertia.minSpeed&&no(e,t)}},s)},no=(s,e)=>{n.stop(Hi,e),s.classList.remove("mapgl-inertia")},Gi="center",kt=(s,e,t={})=>{if(n.stop(Gi,s),io(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(Gi,{easing:i},s,s.center,e,o,1)}},Jc=n.stop.bind(null,Gi),Ac=n.update.bind(null,Gi,{step:(s,e)=>{s.center=e,s.zoomTypePreserving==="zoom"?s.styleZoom=n.getStyleZoom(s.zoom,e):s.zoom=n.getZoomFromStyleZoom(s.styleZoom,e)}}),Vi="rotation";function oo(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 mi(s,e,t={}){if(n.stop(Vi,s),t.animate===!1||t.duration===0)s.rotation=oo(e,0);else{const i=t.normalize!==void 0?t.normalize:!0;n.start(Vi,{easing:t.easing||"linear"},s,s.rotation,i?oo(e,s.rotation):e,t.duration||250,1)}}const ed=n.stop.bind(null,Vi),td=n.update.bind(null,Vi,{step:(s,e)=>s.rotation=oo(e,0)}),ji="pitch";function Zi(s,e,t={}){n.stop(ji,s);const i=n.clamp(e,s.minPitch,s.maxPitch);t.animate===!1||t.duration===0?s.pitch=i:n.start(ji,{easing:t.easing||"linear"},s,s.pitch,i,t.duration||300,1)}const id=n.stop.bind(null,ji),nd=n.update.bind(null,ji,{step:(s,e)=>s.pitch=e}),Wi="zoom",Et=(s,e,t={})=>{n.stop(Wi,s);const i=n.clamp(e,s.minZoom,s.maxZoom);if(i!==s.zoom)if(t.animate===!1||t.duration===0)t.zoomPoint&&(n.add$1(s.center,s.center,n.getCenterCorrection(s,t.zoomPoint,{zoom:i})),n.clampPoint(s.center,s.maxBounds,s.center)),s.zoom=i,s.styleZoom=n.getStyleZoom(i,s.center);else{const o=t.useHeightForAnimation?n.zoomToHeight(s.zoom,s.size):s.zoom,a=t.useHeightForAnimation?n.zoomToHeight(i,s.size):i,r=t.easing!==void 0?t.easing:"easeOutCubic",l=t.duration!==void 0?t.duration:250;n.start(Wi,{easing:r},s,o,a,l,1,{zoomPoint:t.zoomPoint,useHeightForAnimation:!!t.useHeightForAnimation})}},Ws=n.stop.bind(null,Wi),od=n.update.bind(null,Wi,{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)}}),sd=navigator.msPointerEnabled&&navigator.msMaxTouchPoints&&!window.PointerEvent,ad=window.PointerEvent&&navigator.pointerEnabled&&navigator.maxTouchPoints||sd||"ontouchstart"in window||window.DocumentTouch&&document instanceof window.DocumentTouch,rd=Ut("webkit"),ld=Ut("chrome")||Ut("crios"),cd="ActiveXObject"in window,dd=!ld&&Ut("safari");Ut("gecko")&&!rd&&window.opera;const $i=navigator.platform.toUpperCase().indexOf("MAC")>=0,_d=Ut("windows"),ud=Ut("firefox");function Ut(s){return navigator.userAgent.toLowerCase().indexOf(s)>=0}function yt(s){Ws(s),Jc(s),ed(s),id(s),io(s)}class hd{constructor(e,t){this.onWheelScroll=i=>{this.isBlocked||(i.preventDefault(),!(i.deltaMode===void 0&&i.deltaY===void 0)&&(this.state.userHasInteracted=!0,this.screenPoint=Ie(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();$i?o*=n.zoom.macWheelDeltaToZoomDelta:Number.isInteger(o)?o=n.sign(o)*n.zoom.wheelZoomDelta:o*=n.zoom.notMacTrackpadDeltaToZoomDelta;const a=i.zoom+o,r=n.clamp(a,i.minZoom,i.maxZoom);r!==i.zoom&&(yt(i),Et(i,r,{duration:n.zoom.animDuration,animate:!$i,zoomPoint:i.keepCenterWhileUserZoomRotate?void 0:this.screenPoint}))},this.stop=()=>{this.state.userHasInteracted=!0,Ws(this.state)},this.state=e,this.container=t,$i||(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 fd{constructor(e,t){this.onMouseUp=i=>{this.isBlocked||i.which===1&&this.start()},this.onTouchEnd=i=>{this.isBlocked||i.touches.length===0&&this.start()},this.start=()=>{const i=this.state;i.userHasInteracted=!0;const o=this.getCurrentSpeed(i.time),a=n.length(o);if(n.mapToPixelDistance(a,i.zoom)<=n.inertia.minSpeed)return;const l=n.pixelToMapDistance(n.inertia.maxSpeed,i.zoom),c=Math.min(a,l),d=this.calcDistanceByStartSpeed(c),_=n.clone$1(i.center),u=n.create$1();n.normalize(u,o),Yc(i,_,c,u,d),this.container.classList.add("mapgl-inertia")},this.stop=()=>{io(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),ad&&(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 md{constructor(e){this.emitMouseEvent=t=>{if(this.isBlocked)return;const i=Ie(this.container,t.clientX,t.clientY);this.emitEvent(t,i)},this.emitTouchEvent=t=>{if(this.isBlocked)return;const i=Ie(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=>{gt(i,o,e,t,this.modules)})}}class pd{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=Ie(this.container,o.clientX,o.clientY),this.state.userHasInteracted=!0,this.state.disableRotationByUserInteraction||this.container.classList.add("mapgl-rotating"),this.map.emit("interactionstart",{target:"zoom/rotation"}))},this.onGestureEnd=o=>{o.preventDefault(),this.isGestureStart&&(this.isGestureStart=!1,this.state.userHasInteracted=!0,this.container.classList.remove("mapgl-rotating"),this.map.emit("interactionend",{target:"zoom/rotation"}))},this.onGestureChange=o=>{if(o.preventDefault(),this.state.userHasInteracted=!0,o.scale>1?this.gestureZoom=o.scale-1:this.gestureZoom=-1/o.scale+1,this.state.disableRotationByUserInteraction)return;const a=n.degToRad(o.rotation);!this.rotationDetected&&Math.abs(a)>this.state.touchRotationThreshold&&(this.rotationDetected=!0,this.startRotation=this.state.rotation-a),this.rotationDetected&&(this.gestureRotation=a)},this.state=e,this.container=t,this.map=i,this.isBlocked=!1,this.isGestureStart=!1,this.gestureRotation=0,this.gestureZoom=0,this.screenPoint=[0,0],this.startRotation=0,this.startZoom=0,this.container.addEventListener("gesturestart",this.onGestureStart),this.container.addEventListener("gestureend",this.onGestureEnd),this.container.addEventListener("gesturechange",this.onGestureChange)}destroy(){this.container.removeEventListener("gesturestart",this.onGestureStart),this.container.removeEventListener("gestureend",this.onGestureEnd),this.container.removeEventListener("gesturechange",this.onGestureChange)}update(){if(this.gestureRotation===0&&this.gestureZoom===0)return;const e=this.state,t=this.startZoom+this.gestureZoom,i=this.startRotation+this.gestureRotation,o=n.create$1(),a=e.keepCenterWhileUserZoomRotate?n.create$1():n.getCenterCorrection(e,this.screenPoint,{zoom:t,rotation:i});n.add$1(o,e.center,a),yt(e),kt(e,o,{animate:!1}),Et(e,t,{animate:!1}),e.disableRotationByUserInteraction||mi(e,i,{animate:!1}),this.gestureRotation=0,this.gestureZoom=0}block(){this.isBlocked=!0}unblock(){this.isBlocked=!1}}class vd extends n.Evented{constructor(e,t){super(),this.startRenderTime=0,this.catchNextUpdate=!1,this.durations=[],this.badDurations=[],this.countToCheck=75,this.slowFrameTime=100,this.mapState=e,this.mapModules=t,this.originalMapState={center:this.mapState.center.slice(),zoom:this.mapState.zoom,rotation:this.mapState.rotation,pitch:this.mapState.pitch}}update(){const{time:e,needRerender:t,rerenderEvents:i}=this.mapState,o=e-this.startRenderTime;this.catchNextUpdate&&(this.durations.push(o),o>=this.slowFrameTime&&this.badDurations.push(o),this.catchNextUpdate=!1),(t||i.length>0)&&(this.startRenderTime=e,this.catchNextUpdate=!0),this.durations.length>this.countToCheck&&this.check()}getFpsStats(){const e=this.durations.map(a=>1e3/a),t=this.badDurations.map(a=>1e3/a),i=n.equalArrays(this.originalMapState.center,this.mapState.center)&&this.originalMapState.pitch===this.mapState.pitch&&this.originalMapState.rotation===this.mapState.rotation&&this.originalMapState.zoom===this.mapState.zoom;return{all:{min:e.length>0?Math.min(...e):0,max:e.length>0?Math.max(...e):0,avg:e.length>0?e.reduce((a,r)=>a+r)/e.length:0,count:e.length},bad:{min:t.length>0?Math.min(...t):0,max:t.length>0?Math.max(...t):0,avg:t.length>0?t.reduce((a,r)=>a+r)/t.length:0,count:t.length},isStatic:i}}getMemoryStats(){return K(this,null,function*(){const e=yield this.getJsMemoryStats(),t=yield this.getGpuMemoryStats();return{cpu:e,gpu:t}})}check(){const e=gd(this.durations);this.emit("fps",e),e<n.performanceCheck.fpsCaveat&&(this.mapState.performanceCaveatEmitted=!0,this.emit("performancecaveat")),this.durations=[],this.badDurations=[],this.countToCheck=Math.min(1e3,this.countToCheck*2)}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,a)=>o+a["--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,a)=>o+a["--sum"],0)})}}function gd(s){s.sort((t,i)=>t-i);const e=s[Math.floor(s.length*3/4)];return Math.round(1e3/e)}class yd{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 xd{constructor(e){this.onTouchStart=()=>{this.isTouchStartEmitted=!0},this.onMouseOut=t=>{if(!this.prevGeo)return;const i=Ie(this.container,t.clientX,t.clientY);gt("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=Ie(this.container,t.clientX,t.clientY);Promise.resolve().then(()=>this.modules.layout.isActionWithCanvas(t)?this.modules.identifier.search("mouseMove",i):void 0).then(o=>{if(this.skipIdentifyEvents)return;const a=o&&this.prevGeo&&(o.id!==this.prevGeo.id||o.instanceId!==this.prevGeo.instanceId||o.dynamicObjectId!==this.prevGeo.dynamicObjectId||o.symbol!==this.prevGeo.symbol);this.prevGeo&&(!o||a)&&(gt("mouseout",this.prevGeo,t,i,this.modules),this.prevGeo=void 0,this.container.classList.remove("mapgl-hover"),this.modules.defaultSource.resetHoverId()),o&&(!this.prevGeo||a)&&(this.prevGeo=o,this.container.classList.add("mapgl-hover"),gt("mouseover",o,t,i,this.modules),this.modules.defaultSource.setHoverId(o.id)),gt("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 $s=(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)},bd=(s,e,t)=>n.update.call(null,"buildingHeight"+t,{step:(i,o)=>e.set(t,o),complete:i=>i.needLabeling=!0},s),wd=16;class Sd{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()&&bd(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:wd;return this.state.styleZoom<e?0:1}updateByZoom(e,t){const i=this.state,o=n.get("buildingHeight"+e,i),a=o!==void 0?o.to:t;i.styleZoom>=e&&this.modules.tileManager.viewportTilesReady()&&a!==1?$s(i,this.buildingHeights,{animate:!0,easing:n.buildingAnimation.easing,from:t,to:1,duration:n.buildingAnimation.duration*(1-t)},e):i.styleZoom<e&&a!==0&&$s(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 j=class j{constructor(e=null,t={}){this._src=null,this._glContext=null,this._texture=null,this._src=e,this.options=Object.assign({},j.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 a=this._toGlParam(o,this.options.format),r=this._toGlParam(o,(l=this.options.type)!=null?l:j.UnsignedByte);return a===null||r===null?this:(o.texSubImage2D(o.TEXTURE_2D,0,t,i,a,r,e),this.options.generateMipmaps&&this.options.minFilter!==j.NearestFilter&&this.options.minFilter!==j.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:j.UnsignedByte),o=this._toGlParam(e,this.options.wrapS),a=this._toGlParam(e,this.options.wrapT),r=this._toGlParam(e,(_=this.options.magFilter)!=null?_:j.LinearFilter),l=this._toGlParam(e,(u=this.options.minFilter)!=null?u:j.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&&a!==null&&(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,o),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,a)),r!==null&&l!==null&&(e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,l)),c&&!(e instanceof WebGLRenderingContext)&&e.texParameteri(e.TEXTURE_2D,e.TEXTURE_COMPARE_MODE,e.COMPARE_REF_TO_TEXTURE),this.options.generateMipmaps&&this.options.minFilter!==j.NearestFilter&&this.options.minFilter!==j.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,a;if(!this._texture)return 0;const e=((i=(t=this.options.size)==null?void 0:t[0])!=null?i:0)*((a=(o=this.options.size)==null?void 0:o[1])!=null?a:0)*4;return e>0?e:this._src!==null?this.memSizeJs():0}_toGlParam(e,t){return t===j.ClampToEdgeWrapping?e.CLAMP_TO_EDGE:t===j.Repeat?e.REPEAT:t===j.MirroredRepeat?e.MIRRORED_REPEAT:t===j.NearestFilter?e.NEAREST:t===j.NearestMipMapNearestFilter?e.NEAREST_MIPMAP_NEAREST:t===j.NearestMipMapLinearFilter?e.NEAREST_MIPMAP_LINEAR:t===j.LinearFilter?e.LINEAR:t===j.LinearMipMapNearestFilter?e.LINEAR_MIPMAP_NEAREST:t===j.LinearMipMapLinearFilter?e.LINEAR_MIPMAP_LINEAR:t===j.RgbaFormat?e.RGBA:t===j.AlphaFormat?e.ALPHA:t===j.RgbFormat?e.RGB:t===j.DepthComponentFormat?e.DEPTH_COMPONENT:t===j.UnsignedByte?e.UNSIGNED_BYTE:t===j.UnsignedShort?e.UNSIGNED_SHORT:t===j.Float?e.FLOAT:t===j.UnsignedInt?e.UNSIGNED_INT:e instanceof WebGLRenderingContext?null:t===j.RedFormat?e.RED:t===j.CompareRefToTexture?e.COMPARE_REF_TO_TEXTURE:t===j.CompareNone?e.NONE:t===j.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}};j.ClampToEdgeWrapping=1,j.Repeat=2,j.MirroredRepeat=3,j.NearestFilter=4,j.NearestMipMapNearestFilter=5,j.NearestMipMapLinearFilter=6,j.LinearFilter=7,j.LinearMipMapNearestFilter=8,j.LinearMipMapLinearFilter=9,j.DepthComponentFormat=10,j.DepthComponentFormat32=11,j.RgbaFormat=14,j.AlphaFormat=15,j.RgbFormat=16,j.UnsignedByte=17,j.Float=18,j.UnsignedShort=19,j.UnsignedInt=20,j.RedFormat=21,j.CompareNone=22,j.CompareRefToTexture=23,j.defaultOptions={magFilter:j.LinearFilter,minFilter:j.LinearMipMapLinearFilter,wrapS:j.ClampToEdgeWrapping,wrapT:j.ClampToEdgeWrapping,format:j.RgbaFormat,generateMipmaps:!0,flipY:!0,premultiplyAlpha:!0,type:j.UnsignedByte};let w=j;function Xi(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 Jn=class Jn{constructor(e={}){this._texture=null,this._glContext=null,this._frameBuffer=null,this._depthAttachment=null,this.options=Object.assign({},Jn.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,a=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,a,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}`)}}};Jn.defaultOptions=Object.assign({},w.defaultOptions,{size:[0,0],generateMipmaps:!1,depthTexture:!1,hasColorOutput:!0,useHighDepthPrecision:!1,depthInternalFormat:WebGLRenderingContext.DEPTH_COMPONENT16});let Ce=Jn;function Ki(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 so={};function Td(s){const e=String(s);return so[e]===void 0&&(so[e]=Md(s)),so[e]}function Md(s){const e=Ki(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 Ht;function Xs(){Ht=void 0;const s=new Float32Array([-1,-1,1,-1,-1,1]),e=2,t=Ki(!1);if(!t)return Ht="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 Ht=`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),a=`attribute vec2 pos;
    void main () {
        gl_Position = vec4(pos, 0, 1);
    }`,r=`precision mediump float;
    uniform sampler2D tex;
    void main () {
        gl_FragColor = vec4(texture2D(tex, vec2(0.4, 0.4)).a, 0, 0, 0);
    }`,l=t.createShader(t.VERTEX_SHADER),c=t.createShader(t.FRAGMENT_SHADER);if(!l||!c||t.isContextLost())return Ht="Cannot create shaders",!1;t.shaderSource(l,a),t.compileShader(l),t.shaderSource(c,r),t.compileShader(c);const d=t.createProgram();if(!d)return Ht="Cannot compile shader program",!1;t.attachShader(d,l),t.attachShader(d,c),t.linkProgram(d),t.useProgram(d);const _=t.createBuffer();if(!_)return Ht="Cannot create buffer",!1;t.bindBuffer(t.ARRAY_BUFFER,_),t.bufferData(t.ARRAY_BUFFER,s,t.STATIC_DRAW);const u=t.getAttribLocation(d,"pos");t.vertexAttribPointer(u,2,t.FLOAT,!1,0,0),t.enableVertexAttribArray(u),o.enable(t,0);const h=t.getUniformLocation(d,"tex");t.uniform1i(h,0),t.viewport(0,0,e,e),t.drawArrays(t.TRIANGLES,0,3);const f=new Uint8Array(4);return t.readPixels(0,0,1,1,t.RGBA,t.UNSIGNED_BYTE,f),i.unbind(t),f[0]!==255}function Ed(){return Ht}let st=null;function Yt(){if(st!==null)return st;const s=Ki(!1);if(!s)return st=!0,st;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 st=!0,st;s.shaderSource(i,e),s.compileShader(i),s.shaderSource(o,t),s.compileShader(o);const a=s.createProgram();return!a||(s.attachShader(a,i),s.attachShader(a,o),s.linkProgram(a),!a||!s.getProgramParameter(a,s.LINK_STATUS))?(st=!0,st):(st=!1,st)}function Id(){const s=Ki(!1);if(!s)return!1;if(!_d)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 Ks(s){return s instanceof WebGLRenderingContext?!!s.getExtension("WEBGL_depth_texture"):!0}function Cd(s){return!qs(s)}function qs(s){if(!Pd())return"not a browser";if(!Bd())return"insufficient Function support";if(!Rd())return"insufficient JSON support";if(!Fd())return"insufficient worker support";if(!Od())return"insufficient ArrayBuffer support";if(!Nd())return"insufficient Canvas/getImageData support";const e=Td(s&&s.failIfMajorPerformanceCaveat||!1);if(!e.ok)return`insufficient WebGL support${e.msg?`: ${e.msg}`:""}`;if(!Ld())return"insufficient Array support";if(!zd())return"insufficient Object support";if(!Dd())return"insufficient DOM support";if(!kd())return"insufficient ECMAScript 6 support"}function Pd(){return typeof window!="undefined"&&typeof document!="undefined"}function Ld(){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 Bd(){var s;return typeof((s=Function.prototype)==null?void 0:s.bind)=="function"}function zd(){return!!(Object.keys&&Object.assign&&Object.create&&Object.getPrototypeOf&&Object.getOwnPropertyNames&&Object.getOwnPropertyDescriptor&&Object.defineProperty&&Object.freeze)}function Rd(){return"JSON"in window&&"parse"in JSON&&"stringify"in JSON}function Fd(){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 Dd(){const s=document.createElement("div");return s&&typeof s.after=="function"}function Od(){return!!ArrayBuffer.isView}function Nd(){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 kd(){return!("documentMode"in document)}function Ud(){return Ed()}const Hd=Id,Gd=()=>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 ut{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 Vd{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 Ks(this._gl)}isShadowSamplerSupported(){return!(this._gl instanceof WebGLRenderingContext)&&this.isDepthTextureSupported()}isContextLost(){return this._gl.isContextLost()}storeGpuState(e){var i,o,a,r;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:(a=this._lastState.depthFunc)!=null?a:t.getParameter(t.DEPTH_FUNC),clearDepth:(r=this._lastState.clearDepth)!=null?r:t.getParameter(t.DEPTH_CLEAR_VALUE)}}restoreGpuState(e){const t=this._storedStates[e];if(t){const i=this._gl;this._lastState.depthMask!==t.depthMask&&i.depthMask(t.depthMask),this._lastState.depthTest!==t.depthTest&&(t.depthTest?i.enable(i.DEPTH_TEST):i.disable(i.DEPTH_TEST)),this._lastState.depthFunc!==t.depthFunc&&i.depthFunc(t.depthFunc),this._lastState.clearDepth!==t.clearDepth&&i.clearDepth(t.clearDepth)}}drawPoints(e,t){this._gl.drawArrays(this._gl.POINTS,e,t)}drawTriangles(e,t){this._gl.drawArrays(this._gl.TRIANGLES,e,t)}drawTrianglesFan(e,t){this._gl.drawArrays(this._gl.TRIANGLE_FAN,e,t)}drawArrays(e,t,i){this._gl.drawArrays(e,t,i)}drawElements(e,t,i,o){this._gl.drawElements(e,t,i,o)}drawInstancedElements(e,t,i,o,a){const r=this._gl,l=this.webGlExtensions.ANGLE_instanced_arrays;if(r instanceof WebGLRenderingContext){if(!l)return;l.drawElementsInstancedANGLE(e,t,i,o,a)}else r.drawElementsInstanced(e,t,i,o,a)}drawInstancedArrays(e,t,i,o){const a=this._gl,r=this.webGlExtensions.ANGLE_instanced_arrays;if(a instanceof WebGLRenderingContext){if(!r)return;r.drawArraysInstancedANGLE(e,t,i,o)}else a.drawArraysInstanced(e,t,i,o)}triangleCountByDrawMode(e,t){const i=this._gl;switch(e){case i.TRIANGLES:return t/3;case i.TRIANGLE_FAN:case i.TRIANGLE_STRIP:return t-2;default:return 0}}createBuffer(e,t,i,o){return new n.Buffer(this._gl,e,t,i,o)}applyState(e,t){var a,r,l,c,d,_,u,h,f,m,p,v,x,g,y,b,T,S;const i=this._gl;if(i.depthMask((a=t==null?void 0:t.depthMask)!=null?a:e.depthMask),((r=t==null?void 0:t.depthTest)!=null?r: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 L=(h=t==null?void 0:t.blendFuncSeparate)!=null?h:e.blendFuncSeparate;L?this.setBlendFuncSeparate(L.srcRgb,L.dstRgb,L.srcAlpha,L.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,(S=(T=t==null?void 0:t.polygonOffset)==null?void 0:T.units)!=null?S:e.polygonOffset.units)):i.disable(i.POLYGON_OFFSET_FILL)}setDepthFunc(e){const t=ut.depthFuncToWebGL(this._gl,e);this._gl.depthFunc(t)}setCullFaceMode(e){const t=ut.cullFaceModeToWebGL(this._gl,e);this._gl.cullFace(t)}setBlendFunc(e,t){const i=ut.blendFuncToWebGL(this._gl,e),o=ut.blendFuncToWebGL(this._gl,t);this._gl.blendFunc(i,o)}setBlendFuncSeparate(e,t,i,o){const a=ut.blendFuncToWebGL(this._gl,e),r=ut.blendFuncToWebGL(this._gl,t),l=ut.blendFuncToWebGL(this._gl,i),c=ut.blendFuncToWebGL(this._gl,o);this._gl.blendFuncSeparate(a,r,l,c)}setBlendEquation(e){const t=ut.blendEquationToWebGL(this._gl,e);this._gl.blendEquation(t)}setBlendEquationSeparate(e,t){const i=ut.blendEquationToWebGL(this._gl,e),o=ut.blendEquationToWebGL(this._gl,t);this._gl.blendEquationSeparate(i,o)}setDepthMask(e){this._gl.depthMask(e)}overrideStateMethods(){const e=this._gl.depthMask.bind(this._gl);this._gl.depthMask=r=>(this._lastState.depthMask=r,e(r));const t=this._gl.enable.bind(this._gl);this._gl.enable=r=>(r===this._gl.DEPTH_TEST&&(this._lastState.depthTest=!0),t(r));const i=this._gl.disable.bind(this._gl);this._gl.disable=r=>(r===this._gl.DEPTH_TEST&&(this._lastState.depthTest=!1),i(r));const o=this._gl.depthFunc.bind(this._gl);this._gl.depthFunc=r=>(this._lastState.depthFunc=r,o(r));const a=this._gl.clearDepth.bind(this._gl);this._gl.clearDepth=r=>(this._lastState.clearDepth=r,a(r))}}class jd{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 Oi=class Oi{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 jd(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=Oi.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 a=o.filter(c=>c!==t.INVALID_INDEX),r=t.getActiveUniforms(i,a,t.UNIFORM_OFFSET);if(r===null)return console.error("Couldn't get active UBO uniform offsets."),null;const l={};for(let c=0;c<e.length;++c){const d=o[c];if(d!==t.INVALID_INDEX){const _=a.indexOf(d);l[e[c]]=r[_]}}return l}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 a=e.getActiveUniformBlockName(t,o);if(!a)continue;const r=e.getActiveUniformBlockParameter(t,o,e.UNIFORM_BLOCK_ACTIVE_UNIFORMS);if(r===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<r;d++){const _=e.getActiveUniform(t,l[d]);_&&c.push(_.name)}this._uniformBlocksMap[a]=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 a=t.getUniformBlockIndex(e,o);if(a!==t.INVALID_INDEX){const r=Oi.getStableUboBinding(o);if(r===void 0)continue;this._uniformBlocksIndices[o]=a,this._uboBindings[o]=r,t.uniformBlockBinding(e,a,r)}}}};Oi.fixedUboBindings={CommonSettings:0,LightSettings:1};let ao=Oi;const Ys=[1,1,1,1],Zd=3.7,Wd=n.create$1(),$d=n.create$1(),Qs=n.create$2(),Xd=n.create$2(),Kd=n.create$1(),qd=n.fromValues(0,1,0),Js=(s,e,t,i)=>{ht(t,s,{u_float_rounding_factor:e.stillness},i)},pi=(s,e,t,i)=>{ht(t,s,{u_float_border_width_offset:1/window.devicePixelRatio},i)},qi=(s,e,t,i)=>{const o=(n.POINT_CENTER_SIZE-.5)/2,{size:a}=e;ht(t,s,{u_vec2_depth_test_half_point_size:[o/a[0],o/a[1]]},i)},$=(s,e,t,i)=>{if(!t.environmentManager.isFogEnabled())return;const o=t.styleManager.getStyle(e.handyStyleId);let a=Ys,r=Ys;if(o){const _=n.makeBinderContext(e.styleZoom,e.styleState,[]);a=n.getColorForShaders(n.resolveColor(o.environment.style.skyColor,_)),r=n.getColorForShaders(n.resolveColor(o.environment.style.fogColor,_))}const l=t.camera,c=!e.elevation||Number.isNaN(e.elevation)?0:e.elevation*n.MAP_POINTS_IN_METER,d=Math.min(1+Math.max(c/n.zoomToHeight(e.zoom,e.size),0),Zd);ht(t,s,{u_sky_color:e.globeMode?[0,0,0,0]:a,u_fog_color:e.globeMode?[0,0,0,0]:r,u_fog_distance:e.globeMode?0:l.fogDistance,u_fog_limits:t.environmentManager.fogLimits,u_fog_horizon_blend:t.environmentManager.fogHorizonBlend,u_fog_horizon_level:t.environmentManager.fogHorizonLevel,u_fog_horizon_pad:e.cameraConfig.fogHorizonPadFactor*d},i)},W=(s,e,t,i)=>{ht(t,s,{u_cam_pos:t.camera.position},i)},J=(s,e,t,i)=>{t.shadowManager.texture&&ht(t,s,{u_shadow_map_params:t.shadowManager.shadowMapParams,u_shadow_bias:t.shadowManager.bias,u_mat4_clip_to_shadow:t.shadowManager.clipToShadowMatrix},i)},vi=(s,e,t,i)=>{ht(t,s,{u_vec2_scale_limits:[0,n.z0Scale]},i)},As=(s,e,t,i)=>{const o=t.camera.viewMatrixTranspose,a=t.camera.projectionMatrixInverse;ht(t,s,{u_mat4_view_transposed:o,u_mat4_proj_inverted:a},i)},ro=(s,e,t,i)=>{const o=window.devicePixelRatio,a=t.camera.ecef.pixelRadius*o,{left:r,bottom:l,top:c,right:d}=e.padding,[_,u]=e.size,h=[_*o,u*o],f=[(r-d)*o/2,(l-c)*o/2],m=t.environmentManager.globHaloStops.map(b=>(a+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);ht(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)},ea=(s,e,t,i)=>{const o=e.size,a=Math.max(o[0],o[1]),r=o[0]/a,l=o[1]/a;n.ortho(Qs,-r/2,r/2,-l/2,l/2,.001,1);const c=n.Mercator.toGeo(e.center),d=n.set($d,0,0,0),_=n.set(Wd,0,0,1);n.rotateX(_,_,d,n.degToRad(c[1])),n.rotateY(_,_,d,n.degToRad(c[0]));const u=n.lookAt(Xd,Kd,_,qd);n.multiply(u,Qs,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);ht(t,s,{u_float_pixelratio:window.devicePixelRatio,u_float_stars_intensity:p,u_mat4_stars:u},i)},_e=(s,e,t,i)=>{const{size:o}=e,a=window.devicePixelRatio;ht(t,s,{u_vec2_vpt_size:[o[0]*a,o[1]*a]},i)};function ht(s,e,t,i){i?i.updateData(e,t):s.renderer.bindShaderProgram(e,t)}function X(...s){return(e,t,i,o)=>{s.forEach(a=>a(e,t,i,o))}}const Yd=X(Js,pi,qi,$,W,J,vi,As,ro,ea,_e),ta=X(W,$),ia=(s,e,t)=>{const{size:i}=e,o=window.devicePixelRatio;if(e.demMode){const a=t.renderer.getFramebuffer(t.demManager.getFlatFramebufferId());if(!a)return;t.renderer.bindShaderProgram(s,{u_vec2_vpt_size:[Math.trunc(a.renderTarget.options.size[0]),Math.trunc(a.renderTarget.options.size[1])]})}else t.renderer.bindShaderProgram(s,{u_vec2_vpt_size:[i[0]*o,i[1]*o]})},gi=(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]})},na=(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]})},Yi=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_height_factor:t.buildingHeightAnimator.getDefaultBuildingHeight()})},Qi=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_z_offset:0})},Qd=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_z_offset:-1e-5})},ft=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_sr2d_texture:0})},oa=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_sr2d_texture1:1})},sa=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_vec4_border_color:[0,0,0,0]})},aa=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_vec4_space_color:[0,0,0,0]})},Jd=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_identify_opacity:e.iconIdentifyOpacity})},ra=(s,e,t)=>{const{renderer:i}=t,{labelingTextureBuffer:o,spriteLabelingTextureBuffer:a}=i;let r=e.isLabelingDepthTestDisabled;if(!r){const c=o.getDepthAttachment(),d=o.getTexture();!(c instanceof w)||!d?r=!0:(t.renderer.enableTexture(d,cl),t.renderer.enableTexture(c,dl))}const l=a.getTexture();l&&(t.renderer.enableTexture(l,_l),t.renderer.bindShaderProgram(s,{u_color_text_sprite_labeling:_l})),t.renderer.bindShaderProgram(s,{u_bool_depth_test_disable:r}),r||t.renderer.bindShaderProgram(s,{u_color_tex_labeling:cl,u_depth_tex_labeling:dl})};function yi(...s){return(e,t,i)=>{s.forEach(o=>o(e,t,i))}}function Le(...s){return(e,t,i,o,a)=>{s.forEach(r=>r(e,t,i,o,a))}}const Ad=1,e_=2,t_=4,oe=(s,e,t,i,o)=>{let a=n.ReservedLightingMode.none,r=n.DEFAULT_LIGHTING_MODES[a],l=0;const c=la(i,t,e);c&&(r=c.lightConfig,a=c.lightingMode,l=(a===n.ReservedLightingMode.none||o?0:Ad)+(i.receiveShadows!==!1&&r.shadowLightIndex===0?e_:0)+(i.receiveShadows!==!1&&r.shadowLightIndex===1?t_:0));const d=t.renderer.getUbo(a);if(d&&t.renderer.isUboSupported()){d.bind(s),t.renderer.bindShaderProgram(s,{u_int_light_flags:l});return}t.renderer.bindShaderProgram(s,{u_int_light_flags:l,u_vec3_light_dir1_direction:r.dir1Direction,u_vec4_light_dir1_color:r.dir1ColorIntensity,u_vec3_light_dir2_direction:r.dir2Direction,u_vec4_light_dir2_color:r.dir2ColorIntensity,u_vec4_ambient_color:r.ambientColorIntensity})},mt=(s,e,t,i)=>{const o=n.makeBinderContext(e.styleZoom,e.styleState,[],!1),a=n.resolveNumber(i.style.nearCameraFade,o);t.renderer.bindShaderProgram(s,{u_sdtr_distance:a})},Ji=(s,e,t,i)=>{const o=n.makeBinderContext(e.styleZoom,e.styleState,[],!1),a=i.style.showRatio,r=n.resolveExpression(a,o);t.renderer.bindShaderProgram(s,{u_float_show_ratio:r})};function la(s,e,t){var r;const i=e.styleManager.getStyle(t.handyStyleId);if(!i||!i.light.lightingModesResolved)return null;let o=(r=s.lightingMode)!=null?r:i.light.defaultLightMode;s.type==="gltfModel"&&s.style.ignoreGlobalLighting&&(o=n.ReservedLightingMode.none);let a=i.light.lightingModesResolved[o];return a||(a=i.light.lightingModesResolved[i.light.defaultLightMode]),{lightingMode:o,lightConfig:a}}class G{constructor(e,t,i=null){this.isDirty=!1,this._vao=null,this._vaoExt=null,this._gl=null,this.attributesAliases={},this._attributes=t,this._shaderProgram=e,this.indicesBuffer=i}static merge(e){const t=e[0],i={},o={};for(const r of e)Object.assign(i,r._attributes),Object.assign(o,r.attributesAliases);const a=new G(t._shaderProgram,i,t.indicesBuffer);return a.setAttributesAliases(o),a}copy(){const e=new G(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 a in i){const l=this.attributesAliases[a]||a,c=o[l];if(!c)continue;const d=i[a];if(d.index!==!0)for(let _=0;_<d.locationsCount;_++)e.enableVertexAttribArray(d.location+_);c.bind(d.location,void 0,t,d.locationsCount)}this.indicesBuffer&&this.indicesBuffer.bind()}_bind(e,t,i){this._vao?(this.isDirty&&this.updateDirtyBuffers(),this._glBindVertexArray(this._vao)):this._prepare(e,t,i)}_prepare(e,t,i){this._gl=e,t&&(this._vaoExt=t),this._vao=this._glCreateVertexArray(),this._glBindVertexArray(this._vao),this.setAttributes(e,i)}_glCreateVertexArray(){const e=this._gl,t=this._vaoExt;return e&&this._isWebGL2(e)?e.createVertexArray():t?t.createVertexArrayOES():null}_glBindVertexArray(e){const t=this._gl,i=this._vaoExt;t&&this._isWebGL2(t)?t.bindVertexArray(e):i?i.bindVertexArrayOES(e):t&&this._shaderProgram.bind(void 0,this._attributes)}_glDeleteVertexArray(e){const t=this._gl,i=this._vaoExt;t&&this._isWebGL2(t)?t.deleteVertexArray(e):i&&i.deleteVertexArrayOES(e)}_isWebGL2(e){return typeof window!="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 a=i[o]||o,r=t[a];r!=null&&r.isDirty&&r.commitData()}this.isDirty=!1}}const i_=(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 G(e,{a_vec3_vertex:i})},n_=(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 G(e,{a_vec3_vertex:i,a_float_mix_factor:o})},o_=(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 G(e,{a_vec3_vertex:i})},s_=(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 G(e,{a_vec2_vertex:i,a_vec2_texcoord:o})},a_=(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 G(e,{a_vec3_vertex:i,a_vec4_identifier:o})},r_=(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 G(e,{a_vec3_vertex:i,a_vec4_normals:o})},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}),a=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1});return new G(e,{a_vec3_vertex:i,a_vec4_normals:o,a_float_height:a,a_float_abs_z:r})},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}),a=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:16,normalized:!0});return new G(e,{a_vec2_vertex:i,a_vec4_normals:o,a_float_height:a,a_float_abs_z:r,a_vec4_identifier:l})},d_=(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}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1});return new G(e,{a_vec3_vertex:i,a_vec4_normals:o,a_vec2_shift:a})},__=(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}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0});return new G(e,{a_vec3_vertex:i,a_vec4_normals:o,a_vec4_identifier:a})},u_=(s,e)=>{const t=n.LineGenerator.sinks.patterned.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0});return new G(e,{a_vec2_vertex:i,a_vec2_widen:o,a_float_texture:a,a_vec4_identifier:r})},h_=(s,e)=>{const t=n.LineGenerator.sinks.patterned3d.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:16,normalized:!0});return new G(e,{a_vec2_vertex:i,a_vec2_widen:o,a_float_texture:a,a_float_height:r,a_vec4_identifier:l})},ca=(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.Short,stride:t,offset:6,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:10,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:20,normalized:!1}),d=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:24,normalized:!0});return new G(e,{a_vec3_vertex:i,a_vec2_texture_widen:a,a_vec2_widen:o,a_float_vertex_distance:r,a_float_component_distance:l,a_float_object_length:c,a_vec4_identifier:d})},da=(s,e)=>{const t=n.DashedLineGenerator.sinks.stroke3d.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:20,normalized:!1}),d=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:24,normalized:!1}),_=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:28,normalized:!0});return new G(e,{a_vec3_vertex:i,a_vec2_texture_widen:a,a_vec2_widen:o,a_float_vertex_distance:r,a_float_component_distance:l,a_float_object_length:c,a_float_height:d,a_vec4_identifier:_})},_a=(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:6,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:32,offset:10,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:32,offset:14,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 G(e,{a_vec3_vertex:i,a_vec2_offset:o,a_vec2_texcoord:a,a_vec2_check_offset:r,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:6,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:32,offset:20,normalized:!0});return new G(e,{a_vec3_vertex:i,a_vec2_offset:o,a_vec4_identifier:a})},Ai=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:28,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:28,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:28,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:28,offset:20,normalized:!1});return new G(e,{a_vec4_position:i,a_vec2_offset:a,a_vec2_texcoord:o,a_vec2_style_zoom_limits:r})},ua=(s,e)=>{const t=n.MeshGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Byte,stride:t,offset:11,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),d=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0}),_=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!1}),u=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:28,normalized:!0});return new G(e,{a_vec2_vertex:i,a_float_z:o,a_vec3_normal:a,a_float_gradient:r,a_vec2_dem_position:l,a_float_abs_z:c,a_vec4_identifier:d,a_float_is_pivot:_,a_vec4_color:u})},m_=(s,e)=>{const t=n.MeshGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Byte,stride:t,offset:11,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),d=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!1}),_=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:24,normalized:!0});return new G(e,{a_vec2_vertex:i,a_float_z:o,a_vec3_normal:a,a_float_gradient:r,a_vec2_dem_position:l,a_float_abs_z:c,a_vec4_identifier:_,a_float_is_pivot:d})},ha=(s,e)=>{const t=n.MeshGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!1});return new G(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a,a_float_abs_z:r,a_float_is_pivot:l})},en=(s,e)=>{const t=n.MeshGenerator.sinks.inverse.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:8,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!1});return new G(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a,a_float_abs_z:r,a_float_is_pivot:l})},p_=(s,e)=>{const t=n.MeshGenerator.sinks.stroke.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:16,normalized:!1});return new G(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_direction_distance:a,a_vec2_dem_position:r,a_float_abs_z:l,a_float_is_pivot:c})},fa=(s,e)=>{const t=n.PolygonExtrusionGenerator.sinks.sideFill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1}),r=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 G(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a,a_vec4_color:l,a_float_elevation:r})},v_=(s,e)=>{const t=n.PolygonExtrusionGenerator.sinks.sideTexture.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!1}),c=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:24,normalized:!0});return new G(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a,a_vec2_wall_size:r,a_vec2_quad_fraction:l,a_vec4_color:c})},ma=(s,e)=>{const t=n.PolygonExtrusionGenerator.sinks.topFill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:12,normalized:!1}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!0});return new G(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a,a_vec4_color:r})},pa=s=>(e,t)=>{const i=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:s,offset:0,normalized:!0}),o=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:s,offset:4,normalized:!1}),a=new n.BufferChannel(e,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:s,offset:8,normalized:!0}),r=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.Short,stride:s,offset:12,normalized:!1});return new G(t,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:a,a_vec2_dem_position:r})},va=s=>(e,t)=>{const i=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:s,offset:0,normalized:!0}),o=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:s,offset:4,normalized:!1}),a=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.Short,stride:s,offset:12,normalized:!1}),r=new n.BufferChannel(e,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:s,offset:16,normalized:!0});return new G(t,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:r,a_vec2_dem_position:a})},ga=s=>(e,t)=>{const i=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:s,offset:0,normalized:!0}),o=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:s,offset:4,normalized:!1}),a=new n.BufferChannel(e,{itemSize:2,dataType:n.Buffer.Short,stride:s,offset:12,normalized:!1});return new G(t,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a})},g_=(s,e)=>{const t=n.LineExtrusionGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0});return new G(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a,a_vec4_color:r})},y_=(s,e)=>{const t=n.LineExtrusionGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1});return new G(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a})},ya=(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}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:24,offset:8,normalized:!1}),r=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 G(e,{a_vec3_vertex:i,a_float_z:o,a_vec2_normal:a,a_vec2_normal_delta:r,a_vec3_direction:l,a_float_distance:c,a_vec2_dem_position:d,a_vec4_color:_})},x_=(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:6,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:36,offset:10,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:14,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:18,normalized:!1}),c=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:28,normalized:!0});return new G(e,{a_vec3_vertex:i,a_vec2_offset:o,a_vec2_texcoord:a,a_vec2_range:r,a_vec2_check_offset:l,a_vec4_tex_identifier:c})},b_=(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:6,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:36,offset:10,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:14,normalized:!1}),l=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:32,normalized:!0});return new G(e,{a_vec3_vertex:i,a_vec2_offset:o,a_vec2_texcoord:a,a_vec2_range:r,a_vec4_identifier:l})},w_=(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:6,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:36,offset:10,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:14,normalized:!1}),l=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:24,normalized:!0});return new G(e,{a_vec3_vertex:i,a_vec2_offset:o,a_vec2_texcoord:a,a_vec2_range:r,a_vec4_identifier:l})},S_=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:16,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:16,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:16,offset:12,normalized:!0});return new G(e,{a_vec4_position:i,a_vec2_offset:o,a_vec4_identifier:a})},xa=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:12,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:12,offset:8,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:12,offset:10,normalized:!1});return new G(e,{a_vec2_position:i,a_vec2_direction:o,a_vec2_widen_direction:a})},T_=(s,e)=>{const t=n.BuildingModelGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1});return new G(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_texcoord:a,a_vec2_dem_position:r})},M_=(s,e)=>{const t=n.BuildingModelGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1});return new G(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:a,a_vec2_dem_position:r})},E_=(s,e)=>{const t=n.BuildingModelGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),r=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!0});return new G(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_identifier:r,a_vec2_dem_position:a})},I_=(s,e)=>{const t=n.BuildingModelGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1});return new G(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_dem_position:a})},C_=(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 G(e,{a_vec3_vertex:i,a_vec4_direction_distance:o})},lo=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:20,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:20,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:20,offset:8,normalized:!1}),r=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 G(e,{a_vec2_vertex:i,a_float_z:o,a_vec4_direction_distance:a,a_vec2_dem_position:r,a_vec4_color:l})},ba=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:36,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:36,offset:4,normalized:!0}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.Byte,stride:36,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:36,offset:16,normalized:!1}),c=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:36,offset:20,normalized:!1}),d=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:36,offset:24,normalized:!1}),_=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:36,offset:28,normalized:!1}),u=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:36,offset:32,normalized:!0});return new G(e,{a_vec2_vertex:i,a_vec2_segment_end:o,a_vec4_texture_widen_arrow_widen:a,a_vec2_widen:r,a_vec2_direction:l,a_float_distance_from_start:c,a_float_object_length:d,a_float_type:_,a_vec4_identifier:u})},co=(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:6,normalized:!1});return new G(e,{a_vec3_vertex:i,a_vec2_widen:o})},P_=(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:6,normalized:!1}),a=new n.BufferChannel(s,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:t,offset:12,normalized:!0});return new G(e,{a_vec3_vertex:i,a_vec2_widen:o,a_vec4_identifier:a})},L_=(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 G(e,{a_vec2_vertex:i,a_vec2_texcoord:o})},B_=(s,e)=>{const t=n.HeatmapGenerator.sinks.framebuffer.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!1});return new G(e,{a_vec2_position:i,a_vec2_widen:a,a_float_weight:o})},z_=(s,e)=>{const t=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:0,offset:0,normalized:!1});return new G(e,{a_vec2_position:t})},wa=(s,e)=>{const i=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Float,stride:12,offset:0});return new G(e,{a_vec3_position:i})},tn=(s,e)=>new G(e,{a_vec2_position:s}),xi=(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 G(e,{a_vec2_vertex:i,a_float_height:o})},R_=(s,e)=>{const t=n.DemGenerator.sinks.flatBottom.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:t,offset:8,normalized:!0});return new G(e,{a_vec2_vertex:i,a_vec2_centroid:o,a_vec2_extender:a})},_o=(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 G(e,{a_vec2_vertex:i,a_vec2_texcoord:o})},nn=s=>(e,t,i,o)=>{const a=n.GltfModelGenerator.sinks.instances.stride,r=new n.BufferChannel(e,{itemSize:3,dataType:n.Buffer.UnsignedShort,stride:a,offset:0,normalized:!0,instanceDivisor:1}),l=new n.BufferChannel(e,{itemSize:9,dataType:n.Buffer.Float,stride:a,offset:8,instanceDivisor:1}),c=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:a,offset:44,normalized:!1,instanceDivisor:1}),d=new n.BufferChannel(e,{itemSize:1,dataType:n.Buffer.Float,stride:a,offset:48,normalized:!1,instanceDivisor:1}),_=new n.BufferChannel(e,{itemSize:4,dataType:n.Buffer.UnsignedByte,stride:a,offset:s?56:52,normalized:!0,instanceDivisor:1});return new G(t,I({a_vec3_instance_position:r,a_float_instance_height:d,a_mat3_instance_matrix:l,a_vec4_instance_localid:_,a_float_abs_z:c},o),i)},uo=(s,e)=>{const t=n.MapMeshGenerator.sinks.fill.stride,i=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:t,offset:0,normalized:!0}),o=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:4,normalized:!1}),a=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:8,normalized:!1}),r=new n.BufferChannel(s,{itemSize:3,dataType:n.Buffer.Byte,stride:t,offset:12,normalized:!1}),l=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Byte,stride:t,offset:15,normalized:!1}),c=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Short,stride:t,offset:16,normalized:!1}),d=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.Float,stride:t,offset:16,normalized:!1}),_=new n.BufferChannel(s,{itemSize:1,dataType:n.Buffer.UnsignedByte,stride:t,offset:20,normalized:!1});return new G(e,{a_vec2_vertex:i,a_float_z:o,a_vec2_extender:a,a_vec3_normal:r,a_float_gradient:l,a_vec2_dem_position:c,a_float_abs_z:d,a_float_is_pivot:_})},F_=(s,e)=>{const t=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Float,stride:0,offset:0,normalized:!1});return new G(e,{a_vec2_vertex:t})},bi=(s,e)=>{const t=new n.BufferChannel(s,{itemSize:2,dataType:n.Buffer.Byte,stride:0,offset:0,normalized:!1});return new G(e,{a_vec2_vertex:t})},D_=(s,e)=>new G(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})}),Qt=32,Sa=1/0,O_="raster";class Ta extends n.TileObjectBase{constructor(e,t,i){var a;super(O_),this.children=[],this.identifyChildren=[];const o=this;this.setTileCoords(e,t.map.state),(a=t.renderer.symbolSettingsList.dem.mesh)==null||a.forEach(r=>{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:Qt*Qt*6,attributesHash:"",layerSettings:r,vao:i.mesh,canRender:!0,renderingProperties:{flatTexture:null,hillshadeTexture:null,flatIdentifyTexture:null}};r.identify?o.identifyChildren.push(l):r.depthTest?o.depthTestChildren.push(l):r.shadow?o.shadowChildren.push(l):r.dem?o.demChildren.push(l):r.demGround?o.demGroundChildren.push(l):o.children.push(l)})}setTileCoords(e,t){const i=e[2],o=e[3],a=n.tileZoomToSize(i);this.coords=e,this.size=a,this.zoomLevel=i,this.detailLevel=o,this.mvpMatrices.clear(),this.demMatrices.clear(),this.flatMapTexMatrices.clear(),this.syncReplicas(t)}syncReplicas({visibleMapReplicas:e}){const t=Math.pow(2,this.coords[2]),i=this.size/Qt;this.bounds.clear(),this.modelMatrices.clear(),e.forEach(o=>{const a=[this.coords[0]+o*t,this.coords[1],this.coords[2],this.coords[3]],r=n.tileCoordsToMapPoint(a);r[0]-=i,r[1]-=i,this.bounds.set(o,{min:[r[0],r[1]],max:[r[0]+this.size,r[1]+this.size]});const l=n.create$2();n.fromTranslationScale(l,r,n.fromValues(this.size+i,this.size+i,n.tileHeight)),this.modelMatrices.set(o,l)}),this.needSync=!1}}class N_{constructor(e,t){var a;this.meshTiles=new Map,this.destroyed=!1,this.modules=e.modules,this.maxZoom=(a=t==null?void 0:t.maxZoom)!=null?a:Sa;const i=[];for(let r=0;r<Qt;r++)for(let l=0;l<Qt;l++)i.push(l,r,l+1,r,l,r+1),i.push(l,r+1,l+1,r,l+1,r+1);const o=n.maxUint16Value/Qt;for(let r=0;r<i.length;r++)i[r]*=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:tn(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=Sa){e!==this.maxZoom&&(this.maxZoom=e,this.update())}update(){if(this.destroyed)return;const e=this.modules.map.state;e.needReplicasUpdate&&this.meshTiles.forEach(a=>{a.needSync=!0});const t=Math.trunc(e.styleZoom),i=Math.min(t,Math.min(this.maxZoom,t)),o=n.findVisibleTiles(this.modules.map.state,this.modules,i,0,i,void 0,void 0,void 0,!0).reduce((a,r)=>(a.set(n.coordsToKey(r),r),a),new Map);this.meshTiles.forEach((a,r)=>{o.has(r)||this.meshTiles.delete(r)}),o.forEach((a,r)=>{this.meshTiles.has(r)||this.meshTiles.set(r,new Ta(a,this.modules,this.vaos))})}updateStyleId(){this.meshTiles.forEach(e=>this.updateTileStyleId(e))}updateTileStyleId(e){e.children.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId}),e.identifyChildren.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId}),e.depthTestChildren.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId}),e.shadowChildren.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId}),e.demChildren.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId}),e.demGroundChildren.forEach(t=>{t.attributes.styleId=this.modules.map.state.handyStyleId})}}class k_{constructor(e,t,i){this.id=e,this.modules=t,this.options=i,this.type="dem",this.tree=n.rbush(n.DEM_TREE_SIZE),this.tileSize=n.DEM_ELEVATION_TILE_SIZE,this.minElevation=0,this.revision=0,this.tileLoader=new n.BaseTileLoader("arrayBuffer"),this.attributes={},this.tiles=new Map,this.textureIndices=new Map,this.url=o=>{const[a,r,l]=n.tileCoordsToOSM(o);return this.options.url(a,r,l)}}abortTileFetches(e){this.tileLoader.abortRequests(e.map(n.coordsToKey))}deleteTiles(e){for(const t of e){const i=n.coordsToKey(t);if(this.tiles.get(i)){const a=n.getTileBounds(t);this.tree.remove({minX:a.min[0],minY:a.min[1],maxX:a.max[0],maxY:a.max[1]},(r,l)=>i===l.key),this.updateRevision()}this.tiles.delete(i);const o=this.textureIndices.get(i);o!==void 0&&this.modules.imageManager.deleteTexture(o),this.updateMinElevation()}}fetchTiles(e){return e.map(t=>this.fetchTile(t))}generateTile(e,t){return K(this,null,function*(){const i=[],o=[],a=n.coordsToKey(t),r=this.tiles.get(a);if(!r)return Promise.resolve({results:i,transferable:o});const l=this.modules.map.state.handyStyleId,{collector:c}=this.modules,d=n.tileZoomToSize(t[2]),_=r.bounds;this.tree.insert(ce(I({key:a,minX:_.min[0],minY:_.min[1],maxX:_.max[0],maxY:_.max[1],cellSize:d/n.DEM_ELEVATION_TILE_SIZE},r),{tree:null,bounds:_,generated:i})),this.updateMinElevation(),this.updateRevision();do n.DemGenerator.generateMeshElevation(c,r.mesh,l,n.DEM_STYLE_LAYER_ID);while(c.isOverloaded());const u=c.getAccumulatedData();return i.push({regionId:0,metatileHash:-1,styleId:l,collectorOutput:u}),o.push(...u.transferable),Promise.resolve({results:i,transferable:o})})}unpackRaw(e,t){const[i,o,a,r]=t,l=new Uint8Array(e),c=new Float32Array(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),a,r])),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,a,r])}}}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e}getId(){return this.id}destroy(){const{imageManager:e}=this.modules;this.tileLoader.destroy(),this.tiles.clear(),this.tree.clear(),this.textureIndices.forEach(t=>e.deleteTexture(t)),this.textureIndices.clear()}getElevation(e){const t=this.getElevationTile(e);if(t)return n.getElevationFromTile(t,e)}getElevationTile(e){const t=n.normalizeMapPoint(e);return this.tree.search({minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}).reduce((o,a)=>!o||o.cellSize>a.cellSize?a:o,void 0)}getMinElevation(){return this.minElevation}updateMinElevation(){const e=this.modules.map.state;if(!e.demMode)return;const t=this.modules.camera.position[2],i=n.tetragonBounds(e.tilesBounds);if(e.elevation!==void 0){const a=e.elevation*n.MAP_POINTS_IN_METER/t+1,r=Math.max(e.pitch/e.maxPitch*30,4);n.scale$1(i,Math.min(a,r))}const o=this.tree.search({minX:i.min[0],minY:i.min[1],maxX:i.max[0],maxY:i.max[1]});e.styleZoom-So>1?this.minElevation=o.reduce((a,r)=>{if(r.data){const l=n.intersection(i,r.bounds);n.sub(l.min,l.min,r.bounds.min),n.sub(l.max,l.max,r.bounds.min),n.scale$2(l.min,l.min,1/r.cellSize),n.scale$2(l.max,l.max,1/r.cellSize);for(let c=Math.trunc(l.min[0]);c<l.max[0];c++)for(let d=Math.trunc(l.min[1]);d<l.max[1];d++){const _=c+(n.DEM_ELEVATION_TILE_SIZE-1-d)*n.DEM_ELEVATION_TILE_SIZE,u=r.data[_];a=a===void 0?u:Math.min(a,u)}}return a},void 0):this.minElevation=o.reduce((a,r)=>a===void 0?r.minZ:Math.min(a,r.minZ),void 0)}getRevision(){return this.revision}fetchTile(e){const t=n.coordsToKey(e),i=[{regionId:0,metatileHash:-1}];if(this.tiles.has(t))return Promise.resolve(i);const o=this.url(e);return this.tileLoader.fetch(e,()=>o).then(a=>(a.rejected||this.tiles.set(t,a.data&&a.data.byteLength?this.unpackRaw(a.data,e):void 0),i),()=>Promise.resolve(void 0))}updateRevision(){this.revision++}getMesh(e){const t=this.tileSize,i=t*t,o=new Uint16Array(i*2),a=new Uint16Array(i*6);let r=0;for(let l=0;l<t;l++)for(let c=0;c<t;c++){const d=l*t+c;o[2*d+0]=c/(t-1)*n.maxTilePoint,o[2*d+1]=(1-l/(t-1))*n.maxTilePoint,c<t-1&&l<t-1&&(a[r++]=d+1,a[r++]=d,a[r++]=d+t,a[r++]=d+1,a[r++]=d+t,a[r++]=d+t+1)}return{positions:o,heights:e,indices:a}}}class U_{constructor(e,t,i){this.id=e,this.modules=t,this.options=i,this.type="dem",this.tree=n.rbush(n.DEM_TREE_SIZE),this.minElevation=0,this.revision=0,this.worker=new t.workers.parser.MeshElevationSource(this.options),this.attributes={},this.tiles=new Map}abortTileFetches(e){this.worker.abortTileFetches(e)}deleteTiles(e){this.worker.deleteTiles(e);for(const t of e){const i=n.coordsToKey(t),o=this.tiles.get(i);o&&(this.tree.remove(o,(a,r)=>i===r.key),this.tiles.delete(i))}this.updateMinElevation()}fetchTiles(e){return this.worker.fetchTiles(e)}generateTile(e,t){return K(this,null,function*(){const i=n.coordsToKey(t),{tree:o,results:a,minZ:r,maxZ:l}=yield this.worker.generateTile(e.handyStyleId,t),c=n.getTileBounds(t),d={generated:a,key:i,minX:c.min[0],minY:c.min[1],maxX:c.max[0],maxY:c.max[1],cellSize:n.tileZoomToSize(t[2])/n.DEM_ELEVATION_TILE_SIZE,bounds:c,minZ:r,maxZ:l,tree:o};return this.tiles.set(i,d),this.tree.insert(d),this.updateMinElevation(),this.updateRevision(),{results:a}})}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e}getId(){return this.id}destroy(){this.tiles.clear(),this.tree.clear()}getElevation(e){const t=this.getElevationTile(e);if(t)return n.getElevationFromTile(t,e)}getElevationTile(e){const t=n.normalizeMapPoint(e);return this.tree.search({minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}).reduce((o,a)=>!o||o.cellSize>a.cellSize?a:o,void 0)}getMinElevation(){return this.minElevation}updateMinElevation(){const e=this.modules.map.state;if(!e.demMode)return;const t=n.tetragonBounds(e.tilesBounds),i=this.tree.search({minX:t.min[0],minY:t.min[1],maxX:t.max[0],maxY:t.max[1]});this.minElevation=i.reduce((o,a)=>o===void 0?a.minZ:Math.min(o,a.minZ),void 0)}getRevision(){return this.revision}updateRevision(){this.revision++}}const Xe=new Float64Array(16);class ho{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(Xe,this.texMatrix),this.viewport.forEach(o=>{n.transformMat4$1(o,o,Xe),o[0]-=t[0],o[1]-=t[1],o[2]-=t[2],o[2]>=0&&(o[2]=-1),n.normalize(o,o);const a=-t[2]/o[2];o[0]=t[0]+o[0]*a,o[1]=t[1]+o[1]*a,o[2]=t[2]+o[2]*a})}}class H_{constructor(e){this.destroyed=!1,this.modules=e.modules,this.textures=[]}update(){if(this.destroyed)return;const{center:e,padding:t,rotation:i,size:o,viewport:a,extendedTilesBounds:r,zoom:l,cameraConfig:c,globeMode:d}=this.modules.map.state,_=n.getLineConstants(r[0],r[1]),u=n.pointToLineDistance(r[2],_);this.textures=[];const h=n.degToRad(45),f=Math.min(this.modules.map.state.pitch,h),m=new n.Camera({pitch:f,center:e,padding:t,rotation:i,size:o,viewport:a,zoom:l,cameraConfig:c,globeMode:d,styleState:{}}),p=n.clamp(Math.pow(this.modules.map.state.pitch/h,3),0,1),[v,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(Xe,[0,-b,0],[1/Oe[0],1/Oe[1],1]),n.multiply(Xe,Xe,m.viewProjectionMatrix),this.textures.push(new ho(Xe,m.position,0)),n.pointToLineDistance(this.textures[0].viewport[2],_)>=u)return!0;if(y<b){const S=Math.max(Math.abs(y-b)/2,1);n.fromTranslationScale(Xe,[0,2/S+1,0],[1/Oe[0],Oe[1]/S,1]),n.multiply(Xe,Xe,m.viewProjectionMatrix),this.textures.push(new ho(Xe,m.position,1))}b+=1;const T=Math.pow(o[1]/749,2);[1.4,3.2,12,31].some((S,L)=>{S=(S-1)*p*T+1,n.fromTranslationScale(Xe,[0,-(b*S+1),0],[1/Oe[0],S/Oe[1],1]),n.multiply(Xe,Xe,m.viewProjectionMatrix),b+=2/S;const E=this.textures.push(new ho(Xe,m.position,L));if(n.pointToLineDistance(this.textures[E-1].viewport[2],_)>=u)return!0})}destroy(){this.textures=[]}}const fo={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}},de=s=>{if(typeof s=="function")return t=>{const i=s(t);return Object.assign({},fo,i)};const e=Object.assign({},fo,s);return()=>e},Me=de({}),mo=de({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),G_=de({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}}),Jt=de({depthMask:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),V_=de({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA},cullFace:!1}),Ne=de({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),j_=de({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}),Z_=de({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.SRC_ALPHA,dfactor:n.BLEND_FUNC.ONE}}),Ma=de({depthMask:!1,depthTest:!1,colorMask:[!0,!1,!1,!0]}),W_=de({depthMask:!1,depthTest:!1}),xt=de({depthMask:!1,depthTest:!1}),$_=de({depthMask:!1}),on=de({colorMask:[!1,!1,!1,!1]}),X_=de({colorMask:[!1,!1,!1,!1],depthFunc:n.DEPTH_FUNC.ALWAYS}),Ea=de({blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),K_=de({depthFunc:n.DEPTH_FUNC.EQUAL,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),po=de({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),vo=de({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}}),go=de({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}}),Ia=de({polygonOffsetFill:!0,polygonOffset:{factor:1,units:2},blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}}),sn=de({cullFaceMode:n.CULL_FACE_MODE.BACK}),an=de({cullFace:!1}),Ca=de({depthMask:!1,depthTest:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE}}),q_=de({depthTest:!1,cullFace:!1}),Y_=de({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}}),Pa=de({colorMask:[!0,!0,!0,!0],depthMask:!0}),Q_=de({colorMask:[!0,!0,!0,!0],depthMask:!1}),J_=de({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}}),A_=de({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}}),eu=de({depthMask:!0,depthTest:!0}),La=de(s=>s.map.getFeatureFlag("transparentBuildingsOff")?Me(s):K_(s)),tu=de(()=>({depthFunc:n.DEPTH_FUNC.LEQUAL,depthMask:!1,blend:!0,blendFunc:{sfactor:n.BLEND_FUNC.ONE,dfactor:n.BLEND_FUNC.ONE_MINUS_SRC_ALPHA}})),yo=n.reserveTextureIndex(),xo=n.reserveTextureIndex(),bo=n.reserveTextureIndex(),wo=n.reserveTextureIndex(),It=64,Ba=5,So=12,za=5,Ra=15,iu=18,nu=12,ou=18,su=.1,au=.3,Oe=[1.7,1],ru=300,To=.001,Fa=1,lu=n.tileZoomToSize(n.tiles.maxRegionalZoom),cu={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"]}},rn=n.create$1(),Ue=new Float64Array(16);class du{constructor(e){this.demTextureMatrix=new Float64Array(16),this.demCorrectedFbVpToDemTex=new Float32Array(16),this.demTexToCorrectedTex=new Float32Array(16),this.correctedTexToDemTex=new Float32Array(16),this.isDemCorrectionEnabled=!1,this.demCorrectedScale=1,this.demFbVpMatrix=new Float64Array(16),this.demCorrectedFbVpMatrix=new Float64Array(16),this.demFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.correctedDemFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.flatFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.identifyFlatFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.hillshadeRampTextureId=NaN,this.hillshadeFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.groundFramebufferId=n.INVALID_FRAMEBUFFER_ID,this.isGroundBufferValid=!1,this.lastStyleId=NaN,this.disableAnimation=!1,this.isAnimationStarted=!1,this.tilesRevision=0,this.tileSet=n.dem.tileSet,this.modules=e,this.enabled=!1,this.sources=[],this.sourcesRevision=[],this.tileLayers=[],this.terrainAnimationScaleCoef=To,this.reliefTileType="vector",this.elevationSourceType="irregular",this.groundBuffer=new Float32Array,this.differ=new n.Differ([])}enable(){if(this.isTerrainSupported===void 0&&(this.isTerrainSupported=Xs()),this.enabled||!this.isTerrainSupported)return;this.enabled=!0,this.differ=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"demMode",type:"boolean"},{path:"elevation",type:"number"},{path:"minElevation",type:"number"}]),this.demFramebufferId=this.createDemFramebuffer(),this.correctedDemFramebufferId=this.createCorrectedDemFramebuffer(),this.hillshadeFramebufferId=this.createHillshadeFramebuffer(),this.flatFramebufferId=this.createFlatFramebuffer(),this.identifyFlatFramebufferId=this.createFlatIdentifyFramebuffer(),this.groundFramebufferId=this.createGroundFramebuffer(),this.fullscreenBuffer=this.modules.renderer.createBuffer(new Uint16Array([[0,0,0,0],[1,0,1,0],[0,1,0,1],[0,1,0,1],[1,0,1,0],[1,1,1,1]].reduce((t,i)=>{const[o,a,r,l]=i;return t.push(o*n.maxUint16Value,a*n.maxUint16Value,n.packTexCoords(r),n.packTexCoords(l)),t},[]))),this.hillshadeVao=_o(this.fullscreenBuffer,this.modules.renderer.getShaderProgram("demHillshade"));const e=this.modules.renderer.getShaderProgram("demElevationCopy");this.copyDemVao=_o(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,a;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(),(a=this.fullscreenBuffer)==null||a.remove(),this.modules.styleManager.setFramebufferId(this.modules.map.state.handyStyleId,n.DEM_STYLE_LAYER_ID,{hillshade:n.INVALID_FRAMEBUFFER_ID,flatBottom:n.INVALID_FRAMEBUFFER_ID}),this.modules.renderer.removeFramebuffer(this.hillshadeFramebufferId),this.modules.renderer.removeFramebuffer(this.demFramebufferId),this.modules.renderer.removeFramebuffer(this.correctedDemFramebufferId),this.modules.renderer.removeFramebuffer(this.flatFramebufferId),this.modules.renderer.removeFramebuffer(this.groundFramebufferId),this.enabled=!1;const e=this.modules.map.state;this.terrainAnimationScaleCoef=To,this.isAnimationStarted=!1,n.exist("changeScale",e)&&n.stop("changeScale",e)}update(){var o,a,r,l;if(!this.enabled)return;const e=this.modules.map.state;this.lastStyleId!==e.handyStyleId&&(this.updateRampTextureId(),(o=this.meshSource)==null||o.updateStyleId(),(a=this.hillshadeTile)==null||a.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(),(r=this.flatMapSource)==null||r.update(),(l=this.meshSource)==null||l.update(),this.updateDemFramebufferMatrix(),this.modules.renderer.addRerenderEvent()),this.disableAnimation||(this.isAnimationStarted?n.update("changeScale",{step:(c,d)=>{d===Fa&&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(a=>a.type===n.PreLabelType.Point),t)break;if(!t)return;n.vertexTilePointToMapPoint(rn,t.vertices,0,n.createTileInfo(t.tileCoords));let i;for(let o=this.sources.length-1;o>=0;o--){const r=this.sources[o].getElevationTile(rn);if(r!==void 0){i=r;break}}if(i)return i.key}enrichWithElevation(e){var t;if(this.enabled)for(const i of e){let o=null;for(const a of i.labels)a.type===n.PreLabelType.Point&&(o||(o=n.createTileInfo(a.tileCoords)),n.vertexTilePointToMapPoint(rn,a.vertices,0,o),a.demElevation=(t=this.getElevation(rn))!=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(yo),this.modules.renderer.disableTexture(wo),this.modules.renderer.disableTexture(xo),this.modules.renderer.disableTexture(bo)}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,a=e[1]-this.modules.map.state.viewport.top;if(o<0||o>i[0]-1||a<0||a>i[1]-1)return;const l=((i[1]-a-1)*i[0]+o)*4;if(this.groundBuffer[l+3]===0)return;const[d,_]=n.Mercator.toGeo([this.groundBuffer[l],this.groundBuffer[l+1]]);return[d,_,this.groundBuffer[l+2]]}startVerticalScaleAnimation(){const e=this.modules.map.state;this.modules.styleManager.getStyle(e.handyStyleId)&&(this.isAnimationStarted=!0,n.start("changeScale",{easing:"linear"},e,To,Fa,ru,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=_u(this.modules.map.state,e.dem.style.shadingPalette,256);Number.isNaN(this.hillshadeRampTextureId)?this.hillshadeRampTextureId=this.modules.imageManager.addPreparedTexture(t):this.modules.imageManager.updatePreparedTexture(this.hillshadeRampTextureId,t)}}updateClearColor(){const e=this.modules.styleManager.getStyle(this.modules.map.state.handyStyleId);if(e!=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 H_(this.modules.map)}addRegularElevationSources(){var r;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:Ba,maxZoom:8,attributes:{}}),this.addElevationSource({url:t,minZoom:i?9:Ba,maxZoom:So,attributes:{}}),this.meshSource=new N_(this.modules.map,{maxZoom:this.meshMaxZoom});const o=this.hillshadeVao,a=(r=this.modules.renderer.symbolSettingsList.dem.hillshade)==null?void 0:r[0];if(o&&a){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:a,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=cu[this.tileSet])!=null?o:this.modules.map.state;this.addIrregularElevationSource({tileServer:e,tileProtocol:t,subdomains:i,tileSet:this.tileSet,minZoom:za,maxZoom:Ra})}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 k_(n.sourceUuid(),this.modules,e);this.sources.push(t),this.sourcesRevision.push(t.getRevision());const{minZoom:i,maxZoom:o}=e,a=new n.TileLayer(i,o,i,o,this.modules,this.modules.map.state,t);this.modules.tileManager.addTileLayer(a),this.tileLayers.push(a)}addIrregularElevationSource(e){const t=new U_(n.sourceUuid(),this.modules,e);this.sources.push(t),this.sourcesRevision.push(t.getRevision());const{minZoom:i,maxZoom:o}=e,a=new n.TileLayer(i,o,i,o,this.modules,this.modules.map.state,t,{useExtendedTilesBounds:!0});this.modules.tileManager.addTileLayer(a),this.tileLayers.push(a)}getDemTextureSize(){const e=this.modules.map.state.cameraConfig,t=this.modules.map.state.size[1]*e.viewportLimitRatio;return Math.min(Math.ceil(Math.hypot(t,t)/n.tileSizeZpt),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(Ma);const a=0;this.modules.renderer.enableTexture(o,a);const r=this.modules.renderer.getShaderProgram("demElevationCopy");this.modules.renderer.enableShaderProgram(r),this.modules.renderer.bindShaderProgram(r,{u_mat4_mvp:n.TEXTURE_COORDS_TO_WEBGL,u_sr2d_texture:a,u_mat4_dem_corrected:this.correctedTexToDemTex}),this.modules.renderer.bindVao(this.copyDemVao),this.modules.renderer.drawTriangles(0,6),this.modules.renderer.bindRenderTarget(null),this.isDemCorrectionEnabled=!0},useDem:!0})}createHillshadeFramebuffer(){let e=this.getDemTextureSize()*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]*Oe[0]*e),Math.trunc(t[1]*Oe[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]*Oe[0]*e),Math.trunc(o[1]*Oe[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]*Oe[0]*n.identify.pixelDensity),Math.trunc(e[1]*Oe[1]*n.identify.pixelDensity)],magFilter:w.NearestFilter,minFilter:w.NearestFilter,wrapS:w.ClampToEdgeWrapping,wrapT:w.ClampToEdgeWrapping});return this.modules.renderer.addFramebuffer({clearColor:Zt,onResize:()=>{const i=this.modules.map.state.size;t.setSize([Math.trunc(i[0]*Oe[0]*n.identify.pixelDensity),Math.trunc(i[1]*Oe[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"?nu:iu),o=n.tileZoomToSize(i),a=o*this.getDemTextureSize(),r=o/It,l=[Math.trunc(e.center[0]/r)*r+r/2,Math.trunc(e.center[1]/r)*r+r/2],c=[l[0]-a/2,l[1]-a/2,0],d=[];n.sub(d,this.modules.camera.position,e.center);const _=n.len(d);n.normalize$1(d,d);const u=Math.max(a/2-_-r-lu/2,0),h=Math.min(u,(a/2-_-r)*Math.sin(e.pitch/e.maxPitch*(Math.PI/2)));h>0&&(n.scale$2(d,d,h),d[0]=Math.trunc(d[0]/r)*r,d[1]=Math.trunc(d[1]/r)*r,n.sub(c,c,d)),n.fromTranslationScale(Ue,c,[a,a,n.tileHeight]),n.invert(this.demTextureMatrix,Ue),n.multiply(this.demFbVpMatrix,n.TEXTURE_COORDS_TO_WEBGL,this.demTextureMatrix);const f=Math.min(t,ou);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(Ue,v,[p,p,n.tileHeight]),n.invert(Ue,Ue),n.multiply(this.demCorrectedFbVpMatrix,n.TEXTURE_COORDS_TO_WEBGL,Ue),n.fromScaling(Ue,[1/this.demCorrectedScale,1/this.demCorrectedScale,1]),n.multiply(this.demCorrectedFbVpToDemTex,n.WEBGL_COORDS_TO_TEXTURE,Ue),n.fromScaling(Ue,[1/this.demCorrectedScale,1/this.demCorrectedScale,1]),n.multiply(Ue,Ue,n.TEXTURE_COORDS_TO_WEBGL),n.multiply(this.correctedTexToDemTex,n.WEBGL_COORDS_TO_TEXTURE,Ue),n.fromScaling(Ue,[this.demCorrectedScale,this.demCorrectedScale,1]),n.multiply(Ue,Ue,n.TEXTURE_COORDS_TO_WEBGL),n.multiply(this.demTexToCorrectedTex,n.WEBGL_COORDS_TO_TEXTURE,Ue)}validateGroundBufferSize(e){const t=e[0]*e[1]*4;this.groundBuffer.length!==t&&(this.groundBuffer=new Float32Array(t))}}function _u(s,e,t){const i=n.makeBinderContext(s.styleZoom,s.styleState,[]),o=[],a=t-1;for(let r=0;r<t;r++){const l=r/a,c=n.sample(e,l,i)*256;o.push(c)}return new 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=Co(t,s,e),t.length>0&&s.metrics.firstcontent===void 0&&(s.metrics.firstcontent=performance.now()-s.metrics.start);const{environmentManager:o}=e;Na(t,i),s.globeMode&&(o.renderStars(),o.renderGlobeHaloBackground()),Eo(s,e,t,i)};let Mo=!1;const Eo=(s,e,t,i)=>{Mo=!1,yu(t,s,e).forEach(o=>uu(s,e,o,i))},uu=(s,e,t,i)=>{Su(e.styleManager,t,s,e).forEach(o=>{Oa(e.styleManager,o[0])?hu(s,e,o,i):Da(s,e,o,i)})},hu=(s,e,t,i)=>{const o=Oa(e.styleManager,t[0]);if(!o)return;const a=(r,l)=>{l>=o.orderBy.length?Da(s,e,r,i):Mu(o.orderBy[l],r,s,e).forEach(c=>a(c,l+1))};a(t,0)},Da=(s,e,t,i)=>{t.sort((o,a)=>o.tile.zoomLevel-a.tile.zoomLevel),wu(e.styleManager,t,s,e).forEach(o=>fu(s,e,o,i))},fu=(s,e,t,i)=>{Tu(t,s,e).forEach(o=>mu(s,e,o,i))},mu=(s,e,t,i)=>{var l;const o=t[0],a=Lu(e.styleManager,o);if(!a||((l=a==null?void 0:a.style)==null?void 0:l.visibility)==="hidden")return;const r=a.selectedIdx;r!==void 0&&t.sort((c,d)=>{var h,f;const _=Number((h=c.attributes.tileData[r])!=null?h:0),u=Number((f=d.attributes.tileData[r])!=null?f:0);return _-u}),o.type===n.SceneObjectType.Custom?(i.useCustomLayerState(a),e.styleManager.callCustomLayerRender(o.attributes.layerId),i.resetAfterCustomLayer()):Eu(t,s,e).forEach(c=>pu(s,e,c,i,a))},pu=(s,e,t,i,o)=>{o.type==="point"&&!Mo&&s.globeMode&&(Mo=!0,e.environmentManager.renderGlobeHalo()),i.useProgram(t[0],o),Iu(t,s,e).forEach(a=>{vu(s,e,a,i,o)})},vu=(s,e,t,i,o)=>{i.useState(t[0],o),Cu(t,s,e).forEach(a=>{i.drawSymbol(a,o,s,e)})};function Oa(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 gu=(s,e)=>Number(s)-Number(e),At=s=>(e,t,i)=>{const o={};for(let l=0;l<e.length;l++){const c=e[l],d=s(c,t,i),_=o[d];_===void 0?o[d]=[c]:_.push(c)}const a=Object.keys(o);a.sort(gu);const r=[];for(let l=0;l<a.length;l++)r.push(o[a[l]]);return r},Io=s=>(e,t,i)=>{const o=new Map;for(let a=0;a<e.length;a++){const r=e[a],l=s(r,t,i);o.has(l)?o.get(l).push(r):o.set(l,[r])}return o},yu=At(s=>{const{styleId:e}=s.attributes;return e===n.DYNAMIC_STYLE_ID?1:-e}),xu=(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},bu=(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},wu=(s,e,t,i)=>At(o=>bu(s,o.attributes.styleId,o.attributes.layerId))(e,t,i),Su=(s,e,t,i)=>At(o=>xu(s,o.attributes.styleId,o.attributes.layerId))(e,t,i),Tu=At(s=>s.type===n.SceneObjectType.Custom?0:s.layerSettings.subRenderIndex||0),Na=(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))})},Mu=(s,e,t,i)=>At((o,a)=>{const r=n.makeBinderContext(a.styleZoom,a.styleState,o.attributes.tileData);return n.resolveNumber(s,r,0)})(e,t,i),Eu=Io(s=>{var e;return(e=s.shaderDefinitions)!=null&&e.hash?s.layerSettings.programName+"_"+s.shaderDefinitions.hash:s.layerSettings.programName}),Iu=Io(s=>s.layerSettings.stateBinder),Cu=Io(s=>s.sink+"_"+s.attributesHash+"_"+s.tile.readiness),Pu=At(s=>s.tile.zoomLevel);function Lu(s,e){const t=s.getStyle(e.attributes.styleId);if(t)return t.layersById[e.attributes.layerId]}function Co(s,e,t){for(const i of s)i.type!==n.SceneObjectType.Custom&&(i.canRender=Bu(i,t,e));return s.filter(i=>i.canRender)}function Bu(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 ka=[0,0,0,0],bt=(s,e,t,i,o,a)=>{const r={terrain3d:!!o,noEffects:!!a,drawSymbol:(l,c,d,_)=>{const u=l[0];if(u)if(zu(u)&&(c.type==="overpass"||c.type==="tunnel"||c.type==="gltfModel")&&!u.layerSettings.shadow){let h;c.type==="gltfModel"&&(h=ka),r.renderTierTexture(u,c,!1,h),r.useProgram(u,c),r.useState(u),Po(l,c,d,_,r),d.hiddenImmersiveRoutesEnabled&&!u.layerSettings.identify&&c.type!=="gltfModel"&&(r.renderTierTexture(u,c,!0),r.useProgram(u,c),_.renderer.applyGpuState(G_,c),Po(l,c,d,_,r))}else Po(l,c,d,_,r)},useProgram:(l,c)=>{const{layerBinder:d,programName:_,programBinder:u,commonBinder:h}=l.layerSettings,f=e.renderer.getShaderProgram(_,l.shaderDefinitions);e.renderer.enableShaderProgram(f),h&&!e.renderer.isUboSupported()&&h(f,s,e),u==null||u(f,s,e,o,a),d==null||d(f,s,e,c,a)},setProgramBinder:l=>{const c=l.layerSettings.programBinder,d=e.renderer.isUboSupported()?void 0:l.layerSettings.commonBinder;if(l.layerSettings.programBinder||d){const _=e.renderer.getShaderProgram(l.layerSettings.programName,l.shaderDefinitions);e.renderer.enableShaderProgram(_),d==null||d(_,s,e),c==null||c(_,s,e,o,a)}},useState:(l,c)=>{e.renderer.applyGpuState(l.layerSettings.stateBinder,c)},useCustomLayerState:l=>{e.renderer.applyGpuState(q_,l)},resetAfterCustomLayer:()=>{e.renderer.resetStateAfterExternalRender(),e.renderer.setRenderTarget(i)},useCanvas:()=>{e.renderer.setRenderTarget(i)},renderTierTexture:(l,c,d,_)=>{const{viewport:u,size:h}=s,f=window.devicePixelRatio,m=!!l.layerSettings.identify,p=m?e.renderer.getMapMeshIdFramebufferId():e.renderer.getMapMeshFramebufferId(),v=e.renderer.getFramebuffer(p);if(!v)return;const x=bt(s,e,void 0,i,!1,!0);if(e.renderer.disableTexture(0),e.renderer.bindRenderTarget(v.renderTarget),e.renderer.setViewport(0,0,v.renderTarget.options.size[0],v.renderTarget.options.size[1]),d){const b=m?Zt:ka;e.renderer.clearWithColor(b,!0,-1)}else if(m)e.renderer.clearWithColor(Zt,!0);else{const b=n.makeBinderContext(s.styleZoom,s.styleState,l.attributes.tileData),T=_!=null?_:n.resolveColor(c.style.color,b).value;e.renderer.clearWithColor([T[0]/255,T[1]/255,T[2]/255,T[3]/255],!0)}const g=l.attributes.meshTier,y=t==null?void 0:t[g];if(y){y.tileObjects.forEach(S=>{var L,E;S.updateMvpMatrix((E=(L=v.getViewProjectionMatrix)==null?void 0:L.call(v))!=null?E:e.camera.viewProjectionMatrix,void 0)});const b=d?y.objects.filter(S=>{var L;if(S.type!==n.SceneObjectType.Custom){if(S.layerSettings.stateBinder(e).depthTest&&!S.layerSettings.isOverlappedObject)return!0;const E=e.styleManager.getStyleLayer(S.attributes.styleId,S.attributes.layerId);if(E)return((L=E.gpuState)==null?void 0:L.depthTest)===!0}return!1}):y.objects,T=Co(b,s,e);Eo(s,e,T,x),y.tileObjects.forEach(S=>S.updateMvpMatrix(e.camera.viewProjectionMatrix)),Na(y.objects,r)}i?(e.renderer.bindRenderTarget(i),e.renderer.setViewport(0,0,i.options.size[0],i.options.size[1])):(e.renderer.bindRenderTarget(null),e.renderer.setViewport(u.left*f,u.bottom*f,h[0]*f,h[1]*f))},copy:(l,c,d)=>bt(s,e,t,l,c,d)};return r},Po=(s,e,t,i,o)=>{const a=s[0],r=a.layerSettings,l=i.renderer.getShaderProgram(r.programName,a.shaderDefinitions);r.objectBinder(l,t,i,a,e,o.terrain3d),a.layerSettings.zoomBinder?Pu(s,t,i).forEach(c=>{var d,_;l&&((_=(d=a.layerSettings).zoomBinder)==null||_.call(d,l,t,i,c[0],e,o.terrain3d)),c.forEach(u=>Ua(u,i,l,t,o,e))}):s.forEach(c=>Ua(c,i,l,t,o,e))},Ua=(s,e,t,i,o,a)=>{var c;const{renderer:r}=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,a,o))continue;r.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?r.drawInstancedElements(m,h,p,u,f):r.drawElements(m,h,p,u):f?r.drawInstancedArrays(m,u,h,f):r.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=r.triangleCountByDrawMode(m,h);i.stats.triangleCount+=(f!=null?f:1)*v}}};function zu(s){return s.symbol==="mapMesh"||s.symbol==="gltfModel"&&s.attributes.meshTier!==void 0}const Ha=n.create$1(),Ru=n.create$1(),Ga=n.create$2(),Lo=n.create$1(),Fu=n.fromValues(0,0,1),Du=n.create$1(),Ou=.3,Nu=1/2e7,ku=.01,Uu=[1,1,1,1],Va=n.reserveTextureIndex();class Hu{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(Yt())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 R=o[E];if(R.shadowLightIndex===0){this.shadowLightDir=R.dir1Direction,this.shadowMapParams[2]=R.shadowRadius;break}else if(R.shadowLightIndex===1){this.shadowLightDir=R.dir2Direction,this.shadowMapParams[2]=R.shadowRadius;break}}const a=this.shadowLightDir&&!this.modules.map.getFeatureFlag("shadowsOff");if(a?this.renderTarget||(this.renderTarget=this.createRenderTarget()):this.renderTarget&&this.renderTarget.remove(),!a||!this.shadowLightDir||!this.renderTarget||this.modules.renderCacheManager.hasReadyCache())return;const r=this.modules.map.state.center,l=this.modules.camera.position[2];let c=Math.max(this.volumeMultiplier*l);this.discreteVolume&&(c=c-c%this.volumeSizeStep),c=Math.max(c,this.volumeMinSize);let d=this.baseBias;this.modules.renderer.isShadowSamplerSupported()&&(d*=.5),this.shadowMapParams[3]=d/c,this.bias=d*Nu*Math.sqrt(c),this.bias=Math.min(this.bias,ku);let _=1;if(this.adaptiveVerticalSize){const E=Math.abs(n.dot(this.shadowLightDir,Fu));_=Math.max(E,Ou)}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(Lo,m,this.shadowLightDir);const p=Ga;n.lookAt(p,Du,this.shadowLightDir,Lo);const v=n.transformMat4$1(Ha,r,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),T=n.transformMat4$1(Ru,y,b!=null?b:n.identity(Ga)),S=n.add$1(Ha,T,this.shadowLightDir);n.lookAt(this.shadowMatrix,T,S,Lo),n.multiply(this.shadowMatrix,this.orthoMath,this.shadowMatrix);const L=this.modules.camera.viewProjectionMatrixInverse;n.multiply(this.clipToShadowMatrix,this.shadowMatrix,L)}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,a=[];for(const l of e)for(const c of l.shadowChildren){const d=this.modules.styleManager.getStyleLayerForObject(c);if(!d||d.castShadows===!1)continue;const _=la(d,this.modules,this.mapState);!_||_.lightConfig.shadowLightIndex===-1||(a.push(c),o.add(l))}const r=t?this.modules.demManager.demTextureMatrix:void 0;o.forEach(l=>{l.updateMvpMatrix(this.shadowMatrix,r)}),this.modules.renderer.bindRenderTarget(this.renderTarget),this.modules.renderer.applyGpuState(Pa),this.modules.renderer.clearWithColor(Uu,!0),this.modules.renderer.setViewport(0,0,this.renderTarget.options.size[0],this.renderTarget.options.size[1]),Ct(this.mapState,this.modules,a,i),this.modules.renderer.bindRenderTarget(null)}drawDebugFbIfNeeded(){if(!this.debugDraw){this.copyProgram&&(this.copyProgram=null),this.debugVao&&(this.debugVao.remove(),this.debugVao=null);return}if(!this.texture)return;if(this.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=bi(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(xt),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 ja{constructor(e,t,i){this.output=e,this.input=t,this.modules=i,this.enabled=!0}}class Gu extends ja{constructor(e,t,i,o){super(e,t,i),this.name=ei.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!==ti.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=bi(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,a=i.base3;t.push([0,0]);for(let r=0;r<o.length;++r)t.push([2*o[r]-1,2*a[r]-1]);return t}}class Vu extends ja{constructor(e,t,i,o){super(e,t,i),this.name=ei.FXAA,this.vao=null,this.buffer=o}onBeforeRender(e){this.enabled=e.aaMode===ti.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=bi(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;_e(t,o,this.modules)}this.modules.renderer.drawTrianglesFan(0,4)}onAfterRender(){}resize(e){this.output.setSize(e)}isReady(){return!0}}var ei=(s=>(s.TAA="TAA",s.FXAA="FXAA",s))(ei||{}),ti=(s=>(s[s.TAA=0]="TAA",s[s.FXAA=1]="FXAA",s))(ti||{});class ju{constructor(e,t){this.renderGraph=[],this.effectsByType={},this.copyColorVao=null,this.copyColorDepthVao=null,this.copyColorProgram=null,this.copyColorDepthProgram=null,this.state=e,this.modules=t,this.renderTargetSize=this.modules.renderer.getViewportSize();const i=t.renderer.webglContextState.MAX_TEXTURE_SIZE;if(Math.max(...this.renderTargetSize)>i){n.log(`Disabling post-effects as viewport size ${this.renderTargetSize[0]}x${this.renderTargetSize[1]} exceeds hardware limits of ${i}x${i}`);return}const a=this.modules.renderer.createBuffer(new Uint8Array([-1,-1,1,-1,1,1,-1,1]));this.copyColorProgram=this.modules.renderer.getShaderProgram("copy"),this.copyColorDepthProgram=this.modules.renderer.getShaderProgram("copy",n.Shader.createShaderDefinitions([{type:"COPY_DEPTH",value:"1"},...!this.modules.renderer.isWebgl2Context()&&this.modules.renderer.fragDepthSupported()?[{type:"HAS_FRAG_DEPTH_EXT"}]:[]])),this.copyColorVao=bi(a,this.copyColorProgram),this.copyColorDepthVao=bi(a,this.copyColorDepthProgram);const r=this.createRenderTarget(this.renderTargetSize,{useHighDepthPrecision:!0});this.mainFrameBufferWrapper={renderTarget:r,onResize:()=>{},clearColor:n.getColorForShaders(e.defaultBackgroundColor),clearDepth:!0};const l=e.aaMode===0,c=e.aaMode===1,d=l?Gu:c?Vu:null;if(d){const _=this.createRenderTarget(this.renderTargetSize),u=new d(_,r,t,a);this.effectsByType[l?"TAA":"FXAA"]=u,this.renderGraph.push(u)}}update(){this.renderGraph.forEach(e=>e.onBeforeRender(this.state))}render(){this.modules.renderer.applyGpuState(Y_),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,a=window.devicePixelRatio,r=this.modules.renderer.getViewportSize();this.modules.renderer.bindRenderTarget(null),this.modules.renderer.setViewport(o.left*a,o.bottom*a,r[0],r[1]),i&&this.modules.renderer.clear(!1);const l=t?this.copyColorDepthProgram:this.copyColorProgram,c=t?this.copyColorDepthVao:this.copyColorVao;this.modules.renderer.bindVao(c);const d=e.getTexture();if(d&&this.modules.renderer.enableTexture(d,0),this.modules.renderer.enableShaderProgram(l),this.modules.renderer.bindShaderProgram(l,{u_texture:0}),t){const _=e.getDepthAttachment();_ instanceof 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 Zu=[0,0];function ve(...s){return(e,t,i,o,a)=>{s.forEach(r=>r(e,t,i,o,a))}}const ie=(s,e,t,i)=>{var m,p,v;if(!i){Wa(s,e,t);return}const o=(m=t.renderer.getFramebuffer(t.demManager.getDemFramebufferId()))==null?void 0:m.renderTarget.getTexture(),a=(p=t.renderer.getFramebuffer(t.demManager.getCorrectedDemFramebufferId()))==null?void 0:p.renderTarget.getTexture(),r=t.imageManager.getTexture(t.demManager.getHillshadeRampTextureId()),l=o==null?void 0:o.options.size,c=t.styleManager.getStyle(e.handyStyleId);if(!o||!a||!r||!c||!l){Wa(s,e,t);return}const d=n.makeBinderContext(e.styleZoom,e.styleState,[],!1),_=n.clamp(n.resolveNumber(c.dem.style.shadingIntensity,d),0,1),u=t.demManager.getElevationSourceType(),h=n.EARTH_CIRCUMFERENCE/(Math.pow(2,Math.min(Math.trunc(e.styleZoom),u==="regular"?So:Ra))*It);t.renderer.enableTexture(o,yo),t.renderer.enableTexture(r,bo),t.renderer.enableTexture(a,wo);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:yo,u_tex_corrected_dem:wo,u_tex_hillshade_ramp:bo,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})},Za=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_dem_shading_intensity:0})},Wa=(s,e,t)=>{t.renderer.bindShaderProgram(s,{u_float_dem_scale:0})},ln=ie,cn=ve(ft,Yi),$a=gi,Wu=ve(na,Yi,ft,ra,ie),Xa=ve(na,Yi,Jd,ie),Ka=ve(ft,Yi,ra,ie),$u=gi,at=(s,e,t,i,o)=>{const a=t.postEffectsManager.getEffectByName(ei.TAA),r=!o&&(a!=null&&a.jitter)?a.jitter:Zu;t.renderer.bindShaderProgram(s,{u_vec2_camera_jitter:r})},Ge=(s,e,t)=>{const i=t.shadowManager.texture;i&&(t.renderer.enableTexture(i,Va),t.renderer.bindShaderProgram(s,{u_texture_shadow:Va}))},Xu=(s,e,t)=>{if(!t.benchmark)return;const i=n.create$2(),o=t.benchmark.getScale();t.renderer.bindShaderProgram(s,{u_mat4_mvp:n.scale$3(i,i,o),u_vec3_transform:n.fromValues(0,0,0)})},Ku=ve(ie,at,Ge),qu=ve(at,Ge),dn=ve(ie,at,Ge),Yu=gi,Qu=ve(ie,at,Ge),qa=ve(at,Ge),pt=ve(ie,at,Ge),Ya=ve(ie,Ge),ii=ve(ie,at,Ge),Qa=ve(gi,sa,aa),Ja=ve(gi,sa,aa,Ge),Ju=ve(ie,Ja),Au=ve(ie,Qa),Bo=ve(Ge,ie),eh=ve(ie,at,Ge),th=ve(at,Ge),Aa=ve(at,Ge),ih=ve(ie,Aa),wi=new Float32Array(2),Si=new Float32Array(2),nh=[0,0],oh=[0,0,0,0],ni=.01,Be=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_float_opacity:1})},zo=(s,e,{renderer:t},i,o)=>{const a=ke(e,i),r=n.resolveNumber(o.style.textureOpacity,a);t.bindShaderProgram(s,{u_float_texture_opacity:i.tile.readiness*r})},Pt=(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})},er=(s,e,{renderer:t},i)=>{var c;if(!i.renderingProperties.mixColor)return;const{color2:o,factor:a,factorInterpolate:r}=i.renderingProperties.mixColor,l=n.getColorForShaders(o);switch(n.scale$4(l,l,i.tile.readiness),a.type){case"read-from-target":{const d=(c=t.getDrawTargetFramebuffer(a.name))==null?void 0:c.renderTarget.getTexture();if(!d)return;t.enableTexture(d,2),r?t.bindShaderProgram(s,{u_vec4_color2:l,u_sr2d_read_from_target_texture:2,u_int_factor_use_interpolate:1,u_float_factor_interpolate_base:r.base,u_vec4_factor_interpolate_ranges:r.steps}):t.bindShaderProgram(s,{u_vec4_color2:l,u_sr2d_read_from_target_texture:2,u_int_factor_use_interpolate:0});break}case"vertex-attribute":{t.bindShaderProgram(s,{u_vec4_color2:l});break}default:{const{type:d}=a;n.assertUnreachable(d)}}},Ti=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_mat4_gradient:i.renderingProperties.mat4_gradient})},sh=(s,e,{renderer:t},i,o)=>{const a=n.getColorForShaders(n.resolveColor(o.style.strokeColor,ke(e,i)));n.scale$4(a,a,i.tile.readiness),t.bindShaderProgram(s,{u_vec4_border_color:a})},He=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.widthResolved||0;t.bindShaderProgram(s,{u_float_width:o*window.devicePixelRatio})},tr=(s,e,{renderer:t},i,o)=>{t.bindShaderProgram(s,{u_float_shift:n.resolveNumber(o.style.shift,ke(e,i))*window.devicePixelRatio})},ah=(s,e,{renderer:t},i,o)=>{const a=i.renderingProperties.opacityResolved||0,r=n.makeBinderContext(e.styleZoom,e.styleState,i.attributes.tileData,!1),l=o.style.iconOpacity,c=n.resolveNumber(l,r);r.isBehind=!0;const d=e.styleState.graphicsPreset==="light"?1:n.resolveNumber(l,r);t.bindShaderProgram(s,{u_vec2_opacity:[a*c,a*d]})},Dt=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.opacityResolved||0;t.bindShaderProgram(s,{u_float_opacity:o})},Ro=(s,e,{renderer:t},i,o)=>{const a=n.resolveNumber(o.style.iconRotation,ke(e,i));t.bindShaderProgram(s,{u_vec2_rotation:[Math.cos(a),Math.sin(a)]})},rh=(s,e,{renderer:t},i,o)=>{const a=n.resolveNumber(o.style.opacity,ke(e,i));t.bindShaderProgram(s,{u_float_opacity:i.tile.readiness*a})},lh=(s,e,{renderer:t},i,o)=>{const a=n.resolveNumber(o.style.opacity,ke(e,i));t.bindShaderProgram(s,{u_float_opacity:a})},Fo=(s,e,{assetManager:t,renderer:i},o)=>{const a=t.textures[o.attributes.atlasIndex];i.enableTexture(a,0)},oi=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.fontTexture;o&&t.enableTexture(o,0)},ir=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.texture;o&&t.enableTexture(o,0)},ch=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.rampTexture;o&&(t.enableTexture(o,1),t.bindShaderProgram(s,{u_sr2d_ramp_texture:1}))},_n=(s,e,{renderer:t},i,o)=>{const{tile:a}=i,r=n.resolveColor(o.style.gapColor,ke(e,i));if(!r)return;const l=n.getColorForShaders(n.resolveColor(r,ke(e,i)));n.scale$4(l,l,a.readiness),t.bindShaderProgram(s,{u_vec4_space_color:l})},un=(s,e,{renderer:t},i,o)=>{const{styleZoom:a}=e,r=ke(e,i),{tile:l}=i,c=n.getColorForShaders(n.resolveColor(o.style.color,r));n.scale$4(c,c,l.readiness),r.styleZoom=Math.floor(a);const d=Math.pow(2,n.getFractionalPart(a)),_=n.resolveNumber(o.style.dashLength,r)*d,u=n.resolveNumber(o.style.gapLength,r)*d;t.bindShaderProgram(s,{u_vec4_dash_color:c,u_vec2_scaler_params:[0,n.z0Scale],u_float_dash_length:n.zptToSceneDistance(_,l.size),u_float_dash2_length:n.zptToSceneDistance(_,l.size),u_float_space_length:n.zptToSceneDistance(u,l.size),u_int_gap_turns_only:o.style.gapTurnsOnly?1:0})},ue=n.create$3(),nr=(s,e,{renderer:t},i,o)=>{const a=ke(e,i),{tile:r}=i,{pattern:l,width:c}=i.renderingProperties;if(!l||!c)return;const d=n.getColorForShaders(n.resolveColor(o.style.color,a));switch(n.scale$4(d,d,r.readiness),l[0]){case n.LinePatternType.Chess:{const _=l[1];ue[0]=_,ue[1]=.5,ue[2]=.25,ue[3]=-.25;break}case n.LinePatternType.DoubleDash:{const _=l[1];ue[0]=_,ue[1]=l[2]/c,ue[2]=.5*l[3]/_,ue[3]=.5*l[4]/_,ue[2]>=.5-Number.EPSILON&&(ue[2]=.6),ue[3]>=.5-Number.EPSILON&&(ue[3]=.6);break}case n.LinePatternType.Stripe:{const _=l[1]+l[2];ue[0]=_,ue[1]=.55,ue[2]=.5*l[1]/_,ue[3]=.5*l[1]/_,ue[2]>=.5-Number.EPSILON&&(ue[2]=.6),ue[3]>=.5-Number.EPSILON&&(ue[3]=.6);break}case n.LinePatternType.Circle:{const _=l[1]+l[2];ue[0]=_,ue[1]=.5*l[1]/_;break}case n.LinePatternType.Triangles:{const _=l[1]+l[2];ue[0]=_,ue[1]=l[1]/_,ue[2]=String(l[3])==="right"?-1:1;break}case n.LinePatternType.Chevron:{const _=l[1]+l[2];ue[0]=_,ue[1]=l[1]/_,ue[2]=l[3]/_,ue[3]=l[4]/c;break}}t.bindShaderProgram(s,{u_vec4_color:d,u_int_pattern_type:l[0],u_vec4_pattern_params:ue})},hn=(s,e,{renderer:t},i,o)=>{const a=ke(e,i),r=n.resolveNumber(o.style.tipWidth,a),l=n.resolveNumber(o.style.tipHeight,a),c=r,d=0;wi[0]=-c,wi[1]=-d,n.normalize$1(wi,wi),Si[0]=r,Si[1]=l,n.normalize$1(Si,Si);const _=n.resolveNumber(o.style.roundingRadius,a);t.bindShaderProgram(s,{u_vec2_wing_normal:wi,u_vec2_tip_normal:Si,u_float_tip_height_multiplier:l,u_float_wing_height_multiplier:d,u_float_wing_width_multiplier:c,u_float_size_factor:n.zptToSceneDistance(n.uint16ToTileCoords,i.tile.size)/2,u_float_tip_radius_zpt:_,u_float_wing_radius_zpt:_,u_float_tail_radius_zpt:_})},or=(s,e,{renderer:t},i,o)=>{const a=ke(e,i),r=n.resolveNumber(o.style.lineLength,a),l=n.resolveNumber(o.style.lineWidth,a);t.bindShaderProgram(s,{u_float_length:r,u_float_width:l,u_float_border_width:0})},sr=(s,e,{renderer:t},i,o)=>{const a=ke(e,i),{tile:r,attributes:l}=i,c=l.isLongArrow,d=i.tile.dynamicObject;let _=0,u=1;d&&(c?u=d.growPosition:_=d.bouncePosition);let h=0;const f=o.style.animation.type;(f==="appearance"||f==="repeat")&&(h=n.resolveNumber(o.style.animation.tipMovementAmplitude,a));const m=n.resolveNumber(o.style.roundingRadius,a);t.bindShaderProgram(s,{u_float_width_zpt:n.resolveNumber(o.style.lineWidth,a),u_float_border_width_zpt:n.resolveNumber(o.style.strokeWidth,a),u_float_tip_movement_amplitude:n.zptToSceneDistance(h,r.size),u_float_vertex_shift:_,u_float_relative_end_position:u,u_float_tip_radius_zpt:m,u_float_wing_radius_zpt:m,u_float_tail_radius_zpt:m})},dh=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.modelTexture;o&&t.enableTexture(o,0)},Do=(s,e,{renderer:t},i)=>{var o,a;return t.bindShaderProgram(s,{u_int_gltf_dem_pos:i.attributes.demPosition,u_vec2_anchor:(o=i.attributes.centroid)!=null?o:nh,u_vec4_axis:(a=i.attributes.axis)!=null?a:oh}),!0},_h=(s,e,{assetManager:t,renderer:i},o)=>{const{styleId:a}=o.attributes,{renderingProperties:r}=o,{resolvedColorTexture:l,resolvedAoTexture:c,resolvedPbrTexture:d,resolvedMetallic:_,resolvedRoughness:u}=r,{modelId:h}=r,f=t.getModel(h!=null?h:NaN,a);if(!f)return;const m={},p=l!==void 0&&f.textures[l];p&&(i.enableTexture(p,0),m.u_sr2d_texture_0=0);const v=c!==void 0&&f.textures[c];v&&(i.enableTexture(v,1),m.u_ao_texture=1);const 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)},fn=(s,e,{renderer:t},i,o)=>{let a=i.renderingProperties.resolvedHeightFactor||0;a=ni+(1-ni)*a,t.bindShaderProgram(s,{u_float_height_factor:a})},mn=(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})},Oo=(s,e,{modelLayer:t,renderer:i},o,a)=>{if(o.attributes.id===void 0)return;const r=t.getOpacity(o.attributes.id,a.minzoom),c=t.getBuildingHeight(o.attributes.id)===1?1:r;i.bindShaderProgram(s,{u_float_height_factor:c})},pn=(s,e,{renderer:t},i,o)=>{const a=ke(e,i),r=n.resolveNumber(o.style.height,a);t.bindShaderProgram(s,{u_float_height_factor:n.mapHeightToTileHeight(r)})},Qe=(s,e,t,i,o)=>{const{floorManager:a,buildingHeightAnimator:r,modelsScene:l,modelLayer:c,renderer:d}=t;if(i.symbol==="polygonExtrusion"&&i.attributes.floorId&&i.attributes.isFloorStack){d.bindShaderProgram(s,{u_float_height_factor:a.getFloorStackObjectHeight(i.attributes.floorId)});return}let _=r.getBuildingHeight(o.minzoom);_=ni+(1-ni)*_;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 vn=(s,e,{renderer:t},i)=>{const{tile:o}=i,a=i.renderingProperties.widthResolved||0;t.bindShaderProgram(s,{u_float_width:n.zptToSceneDistance(a,o.size)/2*n.uint16ToTileCoords,u_float_width_offset:n.zptToSceneDistance(n.uint16ToTileCoords/window.devicePixelRatio,o.size)/2})},uh=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.resolvedRadius;t.bindShaderProgram(s,{u_float_radius:o*window.devicePixelRatio})},hh=(s,e,{renderer:t},i,o)=>{const a=n.resolveNumber(o.style.intensity,ke(e,i));t.bindShaderProgram(s,{u_float_intensity:a})},Gt=(s,e,{renderer:t},i,o)=>{const a=ke(e,i);let r=n.resolveNumber(o.style.textFontSize,a);if(i.symbol==="point"){const l=i.attributes.labelIndex;l===n.LabelIndex.Second&&o.style.textFontSize2?r=n.resolveNumber(o.style.textFontSize2,a):l===n.LabelIndex.Icon&&o.style.iconTextFontSize&&(r=n.resolveNumber(o.style.iconTextFontSize,a))}t.bindShaderProgram(s,{u_float_scale:r*window.devicePixelRatio/n.fonts.baseSize})},gn=(s,e,{renderer:t},i,o)=>{const a=n.makeBinderContext(e.styleZoom,e.styleState,i.attributes.tileData,!!i.layerSettings.isOverlappedObject),{textFontSize:r,textColor:l,textHaloWidth:c,textHaloColor:d}=o.style,_=n.resolveNumber(r,a)/n.fonts.baseSize,u=_*window.devicePixelRatio,h=n.fonts.gamma/u,f=i.layerSettings.uniformSet,m=f==="fontHalo"?(6-n.resolveNumber(c,a)/_)/8:.75;let p;f==="fontHalo"?p=n.getColorForShaders(n.resolveColor(d,a)):p=n.getColorForShaders(n.resolveColor(l,a)),t.bindShaderProgram(s,{u_float_buffer:m,u_float_gamma:h,u_vec4_color:p})},ar=(s,e,{renderer:t},i,o)=>{const{layerSettings:a}=i,{uniformSet:r}=a,l=i.attributes.labelIndex,c=o.style;let{textFontSize:d,textHaloWidth:_,textColor:u,textHaloColor:h}=c;switch(l){case n.LabelIndex.Icon:d=c.iconTextFontSize,_=c.iconTextHaloWidth,u=c.iconTextColor,h=c.iconTextHaloColor;break;case n.LabelIndex.Second:d=c.textFontSize2,_=c.textHaloWidth2,u=c.textColor2,h=c.textHaloColor2;break}fh(s,t,e,i,d,u,_,h,l,r)},fh=(s,e,t,i,o,a,r,l,c,d)=>{const _=n.makeBinderContext(t.styleZoom,t.styleState,i.attributes.tileData,!1,i.tile.dynamicObject),u=n.resolveNumber(o,_)/n.fonts.baseSize,h=u*window.devicePixelRatio,f=n.fonts.gamma/h,m=d==="fontHalo"?(6-n.resolveNumber(r,_)/u)/8:.75;let p,v;d==="fontHalo"?(p=n.getColorForShaders(n.resolveColor(l,_)),_.isBehind=!0,v=n.getColorForShaders(n.resolveColor(l,_))):(p=n.getColorForShaders(n.resolveColor(a,_)),_.isBehind=!0,v=n.getColorForShaders(n.resolveColor(a,_))),e.bindShaderProgram(s,{u_float_buffer:m,u_float_gamma:f,u_vec4_color:p,u_vec4_hidden_color:v,u_float_label_index:c})},yn=(s,e,{renderer:t},i)=>{const{attributes:o}=i,{offsetX:a,offsetY:r}=o,l=window.devicePixelRatio;t.bindShaderProgram(s,{u_vec2_offset:[a*l,r*l]})},xn=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_float_style_zoom:e.styleZoom})},wt=(s,e,{renderer:t},i)=>{const{tile:o}=i,{zoom:a}=e,r=n.tileSizeZpt*Math.pow(2,a-o.zoomLevel)*window.devicePixelRatio;t.bindShaderProgram(s,{u_float_tile_to_pixel_ratio:n.uint16ToTileCoords/r})},rr=(s,e,{renderer:t},i,o)=>{const{tile:a}=i,{zoom:r,styleZoom:l}=e,c=o.style.lengthUnits===n.LengthUnits.Meters,d=n.tilePointScaleFactor(n.createTileInfo(a.coords),[n.maxTilePoint/2,n.maxTilePoint/2]),_=n.uint16ToTileCoords/(n.tileSizeZpt*Math.pow(2,r-a.zoomLevel)*window.devicePixelRatio),u=c?l:Math.floor(l),h=n.tileSizeZpt*Math.pow(2,u-a.zoomLevel)*window.devicePixelRatio/(n.uint16ToTileCoords*d);t.bindShaderProgram(s,{u_vec2_scales:[h,_]})},lr=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.flatTexture;o&&t.enableTexture(o,0),t.bindShaderProgram(s,{u_flat_tex:0})},cr=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.flatIdentifyTexture;o&&t.enableTexture(o,0),t.bindShaderProgram(s,{u_flat_tex:0})},dr=(s,e,{renderer:t},i)=>{const o=i.renderingProperties.hillshadeTexture;o&&(t.enableTexture(o,xo),t.bindShaderProgram(s,{u_hillshade_tex:xo}))},mh=(s,e,t,i)=>{const{renderer:o,demManager:a}=t,r=i.renderingProperties.demTexture;r&&(o.enableTexture(r,0),o.bindShaderProgram(s,{u_tex_dem:0,u_mat4_dem_corrected:a.demCorrectedFbVpToDemTex}))},Mi=(s,e,{renderer:t},i,o)=>{let a=!0;e.globeMode||(a=!!n.resolveNumber(o.style.elevation,ke(e,i))),t.bindShaderProgram(s,{u_bool_skip_height_factor:a})},Je=(s,e,{buildingHeightAnimator:t,renderer:i},o,a)=>{let r=t.getBuildingHeight(a.minzoom);r=ni+(1-ni)*r,i.bindShaderProgram(s,{u_float_height_factor:r})},Ae=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_int_abs_z:i.attributes.absZ?1:0})},No=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_int_abs_z:!1})},ko=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_float_tile_size:n.tileZoomToSize(i.tile.zoomLevel)})},ph=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_vec4_color:n.LABELING_TEXTURE_DEM_MESH_COLOR})},D=(s,e,{renderer:t},i,o,a)=>{t.bindShaderProgram(s,{u_float_dem_scale:a?e.elevationScale:0})},Uo=(s,e,{renderer:t},i)=>{if(!i.attributes.meshTier)return;const o=i.layerSettings.identify?t.getMapMeshIdFramebufferId():t.getMapMeshFramebufferId(),a=t.getFramebuffer(o),r=a==null?void 0:a.renderTarget.getTexture(),l=a==null?void 0:a.scale;r&&(t.enableTexture(r,n.MAP_MESH_TEXTURE_INDEX),t.bindShaderProgram(s,{u_sampler_map_tex:n.MAP_MESH_TEXTURE_INDEX,u_vec2_tex_scale:l,u_float_tex_shift_scale:1-Math.cos(e.pitch)}))},rt=(s,e,{renderer:t},i)=>{t.bindShaderProgram(s,{u_int_identify:i.layerSettings.identify||i.layerSettings.depthTest?1:0})},vh=(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,a,r)=>{s.forEach(l=>l(e,t,i,o,a,r))}}const si=(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),he=(s,e,{floorManager:t,renderer:i},o)=>{if(!o.attributes.floorId||!o.tile.renderModelMatrix){i.bindShaderProgram(s,{u_float_floor_elevation:0});return}if(o.symbol==="polygonExtrusion"&&o.attributes.isFloorStack){i.bindShaderProgram(s,{u_float_floor_elevation:t.getFloorStackObjectElevation(o.attributes.floorId)/o.tile.renderModelMatrix[10]});return}i.bindShaderProgram(s,{u_float_floor_elevation:t.getFloorObjectElevation(o.attributes.floorId)/o.tile.renderModelMatrix[10]})},ai=(s,e,{renderer:t})=>{t.bindShaderProgram(s,{u_float_floor_elevation:0})},Ei=(s,e,t,i)=>{t.renderer.bindShaderProgram(s,{u_int_is_roof:i.symbol==="polygonExtrusion"&&i.sink==="topFill"?1:0})},_r=(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]})},gh=(s,e,t,i,o)=>{var p;const a=i.attributes.textureIndex,r=(p=o.style.sideTextures)==null?void 0:p[a],l=t.imageManager.getTexture(o.sideTextureIndices[a]),c=n.MAP_POINTS_IN_METER*n.tilePointScaleFactor(n.createTileInfo(i.tile.coords),[0,0]),d=l.options.size,_=[r.texturePadding[3]/d[0],r.texturePadding[0]/d[1],r.texturePadding[1]/d[0],r.texturePadding[2]/d[1]],u=r.wallPadding.map(v=>v*c),h=r.sliceSize.map(v=>v*c),f=[r.horizontal.maxInterval*c,r.vertical.maxInterval*c],m=[ur(r.horizontal.mode),ur(r.vertical.mode)];t.renderer.enableTexture(l,0),t.renderer.bindShaderProgram(s,{u_sr2d_texture:0,u_vec4_wall_padding_su:[u[3],u[0],u[1],u[2]],u_vec4_texture_padding_un:_,u_vec2_texture_part_count:[r.horizontal.slicesCount,r.vertical.slicesCount],u_vec2_max_interval_su:f,u_vec2_texture_slice_size_su:h,u_ivec2_layout_mode:m,u_int_texture_index:i.attributes.textureIndex})};function ur(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 yh="FRAGMENT",xh="VERTEX",bh="FOG",wh="SKY",Sh="METALLIC_ROUGHNESS_DEBUG",Th="PBR_TEXTURE",Mh="AO_TEXTURE",Eh="MAP_MESH_TEXTURE",Ih="COLOR_TEXTURE",hr="ALPHA_MODE",Ch="1",Ph="2",fr="LIGHT_MODEL",Lh="1",Bh="2",zh="DEPTH_TEXTURE_SHADOW",Rh="RENDER_SHADOWS",Fh="UBO",Dh="SCREENDOOR",Oh="ENTRANCE_ARROWS_ROUNDING",Nh="MALI_GPU",kh="VARYINGS_LIMIT_9",Ho="MIX_COLOR_MODE",Uh="1",mr="2",Hh="MIX_COLOR_MODE_VERTEX_ATTRIBUTE_NAME",Gh="1",Vh=n.Shader.createShaderDefinitions([{type:Ho,value:Uh}]),jh=n.Shader.createShaderDefinitions([{type:Ho,value:mr}]),Zh=n.Shader.createShaderDefinitions([{type:Ho,value:mr},{type:Hh,value:Gh}]),Wh={value:[0,0,0]};function ge(s,e){return n.makeBinderContext(s.styleZoom,s.styleState,e.attributes.tileData,!1,e.tile.dynamicObject)}const $h=(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},Go=(s,e)=>{const t=e.assetManager.textures[s.attributes.atlasIndex];return t?(s.renderingProperties.atlasTexture=t,!0):!1},pr=(s,e)=>{const t=e.imageManager.getTexture(s.attributes.textureIndex);return t?(s.renderingProperties.texture=t,!0):!1},ri=(s,e)=>{const{range:t,fontIndex:i,styleId:o}=s.attributes,a=e.styleManager.getStyle(o);if(!a)return!1;const r=a.fonts[i],l=e.assetManager.getFontTextureByName(r,t);return l?(s.renderingProperties.fontTexture=l,!0):!1},Vo=(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(),a=i==null?void 0:i.scale;return!(!o||!a)},Xh=(s,{imageManager:e})=>{const t=e.getTexture(s.attributes.rampTextureIndex);return t?(s.renderingProperties.rampTexture=t,!0):!1},Kh=(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},vr=(s,{demManager:e,renderer:t,map:i})=>{var r;if(!i.state.demMode)return!1;const o=e.getHillshadeFramebufferId(),a=(r=t.getFramebuffer(o))==null?void 0:r.renderTarget.getTexture();return a?(s.renderingProperties.hillshadeTexture=a,!0):!1},gr=(s,{demManager:e,renderer:t,map:i})=>{if(!i.state.demMode)return!1;const o=e.getFlatFramebufferId(),a=t.getFramebuffer(o);if(!a)return!1;const r=a.renderTarget.getTexture();return r?(s.renderingProperties.flatTexture=r,!0):!1},yr=(s,{demManager:e,renderer:t,map:i})=>{if(!i.state.demMode)return!1;const o=e.getIdentifyFlatFramebufferId(),a=t.getFramebuffer(o);if(!a)return!1;const r=a.renderTarget.getTexture();return r?(s.renderingProperties.flatIdentifyTexture=r,!0):!1},qh=(s,e,t,i)=>{var l,c;const{renderingProperties:o}=s,{resolvedUvIndex:a}=o,{colorTextureUvIndex:r}=i.style;return r!==void 0&&a!==r&&(((c=(l=s.meta)==null?void 0:l.availableTextureCoords)!=null?c:[])[r]&&s.vao.setAttributesAliases({texcoord_color:`texcoord_${r}`}),o.resolvedUvIndex=r),!0},Yh=(s,e,t,i)=>{var h,f;const{styleId:o,colorTexture:a,aoTexture:r,pbrTexture:l,meshTier:c}=s.attributes,{renderingProperties:d}=s,{modelId:_}=d,u=e.assetManager.getModel(_!=null?_:NaN,o);return!u||(a!==void 0&&u.textures[a]&&(d.resolvedColorTexture=a),r!==void 0&&u.textures[r]&&(d.resolvedAoTexture=r),l!==void 0&&u.textures[l]?d.resolvedPbrTexture=l:(d.resolvedMetallic=(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?Vo(s,e):!0},xr=(s,{modelsScene:e})=>{const t=e.getModelOpacity(s);return s.renderingProperties.resolvedOpacity=t,t!==0},br=(s,{modelsScene:e})=>{const t=e.getModelHeightFactor(s);return s.renderingProperties.resolvedHeightFactor=t,t!==0},wr=(s,e,t,i)=>{const o=ge(t,s),a=n.resolveNumber(i.style.width,o);if(a===0)return!1;const r=n.resolveExpression(i.style.pattern,o);return!r||r[0]===n.LinePatternType.None?!1:(s.renderingProperties.width=a,s.renderingProperties.pattern=r,!0)},Qh=(s,e,t)=>Yo(t,s.attributes.animDirection)!==0,Sr=(s,e,t,i)=>{const o=ge(t,s);return n.resolveNumber(i.style.iconOpacity,o)*Yo(t,s.attributes.animDirection)!==0},Tr=(s,e)=>!e.map.getFeatureFlag("transparentBuildingsOff"),N=(s,e,t,i)=>Jh(s.tile,t,i),Mr=(s,e,t)=>{var o,a,r,l,c,d;if((o=s.meta)!=null&&o.planId&&(!t.styleState._activeFloorIds||!t.styleState._activeFloorIds.includes(s.meta.planId))||(r=(a=s.meta)==null?void 0:a.linkedIds)!=null&&r.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)))},Jh=(s,e,t)=>{const{purpose:i,detailLevel:o}=s,{styleZoom:a}=e;switch(i){case"zenith":case"traffic":case"geojson":const r=o<uf(i)?n.clamp(a,o,o+.99999):a;return t.minzoom<=r&&r<t.maxzoom;case"dynamicObject":return t.minzoom<=a&&a<=t.maxzoom;default:return t.minzoom<=a&&a<t.maxzoom}},Ah=(s,e,t)=>{var r;const{styleZoom:i}=t,{tile:o}=s;if(o.purpose!=="zenith"||i>n.tiles.maxUniverseZoom)return!0;let a=n.tiles.maxUniverseZoom;if(o.sourceId){const l=e.sourceStorage.getSourceById(o.sourceId);a=(l==null?void 0:l.type)==="zenith"&&(r=l.getOptions().strokeMinZoom)!=null?r:n.tiles.maxUniverseZoom}return i>a},et=(s,e,t,i)=>{const{styleZoom:o}=t;return o>=i.minzoom&&o<i.maxzoom},jo=(s,e)=>s.attributes.id===void 0?!0:!e.modelLayer.isHidden(s.attributes.id),Zo=(s,e,t,i)=>{const o=ge(t,s);return n.resolveNumber(i.style.iconWidth,o)>0},Er=(s,e,t,i)=>{const{layerSettings:o}=s,{uniformSet:a}=o,r=s.attributes.labelIndex,l=i.style;if(a==="fontHalo"){let{textHaloColor:c}=l;switch(r){case n.LabelIndex.Icon:c=l.iconTextHaloColor;break;case n.LabelIndex.Second:c=l.textHaloColor2;break}if(!c)return!1}return!0},bn=(s,e,t,i)=>!(s.layerSettings.uniformSet==="fontHalo"&&!i.style.textHaloColor),Wo=(s,e,t,i)=>{var l,c,d,_,u,h;const o=ge(t,s),a=i.style;if(s.symbol==="point")switch(s.attributes.labelIndex){case n.LabelIndex.Second:return((c=n.resolveNumber((l=a.textHaloWidth2)!=null?l:null,o))!=null?c:0)>0&&!!a.textHaloColor2;case n.LabelIndex.Icon:return((_=n.resolveNumber((d=a.iconTextHaloWidth)!=null?d:null,o))!=null?_:0)>0&&!!a.iconTextHaloColor;case n.LabelIndex.First:break}return((h=n.resolveNumber((u=a.textHaloWidth)!=null?u:null,o))!=null?h:0)>0&&!!a.textHaloColor},Ir=(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},lt=(s,e,t,i)=>{const o=n.resolveNumber(i.style.width,ge(t,s));return s.renderingProperties.widthResolved=o,o!==0},Ii=(s,e,t,i)=>{const o=ge(t,s),a=n.resolveNumber(i.style.strokeWidth,o);return s.renderingProperties.widthResolved=a,a!==0},ef=(s,e,t,i)=>{const o=ge(t,s),a=n.resolveNumber(i.style.strokeWidth,o);if(a===0)return!1;const r=n.resolveNumber(i.style.width,o);return s.renderingProperties.widthResolved=r+a*2,!0},tf=(s,e,t,i)=>{const o=ge(t,s),a=n.resolveNumber(i.style.strokeWidth2,o);if(a===0)return!1;const r=n.resolveNumber(i.style.width,o),l=n.resolveNumber(i.style.strokeWidth,o);return s.renderingProperties.widthResolved=r+l*2+a*2,!0},nf=(s,e,t,i)=>{const o=ge(t,s),a=n.resolveNumber(i.style.width,o),r=n.resolveNumber(i.style.strokeWidth,o),l=n.resolveNumber(i.style.strokeWidth2,o),c=a+r*2+l*2;return s.renderingProperties.widthResolved=c,c!==0},Lt=(s,e,t)=>{const i=Yo(t,s.attributes.animDirection);return s.renderingProperties.opacityResolved=i,i!==0},of=(s,e,t,i)=>(s.renderingProperties.resolvedRadius=n.resolveNumber(i.style.radius,ge(t,s)),s.renderingProperties.resolvedRadius>0),Cr=(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 a=ge(t,s),r=n.resolveExpression(o,a);return s.renderingProperties.mat4_gradient[0]=0,n.isStyleColor(r)?it(s,r):n.isStyleGradient(r)&&(Qo(r,s.tile.readiness,s.renderingProperties.mat4_gradient),r.mixFactor&&(s.renderingProperties.mixFactorColor=r.mixFactor)),!0},$o=(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),Qo(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)},Pr=(s,e,t,i)=>{const o=s.renderingProperties.color;if(!o)return!1;s.renderingProperties.mat4_gradient||(s.renderingProperties.mat4_gradient=new Float32Array(16));const a=ge(t,s),r=n.resolveColor(i.style.sideColor,a).value,l=n.equals(o.value,r),c=l?i.style.sideColor:i.style.sideStrokeColor,d=n.resolveGradient(c,ge(t,s));return d?(n.copy$1(o.value,d.values[0].value),s.renderingProperties.mixFactorColor=d.mixFactor,Qo(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]),ne=(s,e)=>s.attributes.floorId?s.symbol==="polygonExtrusion"&&s.attributes.isFloorStack?e.floorManager.isVisibleFloorStackObject(s.attributes.floorId):e.floorManager.isVisibleFloorObject(s.attributes.floorId):!0,sf=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},Lr=(s,e,t,i)=>{const o=n.makeBinderContext(t.styleZoom,t.styleState,s.attributes.tileData,!!s.layerSettings.isOverlappedObject);return it(s,n.resolveColor(i.style.color,o)),s.renderingProperties.color.value[3]!==0},Xo=(s,e,t,i)=>(it(s,n.resolveColor(i.style.topColor,ge(t,s))),s.renderingProperties.color.value[3]!==0),wn=(s,e,t,i)=>(it(s,n.resolveColor(i.style.sideColor,ge(t,s))),s.renderingProperties.color.value[3]!==0),Ci=(s,e,t,i)=>(it(s,n.resolveColor(i.style.strokeColor,ge(t,s))),s.renderingProperties.color.value[3]!==0),af=(s,e,t,i)=>{switch(s.attributes.side){case n.MeshFillSide.top:it(s,n.resolveColor(i.style.strokeColor,ge(t,s)));break;case n.MeshFillSide.side:it(s,n.resolveColor(i.style.sideColor,ge(t,s)));break;case n.MeshFillSide.bottom:it(s,n.resolveColor(i.style.bottomColor,ge(t,s)));break;default:it(s,Wh);break}return s.renderingProperties.color.value[3]!==0},rf=(s,e,t,i)=>(it(s,n.resolveColor(i.style.strokeColor2,ge(t,s))),s.renderingProperties.color.value[3]!==0),Ko=(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},Br=(s,e,t,i)=>{const o=s.renderingProperties.color;if(!o)return!1;const a=ge(t,s),r=n.resolveColor(i.style.strokeColor,a).value,l=n.resolveNumber(i.style.strokeWidth,a);return n.equals(o.value,r)&&o.value[3]===1&&l<=1&&(o.value[3]*=t.stillness),o.value[3]!==0},lf=(s,e,t,i)=>{const o=s.renderingProperties.color;if(!o)return!1;const a=ge(t,s),r=n.resolveColor(i.style.topColor,a).value,l=n.resolveNumber(i.style.strokeWidth,a);return n.equals(o.value,r)&&o.value[3]===1&&l<=1&&(o.value[3]*=t.stillness),o.value[3]!==0},zr=(s,e,t,i)=>{const o=n.resolveColor(i.style.sideStrokeColor,ge(t,s));return it(s,o),s.renderingProperties.color.value[3]!==0},tt=(s,e,t,i)=>{const o=n.resolveColor(i.style.color,ge(t,s),!0),a=n.isStyleMixColor(o)?o.color1:o;if(it(s,a),n.isStyleMixColor(o)&&!(o.factor.type==="read-from-target"&&!e.renderer.doesDrawTargetFramebufferExist(o.factor.name))){if(hf(s,o),s.renderingProperties.color.value[3]===0&&s.renderingProperties.mixColor.color2.value[3]===0)return!1;const{factor:{type:r,name:l}}=s.renderingProperties.mixColor;switch(r){case"read-from-target":{s.shaderDefinitions=Vh;break}case"vertex-attribute":{switch(l){case"denormalized_distance_to_line":s.shaderDefinitions=Zh;break;default:s.shaderDefinitions=jh;break}break}default:n.assertUnreachable(r)}return!0}return s.renderingProperties.color.value[3]!==0},cf=(s,e,t,i)=>{it(s,n.resolveColor(i.style.color,ge(t,s)));const{color:o,resolvedOpacity:a}=s.renderingProperties;return n.mul(o.value,o.value,s.attributes.colorFactor),o.value[3]*=a!=null?a:0,o.value[3]!==0},Rr=(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 a=s==null?void 0:s.tile.ids;return!(a!=null&&a.isHidden(t,n.HideLevel.PolygonExtrusion))},qo=B(N,Rr,fe,(s,e)=>{if(!s.bboxWorld||s.tile.dynamicObject||s.renderingProperties.animationStack&&s.renderingProperties.animationStack.length>0)return!0;if(e.environmentManager.isAABBInFog(s.bboxWorld))return!1;const t=e.camera.getViewportVertices();return n.tetragonIntersectsBounds(t,s.bboxWorld)},ne,Mr,xr,br,cf),df=B(N,Rr,fe,Mr,xr,br),Fr=B(qh,Yh),_f=(s,e,t,i)=>{var l;const o=s.attributes.textureIndex,a=(l=i.style.sideTextures)==null?void 0:l[o],r=e.imageManager.getTexture(i.sideTextureIndices[o]);return!!a&&!!r};function B(...s){return(e,t,i,o)=>{for(const a of s)if(!a(e,t,i,o))return!1;return!0}}function uf(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 Yo(s,e){return e===n.LabelingAnimation.none?1:e===n.LabelingAnimation.fadeIn?s.labelingOpacity:1-s.labelingOpacity}function Qo(s,e,t){if(!s.steps.length){t[0]=0;return}t[0]=n.clamp(s.values.length,0,3);for(let i=0;i<t[0];i++){const o=s.values[i],a=n.getColorForShaders(o);n.scale$4(a,a,e),t[i+1]=s.steps[i];const r=(i+1)*4;t[r]=a[0],t[r+1]=a[1],t[r+2]=a[2],t[r+3]=a[3]}}function it(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 hf(s,e){s.renderingProperties.mixColor=e}function Dr(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 Or(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 Sn(s,e="image/png"){const t=new Blob([s],{type:e}),i=URL.createObjectURL(t),o=document.createElement("img");return new Promise(a=>{o.onload=()=>{URL.revokeObjectURL(i),a(o)},s.byteLength===0?o.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAC0lEQVQYV2NgAAIAAAUAAarVyFEAAAAASUVORK5CYII=":o.src=i})}function Nr(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 kr(s,e,t){var _;const i=e[s.outputBufferView],o=(_=t.get(s.actionId))!=null?_:-1,a=Math.ceil(o),r=Math.floor(o),l=(o||1)%1,c=Math.round(o);return!i||t.size<=0||r<0||a<0||c<0?void 0:{outputTransforms:new Float32Array(es(i),s.outputBufferOffset,s.outputBufferLength),selfKeyFrame:c,selfKeyFrameMin:r,selfKeyFrameMax:a,keyFrameLerp:l}}const ff={SCALAR:1,VEC2:2,VEC3:3,VEC4:4};function Ur(s,e,t){const{outputTransforms:i,selfKeyFrame:o,selfKeyFrameMin:a,selfKeyFrameMax:r,keyFrameLerp:l}=t,c=ff[s];if(e==="STEP")return Jo(i,o,c);const d=Jo(i,a,c),_=Jo(i,r,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 Hr(s,e,t,i){let o=[0,0],a=[1,1],r=0;i&&e.forEach(u=>{if(!u.targetPointerExtension)return;const h=kr(u,t,i);if(!h)return;const f=Ur(u.outputType,u.interpolation,h);u.outputType==="SCALAR"?u.targetPointerExtension==="KHR_texture_transform/rotation"&&(r=f[0]):u.outputType==="VEC2"&&(u.targetPointerExtension==="KHR_texture_transform/offset"&&(o=f),u.targetPointerExtension==="KHR_texture_transform/scale"&&(a=f))});const l=[1,0,0,0,1,0,o[0],o[1],1],c=[Math.cos(r),Math.sin(r),0,-Math.sin(r),Math.cos(r),0,0,0,1],d=[a[0],0,0,0,a[1],0,0,0,1],_=n.multiply$1(n.create$4(),l,c);s=n.multiply$1(s,_,d)}function Gr(s,e,t,i,o){const a=Array();o&&e.forEach(r=>{if(r.targetPointerExtension)return;const l=kr(r,i,o);if(!l)return;const c=Ur(r.outputType,r.interpolation,l);(r.outputType==="VEC4"||r.outputType==="VEC3")&&(t[r.targetMatIndex[0]][r.targetMatIndex[1]]=c)});for(let r=0;r<t.length;r++){const l=t[r];if(l.length===3){const c=n.create$2();n.fromRotationTranslationScale(c,l[1],l[0],l[2]),a.push(c)}else a.push(l)}Mf(s,a)}function Jo(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 mf(s,e,t,i){s.animations.forEach((o,a)=>{o.channels.forEach((r,l)=>{var d,_;const c=(_=(d=r.target)==null?void 0:d.extensions)==null?void 0:_.KHR_animation_pointer;if(c){const u=c.pointer,h=vf(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[r.sampler],p=o.name||"default",v=s.accessors[m.input];if(v.bufferView===void 0||s.bufferViews[v.bufferView]===void 0)return;Tn(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;Tn(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=Vr(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}_${a}_${l}`,animationIndex:a,animationName:p,targetPointerExtension:h})}}})})}function pf(s,e,t,i,o){s.animations.forEach((a,r)=>{a.channels.forEach((l,c)=>{if(l.target.node===t){const d=a.samplers[l.sampler],_=a.name||"default",u=s.accessors[d.input];if(u.bufferView===void 0||s.bufferViews[u.bufferView]===void 0)return;Tn(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;Tn(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=Vr(l.target.path);i.push({min:u.min,max:u.max,frameCount:u.count,keyFrameType:"SCALAR",interpolation:d.interpolation||"LINEAR",outputType:p.outputType,outputBufferView:f.bufferView,outputBufferOffset:m.byteOffset||0,outputBufferLength:m.byteLength/p.bufferStride,targetMatIndex:[o.length-1,p.targetindex],actionId:`${a.name}_${r}_${c}`,animationIndex:r,animationName:_})}})})}function vf(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 Vr(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 Tn(s,e,t,i){const o=e.bufferViews[t];if(o===void 0)return;if(!s.buffers[t]){const r=e.buffers[o.buffer].buffer;if(!r)return;s.buffers[t]=es(r)}const a=s.buffers[t];if(!(a instanceof n.Buffer))return a}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 yf=new Set(["position","texcoord_0","texcoord_1","texcoord_2","texcoord_3","normal","tangent"]),xf=Array.from(n.create$2()),bf={pbrMetallicRoughness:{baseColorFactor:[1,1,1,1],metallicFactor:1,roughnessFactor:1},emissiveFactor:[0,0,0],alphaMode:"OPAQUE",alphaCutoff:.5,doubleSided:!1};function wf(s){return jr(s,bf),s}function jr(s,e){for(const t in e)s[t]===void 0?s[t]=e[t]:typeof s[t]=="object"&&jr(s[t],e[t])}var nt=(s=>(s[s.Pending=1]="Pending",s[s.Loaded=2]="Loaded",s[s.Failed=3]="Failed",s))(nt||{});function Sf(s){return{buffers:[],textures:[],status:1,scenes:[],defaultScene:0,preserve:s}}function Tf(s,e,t,i,o,a){var c;const r=[],l=[];for(const d of t.scenes){const _=[];Zr(_,s,d.nodes,t,r,l,e,i,o,a),s.scenes.push({id:n.uniqId(),name:d.name,objects:_})}return s.defaultScene=(c=t.scene)!=null?c:0,s}function Zr(s,e,t,i,o,a,r,l,c,d){var u,h,f,m,p,v;if(!t)return;const _=r.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=[...a];if(g.matrix&&y.push(g.matrix),g.translation&&g.rotation&&g.scale){const T=[];T.push(g.translation,g.rotation,g.scale),y.push(T),pf(i,e,x,b,y)}if(g.mesh!==void 0){const T=i.meshes[g.mesh];let S=d?n.GltfDemPosition.flat:n.GltfDemPosition.default;n.isObject(g.extras)&&(g.extras.dem==="flat"?S=n.GltfDemPosition.flat:g.extras.dem==="instance"&&(S=n.GltfDemPosition.default));const L=new Float32Array(16),E=new Float32Array(9);Hr(E,b,e.buffers),Gr(L,b,y,e.buffers);let R,H;if(g.children){const V=[];for(const P of g.children){const F=i.nodes[P];Cf(F)&&V.push(F)}if(V.length){const P=V[0];if(P.extras.dem==="centroid")S=n.GltfDemPosition.centroid,R=[P.translation[0],P.translation[2]];else if(P.extras.dem==="axis"){S=n.GltfDemPosition.axis;const F=gf(V,se=>se.extras.dem==="axis");H=[P.translation[0],P.translation[2],(F!=null?F:P).translation[0],(F!=null?F:P).translation[2]]}}}for(const V of T.primitives){const P=[],F={};let se=0,Y,z;for(const Te in V.attributes){const Ft=/TEXCOORD_(\d+)/.exec(Te);Ft&&(P[parseInt(Ft[1],10)]=!0);const Mt=Te.toLowerCase();if(!yf.has(Mt))continue;const qt=V.attributes[Te],$e=i.accessors[qt];if($e.bufferView===void 0)continue;const hi=i.bufferViews[$e.bufferView];if(hi===void 0)continue;const Ni=Wr(r,e,i,$e.bufferView,$e.componentType);if(Ni){if(Mt==="position"&&(Y=$e.min,z=$e.max),Ni.purpose="gltfMesh",F[Te.toLowerCase()]=new n.BufferChannel(Ni,{itemSize:Ef($e.type),dataType:n.componentTypeToWebGl($e.componentType),stride:(u=hi.byteStride)!=null?u:0,offset:(h=$e.byteOffset)!=null?h:0,normalized:!!$e.normalized}),!R&&Te.toLowerCase()==="position"){const Os=$e.min,Ns=$e.max;Os&&Ns&&(R=[(Ns[0]+Os[0])/2,(Ns[2]+Os[2])/2])}se===0&&(se=$e.count)}}Y||(Y=[0,0,0]),z||(z=[0,0,0]);let ae;if(V.indices!==void 0){const Te=i.accessors[V.indices];if(Te.bufferView===void 0||(ae=Wr(r,e,i,Te.bufferView,Te.componentType,!0),!ae))continue;ae.purpose="gltfIndices",se=Te.count}const we=V.material!==void 0?i.materials[V.material]:{},Se=wf(we),Ke={},Ze={localMatrix:L,textureTransformMatrix:E,animationStack:b,transformStack:y,availableTextureCoords:P,attributesAliases:Ke,colorFactor:[...Se.pbrMetallicRoughness.baseColorFactor],colorTexture:NaN,aoTexture:NaN,pbrTexture:NaN,centroid:R,axis:H,demPosition:S},We=[];Se.alphaMode==="OPAQUE"?We.push({type:hr,value:Ch}):Se.alphaMode==="BLEND"&&We.push({type:hr,value:Ph});const zt=Se.pbrMetallicRoughness.baseColorTexture;zt&&(We.push({type:Ih}),Ke.texcoord_color=`texcoord_${(f=zt.texCoord)!=null?f:0}`,Ao(e,i,zt),Ze.colorTexture=zt.index);const Pe=Se.pbrMetallicRoughness.metallicRoughnessTexture;if(Pe){We.push({type:Th}),Ao(e,i,Pe),Ze.pbrTexture=Pe.index;const Te=typeof Pe.texCoord=="number"?Pe.texCoord:0;Ke.texcoord_pbr=`texcoord_${Te}`,P[Te]=!1}else Ze.roughness=(m=Se.pbrMetallicRoughness.roughnessFactor)!=null?m:1,Ze.metallic=(p=Se.pbrMetallicRoughness.metallicFactor)!=null?p:1;Number.isNaN(c.style.roughness)||We.push({type:Sh}),((v=g.extras)==null?void 0:v.tier)!==void 0&&(Ze.meshTier=g.extras.tier,We.push({type:Eh})),c.style.lightingModel==="pbr"?We.push({type:fr,value:Bh}):We.push({type:fr,value:Lh});const Rt=Se.occlusionTexture;if(Rt){We.push({type:Mh}),Ao(e,i,Rt),Ze.aoTexture=Rt.index;const Te=typeof Rt.texCoord=="number"?Rt.texCoord:0;Ke.texcoord_ao=`texcoord_${Te}`,P[Te]=!1}mf(i,e,b,V.material),s.push({start:0,count:se,attributes:Ze,drawMode:V.mode,accessors:F,elementsBuffer:ae,shaderDefinitions:We,bbox:{min:Y,max:z}})}}g.children&&Zr(s,e,g.children,i,y,b,r,l,c,d)}}function Ao(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 a=e.images[o.source],r=e.samplers[o.sampler];if(!r||!a)return;const l={flipY:!1};if(r.magFilter&&(l.magFilter=Xi(r.magFilter)),r.minFilter&&(l.minFilter=Xi(r.minFilter)),r.wrapS&&(l.wrapS=Xi(r.wrapS)),r.wrapT&&(l.wrapT=Xi(r.wrapT)),t.texCoord!==void 0&&(l.texcoord=t.texCoord),!a.image&&a.bufferView){If(e,a).then(d=>{d&&(a.image=d,s.textures[i]=new w(a.image,l))});return}s.textures[i]=new w(a.image,l)}function Wr(s,e,t,i,o,a=!1){const r=t.bufferViews[i];if(r===void 0)return;if(!e.buffers[i]){const c=t.buffers[r.buffer].buffer;if(!c)return;const d=new DataView(es(c),r.byteOffset,r.byteLength),_=s.createBuffer(d,{dataType:n.componentTypeToWebGl(o)},a);e.buffers[i]=_}const l=e.buffers[i];if(!(l instanceof ArrayBuffer))return l}function Mf(s=[],e){if(e.length===0)return Array.from(xf);n.copy(s,e[0]);for(let t=1;t<e.length;t++)n.mul$1(s,s,e[t]);return s}function Ef(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 es(s){return s instanceof ArrayBuffer?s:s.buffer}function If(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?Sn(new Uint8Array(i,t.byteOffset,t.byteLength),e.mimeType):!1})}function Cf(s){return s.mesh===void 0&&n.isObject(s.extras)&&(s.extras.dem==="centroid"||s.extras.dem==="axis")}const Pf=n.len$1([1,1,1]),Vt=n.create$1(),ts=n.create$1(),Lf=n.create$2();function Bf(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 is(s){return s.symbol==="gltfModel"&&s.sink==="instances"}function zf(s,e,t,i,o){var d;const a=s.modelMatrices.get(0);if(!a)return;const r=[t[0]/n.maxUint16Value,t[1]/n.maxUint16Value,t[2]/n.maxUint16Value],l=[t[3]/n.maxUint16Value,t[4]/n.maxUint16Value,t[5]/n.maxUint16Value],c={min:[0,0,0],max:[0,0,0]};if(n.transformMat4$1(c.min,r,a),n.transformMat4$1(c.max,l,a),o)if(i.tMatrix3x3){const _=Rf(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=Vt,h=ts;n.decomposeMat4(e,u,h);const f=n.len$1(u)/Pf;_*=f,_+=n.len$1(h)}_*=(d=i.maxDiag)!=null?d:1,n.set(Vt,-_,-_,-_),n.add$1(c.min,c.min,Vt),n.set(Vt,_,_,_),n.add$1(c.max,c.max,Vt)}return c}function Rf(s,e,t){const i=n.set$2(Lf,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(Vt,s.min,s.max,.5),a=n.scale(ts,n.sub$1(ts,s.max,s.min),.5),r=n.transformMat4$1(Vt,o,i),l=n.fromValues(Math.abs(i[0])*a[0]+Math.abs(i[4])*a[1]+Math.abs(i[8])*a[2],Math.abs(i[1])*a[0]+Math.abs(i[5])*a[1]+Math.abs(i[9])*a[2],Math.abs(i[2])*a[0]+Math.abs(i[6])*a[1]+Math.abs(i[10])*a[2]),c=n.sub$1(n.create$1(),r,l),d=n.add$1(n.create$1(),r,l);return{min:c,max:d}}class Ff{constructor(e){this.modules=e,this.queue=new Map}enqueue(e,t){this.queue.set(t.id,{batch:e,tile:t,state:void 0})}update(){const{renderer:e,tileManager:t}=this.modules;for(const i of t.getTileObjects()){const o=this.queue.get(i.id);if(!o)continue;const{batch:a}=o,{symbol:r,sink:l}=a,c=n.getSymbolLayers(e,r,l);if(!c){console.error(`Cannot happen! Symbol ${r} does not have sink ${l}!`);continue}const d=c[0].instanceBinder;if(!d){console.error("Cannot happen! No instanceBinder for batch inside instanceLinker queue.");continue}const _=d(this.modules,a,i,o.state);if(!_){this.queue.delete(i.id);continue}o.state=_}}}function Df(s,e,t,i,o,a,r,l,c,d,_,u){const h=n.stride(a,r),f=n.getSymbolLayers(e,a,r),{accessors:m,elementsBuffer:p,count:v,drawMode:x,bbox:g}=i,y=n.Shader.createShaderDefinitions(i.shaderDefinitions);_.linkId=t;for(const b of f){const T=b.uniformSet||"fill",S=JSON.stringify(Object.values(c))+"_"+T+"_"+o.detailLevel,L=e.getShaderProgram(b.programName,y),E=l.buffer;if(!E){console.error(`Expected existing buffer while linking instance, but ${E} found.`);continue}const R=b.vaoCreator(E,L,p,m);_.attributesAliases&&R.setAttributesAliases(_.attributesAliases);const H={id:n.uniqId(),type:n.SceneObjectType.Tile,layerSettings:b,start:0,count:v,attributes:c,shaderDefinitions:y,renderingProperties:d,meta:_,attributesHash:S,vao:R,drawMode:x,tile:o,bbox:g,bboxWorld:u,symbol:a,sink:r,canRender:!0,instanceCount:(l.rangeEnd-l.rangeStart)/h};o.push(H),s.push(H)}s.length&&e.addRerenderEvent({type:"instanceLink"})}function $r(s,e,t){Of(e,i=>{var a;const o=((a=i.meta)==null?void 0:a.linkId)===t;return o&&s.push(i),!o})}function Of(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 Nf={min:[0,0,0],max:[0,0,0]},Mn=(s,e,t,i)=>{var c,d;const{assetManager:o,modelsScene:a,renderer:r}=s;if(i||(i={}),t.destroyed){const _=[];for(const u in i){const h=i[+u];Number.isNaN(h.linkId)||$r(_,t,h.linkId)}for(const u of _)a.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=Nf,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;a.updateModelId(m,h,p,t,v);const b=m.modelId;if(b===void 0||Number.isNaN(b))continue;const T=m.sceneId;if(T===void 0||Number.isNaN(T)||g===b&&y===T)continue;const S=o.getModel(b,x);if(!S||S.status!==nt.Loaded)continue;const L=(d=(c=S==null?void 0:S.scenes.find(H=>H.id===m.sceneId))==null?void 0:c.objects)!=null?d:[];if(L.length===0)continue;const E=m.linkId;if(!Number.isNaN(E)){const H=[];$r(H,t,E);for(const V of H)a.removeSceneObject(V.id)}const R=n.uniqId();m.linkId=R;for(const H of L){const V=t.modelMatrices.get(0),P=new Float32Array(16);Bf(P,V);const{attributesAliases:F,availableTextureCoords:se,colorTexture:Y,colorFactor:z,aoTexture:ae,pbrTexture:we,metallic:Se,roughness:Ke,meshTier:Ze,animationStack:We,transformStack:zt,localMatrix:Pe,demPosition:Rt,axis:Te,centroid:Ft,textureTransformMatrix:Mt}=H.attributes,qt=zf(t,Pe,f,u,H.bbox);!m.referenceBbox&&qt&&(m.referenceBbox=qt),Df(l,r,R,H,t,e.symbol,e.sink,u,I({colorTexture:Y,colorFactor:z,aoTexture:ae,pbrTexture:we,metallic:Se,roughness:Ke,meshTier:Ze,demPosition:Rt,axis:Te,centroid:Ft},h),{modelId:b,animationStack:We,transformStack:zt,localMatrix:new Float32Array(Pe!=null?Pe:[]),textureTransformMatrix:new Float32Array(Mt!=null?Mt:[]),transformMatrix:P},ce(I({},u.meta),{attributesAliases:F,availableTextureCoords:se}),qt)}}return l.forEach(_=>{a.addSceneObject(_)}),i},En=new Float32Array(16),Xr=1e-4;let ze,Re;function C(...s){return(t,i,o,a,r,l)=>{for(const c of s)if(!c(t,i,o,a,r,l))return!1;return!0}}const Z=(s,e,t,i)=>(t.renderer.bindShaderProgram(s,{u_mat4_mvp:i.tile.renderMvpMatrix}),!0);function Kr(s,e){return!!s.styleState.globeEnabled&&(e.coords[2]<n.globeConfig.globeMaxZoom&&e.ecefDataState===n.EcefDataState.DerivedFromTile||e.ecefDataState===n.EcefDataState.Present)}const ns=[0,0],qr=new Float32Array(4),Yr=n.create$3(),os=[0,0],ss=new Float64Array([0,0,0,1]),pe=(s,e,t,i)=>{const{camera:{globeRatio:o,ecefMvpMatrix:a,viewProjectionMatrix:r},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=Kr(e,u);let m=o;return f&&o<Xr?m=Xr:!f&&o>0&&(m=0),m===0||m===1?(c.bindShaderProgram(s,{u_mat4_flat_mvp:i.tile.renderMvpMatrix,u_mat4_ecef_mvp:a,u_float_crossfade:m}),!0):(n.Mercator.toGeo(e.center,os),ns[0]=n.degToRad(os[0]),ns[1]=Math.log(Math.tan(Math.PI/4+n.degToRad(os[1])/2)),ss[0]=e.center[0],ss[1]=e.center[1],n.transformMat4(Yr,ss,r),qr.set(Yr),c.bindShaderProgram(s,{u_mat4_flat_mvp:i.tile.renderMvpMatrix,u_mat4_ecef_mvp:a,u_mat4_vp:r,u_vec2_camera_merc:ns,u_vec4_vp_at_center:qr,u_float_crossfade:m}),!0)},In=n.maxTilePoint/2,kf=[In,In,0],Uf=[In+1,In,0],Bt=[0,0,0],Ot=[0,0,0],Qr=new WeakMap,Hf=16,jt=(s,e,{renderer:t},i)=>{if(!Kr(e,i.tile))t.bindShaderProgram(s,{u_float_ecef_scale:0});else{let o=Qr.get(i.tile);if(o===void 0){const a=n.createTileInfo(i.tile.coords);n.tilePointToMapPoint(Bt,kf,a),n.tilePointToMapPoint(Ot,Uf,a),n.Mercator.toGeo(Bt,Bt);const r=Bt[1];n.Mercator.toGeo(Ot,Ot),n.Ecef.fromGeo(Bt,Bt),n.Ecef.fromGeo(Ot,Ot);const l=Ot[0]-Bt[0],c=Ot[1]-Bt[1],d=Ot[2]-Bt[2],_=Math.sqrt(l*l+c*c+d*d),u=Math.min(n.Mercator.scaleFactor(r),Hf)/(Math.PI/2);o=_/n.worldSize*u,Qr.set(i.tile,o)}t.bindShaderProgram(s,{u_float_ecef_scale:o})}return!0},Cn=(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(En,i.tile.renderModelMatrix),t.renderer.bindShaderProgram(s,{u_mat4_model:En}),!0):!1,Pn=(s,e,t,i)=>(t.renderer.bindShaderProgram(s,{u_int_abs_z:i.attributes.absZ?1:0}),!0),O=(s,e,{renderer:t},i,o,a)=>{if(a.terrain3d){if(!i.tile.renderModelMatrix)return!1;t.bindShaderProgram(s,{u_mat4_dem_mvp:i.tile.renderDemMatrix,u_float_vertical_scale:1/i.tile.renderModelMatrix[10]})}return!0};function li(s,e){return n.makeBinderContext(s.styleZoom,s.styleState,e.attributes.tileData)}const as=(s,e,t,i,o)=>{var m;ze=void 0;const a=li(e,i),r=n.resolveString(o.style.textureImage,a);let l=!1;o.type==="polygon"&&(l=o.style.lengthUnits===n.LengthUnits.Meters);const c=t.styleManager.getStyle(i.attributes.styleId);if(!c)return!0;const d=(m=c.rasterSets.byKey[n.getStaticTextureRasterSetKey(r)])==null?void 0:m.rasters;if(!d)return!0;const _=n.resolveExpression(o.style.textureSize,a);let[u,h]=Array.isArray(_)?_:[_,_];if(l&&(u=u*n.getPixelsPerMeter(u,u),h=h*n.getPixelsPerMeter(h,h)),u<=0||h<=0)return!0;const f=n.selectRaster(d,u*window.devicePixelRatio,!0);return f===void 0||(ze=d[f]),!0},Jr=(s,e,t,i,o)=>{var m;Re=void 0;const a=li(e,i),r=n.resolveString(o.style.normalMapTextureImage,a),l=o.style.normalMapTextureLengthUnits===n.LengthUnits.Meters,c=t.styleManager.getStyle(i.attributes.styleId);if(!c)return!0;const d=(m=c.rasterSets.byKey[n.getStaticTextureRasterSetKey(r)])==null?void 0:m.rasters;if(!d)return!0;const _=n.resolveExpression(o.style.normalMapTextureSize,a);let[u,h]=Array.isArray(_)?_:[_,_];if(l&&(u=u*n.getPixelsPerMeter(u,u),h=h*n.getPixelsPerMeter(h,h)),u<=0||h<=0)return!0;const f=n.selectRaster(d,u*window.devicePixelRatio,!0);return f===void 0||(Re=d[f]),!0},rs=(s,e,{assetManager:t,renderer:i},o,a)=>{if(!ze)return i.bindShaderProgram(s,{u_int_is_textured:0}),!0;let r,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;a.type==="polygon"&&(f=a.style.lengthUnits===n.LengthUnits.Meters),i.enableTexture(h,0);let m;if(f){const p=li(e,o),v=n.resolveExpression(a.style.textureSize,p),[x,g]=Array.isArray(v)?v:[v,v],y=n.Mercator.toGeo(n.tileCoordsToMapPoint(_.coords)),b=n.Mercator.scaleFactor(y[1]),T=n.tileZoomToSize(_.zoomLevel)/n.MAP_POINTS_IN_METER/b,S=T/x,L=T/g,E=Math.trunc(n.atlasSize[0]/S),R=Math.trunc(n.atlasSize[1]/L);r=_.coords[0]*n.atlasSize[0]%E/E,l=_.coords[1]*n.atlasSize[1]%R/R,c=n.atlasSize[0]/E,d=n.atlasSize[1]/R}else m=n.tileSizeZpt*Math.pow(2,Math.round(u)-_.zoomLevel)*window.devicePixelRatio,r=_.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:[r,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},Ar=(s,e,t,i,o)=>{var g;const{assetManager:a,styleManager:r,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=a.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=li(e,i),b=n.resolveExpression(o.style.normalMapTextureSize,y),[T,S]=Array.isArray(b)?b:[b,b],L=n.Mercator.toGeo(n.tileCoordsToMapPoint(h.coords)),E=n.Mercator.scaleFactor(L[1]),R=n.tileZoomToSize(h.zoomLevel)/n.MAP_POINTS_IN_METER/E,H=R/T,V=R/S,P=Math.trunc(n.atlasSize[0]/H),F=Math.trunc(n.atlasSize[1]/V);c=h.coords[0]*n.atlasSize[0]%P/P,d=h.coords[1]*n.atlasSize[1]%F/F,_=n.atlasSize[0]/P,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=r.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)},Gf=(s,e,{renderer:t})=>(t.bindShaderProgram(s,{u_int_is_textured:0,u_int_is_normal_map_textured:0}),!0),el=(s,e,{renderer:t},i,o)=>{if(!Re)return!0;const a=li(e,i),r=n.resolveExpression(o.style.metallic,a),l=n.resolveExpression(o.style.roughness,a);return t.bindShaderProgram(s,{u_float_metallic:r,u_float_roughness:l}),!0},ls=[0,0,0,0],Vf=(s,e,{renderer:t},i)=>(n.tilePointToOffsetSize(ls,n.createTileInfo(i.tile.coords)),ls[3]=Number(e.globeMode),t.bindShaderProgram(s,{u_vec4_tilecoords:ls}),!0),jf=(s,e,t,i)=>{if(!ze)return t.renderer.bindShaderProgram(s,{u_int_is_textured:0}),!0;const{tile:o}=i,{zoom:a}=e,r=t.assetManager.textures[ze.atlasIndex];if(!r)return t.renderer.bindShaderProgram(s,{u_int_is_textured:0}),!0;t.renderer.enableTexture(r,0);const l=n.tileSizeZpt*Math.pow(2,Math.round(a)-o.zoomLevel)*window.devicePixelRatio;return t.renderer.bindShaderProgram(s,{u_int_is_textured:1,u_float_texture_vertical_scale:ze.h*o.size/l}),!0},Zf=(s,e,{styleManager:t,assetManager:i,renderer:o},a,r)=>{var y;const l=li(e,a),c=n.resolveString(r.style.iconImage,l),d=t.getStyle(a.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(r.style.width,l),h=n.resolveNumber(r.style.height,l),f=n.getPixelsPerMeter(u,h),m=u*f,p=h*f;if(m<=0||p<=0)return!1;const v=n.selectRaster(_,m*window.devicePixelRatio,!0);if(v===void 0)return!1;const 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},tl=new Float32Array(16);n.fromScaling(tl,[1/n.worldSize,1/n.worldSize,1/n.worldSize]);const Ln=(s,e,{animationManager:t,assetManager:i,renderer:o},a,r)=>{const{styleId:l}=a.attributes,{localMatrix:c,transformMatrix:d,modelId:_,textureTransformMatrix:u}=a.renderingProperties;if(_===void 0)return!1;const h=i.getModel(_,l);return h===void 0?!1:(t.animateGltfObject(a,r,h),o.bindShaderProgram(s,{u_mat4_localmatrix:c,u_mat3_transform_tex_matrix:u,u_mat4_instance:e.globeMode?tl:d}),!0)},Wf=(s,e,{renderer:t},i)=>i.tile.renderModelMatrix?(n.copy(En,i.tile.renderModelMatrix),t.bindShaderProgram(s,{u_mat4_model:En}),!0):!1,il=(s,e,{animationManager:t,renderer:i},o,a)=>{if(!Re)return!0;let r=[0,0,0,0],l=0;const[c,d]=t.animatePolygonNormalMapTexture(o,a);return r=d,l=c?1:0,i.bindShaderProgram(s,{u_vec4_normal_map_animated_offsets:r,u_int_normal_map_is_animated:l}),!0},$f=(s,e,t)=>!t.shadowManager.texture;function Xf(){return{line:{solid:[{programName:"road",vaoCreator:r_,stateBinder:Ne,needsVisibilityBuffer:!1,commonBinder:X(W,$,J),programBinder:th,objectBinder:M(tr,me,He),layerBinder:oe,zoomBinder:wt,tileBinder:C(q,pe,jt),cullMethod:B(N,fe,lt,tt)},{identify:!0,programName:"roadIdentify",vaoCreator:__,stateBinder:xt,needsVisibilityBuffer:!1,objectBinder:M(He),zoomBinder:wt,tileBinder:C(pe,jt),cullMethod:B(N,fe,lt,tt)}],patterned:[{programName:"patternedLine",vaoCreator:u_,stateBinder:Ne,needsVisibilityBuffer:!1,commonBinder:X(W,$,J),programBinder:Aa,layerBinder:oe,objectBinder:M(nr,He,Be,si),zoomBinder:rr,tileBinder:C(q,Z),cullMethod:B(N,fe,lt,wr)}],solid3d:[{programName:"line3D",vaoCreator:l_,stateBinder:mo,needsVisibilityBuffer:!1,commonBinder:X(W,$,J),programBinder:Ku,objectBinder:M(me,He,Ae,D),layerBinder:oe,zoomBinder:wt,tileBinder:C(q,Z,O),cullMethod:B(N,lt,tt),is3dMapAware:!0},{identify:!0,programName:"line3DIdentify",vaoCreator:c_,stateBinder:Me,needsVisibilityBuffer:!1,programBinder:ie,objectBinder:M(He,Ae,D),zoomBinder:wt,tileBinder:C(Z,O),cullMethod:B(N,lt,tt),is3dMapAware:!0}],patterned3d:[{programName:"patternedLine3D",vaoCreator:h_,stateBinder:mo,needsVisibilityBuffer:!1,commonBinder:X(W,$,J),programBinder:ih,layerBinder:oe,objectBinder:M(nr,He,Be,si,D),zoomBinder:rr,tileBinder:C(q,Z,O),cullMethod:B(N,lt,wr),is3dMapAware:!0}]},polygon:{fill:[{programName:"vtxColor",vaoCreator:i_,stateBinder:Ne,needsVisibilityBuffer:!0,commonBinder:X(W,$,J),programBinder:qa,layerBinder:Le(oe,ft,oa),objectBinder:M(me,er,Be,zo,he),tileBinder:C(as,rs,Jr,Ar,pe,q,il,el,Vf),cullMethod:B(N,ne,fe,tt)},{identify:!0,programName:"vtxColorIdentify",vaoCreator:a_,stateBinder:xt,needsVisibilityBuffer:!0,programBinder:ia,objectBinder:M(he),tileBinder:pe,cullMethod:B(N,ne,fe)}],fillWithMixFactor:[{programName:"vtxColor",vaoCreator:n_,stateBinder:j_,needsVisibilityBuffer:!0,commonBinder:X(W,$,J),programBinder:qa,layerBinder:Le(oe,ft,oa),objectBinder:M(me,er,Be,zo,he),tileBinder:C(as,rs,Jr,Ar,pe,q,il,el),cullMethod:B(N,ne,fe,tt)}],stroke:[{programName:"simpleLine2d",vaoCreator:C_,stateBinder:Ne,needsVisibilityBuffer:!0,commonBinder:X(W,$,J),programBinder:qu,layerBinder:Le(ia,Qi,oe),objectBinder:M(me,He,he),tileBinder:C(q,pe),cullMethod:B(Ah,N,ne,fe,Ii,Ci,Br),subRenderIndex:1}],shadow:[{programName:"vtxColor",vaoCreator:o_,stateBinder:Ne,needsVisibilityBuffer:!0,commonBinder:X(W,$),programBinder:at,layerBinder:ft,objectBinder:M(me,Be,he),tileBinder:C($f,Gf,pe,q),cullMethod:B(N,ne,fe,sf)}]},metricPoint:{fill:[{programName:"metricPoint",vaoCreator:s_,stateBinder:Ne,needsVisibilityBuffer:!1,commonBinder:X(W,J,$),programBinder:Ge,layerBinder:Le(oe,ft),objectBinder:M(me,he),tileBinder:C(Zf,Z,q),cullMethod:B(N,ne,tt)}]},mesh:{fill:[{programName:"mesh",vaoCreator:ua,stateBinder:Ea,needsVisibilityBuffer:!0,commonBinder:X(W,$,J),programBinder:pt,layerBinder:Le(oe,mt),objectBinder:M(me,Pt,Ti,Be,Je,D,Ae,rt,zo),tileBinder:C(as,rs,jf,q,Z,O),cullMethod:B(N,Cr),subRenderIndex:1,is3dMapAware:!0},{identify:!0,programName:"mesh",vaoCreator:ua,stateBinder:Me,needsVisibilityBuffer:!0,commonBinder:X(W,$,J),programBinder:pt,objectBinder:M(Je,D,Ae,rt),tileBinder:C(Z,O),cullMethod:B(N,Cr),subRenderIndex:1,is3dMapAware:!0},{depthTest:!0,programName:"mesh",vaoCreator:m_,stateBinder:Me,needsVisibilityBuffer:!0,commonBinder:X(W,$,J),programBinder:pt,objectBinder:M(Je,D,Ae,rt),tileBinder:C(Z,O),cullMethod:N,subRenderIndex:1,is3dMapAware:!0},{programName:"meshShadow",shadow:!0,vaoCreator:ha,stateBinder:an,needsVisibilityBuffer:!0,programBinder:ie,objectBinder:M(Je,D,Ae),tileBinder:C(Z,O),cullMethod:N,is3dMapAware:!0}],inverse:[{programName:"inverse",vaoCreator:en,stateBinder:on,needsVisibilityBuffer:!0,commonBinder:W,programBinder:pt,objectBinder:M(Je,D,rt),tileBinder:C(Z,O),cullMethod:N,subRenderIndex:-1,is3dMapAware:!0},{identify:!0,programName:"inverse",vaoCreator:en,stateBinder:on,needsVisibilityBuffer:!1,commonBinder:W,programBinder:pt,objectBinder:M(Je,D,rt),tileBinder:C(Z,O),cullMethod:N,subRenderIndex:-1,is3dMapAware:!0},{programName:"meshShadow",shadow:!0,vaoCreator:en,stateBinder:an,needsVisibilityBuffer:!0,programBinder:ie,objectBinder:M(Je,D,Ae),tileBinder:C(Z,O),cullMethod:N,is3dMapAware:!0}],depthClear:[{programName:"meshDepthClear",vaoCreator:en,stateBinder:X_,needsVisibilityBuffer:!0,commonBinder:X(W,$,J),programBinder:pt,objectBinder:M(Je,D,rt,Ae),tileBinder:C(Z,O),cullMethod:N,subRenderIndex:-2,is3dMapAware:!0,forceRenderUnderCacheInDemMode:!0}],stroke:[{programName:"simpleLine3d",vaoCreator:p_,stateBinder:Jt,needsVisibilityBuffer:!0,commonBinder:X(_e,W,$,J),programBinder:dn,layerBinder:Le(Qi,oe),objectBinder:M(me,He,Je,ai,D,Ae),tileBinder:C(q,Z,O),cullMethod:B(N,Ii,$h,af,Br),subRenderIndex:2,is3dMapAware:!0}]},polygonExtrusion:{sideFill:[{programName:"diffuse",vaoCreator:fa,stateBinder:on,needsVisibilityBuffer:!0,commonBinder:X(W,$,J),programBinder:ii,tileBinder:C(q,Z,O),layerBinder:Le(oe,mt),objectBinder:M(me,Pt,Qe,Be,D,he,Ei),cullMethod:B(Tr,N,ne,wn,fe),is3dMapAware:!0},{programName:"gradientDiffuse",vaoCreator:fa,stateBinder:La,needsVisibilityBuffer:!0,commonBinder:X(W,$,J),programBinder:ii,layerBinder:Le(oe,mt),objectBinder:M(me,Ti,Pt,Qe,Be,D,he,_r,Ei),tileBinder:C(q,Z,O),cullMethod:B(N,ne,fe,wn,$o),is3dMapAware:!0},{identify:!0,programName:"buildingIdentify",vaoCreator:pa(n.PolygonExtrusionGenerator.sinks.sideFill.stride),stateBinder:Me,needsVisibilityBuffer:!0,commonBinder:_e,programBinder:ln,objectBinder:M(Qe,D,he),tileBinder:C(Z,O),cullMethod:B(N,ne,fe,wn,$o),is3dMapAware:!0},{depthTest:!0,programName:"buildingIdentify",vaoCreator:va(n.PolygonExtrusionGenerator.sinks.sideFill.stride),stateBinder:Me,needsVisibilityBuffer:!0,commonBinder:_e,programBinder:ln,objectBinder:M(Qe,D,he),tileBinder:C(Z,O),cullMethod:B(N,ne,fe),is3dMapAware:!0},{programName:"buildingShadow",shadow:!0,vaoCreator:ga(n.PolygonExtrusionGenerator.sinks.sideFill.stride),stateBinder:sn,needsVisibilityBuffer:!0,programBinder:ie,objectBinder:M(Qe,D,he),tileBinder:C(Z,O),cullMethod:B(N,ne,fe),is3dMapAware:!0}],sideTexture:[{programName:"wallTexture",vaoCreator:v_,stateBinder:tu,needsVisibilityBuffer:!0,commonBinder:X(W,$,J),programBinder:ii,layerBinder:Le(oe,mt),objectBinder:M(Qe,D,he,gh,Pt),tileBinder:C(q,Z,O),cullMethod:B(N,ne,fe,_f),is3dMapAware:!0}],topFill:[{programName:"diffuse",vaoCreator:ma,stateBinder:on,needsVisibilityBuffer:!0,commonBinder:X(W,$,J),programBinder:ii,layerBinder:oe,objectBinder:M(me,Pt,Qe,Be,D,he,Ei),tileBinder:C(q,Z,O),cullMethod:B(Tr,N,ne,fe,Xo),is3dMapAware:!0},{programName:"diffuse",vaoCreator:ma,stateBinder:La,needsVisibilityBuffer:!0,commonBinder:X(W,$,J),programBinder:ii,layerBinder:Le(oe,mt),objectBinder:M(me,Pt,Qe,Be,D,he,Ei),tileBinder:C(q,Z,O),cullMethod:B(N,ne,fe,Xo),is3dMapAware:!0},{identify:!0,programName:"buildingIdentify",vaoCreator:pa(n.PolygonExtrusionGenerator.sinks.topFill.stride),stateBinder:Me,needsVisibilityBuffer:!0,commonBinder:_e,programBinder:ln,objectBinder:M(Qe,D,he),tileBinder:C(Z,O),cullMethod:B(N,ne,fe,Xo),is3dMapAware:!0},{depthTest:!0,programName:"buildingIdentify",vaoCreator:va(n.PolygonExtrusionGenerator.sinks.topFill.stride),stateBinder:Me,needsVisibilityBuffer:!0,commonBinder:_e,programBinder:ln,objectBinder:M(Qe,D,he),tileBinder:C(Z,O),cullMethod:B(N,ne,fe),is3dMapAware:!0},{programName:"buildingShadow",shadow:!0,vaoCreator:ga(n.PolygonExtrusionGenerator.sinks.topFill.stride),stateBinder:sn,needsVisibilityBuffer:!0,programBinder:ie,objectBinder:M(Qe,D,he),tileBinder:C(Z,O),cullMethod:B(N,ne,fe),is3dMapAware:!0}],sideStroke:[{programName:"line",vaoCreator:ya,stateBinder:Jt,needsVisibilityBuffer:!0,commonBinder:X(W,J,$,_e),programBinder:Ya,layerBinder:oe,objectBinder:M(me,Ti,Pt,Qe,Be,D,he),tileBinder:C(q,pe,O),cullMethod:B(N,ne,fe,zr,Pr),is3dMapAware:!0}],topStroke:[{programName:"simpleLine3d",vaoCreator:lo,stateBinder:Jt,needsVisibilityBuffer:!0,commonBinder:X(_e,W,$,J),programBinder:dn,layerBinder:Le(oe,Qd),objectBinder:M(me,Pt,He,Qe,D,he,No),tileBinder:C(q,Z,O),cullMethod:B(N,ne,fe,Ii,Ci,lf),is3dMapAware:!0}]},labelLine:{raster:[{programName:"labelLine",vaoCreator:Ai,stateBinder:vo,needsVisibilityBuffer:!1,commonBinder:X(W,$),programBinder:cn,objectBinder:M(Dt,oi,Gt,gn,xn),tileBinder:C(Z,q),zoomBinder:wt,cullMethod:B(ne,Lt,et,ri,bn,Wo),uniformSet:"fontHalo"},{programName:"labelLine",vaoCreator:Ai,stateBinder:go,needsVisibilityBuffer:!1,commonBinder:X(W,$),programBinder:cn,objectBinder:M(Dt,oi,Gt,gn,xn),tileBinder:C(Z,q),zoomBinder:wt,cullMethod:B(ne,Lt,Wo,et,ri,bn),uniformSet:"fontHalo",isOverlappedObject:!0},{programName:"labelLine",vaoCreator:Ai,stateBinder:vo,needsVisibilityBuffer:!1,commonBinder:X(W,$),programBinder:cn,objectBinder:M(Dt,oi,Gt,gn,xn),zoomBinder:wt,tileBinder:C(Z,q),cullMethod:B(ne,Lt,et,ri,bn),uniformSet:"fontFill",subRenderIndex:1},{programName:"labelLine",vaoCreator:Ai,stateBinder:go,needsVisibilityBuffer:!1,commonBinder:X(W,$),programBinder:cn,objectBinder:M(Dt,oi,Gt,gn,xn),zoomBinder:wt,tileBinder:C(Z,q),cullMethod:B(ne,Lt,et,ri,bn),uniformSet:"fontFill",subRenderIndex:1,isOverlappedObject:!0}]},dashedLine:{stroke:[{programName:"stripedLine",vaoCreator:ca,stateBinder:Ne,needsVisibilityBuffer:!1,commonBinder:X(J,W,$,_e),programBinder:Ja,layerBinder:oe,objectBinder:M(un,_n,Be,si),zoomBinder:vn,tileBinder:C(q,pe,jt),cullMethod:B(N,lt,fe)},{identify:!0,programName:"stripedLineIdentify",vaoCreator:ca,stateBinder:xt,needsVisibilityBuffer:!1,commonBinder:_e,programBinder:Qa,objectBinder:M(un,Be,_n,si),zoomBinder:vn,tileBinder:C(pe,jt),cullMethod:B(N,lt,fe)}],stroke3d:[{programName:"stripedLine3D",vaoCreator:da,stateBinder:mo,needsVisibilityBuffer:!1,commonBinder:X(J,W,$),programBinder:Ju,layerBinder:oe,objectBinder:M(un,_n,Be,si,D),zoomBinder:vn,tileBinder:C(q,pe,jt,O),cullMethod:B(N,lt),is3dMapAware:!0},{identify:!0,programName:"stripedLine3DIdentify",vaoCreator:da,stateBinder:Me,needsVisibilityBuffer:!1,programBinder:Au,objectBinder:M(un,Be,_n,si,D),zoomBinder:vn,tileBinder:C(pe,jt,O),cullMethod:B(N,lt),is3dMapAware:!0}]},oneWayLine:{raster:[{programName:"oneWayLine",vaoCreator:xa,stateBinder:vo,needsVisibilityBuffer:!1,commonBinder:X(vi,pi,_e),programBinder:$a,objectBinder:M(Dt,me,hn,or),tileBinder:Z,cullMethod:B(Lt,et,Lr)},{programName:"oneWayLine",vaoCreator:xa,stateBinder:go,commonBinder:X(vi,pi,_e),programBinder:$a,needsVisibilityBuffer:!1,objectBinder:M(Dt,me,hn,or),tileBinder:Z,cullMethod:B(Lt,et,Lr),isOverlappedObject:!0}]},point:{raster:[{programName:"pointSprite",vaoCreator:x_,stateBinder:po,needsVisibilityBuffer:!1,commonBinder:yi(W,$,Js,qi,_e),programBinder:Wu,layerBinder:ft,objectBinder:M(ah,Fo,Ro,Mi,D,he),cullMethod:B(et,ne,Zo,Go,Lt),tileBinder:C(pe,q,O),is3dMapAware:!0,forcePrerenderUnderCacheInDemMode:!0},{identify:!0,programName:"pointSpriteIdentify",vaoCreator:w_,stateBinder:xt,needsVisibilityBuffer:!1,commonBinder:_e,programBinder:Xa,objectBinder:M(Fo,Ro,Mi,D,he),tileBinder:C(pe,O),cullMethod:B(et,ne,Zo,Go,Sr),is3dMapAware:!0},{labelTest:!0,programName:"pointSpriteIdentify",vaoCreator:b_,stateBinder:xt,needsVisibilityBuffer:!1,commonBinder:_e,programBinder:Xa,objectBinder:M(Fo,Ro,Mi,D,he),tileBinder:C(pe,O),cullMethod:B(et,ne,Zo,Go,Sr),is3dMapAware:!0}],text:[{programName:"labelPoint",vaoCreator:_a,stateBinder:po,needsVisibilityBuffer:!1,commonBinder:yi(W,$,qi,_e),programBinder:Ka,objectBinder:M(Dt,oi,Gt,ar,yn,Mi,D,he),tileBinder:C(pe,q,O),cullMethod:B(et,ne,Lt,ri,Er,Wo),uniformSet:"fontHalo",subRenderIndex:1,is3dMapAware:!0,forcePrerenderUnderCacheInDemMode:!0},{programName:"labelPoint",vaoCreator:_a,stateBinder:po,needsVisibilityBuffer:!1,commonBinder:X(W,$,qi,_e),programBinder:Ka,objectBinder:M(Dt,oi,Gt,ar,yn,Mi,D,he),tileBinder:C(pe,q,O),cullMethod:B(et,ne,Lt,ri,Er),uniformSet:"fontFill",subRenderIndex:2,is3dMapAware:!0,forcePrerenderUnderCacheInDemMode:!0},{identify:!0,programName:"labelPointIdentify",vaoCreator:f_,stateBinder:xt,needsVisibilityBuffer:!1,commonBinder:_e,programBinder:ve(ie),objectBinder:M(Gt,yn,D,he),tileBinder:C(pe,O),cullMethod:B(et,ne,Qh),subRenderIndex:1,is3dMapAware:!0}],labelingTexture:[{depthTest:!0,programName:"pointDepthTest",vaoCreator:S_,stateBinder:$_,needsVisibilityBuffer:!1,commonBinder:_e,programBinder:ie,objectBinder:M(yn,D,he),tileBinder:C(Z,O),cullMethod:B(et,ne),is3dMapAware:!0}]},buildingModel:{fill:[{programName:"zbmModel",vaoCreator:T_,stateBinder:Ia,needsVisibilityBuffer:!1,commonBinder:X(W,$,J),programBinder:eh,layerBinder:Le(oe,ft,mt),objectBinder:M(me,Oo,dh,D),tileBinder:C(q,Z,O),cullMethod:B(jo,N,Ir,tt,Ko),subRenderIndex:2,is3dMapAware:!0},{programName:"zbmModelIdentify",vaoCreator:M_,stateBinder:Me,needsVisibilityBuffer:!1,commonBinder:_e,objectBinder:M(D),tileBinder:C(Z,O),cullMethod:B(jo,N,Ir,tt,Ko),subRenderIndex:2,identify:!0,is3dMapAware:!0},{programName:"zbmModelIdentify",vaoCreator:E_,stateBinder:Me,needsVisibilityBuffer:!1,commonBinder:_e,objectBinder:M(D),tileBinder:C(Z,O),cullMethod:N,depthTest:!0,is3dMapAware:!0},{programName:"zbmShadow",vaoCreator:I_,stateBinder:sn,needsVisibilityBuffer:!1,programBinder:ie,objectBinder:M(Oo,D),tileBinder:C(Z,O),cullMethod:N,shadow:!0,is3dMapAware:!0}],stroke:[{programName:"simpleLine3d",vaoCreator:lo,stateBinder:Jt,needsVisibilityBuffer:!0,commonBinder:X(_e,W,$,J),programBinder:dn,layerBinder:Le(oe,Qi),objectBinder:M(me,He,Oo,ai,D,No),tileBinder:C(Z,q,O),cullMethod:B(N,jo,Ii,Ci,Ko),subRenderIndex:5,is3dMapAware:!0}]},shiftedLine:{solid:[{programName:"road",commonBinder:X(W,$,J),programBinder:ve(at,Ge),vaoCreator:d_,stateBinder:Ne,needsVisibilityBuffer:!1,layerBinder:oe,objectBinder:M(me,He,tr),tileBinder:C(q,pe,jt),zoomBinder:wt,cullMethod:B(N,lt,tt)}]},circle:{fill:[{programName:"circleMarker",vaoCreator:co,stateBinder:Ne,needsVisibilityBuffer:!1,commonBinder:X(W,J,$,_e),programBinder:Bo,layerBinder:oe,objectBinder:M(me,He,D),cullMethod:B(N,lt,tt),tileBinder:C(pe,q,O),subRenderIndex:2,is3dMapAware:!0},{programName:"circleMarker",vaoCreator:co,stateBinder:Ne,needsVisibilityBuffer:!1,commonBinder:X(W,J,$,_e),programBinder:Bo,layerBinder:oe,objectBinder:M(me,He,D),cullMethod:B(N,ef,Ci),tileBinder:C(pe,q,O),subRenderIndex:1,is3dMapAware:!0},{programName:"circleMarker",vaoCreator:co,stateBinder:Ne,needsVisibilityBuffer:!1,commonBinder:X(W,J,$,_e),programBinder:Bo,layerBinder:oe,objectBinder:M(me,He,D),cullMethod:B(N,tf,rf),tileBinder:C(pe,q,O),is3dMapAware:!0},{identify:!0,programName:"circleMarkerIdentify",vaoCreator:P_,stateBinder:xt,programBinder:ie,needsVisibilityBuffer:!1,commonBinder:_e,objectBinder:M(He,D),cullMethod:B(N,nf),tileBinder:C(pe,O),is3dMapAware:!0}]},arrow:{stroke:[{programName:"entrance",vaoCreator:ba,stateBinder:Ne,needsVisibilityBuffer:!1,commonBinder:X(vi,pi,W,$,_e),programBinder:Yu,objectBinder:M(me,hn,sh,sr,Be),tileBinder:C(Z,q),cullMethod:B(N,tt)},{identify:!0,programName:"entranceIdentify",vaoCreator:ba,stateBinder:xt,needsVisibilityBuffer:!1,commonBinder:X(vi,pi,_e),programBinder:$u,objectBinder:M(hn,sr,Be),tileBinder:Z,cullMethod:B(N,tt)}]},lineExtrusion:{fill:[{programName:"gradientDiffuse",vaoCreator:g_,stateBinder:V_,needsVisibilityBuffer:!0,commonBinder:X(W,$,J),programBinder:ii,layerBinder:Le(oe,mt),objectBinder:M(pn,me,Pt,Ti,Be,D,ai,_r,Ei),tileBinder:C(q,Z,O),cullMethod:B(N,ne,fe,wn,$o),subRenderIndex:9,is3dMapAware:!0},{programName:"buildingShadow",shadow:!0,vaoCreator:y_,stateBinder:an,needsVisibilityBuffer:!0,programBinder:ie,objectBinder:M(pn,D,ai),tileBinder:C(Z,O),cullMethod:B(N,ne,fe),is3dMapAware:!0}],sideStroke:[{programName:"line",vaoCreator:ya,stateBinder:Jt,needsVisibilityBuffer:!0,commonBinder:X(W,J,$,_e),programBinder:Ya,layerBinder:oe,objectBinder:M(pn,me,Ti,Be,D,ai),tileBinder:C(q,pe,O),cullMethod:B(N,ne,fe,zr,Pr),subRenderIndex:10,is3dMapAware:!0}],topStroke:[{programName:"simpleLine3d",vaoCreator:lo,stateBinder:Jt,needsVisibilityBuffer:!0,commonBinder:X(_e,W,$,J),programBinder:dn,layerBinder:Le(oe,Qi),objectBinder:M(pn,me,He,D,ai,No),tileBinder:C(q,Z,O),cullMethod:B(N,ne,fe,Ii,Ci),subRenderIndex:11,is3dMapAware:!0}]},gltfModel:{instances:[{programName:"gltfModel",vaoCreator:nn(!1),instanceBinder:Mn,commonBinder:X(W,$,J),programBinder:Qu,layerBinder:Le(oe,mt,Ji),stateBinder:Ia,needsVisibilityBuffer:!1,objectBinder:M(me,_h,Uo,Do,D,fn,he,mn),tileBinder:C(pe,Ln,Wf,O,Pn),cullMethod:B(qo,Fr),is3dMapAware:!0},{identify:!0,programName:"gltfModelIdentify",instanceBinder:Mn,vaoCreator:nn(!1),stateBinder:Me,needsVisibilityBuffer:!1,layerBinder:Ji,commonBinder:yi(W,$),programBinder:ie,objectBinder:M(D,fn,rt,Do,he,mn),tileBinder:C(pe,Ln,O,Pn),cullMethod:B(qo,Fr),is3dMapAware:!0},{depthTest:!0,programName:"gltfModelIdentify",instanceBinder:Mn,vaoCreator:nn(!0),stateBinder:Me,needsVisibilityBuffer:!1,commonBinder:yi(W,$),programBinder:ie,layerBinder:Ji,objectBinder:M(D,fn,Do,he,mn),tileBinder:C(pe,Ln,O,Pn),cullMethod:qo,is3dMapAware:!0},{shadow:!0,programName:"gltfModelShadow",instanceBinder:Mn,vaoCreator:nn(!1),stateBinder:sn,needsVisibilityBuffer:!1,programBinder:ie,layerBinder:Ji,objectBinder:M(D,fn,mn),tileBinder:C(pe,Ln,O,Pn),cullMethod:df,is3dMapAware:!0}]},raster:{fill:[{programName:"rectWithTexture",vaoCreator:L_,stateBinder:Ne,needsVisibilityBuffer:!1,commonBinder:yi(W,$),layerBinder:ft,objectBinder:M(ir,rh),tileBinder:C(Z,q),cullMethod:B(pr,N)}]},heatmap:{framebuffer:[{programName:"heatmap",vaoCreator:B_,stateBinder:Ca,needsVisibilityBuffer:!1,commonBinder:ta,objectBinder:M(uh,hh),zoomBinder:wt,tileBinder:C(Z,q),cullMethod:B(N,of)}],fill:[{programName:"heatmapTexture",vaoCreator:z_,stateBinder:Ne,needsVisibilityBuffer:!1,layerBinder:ft,objectBinder:M(ir,ch,lh),tileBinder:q,cullMethod:B(N,pr,Xh),subRenderIndex:1}]},dem:{mesh:[{programName:"demMesh",vaoCreator:tn,commonBinder:X(W,$,J),programBinder:pt,layerBinder:oe,stateBinder:Me,needsVisibilityBuffer:!1,objectBinder:M(D,lr,dr),tileBinder:C(Z,q,Cn,O),cullMethod:B(vr,gr),is3dMapAware:!0},{programName:"demGround",demGround:!0,vaoCreator:tn,programBinder:ie,tileBinder:C(Z,q,O),stateBinder:Me,needsVisibilityBuffer:!1,objectBinder:M(D)},{identify:!0,programName:"demMesh",vaoCreator:tn,programBinder:ve(ie,Za),stateBinder:Me,needsVisibilityBuffer:!1,objectBinder:M(cr,D),tileBinder:C(Z,Cn,O),cullMethod:yr,is3dMapAware:!0}],mesh2:[{dem:!0,programName:"demElevation",vaoCreator:xi,stateBinder:W_,needsVisibilityBuffer:!1,tileBinder:Z,objectBinder:M()},{programName:"demGround2",demGround:!0,vaoCreator:xi,programBinder:ie,tileBinder:C(Z,q,O),stateBinder:Me,needsVisibilityBuffer:!1,objectBinder:M(D)},{programName:"demMesh2",vaoCreator:xi,commonBinder:X(W,$,J),programBinder:pt,layerBinder:oe,stateBinder:Me,needsVisibilityBuffer:!1,objectBinder:M(rt,lr,dr,D),tileBinder:C(Z,q,Cn,O),cullMethod:B(vr,gr)},{identify:!0,programName:"demMesh2",vaoCreator:xi,programBinder:ve(ie,Za),stateBinder:Me,needsVisibilityBuffer:!1,objectBinder:M(rt,cr,D),tileBinder:C(Z,Cn,O),cullMethod:yr},{depthTest:!0,programName:"demMesh2DepthTest",vaoCreator:xi,programBinder:ve(ie),stateBinder:Me,needsVisibilityBuffer:!1,objectBinder:M(ph,D),tileBinder:C(Z,O)}],hillshade:[{programName:"demHillshade",vaoCreator:_o,stateBinder:xt,needsVisibilityBuffer:!1,programBinder:ie,objectBinder:M(D),tileBinder:C(Z,O)}],flatBottom:[{programName:"demFlatBottom",vaoCreator:R_,stateBinder:Ma,needsVisibilityBuffer:!1,objectBinder:M(mh,D),tileBinder:C(Z,O),cullMethod:Kh}]},mapMesh:{fill:[{programName:"mapMesh",vaoCreator:uo,stateBinder:Ea,needsVisibilityBuffer:!1,zoomBinder:M(ko),commonBinder:X(W,$,J),programBinder:pt,layerBinder:Le(oe,mt),objectBinder:M(Uo,Je,D,Ae,rt),tileBinder:C(q,Z,O),cullMethod:B(N,Vo),subRenderIndex:Number.MAX_SAFE_INTEGER,is3dMapAware:!0},{identify:!0,programName:"mapMesh",vaoCreator:uo,stateBinder:Me,needsVisibilityBuffer:!1,zoomBinder:M(ko),commonBinder:X(W,$,J),programBinder:pt,layerBinder:Le(oe,mt),objectBinder:M(Uo,Je,D,Ae,rt),tileBinder:C(Z,O),cullMethod:B(N,Vo),subRenderIndex:Number.MAX_SAFE_INTEGER,is3dMapAware:!0},{depthTest:!0,programName:"mapMesh",vaoCreator:uo,stateBinder:Me,needsVisibilityBuffer:!1,zoomBinder:M(ko),commonBinder:X(W,$,J),programBinder:pt,layerBinder:Le(oe,mt),objectBinder:M(Je,D,Ae,rt),tileBinder:C(Z,O),cullMethod:N,subRenderIndex:Number.MAX_SAFE_INTEGER,is3dMapAware:!0},{programName:"meshShadow",shadow:!0,vaoCreator:ha,stateBinder:an,needsVisibilityBuffer:!1,programBinder:ie,objectBinder:M(Je,D,Ae),tileBinder:C(Z,O),cullMethod:N,is3dMapAware:!0}]}}}class Kf{constructor(e){this.gl=e,this.ext=e.getExtension("EXT_disjoint_timer_query"),this.queries=[]}addTimer(){if(!this.ext)return;const e=this.ext.createQueryEXT();this.queries.push(e),this.ext.beginQueryEXT(this.ext.TIME_ELAPSED_EXT,e)}stopTimer(){!this.ext||!this.queries.length||this.ext.endQueryEXT(this.ext.TIME_ELAPSED_EXT)}tryToGetFirstTimerValue(){if(!this.ext)return;const e=this.queries[0];if(!e)return;const t=this.ext,i=t.getQueryObjectEXT(e,t.QUERY_RESULT_AVAILABLE_EXT),o=this.gl.getParameter(t.GPU_DISJOINT_EXT);if(!i||o)return;const a=t.getQueryObjectEXT(e,t.QUERY_RESULT_EXT);return t.deleteQueryEXT(e),this.queries.shift(),Number(a)}}const qf=`
float affine_step(const float edge0, const float edge1, const float x)
{
    return clamp((x - edge0) / (edge1 - edge0), 0., 1.);
}
`,Yf=`#define ALPHA_MODE_OPAQUE 1
#define ALPHA_MODE_BLEND 2
`,nl=`
vec4 apply_opacity(const vec4 color, const float opacity)
{
return color * opacity;
}
`,Qf=`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);
}
`,Jf=`
#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
`,ol=`#ifndef UBO
uniform highp vec3 u_cam_pos;
#endif
`,Af=`
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);
}
`,em=`
#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;
}
`,tm=`#ifdef WEBGL1
#extension GL_OES_standard_derivatives: enable
#endif
`,im=`
#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;
}`,nm=`#define FRAGMENT_NORMAL
vec3 calc_fragment_normal(vec3 vertex) {
    vec3 dx = dFdx(vertex);
    vec3 dy = dFdy(vertex);
    return normalize(cross(dx, dy));
}`,om=`precision highp float;
`,sm=`#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);
}`,am=`
#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
`,rm=`#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
`,lm=`precision lowp float;
`,cm=`precision mediump float;
`,sl=`#define MIX_COLOR_MODE_READ_FROM_TARGET 1
#define MIX_COLOR_MODE_VERTEX_ATTRIBUTE 2
#define VERTEX_ATTRIBUTE_NAME_DENORMALIZED_DISTANCE_TO_LINE 1
`,dm=`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);
}`,_m=`#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
`,um=`#ifdef HAS_FRAG_DEPTH_EXT
#extension GL_EXT_frag_depth : require
#endif
`,hm=`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;
}
`,fm=`#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 `,al=`#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
`,mm=`#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);
}
`,pm=`#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;
}
`,vm=`#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);
}
`,gm=`#include <lowp_float>
#include <prelude>
#include <fog>
varying vec4 v_vec4_color;
void main()
{
    gl_FragColor = apply_fog(v_vec4_color);
}
`,ym=`#include <lowp_float>
#include <prelude>
varying vec4 v_vec4_identifier;
void main()
{
    gl_FragColor = v_vec4_identifier;
}
`,xm=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <screendoor_transparency>
#include <fragment_normal>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
varying vec4 v_vec4_color;
varying vec4 v_vec4_rotated_scaled_vertex;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    apply_screendoor();
    vec3 normal = calc_fragment_normal(v_vec4_rotated_scaled_vertex.xyz);
    vec4 light = light_factor(normal);
    vec4 color = v_vec4_color * light;
    gl_FragColor = apply_fog(color);
# ifndef BLEND
    
    gl_FragColor /= gl_FragColor.a;
# endif
}
`,bm=`#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.);
}
`,Sm=`#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);
}
`,Tm=`#include <mediump_float>
#include <prelude>
varying vec4 v_vec4_color;
void main()
{
    gl_FragColor = v_vec4_color;
}
`,Mm=`#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;
}
`,Em=`#include <mediump_float>
#include <prelude>
varying vec4 v_vec4_coords;
void main()
{
    gl_FragColor = v_vec4_coords;
}
`,Im=`#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);
    }
}
`,Cm=`#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);
}
`,Pm=`#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);
}
`,Lm=`#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 
}
`,Bm=`#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);
}
`,zm=`#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;
}
`,Rm=`#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;
}
`,Fm=`#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>
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(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(color);
}
`,Dm=`#include <enable_standard_derivatives>
#include <highp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <screendoor_transparency>
#include <fragment_normal>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
varying mat4 v_mat4_gradient;
varying vec4 v_vec4_color;
varying vec4 v_vec4_rotated_scaled_vertex;
uniform vec2 u_vec2_floor_level;
void main()
{
    if (check_dem_invalid() != 0) {
        discard;
    }
    apply_screendoor();
    vec4 color = v_vec4_color;
    if (v_mat4_gradient[0][0] != 0.) {
        float height_gradient = v_vec4_rotated_scaled_vertex.w;
        float gradient_position = (float(u_vec2_floor_level.x) + height_gradient) / float(u_vec2_floor_level.y);
        color = mix(v_mat4_gradient[1], v_mat4_gradient[2], smoothstep(v_mat4_gradient[0][1], v_mat4_gradient[0][2], gradient_position));
    }
    vec3 normal = calc_fragment_normal(v_vec4_rotated_scaled_vertex.xyz);
    color *= light_factor(normal);
    gl_FragColor = apply_fog(color);
# ifndef BLEND
    
    gl_FragColor /= gl_FragColor.a;
# endif
}
`,Om=`#include <mediump_float>
#include <prelude>
#include <fog>
uniform highp float u_float_intensity;
varying float v_float_weight;
varying vec2 v_vec2_extrude;
#define GAUSS_COEF 0.3989422804014327
void main() {
    float d = -0.5 * 3.0 * 3.0 * dot(v_vec2_extrude, v_vec2_extrude);
    float val = v_float_weight * u_float_intensity * GAUSS_COEF * exp(d);
    float fog_alpha = apply_fog_alpha(vec4(1)).r;
    gl_FragColor = vec4(val, fog_alpha, 1.0, 1.0);
}
`,Nm=`#include <mediump_float>
#include <prelude>
#include <cam_pos>
uniform sampler2D u_sr2d_texture;
uniform sampler2D u_sr2d_ramp_texture;
uniform float u_float_opacity;
varying vec2 v_vec2_position;
void main() {
    vec2 color_and_alpha = texture2D(u_sr2d_texture, v_vec2_position).rg;
    vec4 color = texture2D(u_sr2d_ramp_texture, vec2(color_and_alpha.r, 0.5));
    gl_FragColor = color * u_float_opacity;
    
    
    #ifdef FOG
        gl_FragColor *= color_and_alpha.g;
    #endif
}
`,km=`#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.);
    }
}
`,Um=`#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);
}
`,Hm=`#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);
}
`,Gm=`#include <mediump_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
varying vec4 v_vec4_color;
varying mat4 v_mat4_gradient;
varying vec3 v_vec3_normal;
varying vec2 v_vec2_height_gradient;
uniform mat4 u_mat4_gradient;
void main()
{ 
    if (check_dem_invalid() != 0) {
        discard;
    }
    vec4 color = v_vec4_color;
    if (u_mat4_gradient[0][0] != 0.) {
        color = mix(v_mat4_gradient[1], v_mat4_gradient[2], smoothstep(v_mat4_gradient[0][1], v_mat4_gradient[0][2], v_vec2_height_gradient[0]));
    }
    color *= (1. - abs(v_vec2_height_gradient[1] * gl_FragCoord.w));
    gl_FragColor = apply_fog(color * light_factor(v_vec3_normal));
}
`,Vm=`#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);
}`,jm=`#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);
}
}
}
`,Zm=`#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);
    }
}
`,Wm=`#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());
}
`,$m=`#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);
}
`,Xm=`#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);
}
`,Km=`#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);
}
`,qm=`#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;
    }
}
`,Ym=`#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);
}
`,Qm=`#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;
}
`,Jm=`#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;
}
`,Am=`#include <lowp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
uniform vec4 u_vec4_color;
varying float v_float_distance;
varying float v_float_distance_offset;
void main()
{
    vec4 light = light_factor_surface();
    vec4 color = u_vec4_color * clamp(
        1. + v_float_distance_offset - abs(v_float_distance * gl_FragCoord.w),
        0.,
        1.) * light;
    gl_FragColor = apply_fog(color);
}
`,ep=`#include <lowp_float>
#include <prelude>
#include <cam_pos>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#include <dem>
varying vec4 v_vec4_color;
varying 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 = v_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 <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);
}
`,ip=`#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);
}
`,np=`#include <mediump_float>
#include <prelude>
varying mediump float v_intensity;
void main() {
    gl_FragColor = vec4(v_intensity);
}
`,op=`#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);
}
`,sp=`#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);
}
`,ap=`#include <mediump_float>
#include <prelude>
#include <cam_pos>
#include <apply_opacity>
#include <fog>
#include <bit_mask>
#include <pack_depth>
#include <shadow>
#include <light>
#define LIGHT_MODEL LIGHT_MODEL_PHONG
#include <light_phong>
#include <mix_color_defs>
uniform sampler2D u_sr2d_texture;
uniform float u_float_texture_opacity;
uniform vec4 u_float_texture_params;
uniform vec4 u_float_sprite_texture_coords;
uniform int u_int_is_textured;
uniform int u_int_is_normal_map_textured; 
uniform sampler2D u_sr2d_texture1;
uniform vec4 u_vec4_normal_map_texture_params;
uniform vec4 u_vec4_normal_map_sprite_texture_coords;
uniform vec4 u_vec4_normal_map_animated_offsets;
uniform int u_int_normal_map_is_animated;
uniform float u_float_metallic;
uniform float u_float_roughness;
varying vec4 v_vec4_color;
varying highp vec2 v_vec2_texcoord;
varying highp vec3 v_vec3_fragment_pos_world;
uniform int u_int_factor_use_interpolate;
uniform float u_float_factor_interpolate_base;
uniform vec4 u_vec4_factor_interpolate_ranges;
#ifdef MIX_COLOR_MODE
varying vec4 v_vec4_color2;
# if MIX_COLOR_MODE == MIX_COLOR_MODE_READ_FROM_TARGET
varying vec4 v_vec4_pos;
uniform sampler2D u_sr2d_read_from_target_texture;
# elif MIX_COLOR_MODE == MIX_COLOR_MODE_VERTEX_ATTRIBUTE
varying float v_float_mix_color_factor;
# endif
#endif
float interpolate(float x, float base, vec4 ranges) {
    float inMin = ranges.x;
    float outMin = ranges.y;
    float inMax = ranges.z;
    float outMax = ranges.w;
    float t = clamp(outMin + (outMax - outMin) * ((x - inMin) / (inMax - inMin)), outMin, outMax);
    return base == 1. ? t : (pow(base, t) - 1.) / (base - 1.);
}
void main() {
#ifdef MIX_COLOR_MODE
    float mix_color_factor = 0.;
# if MIX_COLOR_MODE == MIX_COLOR_MODE_READ_FROM_TARGET
    vec3 clip_space = v_vec4_pos.xyz / v_vec4_pos.w;
    vec3 uv = 0.5 * clip_space + vec3(0.5);
    
    
    
    mix_color_factor = texture2D(u_sr2d_read_from_target_texture, uv.xy).r;
# elif MIX_COLOR_MODE == MIX_COLOR_MODE_VERTEX_ATTRIBUTE
    mix_color_factor = v_float_mix_color_factor;
# endif
#endif
    bool use_normal_map = u_int_is_normal_map_textured == 1;
    vec3 normal;
    
    if(use_normal_map) {
        vec2 texcoord1 = fract(v_vec2_texcoord * u_vec4_normal_map_texture_params.zw + u_vec4_normal_map_texture_params.xy + u_vec4_normal_map_animated_offsets.xy);
        vec2 spritecoord1 = mix(u_vec4_normal_map_sprite_texture_coords.xy, u_vec4_normal_map_sprite_texture_coords.zw, texcoord1);
        vec4 texcolor1 = texture2D(u_sr2d_texture1, spritecoord1);
        
        if(u_int_normal_map_is_animated == 1) {
            vec2 texcoord2 = fract(v_vec2_texcoord * u_vec4_normal_map_texture_params.zw + u_vec4_normal_map_texture_params.xy + u_vec4_normal_map_animated_offsets.zw);
            vec2 spritecoord2 = mix(u_vec4_normal_map_sprite_texture_coords.xy, u_vec4_normal_map_sprite_texture_coords.zw, texcoord2);
            vec4 texcolor2 = texture2D(u_sr2d_texture1, spritecoord2);
            normal = normalize((texcolor1.xyz * 2.0 - 1.0) + (texcolor2.xyz * 2.0 - 1.0));
        } else {
            normal = normalize((texcolor1.xyz * 2.0 - 1.0));
        }
    }
    
    vec4 color = v_vec4_color;
    
    if(u_int_is_textured == 1) {
        vec2 texcoord = fract(v_vec2_texcoord * u_float_texture_params.zw + u_float_texture_params.xy);
        vec2 spritecoord = mix(u_float_sprite_texture_coords.xy, u_float_sprite_texture_coords.zw, texcoord);
        vec4 texcolor = apply_opacity(texture2D(u_sr2d_texture, spritecoord), u_float_texture_opacity);
        color = texcolor + color * (1. - texcolor.a);
    }
#ifdef MIX_COLOR_MODE
    
    if(u_int_factor_use_interpolate == 1) {
        mix_color_factor = interpolate(mix_color_factor, u_float_factor_interpolate_base, u_vec4_factor_interpolate_ranges);
    }
    
    color = mix(color, v_vec4_color2, mix_color_factor);
#endif
    
    if(use_normal_map) {
        color.rgb = color_phong(normal, v_vec3_fragment_pos_world, color.rgb, u_float_roughness, u_float_metallic, 1.0);
    } else {
        color = color * light_factor_surface();
    }
    gl_FragColor = apply_fog(color);
}
`,rp=`#include <lowp_float>
#include <prelude>
uniform vec4 u_vec4_color;
void main()
{
    gl_FragColor = u_vec4_color;
}
`,lp=`#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);
}
`,cp=`#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);
}
`,dp={affine_step:qf,alpha_mode_defs:Yf,apply_opacity:nl,arrow_functions:Qf,bit_mask:Jf,cam_pos:ol,circle_functions:Af,dem:em,enable_standard_derivatives:tm,fog:im,fragment_normal:nm,highp_float:om,light:sm,light_pbr:am,light_phong:rm,lowp_float:lm,mediump_float:cm,mix_color_defs:sl,pack_depth:dm,prelude:_m,require_frag_depth:um,screendoor_transparency:hm,shadow:fm,signed_distance_functions:al},_p={arrow_line:mm,arrow_line_identify:pm,circle_marker:vm,color:gm,color_identify:ym,color_with_z_fade:xm,copy:bm,dem_elevation:wm,dem_elevation_copy:Sm,dem_flat_bottom:Tm,dem_ground:Mm,dem_ground2:Em,dem_mesh:Im,dem_mesh2:Cm,dem_normal:Pm,depth_clear:Lm,fxaa:Bm,globe_halo:zm,globe_halo_background:Rm,gltf_model:Fm,gradient_with_z_fade:Dm,heatmap:Om,heatmap_texture:Nm,inverse:km,label:Um,label_directional:Hm,line:Gm,main_shadow:Vm,map_mesh:jm,mesh:Zm,metric_point:Wm,one_way_line:$m,patterned_line:Xm,pointsprite:Km,pointsprite_identify:qm,rect_with_texture:Ym,road:Qm,road_identify:Jm,simple_line_2d:Am,simple_line_3d:ep,simple_mesh:tp,sky:ip,stars:np,striped_line:op,taa:sp,textured_color:ap,uniform_color:rp,wall_texture:lp,zbm_model:cp},up=`vec4 apply_height_factor(in vec3 vertex, const float height_factor)
{
    vertex.z *= height_factor;
    return vec4(vertex, 1.0);
}
`,hp=`
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);
}
`,fp=`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);
}
`,mp=`
#ifdef SCREENDOOR
varying vec3 v_clipspace_pos;
#endif
void save_clipspace_pos () {
    #ifdef SCREENDOOR
    v_clipspace_pos = gl_Position.xyz;
    #endif
}
`,pp=`
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;
}
`,vp=`#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;
}
`,gp=`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);
}
`,yp=`#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
}`,xp=`#ifdef TAA
uniform vec2 u_vec2_camera_jitter;
void apply_vertex_jitter(inout vec4 clipPos) {
    clipPos.xy += clipPos.w * u_vec2_camera_jitter;
}
#endif`,bp=`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;
`,Sp=`
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);
}
`,Tp=`
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;
}
`,Mp=`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));
}`,Ep=`
const float g_circle_scale_precision_factor = 1e8;
`,Ip=`#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
`,Cp=`
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;
}
`,Pp=`
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);
    }
}
`,Lp=`#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 `,Bp=`
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); 
}
`,zp=`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);
}
`,Rp=`#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);
}
`,Fp=`#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;
}`,Dp=`#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);
}
`,Op=`#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.);
    }
}
`,Np=`#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
}
`,kp=`#include <prelude>
#include <ecef_mvp_mat>
#include <round_position>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_floor_elevation;
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)
    {
        gl_Position = round_position(get_clipspace(a_vec3_vertex, u_float_floor_elevation), .5 * u_vec2_vpt_size);
    }
    else
    {
        gl_Position = vec4(1., 1., 1., 1.);
    }
}
`,Up=`#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;
}
`,Hp=`#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;
}
`,Gp=`#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);
}
`,Vp=`#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;
}
`,jp=`#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;
}
`,Zp=`#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);
}
`,Wp=`#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);
}
`,$p=`#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);
}
`,Xp=`#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);
}
`,Kp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <packed_attributes>
#include <apply_height_factor>
#include <apply_opacity>
#include <pos_world>
#include <cam_pos>
#include <fog>
#include <clipspace_pos>
#include <jitter>
#include <shadow>
uniform 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;
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 (height > posHeight) {
            height = posHeight;
        }
    }
    height += u_float_floor_elevation;
    vec3 vertex = vec3(a_vec2_vertex, a_float_z);
    vec4 vertex_hf = apply_height_factor(vertex, u_float_height_factor);
    vertex_hf.z += height;
    
    vertex_hf.z = max(vertex_hf.z, height);
    vec4 clip_pos = u_mat4_mvp * vertex_hf;
    gl_Position = clip_pos;
    if (u_int_is_roof == 0)
    {
        
        if ((u_mat4_mvp[0][3] == 0.) && (u_mat4_mvp[1][3] == 0.) && (u_mat4_mvp[2][3] == 0.))
        {
            gl_Position.z += g_wall_offset_isometric;
        }
        else
        {
            
            
            
            if (height == 0.) {
                gl_Position.z += g_wall_offset_perspective;
            } else {
                gl_Position.z += g_wall_offset_isometric;
            }
        }
    }
    vec3 pos_world = calc_pos_world(vertex_hf);
    calc_fog_pos(pos_world);
    save_clipspace_pos();
#ifdef TAA
    apply_vertex_jitter(gl_Position);
#endif
    
    
    mat3 rotation_scale_mat = mat3(u_mat4_model);
    v_vec4_rotated_scaled_vertex.xyz = rotation_scale_mat * vertex;
    v_vec4_color = apply_opacity(u_vec4_color, u_float_opacity);
    if (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 (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);
}
`,qp=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <round_position>
#include <apply_height_factor>
#ifndef UBO
uniform vec2 u_vec2_vpt_size;
#endif
uniform float u_float_height_factor;
uniform float u_float_floor_elevation;
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec4 a_vec4_identifier;
attribute vec2 a_vec2_dem_position;
attribute float a_float_visibility;
varying vec4 v_vec4_identifier;
void main()
{
    
    
    
    if (a_float_visibility == 0.0 || a_vec4_identifier == vec4(1., 1., 1., 1.)) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    float height = dem_height(unpack_dem_position(a_vec2_dem_position));
    
    if (a_float_z == 0.) {
        float posHeight = dem_height(a_vec2_vertex);
        if (height > posHeight) {
            height = posHeight;
        }
    }
    height += u_float_floor_elevation;
    v_vec4_identifier = a_vec4_identifier;
    vec4 vertex_hf = apply_height_factor(vec3(a_vec2_vertex, a_float_z), u_float_height_factor);
    vertex_hf.z += height;
    
    vertex_hf.z = max(vertex_hf.z, height);
    gl_Position = round_position(
        u_mat4_mvp * vertex_hf,
        .5 * u_vec2_vpt_size);
}
`,Yp=`#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);
}
`,Qp=`#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);
}
`,Jp=`#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;
}
`,Ap=`#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);
}
`,ev=`#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));
}
`,tv=`#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);
}
`,iv=`#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.;
}
`,nv=`#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.);
    }
}
`,ov=`#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);
}
`,sv=`#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);
}
`,av=`#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;
}
`,rv=`#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);
}
`,lv=`#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 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);
    }
    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);
}
`,cv=`#include <prelude>
#include <mvp_mat>
#include <dem>
#include <apply_height_factor>
attribute vec2 a_vec2_vertex;
attribute float a_float_z;
attribute vec2 a_vec2_dem_position;
attribute float a_float_abs_z;
attribute float a_float_visibility;
attribute float a_float_is_pivot;
uniform float u_float_height_factor;
uniform int u_int_abs_z;
varying float v_depth_metric;
void main()
{
    float height = 0.;
    if (u_int_abs_z == 0) {
        height = dem_height(unpack_dem_position(a_vec2_dem_position));
    } else {
        if (a_float_is_pivot == 1.) {
            height = dem_height(a_vec2_vertex);
        } else {
            height = abs_height(a_float_abs_z);
        }
    }
    if (a_float_visibility == 0.0) {
        gl_Position = vec4(0, 0, 1, 1);
        return;
    }
    
    vec4 vec4_pos = apply_height_factor(vec3(a_vec2_vertex.xy, a_float_z / (65535. * 32.)), u_float_height_factor);
    vec4_pos.z += height;
    gl_Position = u_mat4_mvp * vec4_pos;
    v_depth_metric = 0.5 * gl_Position.z + 0.5;
}`,dv=`#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);
}
`,_v=`#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);
}
`,uv=`#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;
}
`,hv=`#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;
}
`,fv=`#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);
}
`,mv=`#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;
}
`,pv=`#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;
}
`,vv=`#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);
}
`,gv=`#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_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, 0.);
    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);
}
`,yv=`#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_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, 0.);
        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;
}
`,xv=`#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);
}
`,bv=`#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);
}
`,Sv=`#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);
}
`,Tv=`#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);
}
`,Mv=`#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_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) + 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);
}
`,Ev=`#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.);
    }
}
`,Iv=`#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;
}
`,Cv=`#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);
}
`,Pv=`#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.);
    }
}
`,Lv=`#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;
}
`,Bv={apply_height_factor:up,apply_opacity:nl,arrow_functions:hp,calculate_scale:fp,cam_pos:ol,clipspace_pos:mp,dem:pp,depth_test:vp,ecef_mvp_mat:gp,fog:yp,jitter:xp,line_width:bp,mix_color_defs:sl,mvp_mat:wp,packed_attributes:Sp,pixel_offset:Tp,pos_world:Mp,precision_constants:Ep,prelude:Ip,raster_functions:Cp,round_position:Pp,shadow:Lp,show_ratio:Bp,signed_distance_functions:al,striped_line_functions:zp},zv={arrow_line_entrance:Rp,building_shadow:Fp,circle_marker:Dp,circle_marker_identify:Op,color:Np,color_identify:kp,dem_elevation:Up,dem_elevation_copy:Hp,dem_flat_bottom:Gp,dem_ground:Vp,dem_ground2:jp,dem_mesh:Zp,dem_mesh2:Wp,dem_mesh2_depthtest:$p,dem_normal:Xp,diffuse:Kp,diffuse_identify:qp,globe_halo:Yp,gltf_model:Qp,gltf_shadow:Jp,heatmap:Ap,heatmap_texture:ev,label_directional:tv,label_fixed_anchor:iv,label_fixed_anchor_identify:nv,line:ov,line3d:sv,line3d_identify:av,map_mesh:rv,mesh:lv,mesh_shadow:cv,metric_point:dv,one_way_line:_v,patterned_line:uv,point_anchor:hv,pointsprite:fv,pointsprite_identify:mv,posteffect:pv,rect_with_texture:vv,road:gv,road_identify:yv,simple_line_2d:xv,simple_line_3d:bv,simple_mesh:wv,sky:Sv,stars:Tv,striped_line:Mv,striped_line_identify:Ev,wall_texture:Iv,zbm_model:Cv,zbm_model_identify:Pv,zbm_shadow:Lv},Rv=/^\s*#include\s+<(.+)>.*$/gim,Fv=(s,e)=>(t,i)=>{const o=i.trim(),a=s==="vertex"?Bv[o]:dp[o];if(!a)throw new Error(`Cannot resolve "include <${o}>" in ${s} shader "${e}"`);return a+`
`};function rl(s,e){return[(s==="vertex"?zv[e]:_p[e]).replace(Rv,Fv(s,e))]}function k(s){const e=Li.webglVersion===2?["#version 300 es"]:[],t=n.Shader.createShaderDefinitions([{type:`WEBGL${Li.webglVersion}`,value:""},{type:xh,value:""}]);return i=>new n.Shader("vertex",e.concat(rl("vertex",s)),t,i)}function U(s){const e=Li.webglVersion===2?["#version 300 es"]:[],t=n.Shader.createShaderDefinitions([{type:`WEBGL${Li.webglVersion}`,value:""},{type:yh,value:""}]);return i=>new n.Shader("fragment",e.concat(rl("fragment",s)),t,i)}const ee={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"}],te={name:"u_mat4_model",type:"mat4"},cs=[{name:"u_vec2_anchor",type:"2f"},{name:"u_vec4_axis",type:"4f"},{name:"u_int_gltf_dem_pos",type:"1i"}],A=[{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"}],vt=[{name:"u_int_abs_z",type:"1i"}],re=[{name:"u_cam_pos",type:"3f"}],xe=[{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"}],be=[{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"}],le=[{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"}],Ee=[{name:"u_vec2_camera_jitter",type:"2f"}];function Dv(){return{simpleMesh:{buildFragment:U("simple_mesh"),buildVertex:k("simple_mesh"),attributes:[{name:"a_vec3_position",location:0},{name:"a_vec3_normal",location:1}],uniforms:[ee,{name:"u_float_scale",type:"1f"},{name:"u_vec3_transform",type:"3fv"}]},diffuse:{buildVertex:k("diffuse"),buildFragment:U("color_with_z_fade"),uniforms:[ee,te,{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"},...re,...xe,...be,...A,...le,...Ee],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:k("diffuse"),buildFragment:U("gradient_with_z_fade"),uniforms:[ee,te,{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"},...re,...xe,...be,...A,...le,...Ee],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:k("wall_texture"),buildFragment:U("wall_texture"),uniforms:[ee,te,{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"},...re,...xe,...be,...A,...le,...Ee],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:k("label_directional"),buildFragment:U("label_directional"),uniforms:[ee,te,{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"},...re,...le],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:k("label_fixed_anchor"),buildFragment:U("label"),uniforms:[...Fe,te,{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"},...re,...A,...le],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:k("label_fixed_anchor_identify"),buildFragment:U("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"},...A],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec2_offset",location:1},{name:"a_vec4_identifier",location:2}]},line:{buildVertex:k("line"),buildFragment:U("line"),uniforms:[...Fe,te,{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"},...re,...xe,...be,...A,...le,...Ee],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:k("pointsprite"),buildFragment:U("pointsprite"),uniforms:[...Fe,te,{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"},...re,...A,...le],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:k("pointsprite_identify"),buildFragment:U("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"},...A],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:k("point_anchor"),buildFragment:U("color_identify"),uniforms:[ee,{name:"u_vec2_vpt_size",type:"2f"},{name:"u_vec2_offset",type:"2f"},{name:"u_float_floor_elevation",type:"1f"},...A],attributes:[{name:"a_vec4_position",location:0},{name:"a_vec2_offset",location:1},{name:"a_vec4_identifier",location:2}]},stripedLine:{buildVertex:k("striped_line"),buildFragment:U("striped_line"),uniforms:[...Fe,te,{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"},...re,...le,...Ee,...xe,...be],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:k("striped_line"),buildFragment:U("striped_line"),uniforms:[...Fe,te,{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"},...A,...re,...le,...Ee,...xe,...be],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:k("patterned_line"),buildFragment:U("patterned_line"),uniforms:[ee,{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"},te,...re,...le,...Ee,...xe,...be],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:k("patterned_line"),buildFragment:U("patterned_line"),uniforms:[ee,{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"},te,...A,...re,...le,...Ee,...xe,...be],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:k("striped_line_identify"),buildFragment:U("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"}],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:k("striped_line_identify"),buildFragment:U("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"},...A],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:k("color"),buildFragment:U("textured_color"),uniforms:[...Fe,te,{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"},...re,...xe,...be,...le,...Ee],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_float_visibility",location:1},{name:"a_float_mix_factor",location:2}]},vtxColorIdentify:{buildVertex:k("color_identify"),buildFragment:U("color_identify"),uniforms:[...Fe,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_float_floor_elevation",type:"1f"}],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec4_identifier",location:1},{name:"a_float_visibility",location:2}]},metricPoint:{buildVertex:k("metric_point"),buildFragment:U("metric_point"),uniforms:[ee,te,{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"},...re,...le,...xe,...be],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},zbmModelIdentify:{buildVertex:k("zbm_model_identify"),buildFragment:U("color_identify"),uniforms:[ee,{name:"u_vec2_vpt_size",type:"2fv"},...A],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:k("diffuse_identify"),buildFragment:U("color_identify"),uniforms:[ee,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_float_floor_elevation",type:"1f"},...A],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:k("one_way_line"),buildFragment:U("one_way_line"),uniforms:[ee,te,{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"},...re,...le,...Ee],attributes:[{name:"a_vec2_position",location:0},{name:"a_vec2_direction",location:1},{name:"a_vec2_widen_direction",location:2}]},zbmModel:{buildVertex:k("zbm_model"),buildFragment:U("zbm_model"),uniforms:[ee,te,{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"},...re,...A,...le,...Ee,...xe,...be],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:k("zbm_shadow"),buildFragment:U("main_shadow"),uniforms:[ee,{name:"u_float_height_factor",type:"1f"},...A],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec2_dem_position",location:2}]},gltfModel:{buildVertex:k("gltf_model"),buildFragment:U("gltf_model"),uniforms:[...Fe,te,{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"},...re,...Ee,...le,...A,...xe,...be,...vt,...cs],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:k("gltf_model"),buildFragment:U("color_identify"),uniforms:[...Fe,te,{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"},...re,...le,...A,...vt,...cs],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:k("gltf_shadow"),buildFragment:U("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"},...A,...vt,...cs],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:k("simple_line_2d"),buildFragment:U("simple_line_2d"),uniforms:[...Fe,te,{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"},...re,...Ee,...xe,...le,...be],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec4_direction_distance",location:1},{name:"a_float_visibility",location:2}]},simpleLine3d:{buildVertex:k("simple_line_3d"),buildFragment:U("simple_line_3d"),uniforms:[ee,te,{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"},...re,...Ee,...xe,...le,...be,...A,...vt],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:k("road"),buildFragment:U("road"),uniforms:[...Fe,te,{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"},...re,...xe,...le,...Ee,...be],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec4_normals",location:1},{name:"a_vec2_shift",location:2}]},roadIdentify:{buildVertex:k("road_identify"),buildFragment:U("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"}],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec4_normals",location:1},{name:"a_vec4_identifier",location:2}]},line3D:{buildVertex:k("line3d"),buildFragment:U("road"),uniforms:[ee,te,{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},...A,...re,...xe,...le,...Ee,...be,...vt],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:k("line3d_identify"),buildFragment:U("road_identify"),uniforms:[ee,{name:"u_float_width",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},...A,...vt],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:k("arrow_line_entrance"),buildFragment:U("arrow_line"),uniforms:[ee,te,{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"},...re,...le],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:k("arrow_line_entrance"),buildFragment:U("arrow_line_identify"),uniforms:[ee,te,{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:k("circle_marker"),buildFragment:U("circle_marker"),uniforms:[...Fe,te,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_width",type:"1f"},...re,...le,...xe,...be,...A],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec2_widen",location:1}]},rectWithTexture:{buildVertex:k("rect_with_texture"),buildFragment:U("rect_with_texture"),uniforms:[ee,te,{name:"u_sr2d_texture",type:"1i"},{name:"u_float_opacity",type:"1f"},...le,...re],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},circleMarkerIdentify:{buildVertex:k("circle_marker_identify"),buildFragment:U("color_identify"),uniforms:[...Fe,{name:"u_vec2_vpt_size",type:"2fv"},{name:"u_float_width",type:"1f"},...A],attributes:[{name:"a_vec3_vertex",location:0},{name:"a_vec2_widen",location:1},{name:"a_vec4_identifier",location:2}]},heatmap:{buildVertex:k("heatmap"),buildFragment:U("heatmap"),uniforms:[ee,te,...re,{name:"u_float_radius",type:"1f"},{name:"u_float_intensity",type:"1f"},{name:"u_float_tile_to_pixel_ratio",type:"1f"},...le],attributes:[{name:"a_vec2_position",location:0},{name:"a_vec2_widen",location:1},{name:"a_float_weight",location:2}]},heatmapTexture:{buildVertex:k("heatmap_texture"),buildFragment:U("heatmap_texture"),uniforms:[te,{name:"u_sr2d_texture",type:"1i"},{name:"u_sr2d_ramp_texture",type:"1i"},{name:"u_float_opacity",type:"1f"},...re,...le],attributes:[{name:"a_vec2_position",location:0}]},demMesh:{buildVertex:k("dem_mesh"),buildFragment:U("dem_mesh"),uniforms:[ee,te,{name:"u_mat4_flat_map_mvp",type:"mat4"},{name:"u_flat_tex",type:"1i"},{name:"u_hillshade_tex",type:"1i"},...re,...A,...le,...Ee,...xe,...be],attributes:[{name:"a_vec2_position",location:0}]},demGround:{buildVertex:k("dem_ground"),buildFragment:U("dem_ground"),uniforms:[ee,te,...A],attributes:[{name:"a_vec2_position",location:0}]},demMesh2:{buildVertex:k("dem_mesh2"),buildFragment:U("dem_mesh2"),uniforms:[ee,te,{name:"u_mat4_flat_map_mvp",type:"mat4"},{name:"u_flat_tex",type:"1i"},{name:"u_hillshade_tex",type:"1i"},...re,...A,...le,...Ee,...xe,...be,{name:"u_int_identify",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demMesh2DepthTest:{buildVertex:k("dem_mesh2_depthtest"),buildFragment:U("uniform_color"),uniforms:[ee,...A,{name:"u_vec4_color",type:"4fv"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demGround2:{buildVertex:k("dem_ground2"),buildFragment:U("dem_ground2"),uniforms:[ee,te,...A],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demElevationCopy:{buildVertex:k("dem_elevation_copy"),buildFragment:U("dem_elevation_copy"),uniforms:[ee,{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:k("dem_elevation"),buildFragment:U("dem_elevation"),uniforms:[ee],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_height",location:1}]},demHillshade:{buildVertex:k("dem_normal"),buildFragment:U("dem_normal"),uniforms:[...A,...xe,...be,ee,{name:"u_sr2d_texture",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_texcoord",location:1}]},demFlatBottom:{buildVertex:k("dem_flat_bottom"),buildFragment:U("dem_flat_bottom"),uniforms:[ee,...A],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_vec2_centroid",location:1},{name:"a_vec2_extender",location:2}]},mesh:{buildVertex:k("mesh"),buildFragment:U("mesh"),uniforms:[ee,te,...re,...A,...vt,...xe,...be,...le,...Ee,{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"}],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:k("mesh"),buildFragment:U("inverse"),uniforms:[ee,te,...re,...A,...vt,...xe,...be,...le,...Ee,{name:"u_float_opacity",type:"1f"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_mat4_gradient",type:"mat4"},{name:"u_int_identify",type:"1i"},{name:"u_float_texture_params",type:"4fv"},{name:"u_int_is_textured",type:"1i"},{name:"u_float_texture_vertical_scale",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec3_normal",location:2},{name:"a_float_gradient",location:3},{name:"a_vec2_dem_position",location:4},{name:"a_float_abs_z",location:5},{name:"a_vec4_identifier",location:6},{name:"a_float_visibility",location:7},{name:"a_float_is_pivot",location:8}]},meshDepthClear:{buildVertex:k("mesh"),buildFragment:U("depth_clear"),uniforms:[ee,te,...re,...A,...vt,...xe,...be,...le,...Ee,{name:"u_float_opacity",type:"1f"},{name:"u_vec4_color",type:"4fv"},{name:"u_float_height_factor",type:"1f"},{name:"u_sdtr_distance",type:"1f"},{name:"u_mat4_gradient",type:"mat4"},{name:"u_int_identify",type:"1i"},{name:"u_float_texture_params",type:"4fv"},{name:"u_int_is_textured",type:"1i"},{name:"u_float_texture_vertical_scale",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0},{name:"a_float_z",location:1},{name:"a_vec3_normal",location:2},{name:"a_float_gradient",location:3},{name:"a_vec2_dem_position",location:4},{name:"a_float_abs_z",location:5},{name:"a_vec4_identifier",location:6},{name:"a_float_visibility",location:7},{name:"a_float_is_pivot",location:8}]},mapMesh:{buildVertex:k("map_mesh"),buildFragment:U("map_mesh"),uniforms:[ee,te,...re,...A,...xe,...be,...vt,...le,...Ee,{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:k("sky"),buildFragment:U("sky"),uniforms:[te,...re,...le],attributes:[{name:"a_vec2_vertex",location:0}]},taa:{buildVertex:k("posteffect"),buildFragment:U("taa"),uniforms:[{name:"u_texture",type:"1i"},{name:"u_float_mix_coef",type:"1f"}],attributes:[{name:"a_vec2_vertex",location:0}]},fxaa:{buildVertex:k("posteffect"),buildFragment:U("fxaa"),uniforms:[{name:"u_texture",type:"1i"},{name:"u_vec2_vpt_size",type:"2f"}],attributes:[{name:"a_vec2_vertex",location:0}]},copy:{buildVertex:k("posteffect"),buildFragment:U("copy"),uniforms:[{name:"u_texture",type:"1i"},{name:"u_depth",type:"1i"}],attributes:[{name:"a_vec2_vertex",location:0}]},buildingShadow:{buildVertex:k("building_shadow"),buildFragment:U("main_shadow"),uniforms:[...A,ee,{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:k("mesh_shadow"),buildFragment:U("main_shadow"),uniforms:[ee,{name:"u_float_height_factor",type:"1f"},...A,...vt],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:k("globe_halo"),buildFragment:U("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:k("stars"),buildFragment:U("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:k("globe_halo"),buildFragment:U("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 Ov(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 ll{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 a=t[o],r=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(a)||n.isArrayOfNumbers(a))for(let c=0;c<a.length;++c)i[r+c]=a[c];else i[r]=a}}commitData(){if(!this._data)return;const e=this._gl;e.bindBuffer(e.UNIFORM_BUFFER,this._buffer),e.bufferData(e.UNIFORM_BUFFER,this._data,e.DYNAMIC_DRAW),e.bindBuffer(e.UNIFORM_BUFFER,null)}cleanup(){this._buffer&&this._gl.deleteBuffer(this._buffer)}prepare(e){const t=this._gl;this._buffer=t.createBuffer();const i=e.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 a=i[this.params.blockName];a||console.error(`UBO block "${this.params.blockName}" not found in shader program.`);const r=e.getUniformsIndicesOffsetsInBlock(a);if(!r){console.error("Failed to initialize UBO. Couldn't retrieve uniforms information.");return}this._uniformsMap=r}}var ds=(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))(ds||{});const Pi=1/0,Bn=-1/0,zn="renderCacheManager",Nv=[0,0,0,0];class kv{constructor(e,t){this.prevFrameAnimationLayerOverCacheIndex=void 0,this.prevFrameAnimationLayerUnderCacheIndex=void 0,this.cacheObjectsCount=0,this.animationLayersOverCacheMinIndex=Pi,this.animationLayersUnderCacheMaxIndex=Bn,this.state=e,this.modules=t,this.cacheFramebufferId=void 0,this.isReadyCache=!1,this.isLowZoom=this.state.zoom<6,this.cacheDisabled=this.state.disableRenderingCache,this.animationLayersUniqueIds=new Set,this.debugMode=!1,this.debugSkipRenderToCanvas=!1,this.cachedLayersMap=new Map}isLayerAnimated(e,t){const i=this.getUniqueRenderIndex(e,t);return!!this.animationLayersUniqueIds.has(i)}isLayerInCache(e,t){if(!this.isReadyCache)return!1;const i=this.cachedLayersMap.get(e);return!!i&&i.has(t)}frameEnd(){}initInDebugMode(){this.debugMode=!0}setDebugSkipRenderToCanvas(e){this.debugSkipRenderToCanvas=e,this.modules.renderer.addRerenderEvent()}frameStart(){this.cachedLayersMap=new Map,this.cacheObjectsCount=0,this.isLowZoom=this.state.zoom<6,this.isReadyCache=!1;let e=!1;this.cacheDisabled||(this.animationLayersUniqueIds.clear(),this.cacheFramebufferId===void 0&&(this.cacheFramebufferId=this.createCacheFramebuffer()),this.animationLayersOverCacheMinIndex=Pi,this.animationLayersUnderCacheMaxIndex=Bn,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===Pi&&this.animationLayersUnderCacheMaxIndex===Bn||this.isLowZoom||this.animationLayersUnderCacheMaxIndex>=this.animationLayersOverCacheMinIndex||o&&this.modules.renderer.hasAnimatedFlatObjectInDemMode&&t.layerSettings.forceRenderUnderCacheInDemMode)return 1;const a=this.getUniqueRenderIndex(t.attributes.styleId,t.attributes.layerId);return a>=this.animationLayersOverCacheMinIndex?2:a<=this.animationLayersUnderCacheMaxIndex||(e[this.cacheFramebufferId]||(e[this.cacheFramebufferId]={framebuffer:this.modules.renderer.getFramebuffer(this.cacheFramebufferId),objects:[],tileObjects:new Set}),this.isReadyCache||(e[this.cacheFramebufferId].objects.push(t),e[this.cacheFramebufferId].tileObjects.add(i)),this.cacheObjectsCount++,this.markLayerInCache(t.attributes.styleId,t.attributes.layerId),o&&this.modules.renderer.hasAnimatedFlatObjectInDemMode&&t.layerSettings.forcePrerenderUnderCacheInDemMode)?1:0}hasReadyCache(){return this.isReadyCache&&!this.cacheDisabled}hasCachedObjects(){return!!this.cacheObjectsCount}render(){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(zn),this.debugMode?this.modules.renderer.applyGpuState(A_,void 0,!1):this.modules.renderer.applyGpuState(J_,void 0,!1),this.modules.postEffectsManager.copyRenderTargetToCanvas(e,!0,!1),this.modules.renderer.restoreGpuState(zn))}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?Bn:Pi;const a=this.modules.styleManager.getMaxLayersCount();return-e*a+o.renderIndex}createCacheFramebuffer(){if(!this.modules.renderer.fragDepthSupported()){console.warn("Render cache disabled - Fragment Depth write not supported"),this.cacheDisabled=!0;return}const e=this.modules.renderer.getViewportSize(),t=this.modules.renderer.webglContextState.MAX_TEXTURE_SIZE;if(Math.max(...e)>t){n.log(`Render cache disabled as viewport size ${e[0]}x${e[1]} exceeds hardware limits of ${t}x${t}`),this.cacheDisabled=!0;return}const o=w.NearestFilter,a=this.modules.renderer.getViewportSize(),r=new Ce({size:[a[0],a[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();r.setSize([l[0],l[1]])},renderTarget:r,onRenderStart:()=>{if(this.isReadyCache||this.cacheFramebufferId===void 0)return;const l=this.modules.renderer.getFramebuffer(this.cacheFramebufferId);l&&(this.modules.renderer.bindRenderTarget(l.renderTarget),this.modules.renderer.storeGpuState(zn),this.modules.renderer.applyGpuState(eu,void 0,!1),this.modules.renderer.clearWithColor(Nv,!0),this.modules.renderer.bindRenderTarget(null),this.modules.renderer.restoreGpuState(zn))},onRenderEnd:()=>{},isCacheFramebuffer:!0,useDem:!0,renderIndex:Pi})}}const Uv=1.3,Hv=2,cl=n.reserveTextureIndex(),dl=n.reserveTextureIndex(),_l=n.reserveTextureIndex(),Gv=16,Vv=0,Zt=[1,1,1,1],ul=new Float64Array(16);let Li=(Tt=class extends Vd{constructor(e,t){const i=t.layout.canvas,o=e.webglVersion,a={antialias:!1,stencil:o!==2,failIfMajorPerformanceCaveat:!1,preserveDrawingBuffer:e.preserveDrawingBuffer};let r=null;if((!o||o===2)&&(r=i.getContext("webgl2",a),Tt.webglVersion=2),(r===null||o===1)&&(r=i.getContext("webgl",a)||i.getContext("experimental-webgl",a),Tt.webglVersion=1),r===null||!(r instanceof WebGLRenderingContext||r instanceof WebGL2RenderingContext))throw new Error("Failed to obtain WebGL context");super({gl:r,clearColor:n.getColorForShaders(e.defaultBackgroundColor)}),this.commonShaderDefines=n.EMPTY_SHADER_DEFINITIONS,this.hasAnimatedFlatObjectInDemMode=!1,this.destroyed=!1,this.framebuffers=[],this.lastRenderedFramebuffers=[],this.mapMeshMvpMatrix=new Float64Array(16),this.drawTargetsFramebufferIds=new Map,this.ubosMap={},this.lastAppliedGpuState={state:null},this.applyGpuState=(c,d,_=!0)=>{const u=c(this.modules),h=this.lastAppliedGpuState,f=d==null?void 0:d.gpuState;h.state===u&&h.layerState===(d==null?void 0:d.gpuState)||(this.applyState(u,f),_&&(h.state=u,h.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=r.getExtension("WEBGL_debug_renderer_info");this.webglContextState={MAX_TEXTURE_SIZE:r.getParameter(r.MAX_TEXTURE_SIZE),MAX_VIEWPORT_DIMS:r.getParameter(r.MAX_VIEWPORT_DIMS),MAX_UNIFORM_BUFFER_BINDINGS:r instanceof WebGLRenderingContext?0:r.getParameter(r.MAX_UNIFORM_BUFFER_BINDINGS),MAX_COMBINED_UNIFORM_BLOCKS:r instanceof WebGLRenderingContext?0:r.getParameter(r.MAX_COMBINED_UNIFORM_BLOCKS),RENDERER:l?r.getParameter(l.UNMASKED_RENDERER_WEBGL):r.getParameter(r.RENDERER),VENDOR:l?r.getParameter(l.UNMASKED_VENDOR_WEBGL):r.getParameter(r.VENDOR)},this.identifyBuffer=new Ce({minFilter:w.NearestFilter,magFilter:w.NearestFilter}),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=Dv(),this.shaderPrograms={},t.map.once("idle",()=>Ov(this,this.shaderProgramOptions)),this.symbolSettingsList=Xf(),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 Kf(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,a=t===!0?o.COLOR_BUFFER_BIT|o.DEPTH_BUFFER_BIT:o.COLOR_BUFFER_BIT,r=t?Pa:Q_;this.applyGpuState(r),o.clearDepth(i),o.clearColor(e[0],e[1],e[2],e[3]),o.clear(a)}renderTileObjects(e){this.resetStateAfterExternalRender(),this.drawTargetsFramebufferIds.forEach(a=>{const r=this.getFramebuffer(a);r&&(r.requestedInCurrentFrame=!1)}),this.state.collectStats&&this.timers&&this.timers.addTimer();let t=!1,i=!1;const o=this.getRenderObjectsByGroups(e,!1);if(this.lastRenderedFramebuffers.forEach(a=>{o.groups.some(r=>r.framebuffer===a)||this.clearFramebuffer(a)}),this.lastRenderedFramebuffers=[],o.groups.forEach(a=>{var p,v,x,g;const{objects:r,tileObjects:l,isUnderCache:c}=a;let{framebuffer:d}=a;const _=this.modules.map.state.demMode&&(d===void 0||d.useDem===!0),u=!d,h=(d==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,T=window.devicePixelRatio;this._gl.bindFramebuffer(this._gl.FRAMEBUFFER,null),this._gl.viewport(b.left*T,b.bottom*T,y[0]*T,y[1]*T),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(r.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(T=>{T.updateMvpMatrix(y,b)}),Ct(this.state,this.modules,r,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 a=this.timers.tryToGetFirstTimerValue();a&&this.modules.map.emit("gpuRenderTime",a)}for(const[a,r]of this.drawTargetsFramebufferIds){const l=this.getFramebuffer(r);(!l||!l.requestedInCurrentFrame)&&(this.drawTargetsFramebufferIds.delete(a),this.removeFramebuffer(r))}return this}renderElevation(e){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 a=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 r=(d=(c=o.getViewProjectionMatrix)==null?void 0:c.call(o))!=null?d:this.modules.camera.viewProjectionMatrix;e.forEach(u=>{u.updateMvpMatrix(r)}),Ct(this.state,this.modules,t,a),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 a=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 r=(d=(c=o.getViewProjectionMatrix)==null?void 0:c.call(o))!=null?d:this.modules.camera.viewProjectionMatrix;e.forEach(u=>{u.updateMvpMatrix(r,this.modules.demManager.demTextureMatrix)}),Ct(this.state,this.modules,t,a),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),a=e.filter(r=>r.labelTestChildren[0]);a.forEach(r=>{r.updateMvpMatrix(this.modules.camera.viewProjectionMatrix,this.modules.demManager.demTextureMatrix)}),a.forEach(r=>{r.labelTestChildren.forEach(l=>{l.attributes.labelTest===!0&&i.push(l)})}),this.spriteLabelingTextureBuffer.bind(t),this.clearWithColor([1,1,1,1]),t.viewport(0,0,this.spriteLabelingTextureBuffer.options.size[0],this.spriteLabelingTextureBuffer.options.size[1]),Ct(this.state,this.modules,i,o),this.spriteLabelingTextureBuffer.unbind(t)}renderLabelingTexture(e){if(this.modules.renderCacheManager.hasReadyCache()||(this.resetStateAfterExternalRender(),this.state.isLabelingDepthTestDisabled=!0,this.state.styleZoom<Gv||this.state.pitch===Vv||this.state.disableHidingPois))return;const t=this._gl,i=[],o=bt(this.state,this.modules,void 0,this.labelingTextureBuffer,this.modules.map.state.demMode),a=e.filter(r=>r.depthTestChildren[0]);a.forEach(r=>{r.updateMvpMatrix(this.modules.camera.viewProjectionMatrix,this.modules.demManager.demTextureMatrix)}),a.forEach(r=>{r.depthTestChildren.forEach(l=>{const c=this.modules.styleManager.getStyleLayer(l.attributes.styleId,l.attributes.layerId);(c&&c.type!=="gltfModel"||!(c!=null&&c.style.preventObjectsHiding))&&i.push(l)})}),this.state.isLabelingDepthTestDisabled=!1,this.labelingTextureBuffer.bind(t),this.clearWithColor(n.LABELING_TEXTURE_BACKGROUND_COLOR),t.viewport(0,0,this.labelingTextureBuffer.options.size[0],this.labelingTextureBuffer.options.size[1]),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:a,framebuffer:r,isUnderCache:l})=>{var u,h,f;const c=this.modules.map.state.demMode&&(r===void 0||r.useDem===!0),d=r?r.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=r==null?void 0:r.getViewProjectionMatrix)==null?void 0:u.call(r))!=null?h:this.modules.camera.viewProjectionMatrix,p=c?this.modules.demManager.demTextureMatrix:void 0;a.forEach(v=>{v.updateMvpMatrix(m,p)}),Ct(this.state,this.modules,o,_)}d.unbind(t),r==null||r.renderTarget.unbind(this._gl),(f=r==null?void 0:r.onRenderEnd)==null||f.call(r)})}waitForGpuCommandsToFinish(){const e=new Float32Array(4);this.readPixelsFloat(0,0,1,1,e)}readPixelsFloat(e,t,i,o,a){const r=this._gl;r.readPixels(e,t,i,o,r.RGBA,r.FLOAT,a)}getRenderingContext(){return this._gl}getShaderProgram(e,t){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 a=(c=t==null?void 0:t.hash)!=null?c:"",r=(d=t==null?void 0:t.defines)!=null?d:[];let l=o[a];return l||(l=new ao(this._gl,this.shaderProgramOptions[e],n.Shader.createShaderDefinitions([...this.commonShaderDefines.defines,...r])),o[a]=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(){if(this.destroyed)return;this.lastRenderedFramebuffers=[],this.framebuffers.forEach(t=>{t==null||t.renderTarget.remove()}),this.modules.layout.canvas.removeEventListener("webglcontextlost",this.trackContextLost);const e=this._gl.getExtension("WEBGL_lose_context");e&&e.loseContext(),this.modules.layout.destroy(),this.mapMeshFramebufferId=void 0,this.mapMeshIdFramebufferId=void 0,this.destroyed=!0}addFramebuffer(e){return this.framebuffers.push(e),this.framebuffers.length-1}getFramebuffer(e){if(e!==n.INVALID_FRAMEBUFFER_ID)return this.framebuffers[e]}removeFramebuffer(e){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,a=window.devicePixelRatio;t.viewport(o.left*a,o.bottom*a,i[0]*a,i[1]*a)}}getRenderTarget(){return this.currentTarget}getDrawTargetFramebuffer(e){const t=this.drawTargetsFramebufferIds.get(e);if(t!==void 0)return this.getFramebuffer(t)}doesDrawTargetFramebufferExist(e){const t=this.drawTargetsFramebufferIds.get(e);if(t!==void 0){const i=this.getFramebuffer(t);return i&&i.requestedInCurrentFrame}return!1}getDrawTargetFramebufferId(e){let t=this.drawTargetsFramebufferIds.get(e);if(t!==void 0){const c=this.getFramebuffer(t);return c&&(c.requestedInCurrentFrame=!0),t}const i=this.modules.map.state.demMode,o=this.modules.renderer.getPixelRatio(),a=this.modules.map.state.size,r=new Ce({size:i?[Math.trunc(a[0]*Oe[0]*o),Math.trunc(a[1]*Oe[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:r,clearColor:[0,0,0,0],clearDepth:!0,onResize:()=>{const c=this.modules.map.state.demMode,d=this.modules.map.state.size;r.setSize(c?[Math.trunc(d[0]*Oe[0]*o),Math.trunc(d[1]*Oe[1]*o)]:this.getViewportSize()),this.modules.renderer.bindRenderTarget(r),this.modules.renderer.bindRenderTarget(null)},renderIndex:-1/0,useDem:!1,requestedInCurrentFrame:!0};return t=this.modules.renderer.addFramebuffer(l),this.drawTargetsFramebufferIds.set(e,t),t}renderDemMesh(e,t,i=!1,o){const{framebuffer:a,tiles:r}=t;if(!a)return;let l=this.modules.demManager.getFlatMapTextures();if(i&&(l=l.filter(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||is(u))return;const{size:m,viewport:p}=this.state,v=window.devicePixelRatio,{commonBinder:x,programBinder:g,layerBinder:y,programName:b}=u.layerSettings,T=this.getShaderProgram(b),S=[];r.forEach((E,R)=>{S.push({objects:E,tile:R})});const L=e.copy(a.renderTarget,!1,!0);l.forEach(E=>{var F,se;const H=S.filter(Y=>hl(E.viewport,Y.tile.bounds.values())).reduce((Y,z)=>(z.tile.updateMvpMatrix(E.mvpMatrix,this.modules.demManager.demTextureMatrix),Y.concat(z.objects)),[]),V=[],P=new Map;if(H.forEach(({obj:Y,framebufferId:z})=>{if(z===void 0)V.push(Y);else{const ae=P.get(z);ae?ae.push(Y):P.set(z,[Y])}}),P.forEach((Y,z)=>{var we,Se;const ae=this.getFramebuffer(z);ae&&((we=ae.onRenderStart)==null||we.call(ae),ae.renderTarget.bind(this._gl),this._gl.viewport(0,0,ae.renderTarget.options.size[0],ae.renderTarget.options.size[1]),ae.clearColor&&this.clearWithColor(ae.clearColor,!1),Ct(this.state,this.modules,Y,L),ae.renderTarget.unbind(this._gl),(Se=ae.onRenderEnd)==null||Se.call(ae))}),(F=a.onRenderStart)==null||F.call(a),a.renderTarget.bind(this._gl),this._gl.viewport(0,0,a.renderTarget.options.size[0],a.renderTarget.options.size[1]),a.clearColor&&this.clearWithColor(a.clearColor,!1),Ct(this.state,this.modules,V,L),a.renderTarget.unbind(this._gl),(se=a.onRenderEnd)==null||se.call(a),i){this.identifyBuffer.bind(this._gl);const Y=this.identifyBuffer.options.size;this._gl.viewport(0,0,Y[0],Y[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(T),this._gl instanceof WebGLRenderingContext&&(x==null||x(T,this.state,this.modules)),g==null||g(T,this.state,this.modules,!0),y==null||y(T,this.state,this.modules,f),e.useState(u,f),c.forEach(Y=>{if(Y instanceof Ta&&Y.needSync&&Y.syncReplicas(this.state),hl(E.viewport,Y.bounds.values())){Y.updateMvpMatrix(this.modules.camera.viewProjectionMatrix,this.modules.demManager.demTextureMatrix,E.texMatrix);const z=(i?Y.identifyChildren:Y.children).filter(({sink:ae})=>ae==="mesh"||ae==="mesh2");Co(z,this.state,this.modules),e.drawSymbol(z,f,this.state,this.modules)}}),i&&this.identifyBuffer.unbind(this._gl)})}getMapMeshFramebufferId(){return this.mapMeshFramebufferId===void 0&&(this.mapMeshFramebufferId=this.createMapMeshFramebuffer()),this.mapMeshFramebufferId}getMapMeshIdFramebufferId(){return this.mapMeshIdFramebufferId===void 0&&(this.mapMeshIdFramebufferId=this.createMapMeshFramebuffer(!0)),this.mapMeshIdFramebufferId}prerenderUpdate(){const e=this.rebuildExternalShaderDefinitions();this.updateUbos(e)}getRenderObjectsByGroups(e,t){const{demManager:i,map:o}=this.modules,{demMode:a}=o.state,r={},l={framebuffer:void 0,objects:[],tileObjects:new Set},c={framebuffer:void 0,objects:[],tileObjects:new Set,isUnderCache:!0},d={};let _;if(a){const h=t?i.getIdentifyFlatFramebufferId():i.getFlatFramebufferId(),f=this.getFramebuffer(h);f&&(_={framebuffer:f,tiles:new Map})}this.hasAnimatedFlatObjectInDemMode=!t&&a&&e.some(h=>h.children.some(f=>!f.layerSettings.is3dMapAware&&this.modules.renderCacheManager.isLayerAnimated(f.attributes.styleId,f.attributes.layerId))),e.forEach(h=>{(t?h.identifyChildren:h.children).forEach(m=>{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||a&&x){const T=m.attributes.tiers;if(this.state.immersiveLevel.tiers&&T){let S=!1;if(T.forEach(L=>{if(!L){S=!0;return}d[L]||(d[L]={objects:[],tileObjects:new Set}),d[L].objects.push(m),d[L].tileObjects.add(h)}),!S)return}if(a&&!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 S=this.modules.renderCacheManager.tryToCacheObjects(r,m,h,a);if(S===ds.CACHED)return;S===ds.RENDER_OVER_CACHE?(l.objects.push(m),l.tileObjects.add(h)):(c.objects.push(m),c.tileObjects.add(h))}return}r[g]||(r[g]={framebuffer:this.getFramebuffer(g),objects:[],tileObjects:new Set}),r[g].objects.push(m),r[g].tileObjects.add(h)})});const u=Object.values(r).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 ll({gl:t,blockName:"CommonSettings"}),this.ubosMap.CommonSettings=o,o.bind(i)),Yd(i,this.state,this.modules,o),o.commitData();const a=this.modules.map.state,r=!isNaN(a.handyStyleId)&&this.modules.styleManager.getStyle(a.handyStyleId)||void 0,l=(c=r==null?void 0:r.light.lightingModesResolved)!=null?c:n.DEFAULT_LIGHTING_MODES;for(const d in l){let _=this.ubosMap[d];(!_||e)&&(_=new ll({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(Zt[0],Zt[1],Zt[2],Zt[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:a}=this.calculateMapMeshParams(e),r=new Ce({size:a,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(ul,[0,c/d[1],0],[1/d[0],1/d[1],1]),n.multiply(this.mapMeshMvpMatrix,ul,this.modules.camera.viewProjectionMatrix),this.mapMeshMvpMatrix},onResize:()=>{const c=this.calculateMapMeshParams(e);l.scale=c.scale,r.setSize(c.size),r.bind(t),r.unbind(t)},renderTarget:r,scale:o};return this.addFramebuffer(l)}calculateMapMeshParams(e){const t=e?n.identify.pixelDensity:1,i=window.devicePixelRatio,o=n.scale$2([],this.modules.map.state.size,i),a=Math.min(Uv,Math.min(this.webglContextState.MAX_TEXTURE_SIZE,this.webglContextState.MAX_VIEWPORT_DIMS[0])/o[0]),r=Math.min(Hv,Math.min(this.webglContextState.MAX_TEXTURE_SIZE,this.webglContextState.MAX_VIEWPORT_DIMS[1])/o[1]),l=[Math.trunc(o[0]*t*a),Math.trunc(o[1]*t*r)];return{scale:[a,r],size:l}}prepareExternalShaderDefinitions(){const e=[];return this.webGlExtensions.EXT_frag_depth&&e.push({type:"HAS_FRAG_DEPTH_EXT"}),this.modules.environmentManager.isFogEnabled()&&e.push({type:bh}),this.modules.environmentManager.isSkyEnabled()&&e.push({type:wh}),this.modules.shadowManager.texture&&e.push({type:Rh}),this.state.aaMode===ti.FXAA?e.push({type:ei.FXAA}):this.state.aaMode===ti.TAA&&e.push({type:ei.TAA}),Ks(this._gl)&&e.push({type:zh}),this.webglContextState.MAX_UNIFORM_BUFFER_BINDINGS>0&&e.push({type:Fh}),this.state.isDeprecatedSystem?e.push({type:kh}):(e.push({type:Dh}),e.push({type:Oh})),this.webglContextState.RENDERER.toLowerCase().includes("mali")&&this.webglContextState.VENDOR.toLowerCase().includes("arm")&&e.push({type:Nh}),n.Shader.createShaderDefinitions(e)}},Tt.webglVersion=NaN,Tt);function hl(s,e){for(const t of e)if(n.tetragonIntersectsBounds(s,t))return!0;return!1}let Bi="./worker.js";function jv(s){Bi=s}function Zv(){return Bi}function Wv(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 $v(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 Xv(s){return{ModelsSource:s.set("ModelsWorker",n.ModelsWorker).get(n.ThreadName.Models)}}class Kv{constructor(){this.connector=new n.MainConnector,this.fnRegistry=new n.FnRegistry(this.connector),this.classRegistry=new n.ClassRegistry(this.fnRegistry),this.parserWorker=new Worker(Bi),this.labelingWorker=new Worker(Bi),this.modelsWorker=new Worker(Bi),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=Wv(this.fnRegistry,this.classRegistry),this.labeling=$v(this.fnRegistry),this.models=Xv(this.classRegistry)}syncStyle(e){this.parser.syncStyle(e),this.labeling.syncStyle(e)}destroy(){this.parserWorker.terminate(),this.labelingWorker.terminate(),this.modelsWorker.terminate()}}function qv(s=!1){const e=typeof window!="undefined",t=typeof SharedArrayBuffer!="undefined",i=e&&window.crossOriginIsolated===!0,o=typeof OffscreenCanvas!="undefined",a=typeof HTMLCanvasElement!="undefined",r=a&&"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:",a),console.log("[render][check] hasTransferControlToOffscreen:",r));const l=e&&t&&i&&o&&a&&r;return console.log(`[render] mode: ${l?"worker":"main thread"}`),l}function Yv(){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 Qv{constructor(e,t){var r;if(this.frameWriteSlot=1,this.frameId=0,!e.webgpu)return;const i=qv();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=Yv();(r=t.layout.canvas.parentElement)==null||r.appendChild(o);let a;if(i){this.worker=new Worker(Zv(),{name:"Render"}),this.worker.postMessage({msg:{youare:"render"}});const l=o.transferControlToOffscreen();a=n.wrap(this.worker)(n.RenderBackendType.WebGPU,n.transfer(l,[l]),this.transportBuffer)}else a=n.createRenderRunner(n.RenderBackendType.WebGPU,o,this.transportBuffer);a.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 Jv{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,a=o[0],r=o[1];if(e||t instanceof WebGLRenderingContext||this.state.forceSyncIdentify){const l=new Uint8Array(a*r*4);return i.bind(t),t.readPixels(0,0,o[0],o[1],t.RGBA,t.UNSIGNED_BYTE,l),i.unbind(t),l}else return this._pendingReadIdentifyPixelsPromise?this._pendingReadIdentifyPixelsPromise:(this._pendingReadIdentifyPixelsPromise=new Promise((l,c)=>{K(this,null,function*(){const d=new Uint8Array(a*r*4);i.bind(t);const _=a*r*4;!this.pixelPackBuffer||this.pixelPackBufferSize!==_?(this.pixelPackBuffer&&t.deleteBuffer(this.pixelPackBuffer),this.pixelPackBuffer=t.createBuffer(),this.pixelPackBufferSize=_,t.bindBuffer(t.PIXEL_PACK_BUFFER,this.pixelPackBuffer),t.bufferData(t.PIXEL_PACK_BUFFER,_,t.STREAM_READ)):t.bindBuffer(t.PIXEL_PACK_BUFFER,this.pixelPackBuffer),t.readPixels(0,0,a,r,t.RGBA,t.UNSIGNED_BYTE,0);const u=t.fenceSync(t.SYNC_GPU_COMMANDS_COMPLETE,0);if(t.flush(),!u){i.unbind(t),c("Failed to create sync object"),this._pendingReadIdentifyPixelsPromise=void 0;return}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((a,r)=>{function l(){const c=e.clientWaitSync(t,i,0);if(c===e.WAIT_FAILED){r();return}if(c===e.TIMEOUT_EXPIRED){setTimeout(l,o);return}a()}l()})}searchHigherPriority(e){const{viewport:t}=this.state,i=n.fromValues$1(e[0]-t.left,e[1]-t.top),o=this.state.identifyPickDistance*window.devicePixelRatio;let a=1/0,r,l=!1;const c=n.create$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);(!r||!l&&_||d.phase>r.phase||d.phase===r.phase&&u<a)&&(r=d,a=u,_&&(l=!0))}return r}searchPointInCache(e){if(this.colorBuffer===void 0)return;const t=n.identify.pixelDensity*window.devicePixelRatio,i=this.modules.renderer.identifyBuffer.options.size,o=this.state.size;if(e[0]<0||e[0]>o[0]-1||e[1]<0||e[1]>o[1]-1)return;const a=Math.floor(e[0]*t),l=((i[1]-1-Math.floor(e[1]*t))*i[0]+a)*4,c=(this.colorBuffer[l+3]<<24|this.colorBuffer[l+2]<<16|this.colorBuffer[l+1]<<8|this.colorBuffer[l])>>>0;return this.indexToIdentifierResponse(c)}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(a=>this.identifyData.push(a))})}catch(e){console.warn(`Cannot fill cache: ${e}`)}finally{this.cacheBusy=!1}})}indexToIdentifierResponse(e){var t,i,o;for(let a=0;a<this.identifyData.length;a++){const r=this.identifyData[a],{dynamicObjectId:l,ids:c,metatileHash:d,sourceId:_,tileKey:u}=r,{startIndex:h,endIndex:f,idBuffer:m,floorIdBuffer:p,phaseBuffer:v,sublayerBuffer:x,styleIdBuffer:g,layerIdBuffer:y,instanceIdBuffer:b,objectClassBuffer:T,centerBuffer:S,strings:L}=c;if(e<h||e>f)continue;const E=e-h,R=m[E],H=new Uint32Array(x)[E],V=new Uint8Array(b)[E],P=new Uint32Array(T)[E];let F,se="";const Y=p[E],z=this.modules.assetManager.getMetatile(d);if(z){(t=z.reverseDictionaries.db_sublayer)!=null&&t[H]&&(F=z.reverseDictionaries.db_sublayer[H]);const Ze=L[e];Ze!==void 0?se=Ze.objectClass:se=(o=(i=z==null?void 0:z.reverseDictionaries.db_object_class)==null?void 0:i[P])!=null?o:""}const ae=new Uint16Array(g)[E],we=new Uint32Array(y)[E],Se=this.modules.styleManager.getStyleLayer(ae,we);if(!Se||Se.type==="custom")return;const Ke=new Int32Array(S,E*Int32Array.BYTES_PER_ELEMENT*2,2);return{id:R,styleId:ae,layerId:we,floorId:Y,phase:new Float32Array(v)[E],dynamicObjectId:l,sourceId:_,tileKey:u,sublayer:F,symbol:Se.type,instanceId:V,objectClass:se,center:Ke[0]!==n.INVALID_IDENTIFY_CENTER_COORD||Ke[1]!==n.INVALID_IDENTIFY_CENTER_COORD?[Ke[0],Ke[1]]:void 0}}}}function Av(s,e,t){var a;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 r=Object.values(e.groupsById).find(l=>l&&l.id===t);if(r)i=e.layers.findIndex(l=>l.groupId===r.innerId);else{i=e.layers.findIndex(c=>c.id===t);const l=(a=e.layers[i])==null?void 0:a.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 r=i!==e.layers.length?e.layers[i]:void 0;if(r&&r.groupId!==void 0){const l=e.groupsById[r.groupId];if(!l){n.log(`Для слоя с id «${r.id}» находящегося в группе с groupId «${r.groupId}» отсутствует группа id в стиле c id «${e.id}»`);return}const c=l.layers.findIndex(d=>d.id===r.id);if(c===-1){n.log(`Слой с id «${r.id}» и groupId «${r.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(r=>{if(e.layersById[r.innerId]=r,e.layerIdToInnerId[r.id]=r.innerId,r.type==="point"||r.type==="polygon"||r.type==="metricPoint"||r.type==="embankment"||r.type==="polygon3d"){const l=Math.max(0,...Object.keys(e.rasterSets.byIndex).map(_=>Number(_))),c=new n.HandyIndexer(l+1);n.makeHandyRasterSets(r,c,e.icons).forEach(_=>{e.rasterSets.byKey[_.key]||(e.rasterSets.byIndex[_.index]=_,e.rasterSets.byKey[_.key]=_)})}}),fl(e)}function eg(s,e,t){const i=e.layerIdToInnerId[s];if(i===void 0)return;e.revision++;let o=[];const a=e.groupsById[i];if(a){if(o=a.layers,delete e.groupsById[i],delete e.layerIdToInnerId[a.id],o.length===0)return}else{const l=e.layersById[i];if(!l){n.log(`Слой с id «${s}» есть в списке идентификаторов слоев стиля, но при этом отсутствует в стиле c id «${e.id}»`);return}if(l.groupId!==void 0&&l.groupIndex!==void 0){const c=e.groupsById[l.groupId];c&&(c.layers.splice(l.groupIndex,1),c.layers.forEach((d,_)=>d.groupIndex=_))}o=[l]}const r=e.layers.findIndex(l=>l.id===o[0].id);r!==-1&&(o.forEach(l=>{const{styleManager:c,map:{state:d}}=t,_=c.getRemoveLayerHook(l.innerId);_&&(_(d),c.clearRemoveLayerHook(l.innerId)),delete e.layersById[l.innerId],delete e.layerIdToInnerId[l.id]}),e.layers.splice(r,o.length),fl(e))}function fl(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 tg(s,e,t){const{map:{state:i},collector:o,imageManager:a,renderer:r,tileManager:l}=t;let c;try{c=ig(i,s,256)}catch(g){console.error(g);return}const d=a.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=a.addPreparedTexture(f),p=r.addFramebuffer({renderTarget:h,clearColor:[0,0,0,0],onResize:()=>{h.setSize([Math.ceil(i.size[0]*window.devicePixelRatio/_),Math.ceil(i.size[1]*window.devicePixelRatio/_)]),r.bindRenderTarget(h),r.bindRenderTarget(null);const g=h.getTexture();g&&a.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),a.deleteTexture(m),a.deleteTexture(d),r.removeFramebuffer(p)}}function ig(s,e,t){const i=n.makeBinderContext(s.styleZoom,s.styleState,[]),o=e.style.color,a=[];if(!ng(o.argument))throw new Error(`Heatmap color must be interpolate expression with 'heatmap-density' argument in layer ${e.id}`);const r=t-1;for(let l=0;l<t;l++){const c=l/r,d=n.sampleColor(o,c,i);a.push(...d.value)}return new w(new Uint8Array(a),{size:[t,1]})}function ng(s){return typeof s=="object"&&s.type==="heatmap-density"}const ml=1,pl={type:"color",value:[0,0,0,0]};class og{constructor(e){this.modules=e,this.customLayers=new Map,this.maxCountStyleLayers=1e4,this.styleIndex=ml,this.handyStylesMap=new Map,this.waitingStyleRequests=new Map,this.onRemoveLayerHooks=new Map}createStyle(e,t,i){const{state:o}=this.modules.map;if(!Number.isNaN(o.handyStyleId)){const c=this.getStyle(o.handyStyleId);c&&(c.layers.forEach(d=>{const _=this.onRemoveLayerHooks.get(d.innerId);_&&_(o)}),this.onRemoveLayerHooks.clear())}const a=this.styleIndex++;a-n.UNUSED_STYLE_ID_SHIFT>0&&this.handyStylesMap.delete(a-n.UNUSED_STYLE_ID_SHIFT);const r=n.makeHandyStyle(e,a,i);n.applyStyleOptions(r,t),this.handyStylesMap.set(r.id,r),this.setMaxLayersCount(r.layers.length);const l=this.waitingStyleRequests.get(a);return l&&l.resolve(r),this.modules.workers.syncStyle(r),r.layers.forEach(c=>this.initHandyLayer(a,c)),r}hasLayer(e){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&&(Av(o,i,t),this.setMaxLayersCount(i.layers.length),e.type==="custom"&&o.type==="custom"?this.initCustomLayer(i.id,o,e.render,e.onRemove,e.onAdd):this.initHandyLayer(i.id,o),this.modules.workers.syncStyle(i))}setTerrainStyle(e){const t=this.getStyle(this.modules.map.state.handyStyleId);t&&(t.dem=n.makeHandyDemLayer(e),this.modules.demManager.onTerrainStyleChange(),this.modules.renderer.addRerenderEvent())}addIcon(e,t){const i=this.getStyle(this.modules.map.state.handyStyleId);if(!i)return console.error('Cannot add icons before map style was completely set. Please use "styleload" event.'),!1;const o=i.layers.filter(d=>(d.type==="point"||d.type==="metricPoint")&&d.style.iconImage!==void 0&&n.expressionValues(d.style.iconImage).some(_=>_===e)),a=i.layers.filter(d=>(d.type==="polygon"||d.type==="embankment"||d.type==="polygon3d")&&!!d.style.textureImage&&n.expressionValues(d.style.textureImage).some(_=>_===e));if(!!i.icons[e])return console.error(`The icon with the name ${e} already exists.`),!1;const l=Math.max(0,...Object.keys(i.rasterSets.byIndex).map(d=>Number(d))),c=new n.HandyIndexer(l+1);return i.icons[e]=t,[...o,...a].forEach(d=>{n.getLayerImageProps(d).forEach(({imageType:_,anchor:u})=>{const h=n.makeHandyRasterSet(e,_,c,u,i.icons);i.rasterSets.byIndex[h.index]=h,i.rasterSets.byKey[h.key]=h})}),i.revision++,this.modules.workers.syncStyle(i),!0}removeIcon(e){const t=this.getStyle(this.modules.map.state.handyStyleId);if(!t)return console.error('Cannot remove icons before map style was completely set. Please use "styleload" event.'),!1;delete t.icons[e];let i=!1;return t.layers.filter(o=>o.type==="point"&&!!o.style.iconImage||o.type==="polygon"&&!!o.style.textureImage||o.type==="metricPoint"&&!!o.style.iconImage||o.type==="embankment"&&!!o.style.textureImage||o.type==="polygon3d"&&!!o.style.textureImage).forEach(o=>{n.getLayerImageProps(o).forEach(({image:a,imageType:r,anchor:l})=>{n.expressionValues(a).forEach(c=>{if(c===e){const d=r==="icon"?n.getStaticIconRasterSetKey(c,l[0],l[1]):n.getStaticTextureRasterSetKey(c),_=t.rasterSets.byKey[d];_&&(this.modules.assetManager.removeRasterSet(_,t.id),i=!0)}})})}),i?(t.revision++,this.modules.workers.syncStyle(t),!0):!1}addModel(e,t){const i=this.getStyle(this.modules.map.state.handyStyleId);return i?i.modelIndex[e]!==void 0?(console.error(`The model with the name ${e} already exists.`),!1):(i.models.push(t),i.modelIndex[e]=i.models.length-1,i.revision++,this.modules.workers.syncStyle(i),!0):(console.error('Cannot add models before map style was completely set. Please use "styleload" event.'),!1)}removeLayer(e){const t=this.getStyle(this.modules.map.state.handyStyleId);if(!t){console.error('Cannot remove layer before map style was completely set. Please use "styleload" event.');return}n.commPoiLayers.some(i=>i.id===e)||(eg(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 a;const o=(a=this.handyStylesMap.get(e))==null?void 0:a.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(a=>{o.resolve=a}),this.waitingStyleRequests.set(e,o),o.promise}addRemoveLayerHook(e,t){this.onRemoveLayerHooks.set(e,t)}getRemoveLayerHook(e){return this.onRemoveLayerHooks.get(e)}clearRemoveLayerHook(e){this.onRemoveLayerHooks.delete(e)}callCustomLayerRender(e){const t=this.customLayers.get(e);t&&t.renderFunction(this.modules.renderer.getRenderingContext())}getCustomSceneObjects(){const e=[];return this.customLayers.forEach(t=>e.push(t.sceneObject)),e}getMaxLayersCount(){return this.maxCountStyleLayers}getStyleLayerForObject(e){const t=this.getStyle(e.attributes.styleId);return t?t.layersById[e.attributes.layerId]:null}getFeatureFlag(e,t){const i=this.getStyle(this.modules.map.state.handyStyleId);return i?i.graphicsPresets[t][e]===!0:!1}getClearColor(){const{map:e}=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,[]),a=n.resolveColor(i.environment.style.skyColor,o),r=t.globeMode?t.globeRatioTarget:0;return n.lerp$3(pl.value,i.background.color.value,a.value,r),pl}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:a}=t;if(o&&i.layersById){const r=i.layerIdToInnerId[o];if(r){const l=i.layersById[r];if(l)l.style&&(l.style.visibility=e);else{const c=i.groupsById[r];c==null||c.layers.forEach(d=>{d&&d.style&&(d.style.visibility=e)})}}}a&&i.layers.forEach(r=>{r.type===a&&(r.style.visibility=e)})}initHandyLayer(e,t){let i;switch(t.type){case"group":t.layers.forEach(o=>this.initHandyLayer(e,o));return;case"heatmap":i=tg(t,e,this.modules);break;case"polygonExtrusion":i=this.initPolygonExtrusionLayer(e,t);break}i&&this.modules.styleManager.addRemoveLayerHook(t.innerId,i)}setMaxLayersCount(e){this.maxCountStyleLayers<e&&(this.maxCountStyleLayers=e)}initCustomLayer(e,t,i,o,a){const r={sceneObject:{type:n.SceneObjectType.Custom,attributes:{styleId:e,layerId:t.innerId,tileData:[]},tile:{zoomLevel:0},layerSettings:{},canRender:!0},layer:t,renderFunction:i};a==null||a(),this.customLayers.set(t.innerId,r),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((a,r)=>{var _;const l=(_=i==null?void 0:i.icons[a.image])==null?void 0:_.url;if(!l){console.warn(`Texture source for polygonExtrusionSideTexture ${a.image} not found inside style.`);return}const c=n.getUrlForIconMapIcon(l,i,"");this.modules.imageManager.loadTexture(c,{skipAtlasSizeChecking:!0,generateMipmaps:this.modules.renderer.isWebgl2Context(),minFilter:this.modules.renderer.isWebgl2Context()?w.LinearMipMapLinearFilter:w.LinearFilter,imagePadding:0,premultiplyAlpha:!0}).then(u=>{u!==void 0&&!o&&(t.sideTextureIndices[r]=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 a=0;a<o.length;a++)o[a].call(this,t);return this}}const Rn="gltfModels";let vl=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,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.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.universeTileLayer=new n.TileLayer(0,n.tiles.maxUniverseZoom,0,n.tiles.maxUniverseZoom,this.modules,e,this.zenithSource,{requestOddTiles:e.mobileSdkMode,useExtendedTilesBounds:!0,coverageTileLayer:this.regionalTileLayer}),this.universeTileLayer.getLabelingData=()=>{const a=n.TileLayer.prototype.getLabelingData.call(this.universeTileLayer);return this.regionalTileLayer.isBlank()||(a.labelsKeys=[]),a},this.modules.tileManager.addTileLayer(this.universeTileLayer),this.commercialPoiSource=new n.GeoJsonSourceCore(this.id,this.modules,{url:n.bindUrl("commercialPoi",{host:e.tileServer,tileSet:e.commercialTileSet,protocol:n.tiles.protocol,lang:e.lang}),flipY:!0,identifyAsDefaultSource:!0,promoteId:"db_id"},this.state),this.commercialPoiTileLayer=new n.TileLayer(n.commercialPoi.minZoom,n.commercialPoi.maxZoom,n.commercialPoi.minZoom,n.GEOJSON_DEFAULT_MAX_DETAIL_LEVEL,this.modules,e,this.commercialPoiSource,{viewportPadding:n.MODELS_TILES_VIEWPORT_PADDING}),this.modules.tileManager.addTileLayer(this.commercialPoiTileLayer),this.createModelsSource(),this.modules.sourceStorage.addSource(this)}destroyModelsSource(){this.modelsSource&&(this.modelsSource=null,this.modelsTileLayer&&this.modules.tileManager.removeTileLayer(this.modelsTileLayer))}createModelsSource(){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:n.tiles.protocol,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:n.tiles.protocol,lang:this.state.lang}),flipY:!0,attributes:{sourceName:Rn}},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:Rn})),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,a,r,l,c){return this.zenithSource.generateTile(e,t,i,o,a,r,l,c)}generateModel(e){return this.zenithSource.generateModel(e)}isIdentifiedAsDefault(){return!0}setDataType(e){this.options.dt!==e&&(!this.options.dt||!e||!n.equalArrays(this.options.dt,e))&&(this.options.dt=e,this.regionalTileLayer.redraw())}getDataType(){return this.options.dt}setDataFilter(e){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 sg extends St{constructor(e,t){super(),this.coverageRevision=0,this.loadFont=(a,r)=>{let l=this.requestFontRanges.get(a,r);return l||(l=this.createLoadFontRequest(a,r),this.requestFontRanges.set(a,r,l)),l},this.invalidateUsedGltfModels=n.throttle(()=>{var c;const a=new Set;if(this.modules.renderer.isDestroyed)return;const r=this.modules.tileManager.getTileObjects();for(const d of r)for(const _ of d.children){if(!is(_))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){a.add(y);return}if(x===g){const b=this.dataModelIdToUrl[g];if(b){const T=m===this.modules.defaultSource.getId()&&p===Rn;this.loadModel(b,g,u,!1,v,T)}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(!is(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&&a.add(x)})}});for(const d in this.models){const _=this.models[d];!_.preserve&&!a.has(_)&&_.status===nt.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=(a,r,l)=>{const c=n.hashToString(r);fetch(a).then(d=>{if(!d.ok)throw new Error(`Failed to load metatile "${c}"`);return d.json()}).then(d=>this.setMetatile(r,l,d)).catch(d=>console.error(d))};const i=(a,r)=>{const l=this.modules.styleManager.getStyle(a);if(!l){console.error(`Not found style ${a} in AssetManager#addNewRasterSets`);return}const{rasterSets:c}=l;r.forEach(d=>{c.byIndex[d.index]=d,c.byKey[d.key]=d})},{fnRegistry:o}=this.modules.workers;o.set("addNewRasterSets",i),o.set("loadFont",this.loadFont),this.setPreparedMetatile(-1,n.fixedMetatile),this.setPreparedMetatile(n.geoJsonMetatileHash,n.createGeoJsonMetatile(Array.from(this.state.modelShowHideEventsSublayers)))}getMemoryFootprint(){const e={textures:this.textures.map(n.textureSizeJs),fontTextures:this.fontTextures.reduce((i,o)=>(i.push(n.textureSizeJs(o)),i),[]),fontGlyphs:Object.values(this.fontGlyphs).reduce((i,o)=>Object.values(o).reduce((a,r)=>{var l,c;return a.push({bitmap:(c=(l=r.bitmap)==null?void 0:l.byteLength)!=null?c:0}),a},i),[]),models:Object.values(this.models).map(n.modelSizeJs).filter(i=>i.buffers.length>0||i.textures.length>0)},t={textures:this.textures.map(n.textureSizeGpu),fontTextures:this.fontTextures.reduce((i,o)=>(i.push(n.textureSizeGpu(o)),i),[]),models:Object.values(this.models).map(n.modelSizeGpu).filter(i=>i.buffers.length>0||i.textures.length>0)};return{js: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),o.tileCoverage&&this.coverageRevision++,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:a}=o,r=7,l=t.length/r;for(let u=0;u<l;u++){const h=t[u*r],f=t[u*r+1],m=t[u*r+6],p=t[u*r+2],v=t[u*r+3],x=t[u*r+4],g=t[u*r+5],y=a.byIndex[h];if(y.isSvg){const S={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]=S,(d=(c=this.requestedSvgs[o.id])==null?void 0:c[h])==null||d.then(L=>{const E=this.textures[S.atlasIndex],{url:R,revokeURL:H}=Or(L);Dr(R,S.w,S.h).then(V=>{E.subImage(V,S.x,S.y),this.modules.renderer.addRerenderEvent(),H&&H()})})}else{const S=(_=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]=S,S.x=p,S.y=v,S.atlasIndex=m,S.isPacked=!0}this.textures[m]===void 0&&(this.textures[m]=new w(void 0,{size:n.atlasSize,flipY:!1,premultiplyAlpha:!ud,magFilter:w.LinearFilter,minFilter:w.LinearFilter}),this.modules.renderer.prepareTexture(this.textures[m]));const b=this.textures[m],T=i&&i[u];if(T!==void 0){b.subImage(T,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 a=e[o*3],r=e[o*3+1],l=e[o*3+2],c=r<<16|l,d=this.modules.styleManager.getStyle(a);if(!d){console.error(`Not found style ${a} in AssetManager#loadRasters`);continue}if(this.loadedRasters[a]||(this.loadedRasters[a]=new Set,this.failedRasters[a]=new Set,this.requestedRasters[a]=new Set),this.requestedRasters[a].has(c))continue;const{rasterSets:_}=d,u=_.byIndex[r];if(u.rasters[l].isPacked===!1){console.error(`Try to load not packed raster ${u.key}`);continue}this.requestedRasters[a].add(c),u.isSvg?this.loadSvg(c,d,r):this.loadPng(c,d,r,l)}}removeRasterSet(e,t){const{key:i,index:o,rasters:a}=e;delete this.requestedSvgs[t][o],a.forEach(({rasterSetIndex:l,rasterIndex:c})=>{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 r=this.modules.styleManager.getStyle(t);r&&(delete r.rasterSets.byIndex[o],delete r.rasterSets.byKey[i])}getMetatile(e){return this.metatiles[e]}getAllMetatiles(){return this.metatiles}getProjectMetadata(){return this.projectMetatileMetadata}getFontGlyphs(e){return this.fontGlyphs[e]||{}}getFontTextureByName(e,t){return this.fontTextures.get(e,t)}isIdle(){let e=0,t=0;for(const i in this.requestedRasters)e+=this.requestedRasters[i].size,t+=this.loadedRasters[i].size+this.failedRasters[i].size;return e===t&&this.pendingFontRanges===this.loadedFontRanges&&this.allModelsLoaded()}dangerouslySetMetatiles(e){this.metatiles=e}dangerouslySetRasters(e,t){this.loadedRasters=e,this.failedRasters=t}loadModelByIndex(e,t,i){const o=this.getModelUniqueKey(e,t);if(this.models[o]!==void 0)return;const a=this.modules.styleManager.getStyle(t);if(a===void 0){n.logGltfError({layer:"prepare",message:"Style not found. Can't determine url"});return}const r=a.models[e];if(r===void 0){n.logGltfError({layer:"prepare",message:`Model with index "${e}" is missing in the style.`});return}const l=n.getModelUrl(r.url,a);this.fetchModel(l,e,o,!1,i,!1)}loadModel(e,t,i,o,a,r,l){const c=this.getModelUniqueKey(t,i);if(this.models[c]!==void 0){l==null||l();return}this.fetchModel(e,t,c,o,a,r,l)}getModel(e,t){return this.models[this.getModelUniqueKey(e,t)]}allModelsLoaded(){for(const e in this.models)if(this.models[e].status===nt.Pending)return!1;return!0}isModelLoaded(e,t){const i=this.models[this.getModelUniqueKey(e,t)];return i&&i.status===nt.Loaded}removeModel(e){const t=this.models[e];if(t){for(const i of t.scenes)i.objects.forEach(o=>{o.elementsBuffer&&o.elementsBuffer.remove()}),i.objects.splice(0,i.objects.length);t.scenes.splice(0,t.scenes.length),t.buffers.forEach(i=>{i instanceof n.Buffer&&i.remove()}),t.buffers=[],t.textures.forEach(i=>i.remove()),t.textures=[],delete this.models[e]}}fetchModel(e,t,i,o,a,r,l){const{renderer:c}=this.modules,d=this.models[i]=Sf(o);this.modelsWorker.loadModel(e,this.state.dracoDecoderUrl).then(_=>{if(_.type==="ok"){if(d.status=nt.Loaded,!_.result)return;Tf(d,c,_.result,t,a,r),this.emit("modelloaded",t),this.modules.renderer.addRerenderEvent(),l==null||l()}else n.logGltfError(_),d.status=nt.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)?ml:this.state.handyStyleId;try{const o=yield this.modules.styleManager.waitForStyle(i),a=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()),r=n.processFont(a);return this.prepareFontAtlas(e,t,r),this.modules.workers.labeling.appendFont(e,r.glyphData),this.loadedFontRanges+=1,this.modules.workers.labeling.markFontAsLoaded(e,t)}catch(o){return console.error(o),this.loadedFontRanges+=1,this.modules.workers.labeling.markFontAsLoaded(e,t)}})}prepareFontAtlas(e,t,i){const{bitmap:o,width:a,height:r,glyphData:l}=i;this.fontGlyphs[e]||(this.fontGlyphs[e]={});for(const d in l)this.fontGlyphs[e][d]=l[d];const c=new w(new Uint8Array(o),{size:[a,r],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 a=t.rasterSets.byIndex[i],r=a.rasters[o],l=this.textures[r.atlasIndex];let c="";if(a.type===n.RasterSetType.Unique){const d=a.id;a.url?c=n.getSizeDependentImageUrl(a.url,r.w,r.h):c=n.getUrl("dynamicPoi",{host:this.state.tileServer,tileSet:this.state.tileSet,protocol:this.state.tileProtocol,subdomain:n.getSubdomainFromString(this.state.subdomains,d),id:d,width:r.w.toString(),height:r.h.toString(),regionId:String(a.regionId)})}else if(a.type===n.RasterSetType.Static){const d=t.icons[a.name];if(!d){console.error(`There is no appropriate icon config in the style for raster set: "${a.name}"`),this.failedRasters[t.id].add(e);return}c=n.getUrlForIconMapIcon(d.url,t,n.getSubdomainFromString(this.state.subdomains,a.name))}this.modules.workers.parser.prepareAtlas(c).then(d=>K(this,null,function*(){if(d){if(d.isBitmap){if((d.data[0].width!==r.w||d.data[0].height!==r.h)&&a.type===n.RasterSetType.Static){if(r.w<=0||r.h<=0)return;const _=document.createElement("canvas");_.width=r.w,_.height=r.h,_.getContext("2d").drawImage(d.data[0],0,0,_.width,_.height),l.subImage(_,r.x,r.y)}else l.subImage(d.data[0],r.x,r.y);this.modules.renderer.addRerenderEvent()}else Sn(d.data[0]).then(_=>{l.subImage(_,r.x,r.y),this.modules.renderer.addRerenderEvent()});this.loadedRasters[t.id].add(e),a.isReady=!0}else this.failedRasters[t.id].add(e)}))})}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 a=t.icons[o.name];if(!a){console.error(`There is no appropriate icon config in the style for raster set: "${o.name}"`),this.failedRasters[t.id].add(e);return}const r=n.getUrlForIconMapIcon(a.url,t,n.getSubdomainFromString(this.state.subdomains,o.name));this.requestedSvgs[t.id]||(this.requestedSvgs[t.id]={});let l=this.requestedSvgs[t.id][i];(!l||this.disableIconCache)&&(l=fetch(r,{cache:this.disableIconCache?"no-cache":"default"}).then(c=>{if(!c.ok)throw new Error("Not 2xx response");return c.text()}),this.requestedSvgs[t.id][i]=l);try{const c=yield l,{url:d,revokeURL:_}=Or(c),u=yield Dr(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 ag{constructor(e,t,i,o,a,r,l,c){this.modules=e,this.mapState=t,this.cache=i,this.maxStyleZoom=-1/0,this.minStyleZoom=1/0,this.ready=!1,this.useful=!1,this.status="initial",this.model=o,this.key=a,this.selectedIds=r,this.styleId=l,this.styleRevision=c,this.modelRevision=o.revision,this.objects=[]}update(){switch(this.status){case"initial":{this.useful&&(this.loadModel(),this.status="generating");break}case"generating":{if(this.useful&&this.processResponse&&this.model.texturesLoaded){const{objects:{data:e}}=this.processResponse;this.objects=lg(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:a,offset:r}}}=this,c={url:n.getUrl("model",{host:this.mapState.tileServer,tileSet:this.mapState.tileSet,protocol:this.mapState.tileProtocol,subdomain:n.getSubdomainFromString(this.mapState.subdomains,o),regionId:e.toString(),name:o}),id:i,regionId:e,metatileHash:t,selected:this.selectedIds.some(d=>d===i),pixelRatio:window.devicePixelRatio,styleState:this.mapState.styleState,styleId:this.mapState.handyStyleId,offset:r,matrix:a};this.modules.defaultSource.generateModel(c).then(d=>{this.model.prepareTextures(d.textures),this.processResponse=d})}updateMinAndMaxStyleZoom(e){this.minStyleZoom=Math.min(...e.map(t=>Math.min(...t.children.map(i=>{var a;const o=this.modules.styleManager.getStyleLayer(i.attributes.styleId,i.attributes.layerId);return(o==null?void 0:o.type)==="dem"?1/0:(a=o==null?void 0:o.minzoom)!=null?a:-1/0})))),this.maxStyleZoom=Math.max(...e.map(t=>Math.max(...t.children.map(i=>{var a;const o=this.modules.styleManager.getStyleLayer(i.attributes.styleId,i.attributes.layerId);return(o==null?void 0:o.type)==="dem"?-1/0:(a=o==null?void 0:o.maxzoom)!=null?a:1/0}))))}}function rg(s,e,t,i,o){const a=e.join("|");return`model=${s}_sId=${t}_sRev=${i}_mRev=${o}_sel=${a}`}function lg(s,e){var a,r,l;const t=new yl(s,e),i=[],o=gl((l=(r=(a=t.children[0])!=null?a:t.identifyChildren[0])!=null?r: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=gl(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 yl([],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 gl(s){if(s&&"matrix"in s.attributes)return s.attributes.matrix}class yl 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 cg{constructor(e,t,i,o,a,r){var l;this.modules=e,this.mapState=t,this.cache=i,this.regionId=o,this.metatileHash=a,this.sourceModel=r,this.revision=0,this.texturesLoaded=!1,this.textures=[],this.readiness=0,this.id=r.id,this.attributes=(l=r.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=>Sn(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 a=rg(this.id,e,t,i,o),r=this.cache.get(a);r?(this.newMod=r,this.newMod.useful=!0):this.newMod=new ag(this.modules,this.mapState,this.cache,this,a,e,t,i)}startReadinessTicker(){this.readiness=0,n.start(this.readinessTickerName,{easing:n.buildingAnimation.easing},this.mapState,0,1,n.buildingAnimation.duration,1)}stopReadinessTicker(){this.readiness=0,n.stop(this.readinessTickerName,this.mapState)}}class dg{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),a=Math.min(t.sourceModel.maxZoom,i.maxStyleZoom),{styleZoom:r}=this.mapState;if(!(r<o||r>=a))return{minStyleZoom:o,maxStyleZoom:a,opacity:this.getOpacity(e,o)}}isIdle(){return this.viewportModelsReady()&&!this.viewportModels.some(e=>e.isAnimating())}viewportModelsReady(){return this.viewportModels.every(e=>{const t=e.getUsefulMod();return t&&t.ready})}setHiddenBuildingIds(e){e.forEach(t=>{this.hiddenBuildingIds.add(t)})}unsetHiddenBuildingIds(e){e.forEach(t=>{this.hiddenBuildingIds.delete(t)})}findViewportModels(){const{styleZoom:e}=this.mapState;this.viewportModels=[],this.models.forEach(t=>{const{bound:i,minZoom:o,maxZoom:a}=t.sourceModel;if(e<o||e>=a)return;const r=this.mapState.styleState._activeFloorIds,l=t.attributes.db_hidden_by_plan_id;if(l&&r.includes(l)||this.modules.floorManager.hasDisplayedFloorBuilding([t.id])||!!!this.modules.assetManager.getMetatile(t.metatileHash)||this.hiddenBuildingIds.has(t.id))return;n.tetragonIntersectsBounds(this.mapState.tilesBounds,i)&&this.viewportModels.push(t)})}updateScene(){let e=!1;const t=new Map;this.viewportModels.forEach(i=>{const o=i.getCurrentMod();o&&o.ready&&t.set(o.key,o)}),this.displayedMods.forEach((i,o)=>{t.has(o)||(i.objects.length&&i.objects.forEach(a=>this.modules.tileManager.removeObject(a)),e=!0)}),t.forEach((i,o)=>{this.displayedMods.has(o)||(i.objects.length&&i.objects.forEach(a=>this.modules.tileManager.addObject(a)),e=!0),this.cache.get(o)}),e&&(this.displayedMods=t,this.modules.renderer.addRerenderEvent(),this.modules.identifier.resetCache())}cleanUnnessasaryModels(){const e=new Set(this.cache.getData().map(t=>t.model));this.models.forEach(t=>{e.has(t)||t.clean()})}loadModelsInfo(e,t,i){this.requestedModelsInfo.has(t)||(this.requestedModelsInfo.add(t),fetch(e).then(o=>{if(!o.ok)throw new Error(`Failed to load models info for region ${t}`);return o.json()}).then(o=>{o.forEach(a=>{if(!a.fileName){console.error(`ZBM source "fileName" is empty. Failed to load model by url: ${e}`);return}const r=new cg(this.modules,this.mapState,this.cache,t,i,a);this.models.set(r.id,r)}),this.loadedModelsInfo.add(t)}).catch(o=>{this.loadedModelsInfo.add(t),console.error(o)}))}updateObjectsVisibility(){const e=this.ids;this.models.forEach(t=>{var a;const i=((a=this.getVisibleModelData(t.id))==null?void 0:a.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 _g{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=xl(this.currentTrafficState,this.currentSelectedIds),this.ids=e.identifier.getIdScope(n.DEFAULT_ID_SCOPE)}setPersonalPoi(e){this.currentPois=e;const t=new Set;for(const i of e)t.add(i.id);this.currentIdSet=t,this.modCache.clear(),this.displayedModKey=void 0}redraw(){this.modCache.clear(),this.displayedModKey=void 0}getIdentifyDataChunk(){return this.identifyDataChunk}update(){if(this.regionMetadata===void 0&&(this.regionMetadata=this.modules.assetManager.getProjectMetadata()),this.regionMetadata===void 0)return;this.updateModKey();const e=this.currentModKey,t=this.modCache.get(e);t===void 0&&!this.isGenerating&&this.generate(e,this.currentPois,this.regionMetadata),t!==void 0&&e!==this.displayedModKey&&this.show(e,t,this.regionMetadata)}generate(e,t,i){const{regionId:o,metatileHash:a}=i,r=this.modules.map.state;this.isGenerating=!0,this.modules.workers.parser.generatePersonalPoi(t,o,a,window.devicePixelRatio,this.ids.getSelected(),r.handyStyleId,r.styleState,this.modules.defaultSource.getId()).then(l=>{if(l===void 0){this.isGenerating=!1;return}const{collectorOutput:c,styleId:d}=l,{packedRasters:_,rastersToLoad:u}=c;_!==void 0&&this.modules.assetManager.prepareRasters(d,_),this.modules.assetManager.loadRasters(u),this.modCache.set(e,l),this.isGenerating=!1})}show(e,t,i){const{metatileHash:o}=i,{collectorOutput:{labels:a,identifyIds:r},styleId:l}=t;this.modules.labeler.removeLabels("ppoi"),a.length&&this.modules.labeler.addLabels("ppoi",n.LabelSource.PersonalPoi,[{metatileHash:o,labels:a,styleId:l}]),this.identifyDataChunk={metatileHash:o,ids:r},this.modules.identifier.resetCache(),this.displayedModKey=e}updateModKey(){const e=this.ids.getSelected().filter(i=>this.currentIdSet.has(i)),t=this.modules.trafficTileLayer.isEnabled();(!n.deepEqual(this.currentSelectedIds,e)||this.currentTrafficState!==t)&&(this.currentTrafficState=t,this.currentSelectedIds=e,this.currentModKey=xl(t,e))}}function xl(s,e){return`ppoi_${s}_${e.join("|")}`}let _s=(Kt=class extends n.Evented{constructor(e,t){super(),this.fogFactorBreakpoint=.4,this.demElevation=0,this.demTilesRevision=NaN,this.options=n.applyDefaults(t,Kt.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=ug(this.options),this.isHidden=!0,this.targetOpacity=0,this.modules.layers.addLayer(this),this.mapState=e.state,this.rounder=hg(!this.options.disableRounding);let{offset:o}=this.options;const{labeling:a}=this.options;a.type!=="none"&&(a.offset!==void 0&&(o=a.offset),this.modules.labeler.addLabelBox(this.labelKey,{id:this.uniqId,width:a.width,height:a.height,position:this.position.normalizedValue,offset:o,labelingGroup:this.getLabelingGroup(),parentPoiId:a.type==="pinnedToPoi"?a.poiId:void 0}))}destroy(){this.removeHtml(),this.modules.labeler.removeLabels(this.labelKey),this.modules.layers.removeLayer(this)}update(){const e=this.checkZoom(),t=this.checkFog(),i=!this.isInvolvedInLabeling()||this.modules.labeler.isLabelBoxSurvived(this.uniqId);e&&t&&i?this.show():this.hide(),this.updatePosition()}setZIndex(e){this.options.zIndex=e,this.html.style.zIndex=String(e)}setContent(e){this.options.html=e,this.html.innerHTML="";const t=document.createElement("div");typeof e=="string"?t.innerHTML=e:t.append(e),this.html.append(t)}setLabelingSize(e,t){this.options.labeling.type!=="none"&&(this.options.labeling.width=e,this.options.labeling.height=t,this.updateLabelBox())}setPosition(e){const t=n.Mercator.fromGeo(e);this.position={userValue:t,normalizedValue:n.normalizeMapPoint(t)},this.mapState.demMode&&this.updateDemElevation(),this.updateLabelBox()}setOffset(e){this.options.offset=[e[0],e[1]],this.updateLabelBox()}setMinZoom(e){this.options.minZoom=e}setMaxZoom(e){this.options.maxZoom=e}getZIndex(){return this.options.zIndex}getOffset(){return this.options.offset}getPosition(){return n.Mercator.toGeo(this.position.userValue)}getHtmlElement(){return this.html.firstChild}dangerouslyGetRootElement(){return this.html}isShown(){return!this.isHidden}show(){if(this.isHidden&&(this.isHidden=!1,this.appendHtml(),this.emit("shown",{id:this.uniqId.toString(),point:[this.screenPoint[0],this.screenPoint[1]],object:this}),this.options.animate)){if(this.showAnimationTimer)return;this.hideAnimationTimer&&(clearTimeout(this.hideAnimationTimer),this.hideAnimationTimer=void 0),this.targetOpacity!==1&&(this.showAnimationTimer=window.setTimeout(()=>{this.setHtmlOpacity(1),this.showAnimationTimer=void 0},0))}}hide(){if(!this.isHidden)if(this.isHidden=!0,this.options.animate){if(this.hideAnimationTimer)return;this.showAnimationTimer&&(clearTimeout(this.showAnimationTimer),this.showAnimationTimer=void 0),this.setHtmlOpacity(0),this.hideAnimationTimer=window.setTimeout(()=>{this.removeHtml(),this.hideAnimationTimer=void 0},this.options.duration)}else this.removeHtml()}setHtmlOpacity(e){this.html.style.opacity=String(e),this.targetOpacity=e}removeHtml(){this.html.remove(),this.screenPoint=[0,0]}appendHtml(){this.getMarkerContainer().appendChild(this.html)}getMarkerContainer(){return this.options.preventMapInteractions?this.modules.layout.htmlContainerOutMap:this.modules.layout.htmlContainerInMap}updateDemElevation(){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 a=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)}),r=a.map(d=>Math.abs(this.mapState.size[0]/2-(isNaN(d[0])?-1/0:d[0]))),l=r.findIndex(d=>d===Math.min(...r));return a[l]}updatePosition(){const e=this.nearCenterScreenPosition();this.html.hidden=Number.isNaN(e[0]),this.rounder(e,e[0]+this.options.offset[0],e[1]+this.options.offset[1],this.mapState.stillness),this.mapState.globeMode&&(this.html.hidden=!this.modules.camera.ecef.canSee(this.getPosition())),n.equals$1(this.screenPoint,e)||(this.html.style.transform=`translate3d(${e[0]}px, ${e[1]}px, 0px)`,this.screenPoint=e)}updateLabelBox(){if(this.options.labeling.type==="none")return;const{labeling:{width:e,height:t},offset:i}=this.options;this.modules.labeler.removeLabels(this.labelKey),this.modules.labeler.addLabelBox(this.labelKey,{id:this.uniqId,width:e,height:t,position:this.position.normalizedValue,offset:i,labelingGroup:this.getLabelingGroup(),parentPoiId:this.options.labeling.type==="pinnedToPoi"?this.options.labeling.poiId:void 0})}getLabelingGroup(){return this.isInvolvedInLabeling()?"markerText":"htmlLabel"}checkZoom(){const{zoom:e}=this.mapState,{minZoom:t,maxZoom:i}=this.options;return e>=t&&e<i}checkFog(){if(!this.modules.environmentManager.isFogEnabled()||this.mapState.globeMode)return!0;const{fogLimits:e}=this.modules.environmentManager,{fogDistance:t,position:i}=this.modules.camera,o=(this.position.normalizedValue[0]-i[0])/t,a=(this.position.normalizedValue[1]-i[1])/t,r=Math.sqrt(qe(o,2)+qe(a,2)),l=e[1]-e[0];return n.clamp((r-e[0])/l,0,1)<this.fogFactorBreakpoint}isInvolvedInLabeling(){return this.options.labeling.type==="full"||this.options.labeling.type==="pinnedToPoi"}},Kt.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:""},Kt);function ug(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 hg(s){return s?fg:mg}const fg=(s,e,t,i)=>{const o=Math.round(e),a=Math.round(t),r=o-e,l=a-t;s[0]=e+i*r,s[1]=t+i*l},mg=(s,e,t)=>{s[0]=e,s[1]=t},pg="#0085a0",vg="#ffffff",gg=4,yg=1,xg=2,bg=1.5,wg=2.8,bl=6,Sg=!0,Tg=17.1,us=n.entranceAnimation.iterationCount,hs=n.create$1();class fs extends Ye{constructor(e,t){var p,v,x,g,y,b,T,S,L,E,R,H,V;super(e,{interactive:(p=t.interactive)!=null?p:!1}),this.options=t,this.vectors=this.options.coordinates.map(P=>P.map(F=>n.Mercator.fromGeo(F))),this.bouncePosition=0,this.growPosition=1;const{tileManager:i,dynamicStyle:o,collector:a,layers:r}=this.modules,l=(v=this.options.animate)!=null?v:Sg;let c;if(l&&!this.mapState.disableLayerAnimation){const P=(x=this.options.iterationCount)!=null?x:us;P>1?c={type:"repeat",tipMovementAmplitude:this.options.tipMovementAmplitude||bl,iterationCount:P}:P===1&&(c={type:"appearance",tipMovementAmplitude:this.options.tipMovementAmplitude||bl})}const d=n.makeHandyStyleLayer({type:"arrow",id:`dynamic-entrance-${this.uniqId}`,interactive:this.interactive,minzoom:(g=this.options.minZoom)!=null?g:Tg,maxzoom:this.options.maxZoom,style:{color:(y=this.options.color)!=null?y:pg,strokeColor:(b=this.options.borderColor)!=null?b:vg,lineWidth:(T=this.options.width)!=null?T:gg,strokeWidth:(S=this.options.borderWidth)!=null?S:yg,tipWidth:(L=this.options.wingWidthMultiplier)!=null?L:bg,tipHeight:(E=this.options.tipHeightMultiplier)!=null?E:wg,roundingRadius:(R=this.options.roundingRadius)!=null?R:xg,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 P=0;P<this.vectors.length;P++){const F=this.vectors[P],se=this.getVertices(F,_);h.id=String(P),n.generateSafely({collector:a,generator:n.ArrowGenerator.generate,args:[o.getStyle().id,d,h,se]})}const f=a.getAccumulatedData(),m=new n.TileObject("dynamicObject",f.data,this.modules,this.mapState,_.coords,this);this.tileObjects.push(m),i.addObject(m),this.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:(P,F)=>this.bouncePosition=F,complete:()=>{this.bounceTickerUpdate=void 0}},this.mapState),this.growTickerUpdate=n.update.bind(null,this.growTickerId,{step:(P,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,(H=this.options.iterationCount)!=null?H:us,{layerId:this.layerId,styleId:o.getStyle().id}),n.start(this.growTickerId,{easing:n.entranceAnimation.growType},this.mapState,0,1,n.entranceAnimation.growTime,(V=this.options.iterationCount)!=null?V:us,{layerId:this.layerId,styleId:o.getStyle().id})):(this.bouncePosition=0,this.growPosition=1),r.addLayer(this),a.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 a=0;a<e.length;a++)n.mapPointToTilePoint(hs,e[a],t),i[a]=hs[0],o[a]=hs[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 Mg{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 _s)}entranceAnimationFinished(){return this.layers.every(e=>e instanceof fs?!e.entranceAnimationInProgress():!0)}}const wl=()=>"",Eg=[.5,.5];class Ig{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 a=this.getKey(e,i,o),r=this.getFromCache(a,t);if(r)return r;const l=yield this.loadIcon(e,t,i,o);return l&&this.storeInCache(l,a,t),l})}clear(){this.cache={}}decreaseLoadingCounter(){this.loadingCounter=Math.max(this.loadingCounter-1,0)}loadIcon(e,t,i,o){return K(this,null,function*(){const{dynamicStyle:a,workers:r,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]]:Eg,u=[i[0]*window.devicePixelRatio,i[1]*window.devicePixelRatio],h=n.createLoadedRasterSet([{w:u[0],h:u[1],x:0,y:0,atlasIndex:0,isPacked:!1,anchorX:_[0],anchorY:_[1]}]);a.appendRasterSet(h),r.labeling.addNewRasterSets(a.getStyle().id,[h]);const f=new Uint16Array(3);return f[0]=u[0],f[1]=u[1],f[2]=h.index,r.parser.packRasters(f).then(m=>({packedRasters:m.packedRasters,rasterSet:h,scaledSize:u}))}).then(_=>{const{packedRasters:u,rasterSet:h,scaledSize:f}=_;return u!==void 0&&l.prepareRasters(a.getStyle().id,u,[Nr(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||wl)}storeInCache(e,t,i){this.cache[t]||(this.cache[t]=new Map),this.cache[t].set(i||wl,e)}getKey(e,t,i){const o=t!==void 0?`${t[0]},${t[1]}`:"",a=i!==void 0?`${i[0]},${i[1]}`:"";return`${e}_${o}_${a}`}loadImage(e){return new Promise(t=>{const i=new Image;i.crossOrigin="Anonymous",i.src=e,i.onload=()=>t(i),i.onerror=()=>t(void 0)})}loadImageForTransformer(e){return e.indexOf(".svg")===-1?new Promise(t=>{const i=new Image;i.crossOrigin="Anonymous",i.src=e,i.onload=()=>{t({type:"raster",source:i})},i.onerror=()=>{t({type:"unknown"})}}):new Promise(t=>{const i=new XMLHttpRequest;i.open("GET",e,!0),i.onload=function(){if(i.status!==200||i.response.byteLength===0){t({type:"unknown"});return}t({type:"vector",source:i.response})},i.onerror=function(){t({type:"unknown"})},i.send()})}}const Sl={trafficOn:!1,parkingOn:!1,navigatorOn:!1,immersiveRoadsOn:!1,floorStackOn:!1,terrainEnabled:!1,graphicsPreset:Yt()?"light":"immersive",_activeFloorIds:[],_activeFloorBuildingIds:[],_activeFloorIsMetro:!1,_floorHeight:3.5,_customUserTimeOffset:0};let Fn=!1;function Cg(){return I({},Sl)}function Dn(s,e){return s=I({},s),(e==null?void 0:e.immersiveRoadsOff)===!0?(Fn=!0,s.immersiveRoadsOn=!1):Fn&&(s.immersiveRoadsOn=Fn,Fn=!1),s.graphicsPreset&&s.graphicsPreset!=="light"&&Yt()&&(console.warn(`"${String(s.graphicsPreset)}" graphicsPreset is not supported in deprecated system. Using "light" instead.`),s.graphicsPreset="light"),I(I({},Sl),s)}function Tl(s,e,t){const i=ce(I(I({},s),e),{_activeFloorIds:s._activeFloorIds,_activeFloorBuildingIds:s._activeFloorBuildingIds,_activeFloorIsMetro:s._activeFloorIsMetro,_floorHeight:s._floorHeight});return Dn(i,t)}function Ml(s,e=[],t=[],i=!1){return ce(I({},s),{_activeFloorIds:e,_activeFloorBuildingIds:t,_activeFloorIsMetro:i})}const El=["default","metro"],ms="floorStackTicker",Pg=500,On={MAX_DISTANCE_METERS:500,VERY_CLOSE_DISTANCE_METERS:500,DISTANCE_WEIGHT_MULTIPLIER:3,VERY_CLOSE_BONUS:1.5};class Lg{constructor(e,t){this.state=e,this.modules=t,this.repository={descriptors:{default:new Map,metro:new Map},requestedFloors:new Set,failedRequestedFloors:new Set,floorIdsToObjectIds:new Map},this.stateDiffer=new n.Differ([{path:"center",type:"vec2"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"}]),this.stack={readiness:0,offsets:new Map,maxOffset:1},this.viewport={index:{metro:n.rbush(),default:n.rbush()},metro:{in:null,current:null,out:null},default:{in:null,current:null,out:null}},this.displayedComplex=null,this.needUpdate=!1,this.allowedFloors=new Set,this.hiddenObjectIds=new Set,this.pendingUpdateCall=!1,this.ids={default:t.identifier.getIdScope(n.DEFAULT_ID_SCOPE),floor:t.identifier.getIdScope(n.FLOOR_ID_SCOPE)};const i=n.throttle(this._update.bind(this),60);this.prevStyleState=this.state.styleState,this.update=()=>{this.updateReadiness();const o=this.needUpdate||this.stateDiffer.check(this.state);o&&(this.pendingUpdateCall=!0,i()),(o||this.prevStyleState!==this.state.styleState)&&(this.updateStyleState(),this.prevStyleState=this.state.styleState),o&&this.updateHiddenIds()}}get maxFloorOffset(){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 isStackEnabled(){return!this.state.demMode&&this.state.styleState.floorStackOn&&this.floorHeight>0}get shouldIgnoreFloorState(){return!!this.state.resetFloorModeOnActivation}get hiddenBuildingIds(){if(!this.displayedComplex||this.displayedComplex.mode==="building"||this.activeFloorIdx===void 0)return[];const e=this.displayedComplex.floors[this.activeFloorIdx];if(!e)return[];const t=[];if(e.id&&t.push(this.displayedComplex.id),!e.linked_floors_ids)return t;const i=this.repository.descriptors.default.has(this.displayedComplex.id)?"default":"metro";return this.displayedComplex.buildings.filter(o=>{const a=this.repository.descriptors[i].get(o);return e.linked_floors_ids.some(r=>a==null?void 0:a.floorIds.includes(r))}).forEach(o=>t.push(o)),t}getActiveFloorHiddenIds(){const e=this.ids.default.getRelatedChildrenIds(this.hiddenObjectIds);return Array.from(this.hiddenObjectIds).concat(e)}prepareFloors(e,t,i,o){o==="zenith"&&i.forEach((a,r)=>{let l=this.repository.floorIdsToObjectIds.get(r);l===void 0&&(l=new Set,this.repository.floorIdsToObjectIds.set(r,l));for(const c of a)l.add(c);this.loadFloor(r,e,t)})}changeFloorNumber(e,t){var r;const i=this.viewport.default.current,o=this.viewport.metro.current,a=i||o;if(a&&(a.id===e||a.buildings.includes(e)))if(this.needUpdate=!0,t==="metro"){if(!o)return;o.mode="metro",this.displayedComplex&&this.modules.map.emit("floorcomplexhide",{id:this.displayedComplex.id}),this.displayedComplex=o,this.setFloorIdx(o.defaultFloor),this.modules.map.emit("floorcomplexshow",{id:o.id,mode:"metro",currentFloor:o.defaultFloor,floorNames:o.floors.map(l=>l.name),firmsToFloorIndexMap:o.firmsToFloorIndexMap})}else if(t==="building")o&&(o.mode="floor"),a.mode="building",this.displayedComplex=null,this.modules.map.emit("floorcomplexhide",{id:e});else{if(t<0||t>=a.floors.length)return;this.setFloorIdx(t),a.selectedFloorIdx=t,o&&o.mode==="metro"&&(o.mode="floor",this.modules.map.emit("floorcomplexhide",{id:o.id})),this.displayedComplex!==a&&!((r=this.displayedComplex)!=null&&r.buildings.includes(a.id))&&this.modules.map.emit("floorcomplexshow",{id:a.id,mode:"floor",currentFloor:t,floorNames:a.floors.map(({name:l})=>l),firmsToFloorIndexMap:a.firmsToFloorIndexMap}),this.displayedComplex=a,this.updateStackState(),a.mode="floor",this.modules.map.emit("floorcomplexlevelchange",{id:e,floorIndex:t,floorName:a.floors[t].name})}}hasDisplayedFloorBuilding(e){if(!this.displayedComplex||this.displayedComplex.mode==="building")return!1;for(const t of this.hiddenBuildingIds){const i=this.repository.floorIdsToObjectIds.get(t);if(i&&(Array.isArray(e)&&e.some(o=>i.has(o))||typeof e=="string"&&i.has(e)))return!0}return!1}floorsReady(){return!this.pendingUpdateCall&&Array.from(this.repository.requestedFloors).every(e=>this.repository.failedRequestedFloors.has(e)||this.repository.descriptors.default.has(e)||this.repository.descriptors.metro.has(e))}setAllowedFloorIds(e){this.allowedFloors=new Set(e!=null?e:[]),this.needUpdate=!0}isVisibleFloorObject(e){return this.displayedComplex?this.state.styleState._activeFloorIds.includes(e):!1}isVisibleFloorStackObject(e){if(!this.isStackEnabled||!this.displayedComplex||this.activeFloorIdx===void 0)return!1;let t=!1;for(const a of this.hiddenBuildingIds){if(t)break;const r=this.repository.descriptors.default.get(a);t=!!(r!=null&&r.floors.some(l=>l.id===e))}if(!t)return!1;const i=this.activeFloorIdx-this.displayedComplex.defaultFloor,o=this.stack.offsets.get(e);return o<this.maxFloorOffset&&i>0&&o>=0&&o<i}getFloorObjectElevation(e,t){if(!this.isStackEnabled||!this.stack.offsets.has(e))return 0;const i=this.stack.offsets.get(e),o=this.floorHeight*i;return i<=0?0:i>this.maxFloorOffset?this.floorHeight*this.maxFloorOffset:t?o:n.lerp$2((i-1)/i,1,this.stack.readiness)*o}getFloorStackObjectElevation(e){return this.stack.offsets.has(e)?this.stack.offsets.get(e)*this.floorHeight:0}getFloorsStackObjectOffsets(e){return this.stack.offsets.has(e)?{current:this.stack.offsets.get(e),total:this.stack.maxOffset}:{current:0,total:1}}getPlanLevels(){return this.isStackEnabled?Object.fromEntries(this.stack.offsets):{}}getFloorStackObjectHeight(e){return!this.isStackEnabled||this.displayedComplex.floors.findIndex(i=>{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,a=this.viewport.metro.in||this.viewport.metro.current,r=!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)})}if(a){if(i){i.metro={id:a.id,floorNames:a.floors.map(c=>c.name)};for(const c in a.firmsToFloorIndexMap)i.firmsToFloorIndexMap[c]=a.firmsToFloorIndexMap[c];a.mode==="metro"&&(i.mode="metro")}else i={id:a.id,mode:"building",currentFloor:a.defaultFloor,floorNames:[],firmsToFloorIndexMap:a.firmsToFloorIndexMap,metro:{id:a.id,floorNames:a.floors.map(c=>c.name)}};(this.shouldIgnoreFloorState?"building":a.mode)==="metro"&&(i.mode="metro")}i&&r&&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(a=>{if(a.ok===!1)throw new Error(a.statusText);return a.json()}).then(a=>{var _;let r=a.default_floor_idx,l="default";"is_metro"in a&&a.is_metro&&(r=a.default_metro_floor_idx,l="metro");const c=a.floors.reduce((u,h,f)=>(h.id&&(u[h.id]=f),u),{}),d={id:e,regionId:t,metatileHash:i,center:a.center,bound:a.bound,defaultFloor:r,selectedFloorIdx:r,mode:"floor",floors:a.floors,floorIds:a.floors.map(u=>u.id).filter(Boolean),buildings:a.linked_buildings_ids?a.linked_buildings_ids.concat(e):[e],firmsToFloorIndexMap:Object.entries((_=a.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 a;const o=i-this.displayedComplex.defaultFloor;t.id&&this.stack.offsets.set(t.id,o),o>e&&(e=o),(a=t.linked_floors_ids)==null||a.forEach(r=>{this.stack.offsets.set(r,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=Ml(e,[],[],!1));return}const t=new Set,i=new Set,o=new Set(this.state.styleState._activeFloorIds),a=new Set(this.state.styleState._activeFloorBuildingIds),r=e._activeFloorIsMetro===!0,l=this.displayedComplex;if(!l||this.activeFloorIdx===void 0||l.mode==="building")return;const c=l.floors[this.activeFloorIdx];c&&(c.id&&t.add(c.id),(d=c.linked_floors_ids)==null||d.forEach(_=>{t.add(_)}),this.hiddenBuildingIds.forEach(_=>i.add(_)),(Il(o,t)||Il(a,i)||r!==(this.displayedComplex.mode==="metro"))&&(this.state.styleState=Ml(e,Array.from(t),Array.from(i),this.displayedComplex.mode==="metro")))}updateHiddenIds(){if(!this.displayedComplex){this.markHiddenObjectsForUpdate();return}const e=new Set;this.hiddenBuildingIds.forEach(t=>{const i=this.repository.floorIdsToObjectIds.get(t);i&&i.forEach(o=>e.add(o))}),this.markHiddenObjectsForUpdate(e)}markHiddenObjectsForUpdate(e){if(e){const t=this.ids.default.getHidden(n.HideLevel.PolygonExtrusion),i=n.subtract(e,t),o=n.subtract(this.hiddenObjectIds,e);this.ids.default.hide(Array.from(i),n.HideLevel.PolygonExtrusion);const a=this.ids.floor.getHidden(),r=n.intersection$1(i,a);this.ids.default.hide(Array.from(r),n.HideLevel.All),this.ids.default.show(Array.from(o)),this.hiddenObjectIds=new Set(e)}else this.ids.default.show(Array.from(this.hiddenObjectIds)),this.hiddenObjectIds.clear()}updateReadiness(){n.update(ms,{step:(e,t)=>this.stack.readiness=t},this.state)}setFloorIdx(e){this.prevActiveFloorIdx=this.activeFloorIdx,this.activeFloorIdx=e,!Number.isNaN(e)&&this.isStackEnabled&&this.prevActiveFloorIdx!==void 0&&this.activeFloorIdx>this.prevActiveFloorIdx?(this.stack.readiness=0,n.start(ms,{easing:"easeOutQuint"},this.state,0,1,Pg,1)):(this.stack.readiness=1,n.stop(ms,this.state))}updateViewport(){if(!this.isEnabled){this.viewport.default={in:null,current:null,out:this.viewport.default.current},this.viewport.metro={in:null,current:null,out:this.viewport.metro.current};return}const e={default:null,metro:null},{center:t,zoom:i,rotation:o,size:a,viewport:r,padding:l,cameraConfig:c,globeMode:d}=this.state,_=new n.Camera({center:t,zoom:i,rotation:o,size:[Math.floor(a[0]*(1-n.floors.viewportPadding)),Math.floor(a[1]*(1-n.floors.viewportPadding))],styleState:{},pitch:0,viewport:r,padding:l,cameraConfig:c,globeMode:d}),u=_.getViewportVertices().map(m=>[m[0],m[1]]),h=Bg(u),f=[[0,0],[0,0],[0,0],[0,0]];El.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))continue;const y=g.complex.bound;if(zg(_.position,y)){if(v){const S=Cl(y);S<v.complexArea&&(v.complex=g.complex,v.complexArea=S)}else v={complex:g.complex,complexArea:Cl(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=Rg(f,u);if(b.length<3)continue;const T=Dg({complex:g.complex,cameraPosition:_.position,intersectionPolygon:b});x?x.score<T&&(x.complex=g.complex,x.score=T):x={complex:g.complex,score:T}}v?e[m]=v.complex:x&&(e[m]=x.complex)}),El.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.setFloorIdx(t.defaultFloor),this.modules.map.emit("floorcomplexshow",{id:t.id,mode:"metro",currentFloor:t.defaultFloor,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 Il(s,e){if(s.size!==e.size)return!0;for(const t of s)if(!e.has(t))return!0;return!1}function Bg(s){let e=s[0][0],t=s[0][1],i=e,o=t;for(let a=1;a<s.length;a++){const[r,l]=s[a];r<e?e=r:r>i&&(i=r),l<t?t=l:l>o&&(o=l)}return{minX:e,minY:t,maxX:i,maxY:o}}function zg(s,e){return s[0]>=e.min[0]&&s[0]<=e.max[0]&&s[1]>=e.min[1]&&s[1]<=e.max[1]}function Cl(s){return(s.max[0]-s.min[0])*(s.max[1]-s.min[1])}function Rg(s,e){let t=s;for(let a=0;a<e.length;a++){const r=e[a],l=e[(a+1)%e.length],c=t;t=[];for(let d=0;d<c.length;d++){const _=c[d],u=c[(d+1)%c.length];i(u,r,l)?(i(_,r,l)||t.push(o(_,u,r,l)),t.push(u)):i(_,r,l)&&t.push(o(_,u,r,l))}}return t;function i(a,r,l){return(l[0]-r[0])*(a[1]-r[1])>(l[1]-r[1])*(a[0]-r[0])}function o(a,r,l,c){const d=r[1]-a[1],_=a[0]-r[0],u=d*a[0]+_*a[1],h=c[1]-l[1],f=l[0]-c[0],m=h*l[0]+f*l[1],p=d*f-h*_;return p===0?r:[(f*u-_*m)/p,(d*m-h*u)/p]}}function Fg(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 Dg(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/(On.MAX_DISTANCE_METERS*n.MAP_POINTS_IN_METER),i=Math.max(0,1-t),o=e<On.VERY_CLOSE_DISTANCE_METERS*n.MAP_POINTS_IN_METER?On.VERY_CLOSE_BONUS:1;return Fg(s.intersectionPolygon)*o*(1+i*On.DISTANCE_WEIGHT_MULTIPLIER)}class Og{constructor(e,t){this.state=e,this.modules=t,this.tileLayers=[],this.objects=[],this.viewportDiffer=new n.Differ([{path:"center",type:"vec3"},{path:"zoom",type:"number"},{path:"size",type:"vec2"},{path:"rotation",type:"number"},{path:"pitch",type:"number"},{path:"padding",type:"padding"},{path:"demMode",type:"boolean"},{path:"globeMode",type:"boolean"},{path:"elevation",type:"number"},{path:"minElevation",type:"number"},{path:"handyStyleId",type:"string"}])}getMemoryFootprint(e=()=>!0){const t={tileLayers:this.tileLayers.filter(e).map(o=>({[o.getSourceType()]:o.memSizeJs()})),objects:this.objects.filter(o=>o.purpose==="dynamicObject").map(o=>({[o.purpose]:n.tileObjectStatsJS(o)}))},i={tileLayers:this.tileLayers.filter(e).map(o=>({[o.getSourceType()]:o.memSizeGpu()})),objects:this.objects.filter(o=>o.purpose==="dynamicObject").map(o=>({[o.purpose]:n.tileObjectStatsGpu(o)}))};return{js: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"));for(const t of this.tileLayers)t.update();if(this.updateTickers(),e.collectStats){this.state.stats.tileCount=0;for(const t of this.tileLayers)this.state.stats.tileCount+=t.getTileCount();this.state.stats.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 Ng=(s,e,t,i,o)=>{n.start("labelingOpacity",{easing:e},s,t,i,o,1)},kg=n.update.bind(null,"labelingOpacity",{step:(s,e)=>s.labelingOpacity=e});function Ug(s){return s?Object.keys(s).map(Number).sort((e,t)=>e-t):[]}function Hg(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 Gg=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 Vg{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=Gg(this.modules.workers.fnRegistry),this.setLabelingInterval(n.labeling.interval)}disableThrottleUpdateOnce(){this.useThrottleUpdate=!1}update(){kg(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 r=n.getTileBounds(e),l=qe(2,e[2]),c=r.min[0]<-n.HALF_WORLD_SIZE,d=r.max[0]>n.HALF_WORLD_SIZE;if(c||d){const _=[...e];_[0]+=c?l:-l;const u=[...this.state.center];u[0]+=c?n.worldSize:-n.worldSize;const{min:h,max:f}=n.getTileBounds(_);t.push({coords:_,center:u,tilesBounds:[[h[0],h[1],0],[f[0],h[1],0],[f[0],f[1],0],[h[0],f[1],0]]})}}const i=this.modules.tileManager.getLabelingData(),o=t.map(({coords:r,center:l,tilesBounds:c})=>({center:l,elevation:this.state.elevation,zoom:this.state.zoom,styleZoom:this.state.styleZoom,rotation:this.state.rotation,size:this.state.size,pitch:this.state.pitch,viewport:this.state.viewport,padding:this.state.padding,globeMode:this.state.globeMode,styleState:this.state.styleState,buildingHeight:this.modules.buildingHeightAnimator.getDefaultBuildingHeight(),tilesBounds:c,debugLabels:this.modules.labelsDebug.isEnabled(),disableSurvivedPoiPrevalence:this.state.disableSurvivedPoiPrevalence,tileInfo:n.createTileInfo(r),cameraConfig:this.state.cameraConfig})),a=Hg(this.state.styleZoom,this.state.cityCommPoiLabeling);this.worker.processLabels(i,this.alwaysActiveLabelKeys,o,window.devicePixelRatio,this.modules.floorManager.getActiveFloorHiddenIds(),I(I({},n.labeling.commercialMargins),a),this.skipHysteresisInNextLabeling,this.modules.floorManager.getPlanLevels()).then(r=>{this.survivedLabelBoxes.clear(),this.labelTiles.forEach(h=>{this.modules.tileManager.removeObject(h),h.clean(this.state)}),this.labelTiles.length=0;const l=[];r.forEach((h,f)=>{h.survivedLabelBoxIds.forEach(p=>this.survivedLabelBoxes.add(p)),l.push(...h.survivedCommPois),this.modules.assetManager.loadRasters(h.collectorOutput.rastersToLoad);const m=new n.TileObject("labeling",h.collectorOutput.data,this.modules,this.state,t[f].coords,void 0,void 0);this.labelTiles.push(m),this.modules.tileManager.addObject(m)}),this.processSurvivedCommPoiIds(l),this.labelTileRevision++;const c=this.state.metrics;c.firstlabeling===void 0&&r.some(({collectorOutput:h})=>h.data.length>0)&&(c.firstlabeling=performance.now()-c.start);const{animationTime:d,animationType:_,interval:u}=n.labeling;Ng(this.state,_,0,1,Math.min(d,u)),this.modules.renderer.addRerenderEvent(),r[0].labels&&e[2]>=0&&this.modules.labelsDebug.drawLabels(r[0].labels),this.isLabelingInProgress=!1}),this.skipHysteresisInNextLabeling=!1}processSurvivedCommPoiIds(e){if(e.length===0){this.prevSurvivedCommPoiIds.clear();return}const t=e.filter(i=>!this.prevSurvivedCommPoiIds.has(i.id));t.length!==0&&this.modules.map.emit("commpoishow",{commPois:t}),this.prevSurvivedCommPoiIds=new Set(e.map(i=>i.id))}enrichWithElevation(e,t){const{demManager:i,map:o}=this.modules;if(o.state.demMode){const a=this.demKeys[t],r=i.getLabelsDemKey(e);if(r===void 0||r===a)return;i.enrichWithElevation(e),this.demKeys[t]=r}}}class ci{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=Ie(this.handler.container,e.clientX,e.clientY);return new Pl(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=Ie(this.handler.container,e.clientX,e.clientY);return this.handler.modules.identifier.search("contextmenu",t,!0).then(i=>{gt("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 Nn(this.mouseDownPoint,this.handler)):this}returnToInitialState(){return this.handler.mapState.userHasInteracted=!0,this.handler.modules.map.emit("interactionend",{target:"pitch/rotation"}),new ot(this.handler)}}class Pl{constructor(e,t,i,o){this.type=e,this.mouseDownPoint=t,this.mouseMovePoint=i,this.handler=o,this.handler.mapState.userHasInteracted=!0,(!this.handler.mapState.disablePitchByUserInteraction||!this.handler.mapState.disableRotationByUserInteraction)&&this.handler.container.classList.add("mapgl-rotating"),this.update(this.handler.mapState)}processAction(e){switch(e.type){case"mousemove":return this.processMouseMoveAction(e);case"mouseleave":return this.returnToInitialState();case"mouseup":return this.processMouseUpAction(e);case"keyup":return this.processKeyUpAction(e);default:return this}}update(e){this.mouseDownPoint[0]===0&&this.mouseDownPoint[1]===0&&(this.mouseDownPoint=this.mouseMovePoint);const t=n.normalizeMousePosition(e.size,this.mouseDownPoint),i=n.normalizeMousePosition(e.size,this.mouseMovePoint),o=(t[0]-i[0])*n.zoom.mouseRotateDelta,a=(i[1]-t[1])*n.zoom.mousePitchDelta;yt(e),e.disableRotationByUserInteraction||mi(e,e.rotation+o,{animate:!1}),e.disablePitchByUserInteraction||Zi(e,n.clamp(e.pitch+a,e.minPitch,e.maxPitch),{animate:!1}),this.mouseDownPoint=this.mouseMovePoint,this.handler.modules.renderer.addRerenderEvent()}processMouseMoveAction(e){return this.mouseMovePoint=Ie(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 Nn(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 ot(this.handler)}}class Nn{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 ot(this.handler)):this}processMouseMoveAction(e){const t=Ie(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 Ll(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=Ie(this.handler.container,e.clientX,e.clientY);yt(t),Et(t,i,{duration:n.zoom.animDuration,zoomPoint:t.keepCenterWhileUserZoomRotate?void 0:o}),this.handler.modules.renderer.addRerenderEvent()}}else{const t=Ie(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(()=>{gt("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 ot(this.handler)}processKeyDownAction(e){return e.key==="Control"||e.key==="Meta"?(this.handler.modules.map.emit("interactionend",{target:"center"}),new ci("keyPrimary",this.mouseDownPoint,this.handler)):this}}class Ll{constructor(e,t,i){this.mouseMovePoint=e,this.dragStartPoint=t,this.handler=i,this.handler.container.classList.add("mapgl-dragging"),this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState)}processAction(e){switch(e.type){case"mousemove":return this.processMouseMoveAction(e);case"mouseup":return this.processMouseUpAction(e);case"keydown":return this.processKeyDownAction(e);default:return this}}update(e){const t=this.handler.modules.camera,i=t.flat.unproject(this.dragStartPoint),o=t.flat.unproject(this.mouseMovePoint);if(e.globeMode){const r=n.adjustGlobeDragSpeed(t.globeRatio,n.Mercator.toGeo(e.center));n.scale(i,i,r),n.scale(o,o,r)}const a=n.clone$1(e.center);n.add$1(a,a,i),n.sub$1(a,a,o),yt(e),kt(e,a,{animate:!1}),this.dragStartPoint=this.mouseMovePoint,this.handler.modules.renderer.addRerenderEvent()}processMouseMoveAction(e){return this.mouseMovePoint=Ie(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 ci("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 ot(this.handler)}}class Bl{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 di(e,this.handler,!1)}processTouchMoveAction(e){return e.preventDefault(),this.touchMovePoints=dt(e.touches,this.handler.container),this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState),this}processTouchEndAction(e){return this.handler.container.classList.remove("mapgl-rotating"),this.handler.modules.map.emit("interactionend",{target:"pitch/zoom/rotation"}),e.touches.length===0?(this.handler.mapState.userHasInteracted=!0,new ot(this.handler)):new di(e,this.handler,!1)}}class kn extends Bl{constructor(e,t,i){super(e,t,i),this.startPxAngle=0,this.rotationDetected=!1,t.length>1&&(this.startPxAngle=n.calcAngle(t[0],t[1]))}update(e){if(this.touchStartPoints.length<2||this.touchMovePoints.length<2)return;const t=n.calcMidpoint(this.touchMovePoints[0],this.touchMovePoints[1]),i=n.dist(this.touchMovePoints[0],this.touchMovePoints[1]),o=n.dist(this.touchStartPoints[0],this.touchStartPoints[1]),a=i/o,r=e.zoom+Math.log(a)/Math.log(2)*n.zoom.mobilePinchDelta;let l=0,c=0;if(!this.rotationDetected){const u=n.calcAngle(this.touchMovePoints[0],this.touchMovePoints[1]);c=Math.abs(this.startPxAngle-u),c>Math.PI&&(c=2*Math.PI-c),c>=this.handler.mapState.touchRotationThreshold&&(this.rotationDetected=!0)}if(this.rotationDetected){const u=this.handler.modules.camera.flat.unproject(this.touchStartPoints[0]),h=this.handler.modules.camera.flat.unproject(this.touchStartPoints[1]),f=this.handler.modules.camera.flat.unproject(this.touchMovePoints[0]),m=this.handler.modules.camera.flat.unproject(this.touchMovePoints[1]);if(u&&h&&f&&m){const p=n.calcAngle(u,h),v=n.calcAngle(f,m);l=p-v}}const d=e.rotation+l,_=e.center;e.keepCenterWhileUserZoomRotate||n.add$1(_,e.center,n.getCenterCorrection(e,t,{zoom:r,rotation:d})),yt(e),kt(e,_,{animate:!1}),Et(e,r,{animate:!1}),this.handler.mapState.disableRotationByUserInteraction||mi(e,d,{animate:!1}),this.touchStartPoints=this.touchMovePoints,this.handler.modules.renderer.addRerenderEvent()}}class zl extends Bl{constructor(e,t,i){super(e,t,i)}update(e){const t=this.touchStartPoints.map(l=>n.normalizeMousePosition(e.size,l)),i=this.touchMovePoints.map(l=>n.normalizeMousePosition(e.size,l)),o=n.calcMidpoint(t[0],t[1]),r=(n.calcMidpoint(i[0],i[1])[1]-o[1])*n.zoom.mousePitchDelta;yt(e),Zi(e,n.clamp(e.pitch+r,e.minPitch,e.maxPitch),{animate:!1}),this.touchStartPoints=this.touchMovePoints,this.handler.modules.renderer.addRerenderEvent()}}class di{constructor(e,t,i){this.handler=t,this.needClickOnTouchEnd=i,this.toZoomRotate=!1,this.touchStartPoints=dt(e.touches,this.handler.container),this.handler.mapState.userHasInteracted=!0,this.isTimerStarted=this.handler.dblClickTimer!==void 0,_t(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=dt(e.touches,this.handler.container),this}processTouchMoveAction(e){e.preventDefault();const t=dt(e.touches,this.handler.container);if(!_t(e))return n.distance(this.touchStartPoints[0],t[0])<n.events.dragThreshold?(this.touchStartPoints=t,this):this.isTimerStarted?new Rl(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 a=n.dot$1(i,o);if(a>0){if(this.handler.mapState.enableTwoFingerDragging&&this.touchStartPoints.length===2)return n.distance(this.touchStartPoints[0],t[0])<n.events.dragThreshold?(this.touchStartPoints=t,this):new 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 zl(t,this.touchStartPoints,this.handler)}return a<0?new kn(t,this.touchStartPoints,this.handler):n.isNullVector(i)||n.isNullVector(o)?this.pitchWaitingTimer?this:this.toZoomRotate?(this.toZoomRotate=!1,new kn(t,this.touchStartPoints,this.handler)):(this.pitchWaitingTimer=window.setTimeout(()=>{this.toZoomRotate=!0,this.pitchWaitingTimer=void 0},n.events.pitchWaitingTime),this):new kn(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 ot(this.handler)):(_t(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=dt(e.touches,this.handler.container),this)}processTouchClickAction(e,t){if(this.isTimerStarted){if(this.handler.mapState.zoom<this.handler.mapState.maxZoom){const i=this.handler.mapState,o=Math.min(i.zoom+1,i.maxZoom),a=i.keepCenterWhileUserZoomRotate?void 0:e;yt(i),Et(i,o,{duration:n.zoom.animDuration,zoomPoint:a}),this.handler.modules.renderer.addRerenderEvent()}}else if(this.handler.modules.layout.isActionWithCanvas(t))this.handler.modules.identifier.search("mouseClick",e,!0).then(i=>{this.handler.dblClickTimer||(this.handler.dblClickTimer=window.setTimeout(()=>{gt("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 ot(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 r=n.adjustGlobeDragSpeed(t.globeRatio,n.Mercator.toGeo(e.center));n.scale(i,i,r),n.scale(o,o,r)}const a=n.clone$1(e.center);n.add$1(a,a,i),n.sub$1(a,a,o),yt(e),kt(e,a,{animate:!1}),this.touchStartPoint=this.touchMovePoint,this.handler.modules.renderer.addRerenderEvent()}processTouchStartAction(e){return this.handler.container.classList.remove("mapgl-dragging"),this.handler.modules.map.emit("interactionend",{target:"center"}),new di(e,this.handler,!1)}processTouchMoveAction(e){e.preventDefault();const t=dt(e.touches,this.handler.container);return this.touchMovePoint=t[0],this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState),this}processTouchEndAction(){return this.handler.container.classList.remove("mapgl-dragging"),this.handler.modules.map.emit("interactionend",{target:"center"}),this.handler.mapState.userHasInteracted=!0,new ot(this.handler)}}class Rl{constructor(e,t,i){this.handler=i,this.mapHeight=i.mapState.size[1],this.startZoom=i.mapState.zoom,this.touchMovePointY=e[1],this.touchStartPoint=t,this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState)}processAction(e){switch(e.type){case"touchstart":return this.processTouchStartAction(e);case"touchmove":return this.processTouchMoveAction(e);case"touchend":return this.processTouchEndAction();default:return this}}update(e){const t=this.touchMovePointY-this.touchStartPoint[1];if(t===0)return;const i=t/this.mapHeight,o=n.clamp(this.startZoom+i*n.zoom.mobileTapDelta,e.minZoom,e.maxZoom),a=e.center;e.keepCenterWhileUserZoomRotate||n.add$1(a,e.center,n.getCenterCorrection(e,this.touchStartPoint,{zoom:o})),yt(e),kt(e,a,{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 di(e,this.handler,!1)}processTouchMoveAction(e){e.preventDefault();const t=dt(e.touches,this.handler.container);return this.touchMovePointY=t[0][1],this.handler.mapState.userHasInteracted=!0,this.update(this.handler.mapState),this}processTouchEndAction(){return this.handler.modules.map.emit("interactionend",{target:"zoom/rotation"}),this.handler.mapState.userHasInteracted=!0,new ot(this.handler)}}class ot{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=Ie(this.handler.container,e.clientX,e.clientY);switch(e.button){case 0:if(e.ctrlKey||e.metaKey)return new ci("keyPrimary",t,this.handler);if(this.handler.modules.layout.isActionWithCanvas(e)){const i=this.handler.modules.identifier.searchSync(t);gt("mousedown",i,e,t,this.handler.modules)}return new Nn(t,this.handler);case 1:return new ci("auxiliary",t,this.handler);case 2:return new ci("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=Ie(this.handler.container,e.changedTouches[0].clientX,e.changedTouches[0].clientY),i=this.handler.modules.identifier.searchSync(t);gt("touchstart",i,e,t,this.handler.modules)}return new di(e,this.handler,e.touches.length===1)}}class Un{processAction(){return this}}class jg{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 Un||(this.state=o)},this.state=new ot(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 Un)return;const{map:e}=this.modules;switch(this.container.classList.remove("mapgl-dragging"),this.container.classList.remove("mapgl-rotating"),this.state.constructor){case Nn:case Ll:case ps:e.emit("interactionend",{target:"center"});break;case ci:case Pl:e.emit("interactionend",{target:"pitch/rotation"});break;case Rl:e.emit("interactionend",{target:"zoom/rotation"});break;case kn:case zl:e.emit("interactionend",{target:"pitch/zoom/rotation"});break;case di:{const t=this.state.getStartedInteractionTarget();e.emit("interactionend",{target:t});break}}this.state=new Un}unblock(){this.state instanceof ot||this.state instanceof Un&&(this.state=new ot(this))}}const Zg=new Set([n.UNIVERSE_REGION_ID]);class vs extends Error{constructor(e,t){super(e),this.name="TrafficFetchMetaError",this.noRetry=t}}class Wg{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=>$g(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,Zg)){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 vs(`Request traffic timestamp error with status ${i.status}`,!1)}).then(i=>{var a,r;if(!i.length||((a=i[0])==null?void 0:a.time)===void 0||((r=i[0])==null?void 0:r.score)===void 0)throw new vs(`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 vs)||!i.noRetry?this.fetchMetaRetryAttempt=(o=this.fetchMetaRetryAttempt)!=null?o:0:this.fetchMetaRetryAttempt=null,this.lastUpdateTime=Date.now(),this.isMetaLoading=!1,console.error(i)})}}function $g(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 Xg{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 Kg{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 Sn(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,a=(m=t==null?void 0:t.imagePadding)!=null?m:1;this.decreaseLoadingCounter();const r=e.getAttribute("src")||e.currentSrc,l=qg(r,i),c=this.textureKeys.indexOf(l);if(c>-1&&this.texturesMap.has(l))return c;const d=(i?[i[0],i[1]]:[e.width,e.height]).map(b=>b*o),_=Nr(e,d);e.remove();const u=d.map(b=>b+2*a);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(_,a,a),_.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 qg(s,e){const t=e!==void 0?`_${e[0]},${e[1]}`:"";return`${s}${t}`}const Fl=!0,Dl=!1,Ol=!1,Nl=[0];class Yg{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 a=()=>K(this,null,function*(){return Nl.length>=this.attempts?(this.attempts&&(yield new Promise(r=>{this.lastTimeout=window.setTimeout(r,Nl[this.attempts]*1e3)}),this.clearLastTimeout()),this.attempts++,fetch(o).then(r=>r.ok?r.json():a(),a)):(console.error("Could not load tile key info. A style layers with commercial POI will be added to applied styles."),Promise.resolve(void 0))});this.request=a().then(r=>{if(this.isLoading=!1,!r||!r.result||r.meta.code!==200)return{showCommPoi:Fl,hideCopyright:Ol,urbi:Dl,error:!0};const{showCommPoi:l,hideCopyright:c,urbi:d}=r.result.service.properties.public;return{showCommPoi:n.isNullish(l)?Fl:!!l,hideCopyright:n.isNullish(c)?Ol:!!c,urbi:n.isNullish(d)?Dl:!!d}})}}destroy(){this.clearLastTimeout()}clearLastTimeout(){this.lastTimeout!==void 0&&(clearTimeout(this.lastTimeout),this.lastTimeout=void 0)}}class Qg{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 Jg={dead:!0,alive:!0,unused:!0,commercialDead:!1,commercialAlive:!1};class Ag{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=Jg){this.options=e,Object.values(e).every(i=>i===!1)?this.hide():(this.createCanvas(),this.mapState.needLabeling=!0)}hide(){this.canvas&&(this.modules.layout.mapContainer.removeChild(this.canvas),this.ctx=void 0,this.canvas=void 0)}drawLabels(e){if(!this.canvas||!this.ctx)return;const t=this.ctx,i=this.options,o={[n.BBoxType.Dead]:"#ff0000",[n.BBoxType.Alive]:"#30763c",[n.BBoxType.Unused]:"#aaa",[n.BBoxType.CommercialAlive]:"#3a9f22",[n.BBoxType.CommercialDead]:"#ff0000"},a=new Int32Array(e),r={[n.BBoxType.Dead]:[],[n.BBoxType.Alive]:[],[n.BBoxType.Unused]:[],[n.BBoxType.CommercialAlive]:[],[n.BBoxType.CommercialDead]:[]};for(let d=0;d<a.length;d+=5){const _=a[d+4];r[_].push({x:a[d],y:a[d+1],width:a[d+2],height:a[d+3]})}this.clear();const l=window.devicePixelRatio,c=d=>{t.strokeStyle=o[d],r[d].forEach(_=>t.strokeRect(_.x*l+.5,_.y*l+.5,_.width*l,_.height*l))};t.setLineDash([]),i.unused&&c(n.BBoxType.Unused),i.dead&&c(n.BBoxType.Dead),i.alive&&c(n.BBoxType.Alive),t.setLineDash([6]),i.commercialDead&&c(n.BBoxType.CommercialDead),i.commercialAlive&&c(n.BBoxType.CommercialAlive)}clear(){if(this.canvas&&this.ctx){const{clientWidth:e,clientHeight:t}=this.canvas;this.ctx.clearRect(0,0,e*window.devicePixelRatio,t*window.devicePixelRatio)}}createCanvas(){this.canvas||(this.canvas=document.createElement("canvas"),this.canvas.style.position="absolute",this.canvas.style.left="0",this.canvas.style.top="0",this.canvas.style.pointerEvents="none",this.modules.layout.mapContainer.appendChild(this.canvas),this.ctx=this.canvas.getContext("2d")||void 0,this.updateSize())}updateSize(){if(!this.canvas)return;const{clientWidth:e,clientHeight:t}=this.modules.layout.rootContainer;this.canvas.width=e*window.devicePixelRatio,this.canvas.height=t*window.devicePixelRatio,this.canvas.style.width=e+"px",this.canvas.style.height=t+"px"}}const ey=n.create$1();class ty{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=F_(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(Ne);const e=this.modules.renderer.getShaderProgram("sky");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||(As(e,this.modules.map.state,this.modules),W(e,this.modules.map.state,this.modules),$(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(Ne);const e=this.modules.renderer.getShaderProgram("stars");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||ea(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(Ne);const e=this.modules.renderer.getShaderProgram("globeHaloBackground");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||ro(e,this.modules.map.state,this.modules),this.modules.renderer.bindVao(this.vao),this.modules.renderer.drawTrianglesFan(0,4)}renderGlobeHalo(){this.modules.renderer.applyGpuState(Z_);const e=this.modules.renderer.getShaderProgram("globeHalo");this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||ro(e,this.modules.map.state,this.modules),this.modules.renderer.bindVao(this.vao),this.modules.renderer.drawTrianglesFan(0,4)}isFogEnabled(){var a,r;if(this.modules.map.getFeatureFlag("fogOff")||!((a=this.envStyleLayer)!=null&&a.style.fogColor))return!1;const{styleZoom:e,styleState:t}=this.modules.map.state,i=n.makeBinderContext(e,t,[]),o=n.resolveColor((r=this.envStyleLayer)==null?void 0:r.style.fogColor,i);return o&&o.value[3]!==0}isSkyEnabled(){var a,r;if(this.modules.map.getFeatureFlag("skyOff")||!((a=this.envStyleLayer)!=null&&a.style.skyColor))return!1;const{styleZoom:e,styleState:t}=this.modules.map.state,i=n.makeBinderContext(e,t,[]),o=n.resolveColor((r=this.envStyleLayer)==null?void 0:r.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,ey);return this.isPointInFog(i)}updateSky(){const e=this.modules.styleManager.getStyleLayer(this.modules.map.state.handyStyleId,n.ENVIRONMENT_STYLE_LAYER_ID);this.envStyleLayer=e}updateStars(){if(!this.starsUpdateNeeded)return;this.starsUpdateNeeded=!1;const e=n.generatePointsOnSphere(this.starsGenerationCtx,this.starsCount),t=4,i=new Float32Array(t*e.length);for(let r=0;r<e.length;++r){const l=e[r],c=n.getRandomValue(this.starsGenerationCtx,0,1);i[t*r]=l[0],i[t*r+1]=l[1],i[t*r+2]=l[2],i[t*r+3]=c}const o=this.modules.renderer.createBuffer(i),a=this.modules.renderer.getShaderProgram("stars");this.starsVao=D_(o,a)}updateFog(){const e=this.modules.camera;this.squaredDistMaxFog=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,a=n.buildingAnimation.duration){this.state[e]||(this.state[e]={tickerConfig:{start:t,end:i,duration:a,easing:o},tickerKey:"",readiness:t===i?1:0})}has(e){return!!this.state[e]}remove(e){this.state[e]&&delete this.state[e];const t=this.buildTickerKey(e);n.exist(t,this.mapState)&&n.stop(t,this.mapState)}getReadiness(e){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:a,end:r,duration:l,easing:c}=i.tickerConfig;if(i.tickerKey)n.update(i.tickerKey,{step:(d,_)=>{i.readiness=_}},this.mapState);else{const d=this.buildTickerKey(t);i.tickerKey=d,n.start(d,{easing:c},this.mapState,a,r,l,1)}i.readiness===1&&o!==1&&e.push(t)}}return e}buildTickerKey(e){return`gltf-${e}`}}const ny=!0,gs="#ffffffff",oy=0,sy=0,ay=1,ys=15,ry=n.tileZoomToSize(ys)/n.MAP_POINTS_IN_METER,Hn=n.maxTilePoint/2,ly=["coordinates","rotation","scale","offset"];let xs=class ks extends Ye{constructor(e,t){var S,L,E,R,H,V,P,F,se;super(e,{interactive:(S=t.interactive)!=null?S:!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=(L=t.interactiveOcclusion)!=null?L:ny,this.disableAnimation=t.disableAnimation,this.linkedIds=t.linkedIds,this.planId=t.planId,this.tickerNames=new Map,this.generatedAsEcef=ye(this.mapState);const i=n.Mercator.fromGeo(t.coordinates);this.position={userValue:i,normalizedValue:n.normalizeMapPoint(i)};const{dynamicStyle:o,collector:a,tileManager:r,layers:l,assetManager:c}=this.modules,{ignoreGlobalLighting:d,colorTextureUvIndex:_,nearCameraFade:u,showRatio:h,playAnimation:f}=t,m=Gl((E=t.rotation)!=null?E:oy),p=(R=t.scale)!=null?R:ay,v=Vl((H=t.offset)!=null?H:sy,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],((V=t.hover)==null?void 0:V.color)||gs,["match",["object-attr","selected"],[!0],((P=t.select)==null?void 0:P.color)||gs,t.color||gs]]},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,ys),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:a,generator:n.GltfModelGenerator.generateInstances,args:[o.getStyle(),this.layer,y,{x:[Hn],y:[Hn],z:[(se=this.position.userValue[2])!=null?se:0]},n.createTileInfo(x),NaN]});const b=a.getAccumulatedData(),T=new n.TileObject("dynamicObject",b.data,this.modules,this.mapState,x,this);T.ecefDataState=n.ecefDataStateFromBool(ye(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"&&(r.addObject(T),this.modules.renderer.addRerenderEvent(),this.linkedIds&&this.map.hideBuildingsById(this.linkedIds),this.updateIdentifier()),setTimeout(()=>this.emit("modelloaded"),0)}),this.tileObjects.push(T),t.interactive&&this.identifyIds.push(b.identifyIds),l.addLayer(this),a.reset(),this.status==="visible"&&this.hideLinkedObjects())}update(){super.update();const e=ye(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,a)=>{n.update(o,{step:(r,l)=>{i[a]=l},complete:()=>{t.push(a)}},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 ks&&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,a;if(this.status==="destroyed"||!this.layer)return;this.stopTransformation();const t={};e.forEach(r=>{const l=dy(r);if(!l)return;const{duration:c=0,easing:d="linear"}=r;t[l]={value:r[l],duration:c,easing:d}});const i={};for(const r in t){if(!cy(r)||t[r]===void 0)continue;let l;if(r==="coordinates"?l=n.Mercator.fromGeo(t[r].value):r==="offset"?l=Vl(t[r].value,(a=(o=t.coordinates)==null?void 0:o.value[1])!=null?a:n.Mercator.toGeo(this.position.userValue)[1]):l=t[r].value,!t[r].duration){i[r]=l;continue}const c=`dynamicGltfModel-${r}-${this.uniqId}`;let d,_;if(r==="coordinates")d=this.position.userValue,_=l;else{const u=[0,0,0];n.getTriple(this.appliedTransformations[r],u),d=u;const h=[0,0,0];n.getTriple(l,h),_=h}n.start(c,{easing:t[r].easing,renderAfterUpdate:this.needRerender},this.mapState,d,_,t[r].duration,1,{layerId:this.layer.innerId,styleId:n.DYNAMIC_STYLE_ID}),this.tickerNames.set(r,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 a=this.tileObjects[0];if(!a)return;const r=a.buffers[0];if(!r)return;if(e&&(this.position={userValue:e,normalizedValue:n.normalizeMapPoint(e)},a.setTileCoords(n.getTileCoordsByCenterAndZoom(this.position.normalizedValue,ys),this.mapState)),t!==void 0||i!==void 0){const d=Gl(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,Hl),n.getTriple(this.appliedTransformations.scale,kl),n.getTriple(this.appliedTransformations.rotation,Ul);const l=ye(this.mapState);n.GltfModelGenerator.patchBuffer(r,0,n.createTileInfo(a.coords),[Hn,Hn,(c=this.position.userValue[2])!=null?c:0],Hl,kl,Ul,l),a.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 ks&&t!==this&&t.isVisible());this.linkedIds.forEach(t=>{e.every(o=>{var a;return!((a=o.getLinkedIds())!=null&&a.includes(t))})&&this.map.showHiddenBuildingsById([t])})}};const kl=[0,0,0],Ul=[0,0,0],Hl=[0,0,0];function Gl(s){return Array.isArray(s)?s.map(e=>e%360):s%360}function Vl(s,e){const t=ry/n.Mercator.scaleFactor(e),i=["x","y"].filter((o,a)=>{const r=Array.isArray(s)?s[a]:s;return r<-t||r>t});return i.length&&console.warn(`
            The offset is too big along ${i.map(o=>`${o}-axis`).join(" and ")} at the current latitude.
            Please, use more accurate coordinates to place the model.
        `),Array.isArray(s)?[s[0]%t,s[1]%t,s[2]]:[s%t,s%t,s]}function cy(s){return ly.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 _y=[0,0,0],uy=[0,0,0],hy=[0,0,0],fy="modelshow",my="modelhide",Gn=0,jl=.1;class py{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=bs(t.attributes.styleId,t.attributes.sourceId,t.tile.coords),a=this.layerModelKeyBySourceTile.get(o);a?a.add(i):this.layerModelKeyBySourceTile.set(o,new Set([i]))}clearSourceTileMapByTiles(e,t){t.map(i=>bs(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=Vn(e);return(o=this.modelInfo[i])==null?void 0:o.modelIds[t.id]}getModelOpacity(e){var i;if(e===void 0)return Gn;const t=Vn(e.attributes);return t&&(i=this.modelsAnimator.getReadiness(t))!=null?i:Gn}getModelHeightFactor(e){var i;if(!e)return 1;const t=Vn(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=Vn(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 r;const o=bs(i,e,t),a=this.layerModelKeyBySourceTile.get(o);if(!a)return!0;for(const l of a){const c=(r=this.modelInfo[l])==null?void 0:r.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,a){var L,E,R,H;const{assetManager:r,sourceStorage:l,styleManager:c,camera:d,defaultSource:_}=this.mapModules,u=this.mapState;e.modelId=void 0;const{styleId:h,layerId:f,sourceId:m,sourceName:p,modelIndices:v,modelStepValues:x,modelStepSource:g}=t;if(!v.length)return;let y;switch(g){case n.ModelStepSource.None:y=0;break;case n.ModelStepSource.Zoom:y=Zl(x,u.styleZoom);break;case n.ModelStepSource.Distance:y=vy(o,i,d.position,x,a);break;default:return}if(y===-1)return;const b=v[y];if(b===void 0)return;const T=r.getModel(b,h);if(T)switch(T.status){case nt.Loaded:e.modelId=b;const V=(E=(L=T.scenes.find((P,F)=>typeof t.scene=="number"&&!Number.isNaN(t.scene)&&F===t.scene||typeof t.scene=="string"&&P.name===t.scene))!=null?L:T.scenes.find((P,F)=>F===T.defaultScene))!=null?E:T.scenes.find((P,F)=>F===0);e.sceneId=V==null?void 0:V.id,T.usedEmptyScene=((H=(R=T.scenes.find(P=>P.id===e.sceneId))==null?void 0:R.objects.length)!=null?H:0)===0;return;case nt.Failed:e.modelId=NaN;return}else{const V=c.getStyleLayer(h,f),P=r.getDataModelUrlById(b);if(V&&!this.disabled){if(P===void 0)r.loadModelByIndex(b,h,V);else if(P.length){const F=m===_.getId()&&p===Rn;r.loadModel(P,b,h,!1,V,F)}}}if(v.length===1)return;const S=l.getSourceById(m);S&&(g===n.ModelStepSource.Zoom?e.modelId=this.getModelIdByZoom(S,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:a,modelIndices:r}=t,l=e.getZoomDirection();if(l===n.ZoomDirection.Stationary)return this.getCurrentModelId(t,i);const c=r.slice(0,o).reverse(),d=r.slice(o+1),_=l===n.ZoomDirection.ZoomingIn?c.concat(d):d.concat(c);for(let u=0;u<_.length;u++){const h=this.mapModules.assetManager.getModel(_[u],a);if(h&&h.status===nt.Loaded)return _[u];if((h==null?void 0:h.status)===nt.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===nt.Loaded)return i;if((o==null?void 0:o.status)===nt.Failed)return NaN}syncStateWithSceneObjects(){if(this.disabled=this.mapModules.map.getFeatureFlag("modelsOff"),this.disabled){this.destroy();return}const e=new Set,t=new Set,i=Array.from(this.sceneObjects.values());for(let a=0;a<i.length;a++)this.processSceneObject(i[a],e,t);for(const a of t)this.sceneObjects.delete(a),delete this.objectIdToLayerModelKey[a];const o=this.mapState.styleZoom;for(const a of Object.keys(this.modelInfo)){const r=this.modelInfo[a];(!e.has(a)||o<r.layer.minzoom||o>=r.layer.maxzoom)&&this.removeLayerModel(a,r)}}processSceneObject(e,t,i){if(e.tile.destroyed){i.add(e.id);return}const o=e.key,a=this.modelInfo[o],r=this.mapState.disableModelsGrowthAnimation||e.tile.dynamicObject instanceof xs&&e.tile.dynamicObject.isAnimationDisabled();a&&!this.modelsAnimator.has(o)&&(this.mapModules.defaultSource.createModelsSource(),this.startAnimation(o,a,r)),a?this.objectIdToLayerModelKey[e.id]||this.indexateObject(o,e,a):this.addLayerModel(e,o,!0),t.add(o)}addLayerModel(e,t,i=!1){var r,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 a={layer:o,ids:e.tile.ids,linkedIds:[],ownerIds:new Set,modelIds:{},buildingId:((r=e.meta)==null?void 0:r.buildingId)||""};return(l=e.meta)!=null&&l.planId&&(a.planId=e.meta.planId),this.indexateObject(t,e,a),this.modelInfo[t]=a,a}startAnimation(e,t,i){var r;if(i){this.modelsAnimator.add(e,1,1);return}const o=(r=t.layer.minzoom)!=null?r:NaN;t.linkedIds.length>0&&this.mapModules.buildingHeightAnimator.getBuildingHeight(o)>.5?this.modelsAnimator.add(e,.5,1):this.modelsAnimator.add(e)}maybeEmitModelEvent(e,t,i){const o=!t.onKeyRemove&&!!i&&n.tetragonIntersectsBounds(i,{min:e.mapPoint,max:e.mapPoint}),a=e.visible;o!==a&&(e.visible=o,this.emitEvent(o&&!a?fy:my,e))}addNewSceneObjectsToVisibilityMap(){var i,o,a,r;const e=this.mapModules.camera.getViewportVertices(jl),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:((a=c.meta)==null?void 0:a.buildingId)||"",sublayer:((r=c.meta)==null?void 0:r.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(jl);this.sceneObjectsVisibilityMap.forEach(t=>t.forEach(i=>this.maybeEmitModelEvent(i,{},e)))}indexateObject(e,t,i){var a,r,l;this.objectIdToLayerModelKey[t.id]=e,i.ownerIds.add(t.id),i.buildingId=((a=t.meta)==null?void 0:a.buildingId)||"",i.buildingId&&this.buildingIds.add(i.buildingId);const o=(l=(r=t.meta)==null?void 0:r.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 a of t.ownerIds)delete this.objectIdToLayerModelKey[a];t.buildingId&&this.buildingIds.delete(t.buildingId),this.modelsAnimator.remove(e);const i=this.sceneObjectsVisibilityMap.get(e);i&&(i.forEach(a=>this.maybeEmitModelEvent(a,{onKeyRemove:!0})),this.sceneObjectsVisibilityMap.delete(e)),delete this.modelInfo[e]}linkedIdToLayerModelKey(e){const t=this.linkedIdToObjectId[e];if(!t)return null;const i=this.objectIdToLayerModelKey[t];return i||null}emitEvent(e,t){const{buildingId:i,sublayer:o}=t;if(!o){console.warn(`No sublayer for model ${t.key}`);return}if(!i){console.warn(`No buildingId for model ${t.key}`);return}const a=n.isCommercialModel(o);this.mapModules.map.emit(e,{sublayer:o,id:i,isCommercial:a})}updateObjectsVisibility(){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 a=this.modelInfo[o],r=a.ids;if(!r)continue;const l=(i=this.modelsAnimator.getReadiness(o))!=null?i:Gn;for(const c of a.linkedIds){if(r.isHidden(c))continue;const d=a.planId!==void 0?n.HideLevel.FloorPolygons:n.HideLevel.PolygonExtrusion,_=r.isHidden(c,d);l>.5&&!_?r.hide([c],d):l<.5&&_&&r.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 Vn(s){const{layerId:e,modelIndices:t}=s;return`${e}_${t.join(",")}`}function bs(s,e,t){return`${s}_${e}_${JSON.stringify(t)}`}function vy(s,e,t,i,o){const a=s.modelMatrices.get(0);if(!a)return-1;let r=e.min,l=e.max;o||(r=n.transformMat4$1(uy,r,a),l=n.transformMat4$1(hy,l,a));const c=n.projectToXyRect(t,r,l,_y),d=n.Mercator.toGeo(c),_=n.Mercator.scaleFactor(d[1]),u=n.dist$1(t,c)/n.MAP_POINTS_IN_METER/_;return Zl(i,u)}function Zl(s,e){let t=0;for(;t<s.length&&!(e<s[t]);)t++;return t-1}const gy=n.bezier(.42,0,1,1),yy=(s,e,t,i)=>e+t*gy(s/i),xy=n.bezier(0,0,.58,1),by=(s,e,t,i)=>e+t*xy(s/i),wy=n.bezier(.42,0,.58,1),Sy=(s,e,t,i)=>e+t*wy(s/i);function Wl(s){switch(s[0]){case"cubic-bezier":{const e=n.bezier(s[1],s[2],s[3],s[4]);return(t,i,o,a)=>i+o*e(t/a)}case"exponential":{const e=s[1];return(t,i,o,a)=>{const r=i,l=i+o,c=t/a,_=(qe(e,c)-1)/(qe(e,1)-1);return(1-_)*r+_*l}}case"ease":return n.ease;case"ease-in":return yy;case"ease-out":return by;case"ease-in-out":return Sy;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 Ty{constructor(e,t){this.rerenderEvents=[],this.prevObjects=new Map,this.currentObjects=new Map,this.doubleSampledTextureAnimationStateMap=new Map,this.mapState=e,this.modules=t}frameEnd(){this.rerenderEvents.forEach(e=>this.modules.renderer.addRerenderEvent(e)),this.clearUnusedAnimationState(),this.doubleSampledTextureAnimationStateCleanup()}frameStart(){this.rerenderEvents=[]}clearAllTickers(){for(const e of this.currentObjects.keys())n.stop(e,this.mapState);this.clearUnusedAnimationState(),this.prevObjects=new Map,this.currentObjects=new Map}update(){const e=Date.now()+ +(this.mapState.styleState._customUserTimeOffset||0);[...this.prevObjects.values()].some(i=>i.timeToUpdate&&i.timeToUpdate<e)&&this.refresh()}animateGltfObject(e,t,i){const{localMatrix:o,animationStack:a,transformStack:r,textureTransformMatrix:l}=e.renderingProperties;if(t.style.playAnimation===void 0||!(a!=null&&a.length)||!o||!a||!r||!l)return;const c=this.updateAnimationKeyframes(e,t);Hr(l,a,i.buffers,c),Gr(o,a,r,i.buffers,c)}animatePolygonNormalMapTexture(e,t){var V;if(!t.style.normalMapTextureAnimation)return[!1,[0,0,0,0]];let i=1;const o=t.innerId,a=e.attributes.styleId,r=`${a}_${o}`,l=Date.now(),[[c,d],[_,u],[h,f],m,p,v,x,g]=this.resolveDoubleSampledTextureAnimationOptions(t),y=[h,f,0,0];if(this.mapState.disableLayerAnimation)return[!1,y];const b=(V=this.doubleSampledTextureAnimationStateMap.get(r))!=null?V:{lastKnownOffsets:y,animationStage:0,previousTimestamp:l},{lastKnownOffsets:T,previousTimestamp:S,animationStage:L}=b;let E=L;const R=(l-S)/1e3;switch(L){case 0:{let P=!1;const F=n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[]),se=n.resolveString(t.style.normalMapTextureImage,F),Y=this.modules.styleManager.getStyle(a);if(Y){const z=Y.rasterSets.byKey[n.getStaticTextureRasterSetKey(se)];z&&z.isReady&&(P=!0)}P&&(p?(n.start(`${r}_animationSpeedUp`,{easing:Wl(v),forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,0,1,p,1),E=1):(m!==1/0&&n.start(`${r}_animationFullSpeed`,{forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,1,1,m,1),E=2));break}case 1:{n.update(`${r}_animationSpeedUp`,{keepFinished:!0,step:(P,F,se,Y)=>{Y?(i=1,n.stop(`${r}_animationSpeedUp`,this.mapState),m!==1/0&&n.start(`${r}_animationFullSpeed`,{forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,1,1,m,1),E=2):i=F}},this.mapState);break}case 2:{m===1/0||n.update(`${r}_animationFullSpeed`,{keepFinished:!0,step:(P,F,se,Y)=>{Y&&(n.stop(`${r}_animationFullSpeed`,this.mapState),x?(n.start(`${r}_animationSlowDown`,{easing:Wl(g),forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,1,0,x,1),E=3):E=4)}},this.mapState);break}case 3:{n.update(`${r}_animationSlowDown`,{keepFinished:!0,step:(P,F,se,Y)=>{Y?(i=0,n.stop(`${r}_animationSlowDown`,this.mapState),E=4):i=F}},this.mapState);break}case 4:{i=0;break}}const H=[T[0]+c*i*R,T[1]+d*i*R,T[2]+_*i*R,T[3]+u*i*R].map(P=>P%1);return this.doubleSampledTextureAnimationStateMap.set(`${a}_${o}`,{animationStage:E,lastKnownOffsets:H,previousTimestamp:l,updatedOnThisFrame:!0,styleId:a,layerId:o}),E!==4&&this.rerenderEvents.push({type:"layerAnimationTicker",layerId:o,styleId:a,underCache:!0}),[!0,H]}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,T,S,L,E,R;const t=n.makeBinderContext(this.mapState.styleZoom,this.mapState.styleState,[]),i=n.resolveTextureAnimationExpression(e.style.normalMapTextureAnimation,t),o=(p=i[1])!=null?p:0,a=(v=i[2])!=null?v:0,r=(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,_=(T=i[7])!=null?T:1/0,u=(S=i[8])!=null?S:0,h=(L=i[9])!=null?L:["linear"],f=(E=i[10])!=null?E:0,m=(R=i[11])!=null?R:["linear"];return[[o,a],[r,l],[c,d],_,u,h,f,m]}clearUnusedAnimationState(){for(const e of this.prevObjects.keys())if(!this.currentObjects.has(e)){const t=this.prevObjects.get(e);t&&this.modules.renderCacheManager.isLayerInCache(t.styleId,t.layerId)?this.currentObjects.set(e,t):n.stop(e,this.mapState)}this.prevObjects=new Map(this.currentObjects),this.currentObjects=new Map}refresh(){this.modules.renderer.addRerenderEvent()}updateAnimationKeyframes(e,t){if(e.layerSettings.depthTest||e.layerSettings.shadow||this.mapState.disableLayerAnimation)return;const{animationStack:i}=e.renderingProperties;if(!i)return;const o=new Map,a=this.applyAnimationState(t,e);for(const r of i){const l=a.animationStateID,c=n.get(l,this.mapState);if(this.isNeedAnimation(r,a)){if(!c&&a.currentCount>0){const d=a.animationDuration||(r.max?r.max[0]:0),_=a.startOffset||0;let u=a.startOffset?r.frameCount/(r.frameCount*d/_):0,h=d*(1e3/a.playSpeed)-_*(1e3/a.playSpeed);a.elapsedTime&&(u=1-a.elapsedTime,h=d*(1e3/a.playSpeed)*a.elapsedTime),n.start(l,{easing:"linear",forceFinalValue:!0,renderAfterUpdate:!1},this.mapState,u,1,h,1)}n.update(l,{keepFinished:!0,step:(d,_,u,h)=>{const f=(r.frameCount-1)*_;o.set(r.actionId,f),h||this.rerender(e,t,a)},complete:d=>{a.currentCount>0&&a.currentCount--,a.currentCount>0&&(n.stop(l,this.mapState),this.rerender(e,t,a))}},this.mapState),this.currentObjects.set(l,a)}}return o}initObjectAnimationState(e,t){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],a=typeof i[0]=="object"&&!Array.isArray(i[0])&&i[0].type==="schedule-detailed-result"?i[0].currentStepElapsed/1e3:void 0,r=(m=i[2])!=null?m:1/0,l=r,c=i[1]||1,d=i[4]||void 0,_=i[3]||a||void 0,u=typeof o=="number"?o:void 0,h=typeof o=="string"?o:void 0,f=typeof o=="object"&&Array.isArray(o)?o:void 0;return{repeatCount:r,playSpeed:c,animationIndex:u,animationName:h,currentCount:l,animations:f,animationDuration:d,startOffset:_,tickerByStep:!!(_&&d),animationStateID:((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=r=>{o=r};const a=n.resolveAnimationExpression(e.style.playAnimation,i);return a[6]===void 0&&o&&(a[6]=o),a}isNeedAnimation(e,t){return t.animationIndex!==void 0&&e.animationIndex===t.animationIndex||t.animationName!==void 0&&e.animationName===t.animationName||t.animations!==void 0&&t.animations.includes(e.animationIndex)||t.animations!==void 0&&t.animations.includes(e.animationName)}applyAnimationState(e,t){const i=this.initObjectAnimationState(e,t),o=this.prevObjects.get(i.animationStateID);return o&&(o&&((o==null?void 0:o.animationIndex)!==i.animationIndex||(o==null?void 0:o.animationName)!==i.animationName)?(n.update(i.animationStateID,{keepFinished:!0,step:(a,r)=>{o.elapsedTime?(o.elapsedTime>0||o.elapsedTime<1)&&(i.elapsedTime=o.elapsedTime):(o.elapsedTime=r,i.elapsedTime=r)}},this.mapState),n.stop(i.animationStateID,this.mapState)):i.repeatCount===o.repeatCount&&(i.currentCount=o.currentCount)),i}rerender(e,t,i){i.repeatCount!==0&&!i.tickerByStep&&(this.rerenderEvents.push({type:"layerAnimationTicker",layerId:t.innerId,styleId:e.attributes.styleId}),this.modules.identifier.queryFillCache())}}const ct=.1,My={id:"simple-mesh",type:"simpleMesh",innerId:n.SIMPLE_MESH_STYLE_LAYER_ID,filter:!1,minzoom:0,maxzoom:20,precomputes:[],renderIndex:0,style:{}},ws={polygonsQty:1e4,drawCallsQty:150,iterations:7},$l=[18,34],Ey=1e3,zi="__MAPGL_BENCH_TIME",Iy=5,_i=class _i{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(My)}static mockResult(e){_i.mocked=e}run(){return K(this,arguments,function*(e=ws.polygonsQty,t=ws.drawCallsQty,i=ws.iterations,o=Ey){if(_i.mocked)return _i.mocked;const a=this.getCachedResult();if(a)return a;this.timeout=o,this.startTs=performance.now();try{return yield this._run(e,t,t*i,i)}catch(r){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.72.3",t=localStorage.getItem(zi);if(t){const i=t.split(":"),o=i[0];if(e===o){const a=i.slice(1).join(":").split(",").map(r=>parseFloat(r)).filter(r=>!Number.isNaN(r));if(a.length>=Iy){const r=a.reduce((c,d)=>c+d,0)/a.length;return{status:"cached",tier:this.selectTier(r)}}}}}catch(e){}return null}selectTier(e){const t=$l.findIndex(i=>e<=i);return t>-1?$l.length-t:0}saveResult(e){try{const t="v1.72.3",i=localStorage.getItem(zi);if(i){const o=i.split(":"),a=o[0];if(t!==a)localStorage.setItem(zi,`${t}:${e.toPrecision(4)}`);else{const r=o.slice(1).join(":").split(",").map(l=>parseFloat(l)).filter(l=>!Number.isNaN(l));r.push(e),localStorage.setItem(zi,`${t}:${r.map(l=>l.toPrecision(4)).join(",")}`)}}else localStorage.setItem(zi,`${t}:${e.toPrecision(4)}`)}catch(t){}}_run(e,t,i,o){return K(this,null,function*(){const a=this.modules.renderer.getFramebuffer(this.framebufferId);if(!a)throw new Error("Failed to create framebuffer for benchmark.");this.modules.renderer.bindRenderTarget(a.renderTarget),this.modules.renderer.setViewport(0,0,this.modules.renderer.getViewportSize()[0],this.modules.renderer.getViewportSize()[1]);const r=this.prepareData(e,i),l=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:r}})}prepareData(e,t){const i=performance.now();this.buffer=this.generateSphere(e);const o=performance.now(),a=performance.now();this.sceneObjects=this.createSceneObjects(t);const r=performance.now();return{generationTime:o-i,objectsTime:r-a}}measureRendering(e,t){return K(this,null,function*(){return new Promise(i=>{const o=[];let a=0,r=0;const l=()=>{const c=performance.now();if(c-this.startTs>this.timeout){i(o);return}this.modules.renderer.clear(!0),this.scale[0]+=.5-Math.random(),Eo(this.state,this.modules,this.sceneObjects.slice(r,r+t),this.de),this.modules.renderer.waitForGpuCommandsToFinish(),o.push(performance.now()-c),a++,r+=t,a<e?Promise.resolve().then(l):i(o)};setTimeout(()=>{l()},0)})})}processResults(e){const t=e.slice();t.sort((o,a)=>o-a);const i=t.slice(0,t.length-.2*t.length);return{median:i[Math.floor(i.length/2)],mean:i.reduce((o,a)=>o+a,0)/i.length,min:i[0],max:i[i.length-1]}}generateSphere(e){const t=Math.floor(Math.sqrt(e/2)),i=t*2,l=t*i*2*3*3,c=new Float32Array(l);let d=0;const _=Math.PI/t,u=2*Math.PI/i,h=new Float32Array(3),f=new Float32Array(3),m=new Float32Array(3),p=new Float32Array(3);for(let v=0;v<t;v++){const x=v*_,g=(v+1)*_,y=Math.sin(x),b=Math.cos(x),T=Math.sin(g),S=Math.cos(g);for(let L=0;L<i;L++){const E=L*u,R=(L+1)*u,H=Math.sin(E),V=Math.cos(E),P=Math.sin(R),F=Math.cos(R);h[0]=ct*y*V,h[1]=ct*b,h[2]=ct*y*H,f[0]=ct*y*F,f[1]=ct*b,f[2]=ct*y*P,m[0]=ct*T*V,m[1]=ct*S,m[2]=ct*T*H,p[0]=ct*T*F,p[1]=ct*S,p[2]=ct*T*P,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:wa,stateBinder:()=>fo,programBinder:Xu,tileBinder:()=>!0,objectBinder:vh,needsVisibilityBuffer:!1},i=[],o=wa(this.modules.renderer.createBuffer(this.buffer),this.modules.renderer.getShaderProgram("simpleMesh")),a=new n.TileObject("zenith",[],this.modules,this.state),r={layerId:n.SIMPLE_MESH_STYLE_LAYER_ID,styleId:n.DYNAMIC_STYLE_ID,tileData:[]};for(let l=0;l<e;l++){const d=(l/20&1)===0?1-(1+l%10)/10:(1+l%10)/10,_=n.fromValues(-1+l%20/10,1-Math.floor(l/20)*2/(e/20),0);i.push({id:n.uniqId(),type:n.SceneObjectType.Tile,start:0,count:this.buffer.byteLength/12,attributesHash:`benchmark-${l}`,vao:o,drawMode:n.GL_TRIANGLES,tile:a,symbol:"simpleMesh",sink:"fill",layerSettings:t,canRender:!0,attributes:r,meta:{scale:d,transform:_},renderingProperties:{}})}return i}};_i.mocked=null;let jn=_i;class Cy{constructor(e,t,i){this.benchmark=null,this.map=i,this.camera=new n.Camera(e),this.layout=new Xg(t),this.collector=new n.Collector("main"),this.workers=new Kv,this.identifier=new Jv(e,this),this.styleManager=new og(this),this.assetManager=new sg(e,this),this.imageManager=new Kg(this),this.floorManager=new Lg(e,this),this.personalPoiManager=new _g(this),this.buildingHeightAnimator=new Sd(e,this),this.modelsScene=new py(e,this),this.renderer=new Li(e,this),this.newRenderer=new Qv(e,this),this.layers=new Mg(this),this.sourceStorage=new Qg,this.tileManager=new Og(e,this),this.modelLayer=new dg(e,this),this.dynamicStyle=new n.DynamicStyle,this.imageCache=new Ig(this),this.labeler=new Vg(e,this),this.trafficTileLayer=new Wg(e,this),this.handler=new jg(e,this),this.mouseMoveHandler=new xd(this),this.tileKeyInfo=new Yg(e),this.demManager=new du(this),this.environmentManager=new ty(this),this.defaultSource=new vl(e,this),this.labelsDebug=new Ag(e,this),this.postEffectsManager=new ju(e,this),this.renderCacheManager=new kv(e,this),this.animationManager=new Ty(e,this),this.shadowManager=new Hu(e,this),this.instanceLinker=new Ff(this),e.graphicsPresetMode==="auto"&&(this.benchmark=new jn(e,this))}destroy(){this.demManager.disable(),this.imageManager.destroy(),this.trafficTileLayer.destroy(),this.tileManager.destroy(),this.workers.destroy(),this.identifier.destroy(),this.renderer.destroy(),this.newRenderer.destroy(),this.handler.destroy(),this.mouseMoveHandler.destroy(),this.labelsDebug.hide(),this.renderCacheManager.destroy(),this.tileKeyInfo.destroy(),this.layout.destroy()}}const Ss=["light","normal","immersive"],Py=["immersiveRoadsOff","reliefOff","shadowsOff","fogOff","skyOff","modelsOff","globeOff","transparentBuildingsOff","AALinesOff"],Ly=.3,ui=class ui{constructor(e,t={},i){var h,f,m,p,v,x,g,y,b,T,S,L,E,R,H,V,P,F;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=se=>{if(this.modules.renderer.isDestroyed)return;this.requestedFrame=requestAnimationFrame(this.renderLoop),this.updateImmersiveLevel();const Y=window.devicePixelRatio;Y!==this.lastDpr?(this.lastDpr=Y,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 z=this.state;z.time=Date.now(),this.processMetrics(),this.state.enableTrackResize&&this.autoResize(se),this.modules.mouseMoveHandler.update(),this.handlers.forEach(we=>we.update()),od(z),Ac(z),td(z),nd(z),this.stillnessUpdater.update(z),Qc(z,this.modules.layout.rootContainer),Vc(z,this.modules.layout.rootContainer,this.modules.renderer),Kc(z,this.modules.renderer),this.checkGlobeEnabled();const ae=this.modules.demManager.getReliefTileType()==="vector"&&z.styleZoom<za;if(z.demMode=this.checkDemEnabled()&&z.elevationScale>0&&!ae,this.modules.camera.update(),this.updateElevation(),this.updateTilesBounds(),this.replicasDiffer.check(z)&&(z.needReplicasUpdate=!0),this.modules.demManager.update(),this.modules.environmentManager.update(),this.modules.labelsDebug.update(),this.modules.trafficTileLayer.update(),this.modules.layers.getLayers().forEach(we=>{we.update!==void 0&&we.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(),z.loopWorld&&!this.modules.renderer.isNeedRerender()&&n.worldWrapX(z.center),(n.render.alwaysRerender||this.modules.renderer.isNeedRerender())&&z.collectStats&&(z.stats.drawCount=0,z.stats.vertexCount=0,z.stats.triangleCount=0,z.stats.drawCountBySymbol={}),n.render.alwaysRerender||this.modules.renderer.isNeedRerender()){const we=this.modules.tileManager.getTileObjects();this.modules.renderer.prerenderUpdate(),z.metrics.firstdraw===void 0&&(z.metrics.firstdraw=performance.now()-z.metrics.start),we.forEach(Se=>{Se.needSync&&Se.syncReplicas(this.state)}),this.modules.renderCacheManager.frameStart(),this.modules.animationManager.frameStart(),this.modules.renderer.renderElevation(we),this.modules.shadowManager.drawShadowMap(we),this.modules.renderer.renderLabelingTexture(we),this.modules.renderer.renderSpriteLabelingTexture(we),this.modules.renderer.renderTileObjects(we),this.modules.shadowManager.drawDebugFbIfNeeded(),z.needRerender=!1,this.state.rerenderEvents=new Array,this.modules.animationManager.frameEnd(),this.modules.renderCacheManager.frameEnd(),z.collectStats&&(this.modules.map.emit("stats",z.stats),(!z.metricsSent||this.state.metrics.graphicsPreset!==this.state.styleState.graphicsPreset)&&(z.metrics.vertexCount=z.stats.vertexCount,z.metrics.triangleCount=z.stats.triangleCount,z.metrics.drawCount=z.stats.drawCount))}this.finishStyleUpdatingCheck(),this.modules.map.update(),this.modules.assetManager.invalidateUsedGltfModels(),z.needReplicasUpdate=!1,z.shouldIsReadyWaitForUpdates=!1,z.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)};const o=I(I({},ui.options),t),a=I(I({},ui.options.padding),o.padding),r=I(I({},ui.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-r.left-r.right),Math.max(1,e.clientHeight-r.top-r.bottom)],tickers:{},stillness:1,needRerender:!0,needLabeling:!1,needReplicasUpdate:!1,userHasInteracted:!1,dpiChanged:!1,viewport:r,padding:a,labelingOpacity:0,tileServer:o.tileServer,styleServer:o.styleServer||n.styles.url,fontUrl:o.fontUrl||n.fonts.defaultUrl,modelUrl:o.modelUrl||n.defaultModelsPath,iconUrl:o.iconUrl||n.icons.defaultUrl,keyUrl:o.keyUrl||n.keyServerPath,tileSet:o.tileSet,tileProtocol:o.tileProtocol,commercialTileSet:o.commercialTileSet,modelsTileSet:(f=o.modelsTileSet)!=null?f:n.models.tileSet,modelsTilesUrl:(m=o.modelsTilesUrl)!=null?m:n.urls.models,defaultSourceModelsRootUrl:o.defaultSourceModelsRootUrl,defaultSourceModelsAppearStrategy:o.defaultSourceModelsAppearStrategy,subdomains:o.subdomains.split(""),floorsEnabled:o.floorsEnabled,collectStats:o.collectStats,stats:{tileCount:0,dynamicTileCount: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:Dn(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:Ly,disableHidingPois:(b=o.disableHidingPois)!=null?b:!1,resetFloorModeOnActivation:(T=o.resetFloorModeOnActivation)!=null?T:!1,aaMode:o.disableAntiAliasing===!1?ti.TAA:void 0,rerenderEvents:new Array,cameraConfig:Object.assign({},n.defaultCameraConfig),cityCommPoiLabeling:{config:o.cityCommPoiLabelingConfig,ascSortedZoomNumbers:Ug(o.cityCommPoiLabelingConfig)},trafficMinZoom:(S=o.trafficMinZoom)!=null?S:n.traffic.minZoom,trafficMaxZoom:(L=o.trafficMaxZoom)!=null?L:n.traffic.maxZoom,trafficMaxDetailLevel:(E=o.trafficMaxDetailLevel)!=null?E:n.traffic.maxDetailLevel,bssHostAppParams:o.bssHostAppParams,disableStyleFallback:!!o.disableStyleFallback,hiddenImmersiveRoutesEnabled:Hd(),modelShowHideEventsSublayers:new Set((R=o.modelShowHideEventsSublayers)!=null?R:[]),graphicsPresetMode:o.graphicsPreset,shouldEmitGraphicsPresetChangeEvent:!1,isDeprecatedSystem:Yt(),disableModelsGrowthAnimation:(H=o.disableModelsGrowthAnimation)!=null?H:!1,disableLayerAnimation:(V=o.disableLayerAnimation)!=null?V:!1,allowMetro:(P=o.allowMetro)!=null?P:!1,forceSyncIdentify:(F=o.forceSyncIdentify)!=null?F:!1};o.cameraConfig&&Object.assign(_.cameraConfig,o.cameraConfig),this.modules=new Cy(_,e,i),typeof _.commercialPoiRandomSeed=="number"&&this.modules.workers.labeling.setCommercialPoiRandomSeed(_.commercialPoiRandomSeed),this.modules.styleManager.setDynamicStyle(this.modules.dynamicStyle.getStyle()),this.handlers=[new fd(_,this.modules.layout.mapContainer),new md(this.modules)],o.disableZoomOnScroll||this.handlers.push(new hd(_,this.modules.layout.mapContainer)),dd&&$i&&this.handlers.push(new pd(_,e,i)),this.performanceChecker=new vd(_,this.modules),this.stillnessUpdater=new yd,(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=Ss[0];this.state.metrics.graphicsPreset=t,this.modules.map.patchStyleState({graphicsPreset:t});break;case"part-done":case"done":case"cached":{const i=Ss[e.tier];this.state.metrics.graphicsPreset=e.status==="part-done"?Ss[0]: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||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 a=this.state.globeMode;this.state.globeMode=!1,this.state.globeRatioTarget=0,a&&!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,a,r]=this.modules.camera.getViewportVertices(),l=n.getLineConstants(i,o),c=n.pointToLineSignedDistance(this.modules.camera.position,l),d=c<0,_=this.state.cameraConfig;let u=this.modules.environmentManager.fogLimits[1]*this.modules.camera.fogDistance;if(d&&(u+=c),this.state.demMode&&this.state.elevation!==void 0&&!Number.isNaN(this.state.elevation)){const p=this.modules.camera.position[2],v=this.state.minElevation!==void 0&&!Number.isNaN(this.state.minElevation)?this.state.minElevation:this.state.elevation,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(r,this.modules.camera.position,r,g),n.lerp(a,this.modules.camera.position,a,g)}let h=n.pointToLineDistance(a,l);if(h>u){const p=u/h;n.lerp(a,o,a,p),n.lerp(r,i,r,p),h=u}n.copy$2(this.state.extendedTilesBounds[0],i),n.copy$2(this.state.extendedTilesBounds[1],o),n.copy$2(this.state.extendedTilesBounds[2],a),n.copy$2(this.state.extendedTilesBounds[3],r);const f=Math.min(_.minTrapezeHeight,u),m=Math.max(n.pixelToMapDistance(e[1],t)*_.viewportLimitRatio,f);if(h>m){const p=m/h;n.lerp(a,o,a,p),n.lerp(r,i,r,p),h=m}if(this.state.demMode&&d){const p=(h+Math.abs(c))/h;n.lerp(i,r,i,p),n.lerp(o,a,o,p)}n.copy$2(this.state.tilesBounds[0],i),n.copy$2(this.state.tilesBounds[1],o),n.copy$2(this.state.tilesBounds[2],a),n.copy$2(this.state.tilesBounds[3],r),this.state.visibleMapReplicas=this.state.loopWorld||this.state.globeMode?n.getVisibleMapReplicas(this.state.tilesBounds,this.state.globeMode):[0]}updateElevation(){if(this.state.elevationScale=this.modules.demManager.getVerticalScale(),!this.state.demMode){this.state.elevation!==void 0&&(this.modules.renderer.addRerenderEvent(),this.state.elevation=void 0);return}const e=this.modules.demManager.getElevation(this.state.center);if(e!==void 0)if(this.state.elevation===void 0||this.state.skipElevationAnimation)this.state.elevation=e;else{const i=su*(e-this.state.elevation);Math.abs(i)<au?this.state.elevation=e:this.state.elevation+=i;const o=this.modules.demManager.getElevation(this.modules.camera.position);if(o!==void 0){const a=this.state.elevationScale,r=o*a,l=this.modules.camera.position[2]/n.MAP_POINTS_IN_METER,c=Math.min(30,l*.2),d=this.state.elevation*a+l-c;r>d&&(this.state.elevation+=(r-d)/a)}}const t=this.modules.demManager.getMinElevation();t!==void 0&&(this.state.minElevation=t)}autoResize(e){if(e-this.lastResizeTime>=this.state.autoResizeInterval){const t=this.modules.layout.canvas,{clientWidth:i,clientHeight:o}=this.modules.layout.rootContainer,a=window.devicePixelRatio;(t.width!==Math.floor(i*a)||t.height!==Math.floor(o*a))&&(this.lastResizeTime=e,this.modules.map.invalidateSize())}}};ui.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:Cg(),styleOptions:{rootUrl:"",iconsPath:"",fontsPath:"",stylePath:"",modelsPath:""},lang:n.defaultLang,appId:n.tiles.appId,disableHoverStyles:!1,disableZoomOnScroll:!1,disableDragging:!1,enableTwoFingerDragging:!1,disableRotationByUserInteraction:!1,disablePitchByUserInteraction:!1,defaultBackgroundColor:"#f6f2de",disableIconCache:!1,disableRenderingCache:!1,mobileSdkMode:!1,skipElevationAnimation:!1,enableTrackResize:!1,showDefaultTileBounds:!1,immersiveOn:!1,pitchHightLimitation:90,trafficOn:!1,trafficMinZoom:n.traffic.minZoom,trafficMaxZoom:n.traffic.maxZoom,trafficMaxDetailLevel:n.traffic.maxDetailLevel,disableStyleFallback:!1,modelShowHideEventsSublayers:[],styleServer:"",fontUrl:"",modelUrl:"",iconUrl:"",keyUrl:"",disableLayerAnimation:!1};let Ts=ui;const By="https://mapgl.2gis.com/api/js",Zn={minZoom:2,maxZoom:20},zy="tile{subdomain}-sdk.maps.2gis.com",Xl="https://tile{subdomain}-sdk.maps.2gis.com/api/v3/ald",Ry="https://s1.bss.2gis.com/bss/3",Ms=()=>{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},Fy=2;function Dy(s){const e=[Fy,s instanceof WebGLRenderingContext?1:2,s.getParameter(s.ALIASED_LINE_WIDTH_RANGE),s.getParameter(s.ALIASED_POINT_SIZE_RANGE),s.getParameter(s.COMPRESSED_TEXTURE_FORMATS),s.getParameter(s.MAX_COMBINED_TEXTURE_IMAGE_UNITS),s.getParameter(s.MAX_CUBE_MAP_TEXTURE_SIZE),s.getParameter(s.MAX_FRAGMENT_UNIFORM_VECTORS),s.getParameter(s.MAX_RENDERBUFFER_SIZE),s.getParameter(s.MAX_TEXTURE_IMAGE_UNITS),s.getParameter(s.MAX_TEXTURE_SIZE),s.getParameter(s.MAX_VARYING_VECTORS),s.getParameter(s.MAX_VERTEX_ATTRIBS),s.getParameter(s.MAX_VERTEX_TEXTURE_IMAGE_UNITS),s.getParameter(s.MAX_VERTEX_UNIFORM_VECTORS),s.getParameter(s.MAX_VIEWPORT_DIMS),s.getParameter(s.PACK_ALIGNMENT),s.getParameter(s.SUBPIXEL_BITS),s.getParameter(s.UNPACK_ALIGNMENT),s.getParameter(s.VIEWPORT),s.getParameter(s.SHADING_LANGUAGE_VERSION),s.getParameter(s.VENDOR),s.getParameter(s.RENDERER)];s instanceof WebGLRenderingContext?e.push(...new Array(28).fill(-1)):e.push(s.getParameter(s.MAX_3D_TEXTURE_SIZE),s.getParameter(s.MAX_ARRAY_TEXTURE_LAYERS),s.getParameter(s.MAX_CLIENT_WAIT_TIMEOUT_WEBGL),s.getParameter(s.MAX_COLOR_ATTACHMENTS),s.getParameter(s.MAX_COMBINED_FRAGMENT_UNIFORM_COMPONENTS),s.getParameter(s.MAX_COMBINED_UNIFORM_BLOCKS),s.getParameter(s.MAX_COMBINED_VERTEX_UNIFORM_COMPONENTS),s.getParameter(s.MAX_DRAW_BUFFERS),s.getParameter(s.MAX_ELEMENT_INDEX),s.getParameter(s.MAX_ELEMENTS_INDICES),s.getParameter(s.MAX_ELEMENTS_VERTICES),s.getParameter(s.MAX_FRAGMENT_INPUT_COMPONENTS),s.getParameter(s.MAX_FRAGMENT_UNIFORM_BLOCKS),s.getParameter(s.MAX_FRAGMENT_UNIFORM_COMPONENTS),s.getParameter(s.MAX_PROGRAM_TEXEL_OFFSET),s.getParameter(s.MAX_SAMPLES),s.getParameter(s.MAX_SERVER_WAIT_TIMEOUT),s.getParameter(s.MAX_TEXTURE_LOD_BIAS),s.getParameter(s.MAX_TRANSFORM_FEEDBACK_INTERLEAVED_COMPONENTS),s.getParameter(s.MAX_TRANSFORM_FEEDBACK_SEPARATE_ATTRIBS),s.getParameter(s.MAX_TRANSFORM_FEEDBACK_SEPARATE_COMPONENTS),s.getParameter(s.MAX_UNIFORM_BLOCK_SIZE),s.getParameter(s.MAX_UNIFORM_BUFFER_BINDINGS),s.getParameter(s.MAX_VARYING_COMPONENTS),s.getParameter(s.MAX_VERTEX_OUTPUT_COMPONENTS),s.getParameter(s.MAX_VERTEX_UNIFORM_BLOCKS),s.getParameter(s.MAX_VERTEX_UNIFORM_COMPONENTS),s.getParameter(s.MIN_PROGRAM_TEXEL_OFFSET));const t=s.getExtension("WEBGL_debug_renderer_info");t?e.push(s.getParameter(t.UNMASKED_VENDOR_WEBGL),s.getParameter(t.UNMASKED_RENDERER_WEBGL)):e.push("Unsupported","Unsupported");const i=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.LOW_FLOAT),o=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.MEDIUM_FLOAT),a=s.getShaderPrecisionFormat(s.FRAGMENT_SHADER,s.HIGH_FLOAT);return a&&o&&i?(e.push(`[${i.rangeMin},${i.rangeMax}](${i.precision})`),e.push(`[${o.rangeMin},${o.rangeMax}](${o.precision})`),e.push(`[${a.rangeMin},${a.rangeMax}](${a.precision})`)):e.push(new Array(3).fill("Unsupported")),e.push(window.devicePixelRatio),e}function Oy(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 Ny(s){var a,r;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=(a=e[t])!=null?a:{},o={};for(let l=0;l<s.length;l++)o[(r=i[l])!=null?r:l]=s[l];return o}const ky=/(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,Uy=/CrOS/,Hy=/android|ipad|playbook|silk/i,Gy=()=>{const s=typeof navigator!="undefined"?navigator.userAgent:"";if(!s)return!1;const e=ky.test(s)&&!Uy.test(s),t=Hy.test(s),i=navigator.maxTouchPoints>1&&s.includes("Macintosh")&&s.includes("Safari");return e||t||i},Wn=5e3,Vy=64,jy=16;class Zy{constructor(e,t){var i;this.queue=[],this.commPoiMsgOrderNumber=0,this.utcOffset=$y(),this.unsentMessages=[],this.isMetricsFailed=!1,this.webglStatsValues=[],this.onCommPoiShowEvent=({commPois:o})=>{const a=Date.now(),{tileKey:r,sessionId:l}=this.map.state;for(const c of o){const d=Wy(c,a,this.commPoiMsgOrderNumber++,r,this.utcOffset,l);d&&this.queue.push(d)}this.timer||(this.timer=window.setTimeout(this.sendMessages,Wn))},this.onContextLostEvent=()=>K(this,null,function*(){const o=Date.now(),a={cpu:0,gpu:0},r={start:0,fail:!0,contextLost:!0},l=yield this.createMetricMessage(o,r,a);this.queue.push(l),this.timer||(this.timer=window.setTimeout(this.sendMessages,Wn))}),this.onMetricsEvent=o=>K(this,null,function*(){this.isMetricsFailed&&(o.fail=!0);const a=Date.now(),r=yield this.getMetricsMessage(o,a);this.queue.push(r),this.timer||(this.timer=window.setTimeout(this.sendMessages,Wn))}),this.onSendFail=o=>{this.unsentMessages.push(...o),this.timer||(this.timer=window.setTimeout(this.sendMessages,Wn))},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(a=>{a.ok||this.onSendFail(o)},()=>this.onSendFail(o))},this.markMetricsAsFailed=()=>{this.isMetricsFailed=!0},this.map=e,this.bssUrl=(i=t.bssUrl)!=null?i:Ry,this.webglStatsValues=Dy(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=Ny(this.webglStatsValues),t=Oy(e),i=this.map.performanceChecker.getFpsStats(),o=Array.from(this.map.state.center),a=this.map.state.zoom,r=this.map.state.rotation,l=this.map.state.pitch,c=this.map.state.demMode,d=yield Gd();return{webglStats:t,fps:i,center:o,zoom:a,rotation:r,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:Ms(),timestamp:e,payload:{mapGlMapMetrics:ce(I(I({},t),o),{memory:i}),mapGlHostAppParams:Xy(this.map.state.bssHostAppParams)},common:{formatVersion:3,appVersion:n.limitString(Ds,Vy),product:44,deviceType:Gy()?"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 Wy(s,e,t,i,o,a){const r={adsHighlight:!0,entity:{id:s.id,type:"branch"}};s.adsPriority!==void 0&&(r.adsPriority=s.adsPriority);const l={type:302,eventType:"view",eventId:Ms(),eventOrdinal:t,uiElement:{name:"POI",ownerName:"map"},timestamp:e,utcOffset:o,payload:{POI:r},common:{formatVersion:3,appVersion:n.limitString(Ds,jy),product:44,apikey:i}};return a&&(l.common.sessionId=a),!i||i===n.DEFAULT_EMPTY_KEY?null:l}function $y(){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 Xy(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 Kl=s=>typeof s=="number"&&!isNaN(s)&&s!==Number.NEGATIVE_INFINITY&&s!==Number.POSITIVE_INFINITY;function Ky(s){return Array.isArray(s)&&Kl(s[0])&&Kl(s[1])}var Es=(s=>(s[s.IgnoreCall=0]="IgnoreCall",s[s.UseDefault=1]="UseDefault",s))(Es||{});const qy={0:"Method call will be ignored.",1:"Method call will use default value."};class Yy{constructor(e){this.options=e}isValidGeoPoint(e,t){return this.processValidationResult(e,Ky(e),"Invalid GeoPoint",t)}processValidationResult(e,t,i,o){return!t&&this.options.reportToConsole&&console.warn(`${i}: ${JSON.stringify(e)}
${qy[o]}`),t}}const ql=new Yy({reportToConsole:!0}),$n="Style preprocessing:";function Qy(s){const e=new Map,t=i=>{i==null||i.forEach(o=>{const a={layers:i,layer:o};e.set(o.id,a),o.type==="group"&&t(o.layers)})};return t(s.layers),e}function Jy(s,e){var a,r,l;const t=new Set;performance.now(),e!=null&&e.parentStyleId&&console.warn(`${$n} 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=(a=i.layers)!=null?a:[],e){const c=Qy(i),d=(r=s.layersInserts)!=null?r:[];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(`${$n} 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(`${$n} 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(`${$n} 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]=Ay(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 Ay(s,e,t,i,o){var l,c,d,_,u,h,f,m;const a=I({},t==null?void 0:t.commonDefaults),r=I({},i==null?void 0:i.commonDefaults);switch(e.type){case"heatmap":case"overpass":case"tunnel":{delete a.interactive,delete r.interactive,delete a.ignoreTier,delete r.ignoreTier;break}case"embankment":case"polygon3d":case"buildingModel":case"model":case"lineExtrusion":case"polygonExtrusion":case"point":{delete a.ignoreTier,delete r.ignoreTier;break}case"arrow":case"dashedLine":case"labelLine":case"line":case"metricPoint":case"oneWayLine":case"polygon":case"raster":case"shiftedLine":break;default:n.assertUnreachable(e)}return ce(I(I(I(I(I(I(I({},a),(l=t==null?void 0:t.layerTypeDefaults)==null?void 0:l[e.type]),e),r),(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 a=yield o.json();if(a&&a.result)return{loadedId:e,style:a.result}})}function tx(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}),a=yield ex(n.getStyleUrl(o),s,e);if(!a)throw new Error;i=a.style}catch(o){throw new Error("FETCH_PARENT_STYLE_ERROR")}return i})}function ix(s,e,t){return K(this,null,function*(){let i;return s.parentStyleId&&(i=yield tx(s.parentStyleId,e,t)),Jy(s,i)})}const Yl=["zoom","rotation","pitch","center"],nx=150,ox=["static","immersive_roads"];class Is extends n.Evented{constructor(e,t){var a;super();const i=this.core=new Ts(e,t,this);this.state=i.state,this.modules=i.modules,this.performanceChecker=i.performanceChecker,this.values={isMoveChanging:!1,isIdle:!1},Yl.forEach(r=>{this.cloneFromStateToValues(r,`${r}1`),this.cloneFromStateToValues(r,`${r}2`),this.cloneFromStateToValues(r,`${r}End1`),this.cloneFromStateToValues(r,`${r}End2`),this.values[`${r}EndTime`]=0,this.values[`is${r}Changing`]=!1}),this.cloneFromStateToValues("size","size"),this.performanceChecker.on("performancecaveat",()=>{this.emit("performancecaveat")});const o=r=>{if(r instanceof Error)throw r};this.setStyle((a=t==null?void 0:t.style)!=null?a:n.DEFAULT_MAPGL_STYLE,t==null?void 0:t.styleOptions).catch(o),this.setLang(this.state.lang),t&&!t.disableBssStatistics&&(this._bssDispatcher=new Zy(this,{disableBssStatisticsForCommPoi:!!t.disableBssStatisticsForCommPoi,bssUrl:t.bssUrl})),this.state.metrics.init=performance.now()-this.state.metrics.start,this.updateDataToggle()}setCenter(e,t){if(!ql.isValidGeoPoint(e,Es.IgnoreCall))return this;this.state.userHasInteracted=!1;let i=n.Mercator.fromGeo(e);return this.state.loopWorld||(i=n.normalizeMapPoint(i)),kt(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,mi(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,Zi(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,Gc(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,a,r,l;const i={top:(o=e.top)!=null?o:0,left:(a=e.left)!=null?a:0,right:(r=e.right)!=null?r:0,bottom:(l=e.bottom)!=null?l:0};return this.state.userHasInteracted=!1,Xc(this.state,this.modules.renderer,i,t),this}setTime(e){this.patchStyleState({_customUserTimeOffset:e?e-this.state.time:0}),this.modules.animationManager.clearAllTickers(),this.modules.renderer.addRerenderEvent()}getTime(e){return e?this.state.time-new Date().getTimezoneOffset()*6e4+ +(this.state.styleState._customUserTimeOffset||0):this.state.time+ +(this.state.styleState._customUserTimeOffset||0)}getPadding(){return this.state.padding}getCenter(){const e=n.normalizeMapPoint(this.state.center);return n.Mercator.toGeo(e).slice(0,2)}getZoom(){return this.state.zoom}getStyleZoom(){return this.state.styleZoom}getMinZoom(){return this.state.minZoom}getMaxZoom(){return this.state.maxZoom}getRotation(){return n.radToDeg(this.state.rotation)}getPitch(){return n.radToDeg(this.state.pitch)}getViewport(){return this.state.viewport}getSize(){return[this.state.size[0],this.state.size[1]]}getBounds(e){let t=this.modules.camera;if(e!=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,[a,r]=this.state.size,l=[a+o,r+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=a=>(this.modules.styleManager.hideLayers(a),this.modules.renderer.addRerenderEvent(),this);if(n.isStyleLayerType(i)&&n.isStyleLayerHidable(i)){const a=n.convertStyleLayerTypeToHandy(i);if(a)return o({type:a})}else if(t)return o({id:t});return console.warn(`[#hideLayers] The layer with type "${i}" can't be hidden.`),this}showLayers(e){const{id:t,type:i}=e,o=a=>(this.modules.styleManager.showLayers(a),this.modules.renderer.addRerenderEvent(),this);if(n.isStyleLayerType(i)&&n.isStyleLayerHidable(i)){const a=n.convertStyleLayerTypeToHandy(i);if(a)return o({type:a})}else if(t)return o({id:t});return console.warn(`[#showLayers] The layer with type "${i}" can't be shown.`),this}setStyle(e,t){return K(this,null,function*(){let i,o=!1,a=!1;try{return typeof e=="string"?n.isStyleId(e)?(o=!this.core.state.disableStyleFallback&&Number.isNaN(this.state.handyStyleId)&&e!==n.DEFAULT_MAPGL_STYLE,i=yield this.setCustomStyleById(e,t)):i=yield this.setCustomStyleFromUrl(e,t):(yield this.setCustomStyleDirectly(e,t),i=e),a=!0,this.emit("styleload",{style:i}),i}catch(r){if(a)throw r;if(r instanceof Error&&this.emit("error",{type:"styleloaderror",style:e}),o&&!this.currentPendingStyle)return this.setStyle(n.DEFAULT_MAPGL_STYLE);throw r}})}addIcon(e,t){return e?(this.modules.styleManager.addIcon(e,t)&&this.core.activateStyleUpdating(),this):(console.error("The icon name is empty."),this)}removeIcon(e){return e?(this.modules.styleManager.removeIcon(e)&&this.core.activateStyleUpdating(),this):this}addModel(e,t){return e?(this.modules.styleManager.addModel(e,t)&&this.core.activateStyleUpdating(),this):(console.error("The model name is empty."),this)}waitForGpuToFinishDrawing(){return this.modules.identifier.readIdentifyPixels(!0),this}setLang(e){const t=n.isRtlPluginRequired(this.state.rtlPlugin.scenario,e);this.state.rtlPlugin.loadFailed&&t||(this.state.lang=e,this.state.rtlPlugin.loadFailed||n.setupMapboxRtlAdapterIfNeeded(this.state.rtlPlugin,this.modules,e).catch(i=>{throw this.state.rtlPlugin.loadFailed=!0,this.setLang(n.defaultLang),i}),this.modules.tileManager.redraw())}showLabelsDebug(e){this.modules.labelsDebug.show(e)}hideLabelsDebug(){this.modules.labelsDebug.hide()}getContainer(){return this.modules.layout.mapContainer}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:{}),a=this.getViewport(),r=this.getPadding(),l=i!=null&&i.skipMapPadding?o:jc(r,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||mi(this.state,d,{animate:!1});const _=ki([[t[0],e[1]],e,[e[0],t[1]],t],d,[c[0]-l.left-l.right,c[1]-l.top-l.bottom]);if(!_)return console.warn("Map cannot fit within canvas with the given bounds and padding."),this;const u=[(c[0]-l.left-l.right)/2+l.left+a.left,(c[1]-l.top-l.bottom)/2+l.top+a.top];let h;(i==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 kt(this.state,v,x),Et(this.state,h,g),Zi(this.state,0,x),this}update(){const e=this.state,{time:t,userHasInteracted:i}=e,o=this.values,a={};Yl.forEach(c=>{let d=e[c];c==="zoom"&&e.zoomTypePreserving==="styleZoom"&&(d=e.styleZoom),a[`${c}start`]=!o[`is${c}Changing`]&&!this.areEqual(d,o[`${c}1`])&&this.areEqual(o[`${c}1`],o[`${c}2`]),a[`${c}start`]&&(o[`is${c}Changing`]=!0),o[`is${c}Changing`]&&(a[c]=!this.areEqual(d,o[`${c}1`]),t-o[`${c}EndTime`]>nx&&(a[`${c}end`]=this.areEqual(d,o[`${c}End1`])&&!this.areEqual(o[`${c}End1`],o[`${c}End2`]),a[`${c}end`]&&(o[`is${c}Changing`]=!1),this.copyFromValuesToValues(`${c}End2`,`${c}End1`),this.copyFromStateToValues(d,`${c}End1`),o[`${c}EndTime`]=t)),this.copyFromValuesToValues(`${c}2`,`${c}1`),this.copyFromStateToValues(d,`${c}1`)}),a.resize=!this.areEqual(e.size,o.size),this.copyFromStateToValues(e.size,"size"),a.movestart=(a.zoomstart||a.rotationstart||a.centerstart||a.pitchstart)&&!o.isMoveChanging,a.movestart&&(o.isMoveChanging=!0),a.move=o.iszoomChanging||o.isrotationChanging||o.iscenterChanging||o.ispitchChanging,a.moveend=(a.zoomend||a.rotationend||a.centerend||a.pitchend)&&!a.move,a.moveend&&(o.isMoveChanging=!1);const r=o.isIdle,l=o.isReady;o.isIdle=this.isIdle(),o.isReady=this.isReady(),a.idle=!r&&o.isIdle,a.ready=!l&&o.isReady,e.metrics.ready===void 0&&this.isReadyForMetrics()&&(e.metrics.ready=performance.now()-e.metrics.start);for(const c in a){const d=c;a[d]&&this.emit(d,{isUser:i})}}isIdle(){return!this.values.isMoveChanging&&!this.currentPendingStyle&&this.core.isIdle()}isReady(){return!this.values.isMoveChanging&&!this.currentPendingStyle&&this.core.isReady()}isReadyForMetrics(){return!this.values.isMoveChanging&&!this.currentPendingStyle&&this.core.isReadyForMetrics()}setAutoHoverMode(e){this.modules.defaultSource.resetHoverId(),this.state.disableHoverStyles=!e}setStyleState(e){const{_customUserTimeOffset:t}=this.state.styleState,i=()=>{this.state.styleState._customUserTimeOffset=t};if(this.state.graphicsPresetMode){const o=Yt()?"light":e.graphicsPreset;this.state.styleState=Dn(e,this.getGraphicsPresetFeatures(o))}else this.state.styleState=Dn(e);i(),this.updateDataToggle(),this.modules.renderer.addRerenderEvent()}getStyleState(){return I({},this.state.styleState)}patchStyleState(e){if(this.state.graphicsPresetMode){const t=Yt()?"light":e.graphicsPreset;this.state.styleState=Tl(this.state.styleState,e,this.getGraphicsPresetFeatures(t))}else this.state.styleState=Tl(this.state.styleState,e);this.updateDataToggle(),this.modules.renderer.addRerenderEvent()}setOption(e,t){if(Us.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(Us.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,a=598044/(this.state.size[0]*this.state.size[1]/window.devicePixelRatio),r=[{level:0,draws:[0,500],vertcles:[0,1e6],triangles:[0,333e3]},{level:1,draws:[501,1e3],vertcles:[1000001,2e6],triangles:[3330001,666e3]},{level:2,draws:[1001,1500],vertcles:[2000001,3e6],triangles:[666001,999e3]},{level:3,draws:[1501,2500],vertcles:[3000001,6e6],triangles:[999001,2e6]},{level:4,draws:[2501,3500],vertcles:[6000001,12e6],triangles:[2000001,4e6]},{level:5,draws:[3501,1/0],vertcles:[12000001,1/0],triangles:[4000001,1/0]}],l=e*a,c=t*a,d=i*a,_=((f=r.find(v=>v.draws[0]<=l&&v.draws[1]>=l))==null?void 0:f.level)||0,u=((m=r.find(v=>v.vertcles[0]<=c&&v.vertcles[1]>=c))==null?void 0:m.level)||0,h=((p=r.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 Py.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:a,modelUrl:r}=this.state,l=n.applyDefaults(t||{},{rootUrl:o,stylePath:n.styles.path,iconsPath:i,fontsPath:a,modelsPath:r}),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 sx(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,a=n.applyDefaults(t||{},{rootUrl:`${i}//${o}`,stylePath:"",iconsPath:"",fontsPath:"",modelsPath:""});this.currentPendingStyle=`__${Date.now()}__${performance.now()}__`;const r=e&&JSON.parse(JSON.stringify(e));return this.setCustomStyle(r,a)}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 ix(e,this.state.tileKey,t);if(this.currentPendingStyle!==void 0)return;const{showCommPoi:a}=yield this.modules.tileKeyInfo.getKeyInfo(),r=this.modules.styleManager.createStyle(o,t,a);this.state.handyStyleId=r.id,this.state.styleId=i,this.patchStyleState({}),this.core.activateStyleUpdating()})}copyFromStateToValues(e,t){Ri(e)?n.copy$3(this.values[t],e):this.values[t]=e}cloneFromStateToValues(e,t){const i=this.state[e];Ri(i)?this.values[t]=n.clone(i):this.values[t]=i}copyFromValuesToValues(e,t){const i=this.values[t];Ri(i)?n.copy$3(this.values[e],i):this.values[e]=i}areEqual(e,t){return Ri(e)&&Ri(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 a=yield o.json();if(a&&a.result)return{loadedId:t,style:a.result}})}updateDataToggle(){this.modules.defaultSource.setDataType(this.state.styleState.immersiveRoadsOn?ox:void 0)}}function sx(s){return fetch(s).then(e=>{if(e.ok)return e.json()})}function Ri(s){return s.length!==void 0}const Ql={extraReplicas:[NaN,NaN],tile:[0,0,0,0],mapPoint:[0,0],geoPoint:[0,0]};class Jl 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,a,r)=>a===0||!n.exactEquals$2(r[a],r[a-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 a=this.baseOptions,r=((c=a.showAnimation)==null?void 0:c.easing)!==void 0?a.showAnimation.easing:"linear",l=((d=a.showAnimation)==null?void 0:d.duration)!==void 0?a.showAnimation.duration:250;n.start(e,{easing:r,animationGroup:(_=a.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 r,l,c,d;const a=n.affineStep(((l=(r=t.showAnimation)==null?void 0:r.durationRange)==null?void 0:l.start)||0,((d=(c=t.showAnimation)==null?void 0:c.durationRange)==null?void 0:d.end)||1,o);a!==this.length&&(this.length=a,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),a=n.splitPolylineByLength(this.points,this.distances,this.length),r=n.splitPolylineByMaxSize(a,o),l=n.create$1(),c=n.create(),d=[];for(const _ of r){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:a}=e[o];if(this.isTileReplicaVisible(a.coords)){const r=this.tileCache.objectsByPart.get(o);if(!r){for(const l of this.tileObjects)i.removeObject(l,t);return this.tileObjects=[],this.identifyIds=[],!1}i.addObject(r.tileObject,t),this.tileObjects.push(r.tileObject),this.interactive&&r.identifyIds&&this.identifyIds.push(r.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:a}=this.modules,r=o.getAccumulatedData(),l=new n.TileObject("dynamicObject",r.data,this.modules,this.mapState,e.coords,this);a.addObject(l,t),this.tileObjects.push(l),i!==void 0&&this.tileCache.objectsByPart.set(i,{tileObject:l,identifyIds:this.interactive?r.identifyIds:void 0}),this.interactive&&this.identifyIds.push(r.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:a,tile:r,mapPoint:l,geoPoint:c}=Ql;a[0]=o?i[0]-1:NaN,a[1]=o?i[i.length-1]+1:NaN,r[1]=e[1],r[2]=e[2],r[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?a[0]:h===i.length?a[1]:i[h];if(!Number.isNaN(f)){if(r[0]=e[0]+f*t,this.mapState.globeMode){if(l[0]=r[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,r))return!0}else if(n.isTileVisible(r,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}=Ql;for(const o of e){const a=o.mapPoints;if(n.Mercator.toGeo(a[0],i),t.canSee(i)||(n.Mercator.toGeo(a[a.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 Al=0,ax=-1,rx=-2,ec=3,lx=0,cx=0,dx="#3388ff",_x="#00000000",ux="#00000000";let tc=class extends Jl{constructor(e,t){var r,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:(r=this.options.color)!=null?r:dx,width:(l=this.options.width)!=null?l:ec},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:Al)),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:ec},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?_:Al))}}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:_x,width:(h=this.options.width2)!=null?h:lx},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:ax))}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:ux,width:(p=this.options.width3)!=null?p:cx},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 a=(g=(x=this.styleLayer3Id)!=null?x:this.styleLayer2Id)!=null?g:this.styleLayerId;this.initShowAnimation("polyline",a),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,a=this.points.map(u=>t(u));let r=1/0,l=a[0],c=0;for(const u of o){const h=t(this.modules.camera.flat.unproject(e),u);for(let f=0;f<a.length-1;f++){const m=a[f],p=a[f+1],v=n.getClosestPointOnLineSegment(h,m,p),x=v[0]-h[0],g=v[1]-h[1],y=x*x+g*g;y<r&&(r=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:a}=this.modules,{tileProps:r}=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(a,f,this.mapState.styleState);const m=a.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[r.beginningIsCut]=0,this.tileAttrs[r.endingIsCut]=0,l!==0&&(this.tileAttrs[r.beginningIsCut]=1),l+1!==t.length&&(this.tileAttrs[r.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:a,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 a=n.makeHandyStyleLayer(t);a&&(o.updateLayerStyle(e,a),this.modules.renderer.addRerenderEvent())}}};const hx=0,fx=-1,ic=8,nc=12,mx="#2480ff",px="#ffffff",oc=6,sc=20,vx="#ffffff00";class ac extends Jl{constructor(e,t){var o,a,r,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||mx,dashLength:(o=this.options.dashLength)!=null?o:oc,gapColor:this.options.gapColor||vx,gapLength:(a=this.options.gapLength)!=null?a:sc,width:(r=this.options.width)!=null?r:ic},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||px,width:(c=(l=this.options)==null?void 0:l.width2)!=null?c:nc},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:oc,gapColor:this.options.hiddenPartGapColor,gapLength:(_=this.options.gapLength)!=null?_:sc,width:(u=this.options.width)!=null?u:ic},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:nc},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:a,hiddenPartGapColor:r,hiddenPartDash2Color:l}=e,{dynamicStyle:c}=this.modules;if(this.dashLayer){t!==void 0&&(this.dashLayerRaw.style.color=t),o!==void 0&&(this.dashLayerRaw.style.gapColor=o);const d=n.makeHandyStyleLayer(this.dashLayerRaw);d&&c.updateLayerStyle(this.dashLayer.innerId,d)}if(this.baseLayer){i!==void 0&&(this.baseLayerRaw.style.color=i);const d=n.makeHandyStyleLayer(this.baseLayerRaw);d&&c.updateLayerStyle(this.baseLayer.innerId,d)}if(this.hiddenDashLayer&&this.hiddenDashLayerRaw){a!==void 0&&(this.hiddenDashLayerRaw.style.color=a),o!==void 0&&(this.hiddenDashLayerRaw.style.gapColor=r);const d=n.makeHandyStyleLayer(this.hiddenDashLayerRaw);d&&c.updateLayerStyle(this.hiddenDashLayer.innerId,d)}if(this.hiddenBaseLayer&&this.hiddenBaseLayerRaw){l!==void 0&&(this.hiddenBaseLayerRaw.style.color=l);const d=n.makeHandyStyleLayer(this.hiddenBaseLayerRaw);d&&c.updateLayerStyle(this.hiddenBaseLayer.innerId,d)}this.modules.renderer.addRerenderEvent()}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:a}=this;let r=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),r+=h}let d=0;const _=this.makeCtx();t.forEach((u,h)=>{const{tileInfo:f,vertices:m}=u,p=l[h];if(this.tileAttrs[a.beginningIsCut]=0,this.tileAttrs[a.endingIsCut]=0,this.tileAttrs[a.previousPointX]=0,this.tileAttrs[a.previousPointY]=0,this.tileAttrs[a.nextPointX]=0,this.tileAttrs[a.nextPointY]=0,this.tileAttrs[a.componentDistanceStart]=d,d+=p,this.tileAttrs[a.objectLength]=r,h!==0){const g=t[h-1].mapPoints,y=g[g.length-2];n.mapPointToTilePoint(c,y,f),this.tileAttrs[a.beginningIsCut]=1,this.tileAttrs[a.previousPointX]=c[0],this.tileAttrs[a.previousPointY]=c[1]}if(h!==t.length-1){const y=t[h+1].mapPoints[1];n.mapPointToTilePoint(c,y,f),this.tileAttrs[a.endingIsCut]=1,this.tileAttrs[a.nextPointX]=c[0],this.tileAttrs[a.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:hx;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:fx;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 gx="#3388ff33",yx="#3388ff",xx=3;let rc=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 a=[],{dynamicStyle:r,layers:l}=this.modules;i.forEach(v=>{o.length&&a.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||gx}});if(!c)return;r.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||yx,width:this.options.strokeWidth||xx}});v&&(_=v,r.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,a);this.generationState={polygonLayer:c,borderLayer:_,rings:i,points:o,tileAttrs:d,tileInfo:f,trianglesIndexes:p,asEcef:ye(this.mapState)},this.generate(),l.addLayer(this)}update(){if(super.update(),this.generationState===void 0)return;const e=ye(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:a,tileAttrs:r,tileInfo:l}=this.generationState;if(o.length===0)return;const{dynamicStyle:c,collector:d,tileManager:_,identifier:u}=this.modules,h=ye(this.mapState),f=n.ecefDataStateFromBool(h),m=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedTileProps,r,n.emptyFeatureAttrs,this.interactive?"0":"",h?l:void 0,f);n.runPrecomputes(e,m);const p=n.create$1(),v=[],x=[],g=[];for(let T=0;T<a.length;T+=3){for(let S=0;S<3;S++)n.mapPointToTilePoint(p,o[a[T+S]],l),v[S]=p[0],x[S]=p[1],g[S]=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),c.getStyle().rasterSets]})}t&&(n.runPrecomputes(t,m),i.forEach(T=>{const S=[],L=[];T.forEach((E,R)=>{n.mapPointToTilePoint(p,E,l),S[R]=p[0],L[R]=p[1]}),n.generateSafely({collector:d,generator:n.LineGenerator.generate,args:[c.getStyle().id,t,m,l,{x:S,y:L}]})}));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 bx="#3388ff33",wx="#3388ff",Sx=1,Tx=150;let lc=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,a=Mx(n.Mercator.fromGeo(this.options.coordinates),n.geoToMapDistance(this.options.coordinates,this.options.radius),(v=this.options.segments)!=null?v:Tx);this.isGeometryOutOfMainReplica=a.some(b=>b[0]>n.HALF_WORLD_SIZE||b[0]<-n.HALF_WORLD_SIZE);const r=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:bx,strokeWidth:(g=this.options.borderWidth)!=null?g:Sx,strokeColor:(y=this.options.borderColor)!=null?y:wx}});if(!r)return;i.addLayer(r,this.options.zIndex),this.layerId=r.innerId;const l=n.optionsToTileAttrs({db_tiers:this.options.tiers}),c=n.create();for(let b=0;b<a.length;b++)n.expandByPoint(c,a[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<a.length;b++)n.mapPointToTilePoint(m,a[b],_),u[b]=m[0],h[b]=m[1],f[b]=p;this.generationState={circleLayer:r,asEcef:ye(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=ye(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:a,collector:r,tileManager:l,identifier:c}=this.modules,d=ye(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:r,generator:n.PolygonGenerator.generate,args:[a.getStyle().id,e,u,o,n.pixelRatioToDpi(window.devicePixelRatio)]});const h=r.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),r.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 Mx(s,e,t){const i=[];if(t>0){i.push(n.fromValues(s[0]+e,s[1],s[2]));const o=Math.PI/Math.ceil(t/2);for(let a=o;a<Math.PI;a+=o){const r=e*Math.cos(a),l=e*Math.sin(a);i.push(n.fromValues(s[0]+r,s[1]+l,s[2]),n.fromValues(s[0]+r,s[1]-l,s[2]))}i.push(n.fromValues(s[0]-e,s[1],s[2]))}return i}function Cs(s,e,t,i,o,a){if(o-i<=t)return;const r=i+o>>1;cc(s,e,r,i,o,a%2),Cs(s,e,t,i,r-1,a+1),Cs(s,e,t,r+1,o,a+1)}function cc(s,e,t,i,o,a){for(;o>i;){if(o-i>600){const d=o-i+1,_=t-i+1,u=Math.log(d),h=.5*Math.exp(2*u/3),f=.5*Math.sqrt(u*h*(d-h)/d)*(_-d/2<0?-1:1),m=Math.max(i,Math.floor(t-_*h/d+f)),p=Math.min(o,Math.floor(t+(d-_)*h/d+f));cc(s,e,t,m,p,a)}const r=e[2*t+a];let l=i,c=o;for(Fi(s,e,i,t),e[2*o+a]>r&&Fi(s,e,i,o);l<c;){for(Fi(s,e,l,c),l++,c--;e[2*l+a]<r;)l++;for(;e[2*c+a]>r;)c--}e[2*i+a]===r?Fi(s,e,i,c):(c++,Fi(s,e,c,o)),c<=t&&(i=c+1),t<=c&&(o=c-1)}}function Fi(s,e,t,i){Ps(s,t,i),Ps(e,2*t,2*i),Ps(e,2*t+1,2*i+1)}function Ps(s,e,t){const i=s[e];s[e]=s[t],s[t]=i}function Ex(s,e,t,i,o,a,r){const l=[0,s.length-1,0],c=[];let d,_;for(;l.length;){const u=l.pop(),h=l.pop(),f=l.pop();if(h-f<=r){for(let v=f;v<=h;v++)d=e[2*v],_=e[2*v+1],d>=t&&d<=o&&_>=i&&_<=a&&c.push(s[v]);continue}const m=Math.floor((f+h)/2);d=e[2*m],_=e[2*m+1],d>=t&&d<=o&&_>=i&&_<=a&&c.push(s[m]);const p=(u+1)%2;(u===0?t<=d:i<=_)&&(l.push(f),l.push(m-1),l.push(p)),(u===0?o>=d:a>=_)&&(l.push(m+1),l.push(h),l.push(p))}return c}function Ix(s,e,t,i,o,a){const r=[0,s.length-1,0],l=[],c=o*o;for(;r.length;){const d=r.pop(),_=r.pop(),u=r.pop();if(_-u<=a){for(let v=u;v<=_;v++)dc(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];dc(f,m,t,i)<=c&&l.push(s[h]);const p=(d+1)%2;(d===0?t-o<=f:i-o<=m)&&(r.push(u),r.push(h-1),r.push(p)),(d===0?t+o>=f:i+o>=m)&&(r.push(h+1),r.push(_),r.push(p))}return l}function dc(s,e,t,i){const o=s-t,a=e-i;return o*o+a*a}const Cx=s=>s[0],Px=s=>s[1];class Lx{constructor(e,t=Cx,i=Px,o=64,a=Float64Array){this.nodeSize=o,this.points=e;const r=e.length<65536?Uint16Array:Uint32Array,l=this.ids=new r(e.length),c=this.coords=new a(e.length*2);for(let d=0;d<e.length;d++)l[d]=d,c[2*d]=t(e[d]),c[2*d+1]=i(e[d]);Cs(l,c,o,0,l.length-1,0)}range(e,t,i,o){return Ex(this.ids,this.coords,e,t,i,o,this.nodeSize)}within(e,t,i){return Ix(this.ids,this.coords,e,t,i,this.nodeSize)}}function Bx(s,e,t){const i=[],o=[],a=[],r=n.create$1();return e.forEach(({mapCoords:l,weight:c})=>{zx(r,l,t);const d=r[0],_=r[1];for(let u=0;u<6;u++)i.push(d,_),a.push(c);o.push(-1,-1,1,-1,-1,1,-1,1,1,-1,1,1)}),{vertices:s.createBuffer(new Uint16Array(i),{itemSize:2,dataType:n.Buffer.UnsignedShort,stride:0,offset:0,normalized:!0}),widens:s.createBuffer(new Int8Array(o),{itemSize:2,dataType:n.Buffer.Byte,stride:0,offset:0,normalized:!1}),weights:s.createBuffer(new Float32Array(a),{itemSize:1,dataType:n.Buffer.Float,stride:0,offset:0,normalized:!1})}}function zx(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 Rx(s,e){const t=Fx(s),i=Dx(t,e);return new w(new Uint8Array(i),{size:[e,1]})}function Fx(s){const e=new Error("The palette is not valid. The heatmap won't be rendered."),t=Object.getOwnPropertyNames(s);if(t.length===0)throw e;const i=t.map(l=>Number(l));if(i.some(l=>Number.isNaN(l)||l<0||l>1))throw e;const o={};i.forEach(l=>{if(typeof s[l]!="string")throw e;o[l]=n.handyColor(s[l])});const a=Math.min(...i),r=Math.max(...i);return a>0&&(o[0]=o[a]),r<1&&(o[1]=o[r]),o}function Dx(s,e){const t=Object.keys(s).map(r=>Number(r)).sort((r,l)=>r-l);let i=0;const o=[],a=e-1;for(let r=0;r<e;r++){const l=r/a;l>t[i+1]&&i++;const c=t[i],d=t[i+1],_=d-c,h=(l-c)/_;for(let f=0;f<4;f++)o[r*4+f]=Nx(s[c].value[f],s[d].value[f],h)}return o.map(r=>Math.round(r))}function Ox(s,e){return s.every((t,i)=>t===e[i])}function Nx(s,e,t){return s*(1-t)+e*t}const kx=256,Ux=.5,Hx=3,Gx=10,Vx=1,jx=1,Zx={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 Wx 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&&Ox(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(T=>this.points[T]),b=n.createTileInfo(v);this.buffers=Bx(this.modules.renderer,y,b),this.vertexCount=y.length*6,this.vao=new G(m,{a_vec2_position:this.buffers.vertices,a_vec2_widen:this.buffers.widens,a_float_weight:this.buffers.weights})},this.resizeFrameBuffer=()=>{this.frameBuffer.setSize([Math.ceil(this.mapState.size[0]*window.devicePixelRatio/this.downscale),Math.ceil(this.mapState.size[1]*window.devicePixelRatio/this.downscale)]),this.modules.renderer.bindRenderTarget(this.frameBuffer),this.modules.renderer.bindRenderTarget(null);const m=this.frameBuffer.getTexture();m?this.modules.imageManager.updatePreparedTexture(this.offscreenTextureIndex,m):n.log("Can't update a non-prepared texture"),this.heatmapNeedRerender=!0,this.modules.renderer.addRerenderEvent()};const{downscale:i,palette:o,points:a,minZoom:r,maxZoom:l,zIndex:c,pointRadius:d,intensity:_,opacity:u}=t;this.rampTextureIndex=this.modules.imageManager.addPreparedTexture(Rx(o!=null?o:Zx,kx)),this.downscale=i!=null?i:jx,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:r,maxzoom:l,style:{opacity:u!=null?u:Ux,intensity:_!=null?_:Hx,radius:d!=null?d:Gx}});if(!f)throw new Error("There is no correct style layer for heatmap");this.layer=f,this.modules.dynamicStyle.addLayer(f,c),a&&this.setPoints(a)}isOutOfMainReplica(){return!1}setPoints(e){if(!this.isDestroyed){if(this.points=e.map(({coordinates:t,weight:i})=>({mapCoords:n.Mercator.fromGeo(t),weight:i!=null?i:Vx})),this.tree=new Lx(this.points,t=>t.mapCoords[0],t=>t.mapCoords[1]),this.tileCoords=void 0,!this.tileObjects.length){const{layers:t,collector:i,dynamicStyle:o,tileManager:a}=this.modules;n.generateSafely({collector:i,generator:n.HeatmapGenerator.generateTexture,args:[o.getStyle().id,this.layer,this.offscreenTextureIndex,this.rampTextureIndex]});const r=i.getAccumulatedData(),l=new n.TileObject("dynamicObject",r.data,this.modules,this.mapState);a.addObject(l),this.tileObjects.push(l),t.addLayer(this),i.reset()}this.modules.renderer.addRerenderEvent(),this.heatmapNeedRerender=!0}}update(){super.update();const e=this.modules.renderer.getShaderProgram("heatmap",this.modules.renderer.commonShaderDefines);if(this.sizeDiffer.check(this.mapState)&&this.resizeFrameBuffer(),!this.heatmapNeedRerender&&!this.viewDiffer.check(this.mapState)&&!this.modules.renderer.isNeedRerender()||!this.tree)return;const{zoom:t,styleZoom:i,styleState:o}=this.mapState;if(this.modules.renderer.resetStateAfterExternalRender(),this.throttledFillBuffer(e),!this.vao||!this.buffers||!this.tree||!this.tileCoords)return;const a=n.makeBinderContext(i,o,[]),r=n.resolveNumber(this.layer.style.radius,a),l=n.resolveNumber(this.layer.style.intensity,a),c=n.tileSizeZpt*Math.pow(2,t-this.tileCoords[2])*window.devicePixelRatio;this.modules.renderer.enableShaderProgram(e),this.modules.renderer.isUboSupported()||ta(e,this.mapState,this.modules),this.modules.renderer.bindShaderProgram(e,{u_mat4_mvp:n.mul$1(this.mvpMatrix,this.modules.camera.viewProjectionMatrix,this.matrix),u_mat4_model:this.matrix,u_float_radius:r*window.devicePixelRatio,u_float_intensity:l,u_float_tile_to_pixel_ratio:1/c}),this.modules.renderer.bindVao(this.vao),this.modules.renderer.setViewport(0,0,Math.ceil(this.mapState.size[0]*window.devicePixelRatio/this.downscale),Math.ceil(this.mapState.size[1]*window.devicePixelRatio/this.downscale)),this.modules.renderer.bindRenderTarget(this.frameBuffer),this.modules.renderer.clearWithColor([0,0,0,0],!1),this.modules.renderer.applyGpuState(Ca),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 $x="#000000",Xx=0,Kx="#ffffff",qx=0,_c=[0,0],Yx=0,Qx=[0,0,0,0],Ls=-1;class Bs extends Ye{constructor(e,t,i){var V,P,F,se,Y,z,ae,we,Se,Ke,Ze,We,zt;super(e,{interactive:(V=t.interactive)!=null?V:!1},i),this.hovered=!1,this.lastLabelingRevision=Ls,this.imageLabelBoxAdjusted=!1,this.generationId=0,this.status="visible",this.labelingStatus=0,this.options=t,this.labelKey=`point-label-${this.uniqId}`;const o=(P=t.font)!=null?P:n.DEFAULT_FONT,a=(F=t.fontSize)!=null?F:n.fonts.baseSize,r=(se=t.letterSpacing)!=null?se:qx,l=(Y=t.lineHeight)!=null?Y:n.fonts.baseLineHeight,c=[(ae=(z=this.options.offset)==null?void 0:z[0])!=null?ae:_c[0],(Se=(we=this.options.offset)==null?void 0:we[1])!=null?Se:_c[1]],d=n.makeHandyStyleLayer({type:"point",id:`dynamic-pointLabel-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,interactive:this.interactive,style:{textFont:o,textFontSize:a,textColor:(Ke=t.color)!=null?Ke:$x,textHaloWidth:(Ze=t.haloRadius)!=null?Ze:Xx,textHaloColor:(We=t.haloColor)!=null?We:Kx,textLetterSpacing:r,textLineHeight:l,textOffset:c,allowElevation:!0}}),_=n.Mercator.fromGeo(this.options.coordinates);if(this.position={userValue:_,normalizedValue:n.normalizeMapPoint(_)},!d)return;const{dynamicStyle:u,collector:h,assetManager:f,styleManager:m,tileManager:p,layers:v,defaultSource:x}=this.modules,g=(zt=this.options.zIndex)!=null?zt:Yx;u.addLayer(d,g);const y=n.optionsToTileAttrs({db_label:this.options.text}),b=n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),T={x:[0],y:[0]},S=n.makeGeneratorContext(this.mapState.styleState,n.emptySourceAttrs,n.fixedMetatile.tileProps,y,n.emptyFeatureAttrs,this.interactive?"0":"");n.runPrecomputes(d,S),n.generateSafely({collector:h,generator:n.preLabelingPoint,args:[u.getStyle(),d,S,n.fixedMetatile,n.LATEST_TILE_VERSION,b,x.getId(),T,n.pixelRatioToDpi(window.devicePixelRatio)]});const L=h.getAccumulatedData();if(!L.labels.length)return;const E=[{metatileHash:-1,labels:L.labels,styleId:u.getStyle().id}],R=n.unpackPreLabelingResult(E,n.LabelSource.DynamicObject,m,this.mapState.styleState,this.mapState.styleZoom);if(R.length!==1)return;const H=R[0];n.rtlAdapterPromise.then(()=>{var Pe;H.label=(Pe=n.processRTLTextIfNeeded(H.label))!=null?Pe:"",H.updateRanges()}).then(()=>Promise.all(H.ranges.map(Pe=>f.loadFont(o,Pe)))).then(()=>{if(this.status==="destroyed")return;H.textMetrics=n.getTextMetrics(H.label,r,f.getFontGlyphs(o));const Pe=Jx(t.anchor),Rt=a/n.fonts.baseSize,Te=a*l*H.textMetrics.lines.length,Ft=Rt*H.textMetrics.maxWidth,Mt=[-Ft*(Pe[0]-.5),-Te*(Pe[1]-.5)],[qt,$e]=c,hi=[qt+Mt[0],$e+Mt[1]];this.generationState={label:H,styleLayer:d,elementOffset:hi,textFont:o,textOffset:c,anchorOffset:Mt,labelMaxWidthInPx:Ft,labelHeightInPx:Te,asEcef:ye(this.mapState)};const Ni=this.generateTextTileObject(this.generationState);v.addLayer(this),this.interactive&&(this.identifyIds.push(L.identifyIds),this.modules.identifier.resetCache()),this.options.labeling&&this.options.labeling.type!=="none"?(this.labelBox={id:this.uniqId,width:Ft,height:Te,position:this.position.normalizedValue,offset:[hi[0]-Pe[0]*Ft,hi[1]-Pe[1]*Te],labelingGroup:"pointLabel"},this.addLabelToLabeler(),this.update()):this.status==="visible"&&p.addObject(Ni),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),zs(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=ye(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(a=>a.children.forEach(r=>{r.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:a,styleLayer:r,textFont:l}=e,c=this.getTransformPosition();n.generateSafely({collector:t,generator:n.generateTextElement,args:[o,"",1,o.textMetrics,[0,0,0],0,a,r,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(ye(this.mapState)),zs(u,this.position.userValue[2]),this.tileObjects.push(u),t.reset(),u}getTransformPosition(){if(!ye(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 V,P;if(!this.options.image||this.generationState===void 0)return;const{imageCache:t,dynamicStyle:i,collector:o,tileManager:a}=this.modules,r=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||Qx,g=(d+x+p)*r,y=(_+m+v)*r,b=((p-x)/2+u[0]+h[0])*r,T=((v-m)/2+u[1]+h[1])*r,S=(V=this.options.image.stretchX)==null?void 0:V.map(([F,se])=>[F*r,se*r]),L=(P=this.options.image.stretchY)==null?void 0:P.map(([F,se])=>[F*r,se*r]),E=this.getTransformPosition();n.generateSafely({collector:o,generator:n.generateIconElement,args:[f,"",[0,0,0],0,c,g,y,b,T,window.devicePixelRatio,S,L,E]});const R=o.getAccumulatedData();o.reset();const H=new n.TileObject("dynamicObject",R.data,this.modules,this.mapState,n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this);H.ecefDataState=n.ecefDataStateFromBool(ye(this.mapState)),zs(H,this.position.userValue[2]),this.tileObjects.push(H),this.status!=="hidden"&&!this.labelBox&&a.addObject(H),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&&(a.addObject(H),this.mapState.needRerender=!0),this.lastLabelingRevision=Ls)})}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=Ls)}removeLabelFromLabeler(){this.labelBox&&this.modules.labeler.removeLabels(this.labelKey)}}function Jx(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 zs(s,e){s.modelMatrices.forEach(t=>{t[14]=e})}const Ax=18,eb=[.5,.5],tb=[0,18],ib=0,nb=0;let uc=class extends Gs{constructor(e,t){super(e,t,t.draggable),this.generatedAsEcef=!1,this.map=e,this.options=t;const{coordinates:i,size:o,zIndex:a,minZoom:r,maxZoom:l,hoverIcon:c,hoverSize:d,hoverAnchor:_,label:u,rotation:h,opacity:f,hoverOpacity:m}=t;this.status="normal";const p=n.Mercator.fromGeo(i);this.position={userValue:p,normalizedValue:n.normalizeMapPoint(p)},this.rotation=n.degToRad(h!=null?h:nb),this.zIndex=a!==void 0?a:ib,this.minZoom=r!=null?r:-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=ye(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"&&(hc({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}hc({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,a,r;this.status!=="destroyed"&&((t=this.label)==null||t.remove(),e&&(this.label=new Bs(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:(a=e.fontSize)!=null?a:Ax,anchor:e.anchor||eb,offset:e.offset||tb,zIndex:(r=e.zIndex)!=null?r: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(ye(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,a=t!==void 0?t.anchor:i.anchor,r=this.modules.camera.flat.project(this.position.normalizedValue),l=r[0]-o[0]*a[0],c=r[0]+o[0]*(1-a[0]),d=r[1]-o[1]*a[1],_=r[1]+o[1]*(1-a[1]);return e[0]>l&&e[0]<c&&e[1]>d&&e[1]<_}switchToHoveredStyle(){if(this.status==="normal"&&this.hoverStateData&&this.normalStateData){const{tileManager:e}=this.modules;e.removeObject(this.normalStateData.tileObject),e.addObject(this.hoverStateData.tileObject),this.status="hover",this.modules.renderer.addRerenderEvent()}this.label&&(this.label.hovered=!0,this.modules.renderer.addRerenderEvent())}switchToNormalStyle(){if(this.status==="hover"&&this.normalStateData&&this.hoverStateData){const{tileManager:e}=this.modules;e.removeObject(this.hoverStateData.tileObject),e.addObject(this.normalStateData.tileObject),this.status="normal",this.modules.renderer.addRerenderEvent()}this.label&&(this.label.hovered=!1,this.modules.renderer.addRerenderEvent())}getMarkerStateData(e,{icon:t,anchor:i,size:o,opacity:a}){const{zIndex:r,position:l}=this,{collector:c,dynamicStyle:d,styleManager:_,defaultSource:u}=this.modules,h=n.optionsToTileAttrs({dpi:window.devicePixelRatio*96}),f=n.mapPointTo32ZoomTileCoords(l.normalizedValue),m=typeof this.position.userValue[2]=="number"?this.position.userValue[2]:0,p=n.makeHandyStyleLayer({type:"point",id:`dynamic-marker-${this.uniqId}`,minzoom:this.minZoom,maxzoom:this.maxZoom,style:{iconImage:t,iconAnchor:i,iconRotation:this.rotation,iconOpacity:a,elevation:m}});if(!p)throw new Error(`Marker with icon ${t} was created with null style layer`);const v=n.resolveSimpleLiteralExpression(p.style.iconAnchor);d.addLayer(p,r),d.appendRasterSet(e,n.getStaticIconRasterSetKey(t,v[0],v[1]));const 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}],T=n.unpackPreLabelingResult(b,n.LabelSource.DynamicObject,_,this.mapState.styleState,this.mapState.styleZoom);if(T.length!==1)throw new Error(`Marker with icon ${t} has empty unpacked labels`);const S=T[0],L=n.createTileInfo(f),E=ye(this.mapState)?(V,P)=>n.encodeTilePointToEcefU16(L,V,P):void 0;n.generateNotStretchableIconElement(c,S,"",[0,0,m],0,e.rasters[0],window.devicePixelRatio,E);const{data:R}=c.getAccumulatedData();c.reset();const H=new n.TileObject("dynamicObject",R,this.modules,this.mapState,f,this);return H.ecefDataState=n.ecefDataStateFromBool(ye(this.mapState)),{styleLayer:p,tileObject:H,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)),ye(this.mapState)!==this.generatedAsEcef&&this.setLabel(this.options.label)}};function hc(s,e){var t,i,o,a,r,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])!==((a=e.anchor)==null?void 0:a[1])||((r=s.size)==null?void 0:r[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 ob=n.inferGeneratorType({symbol:"polygon",sinks:{fill:{stride:8,binder:(s,e)=>{s.views.position=new Uint16Array(e),s.views.localID=new Uint32Array(e,4)},packObjectAttributes(s,e,t){return n.createObjectAttributesArray([s,e.innerId],e,t)},unpackObjectAttributes(s){return{styleId:s[0],layerId:s[1],tileData:s.slice(2)}}}},generate(s,e,t,i,o){const a=o.x,r=o.y,l=s.idIndexer.getIndex(i,e,t),c=n.resolveExpression(t.ignoreTier,i)?null:i.tileAttrs[i.tileProps.db_tiers],d=s.getBucket(t.type,"fill",n.PolygonGenerator.sinks.fill.packObjectAttributes(e,t,c,"","",i),n.PolygonGenerator.sinks.fill.binder);let _=d.elements.offset;sb(d.indices,_,0,1,2,2,1,3),Xn(d,_++,a[0],r[0],l),Xn(d,_++,a[1],r[1],l),Xn(d,_++,a[2],r[2],l),Xn(d,_++,a[3],r[3],l),d.elements.offset=_}});function Xn(s,e,t,i,o){const a=e*4;s.views.position[a]=n.tileCoordOffset+t,s.views.position[a+1]=n.tileCoordOffset+i;const r=e*2;s.views.localID[r]=o}function sb(s,e,t,i,o,a,r,l){const c=s.buffer,d=s.offset;c[d]=e+t,c[d+1]=e+i,c[d+2]=e+o,c[d+3]=e+a,c[d+4]=e+r,c[d+5]=e+l,s.offset=d+6}const ab="#0085a0";class rb extends Ye{constructor(e,t){super(e,t),this.isGeometryOutOfMainReplica=!1;const{dynamicStyle:i,collector:o,tileManager:a,identifier:r,layers:l}=this.modules;this.options=t,this.points=[];const c=n.makeHandyStyleLayer({type:"polygon",id:`dynamic-polygon-${this.uniqId}`,minzoom:this.options.minZoom,maxzoom:this.options.maxZoom,style:{color:this.options.color||ab}});if(!c)return;i.addLayer(c,this.options.zIndex),this.layerId=c.innerId;const d=n.optionsToTileAttrs({db_tiers:t.tiers});this.points=lb(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:ob.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);a.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&&r.resetCache()}destroy(){this.layerId!==void 0&&this.modules.dynamicStyle.removeLayer(this.layerId),this.options.interactive&&this.modules&&this.modules.identifier.resetCache(),super.destroy()}isOutOfMainReplica(){return this.isGeometryOutOfMainReplica}}function lb(s,e,t){const i=e/2,o=t/2,a=s[0],r=s[1],l=s[2];return[[a-i,r-o,l],[a+i,r-o,l],[a-i,r+o,l],[a+i,r+o,l]]}let fc=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(a=>{this.textureIndex=a,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=cb(this.options.bounds),this.isGeometryOutOfMainReplica=this.points.some(p=>p[0]>n.HALF_WORLD_SIZE||p[0]<-n.HALF_WORLD_SIZE);const a=n.create();for(let p=0;p<this.points.length;p++)n.expandByPoint(a,this.points[p]);const r=n.getBoundsTileCoords(a),l=n.createTileInfo(r),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,r,this);i.addObject(f),this.tileObjects.push(f),o.addLayer(this),e.reset(),this.modules.renderer.addRerenderEvent()}clean(){const e=this.tileObjects[0];e&&(e.clean(this.mapState),this.modules.tileManager.removeObject(e),this.modules.layers.removeLayer(this),this.tileObjects=[])}};function cb(s){const{min:e,max:t}=n.fromGeo(s);return[e,[t[0],e[1]],[e[0],t[1]],t]}class db{constructor(e,t,i){this.id=e,this.modules=t,this.options=i,this.type="raster",this.textureIndices={},this.tileLoader=new n.BaseTileLoader("arrayBuffer"),this.attributes={},this.tiles=new Map,this.sourceAttrs=i.attributes||{},this.url=o=>{const[a,r,l]=n.tileCoordsToOSM(o),{min:c,max:d}=n.getTileBounds(o),_={southWest:[c[0],c[1]].map(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(a,r,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 r=this.modules.sourceStorage.getSourceById(this.id);(r==null?void 0:r.type)==="raster"&&this.modules.map.emit("error",{type:"rasterTileLoadError",tileCoords:n.tileCoordsToOSM(e),tileUrl:i,source:r,responseMessage:o.error.message,responseStatus:o.error.status})}return o.rejected||this.tiles.set(t,o.data),[{regionId:0,metatileHash:-1}]})}generateTile(e,t){return K(this,null,function*(){const i=[],o=[],a=this.modules.styleManager.getStyle(e.handyStyleId),r=n.coordsToKey(t),l=this.tiles.get(r);if(!l||!a)return Promise.resolve({results:i,transferable:o});const c=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[r]=c;const d=[],_=[],u=n.create$1(),h=_b(n.tileCoordsToMapPoint(t),n.tileZoomToSize(t[2])),f=n.createTileInfo(t);for(let v=0;v<h.length;v++)n.mapPointToTilePoint(u,h[v],f),d[v]=u[0],_[v]=u[1];const m=n.makeGeneratorContext(e.styleState,this.sourceAttrs,n.fixedTileProps,[],n.emptyFeatureAttrs);a.layers.filter(v=>v.type==="raster"&&n.resolveExpression(v.filter,m)).forEach(v=>{n.runPrecomputes(v,m),n.generateSafely({collector:this.modules.collector,generator:n.RasterGenerator.generate,args:[{x:d,y:_},a.id,m,v,c,null]})});const p=this.modules.collector.getAccumulatedData();return i.push({regionId:0,metatileHash:0,styleId:a.id,collectorOutput:p}),o.push(...p.transferable),this.modules.collector.reset(),Promise.resolve({results:i,transferable:o})})}getAttributes(){return this.attributes}setAttributes(e){this.attributes=e}destroy(){this.tileLoader.destroy()}}function _b(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 mc=class{constructor(e,t,i){var r,l;this.type="raster",this.id=n.sourceUuid(),this.modules=e.modules,this.source=new db(this.id,this.modules,t);const o=(r=t.minZoom)!=null?r:n.MAP_DEFAULTS.minZoom,a=(l=t.maxZoom)!=null?l:n.MAP_DEFAULTS.maxZoom;this.layer=new n.TileLayer(o,a,o,a,this.modules,e.state,this.source),this.modules.tileManager.addTileLayer(this.layer),this.modules.sourceStorage.addSource(this),this.mapglApiSource=i}destroy(){this.source.deleteTextures(),this.modules.tileManager.removeTileLayer(this.layer),this.modules.sourceStorage.removeSource(this.getId()),this.layer.destroy()}getAttributes(){return this.source.getAttributes()}getZoomDirection(){return this.layer.getZoomDirection()}getId(){return this.source.id}setAttributes(e){this.source.setAttributes(e),this.layer.redraw()}isIdentifiedAsDefault(){return!1}};const ub=0;class hb extends Ye{constructor(e,t){var r;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=(r=t.zIndex)!=null?r:ub,this.isDestroyed=!1,this.labelKey=`onlineMarker-${this.uniqId}`;const o=this.options.floorId?e.modules.floorManager.getFloorObjectElevation(this.options.floorId,!0):0,a=t.elevation?t.elevation*n.Mercator.scaleFactor(t.coordinates[1])*n.MAP_POINTS_IN_METER:0;this.elevation=a+o,this.actualIcon=t.icon,this.setIcon(t.icon)}destroy(){this.isDestroyed=!0,this.modules.identifier.resetCache(),this.modules.labeler.removeLabels(this.labelKey),super.destroy()}isOutOfMainReplica(){return!1}setIcon(e){this.actualIcon=e;const{url:t,transformer:i,size:o,anchor:a}=e;this.modules.imageCache.getRasterSet(t,i,o,a).then(r=>{if(this.isDestroyed||!r||this.actualIcon!==e)return;this.removeIcon();const l=n.makeHandyStyleLayer({type:"point",id:`dynamic-onlineMarker-${this.uniqId}`,minzoom:-1/0,maxzoom:1/0,style:{iconImage:t,iconAnchor:a}}),c=n.optionsToTileAttrs({}),{collector:d,dynamicStyle:_,styleManager:u,defaultSource:h}=this.modules,f=this.zIndex;if(!l)return;const m=n.resolveSimpleLiteralExpression(l.style.iconAnchor);_.addLayer(l,f),_.appendRasterSet(r,n.getStaticIconRasterSetKey(t,m[0],m[1]));const p=n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),v={x:[0],y:[0]},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 T=[{metatileHash:-1,labels:b,styleId:_.getStyle().id}],S=n.unpackPreLabelingResult(T,n.LabelSource.DynamicObject,u,this.mapState.styleState,this.mapState.styleZoom);if(S.length!==1)return;const L=S[0],E=n.createTileInfo(p),R=ye(this.mapState)?(P,F)=>n.encodeTilePointToEcefU16(E,P,F):void 0;n.generateNotStretchableIconElement(d,L,"",[0,0,this.elevation],0,r.rasters[0],window.devicePixelRatio,R);const H=d.getAccumulatedData();d.reset();const V=new n.TileObject("dynamicObject",H.data,this.modules,this.mapState,n.mapPointTo32ZoomTileCoords(this.position.normalizedValue),this);V.ecefDataState=n.ecefDataStateFromBool(ye(this.mapState)),this.tileObjects.push(V),this.identifyIds=[y],this.modules.tileManager.addObject(V),this.modules.layers.addLayer(this),this.modules.identifier.queryFillCache(),this.modules.labeler.removeLabels(this.labelKey),this.modules.labeler.addLabelBox(this.labelKey,{id:this.uniqId,width:o[0],height:o[1],position:this.position.normalizedValue,offset:[-a[0],-a[1]],labelingGroup:"marker"}),this.modules.renderer.addRerenderEvent()})}update(){super.update();const e=ye(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 fb(s,e,t,i,o,a){return{type:s,maxDetailLevel:a,minDetailLevel:o,maxZoomLevel:i,minZoomLevel:t,zoomLevel:Math.floor(e),tiles:{},viewportTiles:[],useExtendedTilesBounds:!1}}function mb(s){s.tiles={},s.viewportTiles=[]}function pb(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 vb(s,e,t,i,o){return fb("data",s,e,t,i,o)}function gb(s,e,t,i){if(s.zoomLevel<s.minZoomLevel){s.viewportTiles=[];return}const o=n.clamp(s.zoomLevel,s.minZoomLevel,s.maxZoomLevel),a=n.clamp(s.zoomLevel,s.minDetailLevel,s.maxDetailLevel);s.viewportTiles=n.findVisibleTiles(e,t,o,s.minZoomLevel,a,void 0,void 0,void 0,s.useExtendedTilesBounds).map(n.coordsToKey);for(let r=0;r<s.viewportTiles.length;r++){const l=s.viewportTiles[r];let c=s.tiles[l];c||(c=s.tiles[l]=i(n.keyToCoords(l)))}}function yb(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 xb(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 bb(s,e){const t=new Set(s.viewportTiles),i=[];for(const o in s.tiles){const a=s.tiles[o];!t.has(o)&&!0&&i.push(a)}return i}class wb extends n.Evented{constructor(e,t,i){super(),this.prevZoomLevel=0,this.mapState=e,this.modules=t,this.config=i,this.gridState=vb(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(){mb(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,gb(this.gridState,this.mapState,this.modules,pb),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(yb(this.gridState)),this.abortFetch(xb(this.gridState)),this.clearTiles(bb(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 Sb=Object.freeze(Object.defineProperty({__proto__:null,Benchmark:jn,Circle:lc,CircleMarker:Vs,DashedPolyline:ac,DataTileLayer:wb,DefaultSource:vl,DynamicObject:Ye,Entrance:fs,GeoJsonSource:n.GeoJsonSource,GeoJsonTileSource:n.GeoJsonTileSource,GeoJsonViewportSource:n.GeoJsonViewportSource,GltfModel:xs,Heatmap:Wx,HtmlMarker:_s,LinePatternType:n.LinePatternType,Map:Is,MapClass:Is,Marker:uc,OnlineMarker:hb,PointLabel:Bs,Polygon:rc,Polyline:tc,Raster:fc,RasterTileSource:mc,Rect:rb,ZenithSource:to,config:n.index,linePatternFromString:n.linePatternFromString,mapglUtils:kc,utils:Nc},Symbol.toStringTag,{value:"Module"})),Tb="topRight";class Wt{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:Tb,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 $t={root:"mapgl_QEdaFvncPWE-",button:"mapgl_mjx-K8iaDdc-",zoomIn:"mapgl_zKZCVsRur9c-",zoomOut:"mapgl_3t-wJELDATg-"},Mb=`
    <div class="${$t.root}">
        <button type="button" class="${$t.button} ${$t.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="${$t.button} ${$t.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 pc extends Wt{constructor(e,t){super(e,Mb,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(`.${$t.zoomIn}`),this._zoomOutButton=this._wrap.querySelector(`.${$t.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 Xt={root:"mapgl_ON-gf73kIU0-",button:"mapgl_mWyZxMObEi8-",none:"mapgl_FwnEmRmDBLg-",easy:"mapgl_uSuUHuf71nM-",medium:"mapgl_LdqAv9Ly624-",hard:"mapgl_udRZCM1quWE-"},Eb=`<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 vc extends Wt{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()?Ib(this._score):Xt.none,t=`
            <div class="${Xt.root}">
                <button type="button" class="${Xt.button} ${e}">
                    ${this._map.isTrafficOn()&&this._score!==void 0?this._score:Eb}
                </button>
            </div>
        `;this._wrap.innerHTML=t,this._wrap.querySelector(`.${Xt.button}`).addEventListener("click",this._onClick)}}function Ib(s){return s===void 0?"":s>6?Xt.hard:s>3?Xt.medium:Xt.easy}const Kn={container:"mapgl_K-1Yb8HCVpQ-",logos:"mapgl_CLps5xx6CNs-"};var gc=(s=>(s.osm="osm",s.api="api",s.license="license",s))(gc||{});const Cb=`<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>`,Pb=`<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>`,yc=s=>`
    <div class=${Kn.container}>
        <div class=${Kn.logos}>
            ${s==="2gis"?Cb:Pb}
        </div>
    </div>
`,Lb=200,Nt=.4,Bb=6.9,zb={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 Rb extends Wt{constructor(e,t){super(e,yc(t.copyrightType),t),this._copyrightType="2gis",this._isHidden=!1,this._onViewportchange=()=>{this._throttledVisibleCopyright()},this._onClick=o=>{if(o.target&&Db(o.target)){const a=o.target.dataset.type;Fb(a)&&this._map.emit("copyrightclick",{type:a,href:o.target.href,originalEvent:o})}},this._copyrightType=t.copyrightType,this._map=e,this._map._impl.on("viewportchange",this._onViewportchange),this._map._impl.on("idle",this._onViewportchange),t.interactive===!1&&(this._wrap.style.pointerEvents="none"),this._wrap.querySelector(`.${Kn.container}`).addEventListener("click",this._onClick),this._throttledVisibleCopyright=n.throttle(()=>{this.update()},Lb)}destroy(){this._map._impl.off("viewportchange",this._onViewportchange),this._map._impl.off("idle",this._onViewportchange),this._wrap.querySelector(`.${Kn.container}`).removeEventListener("click",this._onClick),super.destroy()}update(){let e=!1;if(this._map.getZoom()>Bb){const t=this._map.getSize(),i=this._map._impl.unproject([t[0]*Nt,t[1]*Nt]),o=this._map._impl.unproject([t[0]*(1-Nt),t[1]*Nt]),a=this._map._impl.unproject([t[0]*Nt,t[1]*(1-Nt)]),r=this._map._impl.unproject([t[0]*(1-Nt),t[1]*(1-Nt)]);e=Ob([i,o,r,a,i],zb.features[0].geometry.coordinates[0])}e&&!this._isHidden&&(this._isHidden=!0,super.getContainer().innerHTML=""),!e&&this._isHidden&&(this._isHidden=!1,super.getContainer().innerHTML=yc(this._copyrightType))}}function Fb(s){return s!==void 0&&s in gc}function Db(s){return s&&"href"in s&&"dataset"in s}function Ob(s,e){for(let t=0;t<s.length-1;t++){const i=s[t],o=s[t+1];for(let a=0;a<e.length-1;a++){const r=e[a],l=e[a+1];if(Nb(i,o,r,l))return!0}}return!!(xc(s[0],e)||xc(e[0],s))}function Nb(s,e,t,i){const o=qn(t,i,s),a=qn(t,i,e),r=qn(s,e,t),l=qn(s,e,i);return!!((o>0&&a<0||o<0&&a>0)&&(r>0&&l<0||r<0&&l>0)||o===0&&Yn(t,i,s)||a===0&&Yn(t,i,e)||r===0&&Yn(s,e,t)||l===0&&Yn(s,e,i))}function qn(s,e,t){return(e[0]-s[0])*(t[1]-s[1])-(e[1]-s[1])*(t[0]-s[0])}function Yn(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 xc(s,e){const[t,i]=s;let o=!1;for(let a=0,r=e.length-1;a<e.length;r=a++){const[l,c]=e[a],[d,_]=e[r];c>i!=_>i&&t<(d-l)*(i-c)/(_-c)+l&&(o=!o)}return o}const bc={wrap:"mapgl_r8Wn2E5pGh0-",container:"mapgl_ir0vRf5QXrk-"};class kb{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 Ub=` <div class=${bc.container}>Your MapGL key is invalid. Please contact api@2gis.com to get MapGL key.</div> `;class Hb extends kb{constructor(e){super(e,Ub),e._impl.on("error",t=>{t.type==="invalidtilekey"&&(this.isDisplayed()||this.display())})}initWrap(){const e=document.createElement("div");return e.classList.add(`${bc.wrap}`),e.innerHTML=this.content,e}}class wc{constructor(e){this.northEast=e.northEast,this.southWest=e.southWest}extend(e){return this.southWest=[Math.min(this.southWest[0],e[0]),Math.min(this.southWest[1],e[1])],this.northEast=[Math.max(this.northEast[0],e[0]),Math.max(this.northEast[1],e[1])],this}getCenter(){return[(this.southWest[0]+this.northEast[0])/2,(this.southWest[1]+this.northEast[1])/2]}containsPoint(e){const[t,i]=e,o=t>=this.southWest[0]&&t<=this.northEast[0],a=i>=this.southWest[1]&&i<=this.northEast[1];return o&&a}containsBounds(e){const{southWest:t,northEast:i}=e,o=this.containsPoint(t),a=this.containsPoint(i);return o&&a}intersects(e){const{southWest:t,northEast:i}=e,o=this.getPointRelatedLocation(t),a=this.getPointRelatedLocation(i),r=+o.N+ +a.N,l=+o.S+ +a.S,c=+o.W+ +a.W,d=+o.E+ +a.E;return!(r===2||l===2||c===2||d===2)}getPointRelatedLocation(e){return{S:e[1]<this.southWest[1],N:e[1]>this.northEast[1],W:e[0]<this.southWest[0],E:e[0]>this.northEast[0]}}}const Ve={root:"mapgl_h2pl79nAYpk-",container:"mapgl_64D1bmNQN3Q-",scroller:"mapgl_jdJbkjpLO7k-",content:"mapgl_54Rmy50n6Fw-",control:"mapgl_3i1QoGerxio-",label:"mapgl_wGplqJ4hHPc-"},Gb=`
    <div class="${Ve.root}">
        <div class="${Ve.container}">
            <div class="${Ve.scroller}">
                <div class="${Ve.content}" />
            </div>
        </div>
    </div>
`,Vb=`<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>`,jb=`<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 Sc extends Wt{constructor(e,t){super(e,Gb,t),this._removeButtonsEventListeners=()=>{this._content&&this._content.childNodes.forEach(i=>{if(this._handlers.has(i)){const o=this._handlers.get(i);o!==void 0&&i.removeEventListener("click",o)}})},this._showControl=i=>{const{currentFloor:o,id:a,floorNames:r,metro:l,mode:c}=i;this._floor={mode:c,currentFloorLevelIndex:o,floorPlanId:a,floorNames:r,metro:l},this._root.style.display="block",this._renderControl()},this._hideControl=()=>{this._map._impl.state.floorsEnabled&&(this._removeButtonsEventListeners(),this._floor=void 0,this._root.style.display="none")},this._onLevelChange=i=>{this._switchCurrentFloorLevel(i.floorLevelIndex)},this._controlHandler=i=>o=>{o.preventDefault(),this._switchCurrentFloorLevel(i),this._floor&&this._map._impl.changeFloorNumber(this._floor.floorPlanId,i)},this._map=e,this._root=this._wrap.querySelector(`.${Ve.root}`),this._content=this._wrap.querySelector(`.${Ve.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 o;if(!this._floor)return;this._content.innerHTML="";let e;if(this._floor.metro){const a=document.createElement("button");a.className=`${Ve.control} ${Ve.hideFloorsButton}`,a.innerHTML=jb,a.name="metro",a.type="button";const r=this._controlHandler("metro");a.addEventListener("click",r),this._handlers.set(a,r),this._content.append(a),this._floor.mode==="metro"&&(a.disabled=!0,e=a)}this._floor.floorNames.forEach((a,r)=>{const l=document.createElement("button");l.className=Ve.control,l.innerHTML=`<div class="${Ve.label}">${a}</div>`,l.name=r.toLocaleString(),l.type="button",this._floor&&this._floor.mode==="floor"&&this._floor.currentFloorLevelIndex===r&&(l.disabled=!0,e=l);const c=this._controlHandler(r);l.addEventListener("click",c),this._handlers.set(l,c),this._content.append(l)});const t=document.createElement("button");t.className=`${Ve.control} ${Ve.hideFloorsButton}`,t.innerHTML=`<div class="${Ve.label}">${Vb}</div>`,t.name="building",t.type="button",this._floor&&this._floor.mode==="building"&&(t.disabled=!0,e=t);const i=this._controlHandler("building");if(t.addEventListener("click",i),this._handlers.set(t,i),this._content.append(t),e&&e.offsetTop){const a=(o=e.parentElement)==null?void 0:o.parentElement;a&&(a.scrollTop=e.offsetTop)}}_switchCurrentFloorLevel(e){if(!this._floor)return;const t=this._floor.mode==="floor"?this._floor.currentFloorLevelIndex:this._floor.mode==="building"?"building":"metro",i=this._wrap.querySelector(`.${Ve.control}[name="${t}"]`);i&&(i.disabled=!1);const o=this._wrap.querySelector(`.${Ve.control}[name="${e}"]`);o&&(o.disabled=!0),typeof e=="number"?(this._floor.mode="floor",this._floor.currentFloorLevelIndex=e):this._floor.mode=e}}const Rs={controlPane:"mapgl_z0m6n5pr5no-",container:"mapgl_ITPUswrhaGk-",topLeft:"mapgl_Px-KwzXdVa0-",topCenter:"mapgl_SCX3EYsS-Cw-",topRight:"mapgl_i42TyWqpCPk-",centerLeft:"mapgl_-zKby6nN-nU-",centerRight:"mapgl_SlQM4-ZNKF0-",bottomLeft:"mapgl_lNg3h7Hg-Mo-",bottomCenter:"mapgl_grOepPBwilk-",bottomRight:"mapgl_CiHYefDPhI0-"},Di=10;class Zb{constructor(e,t){this.wrap=document.createElement("div"),this.wrap.className=Rs.controlPane,this.containers={};const{rootContainer:i}=e._impl.modules.layout;i.appendChild(this.wrap),this.padding={top:Di,right:Di,bottom:Di,left:Di},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:Di,this.wrap.style[`margin${i.replace(/^\w/,a=>a.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(Rs.container,Rs[e]),this.wrap.appendChild(t),t}}const Tc={root:"mapgl_9m2ynAxdBT0-",label:"mapgl_sR4nXEQ3L2M-"},Qn={meter:{en:"m",ru:"м"},kilometer:{en:"km",ru:"км"}},Wb=66;class Mc extends Wt{constructor(e,t){super(e,"",t),this._render=()=>{const{state:i}=this._map._impl,o=!!i.styleState.globeEnabled&&i.zoom<n.globeConfig.globeMaxZoom;if(this._wrap.hidden=o,o)return;const a=this._wrap.getBoundingClientRect(),r=this._calcSize([a.x,a.y],a.width||Wb,0),l=`
            <div class="${Tc.root}">
                <div class="${Tc.label}">
                    ${$b(r,this._map.getLanguage())}
                </div>
            </div>
        `;this._wrap.innerHTML=l},this._map=e,this._render(),e.on("zoom",this._render),e.on("pitch",this._render),e.on("changeLanguage",this._render),e.on("move",this._render),e.on("resize",this._render)}destroy(){this._map.off("zoom",this._render),this._map.off("pitch",this._render),this._map.off("changeLanguage",this._render),this._map.off("move",this._render),this._map.off("resize",this._render),super.destroy()}_calcSize(e,t,i){return n.getMetersFromPixelsXY(this._map.getCenter(),this._map.getZoom(),this._map.getRotation(),this._map.getSize(),this._map.getPitch(),e,void 0,this._map.getPadding(),t,i)}}function $b(s,e){return s<1e3?`${s} ${Qn.meter[e]||Qn.meter.en}`:`${(s/1e3).toFixed(1)} ${Qn.kilometer[e]||Qn.kilometer.en}`}class Ec{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 Xb={center:[0,0],zoom:0,minZoom:Zn.minZoom,maxZoom:Zn.maxZoom,rotation:0,touchRotationThreshold:10,pitch:0,minPitch:0,maxPitch:45,lowZoomMaxPitch:45,viewport:{top:0,right:0,bottom:0,left:0},padding:{top:0,right:0,bottom:0,left:0},style:"",lang:"en",iconIdentifyOpacity:.3,disableHidingPois:!1,disableHoverStyles:!1,disableZoomOnScroll:!1,disableDragging:!1,enableTwoFingerDragging:!1,disableRotationByUserInteraction:!1,disablePitchByUserInteraction:!1,defaultBackgroundColor:"#f6f2de",disableIconCache:!1,mobileSdkMode:!1,skipElevationAnimation:!1,enableTrackResize:!1,showDefaultTileBounds:!1,immersiveOn:!1,pitchHightLimitation:90,loopWorld:!1,cityCommPoiLabelingConfig:n.cityCommPoiLabelingConfig,disableRenderingCache:!1,disableStyleFallback:!1,fontUrl:"",modelUrl:"",iconUrl:"",keyUrl:"",disableModelsGrowthAnimation:!1,disableLayerAnimation:!1,trafficOn:!1,allowMetro:!1,resetFloorModeOnActivation:!1,webgpu:!1,forceSyncIdentify:!1};let Kb=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),a=je(this._validateOptions(t),Xb),r=ce(I({},a),{disableHoverStyles:(l=t.disableHoverStyles)!=null?l:!0,tileServer:t.tileServer||zy,style:t.style||n.DEFAULT_MAPGL_STYLE,styleOptions:o,styleState:t.styleState,sessionId:Ms(),tileSessionId:t.tileSessionId});this._impl=new Is(i,r),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:_})=>this.emit("floorplanshow",{floorPlanId:c,currentFloorLevelIndex:d,floorLevels:_.map((u,h)=>({floorLevelIndex:h,floorLevelName:u}))})).on("floorcomplexhide",c=>this.emit("floorplanhide",{floorPlanId:c.id})).on("floorcomplexlevelchange",c=>this.emit("floorlevelchange",{floorLevelName:c.floorName,floorLevelIndex:c.floorIndex,floorPlanId:c.id})).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)),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 Zb(this,{padding:t.controlsLayoutPadding}),this._initControls(t),new Hb(this),this._defaultSource=new Ec(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 wc(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:a,responseMessage:r,responseStatus:l}=t;if((a==null?void 0:a.type)==="raster"){const c=a.mapglApiSource;this.emit(e,{type:t.type,responseMessage:r,responseStatus:l,tileUrl:o,tileCoords:[i[0],i[1],i[2]],source:c})}break}case"webglcontextlost":{this.emit(e,{type:t.type});break}case"styleloaderror":{this.emit("styleloaderror",{style:t.style}),this.emit(e,{type:t.type,style:t.style});break}case"invalidtilekey":{this.emit(e,{type:t.type});break}default:n.assertUnreachable(t)}}_emitMapPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a,target:r,targetData:l}=t;let c;if(l!==void 0)switch(l.type){case"geojson":{c={type:l.type,source:l.source.mapglApiSource,feature:l.feature,id:l.id,layerId:l.layerId};break}case"zenith":{c={type:l.type,id:l.id,source:l.source.mapglApiSource,attributes:l.attributes,layerId:l.layerId};break}case"default":{c={type:l.type,id:l.id,layerId:l.layerId};const{poiIcon:_}=l;_&&(c.poiIcon=_);const{floorId:u}=l;u&&(c.floorId=u);break}}let d;r!==void 0&&(d={id:r.id},r.center&&(d.center=r.center)),this.emit(e,{originalEvent:i,lngLat:o,point:a,target:d,targetData:c})}_initControls(e){if(e.copyright!==!1&&this._impl.modules.tileKeyInfo.getKeyInfo().then(t=>{!t.error&&!t.hideCopyright&&new Rb(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 pc(this,{position:t})}if(e.trafficControl){const t=typeof e.trafficControl=="string"?e.trafficControl:"topRight";new vc(this,{position:t})}if(e.scaleControl){const t=typeof e.scaleControl=="string"?e.scaleControl:"bottomLeft";new Mc(this,{position:t})}if(e.floorControl){const t=typeof e.floorControl=="string"?e.floorControl:"topRight";new Sc(this,{position:t})}}_validateOptions(e){return e=I({},e),typeof e=="object"&&"center"in e&&(ql.isValidGeoPoint(e.center,Es.UseDefault)||(e.center=void 0)),e}};const qb="Noto_Sans",Yb={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"},Qb={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 Jb extends St{constructor(e,t){super(),t.icon||(t.anchor=[15,46]);const i=je(t,Qb);this.userData=i.userData,this.rootOptions={zIndex:i.zIndex,minZoom:i.minZoom,maxZoom:i.maxZoom},this._impl=new uc(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:Ic(this.rootOptions,t.label),anchor:t.anchor,size:t.size,rotation:t.rotation,hoverIcon:t.hoverIcon,hoverSize:t.hoverSize,hoverAnchor:t.hoverAnchor}),this._impl.on("click",o=>this._emitPointerEvent("click",o)).on("dblclick",o=>this._emitPointerEvent("dblclick",o)).on("mousemove",o=>this._emitPointerEvent("mousemove",o)).on("mouseover",o=>this._emitPointerEvent("mouseover",o)).on("mouseout",o=>this._emitPointerEvent("mouseout",o)).on("mousedown",o=>this._emitPointerEvent("mousedown",o)).on("mouseup",o=>this._emitPointerEvent("mouseup",o)).on("touchstart",o=>this._emitPointerEvent("touchstart",o)).on("touchend",o=>this._emitPointerEvent("touchend",o))}setIcon({icon:e,anchor:t,size:i,opacity:o}){return this._impl.setIcon({icon:e,anchor:t,size:i,opacity:o}),this}setHoverIcon(e){const t=e?{icon:e.icon,anchor:e.anchor,size:e.size,opacity:e.opacity}:void 0;return this._impl.setHoverIcon(t),this}setRotation(e){return this._impl.setRotation(e),this}getRotation(){return this._impl.getRotation()}setLabel(e){return this._impl.setLabel(Ic(this.rootOptions,e)),this}setCoordinates(e){return this._impl.setCoordinates(e),this}getCoordinates(){return this._impl.getCoordinates()}show(){return this._impl.show(),this}hide(){return this._impl.hide(),this}destroy(){this._impl.destroy()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}function Ic(s,e){var i,o,a;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=(a=e.zIndex)!=null?a:s.zIndex+1e-5;const t=je(e,Yb);return e.offset===void 0&&e.anchor!==void 0&&(t.offset=e.anchor.map(r=>-r)),{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:qb}}const Ab="Noto_Sans",ew={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 tw extends St{constructor(e,t){super(),this.userData=t.userData;const i=je(t,ew);t.offset===void 0&&t.anchor!==void 0&&(i.offset=t.anchor.map(o=>-o)),this._impl=new Bs(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:Ab,interactive:i.interactive}),this._impl.on("click",o=>this._emitPointerEvent("click",o)).on("dblclick",o=>this._emitPointerEvent("dblclick",o)).on("mousemove",o=>this._emitPointerEvent("mousemove",o)).on("mouseover",o=>this._emitPointerEvent("mouseover",o)).on("mouseout",o=>this._emitPointerEvent("mouseout",o)).on("mousedown",o=>this._emitPointerEvent("mousedown",o)).on("mouseup",o=>this._emitPointerEvent("mouseup",o)).on("touchstart",o=>this._emitPointerEvent("touchstart",o)).on("touchend",o=>this._emitPointerEvent("touchend",o))}destroy(){this._impl.remove()}show(){return this._impl.show(),this}hide(){return this._impl.hide(),this}setCoordinates(e){return this._impl.setCoordinates(e),this}getCoordinates(){return this._impl.getCoordinates()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const 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:""},nw=!1;class ow{constructor(e,t){this.userData=t.userData;const i=je(t,iw);this._impl=new _s(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:nw,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 sw={zIndex:0,minZoom:-1/0,maxZoom:1/0,color:"#3388ff33",strokeColor:"#3388ff",strokeWidth:1,interactive:!0,userData:void 0};class aw extends St{constructor(e,t){super(),this.userData=t.userData;const i=je(t,sw),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 lc(e._impl,o),this._impl.on("click",a=>this._emitPointerEvent("click",a)).on("dblclick",a=>this._emitPointerEvent("dblclick",a)).on("mousemove",a=>this._emitPointerEvent("mousemove",a)).on("mouseover",a=>this._emitPointerEvent("mouseover",a)).on("mouseout",a=>this._emitPointerEvent("mouseout",a)).on("mousedown",a=>this._emitPointerEvent("mousedown",a)).on("mouseup",a=>this._emitPointerEvent("mouseup",a)).on("touchstart",a=>this._emitPointerEvent("touchstart",a)).on("touchend",a=>this._emitPointerEvent("touchend",a))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const rw={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 lw extends St{constructor(e,t){super(),this.userData=t.userData,this.options=je(t,rw);const i={coordinates:this.options.coordinates,interactive:this.options.interactive,maxZoom:this.options.maxZoom,minZoom:this.options.minZoom,color:this.options.color,width:Number.isNaN(this.options.diameter)?this.options.radius:this.options.diameter,zIndex:this.options.zIndex,borderWidth:this.options.strokeWidth,borderColor:this.options.strokeColor,border2Width:this.options.stroke2Width,border2Color:this.options.stroke2Color,draggable:!1};this._impl=new Vs(e._impl,i),this._impl.on("click",o=>this._emitPointerEvent("click",o)).on("dblclick",o=>this._emitPointerEvent("dblclick",o)).on("mousemove",o=>this._emitPointerEvent("mousemove",o)).on("mouseover",o=>this._emitPointerEvent("mouseover",o)).on("mouseout",o=>this._emitPointerEvent("mouseout",o)).on("mousedown",o=>this._emitPointerEvent("mousedown",o)).on("mouseup",o=>this._emitPointerEvent("mouseup",o)).on("touchstart",o=>this._emitPointerEvent("touchstart",o)).on("touchend",o=>this._emitPointerEvent("touchend",o))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const cw={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,cw);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 ac(e._impl,o),this._impl.on("click",a=>this._emitPointerEvent("click",a)).on("dblclick",a=>this._emitPointerEvent("dblclick",a)).on("mousemove",a=>this._emitPointerEvent("mousemove",a)).on("mouseover",a=>this._emitPointerEvent("mouseover",a)).on("mouseout",a=>this._emitPointerEvent("mouseout",a)).on("mousedown",a=>this._emitPointerEvent("mousedown",a)).on("mouseup",a=>this._emitPointerEvent("mouseup",a)).on("touchstart",a=>this._emitPointerEvent("touchstart",a)).on("touchend",a=>this._emitPointerEvent("touchend",a))}else{const o={coordinates:i.coordinates,interactive:i.interactive,maxZoom:i.maxZoom,minZoom:i.minZoom,width:i.width,width2:i.width2,width3:i.width3,color:i.color,color2:i.color2,color3:i.color3,zIndex:i.zIndex,zIndex2:i.zIndex2,zIndex3:i.zIndex3,displayTileBounds:!1,showAnimation:{animate:!1},gpuState:t.gpuState,renderingMode:i.renderingMode,hiddenPartColor:t.hiddenPartColor,tiers:t.tiers};this._impl=new tc(e._impl,o),this._impl.on("click",a=>this._emitPointerEvent("click",a)).on("dblclick",a=>this._emitPointerEvent("dblclick",a)).on("mousemove",a=>this._emitPointerEvent("mousemove",a)).on("mouseover",a=>this._emitPointerEvent("mouseover",a)).on("mouseout",a=>this._emitPointerEvent("mouseout",a)).on("mousedown",a=>this._emitPointerEvent("mousedown",a)).on("mouseup",a=>this._emitPointerEvent("mouseup",a)).on("touchstart",a=>this._emitPointerEvent("touchstart",a)).on("touchend",a=>this._emitPointerEvent("touchend",a))}}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const _w={interactive:!0,maxZoom:1/0,minZoom:-1/0,color:"#3388ff33",zIndex:0,strokeWidth:3,strokeColor:"#3388ff",userData:void 0};class uw extends St{constructor(e,t){super(),this.userData=t.userData;const i=je(t,_w),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 rc(e._impl,o),this._impl.on("click",a=>this._emitPointerEvent("click",a)).on("dblclick",a=>this._emitPointerEvent("dblclick",a)).on("mousemove",a=>this._emitPointerEvent("mousemove",a)).on("mouseover",a=>this._emitPointerEvent("mouseover",a)).on("mouseout",a=>this._emitPointerEvent("mouseout",a)).on("mousedown",a=>this._emitPointerEvent("mousedown",a)).on("mouseup",a=>this._emitPointerEvent("mouseup",a)).on("touchstart",a=>this._emitPointerEvent("touchstart",a)).on("touchend",a=>this._emitPointerEvent("touchend",a))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const hw={minZoom:-1/0,maxZoom:1/0,zIndex:0,opacity:1};class fw{constructor(e,t){const i=je(t,hw),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 fc(e._impl,o)}updateImage(e){return K(this,null,function*(){yield this._impl.updateImage(e)})}destroy(){this._impl.destroy()}}const mw={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 pw extends St{constructor(e,t){super(),this.userData=t.userData;const i=je(t,mw),r={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 fs(e._impl,r),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))}destroy(){this._impl.remove()}_emitPointerEvent(e,t){const{originalEvent:i,lngLat:o,point:a}=t;this.emit(e,{originalEvent:i,lngLat:o,point:a,targetData:this})}}const 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 gw 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 xs(e._impl,o),this._impl.on("click",a=>this._emitPointerEvent("click",a)).on("dblclick",a=>this._emitPointerEvent("dblclick",a)).on("mousemove",a=>this._emitPointerEvent("mousemove",a)).on("mouseover",a=>this._emitPointerEvent("mouseover",a)).on("mouseout",a=>this._emitPointerEvent("mouseout",a)).on("mousedown",a=>this._emitPointerEvent("mousedown",a)).on("mouseup",a=>this._emitPointerEvent("mouseup",a)).on("touchstart",a=>this._emitPointerEvent("touchstart",a)).on("touchend",a=>this._emitPointerEvent("touchend",a)).on("modelloaded",()=>this._emitPointerEvent("modelloaded"))}destroy(e){this._impl.destroy(e)}hide(){this._impl.hide()}show(){this._impl.show()}transform(e){this._impl.transform(e)}stopTransformation(){this._impl.stopTransformation()}getCoordinates(){return this._impl.getCoordinates()}getScale(){return this._impl.getScale()}getRotation(){return this._impl.getRotation()}getOffset(){return this._impl.getOffset()}setState(e){this._impl.setState(e)}_emitPointerEvent(e,t){this.emit(e,t?{originalEvent:t.originalEvent,lngLat:t.lngLat,point:t.point,targetData:this}:void 0)}}const Cc={attributes:{},maxZoom:17,dimensions:2,modelsPath:"",modelsAppearStrategy:"byModel",promoteId:"",idScope:"default",tolerance:3};class yw{constructor(e,t){this.options=je(t,Cc),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 xw=ce(I({},Cc),{viewportPadding:0});class bw{constructor(e,t){this.options=je(t,xw);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 Pc={container:"mapgl_54Xq9OUdARA-",text:"mapgl_qYE18V9u8c0-"},ww=s=>`
    <div class=${Pc.container}>
        <div class=${Pc.text}>${s}</div>
    </div>
`;class Sw extends Wt{constructor(e,t){super(e,ww(t),{position:"bottomLeft"})}}const Tw={attributes:{},attribution:"",minZoom:Zn.minZoom,maxZoom:Zn.maxZoom};class Mw{constructor(e,t){this.options=je(t,Tw),this._impl=new mc(e._impl,this.options,this),this._attribution=new Sw(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 An=class An{constructor(e,t){this.options=t;const i=this.prepareOptions(this.options,e);this._impl=new to(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,a,r,l,c,d,_,u,h,f;const i={tileServer:(o=e.tileServer)!=null?o:"",tileSet:(a=e.tileSet)!=null?a:"",tileProtocol:(r=e.tileProtocol)!=null?r:"",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=`${Xl}?ts=userdata&x={x}&y={y}&z={z}&layer=${e.layerId}`),i.metatileTemplateUrl||(i.metatileTemplateUrl=`${Xl}/file/{hash}?ts=userdata&layer=${e.layerId}`)),i}};An.tileTemplateUrl="{protocol}://{host}/v2/ald?ts={tileSet}&x={x}&y={y}&z={z}&lang={lang}",An.metatileTemplateUrl="{protocol}://{host}/v2/ald/file/{hash}.json?ts={tileSet}";let Fs=An;function Ew(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(By));if(!s)return;const e=Ew(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 Iw(s){jv(s)}const Ds="v1.72.3";Q.API_VERSION=Ds,Q.Arrow=pw,Q.Circle=aw,Q.CircleMarker=lw,Q.Control=Wt,Q.DefaultSource=Ec,Q.FloorControl=Sc,Q.GeoJsonSource=yw,Q.GeoJsonViewportSource=bw,Q.GltfModel=gw,Q.HtmlMarker=ow,Q.Label=tw,Q.LngLatBoundsClass=wc,Q.Map=Kb,Q.Marker=Jb,Q.Polygon=uw,Q.Polyline=dw,Q.Raster=fw,Q.RasterTileSource=Mw,Q.ScaleControl=Mc,Q.TrafficControl=vc,Q.ZenithSource=Fs,Q.ZoomControl=pc,Q._J=Sb,Q.isSupported=Cd,Q.isTerrainSupported=Xs,Q.notSupportedReason=qs,Q.setWorkerUrl=Iw,Q.terrainNotSupportedReason=Ud,Object.defineProperty(Q,Symbol.toStringTag,{value:"Module"})}));
