@xcpcio/board-app
Version:
XCPCIO Board App
2 lines (1 loc) • 3.89 kB
JavaScript
import{u as V}from"./index-DXMw63yv.js";import{k as X,h as j}from"./index-BYh7ktqe.js";import{C as i}from"./index-BNZRV8LR.js";import{d as U,f as R,p as n,W as H,D as J,c as v,o as g,b as m,K as N,n as D,h as x,s as E,F as K,k as b}from"./index-CYsJ2gG-.js";import{_ as z}from"./_plugin-vue_export-helper-DlAUqK2U.js";const Q=U({__name:"Progress",props:{width:null,state:null,needScroll:{type:Boolean},rank:null,rankOptions:null,elapsedTime:null},emits:["update:rank-options"],setup(S,{emit:s}){const t=S,M=s,h=R({get(){return t.rankOptions},set(a){M("update:rank-options",a)}}),I=R(()=>{switch(t.state){case i.PENDING:return"am-progress-bar-secondary";case i.RUNNING:return"am-progress-bar-success";case i.FROZEN:return"am-progress-bar-danger";case i.FINISHED:return"am-progress-bar-primary";case i.PAUSED:return"am-progress-bar-danger"}return""}),o=n(!1),T=n(!1),d=n(0),_=n(t.width),W=n(0),p=V("progress-ratio",-1,{transform:Number}),l=n(null),L=n(null),f=n(null),w=n(null),O=n(null);function $(a){T.value=!0;const r=a.clientX-f.value.offsetLeft,k=u=>{var P,F;if(!T.value)return;o.value=!0;let e=u.clientX-r;e=Math.max(e,0),e=Math.min(e,l.value.offsetWidth-f.value.offsetWidth);const C=l.value.offsetWidth*Number.parseInt((P=L.value.style)==null?void 0:P.width)*.01;e>=C&&(e=C,o.value=!1);let c=0;e>0&&(c=Math.round((e+f.value.offsetWidth)/l.value.offsetWidth*1e4)),c>1e4&&(c=1e4),c===1e4&&(o.value=!1),(F=window.getSelection())==null||F.removeAllRanges(),d.value=c,W.value=e,_.value=c*.01},y=()=>{var u,e;document.removeEventListener("mouseup",y),document.removeEventListener("mousemove",k),T.value=!1,o.value===!0?(p.value=d.value,(u=h.value)==null||u.setWidth(d.value,t.rank.contest)):(p.value=void 0,(e=h.value)==null||e.disableFilterSubmissionByTimestamp())};document.addEventListener("mousemove",k),document.addEventListener("mouseup",y)}function A(){const a=t.rank.contest.getStartTime(),r=t.rank.contest.getEndTime(),k=r.unix()-a.unix(),y=Math.floor(k*_.value*.01),u=X(),e=Math.max(0,Math.min(u.unix(),r.unix())-a.unix());return j(Math.min(y,e))}function G(){return o.value===!0?A():t.elapsedTime}function B(){return o.value===!0?`${Math.max(0,W.value)}px`:`max(calc(0%), min(calc(${t.width}%), calc(100% - 10px)))`}return H(()=>{var a,r;t.needScroll===!0&&(l.value.onmouseenter=()=>{w.value.classList.add("in")},l.value.onmouseleave=()=>{w.value.classList.remove("in")}),p.value!==-1?(o.value=!0,d.value=Math.max(0,Math.min(1e4,p.value)),_.value=d.value*.01,W.value=_.value*.01*l.value.offsetWidth-f.value.offsetWidth,(a=h.value)==null||a.setWidth(p.value,t.rank.contest)):(r=h.value)==null||r.disableFilterSubmissionByTimestamp()}),J(()=>{}),(a,r)=>(g(),v("div",{ref_key:"scroll",ref:l,class:"am-progress am-progress-striped am-active","w-full":"",style:{position:"relative"}},[m("div",{ref_key:"mask",ref:L,class:D(["am-progress-bar",[x(I)]]),style:N({width:`${t.width}%`})},[t.needScroll?(g(),v(K,{key:0},[m("div",{ref_key:"tooltip",ref:w,class:"tooltip tooltip-top",style:N({marginLeft:"-32px",bottom:"22px",left:B()})},[m("div",{ref_key:"tooltipInner",ref:O,class:"tooltip-inner"},b(G()),513)],4),m("div",{ref_key:"bar",ref:f,class:D(["am-progress-bar am-progress-cursor am-progress-scroll-size z-99",[x(I)]]),style:N({left:B()}),onMousedown:$},null,38)],64)):E("",!0)],6)],512))}}),oe=z(Q,[["__scopeId","data-v-a7e62f42"]]),Z={flex:"","flex-row":"","items-center":"","justify-center":""},q={key:0,"ml-2":""},Y={key:1,"ml-2":""},ee=U({__name:"ContestStateBadge",props:{state:null,pendingTime:null,pausedTime:null},setup(S){const s=S;return(t,M)=>(g(),v("div",Z,[m("div",{class:D(["label",s.state])},null,2),m("div",null,b(s.state),1),s.pendingTime&&s.state===x(i).PENDING?(g(),v("div",q,b(s.pendingTime),1)):E("",!0),s.pausedTime&&s.state===x(i).PAUSED?(g(),v("div",Y,b(s.pausedTime),1)):E("",!0)]))}}),le=z(ee,[["__scopeId","data-v-68586c4d"]]);export{le as _,oe as a};