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

    userAgent {
      name
      model
      os
      deviceType
    }

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