(function (factory) {
    if (typeof module === "object" && typeof module.exports === "object") {
        var v = factory(require, exports);
        if (v !== undefined) module.exports = v;
    }
    else if (typeof define === "function" && define.amd) {
        define(["require", "exports", "@angular/core", "./leaflet-map.service", "@fortawesome/free-solid-svg-icons", "@angular/cdk/drag-drop", "./AlertControllerComponent"], factory);
    }
})(function (require, exports) {
    "use strict";
    /**
     * @fileoverview added by tsickle
     * Generated from: lib/leaflet-map.component.ts
     * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
     */
    Object.defineProperty(exports, "__esModule", { value: true });
    const core_1 = require("@angular/core");
    const leaflet_map_service_1 = require("./leaflet-map.service");
    const free_solid_svg_icons_1 = require("@fortawesome/free-solid-svg-icons");
    const drag_drop_1 = require("@angular/cdk/drag-drop");
    const AlertControllerComponent_1 = require("./AlertControllerComponent");
    class LeafletMapComponent {
        /**
         * @param {?} leafletMapService
         */
        constructor(leafletMapService) {
            this.leafletMapService = leafletMapService;
            this.searchText = '';
            this.isCollapsed = true;
            this.geojson = [];
            this.shareIntent = new core_1.EventEmitter();
            this.icons = { faShareSquare: free_solid_svg_icons_1.faShareSquare, faEye: free_solid_svg_icons_1.faEye, faEyeSlash: free_solid_svg_icons_1.faEyeSlash, faSearch: free_solid_svg_icons_1.faSearch, faMapPin: free_solid_svg_icons_1.faMapPin, faChevronLeft: free_solid_svg_icons_1.faChevronLeft, faChevronRight: free_solid_svg_icons_1.faChevronRight };
            this.allCamadasEnable = true;
            this.featureCollection = [];
        }
        /**
         * @return {?}
         */
        ngAfterViewInit() {
            this.mapController = this.leafletMapService.createMap(this.divMap.nativeElement, { updateOnResize: true });
            if (this.geojson && this.geojson.length) {
                this.addGeoJsons(this.geojson);
            }
        }
        /**
         * @param {?} state
         * @return {?}
         */
        alterShowMenu(state) {
            this.showMenu = state;
            this.mapController.refreshMap();
        }
        /**
         * @param {?} geojson
         * @return {?}
         */
        addGeoJson(geojson) {
            this.featureCollection = this.mapController.addCamadas([geojson]);
        }
        /**
         * @param {?} geojson
         * @return {?}
         */
        addGeoJsons(geojson) {
            this.featureCollection = this.mapController.addCamadas(geojson);
        }
        /**
         * @private
         * @return {?}
         */
        checkAllCamadasEnable() {
            this.allCamadasEnable = !this.featureCollection.find((/**
             * @param {?} i
             * @return {?}
             */
            i => !i.isEnable));
        }
        /**
         * @param {?} event
         * @param {?} camada
         * @return {?}
         */
        updateCamadaStatus(event, camada) {
            /** @type {?} */
            const checked = event.checked;
            checked ? this.mapController.enableCamada(camada) : this.mapController.disableCamada(camada);
            this.checkAllCamadasEnable();
        }
        /**
         * @param {?} camada
         * @return {?}
         */
        selectCamada(camada) {
            this.mapController.zoonInCamada(camada);
        }
        /**
         * @return {?}
         */
        share() {
            /** @type {?} */
            const camadasEnabledInJson = this.featureCollection
                .filter((/**
             * @param {?} i
             * @return {?}
             */
            i => i.isEnable))
                .map((/**
             * @param {?} i
             * @return {?}
             */
            i => (/** @type {?} */ (i.featureGroup.toGeoJSON()))));
            if (!camadasEnabledInJson.length) {
                this.errorAlert.addError('nenhuma camada selecionada');
                console.error('nenhuma camada selecionada');
            }
            else {
                this.shareIntent.emit(camadasEnabledInJson);
            }
        }
        /**
         * @param {?} event
         * @return {?}
         */
        listCamadasChengeOrder(event) {
            drag_drop_1.moveItemInArray(this.featureCollection, event.previousIndex, event.currentIndex);
        }
    }
    LeafletMapComponent.decorators = [
        { type: core_1.Component, args: [{
                    selector: 'lib-leaflet-map',
                    template: "<link href=\"https://fonts.googleapis.com/css?family=Roboto:300,400,500&display=swap\" rel=\"stylesheet\">\n<link href=\"https://fonts.googleapis.com/icon?family=Material+Icons\" rel=\"stylesheet\">\n<lib-leaflet-map-alert #errorAlert></lib-leaflet-map-alert>\n<div class=\"conteiner h-100\">\n    <div class=\"mapDiv w-75\" [ngClass]=\"{'w-75':showMenu,'w-100':!showMenu}\">\n        <div #divMap>\n            <div *ngIf=\"canShowMenu && !showMenu\" class=\"btn-group float-right h-100 showMenu\" style=\"z-index: 1001\">\n                <button type=\"buttons\" id=\"others\" (click)=\"alterShowMenu(true)\"\n                    class=\"btn-showMenu btn-showMenu-show btn-warning\">\n                    <fa-icon [icon]=\"icons.faChevronLeft\"></fa-icon>\n                </button>\n            </div>\n        </div>\n    </div>\n    <div *ngIf=\"showMenu\" class=\"camadasDiv\">\n        <div class=\"card h-100\" style=\"width: 18rem;\">\n            <div class=\"card-header h-10 text-center\">\n                <button *ngIf=\"canShowMenu\" type=\"buttons\" id=\"others\" (click)=\"alterShowMenu(false)\"\n                    class=\"leaflet-control-layers-toggle btn-showMenu btn-showMenu btn-showMenu-hide\">\n                    <fa-icon [icon]=\"icons.faChevronRight\"></fa-icon>\n                </button>\n                <div>\n                    <div class=\"float-left\">\n                        <small id=\"emailHelp\" class=\"form-text text-muted\">\n                            <fa-icon [icon]=\"icons.faEye\"></fa-icon>\n                        </small>\n                        <mat-slide-toggle [checked]=\"allCamadasEnable\" (change)=\"updateCamadaStatus($event,null)\">\n                        </mat-slide-toggle>\n                    </div>\n                    <button type=\"button\" class=\"btn btn-outline\" (click)=\"isCollapsed = !isCollapsed\"\n                        [attr.aria-expanded]=\"!isCollapsed\" aria-controls=\"collapseExample\">\n                        <fa-icon [icon]=\"icons.faSearch\"></fa-icon>\n                    </button>Camadas\n                    <fa-icon class=\"float-right\" (click)=\"share()\" [icon]=\"icons.faShareSquare\"></fa-icon>\n                </div>\n                <div id=\"collapseExample\" [ngbCollapse]=\"isCollapsed\">\n                    <input [(ngModel)]=\"searchText\" #ctrl=\"ngModel\" class=\"form-control\" placeholder=\"Procurar...\">\n\n                </div>\n            </div>\n            <ul class=\"list-group listaCamadas h-100\" cdkDropList (cdkDropListDropped)=\"listCamadasChengeOrder($event)\">\n                <li *ngFor=\"let item of featureCollection | filter : searchText\" cdkDrag\n                    class=\"list-group-item list-group-item-action text-center\">\n                    <div class=\"itemSelect\">\n                        <div class=\"float-left\">\n                            <small id=\"emailHelp\" class=\"form-text text-muted\">\n                                <fa-icon *ngIf=\"!item.isEnable\" [icon]=\"icons.faEyeSlash\"></fa-icon>\n                            </small>\n                            <mat-slide-toggle id=\"{{this.id+''+item.name}}\" [checked]=\"item.isEnable\"\n                                (change)=\"updateCamadaStatus($event,item.name)\"></mat-slide-toggle>\n                        </div>\n                        <label class=\"form-check-label text-center\">{{item.name}}</label>\n                        <button class=\"btn btn-outline-warning float-right\" (click)=\"selectCamada(item.name)\">\n                            <fa-icon [icon]=\"icons.faMapPin\">\n                            </fa-icon>\n                        </button>\n                    </div>\n                    <div class=\"cardDivider\" [ngStyle]=\"{'background-color':item.color}\"></div>\n                </li>\n            </ul>\n        </div>\n    </div>",
                    styles: ["body{margin:0;font-family:Roboto,\"Helvetica Neue\",sans-serif}.mapDiv div{height:100%}.container{max-width:unset}.col-3,.col-4,.col-8,.col-9{padding:0}.itemSelect{position:relative}.btn-showMenu{width:36px;height:36px;border-radius:5px 0 0 5px;border:unset}.btn-showMenu-show{margin-top:22vh;box-shadow:-3px 3px rgba(0,0,0,.288)}.btn-showMenu-hide{position:absolute;top:0;left:0;background:0 0}.listaCamadas{overflow:scroll}.conteiner{display:-webkit-box;display:flex;-webkit-box-pack:center;justify-content:center}lib-leaflet-map-alert{position:absolute;top:0;z-index:10000;width:100%}::-webkit-scrollbar{width:10px}::-webkit-scrollbar-track{background:#f1f1f1}::-webkit-scrollbar-thumb{background:#888}::-webkit-scrollbar-thumb:hover{background:#555}.cardDivider{height:1vh;width:100%;position:absolute;top:0;left:0}"]
                }] }
    ];
    /** @nocollapse */
    LeafletMapComponent.ctorParameters = () => [
        { type: leaflet_map_service_1.LeafletMapService }
    ];
    LeafletMapComponent.propDecorators = {
        geojson: [{ type: core_1.Input }],
        id: [{ type: core_1.Input }],
        canShowMenu: [{ type: core_1.Input }],
        showMenu: [{ type: core_1.Input }],
        divMap: [{ type: core_1.ViewChild, args: ['divMap', { static: false },] }],
        errorAlert: [{ type: core_1.ViewChild, args: ['errorAlert', { static: false },] }],
        shareIntent: [{ type: core_1.Output }]
    };
    exports.LeafletMapComponent = LeafletMapComponent;
    if (false) {
        /** @type {?} */
        LeafletMapComponent.prototype.searchText;
        /** @type {?} */
        LeafletMapComponent.prototype.isCollapsed;
        /** @type {?} */
        LeafletMapComponent.prototype.geojson;
        /** @type {?} */
        LeafletMapComponent.prototype.id;
        /** @type {?} */
        LeafletMapComponent.prototype.canShowMenu;
        /** @type {?} */
        LeafletMapComponent.prototype.showMenu;
        /** @type {?} */
        LeafletMapComponent.prototype.divMap;
        /** @type {?} */
        LeafletMapComponent.prototype.errorAlert;
        /** @type {?} */
        LeafletMapComponent.prototype.shareIntent;
        /** @type {?} */
        LeafletMapComponent.prototype.icons;
        /** @type {?} */
        LeafletMapComponent.prototype.allCamadasEnable;
        /** @type {?} */
        LeafletMapComponent.prototype.mapController;
        /** @type {?} */
        LeafletMapComponent.prototype.featureCollection;
        /** @type {?} */
        LeafletMapComponent.prototype.leafletMapService;
    }
});
//# sourceMappingURL=data:application/json;base64, 