pi-straw-boss 0.69.0 → 0.70.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.
- package/README.md +3 -0
- package/README.zh-TW.md +1 -0
- package/dist/gui/assets/{allyasks-BId8RwSi.js → allyasks-D317-PUS.js} +1 -1
- package/dist/gui/assets/{allyunits-qZ9Oi8pU.js → allyunits-0WmO4ge4.js} +1 -1
- package/dist/gui/assets/{answer-FRBxyAhO.js → answer-CI_aqsDi.js} +1 -1
- package/dist/gui/assets/{ask-hH0IsjkM.js → ask-asaoOwYb.js} +1 -1
- package/dist/gui/assets/{asks-DfkMf5Bc.js → asks-BQoExU03.js} +1 -1
- package/dist/gui/assets/auto-Bem-pRhU.js +1 -0
- package/dist/gui/assets/{blockschunk-BipvfK9z.js → blockschunk-B4P03pXf.js} +1 -1
- package/dist/gui/assets/{box--tGu5fh0.js → box-FLGyx5bX.js} +1 -1
- package/dist/gui/assets/chat-JoC8oliB.js +2 -0
- package/dist/gui/assets/{drawer-BIVf2qL5.js → drawer-Cz88O8if.js} +1 -1
- package/dist/gui/assets/{index-CfxTRKov.js → index-Ci_M1nWI.js} +3 -3
- package/dist/gui/assets/index-Cy-sjGia.css +1 -0
- package/dist/gui/assets/{lanwait-CfviwZ1Y.js → lanwait-BVrDXGHx.js} +1 -1
- package/dist/gui/assets/{layer-CRVUNEIC.js → layer-9Ruo8Kq8.js} +1 -1
- package/dist/gui/assets/{lightbox-BFWGHbQX.js → lightbox-CGvsEhxp.js} +1 -1
- package/dist/gui/assets/{link-DBpoLbxE.js → link-TzH3717a.js} +1 -1
- package/dist/gui/assets/{linkdialogs-kpO-VkR1.js → linkdialogs-BKWg9n-3.js} +1 -1
- package/dist/gui/assets/mdbody-LgDqhYO3.js +2 -0
- package/dist/gui/assets/{pair-liBR8zqd.js → pair-KMdN7-Zb.js} +1 -1
- package/dist/gui/assets/{picker-DAyj_VRn.js → picker-Cms3BCXK.js} +1 -1
- package/dist/gui/assets/{server-CLOETMp5.js → server-yZiZpmqj.js} +1 -1
- package/dist/gui/assets/{settings-C6QWGWd7.js → settings-BUGUbyS3.js} +2 -2
- package/dist/gui/assets/{spawn-UJ5hiVOr.js → spawn-Cp_SIms7.js} +1 -1
- package/dist/gui/assets/{termcard-CYpds_ge.js → termcard-CUVRXe4a.js} +1 -1
- package/dist/gui/assets/{towerturns-D2MZjoqB.js → towerturns-Ci8paKaq.js} +1 -1
- package/dist/gui/assets/{trains-_2p0835Z.js → trains-CyRwMUix.js} +1 -1
- package/dist/gui/assets/{trust-CjgWBFt5.js → trust-DggtHVe3.js} +1 -1
- package/dist/gui/assets/views-DYvA_aAJ.js +2 -0
- package/dist/gui/assets/{waitcard-BxPs1wl7.js → waitcard-Du07aA3n.js} +1 -1
- package/dist/gui/assets/{yard-B5_-7bMG.js → yard-D6OKyiRi.js} +1 -1
- package/dist/gui/index.html +3 -3
- package/dist/gui/themes/raven/{raven-DTB8C7Y1.css → raven-CAG7epLI.css} +1 -1
- package/dist/gui/themes/raven/{raven-Brb7Uwyl.js → raven-Di7otXYj.js} +2 -2
- package/dist/gui/themes/zen/zen-DkJEytRT.js +2 -0
- package/dist/gui/themes.json +3 -3
- package/dist/server/main.mjs +1395 -721
- package/package.json +1 -1
- package/prompts/head-run.md +2 -0
- package/src/auto.ts +181 -0
- package/src/autoask.ts +19 -0
- package/src/autoscope.ts +7 -0
- package/src/autostate.ts +150 -0
- package/src/autotext.ts +24 -0
- package/src/boss.ts +15 -6
- package/src/bossauto.ts +50 -0
- package/src/bossconfirm.ts +48 -0
- package/src/bosslink.ts +14 -7
- package/src/bridge.ts +15 -2
- package/src/control.ts +12 -4
- package/src/declined.ts +52 -0
- package/src/dialogs.ts +1 -1
- package/src/gui.ts +3 -3
- package/src/header.ts +1 -1
- package/src/index.ts +16 -3
- package/src/intercept.ts +25 -11
- package/src/link/hooks.ts +5 -1
- package/src/link/runtime.ts +1 -1
- package/src/net.ts +6 -4
- package/src/operateroutes.ts +1 -0
- package/src/owners.ts +4 -4
- package/src/reach.ts +2 -0
- package/src/runallow.ts +2 -2
- package/src/runhead.ts +17 -1
- package/src/runmode.ts +18 -6
- package/src/server/autoback.ts +58 -0
- package/src/server/autofollow.ts +81 -0
- package/src/server/automode.ts +239 -0
- package/src/server/autoops.ts +43 -0
- package/src/server/autotower.ts +112 -0
- package/src/server/boardpanel.ts +3 -3
- package/src/server/guihost.ts +5 -2
- package/src/server/headbrief.ts +4 -0
- package/src/server/headcmds.ts +3 -2
- package/src/server/headside.ts +3 -1
- package/src/server/headtools.ts +14 -1
- package/src/server/main.ts +26 -3
- package/src/server/runs.ts +5 -4
- package/src/server/runtools.ts +4 -0
- package/src/server/towerbrief.ts +3 -1
- package/src/server/towermemory.ts +13 -6
- package/src/server/towers.ts +51 -11
- package/src/server/towerstore.ts +3 -0
- package/src/server/waitpress.ts +3 -0
- package/src/state.ts +3 -1
- package/src/tools.ts +3 -1
- package/src/trust/ask.ts +10 -2
- package/dist/gui/assets/chat-BUYVk40F.js +0 -2
- package/dist/gui/assets/index-yvAHBXVf.css +0 -1
- package/dist/gui/assets/mdbody-CkMZtGcN.js +0 -2
- package/dist/gui/assets/sessionfacts-B1NCBHmm.js +0 -1
- package/dist/gui/assets/views-sk6RtITo.js +0 -2
- package/dist/gui/themes/zen/zen-MeIsUPGE.js +0 -2
package/README.md
CHANGED
|
@@ -129,6 +129,7 @@ The tower only routes and coordinates, so it can run a lighter model: set `tower
|
|
|
129
129
|
| `boss_broadcast` | Message a tab, a workspace, all towers, or every session (under a header). |
|
|
130
130
|
| `boss_server` | See the sb server (status works with the server down), read its log (up to 200 lines), or restart it with a reason. Refused while the boss stopped the server, once a minute at most, and never in a remote turn. |
|
|
131
131
|
| `boss_duty` | A tab's main: set its kind (`coordinator`, `integrator`, `standing`) with a reason; the kind is the prompt it runs and shows on the page. |
|
|
132
|
+
| `boss_auto` | The head tower only: start or end auto mode on your own words in the turn it answers (「我要睡了」 stages a request that you confirm; 「我起床了」 ends it). The server reads the words itself and refuses a question, a negation, a press, and words used before. |
|
|
132
133
|
| `boss_rename` | Name this session with a short phrase for its current work; the net and the GUI show it, and a main agent's tab takes it as its label. Main agents call it when their work changes. |
|
|
133
134
|
| `/boss` | Take over as this tab's main agent. |
|
|
134
135
|
| `/boss status`, `/boss tower` | Show the status; open and focus the tower. |
|
|
@@ -136,6 +137,7 @@ The tower only routes and coordinates, so it can run a lighter model: set `tower
|
|
|
136
137
|
| `/boss head retry`, `parked`, `deliver <id>`, `drop <id>`, `--answers W3 <message>` | The head tower's notices and parked events, and a message that answers a wait: the pi twins of the head page's buttons and composer (the same as `/boss tower -w head …`). |
|
|
137
138
|
| `/boss send <name\|key> [--after] <text>`, `/boss stop <name\|key>` | Write to any session on the net as the boss, as the page's composer does (`--after` queues it for when the session is idle), or press Esc in it as Stop does (asked in pi first, as the page asks). Quote a name that has spaces: `/boss send "fix login" hi`. The post says it came through a `/boss send`, so the server holds it to the guards a paired device's own write meets, whatever its address: a command that is local-only, the `/boss gui lan` screen's mark, an open `link_request`; and to the usual ones: a blocked dialog, a command that ends the session (asked in pi first), the 16 KB limit. A paired device's composer cannot hide a local-only command in a `/boss send`. |
|
|
138
139
|
| `/boss memory [-w workspace]`, `/boss memory confirm P1`, `reject P1`, `add standing\|decision <text>`, `edit S1 <text>`, `delete D1`, `resolve W1` | Read and change the tower's memory from pi: its standing instructions, decisions, and waits, and the proposals the tower made that wait for you. The GUI's Memory panel is the same operation. See [Tower memory](docs/how-it-works.md#tower-memory). |
|
|
140
|
+
| `/boss auto`, `/boss auto on`, `/boss auto confirm`, `/boss auto off` | Auto mode, for when you are away: nothing may wait for you. Plain `/boss auto` shows the state (and the last return list). `on` asks for it and you confirm in this terminal; a request the head tower staged is confirmed with `confirm` (or the button on the head page and Zen's strip). While it is on, a tool that waits for you (`ask_user_question`, `question`, `robot_hand`, `secret_drop`, `link_request`, a confirm inside a tool call) is refused or cancelled with a note to the agent, a card a tower records is parked, and the head tower can end it on your words. `off` ends it and prints the return list: the parked waits by `W<n>` (act on them with `/boss memory done\|choose\|decline W<n>`), then what was cancelled, refused, or decided by a tower ([how](docs/how-it-works.md#auto-mode)). |
|
|
139
141
|
| `/boss server`, `/boss server stop`, `/boss server restart [reason]` | Show the sb server and start it when it is down; stop it on purpose (after a confirm; nothing but a boss command starts it again); restart it (after a confirm) on the same port; the GUI keeps its address, so open pages reconnect by themselves. See [The sb server](docs/how-it-works.md#the-sb-server). |
|
|
140
142
|
| `/boss server logs [n]` | Show the last `n` lines of the sb server's log (default and most 200), as the `boss_server` tool's `logs` does. |
|
|
141
143
|
| `/boss close` | Quit this session and close its pane. |
|
|
@@ -147,6 +149,7 @@ The tower only routes and coordinates, so it can run a lighter model: set `tower
|
|
|
147
149
|
| `/boss dismiss [all\|<name>]` | Hide finished subagents from the net, all of them or one by name, as the page's Dismiss does. |
|
|
148
150
|
| `/boss open base <dir> [label]`, `/boss open member [dir]`, `/boss open main <dir> [prompt]` | The page's + Base, + Member, and + Main, typed. `<dir>` is relative to this session's folder (`~` is home; quote a path with spaces); the server still only takes folders under home. A base opens with one member; a member opens beside this session (or in a tab of its own in `<dir>`); a main opens in a new tab of this base and takes the prompt. A project trust question the new pi waits on is asked in pi. |
|
|
149
151
|
| `/boss link [status]`, `/boss link decide <id> approve\|refuse` | This device's teams and members and the join requests waiting (with a short id), and the page's Approve / Refuse. Approving an attended device shows the team, the device, and the sets of words in pi: pick the set the new computer's screen shows (none of them refuses); approving an unattended device asks first. An unknown or ambiguous id does nothing. A paired phone can read and open but not decide. |
|
|
152
|
+
| `/boss link on` | Set up Straw Link on this computer, as the GUI page's Set up button does (it posts the same `link/enable`; this computer only, never a tower run or a paired device). Until it is on, every other `/boss link` line says Straw Link is not on in this server. |
|
|
150
153
|
| `/boss link confirms`, `link confirm <id> allow\|deny`, `link asks`, `link answer <id> <number \| text>` | The confirms teammates' towers wait on (who, tool, age, the call's arguments in full) and the questions unattended devices forwarded, listed; Allow / Deny and the answer go to the page's routes. Every allow and every answer asks first, on this computer only: while that screen waits, a paired device's key pad can send Escape only. |
|
|
151
154
|
| `/boss link invite show\|cancel <hash>`, `link join cancel`, `link leave <team> [--force]` | Show an open invite's text on a screen of its own (never in the chat), cancel an invite (asks first), cancel the join in progress, leave a team (asks first). |
|
|
152
155
|
| `/boss link create <relay> <dir> [--share status\|presence] [--label x]`, `link join <invite \| @file> [--project <dir>] [--share …] [--label x]` | Create or join a team in pi. Both ask first, naming the relay and the folder. `create` asks for the relay's token on a masked screen that returns it only to the request; `join` prints the four words for the inviter to pick (the folder is this session's unless `--project` says otherwise). Use `@file` for an invite rather than typing it into the command line. |
|
package/README.zh-TW.md
CHANGED
|
@@ -147,6 +147,7 @@ pi install npm:pi-straw-boss
|
|
|
147
147
|
| `/boss send <名稱\|key> [--after] <內容>`、`/boss stop <名稱\|key>` | 以老闆的身分寫給網路上任何一個 session,和網頁輸入框相同(`--after` 排在它閒下來之後);或對它按 Esc,和「停止」相同(會先在 pi 裡確認)。名稱含空白時加引號:`/boss send "fix login" hi`。這個請求會標明它來自 `/boss send`,所以伺服器用已配對裝置自己寫入時的檢查擋它,不論位址:只限本機的指令、`/boss gui lan` 畫面的標記、等待中的 `link_request`;一般的檢查也照舊:被擋住的對話框、會結束 session 的指令(先在 pi 裡確認)、16 KB 上限。已配對的手機不能把只限本機的指令藏在 `/boss send` 裡。 |
|
|
148
148
|
| `/boss open base <資料夾> [名稱]`、`/boss open member [資料夾]`、`/boss open main <資料夾> [提示]` | 網頁的「+基地」「+成員」「+主智慧體」,用打字完成。`<資料夾>` 相對於本工作階段的資料夾(`~` 是家目錄;路徑有空格要加引號);伺服器仍只接受家目錄底下的資料夾。基地會附一位成員;成員開在本工作階段旁邊(給資料夾則開在它的新分頁);主智慧體開在本基地的新分頁,可帶提示。新的 pi 若在等專案信任問題,會在 pi 裡問你。 |
|
|
149
149
|
| `/boss link [status]`、`/boss link decide <id> approve\|refuse` | 列出本裝置的團隊與成員,以及等待中的加入要求(附短 id),並做網頁的「核准/拒絕」。核准有人值守的裝置時,pi 會顯示團隊、裝置與各組單字:選新電腦螢幕上顯示的那一組(都不是就是拒絕);核准無人值守的裝置會先確認。id 不存在或不唯一就什麼都不做。已配對的手機能讀、能開單位,但不能決定。 |
|
|
150
|
+
| `/boss link on` | 在這台電腦設定 Straw Link,等同網頁的「設定 Straw Link」按鈕(送出同一個 `link/enable`;只有這台電腦本機可用,塔台的 run 與配對裝置都不行)。還沒開時,其他 `/boss link` 指令都只會回「沒有開 Straw Link」。 |
|
|
150
151
|
| `/boss link confirms`、`link confirm <id> allow\|deny`、`link asks`、`link answer <id> <編號 \| 文字>` | 列出隊友塔台在等的確認(誰、工具、多久前、呼叫的完整參數),和無人值守裝置轉送來的問題;允許/拒絕與答案送到網頁用的路由。每次允許、每次回答都會先問,且只在這台電腦上問:問的畫面開著時,已配對裝置的按鍵板只能送 Escape。 |
|
|
151
152
|
| `/boss link invite show\|cancel <hash>`、`link join cancel`、`link leave <團隊> [--force]` | 在專屬畫面顯示未用邀請的文字(不會出現在聊天裡)、取消邀請(會先問)、取消進行中的加入、離開團隊(會先問)。 |
|
|
152
153
|
| `/boss link create <中繼站> <資料夾> [--share status\|presence] [--label x]`、`link join <邀請 \| @檔案> [--project <資料夾>] [--share …] [--label x]` | 在 pi 裡建立或加入團隊。兩者都會先問,並列出中繼站與資料夾。`create` 會在遮蔽畫面請你輸入中繼站的 token,只交給那個請求;`join` 會印出四個單字,讓邀請人去選(資料夾預設是本工作階段的,用 `--project` 改)。邀請請用 `@檔案`,不要直接打在指令列。 |
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{C as e}from"./towermodel-BpgH7epr.js";import{t}from"./runtime-ZX6HkxDa.js";import{ct as n,ft as r,ut as i}from"./index-
|
|
1
|
+
import{C as e}from"./towermodel-BpgH7epr.js";import{t}from"./runtime-ZX6HkxDa.js";import{ct as n,ft as r,ut as i}from"./index-Ci_M1nWI.js";import{mountDialogCards as a}from"./linkdialogs-BKWg9n-3.js";var o=t=>{let n=e(`en`,t?.count,{},!0);return n===`one`?`${t?.count} question waits for you: answer it here`:n===`other`?`${t?.count} questions wait for you: answer them here`:`ally_asks_button`},s=e=>`${e?.count} 個問題等你回答,在這裡回答`,c=((e,n={})=>(n.locale??t())===`zh-TW`?s(e):o(e)),l=e=>e.tower===`blocked`||e.tabs.some(e=>e.state===`blocked`);function u(e){let t=new Map,r=i(e?.allies??[]);for(let i of e?.alerts??[]){let e=i.kind===`dialog`?n(i):void 0;if(e!==`open`&&e!==`sent`)continue;let a=r.filter(e=>e.device===i.data.device),o=a.filter(e=>e.teams.some(e=>e.team===i.team)),s=o.length?o:a,c=s.find(l)??s[0];c&&t.set(c.id,[...t.get(c.id)??[],i])}return t}var d=`.ally-unit[data-state="blocked"], .ally-tab[data-state="blocked"]`;function f(){let e=new WeakMap,t=t=>{let i=e.get(t);if(i)return i;let o=r(`button`,{type:`button`,class:`ally-asks-btn`,"aria-expanded":`false`}),s=r(`ul`,{class:`ally-asks-list`}),c=r(`div`,{class:`ally-asks`},o,s);return i={box:c,btn:o,list:s,cards:a(),ids:``},e.set(t,i),o.onclick=()=>n(t),t.addEventListener(`click`,e=>{let r=e.target?.closest?.(d);r&&t.contains(r)&&t.dataset.asks&&!e.target.closest(`details`)&&n(t)}),t.append(c),i};function n(t){let n=e.get(t);if(!n||!t.dataset.asks)return;let r=t.dataset.asking===void 0;r?t.dataset.asking=``:delete t.dataset.asking,n.list.hidden=!r,n.btn.setAttribute(`aria-expanded`,String(r))}function i(n,r){if(!r.length&&!e.has(n))return;let i=t(n);if(i.box.hidden=!r.length,!r.length){delete n.dataset.asks,delete n.dataset.asking,i.btn.setAttribute(`aria-expanded`,`false`),i.cards.keep(new Set),i.list.replaceChildren(),i.ids=``;return}n.dataset.asks=String(r.length),i.btn.textContent=c({count:r.length}),i.list.hidden=n.dataset.asking===void 0,i.cards.keep(new Set(r.map(e=>e.id)));let a=r.map(e=>i.cards.row(e)),o=r.map(e=>e.id).join(`
|
|
2
2
|
`);o!==i.ids&&(i.list.replaceChildren(...a),i.ids=o)}return{toggle:n,fill:i,show:(e,t,n)=>i(e,u(n).get(t.id)??[])}}export{f as mountAllyAsks};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{C as e}from"./towermodel-BpgH7epr.js";import{t}from"./runtime-ZX6HkxDa.js";import{t as n}from"./sentencepack-DtYqpppS.js";import{t as r}from"./link_unit_ago-CvB9wMxM.js";import{At as i,E as a,K as o,Ot as s,T as c,W as l,dt as u,j as d,l as f,v as p,zt as m}from"./index-
|
|
1
|
+
import{C as e}from"./towermodel-BpgH7epr.js";import{t}from"./runtime-ZX6HkxDa.js";import{t as n}from"./sentencepack-DtYqpppS.js";import{t as r}from"./link_unit_ago-CvB9wMxM.js";import{At as i,E as a,K as o,Ot as s,T as c,W as l,dt as u,j as d,l as f,v as p,zt as m}from"./index-Ci_M1nWI.js";var h=e=>`by ${e?.who}`,g=e=>`派工者 ${e?.who}`,ee=((e,n={})=>(n.locale??t())===`zh-TW`?g(e):h(e)),te=((e={},n={})=>(n.locale??t())===`zh-TW`?`中斷並停止`:`Interrupt and stop`),ne=e=>`${e?.box} was not asked: ${e?.reason}`,_=e=>`沒有請 ${e?.box} 停止:${e?.reason}`,v=((e,n={})=>(n.locale??t())===`zh-TW`?_(e):ne(e)),y=((e={},n={})=>(n.locale??t())===`zh-TW`?`停止`:`Stop`),b=e=>`Stop the main ${e?.name}`,x=e=>`停止主智慧體 ${e?.name}`,S=((e,n={})=>(n.locale??t())===`zh-TW`?x(e):b(e)),C=(e,t)=>n(`link_main_stop_aria`,S,e,t),w=e=>`Ask ${e?.box} to stop the main ${e?.name}? Stop lets it quit when it is idle; Interrupt and stop aborts the turn it is in first. The box decides and tells you what happened.`,T=e=>`要請 ${e?.box} 停止主智慧體 ${e?.name} 嗎?「停止」等它閒下來才結束;「中斷並停止」會先中止它進行中的回合。由那台機器決定,結果會通知你。`,E=((e,n={})=>(n.locale??t())===`zh-TW`?T(e):w(e)),D=(e,t)=>n(`link_main_stop_ask`,E,e,t),O=e=>`Mains (${e?.count})`,k=e=>`主智慧體(${e?.count})`,A=((e,n={})=>(n.locale??t())===`zh-TW`?k(e):O(e)),j=(e,t)=>n(`link_mains`,A,e,t),M=((e={},n={})=>(n.locale??t())===`zh-TW`?`發生了什麼事`:`What happened`),N=((e={},n={})=>(n.locale??t())===`zh-TW`?`這個單位最後一次回報的時間`:`When this unit last reported`),P=t=>{let n=e(`en`,t?.count,{},!0);return n===`one`?`${t?.count} monitor`:n===`other`?`${t?.count} monitors`:`link_unit_monitors`},F=e=>`${e?.count} 個監看程序`,I=((e,n={})=>(n.locale??t())===`zh-TW`?F(e):P(e)),re=((e={},n={})=>(n.locale??t())===`zh-TW`?`最後回報`:`Last report`),L=((e={},n={})=>(n.locale??t())===`zh-TW`?`最近沒有狀態`:`no status lately`),R=((e={},n={})=>(n.locale??t())===`zh-TW`?`盒子已超過 3 分鐘沒送狀態,這是它最後一次的內容`:`The box has sent no status for 3 minutes; this is its last one`),z=((e={},n={})=>(n.locale??t())===`zh-TW`?`請在盒子的 trust.json 加入這個專案`:`Add the project to the box's trust.json`),B=((e={},n={})=>(n.locale??t())===`zh-TW`?`為什麼停了`:`Why it stopped`),V=((e={},n={})=>(n.locale??t())===`zh-TW`?`前更新`:` ago`),H=((e={},n={})=>(n.locale??t())===`zh-TW`?``:`updated `),U={choose:d,post:(e,t)=>o(e,t)},W=12e4,G=new Map,K=(e,t)=>`${e.device}/${t.handle}`,q=(e,t,n=Date.now())=>n-(G.get(K(e,t))??-1/0)<W;async function J(e,t,n){let r=await U.choose(D({box:n,name:t.name}),[{label:y(),value:`quit`},{label:te(),value:`interrupt`,tone:`danger`}]);if(!r)return!1;let a=await U.post(`link/unit-stop`,{team:t.team,device:e.device,handle:t.handle,mode:r,reason:``}).catch(()=>({ok:!1,status:0,body:{}}));return a.ok?(G.set(K(e,t),Date.now()),!0):(await U.choose(v({box:n,reason:a.body.reason??(a.status?s({status:a.status}):i())}),[]),!1)}var Y=()=>p(`<li class="ally-unit"><div class="au-head"><i class="au-dot"></i><b class="au-word"></b><span class="au-name"></span><span class="au-time" hidden><span class="au-pre"></span><span class="age"></span><span class="au-ago"></span></span><em class="au-stale" hidden></em></div><p class="au-mons" hidden><b></b><span></span></p><details class="au-mains" hidden><summary><b class="au-mains-label"></b></summary><ul class="au-main-list"></ul></details><details class="au-crash" hidden><summary><b></b><span class="au-time"><span class="age"></span><span class="au-ago"></span></span></summary><pre></pre><p class="au-hint" hidden></p></details><details class="au-report" hidden><summary><b class="au-label"></b><span class="au-peek"></span></summary><div class="md au-md"></div></details></li>`),X,Z=new WeakMap;function Q(e){let t=e.querySelector(`.au-md`),n=Z.get(e)??``;e.open&&t.dataset.report!==n&&(X?Promise.resolve(X):l(()=>import(`./markdown-Bk5NWfKQ.js`).then(e=>e.t).then(e=>X=e),[],import.meta.url)).then(({mount:r,parse:i})=>{e.open&&Z.get(e)===n&&(t.dataset.report=n,t.replaceChildren(r(i(n))))})}function $(e,t,n=``,i=r()){let a=e.querySelector(`.age`);a.dataset.since=String(t),a.textContent=f(t),e.querySelector(`.au-pre`)?.replaceChildren(n),e.querySelector(`.au-ago`).textContent=i}var ie=()=>p(`<li class="au-main"><span class="au-mdot"></span><b class="au-mname"></b><span class="au-mstate"></span><span class="au-mby" hidden></span><button type="button" class="au-stop" hidden></button></li>`);function ae(e,t,n){let r=e.querySelector(`.au-mains`);r.hidden=!t.mains.length,t.mains.length&&(a(r,`.au-mains-label`,j({count:t.mains.length})),c(r.querySelector(`.au-main-list`),t.mains.map(e=>({...e,id:e.handle})),ie,(e,r)=>{let i=r.stopping||q(t,r),o=i?m():r.word;e.dataset.tone=i?`other`:r.tone,a(e,`.au-mname`,r.name),a(e,`.au-mstate`,o);let s=e.querySelector(`.au-mby`);s.hidden=r.byLabel===void 0,s.textContent=r.byLabel===void 0?``:ee({who:r.byLabel});let c=e.querySelector(`.au-stop`);c.hidden=!r.canStop||i,c.textContent=y(),c.setAttribute(`aria-label`,C({name:r.name})),c.onclick=()=>{c.disabled=!0,J(t,r,n).then(t=>{c.disabled=!1,t&&(e.dataset.tone=`other`,a(e,`.au-mstate`,m()),c.hidden=!0)})}}))}function oe(e,t,n,r=``){c(e,t.map(e=>({...e,id:e.unit,named:n})),Y,(e,t)=>{e.dataset.state=t.state,e.dataset.tone=t.tone,e.classList.toggle(`stale`,t.stale),a(e,`.au-word`,t.word),a(e,`.au-name`,t.named?t.unit:``);let n=e.querySelector(`.au-head > .au-time`);n.hidden=!1,n.title=N(),$(n,t.at,H(),V());let i=e.querySelector(`.au-stale`);i.hidden=!t.stale,i.textContent=t.stale?L():``,i.title=t.stale?R():``;let o=e.querySelector(`.au-mons`);o.hidden=!t.monitors.length,t.monitors.length&&(a(o,`b`,I({count:t.monitors.length})),a(o,`span`,t.monitors.join(` · `)),o.title=t.monitors.join(`
|
|
2
2
|
`)),ae(e,t,r);let s=e.querySelector(`.au-crash`);if(s.hidden=!t.crash,s.toggleAttribute(`data-trust`,t.crash?.trust===!0),t.crash){a(s,`summary > b`,t.crash.trust?B():M()),$(s.querySelector(`summary > .au-time`),t.crash.at),a(s,`pre`,t.crash.text);let e=s.querySelector(`.au-hint`);e.hidden=!t.crash.trust,e.textContent=t.crash.trust?z():``}let c=e.querySelector(`.au-report`);c.hidden=!t.report,t.report&&(a(c,`.au-label`,re()),a(c,`.au-peek`,u(t.report)),Z.set(c,t.report),c.ontoggle=()=>Q(c),Q(c))})}export{oe as fillAllyUnits};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./rolldown-runtime-DK3Fl9T5.js";import{t}from"./ask-
|
|
1
|
+
import{t as e}from"./rolldown-runtime-DK3Fl9T5.js";import{t}from"./ask-asaoOwYb.js";import{K as n}from"./index-Ci_M1nWI.js";var r=e({answerPost:()=>i,canAnswer:()=>o,mountAnswer:()=>s,trustPost:()=>a}),i=(e,t)=>t?.(e)??((t,r)=>n(e.startsWith(`grant:`)?`panes/${encodeURIComponent(e.slice(6))}/${t}`:`sessions/${encodeURIComponent(e)}/${t}`,r)),a=e=>e??(e=>n(`trust/answer`,e)),o=(e,...t)=>e===`waiting`&&t.every(Boolean),s=(e,{key:n,show:r,post:i,remote:a,accepted:o,label:s,box:c})=>t(e,i,a,{key:n,show:r},o,s,c);export{a,s as i,r as n,o as r,i as t};
|
|
@@ -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{Ot as o,Qt as s,ft as c,t as l}from"./index-CfxTRKov.js";var u=((t={},n={})=>(n.locale??e())===`zh-TW`?`請在終端機中回答。`:`Answer it in the terminal.`),d=((t={},n={})=>(n.locale??e())===`zh-TW`?`請在終端機中回答。`:`Answer them in the terminal.`),f=((t={},n={})=>(n.locale??e())===`zh-TW`?`作用在那台機器本身畫面的選項,從這裡不能選。`:`Choices that act on the machine's own screen are not available from here.`),p=((t={},n={})=>(n.locale??e())===`zh-TW`?`下方還有 ▾`:`More below ▾`),m=((t={},n={})=>(n.locale??e())===`zh-TW`?`也可以自己輸入答案。`:`It also takes your own words.`),h=((t={},n={})=>(n.locale??e())===`zh-TW`?`可以複選。`:`It takes several choices.`),g=((t={},n={})=>(n.locale??e())===`zh-TW`?`已取消。`:`Cancelled.`),_=((t={},n={})=>(n.locale??e())===`zh-TW`?`選擇`:`Choices`),v=((t={},n={})=>(n.locale??e())===`zh-TW`?`瀏覽器拒絕存取剪貼簿。`:`The browser refused the clipboard.`),y=((t={},n={})=>(n.locale??e())===`zh-TW`?`已複製到這台裝置的剪貼簿。`:`Copied to this device's clipboard.`),ee=((t={},n={})=>(n.locale??e())===`zh-TW`?`複製指令`:`Copy command`),b=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個選項有預覽;請在終端機中查看。`:`It has a preview; see it in the terminal.`),x=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註`:`Note`),S=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註(選填)`:`Note (optional)`),C=e=>`Opened while ${e?.tool} was running; it may not be about that call.`,w=e=>`在 ${e?.tool} 執行時開啟,不一定與該呼叫有關。`,T=((t,n={})=>(n.locale??e())===`zh-TW`?w(t):C(t)),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`選項`:`Options`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`另一個答案沒有被採用;這個可以送出。`:`The other answer was not taken; this one can go.`),O=((t={},n={})=>(n.locale??e())===`zh-TW`?`你的答案`:`Your own answer`),k=((t={},n={})=>(n.locale??e())===`zh-TW`?`或自己輸入答案`:`Or type your own answer`),A=((t={},n={})=>(n.locale??e())===`zh-TW`?`問題已變更,請重新閱讀。`:`The question changed; read it again.`),j=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 讀不懂這個答案。`:`The session could not read that answer.`),M=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個答案不符合問題。`:`That answer does not fit the question.`),N=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 拒絕了這個答案。`:`The session refused that answer.`),P=((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.`),te=((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.`),ne=((t={},n={})=>(n.locale??e())===`zh-TW`?`送出答案`:`Send answer`),re=((t={},n={})=>(n.locale??e())===`zh-TW`?`顯示終端機`:`Show terminal`),F=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中關閉。`:`It was dismissed in the terminal.`),I=((t={},n={})=>(n.locale??e())===`zh-TW`?`它已不再開啟。`:`It is no longer open.`),L=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中回答。`:`It was already answered in the terminal.`),R=((t={},n={})=>(n.locale??e())===`zh-TW`?`它在等待對話框。`:`It waits on a dialog.`),z={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1};function B(e,t,n,r,i){let{q:a}=n,o=r[a],s=z[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`){let e=r[a-1],i=n.part===`opt`?o.own||o.note:n.part===`own`&&o.note;return t?n.part===`opt`&&e?{to:{q:a-1,part:e.note?`note`:e.own?`own`:`opt`}}:void 0:i||a===r.length-1?void 0:{to:{q:a+1,part:`opt`}}}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 V(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,c=!1;return e.addEventListener(`keydown`,i=>{i.key===` `&&(c=!0);let o=a(i.target);if(!o||i.ctrlKey||i.altKey||i.metaKey||i.isComposing)return;let l=i.target;if(o.part!==`opt`&&(i.key===`ArrowUp`?l.selectionStart!==0:i.key===`ArrowDown`&&l.selectionEnd!==l.value.length))return;let u=B(i.key,i.shiftKey,o,t.map(e=>({options:e.opts.length,multiple:e.multiple,own:!!e.own,note:!!e.note})),t.map(e=>e.answered()));if(!u||(i.preventDefault(),i.repeat&&[`Enter`,` `].includes(i.key)))return;if(s=i.key===` `,u.pick!==void 0){let e=t[o.q].opts[u.pick];e.getAttribute(`aria-checked`)!==`true`&&e.click()}let d=u.to===`send`?void 0:t[u.to.q],f=u.to===`send`?n():u.to.part===`opt`?d.opts[u.to.o??r(d)]:u.to.part===`own`?d.own:d.note;f&&!f.disabled&&(e.dispatchEvent(new CustomEvent(`ask-reveal`,{detail:f})),f.focus())}),e.addEventListener(`keyup`,e=>{e.key===` `&&((s||!c)&&e.preventDefault(),s=c=!1)}),()=>t[0]?.opts[r(t[0])]}var H=e=>e.multiple?h():e.freeform&&e.options.length?m():``,U=90,W=(e,t)=>c(`div`,{class:`ask-one`},e.header&&c(`b`,{class:`ask-head`},e.header),c(`p`,{class:`ask-q`,...e.question.length>U?{"data-long":``}:{}},e.question),e.context&&c(`div`,{class:`ask-ctx`},e.context),e.options.length>0&&c(`ol`,{class:`ask-opts`,"aria-label":E()},...e.options.map(e=>c(`li`,{class:`ask-opt`},c(`b`,null,e.title),e.description&&c(`small`,null,e.description)))),t&&H(e)&&c(`small`,{class:`ask-how`},H(e))),G=e=>e.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\p{Cf}]/gu,`�`),K=e=>(e.select?.choices??[]).map((e,t)=>({...e,i:t})),q=(e,t,n)=>({...e.size?{choices:[...e].sort((e,t)=>e-t)}:{},...t.trim()?{text:t}:{},...n.trim()?{note:n}:{}}),J=(e,t,n)=>({dialog:e.dialog,digest:e.digest,answerId:n,...t}),Y=(e,t)=>({dialog:e.dialog,digest:e.digest,answerId:t,cancel:!0}),ie=(e,t)=>e.cancel===!0&&!(t&&e.select?.choices.every(e=>e.hereOnly)),X={digest:A,"not-allowed":M,malformed:j};function ae(e,i=!1){let{outcome:a,reason:s,by:c}=e.body;return a===`accepted`?[`ok`,i?g():n()]:a===`stale`?[`error`,c===`local`?L():c===`cancel`?F():I()]:a===`rejected`?[`error`,(Object.hasOwn(X,String(s))?X[String(s)]:N)()]:a===`busy`?[`error`,t()]:a===`unknown`||e.status===504?[`error`,r(),!0]:[`error`,s??o({status:e.status})]}var oe=e=>[`accepted`,`stale`,`busy`,`unknown`].includes(String(e.body.outcome))||e.status===504,Z=e=>e.answer?`d\n${e.answer.dialog}\n${e.answer.digest}`:`c\n${e.callId}\n${e.why??``}`;function se(e){if(e.dataset.cued)return;e.dataset.cued=`1`;let t=()=>{e.toggleAttribute(`data-more`,e.scrollHeight-e.scrollTop-e.clientHeight>4);for(let t of e.querySelectorAll(`.ask-acts`))t.dataset.cue=p()};for(let n of[`scroll`,`input`])e.addEventListener(n,t,{passive:!0});typeof ResizeObserver<`u`&&new ResizeObserver(t).observe(e),typeof MutationObserver<`u`&&new MutationObserver(t).observe(e,{childList:!0,subtree:!0,characterData:!0}),typeof requestAnimationFrame<`u`&&requestAnimationFrame(t)}var ce=0;function Q(e,t,n=location.hostname!==`127.0.0.1`,o,p,m=re,h=!1){let g=()=>typeof h==`function`?h():h,C=()=>n||g(),w,A,j,M=!1,N,F=!1,I;for(let e of[`focusin`,`pointerdown`])document.addEventListener(e,e=>A&&!A.el.contains(e.target)&&(A.lost=void 0));let L=(e,t,n,...r)=>(e.dataset.tone=t,e.replaceChildren(n,...r)),z=()=>{if(!A)return;let e=document.activeElement;e&&e!==document.body&&e!==A.lost&&(A.lost=void 0),A.controls.forEach(e=>e.disabled=!M||F||A.done),A.send&&(A.send.disabled=!M||F||A.done||!A.pick()),N&&!M&&!F&&!A.done&&!A.sending?(L(A.note,``,N),A.away=!0):A.away&&(L(A.note,``,``),A.away=!1),e&&A.el.contains(e)&&e.disabled&&(A.lost=e);let t=A.lost;t&&!t.disabled&&A.el.contains(t)&&(!document.activeElement||document.activeElement===document.body)&&(t.focus(),A.lost=void 0)};async function B(e,n){[e.sending,F,e.spell]=[!0,!0,!1],z(),L(e.note,``,a());let s=await t(`answer`,n).catch(()=>void 0),u=c(`button`,{type:`button`,class:`cmp-link`},i());u.onclick=()=>void B(e,n);let[d,f,m]=s?ae(s,n.cancel===!0):[`error`,r(),!0];[e.done,e.sending,F,e.busy]=[!s||oe(s),!1,!1,s?.body.outcome===`busy`],L(e.note,d,f,...m?[u]:[]);let h=s?.body.outcome===`accepted`?s.body.then:void 0,g=h&&l(h,{key:o?.key??``,command:e.copy,answerId:String(n.answerId??``)});g&&L(e.note,d,`${f} ${g}`),z(),e.note.scrollIntoView?.({block:`nearest`}),p&&s?.body.outcome===`accepted`&&setTimeout(()=>p(!!h&&!g),h&&!g?0:1200)}let X=(e,t,n,r,i)=>{let a=c(`button`,{type:`button`,class:`ask-opt`,role:e,"aria-checked":`false`},c(`b`,i?{"data-n":String(i)}:null,t),...n.filter(Boolean).map(e=>c(`small`,null,e)));return a.onclick=r,a};function Q(e,t){let n,r=K(t).map(e=>X(`radio`,G(e.label),[e.note&&G(e.note)],()=>(n=e.i,r.forEach((n,r)=>n.setAttribute(`aria-checked`,String(K(t)[r].i===e.i))),z()),e.i+1)),i=t.select?.copy!==void 0&&c(`button`,{type:`button`,class:`cmp-link`},ee());i&&(i.disabled=!navigator.clipboard,i.onclick=()=>void navigator.clipboard.writeText(t.select.copy).then(()=>L(e.note,`ok`,y()),()=>L(e.note,`error`,v())));let a=e=>C()&&e.hereOnly===!0||g()&&e.next===`pane`,o=r.filter((e,n)=>!a(K(t)[n])),s=r.filter(e=>!o.includes(e));s.forEach(e=>e.disabled=!0);let l=s.length>0?c(`p`,{class:`ask-why ask-reason`,id:`ask-why-${++ce}`},f()):void 0;return l&&s.forEach(e=>e.setAttribute(`aria-describedby`,l.id)),e.pick=()=>n===void 0?void 0:{choice:n},e.first=V(e.el,[{opts:r,multiple:!1,answered:()=>n!==void 0}],()=>e.send),e.controls=o,[c(`pre`,{class:`ask-title`},G(t.select.title)),c(`div`,{class:`ask-opts`,role:`radiogroup`,"aria-label":_()},...r),...l?[l]:[],c(`div`,{class:`ask-acts`},e.send,e.cancel,i)]}function le(e,t){let n=t.questions.map(()=>({picks:new Set,text:c(`textarea`,{rows:`1`,maxlength:`8192`,class:`ask-own`,placeholder:k(),"aria-label":O()}),note:c(`input`,{type:`text`,maxlength:`2048`,class:`ask-own ask-memo`,placeholder:S(),"aria-label":x()})})),r=[],i=t.questions.map((t,i)=>{let a=n[i],o=t.multiple?`checkbox`:`radio`,s=t.options.map((e,n)=>X(o,e.title,[e.description,e.preview&&b()],()=>{t.multiple||(a.picks.clear(),a.text.value=``),a.picks.has(n)?a.picks.delete(n):a.picks.add(n),s.forEach((e,t)=>e.setAttribute(`aria-checked`,String(a.picks.has(t)))),z()}));return a.text.oninput=()=>(t.multiple||(a.picks.clear(),s.forEach(e=>e.setAttribute(`aria-checked`,`false`))),z()),e.controls.push(...s,a.text,a.note),r.push({opts:s,multiple:!!t.multiple,own:a.text,note:a.note,answered:()=>a.picks.size>0||a.text.value.trim()!==``}),c(`div`,{class:`ask-one`},t.header&&c(`b`,{class:`ask-head`},t.header),c(`p`,{class:`ask-q`,...t.question.length>U?{"data-long":``}:{}},t.question),c(`div`,{class:`ask-opts`,role:t.multiple?`group`:`radiogroup`,"aria-label":E()},...s),a.text,a.note)});return e.pick=()=>n.every(e=>e.picks.size||e.text.value.trim())?{answers:n.map(e=>q(e.picks,e.text.value,e.note.value))}:void 0,e.first=V(e.el,r,()=>e.send),[...i,c(`div`,{class:`ask-acts`},e.send,e.cancel)]}function ue(e){let t=e.asks??(e.ask?[e.ask]:[]),n=t.length>1,r=e.answer,i={copy:r?.select?.copy,key:Z(e),el:c(`section`,{class:`ask`}),note:c(`p`,{class:`ask-note`,role:`status`,"aria-live":`polite`}),controls:[],pick:()=>void 0,done:!1,sending:!1};r&&((i.send=c(`button`,{type:`button`,class:`ask-send`},ne())).onclick=()=>void(i.pick()&&B(i,J(r,i.pick(),crypto.randomUUID()))));let a=e.tool===`secret_drop`;r&&!a&&ie(r,C())&&((i.cancel=c(`button`,{type:`button`,class:`ask-cancel`},s())).onclick=()=>void B(i,Y(r,crypto.randomUUID())));let l=c(`p`,{class:`ask-term`},e.why&&t.length?e.why:`${n?d():u()} ${n||!t[0]?``:H(t[0])}`.trim()),f=o&&e.tool!==`secret_drop`&&c(`button`,{type:`button`,class:`cmp-link`},m());f&&(f.onclick=o.show);let p=e.answer?.twin&&e.tool&&e.tool!==`dialog`?[c(`p`,{class:`ask-why`},T({tool:e.tool}))]:[];return i.el.append(...p,...r&&!a?r.select?Q(i,r):le(i,r):[...t.length?t.map(e=>W(e,n)):[c(`p`,{class:`ask-why`},a?C()?P():te():e.why??R())],c(`div`,{class:`ask-acts`},a?c(`p`,{class:`ask-term`},u()):l,f)],i.note),i.cancel&&i.controls.push(i.cancel),i}let $=(t,n)=>{let r=document.activeElement;A&&A!==n&&(A.focus=A.el.contains(r)?r:void 0),[w,A,j]=[t,n,n?.send?n:j],e.replaceChildren(...n?[n.el]:[]),n&&se(n.el),z(),n?.focus&&(!document.activeElement||document.activeElement===document.body)&&n.focus.focus()};return{enter(){let e=A&&!A.done?A.first?.():void 0;return!!(e&&!e.disabled&&(e.focus(),1))},cancel(){let e=A&&!A.done?A.cancel:void 0;return!!(e&&!e.disabled&&(e.click(),1))},sending:()=>F,update(e,t,n){[M,N]=[t,n],e&&(I=void clearTimeout(I)),!e&&(A?.done||A?.sending)?I??=setTimeout(()=>(I=void 0,$()),6e3):e?A&&(Z(e)===A.key||!e.answer&&(A.done||A.sending)&&e.callId===w?.callId)?((A.busy||A.sending)&&!e.answer?A.spell=!0:A.busy&&A.spell&&e.answer&&([A.done,A.busy]=[!1,!1],L(A.note,``,D())),w=e):$(e,j?.key===Z(e)&&!j.done?j:ue(e)):$(),z()}}}export{Q 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{Ot as o,Qt as s,ft as c,t as l}from"./index-Ci_M1nWI.js";var u=((t={},n={})=>(n.locale??e())===`zh-TW`?`請在終端機中回答。`:`Answer it in the terminal.`),d=((t={},n={})=>(n.locale??e())===`zh-TW`?`請在終端機中回答。`:`Answer them in the terminal.`),f=((t={},n={})=>(n.locale??e())===`zh-TW`?`作用在那台機器本身畫面的選項,從這裡不能選。`:`Choices that act on the machine's own screen are not available from here.`),p=((t={},n={})=>(n.locale??e())===`zh-TW`?`下方還有 ▾`:`More below ▾`),m=((t={},n={})=>(n.locale??e())===`zh-TW`?`也可以自己輸入答案。`:`It also takes your own words.`),h=((t={},n={})=>(n.locale??e())===`zh-TW`?`可以複選。`:`It takes several choices.`),g=((t={},n={})=>(n.locale??e())===`zh-TW`?`已取消。`:`Cancelled.`),_=((t={},n={})=>(n.locale??e())===`zh-TW`?`選擇`:`Choices`),v=((t={},n={})=>(n.locale??e())===`zh-TW`?`瀏覽器拒絕存取剪貼簿。`:`The browser refused the clipboard.`),y=((t={},n={})=>(n.locale??e())===`zh-TW`?`已複製到這台裝置的剪貼簿。`:`Copied to this device's clipboard.`),ee=((t={},n={})=>(n.locale??e())===`zh-TW`?`複製指令`:`Copy command`),b=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個選項有預覽;請在終端機中查看。`:`It has a preview; see it in the terminal.`),x=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註`:`Note`),S=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註(選填)`:`Note (optional)`),C=e=>`Opened while ${e?.tool} was running; it may not be about that call.`,w=e=>`在 ${e?.tool} 執行時開啟,不一定與該呼叫有關。`,T=((t,n={})=>(n.locale??e())===`zh-TW`?w(t):C(t)),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`選項`:`Options`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`另一個答案沒有被採用;這個可以送出。`:`The other answer was not taken; this one can go.`),O=((t={},n={})=>(n.locale??e())===`zh-TW`?`你的答案`:`Your own answer`),k=((t={},n={})=>(n.locale??e())===`zh-TW`?`或自己輸入答案`:`Or type your own answer`),A=((t={},n={})=>(n.locale??e())===`zh-TW`?`問題已變更,請重新閱讀。`:`The question changed; read it again.`),j=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 讀不懂這個答案。`:`The session could not read that answer.`),M=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個答案不符合問題。`:`That answer does not fit the question.`),N=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 拒絕了這個答案。`:`The session refused that answer.`),P=((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.`),te=((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.`),ne=((t={},n={})=>(n.locale??e())===`zh-TW`?`送出答案`:`Send answer`),re=((t={},n={})=>(n.locale??e())===`zh-TW`?`顯示終端機`:`Show terminal`),F=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中關閉。`:`It was dismissed in the terminal.`),I=((t={},n={})=>(n.locale??e())===`zh-TW`?`它已不再開啟。`:`It is no longer open.`),L=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中回答。`:`It was already answered in the terminal.`),R=((t={},n={})=>(n.locale??e())===`zh-TW`?`它在等待對話框。`:`It waits on a dialog.`),z={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1};function B(e,t,n,r,i){let{q:a}=n,o=r[a],s=z[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`){let e=r[a-1],i=n.part===`opt`?o.own||o.note:n.part===`own`&&o.note;return t?n.part===`opt`&&e?{to:{q:a-1,part:e.note?`note`:e.own?`own`:`opt`}}:void 0:i||a===r.length-1?void 0:{to:{q:a+1,part:`opt`}}}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 V(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,c=!1;return e.addEventListener(`keydown`,i=>{i.key===` `&&(c=!0);let o=a(i.target);if(!o||i.ctrlKey||i.altKey||i.metaKey||i.isComposing)return;let l=i.target;if(o.part!==`opt`&&(i.key===`ArrowUp`?l.selectionStart!==0:i.key===`ArrowDown`&&l.selectionEnd!==l.value.length))return;let u=B(i.key,i.shiftKey,o,t.map(e=>({options:e.opts.length,multiple:e.multiple,own:!!e.own,note:!!e.note})),t.map(e=>e.answered()));if(!u||(i.preventDefault(),i.repeat&&[`Enter`,` `].includes(i.key)))return;if(s=i.key===` `,u.pick!==void 0){let e=t[o.q].opts[u.pick];e.getAttribute(`aria-checked`)!==`true`&&e.click()}let d=u.to===`send`?void 0:t[u.to.q],f=u.to===`send`?n():u.to.part===`opt`?d.opts[u.to.o??r(d)]:u.to.part===`own`?d.own:d.note;f&&!f.disabled&&(e.dispatchEvent(new CustomEvent(`ask-reveal`,{detail:f})),f.focus())}),e.addEventListener(`keyup`,e=>{e.key===` `&&((s||!c)&&e.preventDefault(),s=c=!1)}),()=>t[0]?.opts[r(t[0])]}var H=e=>e.multiple?h():e.freeform&&e.options.length?m():``,U=90,W=(e,t)=>c(`div`,{class:`ask-one`},e.header&&c(`b`,{class:`ask-head`},e.header),c(`p`,{class:`ask-q`,...e.question.length>U?{"data-long":``}:{}},e.question),e.context&&c(`div`,{class:`ask-ctx`},e.context),e.options.length>0&&c(`ol`,{class:`ask-opts`,"aria-label":E()},...e.options.map(e=>c(`li`,{class:`ask-opt`},c(`b`,null,e.title),e.description&&c(`small`,null,e.description)))),t&&H(e)&&c(`small`,{class:`ask-how`},H(e))),G=e=>e.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\p{Cf}]/gu,`�`),K=e=>(e.select?.choices??[]).map((e,t)=>({...e,i:t})),q=(e,t,n)=>({...e.size?{choices:[...e].sort((e,t)=>e-t)}:{},...t.trim()?{text:t}:{},...n.trim()?{note:n}:{}}),J=(e,t,n)=>({dialog:e.dialog,digest:e.digest,answerId:n,...t}),Y=(e,t)=>({dialog:e.dialog,digest:e.digest,answerId:t,cancel:!0}),ie=(e,t)=>e.cancel===!0&&!(t&&e.select?.choices.every(e=>e.hereOnly)),X={digest:A,"not-allowed":M,malformed:j};function ae(e,i=!1){let{outcome:a,reason:s,by:c}=e.body;return a===`accepted`?[`ok`,i?g():n()]:a===`stale`?[`error`,c===`local`?L():c===`cancel`?F():I()]:a===`rejected`?[`error`,(Object.hasOwn(X,String(s))?X[String(s)]:N)()]:a===`busy`?[`error`,t()]:a===`unknown`||e.status===504?[`error`,r(),!0]:[`error`,s??o({status:e.status})]}var oe=e=>[`accepted`,`stale`,`busy`,`unknown`].includes(String(e.body.outcome))||e.status===504,Z=e=>e.answer?`d\n${e.answer.dialog}\n${e.answer.digest}`:`c\n${e.callId}\n${e.why??``}`;function se(e){if(e.dataset.cued)return;e.dataset.cued=`1`;let t=()=>{e.toggleAttribute(`data-more`,e.scrollHeight-e.scrollTop-e.clientHeight>4);for(let t of e.querySelectorAll(`.ask-acts`))t.dataset.cue=p()};for(let n of[`scroll`,`input`])e.addEventListener(n,t,{passive:!0});typeof ResizeObserver<`u`&&new ResizeObserver(t).observe(e),typeof MutationObserver<`u`&&new MutationObserver(t).observe(e,{childList:!0,subtree:!0,characterData:!0}),typeof requestAnimationFrame<`u`&&requestAnimationFrame(t)}var ce=0;function Q(e,t,n=location.hostname!==`127.0.0.1`,o,p,m=re,h=!1){let g=()=>typeof h==`function`?h():h,C=()=>n||g(),w,A,j,M=!1,N,F=!1,I;for(let e of[`focusin`,`pointerdown`])document.addEventListener(e,e=>A&&!A.el.contains(e.target)&&(A.lost=void 0));let L=(e,t,n,...r)=>(e.dataset.tone=t,e.replaceChildren(n,...r)),z=()=>{if(!A)return;let e=document.activeElement;e&&e!==document.body&&e!==A.lost&&(A.lost=void 0),A.controls.forEach(e=>e.disabled=!M||F||A.done),A.send&&(A.send.disabled=!M||F||A.done||!A.pick()),N&&!M&&!F&&!A.done&&!A.sending?(L(A.note,``,N),A.away=!0):A.away&&(L(A.note,``,``),A.away=!1),e&&A.el.contains(e)&&e.disabled&&(A.lost=e);let t=A.lost;t&&!t.disabled&&A.el.contains(t)&&(!document.activeElement||document.activeElement===document.body)&&(t.focus(),A.lost=void 0)};async function B(e,n){[e.sending,F,e.spell]=[!0,!0,!1],z(),L(e.note,``,a());let s=await t(`answer`,n).catch(()=>void 0),u=c(`button`,{type:`button`,class:`cmp-link`},i());u.onclick=()=>void B(e,n);let[d,f,m]=s?ae(s,n.cancel===!0):[`error`,r(),!0];[e.done,e.sending,F,e.busy]=[!s||oe(s),!1,!1,s?.body.outcome===`busy`],L(e.note,d,f,...m?[u]:[]);let h=s?.body.outcome===`accepted`?s.body.then:void 0,g=h&&l(h,{key:o?.key??``,command:e.copy,answerId:String(n.answerId??``)});g&&L(e.note,d,`${f} ${g}`),z(),e.note.scrollIntoView?.({block:`nearest`}),p&&s?.body.outcome===`accepted`&&setTimeout(()=>p(!!h&&!g),h&&!g?0:1200)}let X=(e,t,n,r,i)=>{let a=c(`button`,{type:`button`,class:`ask-opt`,role:e,"aria-checked":`false`},c(`b`,i?{"data-n":String(i)}:null,t),...n.filter(Boolean).map(e=>c(`small`,null,e)));return a.onclick=r,a};function Q(e,t){let n,r=K(t).map(e=>X(`radio`,G(e.label),[e.note&&G(e.note)],()=>(n=e.i,r.forEach((n,r)=>n.setAttribute(`aria-checked`,String(K(t)[r].i===e.i))),z()),e.i+1)),i=t.select?.copy!==void 0&&c(`button`,{type:`button`,class:`cmp-link`},ee());i&&(i.disabled=!navigator.clipboard,i.onclick=()=>void navigator.clipboard.writeText(t.select.copy).then(()=>L(e.note,`ok`,y()),()=>L(e.note,`error`,v())));let a=e=>C()&&e.hereOnly===!0||g()&&e.next===`pane`,o=r.filter((e,n)=>!a(K(t)[n])),s=r.filter(e=>!o.includes(e));s.forEach(e=>e.disabled=!0);let l=s.length>0?c(`p`,{class:`ask-why ask-reason`,id:`ask-why-${++ce}`},f()):void 0;return l&&s.forEach(e=>e.setAttribute(`aria-describedby`,l.id)),e.pick=()=>n===void 0?void 0:{choice:n},e.first=V(e.el,[{opts:r,multiple:!1,answered:()=>n!==void 0}],()=>e.send),e.controls=o,[c(`pre`,{class:`ask-title`},G(t.select.title)),c(`div`,{class:`ask-opts`,role:`radiogroup`,"aria-label":_()},...r),...l?[l]:[],c(`div`,{class:`ask-acts`},e.send,e.cancel,i)]}function le(e,t){let n=t.questions.map(()=>({picks:new Set,text:c(`textarea`,{rows:`1`,maxlength:`8192`,class:`ask-own`,placeholder:k(),"aria-label":O()}),note:c(`input`,{type:`text`,maxlength:`2048`,class:`ask-own ask-memo`,placeholder:S(),"aria-label":x()})})),r=[],i=t.questions.map((t,i)=>{let a=n[i],o=t.multiple?`checkbox`:`radio`,s=t.options.map((e,n)=>X(o,e.title,[e.description,e.preview&&b()],()=>{t.multiple||(a.picks.clear(),a.text.value=``),a.picks.has(n)?a.picks.delete(n):a.picks.add(n),s.forEach((e,t)=>e.setAttribute(`aria-checked`,String(a.picks.has(t)))),z()}));return a.text.oninput=()=>(t.multiple||(a.picks.clear(),s.forEach(e=>e.setAttribute(`aria-checked`,`false`))),z()),e.controls.push(...s,a.text,a.note),r.push({opts:s,multiple:!!t.multiple,own:a.text,note:a.note,answered:()=>a.picks.size>0||a.text.value.trim()!==``}),c(`div`,{class:`ask-one`},t.header&&c(`b`,{class:`ask-head`},t.header),c(`p`,{class:`ask-q`,...t.question.length>U?{"data-long":``}:{}},t.question),c(`div`,{class:`ask-opts`,role:t.multiple?`group`:`radiogroup`,"aria-label":E()},...s),a.text,a.note)});return e.pick=()=>n.every(e=>e.picks.size||e.text.value.trim())?{answers:n.map(e=>q(e.picks,e.text.value,e.note.value))}:void 0,e.first=V(e.el,r,()=>e.send),[...i,c(`div`,{class:`ask-acts`},e.send,e.cancel)]}function ue(e){let t=e.asks??(e.ask?[e.ask]:[]),n=t.length>1,r=e.answer,i={copy:r?.select?.copy,key:Z(e),el:c(`section`,{class:`ask`}),note:c(`p`,{class:`ask-note`,role:`status`,"aria-live":`polite`}),controls:[],pick:()=>void 0,done:!1,sending:!1};r&&((i.send=c(`button`,{type:`button`,class:`ask-send`},ne())).onclick=()=>void(i.pick()&&B(i,J(r,i.pick(),crypto.randomUUID()))));let a=e.tool===`secret_drop`;r&&!a&&ie(r,C())&&((i.cancel=c(`button`,{type:`button`,class:`ask-cancel`},s())).onclick=()=>void B(i,Y(r,crypto.randomUUID())));let l=c(`p`,{class:`ask-term`},e.why&&t.length?e.why:`${n?d():u()} ${n||!t[0]?``:H(t[0])}`.trim()),f=o&&e.tool!==`secret_drop`&&c(`button`,{type:`button`,class:`cmp-link`},m());f&&(f.onclick=o.show);let p=e.answer?.twin&&e.tool&&e.tool!==`dialog`?[c(`p`,{class:`ask-why`},T({tool:e.tool}))]:[];return i.el.append(...p,...r&&!a?r.select?Q(i,r):le(i,r):[...t.length?t.map(e=>W(e,n)):[c(`p`,{class:`ask-why`},a?C()?P():te():e.why??R())],c(`div`,{class:`ask-acts`},a?c(`p`,{class:`ask-term`},u()):l,f)],i.note),i.cancel&&i.controls.push(i.cancel),i}let $=(t,n)=>{let r=document.activeElement;A&&A!==n&&(A.focus=A.el.contains(r)?r:void 0),[w,A,j]=[t,n,n?.send?n:j],e.replaceChildren(...n?[n.el]:[]),n&&se(n.el),z(),n?.focus&&(!document.activeElement||document.activeElement===document.body)&&n.focus.focus()};return{enter(){let e=A&&!A.done?A.first?.():void 0;return!!(e&&!e.disabled&&(e.focus(),1))},cancel(){let e=A&&!A.done?A.cancel:void 0;return!!(e&&!e.disabled&&(e.click(),1))},sending:()=>F,update(e,t,n){[M,N]=[t,n],e&&(I=void clearTimeout(I)),!e&&(A?.done||A?.sending)?I??=setTimeout(()=>(I=void 0,$()),6e3):e?A&&(Z(e)===A.key||!e.answer&&(A.done||A.sending)&&e.callId===w?.callId)?((A.busy||A.sending)&&!e.answer?A.spell=!0:A.busy&&A.spell&&e.answer&&([A.done,A.busy]=[!1,!1],L(A.note,``,D())),w=e):$(e,j?.key===Z(e)&&!j.done?j:ue(e)):$(),z()}}}export{Q as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./rolldown-runtime-DK3Fl9T5.js";import{m as t}from"./towermodel-BpgH7epr.js";import{t as n}from"./runtime-ZX6HkxDa.js";import{K as r,Ot as i}from"./index-
|
|
1
|
+
import{t as e}from"./rolldown-runtime-DK3Fl9T5.js";import{m as t}from"./towermodel-BpgH7epr.js";import{t as n}from"./runtime-ZX6HkxDa.js";import{K as r,Ot as i}from"./index-Ci_M1nWI.js";var a=((e={},t={})=>(t.locale??n())===`zh-TW`?`沒有符合這個號碼的請求。`:`No request has that number.`),o=((e={},t={})=>(t.locale??n())===`zh-TW`?`這個請求已經不在了。`:`That request is gone.`),s=((e={},t={})=>(t.locale??n())===`zh-TW`?`連續輸入三次錯誤號碼,所以所有等待中的請求都已拒絕。請按「新的配對碼」重新配對。`:`Three wrong numbers in a row, so every waiting request was denied. Press New code and pair again.`),c=((e={},t={})=>(t.locale??n())===`zh-TW`?`這個請求已經變了,請重新看過。`:`That request changed. Look at it again.`),l=((e={},t={})=>(t.locale??n())===`zh-TW`?`這個請求已經不在了,或已逾時。`:`That request is gone or has timed out.`),u=((e={},t={})=>(t.locale??n())===`zh-TW`?`這個團隊沒有在這台裝置上執行。`:`That team is not running on this device.`),d=((e={},t={})=>(t.locale??n())===`zh-TW`?`已在該裝置上取消。`:`It was cancelled at the device.`),f=((e={},t={})=>(t.locale??n())===`zh-TW`?`你已從這裡回答。`:`You answered it from here.`),p=((e={},t={})=>(t.locale??n())===`zh-TW`?`已在該裝置上回答。`:`Answered at the device itself.`),m=((e={},t={})=>(t.locale??n())===`zh-TW`?`已由團隊的另一個控制端回答。`:`Answered by another controller of this team.`),h=e=>`The answer was not sent: ${e?.reason}`,g=e=>`答案沒有送出:${e?.reason}`,_=((e,t={})=>(t.locale??n())===`zh-TW`?g(e):h(e)),v=((e={},t={})=>(t.locale??n())===`zh-TW`?`問題在有人回答前就結束了。`:`It ended before anyone answered it.`),y=((e={},t={})=>(t.locale??n())===`zh-TW`?`已送出你的答案;對方裝置還沒關閉這個問題。`:`Your answer was sent; the device has not closed the question yet.`),b=((e={},t={})=>(t.locale??n())===`zh-TW`?`你已不再負責回答這台裝置的問題;問題在那邊仍未結束。`:`You no longer answer this device's questions; it is still open there.`);function x(e){switch(e){case`sent`:return y();case`done-here`:return f();case`done-other`:return m();case`done-local`:return p();case`cancelled`:return d();case`expired`:return v();case`withdrawn`:return b()}}var S=e=>typeof e==`object`&&!!e&&!Array.isArray(e),C=e=>typeof e==`string`,w=e=>Array.isArray(e)&&e.every(e=>S(e)&&C(e.title));function T(e){let{dialog:t,dialogId:n,digest:r}=e.data;if(!C(t)||!C(n)||!C(r))return;let i;try{i=JSON.parse(t)}catch{return}if(!S(i))return;let{select:a,questions:o,cancel:s}=i,c={dialog:n,digest:r,...s===!0?{cancel:!0}:{}};if(S(a)&&C(a.title)&&Array.isArray(a.choices)&&a.choices.every(e=>S(e)&&C(e.label)))return{callId:n,tool:`dialog`,answer:{...c,select:a}};if(Array.isArray(o)&&o.length>0&&o.every(e=>S(e)&&C(e.question)&&w(e.options)))return{callId:n,tool:`dialog`,answer:{...c,questions:o}}}var E=e=>e.cancel===!0?{cancel:!0}:e.choice===void 0?{answers:e.answers}:{choice:e.choice},D=e({confirmActions:()=>M,confirmWhy:()=>N,forwardedAnswer:()=>P,joined:()=>k,lanActions:()=>I,lanReading:()=>L,outcome:()=>O,proposalActions:()=>F,taken:()=>j,waitActions:()=>A}),O=e=>{let t=e.body.outcome;return t===void 0?e.status===504?`unknown`:e.ok&&(e.body.accepted===!0||Array.isArray(e.body.entries))?`accepted`:`refused`:t===`accepted`?`accepted`:t===`unknown`?`unknown`:`refused`},k=e=>e.replace(/^([A-Z])(?=[a-z])/,e=>e.toLowerCase()),A=(e,n)=>({tell:t=>n(`input`,{text:t,as:`send`,answers:e.id}),press:(n,i)=>r(`${t(e.ws)}/memory`,{op:`press`,id:e.id,act:n,...i}),read:()=>r(`${t(e.ws)}/memory`,{op:`read`}),goto:{view:`session`,ws:e.ws,key:e.tower}}),j=e=>e.ok&&e.body.outcome===void 0?{...e,body:{...e.body,outcome:`accepted`}}:e,M=e=>{let t=t=>r(`link/confirm-answer`,{dialogId:e.dialogId,digest:e.digest,allow:t}).then(j);return{allow:()=>t(!0),deny:()=>t(!1)}},N=e=>{let t=String(e.body.reason??e.body.error??``);return[[/^That request is gone/,l],[/^That team is not running/,u],[/^That request changed/,c]].find(([e])=>e.test(t))?.[1]()??(t||i({status:e.status}))},P=e=>async(t,n)=>{let a=await r(`link/dialog-answer`,{device:e.device,dialogId:e.dialogId,digest:e.digest,answer:E(n)});return a.ok?j(a):{ok:!1,status:a.status,body:{reason:_({reason:a.body.reason??i({status:a.status})})}}},F=e=>({confirm:()=>r(`${t(e.ws)}/memory`,{op:`confirm`,proposal:e.id,rev:e.rev()}),reject:()=>r(`${t(e.ws)}/memory`,{op:`reject`,proposal:e.id})}),I=e=>({approve:t=>e(`lan/approve`,{number:t}).then(j),deny:t=>e(`lan/approve`,{deny:t}).then(e=>e.ok&&e.body.denied===0?{...e,ok:!1,body:{error:`gone`,reason:o()}}:j(e)),denyAll:()=>e(`lan/approve`,{deny:`all`}).then(j)});function L(e){let t=!e.ok&&e.body.error===`no_match`&&Number(e.body.denied)>0;return{answer:e.ok||t?``:e.body.error===`no_match`?a():String(e.body.reason??i({status:e.status})),verdict:t?s():``}}export{k as a,O as c,x as d,T as f,P as i,F as l,M as n,I as o,N as r,L as s,D as t,A as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./runtime-ZX6HkxDa.js";import{t}from"./sending-aEpvzoz2.js";import{t as n}from"./sentencepack-DtYqpppS.js";import{c as r,d as i,o as a,u as o}from"./towerturns-Ci8paKaq.js";import{At as s,K as c,Ot as l,Qt as ee,Z as u,b as d,ft as f,q as te}from"./index-Ci_M1nWI.js";var ne=((t={},n={})=>(n.locale??e())===`zh-TW`?`附加檔案`:`Attach files`),p=((t={},n={})=>(n.locale??e())===`zh-TW`?`確認進入自動模式`:`Start auto mode`),m=e=>`You said: “${e?.said}”. Once it is on, agents cannot ask you and what needs you is parked until you are back.`,h=e=>`你說了:「${e?.said}」。進入後各代理不能再問你,需要你的事會先暫放,等你回來。`,g=((t,n={})=>(n.locale??e())===`zh-TW`?h(t):m(t)),_=((t={},n={})=>(n.locale??e())===`zh-TW`?`主塔台要求進入自動模式`:`The head tower asks to start auto mode`),v=(e,t)=>n(`auto_confirm_title`,_,e,t),y=((t={},n={})=>(n.locale??e())===`zh-TW`?`已進入自動模式。`:`Auto mode is on.`),b=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個請求已過期或被取代,請再請主塔台提出一次。`:`This request expired or was replaced. Ask the head tower again.`),x=(e,t)=>n(`auto_stale`,b,e,t),S=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個 session 已經結束`:`This session has ended`),C=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個隊友 run 由隊友的訊息驅動。你可以在這裡看它的通訊,但不能寫給它。`:`A teammate's message drives this ally run. You can read its comms here; you cannot write to it.`),w=((t={},n={})=>(n.locale??e())===`zh-TW`?`請在上方或終端機回答。`:`Answer above or in pi`),T=((t={},n={})=>(n.locale??e())===`zh-TW`?`它在等待對話框;請在它的終端機中回答。`:`It waits on a dialog; answer it in its terminal.`),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個 session 已不再即時;紀錄仍可閱讀。`:`This session is no longer live; its history stays readable.`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個單位沒有即時的 pi 窗格,無處可輸入。`:`No live pi pane backs this unit, so there is nothing to type into.`),O=((t={},n={})=>(n.locale??e())===`zh-TW`?`串流中斷;要等它恢復才能送出。`:`The stream is down; sending waits for it to come back.`),k=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個 run 是塔台為事件啟動的。你可以在這裡看它的通訊;要跟它說話,請寫給塔台。`:`The tower started this run for events. You can read its comms here; to talk to it, write to the tower.`),A=(e,t)=>n(`blocked_run`,k,e,t),j=((t={},n={})=>(n.locale??e())===`zh-TW`?`現在連不上這台機器;連上之後才能傳送。`:`This machine cannot be reached right now; sending waits until it can.`),M=((t={},n={})=>(n.locale??e())===`zh-TW`?`指令`:`Commands`),re=((t={},n={})=>(n.locale??e())===`zh-TW`?`配對、遠端存取、Wi-Fi、伺服器與預設檢視要在這台電腦的頁面或終端機操作,配對裝置不能做。`:`Pairing, remote access, Wi-Fi, the server, and the default view are managed on this computer’s own page or terminal, not from a paired device.`),ie=((t={},n={})=>(n.locale??e())===`zh-TW`?`再取一次`:`Fetch again`),ae=((t={},n={})=>(n.locale??e())===`zh-TW`?`已經沒有排隊的訊息了:它們已送達,或在終端機的輸入框裡。`:`Nothing is queued any more: the messages were delivered, or they are in the terminal’s editor.`),oe=((t={},n={})=>(n.locale??e())===`zh-TW`?`排隊中的訊息已放進輸入框,改完再送出。`:`The queued messages are in the box. Edit them and send.`),se=((t={},n={})=>(n.locale??e())===`zh-TW`?`正在取回排隊中的訊息…`:`Taking the queued messages back…`),ce=((t={},n={})=>(n.locale??e())===`zh-TW`?`未確認。若訊息已被取回,請再取一次;否則它們仍在終端機裡。`:`Not confirmed. If the messages were taken back, fetch them again; otherwise they are still in the terminal.`),N=e=>`${e?.command} ends this session or switches its pane to another one.`,P=e=>`${e?.command} 會結束這個 session,或把它的窗格切換到別的 session。`,le=((t,n={})=>(n.locale??e())===`zh-TW`?P(t):N(t)),F=e=>`${e?.name} is larger than 20 MB.`,I=e=>`${e?.name} 超過 20 MB。`,ue=((t,n={})=>(n.locale??e())===`zh-TW`?I(t):F(t)),de=((t={},n={})=>(n.locale??e())===`zh-TW`?`做完再送`:`After this`),L=((t={},n={})=>(n.locale??e())===`zh-TW`?`接續與主塔台的對話`:`Continue the conversation with the head tower`),R=(e,t)=>n(`head_continues`,L,e,t),z=((t={},n={})=>(n.locale??e())===`zh-TW`?`叫醒主塔台`:`Wakes the head tower`),fe=(e,t)=>n(`head_wakes`,z,e,t),B=e=>`From your message: ${e?.text}`,V=e=>`引自你的訊息:${e?.text}`,H=((t,n={})=>(n.locale??e())===`zh-TW`?V(t):B(t)),pe=((t={},n={})=>(n.locale??e())===`zh-TW`?`訊息`:`Message`),U=e=>`Message ${e?.name}`,W=e=>`傳訊息給 ${e?.name}`,me=((t,n={})=>(n.locale??e())===`zh-TW`?W(t):U(t)),he=((t={},n={})=>(n.locale??e())===`zh-TW`?`隊友的 run 正在回應・送出訊息會另外喚醒塔台跑你自己的 run`:`An ally run is answering a teammate · a message wakes a run of your own`),ge=(e,t)=>n(`placeholder_ally`,he,e,t),_e=((t={},n={})=>(n.locale??e())===`zh-TW`?`接續與塔台的老闆對話`:`Continues the boss conversation`),ve=(e,t)=>n(`placeholder_conversation`,_e,e,t),ye=((t={},n={})=>(n.locale??e())===`zh-TW`?`送給正在跑的事件 run・它會在這裡回答`:`Goes to the running event run · it answers here`),be=((t={},n={})=>(n.locale??e())===`zh-TW`?`反覆當機後暫停中・送出訊息就會喚醒`:`Held after repeated crashes · a message wakes it`),xe=((t={},n={})=>(n.locale??e())===`zh-TW`?`喚醒塔台`:`Wakes the tower`),Se=(e,t)=>n(`placeholder_wake`,xe,e,t),Ce=e=>`Send ${e?.command}`,we=e=>`送出 ${e?.command}`,Te=((t,n={})=>(n.locale??e())===`zh-TW`?we(t):Ce(t)),Ee=((t={},n={})=>(n.locale??e())===`zh-TW`?`已照原文送出;你的修改留在這裡,尚未送出。`:`Sent as it was; your edits stayed here, unsent.`),De=((t={},n={})=>(n.locale??e())===`zh-TW`?`停止`:`Stop`),Oe=((t={},n={})=>(n.locale??e())===`zh-TW`?`要停止目前的任務嗎?佇列中的訊息會退回它的終端機編輯器。`:`Stop the current task? Queued messages go back to its terminal editor.`),ke=((t={},n={})=>(n.locale??e())===`zh-TW`?`它在等待對話框:請在終端機中回答。`:`It is waiting on a dialog: answer it in the terminal.`),Ae=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個 session 上還有另一個輸入在途中。`:`Another input to this session is still on its way.`),je=((t={},n={})=>(n.locale??e())===`zh-TW`?`終端機的輸入框裡除了排隊中的訊息與草稿,還有其他內容(期間有人輸入,或 pi 展開了訊息)。訊息在輸入框裡,請查看終端機。`:`The terminal’s editor holds something other than the queued messages and the draft (typed meanwhile, or a message pi expanded). The messages are in it; check the terminal.`),Me=((t={},n={})=>(n.locale??e())===`zh-TW`?`它在等待連結請求時,配對裝置只能送出 Escape。請在這台電腦的頁面或終端機核准。`:`While it waits on a link request, a paired device can only send Escape. Approve it on this computer’s own page or terminal.`),Ne=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個 session 沒有輸入框,無法把訊息取回。`:`This session has no editor to take the messages back into.`),Pe=((t={},n={})=>(n.locale??e())===`zh-TW`?`pi 的取回按鍵(keybindings.json 裡的 app.message.dequeue)不是這個頁面能送出的按鍵。請在終端機裡按。`:`pi’s dequeue key (app.message.dequeue in its keybindings.json) is not one this page can send. Press it in the terminal.`),Fe=((t={},n={})=>(n.locale??e())===`zh-TW`?`無法清掉終端機輸入框裡的訊息。它們在那裡,不在這裡。`:`The messages could not be cleared from the terminal’s editor. They are there, not here.`),Ie=e=>`pi did not take its queue back; its dequeue key may not be ${e?.key}. Check the terminal.`,Le=e=>`pi 沒有取回它的佇列;它的取回按鍵可能不是 ${e?.key}。請查看終端機。`,Re=((t,n={})=>(n.locale??e())===`zh-TW`?Le(t):Ie(t)),ze=((t={},n={})=>(n.locale??e())===`zh-TW`?`一次按太多鍵了。請一秒後再試。`:`Too many keys at once. Try again in a second.`),Be=((t={},n={})=>(n.locale??e())===`zh-TW`?`取回逾時,或按鍵送出後 session 已有變動:訊息在終端機的輸入框裡,不在這裡。`:`The take-back timed out, or the session changed, after the key went: the messages are in the terminal’s editor, not here.`),Ve=((t={},n={})=>(n.locale??e())===`zh-TW`?`排隊中的訊息太長,帶不回這裡。它們在終端機的輸入框裡。`:`The queued messages are too long to bring here. They are in the terminal’s editor.`),G=((t={},n={})=>(n.locale??e())===`zh-TW`?`未確認。再次送出前請先查看終端機。`:`Not confirmed. Check the terminal before sending again.`),He=((t={},n={})=>(n.locale??e())===`zh-TW`?`上傳中…`:`Uploading…`),Ue=((t={},n={})=>(n.locale??e())===`zh-TW`?`原文已送到 session;這裡是你編輯過、尚未送出的副本。`:`The original already went to the session; what is here is your edited copy, unsent.`),We=e=>/^\/(\S{0,64})$/.exec(e)?.[1],Ge=(e,t,n)=>(e+n+t)%t;function Ke(e,t){let n=f(`ul`,{class:`slash`,id:`slash`,role:`listbox`,"aria-label":M()}),r=[],i=0,a;e.setAttribute(`aria-controls`,`slash`);let o=()=>!n.hidden&&r.length>0,s=()=>(r=[],n.hidden=!0,e.removeAttribute(`aria-activedescendant`)),c=()=>{n.replaceChildren(...r.map((e,t)=>{let n=f(`li`,{id:`slash-${t}`,role:`option`,"aria-selected":String(t===i)},f(`b`,null,`/${e.name}`),e.description&&f(`span`,null,e.description));return n.onmousedown=e=>e.preventDefault(),n.onclick=()=>l(e),n})),n.hidden=!r.length,r.length&&(e.setAttribute(`aria-activedescendant`,`slash-${i}`),n.children[i]?.scrollIntoView({block:`nearest`}))},l=t=>{e.value=`/${t.name} `,s(),e.focus(),e.dispatchEvent(new Event(`input`))};return s(),e.addEventListener(`input`,()=>{let n=We(e.value),o=e.value;if(clearTimeout(a),n===void 0)return s();a=setTimeout(async()=>{let a=await t(n).catch(()=>void 0);if(e.value!==o)return;let s=a?.ok&&Array.isArray(a.body.commands)?a.body.commands:[];[r,i]=[s,0],c()},120)}),e.addEventListener(`blur`,s),e.addEventListener(`keydown`,e=>{if(!o()||e.isComposing||e.keyCode===229)return;let t=e.key;if(t===`ArrowDown`||t===`ArrowUp`)i=Ge(i,r.length,t===`ArrowDown`?1:-1),c();else if(t===`Enter`&&!e.shiftKey||t===`Tab`)l(r[i]);else if(t===`Escape`)s();else return;e.preventDefault(),e.stopImmediatePropagation()}),n}var qe=16384,Je=/^\s*\/(quit|exit|new|resume|fork|clone|import|reload)(?=\s|$)/,Ye=(e,t)=>t.wakes?void 0:e.match(Je)?.[0].trim(),K=new Map;function Xe(e,t,n,i){if(!e.ok)return[`error`,e.status===504?G({},i?{locale:i}:void 0):r(e,i)??e.body.reason??l({status:e.status},i?{locale:i}:void 0)];if(t&&!t.startsWith(n))return[`ok`,Ue()]}var Ze=e=>{try{return e?.startsWith(`[`)?JSON.parse(e):e?[`error`,e]:void 0}catch{return[`error`,e]}},Qe=(e,t)=>e!==``&&!e.startsWith(t)?Ee():``,$e=(e,t)=>e.startsWith(t)?e.slice(t.length).replace(/^\n/,``):e,q=(e,t)=>t.trim()?`${e}\n\n${t}`:e,J=new Map,et=54e4,Y=new Map,X=new Map,Z=e=>`sb-draft:${e}:take`;function tt(e,t=Date.now()){let n=Y.get(e);if(!n)try{let[t,r]=(sessionStorage.getItem(Z(e))??``).split(`:`);r&&Number(t)>0&&Y.set(e,n={id:r,at:Number(t)})}catch{}return n&&t-n.at>=et&&(Q(e),n=void 0),n?.id}function nt(e,t=Date.now()){let n=Array.from(crypto.getRandomValues(new Uint8Array(16)),e=>e.toString(16).padStart(2,`0`)).join(``);Y.set(e,{id:n,at:t});try{sessionStorage.setItem(Z(e),`${t}:${n}`)}catch{}return n}function Q(e){Y.delete(e);try{sessionStorage.removeItem(Z(e))}catch{}}function rt(e,t){let n=`sb-draft:${e}`;try{sessionStorage.setItem(n,q(t,sessionStorage.getItem(n)??``)),sessionStorage.setItem(`${n}:note`,JSON.stringify([`ok`,oe()]))}catch{X.set(e,q(t,X.get(e)??``))}}function it(e,t){let n=X.get(e);return X.delete(e),n===void 0?t:q(n,t)}var at=[`no_editor`,`stale`,`not_taken`,`changed`,`too_large`,`not_cleared`,`no_key`];function ot(e,t){let n=t?{locale:t}:void 0,r=typeof e.body.label==`string`?e.body.label:`?`;return e.status>=400&&e.status!==504?{no_key:()=>Pe({},n),no_editor:()=>Ne({},n),stale:()=>Be({},n),not_taken:()=>Re({key:r},n),changed:()=>je({},n),too_large:()=>Ve({},n),not_cleared:()=>Fe({},n),blocked:()=>ke({},n),local_only:()=>Me({},n),rate:()=>ze({},n),busy:()=>Ae({},n)}[e.body.error??``]?.():void 0}function st(e,t,n){t.ok&&typeof t.body.text==`string`&&(n?(n.box.value=q(t.body.text,n.box.value),n.save()):rt(e,t.body.text)),(t.ok||t.status===400||t.status===409&&at.includes(t.body.error??``))&&Q(e)}var ct=e=>e.live&&!e.ally;function $(e){if(!e.online)return e.away?j():O();if(!e.live)return E();if(!e.control)return e.run?A():e.ally?C():D();if(e.mark===`waiting`)return e.answerable?w():T()}function lt(e){if(e.online){if(!e.live)return S();if(!e.control&&(e.run||e.ally))return e.run?A():C()}}var ut=e=>e.wakes?e.held?be():e.allyLive?ge():e.eventRun?ye():e.head?e.conversation?R():fe():e.conversation?ve():Se():me({name:e.name}),dt=e=>({eventRun:!(!e?.bossIn||e.conversation),wakes:!!e,held:e?.state===`held`,conversation:!(!e?.conversation||e.conversation.closing),allyLive:!(!e?.allyRuns.length||e.run)});function ft(e,n,r,c=e=>te(`sessions/${encodeURIComponent(n)}/upload`,e)){let u=`sb-draft:${n}`,d=matchMedia(`(pointer: coarse)`).matches,p=f(`textarea`,{rows:`1`,maxlength:String(qe),"aria-label":pe(),enterkeyhint:d?`enter`:`send`}),m=f(`button`,{type:`submit`,class:`cmp-send`},i()),h=f(`button`,{type:`button`,class:`cmp-alt`},de()),g=f(`button`,{type:`button`,class:`cmp-alt cmp-stop`},De()),_=f(`input`,{type:`file`,multiple:``,hidden:``}),v=f(`button`,{type:`button`,class:`cmp-alt`,"aria-label":ne()},`+`),y=f(`p`,{class:`cmp-note`,role:`status`,"aria-live":`polite`}),b=Ke(p,e=>r(`commands`,{prefix:e})),x=f(`p`,{class:`cmp-bar`,role:`status`}),S=f(`p`,{class:`cmp-activity`,role:`status`,"aria-live":`polite`});x.hidden=!0;let C=f(`form`,{class:`composer`},b,f(`div`,{class:`cmp-row`},v,_,p,f(`div`,{class:`cmp-acts`},m,h,g)),f(`div`,{class:`cmp-foot`},y),x,S);e.replaceChildren(C);let w={name:``,control:!1,live:!1,mark:`unknown`,online:!1},T=!1,E=!1,D=e=>{try{e()}catch{}};D(()=>p.value=sessionStorage.getItem(u)??``),p.value=it(n,p.value);let O=()=>D(()=>p.value?sessionStorage.setItem(u,p.value):sessionStorage.removeItem(u)),k=CSS.supports(`field-sizing`,`content`)?()=>{}:()=>(p.style.height=`auto`,p.style.height=`${Math.min(p.scrollHeight,220)}px`),A=(e,t=``,...n)=>(y.dataset.tone=t,y.replaceChildren(e,...n)),j=(e,t,n)=>{let r=f(`button`,{type:`button`,class:`cmp-yes`},t),i=f(`button`,{type:`button`,class:`cmp-link`},ee());E=!0,r.onclick=()=>(E=!1,n()),i.onclick=()=>(E=!1,A(``),p.focus()),A(e,`ask`,r,i),r.focus()},[M,N]=[`${u}:note`,()=>{try{return sessionStorage.getItem(u)??``}catch{return}}],P=e=>D(()=>e?sessionStorage.setItem(M,JSON.stringify(e)):sessionStorage.removeItem(M));function F(e,t,i){let a={sent:i,answer:r(e,t)};return i!==void 0&&(P([`error`,G()]),K.set(n,a),a.answer.then(e=>{let t=N();e.ok&&t!==void 0&&D(()=>sessionStorage.setItem(u,$e(t,i))),P(Xe(e,t,i))},()=>P([`error`,G()]))),I(a)}async function I(e,{sent:r}=e){T=!0,E=!1,R(),A(r===void 0?``:t());try{let t=await e.answer;if(!C.isConnected)return;if(!t.ok)return t.status===504||P(),A(a(t)??(t.status===403&&t.body.error===`local_only`?re():void 0)??t.body.reason??l({status:t.status}),`error`);if(r===void 0)return A(``);P();let n=Qe(p.value,r);p.value=$e(p.value,r),O(),k(),A(n,`ok`)}catch{A(G(),`error`)}finally{K.get(n)===e&&K.delete(n),T=!1,R()}}function L(e,t){let n=p.value,r=$(w),i=t===n;if(T||E||!n.trim())return;if(r)return A(r,`error`);if(new TextEncoder().encode(n).length>16384)return A(o(),`error`);let a=!i&&Ye(n,w);if(a)return j(le({command:a}),Te({command:a}),()=>L(e,n));F(`input`,{text:n,as:e,confirmed:i},n)}function R(){let e=lt(w),t=[C.querySelector(`.cmp-row`),C.querySelector(`.cmp-foot`)];x.hidden=e===void 0,x.textContent=e??``,C.classList.toggle(`ended`,e!==void 0);for(let n of t)n.hidden=e!==void 0;b.hidden||=e!==void 0;let n=w.activity;for(let[e,t]of[[`activity`,n?.mark],[`kind`,n?.kind]])t===void 0?delete C.dataset[e]:C.dataset[e]=t;S.textContent!==(n?.text??``)&&(S.textContent=n?.text??``);let r=$(w),i=w.mark===`working`;p.placeholder=r??ut(w),p.disabled=v.disabled=!ct(w),m.disabled=T||!!r||!p.value.trim(),h.hidden=g.hidden=!i||!!r||!!w.wakes,[h.disabled,g.disabled]=[m.disabled,T]}let z=()=>{let e=f(`button`,{type:`button`,class:`cmp-yes`},ie());e.onclick=()=>void B(),A(ce(),`error`,e)};function fe(){return r(`dequeue`,{take:tt(n)??nt(n)}).then(e=>(st(n,e,C.isConnected?{box:p,save:O}:void 0),e),()=>void 0)}async function B(){if(T||E||J.has(n))return;let e=$(w);if(e)return A(e,`error`);let t=fe();J.set(n,t),await V(t)}async function V(e){T=!0,R(),A(se());try{let t=await e;if(!C.isConnected)return;if(!t||t.status===504)return z();if(!t.ok)return A(ot(t)??t.body.reason??l({status:t.status}),`error`);if(typeof t.body.text!=`string`)return A(ae());let r=N();r!==void 0&&r!==p.value&&(p.value=r),p.value=it(n,p.value),O(),P(),k(),p.focus(),p.selectionStart=p.selectionEnd=p.value.length,A(oe(),`ok`)}finally{J.get(n)===e&&J.delete(n),T=!1,R()}}async function H(e){if(!e.length||T)return;let t=$(w);if(t)return A(t,`error`);A(He(),``);for(let t of e){if(t.size>20971520)return A(ue({name:t.name}),`error`);let e=await c(t).catch(()=>void 0);if(!e?.ok||typeof e.body.path!=`string`)return A(e?.body.reason??s(),`error`);let n=p.selectionStart??p.value.length,r=p.value.slice(0,n),i=p.value.slice(p.selectionEnd??n),a=`${r&&!/\s$/.test(r)?` `:``}${e.body.path}${/^\s/.test(i)?``:` `}`;p.value=r+a+i,p.selectionStart=p.selectionEnd=n+a.length}A(``),O(),k(),R(),p.focus()}v.onclick=()=>_.click(),_.onchange=()=>void H([..._.files??[]]).finally(()=>_.value=``),p.addEventListener(`paste`,e=>{let t=[...e.clipboardData?.files??[]];t.length&&(e.preventDefault(),H(t))}),C.addEventListener(`dragover`,e=>e.dataTransfer?.types.includes(`Files`)&&e.preventDefault()),C.addEventListener(`drop`,e=>{let t=[...e.dataTransfer?.files??[]];t.length&&(e.preventDefault(),H(t))}),C.addEventListener(`submit`,e=>(e.preventDefault(),L(`send`))),h.onclick=()=>L(`followUp`),g.onclick=()=>j(Oe(),De(),()=>void(T||F(`keys`,{keys:[`esc`]}))),p.addEventListener(`input`,()=>(O(),k(),R())),C.addEventListener(`keydown`,e=>{e.key===`Escape`&&!e.isComposing&&(E||e.target===p&&p.value)&&(e.preventDefault(),E&&(E=!1,A(``),p.focus()))}),p.addEventListener(`keydown`,e=>{e.isComposing||e.keyCode===229||e.key!==`Enter`||e.shiftKey||d&&!e.altKey||(e.preventDefault(),L(e.altKey?`followUp`:`send`))});let U=window.visualViewport,W=()=>[[`--vvh`,U.height],[`--vvt`,U.offsetTop]].forEach(([e,t])=>document.documentElement.style.setProperty(e,`${t}px`));return U&&(U.addEventListener(`resize`,W),U.addEventListener(`scroll`,W),W()),k(),K.has(n)?I(K.get(n)):J.has(n)?V(J.get(n)):D(()=>{let e=Ze(sessionStorage.getItem(M));sessionStorage.removeItem(M),e?A(e[1],e[0]):tt(n)&&z()}),{box:p,update:e=>(w=e,R()),ready:()=>!$(w),takeQueue:B}}var pt=(e,{name:t,mk:n,state:r,online:i,away:a,role:o,head:s})=>({name:t,control:!!e?.control,live:!u(e,r),mark:n,online:i,away:a,answerable:!!e?.pending?.answer,...dt(e?.service??(s?{state:`absent`,allyRuns:[]}:void 0)),head:!!s,activity:mt(e,r,n),ally:!e&&(o===`ally`||o===`run`),run:!e&&o===`run`});function mt(e,t,n){let r=d(e,t,n);if(!r)return;let i=e?.note??``;return{text:r,mark:n,kind:i.startsWith(`tool:`)?`tool`:i===`watching a monitor`?`monitoring`:`thinking`}}var ht={post:(e,t)=>c(e,t)},gt=e=>e?.auto?.pending,_t=(e,t)=>e.body.error===`stale`?x({},t):e.body.reason??(e.status?l({status:e.status},t):s({},t));function vt(e,t,n){let r=gt(t);if(e.hidden=!r,!r)return void(delete e.dataset.id,e.replaceChildren());if(e.dataset.id===r.id)return;e.dataset.id=r.id;let i=f(`p`,{class:`auto-note`,role:`alert`}),a=f(`button`,{type:`button`,class:`auto-confirm`},p({},n));a.onclick=async()=>{a.disabled=!0,i.textContent=``;let e=await ht.post(`auto/confirm`,{id:r.id}).catch(()=>({ok:!1,status:0,body:{}}));if(e.ok)return void(i.textContent=y({},n));a.disabled=!1,i.textContent=_t(e,n)},e.replaceChildren(f(`p`,{class:`auto-title`},v({},n)),f(`p`,{class:`auto-said`},g({said:r.said},n)),a,i)}export{H as a,G as i,pt as n,T as o,ft as r,vt as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./runtime-ZX6HkxDa.js";import{
|
|
1
|
+
import{t as e}from"./runtime-ZX6HkxDa.js";import{i as t}from"./auto-Bem-pRhU.js";import{i as n}from"./mdbody-LgDqhYO3.js";import{n as r,r as i}from"./markdown-Bk5NWfKQ.js";import{ft as a}from"./index-Ci_M1nWI.js";import{t as o}from"./focusback-DGGGUsJl.js";var s=((t={},n={})=>(n.locale??e())===`zh-TW`?`返回`:`Back`),c=((t={},n={})=>(n.locale??e())===`zh-TW`?`送出`:`Send`),l=((t={},n={})=>(n.locale??e())===`zh-TW`?`你的回答會以這段文字送出:`:`Your answer goes out as this text:`),u=((t={},n={})=>(n.locale??e())===`zh-TW`?`傳送中…`:`Sending…`),d=((t={},n={})=>(n.locale??e())===`zh-TW`?`無法讀取這題是否已回答。`:`Whether this was answered could not be read.`);function f(e){return v(e.replace(/\r\n?/g,`
|
|
2
2
|
`))}var p=/[!-/:-@[-`{-~]/,m=/[\p{L}\p{N}]/u,h=/^https?:\/\/[^\s<>]+/i,g=/^https?:\/\/[^\s<>]+$/i,_=e=>e!==void 0&&m.test(e);function v(e){let t=[],n=``,r=()=>{n&&t.push({type:`text`,text:n}),n=``},i=e=>{r(),t.push(e)},a=0;for(;a<e.length;){let t=e[a];if(t===`\\`&&p.test(e[a+1]??``))n+=e[a+1],a+=2;else if(t===`
|
|
3
3
|
`)i({type:`br`}),a++;else if(t==="`"){let t=y(e,a);if(t===void 0){let t=/^`+/.exec(e.slice(a))?.[0]??"`";n+=t,a+=t.length}else i({type:`code`,text:t.text}),a=t.next}else if(t===`[`){let r=b(e,a);r?(i({type:`link`,href:r.href,children:v(r.label)}),a=r.next):(n+=t,a++)}else if(t===`*`||t===`_`){let r=S(e,a);r?(i({type:r.strong?`strong`:`em`,children:v(r.inner)}),a=r.next):(n+=t,a++)}else if((t===`h`||t===`H`)&&!_(e[a-1])){let r=x(e,a);r?(i({type:`link`,href:r,children:[{type:`text`,text:r}]}),a+=r.length):(n+=t,a++)}else n+=t,a++}return r(),t}function y(e,t){let n=/^`+/.exec(e.slice(t))?.[0],r=t+n.length;for(;r<e.length;){let i=e.indexOf(n,r);if(i<0)return;if(e[i+n.length]==="`"||e[i-1]==="`"){for(r=i+1;e[r]==="`";)r++;continue}let a=e.slice(t+n.length,i).replace(/\n/g,` `);return{text:a.length>2&&a.startsWith(` `)&&a.endsWith(` `)&&a.trim()!==``?a.slice(1,-1):a,next:i+n.length}}}function b(e,t){let n=0,r=-1;for(let i=t;i<e.length;i++){let t=e[i];if(t===`\\`)i++;else if(t===`[`)n++;else if(t===`]`&&--n===0){r=i;break}}if(r<0||e[r+1]!==`(`)return;let i=e.indexOf(`)`,r+2);if(i<0)return;let a=e.slice(r+2,i).trim(),o=e.slice(t+1,r);if(g.test(a)&&o.trim()!==``)return{label:o,href:a,next:i+1}}function x(e,t){let n=h.exec(e.slice(t))?.[0];if(!n)return;let r=n;for(;;){let e=r[r.length-1],t=e===`)`&&(r.match(/\(/g)?.length??0)<(r.match(/\)/g)?.length??0);if(/[.,;:!?'"\]}]/.test(e)||t)r=r.slice(0,-1);else break}return/^https?:\/\/[^/\s]+/i.test(r)&&r.length>8?r:void 0}function S(e,t){let n=e[t],r=e[t+1]===n,i=r?2:1,a=n.repeat(i);if(n===`_`&&_(e[t-1]))return;let o=t+i;if(o>=e.length||/\s/.test(e[o]))return;let s=o;for(;s<e.length;){let t=e.indexOf(a,s);if(t<0)return;if(e[t-1]===`\\`){s=t+1;continue}if(r)for(;e[t+i]===n;)t++;if(!r&&(e[t+1]===n||e[t-1]===n)){s=t+2;continue}let c=e.slice(o,t),l=c===``||/\s$/.test(c),u=n===`_`&&_(e[t+i]);if(l||u)s=t+i;else return{inner:c,strong:r,next:t+i}}}function ee(e){switch(e.type){case`text`:case`code`:return e.text;case`br`:return`
|
|
4
4
|
`;case`strong`:case`em`:return C(e.children);case`link`:{let t=C(e.children);return t===e.href?t:`${t} (${e.href})`}}}var C=e=>e.map(ee).join(``);function w(e){return C(f(e))}function T(e,t){if(typeof e!=`object`||!e||Array.isArray(e))throw Error(`each ${t} must be a mapping`);return e}function E(e,t){if(Array.isArray(e))return e;let n=e&&typeof e==`object`?e[t]:void 0;if(!Array.isArray(n))throw Error(`expected a YAML list, or a mapping with a \`${t}\` list`);return n}function te(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function D(e,t){if(e==null)return;if(typeof e==`object`)throw Error(`${t} must be text`);let n=String(e).trim();return n===``?void 0:n}function ne(e,t){let n=D(e,t);if(n===void 0)throw Error(`${t} is required`);return n}function re(e,t){return e==null?[]:(Array.isArray(e)?e.map(e=>D(e,t)):String(e).split(`;`).map(e=>e.trim())).filter(e=>e!==void 0&&e!==``)}function ie(e){if(e===!0)return!0;if(e&&typeof e!=`object`)return String(e)}function ae(e,t){if(e!=null){if(typeof e!=`boolean`)throw Error(`${t} must be true or false`);return e}}function oe(e,t){if(e==null)return;let n=Number(e);if(!Number.isFinite(n)||n<=0)throw Error(`${t} must be a positive number`);return n}function se(e,t,n){if(e==null)return;let r=t.find(t=>t===String(e));if(r===void 0)throw Error(`${n} must be one of ${t.join(`, `)}`);return r}function ce(e,t,n){return typeof e==`object`&&e?T(e,n):{[t]:e}}function le(e){return{cards:E(e,`cards`).map(e=>{let t=T(e,`card`);return{title:D(t.title,`title`),tone:D(t.tone,`tone`),body:D(t.body,`body`)}})}}function ue(e){return{options:E(e,`options`).map(e=>{let t=T(e,`option`);return{title:D(t.title,`title`),recommended:ie(t.recommended),body:D(t.body,`body`),pros:re(t.pros,`pros`),cons:re(t.cons,`cons`)}})}}var de=`pi-note`,fe=[`single`,`multi`,`text`];function pe(e){let t=ce(e,`label`,`choice`),n=D(t.label??t.value,`choice label`);if(n===void 0)throw Error(`each choice needs a label or a value`);return{value:D(t.value,`choice value`)??n,label:n,note:D(t.note,`note`),recommended:ie(t.recommended)}}function me(e){let t=T(e,`question`),n=D(t.label,`label`),r=D(t.name,`name`)??n;if(r===void 0)throw Error(`each question needs a name or a label`);if(r===`pi-note`)throw Error(`the question name "pi-note" is reserved for the other-comments box`);let i=(Array.isArray(t.choices)?t.choices:re(t.choices,`choices`)).map(pe),a=se(t.type,fe,`type`)??(i.length>0?`single`:`text`),o=t.other===void 0||t.other===null?i.length>0:typeof t.other==`boolean`?t.other:String(t.other);return{name:r,label:n,type:a,hint:D(t.hint,`hint`),required:t.required===!0,other:a!==`text`&&o,choices:i}}function he(e){let t=te(e);return{title:D(t.title,`title`),submit:D(t.submit,`submit`),questions:E(e,`questions`).map(me)}}function ge(e){let t=new Set(e.filter(Boolean)),n=new Set,r=0,i=()=>{for(;;){let e=r<26?String.fromCharCode(65+r):String(r+1);if(r++,!t.has(e))return e}};return e.map(e=>{let t=e||i(),r=t;for(let e=2;n.has(r);e++)r=`${t}${e}`;return n.add(r),r})}var _e=e=>e.label?`${e.name} (${e.label})`:e.name,ve=(e,t)=>e.title?w(e.title):String(t+1);function ye(e){let t=te(e),n=E(e,`items`).map(e=>ce(e,`image`,`item`)),r=ge(n.map(e=>D(e.name,`name`))),i=n.map((e,t)=>({name:r[t],label:D(e.label,`label`),image:D(e.image,`image`),page:D(e.page,`page`),height:oe(e.height,`height`),body:D(e.body,`body`)}));return{title:D(t.title,`title`),submit:D(t.submit,`submit`),pick:ie(t.pick),columns:oe(t.columns,`columns`),items:i}}var O=(e,t)=>e.find(([e])=>e===t)?.[1],be=(e,t)=>e.filter(([e])=>e===t).map(([,e])=>e);function xe(e){return`User submitted a form in the HTML review pane:\n${e.map(([e,t])=>`- ${e}: ${t}`).join(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./runtime-ZX6HkxDa.js";import{t}from"./link_unit_ago-CvB9wMxM.js";import{E as n,S as r,T as i,f as a,h as o,l as s,u as c,v as l}from"./index-
|
|
1
|
+
import{t as e}from"./runtime-ZX6HkxDa.js";import{t}from"./link_unit_ago-CvB9wMxM.js";import{E as n,S as r,T as i,f as a,h as o,l as s,u as c,v as l}from"./index-Ci_M1nWI.js";var u=((t={},n={})=>(n.locale??e())===`zh-TW`?`這台機器的狀態卡`:`This machine's status card`),d=((t={},n={})=>(n.locale??e())===`zh-TW`?`對這台機器的操作已結束`:`Operating this machine has ended`),f=((t={},n={})=>(n.locale??e())===`zh-TW`?`這台機器不讓這部裝置操作`:`This machine does not let this device operate it`),p=((t={},n={})=>(n.locale??e())===`zh-TW`?`操作權限已撤銷`:`Operate permission was withdrawn`),m=e=>`Open ${e?.name}, an earlier run`,h=e=>`開啟先前的執行 ${e?.name}`,g=((t,n={})=>(n.locale??e())===`zh-TW`?h(t):m(t)),_=e=>`Earlier runs (${e?.count})`,v=e=>`先前的執行(${e?.count})`,y=((t,n={})=>(n.locale??e())===`zh-TW`?v(t):_(t)),b=((t={},n={})=>(n.locale??e())===`zh-TW`?`顯示更多`:`Show more`),x=((t={},n={})=>(n.locale??e())===`zh-TW`?`最後看到 `:`last seen `),S=e=>`Team ${e?.team}`,C=e=>`團隊 ${e?.team}`,w=((t,n={})=>(n.locale??e())===`zh-TW`?C(t):S(t)),T=((t={},n={})=>(n.locale??e())===`zh-TW`?`連不上`:`unreachable`),E=new Set([`policy`,`roster`]),D=new Set([`not-granted`,`not-admin`,`out-of-scope`,`local-only`]),O=e=>e!==void 0&&E.has(e)?`revoked`:e!==void 0&&D.has(e)?`refused`:`other`,k=e=>typeof e==`string`&&/^x[0-9a-f]{16}$/.test(e),A=(e,t)=>typeof e==`string`&&e.length>0&&e.length<=t,j=e=>typeof e==`number`&&Number.isFinite(e);function M(e){let t=typeof e==`object`&&e?e:{},n=[];for(let e of Array.isArray(t.rows)?t.rows.slice(0,50):[]){let t=typeof e==`object`&&e?e:{};!k(t.key)||!A(t.name,200)||!A(t.role,40)||typeof t.workspace!=`string`||t.workspace.length>200||!j(t.first)||!j(t.last)||!j(t.size)||n.push({key:t.key,name:t.name,role:t.role,workspace:t.workspace,first:t.first,last:t.last,size:t.size,...A(t.dispatcher,100)?{dispatcher:t.dispatcher}:{}})}return{rows:n,...A(t.before,200)?{before:t.before}:{}}}var N=e=>fetch(`api/${e}`,{cache:`no-store`}).then(e=>e.ok?e.json():Promise.reject(Error(String(e.status)))),P=e=>void(N=e),F=1e4,I=3e4,L=new WeakMap,R=e=>{let t=[],n=e=>e.forEach(e=>(t.push(e.key),n(e.subs)));return n([...e.tower?.subs??[],...e.tabs.flatMap(e=>e.units),...e.outside]),t.sort().join()},z=()=>l(`<li class="box-run"><a class="box-open"><span class="name"></span><em class="role"></em><span class="when"><span class="age"></span><span class="post"></span></span></a></li>`),B=(e,t)=>(e.dataset.since=String(t),e.textContent=s(t));function V(e,a,o){let s=e.querySelector(`.box-runs`);if(s.hidden=a.box?.state!==`live`||!o.rows.length,s.hidden)return;n(s,`summary`,y({count:o.rows.length})),i(s.querySelector(`.box-run-list`),o.rows.map(e=>({...e,id:e.key})),z,(e,i)=>{let o=e.querySelector(`a`);c(o,{view:`session`,ws:a.id,key:i.key}),o.setAttribute(`aria-label`,g({name:i.name})),n(e,`.name`,i.name),n(e,`.role`,r(i.role)),B(e.querySelector(`.age`),i.last),n(e,`.post`,t())});let l=s.querySelector(`.box-more`);l.hidden=!o.before,l.textContent=b()}function H(e,t,n,r){n.busy||(n.busy=!0,n.sig=R(t),n.at=Date.now(),N(`transcripts?base=${t.id}${r?`&before=${encodeURIComponent(r)}`:``}`).then(e=>{let t=M(e);n.failed=!1,n.rows=r?[...n.rows,...t.rows.filter(e=>!n.rows.some(t=>t.key===e.key))]:t.rows,n.before=t.before},()=>void(n.failed=!0)).finally(()=>(n.busy=!1,L.get(e)===n&&V(e,n.base??t,n))))}function U(e,t){let n=L.get(e)??(L.set(e,{rows:[],at:0,busy:!1,failed:!1}),L.get(e)),r=e.querySelector(`.box-more`);if(n.base=t,r.onclick=()=>n.before&&H(e,n.base??t,n,n.before),t.box?.state===`live`&&k(t.id)){let r=Date.now()-n.at>=(n.failed?I:F);!n.busy&&(n.at===0||r&&(n.failed||n.sig!==R(t)))&&H(e,t,n)}V(e,t,n)}function W(e,r){let i=e.querySelector(`.box-seen`),a=r.box,o=a.state===`unreachable`;if(i.hidden=!o,!o)return;n(i,`.bs-state`,T());let s=a.seen!==void 0&&Number.isFinite(a.seen);i.querySelector(`.bs-when`).hidden=!s,s&&(n(i,`.bs-pre`,x()),B(i.querySelector(`.age`),a.seen),n(i,`.bs-post`,t()))}function G(e,t,r=[],s){let c=t.box,l=c?.state===`ended`,m=t=>e.querySelector(t);m(`.box-line`).hidden=!c,c&&(n(e,`.box-dev`,`${c.label} · ${c.short}`),n(e,`.box-team`,w({team:c.team})),W(e,t));let h=m(`.box-ended`);h.hidden=!l,h.textContent=l?{revoked:p,refused:f,other:d}[O(c.why)]():``,m(`.title .tstate`).closest(`p`).hidden=l||!(!c||t.tower);for(let e of[`.tower-subs`,`.tower-notices`,`.tabs`,`.outposts`])m(e).hidden=l;let g=m(`.box-ally`);g.hidden=!c||!r.length,g.hidden||(n(g,`summary`,u()),i(g.querySelector(`.box-ally-in`),r.map(e=>({...e,id:`ally/${e.id}`})),a,(e,t)=>o(e,t,s))),U(e,t)}export{G as fillBox,P as useRuns};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-Cy-sjGia.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./towermodel-BpgH7epr.js";import{t}from"./runtime-ZX6HkxDa.js";import{t as n}from"./sentencepack-DtYqpppS.js";import{i as r,r as i,t as a}from"./mdbody-LgDqhYO3.js";import{f as o,i as s,n as c,r as l,t as u}from"./towerturns-Ci8paKaq.js";import{G as d,K as ee,S as te,W as ne,ft as f,mt as re,nt as ie,o as p,rt as ae,v as m}from"./index-Ci_M1nWI.js";var oe=((e={},n={})=>(n.locale??t())===`zh-TW`?`可能已被當機的 run 處理過:動手前先確認。`:`A run that crashed may already have handled this: check before acting.`),se=((e={},n={})=>(n.locale??t())===`zh-TW`?`分支摘要`:`branch summary`),ce=((e={},n={})=>(n.locale??t())===`zh-TW`?`通訊紀錄`:`Comms log`),h=e=>`context compacted · ${e?.tokens} tokens summarized`,g=e=>`上下文已壓縮 · 摘要了 ${e?.tokens} tokens`,le=((e,n={})=>(n.locale??t())===`zh-TW`?g(e):h(e)),ue=((e={},n={})=>(n.locale??t())===`zh-TW`?`…(於 1 MB 截斷)`:`… (cut at 1 MB)`),_=e=>`exit ${e?.code}`,v=e=>`結束碼 ${e?.code}`,de=((e,n={})=>(n.locale??t())===`zh-TW`?v(e):_(e)),y=e=>`New chapter · ${e?.date} · ${e?.why}`,b=e=>`新的一章・${e?.date}・${e?.why}`,fe=((e,n={})=>(n.locale??t())===`zh-TW`?b(e):y(e)),pe=((e={},n={})=>(n.locale??t())===`zh-TW`?`第一次對話`:`the first conversation`),x=((e={},n={})=>(n.locale??t())===`zh-TW`?`你要求開新對話`:`you asked for a new conversation`),S=((e={},n={})=>(n.locale??t())===`zh-TW`?`上一章太長了`:`the last one grew too large`),C=((e={},n={})=>(n.locale??t())===`zh-TW`?`上一章無法接續`:`the last one could not be resumed`),w=e=>`Image ${e?.n}`,T=e=>`圖片 ${e?.n}`,me=((e,n={})=>(n.locale??t())===`zh-TW`?T(e):w(e)),he=((e={},n={})=>(n.locale??t())===`zh-TW`?`圖片無法讀取`:`Image unavailable`),E=e=>`${e?.count} image(s)`,D=e=>`${e?.count} 張圖片`,ge=((e,n={})=>(n.locale??t())===`zh-TW`?D(e):E(e)),_e=((e={},n={})=>(n.locale??t())===`zh-TW`?`收到`:`incoming`),O=((e={},n={})=>(n.locale??t())===`zh-TW`?`跳到最新`:`jump to latest`),k=e=>`${e?.count} new`,A=e=>`${e?.count} 則新訊息`,j=((e,n={})=>(n.locale??t())===`zh-TW`?A(e):k(e)),ve=((e={},n={})=>(n.locale??t())===`zh-TW`?`還沒有通訊。`:`No transmissions yet.`),ye=((e={},n={})=>(n.locale??t())===`zh-TW`?`通知`:`notice`),be=((e={},n={})=>(n.locale??t())===`zh-TW`?`細節`:`details`),M=((e={},n={})=>(n.locale??t())===`zh-TW`?`表單回覆`:`form answers`),xe=((e={},n={})=>(n.locale??t())===`zh-TW`?`訊息,來自`:`message from`),N=e=>`answer from ${e?.from}`,P=e=>`${e?.from} 的回答`,Se=((e,n={})=>(n.locale??t())===`zh-TW`?P(e):N(e)),Ce=e=>`request from ${e?.from}`,F=e=>`${e?.from} 的請求`,we=((e,n={})=>(n.locale??t())===`zh-TW`?F(e):Ce(e)),Te=e=>`message from ${e?.from}`,Ee=e=>`${e?.from} 的訊息`,De=((e,n={})=>(n.locale??t())===`zh-TW`?Ee(e):Te(e)),I=e=>`reply to your ask from ${e?.from}`,L=e=>`${e?.from} 回覆了你的詢問`,Oe=((e,n={})=>(n.locale??t())===`zh-TW`?L(e):I(e)),ke=((e={},n={})=>(n.locale??t())===`zh-TW`?`記憶`:`memory`),R=((e={},n={})=>(n.locale??t())===`zh-TW`?`監看`:`monitor`),Ae=((e={},n={})=>(n.locale??t())===`zh-TW`?`本機`:`this computer`),je=((e={},n={})=>(n.locale??t())===`zh-TW`?`隊友`:`teammate`),z=((e={},n={})=>(n.locale??t())===`zh-TW`?`提問,來自`:`question from`),B=((e={},n={})=>(n.locale??t())===`zh-TW`?`回報,來自`:`report from`),Me=((e={},n={})=>(n.locale??t())===`zh-TW`?`sb server 的通知`:`notice from the sb server`),V=((e={},n={})=>(n.locale??t())===`zh-TW`?`狀態:`:`status of`),Ne=((e={},n={})=>(n.locale??t())===`zh-TW`?`Straw Link 訊息`:`Straw Link message`),Pe=((e={},n={})=>(n.locale??t())===`zh-TW`?`喚醒鬧鐘`:`wake-up call`),H=((e={},n={})=>(n.locale??t())===`zh-TW`?`塔台事件`:`tower event`),Fe=(e,t)=>n(`notice_tower`,H,e,t),Ie=((e={},n={})=>(n.locale??t())===`zh-TW`?`在旁開啟`:`open beside`),U=e=>`Open image ${e?.n}`,Le=e=>`打開圖片 ${e?.n}`,Re=((e,n={})=>(n.locale??t())===`zh-TW`?Le(e):U(e)),W=e=>`show all (${e?.size})`,G=e=>`顯示全部(${e?.size})`,ze=((e,n={})=>(n.locale??t())===`zh-TW`?G(e):W(e)),Be=((e={},n={})=>(n.locale??t())===`zh-TW`?`顯示全部參數`:`show all arguments`),K=e=>`◇ thought · ${e?.count} chars`,q=e=>`◇ 思考 · ${e?.count} 字元`,Ve=((e,n={})=>(n.locale??t())===`zh-TW`?q(e):K(e)),He=((e={},n={})=>(n.locale??t())===`zh-TW`?`◇ 思考 · 已遮蔽`:`◇ thought · redacted`),J=((e={},n={})=>(n.locale??t())===`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.`),Ue=(e,t)=>n(`tower_empty`,J,e,t),We=((e={},n={})=>(n.locale??t())===`zh-TW`?`無法取得`:`unavailable`);function Ge(){let e=!0,t=0,n=!0,r=0;return{get pinned(){return e},scrolled(r){r!==n&&(n=e=r,r&&(t=0))},parked:e=>void(r=e),moved(i,a){let o=i-r;return r=i,o<-.5&&e&&a()-i>1?!(e=!1):o!==0&&!e&&n&&a()-i<=1&&(e=!0,t=0,!0)},hold:()=>void(n=e=!1),arrived(n){return e||(t+=n),e},jump:()=>void(n=e=!0,t=0),button:n=>e&&!n?void 0:t&&!n?j({count:t}):O()}}async function Ke(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)}var Y={},qe=3e3,X=new Map,Z=new Map;async function Q(e){try{let t=Y.get?await Y.get(e):await d(`answered/${encodeURIComponent(e)}`).then(e=>e.ok?e.body:void 0);if(!t||!Array.isArray(t.done)||!Array.isArray(t.pending))return!1;let n=new Map,i=e=>n.get(e)??(n.set(e,{done:[],pending:[]}),n.get(e));for(let[e,n,r]of t.done)i(e).done.push([n,r]);for(let[e,n]of t.pending)i(e).pending.push(n);for(let t of Z.get(e)??[])n.has(t)||r(e,t).seed({done:[],pending:[]});for(let[t,i]of n)r(e,t).seed(i);return Z.set(e,new Set(n.keys())),!t.unreadable}catch{return!1}}function Je(e){let t=X.get(e);if(t&&Date.now()-t.at<qe)return t.read;let n=Q(e);return X.set(e,{at:Date.now(),read:n}),n}function Ye(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 Xe=(e,t)=>({first:pe,new:x,size:S,unreadable:C})[e??``]?.()??t??``,Ze=e=>e.head?ie(`head_tower`):te(e.role),Qe=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1}):``,$e=e=>e>=1024?`${(e/1024).toFixed(e>=10240?0:1)} KB`:`${e} B`,et={intercom_message:xe,subagent_result:B,subagent_ping:z,subagent_status:V,"pi-loop-monitor":R,"memory-context":ke,"doc-review":M,"straw-tower":Fe,"straw-link":Ne},tt=e=>{let t=m(`<span class="ava"><svg><use/></svg></span>`),n=t.querySelector(`use`),r=p[e]??e;return n.dataset.icon=r,n.setAttribute(`href`,ae(r)),t};function nt(e){let t=[],n=0;for(let r of e.matchAll(/https?:\/\/[^\s<>)\]]+/g))t.push(e.slice(n,r.index),f(`a`,{href:r[0],rel:`noopener noreferrer`,target:`_blank`},r[0])),n=r.index+r[0].length;return[...t,e.slice(n)]}function $(n,r,{who:d,link:te,docFor:p,page:ae,away:m}){let h=Ye(),g=new Map,_=new Set,v=()=>_.forEach(e=>e.button.isConnected?(e.shown=!0,e.button.hidden=!e.paths.some(e=>p?.(e))):e.shown&&_.delete(e)),y=f(`div`,{class:`chat-list`}),b=f(`div`,{class:`chat-top`}),pe=f(`div`,{class:`chat-end`}),x=f(`button`,{class:`chat-pill`,type:`button`,hidden:``}),S=f(`p`,{class:`chat-empty`},ve()),C=f(`div`,{class:`chat-scroll`,tabindex:`-1`,"aria-label":ce()},b,y,pe);n.replaceChildren(C,x);let w=Ge(),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&&!h.detached&&F()),250)),P=(e=w.button(h.detached))=>(x.hidden=!e,x.textContent=e??``),Ce=()=>(C.scrollTop=C.scrollHeight,w.parked(C.scrollTop)),F=()=>(w.jump(),O=void 0,Ce(),P());async function Te(e){T=!0;let t=await Ke(h,r,e,e=>(q(e),X(e))).finally(()=>T=!1),n=g.get(e);if(D===e){if(!t||!n)return F();w.hold(),O=n,n.scrollIntoView({block:`center`}),re(n,`lit`),clearTimeout(k),k=window.setTimeout(()=>(O=void 0,n.classList.remove(`lit`)),2e3),P()}}let Ee=()=>D?void Te(D):F(),I=(e,t,n,i)=>{e.disabled=!0,r.entry(n).then(n=>{let r=n&&i(n);if(r===void 0)return void(e.textContent=We());t.textContent=r,e.remove()},()=>e.textContent=We())};function L(e,t=0){if(!t||!r.pic)return null;let n=Array.from({length:t},(t,n)=>r.pic(e,n));return f(`div`,{class:`pics`},...n.map((e,t)=>{let r=f(`img`,{src:e,alt:me({n:t+1}),loading:`lazy`,decoding:`async`}),i=f(`button`,{type:`button`,class:`pic`,"aria-label":Re({n:t+1})},r);return r.addEventListener(`error`,()=>i.replaceWith(f(`em`,{class:`pic-gone`},he()))),i.addEventListener(`click`,()=>void ne(async()=>{let{lightbox:e}=await import(`./lightbox-CGvsEhxp.js`);return{lightbox:e}},__vite__mapDeps([0]),import.meta.url).then(({lightbox:e})=>e(n,t))),i}))}function ke(e,t){let n=h.result(e.id),r=f(`pre`,{class:`out`},n?.text??``),i=f(`pre`,{class:`args`},e.args??``),a=e.cut?f(`button`,{class:`more`,type:`button`},Be()):null;a?.addEventListener(`click`,()=>I(a,i,t,t=>(e=>e&&`${e.args??``}${e.cut?`\n${ue()}`:``}`)(t.tools?.find(t=>t.id===e.id))));let o=n?.more?f(`button`,{class:`more`,type:`button`},ze({size:$e(n.bytes??0)})):null;o?.addEventListener(`click`,()=>I(o,r,n.id,e=>e.text));let s=e.name===`show_doc`&&p?f(`button`,{class:`more open`,type:`button`,hidden:``},Ie()):null;s?.addEventListener(`click`,t=>(t.preventDefault(),e.summary.split(`, `).forEach(e=>p?.(e)?.()))),s&&_.add({paths:e.summary.split(`, `),button:s}),s&&queueMicrotask(v);let c=f(`details`,{class:`act`},f(`summary`,{"data-mark":n?n.isError?`error`:`done`:`working`},f(`b`,{class:`badge`}),f(`code`,null,e.name),f(`span`,{class:`sum`},e.summary),s),i,a,n&&f(`div`,{class:`result`},n.images?f(`em`,null,ge({count:n.images})):null,r,o)),l=n&&L(n.id,n.images);return l?[c,l]:[c]}let R=e=>f(`time`,null,Qe(e.at)),z=(e,t,n,r)=>f(`article`,{class:`tx you`},f(`header`,null,R(e),f(`b`,null,ie(`you`)),tt(`user`)),f(`div`,{class:`bubble`,title:r},n?f(`small`,{class:`boss-flag`},oe()):null,...nt(t),L(e.id,e.images))),B=(e,t,n,r={})=>f(`article`,{class:`tx sys`},f(`details`,{class:`notice`},f(`summary`,null,tt(`comms`),f(`em`,null,_e()),...t,R(e)),r.crashed?f(`small`,{class:`boss-flag`},oe()):null,f(`pre`,null,n),r.raw?f(`details`,{class:`notice-raw`},f(`summary`,null,be()),f(`pre`,{class:`raw`},r.raw)):null)),V=e=>{let t=s(e);return[xe(),` `,t.name&&te(t.name)||t.name,t.id?` (${t.id})`:``,` · `,Ae()]},Ne=e=>e.kind===`link`?[{ask:we,reply:Oe,answer:Se,message:De}[e.what]({from:e.from}),` · `,je()]:e.kind===`intercom`?V(e.from):[e.kind===`server`?Me():Pe()],H=new Set,Fe=()=>H.forEach(e=>e.deref()||H.delete(e)),U=m&&{why:()=>m()?o():void 0,watch:e=>(H.size>=256&&Fe(),void H.add(new WeakRef(e)))},Le=(e,t)=>{let n=d().key,o=e=>r.post?r.post(`input`,e):ee(`sessions/${encodeURIComponent(n)}/input`,e);return a(t,`md`,{density:`compact`,doc:`chat:${e}`,scope:[n,e],ready:()=>Je(n),...U?{away:U}:{},send:(t,n)=>i(o,{entry:e,index:t.ref.block,fields:t.fields})(n)})},W=()=>ae===!0&&d().head===!0,G=()=>f(`article`,{class:`tx skip`,hidden:``});function K(e){switch(e.kind){case`user`:{let t=d().service?l(e.text):void 0;if(t)return B(e,t.kind===`intercom`?V(t.from):[t.kind===`server`?Me():Pe()],e.text??``);let n=d().service?u(e.text):void 0;return z(e,n?n.body:e.text??``,n?.crashed,n?e.text??``:``)}case`assistant`:{let t=d();if(W()&&!e.text&&!e.thought&&!e.error&&!e.stop)return G();let n=f(`pre`,{class:`thought-text`}),r=e.thought?f(`button`,{class:`thought`,type:`button`},e.thought<0?He():Ve({count:e.thought.toLocaleString()})):null;return e.thought&&e.thought>0&&r?.addEventListener(`click`,()=>I(r,n,e.id,e=>e.thoughtText)),f(`article`,{class:t.head?`tx in head`:`tx in`},tt(t.head?`crown`:t.role),f(`div`,{class:`tx-body`},f(`header`,null,f(`b`,null,Ze(t)),e.model?f(`span`,null,e.model):null,R(e),e.stop?f(`span`,{class:`stop`,"data-mark":`error`},e.stop):null),r,n,e.text?Le(e.id,e.text):null,e.error?f(`p`,{class:`fault`},e.error):null,...(W()?[]:e.tools??[]).flatMap(t=>ke(t,e.id))))}case`bash`:return W()?G():f(`article`,{class:`tx sys`},f(`details`,{class:`act`},f(`summary`,{"data-mark":e.exit?`error`:`done`},f(`b`,{class:`badge`}),f(`code`,null,`shell`),f(`span`,{class:`sum`},`! ${e.command}`),e.exit?f(`span`,{class:`stop`,"data-mark":`error`},de({code:e.exit})):null),e.text?f(`pre`,{class:`out`},e.text):null));case`notice`:{let t=c(e);return t?.kind===`boss`&&d().service?z(e,t.body,t.crashed,e.text??``):W()&&(t?.kind===`server`||t?.kind===`timer`)?G():t&&t.kind!==`boss`?B(e,Ne(t),t.body,t.kind===`link`?{raw:t.raw}:{crashed:t.crashed}):B(e,[et[e.type??``]?.()??e.type??ye(),` `,e.from&&te(e.from)||(e.from??``)],e.text??``)}case`divider`:return e.type===`chapter`?f(`article`,{class:`tx rule chapter`},f(`p`,null,fe({date:e.at?new Date(e.at).toLocaleDateString(t(),{year:`numeric`,month:`short`,day:`numeric`}):``,why:Xe(e.code,e.text)}))):f(`article`,{class:`tx rule`},f(`details`,null,f(`summary`,null,e.type===`compaction`?le({tokens:(e.tokens??0).toLocaleString()}):se()),f(`pre`,null,e.text??``)));default:return f(`article`,{class:`tx note`},e.text??``,` `,R(e))}}function q(e){e.rebuild&&(g.clear(),y.replaceChildren());for(let t of e.dropped)g.get(t)?.remove(),g.delete(t);let t=e.added.map(e=>(g.set(e.id,K(e)),g.get(e.id)));e.front?y.prepend(...t):y.append(...t),E&&!e.front&&!e.rebuild&&t.forEach(e=>(e.classList.add(`fresh`),e.dataset.born=String(Date.now()))),S.remove();let n=d().service;S.textContent=n?.state===`standing`&&!n.run?Ue():ve(),h.items.length||y.append(S),b.hidden=!h.before,qe()}let J=[],Y=new Map;function qe(){let t=new Set;for(let n of J){let r=Date.parse(n.startedAt),i=h.items.findIndex(e=>e.at!==void 0&&Date.parse(e.at)>=r);if(i===0&&h.before)continue;let a=i<0?``:h.items[i].id,o=JSON.stringify([a,e(n)]),s=Y.get(n.id);if(t.add(n.id),s&&s.sig===o&&s.el.isConnected)continue;s?.el.remove();let c=e(n),l=f(`article`,{class:`tx rule conv-rule`},f(`div`,null,f(`b`,null,c.title),c.ended?f(`small`,null,c.ended):null));Y.set(n.id,{el:l,sig:o});let u=a?g.get(a):void 0;u?u.before(l):y.append(l)}for(let[e,n]of Y)t.has(e)||(n.el.remove(),Y.delete(e))}let X=e=>e.touched.forEach(e=>{let t=g.get(e),n=h.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),g.set(e,r)}}),Z=async()=>{if(!T&&h.before&&E){T=!0;try{let e=C.scrollHeight,t=h.prepend(await r.older(h.before));q(t),X(t),C.scrollTop+=C.scrollHeight-e}finally{T=!1}h.before&&C.clientHeight&&b.getBoundingClientRect().bottom>=C.getBoundingClientRect().top&&Z()}};x.addEventListener(`click`,()=>{D=void 0,h.detached?r.latest().then(e=>(q(h.reset(e)),F())):F()});let Q=[new IntersectionObserver(e=>e.some(e=>e.isIntersecting)&&void Z(),{root:C}),new IntersectionObserver(e=>C.clientHeight&&(w.scrolled(e.at(-1).isIntersecting),P()),{root:C,rootMargin:`0px 0px 67px`})],$,rt=()=>($??(Q[0].observe(b),Q[1].observe(pe)),clearTimeout($),$=setTimeout(()=>($=void 0,Q.forEach(e=>e.disconnect())),600));C.addEventListener(`scroll`,()=>(rt(),w.moved(C.scrollTop,()=>C.scrollHeight-C.clientHeight)&&P(),!A&&j!==void 0&&N()),{passive:!0}),C.addEventListener(`wheel`,e=>e.deltaY<0&&N(),{passive:!0}),C.addEventListener(`keydown`,e=>([`ArrowUp`,`PageUp`,`Home`].includes(e.key)||e.key===` `&&e.shiftKey)&&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 it=new ResizeObserver(()=>M()?w.parked(C.scrollTop):w.pinned&&!h.detached?Ce():O?.scrollIntoView({block:`center`}));return it.observe(y),it.observe(C),{log:C,docs:v,box:()=>H.forEach(e=>{let t=e.deref();t?t.refresh():H.delete(e)}),runs(e){JSON.stringify(e)!==JSON.stringify(J)&&(J=e,qe())},apply(e){if(e.reset)q(h.reset({items:e.items??[],before:e.before})),E=!0,Ee();else if(e.items?.length){let t=h.append(e.items);q(t),X(t),w.arrived(t.added.length)&&!h.detached&&!M()?F():P()}},reveal(e){D=e,E&&Ee()}}}export{$ as mountChat,me as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./runtime-ZX6HkxDa.js";import{t}from"./open_main_title-DyToxqLu.js";import{t as n}from"./unit_count-DESQ_h2Y.js";import"./headkey-BhBqIerz.js";import{A as r,C as i,E as a,F as o,H as s,Jt as c,M as l,N as u,Q as d,S as f,T as p,bt as m,c as h,d as g,ft as _,g as v,nt as y,u as b,v as x,w as S,x as C,z as w}from"./index-
|
|
1
|
+
import{t as e}from"./runtime-ZX6HkxDa.js";import{t}from"./open_main_title-DyToxqLu.js";import{t as n}from"./unit_count-DESQ_h2Y.js";import"./headkey-BhBqIerz.js";import{A as r,C as i,E as a,F as o,H as s,Jt as c,M as l,N as u,Q as d,S as f,T as p,bt as m,c as h,d as g,ft as _,g as v,nt as y,u as b,v as x,w as S,x as C,z as w}from"./index-Ci_M1nWI.js";var T=((t={},n={})=>(n.locale??e())===`zh-TW`?`關閉清單`:`Close the list`),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`切換到其他單位`:`Switch to a unit`),ee=((t={},n={})=>(n.locale??e())===`zh-TW`?`回到主地圖`:`Back to the map`),te=((t={},n={})=>(n.locale??e())===`zh-TW`?`所有單位`:`All units`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`指揮中`:`commanding`),O=((t={},n={})=>(n.locale??e())===`zh-TW`?`已結束`:`ended`),k=((t={},n={})=>(n.locale??e())===`zh-TW`?`錯誤`:`error`),A=((t={},n={})=>(n.locale??e())===`zh-TW`?`閒置`:`idle`),j=((t={},n={})=>(n.locale??e())===`zh-TW`?`無狀態`:`unknown`),M=((t={},n={})=>(n.locale??e())===`zh-TW`?`等待`:`waiting`),N=((t={},n={})=>(n.locale??e())===`zh-TW`?`工作中`:`working`),P=.4;function F(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 I=(e,t,n)=>Math.abs(n)>=.45?n>0:e>=t*P,L=(e,t)=>t||e.some(e=>e.editable||e.sink||e.scrollsX||[`input`,`textarea`,`select`].includes(e.tag));function R(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 z=e=>{let t=[];for(let n=e;n;n=n.parentElement)t.push(R(n));return t},B={working:N,waiting:M,idle:A,done:O,error:k,unknown:j,commanding:D},V=(e,t,n)=>(t?O:B[e])({},n&&{locale:n}),H=(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 U(e){return e.bases.flatMap(e=>{let t=[{id:`tower`,rows:e.tower?H(e.id,[{...e.tower,role:`tower`}]):[]},...e.tabs.map(t=>({id:t.id,label:m({label:t.label}),rows:H(e.id,t.units)})),{id:`outside`,label:y(`outside_net`),rows:H(e.id,e.outside)}].filter(e=>e.rows.length);return t.length?[{id:e.id,label:e.label,mark:e.mark,groups:t}]:[]})}var W=(e,t)=>e?.head?{mark:e.head.mark,word:e.head.state===`absent`?c({},t&&{locale:t}):V(e.head.mark,!1,t)}:void 0,G=e=>e.role===`main`&&e.mark===`idle`,K=e=>e.reduce((e,t)=>(t.sub?e.at(-1)?.subs.push(t):e.push({...t,subs:[]}),e),[]),q=()=>x(`<div class="unit"><div class="card"><a class="hit"></a>${h}<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>`),ne=()=>x(`<div class="unit tower-row"><div class="trow"><a class="tower-go">${h}<span class="meta"><span class="name"></span><span class="line"><em class="role"></em><b class="dstate"></b></span></span></a><button type="button" class="pair-btn tower-add"></button></div><div class="subs"></div></div>`),re=()=>x(`<section class="dbase"><h3><a></a><small></small></h3><div class="dgroups"></div></section>`),ie=()=>x(`<div class="dgroup"><h4></h4><div class="drows"></div></div>`),ae=()=>matchMedia(`(max-width: 640px)`).matches;function J(e=()=>!1){let c=_(`div`,{class:`drawer-body`}),m=_(`button`,{type:`button`,class:`x`,"aria-label":T()},`×`),h=_(`a`,{class:`drawer-map`},ee()),D=_(`button`,{type:`button`,class:`pair-btn`,"data-close":`dismiss-all`,hidden:``}),O=_(`div`,{class:`drawer-sweep`,hidden:``},D);b(h,{view:`map`});let k=x(`<a class="drawer-head"><svg viewBox="0 0 512 512" aria-hidden="true"><use data-icon="crown"/></svg><span class="name"></span><b class="dstate"></b></a>`);k.hidden=!0,b(k,{view:`head`});let A=_(`aside`,{class:`drawer`,"aria-label":E()},_(`header`,null,_(`b`,null,te()),m),k,c,_(`footer`,{class:`drawer-foot`},O,h)),j=_(`div`,{class:`drawer-veil`});document.body.append(j,A);let M,N,P=!1,R=!1,B=0,H=0,J,Y=()=>{let e=W(M);k.hidden=!e,e&&(C(k,e.mark),a(k,`.name`,y(`head_tower`)),a(k,`.dstate`,e.word),k.classList.toggle(`current`,P),k.toggleAttribute(`data-news`,w(M?.head,s())&&!P)),u(D,M??{bases:[]}),O.hidden=D.hidden;let l=(e,t)=>{b(e.querySelector(`.hit`),{view:`session`,ws:t.ws,key:t.key}),e.querySelector(`.hit`).setAttribute(`aria-label`,`${t.name}: ${V(t.mark,t.ended)}`),e.classList.toggle(`current`,t.key===N),e.toggleAttribute(`data-dismiss`,t.role===`subagent`&&t.ended),e.dataset.key=t.key,C(e,t.mark),v(e.querySelector(`.plate`),t.role,t.mark),a(e,`.name`,t.name),a(e,`.role`,(e=>e?i(e.role,e.duty):f(t.role))(d(M,t.key)?.u)),a(e,`.dstate`,V(t.mark,t.ended)),S(e,`.note`,t.note,t.mark,t.note?void 0:``);let n=e.querySelector(`:scope > .card > .quit-btn`);G(t)?r(n,t,e=>o(M?.bases.find(e=>e.id===t.ws),e)):n.hidden=!0,p(e.querySelector(`.subs`),t.subs??[],q,l)},m=(e,n)=>{let r=e.querySelector(`.tower-go`),i=e.querySelector(`.tower-add`),o=M?.bases.find(e=>e.id===n.ws);b(r,{view:`session`,ws:n.ws,key:n.key}),r.setAttribute(`aria-label`,`${n.name}: ${V(n.mark,n.ended)}`),e.classList.toggle(`current`,n.key===N),e.dataset.key=n.key,C(e,n.mark),v(r.querySelector(`.plate`),`tower`,n.mark),a(r,`.name`,n.name),a(r,`.role`,f(`tower`)),a(r,`.dstate`,V(n.mark,n.ended)),i.hidden=!o,o&&(g(i,o),i.setAttribute(`aria-label`,t({base:o.label}))),p(e.querySelector(`.subs`),n.subs,q,l)};p(c,U(M??{bases:[]}),re,(e,t)=>{C(e,t.mark),a(e,`h3 a`,t.label),b(e.querySelector(`h3 a`),{view:`workspace`,ws:t.id}),a(e,`small`,n({count:t.groups.reduce((e,t)=>e+t.rows.length,0)})),p(e.querySelector(`.dgroups`),t.groups,ie,(e,t)=>{a(e,`h4`,t.label??``),e.querySelector(`h4`).toggleAttribute(`hidden`,!t.label),t.id===`tower`?p(e.querySelector(`.drows`),K(t.rows),ne,m):p(e.querySelector(`.drows`),K(t.rows),q,l)})})},X=e=>{B=Math.max(0,Math.min(H,e)),A.style.setProperty(`--dx`,`${B}px`),j.style.opacity=String(H?B/H:0),j.style.pointerEvents=B>0?`auto`:`none`},Z=e=>{R=e,A.classList.toggle(`on`,e),A.inert=!e,document.documentElement.classList.remove(`drawer-drag`),X(e?H:0)},Q=()=>{H=A.offsetWidth,Y(),A.classList.add(`on`),document.documentElement.classList.add(`drawer-drag`)};A.inert=!0,document.addEventListener(`touchstart`,t=>{let n=t.target,r=A.contains(n)||n===j;if(J=void 0,!ae()||e()||t.touches.length!==1||document.querySelector(`dialog.sheet[open], dialog.lightbox[open], [popover]:popover-open`)||(R?!r:L(z(n),!!getSelection()?.toString())))return;let i=t.touches[0],a=R?n.closest(`.unit[data-dismiss] > .card`)??void 0:void 0;J={x0:i.clientX,y0:i.clientY,mode:`wait`,was:R,base:B,last:i.clientX,at:performance.now(),v:0,card:a}},{passive:!0}),document.addEventListener(`touchmove`,e=>{if(!J||J.mode===`pass`)return;let t=e.touches[0],n=t.clientX-J.x0,r=t.clientY-J.y0;if(J.mode===`wait`){let e=F(n,r,J.was);if(e===`wait`)return;if(e===`pass`&&J.card&&F(n,r,!1)===`drag`)J.mode=`card`,J.card.classList.add(`swiping`);else if(e===`pass`)return void(J.mode=`pass`);else J.mode=`drag`,Q()}e.preventDefault();let i=performance.now();if(J.v=(t.clientX-J.last)/Math.max(1,i-J.at),[J.last,J.at]=[t.clientX,i],J.mode!==`card`)return X(J.base+n);let a=Math.max(0,n);J.card.style.setProperty(`--sx`,`${a}px`),J.card.style.setProperty(`--so`,String(1-a/J.card.offsetWidth))},{passive:!1});let oe=(e,t)=>{e.classList.remove(`swiping`),e.style.removeProperty(`--sx`),e.style.removeProperty(`--so`),t&&(e.classList.add(`gone`),l({key:e.parentElement.dataset.key}).then(t=>t||e.classList.remove(`gone`)))},$=e=>{let t=J;J=void 0,t?.mode===`drag`&&Z(I(B,H,t.v)),t?.mode===`card`&&oe(t.card,e.type===`touchend`&&I(Math.max(0,t.last-t.x0),t.card.offsetWidth,t.v))};return document.addEventListener(`touchend`,$),document.addEventListener(`touchcancel`,$),j.addEventListener(`click`,()=>Z(!1)),A.addEventListener(`click`,e=>e.target.closest(`a[data-route], button[data-open], .x`)&&Z(!1)),document.addEventListener(`keydown`,e=>R&&e.key===`Escape`&&(e.preventDefault(),Z(!1)),!0),document.addEventListener(`sb-drawer`,()=>(R||Q(),Z(!R))),{net(e){M=e,R&&Y()},route(e){N=e.view===`session`?e.key:void 0,P=e.view===`head`||e.view===`session`&&e.ws===`@head`,h.toggleAttribute(`aria-current`,e.view===`map`),R&&Y()}}}export{J as mountDrawer};
|