import{u as v,j as s,b as p,l as A,T as I,al as O,p as x,am as U,s as _,an as C,ao as L,ap as k}from"./main-Bn3jZxQW.js";import{c as B,b as F}from"./Heading-BPu-MP59.js";import{B as h}from"./ButtonLink-DaMceLGU.js";import{s as R,E as M,g as D,a as P}from"./EndOAuth2SessionButton-BPcopEj_.js";import{b as $,F as z,E as G}from"./Filter-CQaawBwk.js";import{p as m,L as g,D as j}from"./LastActive-CcqY2swy.js";import{R as w,L as b,H as S,N as y,C as N,M as T,I as d,A as E}from"./EndBrowserSessionButton-Dh2DNyLt.js";import{S as H}from"./Separator-CmDle60m.js";import{L as W}from"./Link-fOYvBiI0.js";import"./_commonjsHelpers-DaWZu8wl.js";/* empty css               */import"./computer-BhmLSpYt.js";const K=A(`
  fragment CompatSession_session on CompatSession {
    id
    createdAt
    deviceId
    finishedAt
    lastActiveIp
    lastActiveAt
    humanName
    ...EndCompatSessionButton_session
    userAgent {
      name
      os
      model
      deviceType
    }
    ssoLogin {
      id
      redirectUri
    }
  }
`),q=({session:t})=>{const{t:n}=v(),e=p(K,t),o=e.humanName??(e.ssoLogin?.redirectUri?R(e.ssoLogin.redirectUri):void 0),c=e.userAgent?.deviceType??"UNKNOWN",i=e.userAgent?.model??(e.userAgent?.name?e.userAgent?.os?n("frontend.session.name_for_platform",{name:e.userAgent.name,platform:e.userAgent.os}):e.userAgent.name:n("frontend.session.unknown_device")),a=m(e.createdAt),r=e.lastActiveAt?m(e.lastActiveAt):void 0;return s.jsxs(w,{children:[s.jsxs(b,{to:"/sessions/$id",params:{id:e.id},disabled:!!e.finishedAt,children:[s.jsxs(S,{type:c,children:[s.jsx(y,{name:i}),o&&s.jsx(N,{name:o,logoUri:$(e.userAgent?.name??void 0)})]}),s.jsxs(T,{children:[r&&s.jsx(d,{label:n("frontend.session.last_active_label"),children:s.jsx(g,{lastActive:r})}),s.jsx(d,{label:n("frontend.session.signed_in_label"),children:s.jsx(j,{datetime:a})}),s.jsx(d,{label:n("frontend.session.device_id_label"),children:e.deviceId})]})]}),!e.finishedAt&&s.jsx(E,{children:s.jsx(M,{session:e,size:"sm"})})]})},Q=A(`
  fragment OAuth2Session_session on Oauth2Session {
    id
    scope
    createdAt
    finishedAt
    lastActiveIp
    lastActiveAt
    humanName

    ...EndOAuth2SessionButton_session

    userAgent {
      name
      model
      os
      deviceType
    }

    client {
      id
      clientId
      clientName
      applicationType
      logoUri
    }
  }
`),V=t=>t==="WEB"?"PC":t==="NATIVE"?"MOBILE":"UNKNOWN",Z=({session:t})=>{const{t:n}=v(),e=p(Q,t),o=D(e.scope),c=m(e.createdAt),i=e.lastActiveAt?m(e.lastActiveAt):void 0,a=(e.userAgent?.deviceType==="UNKNOWN"?null:e.userAgent?.deviceType)??V(e.client.applicationType),r=e.client.clientName||e.client.clientId,u=e.humanName??e.userAgent?.model??(e.userAgent?.name?e.userAgent?.os?n("frontend.session.name_for_platform",{name:e.userAgent.name,platform:e.userAgent.os}):e.userAgent.name:n("frontend.session.unknown_device"));return s.jsxs(w,{children:[s.jsxs(b,{to:"/sessions/$id",params:{id:e.id},disabled:!!e.finishedAt,children:[s.jsxs(S,{type:a,children:[s.jsx(y,{name:u}),s.jsx(N,{name:r,logoUri:e.client.logoUri??void 0})]}),s.jsxs(T,{children:[i&&s.jsx(d,{label:n("frontend.session.last_active_label"),children:s.jsx(g,{lastActive:i})}),s.jsx(d,{label:n("frontend.session.signed_in_label"),children:s.jsx(j,{datetime:c})}),o&&s.jsx(d,{label:n("frontend.session.device_id_label"),children:o})]})]}),!e.finishedAt&&s.jsx(E,{children:s.jsx(P,{session:e,size:"sm"})})]})},J="_browser-sessions-overview_xlk0o_8",X={browserSessionsOverview:J},Y=A(`
  fragment BrowserSessionsOverview_user on User {
    id

    browserSessions(first: 0, state: ACTIVE) {
      totalCount
    }
  }
`),ee=({user:t})=>{const n=p(Y,t),{t:e}=v();return s.jsxs("div",{className:X.browserSessionsOverview,children:[s.jsxs("div",{className:"flex flex-1 flex-col",children:[s.jsx(B,{children:e("frontend.browser_sessions_overview.heading")}),s.jsx(I,{children:e("frontend.browser_sessions_overview.body",{count:n.browserSessions.totalCount})})]}),s.jsx(W,{to:"/sessions/browsers",children:e("frontend.browser_sessions_overview.view_all_button")})]})},se=t=>{throw new Error(`Unknown session type: ${t}`)};function pe(){const{t}=v(),{inactive:n,pagination:e}=O.useLoaderDeps(),{data:{viewer:o}}=x(U);if(o.__typename!=="User")throw _();const{data:c}=x(C(e,n));if(c.viewer.__typename!=="User")throw _();const i=c.viewer.appSessions,[a,r]=L(e,i.pageInfo,k),u=[...i.edges].reverse();return s.jsxs("div",{className:"flex flex-col gap-6",children:[s.jsx(F,{children:t("frontend.user_sessions_overview.heading")}),s.jsx(ee,{user:o}),s.jsx(H,{kind:"section"}),s.jsx("div",{className:"flex gap-2 justify-start items-center",children:s.jsx(z,{to:"/sessions",enabled:n,search:{inactive:n?void 0:!0},children:t("frontend.last_active.inactive_90_days")})}),u.map(l=>{const f=l.node.__typename;switch(f){case"Oauth2Session":return s.jsx(Z,{session:l.node},l.cursor);case"CompatSession":return s.jsx(q,{session:l.node},l.cursor);default:return se(f)}}),i.totalCount===0&&s.jsx(G,{children:t(n?"frontend.user_sessions_overview.no_active_sessions.inactive_90_days":"frontend.user_sessions_overview.no_active_sessions.default")}),(r||a)&&s.jsxs("div",{className:"flex *:flex-1",children:[s.jsx(h,{kind:"secondary",size:"sm",disabled:!r,to:"/sessions",search:{inactive:n,...r||e},resetScroll:!0,children:t("common.previous")}),s.jsx("div",{}),s.jsx(h,{kind:"secondary",size:"sm",disabled:!a,to:"/sessions",search:{inactive:n,...a||e},resetScroll:!0,children:t("common.next")})]})]})}export{pe as component};
//# sourceMappingURL=_account.sessions.index-L1DyUn9O.js.map
