@idm-plugin/vessel 3.4.7 → 3.4.8

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,26 +1,26 @@
1
- var ft = Object.defineProperty;
2
- var yt = (D, s, t) => s in D ? ft(D, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : D[s] = t;
3
- var K = (D, s, t) => (yt(D, typeof s != "symbol" ? s + "" : s, t), t);
1
+ var lt = Object.defineProperty;
2
+ var mt = (x, e, t) => e in x ? lt(x, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : x[e] = t;
3
+ var U = (x, e, t) => (mt(x, typeof e != "symbol" ? e + "" : e, t), t);
4
4
  import B from "got";
5
- import ht from "@log4js-node/log4js-api";
5
+ import dt from "@log4js-node/log4js-api";
6
6
  import v from "moment";
7
- import { LaneHelper as V, LngLatHelper as z } from "@idm-plugin/geo2";
8
- import { MeteoHelper2 as Mt } from "@idm-plugin/meteo2";
9
- import { Meteo2Assist as ut } from "@idm-plugin/meteo";
7
+ import { LaneHelper as W, LngLatHelper as z } from "@idm-plugin/geo2";
8
+ import { MeteoHelper2 as ft } from "@idm-plugin/meteo2";
9
+ import { Meteo2Assist as ct } from "@idm-plugin/meteo";
10
10
  let M;
11
11
  try {
12
- M = ht.getLogger("vessel");
12
+ M = dt.getLogger("vessel");
13
13
  } catch {
14
14
  } finally {
15
15
  }
16
- class ot {
16
+ class at {
17
17
  /**
18
18
  * 解析AIS状态码
19
19
  * @param status
20
20
  */
21
- parseStatus(s) {
21
+ parseStatus(e) {
22
22
  let t, a;
23
- switch (s) {
23
+ switch (e) {
24
24
  case 0:
25
25
  t = "在航(主机推动)", a = "Underway Using Engine";
26
26
  break;
@@ -54,12 +54,12 @@ class ot {
54
54
  return { labelCn: t, labelEn: a };
55
55
  }
56
56
  }
57
- class Nt extends ot {
57
+ class Tt extends at {
58
58
  constructor(t, a) {
59
59
  super();
60
- K(this, "clientId");
61
- K(this, "clientSecret");
62
- K(this, "token");
60
+ U(this, "clientId");
61
+ U(this, "clientSecret");
62
+ U(this, "token");
63
63
  this.clientId = t, this.clientSecret = a;
64
64
  }
65
65
  async authToken(t = {}) {
@@ -89,11 +89,11 @@ class Nt extends ot {
89
89
  * @param options
90
90
  */
91
91
  async suggest(t, a = {}) {
92
- var e, r;
92
+ var s, r;
93
93
  await this.checkToken(a);
94
94
  const i = "https://market.myvessel.cn/sdc/v1/mkt/vessels/fuzzy", n = {
95
95
  headers: {
96
- Authorization: `${(e = this.token) == null ? void 0 : e.tokenType} ${(r = this.token) == null ? void 0 : r.accessToken}`
96
+ Authorization: `${(s = this.token) == null ? void 0 : s.tokenType} ${(r = this.token) == null ? void 0 : r.accessToken}`
97
97
  },
98
98
  json: {
99
99
  kw: t,
@@ -122,14 +122,14 @@ class Nt extends ot {
122
122
  async search(t, a = {}) {
123
123
  var h, l;
124
124
  await this.checkToken(a);
125
- const i = /^\d{7}$/.test(t.toString()), n = i ? "https://market.myvessel.cn/sdc/v1/mkt/vessels/detail/imo" : "https://market.myvessel.cn/sdc/v1/mkt/vessels/detail/mmsi", o = i ? { imo: t } : { mmsi: t }, e = {
125
+ const i = /^\d{7}$/.test(t.toString()), n = i ? "https://market.myvessel.cn/sdc/v1/mkt/vessels/detail/imo" : "https://market.myvessel.cn/sdc/v1/mkt/vessels/detail/mmsi", o = i ? { imo: t } : { mmsi: t }, s = {
126
126
  headers: {
127
127
  Authorization: `${(h = this.token) == null ? void 0 : h.tokenType} ${(l = this.token) == null ? void 0 : l.accessToken}`
128
128
  },
129
129
  searchParams: o
130
130
  };
131
- M == null || M.info("[%s] fetch vessel from: %s - %j", a.requestId, n, e);
132
- const r = await B.get(n, e).json();
131
+ M == null || M.info("[%s] fetch vessel from: %s - %j", a.requestId, n, s);
132
+ const r = await B.get(n, s).json();
133
133
  if (r.status !== 200)
134
134
  return M == null || M.warn("[%s] fetch suggest vessels failed: %j", a.requestId, { message: r.message, status: r.status, code: r.code }), {};
135
135
  {
@@ -162,11 +162,11 @@ class Nt extends ot {
162
162
  return {};
163
163
  }
164
164
  async archives(t, a = {}) {
165
- var e, r;
165
+ var s, r;
166
166
  await this.checkToken(a);
167
167
  const i = "https://svc.data.myvessel.cn/sdc/v1/ship/info/batch", n = {
168
168
  headers: {
169
- Authorization: `${(e = this.token) == null ? void 0 : e.tokenType} ${(r = this.token) == null ? void 0 : r.accessToken}`
169
+ Authorization: `${(s = this.token) == null ? void 0 : s.tokenType} ${(r = this.token) == null ? void 0 : r.accessToken}`
170
170
  },
171
171
  json: {
172
172
  mmsiList: typeof t == "number" ? [t] : t
@@ -189,38 +189,38 @@ class Nt extends ot {
189
189
  const o = await B.get(i, n).json();
190
190
  if (o.code)
191
191
  return M == null || M.warn("[%s] fetch realtime position failed: %j", a.requestId, { message: o.message, status: o.status, code: o.code }), o;
192
- const e = o.data;
193
- for (const l in e)
194
- !isNaN(e[l]) && Number(e[l]) !== 1 / 0 && (e[l] = Number(e[l]));
195
- if (e) {
196
- const l = v(`${e.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
192
+ const s = o.data;
193
+ for (const l in s)
194
+ !isNaN(s[l]) && Number(s[l]) !== 1 / 0 && (s[l] = Number(s[l]));
195
+ if (s) {
196
+ const l = v(`${s.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
197
197
  return {
198
- mmsi: e.mmsi,
199
- name: e.vesselName || e.aisVesselName,
200
- imo: e.imo,
201
- callSign: e.callsign || e.aisCallSign,
202
- lat: e.lat,
203
- lng: e.lon,
204
- length: e.length,
205
- width: e.width,
206
- draught: e.currDraught,
207
- sog: e.sog,
208
- cog: e.cog,
209
- hdg: e.hdg,
210
- rot: e.rot,
211
- eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(e.eta) ? v.utc(e.eta).format() : void 0,
212
- destination: e.dest,
198
+ mmsi: s.mmsi,
199
+ name: s.vesselName || s.aisVesselName,
200
+ imo: s.imo,
201
+ callSign: s.callsign || s.aisCallSign,
202
+ lat: s.lat,
203
+ lng: s.lon,
204
+ length: s.length,
205
+ width: s.width,
206
+ draught: s.currDraught,
207
+ sog: s.sog,
208
+ cog: s.cog,
209
+ hdg: s.hdg,
210
+ rot: s.rot,
211
+ eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(s.eta) ? v.utc(s.eta).format() : void 0,
212
+ destination: s.dest,
213
213
  positionTime: l.unix(),
214
- status: e.status,
215
- labelCn: e.statusNameCn,
216
- labelEn: e.statusNameEn,
217
- vesselType: e.vesselTypeNameEn,
218
- flag: e.flagCtryNameEn,
219
- clasz: e.classSociety,
220
- build: e.buildYear,
221
- dwt: e.dwt,
222
- grt: e.grt,
223
- net: e.net,
214
+ status: s.status,
215
+ labelCn: s.statusNameCn,
216
+ labelEn: s.statusNameEn,
217
+ vesselType: s.vesselTypeNameEn,
218
+ flag: s.flagCtryNameEn,
219
+ clasz: s.classSociety,
220
+ build: s.buildYear,
221
+ dwt: s.dwt,
222
+ grt: s.grt,
223
+ net: s.net,
224
224
  method: "position",
225
225
  vendor: "myVessel",
226
226
  utc: l.utc().format()
@@ -236,10 +236,10 @@ class Nt extends ot {
236
236
  * @param excludeSeas 排除水域, [sea.code]
237
237
  * @param options { requiretId: '请求ID', useAIModel: '启用AI算法', withECA: '是否计算低硫区航行距离', withSpecial: '是否计算穿越的特战区列表和海盗区列表', draught: '最大吃水' }
238
238
  */
239
- async calculateRoute(t, a, i, n, o, e = {}) {
239
+ async calculateRoute(t, a, i, n, o, s = {}) {
240
240
  var y, w, g;
241
241
  const r = v();
242
- await this.checkToken(e);
242
+ await this.checkToken(s);
243
243
  const h = "https://svc.data.myvessel.cn/sdc/v1/routes/routing/nodes", l = {
244
244
  headers: {
245
245
  Authorization: `${(y = this.token) == null ? void 0 : y.tokenType} ${(w = this.token) == null ? void 0 : w.accessToken}`
@@ -253,16 +253,16 @@ class Nt extends ot {
253
253
  lon: a.lng,
254
254
  lat: a.lat
255
255
  },
256
- maxDraught: e.draught || 10,
257
- useAIModel: e.useAIModel || !1,
258
- withECA: e.withECA || !1,
259
- withSpecialRegion: e.withSpecial || !1
256
+ maxDraught: s.draught || 10,
257
+ useAIModel: s.useAIModel || !1,
258
+ withECA: s.withECA || !1,
259
+ withSpecialRegion: s.withSpecial || !1
260
260
  }
261
261
  };
262
- i != null && i.length && (l.json.crossMonthList = i), n != null && n.length && (l.json.excludeNodes = n), o != null && o.length && (l.json.excludeSeaAreas = o), M == null || M.info("[%s] fetch route from: %s - %j", e.requestId, h, l);
262
+ i != null && i.length && (l.json.crossMonthList = i), n != null && n.length && (l.json.excludeNodes = n), o != null && o.length && (l.json.excludeSeaAreas = o), M == null || M.info("[%s] fetch route from: %s - %j", s.requestId, h, l);
263
263
  const d = await B.post(h, l).json();
264
264
  if (d.status !== 200)
265
- return M == null || M.warn("[%s] fetch route failed: %j", e.requestId, { message: d.message, status: d.status, code: d.code }), {};
265
+ return M == null || M.warn("[%s] fetch route failed: %j", s.requestId, { message: d.message, status: d.status, code: d.code }), {};
266
266
  {
267
267
  const k = {
268
268
  status: "Success",
@@ -273,7 +273,7 @@ class Nt extends ot {
273
273
  route: [],
274
274
  distance: 0,
275
275
  memo: ""
276
- }, { nodes: j, seas: p, tracks: b, specialRegions: f } = d.data;
276
+ }, { nodes: j, seas: b, tracks: p, specialRegions: f } = d.data;
277
277
  k.nodes = j == null ? void 0 : j.map((c) => ({
278
278
  code: c.nodeCode,
279
279
  nameEn: c.nameEn,
@@ -297,7 +297,7 @@ class Nt extends ot {
297
297
  isKey: c.isKeyNode,
298
298
  // 重要枢纽节点
299
299
  isHub: c.isHubNode
300
- })), k.seas = p == null ? void 0 : p.map((c) => ({
300
+ })), k.seas = b == null ? void 0 : b.map((c) => ({
301
301
  code: c.mrgidSea,
302
302
  nameEn: c.nameEn,
303
303
  nameCn: c.nameCn,
@@ -326,23 +326,23 @@ class Nt extends ot {
326
326
  distance: I.length
327
327
  }))
328
328
  });
329
- }), k.waypoints = b == null ? void 0 : b.map((c) => ({
329
+ }), k.waypoints = p == null ? void 0 : p.map((c) => ({
330
330
  lat: Math.round(c.lat * 1e5) / 1e5,
331
331
  lng: Math.round(c.lon * 1e5) / 1e5
332
- })), (g = k.waypoints) != null && g.length && (k.waypoints = V.simplifyCoordinates(k.waypoints), k.route = V.divideAccordingToLng(k.waypoints), k.distance = V.calculateRouteDistance(k.route));
332
+ })), (g = k.waypoints) != null && g.length && (k.waypoints = W.simplifyCoordinates(k.waypoints), k.route = W.divideAccordingToLng(k.waypoints), k.distance = W.calculateRouteDistance(k.route));
333
333
  const m = v().diff(r, "second");
334
- return k.memo = `time cost: ${m}s`, M.info("[%s] calculate route cost: %d seconds", e.requestId, m), k;
334
+ return k.memo = `time cost: ${m}s`, M.info("[%s] calculate route cost: %d seconds", s.requestId, m), k;
335
335
  }
336
336
  }
337
- async trajectory(t, a, i, n, o = !0, e = {}) {
338
- await this.checkToken(e);
339
- const r = await this.realTimePosition(t, e), h = v(a), l = v(i), d = [];
337
+ async trajectory(t, a, i, n, o = !0, s = {}) {
338
+ await this.checkToken(s);
339
+ const r = await this.realTimePosition(t, s), h = v(a), l = v(i), d = [];
340
340
  for (; l.diff(h, "day", !0) > 30; )
341
- await this.trajectoryIn30Day(t, h, h.clone().add(30, "day"), r, n, d, e), h.add(30, "day");
342
- return await this.trajectoryIn30Day(t, h, l, r, n, d, e), d;
341
+ await this.trajectoryIn30Day(t, h, h.clone().add(30, "day"), r, n, d, s), h.add(30, "day");
342
+ return await this.trajectoryIn30Day(t, h, l, r, n, d, s), d;
343
343
  }
344
- async trajectoryIn30Day(t, a, i, n, o, e, r = {}) {
345
- var g, k, j, p, b;
344
+ async trajectoryIn30Day(t, a, i, n, o, s, r = {}) {
345
+ var g, k, j, b, p;
346
346
  const h = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/track", l = {
347
347
  headers: {
348
348
  Authorization: `${(g = this.token) == null ? void 0 : g.tokenType} ${(k = this.token) == null ? void 0 : k.accessToken}`
@@ -358,10 +358,10 @@ class Nt extends ot {
358
358
  if (d.code)
359
359
  return M == null || M.warn("[%s] fetch trajectory failed: %j", r.requestId, h, { message: d.message, status: d.status, code: d.code }), d;
360
360
  let y = -1;
361
- const w = v(`${(p = (j = d.data) == null ? void 0 : j[0]) == null ? void 0 : p.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
362
- return (b = d.data) == null || b.forEach((f) => {
363
- for (const Y in f)
364
- !isNaN(f[Y]) && Number(f[Y]) !== 1 / 0 && (f[Y] = Number(f[Y]));
361
+ const w = v(`${(b = (j = d.data) == null ? void 0 : j[0]) == null ? void 0 : b.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
362
+ return (p = d.data) == null || p.forEach((f) => {
363
+ for (const P in f)
364
+ !isNaN(f[P]) && Number(f[P]) !== 1 / 0 && (f[P] = Number(f[P]));
365
365
  const u = v(`${f.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00"), m = f.status, { labelCn: c, labelEn: I } = this.parseStatus(m), C = {
366
366
  mmsi: f.mmsi,
367
367
  imo: n == null ? void 0 : n.imo,
@@ -381,14 +381,14 @@ class Nt extends ot {
381
381
  vendor: "myVessel",
382
382
  utc: u.utc().format()
383
383
  }, F = Math.floor(u.diff(w, "minute", !0) / (o || 1));
384
- F !== y && (y = F, e.push(C));
385
- }), e;
384
+ F !== y && (y = F, s.push(C));
385
+ }), s;
386
386
  }
387
387
  }
388
- class xt extends ot {
388
+ class Ft extends at {
389
389
  constructor(t) {
390
390
  super();
391
- K(this, "token");
391
+ U(this, "token");
392
392
  this.token = t;
393
393
  }
394
394
  async realTimePosition(t, a = {}) {
@@ -399,33 +399,33 @@ class xt extends ot {
399
399
  }
400
400
  }, o = await B.post(i, n).json();
401
401
  M == null || M.info("[%s] fetch realtime position from: %s - %j", a.requestId, i, n);
402
- const e = o == null ? void 0 : o.list;
403
- if (!e)
402
+ const s = o == null ? void 0 : o.list;
403
+ if (!s)
404
404
  return M == null || M.warn("[%s] fetch realtime position failed: %j", a.requestId, i, o), o;
405
- for (const w in e)
406
- !isNaN(e[w]) && Number(e[w]) !== 1 / 0 && (e[w] = Number(e[w]));
407
- e.status = e.sp > 3 ? 0 : 1;
408
- const r = e.status, { labelCn: h, labelEn: l } = this.parseStatus(r), d = v(`${e.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
405
+ for (const w in s)
406
+ !isNaN(s[w]) && Number(s[w]) !== 1 / 0 && (s[w] = Number(s[w]));
407
+ s.status = s.sp > 3 ? 0 : 1;
408
+ const r = s.status, { labelCn: h, labelEn: l } = this.parseStatus(r), d = v(`${s.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
409
409
  return {
410
- mmsi: e.m,
411
- name: e.n,
412
- imo: e.imonumber,
413
- callSign: e.callsign,
414
- lat: Math.round(e.la / 60 * 1e5) / 1e5,
415
- lng: Math.round(e.lo / 60 * 1e5) / 1e5,
416
- length: e.l,
417
- width: e.w,
418
- draught: e.draught,
419
- sog: e.sp,
420
- cog: e.co,
421
- hdg: e.h,
422
- rot: isNaN(e.rot) ? 0 : e.rot,
423
- eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(e.eta) ? v.utc(e.eta).format() : void 0,
424
- destination: e.destination,
425
- vesselType: e.type,
426
- dwt: e.dwt,
427
- build: e.buildyear,
428
- flag: e.fn,
410
+ mmsi: s.m,
411
+ name: s.n,
412
+ imo: s.imonumber,
413
+ callSign: s.callsign,
414
+ lat: Math.round(s.la / 60 * 1e5) / 1e5,
415
+ lng: Math.round(s.lo / 60 * 1e5) / 1e5,
416
+ length: s.l,
417
+ width: s.w,
418
+ draught: s.draught,
419
+ sog: s.sp,
420
+ cog: s.co,
421
+ hdg: s.h,
422
+ rot: isNaN(s.rot) ? 0 : s.rot,
423
+ eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(s.eta) ? v.utc(s.eta).format() : void 0,
424
+ destination: s.destination,
425
+ vesselType: s.type,
426
+ dwt: s.dwt,
427
+ build: s.buildyear,
428
+ flag: s.fn,
429
429
  positionTime: d.unix(),
430
430
  utc: d.utc().format(),
431
431
  status: r,
@@ -451,7 +451,7 @@ class xt extends ot {
451
451
  M == null || M.info("[%s] fetch vessel props from: %s - %j", a.requestId, i, n), o instanceof Array && (o = o[0]);
452
452
  for (const r in o)
453
453
  !isNaN(o[r]) && Number(o[r]) !== 1 / 0 && (o[r] = Number(o[r]));
454
- const e = {
454
+ const s = {
455
455
  mmsi: o.m,
456
456
  name: o.n,
457
457
  imo: o.i,
@@ -461,7 +461,7 @@ class xt extends ot {
461
461
  draught: o.dr,
462
462
  type: o.t
463
463
  };
464
- return i = "https://www.hifleet.com/hifleetapi/sameShipSearch.do", o = await B.post(i, n).json(), M == null || M.info("[%s] search vessel dead weight from: %s - %j", a.requestId, i, n), o instanceof Array && (o = o[0]), o && (e.deadweight = Number(o.dwt)), e;
464
+ return i = "https://www.hifleet.com/hifleetapi/sameShipSearch.do", o = await B.post(i, n).json(), M == null || M.info("[%s] search vessel dead weight from: %s - %j", a.requestId, i, n), o instanceof Array && (o = o[0]), o && (s.deadweight = Number(o.dwt)), s;
465
465
  }
466
466
  async suggest(t, a = {}) {
467
467
  const i = "https://www.hifleet.com/hifleetapi/getShipSuggest.do", n = {
@@ -475,20 +475,20 @@ class xt extends ot {
475
475
  }
476
476
  }, o = await B.post(i, n).json();
477
477
  M == null || M.info("[%s] suggest vessel props from: %s - %j", a.requestId, i, n);
478
- const e = [];
478
+ const s = [];
479
479
  for (const r of o)
480
- e.push({
480
+ s.push({
481
481
  mmsi: !r.mmsi || isNaN(r.mmsi) ? null : Number(r.mmsi),
482
482
  name: r.name,
483
483
  callSign: r.callsign,
484
484
  imo: !r.imo || isNaN(r.imo) ? null : Number(r.imo),
485
485
  score: r._score
486
486
  });
487
- return e.sort((r, h) => h.score - r.score), e;
487
+ return s.sort((r, h) => h.score - r.score), s;
488
488
  }
489
- async trajectory(t, a, i, n, o = !0, e = {}) {
489
+ async trajectory(t, a, i, n, o = !0, s = {}) {
490
490
  var f, u, m;
491
- const r = await this.realTimePosition(t, e);
491
+ const r = await this.realTimePosition(t, s);
492
492
  let h = v(a);
493
493
  const l = v(i), d = v();
494
494
  if (o) {
@@ -503,18 +503,18 @@ class xt extends ot {
503
503
  usertoken: this.token
504
504
  }
505
505
  }, w = "https://api.hifleet.com/position/trajectory/nocompressed/withstatic/token", g = await B.get(w, y).json();
506
- M == null || M.info("[%s] fetch trajectory from: %s - %j", e.requestId, w, y);
506
+ M == null || M.info("[%s] fetch trajectory from: %s - %j", s.requestId, w, y);
507
507
  let k;
508
- g && (k = ((u = (f = g.ships) == null ? void 0 : f.offors) == null ? void 0 : u.ship) || [], k.length || M == null || M.warn("[%s] fetch trajectory failed: %j", e.requestId, g));
508
+ g && (k = ((u = (f = g.ships) == null ? void 0 : f.offors) == null ? void 0 : u.ship) || [], k.length || M == null || M.warn("[%s] fetch trajectory failed: %j", s.requestId, g));
509
509
  const j = [];
510
- let p = -1;
511
- const b = v(`${(m = k == null ? void 0 : k[0]) == null ? void 0 : m.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
510
+ let b = -1;
511
+ const p = v(`${(m = k == null ? void 0 : k[0]) == null ? void 0 : m.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
512
512
  for (const c of k) {
513
513
  for (const H in c)
514
514
  !isNaN(c[H]) && Number(c[H]) !== 1 / 0 && (c[H] = Number(c[H]));
515
515
  const I = v(`${c.ti} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
516
516
  c.status = c.sp > 4 ? 0 : 1;
517
- const { labelEn: C, labelCn: F } = this.parseStatus(c.status), Y = {
517
+ const { labelEn: C, labelCn: F } = this.parseStatus(c.status), P = {
518
518
  mmsi: c.m,
519
519
  name: c.n,
520
520
  imo: r == null ? void 0 : r.imo,
@@ -531,16 +531,16 @@ class xt extends ot {
531
531
  labelEn: C,
532
532
  method: "trajectory",
533
533
  vendor: "hifleet"
534
- }, A = Math.floor(I.diff(b, "minute", !0) / (n || 1));
535
- A !== p && (p = A, j.push(Y));
534
+ }, D = Math.floor(I.diff(p, "minute", !0) / (n || 1));
535
+ D !== b && (b = D, j.push(P));
536
536
  }
537
537
  return j;
538
538
  }
539
539
  }
540
- class Dt extends ot {
540
+ class Nt extends at {
541
541
  constructor(t) {
542
542
  super();
543
- K(this, "token");
543
+ U(this, "token");
544
544
  this.token = t;
545
545
  }
546
546
  async realTimePosition(t, a = {}) {
@@ -553,36 +553,36 @@ class Dt extends ot {
553
553
  }, n = "https://api.shipxy.com/apicall/GetSingleShip", o = await B.get(n, i).json();
554
554
  if (M == null || M.info("[%s] fetch realtime position from: %s - %j", a.requestId, n, i), (o == null ? void 0 : o.status) !== 0)
555
555
  return o;
556
- const e = o.data[0];
557
- for (const y in e)
558
- !isNaN(e[y]) && Number(e[y]) !== 1 / 0 && (e[y] = Number(e[y]));
559
- const { labelCn: r, labelEn: h } = await this.parseStatus(e.navistat), l = v.unix(e.lasttime);
556
+ const s = o.data[0];
557
+ for (const y in s)
558
+ !isNaN(s[y]) && Number(s[y]) !== 1 / 0 && (s[y] = Number(s[y]));
559
+ const { labelCn: r, labelEn: h } = await this.parseStatus(s.navistat), l = v.unix(s.lasttime);
560
560
  return {
561
- mmsi: e.ShipID,
562
- name: e.name,
563
- imo: e.imo,
564
- callSign: e.callsign,
565
- lat: Math.round(e.lat / 1e6 * 1e5) / 1e5,
566
- lng: Math.round(e.lon / 1e6 * 1e5) / 1e5,
567
- length: Math.round(e.length / 10 * 100) / 100,
568
- width: Math.round(e.width / 10 * 100) / 100,
569
- draught: Math.round(e.draught / 1e3 * 100) / 100,
570
- sog: Math.round(e.sog * 3600 / 1e3 / 1852 * 100) / 100,
571
- cog: Math.round(e.cog / 100 * 100) / 100,
572
- hdg: Math.round(e.hdg / 100 * 100) / 100,
573
- rot: Math.round(e.rot / 100 * 100) / 100,
574
- positionTime: e.lasttime,
561
+ mmsi: s.ShipID,
562
+ name: s.name,
563
+ imo: s.imo,
564
+ callSign: s.callsign,
565
+ lat: Math.round(s.lat / 1e6 * 1e5) / 1e5,
566
+ lng: Math.round(s.lon / 1e6 * 1e5) / 1e5,
567
+ length: Math.round(s.length / 10 * 100) / 100,
568
+ width: Math.round(s.width / 10 * 100) / 100,
569
+ draught: Math.round(s.draught / 1e3 * 100) / 100,
570
+ sog: Math.round(s.sog * 3600 / 1e3 / 1852 * 100) / 100,
571
+ cog: Math.round(s.cog / 100 * 100) / 100,
572
+ hdg: Math.round(s.hdg / 100 * 100) / 100,
573
+ rot: Math.round(s.rot / 100 * 100) / 100,
574
+ positionTime: s.lasttime,
575
575
  utc: l.utc().format(),
576
- status: e.navistat,
576
+ status: s.navistat,
577
577
  labelEn: h,
578
578
  labelCn: r,
579
579
  method: "position",
580
580
  vendor: "shipxy"
581
581
  };
582
582
  }
583
- async trajectory(t, a, i, n, o = !0, e = {}) {
584
- var b;
585
- const r = await this.realTimePosition(t, e), h = v(a), l = v(i), d = "https://api.shipxy.com/apicall/GetShipTrack", y = {
583
+ async trajectory(t, a, i, n, o = !0, s = {}) {
584
+ var p;
585
+ const r = await this.realTimePosition(t, s), h = v(a), l = v(i), d = "https://api.shipxy.com/apicall/GetShipTrack", y = {
586
586
  searchParams: {
587
587
  id: t,
588
588
  k: this.token,
@@ -592,10 +592,10 @@ class Dt extends ot {
592
592
  etm: l.unix()
593
593
  }
594
594
  }, w = await B.get(d, y).json();
595
- if (M == null || M.info("[%s] fetch trajectory from: %s - %j", e.requestId, d, y), (w == null ? void 0 : w.status) !== 0)
595
+ if (M == null || M.info("[%s] fetch trajectory from: %s - %j", s.requestId, d, y), (w == null ? void 0 : w.status) !== 0)
596
596
  return w;
597
- const g = w == null ? void 0 : w.points, k = [], j = v.unix((b = g[0]) == null ? void 0 : b.utc);
598
- let p = -1;
597
+ const g = w == null ? void 0 : w.points, k = [], j = v.unix((p = g[0]) == null ? void 0 : p.utc);
598
+ let b = -1;
599
599
  for (const f of g) {
600
600
  const u = v.unix(f.utc), m = {
601
601
  imo: r == null ? void 0 : r.imo,
@@ -609,15 +609,15 @@ class Dt extends ot {
609
609
  method: "trajectory",
610
610
  vendor: "shipxy"
611
611
  }, c = Math.floor(u.diff(j, "minute", !0) / (n || 1));
612
- c !== p && (p = c, k.push(m));
612
+ c !== b && (b = c, k.push(m));
613
613
  }
614
614
  return k;
615
615
  }
616
616
  }
617
- class At extends ot {
617
+ class xt extends at {
618
618
  constructor(t) {
619
619
  super();
620
- K(this, "token");
620
+ U(this, "token");
621
621
  this.token = t;
622
622
  }
623
623
  async getShipId(t, a = {}) {
@@ -642,16 +642,16 @@ class At extends ot {
642
642
  }, n = "https://api3.myships.com/sp/ships/aissta", o = await B.post(n, i).json();
643
643
  if (M == null || M.info("[%s] fetch ship info from: %s - %j", a.requestId, n, i), o.code !== "0")
644
644
  return o;
645
- const e = o.data;
646
- let r = e.imo;
647
- return t === "407170" && (r = "9198379", M == null || M.warn("[%s] ship(%s) imo error: %s, should be %s", a.requestId, t, e.imo, r)), {
648
- mmsi: e.mmsi,
649
- name: e.shipnameEn,
645
+ const s = o.data;
646
+ let r = s.imo;
647
+ return t === "407170" && (r = "9198379", M == null || M.warn("[%s] ship(%s) imo error: %s, should be %s", a.requestId, t, s.imo, r)), {
648
+ mmsi: s.mmsi,
649
+ name: s.shipnameEn,
650
650
  imo: r,
651
- callSign: e.callSign,
652
- length: e.length,
653
- width: e.breadth,
654
- draught: (e.draught || 100) / 10
651
+ callSign: s.callSign,
652
+ length: s.length,
653
+ width: s.breadth,
654
+ draught: (s.draught || 100) / 10
655
655
  };
656
656
  }
657
657
  async realTimePosition(t, a = {}) {
@@ -662,8 +662,8 @@ class At extends ot {
662
662
  json: {
663
663
  shipId: i
664
664
  }
665
- }, e = "https://api3.myships.com/sp/ships/position/latest", r = await B.post(e, o).json();
666
- M == null || M.info("[%s] fetch realtime position from: %s - %j", a.requestId, e, o);
665
+ }, s = "https://api3.myships.com/sp/ships/position/latest", r = await B.post(s, o).json();
666
+ M == null || M.info("[%s] fetch realtime position from: %s - %j", a.requestId, s, o);
667
667
  const h = r.data[0];
668
668
  for (const g in h)
669
669
  !isNaN(h[g]) && Number(h[g]) !== 1 / 0 && (h[g] = Number(h[g]));
@@ -686,13 +686,13 @@ class At extends ot {
686
686
  vendor: "myship"
687
687
  };
688
688
  }
689
- async trajectory(t, a, i, n, o = !0, e = {}) {
689
+ async trajectory(t, a, i, n, o = !0, s = {}) {
690
690
  const r = v(a), h = v(i), l = await this.getShipId(t), d = await this.getShipInfo(l), y = [];
691
691
  for (; h.diff(r, "day", !0) > 30; )
692
692
  await this.trajectoryIn30Day(l, r.unix(), r.add(30, "day").unix(), d, t, n, y);
693
693
  return await this.trajectoryIn30Day(l, r.unix(), h.unix(), d, t, n, y), y;
694
694
  }
695
- async trajectoryIn30Day(t, a, i, n, o, e, r, h = {}) {
695
+ async trajectoryIn30Day(t, a, i, n, o, s, r, h = {}) {
696
696
  var j;
697
697
  const l = {
698
698
  headers: {
@@ -707,38 +707,38 @@ class At extends ot {
707
707
  if (M == null || M.info("[%s] fetch trajectory from: %s - %j", h.requestId, d, l), y.code !== "0")
708
708
  return M == null || M.warn("[%s] invoke myship trajectory failed: %j", h.requestId, y), y;
709
709
  const w = y.data;
710
- for (const p in w)
711
- !isNaN(w[p]) && Number(w[p]) !== 1 / 0 && (w[p] = Number(w[p]));
710
+ for (const b in w)
711
+ !isNaN(w[b]) && Number(w[b]) !== 1 / 0 && (w[b] = Number(w[b]));
712
712
  const g = v.unix((j = w[0]) == null ? void 0 : j.posTime);
713
713
  let k = -1;
714
- for (const p of w) {
715
- const b = v.unix(p.posTime), f = {
714
+ for (const b of w) {
715
+ const p = v.unix(b.posTime), f = {
716
716
  imo: n == null ? void 0 : n.imo,
717
717
  mmsi: o,
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: b.unix(),
725
- utc: b.utc().format(),
718
+ lat: Math.round(b.lat / 1e4 / 60 * 1e5) / 1e5,
719
+ lng: Math.round(b.lon / 1e4 / 60 * 1e5) / 1e5,
720
+ sog: Math.round(b.sog / 10 * 100) / 100,
721
+ cog: Math.round(b.cog / 10 * 100) / 100,
722
+ hdg: Math.round(b.heading * 100) / 100,
723
+ rot: Math.round(b.rot * 100) / 100,
724
+ positionTime: p.unix(),
725
+ utc: p.utc().format(),
726
726
  method: "trajectory",
727
727
  vendor: "myship"
728
- }, u = Math.floor(b.diff(g, "minute", !0) / (e || 1));
728
+ }, u = Math.floor(p.diff(g, "minute", !0) / (s || 1));
729
729
  u !== k && (k = u, r.push(f));
730
730
  }
731
731
  return r;
732
732
  }
733
733
  }
734
- let _;
734
+ let J;
735
735
  try {
736
- _ = ht.getLogger("vessel");
736
+ J = dt.getLogger("vessel");
737
737
  } catch {
738
738
  } finally {
739
739
  }
740
- var gt = /* @__PURE__ */ ((D) => (D.NOTICE = "NOTICE", D.WARN = "WARN", D.HEAVY = "HEAVY", D.SEVERE = "SEVERE", D.ERROR = "ERROR", D.FATAL = "FATAL", D))(gt || {});
741
- class pt {
740
+ var yt = /* @__PURE__ */ ((x) => (x.NOTICE = "NOTICE", x.WARN = "WARN", x.HEAVY = "HEAVY", x.SEVERE = "SEVERE", x.ERROR = "ERROR", x.FATAL = "FATAL", x))(yt || {});
741
+ class Mt {
742
742
  /**
743
743
  * 解析告警规则, 多规则场景
744
744
  * @param rule
@@ -747,10 +747,10 @@ class pt {
747
747
  *
748
748
  * @param options
749
749
  */
750
- parsePrinciple(s, t = {}) {
751
- var e, r, h;
752
- _ == null || _.debug("[%s] parse rule: %s", t.requestId, s);
753
- const a = new RegExp("(?<=\\[)(.+)(?=])", "g"), i = s.match(a) ? (e = s.match(a)) == null ? void 0 : e[0] : void 0, n = i == null ? void 0 : i.split(";");
750
+ parsePrinciple(e, t = {}) {
751
+ var s, r, h;
752
+ J == null || J.debug("[%s] parse rule: %s", t.requestId, e);
753
+ const a = new RegExp("(?<=\\[)(.+)(?=])", "g"), i = e.match(a) ? (s = e.match(a)) == null ? void 0 : s[0] : void 0, n = i == null ? void 0 : i.split(";");
754
754
  if (!n)
755
755
  return;
756
756
  const o = {};
@@ -772,17 +772,17 @@ class pt {
772
772
  * @param rule
773
773
  * @param options
774
774
  */
775
- parseRule(s, t = {}) {
775
+ parseRule(e, t = {}) {
776
776
  var o;
777
- _ == null || _.debug("[%s] parse rule: %s", t.requestId, s), s = s.startsWith("[") ? s : `[${s}`, s = s.endsWith("]") ? s : `${s}]`;
778
- const a = new RegExp("(?<=\\[)(.+?)(?=])", "g"), i = (o = s == null ? void 0 : s.match(a)) == null ? void 0 : o[0], n = i == null ? void 0 : i.split(",");
777
+ J == null || J.debug("[%s] parse rule: %s", t.requestId, e), e = e.startsWith("[") ? e : `[${e}`, e = e.endsWith("]") ? e : `${e}]`;
778
+ const a = new RegExp("(?<=\\[)(.+?)(?=])", "g"), i = (o = e == null ? void 0 : e.match(a)) == null ? void 0 : o[0], n = i == null ? void 0 : i.split(",");
779
779
  if (n) {
780
- let e = n[3] === "Number.MAX_VALUE" ? 100 : Number(n[3]);
781
- return e = isNaN(e) ? 1 : e, {
780
+ let s = n[3] === "Number.MAX_VALUE" ? 100 : Number(n[3]);
781
+ return s = isNaN(s) ? 1 : s, {
782
782
  operator: n[0],
783
783
  number: Number.isNaN(Number(n[1])) ? n[1] : Number(n[1]),
784
784
  level: n[2],
785
- time: e,
785
+ time: s,
786
786
  key: n[4]
787
787
  };
788
788
  }
@@ -793,27 +793,27 @@ class pt {
793
793
  * @param principle 告警规则
794
794
  * @param options
795
795
  */
796
- checkWeather(s, t, a = {}) {
797
- var g, k, j, p, b, f, u, m, c, I, C, F, Y, A, H;
798
- let i = 0, n = 0, o = 0, e = 0;
799
- const r = Math.round(((k = (g = t == null ? void 0 : t.SEVERE) == null ? void 0 : g.sigWave) == null ? void 0 : k.number) * 1.6 * 100) / 100, h = (p = (j = t == null ? void 0 : t.SEVERE) == null ? void 0 : j.sigWave) == null ? void 0 : p.number, l = (f = (b = t == null ? void 0 : t.HEAVY) == null ? void 0 : b.sigWave) == null ? void 0 : f.number, d = Math.round((((m = (u = t == null ? void 0 : t.SEVERE) == null ? void 0 : u.wind) == null ? void 0 : m.number) + 2) * 100) / 100, y = (I = (c = t == null ? void 0 : t.SEVERE) == null ? void 0 : c.wind) == null ? void 0 : I.number, w = (F = (C = t == null ? void 0 : t.HEAVY) == null ? void 0 : C.wind) == null ? void 0 : F.number;
800
- for (let E = 0; E < (s == null ? void 0 : s.length); E++) {
801
- const N = s[E], O = (A = (Y = N == null ? void 0 : N.meteo) == null ? void 0 : Y.wave) == null ? void 0 : A.sig, R = (H = N == null ? void 0 : N.meteo) == null ? void 0 : H.wind, J = E ? v(N.eta).diff(v(s[E - 1].eta), "hour", !0) : 0;
802
- e = J > e ? J : e, _ == null || _.debug("[%s] check sig.wave: %j", a.requestId, { ...O, dgThd4Wv: r, svThd4Wv: h, hvThd4Wv: l }), (O == null ? void 0 : O.height) >= r ? N.isDangerous = !0 : (O == null ? void 0 : O.height) >= h ? N.isSevere = !0 : (O == null ? void 0 : O.height) >= l && (N.isHeavy = !0), _ == null || _.debug("[%s] check wind: %j", a.requestId, { ...R, dgThd4Wd: d, svThd4Wd: y, hvThd4Wd: w }), (R == null ? void 0 : R.scale) >= d ? (N.isDangerous = !0, delete N.isSevere, delete N.isHeavy) : (R == null ? void 0 : R.scale) > y ? (N.isDangerous || (N.isSevere = !0), delete N.isHeavy) : (R == null ? void 0 : R.scale) === w && !N.isDangerous && !N.isSevere && (N.isHeavy = !0), i += N.isDangerous ? J : 0, n += N.isSevere ? J : 0, o += N.isHeavy ? J : 0;
796
+ checkWeather(e, t, a = {}) {
797
+ var g, k, j, b, p, f, u, m, c, I, C, F, P, D, H;
798
+ let i = 0, n = 0, o = 0, s = 0;
799
+ const r = Math.round(((k = (g = t == null ? void 0 : t.SEVERE) == null ? void 0 : g.sigWave) == null ? void 0 : k.number) * 1.6 * 100) / 100, h = (b = (j = t == null ? void 0 : t.SEVERE) == null ? void 0 : j.sigWave) == null ? void 0 : b.number, l = (f = (p = t == null ? void 0 : t.HEAVY) == null ? void 0 : p.sigWave) == null ? void 0 : f.number, d = Math.round((((m = (u = t == null ? void 0 : t.SEVERE) == null ? void 0 : u.wind) == null ? void 0 : m.number) + 2) * 100) / 100, y = (I = (c = t == null ? void 0 : t.SEVERE) == null ? void 0 : c.wind) == null ? void 0 : I.number, w = (F = (C = t == null ? void 0 : t.HEAVY) == null ? void 0 : C.wind) == null ? void 0 : F.number;
800
+ for (let T = 0; T < (e == null ? void 0 : e.length); T++) {
801
+ const N = e[T], O = (D = (P = N == null ? void 0 : N.meteo) == null ? void 0 : P.wave) == null ? void 0 : D.sig, R = (H = N == null ? void 0 : N.meteo) == null ? void 0 : H.wind, K = T ? v(N.eta).diff(v(e[T - 1].eta), "hour", !0) : 0;
802
+ s = K > s ? K : s, J == null || J.debug("[%s] check sig.wave: %j", a.requestId, { ...O, dgThd4Wv: r, svThd4Wv: h, hvThd4Wv: l }), (O == null ? void 0 : O.height) >= r ? N.isDangerous = !0 : (O == null ? void 0 : O.height) >= h ? N.isSevere = !0 : (O == null ? void 0 : O.height) >= l && (N.isHeavy = !0), J == null || J.debug("[%s] check wind: %j", a.requestId, { ...R, dgThd4Wd: d, svThd4Wd: y, hvThd4Wd: w }), (R == null ? void 0 : R.scale) >= d ? (N.isDangerous = !0, delete N.isSevere, delete N.isHeavy) : (R == null ? void 0 : R.scale) > y ? (N.isDangerous || (N.isSevere = !0), delete N.isHeavy) : (R == null ? void 0 : R.scale) === w && !N.isDangerous && !N.isSevere && (N.isHeavy = !0), i += N.isDangerous ? K : 0, n += N.isSevere ? K : 0, o += N.isHeavy ? K : 0;
803
803
  }
804
- return i = Math.round(i * 100) / 100, n = Math.round(n * 100) / 100, o = Math.round(o * 100) / 100, e = Math.round(e), { sample: s, dangerous: i, severe: n, heavy: o, step: e < 3 ? 3 : e, wind: { dgThd4Wd: d, svThd4Wd: y, hvThd4Wd: w }, sig: { dgThd4Wv: r, svThd4Wv: h, hvThd4Wv: l } };
804
+ return i = Math.round(i * 100) / 100, n = Math.round(n * 100) / 100, o = Math.round(o * 100) / 100, s = Math.round(s), { sample: e, dangerous: i, severe: n, heavy: o, step: s < 3 ? 3 : s, wind: { dgThd4Wd: d, svThd4Wd: y, hvThd4Wd: w }, sig: { dgThd4Wv: r, svThd4Wv: h, hvThd4Wv: l } };
805
805
  }
806
806
  }
807
- const Pt = new pt();
808
- let T;
807
+ const Dt = new Mt();
808
+ let S;
809
809
  try {
810
- T = ht.getLogger("vessel");
810
+ S = dt.getLogger("vessel");
811
811
  } catch {
812
812
  } finally {
813
813
  }
814
- const bt = new Mt("", !0);
815
- var vt = /* @__PURE__ */ ((D) => (D.common = "common", D.container = "container", D.tugs = "tugs", D))(vt || {}), wt = /* @__PURE__ */ ((D) => (D.Ballast = "Ballast", D.Laden = "Laden", D))(wt || {}), kt = /* @__PURE__ */ ((D) => (D.Cp = "CP", D.Perf = "Basis", D.Instruct = "Other", D))(kt || {});
816
- class W {
814
+ const gt = new ft("", !0);
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 {
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)
@@ -826,11 +826,11 @@ class W {
826
826
  * @param draught 吃水 m
827
827
  * @return [0.55, 0.85]
828
828
  */
829
- static blockCoefficient(s, t, a, i) {
830
- let n = Math.round(s / (t * a * i) * 100) / 100;
829
+ static blockCoefficient(e, t, a, i) {
830
+ let n = Math.round(e / (t * a * i) * 100) / 100;
831
831
  n = n < 0.55 ? 0.55 : n > 0.85 ? 0.85 : n;
832
- const o = [0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85], e = o.map((r) => Math.abs(r - n));
833
- return o[e.indexOf(Math.min(...e))];
832
+ const o = [0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85], s = o.map((r) => Math.abs(r - n));
833
+ return o[s.indexOf(Math.min(...s))];
834
834
  }
835
835
  /**
836
836
  * @see https://baike.baidu.com/item/%E5%BC%97%E5%8A%B3%E5%BE%B7%E6%95%B0/228891?fromModule=search-result_lemma-recommend
@@ -843,8 +843,8 @@ class W {
843
843
  * @param g 重力加速度 9.80 m/s^2
844
844
  * @return [0.05, 0.30]
845
845
  */
846
- static froudeNumber(s, t, a = 9.8) {
847
- let i = Math.round(Math.sqrt(s * s / (a * t)) * 100) / 100;
846
+ static froudeNumber(e, t, a = 9.8) {
847
+ let i = Math.round(Math.sqrt(e * e / (a * t)) * 100) / 100;
848
848
  return i = i < 0.05 ? 0.05 : i > 0.3 ? 0.3 : i, i;
849
849
  }
850
850
  /**
@@ -854,7 +854,7 @@ class W {
854
854
  * @param loadCondition
855
855
  * @private
856
856
  */
857
- static amendFactor(s, t, a) {
857
+ static amendFactor(e, t, a) {
858
858
  const i = {
859
859
  0.55: [1.7, -1.4, -7.4],
860
860
  0.6: [2.2, -2.5, -9.7],
@@ -872,8 +872,8 @@ class W {
872
872
  0.75: [2.6, -12.5, -13.5],
873
873
  0.8: [3, -16.3, -21.6],
874
874
  0.85: [3.4, -20.9, 31.8]
875
- }[s];
876
- return a === "Laden" && (o = i[s]), o[0] + o[1] * t + o[2] * Math.pow(t, 2);
875
+ }[e];
876
+ return a === "Laden" && (o = i[e]), o[0] + o[1] * t + o[2] * Math.pow(t, 2);
877
877
  }
878
878
  /**
879
879
  * 失速方向因子
@@ -886,9 +886,9 @@ class W {
886
886
  * @param bn
887
887
  * @private
888
888
  */
889
- static directionFactor(s, t = 0) {
889
+ static directionFactor(e, t = 0) {
890
890
  let a;
891
- return s > 30 && s <= 60 ? a = (1.7 - 0.03 * Math.pow(t - 4, 2)) / 2 : s > 60 && s <= 150 ? a = (0.9 - 0.06 * Math.pow(t - 6, 2)) / 2 : s > 150 && s <= 180 ? a = (0.4 - 0.03 * Math.pow(t - 8, 2)) / 2 : a = 1, Math.round(a * 1e5) / 1e5;
891
+ return e > 30 && e <= 60 ? a = (1.7 - 0.03 * Math.pow(t - 4, 2)) / 2 : e > 60 && e <= 150 ? a = (0.9 - 0.06 * Math.pow(t - 6, 2)) / 2 : e > 150 && e <= 180 ? a = (0.4 - 0.03 * Math.pow(t - 8, 2)) / 2 : a = 1, Math.round(a * 1e5) / 1e5;
892
892
  }
893
893
  /**
894
894
  * 失速船型因子
@@ -902,9 +902,9 @@ class W {
902
902
  * @param kts
903
903
  * @private
904
904
  */
905
- static vesselTagFactor(s, t, a, i) {
905
+ static vesselTagFactor(e, t, a, i) {
906
906
  let n;
907
- return a === "container" ? n = 0.7 * i / 2 + Math.pow(i, 3) / (22 * Math.pow(s, 2 / 3)) : t === "Ballast" ? n = 0.7 * i / 2 + Math.pow(i, 3) / (2.7 * Math.pow(s, 2 / 3)) : n = 0.5 * i / 2 + Math.pow(i, 3) / (2.7 * Math.pow(s, 2 / 3)), n;
907
+ return a === "container" ? n = 0.7 * i / 2 + Math.pow(i, 3) / (22 * Math.pow(e, 2 / 3)) : t === "Ballast" ? n = 0.7 * i / 2 + Math.pow(i, 3) / (2.7 * Math.pow(e, 2 / 3)) : n = 0.5 * i / 2 + Math.pow(i, 3) / (2.7 * Math.pow(e, 2 / 3)), n;
908
908
  }
909
909
  /**
910
910
  * 浪高影响因子
@@ -912,10 +912,10 @@ class W {
912
912
  * @param beta 夹角
913
913
  * @private
914
914
  */
915
- static waveHeightFactor(s, t) {
916
- s = s < 3 ? s * 0.7 : s, s = s < 0 ? 0.2 : s, s = s > 6 ? s - 0.9 * (s - 6) : s, s = s > 9 ? 9 : s;
915
+ static waveHeightFactor(e, t) {
916
+ e = e < 3 ? e * 0.7 : e, e = e < 0 ? 0.2 : e, e = e > 6 ? e - 0.9 * (e - 6) : e, e = e > 9 ? 9 : e;
917
917
  let a;
918
- return t > 30 && t <= 60 ? a = -0.6 : t > 60 && t <= 90 ? a = -0.4 : t > 90 && t <= 120 ? a = s < 3 ? 0.4 : -0.3 : t > 120 && t <= 150 ? a = s < 3 ? 0.6 : -0.5 : t > 150 && t <= 180 ? a = s < 3 ? 0.7 : -0.6 : a = -0.7, Math.round(a * (0.144 * Math.pow(s, 2) + 0.278 * s) * 1e4) / 1e4;
918
+ return t > 30 && t <= 60 ? a = -0.6 : t > 60 && t <= 90 ? a = -0.4 : t > 90 && t <= 120 ? a = e < 3 ? 0.4 : -0.3 : t > 120 && t <= 150 ? a = e < 3 ? 0.6 : -0.5 : t > 150 && t <= 180 ? a = e < 3 ? 0.7 : -0.6 : a = -0.7, Math.round(a * (0.144 * Math.pow(e, 2) + 0.278 * e) * 1e4) / 1e4;
919
919
  }
920
920
  /**
921
921
  * 组装船舶运行参数
@@ -925,18 +925,18 @@ class W {
925
925
  * @param bearing 方位角
926
926
  * @private
927
927
  */
928
- static assembleProperties(s, t, a, i) {
928
+ static assembleProperties(e, t, a, i) {
929
929
  var y;
930
- const n = s.lbp ?? s.length ?? s.lengthOverall ?? 198.9642, o = s.draught ?? 8, e = s.breadthMoulded ?? s.breadth ?? s.breadthExtreme ?? 32.4572, r = s.deadweight ?? 67035.7773, h = ((y = s == null ? void 0 : s.type) == null ? void 0 : y.toLowerCase()) || "common";
930
+ const n = e.lbp ?? e.length ?? e.lengthOverall ?? 198.9642, o = e.draught ?? 8, s = e.breadthMoulded ?? e.breadth ?? e.breadthExtreme ?? 32.4572, r = e.deadweight ?? 67035.7773, h = ((y = e == null ? void 0 : e.type) == null ? void 0 : y.toLowerCase()) || "common";
931
931
  return {
932
932
  tag: h.indexOf("container") > -1 ? "container" : h.indexOf("tugs") > -1 ? "tugs" : "common",
933
933
  lbp: n,
934
934
  loadCondition: t,
935
935
  draught: o,
936
- breadthMoulded: e,
936
+ breadthMoulded: s,
937
937
  // 排水量(吨)= 载重量(吨)/ 1.025 + 吃水(米)× 船舶型宽(米)× 船舶型长(米)× 0.7
938
938
  // 其中,1.025是指海水的密度,吨是指公吨,吃水是指船舶的最大吃水深度。船舶型宽是指船舶的最大型宽,船舶型长是指船舶的设计型长。上述公式是针对常规船舶适用的,不同类型的船舶可能会有一些差异。
939
- displacement: Math.round((r / 1.025 + o * e * n * 0.7) * 1e4) / 1e4,
939
+ displacement: Math.round((r / 1.025 + o * s * n * 0.7) * 1e4) / 1e4,
940
940
  // 换算为m/s
941
941
  speed: Math.round((a ?? 14.1382) * 1852 / 3600 * 1e4) / 1e4,
942
942
  bearing: i || 90
@@ -953,29 +953,29 @@ class W {
953
953
  * @param useRouteParam true 启用设置速度
954
954
  * @param options
955
955
  */
956
- static async speedLoseAt(s, t, a, i = "", n = 2, o = !0, e = !1, r = {}) {
956
+ static async speedLoseAt(e, t, a, i = "", n = 2, o = !0, s = !1, r = {}) {
957
957
  let h;
958
- if (t.velocity && e && (s.speed = z.roundPrecision(t.velocity * 1852 / 3600, 6)), o) {
958
+ if (t.velocity && s && (e.speed = z.roundPrecision(t.velocity * 1852 / 3600, 6)), o) {
959
959
  let l;
960
960
  try {
961
961
  i = (i == null ? void 0 : i.toUpperCase()) === "CMEMS" ? "ECMWF" : i, i = (i == null ? void 0 : i.toUpperCase()) === "METEO2" ? "best_match" : i;
962
- const { weatherModels: g, marineModels: k } = await ut.autoPickMeteoModel(i), j = await bt.spotForecast(t.lat, t.lng, a.utc().format(), !1, !1, !0, {
962
+ const { weatherModels: g, marineModels: k } = await ct.autoPickMeteoModel(i), j = 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
966
  weatherModels: g,
967
967
  marineModels: k
968
- }), [p] = ut.pickHourly(j, a);
969
- l = ut.toLegacy(p);
968
+ }), [b] = ct.pickHourly(j, a);
969
+ l = ct.toLegacy(b);
970
970
  } catch (g) {
971
- T.warn("[%s] meteo2 spot(%j) forecast failed: %s", r.requestId, { ...t, eta: a.utc().format(), source: i }, g);
971
+ S.warn("[%s] meteo2 spot(%j) forecast failed: %s", r.requestId, { ...t, eta: a.utc().format(), source: i }, g);
972
972
  }
973
- const d = W.currentFactor(s.bearing, l == null ? void 0 : l.current, n), y = W.weatherFactor(s, l, d), w = Math.round((s.speed * 1.943844 + y + d) * 100) / 100;
973
+ const d = Y.currentFactor(e.bearing, l == null ? void 0 : l.current, n), y = Y.weatherFactor(e, l, d), w = Math.round((e.speed * 1.943844 + y + d) * 100) / 100;
974
974
  h = {
975
975
  meteo: { ...l },
976
976
  wxFactor: y,
977
977
  cFactor: d,
978
- speed: t.velocity && e ? t.velocity : w < 0 ? 1 : w,
978
+ speed: t.velocity && s ? t.velocity : w < 0 ? 1 : w,
979
979
  eta: a.utc().format(),
980
980
  etd: a.utc().format()
981
981
  };
@@ -983,7 +983,7 @@ class W {
983
983
  h = {
984
984
  wxFactor: 0,
985
985
  cFactor: 0,
986
- speed: t.velocity && e ? t.velocity : Math.round(s.speed * 1.943844 * 100) / 100,
986
+ speed: t.velocity && s ? t.velocity : Math.round(e.speed * 1.943844 * 100) / 100,
987
987
  eta: a.utc().format(),
988
988
  etd: a.utc().format()
989
989
  };
@@ -1003,15 +1003,15 @@ class W {
1003
1003
  * @param options
1004
1004
  * @private
1005
1005
  */
1006
- static async speedLoseInHoursStep(s, t, a, i, n, o, e = "", r = !0, h = !1, l = {}) {
1006
+ static async speedLoseInHoursStep(e, t, a, i, n, o, s = "", r = !0, h = !1, l = {}) {
1007
1007
  t.utc();
1008
1008
  const d = t.clone().add(14, "days"), y = [], w = [], g = [];
1009
- let k = 0, j = 0, p, b;
1009
+ let k = 0, j = 0, b, p;
1010
1010
  for (let f = 0; f < o.length - 1; f++) {
1011
1011
  let u = o[f];
1012
1012
  u.distanceFromStart = Math.round((n + j) * 1e3) / 1e3;
1013
1013
  const m = o[f + 1];
1014
- if (s.bearing = V.calculateBearing(u, m, !m.gcToPrevious), u.bearing = s.bearing, u.suspend && h) {
1014
+ if (e.bearing = W.calculateBearing(u, m, !m.gcToPrevious), u.bearing = e.bearing, u.suspend && h) {
1015
1015
  u.eta = u.eta || t.utc().format(), u.elapsed = u.elapsed ?? 0;
1016
1016
  const C = u.suspend - u.elapsed;
1017
1017
  if (i - k > C)
@@ -1020,36 +1020,36 @@ class W {
1020
1020
  const F = i - k;
1021
1021
  u.elapsed += F, t.add(F, "hour"), i = 0;
1022
1022
  }
1023
- if (T == null || T.info(`[%s] suspend ${u.elapsed} hours at %j, and remain ${i} hours need to go...`, l.requestId, u), i === 0)
1024
- return u.distanceFromPrevious = j, { etd: t, from: b || u, to: u, next: o.filter((F) => F), wps: y, days: w, all: g };
1023
+ if (S == null || S.info(`[%s] suspend ${u.elapsed} hours at %j, and remain ${i} hours need to go...`, l.requestId, u), i === 0)
1024
+ return u.distanceFromPrevious = j, { etd: t, from: p || u, to: u, next: o.filter((F) => F), wps: y, days: w, all: g };
1025
1025
  } else
1026
1026
  u.suspend = 0;
1027
- r = t.isAfter(d) ? !1 : r, u = await W.speedLoseAt(s, u, t, e, 0, r, h, l), g.push(u), b = b || u, u.important && y.push(u), t.isSameOrAfter(a) && (w.push(u), a.add(24, "hour"));
1028
- const c = V.calculateDistance(u, m, !m.gcToPrevious);
1029
- let I = Math.round(c / b.speed * 1e5) / 1e5;
1027
+ r = t.isAfter(d) ? !1 : r, u = await Y.speedLoseAt(e, u, t, s, 0, r, h, l), g.push(u), p = p || u, u.important && y.push(u), t.isSameOrAfter(a) && (w.push(u), a.add(24, "hour"));
1028
+ const c = W.calculateDistance(u, m, !m.gcToPrevious);
1029
+ let I = Math.round(c / p.speed * 1e5) / 1e5;
1030
1030
  if (k + I < i) {
1031
- if (k += I, t.add(I, "hour"), delete o[f], T == null || T.debug(
1031
+ if (k += I, t.add(I, "hour"), delete o[f], S == null || S.debug(
1032
1032
  `[%s] go to %j from %j with ${c}nm, and cost ${I} hours`,
1033
1033
  l.requestId,
1034
1034
  { lat: m.lat, lng: m.lng },
1035
- { lat: b.lat, lng: b.lng, etd: b.etd }
1035
+ { lat: p.lat, lng: p.lng, etd: p.etd }
1036
1036
  ), j += c, o.filter((C) => C).length <= 1) {
1037
- p = m, p.eta = t.utc().format(), p.distanceFromPrevious = c, p.distanceFromStart = Math.round((n + j) * 1e4) / 1e4, y.push(p), g.push(p), delete o[f + 1];
1037
+ b = m, b.eta = t.utc().format(), b.distanceFromPrevious = c, b.distanceFromStart = Math.round((n + j) * 1e4) / 1e4, y.push(b), g.push(b), delete o[f + 1];
1038
1038
  break;
1039
1039
  }
1040
1040
  } else {
1041
1041
  I = i - k, t.add(I, "hour");
1042
- const C = z.roundPrecision(b.speed * I, 5);
1043
- p = V.calculateCoordinate(u, s.bearing, C, "nauticalmiles", !m.gcToPrevious), p.eta = t.utc().format(), o[f] = p, T == null || T.debug(
1042
+ const C = z.roundPrecision(p.speed * I, 5);
1043
+ b = W.calculateCoordinate(u, e.bearing, C, "nauticalmiles", !m.gcToPrevious), b.eta = t.utc().format(), o[f] = b, S == null || S.debug(
1044
1044
  `[%s] go to %j from %j with ${C}nm, and cost ${I} hours`,
1045
1045
  l.requestId,
1046
- { lat: p.lat, lng: p.lng },
1046
+ { lat: b.lat, lng: b.lng },
1047
1047
  { lat: u.lat, lng: u.lng, etd: u.etd }
1048
- ), j += C, p.distanceFromPrevious = Math.round(j * 1e4) / 1e4, p.distanceFromStart = Math.round((n + j) * 1e4) / 1e4;
1048
+ ), j += C, b.distanceFromPrevious = Math.round(j * 1e4) / 1e4, b.distanceFromStart = Math.round((n + j) * 1e4) / 1e4;
1049
1049
  break;
1050
1050
  }
1051
1051
  }
1052
- return { etd: t, from: b, to: p, next: o.filter((f) => f), wps: y, days: w, all: g };
1052
+ return { etd: t, from: p, to: b, next: o.filter((f) => f), wps: y, days: w, all: g };
1053
1053
  }
1054
1054
  /**
1055
1055
  * 洋流影响因子
@@ -1057,8 +1057,8 @@ class W {
1057
1057
  * @param current 洋流要素
1058
1058
  * @param role 1: 船东, 2: 租家, 0: 未知
1059
1059
  */
1060
- static currentFactor(s, t, a = 0) {
1061
- const i = (s - (t == null ? void 0 : t.degree) || 0) / 180 * Math.PI;
1060
+ static currentFactor(e, t, a = 0) {
1061
+ const i = (e - (t == null ? void 0 : t.degree) || 0) / 180 * Math.PI;
1062
1062
  if (Math.abs(i) === Math.PI / 2)
1063
1063
  return 0;
1064
1064
  let n = ((t == null ? void 0 : t.kts) || 0) * Math.cos(i);
@@ -1070,17 +1070,33 @@ class W {
1070
1070
  * @param wwc 气象要素
1071
1071
  * @param cFactor 洋流因子
1072
1072
  */
1073
- static weatherFactor(s, t, a = 0) {
1074
- var w, g, k, j, p, b, f;
1075
- T == null || T.debug("calculate weather factor via: %j", { ...s, ...t });
1076
- const i = W.blockCoefficient(s.displacement, s.lbp, s.breadthMoulded, s.draught), n = z.roundPrecision(a * 1852 / 3600, 6), o = W.froudeNumber(s.speed - n, s.lbp), e = W.amendFactor(i, o, s.loadCondition);
1077
- let r = Math.abs(s.bearing % 360 - (((w = t == null ? void 0 : t.wind) == null ? void 0 : w.degree) % 360 || 0));
1073
+ static weatherFactor(e, t, a = 0) {
1074
+ var w, g, k, j, b, p, f;
1075
+ S == null || S.debug("calculate weather factor via: %j", { ...e, ...t });
1076
+ const i = Y.blockCoefficient(e.displacement, e.lbp, e.breadthMoulded, e.draught), n = z.roundPrecision(a * 1852 / 3600, 6), o = Y.froudeNumber(e.speed - n, e.lbp), s = Y.amendFactor(i, o, e.loadCondition);
1077
+ let r = Math.abs(e.bearing % 360 - (((w = t == null ? void 0 : t.wind) == null ? void 0 : w.degree) % 360 || 0));
1078
1078
  r = r > 180 ? 360 - r : r;
1079
- const h = W.directionFactor(r, (g = t == null ? void 0 : t.wind) == null ? void 0 : g.scale), l = W.vesselTagFactor(s.displacement, s.loadCondition, s.tag, (k = t == null ? void 0 : t.wind) == null ? void 0 : k.kts);
1080
- let d = h * e * l / 100 * (s.speed - n);
1081
- d = Math.round(d * 1.943844 * 1e4) / 1e4 * -1, s.tag === "tugs" && Math.abs(d) > 1 && (d = d / (Math.abs(Math.round(d)) + 1)), T == null || T.debug("wind wx factor = %d", d), r = Math.abs(s.bearing % 360 - (((p = (j = t == null ? void 0 : t.wave) == null ? void 0 : j.sig) == null ? void 0 : p.degree) % 360 || 0)), r = r > 180 ? 360 - r : r;
1082
- const y = W.waveHeightFactor(((f = (b = t == null ? void 0 : t.wave) == null ? void 0 : b.sig) == null ? void 0 : f.height) ?? 1, r);
1083
- return T == null || T.debug("wave wx factor = %d", y), d = Math.abs(d) > Math.abs(y) ? d : d * 0.3 + y * 0.7, T == null || T.debug("weather factor = %d", d), d = Math.abs(d) > 3 ? 3 * (Math.abs(d) / d) + Math.abs(d) / d * (Math.abs(d) - 2) * 0.1 : d, Math.round((d || 0) * 100) / 100;
1079
+ const h = Y.directionFactor(r, (g = t == null ? void 0 : t.wind) == null ? void 0 : g.scale), l = Y.vesselTagFactor(e.displacement, e.loadCondition, e.tag, (k = t == null ? void 0 : t.wind) == null ? void 0 : k.kts);
1080
+ let d = h * s * l / 100 * (e.speed - n);
1081
+ d = Math.round(d * 1.943844 * 1e4) / 1e4 * -1, e.tag === "tugs" && Math.abs(d) > 1 && (d = d / (Math.abs(Math.round(d)) + 1)), S == null || S.debug("wind wx factor = %d", d), r = Math.abs(e.bearing % 360 - (((b = (j = t == null ? void 0 : t.wave) == null ? void 0 : j.sig) == null ? void 0 : b.degree) % 360 || 0)), r = r > 180 ? 360 - r : r;
1082
+ const y = Y.waveHeightFactor(((f = (p = t == null ? void 0 : t.wave) == null ? void 0 : p.sig) == null ? void 0 : f.height) ?? 1, r);
1083
+ return S == null || S.debug("wave wx factor = %d", y), d = Math.abs(d) > Math.abs(y) ? d : d * 0.3 + y * 0.7, S == null || S.debug("weather factor = %d", d), d = Math.abs(d) > 3 ? 3 * (Math.abs(d) / d) + Math.abs(d) / d * (Math.abs(d) - 2) * 0.1 : d, Math.round((d || 0) * 100) / 100;
1084
+ }
1085
+ /**
1086
+ * 以12小时级别去掉重复的days
1087
+ * @param days
1088
+ * @param interval 12 hours
1089
+ */
1090
+ static async reduceDays(e, t = 12 * 60 * 60) {
1091
+ return e = e == null ? void 0 : e.reduce((a, i) => (a.some((n) => Math.floor(n.positionTime / t) === Math.floor(i.positionTime / t)) || a.push(i), a), []), e;
1092
+ }
1093
+ /**
1094
+ * 以分钟级别去掉重复的wps
1095
+ * @param wps
1096
+ * @param interval 1 minute
1097
+ */
1098
+ static async reduceWPS(e, t = 60) {
1099
+ return e = e == null ? void 0 : e.reduce((a, i) => (a.some((n) => Math.floor(v(n.etd).unix() / t) === Math.floor(v(i.etd).unix() / t)) || a.push(i), a), []), e;
1084
1100
  }
1085
1101
  /**
1086
1102
  * 全程失速分析(走完航程)
@@ -1095,27 +1111,27 @@ class W {
1095
1111
  * @param useRouteParam
1096
1112
  * @param options
1097
1113
  */
1098
- static async analyseInstant(s, t, a, i, n, o = "", e = 0, r = !0, h = !1, l = {}) {
1099
- var U, G, X, Q, Z, $, tt, et;
1114
+ static async analyseInstant(e, t, a, i, n, o = "", s = 0, r = !0, h = !1, l = {}) {
1115
+ var _, G, X, Q, Z, $;
1100
1116
  const d = v().valueOf();
1101
- s.lng = z.convertToStdLng(s.lng);
1102
- const { route: y, waypoints: w } = n.points, g = V.calculateSubRoute(s, y);
1103
- if (((U = g[0]) == null ? void 0 : U.length) <= 1)
1117
+ e.lng = z.convertToStdLng(e.lng);
1118
+ const { route: y, waypoints: w } = n.points, g = W.calculateSubRoute(e, y);
1119
+ if (((_ = g[0]) == null ? void 0 : _.length) <= 1)
1104
1120
  return;
1105
- const { v0: k, label: j } = s.sog ? {
1106
- v0: s.sog,
1107
- label: s.label || "Other"
1121
+ const { v0: k, label: j } = e.sog ? {
1122
+ v0: e.sog,
1123
+ label: e.label || "Other"
1108
1124
  /* Instruct */
1109
1125
  } : {
1110
1126
  v0: i.speed,
1111
1127
  label: "CP"
1112
1128
  /* Cp */
1113
- }, p = W.assembleProperties(a, i.loadCondition, k, 0), b = w.length ? V.calculateSubWaypoints(s, w) : [];
1114
- b.forEach((x) => x.important = !0);
1129
+ }, b = Y.assembleProperties(a, i.loadCondition, k, 0), p = w.length ? W.calculateSubWaypoints(e, w) : [];
1130
+ p.forEach((A) => A.important = !0);
1115
1131
  const f = {
1116
- from: { ...s },
1132
+ from: { ...e },
1117
1133
  route: g,
1118
- waypoints: b,
1134
+ waypoints: p,
1119
1135
  v0: k,
1120
1136
  label: j
1121
1137
  }, u = {
@@ -1124,16 +1140,16 @@ class W {
1124
1140
  wps: [],
1125
1141
  all: []
1126
1142
  };
1127
- e || (V.calculateRouteDistance(g) / i.speed <= 72 ? e = 3 : e = 6);
1128
- let m = V.simplifyRouteToCoordinates(g, b, 0), c = 0, I = 0, C = 0, F = 0;
1143
+ s || (W.calculateRouteDistance(g) / i.speed <= 72 ? s = 3 : s = 6);
1144
+ let m = W.simplifyRouteToCoordinates(g, p, 0), c = 0, I = 0, C = 0, F = 0;
1129
1145
  t = v(t).utc();
1130
- const Y = t.clone();
1146
+ const P = t.clone();
1131
1147
  for (; m.length > 0; ) {
1132
- const x = e - t.hour() % e, L = Math.ceil(t.clone().add(x, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4, S = await W.speedLoseInHoursStep(
1133
- p,
1148
+ 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, E = await Y.speedLoseInHoursStep(
1149
+ b,
1134
1150
  t,
1135
- Y,
1136
- L,
1151
+ P,
1152
+ V,
1137
1153
  c,
1138
1154
  m,
1139
1155
  o,
@@ -1141,38 +1157,38 @@ class W {
1141
1157
  h,
1142
1158
  l
1143
1159
  );
1144
- if (u.all.push(...S.all), (G = S.from) != null && G.speed && (u.hours.push(S.from), u.wps.push(...S.wps), u.days.push(...S.days)), m = S == null ? void 0 : S.next, !m.length) {
1145
- const q = await W.speedLoseAt(p, S.to, v(S.to.eta), o, 0, r, h, l);
1146
- q.bearing = p.bearing, u.hours.push(q), u.all.push(q);
1160
+ if (u.all.push(...E.all), (G = E.from) != null && G.speed && (u.hours.push(E.from), u.wps.push(...E.wps), u.days.push(...E.days)), m = E == null ? void 0 : E.next, !m.length) {
1161
+ const L = await Y.speedLoseAt(b, E.to, v(E.to.eta), o, 0, r, h, l);
1162
+ L.bearing = b.bearing, u.hours.push(L), u.all.push(L);
1147
1163
  }
1148
- c += Math.round((((X = S == null ? void 0 : S.to) == null ? void 0 : X.distanceFromPrevious) ?? 0) * 1e4) / 1e4;
1164
+ c += Math.round((((X = E == null ? void 0 : E.to) == null ? void 0 : X.distanceFromPrevious) ?? 0) * 1e4) / 1e4;
1149
1165
  }
1150
- const A = u.hours;
1151
- for (let x = 0; x < A.length - 1; x++) {
1152
- const L = v(A[x + 1].eta).diff(A[x].etd, "hour", !0) || 1;
1153
- I += (A[x].wxFactor || 0) * L, C += (A[x].cFactor || 0) * L, F += L;
1166
+ const D = u.hours;
1167
+ for (let A = 0; A < D.length - 1; A++) {
1168
+ const V = v(D[A + 1].eta).diff(D[A].etd, "hour", !0) || 1;
1169
+ I += (D[A].wxFactor || 0) * V, C += (D[A].cFactor || 0) * V, F += V;
1154
1170
  }
1155
- const H = A.reduce((x, L) => x + (L.suspend || 0), 0);
1156
- (Q = u.wps) == null || Q.forEach((x, L) => {
1157
- x.positionTime = v.utc(x.etd || x.eta).unix();
1158
- const S = u.wps[L - 1];
1159
- if (S) {
1160
- const q = x.distanceFromStart - S.distanceFromStart, P = v(x.eta || x.etd).diff(v(S.etd || S.eta), "h", !0);
1161
- x.avgSpd = Math.round(q / P * 100) / 100, S.bearing = V.calculateBearing(S, x);
1171
+ const H = D.reduce((A, V) => A + (V.suspend || 0), 0);
1172
+ (Q = u.wps) == null || Q.forEach((A, V) => {
1173
+ A.positionTime = v.utc(A.etd || A.eta).unix();
1174
+ const E = u.wps[V - 1];
1175
+ if (E) {
1176
+ const L = A.distanceFromStart - E.distanceFromStart, q = v(A.eta || A.etd).diff(v(E.etd || E.eta), "h", !0);
1177
+ A.avgSpd = Math.round(L / q * 100) / 100, E.bearing = W.calculateBearing(E, A);
1162
1178
  }
1163
- }), u.wps = (Z = u.wps) == null ? void 0 : Z.reduce((x, L) => (x.some((S) => Math.round(S.positionTime / 60) === Math.round(L.positionTime / 60)) || x.push(L), x), []), u.days = ($ = u.days) == null ? void 0 : $.reduce((x, L) => (x.some((S) => Math.round(S.positionTime / (60 * 60 * 12)) === Math.round(L.positionTime / (60 * 60 * 12))) || x.push(L), x), []), u.all = (tt = u.all) == null ? void 0 : tt.reduce((x, L) => (L.positionTime = v.utc(L.etd || L.eta).unix(), x.some((S) => Math.round(S.positionTime / 60) === Math.round(L.positionTime / 60)) || x.push(L), x), []), f.sample = u;
1164
- const E = u.hours.at(0), N = u.hours.at(-1);
1165
- f.distance = Math.round(N.distanceFromStart * 1e3) / 1e3, f.etd = v(E.eta).utc().format(), f.eta = v(N.eta).utc().format(), f.wxFactor = Math.round(I / F * 1e3) / 1e3, f.cFactor = Math.round(C / F * 1e3) / 1e3, f.avgSpeed = Math.round(N.distanceFromStart / F * 1e3) / 1e3, f.totalHrs = Math.round(F * 1e3) / 1e3, f.suspend = Math.round(H * 1e3) / 1e3;
1166
- const O = z.roundPrecision(i.dgo / 24 * H, 3), { distanceInECA: R, hoursInECA: J, totalDgoConsInECA: it, eca: st } = await this.calculateECA(f, i, l), at = z.roundPrecision(i.fo / 24 * (F - J), 3), rt = z.roundPrecision(i.dgo / 24 * F + O, 3);
1179
+ }), u.wps = await Y.reduceWPS(u.wps), u.days = await Y.reduceDays(u.days), u.all = (Z = u.all) == null ? void 0 : Z.reduce((A, V) => (V.positionTime = v.utc(V.etd || V.eta).unix(), A.some((E) => Math.round(E.positionTime / 60) === Math.round(V.positionTime / 60)) || A.push(V), A), []), f.sample = u;
1180
+ const T = u.hours.at(0), N = u.hours.at(-1);
1181
+ f.distance = Math.round(N.distanceFromStart * 1e3) / 1e3, f.etd = v(T.eta).utc().format(), f.eta = v(N.eta).utc().format(), f.wxFactor = Math.round(I / F * 1e3) / 1e3, f.cFactor = Math.round(C / F * 1e3) / 1e3, f.avgSpeed = Math.round(N.distanceFromStart / F * 1e3) / 1e3, f.totalHrs = Math.round(F * 1e3) / 1e3, f.suspend = Math.round(H * 1e3) / 1e3;
1182
+ const O = z.roundPrecision(i.dgo / 24 * H, 3), { distanceInECA: R, hoursInECA: K, totalDgoConsInECA: nt, eca: tt } = await this.calculateECA(f, i, l), et = z.roundPrecision(i.fo / 24 * (F - K), 3), ot = z.roundPrecision(i.dgo / 24 * F + O, 3);
1167
1183
  f.extend = {
1168
- eca: st,
1184
+ eca: tt,
1169
1185
  distanceInECA: R,
1170
- hoursInECA: J,
1171
- totalDgoConsInECA: it,
1186
+ hoursInECA: K,
1187
+ totalDgoConsInECA: nt,
1172
1188
  totalDgoConsInSuspend: O
1173
- }, f.totalFoCons = at < 0 ? 0 : at, f.totalDgoCons = rt;
1174
- const nt = v().valueOf() - d, dt = ((et = u == null ? void 0 : u.hours) == null ? void 0 : et.length) || 1;
1175
- return T == null || T.info("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", l == null ? void 0 : l.requestId, nt, dt, Math.round(nt / dt * 1e3) / 1e3), f;
1189
+ }, f.totalFoCons = et < 0 ? 0 : et, f.totalDgoCons = ot;
1190
+ const st = v().valueOf() - d, rt = (($ = u == null ? void 0 : u.hours) == null ? void 0 : $.length) || 1;
1191
+ return S == null || S.info("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", l == null ? void 0 : l.requestId, st, rt, Math.round(st / rt * 1e3) / 1e3), f;
1176
1192
  }
1177
1193
  /**
1178
1194
  * 分段失速分析(最多走hours 小时)
@@ -1189,24 +1205,24 @@ class W {
1189
1205
  * @param useRouteParam
1190
1206
  * @param options
1191
1207
  */
1192
- static async analyseInstantWithThreshed(s, t, a, i, n, o, e, r = "", h = 3, l = !0, d = !1, y = {}) {
1193
- var X, Q, Z, $, tt, et, x, L;
1208
+ static async analyseInstantWithThreshed(e, t, a, i, n, o, s, r = "", h = 3, l = !0, d = !1, y = {}) {
1209
+ var X, Q, Z, $, A, V;
1194
1210
  const w = v().valueOf();
1195
- s.lng = z.convertToStdLng(s.lng);
1196
- const { v0: g, label: k } = s.sog ? {
1197
- v0: s.sog,
1198
- label: s.label || "Other"
1211
+ e.lng = z.convertToStdLng(e.lng);
1212
+ const { v0: g, label: k } = e.sog ? {
1213
+ v0: e.sog,
1214
+ label: e.label || "Other"
1199
1215
  /* Instruct */
1200
1216
  } : {
1201
1217
  v0: n.speed,
1202
1218
  label: "CP"
1203
1219
  /* Cp */
1204
- }, j = W.assembleProperties(i, n.loadCondition, g, 0), p = V.calculateSubRoute(s, o);
1205
- if (((X = p[0]) == null ? void 0 : X.length) <= 1)
1220
+ }, j = Y.assembleProperties(i, n.loadCondition, g, 0), b = W.calculateSubRoute(e, o);
1221
+ if (((X = b[0]) == null ? void 0 : X.length) <= 1)
1206
1222
  return;
1207
- const b = e.length ? V.calculateSubWaypoints(s, e) : [];
1208
- b.forEach((S) => S.important = !0);
1209
- let f = V.simplifyRouteToCoordinates(p, b, 0), u = 0, m = 0, c = 0, I = 0;
1223
+ const p = s.length ? W.calculateSubWaypoints(e, s) : [];
1224
+ p.forEach((E) => E.important = !0);
1225
+ let f = W.simplifyRouteToCoordinates(b, p, 0), u = 0, m = 0, c = 0, I = 0;
1210
1226
  const C = {
1211
1227
  hours: [],
1212
1228
  wps: [],
@@ -1216,52 +1232,52 @@ class W {
1216
1232
  t = v(t).utc();
1217
1233
  const F = t.clone();
1218
1234
  for (; f.length > 0; ) {
1219
- const S = h - t.hour() % h;
1220
- let q = Math.ceil(t.clone().add(S, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4;
1221
- q = t.clone().add(q, "h").isSameOrAfter(a) ? a.diff(t, "h", !0) * 1e4 / 1e4 : q;
1222
- const P = await W.speedLoseInHoursStep(j, t, F, q, u, f, r, l, d, y);
1223
- if (C.all.push(...P.all), (Q = P.from) != null && Q.speed && (C.hours.push(P.from), P != null && P.wps && C.wps.push(...P.wps), C.days.push(...P.days)), f = P == null ? void 0 : P.next, f.length || C.hours.push(P == null ? void 0 : P.to), u += Math.round((((Z = P == null ? void 0 : P.to) == null ? void 0 : Z.distanceFromPrevious) ?? 0) * 1e4) / 1e4, !q)
1235
+ const E = h - t.hour() % h;
1236
+ let L = Math.ceil(t.clone().add(E, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4;
1237
+ L = t.clone().add(L, "h").isSameOrAfter(a) ? a.diff(t, "h", !0) * 1e4 / 1e4 : L;
1238
+ const q = await Y.speedLoseInHoursStep(j, t, F, L, u, f, r, l, d, y);
1239
+ if (C.all.push(...q.all), (Q = q.from) != null && Q.speed && (C.hours.push(q.from), q != null && q.wps && C.wps.push(...q.wps), C.days.push(...q.days)), f = q == null ? void 0 : q.next, f.length || C.hours.push(q == null ? void 0 : q.to), u += Math.round((((Z = q == null ? void 0 : q.to) == null ? void 0 : Z.distanceFromPrevious) ?? 0) * 1e4) / 1e4, !L)
1224
1240
  break;
1225
1241
  }
1226
- C.wps = ($ = C.wps) == null ? void 0 : $.reduce((S, q) => (S.some((P) => Math.round(v(P.etd).unix() / 60) === Math.round(v(q.etd).unix() / 60)) || S.push(q), S), []), C.days = (tt = C.days) == null ? void 0 : tt.reduce((S, q) => (S.some((P) => Math.round(P.positionTime / (60 * 60 * 12)) === Math.round(q.positionTime / (60 * 60 * 12))) || S.push(q), S), []), C.all = (et = C.all) == null ? void 0 : et.reduce((S, q) => (q.positionTime = v.utc(q.etd || q.eta).unix(), S.some((P) => Math.round(v(P.etd).unix() / 60) === Math.round(v(q.etd).unix() / 60)) || S.push(q), S), []), (x = C.wps) == null || x.forEach((S, q) => {
1227
- const P = C.wps[q - 1];
1228
- if (P) {
1229
- const lt = S.distanceFromStart - P.distanceFromStart, mt = v(S.eta || S.etd).diff(v(P.etd || P.eta), "h", !0);
1230
- P.bearing = V.calculateBearing(P, S), S.avgSpd = Math.round(lt / mt * 100) / 100;
1242
+ C.wps = await Y.reduceWPS(C.wps), C.days = await Y.reduceDays(C.days), C.all = ($ = C.all) == null ? void 0 : $.reduce((E, L) => (L.positionTime = v.utc(L.etd || L.eta).unix(), E.some((q) => Math.round(v(q.etd).unix() / 60) === Math.round(v(L.etd).unix() / 60)) || E.push(L), E), []), (A = C.wps) == null || A.forEach((E, L) => {
1243
+ const q = C.wps[L - 1];
1244
+ if (q) {
1245
+ const ut = E.distanceFromStart - q.distanceFromStart, ht = v(E.eta || E.etd).diff(v(q.etd || q.eta), "h", !0);
1246
+ q.bearing = W.calculateBearing(q, E), E.avgSpd = Math.round(ut / ht * 100) / 100;
1231
1247
  }
1232
1248
  });
1233
- const Y = C.hours;
1234
- for (let S = 0; S < Y.length - 1; S++) {
1235
- const q = v(Y[S + 1].eta).diff(Y[S].etd, "hour", !0);
1236
- m += Y[S].wxFactor * q, c += Y[S].cFactor * q, I += q;
1249
+ const P = C.hours;
1250
+ for (let E = 0; E < P.length - 1; E++) {
1251
+ const L = v(P[E + 1].eta).diff(P[E].etd, "hour", !0);
1252
+ m += P[E].wxFactor * L, c += P[E].cFactor * L, I += L;
1237
1253
  }
1238
- const A = Y.reduce((S, q) => S + (q.suspend || 0), 0), H = C.hours.at(0), E = C.hours.at(-1), N = await V.calculateRangeRoute(H, E, p), O = await V.calculateRangeWaypoints(H, E, p, b), R = {
1254
+ const D = P.reduce((E, L) => E + (L.suspend || 0), 0), H = C.hours.at(0), T = C.hours.at(-1), N = await W.calculateRangeRoute(H, T, b), O = await W.calculateRangeWaypoints(H, T, b, p), R = {
1239
1255
  sample: C,
1240
- distance: Math.round(((E == null ? void 0 : E.distanceFromStart) || 0) * 1e4) / 1e4,
1256
+ distance: Math.round(((T == null ? void 0 : T.distanceFromStart) || 0) * 1e4) / 1e4,
1241
1257
  // 注意,可能会在first节点Drift,所有采用eta做为初始出发时间
1242
1258
  etd: v(H.eta).utc().format(),
1243
- eta: v(E == null ? void 0 : E.eta).utc().format(),
1259
+ eta: v(T == null ? void 0 : T.eta).utc().format(),
1244
1260
  wxFactor: Math.round(m / I * 1e3) / 1e3,
1245
1261
  cFactor: Math.round(c / I * 1e3) / 1e3,
1246
- avgSpeed: Math.round(((E == null ? void 0 : E.distanceFromStart) || 0) / I * 1e3) / 1e3,
1262
+ avgSpeed: Math.round(((T == null ? void 0 : T.distanceFromStart) || 0) / I * 1e3) / 1e3,
1247
1263
  totalHrs: Math.round(I * 1e3) / 1e3,
1248
- suspend: Math.round(A * 1e3) / 1e3,
1264
+ suspend: Math.round(D * 1e3) / 1e3,
1249
1265
  from: H,
1250
- to: E,
1266
+ to: T,
1251
1267
  route: N,
1252
1268
  waypoints: O,
1253
1269
  v0: g,
1254
1270
  label: k
1255
- }, J = z.roundPrecision(n.dgo / 24 * A, 3), { distanceInECA: it, hoursInECA: st, totalDgoConsInECA: at, eca: rt } = await this.calculateECA(R, n, y), ct = z.roundPrecision(n.fo / 24 * (I - st), 3), nt = z.roundPrecision(n.dgo / 24 * I + J, 3);
1271
+ }, K = z.roundPrecision(n.dgo / 24 * D, 3), { distanceInECA: nt, hoursInECA: tt, totalDgoConsInECA: et, eca: ot } = await this.calculateECA(R, n, y), it = z.roundPrecision(n.fo / 24 * (I - tt), 3), st = z.roundPrecision(n.dgo / 24 * I + K, 3);
1256
1272
  R.extend = {
1257
- eca: rt,
1258
- distanceInECA: it,
1259
- hoursInECA: st,
1260
- totalDgoConsInECA: at,
1261
- totalDgoConsInSuspend: J
1262
- }, R.totalDgoCons = nt, R.totalFoCons = ct < 0 ? 0 : ct;
1263
- const U = v().valueOf() - w, G = ((L = C == null ? void 0 : C.hours) == null ? void 0 : L.length) || 1;
1264
- return T == null || T.debug("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", y == null ? void 0 : y.requestId, U, G, Math.round(U / G * 1e3) / 1e3), R;
1273
+ eca: ot,
1274
+ distanceInECA: nt,
1275
+ hoursInECA: tt,
1276
+ totalDgoConsInECA: et,
1277
+ totalDgoConsInSuspend: K
1278
+ }, R.totalDgoCons = st, R.totalFoCons = it < 0 ? 0 : it;
1279
+ const _ = v().valueOf() - w, G = ((V = C == null ? void 0 : C.hours) == null ? void 0 : V.length) || 1;
1280
+ return S == null || S.debug("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", y == null ? void 0 : y.requestId, _, G, Math.round(_ / G * 1e3) / 1e3), R;
1265
1281
  }
1266
1282
  /**
1267
1283
  * 在指定航线条件下,基于多CP,动态计算最优成本(租金+油费)方案
@@ -1278,34 +1294,34 @@ class W {
1278
1294
  * @param lane 基础航线(重要转向点)
1279
1295
  * @param options
1280
1296
  */
1281
- static async analyseCost(s, t, a, i, n = {}) {
1282
- var p, b;
1283
- const o = v().valueOf(), e = [];
1284
- s.speedStep = s.speedStep || 3, s.alterStep = s.alterStep ?? 1;
1285
- const r = V.calculateRouteDistance(i.route);
1297
+ static async analyseCost(e, t, a, i, n = {}) {
1298
+ var b, p;
1299
+ const o = v().valueOf(), s = [];
1300
+ e.speedStep = e.speedStep || 3, e.alterStep = e.alterStep ?? 1;
1301
+ const r = W.calculateRouteDistance(i.route);
1286
1302
  let h = 0;
1287
1303
  a.forEach((f) => {
1288
1304
  const u = Math.ceil(r / f.speed / 24);
1289
1305
  h = h < u ? u : h;
1290
1306
  }), h = h * 1.3;
1291
- const l = v.utc(s.etd).add(h ?? 14, "day");
1307
+ const l = v.utc(e.etd).add(h ?? 14, "day");
1292
1308
  let d = 1;
1293
1309
  for (const f of a) {
1294
- const u = JSON.parse(JSON.stringify(i.route)), m = JSON.parse(JSON.stringify(i.waypoints)), c = await W.analyseInstantWithThreshed(
1295
- { lat: s.lat, lng: s.lng },
1296
- s.etd,
1310
+ const u = JSON.parse(JSON.stringify(i.route)), m = JSON.parse(JSON.stringify(i.waypoints)), c = await Y.analyseInstantWithThreshed(
1311
+ { lat: e.lat, lng: e.lng },
1312
+ e.etd,
1297
1313
  l,
1298
1314
  t,
1299
1315
  f,
1300
1316
  u,
1301
1317
  m,
1302
- s.meteoVendor,
1303
- s.speedStep,
1304
- s.useMeteo,
1305
- s.useRouteParam,
1318
+ e.meteoVendor,
1319
+ e.speedStep,
1320
+ e.useMeteo,
1321
+ e.useRouteParam,
1306
1322
  n
1307
1323
  );
1308
- c && (await W.calculateCost(c, f, s, n), e.push(c), T == null || T.info("[%s][L%d-%d] analyse from %s to %s cost: %j", n.requestId, 1, d, s.etd, l.format(), {
1324
+ c && (await Y.calculateCost(c, f, e, n), s.push(c), S == null || S.info("[%s][L%d-%d] analyse from %s to %s cost: %j", n.requestId, 1, d, e.etd, l.format(), {
1309
1325
  cost: c.cost.total,
1310
1326
  hire: c.cost.hire,
1311
1327
  bunker: c.cost.bunker,
@@ -1314,23 +1330,23 @@ class W {
1314
1330
  cp: `${f.speed}/${f.fo}/${f.dgo}`
1315
1331
  })), d++;
1316
1332
  }
1317
- e.sort((f, u) => f.cost.total - u.cost.total);
1318
- const y = e.at(0), w = e.at(1), g = [];
1319
- if (g.push({ combined: !1, speeds: [y], cost: (p = y.cost) == null ? void 0 : p.total }), w) {
1333
+ s.sort((f, u) => f.cost.total - u.cost.total);
1334
+ const y = s.at(0), w = s.at(1), g = [];
1335
+ if (g.push({ combined: !1, speeds: [y], cost: (b = y.cost) == null ? void 0 : b.total }), w) {
1320
1336
  const f = y.cost.cp, u = w.cost.cp, m = v(y.eta), c = v(y.etd), I = m.diff(c, "days", !0);
1321
1337
  let C = Math.ceil(I / 2);
1322
- C = C > 7 ? 7 : C < s.alterStep ? s.alterStep : C;
1323
- let F = 2, Y = { combined: !1, speeds: [w], cost: (b = w.cost) == null ? void 0 : b.total }, A;
1324
- for (; C >= s.alterStep; ) {
1325
- const H = await W.combinedAnalyse(s, t, l, [f, u], i, C, { ...n, level: F });
1326
- if (Y.cost > H.cost ? A ? (A == null ? void 0 : A.cost) > H.cost && (A = H) : (A = Y, Y = H) : (!A || (A == null ? void 0 : A.cost) > H.cost) && (A = H), C <= s.alterStep)
1338
+ C = C > 7 ? 7 : C < e.alterStep ? e.alterStep : C;
1339
+ let F = 2, P = { combined: !1, speeds: [w], cost: (p = w.cost) == null ? void 0 : p.total }, D;
1340
+ for (; C >= e.alterStep; ) {
1341
+ const H = await Y.combinedAnalyse(e, t, l, [f, u], i, C, { ...n, level: F });
1342
+ 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), C <= e.alterStep)
1327
1343
  break;
1328
1344
  C = Math.ceil(C / 2), F += 1;
1329
1345
  }
1330
- g.push(Y), A && g.push(A);
1346
+ g.push(P), D && g.push(D);
1331
1347
  }
1332
1348
  const j = v().valueOf() - o;
1333
- return T == null || T.info("[%s] analyse elapsed: %d ms", n == null ? void 0 : n.requestId, j), g.sort((f, u) => f.cost - u.cost);
1349
+ return S == null || S.info("[%s] analyse elapsed: %d ms", n == null ? void 0 : n.requestId, j), g.sort((f, u) => f.cost - u.cost);
1334
1350
  }
1335
1351
  /**
1336
1352
  * 按步长多次减半,分别用7,4,2,1天步长及cpa,cpb交替计算各种组合下的成本
@@ -1342,22 +1358,22 @@ class W {
1342
1358
  * @param step 步长,7,4,2,1
1343
1359
  * @param options
1344
1360
  */
1345
- static async combinedAnalyse(s, t, a, i, n, o, e = {}) {
1346
- e.counter = 1, T == null || T.info("[%s][L%d] analyse with alternate cp in every %d days", e.requestId, e.level, o);
1347
- const r = await W.alternateAnalyse(s, t, a, i, 0, n, o, e), h = r.reduce((u, m) => u + m.cost.total, 0), l = r.reduce((u, m) => u + m.cost.hire, 0), d = r.reduce((u, m) => u + m.cost.bunker, 0), y = r.reduce((u, m) => u + m.distance, 0), w = r.reduce((u, m) => u + m.totalHrs, 0);
1348
- T == null || T.info("[%s][L%d] cost with cpa/cpb turn: %j", e.requestId, e.level, {
1361
+ static async combinedAnalyse(e, t, a, i, n, o, s = {}) {
1362
+ s.counter = 1, S == null || S.info("[%s][L%d] analyse with alternate cp in every %d days", s.requestId, s.level, o);
1363
+ const r = await Y.alternateAnalyse(e, t, a, i, 0, n, o, s), h = r.reduce((u, m) => u + m.cost.total, 0), l = r.reduce((u, m) => u + m.cost.hire, 0), d = r.reduce((u, m) => u + m.cost.bunker, 0), y = r.reduce((u, m) => u + m.distance, 0), w = r.reduce((u, m) => u + m.totalHrs, 0);
1364
+ S == null || S.info("[%s][L%d] cost with cpa/cpb turn: %j", s.requestId, s.level, {
1349
1365
  cost: h,
1350
1366
  hire: l,
1351
1367
  bunker: d,
1352
1368
  distance: y,
1353
1369
  hours: w
1354
1370
  });
1355
- const g = await W.alternateAnalyse(s, t, a, i, 1, n, o, e), k = g.reduce((u, m) => u + m.cost.total, 0), j = g.reduce((u, m) => u + m.cost.hire, 0), p = g.reduce((u, m) => u + m.cost.bunker, 0), b = g.reduce((u, m) => u + m.distance, 0), f = g.reduce((u, m) => u + m.totalHrs, 0);
1356
- return T == null || T.info("[%s][L%d] cost with cpb/cpa turn: %j", e.requestId, e.level, {
1371
+ const g = await Y.alternateAnalyse(e, t, a, i, 1, n, o, s), k = g.reduce((u, m) => u + m.cost.total, 0), j = g.reduce((u, m) => u + m.cost.hire, 0), b = g.reduce((u, m) => u + m.cost.bunker, 0), p = g.reduce((u, m) => u + m.distance, 0), f = g.reduce((u, m) => u + m.totalHrs, 0);
1372
+ return S == null || S.info("[%s][L%d] cost with cpb/cpa turn: %j", s.requestId, s.level, {
1357
1373
  cost: k,
1358
1374
  hire: j,
1359
- bunker: p,
1360
- distance: b,
1375
+ bunker: b,
1376
+ distance: p,
1361
1377
  hours: f
1362
1378
  }), h < k ? { combined: !0, cost: Math.round(h * 1e3) / 1e3, speeds: r, step: o } : { combined: !0, cost: Math.round(k * 1e3) / 1e3, speeds: g, step: o };
1363
1379
  }
@@ -1372,26 +1388,26 @@ class W {
1372
1388
  * @param step 步长,7,4,2,1
1373
1389
  * @param options
1374
1390
  */
1375
- static async alternateAnalyse(s, t, a, i, n, o, e, r = {}) {
1391
+ static async alternateAnalyse(e, t, a, i, n, o, s, r = {}) {
1376
1392
  var y, w;
1377
- let h = v.utc(s.etd);
1378
- const l = { lat: s.lat, lng: s.lng }, d = [];
1393
+ let h = v.utc(e.etd);
1394
+ const l = { lat: e.lat, lng: e.lng }, d = [];
1379
1395
  for (; h.isBefore(a); ) {
1380
- const g = h.clone().utc().add(e, "day"), k = JSON.parse(JSON.stringify(o.route)), j = JSON.parse(JSON.stringify(o.waypoints)), p = i[n], b = await W.analyseInstantWithThreshed(
1396
+ const g = h.clone().utc().add(s, "day"), k = JSON.parse(JSON.stringify(o.route)), j = JSON.parse(JSON.stringify(o.waypoints)), b = i[n], p = await Y.analyseInstantWithThreshed(
1381
1397
  l,
1382
1398
  h.utc().format(),
1383
1399
  g,
1384
1400
  t,
1385
- p,
1401
+ b,
1386
1402
  k,
1387
1403
  j,
1388
- s.meteoVendor,
1389
- s.speedStep,
1390
- s.useMeteo,
1391
- s.useRouteParam,
1404
+ e.meteoVendor,
1405
+ e.speedStep,
1406
+ e.useMeteo,
1407
+ e.useRouteParam,
1392
1408
  r
1393
1409
  );
1394
- b && (await W.calculateCost(b, p, s, r), T == null || T.info(
1410
+ p && (await Y.calculateCost(p, b, e, r), S == null || S.info(
1395
1411
  "[%s][L%d-%d] analyse from %s to %s cost: %j",
1396
1412
  r.requestId,
1397
1413
  r.level,
@@ -1399,17 +1415,17 @@ class W {
1399
1415
  h.utc().format(),
1400
1416
  g.utc().format(),
1401
1417
  {
1402
- cost: b.cost.total,
1403
- hire: b.cost.hire,
1404
- bunker: b.cost.bunker,
1405
- distance: b.distance,
1406
- hours: b.totalHrs,
1407
- cp: `${p.speed}/${p.fo}/${p.dgo}`
1418
+ cost: p.cost.total,
1419
+ hire: p.cost.hire,
1420
+ bunker: p.cost.bunker,
1421
+ distance: p.distance,
1422
+ hours: p.totalHrs,
1423
+ cp: `${b.speed}/${b.fo}/${b.dgo}`
1408
1424
  }
1409
1425
  )), r.counter = r.counter + 1;
1410
- const f = (w = (y = b == null ? void 0 : b.sample) == null ? void 0 : y.hours) == null ? void 0 : w.at(-1);
1426
+ const f = (w = (y = p == null ? void 0 : p.sample) == null ? void 0 : y.hours) == null ? void 0 : w.at(-1);
1411
1427
  if (f)
1412
- l.lat = f.lat, l.lng = f.lng, h = v(f.eta), d.push(b), n = n ? 0 : 1;
1428
+ l.lat = f.lat, l.lng = f.lng, h = v(f.eta), d.push(p), n = n ? 0 : 1;
1413
1429
  else
1414
1430
  break;
1415
1431
  }
@@ -1422,40 +1438,40 @@ class W {
1422
1438
  * @param props
1423
1439
  * @param options
1424
1440
  */
1425
- static async calculateCost(s, t, a, i = {}) {
1441
+ static async calculateCost(e, t, a, i = {}) {
1426
1442
  var n;
1427
- if (s) {
1428
- const o = (a.addComm || 0) >= 1 ? (a.addComm || 0) / 100 : a.addComm || 0, e = Math.round((a.dailyHire || 0) * (s.suspend || 0) / 24 * 1e3) / 1e3, r = Math.round(s.totalHrs / 24 * (a.dailyHire || 0) * (1 - o) * 1e3) / 1e3 + e, h = Math.round(s.totalFoCons * (a.priceFO || 0) * 1e3) / 1e3, l = Math.round((s.totalDgoCons + (((n = s.extend) == null ? void 0 : n.totalDgoConsInECA) || 0)) * (a.priceDGO || 0) * 1e3) / 1e3;
1429
- s.cost = {
1443
+ if (e) {
1444
+ const o = (a.addComm || 0) >= 1 ? (a.addComm || 0) / 100 : a.addComm || 0, s = Math.round((a.dailyHire || 0) * (e.suspend || 0) / 24 * 1e3) / 1e3, r = Math.round(e.totalHrs / 24 * (a.dailyHire || 0) * (1 - o) * 1e3) / 1e3 + s, h = Math.round(e.totalFoCons * (a.priceFO || 0) * 1e3) / 1e3, l = Math.round((e.totalDgoCons + (((n = e.extend) == null ? void 0 : n.totalDgoConsInECA) || 0)) * (a.priceDGO || 0) * 1e3) / 1e3;
1445
+ e.cost = {
1430
1446
  total: Math.round((r + h + l) * 1e3) / 1e3,
1431
1447
  hire: Math.round(r * 1e3) / 1e3,
1432
- suspendHire: e,
1448
+ suspendHire: s,
1433
1449
  bunker: Math.round((h + l) * 1e3) / 1e3,
1434
1450
  cp: t
1435
1451
  };
1436
1452
  }
1437
- return s;
1453
+ return e;
1438
1454
  }
1439
1455
  /**
1440
1456
  * 计算单cp模式下的ECA属性
1441
1457
  *
1442
1458
  */
1443
- static async calculateECA(s, t, a = {}) {
1459
+ static async calculateECA(e, t, a = {}) {
1444
1460
  var r, h, l, d;
1445
- const i = await V.intersectInECA((s == null ? void 0 : s.route) || []);
1446
- let n = 0, o = 0, e = 0;
1447
- (h = (r = s == null ? void 0 : s.sample) == null ? void 0 : r.wps) == null || h.forEach((y) => {
1461
+ const i = await W.intersectInECA((e == null ? void 0 : e.route) || []);
1462
+ let n = 0, o = 0, s = 0;
1463
+ (h = (r = e == null ? void 0 : e.sample) == null ? void 0 : r.wps) == null || h.forEach((y) => {
1448
1464
  y.positionTime = v.utc(y.etd || y.eta).unix();
1449
1465
  });
1450
1466
  for (const y of i) {
1451
1467
  n += y.distance;
1452
- const w = await V.deadReckoningTime((l = y.waypoints) == null ? void 0 : l.at(0), s.sample.all || s.sample.wps), g = await V.deadReckoningTime((d = y.waypoints) == null ? void 0 : d.at(-1), s.sample.all || s.sample.wps);
1453
- y.in = w, y.out = g, y.totalHrs = z.roundPrecision((g.positionTime - w.positionTime) / 3600, 3), y.totalDgoCons = z.roundPrecision(t.fo / 24 * y.totalHrs, 3), o += y.totalHrs, e += y.totalDgoCons;
1468
+ const w = await W.deadReckoningTime((l = y.waypoints) == null ? void 0 : l.at(0), e.sample.all || e.sample.wps), g = await W.deadReckoningTime((d = y.waypoints) == null ? void 0 : d.at(-1), e.sample.all || e.sample.wps);
1469
+ y.in = w, y.out = g, y.totalHrs = z.roundPrecision((g.positionTime - w.positionTime) / 3600, 3), y.totalDgoCons = z.roundPrecision(t.fo / 24 * y.totalHrs, 3), o += y.totalHrs, s += y.totalDgoCons;
1454
1470
  }
1455
- return n = z.roundPrecision(n, 3), o = z.roundPrecision(o, 3), e = z.roundPrecision(e, 3), {
1471
+ return n = z.roundPrecision(n, 3), o = z.roundPrecision(o, 3), s = z.roundPrecision(s, 3), {
1456
1472
  distanceInECA: n,
1457
1473
  hoursInECA: o,
1458
- totalDgoConsInECA: e,
1474
+ totalDgoConsInECA: s,
1459
1475
  eca: i
1460
1476
  };
1461
1477
  }
@@ -1464,64 +1480,62 @@ class W {
1464
1480
  * @param speeds
1465
1481
  * @param options
1466
1482
  */
1467
- static async mergeSpeeds(s, t = {}) {
1483
+ static async mergeSpeeds(e, t = {}) {
1468
1484
  var f, u;
1469
1485
  const a = {
1470
1486
  hours: [],
1471
1487
  wps: [],
1472
1488
  days: []
1473
- }, i = s.reduce((m, c) => m + c.distance, 0), n = s.reduce((m, c) => {
1489
+ }, i = e.reduce((m, c) => m + c.distance, 0), n = e.reduce((m, c) => {
1474
1490
  var I;
1475
1491
  return m + (((I = c.extend) == null ? void 0 : I.distanceInECA) || 0);
1476
- }, 0), o = s.reduce((m, c) => m + c.totalHrs, 0), e = s.reduce((m, c) => {
1492
+ }, 0), o = e.reduce((m, c) => m + c.totalHrs, 0), s = e.reduce((m, c) => {
1477
1493
  var I;
1478
1494
  return m + (((I = c.extend) == null ? void 0 : I.hoursInECA) || 0);
1479
- }, 0), r = s.reduce((m, c) => {
1495
+ }, 0), r = e.reduce((m, c) => {
1480
1496
  var I;
1481
1497
  return m + (((I = c.extend) == null ? void 0 : I.totalDgoConsInECA) || 0);
1482
- }, 0), h = s.reduce((m, c) => m + c.wxFactor * c.totalHrs / o, 0), l = s.reduce((m, c) => m + c.cFactor * c.totalHrs / o, 0), d = s.reduce((m, c) => m + c.totalFoCons, 0), y = s.reduce((m, c) => m + c.totalDgoCons, 0), w = s.reduce((m, c) => m + c.cost.total, 0), g = s.reduce((m, c) => m + c.cost.hire, 0), k = s.reduce((m, c) => m + c.cost.bunker, 0), j = [], p = [];
1483
- let b;
1484
- for (const m of s) {
1485
- p.push(...((f = m.extend) == null ? void 0 : f.eca) || []);
1498
+ }, 0), h = e.reduce((m, c) => m + c.wxFactor * c.totalHrs / o, 0), l = e.reduce((m, c) => m + c.cFactor * c.totalHrs / o, 0), d = e.reduce((m, c) => m + c.totalFoCons, 0), y = e.reduce((m, c) => m + c.totalDgoCons, 0), w = e.reduce((m, c) => m + c.cost.total, 0), g = e.reduce((m, c) => m + c.cost.hire, 0), k = e.reduce((m, c) => m + c.cost.bunker, 0), j = [], b = [];
1499
+ let p;
1500
+ for (const m of e) {
1501
+ b.push(...((f = m.extend) == null ? void 0 : f.eca) || []);
1486
1502
  const c = m.sample.hours, I = m.sample.wps, C = m.sample.days, F = c.at(0);
1487
- b && (F.distanceFromPrevious = b.distanceFromPrevious, F.distanceFromStart = b.distanceFromStart, c.forEach((E, N) => {
1488
- N && (E.distanceFromStart = E.distanceFromStart + b.distanceFromStart);
1489
- }), I.at(0).distanceFromPrevious = b.distanceFromPrevious, I.at(0).distanceFromStart = b.distanceFromStart, I.forEach((E, N) => {
1490
- N && (E.distanceFromStart = E.distanceFromStart + b.distanceFromStart);
1491
- }), C.at(0).distanceFromPrevious = b.distanceFromPrevious, C.at(0).distanceFromStart = b.distanceFromStart, C.forEach((E, N) => {
1492
- N && (E.distanceFromStart = E.distanceFromStart + b.distanceFromStart);
1503
+ p && (F.distanceFromPrevious = p.distanceFromPrevious, F.distanceFromStart = p.distanceFromStart, c.forEach((T, N) => {
1504
+ N && (T.distanceFromStart = T.distanceFromStart + p.distanceFromStart);
1505
+ }), I.at(0).distanceFromPrevious = p.distanceFromPrevious, I.at(0).distanceFromStart = p.distanceFromStart, I.forEach((T, N) => {
1506
+ N && (T.distanceFromStart = T.distanceFromStart + p.distanceFromStart);
1507
+ }), C.at(0).distanceFromPrevious = p.distanceFromPrevious, C.at(0).distanceFromStart = p.distanceFromStart, C.forEach((T, N) => {
1508
+ N && (T.distanceFromStart = T.distanceFromStart + p.distanceFromStart);
1493
1509
  })), F.cp = m.cost.cp;
1494
- const Y = [m.etd, m.eta], A = j.findIndex((E) => E.id === F.cp.id);
1495
- A === -1 ? (F.cp.segment = [Y], j.push(F.cp)) : j[A].segment.push(Y), c.forEach((E) => {
1510
+ const P = [m.etd, m.eta], D = j.findIndex((T) => T.id === F.cp.id);
1511
+ D === -1 ? (F.cp.segment = [P], j.push(F.cp)) : j[D].segment.push(P), c.forEach((T) => {
1496
1512
  var O;
1497
- ((O = a.hours) == null ? void 0 : O.findIndex((R) => R.eta === E.eta)) === -1 && a.hours.push(E);
1498
- }), I.forEach((E) => {
1513
+ ((O = a.hours) == null ? void 0 : O.findIndex((R) => R.eta === T.eta)) === -1 && a.hours.push(T);
1514
+ }), I.forEach((T) => {
1499
1515
  var O;
1500
- ((O = a.wps) == null ? void 0 : O.findIndex((R) => R.eta === E.eta)) === -1 && a.wps.push(E);
1501
- }), C.forEach((E) => {
1516
+ ((O = a.wps) == null ? void 0 : O.findIndex((R) => R.eta === T.eta)) === -1 && a.wps.push(T);
1517
+ }), C.forEach((T) => {
1502
1518
  var O;
1503
- ((O = a == null ? void 0 : a.days) == null ? void 0 : O.findIndex((R) => R.eta === E.eta)) === -1 && a.days.push(E);
1519
+ ((O = a == null ? void 0 : a.days) == null ? void 0 : O.findIndex((R) => R.eta === T.eta)) === -1 && a.days.push(T);
1504
1520
  });
1505
- const H = (u = a.wps) == null ? void 0 : u.findIndex((E) => E.eta === F.eta);
1506
- H === -1 ? a.wps.push(F) : a.wps[H] = F, b = c.at(-1);
1521
+ const H = (u = a.wps) == null ? void 0 : u.findIndex((T) => T.eta === F.eta);
1522
+ H === -1 ? a.wps.push(F) : a.wps[H] = F, p = c.at(-1);
1507
1523
  }
1508
- return a.wps.sort((m, c) => {
1509
- v(m.etd).unix() - v(c.etd).unix();
1510
- }), a.wps.forEach((m, c) => {
1524
+ return a.wps.sort((m, c) => v(m.etd).unix() - v(c.etd).unix()), a.wps.forEach((m, c) => {
1511
1525
  const I = a.wps[c - 1];
1512
1526
  if (I) {
1513
- const C = m.distanceFromStart - (I.distanceFromStart || 0), F = v(m.eta || m.etd).diff(v(I.etd || I.eta), "hour", !0), Y = Math.round(C / F * 100) / 100;
1514
- m.avgSpd = Y;
1515
- const A = V.calculateBearing(I, m);
1516
- I.bearing = A;
1527
+ const C = m.distanceFromStart - (I.distanceFromStart || 0), F = v(m.eta || m.etd).diff(v(I.etd || I.eta), "hour", !0), P = Math.round(C / F * 100) / 100;
1528
+ m.avgSpd = P;
1529
+ const D = W.calculateBearing(I, m);
1530
+ I.bearing = D;
1517
1531
  }
1518
1532
  }), {
1519
1533
  sample: a,
1520
- etd: s.at(0).etd,
1521
- eta: s.at(-1).eta,
1522
- from: s.at(0).from,
1523
- to: s.at(-1).to,
1524
- v0: s.at(0).v0,
1534
+ etd: e.at(0).etd,
1535
+ eta: e.at(-1).eta,
1536
+ from: e.at(0).from,
1537
+ to: e.at(-1).to,
1538
+ v0: e.at(0).v0,
1525
1539
  label: "Combined",
1526
1540
  distance: Math.round(i * 1e3) / 1e3,
1527
1541
  totalHrs: Math.round(o * 1e3) / 1e3,
@@ -1537,26 +1551,26 @@ class W {
1537
1551
  },
1538
1552
  extend: {
1539
1553
  cps: j,
1540
- eca: p,
1554
+ eca: b,
1541
1555
  distanceInECA: Math.round(n * 1e3) / 1e3,
1542
- hoursInECA: Math.round(e * 1e3) / 1e3,
1556
+ hoursInECA: Math.round(s * 1e3) / 1e3,
1543
1557
  totalDgoConsInECA: Math.round(r * 1e3) / 1e3,
1544
- speeds: s
1558
+ speeds: e
1545
1559
  }
1546
1560
  };
1547
1561
  }
1548
1562
  }
1549
1563
  export {
1550
- ot as AISImpl,
1551
- pt as AlertHelper,
1552
- gt as AlertLevel,
1553
- xt as HifleetImpl,
1554
- wt as LoadCondition,
1555
- At as MyShipImpl,
1556
- Nt as MyVesselImpl,
1557
- Dt as ShipxyImpl,
1558
- W as SpeedHelper,
1559
- kt as SpeedLabel,
1560
- vt as VesselTag,
1561
- Pt as alertHelper
1564
+ at as AISImpl,
1565
+ Mt as AlertHelper,
1566
+ yt as AlertLevel,
1567
+ Ft as HifleetImpl,
1568
+ pt as LoadCondition,
1569
+ xt as MyShipImpl,
1570
+ Tt as MyVesselImpl,
1571
+ Nt as ShipxyImpl,
1572
+ Y as SpeedHelper,
1573
+ vt as SpeedLabel,
1574
+ bt as VesselTag,
1575
+ Dt as alertHelper
1562
1576
  };