import{a as ge}from"./chunk-I5K7GPAI.js";import{a as le}from"./chunk-XOY5UTVP.js";import{a as ae}from"./chunk-D4RZOGGF.js";import{a as L}from"./chunk-WFZJP5WR.js";import"./chunk-F6KLNSUK.js";import{b as ce,c as me,d as de}from"./chunk-YOJ4KGSB.js";import"./chunk-CO3X7TQN.js";import{a as F}from"./chunk-VSFNMVXJ.js";import"./chunk-WQ6DP4JQ.js";import{Mb as re,Ob as N,Qb as se,nb as oe,pb as g,s as H,v as K,wb as w,y as X}from"./chunk-YSQLW2JA.js";import{W as Q,X as J,Y as C,Z as D,kb as te,mb as ie,nb as ne}from"./chunk-NVJ2ZZFT.js";import{Aa as p,Ba as _,He as v,Mc as j,Me as V,Nc as k,Ne as R,Ng as A,Pd as h,Qf as u,Rd as I,Sd as f,Te as b,Ue as W,Yg as Z,_a as x,ab as E,af as q,bb as m,bc as B,bh as ee,dc as z,dd as d,gb as y,ha as T,hd as l,kg as $,ng as Y,wa as M,ya as c}from"./chunk-SKPDQO4E.js";var pe=`<div class="h-100">
  <side-navigation>
    <ng-template side-navigation-nav>
      <!-- Filtering area -->
      <div class="report-form-label">{{'REGION.SEARCH' | translate}}</div>
      <armon-filter-input [maxLength]="20" (entryCompleted)="onFilterChanged($event)" placeholder="COMMON.SEARCH">
      </armon-filter-input>
    </ng-template>
    <ng-template side-navigation-content>
      <!-- Listing area -->
      <div class="row mt-3 mb-3">
        <div class="col-12">
          <!-- Add new region button -->
          <button class="btn btn-sm btn-primary" (click)="onAddRegionButtonClicked()"
            *ngIf="permissionAddRegion">{{'REGION.ADD' | translate}}</button>
        </div>
      </div>
      <ng-container *ngIf="regions && regions.length>0">
        <div class="row" [@listAnimation]="regions.length" id="manage-regions-list">
          <!-- List of regions -->
          <div class="col-xxxl-4 col-xl-6 col-lg-6 col-md-12" *ngFor="let region of regions">
            <armon-region-card [region]="region" (regionDeleted)="onRegionDeleted($event)"
              (regionUserRightsUpdated)="onRegionEdited($event)" (regionEdited)="onRegionEdited($event)"
              (regionEmergencyChanged)="onRegionEmergencyChanged($event)"></armon-region-card>
          </div>
        </div>
      </ng-container>
      <!-- Pagination -->
      <div class="row">
        <div class="col-12 my-3">
          <armon-pagination [paginationResponse]="paginationResponse" [scrollDomId]="'manage-regions-list'"
            (pageChanged)="pageChanged($event)"></armon-pagination>
        </div>
      </div>
    </ng-template>
  </side-navigation>
</div>


<ng-template #askManagerModalTemplate let-modal>
  <div class="modal-header">
    {{'REGION.ADD' | translate}}
  </div>
  <div class="modal-body">
    <div class="row">
      <div class="col-12 my-3">
        <span class="text-md">{{'REGION.ADD_MANAGER_ASK'|translate:newRegion}}</span>
      </div>
      <div class="col-12">
        <div class="alert alert-warning mt-5" role="alert">
          <span class="text-sm">{{'REGION.NO_MANAGER_ALERT' | translate}}</span><span
            class="ms-1 text-sm">{{'REGION.ADD_MANAGER_ALERT'|translate}}</span>
        </div>
      </div>
    </div>
  </div>
  <div class="modal-footer">
    <button class="btn btn-outline-primary me-2" (click)="modal.dismiss()">{{'BUTTON.NO' |
      translate}}</button>
    <button class="btn btn-primary" (click)="modal.close()">{{'BUTTON.YES' | translate}}
    </button>
  </div>
</ng-template>`;var ue=`.showMoreArea{margin-top:24px}
`;var he=`<div class="modal-header">
  <span class="text-lg">{{(currentRegion ? currentRegion.name : 'REGION.TITLE_NEW_REGION' ) | translate}}</span>
</div>

<div class="modal-body">
  <form class="form" [formGroup]="regionForm">
    <div class="form-group">
      <label for="regionName">{{'REGION.NAME' | translate}}</label>
      <div class="input-group">
        <input id="regionName" type="text" formControlName="name" class="form-control form-control-sm"
          [ngClass]="{'is-invalid': regionForm.get('name').touched && regionForm.get('name').invalid}">
        <ng-template
          *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: regionForm, control:regionForm.get('name')}">
        </ng-template>
      </div>
    </div>

    <div class="form-group">
      <div class="form-check form-check-inline">
        <input type="checkbox" id="regionAntipassback" formControlName="antipassback" class="form-check-input"
          (change)="onAntiPassbackSelectionChanged($event)">
        <label class="form-check-label" for="regionAntipassback">{{'REGION.ANTIPASSBACK' | translate}}</label>
      </div>
    </div>

    <div class="form-group">
      <label for="regionLockDuration">{{'REGION.LOCK_DURATION' | translate}}</label>
      <input id="regionLockDuration" type="number" formControlName="lockDuration" min="0" max="999999"
        class="form-control form-control-sm"
        [ngClass]="{'is-invalid': regionForm.get('lockDuration').touched && regionForm.get('lockDuration').invalid}">
      <ng-template
        *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: regionForm, control:regionForm.get('lockDuration')}">
      </ng-template>
    </div>

    <div class="form-group mt-4 pt-3 b-t-1">
      <label for="regionCapacity">{{'REGION.CAPACITY' | translate}}</label>
      <input id="regionCapacity" type="number" formControlName="capacity" min="0" max="999999"
        class="form-control form-control-sm"
        [ngClass]="{'is-invalid': regionForm.get('capacity').touched && regionForm.get('capacity').invalid}">
      <ng-template
        *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: regionForm, control:regionForm.get('capacity')}">
      </ng-template>
    </div>

    <div class="form-group ">
      <div class="form-check form-check-inline">
        <input type="checkbox" id="regionTerminateVisitOnExit" formControlName="terminateVisitOnExit"
          class="form-check-input">
        <label class="form-check-label" for="regionTerminateVisitOnExit">{{'REGION.TERMINATE_VISTI_ON_EXIT' |
          translate}}</label>
      </div>
    </div>

    <div class="form-group mt-4 pt-3 b-t-1">
      <div class="form-check form-check-inline align-items-baseline">
        <input type="checkbox" id="deployDeviceEmergency" formControlName="deliverDeviceEmergencyToRegionDevices"
          class="form-check-input">
        <label class="form-check-label" for="deployDeviceEmergency">{{'REGION.DEVICE_EMERGENCY' | translate}}</label>
      </div>
    </div>
  </form>

</div>

<div class="modal-footer">
  <button class="btn btn-outline-primary" (click)="onCancelClicked($event)">{{'BUTTON.CANCEL' | translate}}</button>
  <button class="btn btn-primary" (click)="onSaveClicked($event)" [disabled]="regionForm.invalid">{{'BUTTON.SAVE' |
    translate}}</button>
</div>

<!-- FORM FIELD VALIDATION -->
<ng-template #controlValidationTemplate let-form let-control="control">
  <ng-container *ngIf="control.errors">
    <div class="invalid-feedback d-flex flex-column" style="display: initial;">
      <span *ngIf="control.errors.required">{{'VALIDATION.REQUIRED'|translate}}</span>
      <span *ngIf="control.errors.numeric">{{'VALIDATION.POSITIVE_NUMBER'|translate}}</span>
      <span *ngIf="control.errors.max">{{'VALIDATION.MAX_VALUE'|translate:control.errors.max}}</span>
      <span *ngIf="control.errors.maxlength">{{'VALIDATION.MAX_LENGTH'|translate: {
        max:control.errors.maxlength.requiredLength} }}</span>
      <span *ngIf="control.errors.min">{{'VALIDATION.MIN_VALUE'|translate:control.errors.min}}</span>
      <span *ngIf="control.errors.minlength">{{'VALIDATION.MIN_LENGTH'|translate: {
        min:control.errors.minlength.requiredLength} }}</span>
    </div>
  </ng-container>
</ng-template>`;var fe="";var ye=function(s,e,t,i){var o=arguments.length,n=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(s,e,t,i);else for(var a=s.length-1;a>=0;a--)(r=s[a])&&(n=(o<3?r(n):o>3?r(e,t,n):r(e,t))||n);return o>3&&n&&Object.defineProperty(e,t,n),n},S=class extends f{regionService;interactionService;regionForm=new V({name:new R(null,[v.required,v.maxLength(255)]),antipassback:new R(!1,v.required),lockDuration:new R(null,[v.required,v.max(999999)]),capacity:new R(null,[Y.numeric({acceptValue:$.PositiveNumber,allowDecimal:!1}),v.max(999999)]),terminateVisitOnExit:new R(!1),deliverDeviceEmergencyToRegionDevices:new R(!1)});FORM_FIELD_NAME="name";FORM_FIELD_ANTIPASSBACK="antipassback";FORM_FIELD_LOCKDURATION="lockDuration";FORM_FIELD_CAPACITY="capacity";FORM_FIELD_DEVICE_EMERGENCY="deliverDeviceEmergencyToRegionDevices";FORM_FIELD_TERMINATEVISITONEXIT="terminateVisitOnExit";currentRegion;constructor(e,t){super(),this.regionService=e,this.interactionService=t}get isAntipassbackSelected(){return this.regionForm&&this.regionForm.get(this.FORM_FIELD_ANTIPASSBACK).value}onModalInitialized(){super.onModalInitialized(),this.setRegionData(this.currentRegion)}isFormFieldInvalid(e){return B(this.regionForm,e)}onAntiPassbackSelectionChanged(e){this.changeLockDurationState()}onSaveClicked(e){let t=new D;t.id=this.currentRegion?this.currentRegion.id:void 0,t.name=this.regionForm.get(this.FORM_FIELD_NAME).value||"",t.antiPassback=this.isAntipassbackSelected,t.antiPassbackLockDuration=this.isAntipassbackSelected&&this.regionForm.get(this.FORM_FIELD_LOCKDURATION).value||"",t.capacity=this.regionForm.get(this.FORM_FIELD_CAPACITY).value||null,t.terminateVisitOnExit=this.regionForm.get(this.FORM_FIELD_TERMINATEVISITONEXIT).value||null,t.deliverDeviceEmergencyToRegionDevices=this.regionForm.get(this.FORM_FIELD_DEVICE_EMERGENCY).value||!1,this.regionService.upsertRegion(t).subscribe(i=>{this.interactionService.showMessage(t.id?"REGION.INSERT_SUCCEED":"REGION.UPDATE_SUCCEED",null,k.Success),this.closeModal(i)})}setRegionData(e){this.regionForm.get(this.FORM_FIELD_NAME).setValue(e&&e.name||null),this.regionForm.get(this.FORM_FIELD_ANTIPASSBACK).setValue(e?e.antiPassback:!1),this.changeLockDurationState(),this.regionForm.get(this.FORM_FIELD_LOCKDURATION).setValue(e&&this.isAntipassbackSelected?e.antiPassbackLockDuration:null),this.regionForm.get(this.FORM_FIELD_CAPACITY).setValue(e&&e.capacity||null),this.regionForm.get(this.FORM_FIELD_TERMINATEVISITONEXIT).setValue(e&&e.terminateVisitOnExit||!1),this.regionForm.get(this.FORM_FIELD_DEVICE_EMERGENCY).setValue(e&&e.deliverDeviceEmergencyToRegionDevices||!1)}changeLockDurationState(){this.regionForm.get(this.FORM_FIELD_LOCKDURATION).setValue(null),this.isAntipassbackSelected?this.regionForm.get(this.FORM_FIELD_LOCKDURATION).enable():this.regionForm.get(this.FORM_FIELD_LOCKDURATION).disable()}static ctorParameters=()=>[{type:g},{type:u}];static propDecorators={currentRegion:[{type:p}]}};S=ye([c({selector:"armon-region-edit-modal",template:he,standalone:!0,imports:[b,W,x,y,m,d],styles:[fe]})],S);var ve=`<div class="modal-header">
	<div class="d-flex flex-column">
		<span class="text-lg">{{(isEdit ? 'COMMON.EDIT_MANAGER' : 'COMMON.ADD_MANAGER' ) | translate}}</span>
		<span class="text-sm fw-medium" *ngIf="data.region?.name">{{data.region.name}}</span>
	</div>
</div>
<div class="modal-body">
	<div class="row">
		<div class="col-12">
			<ng-container *ngIf="isEdit">
				<armon-captionlines *ngIf="manager.userCaptions" [showBorder]="false"
					[captionlines]="manager.userCaptions"></armon-captionlines>
			</ng-container>
			<ng-container *ngIf="!isEdit">
				<div class="form-group">
					<label>{{'IDENTITY.TITLE' | translate : languageService.userTranslate}}</label>
					<armon-select-search query="identity" [(ngModel)]="manager.userId" [searchFilters]="searchFilters"
						(ngModelChange)="onIdentityChanged($event)">
					</armon-select-search>
					<div class="invalid-feedback d-block" *ngIf="!manager.userId">
						{{'VALIDATION.REQUIRED'|translate}}
					</div>
				</div>
			</ng-container>
		</div>
		<div class="col-12 my-3">
			<label>{{'REGION.USER_RIGHTS' | translate}}</label>
			<div class="invalid-feedback d-block"
				*ngIf="manager.userRights.read==false && manager.userRights.write==false && manager.userRights.notify==false">
				{{'VALIDATION.MIN_ONE_SELECTED'|translate}}
			</div>
		</div>
		<div class="col-12">
			<div class="form-group">
				<div class="form-check">
					<input id="readInput" type="checkbox" [(ngModel)]="manager.userRights.read" name="readInput"
						(ngModelChange)="onModalChanged($event)" class="form-check-input"
						[disabled]="manager.userRights.write==true || manager.userRights.notify==true">
					<label class="form-check-label cursor-pointer" for="readInput">{{'REGION.USER_RIGHT_READ' |
						translate}}</label>
				</div>
			</div>
		</div>
		<div class="col-12">
			<div class="form-group">
				<div class="form-check">
					<input id="writeInput" type="checkbox" [(ngModel)]="manager.userRights.write" name="writeInput"
						(ngModelChange)="onModalChanged($event)" class="form-check-input"
						[disabled]="mustWrite || !hasSystemWrite">
					<label class="form-check-label cursor-pointer" for="writeInput">{{'REGION.USER_RIGHT_WRITE' |
						translate}}</label>
				</div>
				<small *ngIf="mustWrite" class="text-xs text-italic">
					{{'REGION.FIRST_MANAGER_WRITE'|translate}}
				</small>
				<small *ngIf="!hasSystemWrite && manager.userId" class="text-xs text-italic">
					{{'REGION.SYSTEM_WRITE_REQUIRED'|translate}}
				</small>
			</div>
		</div>
		<div class="col-12">
			<div class="form-group">
				<div class="form-check">
					<input id="notifyInput" type="checkbox" [(ngModel)]="manager.userRights.notify" name="notifyInput"
						(ngModelChange)="onModalChanged($event)" class="form-check-input">
					<label class="form-check-label cursor-pointer" for="notifyInput">{{'REGION.USER_RIGHT_NOTIFY'
						| translate}}</label>
				</div>
			</div>
		</div>
	</div>
</div>
<div class="modal-footer">
	<button class="btn btn-outline-primary me-2" (click)="onCancelClicked($event)">{{'BUTTON.CANCEL' |
		translate}}</button>
	<button class="btn btn-primary" (click)="onSaveClicked($event)" [disabled]="disableSaveButton">{{'BUTTON.SAVE' |
		translate}}</button>
</div>`;var Re=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}
`;var De=function(s,e,t,i){var o=arguments.length,n=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(s,e,t,i);else for(var a=s.length-1;a>=0;a--)(r=s[a])&&(n=(o<3?r(n):o>3?r(e,t,n):r(e,t))||n);return o>3&&n&&Object.defineProperty(e,t,n),n},O=class extends f{interactionService;sessionService;languageService;identityService;regionService;data;manager;isEdit;mustWrite;disableSaveButton=!0;hasSystemWrite=!1;hasSystemRead=!1;searchFilters;constructor(e,t,i,o,n){super(),this.interactionService=e,this.sessionService=t,this.languageService=i,this.identityService=o,this.regionService=n}ngOnInit(){this.manager=this.data.manager,this.isEdit=this.data.forceToAdd?!1:this.data.manager.userId&&this.data.manager.userId!="",this.mustWrite=this.data.mustWrite,this.mustWrite==!0?(this.manager.userRights.write=!0,this.searchFilters={permissions:[l.REGION.getWrite()]}):this.searchFilters={permissionsOr:[l.REGION.getRead(),l.REGION.getWrite()]},(this.isEdit||this.data.forceToAdd)&&this.onIdentityChanged(null),this.validate()}ngOnDestroy(){}validate(){return(this.manager.userRights.write||this.manager.userRights.notify)&&(this.manager.userRights.read=!0),this.disableSaveButton=!this.manager.userId||this.manager.userId==""||this.manager.userRights.read==!1&&this.manager.userRights.write==!1&&this.manager.userRights.notify==!1,!this.disableSaveButton}upsertManager(){let e=J.getEmptyModel(this.manager.userId);e.userRights=this.manager.userRights,this.regionService.upsertRegionManager(this.data.region.id,e).subscribe(t=>{this.closeModal(t)})}onModalChanged(e){this.validate()}onIdentityChanged(e){if(this.manager.userId){let t=new te;t.permissions=[l.REGION.getRead(),l.REGION.getWrite()],this.identityService.queryIdentityPermissions(this.manager.userId,t).subscribe(i=>{this.hasSystemRead=i.permissions[l.REGION.getRead()]?i.permissions[l.REGION.getRead()]:!1,this.hasSystemWrite=i.permissions[l.REGION.getWrite()]?i.permissions[l.REGION.getWrite()]:!1,this.hasSystemWrite==!1&&(this.manager.userRights.write=!1),this.validate()})}}onSaveClicked(e){this.validate&&this.upsertManager()}static ctorParameters=()=>[{type:u},{type:h},{type:q},{type:oe},{type:g}];static propDecorators={data:[{type:p}]}};O=De([c({selector:"armon-region-manager-upsert-modal",template:ve,standalone:!0,imports:[m,L,w,b,d],styles:[Re]})],O);var Ee=`<div class="card mb-3">

  <div class="card-body p-4 mhs-10" [ngClass]="{'emergency-container': region.isEmergency}">
    <div class="d-flex">
      <div class="region-icon me-3">
        <cds-icon shape="region" size="lg"></cds-icon>
      </div>
      <div class="d-flex flex-column flex-grow-1">
        <span class="text-lg fw-medium mb-2">{{region.name}}</span>
        <span class="text-sm fw-normal"
          *ngIf="region.accessControlPointCount && region.accessControlPointCount>0">{{region.accessControlPointCount}}
          {{'REPORT.ACCESS_CONTROL_POINT'|translate}}</span>
        <span class="text-sm" *ngIf="region.antiPassback">{{'REGION.ANTIPASSBACK' | translate}}
          ({{region.antiPassbackLockDuration}} {{'COMMON.SECONDS'|translate}})</span>
      </div>
      <div *ngIf="region.isEmergency" class="ms-2">
        <cds-icon shape="emergency" style="width: 20px; height: 20px;" nz-tooltip
          nzTooltipTitle="{{'TERMINAL.EMERGENCY'| translate}}" class="blink">
        </cds-icon>
      </div>
    </div>
  </div>

  <div class="card-footer" *ngIf="visibleButtons.length > 0">

    <button class="btn btn-sm btn-link" *ngFor="let button of visibleButtons"
      (click)="onFooterButtonClicked($event, button.event)">{{button.text | translate}}</button>

    <button nz-dropdown [nzDropdownMenu]="menuSub" class="btn btn-link btn-sm me-2" *ngIf="hiddenButtons.length > 0"
      [nzClickHide]="true">
      <cds-icon shape="ellipsis-horizontal"></cds-icon>
    </button>
    <nz-dropdown-menu #menuSub="nzDropdownMenu">
      <ul nz-menu>
        <li nz-menu-item *ngFor="let button of hiddenButtons" (click)="onFooterButtonClicked($event, button.event)">
          {{button.text | translate}}</li>
      </ul>
    </nz-dropdown-menu>
  </div>

</div>


<ng-template #deleteWarningsModalTemplate let-modal>
  <div class="modal-header">
    {{region.name}}
  </div>
  <div class="modal-body">
    <div class="row mb-4">
      <div class="col-12">
        <span class="text-md">{{'REGION.DELETE_WARNINGS_TITLE'|translate}}</span>
      </div>
    </div>
    <div class="row mx-1 py-2 px-1 mb-4 b-1 rounded">
      <ng-container *ngFor="let warning of deleteWarnings">
        <div class="col-12">
          <cds-icon shape="link" class="me-2 cds-icon-12"></cds-icon><span
            class="text-sm">{{warning}}</span>
        </div>
      </ng-container>
    </div>
    <div class="row">
      <div class="col-12">
        <span class="text-md text-danger">{{'REGION.DELETE_WARNINGS_CONFIRMATION'|translate}}</span>
      </div>
    </div>
  </div>
  <div class="modal-footer">
    <button class="btn btn-outline-primary me-2" (click)="modal.dismiss()">{{'BUTTON.CANCEL' |
      translate}}</button>
    <button class="btn btn-danger" (click)="modal.close()">{{'BUTTON.DELETE' | translate}}
    </button>
  </div>
</ng-template>`;var Ie=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}.region-icon{width:42px;min-width:42px;height:42px;min-height:42px;display:-webkit-box;display:-moz-box;display:-webkit-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-orient:vertical;-moz-box-orient:vertical;-webkit-flex-direction:column;-moz-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;-webkit-align-items:center;-moz-align-items:center;align-items:center;-webkit-border-radius:.375rem;-moz-border-radius:.375rem;border-radius:.375rem;color:#fff;background-color:#0a2a5a}.emergency-container{background-color:#fdf8f7}.blink{-webkit-animation:blink 1.3s linear infinite;-moz-animation:blink 1.3s linear infinite;animation:blink 1.3s linear infinite}@keyframes blink{0%{color:#c82602}40%{color:#fae9e6}80%{color:#c82602}to{color:#c82602}}@-webkit-keyframes blink{0%{color:#c82602}40%{color:#fae9e6}80%{color:#c82602}to{color:#c82602}}
`;var be=`<div class="modal-header">
  <div class="d-flex flex-column">
    <span class="text-lg">{{'REGION.TITLE_ACCESS_CONTROL_POINTS' | translate}}</span>
    <span class="text-sm fw-medium" *ngIf="currentRegion">{{currentRegion.name}}</span>
  </div>
</div>
<div class="modal-body mhs-15">
  <div class="row" *ngIf="visibleComponent">
    <div class="col-12">
      <label class="report-form-label">{{'REPORT.ACCESS_CONTROL_POINTS' | translate}}</label>
      <armon-select-search query="point" [allowMulti]="true" [(ngModel)]="editedAccessControlPointIds"
        [maxTagCount]="20">
      </armon-select-search>
    </div>
    <div class="col-12 mt-3 mb-3" *ngIf="currentRegion && accessControlPointIds.length == 0">
      <div class="alert alert-warning" role="alert">
        {{'REGION.INFO_NO_ACCESS_CONTROL_POINT' | translate}}
      </div>
    </div>
  </div>
</div>

<div class="modal-footer">
  <button class="btn btn-outline-primary" (click)="onCancelClicked($event)">{{'BUTTON.CANCEL' | translate}}</button>
  <button class="btn btn-primary" (click)="onSaveClicked($event)">{{'BUTTON.SAVE' | translate}}</button>
</div>`;var Ce="";var Ue=function(s,e,t,i){var o=arguments.length,n=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(s,e,t,i);else for(var a=s.length-1;a>=0;a--)(r=s[a])&&(n=(o<3?r(n):o>3?r(e,t,n):r(e,t))||n);return o>3&&n&&Object.defineProperty(e,t,n),n},G=class extends f{regionService;interactionService;sessionService;region;currentRegion;accessControlPointIds;editedAccessControlPointIds;visibleComponent=!1;constructor(e,t,i){super(),this.regionService=e,this.interactionService=t,this.sessionService=i}onModalInitialized(){super.onModalInitialized(),this.getRegionAccessControlPoints(this.region)}onSaveClicked(e){let t=[],i=[];if((this.editedAccessControlPointIds?this.editedAccessControlPointIds:[]).forEach(o=>{this.accessControlPointIds.findIndex(n=>n==o)==-1&&t.push(o)}),this.accessControlPointIds.forEach(o=>{(this.editedAccessControlPointIds?this.editedAccessControlPointIds:[]).findIndex(n=>n==o)==-1&&i.push(o)}),t.length>0||i.length>0){let o=new ne;o.addedIds=t||[],o.removedIds=i||[],this.regionService.upsertRegionAccessControlPoints(this.currentRegion.id,o).subscribe(()=>{this.interactionService.showMessage("REGION.UPDATE_SUCCEED",null,k.Success),this.closeModal()})}else this.closeModal()}getRegionAccessControlPoints(e){this.currentRegion=e,this.regionService.listRegionAccessControlPoints(e.id).subscribe(t=>{this.accessControlPointIds=t.items.map(i=>i.id),this.editedAccessControlPointIds=t.items.map(i=>i.id),this.visibleComponent=!0})}static ctorParameters=()=>[{type:g},{type:u},{type:h}];static propDecorators={region:[{type:p}]}};G=Ue([c({selector:"armon-region-access-control-points-modal",template:be,standalone:!0,imports:[m,w,b,d],styles:[Ce]})],G);var Ne=`<div class="modal-header">
	<div class="d-flex flex-column">
		<span class="text-lg">{{'COMMON.MANAGERS'|translate}}</span>
		<span class="text-sm fw-medium" *ngIf="region && region.name">{{region.name}}</span>
	</div>
</div>
<div class="modal-body d-flex flex-column">
	<div class="mb-3" *ngIf="hasUserRightWrite">
		<button class="btn btn-sm btn-primary"
			(click)="onAddManagerClicked($event)">{{'COMMON.ADD_MANAGER'|translate}}</button>
	</div>
	<div class="d-flex flex-column column-gap-2 mhs-25 mxh-vh-60 overflow-auto px-2" id="region-managers-items">
		<ng-container *ngIf="managers">
			<ng-container *ngFor="let manager of managers">
				<ng-template *ngTemplateOutlet="managerTemplate;context: {$implicit:manager}">
				</ng-template>
			</ng-container>
			<div *ngIf="isLoading==false && managers.length == 0" class="d-flex flex-column">
				<nz-empty [nzNotFoundContent]="contentTpl" [nzNotFoundImage]="'./assets/images/empty/search_user.png'"
					class="my-5">
					<ng-template #contentTpl>
						<span>{{'REGION.NO_MANAGER_INFO'|translate}}</span>
					</ng-template>
				</nz-empty>
				<div class="alert alert-warning mt-5 text-center" role="alert">
					<span>{{'REGION.NO_MANAGER_ALERT' | translate}}</span><span class="ms-1"
						*ngIf="hasUserRightWrite">{{'REGION.ADD_MANAGER_ALERT'|translate}}</span>
				</div>
			</div>
		</ng-container>
	</div>
	<div>
		<armon-pagination [paginationResponse]="paginationResponse" [scrollDomId]="'region-managers-items'"
			(pageChanged)="pageChanged($event)"></armon-pagination>
	</div>
</div>
<div class="modal-footer">
	<button class="btn btn-outline-primary" (click)="onCancelClicked($event)">{{'BUTTON.CLOSE' | translate}}</button>
</div>

<!-- TEMPLATES -->
<ng-template #managerTemplate let-manager>
	<div class="row shadow-box-1 my-2 mx-0 rounded rounded-2">
		<div class="col-12 p-3">
			<armon-captionlines *ngIf="manager.userCaptions" [showBorder]="false" [captionlines]="manager.userCaptions">
			</armon-captionlines>
		</div>
		<div class="col-12 b-t-1 p-3">
			<span class="text-md">{{'REGION.USER_RIGHTS' | translate}}</span>
			<div class="d-flex text-sm">
				<span class="comma me-1" *ngIf="manager.userRights.read">{{'REGION.USER_RIGHT_READ'|translate}}</span>
				<span class="comma me-1" *ngIf="manager.userRights.write">{{'REGION.USER_RIGHT_WRITE'|translate}}</span>
				<span class="comma me-1"
					*ngIf="manager.userRights.notify">{{'REGION.USER_RIGHT_NOTIFY'|translate}}</span>
			</div>
		</div>
		<div class="col-12 p-3 d-flex justify-content-end" *ngIf="hasUserRightWrite">
			<button class="btn btn-sm btn-outline-danger me-2"
				(click)="onDeleteManagerClicked(manager)">{{'BUTTON.DELETE' | translate}}</button>
			<button class="btn btn-sm btn-outline-primary" (click)="onEditManagerClicked(manager)">{{'BUTTON.EDIT' |
				translate}}</button>
		</div>
	</div>
</ng-template>`;var Se=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}
`;var ze=function(s,e,t,i){var o=arguments.length,n=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(s,e,t,i);else for(var a=s.length-1;a>=0;a--)(r=s[a])&&(n=(o<3?r(n):o>3?r(e,t,n):r(e,t))||n);return o>3&&n&&Object.defineProperty(e,t,n),n},U=class extends f{sessionService;regionService;authService;interactionService;modalService;region;request;paginationResponse=new A;isLoading=!0;managers;hasUserRightWrite=!1;constructor(e,t,i,o,n){super(),this.sessionService=e,this.regionService=t,this.authService=i,this.interactionService=o,this.modalService=n}ngOnInit(){this.hasUserRightWrite=this.region&&this.region.userRights&&this.region.userRights.write&&this.authService.checkPermission(l.IDENTITY.getReadBasic()),this.request=Q.getEmptyModel(),this.getManagers()}ngOnDestroy(){}getManagers(){this.isLoading=!0,this.managers=[],this.regionService.getRegionManagerList(this.region.id,this.request).subscribe(e=>{this.managers=e.items,this.paginationResponse=e.pagination,this.isLoading=!1})}pageChanged(e){this.request.pagination=e,this.getManagers()}showUpsertModal(e,t=!1){this.hasUserRightWrite&&this.modalService.open(O,{props:{data:{region:this.region,manager:e,mustWrite:this.managers.length==0}}}).result.then(i=>{this.getManagers(),i.userId==this.sessionService.currentUserId&&i.userRights.write==!1&&this.cancelModal()}).catch(i=>{})}onAddManagerClicked(e){this.hasUserRightWrite&&this.showUpsertModal(C.getEmptyModel())}onEditManagerClicked(e){if(!this.hasUserRightWrite)return;let t=C.getEmptyModel();t.createInstance(z(e),C,t),this.showUpsertModal(t,!0)}onDeleteManagerClicked(e){this.hasUserRightWrite&&this.interactionService.showDialog("COMMON.DELETE_MANAGER","REGION.DELETE_MANAGER_INFO",null,null,!0,"BUTTON.DELETE","BUTTON.CANCEL",!0,()=>{this.regionService.deleteRegionManager(e.userRegionRightId).subscribe(t=>{e.userId==this.sessionService.currentUserId?this.closeModal():this.getManagers()})})}static ctorParameters=()=>[{type:h},{type:g},{type:N},{type:u},{type:I}];static propDecorators={region:[{type:p}]}};U=ze([c({selector:"armon-region-managers-modal",template:Ne,standalone:!0,imports:[m,E,y,ee,F,L,d],styles:[Se]})],U);var je=function(s,e,t,i){var o=arguments.length,n=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(s,e,t,i);else for(var a=s.length-1;a>=0;a--)(r=s[a])&&(n=(o<3?r(n):o>3?r(e,t,n):r(e,t))||n);return o>3&&n&&Object.defineProperty(e,t,n),n},P=class extends ge{regionService;interactionService;modalService;socketService;routingService;authService;region;regionDeleted=new T;regionEdited=new T;regionEmergencyChanged=new T;regionUserRightsUpdated=new T;deleteWarningsModalTemplate;deleteWarnings=[];subscriptionRegionEmergencyState;constructor(e,t,i,o,n,r){super(r),this.regionService=e,this.interactionService=t,this.modalService=i,this.socketService=o,this.routingService=n,this.authService=r}ngOnInit(){this.subscriptionRegionEmergencyState=this.socketService.onRegionEmergencyStateReceived.subscribe(e=>{e&&e.rid==this.region.id&&(this.region.emergencyState=e.s,this.region.isEmergency=D.getIsEmergency(this.region.emergencyState),this.clearButtons(),this.initializeButtons())}),this.initializeButtons()}ngOnDestroy(){this.subscriptionRegionEmergencyState&&this.subscriptionRegionEmergencyState.unsubscribe()}initializeButtons(){let e=this.region&&this.region.userRights&&this.region.userRights.write;e&&(this.addButton("BUTTON.EDIT",this.onEditRegionButtonClicked),this.addButton("BUTTON.ACCESS_CONTROL_POINTS",this.onEditAccessControlPointsButtonClicked),this.addButton("COMMON.MANAGERS",this.onManagersClicked)),this.addButton(this.region.isEmergency?"TERMINAL.EMERGENCY_END_BUTTON":"TERMINAL.EMERGENCY_START_BUTTON",this.onEmergencyButtonClicked,l.SYSTEM.getEmergency()),this.addButton("BUTTON.SHOW_REGION_STATE",this.onShowReportButtonClicked,[l.ACCESSLOG.getReportDetailed(),l.REGION.getRead()]),e&&this.addButton("BUTTON.DELETE",this.onDeleteButtonClicked)}onEditRegionButtonClicked(){this.regionService.getRegionDetailed(this.region.id).subscribe(e=>{this.modalService.open(S,{settings:{size:"md"},props:{currentRegion:e}}).result.then(t=>{this.regionEdited.emit()}).catch(t=>{})})}onEditAccessControlPointsButtonClicked(){this.modalService.open(G,{settings:{size:"lg"},props:{region:this.region}}).result.then(e=>{this.regionEdited.emit()}).catch(e=>{})}onDeleteButtonClicked(){this.interactionService.showDialog(this.region.name,"REGION.APPROVE_FOR_DELETE",null,null,!0,"BUTTON.DELETE","",!0,()=>{this.requestDeleteRegion()})}requestDeleteRegion(e=!1){this.regionService.deleteRegion(this.region.id,e).subscribe({next:()=>{this.regionDeleted.emit(this.region.id)},error:t=>{setTimeout(()=>{t&&t.status&&t.status===j.RegionDeleteWarnings&&(this.deleteWarnings=JSON.parse(t.error).warnings,this.modalService.openTemplate(this.deleteWarningsModalTemplate,{settings:{size:"lg"}}).result.then(i=>{this.requestDeleteRegion(!0)}).catch(i=>{}))},400)}})}onManagersClicked(e){this.modalService.open(U,{settings:{size:"lg"},props:{region:this.region}}).result.then(t=>{this.regionUserRightsUpdated.emit()}).catch(t=>{})}onShowReportButtonClicked(){this.routingService.gotoReportRegion(this.region.id)}onEmergencyButtonClicked(){this.region.isEmergency?this.interactionService.showDialog("TERMINAL.EMERGENCY","REGION.EMERGENCY_END_CONFIRMATION",null,this.region,!0,"TERMINAL.EMERGENCY_END_BUTTON","",!0,()=>{this.regionService.endEmergency(this.region.id).subscribe(()=>{this.regionEmergencyChanged.emit()})}):this.interactionService.showDialog("TERMINAL.EMERGENCY","REGION.EMERGENCY_START_CONFIRMATION",null,this.region,!0,"TERMINAL.EMERGENCY_START_BUTTON","",!0,()=>{this.regionService.startEmergency(this.region.id).subscribe(()=>{this.regionEmergencyChanged.emit()})})}static ctorParameters=()=>[{type:g},{type:u},{type:I},{type:se},{type:re},{type:N}];static propDecorators={region:[{type:p}],regionDeleted:[{type:_}],regionEdited:[{type:_}],regionEmergencyChanged:[{type:_}],regionUserRightsUpdated:[{type:_}],deleteWarningsModalTemplate:[{type:M,args:["deleteWarningsModalTemplate"]}]}};P=je([c({selector:"armon-region-card",template:Ee,standalone:!0,imports:[x,m,Z,E,X,K,H,d],styles:[Ie]})],P);var Ve=function(s,e,t,i){var o=arguments.length,n=o<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,t):i,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(s,e,t,i);else for(var a=s.length-1;a>=0;a--)(r=s[a])&&(n=(o<3?r(n):o>3?r(e,t,n):r(e,t))||n);return o>3&&n&&Object.defineProperty(e,t,n),n},Oe=class{regionService;authService;sessionService;modalService;regions;permissionAddRegion;newRegion;request;filterText;paginationResponse=new A;askManagerModalTemplate;constructor(e,t,i,o){this.regionService=e,this.authService=t,this.sessionService=i,this.modalService=o}ngOnInit(){this.checkPermissions(),this.request=ie.getEmptyModel(),this.getData()}onFilterChanged(e){this.request.filter=e,this.getData()}onAddRegionButtonClicked(){this.modalService.open(S,{settings:{size:"md"}}).result.then(e=>{setTimeout(()=>{this.newRegion=e,this.modalService.openTemplate(this.askManagerModalTemplate).result.then(t=>{this.showManagerUpsertModal()},t=>{this.getData()}).catch(t=>{})},300)}).catch(e=>{})}showManagerUpsertModal(){setTimeout(()=>{let e=C.getEmptyModel();e.userId=this.sessionService.currentUserId,this.modalService.open(O,{props:{data:{region:this.newRegion,manager:e,mustWrite:!0,forceToAdd:!0}}}).result.then(i=>{this.getData()},i=>{this.getData()}).catch(i=>{})},300)}onRegionDeleted(e){this.getData()}onRegionEdited(e){this.getData()}onRegionEmergencyChanged(e){this.getData()}getData(){this.regionService.listRegions(this.request).subscribe(e=>{this.regions=e.items,this.paginationResponse=e.pagination})}checkPermissions(){this.permissionAddRegion=this.authService.checkPermission(l.REGION.getWrite())}pageChanged(e){this.request.pagination=e,this.getData()}static ctorParameters=()=>[{type:g},{type:N},{type:h},{type:I}];static propDecorators={askManagerModalTemplate:[{type:M,args:["askManagerModalTemplate"]}]}};Oe=Ve([c({selector:"armon-manage-regions",template:pe,animations:ae,standalone:!0,imports:[de,ce,le,me,m,E,P,F,d],styles:[ue]})],Oe);export{Oe as ManageRegionsComponent};
