import{u as l,c as p,d as S,m as g,l as r,b as y,j as t}from"./main-BiT4j4N5.js";import{a as v,B as A,H as N,N as E,C as h}from"./EndBrowserSessionButton-Di6zgty2.js";const T=s=>{let n;try{n=new URL(s)}catch{return s}return n.search="",n.hash="",n.protocol==="https:"?n.hostname:n.toString()},I=r(`
  fragment EndCompatSessionButton_session on CompatSession {
    id
    userAgent {
      name
      os
      model
      deviceType
    }
    ssoLogin {
      id
      redirectUri
    }
  }
`),f=r(`
  mutation EndCompatSession($id: ID!) {
    endCompatSession(input: { compatSessionId: $id }) {
      status
      compatSession {
        id
      }
    }
  }
`),D=({session:s,size:n})=>{const{t:i}=l(),e=y(I,s),o=p(),c=S({mutationFn:()=>g({query:f,variables:{id:e.id}}),onSuccess:m=>{o.invalidateQueries({queryKey:["sessionsOverview"]}),o.invalidateQueries({queryKey:["appSessionList"]}),o.invalidateQueries({queryKey:["sessionDetail",m.endCompatSession.compatSession?.id]})}}),a=e.ssoLogin?.redirectUri?T(e.ssoLogin.redirectUri):void 0,u=e.userAgent?.deviceType??"UNKNOWN",d=e.userAgent?.model??(e.userAgent?.name?e.userAgent?.os?i("frontend.session.name_for_platform",{name:e.userAgent.name,platform:e.userAgent.os}):e.userAgent.name:i("frontend.session.unknown_device"));return t.jsx(v,{mutation:c,size:n,children:t.jsx(A,{compact:!0,children:t.jsxs(N,{type:u,children:[t.jsx(E,{name:d}),a&&t.jsx(h,{name:a})]})})})},_="urn:matrix:org.matrix.msc2967.client:device:",x="urn:matrix:client:device:",B=s=>{const[,n]=s.split(x),[,i]=s.split(_);return n||i},O=r(`
  fragment EndOAuth2SessionButton_session on Oauth2Session {
    id

    userAgent {
      name
      model
      os
      deviceType
    }

    client {
      clientId
      clientName
      applicationType
      logoUri
    }
  }
`),C=r(`
  mutation EndOAuth2Session($id: ID!) {
    endOauth2Session(input: { oauth2SessionId: $id }) {
      status
      oauth2Session {
        id
      }
    }
  }
`),U=s=>s==="WEB"?"PC":s==="NATIVE"?"MOBILE":"UNKNOWN",F=({session:s,size:n})=>{const{t:i}=l(),e=y(O,s),o=p(),c=S({mutationFn:()=>g({query:C,variables:{id:e.id}}),onSuccess:m=>{o.invalidateQueries({queryKey:["sessionsOverview"]}),o.invalidateQueries({queryKey:["appSessionList"]}),o.invalidateQueries({queryKey:["sessionDetail",m.endOauth2Session.oauth2Session?.id]})}}),a=(e.userAgent?.deviceType==="UNKNOWN"?null:e.userAgent?.deviceType)??U(e.client.applicationType),u=e.client.clientName||e.client.clientId,d=e.userAgent?.model??(e.userAgent?.name?e.userAgent?.os?i("frontend.session.name_for_platform",{name:e.userAgent.name,platform:e.userAgent.os}):e.userAgent.name:i("frontend.session.unknown_device"));return t.jsx(v,{mutation:c,size:n,children:t.jsx(A,{compact:!0,children:t.jsxs(N,{type:a,children:[t.jsx(E,{name:d}),t.jsx(h,{name:u,logoUri:e.client.logoUri??void 0})]})})})};export{D as E,F as a,B as g,T as s};
//# sourceMappingURL=EndOAuth2SessionButton-D0rrwtbQ.js.map
