k-l-lambda commited on
Commit
f2d331b
·
1 Parent(s): 876d29c

Deploy: add startup logging to debug VS People mode

Browse files
trigo-web/app/dist/assets/{index-C0GpWl8S.js → index-CxJ9O80R.js} RENAMED
@@ -6496,7 +6496,7 @@ Game continues for analysis.`:ge=`Game is a draw!
6496
 
6497
  Both players: ${Yt} points
6498
 
6499
- Game continues for analysis.`}setTimeout(()=>{alert(ge)},100)},Nn=()=>{if(!Oe.value)return;if(wn.value){ne&&ne.hideDomainCubes(),wn.value=!1,ce.value=0,Ie.value=0;return}const z=r.computeTerritory();if(ce.value=z.black+c.value.black,Ie.value=z.white+c.value.white,wn.value=!0,ne){const ge=new Set,Nt=new Set;z.blackTerritory.forEach(Yt=>{const En=`${Yt.x},${Yt.y},${Yt.z}`;ge.add(En)}),z.whiteTerritory.forEach(Yt=>{const En=`${Yt.x},${Yt.y},${Yt.z}`;Nt.add(En)}),ne.setDomainData(ge,Nt),ne.setBlackDomainVisible(!0),ne.setWhiteDomainVisible(!0)}console.log("Territory computed:",z)},Te=()=>{r.undoMove()&&ne&&zt()},xn=()=>{r.redoMove()&&ne&&zt()},lt=z=>{r.jumpToMove(z)&&ne&&(zt(),ne.hideDomainCubes(),wn.value=!1,ce.value=0,Ie.value=0)},zt=()=>{if(!ne)return;ne.clearBoard();const z=r.board,ge=d.value;for(let Nt=0;Nt<ge.x;Nt++)for(let Yt=0;Yt<ge.y;Yt++)for(let En=0;En<ge.z;En++){const In=z[Nt][Yt][En];In===Stone.Black?ne.addStone(Nt,Yt,En,"black"):In===Stone.White&&ne.addStone(Nt,Yt,En,"white")}if(l.value>0&&l.value<=a.value.length){const Nt=a.value[l.value-1];ne.setLastPlacedStone(Nt.x,Nt.y,Nt.z)}else ne.setLastPlacedStone(null,null,null)},bn=computed(()=>y.playerColor?y.playerColor==="black"?"white":"black":null),Pn=computed(()=>o.value===y.playerColor),Rn=computed(()=>y.connectionStatus==="in-room"?"connected":"disconnected"),Vn=computed(()=>y.connectionStatus==="in-room"?"Connected":y.connectionStatus==="connected"?"Joining room...":"Disconnected"),ri=computed(()=>y.connectionStatus==="in-room"?"🟢":y.connectionStatus==="connected"?"🟡":"🔴"),zn=z=>{if(!y.setNickname(z)){console.error("Failed to update nickname");return}y.isInRoom&&v.changeNickname(z,Nt=>{Nt.success||(console.error("Failed to broadcast nickname change:",Nt.error),alert(`Failed to change nickname: ${Nt.error}`))})},ai=()=>{y.roomId&&navigator.clipboard.writeText(y.roomId).then(()=>alert("Room code copied to clipboard!")).catch(z=>console.error("Failed to copy room code:",z))};async function ei(z=5e3){return new Promise((ge,Nt)=>{if(v.socket.connected){ge();return}const Yt=setInterval(()=>{v.socket.connected&&(clearInterval(Yt),clearTimeout(En),ge())},100),En=setTimeout(()=>{clearInterval(Yt),Nt(new Error("Socket connection timeout"))},z)})}function mi(){console.log("[TrigoView] fetchRoomList() called, socket connected:",v.socket.connected,"socket id:",v.socket.id),R.value=!0,v.listRooms(z=>{console.log("[TrigoView] listRooms response:",z),R.value=!1,z.success?($.value=z.rooms||[],console.log("[TrigoView] Room list updated, count:",$.value.length,"rooms:",$.value.map(ge=>ge.id))):console.error("[TrigoView] listRooms failed:",z.error)})}function wi(){console.log("[TrigoView] Setting up room listeners, socket connected:",v.socket.connected,"socket id:",v.socket.id),v.onRoomCreated(z=>{console.log("[TrigoView] >>> Received roomCreated event:",z),console.log("[TrigoView] Current roomList before add:",JSON.stringify($.value)),$.value.find(ge=>ge.id===z.id)||($.value=[...$.value,z],console.log("[TrigoView] Added room to list, new count:",$.value.length,"rooms:",$.value.map(ge=>ge.id)))}),v.onRoomUpdated(z=>{console.log("[TrigoView] >>> Received roomUpdated event:",z);const ge=$.value.findIndex(Nt=>Nt.id===z.id);ge>=0?$.value=[...$.value.slice(0,ge),z,...$.value.slice(ge+1)]:$.value=[...$.value,z],console.log("[TrigoView] roomList after update:",$.value.map(Nt=>Nt.id))}),v.onRoomDeleted(z=>{console.log("[TrigoView] >>> Received roomDeleted event:",z),$.value=$.value.filter(ge=>ge.id!==z.roomId),console.log("[TrigoView] roomList after delete:",$.value.map(ge=>ge.id))})}function Ti(){v.offRoomCreated(),v.offRoomUpdated(),v.offRoomDeleted()}async function gi(z){y.roomId!==z&&(y.roomId&&(v.leaveRoom(),y.leaveRoom()),await _i(z))}async function Ci(){y.roomId&&(v.leaveRoom(),y.leaveRoom()),w(),await ui()}async function di(){if(console.log("[TrigoView] ========== INITIALIZE MULTIPLAYER ROOM =========="),console.log("[TrigoView] isJoiningRoom:",C.value),console.log("[TrigoView] Socket connected:",v.socket.connected),console.log("[TrigoView] Socket ID:",v.socket.id),C.value){console.log("[TrigoView] Already joining, skipping");return}const z=_();console.log("[TrigoView] hashRoomId from URL:",z),z?M(z)?(console.log("[TrigoView] Valid hash found, joining room:",z),await _i(z)):(console.warn(`[TrigoView] Invalid room ID in hash: ${z}`),w(),await ui()):(console.log("[TrigoView] No hash found, creating new room"),await ui())}async function ui(){if(console.log("[TrigoView] createAndJoinRoom called, isJoiningRoom:",C.value),C.value){console.log("[TrigoView] Already joining, returning");return}C.value=!0,console.log("[TrigoView] Set isJoiningRoom to true");try{console.log("[TrigoView] Waiting for socket connection..."),await ei(),console.log("[TrigoView] Socket connection ready, calling joinRoom"),v.joinRoom({nickname:y.nickname},z=>{console.log("[TrigoView] joinRoom callback received:",z),C.value=!1,z.success!==!1&&z.roomId?(y.joinRoom(z.roomId,z.playerColor),x(z.roomId),console.log(`[TrigoView] Room created: ${z.roomId}`)):(console.error("[TrigoView] Failed to create room:",z.error),alert("Failed to create room. Please try again."))})}catch(z){C.value=!1,console.error("[TrigoView] Socket connection failed:",z),alert("Connection failed. Please check your internet and try again.")}}async function _i(z){if(!C.value){C.value=!0;try{await ei(),v.joinRoom({roomId:z,nickname:y.nickname},ge=>{if(C.value=!1,ge.success!==!1&&ge.roomId){if(y.joinRoom(ge.roomId,ge.playerColor),console.log(`[TrigoView] Room joined: ${ge.roomId}`),ge.players&&v.socket.id){for(const[Yt,En]of Object.entries(ge.players))if(Yt!==v.socket.id){y.setOpponentNickname(En.nickname),console.log(`[TrigoView] Opponent found: ${En.nickname}`);break}}(ge.players?Object.keys(ge.players).length:0)>=2&&!Oe.value&&(r.startGame(),ne&&ne.setGameActive(!0),console.log("[TrigoView] Game started - both players present"))}else console.warn("[TrigoView] Failed to join room:",ge.error),Mi(ge.error||"Failed to join room")})}catch(ge){C.value=!1,console.error("[TrigoView] Socket connection failed:",ge),alert("Connection failed. Please check your internet and try again.")}}}function Mi(z){w(),z.includes("not found")?alert("Room not found. Creating a new room..."):z.includes("full")?alert("This room is full. Creating a new room..."):alert(`Failed to join room: ${z}. Creating a new room...`),ui()}function Ai(){if(i.value!=="vs-people")return;const z=_(),ge=y.roomId;z!==ge&&(z&&M(z)?(ge&&v.leaveRoom(),_i(z)):ge?x(ge):ui())}watch(o,z=>{ne&&ne.setCurrentPlayer(z)}),watch(l,()=>{nextTick$1(()=>{if(G.value){const z=G.value.querySelector(".active");z&&z.scrollIntoView({behavior:"smooth",block:"nearest"})}})}),watch(()=>y.roomId,z=>{i.value==="vs-people"&&(z?x(z):w())}),watch(X,z=>{z&&(gt.value=ft.value,Zt.value="valid",Lt.value="")}),onMounted(()=>{console.log("TrigoDemo component mounted");let z=!1;if(i.value!=="vs-people"&&(z=r.loadFromSessionStorage()),z)Vt.value=A(d.value),console.log("Restored game state from session storage");else{const ge=D(Vt.value);r.initializeGame(ge)}U.value&&(ne=new TrigoViewport(U.value,d.value,{onStoneClick:yt,onPositionHover:Qt,isPositionDroppable:It,onInspectGroup:Be}),console.log("TrigoViewport initialized"),Xe.value=!1,z&&(zt(),ne.setGameActive(m.value)),$e=new ResizeObserver(ge=>{for(const Nt of ge)Nt.target===U.value&&ne&&(U.value.getBoundingClientRect(),ne.onWindowResize())}),$e.observe(U.value),console.log("ResizeObserver attached to canvas")),(!z||r.gameStatus==="idle")&&(r.startGame(),ne&&ne.setGameActive(!0)),i.value==="vs-ai"&&(console.log("[TrigoView] Initializing AI agent for VS AI mode..."),Y.initialize().catch(ge=>{console.error("[TrigoView] Failed to initialize AI agent:",ge)})),i.value==="vs-people"&&(console.log("[TrigoView] Setting up socket listeners for VS People mode..."),v.onNicknameChanged(ge=>{console.log(`[TrigoView] Player ${ge.playerId} changed nickname: ${ge.oldNickname} -> ${ge.nickname}`),ge.playerId!==v.socket.id&&y.setOpponentNickname(ge.nickname)}),v.onGameUpdate(ge=>{if(console.log("[TrigoView] Game update received:",ge),ge.currentPlayer&&r.setCurrentPlayer(ge.currentPlayer),ge.action==="move"&&ge.lastMove){const{x:Nt,y:Yt,z:En}=ge.lastMove;if(r.makeMove(Nt,Yt,En).success&&ne){const Mn=r.opponentPlayer;ne.addStone(Nt,Yt,En,Mn),ge.capturedPositions&&ge.capturedPositions.length>0&&(ge.capturedPositions.forEach($n=>{ne.removeStone($n.x,$n.y,$n.z)}),console.log(`[TrigoView] Captured ${ge.capturedPositions.length} stone(s)`)),ne.hideDomainCubes(),wn.value=!1}}else ge.action==="pass"?(r.pass(),console.log("[TrigoView] Pass received from server")):(ge.action==="undo"||ge.action==="redo")&&ge.tgn&&ne&&(r.loadFromTGN(ge.tgn),ne.clearBoard(),ut())}),v.onPlayerJoined(ge=>{console.log("[TrigoView] Player joined:",ge),y.setOpponentNickname(ge.nickname),Oe.value||(r.startGame(),ne&&ne.setGameActive(!0),console.log("[TrigoView] Game started - opponent joined"))}),v.onPlayerLeft(ge=>{console.log("[TrigoView] Player left:",ge),y.setOpponentNickname(null)}),v.onPlayerDisconnected(ge=>{console.log("[TrigoView] Player disconnected:",ge),ge.playerId!==v.socket.id&&y.setOpponentNickname(null)}),v.onGameEnded(ge=>{console.log("[TrigoView] Game ended:",ge),alert(`Game ended! Winner: ${ge.winner||"None"}
6500
  Reason: ${ge.reason}`)}),v.onGameReset(ge=>{if(console.log("[TrigoView] Game reset:",ge),ge.tgn?r.loadFromTGN(ge.tgn):r.resetGame(d.value),ne&&ne.clearBoard(),ge.players&&v.socket.id){const Nt=ge.players[v.socket.id];Nt&&(y.playerColor=Nt.color)}}),v.onError(ge=>{console.error("[TrigoView] Socket error:",ge.message)}),wi(),v.socket.id&&y.setPlayerId(v.socket.id),window.addEventListener("hashchange",Ai),v.socket.on("connect",()=>{console.log("[TrigoView] Socket connected in VS People mode"),v.socket.id&&y.setPlayerId(v.socket.id),mi(),!y.roomId&&!C.value&&(console.log("[TrigoView] Initializing room after socket connection"),di())}),v.socket.on("disconnect",()=>{console.log("[TrigoView] Socket disconnected in VS People mode"),y.roomId?y.connectionStatus="connected":y.disconnect()}),v.socket.connected&&(console.log("[TrigoView] Socket already connected, initializing room"),mi(),di())),window.addEventListener("keydown",j)}),watch(i,(z,ge)=>{console.log(`[TrigoView] Game mode changed: ${ge} -> ${z}`),z==="vs-ai"&&!Q.value&&(console.log("[TrigoView] Switching to VS AI mode, initializing AI agent..."),Y.initialize().then(()=>{Oe.value&&o.value===J.value&&setTimeout(()=>{st()},100)}).catch(Nt=>{console.error("[TrigoView] Failed to initialize AI agent:",Nt)}))}),onUnmounted(()=>{console.log("TrigoDemo component unmounted"),window.removeEventListener("keydown",j),i.value==="vs-people"&&(console.log("[TrigoView] Cleaning up socket listeners..."),v.offNicknameChanged(),v.offGameUpdate(),v.offPlayerJoined(),v.offPlayerLeft(),v.offPlayerDisconnected(),v.offGameEnded(),v.offGameReset(),v.offError(),Ti(),window.removeEventListener("hashchange",Ai)),$e&&($e.disconnect(),$e=null,console.log("ResizeObserver disconnected")),ne&&(ne.destroy(),ne=null)});const j=z=>{if(!(z.target instanceof HTMLInputElement||z.target instanceof HTMLTextAreaElement))switch(z.key.toLowerCase()){case"p":Oe.value&&yn();break;case"n":_t();break;case"r":Oe.value&&_n();break;case"arrowleft":Te(),z.preventDefault();break;case"arrowright":xn(),z.preventDefault();break;case"t":Oe.value&&Nn();break}},Ue={route:n,gameMode:i,gameStore:r,game:s,currentPlayer:o,moveHistory:a,currentMoveIndex:l,capturedStones:c,gameStatus:u,boardShape:d,moveCount:f,isGameActive:m,passCount:b,playerStore:y,socketApi:v,getRoomIdFromHash:_,updateHash:x,clearHash:w,isValidRoomId:M,isJoiningRoom:C,roomList:$,isLoadingRooms:R,parseBoardShape:D,printBoardShape:A,formatMoveCoords:k,aiAgent:Y,aiReady:Q,aiThinking:q,aiError:fe,lastMoveTime:me,loadAIColor:ie,aiPlayerColor:J,humanPlayerColor:H,loadPreferredColor:de,preferredColor:oe,hoveredPosition:V,blackScore:ce,whiteScore:Ie,isLoading:Xe,selectedBoardShape:Vt,showTerritoryMode:wn,showTGNModal:X,inspectInfo:ze,editableTGNContent:gt,tgnValidationState:Zt,tgnValidationError:Lt,get tgnValidationTimeout(){return xe},set tgnValidationTimeout(z){xe=z},viewportCanvas:U,moveHistoryContainer:G,get viewport(){return ne},set viewport(z){ne=z},get resizeObserver(){return $e},set resizeObserver(z){$e=z},gameStarted:Oe,moveRounds:Ge,isBoardShapeDirty:mt,tgnContent:ft,tgnIsValid:Et,tgnValidationClass:bt,tgnValidationMessage:F,onTGNEdit:O,applyTGN:pe,generateAIMove:st,syncViewportWithGame:ut,handleStoneClick:yt,handlePositionHover:Qt,isPositionDroppable:It,handleInspectGroup:Be,swapColors:se,newGame:_t,resetMultiplayerGame:Sn,pass:yn,resign:_n,showGameResult:Cn,computeTerritory:Nn,previousMove:Te,nextMove:xn,jumpToMove:lt,syncViewportWithStore:zt,opponentPlayerColor:bn,isLocalPlayerTurn:Pn,connectionStatusClass:Rn,connectionStatusText:Vn,connectionStatusIcon:ri,updateLocalNickname:zn,copyRoomCode:ai,waitForSocketConnection:ei,fetchRoomList:mi,setupRoomListeners:wi,cleanupRoomListeners:Ti,handleRoomSelect:gi,handleCreateRoom:Ci,initializeMultiplayerRoom:di,createAndJoinRoom:ui,joinRoomByHash:_i,handleJoinFailure:Mi,handleHashChange:Ai,handleKeyPress:j,selectAllTGN:z=>{z.target.select()},copyTGN:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(ft.value),alert("TGN copied to clipboard!");else{const z=document.createElement("textarea");z.value=ft.value,z.style.position="fixed",z.style.opacity="0",document.body.appendChild(z),z.select();try{document.execCommand("copy"),alert("TGN copied to clipboard!")}catch(ge){console.error("Fallback copy failed:",ge),alert("Failed to copy TGN. Please select and copy manually.")}finally{document.body.removeChild(z)}}}catch(z){console.error("Failed to copy TGN:",z),alert("Failed to copy TGN. Please select and copy manually.")}},InlineNicknameEditor,RoomSelector};return Object.defineProperty(Ue,"__isScriptSetup",{enumerable:!1,value:!0}),Ue}}),_hoisted_1$a={class:"trigo-view"},_hoisted_2$a={class:"view-header"},_hoisted_3$a={key:0,class:"view-status"},_hoisted_4$a={class:"move-count"},_hoisted_5$a={key:1,class:"view-status ai-mode"},_hoisted_6$a={key:0,class:"ai-level"},_hoisted_7$a={key:1,class:"ai-level ai-thinking"},_hoisted_8$a={key:2,class:"ai-level ai-error"},_hoisted_9$a={class:"move-count"},_hoisted_10$a={key:0,class:"ai-time"},_hoisted_11$7={key:2,class:"view-status people-mode"},_hoisted_12$7={class:"room-info"},_hoisted_13$7={class:"room-code"},_hoisted_14$7={class:"players-info"},_hoisted_15$6={key:1,class:"waiting-text"},_hoisted_16$6={key:3,class:"view-status library-mode"},_hoisted_17$6={key:4,class:"header-controls"},_hoisted_18$6={key:5,class:"header-controls"},_hoisted_19$6={key:6,class:"header-controls"},_hoisted_20$6=["disabled"],_hoisted_21$6={class:"view-body"},_hoisted_22$6={class:"board-container"},_hoisted_23$6={class:"viewport-wrapper"},_hoisted_24$5={ref:"viewportCanvas",class:"viewport-canvas"},_hoisted_25$5={key:0,class:"viewport-overlay"},_hoisted_26$4={key:1,class:"inspect-tooltip"},_hoisted_27$4={class:"tooltip-content"},_hoisted_28$4={class:"tooltip-label"},_hoisted_29$4={class:"tooltip-label"},_hoisted_30$4={class:"controls-panel"},_hoisted_31$4={class:"section-title"},_hoisted_32$4={class:"score-display"},_hoisted_33$4=["disabled"],_hoisted_34$4={class:"score"},_hoisted_35$4=["disabled"],_hoisted_36$3={class:"score"},_hoisted_37$3=["disabled"],_hoisted_38$3={class:"panel-section routine-section"},_hoisted_39$3={class:"section-title"},_hoisted_40$2={class:"routine-content",ref:"moveHistoryContainer"},_hoisted_41$2={class:"move-list"},_hoisted_42$2={class:"round-number"},_hoisted_43$2=["onClick"],_hoisted_44$2={key:0,class:"move-coords"},_hoisted_45$2={key:1,class:"move-label"},_hoisted_46$2=["onClick"],_hoisted_47$2={key:0,class:"move-coords"},_hoisted_48$2={key:1,class:"move-label"},_hoisted_49$2={key:1,class:"move-cell empty"},_hoisted_50$2={class:"panel-section controls-section"},_hoisted_51$2={class:"control-buttons"},_hoisted_52$2={class:"play-controls"},_hoisted_53$2=["disabled"],_hoisted_54$2=["disabled"],_hoisted_55$2={class:"history-controls"},_hoisted_56$2=["disabled"],_hoisted_57$2=["disabled"],_hoisted_58$1={class:"tgn-modal-content"},_hoisted_59$1={class:"tgn-modal-header"},_hoisted_60$1={class:"tgn-modal-body"},_hoisted_61$1={class:"tgn-modal-footer"},_hoisted_62=["disabled"];function _sfc_render$a(t,e,n,i,r,s){return openBlock(),createElementBlock("div",_hoisted_1$a,[createBaseVNode("div",_hoisted_2$a,[i.gameMode==="single"?(openBlock(),createElementBlock("div",_hoisted_3$a,[createBaseVNode("span",{class:normalizeClass(["turn-indicator",{black:i.currentPlayer==="black",white:i.currentPlayer==="white"}])},toDisplayString(i.currentPlayer==="black"?"Black":"White")+"'s Turn ",3),createBaseVNode("span",_hoisted_4$a,"Move: "+toDisplayString(i.moveCount),1)])):i.gameMode==="vs-ai"?(openBlock(),createElementBlock("div",_hoisted_5$a,[createBaseVNode("div",{class:normalizeClass(["player-info",{"on-turn":i.currentPlayer===i.humanPlayerColor}])},[e[10]||(e[10]=createBaseVNode("span",{class:"player-label"},"You:",-1)),createBaseVNode("span",{class:normalizeClass(["stone-icon",i.humanPlayerColor==="black"?"black":"white"])},null,2)],2),createBaseVNode("button",{class:"btn-swap-colors",onClick:i.swapColors},"⇄ Swap"),createBaseVNode("div",{class:normalizeClass(["ai-status",{"on-turn":i.currentPlayer===i.aiPlayerColor&&!i.aiThinking}])},[e[11]||(e[11]=createBaseVNode("span",{class:"ai-indicator"},"🤖 AI:",-1)),i.aiReady?i.aiThinking?(openBlock(),createElementBlock("span",_hoisted_7$a,"Thinking...")):i.aiError?(openBlock(),createElementBlock("span",_hoisted_8$a,"Error")):(openBlock(),createElementBlock("span",{key:3,class:normalizeClass(["stone-icon",i.aiPlayerColor==="black"?"black":"white"])},null,2)):(openBlock(),createElementBlock("span",_hoisted_6$a,"Loading..."))],2),createBaseVNode("span",_hoisted_9$a,"Move: "+toDisplayString(i.moveCount),1),i.lastMoveTime>0?(openBlock(),createElementBlock("span",_hoisted_10$a,"("+toDisplayString(i.lastMoveTime.toFixed(0))+"ms)",1)):createCommentVNode("",!0)])):i.gameMode==="vs-people"?(openBlock(),createElementBlock("div",_hoisted_11$7,[createBaseVNode("div",_hoisted_12$7,[e[12]||(e[12]=createBaseVNode("span",{class:"room-label"},"Room:",-1)),createBaseVNode("span",_hoisted_13$7,toDisplayString(i.playerStore.roomId||"---"),1),i.playerStore.roomId?(openBlock(),createElementBlock("button",{key:0,class:"btn-copy-room",onClick:i.copyRoomCode,title:"Copy room code"}," 📋 ")):createCommentVNode("",!0)]),createBaseVNode("div",_hoisted_14$7,[createBaseVNode("div",{class:normalizeClass(["player-display",{"on-turn":i.isLocalPlayerTurn}])},[createVNode(i.InlineNicknameEditor,{nickname:i.playerStore.nickname,editable:!0,"player-color":i.playerStore.playerColor,onUpdate:i.updateLocalNickname},null,8,["nickname","player-color"])],2),e[13]||(e[13]=createBaseVNode("span",{class:"vs-divider"},"vs",-1)),createBaseVNode("div",{class:normalizeClass(["player-display",{"on-turn":!i.isLocalPlayerTurn}])},[i.playerStore.opponentNickname?(openBlock(),createBlock(i.InlineNicknameEditor,{key:0,nickname:i.playerStore.opponentNickname,editable:!1,"player-color":i.opponentPlayerColor},null,8,["nickname","player-color"])):(openBlock(),createElementBlock("span",_hoisted_15$6,"Waiting..."))],2)]),createBaseVNode("span",{class:normalizeClass(["connection-status",i.connectionStatusClass])},toDisplayString(i.connectionStatusIcon)+" "+toDisplayString(i.connectionStatusText),3)])):i.gameMode==="library"?(openBlock(),createElementBlock("div",_hoisted_16$6,[...e[14]||(e[14]=[createStaticVNode('<div class="game-info" data-v-6ae1493c><span class="game-title" data-v-6ae1493c>Game #12345</span><span class="game-date" data-v-6ae1493c>2025-01-18</span></div><div class="library-actions" data-v-6ae1493c><button class="btn-library btn-load" title="Load Game" data-v-6ae1493c>📂 Load</button><button class="btn-library btn-export" title="Export TGN" data-v-6ae1493c>📤 Export</button></div>',2)])])):createCommentVNode("",!0),i.gameMode==="single"?(openBlock(),createElementBlock("div",_hoisted_17$6,[withDirectives(createBaseVNode("select",{"onUpdate:modelValue":e[0]||(e[0]=o=>i.selectedBoardShape=o),class:"board-shape-select"},[...e[15]||(e[15]=[createStaticVNode('<option value="3x3x3" data-v-6ae1493c>3×3×3</option><option value="5x5x5" data-v-6ae1493c>5×5×5</option><option value="7x7x7" data-v-6ae1493c>7×7×7</option><option value="9x9x1" data-v-6ae1493c>9×9×1 (2D)</option><option value="9x9x9" data-v-6ae1493c>9×9×9</option><option value="5x5x1" data-v-6ae1493c>5×5×1 (2D)</option><option value="7x7x1" data-v-6ae1493c>7×7×1 (2D)</option>',7)])],512),[[vModelSelect,i.selectedBoardShape]]),createBaseVNode("button",{class:"btn-reset",onClick:i.newGame},toDisplayString(i.gameStarted?"Reset":"Start"),1)])):i.gameMode==="vs-ai"?(openBlock(),createElementBlock("div",_hoisted_18$6,[withDirectives(createBaseVNode("select",{"onUpdate:modelValue":e[1]||(e[1]=o=>i.selectedBoardShape=o),class:"board-shape-select"},[...e[16]||(e[16]=[createStaticVNode('<option value="3x3x3" data-v-6ae1493c>3×3×3</option><option value="5x5x5" data-v-6ae1493c>5��5×5</option><option value="7x7x7" data-v-6ae1493c>7×7×7</option><option value="9x9x1" data-v-6ae1493c>9×9×1 (2D)</option><option value="9x9x9" data-v-6ae1493c>9×9×9</option><option value="5x5x1" data-v-6ae1493c>5×5×1 (2D)</option><option value="7x7x1" data-v-6ae1493c>7×7×1 (2D)</option>',7)])],512),[[vModelSelect,i.selectedBoardShape]]),createBaseVNode("button",{class:"btn-reset",onClick:i.newGame},toDisplayString(i.gameStarted?"Reset":"Start"),1)])):i.gameMode==="vs-people"?(openBlock(),createElementBlock("div",_hoisted_19$6,[createVNode(i.RoomSelector,{"current-room":i.playerStore.roomId,rooms:i.roomList,loading:i.isLoadingRooms,disabled:i.gameStarted&&i.playerStore.hasOpponent,onCreate:i.handleCreateRoom,onSelect:i.handleRoomSelect},null,8,["current-room","rooms","loading","disabled"]),withDirectives(createBaseVNode("select",{"onUpdate:modelValue":e[2]||(e[2]=o=>i.preferredColor=o),class:"color-preference-select",disabled:i.gameStarted||t.connectionStatus==="in-room"},[...e[17]||(e[17]=[createBaseVNode("option",{value:"black"},"Play as Black",-1),createBaseVNode("option",{value:"white"},"Play as White",-1)])],8,_hoisted_20$6),[[vModelSelect,i.preferredColor]]),withDirectives(createBaseVNode("select",{"onUpdate:modelValue":e[3]||(e[3]=o=>i.selectedBoardShape=o),class:"board-shape-select"},[...e[18]||(e[18]=[createStaticVNode('<option value="3x3x3" data-v-6ae1493c>3×3×3</option><option value="5x5x5" data-v-6ae1493c>5×5×5</option><option value="7x7x7" data-v-6ae1493c>7×7×7</option><option value="9x9x1" data-v-6ae1493c>9×9×1 (2D)</option><option value="9x9x9" data-v-6ae1493c>9×9×9</option><option value="5x5x1" data-v-6ae1493c>5×5×1 (2D)</option><option value="7x7x1" data-v-6ae1493c>7×7×1 (2D)</option>',7)])],512),[[vModelSelect,i.selectedBoardShape]]),createBaseVNode("button",{class:"btn-reset",onClick:i.resetMultiplayerGame},"Reset")])):createCommentVNode("",!0)]),createBaseVNode("div",_hoisted_21$6,[createBaseVNode("div",_hoisted_22$6,[createBaseVNode("div",_hoisted_23$6,[createBaseVNode("canvas",_hoisted_24$5,null,512),i.isLoading?(openBlock(),createElementBlock("div",_hoisted_25$5,[...e[19]||(e[19]=[createBaseVNode("p",{class:"loading-text"},"Loading 3D Board...",-1)])])):createCommentVNode("",!0),i.inspectInfo.visible?(openBlock(),createElementBlock("div",_hoisted_26$4,[createBaseVNode("div",_hoisted_27$4,[createBaseVNode("span",_hoisted_28$4,toDisplayString(i.inspectInfo.groupSize)+" stone"+toDisplayString(i.inspectInfo.groupSize>1?"s":""),1),e[20]||(e[20]=createBaseVNode("span",{class:"tooltip-divider"},"|",-1)),createBaseVNode("span",_hoisted_29$4,"Liberties: "+toDisplayString(i.inspectInfo.liberties),1)])])):createCommentVNode("",!0)])]),createBaseVNode("div",_hoisted_30$4,[createBaseVNode("div",{class:normalizeClass(["panel-section score-section",{"show-territory":i.showTerritoryMode}])},[createBaseVNode("h3",_hoisted_31$4,toDisplayString(i.showTerritoryMode?"Territory":"Captured"),1),createBaseVNode("div",_hoisted_32$4,[createBaseVNode("button",{class:"score-button black",disabled:!i.gameStarted},[e[21]||(e[21]=createBaseVNode("span",{class:"color-indicator black-stone"},null,-1)),createBaseVNode("span",_hoisted_34$4,toDisplayString(i.showTerritoryMode?i.blackScore:i.capturedStones.black),1)],8,_hoisted_33$4),createBaseVNode("button",{class:"score-button white",disabled:!i.gameStarted},[e[22]||(e[22]=createBaseVNode("span",{class:"color-indicator white-stone"},null,-1)),createBaseVNode("span",_hoisted_36$3,toDisplayString(i.showTerritoryMode?i.whiteScore:i.capturedStones.white),1)],8,_hoisted_35$4)]),createBaseVNode("button",{class:"compute-territory",onClick:i.computeTerritory,disabled:!i.gameStarted}," Compute Territory ",8,_hoisted_37$3)],2),createBaseVNode("div",_hoisted_38$3,[createBaseVNode("h3",_hoisted_39$3,[e[23]||(e[23]=createTextVNode(" Move History ",-1)),createBaseVNode("button",{class:"btn-view-tgn",onClick:e[4]||(e[4]=o=>i.showTGNModal=!0),title:"View TGN Notation"}," TGN ")]),createBaseVNode("div",_hoisted_40$2,[createBaseVNode("div",_hoisted_41$2,[createBaseVNode("div",{class:normalizeClass([{active:i.currentMoveIndex===0},"move-row start-row"]),onClick:e[5]||(e[5]=o=>i.jumpToMove(0))},[...e[24]||(e[24]=[createBaseVNode("span",{class:"round-number"},null,-1),createBaseVNode("span",{class:"move-label open-label"},"OPEN",-1)])],2),(openBlock(!0),createElementBlock(Fragment,null,renderList(i.moveRounds,(o,a)=>(openBlock(),createElementBlock("div",{key:a,class:"move-row"},[createBaseVNode("span",_hoisted_42$2,toDisplayString(a+1)+".",1),createBaseVNode("div",{class:normalizeClass(["move-cell black-move",{active:o.blackIndex===i.currentMoveIndex}]),onClick:l=>i.jumpToMove(o.blackIndex)},[e[25]||(e[25]=createBaseVNode("span",{class:"stone-icon black"},null,-1)),o.black.isPass?(openBlock(),createElementBlock("span",_hoisted_45$2,"pass")):(openBlock(),createElementBlock("span",_hoisted_44$2,toDisplayString(i.formatMoveCoords(o.black)),1))],10,_hoisted_43$2),o.white?(openBlock(),createElementBlock("div",{key:0,class:normalizeClass(["move-cell white-move",{active:o.whiteIndex===i.currentMoveIndex}]),onClick:l=>i.jumpToMove(o.whiteIndex)},[e[26]||(e[26]=createBaseVNode("span",{class:"stone-icon white"},null,-1)),o.white.isPass?(openBlock(),createElementBlock("span",_hoisted_48$2,"pass")):(openBlock(),createElementBlock("span",_hoisted_47$2,toDisplayString(i.formatMoveCoords(o.white)),1))],10,_hoisted_46$2)):(openBlock(),createElementBlock("div",_hoisted_49$2))]))),128))])],512)]),createBaseVNode("div",_hoisted_50$2,[e[27]||(e[27]=createBaseVNode("h3",{class:"section-title"},"Controls",-1)),createBaseVNode("div",_hoisted_51$2,[createBaseVNode("div",_hoisted_52$2,[createBaseVNode("button",{class:"btn btn-pass",onClick:i.pass,disabled:!i.gameStarted}," Pass ",8,_hoisted_53$2),createBaseVNode("button",{class:"btn btn-resign",onClick:i.resign,disabled:!i.gameStarted}," Resign ",8,_hoisted_54$2)]),createBaseVNode("div",_hoisted_55$2,[createBaseVNode("button",{class:"btn btn-icon btn-prev",onClick:i.previousMove,disabled:i.currentMoveIndex<=0,title:"Previous Move"}," ◀ ",8,_hoisted_56$2),createBaseVNode("button",{class:"btn btn-icon btn-next",onClick:i.nextMove,disabled:i.currentMoveIndex>=i.moveHistory.length,title:"Next Move"}," ▶ ",8,_hoisted_57$2)])])])])]),i.showTGNModal?(openBlock(),createElementBlock("div",{key:0,class:"tgn-modal",onClick:e[9]||(e[9]=withModifiers(o=>i.showTGNModal=!1,["self"]))},[createBaseVNode("div",_hoisted_58$1,[createBaseVNode("div",_hoisted_59$1,[e[28]||(e[28]=createBaseVNode("h3",null,"Game Notation (TGN)",-1)),createBaseVNode("div",{class:normalizeClass(["tgn-status",i.tgnValidationClass])},toDisplayString(i.tgnValidationMessage),3),createBaseVNode("button",{class:"btn-close",onClick:e[6]||(e[6]=o=>i.showTGNModal=!1)},"×")]),createBaseVNode("div",_hoisted_60$1,[withDirectives(createBaseVNode("textarea",{"onUpdate:modelValue":e[7]||(e[7]=o=>i.editableTGNContent=o),class:normalizeClass(["tgn-textarea",i.tgnValidationClass]),onInput:i.onTGNEdit,placeholder:"Enter TGN game notation..."},null,34),[[vModelText,i.editableTGNContent]])]),createBaseVNode("div",_hoisted_61$1,[createBaseVNode("button",{class:"btn btn-apply",onClick:i.applyTGN,disabled:!i.tgnIsValid}," Apply TGN ",8,_hoisted_62),createBaseVNode("button",{class:"btn btn-copy",onClick:i.copyTGN},"Copy to Clipboard"),createBaseVNode("button",{class:"btn btn-close-modal",onClick:e[8]||(e[8]=o=>i.showTGNModal=!1)},"Close")])])])):createCommentVNode("",!0)])}const TrigoView=_export_sfc(_sfc_main$a,[["render",_sfc_render$a],["__scopeId","data-v-6ae1493c"],["__file","/home/camus/work/trigo/trigo-web/app/src/views/TrigoView.vue"]]),_sfc_main$9=defineComponent({__name:"OnnxTestView",setup(t,{expose:e}){e();let n=null;const i=ref(!1),r=ref(!1),s=ref(!1),o=ref(null),a=ref(null),l=ref(null),c=ref(null),u=ref("[Board 5x5]"),d=ref(10),v={get inferencer(){return n},set inferencer(_){n=_},isInitializing:i,isInitialized:r,isRunning:s,error:o,modelInfo:a,basicTestResult:l,generationResult:c,prompt:u,numTokens:d,initialize:async()=>{i.value=!0,o.value=null;try{console.log("=".repeat(80)),console.log("Initializing ONNX Inferencer..."),console.log("=".repeat(80)),n=new OnnxInferencer({modelPath:"/onnx/20251230-trigo-value-llama-l6-h64-it2_251221-value0.01-pretrain/LlamaCausalLM_ep0036_tree.onnx",vocabSize:128,seqLen:256,executionProviders:["wasm"]}),await n.initialize(),a.value=n.getModelInfo(),r.value=!0,console.log("✓ Initialization complete!"),console.log("=".repeat(80))}catch(_){o.value=_ instanceof Error?_.message:"Unknown error",console.error("Initialization failed:",_)}finally{i.value=!1}},runBasicTest:async()=>{if(n){s.value=!0,o.value=null,l.value=null;try{console.log(`
6501
  `+"=".repeat(80)),console.log("Running Basic Inference Test..."),console.log("=".repeat(80));const _=await n.testBasicInference();l.value=_,console.log("✓ Basic test complete!"),console.log("=".repeat(80))}catch(_){o.value=_ instanceof Error?_.message:"Test failed",console.error("Basic test failed:",_)}finally{s.value=!1}}},runGenerationTest:async()=>{if(n){s.value=!0,o.value=null,c.value=null;try{console.log(`
6502
  `+"=".repeat(80)),console.log("Running Text Generation Test..."),console.log("=".repeat(80));const _=await n.generateText(u.value,d.value);c.value=_,console.log("✓ Generation test complete!"),console.log("=".repeat(80))}catch(_){o.value=_ instanceof Error?_.message:"Generation failed",console.error("Generation test failed:",_)}finally{s.value=!1}}},clearConsole:()=>{console.clear(),console.log("Console cleared")}};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),_hoisted_1$9={class:"onnx-test-view"},_hoisted_2$9={class:"test-body"},_hoisted_3$9={class:"test-section"},_hoisted_4$9={class:"status-info"},_hoisted_5$9={class:"status-value"},_hoisted_6$9={key:0,class:"status-item"},_hoisted_7$9={class:"status-value"},_hoisted_8$9={key:1,class:"status-item"},_hoisted_9$9={class:"status-value"},_hoisted_10$9={key:2,class:"error-message"},_hoisted_11$6=["disabled"],_hoisted_12$6={class:"test-section"},_hoisted_13$6=["disabled"],_hoisted_14$6={key:0,class:"test-result"},_hoisted_15$5={class:"result-item"},_hoisted_16$5={class:"value"},_hoisted_17$5={class:"result-item"},_hoisted_18$5={class:"value code"},_hoisted_19$5={class:"result-item"},_hoisted_20$5={class:"value code"},_hoisted_21$5={class:"test-section"},_hoisted_22$5={class:"input-group"},_hoisted_23$5=["disabled"],_hoisted_24$4={class:"input-group"},_hoisted_25$4=["disabled"],_hoisted_26$3=["disabled"],_hoisted_27$3={key:0,class:"test-result"},_hoisted_28$3={class:"result-item"},_hoisted_29$3={class:"value"},_hoisted_30$3={class:"result-item"},_hoisted_31$3={class:"value"},_hoisted_32$3={class:"result-item full-width"},_hoisted_33$3={class:"value code"},_hoisted_34$3={class:"result-item full-width"},_hoisted_35$3={class:"generated-text"};function _sfc_render$9(t,e,n,i,r,s){return openBlock(),createElementBlock("div",_hoisted_1$9,[e[23]||(e[23]=createBaseVNode("div",{class:"test-header"},[createBaseVNode("h1",null,"ONNX Model Inferencer Test"),createBaseVNode("p",{class:"subtitle"},"Testing GPT-2 Causal LM with ONNX Runtime Web")],-1)),createBaseVNode("div",_hoisted_2$9,[createBaseVNode("div",_hoisted_3$9,[e[5]||(e[5]=createBaseVNode("h2",null,"Model Status",-1)),createBaseVNode("div",_hoisted_4$9,[createBaseVNode("div",{class:normalizeClass(["status-item",{ready:i.isInitialized,loading:i.isInitializing}])},[e[2]||(e[2]=createBaseVNode("span",{class:"status-label"},"Status:",-1)),createBaseVNode("span",_hoisted_5$9,toDisplayString(i.isInitialized?"✓ Ready":i.isInitializing?"⏳ Initializing...":"⚪ Not initialized"),1)],2),i.modelInfo?(openBlock(),createElementBlock("div",_hoisted_6$9,[e[3]||(e[3]=createBaseVNode("span",{class:"status-label"},"Inputs:",-1)),createBaseVNode("span",_hoisted_7$9,toDisplayString(i.modelInfo.inputs.join(", ")),1)])):createCommentVNode("",!0),i.modelInfo?(openBlock(),createElementBlock("div",_hoisted_8$9,[e[4]||(e[4]=createBaseVNode("span",{class:"status-label"},"Outputs:",-1)),createBaseVNode("span",_hoisted_9$9,toDisplayString(i.modelInfo.outputs.join(", ")),1)])):createCommentVNode("",!0),i.error?(openBlock(),createElementBlock("div",_hoisted_10$9,"❌ Error: "+toDisplayString(i.error),1)):createCommentVNode("",!0)]),createBaseVNode("button",{class:"btn btn-primary",onClick:i.initialize,disabled:i.isInitializing||i.isInitialized},toDisplayString(i.isInitialized?"Initialized":"Initialize Model"),9,_hoisted_11$6)]),createBaseVNode("div",_hoisted_12$6,[e[10]||(e[10]=createBaseVNode("h2",null,"Test 1: Basic Inference",-1)),e[11]||(e[11]=createBaseVNode("p",null,"Run a single forward pass with random input",-1)),createBaseVNode("button",{class:"btn btn-test",onClick:i.runBasicTest,disabled:!i.isInitialized||i.isRunning},toDisplayString(i.isRunning?"Running...":"Run Basic Test"),9,_hoisted_13$6),i.basicTestResult?(openBlock(),createElementBlock("div",_hoisted_14$6,[e[9]||(e[9]=createBaseVNode("h3",null,"Results:",-1)),createBaseVNode("div",_hoisted_15$5,[e[6]||(e[6]=createBaseVNode("span",{class:"label"},"Inference Time:",-1)),createBaseVNode("span",_hoisted_16$5,toDisplayString(i.basicTestResult.inferenceTime.toFixed(2))+"ms",1)]),createBaseVNode("div",_hoisted_17$5,[e[7]||(e[7]=createBaseVNode("span",{class:"label"},"Sample Tokens:",-1)),createBaseVNode("span",_hoisted_18$5,toDisplayString(i.basicTestResult.tokens.slice(0,20).join(", "))+"...",1)]),createBaseVNode("div",_hoisted_19$5,[e[8]||(e[8]=createBaseVNode("span",{class:"label"},"Sample Text:",-1)),createBaseVNode("span",_hoisted_20$5,toDisplayString(i.basicTestResult.text.slice(0,100))+"...",1)])])):createCommentVNode("",!0)]),createBaseVNode("div",_hoisted_21$5,[e[19]||(e[19]=createBaseVNode("h2",null,"Test 2: Text Generation",-1)),e[20]||(e[20]=createBaseVNode("p",null,"Generate tokens autoregressively from a prompt",-1)),createBaseVNode("div",_hoisted_22$5,[e[12]||(e[12]=createBaseVNode("label",{for:"prompt"},"Prompt:",-1)),withDirectives(createBaseVNode("input",{id:"prompt","onUpdate:modelValue":e[0]||(e[0]=o=>i.prompt=o),type:"text",placeholder:"Enter prompt text...",disabled:!i.isInitialized},null,8,_hoisted_23$5),[[vModelText,i.prompt]])]),createBaseVNode("div",_hoisted_24$4,[e[13]||(e[13]=createBaseVNode("label",{for:"numTokens"},"Number of Tokens:",-1)),withDirectives(createBaseVNode("input",{id:"numTokens","onUpdate:modelValue":e[1]||(e[1]=o=>i.numTokens=o),type:"number",min:"1",max:"50",disabled:!i.isInitialized},null,8,_hoisted_25$4),[[vModelText,i.numTokens,void 0,{number:!0}]])]),createBaseVNode("button",{class:"btn btn-test",onClick:i.runGenerationTest,disabled:!i.isInitialized||i.isRunning||!i.prompt},toDisplayString(i.isRunning?"Generating...":"Generate Text"),9,_hoisted_26$3),i.generationResult?(openBlock(),createElementBlock("div",_hoisted_27$3,[e[18]||(e[18]=createBaseVNode("h3",null,"Generated Output:",-1)),createBaseVNode("div",_hoisted_28$3,[e[14]||(e[14]=createBaseVNode("span",{class:"label"},"Avg Inference Time:",-1)),createBaseVNode("span",_hoisted_29$3,toDisplayString(i.generationResult.inferenceTime.toFixed(2))+"ms",1)]),createBaseVNode("div",_hoisted_30$3,[e[15]||(e[15]=createBaseVNode("span",{class:"label"},"Tokens/sec:",-1)),createBaseVNode("span",_hoisted_31$3,toDisplayString((1e3/i.generationResult.inferenceTime).toFixed(2)),1)]),createBaseVNode("div",_hoisted_32$3,[e[16]||(e[16]=createBaseVNode("span",{class:"label"},"Token Sequence:",-1)),createBaseVNode("span",_hoisted_33$3,toDisplayString(i.generationResult.tokens.join(", ")),1)]),createBaseVNode("div",_hoisted_34$3,[e[17]||(e[17]=createBaseVNode("span",{class:"label"},"Generated Text:",-1)),createBaseVNode("div",_hoisted_35$3,toDisplayString(i.generationResult.text),1)])])):createCommentVNode("",!0)]),createBaseVNode("div",{class:"test-section"},[e[21]||(e[21]=createBaseVNode("h2",null,"Console Output",-1)),e[22]||(e[22]=createBaseVNode("p",null,"Check the browser console (F12) for detailed logs",-1)),createBaseVNode("button",{class:"btn btn-secondary",onClick:i.clearConsole},"Clear Console")])])])}const OnnxTestView=_export_sfc(_sfc_main$9,[["render",_sfc_render$9],["__scopeId","data-v-ee339f1a"],["__file","/home/camus/work/trigo/trigo-web/app/src/views/OnnxTestView.vue"]]);class TrigoAgent{constructor(e){this.inferencer=e}isInitialized(){return this.inferencer!==null}stoneToPlayer(e){if(e===StoneType.BLACK)return"black";if(e===StoneType.WHITE)return"white";throw new Error(`Invalid stone type: ${e}`)}stringToTokens(e){return Array.from(e).map(n=>n.charCodeAt(0))}softmax(e,n){const i=new Float32Array(n);let r=-1/0;for(let o=0;o<n;o++)e[o]>r&&(r=e[o]);let s=0;for(let o=0;o<n;o++)i[o]=Math.exp(e[o]-r),s+=i[o];for(let o=0;o<n;o++)i[o]/=s;return i}async scoreMove(e,n){const i=e.clone();let r;if(n.isPass)r=i.pass();else if(n.x!==void 0&&n.y!==void 0&&n.z!==void 0)r=i.drop({x:n.x,y:n.y,z:n.z});else return-1e3;if(!r)return-1e3;const s=i.toTGN().trim(),o=this.extractMoveTokens(s);if(o.length===0)return-100;const a=this.stringToTokens(s),l=this.inferencer.getConfig(),c=l.seqLen,u=l.vocabSize;a.length>c&&a.splice(0,a.length-c);const d=await this.inferencer.runInference(a),f=a.length-o.length;let m=0;for(let b=0;b<o.length;b++){const y=f+b;if(y<0||y>=a.length)continue;const v=y*u,_=d.slice(v,v+u),x=this.softmax(_,u),w=o[b],M=x[w];M>0?m+=Math.log(M):m+=-100}return m}extractMoveTokens(e){const n=e.match(/[Pa-z0]+$/);return this.stringToTokens(n?n[0]:"")}async selectBestMove(e){if(!this.isInitialized())throw new Error("Agent not initialized. Pass initialized inferencer to constructor.");console.log("[TrigoAgent] Selecting move...");const n=this.stoneToPlayer(e.getCurrentPlayer()),i=e.validMovePositions().map(o=>({x:o.x,y:o.y,z:o.z,player:n}));if(i.push({player:n,isPass:!0}),i.length===0)return console.log("[TrigoAgent] No valid moves available"),null;console.log(`[TrigoAgent] Evaluating ${i.length} valid moves...`);const r=[];for(const o of i){const a=await this.scoreMove(e,o);r.push({move:o,score:Math.exp(a),logProb:a})}r.sort((o,a)=>a.logProb-o.logProb);const s=r[0];console.debug("scores:",r),console.log("[TrigoAgent] Best move:",s.move,"score:",s.score.toFixed(6)),console.log("[TrigoAgent] Top 5 moves:");for(let o=0;o<Math.min(5,r.length);o++)console.log(` ${o+1}. ${r[o].move}: ${r[o].score.toFixed(6)}`);return s.move}destroy(){this.inferencer.destroy(),console.log("[TrigoAgent] Destroyed")}}const _sfc_main$8=defineComponent({__name:"TrigoAgentTestView",setup(t,{expose:e}){e();let n=null,i=null;const r=shallowRef(null),s=ref(!1),o=ref(!1),a=ref(!1),l=ref(null),c=ref({x:5,y:5,z:5}),u=ref("black"),d=ref([]),f=ref(!1),m=ref(null),b=computed(()=>(console.log("validMovesCount:",r),r.value?x():0)),y=computed(()=>r.value?r.value.toTGN():"[Board 5x5] *"),v=async()=>{s.value=!0,l.value=null;try{console.log("=".repeat(80)),console.log("[TrigoAgentTest] Initializing AI agent..."),console.log("=".repeat(80)),n=new OnnxInferencer({modelPath:"/onnx/20251230-trigo-value-llama-l6-h64-it2_251221-value0.01-pretrain/LlamaCausalLM_ep0036_tree.onnx",vocabSize:128,seqLen:256}),await n.initialize(),i=new TrigoAgent(n),o.value=!0,_(),console.log("[TrigoAgentTest] ✓ Agent initialized successfully!"),console.log("=".repeat(80))}catch(D){l.value=D instanceof Error?D.message:"Unknown error",console.error("[TrigoAgentTest] Initialization failed:",D)}finally{s.value=!1}},_=()=>{console.log("[TrigoAgentTest] Resetting game.value..."),r.value=new TrigoGame(c.value),u.value="black",d.value=[],f.value=!0,m.value=null,console.log("[TrigoAgentTest] ✓ Game reset")},x=()=>(console.debug("getValidMovesCount:",r),r.value?r.value.validMovePositions().length:0),R={get inferencer(){return n},set inferencer(D){n=D},get agent(){return i},set agent(D){i=D},game:r,isInitializing:s,isInitialized:o,isGenerating:a,error:l,boardShape:c,currentPlayer:u,moveHistory:d,gameStarted:f,moveResult:m,validMovesCount:b,currentTGN:y,initialize:v,resetGame:_,getValidMovesCount:x,makeRandomMove:()=>{if(!r.value)return;const D=r.value.validMovePositions();if(D.length===0){console.log("[TrigoAgentTest] No valid moves available");return}const A=D[Math.floor(Math.random()*D.length)],k=r.value.getShape(),Y=encodeAb0yz([A.x,A.y,A.z],[k.x,k.y,k.z]);r.value.drop(A),d.value.push({player:u.value,notation:Y,position:`(${A.x}, ${A.y}, ${A.z})`}),u.value=u.value==="black"?"white":"black",console.log(`[TrigoAgentTest] Random move: ${Y} at ${A.x},${A.y},${A.z}`)},testGenerateMove:async()=>{if(!(!i||!r)){a.value=!0,l.value=null,m.value=null;try{console.log(`
 
6496
 
6497
  Both players: ${Yt} points
6498
 
6499
+ Game continues for analysis.`}setTimeout(()=>{alert(ge)},100)},Nn=()=>{if(!Oe.value)return;if(wn.value){ne&&ne.hideDomainCubes(),wn.value=!1,ce.value=0,Ie.value=0;return}const z=r.computeTerritory();if(ce.value=z.black+c.value.black,Ie.value=z.white+c.value.white,wn.value=!0,ne){const ge=new Set,Nt=new Set;z.blackTerritory.forEach(Yt=>{const En=`${Yt.x},${Yt.y},${Yt.z}`;ge.add(En)}),z.whiteTerritory.forEach(Yt=>{const En=`${Yt.x},${Yt.y},${Yt.z}`;Nt.add(En)}),ne.setDomainData(ge,Nt),ne.setBlackDomainVisible(!0),ne.setWhiteDomainVisible(!0)}console.log("Territory computed:",z)},Te=()=>{r.undoMove()&&ne&&zt()},xn=()=>{r.redoMove()&&ne&&zt()},lt=z=>{r.jumpToMove(z)&&ne&&(zt(),ne.hideDomainCubes(),wn.value=!1,ce.value=0,Ie.value=0)},zt=()=>{if(!ne)return;ne.clearBoard();const z=r.board,ge=d.value;for(let Nt=0;Nt<ge.x;Nt++)for(let Yt=0;Yt<ge.y;Yt++)for(let En=0;En<ge.z;En++){const In=z[Nt][Yt][En];In===Stone.Black?ne.addStone(Nt,Yt,En,"black"):In===Stone.White&&ne.addStone(Nt,Yt,En,"white")}if(l.value>0&&l.value<=a.value.length){const Nt=a.value[l.value-1];ne.setLastPlacedStone(Nt.x,Nt.y,Nt.z)}else ne.setLastPlacedStone(null,null,null)},bn=computed(()=>y.playerColor?y.playerColor==="black"?"white":"black":null),Pn=computed(()=>o.value===y.playerColor),Rn=computed(()=>y.connectionStatus==="in-room"?"connected":"disconnected"),Vn=computed(()=>y.connectionStatus==="in-room"?"Connected":y.connectionStatus==="connected"?"Joining room...":"Disconnected"),ri=computed(()=>y.connectionStatus==="in-room"?"🟢":y.connectionStatus==="connected"?"🟡":"🔴"),zn=z=>{if(!y.setNickname(z)){console.error("Failed to update nickname");return}y.isInRoom&&v.changeNickname(z,Nt=>{Nt.success||(console.error("Failed to broadcast nickname change:",Nt.error),alert(`Failed to change nickname: ${Nt.error}`))})},ai=()=>{y.roomId&&navigator.clipboard.writeText(y.roomId).then(()=>alert("Room code copied to clipboard!")).catch(z=>console.error("Failed to copy room code:",z))};async function ei(z=5e3){return new Promise((ge,Nt)=>{if(v.socket.connected){ge();return}const Yt=setInterval(()=>{v.socket.connected&&(clearInterval(Yt),clearTimeout(En),ge())},100),En=setTimeout(()=>{clearInterval(Yt),Nt(new Error("Socket connection timeout"))},z)})}function mi(){console.log("[TrigoView] fetchRoomList() called, socket connected:",v.socket.connected,"socket id:",v.socket.id),R.value=!0,v.listRooms(z=>{console.log("[TrigoView] listRooms response:",z),R.value=!1,z.success?($.value=z.rooms||[],console.log("[TrigoView] Room list updated, count:",$.value.length,"rooms:",$.value.map(ge=>ge.id))):console.error("[TrigoView] listRooms failed:",z.error)})}function wi(){console.log("[TrigoView] Setting up room listeners, socket connected:",v.socket.connected,"socket id:",v.socket.id),v.onRoomCreated(z=>{console.log("[TrigoView] >>> Received roomCreated event:",z),console.log("[TrigoView] Current roomList before add:",JSON.stringify($.value)),$.value.find(ge=>ge.id===z.id)||($.value=[...$.value,z],console.log("[TrigoView] Added room to list, new count:",$.value.length,"rooms:",$.value.map(ge=>ge.id)))}),v.onRoomUpdated(z=>{console.log("[TrigoView] >>> Received roomUpdated event:",z);const ge=$.value.findIndex(Nt=>Nt.id===z.id);ge>=0?$.value=[...$.value.slice(0,ge),z,...$.value.slice(ge+1)]:$.value=[...$.value,z],console.log("[TrigoView] roomList after update:",$.value.map(Nt=>Nt.id))}),v.onRoomDeleted(z=>{console.log("[TrigoView] >>> Received roomDeleted event:",z),$.value=$.value.filter(ge=>ge.id!==z.roomId),console.log("[TrigoView] roomList after delete:",$.value.map(ge=>ge.id))})}function Ti(){v.offRoomCreated(),v.offRoomUpdated(),v.offRoomDeleted()}async function gi(z){y.roomId!==z&&(y.roomId&&(v.leaveRoom(),y.leaveRoom()),await _i(z))}async function Ci(){y.roomId&&(v.leaveRoom(),y.leaveRoom()),w(),await ui()}async function di(){if(console.log("[TrigoView] ========== INITIALIZE MULTIPLAYER ROOM =========="),console.log("[TrigoView] isJoiningRoom:",C.value),console.log("[TrigoView] Socket connected:",v.socket.connected),console.log("[TrigoView] Socket ID:",v.socket.id),C.value){console.log("[TrigoView] Already joining, skipping");return}const z=_();console.log("[TrigoView] hashRoomId from URL:",z),z?M(z)?(console.log("[TrigoView] Valid hash found, joining room:",z),await _i(z)):(console.warn(`[TrigoView] Invalid room ID in hash: ${z}`),w(),await ui()):(console.log("[TrigoView] No hash found, creating new room"),await ui())}async function ui(){if(console.log("[TrigoView] createAndJoinRoom called, isJoiningRoom:",C.value),C.value){console.log("[TrigoView] Already joining, returning");return}C.value=!0,console.log("[TrigoView] Set isJoiningRoom to true");try{console.log("[TrigoView] Waiting for socket connection..."),await ei(),console.log("[TrigoView] Socket connection ready, calling joinRoom"),v.joinRoom({nickname:y.nickname},z=>{console.log("[TrigoView] joinRoom callback received:",z),C.value=!1,z.success!==!1&&z.roomId?(y.joinRoom(z.roomId,z.playerColor),x(z.roomId),console.log(`[TrigoView] Room created: ${z.roomId}`)):(console.error("[TrigoView] Failed to create room:",z.error),alert("Failed to create room. Please try again."))})}catch(z){C.value=!1,console.error("[TrigoView] Socket connection failed:",z),alert("Connection failed. Please check your internet and try again.")}}async function _i(z){if(!C.value){C.value=!0;try{await ei(),v.joinRoom({roomId:z,nickname:y.nickname},ge=>{if(C.value=!1,ge.success!==!1&&ge.roomId){if(y.joinRoom(ge.roomId,ge.playerColor),console.log(`[TrigoView] Room joined: ${ge.roomId}`),ge.players&&v.socket.id){for(const[Yt,En]of Object.entries(ge.players))if(Yt!==v.socket.id){y.setOpponentNickname(En.nickname),console.log(`[TrigoView] Opponent found: ${En.nickname}`);break}}(ge.players?Object.keys(ge.players).length:0)>=2&&!Oe.value&&(r.startGame(),ne&&ne.setGameActive(!0),console.log("[TrigoView] Game started - both players present"))}else console.warn("[TrigoView] Failed to join room:",ge.error),Mi(ge.error||"Failed to join room")})}catch(ge){C.value=!1,console.error("[TrigoView] Socket connection failed:",ge),alert("Connection failed. Please check your internet and try again.")}}}function Mi(z){w(),z.includes("not found")?alert("Room not found. Creating a new room..."):z.includes("full")?alert("This room is full. Creating a new room..."):alert(`Failed to join room: ${z}. Creating a new room...`),ui()}function Ai(){if(i.value!=="vs-people")return;const z=_(),ge=y.roomId;z!==ge&&(z&&M(z)?(ge&&v.leaveRoom(),_i(z)):ge?x(ge):ui())}watch(o,z=>{ne&&ne.setCurrentPlayer(z)}),watch(l,()=>{nextTick$1(()=>{if(G.value){const z=G.value.querySelector(".active");z&&z.scrollIntoView({behavior:"smooth",block:"nearest"})}})}),watch(()=>y.roomId,z=>{i.value==="vs-people"&&(z?x(z):w())}),watch(X,z=>{z&&(gt.value=ft.value,Zt.value="valid",Lt.value="")}),onMounted(()=>{console.log("[TrigoView] Component mounted, gameMode:",i.value,"route.path:",n.path,"route.meta.mode:",n.meta.mode);let z=!1;if(i.value!=="vs-people"&&(z=r.loadFromSessionStorage()),z)Vt.value=A(d.value),console.log("Restored game state from session storage");else{const ge=D(Vt.value);r.initializeGame(ge)}U.value&&(ne=new TrigoViewport(U.value,d.value,{onStoneClick:yt,onPositionHover:Qt,isPositionDroppable:It,onInspectGroup:Be}),console.log("TrigoViewport initialized"),Xe.value=!1,z&&(zt(),ne.setGameActive(m.value)),$e=new ResizeObserver(ge=>{for(const Nt of ge)Nt.target===U.value&&ne&&(U.value.getBoundingClientRect(),ne.onWindowResize())}),$e.observe(U.value),console.log("ResizeObserver attached to canvas")),(!z||r.gameStatus==="idle")&&(r.startGame(),ne&&ne.setGameActive(!0)),i.value==="vs-ai"&&(console.log("[TrigoView] Initializing AI agent for VS AI mode..."),Y.initialize().catch(ge=>{console.error("[TrigoView] Failed to initialize AI agent:",ge)})),i.value==="vs-people"&&(console.log("[TrigoView] Setting up socket listeners for VS People mode..."),v.onNicknameChanged(ge=>{console.log(`[TrigoView] Player ${ge.playerId} changed nickname: ${ge.oldNickname} -> ${ge.nickname}`),ge.playerId!==v.socket.id&&y.setOpponentNickname(ge.nickname)}),v.onGameUpdate(ge=>{if(console.log("[TrigoView] Game update received:",ge),ge.currentPlayer&&r.setCurrentPlayer(ge.currentPlayer),ge.action==="move"&&ge.lastMove){const{x:Nt,y:Yt,z:En}=ge.lastMove;if(r.makeMove(Nt,Yt,En).success&&ne){const Mn=r.opponentPlayer;ne.addStone(Nt,Yt,En,Mn),ge.capturedPositions&&ge.capturedPositions.length>0&&(ge.capturedPositions.forEach($n=>{ne.removeStone($n.x,$n.y,$n.z)}),console.log(`[TrigoView] Captured ${ge.capturedPositions.length} stone(s)`)),ne.hideDomainCubes(),wn.value=!1}}else ge.action==="pass"?(r.pass(),console.log("[TrigoView] Pass received from server")):(ge.action==="undo"||ge.action==="redo")&&ge.tgn&&ne&&(r.loadFromTGN(ge.tgn),ne.clearBoard(),ut())}),v.onPlayerJoined(ge=>{console.log("[TrigoView] Player joined:",ge),y.setOpponentNickname(ge.nickname),Oe.value||(r.startGame(),ne&&ne.setGameActive(!0),console.log("[TrigoView] Game started - opponent joined"))}),v.onPlayerLeft(ge=>{console.log("[TrigoView] Player left:",ge),y.setOpponentNickname(null)}),v.onPlayerDisconnected(ge=>{console.log("[TrigoView] Player disconnected:",ge),ge.playerId!==v.socket.id&&y.setOpponentNickname(null)}),v.onGameEnded(ge=>{console.log("[TrigoView] Game ended:",ge),alert(`Game ended! Winner: ${ge.winner||"None"}
6500
  Reason: ${ge.reason}`)}),v.onGameReset(ge=>{if(console.log("[TrigoView] Game reset:",ge),ge.tgn?r.loadFromTGN(ge.tgn):r.resetGame(d.value),ne&&ne.clearBoard(),ge.players&&v.socket.id){const Nt=ge.players[v.socket.id];Nt&&(y.playerColor=Nt.color)}}),v.onError(ge=>{console.error("[TrigoView] Socket error:",ge.message)}),wi(),v.socket.id&&y.setPlayerId(v.socket.id),window.addEventListener("hashchange",Ai),v.socket.on("connect",()=>{console.log("[TrigoView] Socket connected in VS People mode"),v.socket.id&&y.setPlayerId(v.socket.id),mi(),!y.roomId&&!C.value&&(console.log("[TrigoView] Initializing room after socket connection"),di())}),v.socket.on("disconnect",()=>{console.log("[TrigoView] Socket disconnected in VS People mode"),y.roomId?y.connectionStatus="connected":y.disconnect()}),v.socket.connected&&(console.log("[TrigoView] Socket already connected, initializing room"),mi(),di())),window.addEventListener("keydown",j)}),watch(i,(z,ge)=>{console.log(`[TrigoView] Game mode changed: ${ge} -> ${z}`),z==="vs-ai"&&!Q.value&&(console.log("[TrigoView] Switching to VS AI mode, initializing AI agent..."),Y.initialize().then(()=>{Oe.value&&o.value===J.value&&setTimeout(()=>{st()},100)}).catch(Nt=>{console.error("[TrigoView] Failed to initialize AI agent:",Nt)}))}),onUnmounted(()=>{console.log("TrigoDemo component unmounted"),window.removeEventListener("keydown",j),i.value==="vs-people"&&(console.log("[TrigoView] Cleaning up socket listeners..."),v.offNicknameChanged(),v.offGameUpdate(),v.offPlayerJoined(),v.offPlayerLeft(),v.offPlayerDisconnected(),v.offGameEnded(),v.offGameReset(),v.offError(),Ti(),window.removeEventListener("hashchange",Ai)),$e&&($e.disconnect(),$e=null,console.log("ResizeObserver disconnected")),ne&&(ne.destroy(),ne=null)});const j=z=>{if(!(z.target instanceof HTMLInputElement||z.target instanceof HTMLTextAreaElement))switch(z.key.toLowerCase()){case"p":Oe.value&&yn();break;case"n":_t();break;case"r":Oe.value&&_n();break;case"arrowleft":Te(),z.preventDefault();break;case"arrowright":xn(),z.preventDefault();break;case"t":Oe.value&&Nn();break}},Ue={route:n,gameMode:i,gameStore:r,game:s,currentPlayer:o,moveHistory:a,currentMoveIndex:l,capturedStones:c,gameStatus:u,boardShape:d,moveCount:f,isGameActive:m,passCount:b,playerStore:y,socketApi:v,getRoomIdFromHash:_,updateHash:x,clearHash:w,isValidRoomId:M,isJoiningRoom:C,roomList:$,isLoadingRooms:R,parseBoardShape:D,printBoardShape:A,formatMoveCoords:k,aiAgent:Y,aiReady:Q,aiThinking:q,aiError:fe,lastMoveTime:me,loadAIColor:ie,aiPlayerColor:J,humanPlayerColor:H,loadPreferredColor:de,preferredColor:oe,hoveredPosition:V,blackScore:ce,whiteScore:Ie,isLoading:Xe,selectedBoardShape:Vt,showTerritoryMode:wn,showTGNModal:X,inspectInfo:ze,editableTGNContent:gt,tgnValidationState:Zt,tgnValidationError:Lt,get tgnValidationTimeout(){return xe},set tgnValidationTimeout(z){xe=z},viewportCanvas:U,moveHistoryContainer:G,get viewport(){return ne},set viewport(z){ne=z},get resizeObserver(){return $e},set resizeObserver(z){$e=z},gameStarted:Oe,moveRounds:Ge,isBoardShapeDirty:mt,tgnContent:ft,tgnIsValid:Et,tgnValidationClass:bt,tgnValidationMessage:F,onTGNEdit:O,applyTGN:pe,generateAIMove:st,syncViewportWithGame:ut,handleStoneClick:yt,handlePositionHover:Qt,isPositionDroppable:It,handleInspectGroup:Be,swapColors:se,newGame:_t,resetMultiplayerGame:Sn,pass:yn,resign:_n,showGameResult:Cn,computeTerritory:Nn,previousMove:Te,nextMove:xn,jumpToMove:lt,syncViewportWithStore:zt,opponentPlayerColor:bn,isLocalPlayerTurn:Pn,connectionStatusClass:Rn,connectionStatusText:Vn,connectionStatusIcon:ri,updateLocalNickname:zn,copyRoomCode:ai,waitForSocketConnection:ei,fetchRoomList:mi,setupRoomListeners:wi,cleanupRoomListeners:Ti,handleRoomSelect:gi,handleCreateRoom:Ci,initializeMultiplayerRoom:di,createAndJoinRoom:ui,joinRoomByHash:_i,handleJoinFailure:Mi,handleHashChange:Ai,handleKeyPress:j,selectAllTGN:z=>{z.target.select()},copyTGN:async()=>{try{if(navigator.clipboard&&navigator.clipboard.writeText)await navigator.clipboard.writeText(ft.value),alert("TGN copied to clipboard!");else{const z=document.createElement("textarea");z.value=ft.value,z.style.position="fixed",z.style.opacity="0",document.body.appendChild(z),z.select();try{document.execCommand("copy"),alert("TGN copied to clipboard!")}catch(ge){console.error("Fallback copy failed:",ge),alert("Failed to copy TGN. Please select and copy manually.")}finally{document.body.removeChild(z)}}}catch(z){console.error("Failed to copy TGN:",z),alert("Failed to copy TGN. Please select and copy manually.")}},InlineNicknameEditor,RoomSelector};return Object.defineProperty(Ue,"__isScriptSetup",{enumerable:!1,value:!0}),Ue}}),_hoisted_1$a={class:"trigo-view"},_hoisted_2$a={class:"view-header"},_hoisted_3$a={key:0,class:"view-status"},_hoisted_4$a={class:"move-count"},_hoisted_5$a={key:1,class:"view-status ai-mode"},_hoisted_6$a={key:0,class:"ai-level"},_hoisted_7$a={key:1,class:"ai-level ai-thinking"},_hoisted_8$a={key:2,class:"ai-level ai-error"},_hoisted_9$a={class:"move-count"},_hoisted_10$a={key:0,class:"ai-time"},_hoisted_11$7={key:2,class:"view-status people-mode"},_hoisted_12$7={class:"room-info"},_hoisted_13$7={class:"room-code"},_hoisted_14$7={class:"players-info"},_hoisted_15$6={key:1,class:"waiting-text"},_hoisted_16$6={key:3,class:"view-status library-mode"},_hoisted_17$6={key:4,class:"header-controls"},_hoisted_18$6={key:5,class:"header-controls"},_hoisted_19$6={key:6,class:"header-controls"},_hoisted_20$6=["disabled"],_hoisted_21$6={class:"view-body"},_hoisted_22$6={class:"board-container"},_hoisted_23$6={class:"viewport-wrapper"},_hoisted_24$5={ref:"viewportCanvas",class:"viewport-canvas"},_hoisted_25$5={key:0,class:"viewport-overlay"},_hoisted_26$4={key:1,class:"inspect-tooltip"},_hoisted_27$4={class:"tooltip-content"},_hoisted_28$4={class:"tooltip-label"},_hoisted_29$4={class:"tooltip-label"},_hoisted_30$4={class:"controls-panel"},_hoisted_31$4={class:"section-title"},_hoisted_32$4={class:"score-display"},_hoisted_33$4=["disabled"],_hoisted_34$4={class:"score"},_hoisted_35$4=["disabled"],_hoisted_36$3={class:"score"},_hoisted_37$3=["disabled"],_hoisted_38$3={class:"panel-section routine-section"},_hoisted_39$3={class:"section-title"},_hoisted_40$2={class:"routine-content",ref:"moveHistoryContainer"},_hoisted_41$2={class:"move-list"},_hoisted_42$2={class:"round-number"},_hoisted_43$2=["onClick"],_hoisted_44$2={key:0,class:"move-coords"},_hoisted_45$2={key:1,class:"move-label"},_hoisted_46$2=["onClick"],_hoisted_47$2={key:0,class:"move-coords"},_hoisted_48$2={key:1,class:"move-label"},_hoisted_49$2={key:1,class:"move-cell empty"},_hoisted_50$2={class:"panel-section controls-section"},_hoisted_51$2={class:"control-buttons"},_hoisted_52$2={class:"play-controls"},_hoisted_53$2=["disabled"],_hoisted_54$2=["disabled"],_hoisted_55$2={class:"history-controls"},_hoisted_56$2=["disabled"],_hoisted_57$2=["disabled"],_hoisted_58$1={class:"tgn-modal-content"},_hoisted_59$1={class:"tgn-modal-header"},_hoisted_60$1={class:"tgn-modal-body"},_hoisted_61$1={class:"tgn-modal-footer"},_hoisted_62=["disabled"];function _sfc_render$a(t,e,n,i,r,s){return openBlock(),createElementBlock("div",_hoisted_1$a,[createBaseVNode("div",_hoisted_2$a,[i.gameMode==="single"?(openBlock(),createElementBlock("div",_hoisted_3$a,[createBaseVNode("span",{class:normalizeClass(["turn-indicator",{black:i.currentPlayer==="black",white:i.currentPlayer==="white"}])},toDisplayString(i.currentPlayer==="black"?"Black":"White")+"'s Turn ",3),createBaseVNode("span",_hoisted_4$a,"Move: "+toDisplayString(i.moveCount),1)])):i.gameMode==="vs-ai"?(openBlock(),createElementBlock("div",_hoisted_5$a,[createBaseVNode("div",{class:normalizeClass(["player-info",{"on-turn":i.currentPlayer===i.humanPlayerColor}])},[e[10]||(e[10]=createBaseVNode("span",{class:"player-label"},"You:",-1)),createBaseVNode("span",{class:normalizeClass(["stone-icon",i.humanPlayerColor==="black"?"black":"white"])},null,2)],2),createBaseVNode("button",{class:"btn-swap-colors",onClick:i.swapColors},"⇄ Swap"),createBaseVNode("div",{class:normalizeClass(["ai-status",{"on-turn":i.currentPlayer===i.aiPlayerColor&&!i.aiThinking}])},[e[11]||(e[11]=createBaseVNode("span",{class:"ai-indicator"},"🤖 AI:",-1)),i.aiReady?i.aiThinking?(openBlock(),createElementBlock("span",_hoisted_7$a,"Thinking...")):i.aiError?(openBlock(),createElementBlock("span",_hoisted_8$a,"Error")):(openBlock(),createElementBlock("span",{key:3,class:normalizeClass(["stone-icon",i.aiPlayerColor==="black"?"black":"white"])},null,2)):(openBlock(),createElementBlock("span",_hoisted_6$a,"Loading..."))],2),createBaseVNode("span",_hoisted_9$a,"Move: "+toDisplayString(i.moveCount),1),i.lastMoveTime>0?(openBlock(),createElementBlock("span",_hoisted_10$a,"("+toDisplayString(i.lastMoveTime.toFixed(0))+"ms)",1)):createCommentVNode("",!0)])):i.gameMode==="vs-people"?(openBlock(),createElementBlock("div",_hoisted_11$7,[createBaseVNode("div",_hoisted_12$7,[e[12]||(e[12]=createBaseVNode("span",{class:"room-label"},"Room:",-1)),createBaseVNode("span",_hoisted_13$7,toDisplayString(i.playerStore.roomId||"---"),1),i.playerStore.roomId?(openBlock(),createElementBlock("button",{key:0,class:"btn-copy-room",onClick:i.copyRoomCode,title:"Copy room code"}," 📋 ")):createCommentVNode("",!0)]),createBaseVNode("div",_hoisted_14$7,[createBaseVNode("div",{class:normalizeClass(["player-display",{"on-turn":i.isLocalPlayerTurn}])},[createVNode(i.InlineNicknameEditor,{nickname:i.playerStore.nickname,editable:!0,"player-color":i.playerStore.playerColor,onUpdate:i.updateLocalNickname},null,8,["nickname","player-color"])],2),e[13]||(e[13]=createBaseVNode("span",{class:"vs-divider"},"vs",-1)),createBaseVNode("div",{class:normalizeClass(["player-display",{"on-turn":!i.isLocalPlayerTurn}])},[i.playerStore.opponentNickname?(openBlock(),createBlock(i.InlineNicknameEditor,{key:0,nickname:i.playerStore.opponentNickname,editable:!1,"player-color":i.opponentPlayerColor},null,8,["nickname","player-color"])):(openBlock(),createElementBlock("span",_hoisted_15$6,"Waiting..."))],2)]),createBaseVNode("span",{class:normalizeClass(["connection-status",i.connectionStatusClass])},toDisplayString(i.connectionStatusIcon)+" "+toDisplayString(i.connectionStatusText),3)])):i.gameMode==="library"?(openBlock(),createElementBlock("div",_hoisted_16$6,[...e[14]||(e[14]=[createStaticVNode('<div class="game-info" data-v-6ae1493c><span class="game-title" data-v-6ae1493c>Game #12345</span><span class="game-date" data-v-6ae1493c>2025-01-18</span></div><div class="library-actions" data-v-6ae1493c><button class="btn-library btn-load" title="Load Game" data-v-6ae1493c>📂 Load</button><button class="btn-library btn-export" title="Export TGN" data-v-6ae1493c>📤 Export</button></div>',2)])])):createCommentVNode("",!0),i.gameMode==="single"?(openBlock(),createElementBlock("div",_hoisted_17$6,[withDirectives(createBaseVNode("select",{"onUpdate:modelValue":e[0]||(e[0]=o=>i.selectedBoardShape=o),class:"board-shape-select"},[...e[15]||(e[15]=[createStaticVNode('<option value="3x3x3" data-v-6ae1493c>3×3×3</option><option value="5x5x5" data-v-6ae1493c>5×5×5</option><option value="7x7x7" data-v-6ae1493c>7×7×7</option><option value="9x9x1" data-v-6ae1493c>9×9×1 (2D)</option><option value="9x9x9" data-v-6ae1493c>9×9×9</option><option value="5x5x1" data-v-6ae1493c>5×5×1 (2D)</option><option value="7x7x1" data-v-6ae1493c>7×7×1 (2D)</option>',7)])],512),[[vModelSelect,i.selectedBoardShape]]),createBaseVNode("button",{class:"btn-reset",onClick:i.newGame},toDisplayString(i.gameStarted?"Reset":"Start"),1)])):i.gameMode==="vs-ai"?(openBlock(),createElementBlock("div",_hoisted_18$6,[withDirectives(createBaseVNode("select",{"onUpdate:modelValue":e[1]||(e[1]=o=>i.selectedBoardShape=o),class:"board-shape-select"},[...e[16]||(e[16]=[createStaticVNode('<option value="3x3x3" data-v-6ae1493c>3×3×3</option><option value="5x5x5" data-v-6ae1493c>5��5×5</option><option value="7x7x7" data-v-6ae1493c>7×7×7</option><option value="9x9x1" data-v-6ae1493c>9×9×1 (2D)</option><option value="9x9x9" data-v-6ae1493c>9×9×9</option><option value="5x5x1" data-v-6ae1493c>5×5×1 (2D)</option><option value="7x7x1" data-v-6ae1493c>7×7×1 (2D)</option>',7)])],512),[[vModelSelect,i.selectedBoardShape]]),createBaseVNode("button",{class:"btn-reset",onClick:i.newGame},toDisplayString(i.gameStarted?"Reset":"Start"),1)])):i.gameMode==="vs-people"?(openBlock(),createElementBlock("div",_hoisted_19$6,[createVNode(i.RoomSelector,{"current-room":i.playerStore.roomId,rooms:i.roomList,loading:i.isLoadingRooms,disabled:i.gameStarted&&i.playerStore.hasOpponent,onCreate:i.handleCreateRoom,onSelect:i.handleRoomSelect},null,8,["current-room","rooms","loading","disabled"]),withDirectives(createBaseVNode("select",{"onUpdate:modelValue":e[2]||(e[2]=o=>i.preferredColor=o),class:"color-preference-select",disabled:i.gameStarted||t.connectionStatus==="in-room"},[...e[17]||(e[17]=[createBaseVNode("option",{value:"black"},"Play as Black",-1),createBaseVNode("option",{value:"white"},"Play as White",-1)])],8,_hoisted_20$6),[[vModelSelect,i.preferredColor]]),withDirectives(createBaseVNode("select",{"onUpdate:modelValue":e[3]||(e[3]=o=>i.selectedBoardShape=o),class:"board-shape-select"},[...e[18]||(e[18]=[createStaticVNode('<option value="3x3x3" data-v-6ae1493c>3×3×3</option><option value="5x5x5" data-v-6ae1493c>5×5×5</option><option value="7x7x7" data-v-6ae1493c>7×7×7</option><option value="9x9x1" data-v-6ae1493c>9×9×1 (2D)</option><option value="9x9x9" data-v-6ae1493c>9×9×9</option><option value="5x5x1" data-v-6ae1493c>5×5×1 (2D)</option><option value="7x7x1" data-v-6ae1493c>7×7×1 (2D)</option>',7)])],512),[[vModelSelect,i.selectedBoardShape]]),createBaseVNode("button",{class:"btn-reset",onClick:i.resetMultiplayerGame},"Reset")])):createCommentVNode("",!0)]),createBaseVNode("div",_hoisted_21$6,[createBaseVNode("div",_hoisted_22$6,[createBaseVNode("div",_hoisted_23$6,[createBaseVNode("canvas",_hoisted_24$5,null,512),i.isLoading?(openBlock(),createElementBlock("div",_hoisted_25$5,[...e[19]||(e[19]=[createBaseVNode("p",{class:"loading-text"},"Loading 3D Board...",-1)])])):createCommentVNode("",!0),i.inspectInfo.visible?(openBlock(),createElementBlock("div",_hoisted_26$4,[createBaseVNode("div",_hoisted_27$4,[createBaseVNode("span",_hoisted_28$4,toDisplayString(i.inspectInfo.groupSize)+" stone"+toDisplayString(i.inspectInfo.groupSize>1?"s":""),1),e[20]||(e[20]=createBaseVNode("span",{class:"tooltip-divider"},"|",-1)),createBaseVNode("span",_hoisted_29$4,"Liberties: "+toDisplayString(i.inspectInfo.liberties),1)])])):createCommentVNode("",!0)])]),createBaseVNode("div",_hoisted_30$4,[createBaseVNode("div",{class:normalizeClass(["panel-section score-section",{"show-territory":i.showTerritoryMode}])},[createBaseVNode("h3",_hoisted_31$4,toDisplayString(i.showTerritoryMode?"Territory":"Captured"),1),createBaseVNode("div",_hoisted_32$4,[createBaseVNode("button",{class:"score-button black",disabled:!i.gameStarted},[e[21]||(e[21]=createBaseVNode("span",{class:"color-indicator black-stone"},null,-1)),createBaseVNode("span",_hoisted_34$4,toDisplayString(i.showTerritoryMode?i.blackScore:i.capturedStones.black),1)],8,_hoisted_33$4),createBaseVNode("button",{class:"score-button white",disabled:!i.gameStarted},[e[22]||(e[22]=createBaseVNode("span",{class:"color-indicator white-stone"},null,-1)),createBaseVNode("span",_hoisted_36$3,toDisplayString(i.showTerritoryMode?i.whiteScore:i.capturedStones.white),1)],8,_hoisted_35$4)]),createBaseVNode("button",{class:"compute-territory",onClick:i.computeTerritory,disabled:!i.gameStarted}," Compute Territory ",8,_hoisted_37$3)],2),createBaseVNode("div",_hoisted_38$3,[createBaseVNode("h3",_hoisted_39$3,[e[23]||(e[23]=createTextVNode(" Move History ",-1)),createBaseVNode("button",{class:"btn-view-tgn",onClick:e[4]||(e[4]=o=>i.showTGNModal=!0),title:"View TGN Notation"}," TGN ")]),createBaseVNode("div",_hoisted_40$2,[createBaseVNode("div",_hoisted_41$2,[createBaseVNode("div",{class:normalizeClass([{active:i.currentMoveIndex===0},"move-row start-row"]),onClick:e[5]||(e[5]=o=>i.jumpToMove(0))},[...e[24]||(e[24]=[createBaseVNode("span",{class:"round-number"},null,-1),createBaseVNode("span",{class:"move-label open-label"},"OPEN",-1)])],2),(openBlock(!0),createElementBlock(Fragment,null,renderList(i.moveRounds,(o,a)=>(openBlock(),createElementBlock("div",{key:a,class:"move-row"},[createBaseVNode("span",_hoisted_42$2,toDisplayString(a+1)+".",1),createBaseVNode("div",{class:normalizeClass(["move-cell black-move",{active:o.blackIndex===i.currentMoveIndex}]),onClick:l=>i.jumpToMove(o.blackIndex)},[e[25]||(e[25]=createBaseVNode("span",{class:"stone-icon black"},null,-1)),o.black.isPass?(openBlock(),createElementBlock("span",_hoisted_45$2,"pass")):(openBlock(),createElementBlock("span",_hoisted_44$2,toDisplayString(i.formatMoveCoords(o.black)),1))],10,_hoisted_43$2),o.white?(openBlock(),createElementBlock("div",{key:0,class:normalizeClass(["move-cell white-move",{active:o.whiteIndex===i.currentMoveIndex}]),onClick:l=>i.jumpToMove(o.whiteIndex)},[e[26]||(e[26]=createBaseVNode("span",{class:"stone-icon white"},null,-1)),o.white.isPass?(openBlock(),createElementBlock("span",_hoisted_48$2,"pass")):(openBlock(),createElementBlock("span",_hoisted_47$2,toDisplayString(i.formatMoveCoords(o.white)),1))],10,_hoisted_46$2)):(openBlock(),createElementBlock("div",_hoisted_49$2))]))),128))])],512)]),createBaseVNode("div",_hoisted_50$2,[e[27]||(e[27]=createBaseVNode("h3",{class:"section-title"},"Controls",-1)),createBaseVNode("div",_hoisted_51$2,[createBaseVNode("div",_hoisted_52$2,[createBaseVNode("button",{class:"btn btn-pass",onClick:i.pass,disabled:!i.gameStarted}," Pass ",8,_hoisted_53$2),createBaseVNode("button",{class:"btn btn-resign",onClick:i.resign,disabled:!i.gameStarted}," Resign ",8,_hoisted_54$2)]),createBaseVNode("div",_hoisted_55$2,[createBaseVNode("button",{class:"btn btn-icon btn-prev",onClick:i.previousMove,disabled:i.currentMoveIndex<=0,title:"Previous Move"}," ◀ ",8,_hoisted_56$2),createBaseVNode("button",{class:"btn btn-icon btn-next",onClick:i.nextMove,disabled:i.currentMoveIndex>=i.moveHistory.length,title:"Next Move"}," ▶ ",8,_hoisted_57$2)])])])])]),i.showTGNModal?(openBlock(),createElementBlock("div",{key:0,class:"tgn-modal",onClick:e[9]||(e[9]=withModifiers(o=>i.showTGNModal=!1,["self"]))},[createBaseVNode("div",_hoisted_58$1,[createBaseVNode("div",_hoisted_59$1,[e[28]||(e[28]=createBaseVNode("h3",null,"Game Notation (TGN)",-1)),createBaseVNode("div",{class:normalizeClass(["tgn-status",i.tgnValidationClass])},toDisplayString(i.tgnValidationMessage),3),createBaseVNode("button",{class:"btn-close",onClick:e[6]||(e[6]=o=>i.showTGNModal=!1)},"×")]),createBaseVNode("div",_hoisted_60$1,[withDirectives(createBaseVNode("textarea",{"onUpdate:modelValue":e[7]||(e[7]=o=>i.editableTGNContent=o),class:normalizeClass(["tgn-textarea",i.tgnValidationClass]),onInput:i.onTGNEdit,placeholder:"Enter TGN game notation..."},null,34),[[vModelText,i.editableTGNContent]])]),createBaseVNode("div",_hoisted_61$1,[createBaseVNode("button",{class:"btn btn-apply",onClick:i.applyTGN,disabled:!i.tgnIsValid}," Apply TGN ",8,_hoisted_62),createBaseVNode("button",{class:"btn btn-copy",onClick:i.copyTGN},"Copy to Clipboard"),createBaseVNode("button",{class:"btn btn-close-modal",onClick:e[8]||(e[8]=o=>i.showTGNModal=!1)},"Close")])])])):createCommentVNode("",!0)])}const TrigoView=_export_sfc(_sfc_main$a,[["render",_sfc_render$a],["__scopeId","data-v-6ae1493c"],["__file","/home/camus/work/trigo/trigo-web/app/src/views/TrigoView.vue"]]),_sfc_main$9=defineComponent({__name:"OnnxTestView",setup(t,{expose:e}){e();let n=null;const i=ref(!1),r=ref(!1),s=ref(!1),o=ref(null),a=ref(null),l=ref(null),c=ref(null),u=ref("[Board 5x5]"),d=ref(10),v={get inferencer(){return n},set inferencer(_){n=_},isInitializing:i,isInitialized:r,isRunning:s,error:o,modelInfo:a,basicTestResult:l,generationResult:c,prompt:u,numTokens:d,initialize:async()=>{i.value=!0,o.value=null;try{console.log("=".repeat(80)),console.log("Initializing ONNX Inferencer..."),console.log("=".repeat(80)),n=new OnnxInferencer({modelPath:"/onnx/20251230-trigo-value-llama-l6-h64-it2_251221-value0.01-pretrain/LlamaCausalLM_ep0036_tree.onnx",vocabSize:128,seqLen:256,executionProviders:["wasm"]}),await n.initialize(),a.value=n.getModelInfo(),r.value=!0,console.log("✓ Initialization complete!"),console.log("=".repeat(80))}catch(_){o.value=_ instanceof Error?_.message:"Unknown error",console.error("Initialization failed:",_)}finally{i.value=!1}},runBasicTest:async()=>{if(n){s.value=!0,o.value=null,l.value=null;try{console.log(`
6501
  `+"=".repeat(80)),console.log("Running Basic Inference Test..."),console.log("=".repeat(80));const _=await n.testBasicInference();l.value=_,console.log("✓ Basic test complete!"),console.log("=".repeat(80))}catch(_){o.value=_ instanceof Error?_.message:"Test failed",console.error("Basic test failed:",_)}finally{s.value=!1}}},runGenerationTest:async()=>{if(n){s.value=!0,o.value=null,c.value=null;try{console.log(`
6502
  `+"=".repeat(80)),console.log("Running Text Generation Test..."),console.log("=".repeat(80));const _=await n.generateText(u.value,d.value);c.value=_,console.log("✓ Generation test complete!"),console.log("=".repeat(80))}catch(_){o.value=_ instanceof Error?_.message:"Generation failed",console.error("Generation test failed:",_)}finally{s.value=!1}}},clearConsole:()=>{console.clear(),console.log("Console cleared")}};return Object.defineProperty(v,"__isScriptSetup",{enumerable:!1,value:!0}),v}}),_hoisted_1$9={class:"onnx-test-view"},_hoisted_2$9={class:"test-body"},_hoisted_3$9={class:"test-section"},_hoisted_4$9={class:"status-info"},_hoisted_5$9={class:"status-value"},_hoisted_6$9={key:0,class:"status-item"},_hoisted_7$9={class:"status-value"},_hoisted_8$9={key:1,class:"status-item"},_hoisted_9$9={class:"status-value"},_hoisted_10$9={key:2,class:"error-message"},_hoisted_11$6=["disabled"],_hoisted_12$6={class:"test-section"},_hoisted_13$6=["disabled"],_hoisted_14$6={key:0,class:"test-result"},_hoisted_15$5={class:"result-item"},_hoisted_16$5={class:"value"},_hoisted_17$5={class:"result-item"},_hoisted_18$5={class:"value code"},_hoisted_19$5={class:"result-item"},_hoisted_20$5={class:"value code"},_hoisted_21$5={class:"test-section"},_hoisted_22$5={class:"input-group"},_hoisted_23$5=["disabled"],_hoisted_24$4={class:"input-group"},_hoisted_25$4=["disabled"],_hoisted_26$3=["disabled"],_hoisted_27$3={key:0,class:"test-result"},_hoisted_28$3={class:"result-item"},_hoisted_29$3={class:"value"},_hoisted_30$3={class:"result-item"},_hoisted_31$3={class:"value"},_hoisted_32$3={class:"result-item full-width"},_hoisted_33$3={class:"value code"},_hoisted_34$3={class:"result-item full-width"},_hoisted_35$3={class:"generated-text"};function _sfc_render$9(t,e,n,i,r,s){return openBlock(),createElementBlock("div",_hoisted_1$9,[e[23]||(e[23]=createBaseVNode("div",{class:"test-header"},[createBaseVNode("h1",null,"ONNX Model Inferencer Test"),createBaseVNode("p",{class:"subtitle"},"Testing GPT-2 Causal LM with ONNX Runtime Web")],-1)),createBaseVNode("div",_hoisted_2$9,[createBaseVNode("div",_hoisted_3$9,[e[5]||(e[5]=createBaseVNode("h2",null,"Model Status",-1)),createBaseVNode("div",_hoisted_4$9,[createBaseVNode("div",{class:normalizeClass(["status-item",{ready:i.isInitialized,loading:i.isInitializing}])},[e[2]||(e[2]=createBaseVNode("span",{class:"status-label"},"Status:",-1)),createBaseVNode("span",_hoisted_5$9,toDisplayString(i.isInitialized?"✓ Ready":i.isInitializing?"⏳ Initializing...":"⚪ Not initialized"),1)],2),i.modelInfo?(openBlock(),createElementBlock("div",_hoisted_6$9,[e[3]||(e[3]=createBaseVNode("span",{class:"status-label"},"Inputs:",-1)),createBaseVNode("span",_hoisted_7$9,toDisplayString(i.modelInfo.inputs.join(", ")),1)])):createCommentVNode("",!0),i.modelInfo?(openBlock(),createElementBlock("div",_hoisted_8$9,[e[4]||(e[4]=createBaseVNode("span",{class:"status-label"},"Outputs:",-1)),createBaseVNode("span",_hoisted_9$9,toDisplayString(i.modelInfo.outputs.join(", ")),1)])):createCommentVNode("",!0),i.error?(openBlock(),createElementBlock("div",_hoisted_10$9,"❌ Error: "+toDisplayString(i.error),1)):createCommentVNode("",!0)]),createBaseVNode("button",{class:"btn btn-primary",onClick:i.initialize,disabled:i.isInitializing||i.isInitialized},toDisplayString(i.isInitialized?"Initialized":"Initialize Model"),9,_hoisted_11$6)]),createBaseVNode("div",_hoisted_12$6,[e[10]||(e[10]=createBaseVNode("h2",null,"Test 1: Basic Inference",-1)),e[11]||(e[11]=createBaseVNode("p",null,"Run a single forward pass with random input",-1)),createBaseVNode("button",{class:"btn btn-test",onClick:i.runBasicTest,disabled:!i.isInitialized||i.isRunning},toDisplayString(i.isRunning?"Running...":"Run Basic Test"),9,_hoisted_13$6),i.basicTestResult?(openBlock(),createElementBlock("div",_hoisted_14$6,[e[9]||(e[9]=createBaseVNode("h3",null,"Results:",-1)),createBaseVNode("div",_hoisted_15$5,[e[6]||(e[6]=createBaseVNode("span",{class:"label"},"Inference Time:",-1)),createBaseVNode("span",_hoisted_16$5,toDisplayString(i.basicTestResult.inferenceTime.toFixed(2))+"ms",1)]),createBaseVNode("div",_hoisted_17$5,[e[7]||(e[7]=createBaseVNode("span",{class:"label"},"Sample Tokens:",-1)),createBaseVNode("span",_hoisted_18$5,toDisplayString(i.basicTestResult.tokens.slice(0,20).join(", "))+"...",1)]),createBaseVNode("div",_hoisted_19$5,[e[8]||(e[8]=createBaseVNode("span",{class:"label"},"Sample Text:",-1)),createBaseVNode("span",_hoisted_20$5,toDisplayString(i.basicTestResult.text.slice(0,100))+"...",1)])])):createCommentVNode("",!0)]),createBaseVNode("div",_hoisted_21$5,[e[19]||(e[19]=createBaseVNode("h2",null,"Test 2: Text Generation",-1)),e[20]||(e[20]=createBaseVNode("p",null,"Generate tokens autoregressively from a prompt",-1)),createBaseVNode("div",_hoisted_22$5,[e[12]||(e[12]=createBaseVNode("label",{for:"prompt"},"Prompt:",-1)),withDirectives(createBaseVNode("input",{id:"prompt","onUpdate:modelValue":e[0]||(e[0]=o=>i.prompt=o),type:"text",placeholder:"Enter prompt text...",disabled:!i.isInitialized},null,8,_hoisted_23$5),[[vModelText,i.prompt]])]),createBaseVNode("div",_hoisted_24$4,[e[13]||(e[13]=createBaseVNode("label",{for:"numTokens"},"Number of Tokens:",-1)),withDirectives(createBaseVNode("input",{id:"numTokens","onUpdate:modelValue":e[1]||(e[1]=o=>i.numTokens=o),type:"number",min:"1",max:"50",disabled:!i.isInitialized},null,8,_hoisted_25$4),[[vModelText,i.numTokens,void 0,{number:!0}]])]),createBaseVNode("button",{class:"btn btn-test",onClick:i.runGenerationTest,disabled:!i.isInitialized||i.isRunning||!i.prompt},toDisplayString(i.isRunning?"Generating...":"Generate Text"),9,_hoisted_26$3),i.generationResult?(openBlock(),createElementBlock("div",_hoisted_27$3,[e[18]||(e[18]=createBaseVNode("h3",null,"Generated Output:",-1)),createBaseVNode("div",_hoisted_28$3,[e[14]||(e[14]=createBaseVNode("span",{class:"label"},"Avg Inference Time:",-1)),createBaseVNode("span",_hoisted_29$3,toDisplayString(i.generationResult.inferenceTime.toFixed(2))+"ms",1)]),createBaseVNode("div",_hoisted_30$3,[e[15]||(e[15]=createBaseVNode("span",{class:"label"},"Tokens/sec:",-1)),createBaseVNode("span",_hoisted_31$3,toDisplayString((1e3/i.generationResult.inferenceTime).toFixed(2)),1)]),createBaseVNode("div",_hoisted_32$3,[e[16]||(e[16]=createBaseVNode("span",{class:"label"},"Token Sequence:",-1)),createBaseVNode("span",_hoisted_33$3,toDisplayString(i.generationResult.tokens.join(", ")),1)]),createBaseVNode("div",_hoisted_34$3,[e[17]||(e[17]=createBaseVNode("span",{class:"label"},"Generated Text:",-1)),createBaseVNode("div",_hoisted_35$3,toDisplayString(i.generationResult.text),1)])])):createCommentVNode("",!0)]),createBaseVNode("div",{class:"test-section"},[e[21]||(e[21]=createBaseVNode("h2",null,"Console Output",-1)),e[22]||(e[22]=createBaseVNode("p",null,"Check the browser console (F12) for detailed logs",-1)),createBaseVNode("button",{class:"btn btn-secondary",onClick:i.clearConsole},"Clear Console")])])])}const OnnxTestView=_export_sfc(_sfc_main$9,[["render",_sfc_render$9],["__scopeId","data-v-ee339f1a"],["__file","/home/camus/work/trigo/trigo-web/app/src/views/OnnxTestView.vue"]]);class TrigoAgent{constructor(e){this.inferencer=e}isInitialized(){return this.inferencer!==null}stoneToPlayer(e){if(e===StoneType.BLACK)return"black";if(e===StoneType.WHITE)return"white";throw new Error(`Invalid stone type: ${e}`)}stringToTokens(e){return Array.from(e).map(n=>n.charCodeAt(0))}softmax(e,n){const i=new Float32Array(n);let r=-1/0;for(let o=0;o<n;o++)e[o]>r&&(r=e[o]);let s=0;for(let o=0;o<n;o++)i[o]=Math.exp(e[o]-r),s+=i[o];for(let o=0;o<n;o++)i[o]/=s;return i}async scoreMove(e,n){const i=e.clone();let r;if(n.isPass)r=i.pass();else if(n.x!==void 0&&n.y!==void 0&&n.z!==void 0)r=i.drop({x:n.x,y:n.y,z:n.z});else return-1e3;if(!r)return-1e3;const s=i.toTGN().trim(),o=this.extractMoveTokens(s);if(o.length===0)return-100;const a=this.stringToTokens(s),l=this.inferencer.getConfig(),c=l.seqLen,u=l.vocabSize;a.length>c&&a.splice(0,a.length-c);const d=await this.inferencer.runInference(a),f=a.length-o.length;let m=0;for(let b=0;b<o.length;b++){const y=f+b;if(y<0||y>=a.length)continue;const v=y*u,_=d.slice(v,v+u),x=this.softmax(_,u),w=o[b],M=x[w];M>0?m+=Math.log(M):m+=-100}return m}extractMoveTokens(e){const n=e.match(/[Pa-z0]+$/);return this.stringToTokens(n?n[0]:"")}async selectBestMove(e){if(!this.isInitialized())throw new Error("Agent not initialized. Pass initialized inferencer to constructor.");console.log("[TrigoAgent] Selecting move...");const n=this.stoneToPlayer(e.getCurrentPlayer()),i=e.validMovePositions().map(o=>({x:o.x,y:o.y,z:o.z,player:n}));if(i.push({player:n,isPass:!0}),i.length===0)return console.log("[TrigoAgent] No valid moves available"),null;console.log(`[TrigoAgent] Evaluating ${i.length} valid moves...`);const r=[];for(const o of i){const a=await this.scoreMove(e,o);r.push({move:o,score:Math.exp(a),logProb:a})}r.sort((o,a)=>a.logProb-o.logProb);const s=r[0];console.debug("scores:",r),console.log("[TrigoAgent] Best move:",s.move,"score:",s.score.toFixed(6)),console.log("[TrigoAgent] Top 5 moves:");for(let o=0;o<Math.min(5,r.length);o++)console.log(` ${o+1}. ${r[o].move}: ${r[o].score.toFixed(6)}`);return s.move}destroy(){this.inferencer.destroy(),console.log("[TrigoAgent] Destroyed")}}const _sfc_main$8=defineComponent({__name:"TrigoAgentTestView",setup(t,{expose:e}){e();let n=null,i=null;const r=shallowRef(null),s=ref(!1),o=ref(!1),a=ref(!1),l=ref(null),c=ref({x:5,y:5,z:5}),u=ref("black"),d=ref([]),f=ref(!1),m=ref(null),b=computed(()=>(console.log("validMovesCount:",r),r.value?x():0)),y=computed(()=>r.value?r.value.toTGN():"[Board 5x5] *"),v=async()=>{s.value=!0,l.value=null;try{console.log("=".repeat(80)),console.log("[TrigoAgentTest] Initializing AI agent..."),console.log("=".repeat(80)),n=new OnnxInferencer({modelPath:"/onnx/20251230-trigo-value-llama-l6-h64-it2_251221-value0.01-pretrain/LlamaCausalLM_ep0036_tree.onnx",vocabSize:128,seqLen:256}),await n.initialize(),i=new TrigoAgent(n),o.value=!0,_(),console.log("[TrigoAgentTest] ✓ Agent initialized successfully!"),console.log("=".repeat(80))}catch(D){l.value=D instanceof Error?D.message:"Unknown error",console.error("[TrigoAgentTest] Initialization failed:",D)}finally{s.value=!1}},_=()=>{console.log("[TrigoAgentTest] Resetting game.value..."),r.value=new TrigoGame(c.value),u.value="black",d.value=[],f.value=!0,m.value=null,console.log("[TrigoAgentTest] ✓ Game reset")},x=()=>(console.debug("getValidMovesCount:",r),r.value?r.value.validMovePositions().length:0),R={get inferencer(){return n},set inferencer(D){n=D},get agent(){return i},set agent(D){i=D},game:r,isInitializing:s,isInitialized:o,isGenerating:a,error:l,boardShape:c,currentPlayer:u,moveHistory:d,gameStarted:f,moveResult:m,validMovesCount:b,currentTGN:y,initialize:v,resetGame:_,getValidMovesCount:x,makeRandomMove:()=>{if(!r.value)return;const D=r.value.validMovePositions();if(D.length===0){console.log("[TrigoAgentTest] No valid moves available");return}const A=D[Math.floor(Math.random()*D.length)],k=r.value.getShape(),Y=encodeAb0yz([A.x,A.y,A.z],[k.x,k.y,k.z]);r.value.drop(A),d.value.push({player:u.value,notation:Y,position:`(${A.x}, ${A.y}, ${A.z})`}),u.value=u.value==="black"?"white":"black",console.log(`[TrigoAgentTest] Random move: ${Y} at ${A.x},${A.y},${A.z}`)},testGenerateMove:async()=>{if(!(!i||!r)){a.value=!0,l.value=null,m.value=null;try{console.log(`
trigo-web/app/dist/index.html CHANGED
@@ -5,7 +5,7 @@
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
  <title>Trigo - 3D Go Game</title>
8
- <script type="module" crossorigin src="/assets/index-C0GpWl8S.js"></script>
9
  <link rel="stylesheet" crossorigin href="/assets/index-Siwlapuk.css">
10
  </head>
11
  <body>
 
5
  <link rel="icon" type="image/svg+xml" href="/vite.svg" />
6
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
7
  <title>Trigo - 3D Go Game</title>
8
+ <script type="module" crossorigin src="/assets/index-CxJ9O80R.js"></script>
9
  <link rel="stylesheet" crossorigin href="/assets/index-Siwlapuk.css">
10
  </head>
11
  <body>
trigo-web/app/src/views/TrigoView.vue CHANGED
@@ -1393,7 +1393,7 @@
1393
 
1394
  // Lifecycle hooks
1395
  onMounted(() => {
1396
- console.log("TrigoDemo component mounted");
1397
 
1398
  // In VS People mode, always start fresh (server maintains authoritative state)
1399
  // In other modes, try to restore from session storage
 
1393
 
1394
  // Lifecycle hooks
1395
  onMounted(() => {
1396
+ console.log("[TrigoView] Component mounted, gameMode:", gameMode.value, "route.path:", route.path, "route.meta.mode:", route.meta.mode);
1397
 
1398
  // In VS People mode, always start fresh (server maintains authoritative state)
1399
  // In other modes, try to restore from session storage
trigo-web/app/test-frontend-flow.cjs ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { io } = require('socket.io-client');
2
+
3
+ console.log('=== Testing Frontend Flow on HF Space ===');
4
+ console.log('');
5
+
6
+ const serverUrl = 'https://k-l-lambda-trigo.hf.space';
7
+ console.log('[1] Creating socket with URL:', serverUrl);
8
+
9
+ let socketConnectedOnCreate = false;
10
+ const socket = io(serverUrl, {
11
+ autoConnect: true,
12
+ reconnection: true,
13
+ transports: ['polling', 'websocket']
14
+ });
15
+
16
+ // Check if connected immediately (before setting up listeners)
17
+ console.log('[2] Socket connected immediately after create?', socket.connected);
18
+ socketConnectedOnCreate = socket.connected;
19
+
20
+ // Set up connect listener (simulating what useSocket does)
21
+ socket.on('connect', () => {
22
+ console.log('[3a] Socket connect event fired! ID:', socket.id);
23
+ console.log('[3b] Socket.connected value:', socket.connected);
24
+ });
25
+
26
+ // Simulate onMounted running "shortly after"
27
+ setTimeout(() => {
28
+ console.log('');
29
+ console.log('[4] === Simulating onMounted ===');
30
+ console.log('[4a] gameMode is "vs-people" (assumed)');
31
+ console.log('[4b] Setting up connect listener in TrigoView...');
32
+
33
+ // This is what TrigoView does - set up another connect listener
34
+ socket.on('connect', () => {
35
+ console.log('[5] TrigoView connect listener fired!');
36
+ console.log('[5a] Would call fetchRoomList() here');
37
+
38
+ socket.emit('listRooms', (response) => {
39
+ console.log('[5b] listRooms response:', JSON.stringify(response));
40
+ });
41
+ });
42
+
43
+ // Check if socket is already connected
44
+ console.log('[4c] socket.connected at onMounted time:', socket.connected);
45
+
46
+ if (socket.connected) {
47
+ console.log('[4d] Socket already connected, calling fetchRoomList directly');
48
+ socket.emit('listRooms', (response) => {
49
+ console.log('[4e] listRooms response:', JSON.stringify(response));
50
+ socket.disconnect();
51
+ process.exit(0);
52
+ });
53
+ } else {
54
+ console.log('[4d] Socket not connected yet, waiting for connect event');
55
+ }
56
+ }, 100); // Small delay to simulate Vue's mounting
57
+
58
+ setTimeout(() => {
59
+ console.log('Timeout - test complete');
60
+ socket.disconnect();
61
+ process.exit(0);
62
+ }, 10000);
trigo-web/app/test-hf-rooms.cjs ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ const { io } = require('socket.io-client');
2
+
3
+ const socket = io('https://k-l-lambda-trigo.hf.space', {
4
+ transports: ['websocket', 'polling'],
5
+ timeout: 10000
6
+ });
7
+
8
+ socket.on('connect', () => {
9
+ console.log('Connected to HF Space, socket id:', socket.id);
10
+
11
+ // Test listRooms
12
+ console.log('Calling listRooms...');
13
+ socket.emit('listRooms', (response) => {
14
+ console.log('listRooms response:', JSON.stringify(response, null, 2));
15
+
16
+ // Create a room to test
17
+ console.log('Creating a room...');
18
+ socket.emit('joinRoom', { nickname: 'TestBot' }, (joinResponse) => {
19
+ console.log('joinRoom response:', JSON.stringify(joinResponse, null, 2));
20
+
21
+ // List rooms again
22
+ setTimeout(() => {
23
+ socket.emit('listRooms', (response2) => {
24
+ console.log('listRooms after create:', JSON.stringify(response2, null, 2));
25
+ socket.disconnect();
26
+ process.exit(0);
27
+ });
28
+ }, 500);
29
+ });
30
+ });
31
+ });
32
+
33
+ socket.on('connect_error', (err) => {
34
+ console.error('Connection error:', err.message);
35
+ process.exit(1);
36
+ });
37
+
38
+ setTimeout(() => {
39
+ console.log('Timeout - no response');
40
+ process.exit(1);
41
+ }, 15000);