@hydralms/components 0.3.0 → 0.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/dist/StudentProfile-BPsZBaJj.cjs +1 -0
  2. package/dist/{StudentProfile-DeMxdrL3.js → StudentProfile-Cw2p-RZn.js} +577 -579
  3. package/dist/index.cjs +1 -1
  4. package/dist/index.js +172 -166
  5. package/dist/license/index.d.ts +2 -2
  6. package/dist/license/tiers.d.ts +3 -0
  7. package/dist/modules.cjs +1 -1
  8. package/dist/modules.js +111 -110
  9. package/dist/sections/AdaptiveLearningPath/AdaptiveLearningPath.d.ts +5 -0
  10. package/dist/sections/AdaptiveLearningPath/path-connector.d.ts +8 -0
  11. package/dist/sections/AdaptiveLearningPath/path-milestone-marker.d.ts +7 -0
  12. package/dist/sections/AdaptiveLearningPath/path-node-card.d.ts +10 -0
  13. package/dist/sections/AdaptiveLearningPath/path-skill-bar.d.ts +8 -0
  14. package/dist/sections/AdaptiveLearningPath/types.d.ts +136 -0
  15. package/dist/sections/ContentAuthoringStudio/ContentAuthoringStudio.d.ts +5 -0
  16. package/dist/sections/ContentAuthoringStudio/block-editor-item.d.ts +14 -0
  17. package/dist/sections/ContentAuthoringStudio/block-type-picker.d.ts +12 -0
  18. package/dist/sections/ContentAuthoringStudio/types.d.ts +67 -0
  19. package/dist/sections/index.d.ts +4 -0
  20. package/dist/sections.cjs +1 -1
  21. package/dist/sections.js +1325 -232
  22. package/dist/withProGate-BJdu1T9Y.cjs +2 -0
  23. package/dist/withProGate-BvFc7Jwy.js +4975 -0
  24. package/package.json +24 -7
  25. package/src/license/index.ts +2 -2
  26. package/src/license/tiers.ts +12 -2
  27. package/src/modules/CoursePlayer/CoursePlayer.tsx +3 -1
  28. package/src/progress/stat-card.tsx +10 -5
  29. package/src/sections/AdaptiveLearningPath/AdaptiveLearningPath.tsx +251 -0
  30. package/src/sections/AdaptiveLearningPath/path-connector.tsx +27 -0
  31. package/src/sections/AdaptiveLearningPath/path-milestone-marker.tsx +50 -0
  32. package/src/sections/AdaptiveLearningPath/path-node-card.tsx +166 -0
  33. package/src/sections/AdaptiveLearningPath/path-skill-bar.tsx +49 -0
  34. package/src/sections/AdaptiveLearningPath/types.ts +159 -0
  35. package/src/sections/ContentAuthoringStudio/ContentAuthoringStudio.tsx +289 -0
  36. package/src/sections/ContentAuthoringStudio/block-editor-item.tsx +487 -0
  37. package/src/sections/ContentAuthoringStudio/block-type-picker.tsx +123 -0
  38. package/src/sections/ContentAuthoringStudio/types.ts +67 -0
  39. package/src/sections/ForumBoard/ForumBoard.tsx +8 -6
  40. package/src/sections/LessonPage/LessonPage.tsx +4 -7
  41. package/src/sections/index.ts +18 -0
  42. package/src/video/video-player.tsx +14 -5
  43. package/dist/StudentProfile-BVfZMbnV.cjs +0 -1
  44. package/dist/tabs-BsfVo2Bl.cjs +0 -173
  45. package/dist/tabs-BuY1iNJE.js +0 -22305
  46. package/dist/withProGate-BWqcKdPM.js +0 -137
  47. package/dist/withProGate-DX6XqKLp.cjs +0 -1
@@ -1,4 +1,4 @@
1
- import { useState, useMemo } from "react";
1
+ import { useState, useMemo, memo, useCallback } from "react";
2
2
  import {
3
3
  AlertCircle,
4
4
  Plus,
@@ -257,7 +257,7 @@ export function ForumBoard({
257
257
  <TopicRow
258
258
  key={topic.uid}
259
259
  topic={topic}
260
- onClick={() => onTopicClick(topic.uid)}
260
+ onClick={onTopicClick}
261
261
  />
262
262
  ))}
263
263
  </div>
@@ -275,18 +275,20 @@ export function ForumBoard({
275
275
  );
276
276
  }
277
277
 
278
- function TopicRow({
278
+ const TopicRow = memo(function TopicRow({
279
279
  topic,
280
280
  onClick,
281
281
  }: {
282
282
  topic: ForumTopic;
283
- onClick: () => void;
283
+ onClick: (uid: string) => void;
284
284
  }) {
285
+ const handleClick = useCallback(() => onClick(topic.uid), [onClick, topic.uid]);
286
+
285
287
  return (
286
288
  <button
287
289
  type="button"
288
290
  className="w-full text-left"
289
- onClick={onClick}
291
+ onClick={handleClick}
290
292
  >
291
293
  <Card
292
294
  className={cn(
@@ -339,4 +341,4 @@ function TopicRow({
339
341
  </Card>
340
342
  </button>
341
343
  );
342
- }
344
+ });
@@ -1,4 +1,4 @@
1
- import { useState, useEffect } from "react";
1
+ import { useState } from "react";
2
2
  import { Check, ChevronRight, Clock } from "lucide-react";
3
3
  import { ContentBlock } from "../../content";
4
4
  import { Skeleton } from "../../ui/skeleton";
@@ -27,14 +27,11 @@ export function LessonPage({
27
27
  className,
28
28
  style,
29
29
  }: LessonPageProps) {
30
- const [completed, setCompleted] = useState(isCompleted);
31
-
32
- useEffect(() => {
33
- setCompleted(isCompleted);
34
- }, [isCompleted]);
30
+ const [localCompleted, setLocalCompleted] = useState(false);
31
+ const completed = isCompleted || localCompleted;
35
32
 
36
33
  function handleMarkComplete() {
37
- setCompleted(true);
34
+ setLocalCompleted(true);
38
35
  onMarkComplete?.();
39
36
  }
40
37
 
@@ -129,3 +129,21 @@ export type {
129
129
  ProfileAchievement,
130
130
  ProfileCertificate,
131
131
  } from "./StudentProfile/types";
132
+
133
+ export { ContentAuthoringStudio } from "./ContentAuthoringStudio/ContentAuthoringStudio";
134
+ export type {
135
+ ContentAuthoringStudioProps,
136
+ AuthoringBlock,
137
+ } from "./ContentAuthoringStudio/types";
138
+
139
+ export { AdaptiveLearningPath } from "./AdaptiveLearningPath/AdaptiveLearningPath";
140
+ export type {
141
+ AdaptiveLearningPathProps,
142
+ PathNode,
143
+ PathNodeStatus,
144
+ PathNodeType,
145
+ PathSkill,
146
+ PathMilestone,
147
+ PathBranch,
148
+ PathProgress,
149
+ } from "./AdaptiveLearningPath/types";
@@ -1,4 +1,4 @@
1
- import { useRef, useCallback } from "react";
1
+ import { useRef, useCallback, useMemo } from "react";
2
2
  import { Video, Play } from "lucide-react";
3
3
  import type { VideoPlayerProps } from "./types";
4
4
  import { cn } from "../lib/utils";
@@ -21,6 +21,15 @@ export const VideoPlayer = ({
21
21
  const videoRef = useRef<HTMLVideoElement>(null);
22
22
  const lastReportedTime = useRef(-1);
23
23
 
24
+ const containerStyle = useMemo(
25
+ () => ({ aspectRatio, ...style }),
26
+ [aspectRatio, style],
27
+ );
28
+ const videoStyle = useMemo(
29
+ () => ({ width: "100%" as const, aspectRatio, display: "block" as const }),
30
+ [aspectRatio],
31
+ );
32
+
24
33
  const handleTimeUpdate = useCallback(() => {
25
34
  const video = videoRef.current;
26
35
  if (video && onTimeUpdate) {
@@ -36,7 +45,7 @@ export const VideoPlayer = ({
36
45
  return (
37
46
  <div
38
47
  className={cn("relative overflow-hidden rounded-lg border border-border bg-muted", className)}
39
- style={{ aspectRatio, ...style }}
48
+ style={containerStyle}
40
49
  >
41
50
  <div className="absolute inset-0 flex flex-col items-center justify-center gap-2">
42
51
  <div className="flex items-center justify-center size-12 rounded-full bg-muted-foreground/10">
@@ -54,14 +63,14 @@ export const VideoPlayer = ({
54
63
  return (
55
64
  <div
56
65
  className={cn("relative overflow-hidden rounded-lg", className)}
57
- style={{ aspectRatio, ...style }}
66
+ style={containerStyle}
58
67
  >
59
68
  {poster ? (
60
69
  <img
61
70
  src={poster}
62
71
  alt={title || "Video poster"}
63
72
  loading="lazy"
64
- style={{ width: "100%", height: "100%", objectFit: "cover" }}
73
+ className="w-full h-full object-cover"
65
74
  />
66
75
  ) : (
67
76
  <div className="absolute inset-0 flex items-center justify-center bg-muted">
@@ -103,7 +112,7 @@ export const VideoPlayer = ({
103
112
  onPause={onPause}
104
113
  onEnded={onEnded}
105
114
  onTimeUpdate={handleTimeUpdate}
106
- style={{ width: "100%", aspectRatio, display: "block" }}
115
+ style={videoStyle}
107
116
  >
108
117
  {tracks?.map((track) => (
109
118
  <track
@@ -1 +0,0 @@
1
- "use strict";const e=require("react/jsx-runtime"),o=require("react"),C=require("lucide-react"),s=require("./tabs-BsfVo2Bl.cjs"),ae=require("class-variance-authority");function re(t,n,r,x){const j=r.map(a=>({uid:n,answerUid:a.uid,content:a.content})),m=[...t.filter(a=>a.uid!==n),...j];return x==null||x(m),m}function ie({questions:t,initialAnswers:n=[],onAnswerChange:r,questionMaterials:x}){const[j,i]=o.useState(0),[m,a]=o.useState(n),[N,v]=o.useState(new Set),[h,b]=o.useState(!1),g=o.useRef(null),k=o.useRef(!0),S=o.useRef(t);S.current=t;const c=o.useRef(j);c.current=j;const y=o.useRef(r);y.current=r;const z=t[j];o.useEffect(()=>{var l;if(k.current){k.current=!1;return}(l=g.current)==null||l.focus()},[j]);const u=o.useMemo(()=>z?m.filter(l=>l.uid===z.uid):[],[m,z]),U=o.useMemo(()=>(x==null?void 0:x.filter(l=>l.questionUid===(z==null?void 0:z.uid)))??[],[x,z]),p=o.useMemo(()=>t.map((l,f)=>({uid:l.uid,sequence:f,isFlagged:N.has(l.uid),isAnswered:m.some(B=>B.uid===l.uid),isSkipped:!1})),[t,m,N]),A=o.useCallback(l=>{const f=S.current[c.current];f&&a(B=>re(B,f.uid,l,y.current))},[]),d=o.useCallback(l=>{const f=t.findIndex(B=>B.uid===l);f!==-1&&i(f)},[t]),w=o.useCallback(l=>{v(f=>{const B=new Set(f);return B.has(l)?B.delete(l):B.add(l),B})},[]),T=o.useCallback(()=>{i(l=>Math.min(l+1,S.current.length-1))},[]),R=o.useCallback(()=>{i(l=>Math.max(l-1,0))},[]);return{currentIndex:j,currentQuestion:z,sessionAnswers:m,flaggedUids:N,materialsOpen:h,setMaterialsOpen:b,questionAreaRef:g,currentQuestionAnswers:u,currentMaterials:U,navigatorItems:p,handleAnswer:A,handleNavigate:d,handleToggleFlag:w,goNext:T,goPrevious:R,hasNext:j<t.length-1,hasPrevious:j>0}}function H({isLoading:t,error:n,onRetry:r,skeleton:x,loadingClassName:j="space-y-4",className:i,style:m,children:a}){return t?e.jsx("div",{className:s.cn(j,i),style:m,children:x}):n?e.jsx("div",{className:s.cn("py-12",i),style:m,children:e.jsx(s.EmptyState,{icon:e.jsx(C.AlertCircle,{className:"size-10 text-destructive"}),title:"Something went wrong",description:n,action:r?e.jsx(s.Button,{variant:"outline",onClick:r,children:"Retry"}):void 0})}):e.jsx(e.Fragment,{children:a})}function Ne({questions:t,initialAnswers:n=[],onSubmit:r,onAnswerChange:x,timeElapsedSeconds:j,timeLimitSeconds:i,questionMaterials:m,isSubmitting:a=!1,readOnly:N=!1,isLoading:v,error:h,onRetry:b,className:g,style:k}){const{currentIndex:S,currentQuestion:c,sessionAnswers:y,flaggedUids:z,materialsOpen:u,setMaterialsOpen:U,questionAreaRef:p,currentQuestionAnswers:A,currentMaterials:d,navigatorItems:w,handleAnswer:T,handleNavigate:R,handleToggleFlag:l,goNext:f,goPrevious:B,hasNext:M,hasPrevious:_}=ie({questions:t,initialAnswers:n,onAnswerChange:x,questionMaterials:m}),E=o.useRef(y);E.current=y;const P=o.useRef(r);P.current=r;const Q=o.useCallback(()=>{P.current(E.current)},[]),L=o.useRef(c==null?void 0:c.uid);L.current=c==null?void 0:c.uid;const F=o.useCallback(()=>{const I=L.current;I&&l(I)},[l]),D=o.useCallback(()=>U(!0),[U]);return e.jsx(H,{isLoading:v,error:h,onRetry:b,className:g,style:k,skeleton:e.jsxs(e.Fragment,{children:[e.jsx(s.Skeleton,{className:"h-10 w-full"}),e.jsx(s.Skeleton,{className:"h-48 w-full"}),e.jsx(s.Skeleton,{className:"h-12 w-full"})]}),children:e.jsxs("div",{children:[e.jsx(s.AssessmentToolbar,{currentQuestionIndex:S,totalQuestions:t.length,hasNext:M,hasPrevious:_,onNext:f,onPrevious:B,onSubmit:Q,timeElapsedSeconds:j,timeLimitSeconds:i,questions:w,onNavigateToQuestion:R,currentQuestionUid:c==null?void 0:c.uid,isSubmitting:a,readOnly:N}),e.jsxs("span",{className:"sr-only","aria-live":"polite",children:["Question ",S+1," of ",t.length]}),c&&e.jsxs(s.Card,{className:"mt-3",ref:p,tabIndex:-1,children:[e.jsx(s.CardHeader,{className:"pb-0",children:e.jsx(s.QuestionHeaderBar,{questionNumber:S+1,totalQuestions:t.length,isFlagged:z.has(c.uid),onToggleFlag:F,hasMaterials:d.length>0,onOpenMaterials:D,readOnly:N})}),e.jsx(s.CardContent,{children:e.jsx(s.QuestionRenderer,{question:c,sessionAnswers:A,onAnswer:T,readOnly:N})})]}),!N&&e.jsxs("div",{className:"flex items-center justify-between gap-3 mt-3",children:[e.jsxs(s.Button,{variant:"outline",disabled:!_,onClick:B,children:[e.jsx(C.ChevronLeft,{className:"size-4 mr-1"}),"Previous"]}),M?e.jsxs(s.Button,{onClick:f,children:["Next",e.jsx(C.ChevronRight,{className:"size-4 ml-1"})]}):e.jsxs(s.Button,{onClick:Q,disabled:a,children:[a?"Submitting...":"Submit Quiz",!a&&e.jsx(C.Send,{className:"size-4 ml-1"})]})]}),e.jsx(s.QuestionMaterialsDrawer,{open:u,onOpenChange:U,materials:d,questionNumber:S+1})]})})}function ve({video:t,notes:n,layout:r="horizontal",notesPanelWidth:x="340px",notesPanelHeight:j="240px",isLoading:i,error:m,onRetry:a,onComplete:N,className:v,style:h}){const b=r==="horizontal",g=o.useCallback(()=>{var k;(k=t.onEnded)==null||k.call(t),N==null||N()},[t,N]);return e.jsx(H,{isLoading:i,error:m,onRetry:a,className:v,style:h,skeleton:e.jsxs(e.Fragment,{children:[e.jsx(s.Skeleton,{className:"aspect-video w-full rounded-lg"}),n!==void 0&&e.jsx(s.Skeleton,{className:"h-32 w-full rounded-lg"})]}),children:n?e.jsxs("div",{className:s.cn("flex overflow-hidden gap-4",b?"flex-row":"flex-col",v),style:h,children:[e.jsx("div",{className:"flex-1 min-w-0 min-h-0",children:e.jsx(s.VideoPlayer,{...t,onEnded:g})}),e.jsxs(s.Card,{className:s.cn("overflow-auto shrink-0 rounded-none border-0",b?"border-l border-border":"border-t border-border w-full"),style:{width:b?x:void 0,height:b?void 0:j},children:[e.jsx(s.CardHeader,{children:e.jsx(s.CardTitle,{children:"Notes"})}),e.jsx(s.CardContent,{children:typeof n=="string"?e.jsx("span",{className:"text-sm text-foreground",children:n}):n})]})]}):e.jsx("div",{className:v,style:h,children:e.jsx(s.VideoPlayer,{...t,onEnded:g})})})}function be({cards:t,title:n,description:r,shuffled:x=!1,onComplete:j,readOnly:i=!1,isLoading:m,error:a,onRetry:N,className:v,style:h}){const[b,g]=o.useState(!1),k={totalCards:t.length,wasShuffled:x};function S(){g(!0),j==null||j(k)}function c(){g(!1)}return e.jsx(H,{isLoading:m,error:a,onRetry:N,className:v,style:h,skeleton:e.jsxs(e.Fragment,{children:[e.jsx(s.Skeleton,{className:"h-6 w-48"}),e.jsx(s.Skeleton,{className:"h-64 w-full rounded-lg"})]}),children:b?e.jsx("div",{className:s.cn("flex flex-col items-center",v),style:h,children:e.jsx(s.Card,{children:e.jsxs(s.CardContent,{className:"pt-6 text-center flex flex-col items-center gap-2",children:[e.jsx(C.CheckCircle,{size:48,className:"text-success"}),e.jsx("span",{className:"text-xl font-bold text-foreground",children:"Deck complete!"}),n&&e.jsxs("span",{className:"text-muted-foreground",children:["You finished ",e.jsx("strong",{children:n})]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[k.totalCards," card",k.totalCards!==1?"s":""," studied",k.wasShuffled?" (shuffled)":""]}),e.jsx(s.Button,{className:"mt-2",onClick:c,children:"Study Again"})]})})}):e.jsx("div",{className:s.cn("flex flex-col items-center",v),style:h,children:e.jsx(s.FlashcardDeck,{cards:t,deckName:n,deckDescription:r,shuffled:x,showProgress:!0,onComplete:S,readOnly:i})})})}function we({score:t}){const n=t.percentage!==void 0?t.percentage:t.total>0?Math.round(t.correct/t.total*100):0;return e.jsx(s.Card,{className:"mb-3",children:e.jsx(s.CardContent,{className:"pt-6",children:e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsxs("span",{className:"text-2xl font-bold leading-none text-foreground",children:[n,"%"]}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[t.correct," of ",t.total," correct"]})]}),t.passed!==void 0&&e.jsx(s.Badge,{variant:t.passed?"success":"destructive",children:t.passed?"Passed":"Failed"}),t.passingScore!==void 0&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:["Passing score: ",t.passingScore,"%"]})]})})})}function X({questions:t,sessionAnswers:n,showCorrectAnswers:r}){const x=o.useMemo(()=>{const j=new Map;for(const i of n){const m=j.get(i.uid);m?m.push(i):j.set(i.uid,[i])}return j},[n]);return e.jsx("div",{className:"flex flex-col gap-3",children:t.map((j,i)=>e.jsxs(s.Card,{className:"overflow-hidden",children:[e.jsx("div",{className:"px-2 py-1 bg-muted",children:e.jsxs("span",{className:"text-xs text-muted-foreground font-semibold",children:["Question ",i+1]})}),e.jsx(s.Separator,{}),e.jsx(s.CardContent,{className:"pt-4 pb-4",children:e.jsx(s.QuestionRenderer,{question:j,sessionAnswers:x.get(j.uid)??[],readOnly:!0,showCorrectAnswers:r})})]},j.uid))})}function Ce(t,n,r,x){const j=new Map(t.map(a=>[a.uid,a])),i=new Set(r.flatMap(a=>a.questionUids)),m=t.filter(a=>!i.has(a.uid));return e.jsxs("div",{className:"flex flex-col gap-4",children:[r.map(a=>{const N=a.questionUids.map(v=>j.get(v)).filter(Boolean);return e.jsxs("div",{children:[e.jsx("span",{className:"uppercase text-xs tracking-wide text-muted-foreground font-semibold",children:a.label}),e.jsx(s.Separator,{className:"mb-2"}),e.jsx(X,{questions:N,sessionAnswers:n,showCorrectAnswers:x})]},a.label)}),m.length>0&&e.jsx("div",{children:e.jsx(X,{questions:m,sessionAnswers:n,showCorrectAnswers:x})})]})}function ke({questions:t,sessionAnswers:n,score:r,questionGroups:x,showCorrectAnswers:j=!0,isLoading:i,error:m,onRetry:a,className:N,style:v}){return i?e.jsxs("div",{className:s.cn("space-y-4",N),style:v,children:[e.jsx(s.Skeleton,{className:"h-16 w-full"}),e.jsx(s.Skeleton,{className:"h-24 w-full"}),e.jsx(s.Skeleton,{className:"h-24 w-full"}),e.jsx(s.Skeleton,{className:"h-24 w-full"})]}):m?e.jsx("div",{className:s.cn("py-12",N),style:v,children:e.jsx(s.EmptyState,{icon:e.jsx(C.AlertCircle,{className:"size-10 text-destructive"}),title:"Something went wrong",description:m,action:a?e.jsx(s.Button,{variant:"outline",onClick:a,children:"Retry"}):void 0})}):e.jsxs("div",{className:s.cn(N),style:v,children:[r&&e.jsx(we,{score:r}),x&&x.length>0?Ce(t,n,x,j):e.jsx(X,{questions:t,sessionAnswers:n,showCorrectAnswers:j})]})}function J(t){const n=[];for(const r of t)!r.children||r.children.length===0?n.push(r.uid):n.push(...J(r.children));return n}function Se({items:t,progress:n,courseTitle:r,activeItemUid:x,onItemClick:j,showOverallProgress:i=!0,showDuration:m=!0,showIcons:a=!0,readOnly:N=!1,isLoading:v,error:h,onRetry:b,className:g,style:k}){const{completedCount:S,totalCount:c,percentage:y}=o.useMemo(()=>{const z=J(t),u=z.length,U=n?z.filter(p=>n.some(A=>A.resourceUid===p&&A.isCompleted)).length:0;return{completedCount:U,totalCount:u,percentage:u>0?Math.round(U/u*100):0}},[t,n]);return v?e.jsxs("div",{className:s.cn("space-y-4",g),style:k,children:[e.jsx(s.Skeleton,{className:"h-6 w-48"}),e.jsx(s.Skeleton,{className:"h-2 w-full"}),e.jsx(s.Skeleton,{className:"h-8 w-full"}),e.jsx(s.Skeleton,{className:"h-8 w-full ml-6"}),e.jsx(s.Skeleton,{className:"h-8 w-full ml-6"}),e.jsx(s.Skeleton,{className:"h-8 w-full"}),e.jsx(s.Skeleton,{className:"h-8 w-full ml-6"}),e.jsx(s.Skeleton,{className:"h-8 w-full"})]}):h?e.jsx("div",{className:s.cn("py-12",g),style:k,children:e.jsx(s.EmptyState,{icon:e.jsx(C.AlertCircle,{className:"size-10 text-destructive"}),title:"Something went wrong",description:h,action:b?e.jsx(s.Button,{variant:"outline",onClick:b,children:"Retry"}):void 0})}):e.jsxs("div",{className:s.cn(g),style:k,children:[(r||i)&&e.jsxs("div",{className:"px-2 pt-2 pb-2",children:[r&&e.jsx("p",{className:s.cn("font-semibold text-sm text-foreground",i&&"mb-1"),children:r}),i&&e.jsxs("div",{children:[e.jsx(s.Progress,{value:y,size:"sm"}),e.jsxs("span",{className:"text-xs text-muted-foreground mt-0.5 block",children:[S," of ",c," completed"]})]})]}),(r||i)&&e.jsx(s.Separator,{}),e.jsx(s.CurriculumTree,{items:t,progress:n,activeItemUid:x,onItemClick:j,readOnly:N,showDuration:m,showIcons:a,showProgress:!0})]})}function ye({questions:t,instantFeedback:n=!0,allowRetry:r=!0,onComplete:x,shuffled:j=!1,readOnly:i=!1,isLoading:m,error:a,onRetry:N,className:v,style:h}){const b=o.useMemo(()=>{const L=t??[];return j?s.shuffle(L):L},[t,j]),[g,k]=o.useState(0),[S,c]=o.useState(new Set),[y,z]=o.useState(new Map),[u,U]=o.useState(new Set),[p,A]=o.useState(null),[d,w]=o.useState(!1),T=o.useRef(null),R=o.useRef(!0);o.useEffect(()=>{var L;if(R.current){R.current=!1;return}(L=T.current)==null||L.focus()},[g]);const l=b[g],f=l?S.has(l.uid):!1;function B(){if(!l||!p)return;const L=(y.get(l.uid)??0)+1;z(I=>new Map(I).set(l.uid,L)),c(I=>new Set(I).add(l.uid));const F=p.map(I=>({uid:l.uid,answerUid:I.uid,content:I.content}));s.scoreQuestion(l,F)===!0&&L===1&&U(I=>new Set(I).add(l.uid))}function M(){l&&(c(L=>{const F=new Set(L);return F.delete(l.uid),F}),A(null))}function _(){if(g<b.length-1)k(L=>L+1),A(null);else{const L={totalQuestions:b.length,correctOnFirstAttempt:u.size,totalAttempts:Array.from(y.values()).reduce((F,D)=>F+D,0)};w(!0),x==null||x(L)}}const E=o.useMemo(()=>!l||!p?[]:p.map(L=>({uid:l.uid,answerUid:L.uid,content:L.content})),[l,p]),P=o.useMemo(()=>l?s.scoreQuestion(l,E)===!0:!1,[l,E]),Q=b.length>0?Math.round(u.size/b.length*100):0;return e.jsx(H,{isLoading:m,error:a,onRetry:N,className:v,style:h,skeleton:e.jsxs(e.Fragment,{children:[e.jsx(s.Skeleton,{className:"h-2 w-full"}),e.jsx(s.Skeleton,{className:"h-48 w-full"})]}),children:d?e.jsx(s.Card,{className:v,style:h,children:e.jsxs(s.CardContent,{className:"pt-6 text-center",children:[e.jsx(C.CheckCircle,{size:48,className:"text-success mx-auto mb-4"}),e.jsx("p",{className:"text-xl font-bold mb-1 text-foreground",children:"Practice Complete!"}),e.jsxs("p",{className:"text-muted-foreground mb-2",children:[u.size," of ",b.length," correct on first attempt (",Q,"%)"]}),e.jsx("div",{className:"flex justify-center",children:e.jsx(s.Button,{variant:"outline",onClick:()=>{k(0),c(new Set),z(new Map),U(new Set),A(null),w(!1)},children:"Practice Again"})})]})}):e.jsxs("div",{className:v,style:h,children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsxs("span",{className:"font-semibold text-sm text-foreground",children:["Question ",g+1," of ",b.length]}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[u.size," correct on first try"]})]}),e.jsx(s.Progress,{value:g+(f?1:0),max:b.length,size:"sm",className:"mb-3"}),e.jsxs("span",{className:"sr-only","aria-live":"polite",children:["Question ",g+1," of ",b.length]}),l&&e.jsx(s.Card,{ref:T,tabIndex:-1,children:e.jsxs(s.CardContent,{className:"pt-6",children:[e.jsx(s.QuestionRenderer,{question:l,sessionAnswers:E,onAnswer:A,readOnly:i||f,showCorrectAnswers:f}),n&&f&&e.jsx(s.FeedbackBanner,{isCorrect:P,explanation:l.explanation,onRetry:r&&!P?M:void 0}),e.jsxs("div",{className:"flex justify-end gap-2 mt-2",children:[!f&&n&&e.jsx(s.Button,{onClick:B,disabled:!p||p.length===0||i,children:"Check Answer"}),(!n||f)&&e.jsx(s.Button,{onClick:_,disabled:i,children:g<b.length-1?"Next Question":"Finish"})]})]})})]})})}function Ae({questions:t=[],initialAnswers:n=[],onSubmit:r,onAnswerChange:x,timeLimitSeconds:j,timeElapsedSeconds:i,autoSubmitOnTimeout:m=!0,timeWarningThreshold:a=300,allowBackNavigation:N=!0,confirmBeforeSubmit:v=!0,examTitle:h,instructions:b,questionMaterials:g,isSubmitting:k=!1,readOnly:S=!1,isLoading:c,error:y,onRetry:z,className:u,style:U}){const{currentIndex:p,currentQuestion:A,sessionAnswers:d,flaggedUids:w,materialsOpen:T,setMaterialsOpen:R,questionAreaRef:l,currentQuestionAnswers:f,currentMaterials:B,navigatorItems:M,handleAnswer:_,handleNavigate:E,handleToggleFlag:P,goNext:Q,goPrevious:L,hasNext:F}=ie({questions:t,initialAnswers:n,onAnswerChange:x,questionMaterials:g}),[D,I]=o.useState(!1),[ce,de]=o.useState(!1),K=o.useRef(!1),q=o.useRef(d);q.current=d;const ee=o.useRef(r);ee.current=r;const se=o.useRef(i);se.current=i;const te=o.useRef(A==null?void 0:A.uid);te.current=A==null?void 0:A.uid;const V=j-i,oe=o.useMemo(()=>M.filter(G=>G.isAnswered).length,[M]),$=o.useCallback(G=>{const ne=q.current,pe=new Set(ne.map(Z=>Z.uid)),ge={timeElapsedSeconds:se.current,wasAutoSubmitted:G,answeredCount:t.filter(Z=>pe.has(Z.uid)).length,totalQuestions:t.length};ee.current(ne,ge)},[t]);o.useEffect(()=>{V<=a&&V>0&&de(!0)},[V,a]),o.useEffect(()=>{m&&V<=0&&!K.current&&(K.current=!0,$(!0))},[V,m,$]);const xe=o.useCallback(()=>{v?I(!0):$(!1)},[v,$]),me=o.useCallback(()=>{N&&L()},[N,L]),ue=o.useCallback(()=>{const G=te.current;G&&P(G)},[P]),he=o.useCallback(()=>R(!0),[R]),je=o.useCallback(()=>{I(!1),$(!1)},[$]),fe=o.useCallback(()=>I(!1),[]);return e.jsx(H,{isLoading:c,error:y,onRetry:z,className:u,style:U,skeleton:e.jsxs(e.Fragment,{children:[e.jsx(s.Skeleton,{className:"h-10 w-full"}),e.jsx(s.Skeleton,{className:"h-48 w-full"}),e.jsx(s.Skeleton,{className:"h-12 w-full"})]}),children:e.jsxs("div",{children:[h&&e.jsx("p",{className:"text-xl font-bold mb-2 text-foreground",children:h}),ce&&V>0&&V<=a&&e.jsx(s.Alert,{variant:"warning",className:"mb-2",children:e.jsxs(s.AlertDescription,{children:[Math.ceil(V/60)," minute",Math.ceil(V/60)!==1?"s":""," remaining"]})}),e.jsx(s.AssessmentToolbar,{currentQuestionIndex:p,totalQuestions:t.length,hasNext:F,hasPrevious:N&&p>0,onNext:Q,onPrevious:me,onSubmit:xe,timeElapsedSeconds:i,timeLimitSeconds:j,questions:M,onNavigateToQuestion:E,currentQuestionUid:A==null?void 0:A.uid,isSubmitting:k,readOnly:S}),b&&p===0&&e.jsx(s.Card,{className:"mt-3",children:e.jsx(s.CardContent,{className:"pt-6",children:b})}),e.jsxs("span",{className:"sr-only","aria-live":"polite",children:["Question ",p+1," of ",t.length]}),A&&e.jsxs(s.Card,{className:"mt-3",ref:l,tabIndex:-1,children:[e.jsx(s.CardHeader,{className:"pb-0",children:e.jsx(s.QuestionHeaderBar,{questionNumber:p+1,totalQuestions:t.length,isFlagged:w.has(A.uid),onToggleFlag:ue,hasMaterials:B.length>0,onOpenMaterials:he,readOnly:S})}),e.jsx(s.CardContent,{children:e.jsx(s.QuestionRenderer,{question:A,sessionAnswers:f,onAnswer:_,readOnly:S})})]}),e.jsx(s.QuestionMaterialsDrawer,{open:T,onOpenChange:R,materials:B,questionNumber:p+1}),e.jsx(s.ConfirmDialog,{open:D,title:"Submit Exam?",message:`You have answered ${oe} of ${t.length} questions. Once submitted, you cannot change your answers.`,confirmLabel:"Submit Exam",cancelLabel:"Continue Exam",confirmColor:"primary",onConfirm:je,onCancel:fe,isLoading:k})]})})}function Te({title:t,description:n,questions:r=[],initialAnswers:x=[],onSubmit:j,onAnswerChange:i,showProgress:m=!0,requireAll:a=!1,submitLabel:N="Submit Survey",isSubmitting:v=!1,readOnly:h=!1,isLoading:b,error:g,onRetry:k,className:S,style:c}){const[y,z]=o.useState(x),u=o.useMemo(()=>{const d=new Set(y.map(w=>w.questionUid));return r.filter(w=>d.has(w.uid)).length},[r,y]),U=!a||u===r.length;function p(d,w){z(T=>{const l=[...T.filter(f=>f.questionUid!==d),{questionUid:d,value:w}];return i==null||i(l),l})}const A=o.useMemo(()=>{const d=new Map;for(const w of y)d.set(w.questionUid,w);return d},[y]);return e.jsx(H,{isLoading:b,error:g,onRetry:k,className:S,style:c,skeleton:e.jsxs(e.Fragment,{children:[e.jsx(s.Skeleton,{className:"h-6 w-48"}),e.jsx(s.Skeleton,{className:"h-2 w-full"}),e.jsx(s.Skeleton,{className:"h-16 w-full"}),e.jsx(s.Skeleton,{className:"h-16 w-full"}),e.jsx(s.Skeleton,{className:"h-16 w-full"})]}),children:e.jsxs("div",{className:S,style:c,children:[e.jsx("p",{className:"text-xl font-bold text-foreground mb-2",children:t}),n&&e.jsx("div",{className:"mb-2 text-muted-foreground text-sm",children:typeof n=="string"?e.jsx("span",{children:n}):n}),m&&e.jsxs("div",{className:"mb-3",children:[e.jsx(s.Progress,{value:u/r.length*100}),e.jsxs("span",{className:"block text-xs text-muted-foreground mt-0.5",children:[u," of ",r.length," answered"]})]}),r.map((d,w)=>{var R,l;const T=A.get(d.uid);return e.jsx(s.Card,{className:"mb-2",children:e.jsxs(s.CardContent,{className:"pt-6",children:[e.jsxs("p",{className:"font-medium text-foreground mb-2",children:[w+1,". ",d.content,d.required&&e.jsx("span",{className:"text-destructive ml-0.5",children:"*"})]}),d.type==="likert"&&e.jsx(s.LikertScale,{value:T?Number(T.value):null,onChange:f=>p(d.uid,f),points:d.scalePoints,lowLabel:(R=d.scaleLabels)==null?void 0:R.low,highLabel:(l=d.scaleLabels)==null?void 0:l.high,readOnly:h}),d.type==="rating"&&e.jsx(s.StarRating,{value:T?Number(T.value):0,onChange:f=>p(d.uid,f),readOnly:h}),d.type==="open_text"&&e.jsx(s.RichTextEditor,{placeholder:"Type your response...",value:(T==null?void 0:T.value)??"",onChange:f=>p(d.uid,f),readOnly:h,className:"min-h-24",variant:"minimal"}),d.type==="choice"&&d.answers&&e.jsx("div",{className:"flex flex-col gap-2",children:d.answers.map(f=>e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer py-1 text-sm text-foreground has-[input:disabled]:cursor-default has-[input:disabled]:opacity-60",children:[e.jsx("input",{type:"radio",className:"accent-primary m-0 shrink-0",name:`survey-q-${d.uid}`,value:f.uid,checked:(T==null?void 0:T.value)===f.uid,onChange:()=>p(d.uid,f.uid),disabled:h}),e.jsx("span",{children:f.content})]},f.uid))}),d.type==="multiple_choice"&&d.answers&&e.jsx("div",{className:"flex flex-col gap-2",children:d.answers.map(f=>{const B=y.filter(M=>M.questionUid===d.uid).map(M=>String(M.value));return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer py-1 text-sm text-foreground has-[input:disabled]:cursor-default has-[input:disabled]:opacity-60",children:[e.jsx("input",{type:"checkbox",className:"accent-primary m-0 shrink-0",checked:B.includes(f.uid),disabled:h,onChange:M=>{const _=y.filter(P=>P.questionUid===d.uid);let E;M.target.checked?E=[..._,{questionUid:d.uid,value:f.uid}]:E=_.filter(P=>String(P.value)!==f.uid),z(P=>[...P.filter(Q=>Q.questionUid!==d.uid),...E]),i==null||i([...y.filter(P=>P.questionUid!==d.uid),...E])}}),e.jsx("span",{children:f.content})]},f.uid)})})]})},d.uid)}),e.jsx(s.Separator,{className:"my-3"}),e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[u," of ",r.length," answered"]}),e.jsx(s.Button,{onClick:()=>j(y),disabled:!U||v||h,children:v?"Submitting...":N})]})]})})}function ze({title:t,blocks:n,isCompleted:r=!1,onMarkComplete:x,onNextLesson:j,nextLessonTitle:i,estimatedDuration:m,showDuration:a=!0,readOnly:N=!1,isLoading:v,error:h,onRetry:b,className:g,style:k}){const[S,c]=o.useState(r);o.useEffect(()=>{c(r)},[r]);function y(){c(!0),x==null||x()}return e.jsx(H,{isLoading:v,error:h,onRetry:b,className:g,style:k,skeleton:e.jsxs(e.Fragment,{children:[e.jsx(s.Skeleton,{className:"h-8 w-64"}),e.jsx(s.Skeleton,{className:"h-24 w-full"}),e.jsx(s.Skeleton,{className:"h-16 w-full"}),e.jsx(s.Skeleton,{className:"h-32 w-full"})]}),children:e.jsxs("div",{children:[e.jsxs("div",{className:"mb-3",children:[e.jsx("p",{className:"text-2xl font-bold mb-0.5 text-foreground",children:t}),a&&m!=null&&e.jsxs("div",{className:"flex items-center gap-0.5 text-muted-foreground",children:[e.jsx(C.Clock,{size:16}),e.jsx("span",{className:"text-sm",children:s.formatDuration(m)})]})]}),e.jsx(s.Separator,{className:"mb-3"}),e.jsx("div",{className:"flex flex-col gap-3",children:n!=null&&n.length?n.map((z,u)=>e.jsx(s.ContentBlock,{block:z,readOnly:N},u)):e.jsx(s.EmptyState,{title:"No content yet",description:"This lesson doesn't have any content blocks."})}),e.jsx(s.Card,{className:"mt-4 sticky bottom-0 z-10",children:e.jsx(s.CardContent,{className:"px-4 py-3",children:e.jsxs("div",{className:"flex justify-between items-center",children:[S?e.jsxs("div",{className:"flex items-center gap-1 text-success",children:[e.jsx(C.Check,{size:20}),e.jsx("span",{className:"text-sm font-semibold",children:"Lesson Complete"})]}):e.jsxs(s.Button,{onClick:y,disabled:N,children:[e.jsx(C.Check,{size:18})," Mark Complete"]}),j&&e.jsxs(s.Button,{variant:S?"default":"outline",onClick:j,children:[i?`Next: ${i}`:"Next Lesson"," ",e.jsx(C.ChevronRight,{size:18})]})]})})})]})})}function Be({announcements:t,onMarkRead:n,onSelect:r,showAvatars:x=!0,previewLines:j=3,emptyMessage:i="No announcements yet",readOnly:m=!1,isLoading:a,error:N,onRetry:v,pageSize:h,currentPage:b=1,totalItems:g,onPageChange:k,className:S,style:c}){const[y,z]=o.useState(new Set),u=o.useMemo(()=>{const p=t.filter(d=>d.isPinned),A=t.filter(d=>!d.isPinned);return[...p,...A]},[t]);function U(p){z(d=>{const w=new Set(d);return w.has(p)?w.delete(p):w.add(p),w});const A=t.find(d=>d.uid===p);A&&!A.isRead&&(n==null||n(p))}return a?e.jsx("div",{className:s.cn("space-y-4",S),style:c,children:Array.from({length:3}).map((p,A)=>e.jsxs("div",{className:"flex gap-3 items-start",children:[e.jsx(s.Skeleton,{className:"h-10 w-10 rounded-full shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(s.Skeleton,{className:"h-5 w-48"}),e.jsx(s.Skeleton,{className:"h-4 w-full"}),e.jsx(s.Skeleton,{className:"h-4 w-full"})]})]},A))}):N?e.jsx("div",{className:s.cn("py-12",S),style:c,children:e.jsx(s.EmptyState,{icon:e.jsx(C.AlertCircle,{className:"size-10 text-destructive"}),title:"Something went wrong",description:N,action:v?e.jsx(s.Button,{variant:"outline",onClick:v,children:"Retry"}):void 0})}):u.length===0?e.jsx("div",{className:S,style:c,children:e.jsx(s.EmptyState,{title:i})}):e.jsxs("div",{className:s.cn("flex flex-col gap-2",S),style:c,children:[(k&&h?u.slice((b-1)*h,b*h):u).map(p=>{const A=y.has(p.uid);return e.jsx(s.Card,{className:s.cn(p.isRead&&"opacity-85",r&&"cursor-pointer",p.isPinned&&"border-l-4 border-l-warning"),onClick:()=>r&&!m?r(p):U(p.uid),children:e.jsx(s.CardContent,{className:"py-4",children:e.jsxs("div",{className:"flex gap-1.5 items-start",children:[x&&e.jsx(s.UserAvatar,{displayName:p.author.displayName,avatarUrl:p.author.avatarUrl,role:p.author.role,size:"medium"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-1 mb-0.5",children:[p.isPinned&&e.jsx(C.Pin,{size:14}),e.jsx("span",{className:s.cn("text-foreground",p.isRead?"font-normal":"font-semibold"),children:p.title}),!p.isRead&&e.jsx(s.Badge,{variant:"destructive",className:"text-[10px] px-1.5 py-0",children:"New"})]}),e.jsxs("span",{className:"block text-xs text-muted-foreground mb-1",children:[p.author.displayName," · ",s.formatTimestamp(p.createdAt)]}),e.jsx("div",{className:s.cn("text-sm text-foreground [&_p]:mb-2 [&_ul]:list-disc [&_ul]:pl-5 [&_ol]:list-decimal [&_ol]:pl-5",!A&&"line-clamp-(--preview-lines) overflow-hidden"),style:A?void 0:{"--preview-lines":j},dangerouslySetInnerHTML:{__html:p.content}}),!A&&p.content.replace(/<[^>]*>/g,"").length>200&&e.jsx(s.Button,{variant:"link",size:"xs",className:"px-0 mt-0.5 h-auto",onClick:d=>{d.stopPropagation(),U(p.uid)},children:"Read more"})]})]})})},p.uid)}),k&&h&&u.length>0&&e.jsx(s.Pagination,{currentPage:b,totalPages:Math.ceil((g??u.length)/h),onPageChange:k,className:"mt-4"})]})}function O(t){return t.replace(/<[^>]*>/g,"").trim().length===0}function Re({title:t,rootPost:n,replies:r,currentUser:x,onReply:j,onToggleLike:i,onMarkAnswer:m,maxDepth:a=3,allowReplies:N=!0,sortOrder:v="oldest",readOnly:h=!1,isLoading:b,error:g,onRetry:k,className:S,style:c}){const[y,z]=o.useState(null),[u,U]=o.useState(""),p=o.useMemo(()=>{const w=new Map;for(const T of r){const R=T.parentUid??n.uid,l=w.get(R)??[];l.push(T),w.set(R,l)}for(const[,T]of w)T.sort((R,l)=>v==="newest"?new Date(l.createdAt).getTime()-new Date(R.createdAt).getTime():v==="most_liked"?l.likeCount-R.likeCount:new Date(R.createdAt).getTime()-new Date(l.createdAt).getTime());return w},[r,n.uid,v]);if(b)return e.jsxs("div",{className:s.cn("space-y-4",S),style:c,children:[e.jsx(s.Skeleton,{className:"h-7 w-64"}),e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(s.Skeleton,{className:"h-8 w-8 rounded-full shrink-0"}),e.jsx(s.Skeleton,{className:"h-32 w-full"})]}),Array.from({length:2}).map((w,T)=>e.jsx("div",{className:"ml-8",children:e.jsx(s.Skeleton,{className:"h-20 w-full"})},T))]});if(g)return e.jsx("div",{className:s.cn("py-12",S),style:c,children:e.jsx(s.EmptyState,{icon:e.jsx(C.AlertCircle,{className:"size-10 text-destructive"}),title:"Something went wrong",description:g,action:k?e.jsx(s.Button,{variant:"outline",onClick:k,children:"Retry"}):void 0})});function A(w){O(u)||(j(w,u),U(""),z(null))}function d(w,T){const R=p.get(w.uid)??[],l=Math.min(T,a),f=e.jsxs("div",{className:"flex items-center gap-1",children:[i&&!h&&e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{children:e.jsxs(s.Button,{variant:"ghost",size:"sm","aria-label":w.isLikedByCurrentUser?"Unlike":"Like",className:s.cn(w.isLikedByCurrentUser&&"text-destructive"),onClick:()=>i(w.uid),children:[e.jsx(C.Heart,{size:14,fill:w.isLikedByCurrentUser?"currentColor":"none"}),w.likeCount>0?w.likeCount:"Like"]})}),e.jsx(s.TooltipContent,{children:w.isLikedByCurrentUser?"Unlike":"Like"})]}),N&&!h&&e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{children:e.jsxs(s.Button,{variant:"ghost",size:"sm","aria-label":"Reply",onClick:()=>z(w.uid),children:[e.jsx(C.Reply,{size:14}),"Reply"]})}),e.jsx(s.TooltipContent,{children:"Reply"})]}),m&&!h&&x.role!=="student"&&!w.isAnswer&&e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{children:e.jsxs(s.Button,{variant:"ghost",size:"sm","aria-label":"Mark as answer",className:"text-success",onClick:()=>m(w.uid),children:[e.jsx(C.CheckCircle,{size:14}),"Mark Answer"]})}),e.jsx(s.TooltipContent,{children:"Mark as answer"})]})]});return e.jsxs("div",{children:[e.jsx(s.PostCard,{author:w.author,content:w.content,createdAt:w.createdAt,updatedAt:w.updatedAt,actions:f,highlight:w.isAnswer?"answer":"none",indentLevel:l,className:"mb-2"}),y===w.uid&&e.jsx(s.Card,{className:"mb-2",style:{marginLeft:`${(l+1)*16}px`},children:e.jsxs(s.CardContent,{className:"py-4",children:[e.jsx(s.RichTextEditor,{className:"min-h-15 mb-2",placeholder:"Write a reply...",value:u,onChange:B=>U(B),variant:"minimal"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.Button,{size:"sm",onClick:()=>A(w.uid),disabled:O(u),children:"Post Reply"}),e.jsx(s.Button,{variant:"ghost",size:"sm",onClick:()=>{z(null),U("")},children:"Cancel"})]})]})}),R.map(B=>d(B,T+1))]},w.uid)}return e.jsxs("div",{className:S,style:c,children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx(C.MessageSquare,{size:20,className:"text-foreground shrink-0"}),e.jsx("span",{className:"text-lg font-semibold text-foreground",children:t}),e.jsxs(s.Badge,{variant:"muted",className:"text-xs",children:[r.length," ",r.length===1?"reply":"replies"]})]}),e.jsx(s.Separator,{className:"mb-2"}),d(n,0)]})}function Le({title:t,instructions:n,dueDate:r,maxScore:x,status:j,submissionTypes:i,existingSubmission:m,fileConstraints:a,onSubmit:N,onSaveDraft:v,grade:h,isSubmitting:b=!1,readOnly:g=!1,isLoading:k,error:S,onRetry:c,className:y,style:z}){const[u,U]=o.useState((m==null?void 0:m.textContent)??""),[p,A]=o.useState((m==null?void 0:m.files)??[]),[d,w]=o.useState((m==null?void 0:m.url)??""),[T,R]=o.useState(i[0]);if(k)return e.jsxs("div",{className:s.cn("space-y-4",y),style:z,children:[e.jsx(s.Skeleton,{className:"h-8 w-64"}),e.jsx(s.Skeleton,{className:"h-6 w-20"}),e.jsx(s.Skeleton,{className:"h-32 w-full"}),e.jsx(s.Skeleton,{className:"h-10 w-32"})]});if(S)return e.jsx("div",{className:s.cn("py-12",y),style:z,children:e.jsx(s.EmptyState,{icon:e.jsx(C.AlertCircle,{className:"size-10 text-destructive"}),title:"Something went wrong",description:S,action:c?e.jsx(s.Button,{variant:"outline",onClick:c,children:"Retry"}):void 0})});const l=!g&&!["submitted","graded"].includes(j);function f(){return{textContent:i.includes("text")?u:void 0,files:i.includes("file")?p:void 0,url:i.includes("url")?d:void 0}}return e.jsxs("div",{className:y,style:z,children:[e.jsx("div",{className:"flex justify-between items-start mb-2",children:e.jsxs("div",{children:[e.jsx("div",{className:"text-xl font-bold text-foreground mb-0.5",children:t}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.StatusBadge,{status:j}),r&&e.jsx(s.DueDateDisplay,{dueDate:r,size:"small"}),x!=null&&e.jsxs("span",{className:"text-sm text-muted-foreground",children:[x," points"]})]})]})}),e.jsx(s.Card,{className:"mb-3",children:e.jsxs(s.CardContent,{className:"pt-6",children:[e.jsx("div",{className:"font-semibold text-sm text-foreground mb-1",children:"Instructions"}),e.jsx("div",{className:"text-muted-foreground text-sm",children:typeof n=="string"?e.jsx("span",{children:n}):n})]})}),h&&e.jsx(s.Alert,{variant:"success",className:"mb-3",children:e.jsxs(s.AlertDescription,{children:[e.jsxs("div",{className:"font-semibold text-sm mb-1",children:["Grade: ",h.score,x!=null?` / ${x}`:""]}),h.feedback&&e.jsx("div",{children:h.feedback})]})}),l&&e.jsxs(e.Fragment,{children:[i.length>1?e.jsxs(s.Tabs,{value:T,onValueChange:B=>R(B),children:[e.jsxs(s.TabsList,{children:[i.includes("text")&&e.jsx(s.TabsTrigger,{value:"text",children:"Text"}),i.includes("file")&&e.jsx(s.TabsTrigger,{value:"file",children:"File Upload"}),i.includes("url")&&e.jsx(s.TabsTrigger,{value:"url",children:"URL"})]}),i.includes("text")&&e.jsx(s.TabsContent,{value:"text",children:e.jsx(s.RichTextEditor,{className:"min-h-45",placeholder:"Type your submission...",value:u,onChange:B=>U(B),variant:"default"})}),i.includes("file")&&e.jsx(s.TabsContent,{value:"file",children:e.jsx(s.FileUploadZone,{files:p,onFilesAdded:B=>A(M=>[...M,...B]),onFileRemove:B=>A(M=>M.filter((_,E)=>E!==B)),accept:a==null?void 0:a.acceptedTypes,maxFiles:a==null?void 0:a.maxFiles,maxSizeMB:a==null?void 0:a.maxSizeMB})}),i.includes("url")&&e.jsx(s.TabsContent,{value:"url",children:e.jsx(s.Input,{placeholder:"https://...",value:d,onChange:B=>w(B.target.value)})})]}):e.jsxs(e.Fragment,{children:[i.includes("text")&&e.jsx(s.RichTextEditor,{className:"min-h-45 mb-2",placeholder:"Type your submission...",value:u,onChange:B=>U(B),variant:"default"}),i.includes("file")&&e.jsx("div",{className:"mb-2",children:e.jsx(s.FileUploadZone,{files:p,onFilesAdded:B=>A(M=>[...M,...B]),onFileRemove:B=>A(M=>M.filter((_,E)=>E!==B)),accept:a==null?void 0:a.acceptedTypes,maxFiles:a==null?void 0:a.maxFiles,maxSizeMB:a==null?void 0:a.maxSizeMB})}),i.includes("url")&&e.jsx(s.Input,{className:"mb-2",placeholder:"https://...",value:d,onChange:B=>w(B.target.value)})]}),e.jsx(s.Separator,{className:"my-2"}),e.jsxs("div",{className:"flex gap-2 justify-end",children:[v&&e.jsxs(s.Button,{variant:"outline",onClick:()=>v(f()),disabled:b,children:[e.jsx(C.Save,{size:16}),"Save Draft"]}),e.jsxs(s.Button,{onClick:()=>N(f()),disabled:b,children:[e.jsx(C.Send,{size:16}),b?"Submitting...":"Submit"]})]})]})]})}function W({label:t,field:n,sortField:r,sortDir:x,onSort:j,textAlign:i}){const m=r===n;return e.jsx(s.TableHead,{className:s.cn("cursor-pointer select-none hover:bg-muted",i==="right"&&"text-right"),onClick:()=>j(n),children:e.jsxs("div",{className:s.cn("flex items-center gap-1",i==="right"&&"justify-end"),children:[e.jsx("span",{className:s.cn(m?"text-foreground":"text-muted-foreground"),children:t}),m&&(x==="asc"?e.jsx(C.ArrowUp,{size:14}):e.jsx(C.ArrowDown,{size:14}))]})})}function Ue({items:t,categories:n,overallGrade:r,showWeights:x=!0,showCategoryTotals:j=!0,onItemClick:i,readOnly:m=!1,isLoading:a,error:N,onRetry:v,pageSize:h,currentPage:b=1,totalItems:g,onPageChange:k,className:S,style:c}){const[y,z]=o.useState("dueDate"),[u,U]=o.useState("asc");function p(T){y===T?U(R=>R==="asc"?"desc":"asc"):(z(T),U("asc"))}const A=o.useMemo(()=>{const T=[...t];return T.sort((R,l)=>{let f=0;switch(y){case"name":f=R.name.localeCompare(l.name);break;case"score":f=(R.score??-1)-(l.score??-1);break;case"dueDate":f=(R.dueDate??"").localeCompare(l.dueDate??"");break;case"status":f=R.status.localeCompare(l.status);break}return u==="asc"?f:-f}),T},[t,y,u]),d=o.useMemo(()=>{if(!n||n.length===0)return[{category:null,items:A}];const T=n.map(l=>({category:l,items:A.filter(f=>f.categoryUid===l.uid)})),R=A.filter(l=>!l.categoryUid);return R.length>0&&T.push({category:null,items:R}),T},[A,n]),w=x?5:4;return a?e.jsxs("div",{className:s.cn("space-y-4",S),style:c,children:[e.jsx(s.Skeleton,{className:"h-20 w-full"}),e.jsx(s.Skeleton,{className:"h-10 w-full"}),e.jsx(s.Skeleton,{className:"h-12 w-full"}),e.jsx(s.Skeleton,{className:"h-12 w-full"}),e.jsx(s.Skeleton,{className:"h-12 w-full"}),e.jsx(s.Skeleton,{className:"h-12 w-full"}),e.jsx(s.Skeleton,{className:"h-12 w-full"})]}):N?e.jsx("div",{className:s.cn("py-12",S),style:c,children:e.jsx(s.EmptyState,{icon:e.jsx(C.AlertCircle,{className:"size-10 text-destructive"}),title:"Something went wrong",description:N,action:v?e.jsx(s.Button,{variant:"outline",onClick:v,children:"Retry"}):void 0})}):e.jsxs("div",{className:S,style:c,children:[r&&e.jsx(s.Card,{className:"mb-3",children:e.jsx(s.CardContent,{className:"pt-6",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(s.GradeIndicator,{percentage:r.percentage,letterGrade:r.letterGrade,size:"large",passingThreshold:60}),e.jsxs("div",{children:[e.jsx("div",{className:"text-lg font-semibold text-foreground",children:"Overall Grade"}),e.jsxs("span",{className:"text-sm text-muted-foreground",children:[r.pointsEarned," / ",r.pointsPossible," points"]})]})]})})}),e.jsx(s.Card,{children:e.jsxs(s.Table,{children:[e.jsx(s.TableHeader,{children:e.jsxs(s.TableRow,{children:[e.jsx(W,{label:"Assignment",field:"name",sortField:y,sortDir:u,onSort:p}),e.jsx(W,{label:"Status",field:"status",sortField:y,sortDir:u,onSort:p}),e.jsx(W,{label:"Due Date",field:"dueDate",sortField:y,sortDir:u,onSort:p}),e.jsx(W,{label:"Score",field:"score",sortField:y,sortDir:u,onSort:p,textAlign:"right"}),x&&e.jsx(s.TableHead,{className:"text-right text-muted-foreground",children:"Weight"})]})}),e.jsx(s.TableBody,{children:d.map((T,R)=>{var l;return e.jsxs(o.Fragment,{children:[T.category&&j&&e.jsx(s.TableRow,{className:"bg-muted hover:bg-muted",children:e.jsx(s.TableCell,{colSpan:w,children:e.jsxs("span",{className:"font-semibold text-sm text-foreground",children:[T.category.name,T.category.weight!=null&&` (${T.category.weight}%)`]})})}),T.items.map(f=>e.jsxs(s.TableRow,{className:s.cn(i&&!m&&"cursor-pointer"),onClick:()=>i&&!m?i(f):void 0,children:[e.jsx(s.TableCell,{children:f.name}),e.jsx(s.TableCell,{children:e.jsx(s.StatusBadge,{status:f.status,size:"small"})}),e.jsx(s.TableCell,{children:f.dueDate?e.jsx(s.DueDateDisplay,{dueDate:f.dueDate,submittedDate:f.submittedDate,size:"small"}):"—"}),e.jsx(s.TableCell,{className:"text-right",children:f.score!=null?e.jsxs("span",{className:"text-sm font-semibold text-foreground",children:[f.score," / ",f.maxScore]}):f.status==="excused"?e.jsx("span",{className:"text-sm text-muted-foreground",children:"Excused"}):e.jsx("span",{className:"text-sm text-muted-foreground",children:"—"})}),x&&e.jsx(s.TableCell,{className:"text-right",children:f.weight!=null?`${f.weight}%`:"—"})]},f.uid))]},((l=T.category)==null?void 0:l.uid)??`ungrouped-${R}`)})})]})}),k&&h&&e.jsx(s.Pagination,{currentPage:b,totalPages:Math.ceil((g??t.length)/h),onPageChange:k,className:"mt-4"})]})}const Me=["var(--palette-0)","var(--palette-1)","var(--palette-2)","var(--palette-3)"],Y=Me.length;function Fe(t){return`palette${(t%Y+Y)%Y}`}function De({overallProgress:t,totalTimeSpent:n,modules:r,recentActivity:x,streak:j,achievements:i,recentActivityLimit:m=5,onModuleClick:a,isLoading:N,error:v,onRetry:h,className:b,style:g}){const k=o.useMemo(()=>r.filter(c=>c.completedItems===c.totalItems).length,[r]),S=o.useMemo(()=>(x==null?void 0:x.map(c=>({uid:c.uid,type:c.type,title:c.description,timestamp:c.timestamp})))??[],[x]);return N?e.jsxs("div",{className:s.cn("space-y-4",b),style:g,children:[e.jsxs("div",{className:"grid grid-cols-3 gap-3",children:[e.jsx(s.Skeleton,{className:"h-24"}),e.jsx(s.Skeleton,{className:"h-24"}),e.jsx(s.Skeleton,{className:"h-24"})]}),e.jsx(s.Skeleton,{className:"h-32 w-32 rounded-full mx-auto"}),e.jsx(s.Skeleton,{className:"h-8 w-full"}),e.jsx(s.Skeleton,{className:"h-8 w-full"}),e.jsx(s.Skeleton,{className:"h-8 w-full"})]}):v?e.jsx("div",{className:s.cn("py-12",b),style:g,children:e.jsx(s.EmptyState,{icon:e.jsx(C.AlertCircle,{className:"size-10 text-destructive"}),title:"Something went wrong",description:v,action:h?e.jsx(s.Button,{variant:"outline",onClick:h,children:"Retry"}):void 0})}):e.jsxs("div",{className:b,style:g,children:[e.jsxs("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(160px,1fr))] gap-3 mb-4",children:[e.jsx(s.Card,{children:e.jsx(s.CardContent,{className:"p-3 flex justify-center",children:e.jsx(s.ProgressRing,{value:t,size:100})})}),e.jsx(s.StatCard,{icon:e.jsx(C.Clock,{size:24}),label:"Time Spent",description:"Total learning time",value:s.formatDuration(n)}),j&&e.jsx(s.Card,{children:e.jsx(s.CardContent,{className:"p-4 flex items-center",children:e.jsx(s.StreakBadge,{currentStreak:j.currentDays,longestStreak:j.longestDays,showLongest:!0})})}),e.jsx(s.StatCard,{icon:e.jsx(C.BookOpen,{size:24}),label:"Modules",description:"Course progress",value:`${k} / ${r.length}`,subtitle:"completed"})]}),e.jsx(s.Separator,{className:"mb-3"}),e.jsx("p",{className:"text-lg font-semibold mb-2 text-foreground",children:"Module Progress"}),e.jsx("div",{className:"flex flex-col gap-2 mb-4",children:r.map((c,y)=>{const z=c.totalItems>0?c.completedItems/c.totalItems*100:0;return e.jsx(s.Card,{className:s.cn("transition-colors",a&&"cursor-pointer hover:border-primary"),onClick:()=>a==null?void 0:a(c.uid),children:e.jsxs(s.CardContent,{className:"p-3",children:[e.jsxs("div",{className:"flex justify-between items-center mb-0.5",children:[e.jsx("span",{className:"font-semibold text-sm text-foreground",children:c.name}),e.jsxs("span",{className:"text-xs text-muted-foreground",children:[c.completedItems," / ",c.totalItems]})]}),e.jsx(s.Progress,{value:z,size:"sm",variant:z>=100?"success":Fe(y)})]})},c.uid)})}),x&&x.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(s.Separator,{className:"mb-3"}),e.jsx("p",{className:"text-lg font-semibold mb-2 text-foreground",children:"Recent Activity"}),e.jsx("div",{className:"mb-4",children:e.jsx(s.ActivityTimeline,{events:S,limit:m})})]}),i&&i.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(s.Separator,{className:"mb-3"}),e.jsx("p",{className:"text-lg font-semibold mb-2 text-foreground",children:"Achievements"}),e.jsx("div",{className:"grid grid-cols-[repeat(auto-fill,minmax(140px,1fr))] gap-2",children:i.map(c=>e.jsx(s.AchievementBadge,{title:c.name,description:c.description,icon:c.iconUrl?e.jsx("img",{src:c.iconUrl,alt:c.name,className:"w-12 h-12"}):void 0,earnedDate:c.earnedAt},c.uid))})]})]})}const Ee={classic:{size:40,paths:[{d:"M 2 38 L 2 10 Q 2 2 10 2 L 38 2",strokeWidth:1.5},{d:"M 7 38 L 7 13 Q 7 7 13 7 L 38 7",strokeWidth:.75}],color:"text-warning/50"},modern:null,elegant:{size:32,paths:[{d:"M 0 30 L 0 0 L 30 0",strokeWidth:.5}],dots:[{cx:2.5,cy:2.5,r:1.5}],color:"text-foreground/20"},academic:{size:36,paths:[{d:"M 0 36 L 0 0 L 36 0",strokeWidth:2},{d:"M 5 36 L 5 5 L 36 5",strokeWidth:1}],color:"text-info/35"},minimal:null,bold:{size:20,paths:[],dots:[{cx:5,cy:5,r:5}],color:"text-primary/40"}},Pe=[{key:"tl",pos:"top-3 left-3",transform:void 0},{key:"tr",pos:"top-3 right-3",transform:"scaleX(-1)"},{key:"bl",pos:"bottom-3 left-3",transform:"scaleY(-1)"},{key:"br",pos:"bottom-3 right-3",transform:"scale(-1)"}],Ie={classic:{lineColor:"bg-warning/30",motif:e.jsx("svg",{width:"12",height:"12",viewBox:"0 0 12 12",className:"text-warning/50 shrink-0","aria-hidden":"true",children:e.jsx("path",{d:"M6 0 L12 6 L6 12 L0 6 Z",fill:"currentColor"})})},modern:{lineColor:"bg-primary/20",motif:e.jsx("svg",{width:"8",height:"8",viewBox:"0 0 8 8",className:"text-primary/40 shrink-0","aria-hidden":"true",children:e.jsx("circle",{cx:"4",cy:"4",r:"3",fill:"currentColor"})})},elegant:{lineColor:"bg-foreground/10",motif:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",className:"text-foreground/15 shrink-0","aria-hidden":"true",children:e.jsx("path",{d:"M5 0 L6 4 L10 5 L6 6 L5 10 L4 6 L0 5 L4 4 Z",fill:"currentColor"})})},academic:{lineColor:"bg-info/25",motif:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",className:"text-info/40 shrink-0","aria-hidden":"true",children:e.jsx("path",{d:"M4 0 L6 0 L6 4 L10 4 L10 6 L6 6 L6 10 L4 10 L4 6 L0 6 L0 4 L4 4 Z",fill:"currentColor"})})},minimal:{lineColor:"bg-border",motif:null},bold:{lineColor:"bg-primary/40",motif:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",className:"text-primary/50 shrink-0","aria-hidden":"true",children:e.jsx("rect",{x:"1",y:"1",width:"8",height:"8",fill:"currentColor"})})}},_e={classic:{background:"radial-gradient(ellipse at center, var(--color-warning) 0%, transparent 65%)",opacity:.06},modern:null,elegant:{background:"radial-gradient(ellipse at center, var(--color-foreground) 0%, transparent 70%)",opacity:.03},academic:{background:"radial-gradient(ellipse at center, var(--color-info) 0%, transparent 65%)",opacity:.05},minimal:null,bold:{background:"radial-gradient(ellipse at 30% 50%, var(--color-primary) 0%, transparent 50%), radial-gradient(ellipse at 70% 50%, var(--color-palette-0) 0%, transparent 50%)",opacity:.06}},Qe={classic:"text-warning",modern:"text-primary",elegant:"text-foreground/60",academic:"text-info",minimal:"text-muted-foreground",bold:"text-primary"},He={classic:"uppercase tracking-[4px] text-base font-medium text-foreground/80 font-serif",modern:"uppercase tracking-[3px] text-base font-medium text-primary/80",elegant:"uppercase tracking-[5px] text-sm font-light text-foreground/50",academic:"uppercase tracking-[3px] text-base font-semibold text-info/80",minimal:"uppercase tracking-[2px] text-sm font-normal text-muted-foreground",bold:"uppercase tracking-[3px] text-lg font-black text-primary"},Ve={classic:"text-warning",modern:"text-primary",elegant:"text-foreground/80",academic:"text-info",minimal:"text-foreground",bold:"text-primary"},$e=new Set(["classic","elegant","academic"]),Ge=ae.cva("mx-auto max-w-4xl",{variants:{variant:{classic:"border-[3px] border-double border-warning/50 rounded-lg p-1.5",modern:"rounded-lg",elegant:"border border-foreground/15 rounded-lg p-2.5 dark:border-foreground/10",academic:"border-2 border-info/30 rounded-lg p-1.5",minimal:"rounded-lg",bold:"rounded-lg"}},defaultVariants:{variant:"classic"}}),We=ae.cva("relative text-center p-8 sm:p-12 md:p-16 overflow-hidden",{variants:{variant:{classic:"border border-warning/25 rounded bg-warning/5",modern:"border border-primary/20 rounded-lg bg-linear-to-br from-primary/5 to-primary/8 border-t-[3px] border-t-primary/60",elegant:"border border-foreground/8 rounded bg-linear-to-b from-background to-muted/20 dark:border-foreground/5 dark:to-muted/10",academic:"border border-info/15 rounded bg-info/3",minimal:"border border-border rounded-lg bg-background",bold:"border-[3px] border-primary rounded-lg bg-linear-to-br from-primary/8 to-palette-0/8"}},defaultVariants:{variant:"classic"}});function Oe({variant:t}){const n=Ee[t];return n?e.jsx(e.Fragment,{children:Pe.map(({key:r,pos:x,transform:j})=>{var i;return e.jsxs("svg",{className:s.cn("absolute pointer-events-none",x,n.color),width:n.size,height:n.size,viewBox:`0 0 ${n.size} ${n.size}`,fill:"none",stroke:"currentColor",style:j?{transform:j}:void 0,"aria-hidden":"true",children:[n.paths.map((m,a)=>e.jsx("path",{d:m.d,strokeWidth:m.strokeWidth},a)),(i=n.dots)==null?void 0:i.map((m,a)=>e.jsx("circle",{cx:m.cx,cy:m.cy,r:m.r,fill:"currentColor",stroke:"none"},`d${a}`))]},r)})}):null}function le({variant:t,className:n}){const r=Ie[t];return e.jsxs("div",{className:s.cn("flex items-center justify-center gap-3 my-5 mx-auto max-w-70",n),role:"separator","aria-hidden":"true",children:[e.jsx("span",{className:s.cn("flex-1 h-px",r.lineColor)}),r.motif,e.jsx("span",{className:s.cn("flex-1 h-px",r.lineColor)})]})}function Ze({recipientName:t,courseTitle:n,completionDate:r,organizationName:x,organizationLogo:j,signatory:i,certificateId:m,variant:a="classic",showActions:N=!0,onPrint:v,onDownload:h,isLoading:b,error:g,onRetry:k,className:S,style:c}){const y=o.useMemo(()=>{try{return new Date(r).toLocaleDateString("en-US",{year:"numeric",month:"long",day:"numeric"})}catch{return r}},[r]);function z(){v?v():window.print()}const u=_e[a];return e.jsx(H,{isLoading:b,error:g,onRetry:k,className:S,style:c,skeleton:e.jsx(s.Skeleton,{className:"h-80 w-full rounded-lg border"}),children:e.jsxs("div",{className:S,style:c,children:[e.jsx("div",{className:Ge({variant:a}),children:e.jsxs("div",{className:We({variant:a}),children:[e.jsx(Oe,{variant:a}),u&&e.jsx("div",{className:"absolute inset-0 pointer-events-none rounded-[inherit]",style:u,"aria-hidden":"true"}),e.jsxs("div",{className:"relative",children:[j?e.jsx("img",{src:j,alt:x,className:"h-20 mb-4 mx-auto block"}):e.jsx(C.Award,{size:64,className:s.cn("mx-auto mb-6",Qe[a])}),e.jsx("p",{className:s.cn("mb-2",He[a]),children:"Certificate of Completion"}),e.jsx(le,{variant:a}),e.jsx("p",{className:"text-base text-foreground/70 mb-2",children:"This is to certify that"}),e.jsx("p",{className:s.cn("text-4xl font-bold mb-4 text-foreground",$e.has(a)&&"font-serif"),children:t}),e.jsx("p",{className:"text-base text-foreground/70 mb-2",children:"has successfully completed"}),e.jsx("p",{className:s.cn("text-2xl font-semibold mb-4",Ve[a]),children:n}),e.jsxs("p",{className:"text-base text-foreground/60 mb-6",children:["Issued by ",x," on ",y]}),i&&e.jsxs("div",{className:"mt-6 mb-4",children:[e.jsx(le,{variant:a}),e.jsx("p",{className:"font-semibold text-base text-foreground",children:i.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:i.title})]}),m&&e.jsxs("span",{className:"block text-xs text-muted-foreground mt-4",children:["Certificate ID: ",m]})]})]})}),N&&e.jsxs("div",{className:"flex justify-center gap-3 mt-6",children:[e.jsxs(s.Button,{variant:"outline",onClick:z,children:[e.jsx(C.Printer,{size:16})," Print"]}),h&&e.jsxs(s.Button,{variant:"outline",onClick:h,children:[e.jsx(C.Download,{size:16})," Download"]})]})]})})}function Ye({criteria:t,selectedLevels:n,totalScore:r,maxScore:x,feedback:j,isLoading:i,error:m,onRetry:a,className:N,style:v}){var b;const h=n&&Object.keys(n).length>0;return i?e.jsxs("div",{className:s.cn("space-y-4",N),style:v,children:[e.jsx(s.Skeleton,{className:"h-10 w-full"}),Array.from({length:3}).map((g,k)=>e.jsx(s.Skeleton,{className:"h-16 w-full"},k))]}):m?e.jsx("div",{className:s.cn("py-12",N),style:v,children:e.jsx(s.EmptyState,{icon:e.jsx(C.AlertCircle,{className:"size-10 text-destructive"}),title:"Something went wrong",description:m,action:a?e.jsx(s.Button,{variant:"outline",onClick:a,children:"Retry"}):void 0})}):e.jsxs("div",{className:s.cn("flex flex-col gap-4",N),style:v,children:[h&&r!==void 0&&x!==void 0&&e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Rubric"}),e.jsxs(s.Badge,{variant:r>=x*.7?"success":"destructive",children:[r," / ",x," pts"]})]}),!h&&e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:"Grading Rubric"}),e.jsx(s.Card,{children:e.jsx(s.CardContent,{className:"p-0",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(s.Table,{className:"text-sm",children:[e.jsx(s.TableHeader,{children:e.jsxs(s.TableRow,{className:"bg-muted/50",children:[e.jsx(s.TableHead,{className:"text-left font-medium text-muted-foreground w-1/5",children:"Criterion"}),(b=t[0])==null?void 0:b.levels.map(g=>e.jsxs(s.TableHead,{className:"text-center font-medium text-muted-foreground",children:[e.jsx("div",{children:g.label}),e.jsxs("div",{className:"text-xs font-normal mt-0.5",children:[g.points," pts"]})]},g.uid))]})}),e.jsx(s.TableBody,{children:t.map((g,k)=>{const S=n==null?void 0:n[g.uid];return e.jsxs(s.TableRow,{className:s.cn(k%2===1&&"bg-muted/20"),children:[e.jsxs(s.TableCell,{className:"align-top",children:[e.jsx("div",{className:"font-medium text-foreground",children:g.name}),g.description&&e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:g.description})]}),g.levels.map(c=>{const y=S===c.uid;return e.jsxs(s.TableCell,{className:s.cn("align-top text-center",y&&"bg-primary/10 ring-2 ring-primary/30 ring-inset rounded-sm"),children:[e.jsx("div",{className:"text-xs text-muted-foreground",children:c.description}),y&&e.jsx("div",{className:"mt-1.5 flex justify-center",children:e.jsx(C.CheckCircle2,{className:"size-4 text-primary"})})]},c.uid)})]},g.uid)})})]})})})}),j&&e.jsxs(e.Fragment,{children:[e.jsx(s.Separator,{}),e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-medium text-foreground mb-1",children:"Instructor Feedback"}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:j})]})]})]})}function Xe({title:t,requirements:n,onRequirementClick:r,isLoading:x,error:j,onRetry:i,className:m,style:a}){const N=o.useMemo(()=>n.filter(h=>h.completed).length,[n]),v=n.length>0?Math.round(N/n.length*100):0;return x?e.jsxs("div",{className:s.cn("space-y-4",m),style:a,children:[e.jsx(s.Skeleton,{className:"h-6 w-48"}),e.jsx(s.Skeleton,{className:"h-2 w-full"}),Array.from({length:4}).map((h,b)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(s.Skeleton,{className:"h-5 w-5 rounded-full"}),e.jsx(s.Skeleton,{className:"h-4 w-3/4"})]},b))]}):j?e.jsx("div",{className:s.cn("py-12",m),style:a,children:e.jsx(s.EmptyState,{icon:e.jsx(C.AlertCircle,{className:"size-10 text-destructive"}),title:"Something went wrong",description:j,action:i?e.jsx(s.Button,{variant:"outline",onClick:i,children:"Retry"}):void 0})}):e.jsxs("div",{className:s.cn("flex flex-col gap-4",m),style:a,children:[t&&e.jsx("h3",{className:"text-lg font-semibold text-foreground",children:t}),e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[N," of ",n.length," complete"]}),e.jsxs("span",{className:"font-medium text-foreground",children:[v,"%"]})]}),e.jsx(s.Progress,{value:v})]}),e.jsx("ul",{className:"flex flex-col gap-1",children:n.map(h=>e.jsx("li",{children:e.jsxs("button",{type:"button",className:s.cn("w-full flex items-start gap-3 p-3 rounded-lg text-left transition-colors",h.completed?"bg-success/5":r?"hover:bg-muted/50 cursor-pointer":"cursor-default"),onClick:()=>{!h.completed&&r&&r(h.uid)},disabled:h.completed,children:[h.completed?e.jsx(C.CheckCircle2,{className:"size-5 text-success shrink-0 mt-0.5"}):e.jsx(C.Circle,{className:"size-5 text-muted-foreground shrink-0 mt-0.5"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:s.cn("text-sm font-medium",h.completed?"text-muted-foreground line-through":"text-foreground"),children:h.label}),h.description&&e.jsx("div",{className:"text-xs text-muted-foreground mt-0.5",children:h.description})]}),!h.completed&&r&&e.jsxs("div",{className:"shrink-0 flex items-center gap-1 text-xs text-primary mt-0.5",children:[h.actionLabel&&e.jsx("span",{children:h.actionLabel}),e.jsx(C.ChevronRight,{className:"size-4"})]})]})},h.uid))})]})}const Je={newest:"Newest",oldest:"Oldest",most_replies:"Most Replies",most_liked:"Most Liked"};function Ke({title:t,topics:n,onTopicClick:r,onCreateTopic:x,sortOrder:j="newest",onSortChange:i,searchQuery:m="",onSearchChange:a,readOnly:N,isLoading:v,error:h,onRetry:b,pageSize:g,currentPage:k=1,totalItems:S,onPageChange:c,className:y,style:z}){const[u,U]=o.useState(!1),[p,A]=o.useState(""),[d,w]=o.useState(""),[T,R]=o.useState(m),[l,f]=o.useState(j),B=a!==void 0?m:T,M=i!==void 0?j:l;function _(L){a?a(L):R(L)}function E(){const L=["newest","oldest","most_replies","most_liked"],F=L.indexOf(M),D=L[(F+1)%L.length];i?i(D):f(D)}function P(){!p.trim()||O(d)||(x==null||x(p.trim(),d),A(""),w(""),U(!1))}const Q=o.useMemo(()=>[...n.filter(F=>{var I;if(!B)return!0;const D=B.toLowerCase();return F.title.toLowerCase().includes(D)||((I=F.preview)==null?void 0:I.toLowerCase().includes(D))||F.author.displayName.toLowerCase().includes(D)})].sort((F,D)=>{if(F.isPinned&&!D.isPinned)return-1;if(!F.isPinned&&D.isPinned)return 1;switch(M){case"oldest":return new Date(F.createdAt).getTime()-new Date(D.createdAt).getTime();case"most_replies":return D.replyCount-F.replyCount;case"most_liked":return D.likeCount-F.likeCount;case"newest":default:return new Date(D.createdAt).getTime()-new Date(F.createdAt).getTime()}}),[n,B,M]);return v?e.jsxs("div",{className:s.cn("space-y-4",y),style:z,children:[e.jsx(s.Skeleton,{className:"h-9 w-full"}),Array.from({length:4}).map((L,F)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(s.Skeleton,{className:"h-8 w-8 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(s.Skeleton,{className:"h-5 w-64"}),e.jsx(s.Skeleton,{className:"h-4 w-32"})]})]},F))]}):h?e.jsx("div",{className:s.cn("py-12",y),style:z,children:e.jsx(s.EmptyState,{icon:e.jsx(C.AlertCircle,{className:"size-10 text-destructive"}),title:"Something went wrong",description:h,action:b?e.jsx(s.Button,{variant:"outline",onClick:b,children:"Retry"}):void 0})}):e.jsxs("div",{className:s.cn("flex flex-col gap-4",y),style:z,children:[e.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t&&e.jsx("h2",{className:"text-xl font-bold text-foreground",children:t}),!N&&x&&e.jsxs(s.Button,{size:"sm",onClick:()=>U(!u),children:[e.jsx(C.Plus,{className:"size-4 mr-1.5"}),"New Topic"]})]}),e.jsx(s.Separator,{}),u&&e.jsx(s.Card,{children:e.jsxs(s.CardContent,{className:"pt-4 space-y-3",children:[e.jsx(s.Input,{placeholder:"Topic title",value:p,onChange:L=>A(L.target.value)}),e.jsx(s.RichTextEditor,{placeholder:"What would you like to discuss?",value:d,onChange:L=>w(L),variant:"minimal"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(s.Button,{variant:"outline",size:"sm",onClick:()=>{U(!1),A(""),w("")},children:"Cancel"}),e.jsx(s.Button,{size:"sm",onClick:P,disabled:!p.trim()||O(d),children:"Post Topic"})]})]})}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"flex-1",children:e.jsx(s.SearchInput,{value:B,onChange:_,placeholder:"Search topics..."})}),e.jsxs(s.Button,{variant:"outline",size:"sm",onClick:E,children:[e.jsx(C.ArrowUpDown,{className:"size-3.5 mr-1.5"}),Je[M]]})]}),Q.length===0?e.jsx(s.EmptyState,{icon:e.jsx(C.MessageSquare,{className:"size-10 text-muted-foreground"}),title:"No topics found",description:B?"Try a different search term.":"Be the first to start a discussion!"}):e.jsx("div",{className:"flex flex-col gap-2",children:(c&&g?Q.slice((k-1)*g,k*g):Q).map(L=>e.jsx(qe,{topic:L,onClick:()=>r(L.uid)},L.uid))}),c&&g&&Q.length>0&&e.jsx(s.Pagination,{currentPage:k,totalPages:Math.ceil((S??Q.length)/g),onPageChange:c,className:"mt-4"})]})}function qe({topic:t,onClick:n}){return e.jsx("button",{type:"button",className:"w-full text-left",onClick:n,children:e.jsx(s.Card,{className:s.cn("transition-colors hover:bg-muted/30",t.isPinned&&"border-l-2 border-l-warning"),children:e.jsx(s.CardContent,{className:"py-3 px-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(s.UserAvatar,{displayName:t.author.displayName,avatarUrl:t.author.avatarUrl,size:"small"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("span",{className:"font-medium text-foreground text-sm truncate",children:t.title}),t.isPinned&&e.jsx(C.Pin,{className:"size-3 text-warning shrink-0"}),t.isAnswered&&e.jsxs(s.Badge,{variant:"success",className:"text-xs shrink-0",children:[e.jsx(C.CheckCircle2,{className:"size-3 mr-0.5"}),"Answered"]})]}),t.preview&&e.jsx("p",{className:"text-xs text-muted-foreground line-clamp-1",children:t.preview}),e.jsxs("div",{className:"flex items-center gap-3 mt-1.5 text-xs text-muted-foreground",children:[e.jsx("span",{children:t.author.displayName}),e.jsx("span",{children:s.formatTimestamp(t.createdAt)}),e.jsxs(s.Badge,{variant:"muted",className:"gap-0.5 text-xs px-1.5 py-0",children:[e.jsx(C.MessageSquare,{className:"size-3"}),t.replyCount]}),e.jsxs(s.Badge,{variant:"muted",className:"gap-0.5 text-xs px-1.5 py-0",children:[e.jsx(C.Heart,{className:"size-3"}),t.likeCount]})]})]})]})})})})}function es({course:t,prerequisites:n,onEnroll:r,onCancel:x,enrollLabel:j="Enroll Now",isEnrolling:i=!1,isLoading:m,error:a,onRetry:N,className:v,style:h}){const b=Array.isArray(n)&&n.length>0,[g,k]=o.useState("details"),S=o.useMemo(()=>b?[{key:"details",label:"Course Details"},{key:"prerequisites",label:"Prerequisites"},{key:"confirmation",label:"Confirmation"}]:[{key:"details",label:"Course Details"},{key:"confirmation",label:"Confirmation"}],[b]);if(m)return e.jsxs("div",{className:s.cn("space-y-4",v),style:h,children:[e.jsx(s.Skeleton,{className:"h-8 w-48"}),e.jsx(s.Skeleton,{className:"h-48 w-full"}),e.jsx(s.Skeleton,{className:"h-10 w-32"})]});if(a)return e.jsx("div",{className:s.cn("py-12",v),style:h,children:e.jsx(s.EmptyState,{icon:e.jsx(C.AlertCircle,{className:"size-10 text-destructive"}),title:"Something went wrong",description:a,action:N?e.jsx(s.Button,{variant:"outline",onClick:N,children:"Retry"}):void 0})});const c=S.findIndex(d=>d.key===g),y=!b||n.every(d=>d.isMet);function z(){const d=c+1;d<S.length&&k(S[d].key)}function u(){const d=c-1;d>=0&&k(S[d].key)}function U(){return e.jsx(s.Card,{children:e.jsxs(s.CardContent,{className:"pt-6",children:[t.thumbnailUrl?e.jsx("img",{src:t.thumbnailUrl,alt:t.title,className:"w-full h-48 object-cover rounded-lg mb-4"}):e.jsx("div",{className:"w-full h-48 rounded-lg mb-4 bg-muted flex items-center justify-center",children:e.jsx(C.BookOpen,{className:"size-12 text-muted-foreground"})}),e.jsx("h2",{className:"text-xl font-bold text-foreground mb-1",children:t.title}),t.description&&e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:t.description}),e.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[t.instructor&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.UserAvatar,{displayName:t.instructor.displayName,avatarUrl:t.instructor.avatarUrl,size:"small"}),e.jsx("span",{className:"text-sm text-foreground",children:t.instructor.displayName})]}),t.duration&&e.jsxs(s.Badge,{variant:"muted",children:[e.jsx(C.Clock,{className:"size-3 mr-1"}),t.duration]})]}),t.syllabus&&t.syllabus.length>0&&e.jsxs(e.Fragment,{children:[e.jsx(s.Separator,{className:"my-3"}),e.jsx("div",{className:"mb-1 text-sm font-semibold text-foreground",children:"Syllabus"}),e.jsx("ul",{className:"list-disc list-inside space-y-1",children:t.syllabus.map((d,w)=>e.jsx("li",{className:"text-sm text-muted-foreground",children:d},w))})]}),e.jsx(s.Separator,{className:"my-4"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[x&&e.jsx(s.Button,{variant:"outline",onClick:x,children:"Cancel"}),e.jsx(s.Button,{onClick:z,children:"Continue"})]})]})})}function p(){return e.jsx(s.Card,{children:e.jsxs(s.CardContent,{className:"pt-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-3",children:"Prerequisites"}),e.jsx("ul",{className:"space-y-3",children:n.map(d=>e.jsxs("li",{className:"flex items-start gap-2",children:[d.isMet?e.jsx(C.CheckCircle2,{className:"size-4 text-success shrink-0 mt-0.5"}):e.jsx(C.XCircle,{className:"size-4 text-destructive shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("span",{className:"text-sm font-medium text-foreground",children:d.label}),d.description&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5",children:d.description})]})]},d.uid))}),e.jsx(s.Separator,{className:"my-4"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(s.Button,{variant:"outline",onClick:u,children:"Back"}),e.jsx(s.Button,{onClick:z,disabled:!y,children:"Continue"})]})]})})}function A(){return e.jsx(s.Card,{children:e.jsxs(s.CardContent,{className:"pt-6",children:[e.jsx("h3",{className:"text-lg font-semibold text-foreground mb-3",children:"Confirm Enrollment"}),e.jsxs("div",{className:"space-y-2 mb-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C.BookOpen,{className:"size-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm font-medium text-foreground",children:t.title})]}),t.instructor&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(s.UserAvatar,{displayName:t.instructor.displayName,avatarUrl:t.instructor.avatarUrl,size:"small"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t.instructor.displayName})]}),t.duration&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(C.Clock,{className:"size-4 text-muted-foreground"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:t.duration})]})]}),b&&e.jsx("div",{className:"mb-3",children:y?e.jsxs(s.Badge,{variant:"success",children:[e.jsx(C.CheckCircle2,{className:"size-3 mr-1"}),"All prerequisites met"]}):e.jsxs(s.Badge,{variant:"warning",children:[e.jsx(C.XCircle,{className:"size-3 mr-1"}),"Some prerequisites not met"]})}),e.jsx(s.Separator,{className:"my-4"}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(s.Button,{variant:"outline",onClick:u,children:"Back"}),e.jsxs(s.Button,{onClick:()=>r(t.uid),disabled:i,children:[i&&e.jsx(C.Loader2,{className:"size-4 mr-1 animate-spin"}),j]})]})]})})}return e.jsxs("div",{className:v,style:h,children:[e.jsx(s.Stepper,{steps:S.map(d=>({label:d.label})),currentStep:c,className:"mb-6"}),g==="details"&&U(),g==="prerequisites"&&p(),g==="confirmation"&&A()]})}function ss({courses:t=[],categories:n,onCourseClick:r,onEnroll:x,viewMode:j="grid",allowViewToggle:i=!0,showSearch:m=!0,emptyMessage:a="No courses found",readOnly:N=!1,isLoading:v,error:h,onRetry:b,pageSize:g,currentPage:k=1,totalItems:S,onPageChange:c,className:y,style:z}){const[u,U]=o.useState(""),[p,A]=o.useState(null),[d,w]=o.useState(j),T=o.useMemo(()=>{let l=t;if(p&&(l=l.filter(f=>f.categoryUid===p)),u.trim()){const f=u.toLowerCase();l=l.filter(B=>{var M,_;return B.title.toLowerCase().includes(f)||((M=B.description)==null?void 0:M.toLowerCase().includes(f))||((_=B.instructor)==null?void 0:_.displayName.toLowerCase().includes(f))})}return l},[t,p,u]);if(v)return e.jsxs("div",{className:s.cn("space-y-4",y),style:z,children:[e.jsx(s.Skeleton,{className:"h-9 w-full"}),e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:Array.from({length:6}).map((l,f)=>e.jsx(s.Skeleton,{className:"h-64 w-full rounded-lg"},f))})]});if(h)return e.jsx("div",{className:s.cn("py-12",y),style:z,children:e.jsx(s.EmptyState,{icon:e.jsx(C.AlertCircle,{className:"size-10 text-destructive"}),title:"Something went wrong",description:h,action:b?e.jsx(s.Button,{variant:"outline",onClick:b,children:"Retry"}):void 0})});const R=c&&g?T.slice((k-1)*g,k*g):T;return e.jsxs("div",{className:y,style:z,children:[e.jsxs("div",{className:"flex gap-2 items-center mb-2",children:[m&&e.jsx("div",{className:"flex-1 max-w-80",children:e.jsx(s.SearchInput,{value:u,onChange:U,placeholder:"Search courses...",size:"small"})}),i&&e.jsxs("div",{className:"flex gap-0.5",children:[e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{children:e.jsx(s.Button,{variant:"ghost",size:"icon-xs","aria-label":"Grid view",className:s.cn(d==="grid"&&"text-primary"),onClick:()=>w("grid"),children:e.jsx(C.Grid,{size:18})})}),e.jsx(s.TooltipContent,{children:"Grid view"})]}),e.jsxs(s.Tooltip,{children:[e.jsx(s.TooltipTrigger,{children:e.jsx(s.Button,{variant:"ghost",size:"icon-xs","aria-label":"List view",className:s.cn(d==="list"&&"text-primary"),onClick:()=>w("list"),children:e.jsx(C.List,{size:18})})}),e.jsx(s.TooltipContent,{children:"List view"})]})]})]}),n&&n.length>0&&e.jsx(s.Tabs,{value:p??"all",onValueChange:l=>A(l==="all"?null:l),className:"mb-2",children:e.jsxs(s.TabsList,{children:[e.jsx(s.TabsTrigger,{value:"all",children:"All"}),n.map(l=>e.jsx(s.TabsTrigger,{value:l.uid,children:l.label},l.uid))]})}),T.length===0?e.jsx(s.EmptyState,{icon:e.jsx(C.GraduationCap,{}),title:a,description:"Try adjusting your search or filter."}):d==="grid"?e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:R.map(l=>e.jsx(s.CourseCard,{uid:l.uid,title:l.title,description:l.description,thumbnailUrl:l.thumbnailUrl,instructor:l.instructor,progress:l.progress,enrollmentStatus:l.enrollmentStatus,studentCount:l.studentCount,duration:l.duration,layout:"vertical",onClick:N?void 0:()=>r(l),onEnroll:x&&!N?()=>x(l):void 0,className:s.cn(N&&"opacity-70")},l.uid))}):e.jsx("div",{className:"flex flex-col gap-2",children:R.map(l=>e.jsx(s.CourseCard,{uid:l.uid,title:l.title,description:l.description,thumbnailUrl:l.thumbnailUrl,instructor:l.instructor,progress:l.progress,enrollmentStatus:l.enrollmentStatus,studentCount:l.studentCount,duration:l.duration,layout:"horizontal",onClick:N?void 0:()=>r(l),onEnroll:x&&!N?()=>x(l):void 0,className:s.cn(N&&"opacity-70")},l.uid))}),c&&g&&T.length>0&&e.jsx(s.Pagination,{currentPage:k,totalPages:Math.ceil((S??T.length)/g),onPageChange:c,className:"mt-4"})]})}function ts({student:t,enrolledCourses:n=[],achievements:r=[],certificates:x=[],stats:j,showCourses:i=!0,showAchievements:m=!0,onCourseClick:a,onCertificateClick:N,readOnly:v=!1,isLoading:h,error:b,onRetry:g,className:k,style:S}){const c=n.filter(u=>u.progress>=100),y=[{label:"Enrolled",value:String(n.length),icon:e.jsx(C.BookOpen,{size:24})},{label:"Completed",value:String(c.length),icon:e.jsx(C.GraduationCap,{size:24})}],z=j??y;return e.jsx(H,{isLoading:h,error:b,onRetry:g,className:k,style:S,skeleton:e.jsxs(e.Fragment,{children:[e.jsx(s.Card,{children:e.jsxs(s.CardContent,{className:"p-4 flex items-center gap-4",children:[e.jsx(s.Skeleton,{className:"size-12 rounded-full"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx(s.Skeleton,{className:"h-5 w-40"}),e.jsx(s.Skeleton,{className:"h-4 w-56"})]})]})}),e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:[e.jsx(s.Skeleton,{className:"h-24"}),e.jsx(s.Skeleton,{className:"h-24"}),e.jsx(s.Skeleton,{className:"h-24"}),e.jsx(s.Skeleton,{className:"h-24"})]}),e.jsx(s.Skeleton,{className:"h-8 w-full"}),e.jsx(s.Skeleton,{className:"h-8 w-full"}),e.jsx(s.Skeleton,{className:"h-8 w-full"})]}),children:e.jsxs("div",{className:s.cn("space-y-4",k),style:S,children:[e.jsx(s.Card,{children:e.jsxs(s.CardContent,{className:"p-4 flex items-start gap-4",children:[e.jsx(s.UserAvatar,{displayName:t.displayName,avatarUrl:t.avatarUrl,size:"large"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("h2",{className:"text-xl font-bold text-foreground",children:t.displayName}),t.role&&e.jsx(s.Badge,{variant:"secondary",children:t.role})]}),t.email&&e.jsx("p",{className:"text-sm text-muted-foreground",children:t.email}),t.bio&&e.jsx("p",{className:"text-sm text-foreground mt-1",children:t.bio}),t.joinedAt&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1 flex items-center gap-1",children:[e.jsx(C.Calendar,{size:12}),"Joined ",new Date(t.joinedAt).toLocaleDateString()]})]})]})}),e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-3",children:z.map(u=>e.jsx(s.StatCard,{icon:u.icon,label:u.label,value:u.value},u.label))}),i&&e.jsxs(e.Fragment,{children:[e.jsx(s.Separator,{}),e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground",children:"Enrolled Courses"}),e.jsx(s.Badge,{variant:"secondary",children:n.length})]}),n.length>0?e.jsx(s.Card,{children:e.jsx(s.CardContent,{className:"p-0 divide-y divide-border",children:n.map(u=>e.jsxs("div",{className:s.cn("flex items-center gap-3 px-4 py-3 transition-colors",!v&&a&&"cursor-pointer hover:bg-muted/50"),onClick:!v&&a?()=>a(u.uid):void 0,children:[e.jsx(s.ProgressRing,{value:u.progress,size:32,strokeWidth:3}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:u.title}),u.lastAccessedAt&&e.jsx("p",{className:"text-xs text-muted-foreground",children:s.formatTimestamp(u.lastAccessedAt)})]}),e.jsxs("span",{className:"text-xs text-muted-foreground whitespace-nowrap",children:[Math.round(u.progress),"%"]})]},u.uid))})}):e.jsx(s.EmptyState,{icon:e.jsx(C.BookOpen,{}),title:"No courses yet",description:"This student has not enrolled in any courses."})]}),m&&e.jsxs(e.Fragment,{children:[e.jsx(s.Separator,{}),e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground",children:"Achievements"}),e.jsx(s.Badge,{variant:"secondary",children:r.length})]}),r.length>0?e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 gap-2",children:r.map(u=>e.jsx(s.AchievementBadge,{title:u.name,description:u.description,icon:u.iconUrl?e.jsx("img",{src:u.iconUrl,alt:u.name,className:"w-12 h-12"}):void 0,earnedDate:u.earnedAt},u.uid))}):e.jsx(s.EmptyState,{icon:e.jsx(C.Award,{}),title:"No achievements yet",description:"Achievements will appear here as they are earned."})]}),e.jsx(s.Separator,{}),e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground",children:"Certificates"}),e.jsx(s.Badge,{variant:"secondary",children:x.length})]}),x.length>0?e.jsx(s.Card,{children:e.jsx(s.CardContent,{className:"p-0 divide-y divide-border",children:x.map(u=>e.jsxs("div",{className:s.cn("flex items-center gap-3 px-4 py-3 transition-colors",!v&&N&&"cursor-pointer hover:bg-muted/50"),onClick:!v&&N?()=>N(u.uid):void 0,children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-primary/10 flex items-center justify-center text-primary",children:e.jsx(C.Award,{size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground truncate",children:u.courseName}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Issued ",new Date(u.issuedAt).toLocaleDateString()]})]}),u.certificateUrl&&!v&&e.jsx(s.Button,{variant:"outline",size:"sm",onClick:U=>{U.stopPropagation(),window.open(u.certificateUrl,"_blank")},children:"View"})]},u.uid))})}):e.jsx(s.EmptyState,{icon:e.jsx(C.GraduationCap,{}),title:"No certificates yet",description:"Certificates will appear here once courses are completed."})]})})}exports.AnnouncementFeed=Be;exports.AssessmentReview=ke;exports.AssignmentSubmission=Le;exports.CertificateViewer=Ze;exports.CourseCatalog=ss;exports.CourseOutline=Se;exports.DiscussionThread=Re;exports.EnrollmentWizard=es;exports.ExamSession=Ae;exports.FlashcardStudySession=be;exports.ForumBoard=Ke;exports.GradebookTable=Ue;exports.LecturePlayer=ve;exports.LessonPage=ze;exports.PracticeQuiz=ye;exports.ProgressDashboard=De;exports.QuizSession=Ne;exports.RequirementsChecklist=Xe;exports.RubricView=Ye;exports.SectionShell=H;exports.StudentProfile=ts;exports.SurveyForm=Te;exports.flattenLeaves=J;exports.mergeSessionAnswers=re;