@tomtom-org/maps-sdk 0.51.5 → 0.53.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.
@@ -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 y,generateTomTomHeaders as f,getPosition as g,iconToTrafficIncidentCategory as m,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 w,getRTLTextPluginStatus as O,getVersion as N,setRTLTextPlugin as M,setWorkerCount as x}from"maplibre-gl";var D=["road_category","road_subcategory","relative_speed","left_hand_traffic","road_closure","absolute_speed","part_of_two_way_road","openlr","display_class"],F=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}}}},P=["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"],U={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},H=e=>{const{properties:t}=e;return{id:e.id,type:e.type,geometry:e.geometry,properties:{id:t.id??y(),description:t?.description_0??"",category:m(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}}}},k=e=>/* @__PURE__ */new Error(`Trying to ${e} while it is not in the map style. Did you exclude it when loading the map?`),W="pinCategories",B=e=>`${W}:${e}`,G=()=>"undefined"!=typeof document&&"undefined"!=typeof DOMParser&&"undefined"!=typeof btoa,V=e=>{if(!G())return;const t=document.createElement("img");return t.src=`data:image/svg+xml;base64,${btoa((new XMLSerializer).serializeToString(e))}`,t},j=e=>(new DOMParser).parseFromString(e,"image/svg+xml").documentElement,z=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))(j('<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 $,Y,q,K=e=>(function(e){if(i(e))throw new Error(`${e} must not be null/undefined. Something went wrong with its initialization.`)}(e),e),X=e=>{const t=e.properties?.id;return"string"==typeof t||"number"==typeof t?t:e.id},Z=(e,t)=>{if(null!=t)for(let i=0;i<e.length;i++)if(X(e[i])===t)return{feature:e[i],index:i}},J=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))}},Q=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}equalSourceAndLayerIDs(e){return this.sourceAndLayerIDs.sourceID===e.sourceAndLayerIDs.sourceID&&this.sourceAndLayerIDs.layerIDs.length===e.sourceAndLayerIDs.layerIDs.length&&this.sourceAndLayerIDs.layerIDs.every((t,i)=>t===e.sourceAndLayerIDs.layerIDs[i])}},ee=(e,t)=>e.getStyle().layers.filter(e=>t.includes(e?.source)),te=class extends Q{constructor(e,t,i){let r=ee(e,[t.id]);i&&(r=r.filter(i)),super(e,new J(t.id,e.getStyle().sources[t.id],t),r)}},ie=class extends Q{constructor(e,t,i,r){super(e,new J(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)))}},re={type:"FeatureCollection",features:[]},se=class extends ie{constructor(e,t,i,r=!0,s){super(e,t,s?.cluster?{type:"geojson",data:re,...s}:{type:"geojson",data:re,promoteId:"id",...s??{}},i),this.shownFeatures=re,this.ensureAddedToMapWithVisibility(!1,r)}show(e,{automaticVisibility:t=!0}={}){this.shownFeatures=e,this.mapRemoved||(K(this.source.runtimeSource).setData(e),t&&this.setLayersVisible(!!e.features.length))}findById(e){return Z(this.shownFeatures.features,e)}clear(){this.show(re)}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})}},ae=async e=>{e.mapReady||(await e.mapLibreMap.once("styledata"),await ae(e))},oe=e=>{const t=globalThis.__DEMOS_PROXY_ENSURE_SESSION__;return"function"!=typeof t?e:t().then(()=>e,()=>e)},ne=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?oe({url:o,credentials:"include"}):{url:o};const h=new URL(o);(e=>{e.pathname.includes("incidents")?e.searchParams.set("tags",P.join(",")):e.pathname.includes("flow")&&e.searchParams.set("tags",D.join(","))})(h);const u={url:h.toString(),headers:{...f(e)}};return l?(u.credentials="include",oe(u)):u}},le=(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})},ce=(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)=>le(e,t[r],i))})(l,c,r)},he=(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]})}},ue=(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)}},de=async(e,t,i)=>{if(!e.mapLibreMap.getSource(t)){const r=e.mapLibreMap;r.isStyleLoaded()||await r.once("idle"),e.setStyle(ue(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 ee(r,[t]))r.setLayoutProperty(e.id,"visibility","none",{validate:!1});await r.once("styledata")}},pe=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(V(j(i))):a((await r.loadImage(i)).data):o(i)},ye=e=>{switch(e){case"standardDark":case"drivingDark":case"monoDark":case"satellite":return"dark";default:return"light"}},fe=e=>{if("string"==typeof e)return ye(e);const t=e;return t?.id?ye(t.id):"light"},ge=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.tomtomMap.mapReady&&(this.moduleReady=!0)}async waitUntilModuleReady(){await ae(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}},me=class{constructor(e,t){this.userEventsInstance=e,this.moduleEventsInstance=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)}},_e=class{constructor(){this.interactiveLayerIDs=[],this.handlers={},this.findHandlers=(e,t,i)=>t&&i&&e.flatMap(e=>{const r=this.handlers[t]?.[e];return 1===r?.length?r:this.handlers[t]?.[e]?.filter(e=>e.layerIDs.includes(i))||[]})||[]}ensureInteractiveLayerIDsAdded(e){e._layerSpecs.forEach(e=>{this.interactiveLayerIDs.includes(e.id)||this.interactiveLayerIDs.push(e.id)})}addEventHandler(e,t,i,r){this.ensureInteractiveLayerIDsAdded(e);const s=e.source.id;this.handlers[s]||(this.handlers[s]={[i]:[]}),this.handlers[s][i]??=[],this.handlers[s][i]?.push({sourceWithLayers:e,layerIDs:e._layerSpecs.map(e=>e.id),fn:t,config:r})}removeHandler(t,i,r){const s=this.handlers[t.source.id]?.[i];s&&(o(s,e=>e.fn===r),s.length||(delete this.handlers[t.source.id]?.[i],e(this.handlers[t.source.id])&&delete this.handlers[t.source.id]))}remove(t,i){const r=this.handlers[t.source.id]?.[i];r&&(o(r,e=>{return i=t._layerSpecs,e.layerIDs.every((e,t)=>e===i[t].id);var i}),r.length||(delete this.handlers[t.source.id]?.[i],e(this.handlers[t.source.id])&&delete this.handlers[t.source.id]));for(const e of t._layerSpecs)o(this.interactiveLayerIDs,t=>e.id===t)}removeAll(){this.interactiveLayerIDs=[],this.handlers={}}hasSourceID(e){return!!this.handlers[e]}sourceWithLayersFor(e){if(!e)return;const t=this.handlers[e];if(t)for(const i of Object.values(t))if(i?.length)return i[0].sourceWithLayers}updateIfRegistered(e){for(const t of Object.values(e)){const e=this.handlers[t.source.id];if(e)for(const i of Object.values(e))for(const e of i)t.equalSourceAndLayerIDs(e.sourceWithLayers)&&(e.sourceWithLayers=t)}}},Le=e=>"click"===e||"contextmenu"===e,Ae=(e,t,i,r="updateInProps")=>{const{feature:a,index:o}=Z(i,t)||{};if(a&&(!Le(a.properties?.eventState)||Le(e))){const t={...a,properties:"updateInProps"===r?{...a?.properties,eventState:e}:s(a?.properties,"eventState")};return i.splice(o,1,t),o}},Se=(e,t,r)=>{const s=[...r.shownFeatures.features],a=Ae(e,X(t),s,"removeFromProps");i(a)||r.show({...r.shownFeatures,features:s},{automaticVisibility:!1})},Ie=(e,t,i,r,s)=>{if(t&&r instanceof se){const n=[...r.shownFeatures.features];return Ae(e,X(t),n),!i||(o=t,(a=i)&&o&&a.id===o.id)||(s===r?Ae(e,X(i),n,"removeFromProps"):s instanceof se&&Se(e,i,s)),void r.show({...r.shownFeatures,features:n},{automaticVisibility:!1})}var a,o;i&&s instanceof se&&Se(e,i,s)},Ee={precisionMode:"box",paddingBoxPx:5,cursorOnHover:"pointer",cursorOnMouseDown:"grabbing",cursorOnMap:"default",longHoverDelayAfterMapMoveMS:800,longHoverDelayOnStillMapMS:300},be=class extends _e{constructor(e,t={}){super(),this.enabled=!0,this.firstDelayedHoverSinceMapMove=!0,this.map=e,this.mapCanvas=e.getCanvas(),this.config={...Ee,...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()}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){const i=(e=>{const t=/* @__PURE__ */new Set,i=[];for(const r of e){const e=X(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})((r=e,(s=t)?r.filter(e=>e.source===s):r));var r,s;const a=this.sourceWithLayersFor(t);return a instanceof se?i.map(e=>a.findById(X(e))?.feature??e):i}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){Ie("long-hover",this.hoveringFeature,void 0,this.hoveringSourceWithLayers,void 0);const e=this.findHandlers(["long-hover"],this.hoveringFeature?.source,this.hoveringFeature?.layer.id);if(e.length){const t=this.toCallerFeatures(this.hoveringFeatures??[],this.hoveringFeature?.source);for(const i of e)i.fn(t[0],this.hoveringLngLat,t,i.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){if(!this.isEnabled())return;this.hoveringFeatures=this.getRenderedFeatures(e.point);const[t]=this.hoveringFeatures;if(t&&!this.hasSourceID(t.source))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){this.hoveringLngLat=e.lngLat,this.hoveringPoint=e.point;const s=this.hoveringFeature;this.hoveringFeature=t;const a=this.hoveringSourceWithLayers,o=this.findHandlers(["hover","hover-move","long-hover","click","contextmenu"],t?.source,t?.layer.id)?.[0];let n;if(this.hoveringSourceWithLayers=this.sourceWithLayersFor(t?.source),i){this.updateHoverCursor(o?.config),Ie("hover",this.hoveringFeature,s,this.hoveringSourceWithLayers,a);const i=this.findHandlers(["hover"],t?.source,t?.layer.id);if(i.length){n=this.toCallerFeatures(this.hoveringFeatures,t?.source);for(const t of i)t.fn(n[0],e.lngLat,n,t.sourceWithLayers)}}if(r){const t=this.findHandlers(["hover-move"],this.hoveringFeature?.source,this.hoveringFeature?.layer.id);if(t.length){n??=this.toCallerFeatures(this.hoveringFeatures,this.hoveringFeature?.source);for(const i of t)i.fn(n[0],e.lngLat,n,i.sourceWithLayers)}}this.restartLongHoverTimeout()}}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?.source,this.lastClickedFeature?.layer.id);if(this.lastClickedSourceWithLayers=a[0]?.sourceWithLayers,Ie(e,this.lastClickedFeature,r,this.lastClickedSourceWithLayers,s),a.length){const e=this.toCallerFeatures(i,this.lastClickedFeature?.source);for(const i of a)i.fn(e[0],t.lngLat,e,i.sourceWithLayers)}}},Re={country:"Places - Country name",lowestPlaceLabel:"Places - Village / Hamlet",poi:"POI",lowestLabel:"Borders - Treaty label",lowestRoadLine:"Tunnel - Railway outline",lowestBuilding:"Buildings - Underground"},Te="vectorTiles",Ce="hillshade",ve="vectorTiles",we="vectorTilesIncidents",Oe="vectorTilesFlow",Ne=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}},Me=class{constructor(e,t,i,r){this.eventProxy=e,this.config=i,this.mapping=r,this.sources=Array.isArray(t)?t:[t]}on(e,t){const i=[];if(this.mapping){const r=this.mapping;for(const s of this.sources){const a=(e,...i)=>t(r(e),...i);this.eventProxy.addEventHandler(s,a,e,this.config),i.push({source:s,registeredHandler:a})}}else for(const r of this.sources)this.eventProxy.addEventHandler(r,t,e,this.config),i.push({source:r,registeredHandler:t});return()=>{for(const{source:t,registeredHandler:r}of i)this.eventProxy.removeHandler(t,e,r)}}off(e){for(const t of this.sources)this.eventProxy.remove(t,e)}},xe=["POI","POI - Micro"],De={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"},Fe={...De,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"},Pe=e=>Fe[e],Ue=Array.from(new Set(Object.values(Fe))),He={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"},ke=e=>{const t=Pe(e);return t?He[t]:void 0},We="Noto-Bold",Be=.8,Ge=["interpolate",["linear"],["zoom"],8,.6,22,Be],Ve="title",je="iconID",ze=.7,$e="default_place",Ye="poi-parking-micro",qe={"icon-image":["get",je],"icon-anchor":"bottom","icon-size":Ge,"icon-allow-overlap":!0,"icon-padding":0},Ke={"icon-translate":[0,5],"icon-translate-anchor":"viewport"},Xe={"text-optional":!0,"text-font":[We],"text-field":["get",Ve],"text-justify":"auto","text-variable-anchor":["top","left","right"],"text-variable-anchor-offset":["top",[0,ze],"left",[1.4,-1.4],"right",[-1.4,-1.4]],"text-size":["interpolate",["linear"],["zoom"],10,14,18,16],"text-padding":5},Ze={"text-halo-width":["interpolate",["linear"],["zoom"],6,1,10,1.5],"text-translate-anchor":"viewport"},Je={type:"symbol",layout:{...qe,...Xe},paint:{...Ke,...Ze}},Qe=(e,t)=>`${e}-${t}`,et=["has","point_count"],tt=["!",et],it="clusterBaseMapIconIDs",rt=["all",et,["==",["index-of",",",["get",it]],-1]],st=["all",et,[">=",["index-of",",",["get",it]],0]],at=[12,-14],ot={[it]:($="baseMapIconID",Y=it,[["case",["==",["get",Y],null],["accumulated"],["==",["accumulated"],null],["get",Y],[">=",["index-of",["concat",",",["get",Y],","],["concat",",",["accumulated"],","]],0],["accumulated"],["concat",["accumulated"],",",["get",Y]]],["get",$]])},nt=e=>{const t=["match",e];for(const i of Ue){const e=`poi-${i}`;t.push(e,["image",e])}return t.push(["image",Ye]),t},lt={type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#3f9cd9","line-width":1.5,"line-dasharray":[2,2],"line-opacity":.9}},ct={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}},ht=(e,t)=>{if(!e)return;const i=(e=>{try{if("string"==typeof e){if(e.includes("<svg")){const t=j(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}},ut=e=>Boolean(e&&"availability"in e&&e.availability),dt=e=>"ELECTRIC_VEHICLE_STATION"===e.properties.poi?.categories?.[0]&&ut(e.properties.chargingPark),pt=e=>{const t=e.properties.chargingPark;if(ut(t)){const e=t.availability.chargingPointAvailability,i=e.statusCounts.Available??0;return{availableCount:i,totalCount:e.count,ratio:i/e.count}}},yt=(e,t)=>`${e}/${t}`,ft=e=>pt(e)?.ratio??0,gt=e=>["case",[">=",["get","evAvailabilityRatio"],e?.threshold??0],"green","red"],mt=e=>Math.round(1e4*e)/1e4,_t=(e,t,i,r)=>{const s=void 0!==r;return{top:s?[0,r]:[0,mt(e)],left:s?[r,mt(i)]:[mt(t),mt(i)],right:s?[-r,mt(i)]:[-mt(t),mt(i)]}},Lt=(e,t,i,r)=>{const s=(e=>{if(!e)return Be;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 Be})(e)/Be,a="base-map"===i||"circle-icon"===i;if(a&&void 0!==r)return{"text-offset":[r,r]};const o=1.4*s,n=_t(ze*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:ze)*u.heightScale,t=1.4*u.widthScale,i=_t(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}},At=(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,...Lt(e,i,t?.theme,a?.offset)}}return h},St=(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}},It=["in",["get","eventState"],["literal",["click","contextmenu"]]],Et=e=>JSON.parse(JSON.stringify(e)?.replaceAll("name",Ve)),bt=(e,t)=>e.getStyle().layers.find(e=>e.id===t)??{},Rt=e=>({filter:["!",It],type:"symbol",paint:e.paint,layout:e.layout?s(e.layout,"visibility"):void 0}),Tt=e=>{const t=Rt(bt(e,"POI")),i=t.layout?.["text-size"];return{...t,layout:{...t.layout,"icon-image":["get",je],"text-field":["get",Ve],...i&&{"text-size":Et(i)}}}},Ct=e=>{const t=Rt(bt(e,"POI - Micro"));return{...t,minzoom:0,layout:{...t.layout,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{...t.paint,"icon-opacity":1}}},vt=e=>{const t=bt(e,"POI").layout??{};return{...Je,layout:{...Je.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:{...Je.paint,"icon-translate":[0,0]}}},wt=["has","eventState"],Ot={type:"symbol",layout:{visibility:"none"}},Nt={type:"circle",layout:{visibility:"none"}},Mt="#3f9cd9",xt={...Je,filter:["!",wt]},Dt={...Je,filter:wt,layout:{...Je.layout,"icon-size":["interpolate",["linear"],["zoom"],8,.8,22,1],"text-allow-overlap":!0},paint:{...Je.paint,"text-color":Mt}},Ft=e=>({...e,filter:wt,layout:{...e.layout,"text-allow-overlap":!0},paint:{...e.paint,"text-color":Mt}}),Pt=(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",Ve],{},"\n",{},["get","evAvailabilityText"],{"font-scale":1.1,"text-color":gt(e?.evAvailability)}],["get",Ve]]:["get",Ve])(t,n):void 0;return{...e,...o,layout:At(e,t,i,l,s),paint:St(e,t,i,r)}},Ut=(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=ht(s.image,e?.theme);if(void 0!==r){const e=Qe(s.id,t);if(i.set(e,r),s.availabilityLevel){const e=Qe(`${s.id}-${s.availabilityLevel}`,t);i.set(e,r)}}}return i})(e,r);let a,o,n=Ot,l=Ot,c=Nt,h=Ot,u=Nt,d=Ot;if("base-map"===e?.theme)a={...Tt(t),minzoom:10},n=Ct(t),o=(e=>Ft(Tt(e)))(t);else if("circle-icon"===e?.theme)a=(e=>({...vt(e),filter:["!",wt]}))(t),o=(e=>Ft(vt(e)))(t);else if("pin-clustered"===e?.theme){a={...xt,filter:["all",tt,["!",wt]]},o={...Dt,filter:["all",tt,wt]};const e=Ct(t);n={...e,filter:e.filter?["all",tt,e.filter]:tt},l={type:"symbol",filter:rt,layout:{"icon-image":nt(["get",it]),"icon-size":1,"icon-allow-overlap":!0,"icon-ignore-placement":!0}},c={type:"circle",filter:rt,paint:{"circle-radius":11,"circle-color":"#000000","circle-stroke-color":"#FFFFFF","circle-stroke-width":1.5,"circle-translate":at,"circle-translate-anchor":"viewport"}},h={type:"symbol",filter:rt,layout:{"text-field":["get","point_count_abbreviated"],"text-font":[We],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#FFFFFF","text-translate":at,"text-translate-anchor":"viewport"}},u={type:"circle",filter:st,paint:{"circle-radius":15,"circle-color":"#000000","circle-stroke-color":"#FFFFFF","circle-stroke-width":1.5}},d={type:"symbol",filter:st,layout:{"text-field":["get","point_count_abbreviated"],"text-font":[We],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#FFFFFF"}}}else a=xt,o=Dt;return{micro:{...Pt(n,e,"micro",i,s),beforeID:Re.lowestPlaceLabel},main:{...Pt(a,e,"main",i,s),beforeID:"selected"},selected:Pt(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}},Ht=e=>{if(G())return V(z(e))},kt=(e,t)=>"string"!=typeof e?e:t.features.find(t=>t.id===e),Wt=/* @__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]),Bt=e=>e.properties.poi?.name??e.properties.address.freeformAddress,Gt=(e,t,i)=>{if("pin"===t||"pin-clustered"===t)return(e=>{if(e)return Wt.has(e)?B(e.toString()):B(e.toString().substring(0,4))})(S[e])??i;{const t=Pe(e);return t?`poi-${t}`:i}},Vt=(e,t,i={})=>{const r=i.theme??"pin",s=((e,t)=>e.icon?.default||"base-map"!==(e.theme??"pin")?Qe($e,t):Ye)(i,t),a=i.icon?.mapping;if(a)return"imageID"===a.to?a.fn(e):Gt(a.fn(e),r,s);const o=e.properties.poi?.categories?.[0],n=((e,t,i,r,s)=>{if(!r.evAvailability?.enabled||!dt(e))return;const a=ft(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?Qe(`${n.id}-${a}`,i):o||"pin"!==s?void 0:B(`7309-${a}`)})(e,o,t,i,r);if(n)return n;const l=i.icon?.categoryIcons?.find(e=>e.id===o);return l?Qe(l.id,t):Gt(o,r,s)},jt=(e,t)=>{const i=t?.icon?.mapping;return"poiCategory"===i?.to?i.fn(e):e.properties.poi?.categories?.[0]},zt=(e,t)=>{const i=jt(e,t);return i&&Pe(i)},$t=(e,t)=>{const i=jt(e,t);return i&&ke(i)},Yt=e=>Array.isArray(e)?{type:"FeatureCollection",features:e}:"Feature"===e.type?{type:"FeatureCollection",features:[e]}:e,qt=(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,dt(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=>dt(e)?((e,t)=>{const i=pt(e);return i?(t?.formatText??yt)(i.availableCount,i.totalCount):""})(e,t):"",evAvailabilityRatio:e=>dt(e)?ft(e):0}},Kt=(e,t)=>{const i=zt(e,t);return i?`poi-${i}`:Ye},Xt=(e,t,i={})=>{const r=Yt(e),s=!0===i.evAvailability?.enabled?qt(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):Bt(e),a=s?Object.fromEntries(Object.entries(s).map(([t,i])=>[t,"function"==typeof i?i(e):i])):{},o=e.id??y();return{...e,id:o,geometry:{...e.geometry,bbox:e.bbox},properties:{...e.properties,id:o,title:r,iconID:Vt(e,t,i),...("base-map"===i?.theme||"pin-clustered"===i?.theme)&&{category:zt(e,i),group:$t(e,i)},..."pin-clustered"===i?.theme&&{baseMapIconID:Kt(e,i)},...a}}})}},Zt=class e extends ge{static async get(t,i){return await ae(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=Qe($e,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 se(this.mapLibreMap,this.sourceID,r.clusteredSpecs,!1,i);let a;r.unclusteredSpecs.length>0&&(a=new se(this.mapLibreMap,this.unclusteredSourceID,r.unclusteredSpecs,!1)),he([...s._layerSpecs,...a?._layerSpecs??[]],this.mapLibreMap),this.connectionLayerSpecs=this.buildConnectionLayerSpecs(e);const o=new se(this.mapLibreMap,this.connectionSourceID,Object.values(this.connectionLayerSpecs),!1);return he(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=Ut(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:ot}}buildConnectionLayerSpecs(e){const t=(e=>{const t=e?.layers?.line,i=e?.layers?.label;return{line:{...lt,...t,layout:{...lt.layout,...t?.layout},paint:{...lt.paint,...t?.paint}},label:{...ct,...i,layout:{...ct.layout,...i?.layout},paint:{...ct.paint,...i?.paint}}}})(e?.connections),i=`${this.layerIDPrefix}-connection-line`,r=`${this.layerIDPrefix}-connection-label`,s=Re.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:[]};ce(i.clusteredSpecs,r.clusteredSpecs,this.sourcesWithLayers.places,this.mapLibreMap),this.sourcesWithLayers.placesUnclustered&&i.unclusteredSpecs.length>0&&ce(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=Xt(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;ce(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=kt(a.from,t),i=kt(a.to,t);if(!e||!i)continue;const o=a.id??y(),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;pe("if-not-in-sprite",Qe(e,this.instanceIndex),t.image,this.mapLibreMap,{pixelRatio:t.pixelRatio??2})}e.icon.default&&(e.icon.default.image&&pe("if-not-in-sprite",this.defaultPlaceIconID,e.icon.default.image.image,this.mapLibreMap,{pixelRatio:e.icon.default.image.pixelRatio??2}),e.icon.default.style&&pe("if-not-in-sprite",this.defaultPlaceIconID,Ht(e.icon.default.style),this.mapLibreMap,{pixelRatio:2}))}else pe("if-not-in-sprite",this.defaultPlaceIconID,Ht(),this.mapLibreMap,{pixelRatio:2})}updateData(e){const t=Xt(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=Xt(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(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)}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(){return new me(new Me(this.eventsProxy,this.sourcesWithLayers.places,this.config?.events),new Ne(this.configChangeHandlers,this.shownFeaturesHandlers))}},Jt=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(!Jt(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}},Qt=e=>e?.length?1===e.length?e[0]:{expression:["any",...e.map(e=>e?.expression)],legacy:["any",...e.map(e=>e?.legacy)]}:null,ei=(e,t)=>{return t?["all",e[(i=t,Jt(i)?"expression":"legacy")],t]:e.expression;var i},ti=(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]}},ii=(e,t,i)=>ti(e,t.show,i?t.values.map(i):t.values),ri={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"]},si=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}}},ai=e=>{const t=[];return e.forEach(e=>{e in ri?t.push(...ri[e].map(Pe)):t.push(Pe(e))}),[...new Set(t)]},oi=class e extends ge{static async get(t,i){return await ae(t),new e(t,i)}constructor(e,t){super("style",e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Te);if(!t)throw k(`init ${e.name} with source ID ${Te}`);const i=new te(this.mapLibreMap,t,e=>xe.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=ti("category",e.show,ai(e.values));this.mapLibreMap.setFilter("POI",ei(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(si)}}get events(){return new me(new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.poi,this.config?.events,si),new Ne(this.configChangeHandlers,[]))}},ni=["land","water","buildings2D","roads","railways","ferries","borders","buildings3D","natureLabels","roadLabels","roadShields","houseNumbers","smallerTownLabels","stateLabels","cityLabels","allPlaceLabels","capitalLabels","countryLabels"],li={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"]}},ci=(e,t)=>{const i=li[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))},hi=e=>t=>(!e||((e,t)=>{const i=t?.mode,r=t?.names;if(i&&r?.length){if("include"===i)return r.some(t=>ci(t,e));if("exclude"===i)return!r.some(t=>ci(t,e))}return!0})(t,e))&&!xe.includes(t.id),ui=class e extends ge{static async get(t,i){return await ae(t),new e(t,i)}constructor(e,t){super("style",e,t)}_initSourcesWithLayers(t){const i=this.mapLibreMap.getSource(ve);if(!i)throw k(`init ${e.name} with source ID ${ve}`);const r=new te(this.mapLibreMap,i,hi(t?.layerGroupsFilter));return this.layersByGroup=void 0,{vectorTiles:r}}_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(){return this.sourcesWithLayers.vectorTiles.isAnyLayerVisible()}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&&(e=>{const t=e.mode,i=e.names;return"include"===t?e=>i.some(t=>ci(t,e)):"exclude"===t?e=>!i.some(t=>ci(t,e)):(console.error("Unrecognized layer group mode:",t),()=>!0)})(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(ni.map(e=>[e,[]]));for(const i of e)for(const e of ni)ci(e,i)&&t[e].push(i.id);return t})(this.sourcesWithLayers.vectorTiles._layerSpecs),this.layersByGroup}get events(){return new me(new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.vectorTiles,this.config?.events),new Ne(this.configChangeHandlers,[]))}},di=class e extends ge{static async get(t,i){return await ae(t),pi(i),new e(t,i)}constructor(e,t){super("geojson",e,t)}_initSourcesWithLayers(e,t){const i=e??this.config;t||(this.lastShown={},this.shownFeaturesHandlersBySource=/* @__PURE__ */new Map),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 se(this.mapLibreMap,e,t,!0,a),this.shownFeaturesHandlersBySource.has(s)||this.shownFeaturesHandlersBySource.set(s,[])}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.config;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;ce(r,i,s,this.mapLibreMap);const a=[];for(const e of s._layerSpecs)this.mapLibreMap.getLayer(e.id)||a.push(e);a.length>0&&(he(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=yi(t);this.lastShown[e]=i,this.sourcesWithLayers[e].show(i);const r=this.shownFeaturesHandlersBySource.get(e);if(r)for(const s of r)s(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={};for(const t of Object.keys(this.sourcesWithLayers)){const i=this.sourcesWithLayers[t],r=this.shownFeaturesHandlersBySource.get(t)??[];e[t]=new me(new Me(this.eventsProxy,i,this.config?.events),new Ne(this.configChangeHandlers,r))}return e}},pi=e=>{if(!e.sources||0===Object.keys(e.sources).length)throw new Error("CustomGeoJSONModule requires at least one source in config.sources.");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.`)},yi=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},fi="#0A3653",gi="#555555",mi={type:"fill",paint:{"fill-color":["coalesce",["get","color"],fi],"fill-opacity":["case",["==",["get","theme"],"outline"],0,.15],"fill-antialias":!1}},_i={type:"line",paint:{"line-color":["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],gi],["coalesce",["get","color"],fi]],"line-opacity":["case",["==",["get","theme"],"outline"],.9,1],"line-width":["case",["==",["get","theme"],"outline"],5,2]}},Li=(e,t,r)=>{const s=r?.fill,a=r?.line,o={...mi,id:e,paint:{...mi.paint,...!i(s?.opacity)&&{"fill-opacity":s?.opacity},...s?.color&&{"fill-color":["get","color"]}}},n=a?.layer;return[o,{..._i,...n,id:t,...n?.layout&&{layout:{..._i.layout,...n.layout}},paint:{..._i.paint,...n?.paint,...!i(a?.color)&&{"line-color":a?.color},...!i(a?.width)&&{"line-width":a?.width},...!i(a?.opacity)&&{"line-opacity":a?.opacity}}}]},Ai=(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":[We],"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"}}},Si=(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":[We],"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}}}},Ii={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"]},Ei=Object.keys(Ii),bi=(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&&Ii[i]){const e=Ii[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??y()}}})}),Ri=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??y();return{type:"Feature",id:i,geometry:{type:"Point",coordinates:t},properties:{...e.properties,id:i}}});return{type:"FeatureCollection",bbox:e.bbox,features:t}},Ti=class e extends ge{static async get(t,i){return await ae(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]=Li(this.fillLayerID,this.outlineLayerID,e),s=Ai(this.titleLayerID,e);this.titleLayerSpecs=s,this.geometryFillLayerSpecs=i,this.geometryOutlineLayerSpecs=r;const a=void 0===e?.lineLabelConfig?null:Si(this.lineLabelLayerID,e);return this.lineLabelLayerSpecs=a,{geometry:new se(this.mapLibreMap,this.sourceID,[{...i},{...r},...a?[a]:[]]),geometryLabel:new se(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:Re[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(Ri(this.sourcesWithLayers.geometry.shownFeatures)),this.config=t,this.emitConfigChange()}updateLayerAndData(e){const[t,i]=Li(this.fillLayerID,this.outlineLayerID,e),r=Ai(this.titleLayerID,e);if(le(t,this.geometryFillLayerSpecs,this.mapLibreMap),le(i,this.geometryOutlineLayerSpecs,this.mapLibreMap),le(r,this.titleLayerSpecs,this.mapLibreMap),this.geometryFillLayerSpecs=t,this.geometryOutlineLayerSpecs=i,this.titleLayerSpecs=r,this.lineLabelLayerSpecs){const t=Si(this.lineLabelLayerID,e);le(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(bi(i,this.config)),this.sourcesWithLayers.geometryLabel.show(Ri(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 new me(new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.geometry,this.config?.events),new Ne(this.configChangeHandlers,this.shownFeaturesHandlers))}},Ci={timeMinutes:"min",distanceKM:"km",remainingChargeCPT:"% remaining",spentChargePCT:"% spent",spentFuelLiters:"L"},vi=(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} ${Ci[r.type]??r.type}`:String(t+1)});return{type:"FeatureCollection",...e.bbox&&{bbox:e.bbox},features:vi(r,s,t)}},Oi=(e="fadedRainbow",t="lowestLabel")=>({beforeLayerConfig:t,line:{width:["case",["==",["get","theme"],"outline"],5,1],color:["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],gi],"grey"],opacity:["case",["==",["get","theme"],"outline"],.9,1]},fill:{color:e,opacity:["case",["==",["get","theme"],"outline"],0,.6]},lineLabelConfig:{}}),Ni=(e="fadedRainbow",t,i,r)=>{const s=Oi(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}},Mi=["filled","outline","inverted"],xi=class e extends ge{static async get(t,i){return await ae(t),await de(t,Ce,"hillshade"),new e(t,i)}constructor(e,t){super("style",e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Ce);if(!t)throw k(`init ${e.name} with source ID ${Ce}`);return{hillshade:new te(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 new me(new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.hillshade,this.config?.events),new Ne(this.configChangeHandlers,[]))}},Di=["standardLight","standardDark","drivingLight","drivingDark","monoLight","monoDark","satellite"],Fi=["trafficIncidents","trafficFlow","hillshade"],Pi=(e,t,i)=>Math.min(Math.max(t,e),i),Ui=e=>!e.some(Number.isNaN),Hi=e=>Number.parseInt(e.padEnd(2,e),16)/255,ki=(e,t)=>Pi(t?e/100:e,0,1),Wi=/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,/])\s*([\de.+-]+)(%)?)?\s*\)$/,Bi=/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,/])\s*([\de.+-]+)(%)?)?\s*\)$/,Gi=e=>{const t=Bi.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,Pi(+s,0,100),Pi(+o,0,100),l?ki(+l,c):1];return Ui(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},Vi=e=>{const t=e.toLowerCase().trim();if("transparent"===t)return[0,0,0,0];const i=ji[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[Hi(e.slice(1,1+t)),Hi(e.slice(1+t,1+2*t)),Hi(e.slice(1+2*t,1+3*t)),Hi(e.slice(1+3*t)||"ff")]})(t):t.startsWith("rgb")?(e=>{const t=Wi.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 y=[r,o,c].join(""),f="%%%"===y?100:""===y?255:0;if(!f)return;const g=[Pi(+i/f,0,1),Pi(+a/f,0,1),Pi(+l/f,0,1),u?ki(+u,d):1];return Ui(g)?g:void 0})(t):Gi(t)},ji={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]},zi="#36A8F0",$i="#105287",Yi="#ABAFB3",qi="#3C4956",Ki="#727C85",Xi=["interpolate",["linear"],["zoom"],1,3,5,4,10,7,18,10],Zi=["==",["get","routeState"],"selected"],Ji=["==",["get","routeState"],"deselected"],Qi=["interpolate",["linear"],["zoom"],1,5,5,6,10,10,18,14],er={s:["interpolate",["linear"],["zoom"],1,2,5,3,10,5,18,7],m:Xi,l:["interpolate",["linear"],["zoom"],1,5,5,6,10,11,18,15]},tr={s:["interpolate",["linear"],["zoom"],1,4,5,5,10,8,18,11],m:Qi,l:["interpolate",["linear"],["zoom"],1,7,5,9,10,14,18,19]},ir={s:["interpolate",["linear"],["zoom"],8,.45,22,.6],m:["interpolate",["linear"],["zoom"],8,.6,22,.8],l:["interpolate",["linear"],["zoom"],8,.75,22,1]},rr=e=>er[e??"m"],sr=e=>tr[e??"m"],ar=e=>ir[e??"m"],or={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]},nr=e=>or[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]},cr={s:["interpolate",["linear"],["zoom"],16,10,22,14],m:["interpolate",["linear"],["zoom"],16,14,22,20],l:["interpolate",["linear"],["zoom"],16,20,22,28]},hr=e=>lr[e??"m"],ur=e=>cr[e??"m"],dr="#AD0000",pr="#FB2D09",yr="#FFC105",fr="#f58240",gr="#000000",mr="#C7D2D8",_r="rgba(190, 39, 27, 1)",Lr="rgba(137, 150, 168, 1)",Ar=e=>!1===e?.visible?"":e?.title??["format",["get","title"],"\n",["get","chargingPower"]," • ",["get","chargingDuration"]],Sr=e=>({...Je,filter:Zi,minzoom:4,layout:{...Je.layout,"text-field":Ar(e?.text)},paint:{...Je.paint}}),Ir={filter:Zi,minzoom:16},Er={"line-cap":"round"},br=e=>({...Ir,type:"line",layout:Er,paint:{"line-width":ur(e),"line-color":"grey"}}),Rr=e=>({...Ir,type:"line",layout:Er,paint:{"line-width":hr(e),"line-color":"white"}}),Tr="instruction-arrow",Cr={...Ir,type:"symbol",layout:{"icon-allow-overlap":!0,"icon-image":Tr,"icon-rotation-alignment":"map","icon-rotate":["get","lastPointBearingDegrees"],"icon-size":["interpolate",["linear"],["zoom"],16,1,22,2]}},vr=e=>({filter:Zi,type:"line",layout:{"line-join":"round"},paint:{"line-width":rr(e),"line-color":"#6dc4ed"}}),wr={filter:Zi,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}},Or={type:"line",layout:{"line-join":"round","line-cap":"round","line-sort-key":["get","index"]}},Nr=e=>({...Or,filter:Ji,paint:{"line-color":qi,"line-width":sr(e)}}),Mr=e=>({...Or,filter:Ji,paint:{"line-color":Yi,"line-width":rr(e)}}),xr=(e,t)=>({...Or,filter:Zi,paint:{"line-color":t??"#105287","line-width":sr(e)}}),Dr=(e,t)=>({...Or,filter:Zi,paint:{"line-color":t??"#36A8F0","line-width":rr(e)}}),Fr={type:"symbol",layout:{"symbol-placement":"line","icon-image":"roads-arrow-white","icon-rotate":180}},Pr="selected-route-summary-popup",Ur="deselected-route-summary-popup",Hr=e=>({filter:Zi,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-width":nr(e),"line-color":"#BEBFFA"}}),kr={filter:Zi,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]}},Wr=["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],Br=["match",["get","magnitudeOfDelay"],"unknown",_r,Lr],Gr=["match",["get","magnitudeOfDelay"],"minor",fr,"moderate",pr,"major",dr,"indefinite","#666666",gr],Vr=e=>({type:"line",layout:{"line-cap":"round"},paint:{"line-width":rr(e),"line-color":["match",["get","magnitudeOfDelay"],"minor",yr,"moderate",pr,"major",dr,mr]}}),jr=e=>({type:"line",filter:Wr,layout:{"line-join":"round"},paint:{"line-width":rr(e),"line-color":Br,"line-dasharray":[1.5,1]}}),zr={filter:Zi,type:"symbol",minzoom:6,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-ignore-placement":!0}},$r={...zr,filter:["all",["has","jamIconID"],zr.filter],layout:{...zr.layout,"icon-image":["get","jamIconID"],"icon-anchor":"bottom-left","text-anchor":"bottom-left","text-field":["get","title"],"text-font":[We],"text-offset":[3.9,-1.4],"text-size":13},paint:{...zr.paint,"text-color":Gr,"text-halo-color":"#FFFFFF","text-halo-width":1}},Yr={...zr,filter:["all",["has","causeIconID"],zr.filter],layout:{...zr.layout,"icon-image":["get","causeIconID"],"icon-anchor":"bottom-right"},paint:{...zr.paint}},qr=e=>({filter:Zi,type:"line",layout:{"line-join":"round"},paint:{"line-width":rr(e),"line-color":"#000000","line-opacity":.3}}),Kr=e=>({filter:Zi,type:"line",layout:{"line-join":"round"},paint:{"line-color":$i,"line-width":rr(e)}}),Xr=e=>({filter:Zi,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":zi,"line-width":rr(e),"line-dasharray":[0,1.5]}}),Zr="traffic-clear",Jr="traffic-major",Qr="traffic-moderate",es="traffic-minor",ts=["has","formattedTraffic"],is=e=>{const t=void 0!==e?Qe(Pr,e):Pr,i=void 0!==e?Qe(Ur,e):Ur,r=void 0!==e?Qe(Zr,e):Zr,s=void 0!==e?Qe(Jr,e):Jr,a=void 0!==e?Qe(Qr,e):Qr,o=void 0!==e?Qe(es,e):es;return{type:"symbol",layout:{"icon-image":["case",Zi,t,i],"symbol-placement":"point","icon-rotation-alignment":"viewport","text-rotation-alignment":"viewport","symbol-sort-key":["case",Zi,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",[We]],"text-color":["case",Zi,"black",Ki]},["concat","\t\t",["get","formattedDistance"]],{"text-color":Ki},["case",ts,"\n",""],{},["image",["case",ts,["match",["get","magnitudeOfDelay"],"major",s,"moderate",a,"minor",o,r],""]],{},["case",ts,["concat"," ",["get","formattedTraffic"]],""],{"text-font":["literal",[We]],"text-color":Gr}]},paint:{"icon-translate":[0,-35],"text-translate":[0,-35]}}},rs=is(),ss="start",as="middle",os="finish",ns="indexType",ls="stopDisplayIndex",cs="waypointStart",hs="waypointStop",us="waypointSoft",ds="waypointFinish",ps={"text-field":["get",ls],"text-font":[We],"text-size":["interpolate",["linear"],["zoom"],13,14,18,16],"text-offset":[0,-1.6],"icon-anchor":["case",["all",["==",["get",ns],as],["!",["has",ls]]],"center","bottom"],"text-allow-overlap":!0},ys={type:"symbol",paint:{...Ke,"text-color":"#ffffff"},layout:{...qe,...ps,"symbol-sort-key":["case",["==",["get",je],us],0,["abs",["-",["get","index"],1e3]]]}},fs={type:"symbol",paint:{...Ze,"text-color":"black","text-halo-width":1.5,"text-halo-color":"#ffffff"},layout:{...Xe,"text-anchor":"top","text-offset":[0,.4]}},gs=(e,t)=>e&&t&&(e.startsWith("route")||e.startsWith("waypoint"))?`${t}-${e}`:e,ms=(e,t)=>e&&t?Object.fromEntries(Object.entries(e).map(([e,i])=>[e,i?.beforeID?{...i,beforeID:gs(i.beforeID,t)}:i])):e,_s=(e,t)=>t?{...e,...t,...t.paint&&{paint:{...e.paint,...t.paint}},...t.layout&&{layout:{...e.layout,...t.layout}}}:e,Ls=(e,t)=>e&&void 0!==t?`${e}-${t}`:e,As=(e={},t,i)=>{const r=e.layers,s=r?.sections,a=e.theme?.mainColor,o=a?((e,t)=>{const i=Vi(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=ar(l);return{mainLines:{routeLineArrows:_s({...Fr,beforeID:Re.lowestLabel},r?.mainLines?.routeLineArrows),routeLine:_s({...Dr(n,a),beforeID:gs("routeIncidentBackgroundLine",t)},r?.mainLines?.routeLine),routeOutline:_s({...xr(n,o),beforeID:gs("routeLine",t)},r?.mainLines?.routeOutline),routeDeselectedLine:_s({...Mr(n),beforeID:gs("routeOutline",t)},r?.mainLines?.routeDeselectedLine),routeDeselectedOutline:_s({...Nr(n),beforeID:gs("routeDeselectedLine",t)},r?.mainLines?.routeDeselectedOutline),...ms(r?.mainLines?.additional,t)},waypoints:{routeWaypointSymbol:_s({...ys,layout:{...ys.layout,"icon-size":c},beforeID:gs("routeSummaryBubbleSymbol",t)},r?.waypoints?.routeWaypointSymbol),routeWaypointLabel:_s({...fs,beforeID:gs("routeWaypointSymbol",t)},r?.waypoints?.routeWaypointLabel),...ms(r?.waypoints?.additional,t)},chargingStops:{routeChargingStopSymbol:_s({...Sr(e.chargingStops),beforeID:gs("routeWaypointSymbol",t)},r?.chargingStops?.routeChargingStopSymbol),...ms(r?.chargingStops?.additional,t)},sections:{incident:{routeIncidentJamSymbol:_s({...$r,beforeID:gs("routeChargingStopSymbol",t)},s?.incident?.routeIncidentJamSymbol),routeIncidentCauseSymbol:_s({...Yr,beforeID:gs("routeChargingStopSymbol",t)},s?.incident?.routeIncidentCauseSymbol),routeIncidentBackgroundLine:_s({...Vr(n),beforeID:gs("routeIncidentDashedLine",t)},s?.incident?.routeIncidentBackgroundLine),routeIncidentDashedLine:_s({...jr(n),beforeID:gs("routeTunnelLine",t)},s?.incident?.routeIncidentDashedLine),...ms(s?.incident?.additional,t)},ferry:{routeFerryLine:_s({...vr(n),beforeID:gs("routeLineArrows",t)},s?.ferry?.routeFerryLine),routeFerrySymbol:_s({...wr,beforeID:gs("routeIncidentJamSymbol",t)},s?.ferry?.routeFerrySymbol),...ms(s?.ferry?.additional,t)},tollRoad:{routeTollRoadOutline:_s({...Hr(n),beforeID:gs("routeDeselectedOutline",t)},s?.tollRoad?.routeTollRoadOutline),routeTollRoadSymbol:_s({...kr,beforeID:gs("routeChargingStopSymbol",t)},s?.tollRoad?.routeTollRoadSymbol),...ms(s?.tollRoad?.additional,t)},tunnel:{routeTunnelLine:_s({...qr(n),beforeID:gs("routeLineArrows",t)},s?.tunnel?.routeTunnelLine),...ms(s?.tunnel?.additional,t)},vehicleRestricted:{routeVehicleRestrictedBackgroundLine:_s({...Kr(n),beforeID:gs("routeVehicleRestrictedForegroundLine",t)},s?.vehicleRestricted?.routeVehicleRestrictedBackgroundLine),routeVehicleRestrictedForegroundLine:_s({...Xr(n),beforeID:Re.lowestLabel},s?.vehicleRestricted?.routeVehicleRestrictedForegroundLine),...ms(s?.vehicleRestricted?.additional,t)}},instructionLines:{routeInstructionLine:_s({...Rr(n),beforeID:Re.lowestLabel},r?.instructionLines?.routeInstructionLine),routeInstructionOutline:_s({...br(n),beforeID:gs("routeInstructionLine",t)},r?.instructionLines?.routeInstructionOutline),...ms(r?.instructionLines?.additional,t)},instructionArrows:{routeInstructionArrowSymbol:_s({...Cr,beforeID:gs("routeInstructionLine",t),...void 0!==i&&{layout:{...Cr.layout,"icon-image":Ls(Cr.layout?.["icon-image"],i)}}},r?.instructionArrows?.routeInstructionArrowSymbol),...ms(r?.instructionArrows?.additional,t)},summaryBubbles:{routeSummaryBubbleSymbol:_s(void 0===i?rs:is(i),r?.summaryBubbles?.routeSummaryBubbleSymbol),...ms(r?.summaryBubbles?.additional,t)}}},Ss=As();G()&&(q=V(j('<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 Is,Es=e=>{if(!G())return;const t=j('<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),V(t)},bs={pixelRatio:2,stretchX:[[20,45],[100,130]],stretchY:[[20,35]],content:[10,10,130,45]},Rs=e=>{if(!G())return;const t=j('<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),V(t)},Ts=(e,t)=>{if(!G())return;const i=z(t);return e&&i.appendChild(e),V(i)},Cs=e=>{if(G())return Ts(j('<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)},vs=e=>{if(G())return Ts(j('<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)},ws=(e={},t)=>Object.entries(e).map(([e,i])=>({...i,id:t?`${t}-${e}`:e})),Os=(e={},t)=>({mainLines:ws(e.mainLines,t),waypoints:ws(e.waypoints,t),chargingStops:ws(e?.chargingStops,t),ferries:ws(e.sections?.ferry,t),incidents:ws(e.sections?.incident,t),tollRoads:ws(e.sections?.tollRoad,t),tunnels:ws(e.sections?.tunnel,t),vehicleRestricted:ws(e.sections?.vehicleRestricted,t),instructionLines:ws(e.instructionLines,t),instructionArrows:ws(e.instructionArrows,t),summaryBubbles:ws(e.summaryBubbles,t)}),Ns=(e,t,i)=>{const r=l.instance.get().displayUnits,s=e?.displayUnits;return{...e,...s?{}:{displayUnits:r},layers:As(e,t,i)}},Ms=(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 B("7309")},xs=e=>{const t=e.properties;return t.chargingParkName??t.chargingParkOperatorName},Ds=(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??y(),iconID:Ms(s,t),title:xs(s),chargingPower:`${e.chargingConnectionInfo?.chargingPowerInkW} kW`,chargingDuration:p(e.chargingTimeInSeconds,t?.displayUnits?.time),routeState:r.properties.routeState}})}}return{type:"FeatureCollection",features:i}},Fs=e=>e.categories.includes("jam"),Ps=e=>{const t=(e=>{if(Fs(e))return p(e.delayInSeconds)})(e),i=((e,t)=>Fs(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}}},Us=(e,t,i)=>{if(e.properties.radiusMeters)return void 0!==i?Qe(us,i):us;let r;switch(t){case"start":r=cs;break;case"finish":r=ds;break;default:r=hs}return void 0!==i?Qe(r,i):r},Hs=(e,t,i)=>{let r=-1;return{type:"FeatureCollection",features:e.map((s,a)=>{if(!s)return r++,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?ss:e<t-1?as:os)(a,e.length),l=(e=>!e.properties.radiusMeters)(o);l&&r++;const c=(e=>{const t=e?.properties;return t?.poi?.name??t?.address?.freeformAddress??void 0})(o),h=o.id??y();return{...o,..."main-when-available"===t?.entryPoints&&{geometry:{type:"Point",coordinates:g(o,{useEntryPoint:"main-when-available"})}},id:h,properties:{...o.properties,id:h,index:a,indexType:n,...c&&{title:c},iconID:Us(o,n,i),...l&&"middle"===n&&{stopDisplayIndex:r}}}}).filter(e=>e)}},ks=(e,t,i)=>({type:"FeatureCollection",features:e.features.flatMap(e=>((e,t,i)=>e.properties.sections[t]?.map(t=>{const r=t.id??y();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))}),Ws=(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)),Bs=(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??y();return{...e,id:r,properties:{...e.properties,id:r,routeState:i===t?"selected":"deselected"}}})}},Gs=(e,t)=>e.some(e=>e.magnitudeOfDelay===t),Vs=(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 Gs(t,"major")?"major":Gs(t,"moderate")?"moderate":Gs(t,"minor")?"minor":void 0})(e),o=e.id??y();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)}}})}),js=class e extends ge{static async get(t,i){return await ae(t),new e(t,i)}constructor(e,t){super("geojson",e,t),this.shownFeaturesHandlers=[]}createSourcesWithLayers(e){const t=Qe("routes",this.instanceIndex);return{mainLines:new se(this.mapLibreMap,`${t}-mainLines`,e.mainLines,!1),waypoints:new se(this.mapLibreMap,`${t}-waypoints`,e.waypoints,!1),incidents:new se(this.mapLibreMap,`${t}-incidents`,e.incidents,!1),ferries:new se(this.mapLibreMap,`${t}-ferries`,e.ferries,!1),chargingStops:new se(this.mapLibreMap,`${t}-chargingStops`,e.chargingStops,!1),tollRoads:new se(this.mapLibreMap,`${t}-tollRoads`,e.tollRoads,!1),tunnels:new se(this.mapLibreMap,`${t}-tunnels`,e.tunnels,!1),vehicleRestricted:new se(this.mapLibreMap,`${t}-vehicleRestricted`,e.vehicleRestricted,!1),instructionLines:new se(this.mapLibreMap,`${t}-instructionLines`,e.instructionLines,!1),instructionArrows:new se(this.mapLibreMap,`${t}-instructionArrows`,e.instructionArrows,!1),summaryBubbles:new se(this.mapLibreMap,`${t}-summaryBubbles`,e.summaryBubbles,!1)}}_initSourcesWithLayers(e,t){t||(this.layerIDPrefix=Qe("routes",this.instanceIndex)),this.layersSpecs=Os(Ns(e,this.layerIDPrefix,this.instanceIndex).layers,this.layerIDPrefix);const i=this.createSourcesWithLayers(this.layersSpecs);he(Object.values(i).flatMap(e=>e._layerSpecs),this.mapLibreMap);const r={fillColor:e?.theme?.mainColor,...e?.waypoints?.icon?.style},s={pixelRatio:2},a=Qe(cs,this.instanceIndex),o=Qe(hs,this.instanceIndex),n=Qe(us,this.instanceIndex),l=Qe(ds,this.instanceIndex),c=Qe(Tr,this.instanceIndex),h=Qe(Pr,this.instanceIndex),u=Qe(Ur,this.instanceIndex),d=Qe(Zr,this.instanceIndex),p=Qe(Jr,this.instanceIndex),y=Qe(Qr,this.instanceIndex),f=Qe(es,this.instanceIndex);this.addImageIfNotExisting(a,Cs(r),s),this.addImageIfNotExisting(o,Ts(void 0,r),s),this.addImageIfNotExisting(n,(()=>{if(G())return V(j('<svg width="32" height="32" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg">\n <circle id="circle" cx="16" cy="16" r="12" fill="white" stroke="#105287" stroke-width="4"/>\n</svg>\n'))})(),s),this.addImageIfNotExisting(l,vs(r),s),this.addImageIfNotExisting(c,q,s),this.addImageIfNotExisting(h,Es("white"),bs),this.addImageIfNotExisting(u,Es("#EEEEEE"),bs),this.addImageIfNotExisting(d,Rs(gr),s),this.addImageIfNotExisting(p,Rs(dr),s),this.addImageIfNotExisting(y,Rs(pr),s),this.addImageIfNotExisting(f,Rs(fr),s);for(const g of e?.chargingStops?.icon?.customIcons??[])this.addImageIfNotExisting(g.id,g.image,{pixelRatio:g.pixelRatio??2});return i}_applyConfig(e){const i=Ns(e,this.layerIDPrefix,this.instanceIndex);if(this.config){const e=Os(i.layers,this.layerIDPrefix);Object.keys(e).forEach(t=>{const i=t;ce(e[i],this.layersSpecs[i],this.sourcesWithLayers[i],this.mapLibreMap)});const t=Object.values(this.sourcesWithLayers);he(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};pe("add-or-update",Qe(cs,this.instanceIndex),Cs(t),this.mapLibreMap,i),pe("add-or-update",Qe(hs,this.instanceIndex),Ts(void 0,t),this.mapLibreMap,i),pe("add-or-update",Qe(ds,this.instanceIndex),vs(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(Vs(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){pe("if-not-in-sprite",e,t,this.mapLibreMap,i)}async showRoutes(e,t){const i=Bs(e,t?.selectedIndex);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(i),this.sourcesWithLayers.vehicleRestricted.show(ks(i,"vehicleRestricted")),this.sourcesWithLayers.incidents.show(ks(i,"traffic",Ps)),this.sourcesWithLayers.chargingStops.show(Ds(i,this.config)),this.sourcesWithLayers.ferries.show(ks(i,"ferry")),this.sourcesWithLayers.tunnels.show(ks(i,"tunnel")),this.sourcesWithLayers.tollRoads.show(ks(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:y(),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:y(),routeIndex:t,routeState:e.properties.routeState,lastPointBearingDegrees:I(r[0],r[1])}}})||[])}))(i)),!1!==this.config?.summaryBubbles?.visible?this.sourcesWithLayers.summaryBubbles.show(Vs(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=Bs(this.sourcesWithLayers.mainLines.shownFeatures,e);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(t),this.sourcesWithLayers.chargingStops.show(Ds(t,this.config)),Ws(t,this.sourcesWithLayers.vehicleRestricted),Ws(t,this.sourcesWithLayers.incidents),Ws(t,this.sourcesWithLayers.ferries),Ws(t,this.sourcesWithLayers.tollRoads),Ws(t,this.sourcesWithLayers.tunnels),Ws(t,this.sourcesWithLayers.instructionLines),Ws(t,this.sourcesWithLayers.instructionArrows),Ws(t,this.sourcesWithLayers.summaryBubbles)}async showWaypoints(e){const t=Array.isArray(e)?Hs(e,this.config?.waypoints,this.instanceIndex):Hs(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{user:{mainLines:new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.mainLines,this.config?.events),waypoints:new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.waypoints,this.config?.events),chargingStops:new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.chargingStops,this.config?.events),summaryBubbles:new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.summaryBubbles,this.config?.events),incidents:new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.incidents,this.config?.events),vehicleRestricted:new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.vehicleRestricted,this.config?.events),ferries:new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.ferries,this.config?.events),tollRoads:new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.tollRoads,this.config?.events),tunnels:new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.tunnels,this.config?.events),instructionLines:new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.instructionLines,this.config?.events)},module:new Ne(this.configChangeHandlers,this.shownFeaturesHandlers)}}getLayerToRenderLinesUnder(){return Re.lowestLabel}},zs="standardLight",$s={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"}},Ys={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"},qs=(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",Ys[r]);for(const o of e.include??Fi)a.searchParams.append(o,$s[r][o]);return a.toString()},Ks=e=>{const t=e.style,i=e.commonBaseURL,r=e.apiKey;return"string"==typeof t?qs({id:t},i,r):"standard"===t?.type?qs(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:qs({id:zs},i,r)},Xs=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=fe(r),this.mapLibreMap.setStyle(Ks(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:zs}),this.styleLightDarkTheme=fe(this._params.style),this.ensureMapLibreCSSLoaded(),x(4),this.mapLibreMap=new w({validateStyle:!1,maxTileCacheZoomLevels:22,cancelPendingTileRequestsWhileZooming:!1,...(i=this._params).mapLibre,style:Ks(i),attributionControl:{compact:!1},transformRequest:ne(i)}),this.mapLibreMap.once("style.load",()=>{this.handleStyleData(!1)}),this._eventsProxy=new be(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)}_setTomTomUserAgent(e){this._params={...this._params,"tomtom-user-agent":e},this.mapLibreMap.setTransformRequest(ne(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 ee(this.mapLibreMap,[we,Oe,Ce]))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_${fe(e.style)}`),i.set("apiVersion","1"),i.set("apiChannel","preview"),t.addSprite(W,`${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)}}},Zs={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}},Js={trafficLight:["#2dc653","#f5a623","#e03030"],heat:["#2196F3","#FF9800","#F44336"],monochrome:["#e0e0e0","#888888","#1a1a1a"],viridis:["#fde725","#35b779","#31688e","#440154"],plasma:["#f0f921","#ed7953","#9c179e","#0d0887"]},Qs={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}},ea=e=>"speed"===e||"freeFlowSpeed"===e,ta=e=>e?.activeMetric??Zs.activeMetric,ia=e=>{return"string"==typeof e?(t=Js[e]).map((e,i)=>({value:1===t.length?0:i/(t.length-1),color:e})):e.stops;var t},ra=e=>{if("top"!==e)return e?Re[e]:Re.lowestLabel},sa=e=>{if("top"!==e)return e?Re[e]:Re.lowestPlaceLabel},aa=(e,t,i)=>{const r=t??Zs.metricConfig[e].color??"trafficLight",s=ia(r);let a;if("string"==typeof r){const{min:t,max:i}=Qs[e],r=ea(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}=Qs[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??Qs[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])]},oa=(e,t)=>{const i=t??Zs.metricConfig[e].color??"trafficLight",r=ia(i);let s;if("string"==typeof i){const t=ea(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]},na=(e,t,i)=>{const r=Zs.metricConfig[e].height,s=t?.minHeightMeters??r.minHeightMeters??0;if("raw"===t?.scaleMode){const i=t.scaleFactor??1;if("speed"===e){const{max:t}=Qs[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??Qs[e]:Qs[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]]},la=(e,t,i)=>{const r=ta(t),s=t?.metricConfig?.[r],{min:a,max:o}=i??Qs[r];return{id:e,type:"heatmap",beforeID:ra(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":oa(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]}}},ca=(e,t,i)=>{const r=ta(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:ra(t?.beforeLayerConfig?.hexgrid?.flat2D),paint:{"fill-color":aa(r,s?.color,i),"fill-opacity":.6}}},ha=(e,t,i)=>{const r=ta(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:sa(t?.beforeLayerConfig?.hexgrid?.extrusion3D),paint:{"fill-extrusion-color":aa(r,s?.color,i),"fill-extrusion-height":na(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},ua=(e,t,i)=>{const r=ta(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:ra(t?.beforeLayerConfig?.square?.flat2D),paint:{"fill-color":aa(r,s?.color,i),"fill-opacity":.6}}},da=(e,t,i)=>{const r=ta(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:sa(t?.beforeLayerConfig?.square?.extrusion3D),paint:{"fill-extrusion-color":aa(r,s?.color,i),"fill-extrusion-height":na(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},pa=e=>({...Zs.regionPolygon,...e}),ya=(e,t)=>{const{color:i,fillOpacity:r}=pa(t?.regionPolygon);return{id:e,type:"fill",beforeID:ra(),paint:{"fill-color":i,"fill-opacity":r}}},fa=(e,t)=>{const{color:i,outlineOpacity:r,outlineWidth:s}=pa(t?.regionPolygon);return{id:e,type:"line",beforeID:ra(),paint:{"line-color":i,"line-opacity":r,"line-width":s}}},ga=(e,t)=>({id:e,type:"line",beforeID:t,filter:["has","eventState"],paint:{"line-color":"#ffffff","line-width":["case",It,3,2],"line-opacity":["case",It,1,.8]}}),ma=e=>({...e,filter:["has","eventState"],paint:{...e.paint,"fill-extrusion-color":["case",It,"#ffffff","#ffffff"],"fill-extrusion-height":["+",e.paint?.["fill-extrusion-height"],.5],"fill-extrusion-opacity":.6}}),_a=(e,t,i)=>ma(ha(e,t,i)),La=(e,t,i)=>ma(da(e,t,i)),Aa=(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),Sa=.005,Ia=(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]-Sa,l[1]-Sa,l[2]+Sa,l[3]+Sa],t);s.push(...Aa(n,c,`${r}-${a}`))}return{type:"FeatureCollection",features:s}},Ea=class e extends ge{static async get(t,i){return await ae(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`,y=`${a}-outline`,f=`${a}-extrusion-highlight`,g=`${o}-fill`,m=`${o}-line`;this.heatmapLayerSpec=la(n,e),this.hexFillLayerSpec=ca(l,e),this.hexExtrusionLayerSpec=ha(c,e),this.squareFillLayerSpec=ua(d,e),this.squareExtrusionLayerSpec=da(p,e),this.regionFillLayerSpec=ya(g,e),this.regionLineLayerSpec=fa(m,e),this.hexOutlineLayerSpec=((e,t)=>ga(e,ra(t?.beforeLayerConfig?.hexgrid?.flat2D)))(h,e),this.hexExtrusionHighlightLayerSpec=_a(u,e),this.squareOutlineLayerSpec=((e,t)=>ga(e,ra(t?.beforeLayerConfig?.square?.flat2D)))(y,e),this.squareExtrusionHighlightLayerSpec=La(f,e);const _={heatmap:new se(this.mapLibreMap,r,[this.heatmapLayerSpec]),hexgrid:new se(this.mapLibreMap,s,[this.hexFillLayerSpec,this.hexExtrusionLayerSpec]),square:new se(this.mapLibreMap,a,[this.squareFillLayerSpec,this.squareExtrusionLayerSpec]),region:new se(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(Zs.metricConfig),r=Object.fromEntries(i.map(e=>[e,t?.[e]??Zs.metricConfig[e]])),s={activeMetric:Zs.activeMetric,displayMode:Zs.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)=>Ia(e,t,(e,t)=>T(e,t,{units:"kilometers"}),"hex"))(e),{automaticVisibility:!1}),this.sourcesWithLayers.square.show(((e,t=.5)=>Ia(e,t,(e,t)=>v(e,t,{units:"kilometers"}),"square"))(e),{automaticVisibility:!1});const t=this.config?.regionPolygon?.inverted??Zs.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(Zs.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=ia(e),i=e=>{const{min:i,max:r}=Qs[e],s=ea(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(Zs.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(Zs.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:Re[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 new me(new Me(this.tomtomMap._eventsProxy,[this.sourcesWithLayers.hexgrid,this.sourcesWithLayers.square,this.sourcesWithLayers.heatmap],this.config?.events),new Ne(this.configChangeHandlers,this.shownFeaturesHandlers))}get mode(){return this.config?.displayMode??Zs.displayMode}get activeMetric(){return ta(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=la(this.heatmapLayerSpec.id,e,t),r=ca(this.hexFillLayerSpec.id,e,t),s=ha(this.hexExtrusionLayerSpec.id,e,t),a=_a(this.hexExtrusionHighlightLayerSpec.id,e,t),o=ua(this.squareFillLayerSpec.id,e,t),n=da(this.squareExtrusionLayerSpec.id,e,t),l=La(this.squareExtrusionHighlightLayerSpec.id,e,t);le(i,this.heatmapLayerSpec,this.mapLibreMap),le(r,this.hexFillLayerSpec,this.mapLibreMap),le(s,this.hexExtrusionLayerSpec,this.mapLibreMap),le(a,this.hexExtrusionHighlightLayerSpec,this.mapLibreMap),le(o,this.squareFillLayerSpec,this.mapLibreMap),le(n,this.squareExtrusionLayerSpec,this.mapLibreMap),le(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=ya(this.regionFillLayerSpec.id,e),i=fa(this.regionLineLayerSpec.id,e);if(le(t,this.regionFillLayerSpec,this.mapLibreMap),le(i,this.regionLineLayerSpec,this.mapLibreMap),this.regionFillLayerSpec=t,this.regionLineLayerSpec=i,this.lastAnalytics){const t=e?.regionPolygon?.inverted??Zs.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}}})}}},ba=(e,t)=>e.length?1===e.length?{expression:e[0],legacy:t[0]}:{expression:["all",...e],legacy:["all",...t]}:null,Ra=(e,t,i)=>{e&&(t.push(e.expression),i.push(e.legacy))},Ta=(e,t,i,r)=>{e&&Ra(ii(t,e),i,r)},Ca=(e,t,i)=>{Ta(e.roadCategories,"road_category",t,i),Ta(e.roadSubCategories,"road_subcategory",t,i)},va=e=>{const t=[],i=[];if(Ca(e,t,i),e.incidentCategories){const r=ii("icon_category_0",e.incidentCategories,e=>U[e]);Ra(r,t,i)}if(e.magnitudes){const r=ii("magnitude_of_delay",e.magnitudes,e=>_.indexOf(e));Ra(r,t,i)}return e.delays&&Ra((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 ba(t,i)})(e.delays),t,i),ba(t,i)},wa=e=>{if(!e?.any?.length)return null;const t=e.any.map(va).filter(e=>!i(e));return Qt(t)},Oa=e=>{const t=[],i=[];if(Ca(e,t,i),e.showRoadClosures){const r="only"===e.showRoadClosures?"==":"!=";t.push([r,["get","road_closure"],!0]),i.push([r,"road_closure",!0])}return ba(t,i)},Na=(e,t,i,r)=>{for(const s of t)i.setFilter(s.id,e?ei(e,r[s.id]):r[s.id])},Ma=class e extends ge{static async get(t,i){return await ae(t),await de(t,Oe,"trafficFlow"),new e(t,i)}constructor(e,t){super("style",e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Oe);if(!t)throw k(`init ${e.name} with source ID ${Oe}`);this.originalFilters={};for(const e of this.getLayers())this.originalFilters[e.id]=e.filter;return{trafficFlow:new te(this.mapLibreMap,t)}}_applyConfig(e){return this._setVisible(e?.visible??!1,!1),this._filter(e?.filters,!1),e}getLayers(){return ee(this.tomtomMap.mapLibreMap,[Oe])}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(Oa).filter(e=>!i(e));return Qt(t)})(e);t&&Na(t,this.getLayers(),this.mapLibreMap,this.originalFilters)}else this.config?.filters?.any?.length&&Na(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(F)}}get events(){return new me(new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.trafficFlow,this.config?.events,F),new Ne(this.configChangeHandlers,[]))}},xa="tt-traffic-incident-direction-chevron",Da='<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>',Fa=["unknown","minor","moderate","major","indefinite"],Pa={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"}},Ua={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%)"}},Ha=(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)},ka=["interpolate",["exponential",1.5],["zoom"],5,0,9,.96,13,2.1,19,10.8],Wa=["interpolate",["exponential",1.5],["zoom"],5,.75,9,1.96,13,3.6,19,13.8],Ba=e=>["match",["get","magnitudeOfDelay"],"unknown",e.unknown,"minor",e.minor,"moderate",e.moderate,"major",e.major,"indefinite",e.indefinite,e.major],Ga=["match",["get","magnitudeOfDelay"],"unknown","traffic-incidents-no_delay-pattern","indefinite","traffic-incidents-road_closed-pattern",""],Va=e=>!1===e?null:{outlineColor:e?.outlineColor??"#000",widthScale:e?.widthScale??1.6},ja=["interpolate",["exponential",1.5],["zoom"],5,2.2,9,4.6,13,8.3,19,26],za=["case",["==",["feature-state","focused"],!0],1,0],$a=(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)]},Ya=["in",["get","magnitudeOfDelay"],["literal",["minor","moderate","major"]]],qa=["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],Ka=(e,t,i=Ua,r=Va(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":ja,"line-blur":0,"line-opacity":za},beforeID:t}),a.push({id:`${e}-outline`,type:"line",minzoom:6,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":Ba(i.outline),"line-width":$a(Wa,s)},beforeID:t},{id:`${e}-inner-solid`,type:"line",minzoom:6,filter:Ya,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":Ba(i.inner),"line-width":$a(ka,s)},beforeID:t},{id:`${e}-inner-chevron`,type:"line",minzoom:12,filter:Ya,layout:{"line-cap":"butt","line-join":"round"},paint:{"line-pattern":xa,"line-width":$a(ka,s)},beforeID:t},{id:`${e}-inner-pattern`,type:"line",minzoom:6,filter:qa,layout:{"line-cap":"round","line-join":"round"},paint:{"line-pattern":Ga,"line-width":$a(ka,s)},beforeID:t}),a},Xa=["step",["zoom"],.7,14,.8,16,.9,18,1],Za=["step",["zoom"],12.6,14,14.4,16,16.2,18,18],Ja=["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",""],Qa=["all",["!=",["get","magnitudeOfDelay"],"indefinite"],["any",["!",["has","delayInSeconds"]],["step",["zoom"],[">",["get","delayInSeconds"],900],14,[">",["get","delayInSeconds"],600],15,[">",["get","delayInSeconds"],300],16,!0]]],eo=["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]],to=["==",["get","magnitudeOfDelay"],"indefinite"],io=["concat","traffic-jam-",["get","magnitudeOfDelay"],["case",["<",["get","delayInSeconds"],600],"-small",["<",["get","delayInSeconds"],3600],"-medium","-large"]],ro=["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"]],so=["case",["has","delayInSeconds"],["*",-1,["get","delayInSeconds"]],0],ao=(e,t)=>[{id:`${e}-incident-marker`,type:"symbol",minzoom:13,filter:Qa,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":Ja,"icon-size":Xa,"symbol-sort-key":so},beforeID:t},{id:`${e}-jam-marker`,type:"symbol",minzoom:12,filter:eo,layout:{"symbol-placement":"point","icon-anchor":"bottom-left","icon-offset":[2,3],"icon-image":io,"icon-size":Xa,"icon-padding":0,"text-anchor":"bottom-left","text-field":ro,"text-font":["NotoSans-CondensedBold"],"text-offset":[2.7,-.75],"text-size":Za,"symbol-sort-key":so},paint:{"text-color":"hsl(210, 30%, 14%)"},beforeID:t},{id:`${e}-closed-road-marker`,type:"symbol",minzoom:12,filter:to,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":"traffic-incidents-road_closed","icon-size":Xa},beforeID:t}],oo=e=>{if("top"!==e)return e?Re[e]:Re.lowestLabel},no=class e extends ge{static async get(t,i){return await ae(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(G())return Is||(Is=V(j(Da))),Is})();r&&pe("if-not-in-sprite",xa,r,this.mapLibreMap);const s=oo(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:{...Ua.outline},inner:{...Ua.inner}},s=[];for(const a of Fa){const e=Pa[a],t=Ha(i.get(e.outline),e.outline,s),o=Ha(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=Va(e?.focus),n=[...Ka(i,s,a,o),...ao(i,s)];return{incidents:new se(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=oo(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 new me(new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.incidents,this.config?.events),new Ne(this.configChangeHandlers,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})}},lo=class t extends ge{static async get(e,i){return await ae(e),await de(e,we,"trafficIncidents"),new t(e,i)}constructor(e,t){super("style",e,t)}_initSourcesWithLayers(){const e=this.mapLibreMap.getSource(we);if(!e)throw k(`init ${t.name} with source ID ${we}`);this.originalFilters={};for(const t of this.getLayers())this.originalFilters[t.id]=t.filter;return{trafficIncidents:new te(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=wa(e);if(i){const e=t?this.getNonSymbolLayers():this.getLayers();Na(i,e,this.mapLibreMap,this.originalFilters)}}else this.config?.filters?.any?.length&&Na(void 0,this.getLayers(),this.mapLibreMap,this.originalFilters);if(t?.any?.length){const e=wa(t);e&&Na(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 ee(this.tomtomMap.mapLibreMap,[we])}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(H)}}get events(){return new me(new Me(this.tomtomMap._eventsProxy,this.sourcesWithLayers.trafficIncidents,this.config?.events,H),new Ne(this.configChangeHandlers,[]))}},co=["motorway","motorway_link","trunk","trunk_link","primary","primary_link","secondary","secondary_link","tertiary","tertiary_link","street","service","track"],ho=["unclassified","residential","living_street"],uo=["parking","driveway","alley"],po=(e,t)=>({left:e.left-t.left,top:e.top-t.top,right:e.right-t.left,bottom:e.bottom-t.top}),yo=(e,t,i)=>e.right<=0||e.left>=t||e.bottom<=0||e.top>=i,fo=(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)},go=(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)},mo=(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 fo(a,t,r,s);if(n&&!o)return void go(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):go(a,t,i,s):fo(a,t,r,s)},_o=e=>"string"==typeof e?document.querySelector(e):e,Lo=e=>"mapLibreMap"in e?e.mapLibreMap:e,Ao=(e,t,i)=>{const r=Lo(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=_o(n);if(!e)continue;const t=e.getBoundingClientRect(),l=po(t,r);yo(l,s,a)||mo(l,o,s,a,i)}return o.left>=o.right||o.top>=o.bottom?null:{visibleAreaBounds:o,mapWidthPX:s,mapHeightPX:a}},So=e=>{const{map:t,surroundingElements:i,paddingPX:r=0}=e,s=Ao(t,i,r);if(!s)return null;const{visibleAreaBounds:a}=s,o=Lo(t),n=o.unproject([a.left,a.bottom]),l=o.unproject([a.right,a.top]);return[n.lng,n.lat,l.lng,l.lat]},Io=e=>{const{map:t,surroundingElements:i}=e,r=So({map:t,surroundingElements:i});if(!r)return null;const[s,a,o,n]=r;return[(s+o)/2,(a+n)/2]},Eo=e=>{const{map:t,toBeContainedBBox:i,surroundingElements:r,paddingPX:s=0}=e,a=Ao(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,[y,f,g,m]=i,_=(g-y)/d,L=(m-f)/p,A=y-c*_,S=m+u*L;return[A,S-L,A+_,S]};export{ge as AbstractMapModule,Q as AbstractSourceWithLayers,ie as AddedSourceWithLayers,ve as BASE_MAP_SOURCE_ID,ui as BaseMapModule,me as CombinedEvents,di as CustomGeoJSONModule,Yi as DESELECTED_FOREGROUND_COLOR,qi as DESELECTED_OUTLINE_COLOR,Ji as DESELECTED_ROUTE_FILTER,Ki as DESELECTED_SECONDARY_COLOR,be as EventsProxy,os as FINISH_INDEX,se as GeoJSONSourceWithLayers,Ti as GeometriesModule,Ce as HILLSHADE_SOURCE_ID,xi as HillshadeModule,Lr as INDEFINITE_DELAY_DASH_COLOR,ns as INDEX_TYPE,dr as MAJOR_DELAY_COLOR,as as MIDDLE_INDEX,yr as MINOR_DELAY_COLOR,fr as MINOR_DELAY_LABEL_COLOR,pr as MODERATE_DELAY_COLOR,Ne as ModuleEvents,Te as POI_SOURCE_ID,oi as POIsModule,Zt as PlacesModule,zi as ROUTE_LINE_FOREGROUND_COLOR,Xi as ROUTE_LINE_FOREGROUND_WIDTH,$i as ROUTE_LINE_OUTLINE_COLOR,Qi as ROUTE_LINE_OUTLINE_WIDTH,js as RoutingModule,Zi as SELECTED_ROUTE_FILTER,ss as START_INDEX,ls as STOP_DISPLAY_INDEX,te as StyleSourceWithLayers,Oe as TRAFFIC_FLOW_SOURCE_ID,we as TRAFFIC_INCIDENTS_SOURCE_ID,Xs as TomTomMap,J as TomTomMapSource,Ea as TrafficAreaAnalyticsModule,Ma as TrafficFlowModule,no as TrafficIncidentOverlayModule,lo as TrafficIncidentsModule,mr as UNKNOWN_DELAY_BG_COLOR,gr as UNKNOWN_DELAY_COLOR,_r as UNKNOWN_DELAY_DASH_COLOR,Me as UserEvents,ni as baseMapLayerGroupNames,Ue as baseMapPOICategoryValues,Bt as buildPlaceTitle,vi as buildReachableRangeFeatures,As as buildRoutingLayers,Eo as calculateFittingBBox,So as calculatePaddedBBox,Io as calculatePaddedCenter,Ei as colorPaletteIDs,Ii as colorPalettes,Ss as defaultRoutingLayers,ee as filterLayersBySources,Z as findFeatureByRefId,Mi as geometryThemes,Vt as getIconIDForPlace,hr as getInstructionLineWidth,ur as getInstructionOutlineWidth,rr as getLineForegroundWidth,sr as getLineOutlineWidth,$t as getPOIGroupForPlace,zt as getPOILayerCategoryForPlace,ai as getStyleCategories,nr as getTollRoadOutlineWidth,ar as getWaypointIconSize,De as mapDisplayPoiCategoryMappings,Re as mapStyleLayerIDs,ri as poiCategoryGroups,xe as poiLayerIDs,Xt as preparePlacesForDisplay,wi as prepareReachableRangesForDisplay,Ni as reachableRangeGeometryConfig,X as renderedRefId,ia as resolveColorStops,co as roadCategories,uo as serviceRoadSubCategories,Di as standardStyleIDs,ho as streetRoadSubCategories,Fi as styleModules,Oi as themedGeometryConfig,Pe as toBaseMapPOICategory,ke as toBaseMapPOIGroup,Yt 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}`))};"string"==typeof i?i.includes("<svg")?o(ne(le(i))):a((await r.loadImage(i)).data):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=>Boolean(e&&"availability"in e&&e.availability),Gt=e=>"ELECTRIC_VEHICLE_STATION"===e.properties.poi?.categories?.[0]&&Wt(e.properties.chargingPark),Bt=e=>{const t=e.properties.chargingPark;if(Wt(t)){const e=t.availability.chargingPointAvailability,i=e.statusCounts.Available??0;return{availableCount:i,totalCount:e.count,ratio:i/e.count}}},Vt=(e,t)=>`${e}/${t}`,jt=e=>Bt(e)?.ratio??0,$t=e=>["case",[">=",["get","evAvailabilityRatio"],e?.threshold??0],"green","red"],zt=e=>Math.round(1e4*e)/1e4,Yt=(e,t,i,r)=>{const s=void 0!==r;return{top:s?[0,r]:[0,zt(e)],left:s?[r,zt(i)]:[zt(t),zt(i)],right:s?[-r,zt(i)]:[-zt(t),zt(i)]}},qt=(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=Yt(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,t=1.4*u.widthScale,i=Yt(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}},Kt=(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,...qt(e,i,t?.theme,a?.offset)}}return h},Xt=(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}},Zt=["in",["get","eventState"],["literal",["click","contextmenu"]]],Jt=e=>JSON.parse(JSON.stringify(e)?.replaceAll("name",St)),Qt=(e,t)=>e.getStyle().layers.find(e=>e.id===t)??{},ei=e=>({filter:["!",Zt],type:"symbol",paint:e.paint,layout:e.layout?s(e.layout,"visibility"):void 0}),ti=e=>{const t=ei(Qt(e,"POI")),i=t.layout?.["text-size"];return{...t,layout:{...t.layout,"icon-image":["get",At],"text-field":["get",St],...i&&{"text-size":Jt(i)}}}},ii=e=>{const t=ei(Qt(e,"POI - Micro"));return{...t,minzoom:0,layout:{...t.layout,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{...t.paint,"icon-opacity":1}}},ri=e=>{const t=Qt(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]}}},si=["has","eventState"],ai={type:"symbol",layout:{visibility:"none"}},oi={type:"circle",layout:{visibility:"none"}},ni="#3f9cd9",li={...wt,filter:["!",si]},ci={...wt,filter:si,layout:{...wt.layout,"icon-size":["interpolate",["linear"],["zoom"],8,.8,22,1],"text-allow-overlap":!0},paint:{...wt.paint,"text-color":ni}},hi=e=>({...e,filter:si,layout:{...e.layout,"text-allow-overlap":!0},paint:{...e.paint,"text-color":ni}}),ui=(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":$t(e?.evAvailability)}],["get",St]]:["get",St])(t,n):void 0;return{...e,...o,layout:Kt(e,t,i,l,s),paint:Xt(e,t,i,r)}},di=(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);if(void 0!==r){const e=Ot(s.id,t);if(i.set(e,r),s.availabilityLevel){const e=Ot(`${s.id}-${s.availabilityLevel}`,t);i.set(e,r)}}}return i})(e,r);let a,o,n=ai,l=ai,c=oi,h=ai,u=oi,d=ai;if("base-map"===e?.theme)a={...ti(t),minzoom:10},n=ii(t),o=(e=>hi(ti(e)))(t);else if("circle-icon"===e?.theme)a=(e=>({...ri(e),filter:["!",si]}))(t),o=(e=>hi(ri(e)))(t);else if("pin-clustered"===e?.theme){a={...li,filter:["all",Mt,["!",si]]},o={...ci,filter:["all",Mt,si]};const e=ii(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=li,o=ci;return{micro:{...ui(n,e,"micro",i,s),beforeID:at.lowestPlaceLabel},main:{...ui(a,e,"main",i,s),beforeID:"selected"},selected:ui(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}},pi=e=>{if(oe())return ne(ce(e))},fi=(e,t)=>"string"!=typeof e?e:t.features.find(t=>t.id===e),yi=/* @__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]),mi=e=>e.properties.poi?.name??e.properties.address.freeformAddress,gi=(e,t,i)=>{if("pin"===t||"pin-clustered"===t)return(e=>{if(e)return yi.has(e)?ae(e.toString()):ae(e.toString().substring(0,4))})(A[e])??i;{const t=mt(e);return t?`poi-${t}`:i}},_i=(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):gi(a.fn(e),r,s);const o=e.properties.poi?.categories?.[0],n=((e,t,i,r,s)=>{if(!r.evAvailability?.enabled||!Gt(e))return;const a=jt(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):gi(o,r,s)},Li=(e,t)=>{const i=t?.icon?.mapping;return"poiCategory"===i?.to?i.fn(e):e.properties.poi?.categories?.[0]},Si=(e,t)=>{const i=Li(e,t);return i&&mt(i)},Ai=(e,t)=>{const i=Li(e,t);return i&&Lt(i)},Ii=e=>Array.isArray(e)?{type:"FeatureCollection",features:e}:"Feature"===e.type?{type:"FeatureCollection",features:[e]}:e,Ei=(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,Gt(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=>Gt(e)?((e,t)=>{const i=Bt(e);return i?(t?.formatText??Vt)(i.availableCount,i.totalCount):""})(e,t):"",evAvailabilityRatio:e=>Gt(e)?jt(e):0}},bi=(e,t)=>{const i=Si(e,t);return i?`poi-${i}`:bt},Ri=(e,t,i={})=>{const r=Ii(e),s=!0===i.evAvailability?.enabled?Ei(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):mi(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:_i(e,t,i),...("base-map"===i?.theme||"pin-clustered"===i?.theme)&&{category:Si(e,i),group:Ai(e,i)},..."pin-clustered"===i?.theme&&{baseMapIconID:bi(e,i)},...a}}})}},Ti=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=di(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=Ri(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=fi(a.from,t),i=fi(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,pi(e.icon.default.style),this.mapLibreMap,{pixelRatio:2}))}else Se("if-not-in-sprite",this.defaultPlaceIconID,pi(),this.mapLibreMap,{pixelRatio:2})}updateData(e){const t=Ri(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=Ri(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"])})}},Ci=["pin","circle-icon","base-map","pin-clustered"],vi=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(!vi(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}},wi=e=>"$type"===e?["geometry-type"]:"$id"===e?["id"]:["get",e],Oi=e=>"$type"===e||("$id"===e?["!=",["id"],null]:["has",e]),Ni=(e,t)=>!!t.length&&["in",wi(e),["literal",t]],Mi=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 Oi(i);case"!has":return["!",Oi(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,wi(i),r[0]];case">":case">=":case"<":case"<=":return((e,t,i)=>["all",["==",["typeof",wi(t)],typeof i],[e,wi(t),i]])(t,i,r[0]);case"in":return Ni(i,r);case"!in":return["!",Ni(i,r)];case"all":return["all",...s.map(e=>Di(e))];case"any":return["any",...s.map(e=>Di(e))];case"none":return["!",["any",...s.map(e=>Di(e))]];default:return!0}},Di=e=>vi(e)?e:Mi(e),xi=e=>e?.length?1===e.length?e[0]:["any",...e]:null,Fi=(e,t)=>i(t)?e:["all",e,Di(t)],Pi=(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]},Ui=(e,t,i)=>Pi(e,t.show,i?t.values.map(i):t.values),Hi={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"]},ki=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}}},Wi=e=>{const t=[];return e.forEach(e=>{e in Hi?t.push(...Hi[e].map(mt)):t.push(mt(e))}),[...new Set(t)]},Gi=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=Pi("category",e.show,Wi(e.values));this.mapLibreMap.setFilter("POI",Fi(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(ki)}}get events(){return this.moduleEvents(["poi"],{mapping:ki})}},Bi=["land","water","buildings2D","roads","railways","ferries","borders","buildings3D","natureLabels","roadLabels","roadShields","houseNumbers","smallerTownLabels","stateLabels","cityLabels","allPlaceLabels","capitalLabels","countryLabels"],Vi={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"]}},ji=(e,t)=>{const i=Vi[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))},$i=e=>{const t=e.mode,i=e.names;return"include"===t?e=>i.some(t=>ji(t,e)):"exclude"===t?e=>!i.some(t=>ji(t,e)):(console.error("Unrecognized layer group mode:",t),()=>!0)},zi=e=>!pt.includes(e.id),Yi=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,zi);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&&$i(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&&$i(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(Bi.map(e=>[e,[]]));for(const i of e)for(const e of Bi)ji(e,i)&&t[e].push(i.id);return t})(this.sourcesWithLayers.vectorTiles._layerSpecs),this.layersByGroup}get events(){return this.moduleEvents(["vectorTiles"],{scopeResolver:qi})}},qi=e=>({layerFilter:$i(e.layerGroups),featureMatches:e.features}),Ki=class e extends ve{static async create(t,i){return await he(t),Xi(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=Zi(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)}},Xi=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.`)},Zi=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},Ji="#0A3653",Qi="#555555",er=e=>({defaultColor:"dark"===e?"#5FA8D8":Ji,textColor:"dark"===e?"#FFFFFF":"#333333",haloColor:"dark"===e?"#333333":"#FFFFFF"}),tr=(e,t,r,s=Ji)=>{const a=r?.fill,o=r?.line,n=((e=Ji)=>({type:"fill",paint:{"fill-color":["coalesce",["get","color"],e],"fill-opacity":["case",["==",["get","theme"],"outline"],0,.15],"fill-antialias":!1}}))(s),l=((e=Ji)=>({type:"line",paint:{"line-color":["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],Qi],["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}}}]},ir=(e,t,i="light")=>{const r=t?.textConfig,{textColor:s,haloColor:a}=er(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"}}},rr=(e,t,r="light")=>{const s=t?.lineLabelConfig,a=s?.minZoom??3,{textColor:o,haloColor:n}=er(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}}}},sr={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"]},ar=Object.keys(sr),or=(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}),nr=(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&&sr[r]){const e=or(sr[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()}}})}),lr=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}},cr=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 er(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]=tr(this.fillLayerID,this.outlineLayerID,e,this.defaultColor),s=ir(this.titleLayerID,e,this.lightDark);this.titleLayerSpecs=s,this.geometryFillLayerSpecs=i,this.geometryOutlineLayerSpecs=r;const a=void 0===e?.lineLabelConfig?null:rr(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(lr(this.sourcesWithLayers.geometry.shownFeatures)),this.config=t,this.emitConfigChange()}updateLayerAndData(e){const[t,i]=tr(this.fillLayerID,this.outlineLayerID,e,this.defaultColor),r=ir(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=rr(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(nr(i,this.config,this.lightDark)),this.sourcesWithLayers.geometryLabel.show(lr(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"])})}},hr={timeMinutes:"min",distanceKM:"km",remainingChargeCPT:"% remaining",spentChargePCT:"% spent",spentFuelLiters:"L"},ur=(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},dr=(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} ${hr[r.type]??r.type}`:String(t+1)});return{type:"FeatureCollection",...e.bbox&&{bbox:e.bbox},features:ur(r,s,t)}},pr=(e="fadedRainbow",t="lowestLabel")=>({beforeLayerConfig:t,line:{width:["case",["==",["get","theme"],"outline"],5,1],color:["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],Qi],"grey"],opacity:["case",["==",["get","theme"],"outline"],.9,1]},fill:{color:e,opacity:["case",["==",["get","theme"],"outline"],0,.6]},lineLabelConfig:{}}),fr=(e="fadedRainbow",t,i,r)=>{const s=pr(e,i),a=e=>dr(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}},yr=["filled","outline","inverted"],mr=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"])}},gr=["standardLight","standardDark","drivingLight","drivingDark","monoLight","monoDark","satellite"],_r=["trafficIncidents","trafficFlow","hillshade"],Lr="stopDuration",Sr=[["coalesce",["get",Lr],""],{"text-color":"#727C85","text-font":["literal",[Je]]}],Ar=["has",Lr],Ir="#36A8F0",Er="#105287",br="#ABAFB3",Rr="#3C4956",Tr="#727C85",Cr=["interpolate",["linear"],["zoom"],1,3,5,4,10,7,18,10],vr=["==",["get","routeState"],"selected"],wr=["==",["get","routeState"],"deselected"],Or=["interpolate",["linear"],["zoom"],1,5,5,6,10,10,18,14],Nr={s:["interpolate",["linear"],["zoom"],1,2,5,3,10,5,18,7],m:Cr,l:["interpolate",["linear"],["zoom"],1,5,5,6,10,11,18,15]},Mr={s:["interpolate",["linear"],["zoom"],1,4,5,5,10,8,18,11],m:Or,l:["interpolate",["linear"],["zoom"],1,7,5,9,10,14,18,19]},Dr={s:["interpolate",["linear"],["zoom"],8,.45,22,.6],m:["interpolate",["linear"],["zoom"],8,.6,22,.8],l:["interpolate",["linear"],["zoom"],8,.75,22,1]},xr=e=>Nr[e??"m"],Fr=e=>Mr[e??"m"],Pr=e=>Dr[e??"m"],Ur={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]},Hr=e=>Ur[e??"m"],kr={s:["interpolate",["linear"],["zoom"],16,8,22,12],m:["interpolate",["linear"],["zoom"],16,12,22,17],l:["interpolate",["linear"],["zoom"],16,17,22,24]},Wr={s:["interpolate",["linear"],["zoom"],16,10,22,14],m:["interpolate",["linear"],["zoom"],16,14,22,20],l:["interpolate",["linear"],["zoom"],16,20,22,28]},Gr=e=>kr[e??"m"],Br=e=>Wr[e??"m"],Vr="#AD0000",jr="#FB2D09",$r="#FFC105",zr="#f58240",Yr="#000000",qr="#C7D2D8",Kr="rgba(190, 39, 27, 1)",Xr="rgba(137, 150, 168, 1)",Zr=e=>!1===e?.visible?"":e?.title??["format",["get","title"],{},"\n",{},["get","chargingPower"],{}," • ",{},...Sr],Jr=e=>({...wt,filter:vr,minzoom:4,layout:{...wt.layout,"text-field":Zr(e?.text)},paint:{...wt.paint}}),Qr={filter:vr,minzoom:16},es={"line-cap":"round"},ts=e=>({...Qr,type:"line",layout:es,paint:{"line-width":Br(e),"line-color":"grey"}}),is=e=>({...Qr,type:"line",layout:es,paint:{"line-width":Gr(e),"line-color":"white"}}),rs="instruction-arrow",ss={...Qr,type:"symbol",layout:{"icon-allow-overlap":!0,"icon-image":rs,"icon-rotation-alignment":"map","icon-rotate":["get","lastPointBearingDegrees"],"icon-size":["interpolate",["linear"],["zoom"],16,1,22,2]}},as=e=>({filter:vr,type:"line",layout:{"line-join":"round"},paint:{"line-width":xr(e),"line-color":"#6dc4ed"}}),os={filter:vr,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}},ns={type:"line",layout:{"line-join":"round","line-cap":"round","line-sort-key":["get","index"]}},ls=e=>({...ns,filter:wr,paint:{"line-color":Rr,"line-width":Fr(e)}}),cs=e=>({...ns,filter:wr,paint:{"line-color":br,"line-width":xr(e)}}),hs=(e,t)=>({...ns,filter:vr,paint:{"line-color":t??"#105287","line-width":Fr(e)}}),us=(e,t)=>({...ns,filter:vr,paint:{"line-color":t??"#36A8F0","line-width":xr(e)}}),ds={type:"symbol",layout:{"symbol-placement":"line","icon-image":"roads-arrow-white","icon-rotate":180}},ps="selected-route-summary-popup",fs="deselected-route-summary-popup",ys=e=>({filter:vr,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-width":Hr(e),"line-color":"#BEBFFA"}}),ms={filter:vr,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]}},gs=["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],_s=["match",["get","magnitudeOfDelay"],"unknown",Kr,Xr],Ls=["match",["get","magnitudeOfDelay"],"minor",zr,"moderate",jr,"major",Vr,"indefinite","#666666",Yr],Ss=e=>({type:"line",layout:{"line-cap":"round"},paint:{"line-width":xr(e),"line-color":["match",["get","magnitudeOfDelay"],"minor",$r,"moderate",jr,"major",Vr,qr]}}),As=e=>({type:"line",filter:gs,layout:{"line-join":"round"},paint:{"line-width":xr(e),"line-color":_s,"line-dasharray":[1.5,1]}}),Is={filter:vr,type:"symbol",minzoom:6,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-ignore-placement":!0}},Es={...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":[Ze],"text-offset":[3.9,-1.4],"text-size":13},paint:{...Is.paint,"text-color":Ls,"text-halo-color":"#FFFFFF","text-halo-width":1}},bs={...Is,filter:["all",["has","causeIconID"],Is.filter],layout:{...Is.layout,"icon-image":["get","causeIconID"],"icon-anchor":"bottom-right"},paint:{...Is.paint}},Rs=e=>({filter:vr,type:"line",layout:{"line-join":"round"},paint:{"line-width":xr(e),"line-color":"#000000","line-opacity":.3}}),Ts=e=>({filter:vr,type:"line",layout:{"line-join":"round"},paint:{"line-color":Er,"line-width":xr(e)}}),Cs=e=>({filter:vr,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":Ir,"line-width":xr(e),"line-dasharray":[0,1.5]}}),vs="traffic-clear",ws="traffic-major",Os="traffic-moderate",Ns="traffic-minor",Ms=["has","formattedTraffic"],Ds=e=>{const t=void 0!==e?Ot(ps,e):ps,i=void 0!==e?Ot(fs,e):fs,r=void 0!==e?Ot(vs,e):vs,s=void 0!==e?Ot(ws,e):ws,a=void 0!==e?Ot(Os,e):Os,o=void 0!==e?Ot(Ns,e):Ns;return{type:"symbol",layout:{"icon-image":["case",vr,t,i],"symbol-placement":"point","icon-rotation-alignment":"viewport","text-rotation-alignment":"viewport","symbol-sort-key":["case",vr,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",vr,"black",Tr]},["concat","\t\t",["get","formattedDistance"]],{"text-color":Tr},["case",Ms,"\n",""],{},["image",["case",Ms,["match",["get","magnitudeOfDelay"],"major",s,"moderate",a,"minor",o,r],""]],{},["case",Ms,["concat"," ",["get","formattedTraffic"]],""],{"text-font":["literal",[Ze]],"text-color":Ls}]},paint:{"icon-translate":[0,-35],"text-translate":[0,-35]}}},xs=Ds(),Fs="start",Ps="middle",Us="finish",Hs="stopDisplayIndex",ks="waypointStart",Ws="waypointStop",Gs="waypointFinish",Bs=["format",["coalesce",["get",St],""],{},["case",["all",["has",St],Ar],"\n",""],{},...Sr],Vs={"text-field":["get",Hs],"text-font":[Ze],"text-size":["interpolate",["linear"],["zoom"],13,14,18,16],"text-offset":[0,-1.6],"icon-anchor":"bottom","text-allow-overlap":!0},js={type:"symbol",paint:{...Tt,"text-color":"#ffffff"},layout:{...Rt,...Vs,"symbol-sort-key":["abs",["-",["get","index"],1e3]]}},$s={type:"symbol",paint:{...vt,"text-color":"black","text-halo-width":1.5,"text-halo-color":"#ffffff"},layout:{...Ct,"text-field":Bs,"text-anchor":"top","text-offset":[0,.4]}},zs=(e,t)=>e&&t&&(e.startsWith("route")||e.startsWith("waypoint"))?`${t}-${e}`:e,Ys=(e,t)=>e&&t?Object.fromEntries(Object.entries(e).map(([e,i])=>[e,i?.beforeID?{...i,beforeID:zs(i.beforeID,t)}:i])):e,qs=(e,t)=>t?{...e,...t,...t.paint&&{paint:{...e.paint,...t.paint}},...t.layout&&{layout:{...e.layout,...t.layout}}}:e,Ks=(e,t)=>e&&void 0!==t?`${e}-${t}`:e,Xs=(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=Pr(l);return{mainLines:{routeLineArrows:qs({...ds,beforeID:at.lowestLabel},r?.mainLines?.routeLineArrows),routeLine:qs({...us(n,a),beforeID:zs("routeIncidentBackgroundLine",t)},r?.mainLines?.routeLine),routeOutline:qs({...hs(n,o),beforeID:zs("routeLine",t)},r?.mainLines?.routeOutline),routeDeselectedLine:qs({...cs(n),beforeID:zs("routeOutline",t)},r?.mainLines?.routeDeselectedLine),routeDeselectedOutline:qs({...ls(n),beforeID:zs("routeDeselectedLine",t)},r?.mainLines?.routeDeselectedOutline),...Ys(r?.mainLines?.additional,t)},waypoints:{routeWaypointSymbol:qs({...js,layout:{...js.layout,"icon-size":c},beforeID:zs("routeSummaryBubbleSymbol",t)},r?.waypoints?.routeWaypointSymbol),routeWaypointLabel:qs({...$s,beforeID:zs("routeWaypointSymbol",t)},r?.waypoints?.routeWaypointLabel),...Ys(r?.waypoints?.additional,t)},chargingStops:{routeChargingStopSymbol:qs({...Jr(e.chargingStops),beforeID:zs("routeWaypointSymbol",t)},r?.chargingStops?.routeChargingStopSymbol),...Ys(r?.chargingStops?.additional,t)},sections:{incident:{routeIncidentJamSymbol:qs({...Es,beforeID:zs("routeChargingStopSymbol",t)},s?.incident?.routeIncidentJamSymbol),routeIncidentCauseSymbol:qs({...bs,beforeID:zs("routeChargingStopSymbol",t)},s?.incident?.routeIncidentCauseSymbol),routeIncidentBackgroundLine:qs({...Ss(n),beforeID:zs("routeIncidentDashedLine",t)},s?.incident?.routeIncidentBackgroundLine),routeIncidentDashedLine:qs({...As(n),beforeID:zs("routeTunnelLine",t)},s?.incident?.routeIncidentDashedLine),...Ys(s?.incident?.additional,t)},ferry:{routeFerryLine:qs({...as(n),beforeID:zs("routeLineArrows",t)},s?.ferry?.routeFerryLine),routeFerrySymbol:qs({...os,beforeID:zs("routeIncidentJamSymbol",t)},s?.ferry?.routeFerrySymbol),...Ys(s?.ferry?.additional,t)},tollRoad:{routeTollRoadOutline:qs({...ys(n),beforeID:zs("routeDeselectedOutline",t)},s?.tollRoad?.routeTollRoadOutline),routeTollRoadSymbol:qs({...ms,beforeID:zs("routeChargingStopSymbol",t)},s?.tollRoad?.routeTollRoadSymbol),...Ys(s?.tollRoad?.additional,t)},tunnel:{routeTunnelLine:qs({...Rs(n),beforeID:zs("routeLineArrows",t)},s?.tunnel?.routeTunnelLine),...Ys(s?.tunnel?.additional,t)},vehicleRestricted:{routeVehicleRestrictedBackgroundLine:qs({...Ts(n),beforeID:zs("routeVehicleRestrictedForegroundLine",t)},s?.vehicleRestricted?.routeVehicleRestrictedBackgroundLine),routeVehicleRestrictedForegroundLine:qs({...Cs(n),beforeID:at.lowestLabel},s?.vehicleRestricted?.routeVehicleRestrictedForegroundLine),...Ys(s?.vehicleRestricted?.additional,t)}},instructionLines:{routeInstructionLine:qs({...is(n),beforeID:at.lowestLabel},r?.instructionLines?.routeInstructionLine),routeInstructionOutline:qs({...ts(n),beforeID:zs("routeInstructionLine",t)},r?.instructionLines?.routeInstructionOutline),...Ys(r?.instructionLines?.additional,t)},instructionArrows:{routeInstructionArrowSymbol:qs({...ss,beforeID:zs("routeInstructionLine",t),...void 0!==i&&{layout:{...ss.layout,"icon-image":Ks(ss.layout?.["icon-image"],i)}}},r?.instructionArrows?.routeInstructionArrowSymbol),...Ys(r?.instructionArrows?.additional,t)},summaryBubbles:{routeSummaryBubbleSymbol:qs(void 0===i?xs:Ds(i),r?.summaryBubbles?.routeSummaryBubbleSymbol),...Ys(r?.summaryBubbles?.additional,t)}}},Zs=Xs();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 Js,Qs=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)},ea={pixelRatio:2,stretchX:[[20,45],[100,130]],stretchY:[[20,35]],content:[10,10,130,45]},ta=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)},ia=(e,t)=>{if(!oe())return;const i=ce(t);return e&&i.appendChild(e),ne(i)},ra=e=>{if(oe())return ia(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)},sa=e=>{if(oe())return ia(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)},aa=(e={},t)=>Object.entries(e).map(([e,i])=>({...i,id:t?`${t}-${e}`:e})),oa=(e={},t)=>({mainLines:aa(e.mainLines,t),waypoints:aa(e.waypoints,t),chargingStops:aa(e?.chargingStops,t),ferries:aa(e.sections?.ferry,t),incidents:aa(e.sections?.incident,t),tollRoads:aa(e.sections?.tollRoad,t),tunnels:aa(e.sections?.tunnel,t),vehicleRestricted:aa(e.sections?.vehicleRestricted,t),instructionLines:aa(e.instructionLines,t),instructionArrows:aa(e.instructionArrows,t),summaryBubbles:aa(e.summaryBubbles,t)}),na=(e,t,i)=>{const r=l.instance.get().displayUnits,s=e?.displayUnits;return{...e,...s?{}:{displayUnits:r},layers:Xs(e,t,i)}},la=(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")},ca=e=>{const t=e.properties;return t.chargingParkName??t.chargingParkOperatorName},ha=(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:la(s,t),title:ca(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}},ua=e=>e.categories.includes("jam"),da=e=>{const t=(e=>{if(ua(e))return p(e.delayInSeconds)})(e),i=((e,t)=>ua(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}}},pa=(e,t,i)=>{let r;switch(t){case"start":r=ks;break;case"finish":r=Gs;break;default:r=Ws}return void 0!==i?Ot(r,i):r},fa=(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?Fs:e<t-1?Ps:Us)(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:pa(0,n,i),..."middle"===n&&{stopDisplayIndex:a}}}}).filter(e=>e)}),ya=(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))}),ma=(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)),ga=(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"}}})}},_a=(e,t)=>e.some(e=>e.magnitudeOfDelay===t),La=(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 _a(t,"major")?"major":_a(t,"moderate")?"moderate":_a(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)}}})}),Sa=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=oa(na(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(ks,this.instanceIndex),o=Ot(Ws,this.instanceIndex),n=Ot(Gs,this.instanceIndex),l=Ot(rs,this.instanceIndex),c=Ot(ps,this.instanceIndex),h=Ot(fs,this.instanceIndex),u=Ot(vs,this.instanceIndex),d=Ot(ws,this.instanceIndex),p=Ot(Os,this.instanceIndex),f=Ot(Ns,this.instanceIndex);this.addImageIfNotExisting(a,ra(r),s),this.addImageIfNotExisting(o,ia(void 0,r),s),this.addImageIfNotExisting(n,sa(r),s),this.addImageIfNotExisting(l,Fe,s),this.addImageIfNotExisting(c,Qs("white"),ea),this.addImageIfNotExisting(h,Qs("#EEEEEE"),ea),this.addImageIfNotExisting(u,ta(Yr),s),this.addImageIfNotExisting(d,ta(Vr),s),this.addImageIfNotExisting(p,ta(jr),s),this.addImageIfNotExisting(f,ta(zr),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=na(e,this.layerIDPrefix,this.instanceIndex);if(this.config){const e=oa(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(ks,this.instanceIndex),ra(t),this.mapLibreMap,i),Se("add-or-update",Ot(Ws,this.instanceIndex),ia(void 0,t),this.mapLibreMap,i),Se("add-or-update",Ot(Gs,this.instanceIndex),sa(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(La(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=ga(e,t?.selectedIndex);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(i),this.sourcesWithLayers.vehicleRestricted.show(ya(i,"vehicleRestricted")),this.sourcesWithLayers.incidents.show(ya(i,"traffic",da)),this.sourcesWithLayers.chargingStops.show(ha(i,this.config)),this.sourcesWithLayers.ferries.show(ya(i,"ferry")),this.sourcesWithLayers.tunnels.show(ya(i,"tunnel")),this.sourcesWithLayers.tollRoads.show(ya(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(La(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=ga(this.sourcesWithLayers.mainLines.shownFeatures,e);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(t),this.sourcesWithLayers.chargingStops.show(ha(t,this.config)),ma(t,this.sourcesWithLayers.vehicleRestricted),ma(t,this.sourcesWithLayers.incidents),ma(t,this.sourcesWithLayers.ferries),ma(t,this.sourcesWithLayers.tollRoads),ma(t,this.sourcesWithLayers.tunnels),ma(t,this.sourcesWithLayers.instructionLines),ma(t,this.sourcesWithLayers.instructionArrows),ma(t,this.sourcesWithLayers.summaryBubbles)}async showWaypoints(e){const t=Array.isArray(e)?fa(e,this.config?.waypoints,this.instanceIndex,this.config?.displayUnits?.time):fa(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}},Aa="standardLight",Ia={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"}},Ea={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"},ba=(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",Ea[r]);for(const o of e.include??_r)a.searchParams.append(o,Ia[r][o]);return a.toString()},Ra=e=>{const t=e.style,i=e.commonBaseURL,r=e.apiKey;return"string"==typeof t?ba({id:t},i,r):"standard"===t?.type?ba(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:ba({id:Aa},i,r)},Ta=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:Aa}),this._styleLightDarkTheme=Ie(this._params.style),this.ensureMapLibreCSSLoaded(),D(4),this.styleGivenToMapLibre=Ra(this._params),this.mapLibreMap=new w({validateStyle:!1,maxTileCacheZoomLevels:22,cancelPendingTileRequestsWhileZooming:!1,...(t=this._params).mapLibre,style:Ra(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=Ra(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)}}},Ca={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}},va="#ffffff",wa=e=>"dark"===e?"#FFFFFF":"#000000",Oa={trafficLight:["#2dc653","#f5a623","#e03030"],heat:["#2196F3","#FF9800","#F44336"],monochrome:["#e0e0e0","#888888","#1a1a1a"],viridis:["#fde725","#35b779","#31688e","#440154"],plasma:["#f0f921","#ed7953","#9c179e","#0d0887"]},Na={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}},Ma=e=>"speed"===e||"freeFlowSpeed"===e,Da=e=>e?.activeMetric??Ca.activeMetric,xa=e=>{return"string"==typeof e?(t=Oa[e]).map((e,i)=>({value:1===t.length?0:i/(t.length-1),color:e})):e.stops;var t},Fa=e=>{if("top"!==e)return e?at[e]:at.lowestLabel},Pa=e=>{if("top"!==e)return e?at[e]:at.lowestPlaceLabel},Ua=(e,t,i)=>{const r=t??Ca.metricConfig[e].color??"trafficLight",s=xa(r);let a;if("string"==typeof r){const{min:t,max:i}=Na[e],r=Ma(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}=Na[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??Na[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])]},Ha=(e,t)=>{const i=t??Ca.metricConfig[e].color??"trafficLight",r=xa(i);let s;if("string"==typeof i){const t=Ma(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]},ka=(e,t,i)=>{const r=Ca.metricConfig[e].height,s=t?.minHeightMeters??r.minHeightMeters??0;if("raw"===t?.scaleMode){const i=t.scaleFactor??1;if("speed"===e){const{max:t}=Na[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??Na[e]:Na[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]]},Wa=(e,t,i)=>{const r=Da(t),s=t?.metricConfig?.[r],{min:a,max:o}=i??Na[r];return{id:e,type:"heatmap",beforeID:Fa(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":Ha(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]}}},Ga=(e,t,i)=>{const r=Da(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:Fa(t?.beforeLayerConfig?.hexgrid?.flat2D),paint:{"fill-color":Ua(r,s?.color,i),"fill-opacity":.6}}},Ba=(e,t,i)=>{const r=Da(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:Pa(t?.beforeLayerConfig?.hexgrid?.extrusion3D),paint:{"fill-extrusion-color":Ua(r,s?.color,i),"fill-extrusion-height":ka(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},Va=(e,t,i)=>{const r=Da(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:Fa(t?.beforeLayerConfig?.square?.flat2D),paint:{"fill-color":Ua(r,s?.color,i),"fill-opacity":.6}}},ja=(e,t,i)=>{const r=Da(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:Pa(t?.beforeLayerConfig?.square?.extrusion3D),paint:{"fill-extrusion-color":Ua(r,s?.color,i),"fill-extrusion-height":ka(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},$a=e=>({...Ca.regionPolygon,...e}),za=(e,t,i)=>{const{color:r,fillOpacity:s}=$a(t?.regionPolygon);return{id:e,type:"fill",beforeID:Fa(),paint:{"fill-color":r??wa(i),"fill-opacity":s}}},Ya=(e,t,i)=>{const{color:r,outlineOpacity:s,outlineWidth:a}=$a(t?.regionPolygon);return{id:e,type:"line",beforeID:Fa(),paint:{"line-color":r??wa(i),"line-opacity":s,"line-width":a}}},qa=(e,t)=>({id:e,type:"line",beforeID:t,filter:["has","eventState"],paint:{"line-color":va,"line-width":["case",Zt,3,2],"line-opacity":["case",Zt,1,.8]}}),Ka=e=>({...e,filter:["has","eventState"],paint:{...e.paint,"fill-extrusion-color":["case",Zt,va,va],"fill-extrusion-height":["+",e.paint?.["fill-extrusion-height"],.5],"fill-extrusion-opacity":.6}}),Xa=(e,t,i)=>Ka(Ba(e,t,i)),Za=(e,t,i)=>Ka(ja(e,t,i)),Ja=(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),Qa=.005,eo=(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]-Qa,l[1]-Qa,l[2]+Qa,l[3]+Qa],t);s.push(...Ja(n,c,`${r}-${a}`))}return{type:"FeatureCollection",features:s}},to=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=Wa(n,e),this.hexFillLayerSpec=Ga(l,e),this.hexExtrusionLayerSpec=Ba(c,e),this.squareFillLayerSpec=Va(d,e),this.squareExtrusionLayerSpec=ja(p,e),this.regionFillLayerSpec=za(m,e,_),this.regionLineLayerSpec=Ya(g,e,_),this.hexOutlineLayerSpec=((e,t)=>qa(e,Fa(t?.beforeLayerConfig?.hexgrid?.flat2D)))(h,e),this.hexExtrusionHighlightLayerSpec=Xa(u,e),this.squareOutlineLayerSpec=((e,t)=>qa(e,Fa(t?.beforeLayerConfig?.square?.flat2D)))(f,e),this.squareExtrusionHighlightLayerSpec=Za(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(Ca.metricConfig),r=Object.fromEntries(i.map(e=>[e,t?.[e]??Ca.metricConfig[e]])),s={activeMetric:Ca.activeMetric,displayMode:Ca.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)=>eo(e,t,(e,t)=>T(e,t,{units:"kilometers"}),"hex"))(e),{automaticVisibility:!1}),this.sourcesWithLayers.square.show(((e,t=.5)=>eo(e,t,(e,t)=>v(e,t,{units:"kilometers"}),"square"))(e),{automaticVisibility:!1});const t=this.config?.regionPolygon?.inverted??Ca.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(Ca.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=xa(e),i=e=>{const{min:i,max:r}=Na[e],s=Ma(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(Ca.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(Ca.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??Ca.displayMode}get activeMetric(){return Da(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=Wa(this.heatmapLayerSpec.id,e,t),r=Ga(this.hexFillLayerSpec.id,e,t),s=Ba(this.hexExtrusionLayerSpec.id,e,t),a=Xa(this.hexExtrusionHighlightLayerSpec.id,e,t),o=Va(this.squareFillLayerSpec.id,e,t),n=ja(this.squareExtrusionLayerSpec.id,e,t),l=Za(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=za(this.regionFillLayerSpec.id,e,t),r=Ya(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??Ca.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}}})}}},io=e=>e.length?1===e.length?e[0]:["all",...e]:null,ro=(e,t)=>{e&&t.push(e)},so=(e,t,i)=>{e&&ro(Ui(t,e),i)},ao=(e,t)=>{so(e.roadCategories,"road_category",t),so(e.roadSubCategories,"road_subcategory",t)},oo=e=>{const t=[];if(ao(e,t),e.incidentCategories){const i=Ui("icon_category_0",e.incidentCategories,e=>j[e]);ro(i,t)}if(e.magnitudes){const i=Ui("magnitude_of_delay",e.magnitudes,e=>_.indexOf(e));ro(i,t)}return e.delays&&ro((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 io(t)})(e.delays),t),io(t)},no=e=>{if(!e?.any?.length)return null;const t=e.any.map(oo).filter(e=>!i(e));return xi(t)},lo=e=>{const t=[];if(ao(e,t),e.showRoadClosures){const i="only"===e.showRoadClosures?"==":"!=";t.push([i,["get","road_closure"],!0])}return io(t)},co=(e,t,i,r)=>{for(const s of t)i.setFilter(s.id,e?Fi(e,r[s.id]):r[s.id])},ho=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(lo).filter(e=>!i(e));return xi(t)})(e);t&&co(t,this.getLayers(),this.mapLibreMap,this.originalFilters)}else this.config?.filters?.any?.length&&co(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})}},uo="tt-traffic-incident-direction-chevron",po='<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>',fo=["interpolate",["exponential",1.5],["zoom"],5,0,9,.96,13,2.1,19,10.8],yo=["interpolate",["exponential",1.5],["zoom"],5,.75,9,1.96,13,3.6,19,13.8],mo=e=>["match",["get","magnitudeOfDelay"],"unknown",e.unknown,"minor",e.minor,"moderate",e.moderate,"major",e.major,"indefinite",e.indefinite,e.major],go=["match",["get","magnitudeOfDelay"],"unknown","traffic-incidents-no_delay-pattern","indefinite","traffic-incidents-road_closed-pattern",""],_o=e=>"dark"===e?"#FFF":"#000",Lo=["interpolate",["exponential",1.5],["zoom"],5,2.2,9,4.6,13,8.3,19,26],So=["case",["==",["feature-state","focused"],!0],1,0],Ao=(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"]]],Eo=["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],bo=(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":Lo,"line-blur":0,"line-opacity":So},beforeID:t}),a.push({id:`${e}-outline`,type:"line",minzoom:6,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":mo(i.outline),"line-width":Ao(yo,s)},beforeID:t},{id:`${e}-inner-solid`,type:"line",minzoom:6,filter:Io,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":mo(i.inner),"line-width":Ao(fo,s)},beforeID:t},{id:`${e}-inner-chevron`,type:"line",minzoom:12,filter:Io,layout:{"line-cap":"butt","line-join":"round"},paint:{"line-pattern":uo,"line-width":Ao(fo,s)},beforeID:t},{id:`${e}-inner-pattern`,type:"line",minzoom:6,filter:Eo,layout:{"line-cap":"round","line-join":"round"},paint:{"line-pattern":go,"line-width":Ao(fo,s)},beforeID:t}),a},Ro=["step",["zoom"],.7,14,.8,16,.9,18,1],To=["step",["zoom"],12.6,14,14.4,16,16.2,18,18],Co=["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",""],vo=["all",["!=",["get","magnitudeOfDelay"],"indefinite"],["any",["!",["has","delayInSeconds"]],["step",["zoom"],[">",["get","delayInSeconds"],900],14,[">",["get","delayInSeconds"],600],15,[">",["get","delayInSeconds"],300],16,!0]]],wo=["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]],Oo=["==",["get","magnitudeOfDelay"],"indefinite"],No=["concat","traffic-jam-",["get","magnitudeOfDelay"],["case",["<",["get","delayInSeconds"],600],"-small",["<",["get","delayInSeconds"],3600],"-medium","-large"]],Mo=["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"]],Do=["case",["has","delayInSeconds"],["*",-1,["get","delayInSeconds"]],0],xo=(e,t)=>[{id:`${e}-incident-marker`,type:"symbol",minzoom:13,filter:vo,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":Co,"icon-size":Ro,"symbol-sort-key":Do},beforeID:t},{id:`${e}-jam-marker`,type:"symbol",minzoom:12,filter:wo,layout:{"symbol-placement":"point","icon-anchor":"bottom-left","icon-offset":[2,3],"icon-image":No,"icon-size":Ro,"icon-padding":0,"text-anchor":"bottom-left","text-field":Mo,"text-font":["NotoSans-CondensedBold"],"text-offset":[2.7,-.75],"text-size":To,"symbol-sort-key":Do},paint:{"text-color":"hsl(210, 30%, 14%)"},beforeID:t},{id:`${e}-closed-road-marker`,type:"symbol",minzoom:12,filter:Oo,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":"traffic-incidents-road_closed","icon-size":Ro},beforeID:t}],Fo=["unknown","minor","moderate","major","indefinite"],Po={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"}},Uo={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%)"},Ho={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%)"},ko=(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)},Wo=e=>{if("top"!==e)return e?at[e]:at.lowestLabel},Go=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 Js||(Js=ne(le(po))),Js})();s&&Se("if-not-in-sprite",uo,s,this.mapLibreMap);const a=Wo(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:{...Uo},inner:{...Ho}},s=[];for(const a of Fo){const e=Po[a],t=ko(i.get(e.outline),e.outline,s),o=ko(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??_o(t),widthScale:e?.widthScale??1.6})(e?.focus,r),l=[...bo(i,a,o,n),...xo(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=Wo(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})}},Bo=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=no(e);if(i){const e=t?this.getNonSymbolLayers():this.getLayers();co(i,e,this.mapLibreMap,this.originalFilters)}}else this.config?.filters?.any?.length&&co(void 0,this.getLayers(),this.mapLibreMap,this.originalFilters);if(t?.any?.length){const e=no(t);e&&co(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:$})}},Vo=["motorway","motorway_link","trunk","trunk_link","primary","primary_link","secondary","secondary_link","tertiary","tertiary_link","street","service","track"],jo=["unclassified","residential","living_street"],$o=["parking","driveway","alley"],zo=(e,t)=>({left:e.left-t.left,top:e.top-t.top,right:e.right-t.left,bottom:e.bottom-t.top}),Yo=(e,t,i)=>e.right<=0||e.left>=t||e.bottom<=0||e.top>=i,qo=(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)},Ko=(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)},Xo=(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 qo(a,t,r,s);if(n&&!o)return void Ko(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):Ko(a,t,i,s):qo(a,t,r,s)},Zo=e=>"string"==typeof e?document.querySelector(e):e,Jo=e=>"mapLibreMap"in e?e.mapLibreMap:e,Qo=(e,t,i)=>{const r=Jo(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=Zo(n);if(!e)continue;const t=e.getBoundingClientRect(),l=zo(t,r);Yo(l,s,a)||Xo(l,o,s,a,i)}return o.left>=o.right||o.top>=o.bottom?null:{visibleAreaBounds:o,mapWidthPX:s,mapHeightPX:a}},en=e=>{const{map:t,surroundingElements:i,paddingPX:r=0}=e,s=Qo(t,i,r);if(!s)return null;const{visibleAreaBounds:a}=s,o=Jo(t),n=o.unproject([a.left,a.bottom]),l=o.unproject([a.right,a.top]);return[n.lng,n.lat,l.lng,l.lat]},tn=e=>{const{map:t,surroundingElements:i}=e,r=en({map:t,surroundingElements:i});if(!r)return null;const[s,a,o,n]=r;return[(s+o)/2,(a+n)/2]},rn=e=>{const{map:t,toBeContainedBBox:i,surroundingElements:r,paddingPX:s=0}=e,a=Qo(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,Yi as BaseMapModule,x as CombinedEvents,Ki as CustomGeoJSONModule,tt as DEFAULT_TEXT_SIZE,br as DESELECTED_FOREGROUND_COLOR,Rr as DESELECTED_OUTLINE_COLOR,wr as DESELECTED_ROUTE_FILTER,Tr as DESELECTED_SECONDARY_COLOR,Xe as EventsProxy,Us as FINISH_INDEX,Ve as GeoJSONSourceWithLayers,cr as GeometriesModule,nt as HILLSHADE_SOURCE_ID,mr as HillshadeModule,Xr as INDEFINITE_DELAY_DASH_COLOR,Vr as MAJOR_DELAY_COLOR,Ze as MAP_BOLD_FONT,et as MAP_ITALIC_FONT,Qe as MAP_MEDIUM_FONT,Je as MAP_REGULAR_FONT,Ps as MIDDLE_INDEX,$r as MINOR_DELAY_COLOR,zr as MINOR_DELAY_LABEL_COLOR,jr as MODERATE_DELAY_COLOR,W as ModuleEvents,ot as POI_SOURCE_ID,Gi as POIsModule,Ti as PlacesModule,Ir as ROUTE_LINE_FOREGROUND_COLOR,Cr as ROUTE_LINE_FOREGROUND_WIDTH,Er as ROUTE_LINE_OUTLINE_COLOR,Or as ROUTE_LINE_OUTLINE_WIDTH,Sa as RoutingModule,vr as SELECTED_ROUTE_FILTER,Fs as START_INDEX,Hs as STOP_DISPLAY_INDEX,We as StyleSourceWithLayers,ht as TRAFFIC_FLOW_SOURCE_ID,ct as TRAFFIC_INCIDENTS_SOURCE_ID,Ta as TomTomMap,Ue as TomTomMapSource,to as TrafficAreaAnalyticsModule,ho as TrafficFlowModule,Go as TrafficIncidentOverlayModule,Bo as TrafficIncidentsModule,qr as UNKNOWN_DELAY_BG_COLOR,Yr as UNKNOWN_DELAY_COLOR,Kr as UNKNOWN_DELAY_DASH_COLOR,Te as UserEvents,or as adaptPaletteForTheme,k as assertNoReservedScopeNames,Bi as baseMapLayerGroupNames,gt as baseMapPOICategoryValues,mi as buildPlaceTitle,ur as buildReachableRangeFeatures,Xs as buildRoutingLayers,rn as calculateFittingBBox,en as calculatePaddedBBox,tn as calculatePaddedCenter,ar as colorPaletteIDs,sr as colorPalettes,P as combineEventScopes,Zs as defaultRoutingLayers,ke as filterLayersBySources,Me as findFeatureByRefId,yr as geometryThemes,_i as getIconIDForPlace,Gr as getInstructionLineWidth,Br as getInstructionOutlineWidth,xr as getLineForegroundWidth,Fr as getLineOutlineWidth,Ai as getPOIGroupForPlace,Si as getPOILayerCategoryForPlace,Wi as getStyleCategories,Hr as getTollRoadOutlineWidth,Pr as getWaypointIconSize,ft as mapDisplayPoiCategoryMappings,it as mapFonts,at as mapStyleLayerIDs,Ci as placesThemes,Hi as poiCategoryGroups,pt as poiLayerIDs,Ri as preparePlacesForDisplay,dr as prepareReachableRangesForDisplay,fr as reachableRangeGeometryConfig,Ne as renderedRefId,H as reservedScopeNames,xa as resolveColorStops,Vo as roadCategories,U as scopedLayerSpecs,$o as serviceRoadSubCategories,dt as sharedInstance,gr as standardStyleIDs,jo as streetRoadSubCategories,_r as styleModules,pr as themedGeometryConfig,mt as toBaseMapPOICategory,Lt as toBaseMapPOIGroup,Ii as toPlaces};
2
2
  //# sourceMappingURL=map.es.js.map