1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/uploadMedia-BPkFDiJH.js","assets/api-CyvozDRd.js"])))=>i.map(i=>d[i]); 2import{h as Oe,B as x,a as ze,b as He,_ as $,p as Ue}from"./index-CVuSjWCq.js";import{a as i,j as e}from"./query-vendor-BB0JUlq_.js";import{C as Be}from"./ChatsPanel-fiT1dbtl.js";import{D as qe}from"./DiscussionFeed-DgfaxC1r.js";import{N as Ve}from"./NotificationBell-DrucT7Pa.js";import{C as We,a as Je,b as Ge,c as Ye}from"./card-COxgaMnN.js";import{L as j}from"./label-CuOi8NYy.js";import{R as le,a as D}from"./radio-group-X0hhJcQh.js";import{apiFetch as b}from"./api-CyvozDRd.js";import{d as Ke}from"./react-vendor-BIjsaQ6L.js";import"./ui-vendor-CwH6wFZJ.js";const ge=i.forwardRef(({className:l,...f},m)=>e.jsx("textarea",{className:Oe("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",l),ref:m,...f}));ge.displayName="Textarea";const fe=["Teacher illness or emergency","Student requested cancellation","Schedule conflict","Facility unavailable","Weather-related cancellation","Holiday observance","Professional development/training","Family emergency"];function Ze({lesson:l,onCancel:f,onConfirm:m}){const[O,z]=i.useState("single"),[w,u]=i.useState("prewritten"),[L,E]=i.useState(fe[0]),[C,H]=i.useState(""),[k,p]=i.useState(!1),v=!!l.recurrence_freq,R=new Date(l.start_date).toLocaleDateString(),A=l.start_time,a=async()=>{p(!0);const o=w==="prewritten"?L:C;try{await m(O,o)}finally{p(!1)}};return e.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4",children:e.jsxs(We,{className:"w-full max-w-2xl max-h-[90vh] overflow-y-auto",children:[e.jsx(Je,{children:e.jsx(Ge,{children:"Cancel Lesson"})}),e.jsxs(Ye,{className:"space-y-6",children:[e.jsxs("div",{className:"bg-muted p-4 rounded-lg space-y-1",children:[e.jsx("p",{className:"font-medium",children:l.instrument}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[R," at ",A," ⢠",l.lesson_type]}),v&&e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Recurring: ",l.recurrence_freq]})]}),v&&e.jsxs("div",{className:"space-y-3",children:[e.jsx(j,{className:"text-base font-semibold",children:"Cancellation Scope"}),e.jsxs(le,{value:O,onValueChange:o=>z(o),children:[e.jsxs("div",{className:"flex items-start space-x-3 p-3 border rounded-lg hover:bg-muted/50 cursor-pointer",children:[e.jsx(D,{value:"single",id:"scope-single",className:"mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(j,{htmlFor:"scope-single",className:"font-medium cursor-pointer",children:"This lesson only"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Cancel just the ",R," lesson"]})]})]}),e.jsxs("div",{className:"flex items-start space-x-3 p-3 border rounded-lg hover:bg-muted/50 cursor-pointer",children:[e.jsx(D,{value:"future",id:"scope-future",className:"mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(j,{htmlFor:"scope-future",className:"font-medium cursor-pointer",children:"This and future lessons"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["Cancel ",R," and all following lessons in the series"]})]})]}),e.jsxs("div",{className:"flex items-start space-x-3 p-3 border rounded-lg hover:bg-muted/50 cursor-pointer",children:[e.jsx(D,{value:"all",id:"scope-all",className:"mt-1"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(j,{htmlFor:"scope-all",className:"font-medium cursor-pointer",children:"Entire series"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Cancel all lessons in this recurring series"})]})]})]})]}),e.jsxs("div",{className:"space-y-3",children:[e.jsx(j,{className:"text-base font-semibold",children:"Cancellation Reason"}),e.jsxs(le,{value:w,onValueChange:o=>u(o),children:[e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(D,{value:"prewritten",id:"reason-prewritten"}),e.jsx(j,{htmlFor:"reason-prewritten",className:"cursor-pointer",children:"Select from common reasons"})]}),e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx(D,{value:"custom",id:"reason-custom"}),e.jsx(j,{htmlFor:"reason-custom",className:"cursor-pointer",children:"Write custom reason"})]})]})]}),w==="prewritten"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{children:"Select Reason"}),e.jsx(le,{value:L,onValueChange:E,children:fe.map(o=>e.jsxs("div",{className:"flex items-center space-x-3 p-2",children:[e.jsx(D,{value:o,id:`reason-${o}`}),e.jsx(j,{htmlFor:`reason-${o}`,className:"cursor-pointer font-normal",children:o})]},o))})]}),w==="custom"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx(j,{htmlFor:"custom-reason",children:"Custom Reason"}),e.jsx(ge,{id:"custom-reason",value:C,onChange:o=>H(o.target.value),placeholder:"Enter your reason for cancelling this lesson...",rows:4,className:"resize-none"}),!C.trim()&&e.jsx("p",{className:"text-sm text-destructive",children:"Please provide a reason"})]}),e.jsxs("div",{className:"bg-destructive/10 border border-destructive/20 p-4 rounded-lg",children:[e.jsx("p",{className:"text-sm text-destructive font-medium",children:"â ï¸ This action cannot be undone"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Students will be notified via email about this cancellation."})]}),e.jsxs("div",{className:"flex gap-3 justify-end",children:[e.jsx(x,{variant:"outline",onClick:f,disabled:k,children:"Keep Lesson"}),e.jsx(x,{variant:"destructive",onClick:a,disabled:k||w==="custom"&&!C.trim(),children:k?"Cancelling...":"Cancel Lesson"})]})]})]})})}function cs(){const[l,f]=i.useState("students"),[m,O]=i.useState([]),[z,w]=i.useState([]),[u,L]=i.useState(null),[E,C]=i.useState(!0),[H,k]=i.useState(!1),[p,v]=i.useState({name:"",phone:"",bio:"",specialties:""}),[R,A]=i.useState(!1),[a,o]=i.useState({studentIds:[],instrument:"",lessonType:"solo",durationMinutes:30,startDate:"",startTime:"",timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,recurrenceFreq:"",recurrenceInterval:1,recurrenceByDay:[],recurrenceUntil:"",notes:""}),[Y,oe]=i.useState(""),[N,ce]=i.useState({}),[de,K]=i.useState(!1),[h,S]=i.useState({calendarEmbedLink:"",workingHours:{}}),[Z,je]=i.useState(""),Q=m.filter(s=>
2{if(!Z.trim())return!0;const t=Z.toLowerCase();return s.name&&s.name.toLowerCase().includes(t)||s.email&&s.email.toLowerCase().includes(t)||(Array.isArray(s.instruments)?s.instruments.some(r=>r&&r.toLowerCase().includes(t)):String(s.instruments||"").toLowerCase().includes(t))||s.band&&s.band.toLowerCase().includes(t)}),[be,U]=i.useState(!1),[I,ve]=i.useState(""),[X,B]=i.useState(""),[g,P]=i.useState([]),[_,ue]=i.useState(!1),q=i.useRef(null),[ye,ee]=i.useState(!1),[me,Ne]=i.useState(""),[xe,M]=i.useState([]),[we,he]=i.useState(!1),[pe,V]=i.useState(!1),[W,se]=i.useState(null),te=Ke(),{user:re}=ze(),{toast:c}=He();i.useEffect(()=>{localStorage.getItem("inTuneTeacher")?(ke(),Se(),ae(),Ce()):te("/login")},[te]);const Ce=async()=>{try{const{apiFetch:s}=await $(async()=>{const{apiFetch:r}=await import("./api-CyvozDRd.js");return{apiFetch:r}},[]),t=await s("/api/teacher/schedule/settings");t&&(oe(t.calendarEmbedLink||""),ce(t.workingHours||{}),S({calendarEmbedLink:t.calendarEmbedLink||"",workingHours:t.workingHours||{}}))}catch(s){console.error("Error loading schedule:",s)}},ke=async()=>{try{const{apiFetch:s}=await $(async()=>{const{apiFetch:r}=await import("./api-CyvozDRd.js");return{apiFetch:r}},[]),t=await s("/api/teacher/profile/me");t&&(L(t),v({name:t.name||"",phone:t.phone||"",bio:t.bio||"",specialties:t.specialties||""}))}catch(s){console.error("Error loading profile:",s)}},Se=async()=>{try{C(!0);const{apiFetch:s}=await $(async()=>{const{apiFetch:r}=await import("./api-CyvozDRd.js");return{apiFetch:r}},[]),t=await s("/api/teacher/my-students");Array.isArray(t)?O(t):(console.error("Invalid students data:",t),c({title:"Error",description:t?.error||"Invalid response format",variant:"destructive"}))}catch(s){console.error("Error loading students:",s),c({title:"Error",description:"Failed to load students",variant:"destructive"})}finally{C(!1)}},ae=async()=>{try{const{apiFetch:s}=await $(async()=>{const{apiFetch:r}=await import("./api-CyvozDRd.js");return{apiFetch:r}},[]),t=await s("/api/teacher/my-lessons?limit=20");Array.isArray(t)?w(t):(console.error("Invalid lessons data:",t),c({title:"Error",description:t?.error||"Invalid response format",variant:"destructive"}))}catch(s){console.error("Error loading lessons:",s),c({title:"Error",description:"Failed to load lessons",variant:"destructive"})}},_e=async(s,t)=>{if(W)try{await b(`/api/teacher/lessons/${W.id}`,{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({deleteScope:s,reason:t})}),c({title:"Lesson Cancelled",description:"Lesson has been cancelled. Students have been notified via email."}),await ae(),se(null)}catch(r){console.error("Error cancelling lesson:",r),c({title:"Error",description:"Failed to cancel lesson",variant:"destructive"})}},Fe=s=>{if(!s.recurrence_freq)return"One-time";const t=s.recurrence_freq.toLowerCase(),r=s.recurrence_interval||1;let n=r===1?t:`Every ${r} ${t}s`;return s.recurrence_byday&&s.recurrence_byday.length>0&&(n+=` on ${s.recurrence_byday.join(", ")}`),s.recurrence_until&&(n+=` until ${new Date(s.recurrence_until).toLocaleDateString()}`),n.charAt(0).toUpperCase()+n.slice(1)},Le=async s=>{s.preventDefault();try{const t=await b("/api/teacher/profile/me",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(p)});L(t.teacher),k(!1),c({title:"Success",description:"Profile updated successfully"})}catch(t){console.error("Error updating profile:",t),c({title:"Error",description:"Failed to update profile",variant:"destructive"})}},Te=async s=>{const t=s.target.files?.[0];if(!t)return;const r=new FileReader;r.onload=async n=>{const y=(n.target?.result).split(",")[1];try{const F=await b("/api/teacher/profile/upload-picture",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({data:y})});L(T=>T?{...T,profile_picture_url:F.url}:null),c({title:"Success",description:"Profile picture updated"})}catch(F){console.error("Error uploading picture:",F),c({title:"Error",description:"Failed to upload picture",variant:"destructive"})}},r.readAsDataURL(t)},J=s=>`${s.name}-${s.size}-${s.lastModified}`,G=i.useCallback(s=>{const t=[];for(let r=0;r<s.length;r++){const n=s[r],d=n.size,y=100*1024*1024;d>y?c({title:"File too large",description:`${n.name} exceeds 100MB limit`,variant:"destructive"}):t.push(n)}t.length>0&&P(r=>{const n=new Map;return r.forEach(d=>n.set(J(d),d)),t.forEach(d=>n.set(J(d),d)),Array.from(n.values())})},[c]),De=i.useCallback(s=>{s.preventDefault(),s.dataTransfer?.files?.length&&G(s.dataTransfer.files)},[G]),Ee=i.useCallback(s=>{s.target.files?.length&&G(s.target.files),q.current&&(q.current.value="")},[G]),Re=i.useCallback(s=>{P(t=>t.filter(r=>J(r)!==s))},[]),Ae=i.useCallback(async()=>
2{if(!I){c({title:"Select a student",description:"Choose who should receive the resources.",variant:"destructive"});return}if(g.length===0){c({title:"Add files",description:"Drag and drop or select files to share.",variant:"destructive"});return}const s=g.filter(t=>{const r=t.type.startsWith("image/")?4194304:104857600;return t.size>r});if(s.length>0){c({title:"Files too large",description:`${s.length} file(s) too large: ${s.map(t=>`${t.name} (${Math.round(t.size/1024/1024)}MB)`).join(", ")}. Images: max 4MB, Videos/Audio: max 100MB.`,variant:"destructive"});return}try{ue(!0);const{uploadMedia:t}=await $(async()=>{const{uploadMedia:n}=await import("./uploadMedia-BPkFDiJH.js");return{uploadMedia:n}},__vite__mapDeps([0,1])),r=[];for(const n of g){const d=await t(n);r.push(d)}await b(`/api/admin/learning/${I}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:X.trim()||"Learning resources",description:"",media:r})}),c({title:"Resources uploaded",description:`${g.length} file${g.length>1?"s":""} shared with ${m.find(n=>n.student_id===I)?.name||"the student"}.`}),P([]),B(""),U(!1)}catch(t){c({title:"Upload failed",description:t?.message||"Unable to upload resources.",variant:"destructive"})}finally{ue(!1)}},[g,I,X,m,c]),Ie=async()=>{try{const s=await b("/api/teacher/schedule/settings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify(h)});oe(s.calendarEmbedLink||""),ce(s.workingHours||{}),K(!1),c({title:"Schedule updated",description:"Your schedule settings have been saved."})}catch(s){console.error("Error saving schedule:",s),c({title:"Error",description:"Failed to update schedule settings",variant:"destructive"})}};i.useEffect(()=>{if(a.studentIds.length===0)return;const s=m.filter(n=>a.studentIds.includes(n.student_id));if(s.length===0)return;if(s[0].instruments){const n=Array.isArray(s[0].instruments)?s[0].instruments:String(s[0].instruments).split(",").map(d=>d.trim());n.length>0&&!a.instrument&&o(d=>({...d,instrument:n[0]}))}const t=s.length===1?"solo":"band";a.lessonType!==t&&o(n=>({...n,lessonType:t}));const r=s.length===1?30:60;if((!a.durationMinutes||a.durationMinutes===30)&&o(n=>({...n,durationMinutes:r})),!a.startDate&&Object.keys(N).length>0){const n=new Date,d=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];for(let y=1;y<=7;y++){const F=new Date(n);F.setDate(n.getDate()+y);const T=d[F.getDay()];if(N[T]&&N[T].length>0){const $e=F.toISOString().split("T")[0];o(ie=>({...ie,startDate:$e}));const ne=N[T][0];ne&&ne.start&&!a.startTime&&o(ie=>({...ie,startTime:ne.start}));break}}}},[a.studentIds,m,N]);const Pe=async s=>{if(s.preventDefault(),a.studentIds.length===0){c({title:"Error",description:"Please select at least one student",variant:"destructive"});return}try{await b("/api/teacher/lessons",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({teacherId:re?.id,studentIds:a.studentIds.map(t=>String(t)),instrument:a.instrument,lessonType:a.lessonType,durationMinutes:a.durationMinutes,startDate:a.startDate,startTime:a.startTime,timezone:a.timezone,recurrenceFreq:a.recurrenceFreq||null,recurrenceInterval:a.recurrenceInterval,recurrenceByDay:a.recurrenceByDay.length>0?a.recurrenceByDay:null,recurrenceUntil:a.recurrenceUntil||null,notes:a.notes})}),c({title:"Success",description:"Lesson created successfully"}),A(!1),o({studentIds:[],instrument:"",lessonType:"solo",durationMinutes:30,startDate:"",startTime:"",timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,recurrenceFreq:"",recurrenceInterval:1,recurrenceByDay:[],recurrenceUntil:"",notes:""}),ae()}catch(t){console.error("Error creating lesson:",t),c({title:"Error",description:"Failed to create lesson",variant:"destructive"})}},Me=async()=>{await Ue(),te("/")};return e.jsxs("div",{className:"container mx-auto py-12",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold",children:"Teacher Dashboard"}),e.jsxs("p",{className:"text-sm text-foreground/70 mt-1",children:["Welcome, ",re?.name||re?.username]})]}),e.jsxs("div",{className:"flex gap-2 flex-wrap",children:[e.jsx(Ve,{}),e.jsx("button",{onClick:Me,className:"px-3 py-2 rounded-md border",children:"Logout"})]})]}),e.jsxs("div",{className:"mt-6",children:[e.jsxs("div",{role:"tablist","aria-label":"Teacher sections",className:"flex gap-2 flex-wrap",children:[e.jsx("button",{onClick:()=>f("students"),role:"tab","aria-selected":l==="students",className:`px-4 py-2 rounded-md transition-colors ${l==="students"?"bg-card shadow text-foreground":"bg-muted text-foreground
2/70 hover:text-foreground"}`,children:"ð¥ My Students"}),e.jsx("button",{onClick:()=>f("lessons"),role:"tab","aria-selected":l==="lessons",className:`px-4 py-2 rounded-md transition-colors ${l==="lessons"?"bg-card shadow text-foreground":"bg-muted text-foreground/70 hover:text-foreground"}`,children:"ð My Lessons"}),e.jsx("button",{onClick:()=>f("schedule"),role:"tab","aria-selected":l==="schedule",className:`px-4 py-2 rounded-md transition-colors ${l==="schedule"?"bg-card shadow text-foreground":"bg-muted text-foreground/70 hover:text-foreground"}`,children:"ð
Schedule"}),e.jsx("button",{onClick:()=>f("profile"),role:"tab","aria-selected":l==="profile",className:`px-4 py-2 rounded-md transition-colors ${l==="profile"?"bg-card shadow text-foreground":"bg-muted text-foreground/70 hover:text-foreground"}`,children:"ð¤ My Profile"}),e.jsx("button",{onClick:()=>f("resources"),role:"tab","aria-selected":l==="resources",className:`px-4 py-2 rounded-md transition-colors ${l==="resources"?"bg-card shadow text-foreground":"bg-muted text-foreground/70 hover:text-foreground"}`,children:"ð Resources"}),e.jsx("button",{onClick:()=>f("chats"),role:"tab","aria-selected":l==="chats",className:`px-4 py-2 rounded-md transition-colors ${l==="chats"?"bg-card shadow text-foreground":"bg-muted text-foreground/70 hover:text-foreground"}`,children:"ð¬ Chats"}),e.jsx("button",{onClick:()=>f("discussion"),role:"tab","aria-selected":l==="discussion",className:`px-4 py-2 rounded-md transition-colors ${l==="discussion"?"bg-card shadow text-foreground":"bg-muted text-foreground/70 hover:text-foreground"}`,children:"ð Discussion"})]}),e.jsxs("div",{className:"mt-6",children:[l==="students"&&e.jsxs("div",{className:"rounded-lg border p-6 bg-card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"My Students"}),m.length>0&&e.jsxs("div",{className:"text-sm text-foreground/60",children:[Q.length," of ",m.length," student",m.length!==1?"s":""]})]}),!E&&m.length>0&&e.jsx("div",{className:"mb-4",children:e.jsx("input",{type:"text",placeholder:"Search by name, email, instrument, or band...",className:"w-full px-4 py-2 border rounded-md focus:outline-none focus:ring-2 focus:ring-primary",value:Z,onChange:s=>je(s.target.value)})}),E?e.jsx("div",{className:"text-center py-8 text-foreground/60",children:"Loading students..."}):m.length===0?e.jsx("div",{className:"text-center py-8 text-foreground/60",children:"No students assigned yet"}):Q.length===0?e.jsx("div",{className:"text-center py-8 text-foreground/60",children:"No students match your search"}):e.jsx("div",{className:"grid gap-4",children:Q.map(s=>e.jsx("div",{className:"border rounded-lg p-4 hover:bg-accent/5 transition-colors",children:e.jsx("div",{className:"flex items-start justify-between",children:e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:s.name}),s.is_primary&&e.jsx("span",{className:"px-2 py-1 text-xs bg-primary/10 text-primary rounded-full",children:"Primary Teacher"})]}),e.jsxs("div",{className:"mt-2 grid grid-cols-2 gap-x-6 gap-y-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-foreground/60",children:"Email:"})," ",e.jsx("a",{href:`mailto:${s.email}`,className:"text-primary hover:underline",children:s.email})]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-foreground/60",children:"Age:"})," ",s.age]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-foreground/60",children:"Instruments:"})," ",Array.isArray(s.instruments)?s.instruments.join(", "):s.instruments||"N/A"]}),s.band&&e.jsxs("div",{children:[e.jsx("span",{className:"text-foreground/60",children:"Band:"})," ",s.band]}),e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-foreground/60",children:"Assigned:"})," ",new Date(s.assigned_at).toLocaleDateString()]})]}),(s.emergency_contact_name||s.emergency_contact_phone)&&e.jsxs("div",{className:"mt-3 p-3 bg-amber-50 dark:bg-amber-950/20 rounded-md border border-amber-200 dark:border-amber-800",children:[e.jsx("div",{className:"text-sm font-medium text-amber-900 dark:text-amber-100 mb-1",children:"ð¨ Emergency Contact"}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-sm",children:[s.emergency_contact_name&&e.jsxs("div",{children:[e.jsx("span",{className:"text-foreground
2/60",children:"Name:"})," ",e.jsx("span",{className:"font-medium",children:s.emergency_contact_name})]}),s.emergency_contact_phone&&e.jsxs("div",{children:[e.jsx("span",{className:"text-foreground/60",children:"Phone:"})," ",e.jsx("a",{href:`tel:${s.emergency_contact_phone}`,className:"text-primary hover:underline font-medium",children:s.emergency_contact_phone})]}),s.emergency_contact_relationship&&e.jsxs("div",{className:"col-span-2",children:[e.jsx("span",{className:"text-foreground/60",children:"Relationship:"})," ",e.jsx("span",{className:"font-medium",children:s.emergency_contact_relationship})]})]})]}),s.notes&&e.jsxs("div",{className:"mt-3 text-sm",children:[e.jsx("span",{className:"text-foreground/60",children:"Notes:"})," ",e.jsx("p",{className:"mt-1 text-foreground/80",children:s.notes})]})]})})},s.student_id))})]}),l==="lessons"&&e.jsxs("div",{className:"rounded-lg border p-6 bg-card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"Upcoming Lessons"}),e.jsx(x,{onClick:()=>A(!0),className:"bg-primary text-primary-foreground",children:"+ Create Lesson"})]}),R&&e.jsxs("div",{className:"mb-6 p-4 border rounded-lg bg-accent/5",children:[e.jsx("h3",{className:"font-semibold mb-4",children:"Create New Lesson"}),e.jsxs("form",{onSubmit:Pe,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Students *"}),e.jsx("select",{multiple:!0,className:"w-full px-3 py-2 border rounded-md min-h-[120px]",value:a.studentIds,onChange:s=>{const t=Array.from(s.target.selectedOptions,r=>r.value);o({...a,studentIds:t})},required:!0,children:m.map(s=>{const t=Array.isArray(s.instruments)?s.instruments.join(", "):s.instruments||"No instrument";return e.jsxs("option",{value:s.student_id,children:[s.name," (",t,")"]},s.student_id)})}),e.jsx("p",{className:"text-xs text-foreground/60 mt-1",children:"Hold Ctrl/Cmd to select multiple ⢠Instrument auto-fills from selection"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Instrument *"}),e.jsx("input",{type:"text",className:"w-full px-3 py-2 border rounded-md",value:a.instrument,onChange:s=>o({...a,instrument:s.target.value}),placeholder:"e.g., Piano, Guitar",required:!0}),e.jsx("p",{className:"text-xs text-foreground/60 mt-1",children:a.studentIds.length>0?"â Auto-filled from student profile":"Select student first"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Lesson Type"}),e.jsxs("select",{className:"w-full px-3 py-2 border rounded-md",value:a.lessonType,onChange:s=>o({...a,lessonType:s.target.value}),children:[e.jsx("option",{value:"solo",children:"Solo (30 min)"}),e.jsx("option",{value:"extended",children:"Extended (60 min)"}),e.jsx("option",{value:"band",children:"Band/Group"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Duration (minutes)"}),e.jsxs("select",{className:"w-full px-3 py-2 border rounded-md",value:a.durationMinutes,onChange:s=>o({...a,durationMinutes:parseInt(s.target.value)}),children:[e.jsx("option",{value:30,children:"30 minutes"}),e.jsx("option",{value:45,children:"45 minutes"}),e.jsx("option",{value:60,children:"60 minutes"}),e.jsx("option",{value:90,children:"90 minutes"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Start Date *"}),e.jsx("input",{type:"date",className:"w-full px-3 py-2 border rounded-md",value:a.startDate,onChange:s=>o({...a,startDate:s.target.value}),required:!0}),e.jsx("p",{className:"text-xs text-foreground/60 mt-1",children:a.startDate?"â Next available working day":"Based on your schedule"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Start Time *"}),e.jsx("input",{type:"time",className:"w-full px-3 py-2 border rounded-md",value:a.startTime,onChange:s=>o({...a,startTime:s.target.value}),required:!0}
2),e.jsx("p",{className:"text-xs text-foreground/60 mt-1",children:a.startTime?"â From your working hours":"First available slot"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Recurrence"}),e.jsxs("select",{className:"w-full px-3 py-2 border rounded-md",value:a.recurrenceFreq,onChange:s=>o({...a,recurrenceFreq:s.target.value}),children:[e.jsx("option",{value:"",children:"One-time lesson"}),e.jsx("option",{value:"WEEKLY",children:"Weekly"}),e.jsx("option",{value:"DAILY",children:"Daily"}),e.jsx("option",{value:"MONTHLY",children:"Monthly"})]})]}),a.recurrenceFreq&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Repeat Until"}),e.jsx("input",{type:"date",className:"w-full px-3 py-2 border rounded-md",value:a.recurrenceUntil,onChange:s=>o({...a,recurrenceUntil:s.target.value})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Notes"}),e.jsx("textarea",{className:"w-full px-3 py-2 border rounded-md",rows:3,value:a.notes,onChange:s=>o({...a,notes:s.target.value}),placeholder:"Any additional notes..."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(x,{type:"submit",className:"bg-primary text-primary-foreground",children:"Create Lesson"}),e.jsx(x,{type:"button",onClick:()=>A(!1),className:"bg-muted text-foreground",children:"Cancel"})]})]})]}),E?e.jsx("div",{className:"text-center py-8 text-foreground/60",children:"Loading lessons..."}):z.length===0?e.jsx("div",{className:"text-center py-8 text-foreground/60",children:"No upcoming lessons scheduled"}):e.jsx("div",{className:"grid gap-4",children:z.map(s=>e.jsx("div",{className:"border rounded-lg p-4 hover:bg-accent/5 transition-colors",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-2",children:[e.jsx("h3",{className:"font-semibold text-lg",children:s.instrument}),e.jsx("span",{className:`px-2 py-1 text-xs rounded-full ${s.lesson_type==="individual"?"bg-blue-100 text-blue-800":"bg-purple-100 text-purple-800"}`,children:s.lesson_type}),e.jsx("span",{className:`px-2 py-1 text-xs rounded-full ${s.status==="scheduled"?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}`,children:s.status})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-x-6 gap-y-2 text-sm",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-foreground/60",children:"Date:"})," ",new Date(s.start_date).toLocaleDateString()]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-foreground/60",children:"Time:"})," ",s.start_time]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-foreground/60",children:"Duration:"})," ",s.duration_minutes," min"]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-foreground/60",children:"Recurrence:"})," ",Fe(s)]})]}),s.students&&s.students.length>0&&e.jsxs("div",{className:"mt-3",children:[e.jsx("span",{className:"text-sm text-foreground/60",children:"Students:"}),e.jsx("div",{className:"mt-1 flex flex-wrap gap-2",children:s.students.map(t=>e.jsx("span",{className:"px-2 py-1 text-xs bg-accent rounded-full",children:t.name},t.id))})]}),s.notes&&e.jsxs("div",{className:"mt-3 text-sm",children:[e.jsx("span",{className:"text-foreground/60",children:"Notes:"})," ",e.jsx("p",{className:"mt-1 text-foreground/80",children:s.notes})]})]}),e.jsx("div",{className:"ml-4",children:e.jsx(x,{variant:"destructive",size:"sm",onClick:()=>se(s),disabled:s.status==="cancelled",children:"Cancel Lesson"})})]})},s.id))})]}),l==="schedule"&&e.jsxs("div",{className:"rounded-lg border p-6 bg-card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"ð
My Schedule"}),!de&&e.jsx(x,{onClick:()=>K(!0),className:"bg-primary text-primary-foreground",children:"Edit Schedule"})]}),de?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Calendar Embed Link"}),e.jsx("input",{type:"url",className:"w-full px-3 py-2 border rounded-md",placeholder:"e.g., https://calendar.google.com/calendar/embed?src=...",value:h.calendarEmbedLink,onChange:s=>S({...h,calendarEmbedLink:s.target.value})}
2),e.jsx("p",{className:"text-xs text-foreground/60 mt-1",children:"Paste your Google Calendar embed URL or any calendar iframe source"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Working Hours"}),e.jsx("p",{className:"text-xs text-foreground/60 mb-3",children:"Set your availability for each day of the week"}),e.jsx("div",{className:"space-y-3",children:["monday","tuesday","wednesday","thursday","friday","saturday","sunday"].map(s=>e.jsxs("div",{className:"border rounded-md p-3",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("label",{className:"font-medium capitalize",children:s}),e.jsx(x,{variant:"outline",size:"sm",onClick:()=>{const t=h.workingHours[s]||[];S({...h,workingHours:{...h.workingHours,[s]:[...t,{start:"09:00",end:"17:00"}]}})},children:"+ Add Time Slot"})]}),(h.workingHours[s]||[]).map((t,r)=>e.jsxs("div",{className:"flex items-center gap-2 mt-2",children:[e.jsx("input",{type:"time",className:"px-2 py-1 border rounded text-sm",value:t.start,onChange:n=>{const d=[...h.workingHours[s]||[]];d[r].start=n.target.value,S({...h,workingHours:{...h.workingHours,[s]:d}})}}),e.jsx("span",{className:"text-sm",children:"to"}),e.jsx("input",{type:"time",className:"px-2 py-1 border rounded text-sm",value:t.end,onChange:n=>{const d=[...h.workingHours[s]||[]];d[r].end=n.target.value,S({...h,workingHours:{...h.workingHours,[s]:d}})}}),e.jsx(x,{variant:"ghost",size:"sm",onClick:()=>{const n=(h.workingHours[s]||[]).filter((d,y)=>y!==r);S({...h,workingHours:{...h.workingHours,[s]:n}})},children:"Remove"})]},r))]},s))})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(x,{onClick:Ie,className:"bg-primary text-primary-foreground",children:"Save Changes"}),e.jsx(x,{variant:"outline",onClick:()=>{K(!1),S({calendarEmbedLink:Y,workingHours:N})},children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-6",children:[Y?e.jsx("div",{className:"border rounded-md overflow-hidden",children:e.jsx("iframe",{src:Y,className:"w-full h-[600px] border-0",title:"Teacher Calendar"})}):e.jsxs("div",{className:"border border-dashed rounded-md p-8 text-center text-foreground/60",children:[e.jsx("p",{className:"mb-2",children:"No calendar configured"}),e.jsx("p",{className:"text-sm",children:'Click "Edit Schedule" to add your calendar embed link'})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold mb-3",children:"Working Hours"}),Object.keys(N).length===0?e.jsx("p",{className:"text-foreground/60 text-sm",children:'No working hours set. Click "Edit Schedule" to configure your availability.'}):e.jsx("div",{className:"grid gap-2",children:["monday","tuesday","wednesday","thursday","friday","saturday","sunday"].map(s=>{const t=N[s]||[];return e.jsxs("div",{className:"flex items-center gap-3 border-b pb-2",children:[e.jsx("span",{className:"w-24 font-medium capitalize",children:s}),e.jsx("span",{className:"text-foreground/70",children:t.length===0?"Unavailable":t.map((r,n)=>e.jsxs("span",{children:[r.start," - ",r.end,n<t.length-1&&", "]},n))})]},s)})})]})]})]}),l==="profile"&&e.jsxs("div",{className:"rounded-lg border p-6 bg-card",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"My Profile"}),!H&&e.jsx("button",{onClick:()=>k(!0),className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90",children:"Edit Profile"})]}),u&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"relative",children:[u.profile_picture_url?e.jsx("img",{src:u.profile_picture_url,alt:u.name,className:"w-32 h-32 rounded-full object-cover border-4 border-primary/10"}):e.jsx("div",{className:"w-32 h-32 rounded-full bg-gradient-to-br from-primary/20 to-primary/5 flex items-center justify-center text-4xl font-bold text-primary",children:u.name?.charAt(0)||"T"}),e.jsxs("label",{className:"absolute bottom-0 right-0 p-2 bg-primary text-primary-foreground rounded-full cursor-pointer hover:bg-primary/90 shadow-lg",children:[e.jsx("input",{type:"file",accept:"image/*",className:"hidden",onChange:Te}),e.jsxs("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:[e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M3 9a2 2 0 012-2h.93a2 2 0 001.664-.89l.812-1.22A2 2 0 0110.07 4h3.86a2 2 0 011.
2664.89l.812 1.22A2 2 0 0018.07 7H19a2 2 0 012 2v9a2 2 0 01-2 2H5a2 2 0 01-2-2V9z"}),e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 13a3 3 0 11-6 0 3 3 0 016 0z"})]})]})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-2xl font-bold",children:u.name}),e.jsx("p",{className:"text-foreground/60",children:u.email}),u.phone&&e.jsx("p",{className:"text-foreground/60",children:u.phone})]})]}),H?e.jsxs("form",{onSubmit:Le,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Name"}),e.jsx("input",{type:"text",value:p.name,onChange:s=>v({...p,name:s.target.value}),className:"w-full h-10 rounded-md border px-3"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Phone"}),e.jsx("input",{type:"tel",value:p.phone,onChange:s=>v({...p,phone:s.target.value}),className:"w-full h-10 rounded-md border px-3"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Bio"}),e.jsx("textarea",{value:p.bio,onChange:s=>v({...p,bio:s.target.value}),className:"w-full rounded-md border px-3 py-2 min-h-[100px]",placeholder:"Tell us about yourself and your teaching experience..."})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-2",children:"Specialties"}),e.jsx("input",{type:"text",value:p.specialties,onChange:s=>v({...p,specialties:s.target.value}),className:"w-full h-10 rounded-md border px-3",placeholder:"e.g., Jazz, Classical, Rock"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{type:"submit",className:"px-4 py-2 bg-primary text-primary-foreground rounded-md hover:bg-primary/90",children:"Save Changes"}),e.jsx("button",{type:"button",onClick:()=>{k(!1),v({name:u.name||"",phone:u.phone||"",bio:u.bio||"",specialties:u.specialties||""})},className:"px-4 py-2 border rounded-md hover:bg-accent",children:"Cancel"})]})]}):e.jsxs("div",{className:"space-y-4",children:[u.bio&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground/70 mb-1",children:"Bio"}),e.jsx("p",{className:"text-foreground/80",children:u.bio})]}),u.specialties&&e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold text-sm text-foreground/70 mb-1",children:"Specialties"}),e.jsx("p",{className:"text-foreground/80",children:u.specialties})]}),!u.bio&&!u.specialties&&e.jsx("p",{className:"text-center py-8 text-foreground/60",children:'Click "Edit Profile" to add your bio and specialties'})]})]})]}),l==="resources"&&e.jsxs("div",{className:"rounded-lg border p-6 bg-card",children:[e.jsx("h2",{className:"text-xl font-semibold mb-4",children:"Upload Resources for Students"}),e.jsx("p",{className:"text-foreground/70 mb-6",children:"Select a student to upload learning resources, practice materials, or sheet music."}),m.length===0?e.jsx("div",{className:"text-center py-8 text-foreground/60",children:"No students assigned yet. You'll be able to upload resources once students are assigned to you."}):e.jsx("div",{className:"space-y-3",children:m.map(s=>e.jsx("div",{className:"p-4 border rounded-md hover:bg-accent/5 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex-1",children:[e.jsx("h3",{className:"font-semibold",children:s.name}),e.jsx("p",{className:"text-sm text-foreground/60",children:Array.isArray(s.instruments)?s.instruments.join(", "):s.instruments||"No instruments"})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(x,{variant:"outline",size:"sm",onClick:async()=>{Ne(s.student_id),ee(!0),he(!0);try{const t=await b(`/api/admin/learning/${s.student_id}`);M(Array.isArray(t)?t:t&&t.rows||[])}catch(t){console.error("Failed to load resources:",t),c({title:"Error",description:"Failed to load resources",variant:"destructive"})}finally{he(!1)}},children:"View Resources"}),e.jsx(x,{size:"sm",onClick:()=>{ve(s.student_id),U(!0)},children:"Upload"})]})]})},s.student_id))}),be&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onMouseDown:s=>{s.target===s.currentTarget&&(U(!1),P([]),B(""))},children:e.jsxs("div",{className:"w-full max-w-2xl rounded-lg bg-card p-6 shadow-xl",onMouseDown:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"Upload Learning Resources"}
2),e.jsxs("p",{className:"text-sm text-foreground/70",children:["For ",m.find(s=>s.student_id===I)?.name]})]}),e.jsx(x,{variant:"ghost",onClick:()=>{U(!1),P([]),B("")},disabled:_,children:"Close"})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium mb-1",children:"Folder Name"}),e.jsx("input",{className:"h-10 w-full rounded-md border px-3",value:X,onChange:s=>B(s.target.value),placeholder:"e.g., Week 1 - Scales Practice",disabled:_})]}),e.jsxs("div",{children:[e.jsxs("div",{onDrop:De,onDragOver:s=>s.preventDefault(),className:"flex flex-col items-center justify-center gap-2 rounded-md border-2 border-dashed border-muted-foreground/40 bg-muted/20 p-6 text-center text-sm",children:[e.jsx("p",{className:"font-medium",children:"Drop files here"}),e.jsx("p",{className:"text-xs text-foreground/70",children:"PDF, ZIP, DOC, videos, sheet music, and more"}),e.jsx(x,{variant:"outline",size:"sm",onClick:()=>q.current?.click(),disabled:_,children:"Select Files"})]}),e.jsx("input",{ref:q,type:"file",multiple:!0,accept:"*/*",className:"hidden",onChange:Ee,disabled:_})]}),g.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsxs("p",{className:"text-sm font-medium",children:["Selected Files (",g.length,")"]}),e.jsx("div",{className:"max-h-40 overflow-y-auto space-y-1",children:g.map(s=>{const t=J(s);return e.jsxs("div",{className:"flex items-center justify-between p-2 bg-muted/50 rounded text-sm",children:[e.jsx("span",{className:"truncate flex-1",children:s.name}),e.jsx("button",{onClick:()=>Re(t),className:"ml-2 text-destructive hover:text-destructive/80",disabled:_,children:"Remove"})]},t)})})]}),e.jsx("div",{className:"flex gap-2 pt-4",children:e.jsx(x,{onClick:Ae,disabled:_||g.length===0,className:"flex-1",children:_?"Uploading...":"Upload Resources"})})]})]})}),ye&&e.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",onMouseDown:s=>{s.target===s.currentTarget&&(ee(!1),M([]))},children:e.jsxs("div",{className:"w-full max-w-4xl max-h-[90vh] overflow-y-auto rounded-lg bg-card p-6 shadow-xl",onMouseDown:s=>s.stopPropagation(),children:[e.jsxs("div",{className:"flex items-start justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-semibold",children:"View Resources"}),e.jsxs("p",{className:"text-sm text-foreground/70",children:["For ",m.find(s=>s.student_id===me)?.name]})]}),e.jsx(x,{variant:"ghost",onClick:()=>{ee(!1),M([])},children:"Close"})]}),we?e.jsx("div",{className:"text-center py-8 text-foreground/60",children:"Loading resources..."}):xe.length===0?e.jsx("div",{className:"text-center py-8 text-foreground/60",children:"No resources uploaded yet"}):e.jsx("div",{className:"space-y-4",children:xe.map(s=>e.jsxs("div",{className:"border rounded-lg p-4",children:[e.jsxs("div",{className:"flex items-start justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"font-semibold",children:s.title||"Untitled Folder"}),e.jsx("p",{className:"text-xs text-foreground/60",children:new Date(s.created_at).toLocaleDateString()})]}),e.jsx(x,{size:"sm",variant:"destructive",disabled:pe,onClick:async()=>{if(confirm("Delete this resource folder and all its files?"))try{V(!0),await b(`/api/admin/learning/entry/${s.id}`,{method:"DELETE"});const t=await b(`/api/admin/learning/${me}`);M(Array.isArray(t)?t:t&&t.rows||[]),c({title:"Resource deleted",description:"The folder and all its files have been removed."})}catch(t){console.error(t),c({title:"Failed to delete folder",variant:"destructive"})}finally{V(!1)}},children:"Delete folder"})]}),Array.isArray(s.media)&&s.media.length>0?e.jsx("div",{className:"mt-3 grid gap-2 md:grid-cols-2",children:s.media.map(t=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded border p-2",children:[e.jsx("div",{className:"flex items-center gap-3 flex-1 min-w-0",children:t.mime?.startsWith("image")?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",className:"flex-shrink-0",children:e.jsx("img",{src:t.url,alt:"Resource thumbnail",className:"h-16 w-24 object-cover rounded cursor-pointer hover:opacity-80 transition-opacity"})}),e.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",className:"text-sm text-primary hover:text-primary/80 underline truncate",children:t.url.split("/").pop()})]}):t.mime?.startsWith("video")?e.jsxs(e.Fragment,{children:[e.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",className:"flex-shrink-0",children:e.jsx("video",{src:t.url,className:"h-16 w-24 object-cover rounded cursor-pointer hover:opacity-80 transition-opacity"})}),e.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",className:"text-sm text-primary hover:text-primary/80 underline truncate",children:t.url.split("/").pop()})]}):e.jsx("a",{href:t.url,target:"_blank",rel:"noreferrer",className:"underline text-primary hover:text-primary/80",children:"Open file"})}),e.jsx("div",{className:"flex items-center gap-2 flex-shrink-0",children:e.jsx(x,{size:"sm",variant:"destructive",disabled:pe,onClick:async()=>
2{if(confirm("Remove this file from the resource folder?"))try{V(!0);const r=await b(`/api/admin/learning/entry/${s.id}/media/${t.id}`,{method:"DELETE"});M(Array.isArray(r)?r:r&&r.rows||[]),c({title:"File removed",description:"The file has been deleted from this folder."})}catch(r){console.error(r),c({title:"Failed to delete file",variant:"destructive"})}finally{V(!1)}},children:"Delete"})})]},t.id||t.url))}):e.jsx("div",{className:"text-sm text-muted-foreground",children:"No media files in this resource"})]},s.id))})]})})]}),l==="chats"&&e.jsx("div",{children:e.jsx(Be,{className:"rounded-lg border p-4 bg-card"})}),l==="discussion"&&e.jsx("div",{children:e.jsx(qe,{className:"rounded-lg border p-4 bg-card"})})]})]}),W&&e.jsx(Ze,{lesson:W,onCancel:()=>se(null),onConfirm:_e})]})}export{cs 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.