mario-education 2.0.174-staging → 2.0.176-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"),oe=require("react-redux"),ye=require("react-router-dom"),me=require("moment"),z=require("mario-core"),ge=require("./surveyService-BKooa1m-.cjs"),We=require("./questionCategoryService-CjXNe6xV.cjs"),_e=require("./ArrowBack-C4WIF8bZ.cjs"),Te=require("./Check-CYAVgIcj.cjs"),be=require("./ArrowForward-D4TtLiX5.cjs"),te=require("./createSvgIcon-CRp0VXvr.cjs"),Ce=require("./Add-DE-4A91A.cjs"),pe=require("@mui/x-date-pickers"),Qe=require("./AdapterMoment-B-q0UCj0.cjs"),Oe=require("./Search-CZp6DUOA.cjs"),Ge=require("./Close-BqvQ2Wpz.cjs"),re=[{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=oe.useDispatch(),u=ye.useNavigate(),r=oe.useSelector(n=>n?.common?.language||"en"),[o,i]=S.useState(a?.activeStep??0),[g,h]=S.useState(a?.selectedCategory??"All"),[c,T]=S.useState(a?.selectedTemplateId??null),[y,d]=S.useState($e),[p,k]=S.useState(!1),[C,b]=S.useState(a?.editingTemplate??null),R=S.useCallback(async()=>{try{k(!0),l(z.setLoading(!0));const n=await ge.getTemplateSurvey(r);if(n?.data&&Array.isArray(n.data)&&n.data.length>0){const w=n.data.map(v=>{let F="Well-being";const B=(v.name||"").toLowerCase();return B.includes("climate")||B.includes("grow")?F="School Climate":B.includes("health")&&(F="Health & Wellness"),{id:v.id,title:v.name,description:v.description,questionCount:v.numberQuestion??v.questionTemplates?.length??0,category:F,rawTemplate:v}});d(w),a?.selectedTemplateId||T(v=>v||(w.length>0?w[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{k(!1),l(z.setLoading(!1))}},[r,l]);S.useEffect(()=>{R()},[R]);const N=S.useMemo(()=>{const n=new Set;return y.forEach(w=>{w.category&&n.add(w.category)}),n.size===0?Ye:["All",...Array.from(n)]},[y]),_=S.useMemo(()=>g==="All"?y:y.filter(n=>n.category.toLowerCase()===g.toLowerCase()),[y,g]),D=S.useMemo(()=>y.find(n=>n.id===c)||null,[y,c]),I=n=>{h(n)},G=n=>{T(n)},H=()=>{T("BLANK"),i(n=>Math.min(n+1,re.length-1))},Y=(n,w)=>{w.stopPropagation(),b(n)},Q=()=>{b(null)},$=async n=>{try{l(z.setLoading(!0));const w=n.rawTemplate?.questionTemplates?.map(B=>B.questionId||B.id)?.filter(B=>typeof B=="number"||!String(B).startsWith("q-"))?.map(B=>Number(B))||[],v={id:n.id,name:n.title,description:n.description,isFavorite:n.rawTemplate?.isFavorite??!1,questionIds:w};await We.updateSurvey(v),d(B=>B.map(M=>M.id===n.id?n:M)),b(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(w){l(z.setAlert({type:"danger",message:w.response?.data?.title||"Update template failed"}))}finally{l(z.setLoading(!1))}},O=()=>{u("/admin/survey-dashboard/list-survey")};return{steps:re,activeStep:o,categories:N,selectedCategory:g,selectedTemplateId:c,selectedTemplate:D,templates:_,rawTemplates:y,isLoading:p,editingTemplate:C,handleSelectCategory:I,handleSelectTemplate:G,handleCreateBlankSurvey:H,handleEditTemplate:Y,handleCloseEditTemplate:Q,handleSaveEditTemplate:$,handleGoBackToDashboard:O,handlePreviousStep:()=>{o>0?i(n=>n-1):O()},handleNextStep:()=>{o<re.length-1&&i(n=>n+1)},handleGoToStep:n=>{n>=0&&n<re.length&&i(n)},refetchTemplates:R}},he=(a,l)=>!a||!Array.isArray(a)||a.length===0?[]:a.map((u,r)=>({id:u.questionId??u.id??`q-${r+1}`,orderNumber:u.orderDefaultQuestionTemplate??r+1,questionText:u.questionText??u.text??`Question ${r+1}`,type:String(u.type||"Text"),category:u.category??u.categoryName??u.categoryTitle??u.title??l??"General",options:u.answers?.map(o=>o.text)||[]})),xe=[{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)=>{const u=S.useMemo(()=>{const C=a?.rawTemplate?.questionTemplates,b=he(C,a?.category||"Well-being");return b.length>0?b:xe},[a]),[r,o]=S.useState(()=>l?.step2FormData?l.step2FormData:a===null?{templateName:"",description:"",showLandingPageFlag:!1,questions:[],selectedCategoryFilter:"All"}:{templateName:a?.title||"Well-being",description:a?.description||"General assessment of student wellness and quality of life",showLandingPageFlag:!1,questions:u,selectedCategoryFilter:"All"}),i=S.useRef(l?.selectedTemplateId??(a?a.id:"BLANK"));S.useEffect(()=>{if(a){if(i.current===a.id)return;i.current=a.id;const C=a.rawTemplate?.questionTemplates,b=he(C,a.category||"Well-being");o(R=>({...R,templateName:a.title||"",description:a.description||"",questions:b.length>0?b:R.questions.length>0?R.questions:xe,selectedCategoryFilter:"All"}))}else if(a===null){if(i.current==="BLANK")return;i.current="BLANK",o(C=>({...C,templateName:"",description:"",questions:[],selectedCategoryFilter:"All"}))}},[a]);const g=S.useMemo(()=>{const C=new Set;r.questions.forEach(R=>{const N=R.category?.trim();N&&C.add(N)});const b=Array.from(C);return b.length>0?["All",...b]:["All"]},[r.questions]),h=S.useMemo(()=>r.selectedCategoryFilter==="All"?r.questions:r.questions.filter(C=>C.category===r.selectedCategoryFilter),[r.questions,r.selectedCategoryFilter]),c=C=>{o(b=>({...b,templateName:C}))},T=C=>{o(b=>({...b,description:C}))},y=C=>{o(b=>({...b,selectedCategoryFilter:C}))},d=C=>{console.log("Edit question:",C)},p=C=>{o(b=>({...b,questions:b.questions.filter(R=>R.id!==C).map((R,N)=>({...R,orderNumber:N+1}))}))},k=()=>{const C=`q-${Date.now()}`,b=r.questions.length+1,R={id:C,orderNumber:b,questionText:"New Question",type:"Rating",category:"General"};o(N=>({...N,questions:[...N.questions,R]}))};return{formData:r,questionCategories:g,filteredQuestions:h,totalQuestionsCount:r.questions.length,handleTemplateNameChange:c,handleDescriptionChange:T,handleCategoryFilterChange:y,handleEditQuestion:d,handleRemoveQuestion:p,handleAddQuestion:k}},Ke=(a,{initialTitle:l="",initialDeadline:u=me().add(1,"days").format("DD.MM.YYYY hh:mm A")}={})=>{const[r,o]=S.useState(()=>a?.step3FormData?a.step3FormData:{title:l||"",deadline:u||""});return{formData:r,handleTitleChange:h=>{o(c=>({...c,title:h}))},handleDeadlineChange:h=>{o(c=>({...c,deadline:h}))}}},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,u]=S.useState([]),[r,o]=S.useState(a?.selectedStudentIds??[]),[i,g]=S.useState([]),[h,c]=S.useState(Ze),[T,y]=S.useState([]),[d,p]=S.useState({searchQuery:"",selectedGrade:"All Grades",selectedFlag:"all",selectedTeacher:"All Teachers",page:0,rowsPerPage:10,sortBy:"name",sortOrder:"asc"}),k=S.useCallback(async()=>{try{const x=await ge.searchStudents({roles:["Admin"]});if(x?.data?.items&&Array.isArray(x.data.items)&&x.data.items.length>0){const f=x.data.items.map(m=>{let L="none";if(typeof m.flag=="string"){const V=m.flag.toLowerCase();(V==="red"||V==="yellow"||V==="green")&&(L=V)}else m.redFlags>0||m.flag===1?L="red":m.yellowFlags>0||m.flag===2?L="yellow":(m.greenFlags>0||m.flag===3)&&(L="green");const W=m.fullName||m.studentName,ie=m.gradeLevel,ce=m.email,ae=m.userId||(typeof m.id=="string"?m.id:""),J=typeof m.studentId=="number"?m.studentId:typeof m.id=="number"?m.id:void 0,de=ae||(J!==void 0?String(J):`student-${Math.random()}`),ue=(m.schoolLevel||(m.userId&&m.id===void 0?"ES":"MS")).toUpperCase();return{id:de,userId:ae,studentId:J,schoolLevel:ue,name:W,avatarUrl:m.profileImageFileName?z.getFileUrl(m.profileImageFileName):Je,flag:L,flagTooltip:m.flagTooltip||void 0,flagDetail:m.flagDetail,lastSafetyAnswer:m.lastSafetyAnswer,lastStressAnswer:m.lastStressAnswer,flagSessionId:m.flagSessionId,flagSessionResultId:m.flagSessionResultId,grade:ie,email:ce,listTeachers:m.listTeachers||[]}});u(f);const n=Array.from(new Set(f.map(m=>m.grade))).filter(m=>m&&m!=="N/A"),w=m=>{if(!m||m==="N/A")return-999;const L=m.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 W=L.match(/^(\d+)/);return W?parseInt(W[1],10):999};n.sort((m,L)=>w(m)-w(L)),g(["All Grades",...n]);const v=Array.from(new Set(f.map(m=>m.flag))),F=[{label:"All Flags",value:"all"}];v.includes("red")&&F.push({label:"Red Flag",value:"red"}),v.includes("yellow")&&F.push({label:"Yellow Flag",value:"yellow"}),v.includes("green")&&F.push({label:"Green Flag",value:"green"}),c(F);const B=new Set;f.forEach(m=>{m.listTeachers&&m.listTeachers.length>0&&m.listTeachers.forEach(L=>{L.name&&B.add(L.name.trim())})});const M=Array.from(B).sort((m,L)=>m.localeCompare(L));y(["All Teachers",...M])}}catch(x){console.error("Error fetching students list:",x)}},[]);S.useEffect(()=>{k()},[k]);const C=x=>{p(f=>({...f,searchQuery:x,page:0}))},b=x=>{p(f=>({...f,selectedGrade:x,page:0}))},R=x=>{p(f=>({...f,selectedFlag:x,page:0}))},N=x=>{p(f=>({...f,selectedTeacher:x,page:0}))},_=(x,f)=>{p(n=>({...n,page:f}))},D=x=>{p(f=>({...f,rowsPerPage:parseInt(x.target.value,10),page:0}))},I=S.useMemo(()=>l.filter(x=>{if(d.searchQuery.trim()){const f=F=>(F||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase(),n=f(d.searchQuery.trim()),w=f(x.name).includes(n),v=f(x.email).includes(n);if(!w&&!v)return!1}return!(d.selectedGrade!=="All Grades"&&(x.grade||"").toLowerCase()!==(d.selectedGrade||"").toLowerCase()||d.selectedFlag!=="all"&&x.flag!==d.selectedFlag||d.selectedTeacher!=="All Teachers"&&(!x.listTeachers||x.listTeachers.length===0||!x.listTeachers.some(n=>n.name&&n.name.trim()===d.selectedTeacher)))}),[l,d]),G=x=>{p(f=>({...f,sortBy:x,sortOrder:f.sortBy===x&&f.sortOrder==="asc"?"desc":"asc"}))},H=S.useMemo(()=>[...I].sort((f,n)=>{let w=f[d.sortBy],v=n[d.sortBy];if(d.sortBy==="flag"){const F={red:3,yellow:2,green:1,none:0};w=F[f.flag]||0,v=F[n.flag]||0}else if(d.sortBy==="grade"){const F=B=>{if(!B||B==="N/A")return-999;const M=B.toString().toUpperCase().replace(/TH|RD|ND|ST/g,"").trim();if(M==="PK")return-2;if(M==="K")return-1;if(M==="G")return 0;const m=M.match(/^(\d+)/);return m?parseInt(m[1],10):999};w=F(f.grade),v=F(n.grade)}else d.sortBy==="teacher"?(w=f.listTeachers&&f.listTeachers.length>0?f.listTeachers.map(F=>F.name).join(", ").toLowerCase():"",v=n.listTeachers&&n.listTeachers.length>0?n.listTeachers.map(F=>F.name).join(", ").toLowerCase():""):typeof w=="string"&&typeof v=="string"&&(w=w.toLowerCase(),v=v.toLowerCase());return w<v?d.sortOrder==="asc"?-1:1:w>v?d.sortOrder==="asc"?1:-1:0}),[I,d.sortBy,d.sortOrder]),Y=S.useMemo(()=>{const x=d.page*d.rowsPerPage;return H.slice(x,x+d.rowsPerPage)},[H,d.page,d.rowsPerPage]),Q=S.useMemo(()=>I.length===0?!1:I.every(x=>r.includes(x.id)),[I,r]),$=S.useMemo(()=>{if(I.length===0)return!1;const x=I.filter(f=>r.includes(f.id));return x.length>0&&x.length<I.length},[I,r]),O=()=>{if(Q){const x=I.map(f=>f.id);o(f=>f.filter(n=>!x.includes(n)))}else{const x=new Set([...r,...I.map(f=>f.id)]);o(Array.from(x))}},U=x=>{o(f=>f.includes(x)?f.filter(n=>n!==x):[...f,x])};return{students:Y,allFilteredStudents:I,totalStudentsCount:I.length,totalSelectedCount:r.length,selectedStudentIds:r,filters:d,gradeOptions:i,flagOptions:h,teacherOptions:T,isAllSelected:Q,isIndeterminate:$,handleSortChange:G,handleSearchChange:C,handleGradeFilterChange:b,handleFlagFilterChange:R,handleTeacherFilterChange:N,handlePageChange:_,handleRowsPerPageChange:D,handleToggleSelectAll:O,handleToggleStudent:U}},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",kt="_templateDescription_254g3_346",Lt="_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",Mt="_editTemplateCancelBtn_254g3_460",Wt="_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",ks="_filterDropdownWrapper_254g3_894",Ls="_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",Ms="_studentTableRow_254g3_981",Ws="_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:kt,chipItem:Lt,wizardFooter:Et,previousBtn:qt,disabled:Dt,stepCounterText:Pt,nextBtn:Ht,editTemplateHeaderSection:zt,editTemplateCancelBtn:Mt,editTemplateSaveBtn:Wt,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:ks,filterSelectBox:Ls,studentsTableContainer:Es,studentsTable:qs,studentsTableHeaderRow:Ds,checkboxHeaderCell:Ps,tableHeaderCell:Hs,checkboxBodyCell:zs,studentTableRow:Ms,selectedRow:Ws,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:u})=>e.jsxs(t.Box,{className:s.stepperContainer,children:[e.jsx(t.Button,{onClick:u,startIcon:e.jsx(_e.ArrowBackIcon,{fontSize:"small"}),className:s.backButton,children:"Back to Surveys Dashboard"}),e.jsx(t.Box,{className:s.stepperProgress,children:a.map((r,o)=>{const i=o===l,g=o<l,h=o===a.length-1;return e.jsxs(t.Box,{className:`${s.stepColumn} ${h?s.stepColumnLast:""}`,children:[e.jsxs(t.Box,{className:s.stepCircleRow,children:[e.jsxs(t.Box,{className:`${s.stepCircle} ${i?s.active:g?s.completed:""}`,children:[i&&e.jsx(t.Box,{className:s.stepInnerDot}),g&&e.jsx(Te.CheckIcon,{sx:{fontSize:16,color:"#ffffff"}})]}),!h&&e.jsx(t.Box,{className:`${s.stepConnectorLine} ${g?s.completed:""}`})]}),e.jsxs(t.Stack,{alignItems:"flex-start",spacing:.25,className:s.stepLabelStack,children:[e.jsxs(t.Typography,{variant:"caption",className:`${s.stepNumberLabel} ${i?s.active:""}`,children:["STEP ",r.stepNumber]}),e.jsx(t.Typography,{variant:"body2",className:`${s.stepTextLabel} ${i?s.active:""}`,children:r.label})]})]},r.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(be.ArrowForwardIcon,{sx:{fontSize:16}}),className:s.bannerActionBtn,children:"CREATE BLANK SURVEY"})]}),ca=({categories:a,selectedCategory:l,onSelectCategory:u})=>e.jsx(t.Box,{className:s.filterPillsContainer,children:e.jsx(t.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:a.map(r=>{const o=l.toLowerCase()===r.toLowerCase();return e.jsx(t.Chip,{label:r,onClick:()=>u(r),className:`${s.filterPill} ${o?s.active:""}`},r)})})}),X=te.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:u,onEdit:r})=>e.jsxs(t.Box,{onClick:()=>u(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:o=>r(a,o),startIcon:e.jsx(X,{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=te.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"),se=({currentStep:a,totalSteps:l,onPrevious:u,onNext:r,isNextDisabled:o=!1,isLastStep:i=!1,nextLabel:g="NEXT",onPreview:h})=>e.jsxs(t.Box,{className:s.wizardFooter,children:[e.jsx(t.Button,{variant:"outlined",onClick:u,startIcon:e.jsx(_e.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]}),i?e.jsxs(t.Stack,{direction:"row",spacing:1.5,alignItems:"center",children:[h&&e.jsx(t.Button,{variant:"outlined",onClick:h,startIcon:e.jsx(ua,{sx:{fontSize:18}}),className:s.previewSurveyBtn,children:"SURVEY PREVIEW"}),e.jsx(t.Button,{variant:"contained",onClick:r,disabled:o,className:s.publishBtn,children:g||"PUBLISH"})]}):e.jsx(t.Button,{variant:"contained",onClick:r,disabled:o,endIcon:e.jsx(be.ArrowForwardIcon,{sx:{fontSize:16}}),className:s.nextBtn,children:g})]}),ha=({categories:a,selectedCategory:l,templates:u,selectedTemplateId:r,currentStepNumber:o,totalSteps:i,onSelectCategory:g,onSelectTemplate:h,onCreateBlank:c,onEditTemplate:T,onPrevious:y,onNext:d})=>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:c}),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:g})]}),e.jsx(t.Grid,{container:!0,spacing:2.5,sx:{mt:1},children:u.map(p=>e.jsx(t.Grid,{item:!0,xs:12,sm:6,md:4,children:e.jsx(da,{template:p,isSelected:r===p.id,onSelect:h,onEdit:T})},p.id))}),e.jsx(se,{currentStep:o,totalSteps:i,onPrevious:y,onNext:d})]}),ma=te.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"),Se=({type:a})=>{const l=o=>{if(typeof o=="number"||!isNaN(Number(o))){const i=Number(o);if(i===0)return"Text";if(i===1)return"MultipleChoice";if(i===2||i===3)return"Slider";if(i===4)return"YesNo";if(i===5)return"SingleChoice";if(i===6)return"Date"}return String(o)},u=o=>{switch(l(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}},r=o=>{const i=l(o);switch(i){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 i}};return e.jsx(t.Box,{className:`${s.questionTypeBadge} ${u(a)}`,children:e.jsx(t.Typography,{variant:"caption",className:s.badgeTextLabel,children:r(a)})})},je=({questions:a,onEditQuestion:l,onRemoveQuestion:u})=>{const[r,o]=S.useState(null),[i,g]=S.useState(!1),h=y=>{o(y),g(!0)},c=()=>{r!==null&&u(r),g(!1),o(null)},T=()=>{g(!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,d)=>e.jsxs(t.TableRow,{className:s.tableBodyRow,children:[e.jsxs(t.TableCell,{className:s.tdNumber,children:[d+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(Se,{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(X,{fontSize:"small"}),className:s.tableEditBtn,children:"Edit"}),e.jsx(t.Button,{onClick:()=>h(y.id),startIcon:e.jsx(ma,{fontSize:"small"}),className:s.tableRemoveBtn,children:"Remove"})]})})]},y.id))})]}),e.jsxs(t.Dialog,{open:i,onClose:T,"aria-labelledby":"confirm-delete-dialog-title","aria-describedby":"confirm-delete-dialog-description",children:[e.jsx(t.DialogTitle,{id:"confirm-delete-dialog-title",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:T,color:"inherit",children:"Cancel"}),e.jsx(t.Button,{onClick:c,color:"error",autoFocus:!0,children:"Remove"})]})]})]})},ga=({formData:a,questionCategories:l,filteredQuestions:u,totalQuestionsCount:r,currentStepNumber:o,totalSteps:i,onTemplateNameChange:g,onDescriptionChange:h,onCategoryFilterChange:c,onEditQuestion:T,onRemoveQuestion:y,onAddQuestion:d,onPrevious:p,onNext:k})=>{const C=b=>{c(b.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:b=>g(b.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:b=>h(b.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:r})]}),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:C,className:s.categorySelectInput,children:l.map(b=>e.jsx(t.MenuItem,{value:b,children:b},b))})})]})]}),e.jsx(je,{questions:u,onEditQuestion:T,onRemoveQuestion:y}),e.jsx(t.Box,{className:s.addQuestionWrapper,children:e.jsx(t.Button,{onClick:d,startIcon:e.jsx(Ce.AddIcon,{}),className:s.addQuestionBtn,children:"ADD QUESTION"})}),e.jsx(se,{currentStep:o,totalSteps:i,onPrevious:p,onNext:k,isNextDisabled:!a.templateName||a.templateName.trim()===""})]})},pa=({formData:a,currentStepNumber:l,totalSteps:u,onTitleChange:r,onDeadlineChange:o,onPrevious:i,onNext:g})=>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:h=>r(h.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(pe.LocalizationProvider,{dateAdapter:Qe.AdapterMoment,children:e.jsx(pe.DateTimePicker,{value:a.deadline?me(a.deadline,"DD.MM.YYYY hh:mm A"):null,onChange:h=>{o(h?h.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(se,{currentStep:l,totalSteps:u,onPrevious:i,onNext:g,isNextDisabled:!a.title||a.title.trim()===""||!a.deadline})]}),ee=({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"},fe=a=>{switch(a){case"Red Flag":return e.jsxs("div",{className:j["flag-of-session__title-red"],children:[e.jsx(ee,{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(ee,{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:u,lastStressAnswer:r,showResult:o,defaultStress:i,defaultSafety:g,defaultDecrease:h,isDetailView:c,hasReadyToLearn:T,inSession:y})=>o?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"})]}),c&&a&&fe(a||""),l?.stress&&(c?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 ",r,"%"]})),l?.safety&&(c?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 ",u,"%"]})),l?.decrease&&l?.decrease?.length>0&&(c?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 ",h,"% comparing their average of the last four check-ins."]}),e.jsx("ul",{className:j["flag-of-session__item-column--content"],children:l.decrease?.map((d,p)=>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:[d.questionText,": ",d.answer,"% ",d.averageOtherRatingsText?"":d.averageOtherRatings!==void 0?`vs avr ${d.averageOtherRatings}%`:"vs previous"]})})},p))})]}):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((d,p)=>{const C=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:[d.questionText,":"]}),e.jsxs("p",{style:{margin:0,color:C,fontSize:"12px"},children:[d.answer,"%"]}),d.averageOtherRatingsText?"":d.averageOtherRatings!==void 0&&e.jsxs("p",{style:{margin:0,fontSize:"12px",marginLeft:"4px"},children:["vs avr ",d.averageOtherRatings,"%"]})]})},p)})})]}):e.jsxs("div",{className:j["flag-of-session__item"],children:["Sudden Drop: Any core well-being metric shows a percentage decrease of ",h||20,"% comparing their average of the last four check-ins."]})),l?.readinessToLearn&&(c?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:[fe(a||""),g&&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 ",g,"%"]})]}),i&&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 ",i,"%"]})]}),h&&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 ",h,"% comparing their average of the last four check-ins."]})}),T&&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=te.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(ee,{size:32,color:"#C44140"}):l==="yellow"?e.jsx(ee,{size:32,color:"#F5D500"}):l==="green"?e.jsx(ee,{size:32,color:"#10B981"}):null},_a=({students:a,totalStudentsCount:l,totalSelectedCount:u,selectedStudentIds:r,filters:o,gradeOptions:i,flagOptions:g,teacherOptions:h,page:c,rowsPerPage:T,isAllSelected:y,isIndeterminate:d,sortBy:p,sortOrder:k,onSortChange:C,currentStepNumber:b,totalSteps:R,onSearchChange:N,onGradeChange:_,onFlagChange:D,onTeacherChange:I,onPageChange:G,onRowsPerPageChange:H,onToggleSelectAll:Y,onToggleStudent:Q,onPrevious:$,onNext:O})=>{const U=n=>{_(n.target.value)},x=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:u})]})}),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:n=>N(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:o.selectedGrade,onChange:U,displayEmpty:!0,className:s.filterSelectBox,children:i.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:o.selectedFlag,onChange:x,displayEmpty:!0,className:s.filterSelectBox,children:g.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:o.selectedTeacher,onChange:f,displayEmpty:!0,className:s.filterSelectBox,children:h.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:d,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:p==="name",direction:p==="name"?k:"asc",onClick:()=>C("name"),children:"Student Name"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:p==="flag",direction:p==="flag"?k:"asc",onClick:()=>C("flag"),children:"Flag"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:p==="grade",direction:p==="grade"?k:"asc",onClick:()=>C("grade"),children:"Grade"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:p==="email",direction:p==="email"?k:"asc",onClick:()=>C("email"),children:"Email"})}),e.jsx(t.TableCell,{className:s.tableHeaderCell,children:e.jsx(t.TableSortLabel,{active:p==="teacher",direction:p==="teacher"?k:"asc",onClick:()=>C("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 w=r.includes(n.id);return e.jsxs(t.TableRow,{className:`${s.studentTableRow} ${w?s.selectedRow:""}`,onClick:()=>Q(n.id),children:[e.jsx(t.TableCell,{className:s.checkboxBodyCell,onClick:v=>v.stopPropagation(),children:e.jsx(t.Checkbox,{checked:w,onChange:()=>Q(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(v=>v.name).filter(Boolean).join(", "):"-"})})]},n.id)})})]}),l>0&&e.jsx(t.TablePagination,{rowsPerPageOptions:[5,10,25,50],component:"div",count:l,rowsPerPage:T,page:c,onPageChange:G,onRowsPerPageChange:H,className:s.studentsPagination})]}),e.jsx(se,{currentStep:b,totalSteps:R,onPrevious:$,onNext:O})]})},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 u="#10B981";a==="red"?u="#D10530":a==="yellow"?u="#F5D500":a==="green"&&(u="#0F9655");const r=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:r,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:u,size:28})})})},Sa=te.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:u,deadline:r,questions:o,onClose:i})=>{const g=c=>{if(typeof c=="number"||!isNaN(Number(c))){const T=Number(c);if(T===0)return"Text";if(T===1)return"MultipleChoice";if(T===2||T===3)return"Slider";if(T===4)return"YesNo";if(T===5)return"SingleChoice";if(T===6)return"Date"}return String(c)},h=c=>{try{const T=document.createElement("textarea");return T.innerHTML=c,T.value}catch{return c}};return e.jsxs(t.Dialog,{open:a,onClose:i,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:i,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:u||"General assessment of student wellness and quality of life"}),r&&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: ",r]})]}),e.jsx(t.Stack,{spacing:3,children:o.map((c,T)=>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:[T+1,"."]}),e.jsx(t.Box,{sx:{"& p":{m:0,display:"inline"},"& span":{display:"inline"}},dangerouslySetInnerHTML:{__html:h(c.questionText||"")}})]}),(g(c.type)==="Rating"||g(c.type)==="StarRating"||g(c.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))}),g(c.type)==="MultipleChoice"&&e.jsx(t.Stack,{spacing:1,children:c.options&&c.options.length>0?c.options.map((y,d)=>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})},d)):e.jsx(t.Typography,{variant:"body2",sx:{color:"#94a3b8"},children:"No options provided"})}),(g(c.type)==="YesNo"||g(c.type)==="SingleChoice")&&e.jsx(t.RadioGroup,{row:!0,children:c.options&&c.options.length>0?c.options.map((y,d)=>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})},d)):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"})})]})}),(g(c.type)==="Text"||g(c.type)==="TextInput"||g(c.type)==="OpenField")&&e.jsx(t.TextField,{fullWidth:!0,multiline:!0,rows:2,placeholder:"Your answer...",size:"small",sx:{"& .MuiOutlinedInput-root":{borderRadius:"8px",backgroundColor:"#ffffff"}}})]},c.id))})]})]})},Na=({templateFormData:a,surveyFormData:l,selectedStudents:u,currentStepNumber:r,totalSteps:o,onEditTemplateDetails:i,onEditSurveyDetails:g,onEditSelectedStudents:h,onPrevious:c,onPublish:T})=>{const[y,d]=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:i,startIcon:e.jsx(X,{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((p,k)=>e.jsxs(t.TableRow,{className:s.tableBodyRow,children:[e.jsxs(t.TableCell,{className:s.tdNumber,children:[k+1,"."]}),e.jsx(t.TableCell,{className:s.tdQuestion,children:e.jsx(t.Typography,{variant:"body2",className:s.questionText,dangerouslySetInnerHTML:{__html:p.questionText||""}})}),e.jsx(t.TableCell,{className:s.tdType,children:e.jsx(Se,{type:p.type})}),e.jsx(t.TableCell,{className:s.tdCategory,children:e.jsx(t.Typography,{variant:"body2",className:s.categoryText,children:p.category})})]},p.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:g,startIcon:e.jsx(X,{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:u.length})]}),e.jsx(t.Button,{variant:"text",onClick:h,startIcon:e.jsx(X,{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:u.length===0?e.jsx(t.TableRow,{children:e.jsx(t.TableCell,{colSpan:4,align:"center",sx:{py:3,color:"#94a3b8"},children:"No students selected."})}):u.map(p=>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:p.avatarUrl,alt:p.name,sx:{width:28,height:28,fontSize:"0.75rem",bgcolor:"#e0e7ff",color:"#3730a3"},children:p.name.charAt(0)}),e.jsx(t.Typography,{variant:"body2",className:s.studentNameText,children:p.name})]})}),e.jsx(t.TableCell,{className:s.flagCell,children:e.jsx(Ca,{flag:p.flag,tooltip:p.flagTooltip})}),e.jsx(t.TableCell,{className:s.gradeCell,children:e.jsx(t.Typography,{variant:"body2",className:s.gradeText,children:p.grade})}),e.jsx(t.TableCell,{className:s.emailCell,children:e.jsx(t.Typography,{variant:"body2",className:s.emailText,children:p.email})})]},p.id))})]})})]}),e.jsx(se,{currentStep:r,totalSteps:o,isLastStep:!0,nextLabel:"PUBLISH",onPreview:()=>d(!0),onPrevious:c,onNext:T}),e.jsx(ja,{open:y,title:l.title||a.templateName,description:a.description,deadline:l.deadline,questions:a.questions,onClose:()=>d(!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:u,onCancel:r,onAddQuestionRedirect:o,onEditQuestionRedirect:i})=>{const g=S.useMemo(()=>{const N=a.rawTemplate?.questionTemplates,_=he(N,a.category||"Well-being");return _.length>0?_:va},[a]),[h,c]=S.useState(()=>l||{id:a.id,templateName:a.title,description:a.description||"",showLandingPageFlag:!1,category:a.category||"Well-being",questions:g}),T=S.useMemo(()=>{const N=new Set;h.category?.trim()&&N.add(h.category.trim()),h.questions.forEach(D=>{const I=D.category?.trim();I&&N.add(I)});const _=Array.from(N);return _.length>0?_:["General"]},[h.category,h.questions]),y=N=>{c(_=>({..._,templateName:N}))},d=N=>{c(_=>({..._,description:N}))},p=N=>{c(_=>({..._,category:N}))},k=N=>{i&&i(N,h)},C=N=>{c(_=>({..._,questions:_.questions.filter(D=>D.id!==N).map((D,I)=>({...D,orderNumber:I+1}))}))},b=()=>{o&&o(h)},R=()=>{const N={...a,title:h.templateName,description:h.description,category:h.category,questionCount:h.questions.length,rawTemplate:{...a.rawTemplate,questionTemplates:h.questions.map(_=>({questionId:typeof _.id=="number"||String(_.id).startsWith("q-")?_.id:parseInt(String(_.id)),questionText:_.questionText,type:_.type,category:_.category}))}};u(N)};return{formData:h,categoryOptions:T,totalQuestionsCount:h.questions.length,handleTemplateNameChange:y,handleDescriptionChange:d,handleCategoryChange:p,handleEditQuestion:k,handleRemoveQuestion:C,handleAddQuestion:b,handleSave:R,handleCancel:r}},Ba=({template:a,initialDraftData:l,onSave:u,onCancel:r,onAddQuestionRedirect:o,onEditQuestionRedirect:i})=>{const{formData:g,categoryOptions:h,totalQuestionsCount:c,handleTemplateNameChange:T,handleDescriptionChange:y,handleCategoryChange:d,handleEditQuestion:p,handleRemoveQuestion:k,handleAddQuestion:C,handleSave:b,handleCancel:R}=wa({template:a,initialDraftData:l,onSave:u,onCancel:r,onAddQuestionRedirect:o,onEditQuestionRedirect:i});S.useEffect(()=>{window.scrollTo({top:0,behavior:"instant"});const _=document.querySelector("main");_&&_.scrollTo({top:0,behavior:"instant"});const D=document.documentElement||document.body;D&&(D.scrollTop=0)},[]);const N=_=>{d(_.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:R,className:s.editTemplateCancelBtn,children:"CANCEL"}),e.jsx(t.Button,{variant:"contained",onClick:b,startIcon:e.jsx(Te.CheckIcon,{}),className:s.editTemplateSaveBtn,disabled:!g.templateName||g.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:g.templateName,onChange:_=>T(_.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:g.description,onChange:_=>y(_.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:g.category,onChange:N,className:s.templateCategorySelect,children:h.map(_=>e.jsx(t.MenuItem,{value:_,children:_},_))})})]}),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:c})]})}),e.jsx(je,{questions:g.questions,onEditQuestion:p,onRemoveQuestion:k}),e.jsx(t.Box,{className:s.addQuestionWrapper,children:e.jsx(t.Button,{onClick:C,startIcon:e.jsx(Ce.AddIcon,{}),className:s.addQuestionBtn,children:"ADD QUESTION"})})]})},Fa=()=>{const a=oe.useDispatch(),l=oe.useSelector(E=>E?.common?.user?.roles),u=ye.useNavigate(),r=S.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:o,activeStep:i,categories:g,selectedCategory:h,selectedTemplateId:c,templates:T,editingTemplate:y,handleSelectCategory:d,handleSelectTemplate:p,handleCreateBlankSurvey:k,handleEditTemplate:C,handleCloseEditTemplate:b,handleSaveEditTemplate:R,handleGoBackToDashboard:N,handlePreviousStep:_,handleNextStep:D,handleGoToStep:I}=Ue(r),G=S.useMemo(()=>{if(c==="BLANK")return null;if(c){const E=T.find(P=>P.id===c);return E||null}return T.length>0?T[0]:null},[T,c]),{formData:H,questionCategories:Y,filteredQuestions:Q,totalQuestionsCount:$,handleTemplateNameChange:O,handleDescriptionChange:U,handleCategoryFilterChange:x,handleRemoveQuestion:f}=Ve(G,r),{formData:n,handleTitleChange:w,handleDeadlineChange:v}=Ke(r),{students:F,allFilteredStudents:B,totalStudentsCount:M,totalSelectedCount:m,selectedStudentIds:L,filters:W,gradeOptions:ie,flagOptions:ce,teacherOptions:ae,isAllSelected:J,isIndeterminate:de,handleSortChange:ue,handleSearchChange:V,handleGradeFilterChange:Ne,handleFlagFilterChange:ve,handleTeacherFilterChange:we,handlePageChange:Be,handleRowsPerPageChange:Fe,handleToggleSelectAll:Ie,handleToggleStudent:Ae}=Xe(r),ne=E=>{const P={activeStep:i,selectedCategory:h,selectedTemplateId:c,step2FormData:H,step3FormData:n,selectedStudentIds:L,editingTemplate:y,...E};localStorage.setItem("create_survey_draft",JSON.stringify(P))},Re=()=>{ne(),u("/admin/create-survey-question?type=0&from=create-survey")},ke=E=>{ne(),u(`/admin/survey-question-detail/${E}?type=0&from=create-survey`)},Le=S.useMemo(()=>(B||F).filter(E=>L.includes(E.id)),[B,F,L]),Ee=async()=>{const E=new Map;(B||F||[]).forEach(A=>E.set(A.id,A));const P=[],K=[],le=[];L.forEach(A=>{const q=E.get(A);if(q)q.schoolLevel==="ES"&&q.userId?(K.push(q.userId),le.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&&(K.push(q.userId),le.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 Z=String(A);K.push(Z),le.push({userId:Z,name:`Student ${Z}`,firstName:"Student",email:""})}});const Pe=[{id:c,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((Z,Me)=>({id:0,text:Z,order:Me})):A.answers||[]}))}],He=n.deadline?me(n.deadline,"DD.MM.YYYY hh:mm A").valueOf():null,ze={title:n.title,deadline:He,studentIds:P,esStudentUserIds:K,studentUserIds:K,esStudents:le,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 ge.createSurvey(ze),a(z.setAlert({type:"success",message:"Publish survey success"})),N()}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))}};S.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)},[i,y]);const qe=E=>{ne({editingTemplateFormData:E}),u("/admin/create-survey-question?type=0&from=edit-template")},De=(E,P)=>{ne({editingTemplateFormData:P}),u(`/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:r?.editingTemplateFormData,onSave:R,onCancel:b,onAddQuestionRedirect:qe,onEditQuestionRedirect:De})})}):e.jsxs(t.Box,{className:s.createSurveyPage,children:[e.jsx(t.Box,{className:s.headerTopBar,children:e.jsx(oa,{steps:o,activeStep:i,onBack:N})}),e.jsxs(t.Box,{className:s.contentBody,children:[i===0&&e.jsx(ha,{categories:g,selectedCategory:h,templates:T,selectedTemplateId:c,currentStepNumber:i+1,totalSteps:o.length,onSelectCategory:d,onSelectTemplate:p,onCreateBlank:k,onEditTemplate:C,onPrevious:_,onNext:D}),i===1&&e.jsx(ga,{formData:H,questionCategories:Y,filteredQuestions:Q,totalQuestionsCount:$,currentStepNumber:i+1,totalSteps:o.length,onTemplateNameChange:O,onDescriptionChange:U,onCategoryFilterChange:x,onEditQuestion:ke,onRemoveQuestion:f,onAddQuestion:Re,onPrevious:_,onNext:D}),i===2&&e.jsx(pa,{formData:n,currentStepNumber:i+1,totalSteps:o.length,onTitleChange:w,onDeadlineChange:v,onPrevious:_,onNext:D}),i===3&&e.jsx(_a,{students:F,totalStudentsCount:M,totalSelectedCount:m,selectedStudentIds:L,filters:W,gradeOptions:ie,flagOptions:ce,teacherOptions:ae,page:W.page,rowsPerPage:W.rowsPerPage,isAllSelected:J,isIndeterminate:de,sortBy:W.sortBy,sortOrder:W.sortOrder,onSortChange:ue,currentStepNumber:i+1,totalSteps:o.length,onSearchChange:V,onGradeChange:Ne,onFlagChange:ve,onTeacherChange:we,onPageChange:Be,onRowsPerPageChange:Fe,onToggleSelectAll:Ie,onToggleStudent:Ae,onPrevious:_,onNext:D}),i===4&&e.jsx(Na,{templateFormData:H,surveyFormData:n,selectedStudents:Le,currentStepNumber:i+1,totalSteps:o.length,onEditTemplateDetails:()=>I(1),onEditSurveyDetails:()=>I(2),onEditSelectedStudents:()=>I(3),onPrevious:_,onPublish:Ee})]})]})};exports.default=Fa;