import{a as Re}from"./chunk-EUEKUKCS.js";import{a as De}from"./chunk-JUI5JEEH.js";import{a as G,b as ke}from"./chunk-SLQSOQUB.js";import{a as Pe}from"./chunk-I5K7GPAI.js";import{a as Ie}from"./chunk-P3WQM3KW.js";import{a as Se}from"./chunk-D4RZOGGF.js";import{a as Ae}from"./chunk-JUDWAYYT.js";import{b as ye,c as _e,d as Ce}from"./chunk-YOJ4KGSB.js";import"./chunk-CO3X7TQN.js";import{a as xe}from"./chunk-VSFNMVXJ.js";import"./chunk-WQ6DP4JQ.js";import{Eb as Ee,Ob as w,a as qe,s as le,v as ie,wb as be,y as se}from"./chunk-YSQLW2JA.js";import{Ac as ve,pa as ce,qc as ue,vc as T,wc as he,xc as ge,yc as Te,zc as q}from"./chunk-NVJ2ZZFT.js";import{Aa as p,Ba as $,Dc as s,De as ne,E as x,He as m,Mc as F,Mg as me,Nc as Z,Ng as pe,Pd as ae,Qf as I,Rd as z,S as K,Sc as ee,Sd as A,Se as P,Tb as L,Te as g,Uc as S,Ue as k,Wb as y,Wc as _,Xc as te,Ye as U,Yg as R,_a as b,ab as d,ad as re,af as D,bb as f,bh as de,cd as oe,dd as u,ea as X,eh as fe,fb as N,g as $e,gb as E,ha as B,hd as C,ma as v,rb as Q,wa as J,ya as c}from"./chunk-SKPDQO4E.js";var we=`<div class="h-100">
  <side-navigation>
    <ng-template side-navigation-nav>
      <label class="report-form-label">{{'PACS.SHIFT_TEMPLATE_SEARCH' | translate}}</label>
      <armon-search-text-input [(ngModel)]="filter.name" [maxLength]="20" [minLength]="3"
        (ngModelChange)="filterChanged($event)" placeholder="COMMON.SEARCH"></armon-search-text-input>
    </ng-template>
    <ng-template side-navigation-content>
      <div class="row" *ngIf="permissionAttendancePlanWrite">
        <div class="col-12 my-3">
          <button class="btn btn-sm btn-primary" (click)="onAddShiftTemplateClicked()">{{'PACS.SHIFT_TEMPLATE_ADD' |
            translate}}</button>
        </div>
      </div>
      <ng-container *ngIf="templates && templates.length>0">
        <div class="row" [@listAnimation]="templates.length">
          <!-- List of user groups -->
          <div class="col-xxxl-4 col-lg-6 col-md-12" *ngFor="let template of templates">
            <armon-pacs-shift-template-card [template]="template" (templateDeleted)="onTemplateDeleted($event)"
              (templateUpdated)="onTemplateUpdated($event)">
            </armon-pacs-shift-template-card>
          </div>
        </div>
      </ng-container>
      <div class="row py-5" *ngIf="templates && templates.length==0">
        <div class="col-12">
          <nz-empty [nzNotFoundContent]="contentTpl" [nzNotFoundImage]="'./assets/images/empty/empty_list.png'">
            <ng-template #contentTpl>
              <span>{{'COMMON.NO_DATA'|translate}}</span>
            </ng-template>
          </nz-empty>
        </div>
      </div>
      <div class="row my-2" *ngIf="templates && templates.length>0">
        <div class="col-12">
          <armon-pagination [paginationResponse]="paginationResponse" (pageChanged)="pageChanged($event)">
          </armon-pagination>
        </div>
      </div>
    </ng-template>
  </side-navigation>
</div>`;var Oe="";var W=class extends te{http;sessionService;configurationService;interactionService;constructor(e,t,r,o){super(e,t,r,o),this.http=e,this.sessionService=t,this.configurationService=r,this.interactionService=o}getTemplates(e){return this.requestPost(`/${this.sessionService.currentOrganizationId}/workplan/import/list`,e,"ShiftTemplateListResponse",S.Pacs,_.Pacs)}getTemplateDetail(e){return this.requestGet(`/${this.sessionService.currentOrganizationId}/workplan/import/${e}`,"ShiftTemplateListDetail",S.Pacs,_.Pacs)}upsertTemplate(e){return this.requestPost(`/${this.sessionService.currentOrganizationId}/workplan/import/upsert`,e,null,S.Pacs,_.Pacs)}deleteTemplate(e){return this.requestDelete(`/${this.sessionService.currentOrganizationId}/workplan/import/${e}`,null,S.Pacs,_.Pacs)}downloadTemplateExcel(e){return this.requestPostFileResponse(`/${this.sessionService.currentOrganizationId}/workplan/import/get-excel`,e,S.Pacs,_.Pacs)}uploadTemplateExcel(e,t){return this.requestPostFormData(`/${this.sessionService.currentOrganizationId}/workplan/import/${e}/upload-excel`,t,null,S.Pacs)}};var Ke=function(n,e,t,r){var o=arguments.length,a=o<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,e,t,r);else for(var i=n.length-1;i>=0;i--)(l=n[i])&&(a=(o<3?l(a):o>3?l(e,t,a):l(e,t))||a);return o>3&&a&&Object.defineProperty(e,t,a),a},h=class extends ee{http;configurationService;interactionService;sessionService;api;constructor(e,t,r,o){super(r,o),this.http=e,this.configurationService=t,this.interactionService=r,this.sessionService=o,this.api=new W(this.http,this.sessionService,this.configurationService,this.interactionService)}getTemplates(e){return this.api.getTemplates(e).pipe(x(t=>this.handleError(t,[])))}getTemplateDetail(e){return this.api.getTemplateDetail(e).pipe(x(t=>this.handleError(t,[])))}upsertTemplate(e){return this.api.upsertTemplate(e).pipe(x(t=>this.handleError(t,[])))}deleteTemplate(e){return this.api.deleteTemplate(e).pipe(x(t=>this.handleError(t,[])))}downloadTemplateExcel(e){return this.api.downloadTemplateExcel(e).pipe(x(t=>this.handleError(t,[])))}uploadTemplateExcel(e,t){return this.api.uploadTemplateExcel(e,t).pipe(x(r=>this.handleError(r,[{code:F.Conflict,message:null}])))}static ctorParameters=()=>[{type:Q},{type:re},{type:I},{type:ae}]};h=Ke([X({providedIn:"root"})],h);var Le=`<ng-container>
  <div class="modal-header">
    <span class="text-lg"
      *ngIf="!disabled">{{(isEditMode?'PACS.SHIFT_TEMPLATE_EDIT':'PACS.SHIFT_TEMPLATE_ADD')|translate}}</span>
    <span class="text-lg" *ngIf="disabled">{{'PACS.SHIFT_TEMPLATE_DETAIL'|translate}}</span>
  </div>
  <div class="modal-body mh-vh-60">
    <ng-container *ngIf="visibleComponent">
      <div class="row my-2" *ngIf="disabled">
        <div class="col-12">
          <div class="alert alert-warning" role="alert">
            {{'PACS.SHIFT_TEMPLATE_DISABLED_INFO'|translate}}
          </div>
        </div>
      </div>
      <form [formGroup]="form">
        <div class="row">
          <div class="col-12 col-md-6">
            <div class="form-group form-layout">
              <label for="name-input">{{'PACS.SHIFT_TEMPLATE_NAME' | translate}}</label>
              <input type="text" id="name-input" formControlName="name" maxlength="255"
                class="form-control form-control-sm"
                [ngClass]="{'is-invalid': form.get('name').touched && form.get('name').invalid}">
              <ng-template
                *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('name')}">
              </ng-template>
            </div>
          </div>
          <div class="col-12 col-md-6">
            <div class="form-group form-layout">
              <label for="name-input">{{'PACS.SHIFT_TEMPLATE_DEFAULT_WORKPLAN' | translate}}<cds-icon shape="help" solid
                  class="cds-icon-16 text-secondary cursor-pointer ms-2" nz-tooltip
                  nzTooltipTitle="{{'PACS.SHIFT_TEMPLATE_DEFAULT_WORKPLAN_INFO'|translate}}"></cds-icon></label>
              <armon-select-search query="workplan" [allowMulti]="false" formControlName="defaultWorkPlanId"
                [invalid]="form.get('defaultWorkPlanId').touched && form.get('defaultWorkPlanId').invalid"
                [allowClear]="true">
              </armon-select-search>
              <ng-template
                *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('defaultWorkPlanId')}">
              </ng-template>
            </div>
          </div>
        </div>

        <!-- Add Workplan Button -->
        <div class="row" *ngIf="disabled==false">
          <div class="col-12 col-md-6">
            <div class="d-flex w-50 mb-3">
              <button class="btn btn-sm btn-primary" (click)="onAddWorkPlanImportRuleClicked($event)">
                <cds-icon shape="plus-circle" solid
                  class="cds-icon-18 me-2"></cds-icon>{{'PACS.SHIFT_TEMPLATE_ADD_WORKPLAN'|translate}}
              </button>
            </div>
          </div>
          <ng-container *ngIf="form.get('workPlanImportRules').errors?.required">
            <div class="col-12">
              <div class="border border-1 border-danger-subtle rounded-2 p-3 mb-3">
                <span class="text-sm text-danger">{{'PACS.SHIFT_TEMPLATE_ADD_WORKPLAN_REQUIRED'|translate}}</span>
              </div>
            </div>
          </ng-container>
        </div>

        <div class="d-flex flex-column py-3 pe-2 row-gap-2 modal-scroll-area-60 overflow-y-auto">
          <ng-container
            *ngFor="let formWorkPlanImportRulesControl of formWorkPlanImportRules.controls; let index = index;">
            <div
              class="w-100 border border-1 border-primary-subtle rounded-2 p-3 mb-3 position-relative d-flex flex-column row-gap-2"
              [formGroup]="formWorkPlanImportRulesControl">
              <div class="row">
                <div class="col-12 col-md-6">
                  <div class="form-group form-layout">
                    <label>{{'PACS.WORKPLAN' | translate}}</label>
                    <armon-select-search query="workplan" [allowMulti]="false"
                      [invalid]="formWorkPlanImportRulesControl.get('workPlanId').touched && formWorkPlanImportRulesControl.get('workPlanId').invalid"
                      [formControl]="formWorkPlanImportRulesControl.get('workPlanId')" [allowClear]="false">
                    </armon-select-search>
                    <ng-template
                      *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: formWorkPlanImportRulesControl, control:formWorkPlanImportRulesControl.get('workPlanId')}">
                    </ng-template>
                  </div>
                </div>
                <div class="col-12 col-md-6">
                  <div class="form-group form-layout">
                    <label>{{'PACS.SHIFT_TEMPLATE_KEYWORD' | translate}}<cds-icon shape="help" solid
                        class="cds-icon-16 text-secondary cursor-pointer ms-2" nz-tooltip
                        nzTooltipTitle="{{'PACS.SHIFT_TEMPLATE_KEYWORD_INFO'|translate}}"></cds-icon></label>
                    <input type="text" [formControl]="formWorkPlanImportRulesControl.get('keyword')" maxlength="127"
                      class="form-control form-control-sm"
                      [ngClass]="{'is-invalid': formWorkPlanImportRulesControl.get('keyword').touched && formWorkPlanImportRulesControl.get('keyword').invalid}">
                    <ng-template
                      *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: formWorkPlanImportRulesControl, control:formWorkPlanImportRulesControl.get('keyword')}">
                    </ng-template>
                  </div>
                </div>
              </div>
              <div class="row">
                <div class="col-12">
                  <div class="form-group form-layout">
                    <label class="w-100">{{'PACS.SHIFT_TEMPLATE_RANGE' | translate}}</label>
                    <armon-range-three-days-slider-input
                      [formControl]="formWorkPlanImportRulesControl.get('membershipRange')"></armon-range-three-days-slider-input>
                    <ng-template
                      *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: formWorkPlanImportRulesControl, control:formWorkPlanImportRulesControl.get('membershipRange')}">
                    </ng-template>
                  </div>
                </div>
              </div>
              <!-- absolute position -->
              <div class="position-absolute w-auto bg-white" style="top: -10px; right: 10px;" *ngIf="disabled==false">
                <cds-icon class="text-danger cursor-pointer" shape="times-circle" style="width: 20px; height: 20px;"
                  solid (click)="onRemoveWorkPlanImportRuleClicked($event, index)" nz-tooltip
                  nzTooltipTitle="{{'BUTTON.REMOVE'|translate}}"></cds-icon>
              </div>
            </div>
          </ng-container>
        </div>
      </form>
    </ng-container>
  </div>

  <div class="modal-footer">
    <button class="btn btn-outline-primary"
      (click)="onCancelClicked($event)">{{(disabled?'BUTTON.CLOSE':'BUTTON.CANCEL') | translate}}</button>
    <button class="btn btn-primary" *ngIf="disabled==false" [disabled]="form?.invalid"
      (click)="onSaveClicked($event)">{{'BUTTON.SAVE' |
      translate}}</button>
  </div>
</ng-container>


<!-- FORM FIELD VALIDATION -->
<ng-template #controlValidationTemplate let-form let-control="control">
  <ng-container *ngIf="control.errors">
    <div class="invalid-feedback d-flex flex-column" style="display: initial;">
      <span *ngIf="control.errors.required">{{'VALIDATION.REQUIRED'|translate}}</span>
      <span *ngIf="control.errors.numeric">{{'VALIDATION.POSITIVE_NUMBER'|translate}}</span>
      <span *ngIf="control.errors.max">{{'VALIDATION.MAX_VALUE'|translate:control.errors.max}}</span>
      <span *ngIf="control.errors.maxlength">{{'VALIDATION.MAX_LENGTH'|translate: {
        max:control.errors.maxlength.requiredLength} }}</span>
      <span *ngIf="control.errors.min">{{'VALIDATION.MIN_VALUE'|translate:control.errors.min}}</span>
      <span *ngIf="control.errors.minlength">{{'VALIDATION.MIN_LENGTH'|translate: {
        min:control.errors.minlength.requiredLength} }}</span>
      <span
        *ngIf="control.errors.sameWorkplanKeywordIndex">{{'PACS.SHIFT_TEMPLATE_VALIDATION_WORKPLAN_KEYWORD'|translate}}</span>
      <span *ngIf="control.errors.sameWorkplanIndex">{{'PACS.SHIFT_TEMPLATE_VALIDATION_WORKPLAN'|translate}}</span>
    </div>
  </ng-container>
</ng-template>`;var Me=`.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 Ne=`<div class="d-flex flex-column border border-1 border-light-subtle rounded-1 pt-3">\r
    <div class="d-flex justify-content-start align-items-baseline px-3">\r
        <span class="text-sm fw-medium color-primary">{{dateService.threeDaysFormatTime(selectedRange[0])}} -\r
            {{dateService.threeDaysFormatTime(selectedRange[1])}}</span>\r
    </div>\r
    <div class="d-flex flex-grow-1 justify-content-center px-3">\r
        <div class="w-100">\r
            <nz-slider nzRange [(ngModel)]="selectedRange" (ngModelChange)="rangeChanged($event)"\r
                [nzMax]="DATE_SERVICE_THREEDAYS_DAYCOUNT * 3" [nzMarks]="membershipRangeMarks" [nzDisabled]="isDisabled"\r
                [nzTipFormatter]="membershipRangeTooltipFormatter"></nz-slider>\r
        </div>\r
    </div>\r
</div>`;var Fe=`.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 et=function(n,e,t,r){var o=arguments.length,a=o<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,e,t,r);else for(var i=n.length-1;i>=0;i--)(l=n[i])&&(a=(o<3?l(a):o>3?l(e,t,a):l(e,t))||a);return o>3&&a&&Object.defineProperty(e,t,a),a},tt={provide:ne,useExisting:K(()=>M),multi:!0},M=class{dateService;allowMulti=!1;allowClear=!1;onChange;selectedValue;selectedRange=[288,500];isDisabled=!1;DATE_SERVICE_THREEDAYS_DAYCOUNT=G;membershipRangeMarks;markStep=36;constructor(e){this.dateService=e}writeValue(e){e&&(this.selectedValue=e,this.selectedRange=this.getRangePoints(this.selectedValue))}registerOnChange(e){this.onChange=e}registerOnTouched(e){}setDisabledState(e){this.isDisabled=e}ngOnInit(){this.membershipRangeMarks=this.prepareMarks(0,G*3)}prepareMarks(e,t){let r={};for(;e<=t;){let o=this.dateService.threeDaysFormatHour(e);o=="00:00"?r[e]={style:{color:"#666"},label:"<strong>00:00</strong>"}:r[e]=o,e+=this.markStep}return r}onChanged(e){this.onChange(this.selectedValue)}rangeChanged(e){this.onChange(this.getRangeData(this.selectedRange))}membershipRangeTooltipFormatter=e=>this.dateService.threeDaysFormatTime(e);getRangeData(e){return ue.getCopyModel({from:this.dateService.threeDaysGetRangePointData(e[0]),to:this.dateService.threeDaysGetRangePointData(e[1])})}getRangePoints(e){return[this.dateService.threeDaysGetRangePoint(e.from),this.dateService.threeDaysGetRangePoint(e.to)]}static ctorParameters=()=>[{type:ke}];static propDecorators={allowMulti:[{type:p}],allowClear:[{type:p}]}};M=et([c({selector:"armon-range-three-days-slider-input",providers:[tt],template:Ne,standalone:!0,imports:[b,f,E,d,g,R,Re,u],styles:[Fe]})],M);var rt=function(n,e,t,r){var o=arguments.length,a=o<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,e,t,r);else for(var i=n.length-1;i>=0;i--)(l=n[i])&&(a=(o<3?l(a):o>3?l(e,t,a):l(e,t))||a);return o>3&&a&&Object.defineProperty(e,t,a),a},O=class extends A{shiftTemplateService;authService;formBuilder;templateId;form;isEditMode=!1;visibleComponent=!1;permissionAttendancePlanWrite;disabled=!1;templateDetail;constructor(e,t,r){super(),this.shiftTemplateService=e,this.authService=t,this.formBuilder=r}onModalInitialized(){super.onModalInitialized(),this.permissionAttendancePlanWrite=this.authService.checkPermission(C.ATTENDANCEPLAN.getWrite()),this.permissionAttendancePlanWrite==!1&&(this.disabled=!0),this.getTemplateDetail()}getTemplateDetail(){y(this.templateId)?(this.isEditMode=!1,this.templateDetail=ge.getEmptyModel(),this.prepareUserInterface()):(this.isEditMode=!0,this.shiftTemplateService.getTemplateDetail(this.templateId).subscribe(e=>{this.templateDetail=e,this.prepareUserInterface()}))}prepareUserInterface(){this.initializeForms(),this.visibleComponent=!0}onSaveClicked(e){this.disabled||this.upsertShiftTemplate()}ruleIndexValue(e){return(e.get("workPlanId")?.value?e.get("workPlanId").value.toString():"").concat(e.get("keyword")?.value?e.get("keyword").value.toString():"")}getUniqueDuplicates(e){let t=r=>r.filter((o,a)=>r.indexOf(o)!==a);return[...new Set(t(e))]}formValidator(){return e=>{let t=[];this.formWorkPlanImportRules.controls.forEach(o=>{t.push(this.ruleIndexValue(o))});let r=this.getUniqueDuplicates(t);this.formWorkPlanImportRules.controls.forEach((o,a)=>{r.includes(this.ruleIndexValue(o))?o.get("keyword")?.value&&!L(o.get("keyword").value.toString())?(o.get("workPlanId").setErrors({sameWorkplanKeywordIndex:!0}),o.get("keyword").setErrors({sameWorkplanKeywordIndex:!0})):o.get("workPlanId").setErrors({sameWorkplanIndex:!0}):(o.get("workPlanId").hasError("sameWorkplanKeywordIndex")&&delete o.get("workPlanId").errors.sameWorkplanKeywordIndex,o.get("workPlanId").hasError("sameWorkplanIndex")&&delete o.get("workPlanId").errors.sameWorkplanIndex,o.get("keyword").hasError("sameWorkplanKeywordIndex")&&delete o.get("keyword").errors.sameWorkplanKeywordIndex)})}}initializeForms(){this.form=this.formBuilder.group({name:[{value:this.templateDetail.name?this.templateDetail.name:null,disabled:this.disabled},[m.required]],defaultWorkPlanId:[{value:this.templateDetail.defaultWorkPlanId?this.templateDetail.defaultWorkPlanId:null,disabled:this.disabled},[]],workPlanImportRules:this.formBuilder.array([])}),this.formWorkPlanImportRules.setValidators([m.required,m.minLength(1)]),!y(this.templateDetail.workPlanImportRules)&&!L(this.templateDetail.workPlanImportRules)?this.templateDetail.workPlanImportRules.forEach(e=>{this.formWorkPlanImportRules.push(this.createWorkPlanImportRulesForm(e))}):this.formWorkPlanImportRules.push(this.createWorkPlanImportRulesForm()),this.formWorkPlanImportRules.valueChanges.subscribe(()=>{this.formWorkPlanImportRules.controls.forEach((e,t)=>{e.get("workPlanId").updateValueAndValidity({emitEvent:!1}),e.get("keyword").updateValueAndValidity({emitEvent:!1})})}),this.form.setValidators(this.formValidator()),this.form.updateValueAndValidity()}createWorkPlanImportRulesForm(e=null){return y(e)&&(e=Te.getEmptyModel()),this.formBuilder.group({workPlanId:[{value:e.workPlanId?e.workPlanId:null,disabled:this.disabled},[m.required]],keyword:[{value:e.keyword?e.keyword:null,disabled:this.disabled},[]],membershipRange:[{value:e.membershipRange?e.membershipRange:{from:{days:0,hours:0,minutes:0},to:{days:1,hours:0,minutes:0}},disabled:this.disabled},[m.required]]})}onAddWorkPlanImportRuleClicked(e){this.formWorkPlanImportRules.push(this.createWorkPlanImportRulesForm()),this.form.updateValueAndValidity()}onRemoveWorkPlanImportRuleClicked(e,t){this.formWorkPlanImportRules.removeAt(t),this.form.updateValueAndValidity()}get formWorkPlanImportRules(){return this.form.get("workPlanImportRules")}upsertShiftTemplate(){let e=q.getEmptyModel();e=Object.assign(e,this.form.value),this.isEditMode&&(e.id=this.templateDetail.id),this.shiftTemplateService.upsertTemplate(q.getRequestModel(e)).subscribe(t=>{this.closeModal(t)})}static ctorParameters=()=>[{type:h},{type:w},{type:P}];static propDecorators={templateId:[{type:p}]}};O=rt([c({selector:"armon-pacs-shift-template-modal",template:Le,standalone:!0,schemas:[v],imports:[f,d,g,k,R,b,E,u,be,M],styles:[Me]})],O);var ze=`<div class="card mb-3">

  <div class="card-body p-4 mhs-15">
    <div class="d-flex">
      <div class="card-icon me-3">
        <cds-icon shape="form" size="lg" solid></cds-icon>
      </div>
      <div class="d-flex flex-column flex-grow-1">
        <span class="text-lg fw-medium mb-2">{{template.name}}</span>
        <span class="text-sm fw-normal">{{template.workPlanImportRuleCount}}
          {{'PACS.WORKPLAN' | translate}}</span>
        <span class="text-sm fw-normal" *ngIf="template.defaultWorkPlanName">
          {{template.defaultWorkPlanName}}<span
            class="text-italic color-gray-dark">&nbsp;({{'PACS.SHIFT_TEMPLATE_DEFAULT_WORKPLAN' |
            translate}})</span></span>
        <div class="d-flex align-items-center my-3 column-gap-3">
          <button class="btn btn-outline-primary btn-sm" (click)="onDownloadTemplateClicked($event)"><cds-icon
              shape="download" class="me-2"></cds-icon>{{'BUTTON.DOWNLOAD'|translate}}</button>
          <button class="btn btn-outline-success btn-sm" (click)="onUploadTemplateClicked($event)"><cds-icon
              shape="upload" class="me-2"></cds-icon>{{'BUTTON.UPLOAD'|translate}}</button>
        </div>
      </div>
    </div>
  </div>

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

    <button class="btn btn-sm btn-link" *ngFor="let button of visibleButtons"
      (click)="onFooterButtonClicked($event, button.event)">{{button.text | translate :
      languageService.userTranslate}}</button>
    <button nz-dropdown [nzDropdownMenu]="menuSub" class="btn btn-link btn-sm me-2" *ngIf="hiddenButtons.length > 0"
      [nzClickHide]="true">
      <cds-icon shape="ellipsis-horizontal"></cds-icon>
    </button>
    <nz-dropdown-menu #menuSub="nzDropdownMenu">
      <ul nz-menu>
        <li nz-menu-item *ngFor="let button of hiddenButtons" (click)="onFooterButtonClicked($event, button.event)">
          {{button.text | translate : languageService.userTranslate}}</li>
      </ul>
    </nz-dropdown-menu>
  </div>
</div>`;var Ue=`.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}.card-icon{width:42px;min-width:42px;height:42px;min-height:42px;display:-webkit-box;display:-moz-box;display:-webkit-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-orient:vertical;-moz-box-orient:vertical;-webkit-flex-direction:column;-moz-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center;-webkit-box-align:center;-ms-flex-align:center;-webkit-align-items:center;-moz-align-items:center;align-items:center;-webkit-border-radius:.375rem;-moz-border-radius:.375rem;border-radius:.375rem;color:#fff;background-color:#0a2a5a}
`;var We=`<ng-container>
  <div class="modal-header">
    <span class="text-lg">{{'PACS.SHIFT_TEMPLATE_DOWNLOAD'|translate}}</span>
  </div>
  <div class="modal-body">
    <ng-container *ngIf="visibleComponent">
      <form [formGroup]="form">
        <div class="row">
          <div class="col-12 mb-3">
            <span class="text-md">{{templateName}}</span>
          </div>
          <div class="col-12">
            <div class="form-group form-layout">
              <label>{{'COMMON.USER_FILTER' | translate :
                languageService.userTranslate}}</label>
              <armon-user-filter-control [invalid]="form.get('userFilter').invalid || form.get('userFilter').touched"
                [formControl]="form.get('userFilter')"></armon-user-filter-control>
              <ng-template
                *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('userFilter')}">
              </ng-template>
            </div>
          </div>
          <div class="col-12 mt-3 mb-2">
            <div class="form-check form-check-inline">
              <input class="form-check-input" type="radio" [formControl]="form.get('type')" [value]="1"
                id="typeDateRange">
              <label class="form-check-label d-flex flex-column" for="typeDateRange">
                <span>{{'PACS.SHIFT_TEMPLATE_TYPE_DATERANGE'|translate}}</span>
                <span class="text-sm text-italic">{{'PACS.SHIFT_TEMPLATE_TYPE_DATERANGE_INFO'|translate}}</span>
              </label>
            </div>
          </div>
          <div class="col-12 col-lg-6 ps-5">
            <div class="form-group form-layout">
              <label>{{'PACS.SHIFT_TEMPLATE_RANGE_DATE' | translate}}</label>
              <input placeholder="{{'DATEPICKER.LABEL_CUSTOM'|translate}}" type="text" readonly owlinput
                [ngClass]="{'is-invalid': form.get('range').touched && form.get('range').invalid}"
                [disabled]="form.get('range').disabled" class="form-control form-control-sm" [selectMode]="'range'"
                [formControl]="form.get('range')" [owlDateTimeTrigger]="dtRange1" [owlDateTime]="dtRange1">
              <owl-date-time [firstDayOfWeek]="1" #dtRange1 [pickerType]="'calendar'"></owl-date-time>
              <ng-template
                *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('range')}">
              </ng-template>
            </div>
          </div>
          <div class="col-12 mt-3 mb-2">
            <div class="form-check form-check-inline">
              <input class="form-check-input" type="radio" [formControl]="form.get('type')" [value]="2"
                id="typeCyclical">
              <label class="form-check-label d-flex flex-column" for="typeCyclical">
                <span>{{'PACS.SHIFT_TEMPLATE_TYPE_CYCLICAL'|translate}}</span>
                <span class="text-sm text-italic">{{'PACS.SHIFT_TEMPLATE_TYPE_CYCLICAL_INFO'|translate}}</span>
              </label>
            </div>
          </div>
          <div class="col-12 col-lg-6 ps-5">
            <div class="form-group form-layout">
              <label>{{'PACS.SHIFT_TEMPLATE_NUMBER_OF_DAYS'|translate}}</label>
              <nz-select class="w-100" nzSize="small" nzPlaceHolder="{{'COMMON.SELECT_ONE'|translate}}"
                [formControl]="form.get('days')" [ngClass]="{'nz-invalid': form.get('type').invalid}">
                <nz-option *ngFor="let numberOfDay of numberOfDays" [nzValue]="numberOfDay"
                  [nzLabel]="numberOfDay"></nz-option>
              </nz-select>
              <ng-template
                *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('days')}">
              </ng-template>
            </div>
          </div>
        </div>
      </form>
    </ng-container>
  </div>

  <div class="modal-footer">
    <button class="btn btn-outline-primary" (click)="onCancelClicked($event)">{{'BUTTON.CANCEL' | translate}}</button>
    <button class="btn btn-primary" [disabled]="!visibleComponent || form.invalid"
      (click)="onDownloadClicked($event)"><cds-icon shape="download"
        class="me-2"></cds-icon>{{'BUTTON.DOWNLOAD'|translate}}</button>
  </div>
</ng-container>

<!-- FORM FIELD VALIDATION -->
<ng-template #controlValidationTemplate let-form let-control="control">
  <ng-container *ngIf="control.errors">
    <div class="invalid-feedback d-flex flex-column" style="display: initial;">
      <span *ngIf="control.errors.required">{{'VALIDATION.REQUIRED'|translate}}</span>
      <span *ngIf="control.errors.numeric">{{'VALIDATION.POSITIVE_NUMBER'|translate}}</span>
      <span *ngIf="control.errors.max">{{'VALIDATION.MAX_VALUE'|translate:control.errors.max}}</span>
      <span *ngIf="control.errors.maxlength">{{'VALIDATION.MAX_LENGTH'|translate: {
        max:control.errors.maxlength.requiredLength} }}</span>
      <span *ngIf="control.errors.min">{{'VALIDATION.MIN_VALUE'|translate:control.errors.min}}</span>
      <span *ngIf="control.errors.minlength">{{'VALIDATION.MIN_LENGTH'|translate: {
        min:control.errors.minlength.requiredLength} }}</span>
    </div>
  </ng-container>
</ng-template>`;var Ve=`.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 Y=$e(qe());var it=function(n,e,t,r){var o=arguments.length,a=o<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,e,t,r);else for(var i=n.length-1;i>=0;i--)(l=n[i])&&(a=(o<3?l(a):o>3?l(e,t,a):l(e,t))||a);return o>3&&a&&Object.defineProperty(e,t,a),a},V=class extends A{shiftTemplateService;languageService;formBuilder;interactionService;translate;templateId;templateName;form;visibleComponent=!1;numberOfDays=Array.from({length:60},(e,t)=>t+1);constructor(e,t,r,o,a){super(),this.shiftTemplateService=e,this.languageService=t,this.formBuilder=r,this.interactionService=o,this.translate=a}onModalInitialized(){super.onModalInitialized(),this.initializeForms(),this.visibleComponent=!0,console.log(this.numberOfDays)}onDownloadClicked(e){let t=ve.getEmptyModel();if(t.templateId=this.templateId,t.userFilter=this.form.get("userFilter").value,t.type=this.form.get("type").value,t.type==T.DateRange){let r=s.fromJSDate(this.form.get("range").value[0]),o=s.fromJSDate(this.form.get("range").value[1]);t.dateRange={startDateTime:r.toFormat("yyyy-MM-dd"),endDateTime:o.toFormat("yyyy-MM-dd")}}else t.days=this.form.get("days").value;this.shiftTemplateService.downloadTemplateExcel(t).subscribe(r=>{this.translate.get(["PAGES.PACS_SHIFT_TEMPLATE","USER_PERMISSION_UNIT_TYPE_DAY"]).subscribe(o=>{t.type==T.DateRange?Y.default.saveAs(r,o["PAGES.PACS_SHIFT_TEMPLATE"]+"_"+this.templateName+"_"+s.fromISO(t.dateRange.startDateTime).toLocaleString(s.DATE_MED)+"_"+s.fromISO(t.dateRange.endDateTime).toLocaleString(s.DATE_MED)+".xlsx"):Y.default.saveAs(r,o["PAGES.PACS_SHIFT_TEMPLATE"]+"_"+this.templateName+"_"+t.days+"_"+o.USER_PERMISSION_UNIT_TYPE_DAY+".xlsx"),this.interactionService.showMessage("PACS.SHIFT_TEMPLATE_DOWNLOADED",null,Z.Success),this.closeModal(this.templateId)})})}initializeForms(){this.form=this.formBuilder.group({userFilter:[{value:ce.getEmptyModel(),disabled:!1},[m.required]],type:[{value:T.DateRange,disabled:!1},[m.required]],range:[{value:[s.local().startOf("day").toJSDate(),s.local().plus({days:30}).endOf("day").toJSDate()],disabled:!1},[m.required]],days:[{value:7,disabled:!0},[m.required]]}),this.form.get("type").valueChanges.subscribe(e=>{e==T.DateRange?(this.form.controls.range.enable(),this.form.controls.days.disable()):(this.form.controls.range.disable(),this.form.controls.days.enable())})}static ctorParameters=()=>[{type:h},{type:D},{type:P},{type:I},{type:oe}];static propDecorators={templateId:[{type:p}],templateName:[{type:p}]}};V=it([c({selector:"armon-pacs-shift-template-download-modal",template:We,standalone:!0,schemas:[v],imports:[f,g,k,R,fe,b,E,d,u,U,Ee],styles:[Ve]})],V);var je=`<ng-container>
  <div class="modal-header">
    <span class="text-lg">{{'PACS.SHIFT_TEMPLATE_UPLOAD'|translate}}</span>
  </div>
  <div class="modal-body">
    <div class="row">
      <div class="col-12 mb-3">
        <span class="text-md">{{templateName}}</span>
      </div>
    </div>

    <form [formGroup]="form">
      <div class="row">
        <div class="col-12 mt-3 mb-2">
          <div class="form-check form-check-inline">
            <input class="form-check-input" type="radio" [formControl]="form.get('type')" [value]="1"
              id="typeDateRange">
            <label class="form-check-label d-flex flex-column" for="typeDateRange">
              <span>{{'PACS.SHIFT_TEMPLATE_TYPE_DATERANGE'|translate}}</span>
            </label>
          </div>
        </div>
        <div class="col-12 mt-3 mb-2">
          <div class="form-check form-check-inline">
            <input class="form-check-input" type="radio" [formControl]="form.get('type')" [value]="2" id="typeCyclical">
            <label class="form-check-label d-flex flex-column" for="typeCyclical">
              <span>{{'PACS.SHIFT_TEMPLATE_TYPE_CYCLICAL'|translate}}</span>
              <span class="text-sm text-italic">{{'PACS.SHIFT_TEMPLATE_TYPE_CYCLICAL_INFO_UPLOAD'|translate}}</span>
            </label>
          </div>
        </div>
        <div class="col-12 col-lg-6 ps-5 mb-5">
          <div class="form-group form-layout">
            <label>{{'PACS.SHIFT_TEMPLATE_RANGE_DATE' | translate}}</label>
            <input placeholder="{{'DATEPICKER.LABEL_CUSTOM'|translate}}" type="text" readonly owlinput
              [ngClass]="{'is-invalid': form.get('range').touched && form.get('range').invalid}"
              [disabled]="form.get('range').disabled" class="form-control form-control-sm" [selectMode]="'range'"
              [formControl]="form.get('range')" [owlDateTimeTrigger]="dtRange1" [owlDateTime]="dtRange1">
            <owl-date-time [firstDayOfWeek]="1" #dtRange1 [pickerType]="'calendar'"></owl-date-time>
            <ng-template
              *ngTemplateOutlet="controlValidationTemplate; context: {$implicit: form, control:form.get('range')}">
            </ng-template>
          </div>
        </div>
      </div>
    </form>

    <div class="row">
      <div class=" col-12">
        <div class="d-flex flex-column justify-content-end py-4 px-3 rounded-2 file-drop-area" fileDragDrop
          [ngStyle]="{'background-color':'red'}" [attr.selected]="selectedFile!=null" (files)="filesDropped($event)">
          <input #fileInput type="file" style="display:none" (change)="onChangedFile($event)" accept=".xlsx" />
          <div class="d-flex flex-column align-items-center row-gap-4">
            <cds-icon shape="filetype-xlsx" class="cds-icon-42 color-gray-darkest"></cds-icon>
            <span class="text-sm " *ngIf="selectedFile">{{selectedFile.name}}</span>
            <span class="text-sm text-italic"
              *ngIf="!selectedFile">{{'COMMON.SELECT_OR_DRAGDROP_FILE'|translate}}</span>
          </div>
        </div>
      </div>
      <div class="col-12 mt-4">
        <div class="d-flex justify-content-center align-items-center">
          <button class="btn btn-sm" (click)="onSelectFile($event)"
            [ngClass]="{'btn-primary':!selectedFile, 'btn-outline-primary':selectedFile}"><cds-icon shape="folder-open"
              class="me-2"></cds-icon>{{'PACS.SHIFT_TEMPLATE_UPLOAD_SELECT'|translate}}</button>
        </div>
      </div>
      <div class="col-12 mt-4" *ngIf="uploadError">
        <div class="d-flex flex-column row-gap-1 p-3 rounded-2 bg-danger-subtle"
          style="max-height: 20vh; overflow-y: auto;">
          <span class="text-sm fw-medium text-danger">{{'PACS.SHIFT_TEMPLATE_ERROR_UPLOAD'|translate}}</span>
          <span class="text-sm my-2 text-italic" *ngIf=" uploadError.message">{{uploadError.message}}</span>
          <ng-container *ngIf="uploadError.errorCells && uploadError.errorCells.length>0">
            <span class="text-sm mt-2 text-italic">{{'PACS.SHIFT_TEMPLATE_ERROR_WORKPLAN_CELL'|translate}}</span>
            <span class="text-sm ms-3" *ngFor="let errorCell of uploadError.errorCells">{{errorCell}}</span>
          </ng-container>
          <ng-container *ngIf="uploadError.errorUsers && uploadError.errorUsers.length>0">
            <span class="text-sm mt-2 text-italic">{{'PACS.SHIFT_TEMPLATE_ERROR_USER_CELL'|translate}}</span>
            <span class="text-sm ms-3" *ngFor="let errorUser of uploadError.errorUsers">{{errorUser}}</span>
          </ng-container>
          <ng-container *ngIf="uploadError.errorDates && uploadError.errorDates.length>0">
            <span class="text-sm mt-2 text-italic">{{'PACS.SHIFT_TEMPLATE_ERROR_DATE_CELL'|translate}}</span>
            <span class="text-sm ms-3" *ngFor="let errorDate of uploadError.errorDates">{{errorDate}}</span>
          </ng-container>
        </div>
      </div>
    </div>
  </div>

  <div class="modal-footer">
    <button class="btn btn-outline-primary" (click)="onCancelClicked($event)">{{'BUTTON.CANCEL' | translate}}</button>
    <button class="btn btn-success" [disabled]="selectedFile == null || form.invalid"
      (click)="onUploadClicked($event)"><cds-icon shape="upload"
        class="me-2"></cds-icon>{{'BUTTON.UPLOAD'|translate}}</button>
  </div>
</ng-container>

<!-- FORM FIELD VALIDATION -->
<ng-template #controlValidationTemplate let-form let-control="control">
  <ng-container *ngIf="control.errors">
    <div class="invalid-feedback d-flex flex-column" style="display: initial;">
      <span *ngIf="control.errors.required">{{'VALIDATION.REQUIRED'|translate}}</span>
      <span *ngIf="control.errors.numeric">{{'VALIDATION.POSITIVE_NUMBER'|translate}}</span>
      <span *ngIf="control.errors.max">{{'VALIDATION.MAX_VALUE'|translate:control.errors.max}}</span>
      <span *ngIf="control.errors.maxlength">{{'VALIDATION.MAX_LENGTH'|translate: {
        max:control.errors.maxlength.requiredLength} }}</span>
      <span *ngIf="control.errors.min">{{'VALIDATION.MIN_VALUE'|translate:control.errors.min}}</span>
      <span *ngIf="control.errors.minlength">{{'VALIDATION.MIN_LENGTH'|translate: {
        min:control.errors.minlength.requiredLength} }}</span>
    </div>
  </ng-container>
</ng-template>`;var He=`.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 .file-drop-area{border-color:#3587b4!important;border-style:dashed!important;border-width:2px!important}:host .file-drop-area[selected=true]{border-color:#62a325!important}
`;var pt=function(n,e,t,r){var o=arguments.length,a=o<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,e,t,r);else for(var i=n.length-1;i>=0;i--)(l=n[i])&&(a=(o<3?l(a):o>3?l(e,t,a):l(e,t))||a);return o>3&&a&&Object.defineProperty(e,t,a),a},j=class extends A{shiftTemplateService;languageService;formBuilder;interactionService;templateId;templateName;fileInput;selectedFile=null;uploadError=void 0;form;constructor(e,t,r,o){super(),this.shiftTemplateService=e,this.languageService=t,this.formBuilder=r,this.interactionService=o}onModalInitialized(){super.onModalInitialized(),this.initializeForms()}onSelectFile(e){this.fileInput.nativeElement.click()}resetSelectedFile(){this.selectedFile=null,this.fileInput.nativeElement.value=""}checkSelection(e){if(this.uploadError=void 0,y(e)){this.resetSelectedFile();return}L(e)?this.resetSelectedFile():e.length>1?this.interactionService.showDialog("PACS.SHIFT_TEMPLATE_UPLOAD","COMMON.SELECT_ONLY_ONE_FILE",null,null,!1,"BUTTON.OK","",!1,()=>{this.resetSelectedFile()}):e[0].size/1e6>100?this.interactionService.showDialog("PACS.SHIFT_TEMPLATE_UPLOAD","COMMON.UPLOAD_FILE_EXCEED_LIMIT",null,{maxFileSize:100},!1,"BUTTON.OK","",!1,()=>{this.resetSelectedFile()}):e[0].type!==Ie.EXCEL_XLSX?this.interactionService.showDialog("BUTTON.UPLOAD_FILE","COMMON.UPLOAD_FILE_INVALID_MIME_TYPE",null,null,!1,"BUTTON.OK","",!1,()=>{this.resetSelectedFile()}):this.selectedFile=e[0]}onChangedFile(e){this.checkSelection(e.target.files)}filesDropped(e){this.checkSelection(e)}onUploadClicked(e){let t=new FormData;if(t.append("file",this.selectedFile),t.append("type",this.form.get("type").value),this.form.get("type").value==T.Cyclical){let r=s.fromJSDate(this.form.get("range").value[0]),o=s.fromJSDate(this.form.get("range").value[1]);t.append("startDateTime",r.toFormat("yyyy-MM-dd")),t.append("endDateTime",o.toFormat("yyyy-MM-dd"))}this.shiftTemplateService.uploadTemplateExcel(this.templateId,t).subscribe({next:r=>{this.interactionService.showDialog("PACS.SHIFT_TEMPLATE_UPLOAD","PACS.SHIFT_TEMPLATE_UPLOADED",null,null,!1,"BUTTON.OK","",!1,()=>{this.closeModal(this.templateId)})},error:r=>{r&&r.status&&r.status===F.Conflict&&(this.uploadError=r.error,this.resetSelectedFile())}})}initializeForms(){this.form=this.formBuilder.group({type:[{value:T.DateRange,disabled:!1},[m.required]],range:[{value:[s.local().startOf("day").toJSDate(),s.local().plus({days:7}).endOf("day").toJSDate()],disabled:!0},[m.required]]}),this.form.get("type").valueChanges.subscribe(e=>{e==T.DateRange?this.form.controls.range.disable():this.form.controls.range.enable()})}static ctorParameters=()=>[{type:h},{type:D},{type:P},{type:I}];static propDecorators={templateId:[{type:p}],templateName:[{type:p}],fileInput:[{type:J,args:["fileInput",{static:!0}]}]}};j=pt([c({selector:"armon-pacs-shift-template-upload-modal",template:je,standalone:!0,schemas:[v],imports:[f,d,E,g,k,b,N,u,U,De],styles:[He]})],j);var ct=function(n,e,t,r){var o=arguments.length,a=o<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,e,t,r);else for(var i=n.length-1;i>=0;i--)(l=n[i])&&(a=(o<3?l(a):o>3?l(e,t,a):l(e,t))||a);return o>3&&a&&Object.defineProperty(e,t,a),a},H=class extends Pe{interactionService;languageService;shiftTemplateService;modalService;authService;template;templateDeleted=new B;templateUpdated=new B;permissionAttendancePlanWrite;constructor(e,t,r,o,a){super(a),this.interactionService=e,this.languageService=t,this.shiftTemplateService=r,this.modalService=o,this.authService=a}ngOnInit(){this.permissionAttendancePlanWrite=this.authService.checkPermission(C.ATTENDANCEPLAN.getWrite()),this.initializeButtons()}initializeButtons(){this.addButton(this.permissionAttendancePlanWrite?"BUTTON.EDIT":"BUTTON.SHOW",this.onEditButtonClicked),this.permissionAttendancePlanWrite&&this.addButton("BUTTON.DELETE",this.onDeleteButtonClicked)}onEditButtonClicked(){this.modalService.open(O,{settings:{size:"xxl",scrollable:!0,centered:!1},props:{templateId:this.template.id}}).result.then(e=>{this.templateUpdated.emit(this.template.id)}).catch(e=>{})}onDeleteButtonClicked(){this.interactionService.showDialog(this.template.name,"PACS.SHIFT_TEMPLATE_APPROVE_FOR_DELETE",null,null,!0,"BUTTON.DELETE","",!0,()=>{this.shiftTemplateService.deleteTemplate(this.template.id).subscribe(()=>{this.templateDeleted.emit(this.template.id)})})}onDownloadTemplateClicked(e){this.modalService.open(V,{settings:{size:"lg",scrollable:!0,centered:!0},props:{templateId:this.template.id,templateName:this.template.name}}).result.then(t=>{}).catch(t=>{})}onUploadTemplateClicked(e){this.modalService.open(j,{settings:{size:"lg",scrollable:!0,centered:!0},props:{templateId:this.template.id,templateName:this.template.name}}).result.then(t=>{}).catch(t=>{})}static ctorParameters=()=>[{type:I},{type:D},{type:h},{type:z},{type:w}];static propDecorators={template:[{type:p}],templateDeleted:[{type:$}],templateUpdated:[{type:$}]}};H=ct([c({selector:"armon-pacs-shift-template-card",template:ze,schemas:[v],standalone:!0,imports:[N,f,d,se,ie,le,u],styles:[Ue]})],H);var dt=function(n,e,t,r){var o=arguments.length,a=o<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(n,e,t,r);else for(var i=n.length-1;i>=0;i--)(l=n[i])&&(a=(o<3?l(a):o>3?l(e,t,a):l(e,t))||a);return o>3&&a&&Object.defineProperty(e,t,a),a},Be=class{shiftTemplateService;authService;modalService;templates=[];permissionAttendancePlanWrite;filter;paginationResponse=new pe;paginationRequest=new me;constructor(e,t,r){this.shiftTemplateService=e,this.authService=t,this.modalService=r}ngOnInit(){this.permissionAttendancePlanWrite=this.authService.checkPermission(C.ATTENDANCEPLAN.getWrite()),this.filter=he.getEmptyModel(),this.getTemplates()}filterChanged(e){this.filter.pagination.skip=0,this.getTemplates()}onTemplateDeleted(e){this.filter.pagination.skip=0,this.getTemplates()}onTemplateUpdated(e){this.getTemplates()}getTemplates(){this.shiftTemplateService.getTemplates(this.filter).subscribe(e=>{this.templates=e.items,this.paginationResponse=e.pagination})}onAddShiftTemplateClicked(){this.permissionAttendancePlanWrite!=!1&&this.modalService.open(O,{settings:{size:"xxl",scrollable:!0,centered:!1},props:{templateId:null}}).result.then(e=>{this.getTemplates()}).catch(e=>{})}pageChanged(e){this.filter.pagination=e,this.getTemplates()}static ctorParameters=()=>[{type:h},{type:w},{type:z}]};Be=dt([c({selector:"armon-pacs-shift-template-list",template:we,animations:Se,standalone:!0,imports:[Ce,ye,Ae,g,_e,f,d,H,de,xe,u],styles:[Oe]})],Be);export{Be as PacsShiftTemplateListComponent};
