import { __decorate, __extends, __values } from "tslib";
import { Component, Input, ChangeDetectionStrategy } from '@angular/core';
import { SharedService } from '../../../../shared/service/shared.service';
import { SummaryBase } from '../summary-base';
var MedicalCaseSummaryComponent = /** @class */ (function (_super) {
    __extends(MedicalCaseSummaryComponent, _super);
    function MedicalCaseSummaryComponent(sharedService) {
        var _this = _super.call(this, sharedService) || this;
        _this.sharedService = sharedService;
        return _this;
    }
    MedicalCaseSummaryComponent.prototype.ngOnChanges = function (changes) {
        if (this.question) {
            this.getAnswers();
        }
    };
    MedicalCaseSummaryComponent.prototype.ngOnInit = function () {
        this.convertedTime = this.convertTime2(this.question.questionTimeSpent, 'time');
    };
    MedicalCaseSummaryComponent.prototype.getAnswers = function () {
        var e_1, _a;
        this.correctAnswer = '';
        this.selectedAnswer = '';
        this.question.rationale = '';
        this.question.correct = false;
        var correctIds = [];
        var selectedIds = [];
        if (this.question) {
            if (this.question.parentDetails && this.question.parentDetails.assets[0]) {
                this.question.parentDetails.assetsPosition = this.question.parentDetails.assets[0].assetsPosition;
                this.question.assetsPosition = this.question.parentDetails.assets[0].assetsPosition;
            }
            try {
                for (var _b = __values(this.question.choiceInteraction.simpleChoices), _c = _b.next(); !_c.done; _c = _b.next()) {
                    var choice = _c.value;
                    if (choice.correct === true) {
                        correctIds.push(choice.choiceId);
                        if (this.correctAnswer !== '') {
                            this.correctAnswer = this.correctAnswer + ',' + choice.label;
                        }
                        else {
                            this.correctAnswer = choice.label;
                        }
                    }
                    if (this.question.userResponse.indexOf(choice.choiceId) !== -1) {
                        selectedIds.push(choice.choiceId);
                        if (this.selectedAnswer !== '') {
                            this.selectedAnswer = this.selectedAnswer + ',' + choice.label;
                        }
                        else {
                            this.selectedAnswer = choice.label;
                        }
                    }
                }
            }
            catch (e_1_1) { e_1 = { error: e_1_1 }; }
            finally {
                try {
                    if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
                }
                finally { if (e_1) throw e_1.error; }
            }
            this.formattingAnswers();
            if (correctIds === selectedIds) {
                this.question.correct = true;
            }
        }
        return true;
    };
    MedicalCaseSummaryComponent.ctorParameters = function () { return [
        { type: SharedService }
    ]; };
    __decorate([
        Input('summaryData')
    ], MedicalCaseSummaryComponent.prototype, "question", void 0);
    MedicalCaseSummaryComponent = __decorate([
        Component({
            selector: 'lib-medical-case-summary',
            template: "<ng-container *ngIf=\"question.parentDetails\">\n  <div class=\"wk-row\">\n    <div class=\"wkqp-field-header \">\n      <span class=\"medicalcase-label\"> Case Scenario/Description</span>\n    </div>\n    <media-carousel\n      [imagePath]=\"question.parentDetails.assets[0].assetPath\"\n      [assetData]=\"question.parentDetails.assets\"\n      [assetsPosition]=\"question.parentDetails.assetsPosition\"\n      *ngIf=\"\n        question &&\n        question.parentDetails &&\n        question.parentDetails.assets &&\n        question.parentDetails.assets.length > 0 &&\n        question.parentDetails.assetsPosition !=\n          AssetPositionValuesEnum.withInText &&\n        question.parentDetails.assetsPosition != AssetPositionValuesEnum.bottom\n      \"\n    ></media-carousel>\n\n    <div\n      [ngClass]=\"{\n        'wk-col-8 asset-left-width66':\n          question &&\n          question.parentDetails.assets != undefined &&\n          question.parentDetails.assets.length != 0 &&\n          question.parentDetails.assetsPosition !=\n            AssetPositionValuesEnum.withInText,\n        'wk-col-12':\n          (question &&\n            question.parentDetails &&\n            question.parentDetails.assets == undefined) ||\n          (question &&\n            question.parentDetails &&\n            question.parentDetails.assets.length == 0) ||\n          (question &&\n            question.parentDetails &&\n            question.parentDetails.assetsPosition ==\n              AssetPositionValuesEnum.withInText),\n        'right-assets-position-question':\n          question &&\n          question.parentDetails.assets != undefined &&\n          question.parentDetails.assets.length != 0 &&\n          question.parentDetails.assetsPosition ==\n            AssetPositionValuesEnum.right,\n        'left-assets-position-question':\n          question &&\n          question.parentDetails.assets != undefined &&\n          question.parentDetails.assets.length != 0 &&\n          question.parentDetails.assetsPosition == AssetPositionValuesEnum.left,\n        'top-assets-position-question':\n          question &&\n          question.parentDetails.assets != undefined &&\n          question.parentDetails.assets.length != 0 &&\n          question.parentDetails.assetsPosition == AssetPositionValuesEnum.top,\n        'bottom-assets-position-question':\n          question &&\n          question.parentDetails.assets != undefined &&\n          question.parentDetails.assets.length != 0 &&\n          question.parentDetails.assetsPosition ==\n            AssetPositionValuesEnum.bottom\n      }\"\n    >\n      <div class=\"wkqp-layout-item\">\n        <div class=\"wkqp-field-item normal-font mb0 \">\n          <div\n            class=\"wkqp-field-header\"\n            *ngIf=\"\n              question.parentDetails.assetsPosition !=\n              AssetPositionValuesEnum.withInText\n            \"\n          >\n            <p\n              class=\"mb20 normal-font wkqp-prewrap heading-h3 headingh3-res question-parent-text\"\n            >\n              <span\n                libGetFormatText\n                [preferredTextFormat]=\"question.preferredTextFormat\"\n                [plainText]=\"question.parentDetails.promptText\"\n                [richText]=\"question.parentDetails.richPromptText\"\n              ></span>\n            </p>\n          </div>\n          <div\n            class=\"wkqp-field-header\"\n            *ngIf=\"\n              question.parentDetails.assetsPosition ==\n              AssetPositionValuesEnum.withInText\n            \"\n          >\n            <item-text-assets\n              [promptText]=\"question.parentDetails.promptText\"\n              [assetData]=\"question.parentDetails.assets\"\n              [assetsPosition]=\"AssetPositionValuesEnum.withInText\"\n            ></item-text-assets>\n          </div>\n        </div>\n      </div>\n\n      <media-carousel\n        *ngIf=\"\n          question.parentDetails &&\n          question.parentDetails.assets &&\n          question.parentDetails.assets.length != 0 &&\n          question.parentDetails.assetsPosition ==\n            AssetPositionValuesEnum.bottom\n        \"\n        [imagePath]=\"question.parentDetails.assets[0].assetPath\"\n        [assetData]=\"question.parentDetails.assets\"\n        [assetsPosition]=\"question.parentDetails.assetsPosition\"\n      ></media-carousel>\n    </div>\n  </div>\n  <div class=\"common-full width\">\n    <span\n      class=\"wkqp-field-header\"\n      *ngIf=\"\n        question.parentDetails.assetsPosition ==\n        AssetPositionValuesEnum.withInText\n      \"\n    >\n      <item-text-assets\n        [promptText]=\"question.parentDetails.promptText\"\n        [assetData]=\"question.parentDetails.assets\"\n        [assetsPosition]=\"AssetPositionValuesEnum.withInText\"\n      ></item-text-assets>\n    </span>\n  </div>\n  <div class=\"common-full-width \">\n    <div class=\"wkqp-layout-item summary2-mb0\">\n      <div class=\"wk-row gray-bg-result\">\n        <!--Child Question prompt text-->\n        <div class=\"wk-col-8 responsive-pl15\">\n          <span class=\"wkqb-question-number\">\n            <strong>{{ question.sequence }}</strong>\n          </span>\n          <span\n            class=\"qp-ts-number-right\"\n            *ngIf=\"\n              question.parentDetails.assetsPosition !=\n              AssetPositionValuesEnum.withInText\n            \"\n          >\n            <strong class=\"wkqp-prewrap\">{{ question.promptText }}</strong>\n          </span>\n          <span\n            *ngIf=\"\n              question.parentDetails.assetsPosition ==\n              AssetPositionValuesEnum.withInText\n            \"\n          >\n            <item-text-assets\n              [promptText]=\"question.parentDetails.promptText\"\n              [assetData]=\"question.parentDetails.assets\"\n              [assetsPosition]=\"AssetPositionValuesEnum.withInText\"\n            ></item-text-assets>\n          </span>\n        </div>\n\n        <!--Question time spent-->\n        <div class=\"wk-col-4 responsive-timespent time-qu-pt-remove\">\n          <span\n            class=\"que-mob-left mr10\"\n            [ngClass]=\"getQuestionProgressClass(question)\"\n          ></span>\n          <span\n            class=\"wkqp-badge time-mob-right\"\n            [ngClass]=\"getOvertimelimitClass(question)\"\n          >\n            Time Spent -\n            {{ convertedTime }}\n          </span>\n        </div>\n      </div>\n    </div>\n\n    <!--Child question user response-->\n    <div class=\"wkqp-layout-item mb20  summary3-mb0 common-full-width\">\n      <div class=\"wkqp-field-item summary5-mb0\">\n        <div\n          *ngIf=\"question.userResponse[0] && question.userResponse.length > 0\"\n        >\n          <!--Your Response-->\n          <p\n            class=\"wkqp-prewrap mb20\"\n            ng-show=\"question.userResponse[0]\"\n            [ngClass]=\"getSelectedResponseClass(question)\"\n          >\n            <strong>Your Response: </strong>\n            <label class=\"response-inline\">{{ selectedAnswer }}</label>\n          </p>\n\n          <!--Correct Response-->\n          <p\n            *ngIf=\"question.isCorrect != 1\"\n            class=\"wkqp-prewrap wkqp-alert-success wkqp-success mb20\"\n          >\n            <strong>Correct Response: </strong>\n            <label class=\"response-inline\">{{ correctAnswer }}</label>\n          </p>\n        </div>\n        <div class=\"common-full-width\" *ngIf=\"!question.userResponse[0]\">\n          <p class=\"wkqp-alert-danger\">\n            <strong>You did not answer this question</strong>\n          </p>\n        </div>\n        <div class=\"common-full-width mb20\">\n          <!--Rationale-->\n          <lib-rationale [itemData]=\"question.modelFeedback\"></lib-rationale>\n          <!-- remediation -->\n          <lib-remediation\n            [itemData]=\"question.remediationLinks\"\n          ></lib-remediation>\n        </div>\n      </div>\n    </div>\n  </div>\n</ng-container>\n",
            changeDetection: ChangeDetectionStrategy.OnPush,
            styles: [""]
        })
    ], MedicalCaseSummaryComponent);
    return MedicalCaseSummaryComponent;
}(SummaryBase));
export { MedicalCaseSummaryComponent };
//# sourceMappingURL=data:application/json;base64, 