const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SettingsEditor-CMCYOYER.js","assets/index-iQt3bUih.js","assets/index-BMX7ojAW.css","assets/FileManager-C7_MM5sx.js","assets/ConfigCorruptModal-DBJZLU1c.js","assets/ModsTab-zBqx0FQb.js","assets/ModInstallCard-DcEowQcH.js","assets/PalDefenderTab-DSD4gBLz.js","assets/PalStatsTab-Cq_xrzkA.js","assets/entityCategories-wEy3Bkeq.js","assets/gameData-CvtDsga6.js","assets/BossRespawnTab--KBPhUJ9.js","assets/boss-respawn-BN2WmTii.js","assets/BreedingTab-Ca0JFoY9.js","assets/MultiPicker-B6LPPT69.js","assets/dataCenterIntent-ChOm9q0j.js","assets/WebhookSettingsTab-Bg_Ot8dC.js","assets/CopyPath-DQAeVAZu.js","assets/clipboard-t_-sNjVI.js","assets/DiscordBotTab-Ccn5HLdD.js","assets/PlayersTab-DHbDNabq.js","assets/flags-2LIwgBXb.js","assets/PlayerActionsMenu-CMsPh6AH.js","assets/ConsoleTab-C9ImPlCA.js","assets/PlayerPicker-BdUU0Ccd.js","assets/GrantEntityDetails-eANc5OZy.js","assets/gameDataInsights-B4wQTLgc.js","assets/mapLayers-CfwBxAIe.js","assets/mapLayers-CIGW-MKW.css","assets/GuildsTab-B39NUouq.js","assets/GuildDetailModal-CJMSaXWi.js","assets/LeaderboardTab-CoNGV1ZZ.js","assets/ActivityDirectorTab-enCAOqHD.js","assets/CommunityTab-mTo-BUc1.js","assets/GameDataCenter-DSdLQ9sw.js","assets/MapTab-Ca9xpuq7.js","assets/SavesTab-qT6Fg25_.js","assets/RestartCard-CMiOi-6l.js","assets/InstanceSettingsTab-BGDcCOub.js","assets/LaunchOptionsCard-BZmreBXd.js","assets/PerformanceTab-DSXC-VVq.js","assets/SupervisorTab-9DjYGgoA.js","assets/EngineTab-Dc11CaaH.js"])))=>i.map(i=>d[i]);
import{u as Z,r,j as e,c as K,P as gs,t,e as Y,Q as ke,v as F,f as P,R as Rs,g as V,T as bs,U as zs,F as ge,b as Ne,o as Ge,V as le,y as xe,W as js,X as As,Y as Is,Z as Os,_ as Fs,O as we,$ as oe,i as vs,a0 as ye,a1 as Je,a2 as es,L as Ns,a3 as ws,a4 as Bs,s as ys,a5 as ks,a6 as Ms,a7 as Vs,a8 as Gs,a9 as Us,aa as ze,ab as ss,ac as Ws,ad as Ae,ae as Hs,af as Ue,ag as ts,ah as Ks,p as We,ai as Ie,aj as qs,ak as Ys,al as Qs,am as Xs,an as as,ao as Zs,ap as T,h as Js,aq as et,a as He,ar as st,as as tt,at,J as nt,au as rt,av as it,aw as lt,ax as ot,z as ct,K as ns,ay as dt,k as ut,az as xt,aA as mt,aB as pt,aC as ft,aD as ht,aE as gt,aF as bt}from"./index-iQt3bUih.js";import{c as jt}from"./clipboard-t_-sNjVI.js";import{S as vt,a as rs,m as Nt}from"./flags-2LIwgBXb.js";function wt(s){return s.replace(/[\s﻿]+$/,"")}function yt(s){const a=wt(s);let l;return(l=a.match(/\[Chat::(\w+)\]\['([^']+)'[^\]]*\]:\s?(.*)$/))?{type:"chat",name:l[2],channel:l[1],message:l[3]}:(l=a.match(/'([^']+)'[^)]*\) has logged in/))?{type:"join",name:l[1]}:(l=a.match(/'([^']+)'[^)]*\) has logged out/))?{type:"leave",name:l[1]}:(l=a.match(/(steam_\w+) \('[^']*'\) connected to the server/))?{type:"connect",name:l[1]}:(l=a.match(/'([^']+)'[^)]*\) was attacked by a wild '([^']+)'.*died/))?{type:"death",name:l[1],cause:`wild ${l[2]}`,pal:l[2]}:(l=a.match(/'([^']+)'[^)]*\) died to (.+?)\.?$/))?{type:"death",name:l[1],cause:l[2]}:(l=a.match(/'([^']+)'[^)]*\) has captured Pal '([^']+)'/))?{type:"capture",name:l[1],pal:l[2]}:(l=a.match(/'([^']+)'[^)]*\) has build a (.+?)\.?$/))?{type:"build",name:l[1],built:l[2]}:null}function kt({client:s,instanceId:a,running:l,canReinstall:p,onUpdateStarted:n}){Z();const[x,o]=r.useState(null),[g,w]=r.useState(null),[d,h]=r.useState(!1),k=r.useCallback(async()=>{try{o(await s.version(a)),w(null)}catch(u){w(u instanceof Error?u.message:String(u))}},[s,a]);if(r.useEffect(()=>{k()},[k]),!x)return null;const f=async(u=!1)=>{let S="";if(!u){const v=await s.mods(a).catch(()=>null),y=[v!=null&&v.ue4ss.installed?"UE4SS":"",v!=null&&v.paldefender.installed?"PalDefender":""].filter(Boolean);y.length&&(S=`

`+t("注意:這台裝了模組({list})。遊戲更新後模組常暫時不相容 — 若更新完啟動異常,到「模組」分頁把模組「更新到最新版」或先「停用」。",{list:y.join(" / ")}))}const b=u?t(`重灌會【刪除】遊戲本體檔案後全新下載(數 GB)。

會保留:世界存檔與設定檔(整個 Pal/Saved,含 PalWorldSettings.ini / Engine.ini),並在開始前自動備份啟用中的世界。
會刪除:已安裝的模組(UE4SS / PalDefender / pak),重灌後需重新安裝。

確定要重灌嗎?`):t("更新會先安全停止伺服器,重新下載檔案(數 GB),完成後自動啟動。")+S+`

`+t("確定要更新嗎?");if(confirm(b)){h(!0),w(null);try{await s.updateServer(a,u),n()}catch(v){w(v instanceof Error?v.message:String(v))}finally{h(!1)}}};return e.jsxs("div",{className:K,children:[e.jsxs("h3",{className:"mb-3 inline-flex items-center gap-2 text-sm font-extrabold text-ink-muted",children:[e.jsx(gs,{className:"size-4 text-pal"})," ",t("遊戲版本")]}),g&&e.jsx("p",{className:`mb-3 ${Y}`,children:g}),e.jsxs("dl",{className:"flex flex-col gap-2",children:[e.jsx(be,{label:t("伺服器版本"),value:x.gameVersion??t("未知(啟動一次伺服器即可取得)")}),x.installedBuild&&e.jsx(be,{label:t("已安裝建置"),value:x.installedBuild,mono:!0}),x.latestBuild&&e.jsx(be,{label:t("最新建置"),value:x.latestBuild,mono:!0}),x.latestUpdatedAt&&e.jsx(be,{label:t("官方更新時間"),value:new Date(x.latestUpdatedAt).toLocaleString()})]}),e.jsx("div",{className:"mt-3",children:x.updateAvailable===!0?x.autoUpdate?e.jsx("div",{className:"rounded-xl border-2 border-grass/40 bg-grass/10 p-3",children:e.jsx("p",{className:"text-[13px] font-bold text-grass",children:t("偵測到新版本，自動更新已啟用，將自動安全套用。")})}):e.jsx("div",{className:"rounded-xl border-2 border-sun/40 bg-sun/10 p-3",children:e.jsx("p",{className:"text-[13px] font-bold text-sun",children:t("有新版本可更新。更新前建議先到「存檔備份」建立一份備份。")})}):x.updateAvailable===!1?e.jsxs("p",{className:"inline-flex items-center gap-1.5 rounded-full border-[1.5px] border-grass/40 bg-grass/15 px-3 py-1 text-xs font-bold text-grass",children:[e.jsx(ke,{className:"size-3.5"})," ",t("已是最新版本")]}):e.jsx("p",{className:"text-[13px] text-ink-muted",children:x.reason?t(x.reason):t("無法判斷是否有新版本(可能連不上 Steam)。")})}),e.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-2",children:[e.jsxs("button",{className:`${x.updateAvailable===!0?F:P} inline-flex items-center gap-1.5`,onClick:()=>void f(),disabled:d,title:x.updateAvailable===!0?void 0:t("重新執行更新(內含檔案完整性驗證);偵測不到版本落差時也可用"),children:[e.jsx(Rs,{className:"size-4"})," ",d?t("啟動更新中…"):t("立即更新")]}),e.jsxs("button",{className:`${P} inline-flex items-center gap-1.5`,onClick:k,children:[e.jsx(V,{className:"size-3.5"})," ",t("重新檢查")]}),p&&e.jsxs("button",{className:`${P} inline-flex items-center gap-1.5 text-berry hover:border-berry`,onClick:()=>void f(!0),disabled:d||l,title:l?t("請先停止伺服器"):t("更新一直失敗時用:刪除遊戲本體後全新下載;存檔與設定檔(Pal/Saved)完整保留"),children:[e.jsx(bs,{className:"size-3.5"})," ",t("重灌伺服器")]}),x.checkedAt&&e.jsxs("span",{className:"text-xs text-ink-muted",children:[t("版本資訊取得於")," ",new Date(x.checkedAt).toLocaleString()]})]})]})}function be({label:s,value:a,mono:l}){return e.jsxs("div",{className:"flex justify-between gap-4 text-sm",children:[e.jsx("dt",{className:"shrink-0 text-ink-muted",children:s}),e.jsx("dd",{className:`text-right font-bold break-all ${l?"font-mono text-xs":""}`,children:a})]})}function St({client:s,instanceId:a,onDismiss:l}){Z();const[p,n]=r.useState(null),[x,o]=r.useState(!1),[g,w]=r.useState(null),{ipService:d,vpn:h,playit:k}=zs(),[f,u]=r.useState(()=>localStorage.getItem(`palserver.connMethod.${a}`)||"playit"),S=y=>{u(y),localStorage.setItem(`palserver.connMethod.${a}`,y)},b=r.useCallback(()=>{s.connection(a).then(n).catch(()=>n(null))},[s,a]);if(r.useEffect(()=>b(),[b]),!p)return null;const v=p.gamePort;return e.jsxs("div",{className:`${K} flex flex-col gap-3`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("h3",{className:"inline-flex min-w-0 items-center gap-2 text-sm font-extrabold",children:[e.jsx(ge,{className:"size-4 shrink-0 text-pal"})," ",t("邀請朋友加入")]}),l&&e.jsx("button",{className:"-mr-1 -mt-1 rounded-lg p-1 text-ink-muted transition hover:bg-card-soft hover:text-ink",onClick:l,title:t("隱藏此卡片(可在設定恢復)"),"aria-label":t("隱藏此卡片(可在設定恢復)"),children:e.jsx(Ne,{className:"size-4"})})]}),e.jsx("div",{className:"grid gap-2 sm:grid-cols-3",children:[{id:"playit",icon:e.jsx(Ge,{className:"size-4"}),name:"playit.gg",tag:t("最簡單:朋友什麼都不用裝")},{id:"vpn",icon:e.jsx(le,{className:"size-4"}),name:"VPN",tag:t("你和朋友裝同一套免費 VPN")},{id:"direct",icon:e.jsx(ge,{className:"size-4"}),name:t("直連"),tag:t("公開 IP + 路由器開埠(進階)")}].map(y=>e.jsxs("button",{type:"button",onClick:()=>S(y.id),className:`rounded-xl border-2 px-3 py-2 text-left transition ${f===y.id?"border-pal bg-pal/5":"border-line bg-card-soft/40 hover:border-pal/50"}`,children:[e.jsxs("p",{className:"inline-flex items-center gap-1.5 text-[13px] font-extrabold",children:[y.icon," ",y.name]}),e.jsx("p",{className:"mt-0.5 text-[11px] leading-snug text-ink-muted",children:y.tag})]},y.id))}),f==="playit"&&e.jsxs(Oe,{icon:e.jsx(Ge,{className:"size-4 text-pal"}),title:t("playit.gg — 免費隧道,五分鐘搞定"),hint:t("playit 會給你一個專屬位址,朋友輸入就能進來,路由器什麼都不用設定。"),children:[e.jsxs("ol",{className:"mb-2 flex list-decimal flex-col gap-1 pl-5 text-xs text-ink-muted",children:[e.jsx("li",{children:t("下載並執行 playit(免費),照畫面指示完成綁定。")}),e.jsx("li",{children:t("按「Create Tunnel」建隧道:類型選 Custom → UDP,Local port 填 {port}。",{port:v})}),e.jsx("li",{children:t("把 playit 顯示的位址傳給朋友,輸入就能一起玩。")})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("a",{className:`${P} inline-flex items-center gap-1.5 px-3 py-1 text-xs`,href:k.site,target:"_blank",rel:"noreferrer",children:[e.jsx(xe,{className:"size-3.5"})," ",t("前往 playit.gg")]}),e.jsxs("a",{className:`${P} inline-flex items-center gap-1.5 px-3 py-1 text-xs`,href:k.tutorial,target:"_blank",rel:"noreferrer",children:[e.jsx(xe,{className:"size-3.5"})," ",t("教學影片")]})]})]}),f==="vpn"&&e.jsxs(Oe,{icon:e.jsx(le,{className:"size-4 text-pal"}),title:t("用 VPN 連線"),hint:t("不用動路由器、也不怕外網攻擊。你和朋友裝同一套免費 VPN、加入同一個網路,就像在同一個 WiFi 裡。"),children:[p.vpns.map(y=>e.jsxs("div",{className:"mb-2",children:[e.jsx("p",{className:"mb-1 text-xs font-bold text-ink-muted",children:t("你的 {name} 位址:",{name:y.name})}),e.jsx(is,{address:`${y.address}:${v}`})]},y.name)),e.jsxs("div",{className:"grid gap-2 sm:grid-cols-2",children:[e.jsx(ls,{name:"Radmin VPN",desc:t("免註冊、建個房間邀朋友加入,最適合遊戲聯機。"),site:h.radmin.site,tutorial:h.radmin.tutorial}),e.jsx(ls,{name:"Tailscale",desc:t("用 Google/GitHub 帳號登入,安全穩定,適合長期使用。"),site:h.tailscale.site,tutorial:h.tailscale.tutorial})]})]}),f==="direct"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-xl border-2 border-sun/45 bg-sun/10 p-3",role:"note",children:[e.jsx("p",{className:"text-[13px] font-extrabold text-ink",children:"私人 IP 可以開服，但只能供同一個區域網路使用"}),e.jsxs("p",{className:"mt-1 text-xs leading-relaxed text-ink-muted",children:["看到 192.168.x.x、10.x.x.x 或 172.16–31.x.x 是正常的。外地玩家不能用這個位址連線；請把路由器的 UDP ",v,"轉發到伺服器電腦，或改用 playit.gg／VPN。Windows 防火牆修復不等於路由器已完成轉發。"]})]}),e.jsxs("div",{className:"rounded-xl border-2 border-line bg-card-soft/40 p-3",children:[e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsxs("div",{children:[e.jsxs("p",{className:"inline-flex items-center gap-2 text-[13px] font-extrabold",children:[e.jsx(le,{className:"size-4 text-pal"})," Windows 防火牆"]}),e.jsx("p",{className:"mt-1 text-xs text-ink-muted",children:"自動放行這個世界實際使用的遊戲與查詢 UDP 埠；不會公開 REST、RCON 或管理後台。"})]}),e.jsx("button",{type:"button",className:`${F} shrink-0`,disabled:x,onClick:async()=>{o(!0),w(null);try{const y=await s.repairWindowsFirewall(a);w(y.message)}catch(y){w(y instanceof Error?y.message:String(y))}finally{o(!1)}},children:x?"等待管理員授權…":"一鍵修復連線"})]}),g&&e.jsx("p",{className:"mt-2 rounded-lg border border-line bg-card px-3 py-2 text-xs font-bold text-ink",children:g})]}),p.publicIp&&e.jsx(Oe,{icon:e.jsx(ge,{className:"size-4 text-pal"}),title:t("公開 IP 直連"),hint:p.behindNat?t("你的主機在路由器(NAT)後面:要在路由器把 UDP {port} 轉發到這台電腦,朋友才能用下面的位址連入。CGNAT(電信共享 IP)則開埠也沒用,請改用 playit.gg 或 VPN。",{port:v}):t("朋友直接輸入下面的位址即可(請確認防火牆放行 UDP {port})。",{port:v}),children:e.jsx(is,{address:`${p.publicIp}:${v}`,secret:!0})}),e.jsxs("div",{className:"rounded-xl border-2 border-pal/40 bg-pal/5 p-3",children:[e.jsxs("p",{className:"inline-flex items-center gap-2 text-[13px] font-extrabold",children:[e.jsx(ge,{className:"size-4 text-pal"}),t("覺得麻煩?交給我們設定")]}),e.jsx("p",{className:"mt-1 text-xs text-ink-muted",children:t("連接埠轉發、防火牆、CGNAT⋯⋯公開直連對新手很麻煩,交給我們一次設定到位。")}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsxs("a",{className:`${F} inline-flex items-center gap-1.5`,href:d.website,target:"_blank",rel:"noreferrer",children:[e.jsx(xe,{className:"size-4"})," ",t(d.name)]}),e.jsxs("a",{className:`${P} inline-flex items-center gap-1.5`,href:d.discord,target:"_blank",rel:"noreferrer",children:[e.jsx(js,{className:"size-4"})," ",t("Discord 詢問")]})]})]})]}),e.jsxs("p",{className:"text-xs text-ink-muted",children:[t("朋友這樣加入:開啟 Palworld → 加入多人遊戲 → 在畫面底部的輸入欄貼上位址 → 連線。"),e.jsx("br",{}),t("提示:朋友連線用的是「遊戲埠 UDP {port}」。若朋友連不進來,先確認伺服器正在運作中、且防火牆有放行。",{port:v})]})]})}function Oe({icon:s,title:a,hint:l,children:p}){return e.jsxs("div",{className:"rounded-xl border-2 border-line p-3",children:[e.jsxs("p",{className:"inline-flex items-center gap-2 text-[13px] font-extrabold",children:[s,a]}),e.jsx("p",{className:"mt-1 mb-2 text-xs text-ink-muted",children:l}),p]})}function is({address:s,secret:a}){const[l,p]=r.useState(!1),[n,x]=r.useState(!1),o=a&&!n,g=async()=>{await jt(s)&&(p(!0),setTimeout(()=>p(!1),1500))};return e.jsxs("button",{onClick:g,className:"inline-flex items-center gap-2 rounded-lg border-2 border-line bg-card-soft px-3 py-1.5 font-mono text-sm font-bold transition hover:border-pal",title:t("點擊複製"),children:[e.jsx("span",{className:o?"select-none blur-[6px]":"",children:s}),a&&e.jsx("span",{role:"button",tabIndex:0,title:o?t("顯示"):t("隱藏"),className:"text-ink-muted transition hover:text-pal",onClick:w=>{w.stopPropagation(),x(d=>!d)},children:o?e.jsx(As,{className:"size-4"}):e.jsx(Is,{className:"size-4"})}),l?e.jsx(ke,{className:"size-4 text-grass"}):e.jsx(Os,{className:"size-4 text-ink-muted"})]})}function ls({name:s,desc:a,site:l,tutorial:p}){return e.jsxs("div",{className:"rounded-xl bg-card-soft p-3",children:[e.jsx("p",{className:"text-sm font-extrabold",children:s}),e.jsx("p",{className:"mt-0.5 text-xs text-ink-muted",children:a}),e.jsxs("div",{className:"mt-2 flex flex-wrap gap-2",children:[e.jsxs("a",{className:`${P} inline-flex items-center gap-1.5 px-3 py-1 text-xs`,href:l,target:"_blank",rel:"noreferrer",children:[e.jsx(xe,{className:"size-3.5"})," ",t("官方網站")]}),e.jsxs("a",{className:`${P} inline-flex items-center gap-1.5 px-3 py-1 text-xs`,href:p,target:"_blank",rel:"noreferrer",children:[e.jsx(xe,{className:"size-3.5"})," ",t("教學影片")]})]})]})}const Ss=[{id:"chat",label:"聊天",color:"#5fb0ff",test:/\[Chat::/i},{id:"join",label:"玩家加入",color:"#57d38c",test:/connected to the server|has logged in\b/i},{id:"leave",label:"玩家離開",color:"#9aa4b2",test:/has logged out\b|disconnected from the server/i},{id:"death",label:"死亡",color:"#ff6b6b",test:/\bdied to\b|and died\.|was killed\b/i},{id:"capture",label:"捕捉帕魯",color:"#c792ea",test:/has captured Pal|picked up Pal/i},{id:"warn",label:"警告",color:"#ffcf5f",test:/\[warning\]|(?:^|\s)Warning:/i},{id:"error",label:"錯誤",color:"#ff5c7a",test:/\[error\]|LowLevelFatalError|(?:^|\s)Error:/i}],Et=Object.fromEntries(Ss.map(s=>[s.id,s.color]));function Ct(s){for(const a of Ss)if(a.test.test(s))return a.id;return null}function _t(s){return s&&Et[s]||"#cfd6df"}const Tt=/^\[(\d\d:\d\d):\d\d\]/;function os(s){const a=s.replace(/[\s﻿]+$/,""),l=a.match(Tt),p=l?`${l[1]}  `:"",n=yt(a);if(!n)return null;switch(n.type){case"chat":return p+t("{name}〔{ch}〕{msg}",{name:n.name,ch:n.channel,msg:n.message});case"join":return p+t("{name} 加入伺服器",{name:n.name});case"leave":return p+t("{name} 離開伺服器",{name:n.name});case"connect":return p+t("{id} 連線中…",{id:n.name});case"death":return n.pal?p+t("{name} 被野生 {pal} 擊殺",{name:n.name,pal:n.pal}):p+t("{name} 死亡:{cause}",{name:n.name,cause:n.cause});case"capture":return p+t("{name} 捕捉了 {pal}",{name:n.name,pal:n.pal});case"build":return p+t("{name} 建造了 {what}",{name:n.name,what:n.built})}}function cs(s){const l=s.replace(/[\s﻿]+$/,"").match(/^\[(\d\d:\d\d):\d\d\]\[[a-z]+\]\s?(.*)$/);return l?{time:l[1],message:l[2]}:null}function ds(s=Fs()){return s==="zh"?"zh-TW":s==="zh-CN"?"zh-CN":s==="ja"?"ja":"en"}const us="palserver.logHighlight",xs="palserver.logFormat",ms="palserver.logTranslate",Ke="palserver:logprefs",Fe=(s,a)=>{const l=localStorage.getItem(s);return l===null?a:l==="1"},Be=(s,a)=>{localStorage.setItem(s,a?"1":"0"),window.dispatchEvent(new Event(Ke))};function Pt(){const[,s]=r.useState(0);return r.useEffect(()=>{const a=()=>s(l=>l+1);return window.addEventListener(Ke,a),window.addEventListener("storage",a),()=>{window.removeEventListener(Ke,a),window.removeEventListener("storage",a)}},[]),{highlight:Fe(us,!0),format:Fe(xs,!0),translate:Fe(ms,!1),setHighlight:a=>Be(us,a),setFormat:a=>Be(xs,a),setTranslate:a=>Be(ms,a)}}const Me={game:{label:"遊戲埠(UDP)",hint:"朋友連進伺服器用的主要埠。"},query:{label:"查詢埠(UDP)",hint:"Steam 伺服器瀏覽器查狀態用。"},rest:{label:"REST API 埠(TCP)",hint:"GUI 跟伺服器溝通用(玩家清單/存檔等)。"},rcon:{label:"RCON 埠(TCP)",hint:"遠端指令通道。"},paldefender:{label:"PalDefender 埠(TCP)",hint:"PalDefender 模組的 API 通道。"}};function $t({client:s,instanceId:a,check:l,onResolved:p,onClose:n}){Z();const x=l.ports.filter(u=>!u.free),[o,g]=r.useState(()=>Object.fromEntries(x.map(u=>[u.key,String(u.suggestion??u.port)]))),[w,d]=r.useState(!1),[h,k]=r.useState(null),f=async()=>{d(!0),k(null);try{const u={};for(const S of x){const b=Number(o[S.key]);if(!Number.isInteger(b)||b<1024||b>65535)throw new Error(t("{name} 需為 1024–65535 的數字",{name:t(Me[S.key].label)}));b!==S.port&&(u[S.key]=b)}Object.keys(u).length>0&&await s.portsUpdate(a,u),p()}catch(u){k(u instanceof Error?u.message:String(u)),d(!1)}};return e.jsx(we,{onClose:n,children:e.jsxs("div",{className:`${K} flex max-h-[85vh] w-120 max-w-full flex-col gap-3 overflow-y-auto`,onClick:u=>u.stopPropagation(),children:[e.jsxs("h2",{className:"inline-flex items-center gap-2 text-lg font-extrabold",children:[e.jsx(oe,{className:"size-5 text-sun"})," ",t("有埠被占用了")]}),e.jsx("p",{className:"text-[13px] text-ink-muted",children:t("以下埠已被其他程式占用(可能是另一台伺服器或殘留行程),伺服器會開不起來。已幫你找好可用的替代埠,按「改用並啟動」即可;也可以自行修改。")}),x.map(u=>e.jsx("div",{className:"rounded-xl border-2 border-line px-3 py-2",children:e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-[13px] font-extrabold",children:t(Me[u.key].label)}),e.jsx("p",{className:"text-xs text-ink-muted",children:t(Me[u.key].hint)})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"rounded-full bg-berry/10 px-2 py-0.5 font-mono text-xs font-extrabold text-berry line-through",children:u.port}),e.jsx("span",{className:"text-ink-muted",children:"→"}),e.jsx("input",{className:`${vs} w-24 font-mono`,type:"number",min:1024,max:65535,value:o[u.key]??"",onChange:S=>g(b=>({...b,[u.key]:S.target.value}))})]})]})},u.key)),l.ports.some(u=>u.free)&&e.jsxs("p",{className:"inline-flex items-center gap-1.5 text-xs text-ink-muted",children:[e.jsx(ke,{className:"size-3.5 text-grass"}),t("其餘 {n} 個埠可用,不需修改。",{n:l.ports.filter(u=>u.free).length})]}),h&&e.jsx("p",{className:Y,children:h}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsxs("button",{className:`${F} inline-flex items-center gap-1.5`,onClick:()=>void f(),disabled:w,children:[e.jsx(ye,{className:"size-4"})," ",w?t("套用中…"):t("改用這些埠並啟動")]}),e.jsxs("button",{className:`${P} inline-flex items-center gap-1.5`,onClick:n,disabled:w,children:[e.jsx(Ne,{className:"size-4"})," ",t("取消")]})]})]})})}function Dt({client:s,instanceId:a,worldGuid:l,onResolved:p}){Z();const[n,x]=r.useState(!1),[o,g]=r.useState(null),w=async()=>{x(!0),g(null);try{await s.disableWorldOptions(a,l),p()}catch(d){g(d instanceof Error?d.message:String(d)),x(!1)}};return e.jsx(we,{onClose:()=>{},children:e.jsxs("div",{className:`${K} flex max-h-[90vh] w-[480px] max-w-full flex-col gap-3 overflow-y-auto`,onClick:d=>d.stopPropagation(),children:[e.jsxs("h2",{className:"inline-flex items-center gap-2 text-lg font-extrabold text-berry",children:[e.jsx(oe,{className:"size-5"})," ",t("偵測到存檔設定衝突(WorldOptions.sav)")]}),e.jsx("p",{className:"text-[13px] text-ink-muted",children:t("從四人(連線)存檔搬過來的玩家,可能遇到:")}),e.jsxs("ul",{className:"flex list-disc flex-col gap-1 pl-5 text-[13px] font-bold text-ink",children:[e.jsx("li",{children:t("世界設定(PalWorldSettings.ini)無法正確套用")}),e.jsx("li",{children:t("已設定管理員密碼,玩家列表卻顯示「管理員密碼不符」")})]}),e.jsx("p",{className:"rounded-xl bg-berry/10 px-3 py-2 text-[13px] font-bold text-berry",children:t("這是四人存檔遺留的 WorldOptions.sav 覆蓋掉伺服器設定檔造成的。要正常啟動,必須先移除這個檔案。")}),e.jsx("p",{className:"text-[13px] text-ink-muted",children:t("按下方按鈕會移除該檔(自動改名備份為 .disabled 檔,可還原)後繼續啟動伺服器。世界、玩家、帕魯資料都在別的檔案,不受影響(僅玩家重生點可能需重選)。")}),e.jsx("p",{className:"text-[12px] text-ink-muted",children:t("註:若你是刻意用這個檔案設定 PalWorldSettings.ini 無法調整的參數,移除後那些設定會被打回 ini/預設值。")}),o&&e.jsx("p",{className:Y,children:o}),e.jsx("div",{className:"flex",children:e.jsx("button",{className:F,onClick:w,disabled:n,children:n?t("處理中…"):t("刪除 WorldOptions.sav 並繼續啟動")})})]})})}const je={supervisor:"監控與備份",community:"社群營運","data-center":"遊戲資料",activities:"活動導演台",overview:"營運首頁",performance:"效能監控",players:"玩家管理",guilds:"公會與據點",leaderboard:"活躍排行",map:"世界地圖",settings:"世界規則",engine:"引擎調校",mods:"模組中心",paldefender:"安全防護",palstats:"帕魯數值",bossrespawn:"首領追蹤",breeding:"配種助手",saves:"存檔保險庫",restart:"重啟排程",webhooks:"事件通知","discord-bot":"Discord 控制",instance:"伺服器設定"},ie={overview:"營運總覽",supervisor:"營運總覽",performance:"營運總覽",players:"玩家與社群",guilds:"玩家與社群",leaderboard:"玩家與社群",community:"玩家與社群","data-center":"資料與規劃",activities:"活動與世界",map:"活動與世界",settings:"活動與世界",engine:"活動與世界",mods:"模組與安全",paldefender:"模組與安全",palstats:"模組與安全",bossrespawn:"模組與安全",breeding:"模組與安全",saves:"維護與復原",restart:"維護與復原",instance:"維護與復原",webhooks:"外部串接","discord-bot":"外部串接"},ve={supervisor:{title:"伺服器營運中心",description:"集中查看監控、備份、模組診斷與維護排程。",tips:["先檢查伺服器狀態","定期建立備份","更新模組後重新啟動"]},community:{title:"社群營運中心",description:"管理積分、簽到、商店、玩家交易、雲端背包與 GM 事件。",tips:["先選擇玩家","交易全程留紀錄","高風險操作會先驗證"]},"data-center":{title:"遊戲資料中心",description:"集中搜尋帕魯、道具、主動技能、被動詞條與科技資料。",tips:["輸入中文或遊戲 ID","收藏常用資料","從詳情前往實際操作"]},activities:{title:"活動與獎勵中心",description:"建立獎勵模板、選擇在線玩家並批次發放，完整保留每次執行結果。",tips:["先建立獎勵模板","僅選擇在線玩家","執行後檢查失敗紀錄"]},overview:{title:"GM 營運首頁",description:"先確認服務與玩家狀態，再執行今天最重要的管理工作。",tips:["確認是否在線","查看待處理警告","使用快速操作"]},performance:{title:"效能監控室",description:"用趨勢判斷卡頓來源，不必盯著一堆難懂數字。",tips:["觀察 CPU 峰值","檢查記憶體","比對玩家人數"]},players:{title:"玩家服務台",description:"搜尋玩家、查看狀態，集中處理傳送、警告與管理動作。",tips:["先搜尋玩家","核對 Steam ID","危險操作需確認"]},guilds:{title:"公會與據點",description:"以公會為單位查看成員、基地與異常資料。",tips:["查看公會成員","定位基地","辨識失效資料"]},leaderboard:{title:"社群活躍排行",description:"快速了解近期活躍玩家與世界參與情況。",tips:["切換排行條件","查看統計期間","僅供營運參考"]},map:{title:"世界戰情地圖",description:"在同一張地圖查看玩家、基地與重要世界位置。",tips:["選擇圖層","搜尋目標","點擊查看詳情"]},settings:{title:"世界規則中心",description:"用分類與白話說明調整遊戲規則，儲存前再次確認差異。",tips:["先選分類","套用建議值","儲存後依提示重啟"]},engine:{title:"引擎調校台",description:"管理效能與底層啟動設定，保留適合新手的一鍵預設。",tips:["優先使用預設","一次少量修改","修改後觀察效能"]},mods:{title:"模組管理中心",description:"從相容性、版本與啟用狀態判斷模組是否健康。",tips:["先檢查版本","備份後安裝","逐一啟用測試"]},paldefender:{title:"伺服器安全中心",description:"集中查看防護狀態、權限與高風險操作。",tips:["確認防護在線","限制管理權限","定期輪替權杖"]},palstats:{title:"帕魯數值實驗室",description:"調整數值時保留原始值與可回復紀錄，避免破壞平衡。",tips:["先建立快照","比較原始值","小幅調整測試"]},bossrespawn:{title:"首領追蹤中心",description:"集中查看首領狀態、擊殺紀錄與預估重生時間。",tips:["查看目前狀態","核對重生時間","需要時通知玩家"]},breeding:{title:"配種規劃工作室",description:"從目標帕魯反推親代與路徑，減少來回查資料。",tips:["選擇目標","比較最短路徑","保存規劃結果"]},saves:{title:"存檔保險庫",description:"所有備份、比較、匯入與復原都集中在這裡。",tips:["操作前先備份","確認世界識別碼","復原後驗證玩家資料"]},restart:{title:"維護與重啟排程",description:"安排公告、倒數與自動重啟，降低玩家突然斷線的影響。",tips:["選擇低峰時間","設定倒數公告","確認重啟後狀態"]},webhooks:{title:"事件通知中心",description:"將重要事件發送到外部服務，避免 GM 必須一直盯著後台。",tips:["選擇事件","測試通知","避免洩漏網址"]},"discord-bot":{title:"Discord 遠端控制",description:"設定管理指令、通知頻道與可操作的管理員名單。",tips:["先設定 Bot Token","限制管理員","測試一條指令"]},instance:{title:"伺服器系統設定",description:"管理名稱、資料夾、連接埠與伺服器生命週期。",tips:["確認資料路徑","避免連接埠衝突","刪除前完整備份"]}};function Lt({client:s,detail:a}){const[l,p]=r.useState(Je),[n,x]=r.useState([]),[o,g]=r.useState(!1);r.useEffect(()=>{const d=()=>p(Je());return window.addEventListener(es(),d),window.addEventListener("storage",d),()=>{window.removeEventListener(es(),d),window.removeEventListener("storage",d)}},[]);const w=async()=>{g(!0);const d=[{id:"agent",label:"管理服務連線",requirement:"必要",state:"testing",detail:"正在連線"},{id:"server",label:"伺服器程序",requirement:"多數操作",state:"testing",detail:"正在檢查"},{id:"rcon",label:"RCON 指令通道",requirement:"公告與原生指令",state:a.settings.RCONEnabled?"testing":"missing",detail:a.settings.RCONEnabled?"正在驗證設定":"世界規則尚未啟用 RCON"},{id:"rest",label:"REST API",requirement:"在線玩家與即時資料",state:a.settings.RESTAPIEnabled?"testing":"missing",detail:a.settings.RESTAPIEnabled?"正在驗證設定":"世界規則尚未啟用 REST API"},{id:"mods",label:"模組與 PalDefender",requirement:"發帕魯與進階管理",state:"testing",detail:"正在讀取"},{id:"saves",label:"世界存檔讀取",requirement:"備份、玩家與公會分析",state:"testing",detail:"正在讀取"}];x(d);const h=(f,u)=>x(S=>S.map(b=>b.id===f?{...b,...u}:b)),k=async(f,u,S)=>{try{await u(),h(f,{state:"passed",detail:S})}catch(b){h(f,{state:"failed",detail:b instanceof Error?b.message:String(b)})}};await Promise.all([k("agent",()=>s.info(),"Agent 回應正常"),k("server",()=>s.stats(a.id),a.status==="running"?"伺服器正在運行":"Agent 可讀取狀態，但伺服器未啟動"),a.settings.RCONEnabled?k("rcon",()=>s.rconCommands(a.id),"RCON 指令清單可讀取"):Promise.resolve(),a.settings.RESTAPIEnabled?k("rest",()=>s.live(a.id),"REST 即時資料可讀取"):Promise.resolve(),k("mods",()=>s.mods(a.id),"模組狀態可讀取"),k("saves",()=>s.saves(a.id),"世界存檔可讀取")]),g(!1)};return e.jsxs("div",{className:"operations-center grid gap-4 xl:grid-cols-2",children:[e.jsxs("section",{className:K,children:[e.jsxs("header",{className:"mb-3 flex flex-wrap items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"flex items-center gap-2 font-black",children:[e.jsx(ye,{})," 正式功能測試"]}),e.jsx("p",{className:"text-xs text-ink-muted",children:"直接呼叫目前伺服器的實際 API，只讀檢查、不修改遊戲資料。"})]}),e.jsxs("button",{className:F,disabled:o,onClick:()=>void w(),children:[o?e.jsx(Ns,{}):e.jsx(ye,{})," ",o?"檢查中":"開始完整檢查"]})]}),n.length===0?e.jsx("p",{className:"rounded-xl bg-card-soft p-4 text-sm text-ink-muted",children:"尚未檢查。按下按鈕後會確認操作通道與必要依賴。"}):e.jsx("div",{className:"operation-check-list",children:n.map(d=>e.jsxs("div",{className:`operation-check is-${d.state}`,children:[e.jsx(ps,{state:d.state}),e.jsxs("span",{children:[e.jsx("b",{children:d.label}),e.jsx("small",{children:d.detail})]}),e.jsx("em",{children:d.requirement})]},d.id))})]}),e.jsxs("section",{className:K,children:[e.jsxs("header",{className:"mb-3 flex items-center justify-between gap-2",children:[e.jsxs("div",{children:[e.jsxs("h3",{className:"flex items-center gap-2 font-black",children:[e.jsx(ws,{})," 操作結果中心"]}),e.jsx("p",{className:"text-xs text-ink-muted",children:"集中顯示最近的寫入、發送與設定結果。"})]}),e.jsxs("button",{className:P,disabled:l.length===0,onClick:Bs,children:[e.jsx(bs,{})," 清除"]})]}),l.length===0?e.jsx("p",{className:"rounded-xl bg-card-soft p-4 text-sm text-ink-muted",children:"尚無操作紀錄。之後的啟停、發送、設定與模組操作會自動出現在這裡。"}):e.jsx("div",{className:"operation-result-list",children:l.slice(0,12).map(d=>e.jsxs("div",{children:[e.jsx(ps,{state:d.state}),e.jsxs("span",{children:[e.jsx("b",{children:d.label}),e.jsxs("small",{children:[new Date(d.at).toLocaleString()," · ",d.durationMs==null?"執行中":`${d.durationMs} ms`,d.message?` · ${d.message}`:""]})]}),e.jsx("code",{children:d.method})]},d.id))})]})]})}function ps({state:s}){return s==="passed"||s==="success"||s==="ready"?e.jsx(ys,{className:"text-emerald-600"}):s==="failed"||s==="missing"?e.jsx(ks,{className:"text-red-500"}):e.jsx(Ns,{className:"animate-pulse text-amber-500"})}function Rt({client:s,detail:a,onNavigate:l}){const[p,n]=r.useState([]),[x,o]=r.useState(!1),[g,w]=r.useState(null),d=r.useCallback(async()=>{o(!0);const f=[{label:"伺服器服務",detail:a.status==="running"?"服務正常運行":`目前狀態：${a.status}`,level:a.status==="running"?"good":"bad",target:"overview"}],[u,S,b,v,y]=await Promise.allSettled([s.portsCheck(a.id),s.configHealth(a.id),s.listConfigBackups(a.id),s.stats(a.id),s.mods(a.id)]);if(u.status==="fulfilled"&&u.value.supported&&f.push({label:"連接埠",detail:u.value.anyConflict?"偵測到連接埠衝突":"遊戲與管理連接埠正常",level:u.value.anyConflict?"bad":"good",target:"instance"}),S.status==="fulfilled"&&S.value.supported){const $=S.value.world.corrupted||S.value.engine.corrupted,L=!S.value.world.exists||!S.value.engine.exists;f.push({label:"設定檔",detail:$?"設定檔可能損壞":L?"部分設定檔尚未建立":"世界與引擎設定正常",level:$?"bad":L?"warn":"good",target:"settings"})}if(b.status==="fulfilled"&&b.value.supported){const $=b.value.snapshots.length,L=b.value.snapshots[0],G=L?Date.now()-new Date(L.createdAt).getTime()>7*864e5:!0;f.push({label:"設定備份",detail:$===0?"尚未建立設定快照":`${$} 份快照${G?"，最新備份超過 7 天":"，近期有備份"}`,level:$===0||G?"warn":"good",target:"saves"})}if(v.status==="fulfilled"&&a.status==="running"){const $=v.value.memoryLimitBytes>0?v.value.memoryBytes/v.value.memoryLimitBytes:0,L=(v.value.cpuPercent??0)>=85;f.push({label:"即時效能",detail:L?"CPU 使用率偏高":$>=.85?"記憶體使用率偏高":"目前資源使用正常",level:L||$>=.85?"warn":"good",target:"performance"})}else v.status==="rejected"&&a.status==="running"&&f.push({label:"即時效能",detail:"暫時無法取得 CPU／記憶體資料，請到效能監控查看診斷",level:"warn",target:"performance"});if(y.status==="fulfilled"&&y.value.supported){const $=[y.value.ue4ss,y.value.paldefender].filter(L=>L.installed&&L.enabled===!1).length;f.push({label:"模組狀態",detail:$?`${$} 個已安裝元件目前停用`:"已安裝元件狀態正常",level:$?"warn":"good",target:"mods"})}else y.status==="rejected"&&f.push({label:"模組狀態",detail:"模組掃描暫時失敗，未將它誤判為未安裝",level:"warn",target:"mods"});n(f),w(new Date),o(!1)},[s,a.id,a.status]);r.useEffect(()=>{d()},[d]);const h=p.filter(f=>f.level==="bad").length,k=p.filter(f=>f.level==="warn").length;return e.jsxs("section",{className:"gm-check",children:[e.jsxs("header",{children:[e.jsx("span",{className:"gm-check-mark",children:e.jsx(le,{})}),e.jsxs("div",{children:[e.jsx("small",{children:"MYSHOX DAILY CHECK"}),e.jsx("h3",{children:"GM 一鍵巡檢中心"}),e.jsx("p",{children:"一次確認今天開服前最容易忽略的問題。"})]}),e.jsxs("button",{className:F,onClick:()=>void d(),disabled:x,children:[e.jsx(V,{className:x?"animate-spin":""}),x?"巡檢中":"重新巡檢"]})]}),e.jsxs("div",{className:`gm-check-summary ${h?"is-bad":k?"is-warn":"is-good"}`,children:[e.jsx("strong",{children:h?`${h} 個問題需要處理`:k?`${k} 個項目建議確認`:"目前狀態良好，可以安心營運"}),e.jsx("span",{children:g?`最後檢查 ${g.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}`:"正在取得資料"})]}),e.jsxs("div",{className:"gm-check-list",children:[p.map(f=>{const u=f.level==="good"?ys:f.level==="bad"?ks:oe;return e.jsxs("button",{className:`is-${f.level}`,onClick:()=>f.target&&l(f.target),children:[e.jsx(u,{}),e.jsxs("span",{children:[e.jsx("b",{children:f.label}),e.jsx("small",{children:f.detail})]}),e.jsx("em",{children:"查看"})]},f.label)}),x&&p.length===0&&e.jsxs("div",{className:"gm-check-loading",children:[e.jsx(V,{className:"animate-spin"})," 正在檢查伺服器"]})]}),e.jsxs("footer",{children:[e.jsx("span",{children:"巡檢只讀取狀態，不會自動修改設定。"}),e.jsx("button",{className:P,onClick:()=>l("saves"),children:"前往存檔保險庫"})]})]})}const zt=r.lazy(()=>T(()=>import("./SettingsEditor-CMCYOYER.js"),__vite__mapDeps([0,1,2,3,4])).then(s=>({default:s.SettingsEditor}))),At=r.lazy(()=>T(()=>import("./ModsTab-zBqx0FQb.js"),__vite__mapDeps([5,1,2,3,6])).then(s=>({default:s.ModsTab}))),It=r.lazy(()=>T(()=>import("./PalDefenderTab-DSD4gBLz.js"),__vite__mapDeps([7,1,2,3,6])).then(s=>({default:s.PalDefenderTab}))),Ot=r.lazy(()=>T(()=>import("./PalStatsTab-Cq_xrzkA.js"),__vite__mapDeps([8,1,2,9,10,6])).then(s=>({default:s.PalStatsTab}))),Ft=r.lazy(()=>T(()=>import("./BossRespawnTab--KBPhUJ9.js"),__vite__mapDeps([11,1,2,6,10,12])).then(s=>({default:s.BossRespawnTab}))),Bt=r.lazy(()=>T(()=>import("./BreedingTab-Ca0JFoY9.js"),__vite__mapDeps([13,1,2,9,10,14,15])).then(s=>({default:s.BreedingTab}))),Mt=r.lazy(()=>T(()=>import("./WebhookSettingsTab-Bg_Ot8dC.js"),__vite__mapDeps([16,1,2,17,18])).then(s=>({default:s.WebhookSettingsTab}))),Vt=r.lazy(()=>T(()=>import("./DiscordBotTab-Ccn5HLdD.js"),__vite__mapDeps([19,1,2,17,18,16])).then(s=>({default:s.DiscordBotTab}))),Gt=r.lazy(()=>T(()=>import("./PlayersTab-DHbDNabq.js"),__vite__mapDeps([20,1,2,21,18,10,22,23,9,24,14,25,26,27,28])).then(s=>({default:s.PlayersTab}))),Ut=r.lazy(()=>T(()=>import("./GuildsTab-B39NUouq.js"),__vite__mapDeps([29,1,2,30,10])).then(s=>({default:s.GuildsTab}))),Wt=r.lazy(()=>T(()=>import("./LeaderboardTab-CoNGV1ZZ.js"),__vite__mapDeps([31,1,2,10])).then(s=>({default:s.LeaderboardTab}))),Ht=r.lazy(()=>T(()=>import("./ActivityDirectorTab-enCAOqHD.js"),__vite__mapDeps([32,1,2,9,10,15])).then(s=>({default:s.ActivityDirectorTab}))),Kt=r.lazy(()=>T(()=>import("./CommunityTab-mTo-BUc1.js"),__vite__mapDeps([33,1,2,9,10,24,21,18,14,15])).then(s=>({default:s.CommunityTab}))),qt=r.lazy(()=>T(()=>import("./GameDataCenter-DSdLQ9sw.js"),__vite__mapDeps([34,1,2,10,15,26])).then(s=>({default:s.GameDataCenter}))),fs=r.lazy(()=>T(()=>import("./MapTab-Ca9xpuq7.js"),__vite__mapDeps([35,1,2,27,10,28,22,21,18,23,9,24,14,25,26,30,17,12])).then(s=>({default:s.MapTab}))),Yt=r.lazy(()=>T(()=>import("./ConsoleTab-C9ImPlCA.js").then(s=>s.b),__vite__mapDeps([23,1,2,21,18,9,10,24,14,25,26,27,28])).then(s=>({default:s.ConsoleTab}))),Qt=r.lazy(()=>T(()=>import("./SavesTab-qT6Fg25_.js"),__vite__mapDeps([36,1,2,3])).then(s=>({default:s.SavesTab}))),Xt=r.lazy(()=>T(()=>import("./RestartCard-CMiOi-6l.js"),__vite__mapDeps([37,1,2])).then(s=>({default:s.RestartCard}))),Zt=r.lazy(()=>T(()=>import("./InstanceSettingsTab-BGDcCOub.js"),__vite__mapDeps([38,1,2,17,18,3,39])).then(s=>({default:s.InstanceSettingsTab}))),Jt=r.lazy(()=>T(()=>import("./PerformanceTab-DSXC-VVq.js"),__vite__mapDeps([40,1,2])).then(s=>({default:s.PerformanceTab}))),ea=r.lazy(()=>T(()=>import("./SupervisorTab-9DjYGgoA.js"),__vite__mapDeps([41,1,2])).then(s=>({default:s.SupervisorTab}))),sa=r.lazy(()=>T(()=>import("./EngineTab-Dc11CaaH.js"),__vite__mapDeps([42,1,2,3,4,39])).then(s=>({default:s.EngineTab})));function hs(){return e.jsx("div",{className:`${K} flex min-h-48 items-center justify-center`,role:"status","aria-live":"polite",children:e.jsxs("span",{className:"inline-flex items-center gap-2 text-sm font-bold text-ink-muted",children:[e.jsx(V,{className:"size-4 animate-spin text-pal"})," ",t("載入功能中…")]})})}function ca({client:s,instanceId:a,onBack:l,onDeleted:p}){Z();const[n,x]=r.useState(null),[o,g]=r.useState("overview"),[w,d]=r.useState(null),[h,k]=r.useState(null),[f,u]=r.useState(!1),S=n?n.flavor==="modded":!1,[b,v]=Ms(a,S,f),[y,$]=Vs(a),[L,G]=r.useState(!1),[ce,X]=r.useState(!1),[J,ee]=r.useState(""),se=Gs(Us(pt,{activationConstraint:{distance:6}})),[Se,Ee]=r.useState(!1),te=r.useRef(null);r.useEffect(()=>{if(!L)return;const i=C=>{te.current&&!te.current.contains(C.target)&&G(!1)},m=C=>{C.key==="Escape"&&G(!1)};return document.addEventListener("mousedown",i),document.addEventListener("keydown",m),()=>{document.removeEventListener("mousedown",i),document.removeEventListener("keydown",m)}},[L]),r.useEffect(()=>{const i=m=>{(m.ctrlKey||m.metaKey)&&m.key.toLowerCase()==="k"&&(m.preventDefault(),X(C=>!C),ee("")),m.key==="Escape"&&X(!1)};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[]),r.useEffect(()=>{window.scrollTo({top:0})},[o]),r.useEffect(()=>{!ze.includes(o)&&(b.includes(o)||o==="bossrespawn"&&!rs)&&g("overview")},[b,o]);const[Ce,Q]=r.useState(!1),[ae,U]=r.useState(!1),[c,N]=r.useState(null),[_,R]=r.useState(null),[z,I]=r.useState(!1),[W,me]=r.useState(!1),[M,pe]=r.useState(null),[B,_e]=r.useState(null),[Te,qe]=r.useState(null),O=r.useRef(null),ne=r.useRef(!1),de=r.useRef(null),[Cs,re]=r.useState(!1),[_s,Pe]=r.useState(!1),[Ye,$e]=r.useState(null),[Qe,Xe]=r.useState(null),q=r.useCallback(async()=>{try{const i=await s.getInstance(a);de.current==="running"&&i.status==="exited"&&!ne.current&&re(!0),i.status==="running"&&(ne.current=!1,re(!1),Pe(!1)),i.status==="exited"&&de.current!=="exited"&&s.restartPolicy(a).then(({events:m})=>{const C=m[0];C&&C.reason==="crash"&&!C.ok&&Date.now()-new Date(C.at).getTime()<1440*60*1e3&&Pe(!0)}).catch(()=>{}),de.current=i.status,x(i),N(null)}catch(i){N(i instanceof Error?i.message:String(i))}},[s,a]),De=r.useCallback(()=>{s.mods(a).then(i=>u(i.supported&&i.paldefender.installed)).catch(()=>u(!1))},[s,a]);r.useEffect(()=>De(),[De]),r.useEffect(()=>{q();const m=setInterval(async()=>{if(document.visibilityState==="visible")try{const E=await s.instanceRuntime(a);x(j=>j&&{...j,...E}),de.current==="running"&&E.status==="exited"&&!ne.current&&re(!0),E.status==="running"&&(ne.current=!1,re(!1),Pe(!1)),de.current=E.status}catch(E){N(E instanceof Error?E.message:String(E))}},3e3),C=()=>void q();return window.addEventListener("focus",C),()=>{clearInterval(m),window.removeEventListener("focus",C)}},[s,a,q]);const fe=r.useCallback(async()=>{try{const i=await s.downtimeCountdown(a);if(!i.active){O.current=null,_e(null),qe(null);return}O.current=i.action;const m=Date.parse(i.executeAt);qe(Number.isFinite(m)?m:Date.now()+i.remainingSeconds*1e3),_e(i.remainingSeconds)}catch{}},[s,a]);r.useEffect(()=>{fe();const i=()=>{document.visibilityState==="visible"&&fe()},m=setInterval(i,2e3);return window.addEventListener("focus",i),()=>{clearInterval(m),window.removeEventListener("focus",i)}},[fe]),r.useEffect(()=>{if(Te===null)return;const i=()=>{const C=Math.max(0,Math.ceil((Te-Date.now())/1e3));_e(C)};i();const m=window.setInterval(i,200);return()=>window.clearInterval(m)},[Te]);const ue=async(i,m=!1)=>{if(M)return;if(pe(i),N(null),(i==="stop"||i==="restart")&&(ne.current=!0),i==="start"&&re(!1),i==="start"&&!m&&n&&n.status!=="running"){const E=await s.worldOptionsStatus(a).catch(()=>null);if(E!=null&&E.hasWorldOptions&&E.worldGuid){Xe({worldGuid:E.worldGuid}),pe(null);return}}if(i==="start"&&!m&&n&&n.status!=="running"){const E=await s.portsCheck(a).catch(()=>null);if(E!=null&&E.supported&&E.anyConflict){$e(E),pe(null);return}}const C=(i==="stop"||i==="restart")&&(n==null?void 0:n.status)==="running";try{const E=C?i==="stop"?t("伺服器將在 {n} 秒後停止"):t("伺服器將在 {n} 秒後重新啟動"):void 0;await s.action(a,i,E),await q()}catch(E){N(E instanceof Error?E.message:String(E))}finally{await fe(),pe(null)}},Ts=async i=>{try{await s.action(a,i,void 0,!0)}catch(m){N(m instanceof Error?m.message:String(m))}},Ze=async()=>{const i=O.current;if(!(i!=="stop"&&i!=="restart")){ne.current=!1;try{await s.action(a,i,void 0,void 0,!0),await q()}catch(m){N(m instanceof Error?m.message:String(m))}}},Ps=async()=>{me(!0),N(null);try{await s.saveWorld(a),R(t("世界已存檔")),setTimeout(()=>R(null),3e3)}catch(i){N(i instanceof Error?i.message:String(i))}finally{me(!1)}},$s=async i=>{I(!0);try{await s.updateSettings(a,i),await q()}finally{I(!1)}};return n?e.jsxs("div",{className:"instance-workspace flex flex-col gap-4",children:[e.jsxs("div",{className:"instance-commandbar flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{className:P,onClick:l,"aria-label":t("返回"),children:e.jsx(ss,{className:"inline size-4"})}),e.jsx("h2",{className:"text-xl font-extrabold",children:n.name}),e.jsx(Ws,{status:n.status})]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[n.status==="installing"||n.status==="starting"||n.status==="restarting"?e.jsxs("button",{className:`${F} inline-flex items-center gap-1.5`,disabled:!0,"aria-live":"polite",children:[e.jsx(V,{className:"size-4 animate-spin"}),n.status==="installing"?t("安裝中…"):n.status==="starting"?t("正在啟動…"):t("正在重新啟動…")]}):n.status!=="running"?e.jsxs("button",{className:`${F} inline-flex items-center gap-1.5`,onClick:()=>ue("start"),disabled:B!==null||M!==null,title:t("啟動伺服器"),"aria-label":t("啟動伺服器"),children:[e.jsx(ye,{className:`size-4 ${M==="start"?"animate-pulse":""}`})," ",M==="start"?t("正在啟動…"):t("啟動伺服器")]}):M==="restart"&&B===null?e.jsxs("button",{className:`${F} inline-flex items-center gap-1.5`,disabled:!0,"aria-live":"polite",children:[e.jsx(V,{className:"size-4 animate-spin"})," ",t("正在準備重啟…")]}):B!==null&&(O.current==="stop"||O.current==="restart")?e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:`${F} inline-flex items-center gap-1.5`,disabled:!0,children:[O.current==="restart"?e.jsx(V,{className:"size-4"}):e.jsx(Ae,{className:"size-4"}),B>0?O.current==="restart"?t("重啟倒數 {n} 秒",{n:B}):t("停服倒數 {n} 秒",{n:B}):O.current==="restart"?t("正在重新啟動…"):t("正在停止…")]}),B>0&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{className:`${P} inline-flex items-center gap-1.5`,onClick:()=>void Ts(O.current==="restart"?"restart":"stop"),children:[O.current==="restart"?e.jsx(V,{className:"size-4"}):e.jsx(Ae,{className:"size-4"}),O.current==="restart"?t("現在重啟"):t("現在停止")]}),e.jsx("button",{className:`${P} inline-flex items-center gap-1.5`,onClick:()=>void Ze(),children:O.current==="restart"?t("取消重啟"):t("取消停服")})]})]}):e.jsxs("button",{className:`${F} inline-flex items-center gap-1.5`,onClick:()=>void ue("stop"),disabled:B!==null||M!==null,title:t("目前伺服器正在運作，點此停止伺服器"),"aria-label":t("停止伺服器"),children:[e.jsx(Ae,{className:"size-4"})," ",M==="stop"?t("正在準備停止…"):t("停止伺服器")]}),n.status==="running"&&B===null&&M===null&&e.jsxs("button",{className:`${P} inline-flex items-center gap-1.5`,onClick:()=>ue("restart"),disabled:M!==null,children:[e.jsx(V,{className:`size-4 ${M==="restart"?"animate-spin":""}`})," ",M==="restart"?t("正在準備重啟…"):t("重新啟動")]}),n.status==="running"&&e.jsxs("button",{className:`${P} inline-flex items-center gap-1.5`,onClick:Ps,disabled:W||B!==null,children:[e.jsx(Hs,{className:"size-4"})," ",W?t("儲存中…"):t("立即存檔")]}),e.jsx("button",{className:`${P} inline-flex items-center gap-1.5`,onClick:()=>U(!0),title:t("日誌"),"aria-label":t("日誌"),children:e.jsx(Ue,{className:"size-4"})}),e.jsx("button",{className:`${P} inline-flex items-center gap-1.5`,onClick:()=>Q(!0),title:t("指令台"),"aria-label":t("指令台"),children:e.jsx(ts,{className:"size-4"})})]})]}),B!==null&&e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl bg-sun/15 px-3 py-2 text-[13px] font-bold text-sun",children:[e.jsx("span",{children:t("已在遊戲聊天室公告,{n} 秒後執行…",{n:B})}),O.current==="restart"&&e.jsx("button",{className:"shrink-0 underline underline-offset-2 transition hover:opacity-80",onClick:()=>void Ze(),children:t("取消重啟")})]}),n.status==="installing"&&e.jsx("div",{className:"rounded-xl border-2 border-sun/40 bg-sun/10 px-4 py-3",children:e.jsx(Ks,{percent:n.installProgress})}),Ye&&e.jsx($t,{client:s,instanceId:a,check:Ye,onResolved:()=>{$e(null),ue("start",!0)},onClose:()=>$e(null)}),Qe&&e.jsx(Dt,{client:s,instanceId:a,worldGuid:Qe.worldGuid,onResolved:()=>{Xe(null),ue("start")}}),Ce&&e.jsx(we,{onClose:()=>Q(!1),children:e.jsxs("div",{className:`${K} flex h-[82vh] w-240 max-w-full flex-col gap-3 overflow-hidden`,onClick:i=>i.stopPropagation(),children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between",children:[e.jsxs("h2",{className:"inline-flex items-center gap-2 text-lg font-extrabold",children:[e.jsx(ts,{className:"size-5 text-pal"})," ",t("指令台")]}),e.jsx("button",{className:P,onClick:()=>Q(!1),"aria-label":t("關閉"),children:e.jsx(Ne,{className:"size-4"})})]}),e.jsx(r.Suspense,{fallback:e.jsx(hs,{}),children:e.jsx(Yt,{client:s,instanceId:n.id})})]})}),ae&&e.jsx(we,{onClose:()=>U(!1),children:e.jsxs("div",{className:`${K} flex max-h-[90vh] w-240 max-w-full flex-col gap-3 overflow-y-auto`,onClick:i=>i.stopPropagation(),children:[e.jsxs("div",{className:"flex shrink-0 items-center justify-between",children:[e.jsxs("h2",{className:"inline-flex items-center gap-2 text-lg font-extrabold",children:[e.jsx(Ue,{className:"size-5 text-pal"})," ",t("日誌")]}),e.jsx("button",{className:P,onClick:()=>U(!1),"aria-label":t("關閉"),children:e.jsx(Ne,{className:"size-4"})})]}),e.jsx(ra,{client:s,instanceId:n.id})]})}),_&&e.jsx("p",{className:"rounded-xl bg-grass/10 px-3 py-2 text-[13px] font-bold text-grass",children:_}),c&&e.jsxs("p",{className:`${Y} inline-flex flex-wrap items-center gap-2`,children:[e.jsx("span",{className:"min-w-0 break-all",children:c}),e.jsx("button",{className:"shrink-0 underline underline-offset-2 hover:opacity-80",onClick:()=>U(!0),children:t("查看日誌")})]}),_s&&e.jsxs("p",{className:`${Y} inline-flex flex-wrap items-start gap-2`,children:[e.jsx(oe,{className:"mt-0.5 size-4 shrink-0"}),e.jsxs("span",{children:[t("伺服器連續崩潰達上限,自動重啟已暫停。請先查日誌排除原因(常見:模組不相容、存檔損壞),再手動啟動。")," ",e.jsx("button",{className:"underline underline-offset-2 hover:opacity-80",onClick:()=>U(!0),children:t("查看日誌")})," ",e.jsx("button",{className:"underline underline-offset-2 hover:opacity-80",onClick:()=>g("restart"),children:t("重啟設定")})]})]}),Cs&&e.jsxs("p",{className:`${Y} inline-flex flex-wrap items-start gap-2`,children:[e.jsx(oe,{className:"mt-0.5 size-4 shrink-0"}),e.jsxs("span",{children:[t("伺服器意外停止了(不是你按的)。最常見原因:模組與遊戲版本不相容、世界設定檔損壞、或記憶體不足。")," ",e.jsx("button",{className:"underline underline-offset-2 hover:opacity-80",onClick:()=>U(!0),children:t("查看日誌")})," ",e.jsx("button",{className:"underline underline-offset-2 hover:opacity-80",onClick:()=>re(!1),children:t("知道了")})]})]}),n.installError&&e.jsxs("p",{className:`${Y} inline-flex flex-wrap items-start gap-2`,children:[e.jsx(oe,{className:"mt-0.5 size-4 shrink-0"}),e.jsxs("span",{className:"whitespace-pre-wrap",children:[t("安裝失敗"),":"," ",n.installError.code==="disk-full"?t("磁碟空間不足,請清出更多空間後再試(Palworld 伺服器約需數十 GB)。"):n.installError.message," ",e.jsx("button",{className:"underline underline-offset-2 hover:opacity-80",onClick:()=>U(!0),children:t("查看日誌")})]})]}),e.jsxs("button",{className:"global-command-trigger",onClick:()=>{X(!0),ee("")},children:[e.jsx(We,{})," 搜尋功能、頁面與工具 ",e.jsx("kbd",{children:"Ctrl K"})]}),ce&&e.jsx("div",{className:"command-palette-backdrop",onMouseDown:()=>X(!1),children:e.jsxs("section",{className:"command-palette",onMouseDown:i=>i.stopPropagation(),children:[e.jsxs("header",{children:[e.jsxs("div",{className:"command-palette-title",children:[e.jsx("small",{children:"PALCENTER QUICK FIND"}),e.jsx("strong",{children:"功能搜尋"})]}),e.jsxs("span",{className:"command-palette-version",children:["v","2.9.0 · agent/palserver-admin-ui@0f91ded".replace(/-build/i," · BUILD ")]}),e.jsx("kbd",{children:"ESC"})]}),e.jsxs("label",{className:"command-palette-search",children:[e.jsx(We,{}),e.jsx("input",{autoFocus:!0,value:J,onChange:i=>ee(i.target.value),placeholder:"輸入玩家、模組、備份、地圖或活動名稱…"})]}),e.jsx("div",{children:Ie.filter(i=>{var m,C;return`${je[i.id]} ${((m=ve[i.id])==null?void 0:m.title)??""} ${((C=ve[i.id])==null?void 0:C.description)??""}`.toLowerCase().includes(J.trim().toLowerCase())}).map(i=>{var m;return e.jsxs("button",{onClick:()=>{v(b.filter(C=>C!==i.id)),g(i.id),X(!1)},children:[e.jsx("span",{children:je[i.id]}),e.jsx("small",{children:((m=ve[i.id])==null?void 0:m.description)??"開啟管理頁面"}),e.jsx("b",{children:"前往"})]},i.id)})}),e.jsx("footer",{children:"任何頁面都可以按 Ctrl + K 快速尋找功能"})]})}),e.jsxs("div",{className:"workspace-body",children:[e.jsx(na,{tab:o,serverName:n.name},o),(()=>{const i=y.map(j=>Ie.find(D=>D.id===j)).filter(j=>!!j).filter(j=>j.id!=="palstats"||vt).filter(j=>j.id!=="bossrespawn"||rs),m=i.filter(j=>ze.includes(j.id)||!b.includes(j.id)),C=i.filter(j=>!ze.includes(j.id)),E=j=>{const{active:D,over:A}=j;if(!A||D.id===A.id)return;const H=m.map(he=>he.id),Le=H.indexOf(D.id),Re=H.indexOf(A.id);if(Le<0||Re<0||ie[H[Le]]!==ie[H[Re]])return;const Ds=mt(H,Le,Re);let Ls=0;$(y.map(he=>H.includes(he)?Ds[Ls++]:he))};return e.jsxs("div",{className:"admin-tabs flex flex-nowrap gap-x-1 overflow-x-auto border-b border-line",children:[e.jsx(qs,{sensors:se,collisionDetection:Ys,onDragEnd:E,children:e.jsx(Qs,{items:m.map(j=>j.id),strategy:Xs,children:m.map((j,D)=>{const A=ie[j.id],H=D===0||ie[m[D-1].id]!==A;return e.jsxs(r.Fragment,{children:[H&&e.jsx("div",{className:"admin-tab-group-label",children:A}),e.jsx(aa,{id:j.id,active:j.id===o,label:je[j.id],onSelect:()=>g(j.id)})]},j.id)})})}),e.jsxs("div",{ref:te,className:"relative",children:[e.jsx("button",{type:"button",className:"inline-flex items-center self-center px-3 pb-1 pt-2.5 text-sm font-extrabold text-ink-muted transition hover:text-ink",onClick:()=>{var D;const j=(D=te.current)==null?void 0:D.getBoundingClientRect();Ee(!!j&&j.left+224>window.innerWidth-16),G(A=>!A)},title:t("管理分頁"),"aria-label":t("管理分頁"),children:e.jsx(as,{className:"size-4"})}),L&&e.jsxs("div",{className:`admin-tab-manager absolute top-full z-30 mt-1 w-72 max-w-[calc(100vw-2rem)] rounded-xl border-2 border-line bg-card p-2 shadow-lg ${Se?"right-0":"left-0"}`,children:[e.jsxs("header",{className:"admin-tab-manager-header",children:[e.jsx("strong",{children:t("管理分頁")}),e.jsx("small",{children:t("勾選要顯示的功能")})]}),e.jsx("div",{className:"admin-tab-manager-list",children:[...new Set(C.map(j=>ie[j.id]))].map(j=>e.jsxs("section",{className:"admin-tab-manager-group",children:[e.jsx("h4",{children:j}),C.filter(D=>ie[D.id]===j).map(D=>{const A=!b.includes(D.id);return e.jsxs("button",{type:"button","aria-pressed":A,className:A?"is-visible":"",onClick:()=>{A?v([...b,D.id]):(v(b.filter(H=>H!==D.id)),g(D.id),G(!1))},children:[A?e.jsx(ke,{}):e.jsx(as,{}),e.jsx("span",{children:je[D.id]}),e.jsx("small",{children:A?t("顯示中"):t("已隱藏")})]},D.id)})]},j))}),e.jsxs("button",{type:"button",className:"flex w-full items-center gap-2 rounded-lg px-2 py-1.5 text-left text-xs font-bold text-ink-muted transition hover:bg-card-soft hover:text-ink",onClick:()=>{v(Zs()),$(Ie.map(j=>j.id)),G(!1)},children:[e.jsx(V,{className:"size-3.5 shrink-0"})," ",t("恢復預設分頁與順序")]})]})]})]})})(),e.jsx(r.Suspense,{fallback:e.jsx(hs,{}),children:e.jsxs("section",{className:`tab-stage tab-stage-${o}`,"data-workspace":o,children:[o==="overview"&&e.jsx(ta,{client:s,detail:n,onRefresh:q,onNavigate:g}),o==="performance"&&e.jsx(Jt,{client:s,instanceId:n.id,running:n.status==="running",restEnabled:n.settings.RESTAPIEnabled===!0,initialStats:n.monitorStats,initialLive:n.monitorLive}),o==="supervisor"&&e.jsx(ea,{client:s,instanceId:n.id,running:n.status==="running",initialStats:n.monitorStats,initialMods:n.monitorMods,onNavigate:g}),o==="players"&&e.jsx(Gt,{client:s,instanceId:n.id,onGoToPalDefender:f?()=>g("paldefender"):void 0,onShowOnMap:(i,m)=>{d({x:i,y:m,n:Date.now()}),g("map")}}),o==="guilds"&&e.jsx(Ut,{client:s,instanceId:n.id,onShowOnMap:(i,m)=>{d({x:i,y:m,n:Date.now()}),g("map")}}),o==="leaderboard"&&e.jsx(Wt,{client:s,instanceId:n.id}),o==="activities"&&e.jsx(Ht,{client:s,instanceId:n.id,onNavigate:i=>{v(b.filter(m=>m!==i)),window.setTimeout(()=>g(i),0)}}),o==="community"&&e.jsx(Kt,{client:s,instanceId:n.id}),o==="data-center"&&e.jsx(qt,{onNavigate:i=>{v(b.filter(m=>m!==i)),g(i)}}),o==="map"&&e.jsx(fs,{client:s,instanceId:n.id,externalFocus:w}),o==="settings"&&e.jsx(zt,{settings:n.settings,saving:z,onSave:$s,client:s,instanceId:n.id,canEditRaw:!0,running:n.status==="running"&&n.backend==="native",onSynced:()=>void q()}),o==="engine"&&e.jsx(sa,{client:s,instanceId:n.id,running:n.status==="running"}),o==="mods"&&e.jsx(At,{client:s,instanceId:n.id,running:n.status==="running",onModsChanged:De}),o==="paldefender"&&e.jsx(It,{client:s,instanceId:n.id,running:n.status==="running"}),o==="palstats"&&e.jsx(Ot,{client:s,instanceId:n.id,running:n.status==="running"}),o==="bossrespawn"&&e.jsx(Ft,{client:s,instanceId:n.id,running:n.status==="running"}),o==="breeding"&&e.jsxs(e.Fragment,{children:[e.jsx(Bt,{client:s,instanceId:n.id,onShowOnMap:(i,m)=>k({x:i,y:m,n:Date.now()})}),h&&e.jsx(fs,{client:s,instanceId:n.id,externalFocus:h,overlayOnly:!0,onOverlayClose:()=>k(null)})]}),o==="saves"&&e.jsx(Qt,{client:s,instanceId:n.id,running:n.status==="running"}),o==="restart"&&e.jsx(Xt,{client:s,instanceId:n.id}),o==="webhooks"&&e.jsx(Mt,{client:s,instanceId:n.id}),o==="discord-bot"&&e.jsx(Vt,{client:s,instanceId:n.id}),o==="instance"&&e.jsx(Zt,{client:s,detail:n,onChanged:q,onDeleted:p})]})})]}),e.jsxs("div",{className:`runtime-truth ${n.status==="running"?"is-running":n.status==="starting"||n.status==="restarting"?"is-pending":"is-stopped"}`,children:[e.jsx("span",{className:"runtime-truth-dot"}),e.jsxs("div",{children:[e.jsx("strong",{children:n.status==="running"?"伺服器已開啟":n.status==="starting"||n.status==="restarting"?"伺服器正在處理中":"伺服器目前已關閉"}),e.jsx("small",{children:n.status==="running"?`已偵測到 PalServer 程序${n.runtimeId?`（PID ${n.runtimeId}）`:""}`:"目前沒有偵測到此世界的 PalServer 程序"})]}),e.jsx("span",{className:"runtime-truth-sync",children:"每 3 秒自動同步"})]})]}):e.jsxs("div",{children:[e.jsxs("button",{className:P,onClick:l,children:[e.jsx(ss,{className:"inline size-4"})," ",t("返回")]}),c?e.jsx("p",{className:`mt-4 ${Y}`,children:c}):e.jsx("p",{className:"mt-4 text-ink-muted",children:t("載入中…")})]})}function ta({client:s,detail:a,onRefresh:l,onNavigate:p}){Z();const[n,x]=r.useState(null),[o,g]=gt();r.useEffect(()=>{s.mods(a.id).then(d=>{const h=[];d.paldefender.installed&&h.push("PalDefender"),d.ue4ss.installed&&h.push("UE4SS"),x(h)}).catch(()=>x(null))},[s,a.id]);const w=[[t("狀態"),t(bt[a.status])],[t("運行方式"),a.backend==="native"?t("原生"):a.backend==="docker"?t("Docker 容器"):t("Kubernetes Pod")],[t("類型"),n&&n.length>0?t("強化({list})",{list:n.join(" + ")}):t("原味")],[t("遊戲埠(UDP)"),String(a.gamePort)],["REST API",a.settings.RESTAPIEnabled?t("啟用({port})",{port:Number(a.settings.RESTAPIPort)}):t("停用")],["RCON",a.settings.RCONEnabled?t("啟用({port})",{port:Number(a.settings.RCONPort)}):t("停用")],[a.backend==="native"?t("行程 PID"):a.backend==="docker"?t("容器 ID"):t("Pod 名稱"),a.runtimeId?a.runtimeId.slice(0,12):"—"],[t("建立時間"),new Date(a.createdAt).toLocaleString()]];return e.jsxs("div",{className:"flex flex-col gap-4",children:[e.jsx(Rt,{client:s,detail:a,onNavigate:p}),e.jsx(Lt,{client:s,detail:a}),(()=>{const d=e.jsxs("div",{className:K,children:[e.jsx("h3",{className:"mb-3 text-sm font-extrabold text-ink-muted",children:t("伺服器資訊")}),e.jsx("dl",{className:"flex flex-col gap-2",children:w.map(([k,f],u)=>e.jsxs("div",{className:"flex items-center justify-between gap-4 text-sm",children:[e.jsx("dt",{className:"shrink-0 text-ink-muted",children:k}),e.jsx("dd",{className:"min-w-0 text-right font-bold",children:typeof f=="string"?e.jsx("span",{className:"break-all",children:f}):f})]},u))})]}),h=e.jsx(kt,{client:s,instanceId:a.id,running:a.status==="running",canReinstall:a.backend==="native",onUpdateStarted:l});return o.includes("invite")?e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[d,h]}):e.jsxs("div",{className:"grid items-start gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"flex flex-col gap-4",children:[d,h]}),e.jsx(St,{client:s,instanceId:a.id,onDismiss:()=>g([...o,"invite"])})]})})()]})}function aa({id:s,active:a,label:l,onSelect:p}){const{attributes:n,listeners:x,setNodeRef:o,transform:g,transition:w,isDragging:d}=ft({id:s}),h=Es[s];return e.jsxs("button",{ref:o,"data-tab":s,"aria-selected":a,style:{transform:ht.Translate.toString(g),transition:w,touchAction:"none"},className:`${a?"-mb-px inline-flex min-h-11 items-center gap-2 border-b-[3px] border-pal bg-pal/5 px-4 py-2 text-sm font-extrabold whitespace-nowrap text-pal":"inline-flex min-h-11 items-center gap-2 px-4 py-2 text-sm font-extrabold whitespace-nowrap text-ink-muted transition hover:bg-card-soft hover:text-ink"}${d?" z-10 opacity-60":""}`,onClick:p,...n,...x,children:[e.jsx(h,{className:"tab-icon size-[18px] shrink-0"}),e.jsx("span",{children:l})]})}const Es={overview:xt,supervisor:Ge,performance:ws,players:ut,guilds:le,leaderboard:dt,activities:ns,community:ns,"data-center":We,map:ct,settings:ot,engine:lt,mods:gs,paldefender:le,palstats:it,bossrespawn:He,breeding:rt,saves:nt,restart:V,webhooks:at,"discord-bot":js,instance:tt};function na({tab:s,serverName:a}){const l=Es[s],p=ve[s];return e.jsxs("header",{className:"workspace-context","aria-live":"polite","data-current-tab":s,children:[e.jsx("div",{className:"workspace-context-icon",children:e.jsx(l,{})}),e.jsxs("div",{children:[e.jsxs("p",{children:["PALSERVER ADMIN UI / ",a]}),e.jsx("h2",{children:t(p.title)}),e.jsx("span",{children:t(p.description)}),e.jsx("div",{className:"workspace-tips",children:p.tips.map((n,x)=>e.jsxs("b",{children:[e.jsx("i",{children:x+1}),t(n)]},n))})]})]})}function Ve({on:s,onChange:a,icon:l,label:p,disabled:n,title:x}){return e.jsxs("button",{className:`inline-flex items-center gap-1.5 rounded-full px-3 py-1.5 text-[13px] font-extrabold transition ${s?"bg-pal text-white":"border-2 border-line bg-card-soft text-ink-muted hover:border-pal"} ${n?"cursor-not-allowed opacity-50 hover:border-line":""}`,onClick:()=>!n&&a(!s),disabled:n,title:x,"aria-pressed":s,children:[l," ",p]})}function ra({client:s,instanceId:a}){var U;Z();const[l,p]=r.useState([]),[n,x]=r.useState(""),[o,g]=r.useState([]),[w,d]=r.useState(null),h=Pt(),k=r.useRef(new Map),[,f]=r.useState(0),u=r.useRef(null),[S,b]=r.useState(""),[v,y]=r.useState(!1),[$,L]=r.useState(null),G=async()=>{if(S.trim()){y(!0),L(null);try{await s.announce(a,S.trim()),b("")}catch(c){L(c instanceof Error?c.message:String(c))}finally{y(!1)}}};r.useEffect(()=>{s.license().then(c=>d(Js("log-tools",c))).catch(()=>d(!1))},[s]),r.useEffect(()=>{s.logSources(a).then(c=>{p(c),x(N=>{var _;return N&&c.some(R=>R.id===N)?N:((_=c[0])==null?void 0:_.id)??""})}).catch(()=>p([]))},[s,a]),r.useEffect(()=>{if(!n)return;g([]);const c=s.logsSocket(a,n);return c.onmessage=N=>g(_=>[..._.slice(-999),String(N.data).replace(/\r+$/,"")]),c.onclose=N=>{N.code!==1e3&&N.code!==1005&&g(_=>[..._,t("— 日誌串流已中斷({reason})—",{reason:String(N.reason||N.code)})])},()=>c.close()},[s,a,n]),r.useEffect(()=>{if(w!==!0||!h.translate)return;const c=ds();if(c==="en")return;const N=[],_=new Set;for(const R of o.slice(-300)){let z;if(h.format){if(os(R))continue;const I=cs(R);if(!I||!I.message.trim())continue;z=I.message}else if(z=R.replace(/[\s﻿]+$/,""),!z.trim())continue;k.current.has(`${c}
${z}`)||_.has(z)||(_.add(z),N.push(z))}N.length&&(N.forEach(R=>k.current.set(`${c}
${R}`,"")),(async()=>{try{const R=await s.translateBatch(N,c);N.forEach((z,I)=>{const W=R.texts[I]||"";W?k.current.set(`${c}
${z}`,W):k.current.delete(`${c}
${z}`)})}catch{N.forEach(R=>k.current.delete(`${c}
${R}`))}f(R=>R+1)})())},[w,h.translate,h.format,o,s]);const[ce,X]=r.useState("all"),J=r.useRef(!0),[ee,se]=r.useState(0),Se=r.useRef(null);r.useEffect(()=>{var c;J.current?((c=u.current)==null||c.scrollIntoView({behavior:"smooth"}),se(0)):se(N=>N+1)},[o]);const Ee=()=>{var c;J.current=!0,se(0),(c=u.current)==null||c.scrollIntoView({behavior:"smooth"})},te=h.highlight,Ce=h.format,Q=w===!0&&h.translate,ae=ds();return e.jsxs("div",{className:"flex flex-col gap-3",children:[l.length>1&&e.jsx("div",{className:"flex flex-wrap gap-2",children:l.map(c=>e.jsx("button",{className:c.id===n?"rounded-full bg-pal px-4 py-1.5 text-[13px] font-extrabold text-white":"rounded-full border-2 border-line bg-card-soft px-4 py-1.5 text-[13px] font-extrabold text-ink-muted transition hover:border-pal disabled:opacity-40 disabled:hover:border-line",onClick:()=>x(c.id),disabled:!c.available,title:c.available?void 0:t("此日誌尚未產生"),children:t(c.label)},c.id))}),n&&e.jsxs("p",{className:"inline-flex w-fit items-center gap-1.5 rounded-full bg-card-soft px-3 py-1 text-[12px] font-bold text-ink-muted",children:[e.jsx(Ue,{className:"size-3.5"}),t("日誌來源:{src}",{src:t(((U=l.find(c=>c.id===n))==null?void 0:U.label)??n)})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(Ve,{on:h.highlight,onChange:h.setHighlight,label:t("重點標記")}),e.jsx(Ve,{on:h.format,onChange:h.setFormat,icon:e.jsx(et,{className:"size-4"}),label:t("格式化")}),e.jsx(Ve,{on:Q,onChange:c=>w===!0&&h.setTranslate(c),disabled:w!==!0,icon:e.jsx(He,{className:`size-4 ${Q?"":"text-pal"}`}),label:t("翻譯"),title:w===!0?void 0:t("翻譯為贊助者專屬功能")}),e.jsx("span",{className:"mx-1 h-5 w-0.5 rounded bg-line"}),[{id:"all",label:"全部"},{id:"issues",label:"錯誤與警告"},{id:"chat",label:"聊天與事件"}].map(c=>e.jsx("button",{className:ce===c.id?"rounded-full bg-pal px-3 py-1 text-[12px] font-extrabold text-white":"rounded-full border-2 border-line bg-card-soft px-3 py-1 text-[12px] font-extrabold text-ink-muted transition hover:border-pal",onClick:()=>X(c.id),children:t(c.label)},c.id))]}),w===!1&&e.jsxs("p",{className:"inline-flex items-center gap-2 rounded-cute border-2 border-sun/40 bg-sun/10 px-3 py-2 text-xs font-bold text-sun",children:[e.jsx(He,{className:"size-4 shrink-0 text-pal"}),t("日誌翻譯為贊助者專屬功能,到「設定 → 贊助者識別碼」輸入識別碼即可解鎖。")]}),e.jsxs("div",{className:"relative",children:[e.jsxs("div",{ref:Se,className:"h-[440px] overflow-auto rounded-(--radius-cute) bg-[#1c1927] p-4 font-mono text-sm",onScroll:c=>{const N=c.currentTarget,_=N.scrollHeight-N.scrollTop-N.clientHeight<40;J.current=_,_&&se(0)},children:[o.length?o.map((c,N)=>{const _=Ct(c);if(ce==="issues"&&_!=="warn"&&_!=="error"||ce==="chat"&&(_===null||_==="warn"||_==="error"))return null;const R=te?_t(_):"#cfd6df";let z=c;if(Ce){const I=os(c);if(I)z=I;else{const W=cs(c);if(W){const me=Q&&ae!=="en"?k.current.get(`${ae}
${W.message}`):"";z=`${W.time}  ${me||W.message}`}}}else if(Q&&ae!=="en"){const I=c.replace(/[\s﻿]+$/,"");z=k.current.get(`${ae}
${I}`)||c}return e.jsx("div",{className:"whitespace-pre-wrap break-all",style:{color:R},children:Nt(z)},N)}):e.jsx("span",{className:"text-[#cfd6df]",children:t("(尚無日誌)")}),e.jsx("div",{ref:u})]}),ee>0&&e.jsx("button",{className:"absolute bottom-3 left-1/2 -translate-x-1/2 rounded-full bg-pal px-4 py-1.5 text-[12px] font-extrabold text-white shadow-lg transition hover:bg-pal-strong",onClick:Ee,children:t("{n} 行新日誌,跳到最新",{n:ee})})]}),$&&e.jsx("p",{className:Y,children:$}),e.jsxs("form",{className:"flex shrink-0 items-center gap-2",onSubmit:c=>{c.preventDefault(),G()},children:[e.jsx("input",{className:`${vs} min-w-0 flex-1`,value:S,onChange:c=>b(c.target.value),placeholder:t("輸入要廣播給所有玩家的訊息…"),maxLength:500}),e.jsxs("button",{className:`${F} inline-flex shrink-0 items-center gap-1.5`,disabled:v||!S.trim(),children:[e.jsx(st,{className:"size-4"})," ",v?t("發送中…"):t("廣播")]})]})]})}export{ca as InstanceDetailPage};
