1import{c as te,j as e,C as j,at as J,au as K,e as re,B as v,i as ve,a as C,av as le,aw as ie,ax as ne,y as E,g as be,ay as Ne,G as $,r as M,ap as G,aq as I,d as b,T as ce,Z as oe,t as D,a7 as de,a8 as me,a9 as xe,a6 as we,I as ee,a0 as ye,a1 as ke,a2 as Ce,a3 as _e,a4 as Le,Y as De,L as se,A as Se,U as Te}from"./index-C6--jTPa.js";import{h as Pe}from"./useCourses-e5J4S7B_.js";import{d as Me}from"./useCertificates-DHAf2lGy.js";import{b as ze,c as Ge,d as Ie,e as Be,f as Xe,g as Ae,h as Ee,i as $e,j as Re}from"./useStudentProfile-C-JcXMnh.js";import{B as w}from"./badge-BpH-XLTX.js";import{P as F}from"./progress-Dy9eN8Ge.js";import{T as Ue,a as Fe,b as T,c as P}from"./tabs-D8fM3BSH.js";import{D as Oe}from"./download-Ik9YNL_L.js";import{T as S}from"./trophy-DgKiFJay.js";import{Z as he}from"./zap-CLUU1K-I.js";import{C as Ve}from"./crown-KtjDWeiU.js";import{F as z}from"./flame-DSbK-uqy.js";import{A as _}from"./award-ZALOTPF3.js";import{S as pe}from"./star-DW68ZENy.js";import{T as R}from"./target-C0DchUeA.js";import{F as He}from"./file-question-BrYB9Pes.js";import{C as qe}from"./calendar-BwhCPqqo.js";import{D as We,a as Ye,b as Ze,c as Qe,d as Je}from"./dialog-DWokV1Jm.js";import{P as Ke}from"./plus-CmT-yh5c.js";import{C as es}from"./circle-check-C00LgDD0.js";import{T as ss}from"./trash-2-C35Irn9n.js";import{S as as}from"./settings-9EQ3iqup.js";import{P as ae}from"./play-Dfn43174.js";import{B as X}from"./bookmark-BVIbKBaF.js";import{C as ts}from"./clock-CNf17kMS.js";import"./index-DBJC-V3p.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const rs=te("Gem",[["path",{d:"M6 3h12l4 6-10 13L2 9Z",key:"1pcd5k"}],["path",{d:"M11 3 8 9l4 13 4-13-3-6",key:"1fcu3u"}],["path",{d:"M2 9h20",key:"16fsjt"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const ge=te("Medal",[["path",{d:"M7.21 15 2.66 7.14a2 2 0 0 1 .13-2.2L4.4 2.8A2 2 0 0 1 6 2h12a2 2 0 0 1 1.6.8l1.6 2.14a2 2 0 0 1 .14 2.2L16.79 15",key:"143lza"}],["path",{d:"M11 12 5.12 2.2",key:"qhuxz6"}],["path",{d:"m13 12 5.88-9.8",key:"hbye0f"}],["path",{d:"M8 7h8",key:"i86dvs"}],["circle",{cx:"12",cy:"17",r:"5",key:"qbz8iq"}],["path",{d:"M12 18v-2h-.5",key:"fawc4q"}]]);function ls({certificateId:n,certificateNumber:r,courseName:o,studentName:i,certificateName:p,issuedAt:l,courseHours:x}){const s=p||i,c=()=>{const m=p||i,d=new URL(J,window.location.origin).href,h=`<!DOCTYPE html> 12<html> 13<head> 14 <meta charset="UTF-8"> 15 <title>Certificate - ${o}</title> 16 <style> 17 @import url('https://fonts.googleapis.com/css2?family=Playfair+Display:wght@400;600;700;800&family=Inter:wght@300;400;500;600&display=swap'); 18 * { margin: 0; padding: 0; box-sizing: border-box; } 19 body { 20 font-family: 'Inter', sans-serif; 21 display: flex; justify-content: center; align-items: center; 22 min-height: 100vh; background: #f0f0f0; padding: 20px; 23 } 24 .cert-wrapper { 25 width: 1000px; aspect-ratio: 1.414; padding: 16px; 26 background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%); 27 border-radius: 8px; position: relative; 28 } 29 .cert-inner { 30 width: 100%; height: 100%; background: #fffdf7; 31 border-radius: 4px; position: relative; overflow: hidden; 32 display: flex; flex-direction: column; align-items: center; 33 justify-content: center; padding: 60px; 34 } 35 .corner { position: absolute; width: 80px; height: 80px; } 36 .corner-tl { top: 20px; left: 20px; border-top: 3px solid #c9a84c; border-left: 3px solid #c9a84c; } 37 .corner-tr { top: 20px; right: 20px; border-top: 3px solid #c9a84c; border-right: 3px solid #c9a84c; } 38 .corner-bl { bottom: 20px; left: 20px; border-bottom: 3px solid #c9a84c; border-left: 3px solid #c9a84c; } 39 .corner-br { bottom: 20px; right: 20px; border-bottom: 3px solid #c9a84c; border-right: 3px solid #c9a84c; } 40 .logo-area { margin-bottom: 16px; text-align: center; } 41 .logo-img { width: 70px; height: 70px; object-fit: contain; margin: 0 auto; } 42 .platform-name { font-family: 'Playfair Display', serif; font-size: 14px; letter-spacing: 4px; color: #c9a84c; text-transform: uppercase; margin-top: 8px; text-align: center; } 43 .title { font-family: 'Playfair Display', serif; font-size: 42px; font-weight: 700; color: #1a1a2e; letter-spacing: 6px; text-transform: uppercase; margin: 12px 0 4px; } 44 .subtitle { font-size: 16px; letter-spacing: 8px; color: #666; text-transform: uppercase; margin-bottom: 32px; } 45 .presented { font-size: 14px; color: #888; letter-spacing: 2px; text-transform: uppercase; } 46 .name { font-family: 'Playfair Display', serif; font-size: 38px; font-weight: 600; color: #1a1a2e; margin: 16px 0; padding-bottom: 8px; border-bottom: 2px solid #c9a84c; display: inline-block; } 47 .course-label { font-size: 14px; color: #888; letter-spacing: 2px; text-transform: uppercase; margin-top: 8px; } 48 .course { font-family: 'Playfair Display', serif; font-size: 22px; color: #1a1a2e; font-weight: 600; margin-top: 8px; max-width: 600px; text-align: center; } 49 .details-row { display: flex; justify-content: center; gap: 60px; margin-top: 40px; padding-top: 24px; border-top: 1px solid #e0d9c8; } 50 .detail { text-align: center; } 51 .detail-label { font-size: 10px; letter-spacing: 3px; color: #999; text-transform: uppercase; } 52 .detail-value { font-size: 14px; color: #1a1a2e; font-weight: 500; margin-top: 4px; } 53 .verify-url { position: absolute; bottom: 12px; right: 24px; font-size: 9px; color: #bbb; } 54 .seal { position: absolute; bottom: 40px; left: 60px; width: 70px; height: 70px; border: 2px solid #c9a84c; border-radius: 50%; display: flex; align-items: center; justify-content: center; } 55 .seal-inner { width: 54px; height: 54px; border: 1px solid #c9a84c; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: 'Playfair Display', serif; font-size: 9px; color: #c9a84c; text-align: center; letter-spacing: 1px; text-transform: uppercase; line-height: 1.3; } 56 </style> 57</head> 58<body> 59 <div class="cert-wrapper"> 60 <div class="cert-inner"> 61 <div class="corner corner-tl"></div> 62 <div class="corner corner-tr"></div> 63 <div class="corner corner-bl"></div> 64 <div class="corner corner-br"></div> 65 <div class="logo-area"> 66 <img class="logo-img" src="${d}" alt="SkilliHire Logo" style="height: 40px; width: auto;" /> 67 <div class="platform-name">SkilliHire</div> 68 </div> 69 <div class="title">Certificate</div> 70 <div class="subtitle">of Completion</div> 71 <div class="presented">This is to certify that</div> 72 <div class="name">${m}</div> 73 <div class="course-label">has successfully completed the course</div> 74 <div class="course">${o}</div> 75 <div class="details-row"> 76 <div class="detail"> 77 <div class="detail-label">Date Issued</div> 78 <div class="detail-value">${K(new Date(l),"MMMM d, yyyy")}</div> 79 </div> 80 ${x?`<div class="detail"><div class="detail-label">Duration</div><div class="detail-value">${x} Hours</div></div>`:""} 81 <div class="detail"> 82 <div class="detail-label">Certificate ID</div> 83 <div class="detail-value" style="font-family: monospace; font-size: 12px;">${r}</div> 84 </div> 85 </div> 86 <div class="seal"><div class="seal-inner">Verified<br/>Authentic</div></div> 87 <div class="verify-url">Verify at: ${window.location.origin}/certificate/${r}</div> 88 </div> 89 </div> 90</body> 91</html>`,t=new Blob([h],{type:"text/html"}),f=URL.createObjectURL(t),y=document.createElement("a");y.href=f,y.download=`certificate-${r}.html`,y.click(),URL.revokeObjectURL(f)};return e.jsxs(j,{className:"overflow-hidden",children:[e.jsx("div",{className:"relative p-1 bg-gradient-to-br from-[hsl(var(--primary))] via-[hsl(var(--primary)/0.8)] to-[hsl(var(--primary)/0.6)]",children:e.jsxs("div",{className:"bg-[#fffdf7] dark:bg-card p-6 relative",children:[e.jsx("div",{className:"absolute top-2 left-2 w-8 h-8 border-t-2 border-l-2 border-amber-500/60"}),e.jsx("div",{className:"absolute top-2 right-2 w-8 h-8 border-t-2 border-r-2 border-amber-500/60"}),e.jsx("div",{className:"absolute bottom-2 left-2 w-8 h-8 border-b-2 border-l-2 border-amber-500/60"}),e.jsx("div",{className:"absolute bottom-2 right-2 w-8 h-8 border-b-2 border-r-2 border-amber-500/60"}),e.jsxs("div",{className:"text-center mb-4",children:[e.jsx("img",{src:J,alt:"SkilliHire Logo",className:"w-auto h-8 mx-auto mb-2 object-contain"}),e.jsx("p",{className:"text-[10px] tracking-[4px] text-amber-600 uppercase font-medium",children:"SkilliHire"}),e.jsx("h2",{className:"text-lg font-bold tracking-[4px] uppercase mt-1",children:"Certificate"}),e.jsx("p",{className:"text-[10px] tracking-[6px] text-muted-foreground uppercase",children:"of Completion"})]}),e.jsxs("div",{className:"text-center space-y-2",children:[e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-widest",children:"This is to certify that"}),e.jsx("div",{className:"inline-block",children:e.jsx("p",{className:"text-xl font-semibold border-b-2 border-amber-500 inline-block pb-1",children:s})}),e.jsx("p",{className:"text-[10px] text-muted-foreground uppercase tracking-widest",children:"has successfully completed"}),e.jsx("p",{className:"text-sm font-bold text-primary",children:o})]}),e.jsxs("div",{className:"flex justify-between items-center mt-4 pt-3 border-t border-amber-200/50 text-[10px] text-muted-foreground",children:[e.jsxs("div",{children:[e.jsx("p",{className:"uppercase tracking-widest",children:"Date"}),e.jsx("p",{className:"font-medium text-foreground text-xs",children:K(new Date(l),"MMM d, yyyy")})]}),x&&e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"uppercase tracking-widest",children:"Duration"}),e.jsxs("p",{className:"font-medium text-foreground text-xs",children:[x,"h"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"uppercase tracking-widest",children:"Certificate ID"}),e.jsx("p",{className:"font-medium text-foreground font-mono text-[10px]",children:r})]})]})]})}),e.jsxs("div",{className:"p-3 bg-muted/50 flex gap-2 justify-end items-center",children:[e.jsx(re,{to:`/certificate/${r}`,target:"_blank",children:e.jsxs(v,{variant:"outline",size:"sm",className:"text-xs",children:[e.jsx(ve,{className:"w-3 h-3 mr-1"}),"Verify"]})}),e.jsxs(v,{size:"sm",onClick:c,className:"text-xs",children:[e.jsx(Oe,{className:"w-3 h-3 mr-1"}),"Download"]})]})]})}const is={BookOpen:E,Zap:he,Brain:be,Trophy:S,Medal:ge,Crown:Ve,Flame:z,Fire:z,Rocket:Ne,Award:_,GraduationCap:$,Star:pe,Target:R,Gem:rs,FileQuestion:He};function ns({name:n,description:r,icon:o,xpReward:i,earned:p=!1,earnedAt:l,size:x="md",showTooltip:s=!0}){const c=is[o]||S,m={sm:"w-10 h-10",md:"w-14 h-14",lg:"w-20 h-20"},d={sm:"h-5 w-5",md:"h-7 w-7",lg:"h-10 w-10"},h=e.jsxs("div",{className:C("relative rounded-full flex items-center justify-center transition-all duration-300",m[x],p?"bg-gradient-to-br from-yellow-400 via-amber-500 to-orange-500 shadow-lg shadow-amber-500/30 ring-2 ring-amber-400/50":"bg-muted border-2 border-dashed border-muted-foreground
91/30"),children:[e.jsx(c,{className:C(d[x],p?"text-white drop-shadow-md":"text-muted-foreground/50")}),p&&e.jsx("div",{className:"absolute -bottom-1 -right-1 bg-green-500 rounded-full p-0.5",children:e.jsx("svg",{className:"w-3 h-3 text-white",fill:"currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{fillRule:"evenodd",d:"M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z",clipRule:"evenodd"})})})]});return s?e.jsxs(le,{children:[e.jsx(ie,{asChild:!0,children:h}),e.jsx(ne,{side:"top",className:"max-w-xs",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-semibold",children:n}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r}),e.jsxs("p",{className:"text-xs text-amber-500 mt-1",children:["+",i," XP"]}),p&&l&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Earned ",new Date(l).toLocaleDateString()]})]})})]}):h}function cs({activityData:n,currentStreak:r,longestStreak:o}){const i=M.useMemo(()=>{const l=[],x=new Date;for(let s=29;s>=0;s--){const c=new Date(x);c.setDate(c.getDate()-s);const m=c.toISOString().split("T")[0],d=n.find(h=>h.activity_date===m);l.push({date:m,dayOfWeek:c.getDay(),dayOfMonth:c.getDate(),hasActivity:!!d&&(d.lessons_completed>0||d.minutes_watched>0),lessonsCompleted:(d==null?void 0:d.lessons_completed)||0,minutesWatched:(d==null?void 0:d.minutes_watched)||0,xpEarned:(d==null?void 0:d.xp_earned)||0,isToday:s===0})}return l},[n]),p=(l,x)=>{const s=l*2+Math.floor(x/10);return s===0?"bg-muted":s<=2?"bg-green-200 dark:bg-green-900":s<=5?"bg-green-400 dark:bg-green-700":s<=10?"bg-green-500 dark:bg-green-600":"bg-green-600 dark:bg-green-500"};return e.jsxs(j,{className:"glass-card",children:[e.jsx(G,{className:"pb-3",children:e.jsxs(I,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(qe,{className:"h-5 w-5 text-primary"}),e.jsx("span",{children:"Learning Activity"})]}),e.jsxs("div",{className:"flex items-center gap-4 text-sm font-normal",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"h-4 w-4 text-orange-500"}),e.jsx("span",{className:"font-semibold",children:r}),e.jsx("span",{className:"text-muted-foreground",children:"day streak"})]}),e.jsxs("div",{className:"text-muted-foreground",children:["Best: ",e.jsx("span",{className:"font-semibold text-foreground",children:o})]})]})]})}),e.jsxs(b,{children:[e.jsx("div",{className:"flex flex-wrap gap-1",children:i.map(l=>e.jsxs(le,{children:[e.jsx(ie,{asChild:!0,children:e.jsx("div",{className:C("w-6 h-6 rounded-sm transition-all cursor-pointer hover:ring-2 hover:ring-primary/50",p(l.lessonsCompleted,l.minutesWatched),l.isToday&&"ring-2 ring-primary")})}),e.jsx(ne,{children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium",children:new Date(l.date).toLocaleDateString("en-US",{weekday:"short",month:"short",day:"numeric"})}),l.hasActivity?e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm",children:[l.lessonsCompleted," lessons"]}),e.jsxs("p",{className:"text-sm",children:[l.minutesWatched," min watched"]}),l.xpEarned>0&&e.jsxs("p",{className:"text-xs text-amber-500",children:["+",l.xpEarned," XP"]})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"No activity"})]})})]},l.date))}),e.jsxs("div",{className:"flex items-center justify-end gap-2 mt-4 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Less"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx("div",{className:"w-3 h-3 rounded-sm bg-muted"}),e.jsx("div",{className:"w-3 h-3 rounded-sm bg-green-200 dark:bg-green-900"}),e.jsx("div",{className:"w-3 h-3 rounded-sm bg-green-400 dark:bg-green-700"}),e.jsx("div",{className:"w-3 h-3 rounded-sm bg-green-500 dark:bg-green-600"}),e.jsx("div",{className:"w-3 h-3 rounded-sm bg-green-600 dark:bg-green-500"})]}),e.jsx("span",{children:"More"})]})]})]})}const U=[{level:1,name:"Newcomer",minXP:0},{level:2,name:"Beginner",minXP:100},{level:3,name:"Learner",minXP:300},{level:4,name:"Explorer",minXP:600},{level:5,name:"Achiever",minXP:1e3},{level:6,name:"Scholar",minXP:1500},{level:7,name:"Expert",minXP:2500},{level:8,name:"Master",minXP:4e3}
91,{level:9,name:"Champion",minXP:6e3},{level:10,name:"Legend",minXP:1e4}];function ue(n){let r=U[0];for(const o of U)if(n>=o.minXP)r=o;else break;return r}function os(n){for(const r of U)if(n<r.minXP)return r;return null}function ds({currentXP:n,className:r}){const o=ue(n),i=os(n),p=n-o.minXP,l=i?i.minXP-o.minXP:0,x=i?Math.min(100,p/l*100):100;return e.jsxs("div",{className:C("space-y-2",r),children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-gradient-to-br from-amber-400 to-orange-500 flex items-center justify-center shadow-lg shadow-amber-500/30",children:e.jsx("span",{className:"text-white font-bold text-sm",children:o.level})}),e.jsx(pe,{className:"absolute -top-1 -right-1 h-4 w-4 text-amber-400 fill-amber-400"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold",children:o.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Level ",o.level]})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"font-bold text-lg gradient-text-brand",children:[n.toLocaleString()," XP"]}),i&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:[(i.minXP-n).toLocaleString()," XP to ",i.name]})]})]}),e.jsxs("div",{className:"relative",children:[e.jsx(F,{value:x,className:"h-3"}),i&&e.jsxs("div",{className:"absolute right-0 -top-1 flex items-center gap-1 text-xs text-muted-foreground",children:[e.jsx(ce,{className:"h-3 w-3"}),e.jsxs("span",{children:["Level ",i.level]})]})]})]})}function ms({limit:n=10,className:r}){const{user:o}=oe(),{data:i,isLoading:p}=ze(n),l=s=>{switch(s){case 1:return e.jsx(S,{className:"h-5 w-5 text-yellow-500"});case 2:return e.jsx(ge,{className:"h-5 w-5 text-gray-400"});case 3:return e.jsx(_,{className:"h-5 w-5 text-amber-700"});default:return e.jsx("span",{className:"w-5 text-center text-muted-foreground font-medium",children:s})}},x=s=>{switch(s){case 1:return"bg-gradient-to-r from-yellow-50 to-amber-50 dark:from-yellow-950/30 dark:to-amber-950/30 border-yellow-200 dark:border-yellow-800";case 2:return"bg-gradient-to-r from-gray-50 to-slate-50 dark:from-gray-950/30 dark:to-slate-950/30 border-gray-200 dark:border-gray-800";case 3:return"bg-gradient-to-r from-amber-50 to-orange-50 dark:from-amber-950/30 dark:to-orange-950/30 border-amber-200 dark:border-amber-800";default:return""}};return e.jsxs(j,{className:C("glass-card",r),children:[e.jsx(G,{className:"pb-3",children:e.jsxs(I,{className:"flex items-center gap-2",children:[e.jsx(ce,{className:"h-5 w-5 text-primary"}),"Leaderboard"]})}),e.jsx(b,{children:p?e.jsx("div",{className:"space-y-3",children:Array.from({length:5}).map((s,c)=>e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(D,{className:"h-5 w-5"}),e.jsx(D,{className:"h-10 w-10 rounded-full"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(D,{className:"h-4 w-24"}),e.jsx(D,{className:"h-3 w-16 mt-1"})]}),e.jsx(D,{className:"h-6 w-16"})]},c))}):i!=null&&i.length?e.jsx("div",{className:"space-y-2",children:i.map((s,c)=>{var f;const m=c+1,d=ue(s.xp_points),h=s.user_id===(o==null?void 0:o.id),t=s.profile;return e.jsxs("div",{className:C("flex items-center gap-3 p-2 rounded-lg border transition-colors",x(m),h&&"ring-2 ring-primary"),children:[e.jsx("div",{className:"w-8 flex justify-center",children:l(m)}),e.jsxs(de,{className:"h-10 w-10",children:[e.jsx(me,{src:t==null?void 0:t.avatar_url}),e.jsx(xe,{className:"bg-primary/10",children:((f=t==null?void 0:t.full_name)==null?void 0:f[0])||"?"})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"font-medium truncate",children:[(t==null?void 0:t.full_name)||"Anonymous",h&&e.jsx("span",{className:"text-primary ml-1",children:"(You)"})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Level ",d.level," ⢠",d.name]})]}),e.jsxs(w,{variant:"secondary",className:"bg-amber-100 text-amber-700 dark:bg-amber-900/30 dark:text-amber-400",children:[s.xp_points.toLocaleStr
91ing()," XP"]})]},s.id)})}):e.jsx("p",{className:"text-muted-foreground text-center py-6",children:"No learners on the leaderboard yet"})})]})}const A=[{value:"courses",label:"Complete courses",unit:"courses"},{value:"lessons",label:"Complete lessons",unit:"lessons"},{value:"hours",label:"Watch hours",unit:"hours"},{value:"streak",label:"Maintain streak",unit:"days"}];function xs(){const{toast:n}=we(),{data:r,isLoading:o}=Ge(),i=Ie(),p=Be(),[l,x]=M.useState(!1),[s,c]=M.useState({title:"",goal_type:"lessons",target_value:10}),m=async()=>{if(!s.title.trim()){n({title:"Please enter a goal title",variant:"destructive"});return}try{await i.mutateAsync(s),n({title:"Goal created!",description:"Start working towards your new goal."}),x(!1),c({title:"",goal_type:"lessons",target_value:10})}catch{n({title:"Failed to create goal",variant:"destructive"})}},d=async t=>{try{await p.mutateAsync(t),n({title:"Goal removed"})}catch{n({title:"Failed to remove goal",variant:"destructive"})}},h=t=>A.find(f=>f.value===t)||A[0];return e.jsxs(j,{className:"glass-card",children:[e.jsx(G,{className:"pb-3",children:e.jsxs(I,{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-5 w-5 text-primary"}),"Learning Goals"]}),e.jsxs(We,{open:l,onOpenChange:x,children:[e.jsx(Ye,{asChild:!0,children:e.jsxs(v,{size:"sm",variant:"outline",className:"gap-1",children:[e.jsx(Ke,{className:"h-4 w-4"}),"Add Goal"]})}),e.jsxs(Ze,{children:[e.jsx(Qe,{children:e.jsx(Je,{children:"Create a Learning Goal"})}),e.jsxs("div",{className:"space-y-4 pt-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Goal Title"}),e.jsx(ee,{placeholder:"e.g., Complete AI Course this month",value:s.title,onChange:t=>c({...s,title:t.target.value})})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Goal Type"}),e.jsxs(ye,{value:s.goal_type,onValueChange:t=>c({...s,goal_type:t}),children:[e.jsx(ke,{children:e.jsx(Ce,{})}),e.jsx(_e,{children:A.map(t=>e.jsx(Le,{value:t.value,children:t.label},t.value))})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium",children:"Target"}),e.jsx(ee,{type:"number",min:1,value:s.target_value,onChange:t=>c({...s,target_value:parseInt(t.target.value)||1})})]})]}),e.jsx(v,{className:"w-full",onClick:m,disabled:i.isPending,children:"Create Goal"})]})]})]})]})}),e.jsx(b,{children:o?e.jsx("div",{className:"space-y-4",children:[1,2].map(t=>e.jsx("div",{className:"animate-pulse h-20 bg-muted rounded-lg"},t))}):r!=null&&r.length?e.jsx("div",{className:"space-y-4",children:r.map(t=>{const f=h(t.goal_type),y=Math.min(100,t.current_value/t.target_value*100);return e.jsxs("div",{className:C("p-4 rounded-lg border transition-colors",t.is_completed?"bg-green-50 dark:bg-green-950/20 border-green-200 dark:border-green-800":""),children:[e.jsxs("div",{className:"flex items-start justify-between mb-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[t.is_completed&&e.jsx(es,{className:"h-4 w-4 text-green-500"}),e.jsx("h4",{className:"font-medium",children:t.title})]}),e.jsx(v,{variant:"ghost",size:"icon",className:"h-8 w-8 text-muted-foreground hover:text-destructive",onClick:()=>d(t.id),children:e.jsx(ss,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs("span",{className:"text-muted-foreground",children:[t.current_value," / ",t.target_value," ",f.unit]}),e.jsxs("span",{className:"font-medium",children:[Math.round(y),"%"]})]}),e.jsx(F,{value:y,className:"h-2"})]})]},t.id)})}):e.jsxs("div",{className:"text-center py-6",children:[e.jsx(R,{className:"h-12 w-12 mx-auto text-muted-foreground mb-2"}),e.jsx("p",{className:"text-muted-foreground",children:"No goals set yet"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Create a goal to stay motivated!"})]})})]})}function Es(){var O,V,H,q,W,Y;const n=De(),{user:r,loading:o}=oe(),{data:i,isLoading:p}=Pe(),{data:l,isLoading:x}=Me(),{data:s}=Xe(),{data:c}=Ae(),{data:m}=Ee(),{data:d}=$e(30),{data:h}=Re();if(M.useEffect(()=>{!o&&!r&&n("/login")},[r,o,n]),o||p)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx(se,{className:"h-8 w-8 animate-spin text-primary"})});if(!r)return null;const t=(i==null?void 0:i.filter(a=>a.completed_at))||[],f=(i==null?void 0:i.filter(a=>!a.completed_at&&a.payment_status==="completed"))||[];
91i!=null&&i.length&&Math.round(i.reduce((a,g)=>a+(g.progress_percentage||0),0)/i.length);const y=(s==null?void 0:s.xp_points)||0,B=(s==null?void 0:s.current_streak)||0,fe=(s==null?void 0:s.longest_streak)||0,je=new Set((c==null?void 0:c.map(a=>a.achievement_id))||[]);return e.jsxs("div",{className:"min-h-screen pt-20",children:[e.jsx("section",{className:"py-8 lg:py-12 mesh-gradient",children:e.jsxs("div",{className:"container mx-auto px-4 lg:px-8",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row gap-6 lg:gap-8",children:[e.jsxs("div",{className:"flex items-start gap-4 flex-1",children:[e.jsxs(de,{className:"h-20 w-20 border-4 border-white shadow-xl",children:[e.jsx(me,{src:(O=r.user_metadata)==null?void 0:O.avatar_url}),e.jsx(xe,{className:"text-2xl bg-gradient-to-br from-primary to-secondary text-white",children:((H=(V=r.user_metadata)==null?void 0:V.full_name)==null?void 0:H[0])||((W=(q=r.email)==null?void 0:q[0])==null?void 0:W.toUpperCase())})]}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-1",children:[e.jsx("h1",{className:"text-2xl lg:text-3xl font-bold",children:((Y=r.user_metadata)==null?void 0:Y.full_name)||"Learner"}),B>=7&&e.jsxs(w,{className:"bg-orange-500 text-white gap-1",children:[e.jsx(z,{className:"h-3 w-3"}),B," day streak"]})]}),e.jsx("p",{className:"text-muted-foreground mb-3",children:(s==null?void 0:s.headline)||"Learning enthusiast"}),e.jsx(ds,{currentXP:y})]})]}),e.jsxs("div",{className:"flex gap-4 lg:gap-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-14 h-14 mx-auto rounded-xl bg-white/80 dark:bg-white/10 flex items-center justify-center mb-2 shadow-lg",children:e.jsx(S,{className:"h-7 w-7 text-amber-500"})}),e.jsx("p",{className:"text-2xl font-bold",children:(c==null?void 0:c.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Badges"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-14 h-14 mx-auto rounded-xl bg-white/80 dark:bg-white/10 flex items-center justify-center mb-2 shadow-lg",children:e.jsx(_,{className:"h-7 w-7 text-green-500"})}),e.jsx("p",{className:"text-2xl font-bold",children:(l==null?void 0:l.length)||0}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Certificates"})]}),e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"w-14 h-14 mx-auto rounded-xl bg-white/80 dark:bg-white/10 flex items-center justify-center mb-2 shadow-lg",children:e.jsx(E,{className:"h-7 w-7 text-blue-500"})}),e.jsx("p",{className:"text-2xl font-bold",children:t.length}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Completed"})]})]})]}),e.jsxs("div",{className:"flex flex-wrap gap-3 mt-6",children:[e.jsxs(v,{className:"hero-gradient text-primary-foreground group",onClick:()=>n("/courses"),children:[e.jsx(E,{className:"mr-2 h-4 w-4"}),"Browse Courses",e.jsx(Se,{className:"ml-2 h-4 w-4 transition-transform group-hover:translate-x-1"})]}),e.jsxs(v,{variant:"outline",onClick:()=>n("/student/profile"),children:[e.jsx(Te,{className:"mr-2 h-4 w-4"}),"Edit Profile"]}),e.jsx(v,{variant:"outline",asChild:!0,children:e.jsxs(re,{to:"/dashboard",children:[e.jsx(as,{className:"mr-2 h-4 w-4"}),"Dashboard Hub"]})})]})]})}),e.jsx("section",{className:"py-8 lg:py-12",children:e.jsx("div",{className:"container mx-auto px-4 lg:px-8",children:e.jsxs("div",{className:"grid lg:grid-cols-3 gap-6 lg:gap-8",children:[e.jsxs("div",{className:"lg:col-span-2 space-y-6",children:[e.jsx(cs,{activityData:d||[],currentStreak:B,longestStreak:fe}),e.jsxs(Ue,{defaultValue:"in-progress",className:"space-y-4",children:[e.jsxs(Fe,{className:"grid w-full grid-cols-4",children:[e.jsxs(T,{value:"in-progress",className:"gap-1",children:[e.jsx(ae,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"In Progress"}),e.jsx(w,{variant:"secondary",className:"ml-1",children:f.length})]}),e.jsxs(T,{value:"completed",className:"gap-1",children:[e.jsx(_,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Completed"}),e.jsx(w,{variant:"secondary",className:"ml-1",children:t.length})]}),e.jsxs(T,{value:"bookmarks",className:"gap-1",children:[e.jsx(X,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Saved"}),e.jsx(w,{variant:"secondary",className:"ml-1",children:(h==null?void 0:h.length)||0})]}),e.jsxs(T,{value:"certificates",className:"gap-1",children:[e.jsx($,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:"Certs"}),e.jsx(w,{variant:"secondary",className:"ml-1",children:(l==null?void 0:l.length)||0})]})]}),e.jsx(P,{value:"in-progress",children:f.length>0?e.jsx("div",{className:"grid sm:grid-cols-2 gap-4",children:f.map(a=>{var g,u,N,k;return e.jsxs(j,{className:"glass-card-hover overflow-hidden group cursor-pointer",onClick:()=>{var L;return n(`/learn/${(L=a.course)==null?void 0:L.slug}`)},children:[e.jsxs("div",{className:"relative h-32 overflow-hidden",children:[e.jsx("img",{src:((g=a.course)==null?void 0:g.thumbnail_url)||"https://images.unsplash.com/photo-1516321318423-f06f85e504b3?w=600&h=400&fit=crop",alt:(u=a.course)==null?void 0:u.title,className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-110"}),e.jsx("div",{className:"absolute inset-0 bg-gradient-to-t from-black/80 to-transparent"}),e.jsxs("div",{className:"absolute bottom-3 left-3 right-3",children:[e.jsx(F,{value:a.progress_percentage,className:"h-2"}),e.jsxs("p",{className:"text-white/80 text-xs mt-1",children:[a.progress_percentage,"% complete"]})]})]}),e.jsxs(b,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold line-clamp-1 group-hover:text-primary transition-colors",children:(N=a.course)==null?void 0:N.title}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("span",{className:"text-sm text-muted-foreground flex items-center gap-1",children:[e.jsx(ts,{className:"h-3 w-3"}),(k=a.course)==null?void 0:k.duration_hours,"h"]}),e.jsxs(v,{size:"sm",variant:"ghost",className:"gap-1 text-primary",children:[e.jsx(ae,{className:"h-3 w-3"}),"Resume"]})]})]})]},a.id)})}):e.jsx(j,{className:"glass-card text-center py-12",children:e.jsxs(b,{children:[e.jsx(he,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No courses in progress"}),e.jsx("p",{className:"text-muted-foreground mb-4",children:"Start learning something new today!"}),e.jsx(v,{onClick:()=>n("/courses"),children:"Browse Courses"})]})})}),e.jsx(P,{value:"completed",children:t.length>0?e.jsx("div",{className:"grid sm:grid-cols-2 gap-4",children:t.map(a=>{var g,u,N;return e.jsxs(j,{className:"glass-card overflow-hidden",children:[e.jsxs("div",{className:"relative h-32 overflow-hidden",children:[e.jsx("img",{src:((g=a.course)==null?void 0:g.thumbnail_url)||"https://images.unsplash.com/photo-1516321318423-f06f85e504b3?w=600&h=400&fit=crop",alt:(u=a.course)==null?void 0:u.title,className:"w-full h-full object-cover"}),e.jsxs(w,{className:"absolute top-3 right-3 bg-green-500 text-white",children:[e.jsx(_,{className:"h-3 w-3 mr-1"}),"Completed"]})]}),e.jsxs(b,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold line-clamp-1",children:(N=a.course)==null?void 0:N.title}),e.jsx(v,{variant:"outline",size:"sm",className:"mt-2 w-full",onClick:()=>{var k;return n(`/learn/${(k=a.course)==null?void 0:k.slug}`)},children:"Review Course"})]})]},a.id)})}):e.jsx(j,{className:"glass-card text-center py-12",children:e.jsxs(b,{children:[e.jsx(_,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No completed courses yet"}),e.jsx("p",{className:"text-muted-foreground",children:"Complete your first course to earn a certificate!"})]})})}),e.jsx(P,{value:"bookmarks",children:h&&h.length>0?e.jsx("div",{className:"grid sm:grid-cols-2 gap-4",children:h.map(a=>{var g,u,N,k,L,Z;return e.jsxs(j,{className:"glass-card-hover overflow-hidden group cursor-pointer",onClick:()=>{var Q;return n(`/course/${(Q=a.course)==null?void 0:Q.slug}`)},children:[e.jsxs("div",{className:"relative h-32 overflow-hidden",children:[e.jsx("img",{src:((g=a.course)==null?void 0:g.thumbnail_url)||"https://images.unsplash.com/photo-1516321318423-f06f85e504b3?w=600&h=400&fit=crop",alt:(u=a.course)==null?void 0:u.title,className:"w-full h-full object-cover transition-transform duration-500 group-hover:scale-110"}),e.jsx(X,{className:"absolute top-3 right-3 h-5 w-5 text-white fill-white"})]}),e.jsxs(b,{className:"p-4",children:[e.jsx("h3",{className:"font-semibold line-clamp-1 group-hover:text-primary transition-colors",children:(N=a.course)==null?void 0:N.title}),e.jsxs("div",{className:"flex items-center justify-between mt-2",children:[e.jsxs("span",{className:"text-lg font-bold gradient-text-brand",children:["$",((k=a.course)==null?void 0:k.discounted_price)||((L=a.course)==null?void 0:L.price)]}),e.jsx(w,{variant:"secondary",className:"capitalize",children:(Z=a.c
91ourse)==null?void 0:Z.level})]})]})]},a.id)})}):e.jsx(j,{className:"glass-card text-center py-12",children:e.jsxs(b,{children:[e.jsx(X,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No saved courses"}),e.jsx("p",{className:"text-muted-foreground",children:"Bookmark courses you want to take later!"})]})})}),e.jsx(P,{value:"certificates",children:x?e.jsx("div",{className:"text-center py-12",children:e.jsx(se,{className:"h-8 w-8 animate-spin mx-auto"})}):l&&l.length>0?e.jsx("div",{className:"grid sm:grid-cols-2 gap-4",children:l.map(a=>{var g,u;return e.jsx(ls,{certificateId:a.id,certificateNumber:a.certificate_number,courseName:((g=a.course)==null?void 0:g.title)||"Course",studentName:((u=r==null?void 0:r.user_metadata)==null?void 0:u.full_name)||(r==null?void 0:r.email)||"Student",certificateName:a.certificate_name,issuedAt:a.issued_at},a.id)})}):e.jsx(j,{className:"glass-card text-center py-12",children:e.jsxs(b,{children:[e.jsx($,{className:"h-12 w-12 mx-auto text-muted-foreground mb-4"}),e.jsx("h3",{className:"font-semibold mb-2",children:"No certificates yet"}),e.jsx("p",{className:"text-muted-foreground",children:"Complete a course to earn your certificate!"})]})})})]}),e.jsxs(j,{className:"glass-card",children:[e.jsx(G,{className:"pb-3",children:e.jsxs(I,{className:"flex items-center gap-2",children:[e.jsx(S,{className:"h-5 w-5 text-amber-500"}),"Achievements",e.jsxs(w,{variant:"secondary",className:"ml-2",children:[(c==null?void 0:c.length)||0," / ",(m==null?void 0:m.length)||0]})]})}),e.jsxs(b,{children:[e.jsx("div",{className:"flex flex-wrap gap-3",children:m==null?void 0:m.slice(0,12).map(a=>{const g=je.has(a.id),u=c==null?void 0:c.find(N=>N.achievement_id===a.id);return e.jsx(ns,{name:a.name,description:a.description,icon:a.icon,xpReward:a.xp_reward,earned:g,earnedAt:u==null?void 0:u.earned_at,size:"md"},a.id)})}),m&&m.length>12&&e.jsxs(v,{variant:"link",className:"mt-4 w-full",children:["View all ",m.length," achievements"]})]})]})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(xs,{}),e.jsx(ms,{limit:5})]})]})})})]})}export{Es 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.