{"version":3,"file":"JSONNestedNode.cjs","sources":["../../../../../.yarn/__virtual__/react-json-tree-virtual-6a28170cd8/4/.yarn/berry/cache/react-json-tree-npm-0.19.0-c65c86bc20-10c0.zip/node_modules/react-json-tree/lib/JSONNestedNode.js"],"sourcesContent":["import React, { useCallback, useState } from 'react';\nimport JSONArrow from './JSONArrow.js';\nimport getCollectionEntries from './getCollectionEntries.js';\nimport JSONNode from './JSONNode.js';\nimport ItemRange from './ItemRange.js';\nfunction isRange(rangeOrEntry) {\n    return rangeOrEntry.to !== undefined;\n}\nfunction renderChildNodes(props, from, to) {\n    const { nodeType, data, collectionLimit, circularCache, keyPath, postprocessValue, sortObjectKeys, } = props;\n    const childNodes = [];\n    getCollectionEntries(nodeType, data, sortObjectKeys, collectionLimit, from, to).forEach((entry) => {\n        if (isRange(entry)) {\n            childNodes.push(React.createElement(ItemRange, { ...props, key: `ItemRange--${entry.from}-${entry.to}`, from: entry.from, to: entry.to, renderChildNodes: renderChildNodes }));\n        }\n        else {\n            const { key, value } = entry;\n            const isCircular = circularCache.indexOf(value) !== -1;\n            childNodes.push(React.createElement(JSONNode, { ...props, postprocessValue, collectionLimit, key: `Node--${key}`, keyPath: [key, ...keyPath], value: postprocessValue(value), circularCache: [...circularCache, value], isCircular: isCircular, hideRoot: false }));\n        }\n    });\n    return childNodes;\n}\nexport default function JSONNestedNode(props) {\n    const { circularCache = [], collectionLimit, createItemString, data, expandable, getItemString, hideRoot, isCircular, keyPath, labelRenderer, level = 0, nodeType, nodeTypeIndicator, shouldExpandNodeInitially, styling, } = props;\n    const [expanded, setExpanded] = useState(\n    // calculate individual node expansion if necessary\n    isCircular ? false : shouldExpandNodeInitially(keyPath, data, level));\n    const handleClick = useCallback(() => {\n        if (expandable)\n            setExpanded(!expanded);\n    }, [expandable, expanded]);\n    const renderedChildren = expanded || (hideRoot && level === 0)\n        ? renderChildNodes({ ...props, circularCache, level: level + 1 })\n        : null;\n    const itemType = (React.createElement(\"span\", { ...styling('nestedNodeItemType', expanded) }, nodeTypeIndicator));\n    const renderedItemString = getItemString(nodeType, data, itemType, createItemString(data, collectionLimit), keyPath);\n    const stylingArgs = [keyPath, nodeType, expanded, expandable];\n    return hideRoot ? (React.createElement(\"li\", { ...styling('rootNode', ...stylingArgs) },\n        React.createElement(\"ul\", { ...styling('rootNodeChildren', ...stylingArgs) }, renderedChildren))) : (React.createElement(\"li\", { ...styling('nestedNode', ...stylingArgs) },\n        expandable && (React.createElement(JSONArrow, { styling: styling, nodeType: nodeType, expanded: expanded, onClick: handleClick })),\n        React.createElement(\"label\", { ...styling(['label', 'nestedNodeLabel'], ...stylingArgs), onClick: handleClick }, labelRenderer(...stylingArgs)),\n        React.createElement(\"span\", { ...styling('nestedNodeItemString', ...stylingArgs), onClick: handleClick }, renderedItemString),\n        React.createElement(\"ul\", { ...styling('nestedNodeChildren', ...stylingArgs) }, renderedChildren)));\n}\n"],"names":["React","useState","useCallback"],"mappings":";;;;;;;;AAKA,SAAS,QAAQ,cAAc;AAC3B,SAAO,aAAa,OAAO;AAC/B;AACA,SAAS,iBAAiB,OAAO,MAAM,IAAI;AACvC,QAAM,EAAE,UAAU,MAAM,iBAAiB,eAAe,SAAS,kBAAkB,eAAc,IAAM;AACvG,QAAM,aAAa,CAAA;AACnB,uBAAqB,UAAU,MAAM,gBAAgB,iBAAiB,MAAM,EAAE,EAAE,QAAQ,CAAC,UAAU;AAC/F,QAAI,QAAQ,KAAK,GAAG;AAChB,iBAAW,KAAKA,uBAAM,cAAc,WAAW,EAAE,GAAG,OAAO,KAAK,cAAc,MAAM,IAAI,IAAI,MAAM,EAAE,IAAI,MAAM,MAAM,MAAM,IAAI,MAAM,IAAI,iBAAkC,CAAE,CAAC;AAAA,IACjL,OACK;AACD,YAAM,EAAE,KAAK,MAAK,IAAK;AACvB,YAAM,aAAa,cAAc,QAAQ,KAAK,MAAM;AACpD,iBAAW,KAAKA,eAAAA,QAAM,cAAc,UAAU,EAAE,GAAG,OAAO,kBAAkB,iBAA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