/**
 * @fileoverview added by tsickle
 * Generated from: lib/fhir/device/details/components/status/device-status.component.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
import { TAJ_REGEX } from '../../../../../shared/regular-expressions/regex';
import { Component, Input, EventEmitter, Output } from '@angular/core';
import { DeviceStatusKind } from '@ahryman40k/ts-fhir-types/lib/R4';
import { FormControl, Validators, FormGroup } from '@angular/forms';
export class DeviceStatusComponent {
    constructor() {
        this.callUpdate = new EventEmitter();
        this.deviceStKin = DeviceStatusKind;
    }
    /**
     * @return {?}
     */
    ngOnInit() { this.reset(); }
    /**
     * @return {?}
     */
    reset() {
        this.statusForm = new FormGroup({
            taj: new FormControl('', [Validators.required, Validators.pattern(TAJ_REGEX)]),
            name: new FormControl(''),
            comment: new FormControl('')
        });
    }
    /**
     * @param {?} status
     * @param {?=} statusValue
     * @return {?}
     */
    update(status, statusValue) {
        this.callUpdate.emit({ device: this.device, statusValue, status });
        this.reset();
    }
}
DeviceStatusComponent.decorators = [
    { type: Component, args: [{
                selector: 'inc-device-status',
                template: "<ion-grid class=\"ion-no-padding\">\r\n  <ion-row>\r\n    <ion-col size=\"12\" size-md=\"6\" class=\"avatar-container\">\r\n      <ion-avatar\r\n        [ngClass]=\"{success: device.status === 'active', danger: device.status === 'unknown', warning: device.status === 'entered-in-error'}\">\r\n        <ion-text>\r\n          <b>{{device.status | deviceStatusPipe | translate}}</b>\r\n        </ion-text>\r\n      </ion-avatar>\r\n      <div *ngIf=\"device.status === 'inactive' && device.patient\">\r\n        <ion-text color=\"primary\" *ngIf=\"device.patient.display\">\r\n          <h4 class=\"ion-text-center\">\r\n            <b>{{device.patient.display}}</b>\r\n          </h4>\r\n        </ion-text>\r\n        <h6 class=\"ion-text-center\" *ngIf=\"device.patient.reference\">{{device.patient.reference}}</h6>\r\n      </div>\r\n    </ion-col>\r\n    <ion-col size=\"12\" size-md=\"6\">\r\n      <form [formGroup]=\"statusForm\" (ngSubmit)=\"update('inactive', statusForm.value)\">\r\n        <ion-list>\r\n          <ion-item [disabled]=\"device.status !== 'active'\">\r\n            <ion-label position=\"floating\">{{'TAJ' | translate}}\r\n              <span class=\"required\">*</span>\r\n            </ion-label>\r\n            <ion-input incSinController formControlName=\"taj\" id=\"taj\" type=\"text\" autofocus=\"true\" clearInput>\r\n            </ion-input>\r\n          </ion-item>\r\n          <ion-item>\r\n            <ion-label position=\"floating\">{{'COMMENT' | translate}}</ion-label>\r\n            <ion-textarea id=\"comment\" rows=\"1\" formControlName=\"comment\" autoGrow></ion-textarea>\r\n          </ion-item>\r\n          <div class=\"ion-float-end ion-margin-top\">\r\n            <ion-button fill=\"outline\" id=\"scrapped-button\" color=\"danger\" *ngIf=\"device.status !== 'unknown'\"\r\n              (click)=\"update('unknown', statusForm.value)\" class=\"ion-margin-end\">\r\n              {{'STATUS_MAKE_SCRAPPED' | translate}}\r\n            </ion-button>\r\n            <ion-button fill=\"outline\" id=\"make-error-button\" color=\"warning\"\r\n              *ngIf=\"device.status !== 'entered-in-error'\" (click)=\"update('enteredInError', statusForm.value)\"\r\n              class=\"ion-margin-end\">\r\n              {{'STATUS_MAKE_ERROR' | translate}}\r\n            </ion-button>\r\n            <ion-button fill=\"outline\" id=\"make-active-button\" color=\"success\" *ngIf=\"device.status !== 'active'\"\r\n              (click)=\"update('active', statusForm.value)\">\r\n              {{'TAKE_BACK' | translate}}\r\n            </ion-button>\r\n            <ion-button [disabled]=\"statusForm.invalid\" id=\"make-inactive-button\" *ngIf=\"device.status === 'active'\"\r\n              type=\"submit\">\r\n              {{'STATUS_MAKE_INACTIVE' | translate}}\r\n            </ion-button>\r\n          </div>\r\n        </ion-list>\r\n      </form>\r\n    </ion-col>\r\n  </ion-row>\r\n</ion-grid>",
                styles: [".avatar-container,ion-avatar{display:flex;justify-content:center;align-items:center}.avatar-container{flex-direction:column}ion-avatar{width:100px;height:100px;border:2px solid var(--ion-color-primary)}.success{border-color:var(--ion-color-success)}.danger{border-color:var(--ion-color-danger)}.warning{border-color:var(--ion-color-warning)}.user{background-color:var(--ion-color-primary)}"]
            }] }
];
/** @nocollapse */
DeviceStatusComponent.ctorParameters = () => [];
DeviceStatusComponent.propDecorators = {
    device: [{ type: Input }],
    callUpdate: [{ type: Output }]
};
if (false) {
    /** @type {?} */
    DeviceStatusComponent.prototype.device;
    /** @type {?} */
    DeviceStatusComponent.prototype.callUpdate;
    /** @type {?} */
    DeviceStatusComponent.prototype.deviceStKin;
    /** @type {?} */
    DeviceStatusComponent.prototype.statusForm;
}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGV2aWNlLXN0YXR1cy5jb21wb25lbnQuanMiLCJzb3VyY2VSb290Ijoibmc6Ly9AaW5jbG91ZGVkL2lvbmljNC1pbmNsb3VkZWQtbGliLyIsInNvdXJjZXMiOlsibGliL2ZoaXIvZGV2aWNlL2RldGFpbHMvY29tcG9uZW50cy9zdGF0dXMvZGV2aWNlLXN0YXR1cy5jb21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7Ozs7QUFBQSxPQUFPLEVBQUUsU0FBUyxFQUFFLE1BQU0saURBQWlELENBQUM7QUFDNUUsT0FBTyxFQUFFLFNBQVMsRUFBVSxLQUFLLEVBQUUsWUFBWSxFQUFFLE1BQU0sRUFBRSxNQUFNLGVBQWUsQ0FBQztBQUMvRSxPQUFPLEVBQVcsZ0JBQWdCLEVBQUUsTUFBTSxrQ0FBa0MsQ0FBQztBQUM3RSxPQUFPLEVBQUUsV0FBVyxFQUFFLFVBQVUsRUFBRSxTQUFTLEVBQUUsTUFBTSxnQkFBZ0IsQ0FBQztBQU9wRSxNQUFNLE9BQU8scUJBQXFCO0lBT2hDO1FBTFUsZUFBVSxHQUFHLElBQUksWUFBWSxFQUFPLENBQUM7UUFFL0MsZ0JBQVcsR0FBRyxnQkFBZ0IsQ0FBQztJQUdmLENBQUM7Ozs7SUFFakIsUUFBUS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