import{n as e}from"./chunk-DrgAwqJ9.js";import{a as t,i as n,l as r,s as i,t as a}from"./graphql-BME5mLgf.js";import{n as o,t as s}from"./LoadingSpinner-BR8GsFxa.js";import{n as c,t as l}from"./jsx-runtime-C3uB2UIS.js";import"./useStore-BnK_t0Uy.js";import{n as u}from"./not-found-D2Q6nITs.js";import{t as d}from"./link-DiTuM_g9.js";import{t as f}from"./useTranslation-DVVidJl_.js";import{t as p}from"./Tooltip-Lf-InH2_.js";import{t as m}from"./IconButton-DsXdt-tQ.js";import{i as h,n as g,r as _,t as v}from"./LastActive-c7Jpp_WC.js";import{i as ee,n as y,r as b,t as x}from"./Dialog-B7h_fmap.js";import{t as S}from"./Heading-CuKRj857.js";import{a as C,n as w,o as te,s as ne}from"./Message-C3OrPzh0.js";import{t as re}from"./Button-BZSwK8Kg.js";import{t as ie}from"./Submit-CmO9RMCD.js";import{t as T}from"./Text-S2uXnuWC.js";import{n as E}from"./VisualListItem-CR8GatM7.js";import{S as D,f as O,p as k}from"./main-BpPO1zAy.js";import"./Separator-DAu78SgA.js";import{n as A}from"./computer-BRLj38pU.js";import{t as j}from"./EndBrowserSessionButton-CfUO0PtZ.js";import{i as M,n as N,r as P,t as F}from"./EndOAuth2SessionButton-m20JHBOy.js";import{t as I}from"./edit-xsOZ1TPr.js";import{a as L,c as R,i as z,l as B,n as V,o as H,r as U,s as W,t as G,u as K}from"./SessionInfo-CtUGEAw4.js";var q=e(c(),1),J=l();function Y(e,t){return(0,J.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,width:`1em`,height:`1em`,fill:`currentColor`,viewBox:`0 0 24 24`,ref:t,...e,children:(0,J.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`})})}Y.displayName=`ChevronLeftIcon`;var ae=(0,q.forwardRef)(Y),X={header:`_header_1crjt_8`,backButton:`_back-button_1crjt_16`},Z=({children:e,...t})=>(0,J.jsxs)(`header`,{className:X.header,children:[(0,J.jsx)(d,{className:X.backButton,...t,children:(0,J.jsx)(ae,{})}),(0,J.jsx)(S,{children:e})]}),oe=n(`
  fragment BrowserSession_detail on BrowserSession {
    id
    createdAt
    finishedAt
    ...EndBrowserSessionButton_session
    userAgent {
      name
      model
      os
    }
    lastActiveIp
    lastActiveAt
    lastAuthentication {
      id
      createdAt
    }
    user {
      id
      username
    }
  }
`),se=({session:e,isCurrent:n})=>{let r=t(oe,e),{t:i}=f(),a=i(`frontend.session.generic_browser_session`);return r.userAgent&&(r.userAgent.model&&r.userAgent.name?a=i(`frontend.session.name_for_platform`,{name:r.userAgent.name,platform:r.userAgent.model}):r.userAgent.name&&r.userAgent.os?a=i(`frontend.session.name_for_platform`,{name:r.userAgent.name,platform:r.userAgent.os}):r.userAgent.name&&(a=r.userAgent.name)),(0,J.jsxs)(`div`,{className:`flex flex-col gap-10`,children:[n&&(0,J.jsx)(h,{className:`self-start`,kind:`green`,children:i(`frontend.browser_session_details.current_badge`)}),(0,J.jsx)(Z,{to:`/sessions/browsers`,children:a}),(0,J.jsxs)(z,{children:[(0,J.jsx)(L,{children:i(`frontend.session.title`)}),(0,J.jsxs)(U,{children:[r.lastActiveAt&&(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.last_active_label`)}),(0,J.jsx)(H,{children:(0,J.jsx)(v,{lastActive:_(r.lastActiveAt)})})]}),(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.signed_in_label`)}),(0,J.jsx)(H,{children:(0,J.jsx)(g,{datetime:r.createdAt})})]}),r.finishedAt&&(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.finished_label`)}),(0,J.jsx)(H,{children:(0,J.jsx)(g,{datetime:r.finishedAt})})]}),r.lastActiveIp&&(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.ip_label`)}),(0,J.jsx)(H,{children:(0,J.jsx)(`code`,{children:r.lastActiveIp})})]})]})]}),!r.finishedAt&&(0,J.jsx)(j,{session:r,size:`lg`})]})},ce=(0,q.forwardRef)(({label:e,...t},n)=>(0,J.jsx)(p,{label:e,children:(0,J.jsx)(m,{ref:n,type:`button`,size:`var(--cpd-space-6x)`,style:{marginInline:`var(--cpd-space-2x)`},...t,children:(0,J.jsx)(I,{})})})),Q=({mutation:e,deviceName:t})=>{let{t:n}=f(),r=(0,q.useRef)(null),[i,a]=(0,q.useState)(!1);return(0,J.jsxs)(x,{trigger:(0,J.jsx)(ce,{label:n(`action.edit`)}),open:i,onOpenChange:e=>{r.current?.form?.reset(),a(e)},children:[(0,J.jsx)(y,{children:n(`frontend.session.set_device_name.title`)}),(0,J.jsx)(ee,{asChild:!0,children:(0,J.jsxs)(C,{onSubmit:async t=>{t.preventDefault();let n=t.currentTarget,r=new FormData(n).get(`name`);await e.mutateAsync(r),a(!1)},children:[(0,J.jsxs)(ne,{name:`name`,children:[(0,J.jsx)(te,{children:n(`frontend.session.set_device_name.label`)}),(0,J.jsx)(T,{type:`text`,required:!0,defaultValue:t,ref:r}),(0,J.jsx)(w,{children:n(`frontend.session.set_device_name.help`)})]}),(0,J.jsxs)(ie,{disabled:e.isPending,children:[e.isPending&&(0,J.jsx)(s,{inline:!0}),n(`action.save`)]})]})}),(0,J.jsx)(b,{asChild:!0,children:(0,J.jsx)(re,{kind:`tertiary`,children:n(`action.cancel`)})})]})},le=n(`
  mutation SetCompatSessionName($sessionId: ID!, $displayName: String!) {
    setCompatSessionName(input: { compatSessionId: $sessionId, humanName: $displayName }) {
      status
    }
  }
`),$=n(`
  fragment CompatSession_detail on CompatSession {
    id
    createdAt
    deviceId
    finishedAt
    lastActiveIp
    lastActiveAt
    humanName

    ...EndCompatSessionButton_session

    userAgent {
      name
      os
      model
    }

    ssoLogin {
      id
      redirectUri
    }
  }
`),ue=({session:e})=>{let n=t($,e),{t:i}=f(),s=r(),c=o({mutationFn:e=>a({query:le,variables:{sessionId:n.id,displayName:e}}),onSuccess:()=>{s.invalidateQueries({queryKey:[`sessionDetail`,n.id]}),s.invalidateQueries({queryKey:[`sessionsOverview`]})}}),l=n.userAgent?.model??(n.userAgent?.name?n.userAgent?.os?i(`frontend.session.name_for_platform`,{name:n.userAgent.name,platform:n.userAgent.os}):n.userAgent.name:i(`frontend.session.unknown_device`)),u=n.ssoLogin?.redirectUri?M(n.ssoLogin.redirectUri):n.deviceId||n.id,d=n.humanName??`${u}: ${l}`;return(0,J.jsxs)(`div`,{className:`flex flex-col gap-10`,children:[(0,J.jsxs)(Z,{to:`/sessions`,children:[d,(0,J.jsx)(Q,{mutation:c,deviceName:d})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(L,{children:i(`frontend.session.title`)}),(0,J.jsxs)(U,{children:[n.lastActiveAt&&(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.last_active_label`)}),(0,J.jsx)(H,{children:(0,J.jsx)(v,{lastActive:_(n.lastActiveAt)})})]}),(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.signed_in_label`)}),(0,J.jsx)(H,{children:(0,J.jsx)(g,{datetime:n.createdAt})})]}),n.finishedAt&&(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.finished_label`)}),(0,J.jsx)(H,{children:(0,J.jsx)(g,{datetime:n.finishedAt})})]}),(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.device_id_label`)}),(0,J.jsx)(H,{children:n.deviceId})]}),n.lastActiveIp&&(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.ip_label`)}),(0,J.jsx)(H,{children:(0,J.jsx)(`code`,{children:n.lastActiveIp})})]})]}),(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.scopes_label`)}),(0,J.jsxs)(E,{className:`mt-1`,children:[(0,J.jsx)(K,{}),(0,J.jsx)(B,{}),(0,J.jsx)(R,{})]})]})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(L,{children:i(`frontend.compat_session_detail.client_details_title`)}),(0,J.jsxs)(U,{children:[(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.compat_session_detail.name`)}),(0,J.jsx)(H,{children:l})]}),n.ssoLogin&&(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.uri_label`)}),(0,J.jsx)(H,{children:n.ssoLogin?.redirectUri})]})]})]}),!n.finishedAt&&(0,J.jsx)(P,{session:n,size:`lg`})]})},de=n(`
  mutation SetOAuth2SessionName($sessionId: ID!, $displayName: String!) {
    setOauth2SessionName(input: { oauth2SessionId: $sessionId, humanName: $displayName }) {
      status
    }
  }
`),fe=n(`
  fragment OAuth2Session_detail on Oauth2Session {
    id
    scope
    createdAt
    finishedAt
    lastActiveIp
    lastActiveAt
    humanName

    ...EndOAuth2SessionButton_session

    userAgent {
      name
      model
      os
    }

    client {
      id
      clientId
      clientName
      clientUri
      logoUri
    }
  }
`),pe=({session:e})=>{let n=t(fe,e),{t:i}=f(),s=r(),c=o({mutationFn:e=>a({query:de,variables:{sessionId:n.id,displayName:e}}),onSuccess:()=>{s.invalidateQueries({queryKey:[`sessionDetail`,n.id]}),s.invalidateQueries({queryKey:[`sessionsOverview`]})}}),l=N(n.scope),u=n.client.clientName||n.client.clientId,d=n.humanName??n.userAgent?.model??(n.userAgent?.name?n.userAgent?.os?i(`frontend.session.name_for_platform`,{name:n.userAgent.name,platform:n.userAgent.os}):n.userAgent.name:i(`frontend.session.unknown_device`));return(0,J.jsxs)(`div`,{className:`flex flex-col gap-10`,children:[(0,J.jsxs)(Z,{to:`/sessions`,children:[u,`: `,d,(0,J.jsx)(Q,{mutation:c,deviceName:d})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(L,{children:i(`frontend.session.title`)}),(0,J.jsxs)(U,{children:[n.lastActiveAt&&(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.last_active_label`)}),(0,J.jsx)(H,{children:(0,J.jsx)(v,{lastActive:_(n.lastActiveAt)})})]}),(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.signed_in_label`)}),(0,J.jsx)(H,{children:(0,J.jsx)(g,{datetime:n.createdAt})})]}),n.finishedAt&&(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.finished_label`)}),(0,J.jsx)(H,{children:(0,J.jsx)(g,{datetime:n.finishedAt})})]}),(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.device_id_label`)}),(0,J.jsx)(H,{children:l})]}),n.lastActiveIp&&(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.ip_label`)}),(0,J.jsx)(H,{children:(0,J.jsx)(`code`,{children:n.lastActiveIp})})]})]}),(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.scopes_label`)}),(0,J.jsx)(W,{scope:n.scope})]})]}),(0,J.jsxs)(z,{children:[(0,J.jsx)(L,{children:i(`frontend.oauth2_session_detail.client_title`)}),(0,J.jsxs)(U,{children:[(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.oauth2_session_detail.client_details_name`)}),(0,J.jsxs)(H,{children:[(0,J.jsx)(A,{name:n.client.clientName||n.client.clientId,logoUri:n.client.logoUri||void 0,size:`var(--cpd-space-4x)`}),n.client.clientName]})]}),(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.client_id_label`)}),(0,J.jsx)(H,{children:(0,J.jsx)(`code`,{children:n.client.clientId})})]}),(0,J.jsxs)(G,{children:[(0,J.jsx)(V,{children:i(`frontend.session.uri_label`)}),(0,J.jsx)(H,{children:(0,J.jsx)(`a`,{target:`_blank`,rel:`noreferrer`,href:n.client.clientUri||void 0,children:n.client.clientUri})})]})]})]}),!n.finishedAt&&(0,J.jsx)(F,{session:n,size:`lg`})]})};function me(){let{id:e}=O.useParams(),{data:{node:t,viewerSession:n}}=i(k(e));if(!t)throw u();switch(t.__typename){case`CompatSession`:return(0,J.jsx)(D,{wide:!0,children:(0,J.jsx)(ue,{session:t})});case`Oauth2Session`:return(0,J.jsx)(D,{wide:!0,children:(0,J.jsx)(pe,{session:t})});case`BrowserSession`:return(0,J.jsx)(D,{wide:!0,children:(0,J.jsx)(se,{session:t,isCurrent:t.id===n.id})});default:throw Error(`Unknown session type`)}}export{me as component};
//# sourceMappingURL=sessions._id-D2AzFz6Z.js.map