import{a as $}from"./chunk-C7V3KKPV.js";import{A as S,B as P,G as U,i as A}from"./chunk-2YE7XEKS.js";import{$d as y,Vd as b,Wd as f,_d as v,a as p,b as l,ba as c,ie as d,ka as m,pa as g,r as R,w as u,x as h}from"./chunk-UNHECMG2.js";var j=y({Id:f,Title:b}),C=d(v(j));var H=(()=>{class a{constructor(){this.settings=g(S),this.http=g(A)}getPersonMasterDataReports(t){return this.getAvailableReports("Person",this.settings.personMasterDataReports,[t])}getStudentConfirmationReports(t){return this.getAvailableReports("Praesenzinformation",this.settings.studentConfirmationReports,t)}getEvaluateAbsencesReports(t){return this.getAvailableReports("Praesenzinformation",this.settings.evaluateAbsencesReports,t)}getMyAbsencesReports(t){return this.getAvailableReports("Praesenzinformation",this.settings.myAbsencesReports,t)}getCourseTestsReports(t){return this.getAvailableReports("Anlass",this.settings.testsByCourseReports,[t])}getEvaluationReports(t){return this.getAvailableReports("Anlass",this.settings.evaluationReports,[t])}getEvaluationVerifyReportUrl(t){let{type:r,id:e}=this.settings.evaluationVerifyReport;return this.getReportUrl(r,"Anlass",e,[t])}getStudentSubscriptionGradesReports(t){return this.settings.testsBySubscriptionStudentReports.map((e,i)=>{let s=this.getReportUrl(e.type,"Anmeldung",e.id,t);return l(p({},e),{title:`Report ${i+1}`,url:s})})}getTeacherSubscriptionGradesReports(t){return this.settings.testsBySubscriptionTeacherReports.map((e,i)=>{let s=this.getReportUrl(e.type,"Anmeldung",e.id,t);return l(p({},e),{title:`Report ${i+1}`,url:s})})}getStudyClassStudentsReports(t){return this.getAvailableReports("Anlass",this.settings.studyClassStudentsReports,[t])}getCourseStudentsReports(t){return this.getAvailableReports("Anlass",this.settings.courseStudentsReports,[t])}getAvailableReports(t,r,e){let i=U(r,o=>o.type),s=h(Object.keys(i).map(o=>this.getAvailableReportsForType(o,t,i[o].map(({id:n})=>n),e)));return this.mergeAvailableReports(s,r)}getAvailableReportsForType(t,r,e,i){return i.length===0?R([]):this.http.get(this.getReportAvailabilityUrl(t,r,e,i)).pipe(c($(C)),u(s=>s?s.map(({Id:o,Title:n})=>({type:t,id:o,title:n,url:this.getReportUrl(t,r,o,i)})):[]))}mergeAvailableReports(t,r){return t.pipe(u(e=>{let i=P(e);return r.reduce((s,o)=>{let n=i.find(({id:T})=>T===o.id);return n?[...s,n]:s},[])}))}getReportUrl(t,r,e,i){let s=new URL(`${this.settings.apiUrl}/Files/${this.getReportTypePathPart(t)}/${r}/${e}`);return s.searchParams.set("ids",i.join(",")),s.toString()}getReportAvailabilityUrl(t,r,e,i){let s=new URL(`${this.settings.apiUrl}/${this.getReportTypePathPart(t)}/AvailableReports/${r}`);return s.searchParams.set("ids",Array.isArray(e)?e.join(","):String(e)),s.searchParams.set("keys",i.join(",")),s.toString()}getReportTypePathPart(t){return`${t[0].toUpperCase()+t.slice(1)}Reports`}static{this.\u0275fac=function(r){return new(r||a)}}static{this.\u0275prov=m({token:a,factory:a.\u0275fac,providedIn:"root"})}}return a})();export{H as a};
