@algoux/standard-ranklist-renderer-component-core 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -1
- package/dist/index.js +62 -7
- package/dist/ranklist.d.ts +2 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var le=require("color"),s=require("@algoux/standard-ranklist-utils"),se=require("semver");function z(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var N=z(le),ce=z(se);const U={[s.EnumTheme.light]:"#ffffff",[s.EnumTheme.dark]:"#191919"},ae=["FB","AC","?","NOUT","CE","UKE",null];function ue(e,t,r){if(typeof r=="function")return r(e,t);if(e.startsWith("//"))return e;const o=e.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);if(o){const n=o[1].toLowerCase();return n==="http"||n==="https"||n==="data"?e:(console.warn(`unsupported protocol "${n}" in srk asset url:`,e),"")}return console.warn("unsupported srk asset url:",e),""}function de(e,t,r=180){const{backgroundColor:o}=s.resolveStyle(e||{}),n=o[t]||U[t],i=N.default(n).string(),l=N.default(n).alpha(.27).string();return`linear-gradient(${r}deg, ${i} 0%, ${i} 10%, ${l} 10%, transparent 100%)`}function fe(e,t){return typeof e.style=="string"?{className:`srk-preset-marker-${e.style}`}:e.style?{style:{backgroundColor:s.resolveStyle(e.style).backgroundColor[t]}}:{}}function me(e,t){const r=s.resolveText(e.name,t);return e.role?`${r} (${e.role})`:r}function ge(e){switch(e){case"FB":return{label:"First Blood",className:"srk-preset-result-fb"};case"AC":return{label:"Accepted",className:"srk-preset-result-ac"};case"RJ":return{label:"Rejected",className:"srk-preset-result-rj"};case"?":return{label:"Frozen",className:"srk-preset-result-fz"};case"WA":return{label:"Wrong Answer",className:"srk-preset-result-rj"};case"PE":return{label:"Presentation Error",className:"srk-preset-result-rj"};case"TLE":return{label:"Time Limit Exceeded",className:"srk-preset-result-rj"};case"MLE":return{label:"Memory Limit Exceeded",className:"srk-preset-result-rj"};case"OLE":return{label:"Output Limit Exceeded",className:"srk-preset-result-rj"};case"IDLE":return{label:"Idleness Limit Exceeded",className:"srk-preset-result-rj"};case"RTE":return{label:"Runtime Error",className:"srk-preset-result-rj"};case"NOUT":return{label:"No Output"};case"CE":return{label:"Compile Error"};case"UKE":return{label:"Unknown Error"};case null:return{label:"--"};default:return{label:e}}}function X(e){return`${e.tries}/${e.time?s.formatTimeDuration(e.time,"min",Math.floor):"-"}`}function g(e){return(e==null?void 0:e.result)==="AC"||(e==null?void 0:e.result)==="FB"}function K(e){return(e==null?void 0:e.result)==="RJ"||(e==null?void 0:e.result)==="?"}function v(e){return(e==null?void 0:e.tries)||0}function H(e,t){const r=Re(t),o=e.solutions||[];for(let n=o.length-1;n>=0;n-=1){const i=o[n];if(!r.includes(i.result))return i}}function f(e,t){if(!e)return"-";const r=ke(e,t);if(r==="ms"){const n=Math.floor(s.formatTimeDuration(e,"ms")),i=Math.floor(n/1e3);return`${F(i)}.${b(n%1e3,3)}`}if(r==="s")return F(Math.floor(s.formatTimeDuration(e,"s")));const o=Math.floor(s.formatTimeDuration(e,"min"));return`${Math.floor(o/60)}:${b(o%60,2)}`}function pe(e,t,r="classic"){if(!e.result)return{};if(r==="classic"){if(g(e)){const o=X(e);return typeof e.score=="number"?{score:e.score,scoreDetails:o}:{primary:o}}return{primary:typeof e.tries=="number"?String(e.tries):""}}if(g(e)){const o=Math.max((e.tries||0)-1,0);if(r==="detailed")return{primary:f(e.time,t),secondary:o>0?`(-${o})`:""};const n=o>0?`+${o}`:"+";return r==="compact"?{primary:n,secondary:f(e.time,t)}:{primary:n}}if(K(e)){const o=e.tries||0,n=`-${o}`;if(r==="detailed")return{primary:"",secondary:o>0?`(-${o})`:""};if(r==="compact"&&o>0){const i=H(e,t);if(i)return{primary:n,secondary:f(i.time,t)}}return{primary:n}}return{}}function ye(e){const t=e.statuses.reduce((r,o)=>{if(!g(o))return r;const n=v(o);return{wrong:r.wrong+Math.max(n-1,0),submitted:r.submitted+n}},{wrong:0,submitted:0});return!t.submitted||!t.wrong?"0%":`${Math.floor(t.wrong/t.submitted*100)}%`}function be(e){const t=e.rows.length;return e.problems.map((r,o)=>{const n={participantCount:t,accepted:0,attempted:0,submitted:0,dirt:0,dirtSubmitted:0};return e.rows.forEach(i=>{const l=i.statuses[o],u=v(l);u>0&&(n.attempted+=1,n.submitted+=u),g(l)&&(n.accepted+=1,n.dirt+=Math.max(u-1,0),n.dirtSubmitted+=u,l.time&&((!n.firstAcceptedTime||B(l.time,n.firstAcceptedTime)<0)&&(n.firstAcceptedTime=l.time),(!n.lastAcceptedTime||B(l.time,n.lastAcceptedTime)>0)&&(n.lastAcceptedTime=l.time)))}),n})}function he(e,t){return!e.firstAcceptedTime||!e.lastAcceptedTime?"-":`${f(e.firstAcceptedTime,t)} / ${f(e.lastAcceptedTime,t)}`}function Te(e){return e?String(Math.floor(s.formatTimeDuration(e,"min"))):"-"}function Me(e,t){return t<=0?"(-)":`(${Math.floor(e/t*100)}%)`}function Se(e){const t=V(e);return t===void 0?"-":W(t)}function Pe(e,t){const r=e.statuses.reduce((o,n,i)=>{if(!g(n))return o;const l=V(t[i]);return l!==void 0&&o.push(l),o},[]);return r.length?W(r.reduce((o,n)=>o+n,0)/r.length):"0.00"}function Ae(e,t,r){return`Solutions of ${s.numberToAlphabet(e)} (${s.resolveText(t.name,r)})`}function ve(e){return s.secToTimeStr(s.formatTimeDuration(e.time,"s"))}function we(e){return e.some(t=>{var r;return Boolean((r=t.score)==null?void 0:r.time)})}function ke(e,t){const r=t.sorter;return(r==null?void 0:r.algorithm)==="ICPC"&&r.config.timePrecision?r.config.timePrecision:e[1]}function Re(e){const t=e.sorter;return(t==null?void 0:t.algorithm)==="ICPC"&&t.config.noPenaltyResults?t.config.noPenaltyResults:ae}function V(e){if(!(!e||e.participantCount<=0))return(e.participantCount-e.accepted)/e.participantCount}function W(e){return e.toFixed(2)}function B(e,t){return s.formatTimeDuration(e,"ms")-s.formatTimeDuration(t,"ms")}function F(e){const t=Math.floor(e/3600),r=Math.floor(e%3600/60),o=e%60;return`${t}:${b(r,2)}:${b(o,2)}`}function b(e,t){const r=String(Math.trunc(Math.abs(e)));return r.length>=t?r:`${"0".repeat(t-r.length)}${r}`}function J(e){return s.formatTimeDuration(e.duration,"min")}function xe(e,t,r=0){const o=new Date(e.startAt).getTime(),n=t-r;return Math.min(Math.max(Math.floor((n-o)/6e4),0),J(e))}function Ee(e,t,r=0){const n=new Date(e.startAt).getTime()+s.formatTimeDuration(e.duration,"ms");return t-r>=n}function Ce(e){const t={};for(let r=0;r<=e;++r)t[r]="";return t}function De(e,t,r,o,n){const{contest:i}=e,l=new Date(i.startAt).getTime(),u=l+s.formatTimeDuration(i.duration,"ms"),I=i.frozenDuration?s.formatTimeDuration(i.frozenDuration,"ms"):0,$=t-r,d=u-l,p=d?1-I/d:1,S=Math.min(Math.max($-l,0),d),ee=d-S,te=u-I,re=d?S/d*100:0,O=d?Math.max(Math.min($,te)-l,0)/d*100:0,oe=Math.min(100,p?O/p:0),ne=re-O,ie=Math.min(100,1-p?ne/(1-p):0),P=o*60*1e3,_=d-P;return{elapsed:n?P:S,remaining:n?_:ee,frozenBreakpoint:p,normalInnerPercent:oe,frozenInnerPercent:ie,timeTravelElapsed:P,timeTravelRemaining:_,supportRegen:s.canRegenerateRanklist(e)}}const q=">=0.3.0 <=0.3.13";function Le(e){return ce.default.satisfies(e,q)}const Ie=280,$e="srk-animated-modal-root",M="srk-scrolling-effect";let y=null,a=null,j=!1,m=0,w="",k="",R="",x="",E="",C="",D="",L="",h=0,T=0,A=1,c=[],Y=!1;function Oe(e){var r,o;if(e.key!=="Escape")return;const t=c[c.length-1];!t||((r=t.onEscape)==null||r.call(t,e),(o=e.stopImmediatePropagation)==null||o.call(e),e.stopPropagation())}function _e(){typeof document=="undefined"||Y||(document.addEventListener("keydown",Oe),Y=!0)}function Ne(){typeof document=="undefined"||j||(document.addEventListener("mousedown",e=>{a={x:e.clientX,y:e.clientY}},!0),document.addEventListener("touchstart",e=>{const t=e.touches[0]||e.changedTouches[0];!t||(a={x:t.clientX,y:t.clientY})},{capture:!0,passive:!0}),j=!0)}function Z(e,t,r){y={x:e,y:t,timestamp:Date.now(),source:r==null?void 0:r.source,context:r==null?void 0:r.context}}function Be(e,t){Z(e.clientX,e.clientY,t)}function G(e=500){return!y||Date.now()-y.timestamp>e?null:y}function Fe(){return a}function je(e){if(typeof window=="undefined"||!e)return{origin:{x:0,y:0},source:"fallback",explicitTriggerPoint:null,globalInteractionPoint:a,dialogRect:null,fallbackPoint:{x:0,y:0}};const t=e.getBoundingClientRect(),r={x:t.width/2,y:Math.min(t.height*.22,96)},o=G();return o?{origin:{x:o.x-t.left,y:o.y-t.top},source:"explicit-trigger",explicitTriggerPoint:o,globalInteractionPoint:a,dialogRect:{left:t.left,top:t.top,width:t.width,height:t.height},fallbackPoint:r}:a?{origin:{x:a.x-t.left,y:a.y-t.top},source:"global-pointer",explicitTriggerPoint:null,globalInteractionPoint:a,dialogRect:{left:t.left,top:t.top,width:t.width,height:t.height},fallbackPoint:r}:{origin:r,source:"fallback",explicitTriggerPoint:null,globalInteractionPoint:null,dialogRect:{left:t.left,top:t.top,width:t.width,height:t.height},fallbackPoint:r}}function Ye(){return typeof document=="undefined"?null:document.activeElement instanceof HTMLElement?document.activeElement:null}function Q(e){try{e.focus({preventScroll:!0})}catch{e.focus()}}function ze(e,t={}){if(typeof document=="undefined"||!e)return null;_e();const r=c.find(l=>l.dialogElement===e);if(r)return r.onEscape=t.onEscape,r.id;const o=e.hasAttribute("tabindex"),n=e.getAttribute("tabindex");o||e.setAttribute("tabindex","-1");const i={id:A,dialogElement:e,restoreElement:Ye(),hadTabIndex:o,previousTabIndex:n,onEscape:t.onEscape};return A+=1,c.push(i),Q(e),i.id}function Ue(e){var l;if(typeof document=="undefined"||e==null)return;const t=c.findIndex(u=>u.id===e);if(t===-1)return;const[r]=c.splice(t,1);if(r.hadTabIndex?r.previousTabIndex===null?r.dialogElement.removeAttribute("tabindex"):r.dialogElement.setAttribute("tabindex",r.previousTabIndex):r.dialogElement.removeAttribute("tabindex"),!(t===c.length))return;const n=c[c.length-1],i=(l=r.restoreElement)!=null&&l.isConnected?r.restoreElement:n==null?void 0:n.dialogElement;i&&Q(i)}function Xe(e){var t;return e==null?!1:((t=c[c.length-1])==null?void 0:t.id)===e}function Ke(){typeof document!="undefined"&&(m===0&&(h=window.scrollX,T=window.scrollY,w=document.body.style.overflow,k=document.body.style.overflowX,R=document.body.style.overflowY,x=document.body.style.position,E=document.body.style.top,C=document.body.style.left,D=document.body.style.right,L=document.body.style.width,document.body.classList.add(M),document.body.style.overflow="hidden",document.body.style.overflowX="hidden",document.body.style.overflowY="hidden",document.body.style.position="fixed",document.body.style.top=`-${T}px`,document.body.style.left=`-${h}px`,document.body.style.right="0",document.body.style.width="100%"),m+=1)}function He(){if(!(typeof document=="undefined"||m===0)&&(m-=1,m===0&&(document.body.classList.remove(M),document.body.style.overflow=w,document.body.style.overflowX=k,document.body.style.overflowY=R,document.body.style.position=x,document.body.style.top=E,document.body.style.left=C,document.body.style.right=D,document.body.style.width=L,!(typeof navigator!="undefined"&&/jsdom/i.test(navigator.userAgent))&&typeof window.scrollTo=="function")))try{window.scrollTo(h,T)}catch{}}function Ve(){y=null,a=null,m=0,A=1,c=[],w="",k="",R="",x="",E="",C="",D="",L="",h=0,T=0,typeof document!="undefined"&&(document.body.classList.remove(M),document.body.style.overflow="",document.body.style.overflowX="",document.body.style.overflowY="",document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width="")}Object.defineProperty(exports,"convertToStaticRanklist",{enumerable:!0,get:function(){return s.convertToStaticRanklist}});exports.MODAL_ANIMATION_DURATION_MS=Ie;exports.SRK_ANIMATED_MODAL_ROOT_CLASS=$e;exports.SRK_SCROLL_LOCK_BODY_CLASS=M;exports.buildSliderMarks=Ce;exports.calculateDirtPercentage=ye;exports.calculateProblemStatisticsFooter=be;exports.calculateSEValue=Pe;exports.caniuse=Le;exports.captureModalTriggerPointFromMouseEvent=Be;exports.defaultBackgroundColor=U;exports.ensureModalInteractionTracker=Ne;exports.formatProblemStatisticsAcceptedMinute=Te;exports.formatProblemStatisticsAcceptedRange=he;exports.formatProblemStatisticsAverageHardness=Se;exports.formatProblemStatisticsPercent=Me;exports.formatRanklistStatusTime=f;exports.formatSolutionTimestamp=ve;exports.formatTeamMemberName=me;exports.getAcceptedStatusDetails=X;exports.getLastModalInteractionPoint=Fe;exports.getLastPenaltySolution=H;exports.getMarkerPresentation=fe;exports.getProblemHeaderBackgroundImage=de;exports.getProgressDurationMinutes=J;exports.getProgressMaxAvailableMinutes=xe;exports.getProgressMetrics=De;exports.getRankProblemStatusCellPresentation=pe;exports.getRankProblemStatusTries=v;exports.getRecentModalTriggerPoint=G;exports.getSolutionModalTitle=Ae;exports.getSolutionResultMeta=ge;exports.isAcceptedRankProblemStatus=g;exports.isProgressEnded=Ee;exports.isRejectedRankProblemStatus=K;exports.isTopModalFocusScope=Xe;exports.lockModalBodyScroll=Ke;exports.registerModalFocusScope=ze;exports.resetModalInteractionStateForTests=Ve;exports.resolveModalTransformOrigin=je;exports.resolveSrkAssetUrl=ue;exports.setModalTriggerPoint=Z;exports.shouldShowTimeColumn=we;exports.srkSupportedVersions=q;exports.unlockModalBodyScroll=He;exports.unregisterModalFocusScope=Ue;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});var ce=require("color"),l=require("@algoux/standard-ranklist-utils"),se=require("semver");function z(e){return e&&typeof e=="object"&&"default"in e?e:{default:e}}var O=z(ce),ae=z(se);const H={[l.EnumTheme.light]:"#ffffff",[l.EnumTheme.dark]:"#191919"},ue=["FB","AC","?","NOUT","CE","UKE",null];function de(e,t,r){if(typeof r=="function")return r(e,t);if(e.startsWith("//"))return e;const n=e.match(/^([a-zA-Z][a-zA-Z0-9+.-]*):/);if(n){const o=n[1].toLowerCase();return o==="http"||o==="https"||o==="data"?e:(console.warn(`unsupported protocol "${o}" in srk asset url:`,e),"")}return console.warn("unsupported srk asset url:",e),""}function U(e,t,r=180){const{backgroundColor:n}=l.resolveStyle(e||{}),o=n[t]||H[t],i=O.default(o).string(),c=O.default(o).alpha(.27).string();return`linear-gradient(${r}deg, ${i} 0%, ${i} 10%, ${c} 10%, transparent 100%)`}function fe(e,t,r=180){if(!(!e||!l.resolveStyle(e).backgroundColor[t]))return U(e,t,r)}function me(e,t){return typeof e.style=="string"?{className:`srk-preset-marker-${e.style}`}:e.style?{style:{backgroundColor:l.resolveStyle(e.style).backgroundColor[t]}}:{}}function ge(e,t){const r=l.resolveText(e.name,t);return e.role?`${r} (${e.role})`:r}function pe(e){switch(e){case"FB":return{label:"First Blood",className:"srk-preset-result-fb"};case"AC":return{label:"Accepted",className:"srk-preset-result-ac"};case"RJ":return{label:"Rejected",className:"srk-preset-result-rj"};case"?":return{label:"Frozen",className:"srk-preset-result-fz"};case"WA":return{label:"Wrong Answer",className:"srk-preset-result-rj"};case"PE":return{label:"Presentation Error",className:"srk-preset-result-rj"};case"TLE":return{label:"Time Limit Exceeded",className:"srk-preset-result-rj"};case"MLE":return{label:"Memory Limit Exceeded",className:"srk-preset-result-rj"};case"OLE":return{label:"Output Limit Exceeded",className:"srk-preset-result-rj"};case"IDLE":return{label:"Idleness Limit Exceeded",className:"srk-preset-result-rj"};case"RTE":return{label:"Runtime Error",className:"srk-preset-result-rj"};case"NOUT":return{label:"No Output"};case"CE":return{label:"Compile Error"};case"UKE":return{label:"Unknown Error"};case null:return{label:"--"};default:return{label:e}}}function X(e){return`${e.tries}/${e.time?l.formatTimeDuration(e.time,"min",Math.floor):"-"}`}function g(e){return(e==null?void 0:e.result)==="AC"||(e==null?void 0:e.result)==="FB"}function K(e){return(e==null?void 0:e.result)==="RJ"||(e==null?void 0:e.result)==="?"}function k(e){return(e==null?void 0:e.tries)||0}function be(e,t){if(!!e.result){if(he(e,t))return"srk-prest-status-block-partial";if(Se(e,t))return"srk-prest-status-block-failed";if(e.result==="FB")return"srk-prest-status-block-fb";if(e.result==="AC")return"srk-prest-status-block-accepted";if(e.result==="?")return"srk-prest-status-block-frozen";if(e.result==="RJ")return"srk-prest-status-block-failed"}}function J(e,t){const r=Ie(t),n=e.solutions||[];for(let o=n.length-1;o>=0;o-=1){const i=n[o];if(!r.includes(i.result))return i}}function f(e,t){if(!e)return"-";const r=Le(e,t);if(r==="ms"){const o=Math.floor(l.formatTimeDuration(e,"ms")),i=Math.floor(o/1e3);return`${F(i)}.${y(o%1e3,3)}`}if(r==="s")return F(Math.floor(l.formatTimeDuration(e,"s")));const n=Math.floor(l.formatTimeDuration(e,"min"));return`${Math.floor(n/60)}:${y(n%60,2)}`}function ye(e,t,r="classic"){if(!e.result)return{};if(typeof e.score=="number")return{score:e.score,scoreDetails:Te(e,t,r)};if(r==="classic")return g(e)?{primary:X(e)}:{primary:typeof e.tries=="number"?String(e.tries):""};if(g(e)){const n=Math.max((e.tries||0)-1,0);if(r==="detailed")return{primary:f(e.time,t),secondary:n>0?`(-${n})`:""};const o=n>0?`+${n}`:"+";return r==="compact"?{primary:o,secondary:f(e.time,t)}:{primary:o}}if(K(e)){const n=e.tries||0,o=`-${n}`;if(r==="detailed")return{primary:"",secondary:n>0?`(-${n})`:""};if(r==="compact"&&n>0){const i=J(e,t);if(i)return{primary:o,secondary:f(i.time,t)}}return{primary:o}}return{}}function he(e,t){var r;return((r=t.sorter)==null?void 0:r.algorithm)==="score"&&e.result!=="AC"&&e.result!=="FB"&&typeof e.score=="number"&&e.score>0}function Se(e,t){var r;return((r=t.sorter)==null?void 0:r.algorithm)==="score"&&e.result!=="AC"&&e.result!=="FB"&&typeof e.score=="number"&&e.score===0}function Te(e,t,r){if(r==="minimal")return;if(r==="compact")return e.time?f(e.time,t):void 0;const n=e.time?Me(e.time,t,r):void 0,o=[typeof e.tries=="number"?String(e.tries):void 0,n].filter(i=>i!==void 0);return o.length>0?o.join("/"):void 0}function Me(e,t,r){return r==="detailed"?f(e,t):`${l.formatTimeDuration(e,"min",Math.floor)}min`}function Pe(e){const t=e.statuses.reduce((r,n)=>{if(!g(n))return r;const o=k(n);return{wrong:r.wrong+Math.max(o-1,0),submitted:r.submitted+o}},{wrong:0,submitted:0});return!t.submitted||!t.wrong?"0%":`${Math.floor(t.wrong/t.submitted*100)}%`}function ve(e){const t=e.rows.length;return e.problems.map((r,n)=>{const o={participantCount:t,accepted:0,attempted:0,submitted:0,dirt:0,dirtSubmitted:0};return e.rows.forEach(i=>{const c=i.statuses[n],u=k(c);u>0&&(o.attempted+=1,o.submitted+=u),g(c)&&(o.accepted+=1,o.dirt+=Math.max(u-1,0),o.dirtSubmitted+=u,c.time&&((!o.firstAcceptedTime||_(c.time,o.firstAcceptedTime)<0)&&(o.firstAcceptedTime=c.time),(!o.lastAcceptedTime||_(c.time,o.lastAcceptedTime)>0)&&(o.lastAcceptedTime=c.time)))}),o})}function ke(e,t){return!e.firstAcceptedTime||!e.lastAcceptedTime?"-":`${f(e.firstAcceptedTime,t)} / ${f(e.lastAcceptedTime,t)}`}function Ae(e){return e?String(Math.floor(l.formatTimeDuration(e,"min"))):"-"}function we(e,t){return t<=0?"(-)":`(${Math.floor(e/t*100)}%)`}function Re(e){const t=V(e);return t===void 0?"-":W(t)}function xe(e,t){const r=e.statuses.reduce((n,o,i)=>{if(!g(o))return n;const c=V(t[i]);return c!==void 0&&n.push(c),n},[]);return r.length?W(r.reduce((n,o)=>n+o,0)/r.length):"0.00"}function Ce(e,t,r){return`Solutions of ${l.numberToAlphabet(e)} (${l.resolveText(t.name,r)})`}function Ee(e){return l.secToTimeStr(l.formatTimeDuration(e.time,"s"))}function De(e){return e.some(t=>{var r;return Boolean((r=t.score)==null?void 0:r.time)})}function Le(e,t){const r=t.sorter;return(r==null?void 0:r.algorithm)==="ICPC"&&r.config.timePrecision?r.config.timePrecision:e[1]}function Ie(e){const t=e.sorter;return(t==null?void 0:t.algorithm)==="ICPC"&&t.config.noPenaltyResults?t.config.noPenaltyResults:ue}function V(e){if(!(!e||e.participantCount<=0))return(e.participantCount-e.accepted)/e.participantCount}function W(e){return e.toFixed(2)}function _(e,t){return l.formatTimeDuration(e,"ms")-l.formatTimeDuration(t,"ms")}function F(e){const t=Math.floor(e/3600),r=Math.floor(e%3600/60),n=e%60;return`${t}:${y(r,2)}:${y(n,2)}`}function y(e,t){const r=String(Math.trunc(Math.abs(e)));return r.length>=t?r:`${"0".repeat(t-r.length)}${r}`}function q(e){return l.formatTimeDuration(e.duration,"min")}function $e(e,t,r=0){const n=new Date(e.startAt).getTime(),o=t-r;return Math.min(Math.max(Math.floor((o-n)/6e4),0),q(e))}function Be(e,t,r=0){const o=new Date(e.startAt).getTime()+l.formatTimeDuration(e.duration,"ms");return t-r>=o}function Ne(e){const t={};for(let r=0;r<=e;++r)t[r]="";return t}function Oe(e,t,r,n,o){const{contest:i}=e,c=new Date(i.startAt).getTime(),u=c+l.formatTimeDuration(i.duration,"ms"),I=i.frozenDuration?l.formatTimeDuration(i.frozenDuration,"ms"):0,$=t-r,d=u-c,p=d?1-I/d:1,M=Math.min(Math.max($-c,0),d),te=d-M,re=u-I,oe=d?M/d*100:0,B=d?Math.max(Math.min($,re)-c,0)/d*100:0,ne=Math.min(100,p?B/p:0),ie=oe-B,le=Math.min(100,1-p?ie/(1-p):0),P=n*60*1e3,N=d-P;return{elapsed:o?P:M,remaining:o?N:te,frozenBreakpoint:p,normalInnerPercent:ne,frozenInnerPercent:le,timeTravelElapsed:P,timeTravelRemaining:N,supportRegen:l.canRegenerateRanklist(e)}}const Z=">=0.3.0 <=0.3.13";function _e(e){return ae.default.satisfies(e,Z)}const Fe=280,je="srk-animated-modal-root",T="srk-scrolling-effect";let b=null,a=null,j=!1,m=0,A="",w="",R="",x="",C="",E="",D="",L="",h=0,S=0,v=1,s=[],Y=!1;function Ye(e){var r,n;if(e.key!=="Escape")return;const t=s[s.length-1];!t||((r=t.onEscape)==null||r.call(t,e),(n=e.stopImmediatePropagation)==null||n.call(e),e.stopPropagation())}function ze(){typeof document=="undefined"||Y||(document.addEventListener("keydown",Ye),Y=!0)}function He(){typeof document=="undefined"||j||(document.addEventListener("mousedown",e=>{a={x:e.clientX,y:e.clientY}},!0),document.addEventListener("touchstart",e=>{const t=e.touches[0]||e.changedTouches[0];!t||(a={x:t.clientX,y:t.clientY})},{capture:!0,passive:!0}),j=!0)}function G(e,t,r){b={x:e,y:t,timestamp:Date.now(),source:r==null?void 0:r.source,context:r==null?void 0:r.context}}function Ue(e,t){G(e.clientX,e.clientY,t)}function Q(e=500){return!b||Date.now()-b.timestamp>e?null:b}function Xe(){return a}function Ke(e){if(typeof window=="undefined"||!e)return{origin:{x:0,y:0},source:"fallback",explicitTriggerPoint:null,globalInteractionPoint:a,dialogRect:null,fallbackPoint:{x:0,y:0}};const t=e.getBoundingClientRect(),r={x:t.width/2,y:Math.min(t.height*.22,96)},n=Q();return n?{origin:{x:n.x-t.left,y:n.y-t.top},source:"explicit-trigger",explicitTriggerPoint:n,globalInteractionPoint:a,dialogRect:{left:t.left,top:t.top,width:t.width,height:t.height},fallbackPoint:r}:a?{origin:{x:a.x-t.left,y:a.y-t.top},source:"global-pointer",explicitTriggerPoint:null,globalInteractionPoint:a,dialogRect:{left:t.left,top:t.top,width:t.width,height:t.height},fallbackPoint:r}:{origin:r,source:"fallback",explicitTriggerPoint:null,globalInteractionPoint:null,dialogRect:{left:t.left,top:t.top,width:t.width,height:t.height},fallbackPoint:r}}function Je(){return typeof document=="undefined"?null:document.activeElement instanceof HTMLElement?document.activeElement:null}function ee(e){try{e.focus({preventScroll:!0})}catch{e.focus()}}function Ve(e,t={}){if(typeof document=="undefined"||!e)return null;ze();const r=s.find(c=>c.dialogElement===e);if(r)return r.onEscape=t.onEscape,r.id;const n=e.hasAttribute("tabindex"),o=e.getAttribute("tabindex");n||e.setAttribute("tabindex","-1");const i={id:v,dialogElement:e,restoreElement:Je(),hadTabIndex:n,previousTabIndex:o,onEscape:t.onEscape};return v+=1,s.push(i),ee(e),i.id}function We(e){var c;if(typeof document=="undefined"||e==null)return;const t=s.findIndex(u=>u.id===e);if(t===-1)return;const[r]=s.splice(t,1);if(r.hadTabIndex?r.previousTabIndex===null?r.dialogElement.removeAttribute("tabindex"):r.dialogElement.setAttribute("tabindex",r.previousTabIndex):r.dialogElement.removeAttribute("tabindex"),!(t===s.length))return;const o=s[s.length-1],i=(c=r.restoreElement)!=null&&c.isConnected?r.restoreElement:o==null?void 0:o.dialogElement;i&&ee(i)}function qe(e){var t;return e==null?!1:((t=s[s.length-1])==null?void 0:t.id)===e}function Ze(){typeof document!="undefined"&&(m===0&&(h=window.scrollX,S=window.scrollY,A=document.body.style.overflow,w=document.body.style.overflowX,R=document.body.style.overflowY,x=document.body.style.position,C=document.body.style.top,E=document.body.style.left,D=document.body.style.right,L=document.body.style.width,document.body.classList.add(T),document.body.style.overflow="hidden",document.body.style.overflowX="hidden",document.body.style.overflowY="hidden",document.body.style.position="fixed",document.body.style.top=`-${S}px`,document.body.style.left=`-${h}px`,document.body.style.right="0",document.body.style.width="100%"),m+=1)}function Ge(){if(!(typeof document=="undefined"||m===0)&&(m-=1,m===0&&(document.body.classList.remove(T),document.body.style.overflow=A,document.body.style.overflowX=w,document.body.style.overflowY=R,document.body.style.position=x,document.body.style.top=C,document.body.style.left=E,document.body.style.right=D,document.body.style.width=L,!(typeof navigator!="undefined"&&/jsdom/i.test(navigator.userAgent))&&typeof window.scrollTo=="function")))try{window.scrollTo(h,S)}catch{}}function Qe(){b=null,a=null,m=0,v=1,s=[],A="",w="",R="",x="",C="",E="",D="",L="",h=0,S=0,typeof document!="undefined"&&(document.body.classList.remove(T),document.body.style.overflow="",document.body.style.overflowX="",document.body.style.overflowY="",document.body.style.position="",document.body.style.top="",document.body.style.left="",document.body.style.right="",document.body.style.width="")}Object.defineProperty(exports,"convertToStaticRanklist",{enumerable:!0,get:function(){return l.convertToStaticRanklist}});exports.MODAL_ANIMATION_DURATION_MS=Fe;exports.SRK_ANIMATED_MODAL_ROOT_CLASS=je;exports.SRK_SCROLL_LOCK_BODY_CLASS=T;exports.buildSliderMarks=Ne;exports.calculateDirtPercentage=Pe;exports.calculateProblemStatisticsFooter=ve;exports.calculateSEValue=xe;exports.caniuse=_e;exports.captureModalTriggerPointFromMouseEvent=Ue;exports.defaultBackgroundColor=H;exports.ensureModalInteractionTracker=He;exports.formatProblemStatisticsAcceptedMinute=Ae;exports.formatProblemStatisticsAcceptedRange=ke;exports.formatProblemStatisticsAverageHardness=Re;exports.formatProblemStatisticsPercent=we;exports.formatRanklistStatusTime=f;exports.formatSolutionTimestamp=Ee;exports.formatTeamMemberName=ge;exports.getAcceptedStatusDetails=X;exports.getLastModalInteractionPoint=Xe;exports.getLastPenaltySolution=J;exports.getMarkerPresentation=me;exports.getProblemHeaderBackgroundImage=U;exports.getProblemHeaderBackgroundImageIfStyled=fe;exports.getProgressDurationMinutes=q;exports.getProgressMaxAvailableMinutes=$e;exports.getProgressMetrics=Oe;exports.getRankProblemStatusCellClassName=be;exports.getRankProblemStatusCellPresentation=ye;exports.getRankProblemStatusTries=k;exports.getRecentModalTriggerPoint=Q;exports.getSolutionModalTitle=Ce;exports.getSolutionResultMeta=pe;exports.isAcceptedRankProblemStatus=g;exports.isProgressEnded=Be;exports.isRejectedRankProblemStatus=K;exports.isTopModalFocusScope=qe;exports.lockModalBodyScroll=Ze;exports.registerModalFocusScope=Ve;exports.resetModalInteractionStateForTests=Qe;exports.resolveModalTransformOrigin=Ke;exports.resolveSrkAssetUrl=de;exports.setModalTriggerPoint=G;exports.shouldShowTimeColumn=De;exports.srkSupportedVersions=Z;exports.unlockModalBodyScroll=Ge;exports.unregisterModalFocusScope=We;
|
package/dist/index.js
CHANGED
|
@@ -33,6 +33,12 @@ function getProblemHeaderBackgroundImage(style, theme, gradientDirection = 180)
|
|
|
33
33
|
const bgColorAlphaStr = Color(resolvedColor).alpha(0.27).string();
|
|
34
34
|
return `linear-gradient(${gradientDirection}deg, ${bgColorStr} 0%, ${bgColorStr} 10%, ${bgColorAlphaStr} 10%, transparent 100%)`;
|
|
35
35
|
}
|
|
36
|
+
function getProblemHeaderBackgroundImageIfStyled(style, theme, gradientDirection = 180) {
|
|
37
|
+
if (!style || !resolveStyle(style).backgroundColor[theme]) {
|
|
38
|
+
return void 0;
|
|
39
|
+
}
|
|
40
|
+
return getProblemHeaderBackgroundImage(style, theme, gradientDirection);
|
|
41
|
+
}
|
|
36
42
|
function getMarkerPresentation(marker, theme) {
|
|
37
43
|
if (typeof marker.style === "string") {
|
|
38
44
|
return { className: `srk-preset-marker-${marker.style}` };
|
|
@@ -98,6 +104,30 @@ function isRejectedRankProblemStatus(status) {
|
|
|
98
104
|
function getRankProblemStatusTries(status) {
|
|
99
105
|
return (status == null ? void 0 : status.tries) || 0;
|
|
100
106
|
}
|
|
107
|
+
function getRankProblemStatusCellClassName(status, ranklist) {
|
|
108
|
+
if (!status.result) {
|
|
109
|
+
return void 0;
|
|
110
|
+
}
|
|
111
|
+
if (isPartialScoreRankProblemStatus(status, ranklist)) {
|
|
112
|
+
return "srk-prest-status-block-partial";
|
|
113
|
+
}
|
|
114
|
+
if (isFailedScoreRankProblemStatus(status, ranklist)) {
|
|
115
|
+
return "srk-prest-status-block-failed";
|
|
116
|
+
}
|
|
117
|
+
if (status.result === "FB") {
|
|
118
|
+
return "srk-prest-status-block-fb";
|
|
119
|
+
}
|
|
120
|
+
if (status.result === "AC") {
|
|
121
|
+
return "srk-prest-status-block-accepted";
|
|
122
|
+
}
|
|
123
|
+
if (status.result === "?") {
|
|
124
|
+
return "srk-prest-status-block-frozen";
|
|
125
|
+
}
|
|
126
|
+
if (status.result === "RJ") {
|
|
127
|
+
return "srk-prest-status-block-failed";
|
|
128
|
+
}
|
|
129
|
+
return void 0;
|
|
130
|
+
}
|
|
101
131
|
function getLastPenaltySolution(status, ranklist) {
|
|
102
132
|
const noPenaltyResults = getNoPenaltyResults(ranklist);
|
|
103
133
|
const solutions = status.solutions || [];
|
|
@@ -129,15 +159,15 @@ function getRankProblemStatusCellPresentation(status, ranklist, preset = "classi
|
|
|
129
159
|
if (!status.result) {
|
|
130
160
|
return {};
|
|
131
161
|
}
|
|
162
|
+
if (typeof status.score === "number") {
|
|
163
|
+
return {
|
|
164
|
+
score: status.score,
|
|
165
|
+
scoreDetails: getScoreStatusDetails(status, ranklist, preset)
|
|
166
|
+
};
|
|
167
|
+
}
|
|
132
168
|
if (preset === "classic") {
|
|
133
169
|
if (isAcceptedRankProblemStatus(status)) {
|
|
134
170
|
const details = getAcceptedStatusDetails(status);
|
|
135
|
-
if (typeof status.score === "number") {
|
|
136
|
-
return {
|
|
137
|
-
score: status.score,
|
|
138
|
-
scoreDetails: details
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
171
|
return { primary: details };
|
|
142
172
|
}
|
|
143
173
|
return {
|
|
@@ -183,6 +213,31 @@ function getRankProblemStatusCellPresentation(status, ranklist, preset = "classi
|
|
|
183
213
|
}
|
|
184
214
|
return {};
|
|
185
215
|
}
|
|
216
|
+
function isPartialScoreRankProblemStatus(status, ranklist) {
|
|
217
|
+
var _a;
|
|
218
|
+
return ((_a = ranklist.sorter) == null ? void 0 : _a.algorithm) === "score" && status.result !== "AC" && status.result !== "FB" && typeof status.score === "number" && status.score > 0;
|
|
219
|
+
}
|
|
220
|
+
function isFailedScoreRankProblemStatus(status, ranklist) {
|
|
221
|
+
var _a;
|
|
222
|
+
return ((_a = ranklist.sorter) == null ? void 0 : _a.algorithm) === "score" && status.result !== "AC" && status.result !== "FB" && typeof status.score === "number" && status.score === 0;
|
|
223
|
+
}
|
|
224
|
+
function getScoreStatusDetails(status, ranklist, preset) {
|
|
225
|
+
if (preset === "minimal") {
|
|
226
|
+
return void 0;
|
|
227
|
+
}
|
|
228
|
+
if (preset === "compact") {
|
|
229
|
+
return status.time ? formatRanklistStatusTime(status.time, ranklist) : void 0;
|
|
230
|
+
}
|
|
231
|
+
const time = status.time ? formatScoreStatusTime(status.time, ranklist, preset) : void 0;
|
|
232
|
+
const parts = [typeof status.tries === "number" ? String(status.tries) : void 0, time].filter((part) => part !== void 0);
|
|
233
|
+
return parts.length > 0 ? parts.join("/") : void 0;
|
|
234
|
+
}
|
|
235
|
+
function formatScoreStatusTime(time, ranklist, preset) {
|
|
236
|
+
if (preset === "detailed") {
|
|
237
|
+
return formatRanklistStatusTime(time, ranklist);
|
|
238
|
+
}
|
|
239
|
+
return `${formatTimeDuration(time, "min", Math.floor)}min`;
|
|
240
|
+
}
|
|
186
241
|
function calculateDirtPercentage(row) {
|
|
187
242
|
const totals = row.statuses.reduce((result, status) => {
|
|
188
243
|
if (!isAcceptedRankProblemStatus(status)) {
|
|
@@ -682,4 +737,4 @@ function resetModalInteractionStateForTests() {
|
|
|
682
737
|
document.body.style.width = "";
|
|
683
738
|
}
|
|
684
739
|
}
|
|
685
|
-
export { MODAL_ANIMATION_DURATION_MS, SRK_ANIMATED_MODAL_ROOT_CLASS, SRK_SCROLL_LOCK_BODY_CLASS, buildSliderMarks, calculateDirtPercentage, calculateProblemStatisticsFooter, calculateSEValue, caniuse, captureModalTriggerPointFromMouseEvent, defaultBackgroundColor, ensureModalInteractionTracker, formatProblemStatisticsAcceptedMinute, formatProblemStatisticsAcceptedRange, formatProblemStatisticsAverageHardness, formatProblemStatisticsPercent, formatRanklistStatusTime, formatSolutionTimestamp, formatTeamMemberName, getAcceptedStatusDetails, getLastModalInteractionPoint, getLastPenaltySolution, getMarkerPresentation, getProblemHeaderBackgroundImage, getProgressDurationMinutes, getProgressMaxAvailableMinutes, getProgressMetrics, getRankProblemStatusCellPresentation, getRankProblemStatusTries, getRecentModalTriggerPoint, getSolutionModalTitle, getSolutionResultMeta, isAcceptedRankProblemStatus, isProgressEnded, isRejectedRankProblemStatus, isTopModalFocusScope, lockModalBodyScroll, registerModalFocusScope, resetModalInteractionStateForTests, resolveModalTransformOrigin, resolveSrkAssetUrl, setModalTriggerPoint, shouldShowTimeColumn, srkSupportedVersions, unlockModalBodyScroll, unregisterModalFocusScope };
|
|
740
|
+
export { MODAL_ANIMATION_DURATION_MS, SRK_ANIMATED_MODAL_ROOT_CLASS, SRK_SCROLL_LOCK_BODY_CLASS, buildSliderMarks, calculateDirtPercentage, calculateProblemStatisticsFooter, calculateSEValue, caniuse, captureModalTriggerPointFromMouseEvent, defaultBackgroundColor, ensureModalInteractionTracker, formatProblemStatisticsAcceptedMinute, formatProblemStatisticsAcceptedRange, formatProblemStatisticsAverageHardness, formatProblemStatisticsPercent, formatRanklistStatusTime, formatSolutionTimestamp, formatTeamMemberName, getAcceptedStatusDetails, getLastModalInteractionPoint, getLastPenaltySolution, getMarkerPresentation, getProblemHeaderBackgroundImage, getProblemHeaderBackgroundImageIfStyled, getProgressDurationMinutes, getProgressMaxAvailableMinutes, getProgressMetrics, getRankProblemStatusCellClassName, getRankProblemStatusCellPresentation, getRankProblemStatusTries, getRecentModalTriggerPoint, getSolutionModalTitle, getSolutionResultMeta, isAcceptedRankProblemStatus, isProgressEnded, isRejectedRankProblemStatus, isTopModalFocusScope, lockModalBodyScroll, registerModalFocusScope, resetModalInteractionStateForTests, resolveModalTransformOrigin, resolveSrkAssetUrl, setModalTriggerPoint, shouldShowTimeColumn, srkSupportedVersions, unlockModalBodyScroll, unregisterModalFocusScope };
|
package/dist/ranklist.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export interface RanklistStatusCellPresentation {
|
|
|
41
41
|
}
|
|
42
42
|
export declare function resolveSrkAssetUrl(url: string, field: string, formatter?: (url: string, field: string) => string): string;
|
|
43
43
|
export declare function getProblemHeaderBackgroundImage(style: srk.Style | undefined, theme: EnumTheme, gradientDirection?: number): string;
|
|
44
|
+
export declare function getProblemHeaderBackgroundImageIfStyled(style: srk.Style | undefined, theme: EnumTheme, gradientDirection?: number): string | undefined;
|
|
44
45
|
export declare function getMarkerPresentation(marker: srk.Marker, theme: EnumTheme): MarkerPresentation;
|
|
45
46
|
export declare function formatTeamMemberName(member: srk.ExternalUser, languages?: readonly string[]): string;
|
|
46
47
|
export declare function getSolutionResultMeta(result: srk.Solution['result']): SolutionResultMeta;
|
|
@@ -48,6 +49,7 @@ export declare function getAcceptedStatusDetails(status: srk.RankProblemStatus):
|
|
|
48
49
|
export declare function isAcceptedRankProblemStatus(status: srk.RankProblemStatus | undefined): boolean;
|
|
49
50
|
export declare function isRejectedRankProblemStatus(status: srk.RankProblemStatus | undefined): boolean;
|
|
50
51
|
export declare function getRankProblemStatusTries(status: srk.RankProblemStatus | undefined): number;
|
|
52
|
+
export declare function getRankProblemStatusCellClassName(status: srk.RankProblemStatus, ranklist: srk.Ranklist): string | undefined;
|
|
51
53
|
export declare function getLastPenaltySolution(status: srk.RankProblemStatus, ranklist: srk.Ranklist): srk.Solution | undefined;
|
|
52
54
|
export declare function formatRanklistStatusTime(time: srk.TimeDuration | undefined, ranklist: srk.Ranklist): string;
|
|
53
55
|
export declare function getRankProblemStatusCellPresentation(status: srk.RankProblemStatus, ranklist: srk.Ranklist, preset?: RanklistStatusCellPreset): RanklistStatusCellPresentation;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@algoux/standard-ranklist-renderer-component-core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.4",
|
|
4
4
|
"description": "Core helpers and shared types for Standard Ranklist Renderer Component",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://github.com/algoux/standard-ranklist-renderer-component",
|