1"use strict";(self.webpackChunkaverpoint_react_app=self.webpackChunkaverpoint_react_app||[]).push([[8700],{18700:(e,s,t)=>{t.r(s),t.d(s,{default:()=>A});var a=t(65043),l=t(99706),n=t(40854),i=t.n(n),r=t(89439),c=t(70658),o=t(93248),d=t(25268),m=t(70579);function u(){const e=new Date,s=0===e.getDay()?7:7-e.getDay(),t=new Date(e);return t.setDate(e.getDate()+s),t.setHours(0,0,0,0),t}function v(e,s){const t=new Date(s);t.setDate(s.getDate()+7*e);const a=new Date(t);a.setDate(t.getDate()+6);const l=e=>e.toLocaleDateString("en-US",{month:"short",day:"numeric"});return`${l(t)} \u2013 ${l(a)}`}function h(e,s){const t=new Date(s);return t.setDate(t.getDate()+7*e),t.toDateString()}const g=[{value:"standard",label:"Standard"},{value:"strict",label:"Strict"},{value:"forgiving",label:"Forgiving"}],p=[{value:"hit",label:"Hit"},{value:"miss",label:"Miss"}],x={background:"rgba(87,128,0,0.07)",borderBottom:"1px solid rgba(87,128,0,0.35)"},f={background:"rgba(232,13,37,0.05)",borderBottom:"1px solid rgba(232,13,37,0.3)"},N={standard:[!1,!0,!1,!1,!0,!0,!0,!0,!1,!0,!0,!0],strict:[!1,!0,!1,!0,!0,!0,!0,!0,!0,!0,!0,!0],forgiving:[!0,!0,!1,!0,!0,!1,!0,!0,!0,!0,!0,!0]};function j(e,s,t){const a=N[e]||N.standard;return Array.from({length:12},((e,l)=>{var n;return{hit:null===(n=a[l])||void 0===n||n,protected:!!s&&s.has(h(l,t))}}))}const b=["","#e74c3c","#e67e22","#f1c40f","#578000","#1286c8","#7e57c2"],D={3:!0},w={LEVEL_UP:"Level Up",LEVEL_DOWN:"Level Down",STANDARD_GRACE:"Grace Week",PROTECTED_WEEK:"Protected Week",FORGIVING_HOLD:"Forgiving Hold",HOLD_AT_MAX:"Hold at Max",HOLD_AT_MIN:"Hold at Min"};function S(e){let{level:s}=e;return(0,m.jsx)("span",{className:"sim-lvl",style:{background:b[s],color:D[s]?"#333":"#fff"},children:s})}const A=(0,l.A)((function(e){var s;let{location:t}=e;const l=(0,a.useMemo)((()=>u()),[]),[n,h]=(0,a.useState)(1),[N,b]=(0,a.useState)("1"),[D,A]=(0,a.useState)("standard"),[k,L]=(0,a.useState)(1/0),[_,y]=(0,a.useState)(""),[E,C]=(0,a.useState)((()=>j("standard",null,u()))),[R,W]=(0,a.useState)(null),[G,M]=(0,a.useState)(!1),O=(0,a.useMemo)((()=>new URLSearchParams((null===t||void 0===t?void 0:t.search)||window.location.search).get("courseId")),[t]);(0,a.useEffect)((()=>{O&&(M(!0),i().get("/api/courses/getUserCourseDetails",{params:{courseId:O}}).then((e=>{var s,t,a,n;const i=null===(s=e.data)||void 0===s?void 0:s.course;if(!i)return;W(i);const r=(null===(t=i.courseSettings)||void 0===t?void 0:t.levelStrictness)||"standard";A(r);const c=null===(a=i.courseSettings)||void 0===a?void 0:a.maxGraceWeeks;null!=c?(L(c),y(String(c))):(L(1/0),y(""));const o=new Set(((null===(n=i.courseSettings)||void 0===n?void 0:n.protectedWeeks)||[]).map((e=>new Date(e).toDateString())));C(j(r,o,l))})).catch((()=>{})).finally((()=>M(!1))))}),[O,l]);const H=(0,a.useMemo)((()=>{let e=n,s=!1,t=0;return E.map((a=>{const l=e,{newLevel:n,graceApplied:i,levelProtected:r}=function(e){let{completed:s,level:t,prevGraceApplied:a,lifetimeGraceUsed:l,weekProtected:n,strictness:i,maxGraceWeeks:r}=e,c=t,o=!1,d=!1;return s&&t<6?c=t+1:!s&&t>1&&(n?d=!0:"forgiving"===i||("standard"===i?a||l>=r?c=t-1:o=!0:c=t-1)),{newLevel:c,graceApplied:o,levelProtected:d}}({completed:a.hit,level:e,prevGraceApplied:s,lifetimeGraceUsed:t,weekProtected:a.protected,strictness:D,maxGraceWeeks:k});s=i,i&&t++,e=n;const c=function(e,s,t,a){return s>e?"LEVEL_UP":s<e?"LEVEL_DOWN":t?"STANDARD_GRACE":a?"PROTECTED_WEEK":6===e?"HOLD_AT_MAX":1===e?"HOLD_AT_MIN":"FORGIVING_HOLD"}(l,n,i,r);return{levelBefore:l,levelAfter:n,reason:c}}))}),[E,n,D,k]),I=(0,a.useMemo)((()=>{var e;return R?((null===(e=R.courseSettings)||void 0===e?void 0:e.protectedWeeks)||[]).map((e=>{const s=new Date(e);return`${String(s.getMonth()+1).padStart(2,"0")}/${String(s.getDate()).padStart(2,"0")}/${s.getFullYear()}`})):[]}),[R]);return(0,m.jsxs)("div",{className:"container mb-4 route-level-simulator",children:[(0,m.jsx)("h2",{className:"font-weight-600 pb-4",children:"Level Evaluation Simulator"}),G&&(0,m.jsxs)("div",{className:"sim-course-loading",children:[(0,m.jsx)("i",{className:"fa fa-spin fa-spinner text-primary",style:{fontSize:"20px"}}),(0,m.jsx)("span",{className:"av-gray font-size-14 ml-2",children:"Loading course details..."})]}),R&&!G&&(0,m.jsx)("div",{className:"sim-course-card bg-av-white mb-3",children:(0,m.jsxs)("div",{className:"sim-course-card-row",children:[(0,m.jsxs)("div",{className:"sim-course-info-item",children:[(0,m.jsx)("span",{className:"sim-course-info-label",children:"Course"}),(0,m.jsx)("span",{className:"sim-course-info-value font-weight-600",children:R.name})]}),(0,m.jsxs)("div",{className:"sim-course-info-item",children:[(0,m.jsx)("span",{className:"sim-course-info-label",children:"Course Strictness"}),(0,m.jsx)("span",{className:"sim-course-info-value",children:(null===(s=g.find((e=>e.value===D)))||void 0===s?void 0:s.label)||D})]}),I.length>0&&(0,m.jsxs)("div",{className:"sim-course-info-item sim-course-info-item--weeks",children:[(0,m.jsx)("span",{className:"sim-course-info-label",children:"Protected Weeks"}),(0,m.jsx)("span",{className:"sim-course-info-value",children:I.join(", ")})]})]})}),(0,m.jsxs)("div",{className:"bg-av-white mt-4 p-4",style:{borderRadius:"8px"}
1,children:[(0,m.jsx)("p",{className:"font-size-14 av-gray mb-4",children:"Configure course settings, then set each week's outcome to see how the level system responds."}),(0,m.jsxs)("div",{className:"sim-config",children:[(0,m.jsx)("div",{className:"sim-field",children:(0,m.jsx)(o.A,{type:"number",labelName:"Starting Level",min:1,max:6,value:N,onChange:e=>{const s=e.target.value;b(s);const t=parseInt(s);!isNaN(t)&&t>=1&&t<=6&&h(t)},onBlur:()=>b(String(n))})}),(0,m.jsx)("div",{className:"sim-field",children:(0,m.jsx)(c.A,{className:"sim-config-dropdown",labelName:"Course Strictness",options:g,value:g.find((e=>e.value===D)),onChange:e=>{A(e.value),C(j(e.value,null,l))},isClearable:!1,isDisabled:!!R})}),(0,m.jsx)("div",{className:"sim-field",children:(0,m.jsx)(o.A,{type:"text",inputMode:"numeric",labelName:"Max Grace Weeks",value:_,disabled:!!R,onChange:e=>{const s=e.target.value.replace(/[^0-9]/g,"");y(s);const t=parseInt(s,10);!isNaN(t)&&t>=1&&L(t)},onBlur:()=>{const e=parseInt(_,10);isNaN(e)||e<1?(y(""),L(1/0)):(y(String(e)),L(e))}})})]}),(0,m.jsx)("table",{className:"table sim-table",children:(0,m.jsxs)("tbody",{children:[(0,m.jsxs)("tr",{className:"sim-table-heading",children:[(0,m.jsx)("td",{style:{width:"13%"},children:"Week"}),(0,m.jsx)("td",{style:{width:"19%",textAlign:"center"},children:"Hit / Miss"}),(0,m.jsx)("td",{style:{width:"14%",textAlign:"center"},children:"Protected Week"}),(0,m.jsx)("td",{style:{width:"18%",textAlign:"center"},children:"Level"}),(0,m.jsx)("td",{style:{width:"36%"},children:"Reason"})]}),E.map(((e,s)=>{const t=H[s];return(0,m.jsxs)("tr",{children:[(0,m.jsx)("td",{className:"sim-week-num",children:v(s,l)}),(0,m.jsx)("td",{className:"sim-center-cell",children:(0,m.jsx)(c.A,{className:"sim-outcome-dropdown",options:p,value:p.find((s=>s.value===(e.hit?"hit":"miss"))),onChange:e=>((e,s)=>C((t=>t.map(((t,a)=>a===e?{...t,hit:s}:t)))))(s,"hit"===e.value),isClearable:!1,controlStyle:e.hit?x:f})}),(0,m.jsx)("td",{className:"sim-protected-cell",children:(0,m.jsx)(d.A,{checked:e.protected,handleChange:e=>((e,s)=>C((t=>t.map(((t,a)=>a===e?{...t,protected:s}:t)))))(s,e.target.checked),disabled:!!R})}),(0,m.jsx)("td",{className:"sim-center-cell",children:(0,m.jsxs)("div",{className:"sim-level-flow",children:[(0,m.jsx)(S,{level:t.levelBefore}),(0,m.jsx)(r.I,{icon:r.Z.ARROW_FORWARD,className:"sim-arrow",size:14}),(0,m.jsx)(S,{level:t.levelAfter})]})}),(0,m.jsx)("td",{children:(0,m.jsx)("span",{className:`sim-reason-badge sim-reason-${t.reason}`,children:w[t.reason]})})]},s)}))]})}),(0,m.jsxs)("div",{className:"sim-legend",children:[(0,m.jsx)("div",{className:"sim-legend-title",children:"Reason Reference"}),Object.entries(w).map((e=>{let[s,t]=e;return(0,m.jsx)("span",{className:`sim-reason-badge sim-reason-${s}`,children:t},s)}))]})]})]})}))}}]); 2//# sourceMappingURL=8700.9ffdbd93.chunk.js.map
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.