1import{Ac as N,Ba as E,Da as F,E as k,F as P,I as b,K as j,h as M,if as q,na as x,sa as L,t as A,ta as _,ua as I,va as w,wa as C,xa as G,z as y}from"./chunk-BAKSV7Y6.js";import{J as T,N as p,ia as d,na as o,o as U,s as S,u as m}from"./chunk-TPMNAKGL.js";import{a as l,b as f}from"./chunk-FJYW2LMB.js";var $=(()=>{class s{constructor(t){this.http=t}getTokensByUuid(t){let i=`${k.baseUrl??k.server_address??""}/trinka/api/v1/lti/cookies/${encodeURIComponent(t)}`;return this.http.get(i).pipe(m(r=>this.normalizeTokensResponse(r)),T(()=>U(null)))}normalizeTokensResponse(t){if(!t)return null;let e=t.data??t.tokens??t,i=e?.token??e?.access_token,r=e?.refresh_token??e?.refreshToken;return!i&&!r?null:f(l({},e),{token:i??e?.token,refresh_token:r??e?.refresh_token})}static{this.\u0275fac=function(e){return new(e||s)(o(M))}}static{this.\u0275prov=d({token:s,factory:s.\u0275fac,providedIn:"root"})}}return s})();var ae=(()=>{class s{constructor(t,e,i,r,n,v,h){this.storage=t,this.router=e,this.authService=i,this.dataService=r,this.ltiTokenService=n,this.getMetaService=v,this.userContextService=h,this.isRedirecting=!1,e.events.subscribe(u=>{u instanceof A&&this.dataService.setPreviousUrl(u.url)})}canActivate(t,e){if(this.captureMarketingParamsFromNavigation(e.url),G(e.url))return!0;if(this.isRedirecting)return!1;let i=this.router.parseUrl(e.url),r=e.url.split("?")[0]||"",n=i.queryParams.uuid,v=i.queryParams.islti==="true",h=i.queryParams.ismoodle==="true",u=v||h;if(u&&!this.getMetaService.isLmsAllowedPath(r))return this.dataService.setPreviousUrl(e.url),this.isRedirecting=!0,setTimeout(()=>{this.isRedirecting=!1},1e3),this.router.navigate(["/signin"]),!1;if(u&&this.getMetaService.isLmsAllowedPath(r)){if(n)return S(this.ltiTokenService.getTokensByUuid(n)).then(a=>{let R=a?.token??a?.access_token;if(a&&(R||a.refresh_token)){let B=f(l({},a),{token:R??a.token,source:h?"moodle":"lti"});return localStorage.setItem(P,JSON.stringify(B)),S(this.userContextService.ensureLoaded().pipe(p(1))).then(()=>!0)}return this.dataService.setPreviousUrl(e.url),this.isRedirecting=!0,setTimeout(()=>{this.isRedirecting=!1},1e3),this.router.navigate(["/signin"]),!1}).catch(()=>(this.dataService.setPreviousUrl(e.url),this.isRedirecting=!0,setTimeout(()=>{this.isRedirecting=!1},1e3),this.router.navigate(["/signin"]),!1));let c=this.storage.getItem(P)?.token;return c&&this.authService.isTokenValid(c)?this.userContextService.ensureLoaded().pipe(m(()=>!0),p(1)):(this.dataService.setPreviousUrl(e.url),this.isRedirecting=!0,setTimeout(()=>{this.isRedirecting=!1},1e3),this.router.navigate(["/signin"]),!1)}if(w(r)){let g=L(this.storage.getMeta()),c=_(r);if(g&&!c)return this.router.navigateByUrl(C(e.url)),!1;if(!g&&c)return this.router.navigateByUrl(I(e.url)),!1}return this.authService.isAuthenticated()?this.userContextService.ensureLoaded().pipe(m(()=>!0),p(1)):(this.dataService.setPreviousUrl(e.url),this.isRedirecting=!0,setTimeout(()=>{this.isRedirecting=!1},1e3),this.router.navigate(["/signin"],{queryParams:i.queryParams}),!1)}captureMarketingParamsFromNavigation(t){if(!t)return;let e=this.toAbsoluteUrl(t),i=new URL(e).searchParams;j.some(n=>i.has(n))&&x(e)}toAbsoluteUrl(t){return t.startsWith("http")?t:`${window.location.origin}${t.startsWith("/")?t:`/${t}`}`}static{this.\u0275fac=function(e){return new(e||s)(o(E),o(y),o(F),o(N),o($),o(b),o(q))}}static{this.\u0275prov=d({token:s,factory:s.\u0275fac,providedIn:"root"})}}return s})();export{ae as a};
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.