/*!
 *
 * carbon-angular v0.0.5 | sidenav-item.component.js
 *
 * Copyright 2014, 2019 IBM
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0

 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


import { Component, Input, Optional, Output, EventEmitter } from "@angular/core";
import { DomSanitizer } from "@angular/platform-browser";
import { Router } from "@angular/router";
/**
 * `SideNavItem` can either be a child of `SideNav` or `SideNavMenu`
 */
var SideNavItem = /** @class */ (function () {
    function SideNavItem(domSanitizer, router) {
        this.domSanitizer = domSanitizer;
        this.router = router;
        /**
         * Toggles the active (current page) state for the link.
         */
        this.active = false;
        /**
         * Emits the navigation status promise when the link is activated
         */
        this.navigation = new EventEmitter();
        this.isSubMenu = false;
        this._href = "javascript:void(0)";
    }
    Object.defineProperty(SideNavItem.prototype, "href", {
        get: function () {
            return this.domSanitizer.bypassSecurityTrustUrl(this._href);
        },
        /**
         * Link for the item. NOTE: *do not* pass unsafe or untrusted values, this has the potential to open you up to XSS attacks
         */
        set: function (v) {
            this._href = v;
        },
        enumerable: true,
        configurable: true
    });
    SideNavItem.prototype.navigate = function (event) {
        if (this.router && this.route) {
            event.preventDefault();
            var status_1 = this.router.navigate(this.route, this.routeExtras);
            this.navigation.emit(status_1);
        }
    };
    SideNavItem.decorators = [
        { type: Component, args: [{
                    selector: "ibm-sidenav-item",
                    template: "\n\t\t<li [ngClass]=\"{\n\t\t\t'bx--side-nav__item': !isSubMenu,\n\t\t\t'bx--side-nav__menu-item': isSubMenu\n\t\t}\"\n\t\t[attr.role]=\"(isSubMenu ? 'none' : null)\">\n\t\t\t<a\n\t\t\t\tclass=\"bx--side-nav__link\"\n\t\t\t\t[href]=\"href\"\n\t\t\t\t[attr.role]=\"(isSubMenu ? 'menuitem' : null)\"\n\t\t\t\t[attr.aria-current]=\"(active ? 'page' : null)\"\n\t\t\t\t(click)=\"navigate($event)\">\n\t\t\t\t<div *ngIf=\"!isSubMenu\" class=\"bx--side-nav__icon\">\n\t\t\t\t\t<ng-content select=\"[icon]\"></ng-content>\n\t\t\t\t</div>\n\t\t\t\t<span class=\"bx--side-nav__link-text\">\n\t\t\t\t\t<ng-content></ng-content>\n\t\t\t\t</span>\n\t\t\t</a>\n\t\t</li>\n\t"
                },] },
    ];
    /** @nocollapse */
    SideNavItem.ctorParameters = function () { return [
        { type: DomSanitizer },
        { type: Router, decorators: [{ type: Optional }] }
    ]; };
    SideNavItem.propDecorators = {
        href: [{ type: Input }],
        active: [{ type: Input }],
        route: [{ type: Input }],
        routeExtras: [{ type: Input }],
        navigation: [{ type: Output }]
    };
    return SideNavItem;
}());
export { SideNavItem };
//# sourceMappingURL=sidenav-item.component.js.map