import MapSearchIcon from 'mdi-react/MapSearchIcon';
import * as React from 'react';
import { Route, Switch } from 'react-router';
import { Subject, Subscription } from 'rxjs';
import { HeroPage } from '../components/HeroPage';
import { ExtensionsAreaHeader } from './ExtensionsAreaHeader';
const NotFoundPage = () => React.createElement(HeroPage, { icon: MapSearchIcon, title: "404: Not Found" });
const LOADING = 'loading';
/**
 * The extensions area.
 */
export class ExtensionsArea extends React.Component {
    constructor() {
        super(...arguments);
        this.state = {
            subjectOrError: LOADING,
        };
        this.componentUpdates = new Subject();
        this.subscriptions = new Subscription();
    }
    componentDidMount() {
        this.componentUpdates.next(this.props);
    }
    componentWillReceiveProps(props) {
        this.componentUpdates.next(props);
    }
    componentWillUnmount() {
        this.subscriptions.unsubscribe();
    }
    render() {
        const context = {
            authenticatedUser: this.props.user,
            configurationCascade: this.props.configurationCascade,
            extensions: this.props.extensions,
            subject: this.props.viewerSubject,
            clientConnection: this.props.clientConnection,
            extensionAreaRoutes: this.props.extensionAreaRoutes,
            extensionAreaHeaderNavItems: this.props.extensionAreaHeaderNavItems,
            isLightTheme: this.props.isLightTheme,
        };
        return (React.createElement("div", { className: "extensions-area area--vertical" },
            React.createElement(ExtensionsAreaHeader, Object.assign({}, this.props, context, { actionButtons: this.props.extensionsAreaHeaderActionButtons, isPrimaryHeader: this.props.location.pathname === this.props.match.path })),
            React.createElement(Switch, null,
                this.props.routes.map(({ path, exact, condition = () => true, render }) => condition(context) && (React.createElement(Route, { key: "hardcoded-key", path: this.props.match.url + path, exact: exact, 
                    // tslint:disable-next-line:jsx-no-lambda
                    render: routeComponentProps => render(Object.assign({}, context, routeComponentProps)) }))),
                React.createElement(Route, { key: "hardcoded-key", component: NotFoundPage }))));
    }
}
//# sourceMappingURL=ExtensionsArea.js.map