import{jsx as e,jsxs as r,Fragment as p}from"react/jsx-runtime";import{Badge as z}from"@redocly/theme/components/Badge/Badge";import{SecuritySchemeItem as n}from"./SecuritySchemeItem.js";import{titleize as A}from"../../utils/index.js";import{OAuthFlow as L}from"./OAuthFlow.js";import{StyledLink as v,Tag as O}from"./styled.js";import{Markdown as _}from"../Markdown/index.js";import{useTranslate as w}from"../../hooks/index.js";import{OAuthScopes as b}from"./OAuthScopes.js";import{styled as o}from"../../styled-components.js";import{RequiredScopesList as g}from"./RequiredScopesList.js";const j=["authorizationCode","clientCredentials","implicit","password","deviceAuthorization"];function k({flowType:l,flow:m,schemeId:h,securities:a}){const c=w();return r(p,{children:[e(n,{label:r(H,{className:"tag-grey",children:[e(N,{children:c("openapi.flowType","Flow type")})," ",e(P,{children:l})]}),value:e("span",{})}),r(C,{children:[e(L,{flow:m}),e(b,{id:h,securities:a,flow:m})]})]})}function V({type:l,bearerFormat:m,name:h,flows:a,openIdConnectUrl:c,description:y,id:t,securities:s,in:x,deprecated:T=!1,oauth2MetadataUrl:f}){const i=w();if(!l||!t)return null;const F={http:r(p,{children:[e(n,{label:i("openapi.httpAuthorizationScheme","HTTP Authorization Scheme"),value:l}),e(n,{label:i("openapi.bearerFormat","Bearer Format"),value:m}),e(g,{schemeId:t,securities:s,flows:a})]}),apiKey:r(p,{children:[e(n,{label:`${A(x||"")} ${i("openapi.parameterName","parameter name")}:`,value:h}),e(g,{schemeId:t,securities:s,flows:a})]}),oauth2:r(p,{children:[a&&Object.entries(a).filter(d=>{const[u,S]=d;return!!S&&j.includes(u)}).map(([d,u])=>e(k,{flowType:d,flow:u,schemeId:t,securities:s},d)),e(b,{id:t,securities:s,flows:a})]}),openIdConnect:r(p,{children:[e(n,{label:i("openapi.connectUrl","Connect URL"),value:c&&e(v,{target:"_blank",rel:"noopener noreferrer",href:c,children:c})}),e(g,{schemeId:t,securities:s,flows:a})]})};return r(W,{children:[r(I,{children:[e(R,{children:t}),T&&e(z,{deprecated:!0,children:i("openapi.badges.deprecated","Deprecated")})]}),e(_,{source:y}),f&&e(n,{label:i("openapi.oauth2MetadataUrl","OAuth2 Metadata URL"),value:e(v,{target:"_blank",rel:"noopener noreferrer",href:f,children:f})}),e(B,{children:F[l]||null})]})}const I=o.div`
  display: flex;
  align-items: center;
  gap: var(--spacing-xxs);
  margin: 0 0 var(--spacing-xs);
`,W=o.div`
  background: var(--layer-color);
  padding: var(--spacing-base);
  border-radius: var(--border-radius);
  border: 1px solid var(--border-color-secondary);
  width: 100%;
  margin-top: var(--spacing-base);
`,B=o.div`
  width: 100%;
  margin-top: var(--spacing-md);
`,R=o.p`
  font-size: var(--font-size-base);
  margin: 0;
  text-transform: capitalize;
  font-weight: var(--font-weight-semibold);
`,C=o.div`
  display: flex;
  flex-direction: column;
  padding-left: var(--spacing-xs);
  margin-bottom: var(--spacing-xxs);
`,H=o(O)`
  color: var(--color-warm-grey-8);
  font-family: var(--font-family-base);
`,N=o.span`
  font-weight: var(--font-weight-regular);
`,P=o.span`
  color: var(--color-warm-grey-11);
  font-weight: var(--font-weight-medium);
`;export{V as SecurityFlow};
