import{a as k,b as M,f as z,g as I,h as D,i as N,m as V,n as pt,o as mt,p as B,s as ft,u as ut,v as F}from"./chunk-JNXLVPIF.js";import{Fa as ct,Ga as dt,a as kt,e as O,l as nt,ta as ot,ua as lt,vb as ht}from"./chunk-YSQLW2JA.js";import"./chunk-NVJ2ZZFT.js";import{Ba as Q,Dc as C,Fc as et,Pd as it,Qf as j,_a as tt,bb as S,cd as E,dd as w,g as Ot,gg as st,ha as K,hg as rt,ma as Z,nd as at,wa as X,ya as R}from"./chunk-SKPDQO4E.js";var gt=`<div class="view-container">
    <div class="row">
        <div class="col-xl-12">
            <armon-date-picker [options]="datePickerOptions" (selectionChanged)="onDateSelectionChanged($event)"
                #datePicker></armon-date-picker>
        </div>
    </div>
    <div class="row d-sm-none">
        <div class="col-xl-12">
            <div class="analysis-direction-container">
                <cds-icon class="analysis-direction-icon" shape="rotate_landscape" size="xxl"></cds-icon>
                <div class="analysis-direction-label">{{'ANALYZE.MOBILE_LANDSCAPE_DIRECTION'|translate}}</div>
            </div>
        </div>
    </div>
    <div class="row d-none d-sm-block" *ngIf="segmentType">
        <div class="col-12">
            <div class="analysis-segment-area">
                <cds-icon shape="bar-chart" class="me-2" size=16></cds-icon>
                <div class="btn-group btn-group-sm filter-button-group">
                    <button class="btn"
                        [ngClass]="{'btn-primary': segmentType==1, 'btn-outline-primary': segmentType!=1}"
                        (click)="onSegmentChanged(1)">{{'REPORT.TEMPLATE_INTERVAL_DAILY' | translate}}</button>
                    <button class="btn"
                        [ngClass]="{'btn-primary': segmentType==2, 'btn-outline-primary': segmentType!=2}"
                        (click)="onSegmentChanged(2)">{{'REPORT.TEMPLATE_INTERVAL_WEEKLY' | translate}}</button>
                    <button class="btn"
                        [ngClass]="{'btn-primary': segmentType==3, 'btn-outline-primary': segmentType!=3}"
                        (click)="onSegmentChanged(3)">{{'REPORT.TEMPLATE_INTERVAL_MONTHLY' | translate}}</button>
                </div>
                <div class="d-flex ms-auto">
                    <button class="btn btn-success btn-sm" (click)="onGetExcelClicked($event)">{{'BUTTON.EXCEL' |
                        translate}}</button>
                </div>
            </div>
        </div>
    </div>
    <div class="row d-none d-sm-block" *ngIf="visiblePointsChart">
        <div class="col-12">
            <div class="analysis-bar-chart-container">
                <div class="header-area">
                    <span class="title">{{'ANALYZE.VISIT_COUNTS_VISITOR_POINT'|translate}}</span>
                    <span class="sub-title">{{'COMMON.TOTAL'|translate}}&nbsp;{{pointTotal}}</span>
                </div>
                <div class="chart-area">
                    <d3-stacked-bar-chart [chartData]="pointChartData" [chartOptions]="stackedBarChartOptions">
                    </d3-stacked-bar-chart>
                </div>
            </div>
        </div>
    </div>
    <div class="row d-none d-sm-block" *ngIf="visibleReasonsChart">
        <div class="col-12">
            <div class="analysis-bar-chart-container">
                <div class="header-area">
                    <span class="title">{{'ANALYZE.VISIT_COUNTS_VISITOR_REASON'|translate}}</span>
                    <span class="sub-title">{{'COMMON.TOTAL'|translate}}&nbsp;{{reasonTotal}}</span>
                </div>
                <div class="chart-area">
                    <d3-stacked-bar-chart [chartData]="reasonChartData" [chartOptions]="stackedBarChartOptions">
                    </d3-stacked-bar-chart>
                </div>
            </div>
        </div>
    </div>
    <div class="row d-none d-sm-block" *ngIf="visiblePointTimeChart">
        <div class="col-12">
            <div class="analysis-bar-chart-container">
                <div class="header-area">
                    <span class="title">{{'ANALYZE.VISITOR_PROCESS_TIME_POINT'|translate}}</span>
                </div>
                <div class="chart-area">
                    <d3-line-chart [chartData]="pointTimeChartData" [chartLabels]="pointTimeChartLabels"
                        [chartOptions]="timeChartOptions"></d3-line-chart>
                </div>
            </div>
        </div>
    </div>
    <div class="row d-none d-sm-block" *ngIf="visibleReasonTimeChart">
        <div class="col-12">
            <div class="analysis-bar-chart-container">
                <div class="header-area">
                    <span class="title">{{'ANALYZE.VISITOR_PROCESS_TIME_REASON'|translate}}</span>
                </div>
                <div class="chart-area">
                    <d3-line-chart [chartData]="reasonTimeChartData" [chartLabels]="reasonTimeChartLabels"
                        [chartOptions]="timeChartOptions"></d3-line-chart>
                </div>
            </div>
        </div>
    </div>
</div>`;var vt=`.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 yt=`<div class="w-100 h-100 pos-relative">
    <div #container class="chart-container"></div>
    <div class="d3-nodata-overlay" *ngIf="visibleNoDataOverlay">
        <div>
            <span>{{'CHART.NO_DATA'|translate}}</span>
        </div>
    </div>
</div>
`;var bt=`.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{width:100%;height:100%}:host .chart-container{width:100%;height:100%}:host::ng-deep .line{fill:none;stroke-width:1}:host::ng-deep .dot{stroke:#fff;cursor:pointer}:host::ng-deep .legend-item{cursor:pointer;stroke-width:2}
`;var _t=function(g,t,e,s){var l=arguments.length,a=l<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(g,t,e,s);else for(var i=g.length-1;i>=0;i--)(r=g[i])&&(a=(l<3?r(a):l>3?r(t,e,a):r(t,e))||a);return l>3&&a&&Object.defineProperty(t,e,a),a},U=class extends F{interactionService;translate;radius;translated;defaultChartOptions={type:k.LineChart,drawAfterResize:!0,marginTop:20,marginBottom:50,marginLeft:40,marginRight:20,legendWidth:140,legendAnimationDuration:300,tooltipAnimationDuration:300};valueClicked=new K;constructor(t,e){super(t),this.interactionService=t,this.translate=e,this.chart=this}onInit(){}onDestroy(){}onDataUpdated(){this.drawChart()}onColorsUpdated(){this.drawChart()}onLabelsUpdated(){this.drawChart()}onOptionsUpdated(){this.drawChart()}onAfterViewInit(){this.translate.get(["COMMON.ALL"]).subscribe(t=>{this.translated=t,this.drawChart()})}onResized(){this.defaultChartOptions.drawAfterResize&&this.drawChart()}drawChart(){let t=this.chartData;if(Object.assign(this.defaultChartOptions,this.chartOptions),!t||!t.values||t.values.length==0)return;this.host.html("");let e=!0;t.values.forEach(o=>{o.findIndex(c=>c!=0)>-1&&(e=!1)}),this.noDataOverlay=e;let s={top:this.defaultChartOptions.marginTop,right:this.defaultChartOptions.marginRight,bottom:this.defaultChartOptions.marginBottom,left:this.defaultChartOptions.marginLeft};this.svg=this.host.append("svg").attr("width","100%").attr("height","100%");let l=this.host.node().getBoundingClientRect(),a=l.width-s.left-s.right-this.defaultChartOptions.legendWidth,r=l.height-s.top-s.bottom,i;D("body").select(".tooltip-d3-chart").empty()?i=D("body").append("div").attr("class","tooltip-d3-chart"):i=D("body").select(".tooltip-d3-chart"),i.style("opacity",0);let h=this.svg.append("g").attr("transform","translate("+s.left+","+s.top+")"),n=mt().domain(this.chartLabels.labels).range([0,a]),f=M(t.values,o=>M(o)),p=B().domain([0,f]).range([r,0]),v=V().range(this.colorSchemeCategory).domain(t.keys),A=ft().x((o,c)=>n(this.chartLabels.labels[c])).y(o=>p(o)).curve(ut);h.append("g").attr("class","x axis").attr("transform","translate(0,"+r+")").call(z(n)).selectAll("text").attr("x",-35).attr("text-anchor","start").attr("transform","rotate(-45)"),h.append("g").attr("class","y axis").call(I(p));let W=o=>{t.keys.forEach((c,m)=>{m==o?_(m,1):_(m,.1)})},H=()=>{t.keys.forEach((o,c)=>{_(c,1)})},_=(o,c)=>{h.select("#line"+o).transition().duration(this.defaultChartOptions.tooltipAnimationDuration).style("opacity",c),h.select("#dots"+o).transition().duration(this.defaultChartOptions.tooltipAnimationDuration).style("opacity",c)};t.values.forEach((o,c)=>{h.append("path").datum(o).attr("class","line").attr("id","line"+c).attr("stroke",(m,y)=>v(t.keys[c])).attr("d",A),h.append("g").attr("id","dots"+c).selectAll("g").data(o).enter().append("circle").attr("class","dot").attr("fill",(m,y)=>v(t.keys[c])).attr("cx",(m,y)=>n(this.chartLabels.labels[y])).attr("cy",(m,y)=>p(m)).attr("r",5).on("mouseover",(m,y)=>{if(i){let $=this.defaultChartOptions.tooltipFunction?this.defaultChartOptions.tooltipFunction(y):y;i.html("<span class='title'>"+t.keys[c]+"</span><span>"+$+"</span>").style("border-left-color",v(t.keys[c])).style("opacity",1).style("left",m.pageX+15+"px").style("top",m.pageY-15+"px"),W(c)}}).on("mouseout",m=>{i&&(i.style("opacity",0),H())})});let b=[],T=(o,c)=>{c?b.splice(b.indexOf(o),1):b.findIndex(m=>m==o)==-1&&b.push(o),h.select("#line"+o).transition().duration(this.defaultChartOptions.legendAnimationDuration).attr("visibility",c?"visible":"hidden"),h.select("#dots"+o).transition().duration(this.defaultChartOptions.legendAnimationDuration).attr("visibility",c?"visible":"hidden"),h.select("#legend"+o).style("fill",c?v(t.keys[o]):"#FFF")},J=o=>{T(o,b.indexOf(o)>-1),d()},x=!0,q=()=>(t.keys.forEach((o,c)=>{T(c,!x)}),d(),x),d=()=>{let o;b.length==0?(o="#000",x=!0):b.length==t.keys.length?(x=!1,o="#FFF"):o="#dbdbdb",h.select("#legendall").style("fill",o)},u=N(),L=o=>{let c=o.attr("font-size",this.baseChartOptions.legendFontSize).attr("text-anchor","end").selectAll("g").data(t.keys).enter().append("g").attr("transform",(m,y)=>`translate(0,${y*16+20})`);c.append("rect").attr("x",-12).attr("width",12).attr("height",12).attr("fill",v).attr("stroke",v).attr("id",(m,y)=>"legend"+y).each(function(m,y){u.set(this,y)}).attr("class","legend-item").on("click",function(m,y){let $=u.get(this);J($)}),c.append("text").attr("x",-20).attr("y",8).attr("dy",3).text(m=>m)},P=h.append("g").attr("transform",`translate(${a+this.defaultChartOptions.legendWidth},0)`).call(L);P.attr("font-size",this.baseChartOptions.legendFontSize).attr("text-anchor","end").append("g").attr("transform",(o,c)=>"translate(0,0"),P.append("rect").attr("x",-12).attr("width",12).attr("height",12).attr("fill","#000").attr("stroke","#000").attr("class","legend-item").attr("id","legendall").on("click",()=>{q()}),P.append("text").attr("x",-20).attr("y",8).attr("dy",3).text(this.translated["COMMON.ALL"])}static ctorParameters=()=>[{type:j},{type:E}];static propDecorators={valueClicked:[{type:Q}]}};U=_t([R({selector:"d3-line-chart",template:yt,standalone:!0,imports:[S,w],styles:[bt]})],U);var Ct=`<div class="w-100 h-100 pos-relative">
    <div #container class="chart-container"></div>
    <div class="d3-nodata-overlay" *ngIf="visibleNoDataOverlay">
        <div>
            <span>{{'CHART.NO_DATA'|translate}}</span>
        </div>
    </div>
</div>

`;var Tt=`.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{width:100%;height:100%}:host .chart-container{width:100%;height:100%}:host::ng-deep .axis-x .tick text{font-size:.32rem}:host::ng-deep .mean{stroke-width:1px;stroke:#0a2a5a;stroke-dasharray:2}
`;var Mt=function(g,t,e,s){var l=arguments.length,a=l<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(g,t,e,s);else for(var i=g.length-1;i>=0;i--)(r=g[i])&&(a=(l<3?r(a):l>3?r(t,e,a):r(t,e))||a);return l>3&&a&&Object.defineProperty(t,e,a),a},Y=class extends F{interactionService;translate;totalString;defaultChartOptions={type:k.StackedBarChart,drawAfterResize:!0,marginTop:20,marginBottom:50,marginLeft:40,marginRight:20,legendWidth:140,legendAnimationDuration:300,tooltipAnimationDuration:300};constructor(t,e){super(t),this.interactionService=t,this.translate=e,this.chart=this}onInit(){this.translate.get(["COMMON.TOTAL"]).subscribe(t=>{this.totalString=t["COMMON.TOTAL"]})}onDestroy(){}onDataUpdated(){this.drawChart()}onColorsUpdated(){this.drawChart()}onLabelsUpdated(){this.drawChart()}onOptionsUpdated(){this.drawChart()}onAfterViewInit(){this.drawChart()}onResized(){this.drawChart()}drawChart(){let t=this.chartData.chartValues,e=this.chartData.chartKeys,s=this.chartData.chartNames,l=this.chartData.chartTotals;this.host.html(""),Object.assign(this.defaultChartOptions,this.chartOptions),this.noDataOverlay=l.findIndex(d=>d!=0)==-1;let a={top:this.defaultChartOptions.marginTop,right:this.defaultChartOptions.marginRight,bottom:this.defaultChartOptions.marginBottom,left:this.defaultChartOptions.marginLeft};this.svg=this.host.append("svg").attr("width","100%").attr("height","100%");var r=this.host.node().getBoundingClientRect();let i=r.width-a.left-a.right-this.defaultChartOptions.legendWidth,h=r.height-a.top-a.bottom,n=this.svg.append("g").attr("transform","translate("+a.left+","+a.top+")"),f;D("body").select(".tooltip-d3-chart").empty()?f=D("body").append("div").attr("class","tooltip-d3-chart"):f=D("body").select(".tooltip-d3-chart"),f.style("opacity",0);let p=pt().domain(s).range([0,i]).padding(.1),v=B().domain([0,M(l)]).rangeRound([h,0]),A=V().range(this.colorSchemeCategory).domain(e),W=d=>d.attr("transform",`translate(0,${h})`).call(z(p).tickSizeOuter(0)).selectAll("text").attr("x",-35).attr("text-anchor","start").attr("transform","rotate(-45)"),H=d=>d.call(I(v).ticks(null)),_=d=>{let u=d.attr("font-size",this.baseChartOptions.legendFontSize).attr("text-anchor","end").selectAll("g").data(e.slice()).enter().append("g").attr("transform",(L,P)=>`translate(0,${P*16})`);u.append("rect").attr("x",-12).attr("width",12).attr("height",12).attr("fill",A),u.append("text").attr("x",-20).attr("y",8).attr("dy",3).text(L=>L)};var b,T;let J=this.totalString,x=N(),q=N();n.append("g").selectAll("g").data(t).enter().append("g").each(function(d,u){x.set(this,u)}).on("mouseover",function(d){let u=x.get(this);f&&f.html("<span class='title'>"+e[u]+" : "+(T[1]-T[0])+"</span><span>"+J+" : "+l[b]+"</span><span>% "+Math.round((T[1]-T[0])/l[b]*100)+"</span>").style("opacity",1).style("border-left-color",A(e[u])).style("left",d.pageX+15+"px").style("top",d.pageY-15+"px")}).on("mouseout",(d,u)=>{f&&f.style("opacity",0)}).attr("fill",(d,u)=>A(e[u])).selectAll("rect").data(d=>d).enter().append("rect").each(function(d,u){q.set(this,u)}).on("mouseover",function(d,u){b=q.get(this),T=u}).attr("x",(d,u)=>p(s[u])).attr("y",d=>v(d[1])).attr("height",d=>v(d[0])-v(d[1])).attr("width",p.bandwidth()),n.append("g").call(W),n.append("g").call(H),n.append("g").attr("transform",`translate(${i+this.defaultChartOptions.legendWidth},0)`).call(_)}static ctorParameters=()=>[{type:j},{type:E}]};Y=Mt([R({selector:"d3-stacked-bar-chart",template:Ct,standalone:!0,imports:[S,w],styles:[Tt]})],Y);var G=class g extends et{startDate;endDate;segmentType;static getEmptyModel(){let t=new g;return t.segmentType=O.Daily,t}};var xt=Ot(kt()),Nt=function(g,t,e,s){var l=arguments.length,a=l<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,e):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(g,t,e,s);else for(var i=g.length-1;i>=0;i--)(r=g[i])&&(a=(l<3?r(a):l>3?r(t,e,a):r(t,e))||a);return l>3&&a&&Object.defineProperty(t,e,a),a},Dt=class{translate;visitorService;sessionService;visibleComponent=!1;segmentType=O.Daily;translated;datePicker;datePickerOptions=new rt;stackedBarChartOptions={type:k.StackedBarChart,marginLeft:50};pointRequest;pointChartData;pointTotal;registrationPoints;visiblePointsChart=!1;reasonRequest;reasonChartData;reasonTotal;visibleReasonsChart=!1;reasons;excelRequest;timeChartOptions={type:k.LineChart,tooltipFunction:t=>parseFloat(t).toFixed(2)+" "+this.translated["COMMON.SECONDS"]};pointTimeRequest;pointTimeChartData;pointTimeChartLabels;visiblePointTimeChart=!1;reasonTimeRequest;reasonTimeChartData;reasonTimeChartLabels;visibleReasonTimeChart=!1;constructor(t,e,s){this.translate=t,this.visitorService=e,this.sessionService=s}ngOnInit(){this.pointRequest=ot.getEmptyModel(),this.registrationPoints=this.visitorService.availableRegistrationPoints,this.reasonRequest=lt.getEmptyModel();let t=this.sessionService.currentOrganization.visitorModuleSettings.visitFormFields.filter(e=>e.name==at.VISIT.Reason)[0];this.reasons=t.options.options,this.pointTimeRequest=dt.getEmptyModel(),this.reasonTimeRequest=ct.getEmptyModel(),this.excelRequest=G.getEmptyModel(),this.datePickerOptions.items=[{type:st.Custom,selected:!0}]}ngAfterViewInit(){this.setDateSelection(this.datePicker.setPickerItemAndDate(0,[C.local().minus({days:30}).startOf("day").toJSDate(),C.local().endOf("day").toJSDate()])),this.getTranslations()}ngOnDestroy(){}onDateSelectionChanged(t){this.setDateSelection(t),this.getData()}setDateSelection(t){this.pointRequest.startDate=t.startDate,this.pointRequest.endDate=t.endDate,this.reasonRequest.startDate=t.startDate,this.reasonRequest.endDate=t.endDate,this.pointTimeRequest.startDate=t.startDate,this.pointTimeRequest.endDate=t.endDate,this.reasonTimeRequest.startDate=t.startDate,this.reasonTimeRequest.endDate=t.endDate,this.excelRequest.startDate=t.startDate,this.excelRequest.endDate=t.endDate}getTranslations(){this.translate.get(["COMMON.SECONDS"]).subscribe(t=>{this.translated=t,this.getData()})}getData(){this.visitorService.getCountByVisitorPointAnalysis(this.pointRequest).subscribe(t=>{this.setPointsChartData(t)}),this.visitorService.getCountByReasonAnalysis(this.reasonRequest).subscribe(t=>{this.setReasonChartData(t)}),this.visitorService.getProcessTimeByVisitorPointAnalysis(this.pointTimeRequest).subscribe(t=>{this.setPointTimeChartData(t)}),this.visitorService.getProcessTimeByReasonAnalysis(this.reasonTimeRequest).subscribe(t=>{this.setReasonTimeChartData(t)})}getSegmentLabel(t,e){switch(t){case O.Daily:return C.fromJSDate(e).toFormat("d MMM");case O.Weekly:return C.fromJSDate(e).toFormat("d MMM");case O.Monthly:return C.fromJSDate(e).toFormat("MMMM")}}setPointsChartData(t){let e=[],s=[];this.registrationPoints.forEach((r,i)=>{e[i]=[],t.items.forEach((h,n)=>{e[i][n]=[];let f=h.data.find(v=>v.visitorRegistrationPointId==r.id),p;f?p=f.count:p=0,i==0?(e[i][n][0]=0,e[i][n][1]=p):(e[i][n][0]=e[i-1][n][1],e[i][n][1]=e[i-1][n][1]+p),s[n]=s[n]?s[n]+p:p})}),this.pointTotal=s.reduce((r,i)=>r+i,0);let l=[];t.items.forEach(r=>{t.items.forEach(i=>{l.push(this.getSegmentLabel(this.pointRequest.segmentType,i.startDate))})});let a=[];this.registrationPoints.forEach(r=>{a.push(r.name)}),this.pointChartData={chartValues:e,chartKeys:a,chartNames:l,chartTotals:s},this.visiblePointsChart=!0}setReasonChartData(t){let e=[],s=[];this.reasons.forEach((r,i)=>{e[i]=[],t.items.forEach((h,n)=>{e[i][n]=[];let f=h.data.find(v=>v.reason==r.value),p;f?p=f.count:p=0,i==0?(e[i][n][0]=0,e[i][n][1]=p):(e[i][n][0]=e[i-1][n][1],e[i][n][1]=e[i-1][n][1]+p),s[n]=s[n]?s[n]+p:p})}),this.reasonTotal=s.reduce((r,i)=>r+i,0);let l=[];t.items.forEach(r=>{l.push(this.getSegmentLabel(this.reasonRequest.segmentType,r.startDate))});let a=[];this.reasons.forEach(r=>{a.push(r.captionLines[0])}),this.reasonChartData={chartValues:e,chartKeys:a,chartNames:l,chartTotals:s},this.visibleReasonsChart=!0}onSegmentChanged(t){this.segmentType=t,this.pointRequest.segmentType=t,this.reasonRequest.segmentType=t,this.pointTimeRequest.segmentType=t,this.reasonTimeRequest.segmentType=t,this.excelRequest.segmentType=t,this.getData()}setPointTimeChartData(t){let e=[];this.registrationPoints.forEach((a,r)=>{e[r]=[],t.items.forEach((i,h)=>{let n=i.data.find(f=>f.visitorRegistrationPointId==a.id);e[r][h]=n&&n.averageProcessTime?n.averageProcessTime:0})});let s=[];t.items.forEach(a=>{t.items.forEach(r=>{s.push(this.getSegmentLabel(this.pointRequest.segmentType,r.startDate))})});let l=[];this.registrationPoints.forEach(a=>{l.push(a.name)}),this.pointTimeChartData={values:e,keys:l},this.pointTimeChartLabels={labels:s},this.visiblePointTimeChart=!0}setReasonTimeChartData(t){let e=[];this.reasons.forEach((a,r)=>{e[r]=[],t.items.forEach((i,h)=>{let n=i.data.find(f=>f.reason==a.value);e[r][h]=n&&n.averageProcessTime?n.averageProcessTime:0})});let s=[];t.items.forEach(a=>{t.items.forEach(r=>{s.push(this.getSegmentLabel(this.pointRequest.segmentType,r.startDate))})});let l=[];this.reasons.forEach(a=>{l.push(a.captionLines[0])}),this.reasonTimeChartData={values:e,keys:l},this.reasonTimeChartLabels={labels:s},this.visibleReasonTimeChart=!0}onGetExcelClicked(t){this.visitorService.getVisitorAnalysisAsExcel(this.excelRequest).subscribe(e=>{this.translate.get(["PAGES.ANALYSIS_VISITORS_TITLE"]).subscribe(s=>{xt.default.saveAs(e,s["PAGES.ANALYSIS_VISITORS_TITLE"]+" "+C.fromJSDate(this.excelRequest.startDate).toLocaleString(C.DATETIME_MED)+" "+C.fromJSDate(this.excelRequest.endDate).toLocaleString(C.DATETIME_MED)+".xlsx")})})}static ctorParameters=()=>[{type:E},{type:ht},{type:it}];static propDecorators={datePicker:[{type:X,args:["datePicker",{static:!0}]}]}};Dt=Nt([R({selector:"armon-analysis-visitors",template:gt,schemas:[Z],standalone:!0,imports:[nt,S,tt,Y,U,w],styles:[vt]})],Dt);export{Dt as AnalysisVisitorsComponent};
