var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import { Component, ElementRef, OnInit, Renderer2, ViewChild } from '@angular/core';
import { Router, Event, NavigationStart } from '@angular/router';
import { filter } from 'rxjs/operators';
import { Constants } from '../../core.consts';
import { CartService } from '../../services/cart.service';
import { OptionsService } from '../../services/options.service';
import { ParametersService } from '../../services/parameters.service';
import { ProductsService } from '../../services/products/products.service';
import { AuthService } from '../../services/auth.service';
import { ComponentHelper } from '../../classes/component-helper';
import { TranslateService } from '@ngx-translate/core';
let HeaderEcComponent = class HeaderEcComponent extends ComponentHelper {
    constructor(router, consts, cartService, optionsService, paramsService, productsService, authService, translate, renderer) {
        super();
        this.router = router;
        this.consts = consts;
        this.cartService = cartService;
        this.optionsService = optionsService;
        this.paramsService = paramsService;
        this.productsService = productsService;
        this.authService = authService;
        this.translate = translate;
        this.renderer = renderer;
        //og elden
        this.menuItems = [];
        this.menuSections = [];
        this.attributes = [];
        this.categories = [];
        this.envetUrlTransparent = ["/home", "/"];
        this.params = {};
        this.toggled = false;
        this.updateMenuItem = (title, elements) => {
            const index = this.menuItems.findIndex(element => element.title == title);
            if (index != null && index >= 0) {
                this.menuItems[index].children = this.optionsService.generateMenu(elements);
            }
            else {
                if (title == 'attributes') {
                    this.attributes.push(...this.optionsService.generateMenu(elements));
                    this.attributes = this.updateMenuItemLastCreated(this.attributes);
                }
                if (title == 'categories') {
                    this.categories.push(...this.optionsService.generateMenu(elements));
                    this.categories = this.updateMenuItemLastCreated(this.categories);
                }
            }
        };
        this.nagivate = (url) => this.router.navigateByUrl(`/${url}`);
        this.logout = () => {
            this.authService.logout();
            this.router.navigateByUrl('home');
        };
        this.setSearchValue = (event) => {
            event.key == 'Enter' && this.getCollectionSearch();
            this.searchValue = event.target.value;
        };
        this.getCollectionSearch = () => this.router.navigateByUrl('/collection?search=' + this.searchValue);
        this.toogleToolbar = () => {
            console.log('LLAMA AL TOOGLE');
            if (this.menu_button.nativeElement.classList.contains('d-none')) {
                this.renderer.removeClass(this.menu_button, 'd-none');
                this.renderer.addClass(this.menu_button, 'active-mobile');
            }
            else {
                this.renderer.addClass(this.menu_button, 'd-none');
                this.renderer.removeClass(this.menu_button, 'active-mobile');
            }
        };
        this.changeLanguage = (lang) => {
            this.consts.setLocale(lang);
            window.location.reload();
        };
        this.changeUrlTransparent = (urlTransparent = []) => urlTransparent;
        this.subscribeAttributes = (arrayAttributes) => {
        };
        this.subscribeCategories = (arrayCategories) => {
        };
        this.updateMenuItemLastCreated = (arrayMenu) => arrayMenu;
        this.changeUrlNavigation = (url) => { };
        this.envetUrlTransparent = this.changeUrlTransparent(this.envetUrlTransparent);
        this.router.events.subscribe((event) => {
            if (event instanceof NavigationStart) {
                const url = event.url;
                this.changeUrlNavigation(url);
                this.envetUrlTransparent.find(evUrl => evUrl === url) != undefined
                    ? this.transparent = true
                    : this.transparent = false;
            }
        });
        // menu
        this.optionsService.categories.pipe(filter(cat => cat.length > 0)).subscribe(res => {
            this.updateMenuItem('categories', res);
            this.subscribeCategories(res);
        });
        this.optionsService.attributes.pipe(filter(atr => atr.length > 0)).subscribe(res => {
            this.updateMenuItem('attributes', res);
            this.subscribeAttributes(res);
        });
        this.ecOnConstruct();
    }
    ngOnInit() {
        this.paramsService.parameters.subscribe(res => this.params = res);
        const mediaQuery = window.matchMedia('(max-width: 992px)');
        this.mediaMenu = mediaQuery.matches;
        this.ecOnInit();
    }
};
HeaderEcComponent.ctorParameters = () => [
    { type: Router },
    { type: Constants },
    { type: CartService },
    { type: OptionsService },
    { type: ParametersService },
    { type: ProductsService },
    { type: AuthService },
    { type: TranslateService },
    { type: Renderer2 }
];
__decorate([
    ViewChild("menu")
], HeaderEcComponent.prototype, "menu_button", void 0);
HeaderEcComponent = __decorate([
    Component({
        selector: 'app-header-ec',
        template: "<!-- <header [class]=\"(!transparent ? 'no-banner' : '')\" id=\"header-principal\">\n     <div class=\"row border-color-buttom-gray m-0 d-none d-md-block\" id=\"novedades\">\n          <div class=\"col-12 py-2\">\n               {{ (params && params.header) || 'Sin informaci\u00F3n de cabecera' }}\n          </div>\n     </div>\n     <div class=\"row encabezado-superior m-0 d-flex justify-content-center\" id=\"top-menu-principal\">\n          <div class=\"col-md-6 col-3 p-md-3 p-2\">\n               <a routerLink=\"/home\">\n                    <img src=\"assets/image/logo.png\" id=\"logo-superior\" class=\"ml-md-4 ml-1\">\n               </a>\n          </div>\n          <div class=\"col-md-6 col-9 px-md-5 px-2 d-flex align-items-center justify-content-end\">\n               <ul class=\"nav d-flex align-items-center justify-content-end\">\n                    <li class=\"px-2 outside-menu\">\n                         <div class=\"order-3 order-lg-1 input-search pt-3\">\n                              <form (submit)=\"$event.preventDefault()\" class=\"navbar-form navbar-left m-1\">\n                                   <div class=\"input-group input-group-sm mb-3\" >\n                                        <input type=\"text\" class=\"form-control input-rounded bg-transparent border-left-none\" placeholder=\"Buscar producto\"\n                                             aria-label=\"Username\" aria-describedby=\"basic-addon1\"  (keyup)=\"setSearchValue($event)\">\n                                        <div class=\"input-group-prepend\" (click)=\"getCollectionSearch()\" role=\"button\">\n                                             <span class=\"input-group-text icon-rounded bg-transparent border-right-none\" id=\"basic-addon1\">\n                                                  <a class=\"color-white\"><img src=\"assets/svg/search.svg\"></a>\n                                             </span>\n                                        </div>\n                                   </div>\n                              </form>\n                         </div>\n                    </li>\n                    <li class=\"px-2 outside-menu\">\n                         <a routerLink=\"cart\" class=\"color-white\"><img src=\"assets/svg/cart.svg\"></a>\n                    </li>\n                    <li class=\"px-2 outside-menu\">\n                         <a [routerLink]=\"'/account'\" *ngIf=\"(authService.loggedIn | async); else sessionOptionsViewMobile\" class=\"color-white\"><img src=\"assets/svg/user.svg\"></a>\n                         <ng-template #sessionOptionsViewMobile>\n                              <a [routerLink]=\"'/auth/login'\" class=\"color-white\"><img src=\"assets/svg/user.svg\"></a>\n                         </ng-template>\n                    </li>\n                    <li class=\"px-2 outside-menu\">\n                         <a disabled style=\"vertical-align: -webkit-ecline-middle;\"\n                              class=\"color-white ff-ubuntu-light font-sm\">ES</a>\n                    </li>\n                    <li class=\"px-2 d-inline-block d-md-none\">\n                         <a id=\"openMenu\" class=\"color-white\" (click)=\"toogleToolbar()\">\n                              <img src=\"assets/svg/menu.svg\" class=\"open-m\" >\n                              <img src=\"assets/svg/close.svg\" class=\"close-m\">\n                         </a>\n                    </li>\n               </ul>\n          </div>\n          <div class=\"col-11 border-color-buttom-gray d-none d-md-block\"></div>\n     </div>\n     <nav class=\"py-md-3 py-0 w-100 d-none d-md-block\" id=\"menu-principal\" #menu>\n          <ul class=\"nav d-flex flex-md-row flex-column justify-content-center\">\n               <li class=\"dropdown separador-left\">\n                    <a class=\"dropdown-toggle color-white color-hover-golden ff-ubuntu-light py-md-2 py-3 px-4 font-sm\"\n                         data-toggle=\"dropdown\" aria-haspopup=\"true\" aria-expanded=\"false\" data-target=\"#buscador\"\n                         role=\"button\">\n                         CAT\u00C1LOGO\n                    </a>\n                    <ul class=\"dropdown-menu mega-menu dropdown-menu-right mt-md-2 mt-0\" role=\"menu\">\n                         <div class=\"flex-md-row flex-column py-0 d-flex align-items-start justify-content-center\">\n                              <div class=\"row mega-menu-center px-md-3 px-0\">\n                                   <div class=\"col-sm py-3 box-submenu\"\n                                        *ngFor=\"let category of categories; let i = index\">\n                                        <div class=\"row\">\n                                             <div class=\"col-3 col-md-4 p-0\">\n                                                  <img [src]=\"consts.mediaUrl() + category.images[0].path\"\n                                                       class=\"w-100\">\n                                             </div>\n                                             <div class=\"col-9 col-md-8 py-2 pr-0\">\n                                                  <a [routerLink]=\"category.path\">\n                                                       <h5 class=\"ff-ubuntu-semi-bold font-xl\">{{ category.title }}</h5>\n                                                  </a>\n                                                  <ul\n                                                       class=\"nav d-md-flex d-none flex-column font-ss ff-ubuntu color-white submenu\">\n                                                       <li class=\"text-uppercase mb-2\"\n                                                            *ngFor=\"let child of category.children\">\n                                                            <a [routerLink]=\"child.path\">\n                                                                 {{ child.title }}\n                                                            </a>\n                                                       </li>\n                                                  </ul>\n                                             </div>\n                                        </div>\n                                   </div>\n                              </div>\n                         </div>\n                    </ul>\n               </li>\n               <li class=\"dropdown separador-left\">\n                    <a [routerLink]=\"'collection/'\"\n                         class=\"color-white color-hover-golden ff-ubuntu-light py-md-2 py-3 px-4 font-sm\"\n                         role=\"button\">\n                         NOVEDADES\n                    </a>\n               </li>\n               <li class=\"dropdown separador-left\">\n                    <a [routerLink]=\"'/collection/attributes/ofertas'\"\n                         class=\"color-white color-hover-golden ff-ubuntu-light py-md-2 py-3 px-4 font-sm\"\n                         role=\"button\">\n                         OFERTAS\n                    </a>\n               </li>\n               <li class=\"dropdown separador-left\">\n                    <a [routerLink]=\"'/section/quienes-somos'\"\n                         class=\"color-white color-hover-golden ff-ubuntu-light py-md-2 py-3 px-4 font-sm\"\n                         role=\"button\">\n                         QUIENES SOMOS\n                    </a>\n               </li>\n               <li class=\"dropdown separador-left\">\n                    <a [routerLink]=\"'/contact'\"\n                         class=\"color-white color-hover-golden ff-ubuntu-light py-md-2 py-3 px-4 font-sm\"\n                         role=\"button\">\n                         CONTACTO\n                    </a>\n               </li>\n          </ul>\n     </nav>\n</header> -->",
        styles: [".no-banner{position:relative!important}"]
    })
], HeaderEcComponent);
export { HeaderEcComponent };
//# sourceMappingURL=data:application/json;base64, 