1import{j as e,r as g}from"./vendor-radix-DLGwGdby.js";import{a as x,C as f,e as b,B as m,s as p,J as K,O as Q,h as _,A as C,t as u,as as X,q as Y,K as Z,D as q,L as z,M as ee,az as se,aA as ae,aB as F,aC as M,b as re,c as te}from"./index-Cz1Nuibl.js";import{i as I,D as ne,E as k,a5 as R,L as S,C as ie,P as de,o as ce,a0 as le,br as oe,a as B,v as he,A as me,g as xe}from"./vendor-lucide-BWW0XcuW.js";import"./vendor-recharts-dzgay_RI.js";import"./vendor-datefns-CU7NMMYW.js";function ge({session:s}){const{t:r,i18n:t}=x(),a=new Date(s.end_at)<new Date;return e.jsxs("div",{className:"flex items-center gap-4 p-3 rounded-lg border hover:bg-muted/30 transition-colors",children:[e.jsx("div",{className:`p-2 rounded-full flex-shrink-0 ${s.attended?"bg-success/10":a?"bg-muted":"bg-info/10"}`,children:s.attended?e.jsx(ie,{className:"h-4 w-4 text-success"}):e.jsx(de,{className:"h-4 w-4 text-info"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"font-medium text-sm",children:r("dashboard.shared.learning.workspace.session.title",{number:s.session_number,title:s.title})}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx(ce,{className:"h-3 w-3 inline me-1"}),new Date(s.start_at).toLocaleString(t.language)]})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[s.status==="live"&&s.meeting_url&&e.jsx(m,{size:"sm",className:"bg-destructive hover:bg-destructive/90 text-white",asChild:!0,children:e.jsx("a",{href:s.meeting_url,target:"_blank",rel:"noopener noreferrer",children:r("dashboard.shared.learning.workspace.session.joinLive")})}),s.recording_url&&e.jsx(m,{size:"sm",variant:"outline",asChild:!0,children:e.jsx("a",{href:s.recording_url,target:"_blank",rel:"noopener noreferrer",children:r("dashboard.shared.learning.workspace.session.recording")})}),s.attended&&e.jsx(p,{variant:"outline",className:"text-xs text-success",children:r("dashboard.shared.learning.workspace.session.attended")})]})]})}function ue({submission:s,maxScore:r}){const{t}=x();return!s.feedback&&s.score===null?null:e.jsxs("div",{className:"border border-info/30 rounded-lg p-3 bg-info/10 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{className:"h-4 w-4 text-info"}),e.jsx("span",{className:"text-sm font-medium text-info",children:t("dashboard.shared.learning.workspace.assignment.instructorFeedback")}),s.score!==null&&e.jsxs(p,{className:"ms-auto bg-info text-white",children:[s.score," / ",r]})]}),s.feedback&&e.jsx("p",{className:"text-sm text-info",children:s.feedback})]})}function pe({assignment:s,cohortId:r,highlight:t}){const{t:a,i18n:l}=x(),[o,i]=g.useState(""),[h,d]=g.useState(!1),T=K();async function y(){d(!0);try{await _.post(`${C}/master-classes/assignments/${s.id}/submit`,{text_content:o}),u.success(a("dashboard.shared.learning.workspace.assignment.submitted")),T.invalidateQueries({queryKey:["course-workspace",r]}),i("")}catch{u.error(a("dashboard.shared.learning.workspace.assignment.submitFailed"))}finally{d(!1)}}const c=s.my_submission,w=c?.status==="graded",j=c&&c.status!=="pending",A=s.due_at&&new Date>new Date(s.due_at);return e.jsx(f,{id:`assignment-${s.id}`,className:t?"ring-2 ring-warning":void 0,children:e.jsxs(b,{className:"p-4 space-y-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h4",{className:"font-medium",children:s.title}),s.description&&e.jsx("p",{className:"text-sm text-muted-foreground mt-0.5",children:s.description})]}),w?e.jsx(p,{className:"bg-info/10 text-info flex-shrink-0",children:a("dashboard.shared.learning.workspace.progress.graded")}):j?e.jsx(p,{className:"bg-success/10 text-success flex-shrink-0",children:a(`dashboard.shared.masterClasses.statuses.${c.status}`,{defaultValue:a("dashboard.shared.masterClasses.statuses.submitted")})}):A?e.jsx(p,{variant:"destructive",className:"flex-shrink-0",children:a("dashboard.shared.learning.workspace.assignment.overdue")}):e.jsx(p,{variant:"outline",className:"flex-shrink-0",children:a("dashboard.shared.learning.workspace.assignment.due",{date:s.due_at?new Date(s.due_at).toLocaleDateString(l.language):a("dashboard.shared.learning.workspace.notAvailable")})})]}),j?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"bg-muted rounded p-3 text-sm",children:[e.jsx("p",{className:"font-medium text-xs text-muted-foreground mb-1",children:a("dashboard.shared.learning.workspace.assignment.yourSubmission")}),c.text_content&&e.jsx("p",{className:"whitespace-pre-wrap",children:c.text_content}),c.file_url&&e.jsxs("a",{href:c.file_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-primary hover:underline text-xs mt-1",children:[e.jsx(k,{className:"h-3 w-3"}),a("dashboard.shared.learning.workspace.assignment.viewFile")]}),c.link_url&&e.jsxs("a",{href:c.link_url,target:"_blank",rel:"noopener noreferrer",className:"flex items-center gap-1 text-primary hover:underline text-xs mt-1",children:[e.jsx(k,{className:"h-3 w-3"}),c.link_url]}),c.submitted_at&&e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:a("dashboard.shared.learning.workspace.assignment.submittedAt",{date:new Date(c.submitted_at).toLocaleStr
1ing(l.language)})})]}),w&&e.jsx(ue,{submission:c,maxScore:s.max_score})]}):s.submission_type==="text"?e.jsxs("div",{className:"space-y-2",children:[e.jsx(Q,{placeholder:a("dashboard.shared.learning.workspace.assignment.answerPlaceholder"),"aria-label":a("dashboard.shared.learning.workspace.assignment.answerLabel",{title:s.title}),value:o,onChange:L=>i(L.target.value),rows:4}),e.jsx(m,{size:"sm",onClick:y,disabled:h||!o.trim(),children:h?e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"h-4 w-4 me-1 animate-spin"}),a("dashboard.shared.learning.workspace.assignment.submitting")]}):a("dashboard.shared.learning.workspace.assignment.submit")})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:a("dashboard.shared.learning.workspace.assignment.externalSubmission")})]})})}function fe({text:s}){const{t:r}=x(),[t,a]=g.useState(!1);function l(){navigator.clipboard.writeText(s).then(()=>{a(!0),setTimeout(()=>a(!1),2e3)})}return e.jsxs("button",{onClick:l,className:"inline-flex items-center gap-1 text-xs text-warning hover:text-warning/80 transition-colors",title:r("dashboard.shared.learning.workspace.certificate.copyToClipboard"),"aria-label":r("dashboard.shared.learning.workspace.certificate.copyToClipboard"),children:[t?e.jsx(le,{className:"h-3 w-3"}):e.jsx(oe,{className:"h-3 w-3"}),r(t?"dashboard.shared.learning.workspace.certificate.copied":"dashboard.shared.learning.workspace.certificate.copyLink")]})}function be({result:s}){const{t:r}=x(),{attendance_pct:t,required_pct:a,attended_sessions:l,total_sessions:o}=s,i=Math.ceil(a/100*o),h=Math.max(0,i-l),d=o-l;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-sm font-medium text-destructive flex items-center gap-1.5",children:[e.jsx(B,{className:"h-4 w-4 flex-shrink-0"}),r("dashboard.shared.learning.workspace.certificate.attendanceBelow")]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("dashboard.shared.learning.workspace.certificate.attendanceSummary",{attendance:t,attended:l,total:o,required:a})}),h>0&&d>0&&e.jsxs("p",{className:"text-sm text-warning",children:[e.jsx(R,{className:"h-3.5 w-3.5 inline me-1"}),r("dashboard.shared.learning.workspace.certificate.sessionsNeeded",{count:h})]}),h>0&&d===0&&e.jsx("p",{className:"text-sm text-muted-foreground",children:r("dashboard.shared.learning.workspace.certificate.noMoreSessions")})]})}function we({result:s,assignments:r,onGoToAssignments:t}){const{t:a,i18n:l}=x(),{outstanding_assignments:o,outstanding_assignment_ids:i}=s,h=r.filter(d=>i.includes(d.id));return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium text-destructive flex items-center gap-1.5",children:[e.jsx(B,{className:"h-4 w-4 flex-shrink-0"}),a("dashboard.shared.learning.workspace.certificate.assignmentsOutstanding",{count:o})]}),h.length>0?e.jsx("ul",{className:"space-y-1",children:h.map(d=>e.jsx("li",{children:e.jsxs("button",{onClick:()=>t(d.id),className:"text-sm text-primary hover:underline flex items-center gap-1",children:[e.jsx(k,{className:"h-3 w-3 flex-shrink-0"}),d.title,d.due_at&&e.jsxs("span",{className:"text-muted-foreground text-xs",children:["â ",a("dashboard.shared.learning.workspace.assignment.due",{date:new Date(d.due_at).toLocaleDateString(l.language)})]})]})},d.id))}):e.jsxs("button",{onClick:()=>t(),className:"text-sm text-primary hover:underline flex items-center gap-1",children:[e.jsx(k,{className:"h-3 w-3"}),a("dashboard.shared.learning.workspace.certificate.goToAssignments")]})]})}function je({result:s}){const{t:r}=x(),{average_grade:t,required_grade:a}=s,l=Math.round((a-t)*10)/10;return e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("p",{className:"text-sm font-medium text-destructive flex items-center gap-1.5",children:[e.jsx(B,{className:"h-4 w-4 flex-shrink-0"}),r("dashboard.shared.learning.workspace.certificate.gradeBelow")]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("dashboard.shared.learning.workspace.certificate.gradeSummary",{average:t,required:a,gap:l})}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r("dashboard.shared.learning.workspace.certificate.gradeGuid
1ance")})]})}function Ne({certificate:s,onCheck:r,isPending:t,checkResult:a,assignments:l,onGoToAssignments:o}){const{t:i,i18n:h}=x();if(s){const d=`${window.location.origin}/api/v1/master-classes/certificates/${s.verification_code}/verify`;return e.jsx(f,{className:"border-warning/30 bg-gradient-to-r from-warning/10 to-warning/5",children:e.jsxs(b,{className:"p-6",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-warning/20 flex-shrink-0",children:e.jsx(I,{className:"h-8 w-8 text-warning"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-semibold text-lg text-warning",children:i("dashboard.shared.learning.workspace.certificate.earned")}),e.jsx("p",{className:"text-sm text-warning/80 mt-0.5",children:i("dashboard.shared.learning.workspace.certificate.issuedAt",{date:new Date(s.issued_at).toLocaleDateString(h.language)})}),e.jsxs("div",{className:"flex items-center gap-2 mt-1.5 flex-wrap",children:[e.jsxs("p",{className:"text-xs text-warning/80",children:[i("dashboard.shared.learning.workspace.certificate.verificationCode")," ",e.jsx("code",{dir:"ltr",className:"font-mono bg-warning/20 px-1.5 py-0.5 rounded text-warning",children:s.verification_code})]}),e.jsx(fe,{text:d})]})]})]}),e.jsxs("div",{className:"flex gap-2 mt-5 flex-wrap",children:[e.jsx(m,{className:"bg-warning hover:bg-warning/90 text-warning-foreground",asChild:!0,children:e.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(ne,{className:"h-4 w-4 me-2"}),i("dashboard.shared.learning.workspace.certificate.view")]})}),e.jsx(m,{variant:"outline",asChild:!0,children:e.jsxs("a",{href:d,target:"_blank",rel:"noopener noreferrer",children:[e.jsx(k,{className:"h-4 w-4 me-2"}),i("dashboard.shared.learning.workspace.certificate.verifyOnline")]})})]})]})})}return a&&!a.eligible?e.jsx(f,{className:"border-destructive/30 bg-destructive/5",children:e.jsxs(b,{className:"p-5 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-5 w-5 text-destructive flex-shrink-0"}),e.jsx("h3",{className:"font-semibold text-sm",children:i("dashboard.shared.learning.workspace.certificate.notAvailable")})]}),e.jsx("div",{className:"space-y-4 divide-y divide-border",children:e.jsxs("div",{className:"pt-1",children:[a.reason==="below_attendance_threshold"&&e.jsx(be,{result:a}),a.reason==="incomplete_assignments"&&e.jsx(we,{result:a,assignments:l??[],onGoToAssignments:o??(()=>{})}),a.reason==="below_min_grade"&&e.jsx(je,{result:a})]})}),e.jsx(m,{variant:"outline",size:"sm",onClick:r,disabled:t,children:t?e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"h-4 w-4 animate-spin me-1"}),i("dashboard.shared.learning.workspace.certificate.checking")]}):i("dashboard.shared.learning.workspace.certificate.recheck")})]})}):e.jsx(f,{className:"border-dashed",children:e.jsxs(b,{className:"p-4 flex items-center gap-3",children:[e.jsx(I,{className:"h-6 w-6 text-muted-foreground"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"text-sm font-medium",children:i("dashboard.shared.learning.workspace.certificate.notIssued")}),e.jsx("p",{className:"text-xs text-muted-foreground",children:i("dashboard.shared.learning.workspace.certificate.checkDescription")})]}),e.jsx(m,{variant:"outline",size:"sm",onClick:r,disabled:t,children:t?e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"h-4 w-4 animate-spin me-1"}),i("dashboard.shared.learning.workspace.certificate.checking")]}):i("dashboard.shared.learning.workspace.certificate.check")})]})})}function Se(){const{t:s}=x(),{cohortId:r}=X(),t=K(),[a,l]=g.useState(0),[o,i]=g.useState(""),[h,d]=g.useState(!1),[T,y]=g.useState("sessions"),[c,w]=g.useState(null),{data:j,isLoading:A,error:L}=Y({queryKey:["course-workspace",r],queryFn:()=>_.get(`${C}/master-classes/cohorts/${r}/workspace`),enabled:!!r}),G=Z({mutationFn:()=>_.post(`${C}/master-classes/cohorts/${r}/certificates/check`,{}),onSuccess:n=>{"certificate"in n&&n.certificate?(u.success(n.already_issued?s("dashboard.shared.learning.workspace.certificate.alreadyIssued"):s("dashboard.shared.learning.workspace.certificate.issued")),w(null),t.invalidateQueries({queryKey:["course-workspace",r]}),t.invalidateQueries({queryKey:["learning-dashboard"]})):n.eligible||w(n)},onError:()=>u.error(s("dashboard.shared.learning.workspace.certificate.checkFailed"))});function O(n){y("assignments"),n&&setTimeout(()=>{const E=document.getElementById(`assignment-${n}`);E&&E.scrollIntoView({behavior:"smooth",block:"center"})},100)}async function V(){if(a===0){u.error(s("dashboard.shared.learning.workspace.review.selectRating"));return}d(!0);try{await _.post(`${C}/master-classes/cohorts/${r}/reviews`,{rating:a,review:o}),u.success(s("dashboard.shared.learning.workspace.review.submitted")),l(0),i("")}catch{u.error(s("dashboard.shared.learning.workspace.review.submitFailed"))}finally{d(!1)}}if(A)return e.jsxs("div",{className:"p-6 space-y-4",children:[e.jsx(q,{className:"h-8 w-64"}),e.jsx(q,{className:"h-32 w-full"}),e.jsx(q,{className:"h-64 w-full"})]});if(L||!j)return e.jsxs("div",{className:"p-6 text-center",children:[e.jsx("p",{className:"text-muted-foreground",children:s("dashboard.shared.learning.workspace.notFound")}),e.jsx(z,{to:"/dashboard/learning",children:e.jsx(m,{variant:"link",children:s("dashboard.shared.learning.workspace.backToLearning")})})]});const{cohort:H,master_class:J,sessions:D=[],assignments:N=[],progress:v,certificate:U}=j,P=v?.attendance_pct??0,$=N.filter(n=>n.my_submission?.status==="graded").length,W=c&&!c.eligible&&c.reason==="incomplete_assignments"?new Set(c.outstanding_assignment_ids):new Set;
1return e.jsxs("div",{className:"p-6 max-w-4xl mx-auto space-y-6",children:[e.jsxs("div",{children:[e.jsxs(z,{to:"/dashboard/learning",className:"inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground mb-3",children:[e.jsx(me,{className:"h-4 w-4 rtl:rotate-180"}),s("dashboard.shared.learning.workspace.backToLearning")]}),e.jsx("h1",{className:"text-2xl font-bold",children:J?.title??s("dashboard.shared.learning.workspace.course")}),e.jsx("p",{className:"text-muted-foreground",children:String(H?.name??"")})]}),e.jsx(f,{children:e.jsxs(b,{className:"p-5 space-y-4",children:[e.jsx("h3",{className:"font-semibold",children:s("dashboard.shared.learning.workspace.progress.title")}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsx("span",{className:"text-muted-foreground",children:s("dashboard.shared.learning.attendance")}),e.jsxs("span",{className:"font-medium",children:[P,"%"]})]}),e.jsx(ee,{value:P,className:"h-2"})]}),e.jsxs("div",{className:"grid grid-cols-3 gap-4 text-center text-sm pt-1",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-semibold text-lg",children:[v?.attended_sessions??0,e.jsxs("span",{className:"text-muted-foreground font-normal text-sm",children:["/",v?.total_sessions??0]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:s("dashboard.shared.learning.workspace.progress.sessionsAttended")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"font-semibold text-lg",children:[v?.submitted_assignments??0,e.jsxs("span",{className:"text-muted-foreground font-normal text-sm",children:["/",v?.total_assignments??0]})]}),e.jsx("p",{className:"text-muted-foreground text-xs",children:s("dashboard.shared.learning.workspace.progress.assignmentsSubmitted")})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"font-semibold text-lg",children:$}),e.jsx("p",{className:"text-muted-foreground text-xs",children:s("dashboard.shared.learning.workspace.progress.graded")})]})]})]})}),e.jsx(Ne,{certificate:U,onCheck:()=>G.mutate(),isPending:G.isPending,checkResult:c,assignments:N,onGoToAssignments:O}),e.jsxs(se,{value:T,onValueChange:y,children:[e.jsxs(ae,{children:[e.jsx(F,{value:"sessions",children:s("dashboard.shared.learning.workspace.tabs.sessions",{count:D.length})}),e.jsxs(F,{value:"assignments",children:[s("dashboard.shared.learning.workspace.tabs.assignments",{count:N.length}),$>0&&e.jsx("span",{className:"ms-1.5 bg-info/10 text-info text-xs rounded-full px-1.5 py-0.5",children:s("dashboard.shared.learning.workspace.progress.gradedCount",{count:$})})]}),e.jsx(F,{value:"review",children:s("dashboard.shared.learning.workspace.tabs.review")})]}),e.jsx(M,{value:"sessions",className:"space-y-2 pt-4",children:D.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:s("dashboard.shared.learning.workspace.emptySessions")}):D.map(n=>e.jsx(ge,{session:n},n.id))}),e.jsx(M,{value:"assignments",className:"space-y-4 pt-4",children:N.length===0?e.jsx("p",{className:"text-center text-muted-foreground py-8",children:s("dashboard.shared.learning.workspace.emptyAssignments")}):N.map(n=>e.jsx(pe,{assignment:n,cohortId:r,highlight:W.has(n.id)},n.id))}),e.jsx(M,{value:"review",className:"pt-4",children:e.jsxs(f,{children:[e.jsx(re,{children:e.jsx(te,{className:"text-base",children:s("dashboard.shared.learning.workspace.review.title")})}),e.jsxs(b,{className:"space-y-4",children:[e.jsx("div",{className:"flex gap-1",children:[1,2,3,4,5].map(n=>e.jsx("button",{onClick:()=>l(n),"aria-label":s("dashboard.shared.learning.workspace.review.ratingLabel",{count:n}),children:e.jsx(xe,{className:`h-8 w-8 ${n<=a?"fill-warning text-warning":"text-muted-foreground/30 hover:text-warning/80"}`})},n))}),e.jsx(Q,{placeholder:s("dashboard.shared.learning.workspace.review.placeholder"),"aria-label":s("dashboard.shared.learning.workspace.review.inputLabel"),value:o,onChange:n=>i(n.target.value),rows:4}),e.jsx(m,{onClick:V,disabled:h||a===0,children:h?e.jsxs(e.Fragment,{children:[e.jsx(S,{className:"h-4 w-4 animate-spin me-2"}),s("dashboard.shared.learning.workspace.review.submitting")]}):s("dashboard.shared.learning.workspace.review.submit")})]})]})})]})]})}export{Se 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.