@tomtom-org/maps-sdk 0.52.0 → 0.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/LICENSE.txt +37 -461
- package/README.md +59 -4
- package/THIRD_PARTY.txt +282 -0
- package/core/dist/THIRD_PARTY.txt +101 -1
- package/core/dist/core.es.js +1 -1
- package/core/dist/core.es.js.map +1 -1
- package/core/dist/index.d.ts +190 -6
- package/core/dist/third-party.json +28 -0
- package/map/dist/THIRD_PARTY.txt +231 -1
- package/map/dist/index.d.ts +529 -112
- package/map/dist/map.es.js +1 -1
- package/map/dist/map.es.js.map +1 -1
- package/map/dist/third-party.json +38 -0
- package/package.json +55 -29
- package/services/dist/THIRD_PARTY.txt +102 -1
- package/services/dist/index.d.ts +373 -43
- package/services/dist/services.es.js +1 -1
- package/services/dist/services.es.js.map +1 -1
- package/services/dist/third-party.json +28 -0
package/map/dist/map.es.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{isEmpty as e,isEqual as t,isNil as i,mapValues as r,omit as s,omitBy as a,remove as o}from"lodash-es";import{DEFAULT_COMMON_BASE_URL as n,TomTomConfig as l,bboxCenter as c,bboxFromCoordsArray as h,bboxFromGeoJSON as u,formatDistance as d,formatDuration as p,generateId as f,generateTomTomHeaders as y,getPosition as m,iconToTrafficIncidentCategory as g,indexedMagnitudes as _,isProxyCredentialsMode as L,mergeFromGlobal as A,poiCategoriesToID as S}from"@tomtom-org/maps-sdk/core";import{bearing as I,booleanPointInPolygon as E,difference as b,featureCollection as R,hexGrid as T,mask as C,squareGrid as v}from"@turf/turf";import{Map as O,getRTLTextPluginStatus as w,getVersion as N,setRTLTextPlugin as M,setWorkerCount as x}from"maplibre-gl";var D=class{constructor(e,t){this.userEventsInstance=e,this.moduleEventsInstance=t}where(e,t){return this.userEventsInstance.where(e,t)}on(e,t){return"config-change"===e?this.moduleEventsInstance.on("config-change",t):"shown-features"===e?this.moduleEventsInstance.on("shown-features",t):this.userEventsInstance.on(e,t)}off(e){"config-change"===e||"shown-features"===e?this.moduleEventsInstance.off(e):this.userEventsInstance.off(e)}},F=(e,t)=>e?t?(...i)=>e(...i)&&t(...i):e:t,P=(e,t)=>{if(!e)return t;if(!t)return e;const i=F(e.layerFilter,t.layerFilter),r=F(e.featureMatches,t.featureMatches);return i||r?{layerFilter:i,featureMatches:r}:void 0},U=(e,t)=>t?.layerFilter?e._layerSpecs.filter(t.layerFilter):e._layerSpecs,H=["on","off","where"],k=(e,t)=>{const i=e.find(e=>H.includes(e));if(i)throw new Error(`${t} uses the reserved event scope name "${i}". Reserved: ${H.join(", ")}.`)},W=class{constructor(e,t){this.configChangeHandlers=e,this.shownFeaturesHandlers=t}on(e,t){if("config-change"===e){const e=t;return this.configChangeHandlers.push(e),()=>{const t=this.configChangeHandlers.indexOf(e);-1!==t&&this.configChangeHandlers.splice(t,1)}}const i=t;return this.shownFeaturesHandlers.push(i),()=>{const e=this.shownFeaturesHandlers.indexOf(i);-1!==e&&this.shownFeaturesHandlers.splice(e,1)}}off(e){"config-change"===e?this.configChangeHandlers.length=0:this.shownFeaturesHandlers.length=0}},G=["road_category","road_subcategory","relative_speed","left_hand_traffic","road_closure","absolute_speed","part_of_two_way_road","openlr","display_class"],B=e=>{const{properties:t}=e;return{id:e.id,type:e.type,geometry:e.geometry,properties:{roadCategory:t?.road_category,leftHandTraffic:Boolean(t?.left_hand_traffic),roadClosure:Boolean(t?.road_closure),relativeSpeed:t?.relative_speed,...t?.road_subcategory&&{roadSubcategory:t.road_subcategory},...t?.absolute_speed&&{absoluteSpeed:t.absolute_speed},...t?.part_of_two_way_road&&{partOfTwoWayRoad:Boolean(t.part_of_two_way_road)},...t?.openlr&&{openlr:t.openlr},...t?.display_class&&{displayClass:t.display_class}}}},V=["icon_category","left_hand_traffic","magnitude_of_delay","road_category","road_subcategory","id","description","delay","part_of_two_way_road","start_time","end_time","probability_of_occurrence","number_of_reports","last_report_time","average_speed_kmph","openlr","time_validity","display_class"],j={other:0,accident:1,fog:2,danger:3,rain:4,frost:5,jam:6,"lane-closed":7,"road-closed":8,roadworks:9,wind:10,flooding:11,"animals-on-road":12,"narrow-lanes":13,"broken-down-vehicle":14},z=e=>{const{properties:t}=e;return{id:e.id,type:e.type,geometry:e.geometry,properties:{id:t.id??f(),description:t?.description_0??"",category:g(t?.icon_category_0),magnitudeOfDelay:_[t?.magnitude_of_delay],roadCategory:t?.road_category,roadSubcategory:t?.road_subcategory,leftHandTraffic:Boolean(t?.left_hand_traffic),...t?.delay&&{delayInSeconds:t.delay},...t?.part_of_two_way_road&&{partOfTwoWayRoad:Boolean(t.part_of_two_way_road)},...t?.start_time&&{startTime:new Date(t.start_time)},...t?.end_time&&{endTime:new Date(t.end_time)},...t?.probability_of_occurrence&&{probabilityOfOccurrence:t.probability_of_occurrence},...t?.number_of_reports&&{numberOfReports:t.number_of_reports},...t?.last_report_time&&{lastReportTime:new Date(t.last_report_time)},...t?.average_speed_kmph&&{averageSpeedKmph:t.average_speed_kmph},...t?.openlr&&{openlr:t.openlr},...t?.time_validity&&{timeValidity:t.time_validity},...t?.display_class&&{displayClass:t.display_class},...t?.point_type&&{pointType:t.point_type}}}},$=e=>/* @__PURE__ */new Error(`Trying to ${e} while it is not in the map style. Did you exclude it when loading the map?`),Y="pinCategories",q=e=>`${Y}:${e}`,K=()=>"undefined"!=typeof document&&"undefined"!=typeof DOMParser&&"undefined"!=typeof btoa,X=e=>{if(!K())return;const t=document.createElement("img");return t.src=`data:image/svg+xml;base64,${btoa((new XMLSerializer).serializeToString(e))}`,t},Z=e=>(new DOMParser).parseFromString(e,"image/svg+xml").documentElement,J=e=>((e,t)=>(t?.fillColor&&e.querySelector("#background")?.setAttribute("fill",t.fillColor),t?.outlineColor&&e.querySelector("#outline")?.setAttribute("fill",t.outlineColor),void 0!==t?.outlineOpacity&&e.querySelector("#outline")?.setAttribute("fill-opacity",t.outlineOpacity.toString()),e))(Z('<svg xmlns="http://www.w3.org/2000/svg" width="120" height="140">\n <path id="background" d="M63.95 137.516c6.556-12.737 19.098-21.09 30.828-29.388C110.046 97.324 120 79.603 120 59.574 120 26.671 93.138 0 60 0S0 26.671 0 59.574c0 20.029 9.954 37.75 25.22 48.55 11.734 8.302 24.274 16.652 30.83 29.388 1.706 3.316 6.194 3.316 7.9 0z"\n fill="#1988cf"/>\n <path id="outline" d="M91.298 103.272C105.052 93.544 114 77.596 114 59.574c0-29.61-24.176-53.617-54-53.617S6 29.964 6 59.574c0 18.022 8.95 33.97 22.7 43.698l2.27 1.601c10.172 7.153 21.922 15.423 29.03 27.416 7.104-11.993 18.858-20.259 29.03-27.416l2.268-1.601zm1.468 6.274c-11.13 7.845-22.632 15.957-28.816 27.966-1.706 3.316-6.194 3.316-7.9 0-6.182-12.009-17.686-20.121-28.816-27.966l-2.016-1.422C9.954 97.324 0 79.603 0 59.574 0 26.671 26.862 0 60 0s60 26.671 60 59.574c0 20.029-9.954 37.75-25.222 48.55l-2.016 1.422z"\n fill-opacity=".3"/>\n</svg>\n'),e);var Q,ee,te,ie=e=>(function(e){if(i(e))throw new Error(`${e} must not be null/undefined. Something went wrong with its initialization.`)}(e),e),re=e=>{const t=e.properties?.id;return"string"==typeof t||"number"==typeof t?t:e.id},se=(e,t)=>{if(null!=t)for(let i=0;i<e.length;i++)if(re(e[i])===t)return{feature:e[i],index:i}},ae=class{constructor(e,t,i){this.id=e,this.spec=t,this.runtimeSource=i}ensureAddedToMap(e){this.runtimeSource||(!e.getSource(this.id)&&this.spec&&e.addSource(this.id,this.spec),this.runtimeSource=e.getSource(this.id))}},oe=class{constructor(e,t,i){this.map=e,this.source=t,this._layerSpecs=i,this._updateSourceAndLayerIDs()}get mapRemoved(){return!0===this.map._removed}isAnyLayerVisible(e){return this.getLayerSpecs(e).some(e=>this.isLayerVisible(e))}areAllLayersVisible(e){return this.getLayerSpecs(e).every(e=>this.isLayerVisible(e))}getLayerSpecs(e){return e?this._layerSpecs.filter(e):this._layerSpecs}_updateSourceAndLayerIDs(){this._sourceAndLayerIDs={sourceID:this.source.id,layerIDs:this._layerSpecs.map(e=>e.id)}}isLayerVisible(e){return!this.mapRemoved&&(!!this.map.getLayer(e.id)&&"none"!==this.map.getLayoutProperty(e.id,"visibility"))}setLayersVisible(e,t){if(!this.mapRemoved)for(const i of this.getLayerSpecs(t))this.map.getLayer(i.id)&&this.map.setLayoutProperty(i.id,"visibility",e?"visible":"none",{validate:!1})}get sourceAndLayerIDs(){return this._sourceAndLayerIDs}},ne=(e,t)=>e.getStyle().layers.filter(e=>t.includes(e?.source)),le=class extends oe{constructor(e,t,i){let r=ne(e,[t.id]);i&&(r=r.filter(i)),super(e,new ae(t.id,e.getStyle().sources[t.id],t),r)}},ce=class extends oe{constructor(e,t,i,r){super(e,new ae(t,i),r.map(e=>({...e,source:t})))}ensureLayersAddedToMap(){if(!this.mapRemoved)for(const e of this._layerSpecs)this.map.getLayer(e.id)||this.map.addLayer(e,e.beforeID)}ensureAddedToMapWithVisibility(e,t){this.mapRemoved||(this.source.ensureAddedToMap(this.map),t&&(this.ensureLayersAddedToMap(),this.setLayersVisible(e)))}},he={type:"FeatureCollection",features:[]},ue=class extends ce{constructor(e,t,i,r=!0,s){super(e,t,s?.cluster?{type:"geojson",data:he,...s}:{type:"geojson",data:he,promoteId:"id",...s??{}},i),this.shownFeatures=he,this.ensureAddedToMapWithVisibility(!1,r)}show(e,{automaticVisibility:t=!0}={}){this.shownFeatures=e,this.mapRemoved||(ie(this.source.runtimeSource).setData(e),t&&this.setLayersVisible(!!e.features.length))}findById(e){return se(this.shownFeatures.features,e)}clear(){this.show(he)}findFeature(e){return"index"in e?this.shownFeatures.features[e.index]:"id"in e?this.findById(e.id)?.feature:void 0}putEventState(e){if("put"===(e.mode??"put"))for(const i of this.shownFeatures.features)i.properties?.eventState===e.state&&delete i.properties.eventState;const t=this.findFeature(e);t&&(t.properties={...t.properties,eventState:e.state}),!1!==e.show&&this.show(this.shownFeatures,{automaticVisibility:!1})}cleanEventState(e){const t=this.findFeature(e);t?.properties?.eventState&&(delete t?.properties?.eventState,!1!==e?.show&&this.show(this.shownFeatures,{automaticVisibility:!1}))}cleanEventStates(e){let t=!1;for(const i of this.shownFeatures.features)e?.states&&!e.states.includes(i.properties?.eventState)||(delete i.properties?.eventState,t=!0);!1!==e?.show&&t&&this.show(this.shownFeatures,{automaticVisibility:!1})}},de=async e=>{e.mapReady||(await e.mapLibreMap.once("styledata"),await de(e))},pe=e=>{const t=globalThis.__DEMOS_PROXY_ENSURE_SESSION__;return"function"!=typeof t?e:t().then(()=>e,()=>e)},fe=e=>{const t=e.commonBaseURL??n,i=t!==n,r=L(e);return(s,a)=>{const o=((e,t,i,r)=>{if(!i)return e;try{const i=new URL(e);return"api.tomtom.com"===(s=i.hostname)||s.endsWith(".api.tomtom.com")?(r&&i.searchParams.delete("key"),t+i.pathname+i.search+i.hash):e}catch{return e}var s})(s,t,i,r),n=i&&o.startsWith(t),l=r&&n;let c=!1;try{const e=new URL(s).hostname;c="tomtom.com"===e||e.endsWith(".tomtom.com")}catch{c=!1}if(!c&&!n)return{url:o};if("Image"===a)return l?pe({url:o,credentials:"include"}):{url:o};const h=new URL(o);(e=>{e.pathname.includes("incidents")?e.searchParams.set("tags",V.join(",")):e.pathname.includes("flow")&&e.searchParams.set("tags",G.join(","))})(h);const u={url:h.toString(),headers:{...y(e)}};return l?(u.credentials="include",pe(u)):u}},ye=(e,t,i)=>{const r=e.id;e.maxzoom===t.maxzoom&&e.minzoom===t.minzoom||i.setLayerZoomRange(r,e.minzoom??i.getMinZoom(),e.maxzoom??i.getMaxZoom()),i.setFilter(r,e.filter,{validate:!1});for(const s of Object.keys(t.layout??{}))e.layout?.[s]||i.setLayoutProperty(r,s,void 0,{validate:!1});for(const s of Object.keys(t.paint??{}))e.paint?.[s]||i.setPaintProperty(r,s,void 0,{validate:!1});for(const[s,a]of Object.entries(e.paint??{}))i.setPaintProperty(r,s,a,{validate:!1});for(const[s,a]of Object.entries(e.layout??{}))i.setLayoutProperty(r,s,a,{validate:!1})},me=(e,t,i,r)=>{const s=e.reduce((e,t)=>({...e,[t.id]:t}),{}),a=t.reduce((e,t)=>({...e,[t.id]:t}),{}),o=[],n=[],l=[],c=[];Object.keys(s).forEach(e=>{a[e]?(l.push(s[e]),c.push(a[e])):o.push(e)}),Object.keys(a).forEach(e=>{s[e]||n.push(e)});const h=i._layerSpecs;n.forEach(e=>{r.removeLayer(e);for(let t=0;t<h.length;t++)if(h[t].id===e){h.splice(t,1);break}}),o.forEach(e=>{const t={...s[e],source:i.source.id};h.push(t)}),i._updateSourceAndLayerIDs(),((e,t,i)=>{e.forEach((e,r)=>ye(e,t[r],i))})(l,c,r)},ge=(e,t)=>{const i=/* @__PURE__ */new Set,r=e=>{t.getLayer(e.id)||t.addLayer({...e,layout:{...e.layout,visibility:"none"}},e.beforeID),i.add(e.id)},s={};for(e.forEach(e=>{e.beforeID?i.has(e.beforeID)||t.getLayer(e.beforeID)?(i.add(e.beforeID),r(e)):s[e.beforeID]?s[e.beforeID].push(e):s[e.beforeID]=[e]:r(e)});Object.keys(s).length>0;){const e=Object.keys(s).filter(e=>i.has(e));if(!e.length)return void console.error(`Some layers cannot be added. Check for non-existing layers, or circular beforeID dependencies for the following: ${JSON.stringify(Object.keys(s))}`);e.forEach(e=>{s[e].forEach(e=>r(e)),delete s[e]})}},_e=(e,t)=>{switch(typeof e){case"undefined":return{type:"standard",include:[t]};case"string":return{type:"standard",id:e,include:[t]};default:if("standard"===e.type)return e.include?{...e,include:[...e.include,t]}:{...e,include:[t]};throw(e=>/* @__PURE__ */new Error(`Trying to add style module ${e} to the custom style!`))(t)}},Le=async(e,t,i)=>{if(!e.mapLibreMap.getSource(t)){const r=e.mapLibreMap;r.isStyleLoaded()||await r.once("idle"),e.setStyle(_e(e.getStyle(),i)),await(async(e,t)=>{e.mapLibreMap.getSource(t)&&e.mapLibreMap.isSourceLoaded(t)||await e.mapLibreMap.once("sourcedata")})(e,t),await r.once("styledata");for(const e of ne(r,[t]))r.setLayoutProperty(e.id,"visibility","none",{validate:!1});await r.once("styledata")}},Ae=async(e,t,i,r,s)=>{if(!i)return void console.warn(`addOrUpdateImage called with empty image for ID ${t}`);const a=i=>{const a=r.hasImage(t);a&&"add-or-update"==e?r.updateImage(t,i):a||r.addImage(t,i,s)},o=e=>{e.complete?e.naturalWidth>0?a(e):console.warn(`Failed to load image for ID ${t}`):(e.onload=()=>a(e),e.onerror=()=>console.warn(`Failed to load image for ID ${t}`))};"string"==typeof i?i.includes("<svg")?o(X(Z(i))):a((await r.loadImage(i)).data):o(i)},Se=e=>{switch(e){case"standardDark":case"drivingDark":case"monoDark":case"satellite":return"dark";default:return"light"}},Ie=e=>{if("string"==typeof e)return Se(e);const t=e;return t?.id?Se(t.id):"light"},Ee=class e{constructor(e){this.options=e,this.sources=e.sourcesWithLayers}where(t,i){return new e({...this.options,config:i??this.options.config,scope:P(this.options.scope,this.resolveScope(t))})}resolveScope(e){if("function"==typeof e){const t=e,i=this.options.mapping;return{featureMatches:i?e=>t(i(e)):e=>t(e)}}const t=this.options.scopeResolver;if(!t)throw new Error("This module supports only feature predicates in events.where().");return t(e)}on(e,t){const{eventProxy:i,config:r,owner:s,scope:a}=this.options,o=this.toRegisteredHandler(t),n=[];for(const l of this.sources)i.addEventHandler(l,o,e,{config:r,owner:s,scope:a}),n.push(l);return()=>{for(const t of n)i.removeHandler(t,e,o)}}toRegisteredHandler(e){const{mapping:t,scope:i}=this.options,r=i?.featureMatches;if(!t&&!r)return e;const s=e=>t?t(e):e;return r?(t,i,a,o)=>{const n=(a.length?a:[t]).filter(e=>r(e));if(!n.length)return;const l=n.map(s);e(l[0],i,l,o)}:(t,i,r,a)=>e(s(t),i,r.map(s),a)}off(e){for(const t of this.sources)this.options.eventProxy.remove(t,e,this.options.owner)}},be=class e{static{this.instanceCounters=/* @__PURE__ */new WeakMap}constructor(t,i,r){this._initializing=!0,this.configChangeHandlers=[],this.moduleReady=!1;const s=new.target,a=e.instanceCounters.get(s)??-1;this.instanceIndex=a+1,e.instanceCounters.set(s,this.instanceIndex),this.sourceType=t,this.tomtomMap=i,this.eventsProxy=i._eventsProxy,this.mapLibreMap=i.mapLibreMap,this.initSourcesWithLayers(r),this.applyConfig(r),this.tomtomMap.addStyleChangeHandler({onStyleAboutToChange:()=>{this.moduleReady=!1},onStyleChanged:()=>this.restoreDataAndConfig()}),this._initializing=!1}initSourcesWithLayers(e,t){this.moduleReady=!1,this.sourcesWithLayers=this._initSourcesWithLayers(e,t),this._sourceAndLayerIDs=Object.fromEntries(Object.entries(this.sourcesWithLayers).map(([e,t])=>[e,t.sourceAndLayerIDs])),t&&this.eventsProxy.updateIfRegistered(this.sourcesWithLayers,this),this.tomtomMap.mapReady&&(this.moduleReady=!0)}async waitUntilModuleReady(){await de(this.tomtomMap),this.moduleReady||await new Promise(e=>{const t=setInterval(()=>{this.tomtomMap.mapReady&&this.moduleReady&&(clearInterval(t),e())},200)})}applyConfig(e){this.config=this._applyConfig(e),this.emitConfigChange()}emitConfigChange(){if(!this._initializing)for(const e of this.configChangeHandlers)e(this.config)}resetConfig(){this.applyConfig(void 0)}async restoreDataAndConfig(){this.moduleReady=!1,"geojson"===this.sourceType?requestAnimationFrame(()=>{this.restoreDataAndConfigImpl()}):this.restoreDataAndConfigImpl()}restoreDataAndConfigImpl(){this.initSourcesWithLayers(this.config,!0),this._applyConfig(this.config)}getConfig(){return this.config&&{...this.config}}get sourceAndLayerIDs(){return this._sourceAndLayerIDs}userEvents(e,t={}){return new Ee({eventProxy:this.eventsProxy,sourcesWithLayers:e.map(e=>this.sourcesWithLayers[e]).filter(e=>!!e),owner:this,config:this.config?.events,mapping:t.mapping,scopeResolver:t.scopeResolver})}moduleEvents(e,t={}){return new D(this.userEvents(e,t),new W(this.configChangeHandlers,[]))}moduleEventsWithShown(e,t,i={}){return new D(this.userEvents(e,i),new W(this.configChangeHandlers,t))}buildEvents(e,t){return k(Object.keys(t),this.constructor.name),Object.assign(e,t)}},Re=class{constructor(){this.interactiveLayerIDs=[],this.handlers={click:{},contextmenu:{},hover:{},"hover-move":{},"long-hover":{}},this.findHandlers=(e,t,i)=>t&&e.flatMap(e=>{const r=this.handlers[e][t]??[];return i?r.filter(e=>!e.scope?.featureMatches||e.scope.featureMatches(i)):r})||[]}ensureInteractiveLayerIDsAdded(e){for(const t of e)this.interactiveLayerIDs.includes(t)||this.interactiveLayerIDs.push(t)}releaseUnusedInteractiveLayerIDs(e){o(this.interactiveLayerIDs,t=>e.has(t)&&!this.hasHandlerForLayer(t))}indexHandler(e,t){const i=this.handlers[t];for(const r of e.layerIDs)i[r]??=[],i[r].push(e)}unindexHandlers(e,t){const i=this.handlers[t],r=/* @__PURE__ */new Set;for(const s of e)for(const t of s.layerIDs){r.add(t);const s=i[t];s&&(o(s,t=>e.has(t)),s.length||delete i[t])}return r}dropHandlers(e,t,i){const r=e.source.id,s=/* @__PURE__ */new Set;for(const a of Object.values(this.handlers[t]))for(const e of a)e.sourceWithLayers.source.id===r&&i(e)&&s.add(e);s.size&&this.releaseUnusedInteractiveLayerIDs(this.unindexHandlers(s,t))}addEventHandler(e,t,i,r){const s=new Set(U(e,r.scope).map(e=>e.id));this.ensureInteractiveLayerIDsAdded(s),this.indexHandler({...r,sourceWithLayers:e,layerIDs:s,fn:t},i)}removeHandler(e,t,i){this.dropHandlers(e,t,e=>e.fn===i)}remove(e,t,i){this.dropHandlers(e,t,e=>e.owner===i)}removeAll(){this.interactiveLayerIDs=[],this.handlers={click:{},contextmenu:{},hover:{},"hover-move":{},"long-hover":{}}}hasHandlerForLayer(e){return Object.values(this.handlers).some(t=>!!t[e]?.length)}sourceWithLayersFor(e){if(e)for(const t of Object.values(this.handlers)){const i=t[e];if(i?.length)return i[0].sourceWithLayers}}updateIfRegistered(e,t){const i=new Map(Object.values(e).map(e=>[e.source.id,e]));for(const r of Object.keys(this.handlers)){const e=/* @__PURE__ */new Set;for(const a of Object.values(this.handlers[r]))for(const r of a)r.owner===t&&i.has(r.sourceWithLayers.source.id)&&e.add(r);if(!e.size)continue;const s=this.unindexHandlers(e,r);for(const t of e){const e=i.get(t.sourceWithLayers.source.id);t.sourceWithLayers=e,t.layerIDs=new Set(U(e,t.scope).map(e=>e.id)),this.ensureInteractiveLayerIDsAdded(t.layerIDs),this.indexHandler(t,r)}this.releaseUnusedInteractiveLayerIDs(s)}}},Te=e=>"click"===e||"contextmenu"===e,Ce=(e,t,i,r="updateInProps")=>{const{feature:a,index:o}=se(i,t)||{};if(a&&(!Te(a.properties?.eventState)||Te(e))){const t={...a,properties:"updateInProps"===r?{...a?.properties,eventState:e}:s(a?.properties,"eventState")};return i.splice(o,1,t),o}},ve=(e,t,r)=>{const s=[...r.shownFeatures.features],a=Ce(e,re(t),s,"removeFromProps");i(a)||r.show({...r.shownFeatures,features:s},{automaticVisibility:!1})},Oe=(e,t,i,r,s)=>{if(t&&r instanceof ue){const n=[...r.shownFeatures.features];return Ce(e,re(t),n),!i||(o=t,(a=i)&&o&&a.id===o.id)||(s===r?Ce(e,re(i),n,"removeFromProps"):s instanceof ue&&ve(e,i,s)),void r.show({...r.shownFeatures,features:n},{automaticVisibility:!1})}var a,o;i&&s instanceof ue&&ve(e,i,s)},we=[],Ne={precisionMode:"box",paddingBoxPx:5,cursorOnHover:"pointer",cursorOnMouseDown:"grabbing",cursorOnMap:"default",longHoverDelayAfterMapMoveMS:800,longHoverDelayOnStillMapMS:300},Me=class extends Re{constructor(e,t={}){super(),this.enabled=!0,this.firstDelayedHoverSinceMapMove=!0,this.mouseMoveFrameRequested=!1,this.map=e,this.mapCanvas=e.getCanvas(),this.config={...Ne,...t},this.mapCanvas.style.cursor=this.config.cursorOnMap,this.lastCursorStyle=this.config.cursorOnMap,this.listenToEvents()}listenToEvents(){this.map.on("mousemove",e=>this.onMouseMove(e)),this.map.on("movestart",()=>this.onMouseStart()),this.map.on("mouseout",()=>this.onMouseOut()),this.map.on("mouseover",e=>this.onMouseMove(e)),this.map.on("mousedown",()=>this.onMouseDown()),this.map.on("mouseup",()=>this.onMouseUp()),this.map.on("click",e=>this.onMapClick("click",e)),this.map.on("contextmenu",e=>this.onMapClick("contextmenu",e))}enable(e){this.enabled=e,e||(this.clearLongHoverTimeout(),this.pendingMouseMove=void 0)}toPaddedBounds(e){const t=this.config.paddingBoxPx;return[[e.x-t,e.y+t],[e.x+t,e.y-t]]}isEnabled(){return this.enabled&&!this.map.isMoving()}toCallerFeatures(e,t,i){const r=i?e.filter(e=>i.has(e.layer.id)):e,s=(e=>{const t=/* @__PURE__ */new Set,i=[];for(const r of e){const e=re(r);if(void 0===e){i.push(r);continue}const s=`${r.source} ${e}`;t.has(s)||(t.add(s),i.push(r))}return i})((a=r,o=t?.source,o?a.filter(e=>e.source===o):a));var a,o;const n=this.sourceWithLayersFor(t?.layer.id);return n instanceof ue?s.map(e=>n.findById(re(e))?.feature??e):s}callerFeaturesFor(e,t,i,r){return e.scope?.layerFilter?this.toCallerFeatures(t,i,e.layerIDs):r}getRenderedFeatures(e){if(!this.interactiveLayerIDs.length)return[];const t={layers:this.interactiveLayerIDs,validate:!1},i=this.config.precisionMode,r="point-then-box"===i||"point"===i?this.map.queryRenderedFeatures(e,t):[];return r.length||"point"===i?r:this.map.queryRenderedFeatures(this.toPaddedBounds(e),t)}clearLongHoverTimeout(){window.clearTimeout(this.longHoverTimeoutHandlerID)}restartLongHoverTimeout(){this.clearLongHoverTimeout(),this.longHoverTimeoutHandlerID=window.setTimeout(()=>this.handleLongHoverTimeout(),this.firstDelayedHoverSinceMapMove?this.config.longHoverDelayAfterMapMoveMS:this.config.longHoverDelayOnStillMapMS)}handleLongHoverTimeout(){if(this.firstDelayedHoverSinceMapMove=!1,this.hoveringSourceWithLayers){Oe("long-hover",this.hoveringFeature,void 0,this.hoveringSourceWithLayers,void 0);const e=this.findHandlers(["long-hover"],this.hoveringFeature?.layer.id);if(e.length){const t=this.hoveringFeatures??we,i=this.hoveringFeature,r=this.toCallerFeatures(t,i);for(const s of e){const e=this.callerFeaturesFor(s,t,i,r);s.fn(e[0],this.hoveringLngLat,e,s.sourceWithLayers)}}}}onMouseStart(){this.firstDelayedHoverSinceMapMove=!0,this.clearLongHoverTimeout()}onMouseOut(){this.clearLongHoverTimeout()}onMouseDown(){this.lastCursorStyle=this.mapCanvas.style.cursor,this.mapCanvas.style.cursor=this.config.cursorOnMouseDown}onMouseUp(){this.mapCanvas.style.cursor=this.lastCursorStyle}onMouseMove(e){this.pendingMouseMove=e,this.mouseMoveFrameRequested||(this.mouseMoveFrameRequested=!0,requestAnimationFrame(()=>{this.mouseMoveFrameRequested=!1;const e=this.pendingMouseMove;this.pendingMouseMove=void 0,e&&this.handleMouseMove(e)}))}handleMouseMove(e){if(!this.isEnabled())return;this.hoveringFeatures=this.getRenderedFeatures(e.point);const[t]=this.hoveringFeatures;if(t&&!this.hasHandlerForLayer(t.layer.id))return;const{hoverChanged:i,mouseInMotionOverHoveredFeature:r}=((e,t,i,r)=>{if(t){if(!r)return{hoverChanged:!0};if(t.id&&t.id!==r.id||t.properties.id&&t.properties.id!==r.properties.id||t.source!==r.source||t.layer.id!==r.layer.id)return{hoverChanged:!0};if(i&&(e.x-i.x!=0||e.y-i.y!=0))return{mouseInMotionOverHoveredFeature:!0}}else if(r)return{hoverChanged:!0};return{}})(e.point,t,this.hoveringPoint,this.hoveringFeature);if(!i&&!r)return;const s=this.hoveringFeature,a=this.hoveringSourceWithLayers;let o;this.hoveringLngLat=e.lngLat,this.hoveringPoint=e.point,this.hoveringFeature=t,this.hoveringSourceWithLayers=this.sourceWithLayersFor(t?.layer.id),i&&(o=this.dispatchHoverEnter(e,s,a)),r&&this.dispatchHoverMove(e,o),this.restartLongHoverTimeout()}dispatchHoverEnter(e,t,i){const r=this.hoveringFeature?.layer.id,s=this.findHandlers(["hover","hover-move","long-hover","click","contextmenu"],r,this.hoveringFeature)?.[0];this.updateHoverCursor(s?.config),Oe("hover",this.hoveringFeature,t,this.hoveringSourceWithLayers,i);const a=this.findHandlers(["hover"],r);if(!a.length)return;const o=this.toCallerFeatures(this.hoveringFeatures??we,this.hoveringFeature);return this.dispatchToHandlers(a,e,this.hoveringFeature,o),o}dispatchHoverMove(e,t){const i=this.findHandlers(["hover-move"],this.hoveringFeature?.layer.id);if(!i.length)return;const r=this.hoveringFeature,s=t??this.toCallerFeatures(this.hoveringFeatures??we,r);this.dispatchToHandlers(i,e,r,s)}dispatchToHandlers(e,t,i,r){for(const s of e){const e=this.callerFeaturesFor(s,this.hoveringFeatures??we,i,r);s.fn(e[0],t.lngLat,e,s.sourceWithLayers)}}updateHoverCursor(e){this.hoveringFeature?this.mapCanvas.style.cursor=e?.cursorOnHover??this.config.cursorOnHover:this.mapCanvas.style.cursor=this.config.cursorOnMap}onMapClick(e,t){if(!this.isEnabled())return;const i=this.getRenderedFeatures(t.point),r=this.lastClickedFeature;this.lastClickedFeature=i[0];const s=this.lastClickedSourceWithLayers,a=this.findHandlers([e],this.lastClickedFeature?.layer.id);if(this.lastClickedSourceWithLayers=a[0]?.sourceWithLayers,Oe(e,this.lastClickedFeature,r,this.lastClickedSourceWithLayers,s),a.length){const e=this.lastClickedFeature,r=this.toCallerFeatures(i,e);for(const s of a){const a=this.callerFeaturesFor(s,i,e,r);s.fn(a[0],t.lngLat,a,s.sourceWithLayers)}}}},xe={country:"Places - Country name",lowestPlaceLabel:"Places - Village / Hamlet",poi:"POI",lowestLabel:"Borders - Treaty label",lowestRoadLine:"Tunnel - Railway outline",lowestBuilding:"Buildings - Underground"},De="vectorTiles",Fe="hillshade",Pe="vectorTiles",Ue="vectorTilesIncidents",He="vectorTilesFlow",ke=/* @__PURE__ */new WeakMap,We=async(e,t,i,r)=>{let s=ke.get(e);s||(s=/* @__PURE__ */new Map,ke.set(e,s));const a=s.get(t);if(a){const e=await a;return r?.(e),e}const o=Promise.resolve().then(i);s.set(t,o);try{return await o}catch(n){throw s.delete(t),n}},Ge=["POI","POI - Micro"],Be={NATIVE_RESERVATION:"aboriginal_land",AIRPORT:"airport",AMUSEMENT_PARK:"amusement_park",ATM:"atm",BANK:"bank",BAR:"bar",BEACH:"beach_resort",ACCESS_GATEWAY:"border_control",FRONTIER_CROSSING:"border_control",BUS_STOP:"bus_station",CAFE:"cafe",CAFE_PUB:"cafe",CAMPING_GROUND:"camping_ground",RENT_A_CAR_FACILITY:"car_rental",CASINO:"casino_and_gambling",CEMETERY:"cemetery",ELECTRIC_VEHICLE_STATION:"charging_location",CINEMA:"cinema",MOVIE_THEATER:"cinema",HEALTH_CARE_SERVICE:"clinic",CLOTHING_SHOP:"clothing_shop",COFFEE_SHOP:"coffee_shop",COLLEGE_OR_UNIVERSITY:"college_or_university",COLLEGE_UNIVERSITY:"college_or_university",AGRICULTURE:"commercial_area",BUSINESS_PARK:"commercial_area",COMMERCIAL_BUILDING:"commercial_area",COMPANY:"commercial_area",RESIDENTIAL_ACCOMMODATION:"commercial_area",EXHIBITION_CONVENTION_CENTER:"conference_center",CLUB_ASSOCIATION:"consumer_service",PUBLIC_AMENITY:"consumer_service",WELFARE_ORGANIZATION:"consumer_service",COURTHOUSE:"courthouse",COMMUNITY_CENTER:"cultural_center",CULTURAL_CENTER:"cultural_center",DENTIST:"dentist",DEPARTMENT_STORE:"department_store",DOCTOR:"doctor",EMERGENCY_MEDICAL_SERVICE:"emergency_ward_entrance",EMERGENCY_ROOM:"emergency_ward_entrance",FAST_FOOD:"fast_food",FERRY_TERMINAL:"ferry_terminal",FIRE_STATION_BRIGADE:"fire_station",FITNESS_CLUB_CENTER:"fitness_center",WINERY:"food_and_drinks_shop",CURRENCY_EXCHANGE:"foreign_exchange",EXCHANGE:"foreign_exchange",GAS_STATION:"fuel_station",GOLD_EXCHANGE:"gold_exchange",GOLF_COURSE:"golf_course",EMBASSY:"government_office",GOVERNMENT_OFFICE:"government_office",HELIPAD_HELICOPTER_LANDING:"heliport_or_helipad",HISTORIC_SITE:"historic_site",HOLIDAY_RENTAL:"holiday_home",GENERAL_HOSPITAL_AND_POLYCLINIC:"hospital",HOSPITAL:"hospital",HOTEL_MOTEL:"hotel_or_motel",ICE_SKATING_RINK:"ice_rink",INDUSTRIAL_BUILDING:"industrial_area",PORT_WAREHOUSE_FACILITY:"industrial_area",PRIMARY_RESOURCE_UTILITY:"industrial_area",GEOGRAPHIC_FEATURE:"landmark",SHOPPING_CENTER:"mall",MANUFACTURING_FACILITY:"manufacturing_facility",MARINA:"marina",MARKET:"marketplace",MEDIA_FACILITY:"media_facility",MOUNTAIN_PASS:"mountain_pass",MUSEUM:"museum",NON_GOVERNMENTAL_ORGANIZATION:"ngo_office",CONCERT_HALL:"nightlife",ENTERTAINMENT:"nightlife",NIGHTLIFE:"nightlife",PARK_RECREATION_AREA:"park_and_recreation_area",TRAIL_SYSTEM:"park_and_recreation_area",LEISURE_CENTER:"park_and_recreation_facility",WATER_SPORT:"park_and_recreation_facility",OPEN_PARKING_AREA:"parking_facility",PARKING_GARAGE:"parking_facility",PHARMACY:"pharmacy",POLICE_STATION:"police_station",POST_OFFICE:"post_office",PRISON_CORRECTIONAL_FACILITY:"prison",PROTECTED_AREA:"protected_land",PUB:"pub",LIBRARY:"public_library",PUBLIC_TRANSPORT_STOP:"public_transport_stop",RAILWAY_STATION:"railway_station",CHURCH:"religious_site",GURUDWARA:"religious_site",MOSQUE:"religious_site",PAGODA:"religious_site",PLACE_OF_WORSHIP:"religious_site",SYNAGOG:"religious_site",TEMPLE:"religious_site",RENT_A_CAR_PARKING:"rental_car_parking",RESEARCH_FACILITY:"research_facility",REST_AREA:"rest_and_service_area",RESTAURANT:"restaurant",RESTAURANT_AREA:"restaurant",SCHOOL:"school_or_kindergarten",SHOP:"shop_or_store",ADVENTURE_SPORTS_FACILITY:"sport_facility",SPORTS_CENTER:"sport_facility",TENNIS_COURT:"sport_facility",STADIUM:"stadium",SUPERMARKETS_HYPERMARKETS:"supermarket",SWIMMING_POOL:"swimming_pool",TAXI_STAND:"taxi_stand",OPERA_HOUSE:"theater",THEATER:"theater",TOLL_GATE:"toll_booth",TOURIST_ATTRACTION:"tourist_attraction",TOURIST_INFORMATION_OFFICE:"tourist_information",TRUCK_STOP:"truck_stop",AUTOMOTIVE_DEALER:"vehicle_dealer",MOTORING_ORGANIZATION_OFFICE:"vehicle_inspection",TRAFFIC_CONTROL_DEPARTMENT:"vehicle_inspection",TRANSPORT_AUTHORITY_VEHICLE_REGISTRATION:"vehicle_inspection",REPAIR_FACILITY:"vehicle_repair",CAR_WASH:"vehicle_wash",VETERINARIAN:"veterinary",HILL:"viewpoint",MOUNTAIN_PEAK:"viewpoint",SCENIC_PANORAMIC_VIEW:"viewpoint",WEIGH_STATION:"weighbridge",AQUATIC_ZOO:"zoo_or_aquarium",ARBORETA_BOTANICAL_GARDENS:"zoo_or_aquarium",ZOOS_ARBORETA_BOTANICAL_GARDEN:"zoo_or_aquarium"},Ve={...Be,AIRFIELD:"airport",AIRLINE_ACCESS:"airport",PRIVATE_AIRPORT:"airport",PUBLIC_AIRPORT:"airport",ANIMAL_SHELTER:"animal_shelter",DIVERSIFIED_FINANCIALS:"bank",COCKTAIL_BAR:"bar",BEACH_CLUB:"beach_resort",SECURED_ENTRANCE:"border_control",INTERNET_CAFE:"cafe",CAFETERIA:"cafeteria",CARAVAN_SITE:"camping_ground",RECREATIONAL_CAMPING_GROUND:"camping_ground",REST_CAMP:"camping_ground",MAUSOLEUM_GRAVE:"cemetery",CHILD_CARE_FACILITY:"childcare",PRE_SCHOOL:"childcare",DRIVE_IN_MOVIES:"cinema",CHILDRENS_CLOTHES:"clothing_shop",MENS_CLOTHING:"clothing_shop",SPECIALTY_CLOTHING_SHOP:"clothing_shop",WOMENS_CLOTHING:"clothing_shop",JUNIOR_COLLEGE_COMMUNITY_COLLEGE:"college_or_university",COMEDY_CLUB:"comedy_club",ADVERTISING_COMPANY:"commercial_area",AGRICULTURAL_TECHNOLOGY:"commercial_area",AIRLINE_COMPANY:"commercial_area",APARTMENT_RENTAL:"commercial_area",AUTOMOBILE_COMPANY:"commercial_area",BUILDING:"commercial_area",BUSINESS_SERVICES:"commercial_area",BUS_CHARTER_COMPANY:"commercial_area",CABLE_TELEPHONE_COMPANY:"commercial_area",CLEANING_SERVICES:"commercial_area",COMPUTER_DATA_SERVICES:"commercial_area",CONSTRUCTION_COMPANY:"commercial_area",DELIVERY_SERVICE:"commercial_area",ELECTRONICS_COMPANY:"commercial_area",EQUIPMENT_RENTAL:"commercial_area",FARM:"commercial_area",FLATS_APARTMENT_COMPLEX:"commercial_area",HORTICULTURE:"commercial_area",IMPORT_EXPORT_AND_DISTRIBUTION:"commercial_area",INSURANCE_COMPANY:"commercial_area",INVESTMENT_ADVISOR:"commercial_area",LEGAL_SERVICES:"commercial_area",MINING_COMPANY:"commercial_area",MOVING_STORAGE_COMPANY:"commercial_area",OIL_NATURAL_GAS:"commercial_area",PHARMACEUTICAL_COMPANY:"commercial_area",PRIMARY_PRODUCER:"commercial_area",PUBLISHING_TECHNOLOGIES:"commercial_area",REAL_ESTATE_AGENT:"commercial_area",REAL_ESTATE_COMPANY:"commercial_area",RETIREMENT_COMMUNITY:"commercial_area",SERVICE_COMPANY:"commercial_area",SOFTWARE_COMPANY:"commercial_area",TAX_SERVICES:"commercial_area",TELECOMMUNICATIONS:"commercial_area",TRANSPORT_COMPANY:"commercial_area",TRAVEL_AGENT:"commercial_area",WEDDING_SERVICES:"commercial_area",PUBLIC_CALL_BOX:"consumer_service",PUBLIC_TOILET:"consumer_service",GENERAL_PRACTITIONER:"doctor",SPECIALIST:"doctor",AMBULANCE_UNIT:"emergency_ward_entrance",ROAD_RESCUE:"emergency_ward_entrance",MICROBREWERY:"food_and_drinks_shop",BATTLEFIELD:"historic_site",MEMORIAL:"historic_site",BUNGALOW_RENTAL:"holiday_home",CHALET_RENTAL:"holiday_home",COTTAGE_RENTAL:"holiday_home",VILLA_RENTAL:"holiday_home",HORSE_RIDING_CENTER:"horse_riding",BLOOD_BANK:"hospital",HOSPITAL_FOR_WOMEN_AND_CHILDREN:"hospital",HOSPITAL_OF_CHINESE_MEDICINE:"hospital",SPECIAL_HOSPITAL:"hospital",B_B_GUEST_HOUSE:"hotel_or_motel",CABINS_LODGES:"hotel_or_motel",HOSTEL:"hotel_or_motel",HOTEL:"hotel_or_motel",MOTEL:"hotel_or_motel",RESORT:"hotel_or_motel",ICE_CREAM_PARLOR:"ice_cream_shop",ICE_HOCKEY_ARENA:"ice_rink",CHEMICAL_COMPANY:"industrial_area",MECHANICAL_ENGINEERING:"industrial_area",QUARRY:"industrial_area",YOGURT_JUICE_BAR:"juice_bar",ARCH:"landmark",BAY:"landmark",BRIDGE:"landmark",CAPE:"landmark",COVE:"landmark",DAM:"landmark",DUNE:"landmark",ISLAND:"landmark",LOCALE:"landmark",MARSH:"landmark",MONUMENT:"landmark",OASIS:"landmark",OBSERVATORY:"landmark",PARKWAY:"landmark",PLAIN_FLAT:"landmark",PLATEAU:"landmark",RAPIDS:"landmark",REEF:"landmark",RESERVOIR:"landmark",RIVER_CROSSING:"landmark",ROCKS:"landmark",STATUE:"landmark",TOWER:"landmark",TUNNEL:"landmark",VALLEY:"landmark",WATER_HOLE:"landmark",WELL:"landmark",AUTOMOBILE_MANUFACTURING:"manufacturing_facility",MANUFACTURING_COMPANY:"manufacturing_facility",FARMERS_MARKET:"marketplace",FOOD_MARKET:"marketplace",INFORMAL_MARKET:"marketplace",PUBLIC_MARKET:"marketplace",MILITARY_AIRPORT:"military_airfield",FUNERAL_SERVICE_MORTUARIES:"mourning_facility",AMUSEMENT_PLACE:"nightlife",BETTING_STATION:"nightlife",CABARET_THEATER:"nightlife",DISCO_CLUB:"nightlife",FAIRGROUND:"nightlife",JAZZ_CLUB:"nightlife",KARAOKE_CLUB:"nightlife",MUSIC_CENTER:"nightlife",ADVENTURE_VEHICLE_TRAIL:"park_and_recreation_area",FISHING_HUNTING_AREA:"park_and_recreation_area",FOREST_AREA:"park_and_recreation_area",HIKING_TRAIL:"park_and_recreation_area",HISTORICAL_PARK:"park_and_recreation_area",HORSE_RIDING_TRAIL:"park_and_recreation_area",MOUNTAIN_BIKE_TRAIL:"park_and_recreation_area",PARK:"park_and_recreation_area",PICNIC_AREA:"park_and_recreation_area",RECREATION_AREA:"park_and_recreation_area",ROCK_CLIMBING_TRAIL:"park_and_recreation_area",WILDERNESS_AREA:"park_and_recreation_area",OPEN_CAR_PARKING_AREA:"parking_facility",BEAUTY_SALON:"personal_care_service",HAIRDRESSER:"personal_care_service",NAIL_SALON:"personal_care_service",PERSONAL_CARE_FACILITY:"personal_care_service",PERSONAL_SERVICE:"personal_care_service",SAUNA_SOLARIUM_MASSAGE:"personal_care_service",DRUG_STORE:"pharmacy",MARIJUANA_DISPENSARY:"pharmacy",MEDICINAL_MARIJUANA_DISPENSARY:"pharmacy",RECREATIONAL_MARIJUANA_DISPENSARY:"pharmacy",PLANETARIUM:"planetarium",COURIER_DROP_BOX:"post_depot",BUS_LINES:"public_transport_stop",PASSENGER_TRANSPORT_TICKET_OFFICE:"public_transport_stop",STREETCAR_STOP:"public_transport_stop",SUBWAY_STATION:"public_transport_stop",INTERNATIONAL_RAILROAD_STATION:"railway_station",NATIONAL_RAILROAD_STATION:"railway_station",STATION_ACCESS:"railway_station",URBAN_STATION:"railway_station",AFGHAN_RESTAURANT:"restaurant",AFRICAN_RESTAURANT:"restaurant",AMERICAN_RESTAURANT:"restaurant",ARABIAN_RESTAURANT:"restaurant",ARMENIAN_RESTAURANT:"restaurant",ASIAN_RESTAURANT:"restaurant",AUSTRALIAN_RESTAURANT:"restaurant",AUSTRIAN_RESTAURANT:"restaurant",BANQUET_ROOMS:"restaurant",BARBECUE_RESTAURANT:"restaurant",BASQUE_RESTAURANT:"restaurant",BELGIAN_RESTAURANT:"restaurant",BISTRO:"restaurant",BOLIVIAN_RESTAURANT:"restaurant",BRAZILIAN_RESTAURANT:"restaurant",BRITISH_RESTAURANT:"restaurant",BUFFET_RESTAURANT:"restaurant",BULGARIAN_RESTAURANT:"restaurant",BURMESE_RESTAURANT:"restaurant",CALIFORNIAN_RESTAURANT:"restaurant",CAMBODIAN_RESTAURANT:"restaurant",CANADIAN_RESTAURANT:"restaurant",CARIBBEAN_RESTAURANT:"restaurant",CATERING_SERVICES:"restaurant",CHICKEN_RESTAURANT:"restaurant",CHINESE_RESTAURANT:"restaurant",COLOMBIAN_RESTAURANT:"restaurant",CORSICAN_RESTAURANT:"restaurant",CREOLE_RESTAURANT:"restaurant",CREPERIE:"restaurant",CUBAN_RESTAURANT:"restaurant",CZECH_RESTAURANT:"restaurant",DANISH_RESTAURANT:"restaurant",DINNER_THEATER:"restaurant",DONGBEI_RESTAURANT:"restaurant",DOUGHNUT_RESTAURANT:"restaurant",DUTCH_RESTAURANT:"restaurant",EGYPTIAN_RESTAURANT:"restaurant",ENGLISH_RESTAURANT:"restaurant",ETHIOPIAN_RESTAURANT:"restaurant",FINNISH_RESTAURANT:"restaurant",FONDUE_RESTAURANT:"restaurant",FRENCH_RESTAURANT:"restaurant",FUSION_RESTAURANT:"restaurant",GERMAN_RESTAURANT:"restaurant",GREEK_RESTAURANT:"restaurant",GRILL_RESTAURANT:"restaurant",HAMBURGER_RESTAURANT:"restaurant",HAWAIIAN_RESTAURANT:"restaurant",HOT_POT_RESTAURANT:"restaurant",HUNAN_RESTAURANT:"restaurant",HUNGARIAN_RESTAURANT:"restaurant",INDIAN_RESTAURANT:"restaurant",INDONESIAN_RESTAURANT:"restaurant",INTERNATIONAL_RESTAURANT:"restaurant",IRANIAN_RESTAURANT:"restaurant",IRISH_RESTAURANT:"restaurant",ISRAELI_RESTAURANT:"restaurant",ITALIAN_RESTAURANT:"restaurant",JAMAICAN_RESTAURANT:"restaurant",JAPANESE_RESTAURANT:"restaurant",JEWISH_RESTAURANT:"restaurant",KOREAN_RESTAURANT:"restaurant",KOSHER_RESTAURANT:"restaurant",LATIN_AMERICAN_RESTAURANT:"restaurant",LEBANESE_RESTAURANT:"restaurant",MEDITERRANEAN_RESTAURANT:"restaurant",MEXICAN_RESTAURANT:"restaurant",MIDDLE_EASTERN_RESTAURANT:"restaurant",MONGOLIAN_RESTAURANT:"restaurant",MOROCCAN_RESTAURANT:"restaurant",NEPALESE_RESTAURANT:"restaurant",NORWEGIAN_RESTAURANT:"restaurant",ORGANIC_FOOD_RESTAURANT:"restaurant",ORIENTAL_RESTAURANT:"restaurant",PAKISTANI_RESTAURANT:"restaurant",PERUVIAN_RESTAURANT:"restaurant",PHILIPPINE_RESTAURANT:"restaurant",PIZZERIA:"restaurant",POLISH_RESTAURANT:"restaurant",POLYNESIAN_RESTAURANT:"restaurant",PORTUGUESE_RESTAURANT:"restaurant",PUB_FOOD:"restaurant",RUSSIAN_RESTAURANT:"restaurant",SALAD_BAR:"restaurant",SANDWICH_RESTAURANT:"restaurant",SCANDINAVIAN_RESTAURANT:"restaurant",SEAFOOD:"restaurant",SHANDONG_RESTAURANT:"restaurant",SICHUAN_RESTAURANT:"restaurant",SNACKS_RESTAURANT:"restaurant",SOUL_FOOD:"restaurant",SOUP_RESTAURANT:"restaurant",SPANISH_RESTAURANT:"restaurant",STEAK_HOUSE:"restaurant",SUSHI_RESTAURANT:"restaurant",SWEDISH_RESTAURANT:"restaurant",SWISS_RESTAURANT:"restaurant",SYRIAN_RESTAURANT:"restaurant",TAIWANESE_RESTAURANT:"restaurant",TAKEOUT_FOOD:"restaurant",TAPAS_RESTAURANT:"restaurant",TEPPANYAKI_RESTAURANT:"restaurant",THAI_RESTAURANT:"restaurant",TIBETAN_RESTAURANT:"restaurant",TUNISIAN_RESTAURANT:"restaurant",TURKISH_RESTAURANT:"restaurant",VEGETARIAN_RESTAURANT:"restaurant",VENEZUELAN_RESTAURANT:"restaurant",VIETNAMESE_RESTAURANT:"restaurant",WESTERN_RESTAURANT:"restaurant",ART_SCHOOL:"school_or_kindergarten",DANCE_STUDIO_SCHOOL:"school_or_kindergarten",DRIVING_SCHOOL:"school_or_kindergarten",HIGH_SCHOOL:"school_or_kindergarten",LANGUAGE_SCHOOL:"school_or_kindergarten",MIDDLE_SCHOOL:"school_or_kindergarten",PRIMARY_SCHOOL:"school_or_kindergarten",SENIOR_HIGH_SCHOOL:"school_or_kindergarten",VOCATIONAL_SCHOOL:"school_or_kindergarten",AGRICULTURAL_SUPPLIES:"shop_or_store",ANTIQUE_ART_SHOP:"shop_or_store",BAGS_LEATHERWEAR:"shop_or_store",BAKERY:"shop_or_store",BEAUTY_SUPPLIES:"shop_or_store",BOATING_EQUIPMENT_ACCESSORIES:"shop_or_store",BOOK_SHOP:"shop_or_store",BUTCHER:"shop_or_store",CAMERAS_PHOTOGRAPHY:"shop_or_store",CARPET_FLOOR_COVERINGS:"shop_or_store",CHRISTMAS_HOLIDAY_SHOP:"shop_or_store",COMPUTER_COMPUTER_SUPPLIES:"shop_or_store",CONSTRUCTION_MATERIAL_EQUIPMENT:"shop_or_store",CONSUMER_ELECTRONICS:"shop_or_store",CONVENIENCE_STORE:"shop_or_store",CURTAINS_TEXTILES:"shop_or_store",C_DS_DVD_VIDEOS:"shop_or_store",DELICATESSEN:"shop_or_store",DO_IT_YOURSELF_CENTERS:"shop_or_store",DRIVE_THROUGH_BOTTLE_SHOP:"shop_or_store",DRY_CLEANER:"shop_or_store",ELECTRICAL_APPLIANCES_SHOP:"shop_or_store",FACTORY_OUTLET:"shop_or_store",FISHMONGER:"shop_or_store",FLORISTS:"shop_or_store",FOOTWEAR_SHOE_REPAIRS:"shop_or_store",FURNITURE_HOME_FURNISHINGS:"shop_or_store",GARDEN_CENTERS_SERVICES:"shop_or_store",GIFTS_CARDS_NOVELTIES_SOUVENIRS:"shop_or_store",GLASSWARE_CERAMIC_SHOP:"shop_or_store",GLASS_WINDOWS_STORE:"shop_or_store",GREENGROCER:"shop_or_store",GROCERY_STORE:"shop_or_store",HARDWARE_STORE:"shop_or_store",HOBBY_SHOP:"shop_or_store",HOUSE_GARDEN_FURNITURE_FITTINGS:"shop_or_store",JEWELRY_CLOCKS_WATCHES:"shop_or_store",KITCHENS_BATHROOMS:"shop_or_store",LAUNDRY:"shop_or_store",LIGHTING_SHOPS:"shop_or_store",LOCAL_SPECIALITIES_SHOP:"shop_or_store",LOTTERY_SHOP:"shop_or_store",MEDICAL_SUPPLIES_EQUIPMENT:"shop_or_store",MOBILE_PHONE_SHOP:"shop_or_store",MUSIC_INSTRUMENTS_STORE:"shop_or_store",NEWSAGENTS_TOBACCONISTS:"shop_or_store",OFFICE_EQUIPMENT:"shop_or_store",OPTICIAN:"shop_or_store",OTHER_FOOD_SHOPS:"shop_or_store",PAINTING_DECORATING:"shop_or_store",PAWN_SHOP:"shop_or_store",PET_SUPPLIES:"shop_or_store",PHOTOCOPY_SHOP:"shop_or_store",PHOTO_LAB_DEVELOPMENT:"shop_or_store",RECYCLING_SHOP:"shop_or_store",RETAIL_OUTLET:"shop_or_store",SECURITY_PRODUCTS:"shop_or_store",SHOPPING_SERVICE:"shop_or_store",SPECIALTY_FOODS:"shop_or_store",SPORTS_EQUIPMENT_CLOTHING:"shop_or_store",TAILOR_SHOP:"shop_or_store",TOYS_GAMES_SHOP:"shop_or_store",VARIETY_STORE:"shop_or_store",VIDEO_RENTAL_SHOP:"shop_or_store",WHOLESALE_CLUB:"shop_or_store",WINE_SPIRITS:"shop_or_store",ATHLETICS_TRACK:"sport_facility",BASEBALL_PARK:"sport_facility",BASKETBALL_ARENA:"sport_facility",BOWLING_CENTER:"sport_facility",CRICKET_GROUND:"sport_facility",HOCKEY_CLUB:"sport_facility",HORSE_RACING_TRACK:"sport_facility",RACE_TRACK:"sport_facility",RUGBY_GROUND:"sport_facility",SNOOKER_POOL_BILLIARD:"sport_facility",THEMATIC_SPORT_CENTER:"sport_facility",FOOTBALL_STADIUM:"stadium",MOTOR_RACING_STADIUM:"stadium",MULTI_PURPOSE_STADIUM:"stadium",NETBALL_STADIUM:"stadium",SOCCER_STADIUM:"stadium",STOCK_EXCHANGE:"stock_exchange",TAXI_LIMOUSINE_SHUTTLE_SERVICE:"taxi_stand",TEA_HOUSE:"tea_house",AMPHITHEATER:"theater",CAVE:"tourist_attraction",MINERAL_HOT_SPRINGS:"tourist_attraction",NATURAL_TOURIST_ATTRACTION:"tourist_attraction",BOAT_LAUNCHING_RAMP:"transport_access",HARBOR:"transport_access",YACHT_BASIN:"transport_access",ATV_DEALER:"vehicle_dealer",BOAT_DEALER:"vehicle_dealer",BUS_DEALER:"vehicle_dealer",CAR_DEALER:"vehicle_dealer",MOTORCYCLE_DEALER:"vehicle_dealer",RECREATIONAL_VEHICLE_DEALER:"vehicle_dealer",TRUCK_DEALER:"vehicle_dealer",VAN_DEALER:"vehicle_dealer",ROAD_TRAFFIC_CONTROL_CENTER:"vehicle_inspection",BODYSHOP:"vehicle_repair",CAR_GLASS_REPLACEMENT_SHOP:"vehicle_repair",CAR_REPAIR_AND_SERVICE:"vehicle_repair",HOME_APPLIANCE_REPAIR:"vehicle_repair",MOTORCYCLE_REPAIR:"vehicle_repair",TIRE_SERVICE:"vehicle_repair",TRUCK_REPAIR_AND_SERVICE:"vehicle_repair",ANIMAL_SERVICES:"veterinary",RIDGE:"viewpoint",OTHER_WINTER_SPORT:"winter_sports",SKI_RESORT:"winter_sports",WILDLIFE_PARK:"zoo_or_aquarium",ZOO:"zoo_or_aquarium"},je=e=>Ve[e],ze=Array.from(new Set(Object.values(Ve))),$e={bar:"eat_and_drink",cafe:"eat_and_drink",cafeteria:"eat_and_drink",coffee_shop:"eat_and_drink",fast_food:"eat_and_drink",ice_cream_shop:"eat_and_drink",juice_bar:"eat_and_drink",pub:"eat_and_drink",restaurant:"eat_and_drink",tea_house:"eat_and_drink",clothing_shop:"shopping",department_store:"shopping",food_and_drinks_shop:"shopping",mall:"shopping",marketplace:"shopping",shop_or_store:"shopping",supermarket:"shopping",atm:"finance",bank:"finance",foreign_exchange:"finance",gold_exchange:"finance",stock_exchange:"finance",camping_ground:"lodging",holiday_home:"lodging",hotel_or_motel:"lodging",airport:"transport",bus_station:"transport",ferry_terminal:"transport",heliport_or_helipad:"transport",marina:"transport",public_transport_stop:"transport",railway_station:"transport",taxi_stand:"transport",transport_access:"transport",border_control:"driving",car_rental:"driving",charging_location:"driving",fuel_station:"driving",rest_and_service_area:"driving",toll_booth:"driving",truck_stop:"driving",vehicle_dealer:"driving",vehicle_inspection:"driving",vehicle_repair:"driving",vehicle_wash:"driving",weighbridge:"driving",parking_facility:"parking",rental_car_parking:"parking",clinic:"healthcare",dentist:"healthcare",doctor:"healthcare",emergency_ward_entrance:"healthcare",hospital:"healthcare",pharmacy:"healthcare",veterinary:"healthcare",childcare:"education",college_or_university:"education",research_facility:"education",school_or_kindergarten:"education",cultural_center:"cultural",historic_site:"cultural",museum:"cultural",planetarium:"cultural",theater:"cultural",amusement_park:"leisure",beach_resort:"leisure",casino_and_gambling:"leisure",cinema:"leisure",comedy_club:"leisure",nightlife:"leisure",park_and_recreation_facility:"leisure",tourist_attraction:"leisure",tourist_information:"leisure",zoo_or_aquarium:"leisure",fitness_center:"sport",golf_course:"sport",horse_riding:"sport",ice_rink:"sport",sport_facility:"sport",stadium:"sport",swimming_pool:"sport",winter_sports:"sport",aboriginal_land:"outdoor",landmark:"outdoor",mountain_pass:"outdoor",park_and_recreation_area:"outdoor",viewpoint:"outdoor",protected_land:"protected",cemetery:"public",courthouse:"public",fire_station:"public",government_office:"public",police_station:"public",post_depot:"public",post_office:"public",prison:"public",public_library:"public",military_airfield:"military",religious_site:"religion",animal_shelter:"business",commercial_area:"business",conference_center:"business",consumer_service:"business",industrial_area:"business",manufacturing_facility:"business",media_facility:"business",mourning_facility:"business",ngo_office:"business",personal_care_service:"business"},Ye=e=>{const t=je(e);return t?$e[t]:void 0},qe="Noto-Bold",Ke=.8,Xe=["interpolate",["linear"],["zoom"],8,.6,22,Ke],Ze="title",Je="iconID",Qe=.7,et="default_place",tt="poi-parking-micro",it={"icon-image":["get",Je],"icon-anchor":"bottom","icon-size":Xe,"icon-allow-overlap":!0,"icon-padding":0},rt={"icon-translate":[0,5],"icon-translate-anchor":"viewport"},st={"text-optional":!0,"text-font":[qe],"text-field":["get",Ze],"text-justify":"auto","text-variable-anchor":["top","left","right"],"text-variable-anchor-offset":["top",[0,Qe],"left",[1.4,-1.4],"right",[-1.4,-1.4]],"text-size":["interpolate",["linear"],["zoom"],10,14,18,16],"text-padding":5},at={"text-halo-width":["interpolate",["linear"],["zoom"],6,1,10,1.5],"text-translate-anchor":"viewport"},ot={type:"symbol",layout:{...it,...st},paint:{...rt,...at}},nt=(e,t)=>`${e}-${t}`,lt=["has","point_count"],ct=["!",lt],ht="clusterBaseMapIconIDs",ut=["all",lt,["==",["index-of",",",["get",ht]],-1]],dt=["all",lt,[">=",["index-of",",",["get",ht]],0]],pt=[12,-14],ft={[ht]:(Q="baseMapIconID",ee=ht,[["case",["==",["get",ee],null],["accumulated"],["==",["accumulated"],null],["get",ee],[">=",["index-of",["concat",",",["get",ee],","],["concat",",",["accumulated"],","]],0],["accumulated"],["concat",["accumulated"],",",["get",ee]]],["get",Q]])},yt=e=>{const t=["match",e];for(const i of ze){const e=`poi-${i}`;t.push(e,["image",e])}return t.push(["image",tt]),t},mt={type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#3f9cd9","line-width":1.5,"line-dasharray":[2,2],"line-opacity":.9}},gt={type:"symbol",layout:{"symbol-placement":"line-center","text-field":["get","label"],"text-size":12,"text-offset":[0,-1],"text-allow-overlap":!1,"text-ignore-placement":!1,"text-keep-upright":!0},paint:{"text-color":"#1a5f8a","text-halo-color":"#ffffff","text-halo-width":1.5}},_t=(e,t)=>{if(!e)return;const i=(e=>{try{if("string"==typeof e){if(e.includes("<svg")){const t=Z(e),i=t.getAttribute("viewBox");if(i){const e=i.split(/\s+/);if(4===e.length)return{width:Number.parseFloat(e[2]),height:Number.parseFloat(e[3])}}const r=t.getAttribute("width"),s=t.getAttribute("height");if(r&&s)return{width:Number.parseFloat(r),height:Number.parseFloat(s)}}return null}return e.complete&&e.naturalWidth>0?{width:e.naturalWidth,height:e.naturalHeight}:null}catch(t){return console.warn("Failed to extract image dimensions:",t),null}})(e);if(!i)return;const r="base-map"===t||"circle-icon"===t,s=r?54:140,a=r?54:120;return{heightScale:i.height/s,widthScale:i.width/a}},Lt=e=>Boolean(e&&"availability"in e&&e.availability),At=e=>"ELECTRIC_VEHICLE_STATION"===e.properties.poi?.categories?.[0]&&Lt(e.properties.chargingPark),St=e=>{const t=e.properties.chargingPark;if(Lt(t)){const e=t.availability.chargingPointAvailability,i=e.statusCounts.Available??0;return{availableCount:i,totalCount:e.count,ratio:i/e.count}}},It=(e,t)=>`${e}/${t}`,Et=e=>St(e)?.ratio??0,bt=e=>["case",[">=",["get","evAvailabilityRatio"],e?.threshold??0],"green","red"],Rt=e=>Math.round(1e4*e)/1e4,Tt=(e,t,i,r)=>{const s=void 0!==r;return{top:s?[0,r]:[0,Rt(e)],left:s?[r,Rt(i)]:[Rt(t),Rt(i)],right:s?[-r,Rt(i)]:[-Rt(t),Rt(i)]}},Ct=(e,t,i,r)=>{const s=(e=>{if(!e)return Ke;if("number"==typeof e)return e;if(Array.isArray(e)){const t=e.at(-1);if("number"==typeof t)return t}if("object"==typeof e&&"stops"in e){const t=e.stops;if(Array.isArray(t)&&t.length>0){const e=t.at(-1);if(Array.isArray(e)&&"number"==typeof e[1])return e[1]}}return Ke})(e)/Ke,a="base-map"===i||"circle-icon"===i;if(a&&void 0!==r)return{"text-offset":[r,r]};const o=1.4*s,n=Tt(Qe*s,o,a?0:-o,r),l=["top",n.top,"left",n.left,"right",n.right];if(0===t.size)return{"text-variable-anchor-offset":l};const c=["case"];for(const[h,u]of t.entries()){const e=(a?1.4:Qe)*u.heightScale,t=1.4*u.widthScale,i=Tt(e,t,a?0:-t,r);c.push(["==",["get",Je],h],["literal",["top",i.top,"left",i.left,"right",i.right]])}return c.push(["literal",l]),{"text-variable-anchor-offset":c}},vt=(e,t,i,r,s)=>{const a=t?.text,o=t?.layers?.[i],n=s&&s.size>0,l={...e.layout},c=n||void 0!==a?.offset||"circle-icon"===t?.theme;c&&(delete l["text-offset"],delete l["text-variable-anchor-offset"],delete l["text-radial-offset"]);const h={...l,...o?.layout,...a?.size&&{"text-size":a.size},...a?.font&&{"text-font":a.font},...void 0!==r&&{"text-field":r}};if(c){const e=h["icon-size"],i=s??/* @__PURE__ */new Map;return{...h,...Ct(e,i,t?.theme,a?.offset)}}return h},Ot=(e,t,i,r)=>{const s=t?.text,a=t?.layers?.[i],{textColor:o,haloColor:n}=(e=>({textColor:"dark"===e?"#FFFFFF":"#333333",haloColor:"dark"===e?"#333333":"#FFFFFF"}))(r),l=e.paint??{};return{...l,...void 0===l["text-color"]&&{"text-color":o},...void 0===l["text-halo-color"]&&{"text-halo-color":n},...s?.color&&{"text-color":s.color},...s?.haloColor&&{"text-halo-color":s.haloColor},...s?.haloWidth&&{"text-halo-width":s.haloWidth},...a?.paint}},wt=["in",["get","eventState"],["literal",["click","contextmenu"]]],Nt=e=>JSON.parse(JSON.stringify(e)?.replaceAll("name",Ze)),Mt=(e,t)=>e.getStyle().layers.find(e=>e.id===t)??{},xt=e=>({filter:["!",wt],type:"symbol",paint:e.paint,layout:e.layout?s(e.layout,"visibility"):void 0}),Dt=e=>{const t=xt(Mt(e,"POI")),i=t.layout?.["text-size"];return{...t,layout:{...t.layout,"icon-image":["get",Je],"text-field":["get",Ze],...i&&{"text-size":Nt(i)}}}},Ft=e=>{const t=xt(Mt(e,"POI - Micro"));return{...t,minzoom:0,layout:{...t.layout,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{...t.paint,"icon-opacity":1}}},Pt=e=>{const t=Mt(e,"POI").layout??{};return{...ot,layout:{...ot.layout,"icon-anchor":"center",...void 0!==t["icon-size"]&&{"icon-size":t["icon-size"]},...void 0!==t["icon-padding"]&&{"icon-padding":t["icon-padding"]}},paint:{...ot.paint,"icon-translate":[0,0]}}},Ut=["has","eventState"],Ht={type:"symbol",layout:{visibility:"none"}},kt={type:"circle",layout:{visibility:"none"}},Wt="#3f9cd9",Gt={...ot,filter:["!",Ut]},Bt={...ot,filter:Ut,layout:{...ot.layout,"icon-size":["interpolate",["linear"],["zoom"],8,.8,22,1],"text-allow-overlap":!0},paint:{...ot.paint,"text-color":Wt}},Vt=e=>({...e,filter:Ut,layout:{...e.layout,"text-allow-overlap":!0},paint:{...e.paint,"text-color":Wt}}),jt=(e,t,i,r,s)=>{const a=t?.text,o=t?.layers?.[i],n=!0===t?.evAvailability?.enabled,l=a?.title&&"function"!=typeof a?.title?a.title:n?((e,t)=>t?["case",["has","evAvailabilityText"],["format",["get",Ze],{},"\n",{},["get","evAvailabilityText"],{"font-scale":1.1,"text-color":bt(e?.evAvailability)}],["get",Ze]]:["get",Ze])(t,n):void 0;return{...e,...o,layout:vt(e,t,i,l,s),paint:Ot(e,t,i,r)}},zt=(e,t,i,r)=>{const s=((e,t)=>{const i=/* @__PURE__ */new Map,r=e?.icon?.categoryIcons??[];for(const s of r)if(s.image){const r=_t(s.image,e?.theme);if(void 0!==r){const e=nt(s.id,t);if(i.set(e,r),s.availabilityLevel){const e=nt(`${s.id}-${s.availabilityLevel}`,t);i.set(e,r)}}}return i})(e,r);let a,o,n=Ht,l=Ht,c=kt,h=Ht,u=kt,d=Ht;if("base-map"===e?.theme)a={...Dt(t),minzoom:10},n=Ft(t),o=(e=>Vt(Dt(e)))(t);else if("circle-icon"===e?.theme)a=(e=>({...Pt(e),filter:["!",Ut]}))(t),o=(e=>Vt(Pt(e)))(t);else if("pin-clustered"===e?.theme){a={...Gt,filter:["all",ct,["!",Ut]]},o={...Bt,filter:["all",ct,Ut]};const e=Ft(t);n={...e,filter:e.filter?["all",ct,e.filter]:ct},l={type:"symbol",filter:ut,layout:{"icon-image":yt(["get",ht]),"icon-size":1,"icon-allow-overlap":!0,"icon-ignore-placement":!0}},c={type:"circle",filter:ut,paint:{"circle-radius":11,"circle-color":"#000000","circle-stroke-color":"#FFFFFF","circle-stroke-width":1.5,"circle-translate":pt,"circle-translate-anchor":"viewport"}},h={type:"symbol",filter:ut,layout:{"text-field":["get","point_count_abbreviated"],"text-font":[qe],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#FFFFFF","text-translate":pt,"text-translate-anchor":"viewport"}},u={type:"circle",filter:dt,paint:{"circle-radius":15,"circle-color":"#000000","circle-stroke-color":"#FFFFFF","circle-stroke-width":1.5}},d={type:"symbol",filter:dt,layout:{"text-field":["get","point_count_abbreviated"],"text-font":[qe],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#FFFFFF"}}}else a=Gt,o=Bt;return{micro:{...jt(n,e,"micro",i,s),beforeID:xe.lowestPlaceLabel},main:{...jt(a,e,"main",i,s),beforeID:"selected"},selected:jt(o,e,"selected",i,s),cluster:{...l,...e?.layers?.cluster,beforeID:"clusterBadge"},clusterBadge:{...c,...e?.layers?.clusterBadge,beforeID:"clusterCount"},clusterCount:{...h,...e?.layers?.clusterCount,beforeID:"clusterMixedBadge"},clusterMixedBadge:{...u,...e?.layers?.clusterMixedBadge,beforeID:"clusterMixedCount"},clusterMixedCount:{...d,...e?.layers?.clusterMixedCount},...e?.layers?.additional}},$t=e=>{if(K())return X(J(e))},Yt=(e,t)=>"string"!=typeof e?e:t.features.find(t=>t.id===e),qt=/* @__PURE__ */new Set([7339002,8099002,7369004,7321003,7376006,9362003,9362004,9160004,9376007,7315015,9376006,9376002,7315078,7315149,9376005,7372003,9352045,9352032,9361048,9902003,9378005,7383004,9910004,7320002,9362016,7320003,9362025,9942002,9942003,7380005,9663003,9361021,9379009,9379004,7315147,9376003,9160002,9160003,9352008,9361006,7389004,9910006]),Kt=e=>e.properties.poi?.name??e.properties.address.freeformAddress,Xt=(e,t,i)=>{if("pin"===t||"pin-clustered"===t)return(e=>{if(e)return qt.has(e)?q(e.toString()):q(e.toString().substring(0,4))})(S[e])??i;{const t=je(e);return t?`poi-${t}`:i}},Zt=(e,t,i={})=>{const r=i.theme??"pin",s=((e,t)=>e.icon?.default||"base-map"!==(e.theme??"pin")?nt(et,t):tt)(i,t),a=i.icon?.mapping;if(a)return"imageID"===a.to?a.fn(e):Xt(a.fn(e),r,s);const o=e.properties.poi?.categories?.[0],n=((e,t,i,r,s)=>{if(!r.evAvailability?.enabled||!At(e))return;const a=Et(e)>=(r.evAvailability.threshold??.3)?"available":"occupied",o=r.icon?.categoryIcons&&r.icon.categoryIcons.length>0,n=r.icon?.categoryIcons?.find(e=>e.id===t&&e.availabilityLevel===a);return n?nt(`${n.id}-${a}`,i):o||"pin"!==s?void 0:q(`7309-${a}`)})(e,o,t,i,r);if(n)return n;const l=i.icon?.categoryIcons?.find(e=>e.id===o);return l?nt(l.id,t):Xt(o,r,s)},Jt=(e,t)=>{const i=t?.icon?.mapping;return"poiCategory"===i?.to?i.fn(e):e.properties.poi?.categories?.[0]},Qt=(e,t)=>{const i=Jt(e,t);return i&&je(i)},ei=(e,t)=>{const i=Jt(e,t);return i&&Ye(i)},ti=e=>Array.isArray(e)?{type:"FeatureCollection",features:e}:"Feature"===e.type?{type:"FeatureCollection",features:[e]}:e,ii=(e,t,i)=>{if(!0!==t?.enabled)return e;let r=!1,s=!1;for(const a of i.features)if("ELECTRIC_VEHICLE_STATION"===a.properties.poi?.categories?.[0]&&(r=!0,At(a))){s=!0;break}return r&&!s&&console.warn("PlacesModule: evAvailability is enabled but no availability data found. Did you call getPlacesWithEVAvailability()?"),{...e,evAvailabilityText:e=>At(e)?((e,t)=>{const i=St(e);return i?(t?.formatText??It)(i.availableCount,i.totalCount):""})(e,t):"",evAvailabilityRatio:e=>At(e)?Et(e):0}},ri=(e,t)=>{const i=Qt(e,t);return i?`poi-${i}`:tt},si=(e,t,i={})=>{const r=ti(e),s=!0===i.evAvailability?.enabled?ii(i.extraFeatureProps,i.evAvailability,r):i.extraFeatureProps;return{...r,features:r.features.map(e=>{const r="function"==typeof i?.text?.title?i?.text?.title(e):Kt(e),a=s?Object.fromEntries(Object.entries(s).map(([t,i])=>[t,"function"==typeof i?i(e):i])):{},o=e.id??f();return{...e,id:o,geometry:{...e.geometry,bbox:e.bbox},properties:{...e.properties,id:o,title:r,iconID:Zt(e,t,i),...("base-map"===i?.theme||"pin-clustered"===i?.theme)&&{category:Qt(e,i),group:ei(e,i)},..."pin-clustered"===i?.theme&&{baseMapIconID:ri(e,i)},...a}}})}},ai=class e extends be{static async create(t,i){return await de(t),new e(t,i)}constructor(e,t){super("geojson",e,t),this.currentClusterMode=!1,this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){t||(this.sourceID=`places-${this.instanceIndex}`,this.unclusteredSourceID=`places-${this.instanceIndex}-unclustered`,this.connectionSourceID=`places-connections-${this.instanceIndex}`,this.layerIDPrefix=this.sourceID,this.defaultPlaceIconID=nt(et,this.instanceIndex),this.shownConnections=[]),this.layerSpecs=this.buildLayerSpecs(e);const i=this.buildClusterOptions(e);this.currentClusterMode=!0===i?.cluster;const r=this.partitionSpecsForSources(this.layerSpecs),s=new ue(this.mapLibreMap,this.sourceID,r.clusteredSpecs,!1,i);let a;r.unclusteredSpecs.length>0&&(a=new ue(this.mapLibreMap,this.unclusteredSourceID,r.unclusteredSpecs,!1)),ge([...s._layerSpecs,...a?._layerSpecs??[]],this.mapLibreMap),this.connectionLayerSpecs=this.buildConnectionLayerSpecs(e);const o=new ue(this.mapLibreMap,this.connectionSourceID,Object.values(this.connectionLayerSpecs),!1);return ge(o._layerSpecs,this.mapLibreMap),a?{places:s,placesUnclustered:a,connections:o}:{places:s,connections:o}}partitionSpecsForSources(e){if(!this.currentClusterMode)return{clusteredSpecs:Object.values(e),unclusteredSpecs:[]};const t=[],i=[];for(const[r,s]of Object.entries(e))"micro"===r?t.push(s):i.push(s);return{clusteredSpecs:i,unclusteredSpecs:t}}buildLayerSpecs(e){const t=zt(e,this.tomtomMap.mapLibreMap,this.tomtomMap.styleLightDarkTheme,this.instanceIndex),i=new Set(Object.keys(t));return Object.fromEntries(Object.entries(t).map(([e,t])=>{const r=t.beforeID;return[e,{...t,id:`${this.layerIDPrefix}-${e}`,...r&&i.has(r)?{beforeID:`${this.layerIDPrefix}-${r}`}:{}}]}))}buildClusterOptions(e){if("pin-clustered"===e?.theme)return{cluster:!0,clusterRadius:60,clusterProperties:ft}}buildConnectionLayerSpecs(e){const t=(e=>{const t=e?.layers?.line,i=e?.layers?.label;return{line:{...mt,...t,layout:{...mt.layout,...t?.layout},paint:{...mt.paint,...t?.paint}},label:{...gt,...i,layout:{...gt.layout,...i?.layout},paint:{...gt.paint,...i?.paint}}}})(e?.connections),i=`${this.layerIDPrefix}-connection-line`,r=`${this.layerIDPrefix}-connection-label`,s=xe.lowestLabel;return{line:{...t.line,id:i,beforeID:s},label:{...t.label,id:r,beforeID:s}}}_applyConfig(e){return this.updateLayersAndData(e),e}restoreDataAndConfigImpl(){const e=this.sourcesWithLayers.places.shownFeatures,t=this.shownConnections;this.initSourcesWithLayers(this.config,!0),this.config&&this._applyConfig(this.config),this.show(e),t.length&&this.showConnections(t)}applyTheme(e){this.applyConfigPart({theme:e})}applyIconConfig(e){this.applyConfigPart({icon:e})}applyTextConfig(e){this.applyConfigPart({text:e})}applyConfigPart(e){const t={...this.config,...e};this.updateLayersAndData(t),this.config=t,this.emitConfigChange()}applyExtraFeatureProps(e){const t={...this.config,extraFeatureProps:e};this.updateData(t),this.config=t,this.emitConfigChange()}updateLayersAndData(e){if(this.setupImages(e),!0===this.buildClusterOptions(e)?.cluster!==this.currentClusterMode)return void this.rebuildSourcesAndLayers(e);const t=this.buildLayerSpecs(e),i=this.currentClusterMode?this.partitionSpecsForSources(t):{clusteredSpecs:Object.values(t),unclusteredSpecs:[]},r=this.currentClusterMode?this.partitionSpecsForSources(this.layerSpecs):{clusteredSpecs:Object.values(this.layerSpecs),unclusteredSpecs:[]};me(i.clusteredSpecs,r.clusteredSpecs,this.sourcesWithLayers.places,this.mapLibreMap),this.sourcesWithLayers.placesUnclustered&&i.unclusteredSpecs.length>0&&me(i.unclusteredSpecs,r.unclusteredSpecs,this.sourcesWithLayers.placesUnclustered,this.mapLibreMap),this.layerSpecs=t,this.applyPlacesVisibility(),this.updateData(e),this.updateConnectionLayersAndData(e)}rebuildSourcesAndLayers(e){const t=this.sourcesWithLayers.places.shownFeatures,i=this.shownConnections;for(const s of Object.values(this.layerSpecs))this.mapLibreMap.getLayer(s.id)&&this.mapLibreMap.removeLayer(s.id);for(const s of Object.values(this.connectionLayerSpecs))this.mapLibreMap.getLayer(s.id)&&this.mapLibreMap.removeLayer(s.id);this.mapLibreMap.getSource(this.sourceID)&&this.mapLibreMap.removeSource(this.sourceID),this.mapLibreMap.getSource(this.unclusteredSourceID)&&this.mapLibreMap.removeSource(this.unclusteredSourceID),this.mapLibreMap.getSource(this.connectionSourceID)&&this.mapLibreMap.removeSource(this.connectionSourceID),this.initSourcesWithLayers(e,!0),this.setupImages(e);const r=si(t,this.instanceIndex,e);this.sourcesWithLayers.places.show(r,{automaticVisibility:!1}),this.sourcesWithLayers.placesUnclustered?.show(r,{automaticVisibility:!1}),this.applyPlacesVisibility(),i.length&&(this.shownConnections=[...i],this.updateConnectionsData(e))}updateConnectionLayersAndData(e){const t=this.buildConnectionLayerSpecs(e),i=this.sourcesWithLayers.connections;me(Object.values(t),Object.values(this.connectionLayerSpecs),i,this.mapLibreMap),this.connectionLayerSpecs=t,this.updateConnectionsData(e)}updateConnectionsData(e){const t=this.sourcesWithLayers.places.shownFeatures;this.sourcesWithLayers.connections.show(((e,t,i={})=>{const r=i.connections?.label,s=[];for(const a of e){const e=Yt(a.from,t),i=Yt(a.to,t);if(!e||!i)continue;const o=a.id??f(),n=r?r(a):"";s.push({type:"Feature",id:o,geometry:{type:"LineString",coordinates:[e.geometry.coordinates,i.geometry.coordinates]},properties:{id:o,fromId:"string"==typeof a.from?a.from:e.id,toId:"string"==typeof a.to?a.to:i.id,label:n}})}return{type:"FeatureCollection",features:s}})(this.shownConnections,t,e))}applyPlacesVisibility(){const e=this.sourcesWithLayers.places.shownFeatures.features.length?"visible":"none";for(const t of Object.values(this.layerSpecs))"none"!==t.layout?.visibility&&this.mapLibreMap.setLayoutProperty(t.id,"visibility",e,{validate:!1})}setupImages(e){if(e?.icon){for(const t of e.icon.categoryIcons??[]){const e=t.availabilityLevel?`${t.id}-${t.availabilityLevel}`:t.id;Ae("if-not-in-sprite",nt(e,this.instanceIndex),t.image,this.mapLibreMap,{pixelRatio:t.pixelRatio??2})}e.icon.default&&(e.icon.default.image&&Ae("if-not-in-sprite",this.defaultPlaceIconID,e.icon.default.image.image,this.mapLibreMap,{pixelRatio:e.icon.default.image.pixelRatio??2}),e.icon.default.style&&Ae("if-not-in-sprite",this.defaultPlaceIconID,$t(e.icon.default.style),this.mapLibreMap,{pixelRatio:2}))}else Ae("if-not-in-sprite",this.defaultPlaceIconID,$t(),this.mapLibreMap,{pixelRatio:2})}updateData(e){const t=si(this.sourcesWithLayers.places.shownFeatures,this.instanceIndex,e);this.sourcesWithLayers.places.source.runtimeSource?.setData(t),this.sourcesWithLayers.placesUnclustered?.source.runtimeSource?.setData(t)}async show(e){await this.waitUntilModuleReady(),this.clearConnectionsSync();const t=si(e,this.instanceIndex,this.config);this.sourcesWithLayers.places.show(t,{automaticVisibility:!1}),this.sourcesWithLayers.placesUnclustered?.show(t,{automaticVisibility:!1}),this.applyPlacesVisibility();for(const i of this.shownFeaturesHandlers)i({places:e})}async clear(){await this.waitUntilModuleReady(),this.clearConnectionsSync(),this.sourcesWithLayers.places.clear(),this.sourcesWithLayers.placesUnclustered?.clear()}async showConnections(e){await this.waitUntilModuleReady(),this.shownConnections=[...e],this.updateConnectionsData(this.config);for(const t of this.shownFeaturesHandlers)t({connections:e})}async clearConnections(){await this.waitUntilModuleReady(),this.clearConnectionsSync()}clearConnectionsSync(){this.shownConnections=[],this.sourcesWithLayers.connections?.clear()}getShown(){return{places:this.sourcesWithLayers.places.shownFeatures,connections:[...this.shownConnections]}}putEventState(e){this.sourcesWithLayers.places.putEventState(e)}cleanEventState(e){this.sourcesWithLayers.places.cleanEventState(e)}cleanEventStates(e){this.sourcesWithLayers.places.cleanEventStates(e)}get events(){const e=["places","placesUnclustered"];return this.buildEvents(this.moduleEventsWithShown([...e,"connections"],this.shownFeaturesHandlers),{places:this.userEvents(e),connections:this.userEvents(["connections"])})}},oi=["pin","circle-icon","base-map","pin-clustered"],ni=e=>{if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!ni(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}},li=e=>e?.length?1===e.length?e[0]:{expression:["any",...e.map(e=>e?.expression)],legacy:["any",...e.map(e=>e?.legacy)]}:null,ci=(e,t)=>{return t?["all",e[(i=t,ni(i)?"expression":"legacy")],t]:e.expression;var i},hi=(e,t,i)=>{if(1===i.length){const r="only"===t?"==":"!=";return{expression:[r,["get",e],i[0]],legacy:[r,e,i[0]]}}const r=["in",["get",e],["literal",i]];return"only"===t?{expression:r,legacy:["in",e,...i]}:{expression:["!",r],legacy:["!in",e,...i]}},ui=(e,t,i)=>hi(e,t.show,i?t.values.map(i):t.values),di={FOOD_DRINKS_GROUP:["RESTAURANT","FAST_FOOD","CAFE_PUB","PUB","WINERY","PUB_FOOD","SOUL_FOOD","DELICATESSEN"],SHOPPING_GROUP:["SHOP","SHOPPING_CENTER","CLOTHING_SHOP","MARKET","FOOD_MARKET","SUPERMARKETS_HYPERMARKETS","DEPARTMENT_STORE","CONVENIENCE_STORE","GROCERY_STORE","HARDWARE_STORE","ELECTRICAL_APPLIANCES_SHOP"],TRANSPORTATION_GROUP:["AIRPORT","FERRY_TERMINAL","HELIPAD_HELICOPTER_LANDING","PUBLIC_TRANSPORT_STOP","RAILWAY_STATION","BUS_STOP","TAXI_STAND"],HEALTH_GROUP:["DOCTOR","EMERGENCY_MEDICAL_SERVICE","EMERGENCY_ROOM","HEALTH_CARE_SERVICE","HOSPITAL","PHARMACY","DENTIST","WELFARE_ORGANIZATION"],PARKING_GROUP:["PARKING_GARAGE","OPEN_PARKING_AREA"],HOLIDAY_TOURISM_GROUP:["AMUSEMENT_PARK","BEACH","HOLIDAY_RENTAL","GEOGRAPHIC_FEATURE","TOURIST_ATTRACTION","LEISURE_CENTER","MOUNTAIN_PASS","MOUNTAIN_PEAK","MUSEUM","SCENIC_PANORAMIC_VIEW","TOURIST_INFORMATION_OFFICE"],EV_CHARGING_STATIONS_GROUP:["ELECTRIC_VEHICLE_STATION"],GAS_STATIONS_GROUP:["GAS_STATION"],ACCOMMODATION_GROUP:["CAMPING_GROUND","HOTEL_MOTEL","HOLIDAY_RENTAL"],ENTERTAINMENT_GROUP:["CINEMA","THEATER","MOVIE_THEATER","NIGHTLIFE","CONCERT_HALL","ENTERTAINMENT","CLUB_ASSOCIATION","CASINO"],SPORTS_LEISURE_GROUP:["SPORTS_CENTER","WATER_SPORT","SWIMMING_POOL","GOLF_COURSE","STADIUM","BEACH","ICE_SKATING_RINK","LEISURE_CENTER","MOUNTAIN_PASS","MOUNTAIN_PEAK"],EDUCATION_GROUP:["SCHOOL","COLLEGE_UNIVERSITY","LIBRARY","CULTURAL_CENTER"],GOVERNMENT_GROUP:["GOVERNMENT_OFFICE","COURTHOUSE","EMBASSY","FIRE_STATION_BRIGADE","POLICE_STATION"]},pi=e=>{const{properties:t}=e;return{id:e.id,type:e.type,geometry:e.geometry,properties:{id:String(t?.id),name:t?.name,category:t?.category,group:t?.group,priority:t?.priority}}},fi=e=>{const t=[];return e.forEach(e=>{e in di?t.push(...di[e].map(je)):t.push(je(e))}),[...new Set(t)]},yi=class e extends be{static async get(t,i){return await de(t),We(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super("style",e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(De);if(!t)throw $(`init ${e.name} with source ID ${De}`);const i=new le(this.mapLibreMap,t,e=>Ge.includes(e.id)),r=i.sourceAndLayerIDs.layerIDs[0];return this.mapLibreMap.getLayer(r)&&(this.originalFilter=this.mapLibreMap.getFilter(r)),{poi:i}}_applyConfig(e){return e&&!i(e.visible)?this._setVisible(e.visible,!1):this._initializing||this.isVisible()||this._setVisible(!0,!1),this._filterCategories(e?.filters?.categories,!1),e}isVisible(){return this.sourcesWithLayers.poi.isAnyLayerVisible()}setVisible(e){this._setVisible(e)}_setVisible(e,t=!0){this.tomtomMap.mapReady&&this.sourcesWithLayers.poi.setLayersVisible(e),t&&(this.config={...this.config,visible:e},this.emitConfigChange())}filterCategories(e){this._filterCategories(e)}_filterCategories(e,t=!0){if(e){if(this.tomtomMap.mapReady){const t=hi("category",e.show,fi(e.values));this.mapLibreMap.setFilter("POI",ci(t,this.originalFilter))}t&&(this.config={...this.config,filters:{categories:e}})}else this.categoriesFilter&&(t&&(this.config={...this.config,filters:{categories:{show:"all_except",values:[]}}}),this.tomtomMap.mapReady&&this.mapLibreMap.setFilter("POI",this.originalFilter));this.categoriesFilter=e,t&&this.emitConfigChange()}getShown(){return{poi:this.mapLibreMap.queryRenderedFeatures({layers:this.sourcesWithLayers.poi.sourceAndLayerIDs.layerIDs,validate:!1}).map(pi)}}get events(){return this.moduleEvents(["poi"],{mapping:pi})}},mi=["land","water","buildings2D","roads","railways","ferries","borders","buildings3D","natureLabels","roadLabels","roadShields","houseNumbers","smallerTownLabels","stateLabels","cityLabels","allPlaceLabels","capitalLabels","countryLabels"],gi={land:{metadataGroups:["area","background"]},water:{metadataGroups:["water"]},natureLabels:{metadataGroups:["label"]},roads:{metadataGroups:["road","road_area","transit_area"],idExcludes:["railway","subway","aerialway","ferry"]},railways:{metadataGroups:["road"],layerTypes:["line"],idIncludes:["railway","subway","aerialway"]},ferries:{metadataGroups:["road"],layerTypes:["line"],idIncludes:["ferry"]},buildings2D:{metadataGroups:["building"],layerTypes:["fill","line"]},buildings3D:{metadataGroups:["area_3d","building"],layerTypes:["fill-extrusion"]},borders:{metadataGroups:["border","border_label"]},roadLabels:{metadataGroups:["road_label"],idExcludes:["shield"]},roadShields:{metadataGroups:["road_label"],idIncludes:["shield"]},houseNumbers:{metadataGroups:["address_point_label"]},allPlaceLabels:{metadataGroups:["places_label"]},smallerTownLabels:{metadataGroups:["places_label"],idIncludes:["neighbourhood","village","hamlet","town"]},cityLabels:{metadataGroups:["places_label"],idIncludes:["city"]},capitalLabels:{metadataGroups:["places_label"],idIncludes:["capital"]},stateLabels:{metadataGroups:["places_label"],idIncludes:["state"]},countryLabels:{metadataGroups:["places_label"],idIncludes:["country"]}},_i=(e,t)=>{const i=gi[e],r=(e=>{const t=e.metadata;if(t&&"object"==typeof t&&"group"in t){const e=t.group;return"string"==typeof e?e:void 0}})(t);if(!r||!i.metadataGroups.includes(r))return!1;if(i.layerTypes&&!i.layerTypes.includes(t.type))return!1;const s=t.id.toLowerCase();return!(i.idIncludes&&!i.idIncludes.some(e=>s.includes(e)))&&!i.idExcludes?.some(e=>s.includes(e))},Li=e=>{const t=e.mode,i=e.names;return"include"===t?e=>i.some(t=>_i(t,e)):"exclude"===t?e=>!i.some(t=>_i(t,e)):(console.error("Unrecognized layer group mode:",t),()=>!0)},Ai=e=>!Ge.includes(e.id),Si=class e extends be{static async get(t,i){return await de(t),We(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super("style",e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Pe);if(!t)throw $(`init ${e.name} with source ID ${Pe}`);const i=new le(this.mapLibreMap,t,Ai);return this.layersByGroup=void 0,{vectorTiles:i}}_applyConfig(e){return e&&!i(e.visible)?this._setVisible(e.visible,void 0,!1):this._initializing||this.isVisible()||this._setVisible(!0,void 0,!1),e?.layerGroupsVisibility&&this._setVisible(e.layerGroupsVisibility.visible,{layerGroups:e.layerGroupsVisibility},!1),this.config||e?{...this.config,...e}:void 0}isVisible(e){return this.sourcesWithLayers.vectorTiles.isAnyLayerVisible(e?.layerGroups&&Li(e.layerGroups))}setVisible(e,t){this._setVisible(e,t)}_setVisible(e,t,i=!0){i&&(t?.layerGroups?this.config={...this.config,layerGroupsVisibility:{...t.layerGroups,visible:e}}:(delete this.config?.layerGroupsVisibility,this.config={...this.config,visible:e})),this.tomtomMap.mapReady&&this.sourcesWithLayers.vectorTiles.setLayersVisible(e,t?.layerGroups&&Li(t.layerGroups)),i&&this.emitConfigChange()}getLayers(){return r(this.groupedLayers(),e=>[...e])}getLayerIds(e){return[...this.groupedLayers()[e]]}groupedLayers(){return this.layersByGroup??=(e=>{const t=Object.fromEntries(mi.map(e=>[e,[]]));for(const i of e)for(const e of mi)_i(e,i)&&t[e].push(i.id);return t})(this.sourcesWithLayers.vectorTiles._layerSpecs),this.layersByGroup}get events(){return this.moduleEvents(["vectorTiles"],{scopeResolver:Ii})}},Ii=e=>({layerFilter:Li(e.layerGroups),featureMatches:e.features}),Ei=class e extends be{static async create(t,i){return await de(t),bi(i),new e(t,i)}constructor(e,t){super("geojson",e,t),this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){const i=e??this.config;t||(this.lastShown={}),this.resolveIDs(i),this.registerImages(i);const r={};for(const s of Object.keys(i.sources)){const e=this.resolvedSourceIDs[s],t=this.resolvedLayerSpecs[s],a=i.sources[s].cluster;r[s]=new ue(this.mapLibreMap,e,t,!0,a)}return r}registerImages(e){if(e.images)for(const[t,i]of Object.entries(e.images))this.mapLibreMap.hasImage(t)||this.mapLibreMap.addImage(t,i.image,i.options)}resolveIDs(e){const t={},i={};for(const r of Object.keys(e.sources)){const s=e.sources[r],a=s.sourceID??`custom-geojson-${this.instanceIndex}-${String(r)}`;t[r]=a,i[r]=s.layers.map((e,t)=>({...e,id:e.id??`${a}-layer-${t}`}))}this.resolvedSourceIDs=t,this.resolvedLayerSpecs=i}_applyConfig(e){if(!e)return this._applyConfig(this.initialConfig);this.initialConfig??=e;const t=this.config,i=t?this.resolvedLayerSpecs:void 0;return this.resolveIDs(e),this.registerImages(e),t&&i&&this.updateLayersForExistingSources(i),void 0!==e.visible&&this.applyVisibility(e.visible),e}updateLayersForExistingSources(e){for(const t of Object.keys(this.resolvedLayerSpecs)){const i=e[t],r=this.resolvedLayerSpecs[t],s=this.sourcesWithLayers[t];if(!i||!s)continue;me(r,i,s,this.mapLibreMap);const a=[];for(const e of s._layerSpecs)this.mapLibreMap.getLayer(e.id)||a.push(e);a.length>0&&(ge(a,this.mapLibreMap),s.shownFeatures.features.length>0&&s.setLayersVisible(!0))}}applyVisibility(e){for(const t of Object.keys(this.sourcesWithLayers))this.sourcesWithLayers[t].setLayersVisible(e)}restoreDataAndConfigImpl(){const e=Object.keys(this.lastShown);this.initSourcesWithLayers(this.config,!0),this.config&&this._applyConfig(this.config);for(const t of e){const e=this.lastShown[t];e&&this.showOnSource(t,e)}}async show(e,t){if(await this.waitUntilModuleReady(),void 0!==t)this.showOnSource(t,e);else for(const i of Object.keys(this.sourcesWithLayers))this.showOnSource(i,e)}showOnSource(e,t){const i=Ri(t);this.lastShown[e]=i,this.sourcesWithLayers[e].show(i);for(const r of this.shownFeaturesHandlers)r({sourceName:e,data:i})}async clear(e){if(await this.waitUntilModuleReady(),void 0!==e)return this.sourcesWithLayers[e].clear(),void delete this.lastShown[e];for(const t of Object.keys(this.sourcesWithLayers))this.sourcesWithLayers[t].clear(),delete this.lastShown[t]}getShown(){const e={};for(const t of Object.keys(this.sourcesWithLayers))e[t]=this.sourcesWithLayers[t].shownFeatures;return e}setVisible(e){this.config={...this.config,visible:e},this.applyVisibility(e),this.emitConfigChange()}get events(){const e=Object.keys(this.sourcesWithLayers),t={};for(const i of e)t[i]=this.userEvents([i]);return this.buildEvents(this.moduleEventsWithShown(e,this.shownFeaturesHandlers),t)}},bi=e=>{if(!e.sources||0===Object.keys(e.sources).length)throw new Error("CustomGeoJSONModule requires at least one source in config.sources.");k(Object.keys(e.sources),"CustomGeoJSONModule source");for(const[t,i]of Object.entries(e.sources))if(!i.layers||0===i.layers.length)throw new Error(`CustomGeoJSONModule source "${t}" requires at least one layer.`)},Ri=e=>{let t=!1;for(const i of e.features)if(null==i.id||i.properties?.id!==i.id){t=!0;break}return t?{...e,features:e.features.map((e,t)=>{const i=e.id??e.properties?.id??t;return{...e,id:i,properties:{...e.properties,id:i}}})}:e},Ti="#0A3653",Ci="#555555",vi={type:"fill",paint:{"fill-color":["coalesce",["get","color"],Ti],"fill-opacity":["case",["==",["get","theme"],"outline"],0,.15],"fill-antialias":!1}},Oi={type:"line",paint:{"line-color":["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],Ci],["coalesce",["get","color"],Ti]],"line-opacity":["case",["==",["get","theme"],"outline"],.9,1],"line-width":["case",["==",["get","theme"],"outline"],5,2]}},wi=(e,t,r)=>{const s=r?.fill,a=r?.line,o={...vi,id:e,paint:{...vi.paint,...!i(s?.opacity)&&{"fill-opacity":s?.opacity},...s?.color&&{"fill-color":["get","color"]}}},n=a?.layer;return[o,{...Oi,...n,id:t,...n?.layout&&{layout:{...Oi.layout,...n.layout}},paint:{...Oi.paint,...n?.paint,...!i(a?.color)&&{"line-color":a?.color},...!i(a?.width)&&{"line-width":a?.width},...!i(a?.opacity)&&{"line-opacity":a?.opacity}}}]},Ni=(e,t)=>{const i=t?.textConfig;return{type:"symbol",id:e,layout:{"text-field":["get","title"],...i?.textField&&{"text-field":i.textField},"text-padding":5,"text-size":15,"text-font":[qe],"symbol-placement":"point"},paint:{"text-color":"#333333","text-halo-color":"#FFFFFF","text-halo-width":["interpolate",["linear"],["zoom"],6,1,10,1.5],"text-translate-anchor":"viewport"}}},Mi=(e,t)=>{const r=t?.lineLabelConfig;return{type:"symbol",id:e,minzoom:r?.minZoom??3,layout:{"text-field":["get","title"],"symbol-placement":"line","text-size":r?.textSize??15,"text-font":[qe],"symbol-spacing":r?.symbolSpacing??200,"text-keep-upright":!0,"text-offset":r?.textOffset??[0,1]},paint:{"text-color":r?.textColor??"#333333","text-halo-color":r?.textHaloColor??"#FFFFFF","text-halo-width":r?.textHaloWidth??2,...!i(r?.textOpacity)&&{"text-opacity":r?.textOpacity}}}},xi={warm:["#793F0D","#AC703D","#C38E63","#E49969","#E5AE86","#EEC5A9","#6E7649","#9D9754","#C7C397","#B4A851","#DFD27C","#E7E3B5","#846D74","#B7A6AD","#D3C9CE"],browns:["#edc4b3","#e6b8a2","#deab90","#d69f7e","#cd9777","#c38e70","#b07d62","#9d6b53","#8a5a44","#774936"],cold:["#344464","#548ca4","#549cac","#2c445c","#a4ccd4","#acbccc","#b4c4d4","#acd4cc","#5c8ca4"],fadedBlues:["#152033","#1d2d44","#2e455d","#3e5c76","#4c6884","#597491","#67809e","#6e86a5","#7b91ad","#879bb4"],blues:["#03045e","#023e8a","#0077b6","#0096c7","#00b4d8","#48cae4","#90e0ef","#ade8f4","#caf0f8"],greens:["#004b23","#006400","#007200","#008000","#38b000","#70e000","#9ef01a","#ccff33"],fadedGreenToBlue:["#d9ed92","#b5e48c","#99d98c","#76c893","#52b69a","#34a0a4","#168aad","#1a759f","#1e6091","#184e77"],blueToRed:["#033270","#1368aa","#4091c9","#9dcee2","#fedfd4","#f29479","#f26a4f","#ef3c2d","#cb1b16","#65010c"],greenToYellow:["#007f5f","#2b9348","#55a630","#80b918","#aacc00","#bfd200","#d4d700","#dddf00","#eeef20","#ffff3f"],pastel:["#fec5bb","#fcd5ce","#fae1dd","#f8edeb","#e8e8e4","#d8e2dc","#ece4db","#ffe5d9","#ffd7ba","#fec89a"],retro:["#f94144","#f3722c","#f8961e","#f9844a","#f9c74f","#90be6d","#43aa8b","#4d908e","#577590","#277da1"],contrastRetro:["#001219","#005f73","#0a9396","#94d2bd","#e9d8a6","#ee9b00","#ca6702","#bb3e03","#ae2012","#9b2226"],fadedRainbow:["#ffadad","#ffd6a5","#fdffb6","#caffbf","#9bf6ff","#a0c4ff","#bdb2ff","#ffc6ff","#fffffc"],pastelRainbow:["#54478c","#2c699a","#048ba8","#0db39e","#16db93","#83e377","#b9e769","#efea5a","#f1c453","#f29e4c"]},Di=Object.keys(xi),Fi=(e,t={})=>({...e,features:e.features.map((e,i)=>{const r=(e.properties??{}).theme??t.theme,s="inverted"===r?(e=>{const t=C(e);return{...e,geometry:t.geometry}})(e):e,a=s.properties??{},o=a.title??((e,t)=>t.textConfig?.textField?t.textConfig.textField:e.properties?.address?.freeformAddress)(s,t),n=a.color??((e,t)=>{const i=e?.fill?.color;if("string"==typeof i&&xi[i]){const e=xi[i];return e[t%e.length]}return i})(t,i);return{...s,properties:{...s.properties,...r&&{theme:r},...o&&{title:o},...n&&{color:n},id:a.id??f()}}})}),Pi=e=>{const t=e.features.map(e=>{let t;if(e.properties?.placeCoordinates)t=e.properties?.placeCoordinates;else if("MultiPolygon"===e.geometry.type){const i=(e=>e.flat().reduce((e,t)=>t.length>e.length?t:e,[]))(e.geometry.coordinates),r=h(i);t=r&&c(r)||null}else t=e.geometry.coordinates.flat();const i=e.id??e.properties?.id??f();return{type:"Feature",id:i,geometry:{type:"Point",coordinates:t},properties:{...e.properties,id:i}}});return{type:"FeatureCollection",bbox:e.bbox,features:t}},Ui=class e extends be{static async create(t,i){return await de(t),new e(t,i)}constructor(e,t){super("geojson",e,t),this.lineLabelLayerSpecs=null,this.lastRawInput=null,this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){if(!t){this.sourceID=`geometry-${this.instanceIndex}`,this.titleSourceID=`geometryTitle-${this.instanceIndex}`;const e=`geometry-${this.instanceIndex}`;this.fillLayerID=`${e}_Fill`,this.outlineLayerID=`${e}_Outline`,this.lineLabelLayerID=`${e}_LineLabel`,this.titleLayerID=`${e}_Title`}const[i,r]=wi(this.fillLayerID,this.outlineLayerID,e),s=Ni(this.titleLayerID,e);this.titleLayerSpecs=s,this.geometryFillLayerSpecs=i,this.geometryOutlineLayerSpecs=r;const a=void 0===e?.lineLabelConfig?null:Mi(this.lineLabelLayerID,e);return this.lineLabelLayerSpecs=a,{geometry:new ue(this.mapLibreMap,this.sourceID,[{...i},{...r},...a?[a]:[]]),geometryLabel:new ue(this.mapLibreMap,this.titleSourceID,[s])}}_applyConfig(e){return(e?.textConfig||e?.fill||e?.line)&&this.updateLayerAndData(e),(e?.beforeLayerConfig||e?.fill?.beforeLayerConfig||e?.line?.beforeLayerConfig)&&this.applyBeforeLayerConfig(e),e}resolveBeforeID(e){return"top"===e?this.titleLayerID:xe[e]}moveLayersBefore(e,t){for(const i of e)this.mapLibreMap.moveLayer(i,t)}get fillLayerIDs(){return[this.fillLayerID]}get lineLayerIDs(){return this.lineLabelLayerSpecs?[this.outlineLayerID,this.lineLabelLayerID]:[this.outlineLayerID]}moveBeforeLayer(e){this.config={...this.config,beforeLayerConfig:e},this.applyBeforeLayerConfig(this.config),this.emitConfigChange()}applyBeforeLayerConfig(e){const t=e?.beforeLayerConfig,i=e=>{if(void 0!==t)return"string"==typeof t?t:t[e]??t.all},r=e?.fill?.beforeLayerConfig??i("fill"),s=e?.line?.beforeLayerConfig??i("line");void 0!==r&&this.moveLayersBefore(this.fillLayerIDs,this.resolveBeforeID(r)),void 0!==s&&this.moveLayersBefore(this.lineLayerIDs,this.resolveBeforeID(s))}applyTextConfig(e){const t={...this.config,textConfig:e};this.updateLayerAndData(t),this.sourcesWithLayers.geometryLabel.show(Pi(this.sourcesWithLayers.geometry.shownFeatures)),this.config=t,this.emitConfigChange()}updateLayerAndData(e){const[t,i]=wi(this.fillLayerID,this.outlineLayerID,e),r=Ni(this.titleLayerID,e);if(ye(t,this.geometryFillLayerSpecs,this.mapLibreMap),ye(i,this.geometryOutlineLayerSpecs,this.mapLibreMap),ye(r,this.titleLayerSpecs,this.mapLibreMap),this.geometryFillLayerSpecs=t,this.geometryOutlineLayerSpecs=i,this.titleLayerSpecs=r,this.lineLabelLayerSpecs){const t=Mi(this.lineLabelLayerID,e);ye(t,this.lineLabelLayerSpecs,this.mapLibreMap),this.lineLabelLayerSpecs=t}}restoreDataAndConfigImpl(){const e=this.lastRawInput;this.initSourcesWithLayers(this.config,!0),this.config&&this._applyConfig(this.config),e&&this.show(e)}async show(e){await this.waitUntilModuleReady(),this.lastRawInput=e;const{transformFeaturesForDisplay:t}=this.config??{},i=t?t(e):e,r=this.sourcesWithLayers.geometry;r.show(Fi(i,this.config)),this.sourcesWithLayers.geometryLabel.show(Pi(r.shownFeatures));for(const s of this.shownFeaturesHandlers)s(e)}async clear(){await this.waitUntilModuleReady(),this.sourcesWithLayers.geometry.clear(),this.sourcesWithLayers.geometryLabel.clear()}getShown(){return{geometry:this.sourcesWithLayers.geometry.shownFeatures,geometryLabel:this.sourcesWithLayers.geometryLabel.shownFeatures}}get events(){return this.buildEvents(this.moduleEventsWithShown(["geometry","geometryLabel"],this.shownFeaturesHandlers),{geometry:this.userEvents(["geometry"]),geometryLabel:this.userEvents(["geometryLabel"])})}},Hi={timeMinutes:"min",distanceKM:"km",remainingChargeCPT:"% remaining",spentChargePCT:"% spent",spentFuelLiters:"L"},ki=(e,t,i="filled")=>{const r=e.map((e,r)=>({...e,properties:{...e.properties,title:t[r],theme:i}}));return"inverted"===i?(e=>[...e.map((t,i)=>{const r=0===i?C(t):b(R([e[i-1],t])),{title:s,theme:a,...o}=t.properties??{};return{...t,geometry:r?.geometry??t.geometry,properties:o}}),...e.map(e=>({...e,id:void 0,properties:{...e.properties,theme:"filled"}}))])(r):r},Wi=(e,t="filled",i)=>{const r=e.features,s=r.map((e,t)=>{if(i)return i(e,t);const r=e.properties?.budget;return void 0!==r?.value&&r?.type?`${r.value} ${Hi[r.type]??r.type}`:String(t+1)});return{type:"FeatureCollection",...e.bbox&&{bbox:e.bbox},features:ki(r,s,t)}},Gi=(e="fadedRainbow",t="lowestLabel")=>({beforeLayerConfig:t,line:{width:["case",["==",["get","theme"],"outline"],5,1],color:["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],Ci],"grey"],opacity:["case",["==",["get","theme"],"outline"],.9,1]},fill:{color:e,opacity:["case",["==",["get","theme"],"outline"],0,.6]},lineLabelConfig:{}}),Bi=(e="fadedRainbow",t,i,r)=>{const s=Gi(e,i),a=e=>Wi(e,t,r);return"inverted"!==t?{...s,transformFeaturesForDisplay:a}:{...s,line:{...s.line,opacity:["case",["==",["get","theme"],"filled"],1,0]},fill:{...s.fill,opacity:["case",["==",["get","theme"],"filled"],0,.6]},lineLabelConfig:{textOpacity:["case",["==",["get","theme"],"filled"],1,0],textOffset:["case",["==",["get","theme"],"filled"],["literal",[0,-1]],["literal",[0,1]]]},transformFeaturesForDisplay:a}},Vi=["filled","outline","inverted"],ji=class e extends be{static async get(t,i){return await de(t),await Le(t,Fe,"hillshade"),We(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super("style",e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Fe);if(!t)throw $(`init ${e.name} with source ID ${Fe}`);return{hillshade:new le(this.mapLibreMap,t)}}_applyConfig(e){return this._setVisible(e?.visible??!1,!1),e}setVisible(e){this._setVisible(e)}_setVisible(e,t=!0){this.tomtomMap.mapReady&&this.sourcesWithLayers.hillshade.setLayersVisible(e),t&&(this.config={...this.config,visible:e},this.emitConfigChange())}isVisible(){return this.sourcesWithLayers.hillshade.isAnyLayerVisible()}get events(){return this.moduleEvents(["hillshade"])}},zi=["standardLight","standardDark","drivingLight","drivingDark","monoLight","monoDark","satellite"],$i=["trafficIncidents","trafficFlow","hillshade"],Yi=(e,t,i)=>Math.min(Math.max(t,e),i),qi=e=>!e.some(Number.isNaN),Ki=e=>Number.parseInt(e.padEnd(2,e),16)/255,Xi=(e,t)=>Yi(t?e/100:e,0,1),Zi=/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,/])\s*([\de.+-]+)(%)?)?\s*\)$/,Ji=/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,/])\s*([\de.+-]+)(%)?)?\s*\)$/,Qi=e=>{const t=Ji.exec(e);if(!t)return;const[,i,r,s,a,o,n,l,c]=t,h=[r||" ",a||" ",n].join("");if(" "!==h&&" /"!==h&&",,"!==h&&",,,"!==h)return;const u=[+i,Yi(+s,0,100),Yi(+o,0,100),l?Xi(+l,c):1];return qi(u)?(([e,t,i,r])=>{const s=(e=>{const t=e%360;return t<0?t+360:t})(e),a=t/100,o=i/100,n=e=>{const t=(e+s/30)%12,i=a*Math.min(o,1-o);return o-i*Math.max(-1,Math.min(t-3,9-t,1))};return[n(0),n(8),n(4),r]})(u):void 0},er=e=>{const t=e.toLowerCase().trim();if("transparent"===t)return[0,0,0,0];const i=tr[t];if(i){const[e,t,r]=i;return[e/255,t/255,r/255,1]}return t.startsWith("#")?(e=>{if(!/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e))return;const t=e.length<6?1:2;return[Ki(e.slice(1,1+t)),Ki(e.slice(1+t,1+2*t)),Ki(e.slice(1+2*t,1+3*t)),Ki(e.slice(1+3*t)||"ff")]})(t):t.startsWith("rgb")?(e=>{const t=Zi.exec(e);if(!t)return;const[,i,r,s,a,o,n,l,c,h,u,d]=t,p=[s||" ",n||" ",h].join("");if(" "!==p&&" /"!==p&&",,"!==p&&",,,"!==p)return;const f=[r,o,c].join(""),y="%%%"===f?100:""===f?255:0;if(!y)return;const m=[Yi(+i/y,0,1),Yi(+a/y,0,1),Yi(+l/y,0,1),u?Xi(+u,d):1];return qi(m)?m:void 0})(t):Qi(t)},tr={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},ir="#36A8F0",rr="#105287",sr="#ABAFB3",ar="#3C4956",or="#727C85",nr=["interpolate",["linear"],["zoom"],1,3,5,4,10,7,18,10],lr=["==",["get","routeState"],"selected"],cr=["==",["get","routeState"],"deselected"],hr=["interpolate",["linear"],["zoom"],1,5,5,6,10,10,18,14],ur={s:["interpolate",["linear"],["zoom"],1,2,5,3,10,5,18,7],m:nr,l:["interpolate",["linear"],["zoom"],1,5,5,6,10,11,18,15]},dr={s:["interpolate",["linear"],["zoom"],1,4,5,5,10,8,18,11],m:hr,l:["interpolate",["linear"],["zoom"],1,7,5,9,10,14,18,19]},pr={s:["interpolate",["linear"],["zoom"],8,.45,22,.6],m:["interpolate",["linear"],["zoom"],8,.6,22,.8],l:["interpolate",["linear"],["zoom"],8,.75,22,1]},fr=e=>ur[e??"m"],yr=e=>dr[e??"m"],mr=e=>pr[e??"m"],gr={s:["interpolate",["linear"],["zoom"],1,8,5,9,10,12,18,15],m:["interpolate",["linear"],["zoom"],1,9,5,11,10,15,18,20],l:["interpolate",["linear"],["zoom"],1,12,5,14,10,19,18,24]},_r=e=>gr[e??"m"],Lr={s:["interpolate",["linear"],["zoom"],16,8,22,12],m:["interpolate",["linear"],["zoom"],16,12,22,17],l:["interpolate",["linear"],["zoom"],16,17,22,24]},Ar={s:["interpolate",["linear"],["zoom"],16,10,22,14],m:["interpolate",["linear"],["zoom"],16,14,22,20],l:["interpolate",["linear"],["zoom"],16,20,22,28]},Sr=e=>Lr[e??"m"],Ir=e=>Ar[e??"m"],Er="#AD0000",br="#FB2D09",Rr="#FFC105",Tr="#f58240",Cr="#000000",vr="#C7D2D8",Or="rgba(190, 39, 27, 1)",wr="rgba(137, 150, 168, 1)",Nr=e=>!1===e?.visible?"":e?.title??["format",["get","title"],"\n",["get","chargingPower"]," • ",["get","chargingDuration"]],Mr=e=>({...ot,filter:lr,minzoom:4,layout:{...ot.layout,"text-field":Nr(e?.text)},paint:{...ot.paint}}),xr={filter:lr,minzoom:16},Dr={"line-cap":"round"},Fr=e=>({...xr,type:"line",layout:Dr,paint:{"line-width":Ir(e),"line-color":"grey"}}),Pr=e=>({...xr,type:"line",layout:Dr,paint:{"line-width":Sr(e),"line-color":"white"}}),Ur="instruction-arrow",Hr={...xr,type:"symbol",layout:{"icon-allow-overlap":!0,"icon-image":Ur,"icon-rotation-alignment":"map","icon-rotate":["get","lastPointBearingDegrees"],"icon-size":["interpolate",["linear"],["zoom"],16,1,22,2]}},kr=e=>({filter:lr,type:"line",layout:{"line-join":"round"},paint:{"line-width":fr(e),"line-color":"#6dc4ed"}}),Wr={filter:lr,type:"symbol",minzoom:6,maxzoom:16.5,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-image":"poi-ferry_terminal","icon-size":["interpolate",["linear"],["zoom"],6,.8,16.5,1],"icon-ignore-placement":!0}},Gr={type:"line",layout:{"line-join":"round","line-cap":"round","line-sort-key":["get","index"]}},Br=e=>({...Gr,filter:cr,paint:{"line-color":ar,"line-width":yr(e)}}),Vr=e=>({...Gr,filter:cr,paint:{"line-color":sr,"line-width":fr(e)}}),jr=(e,t)=>({...Gr,filter:lr,paint:{"line-color":t??"#105287","line-width":yr(e)}}),zr=(e,t)=>({...Gr,filter:lr,paint:{"line-color":t??"#36A8F0","line-width":fr(e)}}),$r={type:"symbol",layout:{"symbol-placement":"line","icon-image":"roads-arrow-white","icon-rotate":180}},Yr="selected-route-summary-popup",qr="deselected-route-summary-popup",Kr=e=>({filter:lr,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-width":_r(e),"line-color":"#BEBFFA"}}),Xr={filter:lr,type:"symbol",minzoom:4,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-image":"poi-toll_plaza","icon-size":["interpolate",["linear"],["zoom"],4,.8,16.5,1]}},Zr=["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],Jr=["match",["get","magnitudeOfDelay"],"unknown",Or,wr],Qr=["match",["get","magnitudeOfDelay"],"minor",Tr,"moderate",br,"major",Er,"indefinite","#666666",Cr],es=e=>({type:"line",layout:{"line-cap":"round"},paint:{"line-width":fr(e),"line-color":["match",["get","magnitudeOfDelay"],"minor",Rr,"moderate",br,"major",Er,vr]}}),ts=e=>({type:"line",filter:Zr,layout:{"line-join":"round"},paint:{"line-width":fr(e),"line-color":Jr,"line-dasharray":[1.5,1]}}),is={filter:lr,type:"symbol",minzoom:6,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-ignore-placement":!0}},rs={...is,filter:["all",["has","jamIconID"],is.filter],layout:{...is.layout,"icon-image":["get","jamIconID"],"icon-anchor":"bottom-left","text-anchor":"bottom-left","text-field":["get","title"],"text-font":[qe],"text-offset":[3.9,-1.4],"text-size":13},paint:{...is.paint,"text-color":Qr,"text-halo-color":"#FFFFFF","text-halo-width":1}},ss={...is,filter:["all",["has","causeIconID"],is.filter],layout:{...is.layout,"icon-image":["get","causeIconID"],"icon-anchor":"bottom-right"},paint:{...is.paint}},as=e=>({filter:lr,type:"line",layout:{"line-join":"round"},paint:{"line-width":fr(e),"line-color":"#000000","line-opacity":.3}}),os=e=>({filter:lr,type:"line",layout:{"line-join":"round"},paint:{"line-color":rr,"line-width":fr(e)}}),ns=e=>({filter:lr,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":ir,"line-width":fr(e),"line-dasharray":[0,1.5]}}),ls="traffic-clear",cs="traffic-major",hs="traffic-moderate",us="traffic-minor",ds=["has","formattedTraffic"],ps=e=>{const t=void 0!==e?nt(Yr,e):Yr,i=void 0!==e?nt(qr,e):qr,r=void 0!==e?nt(ls,e):ls,s=void 0!==e?nt(cs,e):cs,a=void 0!==e?nt(hs,e):hs,o=void 0!==e?nt(us,e):us;return{type:"symbol",layout:{"icon-image":["case",lr,t,i],"symbol-placement":"point","icon-rotation-alignment":"viewport","text-rotation-alignment":"viewport","symbol-sort-key":["case",lr,0,1],"icon-text-fit":"both","icon-text-fit-padding":[10,5,5,10],"text-font":["Noto-Medium"],"text-size":13,"icon-padding":0,"text-justify":"left","text-line-height":1.5,"text-field":["format",["get","formattedDuration"],{"text-font":["literal",[qe]],"text-color":["case",lr,"black",or]},["concat","\t\t",["get","formattedDistance"]],{"text-color":or},["case",ds,"\n",""],{},["image",["case",ds,["match",["get","magnitudeOfDelay"],"major",s,"moderate",a,"minor",o,r],""]],{},["case",ds,["concat"," ",["get","formattedTraffic"]],""],{"text-font":["literal",[qe]],"text-color":Qr}]},paint:{"icon-translate":[0,-35],"text-translate":[0,-35]}}},fs=ps(),ys="start",ms="middle",gs="finish",_s="stopDisplayIndex",Ls="waypointStart",As="waypointStop",Ss="waypointFinish",Is={"text-field":["get",_s],"text-font":[qe],"text-size":["interpolate",["linear"],["zoom"],13,14,18,16],"text-offset":[0,-1.6],"icon-anchor":"bottom","text-allow-overlap":!0},Es={type:"symbol",paint:{...rt,"text-color":"#ffffff"},layout:{...it,...Is,"symbol-sort-key":["abs",["-",["get","index"],1e3]]}},bs={type:"symbol",paint:{...at,"text-color":"black","text-halo-width":1.5,"text-halo-color":"#ffffff"},layout:{...st,"text-anchor":"top","text-offset":[0,.4]}},Rs=(e,t)=>e&&t&&(e.startsWith("route")||e.startsWith("waypoint"))?`${t}-${e}`:e,Ts=(e,t)=>e&&t?Object.fromEntries(Object.entries(e).map(([e,i])=>[e,i?.beforeID?{...i,beforeID:Rs(i.beforeID,t)}:i])):e,Cs=(e,t)=>t?{...e,...t,...t.paint&&{paint:{...e.paint,...t.paint}},...t.layout&&{layout:{...e.layout,...t.layout}}}:e,vs=(e,t)=>e&&void 0!==t?`${e}-${t}`:e,Os=(e={},t,i)=>{const r=e.layers,s=r?.sections,a=e.theme?.mainColor,o=a?((e,t)=>{const i=er(e);if(!i)return;const r=1-t;return`#${[Math.round(255*i[0]*r),Math.round(255*i[1]*r),Math.round(255*i[2]*r)].map(e=>e.toString(16).padStart(2,"0")).join("")}`})(a,.4):void 0,n=e.theme?.routeWidth,l=e.theme?.waypointSize,c=mr(l);return{mainLines:{routeLineArrows:Cs({...$r,beforeID:xe.lowestLabel},r?.mainLines?.routeLineArrows),routeLine:Cs({...zr(n,a),beforeID:Rs("routeIncidentBackgroundLine",t)},r?.mainLines?.routeLine),routeOutline:Cs({...jr(n,o),beforeID:Rs("routeLine",t)},r?.mainLines?.routeOutline),routeDeselectedLine:Cs({...Vr(n),beforeID:Rs("routeOutline",t)},r?.mainLines?.routeDeselectedLine),routeDeselectedOutline:Cs({...Br(n),beforeID:Rs("routeDeselectedLine",t)},r?.mainLines?.routeDeselectedOutline),...Ts(r?.mainLines?.additional,t)},waypoints:{routeWaypointSymbol:Cs({...Es,layout:{...Es.layout,"icon-size":c},beforeID:Rs("routeSummaryBubbleSymbol",t)},r?.waypoints?.routeWaypointSymbol),routeWaypointLabel:Cs({...bs,beforeID:Rs("routeWaypointSymbol",t)},r?.waypoints?.routeWaypointLabel),...Ts(r?.waypoints?.additional,t)},chargingStops:{routeChargingStopSymbol:Cs({...Mr(e.chargingStops),beforeID:Rs("routeWaypointSymbol",t)},r?.chargingStops?.routeChargingStopSymbol),...Ts(r?.chargingStops?.additional,t)},sections:{incident:{routeIncidentJamSymbol:Cs({...rs,beforeID:Rs("routeChargingStopSymbol",t)},s?.incident?.routeIncidentJamSymbol),routeIncidentCauseSymbol:Cs({...ss,beforeID:Rs("routeChargingStopSymbol",t)},s?.incident?.routeIncidentCauseSymbol),routeIncidentBackgroundLine:Cs({...es(n),beforeID:Rs("routeIncidentDashedLine",t)},s?.incident?.routeIncidentBackgroundLine),routeIncidentDashedLine:Cs({...ts(n),beforeID:Rs("routeTunnelLine",t)},s?.incident?.routeIncidentDashedLine),...Ts(s?.incident?.additional,t)},ferry:{routeFerryLine:Cs({...kr(n),beforeID:Rs("routeLineArrows",t)},s?.ferry?.routeFerryLine),routeFerrySymbol:Cs({...Wr,beforeID:Rs("routeIncidentJamSymbol",t)},s?.ferry?.routeFerrySymbol),...Ts(s?.ferry?.additional,t)},tollRoad:{routeTollRoadOutline:Cs({...Kr(n),beforeID:Rs("routeDeselectedOutline",t)},s?.tollRoad?.routeTollRoadOutline),routeTollRoadSymbol:Cs({...Xr,beforeID:Rs("routeChargingStopSymbol",t)},s?.tollRoad?.routeTollRoadSymbol),...Ts(s?.tollRoad?.additional,t)},tunnel:{routeTunnelLine:Cs({...as(n),beforeID:Rs("routeLineArrows",t)},s?.tunnel?.routeTunnelLine),...Ts(s?.tunnel?.additional,t)},vehicleRestricted:{routeVehicleRestrictedBackgroundLine:Cs({...os(n),beforeID:Rs("routeVehicleRestrictedForegroundLine",t)},s?.vehicleRestricted?.routeVehicleRestrictedBackgroundLine),routeVehicleRestrictedForegroundLine:Cs({...ns(n),beforeID:xe.lowestLabel},s?.vehicleRestricted?.routeVehicleRestrictedForegroundLine),...Ts(s?.vehicleRestricted?.additional,t)}},instructionLines:{routeInstructionLine:Cs({...Pr(n),beforeID:xe.lowestLabel},r?.instructionLines?.routeInstructionLine),routeInstructionOutline:Cs({...Fr(n),beforeID:Rs("routeInstructionLine",t)},r?.instructionLines?.routeInstructionOutline),...Ts(r?.instructionLines?.additional,t)},instructionArrows:{routeInstructionArrowSymbol:Cs({...Hr,beforeID:Rs("routeInstructionLine",t),...void 0!==i&&{layout:{...Hr.layout,"icon-image":vs(Hr.layout?.["icon-image"],i)}}},r?.instructionArrows?.routeInstructionArrowSymbol),...Ts(r?.instructionArrows?.additional,t)},summaryBubbles:{routeSummaryBubbleSymbol:Cs(void 0===i?fs:ps(i),r?.summaryBubbles?.routeSummaryBubbleSymbol),...Ts(r?.summaryBubbles?.additional,t)}}},ws=Os();K()&&(te=X(Z('<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50">\n <path d="M1.562 40.569L25 1.562l23.438 39.007L25 27.566 1.562 40.569z" fill="#fff"/>\n <path d="M25.369.107c.782.429.506.167.917.682l23.438 39.007c.79 1.316-.671 2.829-2.014 2.085L25 29.281l-22.71 12.6c-1.343.744-2.804-.769-2.014-2.085L23.714.789c.461-.694.9-.682 1.656-.682zM25 1.562L1.562 40.569 25 27.566l23.438 13.003L25 1.562z"\n fill="gray"/>\n</svg>\n')));var Ns,Ms=e=>{if(!K())return;const t=Z('<svg xmlns="http://www.w3.org/2000/svg" width="160" height="65">\n <g filter="url(#A)">\n <rect id="pin" x="81.899" y="47" width="10" height="10" rx="2" transform="rotate(45 81.899 47)"/>\n <rect id="bubble" x="10" y="10" width="140" height="45" rx="12"/>\n </g>\n <defs>\n <filter id="A">\n <feDropShadow dx="0" dy="2" stdDeviation="4" flood-opacity=".3"/>\n </filter>\n </defs>\n</svg>\n');return t.querySelector("#bubble")?.setAttribute("fill",e),t.querySelector("#pin")?.setAttribute("fill",e),X(t)},xs={pixelRatio:2,stretchX:[[20,45],[100,130]],stretchY:[[20,35]],content:[10,10,130,45]},Ds=e=>{if(!K())return;const t=Z('<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32">\n <g id="main">\n <path fill-rule="evenodd"\n d="M11.389 4H9.025a.86.86 0 0 0-.517.173l-.001-.001a.5.5 0 0 1-.464.059l-.028-.011a.5.5 0 0 1-.129-.83A1.86 1.86 0 0 1 9.025 3h2.364a2 2 0 0 1 1.789 1.106l1.02 2.04c.471.176.802.63.802 1.156v.803c0 .543 0 .815-.071 1.038a1.5 1.5 0 0 1-.914.953c-.219.08-.491.092-1.034.114l-1.481.062v-.166-.803a2.23 2.23 0 0 0-1.055-1.897l-.74-1.479 2.326.033h.955l-.703-1.406A1 1 0 0 0 11.389 4zM12 8.4a1 1 0 1 1 2 0 .5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5z"/>\n <path d="M11.833 11.115c0-.109.089-.198.198-.198h1.979c.109 0 .198.089.198.198 0 .328-.266.594-.594.594h-1.187c-.328 0-.594-.266-.594-.594z"/>\n <path fill-rule="evenodd"\n d="M1.802 8.146C1.331 8.321 1 8.776 1 9.302v.803c0 .543 0 .815.071 1.038a1.5 1.5 0 0 0 .914.953c.219.08.491.092 1.034.114l2.731.114 2.731-.114c.543-.023.814-.034 1.034-.114a1.5 1.5 0 0 0 .914-.953c.071-.223.071-.494.071-1.038v-.803c0-.526-.331-.98-.802-1.156l-1.02-2.04A2 2 0 0 0 6.889 5H4.611a2 2 0 0 0-1.789 1.106l-1.02 2.04zM6.889 6H4.611a1 1 0 0 0-.894.553l-.703 1.406h.955 3.563.955l-.703-1.406A1 1 0 0 0 6.889 6zM2 10.4a1 1 0 1 1 2 0 .5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5zm6.5-1a1 1 0 0 0-1 1 .5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5 1 1 0 0 0-1-1z"/>\n <path d="M1.792 13.115c0-.109.089-.198.198-.198h1.979c.109 0 .198.089.198.198 0 .328-.266.594-.594.594H2.385c-.328 0-.594-.266-.594-.594zm5.739-.198c-.109 0-.198.089-.198.198 0 .328.266.594.594.594h1.188c.328 0 .594-.266.594-.594 0-.109-.089-.198-.198-.198h-1.98z"/>\n </g>\n</svg>\n'),i=t.querySelector("#main");return i.setAttribute("transform","scale(2)"),i.setAttribute("fill",e),X(t)},Fs=(e,t)=>{if(!K())return;const i=J(t);return e&&i.appendChild(e),X(i)},Ps=e=>{if(K())return Fs(Z('<svg xmlns="http://www.w3.org/2000/svg" width="120" height="140">\n <path d="M63.734 86.383c-1.404.026-2.78-.393-3.93-1.197s-2.01-1.949-2.46-3.271l-3.15-9.339c-1.093-3.403-3.748-6.089-7.154-7.238L37.5 62.21c-2.742-.902-4.567-3.477-4.5-6.345-.058-2.874 1.761-5.457 4.5-6.388l36-11.886c2.461-.88 5.213-.27 7.062 1.567s2.466 4.571 1.578 7.015L70.17 81.918c-.938 2.719-3.54 4.526-6.436 4.469h0z"\n fill="#f4f5f6"/>\n</svg>\n'),e)},Us=e=>{if(K())return Fs(Z('<svg xmlns="http://www.w3.org/2000/svg" width="120" height="140">\n <path d="M33 83.404a2.99 2.99 0 0 1-3-2.978V44.681a2.99 2.99 0 1 1 6 0v35.745a2.99 2.99 0 0 1-3 2.978zm48-38.723H39v17.872h42V44.681zm3.878 37.851a3.02 3.02 0 0 0 4.244 0c.561-.559.878-1.317.878-2.106V44.681a2.99 2.99 0 1 0-6 0v35.745c0 .789.317 1.547.878 2.106z"\n fill="#f4f5f6"/>\n</svg>\n'),e)},Hs=(e={},t)=>Object.entries(e).map(([e,i])=>({...i,id:t?`${t}-${e}`:e})),ks=(e={},t)=>({mainLines:Hs(e.mainLines,t),waypoints:Hs(e.waypoints,t),chargingStops:Hs(e?.chargingStops,t),ferries:Hs(e.sections?.ferry,t),incidents:Hs(e.sections?.incident,t),tollRoads:Hs(e.sections?.tollRoad,t),tunnels:Hs(e.sections?.tunnel,t),vehicleRestricted:Hs(e.sections?.vehicleRestricted,t),instructionLines:Hs(e.instructionLines,t),instructionArrows:Hs(e.instructionArrows,t),summaryBubbles:Hs(e.summaryBubbles,t)}),Ws=(e,t,i)=>{const r=l.instance.get().displayUnits,s=e?.displayUnits;return{...e,...s?{}:{displayUnits:r},layers:Os(e,t,i)}},Gs=(e,t)=>{const i=t?.chargingStops?.icon;if(i?.mapping){const t=i.mapping;switch(t.basedOn){case"chargingSpeed":if(e.properties.chargingConnectionInfo?.chargingSpeed)return t.value[e.properties.chargingConnectionInfo?.chargingSpeed];break;case"custom":return t.fn(e)}}return q("7309")},Bs=e=>{const t=e.properties;return t.chargingParkName??t.chargingParkOperatorName},Vs=(e,t)=>{const i=[];if(!1!==t?.chargingStops?.visible)for(const r of e.features)for(const e of r.properties.sections.leg){const s=e.summary.chargingInformationAtEndOfLeg;if(s){const e=s.properties;i.push({...s,properties:{...s.properties,id:s.properties.chargingParkId??f(),iconID:Gs(s,t),title:Bs(s),chargingPower:`${e.chargingConnectionInfo?.chargingPowerInkW} kW`,chargingDuration:p(e.chargingTimeInSeconds,t?.displayUnits?.time),routeState:r.properties.routeState}})}}return{type:"FeatureCollection",features:i}},js=e=>e.categories.includes("jam"),zs=e=>{const t=(e=>{if(js(e))return p(e.delayInSeconds)})(e),i=((e,t)=>js(e)?`traffic-jam-${e.magnitudeOfDelay??"unknown"}-${(e=>e?.length?e.length<6?"small":e.length<8?"medium":"large":"collapsed")(t)}`:null)(e,t),r=(e=>{const t=e.categories.find(e=>"jam"!==e);return t?(e=>{switch(e){case"accident":return"traffic-incidents-accident";case"roadworks":return"traffic-incidents-roadworks";case"road-closed":return"traffic-incidents-road_closed";case"lane-closed":case"narrow-lanes":return"traffic-incidents-lane_closed";case"danger":case"animals-on-road":return"traffic-incidents-danger";case"broken-down-vehicle":return"traffic-incidents-broken_down_vehicle";case"wind":return"traffic-incidents-wind";case"fog":return"traffic-incidents-fog";case"rain":return"traffic-incidents-rain";case"frost":return"traffic-incidents-frost";case"flooding":return"traffic-incidents-flooding";default:return null}})(t):null})(e);return{...e,...i&&{jamIconID:i},...r&&{causeIconID:r},...t&&{title:t}}},$s=(e,t,i)=>{let r;switch(t){case"start":r=Ls;break;case"finish":r=Ss;break;default:r=As}return void 0!==i?nt(r,i):r},Ys=(e,t,i)=>({type:"FeatureCollection",features:e.map((r,s)=>{if(!r)return null;const a=(e=>{return Array.isArray(e)?{type:"Feature",geometry:{type:"Point",coordinates:e},properties:{}}:"Point"===e.type?{type:"Feature",geometry:t=e,properties:{},...t.bbox&&{bbox:t.bbox}}:e;var t})(r),o=((e,t)=>0===e?ys:e<t-1?ms:gs)(s,e.length),n=(e=>{const t=e?.properties;return t?.poi?.name??t?.address?.freeformAddress??void 0})(a),l=a.id??f();return{...a,..."main-when-available"===t?.entryPoints&&{geometry:{type:"Point",coordinates:m(a,{useEntryPoint:"main-when-available"})}},id:l,properties:{...a.properties,id:l,index:s,indexType:o,...n&&{title:n},iconID:$s(0,o,i),..."middle"===o&&{stopDisplayIndex:s}}}}).filter(e=>e)}),qs=(e,t,i)=>({type:"FeatureCollection",features:e.features.flatMap(e=>((e,t,i)=>e.properties.sections[t]?.map(t=>{const r=t.id??f();return{type:"Feature",id:r,geometry:{type:"LineString",coordinates:e.geometry.coordinates.slice(t.startPointIndex,t.endPointIndex+1)},properties:{...i?i(t,e.properties):t,routeState:e.properties.routeState,routeIndex:e.properties.index,id:r}}})||[])(e,t,i))}),Ks=(e,t)=>t.show(((e,t)=>({...t,features:t.features.map(t=>({...t,properties:{...t.properties,routeState:e.features[t.properties.routeIndex||0].properties.routeState}}))}))(e,t.shownFeatures)),Xs=(e,t=0)=>{const i="features"in e?e:{type:"FeatureCollection",features:[e]};return{...i,features:i.features.map((e,i)=>{const r=e.id??f();return{...e,id:r,properties:{...e.properties,id:r,routeState:i===t?"selected":"deselected"}}})}},Zs=(e,t)=>e.some(e=>e.magnitudeOfDelay===t),Js=(e,t)=>({type:"FeatureCollection",features:e.features.map(e=>{const i=e.properties.summary,r=e.geometry.coordinates,s=p(i.trafficDelayInSeconds,t?.time),a=(e=>{const t=e.properties.sections.traffic;if(t?.length)return Zs(t,"major")?"major":Zs(t,"moderate")?"moderate":Zs(t,"minor")?"minor":void 0})(e),o=e.id??f();return{type:"Feature",id:o,geometry:{type:"Point",coordinates:r[Math.round(r.length/2)]},properties:{id:o,routeIndex:e.properties.index,routeState:e.properties.routeState,formattedDistance:d(i.lengthInMeters,t?.distance),...a&&{magnitudeOfDelay:a},...s&&{formattedTraffic:s},formattedDuration:p(i.travelTimeInSeconds,t?.time)}}})}),Qs=class e extends be{static async create(t,i){return await de(t),new e(t,i)}constructor(e,t){super("geojson",e,t),this.shownFeaturesHandlers=[]}createSourcesWithLayers(e){const t=nt("routes",this.instanceIndex);return{mainLines:new ue(this.mapLibreMap,`${t}-mainLines`,e.mainLines,!1),waypoints:new ue(this.mapLibreMap,`${t}-waypoints`,e.waypoints,!1),incidents:new ue(this.mapLibreMap,`${t}-incidents`,e.incidents,!1),ferries:new ue(this.mapLibreMap,`${t}-ferries`,e.ferries,!1),chargingStops:new ue(this.mapLibreMap,`${t}-chargingStops`,e.chargingStops,!1),tollRoads:new ue(this.mapLibreMap,`${t}-tollRoads`,e.tollRoads,!1),tunnels:new ue(this.mapLibreMap,`${t}-tunnels`,e.tunnels,!1),vehicleRestricted:new ue(this.mapLibreMap,`${t}-vehicleRestricted`,e.vehicleRestricted,!1),instructionLines:new ue(this.mapLibreMap,`${t}-instructionLines`,e.instructionLines,!1),instructionArrows:new ue(this.mapLibreMap,`${t}-instructionArrows`,e.instructionArrows,!1),summaryBubbles:new ue(this.mapLibreMap,`${t}-summaryBubbles`,e.summaryBubbles,!1)}}_initSourcesWithLayers(e,t){t||(this.layerIDPrefix=nt("routes",this.instanceIndex)),this.layersSpecs=ks(Ws(e,this.layerIDPrefix,this.instanceIndex).layers,this.layerIDPrefix);const i=this.createSourcesWithLayers(this.layersSpecs);ge(Object.values(i).flatMap(e=>e._layerSpecs),this.mapLibreMap);const r={fillColor:e?.theme?.mainColor,...e?.waypoints?.icon?.style},s={pixelRatio:2},a=nt(Ls,this.instanceIndex),o=nt(As,this.instanceIndex),n=nt(Ss,this.instanceIndex),l=nt(Ur,this.instanceIndex),c=nt(Yr,this.instanceIndex),h=nt(qr,this.instanceIndex),u=nt(ls,this.instanceIndex),d=nt(cs,this.instanceIndex),p=nt(hs,this.instanceIndex),f=nt(us,this.instanceIndex);this.addImageIfNotExisting(a,Ps(r),s),this.addImageIfNotExisting(o,Fs(void 0,r),s),this.addImageIfNotExisting(n,Us(r),s),this.addImageIfNotExisting(l,te,s),this.addImageIfNotExisting(c,Ms("white"),xs),this.addImageIfNotExisting(h,Ms("#EEEEEE"),xs),this.addImageIfNotExisting(u,Ds(Cr),s),this.addImageIfNotExisting(d,Ds(Er),s),this.addImageIfNotExisting(p,Ds(br),s),this.addImageIfNotExisting(f,Ds(Tr),s);for(const y of e?.chargingStops?.icon?.customIcons??[])this.addImageIfNotExisting(y.id,y.image,{pixelRatio:y.pixelRatio??2});return i}_applyConfig(e){const i=Ws(e,this.layerIDPrefix,this.instanceIndex);if(this.config){const e=ks(i.layers,this.layerIDPrefix);Object.keys(e).forEach(t=>{const i=t;me(e[i],this.layersSpecs[i],this.sourcesWithLayers[i],this.mapLibreMap)});const t=Object.values(this.sourcesWithLayers);ge(t.flatMap(e=>e._layerSpecs),this.mapLibreMap),t.forEach(e=>e.setLayersVisible(!!e.shownFeatures.features.length)),this.layersSpecs=e}if(e?.theme?.mainColor!==this.config?.theme?.mainColor){const t={fillColor:e?.theme?.mainColor,...e?.waypoints?.icon?.style},i={pixelRatio:2};Ae("add-or-update",nt(Ls,this.instanceIndex),Ps(t),this.mapLibreMap,i),Ae("add-or-update",nt(As,this.instanceIndex),Fs(void 0,t),this.mapLibreMap,i),Ae("add-or-update",nt(Ss,this.instanceIndex),Us(t),this.mapLibreMap,i)}const r=!1!==i.summaryBubbles?.visible,s=!t(this.config?.summaryBubbles?.visible,i.summaryBubbles?.visible),a=!t(this.config?.displayUnits,i.displayUnits),o=this.sourcesWithLayers.summaryBubbles.shownFeatures.features.length>0,n=this.sourcesWithLayers.mainLines.shownFeatures.features.length>0;return!r&&s?this.sourcesWithLayers.summaryBubbles.clear():r&&(s&&n||a&&o)&&this.sourcesWithLayers.summaryBubbles.show(Js(this.sourcesWithLayers.mainLines.shownFeatures,i.displayUnits)),i}restoreDataAndConfigImpl(){const e=Object.entries(this.sourcesWithLayers).map(e=>({[e[0]]:e[1].shownFeatures})).reduce((e,t)=>({...e,...t}),{});this.initSourcesWithLayers(this.config,!0),this._applyConfig(this.config);for(const t of Object.keys(e))this.sourcesWithLayers[t].show(e[t])}addImageIfNotExisting(e,t,i){Ae("if-not-in-sprite",e,t,this.mapLibreMap,i)}async showRoutes(e,t){const i=Xs(e,t?.selectedIndex);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(i),this.sourcesWithLayers.vehicleRestricted.show(qs(i,"vehicleRestricted")),this.sourcesWithLayers.incidents.show(qs(i,"traffic",zs)),this.sourcesWithLayers.chargingStops.show(Vs(i,this.config)),this.sourcesWithLayers.ferries.show(qs(i,"ferry")),this.sourcesWithLayers.tunnels.show(qs(i,"tunnel")),this.sourcesWithLayers.tollRoads.show(qs(i,"toll")),this.sourcesWithLayers.instructionLines.show((e=>({type:"FeatureCollection",features:e.features.flatMap((e,t)=>e.properties.guidance?.instructions?.filter(e=>e.routePath?.length).map(i=>({type:"Feature",geometry:{type:"LineString",coordinates:i.routePath.map(e=>e.point)},properties:{...i,id:f(),routeIndex:t,routeState:e.properties.routeState}}))||[])}))(i)),this.sourcesWithLayers.instructionArrows.show((e=>({type:"FeatureCollection",features:e.features.flatMap((e,t)=>e.properties.guidance?.instructions?.filter(e=>e.routePath?.length&&e.routePath.length>1).map(i=>{const r=[i.routePath[i.routePath.length-2]?.point,i.routePath[i.routePath.length-1]?.point];return{type:"Feature",geometry:{type:"Point",coordinates:r[1]},properties:{...i,id:f(),routeIndex:t,routeState:e.properties.routeState,lastPointBearingDegrees:I(r[0],r[1])}}})||[])}))(i)),!1!==this.config?.summaryBubbles?.visible?this.sourcesWithLayers.summaryBubbles.show(Js(i,this.config?.displayUnits)):this.sourcesWithLayers.summaryBubbles.clear();for(const r of this.shownFeaturesHandlers)r({routes:e})}async clearRoutes(){await this.waitUntilModuleReady();for(const e of Object.keys(this.sourcesWithLayers))"waypoints"!==e&&this.sourcesWithLayers[e].clear()}async selectRoute(e){const t=Xs(this.sourcesWithLayers.mainLines.shownFeatures,e);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(t),this.sourcesWithLayers.chargingStops.show(Vs(t,this.config)),Ks(t,this.sourcesWithLayers.vehicleRestricted),Ks(t,this.sourcesWithLayers.incidents),Ks(t,this.sourcesWithLayers.ferries),Ks(t,this.sourcesWithLayers.tollRoads),Ks(t,this.sourcesWithLayers.tunnels),Ks(t,this.sourcesWithLayers.instructionLines),Ks(t,this.sourcesWithLayers.instructionArrows),Ks(t,this.sourcesWithLayers.summaryBubbles)}async showWaypoints(e){const t=Array.isArray(e)?Ys(e,this.config?.waypoints,this.instanceIndex):Ys(e.features,this.config?.waypoints,this.instanceIndex);await this.waitUntilModuleReady(),this.sourcesWithLayers.waypoints.show(t);for(const i of this.shownFeaturesHandlers)i({waypoints:e})}async clearWaypoints(){await this.waitUntilModuleReady(),this.sourcesWithLayers.waypoints.clear()}getShown(){return{mainLines:this.sourcesWithLayers.mainLines.shownFeatures,waypoints:this.sourcesWithLayers.waypoints.shownFeatures,incidents:this.sourcesWithLayers.incidents.shownFeatures,ferries:this.sourcesWithLayers.ferries.shownFeatures,chargingStops:this.sourcesWithLayers.chargingStops.shownFeatures,tollRoads:this.sourcesWithLayers.tollRoads.shownFeatures,tunnels:this.sourcesWithLayers.tunnels.shownFeatures,vehicleRestricted:this.sourcesWithLayers.vehicleRestricted.shownFeatures,instructionLines:this.sourcesWithLayers.instructionLines.shownFeatures,instructionArrows:this.sourcesWithLayers.instructionArrows.shownFeatures,summaryBubbles:this.sourcesWithLayers.summaryBubbles.shownFeatures}}get events(){return this.buildEvents(this.moduleEventsWithShown(["mainLines","waypoints","chargingStops","summaryBubbles","incidents","vehicleRestricted","ferries","tollRoads","tunnels","instructionLines"],this.shownFeaturesHandlers),{mainLines:this.userEvents(["mainLines"]),waypoints:this.userEvents(["waypoints"]),chargingStops:this.userEvents(["chargingStops"]),summaryBubbles:this.userEvents(["summaryBubbles"]),incidents:this.userEvents(["incidents"]),vehicleRestricted:this.userEvents(["vehicleRestricted"]),ferries:this.userEvents(["ferries"]),tollRoads:this.userEvents(["tollRoads"]),tunnels:this.userEvents(["tunnels"]),instructionLines:this.userEvents(["instructionLines"])})}getLayerToRenderLinesUnder(){return xe.lowestLabel}},ea="standardLight",ta={standardLight:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_light"},standardDark:{trafficIncidents:"incidents_dark",trafficFlow:"flow_relative-dark",hillshade:"hillshade_dark"},drivingLight:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_light"},drivingDark:{trafficIncidents:"incidents_dark",trafficFlow:"flow_relative-dark",hillshade:"hillshade_dark"},monoLight:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_mono-light"},monoDark:{trafficIncidents:"incidents_dark",trafficFlow:"flow_relative-dark",hillshade:"hillshade_mono-dark"},satellite:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_satellite"}},ia={standardLight:"basic_street-light",standardDark:"basic_street-dark",drivingLight:"basic_street-light-driving",drivingDark:"basic_street-dark-driving",monoLight:"basic_mono-light",monoDark:"basic_mono-dark",satellite:"basic_street-satellite"},ra=(e,t,i)=>{const r=e.id??"standardLight",s=e.version??"0.6.0-0",a=new URL(`${t}/maps/orbis/assets/styles/${s}/style.json`);a.searchParams.set("apiVersion","1"),i&&a.searchParams.set("key",i),a.searchParams.set("map",ia[r]);for(const o of e.include??$i)a.searchParams.append(o,ta[r][o]);return a.toString()},sa=e=>{const t=e.style,i=e.commonBaseURL,r=e.apiKey;return"string"==typeof t?ra({id:t},i,r):"standard"===t?.type?ra(t,i,r):"custom"===t?.type&&t?.url?((e,t)=>{const i=new URL(e);return i.searchParams.has("key")?console.warn("The style URL is coming with an API key parameter which takes priority. If you want to use the SDK configured API key, remove the key param from the style URL"):t&&i.searchParams.set("key",t),i.toString()})(t.url,r):"custom"===t?.type&&t?.json?t.json:ra({id:ea},i,r)},aa=class{constructor(e){var i;this.mapReady=!1,this.styleChangeHandlers=[],this.setStyle=(e,i={keepState:!0})=>{this.mapReady=!1;for(const t of[...this.styleChangeHandlers])try{t.onStyleAboutToChange?.()}catch(s){console.error(s)}const r=i.keepState?((e,t)=>t&&"object"==typeof t&&"standard"===t.type&&t.include&&("string"==typeof e||"standard"===e.type&&!e.include)?{type:"standard",id:"string"==typeof e?e:e.id,include:t.include}:e)(e,this._params.style):e;this._params={...this._params,style:r},this.styleLightDarkTheme=Ie(r),this.mapLibreMap.setStyle(sa(this._params),{validate:!1}),this.mapLibreMap.once("style.load",()=>{!this.mapReady&&t(r,this._params.style)&&this.handleStyleData(i.keepState||!0)})},this.getStyle=()=>this._params.style,this._params=A(e),void 0===this._params.style&&(this._params={...this._params,style:ea}),this.styleLightDarkTheme=Ie(this._params.style),this.ensureMapLibreCSSLoaded(),x(4),this.mapLibreMap=new O({validateStyle:!1,maxTileCacheZoomLevels:22,cancelPendingTileRequestsWhileZooming:!1,...(i=this._params).mapLibre,style:sa(i),attributionControl:{compact:!1},transformRequest:fe(i)}),this.mapLibreMap.once("style.load",()=>{this.handleStyleData(!1)}),this._eventsProxy=new Me(this.mapLibreMap,this._params?.events),this.loadRTLTextPlugin()}loadRTLTextPlugin(){setTimeout(()=>{["deferred","loaded"].includes(w())||M("https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.3.0/dist/mapbox-gl-rtl-text.js",!0).catch(e=>console.error("Something went wrong when setting RTL plugin",e))})}ensureMapLibreCSSLoaded(){if("undefined"==typeof document)return;if(Array.from(document.querySelectorAll('link[rel="stylesheet"], style')).some(e=>e.textContent?.includes(".maplibregl-map")))return;const e=document.createElement("link");e.rel="stylesheet",e.href=`https://unpkg.com/maplibre-gl@${N()}/dist/maplibre-gl.css`,document.head.appendChild(e)}_setTomTomUserAgent(e){this._params={...this._params,"tomtom-user-agent":e},this.mapLibreMap.setTransformRequest(fe(this._params))}_setLanguage(e){this._params={...this._params,language:e};const t=e?.includes("-")?e.split("-")[0]:e;this.mapLibreMap.getStyle().layers.forEach(e=>{if("symbol"===e.type&&(e=>{const t=e.layout?.["text-field"]??"";return!!t&&("{name}"===t||2===t.length&&"name"===t[1]||3===t.length&&Array.isArray(t[1])&&"string"==typeof t[1][1]&&t[1][1].includes("name_")&&Array.isArray(t[2])&&t[2].includes("name"))})(e)){const i=t?["coalesce",["get",`name_${t}`],["get","name"]]:["get","name"];this.mapLibreMap.setLayoutProperty(e.id,"text-field",i,{validate:!1})}})}setLanguage(e){this.mapReady?this._setLanguage(e):this.mapLibreMap.once("styledata",()=>this.setLanguage(e))}getBBox(){return this.mapLibreMap.getBounds().toArray().flat()}handleStyleData(e){for(const i of ne(this.mapLibreMap,[Ue,He,Fe]))this.mapLibreMap.setLayoutProperty(i.id,"visibility","none",{validate:!1});if((async(e,t)=>{if(t.getSprite().some(e=>"pinCategories"===e.id))return;const i=new URLSearchParams;e.apiKey&&i.set("key",e.apiKey),i.set("poi",`poi_${Ie(e.style)}`),i.set("apiVersion","1"),i.set("apiChannel","preview"),t.addSprite(Y,`${e.commonBaseURL}/maps/orbis/assets/sprites/2.*/sprite?${i}`,{validate:!1})})(this._params,this.mapLibreMap),this._params.language&&this._setLanguage(this._params.language),this.mapReady=!0,e)for(const i of[...this.styleChangeHandlers])try{i.onStyleChanged?.()}catch(t){console.error(t)}}addStyleChangeHandler(e){this.styleChangeHandlers.push(e);let t=!1;return()=>{if(t)return;t=!0;const i=this.styleChangeHandlers.indexOf(e);-1!==i&&this.styleChangeHandlers.splice(i,1)}}},oa={visible:!0,displayMode:"hexgrid-3d",activeMetric:"congestionLevel",metricConfig:{congestionLevel:{color:{valueType:"raw",stops:[{value:0,color:"#2dc653"},{value:50,color:"#f5a623"},{value:100,color:"#e03030"}]},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},speed:{color:{valueType:"relativeToPredefinedRangePCT",stops:[{value:0,color:"#e03030"},{value:50,color:"#f5a623"},{value:100,color:"#2dc653"}]},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},travelTime:{color:{valueType:"relativeToPredefinedRangePCT",stops:[{value:0,color:"#2dc653"},{value:50,color:"#f5a623"},{value:100,color:"#e03030"}]},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},freeFlowSpeed:{color:{valueType:"relativeToPredefinedRangePCT",stops:[{value:0,color:"#e03030"},{value:50,color:"#f5a623"},{value:100,color:"#2dc653"}]},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},networkLength:{color:{valueType:"relativeToActualRangePCT",stops:[{value:0,color:"#2dc653"},{value:50,color:"#f5a623"},{value:100,color:"#e03030"}]},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"currentRange"}}},regionPolygon:{color:"#000000",fillOpacity:0,outlineOpacity:.5,outlineWidth:2,inverted:!1}},na={trafficLight:["#2dc653","#f5a623","#e03030"],heat:["#2196F3","#FF9800","#F44336"],monochrome:["#e0e0e0","#888888","#1a1a1a"],viridis:["#fde725","#35b779","#31688e","#440154"],plasma:["#f0f921","#ed7953","#9c179e","#0d0887"]},la={congestionLevel:{min:0,max:100},speed:{min:0,max:120},travelTime:{min:0,max:20},freeFlowSpeed:{min:0,max:120},networkLength:{min:0,max:5e3}},ca=e=>"speed"===e||"freeFlowSpeed"===e,ha=e=>e?.activeMetric??oa.activeMetric,ua=e=>{return"string"==typeof e?(t=na[e]).map((e,i)=>({value:1===t.length?0:i/(t.length-1),color:e})):e.stops;var t},da=e=>{if("top"!==e)return e?xe[e]:xe.lowestLabel},pa=e=>{if("top"!==e)return e?xe[e]:xe.lowestPlaceLabel},fa=(e,t,i)=>{const r=t??oa.metricConfig[e].color??"trafficLight",s=ua(r);let a;if("string"==typeof r){const{min:t,max:i}=la[e],r=ca(e)?[...s].reverse().map(e=>e.color):s.map(e=>e.color);a=s.map(({value:e},s)=>[t+e*(i-t),r[s]])}else if("relativeToPredefinedRangePCT"===r.valueType){const{min:t,max:i}=la[e];a=s.map(({value:e,color:r})=>[t+e/100*(i-t),r])}else if("relativeToActualRangePCT"===r.valueType){const{min:t,max:r}=i??la[e];a=s.map(({value:e,color:i})=>[t+e/100*(r-t),i])}else a=s.map(({value:e,color:t})=>[e,t]);return["interpolate",["linear"],["get",e],...a.flatMap(([e,t])=>[e,t])]},ya=(e,t)=>{const i=t??oa.metricConfig[e].color??"trafficLight",r=ua(i);let s;if("string"==typeof i){const t=ca(e)?[...r].reverse().map(e=>e.color):r.map(e=>e.color);s=r.flatMap(({value:e},i)=>[.3+.7*e,t[i]])}else if("relativeToPredefinedRangePCT"===i.valueType||"relativeToActualRangePCT"===i.valueType)s=r.flatMap(({value:e,color:t})=>[.3+e/100*.7,t]);else{const e=Math.min(...r.map(e=>e.value)),t=Math.max(...r.map(e=>e.value))-e||1;s=r.flatMap(({value:i,color:r})=>[.3+(i-e)/t*.7,r])}return["interpolate",["linear"],["heatmap-density"],0,"rgba(0,0,0,0)",...s]},ma=(e,t,i)=>{const r=oa.metricConfig[e].height,s=t?.minHeightMeters??r.minHeightMeters??0;if("raw"===t?.scaleMode){const i=t.scaleFactor??1;if("speed"===e){const{max:t}=la[e];return["max",s,["*",["-",t,["coalesce",["get","speed"],0]],i]]}return["max",s,["*",["coalesce",["get",e],0],i]]}const a=t?.maxHeightMeters??r.maxHeightMeters??1e3,{min:o,max:n}="currentRange"===(t?.scaleMode??r.scaleMode)?i??la[e]:la[e],l=n-o||1;return"speed"===e?["max",s,["*",["/",["-",n,["coalesce",["get","speed"],0]],l],a]]:["max",s,["*",["/",["-",["coalesce",["get",e],0],o],l],a]]},ga=(e,t,i)=>{const r=ha(t),s=t?.metricConfig?.[r],{min:a,max:o}=i??la[r];return{id:e,type:"heatmap",beforeID:da(t?.beforeLayerConfig?.heatmap),paint:{"heatmap-weight":["interpolate",["linear"],["get",r],a,0,o,1],"heatmap-intensity":["interpolate",["linear"],["zoom"],10,.5,14,2,16,4],"heatmap-color":ya(r,s?.color),"heatmap-radius":["interpolate",["linear"],["zoom"],4,1,8,3,12,35,14,80,16,100],"heatmap-opacity":["interpolate",["linear"],["zoom"],4,.8,13,.8,17,0]}}},_a=(e,t,i)=>{const r=ha(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:da(t?.beforeLayerConfig?.hexgrid?.flat2D),paint:{"fill-color":fa(r,s?.color,i),"fill-opacity":.6}}},La=(e,t,i)=>{const r=ha(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:pa(t?.beforeLayerConfig?.hexgrid?.extrusion3D),paint:{"fill-extrusion-color":fa(r,s?.color,i),"fill-extrusion-height":ma(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},Aa=(e,t,i)=>{const r=ha(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:da(t?.beforeLayerConfig?.square?.flat2D),paint:{"fill-color":fa(r,s?.color,i),"fill-opacity":.6}}},Sa=(e,t,i)=>{const r=ha(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:pa(t?.beforeLayerConfig?.square?.extrusion3D),paint:{"fill-extrusion-color":fa(r,s?.color,i),"fill-extrusion-height":ma(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},Ia=e=>({...oa.regionPolygon,...e}),Ea=(e,t)=>{const{color:i,fillOpacity:r}=Ia(t?.regionPolygon);return{id:e,type:"fill",beforeID:da(),paint:{"fill-color":i,"fill-opacity":r}}},ba=(e,t)=>{const{color:i,outlineOpacity:r,outlineWidth:s}=Ia(t?.regionPolygon);return{id:e,type:"line",beforeID:da(),paint:{"line-color":i,"line-opacity":r,"line-width":s}}},Ra=(e,t)=>({id:e,type:"line",beforeID:t,filter:["has","eventState"],paint:{"line-color":"#ffffff","line-width":["case",wt,3,2],"line-opacity":["case",wt,1,.8]}}),Ta=e=>({...e,filter:["has","eventState"],paint:{...e.paint,"fill-extrusion-color":["case",wt,"#ffffff","#ffffff"],"fill-extrusion-height":["+",e.paint?.["fill-extrusion-height"],.5],"fill-extrusion-opacity":.6}}),Ca=(e,t,i)=>Ta(La(e,t,i)),va=(e,t,i)=>Ta(Sa(e,t,i)),Oa=(e,t,i)=>((e,t,i)=>{const r=[];for(let s=0;s<e.length;s++){const a=e[s];if(!a)continue;const{congestionSum:o,speedSum:n,freeFlowSum:l,travelTimeSum:c,networkLengthSum:h,count:u}=a,d=`${i}-${s}`;r.push({type:"Feature",id:d,geometry:t.features[s].geometry,properties:{id:d,congestionLevel:Math.round(o/u),speed:Math.round(n/u),freeFlowSpeed:Math.round(l/u),travelTime:Math.round(c/u*10)/10,networkLength:Math.round(h/u)}})}return r})(((e,t)=>{const i=[];for(const r of e)for(let e=0;e<t.features.length;e++)if(E(r.tileCentre,t.features[e])){let t=i[e];void 0===t&&(t={congestionSum:0,speedSum:0,freeFlowSum:0,travelTimeSum:0,networkLengthSum:0,count:0},i[e]=t),t.congestionSum+=r.congestionLevel??0,t.speedSum+=r.speed??0,t.freeFlowSum+=r.freeFlowSpeed??0,t.travelTimeSum+=r.travelTime??0,t.networkLengthSum+=r.networkLength??0,t.count++;break}return i})(e,t),t,i),wa=.005,Na=(e,t,i,r)=>{const s=[];for(let a=0;a<e.features.length;a++){const o=e.features[a],n=o.properties?.tiledData?.tiles??[];if(0===n.length)continue;const l=u(o);if(!l)continue;const c=i([l[0]-wa,l[1]-wa,l[2]+wa,l[3]+wa],t);s.push(...Oa(n,c,`${r}-${a}`))}return{type:"FeatureCollection",features:s}},Ma=class e extends be{static async create(t,i){return await de(t),new e(t,i??{})}constructor(e,t){super("geojson",e,t),this.lastAnalytics=null,this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){const i=this.instanceIndex,r=`area-analytics-heatmap-${i}`,s=`area-analytics-hexgrid-${i}`,a=`area-analytics-square-${i}`,o=`area-analytics-region-${i}`,n=`${r}-layer`,l=`${s}-fill`,c=`${s}-extrusion`,h=`${s}-outline`,u=`${s}-extrusion-highlight`,d=`${a}-fill`,p=`${a}-extrusion`,f=`${a}-outline`,y=`${a}-extrusion-highlight`,m=`${o}-fill`,g=`${o}-line`;this.heatmapLayerSpec=ga(n,e),this.hexFillLayerSpec=_a(l,e),this.hexExtrusionLayerSpec=La(c,e),this.squareFillLayerSpec=Aa(d,e),this.squareExtrusionLayerSpec=Sa(p,e),this.regionFillLayerSpec=Ea(m,e),this.regionLineLayerSpec=ba(g,e),this.hexOutlineLayerSpec=((e,t)=>Ra(e,da(t?.beforeLayerConfig?.hexgrid?.flat2D)))(h,e),this.hexExtrusionHighlightLayerSpec=Ca(u,e),this.squareOutlineLayerSpec=((e,t)=>Ra(e,da(t?.beforeLayerConfig?.square?.flat2D)))(f,e),this.squareExtrusionHighlightLayerSpec=va(y,e);const _={heatmap:new ue(this.mapLibreMap,r,[this.heatmapLayerSpec]),hexgrid:new ue(this.mapLibreMap,s,[this.hexFillLayerSpec,this.hexExtrusionLayerSpec]),square:new ue(this.mapLibreMap,a,[this.squareFillLayerSpec,this.squareExtrusionLayerSpec]),region:new ue(this.mapLibreMap,o,[this.regionFillLayerSpec,this.regionLineLayerSpec])};return this.addHighlightLayersToMap(s,a),_}_applyConfig(e){if(void 0===e)return;const t=e.metricConfig&&this.config?.metricConfig?{...this.config.metricConfig,...e.metricConfig}:e.metricConfig??this.config?.metricConfig,i=Object.keys(oa.metricConfig),r=Object.fromEntries(i.map(e=>[e,t?.[e]??oa.metricConfig[e]])),s={activeMetric:oa.activeMetric,displayMode:oa.displayMode,...this.config,...e,metricConfig:r};return this.applyLayerConfig(s),s.regionPolygon&&this.applyRegionConfig(s),s.beforeLayerConfig&&this._moveBeforeLayer(s.beforeLayerConfig,!1),this.config=s,this.applyModeVisibility(),s}restoreDataAndConfigImpl(){const e=this.lastAnalytics;this.initSourcesWithLayers(this.config,!0),e?(!1===this.config?.visible&&this.setVisible(!1),this.show(e)):this.config&&this._applyConfig(this.config)}async show(e){await this.waitUntilModuleReady(),this.lastAnalytics=e,this.sourcesWithLayers.heatmap.show((e=>({type:"FeatureCollection",features:e.features.flatMap(e=>e.properties?.tiledData?.tiles??[]).map((e,t)=>{const[i,r]=e.tileCentre,s=`tile-${t}-${i}-${r}`;return{type:"Feature",id:s,geometry:{type:"Point",coordinates:[i,r]},properties:{id:s,speed:e.speed??0,freeFlowSpeed:e.freeFlowSpeed??0,congestionLevel:e.congestionLevel??0,travelTime:e.travelTime??0,networkLength:e.networkLength??0}}})}))(e),{automaticVisibility:!1}),this.sourcesWithLayers.hexgrid.show(((e,t=.25)=>Na(e,t,(e,t)=>T(e,t,{units:"kilometers"}),"hex"))(e),{automaticVisibility:!1}),this.sourcesWithLayers.square.show(((e,t=.5)=>Na(e,t,(e,t)=>v(e,t,{units:"kilometers"}),"square"))(e),{automaticVisibility:!1});const t=this.config?.regionPolygon?.inverted??oa.regionPolygon.inverted;this.sourcesWithLayers.region.show(this.buildRegionFC(e.features,t)),this.applyLayerConfig(this.config),this.applyModeVisibility();for(const i of this.shownFeaturesHandlers)i(e)}async clear(){await this.waitUntilModuleReady(),this.lastAnalytics=null,this.sourcesWithLayers.heatmap.clear(),this.sourcesWithLayers.hexgrid.clear(),this.sourcesWithLayers.square.clear(),this.sourcesWithLayers.region.clear()}setMode(e){e!==this.mode&&(this.config={...this.config,displayMode:e},this.applyModeVisibility(),this.emitConfigChange())}setMetric(e){e!==this.activeMetric&&(this.config={...this.config,activeMetric:e},this.applyLayerConfig(this.config),this.emitConfigChange())}setColor(e,t){const i=Object.keys(oa.metricConfig),r=t??i,s={...this.config?.metricConfig};if(void 0===e)for(const a of r){const{color:e,...t}=s[a]??{};s[a]=t}else if("string"==typeof e){const t=(e=>{const t=ua(e),i=e=>{const{min:i,max:r}=la[e],s=ca(e)?[...t].reverse().map(e=>e.color):t.map(e=>e.color);return{valueType:"raw",stops:t.map(({value:e},t)=>({value:i+e*(r-i),color:s[t]}))}};return{congestionLevel:{color:i("congestionLevel")},speed:{color:i("speed")},travelTime:{color:i("travelTime")},freeFlowSpeed:{color:i("freeFlowSpeed")},networkLength:{color:i("networkLength")}}})(e);for(const e of r)s[e]={...s[e],...t[e]}}else for(const a of r)s[a]={...s[a],color:e};this.config={...this.config,metricConfig:s},this.applyLayerConfig(this.config),this.emitConfigChange()}setHeight(e,t){const i=Object.keys(oa.metricConfig),r=t??i,s={...this.config?.metricConfig};for(const a of r)s[a]={...s[a],height:e};this.config={...this.config,metricConfig:s},this.applyLayerConfig(this.config),this.emitConfigChange()}filter(e,t){const i=Object.keys(oa.metricConfig),r=t??i,s={...this.config?.metricConfig};for(const a of r)s[a]={...s[a],filters:e};this.config={...this.config,metricConfig:s},this.applyFiltersToLayers(),this.emitConfigChange()}clearFilter(e){this.filter(void 0,e)}setVisible(e){this.config={...this.config,visible:e},this.applyModeVisibility(),this.emitConfigChange()}isVisible(){return this.sourcesWithLayers.heatmap.isAnyLayerVisible()||this.sourcesWithLayers.hexgrid.isAnyLayerVisible()||this.sourcesWithLayers.square.isAnyLayerVisible()}getShown(){return{heatmap:this.sourcesWithLayers.heatmap.shownFeatures,hexgrid:this.sourcesWithLayers.hexgrid.shownFeatures,square:this.sourcesWithLayers.square.shownFeatures}}moveBeforeLayer(e){this._moveBeforeLayer(e)}_moveBeforeLayer(e,t=!0){const i=e=>"top"===e?void 0:xe[e];void 0!==e.heatmap&&this.mapLibreMap.moveLayer(this.heatmapLayerSpec.id,i(e.heatmap)),void 0!==e.hexgrid?.flat2D&&this.mapLibreMap.moveLayer(this.hexFillLayerSpec.id,i(e.hexgrid.flat2D)),void 0!==e.hexgrid?.extrusion3D&&this.mapLibreMap.moveLayer(this.hexExtrusionLayerSpec.id,i(e.hexgrid.extrusion3D)),void 0!==e.square?.flat2D&&this.mapLibreMap.moveLayer(this.squareFillLayerSpec.id,i(e.square.flat2D)),void 0!==e.square?.extrusion3D&&this.mapLibreMap.moveLayer(this.squareExtrusionLayerSpec.id,i(e.square.extrusion3D)),t&&(this.config={...this.config,beforeLayerConfig:e})}get events(){return this.moduleEventsWithShown(["hexgrid","square","heatmap"],this.shownFeaturesHandlers)}get mode(){return this.config?.displayMode??oa.displayMode}get activeMetric(){return ha(this.config)}applyModeVisibility(){if(!1===this.config?.visible)return void this.hideAllDataLayers();const e=this.mode,t=this.sourcesWithLayers.heatmap.shownFeatures.features.length>0,i=this.sourcesWithLayers.hexgrid.shownFeatures.features.length>0,r=this.sourcesWithLayers.square.shownFeatures.features.length>0,s=this.sourcesWithLayers.region.shownFeatures.features.length>0;this.sourcesWithLayers.heatmap.setLayersVisible("heatmap"===e&&t),this.sourcesWithLayers.hexgrid.setLayersVisible("hexgrid-3d"===e&&i,e=>e.id===this.hexExtrusionLayerSpec.id),this.sourcesWithLayers.hexgrid.setLayersVisible("hexgrid-2d"===e&&i,e=>e.id===this.hexFillLayerSpec.id),this.sourcesWithLayers.square.setLayersVisible("square-3d"===e&&r,e=>e.id===this.squareExtrusionLayerSpec.id),this.sourcesWithLayers.square.setLayersVisible("square-2d"===e&&r,e=>e.id===this.squareFillLayerSpec.id),this.sourcesWithLayers.region.setLayersVisible(s),this.setHighlightLayerVisible(this.hexOutlineLayerSpec.id,"hexgrid-2d"===e&&i),this.setHighlightLayerVisible(this.hexExtrusionHighlightLayerSpec.id,"hexgrid-3d"===e&&i),this.setHighlightLayerVisible(this.squareOutlineLayerSpec.id,"square-2d"===e&&r),this.setHighlightLayerVisible(this.squareExtrusionHighlightLayerSpec.id,"square-3d"===e&&r)}hideAllDataLayers(){this.sourcesWithLayers.heatmap.setLayersVisible(!1),this.sourcesWithLayers.hexgrid.setLayersVisible(!1),this.sourcesWithLayers.square.setLayersVisible(!1),this.sourcesWithLayers.region.setLayersVisible(!1),this.setHighlightLayerVisible(this.hexOutlineLayerSpec.id,!1),this.setHighlightLayerVisible(this.hexExtrusionHighlightLayerSpec.id,!1),this.setHighlightLayerVisible(this.squareOutlineLayerSpec.id,!1),this.setHighlightLayerVisible(this.squareExtrusionHighlightLayerSpec.id,!1)}addHighlightLayersToMap(e,t){const i=(e,t)=>{this.mapLibreMap.getLayer(e.id)||this.mapLibreMap.addLayer({...e,source:t},e.beforeID),this.mapLibreMap.setLayoutProperty(e.id,"visibility","none")};i(this.hexOutlineLayerSpec,e),i(this.hexExtrusionHighlightLayerSpec,e),i(this.squareOutlineLayerSpec,t),i(this.squareExtrusionHighlightLayerSpec,t)}setHighlightLayerVisible(e,t){this.mapLibreMap.getLayer(e)&&this.mapLibreMap.setLayoutProperty(e,"visibility",t?"visible":"none")}applyLayerConfig(e){const t=this.lastAnalytics?.properties.ranges?.[this.activeMetric],i=ga(this.heatmapLayerSpec.id,e,t),r=_a(this.hexFillLayerSpec.id,e,t),s=La(this.hexExtrusionLayerSpec.id,e,t),a=Ca(this.hexExtrusionHighlightLayerSpec.id,e,t),o=Aa(this.squareFillLayerSpec.id,e,t),n=Sa(this.squareExtrusionLayerSpec.id,e,t),l=va(this.squareExtrusionHighlightLayerSpec.id,e,t);ye(i,this.heatmapLayerSpec,this.mapLibreMap),ye(r,this.hexFillLayerSpec,this.mapLibreMap),ye(s,this.hexExtrusionLayerSpec,this.mapLibreMap),ye(a,this.hexExtrusionHighlightLayerSpec,this.mapLibreMap),ye(o,this.squareFillLayerSpec,this.mapLibreMap),ye(n,this.squareExtrusionLayerSpec,this.mapLibreMap),ye(l,this.squareExtrusionHighlightLayerSpec,this.mapLibreMap),this.heatmapLayerSpec=i,this.hexFillLayerSpec=r,this.hexExtrusionLayerSpec=s,this.hexExtrusionHighlightLayerSpec=a,this.squareFillLayerSpec=o,this.squareExtrusionLayerSpec=n,this.squareExtrusionHighlightLayerSpec=l,this.applyFiltersToLayers()}applyRegionConfig(e){const t=Ea(this.regionFillLayerSpec.id,e),i=ba(this.regionLineLayerSpec.id,e);if(ye(t,this.regionFillLayerSpec,this.mapLibreMap),ye(i,this.regionLineLayerSpec,this.mapLibreMap),this.regionFillLayerSpec=t,this.regionLineLayerSpec=i,this.lastAnalytics){const t=e?.regionPolygon?.inverted??oa.regionPolygon.inverted;this.sourcesWithLayers.region.show(this.buildRegionFC(this.lastAnalytics.features,t))}}applyFiltersToLayers(){const e=this.activeMetric,t=this.config?.metricConfig?.[e]?.filters,i=[this.hexFillLayerSpec.id,this.hexExtrusionLayerSpec.id,this.squareFillLayerSpec.id,this.squareExtrusionLayerSpec.id];if(!t||void 0===t.min&&void 0===t.max){for(const e of i)this.mapLibreMap.setFilter(e,null);return}const r=[];void 0!==t.min&&r.push([">=",["get",e],t.min]),void 0!==t.max&&r.push(["<=",["get",e],t.max]);const s=1===r.length?r[0]:["any",...r];for(const a of i)this.mapLibreMap.setFilter(a,s)}buildRegionFC(e,t){return{type:"FeatureCollection",features:e.map((e,i)=>{const r=`traffic-area-analytics-region-${i}`,s=t?C(e).geometry:e.geometry;return{...e,id:r,geometry:s,properties:{id:r}}})}}},xa=(e,t)=>e.length?1===e.length?{expression:e[0],legacy:t[0]}:{expression:["all",...e],legacy:["all",...t]}:null,Da=(e,t,i)=>{e&&(t.push(e.expression),i.push(e.legacy))},Fa=(e,t,i,r)=>{e&&Da(ui(t,e),i,r)},Pa=(e,t,i)=>{Fa(e.roadCategories,"road_category",t,i),Fa(e.roadSubCategories,"road_subcategory",t,i)},Ua=e=>{const t=[],i=[];if(Pa(e,t,i),e.incidentCategories){const r=ui("icon_category_0",e.incidentCategories,e=>j[e]);Da(r,t,i)}if(e.magnitudes){const r=ui("magnitude_of_delay",e.magnitudes,e=>_.indexOf(e));Da(r,t,i)}return e.delays&&Da((e=>{const t=[],i=[];if(e.mustHaveDelay&&e.minDelayMinutes){const r=60*e.minDelayMinutes;t.push([">=",["get","delay"],r]),i.push([">=","delay",r])}else if(e.mustHaveDelay)t.push([">",["get","delay"],0]),i.push([">","delay",0]);else if(e.minDelayMinutes){const r=60*e.minDelayMinutes;t.push(["any",["!",["has","delay"]],["==",["get","delay"],0],[">=",["get","delay"],r]]),i.push(["any",["!has","delay"],["==","delay",0],[">=","delay",r]])}return xa(t,i)})(e.delays),t,i),xa(t,i)},Ha=e=>{if(!e?.any?.length)return null;const t=e.any.map(Ua).filter(e=>!i(e));return li(t)},ka=e=>{const t=[],i=[];if(Pa(e,t,i),e.showRoadClosures){const r="only"===e.showRoadClosures?"==":"!=";t.push([r,["get","road_closure"],!0]),i.push([r,"road_closure",!0])}return xa(t,i)},Wa=(e,t,i,r)=>{for(const s of t)i.setFilter(s.id,e?ci(e,r[s.id]):r[s.id])},Ga=class e extends be{static async get(t,i){return await de(t),await Le(t,He,"trafficFlow"),We(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super("style",e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(He);if(!t)throw $(`init ${e.name} with source ID ${He}`);this.originalFilters={};for(const e of this.getLayers())this.originalFilters[e.id]=e.filter;return{trafficFlow:new le(this.mapLibreMap,t)}}_applyConfig(e){return this._setVisible(e?.visible??!1,!1),this._filter(e?.filters,!1),e}getLayers(){return ne(this.tomtomMap.mapLibreMap,[He])}filter(e){this._filter(e)}_filter(e,t=!0){if(this.tomtomMap.mapReady)if(e?.any?.length){const t=(e=>{if(!e?.any?.length)return null;const t=e.any.map(ka).filter(e=>!i(e));return li(t)})(e);t&&Wa(t,this.getLayers(),this.mapLibreMap,this.originalFilters)}else this.config?.filters?.any?.length&&Wa(void 0,this.getLayers(),this.mapLibreMap,this.originalFilters);t&&(this.config=a({...this.config,filters:e},i),this.emitConfigChange())}setVisible(e){this._setVisible(e)}_setVisible(e,t=!0){this.tomtomMap.mapReady&&this.sourcesWithLayers.trafficFlow.setLayersVisible(e),t&&(this.config={...this.config,visible:e},this.emitConfigChange())}isVisible(){return this.sourcesWithLayers.trafficFlow.isAnyLayerVisible()}getShown(){return{trafficFlow:this.mapLibreMap.queryRenderedFeatures({layers:this.sourcesWithLayers.trafficFlow.sourceAndLayerIDs.layerIDs,validate:!1}).map(B)}}get events(){return this.moduleEvents(["trafficFlow"],{mapping:B})}},Ba="tt-traffic-incident-direction-chevron",Va='<svg xmlns="http://www.w3.org/2000/svg" width="48" height="18" viewBox="0 0 48 18">\n<path d="M 18 4 L 30 9 L 18 14" fill="none" stroke="rgba(20, 30, 50, 0.5)" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>\n<path d="M 18 4 L 30 9 L 18 14" fill="none" stroke="white" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>\n</svg>',ja=["unknown","minor","moderate","major","indefinite"],za={unknown:{outline:"TrafficIncidents - No delay outline",inner:"TrafficIncidents - No delay pattern"},minor:{outline:"TrafficIncidents - Minor jam outline",inner:"TrafficIncidents - Minor jam"},moderate:{outline:"TrafficIncidents - Moderate jam outline",inner:"TrafficIncidents - Moderate jam"},major:{outline:"TrafficIncidents - Major jam outline",inner:"TrafficIncidents - Major jam"},indefinite:{outline:"TrafficIncidents - Closed road outline",inner:"TrafficIncidents - Closed road pattern"}},$a={outline:{unknown:"hsl(198, 20%, 54%)",minor:"hsl(45, 85%, 36%)",moderate:"hsl(9, 87%, 31%)",major:"hsl(0, 100%, 17%)",indefinite:"hsl(0, 100%, 34%)"},inner:{unknown:"hsl(198, 20%, 90%)",minor:"hsl(45, 100%, 51%)",moderate:"hsl(9, 97%, 51%)",major:"hsl(0, 100%, 34%)",indefinite:"hsl(197, 28%, 95%)"}},Ya=(e,t,i)=>{if(!e||"object"!=typeof e)return;const r=e.paint;if(!r||"object"!=typeof r)return;const s=r["line-color"];if("string"==typeof s)return s;void 0!==s&&i.push(t)},qa=["interpolate",["exponential",1.5],["zoom"],5,0,9,.96,13,2.1,19,10.8],Ka=["interpolate",["exponential",1.5],["zoom"],5,.75,9,1.96,13,3.6,19,13.8],Xa=e=>["match",["get","magnitudeOfDelay"],"unknown",e.unknown,"minor",e.minor,"moderate",e.moderate,"major",e.major,"indefinite",e.indefinite,e.major],Za=["match",["get","magnitudeOfDelay"],"unknown","traffic-incidents-no_delay-pattern","indefinite","traffic-incidents-road_closed-pattern",""],Ja=e=>!1===e?null:{outlineColor:e?.outlineColor??"#000",widthScale:e?.widthScale??1.6},Qa=["interpolate",["exponential",1.5],["zoom"],5,2.2,9,4.6,13,8.3,19,26],eo=["case",["==",["feature-state","focused"],!0],1,0],to=(e,t)=>{if(null===t)return e;const[i,r,s,...a]=e;return[i,r,s,...a.map((e,i)=>i%2==1?["case",["==",["feature-state","focused"],!0],e*t,e]:e)]},io=["in",["get","magnitudeOfDelay"],["literal",["minor","moderate","major"]]],ro=["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],so=(e,t,i=$a,r=Ja(void 0))=>{const s=r?.widthScale??null,a=[];return null!==r&&a.push({id:`${e}-focus-halo`,type:"line",minzoom:6,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":r.outlineColor,"line-width":Qa,"line-blur":0,"line-opacity":eo},beforeID:t}),a.push({id:`${e}-outline`,type:"line",minzoom:6,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":Xa(i.outline),"line-width":to(Ka,s)},beforeID:t},{id:`${e}-inner-solid`,type:"line",minzoom:6,filter:io,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":Xa(i.inner),"line-width":to(qa,s)},beforeID:t},{id:`${e}-inner-chevron`,type:"line",minzoom:12,filter:io,layout:{"line-cap":"butt","line-join":"round"},paint:{"line-pattern":Ba,"line-width":to(qa,s)},beforeID:t},{id:`${e}-inner-pattern`,type:"line",minzoom:6,filter:ro,layout:{"line-cap":"round","line-join":"round"},paint:{"line-pattern":Za,"line-width":to(qa,s)},beforeID:t}),a},ao=["step",["zoom"],.7,14,.8,16,.9,18,1],oo=["step",["zoom"],12.6,14,14.4,16,16.2,18,18],no=["match",["get","category"],"other","traffic-incidents-info","accident","traffic-incidents-accident","fog","traffic-incidents-fog","danger","traffic-incidents-roadworks","rain","traffic-incidents-rain","frost","traffic-incidents-frost","lane-closed","traffic-incidents-lane_closed","roadworks","traffic-incidents-roadworks","wind","traffic-incidents-wind","flooding","traffic-incidents-flooding","broken-down-vehicle","traffic-incidents-broken_down_vehicle",""],lo=["all",["!=",["get","magnitudeOfDelay"],"indefinite"],["any",["!",["has","delayInSeconds"]],["step",["zoom"],[">",["get","delayInSeconds"],900],14,[">",["get","delayInSeconds"],600],15,[">",["get","delayInSeconds"],300],16,!0]]],co=["all",["==",["get","category"],"jam"],["!=",["get","magnitudeOfDelay"],"unknown"],["!=",["get","magnitudeOfDelay"],"indefinite"],["step",["zoom"],[">",["get","delayInSeconds"],900],13,[">",["get","delayInSeconds"],600],14,[">",["get","delayInSeconds"],300],15,!0]],ho=["==",["get","magnitudeOfDelay"],"indefinite"],uo=["concat","traffic-jam-",["get","magnitudeOfDelay"],["case",["<",["get","delayInSeconds"],600],"-small",["<",["get","delayInSeconds"],3600],"-medium","-large"]],po=["case",["<=",["get","delayInSeconds"],60],"1 min",[">=",["get","delayInSeconds"],3600],["concat",["to-string",["floor",["/",["to-number",["get","delayInSeconds"]],3600]]]," hr ",["case",["==",["%",["round",["/",["to-number",["get","delayInSeconds"]],60]],60],0],"",["concat",["to-string",["round",["%",["/",["to-number",["get","delayInSeconds"]],60],60]]]," min"]]],["concat",["round",["/",["get","delayInSeconds"],60]]," min"]],fo=["case",["has","delayInSeconds"],["*",-1,["get","delayInSeconds"]],0],yo=(e,t)=>[{id:`${e}-incident-marker`,type:"symbol",minzoom:13,filter:lo,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":no,"icon-size":ao,"symbol-sort-key":fo},beforeID:t},{id:`${e}-jam-marker`,type:"symbol",minzoom:12,filter:co,layout:{"symbol-placement":"point","icon-anchor":"bottom-left","icon-offset":[2,3],"icon-image":uo,"icon-size":ao,"icon-padding":0,"text-anchor":"bottom-left","text-field":po,"text-font":["NotoSans-CondensedBold"],"text-offset":[2.7,-.75],"text-size":oo,"symbol-sort-key":fo},paint:{"text-color":"hsl(210, 30%, 14%)"},beforeID:t},{id:`${e}-closed-road-marker`,type:"symbol",minzoom:12,filter:ho,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":"traffic-incidents-road_closed","icon-size":ao},beforeID:t}],mo=e=>{if("top"!==e)return e?xe[e]:xe.lowestLabel},go=class e extends be{static async create(t,i){return await de(t),new e(t,i??{})}constructor(e,t){super("geojson",e,t),this.lastResult=null,this.lastFeatureIds=[],this.lastFocusIds=null,this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){const i=`traffic-incident-overlay-${this.instanceIndex}`,r=(()=>{if(K())return Ns||(Ns=X(Z(Va))),Ns})();r&&Ae("if-not-in-sprite",Ba,r,this.mapLibreMap);const s=mo(e?.beforeLayerConfig),a=(e=>{const t=e.getStyle()?.layers??[],i=/* @__PURE__ */new Map;for(const a of t)i.set(a.id,a);const r={outline:{...$a.outline},inner:{...$a.inner}},s=[];for(const a of ja){const e=za[a],t=Ya(i.get(e.outline),e.outline,s),o=Ya(i.get(e.inner),e.inner,s);t&&(r.outline[a]=t),o&&(r.inner[a]=o)}return s.length>0&&console.warn("[TrafficIncidentOverlayModule] style layers have non-literal `line-color` (match/case/etc.); falling back to default colour for: "+s.join(", ")),r})(this.mapLibreMap),o=Ja(e?.focus),n=[...so(i,s,a,o),...yo(i,s)];return{incidents:new ue(this.mapLibreMap,i,n)}}_applyConfig(e){return!1===e?.visible?this.sourcesWithLayers.incidents.setLayersVisible(!1):this.sourcesWithLayers.incidents.setLayersVisible(!0),this.applyBeforeLayer(e?.beforeLayerConfig),e}applyBeforeLayer(e){const t=mo(e);for(const i of this.sourcesWithLayers.incidents.sourceAndLayerIDs.layerIDs)this.mapLibreMap.moveLayer(i,t)}restoreDataAndConfigImpl(){this.initSourcesWithLayers(this.config,!0),this.lastResult&&this.sourcesWithLayers.incidents.show(this.lastResult),this._applyConfig(this.config),null!==this.lastFocusIds&&this.lastFocusIds.length>0&&this.setFocus(this.lastFocusIds)}async show(e){await this.waitUntilModuleReady(),this.clearFeatureState(),this.lastFocusIds=null,this.lastResult=e,this.lastFeatureIds=e.features.map(e=>e.properties.id).filter(e=>"string"==typeof e),this.sourcesWithLayers.incidents.show(e);for(const t of this.shownFeaturesHandlers)t(e)}async clear(){await this.waitUntilModuleReady(),this.clearFeatureState(),this.lastResult=null,this.lastFeatureIds=[],this.lastFocusIds=null,this.sourcesWithLayers.incidents.clear()}setVisible(e){this.config={...this.config,visible:e},this.sourcesWithLayers.incidents.setLayersVisible(e),this.emitConfigChange()}isVisible(){return this.sourcesWithLayers.incidents.isAnyLayerVisible()}moveBeforeLayer(e){this.config={...this.config,beforeLayerConfig:e},this.applyBeforeLayer(e),this.emitConfigChange()}getShown(){return{incidents:this.sourcesWithLayers.incidents.shownFeatures}}get events(){return this.moduleEventsWithShown(["incidents"],this.shownFeaturesHandlers)}setFocus(e){if(null===e||0===e.length)return this.lastFocusIds=null,void this.clearFeatureState();if(0===this.lastFeatureIds.length)return;this.lastFocusIds=e;const t=new Set(e),i=this.sourcesWithLayers.incidents.sourceAndLayerIDs.sourceID;for(const r of this.lastFeatureIds)this.mapLibreMap.setFeatureState({source:i,id:r},{focused:t.has(r)})}clearFeatureState(){if(0===this.lastFeatureIds.length)return;const e=this.sourcesWithLayers.incidents.sourceAndLayerIDs.sourceID;for(const t of this.lastFeatureIds)this.mapLibreMap.removeFeatureState({source:e,id:t})}},_o=class t extends be{static async get(e,i){return await de(e),await Le(e,Ue,"trafficIncidents"),We(e,t,()=>new t(e,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super("style",e,t)}_initSourcesWithLayers(){const e=this.mapLibreMap.getSource(Ue);if(!e)throw $(`init ${t.name} with source ID ${Ue}`);this.originalFilters={};for(const t of this.getLayers())this.originalFilters[t.id]=t.filter;return{trafficIncidents:new le(this.mapLibreMap,e)}}_applyConfig(e){return this._setVisible(e?.visible??!1,{updateConfig:!1}),i(e?.icons?.visible)||this._setIconsVisible(e.icons.visible,!1),this._filter(e?.filters,e?.icons?.filters,!1),e}filter(e,t){this._filter(e,t)}_filter(e,t,r=!0){if(this.tomtomMap.mapReady){if(e?.any?.length){const i=Ha(e);if(i){const e=t?this.getNonSymbolLayers():this.getLayers();Wa(i,e,this.mapLibreMap,this.originalFilters)}}else this.config?.filters?.any?.length&&Wa(void 0,this.getLayers(),this.mapLibreMap,this.originalFilters);if(t?.any?.length){const e=Ha(t);e&&Wa(e,this.getSymbolLayers(),this.mapLibreMap,this.originalFilters)}}r&&(this.config=a({...this.config,filters:e,icons:{...this.config?.icons,filters:t}},i),this.emitConfigChange())}getLayers(){return ne(this.tomtomMap.mapLibreMap,[Ue])}getSymbolLayers(){return this.getLayers().filter(e=>"symbol"===e.type)}getNonSymbolLayers(){return this.getLayers().filter(e=>"symbol"!=e.type)}setIconsVisible(e){this._setIconsVisible(e)}_setIconsVisible(e,t=!0){this.tomtomMap.mapReady&&this.sourcesWithLayers.trafficIncidents.setLayersVisible(e,e=>"symbol"===e.type),t&&(this.config={...this.config,icons:{...this.config?.icons,visible:e}},this.emitConfigChange())}setVisible(e){this._setVisible(e)}_setVisible(t,i){(i?.updateConfig??1)&&(delete this.config?.icons?.visible,this.config={...a({...this.config},e),visible:t},this.emitConfigChange()),this.tomtomMap.mapReady&&this.sourcesWithLayers.trafficIncidents.setLayersVisible(t)}isVisible(){return this.sourcesWithLayers.trafficIncidents.isAnyLayerVisible()}anyIconLayersVisible(){return this.sourcesWithLayers.trafficIncidents?.isAnyLayerVisible(e=>"symbol"===e.type)}getShown(){return{trafficIncidents:this.mapLibreMap.queryRenderedFeatures({layers:this.sourcesWithLayers.trafficIncidents.sourceAndLayerIDs.layerIDs,validate:!1}).map(z)}}get events(){return this.moduleEvents(["trafficIncidents"],{mapping:z})}},Lo=["motorway","motorway_link","trunk","trunk_link","primary","primary_link","secondary","secondary_link","tertiary","tertiary_link","street","service","track"],Ao=["unclassified","residential","living_street"],So=["parking","driveway","alley"],Io=(e,t)=>({left:e.left-t.left,top:e.top-t.top,right:e.right-t.left,bottom:e.bottom-t.top}),Eo=(e,t,i)=>e.right<=0||e.left>=t||e.bottom<=0||e.top>=i,bo=(e,t,i,r)=>{e.top<=i-e.bottom?t.top=Math.max(t.top,e.bottom+r):t.bottom=Math.min(t.bottom,e.top-r)},Ro=(e,t,i,r)=>{e.left<=i-e.right?t.left=Math.max(t.left,e.right+r):t.right=Math.min(t.right,e.left-r)},To=(e,t,i,r,s)=>{const a=((e,t,i)=>({left:Math.max(0,e.left),top:Math.max(0,e.top),right:Math.min(t,e.right),bottom:Math.min(i,e.bottom)}))(e,i,r),o=e.left<=0&&e.right>=i,n=e.top<=0&&e.bottom>=r;if(o&&!n)return void bo(a,t,r,s);if(n&&!o)return void Ro(a,t,i,s);const l=e.left<=0,c=e.right>=i,h=e.top<=0,u=e.bottom>=r;!l&&!c||h||u?!h&&!u||l||c?((e,t,i,r,s)=>{const a=e.left,o=i-e.right,n=e.top,l=r-e.bottom,c=Math.min(a,o,n,l);c===a?t.left=Math.max(t.left,e.right+s):c===o?t.right=Math.min(t.right,e.left-s):c===n?t.top=Math.max(t.top,e.bottom+s):t.bottom=Math.min(t.bottom,e.top-s)})(a,t,i,r,s):Ro(a,t,i,s):bo(a,t,r,s)},Co=e=>"string"==typeof e?document.querySelector(e):e,vo=e=>"mapLibreMap"in e?e.mapLibreMap:e,Oo=(e,t,i)=>{const r=vo(e).getContainer().getBoundingClientRect(),{width:s,height:a}=r,o={left:i,top:i,right:s-i,bottom:a-i};for(const n of t){const e=Co(n);if(!e)continue;const t=e.getBoundingClientRect(),l=Io(t,r);Eo(l,s,a)||To(l,o,s,a,i)}return o.left>=o.right||o.top>=o.bottom?null:{visibleAreaBounds:o,mapWidthPX:s,mapHeightPX:a}},wo=e=>{const{map:t,surroundingElements:i,paddingPX:r=0}=e,s=Oo(t,i,r);if(!s)return null;const{visibleAreaBounds:a}=s,o=vo(t),n=o.unproject([a.left,a.bottom]),l=o.unproject([a.right,a.top]);return[n.lng,n.lat,l.lng,l.lat]},No=e=>{const{map:t,surroundingElements:i}=e,r=wo({map:t,surroundingElements:i});if(!r)return null;const[s,a,o,n]=r;return[(s+o)/2,(a+n)/2]},Mo=e=>{const{map:t,toBeContainedBBox:i,surroundingElements:r,paddingPX:s=0}=e,a=Oo(t,r,s);if(!a)return null;const{visibleAreaBounds:o,mapWidthPX:n,mapHeightPX:l}=a,c=o.left/n,h=o.right/n,u=o.top/l,d=h-c,p=o.bottom/l-u,[f,y,m,g]=i,_=(m-f)/d,L=(g-y)/p,A=f-c*_,S=g+u*L;return[A,S-L,A+_,S]};export{be as AbstractMapModule,oe as AbstractSourceWithLayers,ce as AddedSourceWithLayers,Pe as BASE_MAP_SOURCE_ID,Si as BaseMapModule,D as CombinedEvents,Ei as CustomGeoJSONModule,sr as DESELECTED_FOREGROUND_COLOR,ar as DESELECTED_OUTLINE_COLOR,cr as DESELECTED_ROUTE_FILTER,or as DESELECTED_SECONDARY_COLOR,Me as EventsProxy,gs as FINISH_INDEX,ue as GeoJSONSourceWithLayers,Ui as GeometriesModule,Fe as HILLSHADE_SOURCE_ID,ji as HillshadeModule,wr as INDEFINITE_DELAY_DASH_COLOR,Er as MAJOR_DELAY_COLOR,ms as MIDDLE_INDEX,Rr as MINOR_DELAY_COLOR,Tr as MINOR_DELAY_LABEL_COLOR,br as MODERATE_DELAY_COLOR,W as ModuleEvents,De as POI_SOURCE_ID,yi as POIsModule,ai as PlacesModule,ir as ROUTE_LINE_FOREGROUND_COLOR,nr as ROUTE_LINE_FOREGROUND_WIDTH,rr as ROUTE_LINE_OUTLINE_COLOR,hr as ROUTE_LINE_OUTLINE_WIDTH,Qs as RoutingModule,lr as SELECTED_ROUTE_FILTER,ys as START_INDEX,_s as STOP_DISPLAY_INDEX,le as StyleSourceWithLayers,He as TRAFFIC_FLOW_SOURCE_ID,Ue as TRAFFIC_INCIDENTS_SOURCE_ID,aa as TomTomMap,ae as TomTomMapSource,Ma as TrafficAreaAnalyticsModule,Ga as TrafficFlowModule,go as TrafficIncidentOverlayModule,_o as TrafficIncidentsModule,vr as UNKNOWN_DELAY_BG_COLOR,Cr as UNKNOWN_DELAY_COLOR,Or as UNKNOWN_DELAY_DASH_COLOR,Ee as UserEvents,k as assertNoReservedScopeNames,mi as baseMapLayerGroupNames,ze as baseMapPOICategoryValues,Kt as buildPlaceTitle,ki as buildReachableRangeFeatures,Os as buildRoutingLayers,Mo as calculateFittingBBox,wo as calculatePaddedBBox,No as calculatePaddedCenter,Di as colorPaletteIDs,xi as colorPalettes,P as combineEventScopes,ws as defaultRoutingLayers,ne as filterLayersBySources,se as findFeatureByRefId,Vi as geometryThemes,Zt as getIconIDForPlace,Sr as getInstructionLineWidth,Ir as getInstructionOutlineWidth,fr as getLineForegroundWidth,yr as getLineOutlineWidth,ei as getPOIGroupForPlace,Qt as getPOILayerCategoryForPlace,fi as getStyleCategories,_r as getTollRoadOutlineWidth,mr as getWaypointIconSize,Be as mapDisplayPoiCategoryMappings,xe as mapStyleLayerIDs,oi as placesThemes,di as poiCategoryGroups,Ge as poiLayerIDs,si as preparePlacesForDisplay,Wi as prepareReachableRangesForDisplay,Bi as reachableRangeGeometryConfig,re as renderedRefId,H as reservedScopeNames,ua as resolveColorStops,Lo as roadCategories,U as scopedLayerSpecs,So as serviceRoadSubCategories,We as sharedInstance,zi as standardStyleIDs,Ao as streetRoadSubCategories,$i as styleModules,Gi as themedGeometryConfig,je as toBaseMapPOICategory,Ye as toBaseMapPOIGroup,ti as toPlaces};
|
|
1
|
+
import{isEmpty as e,isEqual as t,isNil as i,mapValues as r,omit as s,omitBy as a,remove as o}from"lodash-es";import{DEFAULT_COMMON_BASE_URL as n,TomTomConfig as l,bboxCenter as c,bboxFromCoordsArray as h,bboxFromGeoJSON as u,formatDistance as d,formatDuration as p,generateId as f,generateTomTomHeaders as y,getPosition as m,iconToTrafficIncidentCategory as g,indexedMagnitudes as _,isProxyCredentialsMode as L,mergeFromGlobal as S,poiCategoriesToID as A}from"@tomtom-org/maps-sdk/core";import{bearing as I,booleanPointInPolygon as E,difference as b,featureCollection as R,hexGrid as T,mask as C,squareGrid as v}from"@turf/turf";import{Map as w,getRTLTextPluginStatus as O,getVersion as N,setRTLTextPlugin as M,setWorkerCount as D}from"maplibre-gl";var x=class{constructor(e,t){this.userEventsInstance=e,this.moduleEventsInstance=t}where(e,t){return this.userEventsInstance.where(e,t)}on(e,t){return"config-change"===e?this.moduleEventsInstance.on("config-change",t):"shown-features"===e?this.moduleEventsInstance.on("shown-features",t):this.userEventsInstance.on(e,t)}off(e){"config-change"===e||"shown-features"===e?this.moduleEventsInstance.off(e):this.userEventsInstance.off(e)}},F=(e,t)=>e?t?(...i)=>e(...i)&&t(...i):e:t,P=(e,t)=>{if(!e)return t;if(!t)return e;const i=F(e.layerFilter,t.layerFilter),r=F(e.featureMatches,t.featureMatches);return i||r?{layerFilter:i,featureMatches:r}:void 0},U=(e,t)=>t?.layerFilter?e._layerSpecs.filter(t.layerFilter):e._layerSpecs,H=["on","off","where"],k=(e,t)=>{const i=e.find(e=>H.includes(e));if(i)throw new Error(`${t} uses the reserved event scope name "${i}". Reserved: ${H.join(", ")}.`)},W=class{constructor(e,t){this.configChangeHandlers=e,this.shownFeaturesHandlers=t}on(e,t){if("config-change"===e){const e=t;return this.configChangeHandlers.push(e),()=>{const t=this.configChangeHandlers.indexOf(e);-1!==t&&this.configChangeHandlers.splice(t,1)}}const i=t;return this.shownFeaturesHandlers.push(i),()=>{const e=this.shownFeaturesHandlers.indexOf(i);-1!==e&&this.shownFeaturesHandlers.splice(e,1)}}off(e){"config-change"===e?this.configChangeHandlers.length=0:this.shownFeaturesHandlers.length=0}},G=["road_category","road_subcategory","relative_speed","left_hand_traffic","road_closure","absolute_speed","part_of_two_way_road","openlr","display_class"],B=e=>{const{properties:t}=e;return{id:e.id,type:e.type,geometry:e.geometry,properties:{roadCategory:t?.road_category,leftHandTraffic:Boolean(t?.left_hand_traffic),roadClosure:Boolean(t?.road_closure),relativeSpeed:t?.relative_speed,...t?.road_subcategory&&{roadSubcategory:t.road_subcategory},...t?.absolute_speed&&{absoluteSpeed:t.absolute_speed},...t?.part_of_two_way_road&&{partOfTwoWayRoad:Boolean(t.part_of_two_way_road)},...t?.openlr&&{openlr:t.openlr},...t?.display_class&&{displayClass:t.display_class}}}},V=["icon_category","left_hand_traffic","magnitude_of_delay","road_category","road_subcategory","id","description","delay","part_of_two_way_road","start_time","end_time","probability_of_occurrence","number_of_reports","last_report_time","average_speed_kmph","openlr","time_validity","display_class"],j={other:0,accident:1,fog:2,danger:3,rain:4,frost:5,jam:6,"lane-closed":7,"road-closed":8,roadworks:9,wind:10,flooding:11,"animals-on-road":12,"narrow-lanes":13,"broken-down-vehicle":14},$=e=>{const{properties:t}=e;return{id:e.id,type:e.type,geometry:e.geometry,properties:{id:t.id??f(),description:t?.description_0??"",category:g(t?.icon_category_0),magnitudeOfDelay:_[t?.magnitude_of_delay],roadCategory:t?.road_category,roadSubcategory:t?.road_subcategory,leftHandTraffic:Boolean(t?.left_hand_traffic),...t?.delay&&{delayInSeconds:t.delay},...t?.part_of_two_way_road&&{partOfTwoWayRoad:Boolean(t.part_of_two_way_road)},...t?.start_time&&{startTime:new Date(t.start_time)},...t?.end_time&&{endTime:new Date(t.end_time)},...t?.probability_of_occurrence&&{probabilityOfOccurrence:t.probability_of_occurrence},...t?.number_of_reports&&{numberOfReports:t.number_of_reports},...t?.last_report_time&&{lastReportTime:new Date(t.last_report_time)},...t?.average_speed_kmph&&{averageSpeedKmph:t.average_speed_kmph},...t?.openlr&&{openlr:t.openlr},...t?.time_validity&&{timeValidity:t.time_validity},...t?.display_class&&{displayClass:t.display_class},...t?.point_type&&{pointType:t.point_type}}}},z=(e,t,i)=>Math.min(Math.max(t,e),i),Y=e=>!e.some(Number.isNaN),q=e=>Number.parseInt(e.padEnd(2,e),16)/255,K=(e,t)=>z(t?e/100:e,0,1),X=/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,/])\s*([\de.+-]+)(%)?)?\s*\)$/,Z=/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,/])\s*([\de.+-]+)(%)?)?\s*\)$/,J=e=>{const t=Z.exec(e);if(!t)return;const[,i,r,s,a,o,n,l,c]=t,h=[r||" ",a||" ",n].join("");if(" "!==h&&" /"!==h&&",,"!==h&&",,,"!==h)return;const u=[+i,z(+s,0,100),z(+o,0,100),l?K(+l,c):1];return Y(u)?(([e,t,i,r])=>{const s=(e=>{const t=e%360;return t<0?t+360:t})(e),a=t/100,o=i/100,n=e=>{const t=(e+s/30)%12,i=a*Math.min(o,1-o);return o-i*Math.max(-1,Math.min(t-3,9-t,1))};return[n(0),n(8),n(4),r]})(u):void 0},Q=e=>{const t=e.toLowerCase().trim();if("transparent"===t)return[0,0,0,0];const i=ie[t];if(i){const[e,t,r]=i;return[e/255,t/255,r/255,1]}return t.startsWith("#")?(e=>{if(!/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/.test(e))return;const t=e.length<6?1:2;return[q(e.slice(1,1+t)),q(e.slice(1+t,1+2*t)),q(e.slice(1+2*t,1+3*t)),q(e.slice(1+3*t)||"ff")]})(t):t.startsWith("rgb")?(e=>{const t=X.exec(e);if(!t)return;const[,i,r,s,a,o,n,l,c,h,u,d]=t,p=[s||" ",n||" ",h].join("");if(" "!==p&&" /"!==p&&",,"!==p&&",,,"!==p)return;const f=[r,o,c].join(""),y="%%%"===f?100:""===f?255:0;if(!y)return;const m=[z(+i/y,0,1),z(+a/y,0,1),z(+l/y,0,1),u?K(+u,d):1];return Y(m)?m:void 0})(t):J(t)},ee=e=>{const t=Q(e);if(!t)return;const i=e=>e<=.03928?e/12.92:((e+.055)/1.055)**2.4;return.2126*i(t[0])+.7152*i(t[1])+.0722*i(t[2])},te=(e,t)=>{const i=Q(e);if(!i)return;const r=1-t;return`#${[Math.round(255*i[0]*r),Math.round(255*i[1]*r),Math.round(255*i[2]*r)].map(e=>e.toString(16).padStart(2,"0")).join("")}`},ie={aliceblue:[240,248,255],antiquewhite:[250,235,215],aqua:[0,255,255],aquamarine:[127,255,212],azure:[240,255,255],beige:[245,245,220],bisque:[255,228,196],black:[0,0,0],blanchedalmond:[255,235,205],blue:[0,0,255],blueviolet:[138,43,226],brown:[165,42,42],burlywood:[222,184,135],cadetblue:[95,158,160],chartreuse:[127,255,0],chocolate:[210,105,30],coral:[255,127,80],cornflowerblue:[100,149,237],cornsilk:[255,248,220],crimson:[220,20,60],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgoldenrod:[184,134,11],darkgray:[169,169,169],darkgreen:[0,100,0],darkgrey:[169,169,169],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkseagreen:[143,188,143],darkslateblue:[72,61,139],darkslategray:[47,79,79],darkslategrey:[47,79,79],darkturquoise:[0,206,209],darkviolet:[148,0,211],deeppink:[255,20,147],deepskyblue:[0,191,255],dimgray:[105,105,105],dimgrey:[105,105,105],dodgerblue:[30,144,255],firebrick:[178,34,34],floralwhite:[255,250,240],forestgreen:[34,139,34],fuchsia:[255,0,255],gainsboro:[220,220,220],ghostwhite:[248,248,255],gold:[255,215,0],goldenrod:[218,165,32],gray:[128,128,128],green:[0,128,0],greenyellow:[173,255,47],grey:[128,128,128],honeydew:[240,255,240],hotpink:[255,105,180],indianred:[205,92,92],indigo:[75,0,130],ivory:[255,255,240],khaki:[240,230,140],lavender:[230,230,250],lavenderblush:[255,240,245],lawngreen:[124,252,0],lemonchiffon:[255,250,205],lightblue:[173,216,230],lightcoral:[240,128,128],lightcyan:[224,255,255],lightgoldenrodyellow:[250,250,210],lightgray:[211,211,211],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightsalmon:[255,160,122],lightseagreen:[32,178,170],lightskyblue:[135,206,250],lightslategray:[119,136,153],lightslategrey:[119,136,153],lightsteelblue:[176,196,222],lightyellow:[255,255,224],lime:[0,255,0],limegreen:[50,205,50],linen:[250,240,230],magenta:[255,0,255],maroon:[128,0,0],mediumaquamarine:[102,205,170],mediumblue:[0,0,205],mediumorchid:[186,85,211],mediumpurple:[147,112,219],mediumseagreen:[60,179,113],mediumslateblue:[123,104,238],mediumspringgreen:[0,250,154],mediumturquoise:[72,209,204],mediumvioletred:[199,21,133],midnightblue:[25,25,112],mintcream:[245,255,250],mistyrose:[255,228,225],moccasin:[255,228,181],navajowhite:[255,222,173],navy:[0,0,128],oldlace:[253,245,230],olive:[128,128,0],olivedrab:[107,142,35],orange:[255,165,0],orangered:[255,69,0],orchid:[218,112,214],palegoldenrod:[238,232,170],palegreen:[152,251,152],paleturquoise:[175,238,238],palevioletred:[219,112,147],papayawhip:[255,239,213],peachpuff:[255,218,185],peru:[205,133,63],pink:[255,192,203],plum:[221,160,221],powderblue:[176,224,230],purple:[128,0,128],rebeccapurple:[102,51,153],red:[255,0,0],rosybrown:[188,143,143],royalblue:[65,105,225],saddlebrown:[139,69,19],salmon:[250,128,114],sandybrown:[244,164,96],seagreen:[46,139,87],seashell:[255,245,238],sienna:[160,82,45],silver:[192,192,192],skyblue:[135,206,235],slateblue:[106,90,205],slategray:[112,128,144],slategrey:[112,128,144],snow:[255,250,250],springgreen:[0,255,127],steelblue:[70,130,180],tan:[210,180,140],teal:[0,128,128],thistle:[216,191,216],tomato:[255,99,71],turquoise:[64,224,208],violet:[238,130,238],wheat:[245,222,179],white:[255,255,255],whitesmoke:[245,245,245],yellow:[255,255,0],yellowgreen:[154,205,50]},re=e=>/* @__PURE__ */new Error(`Trying to ${e} while it is not in the map style. Did you exclude it when loading the map?`),se="pinCategories",ae=e=>`${se}:${e}`,oe=()=>"undefined"!=typeof document&&"undefined"!=typeof DOMParser&&"undefined"!=typeof btoa,ne=e=>{if(!oe())return;const t=document.createElement("img");return t.src=`data:image/svg+xml;base64,${btoa((new XMLSerializer).serializeToString(e))}`,t},le=e=>(new DOMParser).parseFromString(e,"image/svg+xml").documentElement,ce=e=>((e,t)=>(t?.fillColor&&e.querySelector("#background")?.setAttribute("fill",t.fillColor),t?.outlineColor&&e.querySelector("#outline")?.setAttribute("fill",t.outlineColor),void 0!==t?.outlineOpacity&&e.querySelector("#outline")?.setAttribute("fill-opacity",t.outlineOpacity.toString()),e))(le('<svg xmlns="http://www.w3.org/2000/svg" width="120" height="140">\n <path id="background" d="M63.95 137.516c6.556-12.737 19.098-21.09 30.828-29.388C110.046 97.324 120 79.603 120 59.574 120 26.671 93.138 0 60 0S0 26.671 0 59.574c0 20.029 9.954 37.75 25.22 48.55 11.734 8.302 24.274 16.652 30.83 29.388 1.706 3.316 6.194 3.316 7.9 0z"\n fill="#1988cf"/>\n <path id="outline" d="M91.298 103.272C105.052 93.544 114 77.596 114 59.574c0-29.61-24.176-53.617-54-53.617S6 29.964 6 59.574c0 18.022 8.95 33.97 22.7 43.698l2.27 1.601c10.172 7.153 21.922 15.423 29.03 27.416 7.104-11.993 18.858-20.259 29.03-27.416l2.268-1.601zm1.468 6.274c-11.13 7.845-22.632 15.957-28.816 27.966-1.706 3.316-6.194 3.316-7.9 0-6.182-12.009-17.686-20.121-28.816-27.966l-2.016-1.422C9.954 97.324 0 79.603 0 59.574 0 26.671 26.862 0 60 0s60 26.671 60 59.574c0 20.029-9.954 37.75-25.222 48.55l-2.016 1.422z"\n fill-opacity=".3"/>\n</svg>\n'),e),he=async e=>{e.mapReady||(await e.mapLibreMap.once("styledata"),await he(e))},ue=e=>{const t=globalThis.__DEMOS_PROXY_ENSURE_SESSION__;return"function"!=typeof t?e:t().then(()=>e,()=>e)},de=e=>{const t=e.commonBaseURL??n,i=t!==n,r=L(e);return(s,a)=>{const o=((e,t,i,r)=>{if(!i)return e;try{const i=new URL(e);return"api.tomtom.com"===(s=i.hostname)||s.endsWith(".api.tomtom.com")?(r&&i.searchParams.delete("key"),t+i.pathname+i.search+i.hash):e}catch{return e}var s})(s,t,i,r),n=i&&o.startsWith(t),l=r&&n;let c=!1;try{const e=new URL(s).hostname;c="tomtom.com"===e||e.endsWith(".tomtom.com")}catch{c=!1}if(!c&&!n)return{url:o};if("Image"===a)return l?ue({url:o,credentials:"include"}):{url:o};const h=new URL(o);(e=>{e.pathname.includes("incidents")?e.searchParams.set("tags",V.join(",")):e.pathname.includes("flow")&&e.searchParams.set("tags",G.join(","))})(h);const u={url:h.toString(),headers:{...y(e)}};return l?(u.credentials="include",ue(u)):u}},pe=(e,t,i)=>{const r=e.id;e.maxzoom===t.maxzoom&&e.minzoom===t.minzoom||i.setLayerZoomRange(r,e.minzoom??i.getMinZoom(),e.maxzoom??i.getMaxZoom()),i.setFilter(r,e.filter,{validate:!1});for(const s of Object.keys(t.layout??{}))e.layout?.[s]||i.setLayoutProperty(r,s,void 0,{validate:!1});for(const s of Object.keys(t.paint??{}))e.paint?.[s]||i.setPaintProperty(r,s,void 0,{validate:!1});for(const[s,a]of Object.entries(e.paint??{}))i.setPaintProperty(r,s,a,{validate:!1});for(const[s,a]of Object.entries(e.layout??{}))i.setLayoutProperty(r,s,a,{validate:!1})},fe=(e,t,i,r)=>{const s=e.reduce((e,t)=>({...e,[t.id]:t}),{}),a=t.reduce((e,t)=>({...e,[t.id]:t}),{}),o=[],n=[],l=[],c=[];Object.keys(s).forEach(e=>{a[e]?(l.push(s[e]),c.push(a[e])):o.push(e)}),Object.keys(a).forEach(e=>{s[e]||n.push(e)});const h=i._layerSpecs;n.forEach(e=>{r.removeLayer(e);for(let t=0;t<h.length;t++)if(h[t].id===e){h.splice(t,1);break}}),o.forEach(e=>{const t={...s[e],source:i.source.id};h.push(t)}),i._updateSourceAndLayerIDs(),((e,t,i)=>{e.forEach((e,r)=>pe(e,t[r],i))})(l,c,r)},ye=(e,t)=>t&&e.getLayer(t)?t:void 0,me=(e,t,i)=>{e.moveLayer(t,ye(e,i))},ge=(e,t)=>{const i=/* @__PURE__ */new Set,r=e=>{t.getLayer(e.id)||t.addLayer({...e,layout:{...e.layout,visibility:"none"}},e.beforeID),i.add(e.id)},s={};for(e.forEach(e=>{e.beforeID?i.has(e.beforeID)||t.getLayer(e.beforeID)?(i.add(e.beforeID),r(e)):s[e.beforeID]?s[e.beforeID].push(e):s[e.beforeID]=[e]:r(e)});Object.keys(s).length>0;){const e=Object.keys(s).filter(e=>i.has(e));if(!e.length)return void console.error(`Some layers cannot be added. Check for non-existing layers, or circular beforeID dependencies for the following: ${JSON.stringify(Object.keys(s))}`);e.forEach(e=>{s[e].forEach(e=>r(e)),delete s[e]})}},_e=(e,t)=>{switch(typeof e){case"undefined":return{type:"standard",include:[t]};case"string":return{type:"standard",id:e,include:[t]};default:if("standard"===e.type)return e.include?{...e,include:[...e.include,t]}:{...e,include:[t]};throw(e=>/* @__PURE__ */new Error(`The custom map style has no '${e}' part and the SDK cannot add one to it. Style-owned modules work on a custom style only when it already ships the matching source (e.g. built with Map Maker with that part enabled) — or switch to a standard style.`))(t)}},Le=async(e,t,i)=>{if(!e.mapLibreMap.getSource(t)){const r=e.mapLibreMap;r.isStyleLoaded()||await r.once("idle"),await e.setStyle(_e(e.getStyle(),i)),await(async(e,t)=>{e.mapLibreMap.getSource(t)&&e.mapLibreMap.isSourceLoaded(t)||await e.mapLibreMap.once("sourcedata")})(e,t)}},Se=async(e,t,i,r,s)=>{if(!i)return void console.warn(`addOrUpdateImage called with empty image for ID ${t}`);const a=i=>{const a=r.hasImage(t);a&&"add-or-update"==e?r.updateImage(t,i):a||r.addImage(t,i,s)},o=e=>{e.complete?e.naturalWidth>0?a(e):console.warn(`Failed to load image for ID ${t}`):(e.onload=()=>a(e),e.onerror=()=>console.warn(`Failed to load image for ID ${t}`))};if("string"==typeof i)if(i.includes("<svg"))o(ne(le(i)));else try{a((await r.loadImage(i)).data)}catch(n){console.warn(`Failed to load image for ID ${t}`,n)}else o(i)},Ae=e=>{switch(e){case"standardDark":case"drivingDark":case"monoDark":case"satellite":return"dark";default:return"light"}},Ie=e=>{if("string"==typeof e)return Ae(e);const t=Ee(e);if(t)return t;const i=e;return i?.id?Ae(i.id):"light"},Ee=e=>be(e)?e.lightDarkTheme:void 0,be=e=>"object"==typeof e&&"custom"===e?.type,Re=e=>{if("string"==typeof e)return void 0===ee(e)?void 0:e;if(Array.isArray(e))for(const t of e){const e=Re(t);if(e)return e}},Te=class e{constructor(e){this.options=e,this.sources=e.sourcesWithLayers}where(t,i){return new e({...this.options,config:i??this.options.config,scope:P(this.options.scope,this.resolveScope(t))})}resolveScope(e){if("function"==typeof e){const t=e,i=this.options.mapping;return{featureMatches:i?e=>t(i(e)):e=>t(e)}}const t=this.options.scopeResolver;if(!t)throw new Error("This module supports only feature predicates in events.where().");return t(e)}on(e,t){const{eventProxy:i,config:r,owner:s,scope:a}=this.options,o=this.toRegisteredHandler(t),n=[];for(const l of this.sources)i.addEventHandler(l,o,e,{config:r,owner:s,scope:a}),n.push(l);return()=>{for(const t of n)i.removeHandler(t,e,o)}}toRegisteredHandler(e){const{mapping:t,scope:i}=this.options,r=i?.featureMatches;if(!t&&!r)return e;const s=e=>t?t(e):e;return r?(t,i,a,o)=>{const n=(a.length?a:[t]).filter(e=>r(e));if(!n.length)return;const l=n.map(s);e(l[0],i,l,o)}:(t,i,r,a)=>e(s(t),i,r.map(s),a)}off(e){for(const t of this.sources)this.options.eventProxy.remove(t,e,this.options.owner)}},Ce=class e{static{this.instanceCounters=/* @__PURE__ */new WeakMap}constructor(t,i){this._initializing=!0,this.configChangeHandlers=[],this.moduleReady=!1;const r=new.target,s=e.instanceCounters.get(r)??-1;this.instanceIndex=s+1,e.instanceCounters.set(r,this.instanceIndex),this.tomtomMap=t,this.eventsProxy=t._eventsProxy,this.mapLibreMap=t.mapLibreMap,this.initSourcesWithLayers(i),this.applyConfig(i),this.tomtomMap.addStyleChangeHandler({onStyleAboutToChange:()=>{this.moduleReady=!1},onStyleChanged:({resetState:e})=>e?this.resetOnNewStyle():this.restoreDataAndConfig()}),this._initializing=!1}initSourcesWithLayers(e,t){this.moduleReady=!1,this.sourcesWithLayers=this._initSourcesWithLayers(e,t),this._sourceAndLayerIDs=Object.fromEntries(Object.entries(this.sourcesWithLayers).map(([e,t])=>[e,t.sourceAndLayerIDs])),t&&this.eventsProxy.updateIfRegistered(this.sourcesWithLayers,this),this.tomtomMap.mapReady&&(this.moduleReady=!0)}async waitUntilModuleReady(){await he(this.tomtomMap),this.moduleReady||await new Promise(e=>{const t=setInterval(()=>{this.tomtomMap.mapReady&&this.moduleReady&&(clearInterval(t),e())},200)})}applyConfig(e){this.config=this._applyConfig(e),this.emitConfigChange()}emitConfigChange(){if(!this._initializing)for(const e of this.configChangeHandlers)e(this.config)}resetConfig(){this.applyConfig(void 0)}restoreDataAndConfig(){this.moduleReady=!1,this.restoreDataAndConfigImpl()}resetOnNewStyle(){this.moduleReady=!1,this.config=void 0,this.discardShownData(),this.initSourcesWithLayers(void 0,!0),this._applyConfig(void 0),this.emitConfigChange()}discardShownData(){}restoreDataAndConfigImpl(){this.initSourcesWithLayers(this.config,!0),this._applyConfig(this.config)}getConfig(){return this.config&&{...this.config}}get sourceAndLayerIDs(){return this._sourceAndLayerIDs}userEvents(e,t={}){return new Te({eventProxy:this.eventsProxy,sourcesWithLayers:e.map(e=>this.sourcesWithLayers[e]).filter(e=>!!e),owner:this,config:this.config?.events,mapping:t.mapping,scopeResolver:t.scopeResolver})}moduleEvents(e,t={}){return new x(this.userEvents(e,t),new W(this.configChangeHandlers,[]))}moduleEventsWithShown(e,t,i={}){return new x(this.userEvents(e,i),new W(this.configChangeHandlers,t))}buildEvents(e,t){return k(Object.keys(t),this.constructor.name),Object.assign(e,t)}},ve=class extends Ce{},we=class extends Ce{},Oe=class{constructor(){this.interactiveLayerIDs=[],this.handlers={click:{},contextmenu:{},hover:{},"hover-move":{},"long-hover":{}},this.findHandlers=(e,t,i)=>t&&e.flatMap(e=>{const r=this.handlers[e][t]??[];return i?r.filter(e=>!e.scope?.featureMatches||e.scope.featureMatches(i)):r})||[]}ensureInteractiveLayerIDsAdded(e){for(const t of e)this.interactiveLayerIDs.includes(t)||this.interactiveLayerIDs.push(t)}releaseUnusedInteractiveLayerIDs(e){o(this.interactiveLayerIDs,t=>e.has(t)&&!this.hasHandlerForLayer(t))}indexHandler(e,t){const i=this.handlers[t];for(const r of e.layerIDs)i[r]??=[],i[r].push(e)}unindexHandlers(e,t){const i=this.handlers[t],r=/* @__PURE__ */new Set;for(const s of e)for(const t of s.layerIDs){r.add(t);const s=i[t];s&&(o(s,t=>e.has(t)),s.length||delete i[t])}return r}dropHandlers(e,t,i){const r=e.source.id,s=/* @__PURE__ */new Set;for(const a of Object.values(this.handlers[t]))for(const e of a)e.sourceWithLayers.source.id===r&&i(e)&&s.add(e);s.size&&this.releaseUnusedInteractiveLayerIDs(this.unindexHandlers(s,t))}addEventHandler(e,t,i,r){const s=new Set(U(e,r.scope).map(e=>e.id));this.ensureInteractiveLayerIDsAdded(s),this.indexHandler({...r,sourceWithLayers:e,layerIDs:s,fn:t},i)}removeHandler(e,t,i){this.dropHandlers(e,t,e=>e.fn===i)}remove(e,t,i){this.dropHandlers(e,t,e=>e.owner===i)}removeAll(){this.interactiveLayerIDs=[],this.handlers={click:{},contextmenu:{},hover:{},"hover-move":{},"long-hover":{}}}hasHandlerForLayer(e){return Object.values(this.handlers).some(t=>!!t[e]?.length)}sourceWithLayersFor(e){if(e)for(const t of Object.values(this.handlers)){const i=t[e];if(i?.length)return i[0].sourceWithLayers}}updateIfRegistered(e,t){const i=new Map(Object.values(e).map(e=>[e.source.id,e]));for(const r of Object.keys(this.handlers)){const e=/* @__PURE__ */new Set;for(const a of Object.values(this.handlers[r]))for(const r of a)r.owner===t&&i.has(r.sourceWithLayers.source.id)&&e.add(r);if(!e.size)continue;const s=this.unindexHandlers(e,r);for(const t of e){const e=i.get(t.sourceWithLayers.source.id);t.sourceWithLayers=e,t.layerIDs=new Set(U(e,t.scope).map(e=>e.id)),this.ensureInteractiveLayerIDsAdded(t.layerIDs),this.indexHandler(t,r)}this.releaseUnusedInteractiveLayerIDs(s)}}},Ne=e=>{const t=e.properties?.id;return"string"==typeof t||"number"==typeof t?t:e.id},Me=(e,t)=>{if(null!=t)for(let i=0;i<e.length;i++)if(Ne(e[i])===t)return{feature:e[i],index:i}};var De,xe,Fe,Pe=e=>(function(e){if(i(e))throw new Error(`${e} must not be null/undefined. Something went wrong with its initialization.`)}(e),e),Ue=class{constructor(e,t,i){this.id=e,this.spec=t,this.runtimeSource=i}ensureAddedToMap(e){this.runtimeSource||(!e.getSource(this.id)&&this.spec&&e.addSource(this.id,this.spec),this.runtimeSource=e.getSource(this.id))}},He=class{constructor(e,t,i){this.map=e,this.source=t,this._layerSpecs=i,this._updateSourceAndLayerIDs()}get mapRemoved(){return!0===this.map._removed}isAnyLayerVisible(e){return this.getLayerSpecs(e).some(e=>this.isLayerVisible(e))}areAllLayersVisible(e){return this.getLayerSpecs(e).every(e=>this.isLayerVisible(e))}getLayerSpecs(e){return e?this._layerSpecs.filter(e):this._layerSpecs}_updateSourceAndLayerIDs(){this._sourceAndLayerIDs={sourceID:this.source.id,layerIDs:this._layerSpecs.map(e=>e.id)}}isLayerVisible(e){return!this.mapRemoved&&(!!this.map.getLayer(e.id)&&"none"!==this.map.getLayoutProperty(e.id,"visibility"))}setLayersVisible(e,t){if(!this.mapRemoved)for(const i of this.getLayerSpecs(t))this.map.getLayer(i.id)&&this.map.setLayoutProperty(i.id,"visibility",e?"visible":"none",{validate:!1})}get sourceAndLayerIDs(){return this._sourceAndLayerIDs}},ke=(e,t)=>e.getStyle().layers.filter(e=>t.includes(e?.source)),We=class extends He{constructor(e,t,i){let r=ke(e,[t.id]);i&&(r=r.filter(i)),super(e,new Ue(t.id,e.getStyle().sources[t.id],t),r)}},Ge=class extends He{constructor(e,t,i,r){super(e,new Ue(t,i),r.map(e=>({...e,source:t})))}ensureLayersAddedToMap(){if(!this.mapRemoved)for(const e of this._layerSpecs)this.map.getLayer(e.id)||this.map.addLayer(e,e.beforeID)}ensureAddedToMapWithVisibility(e,t){this.mapRemoved||(this.source.ensureAddedToMap(this.map),t&&(this.ensureLayersAddedToMap(),this.setLayersVisible(e)))}},Be={type:"FeatureCollection",features:[]},Ve=class extends Ge{constructor(e,t,i,r=!0,s){super(e,t,s?.cluster?{type:"geojson",data:Be,...s}:{type:"geojson",data:Be,promoteId:"id",...s??{}},i),this.shownFeatures=Be,this.ensureAddedToMapWithVisibility(!1,r)}show(e,{automaticVisibility:t=!0}={}){this.shownFeatures=e,this.mapRemoved||(Pe(this.source.runtimeSource).setData(e),t&&this.setLayersVisible(!!e.features.length))}findById(e){return Me(this.shownFeatures.features,e)}clear(){this.show(Be)}findFeature(e){return"index"in e?this.shownFeatures.features[e.index]:"id"in e?this.findById(e.id)?.feature:void 0}putEventState(e){if("put"===(e.mode??"put"))for(const i of this.shownFeatures.features)i.properties?.eventState===e.state&&delete i.properties.eventState;const t=this.findFeature(e);t&&(t.properties={...t.properties,eventState:e.state}),!1!==e.show&&this.show(this.shownFeatures,{automaticVisibility:!1})}cleanEventState(e){const t=this.findFeature(e);t?.properties?.eventState&&(delete t?.properties?.eventState,!1!==e?.show&&this.show(this.shownFeatures,{automaticVisibility:!1}))}cleanEventStates(e){let t=!1;for(const i of this.shownFeatures.features)e?.states&&!e.states.includes(i.properties?.eventState)||(delete i.properties?.eventState,t=!0);!1!==e?.show&&t&&this.show(this.shownFeatures,{automaticVisibility:!1})}},je=e=>"click"===e||"contextmenu"===e,$e=(e,t,i,r="updateInProps")=>{const{feature:a,index:o}=Me(i,t)||{};if(a&&(!je(a.properties?.eventState)||je(e))){const t={...a,properties:"updateInProps"===r?{...a?.properties,eventState:e}:s(a?.properties,"eventState")};return i.splice(o,1,t),o}},ze=(e,t,r)=>{const s=[...r.shownFeatures.features],a=$e(e,Ne(t),s,"removeFromProps");i(a)||r.show({...r.shownFeatures,features:s},{automaticVisibility:!1})},Ye=(e,t,i,r,s)=>{if(t&&r instanceof Ve){const n=[...r.shownFeatures.features];return $e(e,Ne(t),n),!i||(o=t,(a=i)&&o&&a.id===o.id)||(s===r?$e(e,Ne(i),n,"removeFromProps"):s instanceof Ve&&ze(e,i,s)),void r.show({...r.shownFeatures,features:n},{automaticVisibility:!1})}var a,o;i&&s instanceof Ve&&ze(e,i,s)},qe=[],Ke={precisionMode:"box",paddingBoxPx:5,cursorOnHover:"pointer",cursorOnMouseDown:"grabbing",cursorOnMap:"default",longHoverDelayAfterMapMoveMS:800,longHoverDelayOnStillMapMS:300},Xe=class extends Oe{constructor(e,t={}){super(),this.enabled=!0,this.firstDelayedHoverSinceMapMove=!0,this.mouseMoveFrameRequested=!1,this.map=e,this.mapCanvas=e.getCanvas(),this.config={...Ke,...t},this.mapCanvas.style.cursor=this.config.cursorOnMap,this.lastCursorStyle=this.config.cursorOnMap,this.listenToEvents()}listenToEvents(){this.map.on("mousemove",e=>this.onMouseMove(e)),this.map.on("movestart",()=>this.onMouseStart()),this.map.on("mouseout",()=>this.onMouseOut()),this.map.on("mouseover",e=>this.onMouseMove(e)),this.map.on("mousedown",()=>this.onMouseDown()),this.map.on("mouseup",()=>this.onMouseUp()),this.map.on("click",e=>this.onMapClick("click",e)),this.map.on("contextmenu",e=>this.onMapClick("contextmenu",e))}enable(e){this.enabled=e,e||(this.clearLongHoverTimeout(),this.pendingMouseMove=void 0)}toPaddedBounds(e){const t=this.config.paddingBoxPx;return[[e.x-t,e.y+t],[e.x+t,e.y-t]]}isEnabled(){return this.enabled&&!this.map.isMoving()}toCallerFeatures(e,t,i){const r=i?e.filter(e=>i.has(e.layer.id)):e,s=(e=>{const t=/* @__PURE__ */new Set,i=[];for(const r of e){const e=Ne(r);if(void 0===e){i.push(r);continue}const s=`${r.source} ${e}`;t.has(s)||(t.add(s),i.push(r))}return i})((a=r,o=t?.source,o?a.filter(e=>e.source===o):a));var a,o;const n=this.sourceWithLayersFor(t?.layer.id);return n instanceof Ve?s.map(e=>n.findById(Ne(e))?.feature??e):s}callerFeaturesFor(e,t,i,r){return e.scope?.layerFilter?this.toCallerFeatures(t,i,e.layerIDs):r}getRenderedFeatures(e){if(!this.interactiveLayerIDs.length)return[];const t={layers:this.interactiveLayerIDs,validate:!1},i=this.config.precisionMode,r="point-then-box"===i||"point"===i?this.map.queryRenderedFeatures(e,t):[];return r.length||"point"===i?r:this.map.queryRenderedFeatures(this.toPaddedBounds(e),t)}clearLongHoverTimeout(){window.clearTimeout(this.longHoverTimeoutHandlerID)}restartLongHoverTimeout(){this.clearLongHoverTimeout(),this.longHoverTimeoutHandlerID=window.setTimeout(()=>this.handleLongHoverTimeout(),this.firstDelayedHoverSinceMapMove?this.config.longHoverDelayAfterMapMoveMS:this.config.longHoverDelayOnStillMapMS)}handleLongHoverTimeout(){if(this.firstDelayedHoverSinceMapMove=!1,this.hoveringSourceWithLayers){Ye("long-hover",this.hoveringFeature,void 0,this.hoveringSourceWithLayers,void 0);const e=this.findHandlers(["long-hover"],this.hoveringFeature?.layer.id);if(e.length){const t=this.hoveringFeatures??qe,i=this.hoveringFeature,r=this.toCallerFeatures(t,i);for(const s of e){const e=this.callerFeaturesFor(s,t,i,r);s.fn(e[0],this.hoveringLngLat,e,s.sourceWithLayers)}}}}onMouseStart(){this.firstDelayedHoverSinceMapMove=!0,this.clearLongHoverTimeout()}onMouseOut(){this.clearLongHoverTimeout()}onMouseDown(){this.lastCursorStyle=this.mapCanvas.style.cursor,this.mapCanvas.style.cursor=this.config.cursorOnMouseDown}onMouseUp(){this.mapCanvas.style.cursor=this.lastCursorStyle}onMouseMove(e){this.pendingMouseMove=e,this.mouseMoveFrameRequested||(this.mouseMoveFrameRequested=!0,requestAnimationFrame(()=>{this.mouseMoveFrameRequested=!1;const e=this.pendingMouseMove;this.pendingMouseMove=void 0,e&&this.handleMouseMove(e)}))}handleMouseMove(e){if(!this.isEnabled())return;this.hoveringFeatures=this.getRenderedFeatures(e.point);const[t]=this.hoveringFeatures;if(t&&!this.hasHandlerForLayer(t.layer.id))return;const{hoverChanged:i,mouseInMotionOverHoveredFeature:r}=((e,t,i,r)=>{if(t){if(!r)return{hoverChanged:!0};if(t.id&&t.id!==r.id||t.properties.id&&t.properties.id!==r.properties.id||t.source!==r.source||t.layer.id!==r.layer.id)return{hoverChanged:!0};if(i&&(e.x-i.x!=0||e.y-i.y!=0))return{mouseInMotionOverHoveredFeature:!0}}else if(r)return{hoverChanged:!0};return{}})(e.point,t,this.hoveringPoint,this.hoveringFeature);if(!i&&!r)return;const s=this.hoveringFeature,a=this.hoveringSourceWithLayers;let o;this.hoveringLngLat=e.lngLat,this.hoveringPoint=e.point,this.hoveringFeature=t,this.hoveringSourceWithLayers=this.sourceWithLayersFor(t?.layer.id),i&&(o=this.dispatchHoverEnter(e,s,a)),r&&this.dispatchHoverMove(e,o),this.restartLongHoverTimeout()}dispatchHoverEnter(e,t,i){const r=this.hoveringFeature?.layer.id,s=this.findHandlers(["hover","hover-move","long-hover","click","contextmenu"],r,this.hoveringFeature)?.[0];this.updateHoverCursor(s?.config),Ye("hover",this.hoveringFeature,t,this.hoveringSourceWithLayers,i);const a=this.findHandlers(["hover"],r);if(!a.length)return;const o=this.toCallerFeatures(this.hoveringFeatures??qe,this.hoveringFeature);return this.dispatchToHandlers(a,e,this.hoveringFeature,o),o}dispatchHoverMove(e,t){const i=this.findHandlers(["hover-move"],this.hoveringFeature?.layer.id);if(!i.length)return;const r=this.hoveringFeature,s=t??this.toCallerFeatures(this.hoveringFeatures??qe,r);this.dispatchToHandlers(i,e,r,s)}dispatchToHandlers(e,t,i,r){for(const s of e){const e=this.callerFeaturesFor(s,this.hoveringFeatures??qe,i,r);s.fn(e[0],t.lngLat,e,s.sourceWithLayers)}}updateHoverCursor(e){this.hoveringFeature?this.mapCanvas.style.cursor=e?.cursorOnHover??this.config.cursorOnHover:this.mapCanvas.style.cursor=this.config.cursorOnMap}onMapClick(e,t){if(!this.isEnabled())return;const i=this.getRenderedFeatures(t.point),r=this.lastClickedFeature;this.lastClickedFeature=i[0];const s=this.lastClickedSourceWithLayers,a=this.findHandlers([e],this.lastClickedFeature?.layer.id);if(this.lastClickedSourceWithLayers=a[0]?.sourceWithLayers,Ye(e,this.lastClickedFeature,r,this.lastClickedSourceWithLayers,s),a.length){const e=this.lastClickedFeature,r=this.toCallerFeatures(i,e);for(const s of a){const a=this.callerFeaturesFor(s,i,e,r);s.fn(a[0],t.lngLat,a,s.sourceWithLayers)}}}},Ze="Noto-Bold",Je="Noto-Regular",Qe="Noto-Medium",et="NotoSans-MediumItalic",tt=["interpolate",["linear"],["zoom"],10,14,18,16],it=[Je,et,Ze,Qe],rt=.8,st=["interpolate",["linear"],["zoom"],8,.6,22,rt],at={country:"Places - Country name",lowestPlaceLabel:"Places - Village / Hamlet",poi:"POI",lowestLabel:"Borders - Treaty label",lowestRoadLine:"Tunnel - Railway outline",lowestBuilding:"Buildings - Underground"},ot="vectorTiles",nt="hillshade",lt="vectorTiles",ct="vectorTilesIncidents",ht="vectorTilesFlow",ut=/* @__PURE__ */new WeakMap,dt=async(e,t,i,r)=>{let s=ut.get(e);s||(s=/* @__PURE__ */new Map,ut.set(e,s));const a=s.get(t);if(a){const e=await a;return r?.(e),e}const o=Promise.resolve().then(i);s.set(t,o);try{return await o}catch(n){throw s.delete(t),n}},pt=["POI","POI - Micro"],ft={NATIVE_RESERVATION:"aboriginal_land",AIRPORT:"airport",AMUSEMENT_PARK:"amusement_park",ATM:"atm",BANK:"bank",BAR:"bar",BEACH:"beach_resort",ACCESS_GATEWAY:"border_control",FRONTIER_CROSSING:"border_control",BUS_STOP:"bus_station",CAFE:"cafe",CAFE_PUB:"cafe",CAMPING_GROUND:"camping_ground",RENT_A_CAR_FACILITY:"car_rental",CASINO:"casino_and_gambling",CEMETERY:"cemetery",ELECTRIC_VEHICLE_STATION:"charging_location",CINEMA:"cinema",MOVIE_THEATER:"cinema",HEALTH_CARE_SERVICE:"clinic",CLOTHING_SHOP:"clothing_shop",COFFEE_SHOP:"coffee_shop",COLLEGE_OR_UNIVERSITY:"college_or_university",COLLEGE_UNIVERSITY:"college_or_university",AGRICULTURE:"commercial_area",BUSINESS_PARK:"commercial_area",COMMERCIAL_BUILDING:"commercial_area",COMPANY:"commercial_area",RESIDENTIAL_ACCOMMODATION:"commercial_area",EXHIBITION_CONVENTION_CENTER:"conference_center",CLUB_ASSOCIATION:"consumer_service",PUBLIC_AMENITY:"consumer_service",WELFARE_ORGANIZATION:"consumer_service",COURTHOUSE:"courthouse",COMMUNITY_CENTER:"cultural_center",CULTURAL_CENTER:"cultural_center",DENTIST:"dentist",DEPARTMENT_STORE:"department_store",DOCTOR:"doctor",EMERGENCY_MEDICAL_SERVICE:"emergency_ward_entrance",EMERGENCY_ROOM:"emergency_ward_entrance",FAST_FOOD:"fast_food",FERRY_TERMINAL:"ferry_terminal",FIRE_STATION_BRIGADE:"fire_station",FITNESS_CLUB_CENTER:"fitness_center",WINERY:"food_and_drinks_shop",CURRENCY_EXCHANGE:"foreign_exchange",EXCHANGE:"foreign_exchange",GAS_STATION:"fuel_station",GOLD_EXCHANGE:"gold_exchange",GOLF_COURSE:"golf_course",EMBASSY:"government_office",GOVERNMENT_OFFICE:"government_office",HELIPAD_HELICOPTER_LANDING:"heliport_or_helipad",HISTORIC_SITE:"historic_site",HOLIDAY_RENTAL:"holiday_home",GENERAL_HOSPITAL_AND_POLYCLINIC:"hospital",HOSPITAL:"hospital",HOTEL_MOTEL:"hotel_or_motel",ICE_SKATING_RINK:"ice_rink",INDUSTRIAL_BUILDING:"industrial_area",PORT_WAREHOUSE_FACILITY:"industrial_area",PRIMARY_RESOURCE_UTILITY:"industrial_area",GEOGRAPHIC_FEATURE:"landmark",SHOPPING_CENTER:"mall",MANUFACTURING_FACILITY:"manufacturing_facility",MARINA:"marina",MARKET:"marketplace",MEDIA_FACILITY:"media_facility",MOUNTAIN_PASS:"mountain_pass",MUSEUM:"museum",NON_GOVERNMENTAL_ORGANIZATION:"ngo_office",CONCERT_HALL:"nightlife",ENTERTAINMENT:"nightlife",NIGHTLIFE:"nightlife",PARK_RECREATION_AREA:"park_and_recreation_area",TRAIL_SYSTEM:"park_and_recreation_area",LEISURE_CENTER:"park_and_recreation_facility",WATER_SPORT:"park_and_recreation_facility",OPEN_PARKING_AREA:"parking_facility",PARKING_GARAGE:"parking_facility",PHARMACY:"pharmacy",POLICE_STATION:"police_station",POST_OFFICE:"post_office",PRISON_CORRECTIONAL_FACILITY:"prison",PROTECTED_AREA:"protected_land",PUB:"pub",LIBRARY:"public_library",PUBLIC_TRANSPORT_STOP:"public_transport_stop",RAILWAY_STATION:"railway_station",CHURCH:"religious_site",GURUDWARA:"religious_site",MOSQUE:"religious_site",PAGODA:"religious_site",PLACE_OF_WORSHIP:"religious_site",SYNAGOG:"religious_site",TEMPLE:"religious_site",RENT_A_CAR_PARKING:"rental_car_parking",RESEARCH_FACILITY:"research_facility",REST_AREA:"rest_and_service_area",RESTAURANT:"restaurant",RESTAURANT_AREA:"restaurant",SCHOOL:"school_or_kindergarten",SHOP:"shop_or_store",ADVENTURE_SPORTS_FACILITY:"sport_facility",SPORTS_CENTER:"sport_facility",TENNIS_COURT:"sport_facility",STADIUM:"stadium",SUPERMARKETS_HYPERMARKETS:"supermarket",SWIMMING_POOL:"swimming_pool",TAXI_STAND:"taxi_stand",OPERA_HOUSE:"theater",THEATER:"theater",TOLL_GATE:"toll_booth",TOURIST_ATTRACTION:"tourist_attraction",TOURIST_INFORMATION_OFFICE:"tourist_information",TRUCK_STOP:"truck_stop",AUTOMOTIVE_DEALER:"vehicle_dealer",MOTORING_ORGANIZATION_OFFICE:"vehicle_inspection",TRAFFIC_CONTROL_DEPARTMENT:"vehicle_inspection",TRANSPORT_AUTHORITY_VEHICLE_REGISTRATION:"vehicle_inspection",REPAIR_FACILITY:"vehicle_repair",CAR_WASH:"vehicle_wash",VETERINARIAN:"veterinary",HILL:"viewpoint",MOUNTAIN_PEAK:"viewpoint",SCENIC_PANORAMIC_VIEW:"viewpoint",WEIGH_STATION:"weighbridge",AQUATIC_ZOO:"zoo_or_aquarium",ARBORETA_BOTANICAL_GARDENS:"zoo_or_aquarium",ZOOS_ARBORETA_BOTANICAL_GARDEN:"zoo_or_aquarium"},yt={...ft,AIRFIELD:"airport",AIRLINE_ACCESS:"airport",PRIVATE_AIRPORT:"airport",PUBLIC_AIRPORT:"airport",ANIMAL_SHELTER:"animal_shelter",DIVERSIFIED_FINANCIALS:"bank",COCKTAIL_BAR:"bar",BEACH_CLUB:"beach_resort",SECURED_ENTRANCE:"border_control",INTERNET_CAFE:"cafe",CAFETERIA:"cafeteria",CARAVAN_SITE:"camping_ground",RECREATIONAL_CAMPING_GROUND:"camping_ground",REST_CAMP:"camping_ground",MAUSOLEUM_GRAVE:"cemetery",CHILD_CARE_FACILITY:"childcare",PRE_SCHOOL:"childcare",DRIVE_IN_MOVIES:"cinema",CHILDRENS_CLOTHES:"clothing_shop",MENS_CLOTHING:"clothing_shop",SPECIALTY_CLOTHING_SHOP:"clothing_shop",WOMENS_CLOTHING:"clothing_shop",JUNIOR_COLLEGE_COMMUNITY_COLLEGE:"college_or_university",COMEDY_CLUB:"comedy_club",ADVERTISING_COMPANY:"commercial_area",AGRICULTURAL_TECHNOLOGY:"commercial_area",AIRLINE_COMPANY:"commercial_area",APARTMENT_RENTAL:"commercial_area",AUTOMOBILE_COMPANY:"commercial_area",BUILDING:"commercial_area",BUSINESS_SERVICES:"commercial_area",BUS_CHARTER_COMPANY:"commercial_area",CABLE_TELEPHONE_COMPANY:"commercial_area",CLEANING_SERVICES:"commercial_area",COMPUTER_DATA_SERVICES:"commercial_area",CONSTRUCTION_COMPANY:"commercial_area",DELIVERY_SERVICE:"commercial_area",ELECTRONICS_COMPANY:"commercial_area",EQUIPMENT_RENTAL:"commercial_area",FARM:"commercial_area",FLATS_APARTMENT_COMPLEX:"commercial_area",HORTICULTURE:"commercial_area",IMPORT_EXPORT_AND_DISTRIBUTION:"commercial_area",INSURANCE_COMPANY:"commercial_area",INVESTMENT_ADVISOR:"commercial_area",LEGAL_SERVICES:"commercial_area",MINING_COMPANY:"commercial_area",MOVING_STORAGE_COMPANY:"commercial_area",OIL_NATURAL_GAS:"commercial_area",PHARMACEUTICAL_COMPANY:"commercial_area",PRIMARY_PRODUCER:"commercial_area",PUBLISHING_TECHNOLOGIES:"commercial_area",REAL_ESTATE_AGENT:"commercial_area",REAL_ESTATE_COMPANY:"commercial_area",RETIREMENT_COMMUNITY:"commercial_area",SERVICE_COMPANY:"commercial_area",SOFTWARE_COMPANY:"commercial_area",TAX_SERVICES:"commercial_area",TELECOMMUNICATIONS:"commercial_area",TRANSPORT_COMPANY:"commercial_area",TRAVEL_AGENT:"commercial_area",WEDDING_SERVICES:"commercial_area",PUBLIC_CALL_BOX:"consumer_service",PUBLIC_TOILET:"consumer_service",GENERAL_PRACTITIONER:"doctor",SPECIALIST:"doctor",AMBULANCE_UNIT:"emergency_ward_entrance",ROAD_RESCUE:"emergency_ward_entrance",MICROBREWERY:"food_and_drinks_shop",BATTLEFIELD:"historic_site",MEMORIAL:"historic_site",BUNGALOW_RENTAL:"holiday_home",CHALET_RENTAL:"holiday_home",COTTAGE_RENTAL:"holiday_home",VILLA_RENTAL:"holiday_home",HORSE_RIDING_CENTER:"horse_riding",BLOOD_BANK:"hospital",HOSPITAL_FOR_WOMEN_AND_CHILDREN:"hospital",HOSPITAL_OF_CHINESE_MEDICINE:"hospital",SPECIAL_HOSPITAL:"hospital",B_B_GUEST_HOUSE:"hotel_or_motel",CABINS_LODGES:"hotel_or_motel",HOSTEL:"hotel_or_motel",HOTEL:"hotel_or_motel",MOTEL:"hotel_or_motel",RESORT:"hotel_or_motel",ICE_CREAM_PARLOR:"ice_cream_shop",ICE_HOCKEY_ARENA:"ice_rink",CHEMICAL_COMPANY:"industrial_area",MECHANICAL_ENGINEERING:"industrial_area",QUARRY:"industrial_area",YOGURT_JUICE_BAR:"juice_bar",ARCH:"landmark",BAY:"landmark",BRIDGE:"landmark",CAPE:"landmark",COVE:"landmark",DAM:"landmark",DUNE:"landmark",ISLAND:"landmark",LOCALE:"landmark",MARSH:"landmark",MONUMENT:"landmark",OASIS:"landmark",OBSERVATORY:"landmark",PARKWAY:"landmark",PLAIN_FLAT:"landmark",PLATEAU:"landmark",RAPIDS:"landmark",REEF:"landmark",RESERVOIR:"landmark",RIVER_CROSSING:"landmark",ROCKS:"landmark",STATUE:"landmark",TOWER:"landmark",TUNNEL:"landmark",VALLEY:"landmark",WATER_HOLE:"landmark",WELL:"landmark",AUTOMOBILE_MANUFACTURING:"manufacturing_facility",MANUFACTURING_COMPANY:"manufacturing_facility",FARMERS_MARKET:"marketplace",FOOD_MARKET:"marketplace",INFORMAL_MARKET:"marketplace",PUBLIC_MARKET:"marketplace",MILITARY_AIRPORT:"military_airfield",FUNERAL_SERVICE_MORTUARIES:"mourning_facility",AMUSEMENT_PLACE:"nightlife",BETTING_STATION:"nightlife",CABARET_THEATER:"nightlife",DISCO_CLUB:"nightlife",FAIRGROUND:"nightlife",JAZZ_CLUB:"nightlife",KARAOKE_CLUB:"nightlife",MUSIC_CENTER:"nightlife",ADVENTURE_VEHICLE_TRAIL:"park_and_recreation_area",FISHING_HUNTING_AREA:"park_and_recreation_area",FOREST_AREA:"park_and_recreation_area",HIKING_TRAIL:"park_and_recreation_area",HISTORICAL_PARK:"park_and_recreation_area",HORSE_RIDING_TRAIL:"park_and_recreation_area",MOUNTAIN_BIKE_TRAIL:"park_and_recreation_area",PARK:"park_and_recreation_area",PICNIC_AREA:"park_and_recreation_area",RECREATION_AREA:"park_and_recreation_area",ROCK_CLIMBING_TRAIL:"park_and_recreation_area",WILDERNESS_AREA:"park_and_recreation_area",OPEN_CAR_PARKING_AREA:"parking_facility",BEAUTY_SALON:"personal_care_service",HAIRDRESSER:"personal_care_service",NAIL_SALON:"personal_care_service",PERSONAL_CARE_FACILITY:"personal_care_service",PERSONAL_SERVICE:"personal_care_service",SAUNA_SOLARIUM_MASSAGE:"personal_care_service",DRUG_STORE:"pharmacy",MARIJUANA_DISPENSARY:"pharmacy",MEDICINAL_MARIJUANA_DISPENSARY:"pharmacy",RECREATIONAL_MARIJUANA_DISPENSARY:"pharmacy",PLANETARIUM:"planetarium",COURIER_DROP_BOX:"post_depot",BUS_LINES:"public_transport_stop",PASSENGER_TRANSPORT_TICKET_OFFICE:"public_transport_stop",STREETCAR_STOP:"public_transport_stop",SUBWAY_STATION:"public_transport_stop",INTERNATIONAL_RAILROAD_STATION:"railway_station",NATIONAL_RAILROAD_STATION:"railway_station",STATION_ACCESS:"railway_station",URBAN_STATION:"railway_station",AFGHAN_RESTAURANT:"restaurant",AFRICAN_RESTAURANT:"restaurant",AMERICAN_RESTAURANT:"restaurant",ARABIAN_RESTAURANT:"restaurant",ARMENIAN_RESTAURANT:"restaurant",ASIAN_RESTAURANT:"restaurant",AUSTRALIAN_RESTAURANT:"restaurant",AUSTRIAN_RESTAURANT:"restaurant",BANQUET_ROOMS:"restaurant",BARBECUE_RESTAURANT:"restaurant",BASQUE_RESTAURANT:"restaurant",BELGIAN_RESTAURANT:"restaurant",BISTRO:"restaurant",BOLIVIAN_RESTAURANT:"restaurant",BRAZILIAN_RESTAURANT:"restaurant",BRITISH_RESTAURANT:"restaurant",BUFFET_RESTAURANT:"restaurant",BULGARIAN_RESTAURANT:"restaurant",BURMESE_RESTAURANT:"restaurant",CALIFORNIAN_RESTAURANT:"restaurant",CAMBODIAN_RESTAURANT:"restaurant",CANADIAN_RESTAURANT:"restaurant",CARIBBEAN_RESTAURANT:"restaurant",CATERING_SERVICES:"restaurant",CHICKEN_RESTAURANT:"restaurant",CHINESE_RESTAURANT:"restaurant",COLOMBIAN_RESTAURANT:"restaurant",CORSICAN_RESTAURANT:"restaurant",CREOLE_RESTAURANT:"restaurant",CREPERIE:"restaurant",CUBAN_RESTAURANT:"restaurant",CZECH_RESTAURANT:"restaurant",DANISH_RESTAURANT:"restaurant",DINNER_THEATER:"restaurant",DONGBEI_RESTAURANT:"restaurant",DOUGHNUT_RESTAURANT:"restaurant",DUTCH_RESTAURANT:"restaurant",EGYPTIAN_RESTAURANT:"restaurant",ENGLISH_RESTAURANT:"restaurant",ETHIOPIAN_RESTAURANT:"restaurant",FINNISH_RESTAURANT:"restaurant",FONDUE_RESTAURANT:"restaurant",FRENCH_RESTAURANT:"restaurant",FUSION_RESTAURANT:"restaurant",GERMAN_RESTAURANT:"restaurant",GREEK_RESTAURANT:"restaurant",GRILL_RESTAURANT:"restaurant",HAMBURGER_RESTAURANT:"restaurant",HAWAIIAN_RESTAURANT:"restaurant",HOT_POT_RESTAURANT:"restaurant",HUNAN_RESTAURANT:"restaurant",HUNGARIAN_RESTAURANT:"restaurant",INDIAN_RESTAURANT:"restaurant",INDONESIAN_RESTAURANT:"restaurant",INTERNATIONAL_RESTAURANT:"restaurant",IRANIAN_RESTAURANT:"restaurant",IRISH_RESTAURANT:"restaurant",ISRAELI_RESTAURANT:"restaurant",ITALIAN_RESTAURANT:"restaurant",JAMAICAN_RESTAURANT:"restaurant",JAPANESE_RESTAURANT:"restaurant",JEWISH_RESTAURANT:"restaurant",KOREAN_RESTAURANT:"restaurant",KOSHER_RESTAURANT:"restaurant",LATIN_AMERICAN_RESTAURANT:"restaurant",LEBANESE_RESTAURANT:"restaurant",MEDITERRANEAN_RESTAURANT:"restaurant",MEXICAN_RESTAURANT:"restaurant",MIDDLE_EASTERN_RESTAURANT:"restaurant",MONGOLIAN_RESTAURANT:"restaurant",MOROCCAN_RESTAURANT:"restaurant",NEPALESE_RESTAURANT:"restaurant",NORWEGIAN_RESTAURANT:"restaurant",ORGANIC_FOOD_RESTAURANT:"restaurant",ORIENTAL_RESTAURANT:"restaurant",PAKISTANI_RESTAURANT:"restaurant",PERUVIAN_RESTAURANT:"restaurant",PHILIPPINE_RESTAURANT:"restaurant",PIZZERIA:"restaurant",POLISH_RESTAURANT:"restaurant",POLYNESIAN_RESTAURANT:"restaurant",PORTUGUESE_RESTAURANT:"restaurant",PUB_FOOD:"restaurant",RUSSIAN_RESTAURANT:"restaurant",SALAD_BAR:"restaurant",SANDWICH_RESTAURANT:"restaurant",SCANDINAVIAN_RESTAURANT:"restaurant",SEAFOOD:"restaurant",SHANDONG_RESTAURANT:"restaurant",SICHUAN_RESTAURANT:"restaurant",SNACKS_RESTAURANT:"restaurant",SOUL_FOOD:"restaurant",SOUP_RESTAURANT:"restaurant",SPANISH_RESTAURANT:"restaurant",STEAK_HOUSE:"restaurant",SUSHI_RESTAURANT:"restaurant",SWEDISH_RESTAURANT:"restaurant",SWISS_RESTAURANT:"restaurant",SYRIAN_RESTAURANT:"restaurant",TAIWANESE_RESTAURANT:"restaurant",TAKEOUT_FOOD:"restaurant",TAPAS_RESTAURANT:"restaurant",TEPPANYAKI_RESTAURANT:"restaurant",THAI_RESTAURANT:"restaurant",TIBETAN_RESTAURANT:"restaurant",TUNISIAN_RESTAURANT:"restaurant",TURKISH_RESTAURANT:"restaurant",VEGETARIAN_RESTAURANT:"restaurant",VENEZUELAN_RESTAURANT:"restaurant",VIETNAMESE_RESTAURANT:"restaurant",WESTERN_RESTAURANT:"restaurant",ART_SCHOOL:"school_or_kindergarten",DANCE_STUDIO_SCHOOL:"school_or_kindergarten",DRIVING_SCHOOL:"school_or_kindergarten",HIGH_SCHOOL:"school_or_kindergarten",LANGUAGE_SCHOOL:"school_or_kindergarten",MIDDLE_SCHOOL:"school_or_kindergarten",PRIMARY_SCHOOL:"school_or_kindergarten",SENIOR_HIGH_SCHOOL:"school_or_kindergarten",VOCATIONAL_SCHOOL:"school_or_kindergarten",AGRICULTURAL_SUPPLIES:"shop_or_store",ANTIQUE_ART_SHOP:"shop_or_store",BAGS_LEATHERWEAR:"shop_or_store",BAKERY:"shop_or_store",BEAUTY_SUPPLIES:"shop_or_store",BOATING_EQUIPMENT_ACCESSORIES:"shop_or_store",BOOK_SHOP:"shop_or_store",BUTCHER:"shop_or_store",CAMERAS_PHOTOGRAPHY:"shop_or_store",CARPET_FLOOR_COVERINGS:"shop_or_store",CHRISTMAS_HOLIDAY_SHOP:"shop_or_store",COMPUTER_COMPUTER_SUPPLIES:"shop_or_store",CONSTRUCTION_MATERIAL_EQUIPMENT:"shop_or_store",CONSUMER_ELECTRONICS:"shop_or_store",CONVENIENCE_STORE:"shop_or_store",CURTAINS_TEXTILES:"shop_or_store",C_DS_DVD_VIDEOS:"shop_or_store",DELICATESSEN:"shop_or_store",DO_IT_YOURSELF_CENTERS:"shop_or_store",DRIVE_THROUGH_BOTTLE_SHOP:"shop_or_store",DRY_CLEANER:"shop_or_store",ELECTRICAL_APPLIANCES_SHOP:"shop_or_store",FACTORY_OUTLET:"shop_or_store",FISHMONGER:"shop_or_store",FLORISTS:"shop_or_store",FOOTWEAR_SHOE_REPAIRS:"shop_or_store",FURNITURE_HOME_FURNISHINGS:"shop_or_store",GARDEN_CENTERS_SERVICES:"shop_or_store",GIFTS_CARDS_NOVELTIES_SOUVENIRS:"shop_or_store",GLASSWARE_CERAMIC_SHOP:"shop_or_store",GLASS_WINDOWS_STORE:"shop_or_store",GREENGROCER:"shop_or_store",GROCERY_STORE:"shop_or_store",HARDWARE_STORE:"shop_or_store",HOBBY_SHOP:"shop_or_store",HOUSE_GARDEN_FURNITURE_FITTINGS:"shop_or_store",JEWELRY_CLOCKS_WATCHES:"shop_or_store",KITCHENS_BATHROOMS:"shop_or_store",LAUNDRY:"shop_or_store",LIGHTING_SHOPS:"shop_or_store",LOCAL_SPECIALITIES_SHOP:"shop_or_store",LOTTERY_SHOP:"shop_or_store",MEDICAL_SUPPLIES_EQUIPMENT:"shop_or_store",MOBILE_PHONE_SHOP:"shop_or_store",MUSIC_INSTRUMENTS_STORE:"shop_or_store",NEWSAGENTS_TOBACCONISTS:"shop_or_store",OFFICE_EQUIPMENT:"shop_or_store",OPTICIAN:"shop_or_store",OTHER_FOOD_SHOPS:"shop_or_store",PAINTING_DECORATING:"shop_or_store",PAWN_SHOP:"shop_or_store",PET_SUPPLIES:"shop_or_store",PHOTOCOPY_SHOP:"shop_or_store",PHOTO_LAB_DEVELOPMENT:"shop_or_store",RECYCLING_SHOP:"shop_or_store",RETAIL_OUTLET:"shop_or_store",SECURITY_PRODUCTS:"shop_or_store",SHOPPING_SERVICE:"shop_or_store",SPECIALTY_FOODS:"shop_or_store",SPORTS_EQUIPMENT_CLOTHING:"shop_or_store",TAILOR_SHOP:"shop_or_store",TOYS_GAMES_SHOP:"shop_or_store",VARIETY_STORE:"shop_or_store",VIDEO_RENTAL_SHOP:"shop_or_store",WHOLESALE_CLUB:"shop_or_store",WINE_SPIRITS:"shop_or_store",ATHLETICS_TRACK:"sport_facility",BASEBALL_PARK:"sport_facility",BASKETBALL_ARENA:"sport_facility",BOWLING_CENTER:"sport_facility",CRICKET_GROUND:"sport_facility",HOCKEY_CLUB:"sport_facility",HORSE_RACING_TRACK:"sport_facility",RACE_TRACK:"sport_facility",RUGBY_GROUND:"sport_facility",SNOOKER_POOL_BILLIARD:"sport_facility",THEMATIC_SPORT_CENTER:"sport_facility",FOOTBALL_STADIUM:"stadium",MOTOR_RACING_STADIUM:"stadium",MULTI_PURPOSE_STADIUM:"stadium",NETBALL_STADIUM:"stadium",SOCCER_STADIUM:"stadium",STOCK_EXCHANGE:"stock_exchange",TAXI_LIMOUSINE_SHUTTLE_SERVICE:"taxi_stand",TEA_HOUSE:"tea_house",AMPHITHEATER:"theater",CAVE:"tourist_attraction",MINERAL_HOT_SPRINGS:"tourist_attraction",NATURAL_TOURIST_ATTRACTION:"tourist_attraction",BOAT_LAUNCHING_RAMP:"transport_access",HARBOR:"transport_access",YACHT_BASIN:"transport_access",ATV_DEALER:"vehicle_dealer",BOAT_DEALER:"vehicle_dealer",BUS_DEALER:"vehicle_dealer",CAR_DEALER:"vehicle_dealer",MOTORCYCLE_DEALER:"vehicle_dealer",RECREATIONAL_VEHICLE_DEALER:"vehicle_dealer",TRUCK_DEALER:"vehicle_dealer",VAN_DEALER:"vehicle_dealer",ROAD_TRAFFIC_CONTROL_CENTER:"vehicle_inspection",BODYSHOP:"vehicle_repair",CAR_GLASS_REPLACEMENT_SHOP:"vehicle_repair",CAR_REPAIR_AND_SERVICE:"vehicle_repair",HOME_APPLIANCE_REPAIR:"vehicle_repair",MOTORCYCLE_REPAIR:"vehicle_repair",TIRE_SERVICE:"vehicle_repair",TRUCK_REPAIR_AND_SERVICE:"vehicle_repair",ANIMAL_SERVICES:"veterinary",RIDGE:"viewpoint",OTHER_WINTER_SPORT:"winter_sports",SKI_RESORT:"winter_sports",WILDLIFE_PARK:"zoo_or_aquarium",ZOO:"zoo_or_aquarium"},mt=e=>yt[e],gt=Array.from(new Set(Object.values(yt))),_t={bar:"eat_and_drink",cafe:"eat_and_drink",cafeteria:"eat_and_drink",coffee_shop:"eat_and_drink",fast_food:"eat_and_drink",ice_cream_shop:"eat_and_drink",juice_bar:"eat_and_drink",pub:"eat_and_drink",restaurant:"eat_and_drink",tea_house:"eat_and_drink",clothing_shop:"shopping",department_store:"shopping",food_and_drinks_shop:"shopping",mall:"shopping",marketplace:"shopping",shop_or_store:"shopping",supermarket:"shopping",atm:"finance",bank:"finance",foreign_exchange:"finance",gold_exchange:"finance",stock_exchange:"finance",camping_ground:"lodging",holiday_home:"lodging",hotel_or_motel:"lodging",airport:"transport",bus_station:"transport",ferry_terminal:"transport",heliport_or_helipad:"transport",marina:"transport",public_transport_stop:"transport",railway_station:"transport",taxi_stand:"transport",transport_access:"transport",border_control:"driving",car_rental:"driving",charging_location:"driving",fuel_station:"driving",rest_and_service_area:"driving",toll_booth:"driving",truck_stop:"driving",vehicle_dealer:"driving",vehicle_inspection:"driving",vehicle_repair:"driving",vehicle_wash:"driving",weighbridge:"driving",parking_facility:"parking",rental_car_parking:"parking",clinic:"healthcare",dentist:"healthcare",doctor:"healthcare",emergency_ward_entrance:"healthcare",hospital:"healthcare",pharmacy:"healthcare",veterinary:"healthcare",childcare:"education",college_or_university:"education",research_facility:"education",school_or_kindergarten:"education",cultural_center:"cultural",historic_site:"cultural",museum:"cultural",planetarium:"cultural",theater:"cultural",amusement_park:"leisure",beach_resort:"leisure",casino_and_gambling:"leisure",cinema:"leisure",comedy_club:"leisure",nightlife:"leisure",park_and_recreation_facility:"leisure",tourist_attraction:"leisure",tourist_information:"leisure",zoo_or_aquarium:"leisure",fitness_center:"sport",golf_course:"sport",horse_riding:"sport",ice_rink:"sport",sport_facility:"sport",stadium:"sport",swimming_pool:"sport",winter_sports:"sport",aboriginal_land:"outdoor",landmark:"outdoor",mountain_pass:"outdoor",park_and_recreation_area:"outdoor",viewpoint:"outdoor",protected_land:"protected",cemetery:"public",courthouse:"public",fire_station:"public",government_office:"public",police_station:"public",post_depot:"public",post_office:"public",prison:"public",public_library:"public",military_airfield:"military",religious_site:"religion",animal_shelter:"business",commercial_area:"business",conference_center:"business",consumer_service:"business",industrial_area:"business",manufacturing_facility:"business",media_facility:"business",mourning_facility:"business",ngo_office:"business",personal_care_service:"business"},Lt=e=>{const t=mt(e);return t?_t[t]:void 0},St="title",At="iconID",It=.7,Et="default_place",bt="poi-parking-micro",Rt={"icon-image":["get",At],"icon-anchor":"bottom","icon-size":st,"icon-allow-overlap":!0,"icon-padding":0},Tt={"icon-translate":[0,5],"icon-translate-anchor":"viewport"},Ct={"text-optional":!0,"text-font":[Ze],"text-field":["get",St],"text-justify":"auto","text-variable-anchor":["top","left","right"],"text-variable-anchor-offset":["top",[0,It],"left",[1.4,-1.4],"right",[-1.4,-1.4]],"text-size":tt,"text-padding":5},vt={"text-halo-width":["interpolate",["linear"],["zoom"],6,1,10,1.5],"text-translate-anchor":"viewport"},wt={type:"symbol",layout:{...Rt,...Ct},paint:{...Tt,...vt}},Ot=(e,t)=>`${e}-${t}`,Nt=["has","point_count"],Mt=["!",Nt],Dt="clusterBaseMapIconIDs",xt=["all",Nt,["==",["index-of",",",["get",Dt]],-1]],Ft=["all",Nt,[">=",["index-of",",",["get",Dt]],0]],Pt=[12,-14],Ut={[Dt]:(De="baseMapIconID",xe=Dt,[["case",["==",["get",xe],null],["accumulated"],["==",["accumulated"],null],["get",xe],[">=",["index-of",["concat",",",["get",xe],","],["concat",",",["accumulated"],","]],0],["accumulated"],["concat",["accumulated"],",",["get",xe]]],["get",De]])},Ht=e=>{const t=["match",e];for(const i of gt){const e=`poi-${i}`;t.push(e,["image",e])}return t.push(["image",bt]),t},kt=(e,t)=>{if(!e)return;const i=(e=>{try{if("string"==typeof e){if(e.includes("<svg")){const t=le(e),i=t.getAttribute("viewBox");if(i){const e=i.split(/\s+/);if(4===e.length)return{width:Number.parseFloat(e[2]),height:Number.parseFloat(e[3])}}const r=t.getAttribute("width"),s=t.getAttribute("height");if(r&&s)return{width:Number.parseFloat(r),height:Number.parseFloat(s)}}return null}return e.complete&&e.naturalWidth>0?{width:e.naturalWidth,height:e.naturalHeight}:null}catch(t){return console.warn("Failed to extract image dimensions:",t),null}})(e);if(!i)return;const r="base-map"===t||"circle-icon"===t,s=r?54:140,a=r?54:120;return{heightScale:i.height/s,widthScale:i.width/a}},Wt=e=>{const t=["case"];for(const[i,r]of e)0===r.x&&0===r.y||t.push(["==",["get",At],i],["literal",[r.x,r.y]]);if(1!==t.length)return t.push(["literal",[0,0]]),t},Gt=e=>Boolean(e&&"availability"in e&&e.availability),Bt=e=>"ELECTRIC_VEHICLE_STATION"===e.properties.poi?.categories?.[0]&&Gt(e.properties.chargingPark),Vt=e=>{const t=e.properties.chargingPark;if(Gt(t)){const e=t.availability.chargingPointAvailability,i=e.statusCounts.Available??0;return{availableCount:i,totalCount:e.count,ratio:i/e.count}}},jt=(e,t)=>`${e}/${t}`,$t=e=>Vt(e)?.ratio??0,zt=e=>["case",[">=",["get","evAvailabilityRatio"],e?.threshold??0],"green","red"],Yt=e=>Math.round(1e4*e)/1e4,qt=(e,t,i,r)=>{const s=void 0!==r;return{top:s?[0,r]:[0,Yt(e)],left:s?[r,Yt(i)]:[Yt(t),Yt(i)],right:s?[-r,Yt(i)]:[-Yt(t),Yt(i)]}},Kt=(e,t,i,r)=>{const s=(e=>{if(!e)return rt;if("number"==typeof e)return e;if(Array.isArray(e)){const t=e.at(-1);if("number"==typeof t)return t}if("object"==typeof e&&"stops"in e){const t=e.stops;if(Array.isArray(t)&&t.length>0){const e=t.at(-1);if(Array.isArray(e)&&"number"==typeof e[1])return e[1]}}return rt})(e)/rt,a="base-map"===i||"circle-icon"===i;if(a&&void 0!==r)return{"text-offset":[r,r]};const o=1.4*s,n=qt(It*s,o,a?0:-o,r),l=["top",n.top,"left",n.left,"right",n.right];if(0===t.size)return{"text-variable-anchor-offset":l};const c=["case"];for(const[h,u]of t.entries()){const e=(a?1.4:It)*u.heightScale*s,t=1.4*u.widthScale*s,i=qt(e,t,a?0:-t,r);c.push(["==",["get",At],h],["literal",["top",i.top,"left",i.left,"right",i.right]])}return c.push(["literal",l]),{"text-variable-anchor-offset":c}},Xt=(e,t,i,r,s)=>{const a=t?.text,o=t?.layers?.[i],n=s&&s.size>0,l={...e.layout},c=n||void 0!==a?.offset||"circle-icon"===t?.theme;c&&(delete l["text-offset"],delete l["text-variable-anchor-offset"],delete l["text-radial-offset"]);const h={...l,...o?.layout,...a?.size&&{"text-size":a.size},...a?.font&&{"text-font":a.font},...void 0!==r&&{"text-field":r}};if(c){const e={...h,...Kt(h["icon-size"],s??/* @__PURE__ */new Map,t?.theme,a?.offset)},r="micro"!==i&&s&&Wt([...s].map(([e,{offset:t}])=>[e,t]));return r?{...e,"icon-offset":r}:e}return h},Zt=(e,t,i,r)=>{const s=t?.text,a=t?.layers?.[i],{textColor:o,haloColor:n}=(e=>({textColor:"dark"===e?"#FFFFFF":"#333333",haloColor:"dark"===e?"#333333":"#FFFFFF"}))(r),l=e.paint??{};return{...l,...void 0===l["text-color"]&&{"text-color":o},...void 0===l["text-halo-color"]&&{"text-halo-color":n},...s?.color&&{"text-color":s.color},...s?.haloColor&&{"text-halo-color":s.haloColor},...s?.haloWidth&&{"text-halo-width":s.haloWidth},...a?.paint}},Jt=["in",["get","eventState"],["literal",["click","contextmenu"]]],Qt=e=>JSON.parse(JSON.stringify(e)?.replaceAll("name",St)),ei=(e,t)=>e.getStyle().layers.find(e=>e.id===t)??{},ti=e=>({filter:["!",Jt],type:"symbol",paint:e.paint,layout:e.layout?s(e.layout,"visibility"):void 0}),ii=e=>{const t=ti(ei(e,"POI")),i=t.layout?.["text-size"];return{...t,layout:{...t.layout,"icon-image":["get",At],"text-field":["get",St],...i&&{"text-size":Qt(i)}}}},ri=e=>{const t=ti(ei(e,"POI - Micro"));return{...t,minzoom:0,layout:{...t.layout,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{...t.paint,"icon-opacity":1}}},si=e=>{const t=ei(e,"POI").layout??{};return{...wt,layout:{...wt.layout,"icon-anchor":"center",...void 0!==t["icon-size"]&&{"icon-size":t["icon-size"]},...void 0!==t["icon-padding"]&&{"icon-padding":t["icon-padding"]}},paint:{...wt.paint,"icon-translate":[0,0]}}},ai=["has","eventState"],oi={type:"symbol",layout:{visibility:"none"}},ni={type:"circle",layout:{visibility:"none"}},li="#3f9cd9",ci={...wt,filter:["!",ai]},hi={...wt,filter:ai,layout:{...wt.layout,"icon-size":["interpolate",["linear"],["zoom"],8,.8,22,1],"text-allow-overlap":!0},paint:{...wt.paint,"text-color":li}},ui=e=>({...e,filter:ai,layout:{...e.layout,"text-allow-overlap":!0},paint:{...e.paint,"text-color":li}}),di=(e,t,i,r,s)=>{const a=t?.text,o=t?.layers?.[i],n=!0===t?.evAvailability?.enabled,l=a?.title&&"function"!=typeof a?.title?a.title:n?((e,t)=>t?["case",["has","evAvailabilityText"],["format",["get",St],{},"\n",{},["get","evAvailabilityText"],{"font-scale":1.1,"text-color":zt(e?.evAvailability)}],["get",St]]:["get",St])(t,n):void 0;return{...e,...o,layout:Xt(e,t,i,l,s),paint:Zt(e,t,i,r)}},pi=(e,t,i,r)=>{const s=((e,t)=>{const i=/* @__PURE__ */new Map,r=e?.icon?.categoryIcons??[];for(const s of r)if(s.image){const r=kt(s.image,e?.theme),a=void 0!==s.offsetX||void 0!==s.offsetY;if(void 0===r&&!a)continue;const o={heightScale:r?.heightScale??1,widthScale:r?.widthScale??1,offset:{x:s.offsetX??0,y:s.offsetY??0}},n=Ot(s.id,t);if(i.set(n,o),s.availabilityLevel){const e=Ot(`${s.id}-${s.availabilityLevel}`,t);i.set(e,o)}}return i})(e,r);let a,o,n=oi,l=oi,c=ni,h=oi,u=ni,d=oi;if("base-map"===e?.theme)a={...ii(t),minzoom:10},n=ri(t),o=(e=>ui(ii(e)))(t);else if("circle-icon"===e?.theme)a=(e=>({...si(e),filter:["!",ai]}))(t),o=(e=>ui(si(e)))(t);else if("pin-clustered"===e?.theme){a={...ci,filter:["all",Mt,["!",ai]]},o={...hi,filter:["all",Mt,ai]};const e=ri(t);n={...e,filter:e.filter?["all",Mt,e.filter]:Mt},l={type:"symbol",filter:xt,layout:{"icon-image":Ht(["get",Dt]),"icon-size":1,"icon-allow-overlap":!0,"icon-ignore-placement":!0}},c={type:"circle",filter:xt,paint:{"circle-radius":11,"circle-color":"#000000","circle-stroke-color":"#FFFFFF","circle-stroke-width":1.5,"circle-translate":Pt,"circle-translate-anchor":"viewport"}},h={type:"symbol",filter:xt,layout:{"text-field":["get","point_count_abbreviated"],"text-font":[Ze],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#FFFFFF","text-translate":Pt,"text-translate-anchor":"viewport"}},u={type:"circle",filter:Ft,paint:{"circle-radius":15,"circle-color":"#000000","circle-stroke-color":"#FFFFFF","circle-stroke-width":1.5}},d={type:"symbol",filter:Ft,layout:{"text-field":["get","point_count_abbreviated"],"text-font":[Ze],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#FFFFFF"}}}else a=ci,o=hi;return{micro:{...di(n,e,"micro",i,s),beforeID:at.lowestPlaceLabel},main:{...di(a,e,"main",i,s),beforeID:"selected"},selected:di(o,e,"selected",i,s),cluster:{...l,...e?.layers?.cluster,beforeID:"clusterBadge"},clusterBadge:{...c,...e?.layers?.clusterBadge,beforeID:"clusterCount"},clusterCount:{...h,...e?.layers?.clusterCount,beforeID:"clusterMixedBadge"},clusterMixedBadge:{...u,...e?.layers?.clusterMixedBadge,beforeID:"clusterMixedCount"},clusterMixedCount:{...d,...e?.layers?.clusterMixedCount},...e?.layers?.additional}},fi=e=>{if(oe())return ne(ce(e))},yi=(e,t)=>"string"!=typeof e?e:t.features.find(t=>t.id===e),mi=/* @__PURE__ */new Set([7339002,8099002,7369004,7321003,7376006,9362003,9362004,9160004,9376007,7315015,9376006,9376002,7315078,7315149,9376005,7372003,9352045,9352032,9361048,9902003,9378005,7383004,9910004,7320002,9362016,7320003,9362025,9942002,9942003,7380005,9663003,9361021,9379009,9379004,7315147,9376003,9160002,9160003,9352008,9361006,7389004,9910006]),gi=e=>e.properties.poi?.name??e.properties.address.freeformAddress,_i=(e,t,i)=>{if("pin"===t||"pin-clustered"===t)return(e=>{if(e)return mi.has(e)?ae(e.toString()):ae(e.toString().substring(0,4))})(A[e])??i;{const t=mt(e);return t?`poi-${t}`:i}},Li=(e,t,i={})=>{const r=i.theme??"pin",s=((e,t)=>e.icon?.default||"base-map"!==(e.theme??"pin")?Ot(Et,t):bt)(i,t),a=i.icon?.mapping;if(a)return"imageID"===a.to?a.fn(e):_i(a.fn(e),r,s);const o=e.properties.poi?.categories?.[0],n=((e,t,i,r,s)=>{if(!r.evAvailability?.enabled||!Bt(e))return;const a=$t(e)>=(r.evAvailability.threshold??.3)?"available":"occupied",o=r.icon?.categoryIcons&&r.icon.categoryIcons.length>0,n=r.icon?.categoryIcons?.find(e=>e.id===t&&e.availabilityLevel===a);return n?Ot(`${n.id}-${a}`,i):o||"pin"!==s?void 0:ae(`7309-${a}`)})(e,o,t,i,r);if(n)return n;const l=i.icon?.categoryIcons?.find(e=>e.id===o);return l?Ot(l.id,t):_i(o,r,s)},Si=(e,t)=>{const i=t?.icon?.mapping;return"poiCategory"===i?.to?i.fn(e):e.properties.poi?.categories?.[0]},Ai=(e,t)=>{const i=Si(e,t);return i&&mt(i)},Ii=(e,t)=>{const i=Si(e,t);return i&&Lt(i)},Ei=e=>Array.isArray(e)?{type:"FeatureCollection",features:e}:"Feature"===e.type?{type:"FeatureCollection",features:[e]}:e,bi=(e,t,i)=>{if(!0!==t?.enabled)return e;let r=!1,s=!1;for(const a of i.features)if("ELECTRIC_VEHICLE_STATION"===a.properties.poi?.categories?.[0]&&(r=!0,Bt(a))){s=!0;break}return r&&!s&&console.warn("PlacesModule: evAvailability is enabled but no availability data found. Did you call getPlacesWithEVAvailability()?"),{...e,evAvailabilityText:e=>Bt(e)?((e,t)=>{const i=Vt(e);return i?(t?.formatText??jt)(i.availableCount,i.totalCount):""})(e,t):"",evAvailabilityRatio:e=>Bt(e)?$t(e):0}},Ri=(e,t)=>{const i=Ai(e,t);return i?`poi-${i}`:bt},Ti=(e,t,i={})=>{const r=Ei(e),s=!0===i.evAvailability?.enabled?bi(i.extraFeatureProps,i.evAvailability,r):i.extraFeatureProps;return{...r,features:r.features.map(e=>{const r="function"==typeof i?.text?.title?i?.text?.title(e):gi(e),a=s?Object.fromEntries(Object.entries(s).map(([t,i])=>[t,"function"==typeof i?i(e):i])):{},o=e.id??f();return{...e,id:o,geometry:{...e.geometry,bbox:e.bbox},properties:{...e.properties,id:o,title:r,iconID:Li(e,t,i),...("base-map"===i?.theme||"pin-clustered"===i?.theme)&&{category:Ai(e,i),group:Ii(e,i)},..."pin-clustered"===i?.theme&&{baseMapIconID:Ri(e,i)},...a}}})}},Ci=class e extends ve{static async create(t,i){return await he(t),new e(t,i)}constructor(e,t){super(e,t),this.currentClusterMode=!1,this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){t||(this.sourceID=`places-${this.instanceIndex}`,this.unclusteredSourceID=`places-${this.instanceIndex}-unclustered`,this.connectionSourceID=`places-connections-${this.instanceIndex}`,this.layerIDPrefix=this.sourceID,this.defaultPlaceIconID=Ot(Et,this.instanceIndex),this.shownConnections=[]),this.layerSpecs=this.buildLayerSpecs(e);const i=this.buildClusterOptions(e);this.currentClusterMode=!0===i?.cluster;const r=this.partitionSpecsForSources(this.layerSpecs),s=new Ve(this.mapLibreMap,this.sourceID,r.clusteredSpecs,!1,i);let a;r.unclusteredSpecs.length>0&&(a=new Ve(this.mapLibreMap,this.unclusteredSourceID,r.unclusteredSpecs,!1)),ge([...s._layerSpecs,...a?._layerSpecs??[]],this.mapLibreMap),this.connectionLayerSpecs=this.buildConnectionLayerSpecs(e);const o=new Ve(this.mapLibreMap,this.connectionSourceID,Object.values(this.connectionLayerSpecs),!1);return ge(o._layerSpecs,this.mapLibreMap),a?{places:s,placesUnclustered:a,connections:o}:{places:s,connections:o}}partitionSpecsForSources(e){if(!this.currentClusterMode)return{clusteredSpecs:Object.values(e),unclusteredSpecs:[]};const t=[],i=[];for(const[r,s]of Object.entries(e))"micro"===r?t.push(s):i.push(s);return{clusteredSpecs:i,unclusteredSpecs:t}}buildLayerSpecs(e){const t=pi(e,this.tomtomMap.mapLibreMap,this.tomtomMap.styleLightDarkTheme,this.instanceIndex),i=new Set(Object.keys(t));return Object.fromEntries(Object.entries(t).map(([e,t])=>{const r=t.beforeID;return[e,{...t,id:`${this.layerIDPrefix}-${e}`,...r&&i.has(r)?{beforeID:`${this.layerIDPrefix}-${r}`}:{}}]}))}buildClusterOptions(e){if("pin-clustered"===e?.theme)return{cluster:!0,clusterRadius:60,clusterProperties:Ut}}buildConnectionLayerSpecs(e){const t=((e,t,i="light")=>{const r=(e=>({lineColor:"dark"===e?"#5AB6F0":"#3f9cd9",labelColor:"dark"===e?"#A9D6F5":"#1a5f8a",labelHaloColor:"dark"===e?"#1a1a1a":"#ffffff"}))(i),s=e?.layers?.line,a=e?.layers?.label,o={type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":t??r.lineColor,"line-width":1.5,"line-dasharray":[2,2],"line-opacity":.9}},n=(l=t??r.labelColor,c=r.labelHaloColor,{type:"symbol",layout:{"symbol-placement":"line-center","text-field":["get","label"],"text-size":12,"text-offset":[0,-1],"text-allow-overlap":!1,"text-ignore-placement":!1,"text-keep-upright":!0},paint:{"text-color":l,"text-halo-color":c,"text-halo-width":1.5}});var l,c;return{line:{...o,...s,layout:{...o.layout,...s?.layout},paint:{...o.paint,...s?.paint}},label:{...n,...a,layout:{...n.layout,...a?.layout},paint:{...n.paint,...a?.paint}}}})(e?.connections,void 0,this.tomtomMap.styleLightDarkTheme),i=`${this.layerIDPrefix}-connection-line`,r=`${this.layerIDPrefix}-connection-label`,s=at.lowestLabel;return{line:{...t.line,id:i,beforeID:s},label:{...t.label,id:r,beforeID:s}}}_applyConfig(e){return this.updateLayersAndData(e),e}discardShownData(){this.shownConnections=[]}restoreDataAndConfigImpl(){const e=this.sourcesWithLayers.places.shownFeatures,t=this.shownConnections;this.initSourcesWithLayers(this.config,!0),this.config&&this._applyConfig(this.config),this.show(e),t.length&&this.showConnections(t)}applyTheme(e){this.applyConfigPart({theme:e})}applyIconConfig(e){this.applyConfigPart({icon:e})}applyTextConfig(e){this.applyConfigPart({text:e})}applyConfigPart(e){const t={...this.config,...e};this.updateLayersAndData(t),this.config=t,this.emitConfigChange()}applyExtraFeatureProps(e){const t={...this.config,extraFeatureProps:e};this.updateData(t),this.config=t,this.emitConfigChange()}updateLayersAndData(e){if(this.setupImages(e),!0===this.buildClusterOptions(e)?.cluster!==this.currentClusterMode)return void this.rebuildSourcesAndLayers(e);const t=this.buildLayerSpecs(e),i=this.currentClusterMode?this.partitionSpecsForSources(t):{clusteredSpecs:Object.values(t),unclusteredSpecs:[]},r=this.currentClusterMode?this.partitionSpecsForSources(this.layerSpecs):{clusteredSpecs:Object.values(this.layerSpecs),unclusteredSpecs:[]};fe(i.clusteredSpecs,r.clusteredSpecs,this.sourcesWithLayers.places,this.mapLibreMap),this.sourcesWithLayers.placesUnclustered&&i.unclusteredSpecs.length>0&&fe(i.unclusteredSpecs,r.unclusteredSpecs,this.sourcesWithLayers.placesUnclustered,this.mapLibreMap),this.layerSpecs=t,this.applyPlacesVisibility(),this.updateData(e),this.updateConnectionLayersAndData(e)}rebuildSourcesAndLayers(e){const t=this.sourcesWithLayers.places.shownFeatures,i=this.shownConnections;for(const s of Object.values(this.layerSpecs))this.mapLibreMap.getLayer(s.id)&&this.mapLibreMap.removeLayer(s.id);for(const s of Object.values(this.connectionLayerSpecs))this.mapLibreMap.getLayer(s.id)&&this.mapLibreMap.removeLayer(s.id);this.mapLibreMap.getSource(this.sourceID)&&this.mapLibreMap.removeSource(this.sourceID),this.mapLibreMap.getSource(this.unclusteredSourceID)&&this.mapLibreMap.removeSource(this.unclusteredSourceID),this.mapLibreMap.getSource(this.connectionSourceID)&&this.mapLibreMap.removeSource(this.connectionSourceID),this.initSourcesWithLayers(e,!0),this.setupImages(e);const r=Ti(t,this.instanceIndex,e);this.sourcesWithLayers.places.show(r,{automaticVisibility:!1}),this.sourcesWithLayers.placesUnclustered?.show(r,{automaticVisibility:!1}),this.applyPlacesVisibility(),i.length&&(this.shownConnections=[...i],this.updateConnectionsData(e))}updateConnectionLayersAndData(e){const t=this.buildConnectionLayerSpecs(e),i=this.sourcesWithLayers.connections;fe(Object.values(t),Object.values(this.connectionLayerSpecs),i,this.mapLibreMap),this.connectionLayerSpecs=t,this.updateConnectionsData(e)}updateConnectionsData(e){const t=this.sourcesWithLayers.places.shownFeatures;this.sourcesWithLayers.connections.show(((e,t,i={})=>{const r=i.connections?.label,s=[];for(const a of e){const e=yi(a.from,t),i=yi(a.to,t);if(!e||!i)continue;const o=a.id??f(),n=r?r(a):"";s.push({type:"Feature",id:o,geometry:{type:"LineString",coordinates:[e.geometry.coordinates,i.geometry.coordinates]},properties:{id:o,fromId:"string"==typeof a.from?a.from:e.id,toId:"string"==typeof a.to?a.to:i.id,label:n}})}return{type:"FeatureCollection",features:s}})(this.shownConnections,t,e))}applyPlacesVisibility(){const e=this.sourcesWithLayers.places.shownFeatures.features.length?"visible":"none";for(const t of Object.values(this.layerSpecs))"none"!==t.layout?.visibility&&this.mapLibreMap.setLayoutProperty(t.id,"visibility",e,{validate:!1})}setupImages(e){if(e?.icon){for(const t of e.icon.categoryIcons??[]){const e=t.availabilityLevel?`${t.id}-${t.availabilityLevel}`:t.id;Se("if-not-in-sprite",Ot(e,this.instanceIndex),t.image,this.mapLibreMap,{pixelRatio:t.pixelRatio??2})}e.icon.default&&(e.icon.default.image&&Se("if-not-in-sprite",this.defaultPlaceIconID,e.icon.default.image.image,this.mapLibreMap,{pixelRatio:e.icon.default.image.pixelRatio??2}),e.icon.default.style&&Se("if-not-in-sprite",this.defaultPlaceIconID,fi(e.icon.default.style),this.mapLibreMap,{pixelRatio:2}))}else Se("if-not-in-sprite",this.defaultPlaceIconID,fi(),this.mapLibreMap,{pixelRatio:2})}updateData(e){const t=Ti(this.sourcesWithLayers.places.shownFeatures,this.instanceIndex,e);this.sourcesWithLayers.places.source.runtimeSource?.setData(t),this.sourcesWithLayers.placesUnclustered?.source.runtimeSource?.setData(t)}async show(e){await this.waitUntilModuleReady(),this.clearConnectionsSync();const t=Ti(e,this.instanceIndex,this.config);this.sourcesWithLayers.places.show(t,{automaticVisibility:!1}),this.sourcesWithLayers.placesUnclustered?.show(t,{automaticVisibility:!1}),this.applyPlacesVisibility();for(const i of this.shownFeaturesHandlers)i({places:e})}async clear(){await this.waitUntilModuleReady(),this.clearConnectionsSync(),this.sourcesWithLayers.places.clear(),this.sourcesWithLayers.placesUnclustered?.clear()}async showConnections(e){await this.waitUntilModuleReady(),this.shownConnections=[...e],this.updateConnectionsData(this.config);for(const t of this.shownFeaturesHandlers)t({connections:e})}async clearConnections(){await this.waitUntilModuleReady(),this.clearConnectionsSync()}clearConnectionsSync(){this.shownConnections=[],this.sourcesWithLayers.connections?.clear()}getShown(){return{places:this.sourcesWithLayers.places.shownFeatures,connections:[...this.shownConnections]}}putEventState(e){this.sourcesWithLayers.places.putEventState(e)}cleanEventState(e){this.sourcesWithLayers.places.cleanEventState(e)}cleanEventStates(e){this.sourcesWithLayers.places.cleanEventStates(e)}get events(){const e=["places","placesUnclustered"];return this.buildEvents(this.moduleEventsWithShown([...e,"connections"],this.shownFeaturesHandlers),{places:this.userEvents(e),connections:this.userEvents(["connections"])})}},vi=["pin","circle-icon","base-map","pin-clustered"],wi=e=>{if(!0===e||!1===e)return!0;if(!Array.isArray(e)||0===e.length)return!1;switch(e[0]){case"has":return e.length>=2&&"$id"!==e[1]&&"$type"!==e[1];case"in":return e.length>=3&&("string"!=typeof e[1]||Array.isArray(e[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return 3!==e.length||Array.isArray(e[1])||Array.isArray(e[2]);case"any":case"all":for(const t of e.slice(1))if(!wi(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}},Oi=e=>"$type"===e?["geometry-type"]:"$id"===e?["id"]:["get",e],Ni=e=>"$type"===e||("$id"===e?["!=",["id"],null]:["has",e]),Mi=(e,t)=>!!t.length&&["in",Oi(e),["literal",t]],Di=e=>{const t=e[0];if(e.length<=1)return"any"!==t;const i=e[1],r=e.slice(2),s=e.slice(1);switch(t){case"has":return Ni(i);case"!has":return["!",Ni(i)];case"==":case"!=":return(null===r[0]?((e,t)=>{if("$id"!==t&&"$type"!==t)return"=="===e?["all",["has",t],["==",["get",t],null]]:["any",["!",["has",t]],["!=",["get",t],null]]})(t,i):void 0)??[t,Oi(i),r[0]];case">":case">=":case"<":case"<=":return((e,t,i)=>["all",["==",["typeof",Oi(t)],typeof i],[e,Oi(t),i]])(t,i,r[0]);case"in":return Mi(i,r);case"!in":return["!",Mi(i,r)];case"all":return["all",...s.map(e=>xi(e))];case"any":return["any",...s.map(e=>xi(e))];case"none":return["!",["any",...s.map(e=>xi(e))]];default:return!0}},xi=e=>wi(e)?e:Di(e),Fi=e=>e?.length?1===e.length?e[0]:["any",...e]:null,Pi=(e,t)=>i(t)?e:["all",e,xi(t)],Ui=(e,t,i)=>{if(1===i.length)return["only"===t?"==":"!=",["get",e],i[0]];const r=["in",["get",e],["literal",i]];return"only"===t?r:["!",r]},Hi=(e,t,i)=>Ui(e,t.show,i?t.values.map(i):t.values),ki={FOOD_DRINKS_GROUP:["RESTAURANT","FAST_FOOD","CAFE_PUB","PUB","WINERY","PUB_FOOD","SOUL_FOOD","DELICATESSEN"],SHOPPING_GROUP:["SHOP","SHOPPING_CENTER","CLOTHING_SHOP","MARKET","FOOD_MARKET","SUPERMARKETS_HYPERMARKETS","DEPARTMENT_STORE","CONVENIENCE_STORE","GROCERY_STORE","HARDWARE_STORE","ELECTRICAL_APPLIANCES_SHOP"],TRANSPORTATION_GROUP:["AIRPORT","FERRY_TERMINAL","HELIPAD_HELICOPTER_LANDING","PUBLIC_TRANSPORT_STOP","RAILWAY_STATION","BUS_STOP","TAXI_STAND"],HEALTH_GROUP:["DOCTOR","EMERGENCY_MEDICAL_SERVICE","EMERGENCY_ROOM","HEALTH_CARE_SERVICE","HOSPITAL","PHARMACY","DENTIST","WELFARE_ORGANIZATION"],PARKING_GROUP:["PARKING_GARAGE","OPEN_PARKING_AREA"],HOLIDAY_TOURISM_GROUP:["AMUSEMENT_PARK","BEACH","HOLIDAY_RENTAL","GEOGRAPHIC_FEATURE","TOURIST_ATTRACTION","LEISURE_CENTER","MOUNTAIN_PASS","MOUNTAIN_PEAK","MUSEUM","SCENIC_PANORAMIC_VIEW","TOURIST_INFORMATION_OFFICE"],EV_CHARGING_STATIONS_GROUP:["ELECTRIC_VEHICLE_STATION"],GAS_STATIONS_GROUP:["GAS_STATION"],ACCOMMODATION_GROUP:["CAMPING_GROUND","HOTEL_MOTEL","HOLIDAY_RENTAL"],ENTERTAINMENT_GROUP:["CINEMA","THEATER","MOVIE_THEATER","NIGHTLIFE","CONCERT_HALL","ENTERTAINMENT","CLUB_ASSOCIATION","CASINO"],SPORTS_LEISURE_GROUP:["SPORTS_CENTER","WATER_SPORT","SWIMMING_POOL","GOLF_COURSE","STADIUM","BEACH","ICE_SKATING_RINK","LEISURE_CENTER","MOUNTAIN_PASS","MOUNTAIN_PEAK"],EDUCATION_GROUP:["SCHOOL","COLLEGE_UNIVERSITY","LIBRARY","CULTURAL_CENTER"],GOVERNMENT_GROUP:["GOVERNMENT_OFFICE","COURTHOUSE","EMBASSY","FIRE_STATION_BRIGADE","POLICE_STATION"]},Wi=e=>{const{properties:t}=e;return{id:e.id,type:e.type,geometry:e.geometry,properties:{id:String(t?.id),name:t?.name,category:t?.category,group:t?.group,priority:t?.priority}}},Gi=e=>{const t=[];return e.forEach(e=>{e in ki?t.push(...ki[e].map(mt)):t.push(mt(e))}),[...new Set(t)]},Bi=class e extends we{static async get(t,i){return await he(t),dt(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(ot);if(!t)throw re(`init ${e.name} with source ID ${ot}`);const i=new We(this.mapLibreMap,t,e=>pt.includes(e.id)),r=i.sourceAndLayerIDs.layerIDs[0];return this.mapLibreMap.getLayer(r)&&(this.originalFilter=this.mapLibreMap.getFilter(r)),{poi:i}}_applyConfig(e){return e&&!i(e.visible)?this._setVisible(e.visible,!1):this._initializing||this.isVisible()||this._setVisible(!0,!1),this._filterCategories(e?.filters?.categories,!1),e}isVisible(){return this.sourcesWithLayers.poi.isAnyLayerVisible()}setVisible(e){this._setVisible(e)}_setVisible(e,t=!0){this.tomtomMap.mapReady&&this.sourcesWithLayers.poi.setLayersVisible(e),t&&(this.config={...this.config,visible:e},this.emitConfigChange())}filterCategories(e){this._filterCategories(e)}_filterCategories(e,t=!0){if(e){if(this.tomtomMap.mapReady){const t=Ui("category",e.show,Gi(e.values));this.mapLibreMap.setFilter("POI",Pi(t,this.originalFilter))}t&&(this.config={...this.config,filters:{categories:e}})}else this.categoriesFilter&&(t&&(this.config={...this.config,filters:{categories:{show:"all_except",values:[]}}}),this.tomtomMap.mapReady&&this.mapLibreMap.setFilter("POI",this.originalFilter));this.categoriesFilter=e,t&&this.emitConfigChange()}getShown(){return{poi:this.mapLibreMap.queryRenderedFeatures({layers:this.sourcesWithLayers.poi.sourceAndLayerIDs.layerIDs,validate:!1}).map(Wi)}}get events(){return this.moduleEvents(["poi"],{mapping:Wi})}},Vi=["land","water","buildings2D","roads","railways","ferries","borders","buildings3D","natureLabels","roadLabels","roadShields","houseNumbers","smallerTownLabels","stateLabels","cityLabels","allPlaceLabels","capitalLabels","countryLabels"],ji={land:{metadataGroups:["area","background"]},water:{metadataGroups:["water"]},natureLabels:{metadataGroups:["label"]},roads:{metadataGroups:["road","road_area","transit_area"],idExcludes:["railway","subway","aerialway","ferry"]},railways:{metadataGroups:["road"],layerTypes:["line"],idIncludes:["railway","subway","aerialway"]},ferries:{metadataGroups:["road"],layerTypes:["line"],idIncludes:["ferry"]},buildings2D:{metadataGroups:["building"],layerTypes:["fill","line"]},buildings3D:{metadataGroups:["area_3d","building"],layerTypes:["fill-extrusion"]},borders:{metadataGroups:["border","border_label"]},roadLabels:{metadataGroups:["road_label"],idExcludes:["shield"]},roadShields:{metadataGroups:["road_label"],idIncludes:["shield"]},houseNumbers:{metadataGroups:["address_point_label"]},allPlaceLabels:{metadataGroups:["places_label"]},smallerTownLabels:{metadataGroups:["places_label"],idIncludes:["neighbourhood","village","hamlet","town"]},cityLabels:{metadataGroups:["places_label"],idIncludes:["city"]},capitalLabels:{metadataGroups:["places_label"],idIncludes:["capital"]},stateLabels:{metadataGroups:["places_label"],idIncludes:["state"]},countryLabels:{metadataGroups:["places_label"],idIncludes:["country"]}},$i=(e,t)=>{const i=ji[e],r=(e=>{const t=e.metadata;if(t&&"object"==typeof t&&"group"in t){const e=t.group;return"string"==typeof e?e:void 0}})(t);if(!r||!i.metadataGroups.includes(r))return!1;if(i.layerTypes&&!i.layerTypes.includes(t.type))return!1;const s=t.id.toLowerCase();return!(i.idIncludes&&!i.idIncludes.some(e=>s.includes(e)))&&!i.idExcludes?.some(e=>s.includes(e))},zi=e=>{const t=e.mode,i=e.names;return"include"===t?e=>i.some(t=>$i(t,e)):"exclude"===t?e=>!i.some(t=>$i(t,e)):(console.error("Unrecognized layer group mode:",t),()=>!0)},Yi=e=>!pt.includes(e.id),qi=class e extends we{static async get(t,i){return await he(t),dt(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(lt);if(!t)throw re(`init ${e.name} with source ID ${lt}`);const i=new We(this.mapLibreMap,t,Yi);return this.layersByGroup=void 0,{vectorTiles:i}}_applyConfig(e){return e&&!i(e.visible)?this._setVisible(e.visible,void 0,!1):this._initializing||this.isVisible()||this._setVisible(!0,void 0,!1),e?.layerGroupsVisibility&&this._setVisible(e.layerGroupsVisibility.visible,{layerGroups:e.layerGroupsVisibility},!1),this.config||e?{...this.config,...e}:void 0}isVisible(e){return this.sourcesWithLayers.vectorTiles.isAnyLayerVisible(e?.layerGroups&&zi(e.layerGroups))}setVisible(e,t){this._setVisible(e,t)}_setVisible(e,t,i=!0){i&&(t?.layerGroups?this.config={...this.config,layerGroupsVisibility:{...t.layerGroups,visible:e}}:(delete this.config?.layerGroupsVisibility,this.config={...this.config,visible:e})),this.tomtomMap.mapReady&&this.sourcesWithLayers.vectorTiles.setLayersVisible(e,t?.layerGroups&&zi(t.layerGroups)),i&&this.emitConfigChange()}getLayers(){return r(this.groupedLayers(),e=>[...e])}getLayerIds(e){return[...this.groupedLayers()[e]]}groupedLayers(){return this.layersByGroup??=(e=>{const t=Object.fromEntries(Vi.map(e=>[e,[]]));for(const i of e)for(const e of Vi)$i(e,i)&&t[e].push(i.id);return t})(this.sourcesWithLayers.vectorTiles._layerSpecs),this.layersByGroup}get events(){return this.moduleEvents(["vectorTiles"],{scopeResolver:Ki})}},Ki=e=>({layerFilter:zi(e.layerGroups),featureMatches:e.features}),Xi=class e extends ve{static async create(t,i){return await he(t),Zi(i),new e(t,i)}constructor(e,t){super(e,t),this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){const i=e??this.config;t||(this.lastShown={}),this.resolveIDs(i),this.registerImages(i);const r={};for(const s of Object.keys(i.sources)){const e=this.resolvedSourceIDs[s],t=this.resolvedLayerSpecs[s],a=i.sources[s].cluster;r[s]=new Ve(this.mapLibreMap,e,t,!0,a)}return r}registerImages(e){if(e.images)for(const[t,i]of Object.entries(e.images))this.mapLibreMap.hasImage(t)||this.mapLibreMap.addImage(t,i.image,i.options)}resolveIDs(e){const t={},i={};for(const r of Object.keys(e.sources)){const s=e.sources[r],a=s.sourceID??`custom-geojson-${this.instanceIndex}-${String(r)}`;t[r]=a,i[r]=s.layers.map((e,t)=>({...e,id:e.id??`${a}-layer-${t}`}))}this.resolvedSourceIDs=t,this.resolvedLayerSpecs=i}_applyConfig(e){if(!e)return this._applyConfig(this.initialConfig);this.initialConfig??=e;const t=this.config,i=t?this.resolvedLayerSpecs:void 0;return this.resolveIDs(e),this.registerImages(e),t&&i&&this.updateLayersForExistingSources(i),void 0!==e.visible&&this.applyVisibility(e.visible),e}updateLayersForExistingSources(e){for(const t of Object.keys(this.resolvedLayerSpecs)){const i=e[t],r=this.resolvedLayerSpecs[t],s=this.sourcesWithLayers[t];if(!i||!s)continue;fe(r,i,s,this.mapLibreMap);const a=[];for(const e of s._layerSpecs)this.mapLibreMap.getLayer(e.id)||a.push(e);a.length>0&&(ge(a,this.mapLibreMap),s.shownFeatures.features.length>0&&s.setLayersVisible(!0))}}applyVisibility(e){for(const t of Object.keys(this.sourcesWithLayers))this.sourcesWithLayers[t].setLayersVisible(e)}discardShownData(){this.lastShown={}}restoreDataAndConfigImpl(){const e=Object.keys(this.lastShown);this.initSourcesWithLayers(this.config,!0),this.config&&this._applyConfig(this.config);for(const t of e){const e=this.lastShown[t];e&&this.showOnSource(t,e)}}async show(e,t){if(await this.waitUntilModuleReady(),void 0!==t)this.showOnSource(t,e);else for(const i of Object.keys(this.sourcesWithLayers))this.showOnSource(i,e)}showOnSource(e,t){const i=Ji(t);this.lastShown[e]=i,this.sourcesWithLayers[e].show(i);for(const r of this.shownFeaturesHandlers)r({sourceName:e,data:i})}async clear(e){if(await this.waitUntilModuleReady(),void 0!==e)return this.sourcesWithLayers[e].clear(),void delete this.lastShown[e];for(const t of Object.keys(this.sourcesWithLayers))this.sourcesWithLayers[t].clear(),delete this.lastShown[t]}getShown(){const e={};for(const t of Object.keys(this.sourcesWithLayers))e[t]=this.sourcesWithLayers[t].shownFeatures;return e}setVisible(e){this.config={...this.config,visible:e},this.applyVisibility(e),this.emitConfigChange()}get events(){const e=Object.keys(this.sourcesWithLayers),t={};for(const i of e)t[i]=this.userEvents([i]);return this.buildEvents(this.moduleEventsWithShown(e,this.shownFeaturesHandlers),t)}},Zi=e=>{if(!e.sources||0===Object.keys(e.sources).length)throw new Error("CustomGeoJSONModule requires at least one source in config.sources.");k(Object.keys(e.sources),"CustomGeoJSONModule source");for(const[t,i]of Object.entries(e.sources))if(!i.layers||0===i.layers.length)throw new Error(`CustomGeoJSONModule source "${t}" requires at least one layer.`)},Ji=e=>{let t=!1;for(const i of e.features)if(null==i.id||i.properties?.id!==i.id){t=!0;break}return t?{...e,features:e.features.map((e,t)=>{const i=e.id??e.properties?.id??t;return{...e,id:i,properties:{...e.properties,id:i}}})}:e},Qi="#0A3653",er="#555555",tr=e=>({defaultColor:"dark"===e?"#5FA8D8":Qi,textColor:"dark"===e?"#FFFFFF":"#333333",haloColor:"dark"===e?"#333333":"#FFFFFF"}),ir=(e,t,r,s=Qi)=>{const a=r?.fill,o=r?.line,n=((e=Qi)=>({type:"fill",paint:{"fill-color":["coalesce",["get","color"],e],"fill-opacity":["case",["==",["get","theme"],"outline"],0,.15],"fill-antialias":!1}}))(s),l=((e=Qi)=>({type:"line",paint:{"line-color":["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],er],["coalesce",["get","color"],e]],"line-opacity":["case",["==",["get","theme"],"outline"],.9,1],"line-width":["case",["==",["get","theme"],"outline"],5,2]}}))(s),c={...n,id:e,paint:{...n.paint,...!i(a?.opacity)&&{"fill-opacity":a?.opacity},...a?.color&&{"fill-color":["get","color"]}}},h=o?.layer;return[c,{...l,...h,id:t,...h?.layout&&{layout:{...l.layout,...h.layout}},paint:{...l.paint,...h?.paint,...!i(o?.color)&&{"line-color":o?.color},...!i(o?.width)&&{"line-width":o?.width},...!i(o?.opacity)&&{"line-opacity":o?.opacity}}}]},rr=(e,t,i="light")=>{const r=t?.textConfig,{textColor:s,haloColor:a}=tr(i);return{type:"symbol",id:e,layout:{"text-field":["get","title"],...r?.textField&&{"text-field":r.textField},"text-padding":5,"text-size":15,"text-font":[Ze],"symbol-placement":"point"},paint:{"text-color":s,"text-halo-color":a,"text-halo-width":["interpolate",["linear"],["zoom"],6,1,10,1.5],"text-translate-anchor":"viewport"}}},sr=(e,t,r="light")=>{const s=t?.lineLabelConfig,a=s?.minZoom??3,{textColor:o,haloColor:n}=tr(r);return{type:"symbol",id:e,minzoom:a,layout:{"text-field":["get","title"],"symbol-placement":"line","text-size":s?.textSize??15,"text-font":[Ze],"symbol-spacing":s?.symbolSpacing??200,"text-keep-upright":!0,"text-offset":s?.textOffset??[0,1]},paint:{"text-color":s?.textColor??o,"text-halo-color":s?.textHaloColor??n,"text-halo-width":s?.textHaloWidth??2,...!i(s?.textOpacity)&&{"text-opacity":s?.textOpacity}}}},ar={warm:["#793F0D","#AC703D","#C38E63","#E49969","#E5AE86","#EEC5A9","#6E7649","#9D9754","#C7C397","#B4A851","#DFD27C","#E7E3B5","#846D74","#B7A6AD","#D3C9CE"],browns:["#edc4b3","#e6b8a2","#deab90","#d69f7e","#cd9777","#c38e70","#b07d62","#9d6b53","#8a5a44","#774936"],cold:["#344464","#548ca4","#549cac","#2c445c","#a4ccd4","#acbccc","#b4c4d4","#acd4cc","#5c8ca4"],fadedBlues:["#152033","#1d2d44","#2e455d","#3e5c76","#4c6884","#597491","#67809e","#6e86a5","#7b91ad","#879bb4"],blues:["#03045e","#023e8a","#0077b6","#0096c7","#00b4d8","#48cae4","#90e0ef","#ade8f4","#caf0f8"],greens:["#004b23","#006400","#007200","#008000","#38b000","#70e000","#9ef01a","#ccff33"],fadedGreenToBlue:["#d9ed92","#b5e48c","#99d98c","#76c893","#52b69a","#34a0a4","#168aad","#1a759f","#1e6091","#184e77"],blueToRed:["#033270","#1368aa","#4091c9","#9dcee2","#fedfd4","#f29479","#f26a4f","#ef3c2d","#cb1b16","#65010c"],greenToYellow:["#007f5f","#2b9348","#55a630","#80b918","#aacc00","#bfd200","#d4d700","#dddf00","#eeef20","#ffff3f"],pastel:["#fec5bb","#fcd5ce","#fae1dd","#f8edeb","#e8e8e4","#d8e2dc","#ece4db","#ffe5d9","#ffd7ba","#fec89a"],retro:["#f94144","#f3722c","#f8961e","#f9844a","#f9c74f","#90be6d","#43aa8b","#4d908e","#577590","#277da1"],contrastRetro:["#001219","#005f73","#0a9396","#94d2bd","#e9d8a6","#ee9b00","#ca6702","#bb3e03","#ae2012","#9b2226"],fadedRainbow:["#ffadad","#ffd6a5","#fdffb6","#caffbf","#9bf6ff","#a0c4ff","#bdb2ff","#ffc6ff","#fffffc"],pastelRainbow:["#54478c","#2c699a","#048ba8","#0db39e","#16db93","#83e377","#b9e769","#efea5a","#f1c453","#f29e4c"]},or=Object.keys(ar),nr=(e,t)=>"light"===t?e:e.map(e=>{const t=(e=>{const t=e.replace("#","");return 6!==t.length?.5:Number.parseInt(t.slice(0,2),16)/255*.299+Number.parseInt(t.slice(2,4),16)/255*.587+Number.parseInt(t.slice(4,6),16)/255*.114})(e);return t>.6?te(e,.3)??e:t<.22?((e,t)=>{const i=Q(e);if(!i)return;const r=e=>Math.round(255*(e+(1-e)*t));return`#${[r(i[0]),r(i[1]),r(i[2])].map(e=>e.toString(16).padStart(2,"0")).join("")}`})(e,.4)??e:e}),lr=(e,t={},i="light")=>({...e,features:e.features.map((e,r)=>{const s=(e.properties??{}).theme??t.theme,a="inverted"===s?(e=>{const t=C(e);return{...e,geometry:t.geometry}})(e):e,o=a.properties??{},n=o.title??((e,t)=>t.textConfig?.textField?t.textConfig.textField:e.properties?.address?.freeformAddress)(a,t),l=o.color??((e,t,i)=>{const r=e?.fill?.color;if("string"==typeof r&&ar[r]){const e=nr(ar[r],i);return e[t%e.length]}return r})(t,r,i);return{...a,properties:{...a.properties,...s&&{theme:s},...n&&{title:n},...l&&{color:l},id:o.id??f()}}})}),cr=e=>{const t=e.features.map(e=>{let t;if(e.properties?.placeCoordinates)t=e.properties?.placeCoordinates;else if("MultiPolygon"===e.geometry.type){const i=(e=>e.flat().reduce((e,t)=>t.length>e.length?t:e,[]))(e.geometry.coordinates),r=h(i);t=r&&c(r)||null}else t=e.geometry.coordinates.flat();const i=e.id??e.properties?.id??f();return{type:"Feature",id:i,geometry:{type:"Point",coordinates:t},properties:{...e.properties,id:i}}});return{type:"FeatureCollection",bbox:e.bbox,features:t}},hr=class e extends ve{static async create(t,i){return await he(t),new e(t,i)}constructor(e,t){super(e,t),this.lineLabelLayerSpecs=null,this.lastRawInput=null,this.shownFeaturesHandlers=[]}get lightDark(){return this.tomtomMap.styleLightDarkTheme}get defaultColor(){return tr(this.lightDark).defaultColor}_initSourcesWithLayers(e,t){if(!t){this.sourceID=`geometry-${this.instanceIndex}`,this.titleSourceID=`geometryTitle-${this.instanceIndex}`;const e=`geometry-${this.instanceIndex}`;this.fillLayerID=`${e}_Fill`,this.outlineLayerID=`${e}_Outline`,this.lineLabelLayerID=`${e}_LineLabel`,this.titleLayerID=`${e}_Title`}const[i,r]=ir(this.fillLayerID,this.outlineLayerID,e,this.defaultColor),s=rr(this.titleLayerID,e,this.lightDark);this.titleLayerSpecs=s,this.geometryFillLayerSpecs=i,this.geometryOutlineLayerSpecs=r;const a=void 0===e?.lineLabelConfig?null:sr(this.lineLabelLayerID,e,this.lightDark);return this.lineLabelLayerSpecs=a,{geometry:new Ve(this.mapLibreMap,this.sourceID,[{...i},{...r},...a?[a]:[]]),geometryLabel:new Ve(this.mapLibreMap,this.titleSourceID,[s])}}_applyConfig(e){return(e?.textConfig||e?.fill||e?.line)&&this.updateLayerAndData(e),(e?.beforeLayerConfig||e?.fill?.beforeLayerConfig||e?.line?.beforeLayerConfig)&&this.applyBeforeLayerConfig(e),e}resolveBeforeID(e){return"top"===e?this.titleLayerID:at[e]}moveLayersBefore(e,t){for(const i of e)me(this.mapLibreMap,i,t)}get fillLayerIDs(){return[this.fillLayerID]}get lineLayerIDs(){return this.lineLabelLayerSpecs?[this.outlineLayerID,this.lineLabelLayerID]:[this.outlineLayerID]}moveBeforeLayer(e){this.config={...this.config,beforeLayerConfig:e},this.applyBeforeLayerConfig(this.config),this.emitConfigChange()}applyBeforeLayerConfig(e){const t=e?.beforeLayerConfig,i=e=>{if(void 0!==t)return"string"==typeof t?t:t[e]??t.all},r=e?.fill?.beforeLayerConfig??i("fill"),s=e?.line?.beforeLayerConfig??i("line");void 0!==r&&this.moveLayersBefore(this.fillLayerIDs,this.resolveBeforeID(r)),void 0!==s&&this.moveLayersBefore(this.lineLayerIDs,this.resolveBeforeID(s))}applyTextConfig(e){const t={...this.config,textConfig:e};this.updateLayerAndData(t),this.sourcesWithLayers.geometryLabel.show(cr(this.sourcesWithLayers.geometry.shownFeatures)),this.config=t,this.emitConfigChange()}updateLayerAndData(e){const[t,i]=ir(this.fillLayerID,this.outlineLayerID,e,this.defaultColor),r=rr(this.titleLayerID,e,this.lightDark);if(pe(t,this.geometryFillLayerSpecs,this.mapLibreMap),pe(i,this.geometryOutlineLayerSpecs,this.mapLibreMap),pe(r,this.titleLayerSpecs,this.mapLibreMap),this.geometryFillLayerSpecs=t,this.geometryOutlineLayerSpecs=i,this.titleLayerSpecs=r,this.lineLabelLayerSpecs){const t=sr(this.lineLabelLayerID,e,this.lightDark);pe(t,this.lineLabelLayerSpecs,this.mapLibreMap),this.lineLabelLayerSpecs=t}}discardShownData(){this.lastRawInput=null}restoreDataAndConfigImpl(){const e=this.lastRawInput;this.initSourcesWithLayers(this.config,!0),this.config&&this._applyConfig(this.config),e&&this.show(e)}async show(e){await this.waitUntilModuleReady(),this.lastRawInput=e;const{transformFeaturesForDisplay:t}=this.config??{},i=t?t(e):e,r=this.sourcesWithLayers.geometry;r.show(lr(i,this.config,this.lightDark)),this.sourcesWithLayers.geometryLabel.show(cr(r.shownFeatures));for(const s of this.shownFeaturesHandlers)s(e)}async clear(){await this.waitUntilModuleReady(),this.sourcesWithLayers.geometry.clear(),this.sourcesWithLayers.geometryLabel.clear()}getShown(){return{geometry:this.sourcesWithLayers.geometry.shownFeatures,geometryLabel:this.sourcesWithLayers.geometryLabel.shownFeatures}}get events(){return this.buildEvents(this.moduleEventsWithShown(["geometry","geometryLabel"],this.shownFeaturesHandlers),{geometry:this.userEvents(["geometry"]),geometryLabel:this.userEvents(["geometryLabel"])})}},ur={timeMinutes:"min",distanceKM:"km",remainingChargeCPT:"% remaining",spentChargePCT:"% spent",spentFuelLiters:"L"},dr=(e,t,i="filled")=>{const r=e.map((e,r)=>({...e,properties:{...e.properties,title:t[r],theme:i}}));return"inverted"===i?(e=>[...e.map((t,i)=>{const r=0===i?C(t):b(R([e[i-1],t])),{title:s,theme:a,...o}=t.properties??{};return{...t,geometry:r?.geometry??t.geometry,properties:o}}),...e.map(e=>({...e,id:void 0,properties:{...e.properties,theme:"filled"}}))])(r):r},pr=(e,t="filled",i)=>{const r=e.features,s=r.map((e,t)=>{if(i)return i(e,t);const r=e.properties?.budget;return void 0!==r?.value&&r?.type?`${r.value} ${ur[r.type]??r.type}`:String(t+1)});return{type:"FeatureCollection",...e.bbox&&{bbox:e.bbox},features:dr(r,s,t)}},fr=(e="fadedRainbow",t="lowestLabel")=>({beforeLayerConfig:t,line:{width:["case",["==",["get","theme"],"outline"],5,1],color:["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],er],"grey"],opacity:["case",["==",["get","theme"],"outline"],.9,1]},fill:{color:e,opacity:["case",["==",["get","theme"],"outline"],0,.6]},lineLabelConfig:{}}),yr=(e="fadedRainbow",t,i,r)=>{const s=fr(e,i),a=e=>pr(e,t,r);return"inverted"!==t?{...s,transformFeaturesForDisplay:a}:{...s,line:{...s.line,opacity:["case",["==",["get","theme"],"filled"],1,0]},fill:{...s.fill,opacity:["case",["==",["get","theme"],"filled"],0,.6]},lineLabelConfig:{textOpacity:["case",["==",["get","theme"],"filled"],1,0],textOffset:["case",["==",["get","theme"],"filled"],["literal",[0,-1]],["literal",[0,1]]]},transformFeaturesForDisplay:a}},mr=["filled","outline","inverted"],gr=class e extends we{static async get(t,i){return await he(t),await Le(t,nt,"hillshade"),dt(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(nt);if(!t)throw re(`init ${e.name} with source ID ${nt}`);return{hillshade:new We(this.mapLibreMap,t)}}_applyConfig(e){return this._setVisible(e?.visible??!1,!1),e}setVisible(e){this._setVisible(e)}_setVisible(e,t=!0){this.tomtomMap.mapReady&&this.sourcesWithLayers.hillshade.setLayersVisible(e),t&&(this.config={...this.config,visible:e},this.emitConfigChange())}isVisible(){return this.sourcesWithLayers.hillshade.isAnyLayerVisible()}get events(){return this.moduleEvents(["hillshade"])}},_r=["standardLight","standardDark","drivingLight","drivingDark","monoLight","monoDark","satellite"],Lr=["trafficIncidents","trafficFlow","hillshade"],Sr="stopDuration",Ar=[["coalesce",["get",Sr],""],{"text-color":"#727C85","text-font":["literal",[Je]]}],Ir=["has",Sr],Er="#36A8F0",br="#105287",Rr="#ABAFB3",Tr="#3C4956",Cr="#727C85",vr=["interpolate",["linear"],["zoom"],1,3,5,4,10,7,18,10],wr=["==",["get","routeState"],"selected"],Or=["==",["get","routeState"],"deselected"],Nr=["interpolate",["linear"],["zoom"],1,5,5,6,10,10,18,14],Mr={s:["interpolate",["linear"],["zoom"],1,2,5,3,10,5,18,7],m:vr,l:["interpolate",["linear"],["zoom"],1,5,5,6,10,11,18,15]},Dr={s:["interpolate",["linear"],["zoom"],1,4,5,5,10,8,18,11],m:Nr,l:["interpolate",["linear"],["zoom"],1,7,5,9,10,14,18,19]},xr={s:["interpolate",["linear"],["zoom"],8,.45,22,.6],m:["interpolate",["linear"],["zoom"],8,.6,22,.8],l:["interpolate",["linear"],["zoom"],8,.75,22,1]},Fr=e=>Mr[e??"m"],Pr=e=>Dr[e??"m"],Ur=e=>xr[e??"m"],Hr={s:["interpolate",["linear"],["zoom"],1,8,5,9,10,12,18,15],m:["interpolate",["linear"],["zoom"],1,9,5,11,10,15,18,20],l:["interpolate",["linear"],["zoom"],1,12,5,14,10,19,18,24]},kr=e=>Hr[e??"m"],Wr={s:["interpolate",["linear"],["zoom"],16,8,22,12],m:["interpolate",["linear"],["zoom"],16,12,22,17],l:["interpolate",["linear"],["zoom"],16,17,22,24]},Gr={s:["interpolate",["linear"],["zoom"],16,10,22,14],m:["interpolate",["linear"],["zoom"],16,14,22,20],l:["interpolate",["linear"],["zoom"],16,20,22,28]},Br=e=>Wr[e??"m"],Vr=e=>Gr[e??"m"],jr="#AD0000",$r="#FB2D09",zr="#FFC105",Yr="#f58240",qr="#000000",Kr="#C7D2D8",Xr="rgba(190, 39, 27, 1)",Zr="rgba(137, 150, 168, 1)",Jr=e=>!1===e?.visible?"":e?.title??["format",["get","title"],{},"\n",{},["get","chargingPower"],{}," • ",{},...Ar],Qr=e=>{const t=Wt(((e=[])=>{const t=/* @__PURE__ */new Map;for(const i of e){if(!i.image)continue;const e={x:i.offsetX??0,y:i.offsetY??0};0===e.x&&0===e.y||t.set(i.id,e)}return t})(e?.icon?.customIcons));return{...wt,filter:wr,minzoom:4,layout:{...wt.layout,"text-field":Jr(e?.text),...t&&{"icon-offset":t}},paint:{...wt.paint}}},es={filter:wr,minzoom:16},ts={"line-cap":"round"},is=e=>({...es,type:"line",layout:ts,paint:{"line-width":Vr(e),"line-color":"grey"}}),rs=e=>({...es,type:"line",layout:ts,paint:{"line-width":Br(e),"line-color":"white"}}),ss="instruction-arrow",as={...es,type:"symbol",layout:{"icon-allow-overlap":!0,"icon-image":ss,"icon-rotation-alignment":"map","icon-rotate":["get","lastPointBearingDegrees"],"icon-size":["interpolate",["linear"],["zoom"],16,1,22,2]}},os=e=>({filter:wr,type:"line",layout:{"line-join":"round"},paint:{"line-width":Fr(e),"line-color":"#6dc4ed"}}),ns={filter:wr,type:"symbol",minzoom:6,maxzoom:16.5,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-image":"poi-ferry_terminal","icon-size":["interpolate",["linear"],["zoom"],6,.8,16.5,1],"icon-ignore-placement":!0}},ls={type:"line",layout:{"line-join":"round","line-cap":"round","line-sort-key":["get","index"]}},cs=e=>({...ls,filter:Or,paint:{"line-color":Tr,"line-width":Pr(e)}}),hs=e=>({...ls,filter:Or,paint:{"line-color":Rr,"line-width":Fr(e)}}),us=(e,t)=>({...ls,filter:wr,paint:{"line-color":t??"#105287","line-width":Pr(e)}}),ds=(e,t)=>({...ls,filter:wr,paint:{"line-color":t??"#36A8F0","line-width":Fr(e)}}),ps={type:"symbol",layout:{"symbol-placement":"line","icon-image":"roads-arrow-white","icon-rotate":180}},fs="selected-route-summary-popup",ys="deselected-route-summary-popup",ms=e=>({filter:wr,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-width":kr(e),"line-color":"#BEBFFA"}}),gs={filter:wr,type:"symbol",minzoom:4,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-image":"poi-toll_plaza","icon-size":["interpolate",["linear"],["zoom"],4,.8,16.5,1]}},_s=["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],Ls=["match",["get","magnitudeOfDelay"],"unknown",Xr,Zr],Ss=["match",["get","magnitudeOfDelay"],"minor",Yr,"moderate",$r,"major",jr,"indefinite","#666666",qr],As=e=>({type:"line",layout:{"line-cap":"round"},paint:{"line-width":Fr(e),"line-color":["match",["get","magnitudeOfDelay"],"minor",zr,"moderate",$r,"major",jr,Kr]}}),Is=e=>({type:"line",filter:_s,layout:{"line-join":"round"},paint:{"line-width":Fr(e),"line-color":Ls,"line-dasharray":[1.5,1]}}),Es={filter:wr,type:"symbol",minzoom:6,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-ignore-placement":!0}},bs={...Es,filter:["all",["has","jamIconID"],Es.filter],layout:{...Es.layout,"icon-image":["get","jamIconID"],"icon-anchor":"bottom-left","text-anchor":"bottom-left","text-field":["get","title"],"text-font":[Ze],"text-offset":[3.9,-1.4],"text-size":13},paint:{...Es.paint,"text-color":Ss,"text-halo-color":"#FFFFFF","text-halo-width":1}},Rs={...Es,filter:["all",["has","causeIconID"],Es.filter],layout:{...Es.layout,"icon-image":["get","causeIconID"],"icon-anchor":"bottom-right"},paint:{...Es.paint}},Ts=e=>({filter:wr,type:"line",layout:{"line-join":"round"},paint:{"line-width":Fr(e),"line-color":"#000000","line-opacity":.3}}),Cs=e=>({filter:wr,type:"line",layout:{"line-join":"round"},paint:{"line-color":br,"line-width":Fr(e)}}),vs=e=>({filter:wr,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":Er,"line-width":Fr(e),"line-dasharray":[0,1.5]}}),ws="traffic-clear",Os="traffic-major",Ns="traffic-moderate",Ms="traffic-minor",Ds=["has","formattedTraffic"],xs=e=>{const t=void 0!==e?Ot(fs,e):fs,i=void 0!==e?Ot(ys,e):ys,r=void 0!==e?Ot(ws,e):ws,s=void 0!==e?Ot(Os,e):Os,a=void 0!==e?Ot(Ns,e):Ns,o=void 0!==e?Ot(Ms,e):Ms;return{type:"symbol",layout:{"icon-image":["case",wr,t,i],"symbol-placement":"point","icon-rotation-alignment":"viewport","text-rotation-alignment":"viewport","symbol-sort-key":["case",wr,0,1],"icon-text-fit":"both","icon-text-fit-padding":[10,5,5,10],"text-font":[Qe],"text-size":13,"icon-padding":0,"text-justify":"left","text-line-height":1.5,"text-field":["format",["get","formattedDuration"],{"text-font":["literal",[Ze]],"text-color":["case",wr,"black",Cr]},["concat","\t\t",["get","formattedDistance"]],{"text-color":Cr},["case",Ds,"\n",""],{},["image",["case",Ds,["match",["get","magnitudeOfDelay"],"major",s,"moderate",a,"minor",o,r],""]],{},["case",Ds,["concat"," ",["get","formattedTraffic"]],""],{"text-font":["literal",[Ze]],"text-color":Ss}]},paint:{"icon-translate":[0,-35],"text-translate":[0,-35]}}},Fs=xs(),Ps="start",Us="middle",Hs="finish",ks="stopDisplayIndex",Ws="waypointStart",Gs="waypointStop",Bs="waypointFinish",Vs=["format",["coalesce",["get",St],""],{},["case",["all",["has",St],Ir],"\n",""],{},...Ar],js={"text-field":["get",ks],"text-font":[Ze],"text-size":["interpolate",["linear"],["zoom"],13,14,18,16],"text-offset":[0,-1.6],"icon-anchor":"bottom","text-allow-overlap":!0},$s={type:"symbol",paint:{...Tt,"text-color":"#ffffff"},layout:{...Rt,...js,"symbol-sort-key":["abs",["-",["get","index"],1e3]]}},zs={type:"symbol",paint:{...vt,"text-color":"black","text-halo-width":1.5,"text-halo-color":"#ffffff"},layout:{...Ct,"text-field":Vs,"text-anchor":"top","text-offset":[0,.4]}},Ys=(e,t)=>e&&t&&(e.startsWith("route")||e.startsWith("waypoint"))?`${t}-${e}`:e,qs=(e,t)=>e&&t?Object.fromEntries(Object.entries(e).map(([e,i])=>[e,i?.beforeID?{...i,beforeID:Ys(i.beforeID,t)}:i])):e,Ks=(e,t)=>t?{...e,...t,...t.paint&&{paint:{...e.paint,...t.paint}},...t.layout&&{layout:{...e.layout,...t.layout}}}:e,Xs=(e,t)=>e&&void 0!==t?`${e}-${t}`:e,Zs=(e={},t,i)=>{const r=e.layers,s=r?.sections,a=e.theme?.mainColor,o=a?te(a,.4):void 0,n=e.theme?.routeWidth,l=e.theme?.waypointSize,c=Ur(l);return{mainLines:{routeLineArrows:Ks({...ps,beforeID:at.lowestLabel},r?.mainLines?.routeLineArrows),routeLine:Ks({...ds(n,a),beforeID:Ys("routeIncidentBackgroundLine",t)},r?.mainLines?.routeLine),routeOutline:Ks({...us(n,o),beforeID:Ys("routeLine",t)},r?.mainLines?.routeOutline),routeDeselectedLine:Ks({...hs(n),beforeID:Ys("routeOutline",t)},r?.mainLines?.routeDeselectedLine),routeDeselectedOutline:Ks({...cs(n),beforeID:Ys("routeDeselectedLine",t)},r?.mainLines?.routeDeselectedOutline),...qs(r?.mainLines?.additional,t)},waypoints:{routeWaypointSymbol:Ks({...$s,layout:{...$s.layout,"icon-size":c},beforeID:Ys("routeSummaryBubbleSymbol",t)},r?.waypoints?.routeWaypointSymbol),routeWaypointLabel:Ks({...zs,beforeID:Ys("routeWaypointSymbol",t)},r?.waypoints?.routeWaypointLabel),...qs(r?.waypoints?.additional,t)},chargingStops:{routeChargingStopSymbol:Ks({...Qr(e.chargingStops),beforeID:Ys("routeWaypointSymbol",t)},r?.chargingStops?.routeChargingStopSymbol),...qs(r?.chargingStops?.additional,t)},sections:{incident:{routeIncidentJamSymbol:Ks({...bs,beforeID:Ys("routeChargingStopSymbol",t)},s?.incident?.routeIncidentJamSymbol),routeIncidentCauseSymbol:Ks({...Rs,beforeID:Ys("routeChargingStopSymbol",t)},s?.incident?.routeIncidentCauseSymbol),routeIncidentBackgroundLine:Ks({...As(n),beforeID:Ys("routeIncidentDashedLine",t)},s?.incident?.routeIncidentBackgroundLine),routeIncidentDashedLine:Ks({...Is(n),beforeID:Ys("routeTunnelLine",t)},s?.incident?.routeIncidentDashedLine),...qs(s?.incident?.additional,t)},ferry:{routeFerryLine:Ks({...os(n),beforeID:Ys("routeLineArrows",t)},s?.ferry?.routeFerryLine),routeFerrySymbol:Ks({...ns,beforeID:Ys("routeIncidentJamSymbol",t)},s?.ferry?.routeFerrySymbol),...qs(s?.ferry?.additional,t)},tollRoad:{routeTollRoadOutline:Ks({...ms(n),beforeID:Ys("routeDeselectedOutline",t)},s?.tollRoad?.routeTollRoadOutline),routeTollRoadSymbol:Ks({...gs,beforeID:Ys("routeChargingStopSymbol",t)},s?.tollRoad?.routeTollRoadSymbol),...qs(s?.tollRoad?.additional,t)},tunnel:{routeTunnelLine:Ks({...Ts(n),beforeID:Ys("routeLineArrows",t)},s?.tunnel?.routeTunnelLine),...qs(s?.tunnel?.additional,t)},vehicleRestricted:{routeVehicleRestrictedBackgroundLine:Ks({...Cs(n),beforeID:Ys("routeVehicleRestrictedForegroundLine",t)},s?.vehicleRestricted?.routeVehicleRestrictedBackgroundLine),routeVehicleRestrictedForegroundLine:Ks({...vs(n),beforeID:at.lowestLabel},s?.vehicleRestricted?.routeVehicleRestrictedForegroundLine),...qs(s?.vehicleRestricted?.additional,t)}},instructionLines:{routeInstructionLine:Ks({...rs(n),beforeID:at.lowestLabel},r?.instructionLines?.routeInstructionLine),routeInstructionOutline:Ks({...is(n),beforeID:Ys("routeInstructionLine",t)},r?.instructionLines?.routeInstructionOutline),...qs(r?.instructionLines?.additional,t)},instructionArrows:{routeInstructionArrowSymbol:Ks({...as,beforeID:Ys("routeInstructionLine",t),...void 0!==i&&{layout:{...as.layout,"icon-image":Xs(as.layout?.["icon-image"],i)}}},r?.instructionArrows?.routeInstructionArrowSymbol),...qs(r?.instructionArrows?.additional,t)},summaryBubbles:{routeSummaryBubbleSymbol:Ks(void 0===i?Fs:xs(i),r?.summaryBubbles?.routeSummaryBubbleSymbol),...qs(r?.summaryBubbles?.additional,t)}}},Js=Zs();oe()&&(Fe=ne(le('<svg xmlns="http://www.w3.org/2000/svg" width="50" height="50">\n <path d="M1.562 40.569L25 1.562l23.438 39.007L25 27.566 1.562 40.569z" fill="#fff"/>\n <path d="M25.369.107c.782.429.506.167.917.682l23.438 39.007c.79 1.316-.671 2.829-2.014 2.085L25 29.281l-22.71 12.6c-1.343.744-2.804-.769-2.014-2.085L23.714.789c.461-.694.9-.682 1.656-.682zM25 1.562L1.562 40.569 25 27.566l23.438 13.003L25 1.562z"\n fill="gray"/>\n</svg>\n')));var Qs,ea=e=>{if(!oe())return;const t=le('<svg xmlns="http://www.w3.org/2000/svg" width="160" height="65">\n <g filter="url(#A)">\n <rect id="pin" x="81.899" y="47" width="10" height="10" rx="2" transform="rotate(45 81.899 47)"/>\n <rect id="bubble" x="10" y="10" width="140" height="45" rx="12"/>\n </g>\n <defs>\n <filter id="A">\n <feDropShadow dx="0" dy="2" stdDeviation="4" flood-opacity=".3"/>\n </filter>\n </defs>\n</svg>\n');return t.querySelector("#bubble")?.setAttribute("fill",e),t.querySelector("#pin")?.setAttribute("fill",e),ne(t)},ta={pixelRatio:2,stretchX:[[20,45],[100,130]],stretchY:[[20,35]],content:[10,10,130,45]},ia=e=>{if(!oe())return;const t=le('<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32">\n <g id="main">\n <path fill-rule="evenodd"\n d="M11.389 4H9.025a.86.86 0 0 0-.517.173l-.001-.001a.5.5 0 0 1-.464.059l-.028-.011a.5.5 0 0 1-.129-.83A1.86 1.86 0 0 1 9.025 3h2.364a2 2 0 0 1 1.789 1.106l1.02 2.04c.471.176.802.63.802 1.156v.803c0 .543 0 .815-.071 1.038a1.5 1.5 0 0 1-.914.953c-.219.08-.491.092-1.034.114l-1.481.062v-.166-.803a2.23 2.23 0 0 0-1.055-1.897l-.74-1.479 2.326.033h.955l-.703-1.406A1 1 0 0 0 11.389 4zM12 8.4a1 1 0 1 1 2 0 .5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5z"/>\n <path d="M11.833 11.115c0-.109.089-.198.198-.198h1.979c.109 0 .198.089.198.198 0 .328-.266.594-.594.594h-1.187c-.328 0-.594-.266-.594-.594z"/>\n <path fill-rule="evenodd"\n d="M1.802 8.146C1.331 8.321 1 8.776 1 9.302v.803c0 .543 0 .815.071 1.038a1.5 1.5 0 0 0 .914.953c.219.08.491.092 1.034.114l2.731.114 2.731-.114c.543-.023.814-.034 1.034-.114a1.5 1.5 0 0 0 .914-.953c.071-.223.071-.494.071-1.038v-.803c0-.526-.331-.98-.802-1.156l-1.02-2.04A2 2 0 0 0 6.889 5H4.611a2 2 0 0 0-1.789 1.106l-1.02 2.04zM6.889 6H4.611a1 1 0 0 0-.894.553l-.703 1.406h.955 3.563.955l-.703-1.406A1 1 0 0 0 6.889 6zM2 10.4a1 1 0 1 1 2 0 .5.5 0 0 1-.5.5h-1a.5.5 0 0 1-.5-.5zm6.5-1a1 1 0 0 0-1 1 .5.5 0 0 0 .5.5h1a.5.5 0 0 0 .5-.5 1 1 0 0 0-1-1z"/>\n <path d="M1.792 13.115c0-.109.089-.198.198-.198h1.979c.109 0 .198.089.198.198 0 .328-.266.594-.594.594H2.385c-.328 0-.594-.266-.594-.594zm5.739-.198c-.109 0-.198.089-.198.198 0 .328.266.594.594.594h1.188c.328 0 .594-.266.594-.594 0-.109-.089-.198-.198-.198h-1.98z"/>\n </g>\n</svg>\n'),i=t.querySelector("#main");return i.setAttribute("transform","scale(2)"),i.setAttribute("fill",e),ne(t)},ra=(e,t)=>{if(!oe())return;const i=ce(t);return e&&i.appendChild(e),ne(i)},sa=e=>{if(oe())return ra(le('<svg xmlns="http://www.w3.org/2000/svg" width="120" height="140">\n <path d="M63.734 86.383c-1.404.026-2.78-.393-3.93-1.197s-2.01-1.949-2.46-3.271l-3.15-9.339c-1.093-3.403-3.748-6.089-7.154-7.238L37.5 62.21c-2.742-.902-4.567-3.477-4.5-6.345-.058-2.874 1.761-5.457 4.5-6.388l36-11.886c2.461-.88 5.213-.27 7.062 1.567s2.466 4.571 1.578 7.015L70.17 81.918c-.938 2.719-3.54 4.526-6.436 4.469h0z"\n fill="#f4f5f6"/>\n</svg>\n'),e)},aa=e=>{if(oe())return ra(le('<svg xmlns="http://www.w3.org/2000/svg" width="120" height="140">\n <path d="M33 83.404a2.99 2.99 0 0 1-3-2.978V44.681a2.99 2.99 0 1 1 6 0v35.745a2.99 2.99 0 0 1-3 2.978zm48-38.723H39v17.872h42V44.681zm3.878 37.851a3.02 3.02 0 0 0 4.244 0c.561-.559.878-1.317.878-2.106V44.681a2.99 2.99 0 1 0-6 0v35.745c0 .789.317 1.547.878 2.106z"\n fill="#f4f5f6"/>\n</svg>\n'),e)},oa=(e={},t)=>Object.entries(e).map(([e,i])=>({...i,id:t?`${t}-${e}`:e})),na=(e={},t)=>({mainLines:oa(e.mainLines,t),waypoints:oa(e.waypoints,t),chargingStops:oa(e?.chargingStops,t),ferries:oa(e.sections?.ferry,t),incidents:oa(e.sections?.incident,t),tollRoads:oa(e.sections?.tollRoad,t),tunnels:oa(e.sections?.tunnel,t),vehicleRestricted:oa(e.sections?.vehicleRestricted,t),instructionLines:oa(e.instructionLines,t),instructionArrows:oa(e.instructionArrows,t),summaryBubbles:oa(e.summaryBubbles,t)}),la=(e,t,i)=>{const r=l.instance.get().displayUnits,s=e?.displayUnits;return{...e,...s?{}:{displayUnits:r},layers:Zs(e,t,i)}},ca=(e,t)=>{const i=t?.chargingStops?.icon;if(i?.mapping){const t=i.mapping;switch(t.basedOn){case"chargingSpeed":if(e.properties.chargingConnectionInfo?.chargingSpeed)return t.value[e.properties.chargingConnectionInfo?.chargingSpeed];break;case"custom":return t.fn(e)}}return ae("7309")},ha=e=>{const t=e.properties;return t.chargingParkName??t.chargingParkOperatorName},ua=(e,t)=>{const i=[];if(!1!==t?.chargingStops?.visible)for(const r of e.features)for(const e of r.properties.sections.leg){const s=e.summary.chargingInformationAtEndOfLeg;if(s){const a=s.properties,o=p(e.summary.stopTimeInSeconds??a.chargingTimeInSeconds,t?.displayUnits?.time);i.push({...s,properties:{...s.properties,id:s.properties.chargingParkId??f(),iconID:ca(s,t),title:ha(s),chargingPower:`${a.chargingConnectionInfo?.chargingPowerInkW} kW`,chargingDuration:p(a.chargingTimeInSeconds,t?.displayUnits?.time),...o&&{stopDuration:o},routeState:r.properties.routeState}})}}return{type:"FeatureCollection",features:i}},da=e=>e.categories.includes("jam"),pa=e=>{const t=(e=>{if(da(e))return p(e.delayInSeconds)})(e),i=((e,t)=>da(e)?`traffic-jam-${e.magnitudeOfDelay??"unknown"}-${(e=>e?.length?e.length<6?"small":e.length<8?"medium":"large":"collapsed")(t)}`:null)(e,t),r=(e=>{const t=e.categories.find(e=>"jam"!==e);return t?(e=>{switch(e){case"accident":return"traffic-incidents-accident";case"roadworks":return"traffic-incidents-roadworks";case"road-closed":return"traffic-incidents-road_closed";case"lane-closed":case"narrow-lanes":return"traffic-incidents-lane_closed";case"danger":case"animals-on-road":return"traffic-incidents-danger";case"broken-down-vehicle":return"traffic-incidents-broken_down_vehicle";case"wind":return"traffic-incidents-wind";case"fog":return"traffic-incidents-fog";case"rain":return"traffic-incidents-rain";case"frost":return"traffic-incidents-frost";case"flooding":return"traffic-incidents-flooding";default:return null}})(t):null})(e);return{...e,...i&&{jamIconID:i},...r&&{causeIconID:r},...t&&{title:t}}},fa=(e,t,i)=>{let r;switch(t){case"start":r=Ws;break;case"finish":r=Bs;break;default:r=Gs}return void 0!==i?Ot(r,i):r},ya=(e,t,i,r)=>({type:"FeatureCollection",features:e.map((s,a)=>{if(!s)return null;const o=(e=>{return Array.isArray(e)?{type:"Feature",geometry:{type:"Point",coordinates:e},properties:{}}:"Point"===e.type?{type:"Feature",geometry:t=e,properties:{},...t.bbox&&{bbox:t.bbox}}:e;var t})(s),n=((e,t)=>0===e?Ps:e<t-1?Us:Hs)(a,e.length),l=(e=>{const t=e?.properties;return t?.poi?.name??t?.address?.freeformAddress??void 0})(o),c=o.id??f(),h=p(o.properties.pauseDurationSeconds,r);return{...o,..."main-when-available"===t?.entryPoints&&{geometry:{type:"Point",coordinates:m(o,{useEntryPoint:"main-when-available"})}},id:c,properties:{...o.properties,id:c,index:a,indexType:n,...l&&{title:l},...h&&{stopDuration:h},iconID:fa(0,n,i),..."middle"===n&&{stopDisplayIndex:a}}}}).filter(e=>e)}),ma=(e,t,i)=>({type:"FeatureCollection",features:e.features.flatMap(e=>((e,t,i)=>e.properties.sections[t]?.map(t=>{const r=t.id??f();return{type:"Feature",id:r,geometry:{type:"LineString",coordinates:e.geometry.coordinates.slice(t.startPointIndex,t.endPointIndex+1)},properties:{...i?i(t,e.properties):t,routeState:e.properties.routeState,routeIndex:e.properties.index,id:r}}})||[])(e,t,i))}),ga=(e,t)=>t.show(((e,t)=>({...t,features:t.features.map(t=>({...t,properties:{...t.properties,routeState:e.features[t.properties.routeIndex||0].properties.routeState}}))}))(e,t.shownFeatures)),_a=(e,t=0)=>{const i="features"in e?e:{type:"FeatureCollection",features:[e]};return{...i,features:i.features.map((e,i)=>{const r=e.id??f();return{...e,id:r,properties:{...e.properties,id:r,routeState:i===t?"selected":"deselected"}}})}},La=(e,t)=>e.some(e=>e.magnitudeOfDelay===t),Sa=(e,t)=>({type:"FeatureCollection",features:e.features.map(e=>{const i=e.properties.summary,r=e.geometry.coordinates,s=p(i.trafficDelayInSeconds,t?.time),a=(e=>{const t=e.properties.sections.traffic;if(t?.length)return La(t,"major")?"major":La(t,"moderate")?"moderate":La(t,"minor")?"minor":void 0})(e),o=e.id??f();return{type:"Feature",id:o,geometry:{type:"Point",coordinates:r[Math.round(r.length/2)]},properties:{id:o,routeIndex:e.properties.index,routeState:e.properties.routeState,formattedDistance:d(i.lengthInMeters,t?.distance),...a&&{magnitudeOfDelay:a},...s&&{formattedTraffic:s},formattedDuration:p(i.travelTimeInSeconds,t?.time)}}})}),Aa=class e extends ve{static async create(t,i){return await he(t),new e(t,i)}constructor(e,t){super(e,t),this.shownFeaturesHandlers=[]}createSourcesWithLayers(e){const t=Ot("routes",this.instanceIndex);return{mainLines:new Ve(this.mapLibreMap,`${t}-mainLines`,e.mainLines,!1),waypoints:new Ve(this.mapLibreMap,`${t}-waypoints`,e.waypoints,!1),incidents:new Ve(this.mapLibreMap,`${t}-incidents`,e.incidents,!1),ferries:new Ve(this.mapLibreMap,`${t}-ferries`,e.ferries,!1),chargingStops:new Ve(this.mapLibreMap,`${t}-chargingStops`,e.chargingStops,!1),tollRoads:new Ve(this.mapLibreMap,`${t}-tollRoads`,e.tollRoads,!1),tunnels:new Ve(this.mapLibreMap,`${t}-tunnels`,e.tunnels,!1),vehicleRestricted:new Ve(this.mapLibreMap,`${t}-vehicleRestricted`,e.vehicleRestricted,!1),instructionLines:new Ve(this.mapLibreMap,`${t}-instructionLines`,e.instructionLines,!1),instructionArrows:new Ve(this.mapLibreMap,`${t}-instructionArrows`,e.instructionArrows,!1),summaryBubbles:new Ve(this.mapLibreMap,`${t}-summaryBubbles`,e.summaryBubbles,!1)}}_initSourcesWithLayers(e,t){t||(this.layerIDPrefix=Ot("routes",this.instanceIndex)),this.layersSpecs=na(la(e,this.layerIDPrefix,this.instanceIndex).layers,this.layerIDPrefix);const i=this.createSourcesWithLayers(this.layersSpecs);ge(Object.values(i).flatMap(e=>e._layerSpecs),this.mapLibreMap);const r={fillColor:e?.theme?.mainColor,...e?.waypoints?.icon?.style},s={pixelRatio:2},a=Ot(Ws,this.instanceIndex),o=Ot(Gs,this.instanceIndex),n=Ot(Bs,this.instanceIndex),l=Ot(ss,this.instanceIndex),c=Ot(fs,this.instanceIndex),h=Ot(ys,this.instanceIndex),u=Ot(ws,this.instanceIndex),d=Ot(Os,this.instanceIndex),p=Ot(Ns,this.instanceIndex),f=Ot(Ms,this.instanceIndex);this.addImageIfNotExisting(a,sa(r),s),this.addImageIfNotExisting(o,ra(void 0,r),s),this.addImageIfNotExisting(n,aa(r),s),this.addImageIfNotExisting(l,Fe,s),this.addImageIfNotExisting(c,ea("white"),ta),this.addImageIfNotExisting(h,ea("#EEEEEE"),ta),this.addImageIfNotExisting(u,ia(qr),s),this.addImageIfNotExisting(d,ia(jr),s),this.addImageIfNotExisting(p,ia($r),s),this.addImageIfNotExisting(f,ia(Yr),s);for(const y of e?.chargingStops?.icon?.customIcons??[])this.addImageIfNotExisting(y.id,y.image,{pixelRatio:y.pixelRatio??2});return i}_applyConfig(e){const i=la(e,this.layerIDPrefix,this.instanceIndex);if(this.config){const e=na(i.layers,this.layerIDPrefix);Object.keys(e).forEach(t=>{const i=t;fe(e[i],this.layersSpecs[i],this.sourcesWithLayers[i],this.mapLibreMap)});const t=Object.values(this.sourcesWithLayers);ge(t.flatMap(e=>e._layerSpecs),this.mapLibreMap),t.forEach(e=>e.setLayersVisible(!!e.shownFeatures.features.length)),this.layersSpecs=e}if(e?.theme?.mainColor!==this.config?.theme?.mainColor){const t={fillColor:e?.theme?.mainColor,...e?.waypoints?.icon?.style},i={pixelRatio:2};Se("add-or-update",Ot(Ws,this.instanceIndex),sa(t),this.mapLibreMap,i),Se("add-or-update",Ot(Gs,this.instanceIndex),ra(void 0,t),this.mapLibreMap,i),Se("add-or-update",Ot(Bs,this.instanceIndex),aa(t),this.mapLibreMap,i)}const r=!1!==i.summaryBubbles?.visible,s=!t(this.config?.summaryBubbles?.visible,i.summaryBubbles?.visible),a=!t(this.config?.displayUnits,i.displayUnits),o=this.sourcesWithLayers.summaryBubbles.shownFeatures.features.length>0,n=this.sourcesWithLayers.mainLines.shownFeatures.features.length>0;return!r&&s?this.sourcesWithLayers.summaryBubbles.clear():r&&(s&&n||a&&o)&&this.sourcesWithLayers.summaryBubbles.show(Sa(this.sourcesWithLayers.mainLines.shownFeatures,i.displayUnits)),i}discardShownData(){}restoreDataAndConfigImpl(){const e=Object.entries(this.sourcesWithLayers).map(e=>({[e[0]]:e[1].shownFeatures})).reduce((e,t)=>({...e,...t}),{});this.initSourcesWithLayers(this.config,!0),this._applyConfig(this.config);for(const t of Object.keys(e))this.sourcesWithLayers[t].show(e[t])}addImageIfNotExisting(e,t,i){Se("if-not-in-sprite",e,t,this.mapLibreMap,i)}async showRoutes(e,t){const i=_a(e,t?.selectedIndex);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(i),this.sourcesWithLayers.vehicleRestricted.show(ma(i,"vehicleRestricted")),this.sourcesWithLayers.incidents.show(ma(i,"traffic",pa)),this.sourcesWithLayers.chargingStops.show(ua(i,this.config)),this.sourcesWithLayers.ferries.show(ma(i,"ferry")),this.sourcesWithLayers.tunnels.show(ma(i,"tunnel")),this.sourcesWithLayers.tollRoads.show(ma(i,"tollRoad")),this.sourcesWithLayers.instructionLines.show((e=>({type:"FeatureCollection",features:e.features.flatMap((e,t)=>e.properties.guidance?.instructions?.filter(e=>e.routePath?.length).map(i=>({type:"Feature",geometry:{type:"LineString",coordinates:i.routePath.map(e=>e.point)},properties:{...i,id:f(),routeIndex:t,routeState:e.properties.routeState}}))||[])}))(i)),this.sourcesWithLayers.instructionArrows.show((e=>({type:"FeatureCollection",features:e.features.flatMap((e,t)=>e.properties.guidance?.instructions?.filter(e=>e.routePath?.length&&e.routePath.length>1).map(i=>{const r=[i.routePath[i.routePath.length-2]?.point,i.routePath[i.routePath.length-1]?.point];return{type:"Feature",geometry:{type:"Point",coordinates:r[1]},properties:{...i,id:f(),routeIndex:t,routeState:e.properties.routeState,lastPointBearingDegrees:I(r[0],r[1])}}})||[])}))(i)),!1!==this.config?.summaryBubbles?.visible?this.sourcesWithLayers.summaryBubbles.show(Sa(i,this.config?.displayUnits)):this.sourcesWithLayers.summaryBubbles.clear();for(const r of this.shownFeaturesHandlers)r({routes:e})}async clearRoutes(){await this.waitUntilModuleReady();for(const e of Object.keys(this.sourcesWithLayers))"waypoints"!==e&&this.sourcesWithLayers[e].clear()}async selectRoute(e){const t=_a(this.sourcesWithLayers.mainLines.shownFeatures,e);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(t),this.sourcesWithLayers.chargingStops.show(ua(t,this.config)),ga(t,this.sourcesWithLayers.vehicleRestricted),ga(t,this.sourcesWithLayers.incidents),ga(t,this.sourcesWithLayers.ferries),ga(t,this.sourcesWithLayers.tollRoads),ga(t,this.sourcesWithLayers.tunnels),ga(t,this.sourcesWithLayers.instructionLines),ga(t,this.sourcesWithLayers.instructionArrows),ga(t,this.sourcesWithLayers.summaryBubbles)}async showWaypoints(e){const t=Array.isArray(e)?ya(e,this.config?.waypoints,this.instanceIndex,this.config?.displayUnits?.time):ya(e.features,this.config?.waypoints,this.instanceIndex,this.config?.displayUnits?.time);await this.waitUntilModuleReady(),this.sourcesWithLayers.waypoints.show(t);for(const i of this.shownFeaturesHandlers)i({waypoints:e})}async clearWaypoints(){await this.waitUntilModuleReady(),this.sourcesWithLayers.waypoints.clear()}getShown(){return{mainLines:this.sourcesWithLayers.mainLines.shownFeatures,waypoints:this.sourcesWithLayers.waypoints.shownFeatures,incidents:this.sourcesWithLayers.incidents.shownFeatures,ferries:this.sourcesWithLayers.ferries.shownFeatures,chargingStops:this.sourcesWithLayers.chargingStops.shownFeatures,tollRoads:this.sourcesWithLayers.tollRoads.shownFeatures,tunnels:this.sourcesWithLayers.tunnels.shownFeatures,vehicleRestricted:this.sourcesWithLayers.vehicleRestricted.shownFeatures,instructionLines:this.sourcesWithLayers.instructionLines.shownFeatures,instructionArrows:this.sourcesWithLayers.instructionArrows.shownFeatures,summaryBubbles:this.sourcesWithLayers.summaryBubbles.shownFeatures}}get events(){return this.buildEvents(this.moduleEventsWithShown(["mainLines","waypoints","chargingStops","summaryBubbles","incidents","vehicleRestricted","ferries","tollRoads","tunnels","instructionLines"],this.shownFeaturesHandlers),{mainLines:this.userEvents(["mainLines"]),waypoints:this.userEvents(["waypoints"]),chargingStops:this.userEvents(["chargingStops"]),summaryBubbles:this.userEvents(["summaryBubbles"]),incidents:this.userEvents(["incidents"]),vehicleRestricted:this.userEvents(["vehicleRestricted"]),ferries:this.userEvents(["ferries"]),tollRoads:this.userEvents(["tollRoads"]),tunnels:this.userEvents(["tunnels"]),instructionLines:this.userEvents(["instructionLines"])})}getLayerToRenderLinesUnder(){return at.lowestLabel}},Ia="standardLight",Ea={standardLight:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_light"},standardDark:{trafficIncidents:"incidents_dark",trafficFlow:"flow_relative-dark",hillshade:"hillshade_dark"},drivingLight:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_light"},drivingDark:{trafficIncidents:"incidents_dark",trafficFlow:"flow_relative-dark",hillshade:"hillshade_dark"},monoLight:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_mono-light"},monoDark:{trafficIncidents:"incidents_dark",trafficFlow:"flow_relative-dark",hillshade:"hillshade_mono-dark"},satellite:{trafficIncidents:"incidents_light",trafficFlow:"flow_relative-light",hillshade:"hillshade_satellite"}},ba={standardLight:"basic_street-light",standardDark:"basic_street-dark",drivingLight:"basic_street-light-driving",drivingDark:"basic_street-dark-driving",monoLight:"basic_mono-light",monoDark:"basic_mono-dark",satellite:"basic_street-satellite"},Ra=(e,t,i)=>{const r=e.id??"standardLight",s=e.version??"0.6.0-0",a=new URL(`${t}/maps/orbis/assets/styles/${s}/style.json`);a.searchParams.set("apiVersion","1"),i&&a.searchParams.set("key",i),a.searchParams.set("map",ba[r]);for(const o of e.include??Lr)a.searchParams.append(o,Ea[r][o]);return a.toString()},Ta=e=>{const t=e.style,i=e.commonBaseURL,r=e.apiKey;return"string"==typeof t?Ra({id:t},i,r):"standard"===t?.type?Ra(t,i,r):"custom"===t?.type&&t?.url?((e,t)=>{const i=new URL(e);return i.searchParams.has("key")?console.warn("The style URL is coming with an API key parameter which takes priority. If you want to use the SDK configured API key, remove the key param from the style URL"):t&&i.searchParams.set("key",t),i.toString()})(t.url,r):"custom"===t?.type&&t?.json?t.json:Ra({id:Ia},i,r)},Ca=class{get styleLightDarkTheme(){return this._styleLightDarkTheme}constructor(e){var t;this.mapReady=!1,this.styleChangeHandlers=[],this.styleRequestSequence=0,this.setStyle=(e,t={})=>{const i={resetState:t.resetState??!1};this.mapReady=!1;const r=++this.styleRequestSequence,s=i.resetState?e:((e,t)=>t&&"object"==typeof t&&"standard"===t.type&&t.include&&("string"==typeof e||"standard"===e.type&&!e.include)?{type:"standard",id:"string"==typeof e?e:e.id,include:t.include}:e)(e,this._params.style);return this._params={...this._params,style:s},this._styleLightDarkTheme=Ie(s),this.applyStyle(i,r)},this.getStyle=()=>this._params.style,this._params=S(e),void 0===this._params.style&&(this._params={...this._params,style:Ia}),this._styleLightDarkTheme=Ie(this._params.style),this.ensureMapLibreCSSLoaded(),D(4),this.styleGivenToMapLibre=Ta(this._params),this.mapLibreMap=new w({validateStyle:!1,maxTileCacheZoomLevels:22,cancelPendingTileRequestsWhileZooming:!1,...(t=this._params).mapLibre,style:Ta(t),attributionControl:{compact:!1},transformRequest:de(t)}),this.mapLibreMap.once("style.load",()=>{this.handleStyleData()}),this._eventsProxy=new Xe(this.mapLibreMap,this._params?.events),this.loadRTLTextPlugin()}loadRTLTextPlugin(){setTimeout(()=>{["deferred","loaded"].includes(O())||M("https://unpkg.com/@mapbox/mapbox-gl-rtl-text@0.3.0/dist/mapbox-gl-rtl-text.js",!0).catch(e=>console.error("Something went wrong when setting RTL plugin",e))})}ensureMapLibreCSSLoaded(){if("undefined"==typeof document)return;if(Array.from(document.querySelectorAll('link[rel="stylesheet"], style')).some(e=>e.textContent?.includes(".maplibregl-map")))return;const e=document.createElement("link");e.rel="stylesheet",e.href=`https://unpkg.com/maplibre-gl@${N()}/dist/maplibre-gl.css`,document.head.appendChild(e)}async applyStyle(e,t){if(await this.notifyHandlers("onStyleAboutToChange",e),this.isSuperseded(t))return;if(await(this.styleLoadInFlight?.catch(()=>{})),this.isSuperseded(t))return;const i=this.loadIntoMapLibre();this.styleLoadInFlight=i;try{await i}finally{this.styleLoadInFlight===i&&(this.styleLoadInFlight=void 0)}if(!this.isSuperseded(t))try{await this.handleStyleData(e)}catch(r){console.error(r)}}async loadIntoMapLibre(){const e=Ta(this._params);if(t(e,this.styleGivenToMapLibre))return;const i=this.styleGivenToMapLibre;this.styleGivenToMapLibre=e,await new Promise((t,r)=>{const s=()=>{this.mapLibreMap.off("error",a),t()},a=e=>{"sourceId"in e||(this.mapLibreMap.off("style.load",s),this.mapLibreMap.off("error",a),this.styleGivenToMapLibre=i,r(e.error instanceof Error?e.error:new Error(e.error.message)))};this.mapLibreMap.once("style.load",s),this.mapLibreMap.on("error",a),this.mapLibreMap.setStyle(e,{validate:!1})})}isSuperseded(e){return e!==this.styleRequestSequence}async notifyHandlers(e,t){for(const r of[...this.styleChangeHandlers])try{await(r[e]?.(t))}catch(i){console.error(i)}}_setTomTomUserAgent(e){this._params={...this._params,"tomtom-user-agent":e},this.mapLibreMap.setTransformRequest(de(this._params))}_setLanguage(e){this._params={...this._params,language:e};const t=e?.includes("-")?e.split("-")[0]:e;this.mapLibreMap.getStyle().layers.forEach(e=>{if("symbol"===e.type&&(e=>{const t=e.layout?.["text-field"]??"";return!!t&&("{name}"===t||2===t.length&&"name"===t[1]||3===t.length&&Array.isArray(t[1])&&"string"==typeof t[1][1]&&t[1][1].includes("name_")&&Array.isArray(t[2])&&t[2].includes("name"))})(e)){const i=t?["coalesce",["get",`name_${t}`],["get","name"]]:["get","name"];this.mapLibreMap.setLayoutProperty(e.id,"text-field",i,{validate:!1})}})}setLanguage(e){this.mapReady?this._setLanguage(e):this.mapLibreMap.once("styledata",()=>this.setLanguage(e))}getBBox(){return this.mapLibreMap.getBounds().toArray().flat()}async handleStyleData(e){for(const t of ke(this.mapLibreMap,[ct,ht,nt]))this.mapLibreMap.setLayoutProperty(t.id,"visibility","none",{validate:!1});be(this._params.style)&&!Ee(this._params.style)&&(this._styleLightDarkTheme=(e=>{const t=e?.layers?.find(e=>"background"===e?.type);if(!t)return;const i=Re(t.paint?.["background-color"]),r=void 0===i?void 0:ee(i);return void 0!==r?r<.35?"dark":"light":void 0})(this.mapLibreMap.getStyle())??this._styleLightDarkTheme),(async(e,t,i)=>{if(i.getSprite().some(e=>"pinCategories"===e.id))return;const r=new URLSearchParams;e.apiKey&&r.set("key",e.apiKey),r.set("poi",`poi_${t}`),r.set("apiVersion","1"),r.set("apiChannel","preview"),i.addSprite(se,`${e.commonBaseURL}/maps/orbis/assets/sprites/2.*/sprite?${r}`,{validate:!1})})(this._params,this._styleLightDarkTheme,this.mapLibreMap),this._params.language&&this._setLanguage(this._params.language),this.mapReady=!0,e&&await this.notifyHandlers("onStyleChanged",e)}addStyleChangeHandler(e){this.styleChangeHandlers.push(e);let t=!1;return()=>{if(t)return;t=!0;const i=this.styleChangeHandlers.indexOf(e);-1!==i&&this.styleChangeHandlers.splice(i,1)}}},va={visible:!0,displayMode:"hexgrid-3d",activeMetric:"congestionLevel",metricConfig:{congestionLevel:{color:{valueType:"raw",stops:[{value:0,color:"#2dc653"},{value:50,color:"#f5a623"},{value:100,color:"#e03030"}]},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},speed:{color:{valueType:"relativeToPredefinedRangePCT",stops:[{value:0,color:"#e03030"},{value:50,color:"#f5a623"},{value:100,color:"#2dc653"}]},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},travelTime:{color:{valueType:"relativeToPredefinedRangePCT",stops:[{value:0,color:"#2dc653"},{value:50,color:"#f5a623"},{value:100,color:"#e03030"}]},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},freeFlowSpeed:{color:{valueType:"relativeToPredefinedRangePCT",stops:[{value:0,color:"#e03030"},{value:50,color:"#f5a623"},{value:100,color:"#2dc653"}]},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},networkLength:{color:{valueType:"relativeToActualRangePCT",stops:[{value:0,color:"#2dc653"},{value:50,color:"#f5a623"},{value:100,color:"#e03030"}]},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"currentRange"}}},regionPolygon:{fillOpacity:0,outlineOpacity:.5,outlineWidth:2,inverted:!1}},wa="#ffffff",Oa=e=>"dark"===e?"#FFFFFF":"#000000",Na={trafficLight:["#2dc653","#f5a623","#e03030"],heat:["#2196F3","#FF9800","#F44336"],monochrome:["#e0e0e0","#888888","#1a1a1a"],viridis:["#fde725","#35b779","#31688e","#440154"],plasma:["#f0f921","#ed7953","#9c179e","#0d0887"]},Ma={congestionLevel:{min:0,max:100},speed:{min:0,max:120},travelTime:{min:0,max:20},freeFlowSpeed:{min:0,max:120},networkLength:{min:0,max:5e3}},Da=e=>"speed"===e||"freeFlowSpeed"===e,xa=e=>e?.activeMetric??va.activeMetric,Fa=e=>{return"string"==typeof e?(t=Na[e]).map((e,i)=>({value:1===t.length?0:i/(t.length-1),color:e})):e.stops;var t},Pa=e=>{if("top"!==e)return e?at[e]:at.lowestLabel},Ua=e=>{if("top"!==e)return e?at[e]:at.lowestPlaceLabel},Ha=(e,t,i)=>{const r=t??va.metricConfig[e].color??"trafficLight",s=Fa(r);let a;if("string"==typeof r){const{min:t,max:i}=Ma[e],r=Da(e)?[...s].reverse().map(e=>e.color):s.map(e=>e.color);a=s.map(({value:e},s)=>[t+e*(i-t),r[s]])}else if("relativeToPredefinedRangePCT"===r.valueType){const{min:t,max:i}=Ma[e];a=s.map(({value:e,color:r})=>[t+e/100*(i-t),r])}else if("relativeToActualRangePCT"===r.valueType){const{min:t,max:r}=i??Ma[e];a=s.map(({value:e,color:i})=>[t+e/100*(r-t),i])}else a=s.map(({value:e,color:t})=>[e,t]);return["interpolate",["linear"],["get",e],...a.flatMap(([e,t])=>[e,t])]},ka=(e,t)=>{const i=t??va.metricConfig[e].color??"trafficLight",r=Fa(i);let s;if("string"==typeof i){const t=Da(e)?[...r].reverse().map(e=>e.color):r.map(e=>e.color);s=r.flatMap(({value:e},i)=>[.3+.7*e,t[i]])}else if("relativeToPredefinedRangePCT"===i.valueType||"relativeToActualRangePCT"===i.valueType)s=r.flatMap(({value:e,color:t})=>[.3+e/100*.7,t]);else{const e=Math.min(...r.map(e=>e.value)),t=Math.max(...r.map(e=>e.value))-e||1;s=r.flatMap(({value:i,color:r})=>[.3+(i-e)/t*.7,r])}return["interpolate",["linear"],["heatmap-density"],0,"rgba(0,0,0,0)",...s]},Wa=(e,t,i)=>{const r=va.metricConfig[e].height,s=t?.minHeightMeters??r.minHeightMeters??0;if("raw"===t?.scaleMode){const i=t.scaleFactor??1;if("speed"===e){const{max:t}=Ma[e];return["max",s,["*",["-",t,["coalesce",["get","speed"],0]],i]]}return["max",s,["*",["coalesce",["get",e],0],i]]}const a=t?.maxHeightMeters??r.maxHeightMeters??1e3,{min:o,max:n}="currentRange"===(t?.scaleMode??r.scaleMode)?i??Ma[e]:Ma[e],l=n-o||1;return"speed"===e?["max",s,["*",["/",["-",n,["coalesce",["get","speed"],0]],l],a]]:["max",s,["*",["/",["-",["coalesce",["get",e],0],o],l],a]]},Ga=(e,t,i)=>{const r=xa(t),s=t?.metricConfig?.[r],{min:a,max:o}=i??Ma[r];return{id:e,type:"heatmap",beforeID:Pa(t?.beforeLayerConfig?.heatmap),paint:{"heatmap-weight":["interpolate",["linear"],["get",r],a,0,o,1],"heatmap-intensity":["interpolate",["linear"],["zoom"],10,.5,14,2,16,4],"heatmap-color":ka(r,s?.color),"heatmap-radius":["interpolate",["linear"],["zoom"],4,1,8,3,12,35,14,80,16,100],"heatmap-opacity":["interpolate",["linear"],["zoom"],4,.8,13,.8,17,0]}}},Ba=(e,t,i)=>{const r=xa(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:Pa(t?.beforeLayerConfig?.hexgrid?.flat2D),paint:{"fill-color":Ha(r,s?.color,i),"fill-opacity":.6}}},Va=(e,t,i)=>{const r=xa(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:Ua(t?.beforeLayerConfig?.hexgrid?.extrusion3D),paint:{"fill-extrusion-color":Ha(r,s?.color,i),"fill-extrusion-height":Wa(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},ja=(e,t,i)=>{const r=xa(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:Pa(t?.beforeLayerConfig?.square?.flat2D),paint:{"fill-color":Ha(r,s?.color,i),"fill-opacity":.6}}},$a=(e,t,i)=>{const r=xa(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:Ua(t?.beforeLayerConfig?.square?.extrusion3D),paint:{"fill-extrusion-color":Ha(r,s?.color,i),"fill-extrusion-height":Wa(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},za=e=>({...va.regionPolygon,...e}),Ya=(e,t,i)=>{const{color:r,fillOpacity:s}=za(t?.regionPolygon);return{id:e,type:"fill",beforeID:Pa(),paint:{"fill-color":r??Oa(i),"fill-opacity":s}}},qa=(e,t,i)=>{const{color:r,outlineOpacity:s,outlineWidth:a}=za(t?.regionPolygon);return{id:e,type:"line",beforeID:Pa(),paint:{"line-color":r??Oa(i),"line-opacity":s,"line-width":a}}},Ka=(e,t)=>({id:e,type:"line",beforeID:t,filter:["has","eventState"],paint:{"line-color":wa,"line-width":["case",Jt,3,2],"line-opacity":["case",Jt,1,.8]}}),Xa=e=>({...e,filter:["has","eventState"],paint:{...e.paint,"fill-extrusion-color":["case",Jt,wa,wa],"fill-extrusion-height":["+",e.paint?.["fill-extrusion-height"],.5],"fill-extrusion-opacity":.6}}),Za=(e,t,i)=>Xa(Va(e,t,i)),Ja=(e,t,i)=>Xa($a(e,t,i)),Qa=(e,t,i)=>((e,t,i)=>{const r=[];for(let s=0;s<e.length;s++){const a=e[s];if(!a)continue;const{congestionSum:o,speedSum:n,freeFlowSum:l,travelTimeSum:c,networkLengthSum:h,count:u}=a,d=`${i}-${s}`;r.push({type:"Feature",id:d,geometry:t.features[s].geometry,properties:{id:d,congestionLevel:Math.round(o/u),speed:Math.round(n/u),freeFlowSpeed:Math.round(l/u),travelTime:Math.round(c/u*10)/10,networkLength:Math.round(h/u)}})}return r})(((e,t)=>{const i=[];for(const r of e)for(let e=0;e<t.features.length;e++)if(E(r.tileCentre,t.features[e])){let t=i[e];void 0===t&&(t={congestionSum:0,speedSum:0,freeFlowSum:0,travelTimeSum:0,networkLengthSum:0,count:0},i[e]=t),t.congestionSum+=r.congestionLevel??0,t.speedSum+=r.speed??0,t.freeFlowSum+=r.freeFlowSpeed??0,t.travelTimeSum+=r.travelTime??0,t.networkLengthSum+=r.networkLength??0,t.count++;break}return i})(e,t),t,i),eo=.005,to=(e,t,i,r)=>{const s=[];for(let a=0;a<e.features.length;a++){const o=e.features[a],n=o.properties?.tiledData?.tiles??[];if(0===n.length)continue;const l=u(o);if(!l)continue;const c=i([l[0]-eo,l[1]-eo,l[2]+eo,l[3]+eo],t);s.push(...Qa(n,c,`${r}-${a}`))}return{type:"FeatureCollection",features:s}},io=class e extends ve{static async create(t,i){return await he(t),new e(t,i??{})}constructor(e,t){super(e,t),this.lastAnalytics=null,this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){const i=this.instanceIndex,r=`area-analytics-heatmap-${i}`,s=`area-analytics-hexgrid-${i}`,a=`area-analytics-square-${i}`,o=`area-analytics-region-${i}`,n=`${r}-layer`,l=`${s}-fill`,c=`${s}-extrusion`,h=`${s}-outline`,u=`${s}-extrusion-highlight`,d=`${a}-fill`,p=`${a}-extrusion`,f=`${a}-outline`,y=`${a}-extrusion-highlight`,m=`${o}-fill`,g=`${o}-line`,_=this.lightDark;this.heatmapLayerSpec=Ga(n,e),this.hexFillLayerSpec=Ba(l,e),this.hexExtrusionLayerSpec=Va(c,e),this.squareFillLayerSpec=ja(d,e),this.squareExtrusionLayerSpec=$a(p,e),this.regionFillLayerSpec=Ya(m,e,_),this.regionLineLayerSpec=qa(g,e,_),this.hexOutlineLayerSpec=((e,t)=>Ka(e,Pa(t?.beforeLayerConfig?.hexgrid?.flat2D)))(h,e),this.hexExtrusionHighlightLayerSpec=Za(u,e),this.squareOutlineLayerSpec=((e,t)=>Ka(e,Pa(t?.beforeLayerConfig?.square?.flat2D)))(f,e),this.squareExtrusionHighlightLayerSpec=Ja(y,e);const L={heatmap:new Ve(this.mapLibreMap,r,[this.heatmapLayerSpec]),hexgrid:new Ve(this.mapLibreMap,s,[this.hexFillLayerSpec,this.hexExtrusionLayerSpec]),square:new Ve(this.mapLibreMap,a,[this.squareFillLayerSpec,this.squareExtrusionLayerSpec]),region:new Ve(this.mapLibreMap,o,[this.regionFillLayerSpec,this.regionLineLayerSpec])};return this.addHighlightLayersToMap(s,a),L}_applyConfig(e){if(void 0===e)return;const t=e.metricConfig&&this.config?.metricConfig?{...this.config.metricConfig,...e.metricConfig}:e.metricConfig??this.config?.metricConfig,i=Object.keys(va.metricConfig),r=Object.fromEntries(i.map(e=>[e,t?.[e]??va.metricConfig[e]])),s={activeMetric:va.activeMetric,displayMode:va.displayMode,...this.config,...e,metricConfig:r};return this.applyLayerConfig(s),s.regionPolygon&&this.applyRegionConfig(s),s.beforeLayerConfig&&this._moveBeforeLayer(s.beforeLayerConfig,!1),this.config=s,this.applyModeVisibility(),s}discardShownData(){this.lastAnalytics=null}restoreDataAndConfigImpl(){const e=this.lastAnalytics;this.initSourcesWithLayers(this.config,!0),e?(!1===this.config?.visible&&this.setVisible(!1),this.show(e)):this.config&&this._applyConfig(this.config)}async show(e){await this.waitUntilModuleReady(),this.lastAnalytics=e,this.sourcesWithLayers.heatmap.show((e=>({type:"FeatureCollection",features:e.features.flatMap(e=>e.properties?.tiledData?.tiles??[]).map((e,t)=>{const[i,r]=e.tileCentre,s=`tile-${t}-${i}-${r}`;return{type:"Feature",id:s,geometry:{type:"Point",coordinates:[i,r]},properties:{id:s,speed:e.speed??0,freeFlowSpeed:e.freeFlowSpeed??0,congestionLevel:e.congestionLevel??0,travelTime:e.travelTime??0,networkLength:e.networkLength??0}}})}))(e),{automaticVisibility:!1}),this.sourcesWithLayers.hexgrid.show(((e,t=.25)=>to(e,t,(e,t)=>T(e,t,{units:"kilometers"}),"hex"))(e),{automaticVisibility:!1}),this.sourcesWithLayers.square.show(((e,t=.5)=>to(e,t,(e,t)=>v(e,t,{units:"kilometers"}),"square"))(e),{automaticVisibility:!1});const t=this.config?.regionPolygon?.inverted??va.regionPolygon.inverted;this.sourcesWithLayers.region.show(this.buildRegionFC(e.features,t)),this.applyLayerConfig(this.config),this.applyModeVisibility();for(const i of this.shownFeaturesHandlers)i(e)}async clear(){await this.waitUntilModuleReady(),this.lastAnalytics=null,this.sourcesWithLayers.heatmap.clear(),this.sourcesWithLayers.hexgrid.clear(),this.sourcesWithLayers.square.clear(),this.sourcesWithLayers.region.clear()}setMode(e){e!==this.mode&&(this.config={...this.config,displayMode:e},this.applyModeVisibility(),this.emitConfigChange())}setMetric(e){e!==this.activeMetric&&(this.config={...this.config,activeMetric:e},this.applyLayerConfig(this.config),this.emitConfigChange())}setColor(e,t){const i=Object.keys(va.metricConfig),r=t??i,s={...this.config?.metricConfig};if(void 0===e)for(const a of r){const{color:e,...t}=s[a]??{};s[a]=t}else if("string"==typeof e){const t=(e=>{const t=Fa(e),i=e=>{const{min:i,max:r}=Ma[e],s=Da(e)?[...t].reverse().map(e=>e.color):t.map(e=>e.color);return{valueType:"raw",stops:t.map(({value:e},t)=>({value:i+e*(r-i),color:s[t]}))}};return{congestionLevel:{color:i("congestionLevel")},speed:{color:i("speed")},travelTime:{color:i("travelTime")},freeFlowSpeed:{color:i("freeFlowSpeed")},networkLength:{color:i("networkLength")}}})(e);for(const e of r)s[e]={...s[e],...t[e]}}else for(const a of r)s[a]={...s[a],color:e};this.config={...this.config,metricConfig:s},this.applyLayerConfig(this.config),this.emitConfigChange()}setHeight(e,t){const i=Object.keys(va.metricConfig),r=t??i,s={...this.config?.metricConfig};for(const a of r)s[a]={...s[a],height:e};this.config={...this.config,metricConfig:s},this.applyLayerConfig(this.config),this.emitConfigChange()}filter(e,t){const i=Object.keys(va.metricConfig),r=t??i,s={...this.config?.metricConfig};for(const a of r)s[a]={...s[a],filters:e};this.config={...this.config,metricConfig:s},this.applyFiltersToLayers(),this.emitConfigChange()}clearFilter(e){this.filter(void 0,e)}setVisible(e){this.config={...this.config,visible:e},this.applyModeVisibility(),this.emitConfigChange()}isVisible(){return this.sourcesWithLayers.heatmap.isAnyLayerVisible()||this.sourcesWithLayers.hexgrid.isAnyLayerVisible()||this.sourcesWithLayers.square.isAnyLayerVisible()}getShown(){return{heatmap:this.sourcesWithLayers.heatmap.shownFeatures,hexgrid:this.sourcesWithLayers.hexgrid.shownFeatures,square:this.sourcesWithLayers.square.shownFeatures}}moveBeforeLayer(e){this._moveBeforeLayer(e)}_moveBeforeLayer(e,t=!0){const i=e=>"top"===e?void 0:at[e];void 0!==e.heatmap&&me(this.mapLibreMap,this.heatmapLayerSpec.id,i(e.heatmap)),void 0!==e.hexgrid?.flat2D&&me(this.mapLibreMap,this.hexFillLayerSpec.id,i(e.hexgrid.flat2D)),void 0!==e.hexgrid?.extrusion3D&&me(this.mapLibreMap,this.hexExtrusionLayerSpec.id,i(e.hexgrid.extrusion3D)),void 0!==e.square?.flat2D&&me(this.mapLibreMap,this.squareFillLayerSpec.id,i(e.square.flat2D)),void 0!==e.square?.extrusion3D&&me(this.mapLibreMap,this.squareExtrusionLayerSpec.id,i(e.square.extrusion3D)),t&&(this.config={...this.config,beforeLayerConfig:e})}get events(){return this.moduleEventsWithShown(["hexgrid","square","heatmap"],this.shownFeaturesHandlers)}get mode(){return this.config?.displayMode??va.displayMode}get activeMetric(){return xa(this.config)}get lightDark(){return this.tomtomMap.styleLightDarkTheme}applyModeVisibility(){if(!1===this.config?.visible)return void this.hideAllDataLayers();const e=this.mode,t=this.sourcesWithLayers.heatmap.shownFeatures.features.length>0,i=this.sourcesWithLayers.hexgrid.shownFeatures.features.length>0,r=this.sourcesWithLayers.square.shownFeatures.features.length>0,s=this.sourcesWithLayers.region.shownFeatures.features.length>0;this.sourcesWithLayers.heatmap.setLayersVisible("heatmap"===e&&t),this.sourcesWithLayers.hexgrid.setLayersVisible("hexgrid-3d"===e&&i,e=>e.id===this.hexExtrusionLayerSpec.id),this.sourcesWithLayers.hexgrid.setLayersVisible("hexgrid-2d"===e&&i,e=>e.id===this.hexFillLayerSpec.id),this.sourcesWithLayers.square.setLayersVisible("square-3d"===e&&r,e=>e.id===this.squareExtrusionLayerSpec.id),this.sourcesWithLayers.square.setLayersVisible("square-2d"===e&&r,e=>e.id===this.squareFillLayerSpec.id),this.sourcesWithLayers.region.setLayersVisible(s),this.setHighlightLayerVisible(this.hexOutlineLayerSpec.id,"hexgrid-2d"===e&&i),this.setHighlightLayerVisible(this.hexExtrusionHighlightLayerSpec.id,"hexgrid-3d"===e&&i),this.setHighlightLayerVisible(this.squareOutlineLayerSpec.id,"square-2d"===e&&r),this.setHighlightLayerVisible(this.squareExtrusionHighlightLayerSpec.id,"square-3d"===e&&r)}hideAllDataLayers(){this.sourcesWithLayers.heatmap.setLayersVisible(!1),this.sourcesWithLayers.hexgrid.setLayersVisible(!1),this.sourcesWithLayers.square.setLayersVisible(!1),this.sourcesWithLayers.region.setLayersVisible(!1),this.setHighlightLayerVisible(this.hexOutlineLayerSpec.id,!1),this.setHighlightLayerVisible(this.hexExtrusionHighlightLayerSpec.id,!1),this.setHighlightLayerVisible(this.squareOutlineLayerSpec.id,!1),this.setHighlightLayerVisible(this.squareExtrusionHighlightLayerSpec.id,!1)}addHighlightLayersToMap(e,t){const i=(e,t)=>{this.mapLibreMap.getLayer(e.id)||this.mapLibreMap.addLayer({...e,source:t},ye(this.mapLibreMap,e.beforeID)),this.mapLibreMap.setLayoutProperty(e.id,"visibility","none")};i(this.hexOutlineLayerSpec,e),i(this.hexExtrusionHighlightLayerSpec,e),i(this.squareOutlineLayerSpec,t),i(this.squareExtrusionHighlightLayerSpec,t)}setHighlightLayerVisible(e,t){this.mapLibreMap.getLayer(e)&&this.mapLibreMap.setLayoutProperty(e,"visibility",t?"visible":"none")}applyLayerConfig(e){const t=this.lastAnalytics?.properties.ranges?.[this.activeMetric],i=Ga(this.heatmapLayerSpec.id,e,t),r=Ba(this.hexFillLayerSpec.id,e,t),s=Va(this.hexExtrusionLayerSpec.id,e,t),a=Za(this.hexExtrusionHighlightLayerSpec.id,e,t),o=ja(this.squareFillLayerSpec.id,e,t),n=$a(this.squareExtrusionLayerSpec.id,e,t),l=Ja(this.squareExtrusionHighlightLayerSpec.id,e,t);pe(i,this.heatmapLayerSpec,this.mapLibreMap),pe(r,this.hexFillLayerSpec,this.mapLibreMap),pe(s,this.hexExtrusionLayerSpec,this.mapLibreMap),pe(a,this.hexExtrusionHighlightLayerSpec,this.mapLibreMap),pe(o,this.squareFillLayerSpec,this.mapLibreMap),pe(n,this.squareExtrusionLayerSpec,this.mapLibreMap),pe(l,this.squareExtrusionHighlightLayerSpec,this.mapLibreMap),this.heatmapLayerSpec=i,this.hexFillLayerSpec=r,this.hexExtrusionLayerSpec=s,this.hexExtrusionHighlightLayerSpec=a,this.squareFillLayerSpec=o,this.squareExtrusionLayerSpec=n,this.squareExtrusionHighlightLayerSpec=l,this.applyFiltersToLayers()}applyRegionConfig(e){const t=this.lightDark,i=Ya(this.regionFillLayerSpec.id,e,t),r=qa(this.regionLineLayerSpec.id,e,t);if(pe(i,this.regionFillLayerSpec,this.mapLibreMap),pe(r,this.regionLineLayerSpec,this.mapLibreMap),this.regionFillLayerSpec=i,this.regionLineLayerSpec=r,this.lastAnalytics){const t=e?.regionPolygon?.inverted??va.regionPolygon.inverted;this.sourcesWithLayers.region.show(this.buildRegionFC(this.lastAnalytics.features,t))}}applyFiltersToLayers(){const e=this.activeMetric,t=this.config?.metricConfig?.[e]?.filters,i=[this.hexFillLayerSpec.id,this.hexExtrusionLayerSpec.id,this.squareFillLayerSpec.id,this.squareExtrusionLayerSpec.id];if(!t||void 0===t.min&&void 0===t.max){for(const e of i)this.mapLibreMap.setFilter(e,null);return}const r=[];void 0!==t.min&&r.push([">=",["get",e],t.min]),void 0!==t.max&&r.push(["<=",["get",e],t.max]);const s=1===r.length?r[0]:["any",...r];for(const a of i)this.mapLibreMap.setFilter(a,s)}buildRegionFC(e,t){return{type:"FeatureCollection",features:e.map((e,i)=>{const r=`traffic-area-analytics-region-${i}`,s=t?C(e).geometry:e.geometry;return{...e,id:r,geometry:s,properties:{id:r}}})}}},ro=e=>e.length?1===e.length?e[0]:["all",...e]:null,so=(e,t)=>{e&&t.push(e)},ao=(e,t,i)=>{e&&so(Hi(t,e),i)},oo=(e,t)=>{ao(e.roadCategories,"road_category",t),ao(e.roadSubCategories,"road_subcategory",t)},no=e=>{const t=[];if(oo(e,t),e.incidentCategories){const i=Hi("icon_category_0",e.incidentCategories,e=>j[e]);so(i,t)}if(e.magnitudes){const i=Hi("magnitude_of_delay",e.magnitudes,e=>_.indexOf(e));so(i,t)}return e.delays&&so((e=>{const t=[];if(e.mustHaveDelay&&e.minDelayMinutes){const i=60*e.minDelayMinutes;t.push([">=",["get","delay"],i])}else if(e.mustHaveDelay)t.push([">",["get","delay"],0]);else if(e.minDelayMinutes){const i=60*e.minDelayMinutes;t.push(["any",["!",["has","delay"]],["==",["get","delay"],0],[">=",["get","delay"],i]])}return ro(t)})(e.delays),t),ro(t)},lo=e=>{if(!e?.any?.length)return null;const t=e.any.map(no).filter(e=>!i(e));return Fi(t)},co=e=>{const t=[];if(oo(e,t),e.showRoadClosures){const i="only"===e.showRoadClosures?"==":"!=";t.push([i,["get","road_closure"],!0])}return ro(t)},ho=(e,t,i,r)=>{for(const s of t)i.setFilter(s.id,e?Pi(e,r[s.id]):r[s.id])},uo=class e extends we{static async get(t,i){return await he(t),await Le(t,ht,"trafficFlow"),dt(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(ht);if(!t)throw re(`init ${e.name} with source ID ${ht}`);this.originalFilters={};for(const e of this.getLayers())this.originalFilters[e.id]=e.filter;return{trafficFlow:new We(this.mapLibreMap,t)}}_applyConfig(e){return this._setVisible(e?.visible??!1,!1),this._filter(e?.filters,!1),e}getLayers(){return ke(this.tomtomMap.mapLibreMap,[ht])}filter(e){this._filter(e)}_filter(e,t=!0){if(this.tomtomMap.mapReady)if(e?.any?.length){const t=(e=>{if(!e?.any?.length)return null;const t=e.any.map(co).filter(e=>!i(e));return Fi(t)})(e);t&&ho(t,this.getLayers(),this.mapLibreMap,this.originalFilters)}else this.config?.filters?.any?.length&&ho(void 0,this.getLayers(),this.mapLibreMap,this.originalFilters);t&&(this.config=a({...this.config,filters:e},i),this.emitConfigChange())}setVisible(e){this._setVisible(e)}_setVisible(e,t=!0){this.tomtomMap.mapReady&&this.sourcesWithLayers.trafficFlow.setLayersVisible(e),t&&(this.config={...this.config,visible:e},this.emitConfigChange())}isVisible(){return this.sourcesWithLayers.trafficFlow.isAnyLayerVisible()}getShown(){return{trafficFlow:this.mapLibreMap.queryRenderedFeatures({layers:this.sourcesWithLayers.trafficFlow.sourceAndLayerIDs.layerIDs,validate:!1}).map(B)}}get events(){return this.moduleEvents(["trafficFlow"],{mapping:B})}},po="tt-traffic-incident-direction-chevron",fo='<svg xmlns="http://www.w3.org/2000/svg" width="48" height="18" viewBox="0 0 48 18">\n<path d="M 18 4 L 30 9 L 18 14" fill="none" stroke="rgba(20, 30, 50, 0.5)" stroke-width="5" stroke-linecap="round" stroke-linejoin="round"/>\n<path d="M 18 4 L 30 9 L 18 14" fill="none" stroke="white" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"/>\n</svg>',yo=["interpolate",["exponential",1.5],["zoom"],5,0,9,.96,13,2.1,19,10.8],mo=["interpolate",["exponential",1.5],["zoom"],5,.75,9,1.96,13,3.6,19,13.8],go=e=>["match",["get","magnitudeOfDelay"],"unknown",e.unknown,"minor",e.minor,"moderate",e.moderate,"major",e.major,"indefinite",e.indefinite,e.major],_o=["match",["get","magnitudeOfDelay"],"unknown","traffic-incidents-no_delay-pattern","indefinite","traffic-incidents-road_closed-pattern",""],Lo=e=>"dark"===e?"#FFF":"#000",So=["interpolate",["exponential",1.5],["zoom"],5,2.2,9,4.6,13,8.3,19,26],Ao=["case",["==",["feature-state","focused"],!0],1,0],Io=(e,t)=>{if(null===t)return e;const[i,r,s,...a]=e;return[i,r,s,...a.map((e,i)=>i%2==1?["case",["==",["feature-state","focused"],!0],e*t,e]:e)]},Eo=["in",["get","magnitudeOfDelay"],["literal",["minor","moderate","major"]]],bo=["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],Ro=(e,t,i,r)=>{const s=r?.widthScale??null,a=[];return null!==r&&a.push({id:`${e}-focus-halo`,type:"line",minzoom:6,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":r.outlineColor,"line-width":So,"line-blur":0,"line-opacity":Ao},beforeID:t}),a.push({id:`${e}-outline`,type:"line",minzoom:6,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":go(i.outline),"line-width":Io(mo,s)},beforeID:t},{id:`${e}-inner-solid`,type:"line",minzoom:6,filter:Eo,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":go(i.inner),"line-width":Io(yo,s)},beforeID:t},{id:`${e}-inner-chevron`,type:"line",minzoom:12,filter:Eo,layout:{"line-cap":"butt","line-join":"round"},paint:{"line-pattern":po,"line-width":Io(yo,s)},beforeID:t},{id:`${e}-inner-pattern`,type:"line",minzoom:6,filter:bo,layout:{"line-cap":"round","line-join":"round"},paint:{"line-pattern":_o,"line-width":Io(yo,s)},beforeID:t}),a},To=["step",["zoom"],.7,14,.8,16,.9,18,1],Co=["step",["zoom"],12.6,14,14.4,16,16.2,18,18],vo=["match",["get","category"],"other","traffic-incidents-info","accident","traffic-incidents-accident","fog","traffic-incidents-fog","danger","traffic-incidents-roadworks","rain","traffic-incidents-rain","frost","traffic-incidents-frost","lane-closed","traffic-incidents-lane_closed","roadworks","traffic-incidents-roadworks","wind","traffic-incidents-wind","flooding","traffic-incidents-flooding","broken-down-vehicle","traffic-incidents-broken_down_vehicle",""],wo=["all",["!=",["get","magnitudeOfDelay"],"indefinite"],["any",["!",["has","delayInSeconds"]],["step",["zoom"],[">",["get","delayInSeconds"],900],14,[">",["get","delayInSeconds"],600],15,[">",["get","delayInSeconds"],300],16,!0]]],Oo=["all",["==",["get","category"],"jam"],["!=",["get","magnitudeOfDelay"],"unknown"],["!=",["get","magnitudeOfDelay"],"indefinite"],["step",["zoom"],[">",["get","delayInSeconds"],900],13,[">",["get","delayInSeconds"],600],14,[">",["get","delayInSeconds"],300],15,!0]],No=["==",["get","magnitudeOfDelay"],"indefinite"],Mo=["concat","traffic-jam-",["get","magnitudeOfDelay"],["case",["<",["get","delayInSeconds"],600],"-small",["<",["get","delayInSeconds"],3600],"-medium","-large"]],Do=["case",["<=",["get","delayInSeconds"],60],"1 min",[">=",["get","delayInSeconds"],3600],["concat",["to-string",["floor",["/",["to-number",["get","delayInSeconds"]],3600]]]," hr ",["case",["==",["%",["round",["/",["to-number",["get","delayInSeconds"]],60]],60],0],"",["concat",["to-string",["round",["%",["/",["to-number",["get","delayInSeconds"]],60],60]]]," min"]]],["concat",["round",["/",["get","delayInSeconds"],60]]," min"]],xo=["case",["has","delayInSeconds"],["*",-1,["get","delayInSeconds"]],0],Fo=(e,t)=>[{id:`${e}-incident-marker`,type:"symbol",minzoom:13,filter:wo,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":vo,"icon-size":To,"symbol-sort-key":xo},beforeID:t},{id:`${e}-jam-marker`,type:"symbol",minzoom:12,filter:Oo,layout:{"symbol-placement":"point","icon-anchor":"bottom-left","icon-offset":[2,3],"icon-image":Mo,"icon-size":To,"icon-padding":0,"text-anchor":"bottom-left","text-field":Do,"text-font":["NotoSans-CondensedBold"],"text-offset":[2.7,-.75],"text-size":Co,"symbol-sort-key":xo},paint:{"text-color":"hsl(210, 30%, 14%)"},beforeID:t},{id:`${e}-closed-road-marker`,type:"symbol",minzoom:12,filter:No,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":"traffic-incidents-road_closed","icon-size":To},beforeID:t}],Po=["unknown","minor","moderate","major","indefinite"],Uo={unknown:{outline:"TrafficIncidents - No delay outline",inner:"TrafficIncidents - No delay pattern"},minor:{outline:"TrafficIncidents - Minor jam outline",inner:"TrafficIncidents - Minor jam"},moderate:{outline:"TrafficIncidents - Moderate jam outline",inner:"TrafficIncidents - Moderate jam"},major:{outline:"TrafficIncidents - Major jam outline",inner:"TrafficIncidents - Major jam"},indefinite:{outline:"TrafficIncidents - Closed road outline",inner:"TrafficIncidents - Closed road pattern"}},Ho={unknown:"hsl(198, 20%, 54%)",minor:"hsl(45, 85%, 36%)",moderate:"hsl(9, 87%, 31%)",major:"hsl(0, 100%, 17%)",indefinite:"hsl(0, 100%, 34%)"},ko={unknown:"hsl(198, 20%, 90%)",minor:"hsl(45, 100%, 51%)",moderate:"hsl(9, 97%, 51%)",major:"hsl(0, 100%, 34%)",indefinite:"hsl(197, 28%, 95%)"},Wo=(e,t,i)=>{if(!e||"object"!=typeof e)return;const r=e.paint;if(!r||"object"!=typeof r)return;const s=r["line-color"];if("string"==typeof s)return s;void 0!==s&&i.push(t)},Go=e=>{if("top"!==e)return e?at[e]:at.lowestLabel},Bo=class e extends ve{static async create(t,i){return await he(t),new e(t,i??{})}constructor(e,t){super(e,t),this.lastResult=null,this.lastFeatureIds=[],this.lastFocusIds=null,this.shownFeaturesHandlers=[]}_initSourcesWithLayers(e,t){const i=`traffic-incident-overlay-${this.instanceIndex}`,r=this.tomtomMap.styleLightDarkTheme,s=(()=>{if(oe())return Qs||(Qs=ne(le(fo))),Qs})();s&&Se("if-not-in-sprite",po,s,this.mapLibreMap);const a=Go(e?.beforeLayerConfig),o=(e=>{const t=e.getStyle()?.layers??[],i=/* @__PURE__ */new Map;for(const a of t)i.set(a.id,a);const r={outline:{...Ho},inner:{...ko}},s=[];for(const a of Po){const e=Uo[a],t=Wo(i.get(e.outline),e.outline,s),o=Wo(i.get(e.inner),e.inner,s);t&&(r.outline[a]=t),o&&(r.inner[a]=o)}return s.length>0&&console.warn("[TrafficIncidentOverlayModule] style layers have non-literal `line-color` (match/case/etc.); falling back to default colour for: "+s.join(", ")),r})(this.mapLibreMap),n=((e,t)=>!1===e?null:{outlineColor:e?.outlineColor??Lo(t),widthScale:e?.widthScale??1.6})(e?.focus,r),l=[...Ro(i,a,o,n),...Fo(i,a)];return{incidents:new Ve(this.mapLibreMap,i,l)}}_applyConfig(e){return!1===e?.visible?this.sourcesWithLayers.incidents.setLayersVisible(!1):this.sourcesWithLayers.incidents.setLayersVisible(!0),this.applyBeforeLayer(e?.beforeLayerConfig),e}applyBeforeLayer(e){const t=Go(e);for(const i of this.sourcesWithLayers.incidents.sourceAndLayerIDs.layerIDs)me(this.mapLibreMap,i,t)}discardShownData(){this.lastResult=null,this.lastFeatureIds=[],this.lastFocusIds=null}restoreDataAndConfigImpl(){this.initSourcesWithLayers(this.config,!0),this.lastResult&&this.sourcesWithLayers.incidents.show(this.lastResult),this._applyConfig(this.config),null!==this.lastFocusIds&&this.lastFocusIds.length>0&&this.setFocus(this.lastFocusIds)}async show(e){await this.waitUntilModuleReady(),this.clearFeatureState(),this.lastFocusIds=null,this.lastResult=e,this.lastFeatureIds=e.features.map(e=>e.properties.id).filter(e=>"string"==typeof e),this.sourcesWithLayers.incidents.show(e);for(const t of this.shownFeaturesHandlers)t(e)}async clear(){await this.waitUntilModuleReady(),this.clearFeatureState(),this.lastResult=null,this.lastFeatureIds=[],this.lastFocusIds=null,this.sourcesWithLayers.incidents.clear()}setVisible(e){this.config={...this.config,visible:e},this.sourcesWithLayers.incidents.setLayersVisible(e),this.emitConfigChange()}isVisible(){return this.sourcesWithLayers.incidents.isAnyLayerVisible()}moveBeforeLayer(e){this.config={...this.config,beforeLayerConfig:e},this.applyBeforeLayer(e),this.emitConfigChange()}getShown(){return{incidents:this.sourcesWithLayers.incidents.shownFeatures}}get events(){return this.moduleEventsWithShown(["incidents"],this.shownFeaturesHandlers)}setFocus(e){if(null===e||0===e.length)return this.lastFocusIds=null,void this.clearFeatureState();if(0===this.lastFeatureIds.length)return;this.lastFocusIds=e;const t=new Set(e),i=this.sourcesWithLayers.incidents.sourceAndLayerIDs.sourceID;for(const r of this.lastFeatureIds)this.mapLibreMap.setFeatureState({source:i,id:r},{focused:t.has(r)})}clearFeatureState(){if(0===this.lastFeatureIds.length)return;const e=this.sourcesWithLayers.incidents.sourceAndLayerIDs.sourceID;for(const t of this.lastFeatureIds)this.mapLibreMap.removeFeatureState({source:e,id:t})}},Vo=class t extends we{static async get(e,i){return await he(e),await Le(e,ct,"trafficIncidents"),dt(e,t,()=>new t(e,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const e=this.mapLibreMap.getSource(ct);if(!e)throw re(`init ${t.name} with source ID ${ct}`);this.originalFilters={};for(const t of this.getLayers())this.originalFilters[t.id]=t.filter;return{trafficIncidents:new We(this.mapLibreMap,e)}}_applyConfig(e){return this._setVisible(e?.visible??!1,{updateConfig:!1}),i(e?.icons?.visible)||this._setIconsVisible(e.icons.visible,!1),this._filter(e?.filters,e?.icons?.filters,!1),e}filter(e,t){this._filter(e,t)}_filter(e,t,r=!0){if(this.tomtomMap.mapReady){if(e?.any?.length){const i=lo(e);if(i){const e=t?this.getNonSymbolLayers():this.getLayers();ho(i,e,this.mapLibreMap,this.originalFilters)}}else this.config?.filters?.any?.length&&ho(void 0,this.getLayers(),this.mapLibreMap,this.originalFilters);if(t?.any?.length){const e=lo(t);e&&ho(e,this.getSymbolLayers(),this.mapLibreMap,this.originalFilters)}}r&&(this.config=a({...this.config,filters:e,icons:{...this.config?.icons,filters:t}},i),this.emitConfigChange())}getLayers(){return ke(this.tomtomMap.mapLibreMap,[ct])}getSymbolLayers(){return this.getLayers().filter(e=>"symbol"===e.type)}getNonSymbolLayers(){return this.getLayers().filter(e=>"symbol"!=e.type)}setIconsVisible(e){this._setIconsVisible(e)}_setIconsVisible(e,t=!0){this.tomtomMap.mapReady&&this.sourcesWithLayers.trafficIncidents.setLayersVisible(e,e=>"symbol"===e.type),t&&(this.config={...this.config,icons:{...this.config?.icons,visible:e}},this.emitConfigChange())}setVisible(e){this._setVisible(e)}_setVisible(t,i){(i?.updateConfig??1)&&(delete this.config?.icons?.visible,this.config={...a({...this.config},e),visible:t},this.emitConfigChange()),this.tomtomMap.mapReady&&this.sourcesWithLayers.trafficIncidents.setLayersVisible(t)}isVisible(){return this.sourcesWithLayers.trafficIncidents.isAnyLayerVisible()}anyIconLayersVisible(){return this.sourcesWithLayers.trafficIncidents?.isAnyLayerVisible(e=>"symbol"===e.type)}getShown(){return{trafficIncidents:this.mapLibreMap.queryRenderedFeatures({layers:this.sourcesWithLayers.trafficIncidents.sourceAndLayerIDs.layerIDs,validate:!1}).map($)}}get events(){return this.moduleEvents(["trafficIncidents"],{mapping:$})}},jo=["motorway","motorway_link","trunk","trunk_link","primary","primary_link","secondary","secondary_link","tertiary","tertiary_link","street","service","track"],$o=["unclassified","residential","living_street"],zo=["parking","driveway","alley"],Yo=(e,t)=>({left:e.left-t.left,top:e.top-t.top,right:e.right-t.left,bottom:e.bottom-t.top}),qo=(e,t,i)=>e.right<=0||e.left>=t||e.bottom<=0||e.top>=i,Ko=(e,t,i,r)=>{e.top<=i-e.bottom?t.top=Math.max(t.top,e.bottom+r):t.bottom=Math.min(t.bottom,e.top-r)},Xo=(e,t,i,r)=>{e.left<=i-e.right?t.left=Math.max(t.left,e.right+r):t.right=Math.min(t.right,e.left-r)},Zo=(e,t,i,r,s)=>{const a=((e,t,i)=>({left:Math.max(0,e.left),top:Math.max(0,e.top),right:Math.min(t,e.right),bottom:Math.min(i,e.bottom)}))(e,i,r),o=e.left<=0&&e.right>=i,n=e.top<=0&&e.bottom>=r;if(o&&!n)return void Ko(a,t,r,s);if(n&&!o)return void Xo(a,t,i,s);const l=e.left<=0,c=e.right>=i,h=e.top<=0,u=e.bottom>=r;!l&&!c||h||u?!h&&!u||l||c?((e,t,i,r,s)=>{const a=e.left,o=i-e.right,n=e.top,l=r-e.bottom,c=Math.min(a,o,n,l);c===a?t.left=Math.max(t.left,e.right+s):c===o?t.right=Math.min(t.right,e.left-s):c===n?t.top=Math.max(t.top,e.bottom+s):t.bottom=Math.min(t.bottom,e.top-s)})(a,t,i,r,s):Xo(a,t,i,s):Ko(a,t,r,s)},Jo=e=>"string"==typeof e?document.querySelector(e):e,Qo=e=>"mapLibreMap"in e?e.mapLibreMap:e,en=(e,t,i)=>{const r=Qo(e).getContainer().getBoundingClientRect(),{width:s,height:a}=r,o={left:i,top:i,right:s-i,bottom:a-i};for(const n of t){const e=Jo(n);if(!e)continue;const t=e.getBoundingClientRect(),l=Yo(t,r);qo(l,s,a)||Zo(l,o,s,a,i)}return o.left>=o.right||o.top>=o.bottom?null:{visibleAreaBounds:o,mapWidthPX:s,mapHeightPX:a}},tn=e=>{const{map:t,surroundingElements:i,paddingPX:r=0}=e,s=en(t,i,r);if(!s)return null;const{visibleAreaBounds:a}=s,o=Qo(t),n=o.unproject([a.left,a.bottom]),l=o.unproject([a.right,a.top]);return[n.lng,n.lat,l.lng,l.lat]},rn=e=>{const{map:t,surroundingElements:i}=e,r=tn({map:t,surroundingElements:i});if(!r)return null;const[s,a,o,n]=r;return[(s+o)/2,(a+n)/2]},sn=e=>{const{map:t,toBeContainedBBox:i,surroundingElements:r,paddingPX:s=0}=e,a=en(t,r,s);if(!a)return null;const{visibleAreaBounds:o,mapWidthPX:n,mapHeightPX:l}=a,c=o.left/n,h=o.right/n,u=o.top/l,d=h-c,p=o.bottom/l-u,[f,y,m,g]=i,_=(m-f)/d,L=(g-y)/p,S=f-c*_,A=g+u*L;return[S,A-L,S+_,A]};export{ve as AbstractDataOwnedMapModule,Ce as AbstractMapModule,He as AbstractSourceWithLayers,we as AbstractStyleOwnedMapModule,Ge as AddedSourceWithLayers,lt as BASE_MAP_SOURCE_ID,qi as BaseMapModule,x as CombinedEvents,Xi as CustomGeoJSONModule,tt as DEFAULT_TEXT_SIZE,Rr as DESELECTED_FOREGROUND_COLOR,Tr as DESELECTED_OUTLINE_COLOR,Or as DESELECTED_ROUTE_FILTER,Cr as DESELECTED_SECONDARY_COLOR,Xe as EventsProxy,Hs as FINISH_INDEX,Ve as GeoJSONSourceWithLayers,hr as GeometriesModule,nt as HILLSHADE_SOURCE_ID,gr as HillshadeModule,Zr as INDEFINITE_DELAY_DASH_COLOR,jr as MAJOR_DELAY_COLOR,Ze as MAP_BOLD_FONT,et as MAP_ITALIC_FONT,Qe as MAP_MEDIUM_FONT,Je as MAP_REGULAR_FONT,Us as MIDDLE_INDEX,zr as MINOR_DELAY_COLOR,Yr as MINOR_DELAY_LABEL_COLOR,$r as MODERATE_DELAY_COLOR,W as ModuleEvents,ot as POI_SOURCE_ID,Bi as POIsModule,Ci as PlacesModule,Er as ROUTE_LINE_FOREGROUND_COLOR,vr as ROUTE_LINE_FOREGROUND_WIDTH,br as ROUTE_LINE_OUTLINE_COLOR,Nr as ROUTE_LINE_OUTLINE_WIDTH,Aa as RoutingModule,wr as SELECTED_ROUTE_FILTER,Ps as START_INDEX,ks as STOP_DISPLAY_INDEX,We as StyleSourceWithLayers,ht as TRAFFIC_FLOW_SOURCE_ID,ct as TRAFFIC_INCIDENTS_SOURCE_ID,Ca as TomTomMap,Ue as TomTomMapSource,io as TrafficAreaAnalyticsModule,uo as TrafficFlowModule,Bo as TrafficIncidentOverlayModule,Vo as TrafficIncidentsModule,Kr as UNKNOWN_DELAY_BG_COLOR,qr as UNKNOWN_DELAY_COLOR,Xr as UNKNOWN_DELAY_DASH_COLOR,Te as UserEvents,nr as adaptPaletteForTheme,k as assertNoReservedScopeNames,Vi as baseMapLayerGroupNames,gt as baseMapPOICategoryValues,gi as buildPlaceTitle,dr as buildReachableRangeFeatures,Zs as buildRoutingLayers,sn as calculateFittingBBox,tn as calculatePaddedBBox,rn as calculatePaddedCenter,or as colorPaletteIDs,ar as colorPalettes,P as combineEventScopes,Js as defaultRoutingLayers,ke as filterLayersBySources,Me as findFeatureByRefId,mr as geometryThemes,Li as getIconIDForPlace,Br as getInstructionLineWidth,Vr as getInstructionOutlineWidth,Fr as getLineForegroundWidth,Pr as getLineOutlineWidth,Ii as getPOIGroupForPlace,Ai as getPOILayerCategoryForPlace,Gi as getStyleCategories,kr as getTollRoadOutlineWidth,Ur as getWaypointIconSize,ft as mapDisplayPoiCategoryMappings,it as mapFonts,at as mapStyleLayerIDs,vi as placesThemes,ki as poiCategoryGroups,pt as poiLayerIDs,Ti as preparePlacesForDisplay,pr as prepareReachableRangesForDisplay,yr as reachableRangeGeometryConfig,Ne as renderedRefId,H as reservedScopeNames,Fa as resolveColorStops,jo as roadCategories,U as scopedLayerSpecs,zo as serviceRoadSubCategories,dt as sharedInstance,_r as standardStyleIDs,$o as streetRoadSubCategories,Lr as styleModules,fr as themedGeometryConfig,mt as toBaseMapPOICategory,Lt as toBaseMapPOIGroup,Ei as toPlaces};
|
|
2
2
|
//# sourceMappingURL=map.es.js.map
|