import{a as H}from"./chunk-5OT2MLHH.js";import{a as q}from"./chunk-4IRXRL4C.js";import"./chunk-LAJI7RPC.js";import{a as U}from"./chunk-WFZJP5WR.js";import"./chunk-F6KLNSUK.js";import{a as W}from"./chunk-4MZCYQX4.js";import{b as Y,c as $,d as J}from"./chunk-YOJ4KGSB.js";import"./chunk-I6FSQTEP.js";import"./chunk-CO3X7TQN.js";import{a as B}from"./chunk-VSFNMVXJ.js";import"./chunk-WQ6DP4JQ.js";import{J as _,Ka as l,Ob as j,a as tt,l as A,s as O,v as D,wb as G,y as k}from"./chunk-YSQLW2JA.js";import{$c as z,Uc as p,Yc as I,_c as P,ad as L,bd as F,cd as V}from"./chunk-NVJ2ZZFT.js";import{Dc as s,Fb as v,Mg as C,Ng as M,Qf as y,Te as T,ab as h,bb as g,cb as b,cd as R,db as x,dc as r,dd as E,g as Z,gg as i,hg as w,jg as N,wa as f,ya as u}from"./chunk-SKPDQO4E.js";var K=`<div class="h-100">
  <side-navigation #sideNavigation>
    <ng-template side-navigation-nav>
      <div>
        <div class="row">
          <div class="col-12">
            <label class="report-form-label">{{'REPORT.SENSOR' | translate}}</label>
            <!-- <armon-sensor-search #searchSensor [multiselect]="true" class="custom-item"></armon-sensor-search> -->
            <armon-select-search query="sensor" [allowMulti]="true" [(ngModel)]="filter.sensorIds">
            </armon-select-search>
          </div>
          <div class="col-12">
            <label class="report-form-label">{{'REPORT.TERMINAL' | translate}}</label>
            <!-- <armon-terminal-search #searchTerminal [multiselect]="true" class="custom-item"></armon-terminal-search> -->
            <armon-select-search query="terminal" [allowMulti]="true" [(ngModel)]="filter.terminalDeviceIds">
            </armon-select-search>
          </div>
          <div class="col-12 mb-2">
            <label class="report-form-label">{{'SENSOREVENT.FILTER_SENSOR_TYPE' | translate}}</label>
            <select [(ngModel)]="filter.type" class="form-select form-select-sm">
              <option *ngFor="let option of sensorTypes" [ngValue]="option.type">{{option.description |
                translate}}</option>
            </select>
          </div>
          <ng-container [ngSwitch]="filter.type">
            <!-- STATUS SENSOR TYPE -->
            <ng-container *ngSwitchCase="5">

              <div class="col-12 mb-2">
                <label class="report-form-label">{{'SENSOREVENT.FILTER_SENSOR_STATE' | translate}}</label>
                <select [(ngModel)]="selectedStatusSensorState" class="form-select form-select-sm">
                  <option *ngFor="let statusSensorState of statusSensorStates" [ngValue]="statusSensorState.type">
                    {{statusSensorState.description |
                    translate}}</option>
                </select>
              </div>
              <div class="col-12 mb-2">
                <label class="report-form-label">{{'SENSOREVENT.FILTER_SENSOR_STATE_REASON' | translate}}</label>
                <select [(ngModel)]="selectedStatusSensorStateReason" class="form-select form-select-sm">
                  <option *ngFor="let statusSensorStateReason of statusSensorStateReasons"
                    [ngValue]="statusSensorStateReason.type">{{statusSensorStateReason.description |
                    translate}}</option>
                </select>
              </div>
            </ng-container>
            <!-- END -->
            <!-- COUNTER SENSOR TYPE -->
            <ng-container *ngSwitchCase="7">
              <div class="col-12 mb-2">
                <label class="report-form-label">{{'SENSOREVENT.FILTER_SENSOR_STATE_REASON' | translate}}</label>
                <select [(ngModel)]="selectedCounterSensorStateReason" class="form-select form-select-sm">
                  <option *ngFor="let counterSensorStateReason of counterSensorStateReasons"
                    [ngValue]="counterSensorStateReason.type">{{counterSensorStateReason.description |
                    translate}}</option>
                </select>
              </div>
            </ng-container>
            <!-- END -->
            <!-- TAMPER SWITCH TYPE -->
            <ng-container *ngSwitchCase="6">
              <div class="col-12 mb-2">
                <label class="report-form-label">{{'SENSOREVENT.FILTER_SENSOR_STATE' | translate}}</label>
                <select [(ngModel)]="selectedTamperSwitchState" class="form-select form-select-sm">
                  <option *ngFor="let tamperSwitchState of tamperSwitchStates" [ngValue]="tamperSwitchState.type">
                    {{tamperSwitchState.description |
                    translate}}</option>
                </select>
              </div>
            </ng-container>
            <!-- END -->
          </ng-container>
        </div>
        <!-- Buttons for filtering state -->
        <div class="centered filterButtons">
          <button nz-dropdown [nzDropdownMenu]="menuPrint" class="btn btn-success btn-sm me-2">
            {{'BUTTON.DOWNLOAD' | translate}}
            <cds-icon shape="angle" direction="down"></cds-icon>
          </button>
          <nz-dropdown-menu #menuPrint="nzDropdownMenu">
            <ul nz-menu>
              <li nz-menu-item (click)="onGetExcelClicked($event)">{{'BUTTON.EXCEL'|translate}}</li>
              <li nz-menu-item (click)="onGetPDFClicked($event)">{{'BUTTON.PDF'|translate}}</li>
            </ul>
          </nz-dropdown-menu>
          <button class="btn btn-primary btn-sm" (click)="onGetReportClicked($event)">{{'REPORT.GET_REPORT' |
            translate}}</button>
        </div>
      </div>
    </ng-template>
    <ng-template side-navigation-content>
      <div class="report-data-container">
        <div class="row report-filter-container">
          <div class="col-12" style="min-height:0;">
            <div class="row">
              <div class="col-12">
                <armon-date-picker [options]="datePickerOptions" (selectionChanged)="onDateSelectionChanged($event)">
                </armon-date-picker>
              </div>
            </div>
          </div>
        </div>
        <div class="row report-data-table-container" id="report-data-table-container">
          <div class="col-12">
            <p-table [value]="records" dataKey="id" [responsive]="true" rowExpandMode="single">
              <ng-template pTemplate="header">
                <tr>
                  <th>{{'REPORT.DATE' | translate}}</th>
                  <th>{{'REPORT.SENSOR' | translate}}</th>
                  <th>{{'REPORT.NEW_STATUS' | translate}}</th>
                  <th>{{'REPORT.TERMINAL' | translate}}</th>
                </tr>
              </ng-template>
              <ng-template pTemplate="body" let-record let-rowData let-expanded="expanded">
                <tr [pRowToggler]="rowData" [attr.expanded]="expanded" class="data-row">
                  <td>
                    <div class="report-multi-data-cell py-2">
                      <span class="main-text"
                        *ngIf="record.lastAction && record.lastAction.actionDateTime">{{record.actionUtcHourText}}
                        <armon-local-date [dateUtc]="record.lastAction.actionDateTime"></armon-local-date>
                      </span>
                      <span class="sub-text"
                        *ngIf="record.lastAction && record.lastAction.actionDateTime">{{record.actionUtcText}}</span>
                    </div>
                  </td>
                  <td class="report-multi-data-cell">
                    <div class="d-flex">
                      <div class="d-flex align-items-center justify-content-center me-3">
                        <cds-icon [attr.shape]="record.input.typeIcon" style="width: 28px; height: 28px;"
                          class="color-gray-darkest"></cds-icon>
                      </div>
                      <div class="d-flex flex-column flex-grow-1">
                        <span class="main-text" *ngIf="record.input.name">
                          {{record.input.name}}
                        </span>
                        <span class="sub-text" *ngIf="record.input.typeName">{{record.input.typeName|translate}}<span
                            *ngIf="record.input.number"> #{{record.input.number}}</span></span>
                      </div>
                    </div>
                  </td>
                  <td>
                    <div class="report-multi-data-cell" *ngIf="record.lastAction">
                      <span class="main-text"
                        *ngIf="record.lastAction.stateText"><strong>{{record.lastAction.stateText|translate}}</strong></span>
                      <span class="sub-text"
                        *ngIf="record.lastAction.statusText">{{record.lastAction.statusText|translate}}</span>
                      <span class="sub-text"
                        *ngIf="record.lastAction.stateBeforeAction"><span>{{record.lastAction.stateBeforeActionText|translate}}
                          <cds-icon shape="arrow" direction="right"></cds-icon>
                        </span>{{record.lastAction.stateText|translate}}</span>
                      <div class="sub-text" *ngIf="record.lastAction && record.lastAction.accessLog">
                        <cds-icon shape="user" solid class="me-2" size="sm"></cds-icon>
                        <span>{{'SENSOREVENT.HAS_ACCESS_LOG'|translate}}</span>
                      </div>
                    </div>
                  </td>
                  <td>
                    <div class="report-multi-data-cell">
                      <span class="main-text">{{record.terminal.name}}</span>
                      <span class="sub-text"
                        *ngIf="record.terminal.serialNumber">{{record.terminal.serialNumber}}</span>
                      <span class="sub-text" *ngIf="record.terminal.model">{{record.terminal.model}}</span>
                    </div>
                  </td>
                </tr>
              </ng-template>
              <ng-template pTemplate="rowexpansion" let-record>
                <tr>
                  <td [attr.colspan]="4" class="expanded-row">
                    <div class="detail-row-container detail-event-container py-2">
                      <span class="my-2" *ngIf="record.input"><strong>{{'REPORT.NEW_STATUS' | translate}}:
                        </strong>
                        <span
                          *ngIf="record.lastAction.stateBeforeAction">{{record.lastAction.stateBeforeActionText|translate}}
                          <cds-icon shape="arrow" direction="right"></cds-icon>
                        </span>
                        {{record.lastAction.stateText|translate}}</span>
                      <span class="my-2"
                        *ngIf="record.lastAction && record.lastAction.reason"><strong>{{'SENSOREVENT.FILTER_SENSOR_STATE_REASON'|translate}}:
                        </strong>{{record.lastAction.reasonText|translate}}</span>
                      <span class="my-2"
                        *ngIf="record.lastAction && record.lastAction.direction"><strong>{{'REPORT.DIRECTION'|translate}}:
                        </strong>{{record.lastAction.directionText|translate}}</span>
                      <div class="py-2 mt-2" *ngIf="record.lastAction && record.lastAction.accessLog">
                        <armon-captionlines [captionlines]="record.lastAction.accessLog.user" [showBorder]="false">
                        </armon-captionlines>
                      </div>
                    </div>
                  </td>
                </tr>
              </ng-template>
            </p-table>
          </div>
          <div class="col-12 mb-3 mt-3">
            <armon-pagination [paginationResponse]="paginationResponse" [scrollDomId]="'report-data-table-container'"
              (pageChanged)="pageChanged($event)"></armon-pagination>
          </div>
        </div>
      </div>
    </ng-template>
  </side-navigation>
</div>`;var X=`.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}.filterArea{background:#fff;border:1px solid rgb(235,235,235);padding:12px;border-radius:4px;box-shadow:0 3px 6px #ebebeb;-moz-transition:width .25s ease;-webkit-transition:width .25s ease;-o-transition:width .25s ease;transition:width .25s ease}.filterArea>div:first-child>p:first-child{margin-top:0}.filterSummary>p:first-child{margin-top:0}.filterContent>div{margin-bottom:12px}.filterContent clr-checkbox{margin-top:12px}.filterButtons{margin-top:12px}.filterSmallButtons>button:last-child{margin-right:0!important}.filterMoreInfo p{margin-top:0}.filterMoreInfo div{margin-bottom:8px}.filterMoreInfo div:last-child{margin-bottom:0}.resultArea{position:relative}.resultDisabled{position:absolute;width:100%;height:100%;background:linear-gradient(to top,#f3f4f6,transparent 150%)}.required:after{content:"*";font-size:1.1em;color:#c92100;margin-left:6px}.report-data-container{height:100%;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}.report-data-container .report-filter-container{margin-bottom:.2rem}.report-data-container .report-data-table-container{overflow-y:auto;overflow-x:hidden;-webkit-flex-grow:1;-webkit-box-flex:1;-moz-flex-grow:1;-ms-flex-positive:1;flex-grow:1;height:0;display:block}.report-multi-data-cell{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;line-height:initial!important}.report-multi-data-cell .title-text{font-size:1.008rem}.report-multi-data-cell .main-text{font-size:.84rem}.report-multi-data-cell .sub-text{font-size:.672rem;color:#aaa}.report-form-label{font-size:.672rem;line-height:.84rem;font-weight:500;margin-top:.3rem;margin-bottom:.1rem!important}.report-form-label label{margin-bottom:0!important}.report-form-icon{position:absolute;color:#0a2a5a;right:15px;bottom:6px;cursor:pointer}.report-checkbox-label{font-size:.672rem}.detail-event-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;font-size:.672rem;line-height:.55rem}.detail-event-container .detail-title{font-size:.714rem;line-height:.65rem}
`;var S=Z(tt());var at=function(c,t,e,o){var n=arguments.length,a=n<3?t:o===null?o=Object.getOwnPropertyDescriptor(t,e):o,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(c,t,e,o);else for(var m=c.length-1;m>=0;m--)(d=c[m])&&(a=(n<3?d(a):n>3?d(t,e,a):d(t,e))||a);return n>3&&a&&Object.defineProperty(t,e,a),a},Q=class{interactionService;reportService;authService;translate;route;filter;result;records=[];paginationResponse=new M;paginationRequest=new C;datePickerOptions=new w;sensorTypes;statusSensorStates;selectedStatusSensorState;statusSensorStateReasons;selectedStatusSensorStateReason;counterSensorStates;selectedCounterSensorState;counterSensorStateReasons;selectedCounterSensorStateReason;tamperSwitchStates;selectedTamperSwitchState;sideNavigation;constructor(t,e,o,n,a){this.interactionService=t,this.reportService=e,this.authService=o,this.translate=n,this.route=a}ngOnInit(){this.datePickerOptions.items=[{type:i.Today,selected:!0},{type:i.Yesterday},{type:i.SelectDay},{type:i.Custom}],this.createFilter(),this.sensorTypes=r(I),this.sensorTypes.unshift({type:null,description:"COMMON.ALL"}),this.filter.type=this.sensorTypes[0].type,this.statusSensorStates=r(L),this.statusSensorStates.unshift({type:null,description:"COMMON.ALL"}),this.selectedStatusSensorState=this.statusSensorStates[0].type,this.statusSensorStateReasons=r(P),this.statusSensorStateReasons.unshift({type:null,description:"COMMON.ALL"}),this.selectedStatusSensorStateReason=this.statusSensorStateReasons[0].type,this.counterSensorStates=r(F),this.counterSensorStates.unshift({type:null,description:"COMMON.ALL"}),this.selectedCounterSensorState=this.counterSensorStates[0].type,this.counterSensorStateReasons=r(z),this.counterSensorStateReasons.unshift({type:null,description:"COMMON.ALL"}),this.selectedCounterSensorStateReason=this.counterSensorStateReasons[0].type,this.tamperSwitchStates=r(V),this.tamperSwitchStates.unshift({type:null,description:"COMMON.ALL"}),this.selectedTamperSwitchState=this.tamperSwitchStates[0].type,console.log(this.filter)}ngAfterViewInit(){this.fetchReportData()}ngOnDestroy(){}createFilter(){this.filter=l.getEmptyModel(),this.setDateSelection(N.getDateSelection(this.datePickerOptions.items[0]))}setDateSelection(t){this.filter.dateRange.startDateTime=t.startDate,this.filter.dateRange.endDateTime=t.endDate}onGetReportClicked(t){this.sideNavigation.hideLeftClicked(),this.fetchReportData()}onGetExcelClicked(t){this.updateFilter(),this.reportService.getSensorEventsAsExcel(l.getRequestModel(this.filter)).subscribe(e=>{this.translate.get(["PAGES.REPORT_SENSOR_EVENTS"]).subscribe(o=>{S.default.saveAs(e,o["PAGES.REPORT_SENSOR_EVENTS"]+" "+s.fromJSDate(this.filter.dateRange.startDateTime).toLocaleString(s.DATETIME_MED)+" "+s.fromJSDate(this.filter.dateRange.endDateTime).toLocaleString(s.DATETIME_MED)+".xlsx")})})}onGetPDFClicked(t){this.updateFilter(),this.reportService.getSensorEventsAsPdf(l.getRequestModel(this.filter)).subscribe(e=>{this.translate.get(["PAGES.REPORT_SENSOR_EVENTS"]).subscribe(o=>{S.default.saveAs(e,o["PAGES.REPORT_SENSOR_EVENTS"]+" "+s.fromJSDate(this.filter.dateRange.startDateTime).toLocaleString(s.DATETIME_MED)+" "+s.fromJSDate(this.filter.dateRange.endDateTime).toLocaleString(s.DATETIME_MED)+".pdf")})})}fetchReportData(){this.updateFilter(),this.reportService.getSensorEvents(l.getRequestModel(this.filter)).subscribe(t=>{this.result=t,this.records=t.items||[],this.paginationResponse=t.paginationResponse})}updateFilter(){if(this.filter.type)switch(this.filter.type){case p.StatusSensor:this.filter.state=this.selectedStatusSensorState,this.filter.reason=this.selectedStatusSensorStateReason;break;case p.Counter:this.filter.state=this.selectedCounterSensorState,this.filter.reason=this.selectedCounterSensorStateReason;break;case p.TamperSwitch:this.filter.state=this.selectedTamperSwitchState,this.filter.reason=null;break}this.filter.type==-1&&(this.filter.type=null),this.filter.state==-1&&(this.filter.state=null),this.filter.reason==-1&&(this.filter.reason=null)}pageChanged(t){this.filter.pagination.skip=t.skip,this.filter.pagination.take=t.take,this.fetchReportData()}onDateSelectionChanged(t){this.setDateSelection(t),this.fetchReportData()}static ctorParameters=()=>[{type:y},{type:_},{type:j},{type:R},{type:v}];static propDecorators={sideNavigation:[{type:f,args:["sideNavigation",{static:!0}]}]}};Q=at([u({selector:"armon-report-sensor-events",template:K,standalone:!0,imports:[J,Y,G,T,h,b,x,k,D,O,$,A,H,W,g,q,U,B,E],styles:[X]})],Q);export{Q as ReportSensorEventsComponent};
