import{jsx as _jsx,jsxs as _jsxs,Fragment as _Fragment}from"react/jsx-runtime";import{memo}from"react";import styled from"styled-components";import{useAtom}from"jotai";import{LinkIcon}from"@redocly/theme";import{Dropdown}from"../Dropdown";import{RequiredLabel}from"../Fields";import{ConstraintsView}from"../ConstraintsView";import{Schema}from"../../Schema";import{getActiveMediaType}from"../../../models";import{Markdown}from"../../Markdown";import{activeMimeNameAtom}from"../../../jotai/app";import{LinkToField}from"../LinkToField";function BodyContentComponent({required:e,skipReadOnly:o,skipWriteOnly:i,description:t,content:n,deepLink:r}){const[a,s]=useAtom(activeMimeNameAtom);if(!n)return null;const{schema:m,examples:l,operation:p,name:d}=getActiveMediaType(n,a),c=n.mediaTypes.map((({name:e})=>({label:e,value:e})));return _jsxs(_Fragment,{children:[_jsxs(Title,{children:[r&&_jsx(LinkToField,{to:r}),"Body",_jsx(Dropdown,{options:c,value:d,triggerVariant:"ghost",triggerSize:"large",onChange:({value:e})=>s(e)})]}),e&&_jsx(RequiredLabel,{children:"required"}),_jsx(StyledMarkdown,{source:t}),"object"===(null==m?void 0:m.type)&&(null==m?void 0:m.constraints)&&_jsx(ConstraintsView,{constraints:(null==m?void 0:m.constraints)||[]}),_jsx(Schema,{skipReadOnly:o,skipWriteOnly:i,schema:m,examples:l,operation:p,level:1,disableDeepLinks:!r},"schema")]})}export const BodyContent=memo(BodyContentComponent);const StyledMarkdown=styled(Markdown)`
  margin: var(--spacing-xxs) 0 0;
`,Title=styled.span`
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--spacing-xxs);
  font-weight: var(--font-weight-semibold);
  color: var(--text-color-primary);
  margin-top: var(--spacing-md);
  font-size: 18px;
  line-height: var(--line-height-lg);
  padding: var(--spacing-xxs) 0;

  :hover {
    ${LinkIcon} {
      opacity: 1;
      visibility: visible;
    }
  }

  & button:not(:has(*)) {
    font-family: var(--font-family-monospaced);
    font-size: var(--font-size-sm);
    line-height: var(--line-height-lg);
  }
`;
//# sourceMappingURL=BodyContent.js.map