import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import{memo}from"react";import{useAtomValue}from"jotai";import{PropertiesTableCaption}from"../common";import{Discriminator}from"../Discriminator";import{globalOptionsAtom}from"../../jotai/store";import{PropertyDetails}from"../PropertyDetails";import{SubSchema}from"./SubSchema";import{getExpandByDefault}from"./helpers";import{useTranslate}from"../../hooks";import{ArrayClosingLabel,LabelValue}from"../common/styled";function ObjectSchemaComponent({schema:e,showTitle:a,discriminator:r,level:i,skipWriteOnly:o,skipReadOnly:t,fieldParentsName:n,expandable:l,deepLink:s,required:m,disableDeepLinks:p,shouldCloseArray:c,oneOfLevel:d,slug:h}){const{fields:u=[],title:f}=e,x=useTranslate(),{schemasExpansionLevel:b}=useAtomValue(globalOptionsAtom),y=t||o?u.filter((e=>!(t&&e.schema.readOnly||o&&e.schema.writeOnly))):u,j=getExpandByDefault({required:m,level:i,schemasExpansionLevel:b});return _jsxs(SubSchema,{expandable:l,expandByDefault:j,level:i,propertyLength:y.length,deepLink:s,operationPointer:e.operationPointer,children:[_jsxs(_Fragment,{children:[a&&_jsx(PropertiesTableCaption,{children:f}),y.map(((e,l)=>_jsx(PropertyDetails,{isFirst:0===l,field:e,fieldParentsName:Number(i)>1?n:[],renderDiscriminatorSwitch:(null==r?void 0:r.fieldName)===e.name&&(null==r?void 0:r.parentSchema)?()=>_jsx(Discriminator,{parent:r.parentSchema,onChange:null==r?void 0:r.onChange,activeOneOfIdx:r.activeOneOfIdx,translate:x}):void 0,skipReadOnly:t,skipWriteOnly:o,showTitle:a,level:i,disableDeepLinks:p,oneOfLevel:d,slug:h},e.name)))]}),c&&_jsx(ArrayClosingLabel,{className:"array-closing-label",children:_jsx(LabelValue,{children:"]"})})]})}export const ObjectSchema=memo(ObjectSchemaComponent);
//# sourceMappingURL=ObjectSchema.js.map