@wemap/routers 12.11.0 → 12.11.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +102 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -4
package/dist/index.d.ts
CHANGED
|
@@ -32,5 +32,6 @@ export { default as RemoteRouterManager, type RemoteRouterName, type RoutingFall
|
|
|
32
32
|
export { default as ItineraryInfoManager, type ItineraryInfo } from './src/ItineraryInfoManager.js';
|
|
33
33
|
export { RoutingError, RemoteRoutingError, WemapMultiRoutingError } from './src/RoutingError.js';
|
|
34
34
|
export { default as InstructionManager } from './helpers/InstructionManager.js';
|
|
35
|
+
export { default as InstructionManagerV1 } from './helpers/InstructionManagerV1.js';
|
|
35
36
|
export { StatusCode } from './src/StatusCode.js';
|
|
36
37
|
export * from './src/Utils.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var e=Object.defineProperty,t=(t,r,o)=>(((t,r,o)=>{r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o})(t,"symbol"!=typeof r?r+"":r,o),o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@wemap/geo"),o=require("@wemap/maths"),i=require("@wemap/logger"),s=require("@wemap/salesman.js"),n=require("@wemap/osm"),a=require("@mapbox/polyline"),l=require("@turf/boolean-point-in-polygon"),d=require("@turf/convex");const c=class e{constructor(o,i,s={},n=e.currentUniqueId++){t(this,"level"),t(this,"bearing"),t(this,"length"),this.vertex1=o,this.vertex2=i,this.properties=s,this.id=n,this.level=r.Level.union(o.coords.level,i.coords.level),this.length=this.vertex1.distanceTo(this.vertex2),this.bearing=this.vertex1.bearingTo(this.vertex2)}static getEdgeByVertices(e,t,r){return e.find((e=>t===e.vertex1&&r===e.vertex2||r===e.vertex1&&t===e.vertex2))}reverseProperties(){const{properties:e}=this;e.incline&&(e.incline="up"===e.incline?"down":"up"),e.isOneway&&(e.isOneway=!1)}};t(c,"currentUniqueId",0);let u=c;class h{constructor(e,t,r,o){this.origin=e,this.distanceFromNearestElement=t,this.coords=r,this.nearestElement=o}}class p{constructor(e,r={}){t(this,"id",-1),this.coords=e,this.properties=r}distanceTo(e){return this.coords.distanceTo(e.coords)}bearingTo(e){return this.coords.bearingTo(e.coords)}toJson(){return{id:this.id,coords:this.coords.toCompressedJson(),...Object.keys(this.properties).length>0&&{properties:this.properties}}}static fromJson(e){const t=new p(r.Coordinates.fromCompressedJson(e.coords),e.properties);return t.id=e.id,t}}class m{constructor(e,r){t(this,"exitVertices"),this.vertices=e,this.edges=r;const o=r.filter((e=>null===e.level)).map((e=>[e.vertex1,e.vertex2])).flat(),i=r.filter((e=>null!==e.level)).map((e=>[e.vertex1,e.vertex2])).flat();this.exitVertices=new Set(o.filter((e=>i.includes(e))))}getEdgeByVertices(e,t){return u.getEdgeByVertices(this.edges,e,t)}getVertexByCoords(e){return m.getVertexByCoords(this.vertices,e)}static getVertexByCoords(e,t){return e.find((e=>e.coords.equals(t)))}getVertexByName(e){return this.vertices.find((t=>t.properties.name===e))}getEdgeByName(e){return this.edges.find((t=>t.properties.name===e))}getBoundingBox(e){if(!this.vertices.length)return null;const t=r.BoundingBox.fromCoordinates(this.vertices.map((e=>e.coords)));return e&&t.extendsWithMeasure(e),t}getProjection(e,t={}){const i="maxDistance"in t,s=t.maxDistance,n="maxBearingAngle"in t;if(n&&(!(e instanceof r.UserPosition)||null===e.bearing))return null;const a=t.maxBearingAngle,l="acceptEdgeFn"in t,d=!("useMultiLevelSegments"in t)||t.useMultiLevelSegments;let c=null;const u=t=>{if(!(e instanceof r.UserPosition))return t;const o=e.clone();return o.lat=t.lat,o.lng=t.lng,o.level=t.level,o.alt=t.alt,o.heightFromFloor=t.heightFromFloor,o.heightFromGround=t.heightFromGround,o};return this.edges.forEach((p=>{if(l&&!t.acceptEdgeFn(p))return;if(!d&&r.Level.isRange(p.level))return;if(!r.Level.intersect(p.level,e.level))return;if(n&&o.diffAngleLines(p.bearing,e.bearing)>a)return;const m=e.getSegmentProjection(p.vertex1.coords,p.vertex2.coords);if(!m)return;const g=m.distanceTo(e);i&&g>s||g<((null==c?void 0:c.distanceFromNearestElement)??Number.MAX_VALUE)&&(c=new h(e,g,u(m),p))})),n||this.vertices.forEach((t=>{let o=t.coords;if(this.exitVertices.has(t)&&null===e.level&&(o=t.coords.clone(),o.level=null),!d&&r.Level.isRange(o.level))return;if(!r.Level.intersect(o.level,e.level))return;const n=o.distanceTo(e);n<r.Constants.EPS_MM?c=new h(e,0,u(o),t):i&&n>s||n<((null==c?void 0:c.distanceFromNearestElement)??Number.MAX_VALUE)&&(c=new h(e,n,u(o),t))})),c}toJson(){return{vertices:this.vertices.map((e=>e.toJson())),edges:this.edges.map((e=>({id:e.id,vertex1Idx:this.vertices.indexOf(e.vertex1),vertex2Idx:this.vertices.indexOf(e.vertex2),...Object.keys(e.properties).length>0&&{properties:e.properties}})))}}static fromJson(e){const t=e.vertices.map((e=>p.fromJson(e))),r=e.edges.map((e=>new u(t[e.vertex1Idx],t[e.vertex2Idx],e.properties,e.id)));return new m(t,r)}toCompressedJson(){return{vertices:this.vertices.map((e=>e.coords.toCompressedJson())),verticesIds:this.vertices.map((e=>e.id)),edges:this.edges.map((e=>{const t=this.vertices.indexOf(e.vertex1),r=this.vertices.indexOf(e.vertex2),o=e.properties;return Object.keys(o).length>0?[t,r,o]:[t,r]}))}}static fromCompressedJson(e){const t=e.vertices.map((e=>new p(r.Coordinates.fromCompressedJson(e)))),o=e.edges.map((e=>new u(t[e[0]],t[e[1]],e.length>2?e[2]:{})));return new m(t,o)}static fromCoordinatesSegments(e){const t=[],r=[],o=e=>{const r=t.find((t=>t.coords.equals(e)));if(r)return r;const o=new p(e);return t.push(o),o};for(const i of e){let e=null;for(const t of i){const i=o(t);e&&r.push(new u(i,e)),e=i}}return new m(t,r)}getEdgesAtLevel(e,t=!0){return this.edges.filter((({level:o})=>t?r.Level.intersect(e,o):r.Level.contains(e,o)))}toDetailedString(){let e=`--- Network ---\nVertices: ${this.vertices.length}\nEdges: ${this.edges.length}\n---\nVertices\n`;return this.vertices.forEach((t=>{e+=t.id;const r=t.properties;0!==Object.keys(r).length&&(e+=` ${r}`)})),e+="---\nEdges\n",this.edges.forEach((t=>{e+=`${t.id} - [v1: ${t.vertex1.id}, v2: ${t.vertex2.id}]`;const r=t.properties;0!==Object.keys(r).length&&(e+=` ${r}`)})),e+="---",e}}function g(e,t=5){return e/(1e3*t/3600)}function f(e){return["AIRPLANE","BOAT","BUS","FERRY","FUNICULAR","METRO","MULTI","TRAIN","TRAM"].includes(e)}function w(e,t){return e===t||f(e)&&"TRANSIT"===t||"WALK"===e&&"TRANSIT"===t}function v(e){return{...e.firstStep&&{firstStep:!0},...e.lastStep&&{lastStep:!0},number:e.number,coords:e.coords.toCompressedJson(),...null!==e.name&&{name:e.name},angle:Number(e.angle.toFixed(2)),previousBearing:Number(e.previousBearing.toFixed(2)),nextBearing:Number(e.nextBearing.toFixed(2)),distance:Number(e.distance.toFixed(1)),duration:Number(e.duration.toFixed(1)),...null!==e.levelChange&&{levelChange:e.levelChange},...e.extras&&0!==Object.keys(e.extras).length&&{extras:e.extras}}}function b(e){return Object.assign({},e,{coords:r.Coordinates.fromCompressedJson(e.coords),firstStep:Boolean(e.firstStep),lastStep:Boolean(e.lastStep),name:e.name||null,levelChange:e.levelChange||null,extras:e.extras||null})}function y(e,t){var r,o,i,s,n,a;return e.coords.equals(t.coords)&&Math.abs(e.angle-t.angle)<=.005&&Math.abs(e.distance-t.distance)<=.05&&Math.abs(e.duration-t.duration)<=.05&&e.firstStep===t.firstStep&&e.lastStep===t.lastStep&&(null==(r=e.levelChange)?void 0:r.difference)===(null==(o=t.levelChange)?void 0:o.difference)&&(null==(i=e.levelChange)?void 0:i.direction)===(null==(s=t.levelChange)?void 0:s.direction)&&(null==(n=e.levelChange)?void 0:n.type)===(null==(a=t.levelChange)?void 0:a.type)&&e.name===t.name&&Math.abs(e.nextBearing-t.nextBearing)<=.005&&e.number===t.number&&Math.abs(e.previousBearing-t.previousBearing)<=.005}class T extends m{constructor(e,t,r,o,i){super(r,o),this.start=e,this.end=t,this.vertices=r,this.edges=o,this.edgesWeights=i}reverse(){const e=this.vertices.slice().reverse(),t=this.edges.slice().reverse(),r=this.edgesWeights.slice().reverse();return t.map((e=>new u(e.vertex2,e.vertex1,e.properties))),new T(this.start,this.end,e,t,r)}static fromCoordinates(e,t,r){const o=m.fromCoordinatesSegments([r]),i=o.edges.map((e=>g(e.length)));return new T(e,t,o.vertices,o.edges,i)}get hasRoute(){return Boolean(this.vertices.length)}}const S=o.deg2rad(20);class x{constructor(){t(this,"start",null),t(this,"end",null),t(this,"pathCoords",null),t(this,"stepsInfo",[])}setStart(e){return this.start=e,this}setEnd(e){return this.end=e,this}setPathCoords(e){return this.pathCoords=e,this}setStepsInfo(e){return this.stepsInfo=e,this}addStepInfo(e){return this.stepsInfo.push(e),this}setGraphRoute(e){const t=[],{start:i,end:s}=e;if(!e.hasRoute)return this;let n=null,a=i.bearingTo(e.vertices[0].coords);for(let d=0;d<e.vertices.length-1;d++){const i=0===d,s=e.vertices[d],l=s.coords,c=e.vertices[d+1],u=c.coords,h=e.edges[d],p=s.bearingTo(c),m=o.diffAngle(a,p+Math.PI),g=t.length?t[t.length-1]:null,{isSubwayEntrance:f,isGate:w,subwayEntranceRef:v}=s.properties,{isElevator:b,areEscalators:y,areStairs:T,isMovingWalkway:x,incline:_}=h.properties;let N,E=null;E=b?"elevator":y?"escalator":T?"stairs":x?"moving walkway":"incline plane",(T||b)&&_&&!(null==g?void 0:g.levelChange)&&(N=_);const C=d>0?e.edges[d-1]:null,R=(null==C?void 0:C.properties)||{},A=Boolean(R.incline&&R.areStairs&&(!_||!T)),I=s.properties.isSubwayEntrance,M=h.properties.name||null,k=e.edgesWeights[d],L={...f&&{isSubwayEntrance:f},...v&&{subwayEntranceRef:v},...w&&{isGate:w}};let P=Math.abs(o.diffAngle(Math.PI,m))>=S;const U=r.Level.isRange(h.level)&&!r.Level.isRange(l.level)||N;P=P&&!(l.level&&r.Level.isRange(l.level));const O=(null==g?void 0:g.levelChange)&&!r.Level.isRange(l.level)||A;if(i||(P||U||O||I)){let e;if(U){const t=r.Level.diff(l.level,u.level)||0;let o=t>0?"up":"down";N&&(o=N),e={difference:t,direction:o,...E&&{type:E}}}n={coords:l,...M&&{name:M},extras:L,levelChange:e,distance:0,duration:0},t.push(n)}n.distance+=l.distanceTo(u),n.duration+=k,a=p}const l=e.vertices[e.vertices.length-1].coords;return r.Coordinates.equals(l,s)||t.push({coords:l}),this.setStart(i),this.setEnd(s),this.setPathCoords(e.vertices.map((e=>e.coords))),this.setStepsInfo(t),this}build(){const{pathCoords:e,start:t,end:r}=this;if(!e)return i.warn('StepsBuilder: Missing "pathCoords" property to build steps'),[];if(!t)return i.warn('StepsBuilder: Missing "from" property to build steps'),[];if(!r)return i.warn('StepsBuilder: Missing "to" property to build steps'),[];0===this.stepsInfo.length&&this.setGraphRoute(T.fromCoordinates(t,r,e));const{stepsInfo:s}=this;return s.map(((i,n)=>{const a=e.findIndex((e=>e.equals(i.coords)));if(-1===a)throw new Error("Cannot find step coordinates in itinerary coordinates.");const l=0===a?t:e[a-1],d=a===e.length-1?r:e[a+1],c=l.bearingTo(i.coords),u=i.coords.bearingTo(d);let h=0;const p=n===s.length-1,m=p?e[e.length-1]:s[n+1].coords;let f=a;for(;!e[f].equals(m);)h+=e[f].distanceTo(e[f+1]),f++;return{coords:i.coords,name:i.name||null,number:n+1,previousBearing:c,nextBearing:u,angle:o.diffAngle(c,u+Math.PI),firstStep:0===n,lastStep:p,distance:h,duration:i.duration||g(h),levelChange:i.levelChange||null,extras:i.extras||null}}))}}class _{constructor({start:e,end:o,coords:i,transitMode:s,duration:n,startTime:a,endTime:l,transportInfo:d,steps:c}){t(this,"start"),t(this,"end"),t(this,"coords"),t(this,"distance"),t(this,"transitMode"),t(this,"duration"),t(this,"startTime"),t(this,"endTime"),t(this,"steps"),t(this,"transportInfo"),this.start={name:e.name||null,coords:e.coords},this.end={name:o.name||null,coords:o.coords},this.coords=i,this.transitMode=s,this.distance=r.Utils.calcDistance(i),this.duration="number"==typeof n?n:g(this.distance),this.startTime="number"==typeof a?a:null,this.endTime="number"==typeof l?l:null,this.transportInfo=d||null,this.steps=Array.isArray(c)?c:(new x).setStart(e.coords).setEnd(o.coords).setPathCoords(i).build()}isPublicTransport(){return f(this.transitMode)}toGraph(){return m.fromCoordinatesSegments([this.coords])}static equals(e,t){var r,o;if(!(e.transitMode===t.transitMode&&Math.abs(e.duration-t.duration)<=.05&&e.startTime===t.startTime&&e.endTime===t.endTime&&e.start.name===t.start.name&&e.start.coords.equals(t.start.coords)&&e.end.name===t.end.name&&e.end.coords.equals(t.end.coords)&&e.coords.length===t.coords.length&&(e.steps===t.steps||(null==(r=e.steps)?void 0:r.length)===(null==(o=t.steps)?void 0:o.length))))return!1;let i;for(i=0;i<e.coords.length;i++)if(!e.coords[i].equals(t.coords[i]))return!1;for(i=0;i<e.steps.length;i++)if(!y(e.steps[i],t.steps[i]))return!1;if(e.transportInfo!==t.transportInfo){if(null===e.transportInfo||null===t.transportInfo)return!1;if(e.transportInfo.name!==t.transportInfo.name||e.transportInfo.routeColor!==t.transportInfo.routeColor||e.transportInfo.routeTextColor!==t.transportInfo.routeTextColor||e.transportInfo.directionName!==t.transportInfo.directionName)return!1}return!0}equals(e){return _.equals(this,e)}toJson(){return{transitMode:this.transitMode,start:{coords:this.start.coords.toCompressedJson(),...this.start.name&&{name:this.start.name}},end:{coords:this.end.coords.toCompressedJson(),...this.end.name&&{name:this.end.name}},distance:Number(this.distance.toFixed(1)),duration:Number(this.duration.toFixed(1)),coords:this.coords.map((e=>e.toCompressedJson())),steps:this.steps.map(v),...null!==this.startTime&&{startTime:this.startTime},...null!==this.endTime&&{endTime:this.endTime},...null!==this.transportInfo&&{transportInfo:this.transportInfo}}}static fromJson(e){var t;return new _(Object.assign({},e,{start:{coords:r.Coordinates.fromCompressedJson(e.start.coords),name:e.start.name||null},end:{coords:r.Coordinates.fromCompressedJson(e.end.coords),name:e.end.name||null},coords:e.coords.map(r.Coordinates.fromCompressedJson),steps:(null==(t=e.steps)?void 0:t.map(b))||null}))}static fromGraphRoute(e,t="WALK"){return new _({start:{coords:e.start},end:{coords:e.end},coords:e.vertices.map((e=>e.coords)),duration:e.edgesWeights.reduce(((e,t)=>e+t),0),transitMode:t,steps:(new x).setGraphRoute(e).build()})}multiplyLevel(e){this.start.coords.level=r.Level.multiplyBy(this.start.coords.level,e),this.end.coords.level=r.Level.multiplyBy(this.end.coords.level,e);for(const t of this.coords)t.level=r.Level.multiplyBy(t.level,e);this.steps.forEach((t=>{t.coords.level=r.Level.multiplyBy(t.coords.level,e)}))}}class N{constructor({origin:e,destination:r,duration:o,legs:i,startTime:s,endTime:n}){t(this,"origin"),t(this,"destination"),t(this,"duration"),t(this,"legs"),t(this,"_transitMode",null),t(this,"startTime"),t(this,"endTime"),t(this,"_coords",null),t(this,"_distance",null),this.origin=e,this.destination=r,this.legs=i,this.duration="number"==typeof o?o:this.legs.reduce(((e,t)=>e+t.duration),0),this.startTime="number"==typeof s?s:null,this.endTime="number"==typeof n?n:null,this.updateStepsFromLegs()}set coords(e){throw new Error("Itinerary.coords cannot be set. They are calculated from Itinerary.legs.")}get coords(){return this._coords||(this._coords=this.legs.map((e=>e.coords)).flat().filter(((e,t,r)=>0===t||!r[t-1].equals(e)))),this._coords}set steps(e){throw new Error("Itinerary.step cannot be set. They are calculated from Itinerary.legs.")}get steps(){return this.legs.map((e=>e.steps)).flat()}set transitMode(e){throw new Error("Itinerary.transitMode cannot be set. They are calculated from Itinerary.legs.")}get transitMode(){if(!this._transitMode){const e=new Set(this.legs.map((e=>e.transitMode)));if(e.delete("WALK"),e.size>1)return this._transitMode="MULTI",this._transitMode;if(1===e.size)return this._transitMode=e.values().next().value,this._transitMode;this._transitMode="WALK"}return this._transitMode}set distance(e){throw new Error("Itinerary.distance cannot be set. They are calculated from Itinerary.legs.")}get distance(){return null===this._distance&&(this._distance=r.Utils.calcDistance(this.coords)),this._distance}toGraph(){return m.fromCoordinatesSegments([this.coords])}static fromItineraries(...e){return new N({origin:e[0].origin,destination:e[e.length-1].destination,legs:e.map((e=>e.legs)).flat()})}static fromOrderedPointsArray(e,t,o){const i=e=>new r.Coordinates(e[0],e[1],null,e[2]);return this.fromOrderedCoordinates(e.map(i),i(t),i(o))}static fromOrderedCoordinates(e,t,r,o="WALK"){const i=(new x).setPathCoords(e).setStart(t).setEnd(r).build(),s=new _({start:{coords:t},end:{coords:r},coords:e,transitMode:o,steps:i});return new N({origin:t,destination:r,legs:[s]})}static equals(e,t){if(!(e.origin.equals(t.origin)&&e.destination.equals(t.destination)&&Math.abs(e.distance-t.distance)<=.05&&Math.abs(e.duration-t.duration)<=.05&&e.startTime===t.startTime&&e.endTime===t.endTime&&e.legs.length===t.legs.length))return!1;for(let r=0;r<e.legs.length;r++)if(!e.legs[r].equals(t.legs[r]))return!1;return!0}equals(e){return N.equals(this,e)}toJson(){return{origin:this.origin.toJson(),destination:this.destination.toJson(),distance:Number(this.distance.toFixed(1)),duration:Number(this.duration.toFixed(1)),transitMode:this.transitMode,legs:this.legs.map((e=>e.toJson())),...null!==this.startTime&&{startTime:this.startTime},...null!==this.endTime&&{endTime:this.endTime}}}static fromJson(e){return new N({origin:r.Coordinates.fromJson(e.origin),destination:r.Coordinates.fromJson(e.destination),duration:e.duration,legs:e.legs.map(_.fromJson),startTime:e.startTime,endTime:e.endTime})}static fromGraphRoute(e,t="WALK"){const r=_.fromGraphRoute(e,t);return new N({origin:e.start,destination:e.end,legs:[r]})}multiplyLevel(e){this.origin.level=r.Level.multiplyBy(this.origin.level,e),this.destination.level=r.Level.multiplyBy(this.destination.level,e),this.legs.forEach((t=>t.multiplyLevel(e)))}forceUnknownLevelTo0(){this.origin.level=this.origin.level||0,this.destination.level=this.destination.level||0;for(const e of this.legs){e.start.coords.level=e.start.coords.level||0,e.end.coords.level=e.end.coords.level||0;for(const t of e.coords)t.level=t.level||0;if(e.steps)for(const t of e.steps)t.coords.level=t.coords.level||0}if(this._coords)for(const e of this._coords)e.level=e.level||0}toGeoJson(){const e=(e,t,r)=>({type:"Feature",properties:{name:t,level:e.level,...r&&{type:r}},geometry:{type:"Point",coordinates:[e.lng,e.lat]}}),t=[...new Set(this.coords.map((e=>r.Level.toString(e.level))))].map(r.Level.fromString).map((e=>[e,r.Utils.createSegmentsAtLevel(this.coords,e,!0)])).map((([e,t])=>((e,t)=>({type:"Feature",properties:{level:t,name:null==t?void 0:t.toString()},geometry:{type:"MultiLineString",coordinates:e.map((e=>e.map((({lat:e,lng:t})=>[t,e]))))}}))(t,e))),o=this.legs.map(((t,r)=>e(t.start.coords,`Leg ${r} start`,"leg-start"))),i=this.legs.map(((t,r)=>e(t.end.coords,`Leg ${r} end`,"leg-end"))),s=this.steps.map((t=>e(t.coords,`Step ${t.number}`,"step")));return{type:"FeatureCollection",features:[e(this.origin,"origin","origin"),e(this.destination,"destination","destination"),...t,...o,...i,...s]}}updateStepsFromLegs(){const e=this.coords.filter(((e,t,r)=>0===t||!r[t-1].equals(e))),t=this.legs.map((e=>e.steps)).flat();t.map(((r,i)=>{const s=e.findIndex((e=>e.equals(r.coords)));if(-1===s)throw new Error("Cannot find step coordinates in itinerary coordinates.");const n=0===s?this.origin:e[s-1],a=s===e.length-1?this.destination:e[s+1];r.previousBearing=n.bearingTo(r.coords),r.nextBearing=r.coords.bearingTo(a),r.angle=o.diffAngle(r.previousBearing,r.nextBearing+Math.PI),r.number=i+1,r.firstStep=0===i,r.lastStep=i===t.length-1}))}}var E,C,R="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},A={exports:{}};E=A,C=A.exports,function(e,t){var r="function",o="undefined",i="object",s="string",n="major",a="model",l="name",d="type",c="vendor",u="version",h="architecture",p="console",m="mobile",g="tablet",f="smarttv",w="wearable",v="embedded",b="Amazon",y="Apple",T="ASUS",S="BlackBerry",x="Browser",_="Chrome",N="Firefox",R="Google",A="Huawei",I="LG",M="Microsoft",k="Motorola",L="Opera",P="Samsung",U="Sharp",O="Sony",B="Xiaomi",F="Zebra",D="Facebook",$="Chromium OS",W="Mac OS",j=function(e){for(var t={},r=0;r<e.length;r++)t[e[r].toUpperCase()]=e[r];return t},G=function(e,t){return typeof e===s&&-1!==q(t).indexOf(q(e))},q=function(e){return e.toLowerCase()},K=function(e,t){if(typeof e===s)return e=e.replace(/^\s\s*/,""),typeof t===o?e:e.substring(0,350)},J=function(e,o){for(var s,n,a,l,d,c,u=0;u<o.length&&!d;){var h=o[u],p=o[u+1];for(s=n=0;s<h.length&&!d&&h[s];)if(d=h[s++].exec(e))for(a=0;a<p.length;a++)c=d[++n],typeof(l=p[a])===i&&l.length>0?2===l.length?typeof l[1]==r?this[l[0]]=l[1].call(this,c):this[l[0]]=l[1]:3===l.length?typeof l[1]!==r||l[1].exec&&l[1].test?this[l[0]]=c?c.replace(l[1],l[2]):t:this[l[0]]=c?l[1].call(this,c,l[2]):t:4===l.length&&(this[l[0]]=c?l[3].call(this,c.replace(l[1],l[2])):t):this[l]=c||t;u+=2}},V=function(e,r){for(var o in r)if(typeof r[o]===i&&r[o].length>0){for(var s=0;s<r[o].length;s++)if(G(r[o][s],e))return"?"===o?t:o}else if(G(r[o],e))return"?"===o?t:o;return e},z={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},H={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[u,[l,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[u,[l,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[l,u],[/opios[\/ ]+([\w\.]+)/i],[u,[l,L+" Mini"]],[/\bopr\/([\w\.]+)/i],[u,[l,L]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(heytap|ovi)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[l,u],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[u,[l,"UC"+x]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[u,[l,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[u,[l,"WeChat"]],[/konqueror\/([\w\.]+)/i],[u,[l,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[u,[l,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[u,[l,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[l,/(.+)/,"$1 Secure "+x],u],[/\bfocus\/([\w\.]+)/i],[u,[l,N+" Focus"]],[/\bopt\/([\w\.]+)/i],[u,[l,L+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[u,[l,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[u,[l,"Dolphin"]],[/coast\/([\w\.]+)/i],[u,[l,L+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[u,[l,"MIUI "+x]],[/fxios\/([-\w\.]+)/i],[u,[l,N]],[/\bqihu|(qi?ho?o?|360)browser/i],[[l,"360 "+x]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[l,/(.+)/,"$1 "+x],u],[/(comodo_dragon)\/([\w\.]+)/i],[[l,/_/g," "],u],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[l,u],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[l],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[l,D],u],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram)[\/ ]([-\w\.]+)/i],[l,u],[/\bgsa\/([\w\.]+) .*safari\//i],[u,[l,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[u,[l,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[u,[l,_+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[l,_+" WebView"],u],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[u,[l,"Android "+x]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[l,u],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[u,[l,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[u,l],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[l,[u,V,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[l,u],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[l,"Netscape"],u],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[u,[l,N+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[l,u],[/(cobalt)\/([\w\.]+)/i],[l,[u,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[h,"amd64"]],[/(ia32(?=;))/i],[[h,q]],[/((?:i[346]|x)86)[;\)]/i],[[h,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[h,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[h,"armhf"]],[/windows (ce|mobile); ppc;/i],[[h,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[h,/ower/,"",q]],[/(sun4\w)[;\)]/i],[[h,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[h,q]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[a,[c,P],[d,g]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[a,[c,P],[d,m]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[a,[c,y],[d,m]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[a,[c,y],[d,g]],[/(macintosh);/i],[a,[c,y]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[a,[c,U],[d,m]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[a,[c,A],[d,g]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[a,[c,A],[d,m]],[/\b(poco[\w ]+)(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[a,/_/g," "],[c,B],[d,m]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[a,/_/g," "],[c,B],[d,g]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[a,[c,"OPPO"],[d,m]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[a,[c,"Vivo"],[d,m]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[a,[c,"Realme"],[d,m]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[a,[c,k],[d,m]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[a,[c,k],[d,g]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[a,[c,I],[d,g]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[a,[c,I],[d,m]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[a,[c,"Lenovo"],[d,g]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[a,/_/g," "],[c,"Nokia"],[d,m]],[/(pixel c)\b/i],[a,[c,R],[d,g]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[a,[c,R],[d,m]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[a,[c,O],[d,m]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[a,"Xperia Tablet"],[c,O],[d,g]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[a,[c,"OnePlus"],[d,m]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[a,[c,b],[d,g]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[a,/(.+)/g,"Fire Phone $1"],[c,b],[d,m]],[/(playbook);[-\w\),; ]+(rim)/i],[a,c,[d,g]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[a,[c,S],[d,m]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[a,[c,T],[d,g]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[a,[c,T],[d,m]],[/(nexus 9)/i],[a,[c,"HTC"],[d,g]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[c,[a,/_/g," "],[d,m]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[a,[c,"Acer"],[d,g]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[a,[c,"Meizu"],[d,m]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[c,a,[d,m]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[c,a,[d,g]],[/(surface duo)/i],[a,[c,M],[d,g]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[a,[c,"Fairphone"],[d,m]],[/(u304aa)/i],[a,[c,"AT&T"],[d,m]],[/\bsie-(\w*)/i],[a,[c,"Siemens"],[d,m]],[/\b(rct\w+) b/i],[a,[c,"RCA"],[d,g]],[/\b(venue[\d ]{2,7}) b/i],[a,[c,"Dell"],[d,g]],[/\b(q(?:mv|ta)\w+) b/i],[a,[c,"Verizon"],[d,g]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[a,[c,"Barnes & Noble"],[d,g]],[/\b(tm\d{3}\w+) b/i],[a,[c,"NuVision"],[d,g]],[/\b(k88) b/i],[a,[c,"ZTE"],[d,g]],[/\b(nx\d{3}j) b/i],[a,[c,"ZTE"],[d,m]],[/\b(gen\d{3}) b.+49h/i],[a,[c,"Swiss"],[d,m]],[/\b(zur\d{3}) b/i],[a,[c,"Swiss"],[d,g]],[/\b((zeki)?tb.*\b) b/i],[a,[c,"Zeki"],[d,g]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[c,"Dragon Touch"],a,[d,g]],[/\b(ns-?\w{0,9}) b/i],[a,[c,"Insignia"],[d,g]],[/\b((nxa|next)-?\w{0,9}) b/i],[a,[c,"NextBook"],[d,g]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[c,"Voice"],a,[d,m]],[/\b(lvtel\-)?(v1[12]) b/i],[[c,"LvTel"],a,[d,m]],[/\b(ph-1) /i],[a,[c,"Essential"],[d,m]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[a,[c,"Envizen"],[d,g]],[/\b(trio[-\w\. ]+) b/i],[a,[c,"MachSpeed"],[d,g]],[/\btu_(1491) b/i],[a,[c,"Rotor"],[d,g]],[/(shield[\w ]+) b/i],[a,[c,"Nvidia"],[d,g]],[/(sprint) (\w+)/i],[c,a,[d,m]],[/(kin\.[onetw]{3})/i],[[a,/\./g," "],[c,M],[d,m]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[a,[c,F],[d,g]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[a,[c,F],[d,m]],[/smart-tv.+(samsung)/i],[c,[d,f]],[/hbbtv.+maple;(\d+)/i],[[a,/^/,"SmartTV"],[c,P],[d,f]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[c,I],[d,f]],[/(apple) ?tv/i],[c,[a,y+" TV"],[d,f]],[/crkey/i],[[a,_+"cast"],[c,R],[d,f]],[/droid.+aft(\w)( bui|\))/i],[a,[c,b],[d,f]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[a,[c,U],[d,f]],[/(bravia[\w ]+)( bui|\))/i],[a,[c,O],[d,f]],[/(mitv-\w{5}) bui/i],[a,[c,B],[d,f]],[/Hbbtv.*(technisat) (.*);/i],[c,a,[d,f]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[c,K],[a,K],[d,f]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[d,f]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[c,a,[d,p]],[/droid.+; (shield) bui/i],[a,[c,"Nvidia"],[d,p]],[/(playstation [345portablevi]+)/i],[a,[c,O],[d,p]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[a,[c,M],[d,p]],[/((pebble))app/i],[c,a,[d,w]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[a,[c,y],[d,w]],[/droid.+; (glass) \d/i],[a,[c,R],[d,w]],[/droid.+; (wt63?0{2,3})\)/i],[a,[c,F],[d,w]],[/(quest( 2| pro)?)/i],[a,[c,D],[d,w]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[c,[d,v]],[/(aeobc)\b/i],[a,[c,b],[d,v]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[a,[d,m]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[a,[d,g]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[d,g]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[d,m]],[/(android[-\w\. ]{0,9});.+buil/i],[a,[c,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[u,[l,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[u,[l,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[l,u],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[u,l]],os:[[/microsoft (windows) (vista|xp)/i],[l,u],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[l,[u,V,z]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[l,"Windows"],[u,V,z]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/ios;fbsv\/([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[u,/_/g,"."],[l,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[l,W],[u,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[u,l],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[l,u],[/\(bb(10);/i],[u,[l,S]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[u,[l,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[u,[l,N+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[u,[l,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[u,[l,"watchOS"]],[/crkey\/([\d\.]+)/i],[u,[l,_+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[l,$],u],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[l,u],[/(sunos) ?([\w\.\d]*)/i],[[l,"Solaris"],u],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[l,u]]},Q=function(p,f){if(typeof p===i&&(f=p,p=t),!(this instanceof Q))return new Q(p,f).getResult();var w=typeof e!==o&&e.navigator?e.navigator:t,v=p||(w&&w.userAgent?w.userAgent:""),b=w&&w.userAgentData?w.userAgentData:t,y=f?function(e,t){var r={};for(var o in e)t[o]&&t[o].length%2==0?r[o]=t[o].concat(e[o]):r[o]=e[o];return r}(H,f):H,T=w&&w.userAgent==v;return this.getBrowser=function(){var e,o={};return o[l]=t,o[u]=t,J.call(o,v,y.browser),o[n]=typeof(e=o[u])===s?e.replace(/[^\d\.]/g,"").split(".")[0]:t,T&&w&&w.brave&&typeof w.brave.isBrave==r&&(o[l]="Brave"),o},this.getCPU=function(){var e={};return e[h]=t,J.call(e,v,y.cpu),e},this.getDevice=function(){var e={};return e[c]=t,e[a]=t,e[d]=t,J.call(e,v,y.device),T&&!e[d]&&b&&b.mobile&&(e[d]=m),T&&"Macintosh"==e[a]&&w&&typeof w.standalone!==o&&w.maxTouchPoints&&w.maxTouchPoints>2&&(e[a]="iPad",e[d]=g),e},this.getEngine=function(){var e={};return e[l]=t,e[u]=t,J.call(e,v,y.engine),e},this.getOS=function(){var e={};return e[l]=t,e[u]=t,J.call(e,v,y.os),T&&!e[l]&&b&&"Unknown"!=b.platform&&(e[l]=b.platform.replace(/chrome os/i,$).replace(/macos/i,W)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return v},this.setUA=function(e){return v=typeof e===s&&e.length>350?K(e,350):e,this},this.setUA(v),this};Q.VERSION="1.0.35",Q.BROWSER=j([l,u,n]),Q.CPU=j([h]),Q.DEVICE=j([a,c,d,p,m,f,g,w,v]),Q.ENGINE=Q.OS=j([l,u]),E.exports&&(C=E.exports=Q),C.UAParser=Q;var X=typeof e!==o&&(e.jQuery||e.Zepto);if(X&&!X.ua){var Y=new Q;X.ua=Y.getResult(),X.ua.get=function(){return Y.getUA()},X.ua.set=function(e){Y.setUA(e);var t=Y.getResult();for(var r in t)X.ua[r]=t[r]}}}("object"==typeof window?window:R);var I=Object.defineProperty,M=(e,t,r)=>(((e,t,r)=>{t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);const k="Unknown",L="Safari",P="Firefox",U="Opera",O="Chrome",B="iOS-webview";class F{static getName(){if(!this._name)if("undefined"!=typeof navigator&&navigator){const{userAgent:e}=navigator;e.match(/Firefox/i)?this._name=P:e.match(/(Opera|OPR)/i)?this._name=U:e.match(/Chrome/i)?this._name=O:e.match(/Safari/i)?this._name=L:e.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Version)/i)?this._name=B:this._name=k}else this._name=k;return this._name}static get isMobile(){if(null===this._isMobile&&(this._isMobile=!1,"undefined"!=typeof navigator&&navigator)){const e=navigator.userAgent||navigator.vendor;e&&(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(this._isMobile=!0)}return this._isMobile}static clearCache(){this._name=null,this._isMobile=null}}M(F,"_name",null),M(F,"_isMobile",null);const D=[4215763,14529296,11869460,48895,16468400,45661,13290186];const $=Object.freeze(Object.defineProperty({__proto__:null,getQualitativeColor:function(e){return D[e%D.length]}},Symbol.toStringTag,{value:"Module"})),W=4,j=3,G={wheelchair:{horrible:.1,bad:.5,intermediate:.7,good:.9,excellent:1},default:{horrible:.4,bad:.7,intermediate:.8,good:.9,excellent:1}},q={wheelchair:{asphalt:1,concrete:1,paving_stones:.8,compacted:.7,wood:.6,metal:.5,gravel:.3,grass:.2,ground:.2},default:{asphalt:1,concrete:1,paving_stones:.9,compacted:.8,wood:.8,metal:.7,gravel:.6,grass:.5,ground:.4}},K=class e{constructor(){t(this,"avoidStairs",!1),t(this,"avoidEscalators",!1),t(this,"avoidElevators",!1),t(this,"avoidMovingWalkways",!1),t(this,"avoidTicketRestrictedAreas",!1),t(this,"useMultiLevelSegments",!1),t(this,"projectionMaxDistance"),t(this,"isWheelchair",!1)}setAvoidStairs(e){return this.avoidStairs=e,this}setAvoidEscalators(e){return this.avoidEscalators=e,this}setAvoidElevators(e){return this.avoidElevators=e,this}setAvoidMovingWalkways(e){return this.avoidMovingWalkways=e,this}setAvoidTicketRestrictedAreas(e){return this.avoidTicketRestrictedAreas=e,this}setUseMultiLevelSegments(e){return this.useMultiLevelSegments=e,this}setIsWheelchair(e){return this.isWheelchair=e,this}static fromJson(t){const r=new e;return Object.assign(r,t),r.build()}build(){return{input:{avoidStairs:this.avoidStairs,avoidEscalators:this.avoidEscalators,avoidElevators:this.avoidElevators,avoidMovingWalkways:this.avoidMovingWalkways,avoidTicketRestrictedAreas:this.avoidTicketRestrictedAreas,isWheelchair:this.isWheelchair,projectionMaxDistance:this.projectionMaxDistance},weightEdgeFn:e=>{if(e.properties.isElevator)return 90;const t=this.isWheelchair?j:W;let r=g(e.length,t);if(e.properties.areStairs)r*=3;else if(e.properties.areEscalators)r*=1.5;else if(e.properties.isMovingWalkway)r*=.8;else if(e.properties.smoothness){const t=this.isWheelchair?"wheelchair":"default";r*=G[t][e.properties.smoothness]??1}else if(e.properties.surface){const t=this.isWheelchair?"wheelchair":"default";r*=q[t][e.properties.surface]??1}return r},acceptEdgeFn:e=>{if(e.properties.wheelchair){if(this.isWheelchair&&"no"===e.properties.wheelchair)return!1;if(!this.isWheelchair&&"designated"===e.properties.wheelchair)return!1}if(this.isWheelchair){if(e.properties.areStairs)return!1;if(e.properties.areEscalators)return!1;if(e.properties.isMovingWalkway)return!1}return(!this.avoidStairs||!e.properties.areStairs)&&((!this.avoidEscalators||!e.properties.areEscalators)&&((!this.avoidElevators||!e.properties.isElevator)&&((!this.avoidMovingWalkways||!e.properties.isMovingWalkway)&&(!this.avoidTicketRestrictedAreas||!e.properties.needTicket))))},projectionMaxDistance:this.projectionMaxDistance,useMultiLevelSegments:this.useMultiLevelSegments}}};t(K,"DEFAULT",(new K).build()),t(K,"WITHOUT_STAIRS",(new K).setAvoidStairs(!0).build()),t(K,"WHEELCHAIR",(new K).setIsWheelchair(!0).build());let J=K;class V{constructor(e,t,r,o,i){this.prev=e,this.dist=t,this.source=r,this.targets=o,this.edges=i}routeVertices(e=this.targets[0],t=[]){const r=this.prev[e.id];return null===r?this.source===e?[...t,e]:[]:[...this.routeVertices(r,t),e]}weightedDistance(e=this.targets[0]){const t=this.dist[e.id];return t===Number.MAX_VALUE?null:t}route(e=this.targets[0]){const t=this.routeVertices(e),r=[],o=[];for(let i=1;i<t.length;i++){const e=t[i-1],s=t[i],n=u.getEdgeByVertices(this.edges,e,s),a=new u(e,s,Object.assign({},n.properties));n.vertex1===a.vertex2&&a.reverseProperties(),r.push(a),o.push(this.dist[s.id]-this.dist[e.id])}return new T(this.source.coords,e.coords,t,r,o)}toGeoJson(e){return{type:"FeatureCollection",features:[...e.vertices.map((e=>{const t=this.prev[e.id],r=this.dist[e.id],o=e===this.source,i=this.targets.includes(e),s=e.coords.level;return{type:"Feature",properties:{id:e.id,...t&&{prev:t.id},dist:r===Number.MAX_VALUE?"infinity":r,...o&&{name:"source"},...i&&{name:"target"},...null!==s&&{level:s},...e.properties},geometry:{type:"Point",coordinates:[e.coords.lng,e.coords.lat]}}})),...e.edges.map((e=>{const t=e.level;return{type:"Feature",properties:{id:e.id,...null!==t&&{level:t},...e.properties},geometry:{type:"LineString",coordinates:[[e.vertex1.coords.lng,e.vertex1.coords.lat],[e.vertex2.coords.lng,e.vertex2.coords.lat]]}}}))]}}}class z{constructor(e){t(this,"disabledEdges",new Set),this.graph=e;let r=0;e.vertices.forEach((e=>e.id=r++))}calculateShortestPathToMultipleDestinationsByVertex(e,t,r=J.DEFAULT,o=this.graph.vertices,i=this.graph.edges){const s=new Set(o),n=Array(s.size).fill(Number.MAX_VALUE),a=new Array(s.size).fill(null),l=i.filter((e=>{var t;return((null==(t=r.acceptEdgeFn)?void 0:t.call(r,e))??!0)&&!this.disabledEdges.has(e)})),d=r.weightEdgeFn||(e=>e.length),c=e=>{let t=Number.MAX_VALUE,r=null;return e.forEach((e=>{const o=n[e.id];o<=t&&(t=o,r=e)})),r},u=new Set(t);for(n[e.id]=0;s.size>0;){const e=c(s);if(s.delete(e),t.includes(e)&&(u.delete(e),0===u.size))break;l.filter((t=>t.vertex1==e||!t.properties.isOneway&&t.vertex2==e)).forEach((t=>{const r=e===t.vertex1?t.vertex2:t.vertex1,o=d(t),i=n[e.id]+o;i<n[r.id]&&(n[r.id]=i,a[r.id]=e)}))}return new V(a,n,e,t,l)}calculateShortestPathByVertex(e,t,r=J.DEFAULT,o=this.graph.vertices,i=this.graph.edges){return this.calculateShortestPathToMultipleDestinationsByVertex(e,[t],r,o,i)}calculateComponents(){function e(e){const t=e.values().next().value;return e.delete(t),t}const t=new Set(this.graph.vertices);let r,o=[];for(;t.size>0;){const r=e(t),i=this.graph.vertices.filter((e=>e.id!==r.id)),s=this.calculateShortestPathToMultipleDestinationsByVertex(r,i),n=i.filter((e=>null!==s.weightedDistance(e)));o.push([r,...n]),n.forEach((e=>t.delete(e)))}do{r=!1;for(let e=0;e<o.length-1;e++){const t=o[e];for(let i=e+1;i<o.length;i++){const e=o[i];e.some((e=>t.includes(e)))&&(t.push(...e),o=o.filter((t=>t!==e)),r=!0)}}}while(r);return o.map((e=>[...new Set(e)]))}toGeoJson(){return{type:"FeatureCollection",features:this.calculateComponents().map(((e,t)=>({type:"Feature",geometry:{type:"MultiLineString",coordinates:this.graph.edges.filter((t=>e.includes(t.vertex1)&&e.includes(t.vertex2))).map((e=>[[e.vertex1.coords.lng,e.vertex1.coords.lat],[e.vertex2.coords.lng,e.vertex2.coords.lat]]))},properties:{stroke:"#"+$.getQualitativeColor(t).toString(16)}})))}}}class H extends V{constructor(e,t,r){super(e.prev,e.dist,e.source,e.targets,e.edges),this.sourceProjection=t,this.targetsProjections=r}static createEmpty(e,t){const r=t.length,o=new V(new Array(r).fill(null),new Array(r).fill(Number.MAX_VALUE),new p(e),t.map((e=>new p(e))),[]),i=[e,null],s=t.map((e=>[e,null]));return new H(o,i,s)}routeVertices(e=this.targetsProjections[0][0]){var t;if(e instanceof p)return super.routeVertices(e);if(!this.sourceProjection[1])return[];const r=null==(t=this.targetsProjections.find((([t])=>t===e)))?void 0:t[1];return r?super.routeVertices(r):[]}weightedDistance(e=this.targetsProjections[0][0]){var t;if(e instanceof p)return super.weightedDistance(e);if(!this.sourceProjection[1])return null;const r=null==(t=this.targetsProjections.find((([t])=>t===e)))?void 0:t[1];return r?super.weightedDistance(r):null}route(e=this.targetsProjections[0][0]){var t;if(e instanceof p)return super.route(e);const r=null==(t=this.targetsProjections.find((([t])=>t===e)))?void 0:t[1];if(!r)return new T(this.sourceProjection[0],e,[],[],[]);const o=super.route(r);return o.start=this.sourceProjection[0],o.end=e,o}}class Q extends z{calculateShortestPathToMultipleDestinations(e,t,r=J.DEFAULT){const o=new Set,i=new Set,s=[],n={maxDistance:r.projectionMaxDistance,acceptEdgeFn:r.acceptEdgeFn,useMultiLevelSegments:r.useMultiLevelSegments},a=e=>{const t=this.graph.getProjection(e,n);if(null===t)return null;if(t.nearestElement instanceof p)return t.nearestElement;if(t.nearestElement instanceof u){const e=t.nearestElement,r=new p(t.coords,{name:`proj on ${e.properties.name||null} (tmp)`,...void 0!==e.properties.externalId&&{externalId:e.properties.externalId}});r.id=this.graph.vertices.length+o.size;const n={...e.properties,...void 0!==e.properties.externalId&&{externalId:e.properties.externalId}},a=new u(e.vertex1,r,n),l=new u(r,e.vertex2,n);o.add(r),i.add(a),i.add(l);const d=s.find((t=>t[0]===e));return d?d[1].push(r):s.push([e,[r]]),r}return null},l=a(e);if(!l)return H.createEmpty(e,t);const d=t.map((e=>[e,a(e)])),c=d.map((([,e])=>e)).filter((e=>null!==e));s.filter((e=>e[1].length>=2)),s.forEach((([e,t])=>{const r={...e.properties,name:`splitted ${e.properties.name||null} (tmp)`};for(let o=0;o<t.length;o++){const s=t[o],n=s.distanceTo(e.vertex1);for(let a=o+1;a<t.length;a++){const o=t[a],l=o.distanceTo(e.vertex1)<n?new u(o,s,r):new u(s,o,r);i.add(l)}}}));const h=this.calculateShortestPathToMultipleDestinationsByVertex(l,c,r,[...this.graph.vertices,...o],[...this.graph.edges,...i]);return new H(h,[e,l],d)}calculateShortestPath(e,t,r=J.DEFAULT){return this.calculateShortestPathToMultipleDestinations(e,[t],r)}getShortestTrip(e,t,r=.99){const o=e.map((e=>{const t=new s.Point(0,0);return t.coords=e,t})),i=[],n=s.solve(o,r,void 0,((e,r)=>{const o=this.calculateShortestPath(e.coords,r.coords,t).route();return i.push(o),o.hasRoute?o.edgesWeights.reduce(((e,t)=>e+t),0):Number.MAX_VALUE})).map((e=>o[e])),a=[];for(let s=0;s<n.length;s++){const e=n[s],t=n[(s+1)%n.length];let r=i.find((r=>r.start===e.coords&&r.end===t.coords||r.end===e.coords&&r.start===t.coords));(null==r?void 0:r.end)===e.coords&&(r=r.reverse()),r&&a.push(r)}return a.some((e=>!e.hasRoute))?[]:a}}class X extends Error{constructor(e,t,r=null){super(),this.start=e,this.end=t,this.details=r}get startStr(){return this.start instanceof p?`Vertex ${this.start.coords.toString()}`:this.start.toString()}get endStr(){return this.end instanceof p?`Vertex ${this.end.coords.toString()}`:Array.isArray(this.end)?this.end.map((e=>e instanceof p?e.coords.toString():e.toString())).join(","):this.end.toString()}get message(){let e=`No route found from ${this.startStr} to ${this.endStr}.`;return this.details&&(e+=` Details: ${this.details}`),e}}const Y=class e{static parseNodeProperties(e){return{...e.name&&{name:e.name},...e.id&&{externalId:e.id},...e.isGate&&{isGate:e.isGate},...e.isSubwayEntrance&&{isSubwayEntrance:e.isSubwayEntrance},...e.subwayEntranceRef&&{subwayEntrsanceRef:e.subwayEntranceRef}}}static parseWayProperties(e){return{...e.name&&{name:e.name},...e.id&&{externalId:e.id},...e.isOneway&&{isOneway:e.isOneway},...e.areStairs&&{areStairs:e.areStairs},...e.isElevator&&{isElevator:e.isElevator},...e.areEscalators&&{areEscalators:e.areEscalators},...e.isMovingWalkway&&{isMovingWalkway:e.isMovingWalkway},...e.needTicket&&{needTicket:e.needTicket},...e.incline&&{incline:e.incline},...e.wheelchair&&{wheelchair:e.wheelchair},...e.smoothness&&{smoothness:e.smoothness},...e.surface&&{surface:e.surface}}}static createGraphFromOsmModel(t,o=e.DEFAULT_WAY_SELECTOR,i){const s=[],a=[],l=[],d=(e,t)=>{var o;let i=(null==(o=a.find((([o,i])=>o===e.id&&(!!r.Level.intersect(i.coords.level,t)||(null===i.coords.level||null===t)))))?void 0:o[1])||null;if(i)return r.Level.equals(i.coords.level,t)||(i.coords.level=r.Level.intersection(i.coords.level,t),null===i.coords.level&&(i.coords.level=t)),i;const s=new r.Coordinates(e.coords.lat,e.coords.lng,null,t);if(i=new p(s,this.parseNodeProperties(e)),a.push([e.id,i]),e.isElevator){let t=l.find((([t])=>e.id===t));t||(t=[e.id,e.name,[]],l.push(t)),t[2].push(i)}return i};t.ways.forEach((e=>{if(!o(e))return;const t=this.parseWayProperties(e),i=r=>{for(let o=1;o<e.nodes.length;o++){let i=d(e.nodes[o-1],r),n=d(e.nodes[o],r);if(e.isOnewayBackward){const e=n;n=i,i=e}const a=new u(i,n,t);s.push(a)}};i(e.level),"repeat_on"in e.tags&&e.tags.repeat_on.split(";").map(r.Level.fromString).forEach(i)}));let c=-1;return t.ways.filter((e=>e.isElevator&&e.isGeometryClosed)).forEach((e=>{const t=e.nodes.map((e=>a.filter((([t])=>t===e.id)).map((e=>e[1])))).flat(),o=e.nodes.reduce(((e,t)=>[e[0]+t.coords.lat,e[1]+t.coords.lng]),[0,0]).map((t=>t/e.nodes.length)),i=t.reduce(((e,t)=>r.Level.union(e,t.coords.level)),null),l=new r.Coordinates(o[0],o[1],null,i),h=new n.OsmNode(c--,l,{highway:"elevator"});t.forEach((t=>{const r=d(h,t.coords.level);s.push(new u(r,t,{externalId:e.id}))}))})),l.forEach((([e,t,r])=>{const o={name:t,isElevator:!0,externalId:e};for(let i=0;i<r.length;i++)for(let e=i+1;e<r.length;e++)s.push(new u(r[i],r[e],o))})),null==i||i(a),new m(a.map((e=>e[1])),s)}};t(Y,"RESTRICTED_PEDESTRIANS_HIGHWAYS",["motorway","motorway_link"]),t(Y,"DEFAULT_WAY_SELECTOR",(e=>{if(e.isArea)return!1;if("yes"===e.tags.foot)return!0;if(["no","private"].includes(e.tags.access))return!1;const t="elevator"===e.tags.highway&&e.isGeometryClosed;return e.tags.highway&&!Y.RESTRICTED_PEDESTRIANS_HIGHWAYS.includes(e.tags.highway)&&!t||"sidewalk"===e.tags.footway||"platform"===e.tags.public_transport||"platform"===e.tags.railway}));let Z=Y;class ee{}var te=(e=>(e[e.OK=0]="OK",e[e.CANCELLED=1]="CANCELLED",e[e.UNKNOWN=2]="UNKNOWN",e[e.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",e[e.NOT_FOUND=5]="NOT_FOUND",e[e.UNIMPLEMENTED=12]="UNIMPLEMENTED",e[e.INTERNAL=13]="INTERNAL",e[e.UNAVAILABLE=14]="UNAVAILABLE",e[e.UNAUTHENTICATED=16]="UNAUTHENTICATED",e))(te||{});class re extends Error{constructor(e=te.UNKNOWN,r){super(r),t(this,"customMapName"),this.code=e}static notFound(e){return new re(te.NOT_FOUND,`Cannot found an itinerary. Details: ${e}`)}}class oe extends re{constructor(e=te.UNKNOWN,t,r){super(e,r),this.code=e,this.mapName=t,this.mapName=t}static notFound(e,t){return new oe(te.NOT_FOUND,e,`Cannot found an itinerary in map ${e}. Details: ${t||"No details"}`)}}class ie extends re{constructor(e=te.UNKNOWN,t,r){super(e,r),this.code=e,this.routerName=t,this.routerName=t}static notFound(e,t){return new ie(te.NOT_FOUND,e,`Cannot found an itinerary with ${e}. Details: ${t||"No details"}`)}static missingApiKey(e,t){return new ie(te.UNAUTHENTICATED,e,`API key is missing for ${e}. Details: ${t}`)}static unreachableServer(e,t){return new ie(te.NOT_FOUND,e,`Remote router server ${e} is unreachable. URL: ${t}`)}static responseNotParsing(e,t){return new ie(te.NOT_FOUND,e,`Remote router server response ${e} cannot be parsed. URL: ${t}`)}static travelModeUnimplemented(e,t){return new ie(te.UNIMPLEMENTED,e,`Travel mode "${t}" is not implemented for ${e}`)}}function se(e,t,r,o,i,s,n="Europe/Paris"){const a=new Date(Date.UTC(e,t,r,o,i,s)),l=new Date(a.toLocaleString("en-US",{timeZone:"UTC"})),d=new Date(a.toLocaleString("en-US",{timeZone:n})),c=l.getTime()-d.getTime();return a.setTime(a.getTime()+c),a}function ne(e){return new r.Coordinates(e.Lat,e.Long)}function ae(e){const[t,r]=e.split(" "),[o,i,s]=t.split("/"),[n,a,l]=r.split(":");return se(Number(s),Number(i)-1,Number(o),Number(n),Number(a),Number(l)).getTime()}const le=new Map;le.set("CAR","Car"),le.set("WALK","Walk"),le.set("BIKE","Bike"),le.set("TRANSIT","PT");const de=new Map;de.set("WALK","WALK"),de.set("BICYCLE","BIKE"),de.set("TRAMWAY","TRAM"),de.set("METRO","METRO"),de.set("FUNICULAR","FUNICULAR"),de.set("BUS","BUS"),de.set("COACH","BUS"),de.set("SCHOOL","BUS"),de.set("BUS_PMR","BUS"),de.set("MINIBUS","BUS"),de.set("TROLLEY_BUS","BUS"),de.set("TAXIBUS","BUS"),de.set("SHUTTLE","BUS"),de.set("TRAIN","TRAIN"),de.set("HST","TRAIN"),de.set("LOCAL_TRAIN","TRAIN"),de.set("AIR","AIRPLANE"),de.set("FERRY","BOAT"),de.set("TAXI","UNKNOWN"),de.set("CAR_POOL","UNKNOWN"),de.set("PRIVATE_VEHICLE","CAR"),de.set("SCOOTER","MOTO");const ce=new Map;function ue(e){const t=e.match(/LINESTRING ?\((.*)\)/i),o=e.match(/POINT ?\((.*)\)/i);if(o){const[e,t]=o[1].split(" ");return[new r.Coordinates(Number(t),Number(e))]}return t[1].split(",").map((e=>{const t=e.trim().split(" ");return new r.Coordinates(Number(t[1]),Number(t[0]))}))}ce.set(0,"BUS"),ce.set(1,"WALK"),ce.set(2,"BIKE"),ce.set(3,"CAR"),ce.set(4,"UNKNOWN"),ce.set(5,"UNKNOWN"),ce.set(6,"UNKNOWN"),ce.set(7,"UNKNOWN"),ce.set(8,"UNKNOWN"),ce.set(9,"UNKNOWN"),ce.set(10,"UNKNOWN"),ce.set(11,"UNKNOWN"),ce.set(12,"UNKNOWN"),ce.set(13,"UNKNOWN"),ce.set(14,"UNKNOWN");const he=new class extends ee{get rname(){return"cityway"}async getItineraries(e,t){const r=this.getURL(e,t),o=await fetch(r).catch((()=>{throw ie.unreachableServer(this.rname,r)})),i=await o.json().catch((()=>{throw ie.responseNotParsing(this.rname,r)}));return this.parseResponse(i)}getURL(e,t){const{origin:r,destination:o,travelMode:s,waypoints:n}=t,a=le.get(s);if(!a)throw ie.travelModeUnimplemented(this.rname,s);(n||[]).length>0&&i.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==n?void 0:n.length})`);const l=`DepartureLatitude=${r.latitude}&DepartureLongitude=${r.longitude}`,d=`ArrivalLatitude=${o.latitude}&ArrivalLongitude=${o.longitude}`,c=`TripModes=${a}`,u=new URL(e);let{search:h}=u;return h=(h?`${h}&`:"?")+`${l}&${d}&${c}`,`${u.origin}${u.pathname}${h}`}parseResponse(e){if(200!==e.StatusCode||!e.Data||!e.Data.length)throw ie.notFound(this.rname,e.Message);const t=[],r=e.Data.map((e=>e.response.trips.Trip.map((t=>({...t,...e.hasOwnProperty("PlanTripType")&&{PlanTripType:e.PlanTripType}}))))).flat();e:for(const o of r){if(o.hasOwnProperty("PlanTripType")&&"UNKNOWN"===ce.get(o.PlanTripType))continue;const e=[];for(const t of o.sections.Section){const r=t.Leg?t.Leg:t.PTRide,s=de.get(r.TransportMode),n=[];let a,l,d;const c=new x;if("UNKNOWN"===s)continue e;if("WALK"===s||"BIKE"===s||"CAR"===s){a={name:r.Departure.Site.Name,coords:ne(r.Departure.Site.Position)},l={name:r.Arrival.Site.Name,coords:ne(r.Arrival.Site.Position)};for(const e of r.pathLinks.PathLink){let t;t=e.Geometry&&"Null"!==e.Geometry?ue(e.Geometry):[a.coords,l.coords],t.forEach(((e,t)=>{0===t&&0!==n.length&&n[n.length-1].equals(e)||n.push(e)})),c.addStepInfo({coords:t[0],distance:e.Distance,name:e.Departure.Site.Name})}t===o.sections.Section[o.sections.Section.length-1]&&c.addStepInfo({coords:n[n.length-1]})}else{if(!f(s)){i.warn(`[CitywayParser] Unknown leg mode: ${r.TransportMode}`);continue}{a={name:r.Departure.StopPlace.Name,coords:ne(r.Departure.StopPlace.Position)},l={name:r.Arrival.StopPlace.Name,coords:ne(r.Arrival.StopPlace.Position)};let e=r.Line.Number;"TRAM"===s&&e.toLowerCase().includes("tram")&&(e=e.substr(5)),d={name:e,routeColor:r.Line.Color,routeTextColor:r.Line.TextColor,directionName:r.Destination};for(const t of r.steps.Step){ue(t.Geometry).forEach(((e,t)=>{0===t&&0!==n.length&&n[n.length-1].equals(e)||n.push(e)}))}c.addStepInfo({coords:n[0],name:r.Line.Name,distance:r.Distance})}}c.setStart(a.coords),c.setEnd(l.coords),c.setPathCoords(n);const u=new _({transitMode:s,duration:this.parseDuration(r.Duration),startTime:ae(r.Departure.Time),endTime:ae(r.Arrival.Time),coords:n,start:a,end:l,transportInfo:d,steps:c.build()});e.push(u)}const r=new N({duration:this.parseDuration(o.Duration),startTime:ae(o.Departure.Time),origin:ne(o.Departure.Site.Position),endTime:ae(o.Arrival.Time),destination:ne(o.Arrival.Site.Position),legs:e});t.push(r)}return t}parseDuration(e){const t=e.match(/(-)?P(?:([.,\d]+)Y)?(?:([.,\d]+)M)?(?:([.,\d]+)W)?(?:([.,\d]+)D)?T(?:([.,\d]+)H)?(?:([.,\d]+)M)?(?:([.,\d]+)S)?/),r=void 0===t[2]?0:Number(t[2]),o=void 0===t[3]?0:Number(t[3]),i=void 0===t[4]?0:Number(t[4]),s=void 0===t[5]?0:Number(t[5]),n=void 0===t[6]?0:Number(t[6]),a=void 0===t[7]?0:Number(t[7]);return(void 0===t[8]?0:Number(t[8]))+60*a+3600*n+86400*s+604800*i+2592e3*o+31557600*r}},pe=new Map;pe.set("Air","AIRPLANE"),pe.set("Boat","BOAT"),pe.set("Bus","BUS"),pe.set("BusRapidTransit","BUS"),pe.set("Coach","BUS"),pe.set("Ferry","FERRY"),pe.set("Funicular","FUNICULAR"),pe.set("LocalTrain","TRAIN"),pe.set("LongDistanceTrain","TRAIN"),pe.set("Metro","METRO"),pe.set("Métro","METRO"),pe.set("RailShuttle","TRAIN"),pe.set("RapidTransit","BUS"),pe.set("Shuttle","BUS"),pe.set("SuspendedCableCar","FUNICULAR"),pe.set("Taxi","TAXI"),pe.set("Train","TRAIN"),pe.set("RER","TRAIN"),pe.set("Tramway","TRAM"),pe.set("walking","WALK"),pe.set("bike","BIKE");const me=["physical_mode:Air","physical_mode:Boat","physical_mode:Bus","physical_mode:BusRapidTransit","physical_mode:Coach","physical_mode:Ferry","physical_mode:Funicular","physical_mode:LocalTrain","physical_mode:LongDistanceTrain","physical_mode:Metro","physical_mode:RailShuttle","physical_mode:RapidTransit","physical_mode:Shuttle","physical_mode:SuspendedCableCar","physical_mode:Taxi","physical_mode:Train","physical_mode:Tramway"];function ge(e){return new r.Coordinates(Number(e.lat),Number(e.lon))}function fe(e){return e[e.length-1]}function we(e,t){const r=e.substr(0,4),o=e.substr(4,2),i=e.substr(6,2),s=e.substr(9,2),n=e.substr(11,2),a=e.substr(13,2);return se(Number(r),Number(o)-1,Number(i),Number(s),Number(n),Number(a),t).getTime()}const ve=new class extends ee{get rname(){return"navitia"}async getItineraries(e,t){const r=this.getURL(e,t),o=r.searchParams.get("api_key");if(!o)throw ie.missingApiKey(this.rname);const i=await fetch(r,{method:"GET",headers:{Authorization:o}}).catch((()=>{throw ie.unreachableServer(this.rname,r.toString())})),s=await i.json().catch((()=>{throw ie.responseNotParsing(this.rname,r.toString())}));if(s&&s.error)throw ie.notFound(this.rname,s.error.message);const n=this.parseResponse(s);if(!n.some((e=>w(e.transitMode,t.travelMode))))throw ie.notFound(this.rname,"Selected mode of transport was not found for this itinerary.");return n}getURL(e,t){var r;const{origin:o,destination:s,waypoints:n,travelMode:a}=t;(n||[]).length>0&&i.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==n?void 0:n.length})`);const l=new URL(e),d=new URLSearchParams;d.set("from",`${o.longitude};${o.latitude}`),d.set("to",`${s.longitude};${s.latitude}`),d.set("data_freshness","realtime"),(null==(r=t.itineraryModifiers)?void 0:r.isWheelchair)&&d.set("wheelchair","true");let c=new URLSearchParams;switch(a){case"WALK":c=this.getWalkingQuery();break;case"BIKE":c=this.getBikeQuery();break;case"CAR":c=this.getCarQuery()}return[d,c].map((e=>{for(const t of e.entries())l.searchParams.append(t[0],t[1])})),l}getCarQuery(){const e=new URLSearchParams;return me.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("first_section_mode[]","car"),e.append("last_section_mode[]","walking"),e.append("last_section_mode[]","car"),e}getWalkingQuery(){const e=new URLSearchParams;return me.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("last_section_mode[]","walking"),e}getBikeQuery(){const e=new URLSearchParams;return me.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","bike"),e.append("last_section_mode[]","bike"),e}getSectionCoords(e){let t,r;return t="stop_point"in e.from?e.from.stop_point.coord:"address"in e.from?e.from.address.coord:e.from.poi.coord,r="stop_point"in e.to?e.to.stop_point.coord:"address"in e.to?e.to.address.coord:e.to.poi.coord,{from:ge(t),to:ge(r)}}findStepsCoord(e,t){const o=e,i=[...o];let s=t[0],n=0;const a=[];for(const[l,d]of t.entries()){let e,c;if(0===l)c=0,e=o[0];else if(l===t.length-1)c=o.length-1,e=fe(o);else if(1===i.length)n++,c=n,e=i[0],o[c]=e;else{const t=r.Utils.trimRoute(i,i[0],s.distance);n+=t.length-1,i.splice(0,t.length-1),c=n,e=fe(t),o[c]=e}a.push({...d,coords:e}),s=d}return a}findStepCoords(e,t){var r;if("instruction_start_coordinate"in e)return ge(e.instruction_start_coordinate);const o=null==(r=t.vias)?void 0:r.find((t=>t.id===e.via_uri));return o?ge(o.access_point.coord):void 0}parseResponse(e){var t;if(!e||!e.journeys)throw ie.notFound(this.rname,null==(t=e.error)?void 0:t.message);const o=[],i=e.context.timezone;for(const s of e.journeys){const e=[];for(const o of s.sections){if("waiting"===o.type||"transfer"===o.type)continue;const{from:t,to:s}=this.getSectionCoords(o);let n=[];const a=o.geojson.coordinates.reduce(((e,[t,o])=>(n.includes(`${t}-${o}`)||(n=n.concat(`${t}-${o}`),e.push(new r.Coordinates(o,t))),e)),[]),l=(new x).setStart(t).setEnd(s).setPathCoords(a);let d,c=pe.get(o.mode);if(o.path){const e=o.path.every((e=>"instruction_start_coordinate"in e||e.via_uri)),t=[];for(const r of o.path){let i;if(e){i=this.findStepCoords(r,o);const e={name:r.name,distance:r.length,coords:i};l.addStepInfo(e)}else t.push({name:r.name,distance:r.length})}e||l.setStepsInfo(this.findStepsCoord(a,t))}if("public_transport"===o.type){d={name:o.display_informations.code,routeColor:o.display_informations.color,routeTextColor:o.display_informations.text_color,directionName:o.display_informations.direction},c=pe.get(o.display_informations.physical_mode);const e={coords:a[0],name:d.directionName,distance:o.geojson.properties[0].length};l.setStepsInfo([e])}const u=new _({transitMode:c,duration:o.duration,startTime:we(o.departure_date_time,i),endTime:we(o.arrival_date_time,i),start:{name:o.from.name,coords:t},end:{name:o.to.name,coords:s},coords:a,transportInfo:d,steps:l.build()});e.push(u)}const t=new N({duration:s.duration,startTime:we(s.departure_date_time,i),endTime:we(s.arrival_date_time,i),origin:this.getSectionCoords(s.sections[0]).from,destination:this.getSectionCoords(fe(s.sections)).to,legs:e});o.push(t)}return o}};const be=new class extends ee{get rname(){return"deutsche-bahn"}async getItineraries(e,t){const r=this.getURL(e,t),o=await fetch(r).catch((()=>{throw ie.unreachableServer(this.rname,r)})),i=await o.json().catch((()=>{throw ie.responseNotParsing(this.rname,r)}));return this.parseResponse(i,t.origin,t.destination)}getURL(e,t){let o=e+"/route/v1/walking/";return o+=[t.origin,...t.waypoints||[],t.destination].map((e=>{if(null!==e.level){const t=r.Level.isRange(e.level)?e.level[0]:e.level;return e.longitude+","+e.latitude+","+t}return e.longitude+","+e.latitude})).join(";"),o+="?geometries=geojson&overview=full&steps=true",o}parseResponse(e,t,o){if(!e.segments)throw ie.notFound(this.rname);const i=e.segments.map((e=>{const t=r.Level.union(e.fromLevel,e.toLevel),o=e.polyline.map((({lon:e,lat:o})=>new r.Coordinates(o,e,null,t)));return new _({transitMode:"WALK",coords:o,start:{coords:o[0]},end:{coords:o[o.length-1]}})}));return[new N({origin:t,destination:o,legs:i})]}};function ye(e){const t=e[0];return e.slice(1).map((e=>{const r={};return t.forEach(((t,o)=>{r[t]=e[o]})),r}))}const Te=new Map;Te.set("BIKE","BIKE"),Te.set("PEDESTRIAN","WALK");function Se(e){return new r.Coordinates(e.latitude,e.longitude)}function xe(e){return e[e.length-1]}const _e=new class extends ee{get rname(){return"geovelo"}async getItineraries(e,t){const r=this.getQueryParams(),o=this.getBodyParams(t),i=new URL(e);for(const[a,l]of Object.entries(r))i.searchParams.append(a,l.toString());const s=await fetch(i,{method:"POST",headers:{apiKey:"qWHj6ax6DMttG8DX6tH9CQARaiTgQ1Di","Content-Type":"application/json"},body:JSON.stringify(o)}).catch((()=>{throw ie.unreachableServer(this.rname,i.toString())})),n=await s.json().catch((()=>{throw ie.responseNotParsing(this.rname,i.toString())}));if(!n||0===n.length)throw ie.notFound(this.rname,"No itineraries found.");return this.parseResponse(n)}getQueryParams(){return{instructions:!0,elevations:!1,geometry:!0,single_result:!1,bike_stations:!1,objects_as_ids:!1,merge_instructions:!0,show_pushing_bike_instructions:!1}}getBodyParams(e){const{origin:t,destination:r,waypoints:o}=e;let i=[];return i=o&&o.length>1?o.map((e=>({longitude:e.longitude,latitude:e.latitude}))):[{latitude:t.latitude,longitude:t.longitude},{latitude:r.latitude,longitude:r.longitude}],{transportModes:["BIKE"],waypoints:i}}parseResponse(e){if(!e||!e.length)throw ie.notFound(this.rname);const t=[];for(const o of e){const e=[];for(const t of o.sections){const o=Se(t.waypoints[0]),i=Se(xe(t.waypoints)),s=a.toGeoJSON(t.geometry,6);let n=[];const l=s.coordinates.reduce(((e,[t,o])=>(n.includes(`${t}-${o}`)||(n=n.concat(`${t}-${o}`),e.push(new r.Coordinates(o,t))),e)),[]),d=(new x).setStart(o).setEnd(i).setPathCoords(l),c=Te.get(t.transportMode),u=ye(t.details.instructions);for(const e of u){const{geometryIndex:t,roadLength:o,roadName:i}=e,n=s.coordinates[t],a={name:i,distance:o,coords:new r.Coordinates(n[1],n[0])};d.addStepInfo(a)}const h=new _({transitMode:c,duration:t.duration,startTime:new Date(t.estimatedDatetimeOfDeparture).getTime(),endTime:new Date(t.estimatedDatetimeOfArrival).getTime(),start:{coords:o},end:{coords:i},coords:l,steps:d.build()});e.push(h)}const i=new N({duration:o.duration,startTime:new Date(o.estimatedDatetimeOfDeparture).getTime(),endTime:new Date(o.estimatedDatetimeOfArrival).getTime(),origin:Se(o.waypoints[0]),destination:Se(xe(o.waypoints)),legs:e});t.push(i)}return t}},Ne=new Map;Ne.set("Air","AIRPLANE"),Ne.set("Boat","BOAT"),Ne.set("Bus","BUS"),Ne.set("BusRapidTransit","BUS"),Ne.set("Coach","BUS"),Ne.set("Ferry","FERRY"),Ne.set("Funicular","FUNICULAR"),Ne.set("LocalTrain","TRAIN"),Ne.set("LongDistanceTrain","TRAIN"),Ne.set("Metro","METRO"),Ne.set("Métro","METRO"),Ne.set("RailShuttle","TRAIN"),Ne.set("RapidTransit","BUS"),Ne.set("Shuttle","BUS"),Ne.set("SuspendedCableCar","FUNICULAR"),Ne.set("Taxi","TAXI"),Ne.set("Train","TRAIN"),Ne.set("RER","TRAIN"),Ne.set("Tramway","TRAM"),Ne.set("walking","WALK"),Ne.set("bike","BIKE");const Ee=["physical_mode:Air","physical_mode:Boat","physical_mode:Bus","physical_mode:BusRapidTransit","physical_mode:Coach","physical_mode:Ferry","physical_mode:Funicular","physical_mode:LocalTrain","physical_mode:LongDistanceTrain","physical_mode:Metro","physical_mode:RailShuttle","physical_mode:RapidTransit","physical_mode:Shuttle","physical_mode:SuspendedCableCar","physical_mode:Taxi","physical_mode:Train","physical_mode:Tramway"];function Ce(e){return new r.Coordinates(Number(e.lat),Number(e.lon))}function Re(e){return e[e.length-1]}function Ae(e,t){const r=e.substr(0,4),o=e.substr(4,2),i=e.substr(6,2),s=e.substr(9,2),n=e.substr(11,2),a=e.substr(13,2);return se(Number(r),Number(o)-1,Number(i),Number(s),Number(n),Number(a),t).getTime()}const Ie=new class extends ee{get rname(){return"idfm"}async getItineraries(e,t){const{travelMode:r}=t;if("BIKE"===r)return _e.getItineraries("https://idfm.getwemap.com/marketplace/computedroutes",t);const o=this.getURL(e,t),i=await fetch(o,{method:"GET",headers:{apiKey:"qWHj6ax6DMttG8DX6tH9CQARaiTgQ1Di"}}).catch((()=>{throw ie.unreachableServer(this.rname,o)})),s=await i.json().catch((()=>{throw ie.responseNotParsing(this.rname,o)}));if(s&&s.error)throw ie.notFound(this.rname,s.error.message);const n=this.parseResponse(s);if(!n.some((e=>w(e.transitMode,t.travelMode))))throw ie.notFound(this.rname,"Selected mode of transport was not found for this itinerary.");return n}getURL(e,t){var r;const{origin:o,destination:s,waypoints:n,travelMode:a}=t;(n||[]).length>0&&i.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==n?void 0:n.length})`);const l=new URL(e),d=new URLSearchParams;d.set("from",`${o.longitude};${o.latitude}`),d.set("to",`${s.longitude};${s.latitude}`),d.set("data_freshness","realtime"),(null==(r=t.itineraryModifiers)?void 0:r.isWheelchair)&&d.set("wheelchair","true");let c=new URLSearchParams;switch(a){case"WALK":c=this.getWalkingQuery();break;case"BIKE":c=this.getBikeQuery();break;case"CAR":c=this.getCarQuery()}return[d,c].map((e=>{for(const t of e.entries())l.searchParams.append(t[0],t[1])})),l.toString()}getCarQuery(){const e=new URLSearchParams;return Ee.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("first_section_mode[]","car"),e.append("last_section_mode[]","walking"),e.append("last_section_mode[]","car"),e}getWalkingQuery(){const e=new URLSearchParams;return Ee.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("last_section_mode[]","walking"),e}getBikeQuery(){const e=new URLSearchParams;return Ee.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","bike"),e.append("last_section_mode[]","bike"),e}getSectionCoords(e){let t,r;return t="stop_point"in e.from?e.from.stop_point.coord:"address"in e.from?e.from.address.coord:e.from.poi.coord,r="stop_point"in e.to?e.to.stop_point.coord:"address"in e.to?e.to.address.coord:e.to.poi.coord,{from:Ce(t),to:Ce(r)}}findStepsCoord(e,t){const o=e,i=[...o];let s=t[0],n=0;const a=[];for(const[l,d]of t.entries()){let e,c;if(0===l)c=0,e=o[0];else if(l===t.length-1)c=o.length-1,e=Re(o);else if(1===i.length)n++,c=n,e=i[0],o[c]=e;else{const t=r.Utils.trimRoute(i,i[0],s.distance);n+=t.length-1,i.splice(0,t.length-1),c=n,e=Re(t),o[c]=e}a.push({...d,coords:e}),s=d}return a}findStepCoords(e,t){var r;if("instruction_start_coordinate"in e)return Ce(e.instruction_start_coordinate);const o=null==(r=t.vias)?void 0:r.find((t=>t.id===e.via_uri));return o?Ce(o.access_point.coord):void 0}parseResponse(e){var t;if(!e||!e.journeys)throw ie.notFound(this.rname,null==(t=e.error)?void 0:t.message);const o=[],i=e.context.timezone;for(const s of e.journeys){const e=[];for(const o of s.sections){if("waiting"===o.type||"transfer"===o.type)continue;const{from:t,to:s}=this.getSectionCoords(o);let n=[];const a=o.geojson.coordinates.reduce(((e,[t,o])=>(n.includes(`${t}-${o}`)||(n=n.concat(`${t}-${o}`),e.push(new r.Coordinates(o,t))),e)),[]),l=(new x).setStart(t).setEnd(s).setPathCoords(a);let d,c=Ne.get(o.mode);if(o.path){const e=o.path.every((e=>"instruction_start_coordinate"in e||e.via_uri)),t=[];for(const r of o.path){let i;if(e){i=this.findStepCoords(r,o);const e={name:r.name,distance:r.length,coords:i};l.addStepInfo(e)}else t.push({name:r.name,distance:r.length})}e||l.setStepsInfo(this.findStepsCoord(a,t))}if("public_transport"===o.type){d={name:o.display_informations.code,routeColor:o.display_informations.color,routeTextColor:o.display_informations.text_color,directionName:o.display_informations.direction},c=Ne.get(o.display_informations.physical_mode);const e={coords:a[0],name:d.directionName,distance:o.geojson.properties[0].length};l.setStepsInfo([e])}const u=new _({transitMode:c,duration:o.duration,startTime:Ae(o.departure_date_time,i),endTime:Ae(o.arrival_date_time,i),start:{name:o.from.name,coords:t},end:{name:o.to.name,coords:s},coords:a,transportInfo:d,steps:l.build()});e.push(u)}const t=new N({duration:s.duration,startTime:Ae(s.departure_date_time,i),endTime:Ae(s.arrival_date_time,i),origin:this.getSectionCoords(s.sections[0]).from,destination:this.getSectionCoords(Re(s.sections)).to,legs:e});o.push(t)}return o}},Me=new Map;Me.set("CAR","CAR"),Me.set("WALK","WALK"),Me.set("BIKE","BIKE");const ke=new class extends ee{constructor(){super(...arguments),t(this,"inputModeCorrespondance",(e=>{var t;const{travelMode:r,travelModePreference:o}=e;if("WALK"===r&&(null==(t=e.itineraryModifiers)?void 0:t.isWheelchair))return"pmr";if("WALK"===r)return"walking";if("BIKE"===r)return"FASTEST"===o?"bike-fastest":"bike-safest";if("CAR"===r)return"driving";throw ie.travelModeUnimplemented(this.rname,r)}))}get rname(){return"osrm"}async getItineraries(e,t){const r=this.getURL(e,t),o=await fetch(r).catch((()=>{throw ie.unreachableServer(this.rname,r)})),i=await o.json().catch((()=>{throw ie.responseNotParsing(this.rname,r)}));return this.parseResponse(i,t.origin,t.destination,t.travelMode)}getURL(e,t){const{origin:r,destination:o}=t;let i=e+"/route/v1/"+this.inputModeCorrespondance(t)+"/";return i+=[r,...t.waypoints||[],o].map((e=>[e.longitude+","+e.latitude])).join(";"),i+="?geometries=geojson&overview=full&steps=true",t.provideItineraryAlternatives&&(i+="&alternatives=true"),i}coordinatesToJson({lat:e,lng:t,level:o}){return null===o?[t,e]:r.Level.isRange(o)?[t,e,o[0]]:[t,e,o]}jsonToCoordinates(e){const t=new r.Coordinates(e[1],e[0]);return e.length>2&&(t.level=e[2]),t}getModifierFromAngle(e){const t=o.positiveMod(o.rad2deg(e),360);return t>0&&t<60?"sharp right":t>=60&&t<140?"right":t>=140&&t<160?"slight right":t>=160&&t<=200?"straight":t>200&&t<=220?"slight left":t>220&&t<=300?"left":t>300&&t<360?"sharp left":"u turn"}noRouteFoundJson(e){return{code:"NoRoute",message:e}}itineraryToOsrmJson(e){const t=e.legs.length-1,r=e.steps,i=e.legs.map((({distance:e,duration:i,coords:s},n)=>{const a=r.filter((e=>s.find((t=>t.equals(e.coords))))),l=a.length-1;return{distance:e,duration:i||0,steps:a.map(((e,r,i)=>{let a=0===r&&0===n?"depart":"turn";a=r===l&&n===t?"arrive":a;const d=s.findIndex((t=>t.equals(e.coords))),c=r===l?d:s.findIndex((e=>e.equals(i[r+1].coords)));return{geometry:{type:"LineString",coordinates:s.slice(d,c+1).map(this.coordinatesToJson)},distance:e.distance,duration:e.duration||0,...e.name&&{name:e.name},maneuver:{bearing_before:o.rad2deg(e.previousBearing),bearing_after:o.rad2deg(e.nextBearing),location:this.coordinatesToJson(e.coords),modifier:this.getModifierFromAngle(e.angle),type:a}}}))}}));return{code:"Ok",routes:[{geometry:{type:"LineString",coordinates:e.coords.map(this.coordinatesToJson)},legs:i,distance:e.distance,duration:e.duration,weight_name:"routability",weight:0}],waypoints:[]}}parseResponse(e,t,r,o){const i=Me.get(o),{routes:s}=e;if(!s)throw ie.notFound(this.rname,e.message);return s.map((e=>{const o=e.legs.map((e=>{var t;const r=e.steps.map((e=>e.geometry.coordinates.map(this.jsonToCoordinates))).flat().filter(((e,t,r)=>0===t||!r[t-1].equals(e))),o=r[0],s=r[r.length-1],n=(new x).setPathCoords(r).setStart(o).setEnd(s);return null==(t=e.steps)||t.forEach((({maneuver:e,name:t,distance:o,duration:i})=>{const s=this.jsonToCoordinates(e.location),a=r.map((e=>e.distanceTo(s))),l=a.indexOf(Math.min(...a));if(l<0)throw new Error("Osrm Parser: Cannot find step coords in leg coordinates");n.addStepInfo({coords:r[l],name:t,distance:o,duration:i})})),new _({transitMode:i,duration:e.duration,coords:r,start:{coords:o},end:{coords:s},steps:n.build()})}));return new N({duration:e.duration,origin:t,destination:r,legs:o})}))}};function Le(e){return"BUS"===e.mode||"TRAM"===e.mode}function Pe(e){return new r.Coordinates(e.lat,e.lon)}const Ue=new Map;Ue.set("CAR","CAR"),Ue.set("WALK","WALK"),Ue.set("BIKE","BICYCLE"),Ue.set("TRANSIT","WALK,TRANSIT");const Oe=new class extends ee{get rname(){return"otp"}async getItineraries(e,t){const r=this.getURL(e,t),o=await fetch(r).catch((()=>{throw ie.unreachableServer(this.rname,r)})),i=await o.json().catch((()=>{throw ie.responseNotParsing(this.rname,r)}));return this.parseResponse(i)}getURL(e,t){const{origin:r,destination:o,waypoints:s,travelMode:n}=t,a=Ue.get(n);if(!a)throw ie.travelModeUnimplemented(this.rname,n);(s||[]).length>0&&i.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==s?void 0:s.length})`);const l=`fromPlace=${r.latitude},${r.longitude}`,d=`toPlace=${o.latitude},${o.longitude}`,c=`mode=${a}`,u=new URL(e);let{search:h}=u;return h=(h?`${h}&`:"?")+`${l}&${d}&${c}`,`${u.origin}${u.pathname}${h}`}parseResponse(e){const{plan:t}=e;if(!t)throw ie.notFound(this.rname);const o=[],i=Pe(t.from),s=Pe(t.to);for(const n of t.itineraries){const e=[];for(const o of n.legs){const t=Pe(o.from),i=Pe(o.to),s=a.decode(o.legGeometry.points).map((([e,t])=>new r.Coordinates(e,t)));let n;const l=(new x).setStart(t).setEnd(i).setPathCoords(s);Le(o)?(n={name:o.routeShortName,routeColor:o.routeColor,routeTextColor:o.routeTextColor,directionName:o.headsign},l.addStepInfo({coords:s[0],name:o.headsign})):o.steps.forEach((e=>{const t=s.map((t=>t.distanceTo(Pe(e)))),r=t.indexOf(Math.min(...t));if(r<0)throw new Error("OTP Parser: Cannot find closest step");l.addStepInfo({coords:s[r],name:e.streetName})}));const d=new _({transitMode:o.mode,duration:o.duration,startTime:o.startTime,endTime:o.endTime,start:{name:o.from.name,coords:Pe(o.from)},end:{name:o.to.name,coords:Pe(o.to)},coords:s,transportInfo:n,steps:l.build()});e.push(d)}const t=new N({duration:n.duration,startTime:n.startTime,endTime:n.endTime,origin:i,destination:s,legs:e});o.push(t)}return o}};const Be=new class extends ee{get rname(){return"wemap-multi"}async getItineraries(e,t){const{origin:o,destination:i,waypoints:s}=t,n={...t,origin:o instanceof r.Coordinates?o.toJson():o,destination:i instanceof r.Coordinates?i.toJson():i,...s&&{waypoints:s.map((e=>e instanceof r.Coordinates?e.toJson():e))}},a=await fetch(e,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(n)}).catch((()=>{throw ie.unreachableServer(this.rname,e)})),l=await a.json().catch((()=>{throw ie.responseNotParsing(this.rname,e)}));if(l.error)throw ie.notFound(this.rname,l.error);return(l.itineraries||[]).map(N.fromJson)}},Fe=[he,ve,be,Ie,ke,Oe,Be];const De=new class{getRouterByName(e){return Fe.find((t=>t.rname===e))}async getItineraries(e,t,r){const o=this.getRouterByName(e);if(!o)throw ie.notFound(e,`Unknown "${e}" remote router`);return o.getItineraries(t,r)}async getItinerariesWithFallback(e,t){let r;const o=[];for(const{name:a,endpointUrl:l}of t)try{if(r=await this.getItineraries(a,l,e),r.length)return r}catch(n){if(!(n instanceof ie))throw n;o.push({name:a,endpointUrl:l,error:n})}const i=t.map((({name:e})=>e)).join(", "),s=o.map((e=>`(${e.name}) Could not find an itinerary on endpoint: ${e.endpointUrl}. Details: ${e.error.message}`)).join("\n");throw ie.notFound(i,s)}};class $e{constructor(e,r,o=null,i=null){if(t(this,"name"),t(this,"graph"),t(this,"router"),t(this,"bounds"),t(this,"entryPoints"),this.name=i,this.graph=e,this.router=new Q(e),r.forEach((t=>{if(!e.vertices.includes(t))throw new Error(`Cannot find entry point ${t.coords.toString()} in graph "${i}"`)})),this.entryPoints=r,o)this.bounds=o;else{const t=[e.vertices.map((e=>[e.coords.lng,e.coords.lat]))],r=d({type:"polygon",coordinates:t});if(!r)throw new Error(`Cannot calculate convexHull of graph "${i}"`);this.bounds={type:"MultiPolygon",coordinates:[r.geometry.coordinates]}}}static fromOsmXml(e,t=null,r){const o={routingIoNotFound:[],routingBoundsNotFound:!1};let i;try{i=n.OsmParser.parseOsmXmlString(e)}catch(c){return o.couldNotParseFile=c instanceof Error?c.message:"Unknown error",void(null==r||r(o))}let s=[];const a=Z.createGraphFromOsmModel(i,Z.DEFAULT_WAY_SELECTOR,(e=>s=e)),l=i.nodes.filter((e=>e.tags["wemap:routing-io"])).map((e=>{var t;const r=null==(t=s.find((t=>t[0]===e.id)))?void 0:t[1];return r||o.routingIoNotFound.push(e),r||null})).filter((e=>null!==e));l.forEach((e=>a.exitVertices.add(e)));const d={type:"MultiPolygon",coordinates:[]};return i.ways.filter((({tags:e})=>e["wemap:routing-bounds"])).forEach((e=>{d.coordinates.push([e.nodes.reduce(((e,t)=>(e.push([t.coords.lng,t.coords.lat]),e)),[])])})),i.relations.filter((e=>e.tags["wemap:routing-bounds"]&&e.isMultipolygon())).forEach((e=>{const t=e.getGeoJsonPolygon();t&&d.coordinates.push(t.coordinates)})),d.coordinates.length||(o.routingBoundsNotFound=!0),null==r||r(o),new $e(a,l,d,t)}isPointInside(e){return l([e.lng,e.lat],this.bounds)}getOrderedEntryPointsSortedByDistance(e,t){const o=[...this.entryPoints];return o.sort(((o,i)=>Number(o.coords.distanceTo(e))+o.coords.distanceTo(t)-(i.coords.distanceTo(e)+i.coords.distanceTo(t))+50*(Math.abs(r.Level.diff(e.level,o.coords.level)||0)+Math.abs(r.Level.diff(t.level,o.coords.level)||0)-(Math.abs(r.Level.diff(e.level,i.coords.level)||0)+Math.abs(r.Level.diff(t.level,i.coords.level)||0)))))}getBestRouteFromEntryPointsToDestination(e,t,r){const o=this.getOrderedEntryPointsSortedByDistance(e,t);for(const i of o){const e=this.router.calculateShortestPath(i.coords,t,r).route();if(e.hasRoute)return e}return null}getBestRouteFromOriginToEntryPoints(e,t,r){const o=this.getOrderedEntryPointsSortedByDistance(e,t);for(const i of o){const t=this.router.calculateShortestPath(e,i.coords,r).route();if(t.hasRoute)return t}return null}getRouteInsideMap(e,t,r){const o=this.router.calculateShortestPath(e,t,r).route();return o.hasRoute?o:null}getTripInsideMap(e,t){return this.router.getShortestTrip(e,t)}getRoutesMultipleDestinationsInsideMap(e,t,r){return this.router.calculateShortestPathToMultipleDestinations(e,t,r)}}const We=class e{static getTurnInfoFromAngle(e){let t,r;const i=o.rad2deg(o.diffAngle(e,Math.PI)),s=Math.abs(i);return s<=20?t="straight":(t=i>0?"left":"right",s<55?r="slight":s>120&&(r="sharp")),{direction:t,directionExtra:r}}static getInfoFromStep(t){let r,o,i,s;if(t.levelChange)r="level-change",s=t.levelChange;else{r="turn";const s=e.getTurnInfoFromAngle(t.angle);o=s.direction,i=s.directionExtra}return{type:r,direction:o,directionExtra:i,levelChange:s,name:t.name,indoor:null!==t.coords.level}}static getInstructionFromStep(t){var r,o;const{direction:i,directionExtra:s}=e.getTurnInfoFromAngle(t.angle),n="straight"!==i;if(t.lastStep){if(n&&"left"===i)return"Your destination is on your left";if(n&&"right"===i)return"Your destination is on your right"}let a="";if((null==(r=t.extras)?void 0:r.isGate)?a=` on gate ${t.name}`:t.name&&(a=` on ${t.name}`),t.levelChange){if("up"===t.levelChange.direction)return"stairs"===t.levelChange.type?"Go up the stairs":"escalator"===t.levelChange.type?"Go up the escalator":"elevator"===t.levelChange.type?"Go up the elevator":"moving walkway"===t.levelChange.type?"Go up the moving walkway":"incline plane"===t.levelChange.type?"Go up the incline plane":"Go up"+a;if("down"===t.levelChange.direction)return"stairs"===t.levelChange.type?"Go down the stairs":"escalator"===t.levelChange.type?"Go down the escalator":"elevator"===t.levelChange.type?"Go down the elevator":"moving walkway"===t.levelChange.type?"Go down the moving walkway":"incline plane"===t.levelChange.type?"Go down the incline plane":"Go down"+a;if(null==(o=t.extras)?void 0:o.subwayEntrance)return`Take exit ${t.extras.subwayEntranceRef}`}if(n){if("left"===i)return"slight"===s?"Turn slightly left"+a:"Turn left"+a;if("right"===i)return"slight"===s?"Turn slightly right"+a:"Turn right"+a}return"Continue straight"}static getInstructionFromPosition(t,r){const i=t.getInfo(r);if(!i)return null;if(this.useProposals&&i.projection.distanceFromNearestElement>15)return"It seems that we are a little bit lost, please start again the localization process";const{nextStep:s}=i;if(!s)return"You are arrived";const n=r.distanceTo(s.coords),a=o.roundFactor(n,5);if(this.useProposals&&n>10)return`Continue straight for ${a}m`;let l=e.getInstructionFromStep(s);const d=t._steps.find((e=>e.levelChange&&e.number>s.number&&e.coords.distanceTo(s.coords)<10))||null;if(d&&d.levelChange){const t=s.coords.bearingTo(d.coords),{direction:r}=e.getTurnInfoFromAngle(t-s.previousBearing);l="straight"===r?"Continue straight":`Turn ${r}`;const{direction:o,type:i}=d.levelChange;l+=` and take the ${i} going ${o}`}return n>=5&&(l+=` in ${a}m`),l}};t(We,"useProposals",!1);let je=We;exports.CitywayRemoteRouter=he,exports.CustomGraphMap=$e,exports.CustomGraphMapTester=class{static createReport(e){var t;let r;const o=$e.fromOsmXml(e,null,(e=>r=e)),i=[];if((null==r?void 0:r.couldNotParseFile)||!o)return i.push({type:"could-not-parse-file",details:null==r?void 0:r.couldNotParseFile}),{errors:i};const s=o.router.calculateComponents();return s.length>1&&i.push({type:"multiple-graph-components",data:s}),(null==r?void 0:r.routingBoundsNotFound)&&i.push({type:"routing-bounds-not-found"}),(null==(t=null==r?void 0:r.routingIoNotFound)?void 0:t.length)&&i.push({type:"routing-io-not-on-graph",data:r.routingIoNotFound}),{customGraphMap:o,errors:i}}static reportToJson(e){var t,r;return{graph:null==(r=null==(t=e.customGraphMap)?void 0:t.graph)?void 0:r.toCompressedJson(),errors:e.errors.map((e=>"multiple-graph-components"===e.type?{type:e.type,data:e.data.map((e=>e.map((e=>e.id))))}:"routing-io-not-on-graph"===e.type?{type:e.type,data:e.data.map((e=>e.id))}:{type:e.type}))}}},exports.DeutscheBahnRemoteRouter=be,exports.Edge=u,exports.GeoveloRemoteRouter=_e,exports.Graph=m,exports.GraphProjection=h,exports.GraphRoute=T,exports.GraphRouter=Q,exports.GraphRouterOptionsBuilder=J,exports.IdfmRemoteRouter=Ie,exports.InstructionManager=je,exports.Itinerary=N,exports.ItineraryInfoManager=class{constructor(e=null){t(this,"_itinerary",null),t(this,"_graph",null),t(this,"_steps",[]),t(this,"_coordsNextStep",[]),t(this,"_coordsPreviousStep",[]),t(this,"_coordsDistanceTraveled",[]),t(this,"_coordsLeg",[]),t(this,"_itineraryDistanceWithoutProjections",0),this.itinerary=e}get itinerary(){return this._itinerary}set itinerary(e){if(null===e)return void(this._itinerary=null);this._itinerary=e,this._steps=e.steps,this._graph=e.toGraph(),this._coordsNextStep=new Array(e.coords.length),this._coordsPreviousStep=new Array(e.coords.length),this._coordsDistanceTraveled=new Array(e.coords.length),this._coordsLeg=new Array(e.coords.length),this._itineraryDistanceWithoutProjections=e.distance;let t=0,r=null,o=this._steps[0],i=0;e.coords.forEach(((s,n,a)=>{0!==n&&(i+=a[n-1].distanceTo(s)),this._coordsNextStep[n]=o,this._coordsPreviousStep[n]=r,this._coordsDistanceTraveled[n]=i,this._coordsLeg[n]=e.legs.find((e=>e.coords.includes(s))),t<this._steps.length&&this._steps[t].coords.equals(s)&&(r=this._steps[t],o=t===this._steps.length-1?null:this._steps[t+1],t++)}))}getInfo(e){if(!this._itinerary||!this._graph)return null;const t=this._graph.getProjection(e);if(!t)return null;let r=null;if(t.nearestElement instanceof p){const e=this._itinerary.coords.findIndex((e=>t.nearestElement.coords===e));if(-1===e)throw new Error("ItineraryInfoManager: could not find projection in itinerary (Node)");const o=this._coordsDistanceTraveled[e],i=o,s=this._itineraryDistanceWithoutProjections-o,n=t.distanceFromNearestElement+s,a=i/(i+n),l=1-a;r={nextStep:this._coordsNextStep[e],previousStep:this._coordsPreviousStep[e],projection:t,leg:this._coordsLeg[e],traveledDistance:o,remainingDistance:n,traveledPercentage:a,remainingPercentage:l}}else if(t.nearestElement instanceof u){let e=t.nearestElement.vertex1.coords,o=this._itinerary.coords.findIndex((t=>e===t));if(-1===o)throw new Error("ItineraryInfoManager: could not find projection in itinerary (Edge)");o!==this._itinerary.coords.length-1&&this._itinerary.coords[o+1]===t.nearestElement.vertex2.coords||(e=t.nearestElement.vertex2.coords,o--);const i=this._coordsDistanceTraveled[o]+t.coords.distanceTo(e),s=i,n=this._itineraryDistanceWithoutProjections-i,a=t.distanceFromNearestElement+n,l=s/(s+a),d=1-l;r={nextStep:this._coordsNextStep[o+1],previousStep:this._coordsPreviousStep[o+1],projection:t,leg:this._coordsLeg[o+1],traveledDistance:s,remainingDistance:a,traveledPercentage:l,remainingPercentage:d}}return r}},exports.Leg=_,exports.NavitiaRemoteRouter=ve,exports.NoRouteFoundError=X,exports.OsmGraphUtils=Z,exports.OsrmRemoteRouter=ke,exports.OtpRemoteRouter=Oe,exports.RemoteRouterManager=De,exports.RemoteRoutingError=ie,exports.RoutingError=re,exports.StatusCode=te,exports.Vertex=p,exports.WemapMultiRemoteRouter=Be,exports.WemapMultiRouter=class{constructor(){t(this,"maps",[])}get rname(){return"wemap-multi"}addIOMap(e){this.maps.push(e)}removeIOMap(e){this.maps=this.maps.filter((t=>t!==e))}removeAllMaps(){this.maps=[]}getMapByName(e){return this.maps.find((t=>t.name===e))}async getItineraries(e,t=[],r=this.maps){const{origin:o,destination:i}=e;t=t.filter((({name:e})=>e!==Be.rname))||[];const s=r;if(!s.length)return await De.getItinerariesWithFallback(e,t);let n,a;const l=s.find((e=>e.isPointInside(o))),d=J.fromJson(e.itineraryModifiers||{});if(l&&l.isPointInside(i)){if(n=l.getRouteInsideMap(o,i,d),!n)throw oe.notFound(l.name||"");return[N.fromGraphRoute(n)]}const c=s.find((e=>e.isPointInside(i)));let u;if(!l&&!c)return await De.getItinerariesWithFallback(e,t);if(l&&!c){if(!l.entryPoints.length)throw oe.notFound(l.name||"",`A map including the "origin" but the "destination" has been \n found (${l.name}), however, no "entrypoints" have been found to go out`);const r=e=>`Tried to calculate an itinerary from "origin" to "entrypoints" using wemap router on local map "${l.name}" and an itinerary from "entrypoints" to "destination" using remote routers (${t.map((e=>e.name)).join(", ")}), but failed. Details: ${e}.`;if(n=l.getBestRouteFromOriginToEntryPoints(o,i,d),!n){const e=`No route found from ${o.toString()} to entry points in map: ${l.name}`;throw oe.notFound(l.name||"",r(e))}const s={...e,origin:n.end,destination:i,waypoints:[]};try{u=await De.getItinerariesWithFallback(s,t)}catch(h){throw h instanceof ie&&(h.message=r(h.message)),h}return a=N.fromGraphRoute(n),u.map((e=>N.fromItineraries(a,e)))}if(!l&&c){if(!c.entryPoints.length)throw oe.notFound(c.name||"",`A map including the "destination" but the "origin" has been \n found (${c.name}), however, no "entrypoints" have been found to go in`);const r=e=>`Tried to calculate an itinerary from "origin" to "entrypoints" using remote routers (${t.map((e=>e.name)).join(", ")}) and an itinerary from "entrypoints" to "destination" using wemap router on local map "${c.name}", but failed. Details: ${e}.`;if(n=c.getBestRouteFromEntryPointsToDestination(o,i,d),!n){const e=`No route found from entry points to ${i.toString()} in map: ${c.name}`;throw oe.notFound(c.name||"",r(e))}const s={...e,origin:o,destination:n.start,waypoints:[]};try{u=await De.getItinerariesWithFallback(s,t)}catch(h){throw h instanceof ie&&(h.message=r(h.message)),h}return a=N.fromGraphRoute(n),u.map((e=>N.fromItineraries(e,a)))}if(l&&c){if(!l.entryPoints.length)throw oe.notFound(l.name||"",`One map including the "origin" (${l.name}) and another \n including the "destination" (${c.name}) has been found, however, no "entrypoints" have \n been found to go out of the origin map`);if(!c.entryPoints.length)throw oe.notFound(c.name||"",`One map including the "origin" (${l.name}) and another \n including the "destination" (${c.name}) has been found, however, no "entrypoints" have \n been found to go in the second map`);const r=e=>`Tried to calculate an itinerary from "origin" to "entrypoints1" using wemap router on local map "${l.name}", an itinerary from "entrypoints1" to "entrypoints2" using remote routers (${t.map((e=>e.name)).join(", ")}) and an itinerary from "entrypoints2" to "destination" using wemap router on local map "${c.name}", but failed. Details: ${e}.`,s=l.getBestRouteFromOriginToEntryPoints(o,i,d);if(!s){const e=`No route found from ${o.toString()} to entry points in map: ${l.name}`;throw oe.notFound(l.name||"",r(e))}const n=c.getBestRouteFromEntryPointsToDestination(o,i,d);if(!n){const e=`No route found from entry points to ${i.toString()} in map: ${c.name}`;throw oe.notFound(c.name||"",r(e))}const a={...e,origin:s.end,destination:n.start,waypoints:[]};try{u=await De.getItinerariesWithFallback(a,t)}catch(h){throw h instanceof ie&&(h.message=r(h.message)),h}return u.map((e=>N.fromItineraries(N.fromGraphRoute(s),e,N.fromGraphRoute(n))))}throw new Error("Should never happen")}},exports.WemapMultiRoutingError=oe,exports.areTransitAndTravelModeConsistent=w,exports.getDurationFromLength=g,exports.routerRequestToJson=function(e){const{origin:t,destination:r,waypoints:o,...i}=e;return{origin:t.toJson(),destination:r.toJson(),...o&&{waypoints:o.map((e=>e.toJson()))},...i}};
|
|
1
|
+
"use strict";var e=Object.defineProperty,t=(t,r,o)=>(((t,r,o)=>{r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[r]=o})(t,"symbol"!=typeof r?r+"":r,o),o);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@wemap/geo"),o=require("@wemap/maths"),i=require("@wemap/logger"),s=require("@wemap/salesman.js"),n=require("@wemap/osm"),a=require("@mapbox/polyline"),l=require("@turf/boolean-point-in-polygon"),d=require("@turf/convex");const c=class e{constructor(o,i,s={},n=e.currentUniqueId++){t(this,"level"),t(this,"bearing"),t(this,"length"),this.vertex1=o,this.vertex2=i,this.properties=s,this.id=n,this.level=r.Level.union(o.coords.level,i.coords.level),this.length=this.vertex1.distanceTo(this.vertex2),this.bearing=this.vertex1.bearingTo(this.vertex2)}static getEdgeByVertices(e,t,r){return e.find((e=>t===e.vertex1&&r===e.vertex2||r===e.vertex1&&t===e.vertex2))}reverseProperties(){const{properties:e}=this;e.incline&&(e.incline="up"===e.incline?"down":"up"),e.isOneway&&(e.isOneway=!1)}};t(c,"currentUniqueId",0);let u=c;class h{constructor(e,t,r,o){this.origin=e,this.distanceFromNearestElement=t,this.coords=r,this.nearestElement=o}}class p{constructor(e,r={}){t(this,"id",-1),this.coords=e,this.properties=r}distanceTo(e){return this.coords.distanceTo(e.coords)}bearingTo(e){return this.coords.bearingTo(e.coords)}toJson(){return{id:this.id,coords:this.coords.toCompressedJson(),...Object.keys(this.properties).length>0&&{properties:this.properties}}}static fromJson(e){const t=new p(r.Coordinates.fromCompressedJson(e.coords),e.properties);return t.id=e.id,t}}class m{constructor(e,r){t(this,"exitVertices"),this.vertices=e,this.edges=r;const o=r.filter((e=>null===e.level)).map((e=>[e.vertex1,e.vertex2])).flat(),i=r.filter((e=>null!==e.level)).map((e=>[e.vertex1,e.vertex2])).flat();this.exitVertices=new Set(o.filter((e=>i.includes(e))))}getEdgeByVertices(e,t){return u.getEdgeByVertices(this.edges,e,t)}getVertexByCoords(e){return m.getVertexByCoords(this.vertices,e)}static getVertexByCoords(e,t){return e.find((e=>e.coords.equals(t)))}getVertexByName(e){return this.vertices.find((t=>t.properties.name===e))}getEdgeByName(e){return this.edges.find((t=>t.properties.name===e))}getBoundingBox(e){if(!this.vertices.length)return null;const t=r.BoundingBox.fromCoordinates(this.vertices.map((e=>e.coords)));return e&&t.extendsWithMeasure(e),t}getProjection(e,t={}){const i="maxDistance"in t,s=t.maxDistance,n="maxBearingAngle"in t;if(n&&(!(e instanceof r.UserPosition)||null===e.bearing))return null;const a=t.maxBearingAngle,l="acceptEdgeFn"in t,d=!("useMultiLevelSegments"in t)||t.useMultiLevelSegments;let c=null;const u=t=>{if(!(e instanceof r.UserPosition))return t;const o=e.clone();return o.lat=t.lat,o.lng=t.lng,o.level=t.level,o.alt=t.alt,o.heightFromFloor=t.heightFromFloor,o.heightFromGround=t.heightFromGround,o};return this.edges.forEach((p=>{if(l&&!t.acceptEdgeFn(p))return;if(!d&&r.Level.isRange(p.level))return;if(!r.Level.intersect(p.level,e.level))return;if(n&&o.diffAngleLines(p.bearing,e.bearing)>a)return;const m=e.getSegmentProjection(p.vertex1.coords,p.vertex2.coords);if(!m)return;const g=m.distanceTo(e);i&&g>s||g<((null==c?void 0:c.distanceFromNearestElement)??Number.MAX_VALUE)&&(c=new h(e,g,u(m),p))})),n||this.vertices.forEach((t=>{let o=t.coords;if(this.exitVertices.has(t)&&null===e.level&&(o=t.coords.clone(),o.level=null),!d&&r.Level.isRange(o.level))return;if(!r.Level.intersect(o.level,e.level))return;const n=o.distanceTo(e);n<r.Constants.EPS_MM?c=new h(e,0,u(o),t):i&&n>s||n<((null==c?void 0:c.distanceFromNearestElement)??Number.MAX_VALUE)&&(c=new h(e,n,u(o),t))})),c}toJson(){return{vertices:this.vertices.map((e=>e.toJson())),edges:this.edges.map((e=>({id:e.id,vertex1Idx:this.vertices.indexOf(e.vertex1),vertex2Idx:this.vertices.indexOf(e.vertex2),...Object.keys(e.properties).length>0&&{properties:e.properties}})))}}static fromJson(e){const t=e.vertices.map((e=>p.fromJson(e))),r=e.edges.map((e=>new u(t[e.vertex1Idx],t[e.vertex2Idx],e.properties,e.id)));return new m(t,r)}toCompressedJson(){return{vertices:this.vertices.map((e=>e.coords.toCompressedJson())),verticesIds:this.vertices.map((e=>e.id)),edges:this.edges.map((e=>{const t=this.vertices.indexOf(e.vertex1),r=this.vertices.indexOf(e.vertex2),o=e.properties;return Object.keys(o).length>0?[t,r,o]:[t,r]}))}}static fromCompressedJson(e){const t=e.vertices.map((e=>new p(r.Coordinates.fromCompressedJson(e)))),o=e.edges.map((e=>new u(t[e[0]],t[e[1]],e.length>2?e[2]:{})));return new m(t,o)}static fromCoordinatesSegments(e){const t=[],r=[],o=e=>{const r=t.find((t=>t.coords.equals(e)));if(r)return r;const o=new p(e);return t.push(o),o};for(const i of e){let e=null;for(const t of i){const i=o(t);e&&r.push(new u(i,e)),e=i}}return new m(t,r)}getEdgesAtLevel(e,t=!0){return this.edges.filter((({level:o})=>t?r.Level.intersect(e,o):r.Level.contains(e,o)))}toDetailedString(){let e=`--- Network ---\nVertices: ${this.vertices.length}\nEdges: ${this.edges.length}\n---\nVertices\n`;return this.vertices.forEach((t=>{e+=t.id;const r=t.properties;0!==Object.keys(r).length&&(e+=` ${r}`)})),e+="---\nEdges\n",this.edges.forEach((t=>{e+=`${t.id} - [v1: ${t.vertex1.id}, v2: ${t.vertex2.id}]`;const r=t.properties;0!==Object.keys(r).length&&(e+=` ${r}`)})),e+="---",e}}function g(e,t=5){return e/(1e3*t/3600)}function f(e){return["AIRPLANE","BOAT","BUS","FERRY","FUNICULAR","METRO","MULTI","TRAIN","TRAM"].includes(e)}function w(e,t){return e===t||f(e)&&"TRANSIT"===t||"WALK"===e&&"TRANSIT"===t}function v(e){return{...e.firstStep&&{firstStep:!0},...e.lastStep&&{lastStep:!0},number:e.number,coords:e.coords.toCompressedJson(),...null!==e.name&&{name:e.name},angle:Number(e.angle.toFixed(2)),previousBearing:Number(e.previousBearing.toFixed(2)),nextBearing:Number(e.nextBearing.toFixed(2)),distance:Number(e.distance.toFixed(1)),duration:Number(e.duration.toFixed(1)),...null!==e.levelChange&&{levelChange:e.levelChange},...e.extras&&0!==Object.keys(e.extras).length&&{extras:e.extras}}}function b(e){return Object.assign({},e,{coords:r.Coordinates.fromCompressedJson(e.coords),firstStep:Boolean(e.firstStep),lastStep:Boolean(e.lastStep),name:e.name||null,levelChange:e.levelChange||null,extras:e.extras||null})}function y(e,t){var r,o,i,s,n,a;return e.coords.equals(t.coords)&&Math.abs(e.angle-t.angle)<=.005&&Math.abs(e.distance-t.distance)<=.05&&Math.abs(e.duration-t.duration)<=.05&&e.firstStep===t.firstStep&&e.lastStep===t.lastStep&&(null==(r=e.levelChange)?void 0:r.difference)===(null==(o=t.levelChange)?void 0:o.difference)&&(null==(i=e.levelChange)?void 0:i.direction)===(null==(s=t.levelChange)?void 0:s.direction)&&(null==(n=e.levelChange)?void 0:n.type)===(null==(a=t.levelChange)?void 0:a.type)&&e.name===t.name&&Math.abs(e.nextBearing-t.nextBearing)<=.005&&e.number===t.number&&Math.abs(e.previousBearing-t.previousBearing)<=.005}class T extends m{constructor(e,t,r,o,i){super(r,o),this.start=e,this.end=t,this.vertices=r,this.edges=o,this.edgesWeights=i}reverse(){const e=this.vertices.slice().reverse(),t=this.edges.slice().reverse(),r=this.edgesWeights.slice().reverse();return t.map((e=>new u(e.vertex2,e.vertex1,e.properties))),new T(this.start,this.end,e,t,r)}static fromCoordinates(e,t,r){const o=m.fromCoordinatesSegments([r]),i=o.edges.map((e=>g(e.length)));return new T(e,t,o.vertices,o.edges,i)}get hasRoute(){return Boolean(this.vertices.length)}}const x=o.deg2rad(20);class S{constructor(){t(this,"start",null),t(this,"end",null),t(this,"pathCoords",null),t(this,"stepsInfo",[])}setStart(e){return this.start=e,this}setEnd(e){return this.end=e,this}setPathCoords(e){return this.pathCoords=e,this}setStepsInfo(e){return this.stepsInfo=e,this}addStepInfo(e){return this.stepsInfo.push(e),this}setGraphRoute(e){const t=[],{start:i,end:s}=e;if(!e.hasRoute)return this;let n=null,a=i.bearingTo(e.vertices[0].coords);for(let d=0;d<e.vertices.length-1;d++){const i=0===d,s=e.vertices[d],l=s.coords,c=e.vertices[d+1],u=c.coords,h=e.edges[d],p=s.bearingTo(c),m=o.diffAngle(a,p+Math.PI),g=t.length?t[t.length-1]:null,{isSubwayEntrance:f,isGate:w,subwayEntranceRef:v}=s.properties,{isElevator:b,areEscalators:y,areStairs:T,isMovingWalkway:S,incline:_}=h.properties;let N,E=null;E=b?"elevator":y?"escalator":T?"stairs":S?"moving walkway":"incline plane",(T||b)&&_&&!(null==g?void 0:g.levelChange)&&(N=_);const C=d>0?e.edges[d-1]:null,R=(null==C?void 0:C.properties)||{},I=Boolean(R.incline&&R.areStairs&&(!_||!T)),A=s.properties.isSubwayEntrance,M=h.properties.name||null,k=e.edgesWeights[d],L={...f&&{isSubwayEntrance:f},...v&&{subwayEntranceRef:v},...w&&{isGate:w}};let P=Math.abs(o.diffAngle(Math.PI,m))>=x;const U=r.Level.isRange(h.level)&&!r.Level.isRange(l.level)||N;P=P&&!(l.level&&r.Level.isRange(l.level));const F=(null==g?void 0:g.levelChange)&&!r.Level.isRange(l.level)||I;if(i||(P||U||F||A)){let e;if(U){const t=r.Level.diff(l.level,u.level)||0;let o=t>0?"up":"down";N&&(o=N),e={difference:t,direction:o,...E&&{type:E}}}n={coords:l,...M&&{name:M},extras:L,levelChange:e,distance:0,duration:0},t.push(n)}n.distance+=l.distanceTo(u),n.duration+=k,a=p}const l=e.vertices[e.vertices.length-1].coords;return r.Coordinates.equals(l,s)||t.push({coords:l}),this.setStart(i),this.setEnd(s),this.setPathCoords(e.vertices.map((e=>e.coords))),this.setStepsInfo(t),this}build(){const{pathCoords:e,start:t,end:r}=this;if(!e)return i.warn('StepsBuilder: Missing "pathCoords" property to build steps'),[];if(!t)return i.warn('StepsBuilder: Missing "from" property to build steps'),[];if(!r)return i.warn('StepsBuilder: Missing "to" property to build steps'),[];0===this.stepsInfo.length&&this.setGraphRoute(T.fromCoordinates(t,r,e));const{stepsInfo:s}=this;return s.map(((i,n)=>{const a=e.findIndex((e=>e.equals(i.coords)));if(-1===a)throw new Error("Cannot find step coordinates in itinerary coordinates.");const l=0===a?t:e[a-1],d=a===e.length-1?r:e[a+1],c=l.bearingTo(i.coords),u=i.coords.bearingTo(d);let h=0;const p=n===s.length-1,m=p?e[e.length-1]:s[n+1].coords;let f=a;for(;!e[f].equals(m);)h+=e[f].distanceTo(e[f+1]),f++;return{coords:i.coords,name:i.name||null,number:n+1,previousBearing:c,nextBearing:u,angle:o.diffAngle(c,u+Math.PI),firstStep:0===n,lastStep:p,distance:h,duration:i.duration||g(h),levelChange:i.levelChange||null,extras:i.extras||null}}))}}class _{constructor({start:e,end:o,coords:i,transitMode:s,duration:n,startTime:a,endTime:l,transportInfo:d,steps:c}){t(this,"start"),t(this,"end"),t(this,"coords"),t(this,"distance"),t(this,"transitMode"),t(this,"duration"),t(this,"startTime"),t(this,"endTime"),t(this,"steps"),t(this,"transportInfo"),this.start={name:e.name||null,coords:e.coords},this.end={name:o.name||null,coords:o.coords},this.coords=i,this.transitMode=s,this.distance=r.Utils.calcDistance(i),this.duration="number"==typeof n?n:g(this.distance),this.startTime="number"==typeof a?a:null,this.endTime="number"==typeof l?l:null,this.transportInfo=d||null,this.steps=Array.isArray(c)?c:(new S).setStart(e.coords).setEnd(o.coords).setPathCoords(i).build()}isPublicTransport(){return f(this.transitMode)}toGraph(){return m.fromCoordinatesSegments([this.coords])}static equals(e,t){var r,o;if(!(e.transitMode===t.transitMode&&Math.abs(e.duration-t.duration)<=.05&&e.startTime===t.startTime&&e.endTime===t.endTime&&e.start.name===t.start.name&&e.start.coords.equals(t.start.coords)&&e.end.name===t.end.name&&e.end.coords.equals(t.end.coords)&&e.coords.length===t.coords.length&&(e.steps===t.steps||(null==(r=e.steps)?void 0:r.length)===(null==(o=t.steps)?void 0:o.length))))return!1;let i;for(i=0;i<e.coords.length;i++)if(!e.coords[i].equals(t.coords[i]))return!1;for(i=0;i<e.steps.length;i++)if(!y(e.steps[i],t.steps[i]))return!1;if(e.transportInfo!==t.transportInfo){if(null===e.transportInfo||null===t.transportInfo)return!1;if(e.transportInfo.name!==t.transportInfo.name||e.transportInfo.routeColor!==t.transportInfo.routeColor||e.transportInfo.routeTextColor!==t.transportInfo.routeTextColor||e.transportInfo.directionName!==t.transportInfo.directionName)return!1}return!0}equals(e){return _.equals(this,e)}toJson(){return{transitMode:this.transitMode,start:{coords:this.start.coords.toCompressedJson(),...this.start.name&&{name:this.start.name}},end:{coords:this.end.coords.toCompressedJson(),...this.end.name&&{name:this.end.name}},distance:Number(this.distance.toFixed(1)),duration:Number(this.duration.toFixed(1)),coords:this.coords.map((e=>e.toCompressedJson())),steps:this.steps.map(v),...null!==this.startTime&&{startTime:this.startTime},...null!==this.endTime&&{endTime:this.endTime},...null!==this.transportInfo&&{transportInfo:this.transportInfo}}}static fromJson(e){var t;return new _(Object.assign({},e,{start:{coords:r.Coordinates.fromCompressedJson(e.start.coords),name:e.start.name||null},end:{coords:r.Coordinates.fromCompressedJson(e.end.coords),name:e.end.name||null},coords:e.coords.map(r.Coordinates.fromCompressedJson),steps:(null==(t=e.steps)?void 0:t.map(b))||null}))}static fromGraphRoute(e,t="WALK"){return new _({start:{coords:e.start},end:{coords:e.end},coords:e.vertices.map((e=>e.coords)),duration:e.edgesWeights.reduce(((e,t)=>e+t),0),transitMode:t,steps:(new S).setGraphRoute(e).build()})}multiplyLevel(e){this.start.coords.level=r.Level.multiplyBy(this.start.coords.level,e),this.end.coords.level=r.Level.multiplyBy(this.end.coords.level,e);for(const t of this.coords)t.level=r.Level.multiplyBy(t.level,e);this.steps.forEach((t=>{t.coords.level=r.Level.multiplyBy(t.coords.level,e)}))}}class N{constructor({origin:e,destination:r,duration:o,legs:i,startTime:s,endTime:n}){t(this,"origin"),t(this,"destination"),t(this,"duration"),t(this,"legs"),t(this,"_transitMode",null),t(this,"startTime"),t(this,"endTime"),t(this,"_coords",null),t(this,"_distance",null),this.origin=e,this.destination=r,this.legs=i,this.duration="number"==typeof o?o:this.legs.reduce(((e,t)=>e+t.duration),0),this.startTime="number"==typeof s?s:null,this.endTime="number"==typeof n?n:null,this.updateStepsFromLegs()}set coords(e){throw new Error("Itinerary.coords cannot be set. They are calculated from Itinerary.legs.")}get coords(){return this._coords||(this._coords=this.legs.map((e=>e.coords)).flat().filter(((e,t,r)=>0===t||!r[t-1].equals(e)))),this._coords}set steps(e){throw new Error("Itinerary.step cannot be set. They are calculated from Itinerary.legs.")}get steps(){return this.legs.map((e=>e.steps)).flat()}set transitMode(e){throw new Error("Itinerary.transitMode cannot be set. They are calculated from Itinerary.legs.")}get transitMode(){if(!this._transitMode){const e=new Set(this.legs.map((e=>e.transitMode)));if(e.delete("WALK"),e.size>1)return this._transitMode="MULTI",this._transitMode;if(1===e.size)return this._transitMode=e.values().next().value,this._transitMode;this._transitMode="WALK"}return this._transitMode}set distance(e){throw new Error("Itinerary.distance cannot be set. They are calculated from Itinerary.legs.")}get distance(){return null===this._distance&&(this._distance=r.Utils.calcDistance(this.coords)),this._distance}toGraph(){return m.fromCoordinatesSegments([this.coords])}static fromItineraries(...e){return new N({origin:e[0].origin,destination:e[e.length-1].destination,legs:e.map((e=>e.legs)).flat()})}static fromOrderedPointsArray(e,t,o){const i=e=>new r.Coordinates(e[0],e[1],null,e[2]);return this.fromOrderedCoordinates(e.map(i),i(t),i(o))}static fromOrderedCoordinates(e,t,r,o="WALK"){const i=(new S).setPathCoords(e).setStart(t).setEnd(r).build(),s=new _({start:{coords:t},end:{coords:r},coords:e,transitMode:o,steps:i});return new N({origin:t,destination:r,legs:[s]})}static equals(e,t){if(!(e.origin.equals(t.origin)&&e.destination.equals(t.destination)&&Math.abs(e.distance-t.distance)<=.05&&Math.abs(e.duration-t.duration)<=.05&&e.startTime===t.startTime&&e.endTime===t.endTime&&e.legs.length===t.legs.length))return!1;for(let r=0;r<e.legs.length;r++)if(!e.legs[r].equals(t.legs[r]))return!1;return!0}equals(e){return N.equals(this,e)}toJson(){return{origin:this.origin.toJson(),destination:this.destination.toJson(),distance:Number(this.distance.toFixed(1)),duration:Number(this.duration.toFixed(1)),transitMode:this.transitMode,legs:this.legs.map((e=>e.toJson())),...null!==this.startTime&&{startTime:this.startTime},...null!==this.endTime&&{endTime:this.endTime}}}static fromJson(e){return new N({origin:r.Coordinates.fromJson(e.origin),destination:r.Coordinates.fromJson(e.destination),duration:e.duration,legs:e.legs.map(_.fromJson),startTime:e.startTime,endTime:e.endTime})}static fromGraphRoute(e,t="WALK"){const r=_.fromGraphRoute(e,t);return new N({origin:e.start,destination:e.end,legs:[r]})}multiplyLevel(e){this.origin.level=r.Level.multiplyBy(this.origin.level,e),this.destination.level=r.Level.multiplyBy(this.destination.level,e),this.legs.forEach((t=>t.multiplyLevel(e)))}forceUnknownLevelTo0(){this.origin.level=this.origin.level||0,this.destination.level=this.destination.level||0;for(const e of this.legs){e.start.coords.level=e.start.coords.level||0,e.end.coords.level=e.end.coords.level||0;for(const t of e.coords)t.level=t.level||0;if(e.steps)for(const t of e.steps)t.coords.level=t.coords.level||0}if(this._coords)for(const e of this._coords)e.level=e.level||0}toGeoJson(){const e=(e,t,r)=>({type:"Feature",properties:{name:t,level:e.level,...r&&{type:r}},geometry:{type:"Point",coordinates:[e.lng,e.lat]}}),t=[...new Set(this.coords.map((e=>r.Level.toString(e.level))))].map(r.Level.fromString).map((e=>[e,r.Utils.createSegmentsAtLevel(this.coords,e,!0)])).map((([e,t])=>((e,t)=>({type:"Feature",properties:{level:t,name:null==t?void 0:t.toString()},geometry:{type:"MultiLineString",coordinates:e.map((e=>e.map((({lat:e,lng:t})=>[t,e]))))}}))(t,e))),o=this.legs.map(((t,r)=>e(t.start.coords,`Leg ${r} start`,"leg-start"))),i=this.legs.map(((t,r)=>e(t.end.coords,`Leg ${r} end`,"leg-end"))),s=this.steps.map((t=>e(t.coords,`Step ${t.number}`,"step")));return{type:"FeatureCollection",features:[e(this.origin,"origin","origin"),e(this.destination,"destination","destination"),...t,...o,...i,...s]}}updateStepsFromLegs(){const e=this.coords.filter(((e,t,r)=>0===t||!r[t-1].equals(e))),t=this.legs.map((e=>e.steps)).flat();t.map(((r,i)=>{const s=e.findIndex((e=>e.equals(r.coords)));if(-1===s)throw new Error("Cannot find step coordinates in itinerary coordinates.");const n=0===s?this.origin:e[s-1],a=s===e.length-1?this.destination:e[s+1];r.previousBearing=n.bearingTo(r.coords),r.nextBearing=r.coords.bearingTo(a),r.angle=o.diffAngle(r.previousBearing,r.nextBearing+Math.PI),r.number=i+1,r.firstStep=0===i,r.lastStep=i===t.length-1}))}}var E,C,R="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},I={exports:{}};E=I,C=I.exports,function(e,t){var r="function",o="undefined",i="object",s="string",n="major",a="model",l="name",d="type",c="vendor",u="version",h="architecture",p="console",m="mobile",g="tablet",f="smarttv",w="wearable",v="embedded",b="Amazon",y="Apple",T="ASUS",x="BlackBerry",S="Browser",_="Chrome",N="Firefox",R="Google",I="Huawei",A="LG",M="Microsoft",k="Motorola",L="Opera",P="Samsung",U="Sharp",F="Sony",O="Xiaomi",B="Zebra",D="Facebook",$="Chromium OS",W="Mac OS",j=function(e){for(var t={},r=0;r<e.length;r++)t[e[r].toUpperCase()]=e[r];return t},G=function(e,t){return typeof e===s&&-1!==q(t).indexOf(q(e))},q=function(e){return e.toLowerCase()},K=function(e,t){if(typeof e===s)return e=e.replace(/^\s\s*/,""),typeof t===o?e:e.substring(0,350)},J=function(e,o){for(var s,n,a,l,d,c,u=0;u<o.length&&!d;){var h=o[u],p=o[u+1];for(s=n=0;s<h.length&&!d&&h[s];)if(d=h[s++].exec(e))for(a=0;a<p.length;a++)c=d[++n],typeof(l=p[a])===i&&l.length>0?2===l.length?typeof l[1]==r?this[l[0]]=l[1].call(this,c):this[l[0]]=l[1]:3===l.length?typeof l[1]!==r||l[1].exec&&l[1].test?this[l[0]]=c?c.replace(l[1],l[2]):t:this[l[0]]=c?l[1].call(this,c,l[2]):t:4===l.length&&(this[l[0]]=c?l[3].call(this,c.replace(l[1],l[2])):t):this[l]=c||t;u+=2}},V=function(e,r){for(var o in r)if(typeof r[o]===i&&r[o].length>0){for(var s=0;s<r[o].length;s++)if(G(r[o][s],e))return"?"===o?t:o}else if(G(r[o],e))return"?"===o?t:o;return e},z={ME:"4.90","NT 3.11":"NT3.51","NT 4.0":"NT4.0",2e3:"NT 5.0",XP:["NT 5.1","NT 5.2"],Vista:"NT 6.0",7:"NT 6.1",8:"NT 6.2",8.1:"NT 6.3",10:["NT 6.4","NT 10.0"],RT:"ARM"},H={browser:[[/\b(?:crmo|crios)\/([\w\.]+)/i],[u,[l,"Chrome"]],[/edg(?:e|ios|a)?\/([\w\.]+)/i],[u,[l,"Edge"]],[/(opera mini)\/([-\w\.]+)/i,/(opera [mobiletab]{3,6})\b.+version\/([-\w\.]+)/i,/(opera)(?:.+version\/|[\/ ]+)([\w\.]+)/i],[l,u],[/opios[\/ ]+([\w\.]+)/i],[u,[l,L+" Mini"]],[/\bopr\/([\w\.]+)/i],[u,[l,L]],[/(kindle)\/([\w\.]+)/i,/(lunascape|maxthon|netfront|jasmine|blazer)[\/ ]?([\w\.]*)/i,/(avant |iemobile|slim)(?:browser)?[\/ ]?([\w\.]*)/i,/(ba?idubrowser)[\/ ]?([\w\.]+)/i,/(?:ms|\()(ie) ([\w\.]+)/i,/(flock|rockmelt|midori|epiphany|silk|skyfire|bolt|iron|vivaldi|iridium|phantomjs|bowser|quark|qupzilla|falkon|rekonq|puffin|brave|whale(?!.+naver)|qqbrowserlite|qq|duckduckgo)\/([-\w\.]+)/i,/(heytap|ovi)browser\/([\d\.]+)/i,/(weibo)__([\d\.]+)/i],[l,u],[/(?:\buc? ?browser|(?:juc.+)ucweb)[\/ ]?([\w\.]+)/i],[u,[l,"UC"+S]],[/microm.+\bqbcore\/([\w\.]+)/i,/\bqbcore\/([\w\.]+).+microm/i],[u,[l,"WeChat(Win) Desktop"]],[/micromessenger\/([\w\.]+)/i],[u,[l,"WeChat"]],[/konqueror\/([\w\.]+)/i],[u,[l,"Konqueror"]],[/trident.+rv[: ]([\w\.]{1,9})\b.+like gecko/i],[u,[l,"IE"]],[/ya(?:search)?browser\/([\w\.]+)/i],[u,[l,"Yandex"]],[/(avast|avg)\/([\w\.]+)/i],[[l,/(.+)/,"$1 Secure "+S],u],[/\bfocus\/([\w\.]+)/i],[u,[l,N+" Focus"]],[/\bopt\/([\w\.]+)/i],[u,[l,L+" Touch"]],[/coc_coc\w+\/([\w\.]+)/i],[u,[l,"Coc Coc"]],[/dolfin\/([\w\.]+)/i],[u,[l,"Dolphin"]],[/coast\/([\w\.]+)/i],[u,[l,L+" Coast"]],[/miuibrowser\/([\w\.]+)/i],[u,[l,"MIUI "+S]],[/fxios\/([-\w\.]+)/i],[u,[l,N]],[/\bqihu|(qi?ho?o?|360)browser/i],[[l,"360 "+S]],[/(oculus|samsung|sailfish|huawei)browser\/([\w\.]+)/i],[[l,/(.+)/,"$1 "+S],u],[/(comodo_dragon)\/([\w\.]+)/i],[[l,/_/g," "],u],[/(electron)\/([\w\.]+) safari/i,/(tesla)(?: qtcarbrowser|\/(20\d\d\.[-\w\.]+))/i,/m?(qqbrowser|baiduboxapp|2345Explorer)[\/ ]?([\w\.]+)/i],[l,u],[/(metasr)[\/ ]?([\w\.]+)/i,/(lbbrowser)/i,/\[(linkedin)app\]/i],[l],[/((?:fban\/fbios|fb_iab\/fb4a)(?!.+fbav)|;fbav\/([\w\.]+);)/i],[[l,D],u],[/(kakao(?:talk|story))[\/ ]([\w\.]+)/i,/(naver)\(.*?(\d+\.[\w\.]+).*\)/i,/safari (line)\/([\w\.]+)/i,/\b(line)\/([\w\.]+)\/iab/i,/(chromium|instagram)[\/ ]([-\w\.]+)/i],[l,u],[/\bgsa\/([\w\.]+) .*safari\//i],[u,[l,"GSA"]],[/musical_ly(?:.+app_?version\/|_)([\w\.]+)/i],[u,[l,"TikTok"]],[/headlesschrome(?:\/([\w\.]+)| )/i],[u,[l,_+" Headless"]],[/ wv\).+(chrome)\/([\w\.]+)/i],[[l,_+" WebView"],u],[/droid.+ version\/([\w\.]+)\b.+(?:mobile safari|safari)/i],[u,[l,"Android "+S]],[/(chrome|omniweb|arora|[tizenoka]{5} ?browser)\/v?([\w\.]+)/i],[l,u],[/version\/([\w\.\,]+) .*mobile\/\w+ (safari)/i],[u,[l,"Mobile Safari"]],[/version\/([\w(\.|\,)]+) .*(mobile ?safari|safari)/i],[u,l],[/webkit.+?(mobile ?safari|safari)(\/[\w\.]+)/i],[l,[u,V,{"1.0":"/8",1.2:"/1",1.3:"/3","2.0":"/412","2.0.2":"/416","2.0.3":"/417","2.0.4":"/419","?":"/"}]],[/(webkit|khtml)\/([\w\.]+)/i],[l,u],[/(navigator|netscape\d?)\/([-\w\.]+)/i],[[l,"Netscape"],u],[/mobile vr; rv:([\w\.]+)\).+firefox/i],[u,[l,N+" Reality"]],[/ekiohf.+(flow)\/([\w\.]+)/i,/(swiftfox)/i,/(icedragon|iceweasel|camino|chimera|fennec|maemo browser|minimo|conkeror|klar)[\/ ]?([\w\.\+]+)/i,/(seamonkey|k-meleon|icecat|iceape|firebird|phoenix|palemoon|basilisk|waterfox)\/([-\w\.]+)$/i,/(firefox)\/([\w\.]+)/i,/(mozilla)\/([\w\.]+) .+rv\:.+gecko\/\d+/i,/(polaris|lynx|dillo|icab|doris|amaya|w3m|netsurf|sleipnir|obigo|mosaic|(?:go|ice|up)[\. ]?browser)[-\/ ]?v?([\w\.]+)/i,/(links) \(([\w\.]+)/i,/panasonic;(viera)/i],[l,u],[/(cobalt)\/([\w\.]+)/i],[l,[u,/master.|lts./,""]]],cpu:[[/(?:(amd|x(?:(?:86|64)[-_])?|wow|win)64)[;\)]/i],[[h,"amd64"]],[/(ia32(?=;))/i],[[h,q]],[/((?:i[346]|x)86)[;\)]/i],[[h,"ia32"]],[/\b(aarch64|arm(v?8e?l?|_?64))\b/i],[[h,"arm64"]],[/\b(arm(?:v[67])?ht?n?[fl]p?)\b/i],[[h,"armhf"]],[/windows (ce|mobile); ppc;/i],[[h,"arm"]],[/((?:ppc|powerpc)(?:64)?)(?: mac|;|\))/i],[[h,/ower/,"",q]],[/(sun4\w)[;\)]/i],[[h,"sparc"]],[/((?:avr32|ia64(?=;))|68k(?=\))|\barm(?=v(?:[1-7]|[5-7]1)l?|;|eabi)|(?=atmel )avr|(?:irix|mips|sparc)(?:64)?\b|pa-risc)/i],[[h,q]]],device:[[/\b(sch-i[89]0\d|shw-m380s|sm-[ptx]\w{2,4}|gt-[pn]\d{2,4}|sgh-t8[56]9|nexus 10)/i],[a,[c,P],[d,g]],[/\b((?:s[cgp]h|gt|sm)-\w+|sc[g-]?[\d]+a?|galaxy nexus)/i,/samsung[- ]([-\w]+)/i,/sec-(sgh\w+)/i],[a,[c,P],[d,m]],[/(?:\/|\()(ip(?:hone|od)[\w, ]*)(?:\/|;)/i],[a,[c,y],[d,m]],[/\((ipad);[-\w\),; ]+apple/i,/applecoremedia\/[\w\.]+ \((ipad)/i,/\b(ipad)\d\d?,\d\d?[;\]].+ios/i],[a,[c,y],[d,g]],[/(macintosh);/i],[a,[c,y]],[/\b(sh-?[altvz]?\d\d[a-ekm]?)/i],[a,[c,U],[d,m]],[/\b((?:ag[rs][23]?|bah2?|sht?|btv)-a?[lw]\d{2})\b(?!.+d\/s)/i],[a,[c,I],[d,g]],[/(?:huawei|honor)([-\w ]+)[;\)]/i,/\b(nexus 6p|\w{2,4}e?-[atu]?[ln][\dx][012359c][adn]?)\b(?!.+d\/s)/i],[a,[c,I],[d,m]],[/\b(poco[\w ]+)(?: bui|\))/i,/\b; (\w+) build\/hm\1/i,/\b(hm[-_ ]?note?[_ ]?(?:\d\w)?) bui/i,/\b(redmi[\-_ ]?(?:note|k)?[\w_ ]+)(?: bui|\))/i,/\b(mi[-_ ]?(?:a\d|one|one[_ ]plus|note lte|max|cc)?[_ ]?(?:\d?\w?)[_ ]?(?:plus|se|lite)?)(?: bui|\))/i],[[a,/_/g," "],[c,O],[d,m]],[/\b(mi[-_ ]?(?:pad)(?:[\w_ ]+))(?: bui|\))/i],[[a,/_/g," "],[c,O],[d,g]],[/; (\w+) bui.+ oppo/i,/\b(cph[12]\d{3}|p(?:af|c[al]|d\w|e[ar])[mt]\d0|x9007|a101op)\b/i],[a,[c,"OPPO"],[d,m]],[/vivo (\w+)(?: bui|\))/i,/\b(v[12]\d{3}\w?[at])(?: bui|;)/i],[a,[c,"Vivo"],[d,m]],[/\b(rmx[12]\d{3})(?: bui|;|\))/i],[a,[c,"Realme"],[d,m]],[/\b(milestone|droid(?:[2-4x]| (?:bionic|x2|pro|razr))?:?( 4g)?)\b[\w ]+build\//i,/\bmot(?:orola)?[- ](\w*)/i,/((?:moto[\w\(\) ]+|xt\d{3,4}|nexus 6)(?= bui|\)))/i],[a,[c,k],[d,m]],[/\b(mz60\d|xoom[2 ]{0,2}) build\//i],[a,[c,k],[d,g]],[/((?=lg)?[vl]k\-?\d{3}) bui| 3\.[-\w; ]{10}lg?-([06cv9]{3,4})/i],[a,[c,A],[d,g]],[/(lm(?:-?f100[nv]?|-[\w\.]+)(?= bui|\))|nexus [45])/i,/\blg[-e;\/ ]+((?!browser|netcast|android tv)\w+)/i,/\blg-?([\d\w]+) bui/i],[a,[c,A],[d,m]],[/(ideatab[-\w ]+)/i,/lenovo ?(s[56]000[-\w]+|tab(?:[\w ]+)|yt[-\d\w]{6}|tb[-\d\w]{6})/i],[a,[c,"Lenovo"],[d,g]],[/(?:maemo|nokia).*(n900|lumia \d+)/i,/nokia[-_ ]?([-\w\.]*)/i],[[a,/_/g," "],[c,"Nokia"],[d,m]],[/(pixel c)\b/i],[a,[c,R],[d,g]],[/droid.+; (pixel[\daxl ]{0,6})(?: bui|\))/i],[a,[c,R],[d,m]],[/droid.+ (a?\d[0-2]{2}so|[c-g]\d{4}|so[-gl]\w+|xq-a\w[4-7][12])(?= bui|\).+chrome\/(?![1-6]{0,1}\d\.))/i],[a,[c,F],[d,m]],[/sony tablet [ps]/i,/\b(?:sony)?sgp\w+(?: bui|\))/i],[[a,"Xperia Tablet"],[c,F],[d,g]],[/ (kb2005|in20[12]5|be20[12][59])\b/i,/(?:one)?(?:plus)? (a\d0\d\d)(?: b|\))/i],[a,[c,"OnePlus"],[d,m]],[/(alexa)webm/i,/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i,/(kf[a-z]+)( bui|\)).+silk\//i],[a,[c,b],[d,g]],[/((?:sd|kf)[0349hijorstuw]+)( bui|\)).+silk\//i],[[a,/(.+)/g,"Fire Phone $1"],[c,b],[d,m]],[/(playbook);[-\w\),; ]+(rim)/i],[a,c,[d,g]],[/\b((?:bb[a-f]|st[hv])100-\d)/i,/\(bb10; (\w+)/i],[a,[c,x],[d,m]],[/(?:\b|asus_)(transfo[prime ]{4,10} \w+|eeepc|slider \w+|nexus 7|padfone|p00[cj])/i],[a,[c,T],[d,g]],[/ (z[bes]6[027][012][km][ls]|zenfone \d\w?)\b/i],[a,[c,T],[d,m]],[/(nexus 9)/i],[a,[c,"HTC"],[d,g]],[/(htc)[-;_ ]{1,2}([\w ]+(?=\)| bui)|\w+)/i,/(zte)[- ]([\w ]+?)(?: bui|\/|\))/i,/(alcatel|geeksphone|nexian|panasonic(?!(?:;|\.))|sony(?!-bra))[-_ ]?([-\w]*)/i],[c,[a,/_/g," "],[d,m]],[/droid.+; ([ab][1-7]-?[0178a]\d\d?)/i],[a,[c,"Acer"],[d,g]],[/droid.+; (m[1-5] note) bui/i,/\bmz-([-\w]{2,})/i],[a,[c,"Meizu"],[d,m]],[/(blackberry|benq|palm(?=\-)|sonyericsson|acer|asus|dell|meizu|motorola|polytron)[-_ ]?([-\w]*)/i,/(hp) ([\w ]+\w)/i,/(asus)-?(\w+)/i,/(microsoft); (lumia[\w ]+)/i,/(lenovo)[-_ ]?([-\w]+)/i,/(jolla)/i,/(oppo) ?([\w ]+) bui/i],[c,a,[d,m]],[/(kobo)\s(ereader|touch)/i,/(archos) (gamepad2?)/i,/(hp).+(touchpad(?!.+tablet)|tablet)/i,/(kindle)\/([\w\.]+)/i,/(nook)[\w ]+build\/(\w+)/i,/(dell) (strea[kpr\d ]*[\dko])/i,/(le[- ]+pan)[- ]+(\w{1,9}) bui/i,/(trinity)[- ]*(t\d{3}) bui/i,/(gigaset)[- ]+(q\w{1,9}) bui/i,/(vodafone) ([\w ]+)(?:\)| bui)/i],[c,a,[d,g]],[/(surface duo)/i],[a,[c,M],[d,g]],[/droid [\d\.]+; (fp\du?)(?: b|\))/i],[a,[c,"Fairphone"],[d,m]],[/(u304aa)/i],[a,[c,"AT&T"],[d,m]],[/\bsie-(\w*)/i],[a,[c,"Siemens"],[d,m]],[/\b(rct\w+) b/i],[a,[c,"RCA"],[d,g]],[/\b(venue[\d ]{2,7}) b/i],[a,[c,"Dell"],[d,g]],[/\b(q(?:mv|ta)\w+) b/i],[a,[c,"Verizon"],[d,g]],[/\b(?:barnes[& ]+noble |bn[rt])([\w\+ ]*) b/i],[a,[c,"Barnes & Noble"],[d,g]],[/\b(tm\d{3}\w+) b/i],[a,[c,"NuVision"],[d,g]],[/\b(k88) b/i],[a,[c,"ZTE"],[d,g]],[/\b(nx\d{3}j) b/i],[a,[c,"ZTE"],[d,m]],[/\b(gen\d{3}) b.+49h/i],[a,[c,"Swiss"],[d,m]],[/\b(zur\d{3}) b/i],[a,[c,"Swiss"],[d,g]],[/\b((zeki)?tb.*\b) b/i],[a,[c,"Zeki"],[d,g]],[/\b([yr]\d{2}) b/i,/\b(dragon[- ]+touch |dt)(\w{5}) b/i],[[c,"Dragon Touch"],a,[d,g]],[/\b(ns-?\w{0,9}) b/i],[a,[c,"Insignia"],[d,g]],[/\b((nxa|next)-?\w{0,9}) b/i],[a,[c,"NextBook"],[d,g]],[/\b(xtreme\_)?(v(1[045]|2[015]|[3469]0|7[05])) b/i],[[c,"Voice"],a,[d,m]],[/\b(lvtel\-)?(v1[12]) b/i],[[c,"LvTel"],a,[d,m]],[/\b(ph-1) /i],[a,[c,"Essential"],[d,m]],[/\b(v(100md|700na|7011|917g).*\b) b/i],[a,[c,"Envizen"],[d,g]],[/\b(trio[-\w\. ]+) b/i],[a,[c,"MachSpeed"],[d,g]],[/\btu_(1491) b/i],[a,[c,"Rotor"],[d,g]],[/(shield[\w ]+) b/i],[a,[c,"Nvidia"],[d,g]],[/(sprint) (\w+)/i],[c,a,[d,m]],[/(kin\.[onetw]{3})/i],[[a,/\./g," "],[c,M],[d,m]],[/droid.+; (cc6666?|et5[16]|mc[239][23]x?|vc8[03]x?)\)/i],[a,[c,B],[d,g]],[/droid.+; (ec30|ps20|tc[2-8]\d[kx])\)/i],[a,[c,B],[d,m]],[/smart-tv.+(samsung)/i],[c,[d,f]],[/hbbtv.+maple;(\d+)/i],[[a,/^/,"SmartTV"],[c,P],[d,f]],[/(nux; netcast.+smarttv|lg (netcast\.tv-201\d|android tv))/i],[[c,A],[d,f]],[/(apple) ?tv/i],[c,[a,y+" TV"],[d,f]],[/crkey/i],[[a,_+"cast"],[c,R],[d,f]],[/droid.+aft(\w)( bui|\))/i],[a,[c,b],[d,f]],[/\(dtv[\);].+(aquos)/i,/(aquos-tv[\w ]+)\)/i],[a,[c,U],[d,f]],[/(bravia[\w ]+)( bui|\))/i],[a,[c,F],[d,f]],[/(mitv-\w{5}) bui/i],[a,[c,O],[d,f]],[/Hbbtv.*(technisat) (.*);/i],[c,a,[d,f]],[/\b(roku)[\dx]*[\)\/]((?:dvp-)?[\d\.]*)/i,/hbbtv\/\d+\.\d+\.\d+ +\([\w\+ ]*; *([\w\d][^;]*);([^;]*)/i],[[c,K],[a,K],[d,f]],[/\b(android tv|smart[- ]?tv|opera tv|tv; rv:)\b/i],[[d,f]],[/(ouya)/i,/(nintendo) ([wids3utch]+)/i],[c,a,[d,p]],[/droid.+; (shield) bui/i],[a,[c,"Nvidia"],[d,p]],[/(playstation [345portablevi]+)/i],[a,[c,F],[d,p]],[/\b(xbox(?: one)?(?!; xbox))[\); ]/i],[a,[c,M],[d,p]],[/((pebble))app/i],[c,a,[d,w]],[/(watch)(?: ?os[,\/]|\d,\d\/)[\d\.]+/i],[a,[c,y],[d,w]],[/droid.+; (glass) \d/i],[a,[c,R],[d,w]],[/droid.+; (wt63?0{2,3})\)/i],[a,[c,B],[d,w]],[/(quest( 2| pro)?)/i],[a,[c,D],[d,w]],[/(tesla)(?: qtcarbrowser|\/[-\w\.]+)/i],[c,[d,v]],[/(aeobc)\b/i],[a,[c,b],[d,v]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+? mobile safari/i],[a,[d,m]],[/droid .+?; ([^;]+?)(?: bui|\) applew).+?(?! mobile) safari/i],[a,[d,g]],[/\b((tablet|tab)[;\/]|focus\/\d(?!.+mobile))/i],[[d,g]],[/(phone|mobile(?:[;\/]| [ \w\/\.]*safari)|pda(?=.+windows ce))/i],[[d,m]],[/(android[-\w\. ]{0,9});.+buil/i],[a,[c,"Generic"]]],engine:[[/windows.+ edge\/([\w\.]+)/i],[u,[l,"EdgeHTML"]],[/webkit\/537\.36.+chrome\/(?!27)([\w\.]+)/i],[u,[l,"Blink"]],[/(presto)\/([\w\.]+)/i,/(webkit|trident|netfront|netsurf|amaya|lynx|w3m|goanna)\/([\w\.]+)/i,/ekioh(flow)\/([\w\.]+)/i,/(khtml|tasman|links)[\/ ]\(?([\w\.]+)/i,/(icab)[\/ ]([23]\.[\d\.]+)/i,/\b(libweb)/i],[l,u],[/rv\:([\w\.]{1,9})\b.+(gecko)/i],[u,l]],os:[[/microsoft (windows) (vista|xp)/i],[l,u],[/(windows) nt 6\.2; (arm)/i,/(windows (?:phone(?: os)?|mobile))[\/ ]?([\d\.\w ]*)/i,/(windows)[\/ ]?([ntce\d\. ]+\w)(?!.+xbox)/i],[l,[u,V,z]],[/(win(?=3|9|n)|win 9x )([nt\d\.]+)/i],[[l,"Windows"],[u,V,z]],[/ip[honead]{2,4}\b(?:.*os ([\w]+) like mac|; opera)/i,/ios;fbsv\/([\d\.]+)/i,/cfnetwork\/.+darwin/i],[[u,/_/g,"."],[l,"iOS"]],[/(mac os x) ?([\w\. ]*)/i,/(macintosh|mac_powerpc\b)(?!.+haiku)/i],[[l,W],[u,/_/g,"."]],[/droid ([\w\.]+)\b.+(android[- ]x86|harmonyos)/i],[u,l],[/(android|webos|qnx|bada|rim tablet os|maemo|meego|sailfish)[-\/ ]?([\w\.]*)/i,/(blackberry)\w*\/([\w\.]*)/i,/(tizen|kaios)[\/ ]([\w\.]+)/i,/\((series40);/i],[l,u],[/\(bb(10);/i],[u,[l,x]],[/(?:symbian ?os|symbos|s60(?=;)|series60)[-\/ ]?([\w\.]*)/i],[u,[l,"Symbian"]],[/mozilla\/[\d\.]+ \((?:mobile|tablet|tv|mobile; [\w ]+); rv:.+ gecko\/([\w\.]+)/i],[u,[l,N+" OS"]],[/web0s;.+rt(tv)/i,/\b(?:hp)?wos(?:browser)?\/([\w\.]+)/i],[u,[l,"webOS"]],[/watch(?: ?os[,\/]|\d,\d\/)([\d\.]+)/i],[u,[l,"watchOS"]],[/crkey\/([\d\.]+)/i],[u,[l,_+"cast"]],[/(cros) [\w]+(?:\)| ([\w\.]+)\b)/i],[[l,$],u],[/panasonic;(viera)/i,/(netrange)mmh/i,/(nettv)\/(\d+\.[\w\.]+)/i,/(nintendo|playstation) ([wids345portablevuch]+)/i,/(xbox); +xbox ([^\);]+)/i,/\b(joli|palm)\b ?(?:os)?\/?([\w\.]*)/i,/(mint)[\/\(\) ]?(\w*)/i,/(mageia|vectorlinux)[; ]/i,/([kxln]?ubuntu|debian|suse|opensuse|gentoo|arch(?= linux)|slackware|fedora|mandriva|centos|pclinuxos|red ?hat|zenwalk|linpus|raspbian|plan 9|minix|risc os|contiki|deepin|manjaro|elementary os|sabayon|linspire)(?: gnu\/linux)?(?: enterprise)?(?:[- ]linux)?(?:-gnu)?[-\/ ]?(?!chrom|package)([-\w\.]*)/i,/(hurd|linux) ?([\w\.]*)/i,/(gnu) ?([\w\.]*)/i,/\b([-frentopcghs]{0,5}bsd|dragonfly)[\/ ]?(?!amd|[ix346]{1,2}86)([\w\.]*)/i,/(haiku) (\w+)/i],[l,u],[/(sunos) ?([\w\.\d]*)/i],[[l,"Solaris"],u],[/((?:open)?solaris)[-\/ ]?([\w\.]*)/i,/(aix) ((\d)(?=\.|\)| )[\w\.])*/i,/\b(beos|os\/2|amigaos|morphos|openvms|fuchsia|hp-ux|serenityos)/i,/(unix) ?([\w\.]*)/i],[l,u]]},Q=function(p,f){if(typeof p===i&&(f=p,p=t),!(this instanceof Q))return new Q(p,f).getResult();var w=typeof e!==o&&e.navigator?e.navigator:t,v=p||(w&&w.userAgent?w.userAgent:""),b=w&&w.userAgentData?w.userAgentData:t,y=f?function(e,t){var r={};for(var o in e)t[o]&&t[o].length%2==0?r[o]=t[o].concat(e[o]):r[o]=e[o];return r}(H,f):H,T=w&&w.userAgent==v;return this.getBrowser=function(){var e,o={};return o[l]=t,o[u]=t,J.call(o,v,y.browser),o[n]=typeof(e=o[u])===s?e.replace(/[^\d\.]/g,"").split(".")[0]:t,T&&w&&w.brave&&typeof w.brave.isBrave==r&&(o[l]="Brave"),o},this.getCPU=function(){var e={};return e[h]=t,J.call(e,v,y.cpu),e},this.getDevice=function(){var e={};return e[c]=t,e[a]=t,e[d]=t,J.call(e,v,y.device),T&&!e[d]&&b&&b.mobile&&(e[d]=m),T&&"Macintosh"==e[a]&&w&&typeof w.standalone!==o&&w.maxTouchPoints&&w.maxTouchPoints>2&&(e[a]="iPad",e[d]=g),e},this.getEngine=function(){var e={};return e[l]=t,e[u]=t,J.call(e,v,y.engine),e},this.getOS=function(){var e={};return e[l]=t,e[u]=t,J.call(e,v,y.os),T&&!e[l]&&b&&"Unknown"!=b.platform&&(e[l]=b.platform.replace(/chrome os/i,$).replace(/macos/i,W)),e},this.getResult=function(){return{ua:this.getUA(),browser:this.getBrowser(),engine:this.getEngine(),os:this.getOS(),device:this.getDevice(),cpu:this.getCPU()}},this.getUA=function(){return v},this.setUA=function(e){return v=typeof e===s&&e.length>350?K(e,350):e,this},this.setUA(v),this};Q.VERSION="1.0.35",Q.BROWSER=j([l,u,n]),Q.CPU=j([h]),Q.DEVICE=j([a,c,d,p,m,f,g,w,v]),Q.ENGINE=Q.OS=j([l,u]),E.exports&&(C=E.exports=Q),C.UAParser=Q;var X=typeof e!==o&&(e.jQuery||e.Zepto);if(X&&!X.ua){var Y=new Q;X.ua=Y.getResult(),X.ua.get=function(){return Y.getUA()},X.ua.set=function(e){Y.setUA(e);var t=Y.getResult();for(var r in t)X.ua[r]=t[r]}}}("object"==typeof window?window:R);var A=Object.defineProperty,M=(e,t,r)=>(((e,t,r)=>{t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r})(e,"symbol"!=typeof t?t+"":t,r),r);const k="Unknown",L="Safari",P="Firefox",U="Opera",F="Chrome",O="iOS-webview";class B{static getName(){if(!this._name)if("undefined"!=typeof navigator&&navigator){const{userAgent:e}=navigator;e.match(/Firefox/i)?this._name=P:e.match(/(Opera|OPR)/i)?this._name=U:e.match(/Chrome/i)?this._name=F:e.match(/Safari/i)?this._name=L:e.match(/(iPhone|iPod|iPad).*AppleWebKit(?!.*Version)/i)?this._name=O:this._name=k}else this._name=k;return this._name}static get isMobile(){if(null===this._isMobile&&(this._isMobile=!1,"undefined"!=typeof navigator&&navigator)){const e=navigator.userAgent||navigator.vendor;e&&(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino|android|ipad|playbook|silk/i.test(e)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(e.substr(0,4)))&&(this._isMobile=!0)}return this._isMobile}static clearCache(){this._name=null,this._isMobile=null}}M(B,"_name",null),M(B,"_isMobile",null);const D=[4215763,14529296,11869460,48895,16468400,45661,13290186];const $=Object.freeze(Object.defineProperty({__proto__:null,getQualitativeColor:function(e){return D[e%D.length]}},Symbol.toStringTag,{value:"Module"})),W=4,j=3,G={wheelchair:{horrible:.1,bad:.5,intermediate:.7,good:.9,excellent:1},default:{horrible:.4,bad:.7,intermediate:.8,good:.9,excellent:1}},q={wheelchair:{asphalt:1,concrete:1,paving_stones:.8,compacted:.7,wood:.6,metal:.5,gravel:.3,grass:.2,ground:.2},default:{asphalt:1,concrete:1,paving_stones:.9,compacted:.8,wood:.8,metal:.7,gravel:.6,grass:.5,ground:.4}},K=class e{constructor(){t(this,"avoidStairs",!1),t(this,"avoidEscalators",!1),t(this,"avoidElevators",!1),t(this,"avoidMovingWalkways",!1),t(this,"avoidTicketRestrictedAreas",!1),t(this,"useMultiLevelSegments",!1),t(this,"projectionMaxDistance"),t(this,"isWheelchair",!1)}setAvoidStairs(e){return this.avoidStairs=e,this}setAvoidEscalators(e){return this.avoidEscalators=e,this}setAvoidElevators(e){return this.avoidElevators=e,this}setAvoidMovingWalkways(e){return this.avoidMovingWalkways=e,this}setAvoidTicketRestrictedAreas(e){return this.avoidTicketRestrictedAreas=e,this}setUseMultiLevelSegments(e){return this.useMultiLevelSegments=e,this}setIsWheelchair(e){return this.isWheelchair=e,this}static fromJson(t){const r=new e;return Object.assign(r,t),r.build()}build(){return{input:{avoidStairs:this.avoidStairs,avoidEscalators:this.avoidEscalators,avoidElevators:this.avoidElevators,avoidMovingWalkways:this.avoidMovingWalkways,avoidTicketRestrictedAreas:this.avoidTicketRestrictedAreas,isWheelchair:this.isWheelchair,projectionMaxDistance:this.projectionMaxDistance},weightEdgeFn:e=>{if(e.properties.isElevator)return 90;const t=this.isWheelchair?j:W;let r=g(e.length,t);if(e.properties.areStairs)r*=3;else if(e.properties.areEscalators)r*=1.5;else if(e.properties.isMovingWalkway)r*=.8;else if(e.properties.smoothness){const t=this.isWheelchair?"wheelchair":"default";r*=G[t][e.properties.smoothness]??1}else if(e.properties.surface){const t=this.isWheelchair?"wheelchair":"default";r*=q[t][e.properties.surface]??1}return r},acceptEdgeFn:e=>{if(e.properties.wheelchair){if(this.isWheelchair&&"no"===e.properties.wheelchair)return!1;if(!this.isWheelchair&&"designated"===e.properties.wheelchair)return!1}if(this.isWheelchair){if(e.properties.areStairs)return!1;if(e.properties.areEscalators)return!1;if(e.properties.isMovingWalkway)return!1}return(!this.avoidStairs||!e.properties.areStairs)&&((!this.avoidEscalators||!e.properties.areEscalators)&&((!this.avoidElevators||!e.properties.isElevator)&&((!this.avoidMovingWalkways||!e.properties.isMovingWalkway)&&(!this.avoidTicketRestrictedAreas||!e.properties.needTicket))))},projectionMaxDistance:this.projectionMaxDistance,useMultiLevelSegments:this.useMultiLevelSegments}}};t(K,"DEFAULT",(new K).build()),t(K,"WITHOUT_STAIRS",(new K).setAvoidStairs(!0).build()),t(K,"WHEELCHAIR",(new K).setIsWheelchair(!0).build());let J=K;class V{constructor(e,t,r,o,i){this.prev=e,this.dist=t,this.source=r,this.targets=o,this.edges=i}routeVertices(e=this.targets[0],t=[]){const r=this.prev[e.id];return null===r?this.source===e?[...t,e]:[]:[...this.routeVertices(r,t),e]}weightedDistance(e=this.targets[0]){const t=this.dist[e.id];return t===Number.MAX_VALUE?null:t}route(e=this.targets[0]){const t=this.routeVertices(e),r=[],o=[];for(let i=1;i<t.length;i++){const e=t[i-1],s=t[i],n=u.getEdgeByVertices(this.edges,e,s),a=new u(e,s,Object.assign({},n.properties));n.vertex1===a.vertex2&&a.reverseProperties(),r.push(a),o.push(this.dist[s.id]-this.dist[e.id])}return new T(this.source.coords,e.coords,t,r,o)}toGeoJson(e){return{type:"FeatureCollection",features:[...e.vertices.map((e=>{const t=this.prev[e.id],r=this.dist[e.id],o=e===this.source,i=this.targets.includes(e),s=e.coords.level;return{type:"Feature",properties:{id:e.id,...t&&{prev:t.id},dist:r===Number.MAX_VALUE?"infinity":r,...o&&{name:"source"},...i&&{name:"target"},...null!==s&&{level:s},...e.properties},geometry:{type:"Point",coordinates:[e.coords.lng,e.coords.lat]}}})),...e.edges.map((e=>{const t=e.level;return{type:"Feature",properties:{id:e.id,...null!==t&&{level:t},...e.properties},geometry:{type:"LineString",coordinates:[[e.vertex1.coords.lng,e.vertex1.coords.lat],[e.vertex2.coords.lng,e.vertex2.coords.lat]]}}}))]}}}class z{constructor(e){t(this,"disabledEdges",new Set),this.graph=e;let r=0;e.vertices.forEach((e=>e.id=r++))}calculateShortestPathToMultipleDestinationsByVertex(e,t,r=J.DEFAULT,o=this.graph.vertices,i=this.graph.edges){const s=new Set(o),n=Array(s.size).fill(Number.MAX_VALUE),a=new Array(s.size).fill(null),l=i.filter((e=>{var t;return((null==(t=r.acceptEdgeFn)?void 0:t.call(r,e))??!0)&&!this.disabledEdges.has(e)})),d=r.weightEdgeFn||(e=>e.length),c=e=>{let t=Number.MAX_VALUE,r=null;return e.forEach((e=>{const o=n[e.id];o<=t&&(t=o,r=e)})),r},u=new Set(t);for(n[e.id]=0;s.size>0;){const e=c(s);if(s.delete(e),t.includes(e)&&(u.delete(e),0===u.size))break;l.filter((t=>t.vertex1==e||!t.properties.isOneway&&t.vertex2==e)).forEach((t=>{const r=e===t.vertex1?t.vertex2:t.vertex1,o=d(t),i=n[e.id]+o;i<n[r.id]&&(n[r.id]=i,a[r.id]=e)}))}return new V(a,n,e,t,l)}calculateShortestPathByVertex(e,t,r=J.DEFAULT,o=this.graph.vertices,i=this.graph.edges){return this.calculateShortestPathToMultipleDestinationsByVertex(e,[t],r,o,i)}calculateComponents(){function e(e){const t=e.values().next().value;return e.delete(t),t}const t=new Set(this.graph.vertices);let r,o=[];for(;t.size>0;){const r=e(t),i=this.graph.vertices.filter((e=>e.id!==r.id)),s=this.calculateShortestPathToMultipleDestinationsByVertex(r,i),n=i.filter((e=>null!==s.weightedDistance(e)));o.push([r,...n]),n.forEach((e=>t.delete(e)))}do{r=!1;for(let e=0;e<o.length-1;e++){const t=o[e];for(let i=e+1;i<o.length;i++){const e=o[i];e.some((e=>t.includes(e)))&&(t.push(...e),o=o.filter((t=>t!==e)),r=!0)}}}while(r);return o.map((e=>[...new Set(e)]))}toGeoJson(){return{type:"FeatureCollection",features:this.calculateComponents().map(((e,t)=>({type:"Feature",geometry:{type:"MultiLineString",coordinates:this.graph.edges.filter((t=>e.includes(t.vertex1)&&e.includes(t.vertex2))).map((e=>[[e.vertex1.coords.lng,e.vertex1.coords.lat],[e.vertex2.coords.lng,e.vertex2.coords.lat]]))},properties:{stroke:"#"+$.getQualitativeColor(t).toString(16)}})))}}}class H extends V{constructor(e,t,r){super(e.prev,e.dist,e.source,e.targets,e.edges),this.sourceProjection=t,this.targetsProjections=r}static createEmpty(e,t){const r=t.length,o=new V(new Array(r).fill(null),new Array(r).fill(Number.MAX_VALUE),new p(e),t.map((e=>new p(e))),[]),i=[e,null],s=t.map((e=>[e,null]));return new H(o,i,s)}routeVertices(e=this.targetsProjections[0][0]){var t;if(e instanceof p)return super.routeVertices(e);if(!this.sourceProjection[1])return[];const r=null==(t=this.targetsProjections.find((([t])=>t===e)))?void 0:t[1];return r?super.routeVertices(r):[]}weightedDistance(e=this.targetsProjections[0][0]){var t;if(e instanceof p)return super.weightedDistance(e);if(!this.sourceProjection[1])return null;const r=null==(t=this.targetsProjections.find((([t])=>t===e)))?void 0:t[1];return r?super.weightedDistance(r):null}route(e=this.targetsProjections[0][0]){var t;if(e instanceof p)return super.route(e);const r=null==(t=this.targetsProjections.find((([t])=>t===e)))?void 0:t[1];if(!r)return new T(this.sourceProjection[0],e,[],[],[]);const o=super.route(r);return o.start=this.sourceProjection[0],o.end=e,o}}class Q extends z{calculateShortestPathToMultipleDestinations(e,t,r=J.DEFAULT){const o=new Set,i=new Set,s=[],n={maxDistance:r.projectionMaxDistance,acceptEdgeFn:r.acceptEdgeFn,useMultiLevelSegments:r.useMultiLevelSegments},a=e=>{const t=this.graph.getProjection(e,n);if(null===t)return null;if(t.nearestElement instanceof p)return t.nearestElement;if(t.nearestElement instanceof u){const e=t.nearestElement,r=new p(t.coords,{name:`proj on ${e.properties.name||null} (tmp)`,...void 0!==e.properties.externalId&&{externalId:e.properties.externalId}});r.id=this.graph.vertices.length+o.size;const n={...e.properties,...void 0!==e.properties.externalId&&{externalId:e.properties.externalId}},a=new u(e.vertex1,r,n),l=new u(r,e.vertex2,n);o.add(r),i.add(a),i.add(l);const d=s.find((t=>t[0]===e));return d?d[1].push(r):s.push([e,[r]]),r}return null},l=a(e);if(!l)return H.createEmpty(e,t);const d=t.map((e=>[e,a(e)])),c=d.map((([,e])=>e)).filter((e=>null!==e));s.filter((e=>e[1].length>=2)),s.forEach((([e,t])=>{const r={...e.properties,name:`splitted ${e.properties.name||null} (tmp)`};for(let o=0;o<t.length;o++){const s=t[o],n=s.distanceTo(e.vertex1);for(let a=o+1;a<t.length;a++){const o=t[a],l=o.distanceTo(e.vertex1)<n?new u(o,s,r):new u(s,o,r);i.add(l)}}}));const h=this.calculateShortestPathToMultipleDestinationsByVertex(l,c,r,[...this.graph.vertices,...o],[...this.graph.edges,...i]);return new H(h,[e,l],d)}calculateShortestPath(e,t,r=J.DEFAULT){return this.calculateShortestPathToMultipleDestinations(e,[t],r)}getShortestTrip(e,t,r=.99){const o=e.map((e=>{const t=new s.Point(0,0);return t.coords=e,t})),i=[],n=s.solve(o,r,void 0,((e,r)=>{const o=this.calculateShortestPath(e.coords,r.coords,t).route();return i.push(o),o.hasRoute?o.edgesWeights.reduce(((e,t)=>e+t),0):Number.MAX_VALUE})).map((e=>o[e])),a=[];for(let s=0;s<n.length;s++){const e=n[s],t=n[(s+1)%n.length];let r=i.find((r=>r.start===e.coords&&r.end===t.coords||r.end===e.coords&&r.start===t.coords));(null==r?void 0:r.end)===e.coords&&(r=r.reverse()),r&&a.push(r)}return a.some((e=>!e.hasRoute))?[]:a}}class X extends Error{constructor(e,t,r=null){super(),this.start=e,this.end=t,this.details=r}get startStr(){return this.start instanceof p?`Vertex ${this.start.coords.toString()}`:this.start.toString()}get endStr(){return this.end instanceof p?`Vertex ${this.end.coords.toString()}`:Array.isArray(this.end)?this.end.map((e=>e instanceof p?e.coords.toString():e.toString())).join(","):this.end.toString()}get message(){let e=`No route found from ${this.startStr} to ${this.endStr}.`;return this.details&&(e+=` Details: ${this.details}`),e}}const Y=class e{static parseNodeProperties(e){return{...e.name&&{name:e.name},...e.id&&{externalId:e.id},...e.isGate&&{isGate:e.isGate},...e.isSubwayEntrance&&{isSubwayEntrance:e.isSubwayEntrance},...e.subwayEntranceRef&&{subwayEntrsanceRef:e.subwayEntranceRef}}}static parseWayProperties(e){return{...e.name&&{name:e.name},...e.id&&{externalId:e.id},...e.isOneway&&{isOneway:e.isOneway},...e.areStairs&&{areStairs:e.areStairs},...e.isElevator&&{isElevator:e.isElevator},...e.areEscalators&&{areEscalators:e.areEscalators},...e.isMovingWalkway&&{isMovingWalkway:e.isMovingWalkway},...e.needTicket&&{needTicket:e.needTicket},...e.incline&&{incline:e.incline},...e.wheelchair&&{wheelchair:e.wheelchair},...e.smoothness&&{smoothness:e.smoothness},...e.surface&&{surface:e.surface}}}static createGraphFromOsmModel(t,o=e.DEFAULT_WAY_SELECTOR,i){const s=[],a=[],l=[],d=(e,t)=>{var o;let i=(null==(o=a.find((([o,i])=>o===e.id&&(!!r.Level.intersect(i.coords.level,t)||(null===i.coords.level||null===t)))))?void 0:o[1])||null;if(i)return r.Level.equals(i.coords.level,t)||(i.coords.level=r.Level.intersection(i.coords.level,t),null===i.coords.level&&(i.coords.level=t)),i;const s=new r.Coordinates(e.coords.lat,e.coords.lng,null,t);if(i=new p(s,this.parseNodeProperties(e)),a.push([e.id,i]),e.isElevator){let t=l.find((([t])=>e.id===t));t||(t=[e.id,e.name,[]],l.push(t)),t[2].push(i)}return i};t.ways.forEach((e=>{if(!o(e))return;const t=this.parseWayProperties(e),i=r=>{for(let o=1;o<e.nodes.length;o++){let i=d(e.nodes[o-1],r),n=d(e.nodes[o],r);if(e.isOnewayBackward){const e=n;n=i,i=e}const a=new u(i,n,t);s.push(a)}};i(e.level),"repeat_on"in e.tags&&e.tags.repeat_on.split(";").map(r.Level.fromString).forEach(i)}));let c=-1;return t.ways.filter((e=>e.isElevator&&e.isGeometryClosed)).forEach((e=>{const t=e.nodes.map((e=>a.filter((([t])=>t===e.id)).map((e=>e[1])))).flat(),o=e.nodes.reduce(((e,t)=>[e[0]+t.coords.lat,e[1]+t.coords.lng]),[0,0]).map((t=>t/e.nodes.length)),i=t.reduce(((e,t)=>r.Level.union(e,t.coords.level)),null),l=new r.Coordinates(o[0],o[1],null,i),h=new n.OsmNode(c--,l,{highway:"elevator"});t.forEach((t=>{const r=d(h,t.coords.level);s.push(new u(r,t,{externalId:e.id}))}))})),l.forEach((([e,t,r])=>{const o={name:t,isElevator:!0,externalId:e};for(let i=0;i<r.length;i++)for(let e=i+1;e<r.length;e++)s.push(new u(r[i],r[e],o));if(1===r.length&&null===r[0].coords.level){const e=r[0],t=s.filter((t=>t.vertex1===e||t.vertex2===e));if(t.length>1){const r=[e];for(let o=1;o<t.length;o++){const i=new p(e.coords,e.properties);a.push([e.id,i]),t[o].vertex1===e?t[o].vertex1=i:t[o].vertex2=i,r.push(i)}for(let e=0;e<r.length;e++)for(let t=e+1;t<r.length;t++)s.push(new u(r[e],r[t],o))}}})),null==i||i(a),new m(a.map((e=>e[1])),s)}};t(Y,"RESTRICTED_PEDESTRIANS_HIGHWAYS",["motorway","motorway_link"]),t(Y,"DEFAULT_WAY_SELECTOR",(e=>{if(e.isArea)return!1;if("yes"===e.tags.foot)return!0;if(["no","private"].includes(e.tags.access))return!1;const t="elevator"===e.tags.highway&&e.isGeometryClosed;return e.tags.highway&&!Y.RESTRICTED_PEDESTRIANS_HIGHWAYS.includes(e.tags.highway)&&!t||"sidewalk"===e.tags.footway||"platform"===e.tags.public_transport||"platform"===e.tags.railway}));let Z=Y;class ee{}var te=(e=>(e[e.OK=0]="OK",e[e.CANCELLED=1]="CANCELLED",e[e.UNKNOWN=2]="UNKNOWN",e[e.INVALID_ARGUMENT=3]="INVALID_ARGUMENT",e[e.NOT_FOUND=5]="NOT_FOUND",e[e.UNIMPLEMENTED=12]="UNIMPLEMENTED",e[e.INTERNAL=13]="INTERNAL",e[e.UNAVAILABLE=14]="UNAVAILABLE",e[e.UNAUTHENTICATED=16]="UNAUTHENTICATED",e))(te||{});class re extends Error{constructor(e=te.UNKNOWN,r){super(r),t(this,"customMapName"),this.code=e}static notFound(e){return new re(te.NOT_FOUND,`Cannot found an itinerary. Details: ${e}`)}}class oe extends re{constructor(e=te.UNKNOWN,t,r){super(e,r),this.code=e,this.mapName=t,this.mapName=t}static notFound(e,t){return new oe(te.NOT_FOUND,e,`Cannot found an itinerary in map ${e}. Details: ${t||"No details"}`)}}class ie extends re{constructor(e=te.UNKNOWN,t,r){super(e,r),this.code=e,this.routerName=t,this.routerName=t}static notFound(e,t){return new ie(te.NOT_FOUND,e,`Cannot found an itinerary with ${e}. Details: ${t||"No details"}`)}static missingApiKey(e,t){return new ie(te.UNAUTHENTICATED,e,`API key is missing for ${e}. Details: ${t}`)}static unreachableServer(e,t){return new ie(te.NOT_FOUND,e,`Remote router server ${e} is unreachable. URL: ${t}`)}static responseNotParsing(e,t){return new ie(te.NOT_FOUND,e,`Remote router server response ${e} cannot be parsed. URL: ${t}`)}static travelModeUnimplemented(e,t){return new ie(te.UNIMPLEMENTED,e,`Travel mode "${t}" is not implemented for ${e}`)}}function se(e,t,r,o,i,s,n="Europe/Paris"){const a=new Date(Date.UTC(e,t,r,o,i,s)),l=new Date(a.toLocaleString("en-US",{timeZone:"UTC"})),d=new Date(a.toLocaleString("en-US",{timeZone:n})),c=l.getTime()-d.getTime();return a.setTime(a.getTime()+c),a}function ne(e){return new r.Coordinates(e.Lat,e.Long)}function ae(e){const[t,r]=e.split(" "),[o,i,s]=t.split("/"),[n,a,l]=r.split(":");return se(Number(s),Number(i)-1,Number(o),Number(n),Number(a),Number(l)).getTime()}const le=new Map;le.set("CAR","Car"),le.set("WALK","Walk"),le.set("BIKE","Bike"),le.set("TRANSIT","PT");const de=new Map;de.set("WALK","WALK"),de.set("BICYCLE","BIKE"),de.set("TRAMWAY","TRAM"),de.set("METRO","METRO"),de.set("FUNICULAR","FUNICULAR"),de.set("BUS","BUS"),de.set("COACH","BUS"),de.set("SCHOOL","BUS"),de.set("BUS_PMR","BUS"),de.set("MINIBUS","BUS"),de.set("TROLLEY_BUS","BUS"),de.set("TAXIBUS","BUS"),de.set("SHUTTLE","BUS"),de.set("TRAIN","TRAIN"),de.set("HST","TRAIN"),de.set("LOCAL_TRAIN","TRAIN"),de.set("AIR","AIRPLANE"),de.set("FERRY","BOAT"),de.set("TAXI","UNKNOWN"),de.set("CAR_POOL","UNKNOWN"),de.set("PRIVATE_VEHICLE","CAR"),de.set("SCOOTER","MOTO");const ce=new Map;function ue(e){const t=e.match(/LINESTRING ?\((.*)\)/i),o=e.match(/POINT ?\((.*)\)/i);if(o){const[e,t]=o[1].split(" ");return[new r.Coordinates(Number(t),Number(e))]}return t[1].split(",").map((e=>{const t=e.trim().split(" ");return new r.Coordinates(Number(t[1]),Number(t[0]))}))}ce.set(0,"BUS"),ce.set(1,"WALK"),ce.set(2,"BIKE"),ce.set(3,"CAR"),ce.set(4,"UNKNOWN"),ce.set(5,"UNKNOWN"),ce.set(6,"UNKNOWN"),ce.set(7,"UNKNOWN"),ce.set(8,"UNKNOWN"),ce.set(9,"UNKNOWN"),ce.set(10,"UNKNOWN"),ce.set(11,"UNKNOWN"),ce.set(12,"UNKNOWN"),ce.set(13,"UNKNOWN"),ce.set(14,"UNKNOWN");const he=new class extends ee{get rname(){return"cityway"}async getItineraries(e,t){const r=this.getURL(e,t),o=await fetch(r).catch((()=>{throw ie.unreachableServer(this.rname,r)})),i=await o.json().catch((()=>{throw ie.responseNotParsing(this.rname,r)}));return this.parseResponse(i)}getURL(e,t){const{origin:r,destination:o,travelMode:s,waypoints:n}=t,a=le.get(s);if(!a)throw ie.travelModeUnimplemented(this.rname,s);(n||[]).length>0&&i.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==n?void 0:n.length})`);const l=`DepartureLatitude=${r.latitude}&DepartureLongitude=${r.longitude}`,d=`ArrivalLatitude=${o.latitude}&ArrivalLongitude=${o.longitude}`,c=`TripModes=${a}`,u=new URL(e);let{search:h}=u;return h=(h?`${h}&`:"?")+`${l}&${d}&${c}`,`${u.origin}${u.pathname}${h}`}parseResponse(e){if(200!==e.StatusCode||!e.Data||!e.Data.length)throw ie.notFound(this.rname,e.Message);const t=[],r=e.Data.map((e=>e.response.trips.Trip.map((t=>({...t,...e.hasOwnProperty("PlanTripType")&&{PlanTripType:e.PlanTripType}}))))).flat();e:for(const o of r){if(o.hasOwnProperty("PlanTripType")&&"UNKNOWN"===ce.get(o.PlanTripType))continue;const e=[];for(const t of o.sections.Section){const r=t.Leg?t.Leg:t.PTRide,s=de.get(r.TransportMode),n=[];let a,l,d;const c=new S;if("UNKNOWN"===s)continue e;if("WALK"===s||"BIKE"===s||"CAR"===s){a={name:r.Departure.Site.Name,coords:ne(r.Departure.Site.Position)},l={name:r.Arrival.Site.Name,coords:ne(r.Arrival.Site.Position)};for(const e of r.pathLinks.PathLink){let t;t=e.Geometry&&"Null"!==e.Geometry?ue(e.Geometry):[a.coords,l.coords],t.forEach(((e,t)=>{0===t&&0!==n.length&&n[n.length-1].equals(e)||n.push(e)})),c.addStepInfo({coords:t[0],distance:e.Distance,name:e.Departure.Site.Name})}t===o.sections.Section[o.sections.Section.length-1]&&c.addStepInfo({coords:n[n.length-1]})}else{if(!f(s)){i.warn(`[CitywayParser] Unknown leg mode: ${r.TransportMode}`);continue}{a={name:r.Departure.StopPlace.Name,coords:ne(r.Departure.StopPlace.Position)},l={name:r.Arrival.StopPlace.Name,coords:ne(r.Arrival.StopPlace.Position)};let e=r.Line.Number;"TRAM"===s&&e.toLowerCase().includes("tram")&&(e=e.substr(5)),d={name:e,routeColor:r.Line.Color,routeTextColor:r.Line.TextColor,directionName:r.Destination};for(const t of r.steps.Step){ue(t.Geometry).forEach(((e,t)=>{0===t&&0!==n.length&&n[n.length-1].equals(e)||n.push(e)}))}c.addStepInfo({coords:n[0],name:r.Line.Name,distance:r.Distance})}}c.setStart(a.coords),c.setEnd(l.coords),c.setPathCoords(n);const u=new _({transitMode:s,duration:this.parseDuration(r.Duration),startTime:ae(r.Departure.Time),endTime:ae(r.Arrival.Time),coords:n,start:a,end:l,transportInfo:d,steps:c.build()});e.push(u)}const r=new N({duration:this.parseDuration(o.Duration),startTime:ae(o.Departure.Time),origin:ne(o.Departure.Site.Position),endTime:ae(o.Arrival.Time),destination:ne(o.Arrival.Site.Position),legs:e});t.push(r)}return t}parseDuration(e){const t=e.match(/(-)?P(?:([.,\d]+)Y)?(?:([.,\d]+)M)?(?:([.,\d]+)W)?(?:([.,\d]+)D)?T(?:([.,\d]+)H)?(?:([.,\d]+)M)?(?:([.,\d]+)S)?/),r=void 0===t[2]?0:Number(t[2]),o=void 0===t[3]?0:Number(t[3]),i=void 0===t[4]?0:Number(t[4]),s=void 0===t[5]?0:Number(t[5]),n=void 0===t[6]?0:Number(t[6]),a=void 0===t[7]?0:Number(t[7]);return(void 0===t[8]?0:Number(t[8]))+60*a+3600*n+86400*s+604800*i+2592e3*o+31557600*r}},pe=new Map;pe.set("Air","AIRPLANE"),pe.set("Boat","BOAT"),pe.set("Bus","BUS"),pe.set("BusRapidTransit","BUS"),pe.set("Coach","BUS"),pe.set("Ferry","FERRY"),pe.set("Funicular","FUNICULAR"),pe.set("LocalTrain","TRAIN"),pe.set("LongDistanceTrain","TRAIN"),pe.set("Metro","METRO"),pe.set("Métro","METRO"),pe.set("RailShuttle","TRAIN"),pe.set("RapidTransit","BUS"),pe.set("Shuttle","BUS"),pe.set("SuspendedCableCar","FUNICULAR"),pe.set("Taxi","TAXI"),pe.set("Train","TRAIN"),pe.set("RER","TRAIN"),pe.set("Tramway","TRAM"),pe.set("walking","WALK"),pe.set("bike","BIKE");const me=["physical_mode:Air","physical_mode:Boat","physical_mode:Bus","physical_mode:BusRapidTransit","physical_mode:Coach","physical_mode:Ferry","physical_mode:Funicular","physical_mode:LocalTrain","physical_mode:LongDistanceTrain","physical_mode:Metro","physical_mode:RailShuttle","physical_mode:RapidTransit","physical_mode:Shuttle","physical_mode:SuspendedCableCar","physical_mode:Taxi","physical_mode:Train","physical_mode:Tramway"];function ge(e){return new r.Coordinates(Number(e.lat),Number(e.lon))}function fe(e){return e[e.length-1]}function we(e,t){const r=e.substr(0,4),o=e.substr(4,2),i=e.substr(6,2),s=e.substr(9,2),n=e.substr(11,2),a=e.substr(13,2);return se(Number(r),Number(o)-1,Number(i),Number(s),Number(n),Number(a),t).getTime()}const ve=new class extends ee{get rname(){return"navitia"}async getItineraries(e,t){const r=this.getURL(e,t),o=r.searchParams.get("api_key");if(!o)throw ie.missingApiKey(this.rname);const i=await fetch(r,{method:"GET",headers:{Authorization:o}}).catch((()=>{throw ie.unreachableServer(this.rname,r.toString())})),s=await i.json().catch((()=>{throw ie.responseNotParsing(this.rname,r.toString())}));if(s&&s.error)throw ie.notFound(this.rname,s.error.message);const n=this.parseResponse(s);if(!n.some((e=>w(e.transitMode,t.travelMode))))throw ie.notFound(this.rname,"Selected mode of transport was not found for this itinerary.");return n}getURL(e,t){var r;const{origin:o,destination:s,waypoints:n,travelMode:a}=t;(n||[]).length>0&&i.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==n?void 0:n.length})`);const l=new URL(e),d=new URLSearchParams;d.set("from",`${o.longitude};${o.latitude}`),d.set("to",`${s.longitude};${s.latitude}`),d.set("data_freshness","realtime"),(null==(r=t.itineraryModifiers)?void 0:r.isWheelchair)&&d.set("wheelchair","true");let c=new URLSearchParams;switch(a){case"WALK":c=this.getWalkingQuery();break;case"BIKE":c=this.getBikeQuery();break;case"CAR":c=this.getCarQuery()}return[d,c].map((e=>{for(const t of e.entries())l.searchParams.append(t[0],t[1])})),l}getCarQuery(){const e=new URLSearchParams;return me.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("first_section_mode[]","car"),e.append("last_section_mode[]","walking"),e.append("last_section_mode[]","car"),e}getWalkingQuery(){const e=new URLSearchParams;return me.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("last_section_mode[]","walking"),e}getBikeQuery(){const e=new URLSearchParams;return me.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","bike"),e.append("last_section_mode[]","bike"),e}getSectionCoords(e){let t,r;return t="stop_point"in e.from?e.from.stop_point.coord:"address"in e.from?e.from.address.coord:e.from.poi.coord,r="stop_point"in e.to?e.to.stop_point.coord:"address"in e.to?e.to.address.coord:e.to.poi.coord,{from:ge(t),to:ge(r)}}findStepsCoord(e,t){const o=e,i=[...o];let s=t[0],n=0;const a=[];for(const[l,d]of t.entries()){let e,c;if(0===l)c=0,e=o[0];else if(l===t.length-1)c=o.length-1,e=fe(o);else if(1===i.length)n++,c=n,e=i[0],o[c]=e;else{const t=r.Utils.trimRoute(i,i[0],s.distance);n+=t.length-1,i.splice(0,t.length-1),c=n,e=fe(t),o[c]=e}a.push({...d,coords:e}),s=d}return a}findStepCoords(e,t){var r;if("instruction_start_coordinate"in e)return ge(e.instruction_start_coordinate);const o=null==(r=t.vias)?void 0:r.find((t=>t.id===e.via_uri));return o?ge(o.access_point.coord):void 0}parseResponse(e){var t;if(!e||!e.journeys)throw ie.notFound(this.rname,null==(t=e.error)?void 0:t.message);const o=[],i=e.context.timezone;for(const s of e.journeys){const e=[];for(const o of s.sections){if("waiting"===o.type||"transfer"===o.type)continue;const{from:t,to:s}=this.getSectionCoords(o);let n=[];const a=o.geojson.coordinates.reduce(((e,[t,o])=>(n.includes(`${t}-${o}`)||(n=n.concat(`${t}-${o}`),e.push(new r.Coordinates(o,t))),e)),[]),l=(new S).setStart(t).setEnd(s).setPathCoords(a);let d,c=pe.get(o.mode);if(o.path){const e=o.path.every((e=>"instruction_start_coordinate"in e||e.via_uri)),t=[];for(const r of o.path){let i;if(e){i=this.findStepCoords(r,o);const e={name:r.name,distance:r.length,coords:i};l.addStepInfo(e)}else t.push({name:r.name,distance:r.length})}e||l.setStepsInfo(this.findStepsCoord(a,t))}if("public_transport"===o.type){d={name:o.display_informations.code,routeColor:o.display_informations.color,routeTextColor:o.display_informations.text_color,directionName:o.display_informations.direction},c=pe.get(o.display_informations.physical_mode);const e={coords:a[0],name:d.directionName,distance:o.geojson.properties[0].length};l.setStepsInfo([e])}const u=new _({transitMode:c,duration:o.duration,startTime:we(o.departure_date_time,i),endTime:we(o.arrival_date_time,i),start:{name:o.from.name,coords:t},end:{name:o.to.name,coords:s},coords:a,transportInfo:d,steps:l.build()});e.push(u)}const t=new N({duration:s.duration,startTime:we(s.departure_date_time,i),endTime:we(s.arrival_date_time,i),origin:this.getSectionCoords(s.sections[0]).from,destination:this.getSectionCoords(fe(s.sections)).to,legs:e});o.push(t)}return o}};const be=new class extends ee{get rname(){return"deutsche-bahn"}async getItineraries(e,t){const r=this.getURL(e,t),o=await fetch(r).catch((()=>{throw ie.unreachableServer(this.rname,r)})),i=await o.json().catch((()=>{throw ie.responseNotParsing(this.rname,r)}));return this.parseResponse(i,t.origin,t.destination)}getURL(e,t){let o=e+"/route/v1/walking/";return o+=[t.origin,...t.waypoints||[],t.destination].map((e=>{if(null!==e.level){const t=r.Level.isRange(e.level)?e.level[0]:e.level;return e.longitude+","+e.latitude+","+t}return e.longitude+","+e.latitude})).join(";"),o+="?geometries=geojson&overview=full&steps=true",o}parseResponse(e,t,o){if(!e.segments)throw ie.notFound(this.rname);const i=e.segments.map((e=>{const t=r.Level.union(e.fromLevel,e.toLevel),o=e.polyline.map((({lon:e,lat:o})=>new r.Coordinates(o,e,null,t)));return new _({transitMode:"WALK",coords:o,start:{coords:o[0]},end:{coords:o[o.length-1]}})}));return[new N({origin:t,destination:o,legs:i})]}};function ye(e){const t=e[0];return e.slice(1).map((e=>{const r={};return t.forEach(((t,o)=>{r[t]=e[o]})),r}))}const Te=new Map;Te.set("BIKE","BIKE"),Te.set("PEDESTRIAN","WALK");function xe(e){return new r.Coordinates(e.latitude,e.longitude)}function Se(e){return e[e.length-1]}const _e=new class extends ee{get rname(){return"geovelo"}async getItineraries(e,t){const r=this.getQueryParams(),o=this.getBodyParams(t),i=new URL(e);for(const[a,l]of Object.entries(r))i.searchParams.append(a,l.toString());const s=await fetch(i,{method:"POST",headers:{apiKey:"qWHj6ax6DMttG8DX6tH9CQARaiTgQ1Di","Content-Type":"application/json"},body:JSON.stringify(o)}).catch((()=>{throw ie.unreachableServer(this.rname,i.toString())})),n=await s.json().catch((()=>{throw ie.responseNotParsing(this.rname,i.toString())}));if(!n||0===n.length)throw ie.notFound(this.rname,"No itineraries found.");return this.parseResponse(n)}getQueryParams(){return{instructions:!0,elevations:!1,geometry:!0,single_result:!1,bike_stations:!1,objects_as_ids:!1,merge_instructions:!0,show_pushing_bike_instructions:!1}}getBodyParams(e){const{origin:t,destination:r,waypoints:o}=e;let i=[];return i=o&&o.length>1?o.map((e=>({longitude:e.longitude,latitude:e.latitude}))):[{latitude:t.latitude,longitude:t.longitude},{latitude:r.latitude,longitude:r.longitude}],{transportModes:["BIKE"],waypoints:i}}parseResponse(e){if(!e||!e.length)throw ie.notFound(this.rname);const t=[];for(const o of e){const e=[];for(const t of o.sections){const o=xe(t.waypoints[0]),i=xe(Se(t.waypoints)),s=a.toGeoJSON(t.geometry,6);let n=[];const l=s.coordinates.reduce(((e,[t,o])=>(n.includes(`${t}-${o}`)||(n=n.concat(`${t}-${o}`),e.push(new r.Coordinates(o,t))),e)),[]),d=(new S).setStart(o).setEnd(i).setPathCoords(l),c=Te.get(t.transportMode),u=ye(t.details.instructions);for(const e of u){const{geometryIndex:t,roadLength:o,roadName:i}=e,n=s.coordinates[t],a={name:i,distance:o,coords:new r.Coordinates(n[1],n[0])};d.addStepInfo(a)}const h=new _({transitMode:c,duration:t.duration,startTime:new Date(t.estimatedDatetimeOfDeparture).getTime(),endTime:new Date(t.estimatedDatetimeOfArrival).getTime(),start:{coords:o},end:{coords:i},coords:l,steps:d.build()});e.push(h)}const i=new N({duration:o.duration,startTime:new Date(o.estimatedDatetimeOfDeparture).getTime(),endTime:new Date(o.estimatedDatetimeOfArrival).getTime(),origin:xe(o.waypoints[0]),destination:xe(Se(o.waypoints)),legs:e});t.push(i)}return t}},Ne=new Map;Ne.set("Air","AIRPLANE"),Ne.set("Boat","BOAT"),Ne.set("Bus","BUS"),Ne.set("BusRapidTransit","BUS"),Ne.set("Coach","BUS"),Ne.set("Ferry","FERRY"),Ne.set("Funicular","FUNICULAR"),Ne.set("LocalTrain","TRAIN"),Ne.set("LongDistanceTrain","TRAIN"),Ne.set("Metro","METRO"),Ne.set("Métro","METRO"),Ne.set("RailShuttle","TRAIN"),Ne.set("RapidTransit","BUS"),Ne.set("Shuttle","BUS"),Ne.set("SuspendedCableCar","FUNICULAR"),Ne.set("Taxi","TAXI"),Ne.set("Train","TRAIN"),Ne.set("RER","TRAIN"),Ne.set("Tramway","TRAM"),Ne.set("walking","WALK"),Ne.set("bike","BIKE");const Ee=["physical_mode:Air","physical_mode:Boat","physical_mode:Bus","physical_mode:BusRapidTransit","physical_mode:Coach","physical_mode:Ferry","physical_mode:Funicular","physical_mode:LocalTrain","physical_mode:LongDistanceTrain","physical_mode:Metro","physical_mode:RailShuttle","physical_mode:RapidTransit","physical_mode:Shuttle","physical_mode:SuspendedCableCar","physical_mode:Taxi","physical_mode:Train","physical_mode:Tramway"];function Ce(e){return new r.Coordinates(Number(e.lat),Number(e.lon))}function Re(e){return e[e.length-1]}function Ie(e,t){const r=e.substr(0,4),o=e.substr(4,2),i=e.substr(6,2),s=e.substr(9,2),n=e.substr(11,2),a=e.substr(13,2);return se(Number(r),Number(o)-1,Number(i),Number(s),Number(n),Number(a),t).getTime()}const Ae=new class extends ee{get rname(){return"idfm"}async getItineraries(e,t){const{travelMode:r}=t;if("BIKE"===r)return _e.getItineraries("https://idfm.getwemap.com/marketplace/computedroutes",t);const o=this.getURL(e,t),i=await fetch(o,{method:"GET",headers:{apiKey:"qWHj6ax6DMttG8DX6tH9CQARaiTgQ1Di"}}).catch((()=>{throw ie.unreachableServer(this.rname,o)})),s=await i.json().catch((()=>{throw ie.responseNotParsing(this.rname,o)}));if(s&&s.error)throw ie.notFound(this.rname,s.error.message);const n=this.parseResponse(s);if(!n.some((e=>w(e.transitMode,t.travelMode))))throw ie.notFound(this.rname,"Selected mode of transport was not found for this itinerary.");return n}getURL(e,t){var r;const{origin:o,destination:s,waypoints:n,travelMode:a}=t;(n||[]).length>0&&i.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==n?void 0:n.length})`);const l=new URL(e),d=new URLSearchParams;d.set("from",`${o.longitude};${o.latitude}`),d.set("to",`${s.longitude};${s.latitude}`),d.set("data_freshness","realtime"),(null==(r=t.itineraryModifiers)?void 0:r.isWheelchair)&&d.set("wheelchair","true");let c=new URLSearchParams;switch(a){case"WALK":c=this.getWalkingQuery();break;case"BIKE":c=this.getBikeQuery();break;case"CAR":c=this.getCarQuery()}return[d,c].map((e=>{for(const t of e.entries())l.searchParams.append(t[0],t[1])})),l.toString()}getCarQuery(){const e=new URLSearchParams;return Ee.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("first_section_mode[]","car"),e.append("last_section_mode[]","walking"),e.append("last_section_mode[]","car"),e}getWalkingQuery(){const e=new URLSearchParams;return Ee.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","walking"),e.append("last_section_mode[]","walking"),e}getBikeQuery(){const e=new URLSearchParams;return Ee.forEach((t=>{e.append("forbidden_uris[]",t)})),e.append("first_section_mode[]","bike"),e.append("last_section_mode[]","bike"),e}getSectionCoords(e){let t,r;return t="stop_point"in e.from?e.from.stop_point.coord:"address"in e.from?e.from.address.coord:e.from.poi.coord,r="stop_point"in e.to?e.to.stop_point.coord:"address"in e.to?e.to.address.coord:e.to.poi.coord,{from:Ce(t),to:Ce(r)}}findStepsCoord(e,t){const o=e,i=[...o];let s=t[0],n=0;const a=[];for(const[l,d]of t.entries()){let e,c;if(0===l)c=0,e=o[0];else if(l===t.length-1)c=o.length-1,e=Re(o);else if(1===i.length)n++,c=n,e=i[0],o[c]=e;else{const t=r.Utils.trimRoute(i,i[0],s.distance);n+=t.length-1,i.splice(0,t.length-1),c=n,e=Re(t),o[c]=e}a.push({...d,coords:e}),s=d}return a}findStepCoords(e,t){var r;if("instruction_start_coordinate"in e)return Ce(e.instruction_start_coordinate);const o=null==(r=t.vias)?void 0:r.find((t=>t.id===e.via_uri));return o?Ce(o.access_point.coord):void 0}parseResponse(e){var t;if(!e||!e.journeys)throw ie.notFound(this.rname,null==(t=e.error)?void 0:t.message);const o=[],i=e.context.timezone;for(const s of e.journeys){const e=[];for(const o of s.sections){if("waiting"===o.type||"transfer"===o.type)continue;const{from:t,to:s}=this.getSectionCoords(o);let n=[];const a=o.geojson.coordinates.reduce(((e,[t,o])=>(n.includes(`${t}-${o}`)||(n=n.concat(`${t}-${o}`),e.push(new r.Coordinates(o,t))),e)),[]),l=(new S).setStart(t).setEnd(s).setPathCoords(a);let d,c=Ne.get(o.mode);if(o.path){const e=o.path.every((e=>"instruction_start_coordinate"in e||e.via_uri)),t=[];for(const r of o.path){let i;if(e){i=this.findStepCoords(r,o);const e={name:r.name,distance:r.length,coords:i};l.addStepInfo(e)}else t.push({name:r.name,distance:r.length})}e||l.setStepsInfo(this.findStepsCoord(a,t))}if("public_transport"===o.type){d={name:o.display_informations.code,routeColor:o.display_informations.color,routeTextColor:o.display_informations.text_color,directionName:o.display_informations.direction},c=Ne.get(o.display_informations.physical_mode);const e={coords:a[0],name:d.directionName,distance:o.geojson.properties[0].length};l.setStepsInfo([e])}const u=new _({transitMode:c,duration:o.duration,startTime:Ie(o.departure_date_time,i),endTime:Ie(o.arrival_date_time,i),start:{name:o.from.name,coords:t},end:{name:o.to.name,coords:s},coords:a,transportInfo:d,steps:l.build()});e.push(u)}const t=new N({duration:s.duration,startTime:Ie(s.departure_date_time,i),endTime:Ie(s.arrival_date_time,i),origin:this.getSectionCoords(s.sections[0]).from,destination:this.getSectionCoords(Re(s.sections)).to,legs:e});o.push(t)}return o}},Me=new Map;Me.set("CAR","CAR"),Me.set("WALK","WALK"),Me.set("BIKE","BIKE");const ke=new class extends ee{constructor(){super(...arguments),t(this,"inputModeCorrespondance",(e=>{var t;const{travelMode:r,travelModePreference:o}=e;if("WALK"===r&&(null==(t=e.itineraryModifiers)?void 0:t.isWheelchair))return"pmr";if("WALK"===r)return"walking";if("BIKE"===r)return"FASTEST"===o?"bike-fastest":"bike-safest";if("CAR"===r)return"driving";throw ie.travelModeUnimplemented(this.rname,r)}))}get rname(){return"osrm"}async getItineraries(e,t){const r=this.getURL(e,t),o=await fetch(r).catch((()=>{throw ie.unreachableServer(this.rname,r)})),i=await o.json().catch((()=>{throw ie.responseNotParsing(this.rname,r)}));return this.parseResponse(i,t.origin,t.destination,t.travelMode)}getURL(e,t){const{origin:r,destination:o}=t;let i=e+"/route/v1/"+this.inputModeCorrespondance(t)+"/";return i+=[r,...t.waypoints||[],o].map((e=>[e.longitude+","+e.latitude])).join(";"),i+="?geometries=geojson&overview=full&steps=true",t.provideItineraryAlternatives&&(i+="&alternatives=true"),i}coordinatesToJson({lat:e,lng:t,level:o}){return null===o?[t,e]:r.Level.isRange(o)?[t,e,o[0]]:[t,e,o]}jsonToCoordinates(e){const t=new r.Coordinates(e[1],e[0]);return e.length>2&&(t.level=e[2]),t}getModifierFromAngle(e){const t=o.positiveMod(o.rad2deg(e),360);return t>0&&t<60?"sharp right":t>=60&&t<140?"right":t>=140&&t<160?"slight right":t>=160&&t<=200?"straight":t>200&&t<=220?"slight left":t>220&&t<=300?"left":t>300&&t<360?"sharp left":"u turn"}noRouteFoundJson(e){return{code:"NoRoute",message:e}}itineraryToOsrmJson(e){const t=e.legs.length-1,r=e.steps,i=e.legs.map((({distance:e,duration:i,coords:s},n)=>{const a=r.filter((e=>s.find((t=>t.equals(e.coords))))),l=a.length-1;return{distance:e,duration:i||0,steps:a.map(((e,r,i)=>{let a=0===r&&0===n?"depart":"turn";a=r===l&&n===t?"arrive":a;const d=s.findIndex((t=>t.equals(e.coords))),c=r===l?d:s.findIndex((e=>e.equals(i[r+1].coords)));return{geometry:{type:"LineString",coordinates:s.slice(d,c+1).map(this.coordinatesToJson)},distance:e.distance,duration:e.duration||0,...e.name&&{name:e.name},maneuver:{bearing_before:o.rad2deg(e.previousBearing),bearing_after:o.rad2deg(e.nextBearing),location:this.coordinatesToJson(e.coords),modifier:this.getModifierFromAngle(e.angle),type:a}}}))}}));return{code:"Ok",routes:[{geometry:{type:"LineString",coordinates:e.coords.map(this.coordinatesToJson)},legs:i,distance:e.distance,duration:e.duration,weight_name:"routability",weight:0}],waypoints:[]}}parseResponse(e,t,r,o){const i=Me.get(o),{routes:s}=e;if(!s)throw ie.notFound(this.rname,e.message);return s.map((e=>{const o=e.legs.map((e=>{var t;const r=e.steps.map((e=>e.geometry.coordinates.map(this.jsonToCoordinates))).flat().filter(((e,t,r)=>0===t||!r[t-1].equals(e))),o=r[0],s=r[r.length-1],n=(new S).setPathCoords(r).setStart(o).setEnd(s);return null==(t=e.steps)||t.forEach((({maneuver:e,name:t,distance:o,duration:i})=>{const s=this.jsonToCoordinates(e.location),a=r.map((e=>e.distanceTo(s))),l=a.indexOf(Math.min(...a));if(l<0)throw new Error("Osrm Parser: Cannot find step coords in leg coordinates");n.addStepInfo({coords:r[l],name:t,distance:o,duration:i})})),new _({transitMode:i,duration:e.duration,coords:r,start:{coords:o},end:{coords:s},steps:n.build()})}));return new N({duration:e.duration,origin:t,destination:r,legs:o})}))}};function Le(e){return"BUS"===e.mode||"TRAM"===e.mode}function Pe(e){return new r.Coordinates(e.lat,e.lon)}const Ue=new Map;Ue.set("CAR","CAR"),Ue.set("WALK","WALK"),Ue.set("BIKE","BICYCLE"),Ue.set("TRANSIT","WALK,TRANSIT");const Fe=new class extends ee{get rname(){return"otp"}async getItineraries(e,t){const r=this.getURL(e,t),o=await fetch(r).catch((()=>{throw ie.unreachableServer(this.rname,r)})),i=await o.json().catch((()=>{throw ie.responseNotParsing(this.rname,r)}));return this.parseResponse(i)}getURL(e,t){const{origin:r,destination:o,waypoints:s,travelMode:n}=t,a=Ue.get(n);if(!a)throw ie.travelModeUnimplemented(this.rname,n);(s||[]).length>0&&i.warn(`${this.rname} router uses only the first 2 waypoints (asked ${null==s?void 0:s.length})`);const l=`fromPlace=${r.latitude},${r.longitude}`,d=`toPlace=${o.latitude},${o.longitude}`,c=`mode=${a}`,u=new URL(e);let{search:h}=u;return h=(h?`${h}&`:"?")+`${l}&${d}&${c}`,`${u.origin}${u.pathname}${h}`}parseResponse(e){const{plan:t}=e;if(!t)throw ie.notFound(this.rname);const o=[],i=Pe(t.from),s=Pe(t.to);for(const n of t.itineraries){const e=[];for(const o of n.legs){const t=Pe(o.from),i=Pe(o.to),s=a.decode(o.legGeometry.points).map((([e,t])=>new r.Coordinates(e,t)));let n;const l=(new S).setStart(t).setEnd(i).setPathCoords(s);Le(o)?(n={name:o.routeShortName,routeColor:o.routeColor,routeTextColor:o.routeTextColor,directionName:o.headsign},l.addStepInfo({coords:s[0],name:o.headsign})):o.steps.forEach((e=>{const t=s.map((t=>t.distanceTo(Pe(e)))),r=t.indexOf(Math.min(...t));if(r<0)throw new Error("OTP Parser: Cannot find closest step");l.addStepInfo({coords:s[r],name:e.streetName})}));const d=new _({transitMode:o.mode,duration:o.duration,startTime:o.startTime,endTime:o.endTime,start:{name:o.from.name,coords:Pe(o.from)},end:{name:o.to.name,coords:Pe(o.to)},coords:s,transportInfo:n,steps:l.build()});e.push(d)}const t=new N({duration:n.duration,startTime:n.startTime,endTime:n.endTime,origin:i,destination:s,legs:e});o.push(t)}return o}};const Oe=new class extends ee{get rname(){return"wemap-multi"}async getItineraries(e,t){const{origin:o,destination:i,waypoints:s}=t,n={...t,origin:o instanceof r.Coordinates?o.toJson():o,destination:i instanceof r.Coordinates?i.toJson():i,...s&&{waypoints:s.map((e=>e instanceof r.Coordinates?e.toJson():e))}},a=await fetch(e,{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(n)}).catch((()=>{throw ie.unreachableServer(this.rname,e)})),l=await a.json().catch((()=>{throw ie.responseNotParsing(this.rname,e)}));if(l.error)throw ie.notFound(this.rname,l.error);return(l.itineraries||[]).map(N.fromJson)}},Be=[he,ve,be,Ae,ke,Fe,Oe];const De=new class{getRouterByName(e){return Be.find((t=>t.rname===e))}async getItineraries(e,t,r){const o=this.getRouterByName(e);if(!o)throw ie.notFound(e,`Unknown "${e}" remote router`);return o.getItineraries(t,r)}async getItinerariesWithFallback(e,t){let r;const o=[];for(const{name:a,endpointUrl:l}of t)try{if(r=await this.getItineraries(a,l,e),r.length)return r}catch(n){if(!(n instanceof ie))throw n;o.push({name:a,endpointUrl:l,error:n})}const i=t.map((({name:e})=>e)).join(", "),s=o.map((e=>`(${e.name}) Could not find an itinerary on endpoint: ${e.endpointUrl}. Details: ${e.error.message}`)).join("\n");throw ie.notFound(i,s)}};class $e{constructor(e,r,o=null,i=null){if(t(this,"name"),t(this,"graph"),t(this,"router"),t(this,"bounds"),t(this,"entryPoints"),this.name=i,this.graph=e,this.router=new Q(e),r.forEach((t=>{if(!e.vertices.includes(t))throw new Error(`Cannot find entry point ${t.coords.toString()} in graph "${i}"`)})),this.entryPoints=r,o)this.bounds=o;else{const t=[e.vertices.map((e=>[e.coords.lng,e.coords.lat]))],r=d({type:"polygon",coordinates:t});if(!r)throw new Error(`Cannot calculate convexHull of graph "${i}"`);this.bounds={type:"MultiPolygon",coordinates:[r.geometry.coordinates]}}}static fromOsmXml(e,t=null,r){const o={routingIoNotFound:[],routingBoundsNotFound:!1};let i;try{i=n.OsmParser.parseOsmXmlString(e)}catch(c){return o.couldNotParseFile=c instanceof Error?c.message:"Unknown error",void(null==r||r(o))}let s=[];const a=Z.createGraphFromOsmModel(i,Z.DEFAULT_WAY_SELECTOR,(e=>s=e)),l=i.nodes.filter((e=>e.tags["wemap:routing-io"])).map((e=>{var t;const r=null==(t=s.find((t=>t[0]===e.id)))?void 0:t[1];return r||o.routingIoNotFound.push(e),r||null})).filter((e=>null!==e));l.forEach((e=>a.exitVertices.add(e)));const d={type:"MultiPolygon",coordinates:[]};return i.ways.filter((({tags:e})=>e["wemap:routing-bounds"])).forEach((e=>{d.coordinates.push([e.nodes.reduce(((e,t)=>(e.push([t.coords.lng,t.coords.lat]),e)),[])])})),i.relations.filter((e=>e.tags["wemap:routing-bounds"]&&e.isMultipolygon())).forEach((e=>{const t=e.getGeoJsonPolygon();t&&d.coordinates.push(t.coordinates)})),d.coordinates.length||(o.routingBoundsNotFound=!0),null==r||r(o),new $e(a,l,d,t)}isPointInside(e){return l([e.lng,e.lat],this.bounds)}getOrderedEntryPointsSortedByDistance(e,t){const o=[...this.entryPoints];return o.sort(((o,i)=>Number(o.coords.distanceTo(e))+o.coords.distanceTo(t)-(i.coords.distanceTo(e)+i.coords.distanceTo(t))+50*(Math.abs(r.Level.diff(e.level,o.coords.level)||0)+Math.abs(r.Level.diff(t.level,o.coords.level)||0)-(Math.abs(r.Level.diff(e.level,i.coords.level)||0)+Math.abs(r.Level.diff(t.level,i.coords.level)||0)))))}getBestRouteFromEntryPointsToDestination(e,t,r){const o=this.getOrderedEntryPointsSortedByDistance(e,t);for(const i of o){const e=this.router.calculateShortestPath(i.coords,t,r).route();if(e.hasRoute)return e}return null}getBestRouteFromOriginToEntryPoints(e,t,r){const o=this.getOrderedEntryPointsSortedByDistance(e,t);for(const i of o){const t=this.router.calculateShortestPath(e,i.coords,r).route();if(t.hasRoute)return t}return null}getRouteInsideMap(e,t,r){const o=this.router.calculateShortestPath(e,t,r).route();return o.hasRoute?o:null}getTripInsideMap(e,t){return this.router.getShortestTrip(e,t)}getRoutesMultipleDestinationsInsideMap(e,t,r){return this.router.calculateShortestPathToMultipleDestinations(e,t,r)}}const We=class e{static getTurnInfoFromAngle(e){let t,r;const i=o.rad2deg(o.diffAngle(e,Math.PI)),s=Math.abs(i);return s<=20?t="straight":(t=i>0?"left":"right",s<55?r="slight":s>120&&(r="sharp")),{direction:t,directionExtra:r}}static getInfoFromStep(t){let r,o,i,s;if(t.levelChange)r="level-change",s=t.levelChange;else{r="turn";const s=e.getTurnInfoFromAngle(t.angle);o=s.direction,i=s.directionExtra}return{type:r,direction:o,directionExtra:i,levelChange:s,name:t.name,indoor:null!==t.coords.level}}static getInstructionFromStep(t){var r,o;const{direction:i,directionExtra:s}=e.getTurnInfoFromAngle(t.angle),n="straight"!==i;if(t.lastStep){if(n&&"left"===i)return"Your destination is on your left";if(n&&"right"===i)return"Your destination is on your right"}let a="";if((null==(r=t.extras)?void 0:r.isGate)?a=` on gate ${t.name}`:t.name&&(a=` on ${t.name}`),t.levelChange){if("up"===t.levelChange.direction)return"stairs"===t.levelChange.type?"Go up the stairs":"escalator"===t.levelChange.type?"Go up the escalator":"elevator"===t.levelChange.type?"Go up the elevator":"moving walkway"===t.levelChange.type?"Go up the moving walkway":"incline plane"===t.levelChange.type?"Go up the incline plane":"Go up"+a;if("down"===t.levelChange.direction)return"stairs"===t.levelChange.type?"Go down the stairs":"escalator"===t.levelChange.type?"Go down the escalator":"elevator"===t.levelChange.type?"Go down the elevator":"moving walkway"===t.levelChange.type?"Go down the moving walkway":"incline plane"===t.levelChange.type?"Go down the incline plane":"Go down"+a;if(null==(o=t.extras)?void 0:o.subwayEntrance)return`Take exit ${t.extras.subwayEntranceRef}`}if(n){if("left"===i)return"slight"===s?"Turn slightly left"+a:"Turn left"+a;if("right"===i)return"slight"===s?"Turn slightly right"+a:"Turn right"+a}return"Continue straight"}static getInstructionFromPosition(t,r){const i=t.getInfo(r);if(!i)return null;if(this.useProposals&&i.projection.distanceFromNearestElement>15)return"It seems that we are a little bit lost, please start again the localization process";const{nextStep:s}=i;if(!s)return"You are arrived";const n=r.distanceTo(s.coords),a=o.roundFactor(n,5);if(this.useProposals&&n>10)return`Continue straight for ${a}m`;let l=e.getInstructionFromStep(s);const d=t._steps.find((e=>e.levelChange&&e.number>s.number&&e.coords.distanceTo(s.coords)<10))||null;if(d&&d.levelChange){const t=s.coords.bearingTo(d.coords),{direction:r}=e.getTurnInfoFromAngle(t-s.previousBearing);l="straight"===r?"Continue straight":`Turn ${r}`;const{direction:o,type:i}=d.levelChange;l+=` and take the ${i} going ${o}`}return n>=5&&(l+=` in ${a}m`),l}};t(We,"useProposals",!1);let je=We;class Ge{static getInstructionFromStep(e){var t;const r=ke.getModifierFromAngle(e.angle);let o,i;r.includes("left")?o="left":r.includes("right")&&(o="right"),r.includes("slight")&&(i="slight");const s="straight"!==r;if(e.lastStep){if(s&&"left"===o)return"Your destination is on your left";if(s&&"right"===o)return"Your destination is on your right"}const n=e.name?` on ${e.name}`:"";if(e.levelChange){if("up"===e.levelChange.direction)return"escalator"===e.levelChange.type?"Go up the escalator":"stairs"===e.levelChange.type?"Go up the stairs":"Go up"+n;if("down"===e.levelChange.direction)return"escalator"===e.levelChange.type?"Go down the escalator":"stairs"===e.levelChange.type?"Go down the stairs":"Go down"+n;if(null==(t=e.extras)?void 0:t.subwayEntrance)return`Take exit ${e.extras.subwayEntranceRef}`}if(s){if("left"===o)return"slight"===i?"Turn slightly left"+n:"Turn left"+n;if("right"===o)return"slight"===i?"Turn slightly right"+n:"Turn right"+n}return""}static getInstructionFromPosition(e,t){const r=e.getInfo(t);if(!r)return null;const{nextStep:o}=r;if(!o)return null;const i=t.distanceTo(o.coords),s=e._steps.find((e=>e.number>o.number));return i<3&&s?Ge.getInstructionFromStep(s):Ge.getInstructionFromStep(o)}}exports.CitywayRemoteRouter=he,exports.CustomGraphMap=$e,exports.CustomGraphMapTester=class{static createReport(e){var t;let r;const o=$e.fromOsmXml(e,null,(e=>r=e)),i=[];if((null==r?void 0:r.couldNotParseFile)||!o)return i.push({type:"could-not-parse-file",details:null==r?void 0:r.couldNotParseFile}),{errors:i};const s=o.router.calculateComponents();return s.length>1&&i.push({type:"multiple-graph-components",data:s}),(null==r?void 0:r.routingBoundsNotFound)&&i.push({type:"routing-bounds-not-found"}),(null==(t=null==r?void 0:r.routingIoNotFound)?void 0:t.length)&&i.push({type:"routing-io-not-on-graph",data:r.routingIoNotFound}),{customGraphMap:o,errors:i}}static reportToJson(e){var t,r;return{graph:null==(r=null==(t=e.customGraphMap)?void 0:t.graph)?void 0:r.toCompressedJson(),errors:e.errors.map((e=>"multiple-graph-components"===e.type?{type:e.type,data:e.data.map((e=>e.map((e=>e.id))))}:"routing-io-not-on-graph"===e.type?{type:e.type,data:e.data.map((e=>e.id))}:{type:e.type}))}}},exports.DeutscheBahnRemoteRouter=be,exports.Edge=u,exports.GeoveloRemoteRouter=_e,exports.Graph=m,exports.GraphProjection=h,exports.GraphRoute=T,exports.GraphRouter=Q,exports.GraphRouterOptionsBuilder=J,exports.IdfmRemoteRouter=Ae,exports.InstructionManager=je,exports.InstructionManagerV1=Ge,exports.Itinerary=N,exports.ItineraryInfoManager=class{constructor(e=null){t(this,"_itinerary",null),t(this,"_graph",null),t(this,"_steps",[]),t(this,"_coordsNextStep",[]),t(this,"_coordsPreviousStep",[]),t(this,"_coordsDistanceTraveled",[]),t(this,"_coordsLeg",[]),t(this,"_itineraryDistanceWithoutProjections",0),this.itinerary=e}get itinerary(){return this._itinerary}set itinerary(e){if(null===e)return void(this._itinerary=null);this._itinerary=e,this._steps=e.steps,this._graph=e.toGraph(),this._coordsNextStep=new Array(e.coords.length),this._coordsPreviousStep=new Array(e.coords.length),this._coordsDistanceTraveled=new Array(e.coords.length),this._coordsLeg=new Array(e.coords.length),this._itineraryDistanceWithoutProjections=e.distance;let t=0,r=null,o=this._steps[0],i=0;e.coords.forEach(((s,n,a)=>{0!==n&&(i+=a[n-1].distanceTo(s)),this._coordsNextStep[n]=o,this._coordsPreviousStep[n]=r,this._coordsDistanceTraveled[n]=i,this._coordsLeg[n]=e.legs.find((e=>e.coords.includes(s))),t<this._steps.length&&this._steps[t].coords.equals(s)&&(r=this._steps[t],o=t===this._steps.length-1?null:this._steps[t+1],t++)}))}getInfo(e){if(!this._itinerary||!this._graph)return null;const t=this._graph.getProjection(e);if(!t)return null;let r=null;if(t.nearestElement instanceof p){const e=this._itinerary.coords.findIndex((e=>t.nearestElement.coords===e));if(-1===e)throw new Error("ItineraryInfoManager: could not find projection in itinerary (Node)");const o=this._coordsDistanceTraveled[e],i=o,s=this._itineraryDistanceWithoutProjections-o,n=t.distanceFromNearestElement+s,a=i/(i+n),l=1-a;r={nextStep:this._coordsNextStep[e],previousStep:this._coordsPreviousStep[e],projection:t,leg:this._coordsLeg[e],traveledDistance:o,remainingDistance:n,traveledPercentage:a,remainingPercentage:l}}else if(t.nearestElement instanceof u){let e=t.nearestElement.vertex1.coords,o=this._itinerary.coords.findIndex((t=>e===t));if(-1===o)throw new Error("ItineraryInfoManager: could not find projection in itinerary (Edge)");o!==this._itinerary.coords.length-1&&this._itinerary.coords[o+1]===t.nearestElement.vertex2.coords||(e=t.nearestElement.vertex2.coords,o--);const i=this._coordsDistanceTraveled[o]+t.coords.distanceTo(e),s=i,n=this._itineraryDistanceWithoutProjections-i,a=t.distanceFromNearestElement+n,l=s/(s+a),d=1-l;r={nextStep:this._coordsNextStep[o+1],previousStep:this._coordsPreviousStep[o+1],projection:t,leg:this._coordsLeg[o+1],traveledDistance:s,remainingDistance:a,traveledPercentage:l,remainingPercentage:d}}return r}},exports.Leg=_,exports.NavitiaRemoteRouter=ve,exports.NoRouteFoundError=X,exports.OsmGraphUtils=Z,exports.OsrmRemoteRouter=ke,exports.OtpRemoteRouter=Fe,exports.RemoteRouterManager=De,exports.RemoteRoutingError=ie,exports.RoutingError=re,exports.StatusCode=te,exports.Vertex=p,exports.WemapMultiRemoteRouter=Oe,exports.WemapMultiRouter=class{constructor(){t(this,"maps",[])}get rname(){return"wemap-multi"}addIOMap(e){this.maps.push(e)}removeIOMap(e){this.maps=this.maps.filter((t=>t!==e))}removeAllMaps(){this.maps=[]}getMapByName(e){return this.maps.find((t=>t.name===e))}async getItineraries(e,t=[],r=this.maps){const{origin:o,destination:i}=e;t=t.filter((({name:e})=>e!==Oe.rname))||[];const s=r;if(!s.length)return await De.getItinerariesWithFallback(e,t);let n,a;const l=s.find((e=>e.isPointInside(o))),d=J.fromJson(e.itineraryModifiers||{});if(l&&l.isPointInside(i)){if(n=l.getRouteInsideMap(o,i,d),!n)throw oe.notFound(l.name||"");return[N.fromGraphRoute(n)]}const c=s.find((e=>e.isPointInside(i)));let u;if(!l&&!c)return await De.getItinerariesWithFallback(e,t);if(l&&!c){if(!l.entryPoints.length)throw oe.notFound(l.name||"",`A map including the "origin" but the "destination" has been \n found (${l.name}), however, no "entrypoints" have been found to go out`);const r=e=>`Tried to calculate an itinerary from "origin" to "entrypoints" using wemap router on local map "${l.name}" and an itinerary from "entrypoints" to "destination" using remote routers (${t.map((e=>e.name)).join(", ")}), but failed. Details: ${e}.`;if(n=l.getBestRouteFromOriginToEntryPoints(o,i,d),!n){const e=`No route found from ${o.toString()} to entry points in map: ${l.name}`;throw oe.notFound(l.name||"",r(e))}const s={...e,origin:n.end,destination:i,waypoints:[]};try{u=await De.getItinerariesWithFallback(s,t)}catch(h){throw h instanceof ie&&(h.message=r(h.message)),h}return a=N.fromGraphRoute(n),u.map((e=>N.fromItineraries(a,e)))}if(!l&&c){if(!c.entryPoints.length)throw oe.notFound(c.name||"",`A map including the "destination" but the "origin" has been \n found (${c.name}), however, no "entrypoints" have been found to go in`);const r=e=>`Tried to calculate an itinerary from "origin" to "entrypoints" using remote routers (${t.map((e=>e.name)).join(", ")}) and an itinerary from "entrypoints" to "destination" using wemap router on local map "${c.name}", but failed. Details: ${e}.`;if(n=c.getBestRouteFromEntryPointsToDestination(o,i,d),!n){const e=`No route found from entry points to ${i.toString()} in map: ${c.name}`;throw oe.notFound(c.name||"",r(e))}const s={...e,origin:o,destination:n.start,waypoints:[]};try{u=await De.getItinerariesWithFallback(s,t)}catch(h){throw h instanceof ie&&(h.message=r(h.message)),h}return a=N.fromGraphRoute(n),u.map((e=>N.fromItineraries(e,a)))}if(l&&c){if(!l.entryPoints.length)throw oe.notFound(l.name||"",`One map including the "origin" (${l.name}) and another \n including the "destination" (${c.name}) has been found, however, no "entrypoints" have \n been found to go out of the origin map`);if(!c.entryPoints.length)throw oe.notFound(c.name||"",`One map including the "origin" (${l.name}) and another \n including the "destination" (${c.name}) has been found, however, no "entrypoints" have \n been found to go in the second map`);const r=e=>`Tried to calculate an itinerary from "origin" to "entrypoints1" using wemap router on local map "${l.name}", an itinerary from "entrypoints1" to "entrypoints2" using remote routers (${t.map((e=>e.name)).join(", ")}) and an itinerary from "entrypoints2" to "destination" using wemap router on local map "${c.name}", but failed. Details: ${e}.`,s=l.getBestRouteFromOriginToEntryPoints(o,i,d);if(!s){const e=`No route found from ${o.toString()} to entry points in map: ${l.name}`;throw oe.notFound(l.name||"",r(e))}const n=c.getBestRouteFromEntryPointsToDestination(o,i,d);if(!n){const e=`No route found from entry points to ${i.toString()} in map: ${c.name}`;throw oe.notFound(c.name||"",r(e))}const a={...e,origin:s.end,destination:n.start,waypoints:[]};try{u=await De.getItinerariesWithFallback(a,t)}catch(h){throw h instanceof ie&&(h.message=r(h.message)),h}return u.map((e=>N.fromItineraries(N.fromGraphRoute(s),e,N.fromGraphRoute(n))))}throw new Error("Should never happen")}},exports.WemapMultiRoutingError=oe,exports.areTransitAndTravelModeConsistent=w,exports.getDurationFromLength=g,exports.routerRequestToJson=function(e){const{origin:t,destination:r,waypoints:o,...i}=e;return{origin:t.toJson(),destination:r.toJson(),...o&&{waypoints:o.map((e=>e.toJson()))},...i}};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|