import{r as A,j as e,a as q,u as _,b as v,l as m,D as L,e as O,f as T,R as U,F as $,g as R,h as k,H as F,i as M,k as Q,B as V,n as z,o as H,c as w,d as D,m as S,a5 as K,p as P,q as G,s as Y,L as g}from"./main-BiT4j4N5.js";import{B as J,L as N,p as b,D as h}from"./LastActive-Ceb4QxH0.js";import{E as W}from"./EndBrowserSessionButton-Di6zgty2.js";import{b as X}from"./Heading-CvufBt0-.js";import{D as j,a as f,b as p,c as i,d as t,e as a,S as Z,f as ee,g as se,h as ne}from"./SessionInfo-BtuHKLPz.js";import{V as ie}from"./VisualListItem-BkHZYn9E.js";import{s as te,E as re,g as ae,a as oe}from"./EndOAuth2SessionButton-D0rrwtbQ.js";import{I as le}from"./edit-5KWg-Gnh.js";import{S as de}from"./Submit-fS0aoNPD.js";import{C as ce}from"./computer-BrA2K14l.js";import"./_commonjsHelpers-DaWZu8wl.js";/* empty css               */import"./Separator-Bb4mxhob.js";function C(r,s){return e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",fill:"currentColor",viewBox:"0 0 24 24",ref:s,...r,children:e.jsx("path",{d:"m13.3 17.3-4.6-4.6a.9.9 0 0 1-.213-.325A1.1 1.1 0 0 1 8.425 12q0-.2.062-.375A.9.9 0 0 1 8.7 11.3l4.6-4.6a.95.95 0 0 1 .7-.275q.425 0 .7.275a.95.95 0 0 1 .275.7.95.95 0 0 1-.275.7L10.8 12l3.9 3.9a.95.95 0 0 1 .275.7.95.95 0 0 1-.275.7.95.95 0 0 1-.7.275.95.95 0 0 1-.7-.275"})})}C.displayName="ChevronLeftIcon";const he=A.forwardRef(C),me="_header_1crjt_8",xe="_back-button_1crjt_16",I={header:me,backButton:xe},y=({children:r,...s})=>e.jsxs("header",{className:I.header,children:[e.jsx(q,{className:I.backButton,...s,children:e.jsx(he,{})}),e.jsx(X,{children:r})]}),ue=m(`
  fragment BrowserSession_detail on BrowserSession {
    id
    createdAt
    finishedAt
    ...EndBrowserSessionButton_session
    userAgent {
      name
      model
      os
    }
    lastActiveIp
    lastActiveAt
    lastAuthentication {
      id
      createdAt
    }
    user {
      id
      username
    }
  }
`),je=({session:r,isCurrent:s})=>{const n=v(ue,r),{t:o}=_();let l=o("frontend.session.generic_browser_session");return n.userAgent&&(n.userAgent.model&&n.userAgent.name?l=o("frontend.session.name_for_platform",{name:n.userAgent.name,platform:n.userAgent.model}):n.userAgent.name&&n.userAgent.os?l=o("frontend.session.name_for_platform",{name:n.userAgent.name,platform:n.userAgent.os}):n.userAgent.name&&(l=n.userAgent.name)),e.jsxs("div",{className:"flex flex-col gap-10",children:[s&&e.jsx(J,{className:"self-start",kind:"green",children:o("frontend.browser_session_details.current_badge")}),e.jsx(y,{to:"/sessions/browsers",children:l}),e.jsxs(j,{children:[e.jsx(f,{children:o("frontend.session.title")}),e.jsxs(p,{children:[n.lastActiveAt&&e.jsxs(i,{children:[e.jsx(t,{children:o("frontend.session.last_active_label")}),e.jsx(a,{children:e.jsx(N,{lastActive:b(n.lastActiveAt)})})]}),e.jsxs(i,{children:[e.jsx(t,{children:o("frontend.session.signed_in_label")}),e.jsx(a,{children:e.jsx(h,{datetime:n.createdAt})})]}),n.finishedAt&&e.jsxs(i,{children:[e.jsx(t,{children:o("frontend.session.finished_label")}),e.jsx(a,{children:e.jsx(h,{datetime:n.finishedAt})})]}),n.lastActiveIp&&e.jsxs(i,{children:[e.jsx(t,{children:o("frontend.session.ip_label")}),e.jsx(a,{children:e.jsx("code",{children:n.lastActiveIp})})]})]})]}),!n.finishedAt&&e.jsx(W,{session:n,size:"lg"})]})},fe=A.forwardRef(({label:r,...s},n)=>e.jsx(z,{label:r,children:e.jsx(H,{ref:n,type:"button",size:"var(--cpd-space-6x)",style:{marginInline:"var(--cpd-space-2x)"},...s,children:e.jsx(le,{})})})),E=({mutation:r,deviceName:s})=>{const{t:n}=_(),o=A.useRef(null),[l,c]=A.useState(!1),x=async d=>{d.preventDefault();const u=d.currentTarget,B=new FormData(u).get("name");await r.mutateAsync(B),c(!1)};return e.jsxs(L,{trigger:e.jsx(fe,{label:n("action.edit")}),open:l,onOpenChange:d=>{o.current?.form?.reset(),c(d)},children:[e.jsx(O,{children:n("frontend.session.set_device_name.title")}),e.jsx(T,{asChild:!0,children:e.jsxs(U,{onSubmit:x,children:[e.jsxs($,{name:"name",children:[e.jsx(R,{children:n("frontend.session.set_device_name.label")}),e.jsx(k,{type:"text",required:!0,defaultValue:s,ref:o}),e.jsx(F,{children:n("frontend.session.set_device_name.help")})]}),e.jsxs(de,{disabled:r.isPending,children:[r.isPending&&e.jsx(M,{inline:!0}),n("action.save")]})]})}),e.jsx(Q,{asChild:!0,children:e.jsx(V,{kind:"tertiary",children:n("action.cancel")})})]})},pe=m(`
  mutation SetCompatSessionName($sessionId: ID!, $displayName: String!) {
    setCompatSessionName(input: { compatSessionId: $sessionId, humanName: $displayName }) {
      status
    }
  }
`),Ae=m(`
  fragment CompatSession_detail on CompatSession {
    id
    createdAt
    deviceId
    finishedAt
    lastActiveIp
    lastActiveAt
    humanName

    ...EndCompatSessionButton_session

    userAgent {
      name
      os
      model
    }

    ssoLogin {
      id
      redirectUri
    }
  }
`),_e=({session:r})=>{const s=v(Ae,r),{t:n}=_(),o=w(),l=D({mutationFn:u=>S({query:pe,variables:{sessionId:s.id,displayName:u}}),onSuccess:()=>{o.invalidateQueries({queryKey:["sessionDetail",s.id]}),o.invalidateQueries({queryKey:["sessionsOverview"]})}}),c=s.userAgent?.model??(s.userAgent?.name?s.userAgent?.os?n("frontend.session.name_for_platform",{name:s.userAgent.name,platform:s.userAgent.os}):s.userAgent.name:n("frontend.session.unknown_device")),x=s.ssoLogin?.redirectUri?te(s.ssoLogin.redirectUri):s.deviceId||s.id,d=s.humanName??`${x}: ${c}`;return e.jsxs("div",{className:"flex flex-col gap-10",children:[e.jsxs(y,{to:"/sessions",children:[d,e.jsx(E,{mutation:l,deviceName:d})]}),e.jsxs(j,{children:[e.jsx(f,{children:n("frontend.session.title")}),e.jsxs(p,{children:[s.lastActiveAt&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.last_active_label")}),e.jsx(a,{children:e.jsx(N,{lastActive:b(s.lastActiveAt)})})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.signed_in_label")}),e.jsx(a,{children:e.jsx(h,{datetime:s.createdAt})})]}),s.finishedAt&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.finished_label")}),e.jsx(a,{children:e.jsx(h,{datetime:s.finishedAt})})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.device_id_label")}),e.jsx(a,{children:s.deviceId})]}),s.lastActiveIp&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.ip_label")}),e.jsx(a,{children:e.jsx("code",{children:s.lastActiveIp})})]})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.scopes_label")}),e.jsxs(ie,{className:"mt-1",children:[e.jsx(Z,{}),e.jsx(ee,{}),e.jsx(se,{})]})]})]}),e.jsxs(j,{children:[e.jsx(f,{children:n("frontend.compat_session_detail.client_details_title")}),e.jsxs(p,{children:[e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.compat_session_detail.name")}),e.jsx(a,{children:c})]}),s.ssoLogin&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.uri_label")}),e.jsx(a,{children:s.ssoLogin?.redirectUri})]})]})]}),!s.finishedAt&&e.jsx(re,{session:s,size:"lg"})]})},ge=m(`
  mutation SetOAuth2SessionName($sessionId: ID!, $displayName: String!) {
    setOauth2SessionName(input: { oauth2SessionId: $sessionId, humanName: $displayName }) {
      status
    }
  }
`),ve=m(`
  fragment OAuth2Session_detail on Oauth2Session {
    id
    scope
    createdAt
    finishedAt
    lastActiveIp
    lastActiveAt
    humanName

    ...EndOAuth2SessionButton_session

    userAgent {
      name
      model
      os
    }

    client {
      id
      clientId
      clientName
      clientUri
      logoUri
    }
  }
`),Se=({session:r})=>{const s=v(ve,r),{t:n}=_(),o=w(),l=D({mutationFn:u=>S({query:ge,variables:{sessionId:s.id,displayName:u}}),onSuccess:()=>{o.invalidateQueries({queryKey:["sessionDetail",s.id]}),o.invalidateQueries({queryKey:["sessionsOverview"]})}}),c=ae(s.scope),x=s.client.clientName||s.client.clientId,d=s.humanName??s.userAgent?.model??(s.userAgent?.name?s.userAgent?.os?n("frontend.session.name_for_platform",{name:s.userAgent.name,platform:s.userAgent.os}):s.userAgent.name:n("frontend.session.unknown_device"));return e.jsxs("div",{className:"flex flex-col gap-10",children:[e.jsxs(y,{to:"/sessions",children:[x,": ",d,e.jsx(E,{mutation:l,deviceName:d})]}),e.jsxs(j,{children:[e.jsx(f,{children:n("frontend.session.title")}),e.jsxs(p,{children:[s.lastActiveAt&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.last_active_label")}),e.jsx(a,{children:e.jsx(N,{lastActive:b(s.lastActiveAt)})})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.signed_in_label")}),e.jsx(a,{children:e.jsx(h,{datetime:s.createdAt})})]}),s.finishedAt&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.finished_label")}),e.jsx(a,{children:e.jsx(h,{datetime:s.finishedAt})})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.device_id_label")}),e.jsx(a,{children:c})]}),s.lastActiveIp&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.ip_label")}),e.jsx(a,{children:e.jsx("code",{children:s.lastActiveIp})})]})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.scopes_label")}),e.jsx(ne,{scope:s.scope})]})]}),e.jsxs(j,{children:[e.jsx(f,{children:n("frontend.oauth2_session_detail.client_title")}),e.jsxs(p,{children:[e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.oauth2_session_detail.client_details_name")}),e.jsxs(a,{children:[e.jsx(ce,{name:s.client.clientName||s.client.clientId,logoUri:s.client.logoUri||void 0,size:"var(--cpd-space-4x)"}),s.client.clientName]})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.client_id_label")}),e.jsx(a,{children:e.jsx("code",{children:s.client.clientId})})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.uri_label")}),e.jsx(a,{children:e.jsx("a",{target:"_blank",rel:"noreferrer",href:s.client.clientUri||void 0,children:s.client.clientUri})})]})]})]}),!s.finishedAt&&e.jsx(oe,{session:s,size:"lg"})]})},Ne=m(`
  query SessionDetail($id: ID!) {
    viewerSession {
      ... on Node {
        id
      }
    }

    node(id: $id) {
      __typename
      id
      ...CompatSession_detail
      ...OAuth2Session_detail
      ...BrowserSession_detail
    }
  }
`),be=r=>G({queryKey:["sessionDetail",r],queryFn:({signal:s})=>S({query:Ne,signal:s,variables:{id:r}})});function ke(){const{id:r}=K.useParams(),{data:{node:s,viewerSession:n}}=P(be(r));if(!s)throw Y();switch(s.__typename){case"CompatSession":return e.jsx(g,{wide:!0,children:e.jsx(_e,{session:s})});case"Oauth2Session":return e.jsx(g,{wide:!0,children:e.jsx(Se,{session:s})});case"BrowserSession":return e.jsx(g,{wide:!0,children:e.jsx(je,{session:s,isCurrent:s.id===n.id})});default:throw new Error("Unknown session type")}}export{ke as component};
//# sourceMappingURL=sessions._id-DFuGujwY.js.map
