define(["require", "exports", "react", "react-dom", "./AppDefinition", "office-ui-fabric-react/lib/utilities/router/index", "./GettingStartedPage", "office-ui-fabric-react/lib/Utilities", "office-ui-fabric-react/lib/Fabric", "@uifabric/icons/lib/index", "./index.scss", "./ColorStyles.scss"], function (require, exports, React, ReactDOM, AppDefinition_1, index_1, GettingStartedPage_1, Utilities_1, Fabric_1, index_2) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    index_2.initializeIcons('dist/');
    Utilities_1.setBaseUrl('./dist/');
    var rootElement;
    // Return the anchor link from the URL without the hash
    function _extractAnchorLink(path) {
        var index = path.lastIndexOf('#');
        if (index >= 0) {
            path = path.substr(index + 1, path.length - index);
        }
        return path;
    }
    function _scrollAnchorLink() {
        if ((window.location.hash.match(/#/g) || []).length > 1) {
            var anchor = _extractAnchorLink(window.location.hash);
            document.getElementById(anchor).scrollIntoView();
        }
    }
    function _onLoad() {
        rootElement = rootElement || document.getElementById('content');
        ReactDOM.render(React.createElement(Fabric_1.Fabric, null,
            React.createElement(index_1.Router, { onNewRouteLoaded: _scrollAnchorLink }, _getRoutes())), rootElement);
    }
    function _getRoutes() {
        var routes = AppDefinition_1.AppDefinition.testPages.map(function (page) { return React.createElement(index_1.Route, { key: page.key, path: page.url, component: page.component }); });
        var appRoutes = [];
        AppDefinition_1.AppDefinition.examplePages.forEach(function (group) {
            group.links
                .filter(function (link) { return link.hasOwnProperty('component') || link.hasOwnProperty('getComponent'); })
                .forEach(function (link, linkIndex) {
                var component = link.component, getComponent = link.getComponent;
                appRoutes.push(React.createElement(index_1.Route, { key: link.key, path: link.url, component: component, getComponent: getComponent }));
            });
        });
        // Default route.
        appRoutes.push(React.createElement(index_1.Route, { key: 'gettingstarted', component: GettingStartedPage_1.GettingStartedPage }));
        routes.push(React.createElement(index_1.Route, { key: 'app', component: AppDefinition_1.App }, appRoutes));
        return routes;
    }
    function _onUnload() {
        if (rootElement) {
            ReactDOM.unmountComponentAtNode(rootElement);
        }
    }
    var isReady = document.readyState === 'interactive' || document.readyState === 'complete';
    if (isReady) {
        _onLoad();
    }
    else {
        window.onload = _onLoad;
    }
    window.onunload = _onUnload;
});
//# sourceMappingURL=index.js.map