import{j as s,S as i,h as p,H as g,s as m,a1 as C}from"./vendor-ClLR6ncd.js";import{E as x,L as k,o as w,ar as L,d as v,i as r,f,g as h,aY as a,X as I}from"./index-OtVJl4GC.js";import"./lodash-ZyeDnt0e.js";import{d as R}from"./Cancel-BcN7wjUl.js";import{d as T}from"./Add-CLrXAvOx.js";import{E as B}from"./Messages-BRmQDxrZ.js";import{R as Q}from"./RefreshDataButton-BMv_Vwgi.js";import{T as P,a as D,u as E}from"./ui-erh8p_Di.js";import{L as M}from"./Link-BLwKPJFF.js";import"./OptionallyDenseMuiTable-D7b58l1V.js";import"./TableContainer-CN5gAdqf.js";import"./TableRow-CGDSOtFZ.js";import"./TableSortLabel-BJFq2axQ.js";function U({str:e}){var o;return(o=a(e))==null?void 0:o.sessionPort}function F({str:e,disabled:o}){var l,c,d,u;const n=a(e),t=x(["sessions",n.sessionId],()=>r({url:f(h(n),"session/description")})),j=o||!t.isSuccess,S={repositoryId:(c=(l=t.data)==null?void 0:l.wrapping)==null?void 0:c.name,catalogId:(u=(d=t.data)==null?void 0:d.wrapping)==null?void 0:u.catalog},y=I({...n,...S});return j?s.jsx(p,{sx:{color:"text.disabled"},children:"Link"}):s.jsx(M,{component:m,to:y,children:"Link"})}function N({row:e,disabled:o}){const{closeSessionMutation:n}=E();return s.jsx(C,{disabled:o,onClick:()=>n.mutate(e),children:s.jsx(R,{})})}const q=[{label:"Description",key:"description"},{label:"Port",Component:U,key:"uri"},{label:"Details",key:"shortDescription"},{label:"Link",sortable:!1,key:"uri",Component:F},{label:"Close",sx:{width:"100px"},Component:N,sortable:!1}],b=()=>{L.invalidateQueries(["sessions"])};function _({sessions:e,disabled:o}){const n=v(({uri:t})=>r({url:f(h(a(t)),"session/close"),method:"post"}),{onSettled:b});return s.jsxs(s.Fragment,{children:[s.jsx(B,{error:n.error,reset:n.reset}),s.jsx(P,{value:{closeSessionMutation:n},children:s.jsx(D,{uniqueRowKey:"uri",rows:e,columns:q,emptyRowsTitle:"No active sessions",initSortingColumn:"description",cellProps:{disabled:n.isLoading||o}})})]})}function ss(){const e=x(["sessions"],()=>r({url:"/session"})),o=e.isFetching;return s.jsxs(i,{spacing:w(),sx:{flexGrow:1},children:[s.jsxs(i,{direction:"row",justifyContent:"space-between",children:[s.jsx(p,{variant:"h4",children:"Sessions"}),s.jsxs(i,{direction:"row",spacing:2,children:[s.jsx(Q,{disabled:o,onClick:b}),s.jsx(g,{startIcon:s.jsx(T,{}),variant:"contained",component:m,to:"./new",path:"relative",children:"New session"})]})]}),e.isSuccess?s.jsx(_,{sessions:e.data,disabled:o}):s.jsx(k,{})]})}export{ss as default};
