import * as React from "react";
import ExpandableProperty from "./ExpandableProperty";
const camelCaseToNormal = (str) => str.replace(/([A-Z])/g, " $1").replace(/^./, (str2) => str2.toUpperCase());
export const RecursiveProperty = (props) => {
    return (React.createElement("div", { className: "json-container" }, props.property
        ? (typeof props.property === "number" ||
            typeof props.property === "string" ||
            typeof props.property === "boolean"
            ? (React.createElement(React.Fragment, null,
                React.createElement("span", { className: "prop-name" },
                    props.propertyNameProcessor(props.propertyName),
                    ":",
                    " "),
                props.property.toString()))
            : (React.createElement(ExpandableProperty, { title: props.propertyNameProcessor(props.propertyName), expanded: !!props.rootProperty }, Object.values(props.property).map(
            /* eslint-disable-next-line */
            (property, index, { length }) => (React.createElement(RecursiveProperty, { key: index, property: property, propertyName: Object.getOwnPropertyNames(props.property)[index], propertyNameProcessor: props.propertyNameProcessor }))))))
        : (props.emptyPropertyLabel)));
};
RecursiveProperty.defaultProps = {
    emptyPropertyLabel: "Property is empty",
    propertyNameProcessor: camelCaseToNormal,
};
