var __rest=this&&this.__rest||function(e,t){var o={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(o[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(o[n[r]]=e[n[r]])}return o};import{jsxs as _jsxs,jsx as _jsx}from"react/jsx-runtime";import{memo}from"react";import{useAtom}from"jotai";import styled from"styled-components";import{BadgeStyle,SelectionTitle}from"../common";import{Markdown}from"../Markdown";import{ConstraintsView}from"../common/ConstraintsView";import{Schema}from"./Schema";import{operationStore}from"../../jotai/operation";import{SchemaSelection}from"../common/SchemaSelection";import{useOneOfLocationIdx}from"./useOneOfLocationIdx";function OneOfSchemaComponent(e){var{schema:{oneOf:t},schema:o,oneOfLevel:n=1}=e,r=__rest(e,["schema","schema","oneOfLevel"]);const[i]=useAtom(operationStore(o.operationPointer)),s=useOneOfLocationIdx(t,n),a=-1===s?0:s,c=t[void 0!==i.activeOneOf[o.pointer]?i.activeOneOf[o.pointer]:a];if(!c)return null;const m=t.map(((e,t)=>({label:e.title||e.typePrefix+e.displayType,value:t})));return _jsxs(Wrapper,{children:[_jsxs(SelectionTitle,{children:[o.oneOfType,":"]}),_jsx(SchemaSelection,{options:m,pointer:o.operationPointer,schema:o,defaultOneOfIdx:a}),c.deprecated&&_jsx(BadgeStyle,{deprecated:!0,children:"Deprecated"}),c.description&&_jsx(StyledDescription,{source:c.description}),_jsx(ConstraintsView,{constraints:c.constraints}),_jsx(Schema,Object.assign({},r,{schema:c,oneOfLevel:n+1}))]})}export const OneOfSchema=memo(OneOfSchemaComponent);const StyledDescription=styled(Markdown)`
  margin-top: var(--spacing-xs);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
`,Wrapper=styled.div`
  display: flex;
  flex-direction: column;
  align-items: flex-start;
`;
//# sourceMappingURL=OneOfSchema.js.map