import{jsx as _jsx,jsxs as _jsxs}from"react/jsx-runtime";import{Fragment,useState,useRef}from"react";import styled from"styled-components";import{useOutsideClick,Typography,CloseIcon,SecurityIcon,Segmented,Button,useFocusTrap}from"@redocly/theme";import{SecurityFlow}from"./SecurityFlow";import{Divider}from"./Divider";export function SecurityModal({securities:e,onClose:t}){const[s,i]=useState(0),o=useRef(null),{schemes:r}=e[s]||{};useOutsideClick(o,t),useFocusTrap(o);const a=e.map((({schemes:e},t)=>({label:e.map((({id:e})=>e)).join(" and "),value:t})));return _jsx(StyledBackground,{children:_jsxs(Wrapper,{ref:o,tabIndex:0,children:[_jsx(Close,{onClick:t,"data-testid":"close",variant:"ghost",icon:_jsx(CloseIcon,{})}),_jsxs(Title,{children:[_jsx(SecurityIcon,{size:"24px"}),"Security"]}),_jsx(Segmented,{value:s,onChange:({value:e})=>i(e),options:a}),r.map(((t,s)=>_jsxs(Fragment,{children:[_jsx(SecurityFlow,Object.assign({},t,{securities:e})),s!==r.length-1&&_jsx(Divider,{label:"and"})]},t.id)))]})})}const Wrapper=styled.div`
  background: var(--bg-color);
  box-shadow: var(--bg-raised-shadow);
  border-radius: var(--border-radius-lg);
  padding: var(--spacing-lg);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  position: absolute;
  width: 720px;
  max-width: 100%;
  height: auto;
  max-height: 600px;
  overflow-y: scroll;
  left: 50%;
  top: 100px;
  transform: translateX(-50%);
  .tag-grey span {
    font-size: var(--font-size-base);
    line-height: var(--line-height-base);
  }
`,StyledBackground=styled.div`
  background: var(--bg-color-modal-overlay);
  position: fixed;
  width: 100vw;
  height: 100vh;
  z-index: var(--z-index-popover);
  left: 0;
  top: 0;
  pointer-events: auto;
`,Close=styled(Button)`
  position: absolute;
  right: var(--spacing-md);
  top: var(--spacing-md);
`,Title=styled(Typography)`
  display: flex;
  align-items: center;
  font-size: var(--h4-font-size);
  font-weight: var(--h4-font-weight);
  margin-bottom: var(--spacing-lg);
  svg {
    margin-right: var(--spacing-xs);
  }
`;
//# sourceMappingURL=SecurityModal.js.map