mario-education 2.0.204-staging → 2.0.206-staging

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),S=require("react"),t=require("@mui/material"),he=require("react-redux"),_e=require("react-router-dom"),xe=require("moment"),M=require("mario-core"),ye=require("./surveyService-Lks0sWq4.cjs"),$e=require("./questionCategoryService-CjXNe6xV.cjs"),Te=require("./ArrowBack-C4WIF8bZ.cjs"),Ce=require("./Check-CYAVgIcj.cjs"),Se=require("./ArrowForward-D4TtLiX5.cjs"),ne=require("./createSvgIcon-CRp0VXvr.cjs"),je=require("./Add-DE-4A91A.cjs"),fe=require("@mui/x-date-pickers"),Ue=require("./AdapterMoment-B-q0UCj0.cjs"),Ve=require("./Search-CZp6DUOA.cjs"),Ke=require("./Close-BqvQ2Wpz.cjs"),ce=require("./DropDownComponent-BzsJ_Gac.cjs"),de=[{stepNumber:1,stepCode:"CHOOSE_TEMPLATE",label:"Choose Template"},{stepNumber:2,stepCode:"CHECK_DETAILS",label:"Check Details"},{stepNumber:3,stepCode:"CREATE_SURVEY",label:"Create Survey"},{stepNumber:4,stepCode:"SELECT_STUDENTS",label:"Select Students"},{stepNumber:5,stepCode:"REVIEW_PUBLISH",label:"Review & Publish"}],Je=["All","School Climate","Well-being","Health & Wellness"],Ze=[{id:1,title:"Stress",description:"Assess stress levels and identify stressors affecting students",questionCount:13,category:"Well-being"},{id:2,title:"Grows",description:"Measure student growth mindset and learning attitudes",questionCount:6,category:"School Climate"},{id:3,title:"Climate Survey",description:"Evaluate overall school climate and student experiences",questionCount:9,category:"School Climate"},{id:4,title:"Happiness",description:"Track student happiness and emotional well-being",questionCount:8,category:"Well-being"},{id:5,title:"Climate Survey: Connections with Adults & Peers",description:"Assess the quality of relationships with adults and peers in school",questionCount:14,category:"School Climate"},{id:6,title:"Climate Survey: Holistic Learning Experiences",description:"Evaluate overall school climate and student experiences",questionCount:18,category:"Well-being"},{id:7,title:"Climate Survey: My Health and Well-being",description:"Monitor student physical and mental health and wellness",questionCount:21,category:"Health & Wellness"},{id:8,title:"Well-being",description:"General assessment of student wellness and quality of life",questionCount:10,category:"Well-being"}],Xe=a=>{const n=he.useDispatch(),i=_e.useNavigate(),m=he.useSelector(d=>d?.common?.language||"en"),[o,l]=S.useState(a?.activeStep??0),[b,p]=S.useState(a?.selectedCategory??"All"),[c,C]=S.useState(a?.selectedTemplateId??null),[y,g]=S.useState(Ze),[x,A]=S.useState(!1),[q,E]=S.useState(a?.editingTemplate??null),j=S.useCallback(async()=>{try{A(!0),n(M.setLoading(!0));const d=await ye.getTemplateSurvey(m);if(d?.data&&Array.isArray(d.data)&&d.data.length>0){const B=d.data.map(r=>{let N="Well-being";const v=(r.name||"").toLowerCase();v.includes("climate")||v.includes("grow")?N="School Climate":v.includes("health")&&(N="Health & Wellness");const D=new Set;r.questionTemplates&&Array.isArray(r.questionTemplates)&&r.questionTemplates.forEach(L=>{const Q=L.category??L.categoryName??L.categoryTitle??L.title??N;Q&&typeof Q=="string"&&D.add(Q.trim())});const u=Array.from(D);return{id:r.id,title:r.name,description:r.description,questionCount:r.numberQuestion??r.questionTemplates?.length??0,category:N,categories:u.length>0?u:[N],rawTemplate:r}});g(B),a?.selectedTemplateId||C(r=>r||(B.length>0?B[0].id:null))}}catch(d){console.error("Error fetching survey templates:",d),n(M.setAlert({type:"danger",message:d?.message||"Failed to fetch survey templates"}))}finally{A(!1),n(M.setLoading(!1))}},[m,n]);S.useEffect(()=>{j()},[j]);const F=S.useMemo(()=>{const d=new Set;return y.forEach(B=>{B.category&&d.add(B.category)}),d.size===0?Je:["All",...Array.from(d)]},[y]),T=S.useMemo(()=>b==="All"?y:y.filter(d=>d.category.toLowerCase()===b.toLowerCase()),[y,b]),h=S.useMemo(()=>y.find(d=>d.id===c)||null,[y,c]),I=d=>{p(d)},z=d=>{C(d)},H=()=>{C("BLANK"),l(d=>Math.min(d+1,de.length-1))},Y=(d,B)=>{B.stopPropagation(),E(d)},O=()=>{E(null)},$=async d=>{try{n(M.setLoading(!0));const B=d.rawTemplate?.questionTemplates?.map(v=>v.questionId||v.id)?.filter(v=>typeof v=="number"||!String(v).startsWith("q-"))?.map(v=>Number(v))||[],r={id:d.id,name:d.title,description:d.description,isFavorite:d.rawTemplate?.isFavorite??!1,questionIds:B};await $e.updateSurvey(r),g(v=>v.map(D=>D.id===d.id?d:D)),E(null);const N=localStorage.getItem("create_survey_draft");if(N)try{const v=JSON.parse(N);v.editingTemplateFormData&&(delete v.editingTemplateFormData,localStorage.setItem("create_survey_draft",JSON.stringify(v)))}catch{}await j(),n(M.setAlert({type:"success",message:"Update template successfully"}))}catch(B){n(M.setAlert({type:"danger",message:B.response?.data?.title||"Update template failed"}))}finally{n(M.setLoading(!1))}},G=()=>{i("/admin/survey-dashboard/list-survey")};return{steps:de,activeStep:o,categories:F,selectedCategory:b,selectedTemplateId:c,selectedTemplate:h,templates:T,rawTemplates:y,isLoading:x,editingTemplate:q,handleSelectCategory:I,handleSelectTemplate:z,handleCreateBlankSurvey:H,handleEditTemplate:Y,handleCloseEditTemplate:O,handleSaveEditTemplate:$,handleGoBackToDashboard:G,handlePreviousStep:()=>{o>0?l(d=>d-1):G()},handleNextStep:()=>{o<de.length-1&&l(d=>d+1)},handleGoToStep:d=>{d>=0&&d<de.length&&l(d)},refetchTemplates:j}},ue=(a,n)=>!a||!Array.isArray(a)||a.length===0?[]:a.map((i,m)=>{let o=[];return Array.isArray(i.options)&&i.options.length>0?o=i.options.map(l=>typeof l=="string"?l:l?.text??l?.answerText??l?.name??l?.title??String(l)).filter(l=>!!(l&&l.trim())):Array.isArray(i.answers)&&i.answers.length>0&&(o=i.answers.map(l=>typeof l=="string"?l:l?.text??l?.answerText??l?.name??l?.title??String(l)).filter(l=>!!(l&&l.trim()))),{id:i.questionId??i.id??`q-${m+1}`,orderNumber:i.orderDefaultQuestionTemplate??i.orderNumber??m+1,questionText:i.questionText??i.text??`Question ${m+1}`,type:String(i.type||"Text"),category:i.category??i.categoryName??i.categoryTitle??i.title??n??"General",options:o,numberOfStars:i.numberOfStars??5,fromLabel:i.fromLabel,toLabel:i.toLabel}}),ge=[{id:"q-1",orderNumber:1,questionText:"How would you rate your overall well-being?",type:"Rating",category:"Overall Well-being"},{id:"q-2",orderNumber:2,questionText:"Do you feel balanced in your daily life?",type:"YesNo",category:"Life Balance"},{id:"q-3",orderNumber:3,questionText:"What contributes most to your well-being?",type:"Text",category:"Well-being Factors"},{id:"q-4",orderNumber:4,questionText:"How satisfied are you with your life?",type:"Rating",category:"Life Satisfaction"},{id:"q-5",orderNumber:5,questionText:"Do you have people who support you?",type:"YesNo",category:"Social Support"}],et=(a,n,i)=>{const m=S.useMemo(()=>{const j=n?.rawTemplate?.questionTemplates,F=ue(j,n?.category||"Well-being");return F.length>0?F:ge},[n]),[o,l]=S.useState(()=>i?.step2FormData?i.step2FormData:a==="BLANK"?{templateName:"",description:"",showLandingPageFlag:!1,questions:[],selectedCategoryFilter:"All"}:{templateName:n?.title||"Well-being",description:n?.description||"General assessment of student wellness and quality of life",showLandingPageFlag:!1,questions:m,selectedCategoryFilter:"All"}),b=S.useRef(i?.selectedTemplateId??(a==="BLANK"?"BLANK":n?n.id:null));S.useEffect(()=>{if(n){if(b.current===n.id)return;b.current=n.id;const j=n.rawTemplate?.questionTemplates,F=ue(j,n.category||"Well-being");l(T=>({...T,templateName:n.title||"",description:n.description||"",questions:F.length>0?F:T.questions.length>0?T.questions:ge,selectedCategoryFilter:"All"}))}else if(a==="BLANK"){if(b.current==="BLANK")return;b.current="BLANK",l(j=>({...j,templateName:"",description:"",questions:[],selectedCategoryFilter:"All"}))}},[n,a]);const p=S.useMemo(()=>{const j=new Set;o.questions.forEach(T=>{const h=T.category?.trim();h&&j.add(h)});const F=Array.from(j);return F.length>0?["All",...F]:["All"]},[o.questions]),c=S.useMemo(()=>o.selectedCategoryFilter==="All"?o.questions:o.questions.filter(j=>j.category===o.selectedCategoryFilter),[o.questions,o.selectedCategoryFilter]),C=j=>{l(F=>({...F,templateName:j}))},y=j=>{l(F=>({...F,description:j}))},g=j=>{l(F=>({...F,selectedCategoryFilter:j}))},x=j=>{console.log("Edit question:",j)},A=j=>{l(F=>({...F,questions:F.questions.filter(T=>T.id!==j).map((T,h)=>({...T,orderNumber:h+1}))}))},q=()=>{const j=`q-${Date.now()}`,F=o.questions.length+1,T={id:j,orderNumber:F,questionText:"New Question",type:"Rating",category:"General"};l(h=>({...h,questions:[...h.questions,T]}))},E=j=>{const F=j.rawTemplate?.questionTemplates,T=ue(F,j.category||"Well-being");l({templateName:j.title||"",description:j.description||"",showLandingPageFlag:!1,questions:T.length>0?T:ge,selectedCategoryFilter:"All"}),b.current=j.id};return{formData:o,questionCategories:p,filteredQuestions:c,totalQuestionsCount:o.questions.length,handleTemplateNameChange:C,handleDescriptionChange:y,handleCategoryFilterChange:g,handleEditQuestion:x,handleRemoveQuestion:A,handleAddQuestion:q,resetFormDataWithTemplate:E}},tt=(a,{initialTitle:n="",initialDeadline:i=xe().add(1,"days").format("DD.MM.YYYY hh:mm A")}={})=>{const[m,o]=S.useState(()=>a?.step3FormData?a.step3FormData:{title:n||"",deadline:i||""});return{formData:m,handleTitleChange:p=>{o(c=>({...c,title:p}))},handleDeadlineChange:p=>{o(c=>({...c,deadline:p}))}}},st=M.getStaticFileUrl("/images/image-default.png"),at=[{label:"All Flags",value:"all"},{label:"Red Flag",value:"red"},{label:"Yellow Flag",value:"yellow"},{label:"Green Flag",value:"green"}],nt=a=>{const[n,i]=S.useState([]),[m,o]=S.useState(a?.selectedStudentIds??[]),[l,b]=S.useState([]),[p,c]=S.useState(at),[C,y]=S.useState(["All Teachers"]),[g,x]=S.useState({searchQuery:"",selectedGrade:"All Grades",selectedFlag:"all",selectedTeacher:"All Teachers",page:0,rowsPerPage:10,sortBy:"name",sortOrder:"asc"}),A=S.useCallback(async()=>{try{const f=await ye.searchStudents({roles:["Admin"]});if(f?.data?.items&&Array.isArray(f.data.items)&&f.data.items.length>0){const _=f.data.items.map(u=>{let L="none";if(typeof u.flag=="string"){const Z=u.flag.toLowerCase();Z.includes("red")?L="red":Z.includes("yellow")?L="yellow":Z.includes("green")&&(L="green")}else u.redFlags>0||u.flag===1?L="red":u.yellowFlags>0||u.flag===2?L="yellow":(u.greenFlags>0||u.flag===3)&&(L="green");const Q=u.fullName||u.studentName,U=u.gradeLevel,V=u.email,oe=u.userId||(typeof u.id=="string"?u.id:""),J=typeof u.studentId=="number"?u.studentId:typeof u.id=="number"?u.id:void 0,me=oe||(J!==void 0?String(J):`student-${Math.random()}`),pe=(u.schoolLevel||(u.userId&&u.id===void 0?"ES":"MS")).toUpperCase();return{id:me,userId:oe,studentId:J,schoolLevel:pe,name:Q,avatarUrl:u.profileImageFileName?M.getFileUrl(u.profileImageFileName):st,flag:L,flagTooltip:u.flagTooltip||void 0,flagDetail:u.flagDetail,lastSafetyAnswer:u.lastSafetyAnswer,lastStressAnswer:u.lastStressAnswer,flagSessionId:u.flagSessionId,flagSessionResultId:u.flagSessionResultId,grade:U,email:V,listTeachers:u.listTeachers||[]}});i(_);const d=Array.from(new Set(_.map(u=>u.grade))).filter(u=>u&&u!=="N/A"),B=u=>{if(!u||u==="N/A")return-999;const L=u.toString().toUpperCase().replace(/TH|RD|ND|ST/g,"").trim();if(L==="PK")return-2;if(L==="K")return-1;if(L==="G")return 0;const Q=L.match(/^(\d+)/);return Q?parseInt(Q[1],10):999};d.sort((u,L)=>B(u)-B(L)),b(["All Grades",...d]);const r=Array.from(new Set(_.map(u=>u.flag))),N=[{label:"All Flags",value:"all"}];r.includes("red")&&N.push({label:"Red Flag",value:"red"}),r.includes("yellow")&&N.push({label:"Yellow Flag",value:"yellow"}),r.includes("green")&&N.push({label:"Green Flag",value:"green"}),c(N);const v=new Set;_.forEach(u=>{u.listTeachers&&u.listTeachers.length>0&&u.listTeachers.forEach(L=>{L.name&&v.add(L.name.trim())})});const D=Array.from(v).sort((u,L)=>u.localeCompare(L));y(["All Teachers",...D])}}catch(f){console.error("Error fetching students list:",f)}},[]);S.useEffect(()=>{A()},[A]);const q=f=>{x(_=>({..._,searchQuery:f,page:0}))},E=f=>{x(_=>({..._,selectedGrade:f,page:0}))},j=f=>{x(_=>({..._,selectedFlag:f,page:0}))},F=f=>{x(_=>({..._,selectedTeacher:f,page:0}))},T=(f,_)=>{x(d=>({...d,page:_}))},h=f=>{x(_=>({..._,rowsPerPage:parseInt(f.target.value,10),page:0}))},I=S.useMemo(()=>n.filter(f=>{if(g.searchQuery.trim()){const _=N=>(N||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),d=_(g.searchQuery.trim()),B=_(f.name).includes(d),r=_(f.email).includes(d);if(!B&&!r)return!1}return!(g.selectedGrade!=="All Grades"&&(f.grade||"").toLowerCase()!==(g.selectedGrade||"").toLowerCase()||g.selectedFlag!=="all"&&f.flag!==g.selectedFlag||g.selectedTeacher&&g.selectedTeacher!=="All Teachers"&&(!f.listTeachers||f.listTeachers.length===0||!f.listTeachers.some(d=>d.name&&d.name.trim()===g.selectedTeacher)))}),[n,g]),z=f=>{x(_=>({..._,sortBy:f,sortOrder:_.sortBy===f&&_.sortOrder==="asc"?"desc":"asc"}))},H=S.useMemo(()=>[...I].sort((_,d)=>{let B=_[g.sortBy],r=d[g.sortBy];if(g.sortBy==="flag"){const N={red:3,yellow:2,green:1,none:0};B=N[_.flag]||0,r=N[d.flag]||0}else if(g.sortBy==="grade"){const N=v=>{if(!v||v==="N/A")return-999;const D=v.toString().toUpperCase().replace(/TH|RD|ND|ST/g,"").trim();if(D==="PK")return-2;if(D==="K")return-1;if(D==="G")return 0;const u=D.match(/^(\d+)/);return u?parseInt(u[1],10):999};B=N(_.grade),r=N(d.grade)}else g.sortBy==="teacher"?(B=_.listTeachers&&_.listTeachers.length>0?_.listTeachers.map(N=>N.name).join(", ").toLowerCase():"",r=d.listTeachers&&d.listTeachers.length>0?d.listTeachers.map(N=>N.name).join(", ").toLowerCase():""):typeof B=="string"&&typeof r=="string"&&(B=B.toLowerCase(),r=r.toLowerCase());return B<r?g.sortOrder==="asc"?-1:1:B>r?g.sortOrder==="asc"?1:-1:0}),[I,g.sortBy,g.sortOrder]),Y=S.useMemo(()=>{const f=g.page*g.rowsPerPage;return H.slice(f,f+g.rowsPerPage)},[H,g.page,g.rowsPerPage]),O=S.useMemo(()=>I.length===0?!1:I.every(f=>m.includes(f.id)),[I,m]),$=S.useMemo(()=>{if(I.length===0)return!1;const f=I.filter(_=>m.includes(_.id));return f.length>0&&f.length<I.length},[I,m]),G=()=>{if(O){const f=I.map(_=>_.id);o(_=>_.filter(d=>!f.includes(d)))}else{const f=new Set([...m,...I.map(_=>_.id)]);o(Array.from(f))}},K=f=>{o(_=>_.includes(f)?_.filter(d=>d!==f):[..._,f])};return{students:Y,allFilteredStudents:I,allStudents:n,totalStudentsCount:I.length,totalSelectedCount:m.length,selectedStudentIds:m,filters:g,gradeOptions:l,flagOptions:p,teacherOptions:C,isAllSelected:O,isIndeterminate:$,handleSortChange:z,handleSearchChange:q,handleGradeFilterChange:E,handleFlagFilterChange:j,handleTeacherFilterChange:F,handlePageChange:T,handleRowsPerPageChange:h,handleToggleSelectAll:G,handleToggleStudent:K}},lt="_createSurveyPage_boayg_1",ot="_headerTopBar_boayg_16",rt="_contentBody_boayg_28",it="_stepperContainer_boayg_39",ct="_backButton_boayg_44",dt="_stepperProgress_boayg_58",ut="_stepColumn_boayg_66",ht="_stepColumnLast_boayg_72",mt="_stepCircleRow_boayg_77",pt="_stepCircle_boayg_77",gt="_active_boayg_96",xt="_completed_boayg_100",yt="_stepConnectorLine_boayg_105",ft="_stepLabelStack_boayg_115",bt="_stepInnerDot_boayg_119",_t="_stepNumberLabel_boayg_133",Tt="_stepTextLabel_boayg_145",Ct="_chooseTemplateCard_boayg_157",St="_headerSection_boayg_173",jt="_headerTitle_boayg_177",Nt="_headerSubtitle_boayg_192",vt="_bannerContainer_boayg_199",wt="_bannerIconBox_boayg_219",Bt="_bannerTitle_boayg_228",Ft="_bannerSubtitle_boayg_235",It="_bannerActionBtn_boayg_240",At="_sectionTitle_boayg_258",Lt="_filterPillsContainer_boayg_266",Rt="_filterPill_boayg_266",kt="_templateCard_boayg_301",Et="_selected_boayg_319",qt="_templateCardTitle_boayg_324",Dt="_templateEditBtn_boayg_332",Pt="_templateDescription_boayg_346",Ht="_chipItem_boayg_353",zt="_wizardFooter_boayg_367",Wt="_previousBtn_boayg_387",Mt="_disabled_boayg_409",Qt="_stepCounterText_boayg_427",Ot="_nextBtn_boayg_433",Gt="_editTemplateHeaderSection_boayg_453",Yt="_editTemplateCancelBtn_boayg_460",$t="_editTemplateSaveBtn_boayg_472",Ut="_formFieldBlock_boayg_514",Vt="_formFieldLabel_boayg_520",Kt="_requiredAsterisk_boayg_528",Jt="_customTextField_boayg_532",Zt="_formFieldHelperText_boayg_549",Xt="_questionsHeaderSection_boayg_577",es="_questionsTitle_boayg_585",ts="_questionsCountNumber_boayg_591",ss="_filterByRow_boayg_597",as="_filterByLabel_boayg_605",ns="_categoryFilterFormControl_boayg_611",ls="_categorySelectInput_boayg_616",os="_tableContainerWrapper_boayg_634",rs="_questionsTable_boayg_642",is="_tableHeaderRow_boayg_647",cs="_tableBodyRow_boayg_660",ds="_thNumber_boayg_674",us="_tdNumber_boayg_675",hs="_thQuestion_boayg_684",ms="_tdQuestion_boayg_685",ps="_questionText_boayg_691",gs="_thType_boayg_710",xs="_tdType_boayg_711",ys="_thCategory_boayg_717",fs="_tdCategory_boayg_718",bs="_categoryText_boayg_724",_s="_thActions_boayg_731",Ts="_tdActions_boayg_732",Cs="_questionTypeBadge_boayg_738",Ss="_badgeTextLabel_boayg_748",js="_badgeRating_boayg_754",Ns="_badgeYesNo_boayg_761",vs="_badgeText_boayg_748",ws="_tableEditBtn_boayg_782",Bs="_tableRemoveBtn_boayg_797",Fs="_addQuestionWrapper_boayg_812",Is="_addQuestionBtn_boayg_820",As="_selectedCountSection_boayg_839",Ls="_selectedCountText_boayg_844",Rs="_selectedCountHighlight_boayg_850",ks="_studentsToolbar_boayg_856",Es="_searchBarContainer_boayg_864",qs="_studentSearchInput_boayg_869",Ds="_filterDropdownWrapper_boayg_895",Ps="_teacherFilterWrapper_boayg_899",Hs="_teacherAutocomplete_boayg_903",zs="_teacherAutocompletePaper_boayg_960",Ws="_teacherAutocompleteListbox_boayg_968",Ms="_teacherOptionItem_boayg_985",Qs="_filterSelectBox_boayg_1029",Os="_studentsTableContainer_boayg_1055",Gs="_studentsTable_boayg_1055",Ys="_studentsTableHeaderRow_boayg_1069",$s="_checkboxHeaderCell_boayg_1080",Us="_tableHeaderCell_boayg_1088",Vs="_checkboxBodyCell_boayg_1104",Ks="_studentTableRow_boayg_1112",Js="_selectedRow_boayg_1119",Zs="_studentNameCell_boayg_1126",Xs="_studentNameText_boayg_1131",ea="_flagCell_boayg_1137",ta="_gradeCell_boayg_1142",sa="_gradeText_boayg_1147",aa="_emailCell_boayg_1152",na="_emailText_boayg_1157",la="_studentsPagination_boayg_1162",oa="_reviewSectionBlock_boayg_1180",ra="_reviewSectionHeader_boayg_1189",ia="_reviewSectionTitle_boayg_1196",ca="_reviewEditSectionBtn_boayg_1202",da="_reviewFieldGroup_boayg_1213",ua="_reviewFieldLabel_boayg_1217",ha="_reviewFieldValue_boayg_1225",ma="_reviewQuestionsTableContainer_boayg_1231",pa="_previewSurveyBtn_boayg_1237",ga="_publishBtn_boayg_1253",s={createSurveyPage:lt,headerTopBar:ot,contentBody:rt,stepperContainer:it,backButton:ct,stepperProgress:dt,stepColumn:ut,stepColumnLast:ht,stepCircleRow:mt,stepCircle:pt,active:gt,completed:xt,stepConnectorLine:yt,stepLabelStack:ft,stepInnerDot:bt,stepNumberLabel:_t,stepTextLabel:Tt,chooseTemplateCard:Ct,headerSection:St,headerTitle:jt,headerSubtitle:Nt,bannerContainer:vt,bannerIconBox:wt,bannerTitle:Bt,bannerSubtitle:Ft,bannerActionBtn:It,sectionTitle:At,filterPillsContainer:Lt,filterPill:Rt,templateCard:kt,selected:Et,templateCardTitle:qt,templateEditBtn:Dt,templateDescription:Pt,chipItem:Ht,wizardFooter:zt,previousBtn:Wt,disabled:Mt,stepCounterText:Qt,nextBtn:Ot,editTemplateHeaderSection:Gt,editTemplateCancelBtn:Yt,editTemplateSaveBtn:$t,formFieldBlock:Ut,formFieldLabel:Vt,requiredAsterisk:Kt,customTextField:Jt,formFieldHelperText:Zt,questionsHeaderSection:Xt,questionsTitle:es,questionsCountNumber:ts,filterByRow:ss,filterByLabel:as,categoryFilterFormControl:ns,categorySelectInput:ls,tableContainerWrapper:os,questionsTable:rs,tableHeaderRow:is,tableBodyRow:cs,thNumber:ds,tdNumber:us,thQuestion:hs,tdQuestion:ms,questionText:ps,thType:gs,tdType:xs,thCategory:ys,tdCategory:fs,categoryText:bs,thActions:_s,tdActions:Ts,questionTypeBadge:Cs,badgeTextLabel:Ss,badgeRating:js,badgeYesNo:Ns,badgeText:vs,tableEditBtn:ws,tableRemoveBtn:Bs,addQuestionWrapper:Fs,addQuestionBtn:Is,selectedCountSection:As,selectedCountText:Ls,selectedCountHighlight:Rs,studentsToolbar:ks,searchBarContainer:Es,studentSearchInput:qs,filterDropdownWrapper:Ds,teacherFilterWrapper:Ps,teacherAutocomplete:Hs,teacherAutocompletePaper:zs,teacherAutocompleteListbox:Ws,teacherOptionItem:Ms,filterSelectBox:Qs,studentsTableContainer:Os,studentsTable:Gs,studentsTableHeaderRow:Ys,checkboxHeaderCell:$s,tableHeaderCell:Us,checkboxBodyCell:Vs,studentTableRow:Ks,selectedRow:Js,studentNameCell:Zs,studentNameText:Xs,flagCell:ea,gradeCell:ta,gradeText:sa,emailCell:aa,emailText:na,studentsPagination:la,reviewSectionBlock:oa,reviewSectionHeader:ra,reviewSectionTitle:ia,reviewEditSectionBtn:ca,reviewFieldGroup:da,reviewFieldLabel:ua,reviewFieldValue:ha,reviewQuestionsTableContainer:ma,previewSurveyBtn:pa,publishBtn:ga},xa=({steps:a,activeStep:n,onBack:i})=>e.jsxs(t.Box,{className:s.stepperContainer,children:[e.jsx(t.Button,{onClick:i,startIcon:e.jsx(Te.ArrowBackIcon,{fontSize:"small"}),className:s.backButton,children:"Back to Surveys Dashboard"}),e.jsx(t.Box,{className:s.stepperProgress,children:a.map((m,o)=>{const l=o===n,b=o<n,p=o===a.length-1;return e.jsxs(t.Box,{className:`${s.stepColumn} ${p?s.stepColumnLast:""}`,children:[e.jsxs(t.Box,{className:s.stepCircleRow,children:[e.jsxs(t.Box,{className:`${s.stepCircle} ${l?s.active:b?s.completed:""}`,children:[l&&e.jsx(t.Box,{className:s.stepInnerDot}),b&&e.jsx(Ce.CheckIcon,{sx:{fontSize:16,color:"#ffffff"}})]}),!p&&e.jsx(t.Box,{className:`${s.stepConnectorLine} ${b?s.completed:""}`})]}),e.jsxs(t.Stack,{alignItems:"flex-start",spacing:.25,className:s.stepLabelStack,children:[e.jsxs(t.Typography,{variant:"caption",className:`${s.stepNumberLabel} ${l?s.active:""}`,children:["STEP ",m.stepNumber]}),e.jsx(t.Typography,{variant:"body2",className:`${s.stepTextLabel} ${l?s.active:""}`,children:m.label})]})]},m.stepCode)})})]}),ya=({onCreateBlank:a})=>e.jsxs(t.Box,{className:s.bannerContainer,children:[e.jsxs(t.Stack,{direction:"row",spacing:2,alignItems:"center",children:[e.jsx(t.Box,{className:s.bannerIconBox,children:e.jsx("img",{src:"/images/scratch-icon.png",alt:"Start from Scratch"})}),e.jsxs(t.Box,{children:[e.jsx(t.Typography,{variant:"subtitle1",className:s.bannerTitle,children:"Start from Scratch"}),e.jsx(t.Typography,{variant:"body2",className:s.bannerSubtitle,children:"Create a custom survey tailored to your specific needs"})]})]}),e.jsx(t.Button,{onClick:a,endIcon:e.jsx(Se.ArrowForwardIcon,{sx:{fontSize:16}}),className:s.bannerActionBtn,children:"CREATE BLANK SURVEY"})]}),fa=({categories:a,selectedCategory:n,onSelectCategory:i})=>e.jsx(t.Box,{className:s.filterPillsContainer,children:e.jsx(t.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:a.map(m=>{const o=n.toLowerCase()===m.toLowerCase();return e.jsx(t.Chip,{label:m,onClick:()=>i(m),className:`${s.filterPill} ${o?s.active:""}`},m)})})}),se=ne.createSvgIcon(e.jsx("path",{d:"m14.06 9.02.92.92L5.92 19H5v-.92zM17.66 3c-.25 0-.51.1-.7.29l-1.83 1.83 3.75 3.75 1.83-1.83c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.2-.2-.45-.29-.71-.29m-3.6 3.19L3 17.25V21h3.75L17.81 9.94z"}),"EditOutlined"),ba=({template:a,isSelected:n,onSelect:i,onEdit:m})=>e.jsxs(t.Box,{onClick:()=>i(a.id),className:`${s.templateCard} ${n?s.selected:""}`,children:[e.jsxs(t.Box,{children:[e.jsxs(t.Stack,{direction:"row",alignItems:"flex-start",justifyContent:"space-between",spacing:1,children:[e.jsx(t.Typography,{variant:"h6",className:s.templateCardTitle,children:a.title}),e.jsx(t.Button,{size:"small",onClick:o=>m(a,o),startIcon:e.jsx(se,{sx:{fontSize:14}}),className:s.templateEditBtn,children:"EDIT"})]}),e.jsx(t.Typography,{variant:"body2",className:s.templateDescription,children:a.description})]}),e.jsxs(t.Stack,{direction:"row",spacing:1,alignItems:"center",sx:{gap:.75,flexWrap:"nowrap",overflow:"hidden"},children:[e.jsx(t.Chip,{label:`${a.questionCount} questions`,size:"small",className:s.chipItem,sx:{flexShrink:0}}),(a.categories||[a.category]).slice(0,2).map((o,l)=>e.jsx(t.Chip,{label:o,size:"small",className:s.chipItem,sx:{flexShrink:0,maxWidth:"120px","& .MuiChip-label":{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"}}},l)),(a.categories?.length??1)>2&&e.jsx(t.Chip,{label:"...",size:"small",className:s.chipItem,sx:{flexShrink:0}})]})]}),_a=ne.createSvgIcon(e.jsx("path",{d:"M12 6.5c3.79 0 7.17 2.13 8.82 5.5-1.65 3.37-5.02 5.5-8.82 5.5S4.83 15.37 3.18 12C4.83 8.63 8.21 6.5 12 6.5m0-2C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5m0 5c1.38 0 2.5 1.12 2.5 2.5s-1.12 2.5-2.5 2.5-2.5-1.12-2.5-2.5 1.12-2.5 2.5-2.5m0-2c-2.48 0-4.5 2.02-4.5 4.5s2.02 4.5 4.5 4.5 4.5-2.02 4.5-4.5-2.02-4.5-4.5-4.5"}),"RemoveRedEyeOutlined"),le=({currentStep:a,totalSteps:n,onPrevious:i,onNext:m,isNextDisabled:o=!1,isLastStep:l=!1,nextLabel:b="NEXT",onPreview:p})=>e.jsxs(t.Box,{className:s.wizardFooter,children:[e.jsx(t.Button,{variant:"outlined",onClick:i,startIcon:e.jsx(Te.ArrowBackIcon,{sx:{fontSize:16}}),className:`${s.previousBtn} ${a===1?s.disabled:""}`,children:"PREVIOUS"}),e.jsxs(t.Typography,{variant:"body2",className:s.stepCounterText,children:["Step ",a," of ",n]}),l?e.jsxs(t.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:[p&&e.jsx(t.Button,{variant:"outlined",onClick:p,startIcon:e.jsx(_a,{sx:{fontSize:18}}),className:s.previewSurveyBtn,children:"SURVEY PREVIEW"}),e.jsx(t.Button,{variant:"contained",onClick:m,disabled:o,className:s.publishBtn,children:b||"PUBLISH"})]}):e.jsx(t.Button,{variant:"contained",onClick:m,disabled:o,endIcon:e.jsx(Se.ArrowForwardIcon,{sx:{fontSize:16}}),className:s.nextBtn,children:b})]}),Ta=({categories:a,selectedCategory:n,templates:i,selectedTemplateId:m,currentStepNumber:o,totalSteps:l,onSelectCategory:b,onSelectTemplate:p,onCreateBlank:c,onEditTemplate:C,onPrevious:y,onNext:g})=>e.jsxs(t.Box,{className:s.chooseTemplateCard,children:[e.jsxs(t.Box,{children:[e.jsx(t.Typography,{variant:"h4",className:s.headerTitle,children:"Choose a Template"}),e.jsx(t.Typography,{variant:"body1",className:s.headerSubtitle,children:"Start with a template or create from scratch"})]}),e.jsx(ya,{onCreateBlank:c}),e.jsxs(t.Stack,{spacing:1,children:[e.jsx(t.Typography,{variant:"h6",className:s.sectionTitle,children:"Survey Templates"}),e.jsx(fa,{categories:a,selectedCategory:n,onSelectCategory:b})]}),e.jsx(t.Grid,{container:!0,spacing:2.5,sx:{mt:1},children:i.map(x=>e.jsx(t.Grid,{item:!0,xs:12,sm:6,md:4,children:e.jsx(ba,{template:x,isSelected:m===x.id,onSelect:p,onEdit:C})},x.id))}),e.jsx(le,{currentStep:o,totalSteps:l,onPrevious:y,onNext:g})]}),Ca=ne.createSvgIcon(e.jsx("path",{d:"M6 19c0 1.1.9 2 2 2h8c1.1 0 2-.9 2-2V7H6zM8 9h8v10H8zm7.5-5-1-1h-5l-1 1H5v2h14V4z"}),"DeleteOutlineOutlined"),Ne=({type:a})=>{const n=o=>{if(typeof o=="number"||!isNaN(Number(o))){const l=Number(o);if(l===0)return"Text";if(l===1)return"MultipleChoice";if(l===2||l===3)return"Slider";if(l===4)return"YesNo";if(l===5)return"SingleChoice";if(l===6)return"Date"}return String(o)},i=o=>{switch(n(o)){case"Rating":case"StarRating":case"Slider":return s.badgeRating;case"YesNo":case"SingleChoice":return s.badgeYesNo;case"Text":case"TextInput":case"OpenField":return s.badgeText;default:return s.badgeText}},m=o=>{const l=n(o);switch(l){case"YesNo":return"Yes/No";case"SingleChoice":return"Single Choice";case"StarRating":case"Rating":return"Rating";case"TextInput":case"OpenField":case"Text":return"Text";case"MultipleChoice":return"Multiple Choice";default:return l}};return e.jsx(t.Box,{className:`${s.questionTypeBadge} ${i(a)}`,children:e.jsx(t.Typography,{variant:"caption",className:s.badgeTextLabel,children:m(a)})})},ve=({questions:a,onEditQuestion:n,onRemoveQuestion:i})=>{const[m,o]=S.useState(null),[l,b]=S.useState(!1),p=y=>{o(y),b(!0)},c=()=>{m!==null&&i(m),b(!1),o(null)},C=()=>{b(!1),o(null)};return e.jsxs(t.TableContainer,{className:s.tableContainerWrapper,children:[e.jsxs(t.Table,{className:s.questionsTable,children:[e.jsx(t.TableHead,{children:e.jsxs(t.TableRow,{className:s.tableHeaderRow,children:[e.jsx(t.TableCell,{className:s.thNumber,children:"#"}),e.jsx(t.TableCell,{className:s.thQuestion,children:"Question"}),e.jsx(t.TableCell,{className:s.thType,children:"Type"}),e.jsx(t.TableCell,{className:s.thCategory,children:"Category"}),e.jsx(t.TableCell,{className:s.thActions,children:"Actions"})]})}),e.jsx(t.TableBody,{children:a.map((y,g)=>e.jsxs(t.TableRow,{className:s.tableBodyRow,children:[e.jsxs(t.TableCell,{className:s.tdNumber,children:[g+1,"."]}),e.jsx(t.TableCell,{className:s.tdQuestion,children:e.jsx(t.Typography,{variant:"body2",className:s.questionText,dangerouslySetInnerHTML:{__html:y.questionText||""}})}),e.jsx(t.TableCell,{className:s.tdType,children:e.jsx(Ne,{type:y.type})}),e.jsx(t.TableCell,{className:s.tdCategory,children:e.jsx(t.Typography,{variant:"body2",className:s.categoryText,children:y.category})}),e.jsx(t.TableCell,{className:s.tdActions,children:e.jsxs(t.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:[e.jsx(t.Button,{onClick:()=>n(y.id),startIcon:e.jsx(se,{fontSize:"small"}),className:s.tableEditBtn,children:"Edit"}),e.jsx(t.Button,{onClick:()=>p(y.id),startIcon:e.jsx(Ca,{fontSize:"small"}),className:s.tableRemoveBtn,children:"Remove"})]})})]},y.id))})]}),e.jsxs(t.Dialog,{open:l,onClose:C,"aria-labelledby":"confirm-delete-dialog-title","aria-describedby":"confirm-delete-dialog-description",children:[e.jsx(t.DialogTitle,{id:"confirm-delete-dialog-title",sx:{fontWeight:"bold"},children:"Confirm Remove"}),e.jsx(t.DialogContent,{children:e.jsx(t.DialogContentText,{id:"confirm-delete-dialog-description",children:"Are you sure you want to remove this question?"})}),e.jsxs(t.DialogActions,{children:[e.jsx(t.Button,{onClick:C,color:"inherit",children:"Cancel"}),e.jsx(t.Button,{onClick:c,color:"error",autoFocus:!0,children:"Remove"})]})]})]})},Sa=({formData:a,questionCategories:n,filteredQuestions:i,totalQuestionsCount:m,currentStepNumber:o,totalSteps:l,onTemplateNameChange:b,onDescriptionChange:p,onCategoryFilterChange:c,onEditQuestion:C,onRemoveQuestion:y,onAddQuestion:g,onPrevious:x,onNext:A})=>{const q=E=>{c(E.target.value)};return e.jsxs(t.Box,{className:s.chooseTemplateCard,children:[e.jsxs(t.Box,{className:s.headerSection,children:[e.jsx(t.Typography,{variant:"h5",className:s.headerTitle,children:"Check Details"}),e.jsx(t.Typography,{variant:"body2",className:s.headerSubtitle,children:"Review and edit the details below."})]}),e.jsxs(t.Box,{className:s.formFieldBlock,children:[e.jsxs(t.Typography,{variant:"subtitle2",className:s.formFieldLabel,children:["Template Name ",e.jsx("span",{className:s.requiredAsterisk,children:"*"})]}),e.jsx(t.TextField,{fullWidth:!0,variant:"outlined",value:a.templateName,onChange:E=>b(E.target.value),placeholder:"Enter template name",className:s.customTextField})]}),e.jsxs(t.Box,{className:s.formFieldBlock,children:[e.jsx(t.Typography,{variant:"subtitle2",className:s.formFieldLabel,children:"Description and instructions of when to use"}),e.jsx(t.TextField,{fullWidth:!0,multiline:!0,rows:3,variant:"outlined",value:a.description,onChange:E=>p(E.target.value),placeholder:"Enter description and instructions",className:s.customTextField})]}),e.jsxs(t.Box,{className:s.questionsHeaderSection,children:[e.jsxs(t.Stack,{direction:"row",alignItems:"center",spacing:.75,sx:{mb:1.5},children:[e.jsx(t.Typography,{variant:"subtitle1",className:s.questionsTitle,children:"Questions"}),e.jsx(t.Typography,{variant:"subtitle1",className:s.questionsCountNumber,children:m})]}),e.jsxs(t.Stack,{direction:"row",alignItems:"center",spacing:1.5,className:s.filterByRow,children:[e.jsx(t.Typography,{variant:"body2",className:s.filterByLabel,children:"Filter by category"}),e.jsx(t.FormControl,{size:"small",className:s.categoryFilterFormControl,children:e.jsx(t.Select,{value:a.selectedCategoryFilter,onChange:q,className:s.categorySelectInput,children:n.map(E=>e.jsx(t.MenuItem,{value:E,children:E},E))})})]})]}),e.jsx(ve,{questions:i,onEditQuestion:C,onRemoveQuestion:y}),e.jsx(t.Box,{className:s.addQuestionWrapper,children:e.jsx(t.Button,{onClick:g,startIcon:e.jsx(je.AddIcon,{}),className:s.addQuestionBtn,children:"ADD QUESTION"})}),e.jsx(le,{currentStep:o,totalSteps:l,onPrevious:x,onNext:A,isNextDisabled:!a.templateName||a.templateName.trim()===""})]})},ja=({formData:a,currentStepNumber:n,totalSteps:i,onTitleChange:m,onDeadlineChange:o,onPrevious:l,onNext:b})=>e.jsxs(t.Box,{className:s.chooseTemplateCard,children:[e.jsxs(t.Box,{className:s.headerSection,children:[e.jsx(t.Typography,{variant:"h5",className:s.headerTitle,children:"Create Survey"}),e.jsx(t.Typography,{variant:"body2",className:s.headerSubtitle,children:"Set the title and deadline for your survey"})]}),e.jsxs(t.Box,{className:s.formFieldBlock,children:[e.jsxs(t.Typography,{variant:"subtitle2",className:s.formFieldLabel,children:["Title ",e.jsx("span",{className:s.requiredAsterisk,children:"*"})]}),e.jsx(t.TextField,{fullWidth:!0,variant:"outlined",value:a.title,onChange:p=>m(p.target.value),placeholder:"Enter survey title",className:s.customTextField})]}),e.jsxs(t.Box,{className:s.formFieldBlock,children:[e.jsxs(t.Typography,{variant:"subtitle2",className:s.formFieldLabel,children:["Deadline ",e.jsx("span",{className:s.requiredAsterisk,children:"*"})]}),e.jsx(fe.LocalizationProvider,{dateAdapter:Ue.AdapterMoment,children:e.jsx(fe.DateTimePicker,{value:a.deadline?xe(a.deadline,"DD.MM.YYYY hh:mm A"):null,onChange:p=>{o(p?p.format("DD.MM.YYYY hh:mm A"):"")},format:"DD.MM.YYYY hh:mm A",slotProps:{textField:{fullWidth:!0,variant:"outlined",placeholder:"DD.MM.YYYY hh:mm A",className:s.customTextField}}})}),e.jsx(t.Typography,{variant:"caption",className:s.formFieldHelperText,children:"Select the date and time when the survey will close"})]}),e.jsx(le,{currentStep:n,totalSteps:i,onPrevious:l,onNext:b,isNextDisabled:!a.title||a.title.trim()===""||!a.deadline})]}),ae=({size:a=32,color:n="#C44140"})=>e.jsx("svg",{width:a,height:a,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M28.2409 -0.141754C25.4195 3.28575 25.0819 7.25702 25.2536 11.6181C25.4635 16.9475 26.3117 24.291 27.1324 29.5842C27.2535 30.3658 26.3405 30.8232 25.7942 30.2545C22.7477 27.0829 19.2078 23.33 16.0196 19.1775C13.2409 22.6735 11.0153 26.7226 8.60824 31.0487C8.37898 31.4608 7.83452 31.5433 7.47943 31.2194C7.07049 30.8465 6.80209 30.3374 6.72382 29.7869C5.03439 17.9028 4.08511 12.0405 3.95375 -0.206989L28.2409 -0.141754Z",fill:n})}),w={"flag-of-session":"_flag-of-session_izm26_530","flag-of-session__title-red":"_flag-of-session__title-red_izm26_539","flag-of-session__title-red--text":"_flag-of-session__title-red--text_izm26_544","flag-of-session__title-yellow":"_flag-of-session__title-yellow_izm26_561","flag-of-session__title-yellow--text":"_flag-of-session__title-yellow--text_izm26_566","flag-of-session__content-green":"_flag-of-session__content-green_izm26_572","flag-of-session__content-green--text":"_flag-of-session__content-green--text_izm26_579","flag-of-session__item":"_flag-of-session__item_izm26_586","flag-of-session__item--title":"_flag-of-session__item--title_izm26_594","flag-of-session__item--content":"_flag-of-session__item--content_izm26_601","flag-of-session__item-column":"_flag-of-session__item-column_izm26_608","flag-of-session__item-column--no-bold":"_flag-of-session__item-column--no-bold_izm26_620","flag-of-session__item-column--content":"_flag-of-session__item-column--content_izm26_627"},be=a=>{switch(a){case"Red Flag":return e.jsxs("div",{className:w["flag-of-session__title-red"],children:[e.jsx(ae,{color:"#C44140",size:32}),e.jsx("span",{className:w["flag-of-session__title-red--text"],children:"Red Flag"})]});case"Yellow Flag":return e.jsxs("div",{className:w["flag-of-session__title-yellow"],children:[e.jsx(ae,{color:"#F5D500",size:32}),e.jsx("span",{className:w["flag-of-session__title-yellow--text"],children:"Yellow Flag"})]});default:return null}},Na=({flag:a,flagDetail:n,lastSafetyAnswer:i,lastStressAnswer:m,showResult:o,defaultStress:l,defaultSafety:b,defaultDecrease:p,isDetailView:c,hasReadyToLearn:C,inSession:y})=>o?e.jsxs("div",{className:w["flag-of-session"],style:{gap:"6px"},children:[(a==="Green Flag"||a==="Green")&&e.jsxs("div",{className:w["flag-of-session__content-green"],children:["Everything is ",e.jsx("p",{className:w["flag-of-session__content-green--text"],children:"fine"})]}),c&&a&&be(a||""),n?.stress&&(c?e.jsxs("div",{className:w["flag-of-session__item"],children:[e.jsx("p",{className:w["flag-of-session__item--title"],children:"Stress score:"}),e.jsxs("p",{className:w["flag-of-session__item--content"],children:[n?.stress?.score,"%"]})]}):e.jsxs("div",{className:w["flag-of-session__item"],children:[e.jsxs("span",{style:{fontWeight:600,color:n?.stress?.flag==="Red Flag"?"#C44140":"#F5D500",fontSize:"12px"},children:[n?.stress?.score,"%"]}),"Stress vs Last check-in ",m,"%"]})),n?.safety&&(c?e.jsxs("div",{className:w["flag-of-session__item"],children:[e.jsx("p",{className:w["flag-of-session__item--title"],children:"Safety score:"}),e.jsxs("p",{className:w["flag-of-session__item--content"],children:[n?.safety?.score,"%"]})]}):e.jsxs("div",{className:w["flag-of-session__item"],children:[e.jsxs("span",{style:{fontWeight:600,color:n?.safety?.flag==="Red Flag"?"#C44140":"#F5D500"},children:[n?.safety?.score,"%"]})," Safety vs Last check-in ",i,"%"]})),n?.decrease&&n?.decrease?.length>0&&(c?e.jsxs("div",{children:[e.jsxs("p",{className:w["flag-of-session__item--content"],children:[e.jsx("span",{className:w["flag-of-session__item--title"],children:"Sudden Drop: "}),e.jsxs("span",{className:w["flag-of-session__item--title"],children:[n.decrease.length," "]}),"core well-being metric shows a decrease of ",p,"% comparing their average of the last four check-ins."]}),e.jsx("ul",{className:w["flag-of-session__item-column--content"],children:n.decrease?.map((g,x)=>e.jsx("li",{style:{color:"#242424",marginLeft:"16px"},children:e.jsx("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:e.jsxs("p",{style:{margin:0},children:[g.questionText,": ",g.answer,"% ",g.averageOtherRatingsText?"":g.averageOtherRatings!==void 0?`vs avr ${g.averageOtherRatings}%`:"vs previous"]})})},x))})]}):y?e.jsxs("div",{className:w["flag-of-session__item-column"],children:[e.jsxs("p",{className:w["flag-of-session__item-column--no-bold"],children:["Sudden Drop: ",n.decrease.length||0," core well-being metric shows a decrease compared to the average of the last four check-ins."]}),e.jsx("ul",{className:w["flag-of-session__item-column--content"],children:n.decrease?.map((g,x)=>{const q=a?.includes("Red")?"#C44140":"#F5D500";return e.jsx("li",{style:{color:"#242424",marginLeft:"16px"},children:e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[e.jsxs("p",{style:{margin:0,fontSize:"12px"},children:[g.questionText,":"]}),e.jsxs("p",{style:{margin:0,color:q,fontSize:"12px"},children:[g.answer,"%"]}),g.averageOtherRatingsText?"":g.averageOtherRatings!==void 0&&e.jsxs("p",{style:{margin:0,fontSize:"12px",marginLeft:"4px"},children:["vs avr ",g.averageOtherRatings,"%"]})]})},x)})})]}):e.jsxs("div",{className:w["flag-of-session__item"],children:["Sudden Drop: Any core well-being metric shows a percentage decrease of ",p||20,"% comparing their average of the last four check-ins."]})),n?.readinessToLearn&&(c?e.jsx("div",{children:e.jsxs("p",{className:w["flag-of-session__item--content"],children:[e.jsx("span",{className:w["flag-of-session__item--title"],children:"Ready to learn: "}),n?.readinessToLearn]})}):e.jsxs("div",{className:w["flag-of-session__item"],children:["Ready to learn: ",n?.readinessToLearn]}))]}):e.jsxs("div",{className:w["flag-of-session"],children:[be(a||""),b&&e.jsxs("div",{className:w["flag-of-session__item"],children:[e.jsx("p",{className:w["flag-of-session__item--title"],children:"Safety score:"}),e.jsxs("p",{className:w["flag-of-session__item--content"],children:["Under ",b,"%"]})]}),l&&e.jsxs("div",{className:w["flag-of-session__item"],children:[e.jsx("p",{className:w["flag-of-session__item--title"],children:"Stress level:"}),e.jsxs("p",{className:w["flag-of-session__item--content"],children:["Higher than ",l,"%"]})]}),p&&e.jsx("div",{children:e.jsxs("p",{className:w["flag-of-session__item--content"],children:[e.jsx("span",{className:w["flag-of-session__item--title"],children:"Sudden Drop: "}),"Any core well-being metric shows a percentage decrease of ",p,"% comparing their average of the last four check-ins."]})}),C&&e.jsx("div",{children:e.jsxs("p",{className:w["flag-of-session__item--content"],children:[e.jsx("span",{className:w["flag-of-session__item--title"],children:"Ready to learn: "}),"The student reported as not ready to learn in last check-in."]})})]}),va=ne.styled$1(({className:a,...n})=>e.jsx(t.Tooltip,{...n,classes:{popper:a}}))(({theme:a})=>({zIndex:1e3,[`& .${t.tooltipClasses.tooltip}`]:{backgroundColor:"transparent !important",marginTop:"8px !important",fontFamily:"Poppins-Regular"},[`& .${t.tooltipClasses.arrow}`]:{color:a.palette.common.white,top:"4px !important"}})),wa=a=>{if(!a)return null;const n=a.toLowerCase();return n==="red"?e.jsx(ae,{size:32,color:"#C44140"}):n==="yellow"?e.jsx(ae,{size:32,color:"#F5D500"}):n==="green"?e.jsx(ae,{size:32,color:"#10B981"}):null},Ba=({students:a,totalStudentsCount:n,totalSelectedCount:i,selectedStudentIds:m,filters:o,gradeOptions:l,flagOptions:b,teacherOptions:p,page:c,rowsPerPage:C,isAllSelected:y,isIndeterminate:g,sortBy:x,sortOrder:A,onSortChange:q,currentStepNumber:E,totalSteps:j,onSearchChange:F,onGradeChange:T,onFlagChange:h,onTeacherChange:I,onPageChange:z,onRowsPerPageChange:H,onToggleSelectAll:Y,onToggleStudent:O,onPrevious:$,onNext:G})=>{const K=r=>{T(r.target.value)},f=r=>{h(r.target.value)},_=(r,N)=>{I(N||"All Teachers")},d=S.useMemo(()=>!p||p.length===0?["All Teachers"]:p.includes("All Teachers")?p:["All Teachers",...p],[p]),B=(r,N)=>{const v=(N.inputValue||"").trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"");return v?r.filter(D=>D.toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"").includes(v)):r};return e.jsxs(t.Box,{className:s.chooseTemplateCard,children:[e.jsxs(t.Box,{className:s.headerSection,children:[e.jsx(t.Typography,{variant:"h5",className:s.headerTitle,children:"Select Students"}),e.jsx(t.Typography,{variant:"body2",className:s.headerSubtitle,children:"Choose the students who should participate in this survey"})]}),e.jsx(t.Box,{className:s.selectedCountSection,children:e.jsxs(t.Typography,{variant:"subtitle1",className:s.selectedCountText,children:["Selected students"," ",e.jsx(t.Box,{component:"span",className:s.selectedCountHighlight,children:i})]})}),e.jsxs(t.Box,{className:s.studentsToolbar,children:[e.jsx(t.Box,{className:s.searchBarContainer,children:e.jsx(t.TextField,{fullWidth:!0,size:"small",placeholder:"Search students by name or email...",value:o.searchQuery,onChange:r=>F(r.target.value),className:s.studentSearchInput,InputProps:{startAdornment:e.jsx(t.InputAdornment,{position:"start",children:e.jsx(Ve.SearchIcon,{sx:{color:"#94a3b8",fontSize:20}})})}})}),e.jsx(t.Box,{className:s.filterDropdownWrapper,children:e.jsx(t.FormControl,{size:"small",fullWidth:!0,children:e.jsx(t.Select,{value:o.selectedGrade,onChange:K,displayEmpty:!0,className:s.filterSelectBox,children:l.map(r=>e.jsx(t.MenuItem,{value:r,children:r},r))})})}),e.jsx(t.Box,{className:s.filterDropdownWrapper,children:e.jsx(t.FormControl,{size:"small",fullWidth:!0,children:e.jsx(t.Select,{value:o.selectedFlag,onChange:f,displayEmpty:!0,className:s.filterSelectBox,children:b.map(r=>e.jsx(t.MenuItem,{value:r.value,children:r.label},r.value))})})}),e.jsx(t.Box,{className:s.teacherFilterWrapper,children:e.jsx(t.Autocomplete,{size:"small",fullWidth:!0,options:d,value:o.selectedTeacher||"All Teachers",onChange:_,disableClearable:o.selectedTeacher==="All Teachers",clearOnBlur:!0,handleHomeEndKeys:!0,isOptionEqualToValue:(r,N)=>!N||r===N||N==="All Teachers",filterOptions:B,noOptionsText:"No teachers found",className:s.teacherAutocomplete,classes:{paper:s.teacherAutocompletePaper,listbox:s.teacherAutocompleteListbox},componentsProps:{paper:{className:s.teacherAutocompletePaper,sx:{backgroundColor:"#ffffff !important",color:"#000000 !important"}},popper:{sx:{zIndex:1300}}},slotProps:{paper:{className:s.teacherAutocompletePaper,sx:{backgroundColor:"#ffffff !important",color:"#000000 !important"}},popper:{sx:{zIndex:1300}}},renderOption:(r,N,{selected:v})=>{const{key:D,...u}=r;return e.jsx("li",{...u,className:s.teacherOptionItem,style:{backgroundColor:v?"#f1f5f9":"#ffffff",color:"#000000",fontSize:"14px",fontWeight:v?600:500,padding:"9px 14px",cursor:"pointer"},children:N},D||N)},renderInput:r=>e.jsx(t.TextField,{...r,placeholder:"All Teachers",size:"small",inputProps:{...r.inputProps,style:{color:"#000000",fontWeight:500}}})})})]}),e.jsxs(t.Box,{className:s.studentsTableContainer,children:[e.jsxs(t.Table,{className:s.studentsTable,children:[e.jsx(t.TableHead,{children:e.jsxs(t.TableRow,{className:s.studentsTableHeaderRow,children:[e.jsx(t.TableCell,{className:s.checkboxHeaderCell,children:e.jsx(t.Checkbox,{checked:y,indeterminate:g,onChange:Y,sx:{color:"#cbd5e1","&.Mui-checked":{color:"#2563eb"},"&.MuiCheckbox-indeterminate":{color:"#2563eb"}}})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="name",direction:x==="name"?A:"asc",onClick:()=>q("name"),children:"Student Name"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="flag",direction:x==="flag"?A:"asc",onClick:()=>q("flag"),children:"Flag"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="grade",direction:x==="grade"?A:"asc",onClick:()=>q("grade"),children:"Grade"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="email",direction:x==="email"?A:"asc",onClick:()=>q("email"),children:"Email"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="teacher",direction:x==="teacher"?A:"asc",onClick:()=>q("teacher"),children:"Teacher"})})]})}),e.jsx(t.TableBody,{children:a.length===0?e.jsx(t.TableRow,{children:e.jsx(t.TableCell,{colSpan:5,align:"center",sx:{py:4,color:"#94a3b8"},children:"No students found matching current filters."})}):a.map(r=>{const N=m.includes(r.id);return e.jsxs(t.TableRow,{className:`${s.studentTableRow} ${N?s.selectedRow:""}`,onClick:()=>O(r.id),children:[e.jsx(t.TableCell,{className:s.checkboxBodyCell,onClick:v=>v.stopPropagation(),children:e.jsx(t.Checkbox,{checked:N,onChange:()=>O(r.id),sx:{color:"#cbd5e1","&.Mui-checked":{color:"#2563eb"}}})}),e.jsx(t.TableCell,{className:s.studentNameCell,children:e.jsxs(t.Stack,{direction:"row",alignItems:"center",spacing:1.75,children:[e.jsx("img",{src:r.avatarUrl,alt:r.name,style:{width:44,height:44,borderRadius:"50%",objectFit:"cover"}}),e.jsx(t.Typography,{variant:"body2",className:s.studentNameText,children:r.name})]})}),e.jsx(t.TableCell,{className:s.flagCell,children:e.jsx(va,{arrow:!0,placement:"bottom",title:r?.flag&&r.flag!=="none"?e.jsx(Na,{flag:r.flag==="red"?"Red Flag":r.flag==="yellow"?"Yellow Flag":"Green Flag",flagDetail:r.flagDetail,lastSafetyAnswer:r.lastSafetyAnswer,lastStressAnswer:r.lastStressAnswer,showResult:!0}):"",children:e.jsx("span",{children:e.jsx("div",{style:{display:"flex",justifyContent:"center",cursor:"pointer"},children:wa(r.flag)})})})}),e.jsx(t.TableCell,{className:s.gradeCell,children:e.jsx(t.Typography,{variant:"body2",className:s.gradeText,children:r.grade})}),e.jsx(t.TableCell,{className:s.emailCell,children:e.jsx(t.Typography,{variant:"body2",className:s.emailText,children:r.email})}),e.jsx(t.TableCell,{children:e.jsx(t.Typography,{variant:"body2",sx:{color:"#475569"},children:r.listTeachers&&r.listTeachers.length>0?r.listTeachers.map(v=>v.name).filter(Boolean).join(", "):"-"})})]},r.id)})})]}),n>0&&e.jsx(t.TablePagination,{rowsPerPageOptions:[5,10,25,50],component:"div",count:n,rowsPerPage:C,page:c,onPageChange:z,onRowsPerPageChange:H,className:s.studentsPagination})]}),e.jsx(le,{currentStep:E,totalSteps:j,onPrevious:$,onNext:G})]})},Fa=({size:a=32,color:n="#C44140"})=>e.jsx("svg",{width:a,height:a,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:e.jsx("path",{d:"M28.2409 -0.141754C25.4195 3.28575 25.0819 7.25702 25.2536 11.6181C25.4635 16.9475 26.3117 24.291 27.1324 29.5842C27.2535 30.3658 26.3405 30.8232 25.7942 30.2545C22.7477 27.0829 19.2078 23.33 16.0196 19.1775C13.2409 22.6735 11.0153 26.7226 8.60824 31.0487C8.37898 31.4608 7.83452 31.5433 7.47943 31.2194C7.07049 30.8465 6.80209 30.3374 6.72382 29.7869C5.03439 17.9028 4.08511 12.0405 3.95375 -0.206989L28.2409 -0.141754Z",fill:n})}),Ia=t.styled(({className:a,...n})=>e.jsx(t.Tooltip,{...n,classes:{popper:a}}))(()=>({[`& .${t.tooltipClasses.tooltip}`]:{backgroundColor:"#ffffff",color:"#1e293b",maxWidth:220,fontSize:"0.75rem",border:"1px solid #e2e8f0",boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)",borderRadius:"8px",padding:"8px 12px"},[`& .${t.tooltipClasses.arrow}`]:{color:"#ffffff","&:before":{border:"1px solid #e2e8f0"}}})),Aa=({flag:a,tooltip:n})=>{if(a==="none")return null;let i="#10B981";a==="red"?i="#D10530":a==="yellow"?i="#F5D500":a==="green"&&(i="#0F9655");const m=n?e.jsx(t.Box,{sx:{lineHeight:1.4},children:n}):e.jsx(t.Box,{sx:{lineHeight:1.4},children:a==="red"?e.jsxs(e.Fragment,{children:[e.jsx(t.Box,{component:"span",sx:{color:"#D10530",fontWeight:700},children:"High"})," Risk,",e.jsx("br",{}),e.jsx(t.Box,{component:"span",sx:{color:"#D10530",fontWeight:700},children:"Negative"})," readiness to learn"]}):a==="yellow"?e.jsxs(e.Fragment,{children:[e.jsx(t.Box,{component:"span",sx:{color:"#F5D500",fontWeight:700},children:"Moderate"})," Risk,",e.jsx("br",{}),e.jsx(t.Box,{component:"span",sx:{color:"#F5D500",fontWeight:700},children:"Caution"})," readiness to learn"]}):e.jsxs(e.Fragment,{children:[e.jsx(t.Box,{component:"span",sx:{color:"#0F9655",fontWeight:700},children:"Low"})," Risk,",e.jsx("br",{}),e.jsx(t.Box,{component:"span",sx:{color:"#0F9655",fontWeight:700},children:"Positive"})," readiness to learn"]})});return e.jsx(Ia,{title:m,arrow:!0,placement:"top",children:e.jsx(t.Box,{component:"span",sx:{display:"inline-flex",alignItems:"center",cursor:"pointer",transition:"transform 0.15s ease","&:hover":{transform:"scale(1.15)"}},children:e.jsx(Fa,{color:i,size:28})})})},La=ne.createSvgIcon(e.jsx("path",{d:"M19 4h-1V2h-2v2H8V2H6v2H5c-1.11 0-1.99.9-1.99 2L3 20c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2m0 16H5V10h14zm0-12H5V6h14zM9 14H7v-2h2zm4 0h-2v-2h2zm4 0h-2v-2h2zm-8 4H7v-2h2zm4 0h-2v-2h2zm4 0h-2v-2h2z"}),"CalendarMonthOutlined"),Ra=({open:a,title:n,description:i,deadline:m,questions:o,onClose:l})=>{const b=c=>{if(typeof c=="number"||!isNaN(Number(c))&&String(c).trim()!==""){const C=Number(c);if(C===0)return"Text";if(C===1)return"MultipleChoice";if(C===2||C===3)return"Slider";if(C===4)return"YesNo";if(C===5)return"SingleChoice";if(C===6)return"Date";if(C===9)return"Summarize";if(C===12)return"DropDown"}return String(c)},p=c=>{try{const C=document.createElement("textarea");return C.innerHTML=c,C.value}catch{return c}};return e.jsxs(t.Dialog,{open:a,onClose:l,maxWidth:"md",fullWidth:!0,PaperProps:{sx:{borderRadius:"16px",p:1,maxHeight:"90vh"}},children:[e.jsxs(t.DialogTitle,{sx:{display:"flex",justifyContent:"space-between",alignItems:"center",pb:1,fontWeight:700,fontSize:"1.1rem",color:"#0f172a"},children:["Survey preview",e.jsx(t.IconButton,{onClick:l,size:"small",sx:{color:"#64748b"},children:e.jsx(Ke.CloseIcon,{fontSize:"small"})})]}),e.jsxs(t.DialogContent,{dividers:!0,sx:{p:3},children:[e.jsx(t.Typography,{variant:"h6",sx:{fontWeight:800,color:"#0f172a",mb:.5},children:n||"Student Well Being"}),e.jsx(t.Typography,{variant:"body2",sx:{color:"#64748b",mb:2},children:i||"General assessment of student wellness and quality of life"}),m&&e.jsxs(t.Stack,{direction:"row",spacing:1,alignItems:"center",sx:{color:"#64748b",mb:3},children:[e.jsx(La,{sx:{fontSize:16,color:"#2563eb"}}),e.jsxs(t.Typography,{variant:"caption",sx:{fontWeight:600},children:["Due: ",m]})]}),e.jsx(t.Stack,{spacing:3,children:o.map((c,C)=>{const y=b(c.type),g=c.options&&c.options.length>0?c.options:c.answers&&Array.isArray(c.answers)?c.answers.map(x=>typeof x=="string"?x:x?.text??x?.answerText??"").filter(Boolean):[];return e.jsxs(t.Box,{sx:{pb:1},children:[e.jsxs(t.Box,{sx:{display:"flex",gap:"4px",fontWeight:600,color:"#1e293b",mb:1.5,fontSize:"0.875rem"},children:[e.jsxs(t.Box,{children:[C+1,"."]}),e.jsx(t.Box,{sx:{"& p":{m:0,display:"inline"},"& span":{display:"inline"}},dangerouslySetInnerHTML:{__html:p(c.questionText||"")}})]}),(y==="Rating"||y==="StarRating"||y==="Slider")&&e.jsx(t.Box,{sx:{px:2,py:1},children:e.jsx(ce.SliderSurveyComponent,{questionId:Number(c.id)||0,valueText:"50",minText:c.fromLabel||"",maxText:c.toLabel||"",isBeforeSession:!1,isPageResult:!0})}),y==="MultipleChoice"&&e.jsx(t.Box,{sx:{px:2},children:e.jsx(ce.MultiChoiceComponent,{questionId:Number(c.id)||0,valueText:"",isUserChangeSession:!0,questionAnswer:g,isPageResult:!0})}),(y==="YesNo"||y==="SingleChoice")&&e.jsx(t.Box,{sx:{px:2},children:e.jsx(ce.SingleChoiceComponent,{questionId:Number(c.id)||0,valueText:"",isUserChangeSession:!0,questionAnswer:g.length>0?g:y==="YesNo"?["Yes","No"]:[]})}),(y==="Text"||y==="TextInput"||y==="OpenField")&&e.jsx(t.TextField,{fullWidth:!0,multiline:!0,rows:2,placeholder:"Your answer...",size:"small",sx:{"& .MuiOutlinedInput-root":{borderRadius:"8px",backgroundColor:"#ffffff"}}}),y==="DropDown"&&e.jsx(t.Box,{sx:{px:2},children:e.jsx(ce.DropDownComponent,{questionItemName:"",questionId:Number(c.id)||0,valueText:"",isUserChangeSession:!0,questionAnswer:g.map((x,A)=>({id:A,text:x}))})}),y==="Summarize"&&e.jsx(t.TextField,{fullWidth:!0,multiline:!0,rows:4,placeholder:"Summarize your thoughts...",size:"small",sx:{"& .MuiOutlinedInput-root":{borderRadius:"8px",backgroundColor:"#ffffff"}}})]},c.id)})})]})]})},ka=({templateFormData:a,surveyFormData:n,selectedStudents:i,currentStepNumber:m,totalSteps:o,onEditTemplateDetails:l,onEditSurveyDetails:b,onEditSelectedStudents:p,onPrevious:c,onPublish:C})=>{const[y,g]=S.useState(!1);return e.jsxs(t.Box,{className:s.chooseTemplateCard,children:[e.jsxs(t.Box,{className:s.reviewSectionBlock,children:[e.jsxs(t.Box,{className:s.reviewSectionHeader,children:[e.jsx(t.Typography,{variant:"h6",className:s.reviewSectionTitle,children:"Template Details"}),e.jsx(t.Button,{variant:"text",onClick:l,startIcon:e.jsx(se,{sx:{fontSize:16}}),className:s.reviewEditSectionBtn,children:"EDIT"})]}),e.jsxs(t.Box,{className:s.reviewFieldGroup,children:[e.jsx(t.Typography,{variant:"caption",className:s.reviewFieldLabel,children:"Template Name"}),e.jsx(t.Typography,{variant:"body2",className:s.reviewFieldValue,children:a.templateName||"Well-being"})]}),e.jsxs(t.Box,{className:s.reviewFieldGroup,children:[e.jsx(t.Typography,{variant:"caption",className:s.reviewFieldLabel,children:"Description and instructions of when to use"}),e.jsx(t.Typography,{variant:"body2",className:s.reviewFieldValue,children:a.description||"General assessment of student wellness and quality of life"})]}),e.jsxs(t.Box,{className:s.reviewFieldGroup,sx:{mt:3},children:[e.jsx(t.Typography,{variant:"caption",className:s.reviewFieldLabel,children:"Questions"}),e.jsx(t.Typography,{variant:"h6",className:s.questionsHeadingText,sx:{mb:1.5},children:e.jsx("span",{className:s.questionCountBadge,children:a.questions.length})}),e.jsx(t.Box,{className:s.reviewQuestionsTableContainer,children:e.jsxs(t.Table,{className:s.questionsTable,children:[e.jsx(t.TableHead,{children:e.jsxs(t.TableRow,{className:s.tableHeaderRow,children:[e.jsx(t.TableCell,{className:s.thNumber,children:"#"}),e.jsx(t.TableCell,{className:s.thQuestion,children:"Question"}),e.jsx(t.TableCell,{className:s.thType,children:"Type"}),e.jsx(t.TableCell,{className:s.thCategory,children:"Category"})]})}),e.jsx(t.TableBody,{children:a.questions.map((x,A)=>e.jsxs(t.TableRow,{className:s.tableBodyRow,children:[e.jsxs(t.TableCell,{className:s.tdNumber,children:[A+1,"."]}),e.jsx(t.TableCell,{className:s.tdQuestion,children:e.jsx(t.Typography,{variant:"body2",className:s.questionText,dangerouslySetInnerHTML:{__html:x.questionText||""}})}),e.jsx(t.TableCell,{className:s.tdType,children:e.jsx(Ne,{type:x.type})}),e.jsx(t.TableCell,{className:s.tdCategory,children:e.jsx(t.Typography,{variant:"body2",className:s.categoryText,children:x.category})})]},x.id))})]})})]})]}),e.jsxs(t.Box,{className:s.reviewSectionBlock,children:[e.jsxs(t.Box,{className:s.reviewSectionHeader,children:[e.jsx(t.Typography,{variant:"h6",className:s.reviewSectionTitle,children:"Survey Details"}),e.jsx(t.Button,{variant:"text",onClick:b,startIcon:e.jsx(se,{sx:{fontSize:16}}),className:s.reviewEditSectionBtn,children:"EDIT"})]}),e.jsxs(t.Box,{className:s.reviewFieldGroup,children:[e.jsx(t.Typography,{variant:"caption",className:s.reviewFieldLabel,children:"Title"}),e.jsx(t.Typography,{variant:"body2",className:s.reviewFieldValue,children:n.title||"Student Well Being"})]}),e.jsxs(t.Box,{className:s.reviewFieldGroup,children:[e.jsx(t.Typography,{variant:"caption",className:s.reviewFieldLabel,children:"Deadline"}),e.jsx(t.Typography,{variant:"body2",className:s.reviewFieldValue,children:n.deadline||"15th January 2026, 12:00 PM"})]})]}),e.jsxs(t.Box,{className:s.reviewSectionBlock,children:[e.jsxs(t.Box,{className:s.reviewSectionHeader,children:[e.jsxs(t.Typography,{variant:"h6",className:s.reviewSectionTitle,children:["Selected Students"," ",e.jsx(t.Box,{component:"span",sx:{color:"#2563eb",fontWeight:700},children:i.length})]}),e.jsx(t.Button,{variant:"text",onClick:p,startIcon:e.jsx(se,{sx:{fontSize:16}}),className:s.reviewEditSectionBtn,children:"EDIT"})]}),e.jsx(t.Box,{className:s.studentsTableContainer,children:e.jsxs(t.Table,{className:s.studentsTable,children:[e.jsx(t.TableHead,{children:e.jsxs(t.TableRow,{className:s.tableHeaderRow,children:[e.jsx(t.TableCell,{className:s.tableHeaderCell,children:"Student Name"}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:"Flag"}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:"Grade"}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:"Email"})]})}),e.jsx(t.TableBody,{children:i.length===0?e.jsx(t.TableRow,{children:e.jsx(t.TableCell,{colSpan:4,align:"center",sx:{py:3,color:"#94a3b8"},children:"No students selected."})}):i.map(x=>e.jsxs(t.TableRow,{className:s.studentTableRow,children:[e.jsx(t.TableCell,{className:s.studentNameCell,children:e.jsxs(t.Stack,{direction:"row",alignItems:"center",spacing:1.5,children:[e.jsx(t.Avatar,{src:x.avatarUrl,alt:x.name,sx:{width:28,height:28,fontSize:"0.75rem",bgcolor:"#e0e7ff",color:"#3730a3"},children:x.name.charAt(0)}),e.jsx(t.Typography,{variant:"body2",className:s.studentNameText,children:x.name})]})}),e.jsx(t.TableCell,{className:s.flagCell,children:e.jsx(Aa,{flag:x.flag,tooltip:x.flagTooltip})}),e.jsx(t.TableCell,{className:s.gradeCell,children:e.jsx(t.Typography,{variant:"body2",className:s.gradeText,children:x.grade})}),e.jsx(t.TableCell,{className:s.emailCell,children:e.jsx(t.Typography,{variant:"body2",className:s.emailText,children:x.email})})]},x.id))})]})})]}),e.jsx(le,{currentStep:m,totalSteps:o,isLastStep:!0,nextLabel:"PUBLISH",onPreview:()=>g(!0),onPrevious:c,onNext:C}),e.jsx(Ra,{open:y,title:n.title||a.templateName,description:a.description,deadline:n.deadline,questions:a.questions,onClose:()=>g(!1)})]})},Ea=[{id:"q-1",orderNumber:1,questionText:"How would you rate your overall well-being?",type:"Rating",category:"Overall Well-being"},{id:"q-2",orderNumber:2,questionText:"Do you feel balanced in your daily life?",type:"YesNo",category:"Life Balance"},{id:"q-3",orderNumber:3,questionText:"What contributes most to your well-being?",type:"Text",category:"Well-being Factors"}],qa=({template:a,initialDraftData:n,onSave:i,onCancel:m,onAddQuestionRedirect:o,onEditQuestionRedirect:l})=>{const b=S.useMemo(()=>{const T=a.rawTemplate?.questionTemplates,h=ue(T,a.category||"Well-being");return h.length>0?h:Ea},[a]),[p,c]=S.useState(()=>n||{id:a.id,templateName:a.title,description:a.description||"",showLandingPageFlag:!1,selectedCategoryFilter:"All",questions:b}),C=S.useMemo(()=>{const T=new Set;p.questions.forEach(I=>{const z=I.category?.trim();z&&T.add(z)});const h=Array.from(T);return h.length>0?["All",...h]:["All"]},[p.questions]),y=S.useMemo(()=>p.selectedCategoryFilter==="All"?p.questions:p.questions.filter(T=>T.category===p.selectedCategoryFilter),[p.questions,p.selectedCategoryFilter]),g=T=>{c(h=>({...h,templateName:T}))},x=T=>{c(h=>({...h,description:T}))},A=T=>{c(h=>({...h,selectedCategoryFilter:T}))},q=T=>{l&&l(T,p)},E=T=>{c(h=>({...h,questions:h.questions.filter(I=>I.id!==T).map((I,z)=>({...I,orderNumber:z+1}))}))},j=()=>{o&&o(p)},F=()=>{const T={...a,title:p.templateName,description:p.description,questionCount:p.questions.length,rawTemplate:{...a.rawTemplate,questionTemplates:p.questions.map((h,I)=>({...h,questionId:typeof h.id=="number"||String(h.id).startsWith("q-")?h.id:parseInt(String(h.id)),questionText:h.questionText,type:h.type,category:h.category,fromLabel:h.fromLabel,toLabel:h.toLabel,numberOfStars:h.numberOfStars,orderDefaultQuestionTemplate:h.orderNumber??I+1,options:h.options||[],answers:h.options&&Array.isArray(h.options)&&h.options.length>0?h.options.map((z,H)=>({id:0,text:typeof z=="string"?z:z?.text||"",order:H})):h.answers||[]}))}};i(T)};return{formData:p,categoryOptions:C,filteredQuestions:y,totalQuestionsCount:p.questions.length,handleTemplateNameChange:g,handleDescriptionChange:x,handleCategoryFilterChange:A,handleEditQuestion:q,handleRemoveQuestion:E,handleAddQuestion:j,handleSave:F,handleCancel:m}},Da=({template:a,initialDraftData:n,onSave:i,onCancel:m,onAddQuestionRedirect:o,onEditQuestionRedirect:l})=>{const{formData:b,categoryOptions:p,filteredQuestions:c,totalQuestionsCount:C,handleTemplateNameChange:y,handleDescriptionChange:g,handleCategoryFilterChange:x,handleEditQuestion:A,handleRemoveQuestion:q,handleAddQuestion:E,handleSave:j,handleCancel:F}=qa({template:a,initialDraftData:n,onSave:i,onCancel:m,onAddQuestionRedirect:o,onEditQuestionRedirect:l});S.useEffect(()=>{window.scrollTo({top:0,behavior:"instant"});const h=document.querySelector("main");h&&h.scrollTo({top:0,behavior:"instant"});const I=document.documentElement||document.body;I&&(I.scrollTop=0)},[]);const T=h=>{x(h.target.value)};return e.jsxs(t.Box,{className:s.chooseTemplateCard,children:[e.jsxs(t.Box,{className:s.editTemplateHeaderSection,children:[e.jsx(t.Typography,{variant:"h5",className:s.headerTitle,children:"Edit Template"}),e.jsxs(t.Stack,{direction:"row",alignItems:"center",spacing:2,children:[e.jsx(t.Button,{onClick:F,className:s.editTemplateCancelBtn,children:"CANCEL"}),e.jsx(t.Button,{variant:"contained",onClick:j,startIcon:e.jsx(Ce.CheckIcon,{}),className:s.editTemplateSaveBtn,disabled:!b.templateName||b.templateName.trim()==="",children:"SAVE CHANGES"})]})]}),e.jsxs(t.Box,{className:s.formFieldBlock,children:[e.jsxs(t.Typography,{variant:"subtitle2",className:s.formFieldLabel,children:["Template Name ",e.jsx("span",{className:s.requiredAsterisk,children:"*"})]}),e.jsx(t.TextField,{fullWidth:!0,variant:"outlined",value:b.templateName,onChange:h=>y(h.target.value),placeholder:"Enter template name",className:s.customTextField})]}),e.jsxs(t.Box,{className:s.formFieldBlock,children:[e.jsx(t.Typography,{variant:"subtitle2",className:s.formFieldLabel,children:"Description and instructions of when to use"}),e.jsx(t.TextField,{fullWidth:!0,multiline:!0,rows:3,variant:"outlined",value:b.description,onChange:h=>g(h.target.value),placeholder:"Enter description and instructions",className:s.customTextField})]}),e.jsxs(t.Box,{className:s.questionsHeaderSection,children:[e.jsxs(t.Stack,{direction:"row",alignItems:"center",spacing:.75,sx:{mb:1.5},children:[e.jsx(t.Typography,{variant:"subtitle1",className:s.questionsTitle,children:"Questions"}),e.jsx(t.Typography,{variant:"subtitle1",className:s.questionsCountNumber,children:C})]}),e.jsxs(t.Stack,{direction:"row",alignItems:"center",spacing:1.5,className:s.filterByRow,children:[e.jsx(t.Typography,{variant:"body2",className:s.filterByLabel,children:"Filter by category"}),e.jsx(t.FormControl,{size:"small",className:s.categoryFilterFormControl,children:e.jsx(t.Select,{value:b.selectedCategoryFilter,onChange:T,className:s.categorySelectInput,children:p.map(h=>e.jsx(t.MenuItem,{value:h,children:h},h))})})]})]}),e.jsx(ve,{questions:c,onEditQuestion:A,onRemoveQuestion:q}),e.jsx(t.Box,{className:s.addQuestionWrapper,children:e.jsx(t.Button,{onClick:E,startIcon:e.jsx(je.AddIcon,{}),className:s.addQuestionBtn,children:"ADD QUESTION"})})]})},Pa=()=>{const a=he.useDispatch(),n=he.useSelector(R=>R?.common?.user?.roles),i=_e.useNavigate(),m=S.useMemo(()=>{if(localStorage.getItem("is_returning_from_question")==="true"){const W=localStorage.getItem("create_survey_draft");if(W)try{return JSON.parse(W)}catch{}}return null},[]);S.useEffect(()=>{const R=setTimeout(()=>{localStorage.getItem("is_returning_from_question")==="true"?localStorage.removeItem("is_returning_from_question"):localStorage.removeItem("create_survey_draft")},500);return()=>clearTimeout(R)},[]);const{steps:o,activeStep:l,categories:b,selectedCategory:p,selectedTemplateId:c,templates:C,editingTemplate:y,handleSelectCategory:g,handleSelectTemplate:x,handleCreateBlankSurvey:A,handleEditTemplate:q,handleCloseEditTemplate:E,handleSaveEditTemplate:j,handleGoBackToDashboard:F,handlePreviousStep:T,handleNextStep:h,handleGoToStep:I}=Xe(m),z=S.useMemo(()=>{if(c==="BLANK")return null;if(c){const R=C.find(W=>W.id===c);return R||null}return C.length>0?C[0]:null},[C,c]),{formData:H,questionCategories:Y,filteredQuestions:O,totalQuestionsCount:$,handleTemplateNameChange:G,handleDescriptionChange:K,handleCategoryFilterChange:f,handleRemoveQuestion:_,resetFormDataWithTemplate:d}=et(c,z,m),{formData:B,handleTitleChange:r,handleDeadlineChange:N}=tt(m),{students:v,allFilteredStudents:D,allStudents:u,totalStudentsCount:L,totalSelectedCount:Q,selectedStudentIds:U,filters:V,gradeOptions:oe,flagOptions:J,teacherOptions:me,isAllSelected:pe,isIndeterminate:Z,handleSortChange:we,handleSearchChange:Be,handleGradeFilterChange:Fe,handleFlagFilterChange:Ie,handleTeacherFilterChange:Ae,handlePageChange:Le,handleRowsPerPageChange:Re,handleToggleSelectAll:ke,handleToggleStudent:Ee}=nt(m),re=R=>{const W={activeStep:l,selectedCategory:p,selectedTemplateId:c,step2FormData:H,step3FormData:B,selectedStudentIds:U,editingTemplate:y,...R};localStorage.setItem("create_survey_draft",JSON.stringify(W))},qe=()=>{re(),i("/admin/create-survey-question?type=0&from=create-survey")},De=R=>{re(),i(`/admin/survey-question-detail/${R}?type=0&from=create-survey`)},Pe=S.useMemo(()=>(u&&u.length>0?u:D||v).filter(W=>U.includes(W.id)),[u,D,v,U]),He=async()=>{const R=new Map;(u&&u.length>0?u:D||v||[]).forEach(k=>R.set(k.id,k));const X=[],ee=[],ie=[];U.forEach(k=>{const P=R.get(k);if(P)P.schoolLevel==="ES"&&P.userId?(ee.push(P.userId),ie.push({userId:P.userId,name:P.name,firstName:P.name?.split(" ")?.[0]||"",email:P.email,studentId:P.studentId})):P.studentId!==void 0?X.push(P.studentId):typeof k=="number"?X.push(k):P.userId&&(ee.push(P.userId),ie.push({userId:P.userId,name:P.name,firstName:P.name?.split(" ")?.[0]||"",email:P.email,studentId:P.studentId}));else if(typeof k=="number"||!isNaN(Number(k))&&!String(k).includes("-"))X.push(Number(k));else{const te=String(k);ee.push(te),ie.push({userId:te,name:`Student ${te}`,firstName:"Student",email:""})}});const Qe=[{id:c,name:H.templateName,title:H.templateName,description:H.description,numberQuestion:H.questions.length,orderDefaultSurvey:1,questionTemplates:H.questions.map((k,P)=>({questionId:typeof k.id=="string"&&k.id.startsWith("q-")?0:Number(k.id),questionText:k.questionText,type:k.type||"MultipleChoice",orderDefaultQuestionTemplate:k.orderNumber??P,answers:k.options&&Array.isArray(k.options)?k.options.map((te,Ye)=>({id:0,text:te,order:Ye})):k.answers||[]}))}],Oe=B.deadline?xe(B.deadline,"DD.MM.YYYY hh:mm A").valueOf():null,Ge={title:B.title,deadline:Oe,studentIds:X,esStudentUserIds:ee,studentUserIds:ee,esStudents:ie,additionalQuestions:[],staffIds:[],summarizeQuestions:[],isAdmin:!0,isDraft:!1,role:Array.isArray(n)?n.join(","):n?String(n):"Admin",templateQuestions:Qe};try{a(M.setLoading(!0)),await ye.createSurvey(Ge),a(M.setAlert({type:"success",message:"Publish survey success"})),F()}catch(k){console.error("Error publishing survey:",k),a(M.setAlert({type:"danger",message:k?.response?.data?.title||k?.message||"Failed to publish survey"}))}finally{a(M.setLoading(!1))}};S.useEffect(()=>{window.scrollTo({top:0,behavior:"instant"});const R=document.querySelector("main");R&&R.scrollTo({top:0,behavior:"instant"});const W=document.documentElement||document.body;W&&(W.scrollTop=0)},[l,y]);const ze=R=>{re({editingTemplateFormData:R}),i("/admin/create-survey-question?type=0&from=edit-template")},We=(R,W)=>{re({editingTemplateFormData:W}),i(`/admin/survey-question-detail/${R}?type=0&from=edit-template`)},Me=async R=>{await j(R),(c===R.id||!c)&&d(R)};return y?e.jsx(t.Box,{className:s.createSurveyPage,children:e.jsx(t.Box,{className:s.contentBody,children:e.jsx(Da,{template:y,initialDraftData:m?.editingTemplateFormData,onSave:Me,onCancel:E,onAddQuestionRedirect:ze,onEditQuestionRedirect:We})})}):e.jsxs(t.Box,{className:s.createSurveyPage,children:[e.jsx(t.Box,{className:s.headerTopBar,children:e.jsx(xa,{steps:o,activeStep:l,onBack:F})}),e.jsxs(t.Box,{className:s.contentBody,children:[l===0&&e.jsx(Ta,{categories:b,selectedCategory:p,templates:C,selectedTemplateId:c,currentStepNumber:l+1,totalSteps:o.length,onSelectCategory:g,onSelectTemplate:x,onCreateBlank:A,onEditTemplate:q,onPrevious:T,onNext:h}),l===1&&e.jsx(Sa,{formData:H,questionCategories:Y,filteredQuestions:O,totalQuestionsCount:$,currentStepNumber:l+1,totalSteps:o.length,onTemplateNameChange:G,onDescriptionChange:K,onCategoryFilterChange:f,onEditQuestion:De,onRemoveQuestion:_,onAddQuestion:qe,onPrevious:T,onNext:h}),l===2&&e.jsx(ja,{formData:B,currentStepNumber:l+1,totalSteps:o.length,onTitleChange:r,onDeadlineChange:N,onPrevious:T,onNext:h}),l===3&&e.jsx(Ba,{students:v,totalStudentsCount:L,totalSelectedCount:Q,selectedStudentIds:U,filters:V,gradeOptions:oe,flagOptions:J,teacherOptions:me,page:V.page,rowsPerPage:V.rowsPerPage,isAllSelected:pe,isIndeterminate:Z,sortBy:V.sortBy,sortOrder:V.sortOrder,onSortChange:we,currentStepNumber:l+1,totalSteps:o.length,onSearchChange:Be,onGradeChange:Fe,onFlagChange:Ie,onTeacherChange:Ae,onPageChange:Le,onRowsPerPageChange:Re,onToggleSelectAll:ke,onToggleStudent:Ee,onPrevious:T,onNext:h}),l===4&&e.jsx(ka,{templateFormData:H,surveyFormData:B,selectedStudents:Pe,currentStepNumber:l+1,totalSteps:o.length,onEditTemplateDetails:()=>I(1),onEditSurveyDetails:()=>I(2),onEditSelectedStudents:()=>I(3),onPrevious:T,onPublish:He})]})]})};exports.default=Pa;