import{i as e}from"./chunk-aKtaBQYM.js";import{Vt as t,wt as n}from"./mui-B6lh3XSP.js";import{l as r,u as i}from"./IconButton-BEBOUWhl.js";import{t as a}from"./Container-CHg71Wor.js";import{i as o,n as s,r as c,t as l}from"./ExpandMore-BvigPYWL.js";import{t as u}from"./Typography-DfQXhGTT.js";import{n as d}from"./MenuItem-HQNtf0LG.js";import{en as f,mt as p,w as m,yt as h}from"./index-KVuxnkWj.js";import{n as g,t as _}from"./useSettingsStyles-X3caKosH.js";import{t as v}from"./BaseCommandView-CSuXz86y.js";var y=e(t(),1),b=n(),x=()=>{let e=r(),{classes:t}=_(),n=h(),{id:x}=i(),[S,C]=(0,y.useState)(0),[w,T]=(0,y.useState)({}),E=p(async()=>{let t;t=S?await(await m(`/api/commands/${S}`)).json():w,t.deviceId=parseInt(x,10),await m(`/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};