1import{aG as y,r as s,s as a,j as n,e as L}from"./index-CobRY8C4.js";const I=()=>{const[k]=y(),l=k.get("sessionId"),[p,x]=s.useState(null),[g,b]=s.useState(1),[h,w]=s.useState(null),[i,u]=s.useState(null),[C,c]=s.useState(!0),[R,o]=s.useState(!1),j=s.useRef(null),f=s.useRef(null),d=s.useRef(null);s.useEffect(()=>{if(!l){o(!0),c(!1);return}a.from("program_sessions").select("current_step_id, current_page").eq("id",l).maybeSingle().then(({data:e,error:t})=>{t||!e?(o(!0),c(!1)):(x(e.current_step_id),b(e.current_page??1),o(!1))})},[l]),s.useEffect(()=>{if(!l)return;const e=a.channel(`client-view-${l}`).on("postgres_changes",{event:"UPDATE",schema:"public",table:"program_sessions",filter:`id=eq.${l}`},t=>{const r=t.new;r.current_step_id&&x(r.current_step_id),r.current_page!=null&&b(r.current_page)}).on("postgres_changes",{event:"DELETE",schema:"public",table:"program_sessions",filter:`id=eq.${l}`},()=>{o(!0)}).subscribe();return()=>{a.removeChannel(e)}},[l]),s.useEffect(()=>{if(!p){w(null);return}a.from("program_steps").select("storage_path").eq("id",p).maybeSingle().then(({data:e})=>{w((e==null?void 0:e.storage_path)??null)})}
1,[p]),s.useEffect(()=>{if(!h){u(null),c(!1);return}let e=!1;return c(!0),a.storage.from("program-content").createSignedUrl(h,3600).then(({data:t})=>{e||(t!=null&&t.signedUrl?u(t.signedUrl):u(null),c(!1))}).catch(()=>{e||(u(null),c(!1))}),()=>{e=!0}},[h]),s.useEffect(()=>{if(!i){f.current=null;return}const e=window.pdfjsLib;if(!e)return;e.GlobalWorkerOptions.workerSrc="https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.worker.min.js";let t=!1;return e.getDocument(i).promise.then(r=>{t||(f.current=r,_(g,r))}),()=>{t=!0}},[i]),s.useEffect(()=>{f.current&&_(g,f.current)},[g]);const _=(e,t)=>{const r=j.current;!t||!r||t.getPage(e).then(v=>{var N,P;const m=v.getViewport({scale:1.5});r.height=m.height,r.width=m.width;const S=r.getContext("2d");if(!S)return;d.current&&((P=(N=d.current).cancel)==null||P.call(N));const E=v.render({canvasContext:S,viewport:m});d.current=E,E.promise.catch(()=>{})})};return R?n.jsx("div",{className:"h-screen w-screen bg-black flex items-center justify-center",children:n.jsx("p",{className:"text-white text-lg",children:"Sessionen kunde inte hittas."})}):n.jsxs("div",{className:"h-screen w-screen bg-black relative flex items-center justify-center",children:[n.jsxs("div",{className:"absolute top-4 right-4 z-10 flex items-center gap-2 bg-black/70 backdrop-blur-sm border border-white/10 rounded-full px-3 py-1.5",children:[n.jsxs("span",{className:"relative flex h-2.5 w-2.5",children:[n.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-green-400 opacity-75"}),n.jsx("span",{className:"relative inline-flex rounded-full h-2.5 w-2.5 bg-green-500"})]}),n.jsx("span",{className:"text-white text-xs font-medium",children:"Live session"})]}),C?n.jsx(L,{className:"w-8 h-8 animate-spin text-white"}):i?n.jsx("canvas",{ref:j,className:"max-w-full max-h-full"}):n.jsx("p",{className:"text-white/50 text-sm",children:"Ingen PDF tillgänglig."})]})};export{I as default};
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.