"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,n)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=t[r]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&__createBinding(t,e,r);return __setModuleDefault(t,e),t};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ViewNested=void 0;const jsx_runtime_1=require("react/jsx-runtime"),styled_components_1=__importStar(require("styled-components")),react_1=require("react"),theme_1=require("@redocly/theme"),cycleColorsByLevel_1=require("../PropertyDetails/cycleColorsByLevel"),PlusCircleIcon_1=require("../PropertyDetails/PlusCircleIcon");function ViewNestedComponent({expandByDefault:e,isExpandedFromParent:t,level:r,expandable:o=!1,expandText:n,hideText:i,hideDivider:s=!1,onChange:l,children:a}){const[c,d]=(0,react_1.useState)(e);(0,react_1.useEffect)((()=>{o&&!(0,theme_1.isUndefined)(t)&&d(t)}),[t,o]);const _=c?(0,cycleColorsByLevel_1.cycleColorsByLevel)(r):void 0;if(!o)return a;return(0,jsx_runtime_1.jsxs)(Wrapper,{$divider:!s&&!c,className:"view-nested-wrapper",children:[(0,jsx_runtime_1.jsxs)(ShowProperty,{onClick:()=>{d((e=>!e)),l&&l()},children:[(0,jsx_runtime_1.jsx)(PlusCircleIcon_1.CircleIcon,{sign:c?"-":"+",color:_}),!c&&n,c&&(i||"")]}),c&&(0,jsx_runtime_1.jsx)(StyledNested,{color:_,children:a})]})}exports.ViewNested=(0,react_1.memo)(ViewNestedComponent);const ShowProperty=styled_components_1.default.button`
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  padding: 0;
  gap: var(--spacing-xxs);
  color: var(--text-color-secondary);
  font-size: var(--font-size-base);
  font-family: var(--font-family-base);
  line-height: var(--line-height-base);
  margin-top: var(--spacing-xxs);
  width: 100%;
`,StyledNested=styled_components_1.default.div`
  padding-left: var(--schema-nested-offset);
  border-left: 1px solid ${({color:e})=>e||"var(--border-color-primary)"};
  margin: -10px 0 0 9px;
  ${({color:e})=>e&&styled_components_1.css`
      .schema-name {
        color: ${e};
      }
    `}
`,Wrapper=styled_components_1.default.div`
  width: 100%;
  ${({$divider:e})=>e&&styled_components_1.css`
      border-bottom: 1px solid var(--border-color-primary);
      padding-bottom: var(--schema-property-details-spacing);
    `}
`;
//# sourceMappingURL=ViewNested.js.map