import{jsx as e,jsxs as n,Fragment as x}from"react/jsx-runtime";import{memo as u}from"react";import{useAtom as b}from"jotai";import{LinkIcon as w}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{Dropdown as M}from"../Dropdown/index.js";import{RequiredLabel as T}from"../Fields/index.js";import{ConstraintsView as j}from"../ConstraintsView.js";import{Schema as k}from"../../Schema/index.js";import{getActiveMediaType as C}from"../../../models/index.js";import{Markdown as z}from"../../Markdown/index.js";import{activeMimeNameAtom as A}from"../../../jotai/app.js";import{LinkToField as q}from"../LinkToField.js";import{useTranslate as B}from"../../../hooks/index.js";import{styled as s}from"../../../styled-components.js";function F({required:m,skipReadOnly:p,skipWriteOnly:l,description:c,content:t,deepLink:r}){const a=B(),[g,f]=b(A);if(!t)return null;const{schema:i,examples:d,operation:h,name:v}=C(t,g),y=t.mediaTypes.map(({name:o})=>({label:o,value:o}));return n(x,{children:[n(O,{children:[r&&e(q,{to:r}),a("openapi.body","Body"),e(M,{options:y,value:v,triggerVariant:"ghost",triggerSize:"large",onChange:({value:o})=>f(o)})]}),m&&e(T,{children:a("openapi.badges.required","required")}),e(N,{source:c}),i?.type==="object"&&i?.constraints&&e(j,{constraints:i?.constraints||[]}),e(k,{skipReadOnly:p,skipWriteOnly:l,schema:i,examples:d,operation:h,level:1,disableDeepLinks:!r},"schema")]})}const P=u(F),N=s(z)`
  margin: var(--spacing-xxs) 0 0;
`,O=s.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 {
    ${w} {
      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);
  }
`;export{P as BodyContent};
