import{i as e}from"./chunk-aKtaBQYM.js";import{Vt as t,wt as n,zt as r}from"./mui-B6lh3XSP.js";import{l as i,u as a}from"./IconButton-BEBOUWhl.js";import{t as o}from"./Container-CHg71Wor.js";import{i as s,n as c,r as l,t as u}from"./ExpandMore-BvigPYWL.js";import{t as d}from"./TextField-DOdnjCrL.js";import{t as f}from"./Typography-DfQXhGTT.js";import{n as p}from"./MenuItem-HQNtf0LG.js";import{R as m,at as h,en as g,it as _,mt as v,ot as y,w as b,yt as x}from"./index-KVuxnkWj.js";import{n as S,t as C}from"./useSettingsStyles-X3caKosH.js";var w=e(t(),1),T=n(),E=()=>{let e=i(),{classes:t}=C(),n=x(),E=m(`distanceUnit`),{deviceId:D}=a(),O=r(e=>e.session.positions[D]),[k,A]=(0,w.useState)();(0,w.useEffect)(()=>{O&&!k&&A({deviceId:parseInt(D,10),hours:O.attributes.hours||0,totalDistance:O.attributes.totalDistance||0})},[D,O,k]);let j=v(async()=>{await b(`/api/devices/${D}/accumulators`,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify(k)}),e(-1)});return(0,T.jsx)(p,{menu:(0,T.jsx)(S,{}),breadcrumbs:[`sharedDeviceAccumulators`],children:k&&(0,T.jsxs)(o,{maxWidth:`xs`,className:t.container,children:[(0,T.jsxs)(s,{defaultExpanded:!0,children:[(0,T.jsx)(c,{expandIcon:(0,T.jsx)(u,{}),children:(0,T.jsx)(f,{variant:`subtitle1`,children:n(`sharedRequired`)})}),(0,T.jsxs)(l,{className:t.details,children:[(0,T.jsx)(d,{type:`number`,value:k.hours/36e5,onChange:e=>A({...k,hours:Number(e.target.value)*36e5}),label:n(`positionHours`)}),(0,T.jsx)(d,{type:`number`,value:_(k.totalDistance,E),onChange:e=>A({...k,totalDistance:h(Number(e.target.value),E)}),label:`${n(`deviceTotalDistance`)} (${y(E,n)})`})]})]}),(0,T.jsxs)(`div`,{className:t.buttons,children:[(0,T.jsx)(g,{type:`button`,color:`primary`,variant:`outlined`,onClick:()=>e(-1),children:n(`sharedCancel`)}),(0,T.jsx)(g,{type:`button`,color:`primary`,variant:`contained`,onClick:j,children:n(`sharedSave`)})]})]})})};export{E as default};