var __rest = (this && this.__rest) || function (s, e) {
    var t = {};
    for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
        t[p] = s[p];
    if (s != null && typeof Object.getOwnPropertySymbols === "function")
        for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
            if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
                t[p[i]] = s[p[i]];
        }
    return t;
};
import ConfigProvider from '../config-provider';
import PropTypes from 'prop-types';
import React, { Component } from 'react';
import Tree from '../tree';
import cls from 'classnames';
import { TreeSelect as NextTreeSelect } from '@alifd/next';
import { getTheme } from '../utils/getTheme';
class TreeSelect extends Component {
    render() {
        const theme = getTheme(this.context, this.props);
        const _a = this.props, { prefix = 'next-', popupClassName, className, treeProps = {} } = _a, otherProps = __rest(_a, ["prefix", "popupClassName", "className", "treeProps"]);
        const { isNodeBlock, showLine } = treeProps, otherTreeProps = __rest(treeProps, ["isNodeBlock", "showLine"]);
        // const defaultPaddingLeft = typeof isNodeBlock === 'object' ? parseInt(isNodeBlock.defaultPaddingLeft || 16) : 16;
        // const indent = typeof isNodeBlock === 'object' ? parseInt(isNodeBlock.indent || 20) : 20;
        let defaultPaddingLeft = 16;
        let indent = 20;
        if (typeof isNodeBlock === 'object') {
            const nodeBlock = isNodeBlock;
            defaultPaddingLeft = parseInt(nodeBlock.defaultPaddingLeft || 16);
            indent = parseInt(nodeBlock.indent || 20);
        }
        if (!showLine) {
            return (React.createElement(NextTreeSelect, Object.assign({}, otherProps, { prefix: prefix, treeProps: Object.assign({ isNodeBlock: isNodeBlock ? { defaultPaddingLeft, indent } : false }, treeProps), className: cls(className, {
                    [`${prefix}white`]: theme === 'white',
                    [`${prefix}grey`]: theme === 'grey',
                }), popupClassName: cls(popupClassName, {
                    [`${prefix}white`]: theme === 'white',
                    [`${prefix}grey`]: theme === 'grey',
                }) })));
        }
        return (React.createElement(NextTreeSelect, Object.assign({}, otherProps, { prefix: prefix, treeProps: Object.assign({ showLine }, otherTreeProps), className: cls(className, {
                [`${prefix}white`]: theme === 'white',
                [`${prefix}grey`]: theme === 'grey',
            }), popupClassName: cls(popupClassName, {
                [`${prefix}white`]: theme === 'white',
                [`${prefix}grey`]: theme === 'grey',
            }) })));
    }
}
TreeSelect.Node = Tree.Node;
TreeSelect.contextTypes = {
    theme: PropTypes.string,
};
// hoistNonReactStatics(Tree, NextTree);
export default ConfigProvider.config(TreeSelect);
