UNPKG

@geoapify/route-planner-sdk

Version:

TypeScript SDK for the Geoapify Route Planner API. Supports route optimization, delivery planning, and timeline visualization in browser and Node.js

2 lines 271 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).RoutePlannerSDK={})}(this,(function(t){"use strict";function e(t,e,i,n){return new(i||(i=Promise))((function(s,r){function o(t){try{u(n.next(t))}catch(t){r(t)}}function a(t){try{u(n.throw(t))}catch(t){r(t)}}function u(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}u((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class i{constructor(t){this.raw=t||{capabilities:[],time_windows:[],breaks:[]}}getRaw(){return this.raw}setRaw(t){return this.raw=t,this}setStartLocation(t,e){return this.raw.start_location=[t,e],this}setStartLocationIndex(t){return this.raw.start_location_index=t,this}setEndLocation(t,e){return this.raw.end_location=[t,e],this}setEndLocationIndex(t){return this.raw.end_location_index=t,this}setPickupCapacity(t){return this.raw.pickup_capacity=t,this}setDeliveryCapacity(t){return this.raw.delivery_capacity=t,this}addCapability(t){return this.raw.capabilities.push(t),this}addTimeWindow(t,e){return this.raw.time_windows.push([t,e]),this}addBreak(t){return this.raw.breaks.push(t.getRaw()),this}setId(t){return this.raw.id=t,this}setDescription(t){return this.raw.description=t,this}}class n{constructor(t){this.raw=t||{}}getRaw(){return this.raw}setRaw(t){return this.raw=t,this}setLat(t){return this.raw.lat=t,this}setLon(t){return this.raw.lon=t,this}}class s{constructor(t){this.raw=t||{values:[]}}getRaw(){return this.raw}setRaw(t){return this.raw=t,this}setType(t){return this.raw.type=t,this}addValue(t,e){let i=(new n).setLat(e).setLon(t);return this.raw.values.push(i.getRaw()),this}}class r{constructor(t){this.raw=t||{time_windows:[]}}getRaw(){return this.raw}setRaw(t){return this.raw=t,this}addTimeWindow(t,e){return this.raw.time_windows.push([t,e]),this}setDuration(t){return this.raw.duration=t,this}}class o{constructor(t){this.raw=t||{requirements:[],time_windows:[]}}getRaw(){return this.raw}setRaw(t){return this.raw=t,this}setLocation(t,e){return this.raw.location=[t,e],this}setLocationIndex(t){return this.raw.location_index=t,this}setPriority(t){return this.raw.priority=t,this}setDuration(t){return this.raw.duration=t,this}setPickupAmount(t){return this.raw.pickup_amount=t,this}setDeliveryAmount(t){return this.raw.delivery_amount=t,this}addRequirement(t){return this.raw.requirements.push(t),this}addTimeWindow(t,e){return this.raw.time_windows.push([t,e]),this}setId(t){return this.raw.id=t,this}setDescription(t){return this.raw.description=t,this}}class a{constructor(t){this.raw=t||{}}getRaw(){return this.raw}setRaw(t){return this.raw=t,this}setId(t){return this.raw.id=t,this}setLocation(t,e){return this.raw.location=[t,e],this}}class u{constructor(t){this.raw=t||{requirements:[]}}getRaw(){return this.raw}setRaw(t){return this.raw=t,this}setId(t){return this.raw.id=t,this}setPickup(t){return this.raw.pickup=t.getRaw(),this}setDelivery(t){return this.raw.delivery=t.getRaw(),this}addRequirement(t){return this.raw.requirements.push(t),this}setPriority(t){return this.raw.priority=t,this}setDescription(t){return this.raw.description=t,this}setAmount(t){return this.raw.amount=t,this}}class p{constructor(t){this.raw=t||{time_windows:[]}}getRaw(){return this.raw}setRaw(t){return this.raw=t,this}setLocation(t,e){return this.raw.location=[t,e],this}setLocationIndex(t){return this.raw.location_index=t,this}setDuration(t){return this.raw.duration=t,this}addTimeWindow(t,e){return this.raw.time_windows.push([t,e]),this}}class h{constructor(t){if(!t)throw new Error("RouteLegStepData is undefined");this.raw=t}getRaw(){return this.raw}getDistance(){return this.raw.distance}getTime(){return this.raw.time}getFromIndex(){return this.raw.from_index}getToIndex(){return this.raw.to_index}}class d{constructor(t){if(!t)throw new Error("RouteLegData is undefined");this.raw=t}getRaw(){return this.raw}getTime(){return this.raw.time}getDistance(){return this.raw.distance}getSteps(){return this.raw.steps.map((t=>new h(t)))}getFromWaypointIndex(){return this.raw.from_waypoint_index}getToWaypointIndex(){return this.raw.to_waypoint_index}}class l{constructor(t){if(!t)throw new Error("RouteActionData is undefined");this.raw=t}getRaw(){return this.raw}getType(){return this.raw.type}getStartTime(){return this.raw.start_time}getDuration(){return this.raw.duration}getShipmentIndex(){return this.raw.shipment_index}getShipmentId(){return this.raw.shipment_id}getLocationIndex(){return this.raw.location_index}getLocationId(){return this.raw.location_id}getJobIndex(){return this.raw.job_index}getJobId(){return this.raw.job_id}getIndex(){return this.raw.index}getWaypointIndex(){return this.raw.waypoint_index}}class g{constructor(t){if(!t)throw new Error("WaypointData is undefined");this.raw=t}getRaw(){return this.raw}getOriginalLocation(){return this.raw.original_location}getOriginalLocationIndex(){return this.raw.original_location_index}getOriginalLocationId(){return this.raw.original_location_id}getLocation(){return this.raw.location}getStartTime(){return this.raw.start_time}getDuration(){return this.raw.duration}getActions(){return this.raw.actions.map((t=>new l(t)))}getPrevLegIndex(){return this.raw.prev_leg_index}getNextLegIndex(){return this.raw.next_leg_index}}class c{constructor(t){if(!t)throw new Error("AgentSolutionData is undefined");this.raw=t}getRaw(){return this.raw}getAgentIndex(){return this.raw.agentIndex}getAgentId(){return this.raw.agentId}getTime(){return this.raw.time}getStartTime(){return this.raw.start_time}getEndTime(){return this.raw.end_time}getDistance(){return this.raw.distance}getMode(){return this.raw.mode}getLegs(){return this.raw.legs.map((t=>new d(t)))}getActions(){return this.raw.actions.map((t=>new l(t)))}getWaypoints(){return this.raw.waypoints.map((t=>new g(t)))}}class m{constructor(t){if(!t)throw new Error("RouteActionInfo is undefined");this.raw=t}getRaw(){return this.raw}getAgentId(){return this.raw.agentId}getActions(){return this.raw.actions}getAgent(){return this.raw.agent}}class w extends Error{constructor(t,e,i){super(e),this.errorName=t,this.message=e,this.rawResponse=i,this.name=t,this.rawResponse=i}}class y{static cleanObject(t){if(Array.isArray(t))return t.length>0?t.map(y.cleanObject):void 0;if(null!==t&&"object"==typeof t){const e=Object.entries(t).reduce(((t,[e,i])=>{const n=y.cleanObject(i);return void 0!==n&&(t[e]=n),t}),{});return Object.keys(e).length>0?e:void 0}return t}static cloneObject(t){return JSON.parse(JSON.stringify(t))}}class f{static generateRoutePlannerResultData(t){var e,i,n;let s=y.cloneObject(t);return{agents:this.generateAgents(s),inputData:s.properties.params,unassignedAgents:null===(e=s.properties.issues)||void 0===e?void 0:e.unassigned_agents,unassignedJobs:null===(i=s.properties.issues)||void 0===i?void 0:i.unassigned_jobs,unassignedShipments:null===(n=s.properties.issues)||void 0===n?void 0:n.unassigned_shipments}}static generateAgents(t){let e=[];return t.features.forEach((t=>{let i=t.properties;e.push({agentIndex:i.agent_index,agentId:i.agent_id,time:i.time,start_time:i.start_time,end_time:i.end_time,distance:i.distance,mode:i.mode,legs:this.generateRouteLegs(i.legs),actions:this.generateActions(i.actions),waypoints:this.generateWaypoints(i.waypoints)})})),e}static generateRouteLegs(t){return void 0===t?[]:t.map((t=>({time:t.time,distance:t.distance,steps:this.generateRouteLegSteps(t.steps),from_waypoint_index:t.from_waypoint_index,to_waypoint_index:t.to_waypoint_index})))}static generateRouteLegSteps(t){return t.map((t=>({distance:t.distance,time:t.distance,from_index:t.from_index,to_index:t.to_index})))}static generateActions(t){return t.map((t=>({type:t.type,start_time:t.start_time,duration:t.duration,shipment_index:t.shipment_index,shipment_id:t.shipment_id,location_index:t.location_index,location_id:t.location_id,job_index:t.job_index,job_id:t.job_id,index:t.index,waypoint_index:t.waypoint_index})))}static generateWaypoints(t){return t.map((t=>({original_location:t.original_location,original_location_index:t.original_location_index,original_location_id:t.original_location_id,location:t.location,start_time:t.start_time,duration:t.duration,actions:this.generateActions(t.actions),prev_leg_index:t.prev_leg_index,next_leg_index:t.next_leg_index})))}}class v{constructor(t){if(!t)throw new Error("JobSolutionData is undefined");this.raw=t}getRaw(){return this.raw}getAgentId(){return this.raw.agentId}getActions(){return this.raw.actions.map((t=>new l(t)))}getAgent(){return new c(this.raw.agent)}getJob(){return new o(this.raw.job)}}class b{constructor(t){if(!t)throw new Error("ShipmentSolutionData is undefined");this.raw=t}getRaw(){return this.raw}getAgentId(){return this.raw.agentId}getActions(){return this.raw.actions.map((t=>new l(t)))}getAgent(){return new c(this.raw.agent)}getShipment(){return new u(this.raw.shipment)}}class A{static convertAgentToIndex(t,e,i=!1){if("number"==typeof e)return e;let n=t.inputData.agents.findIndex((t=>t.id===e));if(-1===n){if(i)throw new Error(`Agent with id ${e} not found`);return-1}return n}static convertJobToIndex(t,e){if("number"==typeof e)return e;let i=t.inputData.jobs.findIndex((t=>t.id===e));return i<0?-1:i}static convertShipmentToIndex(t,e){if("number"==typeof e)return e;let i=t.inputData.shipments.findIndex((t=>t.id===e));return i<0?-1:i}static convertJobsToIndexes(t,e){if("number"==typeof e[0])return e;let i=[];return e.forEach((e=>{let n=t.inputData.jobs.findIndex((t=>t.id===e));if(n<0)throw new Error(`Job with id ${e} not found`);i.push(n)})),i}static convertShipmentsToIndexes(t,e){if("number"==typeof e[0])return e;let i=[];return e.forEach((e=>{let n=t.inputData.shipments.findIndex((t=>t.id===e));if(n<0)throw new Error(`Shipment with id ${e} not found`);i.push(n)})),i}}class x{constructor(t,e){this.rawData=e,this.options=t}getData(){return f.generateRoutePlannerResultData(this.rawData)}getRawData(){return this.rawData}getAgentSolutions(){return this.getData().agents.map((t=>new c(t)))}getAgentSolutionsByIndex(){let t=this.getData(),e=Array(t.inputData.agents.length);return this.getData().agents.forEach((t=>{let i=new c(t);e[i.getAgentIndex()]=i})),e}getAgentSolution(t){const e=A.convertAgentToIndex(this.getData(),t);return this.getAgentSolutionByIndex(e)}getAgentSolutionByIndex(t){let e=this.getData().agents.find((e=>e.agentIndex===t));return void 0===e?void 0:new c(e)}getAgentWaypoints(t){const e=this.getAgentSolution(t);return e?e.getWaypoints():[]}getAgentRouteActions(t){const e=this.getAgentSolution(t);return e?e.getActions():[]}getAgentRouteLegs(t){const e=this.getAgentSolution(t);return e?e.getLegs():[]}getOptions(){return this.options}getAgentJobs(t){const e=this.getAgentSolution(t);return void 0===e?[]:e.getActions().filter((t=>void 0!==t.getJobIndex())).map((t=>t.getJobIndex()))}getAgentShipments(t){const e=this.getAgentSolution(t);return void 0===e?[]:Array.from(new Set(e.getActions().filter((t=>void 0!==t.getShipmentIndex())).map((t=>t.getShipmentIndex())))).sort(((t,e)=>t-e))}getUnassignedAgents(){let t=this.getData();return t.unassignedAgents&&0!=t.unassignedAgents.length?t.unassignedAgents.map((e=>t.inputData.agents[e])):[]}getUnassignedJobs(){let t=this.getData();return t.unassignedJobs&&0!=t.unassignedJobs.length?t.unassignedJobs.map((e=>t.inputData.jobs[e])):[]}getUnassignedShipments(){let t=this.getData();return t.unassignedShipments&&0!=t.unassignedShipments.length?t.unassignedShipments.map((e=>t.inputData.shipments[e])):[]}getJobSolutions(){let t=[];return this.getAgentSolutions().forEach((e=>{let i=e.getActions(),n={};i.forEach((t=>{const e=t.getJobIndex();void 0!==e&&(n[e]||(n[e]=[]),n[e].push(t.getRaw()))}));for(const i in n){const s=n[+i];let r={agentId:e.getAgentId(),actions:s,agent:e.getRaw(),job:this.rawData.properties.params.jobs[s[0].job_index]};t.push(new v(r))}})),t}getJobSolution(t){const e=A.convertJobToIndex(this.getData(),t);for(let t of this.getJobSolutions()){const i=t.getActions();if(i.length>0&&i[0].getJobIndex()===e)return t}}getShipmentSolutions(){let t=[];return this.getAgentSolutions().forEach((e=>{let i=e.getActions(),n={};i.forEach((t=>{const e=t.getShipmentIndex();void 0!==e&&(n[e]||(n[e]=[]),n[e].push(t.getRaw()))}));for(const i in n){const s=n[+i];let r={agentId:e.getAgentId(),actions:s,agent:e.getRaw(),shipment:this.rawData.properties.params.shipments[s[0].shipment_index]};t.push(new b(r))}})),t}getShipmentSolution(t){const e=A.convertShipmentToIndex(this.getData(),t);for(let t of this.getShipmentSolutions()){const i=t.getActions();if(i.length>0&&i[0].getShipmentIndex()===e)return t}}getJobInfo(t){const e=A.convertJobToIndex(this.getData(),t);return this.getJobInfoByIndex(e)}getShipmentInfo(t){const e=A.convertShipmentToIndex(this.getData(),t);return this.getShipmentInfoByIndex(e)}getJobInfoByIndex(t){if(t<0)return;let e,i=[];for(const n of this.getAgentSolutions())for(const s of n.getActions())s.getJobIndex()===t&&(i.push(s),e=n);return 0!==i.length&&e?new m({agentId:e.getAgentId(),actions:i,agent:e}):void 0}getShipmentInfoByIndex(t){if(t<0)return;let e,i=[];for(const n of this.getAgentSolutions())for(const s of n.getActions())s.getShipmentIndex()===t&&(i.push(s),e=n);return 0!==i.length&&e?new m({agentId:e.getAgentId(),actions:i,agent:e}):void 0}getAgentRoute(t,i){return e(this,void 0,void 0,(function*(){const e=this.getAgentSolution(t);if(!e)return;let n=e.getWaypoints().map((t=>"lonlat:"+t.getLocation())).join("|");if(0==n.length)return;const s=yield fetch(this.constructRoutingRequest(n,i));return yield s.json()}))}constructRoutingRequest(t,e){let i=`${this.getOptions().baseUrl}/v1/routing?waypoints=${t}&apiKey=${this.getOptions().apiKey}`;return e.mode&&(i+=`&mode=${e.mode}`),e.type&&(i+=`&type=${e.type}`),e.units&&(i+=`&units=${e.units}`),e.lang&&(i+=`&lang=${e.lang}`),e.avoid&&e.avoid.length>0&&(i+=`&avoid=${e.avoid.join("|")}`),e.details&&e.details.length>0&&(i+=`&details=${e.details.join(",")}`),e.traffic&&(i+=`&traffic=${e.traffic}`),e.max_speed&&(i+=`&max_speed=${e.max_speed}`),i}}var I={__proto__:null,Agent:i,AgentSolution:c,Avoid:s,Break:r,Coordinates:n,Job:o,Location:a,RouteAction:l,RouteActionInfo:m,RouteLeg:d,RouteLegStep:h,RoutePlannerError:w,RoutePlannerResult:x,Shipment:u,ShipmentStep:p,Waypoint:g};class R{constructor(t,e){this.options=t,this.options.baseUrl||(this.options.baseUrl="https://api.geoapify.com"),this.raw=e||{agents:[],jobs:[],shipments:[],locations:[],avoid:[]}}getRaw(){return this.raw}setRaw(t){return this.raw=t,this}setMode(t){return this.raw.mode=t,this}addAgent(t){return this.raw.agents.push(t.getRaw()),this}addJob(t){return this.raw.jobs.push(t.getRaw()),this}addLocation(t){return this.raw.locations.push(t.getRaw()),this}addShipment(t){return this.raw.shipments.push(t.getRaw()),this}addAvoid(t){return this.raw.avoid.push(t.getRaw()),this}setTraffic(t){return this.raw.traffic=t,this}setType(t){return this.raw.type=t,this}setMaxSpeed(t){return this.raw.max_speed=t,this}setUnits(t){return this.raw.units=t,this}plan(){return e(this,void 0,void 0,(function*(){const t=y.cleanObject(this.raw),i=yield function(t,i){return e(this,void 0,void 0,(function*(){if("undefined"!=typeof fetch)return fetch(t,i);try{const e=Function("return import('node-fetch')")();return(0,(yield e).default)(t,i)}catch(t){throw new Error("Fetch is not available in this environment. If you are using Node.js <18, install 'node-fetch' manually: npm install node-fetch")}}))}(`${this.options.baseUrl}/v1/routeplanner?apiKey=${this.options.apiKey}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)});if(!i.ok){let t=yield i.json();throw new w(t.error,t.message,t)}let n=yield i.json();return new x(this.options,n)}))}}class D{constructor(t){this.unassignedReq="unassigned",this.assignAgentReqStart="assign-agent-",this.result=t}checkIfArrayIsUnique(t){return t.length===new Set(t).size}getAgentByIndex(t){return this.result.getRawData().properties.params.agents[t]}getJobByIndex(t){return this.result.getRawData().properties.params.jobs[t]}getShipmentByIndex(t){return this.result.getRawData().properties.params.shipments[t]}validateAgent(t){if(!this.getAgentByIndex(t))throw new Error(`Agent with index ${t} not found`)}updateResult(t){this.result.getRawData().features=t.getRawData().features,this.result.getRawData().properties.issues=t.getRawData().properties.issues}addAgentCapabilities(t){for(let e=0;e<t.length;e++){const i=t[e],n=`assign-agent-${e}`;i.capabilities||(i.capabilities=[]),i.capabilities.includes(n)||i.capabilities.push(n)}}}class _ extends D{assignJobs(t,i,n){var s;return e(this,void 0,void 0,(function*(){this.validateAgent(t),this.validateJobs(i,t);for(const t of i)this.setJobPriority(t,n);const e=y.cloneObject(this.result.getRawData().properties.params);(null===(s=this.result.getRawData().properties.issues)||void 0===s?void 0:s.unassigned_jobs)&&this.markJobsUnassigned(e.jobs,this.result.getRawData().properties.issues.unassigned_jobs),this.markJobsForAgent(e.jobs,i,t),this.markRemainingJobsWithAgentRequirement(e.jobs,i),this.addAgentCapabilities(e.agents);const r=new R(this.result.getOptions(),e),o=yield r.plan();return this.updateResult(o),!0}))}removeJobs(t){var i;return e(this,void 0,void 0,(function*(){this.validateJobs(t);const e=y.cloneObject(this.result.getRawData().properties.params);this.markJobsUnassigned(e.jobs,t),(null===(i=this.result.getRawData().properties.issues)||void 0===i?void 0:i.unassigned_jobs)&&this.markJobsUnassigned(e.jobs,this.result.getRawData().properties.issues.unassigned_jobs),this.markRemainingJobsWithAgentRequirement(e.jobs,t),this.addAgentCapabilities(e.agents);const n=new R(this.result.getOptions(),e),s=yield n.plan();return this.updateResult(s),!0}))}addNewJobs(t,i){var n;return e(this,void 0,void 0,(function*(){let e=i.map((t=>t.getRaw()));this.validateAgent(t),this.validateNewJobs(e);const s=this.result.getRawData().properties.params.jobs.length;this.result.getRawData().properties.params.jobs.push(...e);const r=e.map(((t,e)=>s+e)),o=y.cloneObject(this.result.getRawData().properties.params);(null===(n=this.result.getRawData().properties.issues)||void 0===n?void 0:n.unassigned_jobs)&&this.markJobsUnassigned(o.jobs,this.result.getRawData().properties.issues.unassigned_jobs),this.markJobsForAgent(o.jobs,r,t),this.markRemainingJobsWithAgentRequirement(o.jobs,r),this.addAgentCapabilities(o.agents);const a=new R(this.result.getOptions(),o),u=yield a.plan();return this.updateResult(u),!0}))}markJobsUnassigned(t,e){e.forEach((e=>{t[e]&&(t[e].requirements||(t[e].requirements=[]),t[e].requirements.includes(this.unassignedReq)||t[e].requirements.push(this.unassignedReq))}))}markRemainingJobsWithAgentRequirement(t,e){for(let i=0;i<t.length;i++)if(!e.includes(i)){const e=this.result.getJobInfoByIndex(i);if(e){const n=e.getAgent().getAgentIndex(),s=`${this.assignAgentReqStart}${n}`;t[i].requirements||(t[i].requirements=[]),t[i].requirements.includes("unassigned")&&t[i].requirements.splice(t[i].requirements.indexOf("unassigned"),1),t[i].requirements.includes(s)||t[i].requirements.push(s)}}}markJobsForAgent(t,e,i){e.forEach((e=>{if(t[e]){const n=`assign-agent-${i}`;t[e].requirements||(t[e].requirements=[]),t[e].requirements.includes("unassigned")&&t[e].requirements.splice(t[e].requirements.indexOf("unassigned"),1),t[e].requirements.includes(n)||t[e].requirements.push(n)}}))}validateJobs(t,e){if(0==t.length)throw new Error("No jobs provided");if(!this.checkIfArrayIsUnique(t))throw new Error("Jobs are not unique");t.forEach((t=>{let i=this.result.getJobInfoByIndex(t);if(null==i&&this.validateJobExists(t),null!=e&&(null==i?void 0:i.getAgent().getAgentIndex())==e)throw new Error(`Job with index ${t} already assigned to agent with index ${e}`)}))}validateJobExists(t){if(!this.getJobByIndex(t))throw new Error(`Job with index ${t} not found`);if(!this.result.getRawData().properties.issues.unassigned_jobs.includes(t))throw new Error(`Job with index ${t} is invalid`)}validateNewJobs(t){if(0==t.length)throw new Error("No jobs provided");if(!this.checkIfArrayIsUnique(t))throw new Error("Jobs are not unique")}setJobPriority(t,e){null!=e&&(this.result.getRawData().properties.params.jobs[t].priority=e)}}class S extends D{assignShipments(t,i,n){var s;return e(this,void 0,void 0,(function*(){this.validateAgent(t),this.validateShipments(i,t);for(const t of i)this.setShipmentPriority(t,n);const e=y.cloneObject(this.result.getRawData().properties.params);(null===(s=this.result.getRawData().properties.issues)||void 0===s?void 0:s.unassigned_shipments)&&this.markShipmentsUnassigned(e.shipments,this.result.getRawData().properties.issues.unassigned_shipments),this.markShipmentsForAgent(e.shipments,i,t),this.markRemainingShipmentsWithAgentRequirement(e.shipments,i),this.addAgentCapabilities(e.agents);const r=new R(this.result.getOptions(),e),o=yield r.plan();return this.updateResult(o),!0}))}removeShipments(t){var i;return e(this,void 0,void 0,(function*(){this.validateShipments(t);const e=y.cloneObject(this.result.getRawData().properties.params);this.markShipmentsUnassigned(e.shipments,t),(null===(i=this.result.getRawData().properties.issues)||void 0===i?void 0:i.unassigned_shipments)&&this.markShipmentsUnassigned(e.shipments,this.result.getRawData().properties.issues.unassigned_shipments),this.markRemainingShipmentsWithAgentRequirement(e.shipments,t),this.addAgentCapabilities(e.agents);const n=new R(this.result.getOptions(),e),s=yield n.plan();return this.updateResult(s),!0}))}markShipmentsUnassigned(t,e){e.forEach((e=>{t[e]&&(t[e].requirements||(t[e].requirements=[]),t[e].requirements.includes(this.unassignedReq)||t[e].requirements.push(this.unassignedReq))}))}markRemainingShipmentsWithAgentRequirement(t,e){for(let i=0;i<t.length;i++)if(!e.includes(i)){const e=this.result.getShipmentInfoByIndex(i);if(e){const n=e.getAgent().getAgentIndex(),s=`${this.assignAgentReqStart}${n}`;t[i].requirements||(t[i].requirements=[]),t[i].requirements.includes(s)||t[i].requirements.push(s)}}}addNewShipments(t,i){var n;return e(this,void 0,void 0,(function*(){let e=i.map((t=>t.getRaw()));this.validateAgent(t),this.validateNewShipments(e);const s=this.result.getRawData().properties.params.shipments.length;this.result.getRawData().properties.params.shipments.push(...e);const r=e.map(((t,e)=>s+e)),o=y.cloneObject(this.result.getRawData().properties.params);(null===(n=this.result.getRawData().properties.issues)||void 0===n?void 0:n.unassigned_shipments)&&this.markShipmentsUnassigned(o.shipments,this.result.getRawData().properties.issues.unassigned_shipments),this.markShipmentsForAgent(o.shipments,r,t),this.markRemainingShipmentsWithAgentRequirement(o.shipments,r),this.addAgentCapabilities(o.agents);const a=new R(this.result.getOptions(),o),u=yield a.plan();return this.updateResult(u),!0}))}validateShipments(t,e){if(0==t.length)throw new Error("No shipments provided");if(!this.checkIfArrayIsUnique(t))throw new Error("Shipments are not unique");t.forEach((t=>{let i=this.result.getShipmentInfoByIndex(t);if(null==i&&this.validateShipmentExists(t),null!=e&&(null==i?void 0:i.getAgent().getAgentIndex())==e)throw new Error(`Shipment with index ${t} already assigned to agent with index ${e}`)}))}validateShipmentExists(t){if(!this.getShipmentByIndex(t))throw new Error(`Shipment with index ${t} not found`);if(!this.result.getRawData().properties.issues.unassigned_shipments.includes(t))throw new Error(`Shipment with index ${t} is invalid`)}validateNewShipments(t){if(0==t.length)throw new Error("No shipments provided");if(!this.checkIfArrayIsUnique(t))throw new Error("Shipments are not unique")}setShipmentPriority(t,e){null!=e&&(this.result.getRawData().properties.params.shipments[t].priority=e)}markShipmentsForAgent(t,e,i){e.forEach((e=>{if(t[e]){const n=`assign-agent-${i}`;t[e].requirements||(t[e].requirements=[]),t[e].requirements.includes("unassigned")&&t[e].requirements.splice(t[e].requirements.indexOf("unassigned"),1),t[e].requirements.includes(n)||t[e].requirements.push(n)}}))}}class T{constructor(t){this.result=new x(y.cloneObject(t.getOptions()),y.cloneObject(t.getRawData()))}assignJobs(t,i,n){return e(this,void 0,void 0,(function*(){this.assertArray(i,"jobIndexesOrIds");let e=A.convertAgentToIndex(this.result.getData(),t,!0),s=A.convertJobsToIndexes(this.result.getData(),i);return new _(this.result).assignJobs(e,s,n)}))}assignShipments(t,i,n){return e(this,void 0,void 0,(function*(){this.assertArray(i,"shipmentIndexesOrIds");let e=A.convertShipmentsToIndexes(this.result.getData(),i),s=A.convertAgentToIndex(this.result.getData(),t,!0);return new S(this.result).assignShipments(s,e,n)}))}removeJobs(t){return e(this,void 0,void 0,(function*(){this.assertArray(t,"jobIndexesOrIds");let e=A.convertJobsToIndexes(this.result.getData(),t);return new _(this.result).removeJobs(e)}))}removeShipments(t){return e(this,void 0,void 0,(function*(){this.assertArray(t,"shipmentIndexes");let e=A.convertShipmentsToIndexes(this.result.getData(),t);return new S(this.result).removeShipments(e)}))}addNewJobs(t,e){this.assertArray(e,"jobs");let i=A.convertAgentToIndex(this.result.getData(),t,!0);return new _(this.result).addNewJobs(i,e)}addNewShipments(t,e){this.assertArray(e,"shipments");let i=A.convertAgentToIndex(this.result.getData(),t,!0);return new S(this.result).addNewShipments(i,e)}getModifiedResult(){return this.result}assertArray(t,e){if(!Array.isArray(t))throw new Error("Type error: "+e+" must be an array")}}class k{static toPrettyDistance(t){return t>1e4?`${(t/1e3).toFixed(1)} km`:t>5e3?`${(t/1e3).toFixed(2)} km`:`${t} m`}static toPrettyTime(t){let e=Math.floor(t/3600),i=Math.floor((t-3600*e)/60);return 0===t?"0":e?i?e+"h "+i+"m":e+"h":i+"min"}}class L{constructor(t,e,i,n){this.WAYPOINT_POPUP_INITIALIZED_ATTRIBUTE="data-rp-timeline-popup-listeners",this.WAYPOINT_POPUP_CONTAINER_ID="geoapify-rp-sdk-waypoint-popup",this.defaultColors=["#ff4d4d","#1a8cff","#00cc66","#b300b3","#e6b800","#ff3385","#0039e6","#408000","#ffa31a","#990073","#cccc00","#cc5200","#6666ff","#009999"],this.timelineTemplate=(t,e,i,n,s,r)=>`\n <div class="geoapify-rp-sdk-timeline-item flex-container items-center ${e%2==0?"geoapify-rp-sdk-even":""} agent-${e}">\n <div class="geoapify-rp-sdk-timeline-item-agent flex-container items-center padding-top-5 padding-bottom-5 ${this.options.hasLargeDescription?"geoapify-rp-sdk-wider":""}">\n ${r&&r.length>0?`\n <div class="geoapify-rp-sdk-three-dot-menu" data-agent-index="${t.agentIndex}">\n <button class="geoapify-rp-sdk-three-dot-button">\n <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 128 512">\n <path fill="currentColor" d="M64 360a56 56 0 1 0 0 112 56 56 0 1 0 0-112zm0-160a56 56 0 1 0 0 112 56 56 0 1 0 0-112zM120 96A56 56 0 1 0 8 96a56 56 0 1 0 112 0z"/>\n </svg>\n </button>\n <ul class="geoapify-rp-sdk-menu-list">\n ${r.filter((t=>!t.hidden)).map((t=>`\n <li class="geoapify-rp-sdk-menu-item ${t.disabled?"geoapify-rp-sdk-menu-item-disabled":""}" data-key="${t.key}">${t.label}</li>\n `)).join("")}\n </ul>\n </div>\n `:""}\n <div style="color: ${t.color}" class="flex-main geoapify-rp-sdk-agent-info margin-right-10 flex-container column">\n <span class="geoapify-rp-sdk-mat-subtitle-2">${t.label}</span>\n <span class="geoapify-rp-sdk-mat-caption description">${t.description}</span>\n </div>\n </div>\n <div class="geoapify-rp-sdk-timeline flex-main" style="margin-left: 10px; position: relative; height: 100%; min-height: 45px;">\n <div class="geoapify-rp-sdk-line"></div>\n ${t.timelineLength&&"time"===i?`<div class="geoapify-rp-sdk-value-line"\n style="background-color: ${t.color}; width: ${t.timelineLength}; left: ${t.timelineLeft};"></div>\n `:""}\n ${t.distanceLineLength&&"distance"===i?`<div class="geoapify-rp-sdk-value-line"\n style="background-color: ${t.color}; width: ${t.distanceLineLength};"></div>`:""}\n\n ${"time"===i?`\n ${(t.itemsByTime||[]).map(((e,i)=>`\n <div class="geoapify-rp-sdk-solution-item"\n style="left: ${e.position}; width: ${e.minWidth||""}" data-tooltip="${e.description}"\n data-agent-index="${t.agentIndex}" data-waypoint-index="${i}">\n ${"full"===e.form?`<div class="geoapify-rp-sdk-solution-item-full" style="width: 100%; background-color: ${t.color};"></div>`:""}\n ${"standard"===e.form?`<div class="geoapify-rp-sdk-solution-item-standard" style="background-color: ${t.color};"></div>`:""}\n ${"minimal"===e.form?`<div class="geoapify-rp-sdk-solution-item-minimal" style="background-color: ${t.color};"></div>`:""}\n </div>`)).join("")}\n\n `:""}\n\n ${"distance"===i?`\n ${(t.itemsByDistance||[]).map(((e,i)=>`<div class="geoapify-rp-sdk-solution-item" style="left: ${e.position};" data-tooltip="${e.description}"\n data-agent-index="${t.agentIndex}" data-waypoint-index="${i}">\n <div class="geoapify-rp-sdk-solution-item-minimal" style="background-color: ${t.color};"></div>\n </div> `)).join("")}\n `:""}\n ${n&&"time"===i?`\n <div class="geoapify-rp-sdk-label-vertical-lines">\n ${(n||[]).map((t=>`\n <div class="geoapify-rp-sdk-label-vertical-line" style="left: ${t.position};"></div>\n `)).join("")}\n </div>\n `:""}\n\n ${s&&"distance"===i?`\n <div class="geoapify-rp-sdk-label-vertical-lines">\n ${(s||[]).map((t=>`<div class="geoapify-rp-sdk-label-vertical-line" style="left: ${t.position};"></div>`)).join("")}\n </div>\n `:""}\n <div id="global-tooltip" class="geoapify-rp-sdk-custom-tooltip" style="display: none;"></div>\n </div>\n </div>\n`,this.waypointPopupContainer=null,this.eventListeners={},this.container=t,this.result=i,this.inputData=e,this.options=n||{hasLargeDescription:!1,timelineType:"time",agentColors:this.defaultColors,capacityUnit:"items"},this.generateAgentTimeline(),this.initializeThreeDotMenus()}getHasLargeDescription(){return this.options.hasLargeDescription}setHasLargeDescription(t){this.options.hasLargeDescription=t,this.generateAgentTimeline()}getTimelineType(){return this.options.timelineType}setTimelineType(t){this.options.timelineType=t,this.generateAgentTimeline()}getAgentColors(){return this.options.agentColors}setAgentColors(t){this.options.agentColors=t,this.generateAgentTimeline()}getCapacityUnit(){return this.options.capacityUnit}setCapacityUnit(t){this.options.capacityUnit=t,this.generateAgentTimeline()}getTimeLabels(){return this.options.timeLabels}setTimeLabels(t){this.options.timeLabels=t,this.generateAgentTimeline()}getDistanceLabels(){return this.options.distanceLabels}setDistanceLabels(t){this.options.distanceLabels=t,this.generateAgentTimeline()}getAgentLabel(){return this.options.agentLabel}setAgentLabel(t){this.options.agentLabel=t,this.generateAgentTimeline()}getAgentMenuItems(){return this.options.agentMenuItems}setAgentMenuItems(t){this.options.agentMenuItems=t,this.generateAgentTimeline(),this.initializeThreeDotMenus()}getResult(){return this.result}setResult(t){this.result=t,this.generateAgentTimeline(),this.initializeThreeDotMenus()}on(t,e){this.eventListeners[t]||(this.eventListeners[t]=[]),this.eventListeners[t].includes(e)||this.eventListeners[t].push(e)}off(t,e){if(!this.eventListeners[t])return;const i=this.eventListeners[t].indexOf(e);i>-1&&this.eventListeners[t].splice(i,1)}getAgentColorByIndex(t){return this.options.agentColors[(t%this.options.agentColors.length+this.options.agentColors.length)%this.options.agentColors.length]}generateAgentTimeline(){let t;if(this.result&&!this.result.getRawData()){const e=this.result.getRawData().properties.params.agents.length;t=[];for(let i=0;i<=e;i++)t.push({label:`${this.options.agentLabel?this.options.agentLabel:"agent"} ${i+1}`,mode:this.result.getData().inputData.mode,color:this.getAgentColorByIndex(i),description:"",routeVisible:!0,agentIndex:i,timelineLength:"",distanceLineLength:"",itemsByDistance:[],itemsByTime:[],timelineLeft:"100%"});return this.drawTimelines(t,this.result),t}return this.inputData?(t=this.inputData.agents.map(((t,e)=>{var i;const n=`${this.options.agentLabel?this.options.agentLabel:"Agent"} ${e+1}`;return n.length>=10&&(this.options.hasLargeDescription=!0),{label:n,mode:null===(i=this.inputData)||void 0===i?void 0:i.mode,color:this.getAgentColorByIndex(e),description:this.generateAgentDescription(t,this.options.hasLargeDescription).description,routeVisible:!0,agentIndex:e,timelineLength:"",distanceLineLength:"",itemsByDistance:[],itemsByTime:[],timelineLeft:"100%"}})),this.drawTimelines(t,this.result),t):[]}drawTimelines(t,e){t&&e&&this.generateTimelinesData(t,e),this.container.innerHTML="",null==t||t.forEach(((t,e)=>{const i=this.timelineTemplate(t,e,this.options.timelineType,this.options.timeLabels||[],this.options.distanceLabels||[],this.options.agentMenuItems||[]);this.container.insertAdjacentHTML("beforeend",i),this.result&&this.container.querySelectorAll(".geoapify-rp-sdk-solution-item").forEach((t=>{const e=t.getAttribute("data-agent-index"),i=t.getAttribute("data-waypoint-index"),n=this.result.getAgentSolutions().find((t=>t.getAgentIndex()===+e));if(n&&i){const e=n.getWaypoints()[+i];t.addEventListener("mouseover",(()=>{this.emit("onWaypointHover",e)}))}}))})),this.options.showWaypointPopup&&(this.options.waypointPopupGenerator?this.initializeWaypointPopups():this.initializeGlobalTooltip())}generateTimelinesData(t,e){const i=this.options.capacityUnit||"items";let n=Math.max.apply(Math,e.getAgentSolutions().map((t=>t.getDistance()))),s=Math.max.apply(Math,e.getAgentSolutions().map((t=>t.getTime()+t.getStartTime())));e.getAgentSolutions().forEach((r=>{var o,a;const u=t[r.getAgentIndex()];u.timelineLength=(r.getTime()-((null===(o=r.getWaypoints())||void 0===o?void 0:o.length)?r.getWaypoints()[0].getStartTime():0))/s*100+"%",u.distanceLineLength=r.getDistance()/n*100+"%",u.itemsByDistance=[],u.timelineLeft=(r.getStartTime()||((null===(a=r.getWaypoints())||void 0===a?void 0:a.length)?r.getWaypoints()[0].getStartTime():0))/s*100+"%",this.generateItemsByTime(u,r,s,e,i),this.generateItemsByDistance(u,r,n)}))}emit(t,e){this.eventListeners[t]&&this.eventListeners[t].forEach((i=>{try{i(e)}catch(e){console.error(`Error in event handler for "${t}":`,e)}}))}generateItemsByTime(t,e,i,n,s){t.itemsByTime=[],e.getWaypoints().forEach(((e,r)=>{const o=e.getDuration()||0,a=o/i,u=[],p=[...new Set(e.getActions().map((t=>t.getType().charAt(0).toUpperCase()+t.getType().slice(1))))].join(" / ");u.push(`${r+1}: ${p}`),o&&u.push(`Duration: ${k.toPrettyTime(e.getDuration())}`),u.push(`Time before: ${k.toPrettyTime(e.getStartTime())}`),u.push(`Time after: ${k.toPrettyTime(e.getStartTime()+o)}`);const h=e.getActions().map((t=>{const e=[];if(t){let i=t.getJobIndex()&&t.getJobIndex()>=0?n.getData().inputData.jobs[t.getJobIndex()]:void 0;(null==i?void 0:i.pickup_amount)&&e.push(`pickup ${i.pickup_amount} ${s}`),(null==i?void 0:i.delivery_amount)&&e.push(`deliver ${i.delivery_amount} ${s}`)}let i=t.getShipmentIndex()&&t.getShipmentIndex()>=0?n.getData().inputData.shipments[t.getShipmentIndex()]:void 0;return i&&i.amount&&e.push("pickup"===t.getType()?`pickup ${i.amount} ${s}`:`deliver ${i.amount} ${s}`),e.join(", ")})).filter((t=>t)).join("; ");h&&u.push(`Actions: ${h}`);const d={type:"job",actualWidth:100*a+"%",position:100*(e.getStartTime()+o/2)/i+"%",form:"full",minWidth:100*a+"%",description:u.join("\n")};t.itemsByTime.push(d)}))}generateItemsByDistance(t,e,i){let n=0;e.getLegs().forEach(((s,r)=>{const o=e.getWaypoints()[s.getFromWaypointIndex()],a=e.getWaypoints()[s.getToWaypointIndex()];if(0===r){const e=[],i=[...new Set(o.getActions().map((t=>t.getType().charAt(0).toUpperCase()+t.getType().slice(1))))].join(" / ");e.push(i),e.push("Distance traveled: 0");const n={type:"job",actualWidth:"0",position:"0",form:"minimal",minWidth:"10px",description:e.join("\n")};t.itemsByDistance.push(n)}n+=s.getDistance();const u=[],p=[...new Set(a.getActions().map((t=>t.getType().charAt(0).toUpperCase()+t.getType().slice(1))))].join(" / ");u.push(p),u.push(`Distance traveled: ${k.toPrettyDistance(n)}`);const h={type:"job",actualWidth:"0",position:n/i*100+"%",form:"minimal",minWidth:"10px",description:u.join("\n")};t.itemsByDistance.push(h)}))}generateAgentDescription(t,e){const i=[];return t.pickup_capacity&&t.delivery_capacity?i.push(`${t.pickup_capacity} ${this.options.capacityUnit} / ${t.delivery_capacity} ${this.options.capacityUnit}`):(t.pickup_capacity||t.delivery_capacity)&&i.push(`${t.pickup_capacity||t.delivery_capacity} ${this.options.capacityUnit}`),t.time_windows&&i.push(t.time_windows.map((t=>`${k.toPrettyTime(t[0])}-${k.toPrettyTime(t[1])}`)).join(", ")),t.capabilities&&i.push(...t.capabilities),i.join(", ").length>20&&(e=!0),{description:i.join(", "),hasLargeDescription:e}}initializeGlobalTooltip(){if(document.getElementById("global-tooltip-listener"))return;const t=document.createElement("div");t.id="global-tooltip-listener",document.body.appendChild(t);const e=document.createElement("div");e.id="global-tooltip",e.className="geoapify-rp-sdk-custom-tooltip",e.style.display="none",document.body.appendChild(e),document.addEventListener("mouseover",(t=>{var i;const n=t.target,s=null===(i=n.closest(".geoapify-rp-sdk-solution-item"))||void 0===i?void 0:i.getAttribute("data-tooltip");if(s){const i=n.getBoundingClientRect();e.innerText=s,e.style.display="block",e.style.left=`${t.clientX}px`,e.style.top=`${i.bottom+6}px`,e.classList.add("geoapify-rp-sdk-show")}})),document.addEventListener("mouseout",(t=>{t.target.closest(".geoapify-rp-sdk-solution-item")&&(e.classList.remove("geoapify-rp-sdk-show"),e.style.display="none")}))}createWaypointPopupContainer(){const t=document.getElementById(this.WAYPOINT_POPUP_CONTAINER_ID);t?this.waypointPopupContainer=t:(this.waypointPopupContainer=document.createElement("div"),this.waypointPopupContainer.id="geoapify-rp-sdk-waypoint-popup",this.waypointPopupContainer.className="geoapify-rp-sdk-custom-tooltip",this.waypointPopupContainer.style.opacity="1",this.waypointPopupContainer.style.display="none",document.body.appendChild(this.waypointPopupContainer),document.addEventListener("mouseover",(t=>{if(!this.waypointPopupContainer||"none"===this.waypointPopupContainer.style.display)return;const e=t.target,i=this.waypointPopupContainer.contains(e),n=null!==e.closest(".geoapify-rp-sdk-solution-item");i||n||this.hideWaypointPopup()})))}initializeWaypointPopups(){"true"!==this.container.getAttribute(this.WAYPOINT_POPUP_INITIALIZED_ATTRIBUTE)&&(this.container.setAttribute("data-rp-timeline-popup-listeners","true"),this.createWaypointPopupContainer(),this.container.addEventListener("mouseover",(t=>{const e=t.target.closest(".geoapify-rp-sdk-solution-item");if(e){const t=e.getAttribute("data-agent-index"),i=e.getAttribute("data-waypoint-index");if(null!==t&&null!==i){const n=this.result.getAgentSolutions().find((e=>e.getAgentIndex()===+t));if(n){const t=n.getWaypoints()[+i];if(this.options.waypointPopupGenerator)try{const i=this.options.waypointPopupGenerator(t);this.showWaypointPopup(e,i)}catch(t){console.error("Error generating waypoint popup content:",t)}else this.hideWaypointPopup()}}}})))}showWaypointPopup(t,e){if(!this.waypointPopupContainer)return void console.error("Waypoint popup container not initialized.");this.waypointPopupContainer.innerHTML="",this.waypointPopupContainer.appendChild(e);const i=t.getBoundingClientRect();this.waypointPopupContainer.style.top=`${i.bottom+window.scrollY+10}px`;let n=i.left+window.scrollX+i.width/2-this.waypointPopupContainer.offsetWidth/2;const s=window.innerWidth,r=this.waypointPopupContainer.offsetWidth;n+r>s-10&&(n=s-r-10),n<10&&(n=10),this.waypointPopupContainer.style.left=`${n}px`,this.waypointPopupContainer.style.display="block"}hideWaypointPopup(){this.waypointPopupContainer&&(this.waypointPopupContainer.style.display="none")}initializeThreeDotMenus(){if("true"!==this.container.getAttribute("data-rp-timeline-menu-listeners")&&(this.container.setAttribute("data-rp-timeline-menu-listeners","true"),this.container.addEventListener("click",(t=>{const e=t.target.closest(".geoapify-rp-sdk-three-dot-button");if(e){const t=e.closest(".geoapify-rp-sdk-three-dot-menu");t&&(this.generateAgentMenuItemsOnThreeDotClick(t),this.toggleThreeDotMenu(t))}})),this.container.addEventListener("click",(t=>{const e=t.target.closest(".geoapify-rp-sdk-menu-item");if(e){if(e.classList.contains("geoapify-rp-sdk-menu-item-disabled"))return;const t=e.closest(".geoapify-rp-sdk-three-dot-menu"),i=null==t?void 0:t.getAttribute("data-agent-index"),n=i?+i:-1,s=e.getAttribute("data-key");if(s&&-1!==n&&this.options.agentMenuItems){const t=this.options.agentMenuItems.find((t=>t.key===s));t&&t.callback&&t.callback(n)}this.closeAllThreeDotMenus()}})),!document.getElementById("geoapify-rp-sdk-document-click-listener-flag"))){const t=document.createElement("div");t.id="geoapify-rp-sdk-document-click-listener-flag",t.style.display="none",document.body.appendChild(t),document.addEventListener("click",(t=>{const e=t.target;null!==e.closest(".geoapify-rp-sdk-three-dot-menu")||null!==e.closest(".geoapify-rp-sdk-three-dot-button")||this.closeAllThreeDotMenus()}))}}generateAgentMenuItemsOnThreeDotClick(t){const e=t.getAttribute("data-agent-index"),i=e?+e:-1;if(-1!==i){const e=this.generateMenuItemsForAgent(i);this.updateMenuItems(t,e)}}generateMenuItemsForAgent(t){let e=[...this.options.agentMenuItems||[]];if(this.eventListeners.beforeAgentMenuShow&&this.eventListeners.beforeAgentMenuShow.length>0){const i=this.eventListeners.beforeAgentMenuShow[0];try{const n=i(t,e);void 0!==n&&(e=n)}catch(t){console.error("Error in beforeAgentMenuShow event handler:",t)}}return e}updateMenuItems(t,e){const i=t.querySelector(".geoapify-rp-sdk-menu-list");if(i){const t=e.filter((t=>!t.hidden)).map((t=>`\n <li class="geoapify-rp-sdk-menu-item ${t.disabled?"geoapify-rp-sdk-menu-item-disabled":""}" data-key="${t.key}">${t.label}</li>\n `)).join("");i.innerHTML=t}}toggleThreeDotMenu(t){const e=t.querySelector(".geoapify-rp-sdk-menu-list");e&&(this.closeAllThreeDotMenus(t),e.style.display="block"===e.style.display?"none":"block")}closeAllThreeDotMenus(t){this.container.querySelectorAll(".geoapify-rp-sdk-menu-list").forEach((e=>{e.closest(".geoapify-rp-sdk-three-dot-menu")!==t&&(e.style.display="none")}))}}"undefined"!=typeof window&&(window.RoutePlannerSDK=Object.assign({RoutePlanner:R,RouteEditor:T,RoutePlannerTimeLine:L},I)),t.Agent=i,t.AgentSolution=c,t.Avoid=s,t.Break=r,t.Coordinates=n,t.Job=o,t.Location=a,t.RouteAction=l,t.RouteActionInfo=m,t.RouteLeg=d,t.RouteLegStep=h,t.RoutePlanner=R,t.RoutePlannerError=w,t.RoutePlannerResult=x,t.RoutePlannerResultEditor=T,t.RoutePlannerTimeline=L,t.Shipment=u,t.ShipmentStep=p,t.Waypoint=g,t.default=R})); //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXgubWluLmpzIiwic291cmNlcyI6WyIuLi9ub2RlX21vZHVsZXMvdHNsaWIvdHNsaWIuZXM2LmpzIiwiLi4vc3JjL21vZGVscy9lbnRpdGllcy9uZXN0ZWQvaW5wdXQvYWdlbnQudHMiLCIuLi9zcmMvbW9kZWxzL2VudGl0aWVzL25lc3RlZC9pbnB1dC9jb29yZGluYXRlcy50cyIsIi4uL3NyYy9tb2RlbHMvZW50aXRpZXMvbmVzdGVkL2lucHV0L2F2b2lkLnRzIiwiLi4vc3JjL21vZGVscy9lbnRpdGllcy9uZXN0ZWQvaW5wdXQvYnJlYWsudHMiLCIuLi9zcmMvbW9kZWxzL2VudGl0aWVzL25lc3RlZC9pbnB1dC9qb2IudHMiLCIuLi9zcmMvbW9kZWxzL2VudGl0aWVzL25lc3RlZC9pbnB1dC9sb2NhdGlvbi50cyIsIi4uL3NyYy9tb2RlbHMvZW50aXRpZXMvbmVzdGVkL2lucHV0L3NoaXBtZW50LnRzIiwiLi4vc3JjL21vZGVscy9lbnRpdGllcy9uZXN0ZWQvaW5wdXQvc2hpcG1lbnQtc3RlcC50cyIsIi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