(this.webpackJsonpclient=this.webpackJsonpclient||[]).push([[0],{119:function(t,e,n){},148:function(t,e,n){},166:function(t,e,n){},305:function(t,e,n){},306:function(t,e,n){},307:function(t,e,n){},309:function(t,e,n){},310:function(t,e,n){},311:function(t,e,n){"use strict";n.r(e);var a=n(0),i=n.n(a),r=n(26),c=n.n(r),o=n(33),s=n(15),u=(n(148),n(2)),l=function(){return Object(u.jsx)("div",{className:"nav-wrapper",children:Object(u.jsxs)("div",{className:"nav-container",children:[Object(u.jsxs)("div",{className:"nav-block",children:[Object(u.jsx)(o.b,{className:"nav-tab",activeClassName:"nav-tab-active",to:"/rides",children:"RIDES"}),Object(u.jsx)(o.b,{className:"nav-tab",activeClassName:"nav-tab-active",to:"/ml",children:"Machine"})]}),Object(u.jsx)("div",{className:"nav-block",children:Object(u.jsx)(o.b,{className:"nav-tab right-tab",activeClassName:"nav-tab-active",to:"/login",children:"LOGIN"})})]})})},d=n(16),h=n(6),j=n(142),m=function(t){var e=t.forceState,n=t.className,i=t.html,r=t.onClick,c=Object(a.useState)(e||!1),o=Object(h.a)(c,2),s=o[0],l=o[1];return Object(u.jsx)("div",{className:"".concat(n," btn ").concat((void 0===e?s:e)?"btn-checked":""),onClick:function(){var t=void 0===e?!s:!e;r(t),l(t)},children:i})},f=(n(166),function(t){return Array.from({length:t},(function(t,e){return e}))}),p=function(t){return new Array(t).fill(!1)},b=function(t){var e=t.metas,n=t.showMetas,i=t.onClick,r=Object(a.useState)(p(n.length)),c=Object(h.a)(r,2),o=c[0],s=c[1];Object(a.useEffect)((function(){0===o.length&&s(p(n.length))}),[o.length]);return Object(u.jsx)(j.a,{width:170,height:2500,rowHeight:61,rowRenderer:function(t){var a=t.index,r=t.key,c=t.style,l=n[a],h=e[l];return Object(u.jsx)("div",{style:c,children:Object(u.jsx)(m,{forceState:o[l],className:"ride-card-container",html:Object(u.jsxs)("div",{children:[Object(u.jsx)("b",{children:h.TaskId}),Object(u.jsx)("br",{}),new Date(h.Created_Date).toLocaleDateString()]}),onClick:function(t){var e=Object(d.a)(o);e[l]=t,s(e),i(l,t)}})},r)},rowCount:n.length})},O=function(t){var e=t.min,n=t.max,i=t.current,r=Object(a.useState)(i),c=Object(h.a)(r,2),o=c[0],s=c[1];return[o,Object(u.jsx)("input",{type:"number",min:e,max:n,value:o,onChange:function(t){return s(t.target.value)},className:"ride-search-input ride-search-date-input"})]},g=function(t){var e=t.metas,n=t.onClick,i=Object(a.useState)(!1),r=Object(h.a)(i,2),c=r[0],o=r[1],s=Object(a.useState)(!0),l=Object(h.a)(s,2),j=l[0],p=l[1],g=O({min:1,max:12,current:1}),v=Object(h.a)(g,2),x=v[0],_=v[1],w=O({min:2019,max:2050,current:2019}),y=Object(h.a)(w,2),k=y[0],C=y[1],N=O({min:1,max:12,current:12}),S=Object(h.a)(N,2),M=S[0],T=S[1],E=O({min:2019,max:2050,current:2021}),F=Object(h.a)(E,2),L=F[0],D=F[1],W=Object(a.useState)([]),z=Object(h.a)(W,2),I=z[0],P=z[1],B=Object(a.useState)(""),V=Object(h.a)(B,2),A=V[0],R=V[1],H=function(){return j?f(e.length):f(e.length).reverse()};Object(a.useEffect)((function(){P(f(e.length))}),[e]),Object(a.useEffect)((function(){P(c?H().filter((function(t){var n=JSON.parse(e[t].StartPositionDisplay).street_name,a=JSON.parse(e[t].EndPositionDisplay).street_name;return isNaN(parseInt(A))?void 0!==n&&n.includes(A)||void 0!==a&&a.includes(A):e[t].TaskId.toString().includes(A)})):H())}),[c,A,e]),Object(a.useEffect)((function(){P(function(){var t=new Date(k,x-1).getTime(),n=new Date(L,M-1).getTime();return H().filter((function(a){var i=new Date(e[a].Created_Date).getTime();return i>=t&&i<=n}))}())}),[x,M,k,L,e]);var G=function(){R(""),o(!1)};return Object(u.jsxs)("div",{className:"ride-list",children:[Object(u.jsxs)("div",{className:"ride-search-container",children:[Object(u.jsx)("input",{className:"ride-search-input",placeholder:"Search..",value:A,onChange:function(t){if(""===t.target.value)return G();R(t.target.value),o(!0)}}),Object(u.jsx)("div",{className:"ride-search-cross",onClick:G,children:"X"})]}),Object(u.jsxs)("div",{className:"ride-search-container",children:[_,C]}),Object(u.jsxs)("div",{className:"ride-search-container",children:[T,D]}),Object(u.jsx)(m,{className:"ride-sort-cb",html:Object(u.jsxs)("div",{children:["Sort ",j?"\u25b2":"\u25bc"]}),onClick:function(t){p(!t),P(Object(d.a)(I).reverse())}}),Object(u.jsx)(b,{metas:e,showMetas:I,onClick:n})]})},v=n(143),x=n(10),_=n(132),w=n.n(_),y=n(133),k=n.n(y),C=(n(178),k()(w.a)),N=function(){return function(t){return C.fire(Object(x.a)(Object(x.a)({},t),{},{customClass:{popup:"sweetalert-popup",title:"sweetalert-title"}}))}},S=n(141),M=n(319),T=function(t,e,n,a){return Object(u.jsx)(M.a,{center:[t,e],radius:n.size,weight:n.boldness||4,opacity:n.opacity||1,color:n.color,eventHandlers:{click:a}})},E=function(t){var e=t.path,n=t.properties,a=t.onClick,i=e.data[0].pos,r=i.lat,c=i.lng;return T(r,c,n,a(0))},F=function(t){var e=t.path,n=t.properties,a=t.onClick,i=t.PointElt;return Object(u.jsx)(u.Fragment,{children:e.data.map((function(t,e){return Object(u.jsx)(i,{pos:t.pos,properties:n,onClick:a,i:e},"PointElt".concat(Math.random()))}))})},L=function(t){var e=t.pos,n=t.properties,a=t.onClick,i=t.i;return T(e.lat,e.lng,n,a(i))},D=function(t){return Object(u.jsx)(F,Object(x.a)(Object(x.a)({},t),{},{PointElt:L}))},W=n(9),z=n.n(W);z.a.Hotline=function(t,e){var n=function t(e){if(!(this instanceof t))return new t(e);this._canvas=e="string"===typeof e?document.getElementById(e):e,this._ctx=e.getContext("2d"),this._width=e.width,this._height=e.height,this._weight=5,this._weightFunc=void 0,this._outlineWidth=1,this._outlineColor="black",this._min=0,this._max=1,this._data=[],this.palette({0:"green",.5:"yellow",1:"red"})};n.prototype={width:function(t){return this._width=t,this},height:function(t){return this._height=t,this},weight:function(t){return this._weight=t,this},weightFunc:function(t){return this._weightFunc=t,this},outlineWidth:function(t){return this._outlineWidth=t,this},outlineColor:function(t){return this._outlineColor=t,this},palette:function(t){var e=document.createElement("canvas"),n=e.getContext("2d"),a=n.createLinearGradient(0,0,0,256);for(var i in e.width=1,e.height=256,t)a.addColorStop(i,t[i]);return n.fillStyle=a,n.fillRect(0,0,1,256),this._palette=n.getImageData(0,0,1,256).data,this},min:function(t){return this._min=t,this},max:function(t){return this._max=t,this},data:function(t){return this._data=t,this},add:function(t){return this._data.push(t),this},draw:function(){var t=this._ctx;return t.globalCompositeOperation="source-over",t.lineCap="round",this._drawOutline(t),this._drawHotline(t),this},getRGBForValue:function(t){var e=Math.min(Math.max((t-this._min)/(this._max-this._min),0),.999),n=4*Math.floor(256*e);return[this._palette[n],this._palette[n+1],this._palette[n+2]]},getWeight:function(t){return this._weightFunc?this._weightFunc(t):this._weight},_drawOutline:function(t){var e,n,a,i,r,c,o;if(this._outlineWidth)for(e=0,a=this._data.length;e<a;e++)for(n=1,r=(i=this._data[e]).length;n<r;n++)c=i[n-1],o=i[n],t.lineWidth=this.getWeight(n-1)+2*this._outlineWidth,t.strokeStyle=this._outlineColor,t.beginPath(),t.moveTo(c.x,c.y),t.lineTo(o.x,o.y),t.stroke()},_drawHotline:function(t){var e,n,a,i,r,c,o,s,u,l;for(e=0,a=this._data.length;e<a;e++)for(i=this._data[e],console.log(i),n=1,r=i.length;n<r;n++)c=i[n-1],o=i[n],t.lineWidth=this.getWeight(n-1),s=t.createLinearGradient(c.x,c.y,o.x,o.y),u=this.getRGBForValue(c.z),l=this.getRGBForValue(o.z),s.addColorStop(0,"rgb("+u.join(",")+")"),s.addColorStop(1,"rgb("+l.join(",")+")"),t.strokeStyle=s,t.beginPath(),t.moveTo(c.x,c.y),t.lineTo(o.x,o.y),t.stroke()}};var a=z.a.Canvas.extend({_initContainer:function(){z.a.Canvas.prototype._initContainer.call(this),this._hotline=new n(this._container)},_update:function(){z.a.Canvas.prototype._update.call(this),this._hotline.width(this._container.width),this._hotline.height(this._container.height)},_updatePoly:function(t){if(this._drawing){var e=t._parts;e.length&&(this._updateOptions(t),console.log(e,t),this._hotline.data(e).draw())}},_updateOptions:function(t){null!=t.options.min&&this._hotline.min(t.options.min),null!=t.options.max&&this._hotline.max(t.options.max),null!=t.options.weight&&this._hotline.weight(t.options.weight),null!=t.options.weightFunc&&this._hotline.weightFunc(t.options.weightFunc),null!=t.options.outlineWidth&&this._hotline.outlineWidth(t.options.outlineWidth),null!=t.options.outlineColor&&this._hotline.outlineColor(t.options.outlineColor),t.options.palette&&this._hotline.palette(t.options.palette)}}),i=function(t){return z.a.Browser.canvas?new a(t):null},r={clipSegment:function(t,e,n,a,i){var r,c,o,s=a?this._lastCode:z.a.LineUtil._getBitCode(t,n),u=z.a.LineUtil._getBitCode(e,n);for(this._lastCode=u;;){if(!(s|u))return[t,e];if(s&u)return!1;r=s||u,c=z.a.LineUtil._getEdgeIntersection(t,e,r,n,i),o=z.a.LineUtil._getBitCode(c,n),r===s?(c.z=t.z,t=c,s=o):(c.z=e.z,e=c,u=o)}}};return z.a.Polyline.extend({statics:{Renderer:a,renderer:i},options:{renderer:i(),min:0,max:1,palette:{0:"green",.5:"yellow",1:"red"},weight:5,outlineColor:"black",outlineWidth:1},getRGBForValue:function(t){return this._renderer._hotline.getRGBForValue(t)},_projectLatlngs:function(t,e,n){var a,i,r=t[0]instanceof z.a.LatLng,c=t.length;if(r){for(i=[],a=0;a<c;a++)i[a]=this._map.latLngToLayerPoint(t[a]),i[a].z=t[a].alt,n.extend(i[a]);e.push(i)}else for(a=0;a<c;a++)this._projectLatlngs(t[a],e,n)},_clipPoints:function(){if(this.options.noClip)this._parts=this._rings;else{this._parts=[];var t,e,n,a,i,c,o,s=this._parts,u=this._renderer._bounds;for(t=0,n=0,a=this._rings.length;t<a;t++)for(e=0,i=(o=this._rings[t]).length;e<i-1;e++)(c=r.clipSegment(o[e],o[e+1],u,e,!0))&&(s[n]=s[n]||[],s[n].push(c[0]),c[1]===o[e+1]&&e!==i-2||(s[n].push(c[1]),n++))}},_clickTolerance:function(){return this.options.weight/2+this.options.outlineWidth+(z.a.Browser.touch?10:0)}})};n(285);var I,P=n(313),B=function(){var t=Object(P.a)(),e=z.a.canvas({});return Object(a.useEffect)((function(){return e.addTo(t),function(){e.removeFrom(t)}}),[]),[t,e]},V=function(t){var e=t.path,n=(t.properties,t.palette),i=t.onClick,r=B(),c=Object(h.a)(r,2),o=c[0];c[1];return Object(a.useEffect)((function(){var t=n||{0:"green",.5:"yellow",1:"red"},a=e.data.map((function(t){return[t.pos.lat,t.pos.lng,t.value||0]}));console.log(z.a.Hotline),new(z.a.Hotline(a,{weight:4,weightFunc:function(t){return 3*t/a.length+4},outlineWidth:0,palette:t,min:e.minValue||0,max:e.maxValue||1,onclick:i(0)}))(a,{weight:4,weightFunc:function(t){return 3*t/a.length+4},outlineWidth:0,palette:t,min:e.minValue||0,max:e.maxValue||1,onclick:i(0)}).addTo(o)}),[]),Object(u.jsx)(u.Fragment,{})},A=n(314),R=function(t){var e=t.path,n=t.properties,a=t.onClick,i=e.data.map((function(t){return t.pos}));return Object(u.jsx)(A.a,{positions:i,pathOptions:{color:n.color,weight:n.boldness||n.size,opacity:n.opacity||1},eventHandlers:{click:a(0)}},"".concat(Math.random(),"-line"))},H=n(315),G=function(t){var e=t.pos,n=t.properties,a=t.onClick,i=t.i,r=n.size/1e4,c=new W.LatLngBounds([e.lat-r/2,e.lng-r/2],[e.lat+r/3,e.lng+r/1.2]);return Object(u.jsx)(H.a,{bounds:c,color:n.color,weight:n.boldness||4,opacity:n.opacity||1,eventHandlers:{click:a(i)}})},J=function(t){return Object(u.jsx)(F,Object(x.a)(Object(x.a)({},t),{},{PointElt:G}))};!function(t){t.circle="circle",t.circles="circles",t.rectangles="rectangles",t.line="line",t.hotline="hotline",t.hotpoints="hotpoints"}(I||(I={}));var Z={circle:E,circles:D,rectangles:J,line:R,hotline:V,hotpoints:V},U=function(t){var e=t.updateName,n=t.updateTag,i=t.updateSelected,r=t.updateColor,c=t.defaultOptions,o=Object(a.useState)(c.renderer),s=Object(h.a)(o,2),l=s[0],d=s[1],j=Object(a.useState)(c.color),f=Object(h.a)(j,2),p=f[0],b=f[1],O=function(t){return function(e){d(t),i(t)}};return Object(u.jsxs)("div",{className:"popup-wrapper",children:[Object(u.jsx)("input",{className:"sweetalert-input",placeholder:"Name..",type:"text",defaultValue:c.name,onChange:function(t){e(t.target.value)}}),Object(u.jsx)("input",{className:"sweetalert-input",placeholder:"Tag..",type:"text",defaultValue:c.tag,onChange:function(t){n(t.target.value)}}),Object(u.jsx)("div",{className:"sweetalert-checkboxes",children:Object.keys(Z).map((function(t,e){return Object(u.jsx)(m,{className:"ride-metadata-checkbox",html:Object(u.jsx)("div",{style:{textTransform:"capitalize"},children:t}),forceState:l===t,onClick:O(t)},"sweetalert-checkbox-".concat(e))}))}),Object(u.jsx)(S.a,{color:p,onChangeComplete:function(t){b(t.hex),r(t.hex)},triangle:"hide"})]})},q=function(){var t=N();return{fire:function(e,n){t({title:Object(u.jsxs)("p",{children:["Enter the name of your measurement and its tag",Object(u.jsx)("br",{}),"(ex: obd.rpm, acc.xyz)"]}),showCancelButton:!0,cancelButtonColor:"#d33",confirmButtonText:"Add",html:Object(u.jsx)(U,{defaultOptions:n,updateName:function(t){return n.name=t},updateTag:function(t){return n.tag=t},updateSelected:function(t){return n.renderer=t},updateColor:function(t){return n.color=t}})}).then((function(a){if(!a.isConfirmed)return e(void 0);var i={renderer:n.renderer,query:"/trip_measurement",queryMeasurement:n.tag,name:n.name,color:n.color,size:1,value:"number"};e(i),t({title:Object(u.jsxs)("p",{children:["Measurement ",Object(u.jsx)("b",{children:i.name})," added / modified"]}),footer:"Will be drawn as ".concat(i.renderer),icon:"success",timer:1500,timerProgressBar:!0})}))}}},Q=(n(119),["StartTimeUtc","EndTimeUtc"]),X=["StartPositionDisplay","EndPositionDisplay"],Y=["Fully_Imported","Fully_RouteAnnotated","Description","ChangeLog"],K=function(t){var e=new Date(t);return e.getDate()+"/"+e.getMonth()+"/"+e.getFullYear()+"  "+e.getHours()+":"+e.getMinutes()},$=function(t){var e=t.md,n=Object(a.useState)([]),i=Object(h.a)(n,2),r=i[0],c=i[1];return Object(a.useEffect)((function(){var t=Object.entries(e).filter((function(t){return!Y.includes(t[0])})).flatMap((function(t,n){var a=Object(h.a)(t,2),i=a[0],r=a[1],c=e.TaskId+"-"+n;if(X.includes(i)){var o={key:c,title:i,value:""},s=[];try{s=Object.entries(JSON.parse(r))}catch(l){}var u=s.map((function(t,e){return{key:c+"-"+e,title:t[0],value:t[1],isSublist:!0}}));return[o].concat(Object(d.a)(u))}return Q.includes(i)?{key:c,title:i,value:K(r)}:{key:c,title:i,value:r}}));c(t)}),[e]),Object(u.jsxs)(u.Fragment,{children:[Object(u.jsx)("div",{className:"ride-metadata-separation"}),Object(u.jsx)("div",{className:"ride-metadata-list",children:r.map((function(t){return function(t){var e=t.key,n=t.title,a=t.value,i=t.isSublist;return Object(u.jsxs)("div",{className:"ride-metadata-elt ".concat(i?"sublist-elt":""),children:[Object(u.jsxs)("b",{children:[n,":"]})," ",a]},"metadata-".concat(e))}(t)}))})]})},tt=n(83),et=n.n(tt),nt=function(t,e){fetch(t).then((function(t){return t.json()})).then((function(t){return e(t)}))},at=function(t,e,n){et.a.get(t,{params:e}).then((function(t){return n(t.data)}))},it=function(t,e){et.a.put(t,{params:e})},rt=function(){var t=Object(a.useState)([]),e=Object(h.a)(t,2),n=e[0],i=e[1];return Object(a.useEffect)((function(){nt("/measurements",(function(t){i(t)}))}),[]),[n,i]},ct=function(t){var e=t.measurements,n=t.setMeasurements,i=t.metas,r=t.measurementClick,c=Object(a.useState)(!1),o=Object(h.a)(c,2),s=o[0],l=o[1],j=q(),f=function(t,a){t.preventDefault(),t.stopPropagation();var i=e[a];j.fire((function(t){void 0!==t&&(n((function(e){return e.map((function(e,n){return a===n?t:e}))})),it("/editmeasurement",{measurement:t,index:a}))}),{name:i.name,tag:i.queryMeasurement,renderer:i.renderer,color:i.color})},p=function(t,e){return Object(u.jsxs)("div",{className:"checkbox-container",children:[Object(u.jsxs)("div",{className:"checkbox-title",children:[t.name," ",Object(u.jsxs)("p",{className:"checkbox-subtitle",children:["- ",t.renderer]})]}),Object(u.jsx)(v.a,{className:"edit-meas-btn btn",onClick:function(t){return f(t,e)},strokeWidth:1})]})};return Object(u.jsxs)("div",{className:"meta-data",children:[e.map((function(t,e){return Object(u.jsx)(m,{className:"ride-metadata-checkbox",html:p(t,e),onClick:function(t){return r(e,t)}},"ride-md-checkbox-".concat(e))})),Object(u.jsx)(m,{className:"ride-metadata-checkbox md-checkbox-add",html:Object(u.jsx)("div",{children:"+"}),forceState:s,onClick:function(){l(!0),j.fire((function(t){(l(!1),void 0!==t)&&(n((function(e){return[].concat(Object(d.a)(e),[t])})),it("/addmeasurement",t))}),{name:"",tag:"",renderer:I.circles,color:"#bb55dd"})}}),i.map((function(t,e){return Object(u.jsx)($,{md:t},"ride-md-".concat(t.TaskId,"-").concat(e))}))]})},ot=n(138),st=n.n(ot),ut=function(t){var e=t.setAddChartData,n=t.setRemChartData,i=Object(a.useState)([]),r=Object(h.a)(i,2),c=r[0],o=r[1],s=function(t,e){console.log("adding "+t);var n=Math.ceil(e.length/5e3),a=e.filter((function(t,e){return e%n===0})),i=Object(d.a)(c);i.push({name:t,data:a}),o(i)},l=function(t){var e=Object(d.a)(c).filter((function(e){return e.name!==t}));o(e)};Object(a.useEffect)((function(){console.log("before"),e((function(){return s})),n((function(){return l})),console.log("after")}),[]);var j={chart:{id:"basic-bar",animations:{enabled:!1}},stroke:{width:3,curve:"smooth"},toolTip:{shared:!0},xaxis:{type:"number",position:"bottom",tickAmount:10,labels:{formatter:function(t,e,n){var a=new Date(Math.round(Number.parseFloat(t)));return a.getHours()+"h"+a.getMinutes()}}},theme:{mode:"dark",palette:"palette1"}};return Object(u.jsx)("div",{className:"chart-wrapper",children:Object(u.jsx)(st.a,{options:j,series:c,type:"line",height:"100%"})})},lt=n(316),dt=n(317),ht=function t(e){return console.log(e,"object"===typeof e),"object"===typeof e&&Array.isArray(e)?Object(u.jsx)("div",{children:e.map((function(e){return t(e)})).join(", ")},"md-".concat(Math.random())):"object"===typeof e?Object.keys(e).map((function(n){return Object(u.jsxs)("div",{children:[" "," > "," ",n,": ",t(e[n])]},"md-".concat(Math.random()))})):e},jt=function(t,e){return void 0===e||null===e?Object(u.jsx)(u.Fragment,{}):"object"===typeof e?Object(u.jsxs)("div",{children:[t,":",ht(e)]},"popupline-".concat(Math.random())):Object(u.jsxs)("div",{children:[t,": ",e]},"popupline-".concat(Math.random()))},mt=function(t){var e=t.path,n=t.properties,i=t.metadata,r=Object(a.useState)([0,0]),c=Object(h.a)(r,2),o=c[0],s=c[1],l=Object(a.useState)(void 0),d=Object(h.a)(l,2),j=d[0],m=d[1],f=i||{},p=Z[n.renderer],b=e.data[j||0];return Object(u.jsxs)(u.Fragment,{children:[Object(u.jsx)(p,{path:e,properties:n,onClick:function(t){return function(e){var n=e.latlng,a=n.lat,i=n.lng;s([a,i]),m(t)}}}),void 0!==j&&Object(u.jsx)(lt.a,{position:o,children:Object(u.jsxs)(dt.a,{children:[jt("Properties",n),jt("Value",b.value),jt("Timestamp",b.timestamp),Object.keys(b.metadata||{}).map((function(t){return jt(t,b.metadata[t])})),Object.keys(f).map((function(t){return jt(t,f[t])}))]})})]})},ft=(n(305),function(){return{loaded:!1,path:{data:[]},fullPath:void 0}}),pt={12:3e3,13:5e3,14:3e4,15:35e3,16:3e4},bt=function(t){var e=t.measurements,n=t.activeMeasurements,i=t.tripId,r=t.taskId,c=t.addChartData,o=t.removeChartData,s=Object(a.useState)(e.map(ft)),l=Object(h.a)(s,2),j=l[0],m=l[1],f=Object(a.useState)(void 0),p=Object(h.a)(f,2),b=p[0],O=p[1],g=N(),v=Object(P.b)({zoom:function(t){y()},dragend:function(t){y()}}),x=new Worker("/thread.worker.js"),_=function(t,e,n,a,i,r){x.postMessage({type:t,minLength:e,bounds:n,paths:a,path:i,i:r})},w=function(t,e,n,a){var i={type:t,minLength:C(),bounds:k()};void 0===b?_(i.type,i.minLength,i.bounds,e,n,a):(O(i),console.log("Queue request"))},y=function(){w("ALL",Object(d.a)(j),void 0,void 0)},k=function(){var t=v.getBounds();return[t.getNorthWest(),t.getSouthEast()]},C=function(){var t=k(),e=Object(h.a)(t,2),n=e[0],a=e[1],i=n.lat-a.lat,r=a.lng-n.lng,c=Math.min(Math.max(v.getZoom(),12),16),o=pt[c];return Math.sqrt(i*i+r*r)/o},S=function(t){return r.toString()};Object(a.useEffect)((function(){x.onmessage=function(t){var e=t.data,n=e.type,a=e.pathsCopy,i=e.path,r=e.performancePath,c=e.index;if("ONE"===n){var o=Object(d.a)(j),s={loaded:!0,path:r,fullPath:i};c<j.length?o[c]=s:o.push(s),m(o)}else"ALL"===n&&m(a);b&&("ONE"===b.type?_(b.type,b.minLength,b.bounds,void 0,void 0,void 0):"ALL"===b.type&&_(b.type,b.minLength,b.bounds,Object(d.a)(j),void 0,void 0))}}),[x]);var M=function(t){if(void 0===j[t]||!j[t].loaded){var n=e[t];at(n.query,{tripID:i,measurement:n.queryMeasurement},(function(e){var a=e.data.map((function(t){return{pos:new W.LatLng(t.pos.lat,t.pos.lon),value:t.value,timestamp:t.timestamp}})),o=e.minValue,s=e.maxValue,u=e.minTime,l=e.maxTime,d={data:a,minValue:o,maxValue:s,minTime:u,maxTime:l};if(function(t,e){w("ONE",void 0,t,e)}(d,t),console.log("Got data for ride: ",i,", length: ",a.length),console.log("Min value",o,"Max Value",s),console.log("Min time",u,"Max Time",l),n.value){if(0===d.data.length)return g({icon:"warning",title:"This trip doesn't contain data for ".concat(n.name),footer:"TripId: ".concat(i," | TaskId: ").concat(r)});var h=d.data[0].timestamp||0;c(S(),e.data.map((function(t){return{x:t.timestamp-h,y:t.value}})))}}))}};return Object(a.useEffect)((function(){e.length>j.length&&M(j.length),j.forEach((function(t,a){var i=n.includes(a);if(i&&!j[a].loaded)M(a);else if(!i&&j[a].loaded){var r=Object(d.a)(j);r[a].loaded=!1,r[a].path=void 0,r[a].fullPath=void 0,m(r),o(S(e[a]))}}))}),[e,n,j]),Object(u.jsx)(u.Fragment,{children:j.filter((function(t){return t.loaded})).map((function(t,a){return Object(u.jsx)(mt,{path:t.path,properties:e[n[a]]},"path".concat(Math.random()))}))})},Ot=n(318),gt=n(320),vt=(n(306),function(){return Object(P.b)({click:function(t){return console.log(t.latlng)}}),Object(u.jsx)(u.Fragment,{})}),xt=function(t){var e=t.children;return Object(u.jsxs)(Ot.a,{preferCanvas:!0,center:[55.6720619937223,12.558746337890627],zoom:11,scrollWheelZoom:!0,children:[Object(u.jsx)(gt.a,{attribution:'\xa9 <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),Object(u.jsx)(vt,{}),e]})},_t=(n(57),function(){var t=rt(),e=Object(h.a)(t,2),n=e[0],i=e[1],r=Object(a.useState)([]),c=Object(h.a)(r,2),o=c[0],s=c[1],l=Object(a.useState)([]),j=Object(h.a)(l,2),m=j[0],f=j[1],p=Object(a.useState)([]),b=Object(h.a)(p,2),O=b[0],v=b[1],x=Object(a.useState)((function(){})),_=Object(h.a)(x,2),w=_[0],y=_[1],k=Object(a.useState)((function(){})),C=Object(h.a)(k,2),N=C[0],S=C[1];Object(a.useEffect)((function(){nt("/rides",(function(t){return f(t.filter((function(t){return 0!==t.TaskId})))}))}),[]);return Object(u.jsxs)("div",{className:"rides-wrapper",children:[Object(u.jsx)(g,{metas:m,onClick:function(t,e){if(e)v((function(e){return[].concat(Object(d.a)(e),[t])}));else{var n=0;v(O.filter((function(e){return e===t&&(n=t),e!==t}))),N(m[n].TaskId.toString())}}}),Object(u.jsx)(ct,{measurements:n,setMeasurements:i,measurementClick:function(t,e){s(e?function(e){return[].concat(Object(d.a)(e),[t])}:function(e){return e.filter((function(e){return e!==t}))})},metas:O.map((function(t){return m[t]}))}),Object(u.jsxs)("div",{className:"map-container",children:[Object(u.jsx)(xt,{children:m.filter((function(t,e){return O.includes(e)})).flatMap((function(t){return Object(u.jsx)(bt,{measurements:n,activeMeasurements:o,tripId:t.TripId,taskId:t.TaskId,addChartData:w,removeChartData:N},"Ride".concat(Math.random()))}))}),Object(u.jsx)(ut,{setAddChartData:y,setRemChartData:S})]})]})}),wt=n(39),yt=(n(307),function(){var t=Object(a.useState)({username:"",email:"",password:""}),e=Object(h.a)(t,2),n=e[0],i=e[1],r=function(t){t.preventDefault();var e=t.target,n=e.name,a=e.value;i((function(t){return Object(x.a)(Object(x.a)({},t),{},Object(wt.a)({},n,a))}))},c=Object(s.f)();return Object(u.jsxs)("div",{className:"signup-wrapper",children:[Object(u.jsx)("h2",{children:"Sign Up"}),Object(u.jsxs)("div",{children:[Object(u.jsxs)("div",{className:"signup-input-container",children:[Object(u.jsx)("label",{htmlFor:"username",children:"Username"}),Object(u.jsx)("input",{type:"text",name:"username",onChange:r})]}),Object(u.jsxs)("div",{className:"signup-input-container",children:[Object(u.jsx)("label",{htmlFor:"email",children:"Email"}),Object(u.jsx)("input",{type:"email",name:"email",onChange:r})]}),Object(u.jsxs)("div",{className:"signup-input-container",children:[Object(u.jsx)("label",{htmlFor:"password",children:"Password"}),Object(u.jsx)("input",{type:"password",name:"password",onChange:r})]}),Object(u.jsx)("div",{className:"btn signup-btn",onClick:function(){at("/login",n,(function(t){"ok"===t.status&&c.push("/rides")}))},children:"Register Me"})]})]})}),kt=function(t){return Object(u.jsx)(M.a,{center:[t.lat,t.lon],radius:5,color:function(t,e,n){if(void 0==t)return"rgb(0, 0, 0)";t>e?t=e:t<n&&(t=n),t=1/(e-n)*(t-n);var a=255*Math.min(2*t,1),i=255*(t<.5?t+.5:2-2*t);return"rgb(".concat(Math.round(i),", ").concat(Math.round(a),", 0)")}(function(){var e=t.message;return null!=JSON.parse(e)["obd.trac_cons.value"]&&console.log(JSON.parse(e)["obd.trac_cons.value"]),JSON.parse(e)["obd.trac_cons.value"]}(),200,140)})},Ct=function(t){return Object(u.jsx)("div",{children:t.measurements.map((function(t,e){return Object(u.jsx)(kt,{lat:t.lat,lon:t.lon,message:t.message},"measurement-".concat(e))}))})},Nt=n(84),St=n.n(Nt),Mt=n(139),Tt=function(t){var e=18,n=100,a=Object(P.b)({zoomend:function(){return Object(Mt.a)(St.a.mark((function i(){var r,c,o,s,u,l,d,h;return St.a.wrap((function(i){for(;;)switch(i.prev=i.next){case 0:if(console.log("Current zoom "+a.getZoom()),console.log("Latest zoom "+e),console.log("Maximum rendered zoom "+n),!(a.getZoom()>e||a.getZoom()>=n)){i.next=5;break}return i.abrupt("return");case 5:n=a.getZoom(),r=a.getBounds(),c=r.getSouthWest(),o=r.getNorthEast(),s=o.lng,u=o.lat,l=c.lng,d=c.lat,h="/measurements?T=obd.trac_cons&maxlon="+s+"&maxlat="+u+"&minlon="+l+"&minlat="+d,console.log(h),fetch(h).then((function(t){return t.json()})).then((function(e){var n=e;console.log(n),t.setMeasurements(n)}));case 16:case"end":return i.stop()}}),i)})))()},zoomstart:function(){e=a.getZoom(),a.getZoom()<n&&(n=e)}});return null},Et=function(){var t=Object(a.useState)([]),e=Object(h.a)(t,2),n=e[0],i=e[1];return Object(u.jsx)("div",{className:"rides-wrapper",children:Object(u.jsx)("div",{className:"map-container",children:Object(u.jsxs)(Ot.a,{preferCanvas:!0,center:[55.6720619937223,12.558746337890627],zoom:18,scrollWheelZoom:!0,children:[Object(u.jsx)(gt.a,{attribution:'\xa9 <a href="http://osm.org/copyright">OpenStreetMap</a> contributors',url:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png"}),Object(u.jsx)(Tt,{setMeasurements:i}),Object(u.jsx)(Ct,{measurements:n})]})})})},Ft=function(){return Object(u.jsx)(Et,{})},Lt=n(140),Dt=(n(309),function(){var t=Object(a.useState)({}),e=Object(h.a)(t,2),n=e[0],i=e[1],r=Object(a.useState)([]),c=Object(h.a)(r,2),o=c[0],s=c[1];Object(a.useEffect)((function(){var t=new WebSocket("ws://localhost:3001/ws");t.onopen=function(){console.log("open"),t.send("something")},t.onmessage=function(t){var e,a=JSON.parse(t.data),r=a.type,c=a.filename,o=a.data;if(console.log("received:",r,c,o),"rename"===r||"change"===r){console.log(typeof o);var u=c.replace(".json",""),l=Object(x.a)(Object(x.a)({},n),{},Object(wt.a)({},u,o));console.log(n),console.log(l),i(l)}else if("deleted"===r){var d=Object(x.a)({},n);delete d[c.replace(".json","")],i(d)}else if("CONNECTED"===r){s((e=o.length,Array.from({length:e},(function(t,e){return!0}))));var h,j={},m=Object(Lt.a)(o);try{for(m.s();!(h=m.n()).done;){var f=h.value;j[f.filename.replace(".json","")]=f.data}}catch(p){m.e(p)}finally{m.f()}i(j),console.log(j)}}}),[]);var l=function(t){return function(){var e=Object(d.a)(o);e[t]=!e[t],s(e)}};return Object(u.jsxs)("div",{className:"ml-wrapper",children:[Object(u.jsx)(xt,{children:Object.keys(n).map((function(t,e){return o[e]?Object(u.jsx)(mt,{path:n[t].path,properties:n[t].properties,metadata:n[t].metadata},"ml-path-".concat(e)):Object(u.jsx)(u.Fragment,{})}))}),Object(u.jsx)("div",{className:"ml-checkboxes",children:Object.keys(n).map((function(t,e){return Object(u.jsx)(m,{forceState:o[e],className:"btn ml-checkbox",html:Object(u.jsx)("div",{children:t}),onClick:l(e)},"ml-".concat(e))}))})]})}),Wt=(n(310),function(){return Object(u.jsx)("div",{className:"App",children:Object(u.jsxs)(o.a,{children:[Object(u.jsx)(l,{}),Object(u.jsxs)(s.c,{children:[Object(u.jsx)(s.a,{exact:!0,path:"/",component:function(){return Object(u.jsx)(Ft,{})}}),Object(u.jsx)(s.a,{exact:!0,path:"/rides",component:function(){return Object(u.jsx)(_t,{})}}),Object(u.jsx)(s.a,{exact:!0,path:"/ml",component:function(){return Object(u.jsx)(Dt,{})}}),Object(u.jsx)(s.a,{exact:!0,path:"/login",component:function(){return Object(u.jsx)(yt,{})}})]})]})})});c.a.render(Object(u.jsx)(i.a.StrictMode,{children:Object(u.jsx)(Wt,{})}),document.getElementById("root"))},57:function(t,e,n){}},[[311,1,2]]]);
//# sourceMappingURL=main.30d1a1b2.chunk.js.map