1import{j as e,V as $,a as b,T as t,G as g,q as A,s as D,aJ as he,o as ne,E as ie,v as xe,n as v,h as me,A as pe,y as ge,z as je,I as te,r as z,$ as fe,Q as ye,R as be,B as Se,w as ve,aK as Y}from"./vendor-core-1-1ujdHh.js";import{g as Ce,u as re,a as ae,b as ze,c as we,i as Ie,C as ke,S as Me,d as Pe,e as Ae}from"./SessionPlanner-B0hCsJAY.js";import{a5 as Te,at as Ee,S as We,c9 as oe,C as Ne,aH as Oe,cv as Re,cw as $e,cx as De,cy as Z,p as X,u as Le,cz as He,a9 as Be}from"./useInstructorPractice-BBe_zbNF.js";import{c as Fe,e as U,t as G,f as Ve,g as _e,a as le}from"./SkeletonList-BAgg_Ali.js";import{M as T}from"./MatDashCard-aKXTHttj.js";import{f as P,b as Ge,S as L,o as Ue,p as Qe}from"./formatCourseDuration-FFKBtf-G.js";import{C as H,d as ee}from"./licenseColors-8_zq41xT.js";import{T as B}from"./main-BCwBjubz.js";import{S as qe}from"./signature-w07Y8xW8.js";import{G as se}from"./useParallelPracticeConfig-6-OUqcLb.js";import{M as Je}from"./PracticeUnitsBadge-SChwvBTk.js";import{P as Ke}from"./useSectionPaymentOptions-BSVxO6yC.js";import{P as Ye}from"./ErrorModal-Ddo-5kyR.js";import{P as Ze}from"./useAcademy-Bpqf0a9F.js";import{r as Xe,a as ce}from"./ForgotPasswordPage-CdrhwfXe.js";import{u as es}from"./warning-Bgpy_Mn7.js";import"./actionIntent-COGs4cUm.js";import"./AnnouncementsPage-r21Q1r1e.js";import"./useInstructorsBySection-BfE50C5g.js";import"./sparkles-BHLWYoTR.js";import"./inbox-DZeaCDQX.js";import"./useCalendarDateRange-DMCugZ3m.js";import"./CalendarEvent-D5-aJk6l.js";import"./door-open-BrFtT_Kl.js";import"./useTaxLabel-Mc-1dZ0q.js";import"./balanceTypes-DdEonziE.js";import"./navigateFromEvent-DEB2Ge8X.js";import"./useStudentBalanceSummary-BKlGLd9-.js";import"./BackToLoginButton-RKOTVI4o.js";import"./CapacityBars-CxW4pM90.js";/** 2 * @license lucide-react v1.21.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ss=[["path",{d:"M12 10a2 2 0 0 0-2 2c0 1.02-.1 2.51-.26 4",key:"1nerag"}],["path",{d:"M14 13.12c0 2.38 0 6.38-1 8.88",key:"o46ks0"}],["path",{d:"M17.29 21.02c.12-.6.43-2.3.5-3.02",key:"ptglia"}],["path",{d:"M2 12a10 10 0 0 1 18-6",key:"ydlgp0"}],["path",{d:"M2 16h.01",key:"1gqxmh"}],["path",{d:"M21.8 16c.2-2 .131-5.354 0-6",key:"drycrb"}],["path",{d:"M5 19.5C5.5 18 6 15 6 12a6 6 0 0 1 .34-2",key:"1tidbn"}],["path",{d:"M8.65 22c.21-.66.45-1.32.57-2",key:"13wd9y"}],["path",{d:"M9 6.8a6 6 0 0 1 9 5.2v2",key:"1fr1j5"}]],ns=Fe("fingerprint-pattern",ss),is={simple:"Simple",single_pair:"Entrada/Salida",multiple_pairs:"Múltiples entradas"},ts={check:"Checkbox",signature:"Firma",biometric:"Biométrico"};function rs(s){switch(s){case L.REQUEST:return"Por solicitud";case L.DIRECT:return"Inscripción directa";default:return"No permitida"}}function de(s){const n=s.end.getTime()-s.start.getTime(),r=s.breaks.reduce((i,l)=>i+(l.end.getTime()-l.start.getTime()),0);return Math.round((n-r)/6e4)}function Q({icon:s,title:n,onEdit:r}){return e.jsxs(g,{justify:"space-between",align:"center",px:24,pt:20,pb:12,children:[e.jsxs(g,{gap:8,align:"center",children:[s,e.jsx(t,{fw:700,size:"md",children:n})]}),r&&e.jsx(me,{label:"Editar",withArrow:!0,children:e.jsx(pe,{variant:"subtle",color:"gray",onClick:r,"aria-label":"Editar",children:e.jsx(Ye,{size:14})})})]})}function V({state:s,label:n,hint:r}){const i=s==="ok"?"var(--mantine-color-brand-6)":U("alert"),l=s==="ok"?H:B;return e.jsxs(g,{gap:10,wrap:"nowrap",align:"flex-start",style:{padding:"8px 0"},children:[e.jsx(l,{size:16,strokeWidth:2.6,color:i,style:{flexShrink:0,marginTop:2}}),e.jsxs(b,{gap:1,children:[e.jsx(t,{size:"sm",fw:600,children:n}),e.jsx(t,{size:"xs",c:"dimmed",style:{lineHeight:1.35},children:r})]})]})}function as({permitsCount:s,sectionName:n,sessionsCount:r,totalEffectiveMinutes:i,targetMinutes:l,enrolledCount:u,capacity:h}){const o=r>0&&i===l,p=u>0,j=h!==null?Math.max(0,h-u):null,m=o&&p,y=m?H:B,f=m?"brand":"orange";return e.jsx(T,{padding:0,mb:"lg",style:{overflow:"hidden"},children:e.jsxs(b,{gap:0,p:24,children:[e.jsx(t,{size:"xs",fw:700,tt:"uppercase",c:"dimmed",style:{letterSpacing:.4},children:"Estado del curso"}),e.jsxs(g,{gap:12,wrap:"nowrap",align:"center",mt:12,children:[e.jsx("div",{style:{width:40,height:40,borderRadius:10,background:`var(--mantine-color-${f}-0)`,display:"inline-flex",alignItems:"center",justifyContent:"center",color:`var(--mantine-color-${f}-7)`,flexShrink:0},children:e.jsx(y,{size:22,strokeWidth:2.6})}),e.jsxs(b,{gap:2,children:[e.jsx(t,{size:"md",fw:700,children:m?"Listo para activar":"Casi listo"}),e.jsx(t,{size:"sm",c:"dimmed",children:m?"Revisa los detalles y activa el curso":"Revisa lo marcado antes de activar"})]})]}),e.jsx("div",{style:{borderTop:"1px solid var(--mantine-color-gray-2)",margin:"16px 0 4px"}}),e.jsx(V,{state:"ok",label:"Parámetros completos",hint:`${s} permisos · ${n}`}),e.jsx(V,{state:o?"ok":"warn",label:o?"Sesiones planificadas":"Revisa la duración total",hint:o?`${r} sesiones cubren las ${P(l)}`:`Las sesiones suman ${P(i)}, el curso prevé ${P(l)}`}),e.jsx(V,{state:p?"ok":"warn",label:p?`${u} alumnos inscritos`:"Sin alumnos inscritos",hint:p?j!==null?`${j} plazas libres`:"Sin lÃmite de plazas":"Puedes activar el curso y abrir inscripción"})]})})}function I({label:s,children:n,align:r="center"}){return e.jsxs(g,{gap:12,align:r,wrap:"nowrap",style:{minHeight:24,padding:"7px 0"},children:[e.jsx(t,{size:"xs",c:"dimmed",style:{width:140,flexShrink:0},children:s}),e.jsx("div",{style:{flex:1,minWidth:0},children:n})]})}function os({licenseName:s,phaseName:n}){return e.jsxs(g,{gap:6,wrap:"nowrap",style:{padding:"4px 10px 4px 4px",border:"1px solid var(--mantine-color-gray-3)",borderRadius:999,background:"white"},children:[e.jsx("div",{style:{minWidth:28,height:22,padding:"0 7px",background:"var(--mantine-color-brand-0)",color:"var(--mantine-color-brand-8)",fontSize:11,fontWeight:700,letterSpacing:.2,borderRadius:999,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:s}),e.jsx(t,{size:"xs",fw:500,children:n})]})}function ls({params:s,selectedLicensePhases:n,section:r,classroom:i,instructors:l,onEdit:u,classroomCapacityWarning:h}){const o=re(),p=s.instructorIds.map(x=>l.find(E=>E.id===x)).filter(x=>!!x),j=s.start&&s.end?`${A(s.start,"d MMM yyyy",{locale:D})}`:"â",m=s.start&&s.end?`${A(s.end,"d MMM yyyy",{locale:D})}`:"",y=s.start&&s.end?he(s.end,s.start)+1:0,f=s.attendanceMethod==="signature"?e.jsx(qe,{size:11}):s.attendanceMethod==="biometric"?e.jsx(ns,{size:11}):e.jsx(H,{size:11});return e.jsxs(T,{padding:0,style:{height:"100%"},children:[e.jsx(Q,{icon:e.jsx(Te,{size:16,color:"var(--mantine-color-gray-6)"}),title:"Parámetros",onEdit:u}),e.jsx("div",{style:{padding:"0 24px"},children:e.jsxs(g,{gap:12,wrap:"nowrap",style:{padding:"14px 16px",borderRadius:10,background:"var(--mantine-color-brand-0)"},children:[s.type===Ge.CAP&&e.jsx("div",{style:{padding:"6px 10px",minHeight:40,borderRadius:10,background:"white",display:"inline-flex",alignItems:"center",justifyContent:"center",color:"var(--mantine-color-brand-8)",fontSize:13,fontWeight:700,letterSpacing:.4,textTransform:"uppercase",boxShadow:"var(--app-elevation-raised)",flexShrink:0},children:"CAP"}),e.jsxs(b,{gap:2,style:{minWidth:0},children:[e.jsx(t,{fw:700,size:"sm",truncate:!0,children:s.name||"â"}),e.jsx(t,{size:"xs",fw:600,c:"brand.8",truncate:!0,children:(r==null?void 0:r.name)||"â"})]})]})}),e.jsx("div",{style:{borderTop:"1px solid var(--mantine-color-gray-2)",margin:"16px 24px 0"}}),e.jsxs(b,{gap:0,px:24,pb:20,children:[e.jsx(I,{label:"Permisos",align:"flex-start",children:n.length===0?e.jsx(t,{size:"sm",c:"dimmed",children:"â"}):e.jsx(g,{gap:6,wrap:"wrap",children:n.map(x=>e.jsx(os,{licenseName:x.licenseName,phaseName:x.phaseName},x.licensePhaseId))})}),e.jsx(I,{label:"Fechas",children:e.jsxs(g,{gap:6,align:"center",wrap:"nowrap",children:[e.jsx(t,{size:"sm",fw:600,children:j}),m&&e.jsxs(e.Fragment,{children:[e.jsx(Ee,{size:12,color:"var(--mantine-color-gray-6)"}),e.jsx(t,{size:"sm",fw:600,children:m})]}),y>0&&e.jsxs(t,{size:"xs",c:"dimmed",children:["· ",y," dÃas"]})]})}),e.jsx(I,{label:"Duración total",children:e.jsx(t,{size:"sm",fw:600,children:P(s.totalMinutes)})}),e.jsx(I,{label:"Modalidad",children:e.jsx(ne,{color:s.online?"blue":"brand",variant:"light",size:"sm",leftSection:s.online?e.jsx(se,{size:11}):e.jsx(Je,{size:11}),children:s.online?"Online":"Presencial"})}),e.jsx(I,{label:s.online?"Enlace":"Aula",align:"flex-start",children:s.online?e.jsxs(b,{gap:4,style:{minWidth:0},children:[e.jsx(We,{tone:"info",size:"sm",leftSection:e.jsx(se,{size:11}),children:"Enlace online"}),s.onlineLink&&e.jsx(t,{size:"xs",c:"dimmed",truncate:!0,children:s.onlineLink})]}):i?e.jsxs(b,{gap:2,children:[e.jsx(t,{size:"sm",fw:600,children:i.name}),e.jsx(t,{size:"xs",c:"dimmed",children:i.capacity!==null?`${i.capacity} plazas`:"Sin lÃmite"}),h&&e.jsxs(g,{gap:6,wrap:"nowrap",align:"center",mt:4,children:[e.jsx(B,{size:12,color:U("alert")}),e.jsx(t,{size:"xs",style:{color:G("alert")},children:h.message})]})]}):e.jsx(t,{size:"sm",c:"dimmed",children:"â"})}),p.length>0&&e.jsx(I,{label:"Profesores",align:"flex-start",children:e.jsx(b,{gap:6,children:p.map(x=>e.jsxs(g,{gap:8,wrap:"nowrap",children:[e.jsx(ie,{size:26,radius:"xl",color:ae(x.id),children:oe(x.name)}),e.jsx(t,{size:"sm",fw:600,children:x.name})]},x.id))})}),s.tracksAttendance&&e.jsx(I,{label:"Asistencia",children:e.jsxs(g,{gap:6,align:"center",wrap:"nowrap",children:[e.jsx(t,{size:"sm",children:is[s.attendanceModel]}),e.jsx(t,{size:"sm",c:"dimmed",children:"·"}),f,e.jsx(t,{size:"sm",children:ts[s.attendanceMethod]})]})}),e.jsx(I,{label:"Calendario de alumnos",children:e.jsx(t,{size:"sm",children:s.studentAcce
6ss===L.HIDDEN?"Sin publicar":"Publicado"})}),s.studentAccess!==L.HIDDEN&&e.jsx(I,{label:"Inscripción",children:e.jsx(t,{size:"sm",children:rs(s.studentAccess)})}),o&&e.jsx(I,{label:"Web",children:e.jsx(t,{size:"sm",children:s.published?"Anunciado":"Sin anunciar"})})]})]})}function cs({sessions:s,totalEffectiveMinutes:n,targetMinutes:r,onEdit:i}){const l=n===r,u={padding:"12px 14px",borderRadius:10,border:"1px solid var(--mantine-color-gray-2)"};return e.jsxs(T,{padding:0,style:{height:"100%"},children:[e.jsx(Q,{icon:e.jsx(Ne,{size:16,color:"var(--mantine-color-gray-6)"}),title:"Sesiones",onEdit:i}),e.jsxs("div",{style:{padding:"0 24px 20px"},children:[e.jsxs(xe,{cols:{base:1,sm:3},spacing:12,mb:14,children:[e.jsxs("div",{style:{...u,background:"var(--mantine-color-gray-0)"},children:[e.jsx(t,{size:"xs",fw:700,tt:"uppercase",c:"dimmed",style:{letterSpacing:.4},children:"Sesiones"}),e.jsx(t,{fz:26,fw:700,style:{letterSpacing:-1,lineHeight:1.1},children:s.length})]}),e.jsxs("div",{style:{...u,background:"var(--mantine-color-gray-0)"},children:[e.jsx(t,{size:"xs",fw:700,tt:"uppercase",c:"dimmed",style:{letterSpacing:.4},children:"Planificadas"}),e.jsx(t,{fz:16,fw:700,c:"dimmed",style:{lineHeight:1.4},children:P(n)})]}),e.jsxs("div",{style:{...u,background:l?"var(--mantine-color-brand-0)":_e("alert"),borderColor:l?"var(--mantine-color-brand-2)":Ve("alert")},children:[e.jsxs(g,{gap:4,align:"center",wrap:"nowrap",children:[l?e.jsx(H,{size:11,color:"var(--mantine-color-brand-8)",strokeWidth:2.6}):e.jsx(B,{size:11,color:G("alert"),strokeWidth:2.6}),e.jsx(t,{size:"xs",fw:700,tt:"uppercase",style:{color:l?"var(--mantine-color-brand-8)":G("alert"),letterSpacing:.4},children:l?"cubre":"revisar"})]}),e.jsxs(t,{size:"xs",c:l?"brand.8":"orange.8",children:["Total previsto ",P(r)]})]})]}),s.length===0?e.jsx(t,{size:"sm",c:"dimmed",ta:"center",py:"md",children:"Sin sesiones planificadas"}):e.jsx(b,{gap:4,children:s.map(h=>{const o=A(h.start,"EEE d",{locale:D}),p=A(h.start,"MMM",{locale:D}),j=`${A(h.start,"HH:mm")}â${A(h.end,"HH:mm")}`,m=de(h);return e.jsxs(g,{gap:8,wrap:"nowrap",style:{padding:"9px 10px",borderRadius:8},children:[e.jsxs(g,{gap:4,wrap:"nowrap",style:{minWidth:70},children:[e.jsx(t,{size:"xs",fw:700,children:o}),e.jsx(t,{size:"xs",fw:500,c:"dimmed",children:p})]}),e.jsx(t,{size:"xs",c:"gray.7",style:{flex:1},children:j}),e.jsx(ne,{color:"gray",size:"xs",variant:"light",children:P(m)})]},h.id)})})]})]})}function ds({enrolled:s,capacity:n}){const u=2*Math.PI*38,h=n!==null&&n>0?Math.min(1,s/n):0,o=u*(1-h),j=n!==null&&s>=n?U("poor"):"var(--mantine-color-brand-6)";return e.jsxs("div",{style:{position:"relative",width:84,height:84,flexShrink:0},children:[e.jsxs("svg",{width:84,height:84,style:{transform:"rotate(-90deg)"},children:[e.jsx("circle",{cx:84/2,cy:84/2,r:38,stroke:"var(--mantine-color-gray-2)",strokeWidth:8,fill:"none"}),n!==null&&e.jsx("circle",{cx:84/2,cy:84/2,r:38,stroke:j,strokeWidth:8,fill:"none",strokeLinecap:"round",strokeDasharray:u,strokeDashoffset:o})]}),e.jsxs("div",{style:{position:"absolute",inset:0,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[e.jsx(t,{fz:22,fw:700,style:{letterSpacing:-1,lineHeight:1},children:s}),n!==null&&e.jsxs(t,{size:"xs",fw:600,c:"dimmed",children:["de ",n]})]})]})}function us({enrolledStudents:s,capacity:n,onEdit:r}){const i=s.length,l=n!==null?Math.max(0,n-i):null,u=s.slice(0,8),h=s.length>8;return e.jsxs(T,{padding:0,style:{height:"100%"},children:[e.jsx(Q,{icon:e.jsx(Oe,{size:16,color:"var(--mantine-color-gray-6)"}),title:"Alumnos inscritos",onEdit:r}),e.jsxs("div",{style:{padding:"0 24px 20px"},children:[e.jsxs(g,{gap:16,wrap:"nowrap",align:"center",children:[e.jsx(ds,{enrolled:i,capacity:n}),e.jsxs(b,{gap:2,children:[e.jsx(t,{size:"xs",fw:700,tt:"uppercase",c:"dimmed",style:{letterSpacing:.4},children:"Plazas"}),e.jsx(t,{size:"sm",fw:700,children:n===null?"Sin lÃmite":`${l} libres`})]})]}),e.jsx("div",{style:{borderTop:"1px solid var(--mantine-color-gray-2)",margin:"16px 0 12px"}}),i===0?e.jsxs(b,{gap:8,align:"center",style:{padding:"20px 16px",background:"var(--mantine-color-gray-0)",borderRadius:10,border:"1px dashed var(--mantine-color-gray-3)",textAlign:"center"},children:[e.jsx(t,{size:"xs",fw:600,c:"gray.7",children:"Sin alumnos inscritos"}),e.jsx(t,{size:"xs",c:"dimmed",style:{lineHeight:1.4},children:"Al activar el curso, se abrirá a inscripciones según el modo elegido."}),r&&e.jsx(v,{size:"xs",variant:"light",color:"brand",leftSection:e.jsx(Ke,{size:12}),onClick:r,children:"Inscribir ahora"})]}
6):e.jsxs(e.Fragment,{children:[e.jsx(t,{size:"xs",fw:700,tt:"uppercase",c:"dimmed",mb:8,style:{letterSpacing:.4},children:"Lista"}),e.jsx(b,{gap:0,children:u.map(o=>e.jsxs(g,{gap:10,wrap:"nowrap",style:{padding:"7px 0"},children:[e.jsx(ie,{size:28,radius:"xl",color:ae(o.studentId),children:oe(o.name)}),e.jsxs(b,{gap:0,style:{minWidth:0},children:[e.jsx(t,{size:"xs",fw:600,truncate:!0,children:o.name}),e.jsxs(t,{size:"xs",c:"dimmed",truncate:!0,children:[o.enrollmentCode,o.dni?` · ${o.dni}`:""]})]})]},o.enrollmentId))}),h&&r&&e.jsxs(v,{fullWidth:!0,variant:"subtle",size:"xs",color:"brand",onClick:r,mt:8,children:["Ver todos los inscritos (",s.length,")"]})]})]})]})}function hs({params:s,selectedLicensePhases:n,sessions:r,enrolledStudents:i,sections:l,classrooms:u,instructors:h,onEdit:o}){const p=l.find(f=>f.id===s.sectionId),j=u.find(f=>f.id===s.classroomId),m=Ce({online:s.online,capacity:s.capacity,classroomId:s.classroomId},u),y=r.reduce((f,x)=>f+de(x),0);return e.jsxs(e.Fragment,{children:[e.jsx(as,{permitsCount:new Set(n.map(f=>f.licenseId)).size,sectionName:(p==null?void 0:p.name)??"â",sessionsCount:r.length,totalEffectiveMinutes:y,targetMinutes:s.totalMinutes,enrolledCount:i.length,capacity:s.capacity}),e.jsxs($,{gutter:"lg",children:[e.jsx($.Col,{span:{base:12,md:4},children:e.jsx(ls,{params:s,selectedLicensePhases:n,section:p,classroom:j,instructors:h,onEdit:o?()=>o(0):void 0,classroomCapacityWarning:m})}),e.jsx($.Col,{span:{base:12,md:4},children:e.jsx(cs,{sessions:r,totalEffectiveMinutes:y,targetMinutes:s.totalMinutes,onEdit:o?()=>o(1):void 0})}),e.jsx($.Col,{span:{base:12,md:4},children:e.jsx(us,{enrolledStudents:i,capacity:s.capacity,onEdit:o?()=>o(2):void 0})})]})]})}function xs(){const s=ge(),{showToast:n}=ce();return je({mutationFn:r=>le("/administrator/courses",{method:"POST",body:JSON.stringify(r)}),onSuccess:()=>{Re(s)},onError:r=>{const i=Xe(r);n({title:i.title||"Error",description:i.message,variant:i.variant||"destructive"})}})}function ms({params:s,sessions:n,enrolledStudents:r}){const i=te(),{showToast:l,showWarningToast:u}=ce(),[h,o]=z.useState(!1),[p,j]=z.useState(null),[m,y]=z.useState(null),f=re(),x=ze(),{mutateAsync:E}=xs(),{mutateAsync:F}=$e(),{mutateAsync:W,isPending:N}=De(),k=(d,c)=>{l({title:"Curso guardado como borrador",description:c,variant:"warning"}),i(X.course(d))},M=async d=>{const c=[];let S=0;for(const a of r)try{await le(`/administrator/enrollments/${a.enrollmentId}/course-enrollments`,{method:"POST",body:JSON.stringify({courseId:d})}),S+=1}catch{c.push(a.name)}c.length>0&&u({title:`${S} alumnos inscritos, ${c.length} con error`,description:c.join(", ")})},O=async(d,c)=>{if(await M(d),c)try{await F({id:d,status:"active"})}catch{k(d,"No se pudo activar. Puedes activarlo desde la ficha del curso.");return}i(X.course(d))},R=()=>({creates:n.map(d=>({start:d.start.toISOString(),end:d.end.toISOString(),instructorIds:d.instructorIds,classroomId:d.classroomId,breaks:d.breaks.map(c=>({start:c.start.toISOString(),end:c.end.toISOString()}))})),updates:[],deleteIds:[]});return{submit:async d=>{o(!0);try{const S=(await E({name:s.name,type:s.type,sectionId:s.sectionId,start:ee(s.start),end:ee(s.end),totalMinutes:s.totalMinutes,capacity:s.capacity??void 0,online:s.online,onlineLink:s.onlineLink||void 0,classroomId:s.classroomId??void 0,capCenterId:s.capCenterId??void 0,licensePhaseIds:s.licensePhaseIds,instructorIds:s.instructorIds,color:s.color,description:s.description||void 0,publicName:s.publicName||void 0,code:s.code.trim()||void 0,enrollmentScope:s.enrollmentScope,studentAcce
6ss:s.studentAccess,attendanceModel:s.attendanceModel,attendanceMethod:s.attendanceMethod,tracksAttendance:s.tracksAttendance,...Qe(s.published,f),...Ue(s,x)})).id;if(n.length>0){const a=R();try{await W({courseId:S,payload:a})}catch(w){const C=Z(w);if(C){j(C),y({courseId:S,payload:a,activate:d});return}k(S,"Las sesiones no se pudieron guardar. Puedes reintentarlo desde la ficha del curso.");return}}await O(S,d)}catch{return}finally{o(!1)}},isSubmitting:h,isSyncingSessions:N,conflictViolations:p,forceSaveSessions:async()=>{if(!m)return;const{courseId:d,activate:c}=m;o(!0);try{await W({courseId:d,payload:{...m.payload,force:!0}}),j(null),y(null),await O(d,c)}catch(S){const a=Z(S);if(a){j(a);return}j(null),y(null),k(d,"Las sesiones no se pudieron guardar. Puedes reintentarlo desde la ficha del curso.")}finally{o(!1)}},dismissConflicts:()=>{if(!m)return;const{courseId:d}=m;j(null),y(null),k(d,"Las sesiones no se pudieron guardar. Puedes reintentarlo desde la ficha del curso.")}}}function ps({currentStep:s,totalSteps:n,label:r}){const i=(s+1)/n*100;return e.jsxs(b,{gap:6,mb:"md",children:[e.jsxs(t,{size:"sm",fw:600,children:["Paso ",s+1," de ",n," · ",r]}),e.jsx(fe,{value:i,color:"brand",size:"sm",radius:"xl"})]})}const _=[{label:"Configuración del curso",description:"Configura el curso"},{label:"Planificar sesiones",description:"Añade sesiones al calendario"},{label:"Inscribir alumnos",description:"Inscribe alumnos al curso"},{label:"Resumen final",description:"Revisa y activa el curso"}];function Us(){const s=te(),[n,r]=z.useState(0),[i,l]=z.useState(we),[u,h]=z.useState([]),[o,p]=z.useState([]),{data:j=[]}=Le(),{data:m=[]}=He(),{data:y=[]}=Be(),{data:f=[]}=es(),x=z.useMemo(()=>y.map(a=>({id:a.id,name:a.text})),[y]),E=z.useMemo(()=>x.filter(a=>i.instructorIds.includes(a.id)),[x,i.instructorIds]),F=z.useMemo(()=>Object.fromEntries(m.map(a=>[a.id,a.name])),[m]),W=z.useMemo(()=>Object.fromEntries(x.map(a=>[a.id,a.name])),[x]),N=i.licensePhaseIds.flatMap(a=>{for(const w of f){const C=w.phases.find(ue=>ue.id===a);if(C)return[{licensePhaseId:C.id,licenseId:C.licenseId,licenseName:C.licenseName,phaseId:C.phaseId,phaseName:C.phaseName}]}return[]}),{submit:k,isSubmitting:M,isSyncingSessions:O,conflictViolations:R,forceSaveSessions:q,dismissConflicts:J}=ms({params:i,sessions:u,enrolledStudents:o}),K=Ie(i),d=ye(),c=be(`(max-width: ${d.breakpoints.md})`),S=(a,w)=>c?e.jsxs(b,{gap:"sm",mb:"lg",children:[w,a]}):e.jsxs(g,{justify:"space-between",mb:"lg",children:[a,w]});return e.jsxs(e.Fragment,{children:[e.jsx(Ze,{title:"Nuevo curso",backButton:{label:"Volver",to:"/courses"},children:e.jsxs(Se,{pos:"relative",children:[e.jsx(ve,{visible:M}),c?e.jsx(ps,{currentStep:n,totalSteps:_.length,label:_[n].label}):e.jsx(Y,{active:n,size:"sm",mb:"md",children:_.map(a=>e.jsx(Y.Step,{label:a.label,description:a.description},a.label))}),n===0&&S(e.jsx(v,{variant:"subtle",color:"gray",fullWidth:c,onClick:()=>s("/courses"),children:"Cancelar"}),e.jsx(v,{color:"brand",fullWidth:c,disabled:!K,onClick:()=>r(1),children:c?"Siguiente â":"Siguiente: planificar sesiones â"})),n===1&&S(e.jsx(v,{variant:"subtle",color:"gray",fullWidth:c,onClick:()=>r(0),children:"â Atrás"}),e.jsx(v,{color:"brand",fullWidth:c,onClick:()=>r(2),children:"Alumnos â"})),n===2&&S(e.jsx(v,{variant:"subtle",color:"gray",fullWidth:c,onClick:()=>r(1),children:"â Atrás"}),e.jsx(v,{color:"brand",fullWidth:c,onClick:()=>r(3),children:"Ver resumen â"})),n===3&&S(e.jsx(v,{variant:"subtle",color:"gray",fullWidth:c,onClick:()=>r(2),children:"â Editar alumnos"}),c?e.jsxs(e.Fragment,{children:[e.jsx(v,{color:"brand",fullWidth:!0,loading:M,onClick:()=>k(!0),children:"Activar curso"}),e.jsx(v,{variant:"light",color:"brand",fullWidth:!0,loading:M,onClick:()=>k(!1),children:"Guardar como borrador"})]}):e.jsxs(g,{gap:"sm",children:[e.jsx(v,{variant:"light",color:"brand",loading:M,onClick:()=>k(!1),children:"Guardar como borrador"}),e.jsx(v,{color:"brand",loading:M,onClick:()=>k(!0),children:"Activar curso"})]})),n===0&&e.jsx(ke,{value:i,onChange:l}),n===1&&e.jsx(T,{children:i.start&&i.end&&i.classroomId?e.jsx(Me,{sessions:u,onChange:h,courseStart:i.start,courseEnd:i.end,totalMinutes:i.totalMinutes,courseInstructors:E,sectionId:i.sectionId,color:i.color,courseClassroomId:i.classroomId}):null}),n===2&&e.jsx(T,{children:e.jsx(Pe,{enrolledStudents:o,onEnroll:a=>p(w=>[...w,{enrollmentId:a.id,enrollmentCode:a.code,studentId:a.studentId,name:a.name,dni:a.dni,license:a.license,phase:a.phase,enrolledAt:null}]),onRemove:a=>p(w=>w.filter(C=>C.enrollmentId!==a.enrollmentId)),maxCapacity:i.capacity,licensePhases:N,enrollmentScope:i.enrollmentScope,sectionId:i.sectionId,pending:[],onApprove:()=>{},onReject:()=>{}})}),n===3&&e.jsx(hs,{params:i,selectedLicensePhases:N,sessions:u,enrolledStudents:o,sections:j,classrooms:m,instructors:x,onEdit:r})]})}),e.jsx(Ae,{violations:R??[],opened:R!==null,onClose:J,onForce:q,loading:O,classroomNameById:F,instructorNameById:W})]})}
6export{Us as NewCourseWizard};
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.