NeahNew/.next/static/chunks/app/apprendre/page-feb4b632bf8d5015.js
2026-01-02 14:32:36 +01:00

1 line
2.5 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[351,604,768,891,1176,2354,2821,3050,3518,3548,3874,4021,5952,6351,8626,9465,9552],{43902:(e,s,n)=>{"use strict";n.d(s,{ResponsiveIframe:()=>o});var t=n(95155),i=n(12115),r=n(12108);function o(e){let{src:s,className:n="",allow:o,style:a}=e,l=(0,i.useRef)(null),{data:c}=(0,r.useSession)(),[d,h]=(0,i.useState)(!1),[f,u]=(0,i.useState)(""),[w,m]=(0,i.useState)(!1);return(0,i.useEffect)(()=>{if(s&&c){if(w){f||u(s);return}if(!c.accessToken||!c.refreshToken){console.warn("Session missing required tokens, redirecting to sign-in"),window.location.href="/signin";return}(async()=>{h(!0),m(!0);try{await new Promise(e=>setTimeout(e,100));let e=await fetch("/api/auth/refresh-keycloak-session",{method:"GET",credentials:"include"});if(e.ok)console.log("Session refreshed before loading iframe"),u(s);else{let n=await e.json().catch(()=>({}));if(401===e.status&&"SessionInvalidated"===n.error){console.warn("Keycloak session invalidated, redirecting to sign-in"),window.location.href="/signin";return}console.warn("Failed to refresh session, loading iframe anyway (may require login)"),u(s)}}catch(e){console.error("Error refreshing session:",e),u(s)}finally{h(!1)}})()}},[c,s,w,f]),(0,i.useEffect)(()=>{let e=l.current;if(!e||!f)return;let s=()=>{let s=e=>e.offsetParent?e.offsetTop+s(e.offsetParent):e.offsetTop,n=Math.max(0,document.documentElement.clientHeight-s(e));e.style.height="".concat(n,"px")},n=()=>{if(window.location.hash&&window.location.hash.length&&e.src){let s=new URL(e.src);s.hash=window.location.hash,e.src=s.toString()}};return s(),n(),window.addEventListener("resize",s),window.addEventListener("hashchange",n),e.addEventListener("load",s),()=>{window.removeEventListener("resize",s),window.removeEventListener("hashchange",n),e.removeEventListener("load",s)}},[]),(0,t.jsxs)(t.Fragment,{children:[d&&(0,t.jsx)("div",{className:"flex items-center justify-center w-full h-full absolute bg-black/50 z-10",children:(0,t.jsxs)("div",{className:"text-center bg-white p-4 rounded-lg",children:[(0,t.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-t-2 border-b-2 border-blue-500 mx-auto mb-4"}),(0,t.jsx)("p",{className:"text-gray-600",children:"Actualisation de la session..."})]})}),(0,t.jsx)("iframe",{ref:l,id:"myFrame",src:f||s,className:"w-full border-none ".concat(n),style:{display:"block",width:"100%",height:"100%",...a},allow:o,allowFullScreen:!0})]})}},68379:(e,s,n)=>{Promise.resolve().then(n.bind(n,43902))}},e=>{var s=s=>e(e.s=s);e.O(0,[2108,8441,1684,7358],()=>s(68379)),_N_E=e.O()}]);