@tomtom-org/maps-sdk 0.55.1 → 0.56.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 o,remove as a}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 b,poiCategoriesToID as S}from"@tomtom-org/maps-sdk/core";import{bearing as I,booleanPointInPolygon as A,difference as E,featureCollection as R,hexGrid as T,mask as v,squareGrid as w}from"@turf/turf";import{Map as C,getRTLTextPluginStatus as O,getVersion as N,setRTLTextPlugin as M,setWorkerCount as x}from"maplibre-gl";var D=class{constructor(e,t){this.userEventsInstance=e,this.moduleEventsInstance=t}where(e,t){return this.userEventsInstance.where(e,t)}on(e,t){return"config-change"===e?this.moduleEventsInstance.on("config-change",t):"shown-features"===e?this.moduleEventsInstance.on("shown-features",t):this.userEventsInstance.on(e,t)}off(e){"config-change"===e||"shown-features"===e?this.moduleEventsInstance.off(e):this.userEventsInstance.off(e)}},F=(e,t)=>e?t?(...i)=>e(...i)&&t(...i):e:t,P=(e,t)=>{if(!e)return t;if(!t)return e;const i=F(e.layerFilter,t.layerFilter),r=F(e.featureMatches,t.featureMatches);return i||r?{layerFilter:i,featureMatches:r}:void 0},U=(e,t)=>t?.layerFilter?e._layerSpecs.filter(t.layerFilter):e._layerSpecs,k=["on","off","where"],H=(e,t)=>{const i=e.find(e=>k.includes(e));if(i)throw new Error(`${t} uses the reserved event scope name "${i}". Reserved: ${k.join(", ")}.`)},W=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(!W(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}},B=e=>"$type"===e?["geometry-type"]:"$id"===e?["id"]:["get",e],G=e=>"$type"===e||("$id"===e?["!=",["id"],null]:["has",e]),V=(e,t)=>!!t.length&&["in",B(e),["literal",t]],z=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 G(i);case"!has":return["!",G(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,B(i),r[0]];case">":case">=":case"<":case"<=":return((e,t,i)=>["all",["==",["typeof",B(t)],typeof i],[e,B(t),i]])(t,i,r[0]);case"in":return V(i,r);case"!in":return["!",V(i,r)];case"all":return["all",...s.map(e=>$(e))];case"any":return["any",...s.map(e=>$(e))];case"none":return["!",["any",...s.map(e=>$(e))]];default:return!0}},$=e=>W(e)?e:z(e),j=e=>e?.length?1===e.length?e[0]:["any",...e]:null,Y=(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]},K=(e,t,i)=>Y(e,t.show,i?t.values.map(i):t.values),q=/* @__PURE__ */new WeakMap,Z=(e,t,i)=>{void 0!==i?e.set(t,i):e.delete(t)},X=class e{constructor(e){this.byLayer=/* @__PURE__ */new Map,this.mapLibreMap=e.mapLibreMap,e.addStyleChangeHandler({onStyleAboutToChange:()=>this.byLayer.clear(),priority:Number.NEGATIVE_INFINITY})}static for(t){let i=q.get(t);return i||(i=new e(t),q.set(t,i)),i}setTransform(e,t,i){this.contribute(e,({transforms:e})=>Z(e,t,i))}setClause(e,t,i){this.contribute(e,({clauses:e})=>Z(e,t,i))}contribute(e,t){if(!this.mapLibreMap.getLayer(e))return;let i=this.byLayer.get(e);i||(i={styleFilter:this.mapLibreMap.getFilter(e),transforms:/* @__PURE__ */new Map,clauses:/* @__PURE__ */new Map},this.byLayer.set(e,i)),t(i),this.apply(e,i)}apply(e,t){const i=[...t.transforms.values()].reduce((e,t)=>t(e),t.styleFilter),r=((e,t)=>{if(!t.length)return e;const i=null==e?t:[...t,$(e)];return 1===i.length?i[0]:["all",...i]})(i,[...t.clauses.values()]);this.mapLibreMap.setFilter(e,r??null,{validate:!1})}},J=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}},Q=["road_category","road_subcategory","relative_speed","left_hand_traffic","road_closure","absolute_speed","part_of_two_way_road","openlr","display_class"],ee=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}}}},te=["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"],ie={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},re=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}}}},se=e=>{const t=e%360;return t<0?t+360:t},oe=(e,t,i)=>Math.min(Math.max(t,e),i),ae=e=>!e.some(Number.isNaN),ne=e=>Number.parseInt(e.padEnd(2,e),16)/255,le=(e,t)=>oe(t?e/100:e,0,1),ce=/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,/])\s*([\de.+-]+)(%)?)?\s*\)$/,he=/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,/])\s*([\de.+-]+)(%)?)?\s*\)$/,ue=e=>{const t=he.exec(e);if(!t)return;const[,i,r,s,o,a,n,l,c]=t,h=[r||" ",o||" ",n].join("");if(" "!==h&&" /"!==h&&",,"!==h&&",,,"!==h)return;const u=[+i,oe(+s,0,100),oe(+a,0,100),l?le(+l,c):1];return ae(u)?(([e,t,i,r])=>{const s=se(e),o=t/100,a=i/100,n=e=>{const t=(e+s/30)%12,i=o*Math.min(a,1-a);return a-i*Math.max(-1,Math.min(t-3,9-t,1))};return[n(0),n(8),n(4),r]})(u):void 0},de=e=>{const t=e.toLowerCase().trim();if("transparent"===t)return[0,0,0,0];const i=_e[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[ne(e.slice(1,1+t)),ne(e.slice(1+t,1+2*t)),ne(e.slice(1+2*t,1+3*t)),ne(e.slice(1+3*t)||"ff")]})(t):t.startsWith("rgb")?(e=>{const t=ce.exec(e);if(!t)return;const[,i,r,s,o,a,n,l,c,h,u,d]=t,p=[s||" ",n||" ",h].join("");if(" "!==p&&" /"!==p&&",,"!==p&&",,,"!==p)return;const f=[r,a,c].join(""),y="%%%"===f?100:""===f?255:0;if(!y)return;const m=[oe(+i/y,0,1),oe(+o/y,0,1),oe(+l/y,0,1),u?le(+u,d):1];return ae(m)?m:void 0})(t):ue(t)},pe=e=>{const t=de(e);return t&&(([e,t,i,r])=>{const s=Math.max(e,t,i),o=Math.min(e,t,i),a=(s+o)/2,n=s-o;if(0===n)return[0,0,100*a,r];const l=n/(1-Math.abs(2*a-1));let c;return c=s===e?(t-i)/n%6:s===t?(i-e)/n+2:(e-t)/n+4,[se(60*c),100*l,100*a,r]})(t)},fe=(e,t)=>{const i=pe(e),r=pe(t);if(i&&r)return{hue:i[1]<1||r[1]<1?0:r[0]-i[0],saturation:r[1]-i[1],lightness:r[2]-i[2],alpha:r[3]-i[3]}},ye=(e,t)=>{const i=pe(e);if(i)return(([e,t,i,r])=>{const s=Math.round(se(e)),o=Math.round(oe(t,0,100)),a=Math.round(oe(i,0,100));return r<1?`hsla(${s}, ${o}%, ${a}%, ${Math.round(100*r)/100})`:`hsl(${s}, ${o}%, ${a}%)`})([i[0]+t.hue,i[1]+t.saturation,i[2]+t.lightness,oe(i[3]+t.alpha,0,1)])},me=e=>{const t=de(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])},ge=(e,t)=>{const i=de(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("")}`},_e={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]},Le=e=>/* @__PURE__ */new Error(`Trying to ${e} while it is not in the map style. Did you exclude it when loading the map?`),be="pinCategories",Se=e=>`${be}:${e}`,Ie=()=>"undefined"!=typeof document&&"undefined"!=typeof DOMParser&&"undefined"!=typeof btoa,Ae=e=>{if(!Ie())return;const t=document.createElement("img");return t.src=`data:image/svg+xml;base64,${btoa((new XMLSerializer).serializeToString(e))}`,t},Ee=e=>(new DOMParser).parseFromString(e,"image/svg+xml").documentElement,Re=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))(Ee('<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),Te=async e=>{e.mapReady||(await e.mapLibreMap.once("styledata"),await Te(e))},ve=e=>{const t=globalThis.__DEMOS_PROXY_ENSURE_SESSION__;return"function"!=typeof t?e:t().then(()=>e,()=>e)},we=e=>{const t=e.commonBaseURL??n,i=t!==n,r=L(e);return(s,o)=>{const a=((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&&a.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:a};if("Image"===o)return l?ve({url:a,credentials:"include"}):{url:a};const h=new URL(a);(e=>{e.pathname.includes("incidents")?e.searchParams.set("tags",te.join(",")):e.pathname.includes("flow")&&e.searchParams.set("tags",Q.join(","))})(h);const u={url:h.toString(),headers:{...y(e)}};return l?(u.credentials="include",ve(u)):u}},Ce=(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,o]of Object.entries(e.paint??{}))i.setPaintProperty(r,s,o,{validate:!1});for(const[s,o]of Object.entries(e.layout??{}))i.setLayoutProperty(r,s,o,{validate:!1})},Oe=(e,t,i,r)=>{const s=e.reduce((e,t)=>({...e,[t.id]:t}),{}),o=t.reduce((e,t)=>({...e,[t.id]:t}),{}),a=[],n=[],l=[],c=[];Object.keys(s).forEach(e=>{o[e]?(l.push(s[e]),c.push(o[e])):a.push(e)}),Object.keys(o).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}});const u=a.map(e=>({...s[e],source:i.source.id}));u.length&&(h.push(...u),xe(u,r)),i._updateSourceAndLayerIDs(),((e,t,i,r)=>{const s=/* @__PURE__ */new Set,o=e=>{if(!r.getLayer(e.id))return;Me(r,e.id,e.beforeID),s.add(e.id);const t=i.find(t=>t.id===e.id);t&&(t.beforeID=e.beforeID)};e.forEach((e,i)=>{e.beforeID!==t[i].beforeID&&o(e)});const a=()=>e.filter(e=>!s.has(e.id)&&void 0!==e.beforeID&&s.has(e.beforeID));for(let n=a();n.length;n=a())n.forEach(o)})(l,c,h,r),((e,t,i)=>{e.forEach((e,r)=>Ce(e,t[r],i))})(l,c,r)},Ne=(e,t)=>t&&e.getLayer(t)?t:void 0,Me=(e,t,i)=>{e.moveLayer(t,Ne(e,i))},xe=(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]})}},De=(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)}},Fe=async(e,t,i)=>{if(!e.mapLibreMap.getSource(t)){const r=e.mapLibreMap;r.isStyleLoaded()||await r.once("idle"),await e.setStyle(De(e.getStyle(),i)),await(async(e,t)=>{e.mapLibreMap.getSource(t)&&e.mapLibreMap.isSourceLoaded(t)||await e.mapLibreMap.once("sourcedata")})(e,t)}},Pe=async(e,t,i,r,s)=>{if(!i)return void console.warn(`addOrUpdateImage called with empty image for ID ${t}`);const o=i=>{const o=r.hasImage(t);o&&"add-or-update"==e?r.updateImage(t,i):o||r.addImage(t,i,s)},a=e=>{e.complete?e.naturalWidth>0?o(e):console.warn(`Failed to load image for ID ${t}`):(e.onload=()=>o(e),e.onerror=()=>console.warn(`Failed to load image for ID ${t}`))};if("string"==typeof i)if(i.includes("<svg"))a(Ae(Ee(i)));else try{o((await r.loadImage(i)).data)}catch(n){console.warn(`Failed to load image for ID ${t}`,n)}else a(i)},Ue=e=>{switch(e){case"standardDark":case"drivingDark":case"monoDark":case"satellite":return"dark";default:return"light"}},ke=e=>{if("string"==typeof e)return Ue(e);const t=He(e);if(t)return t;const i=e;return i?.id?Ue(i.id):"light"},He=e=>We(e)?e.lightDarkTheme:void 0,We=e=>"object"==typeof e&&"custom"===e?.type,Be=e=>{if("string"==typeof e)return void 0===me(e)?void 0:e;if(Array.isArray(e))for(const t of e){const e=Be(t);if(e)return e}},Ge=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:o}=this.options,a=this.toRegisteredHandler(t),n=[];for(const l of this.sources)i.addEventHandler(l,a,e,{config:r,owner:s,scope:o}),n.push(l);return()=>{for(const t of n)i.removeHandler(t,e,a)}}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,o,a)=>{const n=(o.length?o:[t]).filter(e=>r(e));if(!n.length)return;const l=n.map(s);e(l[0],i,l,a)}:(t,i,r,o)=>e(s(t),i,r.map(s),o)}off(e){for(const t of this.sources)this.options.eventProxy.remove(t,e,this.options.owner)}},Ve=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.filterComposer=X.for(t),this.initSourcesWithLayers(i),this.applyConfig(i),this.tomtomMap.addStyleChangeHandler({onStyleAboutToChange:()=>{this.moduleReady=!1},onStyleChanged:({resetState:e})=>e?this.resetOnNewStyle():this.restoreDataAndConfig(),priority:this.styleChangePriority()}),this._initializing=!1}styleChangePriority(){return 0}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 Te(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 Ge({eventProxy:this.eventsProxy,sourcesWithLayers:e.map(e=>this.sourcesWithLayers[e]).filter(e=>!!e),owner:this,config:this.config?.events,mapping:t.mapping,scopeResolver:t.scopeResolver})}moduleEvents(e,t={}){return new D(this.userEvents(e,t),new J(this.configChangeHandlers,[]))}moduleEventsWithShown(e,t,i={}){return new D(this.userEvents(e,i),new J(this.configChangeHandlers,t))}buildEvents(e,t){return H(Object.keys(t),this.constructor.name),Object.assign(e,t)}},ze=class extends Ve{},$e=class extends Ve{},je=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){a(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&&(a(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 o of Object.values(this.handlers[t]))for(const e of o)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 o of Object.values(this.handlers[r]))for(const r of o)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)}}},Ye=e=>{const t=e.properties?.id;return"string"==typeof t||"number"==typeof t?t:e.id},Ke=(e,t)=>{if(null!=t)for(let i=0;i<e.length;i++)if(Ye(e[i])===t)return{feature:e[i],index:i}};var qe,Ze,Xe,Je=e=>(function(e){if(i(e))throw new Error(`${e} must not be null/undefined. Something went wrong with its initialization.`)}(e),e),Qe=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))}},et=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}},tt=(e,t)=>e.getStyle().layers.filter(e=>t.includes(e?.source)),it=class extends et{constructor(e,t,i){let r=tt(e,[t.id]);i&&(r=r.filter(i)),super(e,new Qe(t.id,e.getStyle().sources[t.id],t),r)}},rt=class extends et{constructor(e,t,i,r){super(e,new Qe(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)))}},st={type:"FeatureCollection",features:[]},ot=class extends rt{constructor(e,t,i,r=!0,s){super(e,t,s?.cluster?{type:"geojson",data:st,...s}:{type:"geojson",data:st,promoteId:"id",...s??{}},i),this.shownFeatures=st,this.ensureAddedToMapWithVisibility(!1,r)}show(e,{automaticVisibility:t=!0}={}){this.shownFeatures=e,this.mapRemoved||(Je(this.source.runtimeSource).setData(e),t&&this.setLayersVisible(!!e.features.length))}findById(e){return Ke(this.shownFeatures.features,e)}clear(){this.show(st)}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})}},at=e=>"click"===e||"contextmenu"===e,nt=(e,t,i,r="updateInProps")=>{const{feature:o,index:a}=Ke(i,t)||{};if(o&&(!at(o.properties?.eventState)||at(e))){const t={...o,properties:"updateInProps"===r?{...o?.properties,eventState:e}:s(o?.properties,"eventState")};return i.splice(a,1,t),a}},lt=(e,t,r)=>{const s=[...r.shownFeatures.features],o=nt(e,Ye(t),s,"removeFromProps");i(o)||r.show({...r.shownFeatures,features:s},{automaticVisibility:!1})},ct=(e,t,i,r,s)=>{if(t&&r instanceof ot){const n=[...r.shownFeatures.features];return nt(e,Ye(t),n),!i||(a=t,(o=i)&&a&&o.id===a.id)||(s===r?nt(e,Ye(i),n,"removeFromProps"):s instanceof ot&&lt(e,i,s)),void r.show({...r.shownFeatures,features:n},{automaticVisibility:!1})}var o,a;i&&s instanceof ot&&lt(e,i,s)},ht=[],ut={precisionMode:"box",paddingBoxPx:5,cursorOnHover:"pointer",cursorOnMouseDown:"grabbing",cursorOnMap:"default",longHoverDelayAfterMapMoveMS:800,longHoverDelayOnStillMapMS:300},dt=class extends je{constructor(e,t={}){super(),this.enabled=!0,this.firstDelayedHoverSinceMapMove=!0,this.mouseMoveFrameRequested=!1,this.map=e,this.mapCanvas=e.getCanvas(),this.config={...ut,...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=Ye(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})((o=r,a=t?.source,a?o.filter(e=>e.source===a):o));var o,a;const n=this.sourceWithLayersFor(t?.layer.id);return n instanceof ot?s.map(e=>n.findById(Ye(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){ct("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??ht,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,o=this.hoveringSourceWithLayers;let a;this.hoveringLngLat=e.lngLat,this.hoveringPoint=e.point,this.hoveringFeature=t,this.hoveringSourceWithLayers=this.sourceWithLayersFor(t?.layer.id),i&&(a=this.dispatchHoverEnter(e,s,o)),r&&this.dispatchHoverMove(e,a),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),ct("hover",this.hoveringFeature,t,this.hoveringSourceWithLayers,i);const o=this.findHandlers(["hover"],r);if(!o.length)return;const a=this.toCallerFeatures(this.hoveringFeatures??ht,this.hoveringFeature);return this.dispatchToHandlers(o,e,this.hoveringFeature,a),a}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??ht,r);this.dispatchToHandlers(i,e,r,s)}dispatchToHandlers(e,t,i,r){for(const s of e){const e=this.callerFeaturesFor(s,this.hoveringFeatures??ht,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,o=this.findHandlers([e],this.lastClickedFeature?.layer.id);if(this.lastClickedSourceWithLayers=o[0]?.sourceWithLayers,ct(e,this.lastClickedFeature,r,this.lastClickedSourceWithLayers,s),o.length){const e=this.lastClickedFeature,r=this.toCallerFeatures(i,e);for(const s of o){const o=this.callerFeaturesFor(s,i,e,r);s.fn(o[0],t.lngLat,o,s.sourceWithLayers)}}}},pt=(e,t,i,r,s,o)=>({id:e,kind:t,description:i,default:r,current:s??r,overridden:void 0!==s,...o}),ft=e=>Object.fromEntries(e.filter(e=>e.overridden).map(e=>[e.id,e.current])),yt="Noto-Bold",mt="Noto-Regular",gt="Noto-Medium",_t="NotoSans-MediumItalic",Lt=["interpolate",["linear"],["zoom"],10,14,18,16],bt=[mt,_t,yt,gt],St=.8,It=["interpolate",["linear"],["zoom"],8,.6,22,St],At={country:"Places - Country name",lowestPlaceLabel:"Places - Village / Hamlet",poi:"POI",lowestLabel:"Borders - Treaty label",lowestRoadLine:"Tunnel - Railway outline",lowestBuilding:"Buildings - Underground"},Et="vectorTiles",Rt="hillshade",Tt="vectorTiles",vt="vectorTilesIncidents",wt="vectorTilesFlow",Ct=/* @__PURE__ */new WeakMap,Ot=async(e,t,i,r)=>{let s=Ct.get(e);s||(s=/* @__PURE__ */new Map,Ct.set(e,s));const o=s.get(t);if(o){const e=await o;return r?.(e),e}const a=Promise.resolve().then(i);s.set(t,a);try{return await a}catch(n){throw s.delete(t),n}},Nt=["POI","POI - Micro"],Mt={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"},xt={...Mt,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"},Dt=e=>xt[e],Ft=Array.from(new Set(Object.values(xt))),Pt={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"},Ut=e=>{const t=Dt(e);return t?Pt[t]:void 0},kt="title",Ht="iconID",Wt=.7,Bt="default_place",Gt="poi-parking-micro",Vt={"icon-image":["get",Ht],"icon-anchor":"bottom","icon-size":It,"icon-allow-overlap":!0,"icon-padding":0},zt={"icon-translate":[0,5],"icon-translate-anchor":"viewport"},$t={"text-optional":!0,"text-font":[yt],"text-field":["get",kt],"text-justify":"auto","text-variable-anchor":["top","left","right"],"text-variable-anchor-offset":["top",[0,Wt],"left",[1.4,-1.4],"right",[-1.4,-1.4]],"text-size":Lt,"text-padding":5},jt={"text-halo-width":["interpolate",["linear"],["zoom"],6,1,10,1.5],"text-translate-anchor":"viewport"},Yt={type:"symbol",layout:{...Vt,...$t},paint:{...zt,...jt}},Kt=(e,t)=>`${e}-${t}`,qt=(e,t)=>t?`${t}-${e}`:e,Zt=["has","point_count"],Xt=["!",Zt],Jt="clusterBaseMapIconIDs",Qt=["all",Zt,["==",["index-of",",",["get",Jt]],-1]],ei=["all",Zt,[">=",["index-of",",",["get",Jt]],0]],ti=[12,-14],ii={[Jt]:(qe="baseMapIconID",Ze=Jt,[["case",["==",["get",Ze],null],["accumulated"],["==",["accumulated"],null],["get",Ze],[">=",["index-of",["concat",",",["get",Ze],","],["concat",",",["accumulated"],","]],0],["accumulated"],["concat",["accumulated"],",",["get",Ze]]],["get",qe]])},ri=e=>{const t=["match",e];for(const i of Ft){const e=`poi-${i}`;t.push(e,["image",e])}return t.push(["image",Gt]),t},si=(e,t)=>{if(!e)return;const i=(e=>{try{if("string"==typeof e){if(e.includes("<svg")){const t=Ee(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,o=r?54:120;return{heightScale:i.height/s,widthScale:i.width/o}},oi=e=>{const t=["case"];for(const[i,r]of e)0===r.x&&0===r.y||t.push(["==",["get",Ht],i],["literal",[r.x,r.y]]);if(1!==t.length)return t.push(["literal",[0,0]]),t},ai=e=>Boolean(e&&"availability"in e&&e.availability),ni=e=>"ELECTRIC_VEHICLE_STATION"===e.properties.poi?.categories?.[0]&&ai(e.properties.chargingPark),li=e=>{const t=e.properties.chargingPark;if(ai(t)){const e=t.availability.chargingPointAvailability,i=e.statusCounts.Available??0;return{availableCount:i,totalCount:e.count,ratio:i/e.count}}},ci=(e,t)=>`${e}/${t}`,hi=e=>li(e)?.ratio??0,ui=e=>["case",[">=",["get","evAvailabilityRatio"],e?.threshold??0],"green","red"],di=e=>Math.round(1e4*e)/1e4,pi=(e,t,i,r)=>{const s=void 0!==r;return{top:s?[0,r]:[0,di(e)],left:s?[r,di(i)]:[di(t),di(i)],right:s?[-r,di(i)]:[-di(t),di(i)]}},fi=(e,t,i,r)=>{const s=(e=>{if(!e)return St;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 St})(e)/St,o="base-map"===i||"circle-icon"===i;if(o&&void 0!==r)return{"text-offset":[r,r]};const a=1.4*s,n=pi(Wt*s,a,o?0:-a,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=(o?1.4:Wt)*u.heightScale*s,t=1.4*u.widthScale*s,i=pi(e,t,o?0:-t,r);c.push(["==",["get",Ht],h],["literal",["top",i.top,"left",i.left,"right",i.right]])}return c.push(["literal",l]),{"text-variable-anchor-offset":c}},yi=(e,t,i,r,s)=>{const o=t?.text,a=t?.layers?.[i],n=s&&s.size>0,l={...e.layout},c=n||void 0!==o?.offset||"circle-icon"===t?.theme;c&&(delete l["text-offset"],delete l["text-variable-anchor-offset"],delete l["text-radial-offset"]);const h={...l,...a?.layout,...o?.size&&{"text-size":o.size},...o?.font&&{"text-font":o.font},...void 0!==r&&{"text-field":r}};if(c){const e={...h,...fi(h["icon-size"],s??/* @__PURE__ */new Map,t?.theme,o?.offset)},r="micro"!==i&&s&&oi([...s].map(([e,{offset:t}])=>[e,t]));return r?{...e,"icon-offset":r}:e}return h},mi=(e,t,i,r)=>{const s=t?.text,o=t?.layers?.[i],{textColor:a,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":a},...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},...o?.paint}},gi=["in",["get","eventState"],["literal",["click","contextmenu"]]],_i=e=>JSON.parse(JSON.stringify(e)?.replaceAll("name",kt)),Li=(e,t)=>e.getStyle().layers.find(e=>e.id===t)??{},bi=e=>({filter:["!",gi],type:"symbol",paint:e.paint,layout:e.layout?s(e.layout,"visibility"):void 0}),Si=e=>{const t=bi(Li(e,"POI")),i=t.layout?.["text-size"];return{...t,layout:{...t.layout,"icon-image":["get",Ht],"text-field":["get",kt],...i&&{"text-size":_i(i)}}}},Ii=e=>{const t=bi(Li(e,"POI - Micro"));return{...t,minzoom:0,layout:{...t.layout,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{...t.paint,"icon-opacity":1}}},Ai=e=>{const t=Li(e,"POI").layout??{};return{...Yt,layout:{...Yt.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:{...Yt.paint,"icon-translate":[0,0]}}},Ei=["has","eventState"],Ri={type:"symbol",layout:{visibility:"none"}},Ti={type:"circle",layout:{visibility:"none"}},vi="#3f9cd9",wi={...Yt,filter:["!",Ei]},Ci={...Yt,filter:Ei,layout:{...Yt.layout,"icon-size":["interpolate",["linear"],["zoom"],8,.8,22,1],"text-allow-overlap":!0},paint:{...Yt.paint,"text-color":vi}},Oi=e=>({...e,filter:Ei,layout:{...e.layout,"text-allow-overlap":!0},paint:{...e.paint,"text-color":vi}}),Ni=(e,t,i,r,s)=>{const o=t?.text,a=t?.layers?.[i],n=!0===t?.evAvailability?.enabled,l=o?.title&&"function"!=typeof o?.title?o.title:n?((e,t)=>t?["case",["has","evAvailabilityText"],["format",["get",kt],{},"\n",{},["get","evAvailabilityText"],{"font-scale":1.1,"text-color":ui(e?.evAvailability)}],["get",kt]]:["get",kt])(t,n):void 0;return{...e,...a,layout:yi(e,t,i,l,s),paint:mi(e,t,i,r)}},Mi=(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=si(s.image,e?.theme),o=void 0!==s.offsetX||void 0!==s.offsetY;if(void 0===r&&!o)continue;const a={heightScale:r?.heightScale??1,widthScale:r?.widthScale??1,offset:{x:s.offsetX??0,y:s.offsetY??0}},n=Kt(s.id,t);if(i.set(n,a),s.availabilityLevel){const e=Kt(`${s.id}-${s.availabilityLevel}`,t);i.set(e,a)}}return i})(e,r);let o,a,n=Ri,l=Ri,c=Ti,h=Ri,u=Ti,d=Ri;if("base-map"===e?.theme)o={...Si(t),minzoom:10},n=Ii(t),a=(e=>Oi(Si(e)))(t);else if("circle-icon"===e?.theme)o=(e=>({...Ai(e),filter:["!",Ei]}))(t),a=(e=>Oi(Ai(e)))(t);else if("pin-clustered"===e?.theme){o={...wi,filter:["all",Xt,["!",Ei]]},a={...Ci,filter:["all",Xt,Ei]};const e=Ii(t);n={...e,filter:e.filter?["all",Xt,e.filter]:Xt},l={type:"symbol",filter:Qt,layout:{"icon-image":ri(["get",Jt]),"icon-size":1,"icon-allow-overlap":!0,"icon-ignore-placement":!0}},c={type:"circle",filter:Qt,paint:{"circle-radius":11,"circle-color":"#000000","circle-stroke-color":"#FFFFFF","circle-stroke-width":1.5,"circle-translate":ti,"circle-translate-anchor":"viewport"}},h={type:"symbol",filter:Qt,layout:{"text-field":["get","point_count_abbreviated"],"text-font":[yt],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#FFFFFF","text-translate":ti,"text-translate-anchor":"viewport"}},u={type:"circle",filter:ei,paint:{"circle-radius":15,"circle-color":"#000000","circle-stroke-color":"#FFFFFF","circle-stroke-width":1.5}},d={type:"symbol",filter:ei,layout:{"text-field":["get","point_count_abbreviated"],"text-font":[yt],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#FFFFFF"}}}else o=wi,a=Ci;return{micro:{...Ni(n,e,"micro",i,s),beforeID:At.lowestPlaceLabel},main:{...Ni(o,e,"main",i,s),beforeID:"selected"},selected:Ni(a,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}},xi=e=>{if(Ie())return Ae(Re(e))},Di=(e,t)=>"string"!=typeof e?e:t.features.find(t=>t.id===e),Fi=/* @__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]),Pi=e=>e.properties.poi?.name??e.properties.address.freeformAddress,Ui=(e,t,i)=>{if("pin"===t||"pin-clustered"===t)return(e=>{if(e)return Fi.has(e)?Se(e.toString()):Se(e.toString().substring(0,4))})(S[e])??i;{const t=Dt(e);return t?`poi-${t}`:i}},ki=(e,t,i={})=>{const r=i.theme??"pin",s=((e,t)=>e.icon?.default||"base-map"!==(e.theme??"pin")?Kt(Bt,t):Gt)(i,t),o=i.icon?.mapping;if(o)return"imageID"===o.to?o.fn(e):Ui(o.fn(e),r,s);const a=e.properties.poi?.categories?.[0],n=((e,t,i,r,s)=>{if(!r.evAvailability?.enabled||!ni(e))return;const o=hi(e)>=(r.evAvailability.threshold??.3)?"available":"occupied",a=r.icon?.categoryIcons&&r.icon.categoryIcons.length>0,n=r.icon?.categoryIcons?.find(e=>e.id===t&&e.availabilityLevel===o);return n?Kt(`${n.id}-${o}`,i):a||"pin"!==s?void 0:Se(`7309-${o}`)})(e,a,t,i,r);if(n)return n;const l=i.icon?.categoryIcons?.find(e=>e.id===a);return l?Kt(l.id,t):Ui(a,r,s)},Hi=(e,t)=>{const i=t?.icon?.mapping;return"poiCategory"===i?.to?i.fn(e):e.properties.poi?.categories?.[0]},Wi=(e,t)=>{const i=Hi(e,t);return i&&Dt(i)},Bi=(e,t)=>{const i=Hi(e,t);return i&&Ut(i)},Gi=e=>Array.isArray(e)?{type:"FeatureCollection",features:e}:"Feature"===e.type?{type:"FeatureCollection",features:[e]}:e,Vi=(e,t,i)=>{if(!0!==t?.enabled)return e;let r=!1,s=!1;for(const o of i.features)if("ELECTRIC_VEHICLE_STATION"===o.properties.poi?.categories?.[0]&&(r=!0,ni(o))){s=!0;break}return r&&!s&&console.warn("PlacesModule: evAvailability is enabled but no availability data found. Did you call getPlacesWithEVAvailability()?"),{...e,evAvailabilityText:e=>ni(e)?((e,t)=>{const i=li(e);return i?(t?.formatText??ci)(i.availableCount,i.totalCount):""})(e,t):"",evAvailabilityRatio:e=>ni(e)?hi(e):0}},zi=(e,t)=>{const i=Wi(e,t);return i?`poi-${i}`:Gt},$i=(e,t,i={})=>{const r=Gi(e),s=!0===i.evAvailability?.enabled?Vi(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):Pi(e),o=s?Object.fromEntries(Object.entries(s).map(([t,i])=>[t,"function"==typeof i?i(e):i])):{},a=e.id??f();return{...e,id:a,geometry:{...e.geometry,bbox:e.bbox},properties:{...e.properties,id:a,title:r,iconID:ki(e,t,i),...("base-map"===i?.theme||"pin-clustered"===i?.theme)&&{category:Wi(e,i),group:Bi(e,i)},..."pin-clustered"===i?.theme&&{baseMapIconID:zi(e,i)},...o}}})}},ji=class e extends ze{static async create(t,i){return await Te(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=Kt(Bt,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 ot(this.mapLibreMap,this.sourceID,r.clusteredSpecs,!1,i);let o;r.unclusteredSpecs.length>0&&(o=new ot(this.mapLibreMap,this.unclusteredSourceID,r.unclusteredSpecs,!1)),xe([...s._layerSpecs,...o?._layerSpecs??[]],this.mapLibreMap),this.connectionLayerSpecs=this.buildConnectionLayerSpecs(e);const a=new ot(this.mapLibreMap,this.connectionSourceID,Object.values(this.connectionLayerSpecs),!1);return xe(a._layerSpecs,this.mapLibreMap),o?{places:s,placesUnclustered:o,connections:a}:{places:s,connections:a}}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=Mi(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:ii}}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,o=e?.layers?.label,a={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:{...a,...s,layout:{...a.layout,...s?.layout},paint:{...a.paint,...s?.paint}},label:{...n,...o,layout:{...n.layout,...o?.layout},paint:{...n.paint,...o?.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:[]};Oe(i.clusteredSpecs,r.clusteredSpecs,this.sourcesWithLayers.places,this.mapLibreMap),this.sourcesWithLayers.placesUnclustered&&i.unclusteredSpecs.length>0&&Oe(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=$i(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;Oe(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 o of e){const e=Di(o.from,t),i=Di(o.to,t);if(!e||!i)continue;const a=o.id??f(),n=r?r(o):"";s.push({type:"Feature",id:a,geometry:{type:"LineString",coordinates:[e.geometry.coordinates,i.geometry.coordinates]},properties:{id:a,fromId:"string"==typeof o.from?o.from:e.id,toId:"string"==typeof o.to?o.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",Kt(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,xi(e.icon.default.style),this.mapLibreMap,{pixelRatio:2}))}else Pe("if-not-in-sprite",this.defaultPlaceIconID,xi(),this.mapLibreMap,{pixelRatio:2})}updateData(e){const t=$i(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=$i(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"])})}},Yi=["pin","circle-icon","base-map","pin-clustered"],Ki={FOOD_DRINKS_GROUP:["RESTAURANT","FAST_FOOD","CAFE_PUB","PUB","WINERY","PUB_FOOD","SOUL_FOOD","DELICATESSEN"],SHOPPING_GROUP:["SHOP","SHOPPING_CENTER","CLOTHING_SHOP","MARKET","FOOD_MARKET","SUPERMARKETS_HYPERMARKETS","DEPARTMENT_STORE","CONVENIENCE_STORE","GROCERY_STORE","HARDWARE_STORE","ELECTRICAL_APPLIANCES_SHOP"],TRANSPORTATION_GROUP:["AIRPORT","FERRY_TERMINAL","HELIPAD_HELICOPTER_LANDING","PUBLIC_TRANSPORT_STOP","RAILWAY_STATION","BUS_STOP","TAXI_STAND"],HEALTH_GROUP:["DOCTOR","EMERGENCY_MEDICAL_SERVICE","EMERGENCY_ROOM","HEALTH_CARE_SERVICE","HOSPITAL","PHARMACY","DENTIST","WELFARE_ORGANIZATION"],PARKING_GROUP:["PARKING_GARAGE","OPEN_PARKING_AREA"],HOLIDAY_TOURISM_GROUP:["AMUSEMENT_PARK","BEACH","HOLIDAY_RENTAL","GEOGRAPHIC_FEATURE","TOURIST_ATTRACTION","LEISURE_CENTER","MOUNTAIN_PASS","MOUNTAIN_PEAK","MUSEUM","SCENIC_PANORAMIC_VIEW","TOURIST_INFORMATION_OFFICE"],EV_CHARGING_STATIONS_GROUP:["ELECTRIC_VEHICLE_STATION"],GAS_STATIONS_GROUP:["GAS_STATION"],ACCOMMODATION_GROUP:["CAMPING_GROUND","HOTEL_MOTEL","HOLIDAY_RENTAL"],ENTERTAINMENT_GROUP:["CINEMA","THEATER","MOVIE_THEATER","NIGHTLIFE","CONCERT_HALL","ENTERTAINMENT","CLUB_ASSOCIATION","CASINO"],SPORTS_LEISURE_GROUP:["SPORTS_CENTER","WATER_SPORT","SWIMMING_POOL","GOLF_COURSE","STADIUM","BEACH","ICE_SKATING_RINK","LEISURE_CENTER","MOUNTAIN_PASS","MOUNTAIN_PEAK"],EDUCATION_GROUP:["SCHOOL","COLLEGE_UNIVERSITY","LIBRARY","CULTURAL_CENTER"],GOVERNMENT_GROUP:["GOVERNMENT_OFFICE","COURTHOUSE","EMBASSY","FIRE_STATION_BRIGADE","POLICE_STATION"]},qi=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}}},Zi=e=>{const t=e.flatMap(e=>e in Ki?Ki[e].map(Dt):[Dt(e)]);return[...new Set(t.filter(e=>!i(e)))]},Xi="pois.categories",Ji=class e extends $e{static async get(t,i){return await Te(t),Ot(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Et);if(!t)throw Le(`init ${e.name} with source ID ${Et}`);return{poi:new it(this.mapLibreMap,t,e=>Nt.includes(e.id))}}_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=Y("category",e.show,Zi(e.values));this.filterComposer.setClause(At.poi,Xi,t)}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.filterComposer.setClause(At.poi,Xi,void 0));this.categoriesFilter=e,t&&this.emitConfigChange()}getShown(){return{poi:this.mapLibreMap.queryRenderedFeatures({layers:this.sourcesWithLayers.poi.sourceAndLayerIDs.layerIDs,validate:!1}).map(qi)}}get events(){return this.moduleEvents(["poi"],{mapping:qi})}},Qi=e=>"source"in e&&"string"==typeof e.source?e.source:void 0,er=(e,t)=>!e||void 0!==t&&e.includes(t),tr=(e,t,i)=>er(e.metadataGroups,(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))&&er(e.layerTypes,t.type)&&er(e.sources,Qi(t))&&er(e.sourceTypes,((e,t)=>{const i=Qi(e);return void 0===i?void 0:t?.[i]?.type})(t,i))&&er(e.sourceLayers,(e=>"source-layer"in e&&"string"==typeof e["source-layer"]?e["source-layer"]:void 0)(t))&&((e,t)=>{const i=t.id.toLowerCase(),r=e=>i.includes(e.toLowerCase());return!(e.idIncludes&&!e.idIncludes.some(r)||e.idExcludes?.some(r))})(e,t),ir=(e,t,i)=>e.some(e=>tr(e,t,i)),rr=["land","water","buildings2D","roads","railways","ferries","borders","buildings3D","natureLabels","roadLabels","roadShields","houseNumbers","smallerTownLabels","stateLabels","cityLabels","allPlaceLabels","capitalLabels","countryLabels"],sr={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"]}},or=(e,t)=>tr(sr[e],t),ar=e=>{const t=e.mode,i=e.names;return"include"===t?e=>i.some(t=>or(t,e)):"exclude"===t?e=>!i.some(t=>or(t,e)):(console.error("Unrecognized layer group mode:",t),()=>!0)},nr=e=>!Nt.includes(e.id),lr=class e extends $e{static async get(t,i){return await Te(t),Ot(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Tt);if(!t)throw Le(`init ${e.name} with source ID ${Tt}`);const i=new it(this.mapLibreMap,t,nr);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&&ar(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&&ar(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(rr.map(e=>[e,[]]));for(const i of e)for(const e of rr)or(e,i)&&t[e].push(i.id);return t})(this.sourcesWithLayers.vectorTiles._layerSpecs),this.layersByGroup}get events(){return this.moduleEvents(["vectorTiles"],{scopeResolver:cr})}},cr=e=>({layerFilter:ar(e.layerGroups),featureMatches:e.features}),hr=class e extends ze{static async create(t,i){return await Te(t),ur(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],o=i.sources[s].cluster;r[s]=new ot(this.mapLibreMap,e,t,!0,o)}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],o=s.sourceID??`custom-geojson-${this.instanceIndex}-${String(r)}`;t[r]=o,i[r]=s.layers.map((e,t)=>({...e,id:e.id??`${o}-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;Oe(r,i,s,this.mapLibreMap);const o=[];for(const e of s._layerSpecs)this.mapLibreMap.getLayer(e.id)||o.push(e);o.length>0&&(xe(o,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=dr(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)}},ur=e=>{if(!e.sources||0===Object.keys(e.sources).length)throw new Error("CustomGeoJSONModule requires at least one source in config.sources.");H(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.`)},dr=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},pr="#0A3653",fr="#555555",yr=e=>({defaultColor:"dark"===e?"#5FA8D8":pr,textColor:"dark"===e?"#FFFFFF":"#333333",haloColor:"dark"===e?"#333333":"#FFFFFF"}),mr=(e,t,r,s=pr)=>{const o=r?.fill,a=r?.line,n=((e=pr)=>({type:"fill",paint:{"fill-color":["coalesce",["get","color"],e],"fill-opacity":["case",["==",["get","theme"],"outline"],0,.15],"fill-antialias":!1}}))(s),l=((e=pr)=>({type:"line",paint:{"line-color":["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],fr],["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(o?.opacity)&&{"fill-opacity":o?.opacity},...o?.color&&{"fill-color":["get","color"]}}},h=a?.layer;return[c,{...l,...h,id:t,...h?.layout&&{layout:{...l.layout,...h.layout}},paint:{...l.paint,...h?.paint,...!i(a?.color)&&{"line-color":a?.color},...!i(a?.width)&&{"line-width":a?.width},...!i(a?.opacity)&&{"line-opacity":a?.opacity}}}]},gr=(e,t,i="light")=>{const r=t?.textConfig,{textColor:s,haloColor:o}=yr(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":[yt],"symbol-placement":"point"},paint:{"text-color":s,"text-halo-color":o,"text-halo-width":["interpolate",["linear"],["zoom"],6,1,10,1.5],"text-translate-anchor":"viewport"}}},_r=(e,t,r="light")=>{const s=t?.lineLabelConfig,o=s?.minZoom??3,{textColor:a,haloColor:n}=yr(r);return{type:"symbol",id:e,minzoom:o,layout:{"text-field":["get","title"],"symbol-placement":"line","text-size":s?.textSize??15,"text-font":[yt],"symbol-spacing":s?.symbolSpacing??200,"text-keep-upright":!0,"text-offset":s?.textOffset??[0,1]},paint:{"text-color":s?.textColor??a,"text-halo-color":s?.textHaloColor??n,"text-halo-width":s?.textHaloWidth??2,...!i(s?.textOpacity)&&{"text-opacity":s?.textOpacity}}}},Lr={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"]},br=Object.keys(Lr),Sr=(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?ge(e,.3)??e:t<.22?((e,t)=>{const i=de(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}),Ir=(e,t={},i="light")=>({...e,features:e.features.map((e,r)=>{const s=(e.properties??{}).theme??t.theme,o="inverted"===s?(e=>{const t=v(e);return{...e,geometry:t.geometry}})(e):e,a=o.properties??{},n=a.title??((e,t)=>t.textConfig?.textField?t.textConfig.textField:e.properties?.address?.freeformAddress)(o,t),l=a.color??((e,t,i)=>{const r=e?.fill?.color;if("string"==typeof r&&Lr[r]){const e=Sr(Lr[r],i);return e[t%e.length]}return r})(t,r,i);return{...o,properties:{...o.properties,...s&&{theme:s},...n&&{title:n},...l&&{color:l},id:a.id??f()}}})}),Ar=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}},Er=class e extends ze{static async create(t,i){return await Te(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 yr(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]=mr(this.fillLayerID,this.outlineLayerID,e,this.defaultColor),s=gr(this.titleLayerID,e,this.lightDark);this.titleLayerSpecs=s,this.geometryFillLayerSpecs=i,this.geometryOutlineLayerSpecs=r;const o=void 0===e?.lineLabelConfig?null:_r(this.lineLabelLayerID,e,this.lightDark);return this.lineLabelLayerSpecs=o,{geometry:new ot(this.mapLibreMap,this.sourceID,[{...i},{...r},...o?[o]:[]]),geometryLabel:new ot(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(Ar(this.sourcesWithLayers.geometry.shownFeatures)),this.config=t,this.emitConfigChange()}updateLayerAndData(e){const[t,i]=mr(this.fillLayerID,this.outlineLayerID,e,this.defaultColor),r=gr(this.titleLayerID,e,this.lightDark);if(Ce(t,this.geometryFillLayerSpecs,this.mapLibreMap),Ce(i,this.geometryOutlineLayerSpecs,this.mapLibreMap),Ce(r,this.titleLayerSpecs,this.mapLibreMap),this.geometryFillLayerSpecs=t,this.geometryOutlineLayerSpecs=i,this.titleLayerSpecs=r,this.lineLabelLayerSpecs){const t=_r(this.lineLabelLayerID,e,this.lightDark);Ce(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(Ir(i,this.config,this.lightDark)),this.sourcesWithLayers.geometryLabel.show(Ar(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"])})}},Rr={timeMinutes:"min",distanceKM:"km",remainingChargeCPT:"% remaining",spentChargePCT:"% spent",spentFuelLiters:"L"},Tr=(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?v(t):E(R([e[i-1],t])),{title:s,theme:o,...a}=t.properties??{};return{...t,geometry:r?.geometry??t.geometry,properties:a}}),...e.map(e=>({...e,id:void 0,properties:{...e.properties,theme:"filled"}}))])(r):r},vr=(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} ${Rr[r.type]??r.type}`:String(t+1)});return{type:"FeatureCollection",...e.bbox&&{bbox:e.bbox},features:Tr(r,s,t)}},wr=(e="fadedRainbow",t="lowestLabel")=>({beforeLayerConfig:t,line:{width:["case",["==",["get","theme"],"outline"],5,1],color:["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],fr],"grey"],opacity:["case",["==",["get","theme"],"outline"],.9,1]},fill:{color:e,opacity:["case",["==",["get","theme"],"outline"],0,.6]},lineLabelConfig:{}}),Cr=(e="fadedRainbow",t,i,r)=>{const s=wr(e,i),o=e=>vr(e,t,r);return"inverted"!==t?{...s,transformFeaturesForDisplay:o}:{...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:o}},Or=["filled","outline","inverted"],Nr=class e extends $e{static async get(t,i){return await Te(t),await Fe(t,Rt,"hillshade"),Ot(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Rt);if(!t)throw Le(`init ${e.name} with source ID ${Rt}`);return{hillshade:new it(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"])}},Mr=["standardLight","standardDark","drivingLight","drivingDark","monoLight","monoDark","satellite"],xr=["trafficIncidents","trafficFlow","hillshade"],Dr="standardLight",Fr="0.6.0-0",Pr={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"}},Ur={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"},kr=(e,t,i)=>{const r=e.id??"standardLight",s=e.version??"0.6.0-0",o=new URL(`${t}/maps/orbis/assets/styles/${s}/style.json`);o.searchParams.set("apiVersion","1"),i&&o.searchParams.set("key",i),o.searchParams.set("map",Ur[r]);for(const a of e.include??xr)o.searchParams.append(a,Pr[r][a]);return o.toString()},Hr=e=>{const t=e.style,i=e.commonBaseURL,r=e.apiKey;return"string"==typeof t?kr({id:t},i,r):"standard"===t?.type?kr(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:kr({id:Dr},i,r)},Wr="stopDuration",Br=[["coalesce",["get",Wr],""],{"text-color":"#727C85","text-font":["literal",[mt]]}],Gr=["has",Wr],Vr="#36A8F0",zr="#105287",$r="#ABAFB3",jr="#3C4956",Yr="#727C85",Kr=["interpolate",["linear"],["zoom"],1,3,5,4,10,7,18,10],qr=["==",["get","routeState"],"selected"],Zr=["==",["get","routeState"],"deselected"],Xr=["interpolate",["linear"],["zoom"],1,5,5,6,10,10,18,14],Jr={s:["interpolate",["linear"],["zoom"],1,2,5,3,10,5,18,7],m:Kr,l:["interpolate",["linear"],["zoom"],1,5,5,6,10,11,18,15]},Qr={s:["interpolate",["linear"],["zoom"],1,4,5,5,10,8,18,11],m:Xr,l:["interpolate",["linear"],["zoom"],1,7,5,9,10,14,18,19]},es={s:["interpolate",["linear"],["zoom"],8,.45,22,.6],m:["interpolate",["linear"],["zoom"],8,.6,22,.8],l:["interpolate",["linear"],["zoom"],8,.75,22,1]},ts=e=>Jr[e??"m"],is=e=>Qr[e??"m"],rs=e=>es[e??"m"],ss={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]},os=e=>ss[e??"m"],as={s:["interpolate",["linear"],["zoom"],16,8,22,12],m:["interpolate",["linear"],["zoom"],16,12,22,17],l:["interpolate",["linear"],["zoom"],16,17,22,24]},ns={s:["interpolate",["linear"],["zoom"],16,10,22,14],m:["interpolate",["linear"],["zoom"],16,14,22,20],l:["interpolate",["linear"],["zoom"],16,20,22,28]},ls=e=>as[e??"m"],cs=e=>ns[e??"m"],hs="#AD0000",us="#FB2D09",ds="#FFC105",ps="#f58240",fs="#000000",ys="#C7D2D8",ms="rgba(190, 39, 27, 1)",gs="rgba(137, 150, 168, 1)",_s=e=>!1===e?.visible?"":e?.title??["format",["get","title"],{},"\n",{},["get","chargingPower"],{}," • ",{},...Br],Ls=e=>{const t=oi(((e=[])=>{const t=/* @__PURE__ */new Map;for(const i of e){if(!i.image)continue;const e={x:i.offsetX??0,y:i.offsetY??0};0===e.x&&0===e.y||t.set(i.id,e)}return t})(e?.icon?.customIcons));return{...Yt,filter:qr,minzoom:4,layout:{...Yt.layout,"text-field":_s(e?.text),...t&&{"icon-offset":t}},paint:{...Yt.paint}}},bs={filter:qr,minzoom:16},Ss={"line-cap":"round"},Is=e=>({...bs,type:"line",layout:Ss,paint:{"line-width":cs(e),"line-color":"grey"}}),As=e=>({...bs,type:"line",layout:Ss,paint:{"line-width":ls(e),"line-color":"white"}}),Es="instruction-arrow",Rs={...bs,type:"symbol",layout:{"icon-allow-overlap":!0,"icon-image":Es,"icon-rotation-alignment":"map","icon-rotate":["get","lastPointBearingDegrees"],"icon-size":["interpolate",["linear"],["zoom"],16,1,22,2]}},Ts={filter:qr,type:"line",layout:{"line-join":"round"},paint:{"line-color":"#6dc4ed"}},vs={filter:qr,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}},ws={type:"line",layout:{"line-join":"round","line-cap":"round","line-sort-key":["get","index"]}},Cs=e=>({...ws,filter:Zr,paint:{"line-color":jr,"line-width":is(e)}}),Os=e=>({...ws,filter:Zr,paint:{"line-color":$r,"line-width":ts(e)}}),Ns=(e,t)=>({...ws,filter:qr,paint:{"line-color":t??"#105287","line-width":is(e)}}),Ms=(e,t)=>({...ws,filter:qr,paint:{"line-color":t??"#36A8F0","line-width":ts(e)}}),xs={type:"symbol",layout:{"symbol-placement":"line","icon-image":"roads-arrow-white","icon-rotate":180}},Ds="selected-route-summary-popup",Fs="deselected-route-summary-popup",Ps={filter:qr,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#BEBFFA"}},Us={filter:qr,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]}},ks=["match",["get","magnitudeOfDelay"],"minor",ps,"moderate",us,"major",hs,"indefinite","#666666",fs],Hs={type:"line",layout:{"line-cap":"round"},paint:{"line-color":["match",["get","magnitudeOfDelay"],"minor",ds,"moderate",us,"major",hs,ys]}},Ws={type:"line",filter:["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],layout:{"line-join":"round"},paint:{"line-color":["match",["get","magnitudeOfDelay"],"unknown",ms,gs],"line-dasharray":[1.5,1]}},Bs={filter:qr,type:"symbol",minzoom:6,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-ignore-placement":!0}},Gs={...Bs,filter:["all",["has","jamIconID"],Bs.filter],layout:{...Bs.layout,"icon-image":["get","jamIconID"],"icon-anchor":"bottom-left","text-anchor":"bottom-left","text-field":["get","title"],"text-font":[yt],"text-offset":[3.9,-1.4],"text-size":13},paint:{...Bs.paint,"text-color":ks,"text-halo-color":"#FFFFFF","text-halo-width":1}},Vs={...Bs,filter:["all",["has","causeIconID"],Bs.filter],layout:{...Bs.layout,"icon-image":["get","causeIconID"],"icon-anchor":"bottom-right"},paint:{...Bs.paint}},zs={filter:qr,type:"line",layout:{"line-join":"round"},paint:{"line-color":"#000000","line-opacity":.3}},$s={filter:qr,type:"line",layout:{"line-join":"round"},paint:{"line-color":zr}},js={filter:qr,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":Vr}},Ys=["carpool","carTrain","importantRoadStretch","lowEmissionZone","motorway","pedestrian","speedLimit","tollVignette","unpaved","urban"],Ks=["ferry","tollRoad","traffic","tunnel","vehicleRestricted"],qs=[...Ys,...Ks],Zs=["visible","color","opacity","width","style","pattern","icon"],Xs={carpool:{sourceKey:"carpoolSections",visible:!1,style:"halo",pattern:"solid",knobs:Zs},carTrain:{sourceKey:"carTrainSections",visible:!0,style:"halo",pattern:"dashed",knobs:Zs},importantRoadStretch:{sourceKey:"importantRoadStretchSections",visible:!1,style:"halo",pattern:"solid",knobs:Zs},lowEmissionZone:{sourceKey:"lowEmissionZoneSections",visible:!0,style:"halo",pattern:"solid",knobs:Zs},motorway:{sourceKey:"motorwaySections",visible:!1,style:"halo",pattern:"solid",knobs:Zs},pedestrian:{sourceKey:"pedestrianSections",visible:!1,style:"halo",pattern:"dashed",knobs:Zs},speedLimit:{sourceKey:"speedLimitSections",visible:!0,knobs:["visible","sign"]},tollVignette:{sourceKey:"tollVignetteSections",visible:!0,style:"halo",pattern:"dashed",knobs:Zs},unpaved:{sourceKey:"unpavedSections",visible:!1,style:"halo",pattern:"dashed",knobs:Zs},urban:{sourceKey:"urbanSections",visible:!1,style:"halo",pattern:"solid",knobs:Zs},ferry:{sourceKey:"ferries",visible:!0,style:"inline",pattern:"solid",knobs:Zs},tollRoad:{sourceKey:"tollRoads",visible:!0,style:"halo",pattern:"solid",knobs:Zs},traffic:{sourceKey:"incidents",visible:!0,style:"inline",pattern:"solid",knobs:["visible","opacity","width","style"]},tunnel:{sourceKey:"tunnels",visible:!0,style:"inline",pattern:"solid",knobs:Zs},vehicleRestricted:{sourceKey:"vehicleRestricted",visible:!0,style:"inline",pattern:"dotted",knobs:Zs}},Js=(e,t)=>Xs[e].knobs.includes(t),Qs=e=>Xs[e],eo=e=>Xs[e].visible,to=e=>Js(e,"sign"),io=(Ys.filter(e=>!to(e)),e=>Xs[e].sourceKey),ro={carpool:{color:"#6D4AC7",opacity:.55},carTrain:{color:"#8A5A2B",opacity:.6},importantRoadStretch:{color:"#C7761F",opacity:.6},lowEmissionZone:{color:"#2E8B57",opacity:.5},motorway:{color:"#1F6FB2",opacity:.4},pedestrian:{color:"#B23F86",opacity:.6},tollVignette:{color:"#8C6B1F",opacity:.55},unpaved:{color:"#7A6A54",opacity:.6},urban:{color:"#7E8C8E",opacity:.3}},so={solid:void 0,dashed:[2,1.5],dotted:[0,1.5]},oo=(e,t)=>t?.visible??Xs[e].visible,ao=(e,t)=>Js(e,"style")&&t?.style||Qs(e).style,no={halo:"routeDeselectedOutline",inline:"routeLineArrows"},lo=(e,t)=>{const i=ao(e,t);return i&&no[i]},co=(e,t,i,r,s="principal")=>{const o=i?.width??r,a={...t.paint,"line-width":"halo"===ao(e,i)?os(o):ts(o)};if(i?.color&&Js(e,"color")){const e="outline"===s?ge(i.color,.4):i.color;e&&(a["line-color"]=e)}return void 0!==i?.opacity&&Js(e,"opacity")&&(a["line-opacity"]=i.opacity),"principal"===s&&Js(e,"pattern")&&((e,t,i)=>{const r=i?.pattern??Qs(e).pattern,s=r&&so[r];s?t["line-dasharray"]=s:delete t["line-dasharray"]})(e,a,i),{...t,layout:{...t.layout,...!oo(e,i)&&{visibility:"none"}},paint:a}},ho=(e,t,i)=>{const r=Js(e,"icon")?i?.icon:void 0;return{...t,layout:{...t.layout,...r&&{"icon-image":r.image,"icon-size":r.size??1,...r.placement&&{"symbol-placement":"along"===r.placement?"line":"line-center"}},...!oo(e,i)&&{visibility:"none"}}}},uo=(e,t,i)=>co(e,{filter:qr,type:"line",layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":ro[e].color,"line-opacity":ro[e].opacity}},t,i),po=["interpolate",["linear"],["zoom"],10,.5,16,.7],fo=["interpolate",["linear"],["zoom"],10,9,16,13],yo=["-",["get","startPointIndex"],["get","endPointIndex"]],mo=["case",["==",["get","signFace"],"plaque"],["literal",[0,.55]],["literal",[0,0]]],go=(e,t)=>({filter:qr,type:"symbol",minzoom:t?.sign?.minzoom??9,layout:{"symbol-placement":"line","symbol-spacing":260,"icon-image":["get","signImageID"],"icon-size":po,"icon-rotation-alignment":"viewport","text-field":["get","signLabel"],"text-font":[yt],"text-size":fo,"text-offset":mo,"text-rotation-alignment":"viewport","symbol-sort-key":yo,...!oo(e,t)&&{visibility:"none"}},paint:{"text-color":["get","signNumeralsColor"]}}),_o=(e,t)=>`routeSection${e.charAt(0).toUpperCase()+e.slice(1)}${t}`,Lo=e=>_o(e,"Sign"),bo="traffic-clear",So="traffic-major",Io="traffic-moderate",Ao="traffic-minor",Eo=["has","formattedTraffic"],Ro=e=>{const t=void 0!==e?Kt(Ds,e):Ds,i=void 0!==e?Kt(Fs,e):Fs,r=void 0!==e?Kt(bo,e):bo,s=void 0!==e?Kt(So,e):So,o=void 0!==e?Kt(Io,e):Io,a=void 0!==e?Kt(Ao,e):Ao;return{type:"symbol",layout:{"icon-image":["case",qr,t,i],"symbol-placement":"point","icon-rotation-alignment":"viewport","text-rotation-alignment":"viewport","symbol-sort-key":["case",qr,0,1],"icon-text-fit":"both","icon-text-fit-padding":[10,5,5,10],"text-font":[gt],"text-size":13,"icon-padding":0,"text-justify":"left","text-line-height":1.5,"text-field":["format",["get","formattedDuration"],{"text-font":["literal",[yt]],"text-color":["case",qr,"black",Yr]},["concat","\t\t",["get","formattedDistance"]],{"text-color":Yr},["case",Eo,"\n",""],{},["image",["case",Eo,["match",["get","magnitudeOfDelay"],"major",s,"moderate",o,"minor",a,r],""]],{},["case",Eo,["concat"," ",["get","formattedTraffic"]],""],{"text-font":["literal",[yt]],"text-color":ks}]},paint:{"icon-translate":[0,-35],"text-translate":[0,-35]}}},To=Ro(),vo="start",wo="middle",Co="finish",Oo="stopDisplayIndex",No="waypointStart",Mo="waypointStop",xo="waypointFinish",Do=["format",["coalesce",["get",kt],""],{},["case",["all",["has",kt],Gr],"\n",""],{},...Br],Fo={"text-field":["get",Oo],"text-font":[yt],"text-size":["interpolate",["linear"],["zoom"],13,14,18,16],"text-offset":[0,-1.6],"icon-anchor":"bottom","text-allow-overlap":!0},Po={type:"symbol",paint:{...zt,"text-color":"#ffffff"},layout:{...Vt,...Fo,"symbol-sort-key":["abs",["-",["get","index"],1e3]]}},Uo={type:"symbol",paint:{...jt,"text-color":"black","text-halo-width":1.5,"text-halo-color":"#ffffff"},layout:{...$t,"text-field":Do,"text-anchor":"top","text-offset":[0,.4]}},ko=(e,t)=>e&&t&&(e.startsWith("route")||e.startsWith("waypoint"))?`${t}-${e}`:e,Ho=(e,t)=>e&&t?Object.fromEntries(Object.entries(e).map(([e,i])=>[e,i?.beforeID?{...i,beforeID:ko(i.beforeID,t)}:i])):e,Wo=(e,t)=>t?{...e,...t,...t.paint&&{paint:{...e.paint,...t.paint}},...t.layout&&{layout:{...e.layout,...t.layout}}}:e,Bo=(e,t)=>e&&void 0!==t?`${e}-${t}`:e,Go=(e={},t,i)=>{const r=e.layers,s=r?.sections,o=e.theme?.mainColor,a=o?ge(o,.4):void 0,n=e.theme?.routeWidth,l=e.theme?.waypointSize,c=rs(l),h=e.sections,u=(e,i,r)=>({...co(e,i,h?.[e],n,r?.role),beforeID:ko(r?.beforeID??lo(e,h?.[e]),t)}),d=(e,i,r)=>({...ho(e,i,h?.[e]),beforeID:ko(r,t)}),p=Object.fromEntries(Ys.map(e=>{const i=h?.[e],r=(e=>_o(e,"Line"))(e),o=(e=>_o(e,"Symbol"))(e),a=s?.[e];if(to(e)){const r=Lo(e);return[e,{[r]:Wo(go(e,i),a?.[r]),...Ho(a?.additional,t)}]}const l=i&&((e,t)=>{if(t.icon&&Js(e,"icon"))return ho(e,{filter:qr,type:"symbol",layout:{"symbol-placement":"line-center","icon-allow-overlap":!0,"icon-rotation-alignment":"viewport"}},t)})(e,i);return[e,{[r]:Wo({...uo(e,i,n),beforeID:ko(lo(e,i),t)},a?.[r]),...l&&{[o]:Wo({...l,beforeID:At.lowestLabel},a?.[o])},...Ho(a?.additional,t)}]}));return{mainLines:{routeLineArrows:Wo({...xs,beforeID:At.lowestLabel},r?.mainLines?.routeLineArrows),routeLine:Wo({...Ms(n,o),beforeID:ko("routeIncidentBackgroundLine",t)},r?.mainLines?.routeLine),routeOutline:Wo({...Ns(n,a),beforeID:ko("routeLine",t)},r?.mainLines?.routeOutline),routeDeselectedLine:Wo({...Os(n),beforeID:ko("routeOutline",t)},r?.mainLines?.routeDeselectedLine),routeDeselectedOutline:Wo({...Cs(n),beforeID:ko("routeDeselectedLine",t)},r?.mainLines?.routeDeselectedOutline),...Ho(r?.mainLines?.additional,t)},waypoints:{routeWaypointSymbol:Wo({...Po,layout:{...Po.layout,"icon-size":c},beforeID:ko("routeSummaryBubbleSymbol",t)},r?.waypoints?.routeWaypointSymbol),routeWaypointLabel:Wo({...Uo,beforeID:ko("routeWaypointSymbol",t)},r?.waypoints?.routeWaypointLabel),...Ho(r?.waypoints?.additional,t)},chargingStops:{routeChargingStopSymbol:Wo({...Ls(e.chargingStops),beforeID:ko("routeWaypointSymbol",t)},r?.chargingStops?.routeChargingStopSymbol),...Ho(r?.chargingStops?.additional,t)},sections:{...p,traffic:{routeIncidentJamSymbol:Wo(d("traffic",Gs,"routeChargingStopSymbol"),s?.traffic?.routeIncidentJamSymbol),routeIncidentCauseSymbol:Wo(d("traffic",Vs,"routeChargingStopSymbol"),s?.traffic?.routeIncidentCauseSymbol),routeIncidentBackgroundLine:Wo(u("traffic",Hs,{beforeID:"routeIncidentDashedLine"}),s?.traffic?.routeIncidentBackgroundLine),routeIncidentDashedLine:Wo(u("traffic",Ws),s?.traffic?.routeIncidentDashedLine),...Ho(s?.traffic?.additional,t)},ferry:{routeFerryLine:Wo(u("ferry",Ts),s?.ferry?.routeFerryLine),routeFerrySymbol:Wo(d("ferry",vs,"routeIncidentJamSymbol"),s?.ferry?.routeFerrySymbol),...Ho(s?.ferry?.additional,t)},tollRoad:{routeTollRoadOutline:Wo(u("tollRoad",Ps),s?.tollRoad?.routeTollRoadOutline),routeTollRoadSymbol:Wo(d("tollRoad",Us,"routeChargingStopSymbol"),s?.tollRoad?.routeTollRoadSymbol),...Ho(s?.tollRoad?.additional,t)},tunnel:{routeTunnelLine:Wo(u("tunnel",zs),s?.tunnel?.routeTunnelLine),...Ho(s?.tunnel?.additional,t)},vehicleRestricted:{routeVehicleRestrictedBackgroundLine:Wo(u("vehicleRestricted",$s,{beforeID:"routeVehicleRestrictedForegroundLine",role:"outline"}),s?.vehicleRestricted?.routeVehicleRestrictedBackgroundLine),routeVehicleRestrictedForegroundLine:Wo(u("vehicleRestricted",js),s?.vehicleRestricted?.routeVehicleRestrictedForegroundLine),...Ho(s?.vehicleRestricted?.additional,t)}},instructionLines:{routeInstructionLine:Wo({...As(n),beforeID:At.lowestLabel},r?.instructionLines?.routeInstructionLine),routeInstructionOutline:Wo({...Is(n),beforeID:ko("routeInstructionLine",t)},r?.instructionLines?.routeInstructionOutline),...Ho(r?.instructionLines?.additional,t)},instructionArrows:{routeInstructionArrowSymbol:Wo({...Rs,beforeID:ko("routeInstructionLine",t),...void 0!==i&&{layout:{...Rs.layout,"icon-image":Bo(Rs.layout?.["icon-image"],i)}}},r?.instructionArrows?.routeInstructionArrowSymbol),...Ho(r?.instructionArrows?.additional,t)},summaryBubbles:{routeSummaryBubbleSymbol:Wo(void 0===i?To:Ro(i),r?.summaryBubbles?.routeSummaryBubbleSymbol),...Ho(r?.summaryBubbles?.additional,t)}}},Vo=Go();Ie()&&(Xe=Ae(Ee('<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 zo,$o,jo=e=>{if(!Ie())return;const t=Ee('<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),Ae(t)},Yo={pixelRatio:2,stretchX:[[20,45],[100,130]],stretchY:[[20,35]],content:[10,10,130,45]},Ko={whiteDisc:'<svg xmlns="http://www.w3.org/2000/svg" width="92" height="92" viewBox="0 0 46 46"><circle cx="23" cy="23" r="19.5" fill="#fff" stroke="#D0021B" stroke-width="5"/></svg>\n',yellowDisc:'<svg xmlns="http://www.w3.org/2000/svg" width="92" height="92" viewBox="0 0 46 46"><circle cx="23" cy="23" r="19.5" fill="#FFCE00" stroke="#D0021B" stroke-width="5"/></svg>\n',plaque:'<svg xmlns="http://www.w3.org/2000/svg" width="92" height="92" viewBox="0 0 46 46"><rect x="7" y="3" width="32" height="40" rx="2" fill="#fff" stroke="#1A2024" stroke-width="2"/><text x="23" y="13" fill="#1A2024" font-family="sans-serif" font-size="7" font-weight="bold" text-anchor="middle">SPEED</text><text x="23" y="21" fill="#1A2024" font-family="sans-serif" font-size="7" font-weight="bold" text-anchor="middle">LIMIT</text></svg>\n'},qo=e=>{if(Ie())return Ae(Ee(Ko[e]))},Zo=e=>{if(!Ie())return;const t=Ee('<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),Ae(t)},Xo=(e,t)=>{if(!Ie())return;const i=Re(t);return e&&i.appendChild(e),Ae(i)},Jo=e=>{if(Ie())return Xo(Ee('<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)},Qo=e=>{if(Ie())return Xo(Ee('<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)},ea=(e={},t)=>Object.entries(e).map(([e,i])=>({...i,id:qt(e,t)})),ta=(e={},t)=>({...Object.fromEntries(Ys.map(i=>[io(i),ea(e.sections?.[i],t)])),mainLines:ea(e.mainLines,t),waypoints:ea(e.waypoints,t),chargingStops:ea(e?.chargingStops,t),ferries:ea(e.sections?.ferry,t),incidents:ea(e.sections?.traffic,t),tollRoads:ea(e.sections?.tollRoad,t),tunnels:ea(e.sections?.tunnel,t),vehicleRestricted:ea(e.sections?.vehicleRestricted,t),instructionLines:ea(e.instructionLines,t),instructionArrows:ea(e.instructionArrows,t),summaryBubbles:ea(e.summaryBubbles,t)}),ia=(e,t,i)=>{const r=l.instance.get().displayUnits,s=e?.displayUnits;return{...e,...s?{}:{displayUnits:r},layers:Go(e,t,i)}},ra=(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 Se("7309")},sa=e=>{const t=e.properties;return t.chargingParkName??t.chargingParkOperatorName},oa=e=>e.categories.includes("jam"),aa=e=>{const t=(e=>{if(oa(e))return p(e.delayInSeconds)})(e),i=((e,t)=>oa(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}}},na=(e,t,i)=>{let r;switch(t){case"start":r=No;break;case"finish":r=xo;break;default:r=Mo}return void 0!==i?Kt(r,i):r},la=(e,t,i,r)=>({type:"FeatureCollection",features:e.map((s,o)=>{if(!s)return null;const a=(e=>{return Array.isArray(e)?{type:"Feature",geometry:{type:"Point",coordinates:e},properties:{}}:"Point"===e.type?{type:"Feature",geometry:t=e,properties:{},...t.bbox&&{bbox:t.bbox}}:e;var t})(s),n=((e,t)=>0===e?vo:e<t-1?wo:Co)(o,e.length),l=(e=>{const t=e?.properties;return t?.poi?.name??t?.address?.freeformAddress??void 0})(a),c=a.id??f(),h=p(a.properties.pauseDurationSeconds,r);return{...a,..."main-when-available"===t?.entryPoints&&{geometry:{type:"Point",coordinates:m(a,{useEntryPoint:"main-when-available"})}},id:c,properties:{...a.properties,id:c,index:o,indexType:n,...l&&{title:l},...h&&{stopDuration:h},iconID:na(0,n,i),..."middle"===n&&{stopDisplayIndex:o}}}}).filter(e=>e)}),ca=(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))}),ha=(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)),ua=(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"}}})}},da=(e,t)=>e.some(e=>e.magnitudeOfDelay===t),pa=(e,t)=>({type:"FeatureCollection",features:e.features.map(e=>{const i=e.properties.summary,r=e.geometry.coordinates,s=p(i.trafficDelayInSeconds,t?.time),o=(e=>{const t=e.properties.sections.traffic;if(t?.length)return da(t,"major")?"major":da(t,"moderate")?"moderate":da(t,"minor")?"minor":void 0})(e),a=e.id??f();return{type:"Feature",id:a,geometry:{type:"Point",coordinates:r[Math.round(r.length/2)]},properties:{id:a,routeIndex:e.properties.index,routeState:e.properties.routeState,formattedDistance:d(i.lengthInMeters,t?.distance),...o&&{magnitudeOfDelay:o},...s&&{formattedTraffic:s},formattedDuration:p(i.travelTimeInSeconds,t?.time)}}})}),fa={GBR:{unit:"mph"},LBR:{unit:"mph"},MMR:{unit:"mph"},USA:{face:"plaque",unit:"mph"},SWE:{face:"yellowDisc"},FIN:{face:"yellowDisc"},ISL:{face:"yellowDisc"},JPN:{numerals:"#0B5FA5"}},ya={metric:{},imperial_uk:{unit:"mph"},imperial_us:{face:"plaque",unit:"mph"}},ma={whiteDisc:"routeSpeedLimitWhiteDisc",yellowDisc:"routeSpeedLimitYellowDisc",plaque:"routeSpeedLimitPlaque"},ga=(e,t)=>"mph"===t?5*Math.round(1e3*e/1609.344/5):e,_a=class e extends ze{static async create(t,i){return await Te(t),new e(t,i)}constructor(e,t){super(e,t),this.shownFeaturesHandlers=[]}createSourcesWithLayers(e){const t=Kt("routes",this.instanceIndex);return{...Object.fromEntries(Ys.map(i=>{const r=io(i);return[r,new ot(this.mapLibreMap,`${t}-${r}`,e[r],!1)]})),mainLines:new ot(this.mapLibreMap,`${t}-mainLines`,e.mainLines,!1),waypoints:new ot(this.mapLibreMap,`${t}-waypoints`,e.waypoints,!1),incidents:new ot(this.mapLibreMap,`${t}-incidents`,e.incidents,!1),ferries:new ot(this.mapLibreMap,`${t}-ferries`,e.ferries,!1),chargingStops:new ot(this.mapLibreMap,`${t}-chargingStops`,e.chargingStops,!1),tollRoads:new ot(this.mapLibreMap,`${t}-tollRoads`,e.tollRoads,!1),tunnels:new ot(this.mapLibreMap,`${t}-tunnels`,e.tunnels,!1),vehicleRestricted:new ot(this.mapLibreMap,`${t}-vehicleRestricted`,e.vehicleRestricted,!1),instructionLines:new ot(this.mapLibreMap,`${t}-instructionLines`,e.instructionLines,!1),instructionArrows:new ot(this.mapLibreMap,`${t}-instructionArrows`,e.instructionArrows,!1),summaryBubbles:new ot(this.mapLibreMap,`${t}-summaryBubbles`,e.summaryBubbles,!1)}}_initSourcesWithLayers(e,t){t||(this.layerIDPrefix=Kt("routes",this.instanceIndex)),this.layersSpecs=ta(ia(e,this.layerIDPrefix,this.instanceIndex).layers,this.layerIDPrefix);const i=this.createSourcesWithLayers(this.layersSpecs);xe(Object.values(i).flatMap(e=>e._layerSpecs),this.mapLibreMap);const r={fillColor:e?.theme?.mainColor,...e?.waypoints?.icon?.style},s={pixelRatio:2},o=Kt(No,this.instanceIndex),a=Kt(Mo,this.instanceIndex),n=Kt(xo,this.instanceIndex),l=Kt(Es,this.instanceIndex),c=Kt(Ds,this.instanceIndex),h=Kt(Fs,this.instanceIndex),u=Kt(bo,this.instanceIndex),d=Kt(So,this.instanceIndex),p=Kt(Io,this.instanceIndex),f=Kt(Ao,this.instanceIndex);this.addImageIfNotExisting(o,Jo(r),s),this.addImageIfNotExisting(a,Xo(void 0,r),s),this.addImageIfNotExisting(n,Qo(r),s),this.addImageIfNotExisting(l,Xe,s),this.addImageIfNotExisting(c,jo("white"),Yo),this.addImageIfNotExisting(h,jo("#EEEEEE"),Yo);for(const[y,m]of Object.entries(ma))this.addImageIfNotExisting(Kt(m,this.instanceIndex),qo(y),s);this.addImageIfNotExisting(u,Zo(fs),s),this.addImageIfNotExisting(d,Zo(hs),s),this.addImageIfNotExisting(p,Zo(us),s),this.addImageIfNotExisting(f,Zo(ps),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=ia(e,this.layerIDPrefix,this.instanceIndex),r=!t(this.config?.displayUnits,i.displayUnits);if(this.config){const t=ta(i.layers,this.layerIDPrefix);Object.keys(t).forEach(e=>{const i=e;Oe(t[i],this.layersSpecs[i],this.sourcesWithLayers[i],this.mapLibreMap)});const s=Object.values(this.sourcesWithLayers);xe(s.flatMap(e=>e._layerSpecs),this.mapLibreMap),this.reshowSpeedLimitSigns(i,r),s.forEach(e=>e.setLayersVisible(!!e.shownFeatures.features.length)),this.applySectionVisibility(e),this.applySignPriority(e),this.layersSpecs=t}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",Kt(No,this.instanceIndex),Jo(t),this.mapLibreMap,i),Pe("add-or-update",Kt(Mo,this.instanceIndex),Xo(void 0,t),this.mapLibreMap,i),Pe("add-or-update",Kt(xo,this.instanceIndex),Qo(t),this.mapLibreMap,i)}const s=!1!==i.summaryBubbles?.visible,o=!t(this.config?.summaryBubbles?.visible,i.summaryBubbles?.visible),a=this.sourcesWithLayers.summaryBubbles.shownFeatures.features.length>0,n=this.sourcesWithLayers.mainLines.shownFeatures.features.length>0;return!s&&o?this.sourcesWithLayers.summaryBubbles.clear():s&&(o&&n||r&&a)&&this.sourcesWithLayers.summaryBubbles.show(pa(this.sourcesWithLayers.mainLines.shownFeatures,i.displayUnits)),i}showSpeedLimitSections(e,t){var i,r;this.sourcesWithLayers.speedLimitSections.show(ca(e,"speedLimit",(i=this.instanceIndex,r={unit:t?.sections?.speedLimit?.sign?.unit,displayUnits:t?.displayUnits},(e,t)=>{const s=(o=e.startPointIndex,a=t?.sections.country,a?.find(e=>o>=e.startPointIndex&&o<=e.endPointIndex)?.countryCodeISO3);var o,a;const n=s?fa[s]??{}:ya[r?.displayUnits?.distance?.type??"metric"],l=n.face??"whiteDisc",c=r?.unit??n.unit??"km/h";return{...e,signImageID:Kt(ma[l],i),signLabel:String(ga(e.maxSpeedLimitInKmh,c)),signFace:l,signNumeralsColor:n.numerals??"#1A2024"}})))}reshowSpeedLimitSigns(e,i){t(this.config?.sections?.speedLimit?.sign?.unit,e.sections?.speedLimit?.sign?.unit)&&!i||this.sourcesWithLayers.speedLimitSections.shownFeatures.features.length&&this.showSpeedLimitSections(this.sourcesWithLayers.mainLines.shownFeatures,e)}applySectionVisibility(e){for(const t of qs){const i=this.sourcesWithLayers[io(t)],r=!!i.shownFeatures.features.length;i.setLayersVisible(r&&oo(t,e?.sections?.[t]))}}signLayerID(e){if(to(e))return qt(Lo(e),this.layerIDPrefix)}applySignPriority(e){for(const t of Ys){const i=this.signLayerID(t);if(!i||!this.mapLibreMap.getLayer(i))continue;const r=e?.sections?.[t];this.mapLibreMap.moveLayer(i,this.signAnchorLayerID(i,r))}}signAnchorLayerID(e,t){const i=t?.sign?.priority??"belowRouteIcons";if("aboveRouteIcons"===i)return;const r=this.mapLibreMap.getStyle().layers;if("belowMapLabels"===i)return At.lowestLabel;const s=r.findIndex(e=>e.id===At.lowestLabel);return r.find((t,i)=>"symbol"===t.type&&t.id!==e&&i>s&&(!this.layerIDPrefix||t.id.startsWith(this.layerIDPrefix)))?.id}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]);this.applySectionVisibility(this.config)}addImageIfNotExisting(e,t,i){Pe("if-not-in-sprite",e,t,this.mapLibreMap,i)}async showRoutes(e,t){const i=ua(e,t?.selectedIndex);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(i),this.sourcesWithLayers.vehicleRestricted.show(ca(i,"vehicleRestricted")),this.sourcesWithLayers.incidents.show(ca(i,"traffic",aa)),this.sourcesWithLayers.chargingStops.show(((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 o=s.properties,a=p(e.summary.stopTimeInSeconds??o.chargingTimeInSeconds,t?.displayUnits?.time);i.push({...s,properties:{...s.properties,id:s.properties.chargingParkId??f(),iconID:ra(s,t),title:sa(s),chargingPower:`${o.chargingConnectionInfo?.chargingPowerInkW} kW`,chargingDuration:p(o.chargingTimeInSeconds,t?.displayUnits?.time),...a&&{stopDuration:a},routeState:r.properties.routeState,routeIndex:r.properties.index}})}}return{type:"FeatureCollection",features:i}})(i,this.config)),this.sourcesWithLayers.ferries.show(ca(i,"ferry")),this.sourcesWithLayers.tunnels.show(ca(i,"tunnel")),this.sourcesWithLayers.tollRoads.show(ca(i,"tollRoad"));for(const r of Ys)to(r)||this.sourcesWithLayers[io(r)].show(ca(i,r));this.showSpeedLimitSections(i,this.config),this.applySectionVisibility(this.config),this.applySignPriority(this.config),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(pa(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=ua(this.sourcesWithLayers.mainLines.shownFeatures,e);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(t),ha(t,this.sourcesWithLayers.chargingStops),ha(t,this.sourcesWithLayers.vehicleRestricted),ha(t,this.sourcesWithLayers.incidents),ha(t,this.sourcesWithLayers.ferries),ha(t,this.sourcesWithLayers.tollRoads);for(const i of Ys)ha(t,this.sourcesWithLayers[io(i)]);ha(t,this.sourcesWithLayers.tunnels),ha(t,this.sourcesWithLayers.instructionLines),ha(t,this.sourcesWithLayers.instructionArrows),ha(t,this.sourcesWithLayers.summaryBubbles),this.applySectionVisibility(this.config)}async showWaypoints(e){const t=Array.isArray(e)?la(e,this.config?.waypoints,this.instanceIndex,this.config?.displayUnits?.time):la(e.features,this.config?.waypoints,this.instanceIndex,this.config?.displayUnits?.time);await this.waitUntilModuleReady(),this.sourcesWithLayers.waypoints.show(t),this.applySignPriority(this.config);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,...Object.fromEntries(Ys.map(e=>[io(e),this.sourcesWithLayers[io(e)].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(){const e=Object.fromEntries(Ys.map(e=>[io(e),this.userEvents([io(e)])]));return this.buildEvents(this.moduleEventsWithShown(["mainLines","waypoints","chargingStops","summaryBubbles","incidents","vehicleRestricted","ferries","tollRoads","tunnels","instructionLines",...Ys.map(io)],this.shownFeaturesHandlers),{...e,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}},La={min:.5,max:1.5,step:.1},ba={min:.5,max:2,step:.1},Sa={sourceTypes:["vector"],layerTypes:["symbol"]},Ia={sources:["vectorTiles"],sourceLayers:["poi"],layerTypes:["symbol"]},Aa={...(zo="roads",sr[zo]),layerTypes:["line"]},Ea=e=>(t,i)=>({sources:[e],layerTypes:["line"],idIncludes:[i?`${t} outline`:t],...i?{}:{idExcludes:["outline"]}}),Ra=Ea(wt),Ta=Ea(vt),va=(e,t,i=La)=>({kind:"factor",description:e,range:i,appliesTo:"any-style",mechanisms:t}),wa=(e,t)=>({kind:"toggle",description:e,appliesTo:"tomtom-styles",mechanisms:[{type:"visibility",layers:t}]}),Ca=(e,t,i,r)=>({kind:"color",description:e,appliesTo:"tomtom-styles",mechanisms:[{type:"color",property:t,layers:i,shades:r}]}),Oa=e=>(t,i)=>Ca(t,"line-color",[e(i,!1)],[e(i,!0)]),Na=Oa(Ra),Ma=Oa(Ta),xa={"labels.sizeFactor":va("Size of every base-map text label (places, roads, POIs, house numbers).",[{type:"scale",property:"text-size",layers:[Sa]}]),"symbols.sizeFactor":va("Size of every base-map icon (POI icons, route shields, road arrows).",[{type:"scale",property:"icon-size",layers:[Sa]}]),"roads.widthFactor":va("Width of all road lines, keeping the hierarchy motorway → path.",[{type:"scale",property:"line-width",layers:[Aa]}]),"pois.sizeFactor":va("Size of the base-map POI icons and their labels.",[{type:"scale",property:"icon-size",layers:[Ia]},{type:"scale",property:"text-size",layers:[Ia]}]),"pois.minZoom":{kind:"number",description:"Zoom level from which base-map POIs appear (the style default is 6).",range:{min:3,max:18,step:1},appliesTo:"tomtom-styles",mechanisms:[{type:"minZoom",layers:[{...Ia,idExcludes:["micro"]}]}]},"pois.zoomShift":{kind:"number",description:"Shifts the zoom at which each POI appears: positive = later and sparser, negative = earlier and denser.",range:{min:-3,max:3,step:1},appliesTo:"tomtom-styles",mechanisms:[{type:"zoomOffset",layers:[Ia]}]},"pois.labelColor":Ca("Text colour of base-map POI labels (replaces the per-category colours).","text-color",[Ia]),"pois.labelOutlineColor":Ca("Halo colour of base-map POI labels.","text-halo-color",[Ia]),"pois.microMarkers":wa("The small dot markers for low-priority POIs at high zoom.",[{...Ia,idIncludes:["micro"]}]),"roads.exitNumbers":wa("Motorway exit number badges.",[{metadataGroups:["road_label"],layerTypes:["symbol"],idIncludes:["exit"]}]),"roads.shields":wa("Route shields along roads.",[{metadataGroups:["road_label"],layerTypes:["symbol"],idIncludes:["shield"]}]),"roads.arrows":wa("One-way arrows drawn on roads.",[{metadataGroups:["road"],layerTypes:["symbol"],idIncludes:["arrow"]}]),"roads.restricted":wa("Dashed marking of roads with restricted access.",[{metadataGroups:["road"],layerTypes:["line"],idIncludes:["restricted"]}]),"roads.underConstruction":wa("Roads under construction.",[{metadataGroups:["road"],layerTypes:["line"],idIncludes:["construction"]}]),"buildings.footprints":wa("2D building footprints, shadows and outlines.",[{metadataGroups:["building"],layerTypes:["fill","line"]}]),"buildings.3d":wa("Extruded 3D buildings (hidden by default in the standard styles).",[{metadataGroups:["area_3d","building"],layerTypes:["fill-extrusion"]}]),"traffic.flow.freeColor":Na("Traffic flow colour for free-flowing roads.","free flow"),"traffic.flow.slowColor":Na("Traffic flow colour for slow traffic.","slow flow"),"traffic.flow.queueingColor":Na("Traffic flow colour for queueing traffic.","queueing flow"),"traffic.flow.stationaryColor":Na("Traffic flow colour for stationary traffic.","stationary flow"),"traffic.flow.closedColor":Ca("Traffic flow colour for closed roads.","line-color",[Ra("closed road",!0)]),"traffic.flow.widthFactor":va("Width of the traffic flow tubes.",[{type:"scale",property:"line-width",layers:[{sources:[wt],layerTypes:["line"]}]}],ba),"traffic.incidents.minorColor":Ma("Traffic incident tube colour for minor delays.","minor jam"),"traffic.incidents.moderateColor":Ma("Traffic incident tube colour for moderate delays.","moderate jam"),"traffic.incidents.majorColor":Ma("Traffic incident tube colour for major delays.","major jam"),"traffic.incidents.closedColor":Ca("Traffic incident tube colour for closed roads.","line-color",[Ta("closed road",!0)]),"traffic.incidents.widthFactor":va("Width of the traffic incident tubes.",[{type:"scale",property:"line-width",layers:[{sources:[vt],layerTypes:["line"]}]}],ba)},Da=Object.keys(xa),Fa=(e,t)=>"number"==typeof e?(e=>Math.round(1e3*e)/1e3)(e*t):(e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&Array.isArray(e.stops))(e)?Pa(e,t):Array.isArray(e)?"interpolate"===e[0]||"step"===e[0]?Ua(e,t):(e=>JSON.stringify(e).includes('"zoom"'))(e)?void 0:["*",t,e]:void 0,Pa=(e,t)=>{const i=[];for(const[r,s]of e.stops){const e=Fa(s,t);if(void 0===e)return;i.push([r,e])}return{...e,stops:i}},Ua=(e,t)=>{const i=[...e];for(let r="interpolate"===e[0]?4:2;r<i.length;r+=2){const e=Fa(i[r],t);if(void 0===e)return;i[r]=e}return i},ka=(e,t)=>{let i=!1;const r=e=>Array.isArray(e)?"-"===e[0]&&3===e.length&&Array.isArray(e[1])&&"zoom"===e[1][0]&&"number"==typeof e[2]?(i=!0,["-",["zoom"],e[2]+t]):e.map(r):e;return{filter:r(e),patched:i}},Ha=/* @__PURE__ */new Set(["text-size","icon-size","visibility"]),Wa=/* @__PURE__ */new Set(["line-width","line-color","text-color","text-halo-color"]),Ba=16,Ga=1,Va=1,za="visible",$a=0,ja=24,Ya=(e,t)=>`${e}|${t}`,Ka=class e extends $e{static async get(t,i){return await Te(t),Ot(t,e,()=>new e(t,i),i&&(e=>e.applyConfig({...e.config,...i})))}constructor(e,t){super(e,t)}styleChangePriority(){return 100}_initSourcesWithLayers(){const e=this.mapLibreMap.getStyle();return this.indexStyle(e?.layers??[],e?.sources??{}),{}}_applyConfig(e){const t=Ja(e),i=/* @__PURE__ */new Set([...Xa(this.config),...Xa(t)]);for(const r of i)this.refreshKnob(r,t);return Object.keys(t).length?t:void 0}describe(){return{knobs:Da.map(e=>this.describeKnob(e))}}get(e){return this.assertKnob(e),this.config?.[e]??this.defaultOf(e)}set(e,t){this.assertKnob(e),this.validate(e,t),this.config={...this.config,[e]:t},this.refreshKnob(e,this.config),this.emitConfigChange()}reset(e){if(void 0===e)return void this.resetConfig();this.assertKnob(e);const{[e]:t,...i}=this.config??{};this.config=Object.keys(i).length?i:void 0,this.refreshKnob(e,this.config??{}),this.emitConfigChange()}get events(){return this.moduleEvents([])}indexStyle(e,t){this.originalValues=/* @__PURE__ */new Map,this.styleSources=t,this.resolved=/* @__PURE__ */new Map,this.scaleKnobsByTarget=/* @__PURE__ */new Map,this.warned=/* @__PURE__ */new Set;for(const i of Da){const t=xa[i],r=t.mechanisms.map(t=>this.resolveMechanism(i,t,e)),s=new Set(r.flatMap(e=>e.layerIds)).size;this.resolved.set(i,{definition:t,mechanisms:r,targets:s}),0===s&&this.warnOnce(i,`knob '${i}' matches no layer in the loaded style (curated for style version ${Fr}); it will have no effect.`)}}resolveMechanism(e,t,i){const r=i.filter(e=>ir(t.layers,e,this.styleSources));let s,o=[];switch(t.type){case"scale":s=r.filter(e=>this.capture(e,t.property)).map(e=>e.id);for(const i of s){const r=Ya(i,t.property);this.scaleKnobsByTarget.set(r,[...this.scaleKnobsByTarget.get(r)??[],e])}break;case"color":{s=r.filter(e=>this.capture(e,t.property)).map(e=>e.id);const e=t.shades??[];o=i.filter(t=>ir(e,t,this.styleSources)).filter(e=>this.capture(e,t.property)).map(e=>e.id);break}case"visibility":s=r.filter(e=>this.capture(e,"visibility")).map(e=>e.id);break;case"minZoom":s=r.map(e=>e.id);for(const e of r)this.capture(e,"minzoom"),this.capture(e,"maxzoom");break;case"zoomOffset":s=r.filter(e=>ka(Qa(e),0).patched).map(e=>e.id)}return{mechanism:t,layerIds:s,shadeLayerIds:o}}capture(e,t){const i=en(e,t);return void 0!==i&&(this.originalValues.set(Ya(e.id,t),i),!0)}originalValueOf(e,t){return this.originalValues.get(Ya(e,t))}refreshKnob(e,t){const i=this.resolved.get(e);if(i&&this.tomtomMap.mapReady)for(const r of i.mechanisms)this.refreshMechanism(r,t[e],t)}refreshMechanism({mechanism:e,layerIds:t,shadeLayerIds:i},r,s){switch(e.type){case"scale":for(const i of t)this.refreshScaledProperty(i,e.property,s);break;case"visibility":for(const e of t)this.refreshVisibility(e,r);break;case"color":this.refreshColor(e.property,t,i,r);break;case"minZoom":for(const e of t)this.refreshMinZoom(e,r);break;case"zoomOffset":for(const e of t)this.refreshZoomOffset(e,r)}}refreshVisibility(e,t){void 0!==t?this.setProperty(e,"visibility",t?"visible":"none"):this.setProperty(e,"visibility",this.originalValueOf(e,"visibility"))}refreshMinZoom(e,t){if(!this.mapLibreMap.getLayer(e))return;const i=t??this.originalValueOf(e,"minzoom")??$a,r=this.originalValueOf(e,"maxzoom")??ja;this.mapLibreMap.setLayerZoomRange(e,i,r)}refreshZoomOffset(e,t){this.filterComposer.setTransform(e,"styling.zoomShift",void 0===t?void 0:e=>ka(e,t).filter)}refreshScaledProperty(e,t,i){const r=this.originalValueOf(e,t),s=(this.scaleKnobsByTarget.get(Ya(e,t))??[]).reduce((e,t)=>e*(i[t]??1),1);if(1===s)return void this.setProperty(e,t,r);const o=Fa(r,s);void 0!==o?this.setProperty(e,t,o):this.warnOnce(`scale:${e}:${t}`,`cannot scale '${t}' of layer '${e}': the style gives it a value this knob cannot scale (a non-numeric value, or an expression holding a nested zoom term); leaving it as the style defines it.`)}refreshColor(e,t,i,r){for(const o of t)this.setProperty(o,e,r??this.originalValueOf(o,e));const s=t.map(t=>this.originalValueOf(t,e)).find(qa);for(const o of i){const t=this.originalValueOf(o,e);let i=t;if(void 0!==r){const e=qa(t)&&s&&fe(s,t);i=(e&&ye(r,e))??r}this.setProperty(o,e,i)}}setProperty(e,t,i){if(!this.mapLibreMap.getLayer(e))return;const r=this.mapLibreMap;Ha.has(t)?r.setLayoutProperty(e,t,i,{validate:!1}):Wa.has(t)&&r.setPaintProperty(e,t,i,{validate:!1})}describeKnob(e){const{definition:t,targets:i}=this.resolved.get(e)??{definition:xa[e],targets:0};return pt(e,t.kind,t.description,this.defaultOf(e),this.config?.[e],{...t.range&&{range:t.range},available:i>0,appliesTo:t.appliesTo})}defaultOf(e){const t=this.resolved.get(e);if(!t)return;const{definition:i,mechanisms:r}=t;if("factor"===i.kind)return 1;const[s]=r,[o]=s?.layerIds??[];if(void 0!==o)switch(s.mechanism.type){case"visibility":return"none"!==this.originalValueOf(o,"visibility");case"color":{const e=this.originalValueOf(o,s.mechanism.property);return qa(e)?e:void 0}case"minZoom":return this.originalValueOf(o,"minzoom")??$a;case"zoomOffset":return 0;default:return}}assertKnob(e){if(!(e in xa))throw new Error(`Unknown styling knob '${e}'. Call describe() for the catalogue of knob ids.`)}validate(e,t){const{kind:i,range:r}=xa[e];switch(i){case"toggle":if("boolean"!=typeof t)throw new RangeError(`Knob '${e}' expects true or false; got ${Za(t)}.`);break;case"color":if("string"!=typeof t||!pe(t))throw new RangeError(`Knob '${e}' expects a CSS colour (#rrggbb, hsl(), rgb() or a named colour); got ${Za(t)}.`);break;default:if("number"!=typeof t||!Number.isFinite(t))throw new RangeError(`Knob '${e}' expects a number; got ${Za(t)}.`);if(r&&(t<r.min||t>r.max))throw new RangeError(`Knob '${e}' expects a number between ${r.min} and ${r.max}; got ${t}.`)}}warnOnce(e,t){this.warned.has(e)||(this.warned.add(e),console.warn(`[StylingModule] ${t}`))}},qa=e=>"string"==typeof e&&void 0!==pe(e),Za=e=>"string"==typeof e?`'${e}'`:String(e),Xa=e=>Object.keys(e??{}).filter(e=>e in xa),Ja=e=>Object.fromEntries(Object.entries(e??{}).filter(([,e])=>void 0!==e)),Qa=e=>"filter"in e?e.filter:void 0,en=(e,t)=>{const i="layout"in e?e.layout:void 0,r="paint"in e?e.paint:void 0;switch(t){case"text-size":return"symbol"===e.type&&void 0!==i?.["text-field"]?i["text-size"]??Ba:void 0;case"icon-size":return"symbol"===e.type&&void 0!==i?.["icon-image"]?i["icon-size"]??Ga:void 0;case"line-width":return"line"===e.type?r?.["line-width"]??Va:void 0;case"visibility":return i?.visibility??za;case"minzoom":return e.minzoom;case"maxzoom":return e.maxzoom;default:return r?.[t]}},tn=["factor","number","toggle","color"],rn=["any-style","tomtom-styles"],sn=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=ke(s),this.applyStyle(i,r)},this.getStyle=()=>this._params.style,this._params=b(e),void 0===this._params.style&&(this._params={...this._params,style:Dr}),this._styleLightDarkTheme=ke(this._params.style),this.ensureMapLibreCSSLoaded(),x(4),this.styleGivenToMapLibre=Hr(this._params),this.mapLibreMap=new C({validateStyle:!1,maxTileCacheZoomLevels:22,cancelPendingTileRequestsWhileZooming:!1,...(t=this._params).mapLibre,style:Hr(t),attributionControl:{compact:!1},transformRequest:we(t)}),this.mapLibreMap.once("style.load",()=>{this.handleStyleData()}),this._eventsProxy=new dt(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=Hr(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",o),t()},o=e=>{"sourceId"in e||(this.mapLibreMap.off("style.load",s),this.mapLibreMap.off("error",o),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",o),this.mapLibreMap.setStyle(e,{validate:!1})})}isSuperseded(e){return e!==this.styleRequestSequence}async notifyHandlers(e,t){const i=[...this.styleChangeHandlers].sort((e,t)=>(e.priority??0)-(t.priority??0));for(const s of i)try{await(s[e]?.(t))}catch(r){console.error(r)}}_setTomTomUserAgent(e){this._params={...this._params,"tomtom-user-agent":e},this.mapLibreMap.setTransformRequest(we(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 tt(this.mapLibreMap,[vt,wt,Rt]))this.mapLibreMap.setLayoutProperty(t.id,"visibility","none",{validate:!1});We(this._params.style)&&!He(this._params.style)&&(this._styleLightDarkTheme=(e=>{const t=e?.layers?.find(e=>"background"===e?.type);if(!t)return;const i=Be(t.paint?.["background-color"]),r=void 0===i?void 0:me(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(be,`${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)}}},on={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}},an="#ffffff",nn=e=>"dark"===e?"#FFFFFF":"#000000",ln={trafficLight:["#2dc653","#f5a623","#e03030"],heat:["#2196F3","#FF9800","#F44336"],monochrome:["#e0e0e0","#888888","#1a1a1a"],viridis:["#fde725","#35b779","#31688e","#440154"],plasma:["#f0f921","#ed7953","#9c179e","#0d0887"]},cn={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}},hn=e=>"speed"===e||"freeFlowSpeed"===e,un=e=>e?.activeMetric??on.activeMetric,dn=e=>{return"string"==typeof e?(t=ln[e]).map((e,i)=>({value:1===t.length?0:i/(t.length-1),color:e})):e.stops;var t},pn=e=>{if("top"!==e)return e?At[e]:At.lowestLabel},fn=e=>{if("top"!==e)return e?At[e]:At.lowestPlaceLabel},yn=(e,t,i)=>{const r=t??on.metricConfig[e].color??"trafficLight",s=dn(r);let o;if("string"==typeof r){const{min:t,max:i}=cn[e],r=hn(e)?[...s].reverse().map(e=>e.color):s.map(e=>e.color);o=s.map(({value:e},s)=>[t+e*(i-t),r[s]])}else if("relativeToPredefinedRangePCT"===r.valueType){const{min:t,max:i}=cn[e];o=s.map(({value:e,color:r})=>[t+e/100*(i-t),r])}else if("relativeToActualRangePCT"===r.valueType){const{min:t,max:r}=i??cn[e];o=s.map(({value:e,color:i})=>[t+e/100*(r-t),i])}else o=s.map(({value:e,color:t})=>[e,t]);return["interpolate",["linear"],["get",e],...o.flatMap(([e,t])=>[e,t])]},mn=(e,t)=>{const i=t??on.metricConfig[e].color??"trafficLight",r=dn(i);let s;if("string"==typeof i){const t=hn(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]},gn=(e,t,i)=>{const r=on.metricConfig[e].height,s=t?.minHeightMeters??r.minHeightMeters??0;if("raw"===t?.scaleMode){const i=t.scaleFactor??1;if("speed"===e){const{max:t}=cn[e];return["max",s,["*",["-",t,["coalesce",["get","speed"],0]],i]]}return["max",s,["*",["coalesce",["get",e],0],i]]}const o=t?.maxHeightMeters??r.maxHeightMeters??1e3,{min:a,max:n}="currentRange"===(t?.scaleMode??r.scaleMode)?i??cn[e]:cn[e],l=n-a||1;return"speed"===e?["max",s,["*",["/",["-",n,["coalesce",["get","speed"],0]],l],o]]:["max",s,["*",["/",["-",["coalesce",["get",e],0],a],l],o]]},_n=(e,t,i)=>{const r=un(t),s=t?.metricConfig?.[r],{min:o,max:a}=i??cn[r];return{id:e,type:"heatmap",beforeID:pn(t?.beforeLayerConfig?.heatmap),paint:{"heatmap-weight":["interpolate",["linear"],["get",r],o,0,a,1],"heatmap-intensity":["interpolate",["linear"],["zoom"],10,.5,14,2,16,4],"heatmap-color":mn(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]}}},Ln=(e,t,i)=>{const r=un(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:pn(t?.beforeLayerConfig?.hexgrid?.flat2D),paint:{"fill-color":yn(r,s?.color,i),"fill-opacity":.6}}},bn=(e,t,i)=>{const r=un(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:fn(t?.beforeLayerConfig?.hexgrid?.extrusion3D),paint:{"fill-extrusion-color":yn(r,s?.color,i),"fill-extrusion-height":gn(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},Sn=(e,t,i)=>{const r=un(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:pn(t?.beforeLayerConfig?.square?.flat2D),paint:{"fill-color":yn(r,s?.color,i),"fill-opacity":.6}}},In=(e,t,i)=>{const r=un(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:fn(t?.beforeLayerConfig?.square?.extrusion3D),paint:{"fill-extrusion-color":yn(r,s?.color,i),"fill-extrusion-height":gn(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},An=e=>({...on.regionPolygon,...e}),En=(e,t,i)=>{const{color:r,fillOpacity:s}=An(t?.regionPolygon);return{id:e,type:"fill",beforeID:pn(),paint:{"fill-color":r??nn(i),"fill-opacity":s}}},Rn=(e,t,i)=>{const{color:r,outlineOpacity:s,outlineWidth:o}=An(t?.regionPolygon);return{id:e,type:"line",beforeID:pn(),paint:{"line-color":r??nn(i),"line-opacity":s,"line-width":o}}},Tn=(e,t)=>({id:e,type:"line",beforeID:t,filter:["has","eventState"],paint:{"line-color":an,"line-width":["case",gi,3,2],"line-opacity":["case",gi,1,.8]}}),vn=e=>({...e,filter:["has","eventState"],paint:{...e.paint,"fill-extrusion-color":["case",gi,an,an],"fill-extrusion-height":["+",e.paint?.["fill-extrusion-height"],.5],"fill-extrusion-opacity":.6}}),wn=(e,t,i)=>vn(bn(e,t,i)),Cn=(e,t,i)=>vn(In(e,t,i)),On=(e,t,i)=>((e,t,i)=>{const r=[];for(let s=0;s<e.length;s++){const o=e[s];if(!o)continue;const{congestionSum:a,speedSum:n,freeFlowSum:l,travelTimeSum:c,networkLengthSum:h,count:u}=o,d=`${i}-${s}`;r.push({type:"Feature",id:d,geometry:t.features[s].geometry,properties:{id:d,congestionLevel:Math.round(a/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(A(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),Nn=.005,Mn=(e,t,i,r)=>{const s=[];for(let o=0;o<e.features.length;o++){const a=e.features[o],n=a.properties?.tiledData?.tiles??[];if(0===n.length)continue;const l=u(a);if(!l)continue;const c=i([l[0]-Nn,l[1]-Nn,l[2]+Nn,l[3]+Nn],t);s.push(...On(n,c,`${r}-${o}`))}return{type:"FeatureCollection",features:s}},xn=class e extends ze{static async create(t,i){return await Te(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}`,o=`area-analytics-square-${i}`,a=`area-analytics-region-${i}`,n=`${r}-layer`,l=`${s}-fill`,c=`${s}-extrusion`,h=`${s}-outline`,u=`${s}-extrusion-highlight`,d=`${o}-fill`,p=`${o}-extrusion`,f=`${o}-outline`,y=`${o}-extrusion-highlight`,m=`${a}-fill`,g=`${a}-line`,_=this.lightDark;this.heatmapLayerSpec=_n(n,e),this.hexFillLayerSpec=Ln(l,e),this.hexExtrusionLayerSpec=bn(c,e),this.squareFillLayerSpec=Sn(d,e),this.squareExtrusionLayerSpec=In(p,e),this.regionFillLayerSpec=En(m,e,_),this.regionLineLayerSpec=Rn(g,e,_),this.hexOutlineLayerSpec=((e,t)=>Tn(e,pn(t?.beforeLayerConfig?.hexgrid?.flat2D)))(h,e),this.hexExtrusionHighlightLayerSpec=wn(u,e),this.squareOutlineLayerSpec=((e,t)=>Tn(e,pn(t?.beforeLayerConfig?.square?.flat2D)))(f,e),this.squareExtrusionHighlightLayerSpec=Cn(y,e);const L={heatmap:new ot(this.mapLibreMap,r,[this.heatmapLayerSpec]),hexgrid:new ot(this.mapLibreMap,s,[this.hexFillLayerSpec,this.hexExtrusionLayerSpec]),square:new ot(this.mapLibreMap,o,[this.squareFillLayerSpec,this.squareExtrusionLayerSpec]),region:new ot(this.mapLibreMap,a,[this.regionFillLayerSpec,this.regionLineLayerSpec])};return this.addHighlightLayersToMap(s,o),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(on.metricConfig),r=Object.fromEntries(i.map(e=>[e,t?.[e]??on.metricConfig[e]])),s={activeMetric:on.activeMetric,displayMode:on.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)=>Mn(e,t,(e,t)=>T(e,t,{units:"kilometers"}),"hex"))(e),{automaticVisibility:!1}),this.sourcesWithLayers.square.show(((e,t=.5)=>Mn(e,t,(e,t)=>w(e,t,{units:"kilometers"}),"square"))(e),{automaticVisibility:!1});const t=this.config?.regionPolygon?.inverted??on.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(on.metricConfig),r=t??i,s={...this.config?.metricConfig};if(void 0===e)for(const o of r){const{color:e,...t}=s[o]??{};s[o]=t}else if("string"==typeof e){const t=(e=>{const t=dn(e),i=e=>{const{min:i,max:r}=cn[e],s=hn(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 o of r)s[o]={...s[o],color:e};this.config={...this.config,metricConfig:s},this.applyLayerConfig(this.config),this.emitConfigChange()}setHeight(e,t){const i=Object.keys(on.metricConfig),r=t??i,s={...this.config?.metricConfig};for(const o of r)s[o]={...s[o],height:e};this.config={...this.config,metricConfig:s},this.applyLayerConfig(this.config),this.emitConfigChange()}filter(e,t){const i=Object.keys(on.metricConfig),r=t??i,s={...this.config?.metricConfig};for(const o of r)s[o]={...s[o],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??on.displayMode}get activeMetric(){return un(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},Ne(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=_n(this.heatmapLayerSpec.id,e,t),r=Ln(this.hexFillLayerSpec.id,e,t),s=bn(this.hexExtrusionLayerSpec.id,e,t),o=wn(this.hexExtrusionHighlightLayerSpec.id,e,t),a=Sn(this.squareFillLayerSpec.id,e,t),n=In(this.squareExtrusionLayerSpec.id,e,t),l=Cn(this.squareExtrusionHighlightLayerSpec.id,e,t);Ce(i,this.heatmapLayerSpec,this.mapLibreMap),Ce(r,this.hexFillLayerSpec,this.mapLibreMap),Ce(s,this.hexExtrusionLayerSpec,this.mapLibreMap),Ce(o,this.hexExtrusionHighlightLayerSpec,this.mapLibreMap),Ce(a,this.squareFillLayerSpec,this.mapLibreMap),Ce(n,this.squareExtrusionLayerSpec,this.mapLibreMap),Ce(l,this.squareExtrusionHighlightLayerSpec,this.mapLibreMap),this.heatmapLayerSpec=i,this.hexFillLayerSpec=r,this.hexExtrusionLayerSpec=s,this.hexExtrusionHighlightLayerSpec=o,this.squareFillLayerSpec=a,this.squareExtrusionLayerSpec=n,this.squareExtrusionHighlightLayerSpec=l,this.applyFiltersToLayers()}applyRegionConfig(e){const t=this.lightDark,i=En(this.regionFillLayerSpec.id,e,t),r=Rn(this.regionLineLayerSpec.id,e,t);if(Ce(i,this.regionFillLayerSpec,this.mapLibreMap),Ce(r,this.regionLineLayerSpec,this.mapLibreMap),this.regionFillLayerSpec=i,this.regionLineLayerSpec=r,this.lastAnalytics){const t=e?.regionPolygon?.inverted??on.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 o of i)this.mapLibreMap.setFilter(o,s)}buildRegionFC(e,t){return{type:"FeatureCollection",features:e.map((e,i)=>{const r=`traffic-area-analytics-region-${i}`,s=t?v(e).geometry:e.geometry;return{...e,id:r,geometry:s,properties:{id:r}}})}}},Dn=e=>e.length?1===e.length?e[0]:["all",...e]:null,Fn=(e,t)=>{e&&t.push(e)},Pn=(e,t,i)=>{e&&Fn(K(t,e),i)},Un=(e,t)=>{Pn(e.roadCategories,"road_category",t),Pn(e.roadSubCategories,"road_subcategory",t)},kn=e=>{const t=[];if(Un(e,t),e.incidentCategories){const i=K("icon_category_0",e.incidentCategories,e=>ie[e]);Fn(i,t)}if(e.magnitudes){const i=K("magnitude_of_delay",e.magnitudes,e=>_.indexOf(e));Fn(i,t)}return e.delays&&Fn((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 Dn(t)})(e.delays),t),Dn(t)},Hn=e=>{if(!e?.any?.length)return null;const t=e.any.map(kn).filter(e=>!i(e));return j(t)},Wn=e=>{const t=[];if(Un(e,t),e.showRoadClosures){const i="only"===e.showRoadClosures?"==":"!=";t.push([i,["get","road_closure"],!0])}return Dn(t)},Bn=(e,t,i,r)=>{for(const s of t)i.setClause(s.id,r,e)},Gn="traffic.flow",Vn=class e extends $e{static async get(t,i){return await Te(t),await Fe(t,wt,"trafficFlow"),Ot(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(wt);if(!t)throw Le(`init ${e.name} with source ID ${wt}`);return{trafficFlow:new it(this.mapLibreMap,t)}}_applyConfig(e){return this._setVisible(e?.visible??!1,!1),this._filter(e?.filters,!1),e}getLayers(){return tt(this.tomtomMap.mapLibreMap,[wt])}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(Wn).filter(e=>!i(e));return j(t)})(e);t&&Bn(t,this.getLayers(),this.filterComposer,Gn)}else this.config?.filters?.any?.length&&Bn(void 0,this.getLayers(),this.filterComposer,Gn);t&&(this.config=o({...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(ee)}}get events(){return this.moduleEvents(["trafficFlow"],{mapping:ee})}},zn="tt-traffic-incident-direction-chevron",$n='<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>',jn=["interpolate",["exponential",1.5],["zoom"],5,0,9,.96,13,2.1,19,10.8],Yn=["interpolate",["exponential",1.5],["zoom"],5,.75,9,1.96,13,3.6,19,13.8],Kn=e=>["match",["get","magnitudeOfDelay"],"unknown",e.unknown,"minor",e.minor,"moderate",e.moderate,"major",e.major,"indefinite",e.indefinite,e.major],qn=["match",["get","magnitudeOfDelay"],"unknown","traffic-incidents-no_delay-pattern","indefinite","traffic-incidents-road_closed-pattern",""],Zn=e=>"dark"===e?"#FFF":"#000",Xn=["interpolate",["exponential",1.5],["zoom"],5,2.2,9,4.6,13,8.3,19,26],Jn=["case",["==",["feature-state","focused"],!0],1,0],Qn=(e,t)=>{if(null===t)return e;const[i,r,s,...o]=e;return[i,r,s,...o.map((e,i)=>i%2==1?["case",["==",["feature-state","focused"],!0],e*t,e]:e)]},el=["in",["get","magnitudeOfDelay"],["literal",["minor","moderate","major"]]],tl=["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],il=(e,t,i,r)=>{const s=r?.widthScale??null,o=[];return null!==r&&o.push({id:`${e}-focus-halo`,type:"line",minzoom:6,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":r.outlineColor,"line-width":Xn,"line-blur":0,"line-opacity":Jn},beforeID:t}),o.push({id:`${e}-outline`,type:"line",minzoom:6,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":Kn(i.outline),"line-width":Qn(Yn,s)},beforeID:t},{id:`${e}-inner-solid`,type:"line",minzoom:6,filter:el,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":Kn(i.inner),"line-width":Qn(jn,s)},beforeID:t},{id:`${e}-inner-chevron`,type:"line",minzoom:12,filter:el,layout:{"line-cap":"butt","line-join":"round"},paint:{"line-pattern":zn,"line-width":Qn(jn,s)},beforeID:t},{id:`${e}-inner-pattern`,type:"line",minzoom:6,filter:tl,layout:{"line-cap":"round","line-join":"round"},paint:{"line-pattern":qn,"line-width":Qn(jn,s)},beforeID:t}),o},rl=["step",["zoom"],.7,14,.8,16,.9,18,1],sl=["step",["zoom"],12.6,14,14.4,16,16.2,18,18],ol=["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",""],al=["all",["!=",["get","magnitudeOfDelay"],"indefinite"],["any",["!",["has","delayInSeconds"]],["step",["zoom"],[">",["get","delayInSeconds"],900],14,[">",["get","delayInSeconds"],600],15,[">",["get","delayInSeconds"],300],16,!0]]],nl=["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]],ll=["==",["get","magnitudeOfDelay"],"indefinite"],cl=["concat","traffic-jam-",["get","magnitudeOfDelay"],["case",["<",["get","delayInSeconds"],600],"-small",["<",["get","delayInSeconds"],3600],"-medium","-large"]],hl=["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"]],ul=["case",["has","delayInSeconds"],["*",-1,["get","delayInSeconds"]],0],dl=(e,t)=>[{id:`${e}-incident-marker`,type:"symbol",minzoom:13,filter:al,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":ol,"icon-size":rl,"symbol-sort-key":ul},beforeID:t},{id:`${e}-jam-marker`,type:"symbol",minzoom:12,filter:nl,layout:{"symbol-placement":"point","icon-anchor":"bottom-left","icon-offset":[2,3],"icon-image":cl,"icon-size":rl,"icon-padding":0,"text-anchor":"bottom-left","text-field":hl,"text-font":["NotoSans-CondensedBold"],"text-offset":[2.7,-.75],"text-size":sl,"symbol-sort-key":ul},paint:{"text-color":"hsl(210, 30%, 14%)"},beforeID:t},{id:`${e}-closed-road-marker`,type:"symbol",minzoom:12,filter:ll,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":"traffic-incidents-road_closed","icon-size":rl},beforeID:t}],pl=["unknown","minor","moderate","major","indefinite"],fl={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"}},yl={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%)"},ml={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%)"},gl=(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)},_l=e=>{if("top"!==e)return e?At[e]:At.lowestLabel},Ll=class e extends ze{static async create(t,i){return await Te(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(Ie())return $o||($o=Ae(Ee($n))),$o})();s&&Pe("if-not-in-sprite",zn,s,this.mapLibreMap);const o=_l(e?.beforeLayerConfig),a=(e=>{const t=e.getStyle()?.layers??[],i=/* @__PURE__ */new Map;for(const o of t)i.set(o.id,o);const r={outline:{...yl},inner:{...ml}},s=[];for(const o of pl){const e=fl[o],t=gl(i.get(e.outline),e.outline,s),a=gl(i.get(e.inner),e.inner,s);t&&(r.outline[o]=t),a&&(r.inner[o]=a)}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??Zn(t),widthScale:e?.widthScale??1.6})(e?.focus,r),l=[...il(i,o,a,n),...dl(i,o)];return{incidents:new ot(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=_l(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})}},bl="traffic.incidents",Sl=class t extends $e{static async get(e,i){return await Te(e),await Fe(e,vt,"trafficIncidents"),Ot(e,t,()=>new t(e,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const e=this.mapLibreMap.getSource(vt);if(!e)throw Le(`init ${t.name} with source ID ${vt}`);return{trafficIncidents:new it(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=Hn(e);if(i){const e=t?this.getNonSymbolLayers():this.getLayers();Bn(i,e,this.filterComposer,bl)}}else this.config?.filters?.any?.length&&Bn(void 0,this.getLayers(),this.filterComposer,bl);if(t?.any?.length){const e=Hn(t);e&&Bn(e,this.getSymbolLayers(),this.filterComposer,bl)}}r&&(this.config=o({...this.config,filters:e,icons:{...this.config?.icons,filters:t}},i),this.emitConfigChange())}getLayers(){return tt(this.tomtomMap.mapLibreMap,[vt])}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={...o({...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(re)}}get events(){return this.moduleEvents(["trafficIncidents"],{mapping:re})}},Il=["motorway","motorway_link","trunk","trunk_link","primary","primary_link","secondary","secondary_link","tertiary","tertiary_link","street","service","track"],Al=["unclassified","residential","living_street"],El=["parking","driveway","alley"],Rl=(e,t)=>({left:e.left-t.left,top:e.top-t.top,right:e.right-t.left,bottom:e.bottom-t.top}),Tl=(e,t,i)=>e.right<=0||e.left>=t||e.bottom<=0||e.top>=i,vl=(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)},wl=(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)},Cl=(e,t,i,r,s)=>{const o=((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),a=e.left<=0&&e.right>=i,n=e.top<=0&&e.bottom>=r;if(a&&!n)return void vl(o,t,r,s);if(n&&!a)return void wl(o,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 o=e.left,a=i-e.right,n=e.top,l=r-e.bottom,c=Math.min(o,a,n,l);c===o?t.left=Math.max(t.left,e.right+s):c===a?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)})(o,t,i,r,s):wl(o,t,i,s):vl(o,t,r,s)},Ol=e=>"string"==typeof e?document.querySelector(e):e,Nl=e=>"mapLibreMap"in e?e.mapLibreMap:e,Ml=(e,t,i)=>{const r=Nl(e).getContainer().getBoundingClientRect(),{width:s,height:o}=r,a={left:i,top:i,right:s-i,bottom:o-i};for(const n of t){const e=Ol(n);if(!e)continue;const t=e.getBoundingClientRect(),l=Rl(t,r);Tl(l,s,o)||Cl(l,a,s,o,i)}return a.left>=a.right||a.top>=a.bottom?null:{visibleAreaBounds:a,mapWidthPX:s,mapHeightPX:o}},xl=e=>{const{map:t,surroundingElements:i,paddingPX:r=0}=e,s=Ml(t,i,r);if(!s)return null;const{visibleAreaBounds:o}=s,a=Nl(t),n=a.unproject([o.left,o.bottom]),l=a.unproject([o.right,o.top]);return[n.lng,n.lat,l.lng,l.lat]},Dl=e=>{const{map:t,surroundingElements:i}=e,r=xl({map:t,surroundingElements:i});if(!r)return null;const[s,o,a,n]=r;return[(s+a)/2,(o+n)/2]},Fl=e=>{const{map:t,toBeContainedBBox:i,surroundingElements:r,paddingPX:s=0}=e,o=Ml(t,r,s);if(!o)return null;const{visibleAreaBounds:a,mapWidthPX:n,mapHeightPX:l}=o,c=a.left/n,h=a.right/n,u=a.top/l,d=h-c,p=a.bottom/l-u,[f,y,m,g]=i,_=(m-f)/d,L=(g-y)/p,b=f-c*_,S=g+u*L;return[b,S-L,b+_,S]};export{ze as AbstractDataOwnedMapModule,Ve as AbstractMapModule,et as AbstractSourceWithLayers,$e as AbstractStyleOwnedMapModule,rt as AddedSourceWithLayers,Tt as BASE_MAP_SOURCE_ID,lr as BaseMapModule,D as CombinedEvents,hr as CustomGeoJSONModule,Fr as DEFAULT_STYLE_VERSION,Lt as DEFAULT_TEXT_SIZE,$r as DESELECTED_FOREGROUND_COLOR,jr as DESELECTED_OUTLINE_COLOR,Zr as DESELECTED_ROUTE_FILTER,Yr as DESELECTED_SECONDARY_COLOR,dt as EventsProxy,Co as FINISH_INDEX,ot as GeoJSONSourceWithLayers,Er as GeometriesModule,Rt as HILLSHADE_SOURCE_ID,Nr as HillshadeModule,gs as INDEFINITE_DELAY_DASH_COLOR,X as LayerFilterComposer,hs as MAJOR_DELAY_COLOR,yt as MAP_BOLD_FONT,_t as MAP_ITALIC_FONT,gt as MAP_MEDIUM_FONT,mt as MAP_REGULAR_FONT,wo as MIDDLE_INDEX,ds as MINOR_DELAY_COLOR,ps as MINOR_DELAY_LABEL_COLOR,us as MODERATE_DELAY_COLOR,J as ModuleEvents,Et as POI_SOURCE_ID,Ji as POIsModule,ji as PlacesModule,Vr as ROUTE_LINE_FOREGROUND_COLOR,Kr as ROUTE_LINE_FOREGROUND_WIDTH,zr as ROUTE_LINE_OUTLINE_COLOR,Xr as ROUTE_LINE_OUTLINE_WIDTH,_a as RoutingModule,qr as SELECTED_ROUTE_FILTER,vo as START_INDEX,Oo as STOP_DISPLAY_INDEX,it as StyleSourceWithLayers,Ka as StylingModule,wt as TRAFFIC_FLOW_SOURCE_ID,vt as TRAFFIC_INCIDENTS_SOURCE_ID,sn as TomTomMap,Qe as TomTomMapSource,xn as TrafficAreaAnalyticsModule,Vn as TrafficFlowModule,Ll as TrafficIncidentOverlayModule,Sl as TrafficIncidentsModule,ys as UNKNOWN_DELAY_BG_COLOR,fs as UNKNOWN_DELAY_COLOR,ms as UNKNOWN_DELAY_DASH_COLOR,Ge as UserEvents,Sr as adaptPaletteForTheme,H as assertNoReservedScopeNames,rr as baseMapLayerGroupNames,Ft as baseMapPOICategoryValues,Ks as bespokeSectionTypes,Pi as buildPlaceTitle,Tr as buildReachableRangeFeatures,Go as buildRoutingLayers,Fl as calculateFittingBBox,xl as calculatePaddedBBox,Dl as calculatePaddedCenter,br as colorPaletteIDs,Lr as colorPalettes,P as combineEventScopes,Vo as defaultRoutingLayers,qs as drawnSectionTypes,tt as filterLayersBySources,Ke as findFeatureByRefId,Ys as generatedSectionTypes,Or as geometryThemes,ki as getIconIDForPlace,ls as getInstructionLineWidth,cs as getInstructionOutlineWidth,ts as getLineForegroundWidth,is as getLineOutlineWidth,Bi as getPOIGroupForPlace,Wi as getPOILayerCategoryForPlace,os as getSectionHaloWidth,Zi as getStyleCategories,rs as getWaypointIconSize,pt as knob,ft as knobSettings,Mt as mapDisplayPoiCategoryMappings,bt as mapFonts,At as mapStyleLayerIDs,Yi as placesThemes,Ki as poiCategoryGroups,Nt as poiLayerIDs,$i as preparePlacesForDisplay,vr as prepareReachableRangesForDisplay,Cr as reachableRangeGeometryConfig,Ye as renderedRefId,k as reservedScopeNames,dn as resolveColorStops,Il as roadCategories,U as scopedLayerSpecs,eo as sectionDrawsByDefault,io as sectionSourceKey,Js as sectionSupportsKnob,El as serviceRoadSubCategories,Ot as sharedInstance,Mr as standardStyleIDs,Al as streetRoadSubCategories,xr as styleModules,rn as stylingKnobAppliesTo,Da as stylingKnobIds,tn as stylingKnobKinds,wr as themedGeometryConfig,Dt as toBaseMapPOICategory,Ut as toBaseMapPOIGroup,Gi as toPlaces};
1
+ import{isEmpty as e,isEqual as t,isNil as i,mapValues as r,omit as s,omitBy as o,remove as a}from"lodash-es";import{DEFAULT_COMMON_BASE_URL as n,MILE_IN_METERS as l,TomTomConfig as c,bboxCenter as h,bboxFromCoordsArray as u,bboxFromGeoJSON as d,formatDistance as p,formatDuration as y,generateId as f,generateTomTomHeaders as m,getPosition as g,iconToTrafficIncidentCategory as _,indexedMagnitudes as b,isProxyCredentialsMode as L,mergeFromGlobal as S,poiCategoriesToID as I,trafficIncidentToIconCategory as A}from"@tomtom-org/maps-sdk/core";import{bearing as E,booleanPointInPolygon as R,difference as v,featureCollection as T,hexGrid as w,mask as C,squareGrid as O}from"@turf/turf";import{Map as M,getRTLTextPluginStatus as N,getVersion as x,setRTLTextPlugin as D,setWorkerCount as F}from"maplibre-gl";var k=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)}},P=(e,t)=>e?t?(...i)=>e(...i)&&t(...i):e:t,U=(e,t)=>{if(!e)return t;if(!t)return e;const i=P(e.layerFilter,t.layerFilter),r=P(e.featureMatches,t.featureMatches);return i||r?{layerFilter:i,featureMatches:r}:void 0},H=(e,t)=>t?.layerFilter?e._layerSpecs.filter(t.layerFilter):e._layerSpecs,W=["on","off","where"],G=(e,t)=>{const i=e.find(e=>W.includes(e));if(i)throw new Error(`${t} uses the reserved event scope name "${i}". Reserved: ${W.join(", ")}.`)},B=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(!B(t)&&"boolean"!=typeof t)return!1;return!0;default:return!0}},V=e=>"$type"===e?["geometry-type"]:"$id"===e?["id"]:["get",e],z=e=>"$type"===e||("$id"===e?["!=",["id"],null]:["has",e]),j=(e,t)=>!!t.length&&["in",V(e),["literal",t]],$=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 z(i);case"!has":return["!",z(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,V(i),r[0]];case">":case">=":case"<":case"<=":return((e,t,i)=>["all",["==",["typeof",V(t)],typeof i],[e,V(t),i]])(t,i,r[0]);case"in":return j(i,r);case"!in":return["!",j(i,r)];case"all":return["all",...s.map(e=>K(e))];case"any":return["any",...s.map(e=>K(e))];case"none":return["!",["any",...s.map(e=>K(e))]];default:return!0}},K=e=>B(e)?e:$(e),Y=e=>e?.length?1===e.length?e[0]:["any",...e]:null,q=(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]},Z=(e,t,i)=>q(e,t.show,i?t.values.map(i):t.values),X=/* @__PURE__ */new WeakMap,J=(e,t,i)=>{void 0!==i?e.set(t,i):e.delete(t)},Q=class e{constructor(e){this.byLayer=/* @__PURE__ */new Map,this.mapLibreMap=e.mapLibreMap,e.addStyleChangeHandler({onStyleAboutToChange:()=>this.byLayer.clear(),priority:Number.NEGATIVE_INFINITY})}static for(t){let i=X.get(t);return i||(i=new e(t),X.set(t,i)),i}setTransform(e,t,i){this.contribute(e,({transforms:e})=>J(e,t,i))}setClause(e,t,i){this.contribute(e,({clauses:e})=>J(e,t,i))}contribute(e,t){if(!this.mapLibreMap.getLayer(e))return;let i=this.byLayer.get(e);i||(i={styleFilter:this.mapLibreMap.getFilter(e),transforms:/* @__PURE__ */new Map,clauses:/* @__PURE__ */new Map},this.byLayer.set(e,i)),t(i),this.apply(e,i)}apply(e,t){const i=[...t.transforms.values()].reduce((e,t)=>t(e),t.styleFilter),r=((e,t)=>{if(!t.length)return e;const i=null==e?t:[...t,K(e)];return 1===i.length?i[0]:["all",...i]})(i,[...t.clauses.values()]);this.mapLibreMap.setFilter(e,r??null,{validate:!1})}},ee=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}},te=["road_category","road_subcategory","relative_speed","left_hand_traffic","road_closure","absolute_speed","part_of_two_way_road","openlr","display_class"],ie=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}}}},re=["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"],se=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:_(t?.icon_category_0),magnitudeOfDelay:b[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}}}},oe=e=>{const t=e%360;return t<0?t+360:t},ae=(e,t,i)=>Math.min(Math.max(t,e),i),ne=e=>!e.some(Number.isNaN),le=e=>Number.parseInt(e.padEnd(2,e),16)/255,ce=(e,t)=>ae(t?e/100:e,0,1),he=/^rgba?\(\s*([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s+|\s*(,)\s*)([\de.+-]+)(%)?(?:\s*([,/])\s*([\de.+-]+)(%)?)?\s*\)$/,ue=/^hsla?\(\s*([\de.+-]+)(?:deg)?(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s+|\s*(,)\s*)([\de.+-]+)%(?:\s*([,/])\s*([\de.+-]+)(%)?)?\s*\)$/,de=e=>{const t=ue.exec(e);if(!t)return;const[,i,r,s,o,a,n,l,c]=t,h=[r||" ",o||" ",n].join("");if(" "!==h&&" /"!==h&&",,"!==h&&",,,"!==h)return;const u=[+i,ae(+s,0,100),ae(+a,0,100),l?ce(+l,c):1];return ne(u)?(([e,t,i,r])=>{const s=oe(e),o=t/100,a=i/100,n=e=>{const t=(e+s/30)%12,i=o*Math.min(a,1-a);return a-i*Math.max(-1,Math.min(t-3,9-t,1))};return[n(0),n(8),n(4),r]})(u):void 0},pe=e=>{const t=e.toLowerCase().trim();if("transparent"===t)return[0,0,0,0];const i=Se[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[le(e.slice(1,1+t)),le(e.slice(1+t,1+2*t)),le(e.slice(1+2*t,1+3*t)),le(e.slice(1+3*t)||"ff")]})(t):t.startsWith("rgb")?(e=>{const t=he.exec(e);if(!t)return;const[,i,r,s,o,a,n,l,c,h,u,d]=t,p=[s||" ",n||" ",h].join("");if(" "!==p&&" /"!==p&&",,"!==p&&",,,"!==p)return;const y=[r,a,c].join(""),f="%%%"===y?100:""===y?255:0;if(!f)return;const m=[ae(+i/f,0,1),ae(+o/f,0,1),ae(+l/f,0,1),u?ce(+u,d):1];return ne(m)?m:void 0})(t):de(t)},ye=e=>{const t=pe(e);return t&&(([e,t,i,r])=>{const s=Math.max(e,t,i),o=Math.min(e,t,i),a=(s+o)/2,n=s-o;if(0===n)return[0,0,100*a,r];const l=n/(1-Math.abs(2*a-1));let c;return c=s===e?(t-i)/n%6:s===t?(i-e)/n+2:(e-t)/n+4,[oe(60*c),100*l,100*a,r]})(t)},fe=e=>"string"==typeof e&&void 0!==ye(e),me=(e,t)=>{const i=ye(e),r=ye(t);if(i&&r)return{hue:i[1]<1||r[1]<1?0:r[0]-i[0],saturation:r[1]-i[1],lightness:r[2]-i[2],alpha:r[3]-i[3]}},ge=(e,t)=>{const i=ye(e);if(i)return(([e,t,i,r])=>{const s=Math.round(oe(e)),o=Math.round(ae(t,0,100)),a=Math.round(ae(i,0,100));return r<1?`hsla(${s}, ${o}%, ${a}%, ${Math.round(100*r)/100})`:`hsl(${s}, ${o}%, ${a}%)`})([i[0]+t.hue,i[1]+t.saturation,i[2]+t.lightness,ae(i[3]+t.alpha,0,1)])},_e=e=>{const t=pe(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])},be=(e,t)=>{const i=pe(e);if(!i)return;const r=1-t;return Le(i.slice(0,3).map(e=>255*e*r))},Le=e=>`#${e.map(e=>Math.round(ae(e,0,255)).toString(16).padStart(2,"0")).join("")}`,Se={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]},Ie=e=>/* @__PURE__ */new Error(`Trying to ${e} while it is not in the map style. Did you exclude it when loading the map?`),Ae="pinCategories",Ee=e=>`${Ae}:${e}`,Re=()=>"undefined"!=typeof document&&"undefined"!=typeof DOMParser&&"undefined"!=typeof btoa,ve=e=>{if(!Re())return;const t=document.createElement("img");return t.src=`data:image/svg+xml;base64,${btoa((new XMLSerializer).serializeToString(e))}`,t},Te=e=>(new DOMParser).parseFromString(e,"image/svg+xml").documentElement,we=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))(Te('<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),Ce=async e=>{e.mapReady||(await e.mapLibreMap.once("styledata"),await Ce(e))},Oe=e=>{const t=globalThis.__DEMOS_PROXY_ENSURE_SESSION__;return"function"!=typeof t?e:t().then(()=>e,()=>e)},Me=e=>{const t=e.commonBaseURL??n,i=t!==n,r=L(e);return(s,o)=>{const a=((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&&a.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:a};if("Image"===o)return l?Oe({url:a,credentials:"include"}):{url:a};const h=new URL(a);(e=>{e.pathname.includes("incidents")?e.searchParams.set("tags",re.join(",")):e.pathname.includes("flow")&&e.searchParams.set("tags",te.join(","))})(h);const u={url:h.toString(),headers:{...m(e)}};return l?(u.credentials="include",Oe(u)):u}},Ne=(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,o]of Object.entries(e.paint??{}))i.setPaintProperty(r,s,o,{validate:!1});for(const[s,o]of Object.entries(e.layout??{}))i.setLayoutProperty(r,s,o,{validate:!1})},xe=(e,t,i,r)=>{const s=e.reduce((e,t)=>({...e,[t.id]:t}),{}),o=t.reduce((e,t)=>({...e,[t.id]:t}),{}),a=[],n=[],l=[],c=[];Object.keys(s).forEach(e=>{o[e]?(l.push(s[e]),c.push(o[e])):a.push(e)}),Object.keys(o).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}});const u=a.map(e=>({...s[e],source:i.source.id}));u.length&&(h.push(...u),ke(u,r)),i._updateSourceAndLayerIDs(),((e,t,i,r)=>{const s=/* @__PURE__ */new Set,o=e=>{if(!r.getLayer(e.id))return;Fe(r,e.id,e.beforeID),s.add(e.id);const t=i.find(t=>t.id===e.id);t&&(t.beforeID=e.beforeID)};e.forEach((e,i)=>{e.beforeID!==t[i].beforeID&&o(e)});const a=()=>e.filter(e=>!s.has(e.id)&&void 0!==e.beforeID&&s.has(e.beforeID));for(let n=a();n.length;n=a())n.forEach(o)})(l,c,h,r),((e,t,i)=>{e.forEach((e,r)=>Ne(e,t[r],i))})(l,c,r)},De=(e,t)=>t&&e.getLayer(t)?t:void 0,Fe=(e,t,i)=>{e.moveLayer(t,De(e,i))},ke=(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]})}},Pe=(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)}},Ue=async(e,t,i)=>{if(!e.mapLibreMap.getSource(t)){const r=e.mapLibreMap;r.isStyleLoaded()||await r.once("idle"),await e.setStyle(Pe(e.getStyle(),i)),await(async(e,t)=>{e.mapLibreMap.getSource(t)&&e.mapLibreMap.isSourceLoaded(t)||await e.mapLibreMap.once("sourcedata")})(e,t)}},He=async(e,t,i,r,s)=>{if(!i)return void console.warn(`addOrUpdateImage called with empty image for ID ${t}`);const o=i=>{const o=r.hasImage(t);o&&"add-or-update"==e?r.updateImage(t,i):o||r.addImage(t,i,s)},a=e=>{e.complete?e.naturalWidth>0?o(e):console.warn(`Failed to load image for ID ${t}`):(e.onload=()=>o(e),e.onerror=()=>console.warn(`Failed to load image for ID ${t}`))};if("string"==typeof i)if(i.includes("<svg"))a(ve(Te(i)));else try{o((await r.loadImage(i)).data)}catch(n){console.warn(`Failed to load image for ID ${t}`,n)}else a(i)},We=e=>{switch(e){case"standardDark":case"drivingDark":case"monoDark":case"satellite":return"dark";default:return"light"}},Ge=e=>{if("string"==typeof e)return We(e);const t=Be(e);if(t)return t;const i=e;return i?.id?We(i.id):"light"},Be=e=>Ve(e)?e.lightDarkTheme:void 0,Ve=e=>"object"==typeof e&&"custom"===e?.type,ze=e=>{if("string"==typeof e)return void 0===_e(e)?void 0:e;if(Array.isArray(e))for(const t of e){const e=ze(t);if(e)return e}},je=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:U(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:o}=this.options,a=this.toRegisteredHandler(t),n=[];for(const l of this.sources)i.addEventHandler(l,a,e,{config:r,owner:s,scope:o}),n.push(l);return()=>{for(const t of n)i.removeHandler(t,e,a)}}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,o,a)=>{const n=(o.length?o:[t]).filter(e=>r(e));if(!n.length)return;const l=n.map(s);e(l[0],i,l,a)}:(t,i,r,o)=>e(s(t),i,r.map(s),o)}off(e){for(const t of this.sources)this.options.eventProxy.remove(t,e,this.options.owner)}},$e=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.filterComposer=Q.for(t),this.initSourcesWithLayers(i),this.applyConfig(i),this.tomtomMap.addStyleChangeHandler({onStyleAboutToChange:()=>{this.moduleReady=!1},onStyleChanged:({resetState:e})=>e?this.resetOnNewStyle():this.restoreDataAndConfig(),priority:this.styleChangePriority()}),this._initializing=!1}styleChangePriority(){return 0}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 Ce(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 je({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 k(this.userEvents(e,t),new ee(this.configChangeHandlers,[]))}moduleEventsWithShown(e,t,i={}){return new k(this.userEvents(e,i),new ee(this.configChangeHandlers,t))}buildEvents(e,t){return G(Object.keys(t),this.constructor.name),Object.assign(e,t)}},Ke=class extends $e{},Ye=class extends $e{},qe=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){a(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&&(a(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 o of Object.values(this.handlers[t]))for(const e of o)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(H(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 o of Object.values(this.handlers[r]))for(const r of o)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(H(e,t.scope).map(e=>e.id)),this.ensureInteractiveLayerIDsAdded(t.layerIDs),this.indexHandler(t,r)}this.releaseUnusedInteractiveLayerIDs(s)}}},Ze=e=>{const t=e.properties?.id;return"string"==typeof t||"number"==typeof t?t:e.id},Xe=(e,t)=>{if(null!=t)for(let i=0;i<e.length;i++)if(Ze(e[i])===t)return{feature:e[i],index:i}};var Je,Qe,et,tt=e=>(function(e){if(i(e))throw new Error(`${e} must not be null/undefined. Something went wrong with its initialization.`)}(e),e),it=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))}},rt=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}},st=(e,t)=>e.getStyle().layers.filter(e=>t.includes(e?.source)),ot=class extends rt{constructor(e,t,i){let r=st(e,[t.id]);i&&(r=r.filter(i)),super(e,new it(t.id,e.getStyle().sources[t.id],t),r)}},at=class extends rt{constructor(e,t,i,r){super(e,new it(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)))}},nt={type:"FeatureCollection",features:[]},lt=class extends at{constructor(e,t,i,r=!0,s){super(e,t,s?.cluster?{type:"geojson",data:nt,...s}:{type:"geojson",data:nt,promoteId:"id",...s??{}},i),this.shownFeatures=nt,this.ensureAddedToMapWithVisibility(!1,r)}show(e,{automaticVisibility:t=!0}={}){this.shownFeatures=e,this.mapRemoved||(tt(this.source.runtimeSource).setData(e),t&&this.setLayersVisible(!!e.features.length))}findById(e){return Xe(this.shownFeatures.features,e)}clear(){this.show(nt)}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})}},ct=e=>"click"===e||"contextmenu"===e,ht=(e,t,i,r="updateInProps")=>{const{feature:o,index:a}=Xe(i,t)||{};if(o&&(!ct(o.properties?.eventState)||ct(e))){const t={...o,properties:"updateInProps"===r?{...o?.properties,eventState:e}:s(o?.properties,"eventState")};return i.splice(a,1,t),a}},ut=(e,t,r)=>{const s=[...r.shownFeatures.features],o=ht(e,Ze(t),s,"removeFromProps");i(o)||r.show({...r.shownFeatures,features:s},{automaticVisibility:!1})},dt=(e,t,i,r,s)=>{if(t&&r instanceof lt){const n=[...r.shownFeatures.features];return ht(e,Ze(t),n),!i||(a=t,(o=i)&&a&&o.id===a.id)||(s===r?ht(e,Ze(i),n,"removeFromProps"):s instanceof lt&&ut(e,i,s)),void r.show({...r.shownFeatures,features:n},{automaticVisibility:!1})}var o,a;i&&s instanceof lt&&ut(e,i,s)},pt=[],yt={precisionMode:"box",paddingBoxPx:5,cursorOnHover:"pointer",cursorOnMouseDown:"grabbing",cursorOnMap:"default",longHoverDelayAfterMapMoveMS:800,longHoverDelayOnStillMapMS:300},ft=class extends qe{constructor(e,t={}){super(),this.enabled=!0,this.firstDelayedHoverSinceMapMove=!0,this.mouseMoveFrameRequested=!1,this.map=e,this.mapCanvas=e.getCanvas(),this.config={...yt,...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=Ze(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})((o=r,a=t?.source,a?o.filter(e=>e.source===a):o));var o,a;const n=this.sourceWithLayersFor(t?.layer.id);return n instanceof lt?s.map(e=>n.findById(Ze(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){dt("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??pt,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,o=this.hoveringSourceWithLayers;let a;this.hoveringLngLat=e.lngLat,this.hoveringPoint=e.point,this.hoveringFeature=t,this.hoveringSourceWithLayers=this.sourceWithLayersFor(t?.layer.id),i&&(a=this.dispatchHoverEnter(e,s,o)),r&&this.dispatchHoverMove(e,a),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),dt("hover",this.hoveringFeature,t,this.hoveringSourceWithLayers,i);const o=this.findHandlers(["hover"],r);if(!o.length)return;const a=this.toCallerFeatures(this.hoveringFeatures??pt,this.hoveringFeature);return this.dispatchToHandlers(o,e,this.hoveringFeature,a),a}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??pt,r);this.dispatchToHandlers(i,e,r,s)}dispatchToHandlers(e,t,i,r){for(const s of e){const e=this.callerFeaturesFor(s,this.hoveringFeatures??pt,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,o=this.findHandlers([e],this.lastClickedFeature?.layer.id);if(this.lastClickedSourceWithLayers=o[0]?.sourceWithLayers,dt(e,this.lastClickedFeature,r,this.lastClickedSourceWithLayers,s),o.length){const e=this.lastClickedFeature,r=this.toCallerFeatures(i,e);for(const s of o){const o=this.callerFeaturesFor(s,i,e,r);s.fn(o[0],t.lngLat,o,s.sourceWithLayers)}}}},mt=(e,t,i,r,s,o)=>({id:e,kind:t,description:i,default:r,current:s??r,overridden:void 0!==s,...o}),gt=e=>Object.fromEntries(e.filter(e=>e.overridden).map(e=>[e.id,e.current])),_t="Noto-Bold",bt="Noto-Regular",Lt="Noto-Medium",St="NotoSans-MediumItalic",It=["interpolate",["linear"],["zoom"],10,14,18,16],At=[bt,St,_t,Lt],Et=.8,Rt=["interpolate",["linear"],["zoom"],8,.6,22,Et],vt={country:"Places - Country name",lowestPlaceLabel:"Places - Village / Hamlet",poi:"POI",lowestLabel:"Borders - Treaty label",lowestRoadLine:"Tunnel - Railway outline",lowestBuilding:"Buildings - Underground"},Tt="vectorTiles",wt="hillshade",Ct="vectorTiles",Ot="vectorTilesIncidents",Mt="vectorTilesFlow",Nt=/* @__PURE__ */new WeakMap,xt=async(e,t,i,r)=>{let s=Nt.get(e);s||(s=/* @__PURE__ */new Map,Nt.set(e,s));const o=s.get(t);if(o){const e=await o;return r?.(e),e}const a=Promise.resolve().then(i);s.set(t,a);try{return await a}catch(n){throw s.delete(t),n}},Dt=["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"},kt={...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"},Pt=e=>kt[e],Ut=Array.from(new Set(Object.values(kt))),Ht={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"},Wt=e=>{const t=Pt(e);return t?Ht[t]:void 0},Gt="title",Bt="iconID",Vt=.7,zt="default_place",jt="poi-parking-micro",$t={"icon-image":["get",Bt],"icon-anchor":"bottom","icon-size":Rt,"icon-allow-overlap":!0,"icon-padding":0},Kt={"icon-translate":[0,5],"icon-translate-anchor":"viewport"},Yt={"text-optional":!0,"text-font":[_t],"text-field":["get",Gt],"text-justify":"auto","text-variable-anchor":["top","left","right"],"text-variable-anchor-offset":["top",[0,Vt],"left",[1.4,-1.4],"right",[-1.4,-1.4]],"text-size":It,"text-padding":5},qt={"text-halo-width":["interpolate",["linear"],["zoom"],6,1,10,1.5],"text-translate-anchor":"viewport"},Zt={type:"symbol",layout:{...$t,...Yt},paint:{...Kt,...qt}},Xt=(e,t)=>`${e}-${t}`,Jt=(e,t)=>t?`${t}-${e}`:e,Qt=["has","point_count"],ei=["!",Qt],ti="clusterBaseMapIconIDs",ii=["all",Qt,["==",["index-of",",",["get",ti]],-1]],ri=["all",Qt,[">=",["index-of",",",["get",ti]],0]],si=[12,-14],oi={[ti]:(Je="baseMapIconID",Qe=ti,[["case",["==",["get",Qe],null],["accumulated"],["==",["accumulated"],null],["get",Qe],[">=",["index-of",["concat",",",["get",Qe],","],["concat",",",["accumulated"],","]],0],["accumulated"],["concat",["accumulated"],",",["get",Qe]]],["get",Je]])},ai=e=>{const t=["match",e];for(const i of Ut){const e=`poi-${i}`;t.push(e,["image",e])}return t.push(["image",jt]),t},ni=(e,t)=>{if(!e)return;const i=(e=>{try{if("string"==typeof e){if(e.includes("<svg")){const t=Te(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,o=r?54:120;return{heightScale:i.height/s,widthScale:i.width/o}},li=e=>{const t=["case"];for(const[i,r]of e)0===r.x&&0===r.y||t.push(["==",["get",Bt],i],["literal",[r.x,r.y]]);if(1!==t.length)return t.push(["literal",[0,0]]),t},ci=e=>Boolean(e&&"availability"in e&&e.availability),hi=e=>"ELECTRIC_VEHICLE_STATION"===e.properties.poi?.categories?.[0]&&ci(e.properties.chargingPark),ui=e=>{const t=e.properties.chargingPark;if(ci(t)){const e=t.availability.chargingPointAvailability,i=e.statusCounts.Available??0;return{availableCount:i,totalCount:e.count,ratio:i/e.count}}},di=(e,t)=>`${e}/${t}`,pi=e=>ui(e)?.ratio??0,yi=e=>["case",[">=",["get","evAvailabilityRatio"],e?.threshold??0],"green","red"],fi=e=>Math.round(1e4*e)/1e4,mi=(e,t,i,r)=>{const s=void 0!==r;return{top:s?[0,r]:[0,fi(e)],left:s?[r,fi(i)]:[fi(t),fi(i)],right:s?[-r,fi(i)]:[-fi(t),fi(i)]}},gi=(e,t,i,r)=>{const s=(e=>{if(!e)return Et;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 Et})(e)/Et,o="base-map"===i||"circle-icon"===i;if(o&&void 0!==r)return{"text-offset":[r,r]};const a=1.4*s,n=mi(Vt*s,a,o?0:-a,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=(o?1.4:Vt)*u.heightScale*s,t=1.4*u.widthScale*s,i=mi(e,t,o?0:-t,r);c.push(["==",["get",Bt],h],["literal",["top",i.top,"left",i.left,"right",i.right]])}return c.push(["literal",l]),{"text-variable-anchor-offset":c}},_i=(e,t,i,r,s)=>{const o=t?.text,a=t?.layers?.[i],n=s&&s.size>0,l={...e.layout},c=n||void 0!==o?.offset||"circle-icon"===t?.theme;c&&(delete l["text-offset"],delete l["text-variable-anchor-offset"],delete l["text-radial-offset"]);const h={...l,...a?.layout,...o?.size&&{"text-size":o.size},...o?.font&&{"text-font":o.font},...void 0!==r&&{"text-field":r}};if(c){const e={...h,...gi(h["icon-size"],s??/* @__PURE__ */new Map,t?.theme,o?.offset)},r="micro"!==i&&s&&li([...s].map(([e,{offset:t}])=>[e,t]));return r?{...e,"icon-offset":r}:e}return h},bi=(e,t,i,r)=>{const s=t?.text,o=t?.layers?.[i],{textColor:a,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":a},...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},...o?.paint}},Li=["in",["get","eventState"],["literal",["click","contextmenu"]]],Si=e=>JSON.parse(JSON.stringify(e)?.replaceAll("name",Gt)),Ii=(e,t)=>e.getStyle().layers.find(e=>e.id===t)??{},Ai=e=>({filter:["!",Li],type:"symbol",paint:e.paint,layout:e.layout?s(e.layout,"visibility"):void 0}),Ei=e=>{const t=Ai(Ii(e,"POI")),i=t.layout?.["text-size"];return{...t,layout:{...t.layout,"icon-image":["get",Bt],"text-field":["get",Gt],...i&&{"text-size":Si(i)}}}},Ri=e=>{const t=Ai(Ii(e,"POI - Micro"));return{...t,minzoom:0,layout:{...t.layout,"icon-allow-overlap":!0,"icon-ignore-placement":!0},paint:{...t.paint,"icon-opacity":1}}},vi=e=>{const t=Ii(e,"POI").layout??{};return{...Zt,layout:{...Zt.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:{...Zt.paint,"icon-translate":[0,0]}}},Ti=["has","eventState"],wi={type:"symbol",layout:{visibility:"none"}},Ci={type:"circle",layout:{visibility:"none"}},Oi="#3f9cd9",Mi={...Zt,filter:["!",Ti]},Ni={...Zt,filter:Ti,layout:{...Zt.layout,"icon-size":["interpolate",["linear"],["zoom"],8,.8,22,1],"text-allow-overlap":!0},paint:{...Zt.paint,"text-color":Oi}},xi=e=>({...e,filter:Ti,layout:{...e.layout,"text-allow-overlap":!0},paint:{...e.paint,"text-color":Oi}}),Di=(e,t,i,r,s)=>{const o=t?.text,a=t?.layers?.[i],n=!0===t?.evAvailability?.enabled,l=o?.title&&"function"!=typeof o?.title?o.title:n?((e,t)=>t?["case",["has","evAvailabilityText"],["format",["get",Gt],{},"\n",{},["get","evAvailabilityText"],{"font-scale":1.1,"text-color":yi(e?.evAvailability)}],["get",Gt]]:["get",Gt])(t,n):void 0;return{...e,...a,layout:_i(e,t,i,l,s),paint:bi(e,t,i,r)}},Fi=(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=ni(s.image,e?.theme),o=void 0!==s.offsetX||void 0!==s.offsetY;if(void 0===r&&!o)continue;const a={heightScale:r?.heightScale??1,widthScale:r?.widthScale??1,offset:{x:s.offsetX??0,y:s.offsetY??0}},n=Xt(s.id,t);if(i.set(n,a),s.availabilityLevel){const e=Xt(`${s.id}-${s.availabilityLevel}`,t);i.set(e,a)}}return i})(e,r);let o,a,n=wi,l=wi,c=Ci,h=wi,u=Ci,d=wi;if("base-map"===e?.theme)o={...Ei(t),minzoom:10},n=Ri(t),a=(e=>xi(Ei(e)))(t);else if("circle-icon"===e?.theme)o=(e=>({...vi(e),filter:["!",Ti]}))(t),a=(e=>xi(vi(e)))(t);else if("pin-clustered"===e?.theme){o={...Mi,filter:["all",ei,["!",Ti]]},a={...Ni,filter:["all",ei,Ti]};const e=Ri(t);n={...e,filter:e.filter?["all",ei,e.filter]:ei},l={type:"symbol",filter:ii,layout:{"icon-image":ai(["get",ti]),"icon-size":1,"icon-allow-overlap":!0,"icon-ignore-placement":!0}},c={type:"circle",filter:ii,paint:{"circle-radius":11,"circle-color":"#000000","circle-stroke-color":"#FFFFFF","circle-stroke-width":1.5,"circle-translate":si,"circle-translate-anchor":"viewport"}},h={type:"symbol",filter:ii,layout:{"text-field":["get","point_count_abbreviated"],"text-font":[_t],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#FFFFFF","text-translate":si,"text-translate-anchor":"viewport"}},u={type:"circle",filter:ri,paint:{"circle-radius":15,"circle-color":"#000000","circle-stroke-color":"#FFFFFF","circle-stroke-width":1.5}},d={type:"symbol",filter:ri,layout:{"text-field":["get","point_count_abbreviated"],"text-font":[_t],"text-size":12,"text-allow-overlap":!0,"text-ignore-placement":!0},paint:{"text-color":"#FFFFFF"}}}else o=Mi,a=Ni;return{micro:{...Di(n,e,"micro",i,s),beforeID:vt.lowestPlaceLabel},main:{...Di(o,e,"main",i,s),beforeID:"selected"},selected:Di(a,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}},ki=e=>{if(Re())return ve(we(e))},Pi=(e,t)=>"string"!=typeof e?e:t.features.find(t=>t.id===e),Ui=/* @__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]),Hi=e=>e.properties.poi?.name??e.properties.address.freeformAddress,Wi=(e,t,i)=>{if("pin"===t||"pin-clustered"===t)return(e=>{if(e)return Ui.has(e)?Ee(e.toString()):Ee(e.toString().substring(0,4))})(I[e])??i;{const t=Pt(e);return t?`poi-${t}`:i}},Gi=(e,t,i={})=>{const r=i.theme??"pin",s=((e,t)=>e.icon?.default||"base-map"!==(e.theme??"pin")?Xt(zt,t):jt)(i,t),o=i.icon?.mapping;if(o)return"imageID"===o.to?o.fn(e):Wi(o.fn(e),r,s);const a=e.properties.poi?.categories?.[0],n=((e,t,i,r,s)=>{if(!r.evAvailability?.enabled||!hi(e))return;const o=pi(e)>=(r.evAvailability.threshold??.3)?"available":"occupied",a=r.icon?.categoryIcons&&r.icon.categoryIcons.length>0,n=r.icon?.categoryIcons?.find(e=>e.id===t&&e.availabilityLevel===o);return n?Xt(`${n.id}-${o}`,i):a||"pin"!==s?void 0:Ee(`7309-${o}`)})(e,a,t,i,r);if(n)return n;const l=i.icon?.categoryIcons?.find(e=>e.id===a);return l?Xt(l.id,t):Wi(a,r,s)},Bi=(e,t)=>{const i=t?.icon?.mapping;return"poiCategory"===i?.to?i.fn(e):e.properties.poi?.categories?.[0]},Vi=(e,t)=>{const i=Bi(e,t);return i&&Pt(i)},zi=(e,t)=>{const i=Bi(e,t);return i&&Wt(i)},ji=e=>Array.isArray(e)?{type:"FeatureCollection",features:e}:"Feature"===e.type?{type:"FeatureCollection",features:[e]}:e,$i=(e,t,i)=>{if(!0!==t?.enabled)return e;let r=!1,s=!1;for(const o of i.features)if("ELECTRIC_VEHICLE_STATION"===o.properties.poi?.categories?.[0]&&(r=!0,hi(o))){s=!0;break}return r&&!s&&console.warn("PlacesModule: evAvailability is enabled but no availability data found. Did you call getPlacesWithEVAvailability()?"),{...e,evAvailabilityText:e=>hi(e)?((e,t)=>{const i=ui(e);return i?(t?.formatText??di)(i.availableCount,i.totalCount):""})(e,t):"",evAvailabilityRatio:e=>hi(e)?pi(e):0}},Ki=(e,t)=>{const i=Vi(e,t);return i?`poi-${i}`:jt},Yi=(e,t,i={})=>{const r=ji(e),s=!0===i.evAvailability?.enabled?$i(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):Hi(e),o=s?Object.fromEntries(Object.entries(s).map(([t,i])=>[t,"function"==typeof i?i(e):i])):{},a=e.id??f();return{...e,id:a,geometry:{...e.geometry,bbox:e.bbox},properties:{...e.properties,id:a,title:r,iconID:Gi(e,t,i),...("base-map"===i?.theme||"pin-clustered"===i?.theme)&&{category:Vi(e,i),group:zi(e,i)},..."pin-clustered"===i?.theme&&{baseMapIconID:Ki(e,i)},...o}}})}},qi=class e extends Ke{static async create(t,i){return await Ce(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=Xt(zt,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 lt(this.mapLibreMap,this.sourceID,r.clusteredSpecs,!1,i);let o;r.unclusteredSpecs.length>0&&(o=new lt(this.mapLibreMap,this.unclusteredSourceID,r.unclusteredSpecs,!1)),ke([...s._layerSpecs,...o?._layerSpecs??[]],this.mapLibreMap),this.connectionLayerSpecs=this.buildConnectionLayerSpecs(e);const a=new lt(this.mapLibreMap,this.connectionSourceID,Object.values(this.connectionLayerSpecs),!1);return ke(a._layerSpecs,this.mapLibreMap),o?{places:s,placesUnclustered:o,connections:a}:{places:s,connections:a}}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=Fi(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:oi}}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,o=e?.layers?.label,a={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:{...a,...s,layout:{...a.layout,...s?.layout},paint:{...a.paint,...s?.paint}},label:{...n,...o,layout:{...n.layout,...o?.layout},paint:{...n.paint,...o?.paint}}}})(e?.connections,void 0,this.tomtomMap.styleLightDarkTheme),i=`${this.layerIDPrefix}-connection-line`,r=`${this.layerIDPrefix}-connection-label`,s=vt.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:[]};xe(i.clusteredSpecs,r.clusteredSpecs,this.sourcesWithLayers.places,this.mapLibreMap),this.sourcesWithLayers.placesUnclustered&&i.unclusteredSpecs.length>0&&xe(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=Yi(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;xe(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 o of e){const e=Pi(o.from,t),i=Pi(o.to,t);if(!e||!i)continue;const a=o.id??f(),n=r?r(o):"";s.push({type:"Feature",id:a,geometry:{type:"LineString",coordinates:[e.geometry.coordinates,i.geometry.coordinates]},properties:{id:a,fromId:"string"==typeof o.from?o.from:e.id,toId:"string"==typeof o.to?o.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;He("if-not-in-sprite",Xt(e,this.instanceIndex),t.image,this.mapLibreMap,{pixelRatio:t.pixelRatio??2})}e.icon.default&&(e.icon.default.image&&He("if-not-in-sprite",this.defaultPlaceIconID,e.icon.default.image.image,this.mapLibreMap,{pixelRatio:e.icon.default.image.pixelRatio??2}),e.icon.default.style&&He("if-not-in-sprite",this.defaultPlaceIconID,ki(e.icon.default.style),this.mapLibreMap,{pixelRatio:2}))}else He("if-not-in-sprite",this.defaultPlaceIconID,ki(),this.mapLibreMap,{pixelRatio:2})}updateData(e){const t=Yi(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=Yi(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"])})}},Zi=["pin","circle-icon","base-map","pin-clustered"],Xi={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"]},Ji=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}}},Qi=e=>{const t=e.flatMap(e=>e in Xi?Xi[e].map(Pt):[Pt(e)]);return[...new Set(t.filter(e=>!i(e)))]},er="pois.categories",tr=class e extends Ye{static async get(t,i){return await Ce(t),xt(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Tt);if(!t)throw Ie(`init ${e.name} with source ID ${Tt}`);return{poi:new ot(this.mapLibreMap,t,e=>Dt.includes(e.id))}}_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=q("category",e.show,Qi(e.values));this.filterComposer.setClause(vt.poi,er,t)}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.filterComposer.setClause(vt.poi,er,void 0));this.categoriesFilter=e,t&&this.emitConfigChange()}getShown(){return{poi:this.mapLibreMap.queryRenderedFeatures({layers:this.sourcesWithLayers.poi.sourceAndLayerIDs.layerIDs,validate:!1}).map(Ji)}}get events(){return this.moduleEvents(["poi"],{mapping:Ji})}},ir=e=>"source"in e&&"string"==typeof e.source?e.source:void 0,rr=(e,t)=>!e||void 0!==t&&e.includes(t),sr=(e,t,i)=>rr(e.metadataGroups,(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))&&rr(e.layerTypes,t.type)&&rr(e.sources,ir(t))&&rr(e.sourceTypes,((e,t)=>{const i=ir(e);return void 0===i?void 0:t?.[i]?.type})(t,i))&&rr(e.sourceLayers,(e=>"source-layer"in e&&"string"==typeof e["source-layer"]?e["source-layer"]:void 0)(t))&&((e,t)=>{const i=t.id.toLowerCase(),r=e=>i.includes(e.toLowerCase());return!(e.idIncludes&&!e.idIncludes.some(r)||e.idExcludes?.some(r))})(e,t),or=(e,t,i)=>e.some(e=>sr(e,t,i)),ar=["land","water","buildings2D","roads","railways","ferries","borders","buildings3D","natureLabels","roadLabels","roadShields","houseNumbers","smallerTownLabels","stateLabels","cityLabels","allPlaceLabels","capitalLabels","countryLabels"],nr={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"]}},lr=(e,t)=>sr(nr[e],t),cr=e=>{const t=e.mode,i=e.names;return"include"===t?e=>i.some(t=>lr(t,e)):"exclude"===t?e=>!i.some(t=>lr(t,e)):(console.error("Unrecognized layer group mode:",t),()=>!0)},hr=e=>!Dt.includes(e.id),ur=class e extends Ye{static async get(t,i){return await Ce(t),xt(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Ct);if(!t)throw Ie(`init ${e.name} with source ID ${Ct}`);const i=new ot(this.mapLibreMap,t,hr);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&&cr(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&&cr(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(ar.map(e=>[e,[]]));for(const i of e)for(const e of ar)lr(e,i)&&t[e].push(i.id);return t})(this.sourcesWithLayers.vectorTiles._layerSpecs),this.layersByGroup}get events(){return this.moduleEvents(["vectorTiles"],{scopeResolver:dr})}},dr=e=>({layerFilter:cr(e.layerGroups),featureMatches:e.features}),pr=class e extends Ke{static async create(t,i){return await Ce(t),yr(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],o=i.sources[s].cluster;r[s]=new lt(this.mapLibreMap,e,t,!0,o)}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],o=s.sourceID??`custom-geojson-${this.instanceIndex}-${String(r)}`;t[r]=o,i[r]=s.layers.map((e,t)=>({...e,id:e.id??`${o}-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;xe(r,i,s,this.mapLibreMap);const o=[];for(const e of s._layerSpecs)this.mapLibreMap.getLayer(e.id)||o.push(e);o.length>0&&(ke(o,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=fr(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)}},yr=e=>{if(!e.sources||0===Object.keys(e.sources).length)throw new Error("CustomGeoJSONModule requires at least one source in config.sources.");G(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.`)},fr=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},mr="#0A3653",gr="#555555",_r=e=>({defaultColor:"dark"===e?"#5FA8D8":mr,textColor:"dark"===e?"#FFFFFF":"#333333",haloColor:"dark"===e?"#333333":"#FFFFFF"}),br=(e,t,r,s=mr)=>{const o=r?.fill,a=r?.line,n=((e=mr)=>({type:"fill",paint:{"fill-color":["coalesce",["get","color"],e],"fill-opacity":["case",["==",["get","theme"],"outline"],0,.15],"fill-antialias":!1}}))(s),l=((e=mr)=>({type:"line",paint:{"line-color":["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],gr],["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(o?.opacity)&&{"fill-opacity":o?.opacity},...o?.color&&{"fill-color":["get","color"]}}},h=a?.layer;return[c,{...l,...h,id:t,...h?.layout&&{layout:{...l.layout,...h.layout}},paint:{...l.paint,...h?.paint,...!i(a?.color)&&{"line-color":a?.color},...!i(a?.width)&&{"line-width":a?.width},...!i(a?.opacity)&&{"line-opacity":a?.opacity}}}]},Lr=(e,t,i="light")=>{const r=t?.textConfig,{textColor:s,haloColor:o}=_r(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":[_t],"symbol-placement":"point"},paint:{"text-color":s,"text-halo-color":o,"text-halo-width":["interpolate",["linear"],["zoom"],6,1,10,1.5],"text-translate-anchor":"viewport"}}},Sr=(e,t,r="light")=>{const s=t?.lineLabelConfig,o=s?.minZoom??3,{textColor:a,haloColor:n}=_r(r);return{type:"symbol",id:e,minzoom:o,layout:{"text-field":["get","title"],"symbol-placement":"line","text-size":s?.textSize??15,"text-font":[_t],"symbol-spacing":s?.symbolSpacing??200,"text-keep-upright":!0,"text-offset":s?.textOffset??[0,1]},paint:{"text-color":s?.textColor??a,"text-halo-color":s?.textHaloColor??n,"text-halo-width":s?.textHaloWidth??2,...!i(s?.textOpacity)&&{"text-opacity":s?.textOpacity}}}},Ir={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(Ir),Er=(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?be(e,.3)??e:t<.22?((e,t)=>{const i=pe(e);if(i)return Le(i.slice(0,3).map(e=>255*(e+(1-e)*t)))})(e,.4)??e:e}),Rr=(e,t={},i="light")=>({...e,features:e.features.map((e,r)=>{const s=(e.properties??{}).theme??t.theme,o="inverted"===s?(e=>{const t=C(e);return{...e,geometry:t.geometry}})(e):e,a=o.properties??{},n=a.title??((e,t)=>t.textConfig?.textField?t.textConfig.textField:e.properties?.address?.freeformAddress)(o,t),l=a.color??((e,t,i)=>{const r=e?.fill?.color;if("string"==typeof r&&Ir[r]){const e=Er(Ir[r],i);return e[t%e.length]}return r})(t,r,i);return{...o,properties:{...o.properties,...s&&{theme:s},...n&&{title:n},...l&&{color:l},id:a.id??f()}}})}),vr=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=u(i);t=r&&h(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}},Tr=class e extends Ke{static async create(t,i){return await Ce(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 _r(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]=br(this.fillLayerID,this.outlineLayerID,e,this.defaultColor),s=Lr(this.titleLayerID,e,this.lightDark);this.titleLayerSpecs=s,this.geometryFillLayerSpecs=i,this.geometryOutlineLayerSpecs=r;const o=void 0===e?.lineLabelConfig?null:Sr(this.lineLabelLayerID,e,this.lightDark);return this.lineLabelLayerSpecs=o,{geometry:new lt(this.mapLibreMap,this.sourceID,[{...i},{...r},...o?[o]:[]]),geometryLabel:new lt(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:vt[e]}moveLayersBefore(e,t){for(const i of e)Fe(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(vr(this.sourcesWithLayers.geometry.shownFeatures)),this.config=t,this.emitConfigChange()}updateLayerAndData(e){const[t,i]=br(this.fillLayerID,this.outlineLayerID,e,this.defaultColor),r=Lr(this.titleLayerID,e,this.lightDark);if(Ne(t,this.geometryFillLayerSpecs,this.mapLibreMap),Ne(i,this.geometryOutlineLayerSpecs,this.mapLibreMap),Ne(r,this.titleLayerSpecs,this.mapLibreMap),this.geometryFillLayerSpecs=t,this.geometryOutlineLayerSpecs=i,this.titleLayerSpecs=r,this.lineLabelLayerSpecs){const t=Sr(this.lineLabelLayerID,e,this.lightDark);Ne(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(Rr(i,this.config,this.lightDark)),this.sourcesWithLayers.geometryLabel.show(vr(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"])})}},wr={timeMinutes:"min",distanceKM:"km",remainingChargeCPT:"% remaining",spentChargePCT:"% spent",spentFuelLiters:"L"},Cr=(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):v(T([e[i-1],t])),{title:s,theme:o,...a}=t.properties??{};return{...t,geometry:r?.geometry??t.geometry,properties:a}}),...e.map(e=>({...e,id:void 0,properties:{...e.properties,theme:"filled"}}))])(r):r},Or=(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} ${wr[r.type]??r.type}`:String(t+1)});return{type:"FeatureCollection",...e.bbox&&{bbox:e.bbox},features:Cr(r,s,t)}},Mr=(e="fadedRainbow",t="lowestLabel")=>({beforeLayerConfig:t,line:{width:["case",["==",["get","theme"],"outline"],5,1],color:["case",["==",["get","theme"],"outline"],["coalesce",["get","color"],gr],"grey"],opacity:["case",["==",["get","theme"],"outline"],.9,1]},fill:{color:e,opacity:["case",["==",["get","theme"],"outline"],0,.6]},lineLabelConfig:{}}),Nr=(e="fadedRainbow",t,i,r)=>{const s=Mr(e,i),o=e=>Or(e,t,r);return"inverted"!==t?{...s,transformFeaturesForDisplay:o}:{...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:o}},xr=["filled","outline","inverted"],Dr=class e extends Ye{static async get(t,i){return await Ce(t),await Ue(t,wt,"hillshade"),xt(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(wt);if(!t)throw Ie(`init ${e.name} with source ID ${wt}`);return{hillshade:new ot(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"])}},Fr=["standardLight","standardDark","drivingLight","drivingDark","monoLight","monoDark","satellite"],kr=["trafficIncidents","trafficFlow","hillshade"],Pr="standardLight",Ur="0.6.0-0",Hr={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"}},Wr={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"},Gr=(e,t,i)=>{const r=e.id??"standardLight",s=e.version??"0.6.0-0",o=new URL(`${t}/maps/orbis/assets/styles/${s}/style.json`);o.searchParams.set("apiVersion","1"),i&&o.searchParams.set("key",i),o.searchParams.set("map",Wr[r]);for(const a of e.include??kr)o.searchParams.append(a,Hr[r][a]);return o.toString()},Br=e=>{const t=e.style,i=e.commonBaseURL,r=e.apiKey;if("string"==typeof t)return Gr({id:t},i,r);if("standard"===t?.type)return Gr(t,i,r);if("custom"===t?.type){if(void 0!==t.url)return((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);if(void 0===t.json)/* @__PURE__ */throw new Error("A custom map style takes exactly one of 'url' or 'json', and this one carries neither. Give the URL the style is served from, or the style specification itself.");return t.json}return Gr({id:Pr},i,r)},Vr="#1A2024",zr="#F1F3F5",jr=(e,t)=>{const i=e?.color??("dark"===t?zr:Vr),r=_e(i),s=void 0!==r&&r>.4?Vr:zr;return{plaque:i,text:e?.textColor??s}},$r="stopDuration",Kr=[["coalesce",["get",$r],""],{"text-color":"#727C85","text-font":["literal",[bt]]}],Yr=["has",$r],qr="#36A8F0",Zr="#105287",Xr="#ABAFB3",Jr="#3C4956",Qr="#727C85",es=["interpolate",["linear"],["zoom"],1,3,5,4,10,7,18,10],ts=["==",["get","routeState"],"selected"],is=["==",["get","routeState"],"deselected"],rs=["interpolate",["linear"],["zoom"],1,5,5,6,10,10,18,14],ss={s:["interpolate",["linear"],["zoom"],1,2,5,3,10,5,18,7],m:es,l:["interpolate",["linear"],["zoom"],1,5,5,6,10,11,18,15]},os={s:["interpolate",["linear"],["zoom"],1,4,5,5,10,8,18,11],m:rs,l:["interpolate",["linear"],["zoom"],1,7,5,9,10,14,18,19]},as={s:["interpolate",["linear"],["zoom"],8,.45,22,.6],m:["interpolate",["linear"],["zoom"],8,.6,22,.8],l:["interpolate",["linear"],["zoom"],8,.75,22,1]},ns=e=>ss[e??"m"],ls=e=>os[e??"m"],cs=e=>as[e??"m"],hs={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]},us=e=>hs[e??"m"],ds={s:["interpolate",["linear"],["zoom"],16,8,22,12],m:["interpolate",["linear"],["zoom"],16,12,22,17],l:["interpolate",["linear"],["zoom"],16,17,22,24]},ps={s:["interpolate",["linear"],["zoom"],16,10,22,14],m:["interpolate",["linear"],["zoom"],16,14,22,20],l:["interpolate",["linear"],["zoom"],16,20,22,28]},ys=e=>ds[e??"m"],fs=e=>ps[e??"m"],ms="#AD0000",gs="#FB2D09",_s="#FFC105",bs="#f58240",Ls="#000000",Ss="#C7D2D8",Is="rgba(190, 39, 27, 1)",As="rgba(137, 150, 168, 1)",Es=e=>!1===e?.visible?"":e?.title??["format",["get","title"],{},"\n",{},["get","chargingPower"],{}," • ",{},...Kr],Rs=e=>{const t=li(((e=[])=>{const t=/* @__PURE__ */new Map;for(const i of e){if(!i.image)continue;const e={x:i.offsetX??0,y:i.offsetY??0};0===e.x&&0===e.y||t.set(i.id,e)}return t})(e?.icon?.customIcons));return{...Zt,filter:ts,minzoom:4,layout:{...Zt.layout,"text-field":Es(e?.text),...t&&{"icon-offset":t}},paint:{...Zt.paint}}},vs=jr(void 0,"light"),Ts="route-country-crossing-plaque",ws="routeCountryCrossing",Cs=["interpolate",["linear"],["zoom"],5,11,12,13],Os=["case",[">",["get","bearing"],180],["-",["get","bearing"],270],["-",["get","bearing"],90]],Ms=(e,t,i)=>{const r=void 0!==e?Xt(Ts,e):Ts,s="route"===t?.alignment;return{type:"symbol",filter:ts,minzoom:t?.minzoom??4,layout:{"symbol-placement":"point","icon-image":r,"icon-text-fit":"both","icon-text-fit-padding":[4,8,4,8],"icon-rotation-alignment":s?"map":"viewport","text-rotation-alignment":s?"map":"viewport",...s&&{"icon-rotate":Os,"text-rotate":Os},"text-field":["get","label"],"text-font":[_t],"text-size":Cs,"text-allow-overlap":!0,"icon-allow-overlap":!0,...!1===t?.visible&&{visibility:"none"}},paint:{"text-color":i?.text??vs.text}}},Ns={filter:ts,minzoom:16},xs={"line-cap":"round"},Ds=e=>({...Ns,type:"line",layout:xs,paint:{"line-width":fs(e),"line-color":"grey"}}),Fs=e=>({...Ns,type:"line",layout:xs,paint:{"line-width":ys(e),"line-color":"white"}}),ks="instruction-arrow",Ps={...Ns,type:"symbol",layout:{"icon-allow-overlap":!0,"icon-image":ks,"icon-rotation-alignment":"map","icon-rotate":["get","lastPointBearingDegrees"],"icon-size":["interpolate",["linear"],["zoom"],16,1,22,2]}},Us={filter:ts,type:"line",layout:{"line-join":"round"},paint:{"line-color":"#6dc4ed"}},Hs={filter:ts,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}},Ws={type:"line",layout:{"line-join":"round","line-cap":"round","line-sort-key":["get","index"]}},Gs=e=>({...Ws,filter:is,paint:{"line-color":Jr,"line-width":ls(e)}}),Bs=e=>({...Ws,filter:is,paint:{"line-color":Xr,"line-width":ns(e)}}),Vs=(e,t)=>({...Ws,filter:ts,paint:{"line-color":t??"#105287","line-width":ls(e)}}),zs=(e,t)=>({...Ws,filter:ts,paint:{"line-color":t??"#36A8F0","line-width":ns(e)}}),js={type:"symbol",layout:{"symbol-placement":"line","icon-image":"roads-arrow-white","icon-rotate":180}},$s="selected-route-summary-popup",Ks="deselected-route-summary-popup",Ys={filter:ts,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":"#BEBFFA"}},qs={filter:ts,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]}},Zs=["match",["get","magnitudeOfDelay"],"minor",bs,"moderate",gs,"major",ms,"indefinite","#666666",Ls],Xs={type:"line",layout:{"line-cap":"round"},paint:{"line-color":["match",["get","magnitudeOfDelay"],"minor",_s,"moderate",gs,"major",ms,Ss]}},Js={type:"line",filter:["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],layout:{"line-join":"round"},paint:{"line-color":["match",["get","magnitudeOfDelay"],"unknown",Is,As],"line-dasharray":[1.5,1]}},Qs={filter:ts,type:"symbol",minzoom:6,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-ignore-placement":!0}},eo={...Qs,filter:["all",["has","jamIconID"],Qs.filter],layout:{...Qs.layout,"icon-image":["get","jamIconID"],"icon-anchor":"bottom-left","text-anchor":"bottom-left","text-field":["get","title"],"text-font":[_t],"text-offset":[3.9,-1.4],"text-size":13},paint:{...Qs.paint,"text-color":Zs,"text-halo-color":"#FFFFFF","text-halo-width":1}},to={...Qs,filter:["all",["has","causeIconID"],Qs.filter],layout:{...Qs.layout,"icon-image":["get","causeIconID"],"icon-anchor":"bottom-right"},paint:{...Qs.paint}},io={filter:ts,type:"line",layout:{"line-join":"round"},paint:{"line-color":"#000000","line-opacity":.3}},ro={filter:ts,type:"line",layout:{"line-join":"round"},paint:{"line-color":Zr}},so={filter:ts,type:"line",layout:{"line-join":"round","line-cap":"round"},paint:{"line-color":qr}},oo=["carpool","carTrain","importantRoadStretch","lowEmissionZone","motorway","pedestrian","speedLimit","tollVignette","unpaved","urban"],ao=["ferry","tollRoad","traffic","tunnel","vehicleRestricted"],no=[...oo,...ao],lo=["visible","color","opacity","width","style","pattern","icon"],co={carpool:{sourceKey:"carpoolSections",visible:!1,style:"halo",pattern:"solid",knobs:lo},carTrain:{sourceKey:"carTrainSections",visible:!0,style:"halo",pattern:"dashed",knobs:lo},importantRoadStretch:{sourceKey:"importantRoadStretchSections",visible:!1,style:"halo",pattern:"solid",knobs:lo},lowEmissionZone:{sourceKey:"lowEmissionZoneSections",visible:!0,style:"halo",pattern:"solid",knobs:lo},motorway:{sourceKey:"motorwaySections",visible:!1,style:"halo",pattern:"solid",knobs:lo},pedestrian:{sourceKey:"pedestrianSections",visible:!1,style:"halo",pattern:"dashed",knobs:lo},speedLimit:{sourceKey:"speedLimitSections",visible:!0,knobs:["visible","sign"]},tollVignette:{sourceKey:"tollVignetteSections",visible:!0,style:"halo",pattern:"dashed",knobs:lo},unpaved:{sourceKey:"unpavedSections",visible:!1,style:"halo",pattern:"dashed",knobs:lo},urban:{sourceKey:"urbanSections",visible:!1,style:"halo",pattern:"solid",knobs:lo},ferry:{sourceKey:"ferries",visible:!0,style:"inline",pattern:"solid",knobs:lo},tollRoad:{sourceKey:"tollRoads",visible:!0,style:"halo",pattern:"solid",knobs:lo},traffic:{sourceKey:"incidents",visible:!0,style:"inline",pattern:"solid",knobs:["visible","opacity","width","style"]},tunnel:{sourceKey:"tunnels",visible:!0,style:"inline",pattern:"solid",knobs:lo},vehicleRestricted:{sourceKey:"vehicleRestricted",visible:!0,style:"inline",pattern:"dotted",knobs:lo}},ho=(e,t)=>co[e].knobs.includes(t),uo=e=>co[e],po=e=>co[e].visible,yo=e=>ho(e,"sign"),fo=(oo.filter(e=>!yo(e)),e=>co[e].sourceKey),mo={carpool:{color:"#6D4AC7",opacity:.55},carTrain:{color:"#8A5A2B",opacity:.6},importantRoadStretch:{color:"#C7761F",opacity:.6},lowEmissionZone:{color:"#2E8B57",opacity:.5},motorway:{color:"#1F6FB2",opacity:.4},pedestrian:{color:"#B23F86",opacity:.6},tollVignette:{color:"#8C6B1F",opacity:.55},unpaved:{color:"#7A6A54",opacity:.6},urban:{color:"#7E8C8E",opacity:.3}},go={solid:void 0,dashed:[2,1.5],dotted:[0,1.5]},_o=(e,t)=>t?.visible??co[e].visible,bo=(e,t)=>ho(e,"style")&&t?.style||uo(e).style,Lo={halo:"routeDeselectedOutline",inline:"routeLineArrows"},So=(e,t)=>{const i=bo(e,t);return i&&Lo[i]},Io=(e,t,i,r,s="principal")=>{const o=i?.width??r,a={...t.paint,"line-width":"halo"===bo(e,i)?us(o):ns(o)};if(i?.color&&ho(e,"color")){const e="outline"===s?be(i.color,.4):i.color;e&&(a["line-color"]=e)}return void 0!==i?.opacity&&ho(e,"opacity")&&(a["line-opacity"]=i.opacity),"principal"===s&&ho(e,"pattern")&&((e,t,i)=>{const r=i?.pattern??uo(e).pattern,s=r&&go[r];s?t["line-dasharray"]=s:delete t["line-dasharray"]})(e,a,i),{...t,layout:{...t.layout,...!_o(e,i)&&{visibility:"none"}},paint:a}},Ao=(e,t,i)=>{const r=ho(e,"icon")?i?.icon:void 0;return{...t,layout:{...t.layout,...r&&{"icon-image":r.image,"icon-size":r.size??1,...r.placement&&{"symbol-placement":"along"===r.placement?"line":"line-center"}},...!_o(e,i)&&{visibility:"none"}}}},Eo=(e,t,i)=>Io(e,{filter:ts,type:"line",layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":mo[e].color,"line-opacity":mo[e].opacity}},t,i),Ro=["interpolate",["linear"],["zoom"],10,.5,16,.7],vo=["interpolate",["linear"],["zoom"],10,9,16,13],To=["-",["get","startPointIndex"],["get","endPointIndex"]],wo=["case",["==",["get","signFace"],"plaque"],["literal",[0,.55]],["literal",[0,0]]],Co=e=>e?.sign?.placement??"atChange",Oo=(e,t)=>{return{filter:ts,type:"symbol",minzoom:t?.sign?.minzoom??10,layout:{...(i=Co(t),"atChange"===i?{"symbol-placement":"point"}:{"symbol-placement":"line","symbol-spacing":260}),"icon-image":["get","signImageID"],"icon-size":Ro,"icon-rotation-alignment":"viewport","text-field":["get","signLabel"],"text-font":[_t],"text-size":vo,"text-offset":wo,"text-rotation-alignment":"viewport","symbol-sort-key":To,...!_o(e,t)&&{visibility:"none"}},paint:{"text-color":["get","signNumeralsColor"]}};var i},Mo=(e,t)=>`routeSection${e.charAt(0).toUpperCase()+e.slice(1)}${t}`,No=e=>Mo(e,"Sign"),xo="traffic-clear",Do="traffic-major",Fo="traffic-moderate",ko="traffic-minor",Po=["has","formattedTraffic"],Uo=e=>{const t=void 0!==e?Xt($s,e):$s,i=void 0!==e?Xt(Ks,e):Ks,r=void 0!==e?Xt(xo,e):xo,s=void 0!==e?Xt(Do,e):Do,o=void 0!==e?Xt(Fo,e):Fo,a=void 0!==e?Xt(ko,e):ko;return{type:"symbol",layout:{"icon-image":["case",ts,t,i],"symbol-placement":"point","icon-rotation-alignment":"viewport","text-rotation-alignment":"viewport","symbol-sort-key":["case",ts,0,1],"icon-text-fit":"both","icon-text-fit-padding":[10,5,5,10],"text-font":[Lt],"text-size":13,"icon-padding":0,"text-justify":"left","text-line-height":1.5,"text-field":["format",["get","formattedDuration"],{"text-font":["literal",[_t]],"text-color":["case",ts,"black",Qr]},["concat","\t\t",["get","formattedDistance"]],{"text-color":Qr},["case",Po,"\n",""],{},["image",["case",Po,["match",["get","magnitudeOfDelay"],"major",s,"moderate",o,"minor",a,r],""]],{},["case",Po,["concat"," ",["get","formattedTraffic"]],""],{"text-font":["literal",[_t]],"text-color":Zs}]},paint:{"icon-translate":[0,-35],"text-translate":[0,-35]}}},Ho=Uo(),Wo="start",Go="middle",Bo="finish",Vo="stopDisplayIndex",zo="waypointStart",jo="waypointStop",$o="waypointFinish",Ko=["format",["coalesce",["get",Gt],""],{},["case",["all",["has",Gt],Yr],"\n",""],{},...Kr],Yo={"text-field":["get",Vo],"text-font":[_t],"text-size":["interpolate",["linear"],["zoom"],13,14,18,16],"text-offset":[0,-1.6],"icon-anchor":"bottom","text-allow-overlap":!0},qo={type:"symbol",paint:{...Kt,"text-color":"#ffffff"},layout:{...$t,...Yo,"symbol-sort-key":["abs",["-",["get","index"],1e3]]}},Zo={type:"symbol",paint:{...qt,"text-color":"black","text-halo-width":1.5,"text-halo-color":"#ffffff"},layout:{...Yt,"text-field":Ko,"text-anchor":"top","text-offset":[0,.4]}},Xo=(e,t)=>e&&t&&(e.startsWith("route")||e.startsWith("waypoint"))?`${t}-${e}`:e,Jo=(e,t)=>e&&t?Object.fromEntries(Object.entries(e).map(([e,i])=>[e,i?.beforeID?{...i,beforeID:Xo(i.beforeID,t)}:i])):e,Qo=(e,t)=>t?{...e,...t,...t.paint&&{paint:{...e.paint,...t.paint}},...t.layout&&{layout:{...e.layout,...t.layout}}}:e,ea=(e,t)=>e&&void 0!==t?`${e}-${t}`:e,ta=(e={},t,i,r="light")=>{const s=e.layers,o=s?.sections,a=e.theme?.mainColor,n=a?be(a,.4):void 0,l=e.theme?.routeWidth,c=e.theme?.waypointSize,h=cs(c),u=e.sections,d=(e,i,r)=>({...Io(e,i,u?.[e],l,r?.role),beforeID:Xo(r?.beforeID??So(e,u?.[e]),t)}),p=(e,i,r)=>({...Ao(e,i,u?.[e]),beforeID:Xo(r,t)}),y=Object.fromEntries(oo.map(e=>{const i=u?.[e],r=(e=>Mo(e,"Line"))(e),s=(e=>Mo(e,"Symbol"))(e),a=o?.[e];if(yo(e)){const r=No(e);return[e,{[r]:Qo(Oo(e,i),a?.[r]),...Jo(a?.additional,t)}]}const n=i&&((e,t)=>{if(t.icon&&ho(e,"icon"))return Ao(e,{filter:ts,type:"symbol",layout:{"symbol-placement":"line-center","icon-allow-overlap":!0,"icon-rotation-alignment":"viewport"}},t)})(e,i);return[e,{[r]:Qo({...Eo(e,i,l),beforeID:Xo(So(e,i),t)},a?.[r]),...n&&{[s]:Qo({...n,beforeID:vt.lowestLabel},a?.[s])},...Jo(a?.additional,t)}]}));return{mainLines:{routeLineArrows:Qo({...js,beforeID:vt.lowestLabel},s?.mainLines?.routeLineArrows),routeLine:Qo({...zs(l,a),beforeID:Xo("routeIncidentBackgroundLine",t)},s?.mainLines?.routeLine),routeOutline:Qo({...Vs(l,n),beforeID:Xo("routeLine",t)},s?.mainLines?.routeOutline),routeDeselectedLine:Qo({...Bs(l),beforeID:Xo("routeOutline",t)},s?.mainLines?.routeDeselectedLine),routeDeselectedOutline:Qo({...Gs(l),beforeID:Xo("routeDeselectedLine",t)},s?.mainLines?.routeDeselectedOutline),...Jo(s?.mainLines?.additional,t)},waypoints:{routeWaypointSymbol:Qo({...qo,layout:{...qo.layout,"icon-size":h},beforeID:Xo("routeSummaryBubbleSymbol",t)},s?.waypoints?.routeWaypointSymbol),routeWaypointLabel:Qo({...Zo,beforeID:Xo("routeWaypointSymbol",t)},s?.waypoints?.routeWaypointLabel),...Jo(s?.waypoints?.additional,t)},chargingStops:{routeChargingStopSymbol:Qo({...Rs(e.chargingStops),beforeID:Xo("routeWaypointSymbol",t)},s?.chargingStops?.routeChargingStopSymbol),...Jo(s?.chargingStops?.additional,t)},sections:{...y,traffic:{routeIncidentJamSymbol:Qo(p("traffic",eo,"routeChargingStopSymbol"),o?.traffic?.routeIncidentJamSymbol),routeIncidentCauseSymbol:Qo(p("traffic",to,"routeChargingStopSymbol"),o?.traffic?.routeIncidentCauseSymbol),routeIncidentBackgroundLine:Qo(d("traffic",Xs,{beforeID:"routeIncidentDashedLine"}),o?.traffic?.routeIncidentBackgroundLine),routeIncidentDashedLine:Qo(d("traffic",Js),o?.traffic?.routeIncidentDashedLine),...Jo(o?.traffic?.additional,t)},ferry:{routeFerryLine:Qo(d("ferry",Us),o?.ferry?.routeFerryLine),routeFerrySymbol:Qo(p("ferry",Hs,"routeIncidentJamSymbol"),o?.ferry?.routeFerrySymbol),...Jo(o?.ferry?.additional,t)},tollRoad:{routeTollRoadOutline:Qo(d("tollRoad",Ys),o?.tollRoad?.routeTollRoadOutline),routeTollRoadSymbol:Qo(p("tollRoad",qs,"routeChargingStopSymbol"),o?.tollRoad?.routeTollRoadSymbol),...Jo(o?.tollRoad?.additional,t)},tunnel:{routeTunnelLine:Qo(d("tunnel",io),o?.tunnel?.routeTunnelLine),...Jo(o?.tunnel?.additional,t)},vehicleRestricted:{routeVehicleRestrictedBackgroundLine:Qo(d("vehicleRestricted",ro,{beforeID:"routeVehicleRestrictedForegroundLine",role:"outline"}),o?.vehicleRestricted?.routeVehicleRestrictedBackgroundLine),routeVehicleRestrictedForegroundLine:Qo(d("vehicleRestricted",so),o?.vehicleRestricted?.routeVehicleRestrictedForegroundLine),...Jo(o?.vehicleRestricted?.additional,t)}},instructionLines:{routeInstructionLine:Qo({...Fs(l),beforeID:vt.lowestLabel},s?.instructionLines?.routeInstructionLine),routeInstructionOutline:Qo({...Ds(l),beforeID:Xo("routeInstructionLine",t)},s?.instructionLines?.routeInstructionOutline),...Jo(s?.instructionLines?.additional,t)},instructionArrows:{routeInstructionArrowSymbol:Qo({...Ps,beforeID:Xo("routeInstructionLine",t),...void 0!==i&&{layout:{...Ps.layout,"icon-image":ea(Ps.layout?.["icon-image"],i)}}},s?.instructionArrows?.routeInstructionArrowSymbol),...Jo(s?.instructionArrows?.additional,t)},summaryBubbles:{routeSummaryBubbleSymbol:Qo(void 0===i?Ho:Uo(i),s?.summaryBubbles?.routeSummaryBubbleSymbol),...Jo(s?.summaryBubbles?.additional,t)},countryCrossings:{[ws]:Qo({...Ms(i,e.countryCrossings,jr(e.countryCrossings,r)),beforeID:Xo("routeWaypointSymbol",t)},s?.countryCrossings?.[ws]),...Jo(s?.countryCrossings?.additional,t)}}},ia=ta();Re()&&(et=ve(Te('<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 ra,sa,oa=e=>{if(!Re())return;const t=Te('<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),ve(t)},aa={pixelRatio:2,stretchX:[[20,45],[100,130]],stretchY:[[20,35]],content:[10,10,130,45]},na={pixelRatio:2,stretchX:[[30,110]],stretchY:[[25,35]],content:[10,10,130,50]},la=e=>{if(!Re())return;const t=Te('<svg xmlns="http://www.w3.org/2000/svg" width="140" height="60">\n <g filter="url(#shadow)">\n <rect id="plaque" x="10" y="10" width="120" height="40" rx="8"/>\n </g>\n <defs>\n <filter id="shadow">\n <feDropShadow dx="0" dy="2" stdDeviation="3" flood-opacity=".35"/>\n </filter>\n </defs>\n</svg>\n');return t.querySelector("#plaque")?.setAttribute("fill",e),ve(t)},ca={whiteDisc:'<svg xmlns="http://www.w3.org/2000/svg" width="92" height="92" viewBox="0 0 46 46"><circle cx="23" cy="23" r="19.5" fill="#fff" stroke="#D0021B" stroke-width="5"/></svg>\n',yellowDisc:'<svg xmlns="http://www.w3.org/2000/svg" width="92" height="92" viewBox="0 0 46 46"><circle cx="23" cy="23" r="19.5" fill="#FFCE00" stroke="#D0021B" stroke-width="5"/></svg>\n',plaque:'<svg xmlns="http://www.w3.org/2000/svg" width="92" height="92" viewBox="0 0 46 46"><rect x="7" y="3" width="32" height="40" rx="2" fill="#fff" stroke="#1A2024" stroke-width="2"/><text x="23" y="13" fill="#1A2024" font-family="sans-serif" font-size="7" font-weight="bold" text-anchor="middle">SPEED</text><text x="23" y="21" fill="#1A2024" font-family="sans-serif" font-size="7" font-weight="bold" text-anchor="middle">LIMIT</text></svg>\n'},ha=e=>{if(Re())return ve(Te(ca[e]))},ua=e=>{if(!Re())return;const t=Te('<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),ve(t)},da=(e,t)=>{if(!Re())return;const i=we(t);return e&&i.appendChild(e),ve(i)},pa=e=>{if(Re())return da(Te('<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)},ya=e=>{if(Re())return da(Te('<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)},fa=(e={},t)=>Object.entries(e).map(([e,i])=>({...i,id:Jt(e,t)})),ma=(e={},t)=>({...Object.fromEntries(oo.map(i=>[fo(i),fa(e.sections?.[i],t)])),mainLines:fa(e.mainLines,t),waypoints:fa(e.waypoints,t),chargingStops:fa(e?.chargingStops,t),ferries:fa(e.sections?.ferry,t),incidents:fa(e.sections?.traffic,t),tollRoads:fa(e.sections?.tollRoad,t),tunnels:fa(e.sections?.tunnel,t),vehicleRestricted:fa(e.sections?.vehicleRestricted,t),instructionLines:fa(e.instructionLines,t),instructionArrows:fa(e.instructionArrows,t),summaryBubbles:fa(e.summaryBubbles,t),countryCrossings:fa(e.countryCrossings,t)}),ga=(e,t,i,r)=>{const s=c.instance.get().displayUnits,o=e?.displayUnits;return{...e,...o?{}:{displayUnits:s},layers:ta(e,t,i,r)}},_a=(e,t)=>{const i=e[t-1]??e[t],r=e[t+1]??e[t];return i===r?0:(E(i,r)+360)%360},ba=(e,t,i,r)=>{const s=f();return{type:"Feature",id:s,geometry:{type:"Point",coordinates:i[t.startPointIndex]},properties:{id:s,fromCountryCode:e.countryCodeISO2,toCountryCode:t.countryCodeISO2,label:`${e.countryCodeISO2} → ${t.countryCodeISO2}`,bearing:_a(i,t.startPointIndex),fromSectionStartPointIndex:e.startPointIndex,toSectionStartPointIndex:t.startPointIndex,routeState:r.routeState,routeIndex:r.index}}},La=e=>{const t=e.properties.sections.country;if(!t?.length)return[];const i=[...t].sort((e,t)=>e.startPointIndex-t.startPointIndex),r=e.geometry.coordinates;return i.slice(1).flatMap((t,s)=>r[t.startPointIndex]?[ba(i[s],t,r,e.properties)]:[])},Sa=e=>({type:"FeatureCollection",features:e.features.flatMap(La)}),Ia=(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 Ee("7309")},Aa=e=>{const t=e.properties;return t.chargingParkName??t.chargingParkOperatorName},Ea=e=>e.categories.includes("jam"),Ra=e=>{const t=(e=>{if(Ea(e))return y(e.delayInSeconds)})(e),i=((e,t)=>Ea(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}}},va=(e,t,i)=>{let r;switch(t){case"start":r=zo;break;case"finish":r=$o;break;default:r=jo}return void 0!==i?Xt(r,i):r},Ta=(e,t,i,r)=>({type:"FeatureCollection",features:e.map((s,o)=>{if(!s)return null;const a=(e=>{return Array.isArray(e)?{type:"Feature",geometry:{type:"Point",coordinates:e},properties:{}}:"Point"===e.type?{type:"Feature",geometry:t=e,properties:{},...t.bbox&&{bbox:t.bbox}}:e;var t})(s),n=((e,t)=>0===e?Wo:e<t-1?Go:Bo)(o,e.length),l=(e=>{const t=e?.properties;return t?.poi?.name??t?.address?.freeformAddress??void 0})(a),c=a.id??f(),h=y(a.properties.pauseDurationSeconds,r);return{...a,..."main-when-available"===t?.entryPoints&&{geometry:{type:"Point",coordinates:g(a,{useEntryPoint:"main-when-available"})}},id:c,properties:{...a.properties,id:c,index:o,indexType:n,...l&&{title:l},...h&&{stopDuration:h},iconID:va(0,n,i),..."middle"===n&&{stopDisplayIndex:o}}}}).filter(e=>e)}),wa=(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))}),Ca=(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)),Oa=(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"}}})}},Ma=(e,t)=>e.some(e=>e.magnitudeOfDelay===t),Na=(e,t)=>({type:"FeatureCollection",features:e.features.map(e=>{const i=e.properties.summary,r=e.geometry.coordinates,s=y(i.trafficDelayInSeconds,t?.time),o=(e=>{const t=e.properties.sections.traffic;if(t?.length)return Ma(t,"major")?"major":Ma(t,"moderate")?"moderate":Ma(t,"minor")?"minor":void 0})(e),a=e.id??f();return{type:"Feature",id:a,geometry:{type:"Point",coordinates:r[Math.round(r.length/2)]},properties:{id:a,routeIndex:e.properties.index,routeState:e.properties.routeState,formattedDistance:p(i.lengthInMeters,t?.distance),...o&&{magnitudeOfDelay:o},...s&&{formattedTraffic:s},formattedDuration:y(i.travelTimeInSeconds,t?.time)}}})}),xa={GBR:{unit:"mph"},LBR:{unit:"mph"},MMR:{unit:"mph"},USA:{face:"plaque",unit:"mph"},SWE:{face:"yellowDisc"},FIN:{face:"yellowDisc"},ISL:{face:"yellowDisc"},JPN:{numerals:"#0B5FA5"}},Da={metric:{},imperial_uk:{unit:"mph"},imperial_us:{face:"plaque",unit:"mph"}},Fa={whiteDisc:"routeSpeedLimitWhiteDisc",yellowDisc:"routeSpeedLimitYellowDisc",plaque:"routeSpeedLimitPlaque"},ka=(e,t)=>"mph"===t?5*Math.round(1e3*e/l/5):e,Pa=class e extends Ke{static async create(t,i){return await Ce(t),new e(t,i)}constructor(e,t){super(e,t),this.shownFeaturesHandlers=[]}createSourcesWithLayers(e){const t=Xt("routes",this.instanceIndex);return{...Object.fromEntries(oo.map(i=>{const r=fo(i);return[r,new lt(this.mapLibreMap,`${t}-${r}`,e[r],!1)]})),mainLines:new lt(this.mapLibreMap,`${t}-mainLines`,e.mainLines,!1),waypoints:new lt(this.mapLibreMap,`${t}-waypoints`,e.waypoints,!1),incidents:new lt(this.mapLibreMap,`${t}-incidents`,e.incidents,!1),ferries:new lt(this.mapLibreMap,`${t}-ferries`,e.ferries,!1),chargingStops:new lt(this.mapLibreMap,`${t}-chargingStops`,e.chargingStops,!1),tollRoads:new lt(this.mapLibreMap,`${t}-tollRoads`,e.tollRoads,!1),tunnels:new lt(this.mapLibreMap,`${t}-tunnels`,e.tunnels,!1),vehicleRestricted:new lt(this.mapLibreMap,`${t}-vehicleRestricted`,e.vehicleRestricted,!1),instructionLines:new lt(this.mapLibreMap,`${t}-instructionLines`,e.instructionLines,!1),instructionArrows:new lt(this.mapLibreMap,`${t}-instructionArrows`,e.instructionArrows,!1),summaryBubbles:new lt(this.mapLibreMap,`${t}-summaryBubbles`,e.summaryBubbles,!1),countryCrossings:new lt(this.mapLibreMap,`${t}-countryCrossings`,e.countryCrossings,!1)}}_initSourcesWithLayers(e,t){t||(this.layerIDPrefix=Xt("routes",this.instanceIndex)),this.layersSpecs=ma(ga(e,this.layerIDPrefix,this.instanceIndex,this.tomtomMap.styleLightDarkTheme).layers,this.layerIDPrefix);const i=this.createSourcesWithLayers(this.layersSpecs);ke(Object.values(i).flatMap(e=>e._layerSpecs),this.mapLibreMap);const r={fillColor:e?.theme?.mainColor,...e?.waypoints?.icon?.style},s={pixelRatio:2},o=Xt(zo,this.instanceIndex),a=Xt(jo,this.instanceIndex),n=Xt($o,this.instanceIndex),l=Xt(ks,this.instanceIndex),c=Xt($s,this.instanceIndex),h=Xt(Ks,this.instanceIndex),u=Xt(xo,this.instanceIndex),d=Xt(Do,this.instanceIndex),p=Xt(Fo,this.instanceIndex),y=Xt(ko,this.instanceIndex);this.addImageIfNotExisting(o,pa(r),s),this.addImageIfNotExisting(a,da(void 0,r),s),this.addImageIfNotExisting(n,ya(r),s),this.addImageIfNotExisting(l,et,s),this.addImageIfNotExisting(c,oa("white"),aa),this.addImageIfNotExisting(h,oa("#EEEEEE"),aa);for(const[f,m]of Object.entries(Fa))this.addImageIfNotExisting(Xt(m,this.instanceIndex),ha(f),s);this.appliedCrossingColors=void 0,this.addImageIfNotExisting(Xt(Ts,this.instanceIndex),la(this.crossingColors(this.config).plaque),{...s,...na}),this.addImageIfNotExisting(u,ua(Ls),s),this.addImageIfNotExisting(d,ua(ms),s),this.addImageIfNotExisting(p,ua(gs),s),this.addImageIfNotExisting(y,ua(bs),s);for(const f of e?.chargingStops?.icon?.customIcons??[])this.addImageIfNotExisting(f.id,f.image,{pixelRatio:f.pixelRatio??2});return i}_applyConfig(e){const i=ga(e,this.layerIDPrefix,this.instanceIndex,this.tomtomMap.styleLightDarkTheme),r=!t(this.config?.displayUnits,i.displayUnits);if(this.config){const t=ma(i.layers,this.layerIDPrefix);Object.keys(t).forEach(e=>{const i=e;xe(t[i],this.layersSpecs[i],this.sourcesWithLayers[i],this.mapLibreMap)});const s=Object.values(this.sourcesWithLayers);ke(s.flatMap(e=>e._layerSpecs),this.mapLibreMap),this.reshowSpeedLimitSigns(i,r),s.forEach(e=>e.setLayersVisible(!!e.shownFeatures.features.length)),this.applySectionVisibility(e),this.applySignPriority(e),this.layersSpecs=t}if(e?.theme?.mainColor!==this.config?.theme?.mainColor){const t={fillColor:e?.theme?.mainColor,...e?.waypoints?.icon?.style},i={pixelRatio:2};He("add-or-update",Xt(zo,this.instanceIndex),pa(t),this.mapLibreMap,i),He("add-or-update",Xt(jo,this.instanceIndex),da(void 0,t),this.mapLibreMap,i),He("add-or-update",Xt($o,this.instanceIndex),ya(t),this.mapLibreMap,i)}const s=!1!==i.summaryBubbles?.visible,o=!t(this.config?.summaryBubbles?.visible,i.summaryBubbles?.visible),a=this.sourcesWithLayers.summaryBubbles.shownFeatures.features.length>0,n=this.sourcesWithLayers.mainLines.shownFeatures.features.length>0;return!s&&o?this.sourcesWithLayers.summaryBubbles.clear():s&&(o&&n||r&&a)&&this.sourcesWithLayers.summaryBubbles.show(Na(this.sourcesWithLayers.mainLines.shownFeatures,i.displayUnits)),this.applyCountryCrossingConfig(i),i}showSpeedLimitSections(e,t){var i,r;this.sourcesWithLayers.speedLimitSections.show(wa(e,"speedLimit",(i=this.instanceIndex,r={unit:t?.sections?.speedLimit?.sign?.unit,displayUnits:t?.displayUnits},(e,t)=>{const s=(o=e.startPointIndex,a=t?.sections.country,a?.find(e=>o>=e.startPointIndex&&o<=e.endPointIndex)?.countryCodeISO3);var o,a;const n=s?xa[s]??{}:Da[r?.displayUnits?.distance?.type??"metric"],l=n.face??"whiteDisc",c=r?.unit??n.unit??"km/h";return{...e,signImageID:Xt(Fa[l],i),signLabel:String(ka(e.maxSpeedLimitInKmh,c)),signFace:l,signNumeralsColor:n.numerals??"#1A2024"}})))}crossingColors(e){return jr(e?.countryCrossings,this.tomtomMap.styleLightDarkTheme)}applyCountryCrossingConfig(e){const i=!1!==e.countryCrossings?.visible,r=!t(this.config?.countryCrossings?.visible,e.countryCrossings?.visible);!i&&r?this.sourcesWithLayers.countryCrossings.clear():i&&r&&this.sourcesWithLayers.countryCrossings.show(Sa(this.sourcesWithLayers.mainLines.shownFeatures));const s=this.crossingColors(e);if(t(this.appliedCrossingColors,s))return;this.appliedCrossingColors=s,He("add-or-update",Xt(Ts,this.instanceIndex),la(s.plaque),this.mapLibreMap,na);const o=Jt(ws,this.layerIDPrefix);this.mapLibreMap.getLayer(o)&&this.mapLibreMap.setPaintProperty(o,"text-color",s.text,{validate:!1})}reshowSpeedLimitSigns(e,i){t(this.config?.sections?.speedLimit?.sign?.unit,e.sections?.speedLimit?.sign?.unit)&&!i||this.sourcesWithLayers.speedLimitSections.shownFeatures.features.length&&this.showSpeedLimitSections(this.sourcesWithLayers.mainLines.shownFeatures,e)}applySectionVisibility(e){for(const t of no){const i=this.sourcesWithLayers[fo(t)],r=!!i.shownFeatures.features.length;i.setLayersVisible(r&&_o(t,e?.sections?.[t]))}}signLayerID(e){if(yo(e))return Jt(No(e),this.layerIDPrefix)}applySignPriority(e){for(const t of oo){const i=this.signLayerID(t);if(!i||!this.mapLibreMap.getLayer(i))continue;const r=e?.sections?.[t];this.mapLibreMap.moveLayer(i,this.signAnchorLayerID(i,r))}}signAnchorLayerID(e,t){const i=(e=>e?.sign?.priority??("atChange"===Co(e)?"belowRouteIcons":"belowMapLabels"))(t);if("aboveRouteIcons"===i)return;const r=this.mapLibreMap.getStyle().layers;if("belowMapLabels"===i)return vt.lowestLabel;const s=r.findIndex(e=>e.id===vt.lowestLabel);return r.find((t,i)=>"symbol"===t.type&&t.id!==e&&i>s&&(!this.layerIDPrefix||t.id.startsWith(this.layerIDPrefix)))?.id}discardShownData(){}restoreDataAndConfigImpl(){const e=Object.fromEntries(Object.entries(this.sourcesWithLayers).map(([e,t])=>[e,t.shownFeatures]));this.initSourcesWithLayers(this.config,!0),this._applyConfig(this.config);for(const t of Object.keys(e))this.sourcesWithLayers[t].show(e[t]);this.applySectionVisibility(this.config)}addImageIfNotExisting(e,t,i){He("if-not-in-sprite",e,t,this.mapLibreMap,i)}async showRoutes(e,t){const i=Oa(e,t?.selectedIndex);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(i),this.sourcesWithLayers.vehicleRestricted.show(wa(i,"vehicleRestricted")),this.sourcesWithLayers.incidents.show(wa(i,"traffic",Ra)),this.sourcesWithLayers.chargingStops.show(((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 o=s.properties,a=y(e.summary.stopTimeInSeconds??o.chargingTimeInSeconds,t?.displayUnits?.time);i.push({...s,properties:{...s.properties,id:s.properties.chargingParkId??f(),iconID:Ia(s,t),title:Aa(s),chargingPower:`${o.chargingConnectionInfo?.chargingPowerInkW} kW`,chargingDuration:y(o.chargingTimeInSeconds,t?.displayUnits?.time),...a&&{stopDuration:a},routeState:r.properties.routeState,routeIndex:r.properties.index}})}}return{type:"FeatureCollection",features:i}})(i,this.config)),this.sourcesWithLayers.ferries.show(wa(i,"ferry")),this.sourcesWithLayers.tunnels.show(wa(i,"tunnel")),this.sourcesWithLayers.tollRoads.show(wa(i,"tollRoad"));for(const r of oo)yo(r)||this.sourcesWithLayers[fo(r)].show(wa(i,r));this.showSpeedLimitSections(i,this.config),this.applySectionVisibility(this.config),this.applySignPriority(this.config),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:E(r[0],r[1])}}})||[])}))(i)),!1!==this.config?.countryCrossings?.visible?this.sourcesWithLayers.countryCrossings.show(Sa(i)):this.sourcesWithLayers.countryCrossings.clear(),!1!==this.config?.summaryBubbles?.visible?this.sourcesWithLayers.summaryBubbles.show(Na(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=Oa(this.sourcesWithLayers.mainLines.shownFeatures,e);await this.waitUntilModuleReady(),this.sourcesWithLayers.mainLines.show(t),Ca(t,this.sourcesWithLayers.chargingStops),Ca(t,this.sourcesWithLayers.vehicleRestricted),Ca(t,this.sourcesWithLayers.incidents),Ca(t,this.sourcesWithLayers.ferries),Ca(t,this.sourcesWithLayers.tollRoads);for(const i of oo)Ca(t,this.sourcesWithLayers[fo(i)]);Ca(t,this.sourcesWithLayers.tunnels),Ca(t,this.sourcesWithLayers.instructionLines),Ca(t,this.sourcesWithLayers.instructionArrows),Ca(t,this.sourcesWithLayers.summaryBubbles),Ca(t,this.sourcesWithLayers.countryCrossings),this.applySectionVisibility(this.config)}async showWaypoints(e){const t=Array.isArray(e)?Ta(e,this.config?.waypoints,this.instanceIndex,this.config?.displayUnits?.time):Ta(e.features,this.config?.waypoints,this.instanceIndex,this.config?.displayUnits?.time);await this.waitUntilModuleReady(),this.sourcesWithLayers.waypoints.show(t),this.applySignPriority(this.config);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,...Object.fromEntries(oo.map(e=>[fo(e),this.sourcesWithLayers[fo(e)].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,countryCrossings:this.sourcesWithLayers.countryCrossings.shownFeatures}}get events(){const e=Object.fromEntries(oo.map(e=>[fo(e),this.userEvents([fo(e)])]));return this.buildEvents(this.moduleEventsWithShown(["mainLines","waypoints","chargingStops","summaryBubbles","countryCrossings","incidents","vehicleRestricted","ferries","tollRoads","tunnels","instructionLines",...oo.map(fo)],this.shownFeaturesHandlers),{...e,mainLines:this.userEvents(["mainLines"]),waypoints:this.userEvents(["waypoints"]),chargingStops:this.userEvents(["chargingStops"]),summaryBubbles:this.userEvents(["summaryBubbles"]),countryCrossings:this.userEvents(["countryCrossings"],{mapping:e=>((e,t)=>{const i=e.properties,r=t.features[i.routeIndex]?.properties.sections.country??[],s=e=>r.find(t=>t.startPointIndex===e);return{type:"Feature",id:e.id,geometry:e.geometry,properties:{...i,fromSection:s(i.fromSectionStartPointIndex),toSection:s(i.toSectionStartPointIndex)}}})(e,this.sourcesWithLayers.mainLines.shownFeatures)}),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 vt.lowestLabel}},Ua={fill:["fill-color","fill-outline-color"],line:["line-color"],"fill-extrusion":["fill-extrusion-color"]},Ha=e=>t=>({layers:[{...t,layerTypes:[e]}],properties:[...Ua[e]]}),Wa=Ha("fill"),Ga=Ha("line"),Ba=Ha("fill-extrusion"),Va=(e,t)=>({metadataGroups:["road"],layerTypes:["line"],idIncludes:e,...t&&{idExcludes:t}}),za=Va(["road line","road outline","under construction"],["tarmac"]),ja=Va(["motorway","primary road","major road"]),$a=Va(["secondary road","tertiary road","street","minor road","link road","restricted","service road"],["outline"]),Ka=Va(["secondary road outline","tertiary road outline","street outline","minor road outline","link road outline","tarmac outline"]),Ya=Va(["railway","subway","track","path","aerialway"],["outline"]),qa={metadataGroups:["places_label","road_label","label","address_point_label","border_label"],layerTypes:["symbol"],idExcludes:["shield","exit","water","river"]},Za={land:{description:"Map background and other bare-land features, influences admin borders/labels. Also used to derive all map colours if undefined.",anchor:{layers:[{layerTypes:["background"]}],property:"background-color"},targets:[{layers:[{layerTypes:["background"]}],properties:["background-color"]},Wa({metadataGroups:["area"],idIncludes:["earth cover","landcover"]}),Wa({metadataGroups:["road_area"]}),Wa({metadataGroups:["transit_area"]}),Ga({metadataGroups:["transit_area"]})]},water:{description:"Waterbodies, waterways and other water features. Also influences glaciers, water labels and ferry lines.",anchor:{layers:[{metadataGroups:["water"],layerTypes:["fill"],idIncludes:["fill"]}],property:"fill-color"},targets:[Wa({metadataGroups:["water"]}),Ga({metadataGroups:["water"]}),{layers:[{metadataGroups:["label"],layerTypes:["symbol"],idIncludes:["water","river"]}],properties:["text-color","text-halo-color"]},Ga({metadataGroups:["road"],idIncludes:["ferry"]})]},vegetation:{description:"Forests and other land cover such as grass and shrubland. Also influences earth cover vegetation at smaller scales.",anchor:{layers:[{metadataGroups:["area"],layerTypes:["fill"],idIncludes:["landcover"]}],property:"fill-color"},targets:[Wa({metadataGroups:["area"],idIncludes:["landcover","earth cover"]})]},park:{description:"City parks and sport/recreation grounds. Also influences National Parks and other protected areas at smaller scales.",anchor:{layers:[{metadataGroups:["area"],layerTypes:["fill"],idIncludes:["protected"]}],property:"fill-color"},targets:[Wa({metadataGroups:["area"],idIncludes:["protected","outdoor","sport","landuse"]}),Ga({metadataGroups:["border"],idIncludes:["overlays"]})]},artificial:{description:"Built-up-areas and man-made features such as landuse grounds and buildings. Also influences railways.",anchor:{layers:[{metadataGroups:["area"],layerTypes:["fill"],idIncludes:["built-up"]}],property:"fill-color"},targets:[Wa({metadataGroups:["area"],idIncludes:["built-up","landuse","parking"]}),Wa({metadataGroups:["building","transit_area","road_area"]}),Ga({metadataGroups:["building","transit_area"]}),Ba({metadataGroups:["area_3d","building"]}),Ga(Ya)]},roadMajor:{description:"Most important road classes, from motorways & trunks to primary roads. Also influences outline and tunnel colours.",anchor:{layers:[Va(["motorway & trunk"],["outline"])],property:"line-color",roadClass:"major"},targets:[Ga(ja),{layers:[za],properties:["line-color"],roadClass:"major"}]},road:{description:"Less important road classes, from secondary/tertiary to streets and service roads. Also influences tunnel colours.",anchor:{layers:[Va(["secondary road"],["outline"])],property:"line-color"},targets:[Ga($a),{layers:[Va(["road line","under construction"])],properties:["line-color"],roadClass:"minor"}]},roadOutline:{description:"Road outlines for secondary/tertiary roads and minor classes. Also influences road labels and all other outline colours.",anchor:{layers:[Va(["secondary road outline"])],property:"line-color"},targets:[Ga(Ka),{layers:[Va(["road outline"],["tarmac"])],properties:["line-color"],roadClass:"minor"}]},label:{description:"Labels for capitals and other populated places/admin areas. Also influences border styling and all other label colours.",anchor:{layers:[{metadataGroups:["places_label"],layerTypes:["symbol"],idIncludes:["city"]}],property:"text-color"},targets:[{layers:[qa],properties:["text-color"]},Ga({metadataGroups:["border"],idIncludes:["country","state","treaty","disputed"]})]},labelOutline:{description:"Outlines for populated places and admin area labels. Also influences border outlines and all other label halos.",anchor:{layers:[{metadataGroups:["places_label"],layerTypes:["symbol"],idIncludes:["city"]}],property:"text-halo-color"},targets:[{layers:[qa],properties:["text-halo-color"]},Ga({metadataGroups:["border"],idIncludes:["background"]})]}},Xa=Object.keys(Za),Ja=e=>e in Za,Qa={min:.5,max:1.5,step:.1},en={min:.5,max:2,step:.1},tn={sourceTypes:["vector"],layerTypes:["symbol"]},rn={sources:["vectorTiles"],sourceLayers:["poi"],layerTypes:["symbol"]},sn={...(ra="roads",nr[ra]),layerTypes:["line"]},on=e=>(t,i)=>({sources:[e],layerTypes:["line"],idIncludes:[i?`${t} outline`:t],...i?{}:{idExcludes:["outline"]}}),an=on(Mt),nn=on(Ot),ln=(e,t,i=Qa)=>({kind:"factor",description:e,range:i,appliesTo:"any-style",mechanisms:t}),cn=(e,t)=>({kind:"toggle",description:e,appliesTo:"tomtom-styles",mechanisms:[{type:"visibility",layers:t}]}),hn=(e,t,i,r)=>({kind:"color",description:e,appliesTo:"tomtom-styles",mechanisms:[{type:"color",property:t,layers:i,shades:r}]}),un=e=>({kind:"color",description:Za[e].description,appliesTo:"tomtom-styles",mechanisms:[{type:"mapColor",color:e}]}),dn=e=>(t,i)=>hn(t,"line-color",[e(i,!1)],[e(i,!0)]),pn=dn(an),yn=dn(nn),fn={"labels.sizeFactor":ln("Size of every base-map text label (places, roads, POIs, house numbers).",[{type:"scale",property:"text-size",layers:[tn]}]),"symbols.sizeFactor":ln("Size of every base-map icon (POI icons, route shields, road arrows).",[{type:"scale",property:"icon-size",layers:[tn]}]),"roads.widthFactor":ln("Width of all road lines, keeping the hierarchy motorway → path.",[{type:"scale",property:"line-width",layers:[sn]}]),"pois.sizeFactor":ln("Size of the base-map POI icons and their labels.",[{type:"scale",property:"icon-size",layers:[rn]},{type:"scale",property:"text-size",layers:[rn]}]),"pois.minZoom":{kind:"number",description:"Zoom level from which base-map POIs appear (the style default is 6).",range:{min:3,max:18,step:1},appliesTo:"tomtom-styles",mechanisms:[{type:"minZoom",layers:[{...rn,idExcludes:["micro"]}]}]},"pois.zoomShift":{kind:"number",description:"Shifts the zoom at which each POI appears: positive = later and sparser, negative = earlier and denser.",range:{min:-3,max:3,step:1},appliesTo:"tomtom-styles",mechanisms:[{type:"zoomOffset",layers:[rn]}]},"pois.labelColor":hn("Text colour of base-map POI labels (replaces the per-category colours).","text-color",[rn]),"pois.labelOutlineColor":hn("Halo colour of base-map POI labels.","text-halo-color",[rn]),"pois.microMarkers":cn("The small dot markers for low-priority POIs at high zoom.",[{...rn,idIncludes:["micro"]}]),"roads.exitNumbers":cn("Motorway exit number badges.",[{metadataGroups:["road_label"],layerTypes:["symbol"],idIncludes:["exit"]}]),"roads.shields":cn("Route shields along roads.",[{metadataGroups:["road_label"],layerTypes:["symbol"],idIncludes:["shield"]}]),"roads.arrows":cn("One-way arrows drawn on roads.",[{metadataGroups:["road"],layerTypes:["symbol"],idIncludes:["arrow"]}]),"roads.restricted":cn("Dashed marking of roads with restricted access.",[{metadataGroups:["road"],layerTypes:["line"],idIncludes:["restricted"]}]),"roads.underConstruction":cn("Roads under construction.",[{metadataGroups:["road"],layerTypes:["line"],idIncludes:["construction"]}]),"buildings.footprints":cn("2D building footprints, shadows and outlines.",[{metadataGroups:["building"],layerTypes:["fill","line"]}]),"buildings.3d":cn("Extruded 3D buildings (hidden by default in the standard styles).",[{metadataGroups:["area_3d","building"],layerTypes:["fill-extrusion"]}]),"traffic.flow.freeColor":pn("Traffic flow colour for free-flowing roads.","free flow"),"traffic.flow.slowColor":pn("Traffic flow colour for slow traffic.","slow flow"),"traffic.flow.queueingColor":pn("Traffic flow colour for queueing traffic.","queueing flow"),"traffic.flow.stationaryColor":pn("Traffic flow colour for stationary traffic.","stationary flow"),"traffic.flow.closedColor":hn("Traffic flow colour for closed roads.","line-color",[an("closed road",!0)]),"traffic.flow.widthFactor":ln("Width of the traffic flow tubes.",[{type:"scale",property:"line-width",layers:[{sources:[Mt],layerTypes:["line"]}]}],en),"traffic.incidents.minorColor":yn("Traffic incident tube colour for minor delays.","minor jam"),"traffic.incidents.moderateColor":yn("Traffic incident tube colour for moderate delays.","moderate jam"),"traffic.incidents.majorColor":yn("Traffic incident tube colour for major delays.","major jam"),"traffic.incidents.closedColor":hn("Traffic incident tube colour for closed roads.","line-color",[nn("closed road",!0)]),"traffic.incidents.widthFactor":ln("Width of the traffic incident tubes.",[{type:"scale",property:"line-width",layers:[{sources:[Ot],layerTypes:["line"]}]}],en),"colors.land":un("land"),"colors.water":un("water"),"colors.vegetation":un("vegetation"),"colors.park":un("park"),"colors.artificial":un("artificial"),"colors.roadMajor":un("roadMajor"),"colors.road":un("road"),"colors.roadOutline":un("roadOutline"),"colors.label":un("label"),"colors.labelOutline":un("labelOutline"),"view.projection":{kind:"enum",description:"How the map is drawn: flat Mercator or a globe. The globe flattens to Mercator between zoom 11 and 12 by design.",options:["mercator","globe"],appliesTo:"any-style",mechanisms:[{type:"projection"}]},"view.sky":{kind:"toggle",description:"A sky with atmosphere behind the globe and above a tilted flat map. Without it MapLibre draws a fully transparent sky, so a globe arrives with no atmosphere.",appliesTo:"any-style",mechanisms:[{type:"sky"}]},"view.skyColor":{kind:"color",description:"Colour of the sky (and of the atmosphere halo around the globe). Defaults to a daylit blue on a light style and a night blue on a dark one.",appliesTo:"any-style",mechanisms:[{type:"sky"}]},"view.horizonColor":{kind:"color",description:"Colour of the sky at the horizon. Defaults with the style theme, so a dark map gets a dim horizon rather than a white one.",appliesTo:"any-style",mechanisms:[{type:"sky"}]},"view.spaceColor":{kind:"color",description:"Colour behind the map, which a globe leaves visible around the planet. The map canvas is transparent, so without this the page background shows through. Defaults with the style theme: white on a light style, near-black on a dark one.",appliesTo:"any-style",mechanisms:[{type:"space"}]},"view.terrain":{kind:"toggle",description:"3D terrain from the style's elevation source (the hillshade style part). Needs a tilted camera to show; MapLibre's terrain fog starts at pitch 60, which is also its default maxPitch.",appliesTo:"any-style",mechanisms:[{type:"terrain"}]},"view.terrainExaggeration":{kind:"number",description:"Vertical exaggeration of the 3D terrain (1 = true elevation).",range:{min:.5,max:3,step:.1},appliesTo:"any-style",mechanisms:[{type:"terrain"}]}},mn=Object.keys(fn),gn=mn.filter(e=>"color"===fn[e].kind),_n={"data-viz":{name:"Data visualisation",description:"A quiet base for your own data on top: fewer labels and markers, thinner roads, no badges competing with the overlay.",settings:{"labels.sizeFactor":.9,"symbols.sizeFactor":.9,"roads.widthFactor":.8,"roads.exitNumbers":!1,"roads.shields":!1,"roads.arrows":!1,"pois.microMarkers":!1,"pois.minZoom":14,"buildings.3d":!1}},"night-driving":{name:"Night driving",description:"Bigger labels and shields, wider roads and traffic tubes, POIs out of the way until close up.",settings:{"labels.sizeFactor":1.2,"symbols.sizeFactor":1.2,"roads.widthFactor":1.2,"roads.exitNumbers":!0,"roads.shields":!0,"roads.arrows":!0,"pois.minZoom":13,"pois.microMarkers":!1,"traffic.flow.widthFactor":1.3,"buildings.3d":!1}},minimal:{name:"Minimal",description:"The bare map: land, water, roads and the main place names. Everything decorative off.",settings:{"labels.sizeFactor":.9,"roads.exitNumbers":!1,"roads.shields":!1,"roads.arrows":!1,"roads.restricted":!1,"roads.underConstruction":!1,"buildings.footprints":!1,"buildings.3d":!1,"pois.microMarkers":!1,"pois.minZoom":16}},globe:{name:"Globe",description:"A globe with an atmosphere for the zoomed-out view; flattens to Mercator as you zoom in.",settings:{"view.projection":"globe","view.sky":!0}},terrain:{name:"Terrain",description:"3D terrain with a sky for tilted views. Needs the hillshade style part and a pitched camera.",settings:{"view.terrain":!0,"view.terrainExaggeration":1.2,"view.sky":!0}}},bn=Object.keys(_n),Ln=e=>"object"==typeof e&&null!==e&&!Array.isArray(e)&&Array.isArray(e.stops),Sn=(e,t)=>"number"==typeof e?(e=>Math.round(1e3*e)/1e3)(e*t):Ln(e)?In(e,t):Array.isArray(e)?"interpolate"===e[0]||"step"===e[0]?An(e,t):(e=>JSON.stringify(e).includes('"zoom"'))(e)?void 0:["*",t,e]:void 0,In=(e,t)=>{const i=[];for(const[r,s]of e.stops){const e=Sn(s,t);if(void 0===e)return;i.push([r,e])}return{...e,stops:i}},An=(e,t)=>{const i=[...e];for(let r="interpolate"===e[0]?4:2;r<i.length;r+=2){const e=Sn(i[r],t);if(void 0===e)return;i[r]=e}return i},En=(e,t)=>{let i=!1;const r=e=>Array.isArray(e)?"-"===e[0]&&3===e.length&&Array.isArray(e[1])&&"zoom"===e[1][0]&&"number"==typeof e[2]?(i=!0,["-",["zoom"],e[2]+t]):e.map(r):e;return{filter:r(e),patched:i}},Rn=/* @__PURE__ */new Set(["motorway","trunk","primary"]),vn=e=>(Array.isArray(e)?e:[e]).some(e=>"string"==typeof e&&Rn.has(e))?"major":"minor",Tn=(e,t,i=void 0)=>{if((e=>{const t="string"==typeof e?ye(e):void 0;return void 0!==t&&t[3]>0})(e))return t(e,i);if(Array.isArray(e)){if("match"===(r=e)[0]&&Array.isArray(r[1])&&"get"===r[1][0]&&("category"===r[1][1]||"road_category"===r[1][1])){const i=[e[0],e[1]];for(let r=2;r<e.length-1;r+=2)i.push(e[r],Tn(e[r+1],t,vn(e[r])));return i.push(Tn(e[e.length-1],t,"minor")),i}return e.map(e=>Tn(e,t,i))}var r;return Ln(e)?{...e,stops:e.stops.map(([e,r])=>[e,Tn(r,t,i)])}:e},wn=(e,t=()=>!0)=>{let i;for(const{literal:r,roadClass:s}of(e=>{const t=[];return Tn(e,(e,i)=>(t.push({literal:e,roadClass:i}),e)),t})(e)){if(!t(s))continue;const e=ye(r)?.[1]??0;(!i||e>i.saturation)&&(i={literal:r,saturation:e})}return i?.literal},Cn=(e,t)=>{const i=ye(e),r=ye(t);if(!i||!r)return;const s=i[1]<8||r[1]<8;if(!s&&(o=i[0],a=r[0],Math.abs((o-a+540)%360-180)>40))return;var o,a;const n=me(e,t);return n&&(s?{...n,hue:0}:n)},On=/* @__PURE__ */new Set(["text-size","icon-size","visibility"]),Mn=/* @__PURE__ */new Set(["line-width","fill-color","fill-outline-color","line-color","text-color","text-halo-color","fill-extrusion-color","background-color"]),Nn=16,xn=1,Dn=1,Fn="visible",kn=0,Pn=24,Un=(e,t)=>`${e}|${t}`,Hn={light:{"sky-color":"#88c6fc","horizon-color":"#ffffff","sky-horizon-blend":.8,"atmosphere-blend":.8,"fog-color":"#ffffff","fog-ground-blend":.5,"horizon-fog-blend":.8},dark:{"sky-color":"#0a1626","horizon-color":"#2b4a72","sky-horizon-blend":.8,"atmosphere-blend":.8,"fog-color":"#0a1626","fog-ground-blend":.5,"horizon-fog-blend":.8}},Wn={light:"#ffffff",dark:"#0a1626"},Gn=/* @__PURE__ */new Set(["","transparent","rgba(0, 0, 0, 0)"]),Bn={"sky-color":"transparent","horizon-color":"transparent","fog-color":"transparent","fog-ground-blend":1,"atmosphere-blend":0},Vn=class e extends Ye{static async get(t,i){return await Ce(t),xt(t,e,()=>new e(t,i),i&&(e=>e.applyConfig({...e.config,...i})))}constructor(e,t){super(e,t)}styleChangePriority(){return 100}_initSourcesWithLayers(){return this.indexStyle(this.mapLibreMap.getStyle()),this.refreshSpace(this.config??{}),{}}_applyConfig(e){const t=Yn(e),i=/* @__PURE__ */new Set([...Kn(this.config),...Kn(t)]),r=this.reindexed?i:[...i].filter(e=>this.config?.[e]!==t[e]);this.reindexed=!1;for(const s of r)this.refreshKnob(s,t);return Object.keys(t).length?t:void 0}describe(){return{knobs:mn.map(e=>this.describeKnob(e)),presets:bn.map(e=>({id:e,..._n[e],settings:{..._n[e].settings}}))}}applyPreset(e,t={}){const i=_n[e];if(!i)throw new Error(`Unknown styling preset '${e}'. Known presets: ${bn.join(", ")}.`);this.applyConfig(t.merge?{...this.config,...i.settings}:{...i.settings})}get(e){return this.assertKnob(e),this.config?.[e]??this.defaultOf(e)}set(e,t){this.assertKnob(e),this.validate(e,t),this.config={...this.config,[e]:t},this.refreshKnob(e,this.config),this.emitConfigChange()}reset(e){if(void 0===e)return void this.resetConfig();this.assertKnob(e);const{[e]:t,...i}=this.config??{};this.config=Object.keys(i).length?i:void 0,this.refreshKnob(e,this.config??{}),this.emitConfigChange()}setMapColors(e){const t={};for(const[i,r]of Object.entries(e)){if(!Ja(i))throw new Error(`Unknown map colour '${i}'. Known colours: ${Xa.join(", ")}.`);if(void 0===r)continue;const e=zn(i);this.validate(e,r),t[e]=r}this.applyConfig({...this.config,...t})}exportStyle(){return structuredClone(this.mapLibreMap.getStyle())}get events(){return this.moduleEvents([])}indexStyle(e){const t=e?.layers??[];this.originalValues=/* @__PURE__ */new Map,this.styleSources=e?.sources??{},this.resolved=/* @__PURE__ */new Map,this.scaleKnobsByTarget=/* @__PURE__ */new Map,this.mapColorTargetsByKey=/* @__PURE__ */new Map,this.mapColorTargetsByKnob=/* @__PURE__ */new Map,this.mapColorAnchors=/* @__PURE__ */new Map,this.warned=/* @__PURE__ */new Set,this.reindexed=!0,this.mapLevelState={projection:e?.projection?.type??"mercator",sky:e?.sky,terrain:e?.terrain??void 0};for(const i of mn){const e=fn[i],r=e.mechanisms.map(e=>this.resolveMechanism(i,e,t)),s=new Set(r.flatMap(e=>e.layerIds)).size;this.resolved.set(i,{definition:e,mechanisms:r,targets:s}),0===s&&this.warnOnce(i,`knob '${i}' matches no layer in the loaded style (curated for style version ${Ur}); it will have no effect.`)}}resolveMechanism(e,t,i){if("mapColor"===t.type)return{mechanism:t,layerIds:this.resolveMapColor(t.color,i),shadeLayerIds:[]};if(!("layers"in t))return{mechanism:t,layerIds:"terrain"!==t.type||void 0!==this.demSourceId()?["\0map"]:[],shadeLayerIds:[]};const r=i.filter(e=>or(t.layers,e,this.styleSources));let s,o=[];switch(t.type){case"scale":s=r.filter(e=>this.capture(e,t.property)).map(e=>e.id);for(const i of s){const r=Un(i,t.property);this.scaleKnobsByTarget.set(r,[...this.scaleKnobsByTarget.get(r)??[],e])}break;case"color":{s=r.filter(e=>this.capture(e,t.property)).map(e=>e.id);const e=t.shades??[];o=i.filter(t=>or(e,t,this.styleSources)).filter(e=>this.capture(e,t.property)).map(e=>e.id);break}case"visibility":s=r.filter(e=>this.capture(e,"visibility")).map(e=>e.id);break;case"minZoom":s=r.map(e=>e.id);for(const e of r)this.capture(e,"minzoom"),this.capture(e,"maxzoom");break;case"zoomOffset":s=r.filter(e=>En(Zn(e),0).patched).map(e=>e.id)}return{mechanism:t,layerIds:s,shadeLayerIds:o}}capture(e,t){const i=Xn(e,t);return void 0!==i&&(this.originalValues.set(Un(e.id,t),i),!0)}originalValueOf(e,t){return this.originalValues.get(Un(e,t))}resolveMapColor(e,t){const i=zn(e),r=Za[e],s=[];for(const l of r.targets)for(const e of t.filter(e=>or(l.layers,e,this.styleSources)))for(const t of l.properties){if(!this.capture(e,t))continue;const r={knobId:i,layerId:e.id,property:t,owns:jn(l)};s.push(r);const o=Un(e.id,t);this.mapColorTargetsByKey.set(o,[...this.mapColorTargetsByKey.get(o)??[],r])}this.mapColorTargetsByKnob.set(i,s);const{anchor:o}=r,a=t.find(e=>or(o.layers,e,this.styleSources)&&void 0!==Xn(e,o.property)),n=a&&wn(Xn(a,o.property),jn({roadClass:o.roadClass}));return n&&this.mapColorAnchors.set(i,n),n?[...new Set(s.map(e=>e.layerId))]:[]}demSourceId(){return Object.entries(this.styleSources).find(([,e])=>"raster-dem"===e.type)?.[0]}refreshKnob(e,t){const i=this.resolved.get(e);if(i&&this.tomtomMap.mapReady)for(const r of i.mechanisms)this.refreshMechanism(e,r,t)}refreshMechanism(e,{mechanism:t,layerIds:i,shadeLayerIds:r},s){const o=s[e];switch(t.type){case"scale":for(const e of i)this.refreshScaledProperty(e,t.property,s);break;case"visibility":for(const e of i)this.refreshVisibility(e,o);break;case"color":this.refreshColor(t.property,i,r,o);break;case"minZoom":for(const e of i)this.refreshMinZoom(e,o);break;case"zoomOffset":for(const e of i)this.refreshZoomOffset(e,o);break;case"projection":this.refreshProjection(s);break;case"sky":this.refreshSky(s);break;case"terrain":i.length&&this.refreshTerrain(s);break;case"space":this.refreshSpace(s);break;case"mapColor":for(const{layerId:t,property:i}of this.mapColorTargetsByKnob.get(e)??[])this.refreshMapColorProperty(t,i,s)}}refreshSpace(e){const t=this.mapLibreMap.getContainer();this.originalSpaceColor??=qn(t),t.style.backgroundColor=e["view.spaceColor"]??this.defaultSpaceColor()}defaultSpaceColor(){return this.originalSpaceColor||Wn[this.tomtomMap.styleLightDarkTheme]}refreshMapColorProperty(e,t,i){const r=this.originalValueOf(e,t),s=[];for(const{knobId:o,owns:a}of this.mapColorTargetsByKey.get(Un(e,t))??[]){const e=i[o],t=this.mapColorAnchors.get(o);"string"==typeof e&&t&&s.push({anchorColor:t,newColor:e,owns:a})}this.setProperty(e,t,s.length?((e,t)=>{const i=[...t].reverse();return Tn(e,(e,t)=>{for(const{anchorColor:r,newColor:s,owns:o}of i){if(o&&!o(t))continue;const i=Cn(r,e);if(i)return ge(s,i)??e}return e})})(r,s):r)}refreshProjection(e){const t=e["view.projection"];this.mapLibreMap.setProjection({type:t??this.mapLevelState.projection})}refreshSky(e){const t=this.mapLevelState.sky,i=e["view.sky"]??this.defaultOf("view.sky"),r=Hn[this.tomtomMap.styleLightDarkTheme],s=i?{...r,...t,"sky-color":e["view.skyColor"]??t?.["sky-color"]??r["sky-color"],"horizon-color":e["view.horizonColor"]??t?.["horizon-color"]??r["horizon-color"]}:Bn;this.mapLibreMap.setSky(s,{validate:!1})}refreshTerrain(e){const t=this.mapLevelState.terrain,i=void 0!==t;if(!(e["view.terrain"]??i))return void this.mapLibreMap.setTerrain(null);const r=t?.source??this.demSourceId();if(!r)return;const s=e["view.terrainExaggeration"]??t?.exaggeration??1;this.mapLibreMap.setTerrain({source:r,exaggeration:s})}refreshVisibility(e,t){void 0!==t?this.setProperty(e,"visibility",t?"visible":"none"):this.setProperty(e,"visibility",this.originalValueOf(e,"visibility"))}refreshMinZoom(e,t){if(!this.mapLibreMap.getLayer(e))return;const i=t??this.originalValueOf(e,"minzoom")??kn,r=this.originalValueOf(e,"maxzoom")??Pn;this.mapLibreMap.setLayerZoomRange(e,i,r)}refreshZoomOffset(e,t){this.filterComposer.setTransform(e,"styling.zoomShift",void 0===t?void 0:e=>En(e,t).filter)}refreshScaledProperty(e,t,i){const r=this.originalValueOf(e,t),s=(this.scaleKnobsByTarget.get(Un(e,t))??[]).reduce((e,t)=>e*(i[t]??1),1);if(1===s)return void this.setProperty(e,t,r);const o=Sn(r,s);void 0!==o?this.setProperty(e,t,o):this.warnOnce(`scale:${e}:${t}`,`cannot scale '${t}' of layer '${e}': the style gives it a value this knob cannot scale (a non-numeric value, or an expression holding a nested zoom term); leaving it as the style defines it.`)}refreshColor(e,t,i,r){for(const o of t)this.setProperty(o,e,r??this.originalValueOf(o,e));const s=t.map(t=>this.originalValueOf(t,e)).find(fe);for(const o of i){const t=this.originalValueOf(o,e);let i=t;if(void 0!==r){const e=fe(t)&&s&&me(s,t);i=(e&&ge(r,e))??r}this.setProperty(o,e,i)}}setProperty(e,t,i){if(!this.mapLibreMap.getLayer(e))return;const r=this.mapLibreMap;On.has(t)?r.setLayoutProperty(e,t,i,{validate:!1}):Mn.has(t)&&r.setPaintProperty(e,t,i,{validate:!1})}describeKnob(e){const t=this.resolved.get(e),i=t?.definition??fn[e],r=t?.targets??0;return mt(e,i.kind,i.description,this.defaultOf(e),this.config?.[e],{...i.range&&{range:i.range},...i.options&&{options:i.options},available:r>0,appliesTo:i.appliesTo})}defaultOf(e){const t=this.resolved.get(e);if(!t)return;const{definition:i,mechanisms:r}=t;if("factor"===i.kind)return 1;const[s]=r,[o]=s?.layerIds??[];if(void 0!==o){if("mapColor"===s.mechanism.type)return this.mapColorAnchors.get(e);if(!("layers"in s.mechanism))return this.mapLevelDefaultOf(e);switch(s.mechanism.type){case"visibility":return"none"!==this.originalValueOf(o,"visibility");case"color":{const e=this.originalValueOf(o,s.mechanism.property);return fe(e)?e:void 0}case"minZoom":return this.originalValueOf(o,"minzoom")??kn;case"zoomOffset":return 0;default:return}}}mapLevelDefaultOf(e){const{projection:t,sky:i,terrain:r}=this.mapLevelState;switch(e){case"view.projection":return"string"==typeof t?t:void 0;case"view.sky":return void 0!==i&&0!==i["atmosphere-blend"]&&"transparent"!==i["sky-color"];case"view.skyColor":return fe(i?.["sky-color"])?i["sky-color"]:Hn[this.tomtomMap.styleLightDarkTheme]["sky-color"];case"view.horizonColor":return fe(i?.["horizon-color"])?i["horizon-color"]:Hn[this.tomtomMap.styleLightDarkTheme]["horizon-color"];case"view.spaceColor":return this.defaultSpaceColor();case"view.terrain":return void 0!==r;case"view.terrainExaggeration":return r?.exaggeration??1;default:return}}assertKnob(e){if(!(e in fn))throw new Error(`Unknown styling knob '${e}'. Call describe() for the catalogue of knob ids.`)}validate(e,t){const{kind:i,range:r,options:s}=fn[e];switch(i){case"toggle":if("boolean"!=typeof t)throw new RangeError(`Knob '${e}' expects true or false; got ${$n(t)}.`);break;case"enum":if("string"!=typeof t||!s?.includes(t))throw new RangeError(`Knob '${e}' expects one of ${s?.join(", ")}; got ${$n(t)}.`);break;case"color":if(!fe(t))throw new RangeError(`Knob '${e}' expects a CSS colour (#rrggbb, hsl(), rgb() or a named colour); got ${$n(t)}.`);break;default:if("number"!=typeof t||!Number.isFinite(t))throw new RangeError(`Knob '${e}' expects a number; got ${$n(t)}.`);if(r&&(t<r.min||t>r.max))throw new RangeError(`Knob '${e}' expects a number between ${r.min} and ${r.max}; got ${t}.`)}}warnOnce(e,t){this.warned.has(e)||(this.warned.add(e),console.warn(`[StylingModule] ${t}`))}},zn=e=>`colors.${e}`,jn=e=>"major"===e.roadClass?e=>"major"===e:"minor"===e.roadClass?e=>"major"!==e:()=>!0,$n=e=>"string"==typeof e?`'${e}'`:String(e),Kn=e=>Object.keys(e??{}).filter(e=>e in fn),Yn=e=>Object.fromEntries(Object.entries(e??{}).filter(([,e])=>void 0!==e)),qn=e=>{const t=getComputedStyle(e).backgroundColor;return Gn.has(t)?"":t},Zn=e=>"filter"in e?e.filter:void 0,Xn=(e,t)=>{const i="layout"in e?e.layout:void 0,r="paint"in e?e.paint:void 0;switch(t){case"text-size":return"symbol"===e.type&&void 0!==i?.["text-field"]?i["text-size"]??Nn:void 0;case"icon-size":return"symbol"===e.type&&void 0!==i?.["icon-image"]?i["icon-size"]??xn:void 0;case"line-width":return"line"===e.type?r?.["line-width"]??Dn:void 0;case"visibility":return i?.visibility??Fn;case"minzoom":return e.minzoom;case"maxzoom":return e.maxzoom;default:return r?.[t]}},Jn=["factor","number","toggle","color","enum"],Qn=["any-style","tomtom-styles"],el=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=Ge(s),this.applyStyle(i,r)},this.getStyle=()=>this._params.style,this._params=S(e),void 0===this._params.style&&(this._params={...this._params,style:Pr}),this._styleLightDarkTheme=Ge(this._params.style),this.ensureMapLibreCSSLoaded(),F(4),this.styleGivenToMapLibre=Br(this._params),this.mapLibreMap=new M({validateStyle:!1,maxTileCacheZoomLevels:22,cancelPendingTileRequestsWhileZooming:!1,...(t=this._params).mapLibre,style:Br(t),attributionControl:{compact:!1},transformRequest:Me(t)}),this.mapLibreMap.once("style.load",()=>{this.handleStyleData()}),this._eventsProxy=new ft(this.mapLibreMap,this._params?.events),this.loadRTLTextPlugin()}loadRTLTextPlugin(){setTimeout(()=>{["deferred","loaded"].includes(N())||D("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@${x()}/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=Br(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",o),t()},o=e=>{"sourceId"in e||(this.mapLibreMap.off("style.load",s),this.mapLibreMap.off("error",o),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",o),this.mapLibreMap.setStyle(e,{validate:!1})})}isSuperseded(e){return e!==this.styleRequestSequence}async notifyHandlers(e,t){const i=[...this.styleChangeHandlers].sort((e,t)=>(e.priority??0)-(t.priority??0));for(const s of i)try{await(s[e]?.(t))}catch(r){console.error(r)}}_setTomTomUserAgent(e){this._params={...this._params,"tomtom-user-agent":e},this.mapLibreMap.setTransformRequest(Me(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 st(this.mapLibreMap,[Ot,Mt,wt]))this.mapLibreMap.setLayoutProperty(t.id,"visibility","none",{validate:!1});Ve(this._params.style)&&!Be(this._params.style)&&(this._styleLightDarkTheme=(e=>{const t=e?.layers?.find(e=>"background"===e?.type);if(!t)return;const i=ze(t.paint?.["background-color"]),r=void 0===i?void 0:_e(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(Ae,`${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)}}},tl="#2dc653",il="#f5a623",rl="#e03030",sl=()=>[{value:0,color:tl},{value:50,color:il},{value:100,color:rl}],ol=()=>[{value:0,color:rl},{value:50,color:il},{value:100,color:tl}],al={visible:!0,displayMode:"hexgrid-3d",activeMetric:"congestionLevel",metricConfig:{congestionLevel:{color:{valueType:"raw",stops:sl()},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},speed:{color:{valueType:"relativeToPredefinedRangePCT",stops:ol()},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},travelTime:{color:{valueType:"relativeToPredefinedRangePCT",stops:sl()},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},freeFlowSpeed:{color:{valueType:"relativeToPredefinedRangePCT",stops:ol()},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"predefinedRange"}},networkLength:{color:{valueType:"relativeToActualRangePCT",stops:sl()},height:{maxHeightMeters:1e3,minHeightMeters:0,scaleMode:"currentRange"}}},regionPolygon:{fillOpacity:0,outlineOpacity:.5,outlineWidth:2,inverted:!1}},nl="#ffffff",ll=e=>"dark"===e?"#FFFFFF":"#000000",cl={trafficLight:[tl,il,rl],heat:["#2196F3","#FF9800","#F44336"],monochrome:["#e0e0e0","#888888","#1a1a1a"],viridis:["#fde725","#35b779","#31688e","#440154"],plasma:["#f0f921","#ed7953","#9c179e","#0d0887"]},hl={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}},ul=e=>"speed"===e||"freeFlowSpeed"===e,dl=e=>e?.activeMetric??al.activeMetric,pl=e=>{return"string"==typeof e?(t=cl[e]).map((e,i)=>({value:1===t.length?0:i/(t.length-1),color:e})):e.stops;var t},yl=e=>{if("top"!==e)return e?vt[e]:vt.lowestLabel},fl=e=>{if("top"!==e)return e?vt[e]:vt.lowestPlaceLabel},ml=(e,t,i)=>{const r=t??al.metricConfig[e].color??"trafficLight",s=pl(r);let o;if("string"==typeof r){const{min:t,max:i}=hl[e],r=ul(e)?[...s].reverse().map(e=>e.color):s.map(e=>e.color);o=s.map(({value:e},s)=>[t+e*(i-t),r[s]])}else if("relativeToPredefinedRangePCT"===r.valueType){const{min:t,max:i}=hl[e];o=s.map(({value:e,color:r})=>[t+e/100*(i-t),r])}else if("relativeToActualRangePCT"===r.valueType){const{min:t,max:r}=i??hl[e];o=s.map(({value:e,color:i})=>[t+e/100*(r-t),i])}else o=s.map(({value:e,color:t})=>[e,t]);return["interpolate",["linear"],["get",e],...o.flatMap(([e,t])=>[e,t])]},gl=(e,t)=>{const i=t??al.metricConfig[e].color??"trafficLight",r=pl(i);let s;if("string"==typeof i){const t=ul(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]},_l=(e,t,i)=>{const r=al.metricConfig[e].height,s=t?.minHeightMeters??r.minHeightMeters??0;if("raw"===t?.scaleMode){const i=t.scaleFactor??1;if("speed"===e){const{max:t}=hl[e];return["max",s,["*",["-",t,["coalesce",["get","speed"],0]],i]]}return["max",s,["*",["coalesce",["get",e],0],i]]}const o=t?.maxHeightMeters??r.maxHeightMeters??1e3,{min:a,max:n}="currentRange"===(t?.scaleMode??r.scaleMode)?i??hl[e]:hl[e],l=n-a||1;return"speed"===e?["max",s,["*",["/",["-",n,["coalesce",["get","speed"],0]],l],o]]:["max",s,["*",["/",["-",["coalesce",["get",e],0],a],l],o]]},bl=(e,t,i)=>{const r=dl(t),s=t?.metricConfig?.[r],{min:o,max:a}=i??hl[r];return{id:e,type:"heatmap",beforeID:yl(t?.beforeLayerConfig?.heatmap),paint:{"heatmap-weight":["interpolate",["linear"],["get",r],o,0,a,1],"heatmap-intensity":["interpolate",["linear"],["zoom"],10,.5,14,2,16,4],"heatmap-color":gl(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]}}},Ll=(e,t,i)=>{const r=dl(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:yl(t?.beforeLayerConfig?.hexgrid?.flat2D),paint:{"fill-color":ml(r,s?.color,i),"fill-opacity":.6}}},Sl=(e,t,i)=>{const r=dl(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:fl(t?.beforeLayerConfig?.hexgrid?.extrusion3D),paint:{"fill-extrusion-color":ml(r,s?.color,i),"fill-extrusion-height":_l(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},Il=(e,t,i)=>{const r=dl(t),s=t?.metricConfig?.[r];return{id:e,type:"fill",beforeID:yl(t?.beforeLayerConfig?.square?.flat2D),paint:{"fill-color":ml(r,s?.color,i),"fill-opacity":.6}}},Al=(e,t,i)=>{const r=dl(t),s=t?.metricConfig?.[r];return{id:e,type:"fill-extrusion",beforeID:fl(t?.beforeLayerConfig?.square?.extrusion3D),paint:{"fill-extrusion-color":ml(r,s?.color,i),"fill-extrusion-height":_l(r,s?.height,i),"fill-extrusion-base":0,"fill-extrusion-opacity":.75}}},El=e=>({...al.regionPolygon,...e}),Rl=(e,t,i)=>{const{color:r,fillOpacity:s}=El(t?.regionPolygon);return{id:e,type:"fill",beforeID:yl(),paint:{"fill-color":r??ll(i),"fill-opacity":s}}},vl=(e,t,i)=>{const{color:r,outlineOpacity:s,outlineWidth:o}=El(t?.regionPolygon);return{id:e,type:"line",beforeID:yl(),paint:{"line-color":r??ll(i),"line-opacity":s,"line-width":o}}},Tl=(e,t)=>({id:e,type:"line",beforeID:t,filter:["has","eventState"],paint:{"line-color":nl,"line-width":["case",Li,3,2],"line-opacity":["case",Li,1,.8]}}),wl=e=>({...e,filter:["has","eventState"],paint:{...e.paint,"fill-extrusion-color":["case",Li,nl,nl],"fill-extrusion-height":["+",e.paint?.["fill-extrusion-height"],.5],"fill-extrusion-opacity":.6}}),Cl=(e,t,i)=>wl(Sl(e,t,i)),Ol=(e,t,i)=>wl(Al(e,t,i)),Ml=(e,t,i)=>((e,t,i)=>{const r=[];for(let s=0;s<e.length;s++){const o=e[s];if(!o)continue;const{congestionSum:a,speedSum:n,freeFlowSum:l,travelTimeSum:c,networkLengthSum:h,count:u}=o,d=`${i}-${s}`;r.push({type:"Feature",id:d,geometry:t.features[s].geometry,properties:{id:d,congestionLevel:Math.round(a/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(R(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),Nl=.005,xl=(e,t,i,r)=>{const s=[];for(let o=0;o<e.features.length;o++){const a=e.features[o],n=a.properties?.tiledData?.tiles??[];if(0===n.length)continue;const l=d(a);if(!l)continue;const c=i([l[0]-Nl,l[1]-Nl,l[2]+Nl,l[3]+Nl],t);s.push(...Ml(n,c,`${r}-${o}`))}return{type:"FeatureCollection",features:s}},Dl=class e extends Ke{static async create(t,i){return await Ce(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}`,o=`area-analytics-square-${i}`,a=`area-analytics-region-${i}`,n=`${r}-layer`,l=`${s}-fill`,c=`${s}-extrusion`,h=`${s}-outline`,u=`${s}-extrusion-highlight`,d=`${o}-fill`,p=`${o}-extrusion`,y=`${o}-outline`,f=`${o}-extrusion-highlight`,m=`${a}-fill`,g=`${a}-line`,_=this.lightDark;this.heatmapLayerSpec=bl(n,e),this.hexFillLayerSpec=Ll(l,e),this.hexExtrusionLayerSpec=Sl(c,e),this.squareFillLayerSpec=Il(d,e),this.squareExtrusionLayerSpec=Al(p,e),this.regionFillLayerSpec=Rl(m,e,_),this.regionLineLayerSpec=vl(g,e,_),this.hexOutlineLayerSpec=((e,t)=>Tl(e,yl(t?.beforeLayerConfig?.hexgrid?.flat2D)))(h,e),this.hexExtrusionHighlightLayerSpec=Cl(u,e),this.squareOutlineLayerSpec=((e,t)=>Tl(e,yl(t?.beforeLayerConfig?.square?.flat2D)))(y,e),this.squareExtrusionHighlightLayerSpec=Ol(f,e);const b={heatmap:new lt(this.mapLibreMap,r,[this.heatmapLayerSpec]),hexgrid:new lt(this.mapLibreMap,s,[this.hexFillLayerSpec,this.hexExtrusionLayerSpec]),square:new lt(this.mapLibreMap,o,[this.squareFillLayerSpec,this.squareExtrusionLayerSpec]),region:new lt(this.mapLibreMap,a,[this.regionFillLayerSpec,this.regionLineLayerSpec])};return this.addHighlightLayersToMap(s,o),b}_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(al.metricConfig),r=Object.fromEntries(i.map(e=>[e,t?.[e]??al.metricConfig[e]])),s={activeMetric:al.activeMetric,displayMode:al.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)=>xl(e,t,(e,t)=>w(e,t,{units:"kilometers"}),"hex"))(e),{automaticVisibility:!1}),this.sourcesWithLayers.square.show(((e,t=.5)=>xl(e,t,(e,t)=>O(e,t,{units:"kilometers"}),"square"))(e),{automaticVisibility:!1});const t=this.config?.regionPolygon?.inverted??al.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(al.metricConfig),r=t??i,s={...this.config?.metricConfig};if(void 0===e)for(const o of r){const{color:e,...t}=s[o]??{};s[o]=t}else if("string"==typeof e){const t=(e=>{const t=pl(e),i=e=>{const{min:i,max:r}=hl[e],s=ul(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 o of r)s[o]={...s[o],color:e};this.config={...this.config,metricConfig:s},this.applyLayerConfig(this.config),this.emitConfigChange()}setHeight(e,t){const i=Object.keys(al.metricConfig),r=t??i,s={...this.config?.metricConfig};for(const o of r)s[o]={...s[o],height:e};this.config={...this.config,metricConfig:s},this.applyLayerConfig(this.config),this.emitConfigChange()}filter(e,t){const i=Object.keys(al.metricConfig),r=t??i,s={...this.config?.metricConfig};for(const o of r)s[o]={...s[o],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:vt[e];void 0!==e.heatmap&&Fe(this.mapLibreMap,this.heatmapLayerSpec.id,i(e.heatmap)),void 0!==e.hexgrid?.flat2D&&Fe(this.mapLibreMap,this.hexFillLayerSpec.id,i(e.hexgrid.flat2D)),void 0!==e.hexgrid?.extrusion3D&&Fe(this.mapLibreMap,this.hexExtrusionLayerSpec.id,i(e.hexgrid.extrusion3D)),void 0!==e.square?.flat2D&&Fe(this.mapLibreMap,this.squareFillLayerSpec.id,i(e.square.flat2D)),void 0!==e.square?.extrusion3D&&Fe(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??al.displayMode}get activeMetric(){return dl(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},De(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=bl(this.heatmapLayerSpec.id,e,t),r=Ll(this.hexFillLayerSpec.id,e,t),s=Sl(this.hexExtrusionLayerSpec.id,e,t),o=Cl(this.hexExtrusionHighlightLayerSpec.id,e,t),a=Il(this.squareFillLayerSpec.id,e,t),n=Al(this.squareExtrusionLayerSpec.id,e,t),l=Ol(this.squareExtrusionHighlightLayerSpec.id,e,t);Ne(i,this.heatmapLayerSpec,this.mapLibreMap),Ne(r,this.hexFillLayerSpec,this.mapLibreMap),Ne(s,this.hexExtrusionLayerSpec,this.mapLibreMap),Ne(o,this.hexExtrusionHighlightLayerSpec,this.mapLibreMap),Ne(a,this.squareFillLayerSpec,this.mapLibreMap),Ne(n,this.squareExtrusionLayerSpec,this.mapLibreMap),Ne(l,this.squareExtrusionHighlightLayerSpec,this.mapLibreMap),this.heatmapLayerSpec=i,this.hexFillLayerSpec=r,this.hexExtrusionLayerSpec=s,this.hexExtrusionHighlightLayerSpec=o,this.squareFillLayerSpec=a,this.squareExtrusionLayerSpec=n,this.squareExtrusionHighlightLayerSpec=l,this.applyFiltersToLayers()}applyRegionConfig(e){const t=this.lightDark,i=Rl(this.regionFillLayerSpec.id,e,t),r=vl(this.regionLineLayerSpec.id,e,t);if(Ne(i,this.regionFillLayerSpec,this.mapLibreMap),Ne(r,this.regionLineLayerSpec,this.mapLibreMap),this.regionFillLayerSpec=i,this.regionLineLayerSpec=r,this.lastAnalytics){const t=e?.regionPolygon?.inverted??al.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 o of i)this.mapLibreMap.setFilter(o,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}}})}}},Fl=e=>e.length?1===e.length?e[0]:["all",...e]:null,kl=(e,t)=>{e&&t.push(e)},Pl=(e,t,i)=>{e&&kl(Z(t,e),i)},Ul=(e,t)=>{Pl(e.roadCategories,"road_category",t),Pl(e.roadSubCategories,"road_subcategory",t)},Hl=e=>{const t=[];if(Ul(e,t),e.incidentCategories){const i=Z("icon_category_0",e.incidentCategories,A);kl(i,t)}if(e.magnitudes){const i=Z("magnitude_of_delay",e.magnitudes,e=>b.indexOf(e));kl(i,t)}return e.delays&&kl((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 Fl(t)})(e.delays),t),Fl(t)},Wl=e=>{if(!e?.any?.length)return null;const t=e.any.map(Hl).filter(e=>!i(e));return Y(t)},Gl=e=>{const t=[];if(Ul(e,t),e.showRoadClosures){const i="only"===e.showRoadClosures?"==":"!=";t.push([i,["get","road_closure"],!0])}return Fl(t)},Bl=(e,t,i,r)=>{for(const s of t)i.setClause(s.id,r,e)},Vl="traffic.flow",zl=class e extends Ye{static async get(t,i){return await Ce(t),await Ue(t,Mt,"trafficFlow"),xt(t,e,()=>new e(t,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const t=this.mapLibreMap.getSource(Mt);if(!t)throw Ie(`init ${e.name} with source ID ${Mt}`);return{trafficFlow:new ot(this.mapLibreMap,t)}}_applyConfig(e){return this._setVisible(e?.visible??!1,!1),this._filter(e?.filters,!1),e}getLayers(){return st(this.tomtomMap.mapLibreMap,[Mt])}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(Gl).filter(e=>!i(e));return Y(t)})(e);t&&Bl(t,this.getLayers(),this.filterComposer,Vl)}else this.config?.filters?.any?.length&&Bl(void 0,this.getLayers(),this.filterComposer,Vl);t&&(this.config=o({...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(ie)}}get events(){return this.moduleEvents(["trafficFlow"],{mapping:ie})}},jl="tt-traffic-incident-direction-chevron",$l='<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>',Kl=["interpolate",["exponential",1.5],["zoom"],5,0,9,.96,13,2.1,19,10.8],Yl=["interpolate",["exponential",1.5],["zoom"],5,.75,9,1.96,13,3.6,19,13.8],ql=e=>["match",["get","magnitudeOfDelay"],"unknown",e.unknown,"minor",e.minor,"moderate",e.moderate,"major",e.major,"indefinite",e.indefinite,e.major],Zl=["match",["get","magnitudeOfDelay"],"unknown","traffic-incidents-no_delay-pattern","indefinite","traffic-incidents-road_closed-pattern",""],Xl=e=>"dark"===e?"#FFF":"#000",Jl=["interpolate",["exponential",1.5],["zoom"],5,2.2,9,4.6,13,8.3,19,26],Ql=["case",["==",["feature-state","focused"],!0],1,0],ec=(e,t)=>{if(null===t)return e;const[i,r,s,...o]=e;return[i,r,s,...o.map((e,i)=>i%2==1?["case",["==",["feature-state","focused"],!0],e*t,e]:e)]},tc=["in",["get","magnitudeOfDelay"],["literal",["minor","moderate","major"]]],ic=["in",["get","magnitudeOfDelay"],["literal",["unknown","indefinite"]]],rc=(e,t,i,r)=>{const s=r?.widthScale??null,o=[];return null!==r&&o.push({id:`${e}-focus-halo`,type:"line",minzoom:6,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":r.outlineColor,"line-width":Jl,"line-blur":0,"line-opacity":Ql},beforeID:t}),o.push({id:`${e}-outline`,type:"line",minzoom:6,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":ql(i.outline),"line-width":ec(Yl,s)},beforeID:t},{id:`${e}-inner-solid`,type:"line",minzoom:6,filter:tc,layout:{"line-cap":"round","line-join":"round"},paint:{"line-color":ql(i.inner),"line-width":ec(Kl,s)},beforeID:t},{id:`${e}-inner-chevron`,type:"line",minzoom:12,filter:tc,layout:{"line-cap":"butt","line-join":"round"},paint:{"line-pattern":jl,"line-width":ec(Kl,s)},beforeID:t},{id:`${e}-inner-pattern`,type:"line",minzoom:6,filter:ic,layout:{"line-cap":"round","line-join":"round"},paint:{"line-pattern":Zl,"line-width":ec(Kl,s)},beforeID:t}),o},sc=["step",["zoom"],.7,14,.8,16,.9,18,1],oc=["step",["zoom"],12.6,14,14.4,16,16.2,18,18],ac=["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",""],nc=["all",["!=",["get","magnitudeOfDelay"],"indefinite"],["any",["!",["has","delayInSeconds"]],["step",["zoom"],[">",["get","delayInSeconds"],900],14,[">",["get","delayInSeconds"],600],15,[">",["get","delayInSeconds"],300],16,!0]]],lc=["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]],cc=["==",["get","magnitudeOfDelay"],"indefinite"],hc=["concat","traffic-jam-",["get","magnitudeOfDelay"],["case",["<",["get","delayInSeconds"],600],"-small",["<",["get","delayInSeconds"],3600],"-medium","-large"]],uc=["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"]],dc=["case",["has","delayInSeconds"],["*",-1,["get","delayInSeconds"]],0],pc=(e,t)=>[{id:`${e}-incident-marker`,type:"symbol",minzoom:13,filter:nc,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":ac,"icon-size":sc,"symbol-sort-key":dc},beforeID:t},{id:`${e}-jam-marker`,type:"symbol",minzoom:12,filter:lc,layout:{"symbol-placement":"point","icon-anchor":"bottom-left","icon-offset":[2,3],"icon-image":hc,"icon-size":sc,"icon-padding":0,"text-anchor":"bottom-left","text-field":uc,"text-font":["NotoSans-CondensedBold"],"text-offset":[2.7,-.75],"text-size":oc,"symbol-sort-key":dc},paint:{"text-color":"hsl(210, 30%, 14%)"},beforeID:t},{id:`${e}-closed-road-marker`,type:"symbol",minzoom:12,filter:cc,layout:{"symbol-placement":"point","symbol-avoid-edges":!0,"icon-anchor":"bottom-right","icon-offset":[-1,3],"icon-image":"traffic-incidents-road_closed","icon-size":sc},beforeID:t}],yc=["unknown","minor","moderate","major","indefinite"],fc={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"}},mc={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%)"},gc={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%)"},_c=(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)},bc=e=>{if("top"!==e)return e?vt[e]:vt.lowestLabel},Lc=class e extends Ke{static async create(t,i){return await Ce(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(Re())return sa||(sa=ve(Te($l))),sa})();s&&He("if-not-in-sprite",jl,s,this.mapLibreMap);const o=bc(e?.beforeLayerConfig),a=(e=>{const t=e.getStyle()?.layers??[],i=/* @__PURE__ */new Map;for(const o of t)i.set(o.id,o);const r={outline:{...mc},inner:{...gc}},s=[];for(const o of yc){const e=fc[o],t=_c(i.get(e.outline),e.outline,s),a=_c(i.get(e.inner),e.inner,s);t&&(r.outline[o]=t),a&&(r.inner[o]=a)}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??Xl(t),widthScale:e?.widthScale??1.6})(e?.focus,r),l=[...rc(i,o,a,n),...pc(i,o)];return{incidents:new lt(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=bc(e);for(const i of this.sourcesWithLayers.incidents.sourceAndLayerIDs.layerIDs)Fe(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})}},Sc="traffic.incidents",Ic=class t extends Ye{static async get(e,i){return await Ce(e),await Ue(e,Ot,"trafficIncidents"),xt(e,t,()=>new t(e,i),i&&(e=>e.applyConfig(i)))}constructor(e,t){super(e,t)}_initSourcesWithLayers(){const e=this.mapLibreMap.getSource(Ot);if(!e)throw Ie(`init ${t.name} with source ID ${Ot}`);return{trafficIncidents:new ot(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=Wl(e);if(i){const e=t?this.getNonSymbolLayers():this.getLayers();Bl(i,e,this.filterComposer,Sc)}}else this.config?.filters?.any?.length&&Bl(void 0,this.getLayers(),this.filterComposer,Sc);if(t?.any?.length){const e=Wl(t);e&&Bl(e,this.getSymbolLayers(),this.filterComposer,Sc)}}r&&(this.config=o({...this.config,filters:e,icons:{...this.config?.icons,filters:t}},i),this.emitConfigChange())}getLayers(){return st(this.tomtomMap.mapLibreMap,[Ot])}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={...o({...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(se)}}get events(){return this.moduleEvents(["trafficIncidents"],{mapping:se})}},Ac=["motorway","motorway_link","trunk","trunk_link","primary","primary_link","secondary","secondary_link","tertiary","tertiary_link","street","service","track"],Ec=["unclassified","residential","living_street"],Rc=["parking","driveway","alley"],vc=(e,t)=>({left:e.left-t.left,top:e.top-t.top,right:e.right-t.left,bottom:e.bottom-t.top}),Tc=(e,t,i)=>e.right<=0||e.left>=t||e.bottom<=0||e.top>=i,wc=(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)},Cc=(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)},Oc=(e,t,i,r,s)=>{const o=((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),a=e.left<=0&&e.right>=i,n=e.top<=0&&e.bottom>=r;if(a&&!n)return void wc(o,t,r,s);if(n&&!a)return void Cc(o,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 o=e.left,a=i-e.right,n=e.top,l=r-e.bottom,c=Math.min(o,a,n,l);c===o?t.left=Math.max(t.left,e.right+s):c===a?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)})(o,t,i,r,s):Cc(o,t,i,s):wc(o,t,r,s)},Mc=e=>"string"==typeof e?document.querySelector(e):e,Nc=e=>"mapLibreMap"in e?e.mapLibreMap:e,xc=(e,t,i)=>{const r=Nc(e).getContainer().getBoundingClientRect(),{width:s,height:o}=r,a={left:i,top:i,right:s-i,bottom:o-i};for(const n of t){const e=Mc(n);if(!e)continue;const t=e.getBoundingClientRect(),l=vc(t,r);Tc(l,s,o)||Oc(l,a,s,o,i)}return a.left>=a.right||a.top>=a.bottom?null:{visibleAreaBounds:a,mapWidthPX:s,mapHeightPX:o}},Dc=e=>{const{map:t,surroundingElements:i,paddingPX:r=0}=e,s=xc(t,i,r);if(!s)return null;const{visibleAreaBounds:o}=s,a=Nc(t),n=a.unproject([o.left,o.bottom]),l=a.unproject([o.right,o.top]);return[n.lng,n.lat,l.lng,l.lat]},Fc=e=>{const{map:t,surroundingElements:i}=e,r=Dc({map:t,surroundingElements:i});if(!r)return null;const[s,o,a,n]=r;return[(s+a)/2,(o+n)/2]},kc=e=>{const{map:t,toBeContainedBBox:i,surroundingElements:r,paddingPX:s=0}=e,o=xc(t,r,s);if(!o)return null;const{visibleAreaBounds:a,mapWidthPX:n,mapHeightPX:l}=o,c=a.left/n,h=a.right/n,u=a.top/l,d=h-c,p=a.bottom/l-u,[y,f,m,g]=i,_=(m-y)/d,b=(g-f)/p,L=y-c*_,S=g+u*b;return[L,S-b,L+_,S]};export{Ke as AbstractDataOwnedMapModule,$e as AbstractMapModule,rt as AbstractSourceWithLayers,Ye as AbstractStyleOwnedMapModule,at as AddedSourceWithLayers,Ct as BASE_MAP_SOURCE_ID,ur as BaseMapModule,k as CombinedEvents,pr as CustomGeoJSONModule,Ur as DEFAULT_STYLE_VERSION,It as DEFAULT_TEXT_SIZE,Xr as DESELECTED_FOREGROUND_COLOR,Jr as DESELECTED_OUTLINE_COLOR,is as DESELECTED_ROUTE_FILTER,Qr as DESELECTED_SECONDARY_COLOR,ft as EventsProxy,Bo as FINISH_INDEX,lt as GeoJSONSourceWithLayers,Tr as GeometriesModule,wt as HILLSHADE_SOURCE_ID,Dr as HillshadeModule,As as INDEFINITE_DELAY_DASH_COLOR,Q as LayerFilterComposer,ms as MAJOR_DELAY_COLOR,_t as MAP_BOLD_FONT,St as MAP_ITALIC_FONT,Lt as MAP_MEDIUM_FONT,bt as MAP_REGULAR_FONT,Go as MIDDLE_INDEX,_s as MINOR_DELAY_COLOR,bs as MINOR_DELAY_LABEL_COLOR,gs as MODERATE_DELAY_COLOR,ee as ModuleEvents,Tt as POI_SOURCE_ID,tr as POIsModule,qi as PlacesModule,qr as ROUTE_LINE_FOREGROUND_COLOR,es as ROUTE_LINE_FOREGROUND_WIDTH,Zr as ROUTE_LINE_OUTLINE_COLOR,rs as ROUTE_LINE_OUTLINE_WIDTH,Pa as RoutingModule,ts as SELECTED_ROUTE_FILTER,Wo as START_INDEX,Vo as STOP_DISPLAY_INDEX,ot as StyleSourceWithLayers,Vn as StylingModule,Mt as TRAFFIC_FLOW_SOURCE_ID,Ot as TRAFFIC_INCIDENTS_SOURCE_ID,el as TomTomMap,it as TomTomMapSource,Dl as TrafficAreaAnalyticsModule,zl as TrafficFlowModule,Lc as TrafficIncidentOverlayModule,Ic as TrafficIncidentsModule,Ss as UNKNOWN_DELAY_BG_COLOR,Ls as UNKNOWN_DELAY_COLOR,Is as UNKNOWN_DELAY_DASH_COLOR,je as UserEvents,Er as adaptPaletteForTheme,G as assertNoReservedScopeNames,ar as baseMapLayerGroupNames,Ut as baseMapPOICategoryValues,ao as bespokeSectionTypes,Hi as buildPlaceTitle,Cr as buildReachableRangeFeatures,ta as buildRoutingLayers,kc as calculateFittingBBox,Dc as calculatePaddedBBox,Fc as calculatePaddedCenter,Ar as colorPaletteIDs,Ir as colorPalettes,U as combineEventScopes,ia as defaultRoutingLayers,no as drawnSectionTypes,st as filterLayersBySources,Xe as findFeatureByRefId,oo as generatedSectionTypes,xr as geometryThemes,Gi as getIconIDForPlace,ys as getInstructionLineWidth,fs as getInstructionOutlineWidth,ns as getLineForegroundWidth,ls as getLineOutlineWidth,zi as getPOIGroupForPlace,Vi as getPOILayerCategoryForPlace,us as getSectionHaloWidth,Qi as getStyleCategories,cs as getWaypointIconSize,mt as knob,gt as knobSettings,Xa as mapColorNames,Ft as mapDisplayPoiCategoryMappings,At as mapFonts,vt as mapStyleLayerIDs,pe as parseCssColor,Zi as placesThemes,Xi as poiCategoryGroups,Dt as poiLayerIDs,Yi as preparePlacesForDisplay,Or as prepareReachableRangesForDisplay,Nr as reachableRangeGeometryConfig,Ze as renderedRefId,W as reservedScopeNames,pl as resolveColorStops,Ac as roadCategories,H as scopedLayerSpecs,po as sectionDrawsByDefault,fo as sectionSourceKey,ho as sectionSupportsKnob,Rc as serviceRoadSubCategories,xt as sharedInstance,Fr as standardStyleIDs,Ec as streetRoadSubCategories,kr as styleModules,gn as stylingColorKnobIds,Qn as stylingKnobAppliesTo,mn as stylingKnobIds,Jn as stylingKnobKinds,bn as stylingPresetIds,Mr as themedGeometryConfig,Pt as toBaseMapPOICategory,Wt as toBaseMapPOIGroup,ji as toPlaces};
2
2
  //# sourceMappingURL=map.es.js.map