import{n as e,r as t,t as n}from"./LastActive-DmnP-QeR.js";import{n as r,r as i,t as a}from"./Heading-B3YO_p87.js";import{A as o,Et as s,M as c,P as l,S as u,c as d,ct as f,ht as p,jt as m,kt as h,l as g,pt as _,s as v,ut as y}from"./main-ChC-SNZa.js";import{t as b}from"./Separator-BgSf8Vu2.js";import"./Separator-BRiwsd7J.js";import{t as x}from"./ButtonLink-CvJOjYPg.js";import{c as S,d as C,f as w,i as T,l as E,o as D,s as O,u as k}from"./EndBrowserSessionButton-l-4WagCS.js";import{i as A,n as j,t as M}from"./Filter-DGIc1Ww2.js";import{i as N,n as P,r as F,t as I}from"./EndOAuth2SessionButton-CyXBjTJw.js";import{t as L}from"./Link-Bz8TE6yh.js";var R=m(),z=o(`
  fragment CompatSession_session on CompatSession {
    id
    createdAt
    deviceId
    finishedAt
    lastActiveIp
    lastActiveAt
    humanName
    ...EndCompatSessionButton_session
    userAgent {
      name
      os
      model
      deviceType
    }
    ssoLogin {
      id
      redirectUri
    }
  }
`),B=({session:r})=>{let{t:i}=l(),a=c(z,r),o=a.humanName??(a.ssoLogin?.redirectUri?N(a.ssoLogin.redirectUri):void 0),s=a.userAgent?.deviceType??`UNKNOWN`,u=a.userAgent?.model??(a.userAgent?.name?a.userAgent?.os?i(`frontend.session.name_for_platform`,{name:a.userAgent.name,platform:a.userAgent.os}):a.userAgent.name:i(`frontend.session.unknown_device`)),d=t(a.createdAt),f=a.lastActiveAt?t(a.lastActiveAt):void 0;return(0,R.jsxs)(w,{children:[(0,R.jsxs)(E,{to:`/sessions/$id`,params:{id:a.id},disabled:!!a.finishedAt,children:[(0,R.jsxs)(O,{type:s,children:[(0,R.jsx)(C,{name:u}),o&&(0,R.jsx)(D,{name:o,logoUri:A(a.userAgent?.name??void 0)})]}),(0,R.jsxs)(k,{children:[f&&(0,R.jsx)(S,{label:i(`frontend.session.last_active_label`),children:(0,R.jsx)(n,{lastActive:f})}),(0,R.jsx)(S,{label:i(`frontend.session.signed_in_label`),children:(0,R.jsx)(e,{datetime:d})}),(0,R.jsx)(S,{label:i(`frontend.session.device_id_label`),children:a.deviceId})]})]}),!a.finishedAt&&(0,R.jsx)(T,{children:(0,R.jsx)(F,{session:a,size:`md`})})]})},V=o(`
  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
    }
  }
`),H=e=>e===`WEB`?`PC`:e===`NATIVE`?`MOBILE`:`UNKNOWN`,U=({session:r})=>{let{t:i}=l(),a=c(V,r),o=P(a.scope),s=t(a.createdAt),u=a.lastActiveAt?t(a.lastActiveAt):void 0,d=(a.userAgent?.deviceType===`UNKNOWN`?null:a.userAgent?.deviceType)??H(a.client.applicationType),f=a.client.clientName||a.client.clientId,p=a.humanName??a.userAgent?.model??(a.userAgent?.name?a.userAgent?.os?i(`frontend.session.name_for_platform`,{name:a.userAgent.name,platform:a.userAgent.os}):a.userAgent.name:i(`frontend.session.unknown_device`));return(0,R.jsxs)(w,{children:[(0,R.jsxs)(E,{to:`/sessions/$id`,params:{id:a.id},disabled:!!a.finishedAt,children:[(0,R.jsxs)(O,{type:d,children:[(0,R.jsx)(C,{name:p}),(0,R.jsx)(D,{name:f,logoUri:a.client.logoUri??void 0})]}),(0,R.jsxs)(k,{children:[u&&(0,R.jsx)(S,{label:i(`frontend.session.last_active_label`),children:(0,R.jsx)(n,{lastActive:u})}),(0,R.jsx)(S,{label:i(`frontend.session.signed_in_label`),children:(0,R.jsx)(e,{datetime:s})}),o&&(0,R.jsx)(S,{label:i(`frontend.session.device_id_label`),children:o})]})]}),!a.finishedAt&&(0,R.jsx)(T,{children:(0,R.jsx)(I,{session:a,size:`md`})})]})},W={browserSessionsOverview:`_browser-sessions-overview_xlk0o_8`},G=o(`
  fragment BrowserSessionsOverview_user on User {
    browserSessions(first: 0, state: ACTIVE) {
      totalCount
    }
  }
`),K=({user:e})=>{let t=c(G,e),{t:n}=l();return(0,R.jsxs)(`div`,{className:W.browserSessionsOverview,children:[(0,R.jsxs)(`div`,{className:`flex flex-1 flex-col`,children:[(0,R.jsx)(i,{children:n(`frontend.browser_sessions_overview.heading`)}),(0,R.jsx)(p,{children:n(`frontend.browser_sessions_overview.body`,{count:t.browserSessions.totalCount})})]}),(0,R.jsx)(L,{to:`/sessions/browsers`,children:n(`frontend.browser_sessions_overview.view_all_button`)})]})},q=e=>{throw Error(`Unknown session type: ${e}`)};function J(){let{t:e}=l(),{inactive:t,pagination:n}=v.useLoaderDeps(),{data:{viewer:i,siteConfig:o}}=h(g);if(i.__typename!==`User`)throw s();let{sessionLimit:c}=o,{data:p}=h(d(n,t));if(p.viewer.__typename!==`User`)throw s();let m=p.viewer.appSessions,[S,C]=u(n,m.pageInfo,6),w=[...m.edges].reverse(),T=e(`frontend.user_sessions_overview.num_sessions_header`,{count:m.totalCount});if(i.unfilteredAppSessions.totalCount!==m.totalCount){let t=e(`frontend.user_sessions_overview.num_sessions_filtered_header.unfiltered_session_total`,{count:i.unfilteredAppSessions.totalCount});T=e(`frontend.user_sessions_overview.num_sessions_filtered_header.header`,{count:m.totalCount,unfiltered_session_total:t})}let E=null;c&&(E=(0,R.jsx)(_,{label:e(`frontend.user_sessions_overview.session_limit_info`,{count:i.unfilteredAppSessions.totalCount,limit:c.softLimit}),children:(0,R.jsx)(y,{})}));let D=null;return c&&i.unfilteredAppSessions.totalCount>=c.softLimit?D=(0,R.jsx)(f,{type:`critical`,title:e(`frontend.user_sessions_overview.hit_session_limit_warning_header`),"data-testid":`device-limit-error`,children:e(`frontend.user_sessions_overview.hit_session_limit_warning_description`,{count:c.softLimit,num_sessions:i.unfilteredAppSessions.totalCount})}):c&&i.unfilteredAppSessions.totalCount>0&&i.unfilteredAppSessions.totalCount+Math.ceil(c.softLimit*.2)>=c.softLimit&&(D=(0,R.jsx)(f,{type:`info`,title:e(`frontend.user_sessions_overview.approaching_session_limit_warning_header`),"data-testid":`device-limit-warning`,children:e(`frontend.user_sessions_overview.approaching_session_limit_warning_description`,{count:c.softLimit,num_sessions:i.unfilteredAppSessions.totalCount})})),(0,R.jsxs)(`div`,{className:`flex flex-col gap-6`,children:[(0,R.jsx)(a,{children:e(`frontend.user_sessions_overview.heading`)}),(0,R.jsx)(K,{user:i}),(0,R.jsxs)(r,{className:`flex gap-1 items-center`,children:[T,E]}),(0,R.jsx)(b,{kind:`section`}),D,(0,R.jsx)(`div`,{className:`flex gap-2 justify-start items-center`,children:(0,R.jsx)(M,{to:`/sessions`,enabled:t,search:{inactive:t?void 0:!0},children:e(`frontend.last_active.inactive_90_days`)})}),w.map(e=>{let t=e.node.__typename;switch(t){case`Oauth2Session`:return(0,R.jsx)(U,{session:e.node},e.cursor);case`CompatSession`:return(0,R.jsx)(B,{session:e.node},e.cursor);default:return q(t)}}),m.totalCount===0&&(0,R.jsx)(j,{children:e(t?`frontend.user_sessions_overview.no_active_sessions.inactive_90_days`:`frontend.user_sessions_overview.no_active_sessions.default`)}),(C||S)&&(0,R.jsxs)(`div`,{className:`flex *:flex-1`,children:[(0,R.jsx)(x,{kind:`secondary`,size:`md`,disabled:!C,to:`/sessions`,search:{inactive:t,...C||n},resetScroll:!0,children:e(`common.previous`)}),(0,R.jsx)(`div`,{}),(0,R.jsx)(x,{kind:`secondary`,size:`md`,disabled:!S,to:`/sessions`,search:{inactive:t,...S||n},resetScroll:!0,children:e(`common.next`)})]})]})}export{J as component};
//# sourceMappingURL=_account.sessions.index-DCNCckE7.js.map