import{jsx as _jsx,Fragment as _Fragment,jsxs as _jsxs}from"react/jsx-runtime";import styled,{css}from"styled-components";import{memo,useEffect,useState}from"react";import{isUndefined}from"@redocly/theme";import{cycleColorsByLevel}from"../PropertyDetails/cycleColorsByLevel";import{CircleIcon}from"../PropertyDetails/PlusCircleIcon";import{LabelValue}from"../common/styled";function ViewNestedComponent({expandByDefault:e,level:r,expandable:s=!1,expandText:o,hideText:t,hideDivider:i=!1,children:a,expandedAll:n,isNestedArray:d}){var l;const[c,p]=useState(null!==(l=e||d)&&void 0!==l&&l);useEffect((()=>{isUndefined(n)||p(n)}),[n]);const m=c?cycleColorsByLevel(r):void 0;if(!s)return a;return d?_jsxs(_Fragment,{children:[_jsx(LabelValue,{children:"Array ["}),_jsx(Wrapper,{$isArrayInsideArray:d,className:"view-nested-wrapper",children:_jsx(StyledNested,{color:m,children:a})})]}):_jsx(_Fragment,{children:_jsxs(Wrapper,{$divider:!i&&!c,className:"view-nested-wrapper",children:[_jsxs(ShowProperty,{onClick:()=>{p((e=>!e))},children:[_jsx(CircleIcon,{sign:c?"-":"+",color:m}),!c&&o,c&&(t||"")]}),c&&_jsx(StyledNested,{color:m,children:a})]})})}export const ViewNested=memo(ViewNestedComponent);const ShowProperty=styled.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.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&&css`
      .schema-name {
        color: ${e};
      }
    `}
`,Wrapper=styled.div`
  width: 100%;
  ${({$isArrayInsideArray:e})=>e&&css`
      padding-top: var(--schema-property-details-spacing);
    `}

  ${({$divider:e})=>e&&css`
      border-bottom: 1px solid var(--border-color-primary);
      padding-bottom: var(--schema-property-details-spacing);
    `}
`;
//# sourceMappingURL=ViewNested.js.map