import{a as _e}from"./chunk-I5K7GPAI.js";import{a as Se}from"./chunk-XOY5UTVP.js";import{a as ge}from"./chunk-G7OJYPNY.js";import{a as fe}from"./chunk-D4RZOGGF.js";import{a as ve,b as Ce,c as Re}from"./chunk-UZB7YFT6.js";import{a as Ae}from"./chunk-5OT2MLHH.js";import{a as Te}from"./chunk-4MZCYQX4.js";import{b as Ee,c as ye,d as be}from"./chunk-YOJ4KGSB.js";import"./chunk-I6FSQTEP.js";import"./chunk-CO3X7TQN.js";import{a as z}from"./chunk-VSFNMVXJ.js";import"./chunk-WQ6DP4JQ.js";import{Fb as me,Ob as he,k as L,s as ee,v as te,wb as k,y as se}from"./chunk-YSQLW2JA.js";import{Ad as ue,Bd as w,Cd as D,Dd as de,Ed as N,Fd as pe,I as ie,Z as re,xd as o,yd as oe,zd as ce}from"./chunk-NVJ2ZZFT.js";import{Aa as S,Ba as G,E as u,He as $,Mg as M,Nc as T,Ng as O,Pd as C,Qf as g,Rd as A,Sc as W,Sd as _,Se as Q,Te as R,Uc as d,Ue as J,Ve as I,Wc as p,Xc as X,Ye as U,Yg as ae,_a as V,ab as h,ad as K,af as x,bb as v,bh as ne,dc as b,dd as f,ea as j,eh as le,gb as Y,ha as B,kg as Z,ng as q,rb as H,ya as m}from"./chunk-SKPDQO4E.js";var Ie=`<div class="h-100">\r
  <side-navigation>\r
    <ng-template side-navigation-nav>\r
      <!-- Filtering area -->\r
      <label class="report-form-label">{{'ACCESS_RULES.SEARCH_SET' | translate}}</label>\r
      <armon-filter-input [maxLength]="20" (entryCompleted)="onFilterChanged($event)" placeholder="COMMON.SEARCH">\r
      </armon-filter-input>\r
    </ng-template>\r
    <ng-template side-navigation-content>\r
      <!-- Listing area -->\r
      <div class="row my-3">\r
        <div class="col-12">\r
          <!-- Add new region button -->\r
          <button class="btn btn-sm btn-primary" (click)="onAddRuleSetButtonClicked()">{{'ACCESS_RULES.ADD_SET' |\r
            translate}}</button>\r
        </div>\r
      </div>\r
      <div class="row" [@listAnimation]="rulesets.length">\r
        <div class="col-xxxl-6 col-12" *ngFor="let ruleset of rulesets">\r
          <armon-manage-access-ruleset-card [ruleset]="ruleset" (itemUpdated)="onItemUpdated($event)"\r
            (itemDeleted)="onItemDeleted($event)"></armon-manage-access-ruleset-card>\r
        </div>\r
      </div>\r
      <div class="row pb-3">\r
        <div class="col-xl-12">\r
          <armon-pagination [paginationResponse]="paginationResponse" (pageChanged)="pageChanged($event)">\r
          </armon-pagination>\r
        </div>\r
      </div>\r
    </ng-template>\r
  </side-navigation>\r
</div>`;var Ue="";var xe=`<ng-container *ngIf="visibleComponent">
  <div class="modal-header">
    <span class="text-lg">{{(editMode ? ruleSet.name : 'ACCESS_RULES.ADD_SET' ) | translate}}</span>
  </div>
  <div class="modal-body">
    <div class="row">
      <div class="col-12">
        <div class="form-group">
          <label for="nameInput" class="required">{{'ACCESS_RULES.SET_NAME' | translate}}</label>
          <input type="text" id="nameInput" [(ngModel)]="ruleSet.name" maxlength="128"
            class="form-control form-control-sm" (ngModelChange)="onModelChanged($event)">
        </div>
      </div>
      <div class="col-12">
        <div class="form-group">
          <label for="regionInput" class="required">{{'ACCESS_RULES.SET_REGION' | translate}}</label>
          <armon-select-search query="region" [allowMulti]="false" [(ngModel)]="ruleSet.region.id"
            (ngModelChange)="onModelChanged($event)">
          </armon-select-search>
        </div>
      </div>
      <div class="col-12">
        <div class="form-group">
          <nz-switch [(ngModel)]="ruleSet.isActive" (ngModelChange)="onModelChanged($event)">
          </nz-switch>
          <label class="ms-2">
            <span class="badge text-bg-success p-2" *ngIf="ruleSet.isActive">{{'ACCESS_RULES.SET_ACTIVE_TRUE' |
              translate}}</span>
            <span class="badge text-bg-warning p-2" *ngIf="!ruleSet.isActive">{{'ACCESS_RULES.SET_ACTIVE_FALSE' |
              translate}}</span>
          </label>
        </div>
      </div>
      <div class="col-12">
        <div class="form-group">
          <label for="statusInput" class="required">{{'ACCESS_RULES.SET_UNCOVERED_STATUS' | translate}}</label>
          <select [(ngModel)]="ruleSet.uncoveredAccessStatus" id="statusInput" class="form-select form-select-sm"
            (ngModelChange)="onModelChanged($event)">
            <option *ngFor="let accessRulesStatus of accessRulesStatusList" [ngValue]="accessRulesStatus.type">
              {{accessRulesStatus.description
              | translate}}</option>
          </select>
        </div>
      </div>
      <div class="col-12">
        <div class="form-row">
          <div class=" form-group col-xl-6 col-md-12">
            <label>{{'ACCESS_RULES.SET_START_DATE' | translate}}</label>
            <input [(ngModel)]="ruleSet.startUtc" type="text" readonly owlinput [max]="ruleSet.endUtc"
              class="form-control form-control-sm bg-white" (ngModelChange)="onModelChanged($event)" [owlDateTime]="dt1"
              [owlDateTimeTrigger]="dt1">
            <owl-date-time [firstDayOfWeek]="1" #dt1 [pickerType]="'calendar'"></owl-date-time>
          </div>
          <div class="form-group col-xl-6 col-md-12">
            <label>{{'ACCESS_RULES.SET_END_DATE' | translate}}</label>
            <input [(ngModel)]="ruleSet.endUtc" type="text" readonly owlinput [min]="ruleSet.startUtc"
              class="form-control form-control-sm bg-white" (ngModelChange)="onModelChanged($event)" [owlDateTime]="dt2"
              [owlDateTimeTrigger]="dt2">
            <owl-date-time [firstDayOfWeek]="1" #dt2 [pickerType]="'calendar'"></owl-date-time>
          </div>
        </div>
      </div>
      <div class="col-12">
        <div class="form-group">
          <label for="noteTextArea">{{'ACCESS_RULES.SET_NOTE' | translate}}</label>
          <textarea name="body" id="noteTextArea" [(ngModel)]="ruleSet.note" rows="4" cols="20" maxlength="512"
            class="form-control form-control-sm" (ngModelChange)="onModelChanged($event)"
            style="resize:none"></textarea>
        </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)="onAddClicked($event)" [disabled]="disableSaveButton">{{(editMode ?
      'BUTTON.EDIT' : 'BUTTON.ADD') | translate}}
    </button>
  </div>
</ng-container>`;var Le=`.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 F=class extends X{http;sessionService;configurationService;interactionService;constructor(e,t,s,r){super(e,t,s,r),this.http=e,this.sessionService=t,this.configurationService=s,this.interactionService=r}upsertRuleset(e){return this.requestPost(`/${this.sessionService.currentOrganizationId}/accessrule/ruleset/upsert`,e,null,d.User,p.User)}listRuleset(e){return this.requestPost(`/${this.sessionService.currentOrganizationId}/accessrule/ruleset/list`,e,"AccessRulesetListResponse",d.User,p.User)}detailRuleset(e){return this.requestGet(`/${this.sessionService.currentOrganizationId}/accessrule/ruleset/${e}`,"AccessRuleset",d.User,p.User)}deleteRuleset(e){return this.requestDelete(`/${this.sessionService.currentOrganizationId}/accessrule/ruleset/${e}`,null,d.User,p.User)}assignRuleset(e,t){return this.requestPost(`/${this.sessionService.currentOrganizationId}/accessrule/ruleset/${e}/assign`,t,null,d.User,p.User)}upsertRule(e,t){return this.requestPost(`/${this.sessionService.currentOrganizationId}/accessrule/ruleset/${e}/rule`,t,null,d.User,p.User)}listRule(e,t){return this.requestPost(`/${this.sessionService.currentOrganizationId}/accessrule/ruleset/${e}/rule/list`,t,"AccessRuleListResponse",d.User,p.User)}deleteRule(e,t){return this.requestDelete(`/${this.sessionService.currentOrganizationId}/accessrule/ruleset/${e}/rule/${t}`,null,d.User,p.User)}};var Be=function(a,e,t,s){var r=arguments.length,i=r<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(a,e,t,s);else for(var l=a.length-1;l>=0;l--)(n=a[l])&&(i=(r<3?n(i):r>3?n(e,t,i):n(e,t))||i);return r>3&&i&&Object.defineProperty(e,t,i),i},c=class extends W{http;configurationService;interactionService;sessionService;apiAccessRules;constructor(e,t,s,r){super(s,r),this.http=e,this.configurationService=t,this.interactionService=s,this.sessionService=r,this.apiAccessRules=new F(this.http,this.sessionService,this.configurationService,this.interactionService)}upsertRuleset(e){return this.apiAccessRules.upsertRuleset(e).pipe(u(t=>this.handleError(t,[])))}listRuleset(e){return this.apiAccessRules.listRuleset(e).pipe(u(t=>this.handleError(t,[])))}detailRuleset(e){return this.apiAccessRules.detailRuleset(e).pipe(u(t=>this.handleError(t,[])))}deleteRuleset(e){return this.apiAccessRules.deleteRuleset(e).pipe(u(t=>this.handleError(t,[])))}assignRuleset(e,t){return this.apiAccessRules.assignRuleset(e,t).pipe(u(s=>this.handleError(s,[])))}upsertRule(e,t){return this.apiAccessRules.upsertRule(e,t).pipe(u(s=>this.handleError(s,[{code:409,message:null}])))}listRule(e,t){return this.apiAccessRules.listRule(e,t).pipe(u(s=>this.handleError(s,[])))}deleteRule(e,t){return this.apiAccessRules.deleteRule(e,t).pipe(u(s=>this.handleError(s,[])))}static ctorParameters=()=>[{type:H},{type:K},{type:g},{type:C}]};c=Be([j({providedIn:"root"})],c);var Ge=function(a,e,t,s){var r=arguments.length,i=r<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(a,e,t,s);else for(var l=a.length-1;l>=0;l--)(n=a[l])&&(i=(r<3?n(i):r>3?n(e,t,i):n(e,t))||i);return r>3&&i&&Object.defineProperty(e,t,i),i},E=class extends _{sessionService;accessRulesService;interactionService;ruleSet;editMode;disableSaveButton=!0;visibleComponent=!1;accessRulesStatusList=w;constructor(e,t,s){super(),this.sessionService=e,this.accessRulesService=t,this.interactionService=s}onModalInitialized(){super.onModalInitialized(),this.ruleSet!==void 0&&this.ruleSet!==null&&(this.ruleSet=b(this.ruleSet),this.ruleSet.id&&this.ruleSet.id!=""?this.editMode=!0:(this.ruleSet.region||(this.ruleSet.region=new re),this.editMode=!1),this.validateSaveForm()),this.visibleComponent=!0}addRuleset(){this.accessRulesService.upsertRuleset(this.ruleSet).subscribe(e=>{this.interactionService.showMessage("ACCESS_RULES.COMPLETED_SET_UPSERT",null,T.Success),this.closeModal()})}validateSaveForm(){let e=!1;(!this.ruleSet.name||this.ruleSet.name=="")&&(e=!0),(!this.ruleSet.region||!this.ruleSet.region.id||this.ruleSet.region.id=="")&&(e=!0),(this.ruleSet.isActive==null||this.ruleSet.isActive==null)&&(e=!0),(this.ruleSet.uncoveredAccessStatus==null||this.ruleSet.uncoveredAccessStatus==null)&&(e=!0),this.disableSaveButton=e}onModelChanged(e){this.validateSaveForm()}onAddClicked(e){this.disableSaveButton||this.addRuleset()}static ctorParameters=()=>[{type:C},{type:c},{type:g}];static propDecorators={ruleSet:[{type:S}]}};E=Ge([m({selector:"armon-manage-access-ruleset-upsert",template:xe,standalone:!0,providers:[{provide:I,useClass:L}],imports:[v,R,k,me,h,U,f],styles:[Le]})],E);var Me=`<div class="card mb-3">
  <div class="card-header d-flex">
    <div class="d-flex flex-column flex-lg-grow-1">
      <span class="text-md">{{ruleset.name}}</span>
      <span class="text-sm text-italic mt-1"
        *ngIf="ruleset.startUtc || ruleset.endUtc">{{'ACCESS_RULES.SET_DATES'|translate}} :
        {{ruleset.startUtcText}} / {{ruleset.endUtcText}} </span>
    </div>
    <div class="ms-auto d-flex align-items-center column-gap-1">
      <armon-icon-label [colorCode]="4" *ngIf="!ruleset.isActive">
        <ng-template icon-label-icon>
          <cds-icon shape="warning-standard"></cds-icon>
        </ng-template>
        <ng-template icon-label-content>
          <span>{{'ACCESS_RULES.SET_ACTIVE_FALSE'|translate}}</span>
        </ng-template>
      </armon-icon-label>
      <armon-icon-label [colorCode]="1" *ngIf="ruleset.region">
        <ng-template icon-label-icon>
          <cds-icon shape="region"></cds-icon>
        </ng-template>
        <ng-template icon-label-content>
          <span>{{ruleset.region.name}}</span>
        </ng-template>
      </armon-icon-label>
    </div>
  </div>
  <div class="card-body">
    <div class="d-flex flex-column p-3 my-2 shadow-box-1 rnd-1">
      <span *ngIf="inEditGroups" class="text-sm">
        <cds-icon shape="users" solid class="cds-icon-18 me-2"></cds-icon>
        {{'PAGES.MANAGE_USERGROUPS'|translate:languageService.userTranslate}}
      </span>
      <div *ngIf="!inEditGroups">
        <span class="text-sm color-error" *ngIf="ruleset.userGroupCount==0">
          <cds-icon shape="users" solid class="cds-icon-18 me-2"></cds-icon>
          {{'ACCESS_RULES.INFO_USERGROUP_EMPTY'|translate}}
        </span>
        <span class="text-sm" *ngIf="ruleset.userGroupCount>0">
          <cds-icon shape="users" solid class="cds-icon-18 me-2"></cds-icon>
          {{'ACCESS_RULES.INFO_USERGROUP_ASSIGNED'|translate:ruleset}}
        </span>
        <div>
          <button class="btn btn-outline-primary btn-sm mt-3" (click)="inEditGroups=true;inEditRules=false;">
            {{'ACCESS_RULES.SET_BUTTON_GROUP'|translate}}
          </button>
        </div>
      </div>
      <div *ngIf="inEditGroups">
        <div class="row my-3">
          <div class="col-lg-4 col-md-6 col-sm-12">
            <armon-select-search query="group" [allowMulti]="true" [(ngModel)]="tempUserGroupIds">
            </armon-select-search>
          </div>
        </div>
        <div class="row my-3">
          <div class="col-12">
            <button class="btn btn-outline-primary btn-sm me-2" (click)="inEditGroups=false">
              {{'BUTTON.CANCEL'|translate}}
            </button>
            <button class="btn btn-primary btn-sm" (click)="onEditGroupsClicked($event)">
              {{'BUTTON.SAVE'|translate}}
            </button>
          </div>
        </div>
      </div>
    </div>
    <div class="d-flex flex-column p-3 mt-3 shadow-box-1 rnd-1">
      <span *ngIf="inEditRules" class="text-sm mb-3">
        <cds-icon shape="scroll" solid class="cds-icon-18 me-2"></cds-icon>{{'ACCESS_RULES.SET_RULES'|translate}}
      </span>
      <div *ngIf="!inEditRules">
        <span class="text-sm color-error" *ngIf="ruleset.ruleCount==0">
          <cds-icon shape="scroll" solid class="cds-icon-18 me-2"></cds-icon>
          {{'ACCESS_RULES.INFO_RULES_EMPTY'|translate}}
        </span>
        <span class="text-sm" *ngIf="ruleset.ruleCount>0">
          <cds-icon shape="scroll" solid class="cds-icon-18 me-2"></cds-icon>
          {{'ACCESS_RULES.INFO_RULES_ADDED'|translate:ruleset}}
        </span>
        <div>
          <button class="btn btn-outline-primary btn-sm mt-3" (click)="onEditRulesClicked($event)">
            {{'ACCESS_RULES.SET_BUTTON_RULES'|translate}}
          </button>
        </div>
      </div>
      <div *ngIf="inEditRules">
        <div class="my-2">
          <button nz-dropdown [nzDropdownMenu]="menuAdd" class="btn btn-primary btn-sm">
            {{'ACCESS_RULES.RULE_BUTTON_ADD'|translate}}
            <cds-icon shape="angle" direction="down"></cds-icon>
          </button>
          <nz-dropdown-menu #menuAdd="nzDropdownMenu" nzTrigger="click">
            <ul nz-menu>
              <li nz-menu-item *ngFor="let accessRulesType of accessRulesTypeList"
                [nzDisabled]="accessRulesType.type ==3 && hasCapacityRule" (click)="onAddRuleClicked(accessRulesType)">
                {{accessRulesType.description|translate}}</li>
            </ul>
          </nz-dropdown-menu>
        </div>
        <div class="row mt-3 report-data-table-container" id="report-data-table-container">
          <div class="col-12">
            <p-table [value]="rules" dataKey="id" [responsive]="true" rowExpandMode="single">
              <ng-template pTemplate="header">
                <tr>
                  <th>{{'ACCESS_RULES.RULE_TYPE' | translate}}</th>
                  <th>{{'ACCESS_RULES.RULE_DIRECTION' | translate}}</th>
                  <th>{{'ACCESS_RULES.RULE_STATUS' | translate}}</th>
                  <th>{{'ACCESS_RULES.RULE_PARAMETERS' | translate}}</th>
                  <th></th>
                </tr>
              </ng-template>
              <ng-template pTemplate="body" let-rule>
                <tr class="data-row">
                  <td>
                    <span>{{rule.typeText | translate}}</span>
                  </td>
                  <td>
                    <span>{{rule.directionText | translate}}</span>
                  </td>
                  <td>
                    <span>{{rule.acceptStatusText | translate}}</span>
                  </td>
                  <td>
                    <div class="report-multi-data-cell" *ngIf="rule.type==1">
                      <span class="main-text">{{rule.parametersMainText}}</span>
                      <div class="sub-text">
                        <ng-container *ngFor="let dayText of rule.daysText">{{dayText|translate}} </ng-container>
                      </div>
                    </div>
                    <div class="report-multi-data-cell" *ngIf="rule.type==2">
                      <span class="main-text">{{rule.parameters.maximumAccessCount}}</span>
                      <span class="sub-text">{{'ACCESS_RULES.RULE_MAX_COUNT' | translate}}</span>
                    </div>
                    <div class="report-multi-data-cell" *ngIf="rule.type==3">
                      <span
                        class="main-text">{{rule.parametersMainText}}&nbsp;/&nbsp;{{ruleset.region.capacity?ruleset.region.capacity:"---"}}</span>
                      <span class="sub-text">{{'ACCESS_RULES.CAPACITY_GROUPS_TOTAL' | translate}}</span>
                    </div>
                    <div class="report-multi-data-cell" *ngIf="rule.type==4">
                      <span class="main-text">{{rule.parametersMainText}}</span>
                      <div class="sub-text">
                        <ng-container *ngFor="let dayText of rule.daysText">{{dayText|translate}} </ng-container>
                      </div>
                      <span class="sub-text">{{'ACCESS_RULES.RULE_MAX_COUNT' | translate}}:
                        {{rule.parameters.maximumAccessCount}}</span>
                    </div>
                  </td>
                  <td class="text-align-right color-primary">
                    <span>
                      <cds-icon shape="cog" class="cds-icon-18 me-2 cursor-pointer" solid
                        (click)="onEditRuleClicked(rule)" nz-tooltip nzTooltipTitle="{{'BUTTON.EDIT'|translate}}">
                      </cds-icon>
                      <cds-icon shape="trash" class="cds-icon-18  cursor-pointer" solid
                        (click)="onDeleteRuleClicked(rule)" nz-tooltip nzTooltipTitle="{{'BUTTON.DELETE'|translate}}">
                      </cds-icon>
                    </span>
                  </td>
                </tr>
              </ng-template>
            </p-table>
          </div>
          <div class="col-12 mb-3 mt-3">
            <armon-pagination [paginationResponse]="paginationResponse" (pageChanged)="pageChanged($event)">
            </armon-pagination>
          </div>
        </div>
        <div>
          <button class="btn btn-outline-primary btn-sm" (click)="inEditRules=false">
            {{'BUTTON.CLOSE'|translate}}
          </button>
        </div>
      </div>
    </div>
  </div>
  <div class="card-footer">
    <button class="btn btn-link btn-sm" (click)="onEditClicked($event)">
      {{'BUTTON.EDIT'|translate}}
    </button>
    <button class="btn btn-link btn-sm" (click)="onDeleteClicked($event)">
      {{'BUTTON.DELETE'|translate}}
    </button>
  </div>
</div>`;var Oe=`.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 we=`<ng-container *ngIf="visibleComponent">
  <div class="modal-header d-flex align-items-center">
    <div class="d-flex flex-column flex-grow-1">
      <span class="text-lg">{{(editMode ? 'ACCESS_RULES.RULE_BUTTON_EDIT' : 'ACCESS_RULES.RULE_BUTTON_ADD' ) |
        translate}}</span>
      <span class="text-sm fw-medium">{{ruleTypeDefinition.description|translate}}</span>
    </div>
    <!-- ONLY CAPACITY -->
    <div *ngIf="rule.type==3 && ruleSet.region.capacity"
      class="d-flex flex-column align-items-end justify-content-center">
      <span class="text-xxl line-height-xxl" [ngClass]="{'color-error': usedCapacity>ruleSet.region.capacity}">
        <cds-icon shape="warning-standard" class="me-2" size="md" *ngIf="usedCapacity>ruleSet.region.capacity">
        </cds-icon>
        <span>{{usedCapacity}}</span>
      </span>
      <span class="text-sm">{{'REGION.CAPACITY_LABEL'|translate}}: {{ruleSet.region.capacity}}</span>
    </div>
  </div>
  <div class="modal-body">
    <div class="row">
      <!-- ONLY TIME && COUNT -->
      <div class="col-12 col-md-6" *ngIf="rule.type!=3">
        <div class="form-group">
          <label for="directionInput" class="required">{{'ACCESS_RULES.RULE_DIRECTION' | translate}}</label>
          <select [(ngModel)]="rule.direction" id="directionInput" (ngModelChange)="onModelChanged($event)"
            class="form-select form-select-sm">
            <option *ngFor="let directionType of directionTypes" [ngValue]="directionType.type">
              {{directionType.description
              | translate}}</option>
          </select>
        </div>
      </div>
      <!-- ONLY TIME && COUNT -->
      <div class="col-12 col-md-6" *ngIf="rule.type!=3">
        <div class="form-group">
          <label for="statusInput" class="required">{{'ACCESS_RULES.RULE_STATUS' | translate}}</label>
          <select [(ngModel)]="rule.acceptStatus" id="statusInput" (ngModelChange)="onModelChanged($event)"
            class="form-select form-select-sm">
            <option *ngFor="let accessRulesStatus of accessRulesStatusList" [ngValue]="accessRulesStatus.type">
              {{accessRulesStatus.description
              | translate}}</option>
          </select>
        </div>
      </div>
      <!-- ONLY TIME -->
      <div class="col-12 col-md-6" *ngIf="rule.type==1 || rule.type==4">
        <div class="form-group">
          <label class="required">{{'ACCESS_RULES.RULE_START_TIME' | translate}}</label>
          <input [(ngModel)]="rule.parameters.startTime" type="text" class="custom-item" readonly owlinput
            class="form-control form-control-sm bg-white" (ngModelChange)="onModelChanged($event)" [owlDateTime]="dt1"
            [owlDateTimeTrigger]="dt1">
          <owl-date-time [firstDayOfWeek]="1" #dt1 [pickerType]="'timer'"></owl-date-time>
        </div>
      </div>
      <!-- ONLY TIME -->
      <div class="col-12 col-md-6" *ngIf="rule.type==1 || rule.type==4">
        <div class="form-group">
          <label class="required">{{'ACCESS_RULES.RULE_END_TIME' | translate}}</label>
          <input [(ngModel)]="rule.parameters.endTime" type="text" class="custom-item" readonly owlinput
            class="form-control form-control-sm bg-white" (ngModelChange)="onModelChanged($event)" [owlDateTime]="dt2"
            [owlDateTimeTrigger]="dt2">
          <owl-date-time [firstDayOfWeek]="1" #dt2 [pickerType]="'timer'"></owl-date-time>
        </div>
      </div>
      <!-- ONLY COUNT -->
      <div class="col-12 col-md-6" *ngIf="rule.type==2 || rule.type==4">
        <div class="form-group">
          <label for="maximumAccessCountInput" class="required">{{'ACCESS_RULES.RULE_MAX_COUNT' | translate}}</label>
          <input type="text" id="maximumAccessCountInput" [(ngModel)]="rule.parameters.maximumAccessCount" maxlength="6"
            class="form-control form-control-sm" onlyNumber="true" (ngModelChange)="onModelChanged($event)">
        </div>
      </div>
      <!-- ONLY TIME -->
      <div class="col-12" *ngIf="rule.type==1 || rule.type==4">
        <div class="form-group">
          <label for="isActive" class="required">{{'ACCESS_RULES.RULE_DAYS' | translate}}</label>
          <ng-container *ngFor="let day of days">
            <div class="form-check">
              <input class="form-check-input" type="checkbox" [(ngModel)]="day.value"
                (ngModelChange)="onDaysChanged($event)" [id]="'day'+day.type.type">
              <label class="form-check-label" [for]="'day'+day.type.type">
                {{day.type.description | translate}}
              </label>
            </div>
          </ng-container>
        </div>
      </div>

      <!-- ONLY CAPACITY -->
      <div class="col-12" *ngIf="rule.type == 3 ">
        <form [formGroup]="capacityForm">
          <div class="row mhs-20 align-content-start">
            <div class="col-12 d-flex align-items-center mb-3 pb-2 b-b-1">
              <span class="text-md">{{'ACCESS_RULES.CAPACITY_GROUPS'|translate}}</span>
              <button class="btn btn-sm btn-primary ms-auto" (click)="onAddCapacityItemClicked($event)">
                <cds-icon shape="plus-circle" solid class="cds-icon-18 me-1"></cds-icon>{{'BUTTON.ADD'|translate}}
              </button>
            </div>
            <div class="col-12" *ngIf="formCapacityItems.controls.length==0">
              <nz-empty [nzNotFoundContent]="contentTpl" [nzNotFoundImage]="'./assets/images/empty/empty_list.png'">
                <ng-template #contentTpl>
                  <span>{{'ACCESS_RULES.NO_CAPACITY_GROUP'|translate}}</span>
                </ng-template>
              </nz-empty>
            </div>
            <div class="col-12 mb-3">
              <div formArray="formServers" [hidden]="formCapacityItems.controls.length==0">
                <ng-container
                  *ngFor="let formCapacityItemControl of formCapacityItems.controls; let index = index; let last = last;">
                  <div class="row mb-2" [formGroup]="formCapacityItemControl">
                    <div class="col-12 col-md-8">
                      <label
                        class="report-form-label">{{'IDENTITY.FILTER_TITLE_USER_GROUPS'|translate:languageService.userTranslate}}</label>
                      <nz-select nzShowSearch nzPlaceHolder="{{'COMMON.SELECT_ONE'|translate}}" nzAllowClear="true"
                        [formControl]="formCapacityItemControl.get('groupId')" nzSize="small" class="w-100"
                        [ngClass]="{'nz-invalid': formCapacityItemControl.get('groupId').invalid}">
                        <ng-container *ngFor="let userGroup of ruleSet.userGroups">
                          <nz-option [nzLabel]="userGroup.name" [nzValue]="userGroup.id"
                            [nzHide]="isSelectedGroup(userGroup.id)"></nz-option>
                        </ng-container>
                      </nz-select>
                      <ng-template
                        *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: formCapacityItemControl, control:formCapacityItemControl.get('groupId'), isArray:false}">
                      </ng-template>
                    </div>
                    <div class="col-12 col-md-4">
                      <label class="report-form-label">{{'ACCESS_RULES.GROUP_CAPACITY'|translate}}</label>
                      <div class="input-group input-group-sm">
                        <input [formControl]="formCapacityItemControl.get('capacity')" type="number"
                          [ngClass]="{'is-invalid': formCapacityItemControl.get('capacity').invalid}"
                          class="form-control form-control-sm">
                          <button class="btn btn-sm btn-danger" (click)="onRemoveCapacityItemClicked($event, index)">
                            <cds-icon shape="times-circle" class="me-1 cds-icon-18" solid></cds-icon>
                            {{'BUTTON.DELETE'|translate}}
                          </button>
                      </div>
                      <ng-template
                        *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: formCapacityItemControl, control:formCapacityItemControl.get('capacity'), isArray:false}">
                      </ng-template>
                    </div>
                  </div>
                </ng-container>
              </div>
            </div>
          </div>
        </form>
      </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)="onAddClicked($event)" [disabled]="disableSaveButton">
      {{(editMode ? 'BUTTON.EDIT' : 'BUTTON.ADD' ) | translate}}
    </button>
  </div>
</ng-container>

<!-- FORM FIELD VALIDATION -->
<ng-template #controlValidationTemplate let-form let-control="control" let-isArray="isArray">
  <ng-container *ngIf="control.errors">
    <div class="invalid-feedback" style="display: initial;">
      <span
        *ngIf="control.errors.required">{{(isArray?'VALIDATION.MIN_ONE_SELECTED':'VALIDATION.REQUIRED')|translate}}</span>
      <span *ngIf="control.errors.numeric">{{'VALIDATION.POSITIVE_NUMBER'|translate}}</span>
      <span *ngIf="control.errors.unique">{{'ACCESS_RULES.HAS_CAPACITY_GROUP'|translate}}</span>
    </div>
  </ng-container>
</ng-template>`;var De="";var Ye=function(a,e,t,s){var r=arguments.length,i=r<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(a,e,t,s);else for(var l=a.length-1;l>=0;l--)(n=a[l])&&(i=(r<3?n(i):r>3?n(e,t,i):n(e,t))||i);return r>3&&i&&Object.defineProperty(e,t,i),i},y=class extends _{sessionService;accessRulesService;interactionService;languageService;formBuilder;rule;ruleSet;editMode;disableSaveButton=!0;visibleComponent=!1;ruleTypeDefinition;days=[];accessRulesStatusList=w;directionTypes=ie;capacityForm;usedCapacity;constructor(e,t,s,r,i){super(),this.sessionService=e,this.accessRulesService=t,this.interactionService=s,this.languageService=r,this.formBuilder=i}onModalInitialized(){super.onModalInitialized(),this.rule!==void 0&&this.rule!==null&&(this.rule=b(this.rule),this.ruleSet=this.ruleSet,this.rule.id&&this.rule.id!=""?this.editMode=!0:this.editMode=!1,this.validateSaveForm()),this.ruleTypeDefinition=D.find(e=>e.type==this.rule.type),(this.rule.type==o.TimeBased||this.rule.type==o.TimeCountBased)&&de.forEach(e=>{this.days.push({value:this.rule.parameters.days.findIndex(t=>t==e.type)>-1,type:e})}),this.rule.type==o.Capacity&&this.createCapacityForm(),this.visibleComponent=!0}set modalData(e){}upsertRule(){let e=N.getRequestModel(this.rule);switch(this.rule.type){case o.Capacity:Object.assign(e.parameters,this.capacityForm.value);break}this.accessRulesService.upsertRule(this.rule.accessRuleSetId,e).subscribe(t=>{this.interactionService.showMessage("ACCESS_RULES.COMPLETED_RULE_UPSERT",null,T.Success),this.closeModal(this.rule)},t=>{this.interactionService.showDialog(this.editMode?"ACCESS_RULES.RULE_BUTTON_EDIT":"ACCESS_RULES.RULE_BUTTON_ADD",t.error.message,null,null,!1,"BUTTON.OK","",!1,()=>{})})}validateSaveForm(){let e=!1;switch(this.rule.type){case o.TimeBased:(this.rule.parameters.days==null||this.rule.parameters.days==null||this.rule.parameters.days.length==0)&&(e=!0),(this.rule.parameters.startTime==null||this.rule.parameters.startTime==null)&&(e=!0),(this.rule.parameters.endTime==null||this.rule.parameters.endTime==null)&&(e=!0);break;case o.CountBased:(this.rule.parameters.maximumAccessCount==null||this.rule.parameters.maximumAccessCount==null||+this.rule.parameters.maximumAccessCount==0)&&(e=!0);break;case o.Capacity:e=(this.capacityForm?this.capacityForm.invalid:!0)||(this.ruleSet.region.capacity?this.usedCapacity>this.ruleSet.region.capacity:!1);break;case o.TimeCountBased:(this.rule.parameters.days==null||this.rule.parameters.days==null||this.rule.parameters.days.length==0)&&(e=!0),(this.rule.parameters.startTime==null||this.rule.parameters.startTime==null)&&(e=!0),(this.rule.parameters.endTime==null||this.rule.parameters.endTime==null)&&(e=!0),(this.rule.parameters.maximumAccessCount==null||this.rule.parameters.maximumAccessCount==null||+this.rule.parameters.maximumAccessCount==0)&&(e=!0);break}this.disableSaveButton=e}onModelChanged(e){this.validateSaveForm()}onDaysChanged(e){let t=[];this.days.forEach(s=>{s.value==!0&&t.push(s.type.type)}),this.rule.parameters.days=t,this.validateSaveForm()}onAddClicked(e){this.disableSaveButton||this.upsertRule()}createCapacityForm(){if(this.capacityForm=this.formBuilder.group({capacityItems:this.formBuilder.array([])}),this.rule.parameters&&this.rule.parameters.capacityItems&&this.rule.parameters.capacityItems.length>0){let e=this.capacityForm.get("capacityItems");this.rule.parameters.capacityItems.map(t=>{e.push(this.createCapacityItemForm(t))})}this.capacityForm.valueChanges.subscribe(e=>{this.calculateUsedCapacity(),this.validateSaveForm()}),this.calculateUsedCapacity(),this.validateSaveForm()}calculateUsedCapacity(){this.usedCapacity=this.formCapacityItems.value.reduce((e,t)=>e+(t.capacity||0),0)}get formCapacityItems(){return this.capacityForm.get("capacityItems")}isSelectedGroup(e){return this.formCapacityItems.value.findIndex(t=>t.groupId==e)>-1}createCapacityItemForm(e=null){return e||(e={}),this.formBuilder.group({groupId:[e.groupId?e.groupId:null,[$.required,q.unique()]],capacity:[e.capacity?e.capacity:0,[$.required,q.numeric({acceptValue:Z.PositiveNumber,allowDecimal:!1})]]})}onAddCapacityItemClicked(e){this.formCapacityItems.push(this.createCapacityItemForm()),this.capacityForm.updateValueAndValidity()}onRemoveCapacityItemClicked(e,t){this.formCapacityItems.removeAt(t),this.capacityForm.updateValueAndValidity()}static ctorParameters=()=>[{type:C},{type:c},{type:g},{type:x},{type:Q}];static propDecorators={rule:[{type:S}],ruleSet:[{type:S}]}};y=Ye([m({selector:"armon-manage-access-rule-upsert",template:we,standalone:!0,providers:[{provide:I,useClass:L}],imports:[v,V,R,h,U,ge,J,ne,le,Y,f],styles:[De]})],y);var He=function(a,e,t,s){var r=arguments.length,i=r<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(a,e,t,s);else for(var l=a.length-1;l>=0;l--)(n=a[l])&&(i=(r<3?n(i):r>3?n(e,t,i):n(e,t))||i);return r>3&&i&&Object.defineProperty(e,t,i),i},P=class extends _e{interactionService;accessRulesService;languageService;modalService;authService;ruleset;inEditGroups=!1;inEditRules=!1;ruleRequest;rules=[];hasCapacityRule=!1;tempUserGroupIds;itemUpdated=new B;itemDeleted=new B;paginationResponse=new O;paginationRequest=new M;accessRulesTypeList=D;constructor(e,t,s,r,i){super(i),this.interactionService=e,this.accessRulesService=t,this.languageService=s,this.modalService=r,this.authService=i}ngOnInit(){this.ruleRequest=pe.getEmptyModel(),this.tempUserGroupIds=this.ruleset.userGroupIds}refreshList(e=!0){e&&(this.ruleRequest.skip=0),this.getRules()}pageChanged(e){this.ruleRequest.skip=e.skip,this.ruleRequest.take=e.take,this.refreshList(!1)}onEditClicked(e){this.modalService.open(E,{settings:{size:"lg"},props:{ruleSet:this.ruleset}}).result.then(t=>{this.itemUpdated.emit(this.ruleset)}).catch(t=>{})}assignRuleset(){let e=ue.getEmptyModel();e.userGroupIds=this.tempUserGroupIds?this.tempUserGroupIds:[],this.accessRulesService.assignRuleset(this.ruleset.id,e).subscribe(t=>{this.inEditGroups=!1,this.detailRuleset()})}detailRuleset(){this.accessRulesService.detailRuleset(this.ruleset.id).subscribe(e=>{this.ruleset=e})}onCancelEditGroupsClicked(e){this.inEditGroups=!1,this.tempUserGroupIds=this.ruleset.userGroupIds}onEditGroupsClicked(e){this.assignRuleset()}onDeleteClicked(e){this.interactionService.showDialog(this.ruleset.name,"ACCESS_RULES.SET_APPROVE_FOR_DELETE",null,null,!0,"BUTTON.DELETE","",!0,()=>{this.accessRulesService.deleteRuleset(this.ruleset.id).subscribe(t=>{this.itemDeleted.emit(this.ruleset)})})}getRules(){this.accessRulesService.listRule(this.ruleset.id,this.ruleRequest).subscribe(e=>{this.rules=e.items,this.hasCapacityRule=this.rules.findIndex(t=>t.type==o.Capacity)>-1,this.paginationResponse=e.pagination,this.ruleset.ruleCount=this.rules.length})}onEditRulesClicked(e){this.inEditRules=!0,this.inEditGroups=!1,this.refreshList()}onAddRuleClicked(e){if(e.type==o.Capacity&&this.hasCapacityRule)return;let t=N.getEmptyModel();t.accessRuleSetId=this.ruleset.id,t.type=e.type,this.modalService.open(y,{settings:{size:"lg",scrollable:!0},props:{rule:t,ruleSet:this.ruleset}}).result.then(s=>{this.refreshList()}).catch(s=>{})}onEditRuleClicked(e){switch(e.type){case o.TimeCountBased:this.interactionService.showDialog(e.typeText,"ACCESS_RULES.RULE_APPROVE_FOR_EDIT_COUNT",null,null,!0,"BUTTON.EDIT","",!1,()=>{this.showEditRuleModal(e)});break;default:this.showEditRuleModal(e);break}}showEditRuleModal(e){this.modalService.open(y,{settings:{size:"lg",scrollable:!0},props:{rule:e,ruleSet:this.ruleset}}).result.then(t=>{this.refreshList()}).catch(t=>{})}onDeleteRuleClicked(e){this.interactionService.showDialog("ACCESS_RULES.RULE_TTILE_FOR_DELETE","ACCESS_RULES.RULE_APPROVE_FOR_DELETE",null,null,!0,"BUTTON.DELETE","",!0,()=>{this.accessRulesService.deleteRule(this.ruleset.id,e.id).subscribe(t=>{this.refreshList()})})}static ctorParameters=()=>[{type:g},{type:c},{type:x},{type:A},{type:he}];static propDecorators={ruleset:[{type:S}],itemUpdated:[{type:G}],itemDeleted:[{type:G}]}};P=He([m({selector:"armon-manage-access-ruleset-card",template:Me,standalone:!0,imports:[v,Re,ve,Ce,k,R,se,te,h,ee,Ae,Te,ae,z,f],styles:[Oe]})],P);var We=function(a,e,t,s){var r=arguments.length,i=r<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(a,e,t,s);else for(var l=a.length-1;l>=0;l--)(n=a[l])&&(i=(r<3?n(i):r>3?n(e,t,i):n(e,t))||i);return r>3&&i&&Object.defineProperty(e,t,i),i},Ne=class{accessRulesService;modalService;request;rulesets=[];paginationResponse=new O;paginationRequest=new M;constructor(e,t){this.accessRulesService=e,this.modalService=t}ngOnInit(){this.checkPermissions(),this.request=ce.getEmptyModel(),this.getList()}getList(){this.accessRulesService.listRuleset(this.request).subscribe(e=>{this.rulesets=e.items,this.paginationResponse=e.pagination})}onFilterChanged(e){this.request.filter=e,this.refreshList()}refreshList(e=!0){e&&(this.request.skip=0),this.getList()}pageChanged(e){this.request.skip=e.skip,this.request.take=e.take,this.refreshList(!1)}onAddRuleSetButtonClicked(){this.modalService.open(E,{settings:{size:"lg"},props:{ruleSet:oe.getEmptyModel()}}).result.then(e=>{this.refreshList()}).catch(e=>{})}onRegionDeleted(e){}onItemUpdated(e){this.refreshList(!1)}onItemDeleted(e){this.refreshList()}checkPermissions(){}static ctorParameters=()=>[{type:c},{type:A}]};Ne=We([m({selector:"armon-manage-access-rules",template:Ie,animations:fe,standalone:!0,imports:[be,Ee,Se,ye,h,P,z,f],styles:[Ue]})],Ne);export{Ne as ManageAccessRulesComponent};
