"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const types_1 = __importDefault(require("../types"));
const middleware_component_1 = require("../middleware/middleware-component");
const libs_1 = require("../libs");
exports.ROUTE_INSTANCE_TYPE = "RouteComponent";
/**
 * The WebApp is a client that runs in the browser, SPA or SSR
 *
 * @param props
 */
exports.default = (props) => {
    //console.log ("route: ",props );
    const componentProps = {
        infrastructureType: types_1.default.INFRASTRUCTURE_TYPE_COMPONENT,
        instanceType: exports.ROUTE_INSTANCE_TYPE,
        instanceId: undefined,
        insulatesChildComponent: (child) => {
            // a route insulates (handles itself) middlewares and does not privide to higher levels
            return middleware_component_1.isMiddleware(child);
        }
    };
    const routeProps = {
        middlewares: libs_1.getChildrenArray(props.children)
            .filter(child => middleware_component_1.isMiddleware(child)),
        exact: true
    };
    return Object.assign(props, componentProps, routeProps);
};
exports.isRoute = (component) => {
    return component !== undefined &&
        component.instanceType === exports.ROUTE_INSTANCE_TYPE;
};
//# sourceMappingURL=route-component.js.map