1"use strict";(self.webpackChunkstudent_management_app=self.webpackChunkstudent_management_app||[]).push([[1880],{674:(e,t,s)=>{s.d(t,{CR:()=>m,PE:()=>f,Sc:()=>u,aw:()=>p,jT:()=>n,oQ:()=>b,s$:()=>v,s1:()=>g,vl:()=>h});const a=["traditionalCnaTuition","hcaCnaBridgeTuition","courseFee","accommodationFee","narRegistrationFee","stateExamRegistrationFee","stateExamFee"],n=Object.freeze({traditionalCnaTuition:1205,hcaCnaBridgeTuition:905,courseFee:1205,accommodationFee:500,narRegistrationFee:120,stateExamRegistrationFee:130,stateExamFee:170}),r=Object.freeze([{id:"cna-traditional",name:"CNA Traditional",description:"Complete 108-hour nursing assistant training program.",hours:108,tuition:1205,enabled:!0},{id:"hca-cna-bridge",name:"HCA\u2013CNA Bridge",description:"40-hour bridge program for students with an active Washington HCA credential.",hours:40,tuition:905,enabled:!0}]),l=Object.freeze([{id:"nar-registration",name:"Nursing Assistant Registration",description:"Assistance with the Washington nursing assistant registration process.",price:120,enabled:!0},{id:"exam-registration",name:"CNA Exam Registration Service",description:"Assistance registering for the nursing assistant competency examination.",price:130,enabled:!0},{id:"exam-fee",name:"CNA Competency Exam Fee",description:"Nursing assistant certification examination charge.",price:170,enabled:!0}]),o=(e,t)=>{const s=Number(e);return Number.isFinite(s)&&s>=0?Math.round(100*s)/100:t},i=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=e.pricesCents||{},s={};return a.forEach(e=>{const a=Number(t[e]);s[e]=Number.isInteger(a)&&a>=0?a/100:n[e]}),{currency:e.currency||"USD",prices:s,programs:Array.isArray(e.programs)&&e.programs.length?e.programs.map(e=>({...e,tuition:o(null!=e.tuitionCents?e.tuitionCents/100:e.tuition,0)})):r.map(e=>({...e})),optionalServices:Array.isArray(e.optionalServices)?e.optionalServices.map(e=>({...e,price:o(null!=e.priceCents?e.priceCents/100:e.price,0)})):l.map(e=>({...e})),updatedAt:e.updatedAt||null}};let d=null,c=0;const u=async function(){let{fresh:e=!1}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!e&&d&&Date.now()-c<6e4)return d;const t=await fetch("/api/registration-pricing",{headers:{Accept:"application/json"},cache:e?"no-store":"default"});if(!t.ok)throw new Error("Registration pricing is temporarily unavailable.");const s=await t.json();return d=i(s.result||s),c=Date.now(),d},m=e=>(d=i(e),c=Date.now(),d),h=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.fromEntries(a.map(t=>[t,Math.round(100*o(e[t],0))]))},p=e=>({version:3,currency:(null===e||void 0===e?void 0:e.currency)||"USD",prices:{...n,...(null===e||void 0===e?void 0:e.prices)||{}},programs:((null===e||void 0===e?void 0:e.programs)||[]).map(e=>({...e})),optionalServices:((null===e||void 0===e?void 0:e.optionalServices)||[]).map(e=>({...e})),capturedAt:(new Date).toISOString()}),x={courseFee:"courseFee",accommodationFee:"accommodationFee",narRegistrationFee:"narRegistrationFee",stateExamRegistrationFee:"stateExamRegistrationFee",stateExamFee:"stateExamFee"},g=(e,t)=>{var s,a,r;const l=x[t]||t,o=null===e||void 0===e||null===(s=e.pricingSnapshot)||void 0===s||null===(a=s.prices)||void 0===a?void 0:a[t];if(Number.isFinite(Number(o))&&Number(o)>=0)return Number(o);const i=null===e||void 0===e||null===(r=e.fees)||void 0===r?void 0:r[l];return Number.isFinite(Number(i))&&Number(i)>=0?Number(i):"courseFee"===t?1100:n[t]||0},f=(e,t)=>{var s,a,n;return null!==(s=null===e||void 0===e||null===(a=e.programs)||void 0===a||null===(n=a.find(e=>e.id===t))||void 0===n?void 0:n.tuition)&&void 0!==s?s:"hca-cna-bridge"===t?e.hcaCnaBridgeTuition:e.traditionalCnaTuition},b=e=>{let{programs:t=[],optionalServices:s=[]}=e;return{programs:t.map(e=>({...e,tuitionCents:Math.round(100*o(e.tuition,0))})),optionalServices:s.map(e=>({...e,priceCents:Math.round(100*o(e.price,0))}))}},v=e=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:Number(e)%1===0?0:2}).format(Number(e)||0)},11594:(e,t,s)=>{s.d(t,{$o:()=>n,Y_:()=>l,hM:()=>r});const a=e=>String(e||"").trim().toLowerCase(),n=(e,t)=>{var s,n;const r=a("nar"===t?null===(s=e.narRegistration)||void 0===s?void 0:s.status:null===(n=e.cprApplication)||void 0===n?void 0:n.status);return["applied","submitted","approved","completed",..."nar"===t?["active"]:[]].includes(r)},r=(e,t)=>{var s,r;const l=a("nar"===t?null===(s=e.narRegistration)||void 0===s?void 0:s.status:null===(r=e.cprApplication)||void 0===r?void 0:r.status);return{text:{not_started:"Not Started",not_registered:"Not Registered",pending:"Pending",in_progress:"In Progress",applied:"Applied",submitted:"Submitted",approved:"Approved",completed:"Completed",active:"Active"}[l]||(l?"Unknown":"Not Started"),color:n(e,t)?"bg-green-100 text-green-800":"bg-gray-100 text-gray-800"}},l=e=>({active:"bg-green-50/50 hover:bg-green-100/60",completed:"bg-blue-50/50 hover:bg-blue-100/60",graduated:"bg-purple-50/50 hover:bg-purple-100/60",withdrawn:"bg-red-50/50 hover:bg-red-100/60",suspended:"bg-orange-50/50 hover:bg-orange-100/60",onleave:"bg-yellow-50/50 hover:bg-yellow-100/60"}[a(e)]||"bg-slate-50/50 hover:bg-slate-100/60")},29402:(e,t,s)=>{s.d(t,{B4:()=>l,Jp:()=>d,YM:()=>o,Yu:()=>c,cU:()=>u,q5:()=>r,tt:()=>i});var a=s(674);const n=["cancelled","void","refunded","reversed"],r=e=>{var t,s,n,r;const l=null!==(t=null!==(s=null===(n=e.paymentDetails)||void 0===n?void 0:n.totalAmount)&&void 0!==s?s:e.totalAmount)&&void 0!==t?t:0,o=parseFloat(l)||0,i=((null===(r=e.paymentDetails)||void 0===r?void 0:r.charges)||[]).reduce((e,t)=>
1{const s=String((null===t||void 0===t?void 0:t.status)||"pending").toLowerCase();return["cancelled","void","refunded","reversed","deleted"].includes(s)?e:e+(parseFloat(t.amount)||0)},0),d=(e=>{var t,s,n,r,l,o,i,d,c,u,m,h,p,x,g,f,b,v;const y=[];y.push({description:`${e.courseType||"CNA Program"} Tuition`,amount:(0,a.s1)(e,"courseFee")}),!0!==(null===(t=e.accommodationDetails)||void 0===t?void 0:t.required)||null!==(s=e.accommodationDetails)&&void 0!==s&&s.cancelled||y.push({description:"Accommodation Fee",amount:(0,a.s1)(e,"accommodationFee")}),!0!==(null===(n=e.optionalFees)||void 0===n?void 0:n.narRegistration)||null!==(r=e.cancelledServices)&&void 0!==r&&r.narRegistration||y.push({description:"NAR Registration",amount:(0,a.s1)(e,"narRegistrationFee")}),!0!==(null===(l=e.optionalFees)||void 0===l?void 0:l.stateExamRegistration)||null!==(o=e.cancelledServices)&&void 0!==o&&o.stateExamRegistration||y.push({description:"State Exam Registration",amount:(0,a.s1)(e,"stateExamRegistrationFee")}),!0!==(null===(i=e.optionalFees)||void 0===i?void 0:i.stateExamFee)||null!==(d=e.cancelledServices)&&void 0!==d&&d.stateExamFee||y.push({description:"State Exam Fee",amount:(0,a.s1)(e,"stateExamFee")}),!((null===(c=e.fees)||void 0===c?void 0:c.narRegistrationFee)>0)||null!==(u=e.cancelledServices)&&void 0!==u&&u.narRegistration||y.find(e=>"NAR Registration"===e.description)||y.push({description:"NAR Registration",amount:e.fees.narRegistrationFee}),!((null===(m=e.fees)||void 0===m?void 0:m.stateExamRegistrationFee)>0)||null!==(h=e.cancelledServices)&&void 0!==h&&h.stateExamRegistration||y.find(e=>"State Exam Registration"===e.description)||y.push({description:"State Exam Registration",amount:e.fees.stateExamRegistrationFee}),!((null===(p=e.fees)||void 0===p?void 0:p.stateExamFee)>0)||null!==(x=e.cancelledServices)&&void 0!==x&&x.stateExamFee||y.find(e=>"State Exam Fee"===e.description)||y.push({description:"State Exam Fee",amount:e.fees.stateExamFee}),!((null===(g=e.fees)||void 0===g?void 0:g.accommodationFee)>0)||null!==(f=e.accommodationDetails)&&void 0!==f&&f.cancelled||y.find(e=>"Accommodation Fee"===e.description)||y.push({description:"Accommodation Fee",amount:e.fees.accommodationFee}),(e.optionalServices||(null===(b=e.fees)||void 0===b?void 0:b.optionalServices)||[]).forEach(e=>{null!==e&&void 0!==e&&e.name&&Number(e.amount)>=0&&y.push({description:e.name,amount:Number(e.amount)})}),(e.customFees||[]).forEach(e=>{e.name&&e.amount>0&&y.push({description:e.name,amount:e.amount})}),((null===(v=e.fees)||void 0===v?void 0:v.customFees)||[]).forEach(e=>{e.name&&e.amount>0&&y.push({description:e.name,amount:e.amount})});const w=new Set;return y.filter(e=>!w.has(e.description)&&(w.add(e.description),!0)).reduce((e,t)=>e+t.amount,0)})(e),c=d+i;return o>1e5?c>0?c:0:c>0?c:o},l=e=>{const t=(e.status||"completed").toLowerCase();return!n.includes(t)},o=e=>{const t={};return e&&Array.isArray(e)?(e.forEach(e=>{const s=e.studentId;if(!s)return;if(!l(e))return;const a=parseFloat(e.amount)||0;t[s]=(t[s]||0)+a}),t):t},i=(e,t)=>t[e]||0,d=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const s=Math.round(100*r(e)),a=t.filter(l).reduce((e,t)=>e+Math.round(100*(Number(t.amount)||0)),0),n=Math.max(0,s-a);return{totalAmount:s/100,totalPaid:a/100,balance:n/100,paymentStatus:0===n?"paid":a>0?"partial":"pending"}},c=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const s=r(e),a=i(e.id,t);return{balance:Math.max(0,s-a),totalAmount:s,actualTotalPaid:a,isFromPayments:e.id in t||Object.keys(t).length>0}},u=(e,t)=>{var s,a;return null!=t?c(e,t).balance:Math.max(0,r(e)-(Number(null!==(s=null===(a=e.paymentDetails)||void 0===a?void 0:a.totalPaid)&&void 0!==s?s:e.paidAmount)||0))}},47798:(e,t,s)=>{s.d(t,{G:()=>n,L:()=>r});const a=(e,t)=>`hca:route-view-state:${e}:${t||"default"}`,n=(e,t)=>{if("undefined"===typeof window)return{};try{const s=window.sessionStorage.getItem(a(e,t));return s?JSON.parse(s):{}}catch{return{}}},r=(e,t,s)=>{if("undefined"!==typeof window)try{window.sessionStorage.setItem(a(e,t),JSON.stringify(s))}catch{}}},73601:(e,t,s)=>{s.d(t,{j:()=>n});const a=e=>{if(null==e||""===e)return null;if("object"===typeof e&&"function"===typeof e.toDate)return a(e.toDate());if("object"===typeof e&&"number"===typeof e.seconds)return a(new Date(1e3*e.seconds));if("string"===typeof e){const t=e.match(/^(\d{4})-(\d{2})-(\d{2})/);if(t)return new Date(Number(t[1]),Number(t[2])-1,Number(t[3]),12,0,0);const s=new Date(e);return isNaN(s.getTime())?null:a(s)}if(e instanceof Date)return isNaN(e.getTime())?null:new Date(e.getFullYear(),e.getMonth(),e.getDate(),12,0,0);const t=new Date(e);return isNaN(t.getTime())?null:a(t)},n=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:20;const s=a(e);if(!s)return null;let n=0===s.getDay()?0:1;for(;n<t;)s.setDate(s.getDate()+1),0!==s.getDay()&&(n+=1);return s}},82587:(e,t,s)=>{s.d(t,{$y:()=>o,Qy:()=>i,pU:()=>d});var a=s(55271),n=s(69212),r=s(29402);const l=e=>{const t=(e=>{if(!e)return null;if("object"===typeof e&&"function"===typeof e.toDate)return e.toDate();if("object"===typeof e&&"number"===typeof e.seconds)return new Date(1e3*e.seconds);if("string"===typeof e&&/^\d{4}-\d{2}-\d{2}$/.test(e))return new Date(`${e}T12:00:00`);const t=new Date(e);return isNaN(t.getTime())?null:t})(e);return t?(0,n.GP)(t,"MMM dd, yyyy"):""},o=[{key:"name",header:"Name",get:e=>{return(t=e.fullName)?t.split(" ").map(e=>e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"").join(" "):"N/A";var t}}
1,{key:"email",header:"Email",get:e=>e.email||""},{key:"phone",header:"Phone",get:e=>e.phoneNumber||""},{key:"status",header:"Status",get:e=>{return(t=e.status)?t.charAt(0).toUpperCase()+t.slice(1):"";var t}},{key:"country",header:"Country",get:e=>e.countryOfOrigin||""},{key:"employerNumber",header:"Employer Number",get:e=>(e=>{const t=Array.isArray(e.employmentHistory)?e.employmentHistory:[],s=t.find(e=>e&&e.isCurrent)||t[0];return s&&s.phone||e.employerPhone||""})(e)},{key:"emergencyContact",header:"Emergency Contact #",get:e=>(e=>e.emergencyContactPhone||e.emergencyContact||"")(e)},{key:"registrationDate",header:"Registration Date",get:e=>l(e.registrationDate)},{key:"courseStart",header:"Course Start",get:e=>l(e.courseStartDate)},{key:"completion",header:"Expected Completion",get:e=>l(e.expectedCompletionDate)},{key:"totalAmount",header:"Total Amount",money:!0,get:e=>(0,r.q5)(e)},{key:"totalPaid",header:"Total Paid",money:!0,get:(e,t)=>(0,r.tt)(e.id,t.paidMap)},{key:"balance",header:"Balance (Dues)",money:!0,get:(e,t)=>Math.max(0,(0,r.q5)(e)-(0,r.tt)(e.id,t.balanceMap))},{key:"paymentStatus",header:"Payment Status",get:(e,t)=>{const s=(0,r.q5)(e),a=(0,r.tt)(e.id,t.balanceMap);return Math.max(0,s-a)<=0?"Paid":a>0?"Partial":"Unpaid"}}],i=()=>o.reduce((e,t)=>(e[t.key]=!0,e),{}),d=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{balanceMap:s={},paidMap:r,selectedColumns:l=null,paidHeader:i=null,extraColumns:d=[],sheetName:c="Students"}=t,u=t.filename||`Students_${(0,n.GP)(new Date,"yyyy-MM-dd")}.xlsx`,m={paidMap:r||s,balanceMap:s},h=(l?o.filter(e=>l[e.key]):o.slice()).concat(d);if(0===h.length)return{ok:!1,reason:"no-columns"};if(!e||0===e.length)return{ok:!1,reason:"no-rows"};const p=e=>"totalPaid"===e.key&&i?i:e.header,x=e.map(e=>{const t={};return h.forEach(s=>{t[p(s)]=s.get(e,m)}),t}),g={};h.forEach((t,s)=>{const a=p(t);0===s?g[a]="TOTAL":t.money?g[a]=e.reduce((e,s)=>e+(Number(t.get(s,m))||0),0):g[a]=""});const f=a.Wp.json_to_sheet([...x,g]);f["!cols"]=h.map(e=>{const t=p(e);return{wch:e.money?Math.max(14,t.length+2):"email"===e.key?28:Math.max(12,t.length+4)}});const b=h.map((e,t)=>e.money?t:-1).filter(e=>e>=0),v=a.Wp.decode_range(f["!ref"]);for(let n=1;n<=v.e.r;n+=1)b.forEach(e=>{const t=a.Wp.encode_cell({r:n,c:e});f[t]&&(f[t].z='"$"#,##0.00')});const y=a.Wp.book_new();return a.Wp.book_append_sheet(y,f,c),a._h(y,u),{ok:!0,count:e.length}}},91880:(e,t,s)=>{s.r(t),s.d(t,{default:()=>ne});var a=s(9950),n=s(73814),r=s(56600),l=s(69212),o=s(73601),i=s(29402),d=s(82587),c=s(99845),u=s(47798),m=s(92375),h=s(11594),p=s(52941),x=s(2391),g=s(50619),f=s(25452),b=s(33720),v=s(64725),y=s(15536),w=s(33695),N=s(99696),j=s(39818),S=s(34208),C=s(84517),D=s(22896),A=s(78010),k=s(41435),F=s(77873),$=s(9936),M=s(24155),E=s(35320),T=s(75516),I=s(59019),R=s(88021);const P=e=>{var t,s;return{jpeg:"JPEG",jpg:"JPEG",png:"PNG",webp:"WEBP",gif:"GIF",bmp:"BMP"}[null===(t=/^data:image\/([^;,]+)/i.exec(e||""))||void 0===t||null===(s=t[1])||void 0===s?void 0:s.toLowerCase()]||null},L=async e=>{if(!e)return null;if(e.startsWith("data:"))return P(e)?e:null;try{const t=await fetch(e,{cache:"no-store"});if(!t.ok)return null;const s=await t.blob(),a=await new Promise(e=>{const t=new FileReader;t.onload=()=>e(t.result),t.onerror=()=>e(null),t.readAsDataURL(s)});return P(a)?a:null}catch{return null}},O=3.375,U=2.125,z=(11-9.1)/2,B=e=>{if(!e)return null;if(e.toDate)return e.toDate();if(e.seconds)return new Date(1e3*e.seconds);const t=new Date(e);return Number.isNaN(t.getTime())?null:t},G=e=>{let{pdf:t,x:s,y:a,student:n,photo:r,logo:l,websiteQr:o,programName:i,clinicalDate:d}=e;t.setFillColor(255,255,255),t.setDrawColor(30,58,95),t.setLineWidth(.012),t.roundedRect(s,a,O,U,.08,.08,"FD"),t.setFillColor(18,59,105),t.roundedRect(s,a,O,.42,.07,.07,"F"),t.rect(s,a+.32,O,.1,"F"),l&&t.addImage(l,P(l),s+.1,a+.065,.27,.27,void 0,"FAST"),t.setTextColor(255,255,255),t.setFont("helvetica","bold"),t.setFontSize(7.1),t.text("Caregiver Training & Huduma Center LLC",s+.43,a+.18,{maxWidth:2.75}),t.setFont("helvetica","normal"),t.setFontSize(5.5),t.text("CNA STUDENT",s+.43,a+.305);const c=s+.14,u=a+.59,m=.86;var h;t.setFillColor(241,245,249),t.setDrawColor(203,213,225),t.roundedRect(c,u,m,1.12,.05,.05,"FD"),r?t.addImage(r,P(r),c+.03,u+.03,.8,1.06,void 0,"FAST"):(t.setTextColor(100,116,139),t.setFont("helvetica","bold"),t.setFontSize(22),t.text((h=n.fullName,String(h||"Student").split(/\s+/).filter(
1Boolean).slice(0,2).map(e=>e[0]).join("").toUpperCase()),c+.43,u+.65,{align:"center"}));const p=s+1.14,x=2.07;t.setTextColor(15,23,42),t.setFont("helvetica","bold"),t.setFontSize(11.2);const g=String(n.fullName||"Student").trim().toUpperCase(),f=t.splitTextToSize(g,x);t.text(f.slice(0,2),p,a+.71,{lineHeightFactor:1.05});const b=f.length>1?.2:0;t.setTextColor(18,59,105),t.setFontSize(7.2),t.text(String(i||"Nursing Assistant Training"),p,a+1+b,{maxWidth:x}),t.setDrawColor(226,232,240),t.line(p,a+1.13+b,s+O-.14,a+1.13+b),t.setFillColor(248,250,252);const v=.52,y=s+O-.14-v,w=a+1.29;t.roundedRect(p,a+1.23+b,1.4099999999999997,.43,.04,.04,"F"),t.setTextColor(100,116,139),t.setFont("helvetica","bold"),t.setFontSize(5.8),t.text("CLINICAL DATE",p+.09,a+1.35+b),t.setTextColor(15,23,42),t.setFontSize(8.7),t.text(d,p+.09,a+1.53+b),o&&(t.addImage(o,"PNG",y,w,v,v,void 0,"FAST"),t.setTextColor(100,116,139),t.setFont("helvetica","bold"),t.setFontSize(4.5),t.text("SCAN FOR WEBSITE",y+.26,w+v+.09,{align:"center"})),t.setFillColor(226,180,83),t.rect(s,a+U-.08,O,.08,"F"),((e,t,s)=>{const a=.09;e.setDrawColor(148,163,184),e.setLineWidth(.005),[[t,s],[t+O,s],[t,s+U],[t+O,s+U]].forEach((t,s)=>{let[n,r]=t;const l=0===s||2===s,o=s<2;e.line(n+(l?-.09:a),r,n+0,r),e.line(n,r+(o?-.09:a),n,r)})})(t,s,a)};async function _(e){var t,s;let{cohort:a,students:n,photoUrls:l={}}=e;const o=n.filter(e=>!e.isDeleted&&!["deleted","inactive"].includes(String(e.status||"").toLowerCase()));if(!o.length)throw new Error("This cohort has no active students for badge generation.");const i=function(){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";const t=[...arguments.length>0&&void 0!==arguments[0]?arguments[0]:[]].filter(e=>B(e.startAt)).sort((e,t)=>B(e.startAt)-B(t.startAt));return/hca\s*[-\u2013\u2014]?\s*cna|bridge/i.test(`${e} ${t.map(e=>`${e.moduleId||""} ${e.programId||""}`).join(" ")}`)?t.find(e=>5===Number(e.seriesPosition))||t[4]||t.at(-1)||null:t.find(e=>/clinical/i.test(`${e.title||""} ${e.phase||""} ${e.registrationNotes||""}`))||t.at(-1)||null}(a.sessions,a.title),d=(e=>{const t=B(e);return t?t.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"America/Los_Angeles"}):"Date to be confirmed"})(null===i||void 0===i?void 0:i.startAt),c=a.title||(null===(t=o[0])||void 0===t?void 0:t.programName)||(null===(s=o[0])||void 0===s?void 0:s.courseType)||"Nursing Assistant Training",u=await Promise.all(o.map(e=>(async(e,t)=>{var s;const a=new Set,n=async e=>!e||a.has(e)?null:(a.add(e),L(e));for(const r of[e.profilePhoto,t]){const e=await n(r);if(e)return e}const l=[];null!==(s=e.profilePhoto)&&void 0!==s&&s.startsWith("https://")&&l.push(e.profilePhoto),e.id&&l.push(`students/${e.id}/profile-photo`);for(const o of l)try{const e=await n(await(0,r.qk)((0,r.KR)(r.IG,o)));if(e)return e}catch{}return null})(e,l[e.id]))),m=o.filter((e,t)=>!u[t]);if(m.length){const e=m.map(e=>e.fullName||e.id||"Unknown student").join(", ");throw new Error(`Badges were not generated because photos could not be loaded for: ${e}. Open each student profile, check or upload the photo, then generate badges again.`)}const h=await L("/official-logo.png"),p=await R.toDataURL("https://hudumacna.com/",{errorCorrectionLevel:"M",margin:1,width:256,color:{dark:"#0f172a",light:"#ffffff"}}),x=new I.Ay({orientation:"portrait",unit:"in",format:"letter"});o.forEach((e,t)=>{t>0&&t%8===0&&x.addPage();const s=t%8,a=s%2,n=Math.floor(s/2);G({pdf:x,x:.75+3.625*a,y:z+2.325*n,student:e,photo:u[t],logo:h,websiteQr:p,programName:c,clinicalDate:d})});const g=`${String(a.title||"Cohort").replace(/[^a-z0-9]+/gi,"-").replace(/^-|-$/g,"")||"Cohort"}-Clinical-Badges.pdf`,f=x.output("blob");return x.save(g),{count:o.length,pages:Math.ceil(o.length/8),clinicalDate:d,blob:f,fileName:g}}var W=s(85863),Y=s(46992),H=s(44414);const q=e=>{let{size:t="medium"}=e;return(0,H.jsx)("div",{className:`animate-spin rounded-full border-b-2 border-blue-600 ${{small:"w-4 h-4",medium:"w-6 h-6",large:"w-8 h-8"}[t]}`})},J=e=>e?e.split(" ").map(e=>e?e.charAt(0).toUpperCase()+e.slice(1).toLowerCase():"").join(" "):"N/A",Q=e=>{if(!e)return null;if("object"===typeof e&&"function"===typeof e.toDate)return e.toDate();if("object"===typeof e&&"number"===typeof e.seconds)return new Date(1e3*e.seconds);if("string"===typeof e&&/^\d{4}-\d{2}-\d{2}$/.test(e))return new Date(`${e}T12:00:00`);const t=new Date(e);return isNaN(t.getTime())?null:t},Z=[{value:"all",label:"All time"},{value:"today",label:"Today"},{value:"last7",label:"Last 7 days"},{value:"last30",label:"Last 30 days"},{value:"thisMonth",label:"This month"},{value:"thisYear",label:"This year"},{value:"custom",label:"Custom range\u2026"}],K=(e,t,s)=>{if("all"===e||!e)return{from:null,to:null};const a=new Date;switch(e){case"today":return{from:new Date(a.getFullYear(),a.getMonth(),a.getDate()),to:null};case"last7":return{from:new Date(a.getTime()-6048e5),to:null};case"last30":return{from:new Date(a.getTime()-2592e6),to:null};case"thisMonth":return{from:new Date(a.getFullYear(),a.getMonth(),1),to:null};case"thisYear":return{from:new Date(a.getFullYear(),0,1),to:null};
1case"custom":return{from:t?new Date(`${t}T00:00:00`):null,to:s?new Date(`${s}T23:59:59`):null};default:return{from:null,to:null}}},V=(e,t)=>{let{from:s,to:a}=t;return!s&&!a||!!e&&(!(s&&e<s)&&!(a&&e>a))},X=(e,t,s)=>{if("custom"===e)return t&&s?`${t} \u2192 ${s}`:t?`from ${t}`:s?`until ${s}`:"Custom";const a=Z.find(t=>t.value===e);return a?a.label:e},ee={all:"All",dues:"Has dues",paid:"Fully paid",unpaid:"Unpaid"},te=e=>{const t=Q(e);return t?(0,l.GP)(t,"MMM dd, yyyy"):""},se=e=>{let{label:t,value:s,onValueChange:a,from:n,to:r,onFromChange:l,onToChange:o}=e;return(0,H.jsxs)("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-2",children:[(0,H.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,H.jsx)(p.A,{className:"w-5 h-5 text-slate-400"}),(0,H.jsxs)("span",{className:"text-sm font-medium text-slate-600 whitespace-nowrap",children:[t,":"]}),(0,H.jsx)("select",{value:s,onChange:e=>a(e.target.value),className:"border border-slate-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:Z.map(e=>(0,H.jsx)("option",{value:e.value,children:e.label},e.value))})]}),"custom"===s&&(0,H.jsxs)("div",{className:"flex items-center gap-2",children:[(0,H.jsx)("input",{type:"date",value:n,onChange:e=>l(e.target.value),className:"border border-slate-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","aria-label":`${t} from`}),(0,H.jsx)("span",{className:"text-slate-400 text-sm",children:"to"}),(0,H.jsx)("input",{type:"date",value:r,onChange:e=>o(e.target.value),className:"border border-slate-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","aria-label":`${t} to`})]})]})},ae=e=>{let{status:t}=e;return(0,H.jsx)("span",{className:`inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium ${(e=>{switch(null===e||void 0===e?void 0:e.toLowerCase()){case"active":return"bg-green-100 text-green-800";case"completed":return"bg-blue-100 text-blue-800";case"graduated":return"bg-purple-100 text-purple-800";case"withdrawn":return"bg-red-100 text-red-800";case"suspended":return"bg-orange-100 text-orange-800";case"onleave":return"bg-yellow-100 text-yellow-800";default:return"bg-gray-100 text-gray-800"}})(t)}`,children:(null===t||void 0===t?void 0:t.toUpperCase())||"N/A"})},ne=()=>{const e=(0,n.Zp)(),t=(0,n.zy)(),{showAlert:s,showConfirm:p}=(0,c.M)(),I=(0,u.G)("total-students",t.key),[R,P]=(0,a.useState)([]),[L,O]=(0,a.useState)([]),[U,z]=(0,a.useState)("folders"),[B,G]=(0,a.useState)(!0),[Z,ne]=(0,a.useState)(()=>I.searchTerm||""),[re,le]=(0,a.useState)(()=>I.statusFilter||"all"),[oe,ie]=(0,a.useState)(()=>I.currentPage||1),[de]=(0,a.useState)(10),[ce,ue]=(0,a.useState)(()=>I.sortBy||"courseStartDate"),[me,he]=(0,a.useState)(()=>I.sortOrder||"desc"),[pe,xe]=(0,a.useState)([]),[ge,fe]=(0,a.useState)(!1),[be,ve]=(0,a.useState)(""),[ye,we]=(0,a.useState)(!1),[Ne,je]=(0,a.useState)({}),[Se,Ce]=(0,a.useState)(!1),[De,Ae]=(0,a.useState)(()=>I.regDateFilter||"all"),[ke,Fe]=(0,a.useState)(()=>I.customFrom||""),[$e,Me]=(0,a.useState)(()=>I.customTo||""),[Ee,Te]=(0,a.useState)(()=>I.courseDateFilter||"all"),[Ie,Re]=(0,a.useState)(()=>I.courseFrom||""),[Pe,Le]=(0,a.useState)(()=>I.courseTo||""),[Oe,Ue]=(0,a.useState)(()=>I.paymentFilter||"all"),[ze,Be]=(0,a.useState)(()=>I.minBalance||""),[Ge,_e]=(0,a.useState)(()=>I.maxBalance||""),[We,Ye]=(0,a.useState)([]),[He,qe]=(0,a.useState)(!1),[Je,Qe]=(0,a.useState)(!1),[Ze,Ke]=(0,a.useState)(!1),[Ve,Xe]=(0,a.useState)(null),[et,tt]=(0,a.useState)(!1),[st,at]=(0,a.useState)(!1),[nt,rt]=(0,a.useState)(!1),[lt,ot]=(0,a.useState)(d.Qy),[it,dt]=(0,a.useState)(()=>I.payFrom||""),[ct,ut]=(0,a.useState)(()=>I.payTo||""),[mt,ht]=(0,a.useState)(null),[pt,xt]=(0,a.useState)(""),[gt,ft]=(0,a.useState)(""),[bt,vt]=(0,a.useState)(!1);(0,a.useEffect)(()=>{(0,u.L)("total-students",t.key,{searchTerm:Z,statusFilter:re,currentPage:oe,sortBy:ce,sortOrder:me,regDateFilter:De,customFrom:ke,customTo:$e,courseDateFilter:Ee,courseFrom:Ie,courseTo:Pe,paymentFilter:Oe,minBalance:ze,maxBalance:Ge,payFrom:it,payTo:ct})},[t.key,Z,re,oe,ce,me,De,ke,$e,Ee,Ie,Pe,Oe,ze,Ge,it,ct]),(0,a.useEffect)(()=>{(0,r.Ij)("reconcileAllApprovedEnrollments").catch(e=>{console.error("Could not reconcile approved enrollments:",e)});const e=(0,r.P)((0,r.rJ)(r.db,"students"),(0,r.My)("registrationDate","desc")),t=(0,r.aQ)(e,e=>{const t=e.docs.map(e=>({id:e.id,...e.data()}));P(t),G(!1)});return()=>t()},[]),(0,a.useEffect)(()=>{const e=(0,r.aQ)((0,r.rJ)(r.db,"classSchedules"),e=>{O(e.docs.map(e=>({id:e.id,...e.data()})))});return()=>e()},[]),(0,a.useEffect)(()=>{const e=(0,r.aQ)((0,r.rJ)(r.db,"payments"),e=>{Ye(e.docs.map(e=>({id:e.id,...e.data()})))});return()=>e()},[]);const yt=(0,a.useMemo)(()=>(0,i.YM)(We),[We]),wt=(0,a.useMemo)(()=>{const e=new Map;L.filter(e=>
1"cancelled"!==e.status).forEach(t=>{const s=t.seriesId||t.id;e.has(s)||e.set(s,[]),e.get(s).push(t)});const t=[...e.entries()].map(e=>{var t;let[s,a]=e;const n=[...a].sort((e,t)=>Q(e.startAt)-Q(t.startAt)),r=R.filter(e=>!e.isDeleted&&"deleted"!==e.status&&(e.scheduleSeriesId===s||!e.scheduleSeriesId&&e.scheduleId&&n.some(t=>t.id===e.scheduleId))).length;return{id:s,title:(null===(t=n[0])||void 0===t?void 0:t.title)||"Scheduled cohort",sessions:n,memberCount:r}}).sort((e,t)=>{var s,a;return Q(null===(s=t.sessions[0])||void 0===s?void 0:s.startAt)-Q(null===(a=e.sessions[0])||void 0===a?void 0:a.startAt)}),s=new Set(t.map(e=>e.id)),a=new Set(t.flatMap(e=>e.sessions.map(e=>e.id))),n=R.filter(e=>!e.isDeleted&&"deleted"!==e.status&&!(e.scheduleSeriesId?s.has(e.scheduleSeriesId):e.scheduleId&&a.has(e.scheduleId))).length;return n&&t.push({id:"unassigned",title:"Not assigned to a cohort",sessions:[],memberCount:n}),t},[L,R]),Nt=(0,a.useMemo)(()=>{if("folders"===U)return[];const e=wt.find(e=>e.id===U),t=new Set(wt.filter(e=>"unassigned"!==e.id).map(e=>e.id)),s=new Set(wt.flatMap(e=>e.sessions.map(e=>e.id)));return R.filter(a=>"unassigned"===U?!(a.scheduleSeriesId?t.has(a.scheduleSeriesId):a.scheduleId&&s.has(a.scheduleId)):a.scheduleSeriesId===U||!a.scheduleSeriesId&&a.scheduleId&&(null===e||void 0===e?void 0:e.sessions.some(e=>e.id===a.scheduleId)))},[wt,U,R]),jt=e=>`cohort-badges/${String(e||"cohort").replace(/[^a-zA-Z0-9_-]/g,"_")}/latest-clinical-badges.pdf`;(0,a.useEffect)(()=>{if("folders"===U||"unassigned"===U)return void Xe(null);let e=!0;tt(!0);const t=(0,r.KR)(r.IG,jt(U));return Promise.all([(0,r.qk)(t),(0,r.yb)(t)]).then(t=>{var s,a,n;let[r,l]=t;if(!e)return;const o=encodeURIComponent(l.updated||l.timeCreated||Date.now());Xe({url:`${r}${r.includes("?")?"&":"?"}v=${o}`,name:(null===(s=l.customMetadata)||void 0===s?void 0:s.displayName)||"Latest clinical badges.pdf",generatedAt:(null===(a=l.customMetadata)||void 0===a?void 0:a.generatedAt)||l.updated||l.timeCreated,count:Number((null===(n=l.customMetadata)||void 0===n?void 0:n.studentCount)||0)})}).catch(()=>{e&&Xe(null)}).finally(()=>{e&&tt(!1)}),()=>{e=!1}},[U]);(0,a.useEffect)(()=>{const e=Z.trim().toLowerCase();if(e.length<2)return;const t=R.filter(t=>!t.isDeleted&&"deleted"!==t.status&&[t.fullName,t.email,t.phoneNumber,t.phone].some(t=>String(t||"").toLowerCase().includes(e))),s=new Set(t.map(e=>{if(e.scheduleSeriesId)return e.scheduleSeriesId;if(e.scheduleId){const t=L.find(t=>t.id===e.scheduleId);return(null===t||void 0===t?void 0:t.seriesId)||(null===t||void 0===t?void 0:t.id)||"unassigned"}return"unassigned"}));t.length&&1===s.size&&z([...s][0])},[Z,R,L]);const St=JSON.stringify([Z,re,De,ke,$e,Ee,Ie,Pe,Oe,ze,Ge,U]),Ct=(0,a.useRef)(St);(0,a.useEffect)(()=>{Ct.current!==St&&(Ct.current=St,ie(1))},[St]),(0,a.useEffect)(()=>{R.length>0&&(async()=>{const e=R.map(async e=>{if(e.profilePhoto)return{id:e.id,url:null};try{const t=(0,r.KR)(r.IG,`students/${e.id}/profile-photo`),s=await(0,r.qk)(t);return{id:e.id,url:s}}catch{return{id:e.id,url:null}}}),t=await Promise.all(e),s={};t.forEach(e=>{let{id:t,url:a}=e;a&&(s[t]=a)}),je(s)})()},[R]);const Dt=(0,a.useMemo)(()=>{const e=K(De,ke,$e),t=K(Ee,Ie,Pe),s=""===ze||isNaN(parseFloat(ze))?null:parseFloat(ze),a=""===Ge||isNaN(parseFloat(Ge))?null:parseFloat(Ge),n="all"!==Oe||null!==s||null!==a;return R.filter(r=>{var l,o,d;if(!0===r.isDeleted||"deleted"===r.status)return!1;const c="folders"===U||("unassigned"===U?!(r.scheduleSeriesId?L.some(e=>"cancelled"!==e.status&&e.seriesId===r.scheduleSeriesId):r.scheduleId&&L.some(e=>"cancelled"!==e.status&&e.id===r.scheduleId)):r.scheduleSeriesId===U||!r.scheduleSeriesId&&L.some(e=>"cancelled"!==e.status&&e.id===r.scheduleId&&(e.seriesId||e.id)===U)),u=!Z||(null===(l=r.fullName)||void 0===l?void 0:l.toLowerCase().includes(Z.toLowerCase()))||(null===(o=r.email)||void 0===o?void 0:o.toLowerCase().includes(Z.toLowerCase()))||(null===(d=r.phoneNumber)||void 0===d?void 0:d.includes(Z)),m="all"===re||r.status===re,h=V(Q(r.registrationDate),e),p=V(Q(r.courseStartDate),t);let x=!0;if(n){const{total:e,paid:t,balance:n}
1=((e,t)=>{const s=(0,i.q5)(e),a=(0,i.tt)(e.id,t);return{total:s,paid:a,balance:Math.max(0,s-a)}})(r,yt);"dues"===Oe?x=n>0:"paid"===Oe?x=n<=0&&e>0:"unpaid"===Oe&&(x=t<=0&&e>0),x&&null!==s&&(x=n>=s),x&&null!==a&&(x=n<=a)}return u&&m&&h&&p&&x&&c})},[R,Z,re,De,ke,$e,Ee,Ie,Pe,Oe,ze,Ge,yt,U,L]),At=(0,a.useMemo)(()=>[...Dt].sort((e,t)=>{var s,a,n,r,l,o,i,d,c,u;let m,h;switch(ce){case"fullName":m=(null===(s=e.fullName)||void 0===s?void 0:s.toLowerCase())||"",h=(null===(a=t.fullName)||void 0===a?void 0:a.toLowerCase())||"";break;case"countryOfOrigin":m=(null===(n=e.countryOfOrigin)||void 0===n?void 0:n.toLowerCase())||"",h=(null===(r=t.countryOfOrigin)||void 0===r?void 0:r.toLowerCase())||"";break;case"courseStartDate":m=null!==(l=e.courseStartDate)&&void 0!==l&&l.toDate?e.courseStartDate.toDate():new Date(e.courseStartDate||0),h=null!==(o=t.courseStartDate)&&void 0!==o&&o.toDate?t.courseStartDate.toDate():new Date(t.courseStartDate||0);break;case"registrationDate":m=null!==(i=e.registrationDate)&&void 0!==i&&i.toDate?e.registrationDate.toDate():new Date(e.registrationDate||0),h=null!==(d=t.registrationDate)&&void 0!==d&&d.toDate?t.registrationDate.toDate():new Date(t.registrationDate||0);break;case"status":m=(null===(c=e.status)||void 0===c?void 0:c.toLowerCase())||"",h=(null===(u=t.status)||void 0===u?void 0:u.toLowerCase())||"";break;default:return 0}return"asc"===me?m>h?1:-1:m<h?1:-1}),[Dt,ce,me]),kt=(0,a.useMemo)(()=>{const e=(oe-1)*de;return At.slice(e,e+de)},[At,oe,de]),Ft=Math.ceil(At.length/de);(0,a.useEffect)(()=>{!B&&Ft>0&&oe>Ft&&ie(Ft)},[B,Ft,oe]);const $t=(0,a.useMemo)(()=>pe.length>0?R.filter(e=>pe.includes(e.id)&&!e.isDeleted&&"deleted"!==e.status):At,[pe,R,At]),Mt=()=>{bt||(ht(null),xt(""),ft(""))},Et=(0,a.useMemo)(()=>mt?wt.filter(e=>{var t,s;if("unassigned"===e.id||!e.sessions.length)return!1;if(mt.scheduleSeriesId===e.id||!mt.scheduleSeriesId&&e.sessions.some(e=>e.id===mt.scheduleId))return!1;const a=null===(t=e.sessions[0])||void 0===t?void 0:t.moduleId;if(mt.programId&&a&&mt.programId!==a)return!1;const n=e.sessions.at(-1);return((null===(s=Q((null===n||void 0===n?void 0:n.endAt)||(null===n||void 0===n?void 0:n.startAt)))||void 0===s?void 0:s.getTime())||0)>Date.now()}):[],[wt,mt]),Tt=async(e,t)=>{const a=e.filter(e=>e.email&&!e.isDeleted&&"deleted"!==e.status&&"inactive"!==e.status&&!(e.portalAccountUid&&"accepted"===e.portalInvitationStatus));if(a.length){Qe(!0);try{const e=await(0,r.Ij)("inviteStudentAccounts",{studentIds:a.map(e=>e.id)});s(`${e.sent} student account invitation${1===e.sent?"":"s"} sent${e.skipped?`; ${e.skipped} active account${1===e.skipped?"":"s"} skipped`:""}${e.failed?`; ${e.failed} could not be sent`:""}.`,{type:e.failed?"warning":"success",title:t})}catch(n){s(n.message||"Student invitations could not be sent.",{type:"error",title:"Invitation error"})}finally{Qe(!1)}}else s("No active students with email addresses were found.",{type:"warning",title:"No invitations sent"})},It=()=>{if(0!==$t.length){qe(!0);try{const{from:e,to:t}=K("custom",it,ct),a=!(!e&&!t),n=a?(0,i.YM)(We.filter(s=>{const a=Q(s.createdAt||s.date||s.paymentDate);return!(e&&(!a||a<e))&&!(t&&(!a||a>t))})):yt,r=it&&ct?`${te(it)} \u2013 ${te(ct)}`:it?`from ${te(it)}`:ct?`until ${te(ct)}`:"",o=(0,d.pU)($t,{paidMap:n,balanceMap:yt,selectedColumns:lt,paidHeader:a?`Total Paid (${r})`:null,filename:`All_Students_${(0,l.GP)(new Date,"yyyy-MM-dd")}.xlsx`});o.ok||"no-columns"!==o.reason||s("Select at least one column to export.",{type:"warning",title:"No Columns Selected"})}catch(e){console.error("Error exporting students:",e),s("Failed to export students. Please try again.",{type:"error",title:"Export Error"})}finally{qe(!1)}}},Rt=[];var Pt;Z&&Rt.push({key:"search",label:`Search: "${Z}"`,clear:()=>ne("")}),"all"!==re&&Rt.push({key:"status",label:`Status: ${Pt=re,Pt?Pt.charAt(0).toUpperCase()+Pt.slice(1):""}`,clear:()=>le("all")}),"all"!==De&&Rt.push({key:"reg",label:`Registered: ${X(De,ke,$e)}`,clear:()=>{Ae("all"),Fe(""),Me("")}}),"all"!==Ee&&Rt.push({key:"course",label:`Course start: ${X(Ee,Ie,Pe)}`,clear:()=>{Te("all"),Re(""),Le("")}}),"all"!==Oe&&Rt.push({key:"pay",label:`Payment: ${ee[Oe]}`,clear:()=>Ue("all")}),""===ze&&""===Ge||Rt.push({key:"bal",label:`Dues: ${""!==ze?"$"+ze:"$0"} \u2013 ${""!==Ge?"$"+Ge:"any"}`,clear:()=>{Be(""),_e("")}});return B?(0,H.jsx)("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50",children:(0,H.jsx)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:(0,H.jsxs)("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-200 p-16 text-center",children:[(0,H.jsx)(q,{size:"large"}),(0,H.jsx)("p",{className:"mt-4 text-slate-600",children:"Loading students..."})]})})}):(0,H.jsxs)("div",{className:"min-h-screen bg-gradient-to-br from-slate-50 via-blue-50 to-indigo-50",children:[(0,H.jsx)("div",{className:"bg-white shadow-sm border-b border-slate-200",children:(0,H.jsx)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",children:(0,H.jsxs)("div",{className:"flex items-center justify-between py-6",children:[(0,H.jsx)("div",{className:"flex items-center space-x-4",children:(0,H.jsxs)("button",{onClick:()=>
1e("/dashboard"),className:"flex items-center space-x-2 text-slate-600 hover:text-slate-900 transition-colors",children:[(0,H.jsx)(x.A,{className:"w-5 h-5"}),(0,H.jsx)("span",{children:"Back to Dashboard"})]})}),(0,H.jsx)("div",{className:"flex items-center space-x-4",children:(0,H.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,H.jsx)("div",{className:"w-10 h-10 bg-gradient-to-br from-blue-600 to-indigo-700 rounded-xl flex items-center justify-center shadow-lg",children:(0,H.jsx)(W.A,{className:"w-6 h-6 text-white"})}),(0,H.jsxs)("div",{children:[(0,H.jsx)("h1",{className:"text-2xl font-bold text-slate-900",children:"All Students"}),(0,H.jsxs)("p",{className:"text-sm text-slate-600",children:["Total:"," ",R.filter(e=>!e.isDeleted&&"deleted"!==e.status).length," ","students"]})]})]})})]})})}),(0,H.jsxs)("main",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8",children:[(0,H.jsxs)("div",{className:"bg-white rounded-2xl border border-slate-200 p-4 mb-6 flex items-center justify-between gap-4",children:[(0,H.jsxs)("div",{children:[(0,H.jsx)("h3",{className:"text-sm font-semibold text-slate-700",children:"Expected Completion Dates"}),(0,H.jsx)("p",{className:"text-xs text-slate-500 mt-1",children:"Recalculate for all students \u2014 11 course days (Sundays off), start day counts as day 1. Overrides existing dates."})]}),(0,H.jsxs)("button",{onClick:async()=>{const e=R.filter(e=>e.courseStartDate&&!e.isDeleted&&"deleted"!==e.status);if(0===e.length)return void s("No students with a course start date to update.",{type:"warning",title:"Nothing to Update"});if(await p(`Recalculate Expected Completion for ${e.length} student${1===e.length?"":"s"} using the current rule (11 course days, Sundays off, start day counts as day 1)?\n\nThis overrides any manually set completion dates.`,{title:"Recalculate All Completion Dates",type:"confirm-danger",confirmText:"Recalculate",cancelText:"Cancel"})){Ce(!0);try{const t=450;let a=0,n=0;for(let s=0;s<e.length;s+=t){const l=(0,r.wP)(r.db);let i=0;for(const d of e.slice(s,s+t)){const e=(0,o.j)(d.courseStartDate);e?(l.update((0,r.H9)(r.db,"students",d.id),{expectedCompletionDate:e.toISOString(),updatedAt:(0,r.O5)()}),i+=1,a+=1):n+=1}i>0&&await l.commit()}s(`Recalculated completion dates for ${a} student${1===a?"":"s"}.${n?` Skipped ${n} (invalid start date).`:""}`,{type:"success",title:"Update Complete"})}catch(t){console.error("Error recalculating completion dates:",t),s("Error recalculating completion dates. Please try again.",{type:"error",title:"Error"})}finally{Ce(!1)}}},disabled:Se,className:"inline-flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-medium text-white shadow-sm whitespace-nowrap "+(Se?"bg-slate-400 cursor-not-allowed":"bg-blue-600 hover:bg-blue-700"),children:[Se?(0,H.jsx)(q,{size:"small"}):(0,H.jsx)(g.A,{className:"w-4 h-4"}),Se?"Recalculating\u2026":"Recalculate All"]})]}),pe.length>0&&(0,H.jsxs)("div",{className:"bg-blue-50 border border-blue-200 rounded-2xl p-4 mb-6 flex items-center justify-between",children:[(0,H.jsxs)("div",{className:"flex items-center space-x-4",children:[(0,H.jsx)(Y.A,{className:"w-5 h-5 text-blue-600"}),(0,H.jsxs)("span",{className:"text-sm font-medium text-blue-900",children:[pe.length," student",pe.length>1?"s":""," selected"]})]}),(0,H.jsxs)("div",{className:"flex items-center space-x-3",children:[(0,H.jsxs)("button",{onClick:()=>Tt(R.filter(e=>pe.includes(e.id)),"Selected students invited"),disabled:Je,className:"inline-flex items-center px-3 py-1.5 border border-transparent text-sm font-medium rounded-md text-white bg-slate-800 hover:bg-slate-900 disabled:opacity-50",children:[(0,H.jsx)(f.A,{className:"w-4 h-4 mr-1.5"}),Je?"Sending\u2026":"Invite students without accounts"]}),(0,H.jsxs)("button",{onClick:()=>{ve("graduated"),fe(!0)},className:"inline-flex items-center px-3 py-1.5 border border-transparent text-sm font-medium rounded-md text-white bg-purple-600 hover:bg-purple-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500",children:[(0,H.jsx)(b.A,{className:"w-4 h-4 mr-1.5"}),"Mark as Graduated"]}),(0,H.jsxs)("button",{onClick:()=>{ve("completed"),fe(!0)},className:"inline-flex items-center px-3 py-1.5 border border-transparent text-sm font-medium rounded-md text-white bg-blue-600 hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500",children:[(0,H.jsx)(v.A,{className:"w-4 h-4 mr-1.5"}),"Mark as Completed"]}),(0,H.jsxs)("button",{onClick:()=>{ve("active"),fe(!0)},className:"inline-flex items-center px-3 py-1.5 border border-transparent text-sm font-medium rounded-md text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500",children:[(0,H.jsx)(g.A,{className:"w-4 h-4 mr-1.5"}),"Mark as Active"]}),(0,H.jsxs)("button",{onClick:()=>xe([]),className:"inline-flex items-center px-3 py-1.5 border border-gray-300 text-sm font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",children:[(0,H.jsx)(y.A,{className:"w-4 h-4 mr-1.5"}),"Clear Selection"]})]})]}),(0,H.jsxs)("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-200 p-4 sm:p-6 mb-8",children:[(0,H.jsxs)("button",{type:"button",onClick:()=>rt(e=>!e),"aria-expanded":nt,className:"flex w-full items-center justify-between gap-4 text-left",children:[(0,H.jsxs)("span",{className:"inline-flex items-center gap-2 font-semibold text-slate-800",children:[(0,H.jsx)(w.A,{className:"h-5 w-5 text-slate-500"}
1),"Search, filters & export"]}),(0,H.jsxs)("span",{className:"inline-flex items-center gap-3 text-sm text-slate-500",children:[(0,H.jsxs)("span",{children:["Showing ",At.length," of"," ",R.filter(e=>!e.isDeleted&&"deleted"!==e.status).length," ","students"]}),(0,H.jsx)(N.A,{className:"h-5 w-5 transition-transform "+(nt?"rotate-90":"")})]})]}),nt&&(0,H.jsxs)("div",{className:"mt-5 flex flex-col gap-4 border-t border-slate-100 pt-5",children:[(0,H.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4",children:[(0,H.jsxs)("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4",children:[(0,H.jsxs)("div",{className:"relative",children:[(0,H.jsx)(j.A,{className:"w-5 h-5 absolute left-3 top-1/2 transform -translate-y-1/2 text-slate-400"}),(0,H.jsx)("input",{type:"text",placeholder:"Search students...",value:Z,onChange:e=>ne(e.target.value),className:"pl-10 pr-4 py-2 border border-slate-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500"})]}),(0,H.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,H.jsx)(w.A,{className:"w-5 h-5 text-slate-400"}),(0,H.jsxs)("select",{value:re,onChange:e=>{le(e.target.value),ie(1)},className:"border border-slate-300 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:[(0,H.jsx)("option",{value:"all",children:"All Statuses"}),[...new Set(R.map(e=>e.status).filter(Boolean))].filter(e=>"deleted"!==e).sort().map(e=>(0,H.jsx)("option",{value:e,children:(null===e||void 0===e?void 0:e.charAt(0).toUpperCase())+(null===e||void 0===e?void 0:e.slice(1))},e))]})]}),(0,H.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,H.jsx)(S.A,{className:"w-5 h-5 text-slate-400"}),(0,H.jsxs)("select",{value:`${ce}-${me}`,onChange:e=>{const[t,s]=e.target.value.split("-");ue(t),he(s),ie(1)},className:"border border-slate-300 rounded-lg px-3 py-2 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:[(0,H.jsx)("option",{value:"courseStartDate-desc",children:"Start Date (Newest)"}),(0,H.jsx)("option",{value:"courseStartDate-asc",children:"Start Date (Oldest)"}),(0,H.jsx)("option",{value:"registrationDate-desc",children:"Registration (Newest)"}),(0,H.jsx)("option",{value:"registrationDate-asc",children:"Registration (Oldest)"}),(0,H.jsx)("option",{value:"fullName-asc",children:"Name (A-Z)"}),(0,H.jsx)("option",{value:"fullName-desc",children:"Name (Z-A)"}),(0,H.jsx)("option",{value:"countryOfOrigin-asc",children:"Country (A-Z)"}),(0,H.jsx)("option",{value:"countryOfOrigin-desc",children:"Country (Z-A)"}),(0,H.jsx)("option",{value:"status-asc",children:"Status (A-Z)"}),(0,H.jsx)("option",{value:"status-desc",children:"Status (Z-A)"})]})]})]}),(0,H.jsxs)("div",{className:"flex items-center gap-2",children:[(0,H.jsxs)("button",{onClick:()=>at(!0),className:"inline-flex items-center gap-2 px-3 py-2 rounded-xl text-sm font-medium text-slate-700 bg-white border border-slate-300 hover:bg-slate-50 whitespace-nowrap",children:[(0,H.jsx)(C.A,{className:"w-4 h-4"}),"Export options"]}),(0,H.jsxs)("button",{onClick:It,disabled:He||0===$t.length,className:"inline-flex items-center gap-2 px-4 py-2 rounded-xl text-sm font-medium text-white shadow-sm whitespace-nowrap "+(He||0===$t.length?"bg-slate-400 cursor-not-allowed":"bg-emerald-600 hover:bg-emerald-700"),children:[He?(0,H.jsx)(q,{size:"small"}):(0,H.jsx)(D.A,{className:"w-4 h-4"}),He?"Exporting\u2026":"Export to Excel"+(pe.length>0?` (${$t.length} selected)`:` (${$t.length})`)]})]})]}),(0,H.jsxs)("div",{className:"flex flex-col lg:flex-row lg:items-center gap-4 lg:gap-8 border-t border-slate-100 pt-4",children:[(0,H.jsx)(se,{label:"Registered",value:De,onValueChange:Ae,from:ke,to:$e,onFromChange:Fe,onToChange:Me}),(0,H.jsx)(se,{label:"Course start",value:Ee,onValueChange:Te,from:Ie,to:Pe,onFromChange:Re,onToChange:Le})]}),(0,H.jsxs)("div",{className:"flex flex-wrap items-center gap-x-4 gap-y-3 border-t border-slate-100 pt-4",children:[(0,H.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,H.jsx)(A.A,{className:"w-5 h-5 text-slate-400"}),(0,H.jsx)("span",{className:"text-sm font-medium text-slate-600 whitespace-nowrap",children:"Payment:"}),(0,H.jsxs)("select",{value:Oe,onChange:e=>Ue(e.target.value),className:"border border-slate-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500",children:[(0,H.jsx)("option",{value:"all",children:"All"}),(0,H.jsx)("option",{value:"dues",children:"Has dues (owes)"}),(0,H.jsx)("option",{value:"paid",children:"Fully paid"}),(0,H.jsx)("option",{value:"unpaid",children:"Unpaid (nothing paid)"})]})]}),(0,H.jsxs)("div",{className:"flex items-center gap-2",children:[(0,H.jsx)("span",{className:"text-sm text-slate-500
1whitespace-nowrap",children:"Dues $"}),(0,H.jsx)("input",{type:"number",min:"0",placeholder:"min",value:ze,onChange:e=>Be(e.target.value),className:"w-24 border border-slate-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","aria-label":"Minimum dues"}),(0,H.jsx)("span",{className:"text-slate-400 text-sm",children:"\u2013"}),(0,H.jsx)("input",{type:"number",min:"0",placeholder:"max",value:Ge,onChange:e=>_e(e.target.value),className:"w-24 border border-slate-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","aria-label":"Maximum dues"})]})]}),(0,H.jsxs)("div",{className:"flex flex-col sm:flex-row sm:items-center sm:justify-between gap-3 border-t border-slate-100 pt-4",children:[(0,H.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:0===Rt.length?(0,H.jsx)("span",{className:"text-sm text-slate-400",children:"No filters applied"}):(0,H.jsxs)(H.Fragment,{children:[Rt.map(e=>(0,H.jsxs)("span",{className:"inline-flex items-center gap-1 pl-2.5 pr-1 py-1 bg-blue-50 text-blue-700 rounded-full text-xs font-medium",children:[e.label,(0,H.jsx)("button",{onClick:e.clear,className:"p-0.5 hover:bg-blue-100 rounded-full","aria-label":`Remove ${e.label} filter`,children:(0,H.jsx)(y.A,{className:"w-3.5 h-3.5"})})]},e.key)),(0,H.jsx)("button",{onClick:()=>{ne(""),le("all"),Ae("all"),Fe(""),Me(""),Te("all"),Re(""),Le(""),Ue("all"),Be(""),_e("")},className:"ml-1 text-xs font-semibold text-slate-500 hover:text-slate-700 underline",children:"Clear all"})]})}),(0,H.jsxs)("div",{className:"text-sm text-slate-600 whitespace-nowrap",children:["Showing ",At.length," of"," ",R.filter(e=>!e.isDeleted&&"deleted"!==e.status).length," ","students"]})]})]})]}),"folders"===U&&(0,H.jsxs)("section",{className:"mb-8",children:[(0,H.jsx)("div",{className:"mb-3 flex items-center justify-between gap-4",children:(0,H.jsxs)("div",{children:[(0,H.jsx)("h2",{className:"font-semibold text-slate-900",children:"Cohort folders"}),(0,H.jsx)("p",{className:"text-sm text-slate-500",children:"Open a folder to work directly with students in that scheduled cohort."})]})}),(0,H.jsx)("div",{className:"grid gap-3 sm:grid-cols-2 lg:grid-cols-3",children:wt.map(e=>{var t,s;const a=null!==(t=e.sessions[0])&&void 0!==t&&t.startAt?Q(e.sessions[0].startAt):null,n=null!==(s=e.sessions.at(-1))&&void 0!==s&&s.startAt?Q(e.sessions.at(-1).startAt):null,r=a?`${a.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}${n&&n.getTime()!==a.getTime()?` \u2013 ${n.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"})}`:""}`:"Schedule pending";return(0,H.jsxs)("button",{type:"button",onClick:()=>z(e.id),className:"flex min-h-28 items-start gap-3 rounded-xl border p-4 text-left transition "+(U===e.id?"border-blue-500 bg-blue-50":"border-slate-200 bg-white hover:border-blue-300"),children:[(0,H.jsx)(k.A,{className:"h-7 w-7 shrink-0 text-blue-700"}),(0,H.jsxs)("div",{className:"min-w-0",children:[(0,H.jsx)("p",{className:"truncate font-semibold text-slate-900",children:e.title}),(0,H.jsx)("p",{className:"mt-1 text-xs text-slate-500",children:r}),(0,H.jsxs)("p",{className:"mt-1 text-xs font-medium text-slate-600",children:[e.memberCount," student",1===e.memberCount?"":"s"]})]})]},e.id)})})]}),"folders"!==U&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-3",children:[(0,H.jsxs)("button",{type:"button",onClick:()=>{z("folders"),xe([]),ne("")},className:"inline-flex items-center gap-2 text-sm font-semibold text-blue-700 hover:text-blue-900",children:[(0,H.jsx)(x.A,{className:"h-4 w-4"})," Back to cohort folders"]}),(0,H.jsxs)("div",{className:"flex items-center gap-3",children:[(0,H.jsxs)("span",{className:"text-sm text-slate-500",children:[At.length," student",1===At.length?"":"s"]}),(0,H.jsxs)("button",{type:"button",onClick:()=>Tt(Nt,"Cohort invitations sent"),disabled:Je,className:"inline-flex items-center gap-2 rounded-lg bg-slate-900 px-3 py-2 text-sm font-semibold text-white hover:bg-slate-800 disabled:opacity-50",children:[(0,H.jsx)(f.A,{className:"h-4 w-4"}),Je?"Sending\u2026":"Invite students without accounts"]}),"unassigned"!==U&&(0,H.jsxs)("button",{type:"button",onClick:async()=>
1{if("unassigned"!==U&&"folders"!==U){Ke(!0);try{var e;const[t,a]=await Promise.all([(0,r.Rr)((0,r.P)((0,r.rJ)(r.db,"students"),(0,r.My)("registrationDate","desc"))),(0,r.Rr)((0,r.rJ)(r.db,"classSchedules"))]),n=t.docs.map(e=>({id:e.id,...e.data()})),l=a.docs.map(e=>({id:e.id,...e.data()})).filter(e=>"cancelled"!==e.status&&(e.seriesId||e.id)===U).sort((e,t)=>Q(e.startAt)-Q(t.startAt));if(!l.length)throw new Error("This cohort no longer has an active schedule.");const o={id:U,title:(null===(e=l[0])||void 0===e?void 0:e.title)||"Scheduled cohort",sessions:l},i=new Set(l.map(e=>e.id)),d=n.filter(e=>e.scheduleSeriesId===U||!e.scheduleSeriesId&&i.has(e.scheduleId)),c=await _({cohort:o,students:d}),u=(new Date).toISOString(),m=(0,r.KR)(r.IG,jt(U)),h=await(0,r.D)(m,c.blob,{contentType:"application/pdf",cacheControl:"no-store, max-age=0",customMetadata:{cohortId:U,cohortTitle:o.title,displayName:c.fileName,generatedAt:u,studentCount:String(c.count)}}),p=await(0,r.qk)(h.ref);Xe({url:`${p}${p.includes("?")?"&":"?"}v=${encodeURIComponent(u)}`,name:c.fileName,generatedAt:u,count:c.count}),s(`${c.count} clinical badge${1===c.count?"":"s"} generated on ${c.pages} print page${1===c.pages?"":"s"}. Clinical date: ${c.clinicalDate}.`)}catch(t){s(t.message||"Unable to generate clinical badges.")}finally{Ke(!1)}}else s("Choose a scheduled cohort before generating clinical badges.")},disabled:Ze,className:"inline-flex items-center gap-2 rounded-lg border border-blue-200 bg-blue-50 px-3 py-2 text-sm font-semibold text-blue-800 hover:bg-blue-100 disabled:opacity-50",children:[(0,H.jsx)(F.A,{className:"h-4 w-4"}),Ze?"Generating\u2026":"Generate clinical badges"]})]})]}),(0,H.jsxs)("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-200 overflow-hidden",children:[(0,H.jsx)("div",{className:"overflow-x-auto",children:(0,H.jsxs)("table",{className:"min-w-full divide-y divide-slate-200",children:[(0,H.jsx)("thead",{className:"bg-slate-50",children:(0,H.jsxs)("tr",{children:[(0,H.jsx)("th",{className:"px-3 py-3 text-left",children:(0,H.jsx)("input",{type:"checkbox",checked:pe.length===kt.length&&kt.length>0,onChange:()=>{pe.length===kt.length?xe([]):xe(kt.map(e=>e.id))},className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"})}),(0,H.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Student"}),(0,H.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Age"}),(0,H.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Status"}),(0,H.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Expected Completion"}),(0,H.jsx)("th",{className:"px-6 py-3 text-left text-xs font-medium text-slate-500 uppercase tracking-wider",children:"Actions"})]})}),(0,H.jsx)("tbody",{className:"bg-white divide-y divide-slate-200",children:kt.map(t=>(0,H.jsxs)("tr",{className:`${(0,h.Y_)(t.status)} transition-colors`,children:[(0,H.jsx)("td",{className:"px-3 py-4",children:(0,H.jsx)("input",{type:"checkbox",checked:pe.includes(t.id),onChange:()=>{return e=t.id,void xe(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]);var e},className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"})}),(0,H.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,H.jsxs)("div",{className:"flex items-center",children:[(0,H.jsx)("div",{className:"flex-shrink-0 h-10 w-10",children:(0,H.jsx)(m.A,{name:t.fullName,src:t.profilePhoto,fallbackSrc:Ne[t.id],preview:!0})}),(0,H.jsxs)("div",{className:"ml-4",children:[(0,H.jsx)("div",{className:"text-sm font-medium text-slate-900",children:J(t.fullName)}),(0,H.jsx)("div",{className:"text-sm text-slate-500",children:t.countryOfOrigin||"Country not specified"})]})]})}),(0,H.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-slate-900",children:t.dateOfBirth?(()=>{const e=new Date(t.dateOfBirth),s=new Date;let a=s.getFullYear()-e.getFullYear();const n=s.getMonth()-e.getMonth();return(n<0||0===n&&s.getDate()<e.getDate())&&a--,`${a} yrs`})():"N/A"}),(0,H.jsx)("td",{className:"px-6 py-4 whitespace-nowrap",children:(0,H.jsx)(ae,{status:t.status})}),(0,H.jsx)("td",{className:"px-6 py-4 whitespace-nowrap text-sm text-slate-900",children:(()=>{let e=t.expectedCompletionDate;if(!e&&t.courseStartDate){const s=(0,o.j)(t.courseStartDate);
1s&&(e=s.toISOString())}const s=Q(e);if(!s)return"N/A";const a=Math.ceil((s-new Date)/864e5);return(0,H.jsxs)("div",{className:"flex items-center gap-2",children:[(0,H.jsx)("span",{children:(0,l.GP)(s,"MMM dd, yyyy")}),a>0?(0,H.jsxs)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-semibold "+(a<=3?"bg-red-100 text-red-700":a<=7?"bg-amber-100 text-amber-700":"bg-blue-100 text-blue-700"),children:[a,"d"]}):0===a?(0,H.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-semibold bg-green-100 text-green-700",children:"Today"}):(0,H.jsx)("span",{className:"inline-flex items-center px-1.5 py-0.5 rounded-full text-xs font-semibold bg-slate-100 text-slate-500",children:"Done"})]})})()}),(0,H.jsxs)("td",{className:"px-6 py-4 whitespace-nowrap text-sm font-medium",children:[(0,H.jsxs)("button",{onClick:()=>(e=>{ht(e),xt(""),ft("")})(t),className:"mr-2 inline-flex items-center rounded-md border border-slate-300 bg-white px-3 py-1 text-sm font-medium leading-4 text-slate-700 transition-colors hover:border-blue-300 hover:bg-blue-50 hover:text-blue-700",children:[(0,H.jsx)($.A,{className:"mr-1 h-4 w-4"}),"Move cohort"]}),(0,H.jsxs)("button",{onClick:()=>{return s=t.id,void e(`/dashboard/student/${s}`);var s},className:"inline-flex items-center px-3 py-1 border border-transparent text-sm leading-4 font-medium rounded-md text-blue-600 bg-blue-100 hover:bg-blue-200 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors",children:[(0,H.jsx)(M.A,{className:"w-4 h-4 mr-1"}),"View"]}
1)]})]},t.id))})]})}),Ft>1&&(0,H.jsxs)("div",{className:"bg-slate-50 px-6 py-3 flex items-center justify-between border-t border-slate-200",children:[(0,H.jsxs)("div",{className:"flex-1 flex justify-between sm:hidden",children:[(0,H.jsx)("button",{onClick:()=>ie(Math.max(1,oe-1)),disabled:1===oe,className:"relative inline-flex items-center px-4 py-2 border border-slate-300 text-sm font-medium rounded-md text-slate-700 bg-white hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Previous"}),(0,H.jsx)("button",{onClick:()=>ie(Math.min(Ft,oe+1)),disabled:oe===Ft,className:"ml-3 relative inline-flex items-center px-4 py-2 border border-slate-300 text-sm font-medium rounded-md text-slate-700 bg-white hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed",children:"Next"})]}),(0,H.jsxs)("div",{className:"hidden sm:flex-1 sm:flex sm:items-center sm:justify-between",children:[(0,H.jsx)("div",{children:(0,H.jsxs)("p",{className:"text-sm text-slate-700",children:["Showing"," ",(0,H.jsx)("span",{className:"font-medium",children:(oe-1)*de+1})," ","to"," ",(0,H.jsx)("span",{className:"font-medium",children:Math.min(oe*de,At.length)})," ","of"," ",(0,H.jsx)("span",{className:"font-medium",children:At.length})," ","results"]})}),(0,H.jsx)("div",{children:(0,H.jsxs)("nav",{className:"relative z-0 inline-flex rounded-md shadow-sm -space-x-px",children:[(0,H.jsx)("button",{onClick:()=>ie(Math.max(1,oe-1)),disabled:1===oe,className:"relative inline-flex items-center px-2 py-2 rounded-l-md border border-slate-300 bg-white text-sm font-medium text-slate-500 hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed",children:(0,H.jsx)(x.A,{className:"h-5 w-5"})}),[...Array(Ft)].map((e,t)=>{const s=t+1;return(0,H.jsx)("button",{onClick:()=>ie(s),className:"relative inline-flex items-center px-4 py-2 border text-sm font-medium "+(oe===s?"z-10 bg-blue-50 border-blue-500 text-blue-600":"bg-white border-slate-300 text-slate-500 hover:bg-slate-50"),children:s},s)}),(0,H.jsx)("button",{onClick:()=>ie(Math.min(Ft,oe+1)),disabled:oe===Ft,className:"relative inline-flex items-center px-2 py-2 rounded-r-md border border-slate-300 bg-white text-sm font-medium text-slate-500 hover:bg-slate-50 disabled:opacity-50 disabled:cursor-not-allowed",children:(0,H.jsx)(N.A,{className:"h-5 w-5"})})]})})]})]})]}),"unassigned"!==U&&(0,H.jsx)("section",{className:"mt-4 rounded-2xl border border-slate-200 bg-white p-5 shadow-sm","aria-label":"Latest generated cohort badge file",children:(0,H.jsxs)("div",{className:"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",children:[(0,H.jsxs)("div",{className:"flex items-start gap-3",children:[(0,H.jsx)("div",{className:"rounded-lg bg-blue-50 p-2.5 text-blue-700",children:(0,H.jsx)(F.A,{className:"h-6 w-6"})}),(0,H.jsxs)("div",{children:[(0,H.jsx)("h3",{className:"font-semibold text-slate-900",children:"Latest generated badge file"}),et?(0,H.jsx)("p",{className:"mt-1 text-sm text-slate-500",children:"Checking for the latest cohort badge sheet\u2026"}):Ve?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)("p",{className:"mt-1 text-sm font-medium text-slate-700",children:Ve.name}),(0,H.jsxs)("p",{className:"mt-1 text-xs text-slate-500",children:["Generated ",Ve.generatedAt?new Date(Ve.generatedAt).toLocaleString():"recently",Ve.count?` \xb7 ${Ve.count} student${1===Ve.count?"":"s"}`:""]})]}):(0,H.jsx)("p",{className:"mt-1 text-sm text-slate-500",children:"No badge file has been generated for this cohort yet."})]})]}),Ve&&(0,H.jsxs)("a",{href:Ve.url,target:"_blank",rel:"noreferrer",download:Ve.name,className:"inline-flex items-center justify-center gap-2 rounded-lg bg-blue-700 px-4 py-2.5 text-sm font-semibold text-white hover:bg-blue-800",children:[(0,H.jsx)(D.A,{className:"h-4 w-4"})," Open latest badges"]})]})}),0===At.length&&!B&&(0,H.jsxs)("div",{className:"bg-white rounded-2xl shadow-sm border border-slate-200 p-16 text-center",children:[(0,H.jsx)(E.A,{className:"w-12 h-12 text-slate-400 mx-auto mb-4"}),(0,H.jsx)("h3",{className:"text-lg font-medium text-slate-900 mb-2",children:"No students found"}),(0,H.jsx)("p",{className:"text-slate-600",children:Z||"all"!==re?"Try adjusting your search or filter criteria.":"No students have been registered yet."})]})]})]}),mt&&(0,H.jsx)("div",{className:"fixed inset-0 z-[70] flex items-center justify-center bg-slate-950/55 p-4",role:"dialog","aria-modal":"true","aria-labelledby":"move-cohort-title",onMouseDown:e=>e.target===e.currentTarget&&Mt(),children:(0,H.jsxs)("div",{className:"w-full max-w-2xl overflow-hidden rounded-2xl bg-white shadow-2xl",children:[(0,H.jsxs)("div",{className:"flex items-start justify-between border-b border-slate-200 px-6 py-5",children:[(0,H.jsxs)("div",{children:[(0,H.jsx)("p",{className:"text-xs font-bold uppercase tracking-wider text-blue-700",children:"Student scheduling"}),(0,H.jsxs)("h2",{id:"move-cohort-title",className:"mt-1 text-xl font-bold text-slate-950",children:["Move ",J(mt.fullName)," to another cohort"]}),(0,H.jsx)("p",{className:"mt-1 text-sm text-slate-500",children:"This updates the student profile, enrollment agreement dates, class roster, attendance membership, portal schedule, and active cohort links."})]}),(0,H.jsx)("button",{type:"button",onClick:Mt,disabled:bt,className:"rounded-lg p-2 text-slate-400 hover:bg-slate-100 hover:text-slate-700 disabled:opacity-50","aria-label":"Close cohort move",children:(0,H.jsx)(y.A,{className:"h-5 w-5"})})]}),(0,H.jsxs)("div",{className:"max-h-[65vh] overflow-y-auto px-6 py-5",children:[(0,H.jsxs)("label",{className:"block text-sm font-semibold text-slate-800",children:["Destination cohort",(0,H.jsxs)("select",{value:pt,onChange:e=>xt(e.target.value),className:"mt-2 w-full rounded-xl border border-slate-300 bg-white px-3 py-3 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200",children:[(0,H.jsx)("option",{value:"",children:"Choose a future or active cohort\u2026"}),Et.map(e=>{var t,s;const a=Q(null===(t=e.sessions[0])||void 0===t?void 0:t.startAt),n=Q(null===(s=e.sessions.at(-1))||void 0===s?void 0:s.startAt);return(0,H.jsxs)("option",{value:e.id,children:[e.title," \u2014 ",a?(0,l.GP)(a,"MMM d, yyyy"):"date pending",n&&(null===a||void 0===a?void 0:a.getTime())!==n.getTime()?` to ${(0,l.GP)(n,"MMM d, yyyy")}`:""," (",e.memberCount," enrolled)"]},e.id)})]})]}),!Et.length&&(0,H.jsx)("p",{className:"mt-3 rounded-lg border border-amber-200 bg-amber-50 px-4 py-3 text-sm text-amber-800",children:"No compatible future or active cohorts are available for this student\u2019s current program."}),(0,H.jsxs)("label",{className:"mt-5 block text-sm font-semibold text-slate-800",children:["Note for the student ",(0,H.jsx)("span",{className:"font-normal text-slate-400",children:"(optional)"}
1),(0,H.jsx)("textarea",{value:gt,onChange:e=>ft(e.target.value),maxLength:500,rows:3,placeholder:"For example: Your requested postponement has been approved.",className:"mt-2 w-full resize-none rounded-xl border border-slate-300 px-3 py-3 text-sm focus:border-blue-500 focus:outline-none focus:ring-2 focus:ring-blue-200"})]}),(0,H.jsxs)("div",{className:"mt-5 rounded-xl border border-blue-200 bg-blue-50 p-4 text-sm leading-6 text-blue-900",children:[(0,H.jsx)("strong",{children:"Records policy:"})," previously signed or marked attendance remains in the historical record. Pending signature requests and active exam links for the old cohort are revoked. Attendance is never copied onto dates the student did not attend."]})]}),(0,H.jsxs)("div",{className:"flex flex-col-reverse gap-3 border-t border-slate-200 bg-slate-50 px-6 py-4 sm:flex-row sm:justify-end",children:[(0,H.jsx)("button",{type:"button",onClick:Mt,disabled:bt,className:"rounded-lg border border-slate-300 bg-white px-4 py-2.5 text-sm font-semibold text-slate-700 hover:bg-slate-100 disabled:opacity-50",children:"Cancel"}),(0,H.jsxs)("button",{type:"button",onClick:async()=>{if(!mt||!pt)return;const e=wt.find(e=>e.id===pt);if(e){vt(!0);try{const t=await(0,r.Ij)("moveStudentToCohort",{studentId:mt.id,targetCohortId:e.id,reason:gt.trim()});xe(e=>e.filter(e=>e!==mt.id)),z(e.id),ht(null),xt(""),ft("");const a=t.refreshedAgreements?` ${t.refreshedAgreements} unsigned enrollment agreement${1===t.refreshedAgreements?" was":"s were"} refreshed with the new dates.`:t.replacementAgreementRequired?" The existing signed agreement was preserved, and the profile is flagged for a new replacement agreement.":"";s(t.emailSent?`${mt.fullName} was moved to ${e.title}. Their profile, roster, attendance membership, enrollment, and agreement dates were synchronized, and the student was emailed.${a}`:`${mt.fullName} was moved to ${e.title}, but the email could not be delivered: ${t.emailError||"unknown email error"}.${a}`,{type:t.emailSent?"success":"warning",title:t.emailSent?"Cohort move complete":"Moved; email needs attention"})}catch(t){s(t.message||"The student could not be moved.",{type:"error",title:"Cohort move failed"})}finally{vt(!1)}}},disabled:!pt||bt,className:"inline-flex items-center justify-center gap-2 rounded-lg bg-blue-700 px-5 py-2.5 text-sm font-semibold text-white hover:bg-blue-800 disabled:cursor-not-allowed disabled:opacity-50",children:[bt?(0,H.jsx)(q,{size:"small"}):(0,H.jsx)($.A,{className:"h-4 w-4"}),bt?"Moving student\u2026":"Move student and notify"]})]})]})}),ge&&(0,H.jsx)("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-75 flex items-center justify-center z-50",children:(0,H.jsxs)("div",{className:"bg-white rounded-lg p-6 max-w-md w-full",children:[(0,H.jsxs)("div",{className:"flex items-center mb-4",children:[(0,H.jsx)(T.A,{className:"h-6 w-6 text-yellow-600 mr-2"}),(0,H.jsx)("h3",{className:"text-lg font-medium text-gray-900",children:"Confirm Mass Action"})]}),(0,H.jsxs)("p",{className:"text-sm text-gray-500 mb-4",children:["You are about to update ",pe.length," student",pe.length>1?"s":""," to"," ",(0,H.jsx)("span",{className:"font-semibold",children:be}
1)," status.","graduated"===be&&" This will set their graduation date to today.","completed"===be&&" This will set their completion date to today."]}),(0,H.jsx)("div",{className:"bg-yellow-50 border border-yellow-200 rounded-md p-3 mb-4",children:(0,H.jsxs)("p",{className:"text-sm text-yellow-800",children:[(0,H.jsx)("strong",{children:"Warning:"})," This action cannot be undone. Please make sure you have selected the correct students."]})}),(0,H.jsxs)("div",{className:"flex justify-end space-x-3",children:[(0,H.jsx)("button",{onClick:()=>{fe(!1),ve("")},className:"px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-gray-500",disabled:ye,children:"Cancel"}),(0,H.jsx)("button",{onClick:async()=>{if(be&&0!==pe.length){we(!0);try{const e=(0,r.wP)(r.db),t={status:be,lastUpdated:new Date};"graduated"===be?t.graduationDate=(0,l.GP)(new Date,"yyyy-MM-dd"):"completed"===be&&(t.completionDate=(0,l.GP)(new Date,"yyyy-MM-dd")),pe.forEach(s=>{const a=(0,r.H9)(r.db,"students",s);e.update(a,t)}),await e.commit(),xe([]),fe(!1),ve(""),s(`Successfully updated ${pe.length} students to ${be} status`,{type:"success",title:"Update Complete"})}catch(e){console.error("Error performing mass action:",e),s("Error updating students. Please try again.",{type:"error",title:"Error"})}finally{we(!1)}}},className:`px-4 py-2 border border-transparent rounded-md text-sm font-medium text-white focus:outline-none focus:ring-2 focus:ring-offset-2 ${"graduated"===be?"bg-purple-600 hover:bg-purple-700 focus:ring-purple-500":"completed"===be?"bg-blue-600 hover:bg-blue-700 focus:ring-blue-500":"bg-green-600 hover:bg-green-700 focus:ring-green-500"} ${ye?"opacity-50 cursor-not-allowed":""}`,disabled:ye,children:ye?(0,H.jsxs)("span",{className:"flex items-center",children:[(0,H.jsx)(q,{size:"small"}),(0,H.jsx)("span",{className:"ml-2",children:"Updating..."})]}):`Confirm Update to ${be}`})]})]})}),st&&(0,H.jsx)("div",{className:"fixed inset-0 bg-gray-500 bg-opacity-75 flex items-center justify-center z-50 p-4",children:(0,H.jsxs)("div",{className:"bg-white rounded-2xl p-6 max-w-md w-full max-h-[85vh] overflow-y-auto",children:[(0,H.jsxs)("div",{className:"flex items-center justify-between mb-4",children:[(0,H.jsx)("h3",{className:"text-lg font-semibold text-gray-900",children:"Export Options"}),(0,H.jsx)("button",{onClick:()=>at(!1),className:"p-1 hover:bg-gray-100 rounded-lg",children:(0,H.jsx)(y.A,{className:"w-5 h-5 text-gray-500"})})]}),(0,H.jsxs)("div",{className:"mb-4 p-3 bg-slate-50 rounded-lg border border-slate-200",children:[(0,H.jsxs)("div",{className:"flex items-center gap-2 mb-2",children:[(0,H.jsx)(A.A,{className:"w-4 h-4 text-slate-400"}),(0,H.jsx)("span",{className:"text-sm font-medium text-slate-700",children:"Payments date range (optional)"})]}),(0,H.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,H.jsx)("input",{type:"date",value:it,onChange:e=>dt(e.target.value),className:"border border-slate-300 rounded-lg px-3 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","aria-label":"Payments from"}),(0,H.jsx)("span",{className:"text-slate-400 text-sm",children:"to"}),(0,H.jsx)("input",{type:"date",value:ct,onChange:e=>ut(e.target.value),className:"border border-slate-300 rounded-lg px-3 py-1.5 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500","aria-label":"Payments to"}),(it||ct)&&(0,H.jsx)("button",{onClick:()=>{dt(""),ut("")},className:"ml-1 text-xs font-semibold text-slate-500 hover:text-slate-700 underline",children:"Clear"})]}),(0,H.jsx)("p",{className:"text-xs text-slate-500 mt-2",children:"\u201cTotal Paid\u201d counts only payments in this range. \u201cBalance (Dues)\u201d always shows current outstanding."})]}),(0,H.jsx)("p",{className:"text-sm font-medium text-gray-700 mb-2",children:"Columns to include"}),(0,H.jsxs)("div",{className:"flex items-center gap-3 mb-3",children:[(0,H.jsx)("button",{onClick:()=>ot((0,d.Qy)()),className:"text-xs font-semibold text-blue-600 hover:text-blue-700",children:"Select all"}),(0,H.jsx)("button",{onClick:()=>ot(d.$y.reduce((e,t)=>
1(e[t.key]=!1,e),{})),className:"text-xs font-semibold text-slate-500 hover:text-slate-700",children:"Clear all"})]}),(0,H.jsx)("div",{className:"space-y-1",children:d.$y.map(e=>(0,H.jsxs)("label",{className:"flex items-center gap-3 p-2 rounded-lg hover:bg-slate-50 cursor-pointer",children:[(0,H.jsx)("input",{type:"checkbox",checked:!!lt[e.key],onChange:()=>ot(t=>({...t,[e.key]:!t[e.key]})),className:"h-4 w-4 text-blue-600 focus:ring-blue-500 border-gray-300 rounded"}),(0,H.jsx)("span",{className:"text-sm text-gray-700",children:e.header})]},e.key))}),(0,H.jsxs)("div",{className:"flex justify-end gap-3 mt-6",children:[(0,H.jsx)("button",{onClick:()=>at(!1),className:"px-4 py-2 border border-gray-300 rounded-lg text-sm font-medium text-gray-700 bg-white hover:bg-gray-50",children:"Done"}),(0,H.jsxs)("button",{onClick:()=>{at(!1),It()},className:"inline-flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-medium text-white bg-emerald-600 hover:bg-emerald-700",children:[(0,H.jsx)(D.A,{className:"w-4 h-4"})," Export now"]})]})]})})]})}},92375:(e,t,s)=>{s.d(t,{A:()=>l});var a=s(9950),n=s(17119),r=s(44414);const l=e=>{let{name:t,src:s,fallbackSrc:l,className:o="h-10 w-10",preview:i=!1}=e;const d=s||l||"",[c,u]=(0,a.useState)(d),[m,h]=(0,a.useState)(null),p=(0,a.useRef)(null),x=(0,a.useRef)(null),g=(0,a.useId)(),f=()=>clearTimeout(x.current),b=()=>{f(),x.current=setTimeout(()=>h(null),120)},v=()=>{if(f(),!i||!c||!p.current)return;const e=p.current.getBoundingClientRect(),t=Math.min(272,window.innerWidth-24),s=Math.min(320,window.innerHeight-24);h({width:t,left:Math.max(12,Math.min(e.right+12,window.innerWidth-t-12)),top:Math.max(12,Math.min(e.top,window.innerHeight-s-12))})};(0,a.useEffect)(()=>()=>clearTimeout(x.current),[]),(0,a.useEffect)(()=>{if(!m)return;const e=()=>h(null),t=t=>{"Escape"===t.key&&e()};return window.addEventListener("scroll",e,!0),window.addEventListener("resize",e),window.addEventListener("keydown",t),()=>{window.removeEventListener("scroll",e,!0),window.removeEventListener("resize",e),window.removeEventListener("keydown",t)}},[m]),(0,a.useEffect)(()=>{u(s||l||""),h(null)},[s,l]);const y=()=>{u(c===s&&l&&l!==s?l:"")},w=i&&!!c,N=w?"button":"div";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(N,{ref:p,...w?{type:"button","aria-label":`Preview photo of ${t||"student"}`,"aria-describedby":m?g:void 0,onMouseEnter:v,onMouseLeave:b,onFocus:v,onBlur:b,onClick:e=>{e.stopPropagation(),v()}}:{},className:`${o} flex-shrink-0 overflow-hidden rounded-full bg-gradient-to-br from-blue-500 to-purple-600 flex items-center justify-center ${w?"cursor-zoom-in focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-blue-600 focus-visible:ring-offset-2":""}`,children:c?(0,r.jsx)("img",{src:c,alt:t||"Student",className:"h-full w-full object-cover",onError:y}):(0,r.jsx)("span",{className:"text-sm font-medium text-white",children:String(t||"").trim().charAt(0).toUpperCase()||"?"})}),w&&m&&(0,n.createPortal)((0,r.jsxs)("div",{id:g,role:"tooltip",onMouseEnter:f,onMouseLeave:b,className:"fixed z-[100] rounded-xl border border-slate-200 bg-white p-3 shadow-2xl",style:m,children:[(0,r.jsx)("img",{src:c,alt:`Enlarged photo of ${t||"student"}`,onError:y,className:"w-full rounded-lg bg-slate-50 object-contain",style:{height:Math.min(248,window.innerHeight-96)}}),(0,r.jsx)("p",{className:"mt-2 truncate text-center text-sm font-medium text-slate-800",children:t||"Student"})]}),document.body)]})}}}]);
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.