import{i as e}from"./chunk-aKtaBQYM.js";import{Ft as t,vt as n}from"./mui-BgU4WrXF.js";import{l as r,u as i}from"./IconButton-oialqkv3.js";import{t as a}from"./Container-fY8-hTkD.js";import{i as o,n as s,r as c,t as l}from"./ExpandMore-D0ycvrdR.js";import{t as u}from"./Typography-7EcQ2i3p.js";import{n as d}from"./MenuItem-BNgF7Xqv.js";import{Ut as f,ct as p,pt as m,w as h}from"./index-bel1r0Sr.js";import{n as g,t as _}from"./useSettingsStyles-Bugi6oTj.js";import{t as v}from"./BaseCommandView-7Yk4HVG-.js";var y=e(t(),1),b=n(),x=()=>{let e=r(),{classes:t}=_(),n=m(),{id:x}=i(),[S,C]=(0,y.useState)(0),[w,T]=(0,y.useState)({}),E=p(async()=>{let t;t=S?await(await h(`/api/commands/${S}`)).json():w,t.deviceId=parseInt(x,10),await h(`/api/commands/send`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),e(-1)});return(0,b.jsx)(d,{menu:(0,b.jsx)(g,{}),breadcrumbs:[`settingsTitle`,`deviceCommand`],children:(0,b.jsxs)(a,{maxWidth:`xs`,className:t.container,children:[(0,b.jsxs)(o,{defaultExpanded:!0,children:[(0,b.jsx)(s,{expandIcon:(0,b.jsx)(l,{}),children:(0,b.jsx)(u,{variant:`subtitle1`,children:n(`sharedRequired`)})}),(0,b.jsx)(c,{className:t.details,children:(0,b.jsx)(v,{deviceId:x,item:w,setItem:T,includeSaved:!0,savedId:S,setSavedId:C})})]}),(0,b.jsxs)(`div`,{className:t.buttons,children:[(0,b.jsx)(f,{type:`button`,color:`primary`,variant:`outlined`,onClick:()=>e(-1),children:n(`sharedCancel`)}),(0,b.jsx)(f,{type:`button`,color:`primary`,variant:`contained`,onClick:E,disabled:!(S||w&&w.type),children:n(`commandSend`)})]})]})})};export{x as default};