"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.SharedEntityDependencies = exports.Dependencies = void 0;
const tslib_1 = require("tslib");
const React = tslib_1.__importStar(require("react"));
const rebass_1 = require("rebass");
const SimpleButton_1 = tslib_1.__importDefault(require("../../components/SimpleButton"));
const AdaptableContext_1 = require("../AdaptableContext");
const AdaptableObjectList_1 = require("../Components/AdaptableObjectList/AdaptableObjectList");
const Dependencies = (props) => {
    const adaptable = (0, AdaptableContext_1.useAdaptable)();
    const dependencies = adaptable.api.teamSharingApi.internalApi.getSharedEntryDependencies(props.sharedEntity);
    return (React.createElement(React.Fragment, null, dependencies.map((sharedEntity) => {
        const module = adaptable.ModuleService.getModuleById('TeamSharing');
        const itemView = module.toView(sharedEntity);
        return (React.createElement(rebass_1.Box, { as: "ul", padding: 0, key: sharedEntity.Uuid, className: "ab-Shared-Entity-Shared-Object", mb: 2 },
            React.createElement(AdaptableObjectList_1.AdaptableObjectListItem, { deleteTooltip: 'Cannot delete dependencies.', deleteDisabled: true, module: module, data: itemView })));
    })));
};
exports.Dependencies = Dependencies;
const SharedEntityDependencies = (props) => {
    const [isExpanded, setIsExpanded] = React.useState(false);
    return (React.createElement(React.Fragment, null,
        React.createElement(rebass_1.Flex, null,
            React.createElement(rebass_1.Box, { mr: 3, className: 'ab-Adaptable-Object-List__Item__label' }, "Dependencies"),
            React.createElement(rebass_1.Box, { mb: 2, mt: 2 }, isExpanded ? (React.createElement(SimpleButton_1.default, { onClick: () => setIsExpanded(false), icon: "arrow-up" }, "Collapse")) : (React.createElement(SimpleButton_1.default, { onClick: () => setIsExpanded(true), icon: "arrow-down" }, "Expand")))),
        isExpanded && React.createElement(exports.Dependencies, { sharedEntity: props.data })));
};
exports.SharedEntityDependencies = SharedEntityDependencies;
