import{r as d,j as s,i as c,b as I}from"./index-iQt3bUih.js";import{P as j,s as h}from"./flags-2LIwgBXb.js";const p=t=>{const a=t.name||"未命名角色",n=t.accountName||"Steam 名稱未讀取",r=t.playerUid||"遊戲 UID 未讀取";return`${a}｜遊戲 UID ${r}｜Steam ${n}｜${h(t.userId)}`};function N({roster:t,value:a,onChange:n,allowManual:r=!0,placeholder:x}){const o=t.filter(e=>e.online),m=t.filter(e=>!e.online),i=t.find(e=>e.userId===a),[l,u]=d.useState("");return d.useEffect(()=>{a||u("")},[a]),a?s.jsxs("div",{className:`${c} player-picker-selected`,children:[i?s.jsx(j,{compact:!0,gameName:i.name,steamName:i.accountName,playerUid:i.playerUid,userId:i.userId}):s.jsxs("span",{className:"player-picker-manual",children:[s.jsx("b",{children:"手動輸入 ID"}),s.jsx("code",{children:a})]}),s.jsx("button",{type:"button",onClick:()=>n(""),"aria-label":"清除玩家",children:s.jsx(I,{})})]}):s.jsxs("div",{className:"player-picker-field",children:[t.length>0&&s.jsxs("select",{className:`${c} player-picker-select`,value:"",onChange:e=>n(e.target.value),children:[s.jsx("option",{value:"",children:"— 選擇玩家（角色／Steam／UID）—"}),o.length>0&&s.jsx("optgroup",{label:"目前在線",children:o.map(e=>s.jsx("option",{value:e.userId,children:p(e)},e.userId))}),m.length>0&&s.jsx("optgroup",{label:"離線與歷史玩家",children:m.map(e=>s.jsx("option",{value:e.userId,children:p(e)},e.userId))})]}),r&&s.jsx("input",{className:c,value:l,onChange:e=>u(e.target.value),onKeyDown:e=>{e.key==="Enter"&&l.trim()&&n(l.trim())},onBlur:()=>{l.trim()&&n(l.trim())},placeholder:t.length?"或貼上完整 SteamID／UserId":x??"輸入 SteamID／UserId"})]})}export{N as P};
