/**
 * @license
 * Copyright 2017 JBoss Inc
 *
 * 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, Output, EventEmitter, ViewChildren, QueryList } from "@angular/core";
import { LicenseService } from "../../_services/license.service";
import { SelectionService } from "../../_services/selection.service";
export class SetLicenseDialogComponent {
    constructor(licenseService, selectionService) {
        this.licenseService = licenseService;
        this.selectionService = selectionService;
        this.onLicenseChosen = new EventEmitter();
        this._isOpen = false;
    }
    /**
     * Called to open the dialog.
     */
    open() {
        this._isOpen = true;
        this.setLicenseModal.changes.subscribe(thing => {
            if (this.setLicenseModal.first) {
                this.setLicenseModal.first.show();
            }
        });
        this.selectionService.simpleSelect("/info/license");
    }
    /**
     * Called to close the dialog.
     */
    close() {
        this._isOpen = false;
    }
    /**
     * Called when the user clicks "cancel".
     */
    cancel() {
        this.setLicenseModal.first.hide();
    }
    /**
     * Returns true if the dialog is open.
     * @return
     */
    isOpen() {
        return this._isOpen;
    }
    /**
     * Returns a list of possible licenses.
     */
    licenses() {
        return this.licenseService.getLicenses();
    }
    /**
     * Called when the user picks a license.
     * @param license
     */
    chooseLicense(license) {
        this.onLicenseChosen.emit({
            name: license.name,
            url: license.url
        });
        this.cancel();
    }
}
SetLicenseDialogComponent.decorators = [
    { type: Component, args: [{
                selector: "set-license-dialog",
                template: "<!-- Choose License Dialog -->\n<div bsModal #setLicenseModal=\"bs-modal\" class=\"set-license-modal modal fade\" id=\"setLicenseModal\" tabindex=\"-1\" role=\"dialog\"\n     aria-labelledby=\"setLicenseModalLabel\" role=\"dialog\" aria-hidden=\"true\" [config]=\"{ backdrop: true }\"\n     (onHidden)=\"close()\" *ngIf=\"isOpen()\">\n    <div class=\"modal-dialog\">\n        <div class=\"modal-content\">\n            <div class=\"modal-header\">\n                <button type=\"button\" class=\"close\" aria-hidden=\"true\" (click)=\"cancel()\">\n                    <span class=\"pficon pficon-close\"></span>\n                </button>\n                <h4 class=\"modal-title\" id=\"setLicenseModalLabel\">Choose a License</h4>\n            </div>\n            <div class=\"modal-body\" #dialogBody>\n\n                <div *ngFor=\"let license of licenses()\" class=\"container-fluid license\">\n                    <div class=\"row\">\n                        <div class=\"col-md-6\">\n                            <h2><a href=\"{{ license.url }}\" target=\"_blank\">{{ license.name }}</a><span class=\"fa fa-fw fa-external-link\"></span></h2>\n                            <p>{{ license.description }}</p>\n                            <button class=\"btn btn-xs btn-primary\" (click)=\"chooseLicense(license)\">Use This License</button>\n                            <a class=\"pull-right\" href=\"{{ license.moreInfoUrl }}\" target=\"_blank\">View full {{ license.fullName }} \u00BB</a>\n                        </div>\n                        <div class=\"col-md-2\">\n                            <h3>Permissions</h3>\n                            <ul class=\"permissions\">\n                                <li *ngFor=\"let permission of license.permissions\"><span title=\"{{ licenseService.permissionDescription(permission) }}\">{{ licenseService.permissionName(permission) }}</span></li>\n                            </ul>\n                        </div>\n                        <div class=\"col-md-2\">\n                            <h3>Conditions</h3>\n                            <ul class=\"conditions\">\n                                <li *ngFor=\"let condition of license.conditions\"><span title=\"{{ licenseService.conditionDescription(condition) }}\">{{ licenseService.conditionName(condition) }}</span></li>\n                            </ul>\n                        </div>\n                        <div class=\"col-md-2\">\n                            <h3>Limitations</h3>\n                            <ul class=\"limitations\">\n                                <li *ngFor=\"let limitation of license.limitations\"><span title=\"{{ licenseService.limitationDescription(limitation) }}\">{{ licenseService.limitationName(limitation) }}</span></li>\n                            </ul>\n                        </div>\n                    </div>\n                    <hr />\n                </div>\n\n            </div>\n            <div class=\"modal-footer\">\n                <span class=\"pull-left\">License information provided by <a href=\"https://choosealicense.com/\" target=\"_blank\">Choose a License &copy; </a> under the <a href=\"https://creativecommons.org/licenses/by/3.0/\" target=\"_blank\">Create Commons License</a>.</span>\n                <button type=\"button\" class=\"btn btn-default\" (click)=\"cancel()\">Cancel</button>\n            </div>\n        </div>\n    </div>\n</div>\n"
            },] }
];
SetLicenseDialogComponent.ctorParameters = () => [
    { type: LicenseService },
    { type: SelectionService }
];
SetLicenseDialogComponent.propDecorators = {
    onLicenseChosen: [{ type: Output }],
    setLicenseModal: [{ type: ViewChildren, args: ["setLicenseModal",] }]
};
//# sourceMappingURL=data:application/json;base64, 