import{r as A,j as e,a as q,u as _,b as v,k as m,D as L,e as O,R as T,F as U,f as $,g as R,H as k,h as F,i as M,B as Q,m as V,n as z,c as w,d as D,l as S,a5 as H,o as K,q as P,p as G,L as g}from"./main-CiAhdYQG.js";import{B as Y,L as N,p as b,D as h}from"./LastActive-D4SP35FS.js";import{E as J}from"./EndBrowserSessionButton-DXsnVcVV.js";import{b as W}from"./Heading-zTQC9Kqs.js";import{D as j,a as f,b as p,c as i,d as t,e as r,S as X,f as Z,g as ee,h as se}from"./SessionInfo-BtmlaGNW.js";import{V as ne}from"./VisualListItem-Dd-weqBc.js";import{s as ie,E as te,g as ae,a as re}from"./EndOAuth2SessionButton-CPWjVtc_.js";import{I as oe}from"./edit-DvN6hAeY.js";import{S as le}from"./Submit-DW2aiKTW.js";import{C as de}from"./computer-Cx9wZ7Nf.js";import"./_commonjsHelpers-DaWZu8wl.js";/* empty css               */import"./Separator-CVNE-7yB.js";function E(a,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,...a,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"})})}E.displayName="ChevronLeftIcon";const ce=A.forwardRef(E),he="_header_1crjt_8",me="_back-button_1crjt_16",I={header:he,backButton:me},y=({children:a,...s})=>e.jsxs("header",{className:I.header,children:[e.jsx(q,{className:I.backButton,...s,children:e.jsx(ce,{})}),e.jsx(W,{children:a})]}),xe=m(`
  fragment BrowserSession_detail on BrowserSession {
    id
    createdAt
    finishedAt
    ...EndBrowserSessionButton_session
    userAgent {
      name
      model
      os
    }
    lastActiveIp
    lastActiveAt
    lastAuthentication {
      id
      createdAt
    }
    user {
      id
      username
    }
  }
`),ue=({session:a,isCurrent:s})=>{const n=v(xe,a),{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(Y,{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(r,{children:e.jsx(N,{lastActive:b(n.lastActiveAt)})})]}),e.jsxs(i,{children:[e.jsx(t,{children:o("frontend.session.signed_in_label")}),e.jsx(r,{children:e.jsx(h,{datetime:n.createdAt})})]}),n.finishedAt&&e.jsxs(i,{children:[e.jsx(t,{children:o("frontend.session.finished_label")}),e.jsx(r,{children:e.jsx(h,{datetime:n.finishedAt})})]}),n.lastActiveIp&&e.jsxs(i,{children:[e.jsx(t,{children:o("frontend.session.ip_label")}),e.jsx(r,{children:e.jsx("code",{children:n.lastActiveIp})})]})]})]}),!n.finishedAt&&e.jsx(J,{session:n,size:"lg"})]})},je=A.forwardRef(({label:a,...s},n)=>e.jsx(V,{label:a,children:e.jsx(z,{ref:n,type:"button",size:"var(--cpd-space-6x)",style:{marginInline:"var(--cpd-space-2x)"},...s,children:e.jsx(oe,{})})})),B=({mutation:a,deviceName:s})=>{const{t:n}=_(),o=A.useRef(null),[l,c]=A.useState(!1),x=async d=>{d.preventDefault();const u=d.currentTarget,C=new FormData(u).get("name");await a.mutateAsync(C),c(!1)};return e.jsxs(L,{trigger:e.jsx(je,{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.jsxs(T,{onSubmit:x,children:[e.jsxs(U,{name:"name",children:[e.jsx($,{children:n("frontend.session.set_device_name.label")}),e.jsx(R,{type:"text",required:!0,defaultValue:s,ref:o}),e.jsx(k,{children:n("frontend.session.set_device_name.help")})]}),e.jsxs(le,{disabled:a.isPending,children:[a.isPending&&e.jsx(F,{inline:!0}),n("action.save")]})]}),e.jsx(M,{asChild:!0,children:e.jsx(Q,{kind:"tertiary",children:n("action.cancel")})})]})},fe=m(`
  mutation SetCompatSessionName($sessionId: ID!, $displayName: String!) {
    setCompatSessionName(input: { compatSessionId: $sessionId, humanName: $displayName }) {
      status
    }
  }
`),pe=m(`
  fragment CompatSession_detail on CompatSession {
    id
    createdAt
    deviceId
    finishedAt
    lastActiveIp
    lastActiveAt
    humanName

    ...EndCompatSessionButton_session

    userAgent {
      name
      os
      model
    }

    ssoLogin {
      id
      redirectUri
    }
  }
`),Ae=({session:a})=>{const s=v(pe,a),{t:n}=_(),o=w(),l=D({mutationFn:u=>S({query:fe,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?ie(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(B,{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(r,{children:e.jsx(N,{lastActive:b(s.lastActiveAt)})})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.signed_in_label")}),e.jsx(r,{children:e.jsx(h,{datetime:s.createdAt})})]}),s.finishedAt&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.finished_label")}),e.jsx(r,{children:e.jsx(h,{datetime:s.finishedAt})})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.device_id_label")}),e.jsx(r,{children:s.deviceId})]}),s.lastActiveIp&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.ip_label")}),e.jsx(r,{children:e.jsx("code",{children:s.lastActiveIp})})]})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.scopes_label")}),e.jsxs(ne,{className:"mt-1",children:[e.jsx(X,{}),e.jsx(Z,{}),e.jsx(ee,{})]})]})]}),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(r,{children:c})]}),s.ssoLogin&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.uri_label")}),e.jsx(r,{children:s.ssoLogin?.redirectUri})]})]})]}),!s.finishedAt&&e.jsx(te,{session:s,size:"lg"})]})},_e=m(`
  mutation SetOAuth2SessionName($sessionId: ID!, $displayName: String!) {
    setOauth2SessionName(input: { oauth2SessionId: $sessionId, humanName: $displayName }) {
      status
    }
  }
`),ge=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
    }
  }
`),ve=({session:a})=>{const s=v(ge,a),{t:n}=_(),o=w(),l=D({mutationFn:u=>S({query:_e,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(B,{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(r,{children:e.jsx(N,{lastActive:b(s.lastActiveAt)})})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.signed_in_label")}),e.jsx(r,{children:e.jsx(h,{datetime:s.createdAt})})]}),s.finishedAt&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.finished_label")}),e.jsx(r,{children:e.jsx(h,{datetime:s.finishedAt})})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.device_id_label")}),e.jsx(r,{children:c})]}),s.lastActiveIp&&e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.ip_label")}),e.jsx(r,{children:e.jsx("code",{children:s.lastActiveIp})})]})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.scopes_label")}),e.jsx(se,{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(r,{children:[e.jsx(de,{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(r,{children:e.jsx("code",{children:s.client.clientId})})]}),e.jsxs(i,{children:[e.jsx(t,{children:n("frontend.session.uri_label")}),e.jsx(r,{children:e.jsx("a",{target:"_blank",rel:"noreferrer",href:s.client.clientUri||void 0,children:s.client.clientUri})})]})]})]}),!s.finishedAt&&e.jsx(re,{session:s,size:"lg"})]})},Se=m(`
  query SessionDetail($id: ID!) {
    viewerSession {
      ... on Node {
        id
      }
    }

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