import{a as I,b as v}from"./chunk-SLQSOQUB.js";import{a as Z}from"./chunk-WFZJP5WR.js";import{$,Y as L,Z as B,_ as q,aa as G,ca as Y,j as U,oa as K}from"./chunk-YSQLW2JA.js";import{kc as z,lc as X}from"./chunk-NVJ2ZZFT.js";import{Aa as m,Bc as p,Dc as s,De as H,He as E,Id as c,Nc as F,Pd as N,Qb as M,Qd as j,Qf as V,S as O,Sd as w,Se as A,Te as S,Ue as J,Yg as C,_a as y,ab as f,af as W,bb as g,dd as h,eh as R,fb as k,gb as P,jb as b,mg as D,ya as u}from"./chunk-SKPDQO4E.js";var Q=`<ng-container>
    <div class="modal-header align-items-center">
        <div class="d-flex me-2 align-items-center">
            <cds-icon shape="calendar" size="lg" class="text-primary opacity-25"></cds-icon>
        </div>
        <div class="d-flex flex-column flex-grow-1">
            <span class="text-lg">{{'PACS.PLANNER_DAY' | translate}}</span>
            <span class="text-sm fw-medium">{{selectedDay | date:'fullDate'}}</span>
        </div>
        <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 ps-2 pe-3 py-0 overflow-hidden">
        <ng-container *ngIf="visibleSpinner">
            <div class="mh-vh-50 d-flex align-items-center justify-content-center">
                <div class="spinner-grow text-primary" role="status">
                    <span class="sr-only"></span>
                </div>
            </div>
        </ng-container>
        <ng-container *ngIf="!visibleSpinner">
            <div class="row">
                <div class="col-2 d-flex flex-column pb-3 ps-4 pe-3 bg-color-background">
                    <div class="row">
                        <div class="col-12 my-3">
                            <div class="d-flex">
                                <div class="flex-grow-1">
                                    <armon-captionlines *ngIf="userCaptions" [captionlines]="userCaptions"
                                        [className]="'bg-white'">
                                    </armon-captionlines>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-12">
                            <div class="d-flex flex-column flex-grow-1">
                                <label class="report-form-label">{{'PACS.PLANNER_SELECTED_WORKPLAN'
                                    |
                                    translate}}</label>
                                <nz-select class="w-100" [(ngModel)]="selectedWorkplan" nzSize="small"
                                    [nzCustomTemplate]="selectedWorkplanTemplate">
                                    <nz-option nzCustomContent *ngFor="let workplan of workplans" [nzValue]="workplan"
                                        [nzLabel]="workplan.name | translate"><span class="me-1"
                                            [ngStyle]="{'color': workplan.hexColor}">&#9646;</span>{{workplan.name}}</nz-option>
                                </nz-select>
                                <ng-template #selectedWorkplanTemplate let-selected>
                                    <span [ngStyle]="{'color': selected.nzValue.hexColor}"
                                        class="me-1">&#9646;</span>{{selected.nzValue.name}}
                                </ng-template>
                            </div>
                        </div>
                    </div>
                    <div class="row my-3 modal-scroll-area-60 overflow-y-scroll">
                        <div class="col-12 my-3 d-flex flex-column">
                            <ng-container *ngFor="let day of days; index as i">
                                <ng-container *ngIf="day.selectedTimes && day.selectedTimes.length>0">
                                    <div class="text-sm fw-normal color-gray-darkest mb-1 border-bottom fst-italic"
                                        [ngClass]="{'fw-medium': (day.isDataDay==true)}">
                                        {{day.date|date:'fullDate'}}</div>
                                    <div class="d-flex flex-column mb-3">
                                        <ng-container *ngFor="let selectedTime of day.selectedTimes">
                                            <span
                                                class="text-xs fw-medium color-gray-darkest cursor-pointer rounded-end-1 hover-summary-day"
                                                (click)="onEditRangeClicked(day, selectedTime)"><span class="me-1"
                                                    [ngStyle]="{'color': selectedTime.workplan.hexColor}">&#9646;</span>{{selectedTime.startTime|date:'HH:mm'}}&nbsp;-&nbsp;{{selectedTime.endTime|date:'HH:mm'}}&nbsp;{{selectedTime.workplan.name}}</span>
                                        </ng-container>
                                    </div>
                                </ng-container>
                            </ng-container>
                        </div>
                    </div>
                    <div class="row mt-auto">
                        <div class="col-12 d-flex justify-content-between">
                            <button class="btn btn-outline-primary" (click)="onCancelClicked($event)">{{'BUTTON.CANCEL'
                                |
                                translate}}</button>
                            <button class="btn btn-primary" (click)="onSaveClicked($event)">{{'BUTTON.SAVE' |
                                translate}}</button>
                        </div>
                    </div>
                </div>
                <div class="col-10 d-flex flex-column ps-3 pe-4 overflow-y-auto modal-scroll-area-80">
                    <ng-container *ngIf="days">
                        <ng-container *ngFor="let day of days; index as i">
                            <div class="row pt-2 pb-2"
                                [ngClass]="{'even-day': i % 2 === 0, 'odd-day': (day.isDataDay==false && (i % 2 !== 0)), 'data-day': (day.isDataDay==true && (i % 2 !== 0))}">
                                <div class="col-12 d-flex flex-column">
                                    <div class="row">
                                        <div class="col-2 d-flex align-items-center">
                                            <span
                                                class="text-base fw-light text-black">{{day.date|date:'fullDate'}}</span>
                                        </div>
                                        <div class="col-10 d-flex justify-content-start column-gap-2 row-gap-2 my-1">
                                            <ng-container *ngIf="day.selectedTimes && day.selectedTimes.length>0">
                                                <ng-container *ngFor="let selectedTime of day.selectedTimes">
                                                    <div nz-tooltip nzTooltipTitle="{{selectedTime.workplan.name}}"
                                                        (click)="onEditRangeClicked(day, selectedTime)"
                                                        class="border border-1 rounded-1 py-1 px-2 bg-white cursor-pointer hover-selected-time d-flex align-items-center">
                                                        <span class="me-1"
                                                            [ngStyle]="{'color': selectedTime.workplan.hexColor}">&#9646;</span>
                                                        <span
                                                            class="text-sm line-height-sm mt-1 fw-semibold color-gray-darkest">{{selectedTime.startTime|date:'HH:mm'}}-{{selectedTime.endTime|date:'HH:mm'}}</span>
                                                        <cds-icon shape="times-circle" solid
                                                            class="ms-1 cds-icon-14 color-gray-dark delete-range-icon"
                                                            title="{{'BUTTON.CLEAR'|translate}}" click-stop-propagation
                                                            (click)="onDeleteRangeClicked(selectedTime)"></cds-icon>
                                                    </div>
                                                </ng-container>
                                            </ng-container>
                                            <div class="d-flex align-items-center py-1 px-2 bg-white border border-success-subtle border-1 rounded-1 cursor-pointer color-success hover-selected-time text-md line-height-md fw-normal"
                                                nz-tooltip nzTooltipTitle="{{selectedWorkplan?.name}}"
                                                (click)="onEditRangeClicked(day)">
                                                <cds-icon shape="plus-circle" solid class="cds-icon-16 me-1"></cds-icon>
                                                {{'BUTTON.ADD'|translate}}
                                            </div>
                                        </div>
                                    </div>
                                    <div class="mhs-5">
                                        <app-timeline-wrapper-component class="w-100" [timeline]="day.timelineSelection"
                                            *ngIf="visibleTimelines" [options]="timelineSelectionOptions"
                                            (onRangeMouseEnter)="onRangeMouseEnter($event, day)"
                                            (onRangeMouseLeave)="onRangeMouseLeave($event, day)"
                                            (onSelectionUpdated)="onSelectionUpdated($event, day)"
                                            (onRangeClicked)="onRangeClicked($event, day)">
                                        </app-timeline-wrapper-component>
                                    </div>

                                </div>
                            </div>
                        </ng-container>
                    </ng-container>
                </div>
            </div>
        </ng-container>
    </div>
</ng-container>`;var ee=`.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}.segment-container{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;border-left:5px solid #fff}.segment-container .segment-line-container{display:-webkit-box;display:-moz-box;display:-webkit-flexbox;display:-ms-flexbox;display:-webkit-flex;display:flex;-webkit-box-pack:justify;-moz-box-pack:justify;-webkit-flex-pack:justify;-ms-flex-pack:justify;-moz-justify-content:space-between;-webkit-justify-content:space-between;justify-content:space-between;-webkit-box-align:center;-ms-flex-align:center;-webkit-align-items:center;-moz-align-items:center;align-items:center;border-left:1px dashed #333;border-right:1px dashed #333;border-bottom:16px solid #333}.data-day{background-color:#d9e9f1!important}.odd-day{background-color:#fafafa!important}.hover-selected-time{-moz-transition:border-color .25s ease;-webkit-transition:border-color .25s ease;-o-transition:border-color .25s ease;transition:border-color .25s ease}.hover-selected-time:hover{border-color:#0369a1!important;background-color:#e6f0f6!important}.delete-range-icon:hover{color:#c82602!important}.hover-summary-day:hover{background-color:#dadfe6!important}
`;var te=`<ng-container>
  <div class="modal-header">
    <span class="text-lg">{{'REPORT.WORKING_PERIOD'|translate}}</span>
  </div>
  <div class="modal-body">
    <form [formGroup]="form">
      <div class="row color-gray-dark" *ngIf="dateRanges">
        <div class="d-flex flex-column flex-grow-1 mb-3">
          <label class="report-form-label">{{'PACS.WORKPLAN'
            |
            translate}}</label>
          <nz-select class="w-100" formControlName="workplan" nzSize="small"
            [nzCustomTemplate]="selectedWorkplanTemplate">
            <nz-option nzCustomContent *ngFor="let workplan of workplans" [nzValue]="workplan"
              [nzLabel]="workplan.name | translate"><span class="me-1"
                [ngStyle]="{'color': workplan.hexColor}">&#9646;</span>{{workplan.name}}</nz-option>
          </nz-select>
          <ng-template #selectedWorkplanTemplate let-selected>
            <span [ngStyle]="{'color': selected.nzValue.hexColor}" class="me-1">&#9646;</span>{{selected.nzValue.name}}
          </ng-template>
        </div>
        <div class="col-12 d-flex justify-content-center">
          <span class="text-md">{{dateRanges[0] | date:'longDate'}} {{dateRanges[0] | date:'shortTime'}}</span>
          <span class="mx-2">-</span>
          <span class="text-md">{{dateRanges[1] | date:'longDate'}} {{dateRanges[1] | date:'shortTime'}}</span>
        </div>
      </div>
      <div class="row">
        <div class="col-12">
          <div class="form-group form-layout mb-3">
            <armon-range-three-days-input id="range-input" formControlName="range"></armon-range-three-days-input>
          </div>
        </div>
      </div>
    </form>
  </div>

  <div class="modal-footer">
    <button class="btn btn-outline-primary" (click)="onCancelClicked($event)">{{'BUTTON.CANCEL' | translate}}</button>
    <button class="btn btn-primary" [disabled]="form.invalid" (click)="onSaveClicked($event)">{{'BUTTON.ADD' |
      translate}}</button>
  </div>
</ng-container>`;var ne=`.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 ae=`<div class="d-flex flex-column align-items-stretch mb-2">\r
    <div class="d-flex justify-content-center align-items-center mb-4 color-gray-darkest"\r
        [ngClass]="{'color-error': invalid}">\r
        <div class="w-100 d-flex justify-content-end align-items-center column-gap-2">\r
            <ng-container *ngIf="selectedFromHour">\r
                <ng-template *ngTemplateOutlet="dayTemplate;context: {$implicit:selectedFromHour, invalid:invalid}">\r
                </ng-template>\r
            </ng-container>\r
            <span class="text-xxxl fw-light">\r
                {{selectedFromHour?.label || '__'}}:{{selectedFromMinute?.label || '__'}}\r
            </span>\r
        </div>\r
        <div>\r
            <span class="text-xxxl fw-light mx-2 ">&gt;</span>\r
        </div>\r
        <div class="w-100 d-flex justify-content-start align-items-center column-gap-2 ">\r
            <span class="text-xxxl fw-light">\r
                {{selectedToHour?.label || '__'}}:{{selectedToMinute?.label || '__'}}\r
            </span>\r
            <ng-container *ngIf="selectedToHour">\r
                <ng-template *ngTemplateOutlet="dayTemplate;context: {$implicit:selectedToHour, invalid:invalid}">\r
                </ng-template>\r
            </ng-container>\r
        </div>\r
    </div>\r
    <div class="d-flex justify-content-center align-items-center">\r
        <ng-template *ngTemplateOutlet="hourTemplate;context: {$implicit:'from', selected:selectedFromHour}">\r
        </ng-template>\r
        <span class="text-xxxl fw-light color-gray-darkest">:</span>\r
        <ng-template *ngTemplateOutlet="minuteTemplate;context: {$implicit:'from', selected:selectedFromMinute}">\r
        </ng-template>\r
        <span class="text-xxxl fw-light color-gray-darkest mx-2">&gt;</span>\r
        <ng-template *ngTemplateOutlet="hourTemplate;context: {$implicit:'to', selected:selectedToHour}">\r
        </ng-template>\r
        <span class="text-xxxl fw-light color-gray-darkest">:</span>\r
        <ng-template *ngTemplateOutlet="minuteTemplate;context: {$implicit:'to', selected:selectedToMinute}">\r
        </ng-template>\r
    </div>\r
</div>\r
\r
<ng-template #hourTemplate let-type let-selected="selected">\r
    <div class="d-flex flex-column overflow-auto mx-2 list-container">\r
        <div *ngFor="let hour of hours" class="py-1 px-3 m-1 d-flex column-gap-2 justify-content-center item-container"\r
            (click)="onHourSelected(hour, type)" [attr.selected]="selected?.value == hour.value" nz-tooltip\r
            [attr.id]="inputId+'-'+type+'-hour-'+hour.stepValue" nzTooltipPlacement="left"\r
            nzTooltipTitle="{{hour.value.days==0? null : ( (hour.value.days==-1) ? 'PACS.AUTOSHIFT_PREVIOUS_DAY':'PACS.AUTOSHIFT_NEXT_DAY') | translate }}">\r
            <ng-template *ngTemplateOutlet="dayTemplate;context: {$implicit:hour}">\r
            </ng-template>\r
            <span class="text-lg fw-medium line-height-lg">{{hour.label}}</span>\r
        </div>\r
    </div>\r
</ng-template>\r
\r
<ng-template #minuteTemplate let-type let-selected="selected">\r
    <div class="d-flex flex-column overflow-auto mx-2 list-container">\r
        <div *ngFor="let minute of minutes" class="py-1 px-3 m-1 d-flex justify-content-center item-container"\r
            [attr.id]="inputId+'-'+type+'-minute-'+minute.value" (click)="onMinuteSelected(minute, type)"\r
            [attr.selected]="selected?.value == minute.value">\r
            <span class="text-lg fw-medium line-height-lg">{{minute.label}}</span>\r
        </div>\r
    </div>\r
</ng-template>\r
\r
<ng-template #dayTemplate let-hour let-invalid="invalid">\r
    <div *ngIf="hour.value.days==-1"\r
        class="d-flex px-1 pt-1 pb-0 border border-1 rounded-1 justify-content-center align-items-center"\r
        [ngClass]="{'border-danger': invalid}">\r
        <span class="text-sm line-height-sm fw-medium"\r
            [ngClass]="{'color-error': invalid, 'color-gray-dark': !invalid}">{{'PACS.AUTOSHIFT_PREVIOUS_DAY_SHORTEN'|translate}}</span>\r
    </div>\r
    <div *ngIf="hour.value.days>=1"\r
        class="d-flex px-1 pt-1 pb-0 border border-1 rounded-1 justify-content-center align-items-center"\r
        [ngClass]="{'border-danger': invalid}">\r
        <span class="text-sm line-height-sm fw-medium color-gray-dark"\r
            [ngClass]="{'color-error': invalid, 'color-gray-dark': !invalid}">{{'PACS.AUTOSHIFT_NEXT_DAY_SHORTEN'|translate}}</span>\r
    </div>\r
</ng-template>`;var ie=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}.list-container{-webkit-border-radius:.375rem;-moz-border-radius:.375rem;border-radius:.375rem;border:1px solid #ccc;height:22rem}.item-container{background-color:#fff;cursor:pointer}.item-container:hover{background-color:#e6f0f6}.item-container[selected=true]{background-color:#c0dae8;cursor:default}
`;var pe=function(d,e,t,a){var n=arguments.length,i=n<3?e:a===null?a=Object.getOwnPropertyDescriptor(e,t):a,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(d,e,t,a);else for(var l=d.length-1;l>=0;l--)(o=d[l])&&(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},ue={provide:H,useExisting:O(()=>x),multi:!0},x=class{dateService;onChange;hours;minutes;selectedFromHour;selectedFromMinute;selectedToHour;selectedToMinute;isDisabled=!1;invalid=!1;inputId=c();constructor(e){this.dateService=e,this.createHours(),this.createMinutes()}getHourFromValue(e){let t=e%12;return this.hours.find(a=>a.stepValue==e-t)}getMinuteFromValue(e){return this.minutes.find(t=>t.value==e%12)}writeValue(e){if(e){this.selectedFromHour=this.getHourFromValue(e[0]),this.selectedToHour=this.getHourFromValue(e[1]),this.selectedFromMinute=this.getMinuteFromValue(e[0]),this.selectedToMinute=this.getMinuteFromValue(e[1]);let t={behavior:"auto",block:"center",inline:"nearest"};setTimeout(()=>{document.getElementById(this.inputId+"-from-hour-"+this.selectedFromHour.stepValue).scrollIntoView(t)},200),setTimeout(()=>{document.getElementById(this.inputId+"-from-minute-"+this.selectedFromMinute.value).scrollIntoView(t)},400),setTimeout(()=>{document.getElementById(this.inputId+"-to-hour-"+this.selectedToHour.stepValue).scrollIntoView(t)},600),setTimeout(()=>{document.getElementById(this.inputId+"-to-minute-"+this.selectedToMinute.value).scrollIntoView(t)},800)}}registerOnChange(e){this.onChange=e}registerOnTouched(e){}setDisabledState(e){this.isDisabled=e}ngOnInit(){}createMinutes(){this.minutes=[];for(let e=0;e<=55;e+=5)this.minutes.push({label:e.toString().length==1?"0"+e.toString():e.toString(),value:e==0?0:e/5})}createHours(){this.hours=[];for(let e=0;e<=I*3;e+=12)this.hours.push({label:this.dateService.threeDaysFormatHour(e,"hh"),value:this.dateService.threeDaysGetRangePointData(e),stepValue:e})}onHourSelected(e,t){t=="from"?this.selectedFromHour=e:this.selectedToHour=e,this.setSelectedValue()}onMinuteSelected(e,t){t=="from"?this.selectedFromMinute=e:this.selectedToMinute=e,this.setSelectedValue()}setSelectedValue(){if(this.selectedFromHour.stepValue+this.selectedFromMinute.value>=this.selectedToHour.stepValue+this.selectedToMinute.value){this.invalid=!0,this.onChange(null);return}else this.invalid=!1,this.onChange([this.selectedFromHour.stepValue+this.selectedFromMinute.value,this.selectedToHour.stepValue+this.selectedToMinute.value])}static ctorParameters=()=>[{type:v}]};x=pe([u({selector:"armon-range-three-days-input",providers:[ue],template:ae,standalone:!0,imports:[y,g,P,f,C,h],styles:[ie]})],x);var fe=function(d,e,t,a){var n=arguments.length,i=n<3?e:a===null?a=Object.getOwnPropertyDescriptor(e,t):a,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(d,e,t,a);else for(var l=d.length-1;l>=0;l--)(o=d[l])&&(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},_=class extends w{formBuilder;languageService;dateService;day;selectedWorkplan;workplans;range;editMode=!1;dateRanges=void 0;form;constructor(e,t,a){super(),this.formBuilder=e,this.languageService=t,this.dateService=a}onModalInitialized(){super.onModalInitialized(),this.initializeForms()}setLayout(){this.form&&this.form.value.range&&(this.dateRanges=this.dateService.threeDaysGetRangeDates(s.fromISO(this.day).toJSDate(),this.form.value.range))}initializeForms(){this.form=this.formBuilder.group({range:[this.range||[396,504],E.required],workplan:[this.selectedWorkplan||void 0,E.required]}),this.setLayout(),this.form.valueChanges.subscribe(e=>{e&&this.setLayout()})}onSaveClicked(e){this.closeModal({start:this.dateRanges[0],end:this.dateRanges[1],workplan:this.form.value.workplan})}static ctorParameters=()=>[{type:A},{type:W},{type:v}];static propDecorators={day:[{type:m}],selectedWorkplan:[{type:m}],workplans:[{type:m}],range:[{type:m}]}};_=fe([u({selector:"armon-pacs-workplan-range-selection-modal",template:te,standalone:!0,imports:[S,J,D,g,R,f,k,x,b,h],styles:[ne]})],_);var ge=function(d,e,t,a){var n=arguments.length,i=n<3?e:a===null?a=Object.getOwnPropertyDescriptor(e,t):a,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(d,e,t,a);else for(var l=d.length-1;l>=0;l--)(o=d[l])&&(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},oe=class extends w{interactionService;pacsService;sessionService;dateService;day;userId;userCaptions;uiRange;workplans;selectedWorkplan;dataRequest;scheduleData;days;visibleTimelines=!1;selectedDay;_previousDaysCount=1;_nextDaysCount=6;_daysCount;visibleSpinner=!0;timelineSelectionOptions={enableZoom:!1,firstRowMarginTop:10,lastRowMarginBottom:5,paddingX:12,paddingY:6,selectFunction:this.getRangeSelected.bind(this)};constructor(e,t,a,n){super(),this.interactionService=e,this.pacsService=t,this.sessionService=a,this.dateService=n}onModalInitialized(){this._daysCount=this._previousDaysCount+this._nextDaysCount+1,super.onModalInitialized(),this.selectedDay=s.fromISO(this.day).toJSDate(),this.getWorkplanData()}getWorkplanData(){this.pacsService.getWorkplans(!0).subscribe(e=>{this.workplans=e,this.getScheduleData()})}getScheduleData(){this.dataRequest=z.getEmptyModel(),this.dataRequest.userIds=[this.userId],this.dataRequest.range={startDateTime:s.fromISO(this.day).minus({days:this._previousDaysCount}).startOf("day").toISO(),endDateTime:s.fromISO(this.day).plus({days:this._nextDaysCount+1}).startOf("day").toISO()},this.pacsService.getPacsWorkplanPlannerRange(z.getRequestModel(this.dataRequest)).subscribe(e=>{this.scheduleData=e,this.createDaysFromResponse()})}getRangeSelected(e){return e.selectedColor=this.selectedWorkplan.hexColor,e.data&&Object.assign(e.data,{workPlanColor:this.selectedWorkplan.hexColor,workPlanName:this.selectedWorkplan.name,workPlanId:this.selectedWorkplan.id,userWorkplanId:void 0,rangeId:c()}),{range:e}}createDaysFromResponse(){let e=[],t=s.fromISO(this.day).minus({days:this._previousDaysCount}).startOf("day");for(let n=0;n<this._daysCount;n++){let i=n+1,o={date:t.toJSDate(),dayIndex:i,isDataDay:t.toFormat("yyyy-MM-dd")==this.day,selectedTimes:[],interval:p.fromDateTimes(t.startOf("day"),t.plus({days:1}).startOf("day"))};o.selectedTimes=this.getSelectTimes(o),o.timelineSelection=this.createTlTimelineData(o),t=t.plus({day:1}),e.push(o)}this.days=e;let a=this._workplanHasRangeId?this.workplans.find(n=>n.id==this._workplanHasRangeId):null;this.selectedWorkplan=a||this.workplans[0]||null,this.visibleSpinner=!1,setTimeout(()=>{this.visibleTimelines=!0},300)}_workplanHasRangeId=null;getSelectTimes(e){let t=[],a=this.scheduleData.items[0];return a.memberships&&a.memberships.length>0&&a.memberships.forEach(n=>{n.ranges.forEach(i=>{if(e.interval.overlaps(p.fromDateTimes(s.fromJSDate(i.intersectingRange.startDateTime),s.fromJSDate(i.intersectingRange.endDateTime)))){let o={id:n.workPlanId,name:n.workPlanName,hexColor:n.workPlanColor};t.push({startTime:i.intersectingRange.startDateTime,endTime:i.intersectingRange.endDateTime,workplan:o,userWorkplanId:i.userWorkPlanId,rangeId:c()}),this._workplanHasRangeId||(this._workplanHasRangeId=n.workPlanId)}})}),t.forEach(n=>{s.fromJSDate(n.startTime)<e.interval.start&&(n.startTime=e.interval.start.toJSDate()),s.fromJSDate(n.endTime)>e.interval.end&&(n.endTime=e.interval.end.toJSDate())}),t}setRangeStatesFromTimeline(e,t=null){if(t){let a=[];t.forEach(n=>{let i={id:n[0].data.workPlanId,name:n[0].data.workPlanName,hexColor:n[0].data.workPlanColor};a.push({startTime:n[0].data.start,endTime:n[1].data.end,workplan:i,userWorkplanId:void 0,rangeId:c()})}),e.selectedTimes=a}}addSelectedTimesFromForm(e,t){let a=p.fromDateTimes(s.fromJSDate(t.startTime),s.fromJSDate(t.endTime));for(let n=e.selectedTimes.length-1;n>=0;n--){let i=p.fromDateTimes(s.fromJSDate(e.selectedTimes[n].startTime),s.fromJSDate(e.selectedTimes[n].endTime));if(a.overlaps(i))if(a.equals(p.fromDateTimes(s.fromJSDate(e.selectedTimes[n].startTime),s.fromJSDate(e.selectedTimes[n].endTime)))||i.start>=a.start&&i.end<=a.end)e.selectedTimes.splice(n,1);else{let o=a.intersection(i);i.start==o.start?e.selectedTimes[n].startTime=o.end.toJSDate():i.end==o.end?e.selectedTimes[n].endTime=o.start.toJSDate():(e.selectedTimes[n].endTime=o.start.toJSDate(),e.selectedTimes.push({startTime:o.end.toJSDate(),endTime:i.end.toJSDate(),workplan:e.selectedTimes[n].workplan,userWorkplanId:void 0,rangeId:c()}))}}e.selectedTimes.push(t)}sortSelectedTimes(e){e.selectedTimes.sort((t,a)=>s.fromJSDate(t.startTime)<s.fromJSDate(a.startTime)?-1:s.fromJSDate(t.startTime)>s.fromJSDate(a.startTime)?1:0)}clearSelectedTimes(e,t){let a=!1;for(let n=e.selectedTimes.length-1;n>=0;n--)e.selectedTimes[n].rangeId==t&&(e.selectedTimes.splice(n,1),a=!0)}refreshTimelines(){this.days.forEach(e=>{e.timelineSelection=this.createTlTimelineData(e)})}mergeDaySelectedTimes(e){for(let t=e.selectedTimes.length-1;t>=0;t--)t>0&&e.selectedTimes[t].workplan.id==e.selectedTimes[t-1].workplan.id&&s.fromJSDate(e.selectedTimes[t].startTime).equals(s.fromJSDate(e.selectedTimes[t-1].endTime))&&(e.selectedTimes[t-1].endTime=e.selectedTimes[t].endTime,e.selectedTimes.splice(t,1))}finalizeDaySelectedTimes(){this.days.forEach(t=>{this.sortSelectedTimes(t),this.mergeDaySelectedTimes(t)});let e=[];this.days.forEach(t=>{t.selectedTimes.forEach(a=>{e.indexOf(a.rangeId)>=0?a.rangeId=c():e.push(a.rangeId)})})}_dayPartCount=I;createTlTimelineData(e){let t=new L,a=new $,n=1/24;for(let l=0;l<=24;l++){let r=new G;r.label=l.toString(),r.pos=l*n,a.addItem(r)}t.addDivider(a);let i=new B;i.height=10,i.enableSelection=!0;let o=1/this._dayPartCount;for(let l=0;l<this._dayPartCount;l++){let r=new q;r.data={start:s.fromJSDate(e.date).startOf("day").plus({minutes:l*5}).toJSDate(),end:s.fromJSDate(e.date).startOf("day").plus({minutes:(l+1)*5}).toJSDate()},r.hoverable=!0,r.startPos=l*o,r.endPos=(l+1)*o,r.color="#DBDBD3";let T=this.getRangeData(e,r.data.start,r.data.end);T&&(r.selected=!0,r.selectedColor=T.workplan.hexColor,r.data.workPlanName=T.workplan.name,r.data.workPlanId=T.workplan.id,r.data.workPlanColor=T.workplan.hexColor,r.data.userWorkplanId=void 0,r.data.rangeId=c()),i.addRange(r)}return t.addRow(i),t}getRangeData(e,t,a){let n=null,i=p.fromDateTimes(s.fromJSDate(t),s.fromJSDate(a));return e.selectedTimes.forEach(o=>{i.overlaps(p.fromDateTimes(s.fromJSDate(o.startTime),s.fromJSDate(o.endTime)))&&(n=o)}),n}updateRange(){let e=X.getEmptyModel();e.userId=this.dataRequest.userIds[0],e.range={startDateTime:this.dataRequest.range.startDateTime,endDateTime:this.dataRequest.range.endDateTime},this.days.forEach(t=>{t.selectedTimes&&t.selectedTimes.forEach(a=>{e.items.push({workplanId:a.workplan.id,range:{startDateTime:s.fromJSDate(a.startTime).toISO(),endDateTime:s.fromJSDate(a.endTime).toISO()}})})});for(let t=e.items.length-1;t>=0;t--)t>0&&e.items[t].workplanId==e.items[t-1].workplanId&&s.fromISO(e.items[t].range.startDateTime).equals(s.fromISO(e.items[t-1].range.endDateTime))&&(e.items[t-1].range.endDateTime=e.items[t].range.endDateTime,e.items.splice(t,1));this.pacsService.updateWorkplanMembershipForRange(e).subscribe(t=>{this.interactionService.showMessage("PACS.PLANNER_WORKPLAN_UPDATED",null,F.Success),this.closeModal()})}onRangeClicked(e,t){}onRangeMouseEnter(e,t){}onRangeMouseLeave(e,t){}onSelectionUpdated(e,t){this.setRangeStatesFromTimeline(t,Y.getSelectedRanges(e.row.ranges,!0,"workPlanId"))}onInfoContainerClicked(e){}onAddClicked(e){}onRemoveClicked(e){}updateAllChecked(e,t){t.timelineSelection=this.createTlTimelineData(t)}onSaveClicked(e){this.updateRange()}getNewSelectedTime(){return{startTime:void 0,endTime:void 0,workplan:{id:void 0,name:void 0,hexColor:void 0},userWorkplanId:void 0,rangeId:c()}}onEditRangeClicked(e,t=void 0){let a,n;t?(n=!1,a={day:s.fromJSDate(e.date).toFormat("yyyy-MM-dd"),selectedWorkplan:this.workplans.find(i=>i.id==t.workplan.id),workplans:this.workplans,range:this.dateService.threeDaysGetRangeSteps(e.date,[t.startTime,t.endTime])}):(n=!0,a={day:s.fromJSDate(e.date).toFormat("yyyy-MM-dd"),selectedWorkplan:this.selectedWorkplan,workplans:this.workplans,range:[396,504]},t=this.getNewSelectedTime()),this.modalService.open(_,{settings:{size:"md",centered:!0},props:a}).result.then(i=>{this.days.forEach(o=>{n==!1&&this.clearSelectedTimes(o,t.rangeId);let l=o.interval.intersection(p.fromDateTimes(s.fromJSDate(i.start),s.fromJSDate(i.end)));if(l){let r=M(t);r.rangeId=c(),r.startTime=l.start.toJSDate(),r.endTime=l.end.toJSDate(),r.workplan=i.workplan,this.addSelectedTimesFromForm(o,r)}}),this.finalizeDaySelectedTimes(),this.refreshTimelines()}).catch(i=>{})}onDeleteRangeClicked(e=void 0){this.days.forEach(t=>{this.clearSelectedTimes(t,e.rangeId)}),this.finalizeDaySelectedTimes(),this.refreshTimelines()}static ctorParameters=()=>[{type:V},{type:U},{type:N},{type:v}];static propDecorators={day:[{type:m}],userId:[{type:m}],userCaptions:[{type:m}],uiRange:[{type:m}]}};oe=ge([u({selector:"armon-pacs-workplan-planner-day-modal",template:Q,standalone:!0,imports:[g,Z,R,S,D,f,k,y,C,j,K,b,h],styles:[ee]})],oe);export{oe as a};
