@idm-plugin/vessel 3.4.6 → 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 mt = Object.defineProperty;
2
- var ft = (x, s, t) => s in x ? mt(x, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : x[s] = t;
3
- var K = (x, s, t) => (ft(x, 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 ut 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 yt } from "@idm-plugin/meteo2";
9
- import { Meteo2Assist as dt } 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 = ut.getLogger("vessel");
12
+ M = dt.getLogger("vessel");
13
13
  } catch {
14
14
  } finally {
15
15
  }
16
- class nt {
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 nt {
54
54
  return { labelCn: t, labelEn: a };
55
55
  }
56
56
  }
57
- class Ft extends nt {
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 Ft extends nt {
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,
@@ -120,16 +120,16 @@ class Ft extends nt {
120
120
  * @param options
121
121
  */
122
122
  async search(t, a = {}) {
123
- var u, l;
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
- Authorization: `${(u = this.token) == null ? void 0 : u.tokenType} ${(l = this.token) == null ? void 0 : l.accessToken}`
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 Ft extends nt {
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
@@ -177,11 +177,11 @@ class Ft extends nt {
177
177
  return o.status !== 200 ? (M == null || M.warn("[%s] fetch vessel archive failed: %j", a.requestId, { message: o.message, status: o.status, code: o.code }), {}) : o.data;
178
178
  }
179
179
  async realTimePosition(t, a = {}) {
180
- var r, u;
180
+ var r, h;
181
181
  await this.checkToken(a);
182
182
  const i = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/location/unit", n = {
183
183
  headers: {
184
- Authorization: `${(r = this.token) == null ? void 0 : r.tokenType} ${(u = this.token) == null ? void 0 : u.accessToken}`
184
+ Authorization: `${(r = this.token) == null ? void 0 : r.tokenType} ${(h = this.token) == null ? void 0 : h.accessToken}`
185
185
  },
186
186
  searchParams: { mmsi: t }
187
187
  };
@@ -189,38 +189,38 @@ class Ft extends nt {
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,11 +236,11 @@ class Ft extends nt {
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);
243
- const u = "https://svc.data.myvessel.cn/sdc/v1/routes/routing/nodes", l = {
242
+ await this.checkToken(s);
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}`
246
246
  },
@@ -253,16 +253,16 @@ class Ft extends nt {
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, u, l);
263
- const d = await B.post(u, l).json();
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
+ 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,8 +273,8 @@ class Ft extends nt {
273
273
  route: [],
274
274
  distance: 0,
275
275
  memo: ""
276
- }, { nodes: E, seas: b, tracks: p, specialRegions: f } = d.data;
277
- k.nodes = E == null ? void 0 : E.map((c) => ({
276
+ }, { nodes: j, seas: b, tracks: p, specialRegions: f } = d.data;
277
+ k.nodes = j == null ? void 0 : j.map((c) => ({
278
278
  code: c.nodeCode,
279
279
  nameEn: c.nameEn,
280
280
  nameCn: c.nameCn,
@@ -329,21 +329,21 @@ class Ft extends nt {
329
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), u = v(a), l = v(i), d = [];
340
- for (; l.diff(u, "day", !0) > 30; )
341
- await this.trajectoryIn30Day(t, u, u.clone().add(30, "day"), r, n, d, e), u.add(30, "day");
342
- return await this.trajectoryIn30Day(t, u, l, r, n, d, e), 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
+ for (; l.diff(h, "day", !0) > 30; )
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, E, b, p;
346
- const u = "https://svc.data.myvessel.cn/sdc/v1/vessels/status/track", l = {
344
+ async trajectoryIn30Day(t, a, i, n, o, s, r = {}) {
345
+ var g, k, j, b, p;
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}`
349
349
  },
@@ -353,16 +353,16 @@ class Ft extends nt {
353
353
  endTime: i.utcOffset(8).format("YYYY-MM-DD HH:mm:ss")
354
354
  }
355
355
  };
356
- M == null || M.info("[%s] fetch trajectory from: %s - %j", r.requestId, u, l);
357
- const d = await B.post(u, l).json();
356
+ M == null || M.info("[%s] fetch trajectory from: %s - %j", r.requestId, h, l);
357
+ const d = await B.post(h, l).json();
358
358
  if (d.code)
359
- return M == null || M.warn("[%s] fetch trajectory failed: %j", r.requestId, u, { message: d.message, status: d.status, code: d.code }), d;
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(`${(b = (E = d.data) == null ? void 0 : E[0]) == null ? void 0 : b.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00");
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
362
  return (p = d.data) == null || p.forEach((f) => {
363
- for (const q in f)
364
- !isNaN(f[q]) && Number(f[q]) !== 1 / 0 && (f[q] = Number(f[q]));
365
- const h = v(`${f.postime} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00"), m = f.status, { labelCn: c, labelEn: I } = this.parseStatus(m), C = {
363
+ for (const P in f)
364
+ !isNaN(f[P]) && Number(f[P]) !== 1 / 0 && (f[P] = Number(f[P]));
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,
368
368
  lat: f.lat,
@@ -374,21 +374,21 @@ class Ft extends nt {
374
374
  status: m,
375
375
  eta: /\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(f.eta) ? v(`${f.eta} +08:00`, "YYYY-MM-DD HH:mm:ss +08:00").utc().format() : void 0,
376
376
  destination: f.dest,
377
- positionTime: h.unix(),
377
+ positionTime: u.unix(),
378
378
  labelCn: c,
379
379
  labelEn: I,
380
380
  method: "trajectory",
381
381
  vendor: "myVessel",
382
- utc: h.utc().format()
383
- }, F = Math.floor(h.diff(w, "minute", !0) / (o || 1));
384
- F !== y && (y = F, e.push(C));
385
- }), e;
382
+ utc: u.utc().format()
383
+ }, F = Math.floor(u.diff(w, "minute", !0) / (o || 1));
384
+ F !== y && (y = F, s.push(C));
385
+ }), s;
386
386
  }
387
387
  }
388
- class Nt extends nt {
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,37 +399,37 @@ class Nt extends nt {
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: u, 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,
432
- labelCn: u,
432
+ labelCn: h,
433
433
  labelEn: l,
434
434
  method: "position",
435
435
  vendor: "hifleet"
@@ -451,7 +451,7 @@ class Nt extends nt {
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 Nt extends nt {
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,38 +475,38 @@ class Nt extends nt {
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, u) => u.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 = {}) {
490
- var f, h, m;
491
- const r = await this.realTimePosition(t, e);
492
- let u = v(a);
489
+ async trajectory(t, a, i, n, o = !0, s = {}) {
490
+ var f, u, m;
491
+ const r = await this.realTimePosition(t, s);
492
+ let h = v(a);
493
493
  const l = v(i), d = v();
494
494
  if (o) {
495
- let c = l.diff(u, "d", !0);
496
- c < 0 ? u = l.clone().subtract(40, "d") : c < 30 ? u.subtract(10, "d") : c < 60 ? u.subtract(5, "d") : u = l.clone().subtract(80, "d"), c = d.diff(l, "d", !0), l.add(c > 10 ? 240 : c * 24, "h");
495
+ let c = l.diff(h, "d", !0);
496
+ c < 0 ? h = l.clone().subtract(40, "d") : c < 30 ? h.subtract(10, "d") : c < 60 ? h.subtract(5, "d") : h = l.clone().subtract(80, "d"), c = d.diff(l, "d", !0), l.add(c > 10 ? 240 : c * 24, "h");
497
497
  }
498
498
  const y = {
499
499
  searchParams: {
500
500
  endtime: l.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),
501
- starttime: u.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),
501
+ starttime: h.utcOffset("+8:00").format("YYYY-MM-DD HH:mm:ss"),
502
502
  mmsi: t,
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 = ((h = (f = g.ships) == null ? void 0 : f.offors) == null ? void 0 : h.ship) || [], k.length || M == null || M.warn("[%s] fetch trajectory failed: %j", e.requestId, g));
509
- const E = [];
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
+ const j = [];
510
510
  let b = -1;
511
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) {
@@ -514,7 +514,7 @@ class Nt extends nt {
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), q = {
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,
@@ -532,15 +532,15 @@ class Nt extends nt {
532
532
  method: "trajectory",
533
533
  vendor: "hifleet"
534
534
  }, D = Math.floor(I.diff(p, "minute", !0) / (n || 1));
535
- D !== b && (b = D, E.push(q));
535
+ D !== b && (b = D, j.push(P));
536
536
  }
537
- return E;
537
+ return j;
538
538
  }
539
539
  }
540
- class xt extends nt {
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,71 +553,71 @@ class xt extends nt {
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: u } = 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,
577
- labelEn: u,
576
+ status: s.navistat,
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 = {}) {
583
+ async trajectory(t, a, i, n, o = !0, s = {}) {
584
584
  var p;
585
- const r = await this.realTimePosition(t, e), u = v(a), l = v(i), d = "https://api.shipxy.com/apicall/GetShipTrack", y = {
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,
589
589
  enc: 1,
590
590
  cut: 0,
591
- btm: u.unix(),
591
+ btm: h.unix(),
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 = [], E = v.unix((p = g[0]) == null ? void 0 : p.utc);
597
+ const g = w == null ? void 0 : w.points, k = [], j = v.unix((p = g[0]) == null ? void 0 : p.utc);
598
598
  let b = -1;
599
599
  for (const f of g) {
600
- const h = v.unix(f.utc), m = {
600
+ const u = v.unix(f.utc), m = {
601
601
  imo: r == null ? void 0 : r.imo,
602
602
  mmsi: t,
603
603
  sog: Math.round(f.sog * 3600 / 1e3 / 1852 * 100) / 100,
604
604
  cog: Math.round(f.cog / 100 * 100) / 100,
605
605
  lat: Math.round(f.lat / 1e6 * 1e5) / 1e5,
606
606
  lng: Math.round(f.lon / 1e6 * 1e5) / 1e5,
607
- positionTime: h.unix(),
608
- utc: h.utc().format(),
607
+ positionTime: u.unix(),
608
+ utc: u.utc().format(),
609
609
  method: "trajectory",
610
610
  vendor: "shipxy"
611
- }, c = Math.floor(h.diff(E, "minute", !0) / (n || 1));
611
+ }, c = Math.floor(u.diff(j, "minute", !0) / (n || 1));
612
612
  c !== b && (b = c, k.push(m));
613
613
  }
614
614
  return k;
615
615
  }
616
616
  }
617
- class Dt extends nt {
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 Dt extends nt {
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,38 +662,38 @@ class Dt extends nt {
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);
667
- const u = r.data[0];
668
- for (const g in u)
669
- !isNaN(u[g]) && Number(u[g]) !== 1 / 0 && (u[g] = Number(u[g]));
670
- const { labelCn: l, labelEn: d } = await this.parseStatus(u.aisNavStatus), y = v.unix(u.posTime);
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
+ const h = r.data[0];
668
+ for (const g in h)
669
+ !isNaN(h[g]) && Number(h[g]) !== 1 / 0 && (h[g] = Number(h[g]));
670
+ const { labelCn: l, labelEn: d } = await this.parseStatus(h.aisNavStatus), y = v.unix(h.posTime);
671
671
  return {
672
672
  ...n,
673
673
  mmsi: t,
674
- lat: Math.round(u.lat / 1e4 / 60 * 1e5) / 1e5,
675
- lng: Math.round(u.lon / 1e4 / 60 * 1e5) / 1e5,
676
- sog: Math.round(u.sog / 10 * 100) / 100,
677
- cog: Math.round(u.cog / 10 * 100) / 100,
678
- hdg: Math.round(u.heading * 100) / 100,
679
- rot: Math.round(u.rot * 100) / 100,
680
- positionTime: u.posTime,
674
+ lat: Math.round(h.lat / 1e4 / 60 * 1e5) / 1e5,
675
+ lng: Math.round(h.lon / 1e4 / 60 * 1e5) / 1e5,
676
+ sog: Math.round(h.sog / 10 * 100) / 100,
677
+ cog: Math.round(h.cog / 10 * 100) / 100,
678
+ hdg: Math.round(h.heading * 100) / 100,
679
+ rot: Math.round(h.rot * 100) / 100,
680
+ positionTime: h.posTime,
681
681
  utc: y.utc().format(),
682
- status: u.aisNavStatus,
682
+ status: h.aisNavStatus,
683
683
  labelEn: d,
684
684
  labelCn: l,
685
685
  method: "position",
686
686
  vendor: "myship"
687
687
  };
688
688
  }
689
- async trajectory(t, a, i, n, o = !0, e = {}) {
690
- const r = v(a), u = v(i), l = await this.getShipId(t), d = await this.getShipInfo(l), y = [];
691
- for (; u.diff(r, "day", !0) > 30; )
689
+ async trajectory(t, a, i, n, o = !0, s = {}) {
690
+ const r = v(a), h = v(i), l = await this.getShipId(t), d = await this.getShipInfo(l), y = [];
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
- return await this.trajectoryIn30Day(l, r.unix(), u.unix(), d, t, n, y), y;
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, u = {}) {
696
- var E;
695
+ async trajectoryIn30Day(t, a, i, n, o, s, r, h = {}) {
696
+ var j;
697
697
  const l = {
698
698
  headers: {
699
699
  appKey: this.token
@@ -704,12 +704,12 @@ class Dt extends nt {
704
704
  endTime: i
705
705
  }
706
706
  }, d = "https://api3.myships.com/sp/ships/position/history", y = await B.post(d, l).json();
707
- if (M == null || M.info("[%s] fetch trajectory from: %s - %j", u.requestId, d, l), y.code !== "0")
708
- return M == null || M.warn("[%s] invoke myship trajectory failed: %j", u.requestId, y), y;
707
+ if (M == null || M.info("[%s] fetch trajectory from: %s - %j", h.requestId, d, l), y.code !== "0")
708
+ return M == null || M.warn("[%s] invoke myship trajectory failed: %j", h.requestId, y), y;
709
709
  const w = y.data;
710
710
  for (const b in w)
711
711
  !isNaN(w[b]) && Number(w[b]) !== 1 / 0 && (w[b] = Number(w[b]));
712
- const g = v.unix((E = w[0]) == null ? void 0 : E.posTime);
712
+ const g = v.unix((j = w[0]) == null ? void 0 : j.posTime);
713
713
  let k = -1;
714
714
  for (const b of w) {
715
715
  const p = v.unix(b.posTime), f = {
@@ -725,20 +725,20 @@ class Dt extends nt {
725
725
  utc: p.utc().format(),
726
726
  method: "trajectory",
727
727
  vendor: "myship"
728
- }, h = Math.floor(p.diff(g, "minute", !0) / (e || 1));
729
- h !== k && (k = h, r.push(f));
728
+ }, u = Math.floor(p.diff(g, "minute", !0) / (s || 1));
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
- _ = ut.getLogger("vessel");
736
+ J = dt.getLogger("vessel");
737
737
  } catch {
738
738
  } finally {
739
739
  }
740
- var Mt = /* @__PURE__ */ ((x) => (x.NOTICE = "NOTICE", x.WARN = "WARN", x.HEAVY = "HEAVY", x.SEVERE = "SEVERE", x.ERROR = "ERROR", x.FATAL = "FATAL", x))(Mt || {});
741
- class gt {
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,15 +747,15 @@ class gt {
747
747
  *
748
748
  * @param options
749
749
  */
750
- parsePrinciple(s, t = {}) {
751
- var e, r, u;
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 = {};
757
757
  for (let l = 0; l < (n == null ? void 0 : n.length); l++) {
758
- const d = (u = (r = n[l].match(a)) == null ? void 0 : r[0]) == null ? void 0 : u.split("],");
758
+ const d = (h = (r = n[l].match(a)) == null ? void 0 : r[0]) == null ? void 0 : h.split("],");
759
759
  if (l === 0 && !d)
760
760
  o.scope = n[0];
761
761
  else if (d)
@@ -772,17 +772,17 @@ class gt {
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 gt {
793
793
  * @param principle 告警规则
794
794
  * @param options
795
795
  */
796
- checkWeather(s, t, a = {}) {
797
- var g, k, E, b, p, f, h, m, c, I, C, F, q, D, 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, u = (b = (E = t == null ? void 0 : t.SEVERE) == null ? void 0 : E.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 = (h = t == null ? void 0 : t.SEVERE) == null ? void 0 : h.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 < (s == null ? void 0 : s.length); T++) {
801
- const N = s[T], L = (D = (q = N == null ? void 0 : N.meteo) == null ? void 0 : q.wave) == null ? void 0 : D.sig, O = (H = N == null ? void 0 : N.meteo) == null ? void 0 : H.wind, J = T ? v(N.eta).diff(v(s[T - 1].eta), "hour", !0) : 0;
802
- e = J > e ? J : e, _ == null || _.debug("[%s] check sig.wave: %j", a.requestId, { ...L, dgThd4Wv: r, svThd4Wv: u, hvThd4Wv: l }), (L == null ? void 0 : L.height) >= r ? N.isDangerous = !0 : (L == null ? void 0 : L.height) >= u ? N.isSevere = !0 : (L == null ? void 0 : L.height) >= l && (N.isHeavy = !0), _ == null || _.debug("[%s] check wind: %j", a.requestId, { ...O, dgThd4Wd: d, svThd4Wd: y, hvThd4Wd: w }), (O == null ? void 0 : O.scale) >= d ? (N.isDangerous = !0, delete N.isSevere, delete N.isHeavy) : (O == null ? void 0 : O.scale) > y ? (N.isDangerous || (N.isSevere = !0), delete N.isHeavy) : (O == null ? void 0 : O.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: u, 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 At = new gt();
808
- let j;
807
+ const Dt = new Mt();
808
+ let S;
809
809
  try {
810
- j = ut.getLogger("vessel");
810
+ S = dt.getLogger("vessel");
811
811
  } catch {
812
812
  } finally {
813
813
  }
814
- const bt = new yt("", !0);
815
- var pt = /* @__PURE__ */ ((x) => (x.common = "common", x.container = "container", x.tugs = "tugs", x))(pt || {}), vt = /* @__PURE__ */ ((x) => (x.Ballast = "Ballast", x.Laden = "Laden", x))(vt || {}), wt = /* @__PURE__ */ ((x) => (x.Cp = "CP", x.Perf = "Basis", x.Instruct = "Other", x))(wt || {});
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, u = ((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
- tag: u.indexOf("container") > -1 ? "container" : u.indexOf("tugs") > -1 ? "tugs" : "common",
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,41 +953,41 @@ 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 = {}) {
957
- let u;
958
- if (t.velocity && e && (s.speed = z.roundPrecision(t.velocity * 1852 / 3600, 6)), o) {
956
+ static async speedLoseAt(e, t, a, i = "", n = 2, o = !0, s = !1, r = {}) {
957
+ let h;
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 dt.autoPickMeteoModel(i), E = 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
- }), [b] = dt.pickHourly(E, a);
969
- l = dt.toLegacy(b);
968
+ }), [b] = ct.pickHourly(j, a);
969
+ l = ct.toLegacy(b);
970
970
  } catch (g) {
971
- j.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;
974
- u = {
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
+ 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
  };
982
982
  } else
983
- u = {
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
  };
990
- return delete t.meteo, delete t.wxFactor, delete t.cFactor, delete t.speed, delete t.etd, { ...u, ...t };
990
+ return delete t.meteo, delete t.wxFactor, delete t.cFactor, delete t.speed, delete t.etd, { ...h, ...t };
991
991
  }
992
992
  /**
993
993
  * 基于步长计算失速样本
@@ -1003,49 +1003,49 @@ class W {
1003
1003
  * @param options
1004
1004
  * @private
1005
1005
  */
1006
- static async speedLoseInHoursStep(s, t, a, i, n, o, e = "", r = !0, u = !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, E = 0, b, p;
1009
+ let k = 0, j = 0, b, p;
1010
1010
  for (let f = 0; f < o.length - 1; f++) {
1011
- let h = o[f];
1012
- h.distanceFromStart = Math.round((n + E) * 1e3) / 1e3;
1011
+ let u = o[f];
1012
+ u.distanceFromStart = Math.round((n + j) * 1e3) / 1e3;
1013
1013
  const m = o[f + 1];
1014
- if (s.bearing = V.calculateBearing(h, m, !m.gcToPrevious), h.bearing = s.bearing, h.suspend && u) {
1015
- h.eta = h.eta || t.utc().format(), h.elapsed = h.elapsed ?? 0;
1016
- const C = h.suspend - h.elapsed;
1014
+ if (e.bearing = W.calculateBearing(u, m, !m.gcToPrevious), u.bearing = e.bearing, u.suspend && h) {
1015
+ u.eta = u.eta || t.utc().format(), u.elapsed = u.elapsed ?? 0;
1016
+ const C = u.suspend - u.elapsed;
1017
1017
  if (i - k > C)
1018
- i = i - k - C, t.add(C, "hour"), h.elapsed = h.suspend;
1018
+ i = i - k - C, t.add(C, "hour"), u.elapsed = u.suspend;
1019
1019
  else {
1020
1020
  const F = i - k;
1021
- h.elapsed += F, t.add(F, "hour"), i = 0;
1021
+ u.elapsed += F, t.add(F, "hour"), i = 0;
1022
1022
  }
1023
- if (j == null || j.info(`[%s] suspend ${h.elapsed} hours at %j, and remain ${i} hours need to go...`, l.requestId, h), i === 0)
1024
- return h.distanceFromPrevious = E, { etd: t, from: p || h, to: h, 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
- h.suspend = 0;
1027
- r = t.isAfter(d) ? !1 : r, h = await W.speedLoseAt(s, h, t, e, 0, r, u, l), g.push(h), p = p || h, h.important && y.push(h), t.isSameOrAfter(a) && (w.push(h), a.add(24, "hour"));
1028
- const c = V.calculateDistance(h, m, !m.gcToPrevious);
1026
+ u.suspend = 0;
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
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], j == null || j.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
1035
  { lat: p.lat, lng: p.lng, etd: p.etd }
1036
- ), E += c, o.filter((C) => C).length <= 1) {
1037
- b = m, b.eta = t.utc().format(), b.distanceFromPrevious = c, b.distanceFromStart = Math.round((n + E) * 1e4) / 1e4, y.push(b), g.push(b), delete o[f + 1];
1036
+ ), j += c, o.filter((C) => C).length <= 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
1042
  const C = z.roundPrecision(p.speed * I, 5);
1043
- b = V.calculateCoordinate(h, s.bearing, C, "nauticalmiles", !m.gcToPrevious), b.eta = t.utc().format(), o[f] = b, j == null || j.debug(
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
1046
  { lat: b.lat, lng: b.lng },
1047
- { lat: h.lat, lng: h.lng, etd: h.etd }
1048
- ), E += C, b.distanceFromPrevious = Math.round(E * 1e4) / 1e4, b.distanceFromStart = Math.round((n + E) * 1e4) / 1e4;
1047
+ { lat: u.lat, lng: u.lng, etd: u.etd }
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
  }
@@ -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, E, b, p, f;
1075
- j == null || j.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 u = 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 = u * 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)), j == null || j.debug("wind wx factor = %d", d), r = Math.abs(s.bearing % 360 - (((b = (E = t == null ? void 0 : t.wave) == null ? void 0 : E.sig) == null ? void 0 : b.degree) % 360 || 0)), r = r > 180 ? 360 - r : r;
1082
- const y = W.waveHeightFactor(((f = (p = t == null ? void 0 : t.wave) == null ? void 0 : p.sig) == null ? void 0 : f.height) ?? 1, r);
1083
- return j == null || j.debug("wave wx factor = %d", y), d = Math.abs(d) > Math.abs(y) ? d : d * 0.3 + y * 0.7, j == null || j.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,84 +1111,84 @@ 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, u = !1, l = {}) {
1099
- var U, G, X, Q, Z, $, tt;
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: E } = 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
- }, b = W.assembleProperties(a, i.loadCondition, k, 0), p = w.length ? V.calculateSubWaypoints(s, w) : [];
1129
+ }, b = Y.assembleProperties(a, i.loadCondition, k, 0), p = w.length ? W.calculateSubWaypoints(e, w) : [];
1114
1130
  p.forEach((A) => A.important = !0);
1115
1131
  const f = {
1116
- from: { ...s },
1132
+ from: { ...e },
1117
1133
  route: g,
1118
1134
  waypoints: p,
1119
1135
  v0: k,
1120
- label: E
1121
- }, h = {
1136
+ label: j
1137
+ }, u = {
1122
1138
  hours: [],
1123
1139
  days: [],
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, p, 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 q = t.clone();
1146
+ const P = t.clone();
1131
1147
  for (; m.length > 0; ) {
1132
- const A = e - t.hour() % e, R = Math.ceil(t.clone().add(A, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4, S = await W.speedLoseInHoursStep(
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(
1133
1149
  b,
1134
1150
  t,
1135
- q,
1136
- R,
1151
+ P,
1152
+ V,
1137
1153
  c,
1138
1154
  m,
1139
1155
  o,
1140
1156
  r,
1141
- u,
1157
+ h,
1142
1158
  l
1143
1159
  );
1144
- if (h.all.push(...S.all), (G = S.from) != null && G.speed && (h.hours.push(S.from), h.wps.push(...S.wps), h.days.push(...S.days)), m = S == null ? void 0 : S.next, !m.length) {
1145
- const Y = await W.speedLoseAt(b, S.to, v(S.to.eta), o, 0, r, u, l);
1146
- Y.bearing = b.bearing, h.hours.push(Y), h.all.push(Y);
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 D = h.hours;
1166
+ const D = u.hours;
1151
1167
  for (let A = 0; A < D.length - 1; A++) {
1152
- const R = v(D[A + 1].eta).diff(D[A].etd, "hour", !0) || 1;
1153
- I += (D[A].wxFactor || 0) * R, C += (D[A].cFactor || 0) * R, F += R;
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 = D.reduce((A, R) => A + (R.suspend || 0), 0);
1156
- (Q = h.wps) == null || Q.forEach((A, R) => {
1171
+ const H = D.reduce((A, V) => A + (V.suspend || 0), 0);
1172
+ (Q = u.wps) == null || Q.forEach((A, V) => {
1157
1173
  A.positionTime = v.utc(A.etd || A.eta).unix();
1158
- const S = h.wps[R - 1];
1159
- if (S) {
1160
- const Y = A.distanceFromStart - S.distanceFromStart, P = v(A.eta || A.etd).diff(v(S.etd || S.eta), "h", !0);
1161
- A.avgSpd = Math.round(Y / P * 100) / 100, S.bearing = V.calculateBearing(S, A);
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
- }), h.wps = (Z = h.wps) == null ? void 0 : Z.reduce((A, R) => (A.some((S) => Math.round(S.positionTime / 60) === Math.round(R.positionTime / 60)) || A.push(R), A), []), h.all = ($ = h.all) == null ? void 0 : $.reduce((A, R) => (R.positionTime = v.utc(R.etd || R.eta).unix(), A.some((S) => Math.round(S.positionTime / 60) === Math.round(R.positionTime / 60)) || A.push(R), A), []), f.sample = h;
1164
- const T = h.hours.at(0), N = h.hours.at(-1);
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);
1165
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;
1166
- const L = z.roundPrecision(i.dgo / 24 * H, 3), { distanceInECA: O, hoursInECA: J, totalDgoConsInECA: ot, eca: et } = await this.calculateECA(f, i, l), st = z.roundPrecision(i.fo / 24 * (F - J), 3), it = z.roundPrecision(i.dgo / 24 * F + L, 3);
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: et,
1169
- distanceInECA: O,
1170
- hoursInECA: J,
1171
- totalDgoConsInECA: ot,
1172
- totalDgoConsInSuspend: L
1173
- }, f.totalFoCons = st < 0 ? 0 : st, f.totalDgoCons = it;
1174
- const at = v().valueOf() - d, ct = ((tt = h == null ? void 0 : h.hours) == null ? void 0 : tt.length) || 1;
1175
- return j == null || j.info("[%s] each hour-sample speed analyse cost: (%d / %d = %d) ms", l == null ? void 0 : l.requestId, at, ct, Math.round(at / ct * 1e3) / 1e3), f;
1184
+ eca: tt,
1185
+ distanceInECA: R,
1186
+ hoursInECA: K,
1187
+ totalDgoConsInECA: nt,
1188
+ totalDgoConsInSuspend: O
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 = "", u = 3, l = !0, d = !1, y = {}) {
1193
- var X, Q, Z, $, tt, A, R;
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
- }, E = W.assembleProperties(i, n.loadCondition, g, 0), b = V.calculateSubRoute(s, o);
1220
+ }, j = Y.assembleProperties(i, n.loadCondition, g, 0), b = W.calculateSubRoute(e, o);
1205
1221
  if (((X = b[0]) == null ? void 0 : X.length) <= 1)
1206
1222
  return;
1207
- const p = e.length ? V.calculateSubWaypoints(s, e) : [];
1208
- p.forEach((S) => S.important = !0);
1209
- let f = V.simplifyRouteToCoordinates(b, p, 0), h = 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,26 +1232,26 @@ class W {
1216
1232
  t = v(t).utc();
1217
1233
  const F = t.clone();
1218
1234
  for (; f.length > 0; ) {
1219
- const S = u - t.hour() % u;
1220
- let Y = Math.ceil(t.clone().add(S, "h").set({ minute: 0, second: 0, millisecond: 0 }).diff(t, "h", !0) * 1e4) / 1e4;
1221
- Y = t.clone().add(Y, "h").isSameOrAfter(a) ? a.diff(t, "h", !0) * 1e4 / 1e4 : Y;
1222
- const P = await W.speedLoseInHoursStep(E, t, F, Y, h, 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), h += Math.round((((Z = P == null ? void 0 : P.to) == null ? void 0 : Z.distanceFromPrevious) ?? 0) * 1e4) / 1e4, !Y)
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, Y) => (S.some((P) => Math.round(v(P.etd).unix() / 60) === Math.round(v(Y.etd).unix() / 60)) || S.push(Y), S), []), C.all = (tt = C.all) == null ? void 0 : tt.reduce((S, Y) => (Y.positionTime = v.utc(Y.etd || Y.eta).unix(), S.some((P) => Math.round(v(P.etd).unix() / 60) === Math.round(v(Y.etd).unix() / 60)) || S.push(Y), S), []), (A = C.wps) == null || A.forEach((S, Y) => {
1227
- const P = C.wps[Y - 1];
1228
- if (P) {
1229
- const ht = S.distanceFromStart - P.distanceFromStart, lt = v(S.eta || S.etd).diff(v(P.etd || P.eta), "h", !0);
1230
- S.avgSpd = Math.round(ht / lt * 100) / 100, P.bearing = V.calculateBearing(P, S);
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 q = C.hours;
1234
- for (let S = 0; S < q.length - 1; S++) {
1235
- const Y = v(q[S + 1].eta).diff(q[S].etd, "hour", !0);
1236
- m += q[S].wxFactor * Y, c += q[S].cFactor * Y, I += Y;
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 D = q.reduce((S, Y) => S + (Y.suspend || 0), 0), H = C.hours.at(0), T = C.hours.at(-1), N = await V.calculateRangeRoute(H, T, b), L = await V.calculateRangeWaypoints(H, T, b, p), O = {
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
1256
  distance: Math.round(((T == null ? void 0 : T.distanceFromStart) || 0) * 1e4) / 1e4,
1241
1257
  // 注意,可能会在first节点Drift,所有采用eta做为初始出发时间
@@ -1249,19 +1265,19 @@ class W {
1249
1265
  from: H,
1250
1266
  to: T,
1251
1267
  route: N,
1252
- waypoints: L,
1268
+ waypoints: O,
1253
1269
  v0: g,
1254
1270
  label: k
1255
- }, J = z.roundPrecision(n.dgo / 24 * D, 3), { distanceInECA: ot, hoursInECA: et, totalDgoConsInECA: st, eca: it } = await this.calculateECA(O, n, y), rt = z.roundPrecision(n.fo / 24 * (I - et), 3), at = z.roundPrecision(n.dgo / 24 * I + J, 3);
1256
- O.extend = {
1257
- eca: it,
1258
- distanceInECA: ot,
1259
- hoursInECA: et,
1260
- totalDgoConsInECA: st,
1261
- totalDgoConsInSuspend: J
1262
- }, O.totalDgoCons = at, O.totalFoCons = rt < 0 ? 0 : rt;
1263
- const U = v().valueOf() - w, G = ((R = C == null ? void 0 : C.hours) == null ? void 0 : R.length) || 1;
1264
- return j == null || j.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), O;
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);
1272
+ R.extend = {
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 = {}) {
1297
+ static async analyseCost(e, t, a, i, n = {}) {
1282
1298
  var b, p;
1283
- const o = v().valueOf(), e = [];
1284
- s.speedStep = s.speedStep || 3, s.alterStep = s.alterStep ?? 1;
1285
- const r = V.calculateRouteDistance(i.route);
1286
- let u = 0;
1299
+ const o = v().valueOf(), s = [];
1300
+ e.speedStep = e.speedStep || 3, e.alterStep = e.alterStep ?? 1;
1301
+ const r = W.calculateRouteDistance(i.route);
1302
+ let h = 0;
1287
1303
  a.forEach((f) => {
1288
- const h = Math.ceil(r / f.speed / 24);
1289
- u = u < h ? h : u;
1290
- }), u = u * 1.3;
1291
- const l = v.utc(s.etd).add(u ?? 14, "day");
1304
+ const u = Math.ceil(r / f.speed / 24);
1305
+ h = h < u ? u : h;
1306
+ }), h = h * 1.3;
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 h = 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
- h,
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), j == null || j.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, h) => f.cost.total - h.cost.total);
1318
- const y = e.at(0), w = e.at(1), g = [];
1333
+ s.sort((f, u) => f.cost.total - u.cost.total);
1334
+ const y = s.at(0), w = s.at(1), g = [];
1319
1335
  if (g.push({ combined: !1, speeds: [y], cost: (b = y.cost) == null ? void 0 : b.total }), w) {
1320
- const f = y.cost.cp, h = w.cost.cp, m = v(y.eta), c = v(y.etd), I = m.diff(c, "days", !0);
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, q = { combined: !1, speeds: [w], cost: (p = w.cost) == null ? void 0 : p.total }, D;
1324
- for (; C >= s.alterStep; ) {
1325
- const H = await W.combinedAnalyse(s, t, l, [f, h], i, C, { ...n, level: F });
1326
- if (q.cost > H.cost ? D ? (D == null ? void 0 : D.cost) > H.cost && (D = H) : (D = q, q = H) : (!D || (D == null ? void 0 : D.cost) > H.cost) && (D = 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(q), D && g.push(D);
1346
+ g.push(P), D && g.push(D);
1331
1347
  }
1332
- const E = v().valueOf() - o;
1333
- return j == null || j.info("[%s] analyse elapsed: %d ms", n == null ? void 0 : n.requestId, E), g.sort((f, h) => f.cost - h.cost);
1348
+ const j = v().valueOf() - o;
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,24 +1358,24 @@ 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, j == null || j.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), u = r.reduce((h, m) => h + m.cost.total, 0), l = r.reduce((h, m) => h + m.cost.hire, 0), d = r.reduce((h, m) => h + m.cost.bunker, 0), y = r.reduce((h, m) => h + m.distance, 0), w = r.reduce((h, m) => h + m.totalHrs, 0);
1348
- j == null || j.info("[%s][L%d] cost with cpa/cpb turn: %j", e.requestId, e.level, {
1349
- cost: u,
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, {
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((h, m) => h + m.cost.total, 0), E = g.reduce((h, m) => h + m.cost.hire, 0), b = g.reduce((h, m) => h + m.cost.bunker, 0), p = g.reduce((h, m) => h + m.distance, 0), f = g.reduce((h, m) => h + m.totalHrs, 0);
1356
- return j == null || j.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
- hire: E,
1374
+ hire: j,
1359
1375
  bunker: b,
1360
1376
  distance: p,
1361
1377
  hours: f
1362
- }), u < k ? { combined: !0, cost: Math.round(u * 1e3) / 1e3, speeds: r, step: o } : { combined: !0, cost: Math.round(k * 1e3) / 1e3, speeds: g, step: o };
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
  }
1364
1380
  /**
1365
1381
  * 基于cp索引,交替计算指定步长下的成本
@@ -1372,31 +1388,31 @@ 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 u = v.utc(s.etd);
1378
- const l = { lat: s.lat, lng: s.lng }, d = [];
1379
- for (; u.isBefore(a); ) {
1380
- const g = u.clone().utc().add(e, "day"), k = JSON.parse(JSON.stringify(o.route)), E = JSON.parse(JSON.stringify(o.waypoints)), b = i[n], p = await W.analyseInstantWithThreshed(
1393
+ let h = v.utc(e.etd);
1394
+ const l = { lat: e.lat, lng: e.lng }, d = [];
1395
+ for (; h.isBefore(a); ) {
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
- u.utc().format(),
1398
+ h.utc().format(),
1383
1399
  g,
1384
1400
  t,
1385
1401
  b,
1386
1402
  k,
1387
- E,
1388
- s.meteoVendor,
1389
- s.speedStep,
1390
- s.useMeteo,
1391
- s.useRouteParam,
1403
+ j,
1404
+ e.meteoVendor,
1405
+ e.speedStep,
1406
+ e.useMeteo,
1407
+ e.useRouteParam,
1392
1408
  r
1393
1409
  );
1394
- p && (await W.calculateCost(p, b, s, r), j == null || j.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,
1398
1414
  r.counter,
1399
- u.utc().format(),
1415
+ h.utc().format(),
1400
1416
  g.utc().format(),
1401
1417
  {
1402
1418
  cost: p.cost.total,
@@ -1409,7 +1425,7 @@ class W {
1409
1425
  )), r.counter = r.counter + 1;
1410
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, u = v(f.eta), d.push(p), 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, u = 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 = {
1430
- total: Math.round((r + u + l) * 1e3) / 1e3,
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 = {
1446
+ total: Math.round((r + h + l) * 1e3) / 1e3,
1431
1447
  hire: Math.round(r * 1e3) / 1e3,
1432
- suspendHire: e,
1433
- bunker: Math.round((u + l) * 1e3) / 1e3,
1448
+ suspendHire: s,
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 = {}) {
1444
- var r, u, l, d;
1445
- const i = await V.intersectInECA((s == null ? void 0 : s.route) || []);
1446
- let n = 0, o = 0, e = 0;
1447
- (u = (r = s == null ? void 0 : s.sample) == null ? void 0 : r.wps) == null || u.forEach((y) => {
1459
+ static async calculateECA(e, t, a = {}) {
1460
+ var r, h, l, d;
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,24 +1480,24 @@ class W {
1464
1480
  * @param speeds
1465
1481
  * @param options
1466
1482
  */
1467
- static async mergeSpeeds(s, t = {}) {
1468
- var f, h;
1483
+ static async mergeSpeeds(e, t = {}) {
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), u = 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), E = [], b = [];
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 = [];
1483
1499
  let p;
1484
- for (const m of s) {
1500
+ for (const m of e) {
1485
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
1503
  p && (F.distanceFromPrevious = p.distanceFromPrevious, F.distanceFromStart = p.distanceFromStart, c.forEach((T, N) => {
@@ -1491,42 +1507,40 @@ class W {
1491
1507
  }), C.at(0).distanceFromPrevious = p.distanceFromPrevious, C.at(0).distanceFromStart = p.distanceFromStart, C.forEach((T, N) => {
1492
1508
  N && (T.distanceFromStart = T.distanceFromStart + p.distanceFromStart);
1493
1509
  })), F.cp = m.cost.cp;
1494
- const q = [m.etd, m.eta], D = E.findIndex((T) => T.id === F.cp.id);
1495
- D === -1 ? (F.cp.segment = [q], E.push(F.cp)) : E[D].segment.push(q), c.forEach((T) => {
1496
- var L;
1497
- ((L = a.hours) == null ? void 0 : L.findIndex((O) => O.eta === T.eta)) === -1 && a.hours.push(T);
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) => {
1512
+ var O;
1513
+ ((O = a.hours) == null ? void 0 : O.findIndex((R) => R.eta === T.eta)) === -1 && a.hours.push(T);
1498
1514
  }), I.forEach((T) => {
1499
- var L;
1500
- ((L = a.wps) == null ? void 0 : L.findIndex((O) => O.eta === T.eta)) === -1 && a.wps.push(T);
1515
+ var O;
1516
+ ((O = a.wps) == null ? void 0 : O.findIndex((R) => R.eta === T.eta)) === -1 && a.wps.push(T);
1501
1517
  }), C.forEach((T) => {
1502
- var L;
1503
- ((L = a == null ? void 0 : a.days) == null ? void 0 : L.findIndex((O) => O.eta === T.eta)) === -1 && a.days.push(T);
1518
+ var O;
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 = (h = a.wps) == null ? void 0 : h.findIndex((T) => T.eta === F.eta);
1521
+ const H = (u = a.wps) == null ? void 0 : u.findIndex((T) => T.eta === F.eta);
1506
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), q = Math.round(C / F * 100) / 100;
1514
- m.avgSpd = q;
1515
- const D = V.calculateBearing(I, m);
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);
1516
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,
1528
1542
  avgSpeed: Math.round(i / o * 1e3) / 1e3,
1529
- wxFactor: Math.round(u * 1e3) / 1e3,
1543
+ wxFactor: Math.round(h * 1e3) / 1e3,
1530
1544
  cFactor: Math.round(l * 1e3) / 1e3,
1531
1545
  totalFoCons: Math.round(d * 1e3) / 1e3,
1532
1546
  totalDgoCons: Math.round(y * 1e3) / 1e3,
@@ -1536,27 +1550,27 @@ class W {
1536
1550
  bunker: Math.round(k * 1e3) / 1e3
1537
1551
  },
1538
1552
  extend: {
1539
- cps: E,
1553
+ cps: j,
1540
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
- nt as AISImpl,
1551
- gt as AlertHelper,
1552
- Mt as AlertLevel,
1553
- Nt as HifleetImpl,
1554
- vt as LoadCondition,
1555
- Dt as MyShipImpl,
1556
- Ft as MyVesselImpl,
1557
- xt as ShipxyImpl,
1558
- W as SpeedHelper,
1559
- wt as SpeedLabel,
1560
- pt as VesselTag,
1561
- At 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
  };