1import{r as m,j as e}from"./vendor-radix-DLGwGdby.js";import{as as Ie,u as Ye,J as ze,N as We,f as Qe,q as Te,K as Fe,t as p,av as U,h as fe,A as be,C as G,e as H,B as N,Q as Ve,R as Ke,U as Ue,V as Ge,a2 as He,W as Je,L as Oe}from"./index-Cz1Nuibl.js";import{W as Xe,B as Ze,A as et,C as tt,a as st,E as it,S as at,b as rt,M as nt,R as ot}from"./EnrollmentFormEditor-Dgy6tsKY.js";import{M as lt,u as we,d as dt,e as ct,E as ut,f as mt,p as ht,h as pt,c as Pe,b as gt,a as ft,g as bt,v as xt,I as _t}from"./CohortPricingEditor-4zCY2VLb.js";import{e as vt}from"./apiErrors-DOs8pvbO.js";import"./switch-DkZdf0MO.js";import{n as Le}from"./masterClassDetailTypes-DQ-OYPs-.js";import"./alert-dialog-DcLzGzcI.js";import{L as ve,c as Ee,a5 as ye,A as qe,G as yt,b3 as wt,b8 as De,l as jt}from"./vendor-lucide-BWW0XcuW.js";import"./vendor-recharts-dzgay_RI.js";import"./vendor-datefns-CU7NMMYW.js";import"./useDropdownOptions-DXM1Ytyj.js";import"./uploadLimits-DnSzEr_f.js";import"./upload-progress-Cl3zmXlA.js";import"./currencyConstants-Cgim7hCA.js";const St=["draft","changes_requested","approved","published","enrollment_open","enrollment_closed","in_progress"],Nt=["draft","changes_requested"],kt=["approved","published","enrollment_open","enrollment_closed","in_progress"],Ct={draft:"bg-muted text-muted-foreground",submitted:"bg-warning/10 text-warning",under_review:"bg-info/10 text-info",changes_requested:"bg-warning/10 text-warning",approved:"bg-primary/10 text-primary",published:"bg-success/10 text-success",enrollment_open:"bg-success/10 text-success",in_progress:"bg-chart-5/10 text-chart-5",completed:"bg-muted text-muted-foreground"},_=lt;function xe(d){return d.replace(/_/g," ").replace(/\b\w/g,s=>s.toUpperCase())}function Et(d){if(d.status!==422||!d.details||typeof d.details!="object")return{};const s={};for(const[a,g]of Object.entries(d.details))a==="fieldErrors"||a==="formErrors"||(Array.isArray(g)&&typeof g[0]=="string"?s[a]=g[0]:typeof g=="string"&&(s[a]=g));return s}function qt(d){if(!d.details||typeof d.details!="object")return;const s=d.details.formErrors;return Array.isArray(s)&&typeof s[0]=="string"?s[0]:void 0}function At(d){const s=Object.keys(d);return s.some(a=>["duration_weeks","total_sessions","max_participants","duration_mode","session_schedule","pricing","price","currency","early_bird_price","early_bird_deadline","enrollment_deadline"].includes(a))?3:s.some(a=>a==="enrollment_form"||a.startsWith("enrollment_form."))?4:s.some(a=>["outcomes","audiences","prerequisites"].includes(a))?1:s.includes("curriculum")?2:s.some(a=>["inclusions","eligibility_criteria","eligibility_enforcement"].includes(a))?5:s.some(a=>["description","description_ar","cover_image_url","promo_video_url","tags","faqs"].includes(a))?6:0}function Mt({mode:d="instructor"}={}){const{copy:s}=we(),{id:a}=Ie(),g=Ye(),h=ze(),{isMentor:k,isSuperAdmin:C,isLoading:f}=We(),[J]=Qe(),r=d==="admin",X=r?C:k,B=r?`${be}/admin/master-classes/${a}`:`${be}/master-classes/${a}`,T=r?`${B}/edit`:`${B}/manage`,$=r?"admin-master-class-editor":"instructor-class",w=Math.min(Math.max(0,Number(J.get("step")??"0")||0),_.length-1),[Z,b]=m.useState(w),[ee,I]=m.useState(!1),[Y,v]=m.useState({}),[l,te]=m.useState({...dt}),[F,se]=m.useState([]),[P,ie]=m.useState([]),[z,ae]=m.useState([]),[re,ne]=m.useState([]),[oe,le]=m.useState([]),[L,de]=m.useState([]),[ce,ue]=m.useState([]),[me,he]=m.useState("advisory"),[E,D]=m.useState([]),[W,Q]=m.useState(ct),[q,pe]=m.useState(ut),[j,y]=m.useState(()=>Le()),[V,O]=m.useState(!1),[je,ge]=m.useState([]),{data:K,isLoading:Se,error:n}=Te({queryKey:[$,a],queryFn:()=>fe.get(T),enabled:!!a&&X,retry:!1}),Ne=Te({queryKey:["instructor-class-cohorts",a],queryFn:()=>fe.get(`${be}/master-classes/${a}/cohorts`),enabled:!!a&&!r&&k,retry:!1}),o=K?.master_class;m.useEffect(()=>{o&&(te({title:o.title??"",title_ar:o.title_ar??"",tagline:o.tagline??"",description:o.description??"",description_ar:o.description_ar??"",cover_image_url:o.cover_image_url??"",promo_video_url:o.promo_video_url??"",format:o.format??"",class_type:o.class_type??"",level:o.level??"",language:o.language??"en",duration_weeks:o.duration_weeks!=null?String(o.duration_weeks):"",total_sessions:o.total_sessions!=null?String(o.total_sessions):"",max_participants:o.max_participants!=null?String(o.max_participants):"",duration_mode:o.duration_mode==="dates"?"dates":"weeks",tags:(o.tags??[]).join(", "),enrollment_deadline:o.cohort?.enrollment_deadline?String(o.cohort.enrollment_deadline).slice(0,10):""}),se((o.outcomes??[]).map(t=>({value:t.outcome,value_ar:t.outcome_ar??""}))),ie((o.audiences??[]).map(t=>
1({value:t.audience,value_ar:t.audience_ar??""}))),ae((o.prerequisites??[]).map(t=>({value:t.prerequisite,value_ar:t.prerequisite_ar??""}))),ne((o.inclusions??[]).map(t=>({value:t.inclusion,value_ar:t.inclusion_ar??""}))),le((o.faqs??[]).map(t=>({question:t.question,question_ar:t.question_ar??"",answer:t.answer,answer_ar:t.answer_ar??""}))),de((o.curriculum??[]).map(t=>({module_title:t.module_title,module_title_ar:t.module_title_ar??"",module_description:t.module_description??"",module_description_ar:t.module_description_ar??"",lessons:(t.lessons??[]).map(i=>({title:i.title,duration_minutes:i.duration_minutes??null}))}))),ue((o.eligibility_criteria??[]).map(mt)),he(o.eligibility_enforcement==="soft_block"?"soft_block":"advisory"),D((o.session_schedule??[]).map(t=>({date:String(t.date??""),start_time:String(t.start_time??""),duration_minutes:Number(t.duration_minutes??60),title:t.title!=null?String(t.title):void 0}))),Q(ht(o.cohort?.pricing)),pe(pt(o.enrollment_form)),y(Le(o.landing_section_visibility)))},[o]);const x=o?r||St.includes(o.status):!1,ke=o?!r&&Nt.includes(o.status):!1,u=o?kt.includes(o.status):!1,S=Fe({mutationFn:()=>{const t={title:l.title.trim()};if(t.title_ar=l.title_ar.trim()||null,t.tagline=l.tagline.trim()||null,t.description=l.description.trim()||null,t.description_ar=l.description_ar.trim()||null,t.cover_image_url=l.cover_image_url.trim()||null,t.promo_video_url=l.promo_video_url.trim()||null,l.format&&(t.format=l.format),l.class_type&&(t.class_type=l.class_type),l.level&&(t.level=l.level),t.language=l.language.trim()||"en",t.duration_mode=l.duration_mode??"weeks",t.session_schedule=E,l.duration_mode==="dates"){t.total_sessions=E.length||null;const i=E.map(c=>new Date(c.date).getTime()).filter(c=>!isNaN(c));if(i.length>=2){const c=Math.max(...i)-Math.min(...i);t.duration_weeks=Math.max(1,Math.ceil(c/(10080*60*1e3))+1)}else i.length===1?t.duration_weeks=1:t.duration_weeks=null}else t.duration_weeks=l.duration_weeks?Number(l.duration_weeks):null,t.total_sessions=l.total_sessions?Number(l.total_sessions):null;return t.max_participants=l.max_participants?Number(l.max_participants):null,t.tags=l.tags.split(",").map(i=>i.trim()).filter(Boolean),t.outcomes=F.map(i=>({value:i.value.trim(),value_ar:i.value_ar.trim()})).filter(i=>i.value).map(i=>({outcome:i.value,outcome_ar:i.value_ar||null})),t.audiences=P.map(i=>({value:i.value.trim(),value_ar:i.value_ar.trim()})).filter(i=>i.value).map(i=>({audience:i.value,audience_ar:i.value_ar||null})),t.prerequisites=z.map(i=>({value:i.value.trim(),value_ar:i.value_ar.trim()})).filter(i=>i.value).map(i=>({prerequisite:i.value,prerequisite_ar:i.value_ar||null})),t.inclusions=re.map(i=>({value:i.value.trim(),value_ar:i.value_ar.trim()})).filter(i=>i.value).map(i=>({inclusion:i.value,inclusion_ar:i.value_ar||null})),t.faqs=oe.map(i=>({question:i.question.trim(),question_ar:i.question_ar.trim()||null,answer:i.answer.trim(),answer_ar:i.answer_ar.trim()||null})).filter(i=>i.question&&i.answer),t.curriculum=L.map(i=>({module_title:i.module_title.trim(),module_title_ar:i.module_title_ar.trim()||null,module_description:i.module_description.trim()||null,module_description_ar:i.module_description_ar.trim()||null,lessons:i.lessons.map(c=>({title:c.title.trim(),duration_minutes:c.duration_minutes!=null?c.duration_minutes:void 0})).filter(c=>c.title)})).filter(i=>i.module_title),t.eligibility_enforcement=me,t.eligibility_criteria=ce.map(Pe).filter(i=>i!==null),t.pricing=gt(W),t.enrollment_deadline=l.enrollment_deadline?new Date(l.enrollment_deadline).toISOString():null,t.enrollment_form=ft(q),t.landing_section_visibility=j,fe.patch(B,t)},onSuccess:t=>{v({}),p.success(r?"Master Class changes saved.":s("edit.feedback.saved","Changes saved!")),ge(t.warnings??[]),h.invalidateQueries({queryKey:[$,a]}),r?h.invalidateQueries({queryKey:["admin-master-class"]}):h.invalidateQueries({queryKey:["instructor-dashboard"]})},onError:t=>{if(t.status===400||t.status===422){const i=vt(t),c=Object.keys(i).length>0?i:Et(t),M=qt(t);if(Object.keys(c).length>0){const Me=At(c);v(c),b(Me),p.error(M??(Me===3?s("create.feedback.pricingInvalid","Could not save cohort pricing: please fix the highlighted fields."):s("edit.feedback.highlighted","Please fix the highlighted fields and try again.")));return}const R=r?"Validation failed. Please check the form and try again.":s("create.feedback.validation","Validation failed. Please check the form and try again.");p.error(M||(r?t.message||R:U(t,R)))}else if(t.status===403)p.error(r?"You do not have permission to edit this Master Class.":s("edit.feedback.ownerOnly","You can only edit classes you own."));else if(t.status===409){const i=t.details&&typeof t.details=="object"?t.details:{};if(i.code==="referenced_enrollment_field_immutable"){const c=q.fields.filter(R=>R.is_active).findIndex(R=>R.id===i.field_id),M=c>=0?`enrollment_form.fields.${c}.field_type`:"enrollment_form";v({[M]:r?"This question already has responses, so its type cannot be changed. Archive it and add a new question instead.":s("enrollment.errors.immutable","This question already has responses, so its type can't be changed. Archive it and add a new question instead.")}),b(4),p.error(r?"A question with existing responses cannot change type.":s("enrollment.feedback.immutable","A question with existing responses can't change type."))}else if(i.code==="form_revision_conflict")v({enrollment_form:r?`This form was updated elsewhere${i.current_revision?` (revision ${i.current_revision})`:""}. Your changes are preserved; reload after copying any unsaved text.`:s("enrollment.errors.conflict","This form was updated elsewhere{{revision}}. Your changes are preserved; copy any unsaved text before reloading.",{revision:i.current_revision?` (${s("enrollment.revision","revision {{number}}",{number:i.current_revision})})`:""})}),b(4),p.error(r?"The enrollment form changed in another session.":s("enrollment.feedback.conflict","The enrollment form changed in another session."));else if(i.code==="required_field_addition_confirmation_required")v({enrollment_form:r?"Confirm required-field changes in the Enrollment Form step, then save again.":s("enrollment.errors.confirmRequired","Confirm required-field changes in the enrollment form step, then save again.")}),b(4),p.error(r?"Required-field confirmation is needed.":s("enrollment.feedback.confirmRequired","Required-field confirmation is needed."));else{const c=r?"This class can no longer be edited.":s("edit.feedback.noLongerEditable","This class can no longer be edited.");p.error(r?t.message||c:U(t,c))}}else{const i=r?"Failed to save changes.":s("edit.feedback.saveFailed","Failed to save changes.");p.error(r?t.message||i:U(t,i))}}}),A=Fe({mutationFn:()=>fe.post(`${be}/master-classes/${a}/submit`),onSuccess:()=>{O(!1),p.success(s("edit.feedback.submitted","Submitted for review! You'll be notified when the review is complete.")),h.invalidateQueries({queryKey:["instructor-class",a]}),h.invalidateQueries({queryKey:["instructor-dashboard"]})},onError:t=>{t.status===403?p.error(s("edit.feedback.submitOwnerOnly","You can only submit classes you own.")):t.status===409?p.error(r?t.message||"This class can't be submitted in its current status.":U(t,s("edit.feedback.submitStatus","This class can't be submitted in its current status."))):t.status===404?p.error(s("edit.feedback.notFound","This Master Class no longer exists.")):p.error(r?t.message||"Failed to submit for review.":U(t,s("edit.feedback.submitFailed","Failed to submit for review.")))}});function Ce(t,i){te(c=>({...c,[t]:i})),t==="title"&&i.trim()&&I(!1),t==="enrollment_deadline"&&Y.enrollment_deadline&&v(c=>{const M={...c};return delete M.enrollment_deadline,M})}function Re(t){if(t>0&&!l.title.trim()){I(!0),b(0),p.error(s("create.feedback.titleBeforeContinue","Enter a title before continuing."));return}b(Math.max(0,Math.min(_.length-1,t)))}function Be(){if(!l.title.trim()){I(!0),b(0),p.error(s("create.feedback.titleRequired","A title is required."));return}const t=xt(q,(i,c)=>s(`enrollment.validation.${i}`,c));if(Object.keys(t).length>0){v(t),b(4),p.error(s("create.feedback.enrollmentInvalid","Please fix the enrollment form and try again."));return}S.mutate()}const Ae=bt({form:l,outcomes:F,audiences:P,curriculum:L,sessionSchedule:E}),$e=_.slice(0,-1).map((t,i)=>({name:t.title,complete:Ae[i]})).filter(t=>!t.complete).map(t=>t.name);return{id:a,mode:d,navigate:g,isMentor:k,isSuperAdmin:C,hasAccess:X,roleLoading:f,isLoading:Se,error:n,mc:o,cohortsQuery:Ne,step:Z,setStep:b,titleError:ee,fieldErrors:Y,setFieldErrors:v,form:l,outcomes:F,setOutcomes:se,audiences:P,setAudiences:ie,prerequisites:z,setPrerequisites:ae,inclusions:re,setInclusions:ne,faqs:oe,setFaqs:le,curriculum:L,setCurriculum:de,eligibilityCriteria:ce,setEligibilityCriteria:ue,eligibilityEnforcement:me,setEligibilityEnforcement:he,sessionSchedule:E,setSessionSchedule:D,cohortPricing:W,setCohortPricing:Q,enrollmentForm:q,setEnrollmentForm:pe,landingSectionVisibility:j,setLandingSectionVisibility:y,submitDialogOpen:V,setSubmitDialogOpen:O,sessionWarnings:je,isEditable:x,canSubmitForReview:ke,isLive:u,saveMutation:S,submitMutation:A,handleChange:Ce,goToStep:Re,handleSave:Be,stepCompletions:Ae,incompleteStepNames:$e,criterionToApi:Pe}}function Ht({mode:d="instructor"}){return e.jsx(_t,{enabled:d==="instructor",children:e.jsx(Tt,{mode:d})})}function Tt({mode:d}){const{copy:s}=we(),{navigate:a,hasAccess:g,roleLoading:h,isLoading:k,error:C,mc:f,cohortsQuery:J,step:r,setStep:X,titleError:B,fieldErrors:T,setFieldErrors:$,form:w,outcomes:Z,setOutcomes:b,audie
1nces:ee,setAudiences:I,prerequisites:Y,setPrerequisites:v,inclusions:l,setInclusions:te,faqs:F,setFaqs:se,curriculum:P,setCurriculum:ie,eligibilityCriteria:z,setEligibilityCriteria:ae,eligibilityEnforcement:re,setEligibilityEnforcement:ne,sessionSchedule:oe,setSessionSchedule:le,cohortPricing:L,setCohortPricing:de,enrollmentForm:ce,setEnrollmentForm:ue,landingSectionVisibility:me,setLandingSectionVisibility:he,submitDialogOpen:E,setSubmitDialogOpen:D,sessionWarnings:W,isEditable:Q,canSubmitForReview:q,isLive:pe,saveMutation:j,submitMutation:y,handleChange:V,goToStep:O,handleSave:je,stepCompletions:ge,incompleteStepNames:K,criterionToApi:Se}=Mt({mode:d}),n=d==="admin",Ne=n?`/dashboard/admin/master-classes/${f?.id??""}`:"/dashboard/instructor",o=n?"Back to Master Class Management":s("common.backToDashboard","Back to Instructor Dashboard");if(h||g&&k)return e.jsx("div",{className:"max-w-2xl mx-auto p-6 flex justify-center py-12","aria-label":n?"Loading Master Class editor":s("edit.loading","Loading Master Class editor"),children:e.jsx(ve,{className:"h-6 w-6 animate-spin text-muted-foreground"})});if(!g)return e.jsx(_e,{icon:e.jsx(Ee,{className:"h-7 w-7 text-warning"}),title:n?"Administrator Access Required":s("access.title","Instructor Access Required"),message:n?"Only authorized administrators can edit Master Classes on behalf of submitters.":s("access.manageDescription","Only approved instructors can manage Master Classes."),onBack:()=>a(-1),backPath:n?"/dashboard/admin/master-classes":"/dashboard/instructor",backLabel:n?"Back to Master Classes":s("common.backToDashboard","Back to Instructor Dashboard")});if(C)return C.status===403?e.jsx(_e,{icon:e.jsx(Ee,{className:"h-7 w-7 text-warning"}),title:n?"Access Denied":s("edit.accessDenied","Access Denied"),message:n?"This Master Class can only be edited by authorized administrators.":s("edit.ownerOnly","You don't have permission to edit this Master Class. Only its owner can make changes."),onBack:()=>a(-1),backPath:n?"/dashboard/admin/master-classes":"/dashboard/instructor",backLabel:n?"Back to Master Classes":s("common.backToDashboard","Back to Instructor Dashboard")}):C.status===404?e.jsx(_e,{icon:e.jsx(ye,{className:"h-7 w-7 text-warning"}),title:n?"Class Not Found":s("edit.notFound","Class Not Found"),message:n?"This MasterClass doesn't exist or has been removed.":s("edit.notFoundDescription","This Master Class doesn't exist or has been removed."),onBack:()=>a(-1),backPath:n?"/dashboard/admin/master-classes":"/dashboard/instructor",backLabel:n?"Back to Master Classes":s("common.backToDashboard","Back to Instructor Dashboard")}):e.jsx(_e,{icon:e.jsx(ye,{className:"h-7 w-7 text-warning"}),title:n?"Something went wrong":s("edit.error","Something went wrong"),message:C.message||(n?"Failed to load this MasterClass.":s("edit.loadError","Failed to load this Master Class.")),onBack:()=>a(-1),backPath:n?"/dashboard/admin/master-classes":"/dashboard/instructor",backLabel:n?"Back to Master Classes":s("common.backToDashboard","Back to Instructor Dashboard")});if(!f)return null;const x=!Q||j.isPending,ke=r===_.length-1;return e.jsxs("div",{className:"max-w-5xl mx-auto px-6 py-8 pb-12 space-y-6",children:[e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>a(Ne),className:"inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground mb-3",children:[e.jsx(qe,{className:"h-4 w-4"}),o]}),e.jsxs("div",{className:"flex items-start justify-between gap-3",children:[e.jsxs("h1",{className:"text-2xl font-bold flex items-center gap-2",children:[e.jsx(yt,{className:"h-6 w-6"}),n?"Edit Master Class":s("edit.title","Edit Master Class")]}),e.jsx("span",{className:`text-xs px-2 py-0.5 rounded-full font-medium whitespace-nowrap mt-1.5 ${Ct[f.status]??"bg-muted text-muted-foreground"}`,children:n?xe(f.status):s(`statuses.${f.status}`,xe(f.status))})]}),e.jsx("p",{className:"text-muted-foreground",children:n?"Update this Master Class on behalf of its submitter. Changes are recorded in the activity history.":s("edit.description","Refine your class details step by step and save your changes.")})]}),!Q&&e.jsx(G,{className:"border-warning/30 bg-warning/10",children:e.jsxs(H,{
1className:"p-4 flex items-start gap-3",children:[e.jsx(Ee,{className:"h-5 w-5 text-warning mt-0.5 shrink-0"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:n?"This class can't be edited right now":s("edit.lockedTitle","This class can't be edited right now")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n?e.jsxs(e.Fragment,{children:["Classes that are mid-review or disabled can't be edited. It's currently ",e.jsx("strong",{children:xe(f.status)}),"."]}):s("edit.lockedDescription","Classes under review or disabled can't be edited. Current status: {{status}}.",{status:s(`statuses.${f.status}`,xe(f.status))})})]})]})}),f.status==="changes_requested"&&f.reviewer_notes&&e.jsx(G,{className:"border-info/30 bg-info/10",children:e.jsxs(H,{className:"p-4",children:[e.jsx("p",{className:"font-medium mb-1",children:n?"Reviewer feedback":s("edit.reviewerFeedback","Reviewer feedback")}),e.jsx("p",{className:"text-sm text-muted-foreground whitespace-pre-wrap",children:f.reviewer_notes})]})}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-[260px_1fr] gap-6",children:[e.jsx(Xe,{steps:_,step:r,onStepSelect:O,stepCompletions:ge}),e.jsx(G,{children:e.jsxs(H,{className:"p-5 md:p-6 space-y-5",children:[e.jsxs("div",{className:"pb-2 border-b",children:[e.jsx("p",{className:"text-xs font-semibold text-primary mb-0.5",children:n?`${String(r+1).padStart(2,"0")} â Step ${r+1} of ${_.length}`:s("wizard.progress","{{current}} â Step {{step}} of {{total}}",{current:String(r+1).padStart(2,"0"),step:r+1,total:_.length})}),e.jsx("h3",{className:"text-lg font-semibold",children:n?_[r].title:s(`wizard.steps.${r}.title`,_[r].title)}),e.jsx("p",{className:"text-sm text-muted-foreground",children:n?_[r].description:s(`wizard.steps.${r}.description`,_[r].description)})]}),r===0&&e.jsx(Ze,{form:w,onChange:V,titleError:B,disabled:x}),r===1&&e.jsx(et,{audiences:ee,setAudiences:I,outcomes:Z,setOutcomes:b,prerequisites:Y,setPrerequisites:v,disabled:x}),r===2&&e.jsx(tt,{modules:P,onChange:ie,disabled:x}),r===3&&e.jsx(st,{form:w,onChange:V,sessionSchedule:oe,setSessionSchedule:u=>{le(u),T.session_schedule&&$(S=>{const A={...S};return delete A.session_schedule,A})},cohortPricing:L,onCohortPricingChange:u=>{de(u),Object.keys(T).some(S=>["pricing","price","currency","early_bird_price","early_bird_deadline"].includes(S))&&$(S=>{const A={...S};return["pricing","price","currency","early_bird_price","early_bird_deadline"].forEach(Ce=>delete A[Ce]),A})},disabled:x,fieldErrors:T}),r===4&&e.jsx(it,{value:ce,onChange:ue,isPaid:!L.is_free,disabled:x,fieldErrors:T,confirmRequiredChanges:!0}),r===5&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{children:[e.jsx("h4",{className:"text-sm font-semibold mb-1",children:n?"What's included":s("inclusions.title","What's included")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:n?"Materials, perks, or resources participants receive.":s("inclusions.description","Materials, benefits, or resources participants receive.")}),e.jsx(at,{items:l,onChange:te,disabled:x,placeholder:n?"e.g. Downloadable templates":s("inclusions.placeholder","e.g. Downloadable templates"),placeholderAr:n?"Ø¨Ø§ÙØ¹Ø±Ø¨ÙØ© (Ø§Ø®ØªÙØ§Ø±Ù)":s("common.optionalArabic","Arabic (optional)"),addLabel:n?"Add inclusion":s("inclusions.add","Add inclusion"),emptyLabel:n?"No inclusions yet.":s("inclusions.empty","No inclusions yet.")})]}),e.jsxs("div",{className:"pt-4 border-t",children:[e.jsx("h4",{className:"text-sm font-semibold mb-1",children:n?"Eligibility":s("eligibility.title","Eligibility")}),e.jsx("p",{className:"text-sm text-muted-foreground mb-3",children:n?"Add structured rules so the right people are matched to this class. Leave empty to keep it open to everyone.":s("eligibility.description","Add structured rules so the right learners are matched to this class. Leave this empty to keep enrollment open to everyone.")}),e.jsx(rt,{criteria:z,onChange:ae,enforcement:re,onEnforcementChange:ne,disabled:x})]})]}),r===6&&e.jsx(nt,{form:w,onChange:V,faqs:F,setFaqs:se,disabled:x}),r===7&&e.jsx(ot,{form:w,counts:{outcomes:Z.filter(u=>u.value.trim()).length,audiences:ee.filter(u=>u.value.trim()).length,prerequisites:Y.filter(u=>u.value.trim()).length,inclusions:l.filter(u=>u.value.trim()).length,faqs:F.filter(u=>u.question.trim()&&u.answer.trim()).length,modules:P.filter(u=>
1u.module_title.trim()).length,eligibility:z.map(Se).filter(Boolean).length},footnote:n?"Review the Master Class details before saving changes on behalf of the submitter.":s("edit.reviewFootnote","Review your class details and save your changes. When you're ready, submit it for review."),stepCompletions:ge,onGoToStep:O,landingSectionVisibility:me,onLandingSectionVisibilityChange:he}),e.jsxs("div",{className:"flex items-center justify-between gap-3 pt-4 border-t",children:[e.jsxs(N,{type:"button",variant:"ghost",disabled:r===0||j.isPending,onClick:()=>X(u=>Math.max(0,u-1)),children:[e.jsx(qe,{className:"h-4 w-4 me-2"}),n?"Back":s("common.back","Back")]}),ke?e.jsxs("div",{className:"flex flex-col items-end gap-2",children:[pe&&e.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-warning/30 bg-warning/10 p-3 text-start w-full",children:[e.jsx(ye,{className:"h-4 w-4 text-warning mt-0.5 shrink-0"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:n?"This class is live. Saving your changes publishes them to the public class page immediately â there's no additional review.":s("edit.liveNotice","This class is live. Saving changes publishes them to the public class page immediately, without another review.")})]}),e.jsxs("div",{className:"flex flex-wrap items-center justify-end gap-3",children:[e.jsx(N,{type:"button",onClick:je,disabled:x||!w.title.trim(),children:j.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-4 w-4 me-2 animate-spin"}),n?"Saving...":s("common.saving","Savingâ¦")]}):e.jsxs(e.Fragment,{children:[e.jsx(wt,{className:"h-4 w-4 me-2"}),n?"Save Changes":s("edit.save","Save Changes")]})}),q&&e.jsxs(N,{type:"button",variant:"secondary",disabled:j.isPending||y.isPending||!w.title.trim()||K.length>0,onClick:()=>D(!0),children:[e.jsx(De,{className:"h-4 w-4 me-2"}),s("edit.submit","Submit for review")]})]}),q&&K.length>0&&e.jsx("p",{className:"text-xs text-warning text-end",children:s("edit.completeBeforeSubmit","Complete before submitting: {{steps}}",{steps:K.map(u=>s(`wizard.stepNames.${u}`,u)).join(", ")})})]}):e.jsxs(N,{type:"button",onClick:()=>O(r+1),disabled:j.isPending,children:[n?"Next":s("common.next","Next"),e.jsx(jt,{className:"h-4 w-4 ms-2"})]})]})]})})]}),W.length>0&&e.jsx(Ft,{warnings:W}),!n&&e.jsx(Ve,{open:E,onOpenChange:u=>!y.isPending&&D(u),children:e.jsxs(Ke,{children:[e.jsxs(Ue,{children:[e.jsx(Ge,{children:s("edit.submitDialog.title","Submit for review?")}),e.jsx(He,{children:s("edit.submitDialog.description","Your class will be sent to the team for review. You won't be able to edit it while it's under review. Save any pending changes first; only saved details are reviewed.")})]}),e.jsxs(Je,{children:[e.jsx(N,{variant:"outline",onClick:()=>D(!1),disabled:y.isPending,children:s("common.cancel","Cancel")}),e.jsx(N,{onClick:()=>y.mutate(),disabled:y.isPending,children:y.isPending?e.jsxs(e.Fragment,{children:[e.jsx(ve,{className:"h-4 w-4 me-2 animate-spin"}),s("common.submitting","Submittingâ¦")]}):e.jsxs(e.Fragment,{children:[e.jsx(De,{className:"h-4 w-4 me-2"}),s("edit.submit","Submit for review")]})})]})]})}),!n&&e.jsx(Pt,{cohorts:J.data?.data??[],isLoading:J.isLoading})]})}function Ft({warnings:d}){const{copy:s}=we();return e.jsxs("div",{role:"alert",className:"rounded-lg border border-warning/40 bg-warning/10 p-4 space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ye,{className:"h-4 w-4 text-warning shrink-0"}),e.jsx("p",{className:"text-sm font-semibold text-warning",children:s("edit.warnings.title","Session schedule notices")})]}),e.jsx("ul",{className:"space-y-1.5 ps-6",children:d.map((a,g)=>e.jsxs("li",{className:"text-sm text-muted-foreground list-disc",children:[e.jsxs("span",{className:"font-medium text-foreground",children:[a.code==="out_of_order"?s("edit.warnings.outOfOrder","Out of order"):s("edit.warnings.largeGap","Large gap"),":"," "]}),s(`edit.warnings.${a.code}Description`,a.message)]},g))}),e.jsx("p",{className:"text-xs text-muted-foreground ps-6",children:s("edit.warnings.help","These are advisory notices; your changes were saved successfully.")})]})}function Pt({cohorts:d,isLoading:s}){const{copy:a,locale:g}=we();
1return e.jsx(G,{children:e.jsxs(H,{className:"p-5 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-lg font-semibold",children:a("edit.cohorts.title","Roster & Sessions")}),e.jsx("p",{className:"text-sm text-muted-foreground",children:a("edit.cohorts.description","Schedule, pricing, and enrollment deadline are set above. Open the cohort below to manage its roster, attendance, and reports.")})]}),s?e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground",children:[e.jsx(ve,{className:"h-4 w-4 animate-spin"}),a("common.loading","Loadingâ¦")]}):d.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:a("edit.cohorts.empty","This cohort opens for enrollment automatically once the class is published.")}):e.jsx("ul",{className:"divide-y divide-border rounded-md border",children:d.map(h=>e.jsxs("li",{className:"flex items-center justify-between gap-3 p-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:h.name}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[e.jsx("span",{dir:"ltr",children:h.start_date?new Date(h.start_date).toLocaleDateString(g):a("edit.cohorts.noStartDate","No start date")})," · ",e.jsx("span",{children:a(`statuses.${h.status}`,h.status.replace(/_/g," "))})]})]}),e.jsx(N,{size:"sm",variant:"outline",asChild:!0,children:e.jsx(Oe,{to:`/dashboard/instructor/cohorts/${h.id}`,children:a("common.manage","Manage")})})]},h.id))})]})})}function _e({icon:d,title:s,message:a,onBack:g,backPath:h,backLabel:k}){return e.jsxs("div",{className:"max-w-2xl mx-auto p-6 space-y-6",children:[e.jsxs("button",{onClick:g,className:"inline-flex items-center gap-1 text-sm text-muted-foreground hover:text-foreground",children:[e.jsx(qe,{className:"h-4 w-4"}),"Back"]}),e.jsx(G,{className:"border-warning/30 bg-warning/10",children:e.jsxs(H,{className:"p-8 flex flex-col items-center text-center gap-4",children:[e.jsx("div",{className:"p-3 rounded-full bg-warning/10",children:d}),e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-bold mb-1",children:s}),e.jsx("p",{className:"text-muted-foreground max-w-sm",children:a})]}),e.jsx(N,{asChild:!0,children:e.jsx(Oe,{to:h,children:k})})]})})]})}export{Ht 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.