/**
 * @fileoverview added by tsickle
 * @suppress {checkTypes,extraRequire,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { Component, EventEmitter, Input, Output } from '@angular/core';
import { RmService } from '@bidi/common-services';
import { createFeatureSelector, select, Store } from '@ngrx/store';
import { CommentsResourcesService } from './comments-resources.service';
import { LoadingComments, SetCommentsResources } from './ngrx/actions';
export class CommentsResourcesComponent {
    /**
     * @param {?} rm
     * @param {?} commentsService
     * @param {?} store
     */
    constructor(rm, commentsService, store) {
        this.rm = rm;
        this.commentsService = commentsService;
        this.store = store;
        this.close = new EventEmitter();
        this.state$ = this.store.pipe(select(createFeatureSelector('@bidi/common-components Ratings')));
    }
    /**
     * @return {?}
     */
    ngOnInit() {
        this.store.dispatch(new LoadingComments(true));
        this.commentsService.getComments(this.resourceId);
    }
    /**
     * @return {?}
     */
    saveComment() {
        /** @type {?} */
        const data = {
            'resource': this.resourceId,
            'comment': this.comment,
            'type': this.role
        };
        this.store.dispatch(new LoadingComments(true));
        this.store.dispatch(new SetCommentsResources(data));
        this.comment = '';
    }
}
CommentsResourcesComponent.decorators = [
    { type: Component, args: [{
                selector: 'bidi-comments-resources',
                template: "<div class=\"contents-comments is-flex has-column-direction\">\n  <div class=\"close-button\">\n    <button (click)=\"close.emit()\" class=\"button is-text\">\n      <svg class=\"icon-svg-tt-angle-right\">\n        <use :xlink:href=\"#icon-svg-tt-angle-right\"></use>\n      </svg>\n    </button>\n  </div>\n\n  <h2 class=\"is-size-6 is-ff-light\">Comentarios:</h2>\n  <div class=\"contents-list\">\n    <div class=\"comment\" *ngFor=\"let comment of (commentsService.comments$ | async)\">\n      <p class=\"user_comment is-pulled-left is-size-7\">{{ comment.user.given_name }} {{comment.user.family_name}}</p>\n      <p class=\"time is-pulled-right\">{{ comment.date | date:\"EEEE, d 'de' MMMM\" }}</p>\n      <p class=\"text-comment\">\n        {{ comment.comment }}\n      </p>\n    </div>\n  </div>\n  <div class=\"save-comment\">\n    <textarea [(ngModel)]=\"comment\"\n              placeholder=\"Escribe aqui comentarios sobre este contenido\"></textarea>\n    <div class=\"buttons is-slide-right is-pulled-right\">\n      <button (click)=\"saveComment()\"\n      class=\"button is-pulled-right is-tt-secondary \">\n        <svg width=\"24\" height=\"24\" xmlns=\"http://www.w3.org/2000/svg\" fill-rule=\"evenodd\" clip-rule=\"evenodd\"><path d=\"M21 6.285l-11.16 12.733-6.84-6.018 1.319-1.49 5.341 4.686 9.865-11.196 1.475 1.285z\"/></svg>\n      </button>\n    </div>\n  </div>\n  <bidi-loading *ngIf=\"commentsService.loading$ | async\"></bidi-loading>\n</div>\n",
                styles: [".contents-comments{height:100%;position:relative;padding:1rem;justify-content:space-between}.close-button{position:absolute;left:0}.close-button .button{padding:0;background:0 0}.contents-list{overflow:auto}.comment{position:relative;border-bottom:1px solid #e5e5e5;border-radius:5px;padding:12px 10px 10px}.comment .user_comment{margin:0 10px;font-weight:700;color:#2d4254}.comment .time{color:#666;font-size:.6875rem}.comment .text-comment{margin:7px;padding:3px;color:#333;border:1px solid #fafafa;clear:both}.comment .text-comment.editable{background:#fff;border-color:#e5e5e5}.save-comment{padding:15px}textarea{width:87%;padding:7px}textarea::-webkit-input-placeholder{color:#777;font-style:italic}textarea::-moz-placeholder{color:#777;font-style:italic}textarea:-ms-input-placeholder{color:#777;font-style:italic}textarea:-moz-placeholder{color:#777;font-style:italic}button.button{padding:.5rem!important;margin-bottom:0!important;min-height:45px!important;border:none!important;background:0 0!important}button.button svg{fill:#23d160!important}"]
            }] }
];
/** @nocollapse */
CommentsResourcesComponent.ctorParameters = () => [
    { type: RmService },
    { type: CommentsResourcesService },
    { type: Store }
];
CommentsResourcesComponent.propDecorators = {
    resourceId: [{ type: Input }],
    role: [{ type: Input }],
    title: [{ type: Input }],
    close: [{ type: Output }]
};
if (false) {
    /** @type {?} */
    CommentsResourcesComponent.prototype.resourceId;
    /** @type {?} */
    CommentsResourcesComponent.prototype.role;
    /** @type {?} */
    CommentsResourcesComponent.prototype.title;
    /** @type {?} */
    CommentsResourcesComponent.prototype.close;
    /** @type {?} */
    CommentsResourcesComponent.prototype.comment;
    /**
     * @type {?}
     * @private
     */
    CommentsResourcesComponent.prototype.state$;
    /**
     * @type {?}
     * @private
     */
    CommentsResourcesComponent.prototype.rm;
    /** @type {?} */
    CommentsResourcesComponent.prototype.commentsService;
    /**
     * @type {?}
     * @private
     */
    CommentsResourcesComponent.prototype.store;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29tbWVudHMtcmVzb3VyY2VzLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiJuZzovL0BiaWRpL2NvbW1vbi1jb21wb25lbnRzLyIsInNvdXJjZXMiOlsibGliL21vZHVsZXMvY29tbWVudHMtcmVzb3VyY2VzL2NvbW1lbnRzLXJlc291cmNlcy5jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7OztBQUFBLE9BQU8sRUFBQyxTQUFTLEVBQUUsWUFBWSxFQUFFLEtBQUssRUFBVSxNQUFNLEVBQUMsTUFBTSxlQUFlLENBQUM7QUFDN0UsT0FBTyxFQUFFLFNBQVMsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ2xELE9BQU8sRUFBRSxxQkFBcUIsRUFBRSxNQUFNLEVBQUUsS0FBSyxFQUFFLE1BQU0sYUFBYSxDQUFDO0FBRW5FLE9BQU8sRUFBRSx3QkFBd0IsRUFBRSxNQUFNLDhCQUE4QixDQUFDO0FBQ3hFLE9BQU8sRUFBQyxlQUFlLEVBQUUsb0JBQW9CLEVBQUMsTUFBTSxnQkFBZ0IsQ0FBQztBQVFyRSxNQUFNLE9BQU8sMEJBQTBCOzs7Ozs7SUFTckMsWUFDVSxFQUFhLEVBQ2QsZUFBeUMsRUFDeEMsS0FBaUI7UUFGakIsT0FBRSxHQUFGLEVBQUUsQ0FBVztRQUNkLG9CQUFlLEdBQWYsZUFBZSxDQUEwQjtRQUN4QyxV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