ocearo-ui
Version:
Ocean Robot UI: 3D visualization dashboard for signalk
1 lines • 18.5 kB
JavaScript
(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,55838,(e,t,n)=>{"use strict";var i=e.r(71645),o="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},r=i.useState,a=i.useEffect,l=i.useLayoutEffect,s=i.useDebugValue;function u(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!o(e,n)}catch(e){return!0}}var c="u"<typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var n=t(),i=r({inst:{value:n,getSnapshot:t}}),o=i[0].inst,c=i[1];return l(function(){o.value=n,o.getSnapshot=t,u(o)&&c({inst:o})},[e,n,t]),a(function(){return u(o)&&c({inst:o}),e(function(){u(o)&&c({inst:o})})},[e]),s(n),n};n.useSyncExternalStore=void 0!==i.useSyncExternalStore?i.useSyncExternalStore:c},2239,(e,t,n)=>{"use strict";t.exports=e.r(55838)},13004,e=>{e.v({boats:[{name:"Default",modelPath:"default",capabilities:["navigation","rudder","sail","color"]},{name:"Optimist",modelPath:"optimist",capabilities:["navigation","ais"]},{name:"Sailboat",modelPath:"sailboat",capabilities:["navigation","ais"]},{name:"Ship",modelPath:"ship",capabilities:["navigation","ais"]},{name:"Windsurf",modelPath:"windsurf",capabilities:["navigation","ais"]}]})},83402,e=>{"use strict";var t=e.i(13004);let n=new class{constructor(){this.defaultConfig={signalkUrl:"http://localhost:3000",username:"",password:"",useAuthentication:!1,signalKUrlSet:!1,debugMode:!1,selectedBoat:"Default",primaryColor:null,metallicEffect:!1,aisLengthScalingFactor:.7,compassNorthUp:!1,hide3DCompass:!1,hideTrueWind:!1,showCustomUrls:!1,customExternalUrls:{},currentView:"default",theme:"dark",language:"en",distanceUnits:"nm",depthUnits:"m",speedUnits:"kn",temperatureUnits:"C",positionFormat:"DD",preferTrueValues:!0,preferredWindSpeedPath:"speedTrue",preferredWindDirectionPath:"directionTrue",preferredHeadingPath:"courseOverGroundTrue",debugWindOverride:!1,debugWindSpeed:10,debugWindDirection:0,debugShowAxes:!1,showSailTrimSliders:!0,showRigging:!0},this.configKey="ocearoConfig",this.inMemoryConfig={...this.defaultConfig},this.config=this.loadConfig()}isLocalStorageAvailable(){try{return"u">typeof localStorage}catch{return!1}}loadConfig(){if(this.isLocalStorageAvailable()){let e=localStorage.getItem(this.configKey);if(!e)return this.saveConfig(this.defaultConfig),{...this.defaultConfig};try{return JSON.parse(e)}catch(e){return console.error("Failed to parse stored configuration:",e),{...this.defaultConfig}}}return{...this.inMemoryConfig}}saveConfig(e){this.config={...this.config,...e},this.isLocalStorageAvailable()?localStorage.setItem(this.configKey,JSON.stringify(this.config)):this.inMemoryConfig={...this.config}}get(e){return this.config[e]}set(e,t){this.config[e]=t,this.saveConfig(this.config)}resetConfig(){this.config={...this.defaultConfig},this.isLocalStorageAvailable()?localStorage.setItem(this.configKey,JSON.stringify(this.config)):this.inMemoryConfig={...this.defaultConfig}}getAll(){return{...this.config}}getDefaultConfig(){return{...this.defaultConfig}}getSelectedBoat(){let e=this.config.selectedBoat;return e?this.getBoatsData().find(t=>t.name===e):[]}getBoatsData(){return t.default.boats}getComputedSignalKUrl(){return this.config.debugMode?"https://demo.signalk.org:443":`${window.location.protocol}//${window.location.hostname}${window.location.port?":"+window.location.port:""}`}getCurrentView(){return this.config.currentView||this.defaultConfig.currentView}setCurrentView(e){this.set("currentView",e)}};e.s(["default",0,n])},67585,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"BailoutToCSR",{enumerable:!0,get:function(){return o}});let i=e.r(32061);function o({reason:e,children:t}){if("u"<typeof window)throw Object.defineProperty(new i.BailoutToCSRError(e),"__NEXT_ERROR_CODE",{value:"E394",enumerable:!1,configurable:!0});return t}},9885,(e,t,n)=>{"use strict";function i(e){return e.split("/").map(e=>encodeURIComponent(e)).join("/")}Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"encodeURIPath",{enumerable:!0,get:function(){return i}})},52157,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"PreloadChunks",{enumerable:!0,get:function(){return s}});let i=e.r(43476),o=e.r(74080),r=e.r(63599),a=e.r(9885),l=e.r(43369);function s({moduleIds:e}){if("u">typeof window)return null;let t=r.workAsyncStorage.getStore();if(void 0===t)return null;let n=[];if(t.reactLoadableManifest&&e){let i=t.reactLoadableManifest;for(let t of e){if(!i[t])continue;let e=i[t].files;n.push(...e)}}if(0===n.length)return null;let s=(0,l.getDeploymentIdQueryOrEmptyString)();return(0,i.jsx)(i.Fragment,{children:n.map(e=>{let n=`${t.assetPrefix}/_next/${(0,a.encodeURIPath)(e)}${s}`;return e.endsWith(".css")?(0,i.jsx)("link",{precedence:"dynamic",href:n,rel:"stylesheet",as:"style",nonce:t.nonce},e):((0,o.preload)(n,{as:"script",fetchPriority:"low",nonce:t.nonce}),null)})})}},69093,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return u}});let i=e.r(43476),o=e.r(71645),r=e.r(67585),a=e.r(52157);function l(e){return{default:e&&"default"in e?e.default:e}}let s={loader:()=>Promise.resolve(l(()=>null)),loading:null,ssr:!0},u=function(e){let t={...s,...e},n=(0,o.lazy)(()=>t.loader().then(l)),u=t.loading;function c(e){let l=u?(0,i.jsx)(u,{isLoading:!0,pastDelay:!0,error:null}):null,s=!t.ssr||!!t.loading,c=s?o.Suspense:o.Fragment,d=t.ssr?(0,i.jsxs)(i.Fragment,{children:["u"<typeof window?(0,i.jsx)(a.PreloadChunks,{moduleIds:t.modules}):null,(0,i.jsx)(n,{...e})]}):(0,i.jsx)(r.BailoutToCSR,{reason:"next/dynamic",children:(0,i.jsx)(n,{...e})});return(0,i.jsx)(c,{...s?{fallback:l}:{},children:d})}return c.displayName="LoadableComponent",c}},70703,(e,t,n)=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0}),Object.defineProperty(n,"default",{enumerable:!0,get:function(){return o}});let i=e.r(55682)._(e.r(69093));function o(e,t){let n={};"function"==typeof e&&(n.loader=e);let o={...n,...t};return(0,i.default)({...o,modules:o.loadableGenerated?.modules})}("function"==typeof n.default||"object"==typeof n.default&&null!==n.default)&&void 0===n.default.__esModule&&(Object.defineProperty(n.default,"__esModule",{value:!0}),Object.assign(n.default,n),t.exports=n.default)},83934,e=>{"use strict";var t=e.i(43476),n=e.i(71645),i=e.i(66799);e.i(67561);var o=e.i(85709);let r=(0,n.createContext)();e.s(["WeatherContextProvider",0,({children:e})=>{let a=(0,o.useSignalKPath)("navigation.position"),l=(0,n.useMemo)(()=>["environment.outside.temperature","environment.outside.relativeHumidity","environment.outside.pressure","environment.wind.speedTrue","environment.wind.directionTrue","environment.wind.gust"],[]),s=(0,o.useSignalKPaths)(l),[u,c]=(0,n.useState)([]),[d,f]=(0,n.useState)(!1),[g,h]=(0,n.useState)(null),[p,m]=(0,n.useState)(null),[w,v]=(0,n.useState)(null),b=(0,n.useRef)(null),y=(0,n.useRef)(null),S=(0,n.useRef)(a);S.current=a;let x=(0,n.useCallback)(async()=>{let e=S.current;if(e?.latitude&&e?.longitude){f(!0),h(null);try{let t=i.default.isWeatherApiAvailable();if(null===t&&(t=await i.default.checkWeatherApiAvailability()),m(t),!t)return void h("Weather API not available on SignalK server");let n=await i.default.getWeatherForecast(e.latitude,e.longitude),o=i.default.parseWeatherForecast(n);c(o),v(new Date)}catch(e){e.message&&e.message.includes("400")?(console.warn("WeatherContext: Weather forecast not supported by this server"),m(!1)):console.warn("WeatherContext: Failed to fetch forecast:",e.message),h(e.message)}finally{f(!1)}}},[]),C=(0,n.useCallback)(e=>{if(!u||0===u.length)return null;let t=Math.min(Math.floor(e),u.length-1);return u[t]||null},[u]),k=(0,n.useCallback)(()=>{let e=u.length>0?u[0]:null,t=s["environment.outside.temperature"]??(e?.temperature!=null?e.temperature+273.15:null),n=s["environment.outside.relativeHumidity"]??e?.humidity??null,i=s["environment.outside.pressure"]??e?.pressure??null,o=s["environment.wind.speedTrue"]??(e?.wind?.speed!=null?e.wind.speed/1.94384:null),r=s["environment.wind.directionTrue"]??(e?.wind?.direction!=null?e.wind.direction*Math.PI/180:null),a=Object.values(s).some(e=>null!==e);return{source:null!==t||null!==n||null!==i||null!==o?a?"sensors":"forecast":null,temperature:t,humidity:n,pressure:i,windSpeed:o,windDirection:r,description:e?.description||null}},[s,u]),P=(0,n.useCallback)(()=>{let e=u.length>0?u[0]:null,t=s["environment.wind.speedTrue"]??(e?.wind?.speed!=null?e.wind.speed/1.94384:null),n=s["environment.wind.directionTrue"]??(e?.wind?.direction!=null?e.wind.direction*Math.PI/180:null),i=s["environment.wind.gust"]??(e?.wind?.gust!=null?e.wind.gust/1.94384:null),o=null!==s["environment.wind.speedTrue"]||null!==s["environment.wind.directionTrue"];return{source:null!==t||null!==n?o?"sensors":"forecast":null,speed:t,direction:n,gust:i}},[s,u]);(0,n.useEffect)(()=>(b.current=setTimeout(()=>{x()},5e3),y.current=setInterval(()=>{x()},18e5),()=>{b.current&&clearTimeout(b.current),y.current&&clearInterval(y.current)}),[x]);let j=(0,n.useMemo)(()=>({forecasts:u,isLoading:d,error:g,weatherApiAvailable:p,lastFetchTime:w,fetchWeatherForecast:x,getForecastForTime:C,getCurrentWeather:k,getWindData:P}),[u,d,g,p,w,x,C,k,P]);return(0,t.jsx)(r.Provider,{value:j,children:e})},"useWeather",0,()=>{let e=(0,n.useContext)(r);if(!e)throw Error("useWeather must be used within a WeatherContextProvider");return e}])},18850,e=>{"use strict";var t=e.i(45141);e.i(85269);var n=e.i(2607);let{slice:i,forEach:o}=[],r=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,a=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{path:"/"},i=encodeURIComponent(t),o=`${e}=${i}`;if(n.maxAge>0){let e=n.maxAge-0;if(Number.isNaN(e))throw Error("maxAge should be a Number");o+=`; Max-Age=${Math.floor(e)}`}if(n.domain){if(!r.test(n.domain))throw TypeError("option domain is invalid");o+=`; Domain=${n.domain}`}if(n.path){if(!r.test(n.path))throw TypeError("option path is invalid");o+=`; Path=${n.path}`}if(n.expires){if("function"!=typeof n.expires.toUTCString)throw TypeError("option expires is invalid");o+=`; Expires=${n.expires.toUTCString()}`}if(n.httpOnly&&(o+="; HttpOnly"),n.secure&&(o+="; Secure"),n.sameSite)switch("string"==typeof n.sameSite?n.sameSite.toLowerCase():n.sameSite){case!0:case"strict":o+="; SameSite=Strict";break;case"lax":o+="; SameSite=Lax";break;case"none":o+="; SameSite=None";break;default:throw TypeError("option sameSite is invalid")}return n.partitioned&&(o+="; Partitioned"),o},l={create(e,t,n,i){let o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{path:"/",sameSite:"strict"};n&&(o.expires=new Date,o.expires.setTime(o.expires.getTime()+60*n*1e3)),i&&(o.domain=i),document.cookie=a(e,t,o)},read(e){let t=`${e}=`,n=document.cookie.split(";");for(let e=0;e<n.length;e++){let i=n[e];for(;" "===i.charAt(0);)i=i.substring(1,i.length);if(0===i.indexOf(t))return i.substring(t.length,i.length)}return null},remove(e,t){this.create(e,"",-1,t)}};var s={name:"cookie",lookup(e){let{lookupCookie:t}=e;if(t&&"u">typeof document)return l.read(t)||void 0},cacheUserLanguage(e,t){let{lookupCookie:n,cookieMinutes:i,cookieDomain:o,cookieOptions:r}=t;n&&"u">typeof document&&l.create(n,e,i,o,r)}},u={name:"querystring",lookup(e){let t,{lookupQuerystring:n}=e;if("u">typeof window){let{search:e}=window.location;!window.location.search&&window.location.hash?.indexOf("?")>-1&&(e=window.location.hash.substring(window.location.hash.indexOf("?")));let i=e.substring(1).split("&");for(let e=0;e<i.length;e++){let o=i[e].indexOf("=");o>0&&i[e].substring(0,o)===n&&(t=i[e].substring(o+1))}}return t}},c={name:"hash",lookup(e){let t,{lookupHash:n,lookupFromHashIndex:i}=e;if("u">typeof window){let{hash:e}=window.location;if(e&&e.length>2){let o=e.substring(1);if(n){let e=o.split("&");for(let i=0;i<e.length;i++){let o=e[i].indexOf("=");o>0&&e[i].substring(0,o)===n&&(t=e[i].substring(o+1))}}if(t)return t;if(!t&&i>-1){let t=e.match(/\/([a-zA-Z-]*)/g);if(!Array.isArray(t))return;return t["number"==typeof i?i:0]?.replace("/","")}}}return t}};let d=null,f=()=>{if(null!==d)return d;try{if(!(d="u">typeof window&&null!==window.localStorage))return!1;let e="i18next.translate.boo";window.localStorage.setItem(e,"foo"),window.localStorage.removeItem(e)}catch(e){d=!1}return d};var g={name:"localStorage",lookup(e){let{lookupLocalStorage:t}=e;if(t&&f())return window.localStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupLocalStorage:n}=t;n&&f()&&window.localStorage.setItem(n,e)}};let h=null,p=()=>{if(null!==h)return h;try{if(!(h="u">typeof window&&null!==window.sessionStorage))return!1;let e="i18next.translate.boo";window.sessionStorage.setItem(e,"foo"),window.sessionStorage.removeItem(e)}catch(e){h=!1}return h};var m={name:"sessionStorage",lookup(e){let{lookupSessionStorage:t}=e;if(t&&p())return window.sessionStorage.getItem(t)||void 0},cacheUserLanguage(e,t){let{lookupSessionStorage:n}=t;n&&p()&&window.sessionStorage.setItem(n,e)}},w={name:"navigator",lookup(e){let t=[];if("u">typeof navigator){let{languages:e,userLanguage:n,language:i}=navigator;if(e)for(let n=0;n<e.length;n++)t.push(e[n]);n&&t.push(n),i&&t.push(i)}return t.length>0?t:void 0}},v={name:"htmlTag",lookup(e){let t,{htmlTag:n}=e,i=n||("u">typeof document?document.documentElement:null);return i&&"function"==typeof i.getAttribute&&(t=i.getAttribute("lang")),t}},b={name:"path",lookup(e){let{lookupFromPathIndex:t}=e;if("u"<typeof window)return;let n=window.location.pathname.match(/\/([a-zA-Z-]*)/g);if(Array.isArray(n))return n["number"==typeof t?t:0]?.replace("/","")}},y={name:"subdomain",lookup(e){let{lookupFromSubdomainIndex:t}=e,n="u">typeof window&&window.location?.hostname?.match(/^(\w{2,5})\.(([a-z0-9-]{1,63}\.[a-z]{2,6})|localhost)/i);if(n)return n["number"==typeof t?t+1:1]}};let S=!1;try{document.cookie,S=!0}catch(e){}let x=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];S||x.splice(1,1);class C{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.type="languageDetector",this.detectors={},this.init(e,t)}init(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{languageUtils:{}},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};this.services=e,this.options=function(e){return o.call(i.call(arguments,1),t=>{if(t)for(let n in t)void 0===e[n]&&(e[n]=t[n])}),e}(t,this.options||{},{order:x,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:e=>e}),"string"==typeof this.options.convertDetectedLanguage&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=e=>e.replace("-","_")),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=n,this.addDetector(s),this.addDetector(u),this.addDetector(g),this.addDetector(m),this.addDetector(w),this.addDetector(v),this.addDetector(b),this.addDetector(y),this.addDetector(c)}addDetector(e){return this.detectors[e.name]=e,this}detect(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this.options.order,t=[];return(e.forEach(e=>{if(this.detectors[e]){let n=this.detectors[e].lookup(this.options);n&&"string"==typeof n&&(n=[n]),n&&(t=t.concat(n))}}),t=t.filter(e=>null!=e&&!("string"==typeof e&&[/<\s*script.*?>/i,/<\s*\/\s*script\s*>/i,/<\s*img.*?on\w+\s*=/i,/<\s*\w+\s*on\w+\s*=.*?>/i,/javascript\s*:/i,/vbscript\s*:/i,/expression\s*\(/i,/eval\s*\(/i,/alert\s*\(/i,/document\.cookie/i,/document\.write\s*\(/i,/window\.location/i,/innerHTML/i].some(t=>t.test(e)))).map(e=>this.options.convertDetectedLanguage(e)),this.services&&this.services.languageUtils&&this.services.languageUtils.getBestMatchFromCodes)?t:t.length>0?t[0]:null}cacheUserLanguage(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.options.caches;!t||this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(e)>-1||t.forEach(t=>{this.detectors[t]&&this.detectors[t].cacheUserLanguage(e,this.options)})}}C.type="languageDetector";var k=e.i(30602),P=e.i(54520),j=e.i(93720),O=e.i(87570),D=e.i(26582),T=e.i(59839),A=e.i(93517),U=e.i(99681),E=e.i(45718),L=e.i(89246),I=e.i(18473),M=e.i(40336);let _={en:{translation:k.default},fr:{translation:P.default},de:{translation:j.default},es:{translation:O.default},it:{translation:D.default},pt:{translation:T.default},nl:{translation:A.default},pl:{translation:U.default},sv:{translation:E.default},da:{translation:L.default},fi:{translation:I.default},el:{translation:M.default}};t.default.use(C).use(n.initReactI18next).init({resources:_,lng:(()=>{try{if("u">typeof localStorage){let e=localStorage.getItem("ocearoConfig");if(e)return JSON.parse(e).language||null}}catch(e){}return null})()||void 0,fallbackLng:"en",interpolation:{escapeValue:!1},detection:{order:["localStorage","navigator"],lookupLocalStorage:"ocearo-language",caches:["localStorage"]}});let W=t.default;e.s(["SUPPORTED_LANGUAGES",0,[{code:"en",label:"English",flag:"🇬🇧"},{code:"fr",label:"Français",flag:"🇫🇷"},{code:"de",label:"Deutsch",flag:"🇩🇪"},{code:"es",label:"Español",flag:"🇪🇸"},{code:"it",label:"Italiano",flag:"🇮🇹"},{code:"pt",label:"Português",flag:"🇵🇹"},{code:"nl",label:"Nederlands",flag:"🇳🇱"},{code:"pl",label:"Polski",flag:"🇵🇱"},{code:"sv",label:"Svenska",flag:"🇸🇪"},{code:"da",label:"Dansk",flag:"🇩🇰"},{code:"fi",label:"Suomi",flag:"🇫🇮"},{code:"el",label:"Ελληνικά",flag:"🇬🇷"}],"default",0,W],18850)},45344,e=>{e.v(t=>Promise.all(["static/chunks/dc7a868e9a2740f1.js","static/chunks/46da3d80b0234973.js"].map(t=>e.l(t))).then(()=>t(42602)))},10520,e=>{e.v(t=>Promise.all(["static/chunks/06e0cd4a5af05adb.js","static/chunks/33a3c72f455c2711.js"].map(t=>e.l(t))).then(()=>t(61891)))},49063,e=>{e.v(t=>Promise.all(["static/chunks/290728133a3e7513.js","static/chunks/33a3c72f455c2711.js","static/chunks/46da3d80b0234973.js"].map(t=>e.l(t))).then(()=>t(85626)))},13181,e=>{e.v(t=>Promise.all(["static/chunks/4974092397cafa41.js","static/chunks/eae6a84b628658b8.js","static/chunks/33a3c72f455c2711.js"].map(t=>e.l(t))).then(()=>t(23595)))}]);