signalk-siparu 0.2.11 → 0.2.12
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/LICENSE +1 -1
- package/package.json +1 -1
- package/plugin/dist/live.js +2 -1
- package/plugin/dist/uplink.js +2 -1
- package/public/assets/Logbook-B8_oMwuZ.js +1 -0
- package/public/assets/{Map-D84VPs-d.js → Map-CEwUZlRh.js} +9 -9
- package/public/assets/Remote--W7QE6vQ.js +1 -0
- package/public/assets/{SecurityHelp-D_IuBUYm.js → SecurityHelp-CmkDtKXa.js} +1 -1
- package/public/assets/Voyage-B5ibpNOg.js +1 -0
- package/public/assets/{export-BS6h3d6E.js → export-CQYXr7nu.js} +1 -1
- package/public/assets/index-D8cInHV9.js +20 -0
- package/public/assets/{index-QctSvxcL.css → index-DnKxzCIS.css} +1 -1
- package/public/index.html +2 -2
- package/public/assets/Logbook-DpHBKbVS.js +0 -1
- package/public/assets/Remote-B66DSZVi.js +0 -1
- package/public/assets/Voyage-DBV-C78R.js +0 -1
- package/public/assets/index-BwOZQYHE.js +0 -20
package/LICENSE
CHANGED
|
@@ -187,7 +187,7 @@
|
|
|
187
187
|
same "printed page" as the copyright notice for easier
|
|
188
188
|
identification within third-party archives.
|
|
189
189
|
|
|
190
|
-
Copyright
|
|
190
|
+
Copyright 2026 Siparu Ltd
|
|
191
191
|
|
|
192
192
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
193
|
you may not use this file except in compliance with the License.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "signalk-siparu",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.12",
|
|
4
4
|
"description": "Kept aboard, proven ashore. Position, wind, depth and voyage history, recorded on the boat and readable from anywhere: sealed to the devices you name, signed on the way out. A read-only Signal K plugin with a built-in dashboard.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"signalk-node-server-plugin",
|
package/plugin/dist/live.js
CHANGED
|
@@ -453,7 +453,8 @@ class LiveUplink {
|
|
|
453
453
|
if (code === CLOSE_PLAN_REQUIRED) {
|
|
454
454
|
this.unentitled = true;
|
|
455
455
|
this.lastError =
|
|
456
|
-
'Remote watching is not active on this account. She is recording as usual, and
|
|
456
|
+
'Remote watching is not active on this account. She is recording as usual, and looks ' +
|
|
457
|
+
'again every fifteen minutes. Your account at siparu.app/app says where it stands.';
|
|
457
458
|
this.deps.debug(`live uplink: ${this.lastError}`);
|
|
458
459
|
this.redial(STAND_OFF_MS);
|
|
459
460
|
return;
|
package/plugin/dist/uplink.js
CHANGED
|
@@ -138,7 +138,8 @@ class Uplink {
|
|
|
138
138
|
this.lastError = this.rejected
|
|
139
139
|
? 'Siparu no longer recognises this boat. Pair her again.'
|
|
140
140
|
: this.unentitled
|
|
141
|
-
? 'Remote watching is not active on this account. She is recording as usual, and
|
|
141
|
+
? 'Remote watching is not active on this account. She is recording as usual, and looks ' +
|
|
142
|
+
'again every fifteen minutes. Your account at siparu.app/app says where it stands.'
|
|
142
143
|
: `Relay refused the frame (${res.status}).`;
|
|
143
144
|
this.deps.debug(`uplink: ${this.lastError}`);
|
|
144
145
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-CaR_m4Xc.js";import{t as r}from"./visibleInterval-CFxPzgzx.js";import{A as i,C as a,D as o,E as s,N as c,O as l,P as u,S as d,T as f,_ as p,b as m,c as h,d as g,g as _,k as v,l as y,o as b,p as x,s as S,v as C,w}from"./index-D8cInHV9.js";import{c as T,i as E,l as D,n as O,r as k,s as A,t as j}from"./export-CQYXr7nu.js";var M=e(t(),1);function N(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getUTCHours())}:${n(t.getUTCMinutes())}`}var P={key:`ts`,head:`UTC`,book:`bridge`,cell:e=>N(e.ts)};function F(e,t,n,r){if(e===null)return`·`;let i=Math.abs(e),a=Math.floor(i),o=(i-a)*60;return`${String(a).padStart(t,`0`)}°${o.toFixed(3).padStart(6,`0`)}' ${e<0?r:n}`}function I(e){return[{col:{key:`lat`,head:`LAT`,book:`bridge`,lanes:2,cell:e=>F(e.lat,2,`N`,`S`)},has:e=>e.lat!==null},{col:{key:`lon`,head:`LON`,book:`bridge`,lanes:2,cell:e=>F(e.lon,3,`E`,`W`)},has:e=>e.lon!==null},{col:{key:`sog`,head:`SOG`,book:`bridge`,unit:`kn`,cell:e=>m(o(e.sog),1)},has:e=>e.sog!==null},{col:{key:`cog`,head:`COG`,book:`bridge`,cell:e=>{let t=s(e.cog);return t===null?`·`:Math.round(t)+`°`}},has:e=>e.cog!==null},{col:{key:`hdg`,head:`HDG`,book:`bridge`,cell:e=>{let t=s(e.heading_true??e.heading_mag);return t===null?`·`:Math.round(t)+`°`}},has:e=>(e.heading_true??e.heading_mag)!==null},{col:{key:`wind`,head:e===`kn`?`TWS`:`BFT`,book:`bridge`,unit:e===`kn`?`kn`:void 0,tappable:!0,cell:t=>{let n=w(t.wind_speed_true);return n===null?`·`:String(e===`kn`?Math.round(n):a(n)??`·`)}},has:e=>e.wind_speed_true!==null},{col:{key:`awa`,head:`AWA`,book:`bridge`,cell:e=>{let t=s(e.wind_angle_apparent);if(t===null)return`·`;let n=(t+180)%360-180;return`${Math.abs(Math.round(n))}°${n<0?`P`:`S`}`}},has:e=>e.wind_angle_apparent!==null},{col:{key:`baro`,head:`BARO`,book:`bridge`,unit:`hPa`,dim:!0,cell:e=>{let t=f(e.air_pressure_pa);return t===null?`·`:String(Math.round(t))}},has:e=>e.air_pressure_pa!==null},{col:{key:`air`,head:`AIR`,book:`bridge`,unit:`°C`,cell:e=>m(d(e.air_temp_k),1)},has:e=>e.air_temp_k!==null},{col:{key:`sea`,head:`SEA`,book:`bridge`,unit:`°C`,cell:e=>m(d(e.water_temp_k),1)},has:e=>e.water_temp_k!==null},{col:{key:`depth`,head:`DEP`,book:`bridge`,unit:`m`,cell:e=>e.depth===null?`·`:e.depth.toFixed(1)},has:e=>e.depth!==null}]}var L={Revolutions:`RPM`,Temperature:`TEMP`,"Oil pressure":`OIL`,"Oil temperature":`OILT`,"Coolant temperature":`COOL`,"Coolant pressure":`COOLP`,"Exhaust temperature":`EXH`,"Intake manifold temperature":`INTK`,"Boost pressure":`BOOST`,"Engine load":`LOAD`,"Engine torque":`TORQ`,"Run time":`HRS`,"Fuel rate":`FUEL`,"Fuel per mile":`L/NM`,"Fuel used (since reset)":`USED`,"Fuel pressure":`FUELP`,"Alternator voltage":`ALT`,"Gearbox oil temperature":`GBOXT`,"Gearbox oil pressure":`GBOXP`,"Current level":`LEVEL`,Voltage:`VOLT`,Current:`AMP`};function R(e){return L[e]??e.split(` `)[0].toUpperCase()}function z(e){return e.sub===null?e.tab===`tanks`?`Current level`:null:e.sub}function B(e){let t=/^(Engine|Generator|Fuel|Fresh water|Black water|Grey water|Lubrication)\s+(\S+)$/.exec(e);return t?`${t[1].split(` `).map(e=>e[0]).join(``)}${t[2]}`.toUpperCase():e.slice(0,1).toUpperCase()}function V(e){let t=[];for(let n of e)for(let e of Object.keys(n.path_values??{}))t.includes(e)||t.push(e);let n=[];for(let e of t){let t=l(e);if(!t)continue;let r=z(t);r!==null&&n.push({path:e,d:{...t,sub:r}})}let r=new Map;for(let{d:e}of n)r.has(e.tab)||r.set(e.tab,new Set),r.get(e.tab).add(e.label);let a=[];for(let{path:e,d:t}of n){let n=R(t.sub);a.push({col:{key:`p:${e}`,head:r.get(t.tab).size>1?`${B(t.label)} ${n}`:n,book:`engine`,tab:t.tab,unit:i(e),cell:t=>{let n=t.path_values?.[e];if(typeof n!=`number`)return`·`;let r=v(e,n).value;return Number.isFinite(r)?Number.isInteger(r)?String(r):r.toFixed(1):`·`}},has:t=>typeof t.path_values?.[e]==`number`})}return a}function H(e,t){return[P,...[...I(t),...V(e)].filter(t=>e.some(t.has)).map(e=>e.col)]}function ee(e,t){return e.filter(e=>e.key===`ts`||e.book===t)}var U={engine:`ENGINES`,generator:`GENERATORS`,tanks:`TANKS`};function te(e){let t=[],n=new Map,r=new Map;for(let i of e)for(let e of Object.keys(i.path_values??{})){let i=l(e);if(!i)continue;let a=z(i);if(a===null)continue;n.has(i.tab)||(t.push(i.tab),n.set(i.tab,new Map),r.set(i.tab,[]));let o=n.get(i.tab);o.has(i.label)||o.set(i.label,new Map),o.get(i.label).set(a,e);let s=r.get(i.tab);s.includes(a)||s.push(a)}return t.map(e=>{let t=[...n.get(e)].map(([e,t])=>({key:e,head:e.toUpperCase(),paths:Object.fromEntries(t)})),a=r.get(e).map(e=>{let n=t.map(t=>t.paths[e]).find(e=>e!==void 0);return{key:e,head:R(e),unit:n===void 0?``:i(n)}});return{tab:e,head:U[e]??e.toUpperCase(),units:t,metrics:a}})}function W(e,t,n){let r=t.paths[n.key];if(r===void 0)return`·`;let i=e.path_values?.[r];if(typeof i!=`number`)return`·`;let a=v(r,i).value;return Number.isFinite(a)?Number.isInteger(a)?String(a):a.toFixed(1):`·`}function G(e,t){let[n,r]=(0,M.useState)(e),[i,a]=(0,M.useState)(!1);return(0,M.useEffect)(()=>{if(e===n)return;a(!0);let i=setTimeout(()=>{r(e),a(!1)},t);return()=>clearTimeout(i)},[e,n,t]),[n,i]}var K=e=>`lb:columns:${e}`,q={off:[]};function J(e){return e.key===`ts`}function Y(e,t){return J(e)||!t.off.includes(e.key)}function ne(e,t){return e.filter(e=>Y(e,t))}function X(e){return e.filter(e=>!J(e))}function re(e,t){return J(t)?e:{off:Y(t,e)?[...e.off,t.key]:e.off.filter(e=>e!==t.key)}}function ie(e,t){return{off:t?[]:X(e).map(e=>e.key)}}function ae(e,t){return ce(e.off)===ce(t.off)}function oe(e){try{let t=globalThis.localStorage?.getItem(K(e));if(!t)return q;let n=JSON.parse(t);return{off:Array.isArray(n.off)?n.off.filter(e=>typeof e==`string`):[]}}catch{return q}}function se(e,t){try{globalThis.localStorage?.setItem(K(e),JSON.stringify(t))}catch{}}function ce(e){return[...new Set(e)].sort().join(` `)}var Z=n();function le({cols:e,applied:t,onApply:n,onCancel:r}){let[i,a]=(0,M.useState)(t),o=ae(i,t),s=X(e),c=s.filter(e=>Y(e,i)).length;return(0,Z.jsxs)(`div`,{className:`lb-pick`,children:[(0,Z.jsxs)(`div`,{className:`lbp-book`,children:[(0,Z.jsxs)(`div`,{className:`lbp-h`,children:[(0,Z.jsx)(`span`,{className:`lbp-n`,children:`Columns`}),(0,Z.jsxs)(`span`,{className:`lbp-s`,children:[c,` of `,s.length]}),(0,Z.jsxs)(`span`,{className:`lbp-all`,children:[(0,Z.jsx)(`button`,{onClick:()=>a(ie(e,!0)),children:`All`}),(0,Z.jsx)(`button`,{onClick:()=>a(ie(e,!1)),children:`None`})]})]}),(0,Z.jsx)(`div`,{className:`lbp-chips`,children:s.map(e=>(0,Z.jsx)(`button`,{className:`lbp-c${Y(e,i)?` on`:``}`,"aria-pressed":Y(e,i),onClick:()=>a(re(i,e)),children:e.head},e.key))})]}),(0,Z.jsxs)(`div`,{className:`lbp-act`,children:[(0,Z.jsx)(`button`,{onClick:r,children:`Cancel`}),(0,Z.jsx)(`button`,{className:`lbp-go`,disabled:o,onClick:()=>n(i),children:`Show these columns`})]})]})}var ue={"1m":1,"1h":60,"6h":360,"1d":1440},de={"1m":`Every minute`,"1h":`Hourly`,"6h":`Six-hourly`,"1d":`Daily`},fe={"1m":60,"1h":48,"6h":40,"1d":30},pe=15e3;function me(e){let t=c(),[n,i]=(0,M.useState)(0),[a,o]=(0,M.useState)(!1),[s,l]=(0,M.useState)([]),[u,d]=(0,M.useState)(null),[f,p]=(0,M.useState)(!1),[m,h]=(0,M.useState)(e);m!==e&&(h(e),i(0),o(!1));let g=ue[e],_=fe[e]+n*fe[e],v=(0,M.useCallback)(async()=>{p(!0),d(null);try{let e=_+1,n=g===1?(await t.logbook.minutes({limit:e,order:`desc`})).rows:await t.logbook.snapshots({bucket:g,limit:e,order:`desc`});o(n.length>_),l(n.slice(0,_))}catch(e){d(e.message)}finally{p(!1)}},[g,_]);return(0,M.useEffect)(()=>{v();let e=r(v,pe);return()=>e()},[v]),{snaps:s,err:u,busy:f,hasMore:a,loadMore:(0,M.useCallback)(()=>i(e=>e+1),[])}}function he(){let e=c(),[t,n]=(0,M.useState)(C()),[i,a]=(0,M.useState)([]),[o,s]=(0,M.useState)(null),[l,u]=(0,M.useState)(!1),d=(0,M.useRef)(!0),f=x(6e4),m=C(new Date(f)),h=(0,M.useMemo)(()=>p(t),[t]),g=h+24*36e5,_=t===m;(0,M.useEffect)(()=>{d.current&&t!==m&&n(m)},[m,t]);let v=(0,M.useCallback)(e=>{d.current=e===C(),n(e)},[]),y=(0,M.useCallback)(async()=>{u(!0),s(null);try{let t=await e.logbook.snapshots({from:h,to:g,limit:5e3,order:`desc`,bucket:60});a(t)}catch(e){s(e.message)}finally{u(!1)}},[h,g]);return(0,M.useEffect)(()=>{if(y(),!_)return;let e=r(y,pe);return()=>e()},[y,_]),{dateStr:t,setDateStr:v,dayStart:h,isToday:_,snaps:i,err:o,busy:l,prevDay:(0,M.useCallback)(()=>v(C(new Date(h-864e5))),[h,v]),nextDay:(0,M.useCallback)(()=>v(C(new Date(h+864e5))),[h,v]),goToday:(0,M.useCallback)(()=>v(C()),[v])}}var ge=5e3;async function _e(e,t,n){let r=await e({from:t,to:n,limit:5001,order:`desc`});return{rows:r.rows.slice(0,ge),truncated:r.clamped||r.rows.length>5e3,minutesFrom:r.minutesFrom}}function ve(e,t,n,r=`last`){let i=c(),[a,o]=(0,M.useState)([]),[s,l]=(0,M.useState)(null),[u,d]=(0,M.useState)(!1),[f,m]=(0,M.useState)(!1),[h,g]=(0,M.useState)(!1),[_,v]=(0,M.useState)(null),[y,b]=(0,M.useState)([]),x=(0,M.useMemo)(()=>p(e),[e]),S=(0,M.useMemo)(()=>p(t)+864e5-1,[t]),C=ue[n],w=(0,M.useCallback)(async()=>{if(Number.isNaN(x)||Number.isNaN(S)||S<x){o([]),b([]),m(!1),l(null),g(!0);return}g(!1),d(!0),l(null);try{if(b([]),C===1){let e=await _e(e=>i.logbook.minutes(e),x,S);v(e.minutesFrom),m(e.truncated),o(e.rows);return}let e=await i.logbook.rollupHours(x,S);v(null);let t=T(e,n),a=t.map(e=>D(e,r)),s=e=>e.slice(Math.max(0,e.length-ge));m(a.length>ge),o(s(a)),r!==`last`&&b(s(t.map(e=>D(e,`last`))))}catch(e){l(e.message)}finally{d(!1),g(!0)}},[x,S,C,n,r]);return(0,M.useEffect)(()=>{w()},[w]),{snaps:a,err:s,busy:u,truncated:f,loaded:h,minutesFrom:_,plain:y}}var ye=[`1m`,`1h`,`6h`,`1d`],be=[{v:`csv`,name:`CSV`,note:`a file for a spreadsheet`},{v:`pdf`,name:`PDF`,note:`the page, through your printer`}],xe=[{v:`screen`,name:`Screen`},{v:`paper`,name:`Paper`}],Se=[`last`,`avg`,`min`,`max`];function Ce(e,t,n){return e===`pdf`?[n]:t.includes(n)?t.filter(e=>e!==n):[...t,n]}function we(e,t){return e===`pdf`?[t[0]??`last`]:t}function Te(){return C(new Date(Date.now()-7*864e5))}function Ee({initial:e,onView:t,onSave:n}){let[r,i]=(0,M.useState)(e?.from??Te()),[a,o]=(0,M.useState)(e?.to??C()),[s,c]=(0,M.useState)(e?.gran??`1h`),[l,u]=(0,M.useState)(e?.format??`csv`),[d,f]=(0,M.useState)(e?.stats??[`last`]),[p,m]=(0,M.useState)(e?.distance??!1),[h,g]=(0,M.useState)(e?.samples??!1),[_,v]=(0,M.useState)(e?.style??`screen`),y=a<r,b={from:r,to:a,gran:s,format:l,stats:we(l,d),distance:p,samples:h,style:_},x=s!==`1m`,S=l===`pdf`,w=x&&!S&&d.length===0&&!p&&!h,T=e=>f(t=>Ce(l,t,e)),E=we(l,d),D=e=>E.includes(e);return(0,Z.jsxs)(`div`,{className:`lb-pick lb-exp`,children:[(0,Z.jsxs)(`div`,{className:`lbp-books`,children:[(0,Z.jsxs)(`div`,{className:`lbp-book`,children:[(0,Z.jsxs)(`div`,{className:`lbp-h`,children:[(0,Z.jsx)(`span`,{className:`lbp-n`,children:`Window`}),(0,Z.jsx)(`span`,{className:`lbp-s`,children:`local days, both ends included`})]}),(0,Z.jsxs)(`div`,{className:`lbe-dates`,children:[(0,Z.jsxs)(`label`,{children:[(0,Z.jsx)(`span`,{children:`From`}),(0,Z.jsx)(`input`,{type:`date`,className:`dt`,value:r,max:C(),onChange:e=>i(e.target.value)})]}),(0,Z.jsxs)(`label`,{children:[(0,Z.jsx)(`span`,{children:`To`}),(0,Z.jsx)(`input`,{type:`date`,className:`dt`,value:a,max:C(),onChange:e=>o(e.target.value)})]})]})]}),(0,Z.jsxs)(`div`,{className:`lbp-book`,children:[(0,Z.jsxs)(`div`,{className:`lbp-h`,children:[(0,Z.jsx)(`span`,{className:`lbp-n`,children:`Interval`}),(0,Z.jsx)(`span`,{className:`lbp-s`,children:`one row per`})]}),(0,Z.jsx)(`div`,{className:`lbp-chips`,children:ye.map(e=>(0,Z.jsx)(`button`,{className:`lbp-c${s===e?` on`:``}`,onClick:()=>c(e),children:de[e]},e))})]}),(0,Z.jsxs)(`div`,{className:`lbp-book`,children:[(0,Z.jsxs)(`div`,{className:`lbp-h`,children:[(0,Z.jsx)(`span`,{className:`lbp-n`,children:`Save as`}),(0,Z.jsx)(`span`,{className:`lbp-s`,children:be.find(e=>e.v===l)?.note})]}),(0,Z.jsx)(`div`,{className:`lbp-chips`,children:be.map(e=>(0,Z.jsx)(`button`,{className:`lbp-c${l===e.v?` on`:``}`,onClick:()=>u(e.v),children:e.name},e.v))})]}),(0,Z.jsxs)(`div`,{className:`lbp-book${S?``:` off`}`,children:[(0,Z.jsxs)(`div`,{className:`lbp-h`,children:[(0,Z.jsx)(`span`,{className:`lbp-n`,children:`Style`}),(0,Z.jsx)(`span`,{className:`lbp-s`,children:S?_===`screen`?`the app's own dark ink`:`white, for a printer`:`the page's ink; a file carries none`})]}),(0,Z.jsx)(`div`,{className:`lbp-chips`,children:xe.map(e=>(0,Z.jsx)(`button`,{className:`lbp-c${_===e.v?` on`:``}`,disabled:!S,onClick:()=>v(e.v),children:e.name},e.v))})]})]}),x&&(0,Z.jsxs)(`div`,{className:`lbp-book lbp-figs`,children:[(0,Z.jsxs)(`div`,{className:`lbp-h`,children:[(0,Z.jsx)(`span`,{className:`lbp-n`,children:`Figures`}),(0,Z.jsx)(`span`,{className:`lbp-s`,children:S?`one: a table cell holds one number`:`one or more: a column each`})]}),(0,Z.jsxs)(`div`,{className:`lbp-chips`,children:[Se.map(e=>(0,Z.jsx)(`button`,{className:`lbp-c${D(e)?` on`:``}`,onClick:()=>T(e),children:A[e]},e)),(0,Z.jsx)(`button`,{className:`lbp-c${p?` on`:``}`,disabled:S,onClick:()=>m(!p),children:`Distance`}),(0,Z.jsx)(`button`,{className:`lbp-c${h?` on`:``}`,disabled:S,onClick:()=>g(!h),children:`Samples`})]})]}),y&&(0,Z.jsx)(`div`,{className:`lbe-warn`,children:`That window ends before it begins.`}),w&&(0,Z.jsx)(`div`,{className:`lbe-warn`,children:`Choose at least one figure to put in the file.`}),(0,Z.jsxs)(`div`,{className:`lbp-act`,children:[S&&(0,Z.jsx)(`button`,{disabled:y,onClick:()=>t(b),children:`View`}),(0,Z.jsxs)(`button`,{className:`lbp-go`,disabled:y||w,onClick:()=>n(b),children:[`Save `,l.toUpperCase()]})]})]})}function Q({open:e,style:t,cls:n,children:r}){let[i,a]=(0,M.useState)(e);return e&&!i&&a(!0),i?(0,Z.jsx)(`div`,{className:`lb-open${e?``:` shut`}${n??``}`,style:t,onAnimationEnd:t=>{t.target===t.currentTarget&&!e&&a(!1)},children:(0,Z.jsx)(`div`,{className:`lb-open-in`,children:r})}):null}function De(e){let t=e-32-58;return Math.max(1,Math.floor(t/52))}function Oe(e){return e.reduce((e,t)=>e+(t.lanes??1),0)}function ke(e,t){if(t===null||e.length===0)return e;let n=De(t),r=e.slice(0,1);for(let t of e.slice(1)){let e=t.lanes??1;if(e>n)break;n-=e,r.push(t)}return r}function Ae(e,t,n){return t===null?e:e.slice(0,De(t-(n?108:0)))}var je=180,Me=[`1m`,`1h`,`6h`,`1d`],Ne={"1m":`Last hour`,"1h":`Last 2 days`,"6h":`Last 10 days`,"1d":`Last month`};function Pe({book:e}){let t=c(),[n,r]=(0,M.useState)(`live`),[i,a]=(0,M.useState)(`1h`),[o,s]=(0,M.useState)(null),[l,u]=G((0,M.useMemo)(()=>({book:e,mode:n,gran:i,family:o}),[e,n,i,o]),je),{book:d,mode:f,gran:m,family:h}=l,_=n!==f,[v,y]=(0,M.useState)(()=>localStorage.getItem(`lb:windUnit`)||`kn`),b=()=>y(e=>{let t=e===`kn`?`bft`:`kn`;return localStorage.setItem(`lb:windUnit`,t),t}),x=(0,M.useRef)([]),S=(0,M.useRef)(0),[C,w]=(0,M.useState)(()=>oe(d)),[A,N]=(0,M.useState)(d);A!==d&&(N(d),w(oe(d)),x.current=[],S.current=0);let[P,F]=(0,M.useState)(!1),I=e=>{w(e),se(d,e),F(!1)},[L,R]=g(),z=(0,M.useRef)(null),B=(0,M.useRef)(null),V=(0,M.useCallback)(e=>{B.current=e,L(e)},[L]),U=(0,M.useRef)(null);(0,M.useLayoutEffect)(()=>{let e=B.current;if(!e)return;let t=()=>e.querySelectorAll(`.lb-ctrl, .lb-pick, .lb-frame`);if(u){let e=new Map;t().forEach(t=>e.set(t,t.getBoundingClientRect().width)),U.current=e;return}let n=U.current;if(U.current=null,!n||window.matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let r=parseFloat(getComputedStyle(e).getPropertyValue(`--lb-fade-in`))||0;t().forEach(e=>{let t=n.get(e);if(t===void 0||typeof e.animate!=`function`)return;let i=e.getBoundingClientRect().width;Math.abs(i-t)<1||e.animate([{maxWidth:`${t}px`},{maxWidth:`${i}px`}],{duration:r,easing:`cubic-bezier(0.32, 0.72, 0, 1)`})})},[u,l]);let[te,W]=(0,M.useState)(!1),[K,q]=(0,M.useState)(null),[J,Y]=(0,M.useState)(!1),[X,re]=(0,M.useState)(null),[ie,ae]=(0,M.useState)(null),ce={book:d,mode:n,setMode:r,gran:i,setGran:a,shownGran:m,family:o,setFamily:s,shownFamily:h,leaving:u,modeLeaving:_,lanesHold:z,groupsHold:x,chosenHold:S,windUnit:v,toggleWind:b,selection:C,picking:P,setPicking:F,applySelection:I,width:R,exporting:te,setExporting:W,request:K,onView:e=>{q(e),r(`range`),re(null)},onSave:async e=>{if(W(!1),re(null),ae(null),e.format===`pdf`){q(e),r(`range`),Y(!0);return}try{let n=p(e.from),r=p(e.to)+864e5-1;if(e.gran===`1m`){let{rows:e,truncated:i}=await _e(e=>t.logbook.minutes(e),n,r),a=ne(ee(H(e,v),d),C);O(k(`logbook-${d}`,n,`csv`,i?`-partial`:``),`text/csv`,E(e,a)),i&&ae(`That window holds more than ${ge} minutes, so the file stops at the most recent ${ge} and its name ends in -partial. A longer interval covers the same days in fewer rows.`);return}let i=T(await t.logbook.rollupHours(n,r),e.gran),a=e.stats.map(e=>({stat:e,cols:ne(ee(H(i.map(t=>D(t,e)),v),d),C)})).filter(e=>e.cols.length>1);O(k(`logbook-${d}`,n,`csv`),`text/csv`,j(i,a,{distance:e.distance,samples:e.samples}))}catch(e){re(e.message)}},saveErr:X,saveNote:ie};return(0,Z.jsxs)(`div`,{className:`lb`,ref:V,children:[(0,Z.jsx)(`style`,{children:`@media print { @page { size: A4 landscape; margin: 12mm; } }`}),f===`live`?(0,Z.jsx)(et,{...ce}):f===`day`?(0,Z.jsx)(tt,{...ce}):(0,Z.jsx)(ct,{...ce,req:K,printing:J,donePrinting:()=>Y(!1)})]})}function Fe({mode:e,setMode:t}){return(0,Z.jsxs)(`div`,{className:`seg`,children:[(0,Z.jsx)(`button`,{className:e===`live`?`on`:``,onClick:()=>t(`live`),children:`Live`}),(0,Z.jsx)(`button`,{className:e===`day`?`on`:``,onClick:()=>t(`day`),children:`Day`})]})}function Ie({leaving:e,children:t}){return(0,Z.jsx)(`div`,{className:`lb-win${e?` leaving`:``}`,children:t})}function Le({groups:e,family:t,setFamily:n}){if(e.length<2)return null;let r=e.find(e=>e.tab===t)??e[0];return(0,Z.jsx)(`div`,{className:`seg`,children:e.map(e=>(0,Z.jsx)(`button`,{className:e.tab===r.tab?`on`:``,onClick:()=>n(e.tab),children:e.head},e.tab))})}function Re(e,t,n){if(e===null||p(t.from)>=e)return null;let r=new Date(e).toLocaleDateString(void 0,{day:`numeric`,month:`short`}),i=n[n.length-1];return`Minutes reach back to ${r}.${i!==void 0&&i.ts<e?` Earlier days in this window read one row per hour.`:``}`}function ze(e,t,n){let r=A[e].toLowerCase(),i=t.length===1?t[0]:`${t.slice(0,-1).join(`, `)} and ${t[t.length-1]}`,a=n.some(e=>e.lat!==null&&e.lon!==null),o=t.length===1;return`${i} ${o?`has`:`have`} no ${r}, so on each row ${o?`it carries`:`they carry`} the reading that window closed on${a?`, as the position does`:``}.`}function Be(e,t){if(t.length===0)return e;let n=new Map(t.map(e=>[e.ts,e]));return e.map(e=>{let t=n.get(e.ts);if(!t)return e;let r={...e};for(let[e,n]of Object.entries(t))e!==`path_values`&&(r[e]===null||r[e]===void 0)&&n!=null&&(r[e]=n);if(t.path_values){let n={...e.path_values??{}};for(let[e,r]of Object.entries(t.path_values))(n[e]===void 0||n[e]===null)&&(n[e]=r);r.path_values=n}return r})}function Ve(e){return p(e.to)+864e5-1>=Date.now()&&e.gran!==`1m`?`No row has closed at this interval yet. A shorter interval shows today's.`:`Nothing was logged between these dates.`}function He(e,t,n){return e.length>1||t===null?$(e):{"--lb-cols":n.current??De(t)}}function Ue({what:e}){return(0,Z.jsxs)(`div`,{className:`sp-empty`,children:[(0,Z.jsx)(`div`,{className:`em-t`,children:`No snapshots`}),(0,Z.jsx)(`div`,{className:`em-s`,children:e})]})}var We=(e,t)=>`u:${e}:${t}`;function Ge(e,t,n,r,i,a,o,s,c,l=!0){let u=t===`engine`?te(e):[];u.length>0&&(s.current=u);let d=u.length===0&&e.length===0?s.current:u,f=u.find(e=>e.tab===a)??u[0];if(f&&f.units.length>1){let e=f.metrics.map(e=>({key:We(f.tab,e.key),head:e.head})),t=f.metrics.filter(e=>Y({key:We(f.tab,e.key)},r)),n=l?Ae(t,i,!0):t,a={...f,metrics:n};return o.current=Math.max(1,n.length),t.length>0&&(c.current=t.length),{groups:d,group:a,drawn:[],pick:e,btn:{shown:n.length,chosen:t.length,kept:c.current,offered:e.length},block:{"--lb-cols":Math.max(1,n.length)},cls:` u`}}let p=ee(H(e,n),t),m=f?p.filter(e=>e.key===`ts`||e.tab===f.tab):p,h=ne(m,r),g=l?ke(h,i):h;return g.length>1&&(o.current=Oe(g.slice(1))),h.length>1&&(c.current=h.length-1),{groups:d,group:null,drawn:g,pick:m,btn:{shown:g.length-1,chosen:h.length-1,kept:c.current,offered:m.length-1},block:He(g,i,o),cls:``}}function Ke(e){return{"--lb-cols":Math.max(1,e.metrics.length)}}function $(e){return{"--lb-cols":Oe(e.slice(1))}}function qe(e){return(e.lanes??1)>1?` w${e.lanes}`:``}function Je(e,t){return t===`last`?de[e]:`${de[e]} · ${A[t]}`}function Ye(e,t,n,r){return r===0?String(n):e<t?`${e} of ${t}`:String(t)}function Xe({shown:e,chosen:t,kept:n,offered:r,open:i,onOpen:a}){let o=r===0;return(0,Z.jsxs)(`button`,{className:`lb-colbtn${i?` on`:``}${o?` quiet`:``}`,onClick:a,disabled:o,children:[`Columns · `,(0,Z.jsx)(`b`,{children:Ye(e,t,n,r)})]})}function Ze({open:e,onOpen:t}){return(0,Z.jsx)(`button`,{className:`lb-colbtn${e?` on`:``}`,onClick:t,children:`View`})}function Qe({cols:e,group:t,toggleWind:n}){if(t){let e=t.units.length>1;return(0,Z.jsxs)(`div`,{className:`lb-cols${e?` u`:``}`,style:Ke(t),children:[(0,Z.jsx)(`span`,{children:`UTC`}),e&&(0,Z.jsx)(`span`,{className:`un`,children:`Unit`}),t.metrics.map(e=>(0,Z.jsxs)(`span`,{children:[e.head,(0,Z.jsx)($e,{of:e.unit})]},e.key))]})}return(0,Z.jsx)(`div`,{className:`lb-cols`,style:$(e),children:e.map(e=>e.tappable?(0,Z.jsxs)(`span`,{className:`tap${qe(e)}`,onClick:n,title:`Tap: knots ⇄ Beaufort`,children:[e.head,(0,Z.jsx)($e,{of:e.unit})]},e.key):(0,Z.jsxs)(`span`,{className:qe(e).trim(),children:[e.head,(0,Z.jsx)($e,{of:e.unit})]},e.key))})}function $e({of:e}){return(0,Z.jsx)(`b`,{className:`lb-u`,children:e===void 0||e===``?`\xA0`:e})}function et({book:e,mode:t,setMode:n,gran:r,setGran:i,shownGran:a,family:o,setFamily:s,shownFamily:c,leaving:l,modeLeaving:u,lanesHold:d,groupsHold:f,chosenHold:p,windUnit:m,toggleWind:h,selection:g,picking:_,setPicking:v,applySelection:y,width:b,exporting:x,setExporting:S,request:C,onView:w,onSave:T,saveErr:E,saveNote:D}){let{snaps:O,err:k,busy:A,hasMore:j,loadMore:M}=me(a),{groups:N,group:P,drawn:F,pick:I,btn:L,block:R,cls:z}=Ge(O,e,m,g,b,c,d,f,p);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`lb-ctrl${z}`,style:R,children:[(0,Z.jsx)(Fe,{mode:t,setMode:n}),(0,Z.jsx)(Ie,{leaving:u,children:(0,Z.jsx)(`div`,{className:`seg`,children:Me.map(e=>(0,Z.jsx)(`button`,{className:r===e?`on`:``,onClick:()=>i(e),children:e},e))})}),(0,Z.jsx)(Le,{groups:N,family:o,setFamily:s}),(0,Z.jsxs)(`div`,{className:`lb-acts`,children:[(0,Z.jsx)(Xe,{shown:L.shown,chosen:L.chosen,kept:L.kept,offered:L.offered,open:_,onOpen:()=>v(!_)}),(0,Z.jsx)(Ze,{open:x,onOpen:()=>S(!x)})]})]}),(0,Z.jsx)(Q,{open:_,style:R,cls:z,children:(0,Z.jsx)(le,{cols:I,applied:g,onApply:y,onCancel:()=>v(!1)})}),(0,Z.jsx)(Q,{open:x,style:R,cls:z,children:(0,Z.jsx)(Ee,{initial:C??void 0,onView:w,onSave:T})}),E&&(0,Z.jsx)(`div`,{className:`lb-err`,children:E}),D&&(0,Z.jsx)(`div`,{className:`lb-note`,children:D}),(0,Z.jsxs)(`div`,{className:`lb-frame${z}${l?` leaving`:``}`,style:R,children:[(0,Z.jsx)(it,{book:e,window:Ne[a],interval:de[a]}),(0,Z.jsxs)(`div`,{className:`lb-day`,style:$(F),children:[(0,Z.jsx)(`span`,{children:Ne[a]}),(0,Z.jsx)(`b`,{children:O.length})]}),(0,Z.jsx)(Qe,{cols:F,group:P,toggleWind:h}),k&&(0,Z.jsx)(`div`,{className:`lb-err`,children:k}),!A&&!k&&O.length===0?(0,Z.jsx)(Ue,{what:`Nothing was logged in this window (${Ne[a].toLowerCase()}).`}):(0,Z.jsx)(lt,{snaps:O,cols:F,group:P,footer:j?(0,Z.jsx)(`button`,{className:`lb-more`,onClick:M,disabled:A,children:A?`Loading…`:`Load ${fe[a]} more`}):null}),(0,Z.jsx)(at,{})]})]})}function tt({book:e,mode:t,setMode:n,family:r,setFamily:i,shownFamily:a,leaving:o,modeLeaving:s,lanesHold:c,groupsHold:l,chosenHold:u,windUnit:d,toggleWind:f,selection:p,picking:m,setPicking:h,applySelection:g,width:_,exporting:v,setExporting:y,request:b,onView:x,onSave:S,saveErr:w,saveNote:T}){let{dateStr:E,setDateStr:D,isToday:O,snaps:k,err:A,busy:j,prevDay:M,nextDay:N,goToday:P}=he(),{groups:F,group:I,drawn:L,pick:R,btn:z,block:B,cls:V}=Ge(k,e,d,p,_,a,c,l,u),H=O?`Today · ${new Date(E).toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`,timeZone:`UTC`})}`:new Date(E).toLocaleDateString(`en-GB`,{weekday:`short`,day:`2-digit`,month:`short`,timeZone:`UTC`}).replace(/,/g,``);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`lb-ctrl${V}`,style:B,children:[(0,Z.jsx)(Fe,{mode:t,setMode:n}),(0,Z.jsx)(Ie,{leaving:s,children:(0,Z.jsxs)(`div`,{className:`lb-date`,children:[(0,Z.jsx)(`button`,{className:`lb-step`,onClick:M,"aria-label":`Previous day`,children:`‹`}),(0,Z.jsx)(`input`,{type:`date`,className:`dt`,value:E,max:C(),onChange:e=>D(e.target.value)}),(0,Z.jsx)(`button`,{className:`lb-step`,onClick:N,disabled:O,"aria-label":`Next day`,children:`›`}),(0,Z.jsx)(`button`,{onClick:P,disabled:O,children:`Now`})]})}),(0,Z.jsx)(Le,{groups:F,family:r,setFamily:i}),(0,Z.jsxs)(`div`,{className:`lb-acts`,children:[(0,Z.jsx)(Xe,{shown:z.shown,chosen:z.chosen,kept:z.kept,offered:z.offered,open:m,onOpen:()=>h(!m)}),(0,Z.jsx)(Ze,{open:v,onOpen:()=>y(!v)})]})]}),(0,Z.jsx)(Q,{open:m,style:B,cls:V,children:(0,Z.jsx)(le,{cols:R,applied:p,onApply:g,onCancel:()=>h(!1)})}),(0,Z.jsx)(Q,{open:v,style:B,cls:V,children:(0,Z.jsx)(Ee,{initial:b??void 0,onView:x,onSave:S})}),w&&(0,Z.jsx)(`div`,{className:`lb-err`,children:w}),T&&(0,Z.jsx)(`div`,{className:`lb-note`,children:T}),(0,Z.jsxs)(`div`,{className:`lb-frame${V}${o?` leaving`:``}`,style:B,children:[(0,Z.jsx)(it,{book:e,window:H,interval:de[`1h`]}),(0,Z.jsxs)(`div`,{className:`lb-day`,style:$(L),children:[(0,Z.jsx)(`span`,{children:H}),(0,Z.jsx)(`b`,{children:k.length})]}),(0,Z.jsx)(Qe,{cols:L,group:I,toggleWind:f}),A&&(0,Z.jsx)(`div`,{className:`lb-err`,children:A}),!j&&k.length===0?(0,Z.jsx)(Ue,{what:`No telemetry was logged for this day.`}):(0,Z.jsx)(lt,{snaps:k,cols:L,group:I,footer:null}),(0,Z.jsx)(at,{})]})]})}function nt(){let e=new Date,t=e.toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`,year:`numeric`,timeZone:`UTC`}),n=e=>String(e).padStart(2,`0`);return`${t.toUpperCase()} · ${n(e.getUTCHours())}:${n(e.getUTCMinutes())} UTC`}var rt={bridge:`CHIEF OFFICER`,engine:`CHIEF ENGINEER`};function it({book:e,window:t,interval:n}){return(0,Z.jsxs)(`div`,{className:`lb-print-hd`,children:[(0,Z.jsxs)(`div`,{className:`ph-id`,children:[(0,Z.jsxs)(`span`,{className:`sp-lockup`,children:[(0,Z.jsx)(S,{className:`sp-glyph`}),(0,Z.jsx)(`span`,{className:`ph-wm`,children:`Siparu`})]}),(0,Z.jsxs)(`span`,{className:`ph-book`,children:[`LOGBOOK · `,(0,Z.jsx)(`b`,{children:e.toUpperCase()}),` · `,rt[e]]})]}),(0,Z.jsxs)(`div`,{className:`ph-meta`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`l`,children:`GENERATED`}),(0,Z.jsx)(`b`,{children:nt()})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`span`,{className:`l`,children:`WINDOW`}),(0,Z.jsx)(`b`,{children:`${t} · ${n} · UTC`.toUpperCase()})]})]})]})}function at(){return(0,Z.jsx)(`div`,{className:`lb-print-ft`,children:(0,Z.jsx)(`span`,{children:`siparu.app`})})}function ot(e){return new Date(e).toLocaleDateString(`en-GB`,{weekday:`short`,day:`2-digit`,month:`short`,year:`numeric`,timeZone:`UTC`}).replace(/,\s*/,` · `).toUpperCase()}function st(e,t){let n=(e,t)=>new Date(e).toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`,...t?{year:`numeric`}:{},timeZone:`UTC`});return e===t?n(t,!0):`${n(e,!1)} - ${n(t,!0)}`}function ct({book:e,req:t,setMode:n,family:r,setFamily:i,shownFamily:a,leaving:o,modeLeaving:s,lanesHold:c,groupsHold:l,chosenHold:u,windUnit:d,toggleWind:f,selection:p,picking:m,setPicking:h,applySelection:g,width:_,exporting:v,setExporting:y,request:b,onView:x,onSave:S,saveErr:w,saveNote:T,printing:E,donePrinting:D}){let O={from:C(),to:C(),gran:`1h`,format:`csv`,stats:[`last`],distance:!1,samples:!1,style:`screen`},k=t??O,A=k.stats[0]??`last`,{snaps:j,err:N,busy:P,truncated:F,loaded:I,minutesFrom:L,plain:R}=ve(k.from,k.to,k.gran,A),z=(0,M.useMemo)(()=>Be([...j].sort((e,t)=>e.ts-t.ts),R),[j,R]),{groups:B,group:V,drawn:U,pick:te,btn:W,block:G,cls:K}=Ge(z,e,d,p,_,a,c,l,u,!1),q=(0,M.useCallback)(()=>D(),[D]);(0,M.useEffect)(()=>{!E||!I||P||(k.style===`screen`&&document.documentElement.classList.add(`pdf-screen`),q(),window.print(),document.documentElement.classList.remove(`pdf-screen`))},[E,I,P,q,k.style]),(0,M.useEffect)(()=>()=>document.documentElement.classList.remove(`pdf-screen`),[]);let J=st(k.from,k.to),Y=Je(k.gran,A),X=(0,M.useMemo)(()=>{if(R.length===0)return[];let t=t=>ne(ee(H(t,d),e),p).map(e=>e.head),n=new Set(t(j));return t(R).filter(e=>!n.has(e))},[R,j,d,e,p]);return(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsxs)(`div`,{className:`lb-ctrl${K}`,style:G,children:[(0,Z.jsx)(Fe,{mode:`range`,setMode:n}),(0,Z.jsx)(Ie,{leaving:s,children:(0,Z.jsxs)(`button`,{className:`lb-colbtn on`,onClick:()=>y(!v),children:[J,` · `,(0,Z.jsx)(`b`,{children:Y})]})}),(0,Z.jsx)(Le,{groups:B,family:r,setFamily:i}),(0,Z.jsx)(`div`,{className:`lb-acts`,children:(0,Z.jsx)(Xe,{shown:W.shown,chosen:W.chosen,kept:W.kept,offered:W.offered,open:m,onOpen:()=>h(!m)})})]}),(0,Z.jsx)(Q,{open:m,style:G,cls:K,children:(0,Z.jsx)(le,{cols:te,applied:p,onApply:g,onCancel:()=>h(!1)})}),(0,Z.jsx)(Q,{open:v,style:G,cls:K,children:(0,Z.jsx)(Ee,{initial:b??void 0,onView:x,onSave:S})}),w&&(0,Z.jsx)(`div`,{className:`lb-err`,children:w}),T&&(0,Z.jsx)(`div`,{className:`lb-note`,children:T}),(0,Z.jsxs)(`div`,{className:`lb-frame dated${K}${o?` leaving`:``}`,style:G,children:[(0,Z.jsx)(it,{book:e,window:J,interval:Y}),(0,Z.jsxs)(`div`,{className:`lb-day`,style:$(U),children:[(0,Z.jsxs)(`span`,{children:[J,` · `,Y]}),(0,Z.jsx)(`b`,{children:F?`${j.length} of more`:j.length})]}),(0,Z.jsx)(Qe,{cols:U,group:V,toggleWind:f}),N&&(0,Z.jsx)(`div`,{className:`lb-err`,children:N}),X.length>0&&(0,Z.jsx)(`div`,{className:`lb-note`,children:ze(A,X,j)}),F&&(0,Z.jsxs)(`div`,{className:`lb-note`,children:[`This window holds more than `,5e3,` rows. The most recent `,5e3,` are here; a longer interval covers the same days in fewer.`]}),Re(L,k,j)&&(0,Z.jsx)(`div`,{className:`lb-note`,children:Re(L,k,j)}),!P&&z.length===0?(0,Z.jsx)(Ue,{what:Ve(k)}):(0,Z.jsx)(lt,{snaps:z,cols:U,group:V,footer:null,dated:!0}),(0,Z.jsx)(at,{})]})]})}function lt({snaps:e,cols:t,group:n,footer:r,dated:i=!1}){let a=[],o=null;for(let r of e){if(i){let e=ot(r.ts);e!==o&&(a.push((0,Z.jsx)(ut,{day:e,cols:t,group:n},`sep-${r.ts}`)),o=e)}a.push(n?(0,Z.jsx)(dt,{s:r,group:n},r.ts):(0,Z.jsx)(ft,{s:r,cols:t},r.ts))}return(0,Z.jsxs)(`div`,{className:`lb-rows`,style:n?Ke(n):$(t),children:[a,r]})}function ut({day:e,cols:t,group:n}){let r=n!==null&&n.units.length>1,i=n?n.metrics.map(e=>({key:e.key,head:e.head,unit:e.unit,cls:``})):t.slice(1).map(e=>({key:e.key,head:e.head,unit:e.unit,cls:qe(e).trim()}));return(0,Z.jsxs)(`div`,{className:`lb-sep${r?` u`:``}`,children:[(0,Z.jsx)(`span`,{className:`sd`,children:e}),r&&(0,Z.jsx)(`span`,{className:`sh`}),i.map(e=>(0,Z.jsxs)(`span`,{className:e.cls?`sh ${e.cls}`:`sh`,children:[e.head,(0,Z.jsx)($e,{of:e.unit})]},e.key))]})}function dt({s:e,group:t}){let n=t.units.length>1;return(0,Z.jsx)(Z.Fragment,{children:t.units.map((r,i)=>(0,Z.jsxs)(`div`,{className:`lb-row${n?` u`:``}${i>0?` cont`:``}`,children:[(0,Z.jsx)(`span`,{className:`tm`,children:N(e.ts)}),n&&(0,Z.jsx)(`span`,{className:`un`,children:r.head}),t.metrics.map(t=>(0,Z.jsx)(`span`,{className:`v`,children:W(e,r,t)},t.key))]},r.key))})}function ft({s:e,cols:t}){return(0,Z.jsx)(`div`,{className:`lb-row`,children:t.map((t,n)=>(0,Z.jsx)(`span`,{className:n===0?`tm`:`${t.dim?`v dim`:`v`}${qe(t)}`,children:t.cell(e)},t.key))})}var pt=[{to:`/logbook/bridge`,name:`Bridge`,keeper:`Chief officer`,holds:`Position, course and speed, the weather she ran in and the water under her.`,Icon:h},{to:`/logbook/engine`,name:`Engine`,keeper:`Chief engineer`,holds:`Engines, generators and tanks, as she reported them.`,Icon:y}];function mt(){let e=_();return(0,Z.jsx)(`div`,{className:`lb-door`,children:(0,Z.jsx)(`div`,{className:`lbd-cards`,children:pt.map(({to:t,name:n,keeper:r,holds:i,Icon:a})=>(0,Z.jsxs)(u,{to:e(t),replace:!0,className:`lbd-card`,children:[(0,Z.jsx)(a,{size:42}),(0,Z.jsx)(`span`,{className:`lbd-n`,children:n}),(0,Z.jsx)(`span`,{className:`lbd-k`,children:r}),(0,Z.jsx)(`span`,{className:`lbd-h`,children:i}),(0,Z.jsxs)(`span`,{className:`lbd-go`,children:[`Open `,(0,Z.jsx)(b,{size:15})]})]},t))})})}function ht({book:e}){return e?(0,Z.jsx)(Pe,{book:e}):(0,Z.jsx)(mt,{})}export{ht as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-CaR_m4Xc.js";import{t as r}from"./visibleInterval-CFxPzgzx.js";import{
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-CaR_m4Xc.js";import{t as r}from"./visibleInterval-CFxPzgzx.js";import{D as i,E as a,N as o,b as s,r as c,x as l,y as u}from"./index-D8cInHV9.js";import{a as d,i as f,n as p,o as m,r as h,s as g,t as _}from"./style-D1uNa2dX.js";var v=e(t(),1),y={fill:`#ffb938`,stroke:`#b38326`,glow:`rgba(255,185,56,0.65)`,dot:`#050706`};function b(e,t=y){let n=t.fill,r=t.stroke;return e===null||Number.isNaN(e)?`
|
|
2
2
|
<div style="
|
|
3
3
|
width: 14px; height: 14px;
|
|
4
4
|
background: ${n};
|
|
@@ -36,7 +36,7 @@ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./j
|
|
|
36
36
|
stroke-width="1.6"
|
|
37
37
|
stroke-linejoin="round"
|
|
38
38
|
style="filter: drop-shadow(0 0 3px ${n}88);"/>
|
|
39
|
-
</svg>`}var S={s:`s`,min:`m`,h:`h`,d:`d`};function C(e,t=Date.now()){let{value:n,unit:r}=
|
|
39
|
+
</svg>`}var S={s:`s`,min:`m`,h:`h`,d:`d`};function C(e,t=Date.now()){let{value:n,unit:r}=c((t-e)/1e3);return`${n}${S[r]} ago`}var w=e(g(),1),T=`siparu.aisPrefs`;function E(e,t,n){return Number.isFinite(e)?Math.min(n,Math.max(t,e)):t}function D(){try{let e=localStorage.getItem(T);if(!e)return{maxNm:5,limit:30};let t=JSON.parse(e);return{maxNm:E(Number(t.maxNm),1,20),limit:E(Number(t.limit),5,100)}}catch{return{maxNm:5,limit:30}}}function O(e){try{localStorage.setItem(T,JSON.stringify(e))}catch{}}var ee=[7.4246,43.7384],te=8,ne=1e4,k=3e4,A=5*6e4,j=24*3600*1e3,M=3e4,N=250;function P(e,t,n){return Math.min(n,Math.max(t,Math.round(e)))}function F(){return document.documentElement.dataset.theme===`day`?`day`:`night`}function I(e){return e.length<2?{type:`FeatureCollection`,features:[]}:{type:`FeatureCollection`,features:[{type:`Feature`,properties:{},geometry:{type:`LineString`,coordinates:e.map(e=>[e.lon,e.lat])}}]}}function L(e){let t=o(),n=(0,v.useRef)(null),i=(0,v.useRef)(null),s=(0,v.useRef)(null),c=(0,v.useRef)(null),l=(0,v.useRef)([]),u=(0,v.useRef)(!1),g=(0,v.useRef)(I([])),y=(0,v.useRef)(e);(0,v.useEffect)(()=>{y.current=e});let[b,x]=(0,v.useState)(!0),[S,C]=(0,v.useState)(0),[T,E]=(0,v.useState)(!1),[L,R]=(0,v.useState)(null),[z,B]=(0,v.useState)(null),[V,H]=(0,v.useState)(()=>D().maxNm),[U,W]=(0,v.useState)(()=>D().limit),G=(0,v.useCallback)(e=>{let t=P(e,1,20);H(t),O({maxNm:t,limit:U})},[U]),K=(0,v.useCallback)(e=>{let t=P(e,5,100);W(t),O({maxNm:V,limit:t})},[V]),[q,J]=(0,v.useState)([]),[Y,X]=(0,v.useState)(null),Z=(0,v.useRef)([]);(0,v.useEffect)(()=>{Z.current=q},[q]);let Q=(0,v.useCallback)(()=>{let e=i.current;if(!e)return;let t=Z.current;if(t.length>=2){let n=new w.default.LngLatBounds;for(let e of t)n.extend([e.lon,e.lat]);e.fitBounds(n,{padding:40,maxZoom:14});return}let n=s.current;n&&e.easeTo({center:n.getLngLat(),zoom:Math.max(e.getZoom(),12)})},[]),$=(0,v.useCallback)(e=>{let t=e.getSource(p);t&&t.setData(g.current)},[]);return(0,v.useEffect)(()=>{if(!n.current||i.current)return;let e=n.current,r=!1,a=null,o=null,u;return(async()=>{d();let n=await m(t);if(r)return;let s=h(n);s||B(`Chart unavailable - position and track only`);let c=e=>f(e,n,{track:y.current.track});a=new w.default.Map({container:e,style:c(F()),center:ee,zoom:te,attributionControl:{compact:!1,customAttribution:_},dragRotate:!1,pitchWithRotate:!1}),a.touchZoomRotate.disableRotation(),a.keyboard.disableRotation(),i.current=a,a.addControl(new w.default.NavigationControl({showCompass:!1}),y.current.zoomPosition??`bottom-left`);let l=!1;a.on(`sourcedata`,e=>{let t=!!e.tile;e.sourceId===s&&t&&!l&&(l=!0,B(null))}),u=window.setTimeout(()=>{!l&&s&&B(`Chart tiles unreachable - position and track only`)},ne),a.on(`style.load`,()=>{a&&$(a)}),o=new MutationObserver(()=>{a&&(a.setStyle(c(F())),$(a))}),o.observe(document.documentElement,{attributes:!0,attributeFilter:[`data-theme`]})})(),()=>{r=!0,window.clearTimeout(u),o?.disconnect(),l.current.forEach(e=>e.remove()),l.current=[],s.current=null,c.current=null,a?.remove(),i.current=null}},[$]),(0,v.useEffect)(()=>{let e=!0;return t.health().then(t=>{e&&(R(t.boat_name),E(t.ais?.receiver_seen===!0))}).catch(()=>{}),()=>{e=!1}},[]),(0,v.useEffect)(()=>{if(!b||!T){l.current.forEach(e=>e.remove()),l.current=[],C(0);return}let e=!1,n=async()=>{if(t.ais)try{let n=await t.ais.targets({maxNm:V,limit:U});if(e)return;let r=i.current;if(!r)return;l.current.forEach(e=>e.remove()),l.current=[];for(let e of n.targets){let t=e.cog_deg??e.heading_deg??null,n=document.createElement(`div`);n.className=`sp-ais-marker`,n.innerHTML=y.current.makeAis(t);let i=new w.default.Marker({element:n,anchor:`center`}).setLngLat([e.lon,e.lat]).setPopup(new w.default.Popup({closeButton:!0,offset:12,maxWidth:`280px`}).setHTML(y.current.aisPopupHtml(e))).addTo(r);l.current.push(i)}C(n.targets.length)}catch{}},a=window.setTimeout(n,N),o=r(n,M);return()=>{e=!0,window.clearTimeout(a),o()}},[b,T,V,U]),(0,v.useEffect)(()=>{let e=!1,n=async()=>{try{let n=Date.now(),r=await t.logbook.snapshots({from:n-j,order:`asc`,bucket:1,limit:2e3});if(e)return;let i=r.filter(e=>e.lat!==null&&e.lon!==null).map(e=>({lat:e.lat,lon:e.lon}));J(i)}catch{}};n();let i=r(n,A);return()=>{e=!0,i()}},[]),(0,v.useEffect)(()=>{g.current=I(q);let e=i.current;if(e&&($(e),!u.current&&q.length>=2)){u.current=!0;let t=new w.default.LngLatBounds;for(let e of q)t.extend([e.lon,e.lat]);e.fitBounds(t,{padding:40,maxZoom:14})}},[q,$]),(0,v.useEffect)(()=>{let e=!1,n=async()=>{try{let n=await t.logbook.snapshotLatest();if(e)return;X(n);let r=i.current;if(!r||n.lat===null||n.lon===null)return;let o=a(n.heading_true),l=y.current.makeBoat(o),d=[n.lon,n.lat];if(s.current)s.current.setLngLat(d),s.current.getElement().innerHTML=l,c.current?.setHTML(y.current.popupHtml(n,Date.now()));else{let e=document.createElement(`div`);e.className=`sp-boat-marker`,e.innerHTML=l;let t=new w.default.Popup({closeButton:!0,offset:16,maxWidth:`300px`}).setHTML(y.current.popupHtml(n,Date.now()));c.current=t,s.current=new w.default.Marker({element:e,anchor:`center`}).setLngLat(d).setPopup(t).addTo(r),u.current||r.easeTo({center:d,zoom:Math.max(r.getZoom(),11)})}}catch{}};n();let o=r(n,k);return()=>{e=!0,o()}},[]),{containerRef:n,aisOn:b,setAisOn:x,aisCount:S,aisMaxNm:V,setAisMaxNm:G,aisLimit:U,setAisLimit:K,aisAvailable:T,boatName:L,latest:Y,chartNote:z,recenter:Q}}var R=n();function z({open:e,onClose:t,maxNm:n,setMaxNm:r,limit:i,setLimit:a,variant:o}){let s=(0,v.useRef)(null);return(0,v.useEffect)(()=>{let t=s.current;if(!t||!e)return;let n=e=>e.stopPropagation(),r=[`pointerdown`,`mousedown`,`touchstart`,`dblclick`,`wheel`];for(let e of r)t.addEventListener(e,n);return()=>{for(let e of r)t.removeEventListener(e,n)}},[e]),(0,v.useEffect)(()=>{if(!e)return;let n=e=>{e.key===`Escape`&&t()};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e,t]),(0,v.useEffect)(()=>{if(!e)return;let n=e=>{let n=s.current;if(!n||!(e.target instanceof Node)||n.contains(e.target))return;let r=n.parentElement;r&&r.contains(e.target)||t()},r=window.setTimeout(()=>{document.addEventListener(`mousedown`,n),document.addEventListener(`touchstart`,n)},0);return()=>{window.clearTimeout(r),document.removeEventListener(`mousedown`,n),document.removeEventListener(`touchstart`,n)}},[e,t]),e?(0,R.jsxs)(`div`,{ref:s,className:`ais-filter ais-filter-${o}`,role:`dialog`,children:[(0,R.jsxs)(`div`,{className:`aisf-row`,children:[(0,R.jsxs)(`div`,{className:`aisf-label`,children:[(0,R.jsx)(`span`,{children:`Range`}),(0,R.jsxs)(`span`,{className:`aisf-value`,children:[n,` NM`]})]}),(0,R.jsx)(`input`,{type:`range`,min:1,max:20,step:1,value:n,onChange:e=>r(Number(e.target.value))})]}),(0,R.jsxs)(`div`,{className:`aisf-row`,children:[(0,R.jsxs)(`div`,{className:`aisf-label`,children:[(0,R.jsx)(`span`,{children:`Targets`}),(0,R.jsx)(`span`,{className:`aisf-value`,children:i})]}),(0,R.jsx)(`input`,{type:`range`,min:5,max:100,step:5,value:i,onChange:e=>a(Number(e.target.value))})]})]}):null}var B=`bottom-left`,V=`
|
|
40
40
|
.mp .maplibregl-map { background: var(--map-sea); font-family: var(--sp-font); font-size: 11px; outline: none; }
|
|
41
41
|
.mp .maplibregl-canvas { outline: none; }
|
|
42
42
|
|
|
@@ -88,15 +88,15 @@ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./j
|
|
|
88
88
|
.mp .ais-filter input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 14px; height: 14px; margin-top: -6px; background: var(--accent); }
|
|
89
89
|
.mp .ais-filter input[type="range"]::-moz-range-track { height: 2px; background: var(--rule); }
|
|
90
90
|
.mp .ais-filter input[type="range"]::-moz-range-thumb { width: 14px; height: 14px; border: none; background: var(--accent); }
|
|
91
|
-
`,H={fill:`#f2f3f5`,stroke:`#e5484d`,glow:`rgba(229,72,77,0.45)`,dot:`#e5484d`},U=`color: var(--muted); font-family: var(--sp-font); font-size: 8.5px; letter-spacing: 0.1em; text-transform: uppercase;`,W=`color: var(--text); font-family: var(--sp-font); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;`,G=`color: var(--text); font-family: var(--sp-font); font-weight: 600; font-size: 14px; margin-bottom: 8px;`,K=`font-family: var(--sp-font); font-size: 8px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #fff; background: var(--map-ais-hi); padding: 3px 5px;`,q=e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]);function J(e,t,n){let r=
|
|
91
|
+
`,H={fill:`#f2f3f5`,stroke:`#e5484d`,glow:`rgba(229,72,77,0.45)`,dot:`#e5484d`},U=`color: var(--muted); font-family: var(--sp-font); font-size: 8.5px; letter-spacing: 0.1em; text-transform: uppercase;`,W=`color: var(--text); font-family: var(--sp-font); font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums;`,G=`color: var(--text); font-family: var(--sp-font); font-weight: 600; font-size: 14px; margin-bottom: 8px;`,K=`font-family: var(--sp-font); font-size: 8px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: #fff; background: var(--map-ais-hi); padding: 3px 5px;`,q=e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]);function J(e,t,n){let r=i(e.sog),o=r===null?null:a(e.cog),c=a(e.heading_true),d=(e.nav_state??`·`).toUpperCase();return`
|
|
92
92
|
<div style="${G}">${q(n)}</div>
|
|
93
93
|
<div style="display:grid;grid-template-columns:auto 1fr;column-gap:14px;row-gap:4px;align-items:baseline;">
|
|
94
|
-
<span style="${U}">POS</span><span style="${W}">${
|
|
95
|
-
<span style="${U}">SOG</span><span style="${W}">${
|
|
96
|
-
<span style="${U}">COG</span><span style="${W}">${
|
|
97
|
-
<span style="${U}">HDG</span><span style="${W}">${
|
|
94
|
+
<span style="${U}">POS</span><span style="${W}">${u(e.lat,[`N`,`S`],2)} · ${u(e.lon,[`E`,`W`],3)}</span>
|
|
95
|
+
<span style="${U}">SOG</span><span style="${W}">${s(r,1,` kt`)}</span>
|
|
96
|
+
<span style="${U}">COG</span><span style="${W}">${o===null?`·`:s(o,0,`°`)}</span>
|
|
97
|
+
<span style="${U}">HDG</span><span style="${W}">${c===null?`·`:s(c,0,`°`)}</span>
|
|
98
98
|
<span style="${U}">NAV</span><span style="${W}">${q(d)}</span>
|
|
99
|
-
<span style="${U}">UPD</span><span style="${W}">${C(e.ts,t)} <span style="color:var(--muted)">(${
|
|
99
|
+
<span style="${U}">UPD</span><span style="${W}">${C(e.ts,t)} <span style="color:var(--muted)">(${l(e.ts).slice(11,19)})</span></span>
|
|
100
100
|
</div>
|
|
101
101
|
`}function Y(e){let t=e.name||`MMSI ${e.mmsi}`,n=e.sog_kn===null?`·`:`${e.sog_kn.toFixed(1)} kt`,r=e.cog_deg===null?`·`:`${String(Math.round(e.cog_deg)).padStart(3,`0`)}°`,i=e.distance_nm===null?`·`:`${e.distance_nm.toFixed(1)} NM`,a=e.length_m===null?`·`:`${Math.round(e.length_m)} m`,o=[e.ship_type,e.ais_class?`Class ${e.ais_class}`:null].filter(Boolean).join(` · `)||`·`;return`
|
|
102
102
|
<div style="${G}; display:flex; justify-content:space-between; gap:10px; align-items:center;">${q(t)} <span style="${K}">AIS</span></div>
|
|
@@ -108,4 +108,4 @@ import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./j
|
|
|
108
108
|
<span style="${U}">DIST</span><span style="${W}">${i}</span>
|
|
109
109
|
<span style="${U}">NAV</span><span style="${W}">${q((e.nav_state??`·`).toUpperCase())}</span>
|
|
110
110
|
</div>
|
|
111
|
-
`}function X(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Z(){let{containerRef:e,aisOn:t,setAisOn:n,aisCount:r,aisMaxNm:
|
|
111
|
+
`}function X(e){return e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function Z(){let{containerRef:e,aisOn:t,setAisOn:n,aisCount:r,aisMaxNm:o,setAisMaxNm:s,aisLimit:c,setAisLimit:l,latest:d,chartNote:f,aisAvailable:p,boatName:m}=L({track:{color:`#c23a3f`,width:1.8,dash:[2.8,2.2]},zoomPosition:B,popupHtml:(e,t)=>J(e,t,m??`This vessel`),aisPopupHtml:Y,makeBoat:e=>b(e,H),makeAis:e=>x(e,`#7a8a86`)}),[h,g]=(0,v.useState)(!1),_=d?a(d.heading_true):null,y=d?i(d.sog):null,S=d?.nav_state?X(d.nav_state):null,C=d?.lat!=null&&d?.lon!=null,w=C?`${u(d.lat,[`N`,`S`],2)} ${u(d.lon,[`E`,`W`],3)}`:`·`,T=[d&&!C?`Awaiting fix - the boat is not on this chart yet`:null,f].filter(e=>e!==null);return(0,R.jsxs)(`div`,{className:`mp`,children:[(0,R.jsx)(`style`,{children:V}),(0,R.jsx)(`div`,{ref:e,className:`mp-canvas`}),(0,R.jsxs)(`div`,{className:`mp-strip`,children:[(0,R.jsx)(`span`,{className:`co`,children:w}),(0,R.jsxs)(`span`,{className:`vec`,children:[(0,R.jsx)(`b`,{children:_===null?`·`:`${Math.round(_)}°`}),` · `,(0,R.jsx)(`b`,{children:y===null?`·`:y.toFixed(1)}),`kn`]}),S&&(0,R.jsx)(`span`,{className:`navp`,children:S})]}),T.length>0&&(0,R.jsx)(`div`,{className:`mp-notes`,children:T.map(e=>(0,R.jsx)(`div`,{className:`mp-chartnote`,children:e},e))}),p&&(0,R.jsxs)(`div`,{className:`mp-ctrl`,children:[(0,R.jsx)(z,{open:h,onClose:()=>g(!1),maxNm:o,setMaxNm:s,limit:c,setLimit:l,variant:`marine`}),(0,R.jsxs)(`button`,{className:`mp-btn${t?` on`:``}`,onClick:()=>n(!t),children:[`AIS`,t&&(0,R.jsx)(`span`,{className:`n`,children:r})]}),(0,R.jsxs)(`button`,{className:`mp-btn`,onClick:()=>g(e=>!e),children:[`Range · `,(0,R.jsx)(`span`,{className:`n`,children:o}),` Nm`]})]})]})}function Q(){return(0,R.jsx)(Z,{})}export{Q as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-CaR_m4Xc.js";import{M as r,N as i,i as a,m as o,n as s,r as c,t as l,u}from"./index-D8cInHV9.js";var d=e(t(),1),f=n(),p=`siparu.app/app`;function m(e){return Math.max(0,Math.round((new Date(e).getTime()-Date.now())/6e4))}function h(e){let{value:t,unit:n}=c((Date.now()-e)/1e3);return`${t}${n===`s`?`s`:` ${n}`} ago`}function g(e){return e?e.unentitled?e.lastError??`Remote watching is not active on this account.`:e.rejected||e.failures>0?e.lastError??`Not reaching Siparu.`:e.lastSentTs?`Sending · last frame ${h(e.lastSentTs)}`:`Waiting to send the first frame.`:`Checking the link…`}function _({sealing:e}){let t=i().pair??r.pair,[n,c]=(0,d.useState)(!1),[u,h]=(0,d.useState)(!1),[_,v]=(0,d.useState)(!1),{data:y,refresh:b}=o(()=>t.status(),n?5e3:3e4,[]);(0,d.useEffect)(()=>{let e=y?.state;c(e===`showing_code`||e===`awaiting_approval`)},[y?.state]);async function x(e){h(!0);try{await e()}catch{}finally{h(!1),v(!1),b()}}let S=s(e),C=S?(0,f.jsx)(`div`,{className:`pair warn`,children:(0,f.jsxs)(`div`,{className:`pl`,children:[(0,f.jsx)(`div`,{className:`t`,children:S.title}),(0,f.jsx)(`div`,{className:`s`,children:S.detail})]})}):null,w=e?.screens??[],T=w.length>0?(0,f.jsx)(`div`,{className:`pair`,children:(0,f.jsxs)(`div`,{className:`pl`,children:[(0,f.jsx)(`div`,{className:`fps`,children:w.map((e,t)=>(0,f.jsx)(`span`,{className:`fp`,children:e},`${e}-${t}`))}),(0,f.jsx)(`div`,{className:`s`,children:`Every screen that can open her reports has a line here. If the line on your phone is missing, she is not sealing to it; if a line here is not one of yours, it can read her.`})]})}):null,E=l(e),D=E?(0,f.jsxs)(f.Fragment,{children:[E.unapproved.length>0?(0,f.jsx)(`div`,{className:`pair warn`,children:(0,f.jsxs)(`div`,{className:`pl`,children:[(0,f.jsx)(`div`,{className:`t`,children:`She will not seal to these screens`}),(0,f.jsx)(`div`,{className:`s`,children:`Nothing she trusts has vouched for them, so they receive nothing at all. A line here you did not add is somebody else's key on your list: remove it from the boat's page ashore, and if you cannot account for it, pair her again from this screen.`}),(0,f.jsx)(`div`,{className:`fps`,children:E.unapproved.map(e=>(0,f.jsxs)(`span`,{className:`fp`,children:[e.kid,` · `,e.reason]},e.kid))})]})}):null,E.unwrapped.length>0?(0,f.jsx)(`div`,{className:`pair warn`,children:(0,f.jsxs)(`div`,{className:`pl`,children:[(0,f.jsx)(`div`,{className:`t`,children:`Authorised, and still receiving nothing`}),(0,f.jsx)(`div`,{className:`s`,children:`These screens are on her list and she could not wrap her last report to them. From ashore that looks exactly like a boat gone quiet, which is why it is named here.`}),(0,f.jsx)(`div`,{className:`fps`,children:E.unwrapped.map(e=>(0,f.jsxs)(`span`,{className:`fp`,children:[e.kid,` · `,e.reason]},e.kid))})]})}):null,E.unpinned?(0,f.jsx)(`div`,{className:`pair`,children:(0,f.jsxs)(`div`,{className:`pl`,children:[(0,f.jsx)(`div`,{className:`t`,children:`Her screens are not pinned`}),(0,f.jsx)(`div`,{className:`s`,children:`She was paired before screens could vouch for one another, so she checks that a key is well formed and nothing about who put it on her list. She still seals every report. Pair her again from this screen to pin the first one, and every later screen will have to chain to it.`})]})}):null]}):null,O=(E?.unapproved.length??0)+(E?.unwrapped.length??0),k=T||D?(0,f.jsxs)(`section`,{className:`sp-sec`,children:[(0,f.jsxs)(`h2`,{className:`sp-sec-h`,children:[(0,f.jsx)(`span`,{className:`sp-sec-n`,children:`Screens`}),(0,f.jsx)(`span`,{className:`sp-sec-badge${O>0?` quiet`:``}`,children:O>0?`${O} refused`:`${w.length} sealed`})]}),(0,f.jsxs)(`div`,{className:`sp-glass`,children:[T,D]})]}):null,A=(e,t)=>(0,f.jsxs)(`section`,{className:`sp-sec`,children:[(0,f.jsxs)(`h2`,{className:`sp-sec-h`,children:[(0,f.jsx)(`span`,{className:`sp-sec-n`,children:`Link ashore`}),e?(0,f.jsxs)(`span`,{className:`sp-sec-badge${e.quiet?` quiet`:``}`,children:[e.live?(0,f.jsx)(`span`,{className:`rm-dot`,"aria-hidden":`true`}):null,e.text]}):null]}),(0,f.jsx)(`div`,{className:`sp-glass`,children:t})]});if(!y)return(0,f.jsxs)(f.Fragment,{children:[A(null,C??(0,f.jsx)(`div`,{className:`pair`,children:(0,f.jsx)(`div`,{className:`pl`,children:(0,f.jsx)(`div`,{className:`s`,children:`Checking the link…`})})})),k]});let j=(e,t,n)=>(0,f.jsx)(`button`,{className:`pbtn${n?` ${n}`:``}`,disabled:u,onClick:t,children:e}),M=y.pairing_locked===!0,N=(0,f.jsx)(a,{on:y.security_off,locked:M}),P=y.revoke_pending?(0,f.jsx)(`div`,{className:`pair warn`,children:(0,f.jsxs)(`div`,{className:`pl`,children:[(0,f.jsx)(`div`,{className:`t`,children:`Still revoking the old key`}),(0,f.jsx)(`div`,{className:`s`,children:`Remote watching is off on this boat, but Siparu could not be reached to revoke its copy of the key. It will keep trying whenever the boat is online.`})]})}):null,F=(()=>{switch(y.state){case`idle`:case`expired`:return(0,f.jsxs)(`div`,{className:`pair`,children:[(0,f.jsxs)(`div`,{className:`pl`,children:[(0,f.jsx)(`div`,{className:`t`,children:`Remote watching`}),(0,f.jsx)(`div`,{className:`s`,children:y.state===`expired`?`The code expired. Nothing was linked.`:`Off - this boat is not linked to an account.`})]}),!M&&j(y.state===`expired`?`New code`:`Turn on`,()=>x(t.start))]});case`showing_code`:return(0,f.jsxs)(`div`,{className:`pair`,children:[(0,f.jsxs)(`div`,{className:`pl`,children:[(0,f.jsx)(`div`,{className:`t`,children:`Remote watching`}),(0,f.jsx)(`div`,{className:`code`,children:y.userCode}),(0,f.jsxs)(`div`,{className:`s`,children:[`Enter this at `,(0,f.jsx)(`b`,{children:p}),` · `,m(y.expiresAt),` min left`]})]}),j(`Cancel`,()=>x(t.deny),`ghost`)]});case`awaiting_approval`:return(0,f.jsxs)(`div`,{className:`pair asking`,children:[(0,f.jsxs)(`div`,{className:`pl`,children:[(0,f.jsx)(`div`,{className:`t`,children:`Someone wants to pair`}),(0,f.jsx)(`div`,{className:`who`,children:y.email??`an account we cannot name`}),y.device?(0,f.jsx)(`div`,{className:`fps`,children:(0,f.jsx)(`span`,{className:`fp`,children:y.device.fingerprint})}):null,(0,f.jsx)(`div`,{className:`s`,children:y.device?`Approve only if this is you, and only if that line matches the one on your phone. They will see where this boat is.`:`Approve only if this is you. They will see where this boat is.`})]}),(0,f.jsxs)(`div`,{className:`acts`,children:[j(`Deny`,()=>x(t.deny),`ghost`),!M&&j(`Approve`,()=>x(t.approve),`accent`)]})]});case`paired`:return(0,f.jsxs)(`div`,{className:`pair${y.uplink?.rejected?` err`:``}`,children:[(0,f.jsxs)(`div`,{className:`pl`,children:[(0,f.jsx)(`div`,{className:`t`,children:`Remote watching`}),(0,f.jsx)(`div`,{className:`who`,children:y.email??`linked account`}),!_&&!S&&(0,f.jsx)(`div`,{className:`s`,children:g(y.uplink)})]}),M?null:_?(0,f.jsxs)(`div`,{className:`acts`,children:[j(`Keep`,()=>v(!1),`ghost`),j(`Unlink`,()=>x(t.reset),`accent`)]}):(0,f.jsxs)(`div`,{className:`acts`,children:[j(`Pair again`,()=>x(t.start),`ghost`),j(`Turn off`,()=>v(!0),`ghost`)]})]});case`error`:return(0,f.jsxs)(`div`,{className:`pair err`,children:[(0,f.jsxs)(`div`,{className:`pl`,children:[(0,f.jsx)(`div`,{className:`t`,children:`Remote watching`}),(0,f.jsx)(`div`,{className:`s`,children:y.message})]}),!M&&(0,f.jsxs)(`div`,{className:`acts`,children:[j(`Dismiss`,()=>x(t.reset),`ghost`),j(`Retry`,()=>x(t.start))]})]})}})();return(0,f.jsxs)(f.Fragment,{children:[A((()=>{switch(y.state){case`paired`:{let e=y.uplink;return e?.unentitled?{text:`inactive`}:e?.rejected||S?{text:`not sending`,quiet:!0}:!e||e.failures>0?{text:`not reaching`,quiet:!0}:e.lastSentTs?{text:`on`,live:!0}:{text:`on`}}case`showing_code`:return{text:`waiting`};case`awaiting_approval`:return{text:`asking`,quiet:!0};case`error`:return{text:`error`,quiet:!0};default:return{text:`off`}}})(),(0,f.jsxs)(f.Fragment,{children:[C,N,P,F]})),k]})}var v=3e4;function y(){let{data:e}=o(u.health,v,[]);return(0,f.jsx)(`div`,{className:`sp-remote`,children:(0,f.jsx)(_,{sealing:e?.sealing??null})})}export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./jsx-runtime-CaR_m4Xc.js";import{
|
|
1
|
+
import{t as e}from"./jsx-runtime-CaR_m4Xc.js";import{P as t,g as n,o as r}from"./index-D8cInHV9.js";var i=e(),a=`/admin/#/security/users`;function o({admin:e}){let a=n();return(0,i.jsx)(`div`,{className:`doc`,children:(0,i.jsxs)(`div`,{className:`doc-in`,children:[(0,i.jsx)(`div`,{className:`doc-eyebrow`,children:`Signal K`}),(0,i.jsx)(`h1`,{className:`doc-h`,children:`Turning on security`}),(0,i.jsx)(`p`,{className:`doc-lead`,children:`Signal K is running without an account on it. Anyone who can reach this network can read the boat, and can use this plugin's own controls to link her to another account or cut her loose. Until there is an account, Siparu refuses those writes: pairing, unpairing and log edits stay locked.`}),(0,i.jsx)(`h2`,{className:`doc-h2`,children:`What to do`}),(0,i.jsxs)(`ol`,{className:`doc-steps`,children:[(0,i.jsxs)(`li`,{children:[(0,i.jsx)(`b`,{children:`Open Signal K's admin pages.`}),` `,e?(0,i.jsxs)(i.Fragment,{children:[`They are on this same server, at`,` `,(0,i.jsx)(`a`,{href:e,target:`_blank`,rel:`noreferrer`,children:`/admin`}),`.`]}):(0,i.jsxs)(i.Fragment,{children:[`They are on the boat's own server, under `,(0,i.jsx)(`b`,{children:`/admin`}),`: open them from a device on her network, the way you open her dashboard aboard.`]}),` `,`Nothing here is a Siparu account: this is the boat's own server, and the account you are about to make lives on board.`]}),(0,i.jsxs)(`li`,{children:[(0,i.jsx)(`b`,{children:`Go to Security, then Users.`}),` With no account yet, that page offers to make the first one.`]}),(0,i.jsxs)(`li`,{children:[(0,i.jsx)(`b`,{children:`Pick a username and a password.`}),` Write them down somewhere that is not the boat. There is no reset from ashore.`]}),(0,i.jsxs)(`li`,{children:[(0,i.jsx)(`b`,{children:`Press Enable, then Restart.`}),` Signal K writes the account down but keeps running open until it is restarted; it says so in red under the form. The Restart button is at the top of its admin pages. Log in when it comes back.`]}),(0,i.jsxs)(`li`,{children:[(0,i.jsx)(`b`,{children:`Decide about "Allow Readonly Access".`}),` It is under Security, then Settings, and newer servers also ask on the form you just filled in. Ticked, anyone on the network can still read the boat and use this app without logging in, and only the controls that change something ask for the password. Unticked, everything asks. Signal K's own note is that readonly access exposes your data on the local network and potentially the public internet, so leave it off on a shared crew or marina network and on only where you know who is on the wire.`]})]}),(0,i.jsx)(`h2`,{className:`doc-h2`,children:`After that`}),(0,i.jsx)(`p`,{className:`doc-p`,children:`This notice stops once the server is back up and asking for an account. It follows whether the server asks at all, not who is allowed in, so it clears whichever way you answer the readonly question. Siparu's locked writes unlock for anyone logged in with admin rights.`}),(0,i.jsx)(`h2`,{className:`doc-h2`,children:`If the network really is yours`}),(0,i.jsx)(`p`,{className:`doc-p`,children:`On a boat with nothing else on her wire, you can leave the server open and tell the plugin you have decided so: the setting is in Signal K under Apps & Plugins, in Siparu's own configuration. The writes unlock. The notice stays, because it reports the door and not the decision: the server is still open. It is the weaker answer of the two, and it is not the one to pick because the password is a nuisance. An open server also lets anything on that network install code, which no setting of ours can hold shut.`}),(0,i.jsx)(`div`,{className:`doc-back`,children:(0,i.jsxs)(t,{to:a(`/`),className:`doc-go`,children:[`Back to the boat `,(0,i.jsx)(r,{size:15})]})})]})})}function s(){return(0,i.jsx)(o,{admin:a})}export{s as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-CaR_m4Xc.js";import{F as r,N as i,a,b as o,f as s,h as c,j as l,m as u,r as d,y as f}from"./index-D8cInHV9.js";import{a as p,n as m,o as h,r as g}from"./export-CQYXr7nu.js";import{a as _,i as v,n as y,o as b,s as x,t as S}from"./style-D1uNa2dX.js";var C=e(t(),1),w=[{mode:`total_l`,label:`Litres`},{mode:`total_usgal`,label:`US gallons`},{mode:`total_impgal`,label:`Imp gallons`},{mode:`per_nm`,label:`Litres / nm`},{mode:`nm_per_l`,label:`nm / L`},{mode:`per_hour`,label:`Litres / hour`}],T=.26417205,E=.21996923,D=1e-6;function O(e,t,n){return`${e.toFixed(n)} ${t}`}function k(e,t,n,r){if(e===null||!Number.isFinite(e))return null;switch(r){case`total_l`:return O(e,`L`,+(e<100));case`total_usgal`:return O(e*T,`US gal`,1);case`total_impgal`:return O(e*E,`Imp gal`,1);case`per_nm`:return t>D?O(e/t,`L/nm`,2):null;case`nm_per_l`:return e>D?O(t/e,`nm/L`,2):null;case`per_hour`:return n>D?O(e/n,`L/h`,1):null}}var A=`Could not load voyage data`;function j(e){return e instanceof l?e.detail||A:e instanceof DOMException&&e.name===`TimeoutError`?`She did not answer in time`:A}function M(e=0){let t=i(),{data:n,error:r}=u(t.voyage.current,6e4,[e],`voyage:current`),[a,o]=(0,C.useState)(null),[s,l]=(0,C.useState)([]),[d,f]=(0,C.useState)(!0),[p,m]=(0,C.useState)(null);return(0,C.useEffect)(()=>{let e=!1;return(async()=>{try{let[n,r]=await Promise.all([t.voyage.stats(),t.voyage.list(50)]);e||(o(n),l(r),m(null))}catch(t){e||m(j(t))}finally{e||f(!1)}})(),()=>{e=!0}},[e]),{current:n??null,currentStale:r!==null,currentSeenTs:c(`voyage:current`),stats:a,list:s,loading:d,err:p}}var N=e(x(),1),P=n();function F(){return document.documentElement.dataset.theme===`day`?`day`:`night`}function I(e,t){let n=document.createElement(`div`);return n.style.cssText=`width:10px;height:10px;border-radius:50%;border:2px solid ${e};background:${t?e:`transparent`};`,n}function L({track:e}){let t=i(),n=(0,C.useRef)(null),r=(0,C.useRef)(null);return(0,C.useEffect)(()=>{if(!n.current||r.current)return;let i=n.current,a=document.documentElement,o=getComputedStyle(a).getPropertyValue(`--accent`).trim()||`#e5484d`,s=!1,c=null,l=null;return(async()=>{_();let n=await b(t);if(s)return;let u=()=>v(F(),n,{track:{color:o,width:3}}),d=e.filter(e=>e.lat!==null&&e.lon!==null).map(e=>[e.lon,e.lat]);c=new N.default.Map({container:i,style:u(),center:[7.42,43.7],zoom:9,attributionControl:{compact:!1,customAttribution:S},dragRotate:!1,pitchWithRotate:!1}),c.touchZoomRotate.disableRotation(),r.current=c;let f=()=>{if(!c)return;let e=c.getSource(y);e&&d.length>=2&&e.setData({type:`FeatureCollection`,features:[{type:`Feature`,properties:{},geometry:{type:`LineString`,coordinates:d}}]})};if(c.on(`style.load`,f),f(),d.length>=2){new N.default.Marker({element:I(o,!1),anchor:`center`}).setLngLat(d[0]).addTo(c),new N.default.Marker({element:I(o,!0),anchor:`center`}).setLngLat(d[d.length-1]).addTo(c);let e=new N.default.LngLatBounds;for(let t of d)e.extend(t);c.fitBounds(e,{padding:22,maxZoom:15,animate:!1})}l=new MutationObserver(()=>{c?.setStyle(u()),f()}),l.observe(a,{attributes:!0,attributeFilter:[`data-theme`]})})(),()=>{s=!0,l?.disconnect(),c?.remove(),r.current=null}},[e]),(0,P.jsx)(`div`,{ref:n,className:`vy-map`})}var R=e(r(),1);function z(e){let t=e.match(/^propulsion\.([^.]+)\.fuel\.rate$/),n=t?t[1]:e;return n.charAt(0).toUpperCase()+n.slice(1)}function B(e){let t=new Set(e.available);return e.selected.filter(e=>!t.has(e))}function V(e){return e.available.length>1||e.selected.length>0}function H(e){return[...e.available.map(e=>({path:e,reporting:!0})),...B(e).map(e=>({path:e,reporting:!1}))]}function U(e){let t=B(e);return t.length===0||t.length<e.selected.length?null:`No fuel counted: ${t.map(z).join(`, `)} is selected but not reporting a rate.`}function W(e){let t=B(e);return t.length>0&&t.length===e.selected.length?`${t.length===1?z(t[0]):`${t.length} engines`} · not reporting`:e.selected.length===0?`All`:e.selected.length===1?z(e.selected[0]):`${e.selected.length} engines`}function G({view:e,onClose:t,onApplied:n}){let r=i(),[o,s]=(0,C.useState)(()=>new Set(e.selected)),[c,u]=(0,C.useState)(!1),[d,f]=(0,C.useState)(null),p=(0,C.useRef)(null),m=e=>{f(null),s(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},h=async()=>{let e=[...o].sort();u(!0),f(null);try{if(!r.config.setFuelPaths)throw Error(`this setting is written aboard`);await r.config.setFuelPaths(e);let t=e.join(`,`);for(let e=0;e<12;e++){await new Promise(e=>setTimeout(e,700));try{if([...(await r.config.fuelPaths()).selected].sort().join(`,`)===t)break}catch{}}n(),p.current?.()}catch(e){e instanceof l?f(e.code===`security_off`?`Signal K security is off, so the fuel source is locked. Add an admin user in Signal K.`:e.detail||`Could not apply the change`):f(e instanceof Error?e.message:`Could not apply the change`),u(!1)}},g=U(e),_=document.querySelector(`.swiss.sp-screen`)??document.body;return(0,R.createPortal)((0,P.jsxs)(a,{title:`Fuel source`,eyebrow:`voyage fuel`,onClose:t,closeRef:p,footer:(0,P.jsx)(`button`,{type:`button`,className:`fs-apply`,onClick:h,disabled:c,children:c?`Applying…`:`Apply`}),children:[(0,P.jsx)(`p`,{className:`fs-note`,children:`Which engines count toward voyage fuel. With none selected, every reporting engine is summed.`}),g&&(0,P.jsx)(`div`,{className:`fs-quiet`,children:g}),(0,P.jsx)(`div`,{className:`fs-list`,role:`group`,"aria-label":`Fuel-rate sources`,children:H(e).map(({path:e,reporting:t})=>{let n=o.has(e);return(0,P.jsxs)(`button`,{type:`button`,className:`fs-row${n?` on`:``}${t?``:` off-air`}`,role:`checkbox`,"aria-checked":n,onClick:()=>m(e),disabled:c,children:[(0,P.jsxs)(`span`,{className:`fs-name`,children:[z(e),!t&&(0,P.jsx)(`span`,{className:`fs-tag`,children:` not reporting`})]}),(0,P.jsx)(`span`,{className:`fs-path`,children:e})]},e)})}),d&&(0,P.jsx)(`div`,{className:`fs-err`,children:d})]}),_)}var K=`siparu.fuelMode`;function q(){let e=localStorage.getItem(K);return w.some(t=>t.mode===e)?e:`total_l`}var J=`(min-width: 1000px)`,Y=[{k:`today`,label:`Today`},{k:`yesterday`,label:`Yesterday`},{k:`rolling_7d`,label:`7 days`},{k:`season`,label:`Season`}],X={not_found:`That passage is no longer in the log.`,no_previous:`There is no earlier passage to join this one to.`,voyage_open:`This passage is still being recorded. It can be edited once it ends.`,nothing_to_undo:`This passage was not joined by hand.`,admin_required:`Sign in to Signal K as an administrator to edit the log.`,security_off:`Signal K security is off, so the log is locked. Add an admin user in Signal K.`};function Z(e){if(e===null||e<=0)return`·`;let t=Math.round(e*60),n=Math.floor(t/60),r=t%60;return n>0?`${n}h ${r}m`:`${r}m`}function Q(e){return new Date(e).toLocaleDateString(`en-GB`,{day:`2-digit`,month:`short`})}function ee(e){let{value:t,unit:n}=d((Date.now()-e)/1e3);return`${t}${n===`s`?`s`:` ${n}`} ago`}function $(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${n(t.getHours())}:${n(t.getMinutes())}`}function te(e){return!e.start_port&&!e.end_port?null:e.end_ts===null?e.start_port?`${e.start_port} →`:null:`${e.start_port??`·`} → ${e.end_port??`·`}`}function ne(){let e=i(),[t,n]=(0,C.useState)(0),r=M(t),a=s(J),[o,c]=(0,C.useState)(`today`),[u,d]=(0,C.useState)(null),[f,p]=(0,C.useState)({}),[_,v]=(0,C.useState)(q),[y,b]=(0,C.useState)(null),[x,S]=(0,C.useState)(!1),[w,T]=(0,C.useState)(null),[E,D]=(0,C.useState)([]),[O,k]=(0,C.useState)(null);(0,C.useEffect)(()=>{localStorage.setItem(K,_)},[_]),(0,C.useEffect)(()=>{let t=!0;return e.health().then(e=>{t&&T(e.boat_name)}).catch(()=>{}),()=>{t=!1}},[]);let A=e.voyage.edits,j=e.voyage.mergePrevious,N=e.voyage.undoMerge;(0,C.useEffect)(()=>{if(!A)return;let e=!0;return A().then(t=>{e&&D(t.merged)}).catch(()=>{}),()=>{e=!1}},[t,A]),(0,C.useEffect)(()=>{let t=!1;return e.config.fuelPaths().then(e=>!t&&b(e)).catch(()=>{}),()=>{t=!0}},[t]);let F=!!y&&V(y)&&e.config.setFuelPaths!==void 0,I=y?U(y):null,L=r.current&&r.current.end_ts===null?r.current:null,R=async t=>{if(u===t){d(null);return}if(d(t),!f[t])try{let n=await e.voyage.track(t);p(e=>({...e,[t]:n}))}catch{}},z=r.stats?.[o]??null,B=async e=>{k(null);try{let t=await e();if(!t.ok){k(X[t.error??``]??`That edit could not be made.`);return}d(null),p({}),n(e=>e+1)}catch(e){e instanceof l?k(X[e.code??``]??(e.detail||`That edit could not be made.`)):k(`The boat did not answer.`)}};return(0,P.jsxs)(`div`,{className:`vy`,children:[(0,P.jsxs)(`div`,{className:`vy-print-hd`,"aria-hidden":`true`,children:[(0,P.jsx)(`span`,{className:`b`,children:w??`Passage record`}),(0,P.jsx)(`span`,{className:`d`,children:new Date().toISOString().slice(0,10)})]}),L&&(0,P.jsxs)(`section`,{className:`sp-sec vy-sec-active`,children:[(0,P.jsxs)(`h2`,{className:`sp-sec-h`,children:[(0,P.jsx)(`span`,{className:`sp-sec-n`,children:`Under way`}),L.start_port?(0,P.jsxs)(`span`,{className:`sp-sec-note`,children:[`from `,L.start_port]}):null,r.currentStale?(0,P.jsxs)(`span`,{className:`sp-sec-badge quiet`,children:[`since `,$(L.start_ts),r.currentSeenTs===null?` · unreachable`:` · last seen ${ee(r.currentSeenTs)}`]}):(0,P.jsxs)(`span`,{className:`sp-sec-badge`,children:[(0,P.jsx)(`span`,{className:`vy-pulse`,"aria-hidden":`true`}),`since `,$(L.start_ts)]})]}),(0,P.jsx)(`div`,{className:`sp-glass`,children:(0,P.jsx)(re,{v:L})})]}),(0,P.jsxs)(`section`,{className:`sp-sec vy-sec-totals`,children:[(0,P.jsxs)(`h2`,{className:`sp-sec-h`,children:[(0,P.jsx)(`span`,{className:`sp-sec-n`,children:`Totals`}),!a&&(0,P.jsx)(`span`,{className:`sp-sec-note`,children:Y.find(e=>e.k===o)?.label.toLowerCase()}),r.err?(0,P.jsx)(`span`,{className:`sp-sec-badge quiet`,children:`unreachable`}):null]}),(0,P.jsx)(`div`,{className:`sp-glass`,children:a?(0,P.jsx)(ie,{stats:r.stats,loading:r.loading}):(0,P.jsxs)(P.Fragment,{children:[(0,P.jsx)(`div`,{className:`vy-seg seg`,role:`group`,"aria-label":`Stats window`,children:Y.map(e=>(0,P.jsx)(`button`,{className:o===e.k?`on`:``,onClick:()=>c(e.k),children:e.label},e.k))}),(0,P.jsx)(ae,{roll:z,loading:r.loading})]})})]}),(0,P.jsxs)(`section`,{className:`sp-sec vy-sec-voyages`,children:[(0,P.jsxs)(`h2`,{className:`sp-sec-h`,children:[(0,P.jsx)(`span`,{className:`sp-sec-n`,children:`Voyages`}),r.err?(0,P.jsx)(`span`,{className:`sp-sec-badge quiet`,children:`unreachable`}):r.loading&&r.list.length===0?null:(0,P.jsx)(`span`,{className:`sp-sec-badge`,children:r.list.length===50?`50 shown`:r.list.length})]}),(0,P.jsxs)(`div`,{className:`sp-glass`,children:[(F||r.list.length>0)&&(0,P.jsx)(`div`,{className:`vy-hd`,children:(0,P.jsxs)(`span`,{className:`vy-hd-acts`,children:[F&&(0,P.jsxs)(`button`,{type:`button`,className:`vy-fuelsrc`,onClick:()=>S(!0),children:[`Fuel · `,W(y)]}),r.list.length>0&&(0,P.jsx)(`button`,{type:`button`,className:`vy-fuelsrc`,onClick:()=>m(g(`siparu-voyages`,Date.now(),`csv`),`text/csv`,h(r.list)),children:`CSV`}),r.list.length>0&&(0,P.jsx)(`button`,{type:`button`,className:`vy-fuelsrc`,onClick:()=>window.print(),children:`Print`})]})}),r.err?(0,P.jsx)(`div`,{className:`vy-err`,children:r.err}):!r.loading&&r.list.length===0?(0,P.jsxs)(`div`,{className:`sp-empty`,children:[(0,P.jsx)(`div`,{className:`em-t`,children:`No voyages yet`}),(0,P.jsx)(`div`,{className:`em-s`,children:`Passages appear here once the boat gets under way.`})]}):(0,P.jsx)(`div`,{className:`vy-list`,children:r.list.map((e,t)=>(0,P.jsx)(oe,{v:e,prev:r.list[t+1],wasJoined:E.includes(e.id),open:u===e.id,track:f[e.id],fuelNotice:I,fuelMode:_,onFuelMode:v,onToggle:()=>R(e.id),onMerge:j?()=>B(()=>j(e.id)):void 0,onUndoMerge:N?()=>B(()=>N(e.id)):void 0,editErr:u===e.id?O:null},e.id))})]})]}),x&&y&&(0,P.jsx)(G,{view:y,onClose:()=>S(!1),onApplied:()=>n(e=>e+1)})]})}function re({v:e}){return(0,P.jsx)(`div`,{className:`vy-active`,children:(0,P.jsxs)(`div`,{className:`vy-active-grid`,children:[(0,P.jsxs)(`div`,{className:`vy-a-hero`,children:[(0,P.jsxs)(`div`,{className:`t`,children:[`Distance · `,(0,P.jsx)(`span`,{className:`sub`,children:`nm`})]}),(0,P.jsx)(`div`,{className:`n`,children:o(e.distance_nm,1)})]}),(0,P.jsxs)(`div`,{className:`vy-a-cell`,children:[(0,P.jsx)(`div`,{className:`t`,children:`Underway`}),(0,P.jsx)(`div`,{className:`v`,children:Z(e.hours_underway)})]}),(0,P.jsxs)(`div`,{className:`vy-a-cell`,children:[(0,P.jsx)(`div`,{className:`t`,children:`Avg SOG`}),(0,P.jsx)(`div`,{className:`v`,children:e.avg_sog_kn===null?`·`:(0,P.jsxs)(P.Fragment,{children:[e.avg_sog_kn.toFixed(1),(0,P.jsx)(`span`,{className:`u`,children:`kn`})]})})]})]})})}function ie({stats:e,loading:t}){let n=(t,n)=>e?n(e[t]):`·`,r=(e,r,i,a=!1)=>(0,P.jsxs)(P.Fragment,{children:[(0,P.jsxs)(`span`,{className:`mx-r${a?` mx-hero-r`:``}`,children:[e,r?(0,P.jsxs)(`span`,{className:`mx-u`,children:[`· `,r]}):null]}),Y.map(e=>(0,P.jsx)(`span`,{className:`mx-v${a?` mx-hero`:``}`,children:(0,P.jsx)(`span`,{className:t?`skel`:void 0,children:t?`128.4`:n(e.k,i)})},e.k))]});return(0,P.jsxs)(`div`,{className:`vy-matrix`,children:[(0,P.jsx)(`span`,{className:`mx-corner`,"aria-hidden":`true`}),Y.map(e=>(0,P.jsx)(`span`,{className:`mx-h`,children:e.label},e.k)),r(`Distance`,`nm`,e=>o(e.distance_nm,1),!0),r(`Underway`,null,e=>Z(e.hours_underway)),r(`Avg SOG`,`kn`,e=>e.avg_sog_kn==null?`·`:e.avg_sog_kn.toFixed(1)),r(`Max SOG`,`kn`,e=>e.max_sog_kn==null?`·`:e.max_sog_kn.toFixed(1))]})}function ae({roll:e,loading:t}){let n=t?``:`·`;return(0,P.jsxs)(`div`,{className:`vy-cards`,children:[(0,P.jsxs)(`div`,{className:`c vy-hero`,children:[(0,P.jsxs)(`div`,{className:`t`,children:[`Distance · `,(0,P.jsx)(`span`,{className:`sub`,children:`nm`})]}),(0,P.jsx)(`div`,{className:`n${t?` skel`:``}`,children:t?`128.4`:e?o(e.distance_nm,1):n})]}),(0,P.jsxs)(`div`,{className:`c`,children:[(0,P.jsx)(`div`,{className:`t`,children:`Underway`}),(0,P.jsx)(`div`,{className:`v`,children:e?Z(e.hours_underway):n})]}),(0,P.jsxs)(`div`,{className:`c`,children:[(0,P.jsx)(`div`,{className:`t`,children:`Avg SOG`}),(0,P.jsx)(`div`,{className:`v`,children:e?.avg_sog_kn==null?n:(0,P.jsxs)(P.Fragment,{children:[e.avg_sog_kn.toFixed(1),(0,P.jsx)(`span`,{className:`u`,children:`kn`})]})})]}),(0,P.jsxs)(`div`,{className:`c`,children:[(0,P.jsx)(`div`,{className:`t`,children:`Max SOG`}),(0,P.jsx)(`div`,{className:`v`,children:e?.max_sog_kn==null?n:(0,P.jsxs)(P.Fragment,{children:[e.max_sog_kn.toFixed(1),(0,P.jsx)(`span`,{className:`u`,children:`kn`})]})})]})]})}function oe({v:e,prev:t,wasJoined:n,open:r,track:i,fuelNotice:a,fuelMode:s,onFuelMode:c,onToggle:l,onMerge:u,onUndoMerge:d,editErr:h}){let _=e.end_ts===null,v=k(e.fuel_used_l,e.distance_nm,e.hours_underway,s),y=_?`${$(e.start_ts)} →`:`${$(e.start_ts)}-${$(e.end_ts)}`,b=e.avg_sog_kn===null?`·`:`${e.avg_sog_kn.toFixed(1)} kn`,x=te(e);return(0,P.jsxs)(`div`,{className:`vy-rowwrap${r?` open`:``}`,children:[(0,P.jsxs)(`button`,{className:`vy-row`,onClick:l,"aria-expanded":r,children:[(0,P.jsxs)(`div`,{className:`vy-row-top`,children:[(0,P.jsx)(`span`,{className:`vy-date`,children:Q(e.start_ts)}),_&&(0,P.jsx)(`span`,{className:`vy-badge`,children:`Under way`}),(0,P.jsxs)(`span`,{className:`vy-dist`,children:[o(e.distance_nm,1),(0,P.jsx)(`span`,{className:`vy-unit`,children:`nm`})]})]}),x&&(0,P.jsx)(`div`,{className:`vy-route`,children:x}),(0,P.jsxs)(`div`,{className:`vy-row-sub`,children:[y,` · `,Z(e.hours_underway),` · `,b]})]}),r&&(0,P.jsxs)(`div`,{className:`vy-detail`,children:[i&&i.length>=2?(0,P.jsx)(L,{track:i}):(0,P.jsx)(`div`,{className:`vy-track-empty`,children:i?`Track too short to plot`:`Loading track…`}),(0,P.jsxs)(`div`,{className:`vy-meta`,children:[(0,P.jsxs)(`div`,{className:`vy-m`,children:[(0,P.jsx)(`span`,{className:`k`,children:`From`}),e.start_port&&(0,P.jsx)(`span`,{className:`val`,children:e.start_port}),(0,P.jsxs)(`span`,{className:e.start_port?`coord`:`val`,children:[f(e.start_lat,[`N`,`S`],2),` · `,f(e.start_lon,[`E`,`W`],2)]})]}),(0,P.jsxs)(`div`,{className:`vy-m`,children:[(0,P.jsx)(`span`,{className:`k`,children:`To`}),_?(0,P.jsx)(`span`,{className:`val`,children:`-`}):(0,P.jsxs)(P.Fragment,{children:[e.end_port&&(0,P.jsx)(`span`,{className:`val`,children:e.end_port}),(0,P.jsxs)(`span`,{className:e.end_port?`coord`:`val`,children:[f(e.end_lat,[`N`,`S`],2),` · `,f(e.end_lon,[`E`,`W`],2)]})]})]}),(0,P.jsxs)(`div`,{className:`vy-m`,children:[(0,P.jsx)(`span`,{className:`k`,children:`Avg SOG`}),(0,P.jsx)(`span`,{className:`val`,children:e.avg_sog_kn===null?`·`:`${e.avg_sog_kn.toFixed(1)} kn`})]}),(0,P.jsxs)(`div`,{className:`vy-m`,children:[(0,P.jsx)(`span`,{className:`k`,children:`Max SOG`}),(0,P.jsx)(`span`,{className:`val`,children:e.max_sog_kn===null?`·`:`${e.max_sog_kn.toFixed(1)} kn`})]}),e.fuel_used_l===null&&a&&(0,P.jsxs)(`div`,{className:`vy-m vy-m-fuel`,children:[(0,P.jsx)(`span`,{className:`k`,children:`Fuel`}),(0,P.jsx)(`span`,{className:`val vy-fuel-quiet`,children:a})]}),e.fuel_used_l!==null&&(0,P.jsxs)(`div`,{className:`vy-m vy-m-fuel`,children:[(0,P.jsx)(`span`,{className:`k`,children:`Fuel`}),(0,P.jsx)(`span`,{className:`val`,children:v??`·`}),(0,P.jsx)(`select`,{className:`vy-fuel-sel`,value:s,"aria-label":`Fuel unit`,onChange:e=>c(e.target.value),children:w.map(e=>(0,P.jsx)(`option`,{value:e.mode,children:e.label},e.mode))})]}),i&&i.length>0&&(0,P.jsxs)(`div`,{className:`vy-m vy-m-track`,children:[(0,P.jsx)(`span`,{className:`k`,children:`Track`}),(0,P.jsxs)(`button`,{type:`button`,className:`vy-fuelsrc`,onClick:()=>m(g(`siparu-voyage-${e.id}`,e.start_ts,`gpx`),`application/gpx+xml`,p(e,i)),children:[`GPX · `,i.length,` fixes`]})]}),!_&&u&&d&&(n||t)&&(0,P.jsxs)(`div`,{className:`vy-m vy-m-edit`,children:[(0,P.jsx)(`span`,{className:`k`,children:`Passage`}),n?(0,P.jsx)(`button`,{type:`button`,className:`vy-fuelsrc`,onClick:d,children:`Separate again`}):(0,P.jsxs)(`button`,{type:`button`,className:`vy-fuelsrc`,onClick:u,children:[`Join to `,$(t.start_ts),t.end_ts===null?``:`-${$(t.end_ts)}`,` · `,Q(t.start_ts)]})]}),h&&(0,P.jsx)(`div`,{className:`vy-m vy-m-editerr`,children:h})]})]})]})}function se(){return(0,P.jsx)(ne,{})}export{se as default};
|
|
@@ -6,4 +6,4 @@ var e={lat:`position`,lon:`position`,sog:`linear`,rate_of_turn:`linear`,magnetic
|
|
|
6
6
|
`)+`\r
|
|
7
7
|
`}function x(e){return e.replace(/&/g,`&`).replace(/</g,`<`).replace(/>/g,`>`).replace(/"/g,`"`)}function S(e){let t=new Date(e.start_ts).toISOString().slice(0,10);return!e.start_port&&!e.end_port?`Voyage ${e.id} ${t}`:`${t} ${e.start_port??`?`} to ${e.end_port??`?`}`}function C(e,t){let n=x(S(e)),r=t.map(e=>` <trkpt lat="${e.lat}" lon="${e.lon}"><time>${new Date(e.ts).toISOString()}</time></trkpt>`).join(`
|
|
8
8
|
`);return[`<?xml version="1.0" encoding="UTF-8"?>`,`<gpx version="1.1" creator="Siparu" xmlns="http://www.topografix.com/GPX/1/1">`,` <metadata>`,` <name>${n}</name>`,` <time>${new Date(e.start_ts).toISOString()}</time>`,` </metadata>`,` <trk>`,` <name>${n}</name>`,` <trkseg>`,r,` </trkseg>`,` </trk>`,`</gpx>`,``].join(`
|
|
9
|
-
`)}function w(e,t,n){let r=URL.createObjectURL(new Blob([n],{type:`${t};charset=utf-8`})),i=document.createElement(`a`);i.href=r,i.download=e,i.rel=`noopener`,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)}function T(e,t,n){let
|
|
9
|
+
`)}function w(e,t,n){let r=URL.createObjectURL(new Blob([n],{type:`${t};charset=utf-8`})),i=document.createElement(`a`);i.href=r,i.download=e,i.rel=`noopener`,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),0)}function T(e,t,n,r=``){let i=new Date(t),a=e=>String(e).padStart(2,`0`);return`${e}-${i.getUTCFullYear()}${a(i.getUTCMonth()+1)}${a(i.getUTCDate())}${r}.${n}`}export{C as a,f as c,y as i,p as l,w as n,v as o,T as r,l as s,b as t};
|