import{jsx as e,jsxs as s,Fragment as C}from"react/jsx-runtime";import{memo as S,useMemo as L}from"react";import{useAtomValue as N}from"jotai";import{LinkIcon as j}from"@redocly/theme/icons/LinkIcon/LinkIcon";import{RecursiveLabel as x,Tag as g,AccessLabel as q,RequiredLabel as A,StyledBadge as M,CustomBadges as R,renderBadge as y}from"../common/index.js";import{ExternalDocumentation as V}from"../ExternalDocumentation/index.js";import{Markdown as $}from"../Markdown/index.js";import{FieldDetail as m}from"./FieldDetail.js";import{Extensions as _}from"./Extensions.js";import{EnumValues as I}from"./EnumValues.js";import{Examples as O,getSerializedValue as G}from"./Examples.js";import{globalOptionsAtom as H}from"../../jotai/store.js";import{SchemaTypeInfo as n}from"./SchemaTypeInfo.js";import{LinkToField as J}from"../common/LinkToField.js";import{Pattern as K}from"./Pattern.js";import{getAccessModeLabelText as Q}from"../RenderHook/index.js";import{useTranslate as U}from"../../hooks/index.js";import{styled as i}from"../../styled-components.js";import{splitBadgesByPosition as W}from"../../utils/index.js";function X({field:a,renderDiscriminatorSwitch:v,deepLink:c,fieldParentsName:b=[]}){const t=U(),{hidePropertiesPrefix:w,hideSchemaTitles:D}=N(H),{schema:r,description:P,example:d,deprecated:B,examples:p,kind:f,required:F,name:l,badges:z}=a,E=a.in==="header",T=L(()=>{if(d!==void 0||p!==void 0){if(p!==void 0)return e(O,{field:a});{const o=!!a.in;return e(m,{label:`${t("openapi.example","Example")}:`,value:G(a,a.example),raw:o})}}else return null},[d,p,a,t]),u=Q(a.schema),{before:h,after:k}=W(z);return s(C,{children:[s(Y,{children:[l&&s(ee,{children:[c&&e(J,{to:c}),e(re,{children:e(R,{badges:h,children:s(ae,{children:[!w&&b.map(o=>o+".\u200B"),e(te,{className:"schema-name",children:l})]})})})]}),!l&&h.map(y),e(n,{type:r.typePrefix+r.displayType}),e(n,{type:r.displayFormat&&`(${r.displayFormat})`}),e(n,{type:r.contentEncoding}),e(n,{type:r.title&&!D?`(${r.title})`:""}),r.constraints?.map(o=>e(n,{type:o},o)),B&&e(M,{deprecated:!0,children:t("openapi.badges.deprecated","Deprecated")}),e(K,{pattern:r.pattern}),f==="additionalProperties"&&e(g,{children:t("openapi.additionalProperties","additional property")}),f==="patternProperties"&&e(g,{children:t("openapi.patternProperties","pattern property")}),u&&e(q,{children:u}),F&&e(A,{children:t("openapi.required","required")}),r.isCircular&&e(x,{children:t("openapi.recursive","Recursive")}),k.map(y)]}),r.isComplex&&e(x,{children:t("openapi.complex","Complex")}),e(Z,{source:P}),e(m,{raw:E,type:"default",label:t("openapi.default","Default"),value:r.default}),e(I,{type:r.type,values:r["x-enumDescriptions"]||r.enum}),T,e(_,{extensions:{...a.extensions,...r.extensions}}),r.externalDocs&&e(V,{externalDocs:r.externalDocs,compact:!0}),v?.(),e(m,{label:t("openapi.value","Value"),value:a.const||void 0})]})}const Pe=S(X),Y=i.div`
  display: flex;
  align-items: center;
  gap: calc(var(--spacing-xxs) / 4) var(--spacing-xxs);
  flex-wrap: wrap;
  margin-bottom: 2px;
  position: relative;
`,Z=i($)`
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);

  article p:last-child {
    margin-bottom: 0;
  }
`,ee=i.span`
  position: relative;
  font-family: var(--font-family-monospaced);
  line-height: var(--line-height-base);
  font-size: var(--font-size-base);
  color: var(--text-color-description);
  max-width: 100%;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;

  :hover {
    ${j} {
      opacity: 1;
      visibility: visible;
      background-color: var(--bg-color);
    }
  }
`,re=i.span`
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-xxs);
  flex-wrap: wrap;
  max-width: 100%;
`,ae=i.span`
  display: inline;
`,te=i.span`
  font-family: var(--font-family-monospaced);
  font-weight: var(--font-weight-semibold);
  font-size: var(--schemas-property-name-font-size);
  line-height: var(--schemas-property-name-line-height);
  color: var(--text-color-primary);
`;export{Pe as FieldDetails};
