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