PageSourceSearch

https://analytics.whiteknight.academy/assets/CoachCurriculumDetailPage-BUlt9p39.js

js whiteknight.academy collected 2026-09-24 14:08:19 UTC 33,350 bytes, 1 lines download raw bytes

1var ye=Object.defineProperty;var s=(r,n)=>ye(r,"name",{value:n,configurable:!0});import{u as ce,f as A,j as e,D as me,G as F}from"./emailRef-2_pXTFTA.js";import{r as d,c as we,L as ee}from"./react-vendor-DAHDpbpd.js";import{I as q}from"./InfoTooltip-CrhdYMpo.js";import{c as $}from"./coachPortalService-DoeUO0X8.js";import{o as Ne,D as _e,a as te,q as ke}from"./main-app-BG8rSm62.js";import{T as Ce}from"./Tabs-OKsJbTQv.js";import{I as M,S as se,T as V}from"./forms-QCnacu7Q.js";import{U as W,d as ae,X as B,a as ne,g as ze,b as Se}from"./campaign-icons-DGRZg7ro.js";import{a3 as Le,C as ue,bg as Te,v as Ae,av as xe,b as K,Q as R,a2 as Ee,O as pe,c as he,n as X,bQ as U,bW as ie,c5 as Me,a0 as Pe,e as De}from"./icons-vendor-BkJfVEt0.js";import{p as $e}from"./puzzleHomeworkService-C7p4uB-Y.js";import{o as re}from"./openingCatalogueService-C2XSLmal.js";import{E as Fe}from"./EmptyState-CslZ5HrU.js";import"./index-BHnHaHtD.js";import"./supabase-vendor-Ba-0_w4O.js";import"./devMode-B1-AxsYh.js";import"./coachStudentName-Btxy_lQs.js";import"./puzzleConstants-BJ6IzKi3.js";const qe=s(r=>({id:r.id,curriculumId:r.curriculum_id,coachId:r.coach_id,title:r.title??"",description:r.description??null,position:Number(r.position)||0,durationMinutes:r.duration_minutes??null,homeworkTemplate:r.homework_template??null,lessonContent:r.lesson_content??{},createdAt:r.created_at,updatedAt:r.updated_at}),"mapLesson");function Oe(r){const{user:n}=ce(),[l,N]=d.useState({head:null,lessons:[]}),[x,c]=d.useState(!0),[b,v]=d.useState(!1),[P,g]=d.useState(null),f=d.useCallback(async()=>{if(!r||!n?.id){c(!1);return}c(!0),g(null);try{const[{data:m,error:i},{data:u,error:h}]=await Promise.all([A.from("coach_curricula").select("id, coach_id, name, level, status, description, updated_at").eq("id",r).eq("coach_id",n.id).maybeSingle(),A.from("coach_curriculum_lessons").select("id, curriculum_id, coach_id, title, description, position, duration_minutes, homework_template, lesson_content, created_at, updated_at").eq("curriculum_id",r).eq("coach_id",n.id).order("position",{ascending:!0})]);if(i)throw i;if(h)throw h;N({head:m?{id:m.id,coachId:m.coach_id,name:m.name,level:m.level,status:m.status,description:m.description??null,updatedAt:m.updated_at}:null,lessons:(u??[]).map(qe)})}catch(m){g(m instanceof Error?m.message:"Failed to load curriculum")}finally{c(!1)}},[r,n?.id]);d.useEffect(()=>{f()},[f]);const w=d.useCallback(async m=>{if(!(!r||!n?.id)){v(!0),g(null);try{const{error:i}=await A.from("coach_curricula").update({name:m.name,level:m.level,status:m.status,description:m.description}).eq("id",r).eq("coach_id",n.id);if(i)throw i;await f()}catch(i){g(i instanceof Error?i.message:"Failed to update curriculum")}finally{v(!1)}}},[r,n?.id,f]),j=d.useCallback(async m=>{if(!(!r||!n?.id)){v(!0),g(null);try{const i=l.lessons.length>0?Math.max(...l.lessons.map(k=>k.position))+1:1,u={curriculum_id:r,coach_id:n.id,title:m.title.trim(),description:m.description?.trim()||null,homework_template:m.homeworkTemplate?.trim()||null,position:i};typeof m.durationMinutes=="number"&&Number.isFinite(m.durationMinutes)&&(u.duration_minutes=m.durationMinutes);const{error:h}=await A.from("coach_curriculum_lessons").insert(u);if(h)throw h;await f()}catch(i){g(i instanceof Error?i.message:"Failed to add lesson")}finally{v(!1)}}},[r,n?.id,l.lessons,f]),y=d.useCallback(async(m,i)=>{if(n?.id){v(!0),g(null);try{const u={};i.title!==void 0&&(u.title=i.title.trim()),i.description!==void 0&&(u.description=i.description?.trim()||null),i.homeworkTemplate!==void 0&&(u.homework_template=i.homeworkTemplate?.trim()||null),typeof i.durationMinutes=="number"&&Number.isFinite(i.durationMinutes)&&(u.duration_minutes=i.durationMinutes);const{error:h}=await A.from("coach_curriculum_lessons").update(u).eq("id",m).eq("coach_id",n.id);if(h)throw h;await f()}catch(u){g(u instanceof Error?u.message:"Failed to update lesson")}finally{v(!1)}}},[n?.id,f]),z=d.useCallback(async(m,i)=>{if(n?.id){v(!0),g(null);try{const u={};i.puzzle_pack_ids?.length&&(u.puzzle_pack_ids=i.puzzle_pack_ids),i.opening_catalogue_id&&(u.opening_catalogue_id=i.opening_catalogue_id),i.is_tournament&&(u.is_tournament=!0),i.online_session&&(u.online_session=!0),typeof i.session_duration_min=="number"&&(u.session_duration_min=i.session_duration_min);const{error:h}=await A.from("coach_curriculum_lessons").update({lesson_content:u}).eq("id",m).eq("coach_id",n.id);if(h)throw h;await f()}catch(u){g(u instanceof Error?u.message:"Failed to update lesson content")}finally{v(!1)}}},[n?.id,f]),_=d.useCallback(async m=>{if(n?.id){v(!0),g(null);try{const{error:i}=await A.from("coach_curriculum_lessons").delete().eq("id",m).eq("coach_id",n.id);if(i)throw i;await f()}catch(i){g(i instanceof Error?i.message:"Failed to delete lesson")}finally{v(!1)}}},[n?.id,f]),S=d.useCallback(async(m,i)=>{if(!n?.id)return;const u=l.lessons.findIndex(p=>p.id===m);if(u<0)return;const h=i==="up"?u-1:u+1;if(h<0||h>=l.lessons.length)return;const k=l.lessons[u],t=l.lessons[h];v(!0),g(null);try{await Promise.all([A.from("coach_curriculum_lessons").update({position:t.position}).eq("id",k.id).eq("coach_id",n.id),A.from("coach_curriculum_lessons").update({position:k.position}).eq("id",t.id).eq("coach_id",n.id)]),await f()}catch(p){g(p instanceof Error?p.message:"Failed to reorder")}finally{v(!1)}},[n?.id,l.lessons,f]);
1return{detail:l,loading:x,saving:b,error:P,refresh:f,updateHead:w,addLesson:j,updateLesson:y,updateLessonContent:z,deleteLesson:_,moveLesson:S}}s(Oe,"useCurriculumLessons");const oe={active:"border-emerald-400/30 bg-emerald-500/10 text-emerald-200",paused:"border-amber-400/30 bg-amber-500/10 text-amber-200",completed:"border-sky-400/30 bg-sky-500/10 text-sky-200",canceled:"border-slate-400/30 bg-slate-500/10 text-slate-300"},Ge=s(({open:r,onClose:n,programId:l,programName:N,coachId:x})=>{const[c,b]=d.useState("group"),[v,P]=d.useState([]),[g,f]=d.useState([]),[w,j]=d.useState([]),[y,z]=d.useState(null),[_,S]=d.useState(null),[m,i]=d.useState(""),[u,h]=d.useState(!1),[k,t]=d.useState(!1),[p,C]=d.useState(!1),[T,O]=d.useState(!1),[G,H]=d.useState(null),[o,L]=d.useState(null),{push:D}=Ne(),I=s(async()=>{C(!0);try{const a=await $.listProgramAssignments(l);j(a)}catch(a){L(a instanceof Error?a.message:"Failed to load assignments.")}finally{C(!1)}},"refreshAssignments");d.useEffect(()=>{r&&(z(null),S(null),L(null),i(""),h(!0),$.listCoachGroupKeys(x).then(a=>P(a)).catch(a=>L(a instanceof Error?a.message:"Failed to load groups.")).finally(()=>h(!1)),I())},[r,l,x]),d.useEffect(()=>{!r||c!=="student"||g.length>0||(t(!0),$.listStudents("live",x).then(a=>f(a)).catch(a=>L(a instanceof Error?a.message:"Failed to load students.")).finally(()=>t(!1)))},[r,c,x]);const J=d.useMemo(()=>{const a=m.trim().toLowerCase();return g.filter(E=>!a||(E.displayName??"").toLowerCase().includes(a)).slice(0,100)},[g,m]),be=s(a=>{D("success",a)},"showToast"),ge=s(async()=>{L(null),O(!0);try{if(c==="group"){if(!y)return;await $.assignProgramToGroup(l,y)}else{if(!_)return;await $.assignProgramToStudent(l,_)}z(null),S(null),await I(),be("Program assigned")}catch(a){L(a instanceof Error?a.message:"Failed to assign program.")}finally{O(!1)}},"handleConfirm"),fe=s(async a=>{L(null),H(a);try{await $.advanceProgramLesson(a),await I()}catch(E){L(E instanceof Error?E.message:"Failed to advance lesson.")}finally{H(null)}},"handleAdvance"),je=c==="group"&&!!y||c==="student"&&!!_,Y=s((a,E,Z,ve)=>e.jsxs("button",{type:"button",onClick:ve,className:`flex w-full items-center justify-between rounded-lg border px-3 py-2 text-left transition ${Z?"border-amber-400/50 bg-amber-500/[0.08] ring-2 ring-amber-400/40":"border-white/10 bg-white/[0.03] hover:border-white/20 hover:bg-white/[0.05]"}`,children:[e.jsx("span",{className:"font-body text-sm text-white",children:E}),Z&&e.jsx(ae,{size:12,className:"text-amber-300"})]},a),"renderTile");return e.jsxs(_e,{open:r,onClose:n,ariaLabel:"Assign program",width:420,children:[e.jsxs("header",{className:"mb-4 -mt-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{size:16,className:"text-amber-300"}),e.jsx("h2",{className:`${me.h3} truncate`,children:"Assign program"})]}),e.jsx("p",{className:"mt-1 truncate font-body text-xs text-slate-400",children:N})]}),e.jsx("div",{className:"-mx-1 overflow-x-auto px-1",children:e.jsx(Ce,{variant:"segment",themedAccentColor:"#F59E0B",value:c,onChange:b,ariaLabel:"Assign program target",tabs:[{id:"group",label:"Assign to group",icon:e.jsx(W,{size:12,"aria-hidden":!0})},{id:"student",label:"Assign to student",icon:e.jsx(Le,{size:12,"aria-hidden":!0})}]})}),o&&e.jsxs("div",{className:"mt-3 flex items-start gap-2 rounded-lg border border-rose-400/30 bg-rose-500/10 p-3 font-body text-xs text-rose-200",children:[e.jsx(ue,{size:14,className:"mt-0.5 shrink-0"}),e.jsx("span",{children:o})]}),e.jsxs("div",{className:"mt-4 flex flex-col gap-5",children:[c==="group"?e.jsxs("section",{children:[e.jsx("h3",{className:"mb-2 text-[10px] font-bold uppercase tracking-wider text-slate-400",children:"Pick a group"}),u?e.jsx("p",{className:"font-body text-xs text-slate-500",children:"Loading groups…"}):v.length===0?e.jsx("p",{className:"rounded-lg border border-white/5 bg-white/[0.02] p-3 font-body text-xs text-slate-500",children:"No active groups for this coach."}):e.jsx("div",{className:"space-y-2",children:v.map(a=>Y(a,a,y===a,()=>z(a)))})]}):e.jsxs("section",{children:[e.jsx("h3",{className:"mb-2 text-[10px] font-bold uppercase tracking-wider text-slate-400",children:"Pick a student"}),e.jsx("div",{className:"mb-2",children:e.jsx(M,{value:m,onChange:s(a=>i(a.target.value),"onChange"),placeholder:"Search students…","aria-label":"Search students"})}),k?e.jsx("p",{className:"font-body text-xs text-slate-500",children:"Loading students…"}):J.length===0?e.jsx("p",{className:"rounded-lg border border-white/5 bg-white/[0.02] p-3 font-body text-xs text-slate-500",children:"No matching students."}):e.jsx("div",{className:"space-y-2",children:J.map(a=>Y(a.id,a.displayName,_===a.id,()=>S(a.id)))})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-2 flex items-center justify-between",children:[e.jsxs("h3",{className:"text-[10px] font-bold uppercase tracking-wider text-slate-400",children:["Current assignments (",w.length,")"]}),e.jsx("button",{type:"button",onClick:s(()=>{I()},"onClick"),disabled:p,className:"rounded p-1 text-slate-500 transition hover:text-slate-200 disabled:opacity-50","aria-label":"Refresh assignments",children:e.jsx(Te,{size:11,className:p?"animate-spin":""})})]}),p&&w.length===0?e.jsx("p",{className:"font-body text-xs text-slate-500",children:"Loading…"}):w.length===0?e.jsx("p",{className:"rounded-lg border border-white/5 bg-white/[0.02] p-3 font-body text-xs text-slate-500",children:"No assignments yet."}):e.jsx("div",{className:"space-y-2",children:w.map(a=>{const E=a.status==="active"&&a.currentLessonIndex<a.totalLessons;return e.jsxs("div",{className:"rounded-lg border border-white/10 bg-white/[0.03] p-3",children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate font-body text-sm text-white",children:a.studentName??a.groupKey??"—"}),e.jsxs("p",{className:"mt-0.5 font-body text-[11px] text-slate-400",children:["Lesson ",a.currentLessonIndex," of ",a.totalLessons," · started ",new Date(a.startedAt).toLocaleDateString()]})]}),e.jsx("span",{className:`shrink-0 rounded-md border px-1.5 py-0.5 font-body text-[10px] font-bold uppercase tracking-wide ${oe[a.status]??oe.canceled}`,children:a.status})]}),e.jsx("div",{className:"mt-2 flex items-center justify-end",children:e.jsxs("button",{type:"button",onClick:s(()=>{fe(a.id)},"onClick"),disabled:!E||G===a.id,className:"inline-flex items-center gap-1 rounded-md border border-amber-400/30 bg-amber-500/10 px-2 py-1 font-body text-[11px] font-semibold text-amber-200 transition hover:bg-amber-500/20 disabled:cursor-not-allowed disabled:opacity-40",children:[e.jsx(Ae,{size:11}),G===a.id?"Advancing…":"Advance"]})})]},a.id)})})]})]}),e.jsxs("footer",{className:"mt-5 flex items-center justify-end gap-2 border-t border-white/10 pt-4",children:[e.jsx("button",{type:"button",onClick:n,className:"inline-flex items-center gap-1.5 rounded-lg border border-white/10 bg-white/[0.04] px-3 py-2 font-body text-xs font-semibold text-slate-300 transition hover:bg-white/[0.08]",children:"Close"}),e.jsxs("button",{type:"button",onClick:s(()=>{ge()},"onClick"),disabled:!je||T,className:"inline-flex items-center gap-1.5 rounded-lg border border-amber-400/40 bg-amber-500/20 px-4 py-2 font-body text-xs font-semibold text-amber-100 transition hover:bg-amber-500/30 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(ae,{size:12}),T?"Assigning…":"Confirm"]})]})]})},"AssignProgramDrawer"),Q="text-[10px] font-bold uppercase tracking-wide text-slate-400",He="w-full rounded-lg border border-white/10 bg-[#080C14] px-2.5 py-2 font-body text-xs text-slate-200 outline-none transition focus:border-amber-400/40 placeholder:text-slate-500",Ie=[30,45,50,60,90],Be=s(({initial:r,coachId:n,saving:l,onCancel:N,onSave:x})=>{const[c,b]=d.useState(r);d.useEffect(()=>{b(r)},[r]);
1const[v,P]=d.useState([]),[g,f]=d.useState(!1),[w,j]=d.useState(""),[y,z]=d.useState([]),[_,S]=d.useState(!1),[m,i]=d.useState(null);d.useEffect(()=>{if(!n)return;let t=!1;return f(!0),$e.listMyPacks(n).then(p=>{t||P(p)}).catch(()=>{}).finally(()=>{t||f(!1)}),()=>{t=!0}},[n]),d.useEffect(()=>{if(!c.opening_catalogue_id||m?.id===c.opening_catalogue_id)return;let t=!1;return re.search(void 0,void 0,200).then(p=>{if(t)return;const C=p.find(T=>T.id===c.opening_catalogue_id);C&&i(C)}).catch(()=>{}),()=>{t=!0}},[c.opening_catalogue_id,m]),d.useEffect(()=>{let t=!1;S(!0);const p=window.setTimeout(()=>{re.search(w.trim()||void 0,void 0,25).then(C=>{t||z(C)}).catch(()=>{}).finally(()=>{t||S(!1)})},200);return()=>{t=!0,window.clearTimeout(p)}},[w]);const u=s(t=>{const p=c.puzzle_pack_ids??[],C=p.includes(t)?p.filter(T=>T!==t):[...p,t];b({...c,puzzle_pack_ids:C.length?C:void 0})},"togglePack"),h=s(t=>{b({...c,opening_catalogue_id:t}),t||i(null)},"setOpeningId"),k=d.useMemo(()=>{const t=[];return c.puzzle_pack_ids?.length&&t.push(`${c.puzzle_pack_ids.length} pack${c.puzzle_pack_ids.length>1?"s":""}`),c.opening_catalogue_id&&t.push("opening"),c.is_tournament&&t.push("tournament"),c.online_session&&t.push("online session"),t.join(" · ")||"no blocks yet"},[c]);return e.jsxs("div",{className:"rounded-xl border border-amber-400/20 bg-amber-500/[0.04] p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h4",{className:"text-sm font-bold text-amber-200",children:"Lesson content"}),e.jsx("span",{className:"text-[10px] uppercase tracking-wide text-slate-500",children:k})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{className:`${Q} inline-flex items-center gap-1`,children:[e.jsx(xe,{size:10})," Puzzle packs"]}),g?e.jsxs("div",{className:"text-[11px] text-slate-500 inline-flex items-center gap-1.5",children:[e.jsx(K,{size:11,className:"animate-spin"})," Loading…"]}):v.length===0?e.jsx("p",{className:"text-[11px] text-slate-500",children:"No packs yet. Create one on /coach/homework, then revisit."}):e.jsx("div",{className:"flex flex-wrap gap-1",children:v.map(t=>{const p=(c.puzzle_pack_ids??[]).includes(t.id);return e.jsx("button",{type:"button",onClick:s(()=>u(t.id),"onClick"),className:`text-[11px] px-2 py-1 rounded-full border transition truncate max-w-[180px] ${p?"border-amber-400/40 bg-amber-500/15 text-amber-100":"border-white/10 bg-white/5 text-slate-300 hover:border-white/20"}`,title:`${t.title} · ${t.puzzleCount??t.puzzleIds.length} puzzles`,children:t.title},t.id)})})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{className:`${Q} inline-flex items-center gap-1`,children:[e.jsx(R,{size:10})," Opening drill"]}),m&&e.jsxs("div",{className:"rounded-lg border border-cyan-400/30 bg-cyan-500/10 px-2.5 py-1.5 flex items-center justify-between",children:[e.jsxs("span",{className:"text-[11px] text-cyan-100 inline-flex items-center gap-1.5",children:[e.jsx("span",{className:"font-mono text-cyan-300",children:m.ecoCode}),e.jsx("span",{className:"font-semibold truncate max-w-[200px]",children:m.name})]}),e.jsx("button",{onClick:s(()=>{h(void 0)},"onClick"),className:"text-cyan-300 hover:text-rose-300",children:e.jsx(B,{size:12})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(Ee,{size:11,className:"absolute left-2.5 top-1/2 -translate-y-1/2 text-slate-500"}),e.jsx("input",{value:w,onChange:s(t=>j(t.target.value),"onChange"),placeholder:m?"Replace with…":"Italian, Sicilian, Caro-Kann…",className:`${He} pl-7`})]}),_&&e.jsxs("div",{className:"text-[11px] text-slate-500 inline-flex items-center gap-1.5",children:[e.jsx(K,{size:11,className:"animate-spin"})," Searching…"]}),!_&&y.length>0&&e.jsx("div",{className:"max-h-[140px] overflow-y-auto rounded-lg border border-white/5 divide-y divide-white/5 premium-scrollbar",children:y.slice(0,12).map(t=>e.jsxs("button",{type:"button",onClick:s(()=>{h(t.id),i(t),j("")},"onClick"),className:"w-full text-left px-2.5 py-1.5 text-[11px] hover:bg-white/5",children:[e.jsx("span",{className:"font-mono text-[10px] text-slate-500 mr-2",children:t.ecoCode}),e.jsx("span",{className:"text-slate-200",children:t.name})]},t.id))})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsx(le,{icon:pe,label:"Tournament roun
1d",hint:"Marks this lesson as a competitive round",active:!!c.is_tournament,onToggle:s(()=>b({...c,is_tournament:!c.is_tournament}),"onToggle"),accent:"amber"}),e.jsx(le,{icon:he,label:"Live online session",hint:"Coach + student meet on Daily.co",active:!!c.online_session,onToggle:s(()=>b({...c,online_session:!c.online_session}),"onToggle"),accent:"emerald"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("label",{className:`${Q} inline-flex items-center gap-1`,children:[e.jsx(X,{size:10})," Duration"]}),e.jsx("div",{className:"flex flex-wrap gap-1.5",children:Ie.map(t=>{const p=(c.session_duration_min??50)===t;return e.jsxs("button",{type:"button",onClick:s(()=>b({...c,session_duration_min:t}),"onClick"),className:`px-3 py-1.5 rounded-lg border text-[11px] font-semibold transition ${p?"border-amber-400/40 bg-amber-500/15 text-amber-100":"border-white/10 bg-white/5 text-slate-300 hover:border-white/20"}`,children:[t," min"]},t)})})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2 pt-2 border-t border-white/5",children:[e.jsxs("button",{onClick:N,disabled:l,className:"inline-flex items-center gap-1.5 rounded-lg border border-white/10 bg-white/[0.04] px-3 py-1.5 text-xs font-semibold text-slate-300 hover:bg-white/[0.08]",children:[e.jsx(B,{size:11})," Cancel"]}),e.jsxs("button",{onClick:s(()=>x(c),"onClick"),disabled:l,className:"inline-flex items-center gap-1.5 rounded-lg border border-amber-400/40 bg-amber-500/20 px-3 py-1.5 text-xs font-semibold text-amber-100 hover:bg-amber-500/30 disabled:opacity-50",children:[l?e.jsx(K,{size:11,className:"animate-spin"}):e.jsx(U,{size:11})," Save content"]})]})]})},"LessonContentEditor"),le=s(({icon:r,label:n,hint:l,active:N,onToggle:x,accent:c})=>{const b=c==="amber"?"border-amber-400/40 bg-amber-500/10 text-amber-100":"border-emerald-400/40 bg-emerald-500/10 text-emerald-100";return e.jsxs("button",{type:"button",onClick:x,className:`text-left rounded-xl border px-3 py-2 transition ${N?b:"border-white/10 bg-white/5 text-slate-200 hover:border-white/20"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-sm font-semibold",children:[e.jsx(r,{size:12})," ",n]}),e.jsx("div",{className:"text-[11px] text-slate-400 mt-0.5",children:l})]})},"ToggleCard"),Re=["beginner","intermediate","advanced","mixed"],Ue=["draft","active","archived"],de={title:"",description:"",durationMinutes:"",homeworkTemplate:""},Ke=s(({lesson:r,onCancel:n,onSave:l,saving:N})=>{const[x,c]=d.useState({title:r.title,description:r.description??"",durationMinutes:r.durationMinutes!=null?String(r.durationMinutes):"",homeworkTemplate:r.homeworkTemplate??""});return e.jsxs("div",{className:"space-y-3",children:[e.jsx(M,{value:x.title,onChange:s(b=>c({...x,title:b.target.value}),"onChange"),placeholder:"Lesson title"}),e.jsx(V,{rows:2,value:x.description,onChange:s(b=>c({...x,description:b.target.value}),"onChange"),placeholder:"Description (optional)"}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsx(M,{type:"number",min:0,value:x.durationMinutes,onChange:s(b=>c({...x,durationMinutes:b.target.value}),"onChange"),placeholder:"Duration (min)"}),e.jsx(M,{value:x.homeworkTemplate,onChange:s(b=>c({...x,homeworkTemplate:b.target.value}),"onChange"),placeholder:"Homework template (optional)"})]}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsxs("button",{onClick:n,disabled:N,className:"inline-flex items-center gap-1.5 rounded-lg border border-white/10 bg-white/[0.04] px-3 py-1.5 font-body text-xs font-semibold text-slate-300 hover:bg-white/[0.08]",children:[e.jsx(B,{size:11})," Cancel"]}),e.jsxs("button",{onClick:s(()=>
1l({title:x.title,description:x.description,durationMinutes:x.durationMinutes?Number(x.durationMinutes):null,homeworkTemplate:x.homeworkTemplate}),"onClick"),disabled:N||!x.title.trim(),className:"inline-flex items-center gap-1.5 rounded-lg border border-amber-400/40 bg-amber-500/20 px-3 py-1.5 font-body text-xs font-semibold text-amber-100 hover:bg-amber-500/30 disabled:opacity-50",children:[e.jsx(U,{size:11})," Save"]})]})]})},"LessonEditor"),ut=s(()=>{const{id:r}=we(),{user:n}=ce(),{detail:l,loading:N,saving:x,error:c,updateHead:b,addLesson:v,updateLesson:P,updateLessonContent:g,deleteLesson:f,moveLesson:w}=Oe(r),[j,y]=d.useState(de),[z,_]=d.useState(!1),[S,m]=d.useState(null),[i,u]=d.useState(null),[h,k]=d.useState(!1),[t,p]=d.useState({name:"",level:"",status:"",description:""}),[C,T]=d.useState(!1);if(N&&!l.head)return e.jsxs("div",{className:"space-y-4",children:[e.jsx(te,{w:"w-full",h:96,r:16}),e.jsx(te,{w:"w-full",h:256,r:16})]});if(!l.head)return e.jsxs("div",{className:"space-y-4",children:[e.jsx("div",{className:"rounded-2xl border border-amber-400/30 bg-amber-500/10 p-4 font-body text-sm text-amber-100",children:"Curriculum not found or you don't have access."}),e.jsxs(ee,{to:"/coach/curriculum",className:"inline-flex items-center gap-1.5 font-body text-xs text-amber-300 hover:text-amber-200",children:[e.jsx(ne,{size:12})," Back to curriculum list"]})]});const O=s(()=>{p({name:l.head.name,level:l.head.level,status:l.head.status,description:l.head.description??""}),k(!0)},"startEditHead"),G=s(async()=>{await b(t),k(!1)},"saveHead"),H=s(async()=>{j.title.trim()&&(await v({title:j.title,description:j.description,durationMinutes:j.durationMinutes?Number(j.durationMinutes):null,homeworkTemplate:j.homeworkTemplate}),y(de),_(!1))},"handleAddLesson");return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{children:e.jsxs(ee,{to:"/coach/curriculum",className:"inline-flex items-center gap-1.5 font-body text-xs text-slate-400 hover:text-amber-300",children:[e.jsx(ne,{size:12})," Back to list"]})}),e.jsx("section",{className:`${F.card} ${F.innerGlow} ${F.radialAmber} rounded-2xl p-6`,children:h?e.jsxs("div",{className:"space-y-3",children:[e.jsx(M,{value:t.name,onChange:s(o=>p({...t,name:o.target.value}),"onChange"),placeholder:"Curriculum name"}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsx(se,{value:t.level,onChange:s(o=>p({...t,level:o.target.value}),"onChange"),options:Re.map(o=>({value:o,label:o}))}),e.jsx(se,{value:t.status,onChange:s(o=>p({...t,status:o.target.value}),"onChange"),options:Ue.map(o=>({value:o,label:o}))})]}),e.jsx(V,{rows:3,value:t.description,onChange:s(o=>p({...t,description:o.target.value}),"onChange"),placeholder:"Description"}),e.jsxs("div",{className:"flex items-center justify-end gap-2",children:[e.jsxs("button",{onClick:s(()=>k(!1),"onClick"),className:"inline-flex items-center gap-1.5 rounded-lg border border-white/10 bg-white/[0.04] px-3 py-1.5 font-body text-xs font-semibold text-slate-300",children:[e.jsx(B,{size:11})," Cancel"]}),e.jsxs("button",{onClick:G,disabled:x,className:"inline-flex items-center gap-1.5 rounded-lg border border-amber-400/40 bg-amber-500/20 px-3 py-1.5 font-body text-xs font-semibold text-amber-100 hover:bg-amber-500/30 disabled:opacity-50",children:[e.jsx(U,{size:11})," Save"]})]})]}):e.jsxs("div",{className:"flex items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex-1",children:[e.jsxs("div",{className:"mb-1 flex flex-wrap items-center gap-2",children:[e.jsx("h1",{className:"font-display text-2xl font-bold text-white",children:l.head.name}),e.jsx(q,{content:"Target student level for this program.",children:e.jsx("span",{className:"rounded-md border border-white/10 bg-white/5 px-2 py-0.5 font-body text-[10px] font-bold uppercase text-slate-300",children:l.head.level})}),e.jsx(q,{content:"Active = in use. Draft = work-in-progress. Archived = retired.",children:e.jsx("span",{className:`rounded-md border px-2 py-0.5 font-body text-[10px] font-bold uppercase ${l.head.status==="active"?"border-emerald-400/30 bg-emerald-500/10 text-emerald-200":l.head.status==="archived"?"border-slate-400/30 bg-slate-500/10 text-slate-300":"border-amber-400/30 bg-amber-500/10 text-amber-200"}`,children:l.head.status})})]}),e.jsx("p",{className:"font-body text-sm text-slate-400",children:l.head.description??e.jsx("span",{className:"italic text-slate-500",children:"No description yet."})}),e.jsx(q,{content:"Total number of lessons currently in this program.",children:e.jsxs("p",{className:"mt-2 font-body text-[11px] text-slate-500",children:[l.lessons.length," ",l.lessons.length===1?"lesson":"lessons"]})})]}),e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[e.jsxs("button",{onClick:s(()=>T(!0),"onClick"),disabled:!n?.id||!r,className:"inline-flex items-center gap-1.5 rounded-lg border border-amber-400/40 bg-amber-500/15 px-3 py-1.5 font-body text-xs font-semibold text-amber-100 hover:bg-amber-500/25 disabled:cursor-not-allowed disabled:opacity-50",children:[e.jsx(W,{size:11})," Assign to group/student"]}),e.jsxs("button",{onClick:O,className:"inline-flex items-center gap-1.5 rounded-lg border border-white/10 bg-white/[0.04] px-3 py-1.5 font-body text-xs font-semibold text-slate-300 hover:bg-white/[0.08]",children:[e.jsx(ie,{size:11})," Edit"]})]})]})}),r&&n?.id&&e.jsx(Ge,{open:C,onClose:s(()=>T(!1),"onClose"),programId:r,programName:l.head.name,coachId:n.id}),c&&e.jsxs("section",{className:"flex items-start gap-3 rounded-2xl border border-red-500/30 bg-red-500/10 p-4",children:[e.jsx(ue,{size:16,className:"mt-0.5 shrink-0 text-red-300"}),e.jsx("p",{className:"font-body text-sm text-red-200",children:c})]}),e.jsxs("section",{className:`${F.card} ${F.innerGlow} rounded-2xl p-6`,children:[e.jsxs("div",{className:"mb-5 flex items-center justify-between",children:[e.jsx("h2",{className:me.h3,children:"Lessons"}),e.jsxs("button",{onClick:s(()=>_(!z),"onClick"),className:"inline-flex items-center gap-1.5 rounded-lg border border-amber-400/40 bg-amber-500/15 px-3 py-1.5 font-body text-xs font-semibold text-amber-100 hover:bg-amber-500/25",children:[e.jsx(Me,{size:12})," ",z?"Cancel":"Add lesson"]})]}),z&&e.jsx("div",{className:"mb-5 rounded-xl border border-amber-400/20 bg-amber-500/[0.05] p-4",children:e.jsxs("div",{className:"space-y-3",children:[e.jsx(M,{value:j.title,onChange:s(o=>y({...j,title:o.target.value}
1),"onChange"),placeholder:"Lesson title (required)",autoFocus:!0}),e.jsx(V,{rows:2,value:j.description,onChange:s(o=>y({...j,description:o.target.value}),"onChange"),placeholder:"What will students learn?"}),e.jsxs("div",{className:"grid gap-2 md:grid-cols-2",children:[e.jsx(M,{type:"number",min:0,value:j.durationMinutes,onChange:s(o=>y({...j,durationMinutes:o.target.value}),"onChange"),placeholder:"Duration (min, optional)"}),e.jsx(M,{value:j.homeworkTemplate,onChange:s(o=>y({...j,homeworkTemplate:o.target.value}),"onChange"),placeholder:"Homework template (optional)"})]}),e.jsx("div",{className:"flex items-center justify-end gap-2",children:e.jsxs("button",{onClick:H,disabled:x||!j.title.trim(),className:"inline-flex items-center gap-1.5 rounded-lg border border-amber-400/40 bg-amber-500/20 px-3 py-1.5 font-body text-xs font-semibold text-amber-100 hover:bg-amber-500/30 disabled:opacity-50",children:[e.jsx(U,{size:11})," Add lesson"]})})]})}),l.lessons.length===0?e.jsx(Fe,{icon:e.jsx(R,{size:16}),title:"No lessons yet",description:'Click "Add lesson" to start building your curriculum.'}):e.jsx("ol",{className:"space-y-3",children:l.lessons.map((o,L)=>e.jsxs("li",{className:"rounded-xl border border-white/10 bg-white/[0.02] p-4",children:[S===o.id?e.jsx(Ke,{lesson:o,saving:x,onCancel:s(()=>m(null),"onCancel"),onSave:s(async D=>{await P(o.id,D),m(null)},"onSave")}):e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsxs("div",{className:"flex flex-col items-center gap-1",children:[e.jsx("button",{onClick:s(()=>w(o.id,"up"),"onClick"),disabled:L===0||x,className:"rounded p-0.5 text-slate-500 hover:text-white disabled:opacity-20","aria-label":"Move up",children:e.jsx(Pe,{size:14})}),e.jsx("span",{className:"font-display text-lg font-bold text-slate-500",children:o.position}),e.jsx("button",{onClick:s(()=>w(o.id,"down"),"onClick"),disabled:L===l.lessons.length-1||x,className:"rounded p-0.5 text-slate-500 hover:text-white disabled:opacity-20","aria-label":"Move down",children:e.jsx(ze,{size:14})})]}),e.jsxs("div",{className:"flex-1",children:[e.jsx("p",{className:"font-body text-sm font-semibold text-white",children:o.title}),o.description&&e.jsx("p",{className:"mt-1 font-body text-xs text-slate-400 line-clamp-2",children:o.description}),e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3 font-body text-[11px] text-slate-500",children:[o.durationMinutes!=null&&e.jsx(q,{content:"Planned duration for this lesson.",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(X,{size:10})," ",o.durationMinutes," min"]})}),o.homeworkTemplate&&e.jsx(q,{content:"Default homework template attached to this lesson.",children:e.jsxs("span",{className:"inline-flex items-center gap-1",children:[e.jsx(R,{size:10})," ",o.homeworkTemplate]})})]}),e.jsx(Qe,{lesson:o})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:s(()=>u(i===o.id?null:o.id),"onClick"),className:`rounded-lg border p-1.5 transition ${i===o.id?"border-amber-400/40 bg-amber-500/15 text-amber-100":"border-white/10 bg-white/[0.04] text-slate-300 hover:bg-white/[0.08] hover:text-white"}`,"aria-label":"Edit content",title:"Edit lesson content",children:e.jsx(De,{size:12})}),e.jsx("button",{onClick:s(()=>m(o.id),"onClick"),className:"rounded-lg border border-white/10 bg-white/[0.04] p-1.5 text-slate-300 hover:bg-white/[0.08] hover:text-white","aria-label":"Edit",children:e.jsx(ie,{size:12})}),e.jsx("button",{onClick:s(async()=>{await ke.confirm({title:`Delete lesson "${o.title}"?`,description:"The lesson and its content will be removed.",variant:"danger",confirmLabel:"Delete"})&&f(o.id)},"onClick"),className:"rounded-lg border border-red-400/20 bg-red-500/[0.05] p-1.5 text-red-300 hover:bg-red-500/[0.12]","aria-label":"Delete",children:e.jsx(Se,{size:12})})]})]}),i===o.id&&S!==o.id&&e.jsx("div",{className:"mt-3",children:e.jsx(Be,{initial:o.lessonContent,coachId:n?.id,saving:x,onCancel:s(()=>u(null),"onCancel"),onSave:s(async D=>{await g(o.id,D),u(null)},"onSave")})})]},o.id))})]})]})},"CoachCurriculumDetailPage"),Qe=s(({lesson:r})=>{const n=r.lessonContent,l=[];return n.puzzle_pack_ids?.length&&l.push(e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-400/30 bg-amber-500/10 px-2 py-0.5 text-[10px] font-semibold text-amber-200",children:[e.jsx(xe,{size:10})," ",n.puzzle_pack_ids.length," pack",n.puzzle_pack_ids.length>
11?"s":""]},"pp")),n.opening_catalogue_id&&l.push(e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-cyan-400/30 bg-cyan-500/10 px-2 py-0.5 text-[10px] font-semibold text-cyan-200",children:[e.jsx(R,{size:10})," Opening"]},"op")),n.is_tournament&&l.push(e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-400/30 bg-amber-500/10 px-2 py-0.5 text-[10px] font-semibold text-amber-200",children:[e.jsx(pe,{size:10})," Tournament"]},"tr")),n.online_session&&l.push(e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-emerald-400/30 bg-emerald-500/10 px-2 py-0.5 text-[10px] font-semibold text-emerald-200",children:[e.jsx(he,{size:10})," Online"]},"on")),typeof n.session_duration_min=="number"&&n.session_duration_min!==(r.durationMinutes??50)&&l.push(e.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-white/10 bg-white/5 px-2 py-0.5 text-[10px] font-semibold text-slate-300",children:[e.jsx(X,{size:10})," ",n.session_duration_min,"m"]},"du")),l.length===0?null:e.jsx("div",{className:"mt-2 flex flex-wrap gap-1",children:l})},"ContentBlockChips");export{ut 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.