import { Component, ChangeDetectionStrategy, ViewEncapsulation, Renderer2, Input, Optional, Host, HostBinding, HostListener, NgModule } from '@angular/core';
import { Patch, Platform, mixinDisabled } from '@bravobit/bb-foundation';
import { BehaviorSubject, of } from 'rxjs';
import { Storage } from '@bravobit/bb-foundation/storage';
import { map } from 'rxjs/operators';
import { ElementsModule } from '@bravobit/bb-foundation/elements';
import { CommonModule } from '@angular/common';
import { RouterModule } from '@angular/router';

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dashboard/dashboard.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class BbDashboard {
    /**
     * @param {?} _patch
     * @param {?} _platform
     * @param {?} _renderer
     */
    constructor(_patch, _platform, _renderer) {
        this._patch = _patch;
        this._platform = _platform;
        this._renderer = _renderer;
        // Inputs.
        this.backgroundColor = '#e7eaed';
        this.maxWidth = '1200px';
        this.padding = '20px';
        // State.
        this.sidebarVisible$ = new BehaviorSubject(true);
    }
    /**
     * @return {?}
     */
    get visibility() {
        return this.sidebarVisible$.asObservable();
    }
    /**
     * @return {?}
     */
    ngOnInit() {
        // Set the vertical height for mobile devices.
        this._patch.mobileVerticalHeight();
        // Set the HTML class to prevent scrolling.
        return this.setHtmlClass();
    }
    /**
     * @return {?}
     */
    ngOnDestroy() {
        // Remove the HTML class.
        this.setHtmlClass(true);
    }
    /**
     * @return {?}
     */
    toggleSidebarVisibility() {
        // Get the previous value.
        /** @type {?} */
        const previousValue = this.sidebarVisible$.getValue();
        // Invert the value and set the visibility.
        this.setSidebarVisibility(!previousValue);
    }
    /**
     * @param {?} newValue
     * @return {?}
     */
    setSidebarVisibility(newValue) {
        this.sidebarVisible$.next(newValue);
    }
    /**
     * @private
     * @param {?=} shouldRemove
     * @return {?}
     */
    setHtmlClass(shouldRemove = false) {
        // Check if we are on a browser.
        if (!this._platform.isBrowser) {
            return;
        }
        // Define the class name.
        /** @type {?} */
        const className = 'bb-dashboard-html';
        // Add or remove the class.
        return shouldRemove
            ? this._renderer.removeClass(document.documentElement, className)
            : this._renderer.addClass(document.documentElement, className);
    }
}
BbDashboard.decorators = [
    { type: Component, args: [{
                selector: 'bb-dashboard',
                template: "<!--\r\n    The outlet for where the sidebar\r\n    will be placed (if provided).\r\n-->\r\n<ng-content select=\"bb-dashboard-sidebar\">\r\n</ng-content>\r\n\r\n<!--\r\n    The section containing the header\r\n    and the main content.\r\n-->\r\n<section [style.background-color]=\"backgroundColor\"\r\n         class=\"bb-dashboard-section\">\r\n    <!--\r\n        The outlet for where the header\r\n        will be placed (if provided).\r\n    -->\r\n    <ng-content select=\"bb-dashboard-header\">\r\n    </ng-content>\r\n\r\n    <!--\r\n        The outlet of the content that\r\n        will be provided by the router.\r\n    -->\r\n    <main [style.padding]=\"padding\"\r\n          class=\"bb-dashboard-scroll\">\r\n        <div [style.max-width]=\"maxWidth\"\r\n             class=\"bb-dashboard-container\">\r\n            <ng-content select=\"bb-dashboard-menu\"></ng-content>\r\n\r\n            <ng-content></ng-content>\r\n        </div>\r\n    </main>\r\n</section>\r\n\r\n<!--\r\n    The backdrop that will be visible when\r\n    the sidebar is opened (only on mobile).\r\n-->\r\n<div [class.bb-dashboard-backdrop--visible]=\"!(visibility | async)\"\r\n     (click)=\"toggleSidebarVisibility()\"\r\n     class=\"bb-dashboard-backdrop\">\r\n</div>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                preserveWhitespaces: false,
                host: {
                    'class': 'bb-dashboard'
                },
                styles: [".bb-dashboard{height:100vh;display:-ms-flexbox;display:flex;overflow:hidden;position:relative;height:calc(var(--vh,1vh) * 100)}.bb-dashboard-section{-ms-flex:1;flex:1;height:100vh;display:-ms-flexbox;display:flex;overflow-x:hidden;-ms-flex-direction:column;flex-direction:column;height:calc(var(--vh,1vh) * 100)}.bb-dashboard-scroll{-ms-flex:1;flex:1;display:-ms-flexbox;display:flex;overflow-x:hidden;overflow-y:scroll;-webkit-overflow-scrolling:touch}.bb-dashboard-container{width:100%;display:-ms-flexbox;display:flex;margin:0 auto;-ms-flex-direction:column;flex-direction:column}.bb-dashboard-backdrop{top:0;left:0;right:0;bottom:0;opacity:0;z-index:5;position:absolute;will-change:opacity;pointer-events:none;background-color:rgba(0,0,0,.5);transition:opacity .2s cubic-bezier(0,0,.2,1)}.bb-dashboard-backdrop--visible{opacity:1;cursor:pointer;pointer-events:all}@media only screen and (min-width:768px){.bb-dashboard-backdrop{display:none}}.bb-dashboard-html{height:100%;overflow:hidden}"]
            }] }
];
/** @nocollapse */
BbDashboard.ctorParameters = () => [
    { type: Patch },
    { type: Platform },
    { type: Renderer2 }
];
BbDashboard.propDecorators = {
    backgroundColor: [{ type: Input }],
    maxWidth: [{ type: Input }],
    padding: [{ type: Input }]
};
if (false) {
    /** @type {?} */
    BbDashboard.prototype.backgroundColor;
    /** @type {?} */
    BbDashboard.prototype.maxWidth;
    /** @type {?} */
    BbDashboard.prototype.padding;
    /**
     * @type {?}
     * @private
     */
    BbDashboard.prototype.sidebarVisible$;
    /**
     * @type {?}
     * @private
     */
    BbDashboard.prototype._patch;
    /**
     * @type {?}
     * @private
     */
    BbDashboard.prototype._platform;
    /**
     * @type {?}
     * @private
     */
    BbDashboard.prototype._renderer;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dashboard-header/dashboard-header.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class BbDashboardHeader {
    /**
     * @param {?} _parent
     */
    constructor(_parent) {
        this._parent = _parent;
    }
    /**
     * @return {?}
     */
    get isSidebarVisible() {
        return this._parent
            ? this._parent.visibility
            : of(false);
    }
    /**
     * @return {?}
     */
    onToggleSidebarClicked() {
        // If the parent exists toggle the sidebar visibility.
        this._parent && this._parent.toggleSidebarVisibility();
    }
}
BbDashboardHeader.decorators = [
    { type: Component, args: [{
                selector: 'bb-dashboard-header',
                template: "<!--\r\n    The button that toggles the sidebar.\r\n-->\r\n<button (click)=\"onToggleSidebarClicked()\"\r\n        [class.bb-dashboard-header-button--reversed]=\"isSidebarVisible | async\"\r\n        class=\"bb-dashboard-header-button\"\r\n        type=\"button\"\r\n        tabindex=\"0\"\r\n        role=\"switch\">\r\n    <svg xmlns=\"http://www.w3.org/2000/svg\"\r\n         viewBox=\"0 0 157 109\"\r\n         width=\"17\"\r\n         height=\"12\"\r\n         role=\"img\">\r\n        <title>\r\n            Toggle\r\n        </title>\r\n        <path fill=\"#fff\"\r\n              d=\"M82 42V11.2L30 54.5l52 43.3V67h75V42zM9.5 109h-2c-4.1 0-7.5-3.4-7.5-7.5v-94C0 3.4 3.4 0 7.5 0h2C13.6 0 17 3.4 17 7.5v94c0 4.1-3.4 7.5-7.5 7.5z\">\r\n        </path>\r\n    </svg>\r\n</button>\r\n\r\n<!--\r\n    The extra items of the header.\r\n-->\r\n<div class=\"bb-dashboard-header-items\">\r\n    <ng-content></ng-content>\r\n</div>",
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                preserveWhitespaces: false,
                host: {
                    'class': 'bb-dashboard-header'
                },
                styles: [".bb-dashboard-header{z-index:1;width:100%;color:#fff;height:50px;display:-ms-flexbox;display:flex;padding:0 8px;min-height:50px;-ms-flex-align:center;align-items:center;background-color:#5b53ff;border-bottom:1px solid #4d46d6}.bb-dashboard-header-button{width:68px;height:34px;border-radius:4px;-ms-flex-align:center;align-items:center;display:-ms-inline-flexbox;display:inline-flex;-ms-flex-pack:center;justify-content:center;border:1px solid #4d46d6;background-color:transparent}.bb-dashboard-header-button>svg{height:100%;-ms-transform:none;transform:none;transition:transform .2s cubic-bezier(0,0,.2,1)}.bb-dashboard-header-button--reversed>svg{transform:rotateY(180deg)}.bb-dashboard-header-button:hover{background-color:rgba(0,0,0,.04)}.bb-dashboard-header-button:active{background-color:rgba(0,0,0,.08)}.bb-dashboard-header-items{display:-ms-flexbox;display:flex;margin-left:auto;-ms-flex-align:center;align-items:center}.bb-dashboard-header-items>:not(:first-child){margin-left:8px}@media only screen and (min-width:768px){.bb-dashboard-header-button>svg{transform:rotateY(180deg)}.bb-dashboard-header-button--reversed>svg{-ms-transform:none;transform:none}}"]
            }] }
];
/** @nocollapse */
BbDashboardHeader.ctorParameters = () => [
    { type: BbDashboard, decorators: [{ type: Optional }] }
];
if (false) {
    /**
     * @type {?}
     * @private
     */
    BbDashboardHeader.prototype._parent;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dashboard-menu/dashboard-menu.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class BbDashboardMenu {
    constructor() {
        // Inputs.
        this.title = null;
        this.imageUrl = null;
        this.backUrlLink = null;
        this.backUrlTitle = null;
    }
}
BbDashboardMenu.decorators = [
    { type: Component, args: [{
                selector: 'bb-dashboard-menu',
                template: "<a *ngIf=\"backUrlLink && backUrlTitle\"\r\n   [routerLink]=\"backUrlLink\"\r\n   class=\"bb-dashboard-menu-link\">\r\n    {{ backUrlTitle }}\r\n</a>\r\n\r\n<div class=\"bb-dashboard-menu-row\">\r\n    <img *ngIf=\"imageUrl\"\r\n         [src]=\"imageUrl\"\r\n         class=\"bb-dashboard-menu-image\"\r\n         alt=\"Menu image\">\r\n    <h1 *ngIf=\"title as titleLabel\"\r\n        class=\"bb-dashboard-menu-title\">\r\n        {{ titleLabel }}\r\n    </h1>\r\n</div>\r\n\r\n<nav class=\"bb-dashboard-menu-navigation\">\r\n    <ng-content select=\"[bb-dashboard-menu-item]\"></ng-content>\r\n</nav>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                preserveWhitespaces: false,
                host: {
                    'class': 'bb-dashboard-menu',
                    'role': 'navigation'
                },
                styles: [".bb-dashboard-menu{display:block;margin-bottom:20px}.bb-dashboard-menu-link,.bb-dashboard-menu-title{max-width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}.bb-dashboard-menu-link{display:block;font-weight:500;margin-bottom:16px;text-decoration:none}.bb-dashboard-menu-link,.bb-dashboard-menu-link:visited{color:#a7a9c4!important}.bb-dashboard-menu-link:before{width:14px;content:\"\";height:13px;margin-right:3px;display:inline-block;background-size:cover;background-image:url(\"data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 492 492'%3E%3Cpath fill='%23a7a9c4' d='M464.344 207.418l.768.168H135.888l103.496-103.724c5.068-5.064 7.848-11.924 7.848-19.124 0-7.2-2.78-14.012-7.848-19.088L223.28 49.538c-5.064-5.064-11.812-7.864-19.008-7.864-7.2 0-13.952 2.78-19.016 7.844L7.844 226.914C2.76 231.998-.02 238.77 0 245.974c-.02 7.244 2.76 14.02 7.844 19.096l177.412 177.412c5.064 5.06 11.812 7.844 19.016 7.844 7.196 0 13.944-2.788 19.008-7.844l16.104-16.112c5.068-5.056 7.848-11.808 7.848-19.008 0-7.196-2.78-13.592-7.848-18.652L134.72 284.406h329.992c14.828 0 27.288-12.78 27.288-27.6v-22.788c0-14.82-12.828-26.6-27.656-26.6z'/%3E%3C/svg%3E\")}.bb-dashboard-menu-row{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;margin-bottom:10px}.bb-dashboard-menu-image{display:block;margin-right:10px;width:30px;height:30px;border-radius:50%}.bb-dashboard-menu-title{color:#272838;display:block;line-height:1;font-size:34px;font-weight:500}.bb-dashboard-menu-navigation{display:-ms-flexbox;display:flex;overflow-x:auto;border-bottom:1px solid #d8d8d8}"]
            }] }
];
BbDashboardMenu.propDecorators = {
    title: [{ type: Input }],
    imageUrl: [{ type: Input }],
    backUrlLink: [{ type: Input }],
    backUrlTitle: [{ type: Input }]
};
if (false) {
    /** @type {?} */
    BbDashboardMenu.prototype.title;
    /** @type {?} */
    BbDashboardMenu.prototype.imageUrl;
    /** @type {?} */
    BbDashboardMenu.prototype.backUrlLink;
    /** @type {?} */
    BbDashboardMenu.prototype.backUrlTitle;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dashboard-menu-item/dashboard-menu-item.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class BbDashboardMenuItemBase {
}
/** @type {?} */
const BbDashboardMenuItemMixinBase = mixinDisabled(BbDashboardMenuItemBase);
class BbDashboardMenuItem extends BbDashboardMenuItemMixinBase {
    /**
     * @param {?} event
     * @return {?}
     */
    stopDisabledEvents(event) {
        // If the menu item is not disabled let all events pass.
        if (!this.disabled) {
            return;
        }
        // If the menu item is disabled stop the event from
        // bubbling up.
        event.preventDefault();
        event.stopImmediatePropagation();
    }
}
BbDashboardMenuItem.decorators = [
    { type: Component, args: [{
                selector: '[bb-dashboard-menu-item]',
                template: "<ng-content select=\"[bbPrefix]\"></ng-content>\r\n<span class=\"bb-dashboard-menu-item-content\">\r\n    <ng-content></ng-content>\r\n</span>\r\n<ng-content select=\"[bbSuffix]\"></ng-content>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                preserveWhitespaces: false,
                inputs: ['disabled'],
                host: {
                    'class': 'bb-dashboard-menu-item',
                    '[class.disabled]': 'disabled',
                    '(click)': 'stopDisabledEvents($event)'
                },
                styles: [".bb-dashboard-menu-item{margin:0;padding:0;border:none;display:-ms-flexbox;display:flex;max-width:100%;font-size:16px;-webkit-appearance:none;-moz-appearance:none;appearance:none;-ms-flex-align:center;align-items:center;white-space:nowrap;background-color:transparent;text-decoration:none!important;border-bottom:2px solid transparent}.bb-dashboard-menu-item,.bb-dashboard-menu-item:visited{color:#6b5c5c}.bb-dashboard-menu-item:not(:first-child){margin-left:10px}.bb-dashboard-menu-item:not(:last-child){margin-right:10px}.bb-dashboard-menu-item:hover:not(.disabled):not(.active){border-color:rgba(117,119,148,.2)}.bb-dashboard-menu-item.active,.bb-dashboard-menu-item.active:visited .bb-dashboard-menu-item.active:hover{color:#5b53ff;border-color:#5b53ff}.bb-dashboard-menu-item.disabled,.bb-dashboard-menu-item.disabled:active,.bb-dashboard-menu-item.disabled:focus,.bb-dashboard-menu-item.disabled:hover{opacity:.4;cursor:default;box-shadow:none}.bb-dashboard-menu-item>.bb-prefix{margin-right:5px}.bb-dashboard-menu-item>.bb-suffix{margin-left:5px}.bb-dashboard-menu-item-content{height:38px;display:block;font-weight:500;line-height:38px}"]
            }] }
];

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dashboard-sidebar/dashboard-sidebar.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class BbDashboardSidebar {
    /**
     * @param {?} _storage
     * @param {?} _parent
     */
    constructor(_storage, _parent) {
        this._storage = _storage;
        this._parent = _parent;
        // Bindings.
        this.visible = true;
        // State.
        this._state$ = new BehaviorSubject({});
        // Token.
        this._localStorageToken = 'bb-dashboard-sidebar-state';
    }
    /**
     * @return {?}
     */
    ngOnInit() {
        // Retrieve the cache.
        this._cache = this._storage.get(this._localStorageToken) || {};
        // Get the visibility observable from the parent
        // if the parent exists.
        /** @type {?} */
        const observable$ = this._parent
            ? this._parent.visibility
            : of(false);
        // Subscribe to get the state changes.
        this._subscription = observable$
            .subscribe((/**
         * @param {?} value
         * @return {?}
         */
        value => this.visible = value));
    }
    /**
     * @return {?}
     */
    ngOnDestroy() {
        // Unsubscribe to prevent memory leaks.
        this._subscription && this._subscription.unsubscribe();
    }
    /**
     * @param {?} id
     * @return {?}
     */
    registerGroup(id) {
        // Get the old state.
        /** @type {?} */
        const oldState = this._state$.getValue();
        // Get the cache value so when it is undefined
        // we will default to true.
        /** @type {?} */
        const cacheValue = this._cache[id] === undefined ? true : this._cache[id];
        // Push the new state.
        this._state$.next(Object.assign({}, oldState, { [id]: cacheValue }));
        // Return the slice of the state that the group needs.
        return this._state$.pipe(map((/**
         * @param {?} state
         * @return {?}
         */
        state => state[id])));
    }
    /**
     * @param {?} id
     * @return {?}
     */
    unregisterGroup(id) {
        // Get the old groups.
        /** @type {?} */
        const oldState = this._state$.getValue();
        // Generate the new state without the id.
        /** @type {?} */
        const newState = Object.keys(oldState).reduce((/**
         * @param {?} object
         * @param {?} key
         * @return {?}
         */
        (object, key) => {
            if (key !== id) {
                object[key] = oldState[key];
            }
            return object;
        }), {});
        // Push the new state.
        this._state$.next(newState);
    }
    /**
     * @param {?} id
     * @param {?} newValue
     * @return {?}
     */
    toggleGroup(id, newValue) {
        // Get the old state.
        /** @type {?} */
        const oldState = this._state$.getValue();
        // Create the new state.
        /** @type {?} */
        const newState = Object.assign({}, oldState, { [id]: newValue });
        // Push the new state.
        this._state$.next(newState);
        // Save in the cache.
        this._storage.set(this._localStorageToken, newState);
    }
    /**
     * @return {?}
     */
    close() {
        // Set the sidebar visibility to true, this means
        // that on mobile the sidebar will be closed.
        this._parent.setSidebarVisibility(true);
    }
}
BbDashboardSidebar.decorators = [
    { type: Component, args: [{
                selector: 'bb-dashboard-sidebar',
                template: "<!--\r\n    The optional header element.\r\n-->\r\n<ng-content select=\"header\"></ng-content>\r\n\r\n<!--\r\n    The scroll area that contains the\r\n    groups in the navigation.\r\n-->\r\n<div class=\"bb-dashboard-sidebar-scroll\">\r\n    <ng-content select=\"bb-dashboard-sidebar-group\"></ng-content>\r\n</div>\r\n\r\n<!--\r\n    The optional footer element.\r\n-->\r\n<ng-content select=\"footer\"></ng-content>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                preserveWhitespaces: false,
                host: {
                    'class': 'bb-dashboard-sidebar',
                    'role': 'navigation'
                },
                styles: [".bb-dashboard-sidebar{top:0;bottom:0;z-index:10;left:-256px;width:256px;height:100vh;display:-ms-flexbox;display:flex;position:fixed;min-width:256px;will-change:transform;-ms-flex-direction:column;flex-direction:column;-ms-transform:translateX(256px);transform:translateX(256px);height:calc(var(--vh,1vh) * 100);border-right:1px solid rgba(0,0,0,.4);transition:transform 250ms cubic-bezier(0,0,.2,1);background:linear-gradient(to bottom,#fff,#f2f2f2) #fff}.bb-dashboard-sidebar.visible{-ms-transform:none;transform:none}.bb-dashboard-sidebar-scroll{-ms-flex:1;flex:1;overflow:auto}.bb-dashboard-sidebar>header{border-bottom:1px solid #d8d8d8;background-color:rgba(255,255,255,.5)}.bb-dashboard-sidebar>footer{border-top:1px solid #d8d8d8;background-color:rgba(255,255,255,.5)}@media only screen and (min-width:768px){.bb-dashboard-sidebar{left:0;z-index:auto;-ms-transform:none;transform:none;position:relative;margin-left:-256px;transition:margin-left 250ms cubic-bezier(0,0,.2,1)}.bb-dashboard-sidebar.visible{margin-left:0}}"]
            }] }
];
/** @nocollapse */
BbDashboardSidebar.ctorParameters = () => [
    { type: Storage },
    { type: BbDashboard, decorators: [{ type: Optional }, { type: Host }] }
];
BbDashboardSidebar.propDecorators = {
    visible: [{ type: HostBinding, args: ['class.visible',] }]
};
if (false) {
    /** @type {?} */
    BbDashboardSidebar.prototype.visible;
    /**
     * @type {?}
     * @private
     */
    BbDashboardSidebar.prototype._state$;
    /**
     * @type {?}
     * @private
     */
    BbDashboardSidebar.prototype._cache;
    /**
     * @type {?}
     * @private
     */
    BbDashboardSidebar.prototype._subscription;
    /**
     * @type {?}
     * @private
     */
    BbDashboardSidebar.prototype._localStorageToken;
    /**
     * @type {?}
     * @private
     */
    BbDashboardSidebar.prototype._storage;
    /**
     * @type {?}
     * @private
     */
    BbDashboardSidebar.prototype._parent;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dashboard-sidebar-group/dashboard-sidebar-group.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class BbDashboardSidebarGroupBase {
    /**
     * @param {?} _parent
     */
    constructor(_parent) {
        this._parent = _parent;
    }
}
if (false) {
    /**
     * @type {?}
     * @protected
     */
    BbDashboardSidebarGroupBase.prototype._parent;
}
/** @type {?} */
const BbDashboardSidebarGroupMixinBase = mixinDisabled(BbDashboardSidebarGroupBase);
class BbDashboardSidebarGroup extends BbDashboardSidebarGroupMixinBase {
    /**
     * @param {?} _parent
     */
    constructor(_parent) {
        super(_parent);
        this._parent = _parent;
        // Inputs.
        this.id = null;
        this.icon = null;
        this.title = null;
        // State.
        this._isExpanded = false;
    }
    /**
     * @return {?}
     */
    get hasToggle() {
        // Check if the user provided a icon and/or title.
        return !!this.icon || !!this.title;
    }
    /**
     * @return {?}
     */
    get isExpanded() {
        // If there is an icon or title the group can be
        // expanded by clicking, else not.
        return this.hasToggle
            ? this._isExpanded
            : true;
    }
    /**
     * @return {?}
     */
    ngOnInit() {
        // Check if the id has been supplied.
        if (!this.id) {
            throw new Error('Id is required.');
        }
        // Register the group at the parent and
        // retrieve the slice of the state.
        /** @type {?} */
        const observable$ = this._parent
            ? this._parent.registerGroup(this.id)
            : of(false);
        // Subscribe to the state.
        this._subscription = observable$
            .subscribe((/**
         * @param {?} isExpanded
         * @return {?}
         */
        isExpanded => this._isExpanded = isExpanded));
    }
    /**
     * @return {?}
     */
    ngOnDestroy() {
        // Unsubscribe to prevent memory leaks.
        this._subscription && this._subscription.unsubscribe();
        // Unregister the group at the parent.
        this._parent && this._parent.unregisterGroup(this.id);
    }
    /**
     * @return {?}
     */
    onClick() {
        // Verify the group is not disabled.
        if (this.disabled) {
            return;
        }
        // Change the state.
        /** @type {?} */
        const newValue = !this._isExpanded;
        // Set the state of the sidebar group.
        this._parent && this._parent.toggleGroup(this.id, newValue);
    }
    /**
     * @param {?} event
     * @return {?}
     */
    onGroupClicked(event) {
        // If the group is not disabled don't do anything.
        if (!this.disabled) {
            return;
        }
        event.preventDefault();
        event.stopPropagation();
    }
}
BbDashboardSidebarGroup.decorators = [
    { type: Component, args: [{
                selector: 'bb-dashboard-sidebar-group',
                template: "<!--\r\n    The wrapper that contains the title and icon.\r\n-->\r\n<button *ngIf=\"hasToggle\"\r\n        (click)=\"onClick()\"\r\n        class=\"bb-dashboard-sidebar-group-title\"\r\n        type=\"button\"\r\n        role=\"switch\">\r\n    <bb-icon *ngIf=\"icon as iconName\"\r\n             [src]=\"iconName\"\r\n             class=\"bb-dashboard-sidebar-group-icon\">\r\n    </bb-icon>\r\n    <span *ngIf=\"title as titleText\"\r\n          role=\"heading\"\r\n          class=\"bb-dashboard-sidebar-group-text\">\r\n        {{ titleText }}\r\n    </span>\r\n    <span class=\"bb-dashboard-sidebar-group-toggle\">\r\n       <svg xmlns=\"http://www.w3.org/2000/svg\"\r\n            viewBox=\"0 0 21.7 30.9\"\r\n            width=\"10\"\r\n            height=\"10\"\r\n            role=\"img\">\r\n           <path\r\n               d=\"M10.1.3L.2 11.8c-.6.6-.1 1.7.8 1.7h19.7c.9 0 1.3-1 .8-1.7L11.6.3c-.4-.4-1.1-.4-1.5 0zM10.1 30.6L.2 19.1c-.6-.6-.1-1.7.8-1.7h19.7c.9 0 1.3 1 .8 1.7l-9.8 11.5c-.5.4-1.2.4-1.6 0z\">\r\n           </path>\r\n       </svg>\r\n    </span>\r\n</button>\r\n\r\n<!--\r\n    The sidebar items that contain the\r\n    links to navigate to other pages.\r\n-->\r\n<ng-content select=\"[bb-dashboard-sidebar-item]\">\r\n</ng-content>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                preserveWhitespaces: false,
                inputs: ['disabled'],
                host: {
                    'class': 'bb-dashboard-sidebar-group',
                    '[class.expanded]': 'isExpanded',
                    '[class.with-toggle]': 'hasToggle',
                    '[class.has-icon]': '!!icon',
                    '[class.disabled]': 'disabled',
                    'role': 'group'
                },
                styles: [".bb-dashboard-sidebar-group{color:#000;display:block;overflow:hidden;border-bottom:1px solid rgba(0,0,0,.1);transition:background-color .2s cubic-bezier(0,0,.2,1),padding-bottom .2s cubic-bezier(0,0,.2,1)}.bb-dashboard-sidebar-group.expanded{background-color:rgba(0,0,0,.04)}.bb-dashboard-sidebar-group.expanded .bb-dashboard-sidebar-group-title{color:#000}.bb-dashboard-sidebar-group.expanded .bb-dashboard-sidebar-item{opacity:1;height:32px;line-height:32px;padding:6px 16px}.bb-dashboard-sidebar-group.expanded .bb-dashboard-sidebar-group-toggle{opacity:0;-ms-transform:translateX(10px);transform:translateX(10px)}.bb-dashboard-sidebar-group.with-toggle.expanded{padding-bottom:20px}.bb-dashboard-sidebar-group.has-icon .bb-dashboard-sidebar-item{padding-left:54px}.bb-dashboard-sidebar-group.disabled{opacity:.5}.bb-dashboard-sidebar-group-title{margin:0;width:100%;border:none;display:-ms-flexbox;display:flex;cursor:pointer;text-align:left;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-ms-flex-align:center;align-items:center;padding:17px 15px;color:rgba(0,0,0,.8);background-color:transparent;transition:color .2s cubic-bezier(0,0,.2,1)}.bb-dashboard-sidebar-group-title:active>.bb-dashboard-sidebar-group-toggle{background-color:rgba(0,0,0,.08)}.bb-dashboard-sidebar-group-icon{margin-right:15px;color:rgba(0,0,0,.25)}.bb-dashboard-sidebar-group-text{width:100%;display:block;font-size:14px;max-width:100%;overflow:hidden;font-weight:500;line-height:15px;white-space:nowrap;text-overflow:ellipsis;text-transform:uppercase}.bb-dashboard-sidebar-group-toggle{width:22px;height:22px;display:-ms-flexbox;display:flex;min-width:22px;min-height:22px;margin-left:auto;border-radius:3px;-ms-flex-align:center;align-items:center;-ms-flex-pack:center;justify-content:center;transition:opacity .2s cubic-bezier(0,0,.2,1),transform .2s cubic-bezier(0,0,.2,1),background-color .2s cubic-bezier(0,0,.2,1)}.bb-dashboard-sidebar-group-toggle>svg{width:10px;height:10px;fill:rgba(0,0,0,.25)}"]
            }] }
];
/** @nocollapse */
BbDashboardSidebarGroup.ctorParameters = () => [
    { type: BbDashboardSidebar, decorators: [{ type: Optional }, { type: Host }] }
];
BbDashboardSidebarGroup.propDecorators = {
    id: [{ type: Input }],
    icon: [{ type: Input }],
    title: [{ type: Input }],
    onGroupClicked: [{ type: HostListener, args: ['click', ['$event'],] }]
};
if (false) {
    /** @type {?} */
    BbDashboardSidebarGroup.prototype.id;
    /** @type {?} */
    BbDashboardSidebarGroup.prototype.icon;
    /** @type {?} */
    BbDashboardSidebarGroup.prototype.title;
    /**
     * @type {?}
     * @private
     */
    BbDashboardSidebarGroup.prototype._isExpanded;
    /**
     * @type {?}
     * @private
     */
    BbDashboardSidebarGroup.prototype._subscription;
    /**
     * @type {?}
     * @protected
     */
    BbDashboardSidebarGroup.prototype._parent;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dashboard-sidebar-item/dashboard-sidebar-item.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
class BbDashboardSidebarItem {
    /**
     * @param {?} _sidebar
     * @param {?} _group
     */
    constructor(_sidebar, _group) {
        this._sidebar = _sidebar;
        this._group = _group;
        // Inputs.
        this.tabIndex = 0;
    }
    /**
     * @return {?}
     */
    onClick() {
        // Try to close the sidebar if it exists.
        // this will close it on mobile.
        return this._sidebar && this._sidebar.close();
    }
    /**
     * @return {?}
     */
    get attributeTabIndex() {
        // Make the items tabindex -1 so it can't
        // be tabbed to when the parent is not visible
        // or the parent is disabled.
        if (this.isHidden) {
            return -1;
        }
        // Else return the specified tabindex.
        return this.tabIndex;
    }
    /**
     * @return {?}
     */
    get isHidden() {
        return !this.isVisible || this.isDisabled;
    }
    /**
     * @private
     * @return {?}
     */
    get isVisible() {
        return this._group
            ? this._group.isExpanded
            : true;
    }
    /**
     * @private
     * @return {?}
     */
    get isDisabled() {
        return this._group
            ? this._group.disabled
            : false;
    }
}
BbDashboardSidebarItem.decorators = [
    { type: Component, args: [{
                selector: '[bb-dashboard-sidebar-item]',
                template: "<!--\r\n    The content between the tags will\r\n    be reflected here.\r\n-->\r\n<span class=\"bb-dashboard-sidebar-item-content\">\r\n    <ng-content></ng-content>\r\n</span>\r\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                encapsulation: ViewEncapsulation.None,
                preserveWhitespaces: false,
                host: {
                    'class': 'bb-dashboard-sidebar-item',
                    '[attr.tabindex]': 'attributeTabIndex',
                    '[attr.aria-hidden]': 'isHidden',
                    '(click)': 'onClick()'
                },
                styles: [".bb-dashboard-sidebar-item{height:0;opacity:0;padding:0;display:-ms-flexbox;display:flex;line-height:0;cursor:pointer;font-size:14px;font-weight:500;-ms-flex-align:center;align-items:center;text-decoration:none;will-change:opacity,height;color:rgba(0,0,0,.85)!important;transition:height .2s cubic-bezier(0,0,.2,1),opacity .2s cubic-bezier(0,0,.2,1) 50ms,color .2s cubic-bezier(0,0,.2,1),background-color .2s cubic-bezier(0,0,.2,1)}.bb-dashboard-sidebar-item:focus,.bb-dashboard-sidebar-item:hover{background-color:rgba(0,0,0,.02)}.bb-dashboard-sidebar-item:active{background-color:rgba(0,0,0,.04)}.bb-dashboard-sidebar-item.active,.bb-dashboard-sidebar-item.active:active,.bb-dashboard-sidebar-item.active:focus,.bb-dashboard-sidebar-item.active:hover{color:#000!important;background-color:rgba(0,0,0,.06)}.bb-dashboard-sidebar-item-content{max-width:100%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}"]
            }] }
];
/** @nocollapse */
BbDashboardSidebarItem.ctorParameters = () => [
    { type: BbDashboardSidebar, decorators: [{ type: Optional }, { type: Host }] },
    { type: BbDashboardSidebarGroup, decorators: [{ type: Optional }, { type: Host }] }
];
BbDashboardSidebarItem.propDecorators = {
    tabIndex: [{ type: Input }]
};
if (false) {
    /** @type {?} */
    BbDashboardSidebarItem.prototype.tabIndex;
    /**
     * @type {?}
     * @private
     */
    BbDashboardSidebarItem.prototype._sidebar;
    /**
     * @type {?}
     * @private
     */
    BbDashboardSidebarItem.prototype._group;
}

/**
 * @fileoverview added by tsickle
 * Generated from: lib/dashboard.module.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/** @type {?} */
const DECLARATIONS_EXPORTS = [
    BbDashboard,
    BbDashboardHeader,
    BbDashboardMenu,
    BbDashboardMenuItem,
    BbDashboardSidebar,
    BbDashboardSidebarGroup,
    BbDashboardSidebarItem
];
class DashboardModule {
}
DashboardModule.decorators = [
    { type: NgModule, args: [{
                imports: [CommonModule, RouterModule, ElementsModule],
                declarations: [...DECLARATIONS_EXPORTS],
                exports: [...DECLARATIONS_EXPORTS]
            },] }
];

/**
 * @fileoverview added by tsickle
 * Generated from: public_api.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */

/**
 * @fileoverview added by tsickle
 * Generated from: bravobit-bb-foundation-dashboard.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */

export { BbDashboard, BbDashboardHeader, BbDashboardMenu, BbDashboardMenuItem, BbDashboardSidebar, BbDashboardSidebarGroup, BbDashboardSidebarItem, DashboardModule };
//# sourceMappingURL=bravobit-bb-foundation-dashboard.js.map
