import{a as se}from"./chunk-4MZCYQX4.js";import{b as oe,c as ae,d as re}from"./chunk-YOJ4KGSB.js";import"./chunk-I6FSQTEP.js";import"./chunk-CO3X7TQN.js";import{a as ne}from"./chunk-VSFNMVXJ.js";import"./chunk-WQ6DP4JQ.js";import{J as Y,Jb as T,Kb as ee,Mb as te,Ob as ie,a as xe,d as B,j as Z,l as H,o as W,s as J,wb as K}from"./chunk-YSQLW2JA.js";import"./chunk-NVJ2ZZFT.js";import{Aa as u,Ba as C,Dc as c,Fb as w,Mg as V,Ng as h,Pd as j,Qd as M,Qf as S,Rd as G,Sc as N,Sd as U,Tb as A,Te as F,Wb as l,Yg as Q,Zb as E,_a as _,ab as p,af as x,bb as f,bh as X,cd as P,dd as g,ea as k,fb as v,g as ye,gg as b,ha as I,hd as y,hg as $,jb as z,jg as q,lb as D,ya as m,zc as L}from"./chunk-SKPDQO4E.js";var ce=`<div class="h-100">
	<side-navigation *ngIf="visibleComponent">
		<ng-template side-navigation-nav>
			<div class="row row-gap-2">
				<div class="col-12" *ngIf="permissionSearchOrganizationUnit">
					<label class="report-form-label">{{'REPORT.ORGANIZATION_UNITS' | translate}}</label>
					<armon-select-search query="unit" [allowMulti]="true" [(ngModel)]="filter.organizationUnitIds">
					</armon-select-search>
				</div>
				<div class="col-12" *ngIf="permissionSearchUserGroup">
					<label class="report-form-label">{{'REPORT.USER_GROUPS' | translate :
						languageService.userTranslate}}</label>
					<armon-select-search query="group" [allowMulti]="true" [(ngModel)]="filter.userGroupIds">
					</armon-select-search>
				</div>
				<div class="col-12">
					<label class="report-form-label">{{'REPORT.REGIONS' | translate}}</label>
					<armon-select-search query="region" [allowMulti]="true" [(ngModel)]="filter.regionIds">
					</armon-select-search>
				</div>
				<div class="col-12">
					<label class="report-form-label">{{'REPORT.ACCESS_CONTROL_POINTS' | translate}}</label>
					<armon-select-search query="point" [allowMulti]="true" [(ngModel)]="filter.accessControlPointIds">
					</armon-select-search>
				</div>
			</div>
			<!-- Buttons for filtering state -->
			<div class="centered filterButtons">
				<button class="btn btn-success btn-sm me-2" (click)="onGetExcelClicked($event)">{{'BUTTON.EXCEL'
					| translate}}</button>
				<button class="btn btn-primary btn-sm" (click)="onGetReportClicked($event)">{{'REPORT.GET_REPORT' |
					translate}}</button>
			</div>
		</ng-template>
		<ng-template side-navigation-content>
			<div class="report-data-container">
				<div class="row report-filter-container">
					<div class="col-12">
						<div class="row">
							<div class="col-12">
								<armon-report-template-panel [reportType]="reportTemplateType" [filter]="filter"
									[templateId]="reportTemplateId"
									(templateLoaded)="onTemplateLoaded($event)"></armon-report-template-panel>
							</div>
						</div>
					</div>
					<div class="col-12">
						<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 pt-5" *ngIf="items && items.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" *ngIf="visibleData">
					<div class="col-12">
						<ng-container *ngFor="let item of topList">
							<armon-report-organization-access-item (daysClicked)="onDaysClick($event)"
								(accessLogsClicked)="onAccessLogsClick($event)"
								[item]="item"></armon-report-organization-access-item>
						</ng-container>
					</div>
				</div>
			</div>
		</ng-template>
	</side-navigation>
</div>`;var le=`.justify-content-center{-webkit-box-pack:center;-moz-box-pack:center;-webkit-flex-pack:center;-ms-flex-pack:center;-moz-justify-content:center;-webkit-justify-content:center;justify-content:center}.justify-content-flex-end{-webkit-box-pack:end;-moz-box-pack:end;-webkit-flex-pack:end;-ms-flex-pack:end;-moz-justify-content:flex-end;-webkit-justify-content:flex-end;justify-content:flex-end}.card-footer{padding:.28rem .7rem}.alert{font-size:.756rem}@media screen and (min-width: 992px){.modal-xxl{max-width:1640px}}@media screen and (min-width: 1200px){.modal-xxxl{max-width:1860px}}.modal-fs{max-width:none;position:absolute;margin:auto;inset:16px;height:100vh;display:flex}.btn-link{text-decoration:none}.btn-link:hover{text-decoration:underline}.invalid-feedback{margin-top:0!important;font-size:.672rem!important}
`;var Oe=function(r,e,t,o){var i=arguments.length,n=i<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(r,e,t,o);else for(var s=r.length-1;s>=0;s--)(a=r[s])&&(n=(i<3?a(n):i>3?a(e,t,n):a(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n},d=class extends N{interactionService;sessionService;translated;data;rangeDays;constructor(e,t){super(e,t),this.interactionService=e,this.sessionService=t,this.init()}resetStoredData(){super.resetStoredData()}init(){}setReportData(e,t){this.data=e,this.rangeDays=t;let o=this.getItem();for(let i of this.data)if(!l(i)){if(l(i.total))i.average=0,i.averageInt="0",i.averageDecimal="00";else{i.average=Math.round((i.total/this.rangeDays+Number.EPSILON)*100)/100;let n=i.average.toString().split(".");i.averageInt=n[0],i.averageDecimal=n[1]||"00",n[1]&&n[1].length==1&&(i.averageDecimal=i.averageDecimal+"0")}if(i.average>0?i.percentage=Math.round(100*i.total/o.total+Number.EPSILON)/100:i.percentage=0,!l(i.dayResults)&&!A(i.dayResults)){let n=E(i.dayResults,"count");for(let a of i.dayResults)a.percentage=Math.round(100*a.count/n.count+Number.EPSILON)/100}}return this.data.filter(i=>l(i.parentId))}getSubItems(e){return e.name=="totals"?[]:this.data.filter(t=>t.parentId==e.unitId)}getItem(e=null){let t;return l(e)?t=this.data.find(o=>o.name=="totals"):t=this.data.find(o=>o.unitId==e),t}getItemDays(e,t){let o=this.getItem(e);if(l(o))return null;{let i=new h;return i.createInstance({take:t.take,skip:t.skip,total:o.dayResults.length},h,i),{days:o.dayResults.slice(t.skip,t.skip+t.take),paginationResponse:i}}}static ctorParameters=()=>[{type:S},{type:j}]};d=Oe([k({providedIn:"root"})],d);var de=`<div class="w-100 bg-white rnd-1 ps-3 pe-1 py-1 my-2 d-flex flex-column border border-1 border-light-subtle"\r
    click-stop-propagation\r
    [ngClass]="{'cursor-pointer hover-border-secondary hover-secondary': hasSubList, 'cursor-default': !hasSubList, 'total-item':item.name=='totals'}"\r
    (click)="onItemClick()">\r
    <div class="d-flex align-items-center column-gap-1">\r
        <ng-container *ngIf="hasSubList">\r
            <cds-icon shape="angle" direction="{{collapsed?'right':'down'}}"\r
                class="cds-icon-18 color-gray-darkest"></cds-icon>\r
        </ng-container>\r
        <span>{{(item.name=='totals'?'COMMON.TOTAL':item.name)|translate}}</span>\r
        <div class="d-flex ms-auto">\r
            <div class="d-flex flex-column align-items-end justify-content-center" *ngIf="item.percentage > 0"\r
                nz-tooltip nzTooltipTitle="{{'COMMON.PERCENTAGE_RATIO'|translate}}" nzTooltipPlacement="rightTop">\r
                <span class="color-gray-dark text-md line-height-md">{{item.percentage|percent}}</span>\r
                <div class="d-flex align-items-center justify-content-end" style="width: 200px;">\r
                    <div class="bg-secondary rounded rounded-1"\r
                        [ngClass]="{'bg-success':item.name=='totals', 'bg-secondary':item.name!='totals'}"\r
                        [ngStyle]="{'width': (item.percentage *100)+'%', 'height': '5px'}">\r
                    </div>\r
                </div>\r
            </div>\r
            <div class="d-flex column-gap-1 align-items-baseline" nz-tooltip\r
                nzTooltipTitle="{{'WIDGET.PACS_AVERAGE_TITLE'|translate}} : {{item.average}}">\r
                <div class="d-flex justify-content-end" style="width: 90px;">\r
                    <span class="text-xxl line-height-xxl"\r
                        [ngClass]="{'text-success':item.name=='totals', 'text-secondary':item.name!='totals'}">{{item.averageInt}}</span>\r
                </div>\r
                <div class="d-flex justify-content-start" style="width: 40px;">\r
                    <span class="text-md color-gray-dark">{{item.averageDecimal}}</span>\r
                </div>\r
            </div>\r
        </div>\r
        <div class="d-flex align-items-center justify-content-end" style="width: 30px;">\r
            <div class="icon-btn-container" (click)="onDaysClick()" click-stop-propagation nz-tooltip\r
                *ngIf="item.total>0" nzTooltipTitle="{{'COMMON.DAY_DISTRUBUTION'|translate}}">\r
                <cds-icon shape="calendar" class="cds-icon-18">\r
                </cds-icon>\r
            </div>\r
            <div class="icon-btn-container" (click)="onAccessLogsClick()" click-stop-propagation nz-tooltip\r
                *ngIf="item.total>0" nzTooltipTitle="{{'PAGES.REPORT_ACCESS_LOGS'|translate}}">\r
                <cds-icon shape="report" class="cds-icon-18">\r
                </cds-icon>\r
            </div>\r
        </div>\r
    </div>\r
    <ng-container *ngIf="hasSubList && collapsed==false">\r
        <div class="d-flex flex-column">\r
            <ng-container *ngFor="let item of subList">\r
                <armon-report-organization-access-item [item]="item" (daysClicked)="onDaysClick($event)"\r
                    (accessLogsClicked)="onAccessLogsClick($event)"></armon-report-organization-access-item>\r
            </ng-container>\r
        </div>\r
    </ng-container>\r
</div>`;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}:host{cursor:default}:host .total-item{background-color:#eff6e9!important;border-color:#c0daa8!important}:host .icon-btn-container{cursor:pointer;padding:3px;color:#999}:host .icon-btn-container:hover{color:#0a2a5a}
`;var Ce=function(r,e,t,o){var i=arguments.length,n=i<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(r,e,t,o);else for(var s=r.length-1;s>=0;s--)(a=r[s])&&(n=(i<3?a(n):i>3?a(e,t,n):a(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n},O=class{reportOrganizationAccessService;languageService;item;daysClicked=new I;accessLogsClicked=new I;subList=void 0;collapsed=!0;hasSubList=!1;isTotal=!1;constructor(e,t){this.reportOrganizationAccessService=e,this.languageService=t}ngOnInit(){l(this.item)||(this.item.name=="totals"&&(this.isTotal=!0),this.subList=this.reportOrganizationAccessService.getSubItems(this.item),!l(this.subList)&&this.subList.length>0&&(this.hasSubList=!0))}ngOnDestroy(){}onDaysClick(e){this.daysClicked.emit(e||this.item.unitId)}onAccessLogsClick(e){this.accessLogsClicked.emit(e||this.item.unitId)}onItemClick(){this.collapsed=!this.collapsed}static ctorParameters=()=>[{type:d},{type:x}];static propDecorators={item:[{type:u}],daysClicked:[{type:C}],accessLogsClicked:[{type:C}]}};O=Ce([m({selector:"armon-report-organization-access-item",template:de,standalone:!0,imports:[p,f,_,v,D,J,Q,M,g],styles:[me]})],O);var pe=`<ng-container *ngIf="visibleComponent">
  <div class="modal-header d-flex flex-column align-items-start">
    <span class="text-lg">{{(item.name=='totals'?'COMMON.TOTAL':item.name)|translate}}</span>
    <span class="text-sm">{{rangeText}}</span>
  </div>
  <div class="modal-body bg-color-background mh-vh-60 mxh-vh-70 overflow-y-auto" id="report-organization-access-days">
    <div class="row d-flex flex-column row-gap-1  mb-2">
      <div class="col-12" *ngFor="let day of days">
        <div class="py-1 px-3 d-flex justify-content-between align-items-center b-1 rounded-2 bg-white">
          <span class="text-md">{{day.date|date:'fullDate'}}</span>
          <div class="d-flex ms-auto">
            <div class="d-flex flex-column align-items-end justify-content-center" *ngIf="day.percentage > 0">
              <div class="d-flex align-items-center justify-content-end" style="width: 200px;">
                <div class="bg-secondary rounded rounded-1 bg-secondary"
                  [ngStyle]="{'width': (day.percentage *100)+'%', 'height': '5px'}">
                </div>
              </div>
            </div>
          </div>
          <span class="text-xl text-align-right" style="width: 60px;">{{day.count}}</span>
        </div>
      </div>
    </div>
    <div class="row">
      <div class="col-12">
        <armon-pagination [paginationResponse]="paginationResponse" [scrollDomId]="'report-organization-access-days'"
          (pageChanged)="pageChanged($event)"></armon-pagination>
      </div>
    </div>
  </div>
  <div class="modal-footer">
    <button class="btn btn-outline-primary" autofocus (click)="onCancelClicked($event)">{{'BUTTON.CLOSE' |
      translate}}</button>
  </div>
</ng-container>`;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 _e=function(r,e,t,o){var i=arguments.length,n=i<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(r,e,t,o);else for(var s=r.length-1;s>=0;s--)(a=r[s])&&(n=(i<3?a(n):i>3?a(e,t,n):a(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n},R=class extends U{pacsService;reportOrganizationAccessService;unitId;range;visibleComponent=!1;rangeText=void 0;item=void 0;days;paginationResponse=new h;paginationRequest=new V;constructor(e,t){super(),this.pacsService=e,this.reportOrganizationAccessService=t}onModalInitialized(){super.onModalInitialized(),this.paginationRequest.skip=0,this.paginationRequest.take=L.REQUEST_ITEM_LIMIT,this.rangeText=c.fromISO(this.range.startDateTime).toLocaleString(c.DATE_HUGE)+" - "+c.fromISO(this.range.endDateTime).toLocaleString(c.DATE_HUGE),this.getList(),this.visibleComponent=!0}getList(){this.item=this.reportOrganizationAccessService.getItem(this.unitId);let e=this.reportOrganizationAccessService.getItemDays(this.unitId,this.paginationRequest);l(e)||(this.days=e.days,this.paginationResponse=e.paginationResponse)}pageChanged(e){this.paginationRequest=e,this.getList()}static ctorParameters=()=>[{type:Z},{type:d}];static propDecorators={unitId:[{type:u}],range:[{type:u}]}};R=_e([m({selector:"armon-report-organization-access-days",template:pe,standalone:!0,imports:[p,f,v,ne,z,g],styles:[fe]})],R);var ue=ye(xe());var ze=function(r,e,t,o){var i=arguments.length,n=i<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(r,e,t,o);else for(var s=r.length-1;s>=0;s--)(a=r[s])&&(n=(i<3?a(n):i>3?a(e,t,n):a(e,t))||n);return i>3&&n&&Object.defineProperty(e,t,n),n},ge=class{route;authService;reportService;languageService;modalService;interactionService;routingService;reportOrganizationAccessService;translate;filter;topList;visibleComponent=!1;visibleData=!1;reportTemplateType=B.OrganizationAccess;reportTemplateId;permissionSearchUserGroup;permissionSearchIdentity;permissionSearchOrganizationUnit;datePickerOptions=new $;constructor(e,t,o,i,n,a,s,he,ve){this.route=e,this.authService=t,this.reportService=o,this.languageService=i,this.modalService=n,this.interactionService=a,this.routingService=s,this.reportOrganizationAccessService=he,this.translate=ve}ngOnInit(){this.permissionSearchIdentity=this.authService.checkPermission(y.IDENTITY.getReadBasic()),this.permissionSearchOrganizationUnit=this.authService.checkPermission(y.ORGANIZATIONUNIT.getReadBasic()),this.permissionSearchUserGroup=this.authService.checkPermission(y.USERGROUP.getRead()),this.filter=T.getEmptyModel(),this.datePickerOptions.items=[{type:b.LastMonth,selected:!0},{type:b.Last3Months},{type:b.CustomWithTimer}],this.setDateSelection(q.getDateSelection(this.datePickerOptions.items[0])),this.visibleComponent=!0}ngAfterViewInit(){this.getList()}ngOnDestroy(){}setDateSelection(e){this.filter.dateRange.startDateTime=c.fromJSDate(e.startDate).toFormat("yyyy-MM-dd"),this.filter.dateRange.endDateTime=c.fromJSDate(e.endDate).toFormat("yyyy-MM-dd")}getList(){this.reportService.getOrganizationAccessLogs(this.filter).subscribe(e=>{this.topList=this.reportOrganizationAccessService.setReportData(e.items,c.fromISO(this.filter.dateRange.endDateTime).diff(c.fromISO(this.filter.dateRange.startDateTime),["days"]).toObject().days+1),this.visibleData=!0})}onGetExcelClicked(e){this.reportService.exportOrganizationAccessLogsAsExcel(this.filter).subscribe(t=>{this.translate.get(["PAGES.REPORT_ORGANIZATION_ACCESS"],this.languageService.userTranslate).subscribe(o=>{ue.default.saveAs(t,o["PAGES.REPORT_ORGANIZATION_ACCESS"]+" "+c.fromISO(this.filter.dateRange.startDateTime).toLocaleString(c.DATE_MED)+" "+c.fromISO(this.filter.dateRange.endDateTime).toLocaleString(c.DATE_MED)+".xlsx")})})}refreshList(e=!0){e&&(this.filter.pagination.skip=0),this.getList()}onGetReportClicked(e){this.refreshList()}pageChanged(e){this.filter.pagination=e,this.refreshList(!1)}onDateSelectionChanged(e){this.setDateSelection(e),this.refreshList()}_templateLoading=!1;onTemplateLoaded(e){if(this._templateLoading=!0,e.filter){let t=T.getEmptyModel();t.dateRange=this.filter.dateRange,Object.assign(t,e.filter),this.filter=t}setTimeout(()=>{this.refreshList()},1e3)}onDaysClick(e){this.modalService.open(R,{settings:{size:"lg"},props:{unitId:e,range:{startDateTime:this.filter.dateRange.startDateTime,endDateTime:this.filter.dateRange.endDateTime}}}).result.then(t=>{}).catch(t=>{})}onAccessLogsClick(e){this.interactionService.showDialog("PAGES.REPORT_ACCESS_LOGS","REPORT.ORGANIZATION_ACCESS_LOGS_CONFIRMATION",null,null,!0,"BUTTON.SHOW","",!1,()=>{this.routingService.gotoOrganizationUnitAccessLogs(e,this.filter.dateRange.startDateTime,this.filter.dateRange.endDateTime,{organizationUnitHierarchically:!0,accessControlPointIds:this.filter.accessControlPointIds||void 0,regionIds:this.filter.regionIds||void 0,userGroupIds:this.filter.userGroupIds||void 0})})}static ctorParameters=()=>[{type:w},{type:ie},{type:Y},{type:x},{type:G},{type:S},{type:te},{type:d},{type:P}]};ge=ze([m({selector:"armon-report-organization-access",template:ce,standalone:!0,imports:[f,re,oe,F,p,K,W,ae,H,X,se,ee,g,O],styles:[le]})],ge);export{ge as ReportOrganizationAccessComponent};
