import{jsx as _jsx}from"react/jsx-runtime";import{memo}from"react";import{useLocation}from"react-router-dom";import{useAtom}from"jotai/index";import{useMount}from"@redocly/theme";import{pathIncludesLink}from"../../utils";import{operationStore}from"../../jotai/operation";import{extractTypeFromDeepLink}from"./helpers";import{ViewNested}from"../ViewNested";function SubSchemaComponent({expandByDefault:e,deepLink:o,level:t,expandable:r=!1,isArray:n="",propertyLength:i="",children:a,operationPointer:p}){var m;const s=useLocation(),d=pathIncludesLink(s,o),u=extractTypeFromDeepLink(o),[c,l]=useAtom(operationStore(p)),x=null===(m=c[u])||void 0===m?void 0:m.expandedFields[o||""],f=e=>{u&&o&&l((t=>{var r;return Object.assign(Object.assign({},t),{[u]:{expandedFields:Object.assign(Object.assign({},(null===(r=t[u])||void 0===r?void 0:r.expandedFields)||{}),{[o]:e})}})}))};useMount((()=>{r&&(e||d)&&f(!0)}));const h=`Show ${1===Number(i)?"":i} ${n&&"array "}${1!==i?"properties":"property"}`;return _jsx(ViewNested,{expandByDefault:e||d,isExpandedFromParent:x,level:t,expandable:r,onChange:()=>{f(!x)},expandText:h,children:a})}export const SubSchema=memo(SubSchemaComponent);
//# sourceMappingURL=SubSchema.js.map