import{i as e}from"./chunk-aKtaBQYM.js";import{Vt as t,t as n,wt as r}from"./mui-B6lh3XSP.js";import{l as i,t as a,u as o}from"./IconButton-BEBOUWhl.js";import{t as s}from"./Typography-DfQXhGTT.js";import{t as c}from"./AppBar-DnD8yI_W.js";import{F as l,Tt as u,o as d,pt as f,q as p,w as m,yt as h}from"./index-KVuxnkWj.js";import{t as g}from"./BackIcon-BjuxlqVJ.js";import{t as _}from"./MapGeofence-Bl8PxdWQ.js";import{t as v}from"./MapPositions-DNSQ8WnZ.js";import{t as y}from"./MapScale-Bi_SBcLe.js";import{t as b}from"./MapCamera-C0XDEMbg.js";var x=e(t(),1),S=r(),C=n()(()=>({root:{height:`100%`,display:`flex`,flexDirection:`column`},toolbar:{zIndex:1},mapContainer:{flexGrow:1}})),w=()=>{let{classes:e}=C(),t=i(),n=h(),{id:r}=o(),[w,T]=(0,x.useState)(),[E,D]=(0,x.useState)(),[O,k]=(0,x.useState)(!1),A=e=>p(n,{type:e.type,attributes:{alarms:e.attributes.alarm}}),j=(0,x.useCallback)(e=>{k(!!e)},[k]);return f(async({signal:e})=>{r&&T(await(await m(`/api/events/${r}`,{signal:e})).json())},[r]),f(async({signal:e})=>{if(w&&w.positionId){let t=await(await m(`/api/positions?id=${w.positionId}`,{signal:e})).json();t.length>0&&D(t[0])}},[w]),(0,S.jsxs)(`div`,{className:e.root,children:[(0,S.jsx)(c,{color:`inherit`,position:`static`,className:e.toolbar,children:(0,S.jsxs)(u,{children:[(0,S.jsx)(a,{color:`inherit`,edge:`start`,sx:{mr:2},onClick:()=>t(`/`),children:(0,S.jsx)(g,{})}),(0,S.jsx)(s,{variant:`h6`,children:w&&A(w)})]})}),(0,S.jsxs)(`div`,{className:e.mapContainer,children:[(0,S.jsxs)(l,{children:[(0,S.jsx)(_,{}),E&&(0,S.jsx)(v,{positions:[E],onMarkerClick:j,titleField:`fixTime`})]}),(0,S.jsx)(y,{}),E&&(0,S.jsx)(b,{latitude:E.latitude,longitude:E.longitude}),E&&O&&(0,S.jsx)(d,{deviceId:E.deviceId,position:E,onClose:()=>k(!1),disableActions:!0})]})]})};export{w as default};