PageSourceSearch

https://aimtest-student-web.vercel.app/_next/static/chunks/9537-d7be5b0e0650745a.js

js aimtest-student-web.vercel.app collected 2026-10-03 06:15:10 UTC 93,011 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9537],{93162:function(e,n,t){var r,o,i;o=[],r=function(){"use strict";function n(e,n){return"undefined"==typeof n?n={autoBom:!1}:"object"!=typeof n&&(console.warn("Deprecated: Expected third argument to be a object"),n={autoBom:!n}),n.autoBom&&/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)?new Blob(["\ufeff",e],{type:e.type}):e}function r(e,n,t){var r=new XMLHttpRequest;r.open("GET",e),r.responseType="blob",r.onload=function(){l(r.response,n,t)},r.onerror=function(){console.error("could not download file")},r.send()}function o(e){var n=new XMLHttpRequest;n.open("HEAD",e,!1);try{n.send()}catch(e){}return 200<=n.status&&299>=n.status}function i(e){try{e.dispatchEvent(new MouseEvent("click"))}catch(r){var n=document.createEvent("MouseEvents");n.initMouseEvent("click",!0,!0,window,0,0,0,80,20,!1,!1,!1,!1,0,null),e.dispatchEvent(n)}}var a="object"==typeof window&&window.window===window?window:"object"==typeof self&&self.self===self?self:"object"==typeof t.g&&t.g.global===t.g?t.g:void 0,s=a.navigator&&/Macintosh/.test(navigator.userAgent)&&/AppleWebKit/.test(navigator.userAgent)&&!/Safari/.test(navigator.userAgent),l=a.saveAs||("object"!=typeof window||window!==a?function(){}:"download"in HTMLAnchorElement.prototype&&!s?function(e,n,t){var s=a.URL||a.webkitURL,l=document.createElement("a");n=n||e.name||"download",l.download=n,l.rel="noopener","string"==typeof e?(l.href=e,l.origin===location.origin?i(l):o(l.href)?r(e,n,t):i(l,l.target="_blank")):(l.href=s.createObjectURL(e),setTimeout((function(){s.revokeObjectURL(l.href)}),4e4),setTimeout((function(){i(l)}),0))}:"msSaveOrOpenBlob"in navigator?function(e,t,a){if(t=t||e.name||"download","string"!=typeof e)navigator.msSaveOrOpenBlob(n(e,a),t);else if(o(e))r(e,t,a);else{var s=document.createElement("a");s.href=e,s.target="_blank",setTimeout((function(){i(s)}))}}:function(e,n,t,o){if((o=o||open("","_blank"))&&(o.document.title=o.document.body.innerText="downloading..."),"string"==typeof e)return r(e,n,t);var i="application/octet-stream"===e.type,l=/constructor/i.test(a.HTMLElement)||a.safari,c=/CriOS\/[\d]+/.test(navigator.userAgent);if((c||i&&l||s)&&"undefined"!=typeof FileReader){var u=new FileReader;u.onloadend=function(){var e=u.result;e=c?e:e.replace(/^data:[^;]*;/,"data:attachment/file;"),o?o.location.href=e:location=e,o=null},u.readAsDataURL(e)}else{var d=a.URL||a.webkitURL,v=d.createObjectURL(e);o?o.location=v:location.href=v,o=null,setTimeout((function(){d.revokeObjectURL(v)}),4e4)}});a.saveAs=l.saveAs=l,e.exports=l},void 0===(i="function"===typeof r?r.apply(n,o):r)||(e.exports=i)},25768:function(e,n){"use strict";n.Z={src:"/_next/static/media/chat.ea4050e5.svg",height:30,width:30}},60423:function(e,n){"use strict";n.Z={src:"/_next/static/media/phone.ee988c33.svg",height:30,width:30}},59395:function(e,n){"use strict";n.Z={src:"/_next/static/media/video-off.359fdf5a.svg",height:30,width:30}},11497:function(e,n){"use strict";n.Z={src:"/_next/static/media/video-on.7ef29d9a.svg",height:30,width:30}},69537:function(e,n,t){"use strict";t.d(n,{Z:function(){return Ge}});var r=t(34051),o=t.n(r),i=t(85893),a=t(25675),s=t.n(a),l=t(47166),c=t.n(l),u=t(32998),d=t.n(u),v=t(11163),f=t(51436),m=t(35005),p=t(62599),h=t(9473),g=t(67814),b=t(67294),x=t(34377),y=t(76881),j=t(64660),w=t(85020),k=t(6212),_=t(73192),N=t(68923),S=t(93162),C=t(61426);function I(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function O(e,n,t,r,o,i,a){try{var s=e[i](a),l=s.value}catch(c){return void t(c)}s.done?n(l):Promise.resolve(l).then(r,o)}function E(e){return function(){var n=this,t=arguments;return new Promise((function(r,o){var i=e.apply(n,t);function a(e){O(i,r,o,a,s,"next",e)}function s(e){O(i,r,o,a,s,"throw",e)}a(void 0)}))}}function P(e){return function(e){if(Array.isArray(e))return I(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,n){if(!e)return;if("string"===typeof e)return I(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return I(e,n)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var F=function(){var e=c().bind(d()),n=new C.fA({apiKey:"AQ.Ab8RN6IiuxyKVyYNtavTXpUJWuxACsUU5w-qRsE9vUbeAowQpQ"}),t=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.healthRecord)||void 0===n?void 0:n.statementsData})),r=(0,b.useState)([]),a=r[0],s=r[1],l=(0,b.useState)(!1),u=l[0],v=l[1],f=(0,b.useState)(""),m=f[0],p=f[1],g=(0,b.useState)(!1),x=g[0],y=g[1],j=(0,b.useState)(null),w=j[0],k=j[1];(0,b.useEffect)((function(){var e=function(){var e=E(o().mark((function e(){var n,t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch("https://aimtest-s3-bucket.s3.ap-northeast-1.amazonaws.com/Chatbot-Questions/chatbot-questions.json");case 3:return n=e.sent,e.next=6,n.json();case 6:t=e.sent,k(t),e.next=13;break;case 10:e.prev=10,e.t0=e.catch(0),console.error("Error fetching question data:",e.t0);case 13:case"end":return e.stop()}}),e,null,[[0,10]])})));return function(){return e.apply(this,arguments)}}();e()}),[]);var _=function(e){return e.toLowerCase().replace(/[^\w\s]/g,"").split(/\s+/).sort()},N=function(e,n){return n.filter((function(n){return e.includes(n)})).length/n.length>=.6},S=function(e,n){var t=n.questions,r=_(e),o=!0,i=!1,a=void 0;try{for(var s,l=t[Symbol.iterator]();!(o=(s=l.next()).done);o=!0){var c=s.value,u=!0,d=!1,v=void 0;try{for(var f,m=c.keywords[Symbol.iterator]();!(u=(f=m.next()).done);u=!0){var p=f.value,h=_(p);if(N(r,h))return c.answer}}catch(g){d=!0,v=g}finally{try{u||null==m.return||m.return()}finally{if(d)throw v}}}}catch(g){i=!0,a=g}finally{try{o||null==l.return||l.return()}finally{if(i)throw a}}return!1},I=function(){var e=E(o().mark((function e(t){var r,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,n.models.generateContent({model:"gemini-flash-lite-latest",contents:[{role:"user",parts:[{text:t}]}]});case 3:return r=e.sent,e.next=6,r.text;case 6:return i=e.sent,o=(o=(o=(o=i||"").replace(/\*\*([^\*]+)\*\*/g,"<b>$1</b>")).replace(/^\*\s+([^\n]+)/gm,"<ul><li>$1</li></ul>")).replace(/\n/g,"<br>"),a=o="<p>".concat(o,"</p>"),e.abrupt("return",a);case 11:return e.prev=11,e.t0=e.catch(0),console.error("Error:",e.t0),e.abrupt("return","Something went wrong. Please try again!");case 15:case"end":return e.stop()}var o}),e,null,[[0,11]])})));return function(n){return e.apply(this,arguments)}}(),O=function(){var e=E(o().mark((function e(n){var t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:s((function(e){return P(e).concat([{id:Date.now(),text:n,user:"Me",createdAt:new Date}])})),w&&((t=S(n,w))?(s((function(e){return P(e).concat([{id:Date.now(),text:t,user:"GPT",createdAt:new Date}])})),y(!1)):(y(!0),p("".concat(n,","))));case 2:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}(),F=function(){var e=E(o().mark((function e(n){var r,i,a;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return v(!0),r=t[n],i="",("problems"===n||"reason"===n||"solution"===n)&&(i="".concat(m.concat(" ",r))),e.next=6,I(i);case 6:a=e.sent,s((function(e){return P(e).concat([{id:Date.now(),text:a,user:"GPT",createdAt:new Date}])})),v(!1);case 9:case"end":return e.stop()}}),e)})));return function(n){return e.apply(this,arguments)}}();return(0,i.jsx)("div",{className:e("gemini-container"),children:(0,i.jsxs)("div",{className:e("gemini-chatbox"),children:[null===a||void 0===a?void 0:a.map((function(n){return(0,i.jsx)("div",{className:"Me"===n.user?e("userMessage"):e("gptMessage"),children:"GPT"===n.user?(0,i.jsx)("span",{dangerouslySetInnerHTML:{__html:n.text}}):(0,i.jsx)("span",{children:n.text})},n.id)})),u&&(0,i.jsx)("div",{className:e("capsules"),children:(0,i.jsx)("span",{children:"Loading..."})}),x&&(0,i.jsxs)("div",{className:e("capsules"),children:[(0,i.jsx)("button",{onClick:function(){return F("problems")},children:"Problems"}),(0,i.jsx)("button",{onClick:function(){return F("reason")},children:"Reason"}),(0,i.jsx)("button",{onClick:function(){return F("solution")},children:"Solution"})]}),(0,i.jsx)("div",{className:e("inputBar"),children:(0,i.jsx)("input",{type:"text",placeholder:"What's on your mind?",onKeyDown:function(e){if("Enter"===e.key){var n=e.target,t=n.value.trim();t&&(O(t),n.value="")}}})})]})})}
1,R=t(16978),T=t(68926),D=t(82580),L=t(74231);function A(e,n,t,r,o,i,a){try{var s=e[i](a),l=s.value}catch(c){return void t(c)}s.done?n(l):Promise.resolve(l).then(r,o)}var M=function(e){var n=e.personalUserId,t=e.token,r=(0,h.I0)(),a=(0,b.useState)(null),s=a[0],l=a[1],c=(0,b.useState)(!1),u=c[0],d=c[1],v=(0,b.useState)(null),f=v[0],m=v[1],p=(0,b.useState)({}),g=p[0],j=p[1],w=(0,b.useState)(!1),k=w[0],_=w[1],N=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.healthRecord)||void 0===n?void 0:n.selectedBmiData}));(0,b.useEffect)((function(){var e=function(){var e,r=(e=o().mark((function e(){var r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,x.qK)(t,n);case 3:r=e.sent,j(r),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.warn("Error while Generate Report:",e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})),function(){var n=this,t=arguments;return new Promise((function(r,o){var i=e.apply(n,t);function a(e){A(i,r,o,a,s,"next",e)}function s(e){A(i,r,o,a,s,"throw",e)}a(void 0)}))});return function(){return r.apply(this,arguments)}}();e()}),[]);var S={age:"",gender:"",height:"",weight:""};(0,b.useEffect)((function(){N&&(null===N||void 0===N?void 0:N.userName)===n?(S.age=N.age,S.gender=N.gender,S.height=N.height,S.weight=N.weight):n===(null===g||void 0===g?void 0:g.userId)&&(S.age=String(g.age),S.gender=g.gender,S.height=String(g.height),S.weight=String(g.weight))}),[N,g]);var C=function(){d(!0),l(null),m(null),_(!1),d(!1)},I=function(e,t){r((0,y.xY)({field:e,value:t,personalUserId:n}))};return(0,i.jsxs)("div",{className:"bmi-calculator container",children:[(0,i.jsx)(D.J9,{initialValues:S,validationSchema:L.Ry({age:L.Rx().required("Age is required").typeError("Age must be a number").positive("Age must be a positive number").integer("Age must be an integer").max(120,"Age must be less than or equal to 120").min(1,"Age must be greater than 0"),gender:L.Z_().required("Gender is required"),height:L.Rx().required("Height is required").positive(),weight:L.Rx().required("Weight is required").positive()}),onSubmit:function(e){if(""!==e.age&&""!==e.gender&&""!==e.height&&""!==e.weight){d(!0);var o=e.height/100,i=e.weight/(o*o);l(i.toFixed(2));var a=function(e){return e<18.5?{category:"Underweight",risk:"Increased",color:"#FFD700"}:e<25?{category:"Normal",risk:"Least",color:"#32CD32"}:e<30?{category:"Overweight",risk:"Increased",color:"#FFD700"}:e<35?{category:"Obese Class I",risk:"High",color:"#FF6347"}:e<40?{category:"Obese Class II",risk:"Very high",color:"#FF4500"}:{category:"Obese Class III",risk:"Extremely high",color:"#B22222"}}(i);m(a);var s={age:parseInt(e.age),gender:e.gender,height:parseInt(e.height),weight:parseInt(e.weight),userId:n,calculatedBmi:i.toFixed(2),unit:"kg/m\xb2",overAllRemark:a.category};r((0,x.mG)(s,t,d)),_(!0)}else d(!1),(0,T.Z)(R.Kp,"All fields are required.")},children:function(){return(0,i.jsxs)(D.l0,{children:[(0,i.jsxs)("div",{className:"form-group-box mb-3",children:[(0,i.jsx)("label",{htmlFor:"age",className:"form-label",children:"Age:"}),(0,i.jsx)(D.gN,{name:"age",type:"number",className:"form-control",id:"age",placeholder:"Enter Age",onBlur:function(e){return I(e.target.name,e.target.value)}}),(0,i.jsx)(D.Bc,{name:"age",component:"div",className:"text-danger"})]}),(0,i.jsxs)("div",{className:"form-group-box mb-3",children:[(0,i.jsx)("label",{className:"form-label",children:"Gender:"}),(0,i.jsxs)("div",{className:"pt-2 d-flex gap-5",children:[(0,i.jsxs)("div",{className:"d-flex align-items-center",children:[(0,i.jsx)(D.gN,{type:"radio",name:"gender",value:"male",className:"form-check-input",id:"gender-male",onBlur:function(e){return I(e.target.name,e.target.value)}}),(0,i.jsx)("label",{htmlFor:"gender-male",className:"form-check-label",children:"Male"})]}),(0,i.jsxs)("div",{className:"d-flex align-items-center",children:[(0,i.jsx)(D.gN,{type:"radio",name:"gender",value:"female",className:"form-check-input ml-3",id:"gender-female",onBlur:function(e){return I(e.target.name,e.target.value)}}),(0,i.jsx)("label",{htmlFor:"gender-female",className:"form-check-label",children:"Female"})]})]}),(0,i.jsx)(D.Bc,{name:"gender",component:"div",className:"text-danger"})]}),(0,i.jsxs)("div",{className:"form-group-box mb-3",children:[(0,i.jsx)("label",{htmlFor:"height",className:"form-label",children:"Height (cm):"}),(0,i.jsx)(D.gN,{name:"height",type:"number",className:"form-control",id:"height",placeholder:"Enter Height (cm)",onBlur:function(e){return I(e.target.name,e.target.value)}}),(0,i.jsx)(D.Bc,{name:"height",component:"div",className:"text-danger"})]}),(0,i.jsxs)("div",{className:"form-group-box mb-3",children:[(0,i.jsx)("label",{htmlFor:"weight",className:"form-label",children:"Weight (kg):"}),(0,i.jsx)(D.gN,{name:"weight",type:"number",className:"form-control",id:"weight",placeholder:"Enter Weight (kg)",onBlur:function(e){return I(e.target.name,e.target.value)}}),(0,i.jsx)(D.Bc,{name:"weight",component:"div",className:"text-danger"})]}),(0,i.jsxs)("div",{className:"d-flex justify-content-center my-4 gap-3",children:[(0,i.jsx)("button",{type:"submit",className:"btn btn-primary",disabled:u,children:u?"Calculating...":k?"Re-calculate":"Calculate"}),k&&(0,i.jsx)("button",{onClick:C,className:"btn btn-secondary",children:"Reset"})]})]})}}),s&&f&&(0,i.jsxs)("div",{className:"bmi-result",style:{background:f.color,fontWeight:"bold"},children:[(0,i.jsxs)("p",{children:["BMI = ",s," kg/m\xb2"]}),(0,i.jsxs)("p",{children:["(",f.category," - ",f.risk," risk)"]})]})]})};function q(e,n,t,r,o,i,a){try{var s=e[i](a),l=s.value}catch(c){return void t(c)}s.done?n(l):Promise.resolve(l).then(r,o)}function U(e){return function(){var n=this,t=arguments;return new Promise((function(r,o){var i=e.apply(n,t);function a(e){q(i,r,o,a,s,"next",e)}function s(e){q(i,r,o,a,s,"throw",e)}a(void 0)}))}}function B(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var Z=function(e){var n,t=e.personalUserId,r=e.token,a=(0,h.I0)(),s=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.healthRecord)||void 0===n?void 0:n.dietRoutineData})),l=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.healthRecord)||void 0===n?void 0:n.selectedDietData})),c=null===(n=null===s||void 0===s?void 0:s.find((function(e){return"Diet Questions"===e.title})))||void 0===n?void 0:n.questions,u=(0,b.useState)({}),d=u[0],v=u[1],f=(0,b.useState)(null),m=f[0],p=f[1],g=(0,b.useState)(""),j=g[0],w=g[1],k=(0,b.useState)(!1),_=k[0],N=k[1],S=(0,b.useState)({}),C=S[0],I=S[1],O=function(e,n){v((function(t){return function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){B(e,n,t[n])}))}return e}({},t,B({},e,n))}
1)),a((0,y.sV)({questionIndex:e,option:n,personalUserId:t}))};(0,b.useEffect)((function(){var e=function(){var e=U(o().mark((function e(){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,x.i5)(r,t);case 3:n=e.sent,I(n.dietData),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.warn("Error while Generate Report:",e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}();e()}),[]),(0,b.useEffect)((function(){l&&(null===l||void 0===l?void 0:l.userName)===t?v(l.data):t===(null===C||void 0===C?void 0:C.userName)?v(C.answers):v({})}),[l,t,C]);var E=b.useCallback((function(){var e;if(null===(e=Object.keys(d))||void 0===e?void 0:e.length){var n,t=Object.values(d).reduce((function(e,n){return e+parseFloat(n.percentage)}),0)/(null===c||void 0===c?void 0:c.length)||0;return p(t),t>=0&&t<=30?n="Very Poor Diet":t>=31&&t<=55?n="Poor Diet":t>=56&&t<=70?n="Unhealthy Diet":t>=71&&t<=85?n="Good Diet":t>=86&&t<=100&&(n="Excellent Diet"),w(n),{avgPercentage:t,remarkTitle:n}}}),[d,c]),P=b.useCallback(U(o().mark((function e(){var n,i,s,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(N(!0),null===(n=Object.keys(d))||void 0===n?void 0:n.length){e.next=6;break}return N(!1),(0,T.Z)(R.Kp,"Please select an answer for all questions."),e.abrupt("return");case 6:try{i=E(),s=Number(i.avgPercentage).toFixed(2),l={userName:t,answers:d,score:Number(s),overAllRemark:i.remarkTitle},a((0,x.xQ)(l,r,N))}catch(o){N(!1),console.error(o)}case 7:case"end":return e.stop()}}),e)}))),[d,t,r,E]);return(0,i.jsxs)("div",{className:"container my-4",children:[(0,i.jsx)("div",{className:"list-group",children:null===c||void 0===c?void 0:c.map((function(e,n){return(0,i.jsxs)("div",{className:"list-group-item",children:[(0,i.jsxs)("h5",{children:[n+1,". ",e.question]}),(t=e.options,r=n,null===t||void 0===t?void 0:t.map((function(e,n){var t,o;return(0,i.jsxs)("div",{className:"form-check ".concat((null===(t=d[r])||void 0===t?void 0:t.option)===e.option?"bg-primary text-white":""),children:[(0,i.jsx)("input",{className:"form-check-input",type:"radio",name:"question-diet".concat(r),id:"question-".concat(r,"-option-diet").concat(n),value:e.option,checked:(null===(o=d[r])||void 0===o?void 0:o.option)===e.option,onChange:function(){return O(r,e)}}),(0,i.jsx)("label",{className:"form-check-label",htmlFor:"question-".concat(r,"-option-diet").concat(n),children:e.option})]},n)})))]},n);var t,r}))}),(0,i.jsx)("div",{className:"d-flex justify-content-center my-4",children:(0,i.jsx)("button",{className:"btn btn-primary",onClick:P,disabled:_,children:_?"Submitting...":"Submit"})}),m&&(0,i.jsxs)("div",{className:"text-center",children:[(0,i.jsx)("p",{children:(0,i.jsxs)("strong",{children:["Score: ",m.toFixed(2),"%"]})}),(0,i.jsx)("p",{children:(0,i.jsxs)("strong",{children:["Remark: ",j]})})]})]})};function H(e,n,t,r,o,i,a){try{var s=e[i](a),l=s.value}catch(c){return void t(c)}s.done?n(l):Promise.resolve(l).then(r,o)}function G(e){return function(){var n=this,t=arguments;return new Promise((function(r,o){var i=e.apply(n,t);function a(e){H(i,r,o,a,s,"next",e)}function s(e){H(i,r,o,a,s,"throw",e)}a(void 0)}))}}function V(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var W=function(e){var n,t=e.personalUserId,r=e.token,a=(0,h.I0)(),s=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.healthRecord)||void 0===n?void 0:n.dietRoutineData})),l=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.healthRecord)||void 0===n?void 0:n.selectedADHDData})),c=null===(n=null===s||void 0===s?void 0:s.find((function(e){return"ADHD"===e.title})))||void 0===n?void 0:n.questions,u=(0,b.useState)({}),d=u[0],v=u[1],f=(0,b.useState)(null),m=f[0],p=f[1],g=(0,b.useState)(""),j=g[0],w=g[1],k=(0,b.useState)(!1),_=k[0],N=k[1],S=(0,b.useState)({}),C=S[0],I=S[1],O=function(e,n){v((function(t){return function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}
1)))),r.forEach((function(n){V(e,n,t[n])}))}return e}({},t,V({},e,n))})),a((0,y.rt)({questionIndex:e,option:n,personalUserId:t}))};(0,b.useEffect)((function(){var e=function(){var e=G(o().mark((function e(){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,x.i5)(r,t);case 3:n=e.sent,I(n.adhdData),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.warn("Error while Generate Report:",e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}();e()}),[]),(0,b.useEffect)((function(){l&&(null===l||void 0===l?void 0:l.userName)===t?v(null===l||void 0===l?void 0:l.data):t===(null===C||void 0===C?void 0:C.userName)?v(C.answers):v({})}),[l,t,C]);var E=function(){var e;if(null===(e=Object.keys(d))||void 0===e?void 0:e.length){var n,t=Object.values(d).reduce((function(e,n){return e+parseFloat(n.percentage)}),0)/(null===c||void 0===c?void 0:c.length)||0;return p(t),t>=25&&t<50?n="No significant symptoms of ADHD":t>=50&&t<75?n="Mild symptoms of ADHD":t>=75&&t<90?n="Moderate symptoms of ADHD":t>=90&&t<=100&&(n="Severe symptoms of ADHD"),w(n),{avgPercentage:t,remarkTitle:n}}},P=function(){var e=G(o().mark((function e(){var n,i,s,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(N(!0),null===(n=Object.keys(d))||void 0===n?void 0:n.length){e.next=6;break}return N(!1),(0,T.Z)(R.Kp,"Please select an answer for all questions."),e.abrupt("return");case 6:try{i=E(),s=Number(i.avgPercentage).toFixed(2),l={userName:t,answers:d,score:Number(s),overAllRemark:i.remarkTitle},N(!1),a((0,x.zZ)(l,r,N))}catch(o){N(!1),console.error(o)}case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return(0,i.jsxs)("div",{className:"container my-4",children:[(0,i.jsx)("div",{className:"list-group",children:null===c||void 0===c?void 0:c.map((function(e,n){return(0,i.jsxs)("div",{className:"list-group-item",children:[(0,i.jsxs)("h5",{children:[n+1,". ",e.question]}),(t=e.options,r=n,null===t||void 0===t?void 0:t.map((function(e,n){var t,o;return(0,i.jsxs)("div",{className:"form-check ".concat((null===(t=d[r])||void 0===t?void 0:t.option)===e.option?"bg-primary text-white":""),children:[(0,i.jsx)("input",{className:"form-check-input",type:"radio",name:"question-adsd".concat(r),id:"question-".concat(r,"-option-adsd").concat(n),value:e.option,checked:(null===(o=d[r])||void 0===o?void 0:o.option)===e.option,onChange:function(){return O(r,e)}}),(0,i.jsx)("label",{className:"form-check-label",htmlFor:"question-".concat(r,"-option-adsd").concat(n),children:e.option})]},n)})))]},n);var t,r}))}),(0,i.jsx)("div",{className:"d-flex justify-content-center my-4",children:(0,i.jsx)("button",{className:"btn btn-primary",onClick:P,disabled:_,children:_?"Submitting...":"Submit"})}),m&&(0,i.jsxs)("div",{className:"text-center",children:[(0,i.jsx)("p",{children:(0,i.jsxs)("strong",{children:["Score: ",m.toFixed(2),"%"]})}),(0,i.jsx)("p",{children:(0,i.jsxs)("strong",{children:["Remark: ",j]})})]})]})};function K(e,n,t,r,o,i,a){try{var s=e[i](a),l=s.value}catch(c){return void t(c)}s.done?n(l):Promise.resolve(l).then(r,o)}function J(e){return function(){var n=this,t=arguments;return new Promise((function(r,o){var i=e.apply(n,t);function a(e){K(i,r,o,a,s,"next",e)}function s(e){K(i,r,o,a,s,"throw",e)}a(void 0)}))}}function z(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var Q=function(e){var n,t=e.personalUserId,r=e.token,a=(0,h.I0)(),s=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.healthRecord)||void 0===n?void 0:n.dietRoutineData})),l=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.healthRecord)||void 0===n?void 0:n.selectedBreathData})),c=null===(n=null===s||void 0===s?void 0:s.find((function(e){return"Breathing Questions"===e.title})))||void 0===n?void 0:n.questions,u=(0,b.useState)({}),d=u[0],v=u[1],f=(0,b.useState)(null),m=f[0],p=f[1],g=(0,b.useState)(""),j=g[0],w=g[1],k=(0,b.useState)(!1),_=k[0],N=k[1],S=(0,b.useState)({}),C=S[0],I=S[1],O=function(e,n){v((function(t){return function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){z(e,n,t[n])}))}return e}({},t,z({},e,n))}
1)),a((0,y.i7)({questionIndex:e,option:n,personalUserId:t}))};(0,b.useEffect)((function(){var e=function(){var e=J(o().mark((function e(){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,x.i5)(r,t);case 3:n=e.sent,I(n.breathingData),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.warn("Error while Generate Report:",e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}();e()}),[]),(0,b.useEffect)((function(){l&&(null===l||void 0===l?void 0:l.userName)===t?v(l.data):t===(null===C||void 0===C?void 0:C.userName)?v(C.answers):v({})}),[l,t,C]);var E=b.useCallback((function(){var e;if(null===(e=Object.keys(d))||void 0===e?void 0:e.length){var n,t=Object.values(d).reduce((function(e,n){return e+parseFloat(n.percentage)}),0)/(null===c||void 0===c?void 0:c.length)||0;return p(t),t>=0&&t<=30?n="Very Poor Breath Habits":t>=31&&t<=55?n="Poor Breath Habits":t>=56&&t<=70?n="Unhealthy Breath Habits":t>=71&&t<=85?n="Good Breath Habits":t>=86&&t<=100&&(n="Excellent Breath Habits"),w(n),{avgPercentage:t,remarkTitle:n}}}),[d,c]),P=b.useCallback(J(o().mark((function e(){var n,i,s,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(N(!0),null===(n=Object.keys(d))||void 0===n?void 0:n.length){e.next=6;break}return N(!1),(0,T.Z)(R.Kp,"Please select an answer for all questions."),e.abrupt("return");case 6:try{i=E(),s=Number(i.avgPercentage).toFixed(2),l={userName:t,answers:d,score:Number(s),overAllRemark:i.remarkTitle},a((0,x.IX)(l,r,N))}catch(o){N(!1),console.error(o)}case 7:case"end":return e.stop()}}),e)}))),[d,t,r,E]);return(0,i.jsxs)("div",{className:"container my-4",children:[(0,i.jsx)("div",{className:"list-group",children:null===c||void 0===c?void 0:c.map((function(e,n){return(0,i.jsxs)("div",{className:"list-group-item",children:[(0,i.jsxs)("h5",{children:[String.fromCharCode(65+n),". "]}),(0,i.jsx)("ul",{style:{listStyleType:"none",paddingLeft:"0"},children:e.question.split("\n").map((function(e,n){return(0,i.jsx)("li",{children:e},n)}))}),(0,i.jsx)("br",{}),(t=e.options,r=n,null===t||void 0===t?void 0:t.map((function(e,n){var t,o;return(0,i.jsxs)("div",{className:"form-check ".concat((null===(t=d[r])||void 0===t?void 0:t.option)===e.option?"bg-primary text-white":""),children:[(0,i.jsx)("input",{className:"form-check-input",type:"radio",name:"question-breath".concat(r),id:"question-".concat(r,"-option-breath").concat(n),value:e.option,checked:(null===(o=d[r])||void 0===o?void 0:o.option)===e.option,onChange:function(){return O(r,e)}}),(0,i.jsxs)("label",{className:"form-check-label",htmlFor:"question-".concat(r,"-option-breath").concat(n),children:["- ",e.option]})]},n)})))]},n);var t,r}))}),(0,i.jsx)("div",{className:"d-flex justify-content-center my-4",children:(0,i.jsx)("button",{className:"btn btn-primary",onClick:P,disabled:_,children:_?"Submitting...":"Submit"})}),m&&(0,i.jsxs)("div",{className:"text-center",children:[(0,i.jsx)("p",{children:(0,i.jsxs)("strong",{children:["Score: ",m.toFixed(2),"%"]})}),(0,i.jsx)("p",{children:(0,i.jsxs)("strong",{children:["Remark: ",j]})})]})]})};function X(e,n,t,r,o,i,a){try{var s=e[i](a),l=s.value}catch(c){return void t(c)}s.done?n(l):Promise.resolve(l).then(r,o)}function $(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var Y=function(e){var n,t=e.personalUserId,r=e.token,a=(0,h.I0)(),s=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.healthRecord)||void 0===n?void 0:n.dietRoutineData})),l=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.healthRecord)||void 0===n?void 0:n.selectedRoutineData})),c=null===(n=null===s||void 0===s?void 0:s.find((function(e){return"Routine Questions"===e.title})))||void 0===n?void 0:n.questions,u=(0,b.useState)({}),d=u[0],v=u[1],f=(0,b.useState)(null),m=f[0],p=f[1],g=(0,b.useState)(""),j=g[0],w=g[1],k=(0,b.useState)(!1),_=k[0],N=k[1],S=(0,b.useState)({}),C=S[0],I=S[1];(0,b.useEffect)((function(){var e=function(){var e,n=(e=o().mark((function e(){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,x.i5)(r,t);case 3:n=e.sent,I(n.routineData),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.warn("Error while Generate Report:",e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})),function(){var n=this,t=arguments;return new Promise((function(r,o){var i=e.apply(n,t);function a(e){X(i,r,o,a,s,"next",e)}function s(e){X(i,r,o,a,s,"throw",e)}a(void 0)}))});return function(){return n.apply(this,arguments)}}();e()}),[]),(0,b.useEffect)((function(){l&&(null===l||void 0===l?void 0:l.userName)===t?v(null===l||void 0===l?void 0:l.data):t===(null===C||void 0===C?void 0:C.userName)?v(C.answers):v({})}),[l,t,C]);var O=function(e,n){v((function(t){return function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){$(e,n,t[n])}))}return e}({},t,$({},e,n))}
1)),a((0,y.LZ)({questionIndex:e,option:n,personalUserId:t}))};return(0,i.jsxs)("div",{className:"container my-4",children:[(0,i.jsx)("div",{className:"list-group",children:null===c||void 0===c?void 0:c.map((function(e,n){return(0,i.jsxs)("div",{className:"list-group-item",children:[(0,i.jsxs)("h5",{children:[n+1,". ",e.question]}),(t=e.options,r=n,null===t||void 0===t?void 0:t.map((function(e,n){var t,o;return(0,i.jsxs)("div",{className:"form-check ".concat((null===(t=d[r])||void 0===t?void 0:t.option)===e.option?"bg-primary text-white":""),children:[(0,i.jsx)("input",{className:"form-check-input",type:"radio",name:"question-routine".concat(r),id:"question-".concat(r,"-option-routine").concat(n),value:e.option,checked:(null===(o=d[r])||void 0===o?void 0:o.option)===e.option,onChange:function(){return O(r,e)}}),(0,i.jsx)("label",{className:"form-check-label",htmlFor:"question-".concat(r,"-option-routine").concat(n),children:e.option})]},n)})))]},n);var t,r}))}),(0,i.jsx)("div",{className:"d-flex justify-content-center my-4",children:(0,i.jsx)("button",{className:"btn btn-primary",onClick:function(){if(N(!0),!Object.keys(d).length)return N(!1),void(0,T.Z)(R.Kp,"Please select an answer for all questions.");try{var e=function(){var e;if(null===(e=Object.keys(d))||void 0===e?void 0:e.length){var n,t=Object.values(d).reduce((function(e,n){return e+parseFloat(n.percentage)}),0)/(null===c||void 0===c?void 0:c.length)||0;return p(t),t>=0&&t<=10?n="Unacceptable Routine Habits":t>10&&t<=20?n="Inadequate Routine Habits":t>20&&t<=30?n="Subpar Routine Habits":t>30&&t<=40?n="Mediocre Routine Habits":t>40&&t<=50?n="Inefficient Routine Habits":t>50&&t<=60?n="Unsatisfactory Routine Habits":t>60&&t<=70?n="Satisfactory Routine Habits":t>70&&t<=80?n="Commendable Routine Habits":t>80&&t<=90?n="Meritorious Routine Habits":t>90&&t<=100&&(n="Exceptional Routine Habits"),w(n),{avgPercentage:t,remarkTitle:n}}}(),n=Number(e.avgPercentage).toFixed(2),o={userName:t,answers:d,score:Number(n),overAllRemark:e.remarkTitle};a((0,x.Ys)(o,r,N))}catch(i){N(!1),console.error("Error submitting data:",i)}},disabled:_,children:_?"Submitting...":"Submit"})}),m&&(0,i.jsxs)("div",{className:"text-center",children:[(0,i.jsx)("p",{children:(0,i.jsxs)("strong",{children:["Score: ",m.toFixed(2),"%"]})}),(0,i.jsx)("p",{children:(0,i.jsxs)("strong",{children:["Remark: ",j]})})]})]})};function ee(e,n,t,r,o,i,a){try{var s=e[i](a),l=s.value}catch(c){return void t(c)}s.done?n(l):Promise.resolve(l).then(r,o)}function ne(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}var te=function(e){var n,t=e.personalUserId,r=e.token,a=(0,h.I0)(),s=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.healthRecord)||void 0===n?void 0:n.dietRoutineData})),l=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.healthRecord)||void 0===n?void 0:n.selectedSleepData})),c=null===(n=null===s||void 0===s?void 0:s.find((function(e){return"Sleep Questions"===e.title})))||void 0===n?void 0:n.questions,u=(0,b.useState)({}),d=u[0],v=u[1],f=(0,b.useState)(null),m=f[0],p=f[1],g=(0,b.useState)(""),j=g[0],w=g[1],k=(0,b.useState)(!1),_=k[0],N=k[1],S=(0,b.useState)({}),C=S[0],I=S[1];(0,b.useEffect)((function(){var e=function(){var e,n=(e=o().mark((function e(){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,x.i5)(r,t);case 3:n=e.sent,I(n.sleepData),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.warn("Error while Generate Report:",e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})),function(){var n=this,t=arguments;return new Promise((function(r,o){var i=e.apply(n,t);function a(e){ee(i,r,o,a,s,"next",e)}function s(e){ee(i,r,o,a,s,"throw",e)}a(void 0)}))});return function(){return n.apply(this,arguments)}}();e()}),[]),(0,b.useEffect)((function(){l&&(null===l||void 0===l?void 0:l.userName)===t?v(null===l||void 0===l?void 0:l.data):t===(null===C||void 0===C?void 0:C.userName)?v(C.answers):v({})}),[l,t,C]);var O=function(e,n){v((function(t){return function(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){ne(e,n,t[n])}))}return e}({},t,ne({},e,n))}
1)),a((0,y.mD)({questionIndex:e,option:n,personalUserId:t}))};return(0,i.jsxs)("div",{className:"container my-4",children:[(0,i.jsx)("div",{className:"list-group",children:null===c||void 0===c?void 0:c.map((function(e,n){return(0,i.jsxs)("div",{className:"list-group-item",children:[(0,i.jsxs)("h5",{children:[n+1,". ",e.question]}),(t=e.options,r=n,null===t||void 0===t?void 0:t.map((function(e,n){var t,o;return(0,i.jsxs)("div",{className:"form-check ".concat((null===(t=d[r])||void 0===t?void 0:t.option)===e.option?"bg-primary text-white":""),children:[(0,i.jsx)("input",{className:"form-check-input",type:"radio",name:"question-sleep".concat(r),id:"question-".concat(r,"-option-sleep").concat(n),value:e.option,checked:(null===(o=d[r])||void 0===o?void 0:o.option)===e.option,onChange:function(){return O(r,e)}}),(0,i.jsx)("label",{className:"form-check-label",htmlFor:"question-".concat(r,"-option-sleep").concat(n),children:e.option})]},n)})))]},n);var t,r}))}),(0,i.jsx)("div",{className:"d-flex justify-content-center my-4",children:(0,i.jsx)("button",{className:"btn btn-primary",onClick:function(){if(N(!0),!Object.keys(d).length)return N(!1),void(0,T.Z)(R.Kp,"Please select an answer for all questions.");try{var e=function(){var e;if(null===(e=Object.keys(d))||void 0===e?void 0:e.length){var n,t=Object.values(d).reduce((function(e,n){return e+parseFloat(n.percentage)}),0)/(null===c||void 0===c?void 0:c.length)||0;return p(t),t>=0&&t<=30?n="Very Poor Sleep":t>=31&&t<=55?n="Poor Sleep":t>=56&&t<=70?n="Unhealthy Sleep":t>=71&&t<=85?n="Good Sleep":t>=86&&t<=100&&(n="Excellent Sleep"),w(n),{avgPercentage:t,remarkTitle:n}}}(),n=Number(e.avgPercentage).toFixed(2),o={userName:t,answers:d,score:Number(n),overAllRemark:e.remarkTitle};a((0,x.WA)(o,r,N))}catch(i){N(!1),console.error("Error submitting data:",i)}},disabled:_,children:_?"Submitting...":"Submit"})}),m&&(0,i.jsxs)("div",{className:"text-center",children:[(0,i.jsx)("p",{children:(0,i.jsxs)("strong",{children:["Score: ",m.toFixed(2),"%"]})}),(0,i.jsx)("p",{children:(0,i.jsxs)("strong",{children:["Remark: ",j]})})]})]})},re=t(93881);function oe(e,n,t,r,o,i,a){try{var s=e[i](a),l=s.value}catch(c){return void t(c)}s.done?n(l):Promise.resolve(l).then(r,o)}function ie(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function ae(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){ie(e,n,t[n])}))}return e}var se=function(e){var n,t,r,a=e.data,s=e.personalUserId,l=(0,h.I0)(),c=(0,h.v9)((function(e){return null===e||void 0===e?void 0:e.login.loginData})),u=(0,b.useState)(""),d=u[0],v=u[1],f=(0,b.useState)({}),m=f[0],p=f[1],g=(0,b.useState)(!1),y=g[0],j=g[1],w=(0,b.useState)(null),k=w[0],_=w[1],N=(0,b.useState)(""),S=N[0],C=N[1],I=(null===a||void 0===a?void 0:a.subCategories)||[],O=null===I||void 0===I?void 0:I.find((function(e){return(null===e||void 0===e?void 0:e._id)===d}));(0,b.useEffect)((function(){var e;(null===I||void 0===I?void 0:I.length)>0?v(null===(e=I[0])||void 0===e?void 0:e._id):v("");p({}),_(null),C("")}),[null===a||void 0===a?void 0:a._id]),(0,b.useEffect)((function(){var e=function(){var e,n=(e=o().mark((function e(){var n,t,r,i,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c&&s&&(null===a||void 0===a?void 0:a._id)&&d){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=6,(0,x.XL)(c,s,null===a||void 0===a?void 0:a._id,d);case 6:(null===(t=e.sent)||void 0===t||null===(n=t.data)||void 0===n?void 0:n.answers)?(p((null===t||void 0===t||null===(r=t.data)||void 0===r?void 0:r.answers)||{}),_((null===t||void 0===t||null===(i=t.data)||void 0===i?void 0:i.score)||null),C((null===t||void 0===t||null===(l=t.data)||void 0===l?void 0:l.overAllRemark)||"")):(p({}),_(null),C("")),e.next=15;break;case 10:e.prev=10,e.t0=e.catch(2),p({}),_(null),C("");case 15:case"end":return e.stop()}}),e,null,[[2,10]])})),function(){var n=this,t=arguments;return new Promise((function(r,o){var i=e.apply(n,t);function a(e){oe(i,r,o,a,s,"next",e)}function s(e){oe(i,r,o,a,s,"throw",e)}a(void 0)}))});return function(){return n.apply(this,arguments)}}();e()}),[c,s,null===a||void 0===a?void 0:a._id,d]);var E=function(e,n,t){var r="".concat(d,"_").concat(e);p((function(e){return ae({},e,ie({},r,ae({},t,{question:null===n||void 0===n?void 0:n.question,subCategoryId:d,subCategoryTitle:null===O||void 0===O?void 0:O.title})))}))};return(0,i.jsxs)("div",{className:"container my-4",children:[(0,i.jsx)("h2",{className:"mb-4",children:"SubCategory"}),(null===I||void 0===I?void 0:I.length)>0?(0,i.jsx)("div",{className:"d-flex flex-wrap gap-2 mb-4",children:null===I||void 0===I?void 0:I.map((function(e){return(0,i.jsx)("button",{type:"button",onClick:function(){return v(null===e||void 0===e?void 0:e._id)},className:"btn ".concat(d===(null===e||void 0===e?void 0:e._id)?"btn-primary":"btn-outline-primary"),children:null===e||void 0===e?void 0:e.title},null===e||void 0===e?void 0:e._id)}))}):(0,i.jsx)("div",{className:"alert alert-warning",children:"No sub category found"}),(0,i.jsx)("div",{className:"list-group",children:(null===O||void 0===O||null===(n=O.questions)||void 0===n?void 0:n.length)>0?null===O||void 0===O||null===(t=O.questions)||void 0===t?void 0:t.map((function(e,n){var t,r="".concat(d,"_").concat(n);return(0,i.jsxs)("div",{className:"list-group-item",children:[(0,i.jsxs)("h5",{children:[n+1,". ",null===e||void 0===e?void 0:e.question]}),null===e||void 0===e||null===(t=e.options)||void 0===t?void 0:t.map((function(t,o){var a,s;return(0,i.jsxs)("div",{onClick:function(){return E(n,e,t)},className:"form-check ".concat((null===(a=m[r])||void 0===a?void 0:a.option)===(null===t||void 0===t?void 0:t.option)?"bg-primary text-white":""),style:{cursor:"pointer",padding:"10px 12px",borderRadius:"8px",marginBottom:"6px"},children:[(0,i.jsx)("input",{className:"form-check-input",type:"radio",name:"academic-question-".concat(d,"-").concat(n),id:"academic-question-".concat(n,"-option-").concat(o),value:null===t||void 0===t?void 0:t.option,checked:(null===(s=m[r])||void 0===s?void 0:s.option)===(null===t||void 0===t?void 0:t.option),onChange:function(){return E(n,e,t)}}),(0,i.jsx)("label",{className:"form-check-label ms-2",htmlFor:"academic-question-".concat(n,"-option-").concat(o),style:{cursor:"pointer"},children:null===t||void 0===t?void 0:t.option})]},o)}))]},n)})):(0,i.jsx)("div",{className:"alert alert-info",children:"No question found"})}),(null===O||void 0===O||null===(r=O.questions)||void 0===r?void 0:r.length)>0&&(0,i.jsxs)("div",{className:"d-flex justify-content-center gap-3 my-4",children:[(0,i.jsx)("button",{type:"button",className:"btn btn-secondary",onClick:function(){p({}),_(null),C("")},disabled:y,children:"Cancel"}),(0,i.jsx)("button",{type:"button",className:"btn btn-primary",onClick:function(){var e,n,t=(null===O||void 0===O||null===(e=O.questions)||void 0===e?void 0:e.length)||0,r=null===(n=Object.keys(m))||void 0===n?void 0:n.length;if(d)if(r===t){j(!0);var o=function(){var e,n=Object.values(m).reduce((function(e,n){return e+Number((null===n||void 0===n?void 0:n.percentage)||0)}),0),t=(null===O||void 0===O||null===(e=O.questions)||void 0===e?void 0:e.length)||0,r=t>0?n/t:0,o="";return r>=0&&r<=30?o="Very Poor":r>=31&&r<=55?o="Poor":r>=56&&r<=70?o="Average":r>=71&&r<=85?o="Good":r>=86&&r<=100&&(o="Excellent"),_(r),C(o),{avgPercentage:r,remarkTitle:o}}(),i=Number((null===o||void 0===o?void 0:o.avgPercentage)||0).toFixed(2),u={userName:s,categoryId:null===a||void 0===a?void 0:a._id,categoryTitle:null===a||void 0===a?void 0:a.title,subCategoryId:d,subCategoryTitle:null===O||void 0===O?void 0:O.title,answers:m,score:Number(i),overAllRemark:null===o||void 0===o?void 0:o.remarkTitle};console.log("Academic Life Submit Payload:",u),l((0,x.FT)(u,c,j))}else(0,T.Z)(R.Kp,"Please select an answer for all questions.");else(0,T.Z)(R.Kp,"Please select sub category.")},disabled:y,children:y?"Submitting...":"Submit"})]}),null!==k&&(0,i.jsxs)("div",{className:"text-center",children:[(0,i.jsx)("p",{children:(0,i.jsxs)("strong",{children:["Score: ",k.toFixed(2),"%"]})}),(0,i.jsx)("p",{children:(0,i.jsxs)("strong",{children:["Remark: ",S]})})]})]})};function le(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function ce(e,n,t,r,o,i,a){try{var s=e[i](a),l=s.value}catch(c){return void t(c)}s.done?n(l):Promise.resolve(l).then(r,o)}function ue(e){return function(){var n=this,t=arguments;return new Promise((function(r,o){var i=e.apply(n,t);function a(e){ce(i,r,o,a,s,"next",e)}function s(e){ce(i,r,o,a,s,"throw",e)}a(void 0)}))}}function de(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function ve(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){de(e,n,t[n])}))}return e}function fe(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,o,i=[],a=!0,s=!1;try{for(t=t.call(e);!(a=(r=t.next()).done)&&(i.push(r.value),!n||i.length!==n);a=!0);}catch(l){s=!0,o=l}finally{try{a||null==t.return||t.return()}finally{if(s)throw o}}return i}}(e,n)||function(e,n){if(!e)return;if("string"===typeof e)return le(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);"Object"===t&&e.constructor&&(t=e.constructor.name);if("Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return le(e,n)}
1(e,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var me=function(e){var n=e.isModalVisible,t=e.setModalVisible,r=e.personalUserId,a=e.token,s=c().bind(d()),l=(0,b.useState)("BMI"),u=l[0],v=l[1],p=(0,b.useState)(!1),y=p[0],j=p[1],w=(0,b.useState)(!1),C=w[0],I=w[1],O=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.healthRecord)||void 0===n?void 0:n.BMIElementData})),E=function(){var e=ue(o().mark((function e(n){var t,r;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,fetch(n);case 3:if((t=e.sent).ok){e.next=6;break}throw new Error("Failed to fetch the PDF file.");case 6:return e.next=8,t.blob();case 8:r=e.sent,(0,S.saveAs)(r,"sabcq-user-report-".concat(Date.now(),".pdf")),e.next=17;break;case 12:e.prev=12,e.t0=e.catch(0),j(!1),I(!1),(0,T.Z)(R.H8,"Failed to download the file.");case 17:return e.prev=17,j(!1),I(!1),e.finish(17);case 21:case"end":return e.stop()}}),e,null,[[0,12,17,21]])})));return function(n){return e.apply(this,arguments)}}(),P=function(){var e=ue(o().mark((function e(){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r){e.next=3;break}return(0,T.Z)(R.Kp,"User Id Required."),e.abrupt("return");case 3:return j(!0),e.prev=4,e.next=7,(0,x.y0)(a,r);case 7:n=e.sent,E(n.pdfUrl),e.next=15;break;case 11:e.prev=11,e.t0=e.catch(4),j(!1),console.warn("Error while Generate Report:",e.t0);case 15:case"end":return e.stop()}}),e,null,[[4,11]])})));return function(){return e.apply(this,arguments)}}(),D=function(){var e=ue(o().mark((function e(){var n,t,i,s,l,c,u,d;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r){e.next=3;break}return(0,T.Z)(R.Kp,"User Id Required."),e.abrupt("return");case 3:return I(!0),e.prev=4,e.next=7,(0,x.qf)(a,r);case 7:if(!(n=e.sent)){e.next=25;break}return i="Provide solution of below modules on the basis of remark: \n        ".concat(JSON.stringify(n),'\n  \n        Example format for Ui =>\n        BMI\n        1. Remark: Normal\n        2. Solution:\n        \u2022 Maintain a healthy diet and exercise regularly.\n        \u2022 Monitor your weight and make adjustments as needed.\n        \u2022 Consult with a healthcare professional to rule out any underlying medical conditions.\n        \u2022 Get enough sleep and manage stress levels.\n        \u2022 Avoid excessive alcohol consumption and smoking.\n  \n        Example format of response :\n        {\n          "bmiData": {\n            "module": "BMI",\n            "remark": "Normal",\n            "solution": [\n              "\u2022 Maintain a healthy diet and exercise regularly.",\n              "\u2022 Monitor your weight and make adjustments as needed.",\n              "\u2022 Consult with a healthcare professional to rule out any underlying medical conditions.",\n              "\u2022 Get enough sleep and manage stress levels.",\n              "\u2022 Avoid excessive alcohol consumption and smoking.",\n              "\u2022 Stay hydrated throughout the day.",\n              "\u2022 Include strength training in your weekly routine.",\n              "\u2022 Track progress with regular BMI checks.",\n              "\u2022 Prefer whole foods over processed snacks.",\n              "\u2022 Seek medical advice if sudden weight changes occur."\n            ]\n          },\n          "routineData": { "module": "Routine", "remark": "...", "solution": ["\u2022 ..."] },\n          "dietData": { "module": "Diet", "remark": "...", "solution": ["\u2022 ..."] },\n          "breathingData": { "module": "Breath", "remark": "...", "solution": ["\u2022 ..."] },\n          "adhdData": { "module": "ADHD", "remark": "...", "solution": ["\u2022 ..."] },\n          "sleepData": { "module": "Sleep", "remark": "...", "solution": ["\u2022 ..."] }\n        }\n  \n        Important Note: \n        1.Please give response that parse properly with JSON.parse method in javascript.\n        2.Please provide data in formated way like json because i have to sent this data to backend to generate pdf with this data.\n        3.solution MUST be a JSON array of exactly 10 strings (not a single str
1ing). Each string starts with \u2022 \n        4.Make sure bullets are \u2022 this only\n        5.Do not wrap JSON in markdown code fences.\n        6.bmiData, routineData and breathingData are mandatory. Include dietData, adhdData, sleepData only if those modules exist in the input.\n        '),e.next=13,(0,re.m_)(i);case 13:if(!(s=e.sent)||!1===s.success||!(null===(t=Object.keys(s))||void 0===t?void 0:t.length)){e.next=24;break}return l=function(e){return Array.isArray(e)?e.map((function(e){return String(e).trim()})).filter(Boolean):"string"===typeof e?e.split(/\n+/).map((function(e){return e.trim()})).filter(Boolean):[]},c=Object.fromEntries(Object.entries(s).map((function(e){var n=fe(e,2),t=n[0],r=n[1];return[t,r&&"object"===typeof r?ve({},r,{solution:l(r.solution)}):r]}))),u={userName:r,data:c},e.next=20,(0,x._f)(u,a);case 20:d=e.sent,E(d.pdfUrl),e.next=25;break;case 24:(0,T.Z)(R.Kp,"Ai not responding. Please try Again!");case 25:e.next=31;break;case 27:e.prev=27,e.t0=e.catch(4),I(!1),console.warn("Error while Generate Report:",e.t0);case 31:case"end":return e.stop()}}),e,null,[[4,27]])})));return function(){return e.apply(this,arguments)}}();return(0,i.jsxs)(k.Z,{show:n,onHide:function(){return t(!1)},size:"xl","aria-labelledby":"contained-modal-title-vcenter",centered:!0,children:[(0,i.jsx)(k.Z.Header,{children:(0,i.jsxs)("div",{className:s("modal-close"),children:[(0,i.jsxs)("div",{className:s("report-btns"),children:[(0,i.jsx)("div",{children:(0,i.jsx)(k.Z.Title,{id:"contained-modal-title-vcenter",children:(0,i.jsx)("button",{type:"button",className:"btn btn-primary",onClick:function(){P()},children:"".concat(y?"Downloading...":"Get Report")})})}),(0,i.jsx)("div",{children:(0,i.jsx)(k.Z.Title,{id:"contained-modal-title-vcenter",children:(0,i.jsx)("button",{type:"button",className:"btn btn-primary",onClick:function(){D()},children:"".concat(C?"Downloading...":"Get Solution Report")})})})]}),(0,i.jsx)("div",{onClick:function(){return t(!1)},children:(0,i.jsx)(g.G,{icon:f.g82,className:s("cross-icon")})})]})}),(0,i.jsx)(k.Z.Body,{children:(0,i.jsxs)(N.Z,{activeKey:u,onSelect:function(e){e&&v(e)},id:"calculations-tabs",defaultActiveKey:"BMI",className:"mb-3 ".concat(s("calculations-tabs")),variant:"tabs",children:[(0,i.jsx)(_.Z,{eventKey:"BMI",title:"BMI",className:"nav-base",children:(0,i.jsx)(M,{personalUserId:r,token:a})}),(0,i.jsx)(_.Z,{eventKey:"Routine",title:"Routine",children:(0,i.jsx)(Y,{personalUserId:r,token:a})}),(0,i.jsx)(_.Z,{eventKey:"Diet",title:"Diet",children:(0,i.jsx)(Z,{personalUserId:r,token:a})}),(0,i.jsx)(_.Z,{eventKey:"Breath",title:"Breath",children:(0,i.jsx)(Q,{personalUserId:r,token:a})}),(0,i.jsx)(_.Z,{eventKey:"ADHD",title:"ADHD",children:(0,i.jsx)(W,{personalUserId:r,token:a})}),(0,i.jsx)(_.Z,{eventKey:"Sleep",title:"Sleep Cycle",children:(0,i.jsx)(te,{personalUserId:r,token:a})}),null===O||void 0===O?void 0:O.map((function(e){return(0,i.jsx)(_.Z,{eventKey:null===e||void 0===e?void 0:e._id,title:null===e||void 0===e?void 0:e.title,children:(0,i.jsx)(se,{data:e,personalUserId:r})},null===e||void 0===e?void 0:e._id)})),(0,i.jsx)(_.Z,{eventKey:"AI",title:"AI",children:(0,i.jsx)(F,{})})]})}),(0,i.jsx)(k.Z.Footer,{children:(0,i.jsx)(m.Z,{variant:"secondary",onClick:function(){return t(!1)},children:"Close"})})]})},pe=t(26541),he=t(96293),ge=t(11041),be=function(e){var n=(0,v.useRouter)(),t=(0,b.useState)(!0),r=t[0],o=t[1],a=(0,b.useState)(""),s=a[0],l=a[1],c=(0,b.useState)({}),u=c[0],d=c[1],f=(0,b.useState)(!0),m=f[0],p=f[1];(0,b.useEffect)((function(){if(null===e||void 0===e?void 0:e.tempMessages){var n=JSON.parse(null===e||void 0===e?void 0:e.tempMessages);if(r)return;var t=Date.now(),o=null===n||void 0===n?void 0:n.userName,i={body:null===n||void 0===n?void 0:n.msg,tag:t,icon:"https://www.aimqtests.com/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Flogo.171f9ee0.png&w=1080&q=75",lang:"en",dir:"ltr"};m||(l(o),d(i))}}),[e.tempMessages]);return(0,b.useEffect)((function(){var e=function(){p(!document.hidden)};return document.addEventListener("visibilitychange",e),function(){document.removeEventListener("visibilitychange",e)}}),[]),(0,i.jsx)("div",{children:(0,i.jsx)(ge.Z,{ignore:r,notSupported:function(){o(!0)},onPermissionGranted:function(){o(!1)},onPermissionDenied:function(){o(!0)},onClick:function(){window.focus(),n.push("/live/counsellor")},timeout:5e3,title:s,options:u})})},xe=t(25768),ye={src:"/_next/static/media/user.d59ed1f4.svg",height:30,width:30},je=t(60423),we=t(11497),ke=t(59395),_e={src:"/_next/static/media/screen-share.bd21807d.svg",height:24,width:24},Ne={src:"/_next/static/media/student-call.85b56a5a.svg",height:800,width:800},Se={src:"/_next/static/media/calculator.7bca6a58.svg",height:24,width:24},Ce={src:"/_next/static/media/screen-share-off.0277aee4.svg",height:24,width:24};function Ie(e,n){(null==n||n>e.length)&&(n=e.length);for(var t=0,r=new Array(n);t<n;t++)r[t]=e[t];return r}function Oe(e,n,t,r,o,i,a){try{var s=e[i](a),l=s.value}catch(c){return void t(c)}s.done?n(l):Promise.resolve(l).then(r,o)}function Ee(e){return function(){var n=this,t=arguments;return new Promise((function(r,o){var i=e.apply(n,t);function a(e){Oe(i,r,o,a,s,"next",e)}function s(e){Oe(i,r,o,a,s,"throw",e)}a(void 0)}))}}function Pe(e,n,t){return n in e?Object.defineProperty(e,n,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[n]=t,e}function Fe(e){for(var n=1;n<arguments.length;n++){var t=null!=arguments[n]?arguments[n]:{},r=Object.keys(t);"function"===typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(t).filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})))),r.forEach((function(n){Pe(e,n,t[n])}))}return e}function Re(e,n){if(null==e)return{};var t,r,o=function(e,n){if(null==e)return{};var t,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||(o[t]=e[t]);return o}(e,n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)t=i[r],n.indexOf(t)>=0||Object.prototype.propertyIsEnumerable.call(e,t)&&(o[t]=e[t])}return o}function Te(e,n){return function(e){if(Array.isArray(e))return e}(e)||function(e,n){var t=null==e?null:"undefined"!==typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=t){var r,o,i=[],a=!0,s=!1;try{for(t=t.call(e);!(a=(r=t.next()).done)&&(i.push(r.value),!n||i.length!==n);a=!0);}catch(l){s=!0,o=l}finally{try{a||null==t.return||t.return()}finally{if(s)throw o}}return i}}(e,n)||Me(e,n)||function(){throw new TypeError("Invalid attempt to de
1structure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function De(e){return function(e){if(Array.isArray(e))return Ie(e)}(e)||function(e){if("undefined"!==typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Me(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function Le(e){var n=function(e,n){if("object"!==Ae(e)||null===e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var r=t.call(e,n||"default");if("object"!==Ae(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(e)}(e,"string");return"symbol"===Ae(n)?n:String(n)}var Ae=function(e){return e&&"undefined"!==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e};function Me(e,n){if(e){if("string"===typeof e)return Ie(e,n);var t=Object.prototype.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(t):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?Ie(e,n):void 0}}for(var qe,Ue=(0,p.ZP)("".concat(pe.MS),{transports:["websocket","polling"],reconnection:!0,reconnectionAttempts:1/0,reconnectionDelay:1e3,reconnectionDelayMax:5e3,timeout:2e4}),Be={},Ze="#",He=0;He<6;He++)Ze+="0123456789ABCDEF"[Math.floor(16*Math.random())];var Ge=function(){var e=function(e){Ue.emit("teacherLive",e),Ue.emit("sendTotalUserCount",{roomId:J})},n=function(){G(!H),null===N||void 0===N||N.getVideoTracks().forEach((function(e){e.enabled=!H}))},t=function(){B(!0),G(!0),qe&&(qe.getTracks().forEach((function(e){return e.stop()})),qe=null),Object.keys(Be).forEach((function(e){Be[e].close(),delete Be[e]})),Ue.emit("onLineOffLineTeacher",{statusType:"offline",roomId:J,userType:"teacher",subject:null===V||void 0===V?void 0:V.subject,name:null===V||void 0===V?void 0:V.name}),S(null),fe(!1),ln(!1),dn(!1),O(null),Ie([]),Je([]),clearInterval(nn.current),nn.current=null,Ue.emit("endCall",{roomId:J}),z.current=null},r=(0,v.useRouter)(),a=(0,h.I0)(),l=(0,b.useRef)(null),u=c().bind(d()),p=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.login)||void 0===n?void 0:n.loginData})),k=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.loader)||void 0===n?void 0:n.loader})),_=(0,b.useState)(null),N=_[0],S=_[1],C=(0,b.useState)(null),I=C[0],O=C[1],E=(0,b.useState)({}),P=E[0],F=E[1],R=(0,b.useState)(!1),T=R[0],D=R[1],L=(0,b.useState)(""),A=L[0],M=L[1],q=(0,b.useState)(!0),U=q[0],B=q[1],Z=(0,b.useState)(!0),H=Z[0],G=Z[1],V=(0,h.v9)((function(e){var n;return null===e||void 0===e||null===(n=e.login)||void 0===n?void 0:n.profileData})),W=(0,b.useRef)(null),K=(0,b.useRef)(null),J=(0,b.useState)(null===V||void 0===V?void 0:V.userName)[0],z=(0,b.useRef)(null),Q=(0,b.useRef)(null),X=(0,b.useRef)({}),$=(0,b.useRef)(null),Y=(0,b.useRef)([]),ee=(0,b.useRef)(null),ne=(0,b.useState)(null),te=ne[0],oe=ne[1],ie=(0,b.useState)([]),ae=ie[0],se=ie[1],le=(0,b.useState)(!1),ce=le[0],ue=le[1],de=(0,b.useState)(!1),ve=de[0],fe=de[1],pe=(0,b.useState)([]),ge=pe[0],Ie=pe[1],Oe=(0,b.useState)(""),Ae=Oe[0],Me=Oe[1],He=(0,b.useState)(null),Ge=He[0],Ve=He[1],We=(0,b.useState)([]),Ke=We[0],Je=We[1],ze=(0,b.useState)(0),Qe=ze[0],Xe=ze[1],$e=(0,b.useState)(0),Ye=$e[0],en=$e[1],nn=(0,b.useRef)(null),tn=(0,b.useState)(!1),rn=tn[0],on=tn[1],an=(0,b.useState)(!1),sn=an[0],ln=an[1],cn=(0,b.useState)(!1),un=cn[0],dn=cn[1];(0,b.useEffect)((function(){var e=function(){var e=Ee(o().mark((function e(){var n,t;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,x.nD)(p);case 3:return n=e.sent,e.next=6,(0,x.$F)(p);case 6:t=e.sent,a((0,y.rK)(n)),a((0,y.zR)(t)),e.next=14;break;case 11:e.prev=11,e.t0=e.catch(0),console.log("error",e.t0);case 14:case"end":return e.stop()}}),e,null,[[0,11]])})));return function(){return e.apply(this,arguments)}}();e()}),[]),(0,b.useEffect)((function(){var e=function(){var e=Ee(o().mark((function e(){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,(0,x.Kf)(p);case 3:n=e.sent,a((0,y.SC)(n)),e.next=10;break;case 7:e.prev=7,e.t0=e.catch(0),console.log("error",e.t0);case 10:case"end":return e.stop()}}),e,null,[[0,7]])})));return function(){return e.apply(this,arguments)}}();e()}),[]),(0,b.useEffect)((function(){return Qe>
10&&(nn.current=setInterval((function(){Xe((function(e){return e-1}))}),1e3)),function(){nn.current&&(clearInterval(nn.current),nn.current=null)}}),[Qe]),(0,b.useEffect)((function(){0===Qe&&(clearInterval(nn.current),nn.current=null)}),[Qe]);var vn=function(){var e=Math.floor(Qe/60),n=Qe%60;return"".concat(e,":").concat(n<10?"0".concat(n):n)};(0,b.useEffect)((function(){p||(Ue.emit("onLineOffLineTeacher",{statusType:"offline",roomId:J,userType:"teacher",subject:null===V||void 0===V?void 0:V.subject,name:null===V||void 0===V?void 0:V.name}),S(null),Ue.emit("endCall",{roomId:J}),z.current=null)}),[p]),(0,b.useEffect)((function(){(null===p||void 0===p?void 0:p.length)>0&&navigator.onLine&&a((0,he.R5)(r,p))}),[a]);var fn=(0,b.useCallback)((function(e){Je((function(n){return null===n||void 0===n?void 0:n.map((function(n){return n.name===e.name?Fe({},n,{connectionType:e.userConnectionType,isMuted:e.isMuted,isVideo:e.isVideo,clientId:e.clientId}):n}))}))}),[]),mn=(0,b.useCallback)((function(e,n){var t,r;e&&n&&(X.current=Fe({},X.current,Pe({},e,n)),F((function(t){var r=t[e];return r&&r.id===n.id?t:Fe({},t,Pe({},e,n))})),$.current===e&&(O(n),K.current&&(K.current.srcObject=n),(null===(t=n.getVideoTracks)||void 0===t||null===(r=t.call(n))||void 0===r?void 0:r.some((function(e){return"live"===e.readyState&&!1!==e.enabled})))&&ue(!0)))}),[]);(0,b.useEffect)((function(){return Ue.on("personalCallStarted",(function(e){var n=e.userId,t=e.duration;en(t);var r,o,i=X.current[n];i?(O(i),K.current&&(K.current.srcObject=i),$.current=n,((null===(r=i.getVideoTracks)||void 0===r||null===(o=r.call(i))||void 0===o?void 0:o.some((function(e){return"live"===e.readyState&&!1!==e.enabled})))||e.isVideo)&&ue(!0)):($.current=n,e.isVideo&&ue(!0),console.warn("Personal stream not ready yet, will bind on arrival:",n));fn(e)})),function(){Ue.off("personalCallStarted")}}),[fn]),(0,b.useEffect)((function(){I&&K.current&&(K.current.srcObject=I)}),[I]),(0,b.useEffect)((function(){try{var e=te?JSON.parse(te):[];se(e||[]),Y.current=e||[]}catch(n){console.warn("Failed to parse rooms",n)}}),[te]),(0,b.useEffect)((function(){var e=null===ae||void 0===ae?void 0:ae.find((function(e){return(null===e||void 0===e?void 0:e.id)===J}));void 0!==e?(ee.current&&(clearTimeout(ee.current),ee.current=null),(null===e||void 0===e?void 0:e.isPersonalCall)&&0===Qe&&null===nn.current&&(Ye>0&&Xe(60*Ye),Me(""),Ie([])),(null===e||void 0===e?void 0:e.isGroupCall)&&nn.current&&(clearInterval(nn.current),nn.current=null)):null===ee.current&&(ee.current=setTimeout((function(){var e;ee.current=null,!(null===(e=Y.current)||void 0===e?void 0:e.find((function(e){return(null===e||void 0===e?void 0:e.id)===J})))&&(Be={},Ue.emit("onLineOffLineTeacher",{statusType:"offline",roomId:J,userType:"teacher",subject:null===V||void 0===V?void 0:V.subject,name:null===V||void 0===V?void 0:V.name}),fe(!1),O(null),Ue.emit("endCall",{roomId:J}),z.current=null,Me(""),Ie([]))}),8e3))}),[ae,Ye]),(0,b.useEffect)((function(){var e=new Date;if(Ae){var n=JSON.parse(Ae);n=Fe({},n,{time:(0,re.mr)(e)}),Ie(De(ge).concat([n]))}}),[Ae]),(0,b.useEffect)((function(){var e=null===ae||void 0===ae?void 0:ae.find((function(e){return(null===e||void 0===e?void 0:e.id)===J}));Ge&&!(null===e||void 0===e?void 0:e.isPersonalCall)&&((null===ge||void 0===ge?void 0:ge.some((function(e){return e.userName===Ge.userName&&"Joined"===e.msg})))||Ie(De(ge).concat([Ge])))}),[Ge]),(0,b.useEffect)((function(){var e=null===ae||void 0===ae?void 0:ae.find((function(e){return(null===e||void 0===e?void 0:e.id)===J}));return Ue.on("LeavedCall",(function(n){var t,r,o,i,a=n.userId;if(null===n||void 0===n?void 0:n.callerId){var s=(null===e||void 0===e||null===(t=e.student)||void 0===t?void 0:t.userId)||(null===(o=null===(r=Y.current)||void 0===r?void 0:r.find((function(e){return(null===e||void 0===e?void 0:e.id)===J})))||void 0===o||null===(i=o.student)||void 0===i?void 0:i.userId);if(!s||!a||a===s){O(null),(null===e||void 0===e?void 0:e.screenShare)&&yn(!0),Ie((function(e){return null===e||void 0===e?void 0:e.filter((function(e){return"Joined"===e.msg&&e.userName!==n.userId}))})),Ve({color:Ze,msg:"Left",profile:"",userName:n.userId}),Je((function(e){return null===e||void 0===e?void 0:e.filter((function(e){return e.name!==a}))})),F((function(e){e[a];return Re(e,[a].map(Le))}));
1var l=X.current,c=(l[a],Re(l,[a].map(Le)));X.current=c,$.current===a&&($.current=null),ue(!1)}}})),function(){Ue.off("LeavedCall")}}),[P,Ke,ae]);var pn=(0,b.useCallback)((function(e){Je((function(n){return n.map((function(n){return n.name===e.studentId?Fe({},n,{isMuted:e.audioStatus}):n}))})),ue(e.videoStatus)}),[]);(0,b.useEffect)((function(){return Ue.on("videoControlCompleteAck",(function(e){if(e.roomId===J){a((0,j._)(!1));var n=I||($.current?X.current[$.current]:null);n&&(I||O(n),K.current&&(K.current.srcObject=n))}})),Ue.on("audioControlCompleteAck",(function(e){e.roomId===J&&a((0,j._)(!1))})),function(){Ue.off("videoControlCompleteAck"),Ue.off("audioControlCompleteAck")}}),[I,K.current]),(0,b.useEffect)((function(){return Ue.on("LeaveGroupUser",(function(e){if(e.roomId===J){a((0,j._)(!1)),Je((function(n){return null===n||void 0===n?void 0:n.filter((function(n){return n.name!==e.userId}))})),Ie((function(n){return null===n||void 0===n?void 0:n.filter((function(n){return"Joined"===n.msg&&n.userName!==e.userId}))})),Ve({color:Ze,msg:"Left",profile:"",userName:e.userId});var n=document.getElementById("audio-".concat(e.userId));if(n&&n.remove(),e.callerId&&Be[e.callerId]){try{Be[e.callerId].close()}catch(i){console.warn("Error closing peer for group leave",i)}delete Be[e.callerId]}if(e.userId){F((function(n){var t=e.userId;n[t];return Re(n,[t].map(Le))}));var t=X.current,r=e.userId,o=(t[r],Re(t,[r].map(Le)));X.current=o}}})),function(){Ue.off("LeaveGroupUser")}}),[]);var hn=(0,b.useRef)(null);function gn(){return(gn=Ee(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:case"end":return e.stop()}}),e)})))).apply(this,arguments)}(0,b.useEffect)((function(){var n;return Ue.on("connect",(function(){Ue.emit("joinRoom",{roomId:J,userType:"teacher",subject:null===V||void 0===V?void 0:V.subject,name:(null===V||void 0===V?void 0:V.name)?null===V||void 0===V?void 0:V.name:"".concat(null===V||void 0===V?void 0:V.fname," ").concat(null===V||void 0===V?void 0:V.lname)})})),Ue.on("receiveMessageByStudent",(function(e){Me(JSON.stringify(e))})),Ue.on("receiveOnlineTeacher",(function(e){oe(JSON.stringify(e.data))})),Ue.emit("sendMessage","test"),Ue.on("newCall",(function(e){hn.current=e.rtcMessage,z.current=e.callerId,Q.current=e.currentUser,Be.current.setRemoteDescription(new RTCSessionDescription(hn.current))})),Ue.on("callAnswered",(function(e){hn.current=e.rtcMessage;var n=e.callee,t=null===e||void 0===e?void 0:e.userName,r=null===e||void 0===e?void 0:e.profile;Be[n]&&("have-local-offer"===Be[n].signalingState?Be[n].setRemoteDescription(new RTCSessionDescription(hn.current)).then((function(){Ve({color:Ze,msg:"Joined",profile:r,userName:t})})).catch((function(e){return console.error("Failed to set remote description:",e)})):console.warn("Cannot set remote description in current signaling state:",Be[n].signalingState))})),Ue.on("LeavedCall",(function(e){var n,t,r=(null===(n=Y.current)||void 0===n?void 0:n.find((function(e){return(null===e||void 0===e?void 0:e.id)===J})))||(null===ae||void 0===ae?void 0:ae.find((function(e){return(null===e||void 0===e?void 0:e.id)===J})));if(null===e||void 0===e?void 0:e.callerId){var o=null===r||void 0===r||null===(t=r.student)||void 0===t?void 0:t.userId;o&&e.userId&&e.userId!==o||(O(null),(null===r||void 0===r?void 0:r.screenShare)&&yn(!0),Ie((function(n){return null===n||void 0===n?void 0:n.filter((function(n){return"Joined"===n.msg&&n.userName!==e.userId}))})),Ve({color:Ze,msg:"Left",profile:"",userName:e.userId}),Je((function(n){return null===n||void 0===n?void 0:n.filter((function(n){return n.name!==e.userId}))})),ue(!1))}})),Ue.on("leavedPersonalCall",(function(e){var n,t,r=null===(n=Y.current)||void 0===n?void 0:n.find((function(e){return(null===e||void 0===e?void 0:e.id)===J})),o=null===r||void 0===r||null===(t=r.student)||void 0===t?void 0:t.userId;(null===e||void 0===e?void 0:e.userId)&&o&&e.userId!==o||(null===e||void 0===e?void 0:e.callerId)&&(Ie([]),Me(""),ue(!1),on(!1))})),Ue.on("audioVideoStatus",(function(e){pn(e)})),Ue.on("requestToJoin",function(){var n=Ee(o().mark((function n(t){var r,i,a;return o().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(r=t.callerId,i=t.userId,Be[r]=new RTCPeerConnection({iceServers:[{urls:"stun:stun.l.google.com:19302"},{urls:"stun:stun1.l.google.com:19302"},{urls:"stun:stun2.l.google.com:19302"},{urls:"turn:freeturn.net:3478",credential:"free",username:"free"}],iceTransportPolicy:"all"}),!qe||!qe.getTracks){n.next=7;break}
1qe.getTracks().forEach((function(e){Be[r].addTrack(e,qe)})),n.next=9;break;case 7:return console.error("localStreamData is undefined or has no tracks"),n.abrupt("return");case 9:return n.next=11,Be[r].createOffer();case 11:return a=n.sent,n.next=14,Be[r].setLocalDescription(a);case 14:Be[r].ontrack=function(e){if(e&&e.streams&&e.streams[0]){var n=e.streams[0];if(mn(i,n),!document.getElementById("audio-".concat(i))){var t=document.createElement("audio");t.srcObject=n,t.autoplay=!0,t.muted=!1,t.id="audio-".concat(i),document.body.appendChild(t)}}else console.error("No stream found in event:",e)},Je((function(e){var n=e.some((function(e){return e.id===t.callerId}));return n?e:De(e).concat([{id:t.callerId,name:t.userId,roomId:t.roomId,connectionType:t.connectionType,isMuted:t.isMuted,isVideo:t.isVideo,profile:t.profile,peerId:r}])})),"personal"===t.connectionType&&"student"===t.userType&&($.current=t.userId,t.isVideo&&ue(!0),Ue.emit("sendUserToClient",{id:t.callerId,name:t.userId,roomId:t.roomId,activePersonal:!0,isMuted:t.isMuted,isVideo:t.isVideo,profile:t.profile,connectionType:t.connectionType})),e({rtcMessage:a,roomId:r});case 18:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}()),Ue.on("ICEcandidate",(function(n){var t=n.rtcMessage,r=n.userId,i=Be[n.sender];i?(i.addIceCandidate(new RTCIceCandidate({candidate:t.candidate,sdpMid:t.id,sdpMLineIndex:t.label})).then((function(){console.log("ICE candidate ")})).catch((function(e){console.warn("Error",e)})),i.oniceconnectionstatechange=Ee(o().mark((function t(){var a,s,l;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(Be[n.sender]){t.next=2;break}return t.abrupt("return");case 2:if("checking"!==(a=i.iceConnectionState)){t.next=11;break}return t.next=6,i.createOffer();case 6:return s=t.sent,t.next=9,i.setLocalDescription(s);case 9:i.ontrack=function(e){e&&e.streams&&e.streams[0]?mn(r,e.streams[0]):console.error("No stream found in event:",e)},e({rtcMessage:s,roomId:n.sender});case 11:if("connected"===a&&bn(),"disconnected"!==a&&"failed"!==a){t.next=25;break}return t.prev=13,t.next=16,i.createOffer({iceRestart:!0});case 16:return l=t.sent,t.next=19,i.setLocalDescription(l);case 19:e({rtcMessage:l,roomId:n.sender}),t.next=25;break;case 22:t.prev=22,t.t0=t.catch(13),console.warn("ICE restart failed",t.t0);case 25:case"end":return t.stop()}}),t,null,[[13,22]])}))),i.onicecandidate=function(e){e.candidate?function(e){Ue.emit("ICEcandidate",e)}({calleeId:n.sender,rtcMessage:{label:e.candidate.sdpMLineIndex,id:e.candidate.sdpMid,candidate:e.candidate.candidate}}):console.warn("End of candidates.",e)}):console.warn("No peer connection for sender:",n.sender)})),null===navigator||void 0===navigator||null===(n=navigator.mediaDevices)||void 0===n||n.enumerateDevices().then((function(e){console.warn("sourceInfos",e)})),function(){Ue.off("newCall"),Ue.off("callAnswered"),Ue.off("ICEcandidate"),Ue.off("receiveOnlineTeacher"),Ue.off("endOfCall"),Ue.off("audioVideoStatus"),Ue.off("joinRoom"),Ue.off("requestToJoin"),Ue.off("leavedPersonalCall")}}),[]),window.addEventListener("beforeunload",(function(){t()})),(0,b.useEffect)((function(){Ue.emit("audioVideoStatus",{roomId:J,audioStatus:U,videoStatus:H})}),[U,H]),(0,b.useEffect)((function(){var e;ve?(null===(e=null===N||void 0===N?void 0:N.getAudioTracks())||void 0===e||e.forEach((function(e){e.enabled=!0})),Ue.emit("onLineOffLineTeacher",{statusType:"online",roomId:J,userType:"teacher",subject:null===V||void 0===V?void 0:V.subject,name:(null===V||void 0===V?void 0:V.name)?null===V||void 0===V?void 0:V.name:"".concat(null===V||void 0===V?void 0:V.fname),profile:null===V||void 0===V?void 0:V.profile}),function(){gn.apply(this,arguments)}()):Ue.emit("onLineOffLineTeacher",{statusType:"offline",roomId:J,userType:"teacher",subject:null===V||void 0===V?void 0:V.subject,name:(null===V||void 0===V?void 0:V.name)?null===V||void 0===V?void 0:V.name:"".concat(null===V||void 0===V?void 0:V.fname," ").concat(null===V||void 0===V?void 0:V.lname),profile:null===V||void 0===V?void 0:V.profile})}),[ve]),(0,b.useEffect)((function(){var e,n;ve&&N&&W.current&&(W.current.srcObject=N,W.current.muted=!0,null===(n=(e=W.current).play)||void 0===n||n.call(e).catch((function(){})))}),[ve,N]);(0,b.useEffect)((function(){if(l.current)for(var e=l.current.parentElement;e;){var n=window.getComputedStyle(e).overflowY;if(("auto"===n||"scroll"===n)&&e.scrollHeight>e.clientHeight&&!e.classList.contains("layout-content")&&e!==document.body&&e!==document.documentElement)return void(e.scrollTop=e.scrollHeight);e=e.parentElement}}),[ge]);var bn=function(){var e,n=!0,t=!0;null===(e=null===qe||void 0===qe?void 0:qe.getAudioTracks())||void 0===e||e.forEach((function(e){n=e.enabled}
1)),null===qe||void 0===qe||qe.getVideoTracks().forEach((function(e){t=e.enabled})),Ue.emit("audioVideoStatus",{roomId:J,audioStatus:n,videoStatus:t})},xn=function(){var e=Ee(o().mark((function e(t){var r,i,a,s,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(T){e.next=22;break}return e.prev=1,H||n(),r={video:{width:{ideal:1920},height:{ideal:1080},frameRate:{ideal:30}},audio:!1},e.next=6,navigator.mediaDevices.getDisplayMedia(r);case 6:(i=e.sent).getVideoTracks()[0].onended=function(){yn(!0)},a=Te(qe.getVideoTracks(),1),s=a[0],l=i.getVideoTracks()[0],s.stop(),qe.removeTrack(s),qe.addTrack(l),S(i),D(!0),Object.values(Be).forEach((function(e){var n=e.getSenders().find((function(e){return"video"===e.track.kind}));n&&n.replaceTrack(l)})),Ue.emit("screenShareStarted",{callerId:J,personalStudentId:t}),e.next=22;break;case 19:e.prev=19,e.t0=e.catch(1),console.error("Error starting screen share:",e.t0);case 22:case"end":return e.stop()}}),e,null,[[1,19]])})));return function(n){return e.apply(this,arguments)}}(),yn=function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];if(T||e){var n=Te(null===qe||void 0===qe?void 0:qe.getVideoTracks(),1),t=n[0];t.stop(),navigator.mediaDevices.getUserMedia({video:!0}).then((function(e){var n=Te(e.getVideoTracks(),1)[0];qe.removeTrack(t),qe.addTrack(n),S(e),Object.values(Be).forEach((function(e){var t=e.getSenders().find((function(e){return"video"===e.track.kind}));t&&t.replaceTrack(n)})),D(!1),Ue.emit("screenShareStopped",{roomId:J})}))}},jn=function(){var e=Ee(o().mark((function e(){var n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,navigator.mediaDevices.getUserMedia({audio:!0,video:!0});case 3:return(n=e.sent).getAudioTracks().forEach((function(e){e.enabled=!0})),S(n),qe=n,W.current&&(W.current.srcObject=n,W.current.muted=!0),e.abrupt("return",n);case 11:e.prev=11,e.t0=e.catch(0),console.warn("Error accessing media devices:",e.t0);case 14:case"end":return e.stop()}}),e,null,[[0,11]])})));return function(){return e.apply(this,arguments)}}(),wn=function(){var e=Ee(o().mark((function e(){return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,jn();case 2:e.sent&&fe(!ve);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),kn=function(){var e=null===ae||void 0===ae?void 0:ae.find((function(e){return(null===e||void 0===e?void 0:e.id)===J}));return(0,i.jsx)("div",{className:u("video-timing"),children:"group"===(null===e||void 0===e?void 0:e.roomType)&&e.isPersonalCall?(0,i.jsxs)(i.Fragment,{children:["Remaining Time: ",vn()]}):null})};return(0,i.jsxs)("div",{className:u(""),children:[(0,i.jsx)(w.a,{open:k}),!ve&&(0,i.jsx)("div",{className:u("te_video-page"),children:(0,i.jsxs)("div",{className:u("card m-3"),style:{height:"250px",maxWidth:"350px",justifyContent:"center",alignItems:"center",borderRadius:"15px"},children:[(0,i.jsx)("div",{className:"form-check form-switch form-switch-lg",children:(0,i.jsx)("input",{name:"showCareerGraph",className:"form-check-input",type:"checkbox",id:"flexSwitchCheckChecked",checked:ve,onChange:function(){return wn()},style:{cursor:"pointer"}})}),(0,i.jsx)("label",{htmlFor:"flexSwitchCheckChecked",className:"mt-3 form-check-label custom-label",style:{cursor:"pointer"},children:"You are offline"})]})}),(0,i.jsxs)("div",{className:u("te_video-section"),style:{display:ve?"flex":"none"},"aria-hidden":!ve,children:[(0,i.jsxs)("div",{className:un?u("sidebar","active"):u("sidebar"),children:[(0,i.jsxs)("div",{className:u("chat-header"),children:[(0,i.jsx)("h3",{children:"Students"})," ",(0,i.jsx)("button",{onClick:function(){return dn(!un)},children:(0,i.jsx)(g.G,{icon:f.g82,className:u("cross-icon")})})]}),(0,i.jsx)("ul",{className:u("user-list"),children:Ke&&Ke.length>0?null===Ke||void 0===Ke?void 0:Ke.map((function(e,n){var t,r,o;return(0,i.jsxs)("li",{className:u("user-item"),children:[(0,i.jsxs)("div",{className:u("connect-st"),children:[(0,i.jsx)("div",{className:u("profile-st"),children:(0,i.jsx)("img",{src:(null===e||void 0===e?void 0:e.profile)||"https://via.placeholder.com/40",alt:"User"})}),(0,i.jsxs)("span",{className:u("st-name"),children:["string"===typeof(null===e||void 0===e?void 0:e.name)&&(null===e||void 0===e?void 0:e.name.length)>0?(null===(r=null===e||void 0===e||null===(t=e.name)||void 0===t?void 0:t.charAt(0))||void 0===r?void 0:r.toUpperCase())+(null===e||void 0===e||null===(o=e.name)||void 0===o?void 0:o.slice(1)):"Unknown User"," "]})]}),(0,i.jsxs)("div",{className:u("st-icons"),children:[(0,i.jsx)("button",{type:"button",className:u("st-icon-btn"),title:e.isMuted?"Unmute":"Mute",onClick:function(){var n,t;n=e.name,t=!e.isMuted,a((0,j._)(!0)),Ue.emit("muteUnmuteStudent",{callerId:J,studentId:n,mute:t}),Je((function(e){return e.map((function(e){return e.name===n?Fe({},e,{isMuted:t}):e}))}))},children:(0,i.jsx)(g.G,{icon:e.isMuted?f.UOM:f.EkX})}),("personal"===e.connectionType||"Personal"===e.connectionType)&&(0,i.jsx)("button",{type:"button",className:u("st-icon-btn"),title:e.isVideo?"Turn video off":"Turn video on",onClick:function(){var n,t;n=e.name,t=!e.isVideo,a((0,j._)(!0)),Ue.emit("accesStudentVideo",{callerId:J,studentId:n,isVideo:t}),Je((function(e){return e.map((function(e){return e.name===n?Fe({},e,{isVideo:t}):e}))})),$.current===n&&ue(Boolean(t))},children:(0,i.jsx)(g.G,{icon:e.isVideo?f.iGN:f.dRd})})]})]},n)})):(0,i.jsxs)("li",{className:u("nocall"),children:[(0,i.jsx)("div",{children:(0,i.jsx)(s(),{src:Ne,height:90,width:90})}),"No one connected yet!"]})})]}),(0,i.jsx)("div",{className:sn||un?u("te_video-box","active"):u("te_video-box"),children:function(e){var n,t=null===ae||void 0===ae?void 0:ae.find((function(e){return(null===e||void 0===e?void 0:e.id)===J})),r=(null===t||void 0===t||null===(n=t.student)||void 0===n?void 0:n.userId)||"",o=Boolean(e||I);return(0,i.jsxs)(i.Fragment,{children:[("group"!==(null===t||void 0===t?void 0:t.roomType)||t.isPersonalCall)&&(null===t||void 0===t?void 0:t.isPersonalCall)?(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("video",{playsInl
1ine:!0,ref:W,autoPlay:!0,muted:!0,className:"video-active",style:{display:"".concat(ve?"block":"none"),width:"180px",maxHeight:"160px",position:"absolute",bottom:"60px",right:"20px",zIndex:"99",borderRadius:"15px"}}),!H&&(0,i.jsx)("div",{style:{width:"180px",height:"160px",position:"absolute",bottom:"60px",right:"20px",zIndex:"99",borderRadius:"15px",background:"#303030",display:"flex",alignItems:"center",justifyContent:"center"},children:(0,i.jsx)(g.G,{icon:f.dRd,style:{color:"#fff"},size:"2x"})}),(0,i.jsx)("video",{playsInline:!0,ref:K,autoPlay:!0,className:"video-active",style:{display:"".concat(o?"block":"none"),width:"100%",border:"none",height:"calc(100vh - 65px)",objectFit:"contain",background:"#000"}}),!o&&(0,i.jsx)("div",{className:u("video-off"),children:(0,i.jsx)("div",{className:u("icon-off"),children:(0,i.jsx)(g.G,{icon:f.dRd,style:{color:"#fff"},size:"3x"})})})]}):(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("video",{playsInline:!0,ref:W,autoPlay:!0,muted:!0,className:"video-active",style:{display:"".concat(H?"block":"none"),width:"100%",height:"calc(100vh - 65px)"}}),!H&&(0,i.jsx)("div",{className:u("video-off"),children:(0,i.jsx)("div",{className:u("icon-off"),children:(0,i.jsx)(g.G,{icon:f.dRd,style:{color:"#fff"},size:"3x"})})})]}),(0,i.jsx)(me,{isModalVisible:rn,setModalVisible:on,personalUserId:r,token:p})]})}(ce)}),function(){var e=null===ae||void 0===ae?void 0:ae.find((function(e){return(null===e||void 0===e?void 0:e.id)===J}));return(0,i.jsx)(i.Fragment,{children:ve&&(0,i.jsx)(i.Fragment,{children:(0,i.jsxs)("div",{className:u("te_chat-btn-list"),children:[(0,i.jsx)("div",{className:u("timer"),children:kn()}),(0,i.jsxs)("div",{className:u("listing-btns"),children:[(0,i.jsx)("div",{children:(0,i.jsx)("button",{className:u("te_chat-btn"),onClick:function(){n()},style:{background:"#337DFF"},children:(0,i.jsx)(s(),{src:H?we.Z:ke.Z,height:25,width:25,alt:""})})}),e&&(null===e||void 0===e?void 0:e.isPersonalCall)&&(0,i.jsx)("div",{children:(0,i.jsx)("button",{className:u("te_chat-btn"),onClick:function(){var n,t=(null===e||void 0===e||null===(n=e.student)||void 0===n?void 0:n.userId)||"";T?yn(!1):xn(t)},style:{background:"#072C6C"},children:(0,i.jsx)(s(),{src:T?Ce:_e,height:25,width:25,alt:"",title:T?"Stop Sharing":"Start Screen Share"})})}),(0,i.jsx)("div",{}),(0,i.jsx)("div",{children:(0,i.jsx)("button",{className:u("te_chat-btn"),onClick:function(){t()},style:{background:"#f10"},children:(0,i.jsx)(s(),{src:je.Z,height:25,width:25,alt:""})})})]}),(0,i.jsxs)("div",{className:u("sidebtn"),children:[(0,i.jsx)("div",{className:"position-relative",children:(0,i.jsx)("button",{className:u("te_chat-btn"),onClick:function(){dn(!un),ln(!1)},style:{background:"#46b8da"},children:(0,i.jsx)(s(),{src:ye,height:25,width:25,alt:""})})}),(0,i.jsx)("div",{children:(0,i.jsx)("button",{className:u("te_chat-btn"),onClick:function(){ln(!sn),dn(!1)},style:{background:"#00AA00"},children:(0,i.jsx)(s(),{src:xe.Z,height:25,width:25,alt:""})})}),e&&(null===e||void 0===e?void 0:e.isPersonalCall)&&(0,i.jsx)("div",{children:(0,i.jsx)("button",{className:u("te_chat-btn"),onClick:function(){on(!rn)},style:{background:"#336699"},children:(0,i.jsx)(s(),{src:Se,height:25,width:25,alt:"",title:"ADHD"})})})]})]})})})}()]}),ve&&(0,i.jsxs)("div",{className:sn?u("te_chat-box","active"):u("te_chat-box"),children:[(0,i.jsx)("button",{className:u("close-modal"),onClick:function(){return ln(!sn)},children:(0,i.jsx)(g.G,{icon:f.g82,className:u("cross-icon")})}),(0,i.jsxs)("div",{className:u("te_chat-scroll-box"),children:[0===ge.length&&(0,i.jsx)("div",{className:u("chat-empty"),children:"No messages yet. Say hello to start the conversation."}),ge.length>0&&ge.map((function(e,n){var t;return(0,i.jsxs)("div",{className:u("te_msg-box"),children:[(0,i.jsx)("div",{className:u("te_chat-profile"),children:(null===e||void 0===e?void 0:e.profile)?(0,i.jsx)(s(),{src:(null===e||void 0===e?void 0:e.profile)?null===e||void 0===e?void 0:e.profile:"/medical.jpg",height:35,width:35,alt:""}):(0,i.jsx)("div",{className:u("message-logo"),style:{backgroundColor:e.color},children:(0,i.jsx)("span",{style:{color:"#fff"},children:null===e||void 0===e||null===(t=e.userName)||void 0===t?void 0:t.charAt(0)})})}),(0,i.jsxs)("div",{style:{maxWidth:"calc(90% - 35px)",paddingLeft:"15px"},children:[(0,i.jsx)("div",{style:{fontSize:"12px"},children:e.userName}),(0,i.jsx)("div",{className:u("te_chat-content"),children:null===e||void 0===e?void 0:e.msg}),(0,i.jsx)("div",{style:{fontSize:"12px",textAlign:"right"},children:null===e||void 0===e?void 0:e.time})]})]},n)})),(0,i.jsx)("div",{ref:l})]}),(0,i.jsx)("div",{className:u("chat-sending"),children:(0,i.jsxs)("div",{className:u("input-rel"),children:[(0,i.jsx)("textarea",{rows:1,placeholder:"Type a message...",onChange:function(e){return M(e.target.value)},value:A,onInput:function(e){e.target.style.height="auto",e.target.style.height="".concat(Math.min(e.target.scrollHeight,96),"px")}}),(0,i.jsx)(m.Z,{className:u("chat-btn"),onClick:function(){return function(){var e=new Date,n=null===A||void 0===A?void 0:A.trim();n&&(Ue.emit("sendMessageToStudents",{roomId:J,message:n,userName:J,color:Ze,profile:(null===V||void 0===V?void 0:V.profile)?null===V||void 0===V?void 0:V.profile:""}),Ie(De(ge).concat([{userName:J,msg:n,color:Ze,profile:null===V||void 0===V?void 0:V.profile,time:(0,re.mr)(e)}])),M(""))}()},"aria-label":"Send message",children:(0,i.jsx)(s(),{src:"/send-icon.svg",height:20,width:20,alt:""})})]})})]}),(0,i.jsx)(be,{tempMessages:Ae})]})}},85020:function(e,n,t){"use strict";t.d(n,{a:function(){return a}});var r=t(85893),o=t(3121),i=t(85574),a=function(e){return(0,r.jsx)(o.Z,{sx:{color:"#3357a4",zIndex:function(e){return e.zIndex.drawer+1}},open:e.open,children:(0,r.jsx)(i.Z,{color:"inherit"})})}},32998:function(e){e.exports={"flex-style":"LiveForCounselling_flex-style__zBB_o","calculations-tabs":"LiveForCounselling_calculations-tabs__tLb4k","bg-one":"LiveForCounselling_bg-one__4OwOr","bg-two":"LiveForCounselling_bg-two___L9bs","bg-three":"LiveForCounselling_bg-three__b_1qb","bg-four":"LiveForCounselling_bg-four__EWvri",card:"LiveForCounselling_card__UrmBf","text-weight":"LiveForCounselling_text-weight__UghTC","exam-detail":"LiveForCounselling_exam-detail__knLrl","my-exam":"LiveForCounselling_my-exam__nGv78","add-scroll-1":"LiveForCounselling_add-scroll-1__WHARm","video-btn":"LiveForCounselling_video-btn__b5lAh","te_video-page":"LiveForCounselling_te_video-page__HUGZL","te_video-section":"LiveForCounselling_te_video-section__uDG0s","te_video-box":"LiveForCounselling_te_video-box__J4dJU",active:"LiveForCounselling_active__T_8W1",nocall:"LiveForCounselling_nocall__rxTH8","listing-btns":"LiveForCounselling_listing-btns__katK8","te_chat-btn-list":"LiveForCounselling_te_chat-btn-list__P8KLn","te_chat-btn":"LiveForCounselling_te_chat-btn__8YXjq",sidebtn:"LiveForCounselling_sidebtn__S_qyp","te_chat-box":"LiveForCounselling_te_chat-box__1na39","close-modal":"LiveForCounselling_close-modal__Iv_oh","te_chat-scroll-box":"LiveForCounselling_te_chat-scroll-box___cQea","chat-empty":"LiveForCounselling_chat-empty__CkoLz","te_msg-box":"LiveForCounselling_te_msg-box__jfwsg","te_chat-profile":"LiveForCounselling_te_chat-profile___y5Ot","te_chat-content":"LiveForCounselling_te_chat-content__7A5ff","message-logo":"LiveForCounselling_message-logo__9_cVT","chat-sending":"LiveForCounselling_chat-sending__kSeHW","input-rel":"LiveForCounselling_input-rel__mFoZG","chat-btn":"LiveForCounselling_chat-btn__qdG7I","add-scroll":"LiveForCounselling_add-scroll__7ph1e","chat-header":"LiveForCounselling_chat-header__JzQ64",sidebar:"LiveForCounselling_sidebar__HmpPn","user-list":"LiveForCounselling_user-list__5bhNl","st-icons":"LiveForCounselling_st-icons__JXWRY","st-icon-btn":"LiveForCounselling_st-icon-btn__pfW36","user-item":"LiveForCounselling_user-item__OGJnh",icons:"LiveForCounselling_icons__UXM2V",counter:"LiveForCounselling_counter__12hFB","connect-st":"LiveForCounselling_connect-st__2ff9c","profile-st":"LiveForCounselling_profile-st__RudwV","st-name":"LiveForCounselling_st-name__Rr7Px","video-timing":"LiveForCounselling_video-timing__X25QU","video-off":"LiveForCounselling_video-off__sgqVX","icon-off":"LiveForCounselling_icon-off__5r_Fx","modal-close":"LiveForCounselling_modal-close__aAV7Q","cross-icon":"LiveForCounselling_cross-icon__ThEbN","gemini-container":"LiveForCounselling_gemini-container__to2Mx","gemini-chatbox":"LiveForCounselling_gemini-chatbox__iEiqZ",userMessage:"LiveForCounselling_userMessage__jCUCU",gptMessage:"LiveForCounselling_gptMessage__zBmbi",capsules:"LiveForCounselling_capsules__WRx73",inputBar:"LiveForCounselling_inputBar__s5zkS","report-btns":"LiveForCounselling_report-btns__1Twse"}},35005:function(e,n,t){"use strict";var r=t(94184),o=t.n(r),i=t(67294),a=t(70861),s=t(76792),l=t(85893);const c=i.forwardRef((({as:e,bsPrefix:n,variant:t,size:r,active:i,className:c,...u},d)=>{const v=(0,s.vE)(n,"btn"),[f,{tagName:m}]=(0,a.FT)({tagName:e,...u}),p=m;return(0,l.jsx)(p,{...f,...u,ref:d,className:o()(c,v,i&&"active",t&&`${v}-${t}`,r&&`${v}-${r}`,u.href&&u.disabled&&"disabled")})}
1));c.displayName="Button",c.defaultProps={variant:"primary",active:!1,disabled:!1},n.Z=c},11041:function(e,n,t){"use strict";n.Z=void 0;var r,o=(r=t(67294))&&r.__esModule?r:{default:r},i=t(45697);function a(e){return a="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"===typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function s(e,n){for(var t=0;t<n.length;t++){var r=n[t];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function l(e){return l=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},l(e)}function c(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function u(e,n){return u=Object.setPrototypeOf||function(e,n){return e.__proto__=n,e},u(e,n)}var d="granted",v=function(){var e=0;return function(){return e++}}();var f=function(e){function n(e){var t;!function(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}(this,n),t=function(e,n){return!n||"object"!==a(n)&&"function"!==typeof n?c(e):n}(this,l(n).call(this,e));var r=!1,o=!1;return"Notification"in window&&window.Notification&&(r=!0,window.Notification.permission===d&&(o=!0)),t.state={supported:r,granted:o},t.notifications={},t.windowFocus=!0,t.onWindowFocus=t._onWindowFocus.bind(c(t)),t.onWindowBlur=t._onWindowBlur.bind(c(t)),t}var t,r,i;return function(e,n){if("function"!==typeof n&&null!==n)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(n&&n.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),n&&u(e,n)}(n,e),t=n,(r=[{key:"_onWindowFocus",value:function(){this.windowFocus=!0}},{key:"_onWindowBlur",value:function(){this.windowFocus=!1}},{key:"_askPermission",value:function(){var e=this,n=function(n){var t=n===d;e.setState({granted:t},(function(){t?e.props.onPermissionGranted():e.props.onPermissionDenied()}))};!function(){try{window.Notification.requestPermission().then()}catch(e){return!1}return!0}()?window.Notification.requestPermission((function(e){n(e)})):window.Notification.requestPermission().then((function(e){n(e)}))}},{key:"componentDidMount",value:function(){this.props.disableActiveWindow&&(window.addEventListener("focus",this.onWindowFocus),window.addEventListener("blur",this.onWindowBlur)),this.state.supported?this.state.granted?this.props.onPermissionGranted():"denied"===window.Notification.permission?this.props.askAgain?this._askPermission():this.props.onPermissionDenied():this._askPermission():this.props.notSupported()}},{key:"componentWillUnmount",value:function(){this.props.disableActiveWindow&&(window.removeEventListener("focus",this.onWindowFocus),window.removeEventListener("blur",this.onWindowBlur))}},{key:"doNotification",value:function(){var e=this,n=this.props.options;if("string"!==typeof n.tag&&(n.tag="web-notification-"+v()),!this.notifications[n.tag])if(this.props.swRegistration&&this.props.swRegistration.showNotification)this.props.swRegistration.showNotification(this.props.title,n),this.notifications[n.tag]={};else{var t=new window.Notification(this.props.title,n);t.onshow=function(r){e.props.onShow(r,n.tag),e.props.timeout>0&&setTimeout((function(){e.close(t)}),e.props.timeout)},t.onclick=function(t){e.props.onClick(t,n.tag)},t.onclose=function(t){e.props.onClose(t,n.tag)},t.onerror=function(t){e.props.onError(t,n.tag)},this.notifications[n.tag]=t}}},{key:"render",value:function(){var e=this.props.disableActiveWindow&&this.windowFocus;return!this.props.ignore&&this.props.title&&this.state.supported&&this.state.granted&&!e&&this.doNotification(),o.default.createElement("input",{type:"hidden",name:"dummy-for-react-web-notification",style:{display:"none"}})}},{key:"close",value:function(e){e&&"function"===typeof e.close&&e.close()}},{key:"_getNotificationInstance",value:function(e){return this.notifications[e]}}])&&s(t.prototype,r),i&&s(t,i),n}(o.default.Component);f.propTypes={ignore:i.bool,disableActiveWindow:i.bool,askAgain:i.bool,notSupported:i.func,onPermissionGranted:i.func,onPermissionDenied:i.func,onShow:i.func,onClick:i.func,onClose:i.func,onError:i.func,timeout:i.number,title:i.string.isRequired,options:i.object,swRegistration:i.object},f.defaultProps={ignore:!1,disableActiveWindow:!1,askAgain:!1,notSupported:function(){},onPermissionGranted:function(){},onPermissionDenied:function(){},onShow:function(){},onClick:function(){},onClose:function(){},onError:function(){},timeout:5e3,options:{},swRegistration:null};var m=f;n.Z=m}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.