PageSourceSearch

https://online.timganmath.edu.sg/_next/static/chunks/50372-10baac459cf1e7a6.js

js timganmath.edu.sg collected 2026-09-30 14:36:28 UTC 46,415 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[50372],{8787:(e,s,a)=>{function t(e){return Number.isFinite(e)&&Number(e)>0?Math.floor(Number(e)):0}function r(e){return Number.isFinite(e.student_occupancy)?t(e.student_occupancy):Math.max(t(e.current_enrollment),t(e.enrolled_students))}function n({sessionId:e,linkedSessionId:s,participantCount:a}){if(s&&e===s)return"linked_trial";let r=t(a);return 0===r?"soft_hold":1===r?"join_second":"full"}function l({isEnquiry:e,isOneToOne:s,hasTrialParticipant:a,hasLinkedSession:t,status:r}){return e&&s&&a&&t&&["trial_lessons","pending_registration","pending_payment","pending_approval","completed"].includes(r)}a.d(s,{SK:()=>n,gx:()=>l,mG:()=>r})},22538:(e,s,a)=>{a.d(s,{C:()=>o,z:()=>d});var t=a(37876),r=a(14232),n=a(66841),l=a(35137),i=a(1773);let d=r.forwardRef(({className:e,...s},a)=>(0,t.jsx)(n.bL,{className:(0,i.cn)("grid gap-2",e),...s,ref:a}));d.displayName=n.bL.displayName;let o=r.forwardRef(({className:e,...s},a)=>(0,t.jsx)(n.q7,{ref:a,className:(0,i.cn)("aspect-square h-4 w-4 rounded-full border border-primary text-primary shadow focus:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",e),...s,children:(0,t.jsx)(n.C1,{className:"flex items-center justify-center",children:(0,t.jsx)(l.A,{className:"h-3.5 w-3.5 fill-current text-primary"})})}));o.displayName=n.q7.displayName},34776:(e,s,a)=>{a.d(s,{D:()=>c});var t=a(37876),r=a(14232),n=a(3033),l=a(53757),i=a(60067),d=a(83529),o=a(1773);let c=r.forwardRef(({value:e,onValueChange:s,onClear:a,clearLabel:c="Clear search",containerClassName:u,className:m,disabled:h,readOnly:x,placeholder:g="Search…","aria-label":p,role:f="searchbox",onKeyDown:_,...b},v)=>{let j=r.useRef(null),N=r.useCallback(e=>{j.current=e,"function"==typeof v?v(e):v&&(v.current=e)},[v]),y=r.useCallback(()=>{!e||h||x||(s(""),a?.(),j.current?.focus())},[h,a,s,x,e]),w=r.useCallback(s=>{_?.(s),!s.defaultPrevented&&"Escape"===s.key&&e&&(s.preventDefault(),y())},[y,_,e]),k=!!e&&!h&&!x;return(0,t.jsxs)("div",{className:(0,o.cn)("relative w-full",u),"data-slot":"search-input",children:[(0,t.jsx)(n.A,{className:"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-muted-foreground","aria-hidden":"true"}),(0,t.jsx)(d.p,{...b,ref:N,type:"search",role:f,value:e,disabled:h,readOnly:x,placeholder:g,"aria-label":p??g,onChange:e=>s(e.target.value),onKeyDown:w,className:(0,o.cn)("pl-10 pr-11 [&::-webkit-search-cancel-button]:appearance-none",m)}),k&&(0,t.jsx)(i.$,{type:"button",variant:"ghost",size:"icon","aria-label":c,title:c,onMouseDown:e=>e.preventDefault(),onClick:y,className:"absolute right-0.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",children:(0,t.jsx)(l.A,{"aria-hidden":"true"})})]})});c.displayName="SearchInput"},50372:(e,s,a)=>{a.d(s,{e:()=>v});var t=a(37876),r=a(14232),n=a(70257),l=a(72895),i=a(98592),d=a(79826),o=a(59688),c=a(86271),u=a(60067),m=a(4447),h=a(83529),x=a(31797),g=a(71459),p=a(15117);let f={withdraw_now:"Not continuing",hold:"Hold and follow up",schedule_withdrawal:"Schedule withdrawal",move_to_one_to_one:"Move to one-to-one"},_=[{value:"family_decision",label:"Family decision"},{value:"financial",label:"Financial reason"},{value:"other",label:"Other"},{value:"programme_change",label:"Programme change"},{value:"schedule_conflict",label:"Schedule conflict"},{value:"student_needs",label:"Student needs"}];function b(e=0){let s=new Date;return s.setDate(s.getDate()+e),`${s.getFullYear()}-${String(s.getMonth()+1).padStart(2,"0")}-${String(s.getDate()).padStart(2,"0")}`}function v({open:e,onOpenChange:s,enrollmentId:a,studentId:j,classSessionId:N,studentName:y,curriculumName:w,onSuccess:k}){let[C,S]=(0,r.useState)(null),[A,E]=(0,r.useState)(!1),[$,O]=(0,r.useState)(!1),[L,R]=(0,r.useState)("withdraw_now"),[D,F]=(0,r.useState)(""),[T,P]=(0,r.useState)(""),[I,M]=(0,r.useState)(b(14)),[J,q]=(0,r.useState)(b(30)),[W,z]=(0,r.useState)(b()),[V,H]=(0,r.useState)(""),[K,G]=(0,r.useState)([]),[U,X]=(0,r.useState)({});(0,r.useEffect)(()=>{if(!e)return;let s=new AbortController;return E(!0),S(null),R("withdraw_now"),F(""),P(""),M(b(14)),q(b(30)),z(b()),H(""),G([]),X({}),fetch(`/api/admin/school/enrollments/${a}/change`,{credentials:"include",signal:s.signal}).then(async e=>{let s=await e.json().catch(()=>({}));if(!e.ok)throw Error(s.error||"Failed to load enrollment");S(s)}).catch(e=>{"AbortError"!==e.name&&o.oR.error(e instanceof Error?e.message:"Failed to load enrollment")}).finally(()=>{s.signal.aborted||E(!1)}),()=>s.abort()},[e,a]);let Y=(0,r.useMemo)(()=>(C?.oneToOneCurriculums||[]).map(e=>({id:e.id,name:e.name,academic_year:e.academicYear,grade_level:e.gradeLevel,curriculum_type:"ONE_TO_ONE",one_to_one_hourly_rate:e.defaultHourlyRate})),[C]),B=Y.filter(e=>K.includes(e.id)),Q=K[0],Z=Q?U[Q]:void 0,ee=async()=>{let e;if(!C||!D)return void o.oR.error("Select a reason before continuing");let t={studentId:j,sourceClassSessionId:N,reasonCode:D,...T.trim()?{note:T.trim()}:{}};if("withdraw_now"===L)e={outcome:L,...t};else if("hold"===L){if(!C.hasLinkedEnquiry)return void o.oR.error("Create a follow-up enquiry first, or choose Not continuing");if(!I)return void o.oR.error("Choose a follow-up date");e={outcome:L,...t,followUpDate:I}}else if("schedule_withdrawal"===L){if(!J)return void o.oR.error("Choose a future withdrawal date");e={outcome:L,...t,effectiveDate:J}}else{if(!Q||!Z)return void o.oR.error("Choose and configure a one-to-one curriculum");if(!Z.syllabus_id||!Z.grade_level)return void o.oR.error("Syllabus and grade are required for one-to-one enrollment");e={outcome:L,...t,targetCurriculumId:Q,startDate:W,syllabusId:Z.syllabus_id,gradeLevel:Z.grade_level,dayOfWeek:Z.day_of_week,startTime:Z.start_time,endTime:Z.end_time,durationMinutes:Z.duration_minutes,createRecurringLessons:Z.create_recurring_lessons,...Z.classroom_id?{classroomId:Z.classroom_id}:{},...Z.location?{location:Z.location}:{},...Z.existing_session_id?{existingSessionId:Z.existing_session_id}:{},...C.canEditFinance&&void 0!==Z.fee_per_lesson?{feePerLesson:Z.fee_per_lesson}:{},...C.canEditFinance&&V?{billableHoursPerCredit:Number(V)}:{}}}O(!0);try{let t=await fetch(`/api/admin/school/enrollments/${a}/change`,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(e)}),r=await t.json().catch(()=>({}));if(!t.ok)return void(r.result?.recoverable?o.oR.error(`${r.error} The private enrollment was retained; Retry is safe.`):o.oR.error(r.error||"Enrollment change failed"));o.oR.success(r.message||"Enrollment updated"),k?.(r),s(!1)}catch(e){o.oR.error(e instanceof Error?e.message:"Enrollment change failed")}finally{O(!1)}};return(0,t.jsx)(m.lG,{open:e,onOpenChange:s,children:(0,t.jsxs)(m.Cf,{className:"max-h-[90vh] overflow-y-auto sm:max-w-2xl",children:[(0,t.jsxs)(m.c7,{children:[(0,t.jsxs)(m.L3,{className:"flex items-center gap-2",children:[(0,t.jsx)(n.A,{className:"h-5 w-5","aria-hidden":"true"}),"Manage Enrollment"]}),(0,t.jsxs)(m.rr,{children:[y," \xb7 ",w,". The approved registration and historical records will stay unchanged."]})]}),A?(0,t.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,t.jsx)(l.A,{className:"h-6 w-6 animate-spin text-muted-foreground"})}):C?(0,t.jsxs)("div",{className:"space-y-5 py-2",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(x.J,{htmlFor:"enrollment-change-outcome",children:"Outcome"}),(0,t.jsxs)(g.l6,{value:L,onValueChange:e=>R(e),children:[(0,t.jsx)(g.bq,{id:"enrollment-change-outcome",children:(0,t.jsx)(g.yv,{})}),(0,t.jsxs)(g.gC,{children:[(0,t.jsx)(g.eb,{value:"withdraw_now",children:"Not continuing"}),(0,t.jsx)(g.eb,{value:"hold",disabled:!C.hasLinkedEnquiry,children:"Hold and follow up"}),(0,t.jsx)(g.eb,{value:"schedule_withdrawal",children:"Schedule withdrawal"}),(0,t.jsx)(g.eb,{value:"move_to_one_to_one",disabled:"GROUP"!==C.sourceCurriculumType,children:"Move to one-to-one"})]})]}),"hold"===L&&!C.hasLinkedEnquiry&&(0,t.jsx)("p",{className:"text-sm text-amber-600 dar
1k:text-amber-400",children:"Hold is unavailable because no completed enquiry is linked. Create a follow-up enquiry first; ordinary withdrawal remains available."})]}),"withdraw_now"===L&&(0,t.jsx)("div",{className:"rounded-md border border-amber-500/40 bg-amber-500/10 p-3 text-sm",children:(0,t.jsxs)("div",{className:"flex gap-2",children:[(0,t.jsx)(i.A,{className:"mt-0.5 h-4 w-4 shrink-0 text-amber-600"}),(0,t.jsx)("p",{children:"The seat is released today, class-derived access is revoked, and the linked enquiry is cancelled. Attendance and registration history remain."})]})}),"hold"===L&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(x.J,{htmlFor:"enrollment-follow-up-date",children:"Follow-up date"}),(0,t.jsx)(h.p,{id:"enrollment-follow-up-date",type:"date",min:b(),value:I,onChange:e=>M(e.target.value)}),(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"The seat is released now and the completed enquiry reopens in Follow Up."})]}),"schedule_withdrawal"===L&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(x.J,{htmlFor:"enrollment-effective-date",children:"Last enrollment date"}),(0,t.jsx)(h.p,{id:"enrollment-effective-date",type:"date",min:b(1),value:J,onChange:e=>q(e.target.value)}),(0,t.jsxs)("p",{className:"flex items-center gap-1 text-xs text-muted-foreground",children:[(0,t.jsx)(d.A,{className:"h-3.5 w-3.5"}),"Enrollment remains active until the existing scheduled-withdrawal job processes this date."]})]}),"move_to_one_to_one"===L&&(0,t.jsxs)("div",{className:"space-y-4",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(x.J,{htmlFor:"private-enrollment-start-date",children:"Private enrollment start date"}),(0,t.jsx)(h.p,{id:"private-enrollment-start-date",type:"date",min:b(),value:W,onChange:e=>z(e.target.value)})]}),(0,t.jsx)(c.TN,{selectedIds:K,onChange:e=>{G(e),0===e.length&&X({})},selectedCurriculums:B,availableCurriculums:Y,oneToOneSessionData:U,onOneToOneSessionChange:(e,s)=>{X(a=>{if(!s){let s={...a};return delete s[e],s}return{...a,[e]:s}})},defaultSyllabusId:"",defaultGradeLevel:"",isAdmin:!0,singleSelection:!0,selectionLabel:"One-to-one curriculum",showRecurringOption:!0}),C.canEditFinance&&(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(x.J,{htmlFor:"private-billable-hours",children:"Billable hours per credit (optional)"}),(0,t.jsx)(h.p,{id:"private-billable-hours",type:"number",min:"0.25",max:"24",step:"0.25",value:V,onChange:e=>H(e.target.value),placeholder:"Use curriculum default"})]}),!Z&&Q&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Configure the private schedule, syllabus, grade, and location above."})]}),(0,t.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,t.jsxs)("div",{className:"space-y-2",children:[(0,t.jsx)(x.J,{htmlFor:"enrollment-change-reason",children:"Reason"}),(0,t.jsxs)(g.l6,{value:D,onValueChange:e=>F(e),children:[(0,t.jsx)(g.bq,{id:"enrollment-change-reason",children:(0,t.jsx)(g.yv,{placeholder:"Select reason"})}),(0,t.jsx)(g.gC,{children:_.map(e=>(0,t.jsx)(g.eb,{value:e.value,children:e.label},e.value))})]})]}),(0,t.jsxs)("div",{className:"space-y-2 sm:col-span-2",children:[(0,t.jsx)(x.J,{htmlFor:"enrollment-change-note",children:"Note (optional)"}),(0,t.jsx)(p.T,{id:"enrollment-change-note",value:T,onChange:e=>P(e.target.value),maxLength:1e3,placeholder:"Add context for the internal history"})]})]})]}):(0,t.jsx)("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"Enrollment details could not be loaded."}),(0,t.jsxs)(m.Es,{children:[(0,t.jsx)(u.$,{variant:"outline",onClick:()=>s(!1),disabled:$,children:"Cancel"}),(0,t.jsxs)(u.$,{onClick:ee,disabled:!C||A||$||!D,children:[$&&(0,t.jsx)(l.A,{className:"mr-2 h-4 w-4 animate-spin"}),$?"Updating…":f[L]]})]})]})})}},60711:(e,s,a)=>{a.d(s,{Q:()=>g});var t=a(37876),r=a(14232),n=a(85645),l=a(83791),i=a(83529),d=a(31797),o=a(60067),c=a(67070),u=a(38658),m=a(76669),h=a(1773);function x({label:e,options:s,value:a,onChange:n}){let l=r.useRef(null);return r.useEffect(()=>{let e=l.current,s=e?.querySelector('[aria-checked="true"]');if(e&&s){let a=s.getBoundingClientRect().top-e.getBoundingClientRect().top+e.scrollTop;e.scrollTop=a-(e.clientHeight-s.offsetHeight)/2}},[a]),(0,t.jsxs)("div",{className:"min-w-0 space-y-1",children:[(0,t.jsx)("p",{className:"px-2 text-xs font-medium text-muted-foreground",children:e}),(0,t.jsx)("div",{ref:l,role:"radiogroup","aria-label":e,className:"max-h-48 overflow-y-auto overscroll-contain p-1",children:s.map((e,r)=>(0,t.jsx)("button",{type:"button",role:"radio","aria-checked":a===e,tabIndex:a!==e&&(s.includes(a)||0!==r)?-1:0,className:(0,h.cn)("flex h-10 w-full items-center justify-center rounded-sm text-sm tabular-nums outline-none hover:bg-accent focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-inset",a===e&&"bg-primary text-primary-foreground hover:bg-primary/90"),onClick:()=>n(e),onKeyDown:e=>
1{let a=["ArrowDown","ArrowRight"].includes(e.key)?1:["ArrowUp","ArrowLeft"].includes(e.key)?-1:0,t="Home"===e.key?0:"End"===e.key?s.length-1:a?(r+a+s.length)%s.length:-1;t<0||(e.preventDefault(),n(s[t]),l.current?.querySelectorAll('[role="radio"]')[t]?.focus())},children:e},e))})]})}function g({id:e,label:s,value:a,onValueChange:h,originalValue:p,interval:f=15,disabled:_,error:b}){let[v,j]=r.useState(()=>(0,m.Wk)(a)),[N,y]=r.useState(()=>(0,m.CX)(a)),[w,k]=r.useState(!1),[C,S]=r.useState(!1),A=r.useRef(a),E=r.useRef(null),$=r.useRef(null),O=r.useRef(null),L=r.useRef(!1),R=r.useRef(!1);r.useEffect(()=>{a!==A.current&&(j((0,m.Wk)(a)),y((0,m.CX)(a)),k(!1)),A.current=a},[a]);let D=e=>{A.current=e,h(e)},F=b||(w?(0,m.k6)(a,p,f):""),T=Array.from({length:12},(e,s)=>String(s+1).padStart(2,"0")),P=Array.from({length:Math.ceil(60/f)},(e,s)=>String(s*f).padStart(2,"0")),I=(e,s)=>{let a={...N,[e]:s};y(a);let t=`${a.hour||"--"}:${a.minute||"--"} ${a.period||"--"}`,r=(0,m.N7)(t);j(r?(0,m.Wk)(r):t),D(r||t),k(!0)};return(0,t.jsxs)("div",{className:"min-w-0 space-y-1.5",children:[(0,t.jsx)(d.J,{htmlFor:e,children:s}),(0,t.jsxs)(c.AM,{open:C&&!_,onOpenChange:S,children:[(0,t.jsx)(n.Mz,{asChild:!0,children:(0,t.jsxs)("div",{className:"flex h-10 overflow-hidden rounded-md border border-input bg-background shadow-sm focus-within:ring-1 focus-within:ring-ring sm:h-9",children:[(0,t.jsx)(i.p,{ref:$,id:e,value:v,disabled:_,placeholder:"4:30 PM",autoComplete:"off","aria-haspopup":"dialog","aria-expanded":C,"aria-controls":C?`${e}-picker`:void 0,"aria-invalid":!!F,"aria-describedby":`${e}-hint${F?` ${e}-error`:""}`,className:"h-full w-[7rem] shrink-0 rounded-none border-0 bg-transparent pr-0 shadow-none focus-visible:ring-0 sm:w-[6.5rem]",onChange:e=>{let s=e.target.value;j(s),y((0,m.CX)(s)),D((0,m.N7)(s)||s)},onBlur:()=>{k(!0),(0,m.N7)(a)&&j((0,m.Wk)(a))},onKeyDown:e=>{"ArrowDown"===e.key&&(e.preventDefault(),R.current=!0,S(!0)),"Escape"===e.key&&C&&(e.preventDefault(),e.stopPropagation(),S(!1)),"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),k(!0),(0,m.N7)(a)&&j((0,m.Wk)(a)))}}),(0,t.jsx)(c.Wv,{asChild:!0,children:(0,t.jsx)(o.$,{ref:O,type:"button",variant:"ghost",disabled:_,"aria-label":`Choose ${s.toLowerCase()}`,onClick:()=>{R.current=!1},className:"h-full min-w-10 flex-1 justify-end rounded-none px-3 text-muted-foreground",children:(0,t.jsx)(l.A,{className:"h-4 w-4","aria-hidden":"true"})})})]})}),(0,t.jsx)(c.hl,{ref:E,collisionPadding:8,id:`${e}-picker`,"aria-label":`Choose ${s.toLowerCase()}`,align:"start",className:"w-64 p-2",onOpenAutoFocus:e=>{e.preventDefault(),E.current?.querySelector('[role="radio"][tabindex="0"]')?.focus()},onCloseAutoFocus:e=>{if(L.current){e.preventDefault(),L.current=!1;return}R.current&&(e.preventDefault(),$.current?.focus(),R.current=!1)},onEscapeKeyDown:e=>e.stopPropagation(),onKeyDown:e=>{"Tab"===e.key&&e.shiftKey&&document.activeElement?.closest('[aria-label="Hour"]')&&(e.preventDefault(),R.current=!0,S(!1)),"Tab"===e.key&&!e.shiftKey&&document.activeElement?.closest('[aria-label="AM/PM"]')&&(L.current=!0,O.current?.focus(),S(!1))},children:(0,t.jsx)(u.c,{children:(0,t.jsxs)("div",{className:"grid grid-cols-3 gap-1",children:[(0,t.jsx)(x,{label:"Hour",options:T,value:N.hour,onChange:e=>I("hour",e)}),(0,t.jsx)(x,{label:"Minute",options:P,value:N.minute,onChange:e=>I("minute",e)}),(0,t.jsx)(x,{label:"AM/PM",options:["AM","PM"],value:N.period,onChange:e=>I("period",e)})]})})})]}),(0,t.jsxs)("p",{id:`${e}-hint`,className:"text-xs text-muted-foreground",children:[f,"-minute steps"]}),F&&(0,t.jsx)("p",{id:`${e}-error`,role:"alert",className:"text-sm text-destructive",children:F})]})}},71429:(e,s,a)=>{a.d(s,{Q:()=>i});var t=a(75656),r=a(14232),n=a(45270),l=a(40846);function i(e={}){let{user:s,loading:a,analyticsPermissions:d,isAnalyticsOwner:o}=(0,n.A)(),c=e.enabled??!0,u=c&&!a&&!!s,m=u&&s?["/api/analytics/permissions",s.id]:null,{data:h,isLoading:x,mutate:g}=(0,t.Ay)(m,([e])=>(0,l.IU)(e),{fallbackData:u?{permissions:d,isOwner:o}:void 0,revalidateOnFocus:!1,revalidateOnReconnect:!1,dedupingInterval:6e4}),p=(0,r.useCallback)(e=>!!h?.isOwner||h?.permissions?.includes(e)||!1,[h?.isOwner,h?.permissions]),f=(0,r.useCallback)(async()=>{await g()},[g]);return{permissions:h?.permissions??d,isOwner:h?.isOwner??o,loading:c&&(a||!!s&&x),hasPermission:p,refetch:f}}},79991:(e,s,a)=>{a.d(s,{A:()=>d});var t=a(37876);a(14232);var r=a(7190),n=a(71459),l=a(1773),i=a(29391);function d({options:e,kind:s,value:a,onValueChange:o,label:c,"aria-label":u,id:m,placeholder:h="Select an option",searchPlaceholder:x,emptyMessage:g,className:p,contentClassName:f,disabled:_=!1,loading:b=!1,onOptionPointerEnter:v,onOptionPointerLeave:j,onOptionFocus:N,onClose:y}){let w=u||c||h,k=_||b||0===e.length;return(0,i.uH)(e.length,s)?(0,t.jsx)(r.q,{options:e,value:a,onValueChange:o,label:c,"aria-label":u,placeholder:b?"Loading…":h,searchPlaceholder:x,emptyMessage:g,className:p,popoverClassName:f,disabled:k,loading:b,onOptionPointerEnter:v,onOptionPointerLeave:j,onOptionFocus:N,onClose:y}):(0,t.jsxs)("div",{className:(0,l.cn)("min-w-0",p),children:[c&&(0,t.jsx)("div",{className:"mb-1.5 text-sm font-medium text-foreground",children:c}),(0,t.jsxs)(n.l6,{value:a||"",onValueChange:o,disabled:k,onOpenChange:e=>{e||y?.()},children:[(0,t.jsx)(n.bq,{id:m,"aria-label":w,children:(0,t.jsx)(n.yv,{placeholder:b?"Loading…":h})}),(0,t.jsx)(n.gC,{className:f,children:e.map(e=>(0,t.jsx)(n.eb,{value:e.value,disabled:e.disabled,onPointerEnter:s=>v?.(s,e),onPointerLeave:j,onFocus:s=>N?.(s,e),children:e.label},e.value))})]})]})}},86271:(e,s,a)=>{a.d(s,{TN:()=>H,VX:()=>K});var t=a(37876),r=a(60711),n=a(36980),l=a(14232),i=a(80901),d=a(83836),o=a(60067),c=a(22538),u=a(31797),m=a(83529),h=a(71459),x=a(73548),g=a(61773),p=a(64780),f=a(53757),_=a(72895),b=a(29599),v=a(83791),j=a(33697),N=a(98592),y=a(71442),w=a(36627),k=a(10511),C=a(83551),S=a(16418),A=a(79991),E=a(34776),$=a(97685),O=a(35253),L=a(54347),R=a(64226),D=a(71429),F=a(58877),T=a(56384),P=a(8787),I=a(29391),M=a(92479),J=a(16997);let q=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function W(e){return(0,M.Ke)(e.session_name,e.tutor)}function z(e){if(!e)return null;let[s,a,t]=e.split("-"),r=Number(s),n=Number(a),l=Number(t);if(!Number.isInteger(r)||!Number.isInteger(n)||!Number.isInteger(l))return null;let i=new Date(r,n-1,l);return Number.isNaN(i.getTime())||i.getFullYear()!==r||i.getMonth()!==n-1||i.getDate()!==l?null:i}function V(e){let s=z(e);return s?(0,R.Yq)(s):""}function H({selectedIds:e,onChange:s,selectedCurriculums:a,availableCurriculums:n,linkedCurriculumId:R,linkedSessionId:M,linkedLessonDate:K,hideAddMore:G=!1,regularEnrollment:U=!1,disabled:X=!1,selectedSessions:Y={},onSessionChange:B,oneToOneSessionData:Q={},onOneToOneSessionChange:Z,defaultSyllabusId:ee="",defaultGradeLevel:es="",defaultLocation:ea="",isAdmin:et,singleSelection:er=!1,selectionLabel:en="Curriculum",optionSyllabusId:el="",oneToOneTrialDate:ei="",onOneToOneTrialDateChange:ed,oneToOneTrialDateMode:eo="editable",oneToOneConflictState:ec,showRecurringOption:eu=!0}){let{userRole:em}=(0,L.A)(),{hasPermission:eh}=(0,D.Q)({enabled:et??"ADMIN"===em}),ex=eh(F.oX.FINANCIAL_FULL),[eg,ep]=(0,l.useState)({}),[ef,e_]=(0,l.useState)(new Set),[eb,ev]=(0,l.useState)({}),ej=(0,l.useRef)({}),[eN,ey]=(0,l.useState)({}),[ew,ek]=(0,l.useState)({});(0,l.useEffect)(()=>
1{a.forEach(e=>{if("ONE_TO_ONE"===e.curriculum_type){let s=U?Q[e.id]?.mode:void 0;if(s)return void ek(a=>a[e.id]===s?a:{...a,[e.id]:s});(Y[e.id]||Q[e.id]?.existing_session_id)&&ek(s=>"existing"!==s[e.id]?{...s,[e.id]:"existing"}:s)}})},[a,Y,Q,U]);let[eC,eS]=(0,l.useState)([]),[eA,eE]=(0,l.useState)([]),[e$,eO]=(0,l.useState)([]),[eL,eR]=(0,l.useState)(!1),[eD,eF]=(0,l.useState)(!1),eT=(0,l.useRef)(new Set),eP=(0,l.useRef)(new Set),eI=(0,l.useCallback)(async e=>{if(!(eT.current.has(e)||eP.current.has(e))){eP.current.add(e),e_(s=>new Set(s).add(e));try{let s=[],a=1,t=1;do{let r=await fetch(`/api/admin/school/class-sessions?yearly_curriculum_id=${encodeURIComponent(e)}&is_active=true&limit=100&page=${a}`,{credentials:"include"});if(!r.ok)throw Error(`Failed to fetch sessions: ${r.status}`);let n=await r.json();s.push(...n.sessions||[]),t=n.pagination?.total_pages||1,a+=1}while(a<=t);let r=s.sort((e,s)=>e.day_of_week-s.day_of_week||e.start_time.localeCompare(s.start_time)||(0,I.WL)(W(e),W(s))||e.id.localeCompare(s.id));eT.current.add(e),ey(s=>({...s,[e]:!1})),ep(s=>({...s,[e]:r}))}catch(s){console.warn(`Could not load sessions for curriculum ${e}:`,s),$.oR.error("Failed to load class sessions"),eT.current.add(e),ey(s=>({...s,[e]:!0})),ep(s=>({...s,[e]:[]}))}finally{eP.current.delete(e),e_(s=>{let a=new Set(s);return a.delete(e),a})}}},[]);(0,l.useEffect)(()=>{if(!a.some(e=>"ONE_TO_ONE"===e.curriculum_type)||eL)return;let e=new AbortController,s=!0;return(async()=>{eF(!0);try{let[a,t,r]=await Promise.all([fetch("/api/admin/syllabi",{credentials:"include",signal:e.signal}),fetch("/api/admin/grade-levels",{credentials:"include",signal:e.signal}),fetch("/api/admin/classrooms",{credentials:"include",signal:e.signal})]);if(!s)return;if(a.ok){let e=await a.json();eS([...e.syllabi||e||[]].sort((e,s)=>(0,I.WL)(e.name,s.name)||e.id.localeCompare(s.id)))}else console.error("Failed to fetch syllabi:",a.status,a.statusText),eS([]);if(t.ok){let e=await t.json();eE(e.gradeLevels||e||[])}else console.error("Failed to fetch grade levels:",t.status,t.statusText),eE([]);if(r.ok){let e=await r.json(),s=e.classrooms||e||[];eO(s.filter(e=>!1!==e.is_active).sort((e,s)=>(0,I.WL)(e.location,s.location)||(0,I.WL)(e.name,s.name)||e.id.localeCompare(s.id)))}else console.error("Failed to fetch classrooms:",r.status,r.statusText),eO([]);s&&(eR(!0),eF(!1))}catch(a){!e.signal.aborted&&s&&(console.error("Error fetching syllabi/grade levels/classrooms:",a instanceof Error?a.message:a),eS([]),eE([]),eO([]),eR(!0),eF(!1))}})(),()=>{s=!1,e.abort()}},[a,eL]),(0,l.useEffect)(()=>{e.forEach(e=>{let s=a.find(s=>s.id===e),t=s?.curriculum_type==="ONE_TO_ONE",r="existing"===ew[e];(!t||r)&&(eT.current.has(e)||eP.current.has(e)||eI(e))})},[e,a,ew,eI]),(0,l.useEffect)(()=>{Z&&a.forEach(e=>{if("ONE_TO_ONE"===e.curriculum_type&&!Q[e.id]){let s=ea;if(ea&&"Online"!==ea&&e$.length>0){let e=e$.find(e=>e.location===ea);e&&(s=e.name)}let a=z(ei);Z(e.id,{syllabus_id:ee,grade_level:es,day_of_week:a?.getDay()??1,start_time:O.RE,end_time:O.W5,duration_minutes:O.Nn,create_recurring_lessons:eu,fee_per_lesson:ex?e.one_to_one_hourly_rate??void 0:void 0,location:s})}})},[a,Q,Z,ee,es,ea,e$,eu,ei,ex]);let eM=(0,l.useCallback)((e,s,a)=>{let t;if(!Z)return;let r=Q[e]||{day_of_week:z(ei)?.getDay()??1,start_time:O.RE,end_time:O.W5,duration_minutes:O.Nn,create_recurring_lessons:eu};if("start_time"===s||"duration_minutes"===s){let e="start_time"===s?String(a):r.start_time,n="duration_minutes"===s?Number(a):r.duration_minutes,l=(0,O.D3)(e,n);t={...r,[s]:"duration_minutes"===s?Number(a):a,start_time:e,end_time:l,duration_minutes:n}}else if("location"===s){let e=String(a),s=(0,J.Yk)(e),n=s?e$.find(e=>e.name===s):void 0;t={...r,location:e,classroom_id:n?.id}}else t={...r,[s]:a};Z(e,t)},[Q,Z,eu,ei,e$]),eJ=(0,l.useCallback)(e=>!el||(e.syllabus_id||e.syllabus?.id||null)===el,[el]),eq=n.filter(eJ).filter(s=>!e.includes(s.id)).map(e=>({value:e.id,label:(0,T.zz)(e),sublabel:e.grade_level||void 0})).sort((e,s)=>(0,I.WL)(e.label,s.label)),eW=[...a.filter(eJ),...n.filter(eJ).filter(e=>!a.some(s=>s.id===e.id))].sort((e,s)=>(0,I.WL)(e.name,s.name));return(0,t.jsxs)(i.Zp,{className:U?"p-0 space-y-3 bg-card border-0 shadow-none min-w-0":"p-4 space-y-3 bg-card",children:[!U&&(0,t.jsxs)("div",{className:"flex items-center justify-between",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[(0,t.jsx)(g.A,{className:"h-4 w-4 text-muted-foreground"}),(0,t.jsx)("h4",{className:"font-medium text-sm",children:"Enrollment Curricula"})]}),(0,t.jsxs)(d.E,{variant:"outline",children:[e.length," selected"]})]}),a.length>0?(0,t.jsx)("div",{className:"space-y-3",children:a.map(n=>{let l,i=eg[n.id]||[],d=ef.has(n.id),g=Y[n.id]||Q[n.id]?.existing_session_id||n.id===R&&M||void 0,S=eb[n.id]||"",$=S.trim().toLocaleLowerCase("en-SG"),L=$?i.filter(e=>[W(e),q[e.day_of_week],e.start_time,e.end_time].some(e=>e?.toLocaleLowerCase("en-SG").includes($))):i;return(0,t.jsxs)("div",{className:`rounded-md border ${n.id===R?"bg-green-50 dark:bg-green-950/30 border-green-200 dark:border-green-800":"bg-muted/30 border-border"}`,children:[(0,t.jsxs)("div",{className:"flex items-center justify-between p-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2",children:[n.id===R&&(0,t.jsx)(p.A,{className:"h-3 w-3 text-green-600 dark:text-green-400"}),(0,t.jsxs)("div",{className:"flex flex-col",children:[(0,t.jsx)("span",{className:"text-sm font-medium",children:(0,T.zz)(n)}),(0,t.jsx)("span",{className:"text-xs text-muted-foreground",children:n.grade_level})]})]}),!X&&!U&&(0,t.jsx)(o.$,{variant:"ghost",size:"sm",onClick:()=>{var t;let r;return t=n.id,r=a.find(e=>e.id===t),void(s(e.filter(e=>e!==t),r),B&&Y[t]&&B(t,null),Z&&Q[t]&&Z(t,null))},className:"h-6 w-6 p-0 hover:bg-destructive/10 hover:text-destructive",children:(0,t.jsx)(f.A,{className:"h-3 w-3"})})]}),"ONE_TO_ONE"===n.curriculum_type&&Z?(0,t.jsx)("div",{className:"px-3 pb-3 pt-0",children:(0,t.jsxs)("div",{className:"border-t border-border/50 pt-2",children:[eN[n.id]&&(0,t.jsxs)("div",{role:"alert",className:"mb-3 text-sm text-destructive",children:["Could not load private sessions. ",(0,t.jsx)(o.$,{type:"button",variant:"outline",size:"sm",onClick:()=>{eT.current.delete(n.id),eI(n.id)},children:"Retry"})]}),(0,t.jsxs)("div",{className:"flex rounded-md bg-muted p-1 mb-3",children:[(0,t.jsx)(o.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>{let e=Q[n.id],s=ew[n.id]||"new";ej.current[n.id]={...ej.current[n.id],[s]:e},ek(e=>({...e,[n.id]:"new"}));let a=ej.current[n.id]?.new;if(a){B?.(n.id,null),Z(n.id,{...a,existing_session_id:void 0,...U?{mode:"new"}:{}});return}B&&B(n.id,null);let t=z(ei);Z(n.id,{...U?{mode:"new",first_lesson_date:e?.first_lesson_date}:{},syllabus_id:ee,grade_level:es,day_of_week:t?.getDay()??1,start_time:O.RE,end_time:O.W5,duration_minutes:O.Nn,create_recurring_lessons:eu,fee_per_lesson:ex?n.one_to_one_hourly_rate??void 0:void 0,location:ea})}
1,disabled:X,className:`flex-1 min-w-0 whitespace-normal text-xs py-1 h-auto min-h-8 rounded-sm transition-all duration-150 ${"new"===(ew[n.id]||"new")?"bg-background shadow-sm text-foreground font-medium":"text-muted-foreground hover:text-foreground"}`,children:"Create New Timing"}),(0,t.jsx)(o.$,{type:"button",variant:"ghost",size:"sm",onClick:()=>{ej.current[n.id]={...ej.current[n.id],[ew[n.id]||"new"]:Q[n.id]};let e=ej.current[n.id]?.existing;e?(B?.(n.id,e.existing_session_id||null),Z(n.id,e)):U&&(B?.(n.id,null),Z(n.id,{...Q[n.id],mode:"existing",existing_session_id:void 0})),ek(e=>({...e,[n.id]:"existing"})),eI(n.id)},disabled:X,className:`flex-1 min-w-0 whitespace-normal text-xs py-1 h-auto min-h-8 rounded-sm transition-all duration-150 ${"existing"===ew[n.id]?"bg-background shadow-sm text-foreground font-medium":"text-muted-foreground hover:text-foreground"}`,children:"Link Existing Session"})]}),"existing"===ew[n.id]?(0,t.jsxs)("div",{className:"space-y-3",children:[(ed||"readonly"===eo)&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(u.J,{className:"text-xs text-muted-foreground",children:"Trial Date *"}),"readonly"===eo?(0,t.jsx)(m.p,{type:"text",value:V(ei),readOnly:!0,placeholder:"No trial date selected",className:"h-8 bg-muted/50 text-xs"}):(0,t.jsx)(m.p,{type:"date",value:ei,onChange:e=>ed?.(n.id,e.target.value),disabled:X,className:"h-8 text-xs"})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(u.J,{className:"text-xs text-muted-foreground",children:"Select Private Session *"}),d?(0,t.jsxs)("div",{className:"flex items-center gap-2 py-2 text-xs text-muted-foreground",children:[(0,t.jsx)(_.A,{className:"h-3.5 w-3.5 animate-spin text-primary"}),(0,t.jsx)("span",{children:"Loading private sessions..."})]}):eN[n.id]?null:0===(l=i.filter(e=>"full"!==(0,P.SK)({sessionId:e.id,linkedSessionId:M,participantCount:(0,P.mG)(e)}))).length?(0,t.jsxs)("div",{className:"rounded-md border border-amber-200 bg-amber-50 p-3 text-xs text-amber-800 dark:border-amber-900/50 dark:bg-amber-950/20 dark:text-amber-200",children:[(0,t.jsx)("span",{className:"font-semibold block mb-0.5",children:i.length?"No private sessions have space":"No existing private sessions"}),i.length?"Existing sessions already have two students. Create a new timing or free a place in another session.":"Create a new timing for this tutor."]}):(0,t.jsx)(A.A,{kind:"entity","aria-label":"Existing private session",value:g||"",onValueChange:e=>{let s=l.find(s=>s.id===e);s&&B&&Z&&(B(n.id,s.id),Z(n.id,{...U?{mode:"existing",first_lesson_date:Q[n.id]?.first_lesson_date}:{},existing_session_id:s.id,day_of_week:s.day_of_week,start_time:s.start_time.slice(0,5),end_time:s.end_time.slice(0,5),duration_minutes:60*Number(s.end_time.slice(0,2))+Number(s.end_time.slice(3,5))-(60*Number(s.start_time.slice(0,2))+Number(s.start_time.slice(3,5))),create_recurring_lessons:Q[n.id]?.create_recurring_lessons??eu,fee_per_lesson:ex?n.one_to_one_hourly_rate??void 0:void 0,syllabus_id:s.syllabus_id||Q[n.id]?.syllabus_id||ee,grade_level:Q[n.id]?.grade_level||es,classroom_id:s.classroom_id||void 0,location:s.classroom_name||s.classroom_location||"Online"}))},disabled:X,placeholder:"Select an existing session...",searchPlaceholder:"Search private sessions…",options:l.map(e=>{let s=(0,P.mG)(e),a=(0,P.SK)({sessionId:e.id,linkedSessionId:M,participantCount:s});return{value:e.id,label:W(e),description:`${q[e.day_of_week]} ${e.start_time?.slice(0,5)} - ${e.end_time?.slice(0,5)} \xb7 ${"linked_trial"===a?"current linked trial":"soft_hold"===a?"soft hold":"1 student — add as 1-to-2"}`}})})]}),g&&(()=>{let e=i.filter(e=>"full"!==(0,P.SK)({sessionId:e.id,linkedSessionId:M,participantCount:(0,P.mG)(e)})).find(e=>e.id===g);if(!e)return null;let s=(0,P.mG)(e),a=(0,P.SK)({sessionId:e.id,linkedSessionId:M,participantCount:s});return(0,t.jsxs)("div",{className:"rounded-md border bg-muted/40 p-2.5 space-y-2 text-xs",children:[(0,t.jsx)("div",{className:"font-medium text-xs text-muted-foreground border-b border-border/50 pb-1",children:"linked_trial"===a?"Current Trial Session:":"join_second"===a?"Shared 1-to-2 Session:":"Linked Session Details:"}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-x-4 gap-y-1 text-xs text-muted-foreground",children:[(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(b.A,{className:"h-3.5 w-3.5 text-primary/70 shrink-0"}),(0,t.jsx)("span",{children:q[e.day_of_week]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,t.jsx)(v.A,{className:"h-3.5 w-3.5 text-primary/70 shrink-0"}),(0,t.jsxs)("span",{children:[e.start_time?.slice(0,5)," - ",e.end_time?.slice(0,5)]})]}),e.classroom_name&&(0,t.jsxs)("div",{className:"flex items-center gap-1.5 col-span-2 mt-1",children:[(0,t.jsx)(j.A,{className:"h-3.5 w-3.5 text-primary/70 shrink-0"}
1),(0,t.jsxs)("span",{children:[e.classroom_name," (",e.classroom_location,")"]})]})]}),"linked_trial"===a&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"This registration is already linked to this student's trial session. Approval keeps the same private slot; it does not add a second participant."}),"join_second"===a&&(0,t.jsx)("p",{className:"text-xs text-muted-foreground",children:"Approval will add this student as the second participant. Enrolment, credits, and attendance remain separate for each student."})]})})(),ex&&n.one_to_one_hourly_rate&&(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsxs)(u.J,{className:"text-xs text-muted-foreground",children:["Hourly Rate: $",n.one_to_one_hourly_rate]})}),eu&&(0,t.jsxs)("div",{className:"flex items-center space-x-2 pt-1",children:[(0,t.jsx)(x.S,{id:`recurring-${n.id}`,checked:Q[n.id]?.create_recurring_lessons??!0,onCheckedChange:e=>eM(n.id,"create_recurring_lessons",!0===e),disabled:X}),(0,t.jsx)(u.J,{htmlFor:`recurring-${n.id}`,className:"text-xs font-normal cursor-pointer",children:"Auto-schedule recurring weekly lessons"})]}),ec&&e[0]===n.id&&(0,t.jsx)("div",{className:`rounded-md border p-2 text-xs ${ec.conflicts.length>0?"border-red-200 bg-red-50 text-red-800 dark:border-red-900 dark:bg-red-950/30 dark:text-red-200":"border-green-200 bg-green-50 text-green-800 dark:border-green-900 dark:bg-green-950/30 dark:text-green-200"}`,children:ec.checking?(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(_.A,{className:"h-3 w-3 animate-spin"}),"Checking schedule conflicts..."]}):ec.conflicts.length>0?(0,t.jsx)("div",{className:"space-y-1",children:ec.conflicts.map((e,s)=>(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(N.A,{className:"h-3 w-3 mt-0.5 shrink-0"}),(0,t.jsx)("span",{children:e.message})]},`${e.type||"conflict"}-${s}`))}):ei?(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(y.A,{className:"h-3 w-3"}),"No schedule conflicts found."]}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"No trial date selected."})})]}):(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,t.jsx)(w.A,{className:"h-3.5 w-3.5 text-primary"}),(0,t.jsx)("p",{className:"text-xs font-medium text-muted-foreground",children:"Create Private Tutoring Session:"})]}),eD&&(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,t.jsx)(_.A,{className:"h-3 w-3 animate-spin"}),(0,t.jsx)("span",{children:"Loading syllabus and grade options..."})]}),(ed||"readonly"===eo)&&(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(u.J,{className:"text-xs text-muted-foreground",children:"Trial Date *"}),"readonly"===eo?(0,t.jsx)(m.p,{type:"text",value:V(ei),readOnly:!0,placeholder:"No trial date selected",className:"h-8 bg-muted/50 text-xs"}):(0,t.jsx)(m.p,{type:"date",value:ei,onChange:e=>ed?.(n.id,e.target.value),disabled:X,className:"h-8 text-xs"})]}),(0,t.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(u.J,{className:"text-xs text-muted-foreground",children:"Syllabus *"}),(0,t.jsx)(A.A,{kind:"entity","aria-label":"One-to-one syllabus",value:Q[n.id]?.syllabus_id||"",onValueChange:e=>eM(n.id,"syllabus_id",e),disabled:X||eD,loading:eD,placeholder:0===eC.length?"No syllabi found":"Select syllabus...",searchPlaceholder:"Search syllabi…",options:eC.map(e=>({value:e.id,label:e.name}))})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(u.J,{className:"text-xs text-muted-foreground",children:"Grade Level"}),(0,t.jsx)(A.A,{kind:"entity","aria-label":"One-to-one grade level",value:Q[n.id]?.grade_level||"",onValueChange:e=>eM(n.id,"grade_level",e),disabled:X||eD,loading:eD,placeholder:0===eA.length?"No grades found":"Select grade...",searchPlaceholder:"Search grade levels…",options:eA.map(e=>({value:e.name,label:e.name}))})]})]}),(0,t.jsxs)("div",{className:"grid grid-cols-[repeat(auto-fit,minmax(min(100%,10rem),1fr))] gap-2",children:[(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(u.J,{className:"text-xs text-muted-foreground",children:"Day"}),(0,t.jsxs)(h.l6,{value:String(Q[n.id]?.day_of_week??1),onValueChange:e=>{let s=parseInt(e,10);isNaN(s)||eM(n.id,"day_of_week",s)},disabled:X||!!ei,children:[(0,t.jsx)(h.bq,{"aria-label":"Lesson day",className:"h-10 text-xs sm:h-9",children:(0,t.jsx)(h.yv,{})}),(0,t.jsx)(h.gC,{children:O.j_.map(e=>(0,t.jsx)(h.eb,{value:e.value,children:e.label},e.value))})]})]}),(0,t.jsx)(r.Q,{id:`regular-start-time-${n.id}`,label:"Start time",value:Q[n.id]?.start_time||O.RE,onValueChange:e=>eM(n.id,"start_time",e),disabled:X}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(u.J,{className:"text-xs text-muted-foreground",children:"Duration"}),(0,t.jsxs)(h.l6,{value:String(Q[n.id]?.duration_minutes??O.Nn),onValueChange:e=>{let s=parseInt(e,10);isNaN(s)||eM(n.id,"duration_minutes",s)},disabled:X,children:[(0,t.jsx)(h.bq,{"aria-label":"Lesson duration",className:"h-10 text-xs sm:h-9",children:(0,t.jsx)(h.yv,{})}),(0,t.jsx)(h.gC,{children:O.U$.map(e=>(0,t.jsx)(h.eb,{value:e.value,children:e.label},e.value))})]})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",children:[(0,t.jsx)(v.A,{className:"h-3 w-3"}),(0,t.jsxs)("span",{children:[ei?`${V(ei)} • `:"",O.j_.find(e=>e.value===String(Q[n.id]?.day_of_week??1))?.label," ",Q[n.id]?.start_time||O.RE," -"," ",Q[n.id]?.end_time||O.W5]})]}),(0,t.jsxs)("div",{className:"space-y-1",children:[(0,t.jsx)(u.J,{className:"text-xs text-muted-foreground",children:"Lesson Location"}),(0,t.jsx)(A.A,{kind:"entity","aria-label":"Lesson location",value:Q[n.id]?.location||"",onValueChange:e=>eM(n.id,"location",e),disabled:X||eD,loading:eD,placeholder:"Select location...",searchPlaceholder:"Search locations…",options:(0,J.MV)(e$,Q[n.id]?.location)})]}),ex&&n.one_to_one_hourly_rate&&(0,t.jsx)("div",{className:"flex items-center gap-2",children:(0,t.jsxs)(u.J,{className:"text-xs text-muted-foreground",children:["Hourly Rate: $",n.one_to_one_hourly_rate]})}),eu&&(0,t.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,t.jsx)(x.S,{id:`recurring-${n.id}`,checked:Q[n.id]?.create_recurring_lessons??!0,onCheckedChange:e=>eM(n.id,"create_recurring_lessons",!0===e),disabled:X}),(0,t.jsx)(u.J,{htmlFor:`recurring-${n.id}`,className:"text-xs font-normal cursor-pointer",children:"Auto-schedule recurring weekly lessons"})]}),ec&&e[0]===n.id&&(0,t.jsx)("div",{className:`rounded-md border p-2 text-xs ${ec.conflicts.length>0?"border-red-200 bg-red-50 text-red-800 dark:border-red-900 dark:bg-red-950/30 dark:text-red-200":"border-green-200 bg-green-50 text-green-800 dark:border-green-900 dark:bg-green-950/30 dark:text-green-200"}`,children:ec.checking?(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(_.A,{className:"h-3 w-3 animate-spin"}),"Checking schedule conflicts..."]}):ec.conflicts.length>0?(0,t.jsx)("div",{className:"space-y-1",children:ec.conflicts.map((e,s)=>(0,t.jsxs)("div",{className:"flex items-start gap-2",children:[(0,t.jsx)(N.A,{className:"h-3 w-3 mt-0.5 shrink-0"}),(0,t.jsx)("span",{children:e.message})]},`${e.type||"conflict"}-${s}`))}):ei?(0,t.jsxs)("span",{className:"flex items-center gap-2",children:[(0,t.jsx)(y.A,{className:"h-3 w-3"}),"No schedule conflicts found."]}):(0,t.jsx)("span",{className:"text-muted-foreground",children:"No trial date selected."})})]})]})}):B&&(0,t.jsx)("div",{className:"px-3 pb-3 pt-0",children:(0,t.jsx)("div",{className:"border-t border-border/50 pt-2",children:n.id===R&&M?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("p",{className:"text-xs font-medium text-green-700 dark:text-green-400 mb-2 flex items-center gap-1",children:[(0,t.jsx)(p.A,{className:"h-3 w-3"}),"Class Session:"]}),d?(0,t.jsxs)("div",{className:"flex items-center gap-2 py-2 text-sm text-muted-foreground",children:[(0,t.jsx)(_.A,{className:"h-3 w-3 animate-spin"}),(0,t.jsx)("span",{children:"Loading session..."})]}):i.filter(e=>e.id===M).map(e=>{var s;let a;return(0,t.jsxs)("a",{href:(s=e.id,a=new URLSearchParams({tab:"attendance"}),K&&a.set("date",K),`/admin/school/class-sessions/${s}?${a.toString()}`),target:"_blank",rel:"noopener noreferrer",className:"block p-2 rounded-md bg-green-50/50 dark:bg-green-950/20 border border-green-200 dark:border-green-800 transition-colors hover:bg-green-100/70 dark:hover:bg-green-950/40 focu
1s-visible:outline-none focus-visible:ring-2 focus-visible:ring-green-600",title:"Open class session attendance in a new window",children:[(0,t.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,t.jsx)("div",{className:"font-medium text-sm",children:W(e)}),(0,t.jsx)(k.A,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]}),(0,t.jsxs)("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(b.A,{className:"h-3 w-3"}),q[e.day_of_week]]}),(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(v.A,{className:"h-3 w-3"}),e.start_time?.slice(0,5)," - ",e.end_time?.slice(0,5)]}),e.max_students&&(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(j.A,{className:"h-3 w-3 text-green-600"}),e.physical_enrollment??e.current_enrollment??0,"/",e.max_students,(0,t.jsx)("span",{className:"text-muted-foreground/50 mx-0.5",children:"|"}),(0,t.jsx)(C.A,{className:"h-3 w-3 text-blue-600"}),e.online_enrollment??0]})]})]},e.id)})]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("p",{className:"text-xs font-medium text-muted-foreground mb-2",children:"Select Class Session:"}),d?(0,t.jsxs)("div",{className:"flex items-center gap-2 py-2 text-sm text-muted-foreground",children:[(0,t.jsx)(_.A,{className:"h-3 w-3 animate-spin"}),(0,t.jsx)("span",{children:"Loading sessions..."})]}):0===i.length?(0,t.jsx)("p",{className:"text-xs text-muted-foreground py-1",children:"No class sessions available for this curriculum."}):(0,t.jsxs)("div",{className:"space-y-2",children:[(0,I.uH)(i.length,"entity")&&(0,t.jsx)(E.D,{value:S,onValueChange:e=>ev(s=>({...s,[n.id]:e})),placeholder:"Search class sessions…","aria-label":`Search class sessions for ${(0,T.zz)(n)}`,clearLabel:"Clear class session search"}),(0,t.jsx)(c.z,{value:g||"",onValueChange:e=>{var s;return s=n.id,void(B&&B(s,e))},disabled:X,className:"space-y-1",children:L.map(e=>(0,t.jsxs)("div",{className:`flex items-center space-x-2 p-2 rounded-md transition-colors cursor-pointer hover:bg-muted/50 ${g===e.id?"bg-primary/10 border border-primary/30":""}`,children:[(0,t.jsx)(c.C,{value:e.id,id:`session-${n.id}-${e.id}`,disabled:X}),(0,t.jsxs)(u.J,{htmlFor:`session-${n.id}-${e.id}`,className:"flex-1 cursor-pointer",children:[(0,t.jsx)("div",{className:"font-medium text-sm",children:W(e)}),(0,t.jsxs)("div",{className:"flex items-center gap-3 text-xs text-muted-foreground",children:[(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(b.A,{className:"h-3 w-3"}),q[e.day_of_week]]}),(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(v.A,{className:"h-3 w-3"}),e.start_time?.slice(0,5)," - ",e.end_time?.slice(0,5)]}),e.max_students&&(0,t.jsxs)("span",{className:"flex items-center gap-1",children:[(0,t.jsx)(j.A,{className:"h-3 w-3 text-green-600"}),e.physical_enrollment??e.current_enrollment??0,"/",e.max_students,(0,t.jsx)("span",{className:"text-muted-foreground/50 mx-0.5",children:"|"}),(0,t.jsx)(C.A,{className:"h-3 w-3 text-blue-600"}),e.online_enrollment??0]})]})]})]},e.id))}),0===L.length&&(0,t.jsx)("p",{className:"py-2 text-center text-xs text-muted-foreground",children:"No class sessions found."})]})]})})})]},n.id)})}):(0,t.jsx)("p",{className:"text-sm text-muted-foreground text-center py-2",children:er?"No curriculum selected.":"No curricula selected. Select a trial lesson to auto-add."}),!X&&!G&&er&&eW.length>0&&(0,t.jsxs)("div",{className:"pt-2 border-t border-border space-y-2",children:[(0,t.jsx)(u.J,{className:"text-xs text-muted-foreground",children:en}),(0,t.jsx)(A.A,{kind:"entity","aria-label":en,value:e[0]||"__none__",onValueChange:e=>{let t=a[0];"__none__"===e?s([],t):s([e],t&&t.id!==e?t:void 0)},placeholder:"Select curriculum...",searchPlaceholder:"Search curriculums…",options:[{value:"__none__",label:"Select curriculum..."},...eW.map(e=>({value:e.id,label:(0,T.zz)(e),description:e.grade_level||void 0}))]})]}),!X&&!G&&!er&&eq.length>0&&(0,t.jsx)("div",{className:"pt-2 border-t border-border",children:(0,t.jsx)(S.A,{options:eq,value:e,onCh
1ange:s,placeholder:"Add more curricula..."})})]})}function K({choice:e,value:s,onChange:a,disabled:r=!1,dateEditableWhenLocked:l=!1}){let i={id:e.curriculum_id,name:e.curriculum_name,grade_level:s.grade_level||null,curriculum_type:"ONE_TO_ONE",tutor_id:e.tutor_id,one_to_one_hourly_rate:e.session_data.fee_per_lesson};return(0,t.jsxs)("div",{className:"space-y-3",children:[(0,t.jsx)("p",{className:"text-sm font-medium",children:"Regular lesson schedule"}),(0,t.jsx)(H,{selectedIds:[i.id],selectedCurriculums:[i],availableCurriculums:[],onChange:()=>{},hideAddMore:!0,regularEnrollment:!0,disabled:r,selectedSessions:s.existing_session_id?{[i.id]:s.existing_session_id}:{},onSessionChange:()=>{},oneToOneSessionData:{[i.id]:s},onOneToOneSessionChange:(e,t)=>{t&&a({...t,mode:t.mode||(t.existing_session_id?"existing":"new"),first_lesson_date:t.first_lesson_date||s.first_lesson_date})},defaultSyllabusId:s.syllabus_id,defaultGradeLevel:s.grade_level,defaultLocation:s.location}),(0,t.jsx)(n.v,{id:`regular-first-date-${i.id}`,label:s.create_recurring_lessons?"First regular lesson date":"Enrolment start date",value:s.first_lesson_date||"",onValueChange:e=>a({...s,first_lesson_date:e}),disabled:r&&!l,description:s.create_recurring_lessons?"Choose the exact first lesson on the selected weekday. New weekly lessons are generated through 31 December; existing sessions use their available lessons or recurrence rule.":"Schedule lessons manually. Enrolment creates no scheduled lessons."})]})}}}]);

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.