PageSourceSearch

https://blitzmemory.com/assets/ProgramLessonPage-Baa9PWWe.js

js blitzmemory.com collected 2026-10-05 07:34:09 UTC 10,820 bytes, 1 lines download raw bytes

1import{ak as me,r as i,j as s,aj as k,C as he,w as ue}from"./index-D3Di9rth.js";import{C as ne}from"./circle-check-Bv8mKxoS.js";const _=new Map,y=new Map;function oe(c,g){return`${c}::${g}`}async function le(c,g,{useCache:t=!0}={}){const d=oe(c,g);if(t&&_.has(d))return _.get(d);if(y.has(d))return y.get(d);const w=fetch(`/api/learning/programs/${c}/${g}`).then(async b=>{const u=await b.json();if(!b.ok||!u.ok)throw new Error(u.error||"Failed to load lesson");return _.set(d,u),u}).finally(()=>{y.delete(d)});return y.set(d,w),w}function be(){var W,D,O,R,B,U,V,q,H,z,J,K,Y,G,Q,X,Z,ee,se,re;const{programSlug:c,lessonSlug:g}=me(),[t,d]=i.useState({loading:!0,data:null,error:""}),[w,b]=i.useState({}),[u,L]=i.useState([]),[P,de]=i.useState(""),S=i.useRef(null);i.useEffect(()=>{let e=!1;return(async()=>{try{const r=_.get(oe(c,g));d(r?{loading:!1,data:r,error:""}:n=>({...n,loading:!0,error:""}));const o=await le(c,g);e||d({loading:!1,data:o,error:""})}catch(r){e||d({loading:!1,data:null,error:r.message||"Failed to load"})}})(),()=>{e=!0}},[c,g]);const v=(D=(((W=t.data)==null?void 0:W.categories)||[]).find(e=>(e.lessons||[]).some(r=>{var o,n;return r.slug===((n=(o=t.data)==null?void 0:o.lesson)==null?void 0:n.slug)})))==null?void 0:D._id;i.useEffect(()=>{v&&b(e=>({...e,[v]:!0}))},[v]),i.useEffect(()=>{var e,r;(r=(e=t.data)==null?void 0:e.program)!=null&&r._id&&(async()=>{try{const o=await fetch(`/api/learning/progress/program/${t.data.program._id}`),n=await o.json();o.ok&&(n!=null&&n.ok)&&L(n.progress||[])}catch{}})()},[(R=(O=t.data)==null?void 0:O.program)==null?void 0:R._id]),i.useEffect(()=>{var e,r;(r=(e=t.data)==null?void 0:e.lesson)!=null&&r._id&&(async()=>{try{const o=t.data.lesson._id;await fetch("/api/learning/progress/lesson",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({contentType:"program_lesson",lessonId:o,viewed:!0,videoWatchPercent:10})}),L(n=>n.some(l=>String(l.lessonId)===String(o))?n.map(l=>String(l.lessonId)===String(o)?{...l,viewedAt:l.viewedAt||new Date().toISOString(),videoWatchPercent:Math.max(Number(l.videoWatchPercent||0),10)}:l):[...n,{lessonId:o,viewedAt:new Date().toISOString(),videoWatchPercent:10}])}catch{}})()},[(U=(B=t.data)==null?void 0:B.lesson)==null?void 0:U._id]),i.useEffect(()=>{var n,m,l,N,j,te;if(!((m=(n=t.data)==null?void 0:n.categories)!=null&&m.length)||!((N=(l=t.data)==null?void 0:l.program)!=null&&N.slug)||!((te=(j=t.data)==null?void 0:j.lesson)!=null&&te.slug))return;const e=t.data.categories.flatMap(h=>h.lessons||[]),r=e.findIndex(h=>h.slug===t.data.lesson.slug);if(r<0)return;const o=new Set;[r-2,r-1,r+1,r+2,r+3].forEach(h=>{var ae;(ae=e[h])!=null&&ae.slug&&o.add(e[h].slug)});for(const h of o)le(t.data.program.slug,h).catch(()=>{})},[(V=t.data)==null?void 0:V.categories,(H=(q=t.data)==null?void 0:q.lesson)==null?void 0:H.slug,(J=(z=t.data)==null?void 0:z.program)==null?void 0:J.slug]);const $=(Y=(K=t.data)==null?void 0:K.lesson)==null?void 0:Y._id;if(i.useEffect(()=>{!$||!S.current||S.current.scrollIntoView({behavior:"smooth",block:"center"})},[$]),t.loading&&!t.data)return s.jsx("div",{className:"min-h-screen bg-dark1 text-white p-8",children:"Loading…"});if(t.error)return s.jsx("div",{className:"min-h-screen bg-dark1 text-red-400 p-8",children:t.error});const{lesson:a,program:p,categories:I}=t.data,x=(I||[]).flatMap(e=>(e.lessons||[]).map(r=>({...r,categoryId:e._id}))),f=x.findIndex(e=>e.slug===a.slug),E=f>0?x[f-1]:null,A=f>=0&&f<x.length-1?x[f+1]:null,C=P.trim().toLowerCase(),ie=C?(I||[]).map(e=>{const o=String(e.title||"").toLowerCase().includes(C)?e.lessons||[]:(e.lessons||[]).filter(n=>String(n.title||"").toLowerCase().includes(C));return{...e,lessons:o}}).filter(e=>e.lessons.length>0):I||[],M=u.filter(e=>!!(e.completedAt||e.videoWatchPercent>0||e.viewedAt)).length,T=x.length?Math.round(M/x.length*100):0,ce=new Set(u.filter(e=>!!(e.completedAt||e.videoWatchPercent>0||e.viewedAt)).map(e=>String(e.lessonId||""))),F=e=>ce.has(String(e||"")),ge=e=>{const r=String(e||"").trim().toLowerCase();return r==="pdf"?"PDF":r==="image"?"Image":r==="link"?"Link":"File"};return s.jsx("div",{className:"min-h-screen bg-dark1 text-white px-4 py-8 sm:px-8",children:s.jsxs("div",{className:"mx-auto max-w-7xl space-y-6",children:[s.jsx("div",{className:"flex items-center justify-between",children:s.jsx(k,{to:"/learning/programs",className:"inline-flex items-center gap-2 rounded-lg border border-dark4 bg-dark2 px-3 py-2 text-sm font-medium text-white hover:border-blue-400",children:"← Back to Programs"})}),s.jsxs("section",{ref:S,className:"rounded-xl border border-dark4 bg-dark2 p-5",children:[s.jsx("h1",{className:"text-2xl font-bold",children:p.title}),p.description&&s.jsx("p",{className:"mt-2 text-white/80",children:p.description})]}),s.jsxs("div",{className:"grid gap-5 lg:grid-cols-[320px,1fr]",children:[s.jsxs("aside",{className:"rounded-xl border border-dark4 bg-dark2 p-4 h-fit",children:[s.jsxs("div",{className:"mb-4 rounded-lg border border-dark4 bg-dark3 p-3",children:[s.jsx("p",{className:"text-xs uppercase tracking-wider text-white/70",children:"Program Progress"}),s.jsxs("div",{className:"mt-2 flex items-center justify-between text-sm",children:[s.jsxs("span",{children:[M," / ",x.length," lessons"]}),s.jsxs("span",{className:"font-semibold text-blue-300",children:[T,"%"]})]}),s.jsx("div",{className:"mt-2 h-2 rounded-full bg-dark4",children:s.jsx("div",{className:"h-2 rounded-full bg-blue-500 transition-all",style:{width:`${T}%`}})})]}),s.jsx("h2",{className:"text-sm font-semibold text-white/80 uppercase tracking-wider mb-3",children:"Program Navigation"}),s.jsx("input",{value:P,onChange:e=>de(e.target.value),placeholder:"Search sections or lessons",className:"mb-3 w-full rounded-lg border border-dark4 bg-dark3 px-3 py-2 text-sm text-white placeholder-gray-500"}),s.jsx("div",{className:"space-y-3",children:(ie||[]).map(e=>{const r=!!w[e._id],o=String(e._id)===String(v),n=e.lessons||[],m=n.length>0&&n.every(l=>F(l._id));return s.jsxs("div",{className:`rounded-xl border p-2 ${m?"border-green-400/70 bg-green-500/10":o?"border-blue-400/70 bg-blue-500/10":"border-dark4 bg-dark2/40"}`,children:[s.jsxs("button",{type:"button",onClick:()=>b(l=>({...l,[e._id]:!l[e._id]})),className:`w-full flex items-center justify-between rounded-lg px-3 py-2 text-sm font-semibold transition ${m?"bg-green-500/20 text-green-100 border border-green-400/50":o?"bg-blue-500/20 text-blue-100 border border-blue-400/50":"text-white/90 border border-transparent hover:bg-dark3"}`,children:[s.jsxs("span",{className:"flex flex-col items-start",children:[s.jsx("span",{className:"text-[10px] uppercase tracking-[0.18em] text-white/55",children:"Section"}),s.jsxs("span",{className:"inline-flex items-center gap-2",children:[s.jsx("span",{children:e.title}),m&&s.jsx(ne,{className:"h-4 w-4 text-green-300"})]})]}),r?s.jsx(he,{className:"h-4 w-4"}):s.jsx(ue,{className:"h-4 w-4"})]}),r&&s.jsx("div",{className:`mt-2 space-y-1 pl-2 border-l-2 ${m?"border-green-400/60":"border-dark4"}`,children:n.map(l=>{const N=l.slug===a.slug,j=F(l._id);return s.jsx(k,{to:`/learning/programs/${p.slug}/${l.slug}`,className:`block rounded-lg border px-3 py-2 text-sm transition ${N?"border-blue-400 bg-blue-500/20 text-blue-100 font-semibold shadow-[0_0_0_1px_rgba(96,165,250,0.4)]":j?"border-green-400/50 bg-green-500/10 text-green-100 hover:border-green-300":"border-dark4 bg-dark3/70 text-white/85 hover:text-white hover:border-blue-300/60"}`,children:s.jsxs("span",{className:"inline-flex items-center gap-2",children:[j?s.jsx(ne,{className:"h-3.5 w-3.5 text-green-300"}):s.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-white/50"}),s.jsx("span",{children:l.title})]})},l._id)})})]},e._id)})})]}),s.jsxs("div",{className:"space-y-5",children:[s.jsxs("section",{className:"rounded-xl border border-dark4 bg-dark2 p-5",children:[s.jsx("h2",{className:"text-center text-2xl font-bold",children:a.title}),a.youtubeVideoId&&s.jsx("div",{className:"mt-4 aspect-video w-full overflow-hidden rounded-xl border border-dark4",children:s.jsx("iframe",{title:a.title,className:"h-full w-full",src:`https://www.youtube.com/embed/${a.youtubeVideoId}`,allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0})})]}),(a.body||((G=a.trainingEvents)==null?void 0:G.length)||((Q=a.resources)==null?void 0:Q.length))&&s.jsxs("section",{className:"rounded-xl border border-dark4 bg-dark2 p-5",children:[a.body&&s.jsxs("div",{children:[s.jsx("h3",{className:"mb-3 text-lg font-semibold",children:"Description"}),s.jsx("div",{className:"[&_ul]:list-disc [&_ul]:pl-6 [&_ul]:space-y-1 [&_ol]:list-decimal [&_ol]:pl-6 [&_ol]:space-y-1 [&_li]:marker:text-white/80",dangerouslySetInnerHTML:{__html:a.body}})]}),!!((X=a.trainingEvents)!=null&&X.length)&&s.jsxs("div",{className:a.body?"mt-5 border-t border-dark4 pt-5":"",children:[s.jsx("h3",{className:"mb-3 text-lg font-semibold",children:"Practice on Training Side"}),a.trainingIntro&&s.jsx("p",{className:"mb-3 text-white/80",children:a.trainingIntro}),s.jsx("div",{className:"grid gap-2 sm:grid-cols-2",children:a.trainingEvents.map((e,r)=>s.jsx("a",{href:e.eventUrl,target:"_blank",rel:"noreferrer",className:"rounded-lg border border-dark4 bg-dark3 px-3 py-2 text-blue-300 hover:text-blue-200",children:e.eventLabel||e.eventId||"Training Event"},`${e.eventUrl}-${r}`))})]}),!!((Z=a.resources)!=null&&Z.length)&&s.jsxs("div",{className:a.body||(ee=a.trainingEvents)!=null&&ee.length?"mt-5 border-t border-dark4 pt-5":"",children:[s.jsx("h3",{className:"mb-3 text-lg font-semibold",children:"Resources"}),s.jsx("div",{className:"space-y-2",children:a.resources.map((e,r)=>s.jsxs("a",{href:e.fileUrl,target:"_blank",rel:"noreferrer",className:"block rounded-lg border border-dark4 bg-dark3 px-3 py-2 text-white hover:border-blue-400",children:[s.jsx("span",{className:"font-medium",children:e.label}),s.jsxs("span",{className:"ml-2 text-white/70 text-sm",children:["(",ge(e.fileType),")"]})]},`${e.fileUrl}-${r}`))})]}),s.jsx("div",{className:a.body||(se=a.trainingEvents)!=null&&se.length||(re=a.resources)!=null&&re.length?"mt-5 border-t border-dark4 pt-5":"",children:s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[E?s.jsx(k,{to:`/learning/programs/${p.slug}/${E.slug}`,className:"rounded-lg border border-dark4 bg-dark3 px-4 py-2 text-sm font-semibold text-white hover:border-blue-400",children:"← Previous Lesson"}):s.jsx("span",{}),A?s.jsx(k,{to:`/learning/programs/${p.slug}/${A.slug}`,className:"rounded-lg bg-blue-600 px-4 py-2 text-sm font-semibold text-white hover:bg-blue-500",children:"Next Lesson →"}):s.jsx("span",{className:"text-sm text-white/70",children:"You’re at the last lesson."})]})})]})]})]})]})})}export{be 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.