import{a as et,b as it,c as ae}from"./chunk-ZDEKLPKE.js";import{b as Xe,c as tt}from"./chunk-VQU52MNH.js";import{a as Ze,b as Ke}from"./chunk-MXSLISEG.js";import{b as Je}from"./chunk-FSCI3FDB.js";import{a as We,b as Ge,c as qe}from"./chunk-UZB7YFT6.js";import{b as Qe}from"./chunk-I6FSQTEP.js";import{Ob as $e,j as Ve,k as Le}from"./chunk-YSQLW2JA.js";import{Hb as He,Ib as J,Lb as Be,Pb as Ye,Qb as je}from"./chunk-NVJ2ZZFT.js";import{$ as R,Aa as l,B as de,Ba as De,C as pe,Dc as r,De as Pe,Ea as ye,Fc as B,Hf as Me,If as ne,Ka as N,Mc as xe,Mg as Ue,Na as U,Nc as Ee,O as me,Oa as te,Of as h,Pa as F,Q as O,Qf as $,Ra as Te,S as ue,Sa as ve,Sd as j,Te as ze,Va as m,Ve as Ce,W as he,Wb as z,Ye as _e,Yg as Fe,_ as E,_a as w,ab as D,bb as g,be as ie,bf as Oe,ca as L,cb as Ie,cd as Re,db as be,dd as y,gb as M,ha as ge,hd as Y,i as oe,jb as H,jf as Ae,kf as se,l as le,ma as fe,mg as ke,na as ee,qa as A,r as re,rf as Ne,ta as Se,uf as we,wa as P,x as Q,y as ce,ya as d}from"./chunk-SKPDQO4E.js";var st=`<ng-container *ngIf="visible && duration">
    <ng-container *ngIf="isDailyScheduled">
        <span>
            <ng-container *ngIf="duration == 0.5">{{'REPORT.PACS_UNIT_DAY_JUST_HALF'|translate}}</ng-container>
            <ng-container *ngIf="duration != 0.5">{{duration}}
                {{(durationDailyHalf ? 'REPORT.PACS_UNIT_DAY_HALF' : 'REPORT.PACS_UNIT_DAY' ) |
                translate}}</ng-container>
        </span>
    </ng-container>
    <ng-container *ngIf="!isDailyScheduled">
        <span>{{duration | minuteFormatter}}</span>
    </ng-container>
</ng-container>`;var ht=function(a,e,t,s){var n=arguments.length,i=n<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(a,e,t,s);else for(var c=a.length-1;c>=0;c--)(o=a[c])&&(i=(n<3?o(i):n>3?o(e,t,i):o(e,t))||i);return n>3&&i&&Object.defineProperty(e,t,i),i},W=class{duration;isDailyScheduled=!1;visible=!1;durationDailyHalf=!1;constructor(){}ngOnChanges(e){e.duration&&!e.duration.isFirstChange()&&this.setDuration()}setDuration(){this.isDailyScheduled&&this.duration&&(this.duration<1?(this.durationDailyHalf=!0,this.duration=.5):(this.durationDailyHalf=!Number.isInteger(this.duration),this.duration=Math.floor(this.duration)))}ngOnInit(){this.setDuration(),this.visible=!0}ngOnDestroy(){}static ctorParameters=()=>[];static propDecorators={duration:[{type:l}],isDailyScheduled:[{type:l}]}};W=ht([d({selector:"armon-pacs-ppermission-duration",template:st,standalone:!0,imports:[g,Oe,y]})],W);var nt=`<div class="modal-header">
  <span class="text-lg">{{(editMode ? 'PACS.EDIT_USER_PPERMISSION' : 'PACS.USER_PPERMISSION_ADD' ) | translate}}</span>
  <button type="button" class="btn btn-light" (click)="onCancelClicked($event)">
    <cds-icon shape="times" class="cds-icon-20"></cds-icon>
  </button>
</div>
<div class="modal-body mh-vh-50">
  <ng-container *ngIf="visibleComponent">
    <div class="row d-none d-md-block mb-5 mt-3">
      <div class="col-12">
        <nz-steps nzSize="small" [nzCurrent]="currentStepIndex">
          <nz-step [nzTitle]="'PACS.PPERMISSION_TYPE_LABEL'|translate"></nz-step>
          <ng-container *ngIf="modeDaily">
            <nz-step [nzTitle]="'PACS.DIRECTION_ADD_PPERMISSION_START_DAY_LABEL'|translate"></nz-step>
            <nz-step [nzTitle]="'PACS.DIRECTION_ADD_PPERMISSION_END_DAY_LABEL'|translate"></nz-step>
          </ng-container>
          <ng-container *ngIf="!modeDaily">
            <nz-step [nzTitle]="'USER_PERMISSION_UNIT_TYPE_DAY'|translate"></nz-step>
            <nz-step [nzTitle]="'ACCESS_RULES.RULE_START_TIME'|translate"></nz-step>
            <nz-step [nzTitle]="'ACCESS_RULES.RULE_END_TIME'|translate"></nz-step>
          </ng-container>
          <nz-step [nzTitle]="'COMMON.SETTINGS'|translate"></nz-step>
          <nz-step [nzTitle]="'COMMON.SUMMARY'|translate"></nz-step>
        </nz-steps>
      </div>
    </div>
    <ng-container [ngSwitch]="viewState">

      <!-- TYPE SELECTION -->
      <ng-container *ngSwitchCase="'typeSelection'">
        <div class="row0" *ngIf="editModeOnlyDateSelection">
          <div class="col-12">
            <div class="alert alert-warning" role="alert">
              {{'PACS.DIRECTION_ADD_PPERMISSION_EDIT_NO_TYPE'|translate}}
            </div>
          </div>
        </div>
        <div class="row align-content-start mh-vh-40 mxh-vh-40 overflow-y-auto">
          <div class="col-12 mb-2" *ngIf="!editModeOnlyDateSelection"><span
              class="text-md text-bold">{{'PACS.DIRECTION_ADD_PPERMISSION_TYPE'|translate}}</span>
          </div>
          <div class="col-12 col-xl-6" *ngFor="let ppermissionType of ppermissionTypes">
            <ng-template
              *ngTemplateOutlet="ppermissionTemplate; context: {$implicit: ppermissionType, selectable:!editModeOnlyDateSelection, showselected:true}">
            </ng-template>
          </div>
        </div>
        <!-- <ng-template *ngTemplateOutlet="navigationTemplate"></ng-template> -->
      </ng-container>
      <!-- TYPE SELECTION -->

      <!-- DAILY START SELECTION -->
      <ng-container *ngSwitchCase="'dailyStartSelection'">
        <div class="row">
          <div class="col-xl-6 col-lg-6 col-md-6">
            <div class="row">
              <div class="col-12">
                <span class="text-md text-bold">{{'PACS.DIRECTION_ADD_PPERMISSION_START_DAY'|translate}}</span>
              </div>
              <div class="col-12 d-flex justify-content-center my-3">
                <owl-date-time-inline [pickerType]="'calendar'" [(ngModel)]="ppermission.dateRange.startDateTime"
                  (ngModelChange)="onDailyStartDateChanged($event)"></owl-date-time-inline>
              </div>
            </div>
            <!-- <ng-template *ngTemplateOutlet="navigationTemplate"></ng-template> -->
          </div>
          <div class="col-xl-6 col-lg-6 col-md-6 right-container">
            <ng-template
              *ngTemplateOutlet="ppermissionTemplate; context: {$implicit: selectedType, selectable:false, showselected:false}">
            </ng-template>
            <ng-template
              *ngTemplateOutlet="rangeTemplate; context: {$implicit: ppermission.dateRange, dailyRange:true, editable:true, customEdit:false}">
            </ng-template>
            <ng-template *ngTemplateOutlet="additionalDataTemplate"></ng-template>
          </div>
        </div>
      </ng-container>
      <!-- DAILY START SELECTION -->

      <!-- DAILY END SELECTION -->
      <ng-container *ngSwitchCase="'dailyEndSelection'">
        <ng-template *ngTemplateOutlet="validationTemplate"></ng-template>
        <div class="row">
          <div class="col-xl-6 col-lg-6 col-md-6">
            <div class="row">
              <div class="col-12">
                <span class="text-md text-bold">{{'PACS.DIRECTION_ADD_PPERMISSION_END_DAY'|translate}}</span>
              </div>
              <div class="col-12 d-flex justify-content-center my-3">
                <owl-date-time-inline [pickerType]="'calendar'" [(ngModel)]="ppermission.dateRange.endDateTime"
                  (ngModelChange)="onDailyEndDateChanged($event)" [min]="minEndDate"
                  [startAt]="ppermission.dateRange.startDateTime"></owl-date-time-inline>
              </div>
            </div>
            <!-- <ng-template *ngTemplateOutlet="navigationTemplate"></ng-template> -->
          </div>
          <div class="col-xl-6 col-lg-6 col-md-6 right-container">
            <ng-template
              *ngTemplateOutlet="ppermissionTemplate; context: {$implicit: selectedType, selectable:false, showselected:false}">
            </ng-template>
            <ng-template
              *ngTemplateOutlet="rangeTemplate; context: {$implicit: ppermission.dateRange, dailyRange:true, editable:true, customEdit:false}">
            </ng-template>
            <ng-template *ngTemplateOutlet="additionalDataTemplate"></ng-template>
          </div>
        </div>
      </ng-container>
      <!-- DAILY END SELECTION -->

      <!-- HOURLY DAY SELECTION -->
      <ng-container *ngSwitchCase="'hourlyDaySelection'">
        <div class="row">
          <div class="col-xl-6 col-lg-6 col-md-6">
            <div class="row">
              <div class="col-12">
                <span class="text-md text-bold">{{'PACS.DIRECTION_ADD_PPERMISSION_DAY'|translate}}</span>
              </div>
              <div class="col-12 d-flex justify-content-center my-3">
                <owl-date-time-inline [pickerType]="'calendar'" [(ngModel)]="ppermission.dateRange.startDateTime"
                  (ngModelChange)="onHourlyStartDayChanged($event)"></owl-date-time-inline>
              </div>
            </div>
            <!-- <ng-template *ngTemplateOutlet="navigationTemplate"></ng-template> -->
          </div>
          <div class="col-xl-6 col-lg-6 col-md-6 right-container">
            <ng-template
              *ngTemplateOutlet="ppermissionTemplate; context: {$implicit: selectedType, selectable:false , showselected:false}">
            </ng-template>
            <ng-template
              *ngTemplateOutlet="rangeTemplate; context: {$implicit: ppermission.dateRange, dailyRange:false, editable:true, customEdit:true}">
            </ng-template>
            <ng-template *ngTemplateOutlet="additionalDataTemplate"></ng-template>
          </div>
        </div>
      </ng-container>
      <!-- HOURLY DAY SELECTION -->

      <!-- HOURLY START HOUR SELECTION -->
      <ng-container *ngSwitchCase="'hourlyStartHourSelection'">
        <div class="row">
          <div class="col-xl-6 col-lg-6 col-md-6">
            <div class="row">
              <div class="col-12">
                <span class="text-md text-bold">{{'PACS.DIRECTION_ADD_PPERMISSION_START_TIME'|translate}}</span>
              </div>
              <div class="col-12 d-flex justify-content-center my-3">
                <armon-time-select-input [(ngModel)]="ppermission.dateRange.startDateTime"
                  (ngModelChange)="onHourlyStartHourChanged($event)"></armon-time-select-input>
              </div>
            </div>
            <!-- <ng-template *ngTemplateOutlet="navigationTemplate"></ng-template> -->
          </div>
          <div class="col-xl-6 col-lg-6 col-md-6 right-container">
            <ng-template
              *ngTemplateOutlet="ppermissionTemplate; context: {$implicit: selectedType, selectable:false, showselected:false}">
            </ng-template>
            <ng-template
              *ngTemplateOutlet="rangeTemplate; context: {$implicit: ppermission.dateRange, dailyRange:false, editable:true, customEdit:true}">
            </ng-template>
            <ng-template *ngTemplateOutlet="additionalDataTemplate"></ng-template>
          </div>
        </div>
      </ng-container>
      <!-- HOURLY START HOUR SELECTION -->

      <!-- HOURLY END HOUR SELECTION -->
      <ng-container *ngSwitchCase="'hourlyEndHourSelection'">
        <ng-template *ngTemplateOutlet="validationTemplate"></ng-template>
        <div class="row">
          <div class="col-xl-6 col-lg-6 col-md-6">
            <div class="row">
              <div class="col-12">
                <span class="text-md text-bold">{{'PACS.DIRECTION_ADD_PPERMISSION_END_TIME'|translate}}</span>
              </div>
              <div class="col-12 d-flex justify-content-center my-3">
                <armon-time-select-input [(ngModel)]="ppermission.dateRange.endDateTime" [min]="minEndDate"
                  (ngModelChange)="onHourlyEndHourChanged($event)">
                </armon-time-select-input>
              </div>
              <ng-container *ngIf="!bulkUpsert">
                <div class="col-6 my-3">
                  <div class="form-group">
                    <label>{{'PACS.USER_PPERMISSION_REPEAT_DAYS' | translate}}</label>
                    <div class="form-check">
                      <input type="checkbox" class="form-check-input" id="repeatCheck" [(ngModel)]="repeatDaySelection"
                        (ngModelChange)="repeatDaySelectionChanged($event)">
                      <label class="form-check-label" for="repeatCheck">{{'PACS.USER_PPERMISSION_REPEAT_DAYS_ON' |
                        translate}}</label>
                    </div>
                  </div>
                </div>
                <div class="col-6 my-3" [hidden]="!repeatDaySelection">
                  <div class="form-group">
                    <label for="repeatCount">{{'PACS.USER_PPERMISSION_REPEAT_DAYS_LABEL' | translate}}</label>
                    <select [(ngModel)]="selectedRepeatCount" class="form-select form-select-sm">
                      <option *ngFor="let count of repeatCounts" [ngValue]="count.value">{{count.label}}</option>
                    </select>
                  </div>
                </div>
              </ng-container>
            </div>
            <!-- <ng-template *ngTemplateOutlet="navigationTemplate"></ng-template> -->
          </div>
          <div class="col-xl-6 col-lg-6 col-md-6 right-container">
            <ng-template
              *ngTemplateOutlet="ppermissionTemplate; context: {$implicit: selectedType, selectable:false, showselected:false}">
            </ng-template>
            <ng-template
              *ngTemplateOutlet="rangeTemplate; context: {$implicit: ppermission.dateRange, dailyRange:false, editable:true, customEdit:true}">
            </ng-template>
            <ng-template *ngTemplateOutlet="additionalDataTemplate"></ng-template>
          </div>
        </div>
      </ng-container>
      <!-- HOURLY END HOUR SELECTION -->

      <!-- ADDITIONAL DATA -->
      <ng-container *ngSwitchCase="'additionalData'">
        <div class="row">
          <div class="col-xl-6 col-lg-6 col-md-6">
            <div class="row" *ngIf="editModeOnlyDateSelection">
              <div class="col-12">
                <div class="alert alert-warning" role="alert">
                  {{'PACS.DIRECTION_ADD_PPERMISSION_EDIT_NO_ADDITIONAL'|translate}}
                </div>
              </div>
            </div>
            <div class="row mb-3" *ngIf="organizationSettingsForm">
              <div class="col-12">
                <span class="text-md text-bold">{{'PACS.DIRECTION_ADD_PPERMISSION_ORG_FORM'|translate}}</span>
              </div>
              <div class="col-12">
                <df-form [formData]="organizationSettingsForm" #dfForm
                  (formInitialized)="onDynamicFormInitialized($event)"></df-form>
              </div>
            </div>
            <div class="row" *ngIf="!editModeOnlyDateSelection">
              <div class="col-12">
                <span class="text-md text-bold">{{'PACS.DIRECTION_ADD_PPERMISSION_NOTE_FILE'|translate}}</span>
              </div>
              <div class="col-12 mt-3">
                <div class="form-group">
                  <label>{{'PACS.USER_PPERMISSION_NOTE' | translate}}</label>
                  <textarea name="note" [(ngModel)]='ppermission.note' (ngModelChange)="onNoteChanged($event)"
                    class="form-control form-control-sm"
                    [ngClass]="{'is-invalid': this.selectedType.noteIsMandatory && (!this.ppermission.note || this.ppermission.note == '')}"
                    placeholder="{{selectedType.notePlaceHolder | translate}}" rows="6" cols="20"
                    maxlength="512"></textarea>
                </div>
              </div>
              <div class="col-12">
                <armon-pacs-attachment-list uploadEnabled="true" [(attachmentList)]="ppermission.attachmentInfoList">
                </armon-pacs-attachment-list>
              </div>
              <div class="col-12 my-2" *ngIf="selectedType && bulkUpsert && selectedType.requireApprovement">
                <div class="form-group">
                  <div class="form-check">
                    <input type="checkbox" class="form-check-input" id="applyApproveStepsCheck"
                      [(ngModel)]="applyApproveSteps">
                    <label class="form-check-label" for="applyApproveStepsCheck">{{'PACS.PPERMISSION_APPROVE' |
                      translate}}</label>
                  </div>
                </div>
              </div>
              <div class="col-12 my-2"
                *ngIf="!editModeOnlyDateSelection && selectedType && !bulkUpsert && visibleDeputySelection">
                <div class="form-group">
                  <label class="ps-3 pt-2">{{'PACS.USER_PPERMISSION_DEPUTY' | translate}}</label>
                  <armon-identity-search id="deputy-selection" #searchIdentity [multiselect]="false">
                  </armon-identity-search>
                </div>
              </div>
            </div>
            <!-- <ng-template *ngTemplateOutlet="navigationTemplate"></ng-template> -->
          </div>
          <div class="col-xl-6 col-lg-6 col-md-6 right-container">
            <ng-template
              *ngTemplateOutlet="ppermissionTemplate; context: {$implicit: selectedType, selectable:false, showselected:false}">
            </ng-template>
            <ng-template
              *ngTemplateOutlet="rangeTemplate; context: {$implicit: ppermission.dateRange, dailyRange:selectedType.isDailyScheduled, editable:false, customEdit:false}">
            </ng-template>
            <ng-template *ngTemplateOutlet="additionalDataTemplate"></ng-template>
          </div>
        </div>
      </ng-container>
      <!-- ADDITIONAL DATA -->

      <!-- SUMMARY -->
      <ng-container *ngSwitchCase="'summary'">
        <div class="row">
          <div class="col-12">
            <ng-template
              *ngTemplateOutlet="ppermissionTemplate; context: {$implicit: selectedType, selectable:false, showselected:false}">
            </ng-template>
            <ng-template
              *ngTemplateOutlet="rangeTemplate; context: {$implicit: ppermission.dateRange, dailyRange:selectedType.isDailyScheduled, editable:false, customEdit:false}">
            </ng-template>
            <ng-template *ngTemplateOutlet="additionalDataTemplate"></ng-template>
          </div>
        </div>
        <!-- <div class="row">
          <ng-container *ngIf="bulkUpsert">
            <div class="col-12 d-flex justify-content-center">
              <button class="btn btn-success" (click)="saveClicked($event)" *ngIf="!editModeOnlyDateSelection"
                [disabled]="disableSaveButton">{{((userId || editMode) ? 'BUTTON.SAVE' :
                'PACS.USER_PPERMISSION_SAVE_SELECT_USER' ) | translate}}
              </button>
              <button class="btn btn-success" (click)="updateDatesClicked($event)"
                *ngIf="editModeOnlyDateSelection" [disabled]="disableSaveButton">
                {{'BUTTON.UPDATE'|translate}}
              </button>
            </div>
          </ng-container>
          <ng-container *ngIf="!bulkUpsert">
            <div class="col-12 d-flex justify-content-center">
              <button class="btn btn-success" (click)="saveClicked($event)" [disabled]="disableSaveButton">
                {{(selectedType.requireApprovement ? 'BUTTON.SEND_TO_APPROVAL' : 'BUTTON.SAVE' ) | translate}}
              </button>
            </div>
          </ng-container>
        </div> -->
        <!-- <ng-template *ngTemplateOutlet="navigationTemplate"></ng-template> -->
      </ng-container>
      <!-- SUMMARY -->

    </ng-container>
  </ng-container>
</div>
<div class="modal-footer">
  <ng-template *ngTemplateOutlet="navigationTemplate"></ng-template>
</div>

<ng-template #navigationTemplate>
  <div class="row">
    <div class="col-12 d-flex justify-content-center column-gap-2">
      <button class="btn btn-outline-primary" (click)="onPrevClicked($event)" [disabled]="disablePrevButton"
        *ngIf="visiblePrevButton">
        {{'BUTTON.PREV' | translate}}
      </button>
      <button class="btn btn-success" (click)="onNextClicked($event)" [disabled]="disableNextButton"
        *ngIf="visibleNextButton">
        {{'BUTTON.NEXT' | translate}}
      </button>
      <ng-container [ngSwitch]="viewState">
        <ng-container *ngSwitchCase="'summary'">
          <ng-container *ngIf="bulkUpsert">
            <button class="btn btn-success" (click)="saveClicked($event)" *ngIf="!editModeOnlyDateSelection"
              [disabled]="disableSaveButton">{{((userId || editMode) ? 'BUTTON.SAVE' :
              'PACS.USER_PPERMISSION_SAVE_SELECT_USER' ) | translate}}
            </button>
            <button class="btn btn-success" (click)="updateDatesClicked($event)" *ngIf="editModeOnlyDateSelection"
              [disabled]="disableSaveButton">
              {{'BUTTON.UPDATE'|translate}}
            </button>
          </ng-container>
          <ng-container *ngIf="!bulkUpsert">
            <button class="btn btn-success" (click)="saveClicked($event)" [disabled]="disableSaveButton">
              {{(selectedType.requireApprovement ? 'BUTTON.SEND_TO_APPROVAL' : 'BUTTON.SAVE' ) | translate}}
            </button>
          </ng-container>
        </ng-container>
      </ng-container>
    </div>
  </div>
</ng-template>


<ng-template #ppermissionTemplate let-ppermissionType let-selectable="selectable" let-showselected="showselected">
  <div class="p-3 my-2 d-flex mhs-5 type-container rounded-2 border border-1"
    [attr.selectable]="selectable && (selectedType?.id!=ppermissionType.id)"
    [attr.selected]="(selectable || showselected) && selectedType?.id==ppermissionType.id"
    (click)="onTypeSelected(ppermissionType)">
    <div class="d-flex flex-column flex-grow-1 justify-content-center">
      <span class="text-md text-bold">{{ppermissionType.name}}
      </span>
      <span class="text-xs" *ngIf="ppermissionType.description">{{ppermissionType.description}}</span>
    </div>
    <armon-icon-label [colorCode]="ppermissionType.isDailyScheduled?1:2">
      <ng-template icon-label-icon>
        <cds-icon shape="{{ppermissionType.isDailyScheduled?'calendar':'clock'}}" solid></cds-icon>
      </ng-template>
      <ng-template icon-label-content>
        <span>{{(ppermissionType.isDailyScheduled ? 'PACS.PPERMISSION_TYPE_UNIT_DAY' :
          'PACS.PPERMISSION_TYPE_UNIT_HOUR' ) | translate}}</span>
      </ng-template>
    </armon-icon-label>
  </div>
</ng-template>

<ng-template #rangeTemplate let-dateRange let-dailyRange="dailyRange" let-editable="editable"
  let-customEdit="customEdit">
  <div class="row mt-4 mb-2">
    <div class="col-4 position-relative d-flex flex-column align-items-end px-3 py-2 b-r-1">
      <input class="date-select-input" [(ngModel)]="dateRange.startDateTime"
        (dateTimeChange)="dailyRange?onDailyStartDateChanged($event):onHourlyStartDayChanged($event);"
        [owlDateTimeTrigger]="dtStart" [owlDateTime]="dtStart">
      <span class="text-sm mb-3">{{(dailyRange ? 'PACS.DIRECTION_ADD_PPERMISSION_START_DAY_LABEL' :
        'PLACEHOLDER.DATE_FROM' ) | translate}}</span>
      <span class="text-xl text-bold">{{dateRange.startDateTime | date:'d MMMM'}}</span>
      <span class="text-xl" *ngIf="!dailyRange">{{dateRange.startDateTime | date:'HH:mm'}}</span>
      <div class="d-flex cursor-pointer p-1 mt-2" [owlDateTimeTrigger]="dtStart"
        *ngIf="editable && customEdit && dateRange.startDateTime">
        <span class="text-xs text-bold text-secondary">{{'BUTTON.EDIT' | translate}}</span>
      </div>
      <owl-date-time [firstDayOfWeek]="1" #dtStart [showSecondsTimer]="true"></owl-date-time>
      <!-- HALF DAY -->
      <div class="d-flex flex-column align-items-end align-self-end mt-4"
        *ngIf="editable && selectedType.lessThanOneUnitEnabled">
        <nz-radio-group name="dailyStartMorning" [(ngModel)]="dailyStartMorning"
          (ngModelChange)="onDailyStartMorningChanged($event)">
          <label nz-radio [nzValue]="true" [nzDisabled]="disableDailyStartMorning">
            {{'PACS.DIRECTION_ADD_PPERMISSION_DAY_MORNING'|translate}}</label>
          <label nz-radio [nzValue]="false" [nzDisabled]="disableDailyStartMorning">
            {{'PACS.DIRECTION_ADD_PPERMISSION_DAY_AFTERNOON'|translate}}</label>
        </nz-radio-group>

        <span class="mt-2 text-xs text-bold text-secondary text-end">{{(dailyStartMorning ?
          'PACS.DIRECTION_ADD_PPERMISSION_DAY_START_MORNING' : 'PACS.DIRECTION_ADD_PPERMISSION_DAY_START_AFTERNOON' ) |
          translate}}</span>
      </div>
      <!-- HALF DAY -->
    </div>
    <div class="col-4 d-flex flex-column align-items-center px-3 py-2">
      <span
        class="text-sm mb-3 align-self-stretch text-center duration-title">{{'PACS.PPERMISSION_DURATION'|translate}}</span>
      <div class="text-md text-center text-bold"
        [ngClass]="{'text-success': differenceValidated, 'text-primary': !differenceValidated}">
        <armon-pacs-ppermission-duration [isDailyScheduled]="selectedType.isDailyScheduled"
          [duration]="difference"></armon-pacs-ppermission-duration>
      </div>
      <span class="text-center" *ngIf="difference">
        <cds-icon shape="help" class="cds-icon-18" solid nz-tooltip
          [ngClass]="{'text-success': differenceValidated, 'text-secondary': !differenceValidated}"
          nzTooltipTitle="{{(differenceValidated ? 'PACS.DIRECTION_ADD_PPERMISSION_DURATION_VALIDATED' : 'PACS.DIRECTION_ADD_PPERMISSION_DURATION' ) | translate}}">
        </cds-icon>
      </span>
    </div>
    <div class="col-4 d-flex flex-column align-items-start px-3 py-2 right-container">
      <input class="date-select-input" [(ngModel)]="dateRange.endDateTime" [min]="minEndDate" [max]="maxEndDate"
        (dateTimeChange)="dailyRange?onDailyEndDateChanged($event, false):onHourlyEndHourChanged($event);"
        [owlDateTimeTrigger]="dtEnd" [owlDateTime]="dtEnd">
      <span class="text-sm mb-3">{{(dailyRange ? 'PACS.DIRECTION_ADD_PPERMISSION_END_DAY_LABEL' : 'PLACEHOLDER.DATE_TO'
        ) | translate}}</span>
      <span class="text-xl text-bold">{{dateRange.endDateTime | date:'d MMMM'}}</span>
      <span class="text-xl" *ngIf="!dailyRange">{{dateRange.endDateTime | date:'HH:mm'}}</span>
      <div class="d-flex cursor-pointer p-1 mt-2" [owlDateTimeTrigger]="dtEnd"
        *ngIf="editable && customEdit && dateRange.endDateTime">
        <span class="text-xs text-bold text-secondary">{{'BUTTON.EDIT' | translate}}</span>
      </div>
      <owl-date-time [firstDayOfWeek]="1" #dtEnd [showSecondsTimer]="true"></owl-date-time>
      <!-- HALF DAY -->
      <div class="d-flex flex-column align-items-start align-self-start mt-4"
        *ngIf="editable && dateRange.endDateTime && selectedType.lessThanOneUnitEnabled">
        <nz-radio-group name="dailyEndMorning" [(ngModel)]="dailyEndMorning"
          (ngModelChange)="onDailyEndMorningChanged($event)">
          <label nz-radio [nzValue]="true" [nzDisabled]="disableDailyEndMorning">
            {{'PACS.DIRECTION_ADD_PPERMISSION_DAY_MORNING'|translate}}</label>
          <label nz-radio [nzValue]="false" [nzDisabled]="disableDailyEndMorning">
            {{'PACS.DIRECTION_ADD_PPERMISSION_DAY_AFTERNOON'|translate}}</label>
        </nz-radio-group>

        <span class="mt-2 text-xs text-bold text-secondary">{{(dailyEndMorning ?
          'PACS.DIRECTION_ADD_PPERMISSION_DAY_END_MORNING' : 'PACS.DIRECTION_ADD_PPERMISSION_DAY_END_AFTERNOON' ) |
          translate}}</span>
      </div>
      <!-- HALF DAY -->
    </div>
  </div>
  <div class="row" *ngIf="repeatDaySelection && selectedRepeatCount">
    <div class="col-12 d-flex justify-content-center">
      <span class="text-sm">
        {{'PACS.USER_PPERMISSION_REPEAT_DAYS'|translate}}, {{selectedRepeatCount}}
        {{'USER_PERMISSION_UNIT_TYPE_DAY'|translate}}
      </span>
    </div>
  </div>
  <!-- <span>DEBUG</span>
  <pre>{{dateRange.startDateTime}}</pre>
  <pre>{{dateRange.endDateTime}}</pre> -->
</ng-template>

<ng-template #additionalDataTemplate>
  <div class="py-2 my-1 d-flex flex-column">
    <span class="text-sm" *ngIf="ppermission?.note && ppermission?.note!=''">{{'PACS.USER_PPERMISSION_NOTE' |
      translate}} :
      {{ppermission.note}}</span>
    <span class="text-sm"
      *ngIf="ppermission?.attachmentInfoList && ppermission.attachmentInfoList.length>0">{{'PACS.DIRECTION_ADD_PPERMISSION_FILE_COUNT'
      | translate:{'count':ppermission.attachmentInfoList.length} }}
      (
      <ng-container *ngFor="let attachmentInfo of ppermission.attachmentInfoList">
        <span class="comma">{{attachmentInfo.name}}</span>
      </ng-container>)
    </span>
  </div>
</ng-template>

<ng-template #validationTemplate>
  <ng-container *ngIf="visibleValidationStatus">
    <div class="row">
      <div class="col-12">
        <span class="text-sm text-bold text-danger">
          <cds-icon shape="error-standard" class="cds-icon-18 me-1" solid></cds-icon>
          {{'PACS.DIRECTION_PPERMISSION_VALIDATE_ERROR'|translate}}
        </span>
      </div>
    </div>
    <div class="row mb-3 pb-2 b-b-1" *ngFor="let item of validationItems">
      <div class="col-12">
        <span class="text-sm">{{item.startDateTime | date:'mediumDate'}}</span>
        <span class="text-sm text-bold ms-2"
          *ngIf="item.dateRangeValid">{{"PACS.DIRECTION_ADD_PPERMISSION_DATES_OK"|translate}}</span>
        <span class="text-sm text-bold text-danger ms-2"
          *ngIf="!item.dateRangeValid">{{item.validationErrorText|translate}}</span>
      </div>
      <div class="col-12" *ngIf="item.dateRangeValid && item.dateRangePeriods && item.dateRangePeriods.length>0">
        <div class="text-sm">{{'PACS.USER_PPERMISSION_DATE_PERIODS' | translate}}</div>
        <div class="periods-container">
          <div *ngFor="let dateRangePeriod of item.dateRangePeriods" class="date-container">
            {{dateRangePeriod.startDateTime
            | date:'medium'}} - {{dateRangePeriod.endDateTime | date:'medium'}}
          </div>
        </div>
      </div>
      <div class="col-12">
        <armon-pacs-ppermission-deputy-info [deputyInfo]="deputyInfo"
          *ngIf="!editModeOnlyDateSelection && item.deputyInfo && visibleDeputyInfo">
        </armon-pacs-ppermission-deputy-info>
      </div>
    </div>
  </ng-container>
</ng-template>`;var at=`.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}.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}:host .type-container[selectable=true]{cursor:pointer}:host .type-container[selectable=true]:hover{background-color:#e6f0f6}:host .type-container[selectable=false]{pointer-events:none}:host .type-container[selected=true]{background-color:#eff6e9;border-left:solid 3px #62a325}:host .duration-title{border-bottom:1px dashed #DDD}:host .date-select-input{visibility:hidden;width:0;position:absolute;top:0;left:0}:host .right-container{border-left:1px solid #DDD}@media screen and (max-width: 768px){:host .right-container{border-left:none;padding-top:1.4rem}}
`;var G=class extends B{id;ppermissionTypeId;dateRange;note;attachmentList=[];userAndDeputyList=[];approve;dynamicFormId;dynamicFormData};var q=class extends B{userId;deputyUserId};var ot=`<div class="modal-header">
  <span class="text-lg">{{'PACS.ADD_USER_PPERMISSION' | translate}}</span>
</div>
<div class="modal-body">
  <div class="d-flex align-items-center">
    <cds-icon shape="warning-standard" size="lg" class="me-3 color-error"></cds-icon>
    <span>{{infoText|translate}}</span>
  </div>
  <div class="d-flex flex-column mt-4 list-container">
    <div class="d-flex flex-column mb-3" *ngFor="let conflict of conflictList">
      <span class="text-md">{{conflict.details}}</span>
      <span class="text-sm text-italic line-height-sm color-gray-dark">{{conflict.message}}</span>
    </div>
  </div>
</div>
<div class="modal-footer">
  <button class="btn btn-primary" (click)="closeClicked($event)">
    {{'BUTTON.OK' | translate}}
  </button>
</div>`;var lt=`.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}.list-container{max-height:50vh!important;overflow-y:auto}
`;var yt=function(a,e,t,s){var n=arguments.length,i=n<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(a,e,t,s);else for(var c=a.length-1;c>=0;c--)(o=a[c])&&(i=(n<3?o(i):n>3?o(e,t,i):o(e,t))||i);return n>3&&i&&Object.defineProperty(e,t,i),i},Z=class extends j{interactionService;conflictList;infoText="PACS.DIALOG_ADD_MULTI_VALIDATION_ERROR";constructor(e){super(),this.interactionService=e}onModalInitialized(){super.onModalInitialized()}closeClicked(e){this.cancelModal()}static ctorParameters=()=>[{type:$}];static propDecorators={conflictList:[{type:l}],infoText:[{type:l}]}};Z=yt([d({selector:"armon-pacs-ppermission-selection-conflict.component",template:ot,standalone:!0,imports:[D,y],styles:[lt]})],Z);var rt=`<div>\r
    <div class="row">\r
        <div class="col-xl-12" *ngIf="!deputyInfo.deputySelectionRequired">\r
            <clr-alert [clrAlertClosable]="false" [clrAlertSizeSmall]="true" [clrAlertType]="'success'">\r
                <div class="alert-item">\r
                    <span class="alert-text">\r
                        {{"PACS.DIRECTION_ADD_PPERMISSION_DEPUTIES_OK"|translate}}\r
                    </span>\r
                </div>\r
            </clr-alert>\r
        </div>\r
        <div class="col-xl-12" *ngIf="deputyInfo.deputySelectionRequired">\r
            <clr-alert [clrAlertClosable]="false" [clrAlertSizeSmall]="true" [clrAlertType]="'danger'">\r
                <div class="alert-item">\r
                    <span class="alert-text">\r
                        {{'PACS.DIRECTION_ADD_PPERMISSION_DEPUTIES_FAIL'|translate}}\r
                    </span>\r
                </div>\r
            </clr-alert>\r
        </div>\r
    </div>\r
    <span>{{'PACS.USER_PPERMISSION_DEPUTIES'|translate}}</span>\r
    <div *ngFor="let unit of units" class="deputy-list">\r
        <span>\r
            <strong>{{unit.unitName}} : </strong>\r
        </span>\r
        <span *ngFor="let deputy of unit.deputies" class="deputy-info">{{deputy.deputyPersonnelFullName}} ({{deputy.deputyStartUtc| date:'mediumDate'}} - {{deputy.deputyEndUtc|\r
            date:'mediumDate'}}) </span>\r
        <span *ngIf="unit.deputies.length==0" class="deputy-info-empty">{{'PACS.USER_PPERMISSION_NO_DEPUTY' |translate}}</span>\r
    </div>\r
    <div class="ps-3">\r
        <a href="{{deputyInfo.responseRedirectURL}}" target="_blank">\r
            <button class="btn btn-sm btn-outline-primary">{{'PACS.USER_PPERMISSION_EDIT_DEPUTY'|translate}}</button>\r
        </a>\r
    </div>\r
</div>`;var ct=`.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}:host{padding:6px 12px;width:100%}:host .deputy-list{padding-left:12px;font-size:.672rem;font-weight:.6rem}:host .deputy-list .deputy-info-empty{color:#c82602}
`;var It=function(a,e,t,s){var n=arguments.length,i=n<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(a,e,t,s);else for(var c=a.length-1;c>=0;c--)(o=a[c])&&(i=(n<3?o(i):n>3?o(e,t,i):o(e,t))||i);return n>3&&i&&Object.defineProperty(e,t,i),i},K=class{deputyInfo;units=[];constructor(){}ngOnInit(){this.prepareList()}prepareList(){this.deputyInfo.deputySummary.forEach(e=>{let t=this.units.findIndex(s=>s.unitCode===e.unitCode);t>=0&&e.deputyPersonnelNumber?this.units[t].deputies.push({deputyPersonnelFullName:e.deputyPersonnelFullName,deputyStartUtc:e.deputyStartUtc,deputyEndUtc:e.deputyEndUtc}):e.deputyPersonnelNumber?this.units.push({unitCode:e.unitCode,unitName:e.unitName,deputies:[{deputyPersonnelFullName:e.deputyPersonnelFullName,deputyStartUtc:e.deputyStartUtc,deputyEndUtc:e.deputyEndUtc}]}):this.units.push({unitCode:e.unitCode,unitName:e.unitName,deputies:[]})})}static ctorParameters=()=>[];static propDecorators={deputyInfo:[{type:l}]}};K=It([d({selector:"armon-pacs-ppermission-deputy-info",template:rt,standalone:!0,imports:[g,D,H,y],styles:[ct]})],K);var dt=`<div class="d-flex flex-column align-items-stretch">
    <div class="d-flex justify-content-center mb-2">
        <span class="text-xxl text-bold">{{selectedHour?.label}}:{{selectedMinute?.label}}</span>
    </div>
    <div class="d-flex">
        <div class="d-flex flex-column overflow-auto mhs-10 mx-2 list-container">
            <div *ngFor="let hour of hours" class="py-1 px-3 m-1 d-flex justify-content-center item-container" (click)="onHourSelected(hour)"
                [attr.selected]="selectedHour?.value == hour.value">
                <span class="text-lg text-bold">{{hour.label}}</span>
            </div>
        </div>
        <div class="d-flex flex-column overflow-auto mhs-10 mx-2 list-container">
            <div *ngFor="let minute of minutes" class="py-1 px-3 m-1 d-flex justify-content-center item-container" (click)="onMinuteSelected(minute)"
                [attr.selected]="selectedMinute?.value == minute.value">
                <span class="text-lg text-bold">{{minute.label}}</span>
            </div>
        </div>
    </div>
</div>`;var pt=`.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}.list-container{-webkit-border-radius:.375rem;-moz-border-radius:.375rem;border-radius:.375rem;border:1px solid #ccc;height:14rem}.item-container{background-color:#fff;cursor:pointer}.item-container:hover{background-color:#e6f0f6}.item-container[selected=true]{background-color:#c0dae8;cursor:default}
`;var Et=function(a,e,t,s){var n=arguments.length,i=n<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(a,e,t,s);else for(var c=a.length-1;c>=0;c--)(o=a[c])&&(i=(n<3?o(i):n>3?o(e,t,i):o(e,t))||i);return n>3&&i&&Object.defineProperty(e,t,i),i},Rt={provide:Pe,useExisting:ue(()=>k),multi:!0},k=class{onChange;hours;minutes;selectedHour;selectedMinute;min;writtenValue;selectedValue;isDisabled=!1;constructor(){this.createHours(),this.createMinutes()}writeValue(e){e&&(this.selectedValue=e,this.writtenValue=r.fromJSDate(e).toJSDate(),this.setSelectedSelection())}registerOnChange(e){this.onChange=e}registerOnTouched(e){}setDisabledState(e){this.isDisabled=e}ngOnInit(){}createMinutes(){this.minutes=[];for(let e=0;e<=60;e+=5)e!=60&&this.minutes.push({label:e.toString().length==1?"0"+e.toString():e.toString(),value:e})}createHours(){this.hours=[];for(let e=0;e<=23;e++)this.hours.push({label:e.toString().length==1?"0"+e.toString():e.toString(),value:e})}setSelectedSelection(){let e=this.hours.find(s=>s.label==r.fromJSDate(this.selectedValue).toFormat("HH"));this.selectedHour=e||this.hours[0];let t=this.minutes.find(s=>s.label==r.fromJSDate(this.selectedValue).toFormat("mm"));this.selectedMinute=t||this.minutes[0]}onHourSelected(e){this.selectedHour=e,this.setSelectedValue(r.fromJSDate(this.selectedValue).set({hour:e.value}))}onMinuteSelected(e){this.selectedMinute=e,this.setSelectedValue(r.fromJSDate(this.selectedValue).set({minute:e.value}))}setSelectedValue(e){this.selectedValue=e.toJSDate();let t;this.min&&e<=r.fromJSDate(this.min)?t=e.plus({day:1}):t=e,this.onChange(t.toJSDate())}static ctorParameters=()=>[];static propDecorators={min:[{type:l}]}};k=Et([d({selector:"armon-time-select-input",providers:[Rt],template:dt,standalone:!0,imports:[D],styles:[pt]})],k);var u=class a{get nzStatus(){return this._status}set nzStatus(e){this._status=e,this.isCustomStatus=!0}get nzIcon(){return this._icon}set nzIcon(e){e instanceof ee||(this.oldAPIIcon=typeof e=="string"&&e.indexOf("anticon")>-1),this._icon=e}get showProgress(){return this.nzPercentage!==null&&!this.nzIcon&&this.nzStatus==="process"&&this.nzPercentage>=0&&this.nzPercentage<=100}get currentIndex(){return this._currentIndex}set currentIndex(e){this._currentIndex=e,this.isCustomStatus||(this._status=e>this.index?"finish":e===this.index?this.outStatus||"":"wait")}constructor(e,t,s){this.cdr=e,this.ngZone=t,this.destroy$=s,this.nzDisabled=!1,this.nzPercentage=null,this.nzSize="default",this.isCustomStatus=!1,this._status="wait",this.oldAPIIcon=!0,this.direction="horizontal",this.index=0,this.last=!1,this.outStatus="process",this.showProcessDot=!1,this.clickable=!1,this.clickOutsideAngular$=new le,this.nullProcessFormat=()=>null,this._currentIndex=0}ngOnInit(){this.ngZone.runOutsideAngular(()=>ce(this.itemContainer.nativeElement,"click").pipe(pe(()=>this.clickable&&this.currentIndex!==this.index&&!this.nzDisabled),O(this.destroy$)).subscribe(()=>{this.clickOutsideAngular$.next(this.index)}))}enable(){this.nzDisabled=!1,this.cdr.markForCheck()}disable(){this.nzDisabled=!0,this.cdr.markForCheck()}markForCheck(){this.cdr.markForCheck()}static{this.\u0275fac=F({minVersion:"12.0.0",version:"17.3.8",ngImport:m,type:a,deps:[{token:N},{token:A},{token:h}],target:L.Component})}static{this.\u0275cmp=te({minVersion:"14.0.0",version:"17.3.8",type:a,isStandalone:!0,selector:"nz-step",inputs:{nzTitle:"nzTitle",nzSubtitle:"nzSubtitle",nzDescription:"nzDescription",nzDisabled:"nzDisabled",nzPercentage:"nzPercentage",nzSize:"nzSize",nzStatus:"nzStatus",nzIcon:"nzIcon"},host:{properties:{"class.ant-steps-item-wait":'nzStatus === "wait"',"class.ant-steps-item-process":'nzStatus === "process"',"class.ant-steps-item-finish":'nzStatus === "finish"',"class.ant-steps-item-error":'nzStatus === "error"',"class.ant-steps-item-active":"currentIndex === index","class.ant-steps-item-disabled":"nzDisabled","class.ant-steps-item-custom":"!!nzIcon","class.ant-steps-next-error":'(outStatus === "error") && (currentIndex === index + 1)'},classAttribute:"ant-steps-item"},providers:[h],viewQueries:[{propertyName:"processDotTemplate",first:!0,predicate:["processDotTemplate"],descendants:!0},{propertyName:"itemContainer",first:!0,predicate:["itemContainer"],descendants:!0,static:!0}],exportAs:["nzStep"],ngImport:m,template:`
    <div
      #itemContainer
      class="ant-steps-item-container"
      [attr.role]="clickable && !nzDisabled ? 'button' : null"
      [tabindex]="clickable && !nzDisabled ? 0 : null"
    >
      <div class="ant-steps-item-tail" *ngIf="last !== true"></div>
      <div class="ant-steps-item-icon">
        <ng-template [ngIf]="!showProcessDot">
          <div *ngIf="showProgress" class="ant-steps-progress-icon">
            <nz-progress
              [nzPercent]="nzPercentage"
              nzType="circle"
              [nzWidth]="nzSize === 'small' ? 32 : 40"
              [nzFormat]="nullProcessFormat"
              [nzStrokeWidth]="4"
            ></nz-progress>
          </div>
          <span class="ant-steps-icon" *ngIf="nzStatus === 'finish' && !nzIcon"
            ><span nz-icon nzType="check"></span
          ></span>
          <span class="ant-steps-icon" *ngIf="nzStatus === 'error'"><span nz-icon nzType="close"></span></span>
          <span class="ant-steps-icon" *ngIf="(nzStatus === 'process' || nzStatus === 'wait') && !nzIcon">
            {{ index + 1 }}
          </span>
          <span class="ant-steps-icon" *ngIf="nzIcon">
            <ng-container *nzStringTemplateOutlet="nzIcon; let icon">
              <span nz-icon [nzType]="!oldAPIIcon && icon" [ngClass]="oldAPIIcon && icon"></span>
            </ng-container>
          </span>
        </ng-template>
        <ng-template [ngIf]="showProcessDot">
          <span class="ant-steps-icon">
            <ng-template #processDotTemplate>
              <span class="ant-steps-icon-dot"></span>
            </ng-template>
            <ng-template
              [ngTemplateOutlet]="customProcessTemplate || processDotTemplate"
              [ngTemplateOutletContext]="{
                $implicit: processDotTemplate,
                status: nzStatus,
                index: index
              }"
            ></ng-template>
          </span>
        </ng-template>
      </div>
      <div class="ant-steps-item-content">
        <div class="ant-steps-item-title">
          <ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>
          <div *ngIf="nzSubtitle" class="ant-steps-item-subtitle">
            <ng-container *nzStringTemplateOutlet="nzSubtitle">{{ nzSubtitle }}</ng-container>
          </div>
        </div>
        <div class="ant-steps-item-description">
          <ng-container *nzStringTemplateOutlet="nzDescription">{{ nzDescription }}</ng-container>
        </div>
      </div>
    </div>
  `,isInline:!0,dependencies:[{kind:"directive",type:g,selector:"[ngIf]",inputs:["ngIf","ngIfThen","ngIfElse"]},{kind:"ngmodule",type:ae},{kind:"component",type:it,selector:"nz-progress",inputs:["nzShowInfo","nzWidth","nzStrokeColor","nzSize","nzFormat","nzSuccessPercent","nzPercent","nzStrokeWidth","nzGapDegree","nzStatus","nzType","nzGapPosition","nzStrokeLinecap","nzSteps"],exportAs:["nzProgress"]},{kind:"ngmodule",type:ne},{kind:"directive",type:Me,selector:"[nz-icon]",inputs:["nzSpin","nzRotate","nzType","nzTheme","nzTwotoneColor","nzIconfont"],exportAs:["nzIcon"]},{kind:"ngmodule",type:se},{kind:"directive",type:Ae,selector:"[nzStringTemplateOutlet]",inputs:["nzStringTemplateOutletContext","nzStringTemplateOutlet"],exportAs:["nzStringTemplateOutlet"]},{kind:"directive",type:w,selector:"[ngClass]",inputs:["class","ngClass"]},{kind:"directive",type:M,selector:"[ngTemplateOutlet]",inputs:["ngTemplateOutletContext","ngTemplateOutlet","ngTemplateOutletInjector"]}],changeDetection:E.OnPush,encapsulation:R.None})}};re([we()],u.prototype,"nzDisabled",void 0);U({minVersion:"12.0.0",version:"17.3.8",ngImport:m,type:u,decorators:[{type:d,args:[{changeDetection:E.OnPush,encapsulation:R.None,selector:"nz-step",exportAs:"nzStep",preserveWhitespaces:!1,template:`
    <div
      #itemContainer
      class="ant-steps-item-container"
      [attr.role]="clickable && !nzDisabled ? 'button' : null"
      [tabindex]="clickable && !nzDisabled ? 0 : null"
    >
      <div class="ant-steps-item-tail" *ngIf="last !== true"></div>
      <div class="ant-steps-item-icon">
        <ng-template [ngIf]="!showProcessDot">
          <div *ngIf="showProgress" class="ant-steps-progress-icon">
            <nz-progress
              [nzPercent]="nzPercentage"
              nzType="circle"
              [nzWidth]="nzSize === 'small' ? 32 : 40"
              [nzFormat]="nullProcessFormat"
              [nzStrokeWidth]="4"
            ></nz-progress>
          </div>
          <span class="ant-steps-icon" *ngIf="nzStatus === 'finish' && !nzIcon"
            ><span nz-icon nzType="check"></span
          ></span>
          <span class="ant-steps-icon" *ngIf="nzStatus === 'error'"><span nz-icon nzType="close"></span></span>
          <span class="ant-steps-icon" *ngIf="(nzStatus === 'process' || nzStatus === 'wait') && !nzIcon">
            {{ index + 1 }}
          </span>
          <span class="ant-steps-icon" *ngIf="nzIcon">
            <ng-container *nzStringTemplateOutlet="nzIcon; let icon">
              <span nz-icon [nzType]="!oldAPIIcon && icon" [ngClass]="oldAPIIcon && icon"></span>
            </ng-container>
          </span>
        </ng-template>
        <ng-template [ngIf]="showProcessDot">
          <span class="ant-steps-icon">
            <ng-template #processDotTemplate>
              <span class="ant-steps-icon-dot"></span>
            </ng-template>
            <ng-template
              [ngTemplateOutlet]="customProcessTemplate || processDotTemplate"
              [ngTemplateOutletContext]="{
                $implicit: processDotTemplate,
                status: nzStatus,
                index: index
              }"
            ></ng-template>
          </span>
        </ng-template>
      </div>
      <div class="ant-steps-item-content">
        <div class="ant-steps-item-title">
          <ng-container *nzStringTemplateOutlet="nzTitle">{{ nzTitle }}</ng-container>
          <div *ngIf="nzSubtitle" class="ant-steps-item-subtitle">
            <ng-container *nzStringTemplateOutlet="nzSubtitle">{{ nzSubtitle }}</ng-container>
          </div>
        </div>
        <div class="ant-steps-item-description">
          <ng-container *nzStringTemplateOutlet="nzDescription">{{ nzDescription }}</ng-container>
        </div>
      </div>
    </div>
  `,host:{class:"ant-steps-item","[class.ant-steps-item-wait]":'nzStatus === "wait"',"[class.ant-steps-item-process]":'nzStatus === "process"',"[class.ant-steps-item-finish]":'nzStatus === "finish"',"[class.ant-steps-item-error]":'nzStatus === "error"',"[class.ant-steps-item-active]":"currentIndex === index","[class.ant-steps-item-disabled]":"nzDisabled","[class.ant-steps-item-custom]":"!!nzIcon","[class.ant-steps-next-error]":'(outStatus === "error") && (currentIndex === index + 1)'},providers:[h],imports:[g,ae,ne,se,w,M],standalone:!0}]}],ctorParameters:()=>[{type:N},{type:A},{type:h}],propDecorators:{processDotTemplate:[{type:P,args:["processDotTemplate",{static:!1}]}],itemContainer:[{type:P,args:["itemContainer",{static:!0}]}],nzTitle:[{type:l}],nzSubtitle:[{type:l}],nzDescription:[{type:l}],nzDisabled:[{type:l}],nzPercentage:[{type:l}],nzSize:[{type:l}],nzStatus:[{type:l}],nzIcon:[{type:l}]}});var T=class a{set nzProgressDot(e){e instanceof ee?(this.showProcessDot=!0,this.customProcessDotTemplate=e):this.showProcessDot=Ne(e),this.updateChildrenSteps()}constructor(e,t,s,n){this.ngZone=e,this.cdr=t,this.directionality=s,this.destroy$=n,this.nzCurrent=0,this.nzDirection="horizontal",this.nzLabelPlacement="horizontal",this.nzType="default",this.nzSize="default",this.nzStartIndex=0,this.nzStatus="process",this.nzIndexChange=new ge,this.indexChangeSubscription=oe.EMPTY,this.showProcessDot=!1,this.showProgress=!1,this.dir="ltr"}ngOnChanges(e){(e.nzStartIndex||e.nzDirection||e.nzStatus||e.nzCurrent||e.nzSize)&&this.updateChildrenSteps()}ngOnInit(){this.directionality.change?.pipe(O(this.destroy$)).subscribe(e=>{this.dir=e,this.cdr.detectChanges()}),this.dir=this.directionality.value,this.updateChildrenSteps()}ngAfterContentInit(){this.steps&&this.steps.changes.pipe(me(null),O(this.destroy$)).subscribe(()=>{this.updateHostProgressClass(),this.updateChildrenSteps()})}updateHostProgressClass(){this.steps&&!this.showProcessDot&&(this.showProgress=!!this.steps.toArray().find(e=>e.nzPercentage!==null))}updateChildrenSteps(){if(this.steps){let e=this.steps.length;this.steps.toArray().forEach((t,s)=>{Promise.resolve().then(()=>{t.nzSize=this.nzSize,t.outStatus=this.nzStatus,t.showProcessDot=this.showProcessDot,this.customProcessDotTemplate&&(t.customProcessTemplate=this.customProcessDotTemplate),t.clickable=this.nzIndexChange.observers.length>0,t.direction=this.nzDirection,t.index=s+this.nzStartIndex,t.currentIndex=this.nzCurrent,t.last=e===s+1,t.markForCheck()})}),this.indexChangeSubscription.unsubscribe(),this.indexChangeSubscription=de(...this.steps.map(t=>t.clickOutsideAngular$)).pipe(O(this.destroy$)).subscribe(t=>{this.nzIndexChange.observers.length&&this.ngZone.run(()=>this.nzIndexChange.emit(t))})}}static{this.\u0275fac=F({minVersion:"12.0.0",version:"17.3.8",ngImport:m,type:a,deps:[{token:A},{token:N},{token:ie,optional:!0},{token:h}],target:L.Component})}static{this.\u0275cmp=te({minVersion:"14.0.0",version:"17.3.8",type:a,isStandalone:!0,selector:"nz-steps",inputs:{nzCurrent:"nzCurrent",nzDirection:"nzDirection",nzLabelPlacement:"nzLabelPlacement",nzType:"nzType",nzSize:"nzSize",nzStartIndex:"nzStartIndex",nzStatus:"nzStatus",nzProgressDot:"nzProgressDot"},outputs:{nzIndexChange:"nzIndexChange"},host:{properties:{"class.ant-steps-horizontal":"nzDirection === 'horizontal'","class.ant-steps-vertical":"nzDirection === 'vertical'","class.ant-steps-label-horizontal":"nzDirection === 'horizontal'","class.ant-steps-label-vertical":"(showProcessDot || nzLabelPlacement === 'vertical') && nzDirection === 'horizontal'","class.ant-steps-dot":"showProcessDot","class.ant-steps-small":"nzSize === 'small'","class.ant-steps-navigation":"nzType === 'navigation'","class.ant-steps-rtl":"dir === 'rtl'","class.ant-steps-with-progress":"showProgress"},classAttribute:"ant-steps"},providers:[h],queries:[{propertyName:"steps",predicate:u}],exportAs:["nzSteps"],usesOnChanges:!0,ngImport:m,template:"<ng-content></ng-content>",isInline:!0,changeDetection:E.OnPush,encapsulation:R.None})}};U({minVersion:"12.0.0",version:"17.3.8",ngImport:m,type:T,decorators:[{type:d,args:[{changeDetection:E.OnPush,encapsulation:R.None,preserveWhitespaces:!1,selector:"nz-steps",exportAs:"nzSteps",template:"<ng-content></ng-content>",host:{class:"ant-steps","[class.ant-steps-horizontal]":"nzDirection === 'horizontal'","[class.ant-steps-vertical]":"nzDirection === 'vertical'","[class.ant-steps-label-horizontal]":"nzDirection === 'horizontal'","[class.ant-steps-label-vertical]":"(showProcessDot || nzLabelPlacement === 'vertical') && nzDirection === 'horizontal'","[class.ant-steps-dot]":"showProcessDot","[class.ant-steps-small]":"nzSize === 'small'","[class.ant-steps-navigation]":"nzType === 'navigation'","[class.ant-steps-rtl]":"dir === 'rtl'","[class.ant-steps-with-progress]":"showProgress"},providers:[h],standalone:!0}]}],ctorParameters:()=>[{type:A},{type:N},{type:ie,decorators:[{type:he}]},{type:h}],propDecorators:{steps:[{type:Se,args:[u]}],nzCurrent:[{type:l}],nzDirection:[{type:l}],nzLabelPlacement:[{type:l}],nzType:[{type:l}],nzSize:[{type:l}],nzStartIndex:[{type:l}],nzStatus:[{type:l}],nzProgressDot:[{type:l}],nzIndexChange:[{type:De}]}});var V=class a{static{this.\u0275fac=F({minVersion:"12.0.0",version:"17.3.8",ngImport:m,type:a,deps:[],target:L.NgModule})}static{this.\u0275mod=ve({minVersion:"14.0.0",version:"17.3.8",ngImport:m,type:a,imports:[T,u],exports:[T,u]})}static{this.\u0275inj=Te({minVersion:"12.0.0",version:"17.3.8",ngImport:m,type:a,imports:[u]})}};U({minVersion:"12.0.0",version:"17.3.8",ngImport:m,type:V,decorators:[{type:ye,args:[{imports:[T,u],exports:[T,u]}]}]});var Pt=function(a,e,t,s){var n=arguments.length,i=n<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(a,e,t,s);else for(var c=a.length-1;c>=0;c--)(o=a[c])&&(i=(n<3?o(i):n>3?o(e,t,i):o(e,t))||i);return n>3&&i&&Object.defineProperty(e,t,i),i},f="typeSelection",v="dailyStartSelection",I="dailyEndSelection",b="hourlyDaySelection",x="hourlyStartHourSelection",C="hourlyEndHourSelection",S="additionalData",X="summary",mt=class extends j{translate;pacsService;interactionService;authService;dfDynamicFormService;identitySelectionService;ppermissionId;useAsHumanResources;hasWritePermission;editModeOnlyDateSelection;userId;selectedStartDate;selectedEndDate;selectedStartDay;typeLimit;ppermission;bulkUpsert=!1;ppermissionTypes;selectedType;modeDaily=!0;currentStepIndex=0;selectionIdentities;visibleComponent=!1;viewState=f;difference;differenceValidated=!1;dateSelection=p.NoDateSelected;dailyStartMorning=!0;dailyEndMorning=!0;disableDailyStartMorning=!1;disableDailyEndMorning=!1;disablePrevButton=!1;disableNextButton=!1;visiblePrevButton=!1;visibleNextButton=!1;visibleDeputySelection=!1;disableSaveButton=!0;showDateRangeInfo=!1;visibleValidationStatus=!1;editMode=!1;nowDate=new Date;maxEndDate=null;minEndDate=null;repeatDaySelection=!1;repeatCounts=[];selectedRepeatCount;validationItems;visibleDeputyInfo=!1;applyApproveSteps=!1;deputyInfo;dfForm;organizationSettingsForm;constructor(e,t,s,n,i,o){super(),this.translate=e,this.pacsService=t,this.interactionService=s,this.authService=n,this.dfDynamicFormService=i,this.identitySelectionService=o}onModalInitialized(){super.onModalInitialized(),z(this.useAsHumanResources)&&this.authService.checkPermission(Y.PPERMISSION.getHRApprovement()),z(this.hasWritePermission)&&this.authService.checkPermission(Y.PPERMISSION.getWrite()),z(this.editModeOnlyDateSelection)&&(this.editModeOnlyDateSelection=!1),z(this.typeLimit)&&(this.typeLimit=_.NoLimit),z(this.ppermissionId)?this.editMode=!1:this.editMode=!0,this.bulkUpsert=this.useAsHumanResources||this.hasWritePermission,this.translate.get(["PACS.SELECT_ONE","PACS.WORKPLAN_PERIOD_UNIT_DAY"]).subscribe(e=>{for(let t=2;t<=10;t++)this.repeatCounts.push({value:t,label:t+" "+e["PACS.WORKPLAN_PERIOD_UNIT_DAY"]});this.getInitData()})}getInitData(){let e=new He,t=new Ue;t.take=0,e.pagination=t,this.pacsService.getPPermissionTypeList(e).subscribe(s=>{let n=[];switch(this.useAsHumanResources?n=s.items.filter(i=>i.hrCanInit==!0&&i.isPassive==!1):this.hasWritePermission?n=s.items.filter(i=>i.unitManagerCanInit==!0&&i.isPassive==!1):n=s.items.filter(i=>i.personnelCanInit==!0&&i.isPassive==!1),this.typeLimit){case _.NoLimit:this.ppermissionTypes=n;break;case _.OnlyTypeDaily:this.ppermissionTypes=n.filter(i=>i.isDailyScheduled==!0);break;case _.OnlyTypeHourly:this.ppermissionTypes=n.filter(i=>i.isDailyScheduled==!1);break}this.editMode?this.pacsService.getPPermissionDetail(this.ppermissionId).subscribe(i=>{this.setPPermission(Be.getCopyModelAsPPermission(i)),this.setSelectedType(this.ppermissionTypes.find(o=>o.id==this.ppermission.ppermissionTypeId)),this.validateDateSettings(),this.changeViewState(f),this.editModeOnlyDateSelection?this.selectedType.isDailyScheduled?this.changeViewState(v):this.changeViewState(b):this.changeViewState(f),this.visibleComponent=!0}):(this.setPPermission(J.getEmptyModel()),this.changeViewState(f),this.visibleComponent=!0,this.selectedStartDate&&this.selectedEndDate?(this.ppermission.dateRange.startDateTime=this.selectedStartDate,this.ppermission.dateRange.endDateTime=this.selectedEndDate,this.dateSelection=p.BothDateSelected):this.selectedStartDay&&(this.ppermission.dateRange.startDateTime=r.fromISO(this.selectedStartDay).toJSDate(),this.dateSelection=p.StartDaySelected))})}setSelectedType(e){this.selectedType=e,this.ppermission.ppermissionTypeId=this.selectedType.id,this.modeDaily=this.selectedType.isDailyScheduled==!0,this.repeatDaySelection=!1,this.selectedRepeatCount=this.repeatCounts[0].value,this.visibleDeputySelection=this.sessionService.currentOrganization.pacsModuleSettings&&this.sessionService.currentOrganization.pacsModuleSettings.deputySelectionEnabled&&this.authService.checkPermission(Y.IDENTITY.getReadBasic())&&this.selectedType.needsManagerDeputy,this.selectedType.dynamicForm?this.organizationSettingsForm=this.dfDynamicFormService.getFormUserDynamicContent(this.selectedType.dynamicForm):this.organizationSettingsForm=null,this.organizationFormValue=null}setPPermission(e){this.ppermission=e,this.ppermission.dateRange&&this.ppermission.dateRange.startDateTime&&(this.minEndDate=this.ppermission.dateRange.startDateTime)}validateDateSettings(){this.selectedType.isDailyScheduled&&this.selectedType.lessThanOneUnitEnabled&&this.ppermission.dateRange&&(this.ppermission.dateRange.startDateTime&&r.fromJSDate(this.ppermission.dateRange.startDateTime)>=r.fromJSDate(this.ppermission.dateRange.startDateTime).startOf("day").plus({hours:12})&&(this.dailyStartMorning=!1,this.normalizeDaySelection(!0)),this.ppermission.dateRange.endDateTime&&r.fromJSDate(this.ppermission.dateRange.endDateTime)>=r.fromJSDate(this.ppermission.dateRange.endDateTime).startOf("day").plus({hours:12})&&(this.dailyEndMorning=!1,this.normalizeDaySelection(!1)))}validateButtons(){switch(this.visiblePrevButton=!0,this.visibleNextButton=!0,this.disablePrevButton=!1,this.disableNextButton=!1,this.viewState){case f:this.disableNextButton=!this.selectedType||this.selectedType.id==null,this.visiblePrevButton=!1;break;case v:break;case I:this.disableNextButton=!this.ppermission.dateRange||!this.ppermission.dateRange.endDateTime;break;case b:break;case x:break;case C:break;case S:this.onNoteChanged(null),this.organizationSettingsForm&&this.dfForm&&this.dfForm.form.invalid&&(this.disableNextButton=!0);break;case X:this.validateForm(),this.visibleNextButton=!1;break}}changeViewState(e){let t=!1,s=!0;switch(this.visibleValidationStatus=!1,e){case f:this.currentStepIndex=0;break;case v:this.currentStepIndex=1;break;case I:this.currentStepIndex=2;break;case b:this.currentStepIndex=1;break;case x:this.currentStepIndex=2;break;case C:this.currentStepIndex=3;break;case S:this.bulkUpsert?this.currentStepIndex=this.selectedType.isDailyScheduled?3:4:(t=!0,this.checkAllValidation().then(n=>{n?(this.visibleValidationStatus=!1,this.currentStepIndex=this.selectedType.isDailyScheduled?3:4,this.viewState=e,this.validateButtons()):this.visibleValidationStatus=!0},n=>{}));break;case X:s=!1,this.currentStepIndex=this.selectedType.isDailyScheduled?4:5;break}t==!1&&(this.viewState=e),s==!0&&this.setDifference(),this.validateButtons()}resetDateSelection(){this.dateSelection=p.NoDateSelected}gotoNextViewState(){switch(this.viewState){case f:if(this.selectedType.isDailyScheduled)switch(this.dateSelection){case p.NoDateSelected:this.changeViewState(v);break;case p.StartDaySelected:this.changeViewState(I),this.resetDateSelection();break;case p.BothDateSelected:this.changeViewState(S),this.resetDateSelection();break}else switch(this.dateSelection){case p.NoDateSelected:this.changeViewState(b);break;case p.StartDaySelected:this.changeViewState(x),this.resetDateSelection();break;case p.BothDateSelected:this.changeViewState(S),this.resetDateSelection();break}break;case v:this.changeViewState(I);break;case I:this.changeViewState(S);break;case b:this.changeViewState(x);break;case x:this.ppermission.dateRange.endDateTime||(this.ppermission.dateRange.endDateTime=r.fromJSDate(this.ppermission.dateRange.startDateTime).plus({hours:1}).toJSDate()),this.changeViewState(C);break;case C:this.changeViewState(S);break;case S:this.changeViewState(X);break}}gotoPrevViewState(){switch(this.viewState){case v:this.changeViewState(f);break;case I:this.changeViewState(v);break;case b:this.changeViewState(f);break;case x:this.changeViewState(b);break;case C:this.changeViewState(x);break;case S:this.selectedType.isDailyScheduled?this.changeViewState(I):this.changeViewState(C);break;case X:this.changeViewState(S);break}}onPrevClicked(e){this.gotoPrevViewState()}onNextClicked(e){this.gotoNextViewState()}normalizeDaySelection(e){if(this.disableDailyStartMorning=!1,this.disableDailyEndMorning=!1,r.fromJSDate(this.ppermission.dateRange.startDateTime)>=r.fromJSDate(this.ppermission.dateRange.endDateTime)&&(this.ppermission.dateRange.endDateTime=this.getDailyMinDate(!0),this.validateDateSettings()),this.ppermission&&this.ppermission.dateRange){if(e==!0&&this.ppermission.dateRange.startDateTime){let t=r.fromJSDate(this.ppermission.dateRange.startDateTime).startOf("day");this.selectedType&&this.selectedType.lessThanOneUnitEnabled&&this.dailyStartMorning==!1&&(t=t.plus({hours:12})),this.ppermission.dateRange.startDateTime=t.toJSDate()}if(e==!1&&this.ppermission.dateRange.endDateTime){let t=r.fromJSDate(this.ppermission.dateRange.endDateTime).startOf("day");this.selectedType&&this.selectedType.lessThanOneUnitEnabled&&this.dailyEndMorning==!1&&(t=t.plus({hours:12})),this.ppermission.dateRange.endDateTime=t.toJSDate()}this.ppermission.dateRange.startDateTime&&this.ppermission.dateRange.endDateTime&&r.fromJSDate(this.ppermission.dateRange.startDateTime).toFormat("yyyy-MM-dd")==r.fromJSDate(this.ppermission.dateRange.endDateTime).toFormat("yyyy-MM-dd")&&(this.dailyStartMorning=!0,this.dailyEndMorning=!1,this.disableDailyStartMorning=!0,this.disableDailyEndMorning=!0)}}setDailyDifference(){this.ppermission&&this.ppermission.dateRange&&this.ppermission.dateRange.startDateTime&&this.ppermission.dateRange.endDateTime?this.difference=r.fromJSDate(this.ppermission.dateRange.endDateTime).diff(r.fromJSDate(this.ppermission.dateRange.startDateTime),["days"]).toObject().days:this.difference=null,this.differenceValidated=!1,this.minEndDate=this.getDailyMinDate()}getDailyMinDate(e=!1){return this.selectedType.isDailyScheduled&&this.selectedType.lessThanOneUnitEnabled==!1?r.fromJSDate(this.ppermission.dateRange.startDateTime).plus({days:this.selectedType.minValue}).startOf("day").toJSDate():e?r.fromJSDate(this.ppermission.dateRange.startDateTime).plus({hours:12}).toJSDate():r.fromJSDate(this.ppermission.dateRange.startDateTime).toJSDate()}onDailyStartDateChanged(e){this.maxEndDate=null,this.normalizeDaySelection(!0),this.setDailyDifference(),this.validateButtons()}onDailyEndDateChanged(e,t=!0){this.maxEndDate=null,this.normalizeDaySelection(!1),this.setDailyDifference(),this.validateButtons()}onDailyStartMorningChanged(e){this.normalizeDaySelection(!0),this.setDailyDifference()}onDailyEndMorningChanged(e){this.normalizeDaySelection(!1),this.setDailyDifference()}checkHourlyEndDate(){(r.fromJSDate(this.ppermission.dateRange.startDateTime)>=r.fromJSDate(this.ppermission.dateRange.endDateTime)||this.difference==null||this.difference>=1440)&&(this.ppermission.dateRange.endDateTime=null),this.maxEndDate=r.fromJSDate(this.ppermission.dateRange.startDateTime).plus({days:1}).toJSDate(),this.minEndDate=this.ppermission.dateRange.startDateTime}onHourlyStartDayChanged(e){this.checkHourlyEndDate(),this.setHourlyDifference(),this.validateButtons()}onHourlyStartHourChanged(e){this.checkHourlyEndDate(),this.setHourlyDifference(),this.validateButtons()}onHourlyEndHourChanged(e){this.setHourlyDifference(),this.validateButtons()}setHourlyDifference(){this.ppermission&&this.ppermission.dateRange&&this.ppermission.dateRange.startDateTime&&this.ppermission.dateRange.endDateTime?this.difference=r.fromJSDate(this.ppermission.dateRange.endDateTime).diff(r.fromJSDate(this.ppermission.dateRange.startDateTime),["minutes"]).toObject().minutes:this.difference=null,this.differenceValidated=!1}setDifference(){this.selectedType&&(this.selectedType.isDailyScheduled?this.setDailyDifference():this.setHourlyDifference())}saveClicked(e){let t;if(this.bulkUpsert&&!this.userId)t=J.getRequestModel(this.ppermission),t.approve=!this.applyApproveSteps,this.addDynamicFormData(t),this.pacsService.upsertPPermission(t,this.useAsHumanResources).subscribe(s=>{this.upsertCompleted(s,!this.editMode)});else if(this.bulkUpsert&&this.userId){let s=new G;s.id=this.ppermission.id,s.ppermissionTypeId=this.ppermission.ppermissionTypeId,s.dateRange=this.ppermission.dateRange,s.note=this.ppermission.note,s.approve=!this.applyApproveSteps,this.addDynamicFormData(s),this.ppermission.attachmentInfoList.forEach(i=>{s.attachmentList.push(i.id)});let n=new q;n.userId=this.userId,n.deputyUserId=this.ppermission.deputyUserId,s.userAndDeputyList.push(n),this.pacsService.upsertWithUser(s).subscribe(i=>{this.upsertCompleted(i)})}else{let s=[];this.validationItems.filter(i=>i.toSaveValid).forEach(i=>{let o=J.getRequestModel(this.ppermission);o.dateRange.startDateTime=i.startDateTime,o.dateRange.endDateTime=i.endDateTime,o.approve=!this.applyApproveSteps,this.addDynamicFormData(o),s.push(o)});let n=[];s.forEach(i=>{n.push(this.pacsService.upsertSelfPPermission(i))}),Q(n).subscribe(i=>{},i=>{},()=>{this.upsertCompleted(null)})}}updateDatesClicked(e){this.bulkUpsert&&this.pacsService.updatePPermissionDateRange(this.ppermission.id,this.ppermission.dateRange).subscribe(t=>{this.upsertCompleted(t,!1)})}get selectedIdentities(){return this.selectionIdentities?this.selectionIdentities.getSelection()||[]:[]}getSessionForPPermission(e){return this.identitySelectionService.getSessionForPPermission(this.ppermission.id,e)}showUserSelection(){this.modalService.open(Ke,{settings:{size:"xl"},props:{editable:!0,sessionFunction:this.getSessionForPPermission.bind(this),useCustomApply:!0}}).result.then(e=>{e&&this.pacsService.applyUserSelectionSession(this.ppermission.id,e.sessionId,this.useAsHumanResources,!this.applyApproveSteps).subscribe(()=>{this.closeModal()},t=>{t&&t.status&&t.status===xe.Conflict&&this.modalService.open(Z,{settings:{size:"lg",scrollable:!0,centered:!0},props:{conflictList:JSON.parse(t.error)}}).result.then(s=>{this.showUserSelection()}).catch(s=>{})})}).catch(e=>{})}upsertCompleted(e,t=!0){this.ppermission.id=e,this.bulkUpsert&&t&&!this.userId?this.showUserSelection():(this.closeModal(),this.interactionService.showMessage("PACS.MESSAGE_SAVED_USER_PPERMISSION",null,Ee.Success))}validateForm(){if(this.bulkUpsert)this.disableSaveButton=this.ppermission.dateRange.startDateTime==null||this.ppermission.dateRange.endDateTime==null||this.ppermission.ppermissionTypeId==null;else{let e=-1;this.validationItems&&this.validationItems.length>0&&(e=this.validationItems.findIndex(s=>s.toSaveValid));let t=this.ppermission.ppermissionTypeId==null||e==-1;this.disableSaveButton=t}return!this.disableSaveButton}validatePPermission(e){return new Promise(t=>{if(e.startDateTime&&e.endDateTime){this.showDateRangeInfo=!1;let s=new Ye;s.dateRange.startDateTime=e.startDateTime,s.dateRange.endDateTime=e.endDateTime,s.ppermissionTypeId=this.selectedType.id,this.editMode&&(s.ppermissionId=this.ppermission.id),this.bulkUpsert?this.pacsService.getPPermissionValidation(s).subscribe(n=>{n.isOk&&(e.dateRangeValid=!0,t(e))},n=>{e.dateRangeValid=!1,t(e)}):this.pacsService.getPPermissionValidationSelf(s).subscribe(n=>{let i=n.isOk;if(i?e.dateRangePeriods=n.workPlanIntersectingDates:e.validationErrorText=n.errorMessage||"PACS.DIRECTION_PPERMISSION_VALIDATE_ERR_"+n.errorCode,i)if(this.difference=n.usedPPermissionClaim,this.differenceValidated=!0,this.sessionService.currentOrganization.pacsModuleSettings&&this.sessionService.currentOrganization.pacsModuleSettings.deputySelectionEnabled==!1&&this.selectedType.needsManagerDeputy){let o=new je;o.dateRange.startDateTime=e.startDateTime,o.dateRange.endDateTime=e.endDateTime,o.ppermissionTypeId=s.ppermissionTypeId,this.pacsService.getPPermissionDeputyInfo(o).subscribe(c=>{c.errorCode?(e.validationErrorText=c.errorMessage||"PACS.DIRECTION_PPERMISSION_VALIDATE_ERR_"+c.errorCode,e.dateRangeValid=!1,t(e)):(e.deputyInfo=c,this.deputyInfo=c,this.visibleDeputyInfo=!0,e.dateRangeValid=!0,t(e))})}else e.dateRangeValid=!0,t(e);else e.dateRangeValid=!1,t(e)})}else e.dateRangeValid=!1,t(e)})}checkAllValidation(){return new Promise(e=>{this.visibleValidationStatus=!1;let t=this.repeatDaySelection?this.selectedRepeatCount:1;this.validationItems=[];for(let n=0;n<t;n++)this.validationItems.push({startDateTime:r.fromJSDate(this.ppermission.dateRange.startDateTime).plus({days:n}).toJSDate(),endDateTime:r.fromJSDate(this.ppermission.dateRange.endDateTime).plus({days:n}).toJSDate(),dateRangeValid:null,dateRangePeriods:[],toSaveValid:!1});let s=[];this.validationItems.forEach(n=>{s.push(this.validatePPermission(n))}),Q(s).subscribe(n=>{},n=>{},()=>{this.validationItems.forEach(n=>{n.toSaveValid=this.validateItem(n)}),e(this.validateForm())})})}validateItem(e){return e.dateRangeValid==!1?!1:this.visibleDeputyInfo&&e.deputyInfo?!e.deputyInfo.deputySelectionRequired:!0}onTypeSelected(e){this.selectedType&&this.selectedType.isDailyScheduled!=e.isDailyScheduled&&this.ppermission&&this.ppermission.dateRange&&(this.ppermission.dateRange.endDateTime=null),this.setSelectedType(e),this.validateButtons()}onNoteChanged(e){this.disableNextButton=this.selectedType.noteIsMandatory&&(!this.ppermission.note||this.ppermission.note=="")}repeatDaySelectionChanged(e){}organizationFormValue;onDynamicFormInitialized(e){this.organizationSettingsForm&&this.dfForm&&(this.editMode&&(this.ppermission.dynamicFormData&&this.dfForm.form.setValue(this.ppermission.dynamicFormData),this.dfForm.form.updateValueAndValidity()),this.validateButtons(),this.organizationFormValue=this.dfForm.form.value,this.dfForm.form.statusChanges.subscribe(()=>{this.validateButtons(),this.organizationFormValue=this.dfForm.form.value}))}addDynamicFormData(e){this.organizationSettingsForm&&this.organizationFormValue&&(e.dynamicFormId=this.selectedType.dynamicForm.id,e.dynamicFormData=this.organizationFormValue)}static ctorParameters=()=>[{type:Re},{type:Ve},{type:$},{type:$e},{type:Xe},{type:Ze}];static propDecorators={ppermissionId:[{type:l}],useAsHumanResources:[{type:l}],hasWritePermission:[{type:l}],editModeOnlyDateSelection:[{type:l}],userId:[{type:l}],selectedStartDate:[{type:l}],selectedEndDate:[{type:l}],selectedStartDay:[{type:l}],typeLimit:[{type:l}],selectionIdentities:[{type:P,args:["searchIdentity"]}],dfForm:[{type:P,args:["dfForm",{static:!1}]}]}};mt=Pt([d({selector:"armon-user-ppermission-upsert-modal",template:nt,standalone:!0,providers:[{provide:Ce,useClass:Le}],schemas:[fe],imports:[g,V,Ie,be,D,M,_e,ze,ke,k,tt,w,Je,et,qe,We,Ge,Qe,W,Fe,K,H,y],styles:[at]})],mt);var _;(function(a){a[a.NoLimit=1]="NoLimit",a[a.OnlyTypeDaily=2]="OnlyTypeDaily",a[a.OnlyTypeHourly=3]="OnlyTypeHourly"})(_||(_={}));var p;(function(a){a[a.NoDateSelected=1]="NoDateSelected",a[a.BothDateSelected=2]="BothDateSelected",a[a.StartDateSelected=3]="StartDateSelected",a[a.EndDateSelected=4]="EndDateSelected",a[a.StartDaySelected=5]="StartDaySelected"})(p||(p={}));export{Z as a,W as b,mt as c,_ as d};
