ocearo-ui
Version:
Ocean Robot UI: 3D visualization dashboard for signalk
9 lines • 9.83 kB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,88653,e=>{"use strict";e.i(47167);var t=e.i(43476),s=e.i(71645),a=e.i(31178),n=e.i(47414),l=e.i(74008),o=e.i(21476),r=e.i(72846),i=s,c=e.i(37806);function u(e,t){if("function"==typeof e)return e(t);null!=e&&(e.current=t)}class d extends i.Component{getSnapshotBeforeUpdate(e){let t=this.props.childRef.current;if(t&&e.isPresent&&!this.props.isPresent&&!1!==this.props.pop){let e=t.offsetParent,s=(0,r.isHTMLElement)(e)&&e.offsetWidth||0,a=(0,r.isHTMLElement)(e)&&e.offsetHeight||0,n=this.props.sizeRef.current;n.height=t.offsetHeight||0,n.width=t.offsetWidth||0,n.top=t.offsetTop,n.left=t.offsetLeft,n.right=s-n.width-n.left,n.bottom=a-n.height-n.top}return null}componentDidUpdate(){}render(){return this.props.children}}function f({children:e,isPresent:a,anchorX:n,anchorY:l,root:o,pop:r}){let f=(0,i.useId)(),m=(0,i.useRef)(null),h=(0,i.useRef)({width:0,height:0,top:0,left:0,right:0,bottom:0}),{nonce:p}=(0,i.useContext)(c.MotionConfigContext),g=function(...e){return s.useCallback(function(...e){return t=>{let s=!1,a=e.map(e=>{let a=u(e,t);return s||"function"!=typeof a||(s=!0),a});if(s)return()=>{for(let t=0;t<a.length;t++){let s=a[t];"function"==typeof s?s():u(e[t],null)}}}}(...e),e)}(m,e.props?.ref??e?.ref);return(0,i.useInsertionEffect)(()=>{let{width:e,height:t,top:s,left:i,right:c,bottom:u}=h.current;if(a||!1===r||!m.current||!e||!t)return;let d="left"===n?`left: ${i}`:`right: ${c}`,g="bottom"===l?`bottom: ${u}`:`top: ${s}`;m.current.dataset.motionPopId=f;let b=document.createElement("style");p&&(b.nonce=p);let x=o??document.head;return x.appendChild(b),b.sheet&&b.sheet.insertRule(`
[data-motion-pop-id="${f}"] {
position: absolute !important;
width: ${e}px !important;
height: ${t}px !important;
${d}px !important;
${g}px !important;
}
`),()=>{x.contains(b)&&x.removeChild(b)}},[a]),(0,t.jsx)(d,{isPresent:a,childRef:m,sizeRef:h,pop:r,children:!1===r?e:i.cloneElement(e,{ref:g})})}let m=({children:e,initial:a,isPresent:l,onExitComplete:r,custom:i,presenceAffectsLayout:c,mode:u,anchorX:d,anchorY:m,root:p})=>{let g=(0,n.useConstant)(h),b=(0,s.useId)(),x=!0,j=(0,s.useMemo)(()=>(x=!1,{id:b,initial:a,isPresent:l,custom:i,onExitComplete:e=>{for(let t of(g.set(e,!0),g.values()))if(!t)return;r&&r()},register:e=>(g.set(e,!1),()=>g.delete(e))}),[l,g,r]);return c&&x&&(j={...j}),(0,s.useMemo)(()=>{g.forEach((e,t)=>g.set(t,!1))},[l]),s.useEffect(()=>{l||g.size||!r||r()},[l]),e=(0,t.jsx)(f,{pop:"popLayout"===u,isPresent:l,anchorX:d,anchorY:m,root:p,children:e}),(0,t.jsx)(o.PresenceContext.Provider,{value:j,children:e})};function h(){return new Map}var p=e.i(64978);let g=e=>e.key||"";function b(e){let t=[];return s.Children.forEach(e,e=>{(0,s.isValidElement)(e)&&t.push(e)}),t}let x=({children:e,custom:o,initial:r=!0,onExitComplete:i,presenceAffectsLayout:c=!0,mode:u="sync",propagate:d=!1,anchorX:f="left",anchorY:h="top",root:x})=>{let[j,k]=(0,p.usePresence)(d),y=(0,s.useMemo)(()=>b(e),[e]),v=d&&!j?[]:y.map(g),P=(0,s.useRef)(!0),w=(0,s.useRef)(y),C=(0,n.useConstant)(()=>new Map),E=(0,s.useRef)(new Set),[A,R]=(0,s.useState)(y),[$,M]=(0,s.useState)(y);(0,l.useIsomorphicLayoutEffect)(()=>{P.current=!1,w.current=y;for(let e=0;e<$.length;e++){let t=g($[e]);v.includes(t)?(C.delete(t),E.current.delete(t)):!0!==C.get(t)&&C.set(t,!1)}},[$,v.length,v.join("-")]);let K=[];if(y!==A){let e=[...y];for(let t=0;t<$.length;t++){let s=$[t],a=g(s);v.includes(a)||(e.splice(t,0,s),K.push(s))}return"wait"===u&&K.length&&(e=K),M(b(e)),R(y),null}let{forceRender:T}=(0,s.useContext)(a.LayoutGroupContext);return(0,t.jsx)(t.Fragment,{children:$.map(e=>{let s=g(e),a=(!d||!!j)&&(y===$||v.includes(s));return(0,t.jsx)(m,{isPresent:a,initial:(!P.current||!!r)&&void 0,custom:o,presenceAffectsLayout:c,mode:u,root:x,onExitComplete:a?void 0:()=>{if(E.current.has(s)||(E.current.add(s),!C.has(s)))return;C.set(s,!0);let e=!0;C.forEach(t=>{t||(e=!1)}),e&&(T?.(),M(w.current),d&&k?.(),i&&i())},anchorX:f,anchorY:h,children:e},s)})})};e.s(["AnimatePresence",()=>x],88653)},68192,e=>{"use strict";var t=e.i(43476),s=e.i(71645),a=e.i(70703),n=e.i(46932),l=e.i(88653),o=e.i(67561);e.i(85269);var r=e.i(22831),i=e.i(85709),c=e.i(83402);let u=({messageKey:e})=>{let{t:s}=(0,r.useTranslation)();return(0,t.jsx)("div",{className:"w-full h-full flex items-center justify-center text-hud-main",children:s(e)})},d=(0,a.default)(()=>e.A(56489),{loadableGenerated:{modules:[92094]},loading:()=>(0,t.jsx)(u,{messageKey:"common.loadingDocuments"})}),f=(0,a.default)(()=>e.A(22155),{loadableGenerated:{modules:[34900]},loading:()=>(0,t.jsx)(u,{messageKey:"common.loadingSettings"})}),m=(0,a.default)(()=>e.A(30455),{loadableGenerated:{modules:[13268]},loading:()=>(0,t.jsx)(u,{messageKey:"common.loadingMediaPlayer"})}),h=(0,a.default)(()=>e.A(71074),{loadableGenerated:{modules:[65862]},loading:()=>(0,t.jsx)(u,{messageKey:"common.loadingBatteryMonitor"})}),p=(0,a.default)(()=>e.A(3523),{loadableGenerated:{modules:[8161]},loading:()=>(0,t.jsx)(u,{messageKey:"common.loadingEngineMonitor"})}),g=(0,a.default)(()=>e.A(88913),{loadableGenerated:{modules:[25294]},loading:()=>(0,t.jsx)(u,{messageKey:"common.loadingDashboard"})}),b=(0,a.default)(()=>e.A(26371),{loadableGenerated:{modules:[70127]},loading:()=>(0,t.jsx)(u,{messageKey:"common.loadingLogbook"})}),x=(0,a.default)(()=>e.A(58293),{loadableGenerated:{modules:[33946]},loading:()=>(0,t.jsx)(u,{messageKey:"common.loadingAutopilot"})}),j=(0,a.default)(()=>e.A(47853),{loadableGenerated:{modules:[58652]},loading:()=>(0,t.jsx)(u,{messageKey:"common.loading"})}),k={latitude:46.1591,longitude:-1.1522},y={navigation:e=>`${e}/@signalk/freeboard-sk/`,instrument:e=>`${e}/@mxtommy/kip/`,dashboard:e=>e.replace(":3000",":3001")+"/grafana",webcam1:()=>"https://pv.viewsurf.com/2080/Chatelaillon-Port?i=NzU4Mjp1bmRlZmluZWQ",webcam2:()=>"https://pv.viewsurf.com/1478/Chatelaillon-Plage<?i=NTkyMDp1bmRlZmluZWQ",weather:(e,t)=>t&&`https://embed.windy.com/embed.html?type=map&location=coordinates&metricRain=mm&metricTemp=\xb0C&metricWind=kt&zoom=10&overlay=wind&product=ecmwf&level=surface&lat=${t.latitude}&lon=${t.longitude}&message=true`};e.s(["default",0,({view:e})=>{let{t:a}=(0,r.useTranslation)(),{nightMode:u}=(0,o.useOcearoContext)(),[v,P]=(0,s.useState)(k),[w,C]=(0,s.useState)(null),{signalkUrl:E}=c.default.getAll(),A=(0,i.useSignalKPath)("navigation.position");(0,s.useEffect)(()=>{A&&P(e=>e?Math.abs(e.latitude-A.latitude)>.01||Math.abs(e.longitude-A.longitude)>.01?A:e:A)},[A]);let R=(0,s.useMemo)(()=>{let t=c.default.getAll(),s=t.customExternalUrls||{};if(t.showCustomUrls&&s[e])try{if("string"==typeof s[e]&&s[e].includes("${signalkUrl}"))return s[e].replace("${signalkUrl}",E).replace("${latitude}",v?.latitude||k.latitude).replace("${longitude}",v?.longitude||k.longitude);return s[e]}catch(e){console.error("Error using custom URL:",e)}let n=y[e];if(!n)return null;try{return n(E,v)}catch(e){return console.error("Error generating URL:",e),C(a("errors.errorGeneratingUrl")),null}},[e,v,E]),$=["motor","logbook","autopilot","battery","dashboard","debug"].includes(e);return(0,t.jsx)("div",{className:"flex flex-col w-full h-full overflow-hidden bg-hud-bg backdrop-blur-sm relative z-0",children:(0,t.jsx)(l.AnimatePresence,{mode:"wait",children:(0,t.jsx)(n.motion.div,{initial:{opacity:0,x:10,scale:.99},animate:{opacity:1,x:0,scale:1},exit:{opacity:0,x:-10,scale:.99},transition:{duration:.4,ease:[.16,1,.3,1]},style:{flex:"1 1 0%",minHeight:0},className:`flex flex-col w-full absolute inset-0 ${$?"overflow-hidden":"overflow-auto"}`,children:(()=>{if(w)return(0,t.jsx)("div",{className:"text-oRed p-4 font-black uppercase text-xs",children:w});switch(e){case"manual":return(0,t.jsx)(d,{path:"/docs"});case"settings":return(0,t.jsx)(f,{});case"mediaplayer":return(0,t.jsx)(m,{});case"battery":return(0,t.jsx)(h,{});case"motor":return(0,t.jsx)(p,{});case"dashboard":return(0,t.jsx)(g,{});case"logbook":return(0,t.jsx)(b,{});case"autopilot":return(0,t.jsx)(x,{});case"debug":return(0,t.jsx)(j,{});default:return R&&(0,t.jsx)("iframe",{className:"flex-grow border-none",src:R,title:"External Application",onError:()=>C(a("errors.failedToLoadExternal"))})}})()},e)})})}])},42602,e=>{e.n(e.i(68192))},56489,e=>{e.v(t=>Promise.all(["static/chunks/4701c1fd00af0aba.js","static/chunks/33a3c72f455c2711.js"].map(t=>e.l(t))).then(()=>t(92094)))},22155,e=>{e.v(t=>Promise.all(["static/chunks/ca5d1b461892da4b.js"].map(t=>e.l(t))).then(()=>t(34900)))},30455,e=>{e.v(t=>Promise.all(["static/chunks/a5243176ef1c1147.js","static/chunks/33a3c72f455c2711.js"].map(t=>e.l(t))).then(()=>t(13268)))},71074,e=>{e.v(t=>Promise.all(["static/chunks/fba1dfce801bc8b9.js","static/chunks/ba6e6b346e330c1c.js","static/chunks/19d7af5c164315cb.js","static/chunks/33a3c72f455c2711.js"].map(t=>e.l(t))).then(()=>t(65862)))},3523,e=>{e.v(t=>Promise.all(["static/chunks/05498d2aba8ad072.js","static/chunks/33a3c72f455c2711.js"].map(t=>e.l(t))).then(()=>t(8161)))},88913,e=>{e.v(t=>Promise.all(["static/chunks/056bb58d7d0223f4.js","static/chunks/7d74814a0cc0f1a8.js","static/chunks/3b9428693f2cc0d6.js","static/chunks/4a440e0aa6a0e7f7.js","static/chunks/fe9ff98ffedd5a18.js","static/chunks/eae6a84b628658b8.js","static/chunks/33a3c72f455c2711.js","static/chunks/607b77f84fd065f0.js"].map(t=>e.l(t))).then(()=>t(25294)))},26371,e=>{e.v(t=>Promise.all(["static/chunks/b08b2ebeb951051c.js","static/chunks/33a3c72f455c2711.js"].map(t=>e.l(t))).then(()=>t(70127)))},58293,e=>{e.v(t=>Promise.all(["static/chunks/c5ca29b672fb8724.js","static/chunks/33a3c72f455c2711.js"].map(t=>e.l(t))).then(()=>t(33946)))},47853,e=>{e.v(t=>Promise.all(["static/chunks/c2ca71308a46ad5c.js"].map(t=>e.l(t))).then(()=>t(58652)))}]);