import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import{memo,useCallback}from"react";import{useAtomValue}from"jotai";import styled from"styled-components";import{DownloadIcon,DocumentIcon,JsonIcon,Button,FileIcon,getPathPrefix,combineUrls}from"@redocly/theme";import{useDownloadInfo}from"./useDownloadInfo";import{globalStoreAtom}from"../../jotai/store";import{useOtelTelemetry}from"../../hooks";function DownloadSpecificationComponent(){const e=useOtelTelemetry(),{options:o}=useAtomValue(globalStoreAtom),t=getPathPrefix(),n=useDownloadInfo({downloadUrls:o.downloadUrls}),r=useCallback((e=>{switch(e){case"yaml":return _jsx(DocumentIcon,{});case"json":return _jsx(JsonIcon,{});default:return _jsx(FileIcon,{})}}),[]);return n?_jsx(Wrapper,{children:(n||[]).map((({title:o,url:n,iconType:a})=>{const s=t?combineUrls(t,n):n;return _jsxs(Card,{onClick:()=>e.send({type:"openapi_docs.download_definition.clicked"}),children:[_jsxs(FileName,{children:[r(a),_jsx("a",{href:s,target:"_blank",download:!0,rel:"noreferrer",children:o})]}),_jsx("a",{href:s,target:"_blank",download:!0,rel:"noreferrer",children:_jsx(Button,{variant:"text",size:"small",icon:_jsx(DownloadIcon,{})})})]},o)}))}):_jsx(_Fragment,{})}export const DownloadSpecification=memo(DownloadSpecificationComponent);const Card=styled.div`
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;

  border-bottom: 1px solid var(--border-color-secondary);
  padding-bottom: var(--spacing-sm);
  :last-of-type {
    padding-bottom: 0px;
    border-bottom: none;
  }
`,FileName=styled.span`
  display: flex;
  width: calc(100% - 25px);
  gap: var(--spacing-xs);
  align-items: center;

  svg {
    flex-shrink: 0;
  }
  a {
    width: 100%;
    color: var(--text-color-primary);
    word-break: break-word;
    text-decoration: none;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
  }
`,Wrapper=styled.div`
  display: flex;
  align-items: center;
  align-self: flex-start;
  justify-content: space-between;
  flex-direction: column;
  gap: var(--spacing-sm);
  font-size: var(--font-size-base);
`;
//# sourceMappingURL=DownloadSpecification.js.map