import { Component, Input } from '@angular/core';
import { Router } from '@angular/router';
import { CaseView } from '../../../domain/case-view/case-view.model';
import { CasesService } from '../../case-editor/services/cases.service';
import * as i0 from "@angular/core";
import * as i1 from "../../case-editor/services/cases.service";
import * as i2 from "@angular/router";
import * as i3 from "@angular/common";
import * as i4 from "../../../../components/banners/alert/alert.component";
import * as i5 from "../../loading-spinner/loading-spinner.component";
import * as i6 from "../../../pipes/case-reference/case-reference.pipe";
import * as i7 from "rpx-xui-translation";
function CaseBasicAccessViewComponent_ccd_loading_spinner_0_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelement(0, "ccd-loading-spinner");
} }
function CaseBasicAccessViewComponent_ng_container_3_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "rpxTranslate");
    i0.ɵɵpipe(3, "rpxTranslate");
    i0.ɵɵpipe(4, "lowercase");
    i0.ɵɵpipe(5, "rpxTranslate");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate3("", i0.ɵɵpipeBind1(2, 3, "This case requires"), " ", i0.ɵɵpipeBind1(4, 7, i0.ɵɵpipeBind1(3, 5, ctx_r0.accessType)), " ", i0.ɵɵpipeBind1(5, 9, "access"), ".");
} }
function CaseBasicAccessViewComponent_ng_container_4_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "rpxTranslate");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(2, 1, "Authorisation is needed to access this case"));
} }
function CaseBasicAccessViewComponent_ng_container_6_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "rpxTranslate");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1("", i0.ɵɵpipeBind1(2, 1, "This is because the case is outside your work area. If you request access to the case, it will be logged for auditing purposes"), ".");
} }
function CaseBasicAccessViewComponent_ng_container_7_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementContainerStart(0);
    i0.ɵɵtext(1);
    i0.ɵɵpipe(2, "rpxTranslate");
    i0.ɵɵelementContainerEnd();
} if (rf & 2) {
    i0.ɵɵadvance();
    i0.ɵɵtextInterpolate1("", i0.ɵɵpipeBind1(2, 1, "This could be because it's outside your jurisdiction, or you may be excluded from the case. If you request access to this case, it will be logged for auditing purposes"), ".");
} }
function CaseBasicAccessViewComponent_div_15_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10)(1, "dt", 11);
    i0.ɵɵtext(2);
    i0.ɵɵpipe(3, "rpxTranslate");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "dd", 12);
    i0.ɵɵtext(5);
    i0.ɵɵpipe(6, "rpxTranslate");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 2, "Case name"));
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(6, 4, ctx_r0.caseDetails.basicFields.caseNameHmctsInternal));
} }
function CaseBasicAccessViewComponent_div_16_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10)(1, "dt", 11);
    i0.ɵɵtext(2);
    i0.ɵɵpipe(3, "rpxTranslate");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "dd", 12);
    i0.ɵɵtext(5);
    i0.ɵɵpipe(6, "rpxTranslate");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 2, "Service"));
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(6, 4, ctx_r0.caseDetails.case_type.jurisdiction.name));
} }
function CaseBasicAccessViewComponent_div_17_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10)(1, "dt", 11);
    i0.ɵɵtext(2);
    i0.ɵɵpipe(3, "rpxTranslate");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "dd", 12);
    i0.ɵɵtext(5);
    i0.ɵɵpipe(6, "rpxTranslate");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 2, "State"));
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(6, 4, ctx_r0.caseDetails.state.description));
} }
function CaseBasicAccessViewComponent_div_18_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10)(1, "dt", 11);
    i0.ɵɵtext(2);
    i0.ɵɵpipe(3, "rpxTranslate");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "dd", 12);
    i0.ɵɵtext(5);
    i0.ɵɵpipe(6, "titlecase");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 2, "Court or hearing centre"));
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(6, 4, ctx_r0.courtOrHearingCentre));
} }
function CaseBasicAccessViewComponent_div_19_Template(rf, ctx) { if (rf & 1) {
    i0.ɵɵelementStart(0, "div", 10)(1, "dt", 11);
    i0.ɵɵtext(2);
    i0.ɵɵpipe(3, "rpxTranslate");
    i0.ɵɵelementEnd();
    i0.ɵɵelementStart(4, "dd", 12);
    i0.ɵɵtext(5);
    i0.ɵɵpipe(6, "titlecase");
    i0.ɵɵpipe(7, "rpxTranslate");
    i0.ɵɵelementEnd()();
} if (rf & 2) {
    const ctx_r0 = i0.ɵɵnextContext();
    i0.ɵɵadvance(2);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(3, 2, "Access"));
    i0.ɵɵadvance(3);
    i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(7, 6, i0.ɵɵpipeBind1(6, 4, ctx_r0.accessType)));
} }
export class CaseBasicAccessViewComponent {
    casesService;
    router;
    static CANCEL_LINK_DESTINATION = '/work/my-work/list';
    caseDetails = null;
    accessType = null;
    courtOrHearingCentre = null;
    showSpinner;
    courtOrHearingCentreSubscription;
    constructor(casesService, router) {
        this.casesService = casesService;
        this.router = router;
    }
    ngOnInit() {
        const locationId = this.caseDetails &&
            this.caseDetails.basicFields &&
            this.caseDetails.basicFields.caseManagementLocation &&
            this.caseDetails.basicFields.caseManagementLocation.baseLocation ?
            this.caseDetails.basicFields.caseManagementLocation.baseLocation : null;
        if (locationId) {
            this.showSpinner = true;
            this.courtOrHearingCentreSubscription = this.casesService.getCourtOrHearingCentreName(locationId).subscribe(courtOrHearingCentre => {
                this.courtOrHearingCentre = courtOrHearingCentre[0] && courtOrHearingCentre[0].court_name ?
                    courtOrHearingCentre[0].court_name : null;
                this.showSpinner = false;
            }, error => this.showSpinner = false);
        }
    }
    ngOnDestroy() {
        if (this.courtOrHearingCentreSubscription) {
            this.courtOrHearingCentreSubscription.unsubscribe();
        }
    }
    onCancel() {
        this.router.navigateByUrl(CaseBasicAccessViewComponent.CANCEL_LINK_DESTINATION);
    }
    getRequestUrl(accessType) {
        return accessType === 'CHALLENGED' ? 'challenged-access-request' : 'specific-access-request';
    }
    static ɵfac = function CaseBasicAccessViewComponent_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || CaseBasicAccessViewComponent)(i0.ɵɵdirectiveInject(i1.CasesService), i0.ɵɵdirectiveInject(i2.Router)); };
    static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: CaseBasicAccessViewComponent, selectors: [["ccd-case-basic-access-view"]], inputs: { caseDetails: "caseDetails", accessType: "accessType" }, decls: 29, vars: 23, consts: [[4, "ngIf"], ["type", "information"], [1, "heading-h1"], [1, "govuk-heading-m"], [1, "govuk-summary-list"], ["class", "govuk-summary-list__row", 4, "ngIf"], [1, "govuk-button-group"], [1, "govuk-button", "govuk-!-margin-right-3", 3, "routerLink"], [1, "govuk-grid-column-full", "govuk-!-padding-left-0"], ["href", "#", 1, "govuk-body", 3, "click"], [1, "govuk-summary-list__row"], [1, "govuk-summary-list__key", "summary-key"], [1, "govuk-summary-list__value"]], template: function CaseBasicAccessViewComponent_Template(rf, ctx) { if (rf & 1) {
            i0.ɵɵtemplate(0, CaseBasicAccessViewComponent_ccd_loading_spinner_0_Template, 1, 0, "ccd-loading-spinner", 0);
            i0.ɵɵelementStart(1, "div")(2, "cut-alert", 1);
            i0.ɵɵtemplate(3, CaseBasicAccessViewComponent_ng_container_3_Template, 6, 11, "ng-container", 0)(4, CaseBasicAccessViewComponent_ng_container_4_Template, 3, 3, "ng-container", 0);
            i0.ɵɵelement(5, "br");
            i0.ɵɵtemplate(6, CaseBasicAccessViewComponent_ng_container_6_Template, 3, 3, "ng-container", 0)(7, CaseBasicAccessViewComponent_ng_container_7_Template, 3, 3, "ng-container", 0);
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(8, "h1", 2);
            i0.ɵɵtext(9);
            i0.ɵɵpipe(10, "ccdCaseReference");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(11, "h2", 3);
            i0.ɵɵtext(12);
            i0.ɵɵpipe(13, "rpxTranslate");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(14, "dl", 4);
            i0.ɵɵtemplate(15, CaseBasicAccessViewComponent_div_15_Template, 7, 6, "div", 5)(16, CaseBasicAccessViewComponent_div_16_Template, 7, 6, "div", 5)(17, CaseBasicAccessViewComponent_div_17_Template, 7, 6, "div", 5)(18, CaseBasicAccessViewComponent_div_18_Template, 7, 6, "div", 5)(19, CaseBasicAccessViewComponent_div_19_Template, 8, 8, "div", 5);
            i0.ɵɵelementEnd()();
            i0.ɵɵelementStart(20, "div", 6)(21, "button", 7);
            i0.ɵɵtext(22);
            i0.ɵɵpipe(23, "rpxTranslate");
            i0.ɵɵelementEnd();
            i0.ɵɵelementStart(24, "div", 8)(25, "p")(26, "a", 9);
            i0.ɵɵlistener("click", function CaseBasicAccessViewComponent_Template_a_click_26_listener($event) { ctx.onCancel(); return $event.preventDefault(); });
            i0.ɵɵtext(27);
            i0.ɵɵpipe(28, "rpxTranslate");
            i0.ɵɵelementEnd()()()();
        } if (rf & 2) {
            i0.ɵɵproperty("ngIf", ctx.showSpinner);
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", ctx.accessType === "CHALLENGED");
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.accessType === "SPECIFIC");
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("ngIf", ctx.accessType === "CHALLENGED");
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.accessType === "SPECIFIC");
            i0.ɵɵadvance(2);
            i0.ɵɵtextInterpolate1("#", i0.ɵɵpipeBind1(10, 15, ctx.caseDetails.case_id), "");
            i0.ɵɵadvance(3);
            i0.ɵɵtextInterpolate(i0.ɵɵpipeBind1(13, 17, "Case details"));
            i0.ɵɵadvance(3);
            i0.ɵɵproperty("ngIf", ctx.caseDetails.basicFields == null ? null : ctx.caseDetails.basicFields.caseNameHmctsInternal);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.caseDetails.case_type == null ? null : ctx.caseDetails.case_type.jurisdiction == null ? null : ctx.caseDetails.case_type.jurisdiction.name);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.caseDetails.state == null ? null : ctx.caseDetails.state.description);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.courtOrHearingCentre);
            i0.ɵɵadvance();
            i0.ɵɵproperty("ngIf", ctx.accessType);
            i0.ɵɵadvance(2);
            i0.ɵɵproperty("routerLink", ctx.getRequestUrl(ctx.accessType));
            i0.ɵɵadvance();
            i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(23, 19, "Request access"), " ");
            i0.ɵɵadvance(5);
            i0.ɵɵtextInterpolate1(" ", i0.ɵɵpipeBind1(28, 21, "Cancel"), " ");
        } }, dependencies: [i3.NgIf, i2.RouterLink, i4.AlertComponent, i5.LoadingSpinnerComponent, i3.LowerCasePipe, i3.TitleCasePipe, i6.CaseReferencePipe, i7.RpxTranslatePipe], encapsulation: 2 });
}
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(CaseBasicAccessViewComponent, [{
        type: Component,
        args: [{ selector: 'ccd-case-basic-access-view', template: "<ccd-loading-spinner  *ngIf=\"showSpinner\"></ccd-loading-spinner>\n<div>\n  <cut-alert type=\"information\">\n    <ng-container *ngIf=\"accessType === 'CHALLENGED'\">{{'This case requires' | rpxTranslate}} {{accessType | rpxTranslate | lowercase}} {{'access' | rpxTranslate}}.</ng-container>\n    <ng-container *ngIf=\"accessType === 'SPECIFIC'\">{{'Authorisation is needed to access this case' | rpxTranslate}}</ng-container>\n    <br />\n    <ng-container *ngIf=\"accessType === 'CHALLENGED'\">{{'This is because the case is outside your work area. If you request access to the case, it will be logged for auditing purposes' | rpxTranslate}}.</ng-container>\n    <ng-container *ngIf=\"accessType === 'SPECIFIC'\">{{\"This could be because it's outside your jurisdiction, or you may be excluded from the case. If you request access to this case, it will be logged for auditing purposes\" | rpxTranslate }}.</ng-container>\n  </cut-alert>\n  <h1 class=\"heading-h1\">#{{ caseDetails.case_id | ccdCaseReference}}</h1>\n  <h2 class=\"govuk-heading-m\">{{'Case details' | rpxTranslate}}</h2>\n  <dl class=\"govuk-summary-list\">\n    <div class=\"govuk-summary-list__row\" *ngIf=\"caseDetails.basicFields?.caseNameHmctsInternal\">\n      <dt class=\"govuk-summary-list__key summary-key\">{{'Case name' | rpxTranslate}}</dt>\n      <dd class=\"govuk-summary-list__value\">{{caseDetails.basicFields.caseNameHmctsInternal | rpxTranslate}}</dd>\n    </div>\n    <div class=\"govuk-summary-list__row\" *ngIf=\"caseDetails.case_type?.jurisdiction?.name\">\n      <dt class=\"govuk-summary-list__key summary-key\">{{'Service' | rpxTranslate}}</dt>\n      <dd class=\"govuk-summary-list__value\">{{caseDetails.case_type.jurisdiction.name | rpxTranslate}}</dd>\n    </div>\n    <div class=\"govuk-summary-list__row\" *ngIf=\"caseDetails.state?.description\">\n      <dt class=\"govuk-summary-list__key summary-key\">{{'State' | rpxTranslate}}</dt>\n      <dd class=\"govuk-summary-list__value\">{{caseDetails.state.description | rpxTranslate}}</dd>\n    </div>\n    <div class=\"govuk-summary-list__row\" *ngIf=\"courtOrHearingCentre\">\n      <dt class=\"govuk-summary-list__key summary-key\">{{'Court or hearing centre' | rpxTranslate}}</dt>\n      <dd class=\"govuk-summary-list__value\">{{courtOrHearingCentre | titlecase}}</dd>\n    </div>\n\n    <div class=\"govuk-summary-list__row\" *ngIf=\"accessType\">\n      <dt class=\"govuk-summary-list__key summary-key\">{{'Access' | rpxTranslate}}</dt>\n      <dd class=\"govuk-summary-list__value\">{{accessType | titlecase | rpxTranslate}}</dd>\n    </div>\n  </dl>\n</div>\n<div class=\"govuk-button-group\">\n  <button class=\"govuk-button govuk-!-margin-right-3\" [routerLink]=\"getRequestUrl(accessType)\">\n    {{'Request access' | rpxTranslate}}\n  </button>\n  <div class=\"govuk-grid-column-full govuk-!-padding-left-0\">\n    <p>\n      <a class=\"govuk-body\" (click)=\"onCancel(); $event.preventDefault()\" href=\"#\">\n        {{'Cancel' | rpxTranslate}}\n      </a>\n    </p>\n  </div>\n</div>\n" }]
    }], () => [{ type: i1.CasesService }, { type: i2.Router }], { caseDetails: [{
            type: Input
        }], accessType: [{
            type: Input
        }] }); })();
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(CaseBasicAccessViewComponent, { className: "CaseBasicAccessViewComponent", filePath: "lib/shared/components/case-viewer/case-basic-access-view/case-basic-access-view.component.ts", lineNumber: 11 }); })();
//# sourceMappingURL=data:application/json;base64, 