pi-straw-boss 0.56.0 → 0.56.1
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/NOTICE.md +1 -1
- package/README.md +1 -1
- package/dist/gui/assets/{answer-BDLr0WWa.js → answer-B2xVIGxA.js} +1 -1
- package/dist/gui/assets/{ask-DJbwzEMR.js → ask-GnsZN-ZU.js} +1 -1
- package/dist/gui/assets/{chat-DlyxIKPA.js → chat-BjCnzH9C.js} +1 -1
- package/dist/gui/assets/{drawer-Bbg1_gy8.js → drawer-Db1FxK9v.js} +1 -1
- package/dist/gui/assets/{index-BteLBGsW.js → index-xkaqCr46.js} +2 -2
- package/dist/gui/assets/{layer-Va0UiuTk.js → layer-C0tYSonN.js} +1 -1
- package/dist/gui/assets/{lightbox-CAi9HfcE.js → lightbox-B_LOCdRi.js} +1 -1
- package/dist/gui/assets/{link-CVicotMs.js → link-Czdv2G24.js} +1 -1
- package/dist/gui/assets/{linkdialogs-CwO8DXoU.js → linkdialogs-DvpmFqpw.js} +1 -1
- package/dist/gui/assets/{pair-DcuwxibU.js → pair-_0iZp_rL.js} +1 -1
- package/dist/gui/assets/{picker-CwvN6kaN.js → picker-BxEsplO6.js} +1 -1
- package/dist/gui/assets/{server-CfGyF8i4.js → server-CfO0fbdV.js} +1 -1
- package/dist/gui/assets/{sessionfacts-CWeNf5C1.js → sessionfacts-DEAEBK6-.js} +1 -1
- package/dist/gui/assets/{settings-D5WSsDVI.js → settings-BbLlLiNl.js} +1 -1
- package/dist/gui/assets/{spawn-DPBblLEw.js → spawn-Ctnm_ccF.js} +1 -1
- package/dist/gui/assets/{termcard-B_xjw9yF.js → termcard-fFZrioKd.js} +1 -1
- package/dist/gui/assets/{trust-DcJzD-5o.js → trust-rtDPq63p.js} +1 -1
- package/dist/gui/assets/{unit_count-BGpcT4cf.js → unit_count-C_IKdFh4.js} +1 -1
- package/dist/gui/assets/{views-DieWterC.js → views-46qJ0r7v.js} +1 -1
- package/dist/gui/assets/zenchunk-CSJxIIPm.js +2 -0
- package/dist/gui/assets/zenchunk-wpsmgtPq.css +1 -0
- package/dist/gui/index.html +1 -1
- package/package.json +1 -1
- package/prompts/integrator.md +1 -1
- package/prompts/main.md +1 -1
- package/dist/gui/assets/zenchunk-BdRRs6h7.css +0 -1
- package/dist/gui/assets/zenchunk-CbbcfYmr.js +0 -2
package/NOTICE.md
CHANGED
|
@@ -63,4 +63,4 @@ Straw Link's safety words are drawn from the BIP-39 English word list (2048 word
|
|
|
63
63
|
|
|
64
64
|
## Zen view lines
|
|
65
65
|
|
|
66
|
-
The short lines under the Zen view's idle circle (`gui/zenlines.ts`) are one sentence or less each, shown with their source. Their sources, with the book, page, or chapter of each, are named in the comment above every entry: Thich Nhat Hanh, *Peace Is Every Step* (Bantam, 1991; 橡實文化 for the Chinese); Tara Brach and Mindful.org (mindful.org); Sharon Salzberg (sharonsalzberg.com); 華人正念減壓中心 (mindfulness.com.tw); 陳德中 and 台灣正念工坊 (Firstory). A Chinese line marked `zh: our translation`, and an English line marked `en: our translation`, are ours.
|
|
66
|
+
The short lines under the Zen view's idle circle (`gui/zenlines.ts`) are one sentence or less each, shown with their source. Their sources, with the book, page, or chapter of each, are named in the comment above every entry: Thich Nhat Hanh, *Peace Is Every Step* (Bantam, 1991; 橡實文化 for the Chinese); Tara Brach and Mindful.org (mindful.org); Sharon Salzberg (sharonsalzberg.com); 華人正念減壓中心 (mindfulness.com.tw); 陳德中 and 台灣正念工坊 (Firstory); Zen Mind, Beginner's Mind by Shunryu Suzuki (Weatherhill, 1970); and the Japanese works whose originals are shown in small type under a line: Matsuo Bashō (おくのほそ道, haiku), Yosa Buson and Kobayashi Issa (haiku), Kamo no Chōmei (方丈記), Yoshida Kenkō (徒然草), Sei Shōnagon (枕草子), the waka of Fujiwara no Teika (新古今和歌集), Ki no Tomonori (古今和歌集), Yamabe no Akahito (万葉集), and Dōgen (傘松道詠), 利休百首 (Urasenke's text), Ii Naosuke (茶湯一会集), Tanizaki Jun'ichirō (陰翳礼讃), Masaoka Shiki and Natsume Sōseki (haiku), and Taneda Santōka (草木塔); the texts of Aozora Bunko, Wikisource, the Nara Manyo Culture Museum database, and Urasenke are named in the comments. A Chinese line marked `zh: our translation`, and an English line marked `en: our translation`, are ours.
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@ English | [繁體中文](https://github.com/wayne930242/pi-straw-boss/blob/main/
|
|
|
18
18
|
|
|
19
19
|
<p align="center"><sub>A unit's comms, a question you can answer from the browser, the Geek view, the settings page where each device picks its view, and the same page on a phone.</sub></p>
|
|
20
20
|
|
|
21
|
-
**Zen** is the third view, for the hours when you are answering the net rather than steering it. When something waits for you, the page shows that one thing alone: no map, no count of what else is queued. When you answer, cancel, or skip it (Maybe later), a breath of a pause follows, then the next. A dialog with several questions shows one at a time: the one you are on is open and clear, the others fold to one faded line (the question, and your answer once it has one), and a scroll or swipe, picking an answer, Tab, or a tap on a line moves on to the next. When nothing waits, a breathing circle and a short line on mindfulness: every visit starts there. `[` or `]` steps to a session to keep you company, its live log and its composer, and the circle sits where the list wraps round; ⌘K's *Back to the breath* returns to it. No session, a tower included, is put there for you. One Esc cancels the question on the page, or skips the card when it cannot be cancelled; Esc twice (or the corner menu's last row) goes back to Standard. The corner menu also holds the language, the view, and the sound and volume, and the button beside it takes the page to full screen. An answer that leaves a terminal step (robot_hand's *Put it in my prompt* or a new Herdr pane) shows a small card in ink to finish it, which closes by itself when your Enter is taken or the pane closes; *Full terminal* on the card opens the whole terminal inside Zen, with *Back to Zen* in the top right corner. **Keys.** Enter or Space ends the breathing pause early (so does a tap); Esc answers or skips the card on the page, and a second Esc within 600 ms goes back to Standard (with the corner menu open, Esc only closes it; with text in a box, it only lets the box go). Inside a terminal the page does not take Esc: Shift+Esc lets the keyboard out of the terminal. **H** opens *Context* on a card, the unit's session log inside the card, read-only, and you can still answer while it is open; H or Esc closes it. `[` and `]` step the session beside you (the companion) through the sessions you can talk to. **⌘K** (Ctrl+K off a Mac) opens a command palette for the page's actions and the corner menu's choices. While nothing waits, a quiet line at the top says how many units work and how many are idle; it never counts what waits. Moving the pointer leaves faint ripples. **Sound** follows the settings page's Sound switch (off by default) and Volume: a soft singing-bowl tone when an item takes the screen, a wooden-fish knock when one is done, a lower bowl on an error; the corner menu's *Try the sounds* plays them. Set it as the default with `/boss gui view zen`, or pick it on a device's settings page. Music is yours: put audio files (mp3, m4a, ogg, wav, flac, and the like) in `~/.pi/agent/straw-boss-music/` and Zen shows a ♪ in the corner that plays them on a loop, with a ⌄ to choose the track (shown when there are two or more); with no files there is no ♪. The folder is read each time Zen shows, and tracks cross-fade into themselves so the loop has no gap. On a phone nothing plays before your first tap (♪ says *tap to play* until then, and again after the phone locks), the music pauses while the page is hidden, and the ringer switch mutes it. Motion stops under *reduce motion*, and the page follows the system's forced colours.
|
|
21
|
+
**Zen** is the third view, for the hours when you are answering the net rather than steering it. When something waits for you, the page shows that one thing alone: no map, no count of what else is queued. When you answer, cancel, or skip it (Maybe later), a breath of a pause follows, then the next. A dialog with several questions shows one at a time: the one you are on is open and clear, the others fold to one faded line (the question, and your answer once it has one), and a scroll or swipe, picking an answer, Tab, or a tap on a line moves on to the next. When nothing waits, a breathing circle and a short line on mindfulness or stillness, with whom it comes from (a Japanese source also has its original, small, below): every visit starts there. `[` or `]` steps to a session to keep you company, its live log and its composer, and the circle sits where the list wraps round; ⌘K's *Back to the breath* returns to it. No session, a tower included, is put there for you. One Esc cancels the question on the page, or skips the card when it cannot be cancelled; Esc twice (or the corner menu's last row) goes back to Standard. The corner menu also holds the language, the view, and the sound and volume, and the button beside it takes the page to full screen. An answer that leaves a terminal step (robot_hand's *Put it in my prompt* or a new Herdr pane) shows a small card in ink to finish it, which closes by itself when your Enter is taken or the pane closes; *Full terminal* on the card opens the whole terminal inside Zen, with *Back to Zen* in the top right corner. **Keys.** Enter or Space ends the breathing pause early (so does a tap); Esc answers or skips the card on the page, and a second Esc within 600 ms goes back to Standard (with the corner menu open, Esc only closes it; with text in a box, it only lets the box go). Inside a terminal the page does not take Esc: Shift+Esc lets the keyboard out of the terminal. **H** opens *Context* on a card, the unit's session log inside the card, read-only, and you can still answer while it is open; H or Esc closes it. `[` and `]` step the session beside you (the companion) through the sessions you can talk to. **⌘K** (Ctrl+K off a Mac) opens a command palette for the page's actions and the corner menu's choices. While nothing waits, a quiet line at the top says how many units work and how many are idle; it never counts what waits. Moving the pointer leaves faint ripples. **Sound** follows the settings page's Sound switch (off by default) and Volume: a soft singing-bowl tone when an item takes the screen, a wooden-fish knock when one is done, a lower bowl on an error; the corner menu's *Try the sounds* plays them. Set it as the default with `/boss gui view zen`, or pick it on a device's settings page. Music is yours: put audio files (mp3, m4a, ogg, wav, flac, and the like) in `~/.pi/agent/straw-boss-music/` and Zen shows a ♪ in the corner that plays them on a loop, with a ⌄ to choose the track (shown when there are two or more); with no files there is no ♪. The folder is read each time Zen shows, and tracks cross-fade into themselves so the loop has no gap. On a phone nothing plays before your first tap (♪ says *tap to play* until then, and again after the phone locks), the music pauses while the page is hidden, and the ringer switch mutes it. Motion stops under *reduce motion*, and the page follows the system's forced colours.
|
|
22
22
|
|
|
23
23
|
<p align="center"><img src="docs/gui-zen-item.png" width="49%" alt="The Zen view with one item: a robot_hand question from ops-main on an ink-dark page, its choices as lines of text, each with a dot, and Maybe later below"> <img src="docs/gui-zen-idle.png" width="49%" alt="The Zen view when nothing waits: a session stepped to with ], its live log and its composer"></p>
|
|
24
24
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{t as e}from"./runtime-ZX6HkxDa.js";import{t}from"./ask-
|
|
1
|
+
import{t as e}from"./runtime-ZX6HkxDa.js";import{t}from"./ask-GnsZN-ZU.js";import{n}from"./post-CmicYl-f.js";import{j as r}from"./index-xkaqCr46.js";var i=((t={},n={})=>(n.locale??e())===`zh-TW`?`這些訊息在 sb server 的佇列裡,等塔台下一個 run 取走;run 啟動時就會被取走。`:`These messages wait in the sb server's queue for the tower's next run; they are taken when it runs.`),a=((t={},n={})=>(n.locale??e())===`zh-TW`?`塔台正在待命:沒有進行中的 run,所以沒有終端機。請在輸入框寫給它,那會喚醒它。`:`The tower is standing by: no run is live, so there is no terminal. Write to it in the composer; that wakes it.`),o=((t={},n={})=>(n.locale??e())===`zh-TW`?`塔台因反覆當機而暫停,沒有終端機。請重試,或在「通訊」裡寫給它。`:`The tower is held after repeated crashes, so it has no terminal. Retry it, or write to it in Comms.`),s=((t={},n={})=>(n.locale??e())===`zh-TW`?`塔台正在待命,沒有終端機。run 被喚醒時才會開一個;請在「通訊」裡寫給它來喚醒。`:`The tower is standing by, so it has no terminal. A run opens one when it wakes; write to it in Comms to wake it.`),c=`[the boss writes to you from the GUI or /boss tower; this is an instruction]`,l=`[possibly handled by a run that crashed: check before acting]`;function u(e){let t=(e??``).split(`
|
|
2
2
|
`,1)[0];if(t.startsWith(`[intercom from `)&&t.endsWith(`]`))return{kind:`intercom`,from:t.slice(15,-1)};if(t===`[notice from the sb server]`)return{kind:`server`};if(t===`[your wakeAfter follow-up is due]`)return{kind:`timer`}}function d(e){let t=(e??``).split(`
|
|
3
3
|
`);if(t[0]!==`[the boss writes to you from the GUI or /boss tower; this is an instruction]`)return;let n=t[1]===l;return{body:t.slice(n?2:1).join(`
|
|
4
4
|
`),crashed:n}}function f(e){let t=(e??``).trim(),n=/^(.*?)\s*\(([^()]*)\)$/.exec(t);return n?{name:n[1],...n[2]?{id:n[2]}:{}}:{name:t}}function p(e){let t=e??``;if(!t.startsWith(`[straw net `))return;let n={},r=11;for(;;){for(;t[r]===` `;)r++;if(t[r]===`]`)break;let e=t.indexOf(`=`,r);if(e<0||!/^[a-z]+$/.test(t.slice(r,e)))return;let i=t.slice(r,e),a;if(t[e+1]===`"`){if(a=t.indexOf(`"`,e+2),a<0)return;n[i]=t.slice(e+2,a++)}else{for(a=e+1;a<t.length&&t[a]!==` `&&t[a]!==`]`;)a++;n[i]=t.slice(e+1,a)}r=a}return{fields:n,raw:t.slice(0,r+1),body:t.slice(r+1).replace(/^ /,``)}}var m={intercom:e=>e.startsWith(`[intercom from `)&&e.endsWith(`]`),notice:e=>e===`[notice from the sb server]`,timer:e=>e===`[your wakeAfter follow-up is due]`};function h(e){let t=e.text??``,n=e=>{let n=t.split(`
|
|
@@ -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{Rt as o,Ut as s,t as c,vt as l}from"./index-BteLBGsW.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`?`下方還有 ▾`:`More below ▾`),p=((t={},n={})=>(n.locale??e())===`zh-TW`?`也可以自己輸入答案。`:`It also takes your own words.`),m=((t={},n={})=>(n.locale??e())===`zh-TW`?`可以複選。`:`It takes several choices.`),h=((t={},n={})=>(n.locale??e())===`zh-TW`?`已取消。`:`Cancelled.`),g=((t={},n={})=>(n.locale??e())===`zh-TW`?`選擇`:`Choices`),_=((t={},n={})=>(n.locale??e())===`zh-TW`?`瀏覽器拒絕存取剪貼簿。`:`The browser refused the clipboard.`),v=((t={},n={})=>(n.locale??e())===`zh-TW`?`已複製到這台裝置的剪貼簿。`:`Copied to this device's clipboard.`),y=((t={},n={})=>(n.locale??e())===`zh-TW`?`複製指令`:`Copy command`),ee=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個選項有預覽;請在終端機中查看。`:`It has a preview; see it in the terminal.`),b=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註`:`Note`),x=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註(選填)`:`Note (optional)`),S=e=>`Opened while ${e?.tool} was running; it may not be about that call.`,C=e=>`在 ${e?.tool} 執行時開啟,不一定與該呼叫有關。`,te=((t,n={})=>(n.locale??e())===`zh-TW`?C(t):S(t)),w=((t={},n={})=>(n.locale??e())===`zh-TW`?`選項`:`Options`),T=((t={},n={})=>(n.locale??e())===`zh-TW`?`另一個答案沒有被採用;這個可以送出。`:`The other answer was not taken; this one can go.`),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`你的答案`:`Your own answer`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`或自己輸入答案`:`Or type your own answer`),O=((t={},n={})=>(n.locale??e())===`zh-TW`?`問題已變更,請重新閱讀。`:`The question changed; read it again.`),k=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 讀不懂這個答案。`:`The session could not read that answer.`),A=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個答案不符合問題。`:`That answer does not fit the question.`),j=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 拒絕了這個答案。`:`The session refused that answer.`),M=((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.`),N=((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.`),P=((t={},n={})=>(n.locale??e())===`zh-TW`?`送出答案`:`Send answer`),F=((t={},n={})=>(n.locale??e())===`zh-TW`?`顯示終端機`:`Show terminal`),I=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中關閉。`:`It was dismissed in the terminal.`),L=((t={},n={})=>(n.locale??e())===`zh-TW`?`它已不再開啟。`:`It is no longer open.`),R=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中回答。`:`It was already answered in the terminal.`),z=((t={},n={})=>(n.locale??e())===`zh-TW`?`它在等待對話框。`:`It waits on a dialog.`),B={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1};function V(e,t,n,r,i){let{q:a}=n,o=r[a],s=B[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 H(e,t,n){let r=e=>Math.max(0,e.opts.findIndex(e=>e.getAttribute(`aria-checked`)===`true`)),i=(e,t)=>e.opts.forEach((e,n)=>e.setAttribute(`tabindex`,n===t?`0`:`-1`)),a=e=>{for(let[n,r]of t.entries()){let t=r.opts.indexOf(e);if(t>=0)return{q:n,part:`opt`,o:t};if(e===r.own||e===r.note)return{q:n,part:e===r.own?`own`:`note`}}};t.forEach(e=>i(e,r(e)));let o=e=>{let n=a(e.target);n?.part===`opt`&&i(t[n.q],n.o)};e.addEventListener(`focusin`,o),e.addEventListener(`click`,o);let s=!1;return e.addEventListener(`keydown`,i=>{let o=a(i.target);if(!o||i.ctrlKey||i.altKey||i.metaKey||i.isComposing)return;let c=i.target;if(o.part!==`opt`&&(i.key===`ArrowUp`?c.selectionStart!==0:i.key===`ArrowDown`&&c.selectionEnd!==c.value.length))return;let l=V(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(!l||(i.preventDefault(),i.repeat&&[`Enter`,` `].includes(i.key)))return;if(s=i.key===` `,l.pick!==void 0){let e=t[o.q].opts[l.pick];e.getAttribute(`aria-checked`)!==`true`&&e.click()}let u=l.to===`send`?void 0:t[l.to.q],d=l.to===`send`?n():l.to.part===`opt`?u.opts[l.to.o??r(u)]:l.to.part===`own`?u.own:u.note;d&&!d.disabled&&(e.dispatchEvent(new CustomEvent(`ask-reveal`,{detail:d})),d.focus())}),e.addEventListener(`keyup`,e=>s&&e.key===` `&&(s=!1,e.preventDefault())),()=>t[0]?.opts[r(t[0])]}var U=e=>e.multiple?m():e.freeform&&e.options.length?p():``,W=90,G=(e,t)=>s(`div`,{class:`ask-one`},e.header&&s(`b`,{class:`ask-head`},e.header),s(`p`,{class:`ask-q`,...e.question.length>W?{"data-long":``}:{}},e.question),e.context&&s(`div`,{class:`ask-ctx`},e.context),e.options.length>0&&s(`ol`,{class:`ask-opts`,"aria-label":w()},...e.options.map(e=>s(`li`,{class:`ask-opt`},s(`b`,null,e.title),e.description&&s(`small`,null,e.description)))),t&&U(e)&&s(`small`,{class:`ask-how`},U(e))),K=e=>e.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\p{Cf}]/gu,`�`),q=e=>(e.select?.choices??[]).map((e,t)=>({...e,i:t})),J=(e,t,n)=>({...e.size?{choices:[...e].sort((e,t)=>e-t)}:{},...t.trim()?{text:t}:{},...n.trim()?{note:n}:{}}),Y=(e,t,n)=>({dialog:e.dialog,digest:e.digest,answerId:n,...t}),X=(e,t)=>({dialog:e.dialog,digest:e.digest,answerId:t,cancel:!0}),Z=(e,t)=>e.cancel===!0&&!(t&&e.select?.choices.every(e=>e.hereOnly)),Q={digest:O,"not-allowed":A,malformed:k};function ne(e,i=!1){let{outcome:a,reason:o,by:s}=e.body;return a===`accepted`?[`ok`,i?h():n()]:a===`stale`?[`error`,s===`local`?R():s===`cancel`?I():L()]:a===`rejected`?[`error`,(Object.hasOwn(Q,String(o))?Q[String(o)]:j)()]:a===`busy`?[`error`,t()]:a===`unknown`||e.status===504?[`error`,r(),!0]:[`error`,o??l({status:e.status})]}var re=e=>[`accepted`,`stale`,`busy`,`unknown`].includes(String(e.body.outcome))||e.status===504,$=e=>e.answer?`d\n${e.answer.dialog}\n${e.answer.digest}`:`c\n${e.callId}\n${e.why??``}`;function ie(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=f()};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)}function ae(e,t,n=location.hostname!==`127.0.0.1`,l,f,p=F){let m,h,S,C=!1,O=!1,k;for(let e of[`focusin`,`pointerdown`])document.addEventListener(e,e=>h&&!h.el.contains(e.target)&&(h.lost=void 0));let A=(e,t,n,...r)=>(e.dataset.tone=t,e.replaceChildren(n,...r)),j=()=>{if(!h)return;let e=document.activeElement;e&&e!==document.body&&e!==h.lost&&(h.lost=void 0),h.controls.forEach(e=>e.disabled=!C||O||h.done),h.send&&(h.send.disabled=!C||O||h.done||!h.pick()),e&&h.el.contains(e)&&e.disabled&&(h.lost=e);let t=h.lost;t&&!t.disabled&&h.el.contains(t)&&(!document.activeElement||document.activeElement===document.body)&&(t.focus(),h.lost=void 0)};async function I(e,n){[e.sending,O,e.spell]=[!0,!0,!1],j(),A(e.note,``,a());let o=await t(`answer`,n).catch(()=>void 0),u=s(`button`,{type:`button`,class:`cmp-link`},i());u.onclick=()=>void I(e,n);let[d,p,m]=o?ne(o,n.cancel===!0):[`error`,r(),!0];[e.done,e.sending,O,e.busy]=[!o||re(o),!1,!1,o?.body.outcome===`busy`],A(e.note,d,p,...m?[u]:[]);let h=o?.body.outcome===`accepted`?o.body.then:void 0,g=h&&c(h,{key:l?.key??``,command:e.copy,answerId:String(n.answerId??``)});g&&A(e.note,d,`${p} ${g}`),j(),e.note.scrollIntoView?.({block:`nearest`}),f&&o?.body.outcome===`accepted`&&setTimeout(()=>f(!!h&&!g),h&&!g?0:1200)}let L=(e,t,n,r,i)=>{let a=s(`button`,{type:`button`,class:`ask-opt`,role:e,"aria-checked":`false`},s(`b`,i?{"data-n":String(i)}:null,t),...n.filter(Boolean).map(e=>s(`small`,null,e)));return a.onclick=r,a};function R(e,t){let r,i=q(t).map(e=>L(`radio`,K(e.label),[e.note&&K(e.note)],()=>(r=e.i,i.forEach((n,r)=>n.setAttribute(`aria-checked`,String(q(t)[r].i===e.i))),j()),e.i+1)),a=t.select?.copy!==void 0&&s(`button`,{type:`button`,class:`cmp-link`},y());a&&(a.disabled=!navigator.clipboard,a.onclick=()=>void navigator.clipboard.writeText(t.select.copy).then(()=>A(e.note,`ok`,v()),()=>A(e.note,`error`,_())));let o=i.filter((e,r)=>!(n&&q(t)[r].hereOnly));return i.forEach(e=>!o.includes(e)&&(e.disabled=!0)),e.pick=()=>r===void 0?void 0:{choice:r},e.first=H(e.el,[{opts:i,multiple:!1,answered:()=>r!==void 0}],()=>e.send),e.controls=o,[s(`pre`,{class:`ask-title`},K(t.select.title)),s(`div`,{class:`ask-opts`,role:`radiogroup`,"aria-label":g()},...i),s(`div`,{class:`ask-acts`},e.send,e.cancel,a)]}function B(e,t){let n=t.questions.map(()=>({picks:new Set,text:s(`textarea`,{rows:`1`,maxlength:`8192`,class:`ask-own`,placeholder:D(),"aria-label":E()}),note:s(`input`,{type:`text`,maxlength:`2048`,class:`ask-own ask-memo`,placeholder:x(),"aria-label":b()})})),r=[],i=t.questions.map((t,i)=>{let a=n[i],o=t.multiple?`checkbox`:`radio`,c=t.options.map((e,n)=>L(o,e.title,[e.description,e.preview&&ee()],()=>{t.multiple||(a.picks.clear(),a.text.value=``),a.picks.has(n)?a.picks.delete(n):a.picks.add(n),c.forEach((e,t)=>e.setAttribute(`aria-checked`,String(a.picks.has(t)))),j()}));return a.text.oninput=()=>(t.multiple||(a.picks.clear(),c.forEach(e=>e.setAttribute(`aria-checked`,`false`))),j()),e.controls.push(...c,a.text,a.note),r.push({opts:c,multiple:!!t.multiple,own:a.text,note:a.note,answered:()=>a.picks.size>0||a.text.value.trim()!==``}),s(`div`,{class:`ask-one`},t.header&&s(`b`,{class:`ask-head`},t.header),s(`p`,{class:`ask-q`,...t.question.length>W?{"data-long":``}:{}},t.question),s(`div`,{class:`ask-opts`,role:t.multiple?`group`:`radiogroup`,"aria-label":w()},...c),a.text,a.note)});return e.pick=()=>n.every(e=>e.picks.size||e.text.value.trim())?{answers:n.map(e=>J(e.picks,e.text.value,e.note.value))}:void 0,e.first=H(e.el,r,()=>e.send),[...i,s(`div`,{class:`ask-acts`},e.send,e.cancel)]}function V(e){let t=e.asks??(e.ask?[e.ask]:[]),r=t.length>1,i=e.answer,a={copy:i?.select?.copy,key:$(e),el:s(`section`,{class:`ask`}),note:s(`p`,{class:`ask-note`,role:`status`,"aria-live":`polite`}),controls:[],pick:()=>void 0,done:!1,sending:!1};i&&((a.send=s(`button`,{type:`button`,class:`ask-send`},P())).onclick=()=>void(a.pick()&&I(a,Y(i,a.pick(),crypto.randomUUID()))));let c=e.tool===`secret_drop`;i&&!c&&Z(i,n)&&((a.cancel=s(`button`,{type:`button`,class:`ask-cancel`},o())).onclick=()=>void I(a,X(i,crypto.randomUUID())));let f=s(`p`,{class:`ask-term`},e.why&&t.length?e.why:`${r?d():u()} ${r||!t[0]?``:U(t[0])}`.trim()),m=l&&e.tool!==`secret_drop`&&s(`button`,{type:`button`,class:`cmp-link`},p());m&&(m.onclick=l.show);let h=e.answer?.twin&&e.tool&&e.tool!==`dialog`?[s(`p`,{class:`ask-why`},te({tool:e.tool}))]:[];return a.el.append(...h,...i&&!c?i.select?R(a,i):B(a,i):[...t.length?t.map(e=>G(e,r)):[s(`p`,{class:`ask-why`},c?n?M():N():e.why??z())],s(`div`,{class:`ask-acts`},c?s(`p`,{class:`ask-term`},u()):f,m)],a.note),a.cancel&&a.controls.push(a.cancel),a}let Q=(t,n)=>{let r=document.activeElement;h&&h!==n&&(h.focus=h.el.contains(r)?r:void 0),[m,h,S]=[t,n,n?.send?n:S],e.replaceChildren(...n?[n.el]:[]),n&&ie(n.el),j(),n?.focus&&(!document.activeElement||document.activeElement===document.body)&&n.focus.focus()};return{enter(){let e=h&&!h.done?h.first?.():void 0;return!!(e&&!e.disabled&&(e.focus(),1))},cancel(){let e=h&&!h.done?h.cancel:void 0;return!!(e&&!e.disabled&&(e.click(),1))},sending:()=>O,update(e,t){C=t,e&&(k=void clearTimeout(k)),!e&&(h?.done||h?.sending)?k??=setTimeout(()=>(k=void 0,Q()),6e3):e?h&&($(e)===h.key||!e.answer&&(h.done||h.sending)&&e.callId===m?.callId)?((h.busy||h.sending)&&!e.answer?h.spell=!0:h.busy&&h.spell&&e.answer&&([h.done,h.busy]=[!1,!1],A(h.note,``,T())),m=e):Q(e,S?.key===$(e)&&!S.done?S:V(e)):Q(),j()}}}export{ae 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{Rt as o,Ut as s,t as c,vt as l}from"./index-xkaqCr46.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`?`下方還有 ▾`:`More below ▾`),p=((t={},n={})=>(n.locale??e())===`zh-TW`?`也可以自己輸入答案。`:`It also takes your own words.`),m=((t={},n={})=>(n.locale??e())===`zh-TW`?`可以複選。`:`It takes several choices.`),h=((t={},n={})=>(n.locale??e())===`zh-TW`?`已取消。`:`Cancelled.`),g=((t={},n={})=>(n.locale??e())===`zh-TW`?`選擇`:`Choices`),_=((t={},n={})=>(n.locale??e())===`zh-TW`?`瀏覽器拒絕存取剪貼簿。`:`The browser refused the clipboard.`),v=((t={},n={})=>(n.locale??e())===`zh-TW`?`已複製到這台裝置的剪貼簿。`:`Copied to this device's clipboard.`),y=((t={},n={})=>(n.locale??e())===`zh-TW`?`複製指令`:`Copy command`),ee=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個選項有預覽;請在終端機中查看。`:`It has a preview; see it in the terminal.`),b=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註`:`Note`),x=((t={},n={})=>(n.locale??e())===`zh-TW`?`備註(選填)`:`Note (optional)`),S=e=>`Opened while ${e?.tool} was running; it may not be about that call.`,C=e=>`在 ${e?.tool} 執行時開啟,不一定與該呼叫有關。`,te=((t,n={})=>(n.locale??e())===`zh-TW`?C(t):S(t)),w=((t={},n={})=>(n.locale??e())===`zh-TW`?`選項`:`Options`),T=((t={},n={})=>(n.locale??e())===`zh-TW`?`另一個答案沒有被採用;這個可以送出。`:`The other answer was not taken; this one can go.`),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`你的答案`:`Your own answer`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`或自己輸入答案`:`Or type your own answer`),O=((t={},n={})=>(n.locale??e())===`zh-TW`?`問題已變更,請重新閱讀。`:`The question changed; read it again.`),k=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 讀不懂這個答案。`:`The session could not read that answer.`),A=((t={},n={})=>(n.locale??e())===`zh-TW`?`這個答案不符合問題。`:`That answer does not fit the question.`),j=((t={},n={})=>(n.locale??e())===`zh-TW`?`session 拒絕了這個答案。`:`The session refused that answer.`),M=((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.`),N=((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.`),P=((t={},n={})=>(n.locale??e())===`zh-TW`?`送出答案`:`Send answer`),F=((t={},n={})=>(n.locale??e())===`zh-TW`?`顯示終端機`:`Show terminal`),I=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中關閉。`:`It was dismissed in the terminal.`),L=((t={},n={})=>(n.locale??e())===`zh-TW`?`它已不再開啟。`:`It is no longer open.`),R=((t={},n={})=>(n.locale??e())===`zh-TW`?`已在終端機中回答。`:`It was already answered in the terminal.`),z=((t={},n={})=>(n.locale??e())===`zh-TW`?`它在等待對話框。`:`It waits on a dialog.`),B={ArrowDown:1,ArrowRight:1,ArrowUp:-1,ArrowLeft:-1};function V(e,t,n,r,i){let{q:a}=n,o=r[a],s=B[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 H(e,t,n){let r=e=>Math.max(0,e.opts.findIndex(e=>e.getAttribute(`aria-checked`)===`true`)),i=(e,t)=>e.opts.forEach((e,n)=>e.setAttribute(`tabindex`,n===t?`0`:`-1`)),a=e=>{for(let[n,r]of t.entries()){let t=r.opts.indexOf(e);if(t>=0)return{q:n,part:`opt`,o:t};if(e===r.own||e===r.note)return{q:n,part:e===r.own?`own`:`note`}}};t.forEach(e=>i(e,r(e)));let o=e=>{let n=a(e.target);n?.part===`opt`&&i(t[n.q],n.o)};e.addEventListener(`focusin`,o),e.addEventListener(`click`,o);let s=!1;return e.addEventListener(`keydown`,i=>{let o=a(i.target);if(!o||i.ctrlKey||i.altKey||i.metaKey||i.isComposing)return;let c=i.target;if(o.part!==`opt`&&(i.key===`ArrowUp`?c.selectionStart!==0:i.key===`ArrowDown`&&c.selectionEnd!==c.value.length))return;let l=V(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(!l||(i.preventDefault(),i.repeat&&[`Enter`,` `].includes(i.key)))return;if(s=i.key===` `,l.pick!==void 0){let e=t[o.q].opts[l.pick];e.getAttribute(`aria-checked`)!==`true`&&e.click()}let u=l.to===`send`?void 0:t[l.to.q],d=l.to===`send`?n():l.to.part===`opt`?u.opts[l.to.o??r(u)]:l.to.part===`own`?u.own:u.note;d&&!d.disabled&&(e.dispatchEvent(new CustomEvent(`ask-reveal`,{detail:d})),d.focus())}),e.addEventListener(`keyup`,e=>s&&e.key===` `&&(s=!1,e.preventDefault())),()=>t[0]?.opts[r(t[0])]}var U=e=>e.multiple?m():e.freeform&&e.options.length?p():``,W=90,G=(e,t)=>s(`div`,{class:`ask-one`},e.header&&s(`b`,{class:`ask-head`},e.header),s(`p`,{class:`ask-q`,...e.question.length>W?{"data-long":``}:{}},e.question),e.context&&s(`div`,{class:`ask-ctx`},e.context),e.options.length>0&&s(`ol`,{class:`ask-opts`,"aria-label":w()},...e.options.map(e=>s(`li`,{class:`ask-opt`},s(`b`,null,e.title),e.description&&s(`small`,null,e.description)))),t&&U(e)&&s(`small`,{class:`ask-how`},U(e))),K=e=>e.replace(/[\u0000-\u0008\u000b-\u001f\u007f-\u009f\p{Cf}]/gu,`�`),q=e=>(e.select?.choices??[]).map((e,t)=>({...e,i:t})),J=(e,t,n)=>({...e.size?{choices:[...e].sort((e,t)=>e-t)}:{},...t.trim()?{text:t}:{},...n.trim()?{note:n}:{}}),Y=(e,t,n)=>({dialog:e.dialog,digest:e.digest,answerId:n,...t}),X=(e,t)=>({dialog:e.dialog,digest:e.digest,answerId:t,cancel:!0}),Z=(e,t)=>e.cancel===!0&&!(t&&e.select?.choices.every(e=>e.hereOnly)),Q={digest:O,"not-allowed":A,malformed:k};function ne(e,i=!1){let{outcome:a,reason:o,by:s}=e.body;return a===`accepted`?[`ok`,i?h():n()]:a===`stale`?[`error`,s===`local`?R():s===`cancel`?I():L()]:a===`rejected`?[`error`,(Object.hasOwn(Q,String(o))?Q[String(o)]:j)()]:a===`busy`?[`error`,t()]:a===`unknown`||e.status===504?[`error`,r(),!0]:[`error`,o??l({status:e.status})]}var re=e=>[`accepted`,`stale`,`busy`,`unknown`].includes(String(e.body.outcome))||e.status===504,$=e=>e.answer?`d\n${e.answer.dialog}\n${e.answer.digest}`:`c\n${e.callId}\n${e.why??``}`;function ie(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=f()};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)}function ae(e,t,n=location.hostname!==`127.0.0.1`,l,f,p=F){let m,h,S,C=!1,O=!1,k;for(let e of[`focusin`,`pointerdown`])document.addEventListener(e,e=>h&&!h.el.contains(e.target)&&(h.lost=void 0));let A=(e,t,n,...r)=>(e.dataset.tone=t,e.replaceChildren(n,...r)),j=()=>{if(!h)return;let e=document.activeElement;e&&e!==document.body&&e!==h.lost&&(h.lost=void 0),h.controls.forEach(e=>e.disabled=!C||O||h.done),h.send&&(h.send.disabled=!C||O||h.done||!h.pick()),e&&h.el.contains(e)&&e.disabled&&(h.lost=e);let t=h.lost;t&&!t.disabled&&h.el.contains(t)&&(!document.activeElement||document.activeElement===document.body)&&(t.focus(),h.lost=void 0)};async function I(e,n){[e.sending,O,e.spell]=[!0,!0,!1],j(),A(e.note,``,a());let o=await t(`answer`,n).catch(()=>void 0),u=s(`button`,{type:`button`,class:`cmp-link`},i());u.onclick=()=>void I(e,n);let[d,p,m]=o?ne(o,n.cancel===!0):[`error`,r(),!0];[e.done,e.sending,O,e.busy]=[!o||re(o),!1,!1,o?.body.outcome===`busy`],A(e.note,d,p,...m?[u]:[]);let h=o?.body.outcome===`accepted`?o.body.then:void 0,g=h&&c(h,{key:l?.key??``,command:e.copy,answerId:String(n.answerId??``)});g&&A(e.note,d,`${p} ${g}`),j(),e.note.scrollIntoView?.({block:`nearest`}),f&&o?.body.outcome===`accepted`&&setTimeout(()=>f(!!h&&!g),h&&!g?0:1200)}let L=(e,t,n,r,i)=>{let a=s(`button`,{type:`button`,class:`ask-opt`,role:e,"aria-checked":`false`},s(`b`,i?{"data-n":String(i)}:null,t),...n.filter(Boolean).map(e=>s(`small`,null,e)));return a.onclick=r,a};function R(e,t){let r,i=q(t).map(e=>L(`radio`,K(e.label),[e.note&&K(e.note)],()=>(r=e.i,i.forEach((n,r)=>n.setAttribute(`aria-checked`,String(q(t)[r].i===e.i))),j()),e.i+1)),a=t.select?.copy!==void 0&&s(`button`,{type:`button`,class:`cmp-link`},y());a&&(a.disabled=!navigator.clipboard,a.onclick=()=>void navigator.clipboard.writeText(t.select.copy).then(()=>A(e.note,`ok`,v()),()=>A(e.note,`error`,_())));let o=i.filter((e,r)=>!(n&&q(t)[r].hereOnly));return i.forEach(e=>!o.includes(e)&&(e.disabled=!0)),e.pick=()=>r===void 0?void 0:{choice:r},e.first=H(e.el,[{opts:i,multiple:!1,answered:()=>r!==void 0}],()=>e.send),e.controls=o,[s(`pre`,{class:`ask-title`},K(t.select.title)),s(`div`,{class:`ask-opts`,role:`radiogroup`,"aria-label":g()},...i),s(`div`,{class:`ask-acts`},e.send,e.cancel,a)]}function B(e,t){let n=t.questions.map(()=>({picks:new Set,text:s(`textarea`,{rows:`1`,maxlength:`8192`,class:`ask-own`,placeholder:D(),"aria-label":E()}),note:s(`input`,{type:`text`,maxlength:`2048`,class:`ask-own ask-memo`,placeholder:x(),"aria-label":b()})})),r=[],i=t.questions.map((t,i)=>{let a=n[i],o=t.multiple?`checkbox`:`radio`,c=t.options.map((e,n)=>L(o,e.title,[e.description,e.preview&&ee()],()=>{t.multiple||(a.picks.clear(),a.text.value=``),a.picks.has(n)?a.picks.delete(n):a.picks.add(n),c.forEach((e,t)=>e.setAttribute(`aria-checked`,String(a.picks.has(t)))),j()}));return a.text.oninput=()=>(t.multiple||(a.picks.clear(),c.forEach(e=>e.setAttribute(`aria-checked`,`false`))),j()),e.controls.push(...c,a.text,a.note),r.push({opts:c,multiple:!!t.multiple,own:a.text,note:a.note,answered:()=>a.picks.size>0||a.text.value.trim()!==``}),s(`div`,{class:`ask-one`},t.header&&s(`b`,{class:`ask-head`},t.header),s(`p`,{class:`ask-q`,...t.question.length>W?{"data-long":``}:{}},t.question),s(`div`,{class:`ask-opts`,role:t.multiple?`group`:`radiogroup`,"aria-label":w()},...c),a.text,a.note)});return e.pick=()=>n.every(e=>e.picks.size||e.text.value.trim())?{answers:n.map(e=>J(e.picks,e.text.value,e.note.value))}:void 0,e.first=H(e.el,r,()=>e.send),[...i,s(`div`,{class:`ask-acts`},e.send,e.cancel)]}function V(e){let t=e.asks??(e.ask?[e.ask]:[]),r=t.length>1,i=e.answer,a={copy:i?.select?.copy,key:$(e),el:s(`section`,{class:`ask`}),note:s(`p`,{class:`ask-note`,role:`status`,"aria-live":`polite`}),controls:[],pick:()=>void 0,done:!1,sending:!1};i&&((a.send=s(`button`,{type:`button`,class:`ask-send`},P())).onclick=()=>void(a.pick()&&I(a,Y(i,a.pick(),crypto.randomUUID()))));let c=e.tool===`secret_drop`;i&&!c&&Z(i,n)&&((a.cancel=s(`button`,{type:`button`,class:`ask-cancel`},o())).onclick=()=>void I(a,X(i,crypto.randomUUID())));let f=s(`p`,{class:`ask-term`},e.why&&t.length?e.why:`${r?d():u()} ${r||!t[0]?``:U(t[0])}`.trim()),m=l&&e.tool!==`secret_drop`&&s(`button`,{type:`button`,class:`cmp-link`},p());m&&(m.onclick=l.show);let h=e.answer?.twin&&e.tool&&e.tool!==`dialog`?[s(`p`,{class:`ask-why`},te({tool:e.tool}))]:[];return a.el.append(...h,...i&&!c?i.select?R(a,i):B(a,i):[...t.length?t.map(e=>G(e,r)):[s(`p`,{class:`ask-why`},c?n?M():N():e.why??z())],s(`div`,{class:`ask-acts`},c?s(`p`,{class:`ask-term`},u()):f,m)],a.note),a.cancel&&a.controls.push(a.cancel),a}let Q=(t,n)=>{let r=document.activeElement;h&&h!==n&&(h.focus=h.el.contains(r)?r:void 0),[m,h,S]=[t,n,n?.send?n:S],e.replaceChildren(...n?[n.el]:[]),n&&ie(n.el),j(),n?.focus&&(!document.activeElement||document.activeElement===document.body)&&n.focus.focus()};return{enter(){let e=h&&!h.done?h.first?.():void 0;return!!(e&&!e.disabled&&(e.focus(),1))},cancel(){let e=h&&!h.done?h.cancel:void 0;return!!(e&&!e.disabled&&(e.click(),1))},sending:()=>O,update(e,t){C=t,e&&(k=void clearTimeout(k)),!e&&(h?.done||h?.sending)?k??=setTimeout(()=>(k=void 0,Q()),6e3):e?h&&($(e)===h.key||!e.answer&&(h.done||h.sending)&&e.callId===m?.callId)?((h.busy||h.sending)&&!e.answer?h.spell=!0:h.busy&&h.spell&&e.answer&&([h.done,h.busy]=[!1,!1],A(h.note,``,T())),m=e):Q(e,S?.key===$(e)&&!S.done?S:V(e)):Q(),j()}}}export{ae as t};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-BeKhdUMk.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{t as e}from"./runtime-ZX6HkxDa.js";import{n as t,t as n}from"./markdown-DvbY97ID.js";import{c as r,l as i,o as a,s as o}from"./answer-BDLr0WWa.js";import{Gt as s,M as c,O as l,Ut as u,h as d,o as f,y as p}from"./index-BteLBGsW.js";var ee=((t={},n={})=>(n.locale??e())===`zh-TW`?`可能已被當機的 run 處理過:動手前先確認。`:`A run that crashed may already have handled this: check before acting.`),te=((t={},n={})=>(n.locale??e())===`zh-TW`?`分支摘要`:`branch summary`),ne=((t={},n={})=>(n.locale??e())===`zh-TW`?`通訊紀錄`:`Comms log`),m=e=>`context compacted · ${e?.tokens} tokens summarized`,h=e=>`上下文已壓縮 · 摘要了 ${e?.tokens} tokens`,re=((t,n={})=>(n.locale??e())===`zh-TW`?h(t):m(t)),ie=((t={},n={})=>(n.locale??e())===`zh-TW`?`…(於 1 MB 截斷)`:`… (cut at 1 MB)`),g=e=>`exit ${e?.code}`,_=e=>`結束碼 ${e?.code}`,ae=((t,n={})=>(n.locale??e())===`zh-TW`?_(t):g(t)),v=e=>`Image ${e?.n}`,y=e=>`圖片 ${e?.n}`,oe=((t,n={})=>(n.locale??e())===`zh-TW`?y(t):v(t)),se=((t={},n={})=>(n.locale??e())===`zh-TW`?`圖片無法讀取`:`Image unavailable`),b=e=>`${e?.count} image(s)`,x=e=>`${e?.count} 張圖片`,ce=((t,n={})=>(n.locale??e())===`zh-TW`?x(t):b(t)),le=((t={},n={})=>(n.locale??e())===`zh-TW`?`收到`:`incoming`),S=((t={},n={})=>(n.locale??e())===`zh-TW`?`跳到最新`:`jump to latest`),C=e=>`${e?.count} new`,w=e=>`${e?.count} 則新訊息`,T=((t,n={})=>(n.locale??e())===`zh-TW`?w(t):C(t)),ue=((t={},n={})=>(n.locale??e())===`zh-TW`?`還沒有通訊。`:`No transmissions yet.`),de=((t={},n={})=>(n.locale??e())===`zh-TW`?`通知`:`notice`),fe=((t={},n={})=>(n.locale??e())===`zh-TW`?`細節`:`details`),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`表單回覆`:`form answers`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`訊息,來自`:`message from`),O=e=>`answer from ${e?.from}`,k=e=>`${e?.from} 的回答`,pe=((t,n={})=>(n.locale??e())===`zh-TW`?k(t):O(t)),A=e=>`request from ${e?.from}`,j=e=>`${e?.from} 的請求`,me=((t,n={})=>(n.locale??e())===`zh-TW`?j(t):A(t)),M=e=>`message from ${e?.from}`,N=e=>`${e?.from} 的訊息`,he=((t,n={})=>(n.locale??e())===`zh-TW`?N(t):M(t)),P=e=>`reply to your ask from ${e?.from}`,F=e=>`${e?.from} 回覆了你的詢問`,ge=((t,n={})=>(n.locale??e())===`zh-TW`?F(t):P(t)),I=((t={},n={})=>(n.locale??e())===`zh-TW`?`記憶`:`memory`),L=((t={},n={})=>(n.locale??e())===`zh-TW`?`監看`:`monitor`),_e=((t={},n={})=>(n.locale??e())===`zh-TW`?`本機`:`this computer`),ve=((t={},n={})=>(n.locale??e())===`zh-TW`?`隊友`:`teammate`),R=((t={},n={})=>(n.locale??e())===`zh-TW`?`提問,來自`:`question from`),ye=((t={},n={})=>(n.locale??e())===`zh-TW`?`回報,來自`:`report from`),be=((t={},n={})=>(n.locale??e())===`zh-TW`?`sb server 的通知`:`notice from the sb server`),z=((t={},n={})=>(n.locale??e())===`zh-TW`?`狀態:`:`status of`),B=((t={},n={})=>(n.locale??e())===`zh-TW`?`Straw Link 訊息`:`Straw Link message`),xe=((t={},n={})=>(n.locale??e())===`zh-TW`?`喚醒鬧鐘`:`wake-up call`),V=((t={},n={})=>(n.locale??e())===`zh-TW`?`塔台事件`:`tower event`),Se=((t={},n={})=>(n.locale??e())===`zh-TW`?`在旁開啟`:`open beside`),Ce=e=>`Open image ${e?.n}`,H=e=>`打開圖片 ${e?.n}`,we=((t,n={})=>(n.locale??e())===`zh-TW`?H(t):Ce(t)),U=e=>`show all (${e?.size})`,W=e=>`顯示全部(${e?.size})`,Te=((t,n={})=>(n.locale??e())===`zh-TW`?W(t):U(t)),Ee=((t={},n={})=>(n.locale??e())===`zh-TW`?`顯示全部參數`:`show all arguments`),G=e=>`◇ thought · ${e?.count} chars`,De=e=>`◇ 思考 · ${e?.count} 字元`,Oe=((t,n={})=>(n.locale??e())===`zh-TW`?De(t):G(t)),ke=((t={},n={})=>(n.locale??e())===`zh-TW`?`◇ 思考 · 已遮蔽`:`◇ thought · redacted`),Ae=((t={},n={})=>(n.locale??e())===`zh-TW`?`這座塔台正在待命。有訊息進來時,sb server 會喚醒它跑一個 run;你在這裡送出的第一則訊息就會啟動它。`:`This tower stands by. The sb server wakes it for a run when a message arrives; your first message here starts that run.`),je=((t={},n={})=>(n.locale??e())===`zh-TW`?`無法取得`:`unavailable`),Me=((t={},n={})=>(n.locale??e())===`zh-TW`?`你`:`you`);function Ne(){let e=!0,t=0;return{get pinned(){return e},scrolled(n){e=n,n&&(t=0)},hold:()=>void(e=!1),arrived(n){return e||(t+=n),e},jump:()=>void(e=!0,t=0),button:n=>e&&!n?void 0:t&&!n?T({count:t}):S()}}async function Pe(e,t,n,r){let i=()=>e.items.some(e=>e.id===n);for(;!i()&&e.before;)r(e.prepend(await t.older(e.before)));return i()?!0:(r(e.reset(await t.latest())),!1)}function Fe(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 Ie=e=>p(e.role),Le=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1}):``,Re=e=>e>=1024?`${(e/1024).toFixed(e>=10240?0:1)} KB`:`${e} B`,ze={intercom_message:D,subagent_result:ye,subagent_ping:R,subagent_status:z,"pi-loop-monitor":L,"memory-context":I,"doc-review":E,"straw-tower":V,"straw-link":B},K=e=>{let t=d(`<span class="ava"><svg><use/></svg></span>`);return t.querySelector(`use`).setAttribute(`href`,`#i-${f[e]??e}`),t};function Be(e){let t=[],n=0;for(let r of e.matchAll(/https?:\/\/[^\s<>)\]]+/g))t.push(e.slice(n,r.index),u(`a`,{href:r[0],rel:`noopener noreferrer`,target:`_blank`},r[0])),n=r.index+r[0].length;return[...t,e.slice(n)]}function q(e,d,{who:f,link:p,docFor:m}){let h=Fe(),g=new Map,_=new Set,v=()=>_.forEach(e=>e.button.isConnected?(e.shown=!0,e.button.hidden=!e.paths.some(e=>m?.(e))):e.shown&&_.delete(e)),y=u(`div`,{class:`chat-list`}),b=u(`div`,{class:`chat-top`}),x=u(`div`,{class:`chat-live`}),S=u(`div`,{class:`chat-end`}),C=u(`button`,{class:`chat-pill`,type:`button`,hidden:``}),w=u(`p`,{class:`chat-empty`},ue()),T=u(`div`,{class:`chat-scroll`,tabindex:`-1`,"aria-label":ne()},b,y,x,S);e.replaceChildren(T,C);let E=Ne(),O=!1,k=!1,A,j,M=0,N=!1,P,F=()=>N||P!==void 0,I=()=>(clearTimeout(P),P=setTimeout(()=>(P=void 0,E.pinned&&!h.detached&&R()),250)),L=(e=E.button(h.detached))=>(C.hidden=!e,C.textContent=e??``),R=()=>(E.jump(),j=void 0,T.scrollTop=T.scrollHeight,L());async function ye(e){O=!0;let t=await Pe(h,d,e,e=>(J(e),Z(e))).finally(()=>O=!1),n=g.get(e);if(A===e){if(!t||!n)return R();E.hold(),j=n,n.scrollIntoView({block:`center`}),s(n,`lit`),clearTimeout(M),M=window.setTimeout(()=>(j=void 0,n.classList.remove(`lit`)),2e3),L()}}let z=()=>A?void ye(A):R(),B=(e,t,n,r)=>{e.disabled=!0,d.entry(n).then(n=>{let i=n&&r(n);if(i===void 0)return void(e.textContent=je());t.textContent=i,e.remove()},()=>e.textContent=je())};function V(e,t=0){if(!t||!d.pic)return null;let n=Array.from({length:t},(t,n)=>d.pic(e,n));return u(`div`,{class:`pics`},...n.map((e,t)=>{let r=u(`img`,{src:e,alt:oe({n:t+1}),loading:`lazy`,decoding:`async`}),i=u(`button`,{type:`button`,class:`pic`,"aria-label":we({n:t+1})},r);return r.addEventListener(`error`,()=>i.replaceWith(u(`em`,{class:`pic-gone`},se()))),i.addEventListener(`click`,()=>void l(async()=>{let{lightbox:e}=await import(`./lightbox-CAi9HfcE.js`);return{lightbox:e}},__vite__mapDeps([0]),import.meta.url).then(({lightbox:e})=>e(n,t))),i}))}function Ce(e,t){let n=h.result(e.id),r=u(`pre`,{class:`out`},n?.text??``),i=u(`pre`,{class:`args`},e.args??``),a=e.cut?u(`button`,{class:`more`,type:`button`},Ee()):null;a?.addEventListener(`click`,()=>B(a,i,t,t=>(e=>e&&`${e.args??``}${e.cut?`\n${ie()}`:``}`)(t.tools?.find(t=>t.id===e.id))));let o=n?.more?u(`button`,{class:`more`,type:`button`},Te({size:Re(n.bytes??0)})):null;o?.addEventListener(`click`,()=>B(o,r,n.id,e=>e.text));let s=e.name===`show_doc`&&m?u(`button`,{class:`more open`,type:`button`,hidden:``},Se()):null;s?.addEventListener(`click`,t=>(t.preventDefault(),e.summary.split(`, `).forEach(e=>m?.(e)?.()))),s&&_.add({paths:e.summary.split(`, `),button:s}),s&&queueMicrotask(v);let c=u(`details`,{class:`act`},u(`summary`,{"data-mark":n?n.isError?`error`:`done`:`working`},u(`b`,{class:`badge`}),u(`code`,null,e.name),u(`span`,{class:`sum`},e.summary),s),i,a,n&&u(`div`,{class:`result`},n.images?u(`em`,null,ce({count:n.images})):null,r,o)),l=n&&V(n.id,n.images);return l?[c,l]:[c]}let H=e=>u(`time`,null,Le(e.at)),U=(e,t,n,r)=>u(`article`,{class:`tx you`},u(`header`,null,H(e),u(`b`,null,Me()),K(`user`)),u(`div`,{class:`bubble`,title:r},n?u(`small`,{class:`boss-flag`},ee()):null,...Be(t),V(e.id,e.images))),W=(e,t,n,r={})=>u(`article`,{class:`tx sys`},u(`details`,{class:`notice`},u(`summary`,null,K(`comms`),u(`em`,null,le()),...t,H(e)),r.crashed?u(`small`,{class:`boss-flag`},ee()):null,u(`pre`,null,n),r.raw?u(`details`,{class:`notice-raw`},u(`summary`,null,fe()),u(`pre`,{class:`raw`},r.raw)):null)),G=e=>{let t=i(e);return[D(),` `,t.name&&p(t.name)||t.name,t.id?` (${t.id})`:``,` · `,_e()]},De=e=>e.kind===`link`?[{ask:me,reply:ge,answer:pe,message:he}[e.what]({from:e.from}),` · `,ve()]:e.kind===`intercom`?G(e.from):[e.kind===`server`?be():xe()];function q(e){switch(e.kind){case`user`:{let t=f().service?r(e.text):void 0;if(t)return W(e,t.kind===`intercom`?G(t.from):[t.kind===`server`?be():xe()],e.text??``);let n=f().service?a(e.text):void 0;return U(e,n?n.body:e.text??``,n?.crashed,n?e.text??``:``)}case`assistant`:{let r=f(),i=u(`pre`,{class:`thought-text`}),a=e.thought?u(`button`,{class:`thought`,type:`button`},e.thought<0?ke():Oe({count:e.thought.toLocaleString()})):null;return e.thought&&e.thought>0&&a?.addEventListener(`click`,()=>B(a,i,e.id,e=>e.thoughtText)),u(`article`,{class:`tx in`},K(r.role),u(`div`,{class:`tx-body`},u(`header`,null,u(`b`,null,Ie(r)),e.model?u(`span`,null,e.model):null,H(e),e.stop?u(`span`,{class:`stop`,"data-mark":`error`},e.stop):null),a,i,e.text?u(`div`,{class:`md`},n(t(e.text))):null,e.error?u(`p`,{class:`fault`},e.error):null,...(e.tools??[]).flatMap(t=>Ce(t,e.id))))}case`bash`:return u(`article`,{class:`tx sys`},u(`details`,{class:`act`},u(`summary`,{"data-mark":e.exit?`error`:`done`},u(`b`,{class:`badge`}),u(`code`,null,`shell`),u(`span`,{class:`sum`},`! ${e.command}`),e.exit?u(`span`,{class:`stop`,"data-mark":`error`},ae({code:e.exit})):null),e.text?u(`pre`,{class:`out`},e.text):null));case`notice`:{let t=o(e);return t?.kind===`boss`&&f().service?U(e,t.body,t.crashed,e.text??``):t&&t.kind!==`boss`?W(e,De(t),t.body,t.kind===`link`?{raw:t.raw}:{crashed:t.crashed}):W(e,[ze[e.type??``]?.()??e.type??de(),` `,e.from&&p(e.from)||(e.from??``)],e.text??``)}case`divider`:return u(`article`,{class:`tx rule`},u(`details`,null,u(`summary`,null,e.type===`compaction`?re({tokens:(e.tokens??0).toLocaleString()}):te()),u(`pre`,null,e.text??``)));default:return u(`article`,{class:`tx note`},e.text??``,` `,H(e))}}function J(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,q(e)),g.get(e.id)));e.front?y.prepend(...t):y.append(...t),k&&!e.front&&!e.rebuild&&t.forEach(e=>(e.classList.add(`fresh`),e.dataset.born=String(Date.now()))),w.remove();let n=f().service;w.textContent=n?.state===`standing`&&!n.run?Ae():ue(),h.items.length||y.append(w),b.hidden=!h.before,Ve()}let Y=[],X=new Map;function Ve(){let e=new Set;for(let t of Y){let n=Date.parse(t.startedAt),r=h.items.findIndex(e=>e.at!==void 0&&Date.parse(e.at)>=n);if(r===0&&h.before)continue;let i=r<0?``:h.items[r].id,a=JSON.stringify([i,c(t)]),o=X.get(t.id);if(e.add(t.id),o&&o.sig===a&&o.el.isConnected)continue;o?.el.remove();let s=c(t),l=u(`article`,{class:`tx rule conv-rule`},u(`div`,null,u(`b`,null,s.title),s.ended?u(`small`,null,s.ended):null));X.set(t.id,{el:l,sig:a});let d=i?g.get(i):void 0;d?d.before(l):y.append(l)}for(let[t,n]of X)e.has(t)||(n.el.remove(),X.delete(t))}let Z=e=>e.touched.forEach(e=>{let t=g.get(e),n=h.items.find(t=>t.id===e);if(t&&n){let r=q(n);t.classList.contains(`fresh`)&&Date.now()-Number(t.dataset.born??0)<400&&r.classList.add(`fresh`),t.replaceWith(r),g.set(e,r)}}),He=async()=>{if(!O&&h.before&&k){O=!0;try{let e=T.scrollHeight,t=h.prepend(await d.older(h.before));J(t),Z(t),T.scrollTop+=T.scrollHeight-e}finally{O=!1}h.before&&T.clientHeight&&b.getBoundingClientRect().bottom>=T.getBoundingClientRect().top&&He()}};C.addEventListener(`click`,()=>{A=void 0,h.detached?d.latest().then(e=>(J(h.reset(e)),R())):R()});let Q=[new IntersectionObserver(e=>e.some(e=>e.isIntersecting)&&void He(),{root:T}),new IntersectionObserver(e=>T.clientHeight&&(E.scrolled(e.at(-1).isIntersecting),L()),{root:T,rootMargin:`0px 0px 67px`})],$,Ue=()=>($??(Q[0].observe(b),Q[1].observe(S)),clearTimeout($),$=setTimeout(()=>($=void 0,Q.forEach(e=>e.disconnect())),600));T.addEventListener(`scroll`,()=>(Ue(),!N&&P!==void 0&&I()),{passive:!0}),T.addEventListener(`touchstart`,()=>(N=!0,clearTimeout(P),P=void 0),{passive:!0});for(let e of[`touchend`,`touchcancel`])T.addEventListener(e,()=>(N=!1,I()),{passive:!0});for(let e of[`wheel`,`touchstart`,`pointerdown`,`keydown`])T.addEventListener(e,()=>j=A=void 0,{passive:!0});let We=new ResizeObserver(()=>F()?void 0:E.pinned&&!h.detached?T.scrollTop=T.scrollHeight:j?.scrollIntoView({block:`center`}));return We.observe(y),We.observe(T),{log:T,docs:v,runs(e){JSON.stringify(e)!==JSON.stringify(Y)&&(Y=e,Ve())},apply(e){if(e.reset)J(h.reset({items:e.items??[],before:e.before})),k=!0,z();else if(e.items?.length){let t=h.append(e.items);J(t),Z(t),E.arrived(t.added.length)&&!h.detached&&!F()?R():L()}},reveal(e){A=e,k&&z()},setLive(e,t){x.dataset.mark=t,x.lastChild?.textContent!==e&&x.replaceChildren(...e?[u(`b`,{class:`badge`}),u(`span`,null,e)]:[])}}}export{q as mountChat,oe as t};
|
|
2
|
+
import{t as e}from"./runtime-ZX6HkxDa.js";import{n as t,t as n}from"./markdown-DvbY97ID.js";import{c as r,l as i,o as a,s as o}from"./answer-B2xVIGxA.js";import{Gt as s,M as c,O as l,Ut as u,h as d,o as f,y as p}from"./index-xkaqCr46.js";var ee=((t={},n={})=>(n.locale??e())===`zh-TW`?`可能已被當機的 run 處理過:動手前先確認。`:`A run that crashed may already have handled this: check before acting.`),te=((t={},n={})=>(n.locale??e())===`zh-TW`?`分支摘要`:`branch summary`),ne=((t={},n={})=>(n.locale??e())===`zh-TW`?`通訊紀錄`:`Comms log`),m=e=>`context compacted · ${e?.tokens} tokens summarized`,h=e=>`上下文已壓縮 · 摘要了 ${e?.tokens} tokens`,re=((t,n={})=>(n.locale??e())===`zh-TW`?h(t):m(t)),ie=((t={},n={})=>(n.locale??e())===`zh-TW`?`…(於 1 MB 截斷)`:`… (cut at 1 MB)`),g=e=>`exit ${e?.code}`,_=e=>`結束碼 ${e?.code}`,ae=((t,n={})=>(n.locale??e())===`zh-TW`?_(t):g(t)),v=e=>`Image ${e?.n}`,y=e=>`圖片 ${e?.n}`,oe=((t,n={})=>(n.locale??e())===`zh-TW`?y(t):v(t)),se=((t={},n={})=>(n.locale??e())===`zh-TW`?`圖片無法讀取`:`Image unavailable`),b=e=>`${e?.count} image(s)`,x=e=>`${e?.count} 張圖片`,ce=((t,n={})=>(n.locale??e())===`zh-TW`?x(t):b(t)),le=((t={},n={})=>(n.locale??e())===`zh-TW`?`收到`:`incoming`),S=((t={},n={})=>(n.locale??e())===`zh-TW`?`跳到最新`:`jump to latest`),C=e=>`${e?.count} new`,w=e=>`${e?.count} 則新訊息`,T=((t,n={})=>(n.locale??e())===`zh-TW`?w(t):C(t)),ue=((t={},n={})=>(n.locale??e())===`zh-TW`?`還沒有通訊。`:`No transmissions yet.`),de=((t={},n={})=>(n.locale??e())===`zh-TW`?`通知`:`notice`),fe=((t={},n={})=>(n.locale??e())===`zh-TW`?`細節`:`details`),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`表單回覆`:`form answers`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`訊息,來自`:`message from`),O=e=>`answer from ${e?.from}`,k=e=>`${e?.from} 的回答`,pe=((t,n={})=>(n.locale??e())===`zh-TW`?k(t):O(t)),A=e=>`request from ${e?.from}`,j=e=>`${e?.from} 的請求`,me=((t,n={})=>(n.locale??e())===`zh-TW`?j(t):A(t)),M=e=>`message from ${e?.from}`,N=e=>`${e?.from} 的訊息`,he=((t,n={})=>(n.locale??e())===`zh-TW`?N(t):M(t)),P=e=>`reply to your ask from ${e?.from}`,F=e=>`${e?.from} 回覆了你的詢問`,ge=((t,n={})=>(n.locale??e())===`zh-TW`?F(t):P(t)),I=((t={},n={})=>(n.locale??e())===`zh-TW`?`記憶`:`memory`),L=((t={},n={})=>(n.locale??e())===`zh-TW`?`監看`:`monitor`),_e=((t={},n={})=>(n.locale??e())===`zh-TW`?`本機`:`this computer`),ve=((t={},n={})=>(n.locale??e())===`zh-TW`?`隊友`:`teammate`),R=((t={},n={})=>(n.locale??e())===`zh-TW`?`提問,來自`:`question from`),ye=((t={},n={})=>(n.locale??e())===`zh-TW`?`回報,來自`:`report from`),be=((t={},n={})=>(n.locale??e())===`zh-TW`?`sb server 的通知`:`notice from the sb server`),z=((t={},n={})=>(n.locale??e())===`zh-TW`?`狀態:`:`status of`),B=((t={},n={})=>(n.locale??e())===`zh-TW`?`Straw Link 訊息`:`Straw Link message`),xe=((t={},n={})=>(n.locale??e())===`zh-TW`?`喚醒鬧鐘`:`wake-up call`),V=((t={},n={})=>(n.locale??e())===`zh-TW`?`塔台事件`:`tower event`),Se=((t={},n={})=>(n.locale??e())===`zh-TW`?`在旁開啟`:`open beside`),Ce=e=>`Open image ${e?.n}`,H=e=>`打開圖片 ${e?.n}`,we=((t,n={})=>(n.locale??e())===`zh-TW`?H(t):Ce(t)),U=e=>`show all (${e?.size})`,W=e=>`顯示全部(${e?.size})`,Te=((t,n={})=>(n.locale??e())===`zh-TW`?W(t):U(t)),Ee=((t={},n={})=>(n.locale??e())===`zh-TW`?`顯示全部參數`:`show all arguments`),G=e=>`◇ thought · ${e?.count} chars`,De=e=>`◇ 思考 · ${e?.count} 字元`,Oe=((t,n={})=>(n.locale??e())===`zh-TW`?De(t):G(t)),ke=((t={},n={})=>(n.locale??e())===`zh-TW`?`◇ 思考 · 已遮蔽`:`◇ thought · redacted`),Ae=((t={},n={})=>(n.locale??e())===`zh-TW`?`這座塔台正在待命。有訊息進來時,sb server 會喚醒它跑一個 run;你在這裡送出的第一則訊息就會啟動它。`:`This tower stands by. The sb server wakes it for a run when a message arrives; your first message here starts that run.`),je=((t={},n={})=>(n.locale??e())===`zh-TW`?`無法取得`:`unavailable`),Me=((t={},n={})=>(n.locale??e())===`zh-TW`?`你`:`you`);function Ne(){let e=!0,t=0;return{get pinned(){return e},scrolled(n){e=n,n&&(t=0)},hold:()=>void(e=!1),arrived(n){return e||(t+=n),e},jump:()=>void(e=!0,t=0),button:n=>e&&!n?void 0:t&&!n?T({count:t}):S()}}async function Pe(e,t,n,r){let i=()=>e.items.some(e=>e.id===n);for(;!i()&&e.before;)r(e.prepend(await t.older(e.before)));return i()?!0:(r(e.reset(await t.latest())),!1)}function Fe(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 Ie=e=>p(e.role),Le=e=>e?new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,hour12:!1}):``,Re=e=>e>=1024?`${(e/1024).toFixed(e>=10240?0:1)} KB`:`${e} B`,ze={intercom_message:D,subagent_result:ye,subagent_ping:R,subagent_status:z,"pi-loop-monitor":L,"memory-context":I,"doc-review":E,"straw-tower":V,"straw-link":B},K=e=>{let t=d(`<span class="ava"><svg><use/></svg></span>`);return t.querySelector(`use`).setAttribute(`href`,`#i-${f[e]??e}`),t};function Be(e){let t=[],n=0;for(let r of e.matchAll(/https?:\/\/[^\s<>)\]]+/g))t.push(e.slice(n,r.index),u(`a`,{href:r[0],rel:`noopener noreferrer`,target:`_blank`},r[0])),n=r.index+r[0].length;return[...t,e.slice(n)]}function q(e,d,{who:f,link:p,docFor:m}){let h=Fe(),g=new Map,_=new Set,v=()=>_.forEach(e=>e.button.isConnected?(e.shown=!0,e.button.hidden=!e.paths.some(e=>m?.(e))):e.shown&&_.delete(e)),y=u(`div`,{class:`chat-list`}),b=u(`div`,{class:`chat-top`}),x=u(`div`,{class:`chat-live`}),S=u(`div`,{class:`chat-end`}),C=u(`button`,{class:`chat-pill`,type:`button`,hidden:``}),w=u(`p`,{class:`chat-empty`},ue()),T=u(`div`,{class:`chat-scroll`,tabindex:`-1`,"aria-label":ne()},b,y,x,S);e.replaceChildren(T,C);let E=Ne(),O=!1,k=!1,A,j,M=0,N=!1,P,F=()=>N||P!==void 0,I=()=>(clearTimeout(P),P=setTimeout(()=>(P=void 0,E.pinned&&!h.detached&&R()),250)),L=(e=E.button(h.detached))=>(C.hidden=!e,C.textContent=e??``),R=()=>(E.jump(),j=void 0,T.scrollTop=T.scrollHeight,L());async function ye(e){O=!0;let t=await Pe(h,d,e,e=>(J(e),Z(e))).finally(()=>O=!1),n=g.get(e);if(A===e){if(!t||!n)return R();E.hold(),j=n,n.scrollIntoView({block:`center`}),s(n,`lit`),clearTimeout(M),M=window.setTimeout(()=>(j=void 0,n.classList.remove(`lit`)),2e3),L()}}let z=()=>A?void ye(A):R(),B=(e,t,n,r)=>{e.disabled=!0,d.entry(n).then(n=>{let i=n&&r(n);if(i===void 0)return void(e.textContent=je());t.textContent=i,e.remove()},()=>e.textContent=je())};function V(e,t=0){if(!t||!d.pic)return null;let n=Array.from({length:t},(t,n)=>d.pic(e,n));return u(`div`,{class:`pics`},...n.map((e,t)=>{let r=u(`img`,{src:e,alt:oe({n:t+1}),loading:`lazy`,decoding:`async`}),i=u(`button`,{type:`button`,class:`pic`,"aria-label":we({n:t+1})},r);return r.addEventListener(`error`,()=>i.replaceWith(u(`em`,{class:`pic-gone`},se()))),i.addEventListener(`click`,()=>void l(async()=>{let{lightbox:e}=await import(`./lightbox-B_LOCdRi.js`);return{lightbox:e}},__vite__mapDeps([0]),import.meta.url).then(({lightbox:e})=>e(n,t))),i}))}function Ce(e,t){let n=h.result(e.id),r=u(`pre`,{class:`out`},n?.text??``),i=u(`pre`,{class:`args`},e.args??``),a=e.cut?u(`button`,{class:`more`,type:`button`},Ee()):null;a?.addEventListener(`click`,()=>B(a,i,t,t=>(e=>e&&`${e.args??``}${e.cut?`\n${ie()}`:``}`)(t.tools?.find(t=>t.id===e.id))));let o=n?.more?u(`button`,{class:`more`,type:`button`},Te({size:Re(n.bytes??0)})):null;o?.addEventListener(`click`,()=>B(o,r,n.id,e=>e.text));let s=e.name===`show_doc`&&m?u(`button`,{class:`more open`,type:`button`,hidden:``},Se()):null;s?.addEventListener(`click`,t=>(t.preventDefault(),e.summary.split(`, `).forEach(e=>m?.(e)?.()))),s&&_.add({paths:e.summary.split(`, `),button:s}),s&&queueMicrotask(v);let c=u(`details`,{class:`act`},u(`summary`,{"data-mark":n?n.isError?`error`:`done`:`working`},u(`b`,{class:`badge`}),u(`code`,null,e.name),u(`span`,{class:`sum`},e.summary),s),i,a,n&&u(`div`,{class:`result`},n.images?u(`em`,null,ce({count:n.images})):null,r,o)),l=n&&V(n.id,n.images);return l?[c,l]:[c]}let H=e=>u(`time`,null,Le(e.at)),U=(e,t,n,r)=>u(`article`,{class:`tx you`},u(`header`,null,H(e),u(`b`,null,Me()),K(`user`)),u(`div`,{class:`bubble`,title:r},n?u(`small`,{class:`boss-flag`},ee()):null,...Be(t),V(e.id,e.images))),W=(e,t,n,r={})=>u(`article`,{class:`tx sys`},u(`details`,{class:`notice`},u(`summary`,null,K(`comms`),u(`em`,null,le()),...t,H(e)),r.crashed?u(`small`,{class:`boss-flag`},ee()):null,u(`pre`,null,n),r.raw?u(`details`,{class:`notice-raw`},u(`summary`,null,fe()),u(`pre`,{class:`raw`},r.raw)):null)),G=e=>{let t=i(e);return[D(),` `,t.name&&p(t.name)||t.name,t.id?` (${t.id})`:``,` · `,_e()]},De=e=>e.kind===`link`?[{ask:me,reply:ge,answer:pe,message:he}[e.what]({from:e.from}),` · `,ve()]:e.kind===`intercom`?G(e.from):[e.kind===`server`?be():xe()];function q(e){switch(e.kind){case`user`:{let t=f().service?r(e.text):void 0;if(t)return W(e,t.kind===`intercom`?G(t.from):[t.kind===`server`?be():xe()],e.text??``);let n=f().service?a(e.text):void 0;return U(e,n?n.body:e.text??``,n?.crashed,n?e.text??``:``)}case`assistant`:{let r=f(),i=u(`pre`,{class:`thought-text`}),a=e.thought?u(`button`,{class:`thought`,type:`button`},e.thought<0?ke():Oe({count:e.thought.toLocaleString()})):null;return e.thought&&e.thought>0&&a?.addEventListener(`click`,()=>B(a,i,e.id,e=>e.thoughtText)),u(`article`,{class:`tx in`},K(r.role),u(`div`,{class:`tx-body`},u(`header`,null,u(`b`,null,Ie(r)),e.model?u(`span`,null,e.model):null,H(e),e.stop?u(`span`,{class:`stop`,"data-mark":`error`},e.stop):null),a,i,e.text?u(`div`,{class:`md`},n(t(e.text))):null,e.error?u(`p`,{class:`fault`},e.error):null,...(e.tools??[]).flatMap(t=>Ce(t,e.id))))}case`bash`:return u(`article`,{class:`tx sys`},u(`details`,{class:`act`},u(`summary`,{"data-mark":e.exit?`error`:`done`},u(`b`,{class:`badge`}),u(`code`,null,`shell`),u(`span`,{class:`sum`},`! ${e.command}`),e.exit?u(`span`,{class:`stop`,"data-mark":`error`},ae({code:e.exit})):null),e.text?u(`pre`,{class:`out`},e.text):null));case`notice`:{let t=o(e);return t?.kind===`boss`&&f().service?U(e,t.body,t.crashed,e.text??``):t&&t.kind!==`boss`?W(e,De(t),t.body,t.kind===`link`?{raw:t.raw}:{crashed:t.crashed}):W(e,[ze[e.type??``]?.()??e.type??de(),` `,e.from&&p(e.from)||(e.from??``)],e.text??``)}case`divider`:return u(`article`,{class:`tx rule`},u(`details`,null,u(`summary`,null,e.type===`compaction`?re({tokens:(e.tokens??0).toLocaleString()}):te()),u(`pre`,null,e.text??``)));default:return u(`article`,{class:`tx note`},e.text??``,` `,H(e))}}function J(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,q(e)),g.get(e.id)));e.front?y.prepend(...t):y.append(...t),k&&!e.front&&!e.rebuild&&t.forEach(e=>(e.classList.add(`fresh`),e.dataset.born=String(Date.now()))),w.remove();let n=f().service;w.textContent=n?.state===`standing`&&!n.run?Ae():ue(),h.items.length||y.append(w),b.hidden=!h.before,Ve()}let Y=[],X=new Map;function Ve(){let e=new Set;for(let t of Y){let n=Date.parse(t.startedAt),r=h.items.findIndex(e=>e.at!==void 0&&Date.parse(e.at)>=n);if(r===0&&h.before)continue;let i=r<0?``:h.items[r].id,a=JSON.stringify([i,c(t)]),o=X.get(t.id);if(e.add(t.id),o&&o.sig===a&&o.el.isConnected)continue;o?.el.remove();let s=c(t),l=u(`article`,{class:`tx rule conv-rule`},u(`div`,null,u(`b`,null,s.title),s.ended?u(`small`,null,s.ended):null));X.set(t.id,{el:l,sig:a});let d=i?g.get(i):void 0;d?d.before(l):y.append(l)}for(let[t,n]of X)e.has(t)||(n.el.remove(),X.delete(t))}let Z=e=>e.touched.forEach(e=>{let t=g.get(e),n=h.items.find(t=>t.id===e);if(t&&n){let r=q(n);t.classList.contains(`fresh`)&&Date.now()-Number(t.dataset.born??0)<400&&r.classList.add(`fresh`),t.replaceWith(r),g.set(e,r)}}),He=async()=>{if(!O&&h.before&&k){O=!0;try{let e=T.scrollHeight,t=h.prepend(await d.older(h.before));J(t),Z(t),T.scrollTop+=T.scrollHeight-e}finally{O=!1}h.before&&T.clientHeight&&b.getBoundingClientRect().bottom>=T.getBoundingClientRect().top&&He()}};C.addEventListener(`click`,()=>{A=void 0,h.detached?d.latest().then(e=>(J(h.reset(e)),R())):R()});let Q=[new IntersectionObserver(e=>e.some(e=>e.isIntersecting)&&void He(),{root:T}),new IntersectionObserver(e=>T.clientHeight&&(E.scrolled(e.at(-1).isIntersecting),L()),{root:T,rootMargin:`0px 0px 67px`})],$,Ue=()=>($??(Q[0].observe(b),Q[1].observe(S)),clearTimeout($),$=setTimeout(()=>($=void 0,Q.forEach(e=>e.disconnect())),600));T.addEventListener(`scroll`,()=>(Ue(),!N&&P!==void 0&&I()),{passive:!0}),T.addEventListener(`touchstart`,()=>(N=!0,clearTimeout(P),P=void 0),{passive:!0});for(let e of[`touchend`,`touchcancel`])T.addEventListener(e,()=>(N=!1,I()),{passive:!0});for(let e of[`wheel`,`touchstart`,`pointerdown`,`keydown`])T.addEventListener(e,()=>j=A=void 0,{passive:!0});let We=new ResizeObserver(()=>F()?void 0:E.pinned&&!h.detached?T.scrollTop=T.scrollHeight:j?.scrollIntoView({block:`center`}));return We.observe(y),We.observe(T),{log:T,docs:v,runs(e){JSON.stringify(e)!==JSON.stringify(Y)&&(Y=e,Ve())},apply(e){if(e.reset)J(h.reset({items:e.items??[],before:e.before})),k=!0,z();else if(e.items?.length){let t=h.append(e.items);J(t),Z(t),E.arrived(t.added.length)&&!h.detached&&!F()?R():L()}},reveal(e){A=e,k&&z()},setLive(e,t){x.dataset.mark=t,x.lastChild?.textContent!==e&&x.replaceChildren(...e?[u(`b`,{class:`badge`}),u(`span`,null,e)]:[])}}}export{q as mountChat,oe as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./runtime-ZX6HkxDa.js";import{t}from"./open_main_title-Ccbha5pD.js";import{n,t as r}from"./unit_count-
|
|
1
|
+
import{t as e}from"./runtime-ZX6HkxDa.js";import{t}from"./open_main_title-Ccbha5pD.js";import{n,t as r}from"./unit_count-C_IKdFh4.js";import{D as i,E as a,S as o,T as s,Ut as c,b as l,c as u,h as d,l as f,p,st as m,u as h,v as g,x as _,y as v}from"./index-xkaqCr46.js";var y=((t={},n={})=>(n.locale??e())===`zh-TW`?`關閉清單`:`Close the list`),b=((t={},n={})=>(n.locale??e())===`zh-TW`?`切換到其他單位`:`Switch to a unit`),x=((t={},n={})=>(n.locale??e())===`zh-TW`?`回到主地圖`:`Back to the map`),S=((t={},n={})=>(n.locale??e())===`zh-TW`?`所有單位`:`All units`),C=((t={},n={})=>(n.locale??e())===`zh-TW`?`指揮中`:`commanding`),w=((t={},n={})=>(n.locale??e())===`zh-TW`?`已結束`:`ended`),T=((t={},n={})=>(n.locale??e())===`zh-TW`?`錯誤`:`error`),E=((t={},n={})=>(n.locale??e())===`zh-TW`?`閒置`:`idle`),D=((t={},n={})=>(n.locale??e())===`zh-TW`?`無狀態`:`unknown`),O=((t={},n={})=>(n.locale??e())===`zh-TW`?`等待`:`waiting`),k=((t={},n={})=>(n.locale??e())===`zh-TW`?`工作中`:`working`),A=.4;function j(e,t,n){let[r,i]=[Math.abs(e),Math.abs(t)];return Math.max(r,i)<10?`wait`:r>=1.7*i&&(n?e<0:e>0)?`drag`:`pass`}var M=(e,t,n)=>Math.abs(n)>=.45?n>0:e>=t*A,N=(e,t)=>t||e.some(e=>e.editable||e.sink||e.scrollsX||[`input`,`textarea`,`select`].includes(e.tag));function P(e){let t=e,n=getComputedStyle(e).overflowX;return{tag:e.tagName.toLowerCase(),editable:t.isContentEditable,sink:e.matches(`.composer, .term-sink`),scrollsX:(n===`auto`||n===`scroll`)&&e.scrollWidth>e.clientWidth+1}}var F=e=>{let t=[];for(let n=e;n;n=n.parentElement)t.push(P(n));return t},I={working:k,waiting:O,idle:E,done:w,error:T,unknown:D,commanding:C},L=(e,t,n)=>(t?w:I[e])({},n&&{locale:n}),R=(e,t)=>t.flatMap(t=>[t,...t.subs.map(e=>({...e,sub:!0}))].map(t=>({id:t.key,key:t.key,ws:e,name:t.name,role:t.role,mark:t.mark,note:t.note,ended:!!t.ended,sub:`sub`in t,control:!!t.control})));function z(e){return e.bases.flatMap(e=>{let t=[{id:`tower`,rows:e.tower?R(e.id,[{...e.tower,role:`tower`}]):[]},...e.tabs.map(t=>({id:t.id,label:m({label:t.label}),rows:R(e.id,t.units)})),{id:`outside`,label:n(),rows:R(e.id,e.outside)}].filter(e=>e.rows.length);return t.length?[{id:e.id,label:e.label,mark:e.mark,groups:t}]:[]})}var B=e=>e.role===`main`&&e.mark===`idle`,V=e=>e.reduce((e,t)=>(t.sub?e.at(-1)?.subs.push(t):e.push({...t,subs:[]}),e),[]),H=()=>d(`<div class="unit"><div class="card"><a class="hit"></a>${u}<div class="meta"><span class="name"></span><span class="line"><em class="role"></em><b class="dstate"></b><span class="note"></span></span></div><button type="button" class="quit-btn" data-close="unit" hidden></button></div><div class="subs"></div></div>`),U=()=>d(`<div class="unit tower-row"><div class="trow"><a class="tower-go">${u}<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>`),W=()=>d(`<section class="dbase"><h3><a></a><small></small></h3><div class="dgroups"></div></section>`),G=()=>d(`<div class="dgroup"><h4></h4><div class="drows"></div></div>`),K=()=>matchMedia(`(max-width: 640px)`).matches;function q(e=()=>!1){let n=c(`div`,{class:`drawer-body`}),u=c(`button`,{type:`button`,class:`x`,"aria-label":y()},`×`),d=c(`a`,{class:`drawer-map`},x()),m=c(`button`,{type:`button`,class:`pair-btn`,"data-close":`dismiss-all`,hidden:``}),C=c(`div`,{class:`drawer-sweep`,hidden:``},m);f(d,{view:`map`});let w=c(`aside`,{class:`drawer`,"aria-label":b()},c(`header`,null,c(`b`,null,S()),u),n,c(`footer`,{class:`drawer-foot`},C,d)),T=c(`div`,{class:`drawer-veil`});document.body.append(T,w);let E,D,O=!1,k=0,A=0,P,I=()=>{i(m,E??{bases:[]}),C.hidden=m.hidden;let e=(t,n)=>{f(t.querySelector(`.hit`),{view:`session`,ws:n.ws,key:n.key}),t.querySelector(`.hit`).setAttribute(`aria-label`,`${n.name}: ${L(n.mark,n.ended)}`),t.classList.toggle(`current`,n.key===D),t.toggleAttribute(`data-dismiss`,n.role===`subagent`&&n.ended),t.dataset.key=n.key,g(t,n.mark),p(t.querySelector(`.plate`),n.role,n.mark),o(t,`.name`,n.name),o(t,`.role`,v(n.role)),o(t,`.dstate`,L(n.mark,n.ended)),l(t,`.note`,n.note,n.mark,n.note?void 0:``);let r=t.querySelector(`:scope > .card > .quit-btn`);B(n)?s(r,n):r.hidden=!0,_(t.querySelector(`.subs`),n.subs??[],H,e)},a=(n,r)=>{let i=n.querySelector(`.tower-go`),a=n.querySelector(`.tower-add`),s=E?.bases.find(e=>e.id===r.ws);f(i,{view:`session`,ws:r.ws,key:r.key}),i.setAttribute(`aria-label`,`${r.name}: ${L(r.mark,r.ended)}`),n.classList.toggle(`current`,r.key===D),n.dataset.key=r.key,g(n,r.mark),p(i.querySelector(`.plate`),`tower`,r.mark),o(i,`.name`,r.name),o(i,`.role`,v(`tower`)),o(i,`.dstate`,L(r.mark,r.ended)),a.hidden=!s,s&&(h(a,s),a.setAttribute(`aria-label`,t({base:s.label}))),_(n.querySelector(`.subs`),r.subs,H,e)};_(n,z(E??{bases:[]}),W,(t,n)=>{g(t,n.mark),o(t,`h3 a`,n.label),f(t.querySelector(`h3 a`),{view:`workspace`,ws:n.id}),o(t,`small`,r({count:n.groups.reduce((e,t)=>e+t.rows.length,0)})),_(t.querySelector(`.dgroups`),n.groups,G,(t,n)=>{o(t,`h4`,n.label??``),t.querySelector(`h4`).toggleAttribute(`hidden`,!n.label),n.id===`tower`?_(t.querySelector(`.drows`),V(n.rows),U,a):_(t.querySelector(`.drows`),V(n.rows),H,e)})})},R=e=>{k=Math.max(0,Math.min(A,e)),w.style.setProperty(`--dx`,`${k}px`),T.style.opacity=String(A?k/A:0),T.style.pointerEvents=k>0?`auto`:`none`},q=e=>{O=e,w.classList.toggle(`on`,e),w.inert=!e,document.documentElement.classList.remove(`drawer-drag`),R(e?A:0)},J=()=>{A=w.offsetWidth,I(),w.classList.add(`on`),document.documentElement.classList.add(`drawer-drag`)};w.inert=!0,document.addEventListener(`touchstart`,t=>{let n=t.target,r=w.contains(n)||n===T;if(P=void 0,!K()||e()||t.touches.length!==1||document.querySelector(`dialog.sheet[open], dialog.lightbox[open], [popover]:popover-open`)||(O?!r:N(F(n),!!getSelection()?.toString())))return;let i=t.touches[0],a=O?n.closest(`.unit[data-dismiss] > .card`)??void 0:void 0;P={x0:i.clientX,y0:i.clientY,mode:`wait`,was:O,base:k,last:i.clientX,at:performance.now(),v:0,card:a}},{passive:!0}),document.addEventListener(`touchmove`,e=>{if(!P||P.mode===`pass`)return;let t=e.touches[0],n=t.clientX-P.x0,r=t.clientY-P.y0;if(P.mode===`wait`){let e=j(n,r,P.was);if(e===`wait`)return;if(e===`pass`&&P.card&&j(n,r,!1)===`drag`)P.mode=`card`,P.card.classList.add(`swiping`);else if(e===`pass`)return void(P.mode=`pass`);else P.mode=`drag`,J()}e.preventDefault();let i=performance.now();if(P.v=(t.clientX-P.last)/Math.max(1,i-P.at),[P.last,P.at]=[t.clientX,i],P.mode!==`card`)return R(P.base+n);let a=Math.max(0,n);P.card.style.setProperty(`--sx`,`${a}px`),P.card.style.setProperty(`--so`,String(1-a/P.card.offsetWidth))},{passive:!1});let Y=(e,t)=>{e.classList.remove(`swiping`),e.style.removeProperty(`--sx`),e.style.removeProperty(`--so`),t&&(e.classList.add(`gone`),a({key:e.parentElement.dataset.key}).then(t=>t||e.classList.remove(`gone`)))},X=e=>{let t=P;P=void 0,t?.mode===`drag`&&q(M(k,A,t.v)),t?.mode===`card`&&Y(t.card,e.type===`touchend`&&M(Math.max(0,t.last-t.x0),t.card.offsetWidth,t.v))};return document.addEventListener(`touchend`,X),document.addEventListener(`touchcancel`,X),T.addEventListener(`click`,()=>q(!1)),w.addEventListener(`click`,e=>e.target.closest(`a[data-route], button[data-open], .x`)&&q(!1)),document.addEventListener(`keydown`,e=>O&&e.key===`Escape`&&(e.preventDefault(),q(!1)),!0),document.addEventListener(`sb-drawer`,()=>(O||J(),q(!O))),{net(e){E=e,O&&I()},route(e){D=e.view===`session`?e.key:void 0,d.toggleAttribute(`aria-current`,e.view===`map`),O&&I()}}}export{q as mountDrawer};
|