pi-straw-boss 0.49.0 → 0.50.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +2 -1
  2. package/README.zh-TW.md +1 -1
  3. package/dist/gui/assets/{ask-BbPMnLTh.js → ask-DyF8bCRN.js} +1 -1
  4. package/dist/gui/assets/{chat-Czv0jPAD.js → chat-BgcA-aNY.js} +2 -2
  5. package/dist/gui/assets/{drawer-aV6sM3Cp.js → drawer-CT88mAQS.js} +1 -1
  6. package/dist/gui/assets/index-B8Ea0mR1.js +1 -0
  7. package/dist/gui/assets/index-Bj0Wj2Bi.css +1 -0
  8. package/dist/gui/assets/lanwait-1tqNsDfl.js +1 -0
  9. package/dist/gui/assets/layer-BBxY5qmM.js +3 -0
  10. package/dist/gui/assets/{lightbox-DeyJW1Ta.js → lightbox-MfTy-vN-.js} +1 -1
  11. package/dist/gui/assets/link-DPtk3xuD.js +1 -0
  12. package/dist/gui/assets/pair-CHVRgr0q.js +3 -0
  13. package/dist/gui/assets/{picker-CezqOEMn.js → picker-CdZJwZaP.js} +1 -1
  14. package/dist/gui/assets/{server-894bzpGw.js → server-CcYiCOxA.js} +2 -2
  15. package/dist/gui/assets/{spawn-4YbdgJBa.js → spawn-CCzQczfO.js} +1 -1
  16. package/dist/gui/assets/{trust-Vf8ZY7v-.js → trust-Bf_itCgj.js} +1 -1
  17. package/dist/gui/assets/{unit_count-DFKHs2Sk.js → unit_count-zv9hdHDK.js} +1 -1
  18. package/dist/gui/assets/views-DZXa6Ete.js +13 -0
  19. package/dist/gui/index.html +4 -3
  20. package/dist/server/{chunk-F4ZOTRQT.mjs → chunk-QVHQNAUG.mjs} +466 -80
  21. package/dist/server/cli.mjs +2 -1
  22. package/dist/server/main.mjs +3170 -1161
  23. package/package.json +1 -1
  24. package/src/appentry.ts +59 -13
  25. package/src/boss.ts +3 -3
  26. package/src/control.ts +39 -3
  27. package/src/devices.ts +104 -15
  28. package/src/docs.ts +44 -10
  29. package/src/entryform.ts +92 -0
  30. package/src/gui.ts +51 -25
  31. package/src/host.ts +52 -2
  32. package/src/index.ts +2 -2
  33. package/src/keys.ts +5 -2
  34. package/src/lan/access.ts +246 -0
  35. package/src/lan/ca.ts +241 -0
  36. package/src/lan/faces.ts +90 -0
  37. package/src/lan/firewall.ts +337 -0
  38. package/src/lan/listener.ts +640 -0
  39. package/src/lan/net.ts +191 -0
  40. package/src/lan/x509.ts +191 -0
  41. package/src/lanface.ts +367 -0
  42. package/src/paircode.ts +84 -5
  43. package/src/remote.ts +42 -26
  44. package/src/server/acl.ts +1 -1
  45. package/src/server/cli.ts +1 -0
  46. package/src/server/client.ts +2 -2
  47. package/src/server/guihost.ts +54 -5
  48. package/src/server/lanhost.ts +526 -0
  49. package/src/server/main.ts +2 -2
  50. package/src/server/record.ts +2 -0
  51. package/src/server-look.ts +2 -0
  52. package/src/state.ts +3 -2
  53. package/dist/gui/assets/index-BwRZ1vKG.js +0 -1
  54. package/dist/gui/assets/index-D3RS3c_W.css +0 -1
  55. package/dist/gui/assets/layer-fdSmeR4i.js +0 -3
  56. package/dist/gui/assets/link-DEyMVgpE.js +0 -1
  57. package/dist/gui/assets/pair-ChR0ekqj.js +0 -1
  58. package/dist/gui/assets/views-BmcT2brW.js +0 -13
package/README.md CHANGED
@@ -105,7 +105,8 @@ The tower only routes and coordinates, so it can run a lighter model: set `tower
105
105
  | Stash, Stashed, Pop on the page | A base's Stash puts it away under its label; the HUD's Stashed list opens each one again with Pop. A base's Quit is checked first, as `/boss close all` is. |
106
106
  | `/boss stash [name]`, `/boss pop [name]` | Put this whole base away (its tower, mains, members, and idle shells) and close it; open it again later, every pi resumed from its own session file in its old role. A stash refuses, naming why, while anything a resume would lose is there: a running turn, a queued message, an open dialog, a running monitor, a subagent, or a busy shell. |
107
107
  | `/boss gui`, `/boss gui stop`, `/boss gui rotate` | Open the net in the browser (any session, joins nothing); stop its GUI, from any session. The GUI is served by the sb server, one per machine, so it does not depend on which pi session runs: `/boss gui` starts the server when none runs and prints the URL, and a server that went down comes back when any pi session starts or looks (or from `cli.mjs up`). The URL carries a random token that is kept across a restart, an upgrade, a crash, a reboot, and a `/boss gui stop` followed by `/boss gui` (on the same port, in `gui-secrets.json`), so a page left open reconnects by itself and a phone stays paired. A new token comes only from `/boss gui rotate` (after a confirm; it unpairs every phone and opens the new address), a missing or corrupt `gui-secrets.json`, or a port that was taken at the next start: the old address then answers 403 and a phone scans the QR code again. Keeping the token has a cost you chose: another account on this machine that binds the port during a crash or restart gap sees what an open page sends; rotate after a gap you do not trust. With `STRAW_BOSS_DESK=1` (a desk shell shows the page itself) it opens no browser and the page leaves out Phone and Stash. Only `/boss gui stop` keeps the GUI stopped, until the next `/boss gui` or `cli.mjs up`; `/boss stash` and `/boss close all` do not start a stopped GUI. The header's Server button (this computer's page only) shows the server's state, restarts it, and shows its log. Type into a session from its comms view, or work its terminal with the key pad under the terminal tile, or on a desktop by clicking into it and typing; answer a waiting `robot_hand` selector, `ask_user_question` questionnaire, or pi-code hook confirmation there or in its alert (so can any extension's `select` and `confirm`, also from a paired device; other dialogs show read-only, to answer in the terminal; `secret_drop` always takes its secret in the terminal, never on a page, local or over the tailnet, because pi-intercom identities are self-reported). Documents a session shows with [pi-herdr-doc-review](https://www.npmjs.com/package/pi-herdr-doc-review) 0.4.0 or newer open beside its comms: HTML in a sandboxed frame whose form answers the agent, text read-only. |
108
- | `/boss gui remote`, `/boss gui remote off` | Reach the GUI from your phone over your tailnet (`tailscale serve`, never Funnel): pair by QR code (or, in an installed app, by the short code shown beside it), and a phone stays paired (90 days from its last use, `remote off` included) until you unpair it in the Phone tile or the GUI gets a new token (a pairing belongs to the token, which a restart keeps; `/boss gui rotate`, a lost `gui-secrets.json`, or a taken port makes a new one and the old pairings are cleared); remote access stays on across a restart or a new server until `remote off`, and a paired phone keeps working after a restart; after a new token a phone pairs again: in the browser by scanning the QR code, in an installed app by typing the pairing code (see below); off removes only its own serve entry. The serve entry points at a second loopback listener of the sb server's GUI, so a request is remote because of the listener it arrived on, whatever headers it carries. The page installs as an app (Add to Home Screen, or Chrome's Install) with a fixed entry, `https://<this machine>.<tailnet>.ts.net:8443/sb-app/`, as its start URL (a token-free address on the tailnet listener only): open with a pairing, it leads to the current page; open without one (after a new token, or on iOS, where the app keeps cookies of its own and scanning the QR in Safari never reaches it), it shows a field for the **pairing code** that `/boss gui remote` prints under the QR (and the Phone tile shows beside it). The code is 8 characters, works once within ten minutes, and is void after five wrong tries until you ask this computer for a new one. An app installed before this entry existed opens its old address, which now leads to the entry as well. |
108
+ | `/boss gui lan`, `/boss gui lan off`, `/boss gui lan reset` | Reach the GUI from a phone on the same Wi-Fi, without Tailscale. It is off until you turn it on. This computer makes its own certificate, after showing you the risk: anyone who copies its key from this computer could pose to your phones as private-network sites (your router's page, a NAS) until you remove it from each phone. So use it on your phone's hotspot, or on a Wi-Fi that connects the phone directly to this computer. Each phone installs the certificate once (AirDrop or Quick Share it from the computer, and check it as the screen says), then pairs by QR code or typed code, and you allow each new phone on the computer by typing the number it shows. [How it works](docs/how-it-works.md#browser-view). |
109
+ | `/boss gui remote`, `/boss gui remote off` | Reach the GUI from your phone over your tailnet (`tailscale serve`, never Funnel): pair by QR code (or, in an installed app, by the short code shown beside it), and a phone stays paired (90 days from its last use, `remote off` included) until you unpair it in the Phone tile or the GUI gets a new token (a pairing belongs to the token, which a restart keeps; `/boss gui rotate`, a lost `gui-secrets.json`, or a taken port makes a new one and the old pairings are cleared); remote access stays on across a restart or a new server until `remote off`, and a paired phone keeps working after a restart; after a new token a phone pairs again: in the browser by scanning the QR code, in an installed app by typing the pairing code (see below); off removes only its own serve entry. The serve entry points at a second loopback listener of the sb server's GUI, so a request is remote because of the listener it arrived on, whatever headers it carries. The page installs as an app (Add to Home Screen, or Chrome's Install) with a fixed entry, `https://<this machine>.<tailnet>.ts.net:8443/sb-app/`, as its start URL (a token-free address on the tailnet listener only): open with a pairing, it leads to the current page; open without one (after a new token, or on iOS, where the app keeps cookies of its own and scanning the QR in Safari never reaches it), it shows eight boxes for the **pairing code** that `/boss gui remote` prints under the QR (and the Phone tile shows beside it), one character per box (a paste fills them all). The code is 8 characters, shown as two groups of four (`ABCD EFGH`; no hyphen to type), works once within ten minutes, and is void after five wrong tries until you ask this computer for a new one. An app installed before this entry existed opens its old address, which now leads to the entry as well. |
109
110
  | `node dist/server/cli.mjs up --dir <folder> --label <name>` (a shell, not a pi command) | The desk steps of `up`, for a shell that shows the page itself (straw-boss-desk): with `STRAW_BOSS_DESK=1` set in the environment of `herdr server` and of this command, it installs Herdr's pi integration when it is not current, makes the shell's home base (a workspace in the folder, recorded in `desk.json` and found again by its workspace id), has the sb server stand in for its tower, waits for the GUI, and prints one JSON line with `url`, `workspace`, `pane`, `tower`, `created`, and `integration`. Idempotent: a second run opens nothing. Without the switch it exits 2. See [Desk mode](docs/how-it-works.md#desk-mode-up---dir). |
110
111
 
111
112
  Subagents and sessions in Herdr worktree workspaces never join: the session that launched them speaks for them. Outside Herdr the extension does nothing.
package/README.zh-TW.md CHANGED
@@ -102,7 +102,7 @@ pi install npm:pi-straw-boss
102
102
  | 網頁上的「收起」「已收起」「接回」 | 基地的「收起」以基地名稱收起它;上方的「已收起」列出收起的基地,按「接回」打開。基地的「關掉」會先檢查,和 `/boss close all` 一樣。 |
103
103
  | `/boss stash [名稱]`、`/boss pop [名稱]` | 把整個基地(塔台、主智慧體、成員和閒置的 shell)收起來並關掉;之後再打開,每個 pi 都從自己的 session 檔接回原本的角色。只要有接回後會遺失的東西就拒絕並說明原因:正在跑的回合、排隊中的訊息、開著的對話框、執行中的 Monitor、子智慧體,或前景有程式在跑的 shell。 |
104
104
  | `/boss gui`、`/boss gui stop`、`/boss gui rotate` | 在瀏覽器開啟網(任何 session 都能開,不會加入任何東西);停止它的伺服器,在哪個 session 都可以。整台機器只跑一個伺服器,網址會保留(見下):開它的 session `/reload` 之後會重開(網址不變);跑它的 session 結束時(關掉 pane、離開 pi、當機),另一個還開著的 session 會在幾秒內重開它(網址不變)(塔台優先;pi-straw-boss 版本比伺服器舊的 session 要等約六秒才接手,直到下一個較新的 session 再接回去);之後才啟動的 session 也會把停著的伺服器重開,即使所有 session 都離開過或機器重開機;版本較新的 session 會接手,但開著的頁面不會自動換成新版:它會顯示「這個網址已失效」,要用 `/boss gui` 重開。網址裡的 token 會跨過重啟保留:伺服器重啟、升級、當機、重開機,或 `/boss gui stop` 之後再 `/boss gui`,都沿用同一個 token(存在 `gui-secrets.json`,連同埠號),開著的分頁會自行重新連線,手機仍維持配對。只有 `/boss gui rotate`(會先確認;換新 token 與 CSRF 密鑰、解除所有手機的配對並開啟新網址)、`gui-secrets.json` 遺失或損毀,或下次啟動時埠號被占用,才會換新 token:舊網址回 403,手機要重新掃 QR code。保留 token 的代價是你選擇接受的:當機或重啟的空檔裡,這台機器上其他帳號若搶先佔用該埠,會看到開著的頁面送出的內容;對空檔不放心時請 rotate。設了 `STRAW_BOSS_DESK=1`(桌面殼自己顯示頁面)時,它不會開瀏覽器,頁面也不顯示 Phone 與 Stash。只有 `/boss gui stop` 會讓它維持停止,直到下一次 `/boss gui`;`/boss stash` 和 `/boss close all` 不會把停著的伺服器重開。可以在通訊畫面直接打字給某個 session,或用終端機畫面下方的按鍵面板操作它的終端機,在桌面上也可以點進終端機直接打字;在等回覆的 `robot_hand` 選單、`ask_user_question` 問卷或 pi-code 的 hook 確認,可以在那裡或它的警示裡作答(任何 extension 的 `select` 和 `confirm` 也可以,`confirm` 也可以從配對的裝置作答;其他對話框只能看,要回到終端機回答;`secret_drop` 的機密一律在終端機輸入,任何頁面(本機或 tailnet)都不接受,因為 pi-intercom 的身分是自己申報的,無法驗證)。session 用 [pi-herdr-doc-review](https://www.npmjs.com/package/pi-herdr-doc-review) 0.4.0 以上顯示的文件,會開在它的通訊畫面旁邊:HTML 放在沙箱框架裡,表單送出的答案會傳給智慧體;純文字只能讀。 |
105
- | `/boss gui remote`、`/boss gui remote off` | 透過你的 tailnet 用手機連 GUI(`tailscale serve`,絕不用 Funnel):掃 QR code 配對(已安裝的 app 則輸入 QR 旁邊顯示的短配對碼),手機配對後的紀錄會保留(從最後一次使用起算 90 天,重啟與 `remote off` 都不影響),直到你在「手機」視窗解除配對;遠端存取在 stop、`/reload`、換新伺服器之後仍會保持開啟,直到 `remote off`;伺服器重啟後 token 不變,已配對的手機照常使用;GUI 換新 token(`/boss gui rotate`、`gui-secrets.json` 遺失,或埠號被占用)時,舊的配對全部清除(cookie 綁在舊 token 的路徑上),手機要重新配對:瀏覽器掃 QR code,已安裝的 app 輸入配對碼(見下);關閉時只移除它自己的 serve 設定。serve 指向 GUI 伺服器的第二個 loopback 監聽埠,請求算不算遠端取決於它進來的監聽埠,不看它帶什麼標頭。頁面可以安裝成 app(加入主畫面,或 Chrome 的「安裝」):app 的起始網址是固定入口 `https://<這台機器>.<tailnet>.ts.net:8443/sb-app/`(沒有 token,只在 tailnet 監聽埠上):已配對時它會帶你到目前的頁面;沒有配對時(換新 token 後,或 iOS 上 app 有自己的 cookie、在 Safari 掃 QR code 永遠到不了 app),它會顯示輸入欄,輸入 `/boss gui remote` 在 QR code 下方印出的**配對碼**(「手機」視窗也顯示在 QR code 旁)。配對碼 8 個字元,十分鐘內只能用一次,輸錯五次後作廢,要在這台電腦上重新取得新的才能再試。在這個入口出現之前安裝的 app,舊網址現在也會導向入口。 |
105
+ | `/boss gui remote`、`/boss gui remote off` | 透過你的 tailnet 用手機連 GUI(`tailscale serve`,絕不用 Funnel):掃 QR code 配對(已安裝的 app 則輸入 QR 旁邊顯示的短配對碼),手機配對後的紀錄會保留(從最後一次使用起算 90 天,重啟與 `remote off` 都不影響),直到你在「手機」視窗解除配對;遠端存取在 stop、`/reload`、換新伺服器之後仍會保持開啟,直到 `remote off`;伺服器重啟後 token 不變,已配對的手機照常使用;GUI 換新 token(`/boss gui rotate`、`gui-secrets.json` 遺失,或埠號被占用)時,舊的配對全部清除(cookie 綁在舊 token 的路徑上),手機要重新配對:瀏覽器掃 QR code,已安裝的 app 輸入配對碼(見下);關閉時只移除它自己的 serve 設定。serve 指向 GUI 伺服器的第二個 loopback 監聽埠,請求算不算遠端取決於它進來的監聽埠,不看它帶什麼標頭。頁面可以安裝成 app(加入主畫面,或 Chrome 的「安裝」):app 的起始網址是固定入口 `https://<這台機器>.<tailnet>.ts.net:8443/sb-app/`(沒有 token,只在 tailnet 監聽埠上):已配對時它會帶你到目前的頁面;沒有配對時(換新 token 後,或 iOS 上 app 有自己的 cookie、在 Safari 掃 QR code 永遠到不了 app),它會顯示 8 個輸入格,輸入 `/boss gui remote` 在 QR code 下方印出的**配對碼**(「手機」視窗也顯示在 QR code 旁),每格一個字元(貼上整組會自動填滿)。配對碼 8 個字元,顯示成兩組各四個(`ABCD EFGH`,不需要輸入連字號),十分鐘內只能用一次,輸錯五次後作廢,要在這台電腦上重新取得新的才能再試。在這個入口出現之前安裝的 app,舊網址現在也會導向入口。 |
106
106
  | `node dist/server/cli.mjs up --dir <資料夾> --label <名稱>`(給外殼程式用,不是 pi 指令) | `up` 的桌面步驟,給自己顯示頁面的外殼程式(straw-boss-desk)使用:在啟動 `herdr server` 與執行這個指令的環境都設了 `STRAW_BOSS_DESK=1` 時,它會在 Herdr 的 pi 整合不是最新時安裝,建立外殼的家基地(在該資料夾開一個工作區,記在 `desk.json`,之後以工作區 id 找回),讓 sb server 代替這個工作區的塔台,等 GUI 起來,最後印出一行 JSON,內有 `url`、`workspace`、`pane`、`tower`、`created`、`integration`。重複執行不會多開東西;沒設這個開關時以代碼 2 結束。詳見[桌面模式](docs/how-it-works.md#desk-mode-up---dir)。 |
107
107
 
108
108
  子智慧體,以及在 Herdr worktree 工作區裡的 session,都不會加入網,由開出它們的 session 代表它們。不在 Herdr 裡時,這個擴充套件什麼都不做。
@@ -1 +1 @@
1
- import{t as e}from"./runtime-ZX6HkxDa.js";import{a as t,i as n,n as r,r as i,t as a}from"./sending-aEpvzoz2.js";import{X as o,dt as s}from"./index-BwRZ1vKG.js";var c=((t={},n={})=>(n.locale??e())===`zh-TW`?`請在終端機中回答。`:`Answer it in the terminal.`),l=((t={},n={})=>(n.locale??e())===`zh-TW`?`請在終端機中回答。`:`Answer them in the terminal.`),u=((t={},n={})=>(n.locale??e())===`zh-TW`?`也可以自己輸入答案。`:`It also takes your own words.`),d=((t={},n={})=>(n.locale??e())===`zh-TW`?`可以複選。`:`It takes several choices.`),f=((t={},n={})=>(n.locale??e())===`zh-TW`?`選擇`:`Choices`),p=((t={},n={})=>(n.locale??e())===`zh-TW`?`瀏覽器拒絕存取剪貼簿。`:`The browser refused the clipboard.`),m=((t={},n={})=>(n.locale??e())===`zh-TW`?`已複製到這台裝置的剪貼簿。`:`Copied to this device's clipboard.`),h=((t={},n={})=>(n.locale??e())===`zh-TW`?`複製指令`:`Copy command`),g=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個選項有預覽;請在終端機中查看。`:`It has a preview; see it in the terminal.`),_=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註`:`Note`),v=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註(選填)`:`Note (optional)`),y=e=>`Opened while ${e?.tool} was running; it may not be about that call.`,b=e=>`在 ${e?.tool} 執行時開啟,不一定與該呼叫有關。`,x=((t,n={})=>(n.locale??e())===`zh-TW`?b(t):y(t)),S=((t={},n={})=>(n.locale??e())===`zh-TW`?`選項`:`Options`),C=((t={},n={})=>(n.locale??e())===`zh-TW`?`另一個答案沒有被採用;這個可以送出。`:`The other answer was not taken; this one can go.`),w=((t={},n={})=>(n.locale??e())===`zh-TW`?`你的答案`:`Your own answer`),T=((t={},n={})=>(n.locale??e())===`zh-TW`?`或自己輸入答案`:`Or type your own answer`),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`問題已變更,請重新閱讀。`:`The question changed; read it again.`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 讀不懂這個答案。`:`The session could not read that answer.`),O=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個答案不符合問題。`:`That answer does not fit the question.`),k=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 拒絕了這個答案。`:`The session refused that answer.`),A=((t={},n={})=>(n.locale??e())===`zh-TW`?`安全考量,遠端不支援輸入機密。請到執行 GUI 的那台電腦的終端機中回答。`:`For security, entering a secret is not supported remotely. Answer it in the terminal on the computer the GUI runs on.`),j=((t={},n={})=>(n.locale??e())===`zh-TW`?`機密內容只能在終端機輸入,這裡不接受。請到執行 GUI 的那台電腦的終端機中回答。`:`A secret is entered in the terminal only, not here. Answer it in the terminal on the computer the GUI runs on.`),M=((t={},n={})=>(n.locale??e())===`zh-TW`?`送出答案`:`Send answer`),N=((t={},n={})=>(n.locale??e())===`zh-TW`?`顯示終端機`:`Show terminal`),P=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中關閉。`:`It was dismissed in the terminal.`),F=((t={},n={})=>(n.locale??e())===`zh-TW`?`它已不再開啟。`:`It is no longer open.`),I=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中回答。`:`It was already answered in the terminal.`),L=((t={},n={})=>(n.locale??e())===`zh-TW`?`它在等待對話框。`:`It waits on a dialog.`),R={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1};function z(e,t,n,r,i){let{q:a}=n,o=r[a],s=R[e]??0,c=e===`ArrowUp`,l=c||e===`ArrowDown`,u=()=>({to:r.map((e,t)=>({q:(a+1+t)%r.length,part:`opt`})).find(e=>e.q!==a&&!i[e.q])??`send`});if(e===`Tab`)return t?n.part===`opt`&&a>0?{to:{q:a-1,part:`opt`}}:void 0:a<r.length-1?{to:{q:a+1,part:`opt`}}:void 0;if(!t){if(n.part===`opt`){let t=n.o+s;if(s)return t>=0&&t<o.options?{to:{q:a,part:`opt`,o:t},...o.multiple?{}:{pick:t}}:{to:s>0&&o.own?{q:a,part:`own`}:n};if(e===`Enter`||e===` `&&!o.multiple)return{...u(),...o.multiple?{}:{pick:n.o}}}else if(n.part===`own`){if(e===`Enter`)return u();if(l)return{to:c?{q:a,part:`opt`,o:o.options-1}:{q:a,part:`note`}}}else if(c)return{to:{q:a,part:`own`}}}}function B(e,t,n){let r=e=>Math.max(0,e.opts.findIndex(e=>e.getAttribute(`aria-checked`)===`true`)),i=(e,t)=>e.opts.forEach((e,n)=>e.setAttribute(`tabindex`,n===t?`0`:`-1`)),a=e=>{for(let[n,r]of t.entries()){let t=r.opts.indexOf(e);if(t>=0)return{q:n,part:`opt`,o:t};if(e===r.own||e===r.note)return{q:n,part:e===r.own?`own`:`note`}}};t.forEach(e=>i(e,r(e)));let o=e=>{let n=a(e.target);n?.part===`opt`&&i(t[n.q],n.o)};e.addEventListener(`focusin`,o),e.addEventListener(`click`,o);let s=!1;return e.addEventListener(`keydown`,e=>{let i=a(e.target);if(!i||e.ctrlKey||e.altKey||e.metaKey||e.isComposing)return;let o=e.target;if(i.part!==`opt`&&(e.key===`ArrowUp`?o.selectionStart!==0:e.key===`ArrowDown`&&o.selectionEnd!==o.value.length))return;let c=z(e.key,e.shiftKey,i,t.map(e=>({options:e.opts.length,multiple:e.multiple,own:!!e.own})),t.map(e=>e.answered()));if(!c||(e.preventDefault(),e.repeat&&[`Enter`,` `].includes(e.key)))return;if(s=e.key===` `,c.pick!==void 0){let e=t[i.q].opts[c.pick];e.getAttribute(`aria-checked`)!==`true`&&e.click()}let l=c.to===`send`?void 0:t[c.to.q],u=c.to===`send`?n():c.to.part===`opt`?l.opts[c.to.o??r(l)]:c.to.part===`own`?l.own:l.note;u&&!u.disabled&&u.focus()}),e.addEventListener(`keyup`,e=>s&&e.key===` `&&(s=!1,e.preventDefault())),()=>t[0]?.opts[r(t[0])]}var V=e=>e.multiple?d():e.freeform&&e.options.length?u():``,H=(e,t)=>o(`div`,{class:`ask-one`},e.header&&o(`b`,{class:`ask-head`},e.header),o(`p`,{class:`ask-q`},e.question),e.context&&o(`div`,{class:`ask-ctx`},e.context),e.options.length>0&&o(`ol`,{class:`ask-opts`,"aria-label":S()},...e.options.map(e=>o(`li`,{class:`ask-opt`},o(`b`,null,e.title),e.description&&o(`small`,null,e.description)))),t&&V(e)&&o(`small`,{class:`ask-how`},V(e))),U=e=>e.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\p{Cf}]/gu,`�`),W=e=>(e.select?.choices??[]).map((e,t)=>({...e,i:t})),G=(e,t,n)=>({...e.size?{choices:[...e].sort((e,t)=>e-t)}:{},...t.trim()?{text:t}:{},...n.trim()?{note:n}:{}}),K=(e,t,n)=>({dialog:e.dialog,digest:e.digest,answerId:n,...t}),q={digest:E,"not-allowed":O,malformed:D};function J(e){let{outcome:i,reason:a,by:o}=e.body;return i===`accepted`?[`ok`,n()]:i===`stale`?[`error`,o===`local`?I():o===`cancel`?P():F()]:i===`rejected`?[`error`,(Object.hasOwn(q,String(a))?q[String(a)]:k)()]:i===`busy`?[`error`,t()]:i===`unknown`||e.status===504?[`error`,r(),!0]:[`error`,a??s({status:e.status})]}var Y=e=>[`accepted`,`stale`,`busy`,`unknown`].includes(String(e.body.outcome))||e.status===504,X=e=>e.answer?`d\n${e.answer.dialog}\n${e.answer.digest}`:`c\n${e.callId}\n${e.why??``}`;function Z(e,t,n=location.hostname!==`127.0.0.1`,s,u){let d,y,b,E=!1,D=!1,O;for(let e of[`focusin`,`pointerdown`])document.addEventListener(e,e=>y&&!y.el.contains(e.target)&&(y.lost=void 0));let k=(e,t,n,...r)=>(e.dataset.tone=t,e.replaceChildren(n,...r)),P=()=>{if(!y)return;let e=document.activeElement;e&&e!==document.body&&e!==y.lost&&(y.lost=void 0),y.controls.forEach(e=>e.disabled=!E||D||y.done),y.send&&(y.send.disabled=!E||D||y.done||!y.pick()),e&&y.el.contains(e)&&e.disabled&&(y.lost=e);let t=y.lost;t&&!t.disabled&&y.el.contains(t)&&(!document.activeElement||document.activeElement===document.body)&&(t.focus(),y.lost=void 0)};async function F(e,n){[e.sending,D,e.spell]=[!0,!0,!1],P(),k(e.note,``,a());let s=await t(`answer`,n).catch(()=>void 0),c=o(`button`,{type:`button`,class:`cmp-link`},i());c.onclick=()=>void F(e,n);let[l,d,f]=s?J(s):[`error`,r(),!0];[e.done,e.sending,D,e.busy]=[!s||Y(s),!1,!1,s?.body.outcome===`busy`],k(e.note,l,d,...f?[c]:[]),P(),e.note.scrollIntoView?.({block:`nearest`}),u&&s?.body.outcome===`accepted`&&setTimeout(u,1200)}let I=(e,t,n,r,i)=>{let a=o(`button`,{type:`button`,class:`ask-opt`,role:e,"aria-checked":`false`},o(`b`,i?{"data-n":String(i)}:null,t),...n.filter(Boolean).map(e=>o(`small`,null,e)));return a.onclick=r,a};function R(e,t){let r,i=W(t).map(e=>I(`radio`,U(e.label),[e.note&&U(e.note)],()=>(r=e.i,i.forEach((n,r)=>n.setAttribute(`aria-checked`,String(W(t)[r].i===e.i))),P()),e.i+1)),a=t.select?.copy!==void 0&&o(`button`,{type:`button`,class:`cmp-link`},h());a&&(a.disabled=!navigator.clipboard,a.onclick=()=>void navigator.clipboard.writeText(t.select.copy).then(()=>k(e.note,`ok`,m()),()=>k(e.note,`error`,p())));let s=i.filter((e,r)=>!(n&&W(t)[r].hereOnly));return i.forEach(e=>!s.includes(e)&&(e.disabled=!0)),e.pick=()=>r===void 0?void 0:{choice:r},e.first=B(e.el,[{opts:i,multiple:!1,answered:()=>r!==void 0}],()=>e.send),e.controls=s,[o(`pre`,{class:`ask-title`},U(t.select.title)),o(`div`,{class:`ask-opts`,role:`radiogroup`,"aria-label":f()},...i),o(`div`,{class:`ask-acts`},e.send,a)]}function z(e,t){let n=t.questions.map(()=>({picks:new Set,text:o(`textarea`,{rows:`1`,maxlength:`8192`,class:`ask-own`,placeholder:T(),"aria-label":w()}),note:o(`input`,{type:`text`,maxlength:`2048`,class:`ask-own ask-memo`,placeholder:v(),"aria-label":_()})})),r=[],i=t.questions.map((t,i)=>{let a=n[i],s=t.multiple?`checkbox`:`radio`,c=t.options.map((e,n)=>I(s,e.title,[e.description,e.preview&&g()],()=>{t.multiple||(a.picks.clear(),a.text.value=``),a.picks.has(n)?a.picks.delete(n):a.picks.add(n),c.forEach((e,t)=>e.setAttribute(`aria-checked`,String(a.picks.has(t)))),P()}));return a.text.oninput=()=>(t.multiple||(a.picks.clear(),c.forEach(e=>e.setAttribute(`aria-checked`,`false`))),P()),e.controls.push(...c,a.text,a.note),r.push({opts:c,multiple:!!t.multiple,own:a.text,note:a.note,answered:()=>a.picks.size>0||a.text.value.trim()!==``}),o(`div`,{class:`ask-one`},t.header&&o(`b`,{class:`ask-head`},t.header),o(`p`,{class:`ask-q`},t.question),o(`div`,{class:`ask-opts`,role:t.multiple?`group`:`radiogroup`,"aria-label":S()},...c),a.text,a.note)});return e.pick=()=>n.every(e=>e.picks.size||e.text.value.trim())?{answers:n.map(e=>G(e.picks,e.text.value,e.note.value))}:void 0,e.first=B(e.el,r,()=>e.send),[...i,o(`div`,{class:`ask-acts`},e.send)]}function q(e){let t=e.asks??(e.ask?[e.ask]:[]),r=t.length>1,i=e.answer,a={key:X(e),el:o(`section`,{class:`ask`}),note:o(`p`,{class:`ask-note`,role:`status`,"aria-live":`polite`}),controls:[],pick:()=>void 0,done:!1,sending:!1};i&&((a.send=o(`button`,{type:`button`,class:`ask-send`},M())).onclick=()=>void(a.pick()&&F(a,K(i,a.pick(),crypto.randomUUID()))));let u=e.tool===`secret_drop`,d=o(`p`,{class:`ask-term`},e.why&&t.length?e.why:`${r?l():c()} ${r||!t[0]?``:V(t[0])}`.trim()),f=s&&e.tool!==`secret_drop`&&o(`button`,{type:`button`,class:`cmp-link`},N());f&&(f.onclick=s);let p=e.answer?.twin&&e.tool&&e.tool!==`dialog`?[o(`p`,{class:`ask-why`},x({tool:e.tool}))]:[];return a.el.append(...p,...i&&!u?i.select?R(a,i):z(a,i):[...t.length?t.map(e=>H(e,r)):[o(`p`,{class:`ask-why`},u?n?A():j():e.why??L())],o(`div`,{class:`ask-acts`},u?o(`p`,{class:`ask-term`},c()):d,f)],a.note),a}let Z=(t,n)=>{let r=document.activeElement;y&&y!==n&&(y.focus=y.el.contains(r)?r:void 0),[d,y,b]=[t,n,n?.send?n:b],e.replaceChildren(...n?[n.el]:[]),P(),n?.focus&&(!document.activeElement||document.activeElement===document.body)&&n.focus.focus()};return{enter(){let e=y&&!y.done?y.first?.():void 0;return!!(e&&!e.disabled&&(e.focus(),1))},update(e,t){E=t,e&&(O=void clearTimeout(O)),!e&&(y?.done||y?.sending)?O??=setTimeout(()=>(O=void 0,Z()),6e3):e?y&&(X(e)===y.key||!e.answer&&(y.done||y.sending)&&e.callId===d?.callId)?((y.busy||y.sending)&&!e.answer?y.spell=!0:y.busy&&y.spell&&e.answer&&([y.done,y.busy]=[!1,!1],k(y.note,``,C())),d=e):Z(e,b?.key===X(e)&&!b.done?b:q(e)):Z(),P()}}}export{Z as t};
1
+ import{t as e}from"./runtime-ZX6HkxDa.js";import{a as t,i as n,n as r,r as i,t as a}from"./sending-aEpvzoz2.js";import{Z as o,ft as s}from"./index-B8Ea0mR1.js";var c=((t={},n={})=>(n.locale??e())===`zh-TW`?`請在終端機中回答。`:`Answer it in the terminal.`),l=((t={},n={})=>(n.locale??e())===`zh-TW`?`請在終端機中回答。`:`Answer them in the terminal.`),u=((t={},n={})=>(n.locale??e())===`zh-TW`?`也可以自己輸入答案。`:`It also takes your own words.`),d=((t={},n={})=>(n.locale??e())===`zh-TW`?`可以複選。`:`It takes several choices.`),f=((t={},n={})=>(n.locale??e())===`zh-TW`?`選擇`:`Choices`),p=((t={},n={})=>(n.locale??e())===`zh-TW`?`瀏覽器拒絕存取剪貼簿。`:`The browser refused the clipboard.`),m=((t={},n={})=>(n.locale??e())===`zh-TW`?`已複製到這台裝置的剪貼簿。`:`Copied to this device's clipboard.`),h=((t={},n={})=>(n.locale??e())===`zh-TW`?`複製指令`:`Copy command`),g=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個選項有預覽;請在終端機中查看。`:`It has a preview; see it in the terminal.`),_=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註`:`Note`),v=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註(選填)`:`Note (optional)`),y=e=>`Opened while ${e?.tool} was running; it may not be about that call.`,b=e=>`在 ${e?.tool} 執行時開啟,不一定與該呼叫有關。`,x=((t,n={})=>(n.locale??e())===`zh-TW`?b(t):y(t)),S=((t={},n={})=>(n.locale??e())===`zh-TW`?`選項`:`Options`),C=((t={},n={})=>(n.locale??e())===`zh-TW`?`另一個答案沒有被採用;這個可以送出。`:`The other answer was not taken; this one can go.`),w=((t={},n={})=>(n.locale??e())===`zh-TW`?`你的答案`:`Your own answer`),T=((t={},n={})=>(n.locale??e())===`zh-TW`?`或自己輸入答案`:`Or type your own answer`),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`問題已變更,請重新閱讀。`:`The question changed; read it again.`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 讀不懂這個答案。`:`The session could not read that answer.`),O=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個答案不符合問題。`:`That answer does not fit the question.`),k=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 拒絕了這個答案。`:`The session refused that answer.`),A=((t={},n={})=>(n.locale??e())===`zh-TW`?`安全考量,遠端不支援輸入機密。請到執行 GUI 的那台電腦的終端機中回答。`:`For security, entering a secret is not supported remotely. Answer it in the terminal on the computer the GUI runs on.`),j=((t={},n={})=>(n.locale??e())===`zh-TW`?`機密內容只能在終端機輸入,這裡不接受。請到執行 GUI 的那台電腦的終端機中回答。`:`A secret is entered in the terminal only, not here. Answer it in the terminal on the computer the GUI runs on.`),M=((t={},n={})=>(n.locale??e())===`zh-TW`?`送出答案`:`Send answer`),N=((t={},n={})=>(n.locale??e())===`zh-TW`?`顯示終端機`:`Show terminal`),P=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中關閉。`:`It was dismissed in the terminal.`),F=((t={},n={})=>(n.locale??e())===`zh-TW`?`它已不再開啟。`:`It is no longer open.`),I=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中回答。`:`It was already answered in the terminal.`),L=((t={},n={})=>(n.locale??e())===`zh-TW`?`它在等待對話框。`:`It waits on a dialog.`),R={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1};function z(e,t,n,r,i){let{q:a}=n,o=r[a],s=R[e]??0,c=e===`ArrowUp`,l=c||e===`ArrowDown`,u=()=>({to:r.map((e,t)=>({q:(a+1+t)%r.length,part:`opt`})).find(e=>e.q!==a&&!i[e.q])??`send`});if(e===`Tab`)return t?n.part===`opt`&&a>0?{to:{q:a-1,part:`opt`}}:void 0:a<r.length-1?{to:{q:a+1,part:`opt`}}:void 0;if(!t){if(n.part===`opt`){let t=n.o+s;if(s)return t>=0&&t<o.options?{to:{q:a,part:`opt`,o:t},...o.multiple?{}:{pick:t}}:{to:s>0&&o.own?{q:a,part:`own`}:n};if(e===`Enter`||e===` `&&!o.multiple)return{...u(),...o.multiple?{}:{pick:n.o}}}else if(n.part===`own`){if(e===`Enter`)return u();if(l)return{to:c?{q:a,part:`opt`,o:o.options-1}:{q:a,part:`note`}}}else if(c)return{to:{q:a,part:`own`}}}}function B(e,t,n){let r=e=>Math.max(0,e.opts.findIndex(e=>e.getAttribute(`aria-checked`)===`true`)),i=(e,t)=>e.opts.forEach((e,n)=>e.setAttribute(`tabindex`,n===t?`0`:`-1`)),a=e=>{for(let[n,r]of t.entries()){let t=r.opts.indexOf(e);if(t>=0)return{q:n,part:`opt`,o:t};if(e===r.own||e===r.note)return{q:n,part:e===r.own?`own`:`note`}}};t.forEach(e=>i(e,r(e)));let o=e=>{let n=a(e.target);n?.part===`opt`&&i(t[n.q],n.o)};e.addEventListener(`focusin`,o),e.addEventListener(`click`,o);let s=!1;return e.addEventListener(`keydown`,e=>{let i=a(e.target);if(!i||e.ctrlKey||e.altKey||e.metaKey||e.isComposing)return;let o=e.target;if(i.part!==`opt`&&(e.key===`ArrowUp`?o.selectionStart!==0:e.key===`ArrowDown`&&o.selectionEnd!==o.value.length))return;let c=z(e.key,e.shiftKey,i,t.map(e=>({options:e.opts.length,multiple:e.multiple,own:!!e.own})),t.map(e=>e.answered()));if(!c||(e.preventDefault(),e.repeat&&[`Enter`,` `].includes(e.key)))return;if(s=e.key===` `,c.pick!==void 0){let e=t[i.q].opts[c.pick];e.getAttribute(`aria-checked`)!==`true`&&e.click()}let l=c.to===`send`?void 0:t[c.to.q],u=c.to===`send`?n():c.to.part===`opt`?l.opts[c.to.o??r(l)]:c.to.part===`own`?l.own:l.note;u&&!u.disabled&&u.focus()}),e.addEventListener(`keyup`,e=>s&&e.key===` `&&(s=!1,e.preventDefault())),()=>t[0]?.opts[r(t[0])]}var V=e=>e.multiple?d():e.freeform&&e.options.length?u():``,H=(e,t)=>o(`div`,{class:`ask-one`},e.header&&o(`b`,{class:`ask-head`},e.header),o(`p`,{class:`ask-q`},e.question),e.context&&o(`div`,{class:`ask-ctx`},e.context),e.options.length>0&&o(`ol`,{class:`ask-opts`,"aria-label":S()},...e.options.map(e=>o(`li`,{class:`ask-opt`},o(`b`,null,e.title),e.description&&o(`small`,null,e.description)))),t&&V(e)&&o(`small`,{class:`ask-how`},V(e))),U=e=>e.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\p{Cf}]/gu,`�`),W=e=>(e.select?.choices??[]).map((e,t)=>({...e,i:t})),G=(e,t,n)=>({...e.size?{choices:[...e].sort((e,t)=>e-t)}:{},...t.trim()?{text:t}:{},...n.trim()?{note:n}:{}}),K=(e,t,n)=>({dialog:e.dialog,digest:e.digest,answerId:n,...t}),q={digest:E,"not-allowed":O,malformed:D};function J(e){let{outcome:i,reason:a,by:o}=e.body;return i===`accepted`?[`ok`,n()]:i===`stale`?[`error`,o===`local`?I():o===`cancel`?P():F()]:i===`rejected`?[`error`,(Object.hasOwn(q,String(a))?q[String(a)]:k)()]:i===`busy`?[`error`,t()]:i===`unknown`||e.status===504?[`error`,r(),!0]:[`error`,a??s({status:e.status})]}var Y=e=>[`accepted`,`stale`,`busy`,`unknown`].includes(String(e.body.outcome))||e.status===504,X=e=>e.answer?`d\n${e.answer.dialog}\n${e.answer.digest}`:`c\n${e.callId}\n${e.why??``}`;function Z(e,t,n=location.hostname!==`127.0.0.1`,s,u){let d,y,b,E=!1,D=!1,O;for(let e of[`focusin`,`pointerdown`])document.addEventListener(e,e=>y&&!y.el.contains(e.target)&&(y.lost=void 0));let k=(e,t,n,...r)=>(e.dataset.tone=t,e.replaceChildren(n,...r)),P=()=>{if(!y)return;let e=document.activeElement;e&&e!==document.body&&e!==y.lost&&(y.lost=void 0),y.controls.forEach(e=>e.disabled=!E||D||y.done),y.send&&(y.send.disabled=!E||D||y.done||!y.pick()),e&&y.el.contains(e)&&e.disabled&&(y.lost=e);let t=y.lost;t&&!t.disabled&&y.el.contains(t)&&(!document.activeElement||document.activeElement===document.body)&&(t.focus(),y.lost=void 0)};async function F(e,n){[e.sending,D,e.spell]=[!0,!0,!1],P(),k(e.note,``,a());let s=await t(`answer`,n).catch(()=>void 0),c=o(`button`,{type:`button`,class:`cmp-link`},i());c.onclick=()=>void F(e,n);let[l,d,f]=s?J(s):[`error`,r(),!0];[e.done,e.sending,D,e.busy]=[!s||Y(s),!1,!1,s?.body.outcome===`busy`],k(e.note,l,d,...f?[c]:[]),P(),e.note.scrollIntoView?.({block:`nearest`}),u&&s?.body.outcome===`accepted`&&setTimeout(u,1200)}let I=(e,t,n,r,i)=>{let a=o(`button`,{type:`button`,class:`ask-opt`,role:e,"aria-checked":`false`},o(`b`,i?{"data-n":String(i)}:null,t),...n.filter(Boolean).map(e=>o(`small`,null,e)));return a.onclick=r,a};function R(e,t){let r,i=W(t).map(e=>I(`radio`,U(e.label),[e.note&&U(e.note)],()=>(r=e.i,i.forEach((n,r)=>n.setAttribute(`aria-checked`,String(W(t)[r].i===e.i))),P()),e.i+1)),a=t.select?.copy!==void 0&&o(`button`,{type:`button`,class:`cmp-link`},h());a&&(a.disabled=!navigator.clipboard,a.onclick=()=>void navigator.clipboard.writeText(t.select.copy).then(()=>k(e.note,`ok`,m()),()=>k(e.note,`error`,p())));let s=i.filter((e,r)=>!(n&&W(t)[r].hereOnly));return i.forEach(e=>!s.includes(e)&&(e.disabled=!0)),e.pick=()=>r===void 0?void 0:{choice:r},e.first=B(e.el,[{opts:i,multiple:!1,answered:()=>r!==void 0}],()=>e.send),e.controls=s,[o(`pre`,{class:`ask-title`},U(t.select.title)),o(`div`,{class:`ask-opts`,role:`radiogroup`,"aria-label":f()},...i),o(`div`,{class:`ask-acts`},e.send,a)]}function z(e,t){let n=t.questions.map(()=>({picks:new Set,text:o(`textarea`,{rows:`1`,maxlength:`8192`,class:`ask-own`,placeholder:T(),"aria-label":w()}),note:o(`input`,{type:`text`,maxlength:`2048`,class:`ask-own ask-memo`,placeholder:v(),"aria-label":_()})})),r=[],i=t.questions.map((t,i)=>{let a=n[i],s=t.multiple?`checkbox`:`radio`,c=t.options.map((e,n)=>I(s,e.title,[e.description,e.preview&&g()],()=>{t.multiple||(a.picks.clear(),a.text.value=``),a.picks.has(n)?a.picks.delete(n):a.picks.add(n),c.forEach((e,t)=>e.setAttribute(`aria-checked`,String(a.picks.has(t)))),P()}));return a.text.oninput=()=>(t.multiple||(a.picks.clear(),c.forEach(e=>e.setAttribute(`aria-checked`,`false`))),P()),e.controls.push(...c,a.text,a.note),r.push({opts:c,multiple:!!t.multiple,own:a.text,note:a.note,answered:()=>a.picks.size>0||a.text.value.trim()!==``}),o(`div`,{class:`ask-one`},t.header&&o(`b`,{class:`ask-head`},t.header),o(`p`,{class:`ask-q`},t.question),o(`div`,{class:`ask-opts`,role:t.multiple?`group`:`radiogroup`,"aria-label":S()},...c),a.text,a.note)});return e.pick=()=>n.every(e=>e.picks.size||e.text.value.trim())?{answers:n.map(e=>G(e.picks,e.text.value,e.note.value))}:void 0,e.first=B(e.el,r,()=>e.send),[...i,o(`div`,{class:`ask-acts`},e.send)]}function q(e){let t=e.asks??(e.ask?[e.ask]:[]),r=t.length>1,i=e.answer,a={key:X(e),el:o(`section`,{class:`ask`}),note:o(`p`,{class:`ask-note`,role:`status`,"aria-live":`polite`}),controls:[],pick:()=>void 0,done:!1,sending:!1};i&&((a.send=o(`button`,{type:`button`,class:`ask-send`},M())).onclick=()=>void(a.pick()&&F(a,K(i,a.pick(),crypto.randomUUID()))));let u=e.tool===`secret_drop`,d=o(`p`,{class:`ask-term`},e.why&&t.length?e.why:`${r?l():c()} ${r||!t[0]?``:V(t[0])}`.trim()),f=s&&e.tool!==`secret_drop`&&o(`button`,{type:`button`,class:`cmp-link`},N());f&&(f.onclick=s);let p=e.answer?.twin&&e.tool&&e.tool!==`dialog`?[o(`p`,{class:`ask-why`},x({tool:e.tool}))]:[];return a.el.append(...p,...i&&!u?i.select?R(a,i):z(a,i):[...t.length?t.map(e=>H(e,r)):[o(`p`,{class:`ask-why`},u?n?A():j():e.why??L())],o(`div`,{class:`ask-acts`},u?o(`p`,{class:`ask-term`},c()):d,f)],a.note),a}let Z=(t,n)=>{let r=document.activeElement;y&&y!==n&&(y.focus=y.el.contains(r)?r:void 0),[d,y,b]=[t,n,n?.send?n:b],e.replaceChildren(...n?[n.el]:[]),P(),n?.focus&&(!document.activeElement||document.activeElement===document.body)&&n.focus.focus()};return{enter(){let e=y&&!y.done?y.first?.():void 0;return!!(e&&!e.disabled&&(e.focus(),1))},update(e,t){E=t,e&&(O=void clearTimeout(O)),!e&&(y?.done||y?.sending)?O??=setTimeout(()=>(O=void 0,Z()),6e3):e?y&&(X(e)===y.key||!e.answer&&(y.done||y.sending)&&e.callId===d?.callId)?((y.busy||y.sending)&&!e.answer?y.spell=!0:y.busy&&y.spell&&e.answer&&([y.done,y.busy]=[!1,!1],k(y.note,``,C())),d=e):Z(e,b?.key===X(e)&&!b.done?b:q(e)):Z(),P()}}}export{Z as t};
@@ -1,2 +1,2 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-D3RS3c_W.css"])))=>i.map(i=>d[i]);
2
- import{t as e}from"./runtime-ZX6HkxDa.js";import{O as t,Q as n,X as r,d as i,h as a,n as o,w as s}from"./index-BwRZ1vKG.js";import{a as c,i as l,n as u,o as d,r as ee,t as te}from"./views-BmcT2brW.js";var ne=((t={},n={})=>(n.locale??e())===`zh-TW`?`可能已被當機的 run 處理過:動手前先確認。`:`A run that crashed may already have handled this: check before acting.`),re=((t={},n={})=>(n.locale??e())===`zh-TW`?`分支摘要`:`branch summary`),ie=((t={},n={})=>(n.locale??e())===`zh-TW`?`通訊紀錄`:`Comms log`),f=e=>`context compacted · ${e?.tokens} tokens summarized`,p=e=>`上下文已壓縮 · 摘要了 ${e?.tokens} tokens`,ae=((t,n={})=>(n.locale??e())===`zh-TW`?p(t):f(t)),oe=((t={},n={})=>(n.locale??e())===`zh-TW`?`…(於 1 MB 截斷)`:`… (cut at 1 MB)`),m=e=>`exit ${e?.code}`,h=e=>`結束碼 ${e?.code}`,se=((t,n={})=>(n.locale??e())===`zh-TW`?h(t):m(t)),g=e=>`Image ${e?.n}`,_=e=>`圖片 ${e?.n}`,ce=((t,n={})=>(n.locale??e())===`zh-TW`?_(t):g(t)),le=((t={},n={})=>(n.locale??e())===`zh-TW`?`圖片無法讀取`:`Image unavailable`),v=e=>`${e?.count} image(s)`,y=e=>`${e?.count} 張圖片`,ue=((t,n={})=>(n.locale??e())===`zh-TW`?y(t):v(t)),de=((t={},n={})=>(n.locale??e())===`zh-TW`?`收到`:`incoming`),b=((t={},n={})=>(n.locale??e())===`zh-TW`?`跳到最新`:`jump to latest`),x=e=>`${e?.count} new`,S=e=>`${e?.count} 則新訊息`,C=((t,n={})=>(n.locale??e())===`zh-TW`?S(t):x(t)),fe=((t={},n={})=>(n.locale??e())===`zh-TW`?`還沒有通訊。`:`No transmissions yet.`),pe=((t={},n={})=>(n.locale??e())===`zh-TW`?`通知`:`notice`),me=((t={},n={})=>(n.locale??e())===`zh-TW`?`細節`:`details`),w=((t={},n={})=>(n.locale??e())===`zh-TW`?`表單回覆`:`form answers`),he=((t={},n={})=>(n.locale??e())===`zh-TW`?`訊息,來自`:`message from`),T=e=>`answer from ${e?.from}`,E=e=>`${e?.from} 的回答`,ge=((t,n={})=>(n.locale??e())===`zh-TW`?E(t):T(t)),D=e=>`request from ${e?.from}`,O=e=>`${e?.from} 的請求`,_e=((t,n={})=>(n.locale??e())===`zh-TW`?O(t):D(t)),k=e=>`message from ${e?.from}`,A=e=>`${e?.from} 的訊息`,ve=((t,n={})=>(n.locale??e())===`zh-TW`?A(t):k(t)),j=e=>`reply to your ask from ${e?.from}`,M=e=>`${e?.from} 回覆了你的詢問`,ye=((t,n={})=>(n.locale??e())===`zh-TW`?M(t):j(t)),N=((t={},n={})=>(n.locale??e())===`zh-TW`?`記憶`:`memory`),P=((t={},n={})=>(n.locale??e())===`zh-TW`?`監看`:`monitor`),be=((t={},n={})=>(n.locale??e())===`zh-TW`?`本機`:`this computer`),xe=((t={},n={})=>(n.locale??e())===`zh-TW`?`隊友`:`teammate`),F=((t={},n={})=>(n.locale??e())===`zh-TW`?`提問,來自`:`question from`),I=((t={},n={})=>(n.locale??e())===`zh-TW`?`回報,來自`:`report from`),Se=((t={},n={})=>(n.locale??e())===`zh-TW`?`sb server 的通知`:`notice from the sb server`),L=((t={},n={})=>(n.locale??e())===`zh-TW`?`狀態:`:`status of`),R=((t={},n={})=>(n.locale??e())===`zh-TW`?`Straw Link 訊息`:`Straw Link message`),Ce=((t={},n={})=>(n.locale??e())===`zh-TW`?`喚醒鬧鐘`:`wake-up call`),z=((t={},n={})=>(n.locale??e())===`zh-TW`?`塔台事件`:`tower event`),we=((t={},n={})=>(n.locale??e())===`zh-TW`?`在旁開啟`:`open beside`),B=e=>`Open image ${e?.n}`,V=e=>`打開圖片 ${e?.n}`,Te=((t,n={})=>(n.locale??e())===`zh-TW`?V(t):B(t)),H=e=>`show all (${e?.size})`,U=e=>`顯示全部(${e?.size})`,Ee=((t,n={})=>(n.locale??e())===`zh-TW`?U(t):H(t)),De=((t={},n={})=>(n.locale??e())===`zh-TW`?`顯示全部參數`:`show all arguments`),W=e=>`◇ thought · ${e?.count} chars`,Oe=e=>`◇ 思考 · ${e?.count} 字元`,ke=((t,n={})=>(n.locale??e())===`zh-TW`?Oe(t):W(t)),Ae=((t={},n={})=>(n.locale??e())===`zh-TW`?`◇ 思考 · 已遮蔽`:`◇ thought · redacted`),je=((t={},n={})=>(n.locale??e())===`zh-TW`?`這座塔台正在待命。有訊息進來時,sb server 會喚醒它跑一個 run;你在這裡送出的第一則訊息就會啟動它。`:`This tower stands by. The sb server wakes it for a run when a message arrives; your first message here starts that run.`),Me=((t={},n={})=>(n.locale??e())===`zh-TW`?`無法取得`:`unavailable`),Ne=((t={},n={})=>(n.locale??e())===`zh-TW`?`你`:`you`);function Pe(){let e=!0,t=0;return{get pinned(){return e},scrolled(n){e=n,n&&(t=0)},hold:()=>void(e=!1),arrived(n){return e||(t+=n),e},jump:()=>void(e=!0,t=0),button:n=>e&&!n?void 0:t&&!n?C({count:t}):b()}}async function Fe(e,t,n,r){let i=()=>e.items.some(e=>e.id===n);for(;!i()&&e.before;)r(e.prepend(await t.older(e.before)));return i()?!0:(r(e.reset(await t.latest())),!1)}function Ie(e=600){let t=[],n,r=!1,i=new Set,a=new Map,o=new Map,s=e=>e.forEach(e=>(i.delete(e.id),e.tools?.forEach(e=>(o.delete(e.id),a.delete(e.id)))));function c(e,t){let n=[];for(let r of e)i.has(r.id)||(i.add(r.id),r.kind===`result`&&r.callId?(a.set(r.callId,r),o.has(r.callId)&&t.add(o.get(r.callId))):(r.tools?.forEach(e=>o.set(e.id,r.id)),n.push(r)));return n}let l=e=>({rebuild:!1,added:[],touched:[],dropped:[],front:!1,...e});return{get items(){return t},get before(){return n},get detached(){return r},result:e=>a.get(e),reset(e){return[t,n,r]=[[],e.before,!1],i.clear(),a.clear(),o.clear(),t=c(e.items,new Set),l({rebuild:!0,added:t})},append(i){if(r)return l({});let a=new Set,o=c(i,a);t.push(...o);let u=t.length>e?t.splice(0,t.length-e):[];return s(u),u.length&&(n=t[0].id),l({added:o,touched:[...a],dropped:u.map(e=>e.id)})},prepend(i){let a=new Set,o=c(i.items,a);t.unshift(...o),n=i.before;let u=t.length>e?t.splice(e):[];return s(u),u.length&&(r=!0),l({added:o,touched:[...a],dropped:u.map(e=>e.id),front:!0})}}}var Le=e=>a(e.role),Re=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1}):``,ze=e=>e>=1024?`${(e/1024).toFixed(e>=10240?0:1)} KB`:`${e} B`,Be={intercom_message:he,subagent_result:I,subagent_ping:F,subagent_status:L,"pi-loop-monitor":P,"memory-context":N,"doc-review":w,"straw-tower":z,"straw-link":R},G=e=>{let t=i(`<span class="ava"><svg><use/></svg></span>`);return t.querySelector(`use`).setAttribute(`href`,`#i-${o[e]??e}`),t};function Ve(e){let t=[],n=0;for(let i of e.matchAll(/https?:\/\/[^\s<>)\]]+/g))t.push(e.slice(n,i.index),r(`a`,{href:i[0],rel:`noopener noreferrer`,target:`_blank`},i[0])),n=i.index+i[0].length;return[...t,e.slice(n)]}function K(e,i,{who:a,link:o,docFor:f}){let p=Ie(),m=new Map,h=new Set,g=()=>h.forEach(e=>e.button.isConnected?(e.shown=!0,e.button.hidden=!e.paths.some(e=>f?.(e))):e.shown&&h.delete(e)),_=r(`div`,{class:`chat-list`}),v=r(`div`,{class:`chat-top`}),y=r(`div`,{class:`chat-live`}),b=r(`div`,{class:`chat-end`}),x=r(`button`,{class:`chat-pill`,type:`button`,hidden:``}),S=r(`p`,{class:`chat-empty`},fe()),C=r(`div`,{class:`chat-scroll`,tabindex:`-1`,"aria-label":ie()},v,_,y,b);e.replaceChildren(C,x);let w=Pe(),T=!1,E=!1,D,O,k=0,A=!1,j,M=()=>A||j!==void 0,N=()=>(clearTimeout(j),j=setTimeout(()=>(j=void 0,w.pinned&&!p.detached&&F()),250)),P=(e=w.button(p.detached))=>(x.hidden=!e,x.textContent=e??``),F=()=>(w.jump(),O=void 0,C.scrollTop=C.scrollHeight,P());async function I(e){T=!0;let t=await Fe(p,i,e,e=>(q(e),X(e))).finally(()=>T=!1),r=m.get(e);if(D===e){if(!t||!r)return F();w.hold(),O=r,r.scrollIntoView({block:`center`}),n(r,`lit`),clearTimeout(k),k=window.setTimeout(()=>(O=void 0,r.classList.remove(`lit`)),2e3),P()}}let L=()=>D?void I(D):F(),R=(e,t,n,r)=>{e.disabled=!0,i.entry(n).then(n=>{let i=n&&r(n);if(i===void 0)return void(e.textContent=Me());t.textContent=i,e.remove()},()=>e.textContent=Me())};function z(e,t=0){if(!t||!i.pic)return null;let n=Array.from({length:t},(t,n)=>i.pic(e,n));return r(`div`,{class:`pics`},...n.map((e,t)=>{let i=r(`img`,{src:e,alt:ce({n:t+1}),loading:`lazy`,decoding:`async`}),a=r(`button`,{type:`button`,class:`pic`,"aria-label":Te({n:t+1})},i);return i.addEventListener(`error`,()=>a.replaceWith(r(`em`,{class:`pic-gone`},le()))),a.addEventListener(`click`,()=>void s(async()=>{let{lightbox:e}=await import(`./lightbox-DeyJW1Ta.js`);return{lightbox:e}},__vite__mapDeps([0]),import.meta.url).then(({lightbox:e})=>e(n,t))),a}))}function B(e,t){let n=p.result(e.id),i=r(`pre`,{class:`out`},n?.text??``),a=r(`pre`,{class:`args`},e.args??``),o=e.cut?r(`button`,{class:`more`,type:`button`},De()):null;o?.addEventListener(`click`,()=>R(o,a,t,t=>(e=>e&&`${e.args??``}${e.cut?`\n${oe()}`:``}`)(t.tools?.find(t=>t.id===e.id))));let s=n?.more?r(`button`,{class:`more`,type:`button`},Ee({size:ze(n.bytes??0)})):null;s?.addEventListener(`click`,()=>R(s,i,n.id,e=>e.text));let c=e.name===`show_doc`&&f?r(`button`,{class:`more open`,type:`button`,hidden:``},we()):null;c?.addEventListener(`click`,t=>(t.preventDefault(),e.summary.split(`, `).forEach(e=>f?.(e)?.()))),c&&h.add({paths:e.summary.split(`, `),button:c}),c&&queueMicrotask(g);let l=r(`details`,{class:`act`},r(`summary`,{"data-mark":n?n.isError?`error`:`done`:`working`},r(`b`,{class:`badge`}),r(`code`,null,e.name),r(`span`,{class:`sum`},e.summary),c),a,o,n&&r(`div`,{class:`result`},n.images?r(`em`,null,ue({count:n.images})):null,i,s)),u=n&&z(n.id,n.images);return u?[l,u]:[l]}let V=e=>r(`time`,null,Re(e.at)),H=(e,t,n,i)=>r(`article`,{class:`tx you`},r(`header`,null,V(e),r(`b`,null,Ne()),G(`user`)),r(`div`,{class:`bubble`,title:i},n?r(`small`,{class:`boss-flag`},ne()):null,...Ve(t),z(e.id,e.images))),U=(e,t,n,i={})=>r(`article`,{class:`tx sys`},r(`details`,{class:`notice`},r(`summary`,null,G(`comms`),r(`em`,null,de()),...t,V(e)),i.crashed?r(`small`,{class:`boss-flag`},ne()):null,r(`pre`,null,n),i.raw?r(`details`,{class:`notice-raw`},r(`summary`,null,me()),r(`pre`,{class:`raw`},i.raw)):null)),W=e=>{let t=l(e);return[he(),` `,t.name&&o(t.name)||t.name,t.id?` (${t.id})`:``,` · `,be()]},Oe=e=>e.kind===`link`?[{ask:_e,reply:ye,answer:ge,message:ve}[e.what]({from:e.from}),` · `,xe()]:e.kind===`intercom`?W(e.from):[e.kind===`server`?Se():Ce()];function K(e){switch(e.kind){case`user`:{let t=a().service?ee(e.text):void 0;if(t)return U(e,t.kind===`intercom`?W(t.from):[t.kind===`server`?Se():Ce()],e.text??``);let n=a().service?te(e.text):void 0;return H(e,n?n.body:e.text??``,n?.crashed,n?e.text??``:``)}case`assistant`:{let t=a(),n=r(`pre`,{class:`thought-text`}),i=e.thought?r(`button`,{class:`thought`,type:`button`},e.thought<0?Ae():ke({count:e.thought.toLocaleString()})):null;return e.thought&&e.thought>0&&i?.addEventListener(`click`,()=>R(i,n,e.id,e=>e.thoughtText)),r(`article`,{class:`tx in`},G(t.role),r(`div`,{class:`tx-body`},r(`header`,null,r(`b`,null,Le(t)),e.model?r(`span`,null,e.model):null,V(e),e.stop?r(`span`,{class:`stop`,"data-mark":`error`},e.stop):null),i,n,e.text?r(`div`,{class:`md`},c(d(e.text))):null,e.error?r(`p`,{class:`fault`},e.error):null,...(e.tools??[]).flatMap(t=>B(t,e.id))))}case`bash`:return r(`article`,{class:`tx sys`},r(`details`,{class:`act`},r(`summary`,{"data-mark":e.exit?`error`:`done`},r(`b`,{class:`badge`}),r(`code`,null,`shell`),r(`span`,{class:`sum`},`! ${e.command}`),e.exit?r(`span`,{class:`stop`,"data-mark":`error`},se({code:e.exit})):null),e.text?r(`pre`,{class:`out`},e.text):null));case`notice`:{let t=u(e);return t?.kind===`boss`&&a().service?H(e,t.body,t.crashed,e.text??``):t&&t.kind!==`boss`?U(e,Oe(t),t.body,t.kind===`link`?{raw:t.raw}:{crashed:t.crashed}):U(e,[Be[e.type??``]?.()??e.type??pe(),` `,e.from&&o(e.from)||(e.from??``)],e.text??``)}case`divider`:return r(`article`,{class:`tx rule`},r(`details`,null,r(`summary`,null,e.type===`compaction`?ae({tokens:(e.tokens??0).toLocaleString()}):re()),r(`pre`,null,e.text??``)));default:return r(`article`,{class:`tx note`},e.text??``,` `,V(e))}}function q(e){e.rebuild&&(m.clear(),_.replaceChildren());for(let t of e.dropped)m.get(t)?.remove(),m.delete(t);let t=e.added.map(e=>(m.set(e.id,K(e)),m.get(e.id)));e.front?_.prepend(...t):_.append(...t),E&&!e.front&&!e.rebuild&&t.forEach(e=>(e.classList.add(`fresh`),e.dataset.born=String(Date.now()))),S.remove();let n=a().service;S.textContent=n?.state===`standing`&&!n.run?je():fe(),p.items.length||_.append(S),v.hidden=!p.before,He()}let J=[],Y=new Map;function He(){let e=new Set;for(let n of J){let i=Date.parse(n.startedAt),a=p.items.findIndex(e=>e.at!==void 0&&Date.parse(e.at)>=i);if(a===0&&p.before)continue;let o=a<0?``:p.items[a].id,s=JSON.stringify([o,t(n)]),c=Y.get(n.id);if(e.add(n.id),c&&c.sig===s&&c.el.isConnected)continue;c?.el.remove();let l=t(n),u=r(`article`,{class:`tx rule conv-rule`},r(`div`,null,r(`b`,null,l.title),l.ended?r(`small`,null,l.ended):null));Y.set(n.id,{el:u,sig:s});let d=o?m.get(o):void 0;d?d.before(u):_.append(u)}for(let[t,n]of Y)e.has(t)||(n.el.remove(),Y.delete(t))}let X=e=>e.touched.forEach(e=>{let t=m.get(e),n=p.items.find(t=>t.id===e);if(t&&n){let r=K(n);t.classList.contains(`fresh`)&&Date.now()-Number(t.dataset.born??0)<400&&r.classList.add(`fresh`),t.replaceWith(r),m.set(e,r)}}),Ue=async()=>{if(!T&&p.before&&E){T=!0;try{let e=C.scrollHeight,t=p.prepend(await i.older(p.before));q(t),X(t),C.scrollTop+=C.scrollHeight-e}finally{T=!1}p.before&&C.clientHeight&&v.getBoundingClientRect().bottom>=C.getBoundingClientRect().top&&Ue()}};x.addEventListener(`click`,()=>{D=void 0,p.detached?i.latest().then(e=>(q(p.reset(e)),F())):F()});let Z=[new IntersectionObserver(e=>e.some(e=>e.isIntersecting)&&void Ue(),{root:C}),new IntersectionObserver(e=>C.clientHeight&&(w.scrolled(e.at(-1).isIntersecting),P()),{root:C,rootMargin:`0px 0px 67px`})],Q,We=()=>(Q??(Z[0].observe(v),Z[1].observe(b)),clearTimeout(Q),Q=setTimeout(()=>(Q=void 0,Z.forEach(e=>e.disconnect())),600));C.addEventListener(`scroll`,()=>(We(),!A&&j!==void 0&&N()),{passive:!0}),C.addEventListener(`touchstart`,()=>(A=!0,clearTimeout(j),j=void 0),{passive:!0});for(let e of[`touchend`,`touchcancel`])C.addEventListener(e,()=>(A=!1,N()),{passive:!0});for(let e of[`wheel`,`touchstart`,`pointerdown`,`keydown`])C.addEventListener(e,()=>O=D=void 0,{passive:!0});let $=new ResizeObserver(()=>M()?void 0:w.pinned&&!p.detached?C.scrollTop=C.scrollHeight:O?.scrollIntoView({block:`center`}));return $.observe(_),$.observe(C),{log:C,docs:g,runs(e){JSON.stringify(e)!==JSON.stringify(J)&&(J=e,He())},apply(e){if(e.reset)q(p.reset({items:e.items??[],before:e.before})),E=!0,L();else if(e.items?.length){let t=p.append(e.items);q(t),X(t),w.arrived(t.added.length)&&!p.detached&&!M()?F():P()}},reveal(e){D=e,E&&L()},setLive(e,t){y.dataset.mark=t,y.lastChild?.textContent!==e&&y.replaceChildren(...e?[r(`b`,{class:`badge`}),r(`span`,null,e)]:[])}}}export{K as mountChat,ce as t};
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-Bj0Wj2Bi.css"])))=>i.map(i=>d[i]);
2
+ import{t as e}from"./runtime-ZX6HkxDa.js";import{$ as t,O as n,Z as r,d as i,h as a,n as o,w as s}from"./index-B8Ea0mR1.js";import{a as c,i as l,n as u,o as d,r as ee,t as te}from"./views-DZXa6Ete.js";var ne=((t={},n={})=>(n.locale??e())===`zh-TW`?`可能已被當機的 run 處理過:動手前先確認。`:`A run that crashed may already have handled this: check before acting.`),re=((t={},n={})=>(n.locale??e())===`zh-TW`?`分支摘要`:`branch summary`),ie=((t={},n={})=>(n.locale??e())===`zh-TW`?`通訊紀錄`:`Comms log`),f=e=>`context compacted · ${e?.tokens} tokens summarized`,p=e=>`上下文已壓縮 · 摘要了 ${e?.tokens} tokens`,ae=((t,n={})=>(n.locale??e())===`zh-TW`?p(t):f(t)),oe=((t={},n={})=>(n.locale??e())===`zh-TW`?`…(於 1 MB 截斷)`:`… (cut at 1 MB)`),m=e=>`exit ${e?.code}`,h=e=>`結束碼 ${e?.code}`,se=((t,n={})=>(n.locale??e())===`zh-TW`?h(t):m(t)),g=e=>`Image ${e?.n}`,_=e=>`圖片 ${e?.n}`,ce=((t,n={})=>(n.locale??e())===`zh-TW`?_(t):g(t)),le=((t={},n={})=>(n.locale??e())===`zh-TW`?`圖片無法讀取`:`Image unavailable`),v=e=>`${e?.count} image(s)`,y=e=>`${e?.count} 張圖片`,ue=((t,n={})=>(n.locale??e())===`zh-TW`?y(t):v(t)),de=((t={},n={})=>(n.locale??e())===`zh-TW`?`收到`:`incoming`),b=((t={},n={})=>(n.locale??e())===`zh-TW`?`跳到最新`:`jump to latest`),x=e=>`${e?.count} new`,S=e=>`${e?.count} 則新訊息`,C=((t,n={})=>(n.locale??e())===`zh-TW`?S(t):x(t)),fe=((t={},n={})=>(n.locale??e())===`zh-TW`?`還沒有通訊。`:`No transmissions yet.`),pe=((t={},n={})=>(n.locale??e())===`zh-TW`?`通知`:`notice`),me=((t={},n={})=>(n.locale??e())===`zh-TW`?`細節`:`details`),w=((t={},n={})=>(n.locale??e())===`zh-TW`?`表單回覆`:`form answers`),he=((t={},n={})=>(n.locale??e())===`zh-TW`?`訊息,來自`:`message from`),T=e=>`answer from ${e?.from}`,E=e=>`${e?.from} 的回答`,ge=((t,n={})=>(n.locale??e())===`zh-TW`?E(t):T(t)),D=e=>`request from ${e?.from}`,O=e=>`${e?.from} 的請求`,_e=((t,n={})=>(n.locale??e())===`zh-TW`?O(t):D(t)),k=e=>`message from ${e?.from}`,A=e=>`${e?.from} 的訊息`,ve=((t,n={})=>(n.locale??e())===`zh-TW`?A(t):k(t)),j=e=>`reply to your ask from ${e?.from}`,M=e=>`${e?.from} 回覆了你的詢問`,ye=((t,n={})=>(n.locale??e())===`zh-TW`?M(t):j(t)),N=((t={},n={})=>(n.locale??e())===`zh-TW`?`記憶`:`memory`),P=((t={},n={})=>(n.locale??e())===`zh-TW`?`監看`:`monitor`),be=((t={},n={})=>(n.locale??e())===`zh-TW`?`本機`:`this computer`),xe=((t={},n={})=>(n.locale??e())===`zh-TW`?`隊友`:`teammate`),F=((t={},n={})=>(n.locale??e())===`zh-TW`?`提問,來自`:`question from`),I=((t={},n={})=>(n.locale??e())===`zh-TW`?`回報,來自`:`report from`),Se=((t={},n={})=>(n.locale??e())===`zh-TW`?`sb server 的通知`:`notice from the sb server`),L=((t={},n={})=>(n.locale??e())===`zh-TW`?`狀態:`:`status of`),R=((t={},n={})=>(n.locale??e())===`zh-TW`?`Straw Link 訊息`:`Straw Link message`),Ce=((t={},n={})=>(n.locale??e())===`zh-TW`?`喚醒鬧鐘`:`wake-up call`),z=((t={},n={})=>(n.locale??e())===`zh-TW`?`塔台事件`:`tower event`),we=((t={},n={})=>(n.locale??e())===`zh-TW`?`在旁開啟`:`open beside`),B=e=>`Open image ${e?.n}`,V=e=>`打開圖片 ${e?.n}`,Te=((t,n={})=>(n.locale??e())===`zh-TW`?V(t):B(t)),H=e=>`show all (${e?.size})`,U=e=>`顯示全部(${e?.size})`,Ee=((t,n={})=>(n.locale??e())===`zh-TW`?U(t):H(t)),De=((t={},n={})=>(n.locale??e())===`zh-TW`?`顯示全部參數`:`show all arguments`),W=e=>`◇ thought · ${e?.count} chars`,Oe=e=>`◇ 思考 · ${e?.count} 字元`,ke=((t,n={})=>(n.locale??e())===`zh-TW`?Oe(t):W(t)),Ae=((t={},n={})=>(n.locale??e())===`zh-TW`?`◇ 思考 · 已遮蔽`:`◇ thought · redacted`),je=((t={},n={})=>(n.locale??e())===`zh-TW`?`這座塔台正在待命。有訊息進來時,sb server 會喚醒它跑一個 run;你在這裡送出的第一則訊息就會啟動它。`:`This tower stands by. The sb server wakes it for a run when a message arrives; your first message here starts that run.`),Me=((t={},n={})=>(n.locale??e())===`zh-TW`?`無法取得`:`unavailable`),Ne=((t={},n={})=>(n.locale??e())===`zh-TW`?`你`:`you`);function Pe(){let e=!0,t=0;return{get pinned(){return e},scrolled(n){e=n,n&&(t=0)},hold:()=>void(e=!1),arrived(n){return e||(t+=n),e},jump:()=>void(e=!0,t=0),button:n=>e&&!n?void 0:t&&!n?C({count:t}):b()}}async function Fe(e,t,n,r){let i=()=>e.items.some(e=>e.id===n);for(;!i()&&e.before;)r(e.prepend(await t.older(e.before)));return i()?!0:(r(e.reset(await t.latest())),!1)}function Ie(e=600){let t=[],n,r=!1,i=new Set,a=new Map,o=new Map,s=e=>e.forEach(e=>(i.delete(e.id),e.tools?.forEach(e=>(o.delete(e.id),a.delete(e.id)))));function c(e,t){let n=[];for(let r of e)i.has(r.id)||(i.add(r.id),r.kind===`result`&&r.callId?(a.set(r.callId,r),o.has(r.callId)&&t.add(o.get(r.callId))):(r.tools?.forEach(e=>o.set(e.id,r.id)),n.push(r)));return n}let l=e=>({rebuild:!1,added:[],touched:[],dropped:[],front:!1,...e});return{get items(){return t},get before(){return n},get detached(){return r},result:e=>a.get(e),reset(e){return[t,n,r]=[[],e.before,!1],i.clear(),a.clear(),o.clear(),t=c(e.items,new Set),l({rebuild:!0,added:t})},append(i){if(r)return l({});let a=new Set,o=c(i,a);t.push(...o);let u=t.length>e?t.splice(0,t.length-e):[];return s(u),u.length&&(n=t[0].id),l({added:o,touched:[...a],dropped:u.map(e=>e.id)})},prepend(i){let a=new Set,o=c(i.items,a);t.unshift(...o),n=i.before;let u=t.length>e?t.splice(e):[];return s(u),u.length&&(r=!0),l({added:o,touched:[...a],dropped:u.map(e=>e.id),front:!0})}}}var Le=e=>a(e.role),Re=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1}):``,ze=e=>e>=1024?`${(e/1024).toFixed(e>=10240?0:1)} KB`:`${e} B`,Be={intercom_message:he,subagent_result:I,subagent_ping:F,subagent_status:L,"pi-loop-monitor":P,"memory-context":N,"doc-review":w,"straw-tower":z,"straw-link":R},G=e=>{let t=i(`<span class="ava"><svg><use/></svg></span>`);return t.querySelector(`use`).setAttribute(`href`,`#i-${o[e]??e}`),t};function Ve(e){let t=[],n=0;for(let i of e.matchAll(/https?:\/\/[^\s<>)\]]+/g))t.push(e.slice(n,i.index),r(`a`,{href:i[0],rel:`noopener noreferrer`,target:`_blank`},i[0])),n=i.index+i[0].length;return[...t,e.slice(n)]}function K(e,i,{who:a,link:o,docFor:f}){let p=Ie(),m=new Map,h=new Set,g=()=>h.forEach(e=>e.button.isConnected?(e.shown=!0,e.button.hidden=!e.paths.some(e=>f?.(e))):e.shown&&h.delete(e)),_=r(`div`,{class:`chat-list`}),v=r(`div`,{class:`chat-top`}),y=r(`div`,{class:`chat-live`}),b=r(`div`,{class:`chat-end`}),x=r(`button`,{class:`chat-pill`,type:`button`,hidden:``}),S=r(`p`,{class:`chat-empty`},fe()),C=r(`div`,{class:`chat-scroll`,tabindex:`-1`,"aria-label":ie()},v,_,y,b);e.replaceChildren(C,x);let w=Pe(),T=!1,E=!1,D,O,k=0,A=!1,j,M=()=>A||j!==void 0,N=()=>(clearTimeout(j),j=setTimeout(()=>(j=void 0,w.pinned&&!p.detached&&F()),250)),P=(e=w.button(p.detached))=>(x.hidden=!e,x.textContent=e??``),F=()=>(w.jump(),O=void 0,C.scrollTop=C.scrollHeight,P());async function I(e){T=!0;let n=await Fe(p,i,e,e=>(q(e),X(e))).finally(()=>T=!1),r=m.get(e);if(D===e){if(!n||!r)return F();w.hold(),O=r,r.scrollIntoView({block:`center`}),t(r,`lit`),clearTimeout(k),k=window.setTimeout(()=>(O=void 0,r.classList.remove(`lit`)),2e3),P()}}let L=()=>D?void I(D):F(),R=(e,t,n,r)=>{e.disabled=!0,i.entry(n).then(n=>{let i=n&&r(n);if(i===void 0)return void(e.textContent=Me());t.textContent=i,e.remove()},()=>e.textContent=Me())};function z(e,t=0){if(!t||!i.pic)return null;let n=Array.from({length:t},(t,n)=>i.pic(e,n));return r(`div`,{class:`pics`},...n.map((e,t)=>{let i=r(`img`,{src:e,alt:ce({n:t+1}),loading:`lazy`,decoding:`async`}),a=r(`button`,{type:`button`,class:`pic`,"aria-label":Te({n:t+1})},i);return i.addEventListener(`error`,()=>a.replaceWith(r(`em`,{class:`pic-gone`},le()))),a.addEventListener(`click`,()=>void s(async()=>{let{lightbox:e}=await import(`./lightbox-MfTy-vN-.js`);return{lightbox:e}},__vite__mapDeps([0]),import.meta.url).then(({lightbox:e})=>e(n,t))),a}))}function B(e,t){let n=p.result(e.id),i=r(`pre`,{class:`out`},n?.text??``),a=r(`pre`,{class:`args`},e.args??``),o=e.cut?r(`button`,{class:`more`,type:`button`},De()):null;o?.addEventListener(`click`,()=>R(o,a,t,t=>(e=>e&&`${e.args??``}${e.cut?`\n${oe()}`:``}`)(t.tools?.find(t=>t.id===e.id))));let s=n?.more?r(`button`,{class:`more`,type:`button`},Ee({size:ze(n.bytes??0)})):null;s?.addEventListener(`click`,()=>R(s,i,n.id,e=>e.text));let c=e.name===`show_doc`&&f?r(`button`,{class:`more open`,type:`button`,hidden:``},we()):null;c?.addEventListener(`click`,t=>(t.preventDefault(),e.summary.split(`, `).forEach(e=>f?.(e)?.()))),c&&h.add({paths:e.summary.split(`, `),button:c}),c&&queueMicrotask(g);let l=r(`details`,{class:`act`},r(`summary`,{"data-mark":n?n.isError?`error`:`done`:`working`},r(`b`,{class:`badge`}),r(`code`,null,e.name),r(`span`,{class:`sum`},e.summary),c),a,o,n&&r(`div`,{class:`result`},n.images?r(`em`,null,ue({count:n.images})):null,i,s)),u=n&&z(n.id,n.images);return u?[l,u]:[l]}let V=e=>r(`time`,null,Re(e.at)),H=(e,t,n,i)=>r(`article`,{class:`tx you`},r(`header`,null,V(e),r(`b`,null,Ne()),G(`user`)),r(`div`,{class:`bubble`,title:i},n?r(`small`,{class:`boss-flag`},ne()):null,...Ve(t),z(e.id,e.images))),U=(e,t,n,i={})=>r(`article`,{class:`tx sys`},r(`details`,{class:`notice`},r(`summary`,null,G(`comms`),r(`em`,null,de()),...t,V(e)),i.crashed?r(`small`,{class:`boss-flag`},ne()):null,r(`pre`,null,n),i.raw?r(`details`,{class:`notice-raw`},r(`summary`,null,me()),r(`pre`,{class:`raw`},i.raw)):null)),W=e=>{let t=l(e);return[he(),` `,t.name&&o(t.name)||t.name,t.id?` (${t.id})`:``,` · `,be()]},Oe=e=>e.kind===`link`?[{ask:_e,reply:ye,answer:ge,message:ve}[e.what]({from:e.from}),` · `,xe()]:e.kind===`intercom`?W(e.from):[e.kind===`server`?Se():Ce()];function K(e){switch(e.kind){case`user`:{let t=a().service?ee(e.text):void 0;if(t)return U(e,t.kind===`intercom`?W(t.from):[t.kind===`server`?Se():Ce()],e.text??``);let n=a().service?te(e.text):void 0;return H(e,n?n.body:e.text??``,n?.crashed,n?e.text??``:``)}case`assistant`:{let t=a(),n=r(`pre`,{class:`thought-text`}),i=e.thought?r(`button`,{class:`thought`,type:`button`},e.thought<0?Ae():ke({count:e.thought.toLocaleString()})):null;return e.thought&&e.thought>0&&i?.addEventListener(`click`,()=>R(i,n,e.id,e=>e.thoughtText)),r(`article`,{class:`tx in`},G(t.role),r(`div`,{class:`tx-body`},r(`header`,null,r(`b`,null,Le(t)),e.model?r(`span`,null,e.model):null,V(e),e.stop?r(`span`,{class:`stop`,"data-mark":`error`},e.stop):null),i,n,e.text?r(`div`,{class:`md`},c(d(e.text))):null,e.error?r(`p`,{class:`fault`},e.error):null,...(e.tools??[]).flatMap(t=>B(t,e.id))))}case`bash`:return r(`article`,{class:`tx sys`},r(`details`,{class:`act`},r(`summary`,{"data-mark":e.exit?`error`:`done`},r(`b`,{class:`badge`}),r(`code`,null,`shell`),r(`span`,{class:`sum`},`! ${e.command}`),e.exit?r(`span`,{class:`stop`,"data-mark":`error`},se({code:e.exit})):null),e.text?r(`pre`,{class:`out`},e.text):null));case`notice`:{let t=u(e);return t?.kind===`boss`&&a().service?H(e,t.body,t.crashed,e.text??``):t&&t.kind!==`boss`?U(e,Oe(t),t.body,t.kind===`link`?{raw:t.raw}:{crashed:t.crashed}):U(e,[Be[e.type??``]?.()??e.type??pe(),` `,e.from&&o(e.from)||(e.from??``)],e.text??``)}case`divider`:return r(`article`,{class:`tx rule`},r(`details`,null,r(`summary`,null,e.type===`compaction`?ae({tokens:(e.tokens??0).toLocaleString()}):re()),r(`pre`,null,e.text??``)));default:return r(`article`,{class:`tx note`},e.text??``,` `,V(e))}}function q(e){e.rebuild&&(m.clear(),_.replaceChildren());for(let t of e.dropped)m.get(t)?.remove(),m.delete(t);let t=e.added.map(e=>(m.set(e.id,K(e)),m.get(e.id)));e.front?_.prepend(...t):_.append(...t),E&&!e.front&&!e.rebuild&&t.forEach(e=>(e.classList.add(`fresh`),e.dataset.born=String(Date.now()))),S.remove();let n=a().service;S.textContent=n?.state===`standing`&&!n.run?je():fe(),p.items.length||_.append(S),v.hidden=!p.before,He()}let J=[],Y=new Map;function He(){let e=new Set;for(let t of J){let i=Date.parse(t.startedAt),a=p.items.findIndex(e=>e.at!==void 0&&Date.parse(e.at)>=i);if(a===0&&p.before)continue;let o=a<0?``:p.items[a].id,s=JSON.stringify([o,n(t)]),c=Y.get(t.id);if(e.add(t.id),c&&c.sig===s&&c.el.isConnected)continue;c?.el.remove();let l=n(t),u=r(`article`,{class:`tx rule conv-rule`},r(`div`,null,r(`b`,null,l.title),l.ended?r(`small`,null,l.ended):null));Y.set(t.id,{el:u,sig:s});let d=o?m.get(o):void 0;d?d.before(u):_.append(u)}for(let[t,n]of Y)e.has(t)||(n.el.remove(),Y.delete(t))}let X=e=>e.touched.forEach(e=>{let t=m.get(e),n=p.items.find(t=>t.id===e);if(t&&n){let r=K(n);t.classList.contains(`fresh`)&&Date.now()-Number(t.dataset.born??0)<400&&r.classList.add(`fresh`),t.replaceWith(r),m.set(e,r)}}),Ue=async()=>{if(!T&&p.before&&E){T=!0;try{let e=C.scrollHeight,t=p.prepend(await i.older(p.before));q(t),X(t),C.scrollTop+=C.scrollHeight-e}finally{T=!1}p.before&&C.clientHeight&&v.getBoundingClientRect().bottom>=C.getBoundingClientRect().top&&Ue()}};x.addEventListener(`click`,()=>{D=void 0,p.detached?i.latest().then(e=>(q(p.reset(e)),F())):F()});let Z=[new IntersectionObserver(e=>e.some(e=>e.isIntersecting)&&void Ue(),{root:C}),new IntersectionObserver(e=>C.clientHeight&&(w.scrolled(e.at(-1).isIntersecting),P()),{root:C,rootMargin:`0px 0px 67px`})],Q,We=()=>(Q??(Z[0].observe(v),Z[1].observe(b)),clearTimeout(Q),Q=setTimeout(()=>(Q=void 0,Z.forEach(e=>e.disconnect())),600));C.addEventListener(`scroll`,()=>(We(),!A&&j!==void 0&&N()),{passive:!0}),C.addEventListener(`touchstart`,()=>(A=!0,clearTimeout(j),j=void 0),{passive:!0});for(let e of[`touchend`,`touchcancel`])C.addEventListener(e,()=>(A=!1,N()),{passive:!0});for(let e of[`wheel`,`touchstart`,`pointerdown`,`keydown`])C.addEventListener(e,()=>O=D=void 0,{passive:!0});let $=new ResizeObserver(()=>M()?void 0:w.pinned&&!p.detached?C.scrollTop=C.scrollHeight:O?.scrollIntoView({block:`center`}));return $.observe(_),$.observe(C),{log:C,docs:g,runs(e){JSON.stringify(e)!==JSON.stringify(J)&&(J=e,He())},apply(e){if(e.reset)q(p.reset({items:e.items??[],before:e.before})),E=!0,L();else if(e.items?.length){let t=p.append(e.items);q(t),X(t),w.arrived(t.added.length)&&!p.detached&&!M()?F():P()}},reveal(e){D=e,E&&L()},setLive(e,t){y.dataset.mark=t,y.lastChild?.textContent!==e&&y.replaceChildren(...e?[r(`b`,{class:`badge`}),r(`span`,null,e)]:[])}}}export{K as mountChat,ce as t};
@@ -1 +1 @@
1
- import{t as e}from"./runtime-ZX6HkxDa.js";import{t}from"./open_main_title-Ccbha5pD.js";import{n,t as r}from"./unit_count-DFKHs2Sk.js";import{C as i,S as a,X as o,_ as s,a as c,d as l,g as u,h as d,i as f,it as p,l as m,m as h,o as g,v as _,x as v}from"./index-BwRZ1vKG.js";var y=((t={},n={})=>(n.locale??e())===`zh-TW`?`關閉清單`:`Close the list`),b=((t={},n={})=>(n.locale??e())===`zh-TW`?`切換到其他單位`:`Switch to a unit`),x=((t={},n={})=>(n.locale??e())===`zh-TW`?`回到主地圖`:`Back to the map`),S=((t={},n={})=>(n.locale??e())===`zh-TW`?`所有單位`:`All units`),C=((t={},n={})=>(n.locale??e())===`zh-TW`?`指揮中`:`commanding`),w=((t={},n={})=>(n.locale??e())===`zh-TW`?`已結束`:`ended`),T=((t={},n={})=>(n.locale??e())===`zh-TW`?`錯誤`:`error`),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`閒置`:`idle`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`無狀態`:`unknown`),O=((t={},n={})=>(n.locale??e())===`zh-TW`?`等待`:`waiting`),k=((t={},n={})=>(n.locale??e())===`zh-TW`?`工作中`:`working`),A=.4;function j(e,t,n){let[r,i]=[Math.abs(e),Math.abs(t)];return Math.max(r,i)<10?`wait`:r>=1.7*i&&(n?e<0:e>0)?`drag`:`pass`}var M=(e,t,n)=>Math.abs(n)>=.45?n>0:e>=t*A,N=(e,t)=>t||e.some(e=>e.editable||e.sink||e.scrollsX||[`input`,`textarea`,`select`].includes(e.tag));function P(e){let t=e,n=getComputedStyle(e).overflowX;return{tag:e.tagName.toLowerCase(),editable:t.isContentEditable,sink:e.matches(`.composer, .term-sink`),scrollsX:(n===`auto`||n===`scroll`)&&e.scrollWidth>e.clientWidth+1}}var F=e=>{let t=[];for(let n=e;n;n=n.parentElement)t.push(P(n));return t},I={working:k,waiting:O,idle:E,done:w,error:T,unknown:D,commanding:C},L=(e,t,n)=>(t?w:I[e])({},n&&{locale:n}),R=(e,t)=>t.flatMap(t=>[t,...t.subs.map(e=>({...e,sub:!0}))].map(t=>({id:t.key,key:t.key,ws:e,name:t.name,role:t.role,mark:t.mark,note:t.note,ended:!!t.ended,sub:`sub`in t,control:!!t.control})));function z(e){return e.bases.flatMap(e=>{let t=[{id:`tower`,rows:e.tower?R(e.id,[{...e.tower,role:`tower`}]):[]},...e.tabs.map(t=>({id:t.id,label:p({label:t.label}),rows:R(e.id,t.units)})),{id:`outside`,label:n(),rows:R(e.id,e.outside)}].filter(e=>e.rows.length);return t.length?[{id:e.id,label:e.label,mark:e.mark,groups:t}]:[]})}var B=e=>e.role===`main`&&e.mark===`idle`,V=e=>e.reduce((e,t)=>(t.sub?e.at(-1)?.subs.push(t):e.push({...t,subs:[]}),e),[]),H=()=>l(`<div class="unit"><div class="card"><a class="hit"></a>${f}<div class="meta"><span class="name"></span><span class="line"><em class="role"></em><b class="dstate"></b><span class="note"></span></span></div><button type="button" class="quit-btn" data-close="unit" hidden></button></div><div class="subs"></div></div>`),U=()=>l(`<div class="unit tower-row"><div class="trow"><a class="tower-go">${f}</a><button type="button" class="pair-btn tower-add"></button></div><div class="subs"></div></div>`),W=()=>l(`<section class="dbase"><h3><a></a><small></small></h3><div class="dgroups"></div></section>`),G=()=>l(`<div class="dgroup"><h4></h4><div class="drows"></div></div>`),K=()=>matchMedia(`(max-width: 640px)`).matches;function q(){let e=o(`div`,{class:`drawer-body`}),n=o(`button`,{type:`button`,class:`x`,"aria-label":y()},`×`),l=o(`a`,{class:`drawer-map`},x()),f=o(`button`,{type:`button`,class:`pair-btn`,"data-close":`dismiss-all`,hidden:``}),p=o(`div`,{class:`drawer-sweep`,hidden:``},f);c(l,{view:`map`});let C=o(`aside`,{class:`drawer`,"aria-label":b()},o(`header`,null,o(`b`,null,S()),n),e,o(`footer`,{class:`drawer-foot`},p,l)),w=o(`div`,{class:`drawer-veil`});document.body.append(w,C);let T,E,D=!1,O=0,k=0,A,P=()=>{i(f,T??{bases:[]}),p.hidden=f.hidden;let n=(e,t)=>{c(e.querySelector(`.hit`),{view:`session`,ws:t.ws,key:t.key}),e.querySelector(`.hit`).setAttribute(`aria-label`,`${t.name}: ${L(t.mark,t.ended)}`),e.classList.toggle(`current`,t.key===E),e.toggleAttribute(`data-dismiss`,t.role===`subagent`&&t.ended),e.dataset.key=t.key,h(e,t.mark),m(e.querySelector(`.plate`),t.role,t.mark),_(e,`.name`,t.name),_(e,`.role`,d(t.role)),_(e,`.dstate`,L(t.mark,t.ended)),u(e,`.note`,t.note,t.mark,t.note?void 0:``);let r=e.querySelector(`:scope > .card > .quit-btn`);B(t)?v(r,t):r.hidden=!0,s(e.querySelector(`.subs`),t.subs??[],H,n)},a=(e,r)=>{let i=e.querySelector(`.tower-go`),a=e.querySelector(`.tower-add`),o=T?.bases.find(e=>e.id===r.ws);c(i,{view:`session`,ws:r.ws,key:r.key}),i.setAttribute(`aria-label`,`${r.name}: ${L(r.mark,r.ended)}`),e.classList.toggle(`current`,r.key===E),e.dataset.key=r.key,h(e,r.mark),m(i.querySelector(`.plate`),`tower`,r.mark),a.hidden=!o,o&&(g(a,o),a.textContent=`+`,a.setAttribute(`aria-label`,t({base:o.label}))),s(e.querySelector(`.subs`),r.subs,H,n)};s(e,z(T??{bases:[]}),W,(e,t)=>{h(e,t.mark),_(e,`h3 a`,t.label),c(e.querySelector(`h3 a`),{view:`workspace`,ws:t.id}),_(e,`small`,r({count:t.groups.reduce((e,t)=>e+t.rows.length,0)})),s(e.querySelector(`.dgroups`),t.groups,G,(e,t)=>{_(e,`h4`,t.label??``),e.querySelector(`h4`).toggleAttribute(`hidden`,!t.label),t.id===`tower`?s(e.querySelector(`.drows`),V(t.rows),U,a):s(e.querySelector(`.drows`),V(t.rows),H,n)})})},I=e=>{O=Math.max(0,Math.min(k,e)),C.style.setProperty(`--dx`,`${O}px`),w.style.opacity=String(k?O/k:0),w.style.pointerEvents=O>0?`auto`:`none`},R=e=>{D=e,C.classList.toggle(`on`,e),C.inert=!e,document.documentElement.classList.remove(`drawer-drag`),I(e?k:0)},q=()=>{k=C.offsetWidth,P(),C.classList.add(`on`),document.documentElement.classList.add(`drawer-drag`)};C.inert=!0,document.addEventListener(`touchstart`,e=>{let t=e.target,n=C.contains(t)||t===w;if(A=void 0,!K()||e.touches.length!==1||document.querySelector(`dialog.sheet[open], dialog.lightbox[open], [popover]:popover-open`)||(D?!n:N(F(t),!!getSelection()?.toString())))return;let r=e.touches[0],i=D?t.closest(`.unit[data-dismiss] > .card`)??void 0:void 0;A={x0:r.clientX,y0:r.clientY,mode:`wait`,was:D,base:O,last:r.clientX,at:performance.now(),v:0,card:i}},{passive:!0}),document.addEventListener(`touchmove`,e=>{if(!A||A.mode===`pass`)return;let t=e.touches[0],n=t.clientX-A.x0,r=t.clientY-A.y0;if(A.mode===`wait`){let e=j(n,r,A.was);if(e===`wait`)return;if(e===`pass`&&A.card&&j(n,r,!1)===`drag`)A.mode=`card`,A.card.classList.add(`swiping`);else if(e===`pass`)return void(A.mode=`pass`);else A.mode=`drag`,q()}e.preventDefault();let i=performance.now();if(A.v=(t.clientX-A.last)/Math.max(1,i-A.at),[A.last,A.at]=[t.clientX,i],A.mode!==`card`)return I(A.base+n);let a=Math.max(0,n);A.card.style.setProperty(`--sx`,`${a}px`),A.card.style.setProperty(`--so`,String(1-a/A.card.offsetWidth))},{passive:!1});let J=(e,t)=>{e.classList.remove(`swiping`),e.style.removeProperty(`--sx`),e.style.removeProperty(`--so`),t&&(e.classList.add(`gone`),a({key:e.parentElement.dataset.key}).then(t=>t||e.classList.remove(`gone`)))},Y=e=>{let t=A;A=void 0,t?.mode===`drag`&&R(M(O,k,t.v)),t?.mode===`card`&&J(t.card,e.type===`touchend`&&M(Math.max(0,t.last-t.x0),t.card.offsetWidth,t.v))};return document.addEventListener(`touchend`,Y),document.addEventListener(`touchcancel`,Y),w.addEventListener(`click`,()=>R(!1)),C.addEventListener(`click`,e=>e.target.closest(`a[data-route], button[data-open], .x`)&&R(!1)),document.addEventListener(`keydown`,e=>D&&e.key===`Escape`&&(e.preventDefault(),R(!1)),!0),document.addEventListener(`sb-drawer`,()=>(D||q(),R(!D))),{net(e){T=e,D&&P()},route(e){E=e.view===`session`?e.key:void 0,l.toggleAttribute(`aria-current`,e.view===`map`),D&&P()}}}export{q as mountDrawer};
1
+ import{t as e}from"./runtime-ZX6HkxDa.js";import{t}from"./open_main_title-Ccbha5pD.js";import{n,t as r}from"./unit_count-zv9hdHDK.js";import{C as i,S as a,Z as o,_ as s,a as c,at as l,d as u,g as d,h as f,i as p,l as m,m as h,o as g,v as _,x as v}from"./index-B8Ea0mR1.js";var y=((t={},n={})=>(n.locale??e())===`zh-TW`?`關閉清單`:`Close the list`),b=((t={},n={})=>(n.locale??e())===`zh-TW`?`切換到其他單位`:`Switch to a unit`),x=((t={},n={})=>(n.locale??e())===`zh-TW`?`回到主地圖`:`Back to the map`),S=((t={},n={})=>(n.locale??e())===`zh-TW`?`所有單位`:`All units`),C=((t={},n={})=>(n.locale??e())===`zh-TW`?`指揮中`:`commanding`),w=((t={},n={})=>(n.locale??e())===`zh-TW`?`已結束`:`ended`),T=((t={},n={})=>(n.locale??e())===`zh-TW`?`錯誤`:`error`),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`閒置`:`idle`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`無狀態`:`unknown`),O=((t={},n={})=>(n.locale??e())===`zh-TW`?`等待`:`waiting`),k=((t={},n={})=>(n.locale??e())===`zh-TW`?`工作中`:`working`),A=.4;function j(e,t,n){let[r,i]=[Math.abs(e),Math.abs(t)];return Math.max(r,i)<10?`wait`:r>=1.7*i&&(n?e<0:e>0)?`drag`:`pass`}var M=(e,t,n)=>Math.abs(n)>=.45?n>0:e>=t*A,N=(e,t)=>t||e.some(e=>e.editable||e.sink||e.scrollsX||[`input`,`textarea`,`select`].includes(e.tag));function P(e){let t=e,n=getComputedStyle(e).overflowX;return{tag:e.tagName.toLowerCase(),editable:t.isContentEditable,sink:e.matches(`.composer, .term-sink`),scrollsX:(n===`auto`||n===`scroll`)&&e.scrollWidth>e.clientWidth+1}}var F=e=>{let t=[];for(let n=e;n;n=n.parentElement)t.push(P(n));return t},I={working:k,waiting:O,idle:E,done:w,error:T,unknown:D,commanding:C},L=(e,t,n)=>(t?w:I[e])({},n&&{locale:n}),R=(e,t)=>t.flatMap(t=>[t,...t.subs.map(e=>({...e,sub:!0}))].map(t=>({id:t.key,key:t.key,ws:e,name:t.name,role:t.role,mark:t.mark,note:t.note,ended:!!t.ended,sub:`sub`in t,control:!!t.control})));function z(e){return e.bases.flatMap(e=>{let t=[{id:`tower`,rows:e.tower?R(e.id,[{...e.tower,role:`tower`}]):[]},...e.tabs.map(t=>({id:t.id,label:l({label:t.label}),rows:R(e.id,t.units)})),{id:`outside`,label:n(),rows:R(e.id,e.outside)}].filter(e=>e.rows.length);return t.length?[{id:e.id,label:e.label,mark:e.mark,groups:t}]:[]})}var B=e=>e.role===`main`&&e.mark===`idle`,V=e=>e.reduce((e,t)=>(t.sub?e.at(-1)?.subs.push(t):e.push({...t,subs:[]}),e),[]),H=()=>u(`<div class="unit"><div class="card"><a class="hit"></a>${p}<div class="meta"><span class="name"></span><span class="line"><em class="role"></em><b class="dstate"></b><span class="note"></span></span></div><button type="button" class="quit-btn" data-close="unit" hidden></button></div><div class="subs"></div></div>`),U=()=>u(`<div class="unit tower-row"><div class="trow"><a class="tower-go">${p}</a><button type="button" class="pair-btn tower-add"></button></div><div class="subs"></div></div>`),W=()=>u(`<section class="dbase"><h3><a></a><small></small></h3><div class="dgroups"></div></section>`),G=()=>u(`<div class="dgroup"><h4></h4><div class="drows"></div></div>`),K=()=>matchMedia(`(max-width: 640px)`).matches;function q(){let e=o(`div`,{class:`drawer-body`}),n=o(`button`,{type:`button`,class:`x`,"aria-label":y()},`×`),l=o(`a`,{class:`drawer-map`},x()),u=o(`button`,{type:`button`,class:`pair-btn`,"data-close":`dismiss-all`,hidden:``}),p=o(`div`,{class:`drawer-sweep`,hidden:``},u);c(l,{view:`map`});let C=o(`aside`,{class:`drawer`,"aria-label":b()},o(`header`,null,o(`b`,null,S()),n),e,o(`footer`,{class:`drawer-foot`},p,l)),w=o(`div`,{class:`drawer-veil`});document.body.append(w,C);let T,E,D=!1,O=0,k=0,A,P=()=>{i(u,T??{bases:[]}),p.hidden=u.hidden;let n=(e,t)=>{c(e.querySelector(`.hit`),{view:`session`,ws:t.ws,key:t.key}),e.querySelector(`.hit`).setAttribute(`aria-label`,`${t.name}: ${L(t.mark,t.ended)}`),e.classList.toggle(`current`,t.key===E),e.toggleAttribute(`data-dismiss`,t.role===`subagent`&&t.ended),e.dataset.key=t.key,h(e,t.mark),m(e.querySelector(`.plate`),t.role,t.mark),_(e,`.name`,t.name),_(e,`.role`,f(t.role)),_(e,`.dstate`,L(t.mark,t.ended)),d(e,`.note`,t.note,t.mark,t.note?void 0:``);let r=e.querySelector(`:scope > .card > .quit-btn`);B(t)?v(r,t):r.hidden=!0,s(e.querySelector(`.subs`),t.subs??[],H,n)},a=(e,r)=>{let i=e.querySelector(`.tower-go`),a=e.querySelector(`.tower-add`),o=T?.bases.find(e=>e.id===r.ws);c(i,{view:`session`,ws:r.ws,key:r.key}),i.setAttribute(`aria-label`,`${r.name}: ${L(r.mark,r.ended)}`),e.classList.toggle(`current`,r.key===E),e.dataset.key=r.key,h(e,r.mark),m(i.querySelector(`.plate`),`tower`,r.mark),a.hidden=!o,o&&(g(a,o),a.textContent=`+`,a.setAttribute(`aria-label`,t({base:o.label}))),s(e.querySelector(`.subs`),r.subs,H,n)};s(e,z(T??{bases:[]}),W,(e,t)=>{h(e,t.mark),_(e,`h3 a`,t.label),c(e.querySelector(`h3 a`),{view:`workspace`,ws:t.id}),_(e,`small`,r({count:t.groups.reduce((e,t)=>e+t.rows.length,0)})),s(e.querySelector(`.dgroups`),t.groups,G,(e,t)=>{_(e,`h4`,t.label??``),e.querySelector(`h4`).toggleAttribute(`hidden`,!t.label),t.id===`tower`?s(e.querySelector(`.drows`),V(t.rows),U,a):s(e.querySelector(`.drows`),V(t.rows),H,n)})})},I=e=>{O=Math.max(0,Math.min(k,e)),C.style.setProperty(`--dx`,`${O}px`),w.style.opacity=String(k?O/k:0),w.style.pointerEvents=O>0?`auto`:`none`},R=e=>{D=e,C.classList.toggle(`on`,e),C.inert=!e,document.documentElement.classList.remove(`drawer-drag`),I(e?k:0)},q=()=>{k=C.offsetWidth,P(),C.classList.add(`on`),document.documentElement.classList.add(`drawer-drag`)};C.inert=!0,document.addEventListener(`touchstart`,e=>{let t=e.target,n=C.contains(t)||t===w;if(A=void 0,!K()||e.touches.length!==1||document.querySelector(`dialog.sheet[open], dialog.lightbox[open], [popover]:popover-open`)||(D?!n:N(F(t),!!getSelection()?.toString())))return;let r=e.touches[0],i=D?t.closest(`.unit[data-dismiss] > .card`)??void 0:void 0;A={x0:r.clientX,y0:r.clientY,mode:`wait`,was:D,base:O,last:r.clientX,at:performance.now(),v:0,card:i}},{passive:!0}),document.addEventListener(`touchmove`,e=>{if(!A||A.mode===`pass`)return;let t=e.touches[0],n=t.clientX-A.x0,r=t.clientY-A.y0;if(A.mode===`wait`){let e=j(n,r,A.was);if(e===`wait`)return;if(e===`pass`&&A.card&&j(n,r,!1)===`drag`)A.mode=`card`,A.card.classList.add(`swiping`);else if(e===`pass`)return void(A.mode=`pass`);else A.mode=`drag`,q()}e.preventDefault();let i=performance.now();if(A.v=(t.clientX-A.last)/Math.max(1,i-A.at),[A.last,A.at]=[t.clientX,i],A.mode!==`card`)return I(A.base+n);let a=Math.max(0,n);A.card.style.setProperty(`--sx`,`${a}px`),A.card.style.setProperty(`--so`,String(1-a/A.card.offsetWidth))},{passive:!1});let J=(e,t)=>{e.classList.remove(`swiping`),e.style.removeProperty(`--sx`),e.style.removeProperty(`--so`),t&&(e.classList.add(`gone`),a({key:e.parentElement.dataset.key}).then(t=>t||e.classList.remove(`gone`)))},Y=e=>{let t=A;A=void 0,t?.mode===`drag`&&R(M(O,k,t.v)),t?.mode===`card`&&J(t.card,e.type===`touchend`&&M(Math.max(0,t.last-t.x0),t.card.offsetWidth,t.v))};return document.addEventListener(`touchend`,Y),document.addEventListener(`touchcancel`,Y),w.addEventListener(`click`,()=>R(!1)),C.addEventListener(`click`,e=>e.target.closest(`a[data-route], button[data-open], .x`)&&R(!1)),document.addEventListener(`keydown`,e=>D&&e.key===`Escape`&&(e.preventDefault(),R(!1)),!0),document.addEventListener(`sb-drawer`,()=>(D||q(),R(!D))),{net(e){T=e,D&&P()},route(e){E=e.view===`session`?e.key:void 0,l.toggleAttribute(`aria-current`,e.view===`map`),D&&P()}}}export{q as mountDrawer};
@@ -0,0 +1 @@
1
+ import{t as e}from"./rolldown-runtime-DK3Fl9T5.js";import{i as t,n,r,t as i}from"./runtime-ZX6HkxDa.js";var a=e=>`${e?.n}d`,o=e=>`${e?.n} 天`,s=((e,t={})=>(t.locale??i())===`zh-TW`?o(e):a(e)),c=e=>`${e?.n}h`,l=e=>`${e?.n} 小時`,u=((e,t={})=>(t.locale??i())===`zh-TW`?l(e):c(e)),d=e=>`${e?.n}m`,f=e=>`${e?.n} 分`,p=((e,t={})=>(t.locale??i())===`zh-TW`?f(e):d(e)),m=e=>`${e?.n}s`,h=e=>`${e?.n} 秒`,g=((e,t={})=>(t.locale??i())===`zh-TW`?h(e):m(e)),ee=((e={},t={})=>(t.locale??i())===`zh-TW`?`警示`:`Alerts`),te=((e={},t={})=>(t.locale??i())===`zh-TW`?`所有基地`:`all bases`),ne=e=>`ally run · ${e?.device}`,re=e=>`隊友 run · ${e?.device}`,ie=((e,t={})=>(t.locale??i())===`zh-TW`?re(e):ne(e)),ae=((e={},t={})=>(t.locale??i())===`zh-TW`?`唯讀查看這個隊友 run 的通訊`:`Read this ally run's comms (read only)`),oe=((e={},t={})=>(t.locale??i())===`zh-TW`?`還看不到它的通訊:尚未取得這個 run 的工作階段檔`:`Its comms are not shown yet: the run's session file is not known`);function se(e,t,n,r){if(typeof t!=`string`||n!==void 0&&!r)return new e(t,n);let i=se;if(n!==void 0){let r=i.prototypeKeys??=new Set([`constructor`,`__defineGetter__`,`__defineSetter__`,`hasOwnProperty`,`__lookupGetter__`,`__lookupSetter__`,`isPrototypeOf`,`propertyIsEnumerable`,`toString`,`valueOf`,`__proto__`,`toLocaleString`]);if(Object.getOwnPropertyNames(Object.prototype).some(e=>!r.has(e)))return new e(t,n)}let a=[];for(let r of Object.keys(n??{}).sort()){let i=n[r];if(i!==void 0){if(i!==null&&![`string`,`number`,`boolean`].includes(typeof i)||typeof i==`number`&&!Number.isFinite(i))return new e(t,n);a.push([r,i])}}let o=JSON.stringify([t,a]),s=i.caches??=new WeakMap,c=s.get(e);if(c||(c=new Map,s.set(e,c)),c.has(o))return c.get(o);let l=new e(t,n);if(c.size>=256){let e=c.keys().next().value;e!==void 0&&c.delete(e)}return c.set(o,l),l}function _(e,t,n,r=!1){return se(Intl.PluralRules,e,n,r).select(Number(t)-Number(n?.offset??0))}var ce=e=>{let t=_(`en`,e?.count,{},!0);return t===`one`?`${e?.count} ally run`:t===`other`?`${e?.count} ally runs`:`ally_runs`},le=e=>`${e?.count} 個隊友 run`,ue=((e,t={})=>(t.locale??i())===`zh-TW`?le(e):ce(e)),de=e=>`${e?.team} · teammate`,fe=e=>`${e?.team} · 隊友`,pe=((e,t={})=>(t.locale??i())===`zh-TW`?fe(e):de(e)),me=((e={},t={})=>(t.locale??i())===`zh-TW`?``:`.`),he=((e={},t={})=>(t.locale??i())===`zh-TW`?`最後更新:`:`Last update`),ge=e=>`Disconnected. Gave up after ${e?.tries} tries; it reconnects when you return to this tab.`,_e=e=>`連線中斷。重試 ${e?.tries} 次後放棄;回到此分頁時會重新連線。`,ve=((e,t={})=>(t.locale??i())===`zh-TW`?_e(e):ge(e)),ye=e=>`The server is up but cannot read the net: ${e?.problem}`,be=e=>`伺服器正常,但讀不到網:${e?.problem}`,xe=((e,t={})=>(t.locale??i())===`zh-TW`?be(e):ye(e)),Se=((e={},t={})=>(t.locale??i())===`zh-TW`?`與稻草網的連線中斷,正在重新連線…畫面顯示的是最後已知狀態。`:`Disconnected from the straw net. Reconnecting… The view shows the last known state.`),Ce=e=>`Disconnected from the straw net. Reconnecting (try ${e?.attempt})… The view shows the last known state.`,we=e=>`與稻草網的連線中斷,正在重新連線(第 ${e?.attempt} 次)…畫面顯示的是最後已知狀態。`,Te=((e,t={})=>(t.locale??i())===`zh-TW`?we(e):Ce(e)),Ee=((e={},t={})=>(t.locale??i())===`zh-TW`?`這個網址在這裡無法使用(sb server 可能重新啟動過,或連結已過期):在這台電腦請開啟 /boss gui;在手機請重新掃描新的 QR code。`:`This address does not work here (the sb server may have restarted, or the link expired): on this computer open /boss gui; on a phone scan a new QR code.`),De=((e={},t={})=>(t.locale??i())===`zh-TW`?`Straw Net:所有基地`:`Straw Net: all bases`),Oe=((e={},t={})=>(t.locale??i())===`zh-TW`?`取消`:`Cancel`),ke=((e={},t={})=>(t.locale??i())===`zh-TW`?`關閉`:`Close`),Ae=e=>`Quit base ${e?.name}`,je=e=>`關掉基地 ${e?.name}`,Me=((e,t={})=>(t.locale??i())===`zh-TW`?je(e):Ae(e)),Ne=e=>`Quit base ${e?.name}? Every agent in it and its tower quit. Nothing quits while anything running would be lost.`,Pe=e=>`要關掉基地 ${e?.name} 嗎?裡面所有 agent 和塔台都會退出。有會遺失的東西時什麼都不關。`,Fe=((e,t={})=>(t.locale??i())===`zh-TW`?Pe(e):Ne(e)),Ie=e=>`Quit squad ${e?.name}`,Le=e=>`關掉小隊 ${e?.name}`,Re=((e,t={})=>(t.locale??i())===`zh-TW`?Le(e):Ie(e)),ze=e=>`Quit squad ${e?.name}? Every agent in it quits.`,Be=e=>`要關掉小隊 ${e?.name} 嗎?裡面所有 agent 都會退出。`,Ve=((e,t={})=>(t.locale??i())===`zh-TW`?Be(e):ze(e)),He=e=>`Quit the tower ${e?.name}? The base's mains become members again.`,Ue=e=>`要關掉塔台 ${e?.name} 嗎?這個基地的主智慧體都會降格成成員。`,We=((e,t={})=>(t.locale??i())===`zh-TW`?Ue(e):He(e)),Ge=e=>`Quit ${e?.name}`,Ke=e=>`關掉 ${e?.name}`,qe=((e,t={})=>(t.locale??i())===`zh-TW`?Ke(e):Ge(e)),Je=e=>`Quit ${e?.name}? It quits pi and its pane closes.`,Ye=e=>`要關掉 ${e?.name} 嗎?它會退出 pi,窗格也會關掉。`,Xe=((e,t={})=>(t.locale??i())===`zh-TW`?Ye(e):Je(e)),Ze=e=>`control tower · ${e?.state}`,Qe=e=>`塔台 · ${e?.state}`,$e=((e,t={})=>(t.locale??i())===`zh-TW`?Qe(e):Ze(e)),et=e=>`hard cap ${e?.time}`,tt=e=>`上限 ${e?.time}`,nt=((e,t={})=>(t.locale??i())===`zh-TW`?tt(e):et(e)),rt=((e={},t={})=>(t.locale??i())===`zh-TW`?`收尾中`:`closing`),it=e=>`Boss conversation · new session · ${e?.time}`,at=e=>`老闆對話・新的工作階段・${e?.time}`,ot=((e,t={})=>(t.locale??i())===`zh-TW`?at(e):it(e)),st=e=>`Boss conversation · resumed · ${e?.time}`,ct=e=>`老闆對話・接續・${e?.time}`,lt=((e,t={})=>(t.locale??i())===`zh-TW`?ct(e):st(e)),ut=e=>`ended ${e?.time}`,dt=e=>`${e?.time} 結束`,ft=((e,t={})=>(t.locale??i())===`zh-TW`?dt(e):ut(e)),pt=e=>`waiting for you; it ends at ${e?.time} if you stay quiet`,mt=e=>`等你說話;你若不說話,${e?.time} 結束`,ht=((e,t={})=>(t.locale??i())===`zh-TW`?mt(e):pt(e)),gt=((e={},t={})=>(t.locale??i())===`zh-TW`?`新的工作階段`:`new session`),_t=e=>`new session · ${e?.why}`,vt=e=>`新的工作階段・${e?.why}`,yt=((e,t={})=>(t.locale??i())===`zh-TW`?vt(e):_t(e)),bt=e=>`resumed session · boss turns: ${e?.turns}`,xt=e=>`接續舊工作階段・老闆輪數 ${e?.turns}`,St=((e,t={})=>(t.locale??i())===`zh-TW`?xt(e):bt(e)),Ct=((e={},t={})=>(t.locale??i())===`zh-TW`?`老闆對話・收尾中`:`boss conversation · closing`),wt=e=>`boss conversation · waiting for you · ends after ${e?.minutes} min idle`,Tt=e=>`老闆對話・等你說話・閒置 ${e?.minutes} 分鐘後結束`,Et=((e,t={})=>(t.locale??i())===`zh-TW`?Tt(e):wt(e)),Dt=e=>`boss conversation · ends after ${e?.minutes} min idle`,Ot=e=>`老闆對話・閒置 ${e?.minutes} 分鐘後結束`,kt=((e,t={})=>(t.locale??i())===`zh-TW`?Ot(e):Dt(e)),At=e=>`working; it ends after ${e?.minutes} min idle`,jt=e=>`處理中;閒置 ${e?.minutes} 分鐘後結束`,Mt=((e,t={})=>(t.locale??i())===`zh-TW`?jt(e):At(e)),Nt=((e={},t={})=>(t.locale??i())===`zh-TW`?`圖示來自 game-icons.net(Lorc、Delapouite),CC BY 3.0。`:`Icons from game-icons.net by Lorc and Delapouite, CC BY 3.0.`),Pt=((e={},t={})=>(t.locale??i())===`zh-TW`?`移除`:`Dismiss`),Ft=e=>`Dismiss finished (${e?.count})`,It=e=>`移除已完成(${e?.count})`,Lt=((e,t={})=>(t.locale??i())===`zh-TW`?It(e):Ft(e)),Rt=e=>`Dismiss ${e?.name}`,zt=e=>`從畫面移除 ${e?.name}`,Bt=((e,t={})=>(t.locale??i())===`zh-TW`?zt(e):Rt(e)),Vt=((e={},t={})=>(t.locale??i())===`zh-TW`?`文件`:`Documents`),Ht=((e={},t={})=>(t.locale??i())===`zh-TW`?`總塔台`:`head tower`),Ut=((e={},t={})=>(t.locale??i())===`zh-TW`?`語言`:`Language`),Wt=e=>`${e?.label} (${e?.short}) asks you to confirm a ${e?.tool} call from its tower ${e?.tower}, which acts on a message you sent`,Gt=e=>`${e?.label}(${e?.short})請你確認它的塔台 ${e?.tower} 的一次 ${e?.tool} 呼叫,該塔台正在處理你送出的訊息`,Kt=((e,t={})=>(t.locale??i())===`zh-TW`?Gt(e):Wt(e)),qt=e=>`${e?.label} (${e?.short}) asks you to confirm a ${e?.tool} call from its tower`,Jt=e=>`${e?.label}(${e?.short})請你確認它塔台的一次 ${e?.tool} 呼叫`,Yt=((e,t={})=>(t.locale??i())===`zh-TW`?Jt(e):qt(e)),Xt=e=>`Team ${e?.team} stopped: ${e?.reason}`,Zt=e=>`團隊 ${e?.team} 已停止:${e?.reason}`,Qt=((e,t={})=>(t.locale??i())===`zh-TW`?Zt(e):Xt(e)),$t=e=>{let t=_(`en`,e?.count,{},!0);return t===`one`?`${e?.count} message has waited more than 10 minutes for an idle tower in team ${e?.team}`:t===`other`?`${e?.count} messages have waited more than 10 minutes for an idle tower in team ${e?.team}`:`link_a_held`},en=e=>`團隊 ${e?.team} 有 ${e?.count} 則訊息已等了超過 10 分鐘,塔台一直不閒`,tn=((e,t={})=>(t.locale??i())===`zh-TW`?en(e):$t(e)),nn=e=>{let t=_(`en`,e?.count,{},!0);return t===`one`?`${e?.count} message waits in the inbox of team ${e?.team}: no tower is open on its project`:t===`other`?`${e?.count} messages wait in the inbox of team ${e?.team}: no tower is open on its project`:`link_a_inbox`},rn=e=>`團隊 ${e?.team} 的收件匣有 ${e?.count} 則訊息在等:專案上沒有開著的塔台`,an=((e,t={})=>(t.locale??i())===`zh-TW`?rn(e):nn(e)),on=e=>`${e?.label} (${e?.short}) asks to join team ${e?.team}`,sn=e=>`${e?.label}(${e?.short})要求加入團隊 ${e?.team}`,cn=((e,t={})=>(t.locale??i())===`zh-TW`?sn(e):on(e)),ln=e=>`${e?.label} (${e?.short}), an unattended device, asks to join team ${e?.team}`,un=e=>`${e?.label}(${e?.short})是無人值守的裝置,要求加入團隊 ${e?.team}`,dn=((e,t={})=>(t.locale??i())===`zh-TW`?un(e):ln(e)),fn=e=>`${e?.label} (${e?.short}) shows another roster than this computer in team ${e?.team}; the relay may be showing different rosters`,pn=e=>`團隊 ${e?.team} 中,${e?.label}(${e?.short})顯示的名冊和這台電腦不同;中繼站可能對不同人顯示不同名冊`,mn=((e,t={})=>(t.locale??i())===`zh-TW`?pn(e):fn(e)),hn=e=>{let t=_(`en`,e?.count,{},!0);return t===`one`?`${e?.count} Straw Link message has waited more than 10 minutes in the inbox of team ${e?.team} for an ally run. Look at the tower's card on the map: a held tower or a refused start keeps it waiting.`:t===`other`?`${e?.count} Straw Link messages have waited more than 10 minutes in the inbox of team ${e?.team} for an ally run. Look at the tower's card on the map: a held tower or a refused start keeps them waiting.`:`link_a_served`},gn=e=>`團隊 ${e?.team} 的收件匣有 ${e?.count} 則 Straw Link 訊息等隊友 run 接手已超過 10 分鐘。請看地圖上塔台的卡片:塔台已暫停或 run 啟動被拒,都會讓它們一直等。`,_n=((e,t={})=>(t.locale??i())===`zh-TW`?gn(e):hn(e)),vn=e=>`The relay of team ${e?.team} has been unreachable for ${e?.minutes} minutes`,yn=e=>`團隊 ${e?.team} 的中繼站已經 ${e?.minutes} 分鐘連不上`,bn=((e,t={})=>(t.locale??i())===`zh-TW`?yn(e):vn(e)),xn=e=>`Link ${e?.count}`,Sn=e=>`連線 ${e?.count}`,Cn=((e,t={})=>(t.locale??i())===`zh-TW`?Sn(e):xn(e)),wn=((e={},t={})=>(t.locale??i())===`zh-TW`?`Straw Link 通知`:`Straw Link notices`),Tn=((e={},t={})=>(t.locale??i())===`zh-TW`?`允許`:`Allow`),En=((e={},t={})=>(t.locale??i())===`zh-TW`?`團隊`:`Teams`),Dn=((e={},t={})=>(t.locale??i())===`zh-TW`?`Straw Link:跨電腦的團隊`:`Straw Link: teams across computers`),On=((e={},t={})=>(t.locale??i())===`zh-TW`?`連線中`:`connecting`),kn=((e={},t={})=>(t.locale??i())===`zh-TW`?`拒絕`:`Deny`),An=((e={},t={})=>(t.locale??i())===`zh-TW`?`即時`:`live`),jn=((e={},t={})=>(t.locale??i())===`zh-TW`?`尚未見到`:`not seen yet`),Mn=((e={},t={})=>(t.locale??i())===`zh-TW`?`離線`:`offline`),Nn=((e={},t={})=>(t.locale??i())===`zh-TW`?`在線`:`online`),Pn=((e={},t={})=>(t.locale??i())===`zh-TW`?`開啟團隊`:`Open Teams`),Fn=((e={},t={})=>(t.locale??i())===`zh-TW`?`重新連線中`:`reconnecting`),In=((e={},t={})=>(t.locale??i())===`zh-TW`?`查看`:`Review`),Ln=e=>`seen ${e?.ago} ago`,Rn=e=>`${e?.ago}前見到`,zn=((e,t={})=>(t.locale??i())===`zh-TW`?Rn(e):Ln(e)),Bn=((e={},t={})=>(t.locale??i())===`zh-TW`?`查看塔台`:`Show towers`),Vn=((e={},t={})=>(t.locale??i())===`zh-TW`?`正體中文`:`English`),Hn=((e={},t={})=>(t.locale??i())===`zh-TW`?`位置`:`Location`),Un=e=>`${e?.name} is commanding`,Wn=e=>`${e?.name} 指揮中`,Gn=((e,t={})=>(t.locale??i())===`zh-TW`?Wn(e):Un(e)),Kn=e=>`${e?.name} finished`,qn=e=>`${e?.name} 已完成`,Jn=((e,t={})=>(t.locale??i())===`zh-TW`?qn(e):Kn(e)),Yn=e=>`${e?.name} hit an error`,Xn=e=>`${e?.name} 發生錯誤`,Zn=((e,t={})=>(t.locale??i())===`zh-TW`?Xn(e):Yn(e)),Qn=e=>`${e?.name} went idle`,$n=e=>`${e?.name} 轉為閒置`,er=((e,t={})=>(t.locale??i())===`zh-TW`?$n(e):Qn(e)),tr=e=>`${e?.name} joined`,nr=e=>`${e?.name} 加入`,rr=((e,t={})=>(t.locale??i())===`zh-TW`?nr(e):tr(e)),ir=e=>`${e?.name} left`,ar=e=>`${e?.name} 離開`,or=((e,t={})=>(t.locale??i())===`zh-TW`?ar(e):ir(e)),sr=e=>`${e?.name} lost its status`,cr=e=>`${e?.name} 失去狀態`,lr=((e,t={})=>(t.locale??i())===`zh-TW`?cr(e):sr(e)),ur=e=>`${e?.name} is waiting on a question`,dr=e=>`${e?.name} 正在等待回答`,fr=((e,t={})=>(t.locale??i())===`zh-TW`?dr(e):ur(e)),pr=e=>`${e?.name} started working`,mr=e=>`${e?.name} 開始工作`,hr=((e,t={})=>(t.locale??i())===`zh-TW`?mr(e):pr(e)),gr=((e={},t={})=>(t.locale??i())===`zh-TW`?`指揮中`:`commanding`),_r=((e={},t={})=>(t.locale??i())===`zh-TW`?`已完成`:`finished`),vr=((e={},t={})=>(t.locale??i())===`zh-TW`?`錯誤`:`error`),v=((e={},t={})=>(t.locale??i())===`zh-TW`?`閒置`:`idle`),yr=((e={},t={})=>(t.locale??i())===`zh-TW`?`待命`:`standing by`),br=((e={},t={})=>(t.locale??i())===`zh-TW`?`無狀態`:`no status`),y=((e={},t={})=>(t.locale??i())===`zh-TW`?`等待回答`:`waiting on a question`),xr=((e={},t={})=>(t.locale??i())===`zh-TW`?`工作中`:`working`),Sr=((e={},t={})=>(t.locale??i())===`zh-TW`?`你的原話`:`your words`),Cr=((e={},t={})=>(t.locale??i())===`zh-TW`?`塔台提議,你確認`:`proposed by the tower, confirmed by you`),wr=((e={},t={})=>(t.locale??i())===`zh-TW`?`塔台自己的備註`:`the tower's note`),Tr=((e={},t={})=>(t.locale??i())===`zh-TW`?`確認`:`Confirm`),Er=e=>`${e?.standing} standing · ${e?.decisions} decisions · ${e?.waits} waits`,Dr=e=>`${e?.standing} 常駐指示・${e?.decisions} 決定・${e?.waits} 等待`,Or=((e,t={})=>(t.locale??i())===`zh-TW`?Dr(e):Er(e)),kr=e=>`${e?.standing} standing · ${e?.decisions} decisions · ${e?.waits} waits · ${e?.proposals} to confirm`,Ar=e=>`${e?.standing} 常駐指示・${e?.decisions} 決定・${e?.waits} 等待・${e?.proposals} 則待你確認`,jr=((e,t={})=>(t.locale??i())===`zh-TW`?Ar(e):kr(e)),Mr=e=>`The tower proposes a decision: ${e?.text}`,Nr=e=>`塔台提議一項決定:${e?.text}`,Pr=((e,t={})=>(t.locale??i())===`zh-TW`?Nr(e):Mr(e)),Fr=e=>`The tower proposes a standing instruction: ${e?.text}`,Ir=e=>`塔台提議一則常駐指示:${e?.text}`,Lr=((e,t={})=>(t.locale??i())===`zh-TW`?Ir(e):Fr(e)),Rr=e=>`The tower proposes to retire ${e?.id}: ${e?.text}`,zr=e=>`塔台提議撤掉 ${e?.id}:${e?.text}`,Br=((e,t={})=>(t.locale??i())===`zh-TW`?zr(e):Rr(e)),Vr=((e={},t={})=>(t.locale??i())===`zh-TW`?`駁回`:`Reject`),Hr=((e={},t={})=>(t.locale??i())===`zh-TW`?`你讀到記憶之後它又有變動,所以重新顯示了。請再試一次。`:`The memory changed since you read it, so it is shown again. Try once more.`),Ur=e=>`waits for ${e?.who}`,Wr=e=>`等 ${e?.who}`,Gr=((e,t={})=>(t.locale??i())===`zh-TW`?Wr(e):Ur(e)),Kr=e=>`answered? a message came from ${e?.who}`,qr=e=>`可能已回覆:${e?.who} 來了一則訊息`,Jr=((e,t={})=>(t.locale??i())===`zh-TW`?qr(e):Kr(e)),Yr=((e={},t={})=>(t.locale??i())===`zh-TW`?`等你決定`:`waits for you`),Xr=((e={},t={})=>(t.locale??i())===`zh-TW`?`已過 7 天而失效`:`expired after 7 days`),Zr=e=>`resolved: ${e?.outcome}`,Qr=e=>`已處理:${e?.outcome}`,$r=((e,t={})=>(t.locale??i())===`zh-TW`?Qr(e):Zr(e)),ei=((e={},t={})=>(t.locale??i())===`zh-TW`?`地圖總覽`:`Overview of the map`),ti=e=>`Monitor failed: ${e?.what}`,ni=e=>`Monitor 出錯:${e?.what}`,ri=((e,t={})=>(t.locale??i())===`zh-TW`?ni(e):ti(e)),ii=e=>`Monitor went quiet and stopped: ${e?.what}`,ai=e=>`Monitor 太久沒輸出,已停止:${e?.what}`,oi=((e,t={})=>(t.locale??i())===`zh-TW`?ai(e):ii(e)),si=((e={},t={})=>(t.locale??i())===`zh-TW`?`從未`:`never`),ci=((e={},t={})=>(t.locale??i())===`zh-TW`?`+新基地`:`+ New base`),li=((e={},t={})=>(t.locale??i())===`zh-TW`?`沒有執行中的智慧體`:`no agent running`),ui=((e={},t={})=>(t.locale??i())===`zh-TW`?`無警示`:`no alerts`),b=((e={},t={})=>(t.locale??i())===`zh-TW`?`伺服器沒有回應。`:`The server did not answer.`),di=((e={},t={})=>(t.locale??i())===`zh-TW`?`尚無塔台`:`no tower yet`),fi=((e={},t={})=>(t.locale??i())===`zh-TW`?`監看中`:`Watching a monitor`),pi=((e={},t={})=>(t.locale??i())===`zh-TW`?`思考中`:`thinking`),mi=e=>`Finished ${e?.note}`,hi=e=>`完成了 ${e?.note}`,gi=((e,t={})=>(t.locale??i())===`zh-TW`?hi(e):mi(e)),_i=e=>`Failed ${e?.note}`,vi=e=>`出錯了 ${e?.note}`,yi=((e,t={})=>(t.locale??i())===`zh-TW`?vi(e):_i(e)),bi=e=>`Waiting on you ${e?.note}`,xi=e=>`等你回答 ${e?.note}`,Si=((e,t={})=>(t.locale??i())===`zh-TW`?xi(e):bi(e)),Ci=((e={},t={})=>(t.locale??i())===`zh-TW`?`+主智慧體`:`+ Main`),wi=((e={},t={})=>(t.locale??i())===`zh-TW`?`+成員`:`+ Member`),Ti=((e={},t={})=>(t.locale??i())===`zh-TW`?`前哨`:`Outposts`),Ei=((e={},t={})=>(t.locale??i())===`zh-TW`?`手機`:`Phone`),Di=((e={},t={})=>(t.locale??i())===`zh-TW`?`配對手機`:`Pair a phone`),Oi=((e={},t={})=>(t.locale??i())===`zh-TW`?`接回`:`Pop`),ki=e=>`Pop ${e?.name}`,Ai=e=>`接回 ${e?.name}`,ji=((e,t={})=>(t.locale??i())===`zh-TW`?Ai(e):ki(e)),Mi=((e={},t={})=>(t.locale??i())===`zh-TW`?`伺服器送來的快照,頁面無法讀取`:`the server sent a snapshot the page cannot read`),Ni=((e={},t={})=>(t.locale??i())===`zh-TW`?`伺服器回報了頁面無法讀取的問題`:`the server reported a problem the page cannot read`),Pi=((e={},t={})=>(t.locale??i())===`zh-TW`?`關掉`:`Quit`),Fi=((e={},t={})=>(t.locale??i())===`zh-TW`?`關掉塔台`:`Quit tower`),Ii=e=>`Refused (${e?.status}).`,Li=e=>`已拒絕(${e?.status})。`,x=((e,t={})=>(t.locale??i())===`zh-TW`?Li(e):Ii(e)),Ri=((e={},t={})=>(t.locale??i())===`zh-TW`?`提醒`:`Remind`),zi=((e={},t={})=>(t.locale??i())===`zh-TW`?`點一下允許瀏覽器通知`:`Press to allow browser notifications`),Bi=((e={},t={})=>(t.locale??i())===`zh-TW`?`瀏覽器已封鎖通知,要到網站設定裡允許`:`The browser blocks notifications; allow them in the site settings`),Vi=((e={},t={})=>(t.locale??i())===`zh-TW`?`提醒已關`:`Reminders off`),Hi=((e={},t={})=>(t.locale??i())===`zh-TW`?`提醒已開:分頁不在前景時,單位等你回答、完成或出錯會跳系統通知`:`Reminders on: while the page is in the background, a unit waiting on you, finishing, or failing raises a system notification`),Ui=((e={},t={})=>(t.locale??i())===`zh-TW`?`這個瀏覽器不支援通知`:`This browser has no notifications`),Wi=((e={},t={})=>(t.locale??i())===`zh-TW`?`隊友 run`:`ally run`),Gi=((e={},t={})=>(t.locale??i())===`zh-TW`?`主智慧體`:`main`),Ki=((e={},t={})=>(t.locale??i())===`zh-TW`?`成員`:`member`),qi=((e={},t={})=>(t.locale??i())===`zh-TW`?`前哨`:`outpost`),Ji=((e={},t={})=>(t.locale??i())===`zh-TW`?`未編入`:`unaligned`),Yi=((e={},t={})=>(t.locale??i())===`zh-TW`?`事件 run`:`event run`),Xi=((e={},t={})=>(t.locale??i(),`session`)),Zi=((e={},t={})=>(t.locale??i())===`zh-TW`?`子智慧體`:`subagent`),Qi=((e={},t={})=>(t.locale??i())===`zh-TW`?`塔台`:`tower`),$i=((e={},t={})=>(t.locale??i())===`zh-TW`?`伺服器`:`Server`),ea=((e={},t={})=>(t.locale??i())===`zh-TW`?`sb 伺服器:狀態、重新啟動與記錄`:`The sb server: state, restart, and log`),ta=((e={},t={})=>(t.locale??i())===`zh-TW`?`設定`:`Settings`),na=((e={},t={})=>(t.locale??i())===`zh-TW`?`音效`:`Sound`),ra=((e={},t={})=>(t.locale??i())===`zh-TW`?`音效已關`:`Sounds off`),ia=((e={},t={})=>(t.locale??i())===`zh-TW`?`音效已開`:`Sounds on`),aa=((e={},t={})=>(t.locale??i())===`zh-TW`?`音效:開關、音量與試聽`:`Sounds: on or off, volume, and a try`),oa=((e={},t={})=>(t.locale??i())===`zh-TW`?`▶ 試聽`:`▶ Try`),sa=((e={},t={})=>(t.locale??i())===`zh-TW`?`音量`:`Volume`),ca=((e={},t={})=>(t.locale??i())===`zh-TW`?`收起`:`Stash`),la=e=>`Stash base ${e?.name}`,ua=e=>`收起基地 ${e?.name}`,da=((e,t={})=>(t.locale??i())===`zh-TW`?ua(e):la(e)),fa=e=>`Stash base ${e?.name}? Its tower, mains, and members quit and come back with Pop. Nothing is stashed while anything running would be lost.`,pa=e=>`要收起基地 ${e?.name} 嗎?塔台、主智慧體和成員會結束,之後可以用「接回」叫回來。有會遺失的東西時不會收。`,ma=((e,t={})=>(t.locale??i())===`zh-TW`?pa(e):fa(e)),ha=e=>`Stashed (${e?.count})`,ga=e=>`已收起(${e?.count})`,_a=((e,t={})=>(t.locale??i())===`zh-TW`?ga(e):ha(e)),va=((e={},t={})=>(t.locale??i())===`zh-TW`?`智慧體`:`Agents`),ya=((e={},t={})=>(t.locale??i())===`zh-TW`?`基地`:`Bases`),ba=((e={},t={})=>(t.locale??i())===`zh-TW`?`指揮中`:`Commanding`),xa=((e={},t={})=>(t.locale??i())===`zh-TW`?`等待中`:`Waiting`),Sa=((e={},t={})=>(t.locale??i())===`zh-TW`?`工作中`:`Working`),Ca=((e={},t={})=>(t.locale??i())===`zh-TW`?`狀態`:`States`),wa=e=>`tab ${e?.label}`,Ta=e=>`分頁 ${e?.label}`,Ea=((e,t={})=>(t.locale??i())===`zh-TW`?Ta(e):wa(e)),Da=((e={},t={})=>(t.locale??i())===`zh-TW`?`即時網況 · 通訊`:`live net · comms`),Oa=((e={},t={})=>(t.locale??i())===`zh-TW`?`網路活動`:`Net activity`),ka=((e={},t={})=>(t.locale??i())===`zh-TW`?`伺服器啟動後還沒有動靜`:`Nothing has happened since the server started`),Aa=((e={},t={})=>(t.locale??i())===`zh-TW`?`現在`:`now`),ja=e=>`${e?.count} events in 30 min`,Ma=e=>`近 30 分鐘 ${e?.count} 筆`,Na=((e,t={})=>(t.locale??i())===`zh-TW`?Ma(e):ja(e)),Pa=((e={},t={})=>(t.locale??i())===`zh-TW`?`網的總計`:`Net totals`),Fa=e=>`The tower refused it: ${e?.reason}`,Ia=e=>`塔台拒絕了:${e?.reason}`,La=((e,t={})=>(t.locale??i())===`zh-TW`?Ia(e):Fa(e)),Ra=((e={},t={})=>(t.locale??i())===`zh-TW`?`回覆`:`Answer`),za=((e={},t={})=>(t.locale??i())===`zh-TW`?`重新送達`:`Deliver again`),Ba=((e={},t={})=>(t.locale??i())===`zh-TW`?`捨棄`:`Drop`),Va=((e={},t={})=>(t.locale??i())===`zh-TW`?`沒有這則已擱置的事件。`:`No such parked event.`),Ha=((e={},t={})=>(t.locale??i())===`zh-TW`?`sb server 沒有替這個工作區執行塔台。`:`The sb server runs no tower for this workspace.`),Ua=e=>{let t=_(`en`,e?.count,{},!0);return t===`one`?`${e?.count} failed run lately`:t===`other`?`${e?.count} failed runs lately`:`tower_failures`},Wa=e=>`近來有 ${e?.count} 次 run 失敗`,Ga=((e,t={})=>(t.locale??i())===`zh-TW`?Wa(e):Ua(e)),Ka=((e={},t={})=>(t.locale??i())===`zh-TW`?`上一次 run 當機`:`last run crashed`),qa=((e={},t={})=>(t.locale??i())===`zh-TW`?`上一次 run 已結束`:`last run quit`),Ja=((e={},t={})=>(t.locale??i())===`zh-TW`?`上一次 run 逾時`:`last run timed out`),Ya=e=>`An event was parked after two runs crashed with it: ${e?.what}`,Xa=e=>`有一則事件在兩個 run 都當機後被擱置:${e?.what}`,Za=((e,t={})=>(t.locale??i())===`zh-TW`?Xa(e):Ya(e)),Qa=((e={},t={})=>(t.locale??i())===`zh-TW`?`run 一再當機或逾時,所以塔台不再自動喚醒。佇列仍保留;按重試,或由老闆送一則訊息,就會再喚醒它。`:`Runs crashed or timed out again and again, so the tower stops waking. The queue is kept; Retry, or a message from the boss, wakes it again.`),$a=((e={},t={})=>(t.locale??i())===`zh-TW`?`常駐窗格不在它自己的 shell:裡面有巢狀 shell 或程式在跑。請先離開它,再按重試`:`The standing pane is not at its own shell: a nested shell or a program runs there. Leave it, then press Retry`),eo=e=>`The tower types nothing in the standing pane: ${e?.reason}`,to=e=>`塔台不在常駐窗格輸入任何東西:${e?.reason}`,no=((e,t={})=>(t.locale??i())===`zh-TW`?to(e):eo(e)),ro=((e={},t={})=>(t.locale??i())===`zh-TW`?`重試`:`Retry`),io=e=>`A run could not start: ${e?.reason}`,ao=e=>`run 無法啟動:${e?.reason}`,oo=((e,t={})=>(t.locale??i())===`zh-TW`?ao(e):io(e)),so=((e={},t={})=>(t.locale??i())===`zh-TW`?`塔台無法檢查常駐窗格裡有沒有你的程式,所以不在那裡輸入任何東西;窗格空出來後請按重試`:`The tower could not check the standing pane for a program of yours, so it types nothing there; press Retry when it is free`),co=e=>`Parked: ${e?.kind} from ${e?.from}: ${e?.first}`,lo=e=>`已擱置:${e?.kind},來自 ${e?.from}:${e?.first}`,uo=((e,t={})=>(t.locale??i())===`zh-TW`?lo(e):co(e)),fo=e=>`Parked: ${e?.kind}: ${e?.first}`,po=e=>`已擱置:${e?.kind}:${e?.first}`,mo=((e,t={})=>(t.locale??i())===`zh-TW`?po(e):fo(e)),ho=e=>{let t=_(`en`,e?.count,{},!0);return t===`one`?`${e?.count} message queued`:t===`other`?`${e?.count} messages queued`:`tower_queued`},go=e=>`${e?.count} 則排隊中`,_o=((e,t={})=>(t.locale??i())===`zh-TW`?go(e):ho(e)),vo=e=>`ally run · ${e?.device}`,yo=e=>`隊友 run · ${e?.device}`,bo=((e,t={})=>(t.locale??i())===`zh-TW`?yo(e):vo(e)),xo=((e={},t={})=>(t.locale??i())===`zh-TW`?`收工中`:`closing`),So=((e={},t={})=>(t.locale??i())===`zh-TW`?`已暫停`:`held`),Co=((e={},t={})=>(t.locale??i())===`zh-TW`?`喚醒中`:`waking`),wo=e=>`Waits for you: ${e?.text}`,To=e=>`等你決定:${e?.text}`,Eo=((e,t={})=>(t.locale??i())===`zh-TW`?To(e):wo(e)),Do=((e={},t={})=>(t.locale??i())===`zh-TW`?`處理中…`:`Working…`),Oo=((e={},t={})=>(t.locale??i())===`zh-TW`?`有智慧體等你同意,才能載入資料夾的設定`:`An agent needs your OK to load a folder's settings`),ko=((e={},t={})=>(t.locale??i())===`zh-TW`?`連不上伺服器。`:`The server could not be reached.`),Ao=e=>`using ${e?.tool}`,jo=e=>`使用 ${e?.tool}`,Mo=((e,t={})=>(t.locale??i())===`zh-TW`?jo(e):Ao(e)),No=`sb-locale`;function Po(e){let n=/^zh\b/i.test(e)&&(/-(hant|tw|hk|mo)\b/i.test(e)?`zh-TW`:/-(hans|cn|sg|my)\b/i.test(e)?`zh-CN`:void 0);return t(e)??(n?t(n):void 0)??t(e.split(`-`)[0])}function Fo(e,n){return t(e)??n.map(Po).find(Boolean)??`en`}var Io={brand_label:De,tagline:Da,totals_label:Pa,stat_bases:ya,stat_agents:va,stat_working:Sa,stat_waiting:xa,stat_commanding:ba,mark_commanding:gr,alerts:ee,no_alerts:ui,pair_button:Ei,pair_title:Di,server_button:$i,server_title:ea,link_connecting:On,location:Hn,all_bases:te,documents:Vt,timeline:Oa,states:Ca,mark_working:xr,mark_waiting:y,mark_idle:v,mark_done:_r,mark_error:vr,credit:Nt,language:Ut,settings:ta,new_base:ci,link_button:En,link_button_title:Dn};Object.keys(Io);function Lo(){let e=null;try{e=localStorage.getItem(No)}catch{}let t=Fo(e,navigator.languages??[navigator.language]);r(()=>t),document.documentElement.lang=t;let i={m:(e,t)=>e.textContent=t,mLabel:(e,t)=>e.setAttribute(`aria-label`,t),mTitle:(e,t)=>e.title=t,mEmpty:(e,t)=>e.dataset.empty=t};for(let e of document.querySelectorAll(`[data-m], [data-m-label], [data-m-title], [data-m-empty]`))for(let[t,n]of Object.entries(i))e.dataset[t]&&n(e,Io[e.dataset[t]]?.()??e.dataset[t]);let a=document.getElementById(`lang`);a.replaceChildren(...n.map(e=>new Option(Vn({},{locale:e}),e,!1,e===t))),a.onchange=()=>{try{localStorage.setItem(No,a.value),location.reload()}catch{a.value=t}}}var Ro=new Set,zo=e=>e.unit??e.key,Bo=e=>e.mark===`waiting`||e.pending?0:1;function Vo(e,t){let n=new Map;for(let r of e.bases)for(let e of[...r.tower?[{...r.tower,role:`tower`},...r.tower.subs]:[],...[...r.tabs.flatMap(e=>e.units),...r.outside].flatMap(e=>[e,...e.subs])]){n.set(e.key,{key:e.key,ws:r.id,name:e.name,role:e.role,mark:e.mark,note:e.note,at:t,pending:e.pending,closed:!e.control||!!e.ended});for(let i of e.monitors??[])(i.status===`error`||i.status===`stale`)&&(a=>n.set(a,{key:a,unit:e.key,ws:r.id,name:e.name,role:e.role,mark:`error`,note:`monitor:${i.status}:${i.what}`,at:t}))(`${e.key}\u001fmonitor:${i.id}:${i.at}`)}for(let r of e.trust??[])r.opening&&Ro.has(r.opening)||(e=>n.set(e,{key:e,ws:``,name:r.folder.split(/[\\/]/).filter(Boolean).at(-1)??r.folder,role:r.agents[0]?.role??`none`,mark:`waiting`,at:t,trust:r}))(`trust\u001f${r.folder}\u001f${r.digest}`);return n}function Ho(e,t){return[...t.values()].filter(t=>{let n=e?.get(t.key);return Bo(t)===0?!n||Bo(n)!==0||n.mark!==t.mark:e!==void 0&&n?.mark!==t.mark&&(t.mark===`error`||t.mark===`done`)})}var Uo=`input, textarea, select, [role=textbox], [role=combobox], [role=listbox], .term-scroll`,Wo=`button, a, summary, [role=button], [role=link]`,Go=`.ask-opt, [role=radio], [role=checkbox]`,Ko=`dialog.sheet[open], dialog.lightbox[open], [popover]:popover-open`;function qo(e,t,n=!1){if(t||e.defaultPrevented||e.isComposing||e.ctrlKey||e.altKey||e.metaKey)return;let r=e.target;if(!(r?.isContentEditable||r?.closest?.(Uo))){if(e.key===`f`||e.key===`F`)return`zoom`;if(e.key===` `&&!r?.closest?.(Go)&&(n||!r?.closest?.(Wo)))return`next`}}function Jo(e,t=()=>document.querySelector(Ko)!==null,n=window){let r,i=!1,a=null;n.addEventListener(`pointerdown`,()=>i=!0,!0),n.addEventListener(`focusin`,e=>a=i?e.target:null,!0),n.addEventListener(`keydown`,n=>{let o=n.target===a;i=!1;let s=qo(n,t(),o);if(s){if(n.repeat)return r===s?n.preventDefault():void 0;e(s)&&(r=s,n.preventDefault())}}),n.addEventListener(`keyup`,e=>{r===`next`&&e.key===` `&&e.preventDefault(),r=void 0})}var Yo=(...e)=>e.filter(e=>e!==!1&&e!=null),Xo=(e,t)=>(e.classList.add(t),e.classList.toggle(`flip`));function S(e,t,...n){let r=document.createElement(e);for(let[e,n]of Object.entries(t??{}))r.setAttribute(e,n);return r.append(...Yo(...n)),r}var C=e=>String(e??``);function Zo(e){let t=e.data,n=e.teamName;switch(e.kind){case`join-request`:return t.unattended?dn({label:C(t.label),short:C(t.short),team:n}):cn({label:C(t.label),short:C(t.short),team:n});case`confirm`:return t.tower?Kt({label:C(t.label),short:C(t.short),tool:C(t.tool),tower:C(t.tower)}):Yt({label:C(t.label),short:C(t.short),tool:C(t.tool)});case`fork`:return Qt({team:n,reason:C(t.reason)});case`mismatch`:return mn({label:C(t.label),short:C(t.short),team:n});case`unreachable`:return bn({team:n,minutes:C(t.minutes)});case`inbox`:return an({count:Number(t.count)||0,team:n});case`held`:return tn({count:Number(t.count)||0,team:n});case`served`:return _n({count:Number(t.count)||0,team:n})}}var Qo=e=>{let t={error:0,warning:1,info:2};return[...e].sort((e,n)=>t[e.level]-t[n.level])};function $o(e){let t=Math.max(0,Math.ceil(e/1e3)),n=e=>String(e).padStart(2,`0`);return t>=3600?`${Math.floor(t/3600)}:${n(Math.floor(t/60)%60)}:${n(t%60)}`:`${Math.floor(t/60)}:${n(t%60)}`}function es(e,t){if(e===null)return jn();if(t)return Nn();let n=Math.floor(e/1e3);return zn({ago:n<3600?p({n:String(Math.max(1,Math.floor(n/60)))}):n<86400?u({n:String(Math.floor(n/3600))}):s({n:String(Math.floor(n/86400))})})}function ts(e){return e.online?e.tower===`blocked`?`waiting`:e.tower===`working`?`working`:e.tower===`unknown`?`unknown`:`idle`:`unknown`}function ns(e){switch(e){case`working`:return xr();case`blocked`:return y();case`idle`:return v();case`done`:return _r();case`unknown`:return br();default:return e}}var rs=e({get:()=>os,post:()=>w,sendFile:()=>as}),is=()=>document.querySelector(`meta[name="sb-csrf"]`)?.content??``,as=(e,t)=>fetch(`api/${e}`,{method:`POST`,cache:`no-store`,headers:{"content-type":`application/octet-stream`,"x-sb-name":encodeURIComponent(t.name||`pasted`),"x-sb-csrf":is()},body:t}).then(async e=>({ok:e.ok,status:e.status,body:await e.json().catch(()=>({}))})),w=(e,t)=>fetch(`api/${e}`,{method:`POST`,cache:`no-store`,headers:{"content-type":`application/json`,"x-sb-csrf":is()},body:JSON.stringify(t)}).then(async e=>({ok:e.ok,status:e.status,body:await e.json().catch(()=>({}))})),os=e=>fetch(`api/${e}`,{cache:`no-store`}).then(async e=>({ok:e.ok,status:e.status,body:await e.json().catch(()=>({}))})),ss=3e4,cs=[`pointermove`,`pointerdown`,`keydown`,`wheel`,`touchstart`];function ls(e=document.documentElement){if(matchMedia(`(prefers-reduced-motion: reduce)`).matches)return;let t=Date.now(),n,r=()=>{let i=t+ss-Date.now();i>0?n=setTimeout(r,i):(n=void 0,e.toggleAttribute(`data-calm`,!0))},i=()=>{t=Date.now(),n===void 0&&(e.toggleAttribute(`data-calm`,!1),n=setTimeout(r,ss))};for(let e of cs)addEventListener(e,i,{capture:!0,passive:!0});document.addEventListener(`visibilitychange`,()=>document.hidden||i()),i()}var us=e=>e.route.view===`map`?``:e.route.ws;function ds(e,t){for(let n of e?.bases??[]){if(n.tower?.key===t)return{u:{key:t,name:n.tower.name,role:`tower`,mark:n.tower.mark,control:n.tower.control,pending:n.tower.pending,queued:n.tower.queued,monitors:n.tower.monitors,service:n.tower.service,docs:n.tower.docs,docsCut:n.tower.docsCut,subs:n.tower.subs},base:n};for(let[e,r]of[...n.tabs.map(e=>[e.label,e.units]),[void 0,n.outside],[void 0,n.tower?.subs??[]]])for(let i of r){if(i.key===t)return{u:i,base:n,squad:e};let r=i.subs.find(e=>e.key===t);if(r)return{u:r,base:n,squad:e,launcher:i}}}}var fs=e=>e?.u.role===`tower`&&e.base.tower?.key===e.u.key?e.base:void 0,T=(e,t)=>(t?t!==`live`:!e)||!(!e?.ended||e.control);function ps(e,t,n){return n?`readonly`:T(e,t)?t===`recent`||e?.ended?`closed`:`none`:`live`}function ms(e){if(e.route.view!==`session`)return;let t=e.route.key,n=ds(e.net,t),r=n?.u;return{key:t,hit:n,u:r,mk:r?.mark??`unknown`,state:e.info?.state,name:r?.name??e.info?.name??t}}var hs=e=>{try{return decodeURIComponent(e)}catch{return e}},gs=e=>/^\.+$/.test(e)?e.replaceAll(`.`,`%2E`):encodeURIComponent(e);function _s(e){let[t,n]=e.split(`#`)[0].split(`?`),[r,i,a,o]=t.replace(/^\/+|\/+$/g,``).split(`/`).map(hs);if(r!==`w`||!i)return{view:`map`};if(a!==`s`||!o)return{view:`workspace`,ws:i};let s=new URLSearchParams(n).get(`at`);return s?{view:`session`,ws:i,key:o,at:s}:{view:`session`,ws:i,key:o}}var E=e=>e.view===`map`?``:e.view===`workspace`?`w/${gs(e.ws)}`:`w/${gs(e.ws)}/s/${gs(e.key)}${e.at?`?at=${encodeURIComponent(e.at)}`:``}`,vs=e=>e.view===`session`?{view:`workspace`,ws:e.ws}:{view:`map`},ys=e=>e.view===`session`?e.key:e.view===`workspace`?`w:${e.ws}`:null,bs=e=>Math.max(0,e?.depth||0);function xs(e,t=new URL(document.baseURI).pathname){let n=()=>_s(location.pathname.slice(t.length)+location.search),r={route:n,href:e=>E(e)||`./`,go(n){let r=t+E(n);location.pathname+location.search!==r&&history.pushState({depth:bs(history.state)+1},``,r),e(n)}};return addEventListener(`popstate`,()=>e(n())),document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`a[data-route]`);!t||e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey||(e.preventDefault(),t.hasAttribute(`data-back`)&&bs(history.state)>0?history.back():r.go(_s(t.getAttribute(`data-route`))))}),r}function Ss(e,t,n){let r=n?.allyRuns??[],i=JSON.stringify([t,r.map(e=>[e.id,e.label,e.key])]);e.dataset.sig!==i&&(e.dataset.sig=i,e.hidden=!r.length,e.replaceChildren(...r.length>1?[S(`b`,null,ue({count:r.length}))]:[],...r.map(e=>{let n=ie({device:e.label});if(!e.key)return S(`span`,{class:`ally-chip`,title:oe()},n);let r=E({view:`session`,ws:t,key:e.key});return S(`a`,{class:`ally-chip`,href:r||`./`,"data-route":r,title:ae()},n)})))}var Cs=(e,t)=>e.allyRuns.length===1?bo({device:e.allyRuns[0].label},t):e.allyRuns.length>1?ue({count:e.allyRuns.length},t):Wi({},t),ws=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1}),Ts=e=>Math.max(1,Math.round(e.idleMs/6e4)),Es=(e,t)=>e.closing?Ct({},t):(e.idle?Et:kt)({minutes:Ts(e)},t);function Ds(e,t){return{began:e.resumed?St({turns:e.turns},t):e.why?yt({why:e.why},t):gt({},t),...e.why?{why:e.why}:{},now:e.closing?rt({},t):e.idle&&e.idleAt?ht({time:ws(e.idleAt)},t):Mt({minutes:Ts(e)},t),cap:nt({time:ws(e.capAt)},t)}}function Os(e,t){return{title:(e.resumed?lt:ot)({time:ws(e.startedAt)},t),...e.endedAt?{ended:[ft({time:ws(e.endedAt)},t),e.note].filter(Boolean).join(` · `)}:{}}}function ks(e,t,n,r){if(!e)return n(t);switch(e.state){case`held`:return So({},r);case`waking`:return Co({},r);case`closing`:return xo({},r);case`running`:return e.run?.kind===`ally`?Cs(e,r):e.conversation&&t!==`waiting`?Es(e.conversation,r):n(t);case`standing`:return t===`idle`?e.allyRuns.length?Cs(e,r):yr({},r):n(t)}}var As={crashed:e=>Ka({},e),timeout:e=>Ja({},e),quit:e=>qa({},e)};function js(e,t){if(!e||e.run)return;let n=Object.hasOwn(As,e.lastRun?.outcome??``)?As[e.lastRun.outcome](t):void 0;return n&&[n,e.crashes?Ga({count:e.crashes},t):``].filter(Boolean).join(` · `)}var Ms=(e,t,n,r)=>[ks(e,t,n,r),js(e,r)].filter(Boolean).join(` · `),Ns=(e,t)=>e?.queued?_o({count:e.queued},t):void 0,Ps=`A run could not start: `,Fs=`The tower could not check the standing pane for a program of yours, so it types nothing there; press Retry when it is free`,Is=`The standing pane is not at its own shell: a nested shell or a program runs there. Leave it, then press Retry`,Ls=`The tower types nothing in the standing pane: `,Rs=`An event was parked after two runs crashed with it: `;function zs(e,t){return(e.kind===`settings`||e.kind===`start`)&&e.text.startsWith(Ps)?oo({reason:e.text.slice(23)},t):e.kind===`start`&&e.text===Fs?so({},t):e.kind===`start`&&e.text===Is?$a({},t):e.kind===`start`&&e.text.startsWith(Ls)?no({reason:e.text.slice(46)},t):e.kind===`loop`?Qa({},t):e.kind===`late`&&e.text.startsWith(Rs)?Za({what:e.text.slice(52)},t):e.text}function Bs(e,t){return[...(e?.notices??[]).filter(e=>!e.id.startsWith(`parked-`)).map(e=>({id:e.id,level:e.level,text:zs(e,t),actions:e.kind===`loop`||e.kind===`start`&&e.id===`start`?[`retry`]:[]})),...(e?.memory?.bossWaits??[]).map(e=>({id:`wait-${e.id}`,level:`warning`,text:Eo({text:e.text},t),actions:[`answer`]})),...(e?.memory?.proposals??[]).map(n=>({id:`proposal-${n.id}`,level:`warning`,text:Gs(n,t),proposal:n.id,rev:e.memory.rev,actions:[`confirm`,`reject`]})),...e?.memory?.problem?[{id:`memory-unreadable`,level:`warning`,text:e.memory.problem,actions:[]}]:[],...(e?.parked??[]).map(e=>({id:`parked-${e.id}`,level:`warning`,text:e.from?uo({kind:e.kind,from:e.from,first:e.first},t):mo({kind:e.kind,first:e.first},t),event:e.id,actions:[`deliver`,`drop`]}))]}function Vs(e,t){if(!(e.status<400)){if(e.body.reason===`No such parked event`)return Va({},t);if(e.body.reason?.startsWith(`The sb server stands in for no tower`))return Ha({},t)}}async function Hs(e,t,n,r=1200){let i=e.textContent;e.disabled=!0,e.textContent=Do(),t(void 0);try{let e=await n();e.ok?r&&await new Promise(e=>setTimeout(e,r)):t(La({reason:Vs(e)??e.body.reason??e.body.error??String(e.status)}))}catch{t(La({reason:ko()}))}finally{e.disabled=!1,e.textContent=i}}var Us={standing:12,decision:24};function Ws(e){let t=e=>e.state===`resolved`||e.state===`expired`;return{standing:e.filter(e=>e.kind===`standing`),decisions:e.filter(e=>e.kind===`decision`).reverse(),waits:e.filter(e=>e.kind===`wait`).sort((e,n)=>Number(t(e))-Number(t(n)))}}var Gs=(e,t)=>e.op===`retire`?Br({id:e.target??``,text:e.text},t):(e.kind===`standing`?Lr:Pr)({text:e.text},t),Ks=(e,t)=>e.proposals.length?jr({standing:e.standing,decisions:e.decisions,waits:e.waits,proposals:e.proposals.length},t):Or({standing:e.standing,decisions:e.decisions,waits:e.waits},t);function qs(e,t){return[e.kind===`wait`?wr({},t):e.via===`proposal`?Cr({},t):Sr({},t),e.kind===`wait`?e.for===`boss`?Yr({},t):Gr({who:e.on??``},t):void 0,e.state===`answered`?Jr({who:e.on??``},t):e.state===`resolved`?$r({outcome:e.outcome??``},t):e.state===`expired`?Xr({},t):void 0].filter(Boolean).join(` · `)}function Js(e,t){return e.body.error===`rev`?Hr({},t):String(e.body.reason??e.body.error??e.status)}var Ys={retry:ro,deliver:za,drop:Ba,answer:Ra,confirm:Tr,reject:Vr};function Xs(e,t,n,r){let i=Bs(n),a=JSON.stringify([t,i]);e.dataset.sig!==a&&(e.dataset.sig=a,e.replaceChildren(...i.map(e=>{let n=S(`small`,{class:`tnote-fail`,role:`alert`}),i=S(`p`,{class:`tnote ${e.level}`},S(`span`,null,e.text));for(let a of e.actions){if(a===`answer`){let e=r?E({view:`session`,ws:t,key:r}):``,n=S(`a`,{class:`pair-btn`,href:e||`./`,"data-route":e},Ys[a]());n.addEventListener(`click`,()=>document.querySelector(`.composer-root textarea`)?.focus()),i.append(n);continue}let o=S(`button`,{type:`button`,class:`pair-btn`},Ys[a]()),[s,c]=e.proposal&&(a===`confirm`||a===`reject`)?[`memory`,a===`confirm`?{op:`confirm`,proposal:e.proposal,rev:e.rev}:{op:`reject`,proposal:e.proposal}]:[a,e.event?{id:e.event}:{}];o.onclick=()=>void Hs(o,e=>n.textContent=e??``,()=>w(`tower/${encodeURIComponent(t)}/${s}`,c)),i.append(o)}return i.append(n),i})))}var Zs=140;function Qs(e,t){let n=document.createElement(`nav`),r=document.createElement(`div`),i=document.createElement(`i`);[n.className,r.className,i.className,n.hidden]=[`minimap`,`mm-in`,`mm-view`,!0],n.setAttribute(`aria-label`,ei()),n.append(r,i),document.body.append(n);let a=1,o=0,s=()=>{o=0;let t=e.getBoundingClientRect();i.style.transform=`translateY(${Math.round(Math.max(0,-t.top)*a)}px)`,i.style.height=`${Math.round(Math.min(innerHeight-Math.max(0,t.top),t.bottom)*a)}px`,n.classList.toggle(`away`,t.bottom<innerHeight)},c=()=>{let i=e.getBoundingClientRect();n.hidden=e.hidden||i.height<innerHeight*1.05||!matchMedia(`(min-width: 900px) and (hover: hover)`).matches,!n.hidden&&(a=Math.min(Zs/i.width,innerHeight*.4/i.height),Object.assign(n.style,{width:`${Math.round(i.width*a)}px`,height:`${Math.round(i.height*a)}px`}),r.replaceChildren(...[...t.querySelectorAll(`:scope > .base:not(.leaving)`)].map(e=>{let t=e.getBoundingClientRect(),n=document.createElement(`i`);return n.dataset.mark=e.dataset.mark??`idle`,n.style.cssText=`left:${(t.left-i.left)*a}px;top:${(t.top-i.top)*a}px;width:${t.width*a}px;height:${t.height*a}px`,n})),s())};return addEventListener(`scroll`,()=>o||=requestAnimationFrame(s),{passive:!0}),addEventListener(`resize`,c),n.addEventListener(`click`,t=>{let n=e.getBoundingClientRect(),i=(t.clientY-r.getBoundingClientRect().top)/a;scrollTo({top:n.top+scrollY+i-innerHeight/2,behavior:matchMedia(`(prefers-reduced-motion: reduce)`).matches?`auto`:`smooth`})}),c}function $s({x1:e,y1:t,x2:n,y2:r,mid:i},a=64){let o=Array.from({length:201},(a,o)=>{let s=o/200,c=1-s;return[c**3*e+3*c*c*s*i+3*c*s*s*i+s**3*n,c**3*t+3*c*c*s*t+3*c*s*s*r+s**3*r]}),s=o.reduce((e,t,n)=>(e.push(n?e[n-1]+Math.hypot(t[0]-o[n-1][0],t[1]-o[n-1][1]):0),e),[]);return Array.from({length:a+1},(e,t)=>{let n=t/a*s.at(-1),r=Math.max(1,s.findIndex(e=>e>=n)),[i,c]=[o[r-1],o[r]],l=s[r]>s[r-1]?(n-s[r-1])/(s[r]-s[r-1]):0;return[i[0]+(c[0]-i[0])*l,i[1]+(c[1]-i[1])*l]})}function ec(e,t){if(t||!e.length)return[];let n=document.createElement(`style`);return n.textContent=e.map((e,t)=>`@keyframes pk${t}{${$s(e).map(([e,t],n,r)=>`${(n/(r.length-1)*100).toFixed(2)}%{transform:translate(${e.toFixed(1)}px,${t.toFixed(1)}px)}`).join(``)}}`).join(``),[n,...e.map((e,t)=>(e=>(e.className=`packet`,e.style.animationName=`pk${t}`,e))(document.createElement(`i`)))]}var tc=typeof document<`u`&&typeof document.querySelector==`function`&&((e=document)=>e.querySelector(`meta[name="sb-desk"]`)?.content===`1`)(),nc=(e,t=tc)=>t||e!==`127.0.0.1`,rc=(function(){let e=typeof document<`u`&&document.createElement(`link`).relList;return e&&e.supports&&e.supports(`modulepreload`)?`modulepreload`:`preload`})(),ic=function(e,t){return new URL(e,t).href},ac={},oc=function(e){return e.pathname.endsWith(`.css`)},sc=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},D=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=ic(t,n);let r=s(t),i=oc(r);return sc(ac,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:rc,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function O(e,t,n,r,i=!1){Object.assign(e.dataset,t),[e.hidden,e.textContent]=[i,n],r&&e.setAttribute(`aria-label`,r)}var cc=(e,t)=>t.role===`subagent`&&t.ended&&t.key?O(e,{close:`dismiss`,key:t.key,name:t.name,role:t.role},Pt(),Bt({name:t.name})):O(e,{close:`unit`,key:t.key??``,name:t.name,role:t.role},Pi(),qe({name:t.name}),!(t.control&&t.key)||t.role===`subagent`),lc=(e,t)=>O(e,{key:t?.key??``,name:t?.name??``,role:`tower`},Fi(),void 0,!t?.control);function uc(e,t){e.dataset.close=`unit`,t?.u.role===`tower`&&t.base.tower?.key===t.u.key?lc(e,t.base.tower):t&&cc(e,t.u),e.hidden=!t||e.dataset.close!==`unit`||e.hidden}var dc=(e,t)=>O(e,{ws:t.id,name:t.label},Pi(),Me({name:t.label})),fc=(e,t,n=tc)=>O(e,{ws:t.id,name:t.label},ca(),da({name:t.label}),n),pc=(e,t,n)=>O(e,{ws:t.id,name:n.label,tab:n.id},Pi(),Re({name:n.label})),k=(e,t)=>new Promise(n=>{let r=document.createElement(`dialog`),i=document.createElement(`p`),a=document.createElement(`div`),o=(e,t,i)=>Object.assign(document.createElement(`button`),{type:`button`,className:t,textContent:e,onclick:()=>(r.close(),n(i))});[r.className,i.textContent,a.className]=[`sheet`,e,`sheet-row`],a.append(...t?[o(Oe(),`later`,!1),o(t,`sheet-yes`,!0)]:[o(ke(),`later`,!1)]),r.append(i,a),r.addEventListener(`close`,()=>(r.remove(),n(!1))),document.body.append(r),r.showModal()}),mc=e=>e.bases.flatMap(e=>[...e.tower?[e.tower]:[],...e.tabs.flatMap(e=>e.units),...e.outside]).flatMap(e=>e.subs).filter(e=>e.ended).map(e=>e.key);function hc(e,t){let n=mc(t).length;e.hidden=!n,n&&(e.textContent=Lt({count:n}))}function gc(e,t,n,r=tc){if(r)return void(e.hidden=!0);let i=n.stashed??[],a=JSON.stringify(i);e.hidden=!i.length;let o=t.closest(`[popover]`);!i.length&&o?.matches(`:popover-open`)&&o.hidePopover(),i.length&&(e.textContent=_a({count:i.length})),t.dataset.key!==a&&(t.dataset.key=a,t.replaceChildren(...i.map(e=>{let t=document.createElement(`li`),n=document.createElement(`span`),r=document.createElement(`button`);return n.textContent=e.name===e.label?e.label:`${e.name} (${e.label})`,[r.type,r.className]=[`button`,`pair-btn`],O(r,{close:`pop`,name:e.name},Oi(),ji({name:e.name})),t.append(n,r),t})))}var _c=e=>D(async()=>{let{post:e}=await Promise.resolve().then(()=>rs);return{post:e}},void 0,import.meta.url).then(({post:t})=>t(`dismiss`,e)).then(e=>e.ok||(k(e.body.reason??x({status:e.status})),!1),()=>(k(b()),!1));function vc(e,{route:t,net:n,go:r}){let i=t();if(i.view===`map`)return;if(e.close===`base`||e.close===`stash`)return void(i.ws===e.ws&&r({view:`map`}));let a=e=>e.flatMap(e=>[e.key,...a(e.subs)]),o=e.close===`tab`&&i.ws===e.ws?n()?.bases.find(t=>t.id===e.ws)?.tabs.find(t=>t.id===e.tab):void 0;i.view===`session`&&(e.close===`unit`?i.key===e.key:o&&a(o.units).includes(i.key))&&r({view:`workspace`,ws:i.ws})}function yc(e){document.addEventListener(`click`,t=>{let n=t.target?.closest?.(`button[data-close]`),r=n?.dataset;if(n&&r){if(t.preventDefault(),r.close===`dismiss`||r.close===`dismiss-all`)return void _c(r.close===`dismiss`?{key:r.key}:{all:!0});if(r.close===`pop`)return void(n.toggleAttribute(`disabled`,!0),Promise.all([D(()=>Promise.resolve().then(()=>rs),void 0,import.meta.url),D(()=>import(`./refusal--wJ5SRx-.js`).then(e=>e.n),[],import.meta.url)]).then(([{post:e},{reasonOf:t}])=>e(`close/pop`,{name:r.name}).then(e=>e.ok||k(t(e.body.reason,e.body.settings)??x({status:e.status})))).catch(()=>k(b())).finally(()=>n.toggleAttribute(`disabled`,!1)));k((r.close===`stash`?ma:r.close===`base`?Fe:r.close===`tab`?Ve:r.role===`tower`?We:Xe)({name:r.name??``}),r.close===`stash`?ca():Pi()).then(t=>{t&&(n.toggleAttribute(`disabled`,!0),D(async()=>{let{post:e}=await Promise.resolve().then(()=>rs);return{post:e}},void 0,import.meta.url).then(({post:e})=>e(`close/${r.close===`base`?`all`:r.close}`,r.close===`unit`?{key:r.key}:{workspace:r.ws,...r.tab&&{tab:r.tab}})).then(t=>t.ok?vc(r,e):k(t.body.reason??x({status:t.status})),()=>k(b())).finally(()=>n.toggleAttribute(`disabled`,!1)))})}})}var bc={main:`main`,member:`member`,subagent:`subagent`,outpost:`outpost`,outside:`outside`,tower:`tower`,ally:`tower`,run:`tower`},A={commanding:gr,working:xr,waiting:y,idle:v,done:_r,error:vr,unknown:br},xc={ally:Wi,run:Yi,main:Gi,member:Ki,subagent:Zi,tower:Qi,outpost:qi,outside:Ji,session:Xi},Sc={thinking:pi,"watching a monitor":fi,idle:v,"waiting on a question":y,finished:_r},Cc={claude:`Claude`,codex:`Codex`},wc=e=>Object.hasOwn(xc,e)?xc[e]():e,Tc=e=>e===`waiting`||e===`error`,j=e=>{let t=new DOMParser().parseFromString(e.trim(),`text/html`).body.firstElementChild;if(!(t instanceof HTMLElement))throw Error(`bad template`);return document.importNode(t,!0)},M=(e,t)=>{let n=document.getElementById(e);if(!(n instanceof t))throw Error(`#${e} is missing from the page`);return n},N=(e,t,n)=>{let r=e.querySelector(t);r.textContent!==n&&(r.textContent=n)},P=(e,t)=>{if(e.dataset.mark===t)return;let n=e.dataset.mark!==void 0;e.dataset.mark=t,n&&Xo(e,`flash`)},Ec=e=>(t=>(e.slice(8,t)===`stale`?oi:ri)({what:e.slice(t+1)}))(e.indexOf(`:`,8)),F=(e,t)=>e?e.startsWith(`tool:`)?Mo({tool:e.slice(5)}):e.startsWith(`monitor:`)?Ec(e):Object.hasOwn(Sc,e)?Sc[e]():e:A[t](),Dc=(e,t,n)=>T(e,t)?``:n===`working`||n===`commanding`?F(e?.note,n):Tc(n)?A[n]():``,Oc=(e,t,n)=>T(e,t)&&(n===`working`||n===`commanding`)?`done`:n,kc=(e,t,n,r,i=F(n,r))=>{N(e,t,i),e.querySelector(t).toggleAttribute(`data-monitoring`,i===F(n,r)&&n===`watching a monitor`)},I=(e,t)=>{e.toggleAttribute(`hidden`,!t),t&&(e.setAttribute(`href`,E(t)||`./`),e.setAttribute(`data-route`,E(t)))},L=(e,t)=>{let n=t.getBoundingClientRect(),r=e.offsetWidth;e.style.top=`${n.bottom+8}px`,e.style.left=`${Math.max(8,Math.min(n.right-r,innerWidth-r-8))}px`},Ac=`<div class="plate"><i class="ring"></i><svg><use href="#i-main"/></svg><b class="badge"></b></div>`;function jc(e,t,n,r){P(e,n);let i=e.querySelector(`use`),a=`#i-${bc[t]??`member`}`,o=r?.filter(e=>e.onScreen).length;i.getAttribute(`href`)!==a&&i.setAttribute(`href`,a),o?e.dataset.docs=String(o):delete e.dataset.docs}function R(e,t,n,r){let i=new Map;for(let t of e.children)!t.classList.contains(`leaving`)&&t.dataset.key&&i.set(t.dataset.key,t);let a=e.firstElementChild;for(let o of t){let t=i.get(o.id);for(t||(t=n(o),t.dataset.key=o.id,t.classList.add(`enter`),setTimeout(()=>t.classList.remove(`enter`),600)),i.delete(o.id);a?.classList.contains(`leaving`);)a=a.nextElementSibling;t===a?a=a.nextElementSibling:e.insertBefore(t,a),r(t,o)}for(let e of i.values())e.classList.add(`leaving`),setTimeout(()=>e.remove(),400)}var Mc=(e,t=Math.max(0,Date.now()-e)/1e3)=>t<60?g({n:String(Math.floor(t))}):t<3600?p({n:String(Math.floor(t/60))}):t<86400?u({n:String(Math.floor(t/3600))}):s({n:String(Math.floor(t/86400))}),Nc=(e,t)=>(t===void 0?delete e.dataset.since:e.dataset.since=String(t),e.textContent=t===void 0?``:Mc(t));function Pc(e,t=[]){let n=e.querySelector(`:scope > .ticks`),r=t.map(e=>`${e.at}${e.mark}`).join();n.dataset.sig!==r&&(n.dataset.sig=r,e.classList.toggle(`ticked`,t.length>0),n.replaceChildren(...t.map((e,n)=>{let r=document.createElement(`i`);return r.dataset.mark=e.mark,r.style.setProperty(`--o`,((n+1)/t.length).toFixed(2)),r})))}var z=()=>j(`<div class="unit"><div class="card"><a class="hit"></a>${Ac}<div class="meta"><span class="name"></span><span class="line"><em class="role"></em><em class="agent"></em><span class="note"></span><span class="age"></span></span><span class="todo" hidden><b></b><span></span></span></div><button type="button" class="quit-btn" data-close="unit" hidden></button><span class="ticks" aria-hidden="true"></span></div><div class="subs"></div></div>`);function B(e,t){let n=e.closest(`.base`)?.dataset.key,r=e.querySelector(`.hit`),i=Oc(t,void 0,t.mark),a=T(t)?void 0:t.note;I(r,t.key&&n?{view:`session`,ws:n,key:t.key}:void 0),r.setAttribute(`aria-label`,`${t.name}: ${F(a,i)}`),r.toggleAttribute(`data-alert`,Tc(i)),P(e,i),jc(e.querySelector(`.plate`),t.role,i,t.docs),N(e,`.name`,t.name),N(e,`.role`,wc(t.role)),N(e,`.agent`,t.agent?Cc[t.agent]:``),kc(e,`.note`,a,i),Nc(e.querySelector(`:scope > .card .age`),t.since);let o=e.querySelector(`:scope > .card .todo`);o.hidden=!t.todo,t.todo&&(N(o,`b`,`${t.todo.done<t.todo.total?`◐`:`✓`} ${t.todo.done}/${t.todo.total}`),N(o,`span`,t.todo.now??``)),Pc(e.querySelector(`:scope > .card`),t.ticks),cc(e.querySelector(`:scope > .card > .quit-btn`),t),R(e.querySelector(`.subs`),t.subs??[],z,B)}function Fc(e,t,n){let r=t.tower?`main`:`member`;e.hidden=!!(n&&t.tower),e.dataset.open=r,e.dataset.ws=t.id,n&&(e.dataset.tab=n),e.textContent!==(r===`main`?Ci():wi())&&(e.textContent=r===`main`?Ci():wi())}var Ic=()=>j(`<section class="base"><header><div class="tower"><i class="sweep"></i><i class="pulse"></i><svg><use href="#i-tower"/></svg><b class="badge"></b></div><div class="title"><span class="crown"><svg><use href="#i-crown"/></svg>${Ht()}</span><h2><a class="enter-base"></a></h2><p><span class="tstate"></span><span class="tqueue"></span><span class="age"></span></p><div class="allies" hidden></div><button type="button" class="quit-btn tower-quit" data-close="unit" hidden></button></div><button type="button" class="quit-btn" data-close="base"></button></header><div class="subs tower-subs"></div><div class="tower-notices"></div><div class="spawn-btns"><button type="button" class="pair-btn"></button><button type="button" class="pair-btn" data-close="stash"></button></div><div class="tabs"></div><div class="outposts" data-label="${Ti()}"></div></section>`),Lc=e=>Ms(e.service,e.mark,e=>A[e]());function Rc(e,t){P(e,t.mark),e.classList.toggle(`head`,t.head);let n=e.querySelector(`.tower`);n.classList.toggle(`ghost`,!t.tower),P(n,t.tower?.mark??`unknown`),N(e,`h2 a`,t.label),I(e.querySelector(`h2 a`),{view:`workspace`,ws:t.id}),N(e,`.title .tstate`,t.tower?$e({state:Lc(t.tower)}):di()),N(e,`.title .tqueue`,Ns(t.tower?.service)??``),Nc(e.querySelector(`.title .age`),t.tower?.since),Fc(e.querySelector(`.spawn-btns button`),t),dc(e.querySelector(`header > .quit-btn`),t),fc(e.querySelector(`.spawn-btns [data-close=stash]`),t),lc(e.querySelector(`.tower-quit`),t.tower),R(e.querySelector(`.tower-subs`),t.tower?.subs??[],z,B),Ss(e.querySelector(`.title .allies`),t.id,t.tower?.service),Xs(e.querySelector(`.tower-notices`),t.id,t.tower?.service,t.tower?.key),R(e.querySelector(`.tabs`),t.tabs,()=>j(`<div class="tab"><h3><span></span><button type="button" class="tab-add"></button><button type="button" class="quit-btn" data-close="tab"></button></h3><div class="units"></div></div>`),(e,n)=>{N(e,`h3 span`,Ea({label:n.label})),pc(e.querySelector(`.quit-btn`),t,n),Fc(e.querySelector(`.tab-add`),t,n.id),R(e.querySelector(`.units`),n.units,z,B)}),R(e.querySelector(`.outposts`),t.outposts.map(e=>({id:e.id,name:e.label,role:`outpost`,mark:e.mark,note:e.mark===`unknown`?li():void 0,since:e.since,ticks:e.ticks})),z,B)}var zc=()=>j(`<section class="base ally"><header><div class="tower"><i class="pulse"></i><svg><use href="#i-tower"/></svg><b class="badge"></b></div><div class="title"><span class="crown"><svg><use href="#i-main"/></svg><em class="ally-tag"></em></span><h2></h2><p><span class="tstate"></span></p></div></header><ul class="ally-tabs"></ul></section>`);function Bc(e,t){let n=ts(t);P(e,n),e.classList.toggle(`offline`,!t.online),P(e.querySelector(`.tower`),n),N(e,`.ally-tag`,pe({team:t.teamName})),N(e,`h2`,t.workspace??t.label),N(e,`.tstate`,`${t.workspace?`${t.label} · `:``}${t.short} · ${t.online?ns(t.tower):Mn()}`),R(e.querySelector(`.ally-tabs`),t.tabs.map((e,t)=>({id:`${t}`,...e})),()=>j(`<li class="ally-tab"><b></b><span></span></li>`),(e,n)=>{N(e,`b`,n.label),N(e,`span`,t.online?ns(n.state):``),e.dataset.state=n.state})}function Vc(e,t,n,r){let i=[...e.querySelectorAll(`.base:not(.leaving):not(.ally) .tower`)],a=e.querySelector(`.base.head:not(.leaving) .tower`),o=e.getBoundingClientRect(),s=e=>{let t=e.getBoundingClientRect();return[Math.round(t.x+t.width/2-o.x),Math.round(t.y+t.height/2-o.y)]},c=a?i.filter(e=>e!==a):[],l=c.map(e=>{let[[t,n],[r,i]]=[s(a),s(e)];return{x1:t,y1:n,x2:r,y2:i,mid:Math.round((t+r)/2)}}),u=l.map(({x1:e,y1:t,x2:n,y2:r,mid:i})=>`M${e} ${t}C${i} ${t} ${i} ${r} ${n} ${r}`),d=u.join(`|`);t.dataset.sig!==d&&(t.dataset.sig=d,t.replaceChildren(...u.map(e=>(t=>(t.setAttribute(`class`,`wire`),t.setAttribute(`d`,e),t))(document.createElementNS(`http://www.w3.org/2000/svg`,`path`)))),n.replaceChildren(...ec(l,r))),n.querySelectorAll(`.packet`).forEach((e,t)=>e.toggleAttribute(`data-live`,[`working`,`commanding`].includes(a.dataset.mark??``)||[`working`,`commanding`].includes(c[t].dataset.mark??``)))}var Hc=2,Uc=20;function Wc(){let[e,t,n,r]=[M(`map`,HTMLElement),M(`bases`,HTMLElement),M(`links`,SVGSVGElement),M(`packets`,HTMLElement)],i=matchMedia(`(prefers-reduced-motion: reduce)`).matches,a=new Set,o=Qs(e,t),s=()=>(o(),!e.hidden&&Vc(e,n,r,i)),c=0,l=()=>c||=requestAnimationFrame(()=>(c=0,s())),u=new ResizeObserver(e=>(e.forEach(({target:e,borderBoxSize:t})=>e.style.gridRowEnd=`span ${Math.ceil((t[0].blockSize+Uc)/Hc)}`),l()));return setInterval(()=>document.querySelectorAll(`.age[data-since]`).forEach(e=>Nc(e,Number(e.dataset.since))),15e3),addEventListener(`resize`,l),new ResizeObserver(([e])=>document.documentElement.style.setProperty(`--hud`,`${Math.ceil(e.borderBoxSize[0].blockSize)}px`)).observe(document.querySelector(`.hud`)),ls(),{layout:s,stats(e){let t=e.bases.flatMap(e=>[...e.tower?.subs??[],...e.tabs.flatMap(e=>e.units.flatMap(e=>[e,...e.subs]))]),n=e=>String(t.filter(t=>!e||t.mark===e).length);M(`s-commanding`,HTMLElement).parentElement.toggleAttribute(`data-on`,t.some(e=>e.mark===`commanding`));for(let[t,r]of[[`s-bases`,String(e.bases.length)],[`s-agents`,n()],[`s-working`,n(`working`)],[`s-commanding`,n(`commanding`)],[`s-waiting`,n(`waiting`)]])M(t,HTMLElement).textContent=r},show(e){let n=(e.link?.allies??[]).map(e=>({...e,id:`ally/${e.id}`,ally:!0}));R(t,[...e.bases,...n],e=>`ally`in e?zc():Ic(),(e,t)=>`ally`in t?Bc(e,t):Rc(e,t));for(let e of t.children)a.has(e)||(a.add(e),u.observe(e));for(let e of a)e.isConnected||(a.delete(e),u.unobserve(e));requestAnimationFrame(s)},pause(e){document.documentElement.classList.toggle(`paused`,e)}}}function Gc(e,t){let n=M(`link-alerts`,HTMLButtonElement),r=M(`link-alerts-pop`,HTMLElement),i=M(`link-alerts-list`,HTMLElement),a=``,o=new Set,s=!0;r.addEventListener(`toggle`,e=>e.newState===`open`&&L(r,n)),r.setAttribute(`aria-label`,wn()),n.title=wn();let c=(e,t,n)=>{let r=n.querySelector(`.link-note`);for(let e of n.querySelectorAll(`button`))e.disabled=!0;w(`link/confirm-answer`,{dialogId:e.dialogId,allow:t}).then(e=>{e.ok||(r.textContent=e.body.reason??x({status:e.status}));for(let e of n.querySelectorAll(`button`))e.disabled=!1},()=>{r.textContent=b();for(let e of n.querySelectorAll(`button`))e.disabled=!1})},l=e=>{let t=S(`li`,{class:`link-alert`,"data-level":`warning`}),n=S(`button`,{type:`button`,class:`pair-btn`},Tn()),r=S(`button`,{type:`button`,class:`pair-btn`},kn());return n.onclick=()=>c(e,!0,t),r.onclick=()=>c(e,!1,t),t.append(S(`b`,null,Zo({id:``,kind:`confirm`,level:`warning`,team:e.team,teamName:``,data:{label:e.fromLabel,short:e.fromShort,tool:e.tool,tower:e.tower}})),S(`pre`,{class:`link-args`},e.args),S(`div`,{class:`devices-acts`},n,r),S(`small`,{class:`link-note`,role:`status`})),t};return{net(c){let u=Qo((c?.alerts??[]).filter(e=>e.kind!==`confirm`)),d=c?.confirms??[],f=JSON.stringify([u,d]);if(f===a)return;a=f;let p=new Set([...d.map(e=>`c/${e.dialogId}`),...u.filter(e=>e.kind===`join-request`).map(e=>e.id)]);s||t([...p].filter(e=>!o.has(e)).length),[o,s]=[p,!1];let m=u.length+d.length;n.hidden=m===0,n.textContent=Cn({count:String(m)}),n.dataset.state=d.length||u.some(e=>e.level===`error`)?`error`:u.some(e=>e.level===`warning`)?`waiting`:`done`,!m&&r.matches(`:popover-open`)&&r.hidePopover(),i.replaceChildren(...Yo(...d.map(l),...u.map(t=>{let n=S(`li`,{class:`link-alert`,"data-level":t.level},S(`span`,null,Zo(t)));if(t.kind===`join-request`||t.kind===`fork`||t.kind===`mismatch`){let i=S(`button`,{type:`button`,class:`later`},t.kind===`join-request`?In():Pn());i.onclick=()=>(r.hidePopover(),e()),n.append(i)}if(t.kind===`served`){let e=S(`a`,{class:`later`,href:`./`,"data-route":``},Bn());e.onclick=()=>r.hidePopover(),n.append(e)}return n})))}}}var Kc=new URL(`done-jqKY4qf5.mp3`,import.meta.url).href,qc=new URL(`error-DdTLgPEw.mp3`,import.meta.url).href,Jc={waiting:new URL(`waiting-DOg8-8gu.mp3`,import.meta.url).href,error:qc,done:Kc},Yc=e=>e.mark===`waiting`||e.pending?`waiting`:e.mark===`error`?`error`:e.mark===`done`?`done`:void 0,Xc=(e,t)=>{try{return localStorage.getItem(e)??t}catch{return t}},Zc=(e,t)=>{try{localStorage.setItem(e,t)}catch{}};function Qc(e){let t=e=>document.getElementById(e),n=t(`remind`),r=t(`sound`),i=t(`sound-pop`),a=t(`sound-on`),o=t(`sound-vol`),s=t(`sound-vol-out`),c=typeof Notification<`u`,l=Xc(`sb.remind`,`1`)===`1`,u=Xc(`sb.sound`,`0`)===`1`,d=Math.min(100,Math.max(0,Number(Xc(`sb.volume`,`60`))||0)),f,p,m=new Map,h=()=>{let e=c?Notification.permission:`denied`;n.setAttribute(`aria-pressed`,String(l)),n.dataset.state=l?e===`granted`?`on`:e===`denied`?`blocked`:`ask`:`off`,n.title=c?l?e===`granted`?Hi():e===`denied`?Bi():zi():Vi():Ui(),r.dataset.state=u?`on`:`off`,r.setAttribute(`aria-label`,u?ia():ra()),a.checked=u,o.value=s.value=String(d),p&&(p.gain.value=(d/100)**2)};n.textContent=Ri(),r.textContent=na(),r.title=aa(),t(`sound-on-label`).textContent=na(),t(`sound-vol-label`).textContent=sa(),t(`sound-try`).textContent=oa(),n.onclick=async()=>{l&&c&&Notification.permission==="default"?await Notification.requestPermission().catch(()=>{}):Zc(`sb.remind`,(l=!l)?`1`:`0`),h()},i.addEventListener(`toggle`,e=>e.newState===`open`&&L(i,r)),a.onchange=()=>{Zc(`sb.sound`,(u=a.checked)?`1`:`0`),h(),u&&g(`done`)},o.oninput=()=>(Zc(`sb.volume`,String(d=Number(o.value))),h()),o.onchange=()=>g(`done`),t(`sound-try`).onclick=()=>g(`done`);function g(e){f??=new AudioContext,p||((p=f.createGain()).connect(f.destination),h());let t=f,n=p;m.has(e)||m.set(e,fetch(Jc[e]).then(e=>e.arrayBuffer()).then(e=>t.decodeAudioData(e))),Promise.all([t.resume(),m.get(e)]).then(([,e])=>{let r=t.createBufferSource();r.buffer=e,r.connect(n),r.start()}).catch(()=>m.delete(e))}return h(),{chime:()=>u&&g(`done`),signal(t){let n=t.flatMap(e=>(t=>t?[{a:e,k:t}]:[])(Yc(e)));if(n.length&&(u&&g([`waiting`,`error`,`done`].find(e=>n.some(t=>t.k===e))),l&&c&&Notification.permission===`granted`&&(document.hidden||!document.hasFocus())))for(let{a:t,k:r}of n){let n=new Notification(t.name,{body:t.trust?Oo():{waiting:Si,error:yi,done:gi}[r]({note:t.note??``}).trim(),tag:t.key,icon:document.querySelector(`link[rel="icon"]`)?.href,silent:r!==`waiting`});n.onclick=()=>(window.focus(),n.close(),e(t))}}}}var $c=45e3,el=1e3,tl=3e4,nl=(e,t)=>Math.min(tl,el*2**(e-1))*(.8+.4*t);function rl(e){try{return JSON.parse(e)}catch{return}}function il(e){let t,n,r,i=0,a={state:`connecting`,attempt:0},o=t=>e.onStatus(a={...a,...t}),s=()=>(e.clearTimeout(n),e.clearTimeout(r),n=r=void 0),c=()=>{let e=t;t=void 0,e?.close()},l=()=>{e.clearTimeout(r),r=e.setTimeout(()=>u(),$c),o({state:`live`,attempt:0,lastContact:e.now()})},u=()=>{c(),s();let t=a.attempt+1;if(t>8)return o({state:`offline`,attempt:t});o({state:`reconnecting`,attempt:t}),e.hidden()||(n=e.setTimeout(d,nl(t,e.random())))},d=()=>{c(),s(),i=e.now();let n=t=e.open();n.onError(()=>{t===n&&(u(),e.replaced?.().then(e=>{e&&a.state!==`live`&&a.state!==`replaced`&&(c(),s(),o({state:`replaced`}))},()=>{}))}),n.listen(`message`,r=>{if(t!==n)return;let i=rl(r);i&&e.onNet(i),o({problem:i?void 0:Mi()}),l()}),n.listen(`ping`,()=>t===n&&l()),n.listen(`problem`,e=>{t===n&&(o({problem:rl(e)??Ni()}),l())}),r=e.setTimeout(()=>u(),$c)};return{start(){o({state:`connecting`,attempt:0}),d()},resume(){if(a.state===`replaced`)return;let n=e.now()-i<2e3||a.lastContact!==void 0&&e.now()-a.lastContact<=2e4;t&&n||(o({attempt:0,state:a.state===`live`?`reconnecting`:a.state}),d())},restart:d,hide(){e.clearTimeout(n),n=void 0},stop(){c(),s()}}}var al={commanding:Gn,working:hr,waiting:fr,idle:er,done:Jn,error:Zn,unknown:lr},ol=e=>(e.kind===`joined`?rr:e.kind===`left`?or:al[e.mark])({name:e.name}),sl=18e5,cl={waiting:0,error:0,working:1,commanding:1},ll=e=>new Date(e).toLocaleTimeString([],{hour12:!1});function ul(e){let[t,n,r,i,a]=[`.tl-lanes`,`.tl-axis`,`.tl-at`,`.tl-last`,`.tl-span`].map(t=>e.querySelector(t)),o=[],s=``;matchMedia(`(max-width: 640px)`).matches&&(e.open=!1);let c=()=>{let e=Date.now()-sl,s=o.filter(t=>t.at>=e),c=s.at(-1);t.replaceChildren(...s.map(t=>{let n=document.createElement(`a`),r=(t.at-e)/sl*100;return n.className=`tl-mark ${t.kind}${r>70?` end`:``}`,n.dataset.mark=t.kind===`left`?`unknown`:t.mark,n.style.cssText=`left:${r.toFixed(2)}%;top:${(cl[t.mark]??2)*14+4}px`,n.setAttribute(`aria-label`,`${ll(t.at)} ${ol(t)}`),I(n,t.key&&t.kind!==`left`?{view:`session`,ws:t.ws,key:t.key}:{view:`workspace`,ws:t.ws}),n})),n.replaceChildren(...[0,10,20].map(t=>Object.assign(document.createElement(`span`),{textContent:ll(e+t*6e4).slice(0,5)})),Object.assign(document.createElement(`span`),{textContent:Aa()})),r.textContent=c?ll(c.at):``,i.textContent=c?ol(c):ka(),a.textContent=Na({count:String(s.length)})};return setInterval(c,3e4),c(),{net(e){let t=e.events??[],n=t.map(e=>`${e.at}${e.kind}${e.key??e.name}${e.mark}`).join();n!==s&&(s=n,o=t,c())}}}Lo();var V=Wc(),dl=ul(document.getElementById(`timeline`)),H=e=>document.getElementById(e),fl=e=>e?new Date(e).toLocaleTimeString([],{hour12:!1}):si(),pl,U,W,ml={state:`connecting`,attempt:0},G={view:`map`},hl=!1,gl,_l=``,K,vl,yl=e=>K?e(K):void vl?.then(e);function bl(){vl??=D(async()=>{let{mountFocus:e}=await import(`./views-DZXa6Ete.js`);return{mountFocus:e}},[],import.meta.url).then(({mountFocus:e})=>(K=e({data:Il,restart:()=>Q.restart(),openTile:Y,embedTerminal:(e,t,n)=>new Promise(r=>J(i=>r(i.terminal.embed(e,t,n)))),online:()=>ml.state===`live`}),K.show(G,G),U&&K.net(U),K))}var q,xl,J=e=>{if(q)return e(q);xl??=D(async()=>{let{mountPanels:e}=await import(`./layer-BBxY5qmM.js`);return{mountPanels:e}},[],import.meta.url).then(({mountPanels:e})=>q=e({label:e=>U?.bases.find(t=>t.id===e)?.label??e,recent:async e=>(await(Fl?Fl.data(e).latest():Pl(e,`?limit=12`))).items,post:e=>Fl&&((t,n)=>Fl.data(e).post(t,n)),stream:()=>_l,showTerminal:(e,t)=>(q?.stack.close(),K?.terminal(t),Z.go({view:`session`,ws:e,key:t}))})),xl.then(e)},Y=(e,t)=>J(n=>n.tiles.open(e,t)),X=document.querySelector(`link[rel="icon"]`),Sl=X&&decodeURIComponent(X.href.slice(X.href.indexOf(`,`)+1)),Cl=0;function wl(e){let t=e.bases.flatMap(e=>[...e.tower?[e.tower,...e.tower.subs]:[],...[...e.tabs.flatMap(e=>e.units),...e.outside].flatMap(e=>[e,...e.subs])]).filter(e=>e.mark===`waiting`||e.pending).length+(e.trust?.length??0);if(!X||!Sl||t===Cl)return;Cl=t;let n=`<circle cx='23' cy='9' r='9' fill='#e0af68' stroke='#1a1b26' stroke-width='2'/><text x='23' y='13' text-anchor='middle' font-family='sans-serif' font-size='${t>9?9:12}' font-weight='700' fill='#16161e'>${t>9?`9+`:t}</text>`;X.href=`data:image/svg+xml,${encodeURIComponent(t?Sl.replace(`</svg>`,`${n}</svg>`):Sl)}`}var Tl;function El(e){U=W=e,wl(e),zl.net(e.link);let t=Vo(e,Date.now());if(Tl&&Bl.signal(Ho(Tl,t)),Tl=t,document.hidden)return;V.stats(e),hc(H(`dismiss-all`),e),gc(H(`stashed`),H(`stashed-list`),e),$?.net(e);let n=Ho(gl,t);(n.length||q)&&J(e=>e.alerts(n,t)),gl=t,dl.net(e),yl(t=>t.net(e)),G.view===`map`&&(V.show(e),pl=e,W=void 0)}function Dl(e){let t=G,n=e.view===`workspace`&&t.view===`map`?document.querySelector(`#bases [data-key="${CSS.escape(e.ws)}"]`)?.getBoundingClientRect():void 0;G=e,$?.route(e),e.view!==`map`&&bl(),H(`map`).hidden=e.view!==`map`,H(`legend`).hidden=e.view===`session`,H(`stage`).dataset.view=e.view,yl(r=>r.show(e,t,n)),e.view===`map`&&U&&U!==pl&&(El(U),requestAnimationFrame(V.layout)),hl&&ys(e)!==ys(t)&&Q.restart()}function Ol(e){ml=e;let t=e.state===`reconnecting`||e.state===`offline`||e.state===`replaced`;document.body.dataset.stale=H(`stage`).dataset.stale=String(t),H(`link`).dataset.state=e.state,H(`link-text`).textContent={connecting:On,live:An,reconnecting:Fn,offline:Mn,replaced:Mn}[e.state](),K&&U&&K.net(U),q?.stack.redraw();let n=H(`banner`);n.hidden=!t&&!e.problem;let r=e.state===`replaced`?Ee():e.state===`offline`?ve({tries:e.attempt-1}):e.state===`reconnecting`?e.attempt?Te({attempt:e.attempt}):Se():xe({problem:e.problem??``}),i=document.createElement(`b`);i.textContent=fl(e.lastContact),n.replaceChildren(`${r} ${he()} `,i,me())}function kl(e,t){try{let n=JSON.parse(t);yl(t=>e===`history`?t.history(n):t.cards(n))}catch{}}var Al=document.querySelector(`meta[name="sb-build"]`)?.content,jl=e=>!!(Al&&Al!==JSON.parse(e).build);function Ml(e){let t=new EventSource(e?`events?watch=${encodeURIComponent(e)}`:`events`);return{onError:e=>t.onerror=e,listen:(e,n)=>t.addEventListener(e,e=>n(e.data)),close:()=>t.close()}}var Nl=e=>fetch(`api/${e}`,{cache:`no-store`}).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))),Pl=(e,t=``)=>Nl(`history/${encodeURIComponent(e)}${t}`),Fl=void 0,Il=e=>({older:t=>Pl(e,`?before=${encodeURIComponent(t)}`),latest:()=>Pl(e),entry:t=>Nl(`entry/${encodeURIComponent(e)}/${encodeURIComponent(t)}`).catch(()=>void 0),pic:(t,n)=>`api/image/${encodeURIComponent(e)}/${encodeURIComponent(t)}/${n}`}),Ll=()=>{let e=Ml(ys(G));return e.listen(`history`,e=>kl(`history`,e)),e.listen(`cards`,e=>kl(`cards`,e)),e.listen(`hello`,e=>jl(e)?location.reload():(_l=e,q?.terminal.hello())),e.listen(`mirror`,e=>q?.terminal.frame(e)),e};document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`a[data-alert]`),n=t&&_s(t.getAttribute(`data-route`)??``);if(!n||n.view!==`session`||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey)return;let r=gl?.get(n.key);r&&(e.preventDefault(),J(e=>e.stack.show(r)))},!0);var Z=xs(e=>Dl(e)),Rl=()=>void D(async()=>{let{linkTile:e}=await import(`./link-DPtk3xuD.js`);return{linkTile:e}},[],import.meta.url).then(({linkTile:e})=>Y(e(),!0)),zl=Gc(Rl,e=>e&&Bl.chime()),Bl=Qc(e=>e.trust?J(t=>t.stack.show(e)):Z.go({view:`session`,ws:e.ws,key:zo(e)})),Q=il({open:Ll,now:Date.now,setTimeout:(e,t)=>window.setTimeout(e,t),clearTimeout:e=>window.clearTimeout(e),random:Math.random,hidden:()=>document.hidden,onNet:El,onStatus:Ol,replaced:()=>fetch(`./`,{cache:`no-store`}).then(e=>e.status===403)}),Vl=()=>Q.resume();document.addEventListener(`visibilitychange`,()=>{if(V.pause(document.hidden),document.hidden)return Q.hide();W&&El(W),yl(e=>e.wake()),Vl()}),addEventListener(`keydown`,e=>{e.key!==`Escape`||e.defaultPrevented||document.querySelector(`dialog.sheet[open], dialog.lightbox[open], [popover]:popover-open`)||(e.preventDefault(),!q?.stack.close()&&G.view!==`map`&&Z.go(vs(G)))}),Jo(e=>q?.hotkey(e)??!1),H(`teams`).addEventListener(`click`,Rl),H(`pair`).hidden=nc(location.hostname),H(`pair`).addEventListener(`click`,()=>void D(async()=>{let{pairTile:e}=await import(`./pair-CHVRgr0q.js`);return{pairTile:e}},[],import.meta.url).then(({pairTile:e})=>Y(e(),!0))),H(`pair`).hidden||D(async()=>{let{mountLanWait:e}=await import(`./lanwait-1tqNsDfl.js`);return{mountLanWait:e}},[],import.meta.url).then(({mountLanWait:e})=>e(H(`lan-wait`),()=>void D(async()=>{let{pairTile:e}=await import(`./pair-CHVRgr0q.js`);return{pairTile:e}},[],import.meta.url).then(({pairTile:e})=>Y(e(`lan`),!0)))),H(`server`).hidden=location.hostname!==`127.0.0.1`,H(`server`).addEventListener(`click`,()=>void D(async()=>{let{serverTile:e}=await import(`./server-CcYiCOxA.js`);return{serverTile:e}},[],import.meta.url).then(({serverTile:e})=>Y(e(),!0)));var $,Hl=matchMedia(`(pointer: coarse), (max-width: 640px)`),Ul=()=>void D(async()=>{let{mountDrawer:e}=await import(`./drawer-CT88mAQS.js`);return{mountDrawer:e}},[],import.meta.url).then(({mountDrawer:e})=>($??=e(),U&&$.net(U),$.route(G)));Hl.matches?Ul():Hl.addEventListener(`change`,()=>Hl.matches&&!$&&Ul(),{once:!0}),yc({route:()=>G,net:()=>U,go:e=>Z.go(e)}),H(`stashed-pop`).addEventListener(`toggle`,e=>e.newState===`open`&&L(H(`stashed-pop`),H(`stashed`))),H(`prefs-pop`).addEventListener(`toggle`,e=>e.newState===`open`&&L(H(`prefs-pop`),H(`prefs`))),document.addEventListener(`click`,e=>{let t=e.target?.closest?.(`button[data-open]`);t&&D(async()=>{let{openingOf:e,spawnTile:t}=await import(`./spawn-CCzQczfO.js`);return{openingOf:e,spawnTile:t}},[],import.meta.url).then(({openingOf:e,spawnTile:n})=>{let r=e(t,U?.bases??[]);r&&Y(n(r,(e,t,n)=>(q?.tiles.close(n),Z.go({view:`session`,ws:e,key:t})),()=>Bl.chime()),!0)})});for(let e of[`focus`,`pageshow`,`online`])window.addEventListener(e,()=>!document.hidden&&Vl());Ol(ml),Dl(Z.route()),Q.start(),hl=!0;export{Xo as $,Hs as A,_ as At,ps as B,hc as C,cn as Ct,Vs as D,$e as Dt,Us as E,Vt as Et,Gs as F,us as G,ds as H,Ns as I,as as J,os as K,Ms as L,Ws as M,te as Mt,qs as N,Os as O,ke as Ot,Js as P,Yo as Q,Ss as R,_c as S,dn as St,Xs as T,Ht as Tt,ms as U,T as V,fs as W,es as X,$o as Y,S as Z,R as _,li as _t,I as a,Ea as at,uc as b,Tr as bt,F as c,Yi as ct,j as d,Wi as dt,Ko as et,Oc as f,x as ft,kc as g,ui as gt,wc as h,b as ht,Ac as i,ko as it,Ks as j,ie as jt,Ds as k,Oe as kt,jc as l,Ki as lt,P as m,di as mt,bc as n,Bo as nt,Fc as o,Sa as ot,Dc as p,Ti as pt,w as q,A as r,zo as rt,M as s,xa as st,Cc as t,Ro as tt,L as u,Gi as ut,N as v,si as vt,D as w,Qt as wt,cc as x,bn as xt,Tc as y,Vr as yt,E as z};