import { __decorate } from "tslib";
import { ChangeDetectionStrategy, Component, Input, OnDestroy, OnInit, Renderer2, ViewEncapsulation } from '@angular/core';
import { Patch, Platform } from '@bravobit/bb-foundation';
import { BehaviorSubject } from 'rxjs';
var BbDashboard = /** @class */ (function () {
    function BbDashboard(_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);
    }
    Object.defineProperty(BbDashboard.prototype, "visibility", {
        get: function () {
            return this.sidebarVisible$.asObservable();
        },
        enumerable: true,
        configurable: true
    });
    BbDashboard.prototype.ngOnInit = function () {
        // Set the vertical height for mobile devices.
        this._patch.mobileVerticalHeight();
        // Set the HTML class to prevent scrolling.
        return this.setHtmlClass();
    };
    BbDashboard.prototype.ngOnDestroy = function () {
        // Remove the HTML class.
        this.setHtmlClass(true);
    };
    BbDashboard.prototype.toggleSidebarVisibility = function () {
        // Get the previous value.
        var previousValue = this.sidebarVisible$.getValue();
        // Invert the value and set the visibility.
        this.setSidebarVisibility(!previousValue);
    };
    BbDashboard.prototype.setSidebarVisibility = function (newValue) {
        this.sidebarVisible$.next(newValue);
    };
    BbDashboard.prototype.setHtmlClass = function (shouldRemove) {
        if (shouldRemove === void 0) { shouldRemove = false; }
        // Check if we are on a browser.
        if (!this._platform.isBrowser) {
            return;
        }
        // Define the class name.
        var className = 'bb-dashboard-html';
        // Add or remove the class.
        return shouldRemove
            ? this._renderer.removeClass(document.documentElement, className)
            : this._renderer.addClass(document.documentElement, className);
    };
    BbDashboard.ctorParameters = function () { return [
        { type: Patch },
        { type: Platform },
        { type: Renderer2 }
    ]; };
    __decorate([
        Input()
    ], BbDashboard.prototype, "backgroundColor", void 0);
    __decorate([
        Input()
    ], BbDashboard.prototype, "maxWidth", void 0);
    __decorate([
        Input()
    ], BbDashboard.prototype, "padding", void 0);
    BbDashboard = __decorate([
        Component({
            selector: 'bb-dashboard',
            template: "<!--\n    The outlet for where the sidebar\n    will be placed (if provided).\n-->\n<ng-content select=\"bb-dashboard-sidebar\">\n</ng-content>\n\n<!--\n    The section containing the header\n    and the main content.\n-->\n<section [style.background-color]=\"backgroundColor\"\n         class=\"bb-dashboard-section\">\n    <!--\n        The outlet for where the header\n        will be placed (if provided).\n    -->\n    <ng-content select=\"bb-dashboard-header\">\n    </ng-content>\n\n    <!--\n        The outlet of the content that\n        will be provided by the router.\n    -->\n    <main [style.padding]=\"padding\"\n          class=\"bb-dashboard-scroll\">\n        <div [style.max-width]=\"maxWidth\"\n             class=\"bb-dashboard-container\">\n            <ng-content select=\"bb-dashboard-menu\"></ng-content>\n\n            <ng-content></ng-content>\n        </div>\n        <!--\n            The outlet for where the footer\n            will be placed (if provided).\n        -->\n        <ng-content select=\"bb-dashboard-footer\">\n        </ng-content>\n    </main>\n</section>\n\n<!--\n    The backdrop that will be visible when\n    the sidebar is opened (only on mobile).\n-->\n<div [class.bb-dashboard-backdrop--visible]=\"!(visibility | async)\"\n     (click)=\"toggleSidebarVisibility()\"\n     class=\"bb-dashboard-backdrop\">\n</div>\n",
            changeDetection: ChangeDetectionStrategy.OnPush,
            encapsulation: ViewEncapsulation.None,
            preserveWhitespaces: false,
            host: {
                'class': 'bb-dashboard'
            },
            styles: [".bb-dashboard{height:100vh;display:-webkit-box;display:-ms-flexbox;display:flex;overflow:hidden;position:relative;height:calc(var(--vh,1vh) * 100)}.bb-dashboard-section{-webkit-box-flex:1;-ms-flex:1;flex:1;height:100vh;display:-webkit-box;display:-ms-flexbox;display:flex;overflow-x:hidden;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;height:calc(var(--vh,1vh) * 100)}.bb-dashboard-scroll{-webkit-box-flex:1;-ms-flex:1;flex:1;display:-webkit-box;display:-ms-flexbox;display:flex;overflow-x:hidden;overflow-y:scroll;-webkit-box-orient:vertical;-webkit-box-direction:normal;-ms-flex-direction:column;flex-direction:column;-webkit-overflow-scrolling:touch}.bb-dashboard-container{width:100%;display:-webkit-box;display:-ms-flexbox;display:flex;margin:0 auto;-webkit-box-orient:vertical;-webkit-box-direction:normal;-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);-webkit-transition:opacity .2s cubic-bezier(0,0,.2,1);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}"]
        })
    ], BbDashboard);
    return BbDashboard;
}());
export { BbDashboard };
//# sourceMappingURL=data:application/json;base64, 