import{jsx as e,Fragment as m,jsxs as s}from"react/jsx-runtime";import{memo as p,useCallback as f}from"react";import{getPathPrefix as w,combineUrls as x}from"@redocly/theme/core/openapi";import{DocumentIcon as g}from"@redocly/theme/icons/DocumentIcon/DocumentIcon";import{JsonIcon as b}from"@redocly/theme/icons/JsonIcon/JsonIcon";import{FileIcon as h}from"@redocly/theme/icons/FileIcon/FileIcon";import{DownloadButton as u}from"@redocly/theme/components/Buttons/DownloadButton";import{transformStringToTelemetryId as y}from"../../utils/helpers.js";import{useTelemetry as v}from"../../hooks/index.js";import{styled as n}from"../../styled-components.js";function j({downloadObjects:t}){const c=v(),i=w(),l=f(o=>{switch(o){case"yaml":return e(g,{});case"json":return e(b,{});default:return e(h,{})}},[]);return t?e(C,{children:(t||[]).map(({title:o,url:a,iconType:d})=>{const r=i?x(i,a):a;return s(k,{onClick:()=>{c.sendDownloadDefinitionClickedMessage([{id:y("definition",window.location.hostname,o),object:"definition",uri:new URL(r,window.location.origin).href}])},children:[s(D,{children:[l(d),e("a",{href:r,target:"_blank",download:!0,rel:"noreferrer",children:o})]}),e(u,{data:r})]},o)})}):e(m,{})}const L=p(j),k=n.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;
  }
`,D=n.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;
  }
`,C=n.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);
`;export{L as DownloadSpecification};
