mario-education 2.0.177-staging → 2.0.178-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"),C=require("react"),t=require("@mui/material"),ie=require("react-redux"),_e=require("react-router-dom"),ge=require("moment"),z=require("mario-core"),pe=require("./surveyService-BKooa1m-.cjs"),Me=require("./questionCategoryService-CjXNe6xV.cjs"),Te=require("./ArrowBack-C4WIF8bZ.cjs"),be=require("./Check-CYAVgIcj.cjs"),Ce=require("./ArrowForward-D4TtLiX5.cjs"),se=require("./createSvgIcon-CRp0VXvr.cjs"),Se=require("./Add-DE-4A91A.cjs"),xe=require("@mui/x-date-pickers"),Qe=require("./AdapterMoment-B-q0UCj0.cjs"),Oe=require("./Search-CZp6DUOA.cjs"),Ge=require("./Close-BqvQ2Wpz.cjs"),oe=[{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"}],Ye=["All","School Climate","Well-being","Health & Wellness"],$e=[{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"}],Ue=a=>{const l=ie.useDispatch(),d=_e.useNavigate(),c=ie.useSelector(n=>n?.common?.language||"en"),[r,o]=C.useState(a?.activeStep??0),[m,g]=C.useState(a?.selectedCategory??"All"),[i,b]=C.useState(a?.selectedTemplateId??null),[y,u]=C.useState($e),[x,R]=C.useState(!1),[k,_]=C.useState(a?.editingTemplate??null),N=C.useCallback(async()=>{try{R(!0),l(z.setLoading(!0));const n=await pe.getTemplateSurvey(c);if(n?.data&&Array.isArray(n.data)&&n.data.length>0){const v=n.data.map(w=>{let F="Well-being";const B=(w.name||"").toLowerCase();return B.includes("climate")||B.includes("grow")?F="School Climate":B.includes("health")&&(F="Health & Wellness"),{id:w.id,title:w.name,description:w.description,questionCount:w.numberQuestion??w.questionTemplates?.length??0,category:F,rawTemplate:w}});u(v),a?.selectedTemplateId||b(w=>w||(v.length>0?v[0].id:null))}}catch(n){console.error("Error fetching survey templates:",n),l(z.setAlert({type:"danger",message:n?.message||"Failed to fetch survey templates"}))}finally{R(!1),l(z.setLoading(!1))}},[c,l]);C.useEffect(()=>{N()},[N]);const S=C.useMemo(()=>{const n=new Set;return y.forEach(v=>{v.category&&n.add(v.category)}),n.size===0?Ye:["All",...Array.from(n)]},[y]),p=C.useMemo(()=>m==="All"?y:y.filter(n=>n.category.toLowerCase()===m.toLowerCase()),[y,m]),D=C.useMemo(()=>y.find(n=>n.id===i)||null,[y,i]),I=n=>{g(n)},O=n=>{b(n)},H=()=>{b("BLANK"),o(n=>Math.min(n+1,oe.length-1))},G=(n,v)=>{v.stopPropagation(),_(n)},M=()=>{_(null)},Y=async n=>{try{l(z.setLoading(!0));const v=n.rawTemplate?.questionTemplates?.map(B=>B.questionId||B.id)?.filter(B=>typeof B=="number"||!String(B).startsWith("q-"))?.map(B=>Number(B))||[],w={id:n.id,name:n.title,description:n.description,isFavorite:n.rawTemplate?.isFavorite??!1,questionIds:v};await Me.updateSurvey(w),u(B=>B.map(W=>W.id===n.id?n:W)),_(null);const F=localStorage.getItem("create_survey_draft");if(F)try{const B=JSON.parse(F);B.editingTemplateFormData&&(delete B.editingTemplateFormData,localStorage.setItem("create_survey_draft",JSON.stringify(B)))}catch{}l(z.setAlert({type:"success",message:"Update template successfully"}))}catch(v){l(z.setAlert({type:"danger",message:v.response?.data?.title||"Update template failed"}))}finally{l(z.setLoading(!1))}},Q=()=>{d("/admin/survey-dashboard/list-survey")};return{steps:oe,activeStep:r,categories:S,selectedCategory:m,selectedTemplateId:i,selectedTemplate:D,templates:p,rawTemplates:y,isLoading:x,editingTemplate:k,handleSelectCategory:I,handleSelectTemplate:O,handleCreateBlankSurvey:H,handleEditTemplate:G,handleCloseEditTemplate:M,handleSaveEditTemplate:Y,handleGoBackToDashboard:Q,handlePreviousStep:()=>{r>0?o(n=>n-1):Q()},handleNextStep:()=>{r<oe.length-1&&o(n=>n+1)},handleGoToStep:n=>{n>=0&&n<oe.length&&o(n)},refetchTemplates:N}},me=(a,l)=>!a||!Array.isArray(a)||a.length===0?[]:a.map((d,c)=>({id:d.questionId??d.id??`q-${c+1}`,orderNumber:d.orderDefaultQuestionTemplate??c+1,questionText:d.questionText??d.text??`Question ${c+1}`,type:String(d.type||"Text"),category:d.category??d.categoryName??d.categoryTitle??d.title??l??"General",options:d.answers?.map(r=>r.text)||[]})),fe=[{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"}],Ve=(a,l,d)=>{const c=C.useMemo(()=>{const _=l?.rawTemplate?.questionTemplates,N=me(_,l?.category||"Well-being");return N.length>0?N:fe},[l]),[r,o]=C.useState(()=>d?.step2FormData?d.step2FormData:a==="BLANK"?{templateName:"",description:"",showLandingPageFlag:!1,questions:[],selectedCategoryFilter:"All"}:{templateName:l?.title||"Well-being",description:l?.description||"General assessment of student wellness and quality of life",showLandingPageFlag:!1,questions:c,selectedCategoryFilter:"All"}),m=C.useRef(d?.selectedTemplateId??(a==="BLANK"?"BLANK":l?l.id:null));C.useEffect(()=>{if(l){if(m.current===l.id)return;m.current=l.id;const _=l.rawTemplate?.questionTemplates,N=me(_,l.category||"Well-being");o(S=>({...S,templateName:l.title||"",description:l.description||"",questions:N.length>0?N:S.questions.length>0?S.questions:fe,selectedCategoryFilter:"All"}))}else if(a==="BLANK"){if(m.current==="BLANK")return;m.current="BLANK",o(_=>({..._,templateName:"",description:"",questions:[],selectedCategoryFilter:"All"}))}},[l,a]);const g=C.useMemo(()=>{const _=new Set;r.questions.forEach(S=>{const p=S.category?.trim();p&&_.add(p)});const N=Array.from(_);return N.length>0?["All",...N]:["All"]},[r.questions]),i=C.useMemo(()=>r.selectedCategoryFilter==="All"?r.questions:r.questions.filter(_=>_.category===r.selectedCategoryFilter),[r.questions,r.selectedCategoryFilter]),b=_=>{o(N=>({...N,templateName:_}))},y=_=>{o(N=>({...N,description:_}))},u=_=>{o(N=>({...N,selectedCategoryFilter:_}))},x=_=>{console.log("Edit question:",_)},R=_=>{o(N=>({...N,questions:N.questions.filter(S=>S.id!==_).map((S,p)=>({...S,orderNumber:p+1}))}))},k=()=>{const _=`q-${Date.now()}`,N=r.questions.length+1,S={id:_,orderNumber:N,questionText:"New Question",type:"Rating",category:"General"};o(p=>({...p,questions:[...p.questions,S]}))};return{formData:r,questionCategories:g,filteredQuestions:i,totalQuestionsCount:r.questions.length,handleTemplateNameChange:b,handleDescriptionChange:y,handleCategoryFilterChange:u,handleEditQuestion:x,handleRemoveQuestion:R,handleAddQuestion:k}},Ke=(a,{initialTitle:l="",initialDeadline:d=ge().add(1,"days").format("DD.MM.YYYY hh:mm A")}={})=>{const[c,r]=C.useState(()=>a?.step3FormData?a.step3FormData:{title:l||"",deadline:d||""});return{formData:c,handleTitleChange:g=>{r(i=>({...i,title:g}))},handleDeadlineChange:g=>{r(i=>({...i,deadline:g}))}}},Je=z.getStaticFileUrl("/images/image-default.png"),Ze=[{label:"All Flags",value:"all"},{label:"Red Flag",value:"red"},{label:"Yellow Flag",value:"yellow"},{label:"Green Flag",value:"green"}],Xe=a=>{const[l,d]=C.useState([]),[c,r]=C.useState(a?.selectedStudentIds??[]),[o,m]=C.useState([]),[g,i]=C.useState(Ze),[b,y]=C.useState([]),[u,x]=C.useState({searchQuery:"",selectedGrade:"All Grades",selectedFlag:"all",selectedTeacher:"All Teachers",page:0,rowsPerPage:10,sortBy:"name",sortOrder:"asc"}),R=C.useCallback(async()=>{try{const f=await pe.searchStudents({roles:["Admin"]});if(f?.data?.items&&Array.isArray(f.data.items)&&f.data.items.length>0){var T=f.data.items.filter(h=>!!h.flag);console.table(T);const n=f.data.items.map(h=>{let L="none";if(typeof h.flag=="string"){const K=h.flag.toLowerCase();(K.includes("red")||K.includes("yellow")||K.includes("green"))&&(L=K)}else h.redFlags>0||h.flag===1?L="red":h.yellowFlags>0||h.flag===2?L="yellow":(h.greenFlags>0||h.flag===3)&&(L="green");const V=h.fullName||h.studentName,ce=h.gradeLevel,de=h.email,ne=h.userId||(typeof h.id=="string"?h.id:""),Z=typeof h.studentId=="number"?h.studentId:typeof h.id=="number"?h.id:void 0,ue=ne||(Z!==void 0?String(Z):`student-${Math.random()}`),he=(h.schoolLevel||(h.userId&&h.id===void 0?"ES":"MS")).toUpperCase();return{id:ue,userId:ne,studentId:Z,schoolLevel:he,name:V,avatarUrl:h.profileImageFileName?z.getFileUrl(h.profileImageFileName):Je,flag:L,flagTooltip:h.flagTooltip||void 0,flagDetail:h.flagDetail,lastSafetyAnswer:h.lastSafetyAnswer,lastStressAnswer:h.lastStressAnswer,flagSessionId:h.flagSessionId,flagSessionResultId:h.flagSessionResultId,grade:ce,email:de,listTeachers:h.listTeachers||[]}});d(n);const v=Array.from(new Set(n.map(h=>h.grade))).filter(h=>h&&h!=="N/A"),w=h=>{if(!h||h==="N/A")return-999;const L=h.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 V=L.match(/^(\d+)/);return V?parseInt(V[1],10):999};v.sort((h,L)=>w(h)-w(L)),m(["All Grades",...v]);const F=Array.from(new Set(n.map(h=>h.flag))),B=[{label:"All Flags",value:"all"}];F.includes("red")&&B.push({label:"Red Flag",value:"red"}),F.includes("yellow")&&B.push({label:"Yellow Flag",value:"yellow"}),F.includes("green")&&B.push({label:"Green Flag",value:"green"}),i(B);const W=new Set;n.forEach(h=>{h.listTeachers&&h.listTeachers.length>0&&h.listTeachers.forEach(L=>{L.name&&W.add(L.name.trim())})});const U=Array.from(W).sort((h,L)=>h.localeCompare(L));y(["All Teachers",...U])}}catch(f){console.error("Error fetching students list:",f)}},[]);C.useEffect(()=>{R()},[R]);const k=T=>{x(f=>({...f,searchQuery:T,page:0}))},_=T=>{x(f=>({...f,selectedGrade:T,page:0}))},N=T=>{x(f=>({...f,selectedFlag:T,page:0}))},S=T=>{x(f=>({...f,selectedTeacher:T,page:0}))},p=(T,f)=>{x(n=>({...n,page:f}))},D=T=>{x(f=>({...f,rowsPerPage:parseInt(T.target.value,10),page:0}))},I=C.useMemo(()=>l.filter(T=>{if(u.searchQuery.trim()){const f=F=>(F||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),n=f(u.searchQuery.trim()),v=f(T.name).includes(n),w=f(T.email).includes(n);if(!v&&!w)return!1}return!(u.selectedGrade!=="All Grades"&&(T.grade||"").toLowerCase()!==(u.selectedGrade||"").toLowerCase()||u.selectedFlag!=="all"&&T.flag!==u.selectedFlag||u.selectedTeacher!=="All Teachers"&&(!T.listTeachers||T.listTeachers.length===0||!T.listTeachers.some(n=>n.name&&n.name.trim()===u.selectedTeacher)))}),[l,u]),O=T=>{x(f=>({...f,sortBy:T,sortOrder:f.sortBy===T&&f.sortOrder==="asc"?"desc":"asc"}))},H=C.useMemo(()=>[...I].sort((f,n)=>{let v=f[u.sortBy],w=n[u.sortBy];if(u.sortBy==="flag"){const F={red:3,yellow:2,green:1,none:0};v=F[f.flag]||0,w=F[n.flag]||0}else if(u.sortBy==="grade"){const F=B=>{if(!B||B==="N/A")return-999;const W=B.toString().toUpperCase().replace(/TH|RD|ND|ST/g,"").trim();if(W==="PK")return-2;if(W==="K")return-1;if(W==="G")return 0;const U=W.match(/^(\d+)/);return U?parseInt(U[1],10):999};v=F(f.grade),w=F(n.grade)}else u.sortBy==="teacher"?(v=f.listTeachers&&f.listTeachers.length>0?f.listTeachers.map(F=>F.name).join(", ").toLowerCase():"",w=n.listTeachers&&n.listTeachers.length>0?n.listTeachers.map(F=>F.name).join(", ").toLowerCase():""):typeof v=="string"&&typeof w=="string"&&(v=v.toLowerCase(),w=w.toLowerCase());return v<w?u.sortOrder==="asc"?-1:1:v>w?u.sortOrder==="asc"?1:-1:0}),[I,u.sortBy,u.sortOrder]),G=C.useMemo(()=>{const T=u.page*u.rowsPerPage;return H.slice(T,T+u.rowsPerPage)},[H,u.page,u.rowsPerPage]),M=C.useMemo(()=>I.length===0?!1:I.every(T=>c.includes(T.id)),[I,c]),Y=C.useMemo(()=>{if(I.length===0)return!1;const T=I.filter(f=>c.includes(f.id));return T.length>0&&T.length<I.length},[I,c]),Q=()=>{if(M){const T=I.map(f=>f.id);r(f=>f.filter(n=>!T.includes(n)))}else{const T=new Set([...c,...I.map(f=>f.id)]);r(Array.from(T))}},$=T=>{r(f=>f.includes(T)?f.filter(n=>n!==T):[...f,T])};return{students:G,allFilteredStudents:I,totalStudentsCount:I.length,totalSelectedCount:c.length,selectedStudentIds:c,filters:u,gradeOptions:o,flagOptions:g,teacherOptions:b,isAllSelected:M,isIndeterminate:Y,handleSortChange:O,handleSearchChange:k,handleGradeFilterChange:_,handleFlagFilterChange:N,handleTeacherFilterChange:S,handlePageChange:p,handleRowsPerPageChange:D,handleToggleSelectAll:Q,handleToggleStudent:$}},et="_createSurveyPage_254g3_1",tt="_headerTopBar_254g3_16",st="_contentBody_254g3_28",at="_stepperContainer_254g3_39",nt="_backButton_254g3_44",lt="_stepperProgress_254g3_58",rt="_stepColumn_254g3_66",ot="_stepColumnLast_254g3_72",it="_stepCircleRow_254g3_77",ct="_stepCircle_254g3_77",dt="_active_254g3_96",ut="_completed_254g3_100",ht="_stepConnectorLine_254g3_105",mt="_stepLabelStack_254g3_115",gt="_stepInnerDot_254g3_119",pt="_stepNumberLabel_254g3_133",xt="_stepTextLabel_254g3_145",ft="_chooseTemplateCard_254g3_157",yt="_headerSection_254g3_173",_t="_headerTitle_254g3_177",Tt="_headerSubtitle_254g3_192",bt="_bannerContainer_254g3_199",Ct="_bannerIconBox_254g3_219",St="_bannerTitle_254g3_228",jt="_bannerSubtitle_254g3_235",Nt="_bannerActionBtn_254g3_240",vt="_sectionTitle_254g3_258",wt="_filterPillsContainer_254g3_266",Bt="_filterPill_254g3_266",Ft="_templateCard_254g3_301",It="_selected_254g3_319",At="_templateCardTitle_254g3_324",Rt="_templateEditBtn_254g3_332",Lt="_templateDescription_254g3_346",kt="_chipItem_254g3_353",Et="_wizardFooter_254g3_367",qt="_previousBtn_254g3_387",Dt="_disabled_254g3_409",Pt="_stepCounterText_254g3_427",Ht="_nextBtn_254g3_433",zt="_editTemplateHeaderSection_254g3_453",Wt="_editTemplateCancelBtn_254g3_460",Mt="_editTemplateSaveBtn_254g3_472",Qt="_templateCategorySelect_254g3_495",Ot="_formFieldBlock_254g3_514",Gt="_formFieldLabel_254g3_520",Yt="_requiredAsterisk_254g3_528",$t="_customTextField_254g3_532",Ut="_formFieldHelperText_254g3_549",Vt="_questionsHeaderSection_254g3_577",Kt="_questionsTitle_254g3_585",Jt="_questionsCountNumber_254g3_591",Zt="_filterByRow_254g3_597",Xt="_filterByLabel_254g3_605",es="_categoryFilterFormControl_254g3_611",ts="_categorySelectInput_254g3_615",ss="_tableContainerWrapper_254g3_633",as="_questionsTable_254g3_641",ns="_tableHeaderRow_254g3_646",ls="_tableBodyRow_254g3_659",rs="_thNumber_254g3_673",os="_tdNumber_254g3_674",is="_thQuestion_254g3_683",cs="_tdQuestion_254g3_684",ds="_questionText_254g3_690",us="_thType_254g3_709",hs="_tdType_254g3_710",ms="_thCategory_254g3_716",gs="_tdCategory_254g3_717",ps="_categoryText_254g3_723",xs="_thActions_254g3_730",fs="_tdActions_254g3_731",ys="_questionTypeBadge_254g3_737",_s="_badgeTextLabel_254g3_747",Ts="_badgeRating_254g3_753",bs="_badgeYesNo_254g3_760",Cs="_badgeText_254g3_747",Ss="_tableEditBtn_254g3_781",js="_tableRemoveBtn_254g3_796",Ns="_addQuestionWrapper_254g3_811",vs="_addQuestionBtn_254g3_819",ws="_selectedCountSection_254g3_838",Bs="_selectedCountText_254g3_843",Fs="_selectedCountHighlight_254g3_849",Is="_studentsToolbar_254g3_855",As="_searchBarContainer_254g3_863",Rs="_studentSearchInput_254g3_868",Ls="_filterDropdownWrapper_254g3_894",ks="_filterSelectBox_254g3_898",Es="_studentsTableContainer_254g3_924",qs="_studentsTable_254g3_924",Ds="_studentsTableHeaderRow_254g3_938",Ps="_checkboxHeaderCell_254g3_949",Hs="_tableHeaderCell_254g3_957",zs="_checkboxBodyCell_254g3_973",Ws="_studentTableRow_254g3_981",Ms="_selectedRow_254g3_988",Qs="_studentNameCell_254g3_995",Os="_studentNameText_254g3_1000",Gs="_flagCell_254g3_1006",Ys="_gradeCell_254g3_1011",$s="_gradeText_254g3_1016",Us="_emailCell_254g3_1021",Vs="_emailText_254g3_1026",Ks="_studentsPagination_254g3_1031",Js="_reviewSectionBlock_254g3_1049",Zs="_reviewSectionHeader_254g3_1058",Xs="_reviewSectionTitle_254g3_1065",ea="_reviewEditSectionBtn_254g3_1071",ta="_reviewFieldGroup_254g3_1082",sa="_reviewFieldLabel_254g3_1086",aa="_reviewFieldValue_254g3_1094",na="_reviewQuestionsTableContainer_254g3_1100",la="_previewSurveyBtn_254g3_1106",ra="_publishBtn_254g3_1122",s={createSurveyPage:et,headerTopBar:tt,contentBody:st,stepperContainer:at,backButton:nt,stepperProgress:lt,stepColumn:rt,stepColumnLast:ot,stepCircleRow:it,stepCircle:ct,active:dt,completed:ut,stepConnectorLine:ht,stepLabelStack:mt,stepInnerDot:gt,stepNumberLabel:pt,stepTextLabel:xt,chooseTemplateCard:ft,headerSection:yt,headerTitle:_t,headerSubtitle:Tt,bannerContainer:bt,bannerIconBox:Ct,bannerTitle:St,bannerSubtitle:jt,bannerActionBtn:Nt,sectionTitle:vt,filterPillsContainer:wt,filterPill:Bt,templateCard:Ft,selected:It,templateCardTitle:At,templateEditBtn:Rt,templateDescription:Lt,chipItem:kt,wizardFooter:Et,previousBtn:qt,disabled:Dt,stepCounterText:Pt,nextBtn:Ht,editTemplateHeaderSection:zt,editTemplateCancelBtn:Wt,editTemplateSaveBtn:Mt,templateCategorySelect:Qt,formFieldBlock:Ot,formFieldLabel:Gt,requiredAsterisk:Yt,customTextField:$t,formFieldHelperText:Ut,questionsHeaderSection:Vt,questionsTitle:Kt,questionsCountNumber:Jt,filterByRow:Zt,filterByLabel:Xt,categoryFilterFormControl:es,categorySelectInput:ts,tableContainerWrapper:ss,questionsTable:as,tableHeaderRow:ns,tableBodyRow:ls,thNumber:rs,tdNumber:os,thQuestion:is,tdQuestion:cs,questionText:ds,thType:us,tdType:hs,thCategory:ms,tdCategory:gs,categoryText:ps,thActions:xs,tdActions:fs,questionTypeBadge:ys,badgeTextLabel:_s,badgeRating:Ts,badgeYesNo:bs,badgeText:Cs,tableEditBtn:Ss,tableRemoveBtn:js,addQuestionWrapper:Ns,addQuestionBtn:vs,selectedCountSection:ws,selectedCountText:Bs,selectedCountHighlight:Fs,studentsToolbar:Is,searchBarContainer:As,studentSearchInput:Rs,filterDropdownWrapper:Ls,filterSelectBox:ks,studentsTableContainer:Es,studentsTable:qs,studentsTableHeaderRow:Ds,checkboxHeaderCell:Ps,tableHeaderCell:Hs,checkboxBodyCell:zs,studentTableRow:Ws,selectedRow:Ms,studentNameCell:Qs,studentNameText:Os,flagCell:Gs,gradeCell:Ys,gradeText:$s,emailCell:Us,emailText:Vs,studentsPagination:Ks,reviewSectionBlock:Js,reviewSectionHeader:Zs,reviewSectionTitle:Xs,reviewEditSectionBtn:ea,reviewFieldGroup:ta,reviewFieldLabel:sa,reviewFieldValue:aa,reviewQuestionsTableContainer:na,previewSurveyBtn:la,publishBtn:ra},oa=({steps:a,activeStep:l,onBack:d})=>e.jsxs(t.Box,{className:s.stepperContainer,children:[e.jsx(t.Button,{onClick:d,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((c,r)=>{const o=r===l,m=r<l,g=r===a.length-1;return e.jsxs(t.Box,{className:`${s.stepColumn} ${g?s.stepColumnLast:""}`,children:[e.jsxs(t.Box,{className:s.stepCircleRow,children:[e.jsxs(t.Box,{className:`${s.stepCircle} ${o?s.active:m?s.completed:""}`,children:[o&&e.jsx(t.Box,{className:s.stepInnerDot}),m&&e.jsx(be.CheckIcon,{sx:{fontSize:16,color:"#ffffff"}})]}),!g&&e.jsx(t.Box,{className:`${s.stepConnectorLine} ${m?s.completed:""}`})]}),e.jsxs(t.Stack,{alignItems:"flex-start",spacing:.25,className:s.stepLabelStack,children:[e.jsxs(t.Typography,{variant:"caption",className:`${s.stepNumberLabel} ${o?s.active:""}`,children:["STEP ",c.stepNumber]}),e.jsx(t.Typography,{variant:"body2",className:`${s.stepTextLabel} ${o?s.active:""}`,children:c.label})]})]},c.stepCode)})})]}),ia=({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(Ce.ArrowForwardIcon,{sx:{fontSize:16}}),className:s.bannerActionBtn,children:"CREATE BLANK SURVEY"})]}),ca=({categories:a,selectedCategory:l,onSelectCategory:d})=>e.jsx(t.Box,{className:s.filterPillsContainer,children:e.jsx(t.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:a.map(c=>{const r=l.toLowerCase()===c.toLowerCase();return e.jsx(t.Chip,{label:c,onClick:()=>d(c),className:`${s.filterPill} ${r?s.active:""}`},c)})})}),ee=se.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"),da=({template:a,isSelected:l,onSelect:d,onEdit:c})=>e.jsxs(t.Box,{onClick:()=>d(a.id),className:`${s.templateCard} ${l?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:r=>c(a,r),startIcon:e.jsx(ee,{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",flexWrap:"wrap",sx:{gap:.75},children:[e.jsx(t.Chip,{label:`${a.questionCount} questions`,size:"small",className:s.chipItem}),e.jsx(t.Chip,{label:a.category,size:"small",className:s.chipItem})]})]}),ua=se.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"),ae=({currentStep:a,totalSteps:l,onPrevious:d,onNext:c,isNextDisabled:r=!1,isLastStep:o=!1,nextLabel:m="NEXT",onPreview:g})=>e.jsxs(t.Box,{className:s.wizardFooter,children:[e.jsx(t.Button,{variant:"outlined",onClick:d,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 ",l]}),o?e.jsxs(t.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:[g&&e.jsx(t.Button,{variant:"outlined",onClick:g,startIcon:e.jsx(ua,{sx:{fontSize:18}}),className:s.previewSurveyBtn,children:"SURVEY PREVIEW"}),e.jsx(t.Button,{variant:"contained",onClick:c,disabled:r,className:s.publishBtn,children:m||"PUBLISH"})]}):e.jsx(t.Button,{variant:"contained",onClick:c,disabled:r,endIcon:e.jsx(Ce.ArrowForwardIcon,{sx:{fontSize:16}}),className:s.nextBtn,children:m})]}),ha=({categories:a,selectedCategory:l,templates:d,selectedTemplateId:c,currentStepNumber:r,totalSteps:o,onSelectCategory:m,onSelectTemplate:g,onCreateBlank:i,onEditTemplate:b,onPrevious:y,onNext:u})=>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(ia,{onCreateBlank:i}),e.jsxs(t.Stack,{spacing:1,children:[e.jsx(t.Typography,{variant:"h6",className:s.sectionTitle,children:"Survey Templates"}),e.jsx(ca,{categories:a,selectedCategory:l,onSelectCategory:m})]}),e.jsx(t.Grid,{container:!0,spacing:2.5,sx:{mt:1},children:d.map(x=>e.jsx(t.Grid,{item:!0,xs:12,sm:6,md:4,children:e.jsx(da,{template:x,isSelected:c===x.id,onSelect:g,onEdit:b})},x.id))}),e.jsx(ae,{currentStep:r,totalSteps:o,onPrevious:y,onNext:u})]}),ma=se.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"),je=({type:a})=>{const l=r=>{if(typeof r=="number"||!isNaN(Number(r))){const o=Number(r);if(o===0)return"Text";if(o===1)return"MultipleChoice";if(o===2||o===3)return"Slider";if(o===4)return"YesNo";if(o===5)return"SingleChoice";if(o===6)return"Date"}return String(r)},d=r=>{switch(l(r)){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}},c=r=>{const o=l(r);switch(o){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 o}};return e.jsx(t.Box,{className:`${s.questionTypeBadge} ${d(a)}`,children:e.jsx(t.Typography,{variant:"caption",className:s.badgeTextLabel,children:c(a)})})},Ne=({questions:a,onEditQuestion:l,onRemoveQuestion:d})=>{const[c,r]=C.useState(null),[o,m]=C.useState(!1),g=y=>{r(y),m(!0)},i=()=>{c!==null&&d(c),m(!1),r(null)},b=()=>{m(!1),r(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,u)=>e.jsxs(t.TableRow,{className:s.tableBodyRow,children:[e.jsxs(t.TableCell,{className:s.tdNumber,children:[u+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(je,{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:()=>l(y.id),startIcon:e.jsx(ee,{fontSize:"small"}),className:s.tableEditBtn,children:"Edit"}),e.jsx(t.Button,{onClick:()=>g(y.id),startIcon:e.jsx(ma,{fontSize:"small"}),className:s.tableRemoveBtn,children:"Remove"})]})})]},y.id))})]}),e.jsxs(t.Dialog,{open:o,onClose:b,"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:b,color:"inherit",children:"Cancel"}),e.jsx(t.Button,{onClick:i,color:"error",autoFocus:!0,children:"Remove"})]})]})]})},ga=({formData:a,questionCategories:l,filteredQuestions:d,totalQuestionsCount:c,currentStepNumber:r,totalSteps:o,onTemplateNameChange:m,onDescriptionChange:g,onCategoryFilterChange:i,onEditQuestion:b,onRemoveQuestion:y,onAddQuestion:u,onPrevious:x,onNext:R})=>{const k=_=>{i(_.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:_=>m(_.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:_=>g(_.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:a.selectedCategoryFilter,onChange:k,className:s.categorySelectInput,children:l.map(_=>e.jsx(t.MenuItem,{value:_,children:_},_))})})]})]}),e.jsx(Ne,{questions:d,onEditQuestion:b,onRemoveQuestion:y}),e.jsx(t.Box,{className:s.addQuestionWrapper,children:e.jsx(t.Button,{onClick:u,startIcon:e.jsx(Se.AddIcon,{}),className:s.addQuestionBtn,children:"ADD QUESTION"})}),e.jsx(ae,{currentStep:r,totalSteps:o,onPrevious:x,onNext:R,isNextDisabled:!a.templateName||a.templateName.trim()===""})]})},pa=({formData:a,currentStepNumber:l,totalSteps:d,onTitleChange:c,onDeadlineChange:r,onPrevious:o,onNext:m})=>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:g=>c(g.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(xe.LocalizationProvider,{dateAdapter:Qe.AdapterMoment,children:e.jsx(xe.DateTimePicker,{value:a.deadline?ge(a.deadline,"DD.MM.YYYY hh:mm A"):null,onChange:g=>{r(g?g.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(ae,{currentStep:l,totalSteps:d,onPrevious:o,onNext:m,isNextDisabled:!a.title||a.title.trim()===""||!a.deadline})]}),te=({size:a=32,color:l="#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:l})}),j={"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"},ye=a=>{switch(a){case"Red Flag":return e.jsxs("div",{className:j["flag-of-session__title-red"],children:[e.jsx(te,{color:"#C44140",size:32}),e.jsx("span",{className:j["flag-of-session__title-red--text"],children:"Red Flag"})]});case"Yellow Flag":return e.jsxs("div",{className:j["flag-of-session__title-yellow"],children:[e.jsx(te,{color:"#F5D500",size:32}),e.jsx("span",{className:j["flag-of-session__title-yellow--text"],children:"Yellow Flag"})]});default:return null}},xa=({flag:a,flagDetail:l,lastSafetyAnswer:d,lastStressAnswer:c,showResult:r,defaultStress:o,defaultSafety:m,defaultDecrease:g,isDetailView:i,hasReadyToLearn:b,inSession:y})=>r?e.jsxs("div",{className:j["flag-of-session"],style:{gap:"6px"},children:[(a==="Green Flag"||a==="Green")&&e.jsxs("div",{className:j["flag-of-session__content-green"],children:["Everything is ",e.jsx("p",{className:j["flag-of-session__content-green--text"],children:"fine"})]}),i&&a&&ye(a||""),l?.stress&&(i?e.jsxs("div",{className:j["flag-of-session__item"],children:[e.jsx("p",{className:j["flag-of-session__item--title"],children:"Stress score:"}),e.jsxs("p",{className:j["flag-of-session__item--content"],children:[l?.stress?.score,"%"]})]}):e.jsxs("div",{className:j["flag-of-session__item"],children:[e.jsxs("span",{style:{fontWeight:600,color:l?.stress?.flag==="Red Flag"?"#C44140":"#F5D500",fontSize:"12px"},children:[l?.stress?.score,"%"]}),"Stress vs Last check-in ",c,"%"]})),l?.safety&&(i?e.jsxs("div",{className:j["flag-of-session__item"],children:[e.jsx("p",{className:j["flag-of-session__item--title"],children:"Safety score:"}),e.jsxs("p",{className:j["flag-of-session__item--content"],children:[l?.safety?.score,"%"]})]}):e.jsxs("div",{className:j["flag-of-session__item"],children:[e.jsxs("span",{style:{fontWeight:600,color:l?.safety?.flag==="Red Flag"?"#C44140":"#F5D500"},children:[l?.safety?.score,"%"]})," Safety vs Last check-in ",d,"%"]})),l?.decrease&&l?.decrease?.length>0&&(i?e.jsxs("div",{children:[e.jsxs("p",{className:j["flag-of-session__item--content"],children:[e.jsx("span",{className:j["flag-of-session__item--title"],children:"Sudden Drop: "}),e.jsxs("span",{className:j["flag-of-session__item--title"],children:[l.decrease.length," "]}),"core well-being metric shows a decrease of ",g,"% comparing their average of the last four check-ins."]}),e.jsx("ul",{className:j["flag-of-session__item-column--content"],children:l.decrease?.map((u,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:[u.questionText,": ",u.answer,"% ",u.averageOtherRatingsText?"":u.averageOtherRatings!==void 0?`vs avr ${u.averageOtherRatings}%`:"vs previous"]})})},x))})]}):y?e.jsxs("div",{className:j["flag-of-session__item-column"],children:[e.jsxs("p",{className:j["flag-of-session__item-column--no-bold"],children:["Sudden Drop: ",l.decrease.length||0," core well-being metric shows a decrease compared to the average of the last four check-ins."]}),e.jsx("ul",{className:j["flag-of-session__item-column--content"],children:l.decrease?.map((u,x)=>{const k=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:[u.questionText,":"]}),e.jsxs("p",{style:{margin:0,color:k,fontSize:"12px"},children:[u.answer,"%"]}),u.averageOtherRatingsText?"":u.averageOtherRatings!==void 0&&e.jsxs("p",{style:{margin:0,fontSize:"12px",marginLeft:"4px"},children:["vs avr ",u.averageOtherRatings,"%"]})]})},x)})})]}):e.jsxs("div",{className:j["flag-of-session__item"],children:["Sudden Drop: Any core well-being metric shows a percentage decrease of ",g||20,"% comparing their average of the last four check-ins."]})),l?.readinessToLearn&&(i?e.jsx("div",{children:e.jsxs("p",{className:j["flag-of-session__item--content"],children:[e.jsx("span",{className:j["flag-of-session__item--title"],children:"Ready to learn: "}),l?.readinessToLearn]})}):e.jsxs("div",{className:j["flag-of-session__item"],children:["Ready to learn: ",l?.readinessToLearn]}))]}):e.jsxs("div",{className:j["flag-of-session"],children:[ye(a||""),m&&e.jsxs("div",{className:j["flag-of-session__item"],children:[e.jsx("p",{className:j["flag-of-session__item--title"],children:"Safety score:"}),e.jsxs("p",{className:j["flag-of-session__item--content"],children:["Under ",m,"%"]})]}),o&&e.jsxs("div",{className:j["flag-of-session__item"],children:[e.jsx("p",{className:j["flag-of-session__item--title"],children:"Stress level:"}),e.jsxs("p",{className:j["flag-of-session__item--content"],children:["Higher than ",o,"%"]})]}),g&&e.jsx("div",{children:e.jsxs("p",{className:j["flag-of-session__item--content"],children:[e.jsx("span",{className:j["flag-of-session__item--title"],children:"Sudden Drop: "}),"Any core well-being metric shows a percentage decrease of ",g,"% comparing their average of the last four check-ins."]})}),b&&e.jsx("div",{children:e.jsxs("p",{className:j["flag-of-session__item--content"],children:[e.jsx("span",{className:j["flag-of-session__item--title"],children:"Ready to learn: "}),"The student reported as not ready to learn in last check-in."]})})]}),fa=se.styled$1(({className:a,...l})=>e.jsx(t.Tooltip,{...l,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"}})),ya=a=>{if(!a)return null;const l=a.toLowerCase();return l==="red"?e.jsx(te,{size:32,color:"#C44140"}):l==="yellow"?e.jsx(te,{size:32,color:"#F5D500"}):l==="green"?e.jsx(te,{size:32,color:"#10B981"}):null},_a=({students:a,totalStudentsCount:l,totalSelectedCount:d,selectedStudentIds:c,filters:r,gradeOptions:o,flagOptions:m,teacherOptions:g,page:i,rowsPerPage:b,isAllSelected:y,isIndeterminate:u,sortBy:x,sortOrder:R,onSortChange:k,currentStepNumber:_,totalSteps:N,onSearchChange:S,onGradeChange:p,onFlagChange:D,onTeacherChange:I,onPageChange:O,onRowsPerPageChange:H,onToggleSelectAll:G,onToggleStudent:M,onPrevious:Y,onNext:Q})=>{const $=n=>{p(n.target.value)},T=n=>{D(n.target.value)},f=n=>{I(n.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:"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:d})]})}),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:r.searchQuery,onChange:n=>S(n.target.value),className:s.studentSearchInput,InputProps:{startAdornment:e.jsx(t.InputAdornment,{position:"start",children:e.jsx(Oe.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:r.selectedGrade,onChange:$,displayEmpty:!0,className:s.filterSelectBox,children:o.map(n=>e.jsx(t.MenuItem,{value:n,children:n},n))})})}),e.jsx(t.Box,{className:s.filterDropdownWrapper,children:e.jsx(t.FormControl,{size:"small",fullWidth:!0,children:e.jsx(t.Select,{value:r.selectedFlag,onChange:T,displayEmpty:!0,className:s.filterSelectBox,children:m.map(n=>e.jsx(t.MenuItem,{value:n.value,children:n.label},n.value))})})}),e.jsx(t.Box,{className:s.filterDropdownWrapper,children:e.jsx(t.FormControl,{size:"small",fullWidth:!0,children:e.jsx(t.Select,{value:r.selectedTeacher,onChange:f,displayEmpty:!0,className:s.filterSelectBox,children:g.map(n=>e.jsx(t.MenuItem,{value:n,children:n},n))})})})]}),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:u,onChange:G,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"?R:"asc",onClick:()=>k("name"),children:"Student Name"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="flag",direction:x==="flag"?R:"asc",onClick:()=>k("flag"),children:"Flag"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="grade",direction:x==="grade"?R:"asc",onClick:()=>k("grade"),children:"Grade"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="email",direction:x==="email"?R:"asc",onClick:()=>k("email"),children:"Email"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:x==="teacher",direction:x==="teacher"?R:"asc",onClick:()=>k("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(n=>{const v=c.includes(n.id);return e.jsxs(t.TableRow,{className:`${s.studentTableRow} ${v?s.selectedRow:""}`,onClick:()=>M(n.id),children:[e.jsx(t.TableCell,{className:s.checkboxBodyCell,onClick:w=>w.stopPropagation(),children:e.jsx(t.Checkbox,{checked:v,onChange:()=>M(n.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:n.avatarUrl,alt:n.name,style:{width:44,height:44,borderRadius:"50%",objectFit:"cover"}}),e.jsx(t.Typography,{variant:"body2",className:s.studentNameText,children:n.name})]})}),e.jsx(t.TableCell,{className:s.flagCell,children:e.jsx(fa,{arrow:!0,placement:"bottom",title:n?.flag&&n.flag!=="none"?e.jsx(xa,{flag:n.flag==="red"?"Red Flag":n.flag==="yellow"?"Yellow Flag":"Green Flag",flagDetail:n.flagDetail,lastSafetyAnswer:n.lastSafetyAnswer,lastStressAnswer:n.lastStressAnswer,showResult:!0}):"",children:e.jsx("span",{children:e.jsx("div",{style:{display:"flex",justifyContent:"center",cursor:"pointer"},children:ya(n.flag)})})})}),e.jsx(t.TableCell,{className:s.gradeCell,children:e.jsx(t.Typography,{variant:"body2",className:s.gradeText,children:n.grade})}),e.jsx(t.TableCell,{className:s.emailCell,children:e.jsx(t.Typography,{variant:"body2",className:s.emailText,children:n.email})}),e.jsx(t.TableCell,{children:e.jsx(t.Typography,{variant:"body2",sx:{color:"#475569"},children:n.listTeachers&&n.listTeachers.length>0?n.listTeachers.map(w=>w.name).filter(Boolean).join(", "):"-"})})]},n.id)})})]}),l>0&&e.jsx(t.TablePagination,{rowsPerPageOptions:[5,10,25,50],component:"div",count:l,rowsPerPage:b,page:i,onPageChange:O,onRowsPerPageChange:H,className:s.studentsPagination})]}),e.jsx(ae,{currentStep:_,totalSteps:N,onPrevious:Y,onNext:Q})]})},Ta=({size:a=32,color:l="#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:l})}),ba=t.styled(({className:a,...l})=>e.jsx(t.Tooltip,{...l,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"}}})),Ca=({flag:a,tooltip:l})=>{if(a==="none")return null;let d="#10B981";a==="red"?d="#D10530":a==="yellow"?d="#F5D500":a==="green"&&(d="#0F9655");const c=l?e.jsx(t.Box,{sx:{lineHeight:1.4},children:l}):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(ba,{title:c,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(Ta,{color:d,size:28})})})},Sa=se.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"),ja=({open:a,title:l,description:d,deadline:c,questions:r,onClose:o})=>{const m=i=>{if(typeof i=="number"||!isNaN(Number(i))){const b=Number(i);if(b===0)return"Text";if(b===1)return"MultipleChoice";if(b===2||b===3)return"Slider";if(b===4)return"YesNo";if(b===5)return"SingleChoice";if(b===6)return"Date"}return String(i)},g=i=>{try{const b=document.createElement("textarea");return b.innerHTML=i,b.value}catch{return i}};return e.jsxs(t.Dialog,{open:a,onClose:o,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:o,size:"small",sx:{color:"#64748b"},children:e.jsx(Ge.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:l||"Student Well Being"}),e.jsx(t.Typography,{variant:"body2",sx:{color:"#64748b",mb:2},children:d||"General assessment of student wellness and quality of life"}),c&&e.jsxs(t.Stack,{direction:"row",spacing:1,alignItems:"center",sx:{color:"#64748b",mb:3},children:[e.jsx(Sa,{sx:{fontSize:16,color:"#2563eb"}}),e.jsxs(t.Typography,{variant:"caption",sx:{fontWeight:600},children:["Due: ",c]})]}),e.jsx(t.Stack,{spacing:3,children:r.map((i,b)=>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:[b+1,"."]}),e.jsx(t.Box,{sx:{"& p":{m:0,display:"inline"},"& span":{display:"inline"}},dangerouslySetInnerHTML:{__html:g(i.questionText||"")}})]}),(m(i.type)==="Rating"||m(i.type)==="StarRating"||m(i.type)==="Slider")&&e.jsx(t.Stack,{direction:"row",spacing:1.5,children:[1,2,3,4,5].map(y=>e.jsx(t.Box,{sx:{width:32,height:32,borderRadius:"50%",backgroundColor:"#eff6ff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"0.875rem",fontWeight:600,color:"#2563eb",cursor:"pointer",transition:"all 0.15s ease","&:hover":{borderColor:"#2563eb",backgroundColor:"#eff6ff"}},children:y},y))}),m(i.type)==="MultipleChoice"&&e.jsx(t.Stack,{spacing:1,children:i.options&&i.options.length>0?i.options.map((y,u)=>e.jsx(t.FormControlLabel,{control:e.jsx(t.Checkbox,{size:"small",sx:{color:"#cbd5e1","&.Mui-checked":{color:"#2563eb"}}}),label:e.jsx(t.Typography,{variant:"body2",sx:{color:"#475569"},children:y})},u)):e.jsx(t.Typography,{variant:"body2",sx:{color:"#94a3b8"},children:"No options provided"})}),(m(i.type)==="YesNo"||m(i.type)==="SingleChoice")&&e.jsx(t.RadioGroup,{row:!0,children:i.options&&i.options.length>0?i.options.map((y,u)=>e.jsx(t.FormControlLabel,{value:y,control:e.jsx(t.Radio,{size:"small",sx:{color:"#cbd5e1","&.Mui-checked":{color:"#2563eb"}}}),label:e.jsx(t.Typography,{variant:"body2",sx:{color:"#475569"},children:y})},u)):e.jsxs(e.Fragment,{children:[e.jsx(t.FormControlLabel,{value:"yes",control:e.jsx(t.Radio,{size:"small",sx:{color:"#cbd5e1","&.Mui-checked":{color:"#2563eb"}}}),label:e.jsx(t.Typography,{variant:"body2",sx:{color:"#475569"},children:"Yes"})}),e.jsx(t.FormControlLabel,{value:"no",control:e.jsx(t.Radio,{size:"small",sx:{color:"#cbd5e1","&.Mui-checked":{color:"#2563eb"}}}),label:e.jsx(t.Typography,{variant:"body2",sx:{color:"#475569"},children:"No"})})]})}),(m(i.type)==="Text"||m(i.type)==="TextInput"||m(i.type)==="OpenField")&&e.jsx(t.TextField,{fullWidth:!0,multiline:!0,rows:2,placeholder:"Your answer...",size:"small",sx:{"& .MuiOutlinedInput-root":{borderRadius:"8px",backgroundColor:"#ffffff"}}})]},i.id))})]})]})},Na=({templateFormData:a,surveyFormData:l,selectedStudents:d,currentStepNumber:c,totalSteps:r,onEditTemplateDetails:o,onEditSurveyDetails:m,onEditSelectedStudents:g,onPrevious:i,onPublish:b})=>{const[y,u]=C.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:o,startIcon:e.jsx(ee,{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,R)=>e.jsxs(t.TableRow,{className:s.tableBodyRow,children:[e.jsxs(t.TableCell,{className:s.tdNumber,children:[R+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(je,{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:m,startIcon:e.jsx(ee,{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:l.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:l.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:d.length})]}),e.jsx(t.Button,{variant:"text",onClick:g,startIcon:e.jsx(ee,{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:d.length===0?e.jsx(t.TableRow,{children:e.jsx(t.TableCell,{colSpan:4,align:"center",sx:{py:3,color:"#94a3b8"},children:"No students selected."})}):d.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(Ca,{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(ae,{currentStep:c,totalSteps:r,isLastStep:!0,nextLabel:"PUBLISH",onPreview:()=>u(!0),onPrevious:i,onNext:b}),e.jsx(ja,{open:y,title:l.title||a.templateName,description:a.description,deadline:l.deadline,questions:a.questions,onClose:()=>u(!1)})]})},va=[{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"}],wa=({template:a,initialDraftData:l,onSave:d,onCancel:c,onAddQuestionRedirect:r,onEditQuestionRedirect:o})=>{const m=C.useMemo(()=>{const S=a.rawTemplate?.questionTemplates,p=me(S,a.category||"Well-being");return p.length>0?p:va},[a]),[g,i]=C.useState(()=>l||{id:a.id,templateName:a.title,description:a.description||"",showLandingPageFlag:!1,category:a.category||"Well-being",questions:m}),b=C.useMemo(()=>{const S=new Set;g.category?.trim()&&S.add(g.category.trim()),g.questions.forEach(D=>{const I=D.category?.trim();I&&S.add(I)});const p=Array.from(S);return p.length>0?p:["General"]},[g.category,g.questions]),y=S=>{i(p=>({...p,templateName:S}))},u=S=>{i(p=>({...p,description:S}))},x=S=>{i(p=>({...p,category:S}))},R=S=>{o&&o(S,g)},k=S=>{i(p=>({...p,questions:p.questions.filter(D=>D.id!==S).map((D,I)=>({...D,orderNumber:I+1}))}))},_=()=>{r&&r(g)},N=()=>{const S={...a,title:g.templateName,description:g.description,category:g.category,questionCount:g.questions.length,rawTemplate:{...a.rawTemplate,questionTemplates:g.questions.map(p=>({questionId:typeof p.id=="number"||String(p.id).startsWith("q-")?p.id:parseInt(String(p.id)),questionText:p.questionText,type:p.type,category:p.category}))}};d(S)};return{formData:g,categoryOptions:b,totalQuestionsCount:g.questions.length,handleTemplateNameChange:y,handleDescriptionChange:u,handleCategoryChange:x,handleEditQuestion:R,handleRemoveQuestion:k,handleAddQuestion:_,handleSave:N,handleCancel:c}},Ba=({template:a,initialDraftData:l,onSave:d,onCancel:c,onAddQuestionRedirect:r,onEditQuestionRedirect:o})=>{const{formData:m,categoryOptions:g,totalQuestionsCount:i,handleTemplateNameChange:b,handleDescriptionChange:y,handleCategoryChange:u,handleEditQuestion:x,handleRemoveQuestion:R,handleAddQuestion:k,handleSave:_,handleCancel:N}=wa({template:a,initialDraftData:l,onSave:d,onCancel:c,onAddQuestionRedirect:r,onEditQuestionRedirect:o});C.useEffect(()=>{window.scrollTo({top:0,behavior:"instant"});const p=document.querySelector("main");p&&p.scrollTo({top:0,behavior:"instant"});const D=document.documentElement||document.body;D&&(D.scrollTop=0)},[]);const S=p=>{u(p.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:N,className:s.editTemplateCancelBtn,children:"CANCEL"}),e.jsx(t.Button,{variant:"contained",onClick:_,startIcon:e.jsx(be.CheckIcon,{}),className:s.editTemplateSaveBtn,disabled:!m.templateName||m.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:m.templateName,onChange:p=>b(p.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:m.description,onChange:p=>y(p.target.value),placeholder:"Enter description and instructions",className:s.customTextField})]}),e.jsxs(t.Box,{className:s.formFieldBlock,children:[e.jsxs(t.Typography,{variant:"subtitle2",className:s.formFieldLabel,children:["Category ",e.jsx("span",{className:s.requiredAsterisk,children:"*"})]}),e.jsx(t.FormControl,{fullWidth:!0,size:"small",children:e.jsx(t.Select,{value:m.category,onChange:S,className:s.templateCategorySelect,children:g.map(p=>e.jsx(t.MenuItem,{value:p,children:p},p))})})]}),e.jsx(t.Box,{className:s.questionsHeaderSection,children:e.jsxs(t.Stack,{direction:"row",alignItems:"center",spacing:.75,children:[e.jsx(t.Typography,{variant:"subtitle1",className:s.questionsTitle,children:"Questions"}),e.jsx(t.Typography,{variant:"subtitle1",className:s.questionsCountNumber,children:i})]})}),e.jsx(Ne,{questions:m.questions,onEditQuestion:x,onRemoveQuestion:R}),e.jsx(t.Box,{className:s.addQuestionWrapper,children:e.jsx(t.Button,{onClick:k,startIcon:e.jsx(Se.AddIcon,{}),className:s.addQuestionBtn,children:"ADD QUESTION"})})]})},Fa=()=>{const a=ie.useDispatch(),l=ie.useSelector(E=>E?.common?.user?.roles),d=_e.useNavigate(),c=C.useMemo(()=>{if(localStorage.getItem("is_returning_from_question")==="true"){localStorage.removeItem("is_returning_from_question");const P=localStorage.getItem("create_survey_draft");if(P)try{return JSON.parse(P)}catch{}}else localStorage.removeItem("create_survey_draft");return null},[]),{steps:r,activeStep:o,categories:m,selectedCategory:g,selectedTemplateId:i,templates:b,editingTemplate:y,handleSelectCategory:u,handleSelectTemplate:x,handleCreateBlankSurvey:R,handleEditTemplate:k,handleCloseEditTemplate:_,handleSaveEditTemplate:N,handleGoBackToDashboard:S,handlePreviousStep:p,handleNextStep:D,handleGoToStep:I}=Ue(c),O=C.useMemo(()=>{if(i==="BLANK")return null;if(i){const E=b.find(P=>P.id===i);return E||null}return b.length>0?b[0]:null},[b,i]),{formData:H,questionCategories:G,filteredQuestions:M,totalQuestionsCount:Y,handleTemplateNameChange:Q,handleDescriptionChange:$,handleCategoryFilterChange:T,handleRemoveQuestion:f}=Ve(i,O,c),{formData:n,handleTitleChange:v,handleDeadlineChange:w}=Ke(c),{students:F,allFilteredStudents:B,totalStudentsCount:W,totalSelectedCount:U,selectedStudentIds:h,filters:L,gradeOptions:V,flagOptions:ce,teacherOptions:de,isAllSelected:ne,isIndeterminate:Z,handleSortChange:ue,handleSearchChange:he,handleGradeFilterChange:K,handleFlagFilterChange:ve,handleTeacherFilterChange:we,handlePageChange:Be,handleRowsPerPageChange:Fe,handleToggleSelectAll:Ie,handleToggleStudent:Ae}=Xe(c),le=E=>{const P={activeStep:o,selectedCategory:g,selectedTemplateId:i,step2FormData:H,step3FormData:n,selectedStudentIds:h,editingTemplate:y,...E};localStorage.setItem("create_survey_draft",JSON.stringify(P))},Re=()=>{le(),d("/admin/create-survey-question?type=0&from=create-survey")},Le=E=>{le(),d(`/admin/survey-question-detail/${E}?type=0&from=create-survey`)},ke=C.useMemo(()=>(B||F).filter(E=>h.includes(E.id)),[B,F,h]),Ee=async()=>{const E=new Map;(B||F||[]).forEach(A=>E.set(A.id,A));const P=[],J=[],re=[];h.forEach(A=>{const q=E.get(A);if(q)q.schoolLevel==="ES"&&q.userId?(J.push(q.userId),re.push({userId:q.userId,name:q.name,firstName:q.name?.split(" ")?.[0]||"",email:q.email,studentId:q.studentId})):q.studentId!==void 0?P.push(q.studentId):typeof A=="number"?P.push(A):q.userId&&(J.push(q.userId),re.push({userId:q.userId,name:q.name,firstName:q.name?.split(" ")?.[0]||"",email:q.email,studentId:q.studentId}));else if(typeof A=="number"||!isNaN(Number(A))&&!String(A).includes("-"))P.push(Number(A));else{const X=String(A);J.push(X),re.push({userId:X,name:`Student ${X}`,firstName:"Student",email:""})}});const Pe=[{id:i,name:H.templateName,title:H.templateName,description:H.description,numberQuestion:H.questions.length,orderDefaultSurvey:1,questionTemplates:H.questions.map((A,q)=>({questionId:typeof A.id=="string"&&A.id.startsWith("q-")?0:Number(A.id),questionText:A.questionText,type:A.type||"MultipleChoice",orderDefaultQuestionTemplate:A.orderNumber??q,answers:A.options&&Array.isArray(A.options)?A.options.map((X,We)=>({id:0,text:X,order:We})):A.answers||[]}))}],He=n.deadline?ge(n.deadline,"DD.MM.YYYY hh:mm A").valueOf():null,ze={title:n.title,deadline:He,studentIds:P,esStudentUserIds:J,studentUserIds:J,esStudents:re,additionalQuestions:[],staffIds:[],summarizeQuestions:[],isAdmin:!0,isDraft:!1,role:Array.isArray(l)?l.join(","):l?String(l):"Admin",templateQuestions:Pe};try{a(z.setLoading(!0)),await pe.createSurvey(ze),a(z.setAlert({type:"success",message:"Publish survey success"})),S()}catch(A){console.error("Error publishing survey:",A),a(z.setAlert({type:"danger",message:A?.response?.data?.title||A?.message||"Failed to publish survey"}))}finally{a(z.setLoading(!1))}};C.useEffect(()=>{window.scrollTo({top:0,behavior:"instant"});const E=document.querySelector("main");E&&E.scrollTo({top:0,behavior:"instant"});const P=document.documentElement||document.body;P&&(P.scrollTop=0)},[o,y]);const qe=E=>{le({editingTemplateFormData:E}),d("/admin/create-survey-question?type=0&from=edit-template")},De=(E,P)=>{le({editingTemplateFormData:P}),d(`/admin/survey-question-detail/${E}?type=0&from=edit-template`)};return y?e.jsx(t.Box,{className:s.createSurveyPage,children:e.jsx(t.Box,{className:s.contentBody,children:e.jsx(Ba,{template:y,initialDraftData:c?.editingTemplateFormData,onSave:N,onCancel:_,onAddQuestionRedirect:qe,onEditQuestionRedirect:De})})}):e.jsxs(t.Box,{className:s.createSurveyPage,children:[e.jsx(t.Box,{className:s.headerTopBar,children:e.jsx(oa,{steps:r,activeStep:o,onBack:S})}),e.jsxs(t.Box,{className:s.contentBody,children:[o===0&&e.jsx(ha,{categories:m,selectedCategory:g,templates:b,selectedTemplateId:i,currentStepNumber:o+1,totalSteps:r.length,onSelectCategory:u,onSelectTemplate:x,onCreateBlank:R,onEditTemplate:k,onPrevious:p,onNext:D}),o===1&&e.jsx(ga,{formData:H,questionCategories:G,filteredQuestions:M,totalQuestionsCount:Y,currentStepNumber:o+1,totalSteps:r.length,onTemplateNameChange:Q,onDescriptionChange:$,onCategoryFilterChange:T,onEditQuestion:Le,onRemoveQuestion:f,onAddQuestion:Re,onPrevious:p,onNext:D}),o===2&&e.jsx(pa,{formData:n,currentStepNumber:o+1,totalSteps:r.length,onTitleChange:v,onDeadlineChange:w,onPrevious:p,onNext:D}),o===3&&e.jsx(_a,{students:F,totalStudentsCount:W,totalSelectedCount:U,selectedStudentIds:h,filters:L,gradeOptions:V,flagOptions:ce,teacherOptions:de,page:L.page,rowsPerPage:L.rowsPerPage,isAllSelected:ne,isIndeterminate:Z,sortBy:L.sortBy,sortOrder:L.sortOrder,onSortChange:ue,currentStepNumber:o+1,totalSteps:r.length,onSearchChange:he,onGradeChange:K,onFlagChange:ve,onTeacherChange:we,onPageChange:Be,onRowsPerPageChange:Fe,onToggleSelectAll:Ie,onToggleStudent:Ae,onPrevious:p,onNext:D}),o===4&&e.jsx(Na,{templateFormData:H,surveyFormData:n,selectedStudents:ke,currentStepNumber:o+1,totalSteps:r.length,onEditTemplateDetails:()=>I(1),onEditSurveyDetails:()=>I(2),onEditSelectedStudents:()=>I(3),onPrevious:p,onPublish:Ee})]})]})};exports.default=Fa;
|