"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,s){void 0===s&&(s=t);var n=Object.getOwnPropertyDescriptor(r,t);n&&!("get"in n?!r.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,s,n)}:function(e,r,t,s){void 0===s&&(s=t),e[s]=r[t]}),__setModuleDefault=this&&this.__setModuleDefault||(Object.create?function(e,r){Object.defineProperty(e,"default",{enumerable:!0,value:r})}:function(e,r){e.default=r}),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)"default"!==t&&Object.prototype.hasOwnProperty.call(e,t)&&__createBinding(r,e,t);return __setModuleDefault(r,e),r};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"),styled_1=require("../common/styled");function ViewNestedComponent({expandByDefault:e,level:r,expandable:t=!1,expandText:s,hideText:n,hideDivider:i=!1,children:o,expandedAll:a,isNestedArray:l}){var c;const[d,_]=(0,react_1.useState)(null!==(c=e||l)&&void 0!==c&&c);(0,react_1.useEffect)((()=>{(0,theme_1.isUndefined)(a)||_(a)}),[a]);const p=d?(0,cycleColorsByLevel_1.cycleColorsByLevel)(r):void 0;if(!t)return o;return l?(0,jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment,{children:[(0,jsx_runtime_1.jsx)(styled_1.LabelValue,{children:"Array ["}),(0,jsx_runtime_1.jsx)(Wrapper,{$isArrayInsideArray:l,className:"view-nested-wrapper",children:(0,jsx_runtime_1.jsx)(StyledNested,{color:p,children:o})})]}):(0,jsx_runtime_1.jsx)(jsx_runtime_1.Fragment,{children:(0,jsx_runtime_1.jsxs)(Wrapper,{$divider:!i&&!d,className:"view-nested-wrapper",children:[(0,jsx_runtime_1.jsxs)(ShowProperty,{onClick:()=>{_((e=>!e))},children:[(0,jsx_runtime_1.jsx)(PlusCircleIcon_1.CircleIcon,{sign:d?"-":"+",color:p}),!d&&s,d&&(n||"")]}),d&&(0,jsx_runtime_1.jsx)(StyledNested,{color:p,children:o})]})})}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: var(--spacing-xxs) 0 var(--spacing-xs);
  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%;
  ${({$isArrayInsideArray:e})=>e&&styled_components_1.css`
      padding-top: var(--schema-property-details-spacing);
    `}

  ${({$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