@idm-plugin/vessel 3.6.0 → 3.6.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.js CHANGED
@@ -1,10 +1,10 @@
1
1
  var ht = Object.defineProperty;
2
2
  var mt = (x, e, t) => e in x ? ht(x, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : x[e] = t;
3
3
  var U = (x, e, t) => (mt(x, typeof e != "symbol" ? e + "" : e, t), t);
4
- import B from "got";
4
+ import z from "got";
5
5
  import dt from "@log4js-node/log4js-api";
6
6
  import w from "moment";
7
- import { LaneHelper as O, LngLatHelper as z } from "@idm-plugin/geo2";
7
+ import { LaneHelper as R, LngLatHelper as J } from "@idm-plugin/geo2";
8
8
  import { MeteoHelper2 as ft } from "@idm-plugin/meteo2";
9
9
  import { Meteo2Assist as ct } from "@idm-plugin/meteo";
10
10
  let g;
@@ -54,7 +54,7 @@ class at {
54
54
  return { labelCn: t, labelEn: a };
55
55
  }
56
56
  }
57
- class jt extends at {
57
+ class Tt extends at {
58
58
  constructor(t, a) {
59
59
  super();
60
60
  U(this, "clientId");
@@ -69,7 +69,7 @@ class jt extends at {
69
69
  client_secret: this.clientSecret,
70
70
  grant_type: "client_credentials"
71
71
  }
72
- }, n = await B.post(a, o).json();
72
+ }, n = await z.post(a, o).json();
73
73
  g == null || g.info("[%s] fetch access token from: %s - %j", t.requestId, a, n), n.error || (this.token = {
74
74
  accessToken: n.access_token,
75
75
  tokenType: n.token_type,
@@ -101,7 +101,7 @@ class jt extends at {
101
101
  }
102
102
  };
103
103
  g == null || g.info("[%s] fetch suggest vessels from: %s - %j", a.requestId, o, n);
104
- const i = await B.post(o, n).json();
104
+ const i = await z.post(o, n).json();
105
105
  return i.status !== 200 ? (g == null || g.warn("[%s] fetch suggest vessels failed: %j", a.requestId, { message: i.message, status: i.status, code: i.code }), []) : (i.data || []).map((u) => ({
106
106
  mmsi: u.mmsi,
107
107
  name: u.nameEn,
@@ -129,7 +129,7 @@ class jt extends at {
129
129
  searchParams: i
130
130
  };
131
131
  g == null || g.info("[%s] fetch vessel from: %s - %j", a.requestId, n, s);
132
- const r = await B.get(n, s).json();
132
+ const r = await z.get(n, s).json();
133
133
  if (r.status !== 200)
134
134
  return g == null || g.warn("[%s] fetch suggest vessels failed: %j", a.requestId, { message: r.message, status: r.status, code: r.code }), {};
135
135
  {
@@ -173,7 +173,7 @@ class jt extends at {
173
173
  }
174
174
  };
175
175
  g == null || g.info("[%s] fetch vessel archive from: %s - %j", a.requestId, o, n);
176
- const i = await B.post(o, n).json();
176
+ const i = await z.post(o, n).json();
177
177
  return i.status !== 200 ? (g == null || g.warn("[%s] fetch vessel archive failed: %j", a.requestId, { message: i.message, status: i.status, code: i.code }), {}) : i.data;
178
178
  }
179
179
  async realTimePosition(t, a = {}) {
@@ -186,7 +186,7 @@ class jt extends at {
186
186
  searchParams: { mmsi: t }
187
187
  };
188
188
  g == null || g.info("[%s] fetch realtime position from: %s - %j", a.requestId, o, n);
189
- const i = await B.get(o, n).json();
189
+ const i = await z.get(o, n).json();
190
190
  if (i.code)
191
191
  return g == null || g.warn("[%s] fetch realtime position failed: %j", a.requestId, { message: i.message, status: i.status, code: i.code }), i;
192
192
  const s = i.data;
@@ -237,7 +237,7 @@ class jt extends at {
237
237
  * @param options { requiretId: '请求ID', useAIModel: '启用AI算法', withECA: '是否计算低硫区航行距离', withSpecial: '是否计算穿越的特战区列表和海盗区列表', draught: '最大吃水' }
238
238
  */
239
239
  async calculateRoute(t, a, o, n, i, s = {}) {
240
- var k, b, S;
240
+ var k, b, F;
241
241
  const r = w();
242
242
  await this.checkToken(s);
243
243
  const l = "https://market.myvessel.cn/sdc/v1/mkt/routes/plan", u = {
@@ -260,7 +260,7 @@ class jt extends at {
260
260
  json: u
261
261
  };
262
262
  g == null || g.info("[%s] fetch route from: %s - %j", s.requestId, l, c);
263
- const h = await B.post(l, c).json();
263
+ const h = await z.post(l, c).json();
264
264
  if (h.status !== 200)
265
265
  return g == null || g.warn("[%s] fetch route failed: %j", s.requestId, { message: h.message, status: h.status, code: h.code }), {};
266
266
  {
@@ -273,8 +273,8 @@ class jt extends at {
273
273
  route: [],
274
274
  distance: 0,
275
275
  memo: ""
276
- }, { nodes: p, seas: v, tracks: f, specialRegions: d, ecaLength: m } = h.data;
277
- I.nodes = p == null ? void 0 : p.map((M) => ({
276
+ }, { nodes: v, seas: p, tracks: f, specialRegions: d, ecaLength: m } = h.data;
277
+ I.nodes = v == null ? void 0 : v.map((M) => ({
278
278
  code: M.nodeCode,
279
279
  nameEn: M.nameEn,
280
280
  nameCn: M.nameCn,
@@ -297,7 +297,7 @@ class jt extends at {
297
297
  isKey: M.isKeyNode,
298
298
  // 重要枢纽节点
299
299
  isHub: M.isHubNode
300
- })), I.seas = v == null ? void 0 : v.map((M) => ({
300
+ })), I.seas = p == null ? void 0 : p.map((M) => ({
301
301
  code: M.mrgidSea,
302
302
  nameEn: M.nameEn,
303
303
  nameCn: M.nameCn,
@@ -329,9 +329,9 @@ class jt extends at {
329
329
  }), I.waypoints = f == null ? void 0 : f.map((M) => ({
330
330
  lat: Math.round(M.lat * 1e5) / 1e5,
331
331
  lng: Math.round(M.lon * 1e5) / 1e5
332
- })), (S = I.waypoints) != null && S.length && (I.waypoints = O.simplifyCoordinates(I.waypoints), I.route = O.divideAccordingToLng(I.waypoints), I.distance = O.calculateRouteDistance(I.route), I.distanceInECA = m);
333
- const C = w().diff(r, "second");
334
- return I.memo = `time cost: ${C}s`, g.info("[%s] calculate route cost: %d seconds", s.requestId, C), I;
332
+ })), (F = I.waypoints) != null && F.length && (I.waypoints = R.simplifyCoordinates(I.waypoints), I.route = R.divideAccordingToLng(I.waypoints), I.distance = R.calculateRouteDistance(I.route), I.distanceInECA = m);
333
+ const S = w().diff(r, "second");
334
+ return I.memo = `time cost: ${S}s`, g.info("[%s] calculate route cost: %d seconds", s.requestId, S), I;
335
335
  }
336
336
  }
337
337
  async trajectory(t, a, o, n, i = !0, s = {}) {
@@ -342,10 +342,10 @@ class jt extends at {
342
342
  return await this.trajectoryIn30Day(t, l, u, r, n, c, s), c;
343
343
  }
344
344
  async trajectoryIn30Day(t, a, o, n, i, s, r = {}) {
345
- var b, S, I, p, v;
345
+ var b, F, I, v, p;
346
346
  const l = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/track", u = {
347
347
  headers: {
348
- Authorization: `${(b = this.token) == null ? void 0 : b.tokenType} ${(S = this.token) == null ? void 0 : S.accessToken}`
348
+ Authorization: `${(b = this.token) == null ? void 0 : b.tokenType} ${(F = this.token) == null ? void 0 : F.accessToken}`
349
349
  },
350
350
  json: {
351
351
  mmsi: t,
@@ -354,15 +354,15 @@ class jt extends at {
354
354
  }
355
355
  };
356
356
  g == null || g.info("[%s] fetch trajectory from: %s - %j", r.requestId, l, u);
357
- const c = await B.post(l, u).json();
357
+ const c = await z.post(l, u).json();
358
358
  if (c.code)
359
359
  return g == null || g.warn("[%s] fetch trajectory failed: %j", r.requestId, l, { message: c.message, status: c.status, code: c.code }), c;
360
360
  let h = -1;
361
- const k = w(`${(p = (I = c.data) == null ? void 0 : I[0]) == null ? void 0 : p.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
362
- return (v = c.data) == null || v.forEach((f) => {
363
- for (const P in f)
364
- !isNaN(f[P]) && Number(f[P]) !== 1 / 0 && (f[P] = Number(f[P]));
365
- const d = w(`${f.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00"), m = f.status, { labelCn: y, labelEn: C } = this.parseStatus(m), M = {
361
+ const k = w(`${(v = (I = c.data) == null ? void 0 : I[0]) == null ? void 0 : v.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
362
+ return (p = c.data) == null || p.forEach((f) => {
363
+ for (const N in f)
364
+ !isNaN(f[N]) && Number(f[N]) !== 1 / 0 && (f[N] = Number(f[N]));
365
+ const d = w(`${f.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00"), m = f.status, { labelCn: y, labelEn: S } = this.parseStatus(m), M = {
366
366
  mmsi: f.mmsi,
367
367
  imo: n == null ? void 0 : n.imo,
368
368
  lat: f.lat,
@@ -376,7 +376,7 @@ class jt extends at {
376
376
  destination: f.dest,
377
377
  positionTime: d.unix(),
378
378
  labelCn: y,
379
- labelEn: C,
379
+ labelEn: S,
380
380
  method: "trajectory",
381
381
  vendor: "myVessel",
382
382
  utc: d.utc().format()
@@ -385,7 +385,7 @@ class jt extends at {
385
385
  }), s;
386
386
  }
387
387
  }
388
- class Ft extends at {
388
+ class jt extends at {
389
389
  constructor(t) {
390
390
  super();
391
391
  U(this, "token");
@@ -397,7 +397,7 @@ class Ft extends at {
397
397
  mmsi: t,
398
398
  usertoken: this.token
399
399
  }
400
- }, i = await B.post(o, n).json();
400
+ }, i = await z.post(o, n).json();
401
401
  g == null || g.info("[%s] fetch realtime position from: %s - %j", a.requestId, o, n);
402
402
  const s = i == null ? void 0 : i.list;
403
403
  if (!s)
@@ -447,7 +447,7 @@ class Ft extends at {
447
447
  Host: "www.hifleet.com"
448
448
  }
449
449
  };
450
- let i = await B.post(o, n).json();
450
+ let i = await z.post(o, n).json();
451
451
  g == null || g.info("[%s] fetch vessel props from: %s - %j", a.requestId, o, n), i instanceof Array && (i = i[0]);
452
452
  for (const r in i)
453
453
  !isNaN(i[r]) && Number(i[r]) !== 1 / 0 && (i[r] = Number(i[r]));
@@ -461,7 +461,7 @@ class Ft extends at {
461
461
  draught: i.dr,
462
462
  type: i.t
463
463
  };
464
- return o = "https://www.hifleet.com/hifleetapi/sameShipSearch.do", i = await B.post(o, n).json(), g == null || g.info("[%s] search vessel dead weight from: %s - %j", a.requestId, o, n), i instanceof Array && (i = i[0]), i && (s.deadweight = Number(i.dwt)), s;
464
+ return o = "https://www.hifleet.com/hifleetapi/sameShipSearch.do", i = await z.post(o, n).json(), g == null || g.info("[%s] search vessel dead weight from: %s - %j", a.requestId, o, n), i instanceof Array && (i = i[0]), i && (s.deadweight = Number(i.dwt)), s;
465
465
  }
466
466
  async suggest(t, a = {}) {
467
467
  const o = "https://www.hifleet.com/hifleetapi/getShipSuggest.do", n = {
@@ -473,7 +473,7 @@ class Ft extends at {
473
473
  Origin: "https://www.hifleet.com",
474
474
  Host: "www.hifleet.com"
475
475
  }
476
- }, i = await B.post(o, n).json();
476
+ }, i = await z.post(o, n).json();
477
477
  g == null || g.info("[%s] suggest vessel props from: %s - %j", a.requestId, o, n);
478
478
  const s = [];
479
479
  for (const r of i)
@@ -502,19 +502,19 @@ class Ft extends at {
502
502
  mmsi: t,
503
503
  usertoken: this.token
504
504
  }
505
- }, k = "https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token", b = await B.get(k, h).json();
505
+ }, k = "https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token", b = await z.get(k, h).json();
506
506
  g == null || g.info("[%s] fetch trajectory from: %s - %j", s.requestId, k, h);
507
- let S;
508
- b && (S = ((d = (f = b.ships) == null ? void 0 : f.offors) == null ? void 0 : d.ship) || [], S.length || g == null || g.warn("[%s] fetch trajectory failed: %j", s.requestId, b));
507
+ let F;
508
+ b && (F = ((d = (f = b.ships) == null ? void 0 : f.offors) == null ? void 0 : d.ship) || [], F.length || g == null || g.warn("[%s] fetch trajectory failed: %j", s.requestId, b));
509
509
  const I = [];
510
- let p = -1;
511
- const v = w(`${(m = S == null ? void 0 : S[0]) == null ? void 0 : m.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
512
- for (const y of S) {
513
- for (const H in y)
514
- !isNaN(y[H]) && Number(y[H]) !== 1 / 0 && (y[H] = Number(y[H]));
515
- const C = w(`${y.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
510
+ let v = -1;
511
+ const p = w(`${(m = F == null ? void 0 : F[0]) == null ? void 0 : m.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
512
+ for (const y of F) {
513
+ for (const L in y)
514
+ !isNaN(y[L]) && Number(y[L]) !== 1 / 0 && (y[L] = Number(y[L]));
515
+ const S = w(`${y.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
516
516
  y.status = y.sp > 4 ? 0 : 1;
517
- const { labelEn: M, labelCn: j } = this.parseStatus(y.status), P = {
517
+ const { labelEn: M, labelCn: j } = this.parseStatus(y.status), N = {
518
518
  mmsi: y.m,
519
519
  name: y.n,
520
520
  imo: r == null ? void 0 : r.imo,
@@ -524,20 +524,20 @@ class Ft extends at {
524
524
  sog: y.sp,
525
525
  cog: y.co,
526
526
  hdg: y.hdg,
527
- positionTime: C.unix(),
528
- utc: C.utc().format(),
527
+ positionTime: S.unix(),
528
+ utc: S.utc().format(),
529
529
  status: y.status,
530
530
  labelCn: j,
531
531
  labelEn: M,
532
532
  method: "trajectory",
533
533
  vendor: "hifleet"
534
- }, D = Math.floor(C.diff(v, "minute", !0) / (n || 1));
535
- D !== p && (p = D, I.push(P));
534
+ }, D = Math.floor(S.diff(p, "minute", !0) / (n || 1));
535
+ D !== v && (v = D, I.push(N));
536
536
  }
537
537
  return I;
538
538
  }
539
539
  }
540
- class Nt extends at {
540
+ class xt extends at {
541
541
  constructor(t) {
542
542
  super();
543
543
  U(this, "token");
@@ -550,7 +550,7 @@ class Nt extends at {
550
550
  k: this.token,
551
551
  enc: 1
552
552
  }
553
- }, n = "https://api.shipxy.com/apicall/GetSingleShip", i = await B.get(n, o).json();
553
+ }, n = "https://api.shipxy.com/apicall/GetSingleShip", i = await z.get(n, o).json();
554
554
  if (g == null || g.info("[%s] fetch realtime position from: %s - %j", a.requestId, n, o), (i == null ? void 0 : i.status) !== 0)
555
555
  return i;
556
556
  const s = i.data[0];
@@ -581,7 +581,7 @@ class Nt extends at {
581
581
  };
582
582
  }
583
583
  async trajectory(t, a, o, n, i = !0, s = {}) {
584
- var v;
584
+ var p;
585
585
  const r = await this.realTimePosition(t, s), l = w(a), u = w(o), c = "https://api.shipxy.com/apicall/GetShipTrack", h = {
586
586
  searchParams: {
587
587
  id: t,
@@ -591,11 +591,11 @@ class Nt extends at {
591
591
  btm: l.unix(),
592
592
  etm: u.unix()
593
593
  }
594
- }, k = await B.get(c, h).json();
594
+ }, k = await z.get(c, h).json();
595
595
  if (g == null || g.info("[%s] fetch trajectory from: %s - %j", s.requestId, c, h), (k == null ? void 0 : k.status) !== 0)
596
596
  return k;
597
- const b = k == null ? void 0 : k.points, S = [], I = w.unix((v = b[0]) == null ? void 0 : v.utc);
598
- let p = -1;
597
+ const b = k == null ? void 0 : k.points, F = [], I = w.unix((p = b[0]) == null ? void 0 : p.utc);
598
+ let v = -1;
599
599
  for (const f of b) {
600
600
  const d = w.unix(f.utc), m = {
601
601
  imo: r == null ? void 0 : r.imo,
@@ -609,12 +609,12 @@ class Nt extends at {
609
609
  method: "trajectory",
610
610
  vendor: "shipxy"
611
611
  }, y = Math.floor(d.diff(I, "minute", !0) / (n || 1));
612
- y !== p && (p = y, S.push(m));
612
+ y !== v && (v = y, F.push(m));
613
613
  }
614
- return S;
614
+ return F;
615
615
  }
616
616
  }
617
- class xt extends at {
617
+ class Nt extends at {
618
618
  constructor(t) {
619
619
  super();
620
620
  U(this, "token");
@@ -628,7 +628,7 @@ class xt extends at {
628
628
  json: {
629
629
  mmsiList: t
630
630
  }
631
- }, n = "https://api3.myships.com/sp/ships/getShipIdByMMSI", i = await B.post(n, o).json();
631
+ }, n = "https://api3.myships.com/sp/ships/getShipIdByMMSI", i = await z.post(n, o).json();
632
632
  return g == null || g.info("[%s] fetch ship id from: %s - %j", a.requestId, n, o), i.code !== "0" ? i : i.data[0].shipId;
633
633
  }
634
634
  async getShipInfo(t, a = {}) {
@@ -639,7 +639,7 @@ class xt extends at {
639
639
  json: {
640
640
  shipId: t
641
641
  }
642
- }, n = "https://api3.myships.com/sp/ships/aissta", i = await B.post(n, o).json();
642
+ }, n = "https://api3.myships.com/sp/ships/aissta", i = await z.post(n, o).json();
643
643
  if (g == null || g.info("[%s] fetch ship info from: %s - %j", a.requestId, n, o), i.code !== "0")
644
644
  return i;
645
645
  const s = i.data;
@@ -662,7 +662,7 @@ class xt extends at {
662
662
  json: {
663
663
  shipId: o
664
664
  }
665
- }, s = "https://api3.myships.com/sp/ships/position/latest", r = await B.post(s, i).json();
665
+ }, s = "https://api3.myships.com/sp/ships/position/latest", r = await z.post(s, i).json();
666
666
  g == null || g.info("[%s] fetch realtime position from: %s - %j", a.requestId, s, i);
667
667
  const l = r.data[0];
668
668
  for (const b in l)
@@ -703,37 +703,37 @@ class xt extends at {
703
703
  startTime: a,
704
704
  endTime: o
705
705
  }
706
- }, c = "https://api3.myships.com/sp/ships/position/history", h = await B.post(c, u).json();
706
+ }, c = "https://api3.myships.com/sp/ships/position/history", h = await z.post(c, u).json();
707
707
  if (g == null || g.info("[%s] fetch trajectory from: %s - %j", l.requestId, c, u), h.code !== "0")
708
708
  return g == null || g.warn("[%s] invoke myship trajectory failed: %j", l.requestId, h), h;
709
709
  const k = h.data;
710
- for (const p in k)
711
- !isNaN(k[p]) && Number(k[p]) !== 1 / 0 && (k[p] = Number(k[p]));
710
+ for (const v in k)
711
+ !isNaN(k[v]) && Number(k[v]) !== 1 / 0 && (k[v] = Number(k[v]));
712
712
  const b = w.unix((I = k[0]) == null ? void 0 : I.posTime);
713
- let S = -1;
714
- for (const p of k) {
715
- const v = w.unix(p.posTime), f = {
713
+ let F = -1;
714
+ for (const v of k) {
715
+ const p = w.unix(v.posTime), f = {
716
716
  imo: n == null ? void 0 : n.imo,
717
717
  mmsi: i,
718
- lat: Math.round(p.lat / 1e4 / 60 * 1e5) / 1e5,
719
- lng: Math.round(p.lon / 1e4 / 60 * 1e5) / 1e5,
720
- sog: Math.round(p.sog / 10 * 100) / 100,
721
- cog: Math.round(p.cog / 10 * 100) / 100,
722
- hdg: Math.round(p.heading * 100) / 100,
723
- rot: Math.round(p.rot * 100) / 100,
724
- positionTime: v.unix(),
725
- utc: v.utc().format(),
718
+ lat: Math.round(v.lat / 1e4 / 60 * 1e5) / 1e5,
719
+ lng: Math.round(v.lon / 1e4 / 60 * 1e5) / 1e5,
720
+ sog: Math.round(v.sog / 10 * 100) / 100,
721
+ cog: Math.round(v.cog / 10 * 100) / 100,
722
+ hdg: Math.round(v.heading * 100) / 100,
723
+ rot: Math.round(v.rot * 100) / 100,
724
+ positionTime: p.unix(),
725
+ utc: p.utc().format(),
726
726
  method: "trajectory",
727
727
  vendor: "myship"
728
- }, d = Math.floor(v.diff(b, "minute", !0) / (s || 1));
729
- d !== S && (S = d, r.push(f));
728
+ }, d = Math.floor(p.diff(b, "minute", !0) / (s || 1));
729
+ d !== F && (F = d, r.push(f));
730
730
  }
731
731
  return r;
732
732
  }
733
733
  }
734
- let J;
734
+ let K;
735
735
  try {
736
- J = dt.getLogger("vessel");
736
+ K = dt.getLogger("vessel");
737
737
  } catch {
738
738
  } finally {
739
739
  }
@@ -749,7 +749,7 @@ class Mt {
749
749
  */
750
750
  parsePrinciple(e, t = {}) {
751
751
  var s, r, l;
752
- J == null || J.debug("[%s] parse rule: %s", t.requestId, e);
752
+ K == null || K.debug("[%s] parse rule: %s", t.requestId, e);
753
753
  const a = new RegExp("(?<=\\[)(.+)(?=])", "g"), o = e.match(a) ? (s = e.match(a)) == null ? void 0 : s[0] : void 0, n = o == null ? void 0 : o.split(";");
754
754
  if (!n)
755
755
  return;
@@ -774,7 +774,7 @@ class Mt {
774
774
  */
775
775
  parseRule(e, t = {}) {
776
776
  var i;
777
- J == null || J.debug("[%s] parse rule: %s", t.requestId, e), e = e.startsWith("[") ? e : `[${e}`, e = e.endsWith("]") ? e : `${e}]`;
777
+ K == null || K.debug("[%s] parse rule: %s", t.requestId, e), e = e.startsWith("[") ? e : `[${e}`, e = e.endsWith("]") ? e : `${e}]`;
778
778
  const a = new RegExp("(?<=\\[)(.+?)(?=])", "g"), o = (i = e == null ? void 0 : e.match(a)) == null ? void 0 : i[0], n = o == null ? void 0 : o.split(",");
779
779
  if (n) {
780
780
  let s = n[3] === "Number.MAX_VALUE" ? 100 : Number(n[3]);
@@ -794,12 +794,12 @@ class Mt {
794
794
  * @param options
795
795
  */
796
796
  checkWeather(e, t, a = {}) {
797
- var b, S, I, p, v, f, d, m, y, C, M, j, P, D, H;
797
+ var b, F, I, v, p, f, d, m, y, S, M, j, N, D, L;
798
798
  let o = 0, n = 0, i = 0, s = 0;
799
- const r = Math.round(((S = (b = t == null ? void 0 : t.SEVERE) == null ? void 0 : b.sigWave) == null ? void 0 : S.number) * 1.6 * 100) / 100, l = (p = (I = t == null ? void 0 : t.SEVERE) == null ? void 0 : I.sigWave) == null ? void 0 : p.number, u = (f = (v = t == null ? void 0 : t.HEAVY) == null ? void 0 : v.sigWave) == null ? void 0 : f.number, c = Math.round((((m = (d = t == null ? void 0 : t.SEVERE) == null ? void 0 : d.wind) == null ? void 0 : m.number) + 2) * 100) / 100, h = (C = (y = t == null ? void 0 : t.SEVERE) == null ? void 0 : y.wind) == null ? void 0 : C.number, k = (j = (M = t == null ? void 0 : t.HEAVY) == null ? void 0 : M.wind) == null ? void 0 : j.number;
800
- for (let F = 0; F < (e == null ? void 0 : e.length); F++) {
801
- const N = e[F], R = (D = (P = N == null ? void 0 : N.meteo) == null ? void 0 : P.wave) == null ? void 0 : D.sig, W = (H = N == null ? void 0 : N.meteo) == null ? void 0 : H.wind, K = F ? w(N.eta).diff(w(e[F - 1].eta), "hour", !0) : 0;
802
- s = K > s ? K : s, J == null || J.debug("[%s] check sig.wave: %j", a.requestId, { ...R, dgThd4Wv: r, svThd4Wv: l, hvThd4Wv: u }), (R == null ? void 0 : R.height) >= r ? N.isDangerous = !0 : (R == null ? void 0 : R.height) >= l ? N.isSevere = !0 : (R == null ? void 0 : R.height) >= u && (N.isHeavy = !0), J == null || J.debug("[%s] check wind: %j", a.requestId, { ...W, dgThd4Wd: c, svThd4Wd: h, hvThd4Wd: k }), (W == null ? void 0 : W.scale) >= c ? (N.isDangerous = !0, delete N.isSevere, delete N.isHeavy) : (W == null ? void 0 : W.scale) > h ? (N.isDangerous || (N.isSevere = !0), delete N.isHeavy) : (W == null ? void 0 : W.scale) === k && !N.isDangerous && !N.isSevere && (N.isHeavy = !0), o += N.isDangerous ? K : 0, n += N.isSevere ? K : 0, i += N.isHeavy ? K : 0;
799
+ const r = Math.round(((F = (b = t == null ? void 0 : t.SEVERE) == null ? void 0 : b.sigWave) == null ? void 0 : F.number) * 1.6 * 100) / 100, l = (v = (I = t == null ? void 0 : t.SEVERE) == null ? void 0 : I.sigWave) == null ? void 0 : v.number, u = (f = (p = t == null ? void 0 : t.HEAVY) == null ? void 0 : p.sigWave) == null ? void 0 : f.number, c = Math.round((((m = (d = t == null ? void 0 : t.SEVERE) == null ? void 0 : d.wind) == null ? void 0 : m.number) + 2) * 100) / 100, h = (S = (y = t == null ? void 0 : t.SEVERE) == null ? void 0 : y.wind) == null ? void 0 : S.number, k = (j = (M = t == null ? void 0 : t.HEAVY) == null ? void 0 : M.wind) == null ? void 0 : j.number;
800
+ for (let W = 0; W < (e == null ? void 0 : e.length); W++) {
801
+ const C = e[W], Y = (D = (N = C == null ? void 0 : C.meteo) == null ? void 0 : N.wave) == null ? void 0 : D.sig, A = (L = C == null ? void 0 : C.meteo) == null ? void 0 : L.wind, V = W ? w(C.eta).diff(w(e[W - 1].eta), "hour", !0) : 0;
802
+ s = V > s ? V : s, K == null || K.debug("[%s] check sig.wave: %j", a.requestId, { ...Y, dgThd4Wv: r, svThd4Wv: l, hvThd4Wv: u }), (Y == null ? void 0 : Y.height) >= r ? C.isDangerous = !0 : (Y == null ? void 0 : Y.height) >= l ? C.isSevere = !0 : (Y == null ? void 0 : Y.height) >= u && (C.isHeavy = !0), K == null || K.debug("[%s] check wind: %j", a.requestId, { ...A, dgThd4Wd: c, svThd4Wd: h, hvThd4Wd: k }), (A == null ? void 0 : A.scale) >= c ? (C.isDangerous = !0, delete C.isSevere, delete C.isHeavy) : (A == null ? void 0 : A.scale) > h ? (C.isDangerous || (C.isSevere = !0), delete C.isHeavy) : (A == null ? void 0 : A.scale) === k && !C.isDangerous && !C.isSevere && (C.isHeavy = !0), o += C.isDangerous ? V : 0, n += C.isSevere ? V : 0, i += C.isHeavy ? V : 0;
803
803
  }
804
804
  return o = Math.round(o * 100) / 100, n = Math.round(n * 100) / 100, i = Math.round(i * 100) / 100, s = Math.round(s), { sample: e, dangerous: o, severe: n, heavy: i, step: s < 3 ? 3 : s, wind: { dgThd4Wd: c, svThd4Wd: h, hvThd4Wd: k }, sig: { dgThd4Wv: r, svThd4Wv: l, hvThd4Wv: u } };
805
805
  }
@@ -813,7 +813,7 @@ try {
813
813
  }
814
814
  const gt = new ft("", !0);
815
815
  var bt = /* @__PURE__ */ ((x) => (x.common = "common", x.container = "container", x.tugs = "tugs", x))(bt || {}), pt = /* @__PURE__ */ ((x) => (x.Ballast = "Ballast", x.Laden = "Laden", x))(pt || {}), vt = /* @__PURE__ */ ((x) => (x.Cp = "CP", x.Perf = "Basis", x.Instruct = "Other", x))(vt || {});
816
- class Y {
816
+ class H {
817
817
  /**
818
818
  * @see https://baike.baidu.com/item/%E6%96%B9%E5%BD%A2%E7%B3%BB%E6%95%B0/4965568?fr=aladdin
819
819
  * 方形系数(block coefficient)
@@ -955,22 +955,22 @@ class Y {
955
955
  */
956
956
  static async speedLoseAt(e, t, a, o = "", n = 2, i = !0, s = !1, r = {}) {
957
957
  let l;
958
- if (t.velocity && s && (e.speed = z.roundPrecision(t.velocity * 1852 / 3600, 6)), i) {
958
+ if (t.velocity && s && (e.speed = J.roundPrecision(t.velocity * 1852 / 3600, 6)), i) {
959
959
  let u;
960
960
  try {
961
961
  o = (o == null ? void 0 : o.toUpperCase()) === "CMEMS" ? "ECMWF" : o, o = (o == null ? void 0 : o.toUpperCase()) === "METEO2" ? "best_match" : o;
962
- const { weatherModels: S, marineModels: I } = await ct.autoPickMeteoModel(o), p = await gt.spotForecast(t.lat, t.lng, a.utc().format(), !1, !1, !0, {
962
+ const { weatherModels: F, marineModels: I } = await ct.autoPickMeteoModel(o), v = await gt.spotForecast(t.lat, t.lng, a.utc().format(), !1, !1, !0, {
963
963
  ...r,
964
964
  pastDays: 1,
965
965
  forecastDays: 1,
966
- weatherModels: S,
966
+ weatherModels: F,
967
967
  marineModels: I
968
- }), [v] = ct.pickHourly(p, a);
969
- u = ct.toLegacy(v);
970
- } catch (S) {
971
- E.warn("[%s] meteo2 spot(%j) forecast failed: %s", r.requestId, { ...t, eta: a.utc().format(), source: o }, S);
968
+ }), [p] = ct.pickHourly(v, a);
969
+ u = ct.toLegacy(p);
970
+ } catch (F) {
971
+ E.warn("[%s] meteo2 spot(%j) forecast failed: %s", r.requestId, { ...t, eta: a.utc().format(), source: o }, F);
972
972
  }
973
- let c = Y.currentFactor(e.bearing, u == null ? void 0 : u.current, n), h = Y.weatherFactor(e, u, c);
973
+ let c = H.currentFactor(e.bearing, u == null ? void 0 : u.current, n), h = H.weatherFactor(e, u, c);
974
974
  const k = e.speed * 1.943844;
975
975
  k + c + h <= 0 && (E.warn(
976
976
  "[%s] v0(%d) is less then factor(%d) = wxFactor(%d) + cFactor(%d), scale factor with 0.6",
@@ -1016,50 +1016,50 @@ class Y {
1016
1016
  static async speedLoseInHoursStep(e, t, a, o, n, i, s = "", r = !0, l = !1, u = {}) {
1017
1017
  t.utc();
1018
1018
  const c = t.clone().add(14, "days"), h = [], k = [], b = [];
1019
- let S = 0, I = 0, p, v;
1019
+ let F = 0, I = 0, v, p;
1020
1020
  for (let f = 0; f < i.length - 1; f++) {
1021
1021
  let d = i[f];
1022
1022
  d.distanceFromStart = Math.round((n + I) * 1e3) / 1e3;
1023
1023
  const m = i[f + 1];
1024
- if (e.bearing = O.calculateBearing(d, m, !m.gcToPrevious), d.bearing = e.bearing, d.suspend && l) {
1024
+ if (e.bearing = R.calculateBearing(d, m, !m.gcToPrevious), d.bearing = e.bearing, d.suspend && l) {
1025
1025
  d.eta = d.eta || t.utc().format(), d.elapsed = d.elapsed ?? 0;
1026
1026
  const M = d.suspend - d.elapsed;
1027
- if (o - S > M)
1028
- o = o - S - M, t.add(M, "hour"), d.elapsed = d.suspend;
1027
+ if (o - F > M)
1028
+ o = o - F - M, t.add(M, "hour"), d.elapsed = d.suspend;
1029
1029
  else {
1030
- const j = o - S;
1030
+ const j = o - F;
1031
1031
  d.elapsed += j, t.add(j, "hour"), o = 0;
1032
1032
  }
1033
1033
  if (E == null || E.info(`[%s] suspend ${d.elapsed} hours at %j, and remain ${o} hours need to go...`, u.requestId, d), o === 0)
1034
- return d.distanceFromPrevious = I, { etd: t, from: v || d, to: d, next: i.filter((j) => j), wps: h, days: k, all: b };
1034
+ return d.distanceFromPrevious = I, { etd: t, from: p || d, to: d, next: i.filter((j) => j), wps: h, days: k, all: b };
1035
1035
  } else
1036
1036
  d.suspend = 0;
1037
- r = t.isAfter(c) ? !1 : r, d = await Y.speedLoseAt(e, d, t, s, 0, r, l, u), b.push(d), v = v || d, d.important && h.push(d), t.isSameOrAfter(a) && (k.push(d), a.add(24, "hour"));
1038
- const y = O.calculateDistance(d, m, !m.gcToPrevious);
1039
- let C = Math.round(y / v.speed * 1e5) / 1e5;
1040
- if (S + C < o) {
1041
- if (S += C, t.add(C, "hour"), delete i[f], E == null || E.debug(
1042
- `[%s] go to %j from %j with ${y}nm, and cost ${C} hours`,
1037
+ r = t.isAfter(c) ? !1 : r, d = await H.speedLoseAt(e, d, t, s, 0, r, l, u), b.push(d), p = p || d, d.important && h.push(d), t.isSameOrAfter(a) && (k.push(d), a.add(24, "hour"));
1038
+ const y = R.calculateDistance(d, m, !m.gcToPrevious);
1039
+ let S = Math.round(y / p.speed * 1e5) / 1e5;
1040
+ if (F + S < o) {
1041
+ if (F += S, t.add(S, "hour"), delete i[f], E == null || E.debug(
1042
+ `[%s] go to %j from %j with ${y}nm, and cost ${S} hours`,
1043
1043
  u.requestId,
1044
1044
  { lat: m.lat, lng: m.lng },
1045
- { lat: v.lat, lng: v.lng, etd: v.etd }
1045
+ { lat: p.lat, lng: p.lng, etd: p.etd }
1046
1046
  ), I += y, i.filter((M) => M).length <= 1) {
1047
- p = m, p.eta = t.utc().format(), p.distanceFromPrevious = y, p.distanceFromStart = Math.round((n + I) * 1e4) / 1e4, h.push(p), b.push(p), delete i[f + 1];
1047
+ v = m, v.eta = t.utc().format(), v.distanceFromPrevious = y, v.distanceFromStart = Math.round((n + I) * 1e4) / 1e4, h.push(v), b.push(v), delete i[f + 1];
1048
1048
  break;
1049
1049
  }
1050
1050
  } else {
1051
- C = o - S, t.add(C, "hour");
1052
- const M = z.roundPrecision(v.speed * C, 5);
1053
- p = O.calculateCoordinate(d, e.bearing, M, "nauticalmiles", !m.gcToPrevious), p.eta = t.utc().format(), i[f] = p, E == null || E.debug(
1054
- `[%s] go to %j from %j with ${M}nm, and cost ${C} hours`,
1051
+ S = o - F, t.add(S, "hour");
1052
+ const M = J.roundPrecision(p.speed * S, 5);
1053
+ v = R.calculateCoordinate(d, e.bearing, M, "nauticalmiles", !m.gcToPrevious), v.eta = t.utc().format(), i[f] = v, E == null || E.debug(
1054
+ `[%s] go to %j from %j with ${M}nm, and cost ${S} hours`,
1055
1055
  u.requestId,
1056
- { lat: p.lat, lng: p.lng },
1056
+ { lat: v.lat, lng: v.lng },
1057
1057
  { lat: d.lat, lng: d.lng, etd: d.etd }
1058
- ), I += M, p.distanceFromPrevious = Math.round(I * 1e4) / 1e4, p.distanceFromStart = Math.round((n + I) * 1e4) / 1e4;
1058
+ ), I += M, v.distanceFromPrevious = Math.round(I * 1e4) / 1e4, v.distanceFromStart = Math.round((n + I) * 1e4) / 1e4;
1059
1059
  break;
1060
1060
  }
1061
1061
  }
1062
- return { etd: t, from: v, to: p, next: i.filter((f) => f), wps: h, days: k, all: b };
1062
+ return { etd: t, from: p, to: v, next: i.filter((f) => f), wps: h, days: k, all: b };
1063
1063
  }
1064
1064
  /**
1065
1065
  * 洋流影响因子
@@ -1068,7 +1068,7 @@ class Y {
1068
1068
  * @param role 1: 船东, 2: 租家, 0: 未知
1069
1069
  */
1070
1070
  static currentFactor(e, t, a = 0) {
1071
- const o = O.includedAngle(e, (t == null ? void 0 : t.degree) || 0) / 180 * Math.PI;
1071
+ const o = R.includedAngle(e, (t == null ? void 0 : t.degree) || 0) / 180 * Math.PI;
1072
1072
  if (Math.abs(o) === Math.PI / 2)
1073
1073
  return 0;
1074
1074
  let n = ((t == null ? void 0 : t.kts) || 0) * Math.cos(o);
@@ -1081,14 +1081,14 @@ class Y {
1081
1081
  * @param cFactor 洋流因子
1082
1082
  */
1083
1083
  static weatherFactor(e, t, a = 0) {
1084
- var k, b, S, I, p, v, f;
1084
+ var k, b, F, I, v, p, f;
1085
1085
  E == null || E.debug("calculate weather factor via: %j", { ...e, ...t });
1086
- const o = Y.blockCoefficient(e.displacement, e.lbp, e.breadthMoulded, e.draught), n = z.roundPrecision(a * 1852 / 3600, 6), i = Y.froudeNumber(e.speed - n, e.lbp), s = Y.amendFactor(o, i, e.loadCondition);
1087
- let r = O.includedAngle(e.bearing, (k = t == null ? void 0 : t.wind) == null ? void 0 : k.degree);
1088
- const l = Y.directionFactor(r, (b = t == null ? void 0 : t.wind) == null ? void 0 : b.scale), u = Y.vesselTagFactor(e.displacement, e.loadCondition, e.tag, (S = t == null ? void 0 : t.wind) == null ? void 0 : S.kts);
1086
+ const o = H.blockCoefficient(e.displacement, e.lbp, e.breadthMoulded, e.draught), n = J.roundPrecision(a * 1852 / 3600, 6), i = H.froudeNumber(e.speed - n, e.lbp), s = H.amendFactor(o, i, e.loadCondition);
1087
+ let r = R.includedAngle(e.bearing, (k = t == null ? void 0 : t.wind) == null ? void 0 : k.degree);
1088
+ const l = H.directionFactor(r, (b = t == null ? void 0 : t.wind) == null ? void 0 : b.scale), u = H.vesselTagFactor(e.displacement, e.loadCondition, e.tag, (F = t == null ? void 0 : t.wind) == null ? void 0 : F.kts);
1089
1089
  let c = l * s * u / 100 * (e.speed - n);
1090
- c = Math.round(c * 1.943844 * 1e4) / 1e4 * -1, e.tag === "tugs" && Math.abs(c) > 1 && (c = c / (Math.abs(Math.round(c)) + 1)), E == null || E.debug("wind wx factor = %d", c), r = O.includedAngle(e.bearing, (p = (I = t == null ? void 0 : t.wave) == null ? void 0 : I.sig) == null ? void 0 : p.degree);
1091
- const h = Y.waveHeightFactor(((f = (v = t == null ? void 0 : t.wave) == null ? void 0 : v.sig) == null ? void 0 : f.height) ?? 1, r);
1090
+ c = Math.round(c * 1.943844 * 1e4) / 1e4 * -1, e.tag === "tugs" && Math.abs(c) > 1 && (c = c / (Math.abs(Math.round(c)) + 1)), E == null || E.debug("wind wx factor = %d", c), r = R.includedAngle(e.bearing, (v = (I = t == null ? void 0 : t.wave) == null ? void 0 : I.sig) == null ? void 0 : v.degree);
1091
+ const h = H.waveHeightFactor(((f = (p = t == null ? void 0 : t.wave) == null ? void 0 : p.sig) == null ? void 0 : f.height) ?? 1, r);
1092
1092
  return E == null || E.debug("wave wx factor = %d", h), c = Math.abs(c) > Math.abs(h) ? c : c * 0.3 + h * 0.7, E == null || E.debug("weather factor = %d", c), c = Math.abs(c) > 3 ? 3 * (Math.abs(c) / c) + Math.abs(c) / c * (Math.abs(c) - 2) * 0.1 : c, Math.round((c || 0) * 100) / 100;
1093
1093
  }
1094
1094
  /**
@@ -1123,11 +1123,11 @@ class Y {
1123
1123
  static async analyseInstant(e, t, a, o, n, i = "", s = 0, r = !0, l = !1, u = {}) {
1124
1124
  var _, G, X, Q, Z, $;
1125
1125
  const c = w().valueOf();
1126
- e.lng = z.convertToStdLng(e.lng);
1127
- const { route: h, waypoints: k } = n.points, b = O.calculateSubRoute(e, h);
1126
+ e.lng = J.convertToStdLng(e.lng);
1127
+ const { route: h, waypoints: k } = n.points, b = R.calculateSubRoute(e, h);
1128
1128
  if (((_ = b[0]) == null ? void 0 : _.length) <= 1)
1129
1129
  return;
1130
- const { v0: S, label: I } = e.sog ? {
1130
+ const { v0: F, label: I } = e.sog ? {
1131
1131
  v0: e.sog,
1132
1132
  label: e.label || "Other"
1133
1133
  /* Instruct */
@@ -1135,13 +1135,13 @@ class Y {
1135
1135
  v0: o.speed,
1136
1136
  label: "CP"
1137
1137
  /* Cp */
1138
- }, p = Y.assembleProperties(a, o.loadCondition, S, 0), v = k.length ? O.calculateSubWaypoints(e, k) : [];
1139
- v.forEach((A) => A.important = !0);
1138
+ }, v = H.assembleProperties(a, o.loadCondition, F, 0), p = k.length ? R.calculateSubWaypoints(e, k) : [];
1139
+ p.forEach((P) => P.important = !0);
1140
1140
  const f = {
1141
1141
  from: { ...e },
1142
1142
  route: b,
1143
- waypoints: v,
1144
- v0: S,
1143
+ waypoints: p,
1144
+ v0: F,
1145
1145
  label: I
1146
1146
  }, d = {
1147
1147
  hours: [],
@@ -1149,16 +1149,16 @@ class Y {
1149
1149
  wps: [],
1150
1150
  all: []
1151
1151
  };
1152
- s || (O.calculateRouteDistance(b) / o.speed <= 72 ? s = 3 : s = 6);
1153
- let m = O.simplifyRouteToCoordinates(b, v, 0), y = 0, C = 0, M = 0, j = 0;
1152
+ s || (R.calculateRouteDistance(b) / o.speed <= 72 ? s = 3 : s = 6);
1153
+ let m = R.simplifyRouteToCoordinates(b, p, 0), y = 0, S = 0, M = 0, j = 0;
1154
1154
  t = w(t).utc();
1155
- const P = t.clone();
1155
+ const N = t.clone();
1156
1156
  for (; m.length > 0; ) {
1157
- const A = s - t.hour() % s, V = Math.ceil(t.clone().add(A, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4, T = await Y.speedLoseInHoursStep(
1158
- p,
1157
+ const P = s - t.hour() % s, B = Math.ceil(t.clone().add(P, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4, T = await H.speedLoseInHoursStep(
1158
+ v,
1159
1159
  t,
1160
- P,
1161
- V,
1160
+ N,
1161
+ B,
1162
1162
  y,
1163
1163
  m,
1164
1164
  i,
@@ -1167,34 +1167,34 @@ class Y {
1167
1167
  u
1168
1168
  );
1169
1169
  if (d.all.push(...T.all), (G = T.from) != null && G.speed && (d.hours.push(T.from), d.wps.push(...T.wps), d.days.push(...T.days)), m = T == null ? void 0 : T.next, !m.length) {
1170
- const L = await Y.speedLoseAt(p, T.to, w(T.to.eta), i, 0, r, l, u);
1171
- L.bearing = p.bearing, d.hours.push(L), d.all.push(L);
1170
+ const O = await H.speedLoseAt(v, T.to, w(T.to.eta), i, 0, r, l, u);
1171
+ O.bearing = v.bearing, d.hours.push(O), d.all.push(O);
1172
1172
  }
1173
1173
  y += Math.round((((X = T == null ? void 0 : T.to) == null ? void 0 : X.distanceFromPrevious) ?? 0) * 1e4) / 1e4;
1174
1174
  }
1175
1175
  const D = d.hours;
1176
- for (let A = 0; A < D.length - 1; A++) {
1177
- const V = w(D[A + 1].eta).diff(D[A].etd, "hour", !0) || 1;
1178
- C += (D[A].wxFactor || 0) * V, M += (D[A].cFactor || 0) * V, j += V;
1176
+ for (let P = 0; P < D.length - 1; P++) {
1177
+ const B = w(D[P + 1].eta).diff(D[P].etd, "hour", !0) || 1;
1178
+ S += (D[P].wxFactor || 0) * B, M += (D[P].cFactor || 0) * B, j += B;
1179
1179
  }
1180
- const H = D.reduce((A, V) => A + (V.suspend || 0), 0);
1181
- (Q = d.wps) == null || Q.forEach((A, V) => {
1182
- A.positionTime = w.utc(A.etd || A.eta).unix();
1183
- const T = d.wps[V - 1];
1180
+ const L = D.reduce((P, B) => P + (B.suspend || 0), 0);
1181
+ (Q = d.wps) == null || Q.forEach((P, B) => {
1182
+ P.positionTime = w.utc(P.etd || P.eta).unix();
1183
+ const T = d.wps[B - 1];
1184
1184
  if (T) {
1185
- const L = A.distanceFromStart - T.distanceFromStart, q = w(A.eta || A.etd).diff(w(T.etd || T.eta), "h", !0);
1186
- A.avgSpd = Math.round(L / q * 100) / 100, T.bearing = O.calculateBearing(T, A);
1185
+ const O = P.distanceFromStart - T.distanceFromStart, q = w(P.eta || P.etd).diff(w(T.etd || T.eta), "h", !0);
1186
+ P.avgSpd = Math.round(O / q * 100) / 100, T.bearing = R.calculateBearing(T, P);
1187
1187
  }
1188
- }), d.wps = await Y.reduceWPS(d.wps), d.days = await Y.reduceDays(d.days), d.all = (Z = d.all) == null ? void 0 : Z.reduce((A, V) => (V.positionTime = w.utc(V.etd || V.eta).unix(), A.some((T) => Math.round(T.positionTime / 60) === Math.round(V.positionTime / 60)) || A.push(V), A), []), f.sample = d;
1189
- const F = d.hours.at(0), N = d.hours.at(-1);
1190
- f.distance = Math.round(N.distanceFromStart * 1e3) / 1e3, f.etd = w(F.eta).utc().format(), f.eta = w(N.eta).utc().format(), f.wxFactor = Math.round(C / j * 1e3) / 1e3, f.cFactor = Math.round(M / j * 1e3) / 1e3, f.avgSpeed = Math.round(N.distanceFromStart / j * 1e3) / 1e3, f.totalHrs = Math.round(j * 1e3) / 1e3, f.suspend = Math.round(H * 1e3) / 1e3;
1191
- const R = z.roundPrecision(o.dgo / 24 * H, 3), { distanceInECA: W, hoursInECA: K, totalDgoConsInECA: nt, eca: tt } = await this.calculateECA(f, o, u), et = z.roundPrecision(o.fo / 24 * (j - K), 3), ot = z.roundPrecision(o.dgo / 24 * j + R, 3);
1188
+ }), d.wps = await H.reduceWPS(d.wps), d.days = await H.reduceDays(d.days), d.all = (Z = d.all) == null ? void 0 : Z.reduce((P, B) => (B.positionTime = w.utc(B.etd || B.eta).unix(), P.some((T) => Math.round(T.positionTime / 60) === Math.round(B.positionTime / 60)) || P.push(B), P), []), f.sample = d;
1189
+ const W = d.hours.at(0), C = d.hours.at(-1);
1190
+ f.distance = Math.round(C.distanceFromStart * 1e3) / 1e3, f.etd = w(W.eta).utc().format(), f.eta = w(C.eta).utc().format(), f.wxFactor = Math.round(S / j * 1e3) / 1e3, f.cFactor = Math.round(M / j * 1e3) / 1e3, f.avgSpeed = Math.round(C.distanceFromStart / j * 1e3) / 1e3, f.totalHrs = Math.round(j * 1e3) / 1e3, f.suspend = Math.round(L * 1e3) / 1e3;
1191
+ const Y = J.roundPrecision(o.dgo / 24 * L, 3), { distanceInECA: A, hoursInECA: V, totalDgoConsInECA: nt, eca: tt } = await this.calculateECA(f, o, u), et = J.roundPrecision(o.fo / 24 * (j - V), 3), ot = J.roundPrecision(o.dgo / 24 * j + Y, 3);
1192
1192
  f.extend = {
1193
1193
  eca: tt,
1194
- distanceInECA: W,
1195
- hoursInECA: K,
1194
+ distanceInECA: A,
1195
+ hoursInECA: V,
1196
1196
  totalDgoConsInECA: nt,
1197
- totalDgoConsInSuspend: R
1197
+ totalDgoConsInSuspend: Y
1198
1198
  }, f.totalFoCons = et < 0 ? 0 : et, f.totalDgoCons = ot;
1199
1199
  const st = w().valueOf() - c, rt = (($ = d == null ? void 0 : d.hours) == null ? void 0 : $.length) || 1;
1200
1200
  return E == null || E.info("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", u == null ? void 0 : u.requestId, st, rt, Math.round(st / rt * 1e3) / 1e3), f;
@@ -1215,10 +1215,10 @@ class Y {
1215
1215
  * @param options
1216
1216
  */
1217
1217
  static async analyseInstantWithThreshed(e, t, a, o, n, i, s, r = "", l = 3, u = !0, c = !1, h = {}) {
1218
- var X, Q, Z, $, A, V;
1218
+ var X, Q, Z, $, P, B;
1219
1219
  const k = w().valueOf();
1220
- e.lng = z.convertToStdLng(e.lng);
1221
- const { v0: b, label: S } = e.sog ? {
1220
+ e.lng = J.convertToStdLng(e.lng);
1221
+ const { v0: b, label: F } = e.sog ? {
1222
1222
  v0: e.sog,
1223
1223
  label: e.label || "Other"
1224
1224
  /* Instruct */
@@ -1226,12 +1226,12 @@ class Y {
1226
1226
  v0: n.speed,
1227
1227
  label: "CP"
1228
1228
  /* Cp */
1229
- }, I = Y.assembleProperties(o, n.loadCondition, b, 0), p = O.calculateSubRoute(e, i);
1230
- if (((X = p[0]) == null ? void 0 : X.length) <= 1)
1229
+ }, I = H.assembleProperties(o, n.loadCondition, b, 0), v = R.calculateSubRoute(e, i);
1230
+ if (((X = v[0]) == null ? void 0 : X.length) <= 1)
1231
1231
  return;
1232
- const v = s.length ? O.calculateSubWaypoints(e, s) : [];
1233
- v.forEach((T) => T.important = !0);
1234
- let f = O.simplifyRouteToCoordinates(p, v, 0), d = 0, m = 0, y = 0, C = 0;
1232
+ const p = s.length ? R.calculateSubWaypoints(e, s) : [];
1233
+ p.forEach((T) => T.important = !0);
1234
+ let f = R.simplifyRouteToCoordinates(v, p, 0), d = 0, m = 0, y = 0, S = 0;
1235
1235
  const M = {
1236
1236
  hours: [],
1237
1237
  wps: [],
@@ -1242,51 +1242,51 @@ class Y {
1242
1242
  const j = t.clone();
1243
1243
  for (; f.length > 0; ) {
1244
1244
  const T = l - t.hour() % l;
1245
- let L = Math.ceil(t.clone().add(T, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4;
1246
- L = t.clone().add(L, "h").isSameOrAfter(a) ? a.diff(t, "h", !0) * 1e4 / 1e4 : L;
1247
- const q = await Y.speedLoseInHoursStep(I, t, j, L, d, f, r, u, c, h);
1248
- if (M.all.push(...q.all), (Q = q.from) != null && Q.speed && (M.hours.push(q.from), q != null && q.wps && M.wps.push(...q.wps), M.days.push(...q.days)), f = q == null ? void 0 : q.next, f.length || M.hours.push(q == null ? void 0 : q.to), d += Math.round((((Z = q == null ? void 0 : q.to) == null ? void 0 : Z.distanceFromPrevious) ?? 0) * 1e4) / 1e4, !L)
1245
+ let O = Math.ceil(t.clone().add(T, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4;
1246
+ O = t.clone().add(O, "h").isSameOrAfter(a) ? a.diff(t, "h", !0) * 1e4 / 1e4 : O;
1247
+ const q = await H.speedLoseInHoursStep(I, t, j, O, d, f, r, u, c, h);
1248
+ if (M.all.push(...q.all), (Q = q.from) != null && Q.speed && (M.hours.push(q.from), q != null && q.wps && M.wps.push(...q.wps), M.days.push(...q.days)), f = q == null ? void 0 : q.next, f.length || M.hours.push(q == null ? void 0 : q.to), d += Math.round((((Z = q == null ? void 0 : q.to) == null ? void 0 : Z.distanceFromPrevious) ?? 0) * 1e4) / 1e4, !O)
1249
1249
  break;
1250
1250
  }
1251
- M.wps = await Y.reduceWPS(M.wps), M.days = await Y.reduceDays(M.days), M.all = ($ = M.all) == null ? void 0 : $.reduce((T, L) => (L.positionTime = w.utc(L.etd || L.eta).unix(), T.some((q) => Math.round(w(q.etd).unix() / 60) === Math.round(w(L.etd).unix() / 60)) || T.push(L), T), []), (A = M.wps) == null || A.forEach((T, L) => {
1252
- const q = M.wps[L - 1];
1251
+ M.wps = await H.reduceWPS(M.wps), M.days = await H.reduceDays(M.days), M.all = ($ = M.all) == null ? void 0 : $.reduce((T, O) => (O.positionTime = w.utc(O.etd || O.eta).unix(), T.some((q) => Math.round(w(q.etd).unix() / 60) === Math.round(w(O.etd).unix() / 60)) || T.push(O), T), []), (P = M.wps) == null || P.forEach((T, O) => {
1252
+ const q = M.wps[O - 1];
1253
1253
  if (q) {
1254
1254
  const ut = T.distanceFromStart - q.distanceFromStart, lt = w(T.eta || T.etd).diff(w(q.etd || q.eta), "h", !0);
1255
- q.bearing = O.calculateBearing(q, T), T.avgSpd = Math.round(ut / lt * 100) / 100;
1255
+ q.bearing = R.calculateBearing(q, T), T.avgSpd = Math.round(ut / lt * 100) / 100;
1256
1256
  }
1257
1257
  });
1258
- const P = M.hours;
1259
- for (let T = 0; T < P.length - 1; T++) {
1260
- const L = w(P[T + 1].eta).diff(P[T].etd, "hour", !0);
1261
- m += P[T].wxFactor * L, y += P[T].cFactor * L, C += L;
1258
+ const N = M.hours;
1259
+ for (let T = 0; T < N.length - 1; T++) {
1260
+ const O = w(N[T + 1].eta).diff(N[T].etd, "hour", !0);
1261
+ m += N[T].wxFactor * O, y += N[T].cFactor * O, S += O;
1262
1262
  }
1263
- const D = P.reduce((T, L) => T + (L.suspend || 0), 0), H = M.hours.at(0), F = M.hours.at(-1), N = await O.calculateRangeRoute(H, F, p), R = await O.calculateRangeWaypoints(H, F, p, v), W = {
1263
+ const D = N.reduce((T, O) => T + (O.suspend || 0), 0), L = M.hours.at(0), W = M.hours.at(-1), C = await R.calculateRangeRoute(L, W, v), Y = await R.calculateRangeWaypoints(L, W, v, p), A = {
1264
1264
  sample: M,
1265
- distance: Math.round(((F == null ? void 0 : F.distanceFromStart) || 0) * 1e4) / 1e4,
1265
+ distance: Math.round(((W == null ? void 0 : W.distanceFromStart) || 0) * 1e4) / 1e4,
1266
1266
  // 注意,可能会在first节点Drift,所有采用eta做为初始出发时间
1267
- etd: w(H.eta).utc().format(),
1268
- eta: w(F == null ? void 0 : F.eta).utc().format(),
1269
- wxFactor: Math.round(m / C * 1e3) / 1e3,
1270
- cFactor: Math.round(y / C * 1e3) / 1e3,
1271
- avgSpeed: Math.round(((F == null ? void 0 : F.distanceFromStart) || 0) / C * 1e3) / 1e3,
1272
- totalHrs: Math.round(C * 1e3) / 1e3,
1267
+ etd: w(L.eta).utc().format(),
1268
+ eta: w(W == null ? void 0 : W.eta).utc().format(),
1269
+ wxFactor: Math.round(m / S * 1e3) / 1e3,
1270
+ cFactor: Math.round(y / S * 1e3) / 1e3,
1271
+ avgSpeed: Math.round(((W == null ? void 0 : W.distanceFromStart) || 0) / S * 1e3) / 1e3,
1272
+ totalHrs: Math.round(S * 1e3) / 1e3,
1273
1273
  suspend: Math.round(D * 1e3) / 1e3,
1274
- from: H,
1275
- to: F,
1276
- route: N,
1277
- waypoints: R,
1274
+ from: L,
1275
+ to: W,
1276
+ route: C,
1277
+ waypoints: Y,
1278
1278
  v0: b,
1279
- label: S
1280
- }, K = z.roundPrecision(n.dgo / 24 * D, 3), { distanceInECA: nt, hoursInECA: tt, totalDgoConsInECA: et, eca: ot } = await this.calculateECA(W, n, h), it = z.roundPrecision(n.fo / 24 * (C - tt), 3), st = z.roundPrecision(n.dgo / 24 * C + K, 3);
1281
- W.extend = {
1279
+ label: F
1280
+ }, V = J.roundPrecision(n.dgo / 24 * D, 3), { distanceInECA: nt, hoursInECA: tt, totalDgoConsInECA: et, eca: ot } = await this.calculateECA(A, n, h), it = J.roundPrecision(n.fo / 24 * (S - tt), 3), st = J.roundPrecision(n.dgo / 24 * S + V, 3);
1281
+ A.extend = {
1282
1282
  eca: ot,
1283
1283
  distanceInECA: nt,
1284
1284
  hoursInECA: tt,
1285
1285
  totalDgoConsInECA: et,
1286
- totalDgoConsInSuspend: K
1287
- }, W.totalDgoCons = st, W.totalFoCons = it < 0 ? 0 : it;
1288
- const _ = w().valueOf() - k, G = ((V = M == null ? void 0 : M.hours) == null ? void 0 : V.length) || 1;
1289
- return E == null || E.debug("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", h == null ? void 0 : h.requestId, _, G, Math.round(_ / G * 1e3) / 1e3), W;
1286
+ totalDgoConsInSuspend: V
1287
+ }, A.totalDgoCons = st, A.totalFoCons = it < 0 ? 0 : it;
1288
+ const _ = w().valueOf() - k, G = ((B = M == null ? void 0 : M.hours) == null ? void 0 : B.length) || 1;
1289
+ return E == null || E.debug("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", h == null ? void 0 : h.requestId, _, G, Math.round(_ / G * 1e3) / 1e3), A;
1290
1290
  }
1291
1291
  /**
1292
1292
  * 在指定航线条件下,基于多CP,动态计算最优成本(租金+油费)方案
@@ -1304,10 +1304,10 @@ class Y {
1304
1304
  * @param options
1305
1305
  */
1306
1306
  static async analyseCost(e, t, a, o, n = {}) {
1307
- var p, v;
1307
+ var v, p;
1308
1308
  const i = w().valueOf(), s = [];
1309
1309
  e.speedStep = e.speedStep || 3, e.alterStep = e.alterStep ?? 1;
1310
- const r = O.calculateRouteDistance(o.route);
1310
+ const r = R.calculateRouteDistance(o.route);
1311
1311
  let l = 0;
1312
1312
  a.forEach((f) => {
1313
1313
  const d = Math.ceil(r / f.speed / 24);
@@ -1316,7 +1316,7 @@ class Y {
1316
1316
  const u = w.utc(e.etd).add(l ?? 14, "day");
1317
1317
  let c = 1;
1318
1318
  for (const f of a) {
1319
- const d = JSON.parse(JSON.stringify(o.route)), m = JSON.parse(JSON.stringify(o.waypoints)), y = await Y.analyseInstantWithThreshed(
1319
+ const d = JSON.parse(JSON.stringify(o.route)), m = JSON.parse(JSON.stringify(o.waypoints)), y = await H.analyseInstantWithThreshed(
1320
1320
  { lat: e.lat, lng: e.lng },
1321
1321
  e.etd,
1322
1322
  u,
@@ -1330,7 +1330,7 @@ class Y {
1330
1330
  e.useRouteParam,
1331
1331
  n
1332
1332
  );
1333
- y && (await Y.calculateCost(y, f, e, n), s.push(y), E == null || E.info("[%s][L%d-%d] analyse from %s to %s cost: %j", n.requestId, 1, c, e.etd, u.format(), {
1333
+ y && (await H.calculateCost(y, f, e, n), s.push(y), E == null || E.info("[%s][L%d-%d] analyse from %s to %s cost: %j", n.requestId, 1, c, e.etd, u.format(), {
1334
1334
  cost: y.cost.total,
1335
1335
  hire: y.cost.hire,
1336
1336
  bunker: y.cost.bunker,
@@ -1341,18 +1341,18 @@ class Y {
1341
1341
  }
1342
1342
  s.sort((f, d) => f.cost.total - d.cost.total);
1343
1343
  const h = s.at(0), k = s.at(1), b = [];
1344
- if (b.push({ combined: !1, speeds: [h], cost: (p = h.cost) == null ? void 0 : p.total }), k) {
1345
- const f = h.cost.cp, d = k.cost.cp, m = w(h.eta), y = w(h.etd), C = m.diff(y, "days", !0);
1346
- let M = Math.ceil(C / 2);
1344
+ if (b.push({ combined: !1, speeds: [h], cost: (v = h.cost) == null ? void 0 : v.total }), k) {
1345
+ const f = h.cost.cp, d = k.cost.cp, m = w(h.eta), y = w(h.etd), S = m.diff(y, "days", !0);
1346
+ let M = Math.ceil(S / 2);
1347
1347
  M = M > 7 ? 7 : M < e.alterStep ? e.alterStep : M;
1348
- let j = 2, P = { combined: !1, speeds: [k], cost: (v = k.cost) == null ? void 0 : v.total }, D;
1348
+ let j = 2, N = { combined: !1, speeds: [k], cost: (p = k.cost) == null ? void 0 : p.total }, D;
1349
1349
  for (; M >= e.alterStep; ) {
1350
- const H = await Y.combinedAnalyse(e, t, u, [f, d], o, M, { ...n, level: j });
1351
- if (P.cost > H.cost ? D ? (D == null ? void 0 : D.cost) > H.cost && (D = H) : (D = P, P = H) : (!D || (D == null ? void 0 : D.cost) > H.cost) && (D = H), M <= e.alterStep)
1350
+ const L = await H.combinedAnalyse(e, t, u, [f, d], o, M, { ...n, level: j });
1351
+ if (N.cost > L.cost ? D ? (D == null ? void 0 : D.cost) > L.cost && (D = L) : (D = N, N = L) : (!D || (D == null ? void 0 : D.cost) > L.cost) && (D = L), M <= e.alterStep)
1352
1352
  break;
1353
1353
  M = Math.ceil(M / 2), j += 1;
1354
1354
  }
1355
- b.push(P), D && b.push(D);
1355
+ b.push(N), D && b.push(D);
1356
1356
  }
1357
1357
  const I = w().valueOf() - i;
1358
1358
  return E == null || E.info("[%s] analyse elapsed: %d ms", n == null ? void 0 : n.requestId, I), b.sort((f, d) => f.cost - d.cost);
@@ -1369,7 +1369,7 @@ class Y {
1369
1369
  */
1370
1370
  static async combinedAnalyse(e, t, a, o, n, i, s = {}) {
1371
1371
  s.counter = 1, E == null || E.info("[%s][L%d] analyse with alternate cp in every %d days", s.requestId, s.level, i);
1372
- const r = await Y.alternateAnalyse(e, t, a, o, 0, n, i, s), l = r.reduce((d, m) => d + m.cost.total, 0), u = r.reduce((d, m) => d + m.cost.hire, 0), c = r.reduce((d, m) => d + m.cost.bunker, 0), h = r.reduce((d, m) => d + m.distance, 0), k = r.reduce((d, m) => d + m.totalHrs, 0);
1372
+ const r = await H.alternateAnalyse(e, t, a, o, 0, n, i, s), l = r.reduce((d, m) => d + m.cost.total, 0), u = r.reduce((d, m) => d + m.cost.hire, 0), c = r.reduce((d, m) => d + m.cost.bunker, 0), h = r.reduce((d, m) => d + m.distance, 0), k = r.reduce((d, m) => d + m.totalHrs, 0);
1373
1373
  E == null || E.info("[%s][L%d] cost with cpa/cpb turn: %j", s.requestId, s.level, {
1374
1374
  cost: l,
1375
1375
  hire: u,
@@ -1377,14 +1377,14 @@ class Y {
1377
1377
  distance: h,
1378
1378
  hours: k
1379
1379
  });
1380
- const b = await Y.alternateAnalyse(e, t, a, o, 1, n, i, s), S = b.reduce((d, m) => d + m.cost.total, 0), I = b.reduce((d, m) => d + m.cost.hire, 0), p = b.reduce((d, m) => d + m.cost.bunker, 0), v = b.reduce((d, m) => d + m.distance, 0), f = b.reduce((d, m) => d + m.totalHrs, 0);
1380
+ const b = await H.alternateAnalyse(e, t, a, o, 1, n, i, s), F = b.reduce((d, m) => d + m.cost.total, 0), I = b.reduce((d, m) => d + m.cost.hire, 0), v = b.reduce((d, m) => d + m.cost.bunker, 0), p = b.reduce((d, m) => d + m.distance, 0), f = b.reduce((d, m) => d + m.totalHrs, 0);
1381
1381
  return E == null || E.info("[%s][L%d] cost with cpb/cpa turn: %j", s.requestId, s.level, {
1382
- cost: S,
1382
+ cost: F,
1383
1383
  hire: I,
1384
- bunker: p,
1385
- distance: v,
1384
+ bunker: v,
1385
+ distance: p,
1386
1386
  hours: f
1387
- }), l < S ? { combined: !0, cost: Math.round(l * 1e3) / 1e3, speeds: r, step: i } : { combined: !0, cost: Math.round(S * 1e3) / 1e3, speeds: b, step: i };
1387
+ }), l < F ? { combined: !0, cost: Math.round(l * 1e3) / 1e3, speeds: r, step: i } : { combined: !0, cost: Math.round(F * 1e3) / 1e3, speeds: b, step: i };
1388
1388
  }
1389
1389
  /**
1390
1390
  * 基于cp索引,交替计算指定步长下的成本
@@ -1402,13 +1402,13 @@ class Y {
1402
1402
  let l = w.utc(e.etd);
1403
1403
  const u = { lat: e.lat, lng: e.lng }, c = [];
1404
1404
  for (; l.isBefore(a); ) {
1405
- const b = l.clone().utc().add(s, "day"), S = JSON.parse(JSON.stringify(i.route)), I = JSON.parse(JSON.stringify(i.waypoints)), p = o[n], v = await Y.analyseInstantWithThreshed(
1405
+ const b = l.clone().utc().add(s, "day"), F = JSON.parse(JSON.stringify(i.route)), I = JSON.parse(JSON.stringify(i.waypoints)), v = o[n], p = await H.analyseInstantWithThreshed(
1406
1406
  u,
1407
1407
  l.utc().format(),
1408
1408
  b,
1409
1409
  t,
1410
- p,
1411
- S,
1410
+ v,
1411
+ F,
1412
1412
  I,
1413
1413
  e.meteoVendor,
1414
1414
  e.speedStep,
@@ -1416,7 +1416,7 @@ class Y {
1416
1416
  e.useRouteParam,
1417
1417
  r
1418
1418
  );
1419
- v && (await Y.calculateCost(v, p, e, r), E == null || E.info(
1419
+ p && (await H.calculateCost(p, v, e, r), E == null || E.info(
1420
1420
  "[%s][L%d-%d] analyse from %s to %s cost: %j",
1421
1421
  r.requestId,
1422
1422
  r.level,
@@ -1424,17 +1424,17 @@ class Y {
1424
1424
  l.utc().format(),
1425
1425
  b.utc().format(),
1426
1426
  {
1427
- cost: v.cost.total,
1428
- hire: v.cost.hire,
1429
- bunker: v.cost.bunker,
1430
- distance: v.distance,
1431
- hours: v.totalHrs,
1432
- cp: `${p.speed}/${p.fo}/${p.dgo}`
1427
+ cost: p.cost.total,
1428
+ hire: p.cost.hire,
1429
+ bunker: p.cost.bunker,
1430
+ distance: p.distance,
1431
+ hours: p.totalHrs,
1432
+ cp: `${v.speed}/${v.fo}/${v.dgo}`
1433
1433
  }
1434
1434
  )), r.counter = r.counter + 1;
1435
- const f = (k = (h = v == null ? void 0 : v.sample) == null ? void 0 : h.hours) == null ? void 0 : k.at(-1);
1435
+ const f = (k = (h = p == null ? void 0 : p.sample) == null ? void 0 : h.hours) == null ? void 0 : k.at(-1);
1436
1436
  if (f)
1437
- u.lat = f.lat, u.lng = f.lng, l = w(f.eta), c.push(v), n = n ? 0 : 1;
1437
+ u.lat = f.lat, u.lng = f.lng, l = w(f.eta), c.push(p), n = n ? 0 : 1;
1438
1438
  else
1439
1439
  break;
1440
1440
  }
@@ -1467,17 +1467,17 @@ class Y {
1467
1467
  */
1468
1468
  static async calculateECA(e, t, a = {}) {
1469
1469
  var r, l, u, c;
1470
- const o = await O.intersectInECA((e == null ? void 0 : e.route) || []);
1470
+ const o = await R.intersectInECA((e == null ? void 0 : e.route) || []);
1471
1471
  let n = 0, i = 0, s = 0;
1472
1472
  (l = (r = e == null ? void 0 : e.sample) == null ? void 0 : r.wps) == null || l.forEach((h) => {
1473
1473
  h.positionTime = w.utc(h.etd || h.eta).unix();
1474
1474
  });
1475
1475
  for (const h of o) {
1476
1476
  n += h.distance;
1477
- const k = await O.deadReckoningTime((u = h.waypoints) == null ? void 0 : u.at(0), e.sample.all || e.sample.wps), b = await O.deadReckoningTime((c = h.waypoints) == null ? void 0 : c.at(-1), e.sample.all || e.sample.wps);
1478
- h.in = k, h.out = b, h.totalHrs = z.roundPrecision((b.positionTime - k.positionTime) / 3600, 3), h.totalDgoCons = z.roundPrecision(t.fo / 24 * h.totalHrs, 3), i += h.totalHrs, s += h.totalDgoCons;
1477
+ const k = await R.deadReckoningTime((u = h.waypoints) == null ? void 0 : u.at(0), e.sample.all || e.sample.wps), b = await R.deadReckoningTime((c = h.waypoints) == null ? void 0 : c.at(-1), e.sample.all || e.sample.wps);
1478
+ h.in = k, h.out = b, h.totalHrs = J.roundPrecision((b.positionTime - k.positionTime) / 3600, 3), h.totalDgoCons = J.roundPrecision(t.fo / 24 * h.totalHrs, 3), i += h.totalHrs, s += h.totalDgoCons;
1479
1479
  }
1480
- return n = z.roundPrecision(n, 3), i = z.roundPrecision(i, 3), s = z.roundPrecision(s, 3), {
1480
+ return n = J.roundPrecision(n, 3), i = J.roundPrecision(i, 3), s = J.roundPrecision(s, 3), {
1481
1481
  distanceInECA: n,
1482
1482
  hoursInECA: i,
1483
1483
  totalDgoConsInECA: s,
@@ -1494,49 +1494,55 @@ class Y {
1494
1494
  const a = {
1495
1495
  hours: [],
1496
1496
  wps: [],
1497
- days: []
1497
+ days: [],
1498
+ all: []
1498
1499
  }, o = e.reduce((m, y) => m + y.distance, 0), n = e.reduce((m, y) => {
1499
- var C;
1500
- return m + (((C = y.extend) == null ? void 0 : C.distanceInECA) || 0);
1500
+ var S;
1501
+ return m + (((S = y.extend) == null ? void 0 : S.distanceInECA) || 0);
1501
1502
  }, 0), i = e.reduce((m, y) => m + y.totalHrs, 0), s = e.reduce((m, y) => {
1502
- var C;
1503
- return m + (((C = y.extend) == null ? void 0 : C.hoursInECA) || 0);
1503
+ var S;
1504
+ return m + (((S = y.extend) == null ? void 0 : S.hoursInECA) || 0);
1504
1505
  }, 0), r = e.reduce((m, y) => {
1505
- var C;
1506
- return m + (((C = y.extend) == null ? void 0 : C.totalDgoConsInECA) || 0);
1507
- }, 0), l = e.reduce((m, y) => m + y.wxFactor * y.totalHrs / i, 0), u = e.reduce((m, y) => m + y.cFactor * y.totalHrs / i, 0), c = e.reduce((m, y) => m + y.totalFoCons, 0), h = e.reduce((m, y) => m + y.totalDgoCons, 0), k = e.reduce((m, y) => m + y.cost.total, 0), b = e.reduce((m, y) => m + y.cost.hire, 0), S = e.reduce((m, y) => m + y.cost.bunker, 0), I = [], p = [];
1508
- let v;
1506
+ var S;
1507
+ return m + (((S = y.extend) == null ? void 0 : S.totalDgoConsInECA) || 0);
1508
+ }, 0), l = e.reduce((m, y) => m + y.wxFactor * y.totalHrs / i, 0), u = e.reduce((m, y) => m + y.cFactor * y.totalHrs / i, 0), c = e.reduce((m, y) => m + y.totalFoCons, 0), h = e.reduce((m, y) => m + y.totalDgoCons, 0), k = e.reduce((m, y) => m + y.cost.total, 0), b = e.reduce((m, y) => m + y.cost.hire, 0), F = e.reduce((m, y) => m + y.cost.bunker, 0), I = [], v = [];
1509
+ let p;
1509
1510
  for (const m of e) {
1510
- p.push(...((f = m.extend) == null ? void 0 : f.eca) || []);
1511
- const y = m.sample.hours, C = m.sample.wps, M = m.sample.days, j = y.at(0);
1512
- v && (j.distanceFromPrevious = v.distanceFromPrevious, j.distanceFromStart = v.distanceFromStart, y.forEach((F, N) => {
1513
- N && (F.distanceFromStart = F.distanceFromStart + v.distanceFromStart);
1514
- }), C.at(0).distanceFromPrevious = v.distanceFromPrevious, C.at(0).distanceFromStart = v.distanceFromStart, C.forEach((F, N) => {
1515
- N && (F.distanceFromStart = F.distanceFromStart + v.distanceFromStart);
1516
- }), M.at(0).distanceFromPrevious = v.distanceFromPrevious, M.at(0).distanceFromStart = v.distanceFromStart, M.forEach((F, N) => {
1517
- N && (F.distanceFromStart = F.distanceFromStart + v.distanceFromStart);
1518
- })), j.cp = m.cost.cp;
1519
- const P = [m.etd, m.eta], D = I.findIndex((F) => F.id === j.cp.id);
1520
- D === -1 ? (j.cp.segment = [P], I.push(j.cp)) : I[D].segment.push(P), y.forEach((F) => {
1521
- var R;
1522
- ((R = a.hours) == null ? void 0 : R.findIndex((W) => W.eta === F.eta)) === -1 && a.hours.push(F);
1523
- }), C.forEach((F) => {
1524
- var R;
1525
- ((R = a.wps) == null ? void 0 : R.findIndex((W) => W.eta === F.eta)) === -1 && a.wps.push(F);
1526
- }), M.forEach((F) => {
1527
- var R;
1528
- ((R = a == null ? void 0 : a.days) == null ? void 0 : R.findIndex((W) => W.eta === F.eta)) === -1 && a.days.push(F);
1511
+ v.push(...((f = m.extend) == null ? void 0 : f.eca) || []);
1512
+ const y = m.sample.hours, S = m.sample.all, M = m.sample.wps, j = m.sample.days, N = y.at(0);
1513
+ p && (N.distanceFromPrevious = p.distanceFromPrevious, N.distanceFromStart = p.distanceFromStart, y.forEach((C, Y) => {
1514
+ Y && (C.distanceFromStart = C.distanceFromStart + p.distanceFromStart);
1515
+ }), S.at(0).distanceFromPrevious = p.distanceFromPrevious, S.at(0).distanceFromStart = p.distanceFromStart, S.forEach((C, Y) => {
1516
+ Y && (C.distanceFromStart = C.distanceFromStart + p.distanceFromStart);
1517
+ }), M.at(0).distanceFromPrevious = p.distanceFromPrevious, M.at(0).distanceFromStart = p.distanceFromStart, M.forEach((C, Y) => {
1518
+ Y && (C.distanceFromStart = C.distanceFromStart + p.distanceFromStart);
1519
+ }), j.at(0).distanceFromPrevious = p.distanceFromPrevious, j.at(0).distanceFromStart = p.distanceFromStart, j.forEach((C, Y) => {
1520
+ Y && (C.distanceFromStart = C.distanceFromStart + p.distanceFromStart);
1521
+ })), N.cp = m.cost.cp;
1522
+ const D = [m.etd, m.eta], L = I.findIndex((C) => C.id === N.cp.id);
1523
+ L === -1 ? (N.cp.segment = [D], I.push(N.cp)) : I[L].segment.push(D), y.forEach((C) => {
1524
+ var A;
1525
+ ((A = a.hours) == null ? void 0 : A.findIndex((V) => V.eta === C.eta)) === -1 && a.hours.push(C);
1526
+ }), S.forEach((C) => {
1527
+ var A;
1528
+ ((A = a.all) == null ? void 0 : A.findIndex((V) => V.eta === C.eta)) === -1 && a.all.push(C);
1529
+ }), M.forEach((C) => {
1530
+ var A;
1531
+ ((A = a.wps) == null ? void 0 : A.findIndex((V) => V.eta === C.eta)) === -1 && a.wps.push(C);
1532
+ }), j.forEach((C) => {
1533
+ var A;
1534
+ ((A = a == null ? void 0 : a.days) == null ? void 0 : A.findIndex((V) => V.eta === C.eta)) === -1 && a.days.push(C);
1529
1535
  });
1530
- const H = (d = a.wps) == null ? void 0 : d.findIndex((F) => F.eta === j.eta);
1531
- H === -1 ? a.wps.push(j) : a.wps[H] = j, v = y.at(-1);
1536
+ const W = (d = a.wps) == null ? void 0 : d.findIndex((C) => C.eta === N.eta);
1537
+ W === -1 ? a.wps.push(N) : a.wps[W] = N, p = y.at(-1);
1532
1538
  }
1533
1539
  return a.wps.sort((m, y) => w(m.etd).unix() - w(y.etd).unix()), a.wps.forEach((m, y) => {
1534
- const C = a.wps[y - 1];
1535
- if (C) {
1536
- const M = m.distanceFromStart - (C.distanceFromStart || 0), j = w(m.eta || m.etd).diff(w(C.etd || C.eta), "hour", !0), P = Math.round(M / j * 100) / 100;
1537
- m.avgSpd = P;
1538
- const D = O.calculateBearing(C, m);
1539
- C.bearing = D;
1540
+ const S = a.wps[y - 1];
1541
+ if (S) {
1542
+ const M = m.distanceFromStart - (S.distanceFromStart || 0), j = w(m.eta || m.etd).diff(w(S.etd || S.eta), "hour", !0), N = Math.round(M / j * 100) / 100;
1543
+ m.avgSpd = N;
1544
+ const D = R.calculateBearing(S, m);
1545
+ S.bearing = D;
1540
1546
  }
1541
1547
  }), {
1542
1548
  sample: a,
@@ -1556,11 +1562,11 @@ class Y {
1556
1562
  cost: {
1557
1563
  total: Math.round(k * 1e3) / 1e3,
1558
1564
  hire: Math.round(b * 1e3) / 1e3,
1559
- bunker: Math.round(S * 1e3) / 1e3
1565
+ bunker: Math.round(F * 1e3) / 1e3
1560
1566
  },
1561
1567
  extend: {
1562
1568
  cps: I,
1563
- eca: p,
1569
+ eca: v,
1564
1570
  distanceInECA: Math.round(n * 1e3) / 1e3,
1565
1571
  hoursInECA: Math.round(s * 1e3) / 1e3,
1566
1572
  totalDgoConsInECA: Math.round(r * 1e3) / 1e3,
@@ -1573,12 +1579,12 @@ export {
1573
1579
  at as AISImpl,
1574
1580
  Mt as AlertHelper,
1575
1581
  yt as AlertLevel,
1576
- Ft as HifleetImpl,
1582
+ jt as HifleetImpl,
1577
1583
  pt as LoadCondition,
1578
- xt as MyShipImpl,
1579
- jt as MyVesselImpl,
1580
- Nt as ShipxyImpl,
1581
- Y as SpeedHelper,
1584
+ Nt as MyShipImpl,
1585
+ Tt as MyVesselImpl,
1586
+ xt as ShipxyImpl,
1587
+ H as SpeedHelper,
1582
1588
  vt as SpeedLabel,
1583
1589
  bt as VesselTag,
1584
1590
  Dt as alertHelper