1import{a as $}from"./chunk-4GVHNOFT.js";import{a as J}from"./chunk-NI37FYAP.js";import{a as N,b as G,c as X}from"./chunk-ZV4XERJ2.js";import{a as _}from"./chunk-MIHC4Y75.js";import"./chunk-SB5L2XE4.js";import{D as V,c as H,g as W,l as O}from"./chunk-ICJV4PL6.js";import{a as Y}from"./chunk-RIRGXRXY.js";import"./chunk-3GN2FC7K.js";import{t as j}from"./chunk-47CSRN7C.js";import{a as A,c as U}from"./chunk-SKH2MXBC.js";import{J as P,v as z}from"./chunk-BQLJE42W.js";import{$b as F,B as d,Dc as L,Ib as w,O as B,Ra as E,Tb as f,V as I,Xa as m,Ya as l,Zb as D,_ as T,_b as R,ac as C,bc as M,c as v,da as x,mb as p,p as b,v as k,xb as h,yb as g,zb as y}from"./chunk-YE3BF7DR.js";import{e as Q}from"./chunk-4IDNTCH7.js";var K=Q(X());var u=class c{constructor(e){this.http=e}get(){return this.http.get("/api/v1/indicators/")}static \u0275fac=function(t){return new(t||c)(T(A))};static \u0275prov=I({token:c,factory:c.\u0275fac,providedIn:"root"})};var q=class c{constructor(e,t,i,n,r,s,a){this.settingService=e;this.sanitizer=t;this.siteScoreService=i;this.indicatorsService=n;this.helperService=r;this.sharedSignalsService=s;this.modalService=a;L(()=>{this.isAuthorized=this.sharedSignalsService.isAuthorized(),this.progressFile=this.sharedSignalsService.progressFile()})}locale=K.Spanish;dateRange;model={};url;siteScore;availableDates;selectableDates;indicators;modelScore;activeSelector=!1;historyPoints;fullList;processingRanking=!1;chartsLoaded=!1;fullListByType;processingRankingByType;ranking;upBtnEnabled;downBtnEnabled;centerBtnEnabled;rankingByType;upBtnByTypeEnabled;downBtnByTypeEnabled;centerBtnByTypeEnabled;rankingIndex;rankingIndexByType;isAuthorized=!1;typeRanking=0;progressFile;ngOnInit(){this.activate()}activate(){let e=new Date,t=new Date,i=(n,r)=>(n.setDate(n.getDate()+r),n.toISOString().split("T")[0]);this.dateRange={from:i(e,-30),to:i(t,0)},this.setUrl(this.dateRange.from,this.dateRange.to),this.model.imageUrl=this.settingService.settings.general.statictsFile}setUrl(e,t){this.settingService.settings.general.piwikUrl&&(this.url=this.sanitizer.bypassSecurityTrustResourceUrl(`${this.settingService.settings.general.piwikUrl}/index.php?module=Widgetize&action=iframe&containerId=VisitorsSummaryWithGraph&widget=1&moduleToWidgetize=CoreHome&actionToWidgetize=renderWidgetContainer&idSite=${this.settingService.settings.general.analyticsCode}&period=range&date=${e},${t}&disableLink=1&widget=1`))}getScores(){if(this.processingRanking=!0,this.processingRankingByType=!0,this.rankingIndex=0,this.rankingIndexByType=0,this.dateRange&&this.dateRange.from&&this.dateRange.to){let e=this.dateRange.from,t=this.dateRange.to,i=(n,r)=>(n.setDate(n.getDate()+r),n.toISOString().split("T")[0]);this.dateRange={from:i(e,0),to:i(t,0)},this.setUrl(this.dateRange.from,this.dateRange.to)}}buildScores(){this.siteScoreService.get({}).subscribe({next:e=>{this.siteScore=e,this.getDates()},error:e=>{console.log(e)}})}getDates(){this.siteScoreService.getDates().pipe(b(e=>(this.availableDates=e,this.selectableDates=e.map(t=>t.dateStr),e)),B(()=>this.indicatorsService.get()),d(e=>(console.log(e),[]))).subscribe(e=>{this.indicators=e.map(a=>({indicator:a,score:{}}));let t=parseInt(this.modelScore.date,10),i=this.availableDates[t];this.activeSelector=!1;let n=i.year,r=i.month,s=i.week;k({siteScore:this.siteScoreService.get({year:n,month:r,week:s}),indicatorScores:this.siteScoreService.getIndicatorScores({year:n,month:r,week:s}),ranking:this.siteScoreService.getRanking({year:n,month:r,week:s})}).pipe(d(a=>(console.log(a),[]))).subscribe({next:({siteScore:a,indicatorScores:S,ranking:o})=>{this.setSiteScore(a),this.setIndicatorScores(S),this.setRanking(o)},error:a=>console.log(a)})})}setSiteScore(e){this.siteScore=e;let t={year:this.siteScore.year,month:this.siteScore.month,week:this.siteScore.week,amountPoints:4};this.siteScoreService.getHistory(t).pipe(d(s=>(console.log(s),[]))).subscribe(s=>{this.historyPoints=s;let a=[["Mes","Puntos",{role:"style"}]];this.historyPoints.forEach(o=>{a.push([o.dateStr,o.score,"opacity: 1"])});let S={legend:{position:"none"}
1,height:320,pointsVisible:!0,pointShape:"circle",pointSize:10,colors:["#FFFFFF"],chartArea:{backgroundColor:{fill:"#005ECA"}},backgroundColor:{fill:"#005ECA"},hAxis:{textStyle:{color:"#FFFFFF"}},vAxis:{textStyle:{color:"#FFFFFF"}}};this.isPrepareGoogle().pipe(d(o=>(console.log(o),[]))).subscribe(()=>{let o=google.visualization.arrayToDataTable(a);new google.visualization.LineChart(document.getElementById("columnchart_values")).draw(o,S)})});let i=parseInt(this.modelScore.date,10),n=this.availableDates[i],r={year:n.year,month:n.month,week:n.week,siteTypeID:this.siteScore.siteTypeId};this.siteScoreService.getRanking(r).pipe(d(s=>(console.log(s),[]))).subscribe(s=>{this.setRankingByType(s)})}setIndicatorScores(e){this.activeSelector=!0,e.forEach(t=>{let i=this.indicators.find(n=>n.indicator.indicatorId===t.indicatorId);i&&(i.score=t)})}setRanking(e){this.fullList=e,this.partialRanking(1,"center"),this.processingRanking=!1}isPrepareGoogle(){return new v(e=>{this.helperService.loadScript("https://www.gstatic.com/charts/loader.js","google-ch").subscribe({next:()=>{this.chartsLoaded?(e.next(),e.complete()):google.charts.load("current",{packages:["corechart","line"],callback:()=>{this.chartsLoaded=!0,e.next(),e.complete()}})},error:t=>{console.error(t)}})})}setRankingByType(e){this.fullListByType=e,this.partialRanking(2,"center"),this.processingRankingByType=!1}partialRanking(e,t){let i=e===1?this.fullList.length:this.fullListByType.length;if(i<=5){e===1?(this.ranking=this.fullList,this.upBtnEnabled=!1,this.downBtnEnabled=!1,this.centerBtnEnabled=!1):(this.rankingByType=this.fullListByType,this.upBtnByTypeEnabled=!1,this.downBtnByTypeEnabled=!1,this.centerBtnByTypeEnabled=!1);return}let n=e===1?this.currentPosition(this.fullList):this.currentPosition(this.fullListByType);switch(t){case"center":n<=2?e===1?this.rankingIndex=0:this.rankingIndexByType=0:n>=i-3?e===1?this.rankingIndex=i-5:this.rankingIndexByType=i-5:e===1?this.rankingIndex=n-2:this.rankingIndexByType=n-2;break;case"up":e===1?this.rankingIndex=this.rankingIndex<=5?0:this.rankingIndex-5:this.rankingIndexByType=this.rankingIndexByType<=5?0:this.rankingIndexByType-5;break;case"down":e===1?this.rankingIndex=this.rankingIndex+10>i?i-5:this.rankingIndex+5:this.rankingIndexByType=this.rankingIndexByType+10>i?i-5:this.rankingIndexByType+5;break}let r=e===1?this.rankingIndex:this.rankingIndexByType;r===0?e===1?(this.upBtnEnabled=!1,this.downBtnEnabled=!0):(this.upBtnByTypeEnabled=!1,this.downBtnByTypeEnabled=!0):r>=i-5?e===1?(this.upBtnEnabled=!0,this.downBtnEnabled=!1):(this.upBtnByTypeEnabled=!0,this.downBtnByTypeEnabled=!1):e===1?(this.upBtnEnabled=!0,this.downBtnEnabled=!0):(this.upBtnByTypeEnabled=!0,this.downBtnByTypeEnabled=!0),e===1?(this.ranking=this.copyArray(this.rankingIndex,5,this.fullList),this.centerBtnEnabled=!this.arrayContainsSite(this.ranking)):(this.rankingByType=this.copyArray(this.rankingIndexByType,5,this.fullListByType),this.centerBtnByTypeEnabled=!this.arrayContainsSite(this.rankingByType))}currentPosition(e){for(let t=0;t<e.length;t++)if(e[t].current)return t;return 0}arrayContainsSite(e){for(let t=0;t<e.length;t++)if(e[t].current)return!0;return!1}copyArray(e,t,i){let n=[],r=e+t;for(let s=e;s<r&&s<i.length;s++)n.push({rank:i[s].rank,siteName:i[s].siteName,current:i[s].current});return n}setAnalyticsDates(){this.setUrl(this.dateRange.from.format("YYYY-MM-DD"),this.dateRange.to.format("YYYY-MM-DD"))}navigate(e,t){e===1&&this.processingRanking||e===2&&this.processingRankingByType||this.partialRanking(e,t)}endupload(){this.isAuthorized?this.settingService.get({keyword:"GeneralSettings.StatictsFile"}).subscribe({next:e=>this.setSetting(e),error:e=>console.error(e)}):this.model.imageUrl=this.settingService.settings.general.statictsFile}setSetting(e){if(e.results&&e.results.length){let t=e.results[0];t.value=this.model.imageUrl,this.settingService.settings.general.statictsFile=this.model.imageUrl,this.settingService.update(t).subscribe({next:()=>this.updateSetting(),error:i=>console.error(i)})}}updateSetting(){this.modalService.showAlert("File uploaded successfully")}static \u0275fac=function(t){return new(t||c)(l(U),l(P),l($),l(u),l(Y),l(_),l(j))};static \u0275cmp=x({type:c,selectors:[["app-statistics"]],standalone:!0,features:[C([G()]),M],decls:11,vars:6,consts:[[1,"content_all"],[3,"seedValue"],[1,"section-tit"],[1,"estadistic-label"],["mwlFlatpickr","","type","text","name","selectedDate","altFormat","Y-m-d","dateFormat","Y-m-d","mode","range",1,"metrics-picker","border","border-gray-400","important!",3,"ngModelChange","locale","ngModel","altInput","convertModelValue"],["frameborder","0","scrolling","no",2,"width","100%","min-height","500px","background-color","transparent",3,"src"]],template:function(t,i){t&1&&(h(0,"section",0),y(1,"app-seed",1),h(2,"h2",2),f(3,"Estad\xEDsticas"),g(),h(4,"label",3),f(5,"Rango de fechas"),g(),y(6,"br")(7,"br"),h(8,"input",4),F("ngModelChange",function(r){return R(i.dateRange,r)||(i.dateRange=r),r}),w("ngModelChange",function(){return i.getScores()}),g(),h(9,"div"),y(10,"iframe",5),g()()),t&2&&(m(),p("seedValue","Estad\xEDsticas"),m(7),p("locale",i.locale),D("ngModel",i.dateRange),p("altInput",!0)("convertModelValue",!0),m(2),p("src",i.url,E))},dependencies:[z,J,V,H,W,O,N]})};export{q as StatisticsComponent};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.