/**
 * @fileoverview added by tsickle
 * Generated from: components/modal/addons/modal-toolbar/modal-toolbar.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/*
 MIT License

 Copyright (c) 2019 Temainfo Software

 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
 in the Software without restriction, including without limitation the rights
 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the Software is
 furnished to do so, subject to the following conditions:
 The above copyright notice and this permission notice shall be included in all
 copies or substantial portions of the Software.
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 SOFTWARE.
 */
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, ViewChild } from '@angular/core';
import { ModalService } from '../../services/modal.service';
import { Subscription } from 'rxjs';
export class TlModalToolbar {
    /**
     * @param {?} modalService
     * @param {?} changes
     */
    constructor(modalService, changes) {
        this.modalService = modalService;
        this.changes = changes;
        this.containerColor = '';
        this.height = '30px';
        this.color = 'basic';
        this.modalBoxWidth = 150;
        this.limitStringBox = 12;
        this.isScrolling = false;
        this.subscription = new Subscription();
    }
    /**
     * @return {?}
     */
    ngOnInit() {
        this.subscribeFrontModal();
        this.subscribeChanges();
    }
    /**
     * @return {?}
     */
    subscribeFrontModal() {
        this.subscription.add(this.modalService.frontModal.subscribe((/**
         * @param {?} value
         * @return {?}
         */
        (value) => {
            this.activeModal = value.activeModal;
            this.changes.detectChanges();
        })));
    }
    /**
     * @return {?}
     */
    subscribeChanges() {
        this.subscription.add(this.modalService.changeModal.subscribe((/**
         * @return {?}
         */
        () => {
            this.validateScroll();
            this.changes.detectChanges();
        })));
    }
    /**
     * @param {?} item
     * @return {?}
     */
    showWindow(item) {
        this.modalService.showModal(item);
    }
    /**
     * @return {?}
     */
    validateScroll() {
        setTimeout((/**
         * @return {?}
         */
        () => {
            this.wrapper.nativeElement.offsetWidth >= this.container.nativeElement.offsetWidth ?
                this.isScrolling = true : this.isScrolling = false;
        }), 1);
    }
    /**
     * @return {?}
     */
    handleArrowRight() {
        if (this.container.nativeElement.scrollLeft < this.wrapper.nativeElement.offsetWidth) {
            this.container.nativeElement.scrollLeft += 300;
        }
        this.handleScrollFinish();
    }
    /**
     * @return {?}
     */
    handleArrowLeft() {
        if (this.container.nativeElement.scrollLeft > 0) {
            this.container.nativeElement.scrollLeft -= 300;
        }
        this.handleScrollFinish();
    }
    /**
     * @return {?}
     */
    handleScrollFinish() {
        /** @type {?} */
        const scrollLeft = this.container.nativeElement.scrollLeft + this.container.nativeElement.offsetWidth;
        this.isScrolling = scrollLeft >= this.wrapper.nativeElement.offsetWidth;
    }
    /**
     * @return {?}
     */
    ngOnDestroy() {
        this.subscription.unsubscribe();
    }
}
TlModalToolbar.decorators = [
    { type: Component, args: [{
                selector: 'tl-modal-toolbar',
                template: "<div [class]=\"'container-wrapper '+ color\">\n     <span [style.lineHeight]=\"height\"\n           (click)=\"handleArrowLeft()\" *ngIf=\"container.scrollLeft > 0\" class=\"arrow-left\">\n       <tl-icon [lib]=\"'ion'\" [style]=\"'ios'\">arrow-back</tl-icon>\n     </span>\n    <div #container [style.height]=\"height\" [style.background-color]=\"containerColor\" class=\"container-modals\">\n      <div #wrapper class=\"wrapper-container-modals\" [style.line-height]=\"height\" [ngStyle]=\"\n      {position: 'absolute'}\">\n          <div class=\"container-modal-box\"\n               [style.width]=\"modalBoxWidth + 'px'\"\n               [style.height]=\"'calc(' + height  + ' - 6px)'\"\n               [style.lineHeight]=\"'calc(' + height + ' - 6px)'\"\n               *ngFor=\"let item of modalService.componentList; let i = index\" (click)=\"showWindow(item.modal)\"\n               [style.opacity]=\"item?.modal === modalService?.activeModal ? 1 : 0.7\">\n              <span class=\"ui-container-item ui-container-icon\"><tl-icon>{{ item?.modal?.instance?.icon }}</tl-icon></span>\n              <span class=\"ui-container-item ui-container-text\">{{item?.modal?.instance?.title}}</span>\n          </div>\n      </div>\n    </div>\n    <span [style.lineHeight]=\"height\" (click)=\"handleArrowRight()\" *ngIf=\"isScrolling\" class=\"arrow-right\">\n      <tl-icon [lib]=\"'ion'\" [style]=\"'ios'\">arrow-forward</tl-icon>\n    </span>\n</div>\n",
                changeDetection: ChangeDetectionStrategy.OnPush,
                styles: [".container-wrapper{-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;position:relative;user-select:none}.container-wrapper>.arrow-right{border-left:0;box-sizing:border-box;height:100%;padding:0 5px;position:absolute;right:0;top:0}.container-wrapper>.arrow-right:hover{cursor:pointer}.container-wrapper>.arrow-left{border-right:0;box-sizing:border-box;height:100%;left:0;padding:0 5px;position:absolute;top:0;z-index:100}.container-wrapper>.arrow-left:hover{cursor:pointer}.container-modals{box-sizing:border-box;overflow:auto;overflow-y:hidden;position:relative;width:100%}.container-modals>.wrapper-container-modals{display:inline-flex}.container-modals>.wrapper-container-modals>.container-modal-box{box-sizing:border-box;cursor:pointer;margin:2px 0 2px 2px;padding-right:5px}.container-modals>.wrapper-container-modals>.container-modal-box>.ui-container-item{display:block;float:left;font-family:Segoe UI,Lato,\"sans-serif\",Arial;font-size:13px}.container-modals>.wrapper-container-modals>.container-modal-box>.ui-container-icon{text-align:center;width:20%}.container-modals>.wrapper-container-modals>.container-modal-box>.ui-container-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:80%}.container-modals::-webkit-scrollbar{height:0}"]
            }] }
];
/** @nocollapse */
TlModalToolbar.ctorParameters = () => [
    { type: ModalService },
    { type: ChangeDetectorRef }
];
TlModalToolbar.propDecorators = {
    containerColor: [{ type: Input }],
    height: [{ type: Input }],
    color: [{ type: Input }],
    modalBoxWidth: [{ type: Input }],
    limitStringBox: [{ type: Input }],
    container: [{ type: ViewChild, args: ['container', { static: true },] }],
    wrapper: [{ type: ViewChild, args: ['wrapper', { static: true },] }]
};
if (false) {
    /** @type {?} */
    TlModalToolbar.prototype.containerColor;
    /** @type {?} */
    TlModalToolbar.prototype.height;
    /** @type {?} */
    TlModalToolbar.prototype.color;
    /** @type {?} */
    TlModalToolbar.prototype.modalBoxWidth;
    /** @type {?} */
    TlModalToolbar.prototype.limitStringBox;
    /** @type {?} */
    TlModalToolbar.prototype.container;
    /** @type {?} */
    TlModalToolbar.prototype.wrapper;
    /** @type {?} */
    TlModalToolbar.prototype.isScrolling;
    /** @type {?} */
    TlModalToolbar.prototype.activeModal;
    /**
     * @type {?}
     * @private
     */
    TlModalToolbar.prototype.subscription;
    /** @type {?} */
    TlModalToolbar.prototype.modalService;
    /**
     * @type {?}
     * @private
     */
    TlModalToolbar.prototype.changes;
}
//# sourceMappingURL=data:application/json;base64, 