1import S from"./CC_CyKVM.js";import{_ as P}from"./C7m1Q1fO.js";import{C as B,$ as C}from"./BM8Wk4t6.js";import{C as T}from"./BBRqke0y.js";import{_ as I,c as u,o as p,f as t,A as y,t as l,b as g,w,B as f,d as R,l as $,m as M,ak as F,F as z,r as O}from"./C8OjvWdH.js";import"./CytzSlOG.js";import"./CRrUdjPr.js";import"./BdDUjuwf.js";typeof window<"u"&&(window.$=window.jQuery=C);function E(s){return s.replace(/\d+\.(\.\.)?/g,"").replace(/\{[^}]*\}/g,"").replace(/\s+/g," ").trim().split(" ").filter(e=>e&&!["1-0","0-1","1/2-1/2","\xBD-\xBD","*"].includes(e))}const j={props:{pairing:{type:Object,required:!1},boardId:{type:String,required:!1}},data(){return{chess:null,board:null,currentMoveIndex:-1,moveSound:null,captureSound:null,resizeObserver:null,gameResult:null,isWhitesTurnToPlay:!0,selectedBoardColor:"#9f4152",selectedColorName:"Default",selectedPieceSet:"default",isPieceDropdownOpen:!1,boardColors:[{name:"ChessTV Rosewood",value:"#9f4152"},{name:"Green",value:"#008000"},{name:"Sky Blue",value:"#00BFFF"},{name:"Orange",value:"#FF8C00"},{name:"Cyan",value:"#00FFFF"}],pieceSets:[{name:"Default",value:"default"},{name:"Alpha",value:"alpha"}]}},computed:{pgnMoves(){return this.pairing.game.pgnMoves?E(this.pairing.game.pgnMoves):[]},movesByTurn(){return this.isBoardReversed?this.pgnMoves.map((s,e)=>({white:this.pgnMoves[e+1]||"",black:this.pgnMoves[e]||""})).filter((s,e)=>e%2===0):this.pgnMoves.map((s,e)=>({white:this.pgnMoves[e]||"",black:this.pgnMoves[e+1]||""})).filter((s,e)=>e%2===0)}},watch:{selectedPieceSet(){this.initializeBoard()},"pairing.game.pgnMoves"(){this.showLatestPosition()},"pairing.result"(){this.updateDisplayedResult()},"pairing.game.result"(){this.updateDisplayedResult()}},mounted(){this.chess=new T;const s={wK:`/img/pieces/${this.selectedPieceSet}/wK.svg`,wQ:`/img/pieces/${this.selectedPieceSet}/wQ.svg`,wR:`/img/pieces/${this.selectedPieceSet}/wR.svg`,wB:`/img/pieces/${this.selectedPieceSet}/wB.svg`,wN:`/img/pieces/${this.selectedPieceSet}/wN.svg`,wP:`/img/pieces/${this.selectedPieceSet}/wP.svg`,bK:`/img/pieces/${this.selectedPieceSet}/bK.svg`,bQ:`/img/pieces/${this.selectedPieceSet}/bQ.svg`,bR:`/img/pieces/${this.selectedPieceSet}/bR.svg`,bB:`/img/pieces/${this.selectedPieceSet}/bB.svg`,bN:`/img/pieces/${this.selectedPieceSet}/bN.svg`,bP:`/img/pieces/${this.selectedPieceSet}/bP.svg`};this.board=B(this.boardId,{position:"start",showNotation:!1,pieceTheme:i=>s[i]||""}),this.applyBoardColors(),this.showLatestPosition();const e=document.getElementById(this.boardId);e&&"ResizeObserver"in window?(this.resizeObserver=new ResizeObserver(this.resizeBoard),this.resizeObserver.observe(e.parentElement||e)):window.addEventListener("resize",this.resizeBoard)},beforeUnmount(){var s,e,i;(s=this.resizeObserver)==null||s.disconnect(),window.removeEventListener("resize",this.resizeBoard),(i=(e=this.board)==null?void 0:e.destroy)==null||i.call(e)},methods:{backendResult(){var s,e,i;const o=((s=this.pairing)==null?void 0:s.result)||((i=(e=this.pairing)==null?void 0:e.game)==null?void 0:i.result);return o&&o!=="*"?o:null},updateDisplayedResult(){this.gameResult=this.backendResult()},showLatestPosition(){if(!this.chess||!this.board)return;this.chess.reset();let s=null,e=0;for(const i of this.pgnMoves)try{const o=this.chess.move(i);if(!o)break;s=o,e++}catch{break}this.currentMoveIndex=s?e-1:-1,this.isWhitesTurnToPlay=this.chess.turn()==="w",this.board.position(this.chess.fen(),!1),this.applyBoardColors(),this.updateDisplayedResult(),!this.gameResult&&this.chess.isGameOver()&&(this.chess.isCheckmate()?this.gameResult=this.chess.turn()==="w"?"0-1":"1-0":this.gameResult="\xBD-\xBD")},resizeBoard(){this.board&&this.board.resize(),this.applyBoardColors()},getBoardPalette(){return document.documentElement.classList.contains("dark")||document.body.classList.contains("dark")?{light:"#cbbda8",dark:"#7b2942"}:{light:"#f3eadc",dark:this.selectedBoardColor}},applyBoardColors(){this.$nextTick(()=>{const s=document.getElementById(this.boardId);if(s){const e=this.getBoardPalette(),i=s.querySelectorAll(".white-1e1d7, .w-square"),o=s.querySelectorAll(".black-3c85d, .b-square");
1i.forEach(n=>{n.style.backgroundColor=e.light}),o.forEach(n=>{n.style.backgroundColor=e.dark})}})},initializeBoard(){this.board&&this.board.destroy(),this.applyBoardColors()},formatTime(s){const e=Math.floor(s/60),i=s%60;return e>0?`${e}:${i.toString().padStart(2,"0")}`:`0:${i.toString().padStart(2,"0")}`},getTextColor(s){const e=parseInt(s.substring(1,3),16),i=parseInt(s.substring(3,5),16),o=parseInt(s.substring(5,7),16);return(e*299+i*587+o*114)/1e3>125?"#000000":"#FFFFFF"},playMoves(){this.chess.reset();let s;for(let e=0;e<=this.currentMoveIndex;e++)s=this.chess.move(this.pgnMoves[e]);s&&this.playMoveSound(s),this.isWhitesTurnToPlay=this.currentMoveIndex%2===1,this.board.position(this.chess.fen()),this.applyBoardColors(),this.chess.isGameOver()?this.chess.isCheckmate()?this.gameResult=this.chess.turn()==="w"?"0-1":"1-0":(this.chess.isStalemate()||this.chess.isDraw()||this.chess.isThreefoldRepetition()||this.chess.isInsufficientMaterial())&&(this.gameResult="\xBD-\xBD"):this.gameResult=null},goToSpecificMove(s){this.isWhitesTurnToPlay=this.chess.turn()==="w",this.isEngineMoveHighlighted=!1,this.currentMoveIndex=s,this.playMoves()},goToStartOfTheGame(){this.goToSpecificMove(-1)},goToEndOfTheGame(){this.goToSpecificMove(this.pgnMoves.length-1)},toggleSound(){this.isMuted=!this.isMuted},playMoveSound(s){this.isMuted||(s.captured?(this.captureSound||(this.captureSound=new Audio("/sounds/capture.mp3")),this.captureSound.play()):(this.moveSound||(this.moveSound=new Audio("/sounds/move.mp3")),this.moveSound.play()))},goToPreviousMove(){this.currentMoveIndex>0&&(this.isEngineMoveHighlighted=!1,this.currentMoveIndex--,this.playMoves())},goToNextMove(){this.currentMoveIndex<this.pgnMoves.length-1&&(this.isEngineMoveHighlighted=!1,this.currentMoveIndex++,this.playMoves())},isWhiteMoveHighlighted(s){return this.currentMoveIndex===s*2},isBlackMoveHighlighted(s){return this.currentMoveIndex===s*2+1}}},_={class:"flex flex-col"},G={class:"min-w-0 space-y-2 rounded-md border border-slate-200 bg-white p-2 dark:border-slate-800 dark:bg-slate-900 sm:space-y-3 sm:p-3"},N={class:"flex flex-col items-center space-y-3"},D={class:"relative overflow-hidden rounded-md border border-slate-200 bg-white dark:border-slate-800 dark:bg-slate-950"},L=["id"],q={key:0,class:"absolute inset-0 flex items-center justify-center bg-slate-950/75 text-2xl font-black text-white"},A={class:"flex w-full items-center justify-center gap-2 overflow-hidden text-xs font-black text-slate-800 dark:text-slate-100"},H={class:"max-w-[45%] truncate whitespace-nowrap text-center"},Q={class:"max-w-[45%] truncate whitespace-nowrap text-center"},W={class:"mt-1 flex items-center justify-center gap-1"};function K(s,e,i,o,n,h){const m=S,b=P;return p(),u("div",_,[t("div",G,[t("div",N,[t("div",D,[t("div",{id:i.boardId,class:"aspect-square w-[min(70vw,220px)] max-w-full sm:w-[200px]"},null,8,L),n.gameResult?(p(),u("div",q,l(n.gameResult),1)):y("",!0)]),t("div",A,[t("span",H,l(i.pairing.players[0].name)+" "+l(i.pairing.players[0].surname),1),e[0]||(e[0]=t("span",{class:"text-gray-500 dark:text-gray-400"},"\u2014",-1)),t("span",Q,l(i.pairing.players[1].name)+" "+l(i.pairing.players[1].surname),1)]),t("div",W,[g(b,{onClick:f(h.goToStartOfTheGame,["stop"]),disabled:n.currentMoveIndex<=0,class:"m-0 h-8 w-8 rounded-md bg-slate-950 p-0 text-white hover:bg-slate-800 disabled:cursor-not-allowed disabled:opacity-40 dark:bg-slate-100 dark:text-slate-950 dark:hover:bg-white"},{default:w(()=>[g(m,{name:"mdi:chevron-double-left",class:"w-4 h-4"})]),_:1},8,["onClick","disabled"]),g(b,{onClick:f(h.goToPreviousMove,["stop"]),disabled:n.currentMoveIndex<=0,class:"m-0 h-8 w-8 rounded-md bg-rose-700 p-0 text-white hover:bg-rose-800 disabled:cursor-not-allowed disabled:opacity-40 dark:bg-rose-600 dar
1k:hover:bg-rose-500"},{default:w(()=>[g(m,{name:"mdi:chevron-left",class:"w-4 h-4"})]),_:1},8,["onClick","disabled"]),g(b,{onClick:f(h.goToNextMove,["stop"]),disabled:n.currentMoveIndex>=h.pgnMoves.length-1,class:"m-0 h-8 w-8 rounded-md bg-rose-700 p-0 text-white hover:bg-rose-800 disabled:cursor-not-allowed disabled:opacity-40 dark:bg-rose-600 dark:hover:bg-rose-500"},{default:w(()=>[g(m,{name:"mdi:chevron-right",class:"w-4 h-4"})]),_:1},8,["onClick","disabled"]),g(b,{onClick:f(h.goToEndOfTheGame,["stop"]),disabled:n.currentMoveIndex>=h.pgnMoves.length-1,class:"m-0 h-8 w-8 rounded-md bg-slate-950 p-0 text-white hover:bg-slate-800 disabled:cursor-not-allowed disabled:opacity-40 dark:bg-slate-100 dark:text-slate-950 dark:hover:bg-white"},{default:w(()=>[g(m,{name:"mdi:chevron-double-right",class:"w-4 h-4"})]),_:1},8,["onClick","disabled"])])])])])}const U=I(j,[["render",K],["__scopeId","data-v-1205852e"]]),V={class:"overflow-hidden rounded-lg border border-slate-200 bg-white shadow-sm dark:border-slate-800 dark:bg-slate-900"},J={class:"flex flex-row items-end justify-between gap-3 border-b border-slate-200 bg-[#fffaf2] p-3 dark:border-slate-800 dark:bg-slate-950 sm:gap-4 sm:p-4"},X={class:"inline-flex shrink-0 items-center rounded-md border border-indigo-100 bg-white px-2 py-1.5 text-xs font-black text-indigo-800 dark:border-indigo-900 dark:bg-slate-900 dark:text-indigo-200 sm:px-3 sm:py-2 sm:text-sm"},Y={key:0,class:"grid min-w-0 grid-cols-[minmax(0,1fr)] gap-3 p-2 sm:grid-cols-2 sm:gap-4 sm:p-4 lg:grid-cols-3 2xl:grid-cols-4"},Z=["onClick"],ee={class:"flex items-center justify-between border-b border-slate-200 bg-white p-3 dark:border-slate-800 dark:bg-slate-900"},se={class:"inline-flex h-9 min-w-9 items-center justify-center rounded-md bg-slate-950 px-2 text-sm font-black text-white dark:bg-white dark:text-slate-950"},te={class:"inline-flex min-w-16 justify-center rounded-md bg-indigo-50 px-3 py-2 text-sm font-black text-indigo-800 dark:bg-indigo-500/10 dark:text-indigo-200"},ie={class:"space-y-3 p-3"},re={class:"flex min-w-0 items-center gap-3"},ae={class:"truncate text-sm font-black text-slate-950 dark:text-white"},oe={class:"mt-2 flex min-w-0 items-center gap-3"},le={class:"truncate text-sm font-black text-slate-950 dark:text-white"},ne={class:"px-3 pb-3"},de={class:"mb-3 flex items-center justify-between rounded-md bg-white px-3 py-2 text-sm dark:bg-slate-900"},ce={class:"font-black text-slate-950 dark:text-white"},he={class:"rounded-md border border-slate-200 bg-white p-2 dark:border-slate-800 dark:bg-slate-900"},ge={key:1,class:"border-t border-slate-200 p-4 text-center dark:border-slate-800"},ue={class:"mt-2 text-xs font-semibold text-slate-500 dark:text-slate-400"},pe={key:2,class:"p-8 text-center"},x=8,me=R({__name:"RoundGamesGrid",props:{pairings:{},selectPairing:{type:Function}},setup(s){const e=s,i=$(x),o=M(()=>e.pairings.slice(0,i.value)),n=M(()=>o.value.length<e.pairings.length);F(()=>e.pairings,()=>{i.value=x});function h(d,r){var c;const a=(c=d.players)==null?void 0:c[r];return[a==null?void 0:a.name,a==null?void 0:a.surname].filter(Boolean).join(" ")||"Player"}function m(d){var r;const c=d.result||((r=d.game)==null?void 0:r.result);return c&&c!=="*"?c:null}function b(d){var r,c;const a=(c=(r=d.game)==null?void 0:r.pgnMoves)==null?void 0:c.replace(/\d+\.(\.\.)?/g,"").replace(/\{[^}]*\}/g,"").replace(/\s+/g," ").trim().split(" ").filter(v=>v&&!["1-0","0-1","1/2-1/2","*"].includes(v));return(a==null?void 0:a.length)||0}return(d,r)=>{const c=U;return p(),u("section",V,[t("div",J,[r[1]||(r[1]=t("div",null,[t("p",{class:"text-xs font-bold uppercase tracking-wide text-rose-700 dark:text-rose-300"}," Boards "),t("h2",{class:"mt-1 text-xl font-black text-slate-950 dark:text-white"},"Round games")],-1)),t("div",X,l(d.pairings.length)+" games ",1)]),d.pairings.length?(p(),u("div",Y,[(p(!0),u(z,null,O(o.value,(a,v)=>(p(),u("article",{key:a.id||v,class:"min-w-0 cursor-pointer overflow-hidden rounded-lg border border-slate-200 bg-slate-50 shadow-sm transition hover:-translate-y-0.5 hover:border-rose-200 hover:bg-rose-50/70 hover:shadow-md dark:border-slate-800 dark:bg-slate-950/60 dark:hover:border-rose-900 dark:hover:bg-rose-950/20",onClick:be=>{var k;
1return(k=d.selectPairing)==null?void 0:k.call(d,a)}},[t("div",ee,[t("span",se,l(v+1),1),t("span",te,l(m(a)||"*"),1)]),t("div",ie,[t("div",re,[r[2]||(r[2]=t("span",{class:"h-3 w-3 rounded-full bg-white ring-1 ring-slate-300 dark:ring-slate-500"},null,-1)),t("p",ae,l(h(a,0)),1)]),t("div",oe,[r[3]||(r[3]=t("span",{class:"h-3 w-3 rounded-full bg-black ring-1 ring-black dark:bg-black dark:ring-slate-400"},null,-1)),t("p",le,l(h(a,1)),1)])]),t("div",ne,[t("div",de,[r[4]||(r[4]=t("span",{class:"font-bold text-slate-500 dark:text-slate-400"},"Moves",-1)),t("span",ce,l(b(a)),1)]),t("div",he,[g(c,{pairing:a,"board-id":`board-${v}`},null,8,["pairing","board-id"])])])],8,Z))),128))])):y("",!0),n.value?(p(),u("div",ge,[t("button",{type:"button",class:"inline-flex h-10 items-center justify-center rounded-md bg-rose-700 px-5 text-sm font-black text-white transition hover:bg-rose-800 dark:bg-rose-600 dark:hover:bg-rose-500",onClick:r[0]||(r[0]=a=>i.value+=x)}," Load more games "),t("p",ue," Showing "+l(o.value.length)+" of "+l(d.pairings.length)+" games ",1)])):(p(),u("div",pe,r[5]||(r[5]=[t("p",{class:"text-sm font-semibold text-slate-500 dark:text-slate-400"}," No games are available for this round yet. ",-1)])))])}}});export{me as default};
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.