cli-jaw 2.17.44 → 2.17.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/README.ja.md +5 -7
  2. package/README.ko.md +5 -7
  3. package/README.md +19 -7
  4. package/README.zh-CN.md +5 -7
  5. package/dist/bin/commands/dispatch.js +93 -18
  6. package/dist/bin/commands/dispatch.js.map +1 -1
  7. package/dist/bin/commands/doctor.js +0 -70
  8. package/dist/bin/commands/doctor.js.map +1 -1
  9. package/dist/bin/commands/provider.js +16 -28
  10. package/dist/bin/commands/provider.js.map +1 -1
  11. package/dist/bin/commands/slack.js +65 -2
  12. package/dist/bin/commands/slack.js.map +1 -1
  13. package/dist/bin/commands/tui/slash-command-runner.js +1 -1
  14. package/dist/bin/commands/tui/slash-command-runner.js.map +1 -1
  15. package/dist/bin/commands/tui/types.js +0 -4
  16. package/dist/bin/commands/tui/types.js.map +1 -1
  17. package/dist/scripts/fresh-install-smoke.js +1 -1
  18. package/dist/scripts/fresh-install-smoke.js.map +1 -1
  19. package/dist/server.js +5 -3
  20. package/dist/server.js.map +1 -1
  21. package/dist/src/agent/args.js +1 -176
  22. package/dist/src/agent/args.js.map +1 -1
  23. package/dist/src/agent/claude-runtime-pool.js +11 -7
  24. package/dist/src/agent/claude-runtime-pool.js.map +1 -1
  25. package/dist/src/agent/cli-helpers.js +1 -3
  26. package/dist/src/agent/cli-helpers.js.map +1 -1
  27. package/dist/src/agent/error-classifier.js +1 -1
  28. package/dist/src/agent/error-classifier.js.map +1 -1
  29. package/dist/src/agent/error-cooldown.js +1 -3
  30. package/dist/src/agent/error-cooldown.js.map +1 -1
  31. package/dist/src/agent/events/claude.js +4 -56
  32. package/dist/src/agent/events/claude.js.map +1 -1
  33. package/dist/src/agent/events/helpers.js +3 -5
  34. package/dist/src/agent/events/helpers.js.map +1 -1
  35. package/dist/src/agent/events/index.js +12 -18
  36. package/dist/src/agent/events/index.js.map +1 -1
  37. package/dist/src/agent/kiro-runtime.js +3 -16
  38. package/dist/src/agent/kiro-runtime.js.map +1 -1
  39. package/dist/src/agent/lifecycle-handler.js +17 -12
  40. package/dist/src/agent/lifecycle-handler.js.map +1 -1
  41. package/dist/src/agent/native-runtime-run.js +7 -2
  42. package/dist/src/agent/native-runtime-run.js.map +1 -1
  43. package/dist/src/agent/prompt-context.js +4 -5
  44. package/dist/src/agent/prompt-context.js.map +1 -1
  45. package/dist/src/agent/resume-classifier.js +0 -5
  46. package/dist/src/agent/resume-classifier.js.map +1 -1
  47. package/dist/src/agent/runtime/acp/cursor-session.js +21 -3
  48. package/dist/src/agent/runtime/acp/cursor-session.js.map +1 -1
  49. package/dist/src/agent/runtime-pool.js +127 -51
  50. package/dist/src/agent/runtime-pool.js.map +1 -1
  51. package/dist/src/agent/session-persistence.js +1 -6
  52. package/dist/src/agent/session-persistence.js.map +1 -1
  53. package/dist/src/agent/spawn/resume.js +3 -3
  54. package/dist/src/agent/spawn/resume.js.map +1 -1
  55. package/dist/src/agent/spawn.js +27 -96
  56. package/dist/src/agent/spawn.js.map +1 -1
  57. package/dist/src/cli/claude-models.js +1 -1
  58. package/dist/src/cli/claude-models.js.map +1 -1
  59. package/dist/src/cli/cli-status-worker.js +1 -8
  60. package/dist/src/cli/cli-status-worker.js.map +1 -1
  61. package/dist/src/cli/compact.js +2 -6
  62. package/dist/src/cli/compact.js.map +1 -1
  63. package/dist/src/cli/employee-handler.js +4 -0
  64. package/dist/src/cli/employee-handler.js.map +1 -1
  65. package/dist/src/cli/handlers-completions.js +1 -1
  66. package/dist/src/cli/handlers-completions.js.map +1 -1
  67. package/dist/src/cli/handlers-runtime.js +18 -8
  68. package/dist/src/cli/handlers-runtime.js.map +1 -1
  69. package/dist/src/cli/handlers.js +3 -31
  70. package/dist/src/cli/handlers.js.map +1 -1
  71. package/dist/src/cli/opencodex-models.js +0 -5
  72. package/dist/src/cli/opencodex-models.js.map +1 -1
  73. package/dist/src/cli/readiness.js +1 -20
  74. package/dist/src/cli/readiness.js.map +1 -1
  75. package/dist/src/cli/registry-live.js +1 -51
  76. package/dist/src/cli/registry-live.js.map +1 -1
  77. package/dist/src/cli/registry.js +0 -64
  78. package/dist/src/cli/registry.js.map +1 -1
  79. package/dist/src/core/chat-sessions.js +3 -2
  80. package/dist/src/core/chat-sessions.js.map +1 -1
  81. package/dist/src/core/cli-detection.js +2 -178
  82. package/dist/src/core/cli-detection.js.map +1 -1
  83. package/dist/src/core/compact.js +2 -4
  84. package/dist/src/core/compact.js.map +1 -1
  85. package/dist/src/core/config.js +5 -4
  86. package/dist/src/core/config.js.map +1 -1
  87. package/dist/src/core/runtime-settings.js +5 -20
  88. package/dist/src/core/runtime-settings.js.map +1 -1
  89. package/dist/src/core/session-ops.js +4 -6
  90. package/dist/src/core/session-ops.js.map +1 -1
  91. package/dist/src/core/windows-launch-spec.js +1 -1
  92. package/dist/src/http/full-access.js +42 -0
  93. package/dist/src/http/full-access.js.map +1 -0
  94. package/dist/src/manager/proxy.js +1 -0
  95. package/dist/src/manager/proxy.js.map +1 -1
  96. package/dist/src/messaging/send.js +30 -8
  97. package/dist/src/messaging/send.js.map +1 -1
  98. package/dist/src/orchestrator/dispatch-admission.js +424 -0
  99. package/dist/src/orchestrator/dispatch-admission.js.map +1 -0
  100. package/dist/src/orchestrator/distribute.js +63 -21
  101. package/dist/src/orchestrator/distribute.js.map +1 -1
  102. package/dist/src/orchestrator/gateway.js +6 -4
  103. package/dist/src/orchestrator/gateway.js.map +1 -1
  104. package/dist/src/orchestrator/worker-registry.js +8 -1
  105. package/dist/src/orchestrator/worker-registry.js.map +1 -1
  106. package/dist/src/prompt/builder.js +40 -16
  107. package/dist/src/prompt/builder.js.map +1 -1
  108. package/dist/src/prompt/templates/employee.md +4 -4
  109. package/dist/src/routes/messaging.js +34 -18
  110. package/dist/src/routes/messaging.js.map +1 -1
  111. package/dist/src/routes/orchestrate.js +139 -64
  112. package/dist/src/routes/orchestrate.js.map +1 -1
  113. package/dist/src/routes/settings.js +1 -30
  114. package/dist/src/routes/settings.js.map +1 -1
  115. package/dist/src/routes/slack-tools.js +6 -4
  116. package/dist/src/routes/slack-tools.js.map +1 -1
  117. package/dist/src/security/path-guards.js +15 -1
  118. package/dist/src/security/path-guards.js.map +1 -1
  119. package/dist/src/slack/search-quote.js +9 -5
  120. package/dist/src/slack/search-quote.js.map +1 -1
  121. package/dist/src/slack/send-handler.js +1 -25
  122. package/dist/src/slack/send-handler.js.map +1 -1
  123. package/dist/src/slack/slack-file.js +105 -53
  124. package/dist/src/slack/slack-file.js.map +1 -1
  125. package/dist/src/slack/tool-access.js +10 -2
  126. package/dist/src/slack/tool-access.js.map +1 -1
  127. package/dist/src/slack/tool-capabilities.js +16 -8
  128. package/dist/src/slack/tool-capabilities.js.map +1 -1
  129. package/dist/src/types/cli-engine.js +26 -3
  130. package/dist/src/types/cli-engine.js.map +1 -1
  131. package/dist/src/types/cli-events.js +1 -1
  132. package/dist/src/types/cli-events.js.map +1 -1
  133. package/dist/src/workflows/employee-boundary.js +9 -5
  134. package/dist/src/workflows/employee-boundary.js.map +1 -1
  135. package/dist/src/workflows/scope-sandbox.js +5 -2
  136. package/dist/src/workflows/scope-sandbox.js.map +1 -1
  137. package/package.json +2 -6
  138. package/public/dist/.vite/manifest.json +115 -115
  139. package/public/dist/assets/Agent-CKX93LQ8.js +1 -0
  140. package/public/dist/assets/Employees-BuFw6-fT.js +1 -0
  141. package/public/dist/assets/Heartbeat-BmkZshEU.js +1 -0
  142. package/public/dist/assets/Memory-DsK_yOCW.js +1 -0
  143. package/public/dist/assets/ModelProvider-L_hW6YWJ.js +1 -0
  144. package/public/dist/assets/agent-meta-CkRJlOmN.js +1 -0
  145. package/public/dist/assets/{app-9OQNfmqw.js → app-B_JTnXIY.js} +4 -4
  146. package/public/dist/assets/{bgtask-badge-BvxHqMGi.js → bgtask-badge-BLdI7Ara.js} +1 -1
  147. package/public/dist/assets/bgtask-badge-DOhTsE9l.js +1 -0
  148. package/public/dist/assets/cli-engine-NdU0lzs_.js +1 -0
  149. package/public/dist/assets/constants-DmRtjRj3.js +1 -0
  150. package/public/dist/assets/{employees-CkUqN4oh.js → employees-DGoVBWQd.js} +1 -1
  151. package/public/dist/assets/iframe-renderer-Dw5vTqFX.js +1 -0
  152. package/public/dist/assets/{iframe-renderer-C2gchtOj.js → iframe-renderer-mBjdW5ZV.js} +2 -2
  153. package/public/dist/assets/{manager-rb5X-4DJ.js → manager-iX7KosWI.js} +1 -1
  154. package/public/dist/assets/memory-DuHc2no-.js +1 -0
  155. package/public/dist/assets/{memory-BiWzpoBq.js → memory-Hq9y-GQB.js} +1 -1
  156. package/public/dist/assets/message-history-DT0VaJRd.js +1 -0
  157. package/public/dist/assets/{message-history-CuFefS02.js → message-history-H7G4apTo.js} +1 -1
  158. package/public/dist/assets/{provider-icons-Det0fC-4.js → provider-icons-Bge6teOj.js} +1 -1
  159. package/public/dist/assets/{render-DUGqq9Mu.js → render-OT0puqo3.js} +1 -1
  160. package/public/dist/assets/settings-BW8q_Rnq.js +1 -0
  161. package/public/dist/assets/{settings-DQ1fLygB.js → settings-DjCtFSpd.js} +3 -3
  162. package/public/dist/assets/{settings-BqUHavbH.js → settings-KIPNUOIV.js} +1 -1
  163. package/public/dist/assets/settings-core-CVO3_bn9.js +1 -0
  164. package/public/dist/assets/settings-core-DiStY7KC.js +2 -0
  165. package/public/dist/assets/{settings-embedding-BAKFrVLV.js → settings-embedding-DIqST-91.js} +1 -1
  166. package/public/dist/assets/{sidebar-CvGbp9x5.js → sidebar-DiS6dGEP.js} +3 -3
  167. package/public/dist/assets/{skills-abLMqY5_.js → skills-D_mbeyb3.js} +1 -1
  168. package/public/dist/assets/skills-NzM-geDj.js +1 -0
  169. package/public/dist/assets/slash-commands-DUk5bLQ1.js +1 -0
  170. package/public/dist/assets/{slash-commands-D8o9pqOS.js → slash-commands-PWDX9hXL.js} +1 -1
  171. package/public/dist/assets/{trace-drawer-C6RvkUAd.js → trace-drawer-DSn3xg8f.js} +1 -1
  172. package/public/dist/assets/{ui-Bxapl_Eu.js → ui-Dzebjyzl.js} +1 -1
  173. package/public/dist/assets/ui-TcZtZTFR.js +1 -0
  174. package/public/dist/index.html +1 -3
  175. package/public/dist/manager/index.html +1 -1
  176. package/public/dist/settings/index.html +1 -1
  177. package/public/index.html +0 -2
  178. package/public/js/constants.ts +1 -46
  179. package/public/js/features/employees.ts +1 -1
  180. package/public/js/features/retired-runtime-option.ts +2 -2
  181. package/public/js/features/settings-channel.ts +4 -2
  182. package/public/js/features/settings-cli-status-render.ts +2 -2
  183. package/public/js/features/settings-cli-status.ts +0 -2
  184. package/public/js/provider-icons.ts +1 -3
  185. package/public/manager/src/settings/pages/Heartbeat.tsx +2 -2
  186. package/public/manager/src/settings/pages/Memory.tsx +2 -2
  187. package/public/manager/src/settings/pages/ModelProvider.tsx +7 -4
  188. package/public/manager/src/settings/pages/components/agent/FlushAgentSection.tsx +2 -2
  189. package/public/manager/src/settings/pages/components/agent/RuntimeEmployeeRow.tsx +2 -2
  190. package/public/manager/src/settings/pages/components/agent/RuntimeHeader.tsx +2 -2
  191. package/public/manager/src/settings/pages/components/agent/agent-meta.ts +4 -35
  192. package/public/manager/src/settings/pages/components/employees-helpers.ts +0 -2
  193. package/public/manager/src/settings/pages/components/heartbeat-helpers.ts +0 -2
  194. package/scripts/bundle-sidecar.sh +0 -24
  195. package/scripts/check-electron-sidecar-no-jwc.cjs +12 -4
  196. package/scripts/fresh-install-smoke.ts +1 -1
  197. package/scripts/install.sh +0 -5
  198. package/scripts/retired-runtime-package-smoke.mjs +2 -12
  199. package/scripts/verify-fresh-install.sh +0 -14
  200. package/dist/src/agent/claude-e-runtime.js +0 -44
  201. package/dist/src/agent/claude-e-runtime.js.map +0 -1
  202. package/public/dist/assets/Agent-CNad_A6t.js +0 -1
  203. package/public/dist/assets/Employees-B6uviPeN.js +0 -1
  204. package/public/dist/assets/Heartbeat-C3S3d8xW.js +0 -1
  205. package/public/dist/assets/Memory-BgeIbQSr.js +0 -1
  206. package/public/dist/assets/ModelProvider-AnxBVYws.js +0 -1
  207. package/public/dist/assets/agent-meta-BWHASq1a.js +0 -1
  208. package/public/dist/assets/bgtask-badge-DeSZJGNN.js +0 -1
  209. package/public/dist/assets/cli-engine-Bw0QTAVX.js +0 -1
  210. package/public/dist/assets/constants-D8XAqfHk.js +0 -1
  211. package/public/dist/assets/iframe-renderer-DfvACXIn.js +0 -1
  212. package/public/dist/assets/memory-Ckp1Eq5a.js +0 -1
  213. package/public/dist/assets/message-history-Bv0l_t7O.js +0 -1
  214. package/public/dist/assets/settings-C81Kf9uX.js +0 -1
  215. package/public/dist/assets/settings-core-CzdXfoOK.js +0 -2
  216. package/public/dist/assets/settings-core-DO_5M7Lv.js +0 -1
  217. package/public/dist/assets/skills-DFpPmMUR.js +0 -1
  218. package/public/dist/assets/slash-commands-BU58xYih.js +0 -1
  219. package/public/dist/assets/ui-CUB4iwz3.js +0 -1
@@ -1,5 +1,5 @@
1
1
  const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-render-DSSkXCir.css","assets/TerminalPanel-CdfhZ2mu.css","assets/DiffPanel-C_OzH7Q2.css","assets/FolderPanel-BHEYcjea.css","assets/DocPanel-DZKPTOm8.css","assets/BrowserPanel-D7SnTts8.css","assets/DesignPanel-3XpGjuEW.css"])))=>i.map(i=>d[i]);
2
- import{r as e}from"./rolldown-runtime-hePW80VL.js";import"./vendor-render-Cmfl_oW8.js";import{t}from"./preload-helper-CfbQpVni.js";import{a as n,i as r,n as i,r as a,t as o}from"./esm-Q6VOkDbn.js";import{n as s,t as c}from"./settings-embedding-BAKFrVLV.js";import{t as l}from"./react-C_pPTFsM.js";import{t as u}from"./react-dom-DyUOYpVL.js";import{C as d,D as f,E as p,O as m,S as h,T as g,_,a as v,b as y,c as b,d as x,f as S,g as C,h as w,i as T,k as E,l as D,m as O,n as k,o as ee,p as A,r as j,s as te,t as ne,u as re,v as ie,w as ae,x as oe,y as se}from"./api-B9RiiOMM.js";import{t as ce}from"./jsx-runtime-NZYk81nU.js";import{n as le,t as M}from"./desktop-bridge-DbRfkg8l.js";import{n as ue}from"./terminal-shortcut-queue-B_AyW1hN.js";import{a as de,c as fe,i as pe,l as N,n as P,o as me,r as he,s as ge,t as _e,u as F}from"./PanelLayoutProvider-mn8sI0h-.js";import{a as ve,i as ye,o as be,r as xe,t as Se}from"./manager-shortcuts-jsiX-zV6.js";import{t as Ce}from"./copy-text-WsUHYigB.js";import{i as I,r as L}from"./folder-drag-payload-BhV9yzhH.js";import{$ as R,At as we,Ct as Te,D as Ee,Et as z,It as De,L as B,N as Oe,Ot as ke,Q as V,St as H,Y as U,Z as Ae,_t as W,a as G,at as K,c as je,ct as Me,dt as Ne,et as Pe,ft as Fe,ht as q,it as Ie,jt as Le,k as Re,lt as ze,nt as Be,o as Ve,ot as He,p as Ue,q as J,st as We,t as Ge,u as Ke,vt as qe,wt as Je,x as Ye,y as Xe}from"./dist-D011G-p-.js";import{d as Ze,f as Qe,g as $e,i as et,r as tt,u as nt}from"./dist-CcmA2WLJ.js";import{c as rt,i as it,l as at,n as ot,o as st,r as ct}from"./dist-DBpt7gM8.js";import{a as lt}from"./dist-DBX5LjYY.js";import{t as ut}from"./MarkdownRenderer-DhonsAPC.js";import{a as dt,i as ft,n as pt,r as mt,t as ht}from"./wiki-link-suggestions-BcEfThgf.js";import{i as gt,t as _t}from"./notes-graph-settings-BUoTzvqs.js";var Y=e(l(),1),vt=s();async function yt(e){let t=Math.max(1,e.maxAttempts??16),n=Math.max(50,e.intervalMs??500),r=null;for(let i=1;i<=t;i+=1){if(e.signal?.aborted)return{settled:!1,attempts:i-1,instance:r};let a=new AbortController,o=()=>a.abort();e.signal?.addEventListener(`abort`,o,{once:!0});try{r=await e.fetchOnce(e.port,a.signal)}catch{r=null}finally{e.signal?.removeEventListener(`abort`,o)}if(e.onAttempt?.(r,i),bt(r,e))return{settled:!0,attempts:i,instance:r};if(i===t)break;await xt(n,e.signal)}return{settled:!1,attempts:t,instance:r}}function bt(e,t){return t.expected===`online`?e?.status===`online`:t.expected===`offline`?!e||e.status!==`online`:t.expected===`restart-detected`?!e||e.status!==`online`||typeof e.uptime!=`number`?!1:typeof t.previousUptime!=`number`||e.uptime<t.previousUptime:!1}function xt(e,t){return new Promise(n=>{let r=setTimeout(()=>{i(),n()},e);function i(){clearTimeout(r),t?.removeEventListener(`abort`,a)}function a(){i(),n()}if(t?.aborted){i(),n();return}t?.addEventListener(`abort`,a,{once:!0})})}var X=ce();function St(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),o=e?.managed.length||0;(0,Y.useEffect)(()=>{s()},[]);async function s(){try{t(await _())}catch(e){a(e.message)}}async function c(e,n){r(e),a(null);try{let r=await n();t(r),a(`${e} complete.`)}catch(e){a(e.message)}finally{r(null)}}function l(){o!==0&&window.confirm(`Stop ${o} dashboard-managed server${o===1?``:`s`}?`)&&c(`Stop all managed`,f)}return(0,X.jsxs)(`section`,{className:`process-control-panel`,"aria-label":`Process control`,children:[(0,X.jsxs)(`div`,{className:`process-control-header`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Process control`}),(0,X.jsxs)(`strong`,{children:[o,` managed`]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:s,disabled:n!=null,children:`Refresh`})]}),(0,X.jsxs)(`div`,{className:`process-control-actions`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:l,disabled:n!=null||o===0,children:`Stop all managed`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void c(`Adopt/recover managed`,k),disabled:n!=null,children:`Adopt/recover`}),(0,X.jsx)(`button`,{type:`button`,disabled:!0,title:e?.unsupported.reason||`Planned`,children:`Force release port`})]}),(0,X.jsx)(`p`,{className:`process-control-hint`,children:`Stop all affects only dashboard-managed servers. Adopt/recover reconnects known managed process records without stopping external instances.`}),(0,X.jsxs)(`div`,{className:`process-control-list`,children:[e?.managed.map(e=>(0,X.jsxs)(`div`,{className:`process-control-row`,children:[(0,X.jsxs)(`span`,{children:[`:`,e.port]}),(0,X.jsx)(`strong`,{children:e.pid?`pid ${e.pid}`:`pid n/a`}),(0,X.jsx)(`em`,{children:e.proof})]},e.port)),o===0&&(0,X.jsx)(`p`,{children:`No dashboard-managed servers are registered.`})]}),i&&(0,X.jsx)(`p`,{className:`process-control-message`,children:i})]})}var Ct=4e3,wt={info:`log-level-info`,warn:`log-level-warn`,error:`log-level-error`};function Tt(e){try{return new Date(e).toLocaleTimeString(`en-GB`,{hour12:!1})}catch{return e.slice(11,19)}}function Et({port:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!0),[s,c]=(0,Y.useState)(`all`),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useCallback)(async()=>{try{let t=await fetch(`/api/manager/instance-logs/${e}`);if(!t.ok){i(`HTTP ${t.status}`);return}let r=await t.json();r.ok&&r.snapshot?(n(r.snapshot),i(null)):i(r.error||`Unknown error`)}catch(e){i(e.message)}},[e]);(0,Y.useEffect)(()=>(d(),u.current=setInterval(d,Ct),()=>{u.current&&clearInterval(u.current)}),[d]),(0,Y.useEffect)(()=>{a&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},[t,a]);let f=t?.lines.filter(e=>s===`all`||e.level===s)??[];return r&&!t?(0,X.jsxs)(`div`,{className:`detail-empty`,children:[`Failed to load logs: `,r]}):t?.source===`none`?(0,X.jsx)(`div`,{className:`detail-empty`,children:t.reason||`No log source reachable for this instance.`}):(0,X.jsxs)(`div`,{className:`logs-panel`,children:[(0,X.jsxs)(`div`,{className:`logs-toolbar`,children:[(0,X.jsxs)(`select`,{className:`logs-filter`,value:s,onChange:e=>c(e.target.value),children:[(0,X.jsx)(`option`,{value:`all`,children:`All levels`}),(0,X.jsx)(`option`,{value:`info`,children:`Info`}),(0,X.jsx)(`option`,{value:`warn`,children:`Warn`}),(0,X.jsx)(`option`,{value:`error`,children:`Error`})]}),(0,X.jsxs)(`label`,{className:`logs-autoscroll`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),`Auto-scroll`]}),(0,X.jsxs)(`span`,{className:`logs-meta`,children:[t?`${t.lines.length} lines · source: ${t.source}`:`Loading…`,t?.truncated&&` · truncated`]})]}),(0,X.jsx)(`div`,{className:`logs-container`,ref:l,children:f.length===0?(0,X.jsx)(`div`,{className:`logs-empty`,children:`No log lines available.`}):f.map((e,t)=>(0,X.jsxs)(`div`,{className:`log-line ${wt[e.level]}`,children:[(0,X.jsx)(`span`,{className:`log-ts`,children:Tt(e.ts)}),(0,X.jsx)(`span`,{className:`log-level`,children:e.level.toUpperCase()}),(0,X.jsx)(`span`,{className:`log-text`,children:e.text})]},t))})]})}function Dt(e){let t=e.instance;return(0,X.jsxs)(`section`,{className:`detail-panel`,"aria-label":`Selected instance detail`,children:[e.activeTab===`overview`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`overview-grid`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Status`}),(0,X.jsx)(`strong`,{children:t?.status||`n/a`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`CLI`}),(0,X.jsx)(`strong`,{children:t?.currentCli||`n/a`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Model`}),(0,X.jsx)(`strong`,{children:t?.currentModel||`n/a`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Owner`}),(0,X.jsx)(`strong`,{children:t?.lifecycle?.owner||`n/a`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Version`}),(0,X.jsx)(`strong`,{children:t?.version||`n/a`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Group`}),(0,X.jsx)(`strong`,{children:t?.group||`ungrouped`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Reason`}),(0,X.jsx)(`strong`,{children:t?.lifecycle?.reason||t?.healthReason||`ok`})]})]}),(0,X.jsx)(St,{})]}),e.activeTab===`logs`&&t&&(0,X.jsx)(Et,{port:t.port}),e.activeTab===`logs`&&!t&&(0,X.jsx)(`div`,{className:`detail-empty`,children:`Select an instance to view its logs.`})]})}function Ot(e){return(0,X.jsxs)(`div`,{className:`empty-navigator`,role:`status`,"aria-live":`polite`,children:[(0,X.jsx)(`p`,{className:`empty-navigator-headline`,children:`No Jaw instances detected on the scanned range.`}),(0,X.jsxs)(`p`,{className:`empty-navigator-subline`,children:[`Currently scanning ports `,e.rangeFrom,`–`,e.rangeTo,`. Try widening the range, or start a Jaw with the command below.`]}),(0,X.jsxs)(`code`,{className:`empty-navigator-code`,"aria-label":`Suggested command`,children:[`jaw serve --port `,e.rangeFrom]})]})}function kt(e,t={}){return t.transitioning?`transitioning`:t.busy?`working`:e.status===`offline`?`offline`:e.status===`online`?`online`:`attention`}function At(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e/1e3)):0;if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function jt(e){return[`:${e.port}`,e.homeDisplay||`home n/a`,e.currentCli||`cli n/a`,e.currentModel||`model n/a`,`v${e.version||`n/a`}`].join(` · `)}function Mt(e,t){let n=Number(!!t.favorite)-Number(!!e.favorite);return n===0?e.port-t.port:n}var Nt={start:`starting…`,stop:`stopping…`,restart:`restarting…`,perm:`registering…`,unperm:`unregistering…`};function Pt(e){return`instance-status status-${e}`}var Ft=()=>(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`12`,height:`12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,X.jsx)(`rect`,{x:`3`,y:`3`,width:`10`,height:`10`,rx:`1.5`})}),It=()=>(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`12`,height:`12`,stroke:`currentColor`,strokeWidth:`1.5`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M6.5 3.5H4a1 1 0 0 0-1 1V12a1 1 0 0 0 1 1h7.5a1 1 0 0 0 1-1V9.5`}),(0,X.jsx)(`path`,{d:`M9.5 2.5h4v4`}),(0,X.jsx)(`path`,{d:`M13.5 2.5 8 8`})]}),Lt=({open:e})=>(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`12`,height:`12`,stroke:`currentColor`,strokeWidth:`1.5`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,style:{transform:e?`rotate(180deg)`:void 0,transition:`transform 0.12s`},children:(0,X.jsx)(`path`,{d:`M3.5 6l4.5 4.5L12.5 6`})});function Rt(e){let[,t]=(0,Y.useState)(0);return(0,Y.useEffect)(()=>{if(e.startedAtMs==null)return;let n=window.setInterval(()=>t(e=>e+1),1e3);return()=>window.clearInterval(n)},[e.startedAtMs]),e.startedAtMs==null?null:(0,X.jsx)(`span`,{className:`instance-row-working-duration`,children:At(Date.now()-e.startedAtMs)})}function zt(e){let t=e.instance.lifecycle,n=t?.reason||e.instance.healthReason||`ok`,[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(e.instance.label||e.profile?.label||e.label),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null);function d(e){e.stopPropagation()}let f=e.transitioning?Nt[e.transitioning]:null,p=kt(e.instance,{busy:!!e.agentBusy,transitioning:e.transitioning||null}),m=(0,Y.useRef)(null);p===`working`?m.current??=Date.now():m.current=null;let h=p===`transitioning`&&f?f:p===`working`?`Working`:p===`offline`?`Offline`:p===`attention`?`Attention`:`Online`,g=e.density===`compact`||e.density===`rail`,_=`${Pt(e.instance.status)}${f?` is-transitioning`:``}${e.agentBusy?` is-busy`:``} is-${p}`,v=e.instance.label||e.profile?.label||e.label;async function y(t){t.preventDefault(),t.stopPropagation(),c(!0),u(null);try{await e.onInstanceLabelSave(e.instance.port,a),i(!1)}catch(e){u(e.message)}finally{c(!1)}}return(0,X.jsxs)(`article`,{className:`instance-row density-${e.density||`comfortable`} priority-${e.priority||`normal`} ${e.selected?`is-selected`:``}${f?` is-transitioning-row`:``} is-${p}`,title:jt(e.instance),"aria-current":e.selected?`true`:void 0,children:[(0,X.jsxs)(`div`,{className:`instance-row-body`,children:[(0,X.jsxs)(`button`,{className:`instance-row-select`,type:`button`,"data-instance-port":e.instance.port,"aria-pressed":e.selected,onClick:()=>{e.onSelect(e.instance)},children:[(0,X.jsxs)(`span`,{className:`instance-row-main`,children:[(0,X.jsx)(`span`,{className:_,"aria-label":e.instance.status}),(0,X.jsxs)(`span`,{className:`instance-row-title`,children:[g?null:(0,X.jsxs)(`span`,{className:`instance-row-status-line`,"data-status":p,children:[(0,X.jsx)(`span`,{className:`instance-row-status-pill is-${p} health-${e.instance.status}`,title:h,children:h}),p===`working`?(0,X.jsx)(Rt,{startedAtMs:m.current}):null]}),(0,X.jsxs)(`span`,{className:`instance-row-title-line`,children:[(0,X.jsx)(`strong`,{children:e.instance.favorite?`Pinned ${v}`:v}),e.activityUnreadCount?(0,X.jsxs)(`span`,{className:`instance-unread-badge`,"aria-label":`${e.activityUnreadCount} unread activity`,children:[`(`,e.activityUnreadCount>99?`99+`:e.activityUnreadCount,`)`]}):null]}),f&&(0,X.jsx)(`span`,{className:`instance-row-secondary`,children:(0,X.jsx)(`em`,{className:`instance-row-transition`,children:f})})]})]}),(0,X.jsxs)(`span`,{className:`instance-row-meta`,children:[e.priority!==`active`&&e.showLatestActivityTitle!==!1&&e.latestActivityTitle&&(0,X.jsx)(`span`,{className:`instance-row-activity-title`,children:e.latestActivityTitle}),e.showRuntimeLine!==!1&&(0,X.jsxs)(`span`,{className:`instance-row-runtime`,children:[e.instance.currentCli||`cli n/a`,` / `,e.instance.currentModel||`model n/a`]}),e.priority!==`active`&&(0,X.jsxs)(`span`,{className:`instance-row-version`,children:[`v`,e.instance.version||`n/a`,` · `,e.uptime]}),e.priority!==`active`&&(0,X.jsxs)(`span`,{className:`instance-row-reason`,children:[new Date(e.instance.lastCheckedAt).toLocaleTimeString(),` · `,n]})]})]}),(0,X.jsxs)(`div`,{className:`instance-row-quick`,onClick:d,children:[e.priority===`active`&&e.instance.ok&&(e.sessionCount??0)>=1&&e.onToggleSessions?(0,X.jsx)(`button`,{type:`button`,className:`quick-btn action-sessions`,"aria-controls":e.sessionListId,"aria-expanded":e.sessionsOpen===!0,"aria-label":`Sessions (${e.sessionCount})`,title:`Sessions (${e.sessionCount})`,onClick:t=>{d(t),e.onToggleSessions?.(e.instance.port)},children:(0,X.jsx)(Lt,{open:e.sessionsOpen===!0})}):null,(0,X.jsx)(`button`,{type:`button`,className:`quick-btn action-stop`,onClick:t=>{d(t),e.onLifecycle(`stop`,e.instance)},disabled:!t?.canStop||e.busy,title:`Stop`,"aria-label":`Stop`,children:(0,X.jsx)(Ft,{})}),(0,X.jsx)(`a`,{className:`quick-btn action-open${e.instance.ok?``:` is-disabled`}`,href:e.instance.ok?e.instance.url:void 0,target:e.instance.ok?`_blank`:void 0,rel:e.instance.ok?`noreferrer`:void 0,title:`Open in new tab`,"aria-label":`Open`,"aria-disabled":!e.instance.ok||void 0,tabIndex:e.instance.ok?void 0:-1,onClick:t=>{if(!e.instance.ok){t.preventDefault();return}d(t),e.onMarkActivitySeen(e.instance.port)},children:(0,X.jsx)(It,{})}),(0,X.jsxs)(`span`,{className:`port`,children:[`:`,e.instance.port]})]})]}),e.showInlineLabelEditor!==!1&&r?(0,X.jsxs)(`form`,{className:`instance-label-edit-form`,onSubmit:e=>void y(e),onClick:d,children:[(0,X.jsx)(`input`,{className:`instance-label-input`,value:a,maxLength:120,"aria-label":`Rename ${v}`,onChange:e=>o(e.target.value)}),(0,X.jsx)(`button`,{className:`instance-label-save`,type:`submit`,disabled:s,children:`Save`}),(0,X.jsx)(`button`,{className:`instance-label-cancel`,type:`button`,disabled:s,onClick:()=>{o(e.instance.label||e.profile?.label||e.label),u(null),i(!1)},children:`Cancel`}),l&&(0,X.jsx)(`span`,{className:`instance-label-error`,children:l})]}):e.showInlineLabelEditor===!1?null:(0,X.jsx)(`button`,{className:`instance-label-edit-button`,type:`button`,"aria-label":`Rename ${v}`,title:`Rename`,onClick:t=>{d(t),o(e.instance.label||e.profile?.label||e.label),u(null),i(!0)},children:(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`13`,height:`13`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M12 20h9`}),(0,X.jsx)(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]})}),e.jumpHint?(0,X.jsx)(`span`,{className:`instance-jump-hint`,"aria-hidden":`true`,children:e.jumpHint}):null,e.showSelectedActions!==!1&&(0,X.jsxs)(`div`,{className:`instance-actions`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`Preview`,title:`Preview`,onClick:t=>{d(t),e.onPreview(e.instance)},disabled:!e.instance.ok,children:`Prev`}),(0,X.jsx)(`button`,{type:`button`,className:`action-start`,"aria-label":`Start`,onClick:t=>{d(t),e.onLifecycle(`start`,e.instance)},disabled:!t?.canStart||e.busy,title:t?.commandPreview?.join(` `),children:`Start`}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Register as persistent service`,onClick:t=>{d(t),e.onLifecycle(`perm`,e.instance)},disabled:!t?.canPerm||e.busy,title:`Register as persistent service`,children:`Perm`}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Restart`,title:`Restart`,onClick:t=>{d(t),e.onLifecycle(`restart`,e.instance)},disabled:!t?.canRestart||e.busy,children:`Res`})]})]})}var Bt=`jaw.sidebarGroupCollapsed`;function Vt(){try{if(typeof localStorage>`u`)return{};let e=localStorage.getItem(Bt);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`boolean`&&(n[e]=r);return n}catch{return{}}}function Ht(e){try{if(typeof localStorage>`u`)return;localStorage.setItem(Bt,JSON.stringify(e))}catch{}}function Ut(){let[e,t]=(0,Y.useState)(Vt),n=(0,Y.useCallback)(t=>e[t]===!0,[e]),r=(0,Y.useCallback)(e=>{t(t=>{let n={...t,[e]:!t[e]};return Ht(n),n})},[]);return{isCollapsed:n,toggle:r,toggleGroup:r}}function Wt(e,t,n){if(e.length===0)return null;if(t==null)return n===`previous`?e[e.length-1]??null:e[0]??null;let r=e.indexOf(t);return r===-1?null:n===`previous`?r>0?e[r-1]??null:null:r<e.length-1?e[r+1]??null:null}function Gt(e){let t=/^jumpInstance([1-9])$/.exec(e);return t?Number(t[1])-1:null}function Kt(e){return e===`offline`||e===`unknown`||e===`timeout`}function qt(e,t,n){let r=e.slice(0,Math.max(0,t));return n!=null&&e.includes(n)&&!r.includes(n)?[...r,n]:r}function Jt(e){let t=e.setTimeoutFn??setTimeout,n=e.clearTimeoutFn??clearTimeout,r=!1,i=null,a=()=>{i!=null&&(n(i),i=null)};return{sync(n){if(!n){a(),r&&(r=!1,e.onVisibilityChange(!1));return}r||i!=null||(i=t(()=>{i=null,r=!0,e.onVisibilityChange(!0)},e.delayMs))},dispose(){a()}}}var Yt=!1,Xt=new Set;function Zt(e){return Xt.add(e),()=>{Xt.delete(e)}}function Qt(){return Yt}function $t(e){Yt!==e&&(Yt=e,Xt.forEach(e=>e()))}function en(e){return e.altKey&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey}function tn(e){return Array.from(e.querySelectorAll(`[data-instance-port]`)).map(e=>Number(e.dataset.instancePort)).filter(e=>Number.isInteger(e))}function nn(e,t,n){if(e.isComposing||e.keyCode===229)return;let r=Array.from(t.querySelectorAll(`[data-instance-port]`));if(r.length===0)return;let i=r.map(e=>Number(e.dataset.instancePort)),a=document.activeElement instanceof HTMLElement?document.activeElement:null;if(!a||!r.includes(a)||e.target!==a)return;let o=Number(a.dataset.instancePort),s=null;if(e.key===`ArrowDown`)s=Wt(i,o,`next`);else if(e.key===`ArrowUp`)s=Wt(i,o,`previous`);else if(e.key===`Home`)s=i[0]??null;else if(e.key===`End`)s=i[i.length-1]??null;else if(e.key===`Enter`&&o!=null){e.preventDefault(),n(o);return}s!=null&&(e.preventDefault(),r.find(e=>Number(e.dataset.instancePort)===s)?.focus())}var rn=null;function an(e){rn=e}function on(){return rn}function sn(e,t){return e.filter(e=>!t.has(e.port))}function cn(e,t){let n=new Set,r=t==null?[]:e.filter(e=>e.port===t),i=sn(e,n).filter(e=>e.favorite);i.forEach(e=>n.add(e.port));let a=new Map;for(let t of sn(e,n)){if(!t.group)continue;let e=a.get(t.group)||[];e.push(t),a.set(t.group,e),n.add(t.port)}let o=sn(e,n),s=o.filter(e=>e.status===`online`),c=o.filter(e=>e.status===`error`),l=o.filter(e=>Kt(e.status));i.sort(Mt),s.sort(Mt),c.sort(Mt),l.sort(Mt);for(let e of a.values())e.sort(Mt);return[{id:`active`,label:`Selected`,instances:r},{id:`favorites`,label:`Pinned`,instances:i},...Array.from(a.entries()).map(([e,t])=>({id:`group-${e}`,label:e,instances:t})),{id:`running`,label:`Running`,instances:s},{id:`attention`,label:`Attention`,instances:c},{id:`settled`,label:`Settled`,instances:l}].filter(e=>e.instances.length>0)}function ln(e,t,n,r=`normal`,i,a){return(0,X.jsx)(zt,{instance:t,...n===void 0?{}:{profile:n},selected:e.selectedPort===t.port,busy:e.lifecycleBusyPort===t.port,transitioning:e.transitioningPort===t.port&&e.transitionAction||null,activityUnreadCount:e.activityUnreadByPort?.[t.port]||0,latestActivityTitle:e.latestTitleByPort?.[t.port]||null,agentBusy:e.busyPorts?.has(t.port)||!1,...e.showLatestActivityTitles===void 0?{}:{showLatestActivityTitle:e.showLatestActivityTitles},...e.showInlineLabelEditor===void 0?{}:{showInlineLabelEditor:e.showInlineLabelEditor},...e.showSidebarRuntimeLine===void 0?{}:{showRuntimeLine:e.showSidebarRuntimeLine},...e.showSelectedRowActions===void 0?{}:{showSelectedActions:e.showSelectedRowActions},...e.density===void 0?{}:{density:e.density},...r===`active`&&e.activeSessionCount!==void 0?{sessionCount:e.activeSessionCount}:{},...r===`active`&&e.activeSessionsOpen!==void 0?{sessionsOpen:e.activeSessionsOpen}:{},...r===`active`&&e.onToggleActiveSessions?{onToggleSessions:e.onToggleActiveSessions}:{},...a===void 0?{}:{sessionListId:a},priority:r,label:e.getLabel(t),uptime:e.formatUptime(t.uptime),onSelect:e.onSelect,onPreview:e.onPreview,onMarkActivitySeen:e.onMarkActivitySeen,onInstanceLabelSave:e.onInstanceLabelSave,onLifecycle:e.onLifecycle,jumpHint:i??null},t.port)}function un(e,t,n,r){let i=e.instances.find(e=>e.port===t),a=e.id===`settled`?qt(e.instances.map(e=>e.port),r,t):[],o=new Map(e.instances.map(e=>[e.port,e])),s=e.id===`settled`?a.map(e=>o.get(e)).filter(e=>e!=null):e.instances;return e.id===`active`||!n?s:i?[i]:[]}function dn(e){let t=(0,Y.useId)(),{group:n,props:r,profileMap:i,collapsed:a,onToggle:o,jumpStartIndex:s,showJumpHints:c,settledVisibleCount:l,onShowMoreSettled:u}=e,d=n.id!==`settled`||!a,f=un(n,r.selectedPort,a,l),p=`instance-group-body-${t}`,m=n.id===`active`&&f[0]?.ok?`instance-sessions-${t}-${f[0].port}`:void 0,h=n.id===`settled`&&d?Math.max(0,n.instances.length-l):0,g=n.id===`active`?(0,X.jsxs)(`div`,{className:`instance-group-header`,children:[(0,X.jsx)(`span`,{children:n.label}),(0,X.jsx)(`strong`,{children:n.instances.length})]}):(0,X.jsxs)(`button`,{type:`button`,className:`instance-group-header instance-group-toggle`,"aria-expanded":!a,"aria-controls":p,onClick:o,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`svg`,{className:`instance-group-chevron`,viewBox:`0 0 16 16`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M3.5 6l4.5 4.5L12.5 6`})}),` `,n.label]}),(0,X.jsx)(`strong`,{children:n.instances.length})]});return(0,X.jsxs)(`section`,{className:`instance-group`,"aria-label":`${n.label} instances`,children:[g,(0,X.jsxs)(`div`,{id:p,hidden:a&&f.length===0,children:[f.map((e,t)=>{let a=s+t,o=c&&a<9?String(a+1):null;return ln(r,e,e.profileId?i.get(e.profileId):void 0,n.id===`active`?`active`:`normal`,o,m)}),n.id===`active`&&f[0]?.ok?(0,X.jsx)(`div`,{id:m,children:r.renderActiveSessionList?.(f[0].port)}):null,n.id===`settled`&&d&&h>0?(0,X.jsxs)(`button`,{type:`button`,className:`instance-settled-more`,onClick:u,children:[`Show `,Math.min(h,25),` more`]}):null]})]},n.id)}function fn(e){let t=cn(e.instances,e.selectedPort),n=new Map((e.profiles||[]).map(e=>[e.profileId,e])),{isCollapsed:r,toggle:i}=Ut(),a=(0,Y.useSyncExternalStore)(Zt,Qt),[o,s]=(0,Y.useState)(10);if((0,Y.useEffect)(()=>{s(10)},[e.instances]),t.length===0&&n.size===0)return(0,X.jsx)(`section`,{className:`state`,children:`No matching instances found.`});let c=0,l=t.map(t=>{let l=t.id!==`active`&&r(t.id),u=un(t,e.selectedPort,l,o).length,d=c;return c+=u,(0,X.jsx)(dn,{group:t,props:e,profileMap:n,collapsed:l,onToggle:()=>i(t.id),jumpStartIndex:d,showJumpHints:a,settledVisibleCount:o,onShowMoreSettled:()=>s(e=>e+25)},t.id)});return n.size>0?(0,X.jsx)(`div`,{className:`instance-groups profile-instance-groups is-profile-merged`,children:l}):(0,X.jsx)(`div`,{className:`instance-groups`,children:l})}var pn=2,mn=500,hn=1e4;function gn(e){let t=e?.trim();if(!t)return null;if(/^\d+$/.test(t)){let e=Number(t)*1e3;return Number.isSafeInteger(e)?e:null}let n=Date.parse(t);if(!Number.isFinite(n))return null;let r=n-Date.now();return r>0?r:null}function _n(){return new DOMException(`The operation was aborted.`,`AbortError`)}function vn(e,t){return new Promise((n,r)=>{if(t?.aborted){r(_n());return}let i=()=>{clearTimeout(a),r(_n())},a=setTimeout(()=>{t?.removeEventListener(`abort`,i),n()},e);t?.addEventListener(`abort`,i,{once:!0})})}function yn(e,t){return e===void 0||!Number.isFinite(e)?t:Math.max(0,Math.floor(e))}async function bn(e,t={}){let n=yn(t.retries,pn),r=yn(t.baseDelayMs,mn),i=t.fetchImpl??fetch,a=t.delay??vn,o=t.random??Math.random,s={method:`GET`,...t.signal?{signal:t.signal}:{}},c=0,l=await i(e,s);for(let u=0;l.status===429&&u<n;u++){let n=hn-c;if(n<=0)return l;let d=gn(l.headers.get(`Retry-After`)),f=Math.min(r*2**u,hn),p=Math.min(1,Math.max(0,o()))*f,m=Math.min(d??p,n);await a(m,t.signal),c+=m,l=await i(e,s)}return l}var xn=2e3,Sn=new Map,Cn=(...e)=>fetch(...e),wn=()=>Date.now();function Tn(e){let t=null;return e.lastError?.kind===`load`?t={kind:`load`,message:e.errorMessage??`sessions load failed`}:e.lastError?.kind===`switch`&&(t={kind:`switch`,seq:e.lastError.seq,message:e.errorMessage??`session switch failed`}),{data:e.data,switching:e.switching,error:t,count:e.data?.sessions.length??0}}function En(){return{generation:0,at:0,promise:null,data:null,switching:!1,lastError:null,errorMessage:null,snapshot:{data:null,switching:!1,error:null,count:0},listeners:new Set}}function Dn(e){let t=Sn.get(e);return t||(t=En(),Sn.set(e,t)),t}function On(e){return e instanceof Error?e.message:String(e)}function kn(e){e.snapshot=Tn(e);for(let t of[...e.listeners])t()}async function An(e){let t=await bn(`/i/${e}/api/chat-sessions`,{fetchImpl:Cn});if(!t.ok)throw Error(`sessions fetch failed: ${t.status}`);let n=(await t.json()).data??{};return{sessions:Array.isArray(n.sessions)?n.sessions:[],activeId:typeof n.active==`string`?n.active:null}}async function jn(e,t){let n=await Cn(`/i/${e}/api/chat-sessions/${t}/switch`,{method:`POST`});if(n.ok)return;let r=await n.json().catch(()=>({}));throw Error(r.error||`switch failed: ${n.status}`)}function Mn(e,t){let n=Dn(e);return n.listeners.add(t),()=>{n.listeners.delete(t)}}function Nn(e){return Dn(e).snapshot}async function Pn(e){let t=Dn(e);if(t.promise){await t.promise;return}if(t.data&&wn()-t.at<xn)return;let n=t.generation,r=An(e);t.promise=r;try{let e=await r;if(t.generation!==n)return;t.data=e,t.at=wn(),t.lastError=null,t.errorMessage=null,kn(t)}catch(e){throw t.promise===r&&(t.promise=null),t.generation===n&&(t.lastError={kind:`load`},t.errorMessage=On(e),kn(t)),e}finally{t.promise===r&&(t.promise=null)}}async function Fn(e,t){let n=Dn(e);if(!n.switching){n.switching=!0,n.lastError=null,n.errorMessage=null,kn(n);try{try{await jn(e,t)}catch(e){throw n.lastError={kind:`switch`,seq:t},n.errorMessage=On(e),kn(n),e}n.generation++,n.at=-1/0,n.promise=null,await Pn(e)}finally{n.switching=!1,kn(n)}}}async function In(e){let t=Dn(e).lastError;if(t?.kind===`switch`){await Fn(e,t.seq);return}await Pn(e)}function Ln(e){let t=e.split(`:`);if(t.length>=4&&t[0]===`jaw`){let e=t[3]||``,n=t.includes(`thread`);return`${t[1]} ${e.slice(0,11)}${n?` · thread`:``}`}return e.slice(0,32)}function Rn(e){return e.label&&!e.label.startsWith(`jaw:`)?e.label:e.remoteKey?Ln(e.remoteKey):e.label?Ln(e.label):e.seq===0?`Default session`:`Session #${e.seq}`}function zn(e){if(!e)return null;let t=new Date(e.replace(` `,`T`)).getTime();if(Number.isNaN(t))return null;let n=Math.floor((Date.now()-t)/6e4);if(n<1)return`now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Bn(e){let t=(0,Y.useCallback)(t=>Mn(e.port,t),[e.port]),n=(0,Y.useSyncExternalStore)(t,()=>Nn(e.port));if((0,Y.useEffect)(()=>{e.open&&Pn(e.port).catch(()=>{})},[e.open,e.port]),!e.open)return null;async function r(t,r){if(t.stopPropagation(),!(r.id===n.data?.activeId||n.switching))try{await Fn(e.port,r.seq),e.onSessionSwitched?.()}catch{}}let i=t=>{t.stopPropagation(),In(e.port).catch(()=>{})};if(n.error?.kind===`load`)return(0,X.jsx)(`div`,{className:`instance-session-list`,role:`list`,"aria-label":`Chat sessions`,children:(0,X.jsxs)(`div`,{className:`instance-session-error`,children:[(0,X.jsx)(`span`,{children:n.error.message}),(0,X.jsx)(`button`,{type:`button`,className:`instance-session-retry`,onClick:i,children:`Retry`})]})});if(n.data===null)return(0,X.jsx)(`div`,{className:`instance-session-list`,role:`list`,"aria-label":`Chat sessions`,children:(0,X.jsx)(`div`,{className:`instance-session-empty`,children:`Loading sessions…`})});let a=n.data.sessions;if(a.length===0)return null;let o=n.data?.activeId??null;return(0,X.jsxs)(`div`,{className:`instance-session-list`,role:`list`,"aria-label":`Chat sessions`,children:[n.error?.kind===`switch`&&(0,X.jsxs)(`div`,{className:`instance-session-error`,children:[(0,X.jsx)(`span`,{children:n.error.message}),(0,X.jsx)(`button`,{type:`button`,className:`instance-session-retry`,onClick:i,children:`Retry`})]}),a.map(e=>{let t=e.id===o,i=zn(e.lastActivityAt);return(0,X.jsxs)(`button`,{type:`button`,role:`listitem`,className:`instance-session-row${t?` is-active`:``}`,disabled:n.switching,"aria-current":t||void 0,onClick:t=>void r(t,e),children:[(0,X.jsxs)(`span`,{className:`instance-session-title`,children:[Rn(e),e.source&&(0,X.jsx)(`span`,{className:`session-source-badge`,children:e.source})]}),(0,X.jsx)(`span`,{className:`instance-session-meta`,children:n.switching?`switching…`:`${e.message_count} msg${i?` · ${i}`:``}`})]},e.id)})]})}var Vn={data:null,switching:!1,error:null,count:0};function Hn(e){let[t,n]=(0,Y.useState)(!0),r=(0,Y.useCallback)(t=>e==null?()=>{}:Mn(e,t),[e]),i=(0,Y.useCallback)(()=>e==null?Vn:Nn(e),[e]),a=(0,Y.useSyncExternalStore)(r,i);return(0,Y.useEffect)(()=>{n(!0),e!=null&&Pn(e).catch(()=>{})},[e]),{activeSessionCount:a.count,sessionsOpen:t,setSessionsOpen:n}}function Un(e){let{activeSessionCount:t,sessionsOpen:n,setSessionsOpen:r}=Hn(e.selectedInstance?.ok?e.selectedInstance.port:null),i=!e.error&&!e.loading&&e.instances.length===0&&!e.instances.some(e=>e.hidden),a=e.selectedInstance&&!e.filtered.some(t=>t.port===e.selectedInstance?.port)?[e.selectedInstance,...e.filtered]:e.filtered,o=t=>{if(t.ok){e.onPreview(t);return}e.onSelect(t)},s=e=>(0,X.jsx)(Bn,{port:e,open:n},e);return(0,X.jsxs)(X.Fragment,{children:[e.error&&(0,X.jsxs)(`section`,{className:`state error-state`,children:[`Scan failed: `,e.error]}),!e.error&&e.loading&&(0,X.jsx)(`section`,{className:`state`,children:`Scanning local Jaw instances...`}),i&&e.data?.manager&&(0,X.jsx)(Ot,{rangeFrom:e.data.manager.rangeFrom,rangeTo:e.data.manager.rangeTo}),!e.error&&!i&&(0,X.jsx)(fn,{instances:a,selectedPort:e.selectedInstance?.port||null,lifecycleBusyPort:e.lifecycleBusyPort,transitioningPort:e.transitioningPort,transitionAction:e.transitionAction,activityUnreadByPort:e.activityUnreadByPort,latestTitleByPort:e.latestTitleByPort,...e.busyPorts===void 0?{}:{busyPorts:e.busyPorts},showLatestActivityTitles:e.showLatestActivityTitles,showInlineLabelEditor:e.showInlineLabelEditor,showSidebarRuntimeLine:e.showSidebarRuntimeLine,showSelectedRowActions:e.showSelectedRowActions,activeSessionCount:t,activeSessionsOpen:n,onToggleActiveSessions:()=>r(e=>!e),renderActiveSessionList:s,profiles:e.profiles,getLabel:e.getLabel,formatUptime:e.formatUptime,onSelect:o,onPreview:e.onPreview,onMarkActivitySeen:e.onMarkActivitySeen,onInstanceLabelSave:e.onInstanceLabelSave,onLifecycle:e.onLifecycle})]})}function Wn(e){let t=e.count==null?``:` ${e.count}`;return(0,X.jsxs)(`button`,{type:`button`,className:`profile-chip ${e.active?`is-active`:``}`,onClick:()=>e.onToggle(e.profile.profileId),"aria-pressed":e.active,title:e.profile.homePath,children:[(0,X.jsx)(`span`,{children:e.profile.label}),t&&(0,X.jsx)(`strong`,{children:t})]})}async function Gn(){let e=await fetch(`/api/dashboard/desktop-status`);if(!e.ok)throw Error(`desktop status failed: ${e.status}`);return await e.json()}function Kn(){let e=window.location.pathname+window.location.search;window.location.href=`jaw://open?path=${encodeURIComponent(e)}`}function qn(){let e=le(),[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{if(e)return;let t=!1;return Gn().then(e=>{t||n(e)}).catch(()=>{t||i(!0)}),()=>{t=!0}},[e]),e?null:t?.inDesktop?(0,X.jsx)(`span`,{className:`desktop-status-badge`,title:`cli-jaw Desktop ${t.version}`,children:`Running in cli-jaw Desktop`}):!t&&!r?null:(0,X.jsx)(`button`,{type:`button`,className:`desktop-open-button`,onClick:Kn,title:t?.downloadUrl||`Open this dashboard path in cli-jaw Desktop`,children:`Open in Desktop App`})}function Jn(e){let t=le(),n=e.actions;return(0,X.jsx)(`div`,{className:`command-center command-bar${t?` is-electron-titlebar`:``}`,children:(0,X.jsxs)(`div`,{className:`command-primary`,children:[e.mobileMenuButton,(0,X.jsx)(`div`,{className:`command-title`,children:e.title}),(0,X.jsx)(`div`,{className:`command-search`,children:e.search}),(0,X.jsx)(`div`,{className:`command-actions`,children:n})]})})}function Yn(e,t,n){return{feature:e,state:t,...n?{reason:n}:{}}}function Xn(){return le()?`electron`:`web`}function Zn(e){return e===`electron`?{terminal:Yn(`terminal`,`enabled`),browser:Yn(`browser`,`enabled`),folder:Yn(`folder`,`enabled`),doc:Yn(`doc`,`enabled`),diff:Yn(`diff`,`enabled`)}:{terminal:Yn(`terminal`,`disabled`,`Terminal requires the desktop PTY bridge.`),browser:Yn(`browser`,`disabled`,`Browser side panel is available in the desktop app.`),folder:Yn(`folder`,`disabled`,`Folder side panel is available in the desktop app; use the Jawsidian Notes tab on web.`),doc:Yn(`doc`,`disabled`,`Document side panel is available in the desktop app; use the Jawsidian document tab on web.`),diff:Yn(`diff`,`disabled`,`Diff side panel is available in the desktop app.`)}}function Qn(e){return e.state===`enabled`||e.state===`limited`}function $n(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`4`,width:`14`,height:`12`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M6 9l3 2-3 2`}),(0,X.jsx)(`path`,{d:`M11 13h3`})]})}function er(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`4`,width:`14`,height:`12`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M13 4v12`})]})}function tr(){let e=pe(),t=he(),n=Xn();if(n!==`electron`)return null;let r=Zn(n),i=r.terminal,a=r.folder,o=Qn(i),s=Qn(a),c=e.state.bottomPanel,l=c.open&&(c.activeTab??c.tabs[0])===`terminal`,u=e.effectiveRightOpen;return(0,X.jsxs)(`div`,{className:`command-panel-controls`,"aria-label":`Desktop panels`,children:[(0,X.jsx)(`button`,{className:`command-panel-toggle${l?` is-active`:``}`,type:`button`,disabled:!o,onClick:()=>{o&&(l?t.toggleBottomPanel():(t.openBottomTab(`terminal`),document.dispatchEvent(new CustomEvent(`jaw:shortcut-action`,{detail:`focusTerminal`}))))},id:ue,"aria-label":`Toggle terminal panel`,"aria-pressed":l,title:i.reason??"Terminal (Ctrl+`)",children:(0,X.jsx)($n,{})}),(0,X.jsx)(`button`,{className:`command-panel-toggle${u?` is-active`:``}`,type:`button`,disabled:!s,onClick:()=>{s&&(u?t.toggleRightPanel():t.focusOrCreateFirstRightSidebarTab(`files`))},"aria-label":`Toggle right panel`,"aria-pressed":u,title:a.reason??`Side panel (Command+B)`,children:(0,X.jsx)(er,{})})]})}var nr=[{value:`auto`,label:`Auto`,hint:`Follow OS preference`},{value:`light`,label:`Light`,hint:`Always light theme`},{value:`dark`,label:`Dark`,hint:`Always dark theme`}];function rr(e){return(0,X.jsx)(`div`,{className:`theme-switch`,role:`radiogroup`,"aria-label":`Theme`,children:nr.map(t=>{let n=e.theme===t.value;return(0,X.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n,title:t.hint,className:n?`is-active`:``,onClick:()=>e.onChange(t.value),children:t.label},t.value)})})}function ir(e){return(0,X.jsx)(Jn,{mobileMenuButton:(0,X.jsx)(`button`,{className:`drawer-trigger command-icon-button`,type:`button`,onClick:e.onOpenDrawer,"aria-label":`Open sidebar`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`path`,{d:`M4 6h12M4 10h12M4 14h12`})})}),title:(0,X.jsxs)(`h1`,{className:`manager-brand-heading`,"aria-label":`CLI-JAW Dashboard`,children:[(0,X.jsx)(`span`,{className:`manager-brand-wordmark`,children:`CLI-JAW`}),(0,X.jsx)(`span`,{className:`manager-brand-dash`,children:`DASH`})]}),search:(0,X.jsxs)(`div`,{className:`search-input-wrapper is-ghost`,children:[(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,X.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),(0,X.jsx)(`input`,{value:e.query,onChange:t=>e.onQueryChange(t.target.value),placeholder:`Search port, home, CLI, model`,"aria-label":`Search instances`})]}),actions:(0,X.jsxs)(`div`,{className:`command-actions-group`,children:[(0,X.jsx)(tr,{}),(0,X.jsx)(qn,{}),(0,X.jsx)(`button`,{type:`button`,className:`command-palette-trigger`,onClick:e.onOpenPalette,"aria-label":`Open command palette`,title:`Open command palette (⌘K / Ctrl+K)`,children:(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`⌘K`})}),(0,X.jsx)(rr,{theme:e.theme,onChange:e.onThemeChange}),(0,X.jsx)(`button`,{type:`button`,className:`command-icon-button`,onClick:e.onRefresh,disabled:e.loading,"aria-label":e.loading?`Scanning`:`Refresh`,title:e.loading?`Scanning`:`Refresh`,children:(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M16 10a6 6 0 1 1-2-4.5`}),(0,X.jsx)(`path`,{d:`M16 4v4h-4`})]})})]})})}function ar(e,t){return(e.split(`/`).filter(Boolean).pop()||e).replace(/^\.?cli-jaw-(\d+)-[a-f0-9]{7,}$/i,`cli-jaw $1`).replace(/^\.?cli-jaw-(\d+)$/i,`cli-jaw $1`)||`cli-jaw ${t}`}function or(e){if(e.label)return e.label;let t=e.instanceId||e.homeDisplay||``;return ar(t.split(`/`).filter(Boolean).pop()||t,e.port)}function sr(e){if(e==null)return`n/a`;let t=Math.floor(e/60);if(t<1)return`${Math.round(e)}s`;let n=Math.floor(t/60);return n<1?`${t}m`:`${n}h ${t%60}m`}function cr(e){let t=e.className?`help-topic-button ${e.className}`:`help-topic-button`;return(0,X.jsx)(`button`,{type:`button`,className:t,"aria-label":e.label,title:e.label,onClick:()=>e.onOpen(e.topic),children:`?`})}function lr(e){let t=e.split(/[/\\]/).filter(Boolean);return t.length<=2?e:`…/${t.slice(-2).join(`/`)}`}function ur(e){let t=e.instance,n=!!t?.ok,r=e.previewEnabled?`Preview on`:`Preview off`,i=!!(t||e.onOpenHelpTopic),a=t?.projectDirs?.filter(Boolean)??[];return(0,X.jsxs)(`div`,{className:`detail-header`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`eyebrow`,children:`Selected instance`}),(0,X.jsx)(`h2`,{children:t?or(t):`No instance selected`}),t?(0,X.jsxs)(`div`,{className:`project-dirs${a.length?``:` is-empty`}`,children:[(0,X.jsx)(`span`,{className:`label`,children:`Project`}),a.length?a.map((e,t)=>(0,X.jsx)(`span`,{className:`project-dir`,title:e,children:lr(e)},t)):(0,X.jsx)(`span`,{className:`project-dir`,children:`Not set`}),e.onPickProject&&t.ok?(0,X.jsx)(`button`,{type:`button`,className:`project-pick-button`,disabled:e.projectPickBusy,title:`Open the folder chooser on this machine and set the project root`,onClick:()=>e.onPickProject?.(t.port),children:e.projectPickBusy?`Choosing…`:a.length?`Change`:`Choose…`}):null]}):(0,X.jsx)(`span`,{children:`Select an online instance to inspect it.`})]}),i&&(0,X.jsxs)(`div`,{className:`detail-header-actions`,children:[e.onOpenHelpTopic?(0,X.jsx)(cr,{topic:`instances`,label:`Open Instances help`,onOpen:e.onOpenHelpTopic}):null,t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`preview-inline-status ${t.ok&&e.previewEnabled?`is-ready`:`is-unavailable`}`,"aria-label":t.ok&&e.previewEnabled?`Preview ready`:`Preview unavailable`,title:t.ok&&e.previewEnabled?`Preview ready`:`Preview unavailable`}),(0,X.jsxs)(`button`,{type:`button`,className:`preview-switch ${e.previewEnabled?`is-on`:`is-off`}`,role:`switch`,"aria-checked":e.previewEnabled,disabled:!n,onClick:()=>e.onPreviewEnabledChange(!e.previewEnabled),children:[(0,X.jsx)(`span`,{className:`preview-switch-track`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:r})]}),(0,X.jsx)(`button`,{type:`button`,className:`preview-refresh-button`,disabled:!n||!e.previewEnabled,onClick:e.onPreviewRefresh,children:`Refresh`}),(0,X.jsxs)(`a`,{className:`open-link`,href:t.url,target:`_blank`,rel:`noreferrer`,children:[(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`12`,height:`12`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`}),(0,X.jsx)(`polyline`,{points:`15 3 21 3 21 9`}),(0,X.jsx)(`line`,{x1:`10`,y1:`14`,x2:`21`,y2:`3`})]}),`Open`]})]}):null]})]})}var dr=8,fr=5;function pr(e,t,n){if(!n)return!0;let r=n.toLowerCase();return[String(e.port),t,e.url,e.workingDir,e.currentCli].some(e=>{if(!e)return!1;let t=String(e).toLowerCase();return t.startsWith(r)?!0:RegExp(`(^|[^\\p{L}\\p{N}])${mr(r)}`,`u`).test(t)})}function mr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function hr(e){let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)(0),a=(0,Y.useRef)(null),o=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{e.open&&(n(``),i(0),requestAnimationFrame(()=>a.current?.focus()))},[e.open]),(0,Y.useEffect)(()=>{if(!e.open)return;function t(t){t.key===`Escape`&&(t.preventDefault(),e.onClose())}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e.open,e.onClose]);let s=(0,Y.useMemo)(()=>e.instances.filter(n=>pr(n,e.getLabel(n),t)).slice(0,dr),[e.instances,e.getLabel,t]),c=(0,Y.useMemo)(()=>[{id:`refresh`,label:`Refresh scan`,hint:`Re-scan local ports`,run:e.onRefresh},{id:`theme`,label:`Theme: cycle (current ${e.theme})`,hint:`Auto → Light → Dark`,run:e.onCycleTheme},{id:`hidden`,label:e.showHidden?`Hide hidden instances`:`Show hidden instances`,run:e.onToggleHidden},...e.selectedInstance?[{id:`open`,label:`Open ${e.selectedInstance.url} in new tab`,run:e.onOpenSelected}]:[]].slice(0,fr),[e.onRefresh,e.theme,e.onCycleTheme,e.showHidden,e.onToggleHidden,e.selectedInstance,e.onOpenSelected]),l=(0,Y.useMemo)(()=>{let e=[];for(let t of s)e.push({kind:`instance`,instance:t});for(let t of c)e.push({kind:`action`,action:t});return e},[s,c]);(0,Y.useEffect)(()=>{r>=l.length&&i(Math.max(0,l.length-1))},[l.length,r]);function u(t){let n=l[t];n&&(n.kind===`instance`?e.onSelectInstance(n.instance):n.action.run(),e.onClose())}function d(e){e.key===`ArrowDown`?(e.preventDefault(),i(e=>Math.min(l.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),i(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),u(r))}return e.open?(0,X.jsx)(`div`,{className:`command-palette-backdrop`,role:`presentation`,onClick:e.onClose,children:(0,X.jsxs)(`div`,{className:`command-palette`,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`input`,{ref:a,className:`command-palette-input`,placeholder:`Go to instance, or run an action…`,value:t,onChange:e=>{n(e.target.value),i(0)},onKeyDown:d,"aria-label":`Command query`}),(0,X.jsxs)(`div`,{className:`command-palette-list`,ref:o,children:[s.length>0&&(0,X.jsxs)(`div`,{className:`command-palette-section`,role:`group`,"aria-label":`Go to instance`,children:[(0,X.jsx)(`header`,{className:`command-palette-section-header`,children:`Go to instance`}),s.map((t,n)=>{let a=n;return(0,X.jsxs)(`button`,{type:`button`,className:a===r?`command-palette-item is-active`:`command-palette-item`,onMouseEnter:()=>i(a),onClick:()=>u(a),children:[(0,X.jsxs)(`span`,{className:`command-palette-port`,children:[`:`,t.port]}),(0,X.jsx)(`span`,{className:`command-palette-label`,children:e.getLabel(t)})]},t.port)})]}),c.length>0&&(0,X.jsxs)(`div`,{className:`command-palette-section`,role:`group`,"aria-label":`Actions`,children:[(0,X.jsx)(`header`,{className:`command-palette-section-header`,children:`Actions`}),c.map((e,t)=>{let n=s.length+t;return(0,X.jsxs)(`button`,{type:`button`,className:n===r?`command-palette-item is-active`:`command-palette-item`,onMouseEnter:()=>i(n),onClick:()=>u(n),children:[(0,X.jsx)(`span`,{className:`command-palette-label`,children:e.label}),e.hint&&(0,X.jsx)(`span`,{className:`command-palette-hint`,children:e.hint})]},e.id)})]}),l.length===0&&(0,X.jsx)(`p`,{className:`command-palette-empty`,children:`No matches.`})]}),(0,X.jsxs)(`footer`,{className:`command-palette-footer`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`↑↓`}),` navigate`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Enter`}),` select`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Esc`}),` close`]})]})]})}):null}function gr(e){let t={"--activity-dock-height":`${e.activityHeight}px`};return(0,X.jsxs)(`main`,{className:`dashboard-shell manager-shell${e.sidebarCollapsed?` is-sidebar-collapsed`:``}`,style:t,children:[(0,X.jsx)(`header`,{className:`manager-command`,children:e.commandBar}),e.workspace]})}var _r=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`실행 중인 jaw 인스턴스를 보고, 미리보기·로그·설정을 다루는 곳이에요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsx)(`li`,{children:`좌측 네비게이터에서 인스턴스를 골라 우측 Workbench(Overview / Preview / Logs / Settings)에서 작업하실 수 있어요.`}),(0,X.jsx)(`li`,{children:`우측 상단 상태 점이 초록이면 온라인, 회색이면 오프라인이에요.`}),(0,X.jsx)(`li`,{children:`인스턴스에 직접 메시지를 보내실 땐 Preview 탭의 채팅 입력을 쓰세요.`}),(0,X.jsx)(`li`,{children:`Preview 채팅에 나온 Notes vault 경로를 클릭하면 Notes workspace로 이동해 해당 파일을 열 수 있어요.`})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`빠른 판단 기준`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Preview`}),(0,X.jsx)(`td`,{children:`실제 인스턴스 화면을 보거나 메시지를 보낼 때`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Logs`}),(0,X.jsx)(`td`,{children:`응답이 멈췄거나 dispatch 실패 원인을 확인할 때`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Settings`}),(0,X.jsx)(`td`,{children:`해당 인스턴스의 CLI, 모델, 권한을 조정할 때`})]})]})})]}),(0,X.jsxs)(`p`,{className:`help-tip`,children:[`인스턴스가 안 보이시면 터미널에서 `,(0,X.jsx)(`code`,{children:`cli-jaw start`}),`로 새 jaw를 띄워보세요. 자동으로 목록에 떠요.`]})]}),vr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`사람이 먼저 일반 칸반 블럭을 만들고, 실행 인스턴스 블럭을 그 안에 붙이는 계층형 보드예요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[`레인 5개는 `,(0,X.jsx)(`strong`,{children:`Backlog / Ready / In Progress / Review / Done`}),` 순서예요. Backlog는 아직 commit 전 옵션, Ready는 바로 pull 가능한 작업이에요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Overall`}),`은 5열 전체 보드이고, 사이드바에서 각 레인을 누르면 해당 레인만 보는 detail 화면으로 전환돼요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Done`}),`은 Overall에서 최근 4개만 full card로 보여주고, 나머지는 `,(0,X.jsx)(`strong`,{children:`+ N more`}),`를 눌러 Done detail 화면에서 2줄 row로 확인해요.`]}),(0,X.jsxs)(`li`,{children:[`각 레인 하단의 `,(0,X.jsx)(`strong`,{children:`+ Add task`}),`로 일반 칸반 블럭을 만들고, 그 블럭 제목에 쿼리나 작업 메모를 적으시면 돼요.`]}),(0,X.jsxs)(`li`,{children:[`좌측 `,(0,X.jsx)(`strong`,{children:`Running`}),` 섹션에는 현재 실행 중인 인스턴스만 인스턴스 블럭으로 보여요.`]}),(0,X.jsx)(`li`,{children:`인스턴스 블럭을 일반 칸반 블럭 안의 드롭 영역으로 끌어 넣으면 내부 자식 블럭으로 병합돼요. 인스턴스 실행에는 영향 없어요.`}),(0,X.jsxs)(`li`,{children:[`일반 칸반 블럭은 직접 드래그해서 다른 레인으로 옮길 수 있고, `,(0,X.jsx)(`strong`,{children:`Move`}),` / `,(0,X.jsx)(`strong`,{children:`Delete`}),`도 유지돼요.`]})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`상태를 나눠 쓰는 법`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Ready`}),(0,X.jsx)(`td`,{children:`바로 구현하거나 검증할 수 있는 작업`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Review`}),(0,X.jsx)(`td`,{children:`직원 감사, Pro 검증, 수동 smoke가 필요한 작업`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Done`}),(0,X.jsx)(`td`,{children:`커밋, 푸시, 이슈 close까지 끝난 작업`})]})]})})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`인스턴스가 없어도 일반 칸반 블럭은 계속 남아요. 쿼리·아이디어·작업 단위를 먼저 적고, 필요할 때만 실행 인스턴스를 붙이면 돼요.`})]}),yr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`매니저가 1분마다 틱을 돌면서 대시보드에 등록된 자동화 작업을 일괄 dispatch 해주는 곳이에요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Today / Upcoming / Recurring / Blocked`}),` 그룹으로 정리되고, `,(0,X.jsx)(`code`,{children:`cron`}),`·`,(0,X.jsx)(`code`,{children:`runAt`}),`·target port를 함께 저장해요.`]}),(0,X.jsx)(`li`,{children:`Run 버튼으로 즉시 dispatch, 대상 인스턴스가 바쁘면 자동 큐잉이에요. last/next 컬럼으로 실행 이력이 보여요.`}),(0,X.jsxs)(`li`,{children:[`예전엔 인스턴스마다 자기 `,(0,X.jsx)(`code`,{children:`heartbeat.json`}),`을 setInterval로 돌리던 구조였는데, 지금은 `,(0,X.jsx)(`strong`,{children:`매니저가 단일 ticker`}),`로 돌려요. heartbeat.json은 legacy로만 표시되고 자동 실행은 안 돼요.`]})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`실패를 볼 때`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`queued`}),(0,X.jsx)(`td`,{children:`대상 인스턴스가 바빠서 대기 중`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`blocked`}),(0,X.jsx)(`td`,{children:`비활성화했거나 실행 조건이 아직 맞지 않음`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`last/next`}),(0,X.jsx)(`td`,{children:`최근 실행 결과와 다음 실행 예측을 확인하는 기준`})]})]})})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`새 작업은 여기서 만들고, 기존 heartbeat job은 같은 cron으로 옮겨 등록하시면 돼요. 마이그레이션 자동화는 추후 추가됩니다.`})]}),br=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`help-lead`,children:[(0,X.jsx)(`code`,{children:`~/.cli-jaw-dashboard/notes/`}),`의 마크다운 파일을 직접 편집하는 노트장이에요.`]}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[`좌측 트리에서 파일 선택, 우측에서 `,(0,X.jsx)(`strong`,{children:`Raw / Preview / WYSIWYG`}),` 모드로 편집하실 수 있어요.`]}),(0,X.jsxs)(`li`,{children:[`Instances Preview 채팅에서 vault 경로(예: `,(0,X.jsx)(`code`,{children:`~/.cli-jaw-dashboard/notes/foo.md`}),` 또는 `,(0,X.jsx)(`code`,{children:`daily/foo.md`}),`)를 `,(0,X.jsx)(`strong`,{children:`클릭`}),`하면 Notes 탭으로 이동하고 해당 파일이 열려요. 자동 전환은 없고 클릭할 때만 이동합니다.`]}),(0,X.jsxs)(`li`,{children:[`vault 밖 경로(예: 프로젝트 `,(0,X.jsx)(`code`,{children:`.ts`}),` 파일)는 기존처럼 Finder로 열려요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:`⌘/Ctrl + S`}),`로 저장, `,(0,X.jsx)(`kbd`,{children:`⌘/Ctrl + E`}),`로 모드 순환 전환이에요.`]}),(0,X.jsx)(`li`,{children:`파일이 외부에서 바뀌면 충돌 알림이 떠요 — Reload / Overwrite / Keep local 중 선택하세요.`})]}),(0,X.jsxs)(`p`,{className:`help-tip`,children:[`💡 좌측 트리 상단 `,(0,X.jsx)(`strong`,{children:`+ New`}),`로 첫 노트를 만들어 보세요. 폴더는 `,(0,X.jsx)(`code`,{children:`folder/note.md`}),` 처럼 한 번에 만드실 수 있어요.`]})]}),xr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`Jaw Reminders 스냅샷을 대시보드에서 읽고 확인하는 미러 화면이에요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`All / Focused / Scheduled / High / Done`}),` 보기로 현재 reminder 상태를 훑어볼 수 있어요.`]}),(0,X.jsx)(`li`,{children:`Refresh는 외부 Jaw Reminders 스냅샷을 다시 읽어서 대시보드용 row로 반영해요.`}),(0,X.jsx)(`li`,{children:`원본 reminder 저장소가 없거나 형식이 맞지 않아도 대시보드는 기존 미러 데이터를 유지하고 상태 메시지만 보여줘요.`})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`Matrix 보기`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Top Priority`}),(0,X.jsx)(`td`,{children:`지금 먼저 처리할 3개를 따로 고정`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Important`}),(0,X.jsx)(`td`,{children:`중요하지만 급하지 않은 장기 작업`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Waiting`}),(0,X.jsx)(`td`,{children:`다른 사람, 직원, 외부 검증을 기다리는 작업`})]})]})})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`Reminders는 실험 기능이라 개발 모드 또는 실험 플래그가 켜진 빌드에서만 보여요.`})]}),Sr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`대시보드 외형과 동작 옵션을 조정하는 곳이에요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsx)(`li`,{children:`사이드바 폭, 워드랩, 테마 같은 표시 옵션을 바꾸실 수 있어요.`}),(0,X.jsxs)(`li`,{children:[`인스턴스 자체 설정이 아니라 `,(0,X.jsx)(`strong`,{children:`이 대시보드 UI의 환경설정`}),`이에요.`]}),(0,X.jsx)(`li`,{children:`변경 사항은 즉시 저장돼요.`})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`설정 범위`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Display`}),(0,X.jsx)(`td`,{children:`목록, 언어, 단축키 같은 dashboard UI 선호도`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Activity`}),(0,X.jsx)(`td`,{children:`최근 작업 제목이 어떤 인스턴스에서 준비됐는지 확인`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Instance settings`}),(0,X.jsx)(`td`,{children:`개별 인스턴스 동작은 Instances workspace에서 수정`})]})]})})]}),(0,X.jsxs)(`p`,{className:`help-tip`,children:[`인스턴스 동작을 바꾸시려면 여기가 아니라 `,(0,X.jsx)(`strong`,{children:`Instances → 해당 인스턴스 → Settings 탭`}),`으로 가세요.`]})]}),Cr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`반복 작업을 줄이는 Manager 전역 단축키예요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:`?`}),`는 이 도움말을 열어요. 입력창, 노트 에디터, WYSIWYG 편집 중에는 글자 입력을 방해하지 않아요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:ye(Se.focusInstances)}),`는 Instances workspace로 이동해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:ye(Se.focusActiveSession)}),`는 선택된 인스턴스의 Preview 탭으로 이동해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:ye(Se.focusNotes)}),`는 Notes workspace로 이동해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:ye(Se.previousInstance)}),` / `,(0,X.jsx)(`kbd`,{children:ye(Se.nextInstance)}),`는 현재 필터된 인스턴스 목록에서 이전/다음 행을 선택해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:`Alt+1`}),` … `,(0,X.jsx)(`kbd`,{children:`Alt+9`}),`는 렌더된 사이드바 행으로 점프하고, Alt를 200ms 누르면 행 오른쪽에 점프 힌트가 떠요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:`⌘/Ctrl + S`}),`는 Notes와 Settings처럼 저장 가능한 화면에서 현재 편집 내용을 저장해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:`⌘/Ctrl + E`}),`는 Notes 편집 모드를 순환해요.`]}),(0,X.jsx)(`li`,{children:`Manager 단축키는 Dashboard settings에서 켜고 끄거나 keymap을 바꿀 수 있어요.`}),(0,X.jsx)(`li`,{children:`Preview 탭을 보는 동안 새 activity는 읽음으로 처리되고, 다른 탭에 있을 때는 Activity Dock에 쌓여요.`})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`충돌이 날 때`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`입력 중`}),(0,X.jsx)(`td`,{children:`글자 입력을 우선하고 전역 shortcut은 실행하지 않음`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`브라우저 충돌`}),(0,X.jsx)(`td`,{children:`Dashboard settings에서 keymap을 바꾸는 것이 안전함`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`도움말`}),(0,X.jsxs)(`td`,{children:[(0,X.jsx)(`kbd`,{children:`?`}),`는 현재 workspace 도움말과 shortcut 도움말의 진입점`]})]})]})})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`단축키는 브라우저 기본 단축키와 에디터 입력을 우선합니다.`})]}),wr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`jaw는 Boss가 직접 처리할지, Employee에게 보낼지 상황에 따라 나눠요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Boss`}),`는 현재 대화의 주 작업자예요. 단일 파일 수정, 상태 확인, GitHub 정리는 보통 Boss가 직접 처리해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Employee`}),`는 `,(0,X.jsx)(`code`,{children:`cli-jaw dispatch`}),`로 보내는 독립 작업자예요. Backend, Frontend, Docs 같은 역할별 검증에 씁니다.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`PABCD`}),`에서는 A phase가 plan audit, B phase가 read-only verification 중심이에요. 구현은 Boss가 직접 합니다.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`$computer-use`}),` 요청은 desktop-control 규칙을 따라 real desktop 또는 browser automation 경로로 라우팅돼요.`]})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`직원이 다른 repo로 착각하지 않도록 dispatch task에는 현재 repo 절대경로를 함께 넣는 게 원칙이에요.`})]}),Tr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`Process 상태는 인스턴스 실행과 Manager가 관리하는 preview/runtime 상태를 구분해서 봐야 해요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`online`}),`은 인스턴스 health check가 통과한 상태예요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`offline / timeout / error`}),`는 프로세스가 없거나, 응답이 늦거나, health check가 실패한 상태예요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`managed`}),`는 Manager가 띄우거나 복구 대상으로 추적하는 서버예요.`]}),(0,X.jsx)(`li`,{children:`탭 전환 후 Preview가 다시 붙을 수 있지만, 인스턴스의 실제 실행 여부는 health/status 쪽을 기준으로 보세요.`})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`Process UI가 비어 보이면 먼저 Refresh로 registry와 health 상태를 다시 읽어보세요.`})]}),Er=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`실행 상태를 바꾸는 버튼은 현재 선택한 인스턴스나 Manager-managed 프로세스에 영향을 줘요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Stop`}),`은 대상 인스턴스를 중지해요. service-owned 인스턴스는 persistent service 제거까지 포함될 수 있어요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Restart`}),`는 새 실행으로 바뀌므로 uptime과 elapsed time 판단 기준이 다시 시작돼요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Stop all managed`}),`는 Manager가 추적 중인 서버들을 한 번에 중지해요. 외부에서 직접 띄운 프로세스는 대상으로 삼지 않아요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Adopt/recover`}),`는 남아 있는 managed process 기록을 다시 연결하려는 복구 작업이에요.`]})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`위험 작업은 가능한 한 확인창을 거치며, 진행 후 상태가 애매하면 Refresh로 실제 health를 확인하세요.`})]}),Dr={instances:{title:`Instances`,subtitle:`인스턴스 운영`,body:_r},board:{title:`Board`,subtitle:`Cross-instance Kanban`,body:vr},schedule:{title:`Schedule`,subtitle:`시간 기반 작업`,body:yr},reminders:{title:`Reminders`,subtitle:`Jaw Reminders mirror`,body:xr},notes:{title:`Notes`,subtitle:`마크다운 노트`,body:br},settings:{title:`Settings`,subtitle:`대시보드 설정`,body:Sr},shortcuts:{title:`Shortcuts`,subtitle:`전역 키보드 도움말`,body:Cr},routing:{title:`Routing`,subtitle:`Boss / Employee 작업 흐름`,body:wr},processLifecycle:{title:`Process lifecycle`,subtitle:`인스턴스와 managed process 상태`,body:Tr},dangerousActions:{title:`Dangerous actions`,subtitle:`중지·재시작·복구 작업 영향`,body:Er}};function Or({open:e,topic:t,onClose:n}){let r=(0,Y.useRef)(null);if((0,Y.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,t),r.current?.focus(),()=>document.removeEventListener(`keydown`,t)},[e,n]),!e)return null;let i=Dr[t];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`help-drawer-overlay`,onClick:n,"aria-hidden":`true`}),(0,X.jsxs)(`aside`,{className:`help-drawer`,role:`dialog`,"aria-modal":`true`,"aria-label":`${i.title} help`,children:[(0,X.jsxs)(`header`,{className:`help-drawer-header`,children:[(0,X.jsxs)(`div`,{className:`help-drawer-title`,children:[(0,X.jsx)(`span`,{className:`help-drawer-eyebrow`,children:`현재 모드`}),(0,X.jsx)(`h3`,{children:i.title}),(0,X.jsx)(`span`,{className:`help-drawer-subtitle`,children:i.subtitle})]}),(0,X.jsx)(`button`,{ref:r,type:`button`,className:`help-drawer-close`,onClick:n,"aria-label":`Close help`,children:`×`})]}),(0,X.jsx)(`div`,{className:`help-drawer-body`,children:i.body}),(0,X.jsx)(`footer`,{className:`help-drawer-footer`,children:(0,X.jsx)(`span`,{children:`사이드바 도움말은 현재 모드를 따르고, ? 키는 단축키 도움말을 열어요.`})})]})]})}function kr(e){switch(e.kind){case`scan-completed`:return{at:e.at,source:`scan`,message:`range ${e.from}-${e.to}, ${e.reachable} reachable`};case`scan-failed`:return{at:e.at,source:`error`,message:e.reason};case`lifecycle-result`:return{at:e.at,source:e.action,message:`:${e.port} ${e.status}`};case`health-changed`:return{at:e.at,source:`health`,message:`:${e.port} ${e.from} → ${e.to}`};case`instance-message`:{let t=e.title?.trim();return{at:e.at,source:`:${e.port}`,message:`${e.role}: ${t||`message #${e.messageId}`}`}}case`version-mismatch`:return{at:e.at,source:`version`,message:`:${e.port} ${e.expected||`?`} → ${e.seen}`};case`port-collision`:return{at:e.at,source:`collision`,message:`:${e.port} pids ${e.pids.join(`, `)}`};default:return{at:new Date().toISOString(),source:`event`,message:`unknown event`}}}var Ar={now:`Now`,earlier:`Earlier today`,yesterday:`Yesterday`,older:`Older`},jr=[`now`,`earlier`,`yesterday`,`older`],Mr=3e5;function Nr(e,t){return typeof e==`string`?{at:t,message:e}:`kind`in e?kr(e):e}function Pr(e,t){let n=Date.parse(e);if(Number.isNaN(n))return`older`;if(t.getTime()-n<=Mr)return`now`;let r=new Date(t);if(r.setHours(0,0,0,0),n>=r.getTime())return`earlier`;let i=new Date(r);return i.setDate(i.getDate()-1),n>=i.getTime()?`yesterday`:`older`}function Fr(e,t){let n=new Date(e);return Number.isNaN(n.getTime())?`—`:t===`now`||t===`earlier`?n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):t===`yesterday`?`Yesterday ${n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`:n.toLocaleDateString([],{month:`short`,day:`numeric`})}function Ir(e){let t=(0,Y.useMemo)(()=>{let t=new Date,n=t.toISOString(),r={now:[],earlier:[],yesterday:[],older:[]};for(let i of e.entries){let e=Nr(i,n),a=Pr(e.at,t);r[a].push({...e,_bucket:a})}return r},[e.entries]);return e.entries.length===0?(0,X.jsx)(`div`,{className:`activity-list activity-list-empty`,role:`status`,children:(0,X.jsx)(`p`,{children:e.emptyMessage||`Activity will appear here as scans, lifecycle changes, and registry updates happen.`})}):(0,X.jsx)(`div`,{className:`activity-list`,role:`list`,"aria-label":`Recent activity grouped by time`,children:jr.map(e=>{let n=t[e];return n.length===0?null:(0,X.jsxs)(`section`,{className:`activity-group`,"aria-label":Ar[e],children:[(0,X.jsx)(`header`,{className:`activity-group-header`,children:Ar[e]}),n.map((t,n)=>(0,X.jsxs)(`article`,{className:`activity-entry`,role:`listitem`,children:[(0,X.jsx)(`time`,{className:`activity-entry-time`,dateTime:t.at,children:Fr(t.at,t._bucket)}),t.source&&(0,X.jsx)(`span`,{className:`activity-entry-source`,children:t.source}),(0,X.jsx)(`p`,{className:`activity-entry-message`,children:t.message})]},`${e}-${n}`))]},e)})})}var Lr=88,Rr=320;function zr(e){return Math.min(Rr,Math.max(Lr,Math.round(e)))}function Br(e){let t=(0,Y.useRef)(null),{onHeightChange:n}=e,r=Vr(e);(0,Y.useEffect)(()=>{function e(e){let r=t.current;r&&n(zr(r.startHeight+r.startY-e.clientY))}function r(){t.current=null,document.body.classList.remove(`is-resizing-activity`)}return document.addEventListener(`pointermove`,e),document.addEventListener(`pointerup`,r),()=>{document.removeEventListener(`pointermove`,e),document.removeEventListener(`pointerup`,r),document.body.classList.remove(`is-resizing-activity`)}},[n]);function i(n){e.collapsed||(n.preventDefault(),t.current={startY:n.clientY,startHeight:e.height},document.body.classList.add(`is-resizing-activity`))}return(0,X.jsxs)(`aside`,{className:`activity-dock ${e.collapsed?`is-collapsed`:``}`,"aria-label":`Activity dock`,children:[(0,X.jsx)(`button`,{className:`activity-resize-handle`,type:`button`,"aria-label":`Resize activity dock`,title:`Resize activity dock`,onPointerDown:i,disabled:e.collapsed}),(0,X.jsxs)(`div`,{className:`activity-header`,children:[(0,X.jsx)(`span`,{children:`Activity`}),(0,X.jsx)(`button`,{type:`button`,onClick:e.onToggle,children:e.collapsed?`Expand`:`Collapse`})]}),!e.collapsed&&(0,X.jsx)(Ir,{entries:r})]})}function Vr(e){return(0,Y.useMemo)(()=>{let t=[];if(e.events&&e.events.length>0)for(let n of e.events)t.push(n);let n=new Date().toISOString();return e.error&&t.push({at:n,source:`error`,message:e.error}),e.registryMessage&&t.push({at:n,source:`registry`,message:e.registryMessage}),e.lifecycleMessage&&t.push({at:n,source:`lifecycle`,message:e.lifecycleMessage}),t.length===0&&t.push({at:n,source:`scan`,message:e.loading?`scanning local ports`:`no recent activity`}),t},[e.events,e.loading,e.error,e.registryMessage,e.lifecycleMessage])}function Hr(e){let{children:t,onClose:n,open:r}=e,i=(0,Y.useRef)(null),a=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(r)return a.current=document.activeElement,i.current?.focus(),()=>a.current?.focus()},[r]),(0,Y.useEffect)(()=>{if(!r)return;function e(e){e.key===`Escape`&&n()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n,r]),r?(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:n,children:(0,X.jsxs)(`aside`,{className:`instance-drawer`,role:`dialog`,"aria-modal":`true`,"aria-label":`Instance drawer`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`drawer-header`,children:[(0,X.jsx)(`span`,{children:`Instances`}),(0,X.jsx)(`button`,{ref:i,type:`button`,onClick:n,children:`Close`})]}),(0,X.jsxs)(`div`,{className:`drawer-body`,children:[e.profileFilters&&(0,X.jsx)(`div`,{className:`drawer-profile-filters`,children:e.profileFilters}),t]})]})}):null}function Ur(e){return(0,Y.useEffect)(()=>{let e=Jt({delayMs:200,onVisibilityChange:$t}),t=t=>{e.sync(en(t))},n=t=>{e.sync(en(t))};return window.addEventListener(`keydown`,t),window.addEventListener(`keyup`,n),()=>{window.removeEventListener(`keydown`,t),window.removeEventListener(`keyup`,n),e.dispose(),$t(!1)}},[]),e.collapsed?(0,X.jsx)(`div`,{className:`instance-navigator is-collapsed`,children:e.children}):(0,X.jsxs)(`section`,{className:`instance-navigator`,"aria-label":`Instance navigator`,children:[(0,X.jsxs)(`header`,{className:`instance-navigator-header`,children:[(0,X.jsx)(`strong`,{children:`Instances`}),e.hiddenCount>0?(0,X.jsxs)(`span`,{children:[e.hiddenCount,` hidden`]}):null,(0,X.jsxs)(`label`,{className:`instance-navigator-search`,children:[(0,X.jsx)(`span`,{className:`visually-hidden`,children:`Search instances`}),(0,X.jsx)(`input`,{id:`manager-sidebar-search`,value:e.query,placeholder:`Search instances`,"aria-label":`Search instances`,onChange:t=>e.onQueryChange(t.currentTarget.value),onKeyDown:t=>{t.nativeEvent.isComposing||t.keyCode===229||t.key===`Escape`&&(t.preventDefault(),e.onQueryChange(``))}})]})]}),(0,X.jsx)(`div`,{className:`instance-navigator-scroll`,onKeyDown:t=>nn(t.nativeEvent,t.currentTarget,e.onSelectPort),children:e.children})]})}function Wr(e){return(0,X.jsxs)(`div`,{className:`mobile-nav-actions`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:e.onOpenInstances,children:`Instances`}),(0,X.jsx)(`button`,{type:`button`,className:e.activeTab===`preview`?`is-active`:``,onClick:()=>e.onSelectTab(`preview`),children:`Preview`}),(0,X.jsx)(`button`,{type:`button`,onClick:e.onToggleActivity,children:`Activity`}),(0,X.jsx)(`button`,{type:`button`,className:e.activeTab===`settings`?`is-active`:``,onClick:()=>e.onSelectTab(`settings`),children:`More`})]})}function Gr({direction:e}){return(0,X.jsx)(`svg`,{className:`rail-collapse-chevron`,viewBox:`0 0 16 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`polyline`,{points:e===`left`?`11 4 5 10 11 16`:`5 4 11 10 5 16`})})}function Kr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`4`,width:`14`,height:`10`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M8 17h4M10 14v3`})]})}function qr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M6 3h6l3 3v11H6z`}),(0,X.jsx)(`path`,{d:`M12 3v4h3M8 10h5M8 13h5`})]})}function Jr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`4`,width:`14`,height:`12`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M7 4v12M13 4v12`})]})}function Yr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`5`,width:`14`,height:`12`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M3 9h14M7 3v4M13 3v4`})]})}function Xr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M5 4h10v13H5z`}),(0,X.jsx)(`path`,{d:`M8 2v4M12 2v4M8 10h4M8 13h3`})]})}function Zr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}),(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}function Qr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`circle`,{cx:`10`,cy:`10`,r:`7`}),(0,X.jsx)(`path`,{d:`M7.6 7.6a2.4 2.4 0 0 1 4.8 0c0 1.4-1.6 1.7-2.2 2.5-.3.4-.3.8-.3 1.2`}),(0,X.jsx)(`circle`,{cx:`10`,cy:`14.2`,r:`0.6`,fill:`currentColor`,stroke:`none`})]})}function $r(e){let t=!e.collapsed,n=t?`Collapse navigation`:`Expand navigation`;return(0,X.jsxs)(`div`,{className:`sidebar-rail`,children:[(0,X.jsx)(`button`,{className:`rail-collapse-button`,type:`button`,onClick:e.onToggleSidebar,"aria-label":n,"aria-expanded":t,"aria-pressed":e.collapsed,"aria-controls":`manager-sidebar-list`,title:n,children:(0,X.jsx)(Gr,{direction:t?`left`:`right`})}),(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`instances`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`instances`),"aria-label":`Instances`,"aria-pressed":e.mode===`instances`,title:`Instances`,children:(0,X.jsx)(Kr,{})}),(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`board`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`board`),"aria-label":`Board`,"aria-pressed":e.mode===`board`,title:`Board`,children:(0,X.jsx)(Jr,{})}),e.scheduleWorkspaceEnabled?(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`schedule`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`schedule`),"aria-label":`Schedule`,"aria-pressed":e.mode===`schedule`,title:`Schedule`,children:(0,X.jsx)(Yr,{})}):null,e.remindersWorkspaceEnabled?(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`reminders`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`reminders`),"aria-label":`Reminders`,"aria-pressed":e.mode===`reminders`,title:`Reminders`,children:(0,X.jsx)(Xr,{})}):null,(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`notes`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`notes`),"aria-label":`Notes`,"aria-pressed":e.mode===`notes`,title:`Notes`,children:(0,X.jsx)(qr,{})}),(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`settings`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`settings`),"aria-label":`Dashboard settings`,"aria-pressed":e.mode===`settings`,title:`Dashboard settings`,children:(0,X.jsx)(Zr,{})}),(0,X.jsx)(`div`,{className:`rail-spacer`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{className:`rail-button rail-help-button${e.helpOpen?` is-active`:``}`,type:`button`,onClick:e.onToggleHelp,"aria-label":`Help guide`,"aria-pressed":e.helpOpen,"aria-expanded":e.helpOpen,title:`Help (?)`,children:(0,X.jsx)(Qr,{})}),(0,X.jsx)(`span`,{className:`rail-status-dot`,"aria-label":`${e.onlineCount} online instances`})]})}var ei=[`overview`,`preview`,`logs`];function ti(e){return e[0].toUpperCase()+e.slice(1)}function ni(e){return(0,X.jsxs)(`section`,{className:`workbench workbench-${e.mode}`,"aria-label":`Selected instance workbench`,children:[(0,X.jsxs)(`div`,{className:`workbench-header`,children:[e.header,(0,X.jsxs)(`div`,{className:`workbench-mode-bar`,children:[(0,X.jsx)(`div`,{className:`workbench-mode-tabs`,role:`tablist`,"aria-label":`Workbench modes`,onKeyDown:t=>{if(t.key!==`ArrowRight`&&t.key!==`ArrowLeft`)return;let n=ei[(ei.indexOf(e.mode)+(t.key===`ArrowRight`?1:ei.length-1))%ei.length];t.preventDefault(),e.onModeChange(n),t.currentTarget.querySelector(`[data-mode="${n}"]`)?.focus()},children:ei.map(t=>(0,X.jsx)(`button`,{type:`button`,role:`tab`,id:`workbench-tab-${t}`,"data-mode":t,"aria-selected":e.mode===t,"aria-controls":`workbench-panel-${t}`,tabIndex:e.mode===t?0:-1,className:e.mode===t?`is-active`:``,onClick:()=>e.onModeChange(t),children:ti(t)},t))}),e.modeActions]})]}),(0,X.jsxs)(`div`,{className:`workbench-body`,children:[e.mode===`overview`&&(0,X.jsx)(`div`,{id:`workbench-panel-overview`,role:`tabpanel`,"aria-labelledby":`workbench-tab-overview`,className:`workbench-panel workbench-panel-overview`,children:e.overview},`overview`),(0,X.jsx)(`div`,{id:`workbench-panel-preview`,role:`tabpanel`,"aria-labelledby":`workbench-tab-preview`,className:`workbench-panel workbench-panel-preview`,hidden:e.mode!==`preview`,"aria-hidden":e.mode!==`preview`,"data-preview-host":`persistent`,children:e.preview},`preview`),e.mode===`logs`&&(0,X.jsx)(`div`,{id:`workbench-panel-logs`,role:`tabpanel`,"aria-labelledby":`workbench-tab-logs`,className:`workbench-panel workbench-panel-logs`,children:e.logs},`logs`)]})]})}function ri(e){let t=(0,Y.useRef)(!1),n=(0,Y.useRef)(0),r=(0,Y.useRef)(0),i=(0,Y.useRef)(!1),a=(0,Y.useRef)(e.onDelta),o=(0,Y.useRef)(e.onEnd),[s,c]=(0,Y.useState)(!1),{direction:l}=e;(0,Y.useEffect)(()=>{a.current=e.onDelta,o.current=e.onEnd},[e.onDelta,e.onEnd]);let u=(0,Y.useCallback)((e,o)=>{if(!t.current)return;let s=l===`horizontal`?e:o;if(!i.current){if(Math.abs(s-r.current)<=2)return;i.current=!0}let c=s-n.current;n.current=s,c!==0&&a.current(c)},[l]),d=(0,Y.useCallback)(e=>{t.current&&(e.preventDefault(),u(e.clientX,e.clientY))},[u]),f=(0,Y.useCallback)(e=>{t.current&&(e.preventDefault(),u(e.clientX,e.clientY))},[u]),p=(0,Y.useCallback)(()=>{t.current&&(t.current=!1,c(!1),document.body.classList.remove(`is-resizing-horizontal`,`is-resizing-vertical`),o.current?.())},[]);(0,Y.useEffect)(()=>{let e={capture:!0};return document.addEventListener(`pointermove`,d,e),document.addEventListener(`pointerup`,p,e),document.addEventListener(`pointercancel`,p,e),document.addEventListener(`mousemove`,f,e),document.addEventListener(`mouseup`,p,e),window.addEventListener(`pointermove`,d,e),window.addEventListener(`pointerup`,p,e),window.addEventListener(`pointercancel`,p,e),window.addEventListener(`mousemove`,f,e),window.addEventListener(`mouseup`,p,e),window.addEventListener(`blur`,p),()=>{document.removeEventListener(`pointermove`,d,e),document.removeEventListener(`pointerup`,p,e),document.removeEventListener(`pointercancel`,p,e),document.removeEventListener(`mousemove`,f,e),document.removeEventListener(`mouseup`,p,e),window.removeEventListener(`pointermove`,d,e),window.removeEventListener(`pointerup`,p,e),window.removeEventListener(`pointercancel`,p,e),window.removeEventListener(`mousemove`,f,e),window.removeEventListener(`mouseup`,p,e),window.removeEventListener(`blur`,p),document.body.classList.remove(`is-resizing-horizontal`,`is-resizing-vertical`)}},[f,d,p]);function m(e){e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),g(e.clientX,e.clientY)}function h(e){e.preventDefault(),e.stopPropagation(),g(e.clientX,e.clientY)}function g(e,a){t.current=!0,i.current=!1,c(!0),r.current=l===`horizontal`?e:a,n.current=r.current,document.body.classList.add(l===`horizontal`?`is-resizing-horizontal`:`is-resizing-vertical`)}function _(e){e.preventDefault(),u(e.clientX,e.clientY)}function v(e){e.preventDefault(),p()}function y(e){e.preventDefault(),u(e.clientX,e.clientY)}function b(e){e.preventDefault(),p()}function x(e){if(e.nativeEvent.isComposing||e.keyCode===229||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=l===`horizontal`?`ArrowLeft`:`ArrowUp`,n=l===`horizontal`?`ArrowRight`:`ArrowDown`;(e.key===t||e.key===n)&&(e.preventDefault(),a.current(e.key===t?-10:10),o.current?.())}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{role:`separator`,tabIndex:0,className:`panel-resizer panel-resizer-${l} ${e.className??``}`,"aria-label":e.ariaLabel??`Resize ${l===`horizontal`?`width`:`height`}`,"aria-valuenow":e.ariaValueNow,"aria-valuetext":e.ariaValueNow===void 0?void 0:`${e.ariaValueNow}px`,"aria-orientation":l===`horizontal`?`vertical`:`horizontal`,onPointerDown:m,onMouseDown:h,onLostPointerCapture:p,onKeyDown:x,onDoubleClick:e.onDoubleClick}),s&&(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`panel-resize-overlay panel-resize-overlay-${l}`,onPointerMove:_,onPointerUp:v,onPointerCancel:v,onMouseMove:y,onMouseUp:b})]})}function ii(e){return(0,X.jsx)(ri,{direction:`horizontal`,onDelta:e.onDelta,onEnd:e.onEnd,onDoubleClick:e.onDoubleClick,className:`sidebar-resize-handle`,ariaLabel:`Resize sidebar`,ariaValueNow:e.width})}var ai=`jaw.sidebarWidth`;function oi(e){let t=640+(e.rightPanelOpen?Math.max(0,e.rightPanelWidth):0);return Math.max(220,Math.floor(e.viewportWidth)-t)}function si(e,t){let n=oi(t);return Math.min(n,Math.max(220,Number.isFinite(e)?Math.round(e):300))}function ci(){try{if(typeof localStorage>`u`)return null;let e=localStorage.getItem(ai);if(e==null||e.trim()===``)return null;let t=Number(e);return Number.isFinite(t)?t:null}catch{return null}}function li(e){try{localStorage.setItem(ai,String(e))}catch{}}function ui(){try{localStorage.removeItem(ai)}catch{}}function di(e){return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)}function fi(){return typeof window>`u`?1440:window.innerWidth}function pi(e){let t=(0,Y.useSyncExternalStore)(di,fi,()=>1440),n={viewportWidth:t,rightPanelOpen:e.rightPanelOpen,rightPanelWidth:e.rightPanelWidth},[r,i]=(0,Y.useState)(()=>Math.max(220,ci()??300)),a=(0,Y.useRef)(r);return{width:si(r,n),addDelta:(0,Y.useCallback)(e=>{let t=si(si(a.current,n)+e,n);a.current=t,i(t)},[n.viewportWidth,n.rightPanelOpen,n.rightPanelWidth]),persist:(0,Y.useCallback)(()=>{li(a.current)},[]),reset:(0,Y.useCallback)(()=>{ui(),a.current=300,i(300)},[]),viewportWidth:t}}var mi=260,hi=200;function gi(){return typeof window>`u`?1440:window.innerWidth}function _i(){let[e,t]=(0,Y.useState)(gi);return(0,Y.useEffect)(()=>{let e=()=>t(gi());return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}function vi(e,t,n){let r=typeof e==`number`&&Number.isFinite(e)?Math.round(e):480,i=Math.max(mi,n-t-hi);return Math.max(mi,Math.min(r,i))}function yi(e){let t=_i(),n=e.sidebarCollapsed?44:e.sidebarWidth,r=e.rightPanelOpen?vi(e.rightPanelWidth,n,t):0,i={"--activity-dock-height":`${e.inspectorHeight}px`,"--sidebar-width":e.sidebarCollapsed?`44px`:`${e.sidebarWidth}px`,"--right-panel-width":e.rightPanelOpen?`${r}px`:e.sidePanel?void 0:`0px`,"--bottom-panel-height":e.bottomPanelOpen?`${e.bottomPanelHeight??0}px`:void 0},a=[`manager-workspace`,e.sidebarCollapsed&&`is-sidebar-collapsed`,e.inspectorCollapsed&&`is-inspector-collapsed`,e.rightPanelOpen&&`is-right-panel-open`,!e.rightPanelOpen&&!e.sidePanel&&`is-right-panel-closed`,e.bottomPanelOpen&&`is-bottom-panel-open`,!e.bottomPanelOpen&&`is-bottom-panel-closed`,e.sidePanel&&`is-side-panel-open`,e.drawerOpen&&`is-drawer-open`].filter(Boolean).join(` `);return(0,X.jsxs)(`div`,{className:a,style:i,children:[e.drawerOpen&&(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:e.onCloseDrawer}),(0,X.jsx)(`aside`,{className:`manager-sidebar`,"aria-label":e.navigatorLabel??`Jaw instances`,children:e.navigator}),!e.sidebarCollapsed&&t>=1024&&(0,X.jsx)(ii,{width:e.sidebarWidth,onDelta:e.onSidebarWidthDelta,onEnd:e.onSidebarWidthEnd,onDoubleClick:e.onSidebarWidthReset}),(0,X.jsx)(`section`,{className:`manager-detail`,"aria-label":`Manager workbench`,children:e.workbench}),(0,X.jsx)(`section`,{className:`manager-activity`,"aria-label":`Manager inspector`,children:e.inspector}),e.sidePanel&&(0,X.jsx)(`aside`,{className:`manager-ceo-panel`,"aria-label":`Jaw CEO console`,children:e.sidePanel}),e.rightPanelContent,e.bottomPanelContent,(0,X.jsx)(`nav`,{className:`manager-mobile-nav`,"aria-label":`Mobile dashboard navigation`,children:e.mobileNav}),e.drawer]})}function bi(e){let t=N[e.kind],n=e.sourceLabel??e.specificName;return{visibleLabel:e.specificName,title:`${t}: ${n}`,ariaLabel:`${t} tab, ${n}`}}function xi(e){return e<=2?`comfortable`:e<=4?`compact`:`mini`}var Si=class extends Y.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[panel-error] ${this.props.label}:`,e,t.componentStack)}handleRetry=()=>{this.setState({error:null})};render(){return this.state.error?(0,X.jsxs)(`div`,{className:`panel-error-boundary`,role:`alert`,children:[(0,X.jsxs)(`div`,{className:`panel-error-title`,children:[this.props.label,` panel crashed`]}),(0,X.jsx)(`pre`,{className:`panel-error-message`,children:this.state.error.message}),(0,X.jsx)(`button`,{type:`button`,className:`panel-error-retry`,onClick:this.handleRetry,children:`Retry`})]}):this.props.children}};function Ci(){return(0,X.jsx)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`path`,{d:`M6 6l8 8M14 6l-8 8`})})}function wi(){return(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`11`,height:`11`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`})})}function Ti(){return(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`path`,{d:`M8 3v10M3 8h10`})})}function Ei(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M2 4.5h4.5L8 6h6v6.5a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4.5Z`}),(0,X.jsx)(`path`,{d:`M2 4.5V3.5a1 1 0 0 1 1-1h2.5L7 4h5a1 1 0 0 1 1 1v1`})]})}function Di(){return(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`path`,{d:`M4 3v10M12 3v10M4 8h8`})})}function Oi(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`2`,y:`2`,width:`12`,height:`12`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M2 5.5h12`})]})}function ki(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M9.5 3.5l3 3L6 13H3v-3Z`}),(0,X.jsx)(`path`,{d:`M8 5l3 3`}),(0,X.jsx)(`path`,{d:`M12.5 6.5l1-1a1.4 1.4 0 0 0 0-2l-1-1a1.4 1.4 0 0 0-2 0l-1 1`})]})}function Ai(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M3 6.5h5l1.4 1.8H17v6.2A1.5 1.5 0 0 1 15.5 16h-11A1.5 1.5 0 0 1 3 14.5v-8Z`}),(0,X.jsx)(`path`,{d:`M3 6.5V5a1.5 1.5 0 0 1 1.5-1.5h3L9 5.5h6.5A1.5 1.5 0 0 1 17 7v1.3`})]})}function ji(){return(0,X.jsx)(`span`,{className:`right-breadcrumb-sep`,"aria-hidden":`true`,children:`>`})}var Mi={files:Ei,diff:Di,browser:Oi,design:ki};function Ni(e){if(!e)return[];let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean);return t.length>0&&t[0]===``&&t.shift(),t}var Pi=[`files`,`diff`,`browser`,`design`];function Fi(e){let{state:t,dispatch:n,effectiveRightOpen:r,activeRightTabKind:i}=pe(),a=t.rightPanel,o=(0,Y.useRef)(a.width);(0,Y.useEffect)(()=>{o.current=a.width},[a.width]);let s=(0,Y.useCallback)(e=>{let t=o.current-e;o.current=t,n({type:`SET_RIGHT_WIDTH`,width:t})},[n]),c=(0,Y.useCallback)(()=>{},[]),[l,u]=(0,Y.useState)(!1),d=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(!l)return;function e(e){d.current&&!d.current.contains(e.target)&&u(!1)}return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)},[l]);let f=a.tabs.openTabs,p=a.tabs.activeTabId,m=f.find(e=>e.id===p)??null,h=a.fileFolderLayout,g=m?.kind===`files`?m.files?.activeFilePath??null:null,_=xi(f.length),v=f.some(e=>e.kind===`diff`),y=Pi.filter(e=>!(e===`diff`&&v)),b=h.mode!==`file-only`,x=b?`Hide folder pane`:`Show folder pane`,S=(0,Y.useCallback)(()=>{h.mode===`file-only`?n({type:`RESTORE_FILE_FOLDER_SPLIT`}):n({type:`SET_FILE_FOLDER_VIEW_MODE`,mode:`file-only`})},[n,h.mode]),C=(0,Y.useCallback)(()=>{let e=M()?.folder;(async()=>{if(e?.pickFile){let t=await e.pickFile();t?.ok&&t.path&&n({type:`OPEN_FILE_IN_FILES_TAB`,path:t.path});return}e?.pickFolder&&await e.pickFolder()})()},[n]),w=(0,Y.useCallback)(e=>{n({type:`FOCUS_OR_CREATE_FIRST_RIGHT_SIDEBAR_TAB`,kind:e})},[n]),T=(0,Y.useCallback)(e=>{n({type:`CREATE_RIGHT_SIDEBAR_TAB`,kind:e}),u(!1)},[n]),E=(0,Y.useCallback)((e,t)=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n({type:`ACTIVATE_RIGHT_SIDEBAR_TAB`,tabId:t}))},[n]),D=Ni(g),O=l?(0,X.jsx)(`div`,{className:`right-sidebar-plus-menu`,role:`menu`,children:y.map(e=>(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`right-sidebar-plus-menu-item`,onClick:()=>T(e),children:[Mi[e](),(0,X.jsx)(`span`,{children:N[e]})]},e))}):null;return!r||f.length===0?a.open&&f.length===0?(0,X.jsxs)(`aside`,{className:`right-panel`,"aria-label":`Right sidebar`,children:[(0,X.jsx)(ri,{direction:`horizontal`,onDelta:s,onEnd:c}),(0,X.jsxs)(`div`,{className:`right-panel-shell`,children:[(0,X.jsx)(`div`,{className:`right-panel-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`right-panel-close`,"aria-label":`Close right sidebar`,title:`Close`,onClick:()=>n({type:`SET_RIGHT_OPEN`,open:!1}),children:(0,X.jsx)(Ci,{})})}),(0,X.jsx)(`div`,{className:`right-panel-body is-single-panel`,children:(0,X.jsx)(`div`,{className:`right-sidebar-empty-state`,"aria-label":`No open tabs`,children:(0,X.jsxs)(`div`,{className:`right-sidebar-empty-plus-wrap`,ref:d,children:[(0,X.jsx)(`button`,{type:`button`,className:`right-sidebar-empty-plus`,"aria-label":`Open panel tab`,"aria-haspopup":`menu`,"aria-expanded":l,title:`Open panel tab`,onClick:()=>u(e=>!e),children:(0,X.jsx)(Ti,{})}),O]})})})]})]}):null:(0,X.jsxs)(`aside`,{className:`right-panel`,"aria-label":`Right sidebar`,children:[(0,X.jsx)(ri,{direction:`horizontal`,onDelta:s,onEnd:c}),(0,X.jsxs)(`div`,{className:`right-panel-shell`,children:[(0,X.jsxs)(`div`,{className:`right-launcher-row`,"aria-label":`Panel launchers`,children:[(0,X.jsx)(`div`,{className:`right-launcher-group`,children:Pi.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`right-launcher-button${i===e?` is-active`:``}`,"aria-label":N[e],"aria-pressed":i===e,title:N[e],onClick:()=>w(e),children:Mi[e]()},e))}),(0,X.jsx)(`button`,{type:`button`,className:`right-panel-close`,"aria-label":`Close right sidebar`,title:`Close`,onClick:()=>n({type:`SET_RIGHT_OPEN`,open:!1}),children:(0,X.jsx)(Ci,{})})]}),(0,X.jsxs)(`div`,{className:`right-sidebar-tab-strip`,"data-density":_,children:[(0,X.jsx)(`div`,{className:`right-sidebar-tabs`,role:`tablist`,"aria-label":`Open panel tabs`,children:f.map(e=>{let t=e.id===p,r=Mi[e.kind],i=bi(e);return(0,X.jsxs)(`div`,{role:`tab`,tabIndex:0,className:`right-sidebar-tab${t?` is-active`:``}`,"aria-selected":t,"aria-label":i.ariaLabel,title:i.title,onClick:()=>n({type:`ACTIVATE_RIGHT_SIDEBAR_TAB`,tabId:e.id}),onKeyDown:t=>E(t,e.id),children:[(0,X.jsx)(r,{}),(0,X.jsx)(`span`,{className:`right-sidebar-tab-label`,children:i.visibleLabel}),(0,X.jsx)(`button`,{type:`button`,className:`right-sidebar-tab-close`,"aria-label":`Close ${i.ariaLabel}`,title:`Close ${i.visibleLabel}`,onClick:t=>{t.stopPropagation(),n({type:`CLOSE_RIGHT_SIDEBAR_TAB`,tabId:e.id})},children:(0,X.jsx)(wi,{})})]},e.id)})}),(0,X.jsxs)(`div`,{className:`right-sidebar-plus-wrap`,ref:d,children:[(0,X.jsx)(`button`,{type:`button`,className:`right-sidebar-plus`,"aria-label":`Open panel tab`,"aria-haspopup":`menu`,"aria-expanded":l,title:`Open panel tab`,onClick:()=>u(e=>!e),children:(0,X.jsx)(Ti,{})}),O]})]}),i===`files`&&(0,X.jsx)(`div`,{className:`right-files-chrome`,"aria-label":`Files tab chrome`,children:(0,X.jsxs)(`div`,{className:`right-files-toolbar`,children:[(0,X.jsx)(`nav`,{className:`right-breadcrumb`,"aria-label":`File path breadcrumb`,children:D.map((e,t)=>{let n=t===D.length-1;return(0,X.jsxs)(`span`,{className:`right-breadcrumb-item`,children:[t>0&&(0,X.jsx)(ji,{}),(0,X.jsx)(`span`,{className:`right-breadcrumb-segment${n?` is-final`:``}`,title:e,children:e})]},t)})}),e.onLoadProjectFolder&&(0,X.jsx)(`button`,{type:`button`,className:`right-files-load-folder`,title:`Load project folder`,disabled:e.loadProjectFolderDisabled===!0,onClick:e.onLoadProjectFolder,children:`불러오기`}),(0,X.jsx)(`button`,{type:`button`,className:`right-files-open-file`,title:`Open file`,onClick:C,children:`Open file`}),(0,X.jsx)(`button`,{type:`button`,className:`right-files-folder-toggle`,"aria-pressed":b,title:x,onClick:S,children:(0,X.jsx)(Ai,{})})]})}),(0,X.jsx)(`div`,{className:`right-panel-body is-single-panel`,children:m&&(0,X.jsx)(`div`,{className:`right-sub-panel`,"aria-label":bi(m).ariaLabel,children:(0,X.jsx)(`div`,{className:`right-sub-content`,children:(0,X.jsx)(Si,{label:N[m.kind],children:e.renderPanel(m.kind,m)})})},m.id)})]})]})}var Ii={activity:`Activity`,terminal:`Terminal`,browser:`Browser`,logs:`Logs`};function Li(e){function t(t){let n=e.tabs,r=e.activeTab?n.indexOf(e.activeTab):-1;if(t.key===`ArrowRight`||t.key===`ArrowLeft`){t.preventDefault();let i=n[(r+(t.key===`ArrowRight`?1:-1)+n.length)%n.length];i&&e.onActivate(i)}else if(t.key===`Home`)t.preventDefault(),n[0]&&e.onActivate(n[0]);else if(t.key===`End`){t.preventDefault();let r=n[n.length-1];r&&e.onActivate(r)}}return(0,X.jsxs)(`div`,{className:`bottom-tab-bar`,role:`tablist`,onKeyDown:t,children:[e.tabs.map(t=>(0,X.jsxs)(`div`,{className:`bottom-tab-item ${t===e.activeTab?`is-active`:``}`,role:`presentation`,children:[(0,X.jsx)(`button`,{type:`button`,role:`tab`,className:`bottom-tab ${t===e.activeTab?`is-active`:``}`,"aria-selected":t===e.activeTab,tabIndex:t===e.activeTab?0:-1,onClick:()=>e.onActivate(t),children:(0,X.jsx)(`span`,{children:Ii[t]})}),(0,X.jsx)(`button`,{type:`button`,className:`bottom-tab-close`,"aria-label":`Close ${Ii[t]}`,title:`Close ${Ii[t]}`,onClick:()=>e.onClose(t),children:`×`})]},t)),(0,X.jsx)(`button`,{type:`button`,className:`bottom-collapse-button`,"aria-label":`Collapse panel`,onClick:e.onCollapse,children:`▼`})]})}var Ri=[`terminal`,`browser`];function zi(e){let{state:t,dispatch:n}=pe(),r=t.bottomPanel,i=(0,Y.useCallback)(e=>{n({type:`SET_BOTTOM_HEIGHT`,height:r.height-e})},[n,r.height]),a=(0,Y.useCallback)(()=>{n({type:`SET_BOTTOM_OPEN`,open:!1})},[n]),o=r.activeTab??r.tabs[0]??null,s=o!==null&&Ri.includes(o);return r.tabs.length===0?null:(0,X.jsxs)(`div`,{className:`bottom-panel ${s?`has-content-owned-chrome`:``}`,"aria-label":`Bottom panel`,"aria-hidden":!r.open,children:[(0,X.jsx)(ri,{direction:`vertical`,onDelta:i,ariaLabel:`Resize bottom panel height`,ariaValueNow:r.height}),!s&&(0,X.jsx)(Li,{tabs:r.tabs,activeTab:r.activeTab,onActivate:e=>n({type:`SET_BOTTOM_ACTIVE_TAB`,tab:e}),onClose:e=>n({type:`CLOSE_BOTTOM_TAB`,tab:e}),onCollapse:a}),(0,X.jsx)(`div`,{className:`bottom-panel-content`,children:o&&e.renderTab(o,{onCollapse:a,onCloseTab:()=>n({type:`CLOSE_BOTTOM_TAB`,tab:o}),ownsChrome:s})})]})}function Bi(e){let{state:t,dispatch:n}=pe(),r=t.rightPanel.fileFolderLayout,i=r.mode,a=r.splitRatio,o=(0,Y.useRef)(null),s=(0,Y.useCallback)(e=>{let r=o.current;if(!r)return;let i=r.offsetWidth;if(i<=0)return;let a=e/i,s=t.rightPanel.fileFolderLayout.splitRatio,c=Math.max(0,Math.min(1,s+a));n({type:`SET_FILE_FOLDER_SPLIT_RATIO`,ratio:c})},[n,t.rightPanel.fileFolderLayout.splitRatio]),c=(0,Y.useCallback)(()=>{},[]),l=i===`folder-only`?{display:`none`}:i===`file-only`?{flex:`1 1 100%`,minWidth:0}:{flex:`0 0 ${(a*100).toFixed(2)}%`,minWidth:0},u=i===`file-only`?{display:`none`}:i===`folder-only`?{flex:`1 1 100%`,minWidth:0}:{flex:`1 1 0%`,minWidth:0},d=i===`split`;return(0,X.jsxs)(`div`,{className:`file-folder-split-panel`,ref:o,"data-mode":i,children:[(0,X.jsx)(`div`,{className:`file-folder-split-file-pane`,style:l,children:e.filePane}),d&&(0,X.jsx)(ri,{direction:`horizontal`,onDelta:s,onEnd:c,className:`file-folder-split-resizer`}),(0,X.jsx)(`div`,{className:`file-folder-split-folder-pane`,style:u,children:e.folderPane})]})}function Vi(e){return e===`127.0.0.1`||e===`localhost`||e===`::1`||e===`[::1]`}function Hi(e=typeof navigator<`u`?navigator.userAgent:``){return/Safari/i.test(e)&&!/Chrome|Chromium|CriOS|Edg|OPR|Android/i.test(e)}function Ui(e){return e===`dark`||e===`light`}function Wi(e){return e&&typeof e==`object`?{theme:e.theme===`dark`||e.theme===`light`?e.theme:null,transport:e.transport===`legacy-path`||e.transport===`origin-port`?e.transport:null}:{theme:Ui(e)?e:null,transport:e===`proxy`?`legacy-path`:null}}function Gi(e,t){let n=t||(typeof window<`u`?window.location.href:``);if(!n||e.startsWith(`/`))return e;try{let t=new URL(e),r=new URL(n);return Vi(t.hostname)&&Vi(r.hostname)&&(t.hostname=r.hostname),t.toString()}catch{return e}}function Ki(e,t){if(!t)return e;let n=e.startsWith(`/`),r=new URL(e,`http://jaw.local`);return r.searchParams.set(`jawTheme`,t),n?`${r.pathname}${r.search}${r.hash}`:r.toString()}function qi(e,t,n){if(!e)return{canPreview:!1,src:null,reason:`Select an online instance to preview.`,transport:`none`,warning:null};if(!e.ok)return{canPreview:!1,src:null,reason:`Preview is only available for online instances.`,transport:`none`,warning:null};let r=t?.manager.proxy;if(!r?.enabled)return{canPreview:!1,src:null,reason:`Proxy preview is not available.`,transport:`none`,warning:null};if(e.port<r.allowedFrom||e.port>r.allowedTo)return{canPreview:!1,src:null,reason:`This port is outside the proxy allowlist.`,transport:`none`,warning:null};let i=r.preview?.instances[String(e.port)],{theme:a,transport:o}=Wi(n);if(o!==`legacy-path`&&r.preview?.enabled&&i?.status===`ready`&&i.url&&!Hi()){let e=new URL(Gi(i.url));return e.pathname=`${e.pathname.replace(/\/?$/,`/`)}0`,{canPreview:!0,src:Ki(e.toString(),a),reason:null,transport:`origin-port`,warning:`origin proxy ready`}}return{canPreview:!0,src:Ki(`${r.basePath||`/i`}/${e.port}/0`,a),reason:null,transport:`legacy-path`,warning:`legacy proxy fallback`}}var Ji=`allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads`;function Yi(e){return e.replace(/^\[|\]$/g,``).toLowerCase()}function Xi(e){let t=Yi(e);return t===`127.0.0.1`||t===`localhost`||t===`::1`}function Zi(e,t){if(e===t)return!0;try{let n=new URL(e),r=new URL(t);return n.protocol!==r.protocol||n.port!==r.port?!1:Xi(n.hostname)&&Xi(r.hostname)}catch{return!1}}function Qi(e,t,n){if(!e||e===`null`)return!1;let r=ta(t,n);return!!(r&&Zi(r,e))}function $i(e,t,n){return Qi(e.origin,t,n)}function ea(e,t,n,r){if(e&&t&&t!==`null`)try{e.postMessage({type:`jaw-preview-send-result`,requestId:n,...r},t)}catch(e){console.warn(`[manager-preview] send relay result skipped`,e)}}function ta(e,t){if(typeof window>`u`)return`http://localhost`;try{let e=t?.contentWindow?.location.origin;if(e&&e!==`null`)return e}catch{}let n=new URL(e,window.location.href).origin;return n===`null`?null:n}function na(e,t,n){let r=e?.contentWindow;if(!r)return;let i=ta(t,e);if(i&&i!==`null`)try{r.postMessage({type:`jaw-preview-theme-sync`,theme:n},i)}catch(e){console.warn(`[manager-preview] theme sync skipped`,e)}}function ra(e,t){let n=e?.contentWindow;if(!n)return;let r=ta(t,e);if(r&&r!==`null`)try{n.postMessage({type:`jaw-preview-stt-toggle`},r)}catch(e){console.warn(`[manager-preview] STT shortcut sync skipped`,e)}}function ia(e,t){let n=e?.contentWindow;if(!n)return;let r=ta(t,e);if(r&&r!==`null`)try{n.postMessage({type:`jaw-preview-settings-open`},r)}catch(e){console.warn(`[manager-preview] settings open request skipped`,e)}}function aa(e,t){let n=e?.contentWindow;if(!n)return;let r=ta(t,e);if(r&&r!==`null`)try{n.postMessage({type:`jaw-preview-visibility`,visible:!0},r)}catch(e){console.warn(`[manager-preview] visibility sync skipped`,e)}}function oa(e,t,n){let r=e?.contentWindow;if(!r)return;let i=ta(t,e);if(i&&i!==`null`)try{r.postMessage({type:`jaw-preview-capabilities`,docPanel:n},i)}catch(e){console.warn(`[manager-preview] capability sync skipped`,e)}}function sa(e,t,n){if(e&&t&&t!==`null`)try{e.postMessage({type:`jaw-preview-capabilities`,docPanel:n},t)}catch(e){console.warn(`[manager-preview] capability reply skipped`,e)}}function ca(e,t,n,r=800){let i=e?.contentWindow;if(!i)return Promise.resolve({ok:!1,error:`preview is unavailable`});let a=ta(t,e);if(!a||a===`null`)return Promise.resolve({ok:!1,error:`preview origin is unavailable`});let o=crypto.randomUUID();return new Promise(s=>{let c=!1,l=e=>{c||(c=!0,window.removeEventListener(`message`,u),window.clearTimeout(d),s(e))},u=n=>{if(n.source!==i||!Qi(n.origin,t,e))return;let r=n.data;r&&r.type===`jaw-preview-insert-text-result`&&r.requestId===o&&(r.ok===!0?l({ok:!0}):l({ok:!1,error:typeof r.error==`string`?r.error:`preview rejected insert`}))},d=window.setTimeout(()=>l({ok:!1,error:`preview insert timed out`}),r);window.addEventListener(`message`,u);try{i.postMessage({type:`jaw-preview-insert-text`,requestId:o,text:n},a)}catch(e){l({ok:!1,error:e.message})}})}function la(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||!!e.closest(`[contenteditable="true"], .cm-editor, .ProseMirror, [data-milkdown-root]`)}function ua(e){let t=(e.ctrlKey||e.metaKey)&&e.shiftKey&&e.code===`Space`,n=e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyM`;return t||n}function da(e){return!e||e.type!==`jaw-preview-dropped-files`||!Array.isArray(e.files)?[]:e.files.filter(e=>e instanceof File)}function fa(e){let t=(0,Y.useRef)(null),n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=(0,Y.useRef)(null),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(!1),l=qi(e.instance,e.data,{theme:e.theme}),u=e.instance?.ok?`Preview is off. Turn it on from the header to mount the iframe.`:l.reason,d=(0,Y.useCallback)(()=>{e.enabled&&l.canPreview&&l.src&&n.current===l.src&&na(t.current,l.src,e.theme)},[e.enabled,e.theme,l.canPreview,l.src]);(0,Y.useEffect)(()=>{let i=e.previewInsertTextRequest;if(!i||r.current===i.id)return;r.current=i.id;let a=t=>{e.onPreviewInsertTextResult?.(i.id,t)};if(!e.instance?.ok||e.instance.port!==i.port){a({ok:!1,error:`selected instance preview is not mounted`});return}if(!e.enabled||!l.canPreview||!l.src){a({ok:!1,error:u||`selected instance preview is unavailable`});return}if(n.current!==l.src){a({ok:!1,error:`selected instance preview is still loading`});return}ca(t.current,l.src,i.text).then(a).catch(e=>a({ok:!1,error:e.message}))},[u,e.enabled,e.instance,e.onPreviewInsertTextResult,e.previewInsertTextRequest,l.canPreview,l.src]),(0,Y.useEffect)(()=>{let r=e.previewSettingsOpenRequest;if(!r||i.current===r)return;i.current=r;let a=t=>{e.onPreviewSettingsOpenResult?.(r,t)};if(!e.instance?.ok){a({ok:!1,error:`selected instance is not online`});return}if(!e.enabled||!l.canPreview||!l.src){a({ok:!1,error:u||`turn Preview on to open this instance’s settings`});return}if(n.current!==l.src){a({ok:!1,error:`selected instance preview is still loading`});return}ia(t.current,l.src),a({ok:!0})},[u,e.enabled,e.instance,e.onPreviewSettingsOpenResult,e.previewSettingsOpenRequest,l.canPreview,l.src]);let f=(0,Y.useCallback)(async e=>{if(!L(e.dataTransfer))return;e.preventDefault(),e.stopPropagation(),c(!1);let n=I(e.dataTransfer),r=e.dataTransfer.getData(`text/plain`),i=n?.entries?.length?n.entries.map(e=>e.path).join(`
2
+ import{r as e}from"./rolldown-runtime-hePW80VL.js";import"./vendor-render-Cmfl_oW8.js";import{t}from"./preload-helper-CfbQpVni.js";import{a as n,i as r,n as i,r as a,t as o}from"./esm-Q6VOkDbn.js";import{n as s,t as c}from"./settings-embedding-DIqST-91.js";import{t as l}from"./react-C_pPTFsM.js";import{t as u}from"./react-dom-DyUOYpVL.js";import{C as d,D as f,E as p,O as m,S as h,T as g,_,a as v,b as y,c as b,d as x,f as S,g as C,h as w,i as T,k as E,l as D,m as O,n as k,o as ee,p as A,r as j,s as te,t as ne,u as re,v as ie,w as ae,x as oe,y as se}from"./api-B9RiiOMM.js";import{t as ce}from"./jsx-runtime-NZYk81nU.js";import{n as le,t as M}from"./desktop-bridge-DbRfkg8l.js";import{n as ue}from"./terminal-shortcut-queue-B_AyW1hN.js";import{a as de,c as fe,i as pe,l as N,n as P,o as me,r as he,s as ge,t as _e,u as F}from"./PanelLayoutProvider-mn8sI0h-.js";import{a as ve,i as ye,o as be,r as xe,t as Se}from"./manager-shortcuts-jsiX-zV6.js";import{t as Ce}from"./copy-text-WsUHYigB.js";import{i as I,r as L}from"./folder-drag-payload-BhV9yzhH.js";import{$ as R,At as we,Ct as Te,D as Ee,Et as z,It as De,L as B,N as Oe,Ot as ke,Q as V,St as H,Y as U,Z as Ae,_t as W,a as G,at as K,c as je,ct as Me,dt as Ne,et as Pe,ft as Fe,ht as q,it as Ie,jt as Le,k as Re,lt as ze,nt as Be,o as Ve,ot as He,p as Ue,q as J,st as We,t as Ge,u as Ke,vt as qe,wt as Je,x as Ye,y as Xe}from"./dist-D011G-p-.js";import{d as Ze,f as Qe,g as $e,i as et,r as tt,u as nt}from"./dist-CcmA2WLJ.js";import{c as rt,i as it,l as at,n as ot,o as st,r as ct}from"./dist-DBpt7gM8.js";import{a as lt}from"./dist-DBX5LjYY.js";import{t as ut}from"./MarkdownRenderer-DhonsAPC.js";import{a as dt,i as ft,n as pt,r as mt,t as ht}from"./wiki-link-suggestions-BcEfThgf.js";import{i as gt,t as _t}from"./notes-graph-settings-BUoTzvqs.js";var Y=e(l(),1),vt=s();async function yt(e){let t=Math.max(1,e.maxAttempts??16),n=Math.max(50,e.intervalMs??500),r=null;for(let i=1;i<=t;i+=1){if(e.signal?.aborted)return{settled:!1,attempts:i-1,instance:r};let a=new AbortController,o=()=>a.abort();e.signal?.addEventListener(`abort`,o,{once:!0});try{r=await e.fetchOnce(e.port,a.signal)}catch{r=null}finally{e.signal?.removeEventListener(`abort`,o)}if(e.onAttempt?.(r,i),bt(r,e))return{settled:!0,attempts:i,instance:r};if(i===t)break;await xt(n,e.signal)}return{settled:!1,attempts:t,instance:r}}function bt(e,t){return t.expected===`online`?e?.status===`online`:t.expected===`offline`?!e||e.status!==`online`:t.expected===`restart-detected`?!e||e.status!==`online`||typeof e.uptime!=`number`?!1:typeof t.previousUptime!=`number`||e.uptime<t.previousUptime:!1}function xt(e,t){return new Promise(n=>{let r=setTimeout(()=>{i(),n()},e);function i(){clearTimeout(r),t?.removeEventListener(`abort`,a)}function a(){i(),n()}if(t?.aborted){i(),n();return}t?.addEventListener(`abort`,a,{once:!0})})}var X=ce();function St(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),o=e?.managed.length||0;(0,Y.useEffect)(()=>{s()},[]);async function s(){try{t(await _())}catch(e){a(e.message)}}async function c(e,n){r(e),a(null);try{let r=await n();t(r),a(`${e} complete.`)}catch(e){a(e.message)}finally{r(null)}}function l(){o!==0&&window.confirm(`Stop ${o} dashboard-managed server${o===1?``:`s`}?`)&&c(`Stop all managed`,f)}return(0,X.jsxs)(`section`,{className:`process-control-panel`,"aria-label":`Process control`,children:[(0,X.jsxs)(`div`,{className:`process-control-header`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Process control`}),(0,X.jsxs)(`strong`,{children:[o,` managed`]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:s,disabled:n!=null,children:`Refresh`})]}),(0,X.jsxs)(`div`,{className:`process-control-actions`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:l,disabled:n!=null||o===0,children:`Stop all managed`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void c(`Adopt/recover managed`,k),disabled:n!=null,children:`Adopt/recover`}),(0,X.jsx)(`button`,{type:`button`,disabled:!0,title:e?.unsupported.reason||`Planned`,children:`Force release port`})]}),(0,X.jsx)(`p`,{className:`process-control-hint`,children:`Stop all affects only dashboard-managed servers. Adopt/recover reconnects known managed process records without stopping external instances.`}),(0,X.jsxs)(`div`,{className:`process-control-list`,children:[e?.managed.map(e=>(0,X.jsxs)(`div`,{className:`process-control-row`,children:[(0,X.jsxs)(`span`,{children:[`:`,e.port]}),(0,X.jsx)(`strong`,{children:e.pid?`pid ${e.pid}`:`pid n/a`}),(0,X.jsx)(`em`,{children:e.proof})]},e.port)),o===0&&(0,X.jsx)(`p`,{children:`No dashboard-managed servers are registered.`})]}),i&&(0,X.jsx)(`p`,{className:`process-control-message`,children:i})]})}var Ct=4e3,wt={info:`log-level-info`,warn:`log-level-warn`,error:`log-level-error`};function Tt(e){try{return new Date(e).toLocaleTimeString(`en-GB`,{hour12:!1})}catch{return e.slice(11,19)}}function Et({port:e}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!0),[s,c]=(0,Y.useState)(`all`),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useCallback)(async()=>{try{let t=await fetch(`/api/manager/instance-logs/${e}`);if(!t.ok){i(`HTTP ${t.status}`);return}let r=await t.json();r.ok&&r.snapshot?(n(r.snapshot),i(null)):i(r.error||`Unknown error`)}catch(e){i(e.message)}},[e]);(0,Y.useEffect)(()=>(d(),u.current=setInterval(d,Ct),()=>{u.current&&clearInterval(u.current)}),[d]),(0,Y.useEffect)(()=>{a&&l.current&&(l.current.scrollTop=l.current.scrollHeight)},[t,a]);let f=t?.lines.filter(e=>s===`all`||e.level===s)??[];return r&&!t?(0,X.jsxs)(`div`,{className:`detail-empty`,children:[`Failed to load logs: `,r]}):t?.source===`none`?(0,X.jsx)(`div`,{className:`detail-empty`,children:t.reason||`No log source reachable for this instance.`}):(0,X.jsxs)(`div`,{className:`logs-panel`,children:[(0,X.jsxs)(`div`,{className:`logs-toolbar`,children:[(0,X.jsxs)(`select`,{className:`logs-filter`,value:s,onChange:e=>c(e.target.value),children:[(0,X.jsx)(`option`,{value:`all`,children:`All levels`}),(0,X.jsx)(`option`,{value:`info`,children:`Info`}),(0,X.jsx)(`option`,{value:`warn`,children:`Warn`}),(0,X.jsx)(`option`,{value:`error`,children:`Error`})]}),(0,X.jsxs)(`label`,{className:`logs-autoscroll`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:a,onChange:e=>o(e.target.checked)}),`Auto-scroll`]}),(0,X.jsxs)(`span`,{className:`logs-meta`,children:[t?`${t.lines.length} lines · source: ${t.source}`:`Loading…`,t?.truncated&&` · truncated`]})]}),(0,X.jsx)(`div`,{className:`logs-container`,ref:l,children:f.length===0?(0,X.jsx)(`div`,{className:`logs-empty`,children:`No log lines available.`}):f.map((e,t)=>(0,X.jsxs)(`div`,{className:`log-line ${wt[e.level]}`,children:[(0,X.jsx)(`span`,{className:`log-ts`,children:Tt(e.ts)}),(0,X.jsx)(`span`,{className:`log-level`,children:e.level.toUpperCase()}),(0,X.jsx)(`span`,{className:`log-text`,children:e.text})]},t))})]})}function Dt(e){let t=e.instance;return(0,X.jsxs)(`section`,{className:`detail-panel`,"aria-label":`Selected instance detail`,children:[e.activeTab===`overview`&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{className:`overview-grid`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Status`}),(0,X.jsx)(`strong`,{children:t?.status||`n/a`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`CLI`}),(0,X.jsx)(`strong`,{children:t?.currentCli||`n/a`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Model`}),(0,X.jsx)(`strong`,{children:t?.currentModel||`n/a`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Owner`}),(0,X.jsx)(`strong`,{children:t?.lifecycle?.owner||`n/a`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Version`}),(0,X.jsx)(`strong`,{children:t?.version||`n/a`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Group`}),(0,X.jsx)(`strong`,{children:t?.group||`ungrouped`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`span`,{children:`Reason`}),(0,X.jsx)(`strong`,{children:t?.lifecycle?.reason||t?.healthReason||`ok`})]})]}),(0,X.jsx)(St,{})]}),e.activeTab===`logs`&&t&&(0,X.jsx)(Et,{port:t.port}),e.activeTab===`logs`&&!t&&(0,X.jsx)(`div`,{className:`detail-empty`,children:`Select an instance to view its logs.`})]})}function Ot(e){return(0,X.jsxs)(`div`,{className:`empty-navigator`,role:`status`,"aria-live":`polite`,children:[(0,X.jsx)(`p`,{className:`empty-navigator-headline`,children:`No Jaw instances detected on the scanned range.`}),(0,X.jsxs)(`p`,{className:`empty-navigator-subline`,children:[`Currently scanning ports `,e.rangeFrom,`–`,e.rangeTo,`. Try widening the range, or start a Jaw with the command below.`]}),(0,X.jsxs)(`code`,{className:`empty-navigator-code`,"aria-label":`Suggested command`,children:[`jaw serve --port `,e.rangeFrom]})]})}function kt(e,t={}){return t.transitioning?`transitioning`:t.busy?`working`:e.status===`offline`?`offline`:e.status===`online`?`online`:`attention`}function At(e){let t=Number.isFinite(e)?Math.max(0,Math.floor(e/1e3)):0;if(t<60)return`${t}s`;let n=Math.floor(t/60);return n<60?`${n}m`:`${Math.floor(n/60)}h ${n%60}m`}function jt(e){return[`:${e.port}`,e.homeDisplay||`home n/a`,e.currentCli||`cli n/a`,e.currentModel||`model n/a`,`v${e.version||`n/a`}`].join(` · `)}function Mt(e,t){let n=Number(!!t.favorite)-Number(!!e.favorite);return n===0?e.port-t.port:n}var Nt={start:`starting…`,stop:`stopping…`,restart:`restarting…`,perm:`registering…`,unperm:`unregistering…`};function Pt(e){return`instance-status status-${e}`}var Ft=()=>(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`12`,height:`12`,fill:`currentColor`,"aria-hidden":`true`,children:(0,X.jsx)(`rect`,{x:`3`,y:`3`,width:`10`,height:`10`,rx:`1.5`})}),It=()=>(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`12`,height:`12`,stroke:`currentColor`,strokeWidth:`1.5`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M6.5 3.5H4a1 1 0 0 0-1 1V12a1 1 0 0 0 1 1h7.5a1 1 0 0 0 1-1V9.5`}),(0,X.jsx)(`path`,{d:`M9.5 2.5h4v4`}),(0,X.jsx)(`path`,{d:`M13.5 2.5 8 8`})]}),Lt=({open:e})=>(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`12`,height:`12`,stroke:`currentColor`,strokeWidth:`1.5`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,style:{transform:e?`rotate(180deg)`:void 0,transition:`transform 0.12s`},children:(0,X.jsx)(`path`,{d:`M3.5 6l4.5 4.5L12.5 6`})});function Rt(e){let[,t]=(0,Y.useState)(0);return(0,Y.useEffect)(()=>{if(e.startedAtMs==null)return;let n=window.setInterval(()=>t(e=>e+1),1e3);return()=>window.clearInterval(n)},[e.startedAtMs]),e.startedAtMs==null?null:(0,X.jsx)(`span`,{className:`instance-row-working-duration`,children:At(Date.now()-e.startedAtMs)})}function zt(e){let t=e.instance.lifecycle,n=t?.reason||e.instance.healthReason||`ok`,[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(e.instance.label||e.profile?.label||e.label),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null);function d(e){e.stopPropagation()}let f=e.transitioning?Nt[e.transitioning]:null,p=kt(e.instance,{busy:!!e.agentBusy,transitioning:e.transitioning||null}),m=(0,Y.useRef)(null);p===`working`?m.current??=Date.now():m.current=null;let h=p===`transitioning`&&f?f:p===`working`?`Working`:p===`offline`?`Offline`:p===`attention`?`Attention`:`Online`,g=e.density===`compact`||e.density===`rail`,_=`${Pt(e.instance.status)}${f?` is-transitioning`:``}${e.agentBusy?` is-busy`:``} is-${p}`,v=e.instance.label||e.profile?.label||e.label;async function y(t){t.preventDefault(),t.stopPropagation(),c(!0),u(null);try{await e.onInstanceLabelSave(e.instance.port,a),i(!1)}catch(e){u(e.message)}finally{c(!1)}}return(0,X.jsxs)(`article`,{className:`instance-row density-${e.density||`comfortable`} priority-${e.priority||`normal`} ${e.selected?`is-selected`:``}${f?` is-transitioning-row`:``} is-${p}`,title:jt(e.instance),"aria-current":e.selected?`true`:void 0,children:[(0,X.jsxs)(`div`,{className:`instance-row-body`,children:[(0,X.jsxs)(`button`,{className:`instance-row-select`,type:`button`,"data-instance-port":e.instance.port,"aria-pressed":e.selected,onClick:()=>{e.onSelect(e.instance)},children:[(0,X.jsxs)(`span`,{className:`instance-row-main`,children:[(0,X.jsx)(`span`,{className:_,"aria-label":e.instance.status}),(0,X.jsxs)(`span`,{className:`instance-row-title`,children:[g?null:(0,X.jsxs)(`span`,{className:`instance-row-status-line`,"data-status":p,children:[(0,X.jsx)(`span`,{className:`instance-row-status-pill is-${p} health-${e.instance.status}`,title:h,children:h}),p===`working`?(0,X.jsx)(Rt,{startedAtMs:m.current}):null]}),(0,X.jsxs)(`span`,{className:`instance-row-title-line`,children:[(0,X.jsx)(`strong`,{children:e.instance.favorite?`Pinned ${v}`:v}),e.activityUnreadCount?(0,X.jsxs)(`span`,{className:`instance-unread-badge`,"aria-label":`${e.activityUnreadCount} unread activity`,children:[`(`,e.activityUnreadCount>99?`99+`:e.activityUnreadCount,`)`]}):null]}),f&&(0,X.jsx)(`span`,{className:`instance-row-secondary`,children:(0,X.jsx)(`em`,{className:`instance-row-transition`,children:f})})]})]}),(0,X.jsxs)(`span`,{className:`instance-row-meta`,children:[e.priority!==`active`&&e.showLatestActivityTitle!==!1&&e.latestActivityTitle&&(0,X.jsx)(`span`,{className:`instance-row-activity-title`,children:e.latestActivityTitle}),e.showRuntimeLine!==!1&&(0,X.jsxs)(`span`,{className:`instance-row-runtime`,children:[e.instance.currentCli||`cli n/a`,` / `,e.instance.currentModel||`model n/a`]}),e.priority!==`active`&&(0,X.jsxs)(`span`,{className:`instance-row-version`,children:[`v`,e.instance.version||`n/a`,` · `,e.uptime]}),e.priority!==`active`&&(0,X.jsxs)(`span`,{className:`instance-row-reason`,children:[new Date(e.instance.lastCheckedAt).toLocaleTimeString(),` · `,n]})]})]}),(0,X.jsxs)(`div`,{className:`instance-row-quick`,onClick:d,children:[e.priority===`active`&&e.instance.ok&&(e.sessionCount??0)>=1&&e.onToggleSessions?(0,X.jsx)(`button`,{type:`button`,className:`quick-btn action-sessions`,"aria-controls":e.sessionListId,"aria-expanded":e.sessionsOpen===!0,"aria-label":`Sessions (${e.sessionCount})`,title:`Sessions (${e.sessionCount})`,onClick:t=>{d(t),e.onToggleSessions?.(e.instance.port)},children:(0,X.jsx)(Lt,{open:e.sessionsOpen===!0})}):null,(0,X.jsx)(`button`,{type:`button`,className:`quick-btn action-stop`,onClick:t=>{d(t),e.onLifecycle(`stop`,e.instance)},disabled:!t?.canStop||e.busy,title:`Stop`,"aria-label":`Stop`,children:(0,X.jsx)(Ft,{})}),(0,X.jsx)(`a`,{className:`quick-btn action-open${e.instance.ok?``:` is-disabled`}`,href:e.instance.ok?e.instance.url:void 0,target:e.instance.ok?`_blank`:void 0,rel:e.instance.ok?`noreferrer`:void 0,title:`Open in new tab`,"aria-label":`Open`,"aria-disabled":!e.instance.ok||void 0,tabIndex:e.instance.ok?void 0:-1,onClick:t=>{if(!e.instance.ok){t.preventDefault();return}d(t),e.onMarkActivitySeen(e.instance.port)},children:(0,X.jsx)(It,{})}),(0,X.jsxs)(`span`,{className:`port`,children:[`:`,e.instance.port]})]})]}),e.showInlineLabelEditor!==!1&&r?(0,X.jsxs)(`form`,{className:`instance-label-edit-form`,onSubmit:e=>void y(e),onClick:d,children:[(0,X.jsx)(`input`,{className:`instance-label-input`,value:a,maxLength:120,"aria-label":`Rename ${v}`,onChange:e=>o(e.target.value)}),(0,X.jsx)(`button`,{className:`instance-label-save`,type:`submit`,disabled:s,children:`Save`}),(0,X.jsx)(`button`,{className:`instance-label-cancel`,type:`button`,disabled:s,onClick:()=>{o(e.instance.label||e.profile?.label||e.label),u(null),i(!1)},children:`Cancel`}),l&&(0,X.jsx)(`span`,{className:`instance-label-error`,children:l})]}):e.showInlineLabelEditor===!1?null:(0,X.jsx)(`button`,{className:`instance-label-edit-button`,type:`button`,"aria-label":`Rename ${v}`,title:`Rename`,onClick:t=>{d(t),o(e.instance.label||e.profile?.label||e.label),u(null),i(!0)},children:(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`13`,height:`13`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M12 20h9`}),(0,X.jsx)(`path`,{d:`M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z`})]})}),e.jumpHint?(0,X.jsx)(`span`,{className:`instance-jump-hint`,"aria-hidden":`true`,children:e.jumpHint}):null,e.showSelectedActions!==!1&&(0,X.jsxs)(`div`,{className:`instance-actions`,children:[(0,X.jsx)(`button`,{type:`button`,"aria-label":`Preview`,title:`Preview`,onClick:t=>{d(t),e.onPreview(e.instance)},disabled:!e.instance.ok,children:`Prev`}),(0,X.jsx)(`button`,{type:`button`,className:`action-start`,"aria-label":`Start`,onClick:t=>{d(t),e.onLifecycle(`start`,e.instance)},disabled:!t?.canStart||e.busy,title:t?.commandPreview?.join(` `),children:`Start`}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Register as persistent service`,onClick:t=>{d(t),e.onLifecycle(`perm`,e.instance)},disabled:!t?.canPerm||e.busy,title:`Register as persistent service`,children:`Perm`}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Restart`,title:`Restart`,onClick:t=>{d(t),e.onLifecycle(`restart`,e.instance)},disabled:!t?.canRestart||e.busy,children:`Res`})]})]})}var Bt=`jaw.sidebarGroupCollapsed`;function Vt(){try{if(typeof localStorage>`u`)return{};let e=localStorage.getItem(Bt);if(!e)return{};let t=JSON.parse(e);if(!t||typeof t!=`object`||Array.isArray(t))return{};let n={};for(let[e,r]of Object.entries(t))typeof r==`boolean`&&(n[e]=r);return n}catch{return{}}}function Ht(e){try{if(typeof localStorage>`u`)return;localStorage.setItem(Bt,JSON.stringify(e))}catch{}}function Ut(){let[e,t]=(0,Y.useState)(Vt),n=(0,Y.useCallback)(t=>e[t]===!0,[e]),r=(0,Y.useCallback)(e=>{t(t=>{let n={...t,[e]:!t[e]};return Ht(n),n})},[]);return{isCollapsed:n,toggle:r,toggleGroup:r}}function Wt(e,t,n){if(e.length===0)return null;if(t==null)return n===`previous`?e[e.length-1]??null:e[0]??null;let r=e.indexOf(t);return r===-1?null:n===`previous`?r>0?e[r-1]??null:null:r<e.length-1?e[r+1]??null:null}function Gt(e){let t=/^jumpInstance([1-9])$/.exec(e);return t?Number(t[1])-1:null}function Kt(e){return e===`offline`||e===`unknown`||e===`timeout`}function qt(e,t,n){let r=e.slice(0,Math.max(0,t));return n!=null&&e.includes(n)&&!r.includes(n)?[...r,n]:r}function Jt(e){let t=e.setTimeoutFn??setTimeout,n=e.clearTimeoutFn??clearTimeout,r=!1,i=null,a=()=>{i!=null&&(n(i),i=null)};return{sync(n){if(!n){a(),r&&(r=!1,e.onVisibilityChange(!1));return}r||i!=null||(i=t(()=>{i=null,r=!0,e.onVisibilityChange(!0)},e.delayMs))},dispose(){a()}}}var Yt=!1,Xt=new Set;function Zt(e){return Xt.add(e),()=>{Xt.delete(e)}}function Qt(){return Yt}function $t(e){Yt!==e&&(Yt=e,Xt.forEach(e=>e()))}function en(e){return e.altKey&&!e.metaKey&&!e.ctrlKey&&!e.shiftKey}function tn(e){return Array.from(e.querySelectorAll(`[data-instance-port]`)).map(e=>Number(e.dataset.instancePort)).filter(e=>Number.isInteger(e))}function nn(e,t,n){if(e.isComposing||e.keyCode===229)return;let r=Array.from(t.querySelectorAll(`[data-instance-port]`));if(r.length===0)return;let i=r.map(e=>Number(e.dataset.instancePort)),a=document.activeElement instanceof HTMLElement?document.activeElement:null;if(!a||!r.includes(a)||e.target!==a)return;let o=Number(a.dataset.instancePort),s=null;if(e.key===`ArrowDown`)s=Wt(i,o,`next`);else if(e.key===`ArrowUp`)s=Wt(i,o,`previous`);else if(e.key===`Home`)s=i[0]??null;else if(e.key===`End`)s=i[i.length-1]??null;else if(e.key===`Enter`&&o!=null){e.preventDefault(),n(o);return}s!=null&&(e.preventDefault(),r.find(e=>Number(e.dataset.instancePort)===s)?.focus())}var rn=null;function an(e){rn=e}function on(){return rn}function sn(e,t){return e.filter(e=>!t.has(e.port))}function cn(e,t){let n=new Set,r=t==null?[]:e.filter(e=>e.port===t),i=sn(e,n).filter(e=>e.favorite);i.forEach(e=>n.add(e.port));let a=new Map;for(let t of sn(e,n)){if(!t.group)continue;let e=a.get(t.group)||[];e.push(t),a.set(t.group,e),n.add(t.port)}let o=sn(e,n),s=o.filter(e=>e.status===`online`),c=o.filter(e=>e.status===`error`),l=o.filter(e=>Kt(e.status));i.sort(Mt),s.sort(Mt),c.sort(Mt),l.sort(Mt);for(let e of a.values())e.sort(Mt);return[{id:`active`,label:`Selected`,instances:r},{id:`favorites`,label:`Pinned`,instances:i},...Array.from(a.entries()).map(([e,t])=>({id:`group-${e}`,label:e,instances:t})),{id:`running`,label:`Running`,instances:s},{id:`attention`,label:`Attention`,instances:c},{id:`settled`,label:`Settled`,instances:l}].filter(e=>e.instances.length>0)}function ln(e,t,n,r=`normal`,i,a){return(0,X.jsx)(zt,{instance:t,...n===void 0?{}:{profile:n},selected:e.selectedPort===t.port,busy:e.lifecycleBusyPort===t.port,transitioning:e.transitioningPort===t.port&&e.transitionAction||null,activityUnreadCount:e.activityUnreadByPort?.[t.port]||0,latestActivityTitle:e.latestTitleByPort?.[t.port]||null,agentBusy:e.busyPorts?.has(t.port)||!1,...e.showLatestActivityTitles===void 0?{}:{showLatestActivityTitle:e.showLatestActivityTitles},...e.showInlineLabelEditor===void 0?{}:{showInlineLabelEditor:e.showInlineLabelEditor},...e.showSidebarRuntimeLine===void 0?{}:{showRuntimeLine:e.showSidebarRuntimeLine},...e.showSelectedRowActions===void 0?{}:{showSelectedActions:e.showSelectedRowActions},...e.density===void 0?{}:{density:e.density},...r===`active`&&e.activeSessionCount!==void 0?{sessionCount:e.activeSessionCount}:{},...r===`active`&&e.activeSessionsOpen!==void 0?{sessionsOpen:e.activeSessionsOpen}:{},...r===`active`&&e.onToggleActiveSessions?{onToggleSessions:e.onToggleActiveSessions}:{},...a===void 0?{}:{sessionListId:a},priority:r,label:e.getLabel(t),uptime:e.formatUptime(t.uptime),onSelect:e.onSelect,onPreview:e.onPreview,onMarkActivitySeen:e.onMarkActivitySeen,onInstanceLabelSave:e.onInstanceLabelSave,onLifecycle:e.onLifecycle,jumpHint:i??null},t.port)}function un(e,t,n,r){let i=e.instances.find(e=>e.port===t),a=e.id===`settled`?qt(e.instances.map(e=>e.port),r,t):[],o=new Map(e.instances.map(e=>[e.port,e])),s=e.id===`settled`?a.map(e=>o.get(e)).filter(e=>e!=null):e.instances;return e.id===`active`||!n?s:i?[i]:[]}function dn(e){let t=(0,Y.useId)(),{group:n,props:r,profileMap:i,collapsed:a,onToggle:o,jumpStartIndex:s,showJumpHints:c,settledVisibleCount:l,onShowMoreSettled:u}=e,d=n.id!==`settled`||!a,f=un(n,r.selectedPort,a,l),p=`instance-group-body-${t}`,m=n.id===`active`&&f[0]?.ok?`instance-sessions-${t}-${f[0].port}`:void 0,h=n.id===`settled`&&d?Math.max(0,n.instances.length-l):0,g=n.id===`active`?(0,X.jsxs)(`div`,{className:`instance-group-header`,children:[(0,X.jsx)(`span`,{children:n.label}),(0,X.jsx)(`strong`,{children:n.instances.length})]}):(0,X.jsxs)(`button`,{type:`button`,className:`instance-group-header instance-group-toggle`,"aria-expanded":!a,"aria-controls":p,onClick:o,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`svg`,{className:`instance-group-chevron`,viewBox:`0 0 16 16`,width:`12`,height:`12`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M3.5 6l4.5 4.5L12.5 6`})}),` `,n.label]}),(0,X.jsx)(`strong`,{children:n.instances.length})]});return(0,X.jsxs)(`section`,{className:`instance-group`,"aria-label":`${n.label} instances`,children:[g,(0,X.jsxs)(`div`,{id:p,hidden:a&&f.length===0,children:[f.map((e,t)=>{let a=s+t,o=c&&a<9?String(a+1):null;return ln(r,e,e.profileId?i.get(e.profileId):void 0,n.id===`active`?`active`:`normal`,o,m)}),n.id===`active`&&f[0]?.ok?(0,X.jsx)(`div`,{id:m,children:r.renderActiveSessionList?.(f[0].port)}):null,n.id===`settled`&&d&&h>0?(0,X.jsxs)(`button`,{type:`button`,className:`instance-settled-more`,onClick:u,children:[`Show `,Math.min(h,25),` more`]}):null]})]},n.id)}function fn(e){let t=cn(e.instances,e.selectedPort),n=new Map((e.profiles||[]).map(e=>[e.profileId,e])),{isCollapsed:r,toggle:i}=Ut(),a=(0,Y.useSyncExternalStore)(Zt,Qt),[o,s]=(0,Y.useState)(10);if((0,Y.useEffect)(()=>{s(10)},[e.instances]),t.length===0&&n.size===0)return(0,X.jsx)(`section`,{className:`state`,children:`No matching instances found.`});let c=0,l=t.map(t=>{let l=t.id!==`active`&&r(t.id),u=un(t,e.selectedPort,l,o).length,d=c;return c+=u,(0,X.jsx)(dn,{group:t,props:e,profileMap:n,collapsed:l,onToggle:()=>i(t.id),jumpStartIndex:d,showJumpHints:a,settledVisibleCount:o,onShowMoreSettled:()=>s(e=>e+25)},t.id)});return n.size>0?(0,X.jsx)(`div`,{className:`instance-groups profile-instance-groups is-profile-merged`,children:l}):(0,X.jsx)(`div`,{className:`instance-groups`,children:l})}var pn=2,mn=500,hn=1e4;function gn(e){let t=e?.trim();if(!t)return null;if(/^\d+$/.test(t)){let e=Number(t)*1e3;return Number.isSafeInteger(e)?e:null}let n=Date.parse(t);if(!Number.isFinite(n))return null;let r=n-Date.now();return r>0?r:null}function _n(){return new DOMException(`The operation was aborted.`,`AbortError`)}function vn(e,t){return new Promise((n,r)=>{if(t?.aborted){r(_n());return}let i=()=>{clearTimeout(a),r(_n())},a=setTimeout(()=>{t?.removeEventListener(`abort`,i),n()},e);t?.addEventListener(`abort`,i,{once:!0})})}function yn(e,t){return e===void 0||!Number.isFinite(e)?t:Math.max(0,Math.floor(e))}async function bn(e,t={}){let n=yn(t.retries,pn),r=yn(t.baseDelayMs,mn),i=t.fetchImpl??fetch,a=t.delay??vn,o=t.random??Math.random,s={method:`GET`,...t.signal?{signal:t.signal}:{}},c=0,l=await i(e,s);for(let u=0;l.status===429&&u<n;u++){let n=hn-c;if(n<=0)return l;let d=gn(l.headers.get(`Retry-After`)),f=Math.min(r*2**u,hn),p=Math.min(1,Math.max(0,o()))*f,m=Math.min(d??p,n);await a(m,t.signal),c+=m,l=await i(e,s)}return l}var xn=2e3,Sn=new Map,Cn=(...e)=>fetch(...e),wn=()=>Date.now();function Tn(e){let t=null;return e.lastError?.kind===`load`?t={kind:`load`,message:e.errorMessage??`sessions load failed`}:e.lastError?.kind===`switch`&&(t={kind:`switch`,seq:e.lastError.seq,message:e.errorMessage??`session switch failed`}),{data:e.data,switching:e.switching,error:t,count:e.data?.sessions.length??0}}function En(){return{generation:0,at:0,promise:null,data:null,switching:!1,lastError:null,errorMessage:null,snapshot:{data:null,switching:!1,error:null,count:0},listeners:new Set}}function Dn(e){let t=Sn.get(e);return t||(t=En(),Sn.set(e,t)),t}function On(e){return e instanceof Error?e.message:String(e)}function kn(e){e.snapshot=Tn(e);for(let t of[...e.listeners])t()}async function An(e){let t=await bn(`/i/${e}/api/chat-sessions`,{fetchImpl:Cn});if(!t.ok)throw Error(`sessions fetch failed: ${t.status}`);let n=(await t.json()).data??{};return{sessions:Array.isArray(n.sessions)?n.sessions:[],activeId:typeof n.active==`string`?n.active:null}}async function jn(e,t){let n=await Cn(`/i/${e}/api/chat-sessions/${t}/switch`,{method:`POST`});if(n.ok)return;let r=await n.json().catch(()=>({}));throw Error(r.error||`switch failed: ${n.status}`)}function Mn(e,t){let n=Dn(e);return n.listeners.add(t),()=>{n.listeners.delete(t)}}function Nn(e){return Dn(e).snapshot}async function Pn(e){let t=Dn(e);if(t.promise){await t.promise;return}if(t.data&&wn()-t.at<xn)return;let n=t.generation,r=An(e);t.promise=r;try{let e=await r;if(t.generation!==n)return;t.data=e,t.at=wn(),t.lastError=null,t.errorMessage=null,kn(t)}catch(e){throw t.promise===r&&(t.promise=null),t.generation===n&&(t.lastError={kind:`load`},t.errorMessage=On(e),kn(t)),e}finally{t.promise===r&&(t.promise=null)}}async function Fn(e,t){let n=Dn(e);if(!n.switching){n.switching=!0,n.lastError=null,n.errorMessage=null,kn(n);try{try{await jn(e,t)}catch(e){throw n.lastError={kind:`switch`,seq:t},n.errorMessage=On(e),kn(n),e}n.generation++,n.at=-1/0,n.promise=null,await Pn(e)}finally{n.switching=!1,kn(n)}}}async function In(e){let t=Dn(e).lastError;if(t?.kind===`switch`){await Fn(e,t.seq);return}await Pn(e)}function Ln(e){let t=e.split(`:`);if(t.length>=4&&t[0]===`jaw`){let e=t[3]||``,n=t.includes(`thread`);return`${t[1]} ${e.slice(0,11)}${n?` · thread`:``}`}return e.slice(0,32)}function Rn(e){return e.label&&!e.label.startsWith(`jaw:`)?e.label:e.remoteKey?Ln(e.remoteKey):e.label?Ln(e.label):e.seq===0?`Default session`:`Session #${e.seq}`}function zn(e){if(!e)return null;let t=new Date(e.replace(` `,`T`)).getTime();if(Number.isNaN(t))return null;let n=Math.floor((Date.now()-t)/6e4);if(n<1)return`now`;if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function Bn(e){let t=(0,Y.useCallback)(t=>Mn(e.port,t),[e.port]),n=(0,Y.useSyncExternalStore)(t,()=>Nn(e.port));if((0,Y.useEffect)(()=>{e.open&&Pn(e.port).catch(()=>{})},[e.open,e.port]),!e.open)return null;async function r(t,r){if(t.stopPropagation(),!(r.id===n.data?.activeId||n.switching))try{await Fn(e.port,r.seq),e.onSessionSwitched?.()}catch{}}let i=t=>{t.stopPropagation(),In(e.port).catch(()=>{})};if(n.error?.kind===`load`)return(0,X.jsx)(`div`,{className:`instance-session-list`,role:`list`,"aria-label":`Chat sessions`,children:(0,X.jsxs)(`div`,{className:`instance-session-error`,children:[(0,X.jsx)(`span`,{children:n.error.message}),(0,X.jsx)(`button`,{type:`button`,className:`instance-session-retry`,onClick:i,children:`Retry`})]})});if(n.data===null)return(0,X.jsx)(`div`,{className:`instance-session-list`,role:`list`,"aria-label":`Chat sessions`,children:(0,X.jsx)(`div`,{className:`instance-session-empty`,children:`Loading sessions…`})});let a=n.data.sessions;if(a.length===0)return null;let o=n.data?.activeId??null;return(0,X.jsxs)(`div`,{className:`instance-session-list`,role:`list`,"aria-label":`Chat sessions`,children:[n.error?.kind===`switch`&&(0,X.jsxs)(`div`,{className:`instance-session-error`,children:[(0,X.jsx)(`span`,{children:n.error.message}),(0,X.jsx)(`button`,{type:`button`,className:`instance-session-retry`,onClick:i,children:`Retry`})]}),a.map(e=>{let t=e.id===o,i=zn(e.lastActivityAt);return(0,X.jsxs)(`button`,{type:`button`,role:`listitem`,className:`instance-session-row${t?` is-active`:``}`,disabled:n.switching,"aria-current":t||void 0,onClick:t=>void r(t,e),children:[(0,X.jsxs)(`span`,{className:`instance-session-title`,children:[Rn(e),e.source&&(0,X.jsx)(`span`,{className:`session-source-badge`,children:e.source})]}),(0,X.jsx)(`span`,{className:`instance-session-meta`,children:n.switching?`switching…`:`${e.message_count} msg${i?` · ${i}`:``}`})]},e.id)})]})}var Vn={data:null,switching:!1,error:null,count:0};function Hn(e){let[t,n]=(0,Y.useState)(!0),r=(0,Y.useCallback)(t=>e==null?()=>{}:Mn(e,t),[e]),i=(0,Y.useCallback)(()=>e==null?Vn:Nn(e),[e]),a=(0,Y.useSyncExternalStore)(r,i);return(0,Y.useEffect)(()=>{n(!0),e!=null&&Pn(e).catch(()=>{})},[e]),{activeSessionCount:a.count,sessionsOpen:t,setSessionsOpen:n}}function Un(e){let{activeSessionCount:t,sessionsOpen:n,setSessionsOpen:r}=Hn(e.selectedInstance?.ok?e.selectedInstance.port:null),i=!e.error&&!e.loading&&e.instances.length===0&&!e.instances.some(e=>e.hidden),a=e.selectedInstance&&!e.filtered.some(t=>t.port===e.selectedInstance?.port)?[e.selectedInstance,...e.filtered]:e.filtered,o=t=>{if(t.ok){e.onPreview(t);return}e.onSelect(t)},s=e=>(0,X.jsx)(Bn,{port:e,open:n},e);return(0,X.jsxs)(X.Fragment,{children:[e.error&&(0,X.jsxs)(`section`,{className:`state error-state`,children:[`Scan failed: `,e.error]}),!e.error&&e.loading&&(0,X.jsx)(`section`,{className:`state`,children:`Scanning local Jaw instances...`}),i&&e.data?.manager&&(0,X.jsx)(Ot,{rangeFrom:e.data.manager.rangeFrom,rangeTo:e.data.manager.rangeTo}),!e.error&&!i&&(0,X.jsx)(fn,{instances:a,selectedPort:e.selectedInstance?.port||null,lifecycleBusyPort:e.lifecycleBusyPort,transitioningPort:e.transitioningPort,transitionAction:e.transitionAction,activityUnreadByPort:e.activityUnreadByPort,latestTitleByPort:e.latestTitleByPort,...e.busyPorts===void 0?{}:{busyPorts:e.busyPorts},showLatestActivityTitles:e.showLatestActivityTitles,showInlineLabelEditor:e.showInlineLabelEditor,showSidebarRuntimeLine:e.showSidebarRuntimeLine,showSelectedRowActions:e.showSelectedRowActions,activeSessionCount:t,activeSessionsOpen:n,onToggleActiveSessions:()=>r(e=>!e),renderActiveSessionList:s,profiles:e.profiles,getLabel:e.getLabel,formatUptime:e.formatUptime,onSelect:o,onPreview:e.onPreview,onMarkActivitySeen:e.onMarkActivitySeen,onInstanceLabelSave:e.onInstanceLabelSave,onLifecycle:e.onLifecycle})]})}function Wn(e){let t=e.count==null?``:` ${e.count}`;return(0,X.jsxs)(`button`,{type:`button`,className:`profile-chip ${e.active?`is-active`:``}`,onClick:()=>e.onToggle(e.profile.profileId),"aria-pressed":e.active,title:e.profile.homePath,children:[(0,X.jsx)(`span`,{children:e.profile.label}),t&&(0,X.jsx)(`strong`,{children:t})]})}async function Gn(){let e=await fetch(`/api/dashboard/desktop-status`);if(!e.ok)throw Error(`desktop status failed: ${e.status}`);return await e.json()}function Kn(){let e=window.location.pathname+window.location.search;window.location.href=`jaw://open?path=${encodeURIComponent(e)}`}function qn(){let e=le(),[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(!1);return(0,Y.useEffect)(()=>{if(e)return;let t=!1;return Gn().then(e=>{t||n(e)}).catch(()=>{t||i(!0)}),()=>{t=!0}},[e]),e?null:t?.inDesktop?(0,X.jsx)(`span`,{className:`desktop-status-badge`,title:`cli-jaw Desktop ${t.version}`,children:`Running in cli-jaw Desktop`}):!t&&!r?null:(0,X.jsx)(`button`,{type:`button`,className:`desktop-open-button`,onClick:Kn,title:t?.downloadUrl||`Open this dashboard path in cli-jaw Desktop`,children:`Open in Desktop App`})}function Jn(e){let t=le(),n=e.actions;return(0,X.jsx)(`div`,{className:`command-center command-bar${t?` is-electron-titlebar`:``}`,children:(0,X.jsxs)(`div`,{className:`command-primary`,children:[e.mobileMenuButton,(0,X.jsx)(`div`,{className:`command-title`,children:e.title}),(0,X.jsx)(`div`,{className:`command-search`,children:e.search}),(0,X.jsx)(`div`,{className:`command-actions`,children:n})]})})}function Yn(e,t,n){return{feature:e,state:t,...n?{reason:n}:{}}}function Xn(){return le()?`electron`:`web`}function Zn(e){return e===`electron`?{terminal:Yn(`terminal`,`enabled`),browser:Yn(`browser`,`enabled`),folder:Yn(`folder`,`enabled`),doc:Yn(`doc`,`enabled`),diff:Yn(`diff`,`enabled`)}:{terminal:Yn(`terminal`,`disabled`,`Terminal requires the desktop PTY bridge.`),browser:Yn(`browser`,`disabled`,`Browser side panel is available in the desktop app.`),folder:Yn(`folder`,`disabled`,`Folder side panel is available in the desktop app; use the Jawsidian Notes tab on web.`),doc:Yn(`doc`,`disabled`,`Document side panel is available in the desktop app; use the Jawsidian document tab on web.`),diff:Yn(`diff`,`disabled`,`Diff side panel is available in the desktop app.`)}}function Qn(e){return e.state===`enabled`||e.state===`limited`}function $n(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`4`,width:`14`,height:`12`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M6 9l3 2-3 2`}),(0,X.jsx)(`path`,{d:`M11 13h3`})]})}function er(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`4`,width:`14`,height:`12`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M13 4v12`})]})}function tr(){let e=pe(),t=he(),n=Xn();if(n!==`electron`)return null;let r=Zn(n),i=r.terminal,a=r.folder,o=Qn(i),s=Qn(a),c=e.state.bottomPanel,l=c.open&&(c.activeTab??c.tabs[0])===`terminal`,u=e.effectiveRightOpen;return(0,X.jsxs)(`div`,{className:`command-panel-controls`,"aria-label":`Desktop panels`,children:[(0,X.jsx)(`button`,{className:`command-panel-toggle${l?` is-active`:``}`,type:`button`,disabled:!o,onClick:()=>{o&&(l?t.toggleBottomPanel():(t.openBottomTab(`terminal`),document.dispatchEvent(new CustomEvent(`jaw:shortcut-action`,{detail:`focusTerminal`}))))},id:ue,"aria-label":`Toggle terminal panel`,"aria-pressed":l,title:i.reason??"Terminal (Ctrl+`)",children:(0,X.jsx)($n,{})}),(0,X.jsx)(`button`,{className:`command-panel-toggle${u?` is-active`:``}`,type:`button`,disabled:!s,onClick:()=>{s&&(u?t.toggleRightPanel():t.focusOrCreateFirstRightSidebarTab(`files`))},"aria-label":`Toggle right panel`,"aria-pressed":u,title:a.reason??`Side panel (Command+B)`,children:(0,X.jsx)(er,{})})]})}var nr=[{value:`auto`,label:`Auto`,hint:`Follow OS preference`},{value:`light`,label:`Light`,hint:`Always light theme`},{value:`dark`,label:`Dark`,hint:`Always dark theme`}];function rr(e){return(0,X.jsx)(`div`,{className:`theme-switch`,role:`radiogroup`,"aria-label":`Theme`,children:nr.map(t=>{let n=e.theme===t.value;return(0,X.jsx)(`button`,{type:`button`,role:`radio`,"aria-checked":n,title:t.hint,className:n?`is-active`:``,onClick:()=>e.onChange(t.value),children:t.label},t.value)})})}function ir(e){return(0,X.jsx)(Jn,{mobileMenuButton:(0,X.jsx)(`button`,{className:`drawer-trigger command-icon-button`,type:`button`,onClick:e.onOpenDrawer,"aria-label":`Open sidebar`,children:(0,X.jsx)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`path`,{d:`M4 6h12M4 10h12M4 14h12`})})}),title:(0,X.jsxs)(`h1`,{className:`manager-brand-heading`,"aria-label":`CLI-JAW Dashboard`,children:[(0,X.jsx)(`span`,{className:`manager-brand-wordmark`,children:`CLI-JAW`}),(0,X.jsx)(`span`,{className:`manager-brand-dash`,children:`DASH`})]}),search:(0,X.jsxs)(`div`,{className:`search-input-wrapper is-ghost`,children:[(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`14`,height:`14`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`circle`,{cx:`11`,cy:`11`,r:`8`}),(0,X.jsx)(`line`,{x1:`21`,y1:`21`,x2:`16.65`,y2:`16.65`})]}),(0,X.jsx)(`input`,{value:e.query,onChange:t=>e.onQueryChange(t.target.value),placeholder:`Search port, home, CLI, model`,"aria-label":`Search instances`})]}),actions:(0,X.jsxs)(`div`,{className:`command-actions-group`,children:[(0,X.jsx)(tr,{}),(0,X.jsx)(qn,{}),(0,X.jsx)(`button`,{type:`button`,className:`command-palette-trigger`,onClick:e.onOpenPalette,"aria-label":`Open command palette`,title:`Open command palette (⌘K / Ctrl+K)`,children:(0,X.jsx)(`span`,{"aria-hidden":`true`,children:`⌘K`})}),(0,X.jsx)(rr,{theme:e.theme,onChange:e.onThemeChange}),(0,X.jsx)(`button`,{type:`button`,className:`command-icon-button`,onClick:e.onRefresh,disabled:e.loading,"aria-label":e.loading?`Scanning`:`Refresh`,title:e.loading?`Scanning`:`Refresh`,children:(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M16 10a6 6 0 1 1-2-4.5`}),(0,X.jsx)(`path`,{d:`M16 4v4h-4`})]})})]})})}function ar(e,t){return(e.split(`/`).filter(Boolean).pop()||e).replace(/^\.?cli-jaw-(\d+)-[a-f0-9]{7,}$/i,`cli-jaw $1`).replace(/^\.?cli-jaw-(\d+)$/i,`cli-jaw $1`)||`cli-jaw ${t}`}function or(e){if(e.label)return e.label;let t=e.instanceId||e.homeDisplay||``;return ar(t.split(`/`).filter(Boolean).pop()||t,e.port)}function sr(e){if(e==null)return`n/a`;let t=Math.floor(e/60);if(t<1)return`${Math.round(e)}s`;let n=Math.floor(t/60);return n<1?`${t}m`:`${n}h ${t%60}m`}function cr(e){let t=e.className?`help-topic-button ${e.className}`:`help-topic-button`;return(0,X.jsx)(`button`,{type:`button`,className:t,"aria-label":e.label,title:e.label,onClick:()=>e.onOpen(e.topic),children:`?`})}function lr(e){let t=e.split(/[/\\]/).filter(Boolean);return t.length<=2?e:`…/${t.slice(-2).join(`/`)}`}function ur(e){let t=e.instance,n=!!t?.ok,r=e.previewEnabled?`Preview on`:`Preview off`,i=!!(t||e.onOpenHelpTopic),a=t?.projectDirs?.filter(Boolean)??[];return(0,X.jsxs)(`div`,{className:`detail-header`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`eyebrow`,children:`Selected instance`}),(0,X.jsx)(`h2`,{children:t?or(t):`No instance selected`}),t?(0,X.jsxs)(`div`,{className:`project-dirs${a.length?``:` is-empty`}`,children:[(0,X.jsx)(`span`,{className:`label`,children:`Project`}),a.length?a.map((e,t)=>(0,X.jsx)(`span`,{className:`project-dir`,title:e,children:lr(e)},t)):(0,X.jsx)(`span`,{className:`project-dir`,children:`Not set`}),e.onPickProject&&t.ok?(0,X.jsx)(`button`,{type:`button`,className:`project-pick-button`,disabled:e.projectPickBusy,title:`Open the folder chooser on this machine and set the project root`,onClick:()=>e.onPickProject?.(t.port),children:e.projectPickBusy?`Choosing…`:a.length?`Change`:`Choose…`}):null]}):(0,X.jsx)(`span`,{children:`Select an online instance to inspect it.`})]}),i&&(0,X.jsxs)(`div`,{className:`detail-header-actions`,children:[e.onOpenHelpTopic?(0,X.jsx)(cr,{topic:`instances`,label:`Open Instances help`,onOpen:e.onOpenHelpTopic}):null,t?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`preview-inline-status ${t.ok&&e.previewEnabled?`is-ready`:`is-unavailable`}`,"aria-label":t.ok&&e.previewEnabled?`Preview ready`:`Preview unavailable`,title:t.ok&&e.previewEnabled?`Preview ready`:`Preview unavailable`}),(0,X.jsxs)(`button`,{type:`button`,className:`preview-switch ${e.previewEnabled?`is-on`:`is-off`}`,role:`switch`,"aria-checked":e.previewEnabled,disabled:!n,onClick:()=>e.onPreviewEnabledChange(!e.previewEnabled),children:[(0,X.jsx)(`span`,{className:`preview-switch-track`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{children:r})]}),(0,X.jsx)(`button`,{type:`button`,className:`preview-refresh-button`,disabled:!n||!e.previewEnabled,onClick:e.onPreviewRefresh,children:`Refresh`}),(0,X.jsxs)(`a`,{className:`open-link`,href:t.url,target:`_blank`,rel:`noreferrer`,children:[(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`12`,height:`12`,stroke:`currentColor`,strokeWidth:`2`,fill:`none`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`}),(0,X.jsx)(`polyline`,{points:`15 3 21 3 21 9`}),(0,X.jsx)(`line`,{x1:`10`,y1:`14`,x2:`21`,y2:`3`})]}),`Open`]})]}):null]})]})}var dr=8,fr=5;function pr(e,t,n){if(!n)return!0;let r=n.toLowerCase();return[String(e.port),t,e.url,e.workingDir,e.currentCli].some(e=>{if(!e)return!1;let t=String(e).toLowerCase();return t.startsWith(r)?!0:RegExp(`(^|[^\\p{L}\\p{N}])${mr(r)}`,`u`).test(t)})}function mr(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function hr(e){let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)(0),a=(0,Y.useRef)(null),o=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{e.open&&(n(``),i(0),requestAnimationFrame(()=>a.current?.focus()))},[e.open]),(0,Y.useEffect)(()=>{if(!e.open)return;function t(t){t.key===`Escape`&&(t.preventDefault(),e.onClose())}return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e.open,e.onClose]);let s=(0,Y.useMemo)(()=>e.instances.filter(n=>pr(n,e.getLabel(n),t)).slice(0,dr),[e.instances,e.getLabel,t]),c=(0,Y.useMemo)(()=>[{id:`refresh`,label:`Refresh scan`,hint:`Re-scan local ports`,run:e.onRefresh},{id:`theme`,label:`Theme: cycle (current ${e.theme})`,hint:`Auto → Light → Dark`,run:e.onCycleTheme},{id:`hidden`,label:e.showHidden?`Hide hidden instances`:`Show hidden instances`,run:e.onToggleHidden},...e.selectedInstance?[{id:`open`,label:`Open ${e.selectedInstance.url} in new tab`,run:e.onOpenSelected}]:[]].slice(0,fr),[e.onRefresh,e.theme,e.onCycleTheme,e.showHidden,e.onToggleHidden,e.selectedInstance,e.onOpenSelected]),l=(0,Y.useMemo)(()=>{let e=[];for(let t of s)e.push({kind:`instance`,instance:t});for(let t of c)e.push({kind:`action`,action:t});return e},[s,c]);(0,Y.useEffect)(()=>{r>=l.length&&i(Math.max(0,l.length-1))},[l.length,r]);function u(t){let n=l[t];n&&(n.kind===`instance`?e.onSelectInstance(n.instance):n.action.run(),e.onClose())}function d(e){e.key===`ArrowDown`?(e.preventDefault(),i(e=>Math.min(l.length-1,e+1))):e.key===`ArrowUp`?(e.preventDefault(),i(e=>Math.max(0,e-1))):e.key===`Enter`&&(e.preventDefault(),u(r))}return e.open?(0,X.jsx)(`div`,{className:`command-palette-backdrop`,role:`presentation`,onClick:e.onClose,children:(0,X.jsxs)(`div`,{className:`command-palette`,role:`dialog`,"aria-modal":`true`,"aria-label":`Command palette`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`input`,{ref:a,className:`command-palette-input`,placeholder:`Go to instance, or run an action…`,value:t,onChange:e=>{n(e.target.value),i(0)},onKeyDown:d,"aria-label":`Command query`}),(0,X.jsxs)(`div`,{className:`command-palette-list`,ref:o,children:[s.length>0&&(0,X.jsxs)(`div`,{className:`command-palette-section`,role:`group`,"aria-label":`Go to instance`,children:[(0,X.jsx)(`header`,{className:`command-palette-section-header`,children:`Go to instance`}),s.map((t,n)=>{let a=n;return(0,X.jsxs)(`button`,{type:`button`,className:a===r?`command-palette-item is-active`:`command-palette-item`,onMouseEnter:()=>i(a),onClick:()=>u(a),children:[(0,X.jsxs)(`span`,{className:`command-palette-port`,children:[`:`,t.port]}),(0,X.jsx)(`span`,{className:`command-palette-label`,children:e.getLabel(t)})]},t.port)})]}),c.length>0&&(0,X.jsxs)(`div`,{className:`command-palette-section`,role:`group`,"aria-label":`Actions`,children:[(0,X.jsx)(`header`,{className:`command-palette-section-header`,children:`Actions`}),c.map((e,t)=>{let n=s.length+t;return(0,X.jsxs)(`button`,{type:`button`,className:n===r?`command-palette-item is-active`:`command-palette-item`,onMouseEnter:()=>i(n),onClick:()=>u(n),children:[(0,X.jsx)(`span`,{className:`command-palette-label`,children:e.label}),e.hint&&(0,X.jsx)(`span`,{className:`command-palette-hint`,children:e.hint})]},e.id)})]}),l.length===0&&(0,X.jsx)(`p`,{className:`command-palette-empty`,children:`No matches.`})]}),(0,X.jsxs)(`footer`,{className:`command-palette-footer`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`↑↓`}),` navigate`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Enter`}),` select`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Esc`}),` close`]})]})]})}):null}function gr(e){let t={"--activity-dock-height":`${e.activityHeight}px`};return(0,X.jsxs)(`main`,{className:`dashboard-shell manager-shell${e.sidebarCollapsed?` is-sidebar-collapsed`:``}`,style:t,children:[(0,X.jsx)(`header`,{className:`manager-command`,children:e.commandBar}),e.workspace]})}var _r=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`실행 중인 jaw 인스턴스를 보고, 미리보기·로그·설정을 다루는 곳이에요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsx)(`li`,{children:`좌측 네비게이터에서 인스턴스를 골라 우측 Workbench(Overview / Preview / Logs / Settings)에서 작업하실 수 있어요.`}),(0,X.jsx)(`li`,{children:`우측 상단 상태 점이 초록이면 온라인, 회색이면 오프라인이에요.`}),(0,X.jsx)(`li`,{children:`인스턴스에 직접 메시지를 보내실 땐 Preview 탭의 채팅 입력을 쓰세요.`}),(0,X.jsx)(`li`,{children:`Preview 채팅에 나온 Notes vault 경로를 클릭하면 Notes workspace로 이동해 해당 파일을 열 수 있어요.`})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`빠른 판단 기준`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Preview`}),(0,X.jsx)(`td`,{children:`실제 인스턴스 화면을 보거나 메시지를 보낼 때`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Logs`}),(0,X.jsx)(`td`,{children:`응답이 멈췄거나 dispatch 실패 원인을 확인할 때`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Settings`}),(0,X.jsx)(`td`,{children:`해당 인스턴스의 CLI, 모델, 권한을 조정할 때`})]})]})})]}),(0,X.jsxs)(`p`,{className:`help-tip`,children:[`인스턴스가 안 보이시면 터미널에서 `,(0,X.jsx)(`code`,{children:`cli-jaw start`}),`로 새 jaw를 띄워보세요. 자동으로 목록에 떠요.`]})]}),vr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`사람이 먼저 일반 칸반 블럭을 만들고, 실행 인스턴스 블럭을 그 안에 붙이는 계층형 보드예요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[`레인 5개는 `,(0,X.jsx)(`strong`,{children:`Backlog / Ready / In Progress / Review / Done`}),` 순서예요. Backlog는 아직 commit 전 옵션, Ready는 바로 pull 가능한 작업이에요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Overall`}),`은 5열 전체 보드이고, 사이드바에서 각 레인을 누르면 해당 레인만 보는 detail 화면으로 전환돼요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Done`}),`은 Overall에서 최근 4개만 full card로 보여주고, 나머지는 `,(0,X.jsx)(`strong`,{children:`+ N more`}),`를 눌러 Done detail 화면에서 2줄 row로 확인해요.`]}),(0,X.jsxs)(`li`,{children:[`각 레인 하단의 `,(0,X.jsx)(`strong`,{children:`+ Add task`}),`로 일반 칸반 블럭을 만들고, 그 블럭 제목에 쿼리나 작업 메모를 적으시면 돼요.`]}),(0,X.jsxs)(`li`,{children:[`좌측 `,(0,X.jsx)(`strong`,{children:`Running`}),` 섹션에는 현재 실행 중인 인스턴스만 인스턴스 블럭으로 보여요.`]}),(0,X.jsx)(`li`,{children:`인스턴스 블럭을 일반 칸반 블럭 안의 드롭 영역으로 끌어 넣으면 내부 자식 블럭으로 병합돼요. 인스턴스 실행에는 영향 없어요.`}),(0,X.jsxs)(`li`,{children:[`일반 칸반 블럭은 직접 드래그해서 다른 레인으로 옮길 수 있고, `,(0,X.jsx)(`strong`,{children:`Move`}),` / `,(0,X.jsx)(`strong`,{children:`Delete`}),`도 유지돼요.`]})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`상태를 나눠 쓰는 법`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Ready`}),(0,X.jsx)(`td`,{children:`바로 구현하거나 검증할 수 있는 작업`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Review`}),(0,X.jsx)(`td`,{children:`직원 감사, Pro 검증, 수동 smoke가 필요한 작업`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Done`}),(0,X.jsx)(`td`,{children:`커밋, 푸시, 이슈 close까지 끝난 작업`})]})]})})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`인스턴스가 없어도 일반 칸반 블럭은 계속 남아요. 쿼리·아이디어·작업 단위를 먼저 적고, 필요할 때만 실행 인스턴스를 붙이면 돼요.`})]}),yr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`매니저가 1분마다 틱을 돌면서 대시보드에 등록된 자동화 작업을 일괄 dispatch 해주는 곳이에요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Today / Upcoming / Recurring / Blocked`}),` 그룹으로 정리되고, `,(0,X.jsx)(`code`,{children:`cron`}),`·`,(0,X.jsx)(`code`,{children:`runAt`}),`·target port를 함께 저장해요.`]}),(0,X.jsx)(`li`,{children:`Run 버튼으로 즉시 dispatch, 대상 인스턴스가 바쁘면 자동 큐잉이에요. last/next 컬럼으로 실행 이력이 보여요.`}),(0,X.jsxs)(`li`,{children:[`예전엔 인스턴스마다 자기 `,(0,X.jsx)(`code`,{children:`heartbeat.json`}),`을 setInterval로 돌리던 구조였는데, 지금은 `,(0,X.jsx)(`strong`,{children:`매니저가 단일 ticker`}),`로 돌려요. heartbeat.json은 legacy로만 표시되고 자동 실행은 안 돼요.`]})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`실패를 볼 때`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`queued`}),(0,X.jsx)(`td`,{children:`대상 인스턴스가 바빠서 대기 중`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`blocked`}),(0,X.jsx)(`td`,{children:`비활성화했거나 실행 조건이 아직 맞지 않음`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`last/next`}),(0,X.jsx)(`td`,{children:`최근 실행 결과와 다음 실행 예측을 확인하는 기준`})]})]})})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`새 작업은 여기서 만들고, 기존 heartbeat job은 같은 cron으로 옮겨 등록하시면 돼요. 마이그레이션 자동화는 추후 추가됩니다.`})]}),br=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`p`,{className:`help-lead`,children:[(0,X.jsx)(`code`,{children:`~/.cli-jaw-dashboard/notes/`}),`의 마크다운 파일을 직접 편집하는 노트장이에요.`]}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[`좌측 트리에서 파일 선택, 우측에서 `,(0,X.jsx)(`strong`,{children:`Raw / Preview / WYSIWYG`}),` 모드로 편집하실 수 있어요.`]}),(0,X.jsxs)(`li`,{children:[`Instances Preview 채팅에서 vault 경로(예: `,(0,X.jsx)(`code`,{children:`~/.cli-jaw-dashboard/notes/foo.md`}),` 또는 `,(0,X.jsx)(`code`,{children:`daily/foo.md`}),`)를 `,(0,X.jsx)(`strong`,{children:`클릭`}),`하면 Notes 탭으로 이동하고 해당 파일이 열려요. 자동 전환은 없고 클릭할 때만 이동합니다.`]}),(0,X.jsxs)(`li`,{children:[`vault 밖 경로(예: 프로젝트 `,(0,X.jsx)(`code`,{children:`.ts`}),` 파일)는 기존처럼 Finder로 열려요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:`⌘/Ctrl + S`}),`로 저장, `,(0,X.jsx)(`kbd`,{children:`⌘/Ctrl + E`}),`로 모드 순환 전환이에요.`]}),(0,X.jsx)(`li`,{children:`파일이 외부에서 바뀌면 충돌 알림이 떠요 — Reload / Overwrite / Keep local 중 선택하세요.`})]}),(0,X.jsxs)(`p`,{className:`help-tip`,children:[`💡 좌측 트리 상단 `,(0,X.jsx)(`strong`,{children:`+ New`}),`로 첫 노트를 만들어 보세요. 폴더는 `,(0,X.jsx)(`code`,{children:`folder/note.md`}),` 처럼 한 번에 만드실 수 있어요.`]})]}),xr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`Jaw Reminders 스냅샷을 대시보드에서 읽고 확인하는 미러 화면이에요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`All / Focused / Scheduled / High / Done`}),` 보기로 현재 reminder 상태를 훑어볼 수 있어요.`]}),(0,X.jsx)(`li`,{children:`Refresh는 외부 Jaw Reminders 스냅샷을 다시 읽어서 대시보드용 row로 반영해요.`}),(0,X.jsx)(`li`,{children:`원본 reminder 저장소가 없거나 형식이 맞지 않아도 대시보드는 기존 미러 데이터를 유지하고 상태 메시지만 보여줘요.`})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`Matrix 보기`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Top Priority`}),(0,X.jsx)(`td`,{children:`지금 먼저 처리할 3개를 따로 고정`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Important`}),(0,X.jsx)(`td`,{children:`중요하지만 급하지 않은 장기 작업`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Waiting`}),(0,X.jsx)(`td`,{children:`다른 사람, 직원, 외부 검증을 기다리는 작업`})]})]})})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`Reminders는 실험 기능이라 개발 모드 또는 실험 플래그가 켜진 빌드에서만 보여요.`})]}),Sr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`대시보드 외형과 동작 옵션을 조정하는 곳이에요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsx)(`li`,{children:`사이드바 폭, 워드랩, 테마 같은 표시 옵션을 바꾸실 수 있어요.`}),(0,X.jsxs)(`li`,{children:[`인스턴스 자체 설정이 아니라 `,(0,X.jsx)(`strong`,{children:`이 대시보드 UI의 환경설정`}),`이에요.`]}),(0,X.jsx)(`li`,{children:`변경 사항은 즉시 저장돼요.`})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`설정 범위`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Display`}),(0,X.jsx)(`td`,{children:`목록, 언어, 단축키 같은 dashboard UI 선호도`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Activity`}),(0,X.jsx)(`td`,{children:`최근 작업 제목이 어떤 인스턴스에서 준비됐는지 확인`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`Instance settings`}),(0,X.jsx)(`td`,{children:`개별 인스턴스 동작은 Instances workspace에서 수정`})]})]})})]}),(0,X.jsxs)(`p`,{className:`help-tip`,children:[`인스턴스 동작을 바꾸시려면 여기가 아니라 `,(0,X.jsx)(`strong`,{children:`Instances → 해당 인스턴스 → Settings 탭`}),`으로 가세요.`]})]}),Cr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`반복 작업을 줄이는 Manager 전역 단축키예요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:`?`}),`는 이 도움말을 열어요. 입력창, 노트 에디터, WYSIWYG 편집 중에는 글자 입력을 방해하지 않아요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:ye(Se.focusInstances)}),`는 Instances workspace로 이동해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:ye(Se.focusActiveSession)}),`는 선택된 인스턴스의 Preview 탭으로 이동해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:ye(Se.focusNotes)}),`는 Notes workspace로 이동해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:ye(Se.previousInstance)}),` / `,(0,X.jsx)(`kbd`,{children:ye(Se.nextInstance)}),`는 현재 필터된 인스턴스 목록에서 이전/다음 행을 선택해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:`Alt+1`}),` … `,(0,X.jsx)(`kbd`,{children:`Alt+9`}),`는 렌더된 사이드바 행으로 점프하고, Alt를 200ms 누르면 행 오른쪽에 점프 힌트가 떠요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:`⌘/Ctrl + S`}),`는 Notes와 Settings처럼 저장 가능한 화면에서 현재 편집 내용을 저장해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`kbd`,{children:`⌘/Ctrl + E`}),`는 Notes 편집 모드를 순환해요.`]}),(0,X.jsx)(`li`,{children:`Manager 단축키는 Dashboard settings에서 켜고 끄거나 keymap을 바꿀 수 있어요.`}),(0,X.jsx)(`li`,{children:`Preview 탭을 보는 동안 새 activity는 읽음으로 처리되고, 다른 탭에 있을 때는 Activity Dock에 쌓여요.`})]}),(0,X.jsxs)(`div`,{className:`help-deep`,children:[(0,X.jsx)(`h4`,{children:`충돌이 날 때`}),(0,X.jsx)(`table`,{className:`help-table`,children:(0,X.jsxs)(`tbody`,{children:[(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`입력 중`}),(0,X.jsx)(`td`,{children:`글자 입력을 우선하고 전역 shortcut은 실행하지 않음`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`브라우저 충돌`}),(0,X.jsx)(`td`,{children:`Dashboard settings에서 keymap을 바꾸는 것이 안전함`})]}),(0,X.jsxs)(`tr`,{children:[(0,X.jsx)(`th`,{children:`도움말`}),(0,X.jsxs)(`td`,{children:[(0,X.jsx)(`kbd`,{children:`?`}),`는 현재 workspace 도움말과 shortcut 도움말의 진입점`]})]})]})})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`단축키는 브라우저 기본 단축키와 에디터 입력을 우선합니다.`})]}),wr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`jaw는 Boss가 직접 처리할지, Employee에게 보낼지 상황에 따라 나눠요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Boss`}),`는 현재 대화의 주 작업자예요. 단일 파일 수정, 상태 확인, GitHub 정리는 보통 Boss가 직접 처리해요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Employee`}),`는 `,(0,X.jsx)(`code`,{children:`cli-jaw dispatch`}),`로 보내는 독립 작업자예요. Backend, Frontend, Docs 같은 역할별 검증에 씁니다.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`PABCD`}),`에서는 A phase가 plan audit, B phase가 read-only verification 중심이에요. 구현은 Boss가 직접 합니다.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`$computer-use`}),` 요청은 desktop-control 규칙을 따라 real desktop 또는 browser automation 경로로 라우팅돼요.`]})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`직원이 다른 repo로 착각하지 않도록 dispatch task에는 현재 repo 절대경로를 함께 넣는 게 원칙이에요.`})]}),Tr=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`Process 상태는 인스턴스 실행과 Manager가 관리하는 preview/runtime 상태를 구분해서 봐야 해요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`online`}),`은 인스턴스 health check가 통과한 상태예요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`offline / timeout / error`}),`는 프로세스가 없거나, 응답이 늦거나, health check가 실패한 상태예요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`managed`}),`는 Manager가 띄우거나 복구 대상으로 추적하는 서버예요.`]}),(0,X.jsx)(`li`,{children:`탭 전환 후 Preview가 다시 붙을 수 있지만, 인스턴스의 실제 실행 여부는 health/status 쪽을 기준으로 보세요.`})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`Process UI가 비어 보이면 먼저 Refresh로 registry와 health 상태를 다시 읽어보세요.`})]}),Er=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`help-lead`,children:`실행 상태를 바꾸는 버튼은 현재 선택한 인스턴스나 Manager-managed 프로세스에 영향을 줘요.`}),(0,X.jsxs)(`ul`,{className:`help-bullets`,children:[(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Stop`}),`은 대상 인스턴스를 중지해요. service-owned 인스턴스는 persistent service 제거까지 포함될 수 있어요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Restart`}),`는 새 실행으로 바뀌므로 uptime과 elapsed time 판단 기준이 다시 시작돼요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Stop all managed`}),`는 Manager가 추적 중인 서버들을 한 번에 중지해요. 외부에서 직접 띄운 프로세스는 대상으로 삼지 않아요.`]}),(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`strong`,{children:`Adopt/recover`}),`는 남아 있는 managed process 기록을 다시 연결하려는 복구 작업이에요.`]})]}),(0,X.jsx)(`p`,{className:`help-tip`,children:`위험 작업은 가능한 한 확인창을 거치며, 진행 후 상태가 애매하면 Refresh로 실제 health를 확인하세요.`})]}),Dr={instances:{title:`Instances`,subtitle:`인스턴스 운영`,body:_r},board:{title:`Board`,subtitle:`Cross-instance Kanban`,body:vr},schedule:{title:`Schedule`,subtitle:`시간 기반 작업`,body:yr},reminders:{title:`Reminders`,subtitle:`Jaw Reminders mirror`,body:xr},notes:{title:`Notes`,subtitle:`마크다운 노트`,body:br},settings:{title:`Settings`,subtitle:`대시보드 설정`,body:Sr},shortcuts:{title:`Shortcuts`,subtitle:`전역 키보드 도움말`,body:Cr},routing:{title:`Routing`,subtitle:`Boss / Employee 작업 흐름`,body:wr},processLifecycle:{title:`Process lifecycle`,subtitle:`인스턴스와 managed process 상태`,body:Tr},dangerousActions:{title:`Dangerous actions`,subtitle:`중지·재시작·복구 작업 영향`,body:Er}};function Or({open:e,topic:t,onClose:n}){let r=(0,Y.useRef)(null);if((0,Y.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&n()};return document.addEventListener(`keydown`,t),r.current?.focus(),()=>document.removeEventListener(`keydown`,t)},[e,n]),!e)return null;let i=Dr[t];return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{className:`help-drawer-overlay`,onClick:n,"aria-hidden":`true`}),(0,X.jsxs)(`aside`,{className:`help-drawer`,role:`dialog`,"aria-modal":`true`,"aria-label":`${i.title} help`,children:[(0,X.jsxs)(`header`,{className:`help-drawer-header`,children:[(0,X.jsxs)(`div`,{className:`help-drawer-title`,children:[(0,X.jsx)(`span`,{className:`help-drawer-eyebrow`,children:`현재 모드`}),(0,X.jsx)(`h3`,{children:i.title}),(0,X.jsx)(`span`,{className:`help-drawer-subtitle`,children:i.subtitle})]}),(0,X.jsx)(`button`,{ref:r,type:`button`,className:`help-drawer-close`,onClick:n,"aria-label":`Close help`,children:`×`})]}),(0,X.jsx)(`div`,{className:`help-drawer-body`,children:i.body}),(0,X.jsx)(`footer`,{className:`help-drawer-footer`,children:(0,X.jsx)(`span`,{children:`사이드바 도움말은 현재 모드를 따르고, ? 키는 단축키 도움말을 열어요.`})})]})]})}function kr(e){switch(e.kind){case`scan-completed`:return{at:e.at,source:`scan`,message:`range ${e.from}-${e.to}, ${e.reachable} reachable`};case`scan-failed`:return{at:e.at,source:`error`,message:e.reason};case`lifecycle-result`:return{at:e.at,source:e.action,message:`:${e.port} ${e.status}`};case`health-changed`:return{at:e.at,source:`health`,message:`:${e.port} ${e.from} → ${e.to}`};case`instance-message`:{let t=e.title?.trim();return{at:e.at,source:`:${e.port}`,message:`${e.role}: ${t||`message #${e.messageId}`}`}}case`version-mismatch`:return{at:e.at,source:`version`,message:`:${e.port} ${e.expected||`?`} → ${e.seen}`};case`port-collision`:return{at:e.at,source:`collision`,message:`:${e.port} pids ${e.pids.join(`, `)}`};default:return{at:new Date().toISOString(),source:`event`,message:`unknown event`}}}var Ar={now:`Now`,earlier:`Earlier today`,yesterday:`Yesterday`,older:`Older`},jr=[`now`,`earlier`,`yesterday`,`older`],Mr=3e5;function Nr(e,t){return typeof e==`string`?{at:t,message:e}:`kind`in e?kr(e):e}function Pr(e,t){let n=Date.parse(e);if(Number.isNaN(n))return`older`;if(t.getTime()-n<=Mr)return`now`;let r=new Date(t);if(r.setHours(0,0,0,0),n>=r.getTime())return`earlier`;let i=new Date(r);return i.setDate(i.getDate()-1),n>=i.getTime()?`yesterday`:`older`}function Fr(e,t){let n=new Date(e);return Number.isNaN(n.getTime())?`—`:t===`now`||t===`earlier`?n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`}):t===`yesterday`?`Yesterday ${n.toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}`:n.toLocaleDateString([],{month:`short`,day:`numeric`})}function Ir(e){let t=(0,Y.useMemo)(()=>{let t=new Date,n=t.toISOString(),r={now:[],earlier:[],yesterday:[],older:[]};for(let i of e.entries){let e=Nr(i,n),a=Pr(e.at,t);r[a].push({...e,_bucket:a})}return r},[e.entries]);return e.entries.length===0?(0,X.jsx)(`div`,{className:`activity-list activity-list-empty`,role:`status`,children:(0,X.jsx)(`p`,{children:e.emptyMessage||`Activity will appear here as scans, lifecycle changes, and registry updates happen.`})}):(0,X.jsx)(`div`,{className:`activity-list`,role:`list`,"aria-label":`Recent activity grouped by time`,children:jr.map(e=>{let n=t[e];return n.length===0?null:(0,X.jsxs)(`section`,{className:`activity-group`,"aria-label":Ar[e],children:[(0,X.jsx)(`header`,{className:`activity-group-header`,children:Ar[e]}),n.map((t,n)=>(0,X.jsxs)(`article`,{className:`activity-entry`,role:`listitem`,children:[(0,X.jsx)(`time`,{className:`activity-entry-time`,dateTime:t.at,children:Fr(t.at,t._bucket)}),t.source&&(0,X.jsx)(`span`,{className:`activity-entry-source`,children:t.source}),(0,X.jsx)(`p`,{className:`activity-entry-message`,children:t.message})]},`${e}-${n}`))]},e)})})}var Lr=88,Rr=320;function zr(e){return Math.min(Rr,Math.max(Lr,Math.round(e)))}function Br(e){let t=(0,Y.useRef)(null),{onHeightChange:n}=e,r=Vr(e);(0,Y.useEffect)(()=>{function e(e){let r=t.current;r&&n(zr(r.startHeight+r.startY-e.clientY))}function r(){t.current=null,document.body.classList.remove(`is-resizing-activity`)}return document.addEventListener(`pointermove`,e),document.addEventListener(`pointerup`,r),()=>{document.removeEventListener(`pointermove`,e),document.removeEventListener(`pointerup`,r),document.body.classList.remove(`is-resizing-activity`)}},[n]);function i(n){e.collapsed||(n.preventDefault(),t.current={startY:n.clientY,startHeight:e.height},document.body.classList.add(`is-resizing-activity`))}return(0,X.jsxs)(`aside`,{className:`activity-dock ${e.collapsed?`is-collapsed`:``}`,"aria-label":`Activity dock`,children:[(0,X.jsx)(`button`,{className:`activity-resize-handle`,type:`button`,"aria-label":`Resize activity dock`,title:`Resize activity dock`,onPointerDown:i,disabled:e.collapsed}),(0,X.jsxs)(`div`,{className:`activity-header`,children:[(0,X.jsx)(`span`,{children:`Activity`}),(0,X.jsx)(`button`,{type:`button`,onClick:e.onToggle,children:e.collapsed?`Expand`:`Collapse`})]}),!e.collapsed&&(0,X.jsx)(Ir,{entries:r})]})}function Vr(e){return(0,Y.useMemo)(()=>{let t=[];if(e.events&&e.events.length>0)for(let n of e.events)t.push(n);let n=new Date().toISOString();return e.error&&t.push({at:n,source:`error`,message:e.error}),e.registryMessage&&t.push({at:n,source:`registry`,message:e.registryMessage}),e.lifecycleMessage&&t.push({at:n,source:`lifecycle`,message:e.lifecycleMessage}),t.length===0&&t.push({at:n,source:`scan`,message:e.loading?`scanning local ports`:`no recent activity`}),t},[e.events,e.loading,e.error,e.registryMessage,e.lifecycleMessage])}function Hr(e){let{children:t,onClose:n,open:r}=e,i=(0,Y.useRef)(null),a=(0,Y.useRef)(null);return(0,Y.useEffect)(()=>{if(r)return a.current=document.activeElement,i.current?.focus(),()=>a.current?.focus()},[r]),(0,Y.useEffect)(()=>{if(!r)return;function e(e){e.key===`Escape`&&n()}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n,r]),r?(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:n,children:(0,X.jsxs)(`aside`,{className:`instance-drawer`,role:`dialog`,"aria-modal":`true`,"aria-label":`Instance drawer`,onClick:e=>e.stopPropagation(),children:[(0,X.jsxs)(`div`,{className:`drawer-header`,children:[(0,X.jsx)(`span`,{children:`Instances`}),(0,X.jsx)(`button`,{ref:i,type:`button`,onClick:n,children:`Close`})]}),(0,X.jsxs)(`div`,{className:`drawer-body`,children:[e.profileFilters&&(0,X.jsx)(`div`,{className:`drawer-profile-filters`,children:e.profileFilters}),t]})]})}):null}function Ur(e){return(0,Y.useEffect)(()=>{let e=Jt({delayMs:200,onVisibilityChange:$t}),t=t=>{e.sync(en(t))},n=t=>{e.sync(en(t))};return window.addEventListener(`keydown`,t),window.addEventListener(`keyup`,n),()=>{window.removeEventListener(`keydown`,t),window.removeEventListener(`keyup`,n),e.dispose(),$t(!1)}},[]),e.collapsed?(0,X.jsx)(`div`,{className:`instance-navigator is-collapsed`,children:e.children}):(0,X.jsxs)(`section`,{className:`instance-navigator`,"aria-label":`Instance navigator`,children:[(0,X.jsxs)(`header`,{className:`instance-navigator-header`,children:[(0,X.jsx)(`strong`,{children:`Instances`}),e.hiddenCount>0?(0,X.jsxs)(`span`,{children:[e.hiddenCount,` hidden`]}):null,(0,X.jsxs)(`label`,{className:`instance-navigator-search`,children:[(0,X.jsx)(`span`,{className:`visually-hidden`,children:`Search instances`}),(0,X.jsx)(`input`,{id:`manager-sidebar-search`,value:e.query,placeholder:`Search instances`,"aria-label":`Search instances`,onChange:t=>e.onQueryChange(t.currentTarget.value),onKeyDown:t=>{t.nativeEvent.isComposing||t.keyCode===229||t.key===`Escape`&&(t.preventDefault(),e.onQueryChange(``))}})]})]}),(0,X.jsx)(`div`,{className:`instance-navigator-scroll`,onKeyDown:t=>nn(t.nativeEvent,t.currentTarget,e.onSelectPort),children:e.children})]})}function Wr(e){return(0,X.jsxs)(`div`,{className:`mobile-nav-actions`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:e.onOpenInstances,children:`Instances`}),(0,X.jsx)(`button`,{type:`button`,className:e.activeTab===`preview`?`is-active`:``,onClick:()=>e.onSelectTab(`preview`),children:`Preview`}),(0,X.jsx)(`button`,{type:`button`,onClick:e.onToggleActivity,children:`Activity`}),(0,X.jsx)(`button`,{type:`button`,className:e.activeTab===`settings`?`is-active`:``,onClick:()=>e.onSelectTab(`settings`),children:`More`})]})}function Gr({direction:e}){return(0,X.jsx)(`svg`,{className:`rail-collapse-chevron`,viewBox:`0 0 16 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`polyline`,{points:e===`left`?`11 4 5 10 11 16`:`5 4 11 10 5 16`})})}function Kr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`4`,width:`14`,height:`10`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M8 17h4M10 14v3`})]})}function qr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M6 3h6l3 3v11H6z`}),(0,X.jsx)(`path`,{d:`M12 3v4h3M8 10h5M8 13h5`})]})}function Jr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`4`,width:`14`,height:`12`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M7 4v12M13 4v12`})]})}function Yr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`3`,y:`5`,width:`14`,height:`12`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M3 9h14M7 3v4M13 3v4`})]})}function Xr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M5 4h10v13H5z`}),(0,X.jsx)(`path`,{d:`M8 2v4M12 2v4M8 10h4M8 13h3`})]})}function Zr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 24 24`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915`}),(0,X.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`})]})}function Qr(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`18`,height:`18`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`circle`,{cx:`10`,cy:`10`,r:`7`}),(0,X.jsx)(`path`,{d:`M7.6 7.6a2.4 2.4 0 0 1 4.8 0c0 1.4-1.6 1.7-2.2 2.5-.3.4-.3.8-.3 1.2`}),(0,X.jsx)(`circle`,{cx:`10`,cy:`14.2`,r:`0.6`,fill:`currentColor`,stroke:`none`})]})}function $r(e){let t=!e.collapsed,n=t?`Collapse navigation`:`Expand navigation`;return(0,X.jsxs)(`div`,{className:`sidebar-rail`,children:[(0,X.jsx)(`button`,{className:`rail-collapse-button`,type:`button`,onClick:e.onToggleSidebar,"aria-label":n,"aria-expanded":t,"aria-pressed":e.collapsed,"aria-controls":`manager-sidebar-list`,title:n,children:(0,X.jsx)(Gr,{direction:t?`left`:`right`})}),(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`instances`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`instances`),"aria-label":`Instances`,"aria-pressed":e.mode===`instances`,title:`Instances`,children:(0,X.jsx)(Kr,{})}),(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`board`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`board`),"aria-label":`Board`,"aria-pressed":e.mode===`board`,title:`Board`,children:(0,X.jsx)(Jr,{})}),e.scheduleWorkspaceEnabled?(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`schedule`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`schedule`),"aria-label":`Schedule`,"aria-pressed":e.mode===`schedule`,title:`Schedule`,children:(0,X.jsx)(Yr,{})}):null,e.remindersWorkspaceEnabled?(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`reminders`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`reminders`),"aria-label":`Reminders`,"aria-pressed":e.mode===`reminders`,title:`Reminders`,children:(0,X.jsx)(Xr,{})}):null,(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`notes`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`notes`),"aria-label":`Notes`,"aria-pressed":e.mode===`notes`,title:`Notes`,children:(0,X.jsx)(qr,{})}),(0,X.jsx)(`button`,{className:`rail-button rail-workspace-button${e.mode===`settings`?` is-active`:``}`,type:`button`,onClick:()=>e.onModeChange(`settings`),"aria-label":`Dashboard settings`,"aria-pressed":e.mode===`settings`,title:`Dashboard settings`,children:(0,X.jsx)(Zr,{})}),(0,X.jsx)(`div`,{className:`rail-spacer`,"aria-hidden":`true`}),(0,X.jsx)(`button`,{className:`rail-button rail-help-button${e.helpOpen?` is-active`:``}`,type:`button`,onClick:e.onToggleHelp,"aria-label":`Help guide`,"aria-pressed":e.helpOpen,"aria-expanded":e.helpOpen,title:`Help (?)`,children:(0,X.jsx)(Qr,{})}),(0,X.jsx)(`span`,{className:`rail-status-dot`,"aria-label":`${e.onlineCount} online instances`})]})}var ei=[`overview`,`preview`,`logs`];function ti(e){return e[0].toUpperCase()+e.slice(1)}function ni(e){return(0,X.jsxs)(`section`,{className:`workbench workbench-${e.mode}`,"aria-label":`Selected instance workbench`,children:[(0,X.jsxs)(`div`,{className:`workbench-header`,children:[e.header,(0,X.jsxs)(`div`,{className:`workbench-mode-bar`,children:[(0,X.jsx)(`div`,{className:`workbench-mode-tabs`,role:`tablist`,"aria-label":`Workbench modes`,onKeyDown:t=>{if(t.key!==`ArrowRight`&&t.key!==`ArrowLeft`)return;let n=ei[(ei.indexOf(e.mode)+(t.key===`ArrowRight`?1:ei.length-1))%ei.length];t.preventDefault(),e.onModeChange(n),t.currentTarget.querySelector(`[data-mode="${n}"]`)?.focus()},children:ei.map(t=>(0,X.jsx)(`button`,{type:`button`,role:`tab`,id:`workbench-tab-${t}`,"data-mode":t,"aria-selected":e.mode===t,"aria-controls":`workbench-panel-${t}`,tabIndex:e.mode===t?0:-1,className:e.mode===t?`is-active`:``,onClick:()=>e.onModeChange(t),children:ti(t)},t))}),e.modeActions]})]}),(0,X.jsxs)(`div`,{className:`workbench-body`,children:[e.mode===`overview`&&(0,X.jsx)(`div`,{id:`workbench-panel-overview`,role:`tabpanel`,"aria-labelledby":`workbench-tab-overview`,className:`workbench-panel workbench-panel-overview`,children:e.overview},`overview`),(0,X.jsx)(`div`,{id:`workbench-panel-preview`,role:`tabpanel`,"aria-labelledby":`workbench-tab-preview`,className:`workbench-panel workbench-panel-preview`,hidden:e.mode!==`preview`,"aria-hidden":e.mode!==`preview`,"data-preview-host":`persistent`,children:e.preview},`preview`),e.mode===`logs`&&(0,X.jsx)(`div`,{id:`workbench-panel-logs`,role:`tabpanel`,"aria-labelledby":`workbench-tab-logs`,className:`workbench-panel workbench-panel-logs`,children:e.logs},`logs`)]})]})}function ri(e){let t=(0,Y.useRef)(!1),n=(0,Y.useRef)(0),r=(0,Y.useRef)(0),i=(0,Y.useRef)(!1),a=(0,Y.useRef)(e.onDelta),o=(0,Y.useRef)(e.onEnd),[s,c]=(0,Y.useState)(!1),{direction:l}=e;(0,Y.useEffect)(()=>{a.current=e.onDelta,o.current=e.onEnd},[e.onDelta,e.onEnd]);let u=(0,Y.useCallback)((e,o)=>{if(!t.current)return;let s=l===`horizontal`?e:o;if(!i.current){if(Math.abs(s-r.current)<=2)return;i.current=!0}let c=s-n.current;n.current=s,c!==0&&a.current(c)},[l]),d=(0,Y.useCallback)(e=>{t.current&&(e.preventDefault(),u(e.clientX,e.clientY))},[u]),f=(0,Y.useCallback)(e=>{t.current&&(e.preventDefault(),u(e.clientX,e.clientY))},[u]),p=(0,Y.useCallback)(()=>{t.current&&(t.current=!1,c(!1),document.body.classList.remove(`is-resizing-horizontal`,`is-resizing-vertical`),o.current?.())},[]);(0,Y.useEffect)(()=>{let e={capture:!0};return document.addEventListener(`pointermove`,d,e),document.addEventListener(`pointerup`,p,e),document.addEventListener(`pointercancel`,p,e),document.addEventListener(`mousemove`,f,e),document.addEventListener(`mouseup`,p,e),window.addEventListener(`pointermove`,d,e),window.addEventListener(`pointerup`,p,e),window.addEventListener(`pointercancel`,p,e),window.addEventListener(`mousemove`,f,e),window.addEventListener(`mouseup`,p,e),window.addEventListener(`blur`,p),()=>{document.removeEventListener(`pointermove`,d,e),document.removeEventListener(`pointerup`,p,e),document.removeEventListener(`pointercancel`,p,e),document.removeEventListener(`mousemove`,f,e),document.removeEventListener(`mouseup`,p,e),window.removeEventListener(`pointermove`,d,e),window.removeEventListener(`pointerup`,p,e),window.removeEventListener(`pointercancel`,p,e),window.removeEventListener(`mousemove`,f,e),window.removeEventListener(`mouseup`,p,e),window.removeEventListener(`blur`,p),document.body.classList.remove(`is-resizing-horizontal`,`is-resizing-vertical`)}},[f,d,p]);function m(e){e.preventDefault(),e.stopPropagation(),e.currentTarget.setPointerCapture(e.pointerId),g(e.clientX,e.clientY)}function h(e){e.preventDefault(),e.stopPropagation(),g(e.clientX,e.clientY)}function g(e,a){t.current=!0,i.current=!1,c(!0),r.current=l===`horizontal`?e:a,n.current=r.current,document.body.classList.add(l===`horizontal`?`is-resizing-horizontal`:`is-resizing-vertical`)}function _(e){e.preventDefault(),u(e.clientX,e.clientY)}function v(e){e.preventDefault(),p()}function y(e){e.preventDefault(),u(e.clientX,e.clientY)}function b(e){e.preventDefault(),p()}function x(e){if(e.nativeEvent.isComposing||e.keyCode===229||e.altKey||e.ctrlKey||e.metaKey||e.shiftKey)return;let t=l===`horizontal`?`ArrowLeft`:`ArrowUp`,n=l===`horizontal`?`ArrowRight`:`ArrowDown`;(e.key===t||e.key===n)&&(e.preventDefault(),a.current(e.key===t?-10:10),o.current?.())}return(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`div`,{role:`separator`,tabIndex:0,className:`panel-resizer panel-resizer-${l} ${e.className??``}`,"aria-label":e.ariaLabel??`Resize ${l===`horizontal`?`width`:`height`}`,"aria-valuenow":e.ariaValueNow,"aria-valuetext":e.ariaValueNow===void 0?void 0:`${e.ariaValueNow}px`,"aria-orientation":l===`horizontal`?`vertical`:`horizontal`,onPointerDown:m,onMouseDown:h,onLostPointerCapture:p,onKeyDown:x,onDoubleClick:e.onDoubleClick}),s&&(0,X.jsx)(`div`,{"aria-hidden":`true`,className:`panel-resize-overlay panel-resize-overlay-${l}`,onPointerMove:_,onPointerUp:v,onPointerCancel:v,onMouseMove:y,onMouseUp:b})]})}function ii(e){return(0,X.jsx)(ri,{direction:`horizontal`,onDelta:e.onDelta,onEnd:e.onEnd,onDoubleClick:e.onDoubleClick,className:`sidebar-resize-handle`,ariaLabel:`Resize sidebar`,ariaValueNow:e.width})}var ai=`jaw.sidebarWidth`;function oi(e){let t=640+(e.rightPanelOpen?Math.max(0,e.rightPanelWidth):0);return Math.max(220,Math.floor(e.viewportWidth)-t)}function si(e,t){let n=oi(t);return Math.min(n,Math.max(220,Number.isFinite(e)?Math.round(e):300))}function ci(){try{if(typeof localStorage>`u`)return null;let e=localStorage.getItem(ai);if(e==null||e.trim()===``)return null;let t=Number(e);return Number.isFinite(t)?t:null}catch{return null}}function li(e){try{localStorage.setItem(ai,String(e))}catch{}}function ui(){try{localStorage.removeItem(ai)}catch{}}function di(e){return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)}function fi(){return typeof window>`u`?1440:window.innerWidth}function pi(e){let t=(0,Y.useSyncExternalStore)(di,fi,()=>1440),n={viewportWidth:t,rightPanelOpen:e.rightPanelOpen,rightPanelWidth:e.rightPanelWidth},[r,i]=(0,Y.useState)(()=>Math.max(220,ci()??300)),a=(0,Y.useRef)(r);return{width:si(r,n),addDelta:(0,Y.useCallback)(e=>{let t=si(si(a.current,n)+e,n);a.current=t,i(t)},[n.viewportWidth,n.rightPanelOpen,n.rightPanelWidth]),persist:(0,Y.useCallback)(()=>{li(a.current)},[]),reset:(0,Y.useCallback)(()=>{ui(),a.current=300,i(300)},[]),viewportWidth:t}}var mi=260,hi=200;function gi(){return typeof window>`u`?1440:window.innerWidth}function _i(){let[e,t]=(0,Y.useState)(gi);return(0,Y.useEffect)(()=>{let e=()=>t(gi());return window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[]),e}function vi(e,t,n){let r=typeof e==`number`&&Number.isFinite(e)?Math.round(e):480,i=Math.max(mi,n-t-hi);return Math.max(mi,Math.min(r,i))}function yi(e){let t=_i(),n=e.sidebarCollapsed?44:e.sidebarWidth,r=e.rightPanelOpen?vi(e.rightPanelWidth,n,t):0,i={"--activity-dock-height":`${e.inspectorHeight}px`,"--sidebar-width":e.sidebarCollapsed?`44px`:`${e.sidebarWidth}px`,"--right-panel-width":e.rightPanelOpen?`${r}px`:e.sidePanel?void 0:`0px`,"--bottom-panel-height":e.bottomPanelOpen?`${e.bottomPanelHeight??0}px`:void 0},a=[`manager-workspace`,e.sidebarCollapsed&&`is-sidebar-collapsed`,e.inspectorCollapsed&&`is-inspector-collapsed`,e.rightPanelOpen&&`is-right-panel-open`,!e.rightPanelOpen&&!e.sidePanel&&`is-right-panel-closed`,e.bottomPanelOpen&&`is-bottom-panel-open`,!e.bottomPanelOpen&&`is-bottom-panel-closed`,e.sidePanel&&`is-side-panel-open`,e.drawerOpen&&`is-drawer-open`].filter(Boolean).join(` `);return(0,X.jsxs)(`div`,{className:a,style:i,children:[e.drawerOpen&&(0,X.jsx)(`div`,{className:`drawer-backdrop`,onClick:e.onCloseDrawer}),(0,X.jsx)(`aside`,{className:`manager-sidebar`,"aria-label":e.navigatorLabel??`Jaw instances`,children:e.navigator}),!e.sidebarCollapsed&&t>=1024&&(0,X.jsx)(ii,{width:e.sidebarWidth,onDelta:e.onSidebarWidthDelta,onEnd:e.onSidebarWidthEnd,onDoubleClick:e.onSidebarWidthReset}),(0,X.jsx)(`section`,{className:`manager-detail`,"aria-label":`Manager workbench`,children:e.workbench}),(0,X.jsx)(`section`,{className:`manager-activity`,"aria-label":`Manager inspector`,children:e.inspector}),e.sidePanel&&(0,X.jsx)(`aside`,{className:`manager-ceo-panel`,"aria-label":`Jaw CEO console`,children:e.sidePanel}),e.rightPanelContent,e.bottomPanelContent,(0,X.jsx)(`nav`,{className:`manager-mobile-nav`,"aria-label":`Mobile dashboard navigation`,children:e.mobileNav}),e.drawer]})}function bi(e){let t=N[e.kind],n=e.sourceLabel??e.specificName;return{visibleLabel:e.specificName,title:`${t}: ${n}`,ariaLabel:`${t} tab, ${n}`}}function xi(e){return e<=2?`comfortable`:e<=4?`compact`:`mini`}var Si=class extends Y.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[panel-error] ${this.props.label}:`,e,t.componentStack)}handleRetry=()=>{this.setState({error:null})};render(){return this.state.error?(0,X.jsxs)(`div`,{className:`panel-error-boundary`,role:`alert`,children:[(0,X.jsxs)(`div`,{className:`panel-error-title`,children:[this.props.label,` panel crashed`]}),(0,X.jsx)(`pre`,{className:`panel-error-message`,children:this.state.error.message}),(0,X.jsx)(`button`,{type:`button`,className:`panel-error-retry`,onClick:this.handleRetry,children:`Retry`})]}):this.props.children}};function Ci(){return(0,X.jsx)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`path`,{d:`M6 6l8 8M14 6l-8 8`})})}function wi(){return(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`11`,height:`11`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`})})}function Ti(){return(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`path`,{d:`M8 3v10M3 8h10`})})}function Ei(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M2 4.5h4.5L8 6h6v6.5a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4.5Z`}),(0,X.jsx)(`path`,{d:`M2 4.5V3.5a1 1 0 0 1 1-1h2.5L7 4h5a1 1 0 0 1 1 1v1`})]})}function Di(){return(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:(0,X.jsx)(`path`,{d:`M4 3v10M12 3v10M4 8h8`})})}function Oi(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`rect`,{x:`2`,y:`2`,width:`12`,height:`12`,rx:`1.5`}),(0,X.jsx)(`path`,{d:`M2 5.5h12`})]})}function ki(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.4`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M9.5 3.5l3 3L6 13H3v-3Z`}),(0,X.jsx)(`path`,{d:`M8 5l3 3`}),(0,X.jsx)(`path`,{d:`M12.5 6.5l1-1a1.4 1.4 0 0 0 0-2l-1-1a1.4 1.4 0 0 0-2 0l-1 1`})]})}function Ai(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M3 6.5h5l1.4 1.8H17v6.2A1.5 1.5 0 0 1 15.5 16h-11A1.5 1.5 0 0 1 3 14.5v-8Z`}),(0,X.jsx)(`path`,{d:`M3 6.5V5a1.5 1.5 0 0 1 1.5-1.5h3L9 5.5h6.5A1.5 1.5 0 0 1 17 7v1.3`})]})}function ji(){return(0,X.jsx)(`span`,{className:`right-breadcrumb-sep`,"aria-hidden":`true`,children:`>`})}var Mi={files:Ei,diff:Di,browser:Oi,design:ki};function Ni(e){if(!e)return[];let t=e.replace(/\\/g,`/`).split(`/`).filter(Boolean);return t.length>0&&t[0]===``&&t.shift(),t}var Pi=[`files`,`diff`,`browser`,`design`];function Fi(e){let{state:t,dispatch:n,effectiveRightOpen:r,activeRightTabKind:i}=pe(),a=t.rightPanel,o=(0,Y.useRef)(a.width);(0,Y.useEffect)(()=>{o.current=a.width},[a.width]);let s=(0,Y.useCallback)(e=>{let t=o.current-e;o.current=t,n({type:`SET_RIGHT_WIDTH`,width:t})},[n]),c=(0,Y.useCallback)(()=>{},[]),[l,u]=(0,Y.useState)(!1),d=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(!l)return;function e(e){d.current&&!d.current.contains(e.target)&&u(!1)}return document.addEventListener(`click`,e,!0),()=>document.removeEventListener(`click`,e,!0)},[l]);let f=a.tabs.openTabs,p=a.tabs.activeTabId,m=f.find(e=>e.id===p)??null,h=a.fileFolderLayout,g=m?.kind===`files`?m.files?.activeFilePath??null:null,_=xi(f.length),v=f.some(e=>e.kind===`diff`),y=Pi.filter(e=>!(e===`diff`&&v)),b=h.mode!==`file-only`,x=b?`Hide folder pane`:`Show folder pane`,S=(0,Y.useCallback)(()=>{h.mode===`file-only`?n({type:`RESTORE_FILE_FOLDER_SPLIT`}):n({type:`SET_FILE_FOLDER_VIEW_MODE`,mode:`file-only`})},[n,h.mode]),C=(0,Y.useCallback)(()=>{let e=M()?.folder;(async()=>{if(e?.pickFile){let t=await e.pickFile();t?.ok&&t.path&&n({type:`OPEN_FILE_IN_FILES_TAB`,path:t.path});return}e?.pickFolder&&await e.pickFolder()})()},[n]),w=(0,Y.useCallback)(e=>{n({type:`FOCUS_OR_CREATE_FIRST_RIGHT_SIDEBAR_TAB`,kind:e})},[n]),T=(0,Y.useCallback)(e=>{n({type:`CREATE_RIGHT_SIDEBAR_TAB`,kind:e}),u(!1)},[n]),E=(0,Y.useCallback)((e,t)=>{e.target===e.currentTarget&&(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),n({type:`ACTIVATE_RIGHT_SIDEBAR_TAB`,tabId:t}))},[n]),D=Ni(g),O=l?(0,X.jsx)(`div`,{className:`right-sidebar-plus-menu`,role:`menu`,children:y.map(e=>(0,X.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`right-sidebar-plus-menu-item`,onClick:()=>T(e),children:[Mi[e](),(0,X.jsx)(`span`,{children:N[e]})]},e))}):null;return!r||f.length===0?a.open&&f.length===0?(0,X.jsxs)(`aside`,{className:`right-panel`,"aria-label":`Right sidebar`,children:[(0,X.jsx)(ri,{direction:`horizontal`,onDelta:s,onEnd:c}),(0,X.jsxs)(`div`,{className:`right-panel-shell`,children:[(0,X.jsx)(`div`,{className:`right-panel-toolbar`,children:(0,X.jsx)(`button`,{type:`button`,className:`right-panel-close`,"aria-label":`Close right sidebar`,title:`Close`,onClick:()=>n({type:`SET_RIGHT_OPEN`,open:!1}),children:(0,X.jsx)(Ci,{})})}),(0,X.jsx)(`div`,{className:`right-panel-body is-single-panel`,children:(0,X.jsx)(`div`,{className:`right-sidebar-empty-state`,"aria-label":`No open tabs`,children:(0,X.jsxs)(`div`,{className:`right-sidebar-empty-plus-wrap`,ref:d,children:[(0,X.jsx)(`button`,{type:`button`,className:`right-sidebar-empty-plus`,"aria-label":`Open panel tab`,"aria-haspopup":`menu`,"aria-expanded":l,title:`Open panel tab`,onClick:()=>u(e=>!e),children:(0,X.jsx)(Ti,{})}),O]})})})]})]}):null:(0,X.jsxs)(`aside`,{className:`right-panel`,"aria-label":`Right sidebar`,children:[(0,X.jsx)(ri,{direction:`horizontal`,onDelta:s,onEnd:c}),(0,X.jsxs)(`div`,{className:`right-panel-shell`,children:[(0,X.jsxs)(`div`,{className:`right-launcher-row`,"aria-label":`Panel launchers`,children:[(0,X.jsx)(`div`,{className:`right-launcher-group`,children:Pi.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`right-launcher-button${i===e?` is-active`:``}`,"aria-label":N[e],"aria-pressed":i===e,title:N[e],onClick:()=>w(e),children:Mi[e]()},e))}),(0,X.jsx)(`button`,{type:`button`,className:`right-panel-close`,"aria-label":`Close right sidebar`,title:`Close`,onClick:()=>n({type:`SET_RIGHT_OPEN`,open:!1}),children:(0,X.jsx)(Ci,{})})]}),(0,X.jsxs)(`div`,{className:`right-sidebar-tab-strip`,"data-density":_,children:[(0,X.jsx)(`div`,{className:`right-sidebar-tabs`,role:`tablist`,"aria-label":`Open panel tabs`,children:f.map(e=>{let t=e.id===p,r=Mi[e.kind],i=bi(e);return(0,X.jsxs)(`div`,{role:`tab`,tabIndex:0,className:`right-sidebar-tab${t?` is-active`:``}`,"aria-selected":t,"aria-label":i.ariaLabel,title:i.title,onClick:()=>n({type:`ACTIVATE_RIGHT_SIDEBAR_TAB`,tabId:e.id}),onKeyDown:t=>E(t,e.id),children:[(0,X.jsx)(r,{}),(0,X.jsx)(`span`,{className:`right-sidebar-tab-label`,children:i.visibleLabel}),(0,X.jsx)(`button`,{type:`button`,className:`right-sidebar-tab-close`,"aria-label":`Close ${i.ariaLabel}`,title:`Close ${i.visibleLabel}`,onClick:t=>{t.stopPropagation(),n({type:`CLOSE_RIGHT_SIDEBAR_TAB`,tabId:e.id})},children:(0,X.jsx)(wi,{})})]},e.id)})}),(0,X.jsxs)(`div`,{className:`right-sidebar-plus-wrap`,ref:d,children:[(0,X.jsx)(`button`,{type:`button`,className:`right-sidebar-plus`,"aria-label":`Open panel tab`,"aria-haspopup":`menu`,"aria-expanded":l,title:`Open panel tab`,onClick:()=>u(e=>!e),children:(0,X.jsx)(Ti,{})}),O]})]}),i===`files`&&(0,X.jsx)(`div`,{className:`right-files-chrome`,"aria-label":`Files tab chrome`,children:(0,X.jsxs)(`div`,{className:`right-files-toolbar`,children:[(0,X.jsx)(`nav`,{className:`right-breadcrumb`,"aria-label":`File path breadcrumb`,children:D.map((e,t)=>{let n=t===D.length-1;return(0,X.jsxs)(`span`,{className:`right-breadcrumb-item`,children:[t>0&&(0,X.jsx)(ji,{}),(0,X.jsx)(`span`,{className:`right-breadcrumb-segment${n?` is-final`:``}`,title:e,children:e})]},t)})}),e.onLoadProjectFolder&&(0,X.jsx)(`button`,{type:`button`,className:`right-files-load-folder`,title:`Load project folder`,disabled:e.loadProjectFolderDisabled===!0,onClick:e.onLoadProjectFolder,children:`불러오기`}),(0,X.jsx)(`button`,{type:`button`,className:`right-files-open-file`,title:`Open file`,onClick:C,children:`Open file`}),(0,X.jsx)(`button`,{type:`button`,className:`right-files-folder-toggle`,"aria-pressed":b,title:x,onClick:S,children:(0,X.jsx)(Ai,{})})]})}),(0,X.jsx)(`div`,{className:`right-panel-body is-single-panel`,children:m&&(0,X.jsx)(`div`,{className:`right-sub-panel`,"aria-label":bi(m).ariaLabel,children:(0,X.jsx)(`div`,{className:`right-sub-content`,children:(0,X.jsx)(Si,{label:N[m.kind],children:e.renderPanel(m.kind,m)})})},m.id)})]})]})}var Ii={activity:`Activity`,terminal:`Terminal`,browser:`Browser`,logs:`Logs`};function Li(e){function t(t){let n=e.tabs,r=e.activeTab?n.indexOf(e.activeTab):-1;if(t.key===`ArrowRight`||t.key===`ArrowLeft`){t.preventDefault();let i=n[(r+(t.key===`ArrowRight`?1:-1)+n.length)%n.length];i&&e.onActivate(i)}else if(t.key===`Home`)t.preventDefault(),n[0]&&e.onActivate(n[0]);else if(t.key===`End`){t.preventDefault();let r=n[n.length-1];r&&e.onActivate(r)}}return(0,X.jsxs)(`div`,{className:`bottom-tab-bar`,role:`tablist`,onKeyDown:t,children:[e.tabs.map(t=>(0,X.jsxs)(`div`,{className:`bottom-tab-item ${t===e.activeTab?`is-active`:``}`,role:`presentation`,children:[(0,X.jsx)(`button`,{type:`button`,role:`tab`,className:`bottom-tab ${t===e.activeTab?`is-active`:``}`,"aria-selected":t===e.activeTab,tabIndex:t===e.activeTab?0:-1,onClick:()=>e.onActivate(t),children:(0,X.jsx)(`span`,{children:Ii[t]})}),(0,X.jsx)(`button`,{type:`button`,className:`bottom-tab-close`,"aria-label":`Close ${Ii[t]}`,title:`Close ${Ii[t]}`,onClick:()=>e.onClose(t),children:`×`})]},t)),(0,X.jsx)(`button`,{type:`button`,className:`bottom-collapse-button`,"aria-label":`Collapse panel`,onClick:e.onCollapse,children:`▼`})]})}var Ri=[`terminal`,`browser`];function zi(e){let{state:t,dispatch:n}=pe(),r=t.bottomPanel,i=(0,Y.useCallback)(e=>{n({type:`SET_BOTTOM_HEIGHT`,height:r.height-e})},[n,r.height]),a=(0,Y.useCallback)(()=>{n({type:`SET_BOTTOM_OPEN`,open:!1})},[n]),o=r.activeTab??r.tabs[0]??null,s=o!==null&&Ri.includes(o);return r.tabs.length===0?null:(0,X.jsxs)(`div`,{className:`bottom-panel ${s?`has-content-owned-chrome`:``}`,"aria-label":`Bottom panel`,"aria-hidden":!r.open,children:[(0,X.jsx)(ri,{direction:`vertical`,onDelta:i,ariaLabel:`Resize bottom panel height`,ariaValueNow:r.height}),!s&&(0,X.jsx)(Li,{tabs:r.tabs,activeTab:r.activeTab,onActivate:e=>n({type:`SET_BOTTOM_ACTIVE_TAB`,tab:e}),onClose:e=>n({type:`CLOSE_BOTTOM_TAB`,tab:e}),onCollapse:a}),(0,X.jsx)(`div`,{className:`bottom-panel-content`,children:o&&e.renderTab(o,{onCollapse:a,onCloseTab:()=>n({type:`CLOSE_BOTTOM_TAB`,tab:o}),ownsChrome:s})})]})}function Bi(e){let{state:t,dispatch:n}=pe(),r=t.rightPanel.fileFolderLayout,i=r.mode,a=r.splitRatio,o=(0,Y.useRef)(null),s=(0,Y.useCallback)(e=>{let r=o.current;if(!r)return;let i=r.offsetWidth;if(i<=0)return;let a=e/i,s=t.rightPanel.fileFolderLayout.splitRatio,c=Math.max(0,Math.min(1,s+a));n({type:`SET_FILE_FOLDER_SPLIT_RATIO`,ratio:c})},[n,t.rightPanel.fileFolderLayout.splitRatio]),c=(0,Y.useCallback)(()=>{},[]),l=i===`folder-only`?{display:`none`}:i===`file-only`?{flex:`1 1 100%`,minWidth:0}:{flex:`0 0 ${(a*100).toFixed(2)}%`,minWidth:0},u=i===`file-only`?{display:`none`}:i===`folder-only`?{flex:`1 1 100%`,minWidth:0}:{flex:`1 1 0%`,minWidth:0},d=i===`split`;return(0,X.jsxs)(`div`,{className:`file-folder-split-panel`,ref:o,"data-mode":i,children:[(0,X.jsx)(`div`,{className:`file-folder-split-file-pane`,style:l,children:e.filePane}),d&&(0,X.jsx)(ri,{direction:`horizontal`,onDelta:s,onEnd:c,className:`file-folder-split-resizer`}),(0,X.jsx)(`div`,{className:`file-folder-split-folder-pane`,style:u,children:e.folderPane})]})}function Vi(e){return e===`127.0.0.1`||e===`localhost`||e===`::1`||e===`[::1]`}function Hi(e=typeof navigator<`u`?navigator.userAgent:``){return/Safari/i.test(e)&&!/Chrome|Chromium|CriOS|Edg|OPR|Android/i.test(e)}function Ui(e){return e===`dark`||e===`light`}function Wi(e){return e&&typeof e==`object`?{theme:e.theme===`dark`||e.theme===`light`?e.theme:null,transport:e.transport===`legacy-path`||e.transport===`origin-port`?e.transport:null}:{theme:Ui(e)?e:null,transport:e===`proxy`?`legacy-path`:null}}function Gi(e,t){let n=t||(typeof window<`u`?window.location.href:``);if(!n||e.startsWith(`/`))return e;try{let t=new URL(e),r=new URL(n);return Vi(t.hostname)&&Vi(r.hostname)&&(t.hostname=r.hostname),t.toString()}catch{return e}}function Ki(e,t){if(!t)return e;let n=e.startsWith(`/`),r=new URL(e,`http://jaw.local`);return r.searchParams.set(`jawTheme`,t),n?`${r.pathname}${r.search}${r.hash}`:r.toString()}function qi(e,t,n){if(!e)return{canPreview:!1,src:null,reason:`Select an online instance to preview.`,transport:`none`,warning:null};if(!e.ok)return{canPreview:!1,src:null,reason:`Preview is only available for online instances.`,transport:`none`,warning:null};let r=t?.manager.proxy;if(!r?.enabled)return{canPreview:!1,src:null,reason:`Proxy preview is not available.`,transport:`none`,warning:null};if(e.port<r.allowedFrom||e.port>r.allowedTo)return{canPreview:!1,src:null,reason:`This port is outside the proxy allowlist.`,transport:`none`,warning:null};let i=r.preview?.instances[String(e.port)],{theme:a,transport:o}=Wi(n);if(o!==`legacy-path`&&r.preview?.enabled&&i?.status===`ready`&&i.url&&!Hi()){let e=new URL(Gi(i.url));return e.pathname=`${e.pathname.replace(/\/?$/,`/`)}0`,{canPreview:!0,src:Ki(e.toString(),a),reason:null,transport:`origin-port`,warning:`origin proxy ready`}}return{canPreview:!0,src:Ki(`${r.basePath||`/i`}/${e.port}/0`,a),reason:null,transport:`legacy-path`,warning:`legacy proxy fallback`}}var Ji=`allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox allow-same-origin allow-scripts allow-downloads`;function Yi(e){return e.replace(/^\[|\]$/g,``).toLowerCase()}function Xi(e){let t=Yi(e);return t===`127.0.0.1`||t===`localhost`||t===`::1`}function Zi(e,t){if(e===t)return!0;try{let n=new URL(e),r=new URL(t);return n.protocol!==r.protocol||n.port!==r.port?!1:Xi(n.hostname)&&Xi(r.hostname)}catch{return!1}}function Qi(e,t,n){if(!e||e===`null`)return!1;let r=ta(t,n);return!!(r&&Zi(r,e))}function $i(e,t,n){return Qi(e.origin,t,n)}function ea(e,t,n,r){if(e&&t&&t!==`null`)try{e.postMessage({type:`jaw-preview-send-result`,requestId:n,...r},t)}catch(e){console.warn(`[manager-preview] send relay result skipped`,e)}}function ta(e,t){if(typeof window>`u`)return`http://localhost`;try{let e=t?.contentWindow?.location.origin;if(e&&e!==`null`)return e}catch{}let n=new URL(e,window.location.href).origin;return n===`null`?null:n}function na(e,t,n){let r=e?.contentWindow;if(!r)return;let i=ta(t,e);if(i&&i!==`null`)try{r.postMessage({type:`jaw-preview-theme-sync`,theme:n},i)}catch(e){console.warn(`[manager-preview] theme sync skipped`,e)}}function ra(e,t){let n=e?.contentWindow;if(!n)return;let r=ta(t,e);if(r&&r!==`null`)try{n.postMessage({type:`jaw-preview-stt-toggle`},r)}catch(e){console.warn(`[manager-preview] STT shortcut sync skipped`,e)}}function ia(e,t){let n=e?.contentWindow;if(!n)return;let r=ta(t,e);if(r&&r!==`null`)try{n.postMessage({type:`jaw-preview-settings-open`},r)}catch(e){console.warn(`[manager-preview] settings open request skipped`,e)}}function aa(e,t){let n=e?.contentWindow;if(!n)return;let r=ta(t,e);if(r&&r!==`null`)try{n.postMessage({type:`jaw-preview-visibility`,visible:!0},r)}catch(e){console.warn(`[manager-preview] visibility sync skipped`,e)}}function oa(e,t,n){let r=e?.contentWindow;if(!r)return;let i=ta(t,e);if(i&&i!==`null`)try{r.postMessage({type:`jaw-preview-capabilities`,docPanel:n},i)}catch(e){console.warn(`[manager-preview] capability sync skipped`,e)}}function sa(e,t,n){if(e&&t&&t!==`null`)try{e.postMessage({type:`jaw-preview-capabilities`,docPanel:n},t)}catch(e){console.warn(`[manager-preview] capability reply skipped`,e)}}function ca(e,t,n,r=800){let i=e?.contentWindow;if(!i)return Promise.resolve({ok:!1,error:`preview is unavailable`});let a=ta(t,e);if(!a||a===`null`)return Promise.resolve({ok:!1,error:`preview origin is unavailable`});let o=crypto.randomUUID();return new Promise(s=>{let c=!1,l=e=>{c||(c=!0,window.removeEventListener(`message`,u),window.clearTimeout(d),s(e))},u=n=>{if(n.source!==i||!Qi(n.origin,t,e))return;let r=n.data;r&&r.type===`jaw-preview-insert-text-result`&&r.requestId===o&&(r.ok===!0?l({ok:!0}):l({ok:!1,error:typeof r.error==`string`?r.error:`preview rejected insert`}))},d=window.setTimeout(()=>l({ok:!1,error:`preview insert timed out`}),r);window.addEventListener(`message`,u);try{i.postMessage({type:`jaw-preview-insert-text`,requestId:o,text:n},a)}catch(e){l({ok:!1,error:e.message})}})}function la(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||!!e.closest(`[contenteditable="true"], .cm-editor, .ProseMirror, [data-milkdown-root]`)}function ua(e){let t=(e.ctrlKey||e.metaKey)&&e.shiftKey&&e.code===`Space`,n=e.altKey&&!e.ctrlKey&&!e.metaKey&&!e.shiftKey&&e.code===`KeyM`;return t||n}function da(e){return!e||e.type!==`jaw-preview-dropped-files`||!Array.isArray(e.files)?[]:e.files.filter(e=>e instanceof File)}function fa(e){let t=(0,Y.useRef)(null),n=(0,Y.useRef)(null),r=(0,Y.useRef)(null),i=(0,Y.useRef)(null),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(!1),l=qi(e.instance,e.data,{theme:e.theme}),u=e.instance?.ok?`Preview is off. Turn it on from the header to mount the iframe.`:l.reason,d=(0,Y.useCallback)(()=>{e.enabled&&l.canPreview&&l.src&&n.current===l.src&&na(t.current,l.src,e.theme)},[e.enabled,e.theme,l.canPreview,l.src]);(0,Y.useEffect)(()=>{let i=e.previewInsertTextRequest;if(!i||r.current===i.id)return;r.current=i.id;let a=t=>{e.onPreviewInsertTextResult?.(i.id,t)};if(!e.instance?.ok||e.instance.port!==i.port){a({ok:!1,error:`selected instance preview is not mounted`});return}if(!e.enabled||!l.canPreview||!l.src){a({ok:!1,error:u||`selected instance preview is unavailable`});return}if(n.current!==l.src){a({ok:!1,error:`selected instance preview is still loading`});return}ca(t.current,l.src,i.text).then(a).catch(e=>a({ok:!1,error:e.message}))},[u,e.enabled,e.instance,e.onPreviewInsertTextResult,e.previewInsertTextRequest,l.canPreview,l.src]),(0,Y.useEffect)(()=>{let r=e.previewSettingsOpenRequest;if(!r||i.current===r)return;i.current=r;let a=t=>{e.onPreviewSettingsOpenResult?.(r,t)};if(!e.instance?.ok){a({ok:!1,error:`selected instance is not online`});return}if(!e.enabled||!l.canPreview||!l.src){a({ok:!1,error:u||`turn Preview on to open this instance’s settings`});return}if(n.current!==l.src){a({ok:!1,error:`selected instance preview is still loading`});return}ia(t.current,l.src),a({ok:!0})},[u,e.enabled,e.instance,e.onPreviewSettingsOpenResult,e.previewSettingsOpenRequest,l.canPreview,l.src]);let f=(0,Y.useCallback)(async e=>{if(!L(e.dataTransfer))return;e.preventDefault(),e.stopPropagation(),c(!1);let n=I(e.dataTransfer),r=e.dataTransfer.getData(`text/plain`),i=n?.entries?.length?n.entries.map(e=>e.path).join(`
3
3
  `):n?.path||r;if(!i||!l.src)return;let a=await ca(t.current,l.src,i);if(a.ok){o(`Inserted path into preview`);return}let s=await Ce(i);o(s.ok?`Preview did not accept text. Copied path instead.`:s.error??a.error)},[l.src]);(0,Y.useEffect)(()=>{d()},[d]),(0,Y.useEffect)(()=>{let e=e=>{let t=e.detail;c(!!t?.active)};return window.addEventListener(`jaw-folder-panel-drag`,e),()=>window.removeEventListener(`jaw-folder-panel-drag`,e)},[]),(0,Y.useEffect)(()=>{if(!e.enabled||!l.canPreview||!l.src||!e.instance?.ok)return;function n(n){if(n.source!==t.current?.contentWindow||!l.src||!Qi(n.origin,l.src,t.current))return;let r=n.data;if(!r||r.type!==`jaw-preview-send-message`)return;let i=typeof r.requestId==`string`?r.requestId:``,a=typeof r.prompt==`string`?r.prompt.trim():``;if(!i)return;if(!a){ea(n.source,n.origin,i,{ok:!1,status:400,error:`prompt must be a non-empty string`});return}let o=typeof r.sessionId==`string`?r.sessionId:void 0;g(e.instance.port,a,o).then(e=>{ea(n.source,n.origin,i,{ok:e.ok,status:e.status,data:e.data,...e.data.error?{error:e.data.error}:{}})}).catch(e=>{ea(n.source,n.origin,i,{ok:!1,status:502,error:e.message})})}window.addEventListener(`message`,n);function r(n){if(!l.src||!$i(n,l.src,t.current))return;let r=n.data;if(!r||r.type!==`jaw-preview-open-notes`)return;let i=typeof r.path==`string`?r.path.trim():``;i&&e.onOpenNotesFromPreview?.(i)}window.addEventListener(`message`,r);function i(n){if(!l.src||!$i(n,l.src,t.current))return;let r=n.data;if(!r||r.type!==`jaw-preview-open-doc`)return;let i=typeof r.path==`string`?r.path.trim():``;i&&e.onOpenDocFromPreview?.(i)}window.addEventListener(`message`,i);function a(n){if(!l.src||!$i(n,l.src,t.current))return;let r=n.data;r&&r.type===`jaw-preview-capabilities-request`&&sa(n.source,n.origin,e.docPanelCapable===!0)}window.addEventListener(`message`,a);function o(n){if(n.source!==t.current?.contentWindow||!l.src||!Qi(n.origin,l.src,t.current))return;let r=da(n.data);r.length!==0&&e.onPreviewDroppedFiles?.(r)}return window.addEventListener(`message`,o),()=>{window.removeEventListener(`message`,n),window.removeEventListener(`message`,r),window.removeEventListener(`message`,i),window.removeEventListener(`message`,a),window.removeEventListener(`message`,o)}},[e.enabled,e.instance,e.onOpenNotesFromPreview,e.onOpenDocFromPreview,e.onPreviewDroppedFiles,e.docPanelCapable,l.canPreview,l.src]),(0,Y.useEffect)(()=>{if(!e.active||!e.enabled||!l.canPreview||!l.src)return;function n(e){e.defaultPrevented||la(e.target)||ua(e)&&(e.preventDefault(),ra(t.current,l.src||``))}return document.addEventListener(`keydown`,n,!0),()=>document.removeEventListener(`keydown`,n,!0)},[e.active,e.enabled,l.canPreview,l.src]);let p=(0,Y.useRef)(!1);return(0,Y.useEffect)(()=>{let n=p.current;p.current=e.active,!n&&e.active&&l.src&&(aa(t.current,l.src),oa(t.current,l.src,e.docPanelCapable===!0))},[e.active,l.src,e.docPanelCapable]),(0,Y.useEffect)(()=>{e.enabled&&l.canPreview&&l.src&&n.current===l.src&&oa(t.current,l.src,e.docPanelCapable===!0)},[e.enabled,e.docPanelCapable,l.canPreview,l.src]),(0,X.jsxs)(`aside`,{className:`preview-panel`,"aria-label":`Instance preview`,onDragOver:e=>{L(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDrop:e=>{f(e)},children:[(!e.enabled||!l.canPreview)&&(0,X.jsx)(`div`,{className:`preview-empty`,children:u}),a&&(0,X.jsxs)(`div`,{className:`preview-path-drop-status`,role:`status`,children:[a,(0,X.jsx)(`button`,{type:`button`,"aria-label":`Dismiss path drop status`,onClick:()=>o(null),children:`x`})]}),e.enabled&&l.canPreview&&l.src&&(0,X.jsx)(`iframe`,{title:`Jaw instance ${e.instance?.port} preview`,ref:t,className:`preview-frame`,src:l.src,sandbox:le()?void 0:Ji,allow:`clipboard-read; clipboard-write; microphone`,onLoad:()=>{n.current=l.src,d(),l.src&&(aa(t.current,l.src),oa(t.current,l.src,e.docPanelCapable===!0))}},`${e.instance?.port||`none`}:${e.refreshKey}`),s&&(0,X.jsx)(`div`,{className:`preview-path-drop-overlay`,onDragOver:e=>{L(e.dataTransfer)&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`)},onDragLeave:()=>c(!1),onDrop:e=>void f(e)})]})}var pa=/\{\{(\w+)\}\}/g;function ma(){let e=new Date,t=e=>String(e).padStart(2,`0`),n=e.getFullYear(),r=t(e.getMonth()+1),i=t(e.getDate()),a=t(e.getHours()),o=t(e.getMinutes());return{date:`${n}-${r}-${i}`,time:`${a}:${o}`,year:String(n),month:r,day:i}}function ha(e,t={}){let n={...ma(),...t};return e.replace(pa,(e,t)=>Object.hasOwn(n,t)?n[t]:e)}function ga({expanded:e}){return(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,className:`notes-tree-chevron`,children:(0,X.jsx)(`path`,{d:e?`M4 6l4 4 4-4`:`M6 4l4 4-4 4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function _a({open:e}){return(0,X.jsxs)(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:`notes-tree-icon`,children:[(0,X.jsx)(`path`,{d:`M2.5 5.2h5.1l1.2 1.5h6.7v6.7a1.4 1.4 0 0 1-1.4 1.4H3.9a1.4 1.4 0 0 1-1.4-1.4V5.2Z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`}),(0,X.jsx)(`path`,{d:e?`M2.8 7.1h12.7`:`M2.8 5.2h4.8`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}function va(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:`notes-tree-icon`,children:[(0,X.jsx)(`path`,{d:`M5 2.8h5.2L13.5 6v9.2H5V2.8Z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`}),(0,X.jsx)(`path`,{d:`M10.2 2.8V6h3.3M6.9 9h4.4M6.9 11.5h3.3`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}function ya(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:`notes-tree-action-icon`,children:[(0,X.jsx)(`path`,{d:`M5 2.8h5.2L13.5 6v9.2H5V2.8Z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`}),(0,X.jsx)(`path`,{d:`M9.2 8.1v4.2M7.1 10.2h4.2`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}function ba(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:`notes-tree-action-icon`,children:[(0,X.jsx)(`path`,{d:`M2.5 5.2h5.1l1.2 1.5h6.7v6.7a1.4 1.4 0 0 1-1.4 1.4H3.9a1.4 1.4 0 0 1-1.4-1.4V5.2Z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinejoin:`round`}),(0,X.jsx)(`path`,{d:`M9 8.3v4M7 10.3h4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}function xa(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:`notes-tree-action-icon`,children:[(0,X.jsx)(`path`,{d:`M14.2 6.3A5.5 5.5 0 0 0 4 5.2L3 6.6M3.8 11.7A5.5 5.5 0 0 0 14 12.8l1-1.4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,X.jsx)(`path`,{d:`M3 3.5v3.1h3.1M15 14.5v-3.1h-3.1`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`})]})}function Sa(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:`notes-tree-action-icon`,children:[(0,X.jsx)(`path`,{d:`M4 12.8 3.5 15l2.2-.5 7.7-7.7-1.7-1.7L4 12.8Z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`,strokeLinejoin:`round`}),(0,X.jsx)(`path`,{d:`m10.9 5.9 1.7 1.7`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}function Ca(e){return e.dataTransfer.getData(`application/x-cli-jaw-note-path`)||e.dataTransfer.getData(`text/plain`)||null}function wa(e){return Array.from(e.dataTransfer.types).some(e=>e===`application/x-cli-jaw-note-path`||e===`text/plain`)}function Ta(e,t){let n=[];for(let r of e)n.push(r.path),r.kind===`folder`&&t.has(r.path)&&r.children&&n.push(...Ta(r.children,t));return n}function Ea(e,t){for(let n of e)t.set(n.path,n.kind),n.kind===`folder`&&n.children&&Ea(n.children,t)}function Da(e,t){let n=[];for(let r of e){let e=t.get(r);e&&n.push({path:r,kind:e})}return n}function Oa(e){if(!(e instanceof HTMLElement))return!1;let t=e.tagName.toLowerCase();return e.isContentEditable||t===`input`||t===`textarea`||t===`select`}function ka(e,t,n){let r=e.indexOf(t),i=e.indexOf(n);if(r===-1||i===-1)return new Set([n]);let a=Math.min(r,i),o=Math.max(r,i);return new Set(e.slice(a,o+1))}function Aa(e,t,n){if(e.key===`F2`){e.preventDefault(),n.onRenamePath(t.path,t.kind);return}if(e.key===`Delete`||e.key===`Backspace`){if(e.preventDefault(),n.multiSelected.size>1&&n.multiSelected.has(t.path)){let e=Da(n.multiSelected,n.pathKindLookup);e.length>0&&n.onTrashPaths(e);return}n.onTrashPath(t.path,t.kind);return}if(e.key===`Enter`){if(e.preventDefault(),t.kind===`folder`){n.onSelectFolder?.(t.path),n.toggleFolder?.(t.path);return}n.onSelectPath(t.path)}}function ja(e,t,n,r,i,a,o,s,c){let l=e.path===t.selectedPath,u=o.has(e.path);if(e.kind===`folder`){let l=n.has(e.path),d=e.path===t.selectedFolderPath,f=e.children||[];return(0,X.jsxs)(`li`,{className:`notes-tree-folder`,children:[(0,X.jsxs)(`div`,{className:`notes-tree-folder-row ${d?`is-folder-selected`:``} ${i===e.path?`is-drop-target`:``} ${u?`is-multi-selected`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`notes-tree-folder-button`,"aria-expanded":l,draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`application/x-cli-jaw-note-path`,e.path),t.dataTransfer.setData(`text/plain`,e.path)},onClick:n=>{if(n.shiftKey||n.metaKey||n.ctrlKey){c(e.path,n);return}c(e.path,n),t.onSelectFolder(e.path),r(e.path)},onDragOver:t=>{t.preventDefault(),t.stopPropagation(),a(e.path)},onDragLeave:e=>{e.stopPropagation(),a(null)},onDrop:n=>{n.preventDefault(),n.stopPropagation();let r=Ca(n);a(null),r&&r!==e.path&&!e.path.startsWith(`${r}/`)&&t.onMovePath(r,e.path)},onKeyDown:n=>{if(n.key===`ArrowRight`&&!l){n.preventDefault(),r(e.path);return}if(n.key===`ArrowLeft`&&l){n.preventDefault(),r(e.path);return}Aa(n,e,{toggleFolder:r,onSelectPath:t.onSelectPath,onSelectFolder:t.onSelectFolder,onRenamePath:t.onRenamePath,onTrashPath:t.onTrashPath,onTrashPaths:t.onTrashPaths,multiSelected:o,pathKindLookup:s})},children:[(0,X.jsx)(ga,{expanded:l}),(0,X.jsx)(_a,{open:l}),(0,X.jsx)(`span`,{children:e.name})]}),(0,X.jsx)(`button`,{type:`button`,className:`notes-tree-inline-action`,title:`Rename folder`,"aria-label":`Rename folder ${e.name}`,onClick:n=>{n.stopPropagation(),t.onRenamePath(e.path,e.kind)},children:(0,X.jsx)(Sa,{})})]}),l&&f.length>0&&(0,X.jsx)(`ul`,{children:f.map(e=>ja(e,t,n,r,i,a,o,s,c))})]},e.path)}let d=e.path===t.dirtyPath,f=e.path===t.highlightedPath;return(0,X.jsx)(`li`,{children:(0,X.jsxs)(`div`,{className:`notes-tree-file-row ${l?`is-selected`:``} ${d?`is-dirty`:``} ${u?`is-multi-selected`:``} ${f?`is-highlighted`:``}`,children:[(0,X.jsxs)(`button`,{type:`button`,className:`notes-tree-file-button`,"aria-current":l?`page`:void 0,draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(`application/x-cli-jaw-note-path`,e.path),t.dataTransfer.setData(`text/plain`,e.path)},onClick:n=>{if(n.shiftKey||n.metaKey||n.ctrlKey){c(e.path,n);return}c(e.path,n),t.onSelectPath(e.path)},onKeyDown:n=>Aa(n,e,{onSelectPath:t.onSelectPath,onRenamePath:t.onRenamePath,onTrashPath:t.onTrashPath,onTrashPaths:t.onTrashPaths,multiSelected:o,pathKindLookup:s}),children:[(0,X.jsx)(va,{}),(0,X.jsx)(`span`,{children:e.name}),d&&(0,X.jsx)(`span`,{className:`notes-tree-dirty-dot`,"aria-label":`Unsaved changes`})]}),(0,X.jsx)(`button`,{type:`button`,className:`notes-tree-inline-action`,title:`Rename`,"aria-label":`Rename ${e.name}`,onClick:n=>{n.stopPropagation(),t.onRenamePath(e.path,e.kind)},children:(0,X.jsx)(Sa,{})})]})},e.path)}function Ma(e){let[t,n]=(0,Y.useState)(()=>new Set),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(()=>new Set),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{let t=e.externalFocusPath??e.highlightedPath;if(!t)return;let r=t.split(`/`).filter(Boolean);if(r.length<=1)return;let i=[];for(let e=1;e<r.length;e++)i.push(r.slice(0,e).join(`/`));n(e=>{let t=new Set(e);for(let e of i)t.add(e);return t})},[e.externalFocusPath,e.highlightedPath]);function d(e){n(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}let f=Ta(e.entries,t),p=(0,Y.useMemo)(()=>{let t=new Map;return Ea(e.entries,t),t},[e.entries]);function m(){if(a.size===0)return;let t=Da(a,p);t.length!==0&&e.onTrashPaths(t)}let h=(0,Y.useCallback)((t,n)=>{if(u(t),n.shiftKey&&s){let e=ka(f,s,t);o(e)}else n.metaKey||n.ctrlKey?(o(n=>{let r=new Set(n);return r.size===0&&e.selectedPath&&r.add(e.selectedPath),r.has(t)?r.delete(t):r.add(t),r}),c(t)):(a.size>0&&o(new Set),c(t))},[s,f,a.size,e.selectedPath]);return(0,Y.useEffect)(()=>{e.selectedPath&&c(e.selectedPath)},[e.selectedPath]),(0,Y.useEffect)(()=>{l&&!p.has(l)&&u(null),a.size!==0&&o(e=>{let t=!1,n=new Set;for(let r of e)p.has(r)?n.add(r):t=!0;return t?n:e})},[l,a.size,p]),(0,Y.useEffect)(()=>{function t(t){if(!(t.metaKey||t.ctrlKey)||!t.shiftKey||t.key.toLowerCase()!==`c`||Oa(t.target))return;let n=e.notesRoot;if(!n)return;let r=a.size>0?Array.from(a):l&&p.has(l)?[l]:e.selectedPath?[e.selectedPath]:[];if(r.length===0)return;t.preventDefault();let i=r.map(e=>`${n}/${e}`).join(`
4
4
  `);Ce(i).then(e=>{e.ok||console.error(`[notes:path-copy]`,e.error)})}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[l,a,p,e.selectedPath,e.notesRoot]),(0,Y.useEffect)(()=>{function t(t){if(t.defaultPrevented||!(t.metaKey||t.ctrlKey)||t.key!==`Delete`&&t.key!==`Backspace`||Oa(t.target))return;let n=a.size>0?Da(a,p):e.selectedFolderPath&&p.get(e.selectedFolderPath)===`folder`?[{path:e.selectedFolderPath,kind:`folder`}]:e.selectedPath&&p.get(e.selectedPath)===`file`?[{path:e.selectedPath,kind:`file`}]:[];n.length!==0&&(t.preventDefault(),n.length>1?e.onTrashPaths(n):e.onTrashPath(n[0].path,n[0].kind))}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[a,p,e]),(0,X.jsxs)(`div`,{className:`notes-tree-body ${r===null?`is-root-drop-target`:``}`,onDragOver:e=>{wa(e)&&(e.preventDefault(),i(null))},onDrop:t=>{let n=Ca(t);n&&(t.preventDefault(),e.onMovePath(n,null))},children:[a.size>0&&(0,X.jsxs)(`div`,{className:`notes-tree-selection-info`,children:[a.size,` selected`,(0,X.jsx)(`button`,{type:`button`,className:`notes-tree-selection-delete`,onClick:m,disabled:a.size===0,children:`Delete`}),(0,X.jsx)(`button`,{type:`button`,className:`notes-tree-clear-selection`,onClick:()=>o(new Set),children:`Clear`})]}),e.loading&&(0,X.jsx)(`div`,{className:`notes-tree-state`,children:`Loading notes...`}),!e.loading&&e.entries.length===0&&(0,X.jsx)(`div`,{className:`notes-tree-state`,children:`No notes or folders`}),!e.loading&&e.entries.length>0&&(0,X.jsx)(`ul`,{className:`notes-tree-list`,children:e.entries.map(n=>ja(n,e,t,d,r,i,a,p,h))})]})}var Na=2,Pa=275,Fa=20;function Ia(e){return e instanceof DOMException&&e.name===`AbortError`}function La(e){let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)([]),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),l=(0,Y.useRef)(null),u=(0,Y.useRef)(null),d=(0,Y.useRef)(null),f=(0,Y.useCallback)(()=>{u.current&&clearTimeout(u.current),u.current=null,d.current?.abort(),d.current=null},[]);(0,Y.useEffect)(()=>{l.current?.focus()},[e.focusToken]),(0,Y.useEffect)(()=>()=>f(),[f]);let p=(0,Y.useCallback)(e=>{let t=e.trim();if(f(),c(null),t.length<Na){i([]),o(!1);return}let n=new AbortController;d.current=n,o(!0),ae(t,{limit:Fa,signal:n.signal}).then(e=>{n.signal.aborted||i(e)}).catch(e=>{n.signal.aborted||Ia(e)||(i([]),c(e.message||`Search failed`))}).finally(()=>{n.signal.aborted||o(!1)})},[f]);function m(e){n(e),u.current&&clearTimeout(u.current),u.current=setTimeout(()=>p(e),Pa)}function h(t){t.key===`Escape`&&(t.preventDefault(),e.onModeChange(`files`))}return(0,X.jsxs)(`section`,{className:`notes-search-sidebar`,"aria-label":`Search notes`,onKeyDown:h,children:[(0,X.jsx)(`div`,{className:`notes-search-sidebar-header`,children:(0,X.jsx)(`input`,{ref:l,className:`notes-search-input`,type:`search`,placeholder:`Search notes`,value:t,onChange:e=>m(e.currentTarget.value),"aria-label":`Search notes`})}),(0,X.jsxs)(`div`,{className:`notes-search-sidebar-results`,"aria-live":`polite`,children:[a&&(0,X.jsx)(`div`,{className:`notes-search-loading`,children:`Searching...`}),s&&(0,X.jsx)(`div`,{className:`notes-search-error`,children:s}),!s&&r.map(t=>(0,X.jsxs)(`button`,{type:`button`,className:`notes-search-result`,onClick:()=>e.onSelect(t.path),children:[(0,X.jsx)(`span`,{className:`notes-search-result-path`,children:t.path}),(0,X.jsx)(`span`,{className:`notes-search-result-line`,children:t.kind===`path`?`Path match`:`Line ${t.line}`}),(0,X.jsx)(`span`,{className:`notes-search-result-context`,children:t.context})]},`${t.kind}:${t.path}:${t.line}:${t.context}`)),!a&&!s&&t.trim().length>=Na&&r.length===0&&(0,X.jsx)(`div`,{className:`notes-search-empty`,children:`No results`})]})]})}var Ra=(0,Y.createContext)(null);function za(e){let[t,n]=(0,Y.useState)(()=>new Map),r=(0,Y.useCallback)(e=>{let t=new Map(e.map(e=>[e.id,e]));return n(t=>{let n=new Map(t);for(let t of e){let e=n.get(t.id);e&&e!==t&&console.warn(`[notes-command-palette] duplicate command id: ${t.id}`),n.set(t.id,t)}return n}),()=>{n(e=>{let n=new Map(e);for(let[e,r]of t)n.get(e)===r&&n.delete(e);return n})}},[]),i=(0,Y.useMemo)(()=>[...t.values()].sort((e,t)=>{let n=e.section.localeCompare(t.section);return n===0?e.label.localeCompare(t.label):n}),[t]),a=(0,Y.useMemo)(()=>({commands:i,register:r}),[i,r]);return(0,X.jsx)(Ra.Provider,{value:a,children:e.children})}function Ba(){let e=(0,Y.useContext)(Ra);if(!e)throw Error(`useNoteCommands must be used inside NotesCommandProvider`);return e.commands}function Va(e,t=!0){let n=(0,Y.useContext)(Ra);if(!n)throw Error(`useRegisterNoteCommands must be used inside NotesCommandProvider`);let r=n.register;(0,Y.useEffect)(()=>{if(t&&e.length!==0)return r(e)},[t,e,r])}var Ha=new EventTarget,Ua=`dashboard:invalidate`;function Z(e){Ha.dispatchEvent(new CustomEvent(Ua,{detail:e}))}function Wa(e,t,n){function r(r){let i=r.detail;i.topics.includes(e)&&(n&&i.sourceId===n||t(i))}return Ha.addEventListener(Ua,r),()=>Ha.removeEventListener(Ua,r)}function Ga(e,t){let n=e.split(`/`).filter(Boolean),r=n[n.length-1];return r?t?`${t}/${r}`:r:e}function Ka(e){let t=e.split(`/`).filter(Boolean);return t[t.length-1]||e}function qa(e){let t=e.split(`/`).filter(Boolean);return t.length<=1?null:t.slice(0,-1).join(`/`)}function Ja(e,t,n){let r=n===`file`&&!t.endsWith(`.md`)?`${t}.md`:t;if(r.includes(`/`))return r;let i=qa(e);return i?`${i}/${r}`:r}function Ya(e,t,n){return e?e===t?n:e.startsWith(`${t}/`)?`${n}/${e.slice(t.length+1)}`:e:null}function Xa(e,t){return t?t===e||t.startsWith(`${e}/`):!1}function Za(e,t,n){return n?t===`folder`?Xa(e,n):n===e:!1}function Qa(e,t,n){let r=t===`folder`?`Move folder "${e}" and all child notes to trash?`:`Move note "${e}" to trash?`;return n?`${r}\n\nThere are unsaved changes inside this target.`:r}function $a(e,t){let n=e.filter(e=>e.kind===`file`).length,r=e.length-n,i=[];r>0&&i.push(`${r} folder${r===1?``:`s`}`),n>0&&i.push(`${n} note${n===1?``:`s`}`);let a=`Move ${i.length>0?i.join(` + `):`${e.length} items`} to trash?`;return t?`${a}\n\nThere are unsaved changes inside this selection.`:a}function eo(){return(0,X.jsxs)(`svg`,{viewBox:`0 0 18 18`,"aria-hidden":`true`,className:`notes-tree-action-icon`,children:[(0,X.jsx)(`path`,{d:`M7.8 3.2a4.6 4.6 0 1 1 0 9.2 4.6 4.6 0 0 1 0-9.2Z`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`}),(0,X.jsx)(`path`,{d:`m11.3 11.3 3.2 3.2`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})]})}function to(e,t){return e.some(e=>e.kind===`file`&&e.name===t)}function no(e){let t={"--notes-tree-width":`${e.treeWidth}px`},[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(null),[c,l]=(0,Y.useState)([]),[u,d]=(0,Y.useState)(`pending`),[f,p]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{S().then(e=>{l(e),d(`ok`)}).catch(()=>{d(`error`)})},[]);async function m(){let t=new Date,n=e=>String(e).padStart(2,`0`),i=`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}.md`;if(to(e.tree,i)){e.onSelectedPathChange(i),r(null);return}if(u===`pending`){r(`Templates are still loading. Please try again.`);return}if(u===`error`){r(`Template list failed to load. Cannot determine daily template.`);return}try{a(null),r(null);let t=c.find(e=>e.name===`daily`),n=``;if(t)try{n=ha((await x(t.name)).content,{title:i.replace(/\.md$/,``)})}catch{r(`Daily template failed to load. Note was not created.`);return}let o=await j(i,n);e.onSelectedPathChange(o.path),await e.onRefreshTree(o.path),Z({topics:[`notes`],reason:`note:created`,source:`ui`,sourceId:`notes-sidebar`})}catch(t){if(t instanceof ne&&t.status===409&&t.code===`note_path_exists`){r(null),e.onSelectedPathChange(i),await e.onRefreshTree(i);return}r(t.message)}}async function h(){if(u===`pending`){r(`Templates are still loading. Please try again.`);return}if(u===`error`){r(`Template list failed to load. Cannot offer template picker.`);return}let e=o?`${o}/untitled.md`:`untitled.md`,t=window.prompt(`Note path`,e);if(!t)return;let n=t.endsWith(`.md`)?t:`${t}.md`;if(c.length>0){p(n);return}await g(n,null)}async function g(t,n){p(null);let i=``;if(n)try{let e=await x(n),r=(t.endsWith(`.md`)?t.slice(0,-3):t).split(`/`).pop()??``;i=ha(e.content,{title:r})}catch{r(`Template "${n}" failed to load. Note was not created.`);return}try{a(null),r(null);let n=await j(t,i);e.onSelectedPathChange(n.path),await e.onRefreshTree(n.path),Z({topics:[`notes`],reason:`note:created`,source:`ui`,sourceId:`notes-sidebar`})}catch(e){r(e.message)}}(0,Y.useEffect)(()=>{function e(e){!e.altKey||e.metaKey||e.ctrlKey||e.shiftKey||e.key.toLowerCase()!==`n`||(e.preventDefault(),h())}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)});async function _(){let t=o?`${o}/new-folder`:`new-folder`,n=window.prompt(`Folder path`,t);if(n)try{a(null);let t=await T(n);s(t.path),await e.onRefreshTree(),Z({topics:[`notes`],reason:`folder:created`,source:`ui`,sourceId:`notes-sidebar`})}catch(e){r(e.message)}}async function v(t,n){let i=Ga(t,n);if(t!==i)try{a(null);let n=await oe(t,i);e.selectedPath===t&&e.onSelectedPathChange(n.to),await e.onRefreshTree(n.to),Z({topics:[`notes`],reason:`note:moved`,source:`ui`,sourceId:`notes-sidebar`})}catch(e){r(e.message)}}async function y(t,n){let i=n===`folder`?`Rename folder`:`Rename note`,c=window.prompt(i,Ka(t));if(!c)return;let l=Ja(t,c,n);if(l!==t)try{a(null);let n=await oe(t,l),r=Ya(e.selectedPath,n.from,n.to),i=Ya(o,n.from,n.to);i!==o&&s(i),r!==e.selectedPath&&e.onSelectedPathChange(r),await e.onRefreshTree(r),Z({topics:[`notes`],reason:`note:renamed`,source:`ui`,sourceId:`notes-sidebar`})}catch(e){r(e.message)}}async function b(t){if(t.length===0)return;if(t.length===1){await C(t[0].path,t[0].kind);return}let n=t.some(t=>Za(t.path,t.kind,e.dirtyPath));if(!window.confirm($a(t,n)))return;a(null);let i=0,c=!1,l=!1,u=null;for(let n of t)try{await E(n.path,n.kind),i+=1,c||(n.kind===`folder`?Xa(n.path,e.selectedPath):e.selectedPath===n.path)&&(c=!0),!l&&n.kind===`folder`&&Xa(n.path,o)&&(l=!0)}catch(e){u=`Failed at ${n.path}: ${e.message}`;break}c&&e.onSelectedPathChange(null),l&&s(null),u?(r(u),a(i>0?`Moved ${i} of ${t.length} to trash before stopping.`:null)):a(`Moved ${i} item${i===1?``:`s`} to trash.`),await e.onRefreshTree(c?null:e.selectedPath),Z({topics:[`notes`],reason:`notes:batch-trashed`,source:`ui`,sourceId:`notes-sidebar`})}async function C(t,n){let i=Za(t,n,e.dirtyPath);if(window.confirm(Qa(t,n,i)))try{a(null);let r=await E(t,n),i=n===`folder`?Xa(t,e.selectedPath):e.selectedPath===t,c=n===`folder`&&Xa(t,o);i&&e.onSelectedPathChange(null),c&&s(null);let l=r.deletedTo===`os-trash`?`OS trash`:`dashboard trash`,u=r.deletedTo===`dashboard-trash`&&r.restoreHint?` Restore from: ${r.restoreHint}`:``;a(`Moved ${r.path} to ${l}.${u}`),await e.onRefreshTree(i?null:e.selectedPath),Z({topics:[`notes`],reason:`note:trashed`,source:`ui`,sourceId:`notes-sidebar`})}catch(e){r(e.message)}}let w=u===`pending`?`Templates are still loading`:u===`error`?`Templates failed to load`:void 0;return Va((0,Y.useMemo)(()=>[{id:`sidebar:new-note`,section:`Create`,label:`New note`,shortcut:`Alt+N`,keywords:[`create`,`file`],disabled:u!==`ok`,disabledReason:w,run:()=>void h()},{id:`sidebar:new-folder`,section:`Create`,label:`New folder`,keywords:[`directory`],run:()=>void _()},{id:`sidebar:today`,section:`Create`,label:`Open today`,keywords:[`daily`,`journal`],disabled:u!==`ok`,disabledReason:w,run:()=>void m()},{id:`sidebar:search`,section:`Navigate`,label:`Search notes`,shortcut:`Cmd+Shift+F`,run:e.onOpenSearch},{id:`sidebar:refresh`,section:`File`,label:`Refresh notes`,disabled:e.loading,disabledReason:`Refresh already running`,run:()=>void e.onRefreshTree()},{id:`sidebar:clear-tag-filter`,section:`Navigate`,label:`Clear tag filter`,disabled:!e.tagFilter,disabledReason:`No active tag filter`,run:e.onClearTagFilter}],[e.loading,e.onClearTagFilter,e.onOpenSearch,e.onRefreshTree,e.onSelectedPathChange,e.selectedPath,e.tagFilter,e.tree,o,w,c,u])),(0,X.jsxs)(`aside`,{className:`notes-tree`,style:t,children:[(e.error||n)&&(0,X.jsx)(`section`,{className:`state error-state`,children:e.error||n}),i&&(0,X.jsx)(`section`,{className:`state notes-status-state`,children:i}),(0,X.jsxs)(`div`,{className:`notes-tree-header`,children:[(0,X.jsx)(`strong`,{children:`Notes`}),(0,X.jsxs)(`div`,{className:`notes-tree-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:e.mode===`search`?`is-active`:``,onClick:()=>{e.mode===`search`?e.onModeChange(`files`):e.onOpenSearch()},title:`Search notes`,"aria-label":`Search notes`,"aria-pressed":e.mode===`search`,children:(0,X.jsx)(eo,{})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void h(),title:`New note`,"aria-label":`New note`,children:(0,X.jsx)(ya,{})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void _(),title:`New folder`,"aria-label":`New folder`,children:(0,X.jsx)(ba,{})}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void e.onRefreshTree(),disabled:e.loading,title:`Refresh notes`,"aria-label":`Refresh notes`,children:(0,X.jsx)(xa,{})})]})]}),e.mode===`files`?(0,X.jsxs)(X.Fragment,{children:[e.tagFilter&&(0,X.jsxs)(`div`,{className:`notes-tag-filter-banner`,role:`status`,children:[(0,X.jsxs)(`span`,{className:`notes-tag-filter-banner-meta`,children:[(0,X.jsxs)(`span`,{children:[`Tag: #`,e.tagFilter]}),e.selectedHiddenByFilter&&(0,X.jsx)(`span`,{className:`notes-tag-filter-banner-hint`,children:`Selected note hidden by filter`})]}),(0,X.jsx)(`button`,{type:`button`,className:`notes-tag-filter-clear`,onClick:e.onClearTagFilter,children:`Clear`})]}),f&&(0,X.jsxs)(`div`,{className:`notes-template-picker`,children:[(0,X.jsxs)(`div`,{className:`notes-template-picker-label`,children:[`Template for `,Ka(f)]}),(0,X.jsxs)(`div`,{className:`notes-template-picker-options`,children:[(0,X.jsx)(`button`,{type:`button`,className:`notes-template-picker-option`,onClick:()=>void g(f,null),children:`Blank`}),c.map(e=>(0,X.jsx)(`button`,{type:`button`,className:`notes-template-picker-option`,onClick:()=>void g(f,e.name),children:e.name},e.name))]}),(0,X.jsx)(`button`,{type:`button`,className:`notes-template-picker-cancel`,onClick:()=>p(null),children:`Cancel`})]}),(0,X.jsx)(`div`,{className:`notes-today-bar`,children:(0,X.jsx)(`button`,{type:`button`,className:`notes-today-button`,onClick:()=>void m(),children:`Today`})}),(0,X.jsx)(Ma,{entries:e.tree,selectedPath:e.selectedPath,selectedFolderPath:o,dirtyPath:e.dirtyPath,highlightedPath:e.highlightedPath??null,externalFocusPath:e.externalFocusPath??null,loading:e.loading,notesRoot:e.notesRoot,onSelectPath:e.onSelectedPathChange,onSelectFolder:s,onMovePath:(e,t)=>void v(e,t),onRenamePath:(e,t)=>void y(e,t),onTrashPath:(e,t)=>void C(e,t),onTrashPaths:e=>void b(e)})]}):(0,X.jsx)(La,{focusToken:e.searchFocusToken,onSelect:e.onSelectedPathChange,onModeChange:e.onModeChange})]})}var ro=[`default`,`sepia`,`nord`,`solarized-dark`];function io(){let[e,t]=(0,Y.useState)([]),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!0);(0,Y.useEffect)(()=>{re().then(e=>{t(e.snippets),r(e.activeTheme),a(!1)}).catch(()=>a(!1))},[]);async function o(e){let t=e==="default"?null:e;r(t),await p(t)}async function s(e,n){t(t=>t.map(t=>t.name===e?{...t,enabled:n}:t)),await m(e,n)}return i?(0,X.jsx)(`div`,{className:`notes-theme-loading`,children:`Loading theme settings...`}):(0,X.jsxs)(`div`,{className:`notes-theme-settings`,children:[(0,X.jsxs)(`fieldset`,{className:`notes-theme-fieldset`,children:[(0,X.jsx)(`legend`,{children:`Theme`}),(0,X.jsx)(`select`,{value:n??`default`,onChange:e=>void o(e.target.value),children:ro.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))})]}),e.length>0&&(0,X.jsxs)(`fieldset`,{className:`notes-theme-fieldset`,children:[(0,X.jsx)(`legend`,{children:`CSS Snippets`}),(0,X.jsx)(`div`,{className:`notes-theme-warning`,children:`CSS snippets run trusted local code.`}),e.map(e=>(0,X.jsxs)(`label`,{className:`notes-snippet-toggle`,children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:e.enabled,onChange:t=>void s(e.name,t.target.checked)}),e.name]},e.name))]})]})}function ao(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)([]),[i,a]=(0,Y.useState)(new Map);(0,Y.useEffect)(()=>{re().then(e=>{t(e.activeTheme),r(e.snippets.filter(e=>e.enabled).map(e=>e.name))})},[]),(0,Y.useEffect)(()=>{for(let e of n)i.has(e)||D(e).then(t=>{a(n=>new Map(n).set(e,t))})},[n]),(0,Y.useEffect)(()=>{let t=document.documentElement;return e?t.setAttribute(`data-notes-theme`,e):t.removeAttribute(`data-notes-theme`),()=>t.removeAttribute(`data-notes-theme`)},[e]);let o=n.map(e=>i.get(e)).filter(e=>!!e).join(`
5
5
  `);return o?(0,X.jsx)(`style`,{dangerouslySetInnerHTML:{__html:o}}):null}function oo(){return oo=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},oo.apply(null,arguments)}function so(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var co=class{constructor(e,t,n){this.from=e,this.to=t,this.diagnostic=n}},lo=class e{constructor(e,t,n){this.diagnostics=e,this.panel=t,this.selected=n}static init(t,n,r){let i=r.facet(Co).markerFilter;i&&(t=i(t,r));let a=t.slice().sort((e,t)=>e.from-t.from||e.to-t.to),o=new ke,s=[],c=0,l=r.doc.iter(),u=0,d=r.doc.length;for(let e=0;;){let t=e==a.length?null:a[e];if(!t&&!s.length)break;let n,r;if(s.length)n=c,r=s.reduce((e,t)=>Math.min(e,t.to),t&&t.from>n?t.from:1e8);else{if(n=t.from,n>d)break;r=t.to,s.push(t),e++}for(;e<a.length;){let t=a[e];if(t.from==n&&(t.to>t.from||t.to==n))s.push(t),e++,r=Math.min(t.to,r);else{r=Math.min(t.from,r);break}}r=Math.min(r,d);let i=!1;if(s.some(e=>e.from==n&&(e.to==r||r==d))&&(i=n==r,!i&&r-n<10)){let e=n-(u+l.value.length);e>0&&(l.next(e),u=n);for(let e=n;;){if(e>=r){i=!0;break}if(!l.lineBreak&&u+l.value.length>e)break;e=u+l.value.length,u+=l.value.length,l.next()}}let f=Po(s);if(i)o.add(n,n,J.widget({widget:new Do(f),diagnostics:s.slice()}));else{let e=s.reduce((e,t)=>t.markClass?e+` `+t.markClass:e,``);o.add(n,r,J.mark({class:`cm-lintRange cm-lintRange-`+f+e,diagnostics:s.slice(),inclusiveEnd:s.some(e=>e.to>r)}))}if(c=r,c==d)break;for(let e=0;e<s.length;e++)s[e].to<=c&&s.splice(e--,1)}let f=o.finish();return new e(f,n,uo(f))}};function uo(e,t=null,n=0){let r=null;return e.between(n,1e9,(e,n,{spec:i})=>{if(!(t&&i.diagnostics.indexOf(t)<0)){if(!r)r=new co(e,n,t||i.diagnostics[0]);else if(i.diagnostics.indexOf(r.diagnostic)<0)return!1;else r=new co(r.from,n,r.diagnostic)}}),r}function fo(e,t){let n=t.pos,r=t.end||n,i=e.state.facet(Co).hideOn(e,n,r);if(i!=null)return i;let a=e.startState.doc.lineAt(t.pos);return!!(e.effects.some(e=>e.is(mo))||e.changes.touchesRange(a.from,Math.max(a.to,r)))}function po(e,t){return e.field(Q,!1)?t:t.concat(we.appendConfig.of(Fo))}var mo=we.define(),ho=we.define(),go=we.define(),Q=Le.define({create(){return new lo(J.none,null,null)},update(e,t){if(t.docChanged&&e.diagnostics.size){let n=e.diagnostics.map(t.changes),r=null,i=e.panel;if(e.selected){let i=t.changes.mapPos(e.selected.from,1);r=uo(n,e.selected.diagnostic,i)||uo(n,null,i)}!n.size&&i&&t.state.facet(Co).autoPanel&&(i=null),e=new lo(n,i,r)}for(let n of t.effects)if(n.is(mo)){let r=t.state.facet(Co).autoPanel?n.value.length?ko.open:null:e.panel;e=lo.init(n.value,r,t.state)}else n.is(ho)?e=new lo(e.diagnostics,n.value?ko.open:null,e.selected):n.is(go)&&(e=new lo(e.diagnostics,e.panel,n.value));return e},provide:e=>[q.from(e,e=>e.panel),U.decorations.from(e,e=>e.diagnostics)]}),_o=J.mark({class:`cm-lintRange cm-lintRange-active`});function vo(e,t,n){let{diagnostics:r}=e.state.field(Q),i,a=-1,o=-1;r.between(t-+(n<0),t+ +(n>0),(e,r,{spec:s})=>{if(t>=e&&t<=r&&(e==r||(t>e||n>0)&&(t<r||n<0)))return i=s.diagnostics,a=e,o=r,!1});let s=e.state.facet(Co).tooltipFilter;return i&&s&&(i=s(i,e.state)),i?{pos:a,end:o,above:e.state.doc.lineAt(a).to<o,create(){return{dom:yo(e,i)}}}:null}function yo(e,t){return W(`ul`,{class:`cm-tooltip-lint`},t.map(t=>Eo(e,t,!1)))}var bo=e=>{let t=e.state.field(Q,!1);(!t||!t.panel)&&e.dispatch({effects:po(e.state,[ho.of(!0)])});let n=Be(e,ko.open);return n&&n.dom.querySelector(`.cm-panel-lint ul`).focus(),!0},xo=e=>{let t=e.state.field(Q,!1);return!t||!t.panel?!1:(e.dispatch({effects:ho.of(!1)}),!0)},So=[{key:`Mod-Shift-m`,run:bo,preventDefault:!0},{key:`F8`,run:e=>{let t=e.state.field(Q,!1);if(!t)return!1;let n=e.state.selection.main,r=uo(t.diagnostics,null,n.to+1);return!r&&(r=uo(t.diagnostics,null,0),!r||r.from==n.from&&r.to==n.to)?!1:(e.dispatch({selection:{anchor:r.from,head:r.to},scrollIntoView:!0}),!0)}}],Co=Je.define({combine(e){return{sources:e.map(e=>e.source).filter(e=>e!=null),...De(e.map(e=>e.config),{delay:750,markerFilter:null,tooltipFilter:null,needsRefresh:null,hideOn:()=>null},{delay:Math.max,markerFilter:wo,tooltipFilter:wo,needsRefresh:(e,t)=>e?t?n=>e(n)||t(n):e:t,hideOn:(e,t)=>e?t?(n,r,i)=>e(n,r,i)||t(n,r,i):e:t,autoPanel:(e,t)=>e||t})}}});function wo(e,t){return e?t?(n,r)=>t(e(n,r),r):e:t}function To(e){let t=[];if(e)actions:for(let{name:n}of e){for(let e=0;e<n.length;e++){let r=n[e];if(/[a-zA-Z]/.test(r)&&!t.some(e=>e.toLowerCase()==r.toLowerCase())){t.push(r);continue actions}}t.push(``)}return t}function Eo(e,t,n){let r=n?To(t.actions):[];return W(`li`,{class:`cm-diagnostic cm-diagnostic-`+t.severity},W(`span`,{class:`cm-diagnosticText`},t.renderMessage?t.renderMessage(e):t.message),t.actions?.map((n,i)=>{let a=!1,o=r=>{if(r.preventDefault(),a)return;a=!0;let i=uo(e.state.field(Q).diagnostics,t);i&&n.apply(e,i.from,i.to)},{name:s}=n,c=r[i]?s.indexOf(r[i]):-1,l=c<0?s:[s.slice(0,c),W(`u`,s.slice(c,c+1)),s.slice(c+1)],u=n.markClass?` `+n.markClass:``;return W(`button`,{type:`button`,class:`cm-diagnosticAction`+u,onclick:o,onmousedown:o,"aria-label":` Action: ${s}${c<0?``:` (access key "${r[i]})"`}.`},l)}),t.source&&W(`div`,{class:`cm-diagnosticSource`},t.source))}var Do=class extends Ae{constructor(e){super(),this.sev=e}eq(e){return e.sev==this.sev}toDOM(){return W(`span`,{class:`cm-lintPoint cm-lintPoint-`+this.sev})}},Oo=class{constructor(e,t){this.diagnostic=t,this.id=`item_`+Math.floor(Math.random()*4294967295).toString(16),this.dom=Eo(e,t,!0),this.dom.id=this.id,this.dom.setAttribute(`role`,`option`)}},ko=class e{constructor(e){this.view=e,this.items=[];let t=t=>{if(!(t.ctrlKey||t.altKey||t.metaKey)){if(t.keyCode==27)xo(this.view),this.view.focus();else if(t.keyCode==38||t.keyCode==33)this.moveSelection((this.selectedIndex-1+this.items.length)%this.items.length);else if(t.keyCode==40||t.keyCode==34)this.moveSelection((this.selectedIndex+1)%this.items.length);else if(t.keyCode==36)this.moveSelection(0);else if(t.keyCode==35)this.moveSelection(this.items.length-1);else if(t.keyCode==13)this.view.focus();else if(t.keyCode>=65&&t.keyCode<=90&&this.selectedIndex>=0){let{diagnostic:n}=this.items[this.selectedIndex],r=To(n.actions);for(let i=0;i<r.length;i++)if(r[i].toUpperCase().charCodeAt(0)==t.keyCode){let t=uo(this.view.state.field(Q).diagnostics,n);t&&n.actions[i].apply(e,t.from,t.to)}}else return;t.preventDefault()}},n=e=>{for(let t=0;t<this.items.length;t++)this.items[t].dom.contains(e.target)&&this.moveSelection(t)};this.list=W(`ul`,{tabIndex:0,role:`listbox`,"aria-label":this.view.state.phrase(`Diagnostics`),onkeydown:t,onclick:n}),this.dom=W(`div`,{class:`cm-panel-lint`},this.list,W(`button`,{type:`button`,name:`close`,"aria-label":this.view.state.phrase(`close`),onclick:()=>xo(this.view)},`×`)),this.update()}get selectedIndex(){let e=this.view.state.field(Q).selected;if(!e)return-1;for(let t=0;t<this.items.length;t++)if(this.items[t].diagnostic==e.diagnostic)return t;return-1}update(){let{diagnostics:e,selected:t}=this.view.state.field(Q),n=0,r=!1,i=null,a=new Set;for(e.between(0,this.view.state.doc.length,(e,o,{spec:s})=>{for(let e of s.diagnostics){if(a.has(e))continue;a.add(e);let o=-1,s;for(let t=n;t<this.items.length;t++)if(this.items[t].diagnostic==e){o=t;break}o<0?(s=new Oo(this.view,e),this.items.splice(n,0,s),r=!0):(s=this.items[o],o>n&&(this.items.splice(n,o-n),r=!0)),t&&s.diagnostic==t.diagnostic?s.dom.hasAttribute(`aria-selected`)||(s.dom.setAttribute(`aria-selected`,`true`),i=s):s.dom.hasAttribute(`aria-selected`)&&s.dom.removeAttribute(`aria-selected`),n++}});n<this.items.length&&!(this.items.length==1&&this.items[0].diagnostic.from<0);)r=!0,this.items.pop();this.items.length==0&&(this.items.push(new Oo(this.view,{from:-1,to:-1,severity:`info`,message:this.view.state.phrase(`No diagnostics`)})),r=!0),i?(this.list.setAttribute(`aria-activedescendant`,i.id),this.view.requestMeasure({key:this,read:()=>({sel:i.dom.getBoundingClientRect(),panel:this.list.getBoundingClientRect()}),write:({sel:e,panel:t})=>{let n=t.height/this.list.offsetHeight;e.top<t.top?this.list.scrollTop-=(t.top-e.top)/n:e.bottom>t.bottom&&(this.list.scrollTop+=(e.bottom-t.bottom)/n)}})):this.selectedIndex<0&&this.list.removeAttribute(`aria-activedescendant`),r&&this.sync()}sync(){let e=this.list.firstChild;function t(){let t=e;e=t.nextSibling,t.remove()}for(let n of this.items)if(n.dom.parentNode==this.list){for(;e!=n.dom;)t();e=n.dom.nextSibling}else this.list.insertBefore(n.dom,e);for(;e;)t()}moveSelection(e){if(this.selectedIndex<0)return;let t=uo(this.view.state.field(Q).diagnostics,this.items[e].diagnostic);t&&this.view.dispatch({selection:{anchor:t.from,head:t.to},scrollIntoView:!0,effects:go.of(t)})}static open(t){return new e(t)}};function Ao(e,t=`viewBox="0 0 40 40"`){return`url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" ${t}>${encodeURIComponent(e)}</svg>')`}function jo(e){return Ao(`<path d="m0 2.5 l2 -1.5 l1 0 l2 1.5 l1 0" stroke="${e}" fill="none" stroke-width=".7"/>`,`width="6" height="3"`)}var Mo=U.baseTheme({".cm-diagnostic":{padding:`3px 6px 3px 8px`,marginLeft:`-1px`,display:`block`,whiteSpace:`pre-wrap`},".cm-diagnostic-error":{borderLeft:`5px solid #d11`},".cm-diagnostic-warning":{borderLeft:`5px solid orange`},".cm-diagnostic-info":{borderLeft:`5px solid #999`},".cm-diagnostic-hint":{borderLeft:`5px solid #66d`},".cm-diagnosticAction":{font:`inherit`,border:`none`,padding:`2px 4px`,backgroundColor:`#444`,color:`white`,borderRadius:`3px`,marginLeft:`8px`,cursor:`pointer`},".cm-diagnosticSource":{fontSize:`70%`,opacity:.7},".cm-lintRange":{backgroundPosition:`left bottom`,backgroundRepeat:`repeat-x`,paddingBottom:`0.7px`},".cm-lintRange-error":{backgroundImage:jo(`#d11`)},".cm-lintRange-warning":{backgroundImage:jo(`orange`)},".cm-lintRange-info":{backgroundImage:jo(`#999`)},".cm-lintRange-hint":{backgroundImage:jo(`#66d`)},".cm-lintRange-active":{backgroundColor:`#ffdd9980`},".cm-tooltip-lint":{padding:0,margin:0},".cm-lintPoint":{position:`relative`,"&:after":{content:`""`,position:`absolute`,bottom:0,left:`-2px`,borderLeft:`3px solid transparent`,borderRight:`3px solid transparent`,borderBottom:`4px solid #d11`}},".cm-lintPoint-warning":{"&:after":{borderBottomColor:`orange`}},".cm-lintPoint-info":{"&:after":{borderBottomColor:`#999`}},".cm-lintPoint-hint":{"&:after":{borderBottomColor:`#66d`}},".cm-panel.cm-panel-lint":{position:`relative`,"& ul":{maxHeight:`100px`,overflowY:`auto`,"& [aria-selected]":{backgroundColor:`#ddd`,"& u":{textDecoration:`underline`}},"&:focus [aria-selected]":{background_fallback:`#bdf`,backgroundColor:`Highlight`,color_fallback:`white`,color:`HighlightText`},"& u":{textDecoration:`none`},padding:0,margin:0},"& [name=close]":{position:`absolute`,top:`0`,right:`2px`,background:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0}},"&dark .cm-lintRange-active":{backgroundColor:`#86714a80`},"&dark .cm-panel.cm-panel-lint ul":{"& [aria-selected]":{backgroundColor:`#2e343e`}}});function No(e){return e==`error`?4:e==`warning`?3:e==`info`?2:1}function Po(e){let t=`hint`,n=1;for(let r of e){let e=No(r.severity);e>n&&(n=e,t=r.severity)}return t}var Fo=[Q,U.decorations.compute([Q],e=>{let{selected:t,panel:n}=e.field(Q);return!t||!n||t.from==t.to?J.none:J.set([_o.range(t.from,t.to)])}),We(vo,{hideOn:fo}),Mo],Io=function(e){e===void 0&&(e={});var{crosshairCursor:t=!1}=e,n=[];e.closeBracketsKeymap!==!1&&(n=n.concat(it)),e.defaultKeymap!==!1&&(n=n.concat(nt)),e.searchKeymap!==!1&&(n=n.concat(et)),e.historyKeymap!==!1&&(n=n.concat(Qe)),e.foldKeymap!==!1&&(n=n.concat(Ye)),e.completionKeymap!==!1&&(n=n.concat(st)),e.lintKeymap!==!1&&(n=n.concat(So));var r=[];return e.lineNumbers!==!1&&r.push(ze()),e.highlightActiveLineGutter!==!1&&r.push(K()),e.highlightSpecialChars!==!1&&r.push(He()),e.history!==!1&&r.push(Ze()),e.foldGutter!==!1&&r.push(Xe()),e.drawSelection!==!1&&r.push(R()),e.dropCursor!==!1&&r.push(Pe()),e.allowMultipleSelections!==!1&&r.push(Te.allowMultipleSelections.of(!0)),e.indentOnInput!==!1&&r.push(Ee()),e.syntaxHighlighting!==!1&&r.push(Oe(Ue,{fallback:!0})),e.bracketMatching!==!1&&r.push(Ke()),e.closeBrackets!==!1&&r.push(ct()),e.autocompletion!==!1&&r.push(ot()),e.rectangularSelection!==!1&&r.push(Fe()),t!==!1&&r.push(V()),e.highlightActiveLine!==!1&&r.push(Ie()),e.highlightSelectionMatches!==!1&&r.push(tt()),e.tabSize&&typeof e.tabSize==`number`&&r.push(Re.of(` `.repeat(e.tabSize))),r.concat([Me.of(n.flat())]).filter(Boolean)},Lo=`#e5c07b`,Ro=`#e06c75`,zo=`#56b6c2`,Bo=`#ffffff`,Vo=`#abb2bf`,Ho=`#7d8799`,Uo=`#61afef`,Wo=`#98c379`,Go=`#d19a66`,Ko=`#c678dd`,qo=`#21252b`,Jo=`#2c313a`,Yo=`#282c34`,Xo=`#353a42`,Zo=`#3E4451`,Qo=`#528bff`,$o=U.theme({"&":{color:Vo,backgroundColor:Yo},".cm-content":{caretColor:Qo},".cm-cursor, .cm-dropCursor":{borderLeftColor:Qo},"&.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-selectionBackground, .cm-content ::selection":{backgroundColor:Zo},".cm-panels":{backgroundColor:qo,color:Vo},".cm-panels.cm-panels-top":{borderBottom:`2px solid black`},".cm-panels.cm-panels-bottom":{borderTop:`2px solid black`},".cm-searchMatch":{backgroundColor:`#72a1ff59`,outline:`1px solid #457dff`},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:`#6199ff2f`},".cm-activeLine":{backgroundColor:`#6699ff0b`},".cm-selectionMatch":{backgroundColor:`#aafe661a`},"&.cm-focused .cm-matchingBracket, &.cm-focused .cm-nonmatchingBracket":{backgroundColor:`#bad0f847`},".cm-gutters":{backgroundColor:Yo,color:Ho,border:`none`},".cm-activeLineGutter":{backgroundColor:Jo},".cm-foldPlaceholder":{backgroundColor:`transparent`,border:`none`,color:`#ddd`},".cm-tooltip":{border:`none`,backgroundColor:Xo},".cm-tooltip .cm-tooltip-arrow:before":{borderTopColor:`transparent`,borderBottomColor:`transparent`},".cm-tooltip .cm-tooltip-arrow:after":{borderTopColor:Xo,borderBottomColor:Xo},".cm-tooltip-autocomplete":{"& > ul > li[aria-selected]":{backgroundColor:Jo,color:Vo}}},{dark:!0}),es=Ge.define([{tag:B.keyword,color:Ko},{tag:[B.name,B.deleted,B.character,B.propertyName,B.macroName],color:Ro},{tag:[B.function(B.variableName),B.labelName],color:Uo},{tag:[B.color,B.constant(B.name),B.standard(B.name)],color:Go},{tag:[B.definition(B.name),B.separator],color:Vo},{tag:[B.typeName,B.className,B.number,B.changed,B.annotation,B.modifier,B.self,B.namespace],color:Lo},{tag:[B.operator,B.operatorKeyword,B.url,B.escape,B.regexp,B.link,B.special(B.string)],color:zo},{tag:[B.meta,B.comment],color:Ho},{tag:B.strong,fontWeight:`bold`},{tag:B.emphasis,fontStyle:`italic`},{tag:B.strikethrough,textDecoration:`line-through`},{tag:B.link,color:Ho,textDecoration:`underline`},{tag:B.heading,fontWeight:`bold`,color:Ro},{tag:[B.atom,B.bool,B.special(B.variableName)],color:Go},{tag:[B.processingInstruction,B.string,B.inserted],color:Wo},{tag:B.invalid,color:Bo}]),ts=[$o,Oe(es)],ns=U.theme({"&":{backgroundColor:`#fff`}},{dark:!1}),rs=function(e){e===void 0&&(e={});var{indentWithTab:t=!0,editable:n=!0,readOnly:r=!1,theme:i=`light`,placeholder:a=``,basicSetup:o=!0}=e,s=[];switch(t&&s.unshift(Me.of([$e])),o&&(typeof o==`boolean`?s.unshift(Io()):s.unshift(Io(o))),a&&s.unshift(Ne(a)),i){case`light`:s.push(ns);break;case`dark`:s.push(ts);break;case`none`:break;default:s.push(i)}return n===!1&&s.push(U.editable.of(!1)),r&&s.push(Te.readOnly.of(!0)),[...s]},is=e=>({line:e.state.doc.lineAt(e.state.selection.main.from),lineCount:e.state.doc.lines,lineBreak:e.state.lineBreak,length:e.state.doc.length,readOnly:e.state.readOnly,tabSize:e.state.tabSize,selection:e.state.selection,selectionAsSingle:e.state.selection.asSingle().main,ranges:e.state.selection.ranges,selectionCode:e.state.sliceDoc(e.state.selection.main.from,e.state.selection.main.to),selections:e.state.selection.ranges.map(t=>e.state.sliceDoc(t.from,t.to)),selectedText:e.state.selection.ranges.some(e=>!e.empty)}),as=class{constructor(e,t){this.timeLeftMS=void 0,this.timeoutMS=void 0,this.isCancelled=!1,this.isTimeExhausted=!1,this.callbacks=[],this.timeLeftMS=t,this.timeoutMS=t,this.callbacks.push(e)}tick(){if(!this.isCancelled&&!this.isTimeExhausted&&(this.timeLeftMS--,this.timeLeftMS<=0)){this.isTimeExhausted=!0;var e=this.callbacks.slice();this.callbacks.length=0,e.forEach(e=>{try{e()}catch(e){console.error(`TimeoutLatch callback error:`,e)}})}}cancel(){this.isCancelled=!0,this.callbacks.length=0}reset(){this.timeLeftMS=this.timeoutMS,this.isCancelled=!1,this.isTimeExhausted=!1}get isDone(){return this.isCancelled||this.isTimeExhausted}},os=class{constructor(){this.interval=null,this.latches=new Set}add(e){this.latches.add(e),this.start()}remove(e){this.latches.delete(e),this.latches.size===0&&this.stop()}start(){this.interval===null&&(this.interval=setInterval(()=>{this.latches.forEach(e=>{e.tick(),e.isDone&&this.remove(e)})},1))}stop(){this.interval!==null&&(clearInterval(this.interval),this.interval=null)}},ss=null,cs=()=>typeof window>`u`?new os:(ss||=new os,ss),ls=qe.define(),us=200,ds=[];function fs(e){var{value:t,selection:n,onChange:r,onStatistics:i,onCreateEditor:a,onUpdate:o,extensions:s=ds,autoFocus:c,theme:l=`light`,height:u=null,minHeight:d=null,maxHeight:f=null,width:p=null,minWidth:m=null,maxWidth:h=null,placeholder:g=``,editable:_=!0,readOnly:v=!1,indentWithTab:y=!0,basicSetup:b=!0,root:x,initialState:S}=e,[C,w]=(0,Y.useState)(),[T,E]=(0,Y.useState)(),[D,O]=(0,Y.useState)(),k=(0,Y.useState)(()=>({current:null}))[0],ee=(0,Y.useState)(()=>({current:null}))[0],A=U.theme({"&":{height:u,minHeight:d,maxHeight:f,width:p,minWidth:m,maxWidth:h},"& .cm-scroller":{height:`100% !important`}}),j=[U.updateListener.of(e=>{e.docChanged&&typeof r==`function`&&!e.transactions.some(e=>e.annotation(ls))&&(k.current?k.current.reset():(k.current=new as(()=>{if(ee.current){var e=ee.current;ee.current=null,e()}k.current=null},us),cs().add(k.current)),r(e.state.doc.toString(),e)),i&&i(is(e))}),A,...rs({theme:l,editable:_,readOnly:v,placeholder:g,indentWithTab:y,basicSetup:b})];return o&&typeof o==`function`&&j.push(U.updateListener.of(o)),j=j.concat(s),(0,Y.useLayoutEffect)(()=>{if(C&&!D){var e={doc:t,selection:n,extensions:j},r=S?Te.fromJSON(S.json,e,S.fields):Te.create(e);if(O(r),!T){var i=new U({state:r,parent:C,root:x});E(i),a&&a(i,r)}}return()=>{T&&(O(void 0),E(void 0))}},[C,D]),(0,Y.useEffect)(()=>{e.container&&w(e.container)},[e.container]),(0,Y.useEffect)(()=>()=>{T&&(T.destroy(),E(void 0)),k.current&&=(k.current.cancel(),null)},[T]),(0,Y.useEffect)(()=>{c&&T&&T.focus()},[c,T]),(0,Y.useEffect)(()=>{T&&T.dispatch({effects:we.reconfigure.of(j)})},[l,s,u,d,f,p,m,h,g,_,v,y,b,r,o]),(0,Y.useEffect)(()=>{if(t!==void 0){var e=T?T.state.doc.toString():``;if(T&&t!==e){var n=k.current&&!k.current.isDone,r=()=>{T&&t!==T.state.doc.toString()&&T.dispatch({changes:{from:0,to:T.state.doc.toString().length,insert:t||``},annotations:[ls.of(!0)]})};n?ee.current=r:r()}}},[t,T]),{state:D,setState:O,view:T,setView:E,container:C,setContainer:w}}var ps=[`className`,`value`,`selection`,`extensions`,`onChange`,`onStatistics`,`onCreateEditor`,`onUpdate`,`autoFocus`,`theme`,`height`,`minHeight`,`maxHeight`,`width`,`minWidth`,`maxWidth`,`basicSetup`,`placeholder`,`indentWithTab`,`editable`,`readOnly`,`root`,`initialState`],ms=(0,Y.forwardRef)((e,t)=>{var{className:n,value:r=``,selection:i,extensions:a=[],onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,autoFocus:u,theme:d=`light`,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:v,placeholder:y,indentWithTab:b,editable:x,readOnly:S,root:C,initialState:w}=e,T=so(e,ps),E=(0,Y.useRef)(null),{state:D,view:O,container:k,setContainer:ee}=fs({root:C,value:r,autoFocus:u,theme:d,height:f,minHeight:p,maxHeight:m,width:h,minWidth:g,maxWidth:_,basicSetup:v,placeholder:y,indentWithTab:b,editable:x,readOnly:S,selection:i,onChange:o,onStatistics:s,onCreateEditor:c,onUpdate:l,extensions:a,initialState:w});(0,Y.useImperativeHandle)(t,()=>({editor:E.current,state:D,view:O}),[E,k,D,O]);var A=(0,Y.useCallback)(e=>{E.current=e,ee(e)},[ee]);if(typeof r!=`string`)throw Error(`value must be typeof string but got `+typeof r);var j=typeof d==`string`?`cm-theme-`+d:`cm-theme`;return(0,X.jsx)(`div`,oo({ref:A,className:``+j+(n?` `+n:``)},T))});ms.displayName=`CodeMirror`;function $(e){return new Ve(je.define(e))}function hs(e){return t(()=>import(`./dist-TN2_Nms3.js`).then(t=>t.sql({dialect:t[e]})),[])}var gs=[G.of({name:`C`,extensions:[`c`,`h`,`ino`],load(){return t(()=>import(`./dist-ClT6EIJP.js`).then(e=>e.cpp()),[])}}),G.of({name:`C++`,alias:[`cpp`],extensions:[`cpp`,`c++`,`cc`,`cxx`,`hpp`,`h++`,`hh`,`hxx`],load(){return t(()=>import(`./dist-ClT6EIJP.js`).then(e=>e.cpp()),[])}}),G.of({name:`CQL`,alias:[`cassandra`],extensions:[`cql`],load(){return hs(`Cassandra`)}}),G.of({name:`CSS`,extensions:[`css`],load(){return t(()=>import(`./dist-Y0iINzVl.js`).then(e=>e.css()),[])}}),G.of({name:`Go`,extensions:[`go`],load(){return t(()=>import(`./dist-Ohtnri73.js`).then(e=>e.go()),[])}}),G.of({name:`HTML`,alias:[`xhtml`],extensions:[`html`,`htm`,`handlebars`,`hbs`],load(){return t(()=>import(`./dist-Dxy8kUAu.js`).then(e=>e.html()),[])}}),G.of({name:`Java`,extensions:[`java`],load(){return t(()=>import(`./dist-DJGc9cyj.js`).then(e=>e.java()),[])}}),G.of({name:`JavaScript`,alias:[`ecmascript`,`js`,`node`],extensions:[`js`,`mjs`,`cjs`],load(){return t(()=>import(`./dist-C9i-hLBK.js`).then(e=>e.javascript()),[])}}),G.of({name:`Jinja`,extensions:[`j2`,`jinja`,`jinja2`],load(){return t(()=>import(`./dist-XM8qpb8C.js`).then(e=>e.jinja()),[])}}),G.of({name:`JSON`,alias:[`json5`],extensions:[`json`,`map`],load(){return t(()=>import(`./dist-CGUtB2hn.js`).then(e=>e.json()),[])}}),G.of({name:`JSX`,extensions:[`jsx`],load(){return t(()=>import(`./dist-C9i-hLBK.js`).then(e=>e.javascript({jsx:!0})),[])}}),G.of({name:`LESS`,extensions:[`less`],load(){return t(()=>import(`./dist-lsEiXLAb.js`).then(e=>e.less()),[])}}),G.of({name:`Liquid`,extensions:[`liquid`],load(){return t(()=>import(`./dist-CJNnOuaA.js`).then(e=>e.liquid()),[])}}),G.of({name:`MariaDB SQL`,load(){return hs(`MariaSQL`)}}),G.of({name:`Markdown`,extensions:[`md`,`markdown`,`mkd`],load(){return t(()=>import(`./dist-CPYD5RoF.js`).then(e=>e.markdown()),[])}}),G.of({name:`MS SQL`,load(){return hs(`MSSQL`)}}),G.of({name:`MySQL`,load(){return hs(`MySQL`)}}),G.of({name:`PHP`,extensions:[`php`,`php3`,`php4`,`php5`,`php7`,`phtml`],load(){return t(()=>import(`./dist-B2ugUS7T.js`).then(e=>e.php()),[])}}),G.of({name:`PLSQL`,extensions:[`pls`],load(){return hs(`PLSQL`)}}),G.of({name:`PostgreSQL`,load(){return hs(`PostgreSQL`)}}),G.of({name:`Python`,extensions:[`BUILD`,`bzl`,`py`,`pyw`],filename:/^(BUCK|BUILD)$/,load(){return t(()=>import(`./dist--wUCkuiC.js`).then(e=>e.python()),[])}}),G.of({name:`Rust`,extensions:[`rs`],load(){return t(()=>import(`./dist-Cbkb9LHa.js`).then(e=>e.rust()),[])}}),G.of({name:`Sass`,extensions:[`sass`],load(){return t(()=>import(`./dist-Box-O1ow.js`).then(e=>e.sass({indented:!0})),[])}}),G.of({name:`SCSS`,extensions:[`scss`],load(){return t(()=>import(`./dist-Box-O1ow.js`).then(e=>e.sass()),[])}}),G.of({name:`SQL`,extensions:[`sql`],load(){return hs(`StandardSQL`)}}),G.of({name:`SQLite`,load(){return hs(`SQLite`)}}),G.of({name:`TSX`,extensions:[`tsx`],load(){return t(()=>import(`./dist-C9i-hLBK.js`).then(e=>e.javascript({jsx:!0,typescript:!0})),[])}}),G.of({name:`TypeScript`,alias:[`ts`],extensions:[`ts`,`mts`,`cts`],load(){return t(()=>import(`./dist-C9i-hLBK.js`).then(e=>e.javascript({typescript:!0})),[])}}),G.of({name:`WebAssembly`,extensions:[`wat`,`wast`],load(){return t(()=>import(`./dist-Ds6qQDMC.js`).then(e=>e.wast()),[])}}),G.of({name:`XML`,alias:[`rss`,`wsdl`,`xsd`],extensions:[`xml`,`xsl`,`xsd`,`svg`],load(){return t(()=>import(`./dist-B_o5XbiL.js`).then(e=>e.xml()),[])}}),G.of({name:`YAML`,alias:[`yml`],extensions:[`yaml`,`yml`],load(){return t(()=>import(`./dist-CW1HDUim.js`).then(e=>e.yaml()),[])}}),G.of({name:`APL`,extensions:[`dyalog`,`apl`],load(){return t(()=>import(`./apl-gfMMiTNf.js`).then(e=>$(e.apl)),[])}}),G.of({name:`PGP`,alias:[`asciiarmor`],extensions:[`asc`,`pgp`,`sig`],load(){return t(()=>import(`./asciiarmor-C_eisQCp.js`).then(e=>$(e.asciiArmor)),[])}}),G.of({name:`ASN.1`,extensions:[`asn`,`asn1`],load(){return t(()=>import(`./asn1-DCl_8MCW.js`).then(e=>$(e.asn1({}))),[])}}),G.of({name:`Asterisk`,filename:/^extensions\.conf$/i,load(){return t(()=>import(`./asterisk-BEn0Cwpx.js`).then(e=>$(e.asterisk)),[])}}),G.of({name:`Brainfuck`,extensions:[`b`,`bf`],load(){return t(()=>import(`./brainfuck-D5EjA2JK.js`).then(e=>$(e.brainfuck)),[])}}),G.of({name:`Cobol`,extensions:[`cob`,`cpy`],load(){return t(()=>import(`./cobol-DHLQUbN7.js`).then(e=>$(e.cobol)),[])}}),G.of({name:`C#`,alias:[`csharp`,`cs`],extensions:[`cs`],load(){return t(()=>import(`./clike-D_6L3tnO.js`).then(e=>$(e.csharp)),[])}}),G.of({name:`Clojure`,extensions:[`clj`,`cljc`,`cljx`],load(){return t(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[])}}),G.of({name:`ClojureScript`,extensions:[`cljs`],load(){return t(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[])}}),G.of({name:`Closure Stylesheets (GSS)`,extensions:[`gss`],load(){return t(()=>import(`./css-CnaYoQib.js`).then(e=>$(e.gss)),[])}}),G.of({name:`CMake`,extensions:[`cmake`,`cmake.in`],filename:/^CMakeLists\.txt$/,load(){return t(()=>import(`./cmake-84nbDH0I.js`).then(e=>$(e.cmake)),[])}}),G.of({name:`CoffeeScript`,alias:[`coffee`,`coffee-script`],extensions:[`coffee`],load(){return t(()=>import(`./coffeescript-De_zI4J0.js`).then(e=>$(e.coffeeScript)),[])}}),G.of({name:`Common Lisp`,alias:[`lisp`],extensions:[`cl`,`lisp`,`el`],load(){return t(()=>import(`./commonlisp-DgAKBe0r.js`).then(e=>$(e.commonLisp)),[])}}),G.of({name:`Cypher`,extensions:[`cyp`,`cypher`],load(){return t(()=>import(`./cypher-p9eYesGn.js`).then(e=>$(e.cypher)),[])}}),G.of({name:`Cython`,extensions:[`pyx`,`pxd`,`pxi`],load(){return t(()=>import(`./python-B_1Jd8HM.js`).then(e=>$(e.cython)),[])}}),G.of({name:`Crystal`,extensions:[`cr`],load(){return t(()=>import(`./crystal-Bsdphhtm.js`).then(e=>$(e.crystal)),[])}}),G.of({name:`D`,extensions:[`d`],load(){return t(()=>import(`./d-DWkQyNnU.js`).then(e=>$(e.d)),[])}}),G.of({name:`Dart`,extensions:[`dart`],load(){return t(()=>import(`./clike-D_6L3tnO.js`).then(e=>$(e.dart)),[])}}),G.of({name:`diff`,extensions:[`diff`,`patch`],load(){return t(()=>import(`./diff-ChtP43wD.js`).then(e=>$(e.diff)),[])}}),G.of({name:`Dockerfile`,filename:/^Dockerfile$/,load(){return t(()=>import(`./dockerfile-DJkHQgkl.js`).then(e=>$(e.dockerFile)),[])}}),G.of({name:`DTD`,extensions:[`dtd`],load(){return t(()=>import(`./dtd-DTF72YNO.js`).then(e=>$(e.dtd)),[])}}),G.of({name:`Dylan`,extensions:[`dylan`,`dyl`,`intr`],load(){return t(()=>import(`./dylan-BCDoL_-p.js`).then(e=>$(e.dylan)),[])}}),G.of({name:`EBNF`,load(){return t(()=>import(`./ebnf-D4c0_ac3.js`).then(e=>$(e.ebnf)),[])}}),G.of({name:`ECL`,extensions:[`ecl`],load(){return t(()=>import(`./ecl-BVIeWmwY.js`).then(e=>$(e.ecl)),[])}}),G.of({name:`edn`,extensions:[`edn`],load(){return t(()=>import(`./clojure-BflJGmDX.js`).then(e=>$(e.clojure)),[])}}),G.of({name:`Eiffel`,extensions:[`e`],load(){return t(()=>import(`./eiffel-BEjRio4Q.js`).then(e=>$(e.eiffel)),[])}}),G.of({name:`Elm`,extensions:[`elm`],load(){return t(()=>import(`./elm-Cshzl8qu.js`).then(e=>$(e.elm)),[])}}),G.of({name:`Erlang`,extensions:[`erl`],load(){return t(()=>import(`./erlang-BV0c4Hdn.js`).then(e=>$(e.erlang)),[])}}),G.of({name:`Esper`,load(){return t(()=>import(`./sql-DuQMFDvy.js`).then(e=>$(e.esper)),[])}}),G.of({name:`Factor`,extensions:[`factor`],load(){return t(()=>import(`./factor-LKH5gN8L.js`).then(e=>$(e.factor)),[])}}),G.of({name:`FCL`,load(){return t(()=>import(`./fcl-ClOhbFR7.js`).then(e=>$(e.fcl)),[])}}),G.of({name:`Forth`,extensions:[`forth`,`fth`,`4th`],load(){return t(()=>import(`./forth-D6RzAl64.js`).then(e=>$(e.forth)),[])}}),G.of({name:`Fortran`,extensions:[`f`,`for`,`f77`,`f90`,`f95`],load(){return t(()=>import(`./fortran-Bt6PBEDR.js`).then(e=>$(e.fortran)),[])}}),G.of({name:`F#`,alias:[`fsharp`],extensions:[`fs`],load(){return t(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.fSharp)),[])}}),G.of({name:`Gas`,extensions:[`s`],load(){return t(()=>import(`./gas-BHEdbvp9.js`).then(e=>$(e.gas)),[])}}),G.of({name:`Gherkin`,extensions:[`feature`],load(){return t(()=>import(`./gherkin-oBAE_ms0.js`).then(e=>$(e.gherkin)),[])}}),G.of({name:`Groovy`,extensions:[`groovy`,`gradle`],filename:/^Jenkinsfile$/,load(){return t(()=>import(`./groovy-CUpZ7dEl.js`).then(e=>$(e.groovy)),[])}}),G.of({name:`Haskell`,extensions:[`hs`],load(){return t(()=>import(`./haskell-BRsoo5mP.js`).then(e=>$(e.haskell)),[])}}),G.of({name:`Haxe`,extensions:[`hx`],load(){return t(()=>import(`./haxe-DjVOVvNP.js`).then(e=>$(e.haxe)),[])}}),G.of({name:`HXML`,extensions:[`hxml`],load(){return t(()=>import(`./haxe-DjVOVvNP.js`).then(e=>$(e.hxml)),[])}}),G.of({name:`HTTP`,load(){return t(()=>import(`./http-CLVgA2GD.js`).then(e=>$(e.http)),[])}}),G.of({name:`IDL`,extensions:[`pro`],load(){return t(()=>import(`./idl-BUZw3wgd.js`).then(e=>$(e.idl)),[])}}),G.of({name:`JSON-LD`,alias:[`jsonld`],extensions:[`jsonld`],load(){return t(()=>import(`./javascript-DctB8BJo.js`).then(e=>$(e.jsonld)),[])}}),G.of({name:`Julia`,extensions:[`jl`],load(){return t(()=>import(`./julia-CQfgDRfP.js`).then(e=>$(e.julia)),[])}}),G.of({name:`Kotlin`,extensions:[`kt`,`kts`],load(){return t(()=>import(`./clike-D_6L3tnO.js`).then(e=>$(e.kotlin)),[])}}),G.of({name:`LiveScript`,alias:[`ls`],extensions:[`ls`],load(){return t(()=>import(`./livescript-BXxG0Yva.js`).then(e=>$(e.liveScript)),[])}}),G.of({name:`Lua`,extensions:[`lua`],load(){return t(()=>import(`./lua-zbJo2mq3.js`).then(e=>$(e.lua)),[])}}),G.of({name:`mIRC`,extensions:[`mrc`],load(){return t(()=>import(`./mirc-C9zpzAZU.js`).then(e=>$(e.mirc)),[])}}),G.of({name:`Mathematica`,extensions:[`m`,`nb`,`wl`,`wls`],load(){return t(()=>import(`./mathematica-u8YMmbU0.js`).then(e=>$(e.mathematica)),[])}}),G.of({name:`Modelica`,extensions:[`mo`],load(){return t(()=>import(`./modelica-CqHI_q-D.js`).then(e=>$(e.modelica)),[])}}),G.of({name:`MUMPS`,extensions:[`mps`],load(){return t(()=>import(`./mumps-BSzj6Xyz.js`).then(e=>$(e.mumps)),[])}}),G.of({name:`Mbox`,extensions:[`mbox`],load(){return t(()=>import(`./mbox-BEMVcqjs.js`).then(e=>$(e.mbox)),[])}}),G.of({name:`Nginx`,filename:/nginx.*\.conf$/i,load(){return t(()=>import(`./nginx-8H7HVH4w.js`).then(e=>$(e.nginx)),[])}}),G.of({name:`NSIS`,extensions:[`nsh`,`nsi`],load(){return t(()=>import(`./nsis-CfSuhXs5.js`).then(e=>$(e.nsis)),[])}}),G.of({name:`NTriples`,extensions:[`nt`,`nq`],load(){return t(()=>import(`./ntriples-B9h1VB_g.js`).then(e=>$(e.ntriples)),[])}}),G.of({name:`Objective-C`,alias:[`objective-c`,`objc`],extensions:[`m`],load(){return t(()=>import(`./clike-D_6L3tnO.js`).then(e=>$(e.objectiveC)),[])}}),G.of({name:`Objective-C++`,alias:[`objective-c++`,`objc++`],extensions:[`mm`],load(){return t(()=>import(`./clike-D_6L3tnO.js`).then(e=>$(e.objectiveCpp)),[])}}),G.of({name:`OCaml`,extensions:[`ml`,`mli`,`mll`,`mly`],load(){return t(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.oCaml)),[])}}),G.of({name:`Octave`,extensions:[`m`],load(){return t(()=>import(`./octave-D2Q8cUp1.js`).then(e=>$(e.octave)),[])}}),G.of({name:`Oz`,extensions:[`oz`],load(){return t(()=>import(`./oz-BwTct_5T.js`).then(e=>$(e.oz)),[])}}),G.of({name:`Pascal`,extensions:[`p`,`pas`],load(){return t(()=>import(`./pascal-Dp_KdFgX.js`).then(e=>$(e.pascal)),[])}}),G.of({name:`Perl`,extensions:[`pl`,`pm`],load(){return t(()=>import(`./perl-BkSkiI9m.js`).then(e=>$(e.perl)),[])}}),G.of({name:`Pig`,extensions:[`pig`],load(){return t(()=>import(`./pig-AF4Hwhju.js`).then(e=>$(e.pig)),[])}}),G.of({name:`PowerShell`,extensions:[`ps1`,`psd1`,`psm1`],load(){return t(()=>import(`./powershell-BcIto6Sf.js`).then(e=>$(e.powerShell)),[])}}),G.of({name:`Properties files`,alias:[`ini`,`properties`],extensions:[`properties`,`ini`,`in`],load(){return t(()=>import(`./properties-C357ku5U.js`).then(e=>$(e.properties)),[])}}),G.of({name:`ProtoBuf`,extensions:[`proto`],load(){return t(()=>import(`./protobuf-D1ij_kNL.js`).then(e=>$(e.protobuf)),[])}}),G.of({name:`Pug`,alias:[`jade`],extensions:[`pug`,`jade`],load(){return t(()=>import(`./pug-CqqUmdG7.js`).then(e=>$(e.pug)),[])}}),G.of({name:`Puppet`,extensions:[`pp`],load(){return t(()=>import(`./puppet-BZyAS7I4.js`).then(e=>$(e.puppet)),[])}}),G.of({name:`Q`,extensions:[`q`],load(){return t(()=>import(`./q-B9NhS7L_.js`).then(e=>$(e.q)),[])}}),G.of({name:`R`,alias:[`rscript`],extensions:[`r`,`R`],load(){return t(()=>import(`./r-CxDmU1I4.js`).then(e=>$(e.r)),[])}}),G.of({name:`RPM Changes`,load(){return t(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmChanges)),[])}}),G.of({name:`RPM Spec`,extensions:[`spec`],load(){return t(()=>import(`./rpm-gpDK5sbt.js`).then(e=>$(e.rpmSpec)),[])}}),G.of({name:`Ruby`,alias:[`jruby`,`macruby`,`rake`,`rb`,`rbx`],extensions:[`rb`],filename:/^(Gemfile|Rakefile)$/,load(){return t(()=>import(`./ruby-BjXV7-Qa.js`).then(e=>$(e.ruby)),[])}}),G.of({name:`SAS`,extensions:[`sas`],load(){return t(()=>import(`./sas-C2OyD2Y6.js`).then(e=>$(e.sas)),[])}}),G.of({name:`Scala`,extensions:[`scala`],load(){return t(()=>import(`./clike-D_6L3tnO.js`).then(e=>$(e.scala)),[])}}),G.of({name:`Scheme`,extensions:[`scm`,`ss`],load(){return t(()=>import(`./scheme-D9qYN0V5.js`).then(e=>$(e.scheme)),[])}}),G.of({name:`Shell`,alias:[`bash`,`sh`,`zsh`],extensions:[`sh`,`ksh`,`bash`],filename:/^PKGBUILD$/,load(){return t(()=>import(`./shell-DwuoZtxw.js`).then(e=>$(e.shell)),[])}}),G.of({name:`Sieve`,extensions:[`siv`,`sieve`],load(){return t(()=>import(`./sieve-tLWDfEkZ.js`).then(e=>$(e.sieve)),[])}}),G.of({name:`Smalltalk`,extensions:[`st`],load(){return t(()=>import(`./smalltalk-BLp5-jwC.js`).then(e=>$(e.smalltalk)),[])}}),G.of({name:`Solr`,load(){return t(()=>import(`./solr-B78wSQJQ.js`).then(e=>$(e.solr)),[])}}),G.of({name:`SML`,extensions:[`sml`,`sig`,`fun`,`smackspec`],load(){return t(()=>import(`./mllike-B45xgp2S.js`).then(e=>$(e.sml)),[])}}),G.of({name:`SPARQL`,alias:[`sparul`],extensions:[`rq`,`sparql`],load(){return t(()=>import(`./sparql-Dz-mlCAC.js`).then(e=>$(e.sparql)),[])}}),G.of({name:`Spreadsheet`,alias:[`excel`,`formula`],load(){return t(()=>import(`./spreadsheet-CTIncYxj.js`).then(e=>$(e.spreadsheet)),[])}}),G.of({name:`Squirrel`,extensions:[`nut`],load(){return t(()=>import(`./clike-D_6L3tnO.js`).then(e=>$(e.squirrel)),[])}}),G.of({name:`Stylus`,extensions:[`styl`],load(){return t(()=>import(`./stylus-BOVgKnng.js`).then(e=>$(e.stylus)),[])}}),G.of({name:`Swift`,extensions:[`swift`],load(){return t(()=>import(`./swift-DKB6_1j6.js`).then(e=>$(e.swift)),[])}}),G.of({name:`sTeX`,load(){return t(()=>import(`./stex-DNzd62Q_.js`).then(e=>$(e.stex)),[])}}),G.of({name:`LaTeX`,alias:[`tex`],extensions:[`text`,`ltx`,`tex`],load(){return t(()=>import(`./stex-DNzd62Q_.js`).then(e=>$(e.stex)),[])}}),G.of({name:`SystemVerilog`,extensions:[`v`,`sv`,`svh`],load(){return t(()=>import(`./verilog-CjI9Y6RI.js`).then(e=>$(e.verilog)),[])}}),G.of({name:`Tcl`,extensions:[`tcl`],load(){return t(()=>import(`./tcl-BGfruO1u.js`).then(e=>$(e.tcl)),[])}}),G.of({name:`Textile`,extensions:[`textile`],load(){return t(()=>import(`./textile-C4jVoHG1.js`).then(e=>$(e.textile)),[])}}),G.of({name:`TiddlyWiki`,load(){return t(()=>import(`./tiddlywiki-VlUiK86J.js`).then(e=>$(e.tiddlyWiki)),[])}}),G.of({name:`Tiki wiki`,load(){return t(()=>import(`./tiki-AK6FwT8q.js`).then(e=>$(e.tiki)),[])}}),G.of({name:`TOML`,extensions:[`toml`],load(){return t(()=>import(`./toml-BPTmHmyx.js`).then(e=>$(e.toml)),[])}}),G.of({name:`Troff`,extensions:[`1`,`2`,`3`,`4`,`5`,`6`,`7`,`8`,`9`],load(){return t(()=>import(`./troff-C2dAgh7P.js`).then(e=>$(e.troff)),[])}}),G.of({name:`TTCN`,extensions:[`ttcn`,`ttcn3`,`ttcnpp`],load(){return t(()=>import(`./ttcn-PPSTk1ow.js`).then(e=>$(e.ttcn)),[])}}),G.of({name:`TTCN_CFG`,extensions:[`cfg`],load(){return t(()=>import(`./ttcn-cfg-2b4Gb5sE.js`).then(e=>$(e.ttcnCfg)),[])}}),G.of({name:`Turtle`,extensions:[`ttl`],load(){return t(()=>import(`./turtle-Cx3rYX2g.js`).then(e=>$(e.turtle)),[])}}),G.of({name:`Web IDL`,extensions:[`webidl`],load(){return t(()=>import(`./webidl-D5jiJvOU.js`).then(e=>$(e.webIDL)),[])}}),G.of({name:`VB.NET`,extensions:[`vb`],load(){return t(()=>import(`./vb-BthdM_4N.js`).then(e=>$(e.vb)),[])}}),G.of({name:`VBScript`,extensions:[`vbs`],load(){return t(()=>import(`./vbscript-D9f6rSsU.js`).then(e=>$(e.vbScript)),[])}}),G.of({name:`Velocity`,extensions:[`vtl`],load(){return t(()=>import(`./velocity-CqftRsjg.js`).then(e=>$(e.velocity)),[])}}),G.of({name:`Verilog`,extensions:[`v`],load(){return t(()=>import(`./verilog-CjI9Y6RI.js`).then(e=>$(e.verilog)),[])}}),G.of({name:`VHDL`,extensions:[`vhd`,`vhdl`],load(){return t(()=>import(`./vhdl-kS471soi.js`).then(e=>$(e.vhdl)),[])}}),G.of({name:`XQuery`,extensions:[`xy`,`xquery`,`xq`,`xqm`,`xqy`],load(){return t(()=>import(`./xquery-BKJx4mf9.js`).then(e=>$(e.xQuery)),[])}}),G.of({name:`Yacas`,extensions:[`ys`],load(){return t(()=>import(`./yacas-CXXgtw0p.js`).then(e=>$(e.yacas)),[])}}),G.of({name:`Z80`,extensions:[`z80`],load(){return t(()=>import(`./z80-Co3PbHdE.js`).then(e=>$(e.z80)),[])}}),G.of({name:`MscGen`,extensions:[`mscgen`,`mscin`,`msc`],load(){return t(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.mscgen)),[])}}),G.of({name:`Xù`,extensions:[`xu`],load(){return t(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.xu)),[])}}),G.of({name:`MsGenny`,extensions:[`msgenny`],load(){return t(()=>import(`./mscgen-qgSLujhx.js`).then(e=>$(e.msgenny)),[])}}),G.of({name:`Vue`,extensions:[`vue`],load(){return t(()=>import(`./dist-DUl4SBwX.js`).then(e=>e.vue()),[])}}),G.of({name:`Angular Template`,load(){return t(()=>import(`./dist-B6-H00Bu.js`).then(e=>e.angular()),[])}})],_s=U.theme({"&":{height:`100%`,color:`var(--text-primary)`,backgroundColor:`var(--canvas-deep)`},".cm-editor":{height:`100%`,color:`var(--text-primary)`,backgroundColor:`var(--canvas-deep)`},".cm-scroller":{fontFamily:`ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace`,backgroundColor:`var(--canvas-deep)`},".cm-content":{caretColor:`var(--text-primary)`},".cm-gutters":{color:`var(--text-tertiary, var(--text-secondary))`,backgroundColor:`var(--canvas-deep)`,borderRight:`1px solid var(--border-subtle)`},".cm-activeLine":{backgroundColor:`var(--canvas-soft)`},".cm-activeLineGutter":{color:`var(--text-primary)`,backgroundColor:`var(--canvas-soft)`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--text-primary)`},"&.cm-focused .cm-selectionBackground, .cm-selectionBackground, ::selection":{backgroundColor:`var(--selection-bg)`},"&.cm-focused":{outline:`1px solid var(--border-strong)`},".cm-line":{color:`var(--text-primary)`},".cm-panels":{color:`var(--text-primary)`,backgroundColor:`var(--bg-panel)`,borderColor:`var(--border-subtle)`},".cm-tooltip":{color:`var(--text-primary)`,backgroundColor:`var(--bg-panel)`,border:`1px solid var(--border-subtle)`},".cm-matchingBracket, .cm-nonmatchingBracket":{outline:`1px solid var(--accent)`,backgroundColor:`var(--accent-soft)`},".cm-rich-widget":{color:`var(--text-primary)`,backgroundColor:`var(--canvas-soft)`,border:`1px solid var(--border-subtle)`,borderRadius:`6px`},".cm-rich-block":{display:`block`,margin:`6px 0`,padding:`8px 10px`,overflowX:`auto`},".cm-rich-inline":{display:`inline-flex`,alignItems:`center`,maxWidth:`100%`,padding:`0 4px`,verticalAlign:`baseline`},".cm-rich-source-muted":{color:`var(--text-tertiary, var(--text-secondary))`},".cm-rich-widget-error":{color:`var(--danger-strong, var(--text-primary))`,borderColor:`var(--danger-strong, var(--border-subtle))`}},{dark:!0}),vs=Ge.define([{tag:B.heading,color:`var(--text-primary)`,fontWeight:`650`},{tag:[B.strong,B.emphasis],color:`var(--text-primary)`},{tag:B.link,color:`var(--accent-strong, var(--accent))`,textDecoration:`underline`},{tag:B.url,color:`var(--accent-strong, var(--accent))`},{tag:[B.keyword,B.atom,B.bool],color:`var(--accent-strong, var(--accent))`},{tag:[B.string,B.special(B.string)],color:`var(--success-strong, var(--text-primary))`},{tag:[B.comment,B.quote],color:`var(--text-tertiary, var(--text-secondary))`},{tag:[B.number,B.integer,B.float],color:`var(--warning-strong, var(--text-primary))`},{tag:[B.variableName,B.propertyName],color:`var(--text-primary)`},{tag:[B.definition(B.variableName),B.function(B.variableName)],color:`var(--accent)`},{tag:[B.punctuation,B.bracket],color:`var(--text-secondary)`},{tag:B.invalid,color:`var(--danger-strong, var(--text-primary))`}]),ys=Oe(vs);function bs(e,t=e){return n=>{let{state:r}=n,i=!1,a=r.changeByRange(n=>{i=!0;let a=r.sliceDoc(n.from,n.to),o=`${e}${a}${t}`,s=n.from+e.length,c=s+a.length;return{changes:{from:n.from,to:n.to,insert:o},range:n.empty?H.cursor(s):H.range(s,c)}});return i?(n.dispatch(a),!0):!1}}var xs=[{key:`Mod-b`,run:bs(`**`),preventDefault:!0},{key:`Mod-i`,run:bs(`*`),preventDefault:!0},{key:`Mod-e`,run:bs("`"),preventDefault:!0},{key:`Mod-k`,run:e=>{let{state:t}=e,n=!1,r=t.changeByRange(e=>{n=!0;let r=t.sliceDoc(e.from,e.to);if(e.empty)return{changes:{from:e.from,insert:`[](url)`},range:H.cursor(e.from+1)};let i=`[${r}](url)`,a=e.from+1+r.length+2,o=a+3;return{changes:{from:e.from,to:e.to,insert:i},range:H.range(a,o)}});return n?(e.dispatch(r),!0):!1},preventDefault:!0}],Ss=u();function Cs(e){return(0,X.jsx)(X.Fragment,{children:e.widgets.map(e=>(0,Ss.createPortal)((0,X.jsx)(ut,{markdown:e.markdown}),e.shell,e.id))})}function ws(e,t,n){return n.selectionFrom<=t&&n.selectionTo>=e}function Ts(e,t){return new TextEncoder().encode(e).byteLength<=t.maxSnippetBytes}function Es(e,t,n){e.length>=n.maxWidgets||ws(t.from,t.to,n)||Ts(t.markdown,n)&&e.push(t)}function Ds(e,t){if(e.length>t.largeNoteDisableThreshold)return[];let n=[],r=0;for(let i of e.matchAll(/^```([^\n`]*)\n[\s\S]*?\n```[ \t]*$/gm)){if(n.length>=t.maxWidgets)break;let e=i.index||0,a=e+i[0].length,o=(i[1]||``).trim().toLowerCase();if(o===`mermaid`){if(r>=t.maxMermaidWidgets)continue;r+=1}Es(n,{from:e,to:a,kind:o===`mermaid`?`mermaid`:`code`,markdown:i[0],block:!0},t)}for(let r of e.matchAll(/^\$\$\n[\s\S]*?\n\$\$[ \t]*$/gm)){if(n.length>=t.maxWidgets)break;let e=r.index||0;Es(n,{from:e,to:e+r[0].length,kind:`math-block`,markdown:r[0],block:!0},t)}for(let r of e.matchAll(/(^|[^$\\])(\$[^$\n]+\$)/g)){if(n.length>=t.maxWidgets)break;let e=r[1].length,i=(r.index||0)+e,a=r[2];Es(n,{from:i,to:i+a.length,kind:`math-inline`,markdown:a,block:!1},t)}return n.sort((e,t)=>e.from-t.from||e.to-t.to)}var Os=class e extends Ae{options;constructor(e){super(),this.options=e}eq(t){return t instanceof e&&this.options.id===t.options.id&&this.options.kind===t.options.kind&&this.options.markdown===t.options.markdown}toDOM(){let e=document.createElement(this.options.block?`div`:`span`);return e.className=this.options.block?`cm-rich-widget cm-rich-block`:`cm-rich-widget cm-rich-inline`,e.dataset.richWidgetId=this.options.id,e.dataset.richWidgetKind=this.options.kind,this.options.registerWidget({id:this.options.id,kind:this.options.kind,markdown:this.options.markdown,shell:e}),queueMicrotask(this.options.requestMeasure),e}updateDOM(e){return this.options.registerWidget({id:this.options.id,kind:this.options.kind,markdown:this.options.markdown,shell:e}),queueMicrotask(this.options.requestMeasure),!0}destroy(){this.options.unregisterWidget(this.options.id)}get estimatedHeight(){return this.options.block?96:20}ignoreEvent(){return!1}},ks=50,As=100,js=5e4,Ms=5,Ns=1e6,Ps=/^([ \t]*[-*+][ \t]+)\[([ xX])\]([ \t]*)(.*)$/,Fs=class e extends Ae{range;constructor(e){super(),this.range=e}eq(t){return t instanceof e&&t.range.markerFrom===this.range.markerFrom&&t.range.checked===this.range.checked&&t.range.text===this.range.text}toDOM(e){let t=document.createElement(`label`);t.className=`cm-rich-task-widget`;let n=document.createElement(`input`);n.type=`checkbox`;let r=document.createElement(`span`);return t.append(n,r),this.syncDOM(t,e),t}updateDOM(e,t){return e.classList.contains(`cm-rich-task-widget`)?(this.syncDOM(e,t),!0):!1}destroy(e){let t=e.querySelector(`input[type="checkbox"]`);t&&(t.onchange=null)}ignoreEvent(e){return e.type===`mousedown`||e.type===`click`||e.type===`change`||e.type===`input`||e.type===`keydown`}syncDOM(e,t){let n=e.querySelector(`input[type="checkbox"]`),r=e.querySelector(`span`);n&&r&&(n.checked=this.range.checked,n.setAttribute(`aria-label`,this.range.text||(this.range.checked?`Checked task`:`Unchecked task`)),n.setAttribute(`aria-checked`,this.range.checked?`true`:`false`),n.onchange=()=>{t.dispatch({changes:{from:this.range.markerFrom,to:this.range.markerFrom+3,insert:n.checked?`[x]`:`[ ]`},userEvent:`input.task-toggle`})},r.textContent=this.range.text||`Task`)}};function Is(e){return`rich-${e.kind}-${e.from}-${e.to}-${e.markdown.length}`}function Ls(e){let t=[],n=e.selection.main,r=!1;for(let i=1;i<=e.doc.lines&&!(t.length>=As);i+=1){let a=e.doc.line(i);if(/^```/.test(a.text.trim())){r=!r;continue}if(r||n.from<=a.to&&n.to>=a.from)continue;let o=a.text.match(Ps);o&&t.push({from:a.from,to:a.to,markerFrom:a.from+o[1].length,checked:o[2].toLowerCase()===`x`,text:o[4].trim()})}return t}function Rs(e,t){if(!t.enabled||!t.active)return J.none;let n=e.selection.main,r=Ds(e.doc.toString(),{selectionFrom:n.from,selectionTo:n.to,maxWidgets:ks,maxSnippetBytes:js,maxMermaidWidgets:Ms,largeNoteDisableThreshold:Ns}),i=[];for(let t of Ls(e))i.push({from:t.from,to:t.to,decoration:J.replace({widget:new Fs(t)})});for(let e of r)i.push({from:e.from,to:e.to,decoration:J.replace({block:e.block,widget:new Os({id:Is(e),kind:e.kind,markdown:e.markdown,block:e.block,registerWidget:t.registerWidget,unregisterWidget:t.unregisterWidget,requestMeasure:t.requestMeasure})})});i.sort((e,t)=>{let n=e.from-t.from;if(n!==0)return n;let r=e.decoration.startSide-t.decoration.startSide;return r===0?e.to-t.to:r});let a=new ke;for(let e of i)a.add(e.from,e.to,e.decoration);return a.finish()}function zs(e){return Le.define({create(t){return Rs(t,e)},update(t,n){return n.docChanged||n.selection?Rs(n.state,e):t.map(n.changes)},provide(e){return[U.decorations.from(e),U.atomicRanges.of(t=>t.state.field(e,!1)??J.none)]}})}function Bs(e){let t=document.createElement(`template`);return t.innerHTML=e,t.content.textContent||``}function Vs(e){return U.domEventHandlers({paste(t,n){if(e&&ft(t,n,e))return!0;if(t.clipboardData?.getData(`text/plain`))return!1;let r=t.clipboardData?.getData(`text/html`);return r?(t.preventDefault(),n.dispatch(n.state.replaceSelection(Bs(r))),!0):!1},drop(t,n){return!!(e&&dt(t,n,e))}})}function Hs(e){return(t,n,r,i)=>{let a=t.state.sliceDoc(i,i+2)===`]]`?i+2:i;t.dispatch({...rt(t.state,ht(e),r,a),annotations:at.of(n)})}}function Us(e){function t(t){let n=t.state.doc.lineAt(t.pos),r=t.state.sliceDoc(n.from,n.to),i=pt(r,t.pos-n.from);if(!i)return null;let a=n.from+i.to-(i.hasClosingSuffix?2:0),o=mt(e,i.query).map(e=>({label:e.title||e.path,detail:e.path,info:e.matchKind===`alias`?`Alias: ${e.aliases.join(`, `)}`:e.matchKind,type:`text`,apply:Hs(e),boost:e.score}));return o.length===0?null:{from:n.from+i.from,to:a,options:o,validFor:/^[^\]\n]*$/}}return ot({activateOnTyping:!0,override:[t]})}var Ws=null;async function Gs(){if(Ws)return Ws;let{vim:e}=await t(async()=>{let{vim:e}=await import(`./dist-Bp7q5-Qc.js`);return{vim:e}},[]);return Ws=e(),Ws}var Ks=(0,Y.lazy)(async()=>({default:(await t(()=>import(`./MilkdownWysiwygEditor-D6JaLDE4.js`),__vite__mapDeps([0]))).MilkdownWysiwygEditor}));function qs(e){let[t,n]=(0,Y.useState)(()=>new Map),[r,i]=(0,Y.useState)(null),a=e.authoringMode===`wysiwyg`;(0,Y.useEffect)(()=>{if(!e.vimMode){i(null);return}let t=!1;return Gs().then(e=>{t||i(e)}),()=>{t=!0}},[e.vimMode]);let o=(0,Y.useCallback)(e=>{n(t=>{let n=new Map(t);return n.set(e.id,e),n})},[]),s=(0,Y.useCallback)(e=>{n(t=>{if(!t.has(e))return t;let n=new Map(t);return n.delete(e),n})},[]),c=(0,Y.useCallback)(()=>{window.dispatchEvent(new Event(`resize`))},[]),l=(0,Y.useMemo)(()=>{let t=[z.highest(Me.of(xs)),_s,ys,lt({codeLanguages:gs}),Us(e.notes),Vs({notePath:e.notePath,onError:e=>console.warn(`[notes-image-paste]`,e)}),zs({enabled:e.authoringMode===`rich`||e.authoringMode===`wysiwyg`,active:e.active,registerWidget:o,unregisterWidget:s,requestMeasure:c})];return e.wordWrap&&t.push(U.lineWrapping),r&&t.unshift(r),t},[e.active,e.authoringMode,e.notePath,e.notes,e.wordWrap,r,o,c,s]);return a?(0,X.jsx)(`div`,{className:`notes-editor notes-wysiwyg-editor`,children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(`div`,{className:`notes-wysiwyg-loading`,children:`Loading WYSIWYG editor...`}),children:(0,X.jsx)(Ks,{active:e.active,content:e.content,notePath:e.notePath,outgoing:e.outgoing,notes:e.notes,activeTag:e.activeTag,onChange:e.onChange,onTagSelect:e.onTagSelect,onWikiLinkNavigate:e.onWikiLinkNavigate})})}):(0,X.jsxs)(`div`,{className:`notes-editor`,children:[(0,X.jsx)(Cs,{widgets:[...t.values()]}),(0,X.jsx)(ms,{value:e.content,extensions:l,onChange:e.onChange,height:`100%`,basicSetup:{lineNumbers:!0,foldGutter:!0,highlightActiveLine:!0}})]})}function Js(e){return(0,X.jsx)(`article`,{className:`notes-preview`,children:(0,X.jsx)(ut,{markdown:e.markdown,outgoing:e.outgoing,notes:e.notes,onWikiLinkNavigate:e.onWikiLinkNavigate})})}function Ys(e){let t=e.split(`/`).pop()??e;return t.endsWith(`.md`)?t.slice(0,-3):t}function Xs(e){let t=[],n=/\[\[([^\]]+)\]\]/g,r=0,i,a=0;for(;(i=n.exec(e))!==null;)i.index>r&&t.push(e.slice(r,i.index)),t.push((0,X.jsx)(`mark`,{className:`backlink-highlight`,children:`[[`+i[1]+`]]`},a++)),r=n.lastIndex;return r<e.length&&t.push(e.slice(r)),t}function Zs(e){let[t,n]=(0,Y.useState)(!1),r=(0,Y.useCallback)(t=>{e.onNavigate(t)},[e.onNavigate]),i=e.backlinks.length;return(0,X.jsxs)(`div`,{className:`notes-backlinks-panel`,children:[(0,X.jsxs)(`button`,{className:`notes-backlinks-header`,onClick:()=>n(e=>!e),children:[(0,X.jsx)(`span`,{className:`notes-backlinks-chevron`,children:t?`▶`:`▼`}),(0,X.jsx)(`span`,{children:`Backlinks`}),(0,X.jsx)(`span`,{className:`notes-backlinks-count`,children:i})]}),!t&&(0,X.jsxs)(`div`,{className:`notes-backlinks-list`,children:[i===0&&(0,X.jsx)(`div`,{className:`notes-backlinks-empty`,children:`No backlinks found`}),e.backlinks.map((e,t)=>{let n=e.raw.length>120?e.raw.slice(0,120)+`...`:e.raw;return(0,X.jsxs)(`button`,{className:`notes-backlink-entry`,onClick:()=>r(e.sourcePath),children:[(0,X.jsx)(`span`,{className:`notes-backlink-title`,children:Ys(e.sourcePath)}),(0,X.jsxs)(`span`,{className:`notes-backlink-line`,children:[`L`,e.line]}),(0,X.jsx)(`span`,{className:`notes-backlink-context`,children:Xs(n)})]},`${e.sourcePath}:${e.line}:${t}`)})]})]})}function Qs(){return(0,X.jsxs)(`section`,{className:`notes-empty-state`,children:[(0,X.jsx)(`strong`,{children:`No notes yet`}),(0,X.jsx)(`span`,{children:`Create a markdown note from the file tree.`})]})}function $s(e){let t=e.note;if(!t)return null;let n=t.aliases||[],r=t.tags||[],i=t.created,a=t.frontmatterError;return!a&&n.length===0&&r.length===0&&!i?null:(0,X.jsxs)(`div`,{className:`notes-frontmatter-strip`,"aria-label":`Note frontmatter`,children:[a&&(0,X.jsxs)(`span`,{className:`notes-frontmatter-error`,role:`alert`,children:[`Frontmatter: `,a]}),n.length>0&&(0,X.jsxs)(`span`,{className:`notes-frontmatter-section`,children:[(0,X.jsx)(`span`,{className:`notes-frontmatter-label`,children:`Aliases`}),(0,X.jsx)(`span`,{className:`notes-frontmatter-value`,children:n.join(`, `)})]}),i&&(0,X.jsxs)(`span`,{className:`notes-frontmatter-section`,children:[(0,X.jsx)(`span`,{className:`notes-frontmatter-label`,children:`Created`}),(0,X.jsx)(`span`,{className:`notes-frontmatter-value`,children:i})]}),r.length>0&&(0,X.jsx)(`span`,{className:`notes-frontmatter-section notes-frontmatter-tags`,children:r.map(t=>{let n=t===e.activeTag;return(0,X.jsxs)(`button`,{type:`button`,className:n?`notes-tag-chip is-active`:`notes-tag-chip`,"aria-pressed":n,title:n?`Clear filter: #${t}`:`Filter notes by #${t}`,onClick:()=>e.onTagClick(n?null:t),children:[`#`,t]},t)})})]})}var ec=50;function tc(e){return e.trim().toLowerCase()}function nc(e,t){let n=tc(e),r=tc(t);if(!r)return 1;if(n.startsWith(r))return 1e3-n.length;let i=n.indexOf(r);if(i>=0)return 700-i;let a=-1,o=0,s=0;for(let e of r){let t=n.indexOf(e,a+1);if(t<0)return null;o=t===a+1?o+1:0,s+=4+o*3-Math.min(t,40)*.1,a=t}return s}function rc(e,t){let n=[{value:e.title,reason:`title`,boost:120},{value:e.path,reason:`path`,boost:40},...e.aliases.map(e=>({value:e,reason:`alias`,boost:80}))],r=null;for(let i of n){let n=nc(i.value,t);if(n==null)continue;let a=n+i.boost;(!r||a>r.score)&&(r={note:e,score:a,reason:i.reason})}return r}function ic(e,t,n=ec){let r=t.trim();return e.map(e=>rc(e,r)).filter(e=>!!e).sort((e,t)=>t.score===e.score?e.note.path.localeCompare(t.note.path):t.score-e.score).slice(0,n)}function ac(e){let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)(0),a=(0,Y.useRef)(null),o=(0,Y.useRef)(null),s=(0,Y.useMemo)(()=>ic(e.notes,t),[e.notes,t]),c=s[r]?`notes-quick-switcher-option-${r}`:void 0;(0,Y.useEffect)(()=>{e.open&&(n(``),i(0),requestAnimationFrame(()=>a.current?.focus()))},[e.open]),(0,Y.useEffect)(()=>{r>=s.length&&i(Math.max(0,s.length-1))},[r,s.length]),(0,Y.useEffect)(()=>{(c?document.getElementById(c):null)?.scrollIntoView({block:`nearest`})},[c]);function l(){let t=s[r];t&&e.onSelect(t.note.path)}function u(t){t.key===`ArrowDown`?(t.preventDefault(),i(e=>Math.min(s.length-1,e+1))):t.key===`ArrowUp`?(t.preventDefault(),i(e=>Math.max(0,e-1))):t.key===`Enter`?(t.preventDefault(),l()):t.key===`Escape`&&(t.preventDefault(),e.onClose())}return e.open?(0,X.jsx)(`div`,{className:`notes-quick-switcher-backdrop`,role:`presentation`,onClick:e.onClose,children:(0,X.jsxs)(`section`,{className:`notes-quick-switcher`,role:`dialog`,"aria-modal":`true`,"aria-label":`Quick switch note`,onClick:e=>e.stopPropagation(),children:[(0,X.jsx)(`input`,{ref:a,className:`notes-quick-switcher-input`,type:`search`,placeholder:`Go to note`,value:t,onChange:e=>{n(e.currentTarget.value),i(0)},onKeyDown:u,"aria-label":`Quick switch note`,"aria-controls":`notes-quick-switcher-results`,"aria-activedescendant":c}),(0,X.jsxs)(`div`,{id:`notes-quick-switcher-results`,className:`notes-quick-switcher-list`,role:`listbox`,"aria-label":`Matching notes`,ref:o,children:[s.map((t,n)=>{let a=n===r,o=t.note.path===e.selectedPath;return(0,X.jsxs)(`button`,{id:`notes-quick-switcher-option-${n}`,type:`button`,role:`option`,"aria-selected":a,className:`notes-quick-switcher-item${a?` is-active`:``}${o?` is-current`:``}`,onMouseEnter:()=>i(n),onClick:()=>e.onSelect(t.note.path),children:[(0,X.jsx)(`span`,{className:`notes-quick-switcher-title`,children:t.note.title||t.note.path}),(0,X.jsx)(`span`,{className:`notes-quick-switcher-path`,children:t.note.path}),(0,X.jsx)(`span`,{className:`notes-quick-switcher-alias`,children:o?`Current note`:t.reason===`alias`?`Alias match`:t.reason===`path`?`Path match`:`Title match`})]},t.note.path)}),s.length===0&&(0,X.jsx)(`p`,{className:`notes-quick-switcher-empty`,children:`No matching notes.`})]}),(0,X.jsxs)(`footer`,{className:`notes-quick-switcher-footer`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Up/Down`}),` move`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Enter`}),` open`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Esc`}),` close`]})]})]})}):null}function oc(e){return e instanceof ne&&e.status===409&&e.code===`note_revision_conflict`}function sc(e){return e?e.split(`/`).filter(Boolean).at(-1)||e:`No note selected`}function cc(e,t,n){return!!e&&t&&!n}var lc=[`raw`,`split`,`preview`,`wysiwyg`,`graph`];function uc(e){return e===`raw`?`Raw`:e===`split`?`Split`:e===`preview`?`Preview`:e===`graph`?`Graph`:`WYSIWYG`}function dc(e,t){return e===`settings`?null:e===`graph`?`graph`:e===`split`?`split`:e===`preview`?`preview`:t===`wysiwyg`?`wysiwyg`:`raw`}function fc(e){function t(t){if(t===`graph`){e.onViewModeChange(`graph`);return}if(t===`split`){e.onViewModeChange(`split`),e.onAuthoringModeChange(`plain`);return}if(t===`preview`){e.onViewModeChange(`preview`);return}e.onViewModeChange(`raw`),e.onAuthoringModeChange(t===`wysiwyg`?`wysiwyg`:`plain`)}let n=dc(e.viewMode,e.authoringMode);return(0,X.jsxs)(`div`,{className:`notes-toolbar`,children:[(0,X.jsxs)(`div`,{className:`notes-toolbar-title`,children:[(0,X.jsx)(`strong`,{children:sc(e.selectedPath)}),(0,X.jsx)(`span`,{children:e.conflict?`Conflict`:e.dirty?`Unsaved`:`Saved`})]}),(0,X.jsxs)(`div`,{className:`notes-toolbar-actions`,children:[(0,X.jsx)(`div`,{className:`notes-view-tabs`,role:`tablist`,"aria-label":`Notes view`,children:lc.map(r=>(0,X.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":n===r,className:n===r?`is-active`:``,disabled:r!==`graph`&&!e.selectedPath,onClick:()=>t(r),children:uc(r)},r))}),(0,X.jsx)(`button`,{type:`button`,className:e.viewMode===`settings`?`is-active`:``,onClick:()=>e.onViewModeChange(`settings`),children:`Settings`}),(0,X.jsx)(`button`,{type:`button`,onClick:e.onReload,disabled:!e.selectedPath||e.loading,children:`Refresh`}),(0,X.jsx)(`button`,{type:`button`,className:`notes-save-button`,onClick:e.onSave,disabled:!cc(e.selectedPath,e.dirty,e.saving),children:e.saving?`Saving`:`Save`})]})]})}function pc(e){return(e.metaKey||e.ctrlKey)&&!e.altKey}function mc(e){return typeof HTMLElement>`u`||!(e instanceof HTMLElement)?!1:!!e.closest(`[data-notes-palette]`)}function hc(e){return pc(e)&&!e.shiftKey&&e.key.toLowerCase()===`p`&&!mc(e.target)}function gc(e){return pc(e)&&e.shiftKey&&e.key.toLowerCase()===`p`}async function _c(){await Promise.resolve(),await new Promise(e=>setTimeout(e,0))}function vc(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),h=(0,Y.useRef)(``),g=(0,Y.useRef)(!1),_=(0,Y.useRef)(!1),v=(0,Y.useCallback)(async e=>{s(!0),f(null),m(null);try{let n=await b(e);t(n),h.current=n.content,g.current=!1,r(n.content),a(!1)}catch(e){f(e.message)}finally{s(!1)}},[]);function y(e){h.current=e,g.current=!0,r(e),a(!0)}return{file:e,content:n,dirty:i,loading:o,saving:c,error:u,conflict:p,setContent:y,load:v,save:(0,Y.useCallback)(async()=>{if(await _c(),!e||!g.current||_.current)return;let n=h.current;_.current=!0,l(!0),f(null),m(null);try{let i=await d({path:e.path,content:n,baseRevision:e.revision});t(i),h.current===n&&(h.current=i.content,g.current=!1,r(i.content),a(!1))}catch(r){if(oc(r)){let i=e.revision;try{let n=await b(e.path);i=n.revision,t(n)}catch{i=e.revision}m({localContent:n,remoteRevision:i,message:r.message})}else f(r.message)}finally{_.current=!1,l(!1)}},[e]),reloadFromDisk:(0,Y.useCallback)(async()=>{e&&await v(e.path)},[e,v]),overwrite:(0,Y.useCallback)(async()=>{if(await _c(),!e||_.current)return;let n=h.current;_.current=!0,l(!0),f(null);try{let i=await d({path:e.path,content:n});t(i),h.current===n&&(h.current=i.content,g.current=!1,r(i.content),a(!1)),m(null)}catch(e){f(e.message)}finally{_.current=!1,l(!1)}},[e]),clearConflict:()=>m(null)}}var yc=(0,Y.lazy)(async()=>({default:(await t(()=>import(`./NotesGraphWorkspace-CgdC-fM6.js`),[])).NotesGraphWorkspace})),bc=[`raw`,`preview`,`wysiwyg`],xc=/[/\\]/g;function Sc(e){let t=e.split(`/`).pop()??e;return t.endsWith(`.md`)?t.slice(0,-3):t}function Cc(e,t){return e===`preview`?`preview`:t===`wysiwyg`?`wysiwyg`:`raw`}function wc(e){let t=vc(),n=(0,Y.useRef)(!1),[r,i]=(0,Y.useState)(!1);(0,Y.useEffect)(()=>{e.selectedPath&&t.load(e.selectedPath)},[e.selectedPath]),(0,Y.useEffect)(()=>{e.onDirtyPathChange(t.dirty?e.selectedPath:null)},[t.dirty,e.selectedPath]),(0,Y.useEffect)(()=>{if(!e.active)return;function n(e){(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`s`&&(e.preventDefault(),t.save())}return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[t.save,e.active]),(0,Y.useEffect)(()=>{if(!e.active)return;function t(t){if(!(t.metaKey||t.ctrlKey)||t.key.toLowerCase()!==`e`)return;t.preventDefault();let n=Cc(e.viewMode,e.authoringMode),r=bc[(bc.indexOf(n)+1)%bc.length];if(r===`preview`){e.onViewModeChange(`preview`);return}e.onViewModeChange(`raw`),e.onAuthoringModeChange(r===`wysiwyg`?`wysiwyg`:`plain`)}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.active,e.viewMode,e.authoringMode,e.onViewModeChange,e.onAuthoringModeChange]),(0,Y.useEffect)(()=>{if(!e.active)return;function t(t){(t.metaKey||t.ctrlKey)&&t.shiftKey&&t.key.toLowerCase()===`f`&&(t.preventDefault(),e.onOpenSidebarSearch())}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.active,e.onOpenSidebarSearch]),(0,Y.useEffect)(()=>{if(!e.active)return;function t(e){hc(e)&&(e.preventDefault(),i(e=>!e))}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.active]);let a=e.selectedPath?t.saving?`Save in progress`:t.dirty?void 0:`No unsaved changes`:`No note selected`;Va((0,Y.useMemo)(()=>[{id:`workspace:save`,section:`File`,label:`Save note`,shortcut:`Cmd+S`,disabled:!cc(e.selectedPath,t.dirty,t.saving),disabledReason:a,keywords:[`write`,`persist`],run:()=>void t.save()},{id:`workspace:reload`,section:`File`,label:`Reload note from disk`,keywords:[`refresh`,`discard`],disabled:!e.selectedPath,disabledReason:`No note selected`,run:()=>void t.reloadFromDisk()},{id:`workspace:view-raw`,section:`View`,label:`Switch to raw editor`,run:()=>{e.onViewModeChange(`raw`),e.onAuthoringModeChange(`plain`)}},{id:`workspace:view-split`,section:`View`,label:`Switch to split view`,run:()=>{e.onViewModeChange(`split`),e.onAuthoringModeChange(`plain`)}},{id:`workspace:view-preview`,section:`View`,label:`Switch to preview`,shortcut:`Cmd+E`,run:()=>e.onViewModeChange(`preview`)},{id:`workspace:view-wysiwyg`,section:`View`,label:`Switch to WYSIWYG editor`,run:()=>{e.onViewModeChange(`raw`),e.onAuthoringModeChange(`wysiwyg`)}},{id:`workspace:view-graph`,section:`View`,label:`Open graph view`,run:()=>e.onViewModeChange(`graph`)},{id:`workspace:open-settings`,section:`View`,label:`Open Notes settings`,run:()=>e.onViewModeChange(`settings`)},{id:`workspace:toggle-word-wrap`,section:`Editor`,label:e.wordWrap?`Disable word wrap`:`Enable word wrap`,run:()=>e.onWordWrapChange(!e.wordWrap)},{id:`workspace:toggle-vim-mode`,section:`Editor`,label:e.vimMode?`Disable Vim mode`:`Enable Vim mode`,keywords:[`vim`,`keybindings`,`editor`],run:()=>e.onVimModeChange(!e.vimMode)},{id:`workspace:open-search`,section:`Navigate`,label:`Search notes`,shortcut:`Cmd+Shift+F`,run:e.onOpenSidebarSearch},{id:`workspace:quick-switch-note`,section:`Navigate`,label:`Quick switch note`,shortcut:`Cmd+P`,run:()=>i(!0)}],[t.dirty,t.reloadFromDisk,t.save,t.saving,e.onAuthoringModeChange,e.onOpenSidebarSearch,e.onViewModeChange,e.onVimModeChange,e.onWordWrapChange,e.selectedPath,e.vimMode,e.wordWrap,a]),e.active);async function o(t){if(n.current||!e.selectedPath)return;let r=t.currentTarget.value.trim().replace(xc,``),i=Sc(e.selectedPath);if(!r||r===i){t.currentTarget.value=i;return}let a=e.selectedPath.split(`/`);a[a.length-1]=r.endsWith(`.md`)?r:`${r}.md`;let o=a.join(`/`);if(o===e.selectedPath){t.currentTarget.value=i;return}n.current=!0;try{await oe(e.selectedPath,o),e.onSelectedPathChange(o),Z({topics:[`notes`],reason:`note:title-renamed`,source:`ui`})}catch(e){console.warn(`[notes-rename]`,e),t.currentTarget.value=i}finally{n.current=!1}}let s=e.viewMode===`raw`||e.viewMode===`split`,c=e.viewMode===`preview`||e.viewMode===`split`,l=e.selectedPath&&e.vaultIndex?.outgoingLinks?.[e.selectedPath]||[],u=e.selectedPath&&e.vaultIndex?.backlinks?.[e.selectedPath]||[],d=e.vaultIndex?.notes||[],f=e.authoringMode===`wysiwyg`&&s;return(0,X.jsxs)(`section`,{className:`notes-workspace`,"aria-label":`Notes workspace`,children:[(0,X.jsx)(ao,{}),(0,X.jsxs)(`main`,{className:`notes-main notes-mode-${e.viewMode}`,children:[(0,X.jsx)(fc,{selectedPath:e.selectedPath,viewMode:e.viewMode,authoringMode:e.authoringMode,dirty:t.dirty,saving:t.saving,loading:t.loading,conflict:!!t.conflict,onViewModeChange:e.onViewModeChange,onAuthoringModeChange:e.onAuthoringModeChange,onSave:()=>void t.save(),onReload:()=>void t.reloadFromDisk()}),(0,X.jsxs)(`div`,{className:`notes-content`,children:[t.error&&(0,X.jsx)(`section`,{className:`state error-state`,children:t.error}),t.conflict&&(0,X.jsxs)(`section`,{className:`notes-conflict`,children:[(0,X.jsx)(`span`,{children:t.conflict.message}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void t.reloadFromDisk(),children:`Reload`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void t.overwrite(),children:`Overwrite`}),(0,X.jsx)(`button`,{type:`button`,onClick:t.clearConflict,children:`Keep local`})]}),e.viewMode===`settings`&&(0,X.jsxs)(`section`,{className:`notes-settings`,children:[(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:e.wordWrap,onChange:t=>e.onWordWrapChange(t.currentTarget.checked)}),`Word wrap`]}),(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`input`,{type:`checkbox`,checked:e.vimMode,onChange:t=>e.onVimModeChange(t.currentTarget.checked)}),`Vim mode`]}),(0,X.jsxs)(`label`,{children:[`Tree width`,(0,X.jsx)(`input`,{type:`range`,min:`220`,max:`420`,value:e.treeWidth,onChange:t=>e.onTreeWidthChange(Number(t.currentTarget.value))})]}),(0,X.jsx)(io,{})]}),e.viewMode===`graph`&&(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(`div`,{className:`notes-graph-loading`,children:`Loading graph...`}),children:(0,X.jsx)(yc,{vaultIndex:e.vaultIndex,selectedPath:e.selectedPath,settings:e.notesGraphSettings,onSettingsChange:e.onNotesGraphSettingsChange,onNavigate:t=>{e.onSelectedPathChange(t),e.onViewModeChange(`raw`)}})}),!e.selectedPath&&e.viewMode!==`settings`&&e.viewMode!==`graph`&&(0,X.jsx)(Qs,{}),e.selectedPath&&e.viewMode!==`settings`&&e.viewMode!==`graph`&&(0,X.jsxs)(`div`,{className:`notes-document-grid`,children:[(0,X.jsx)(`input`,{className:`notes-inline-title`,defaultValue:Sc(e.selectedPath),onBlur:o,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},spellCheck:!1,"aria-label":`Note title`},e.selectedPath),!f&&(0,X.jsx)($s,{note:e.selectedNote,activeTag:e.tagFilter,onTagClick:e.onTagSelect}),s&&(0,X.jsx)(`div`,{className:`notes-editor-pane`,children:(0,X.jsx)(qs,{active:e.active&&s,authoringMode:e.authoringMode,content:t.content,notePath:e.selectedPath,outgoing:l,notes:d,activeTag:e.tagFilter,wordWrap:e.wordWrap,vimMode:e.vimMode,onChange:t.setContent,onTagSelect:e.onTagSelect,onWikiLinkNavigate:e.onWikiLinkNavigate},e.selectedPath)}),c&&(0,X.jsx)(Js,{markdown:t.content,outgoing:l,notes:d,onWikiLinkNavigate:e.onWikiLinkNavigate})]})]}),e.viewMode!==`graph`&&e.viewMode!==`settings`&&e.selectedPath&&(0,X.jsx)(Zs,{backlinks:u,onNavigate:e.onWikiLinkNavigate})]}),(0,X.jsx)(ac,{open:r,notes:e.vaultIndex?.notes||[],selectedPath:e.selectedPath,onClose:()=>i(!1),onSelect:t=>{e.onSelectedPathChange(t),i(!1)}})]})}var Tc=`application/x-jaw-running-chip`;function Ec(e,t,n){let r=[],i=new Set;for(let a of e){if(a.hidden)continue;let e=a.port;if(i.has(e))continue;i.add(e);let o=n.has(e),s=a.status===`online`,c=a.status===`error`;(o||s||c)&&r.push({port:e,label:a.label||a.instanceId||`Port ${e}`,activity:t[e]||null,state:o?`busy`:c?`error`:`online`})}return r}function Dc(e){return JSON.stringify({port:e.port,label:e.label,activity:e.activity,state:e.state})}function Oc(e){let t=e.dataTransfer.getData(Tc);if(!t)return null;try{let e=JSON.parse(t);return typeof e.port==`number`?{port:e.port,label:typeof e.label==`string`?e.label:`Port ${e.port}`,activity:typeof e.activity==`string`?e.activity:null,state:e.state===`busy`||e.state===`error`?e.state:`online`}:null}catch{return null}}var kc=[{id:`backlog`,label:`Backlog`,policy:`Options not yet committed`},{id:`ready`,label:`Ready`,policy:`Pullable, clear enough to start`},{id:`active`,label:`In Progress`,policy:`Current WIP, keep starts limited`},{id:`review`,label:`Review`,policy:`Check output before delivery`},{id:`done`,label:`Done`,policy:`Delivered or no longer active`}];function Ac(e){let t=(0,Y.useMemo)(()=>Ec(e.instances,e.titlesByPort,e.busyPorts),[e.instances,e.titlesByPort,e.busyPorts]);return(0,X.jsxs)(`nav`,{className:`dashboard-board-sidebar`,"aria-label":`Board lanes`,children:[(0,X.jsxs)(`header`,{className:`dashboard-board-sidebar-header`,children:[(0,X.jsx)(`span`,{className:`dashboard-board-sidebar-title`,children:`Board`}),(0,X.jsxs)(`span`,{className:`dashboard-board-sidebar-count`,children:[t.length,` running`]})]}),(0,X.jsxs)(`section`,{className:`dashboard-board-sidebar-running`,"aria-label":`Running instances`,children:[(0,X.jsx)(`div`,{className:`dashboard-board-sidebar-section-title`,children:`Running`}),t.length===0?(0,X.jsx)(`p`,{className:`dashboard-board-sidebar-empty`,children:`No running instances`}):(0,X.jsx)(`div`,{className:`dashboard-board-sidebar-running-list`,children:t.map(e=>(0,X.jsxs)(`div`,{className:`dashboard-board-running-chip`,"data-state":e.state,draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`copy`,t.dataTransfer.setData(Tc,Dc(e))},"aria-label":e.activity?`${e.label} — ${e.activity}`:e.label,children:[(0,X.jsxs)(`span`,{className:`dashboard-board-running-chip-port`,children:[`:`,e.port]}),(0,X.jsx)(`span`,{className:`dashboard-board-running-chip-label`,children:e.label}),e.activity?(0,X.jsx)(`span`,{className:`dashboard-board-running-chip-activity`,children:e.activity}):null,(0,X.jsx)(`span`,{className:`dashboard-board-running-chip-state`,"data-state":e.state,children:e.state})]},e.port))})]}),(0,X.jsx)(`div`,{className:`dashboard-board-sidebar-section-title`,children:`Lanes`}),(0,X.jsxs)(`ul`,{className:`dashboard-board-sidebar-list`,children:[(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`dashboard-board-sidebar-item${e.view.kind===`overall`?` is-active`:``}`,onClick:()=>e.onViewChange({kind:`overall`}),"aria-pressed":e.view.kind===`overall`,children:[(0,X.jsx)(`span`,{children:`Overall`}),(0,X.jsx)(`small`,{children:`Five-column workflow`})]})}),kc.map(t=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`dashboard-board-sidebar-item${e.view.kind===`lane`&&e.view.lane===t.id?` is-active`:``}`,onClick:()=>e.onViewChange({kind:`lane`,lane:t.id}),"aria-pressed":e.view.kind===`lane`&&e.view.lane===t.id,children:[(0,X.jsx)(`span`,{children:t.label}),(0,X.jsx)(`small`,{children:t.policy})]})},t.id))]})]})}function jc(e,t){if(e.port===null)return`no instance`;let n=t.get(e.port);return n?`:${n.port} ${n.label}`:`:${e.port}`}function Mc(e){let t=kc.find(t=>t.id===e.lane),n=t?.label??`Lane`,r=t?.policy??``,i=e.cards.filter(e=>e.port!==null).length,a=e.cards.length-i;return(0,X.jsxs)(`div`,{className:`dashboard-board-lane-detail-shell`,"data-lane":e.lane,children:[(0,X.jsxs)(`aside`,{className:`dashboard-board-lane-detail-sidebar`,"aria-label":`${n} filters`,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`span`,{children:n}),(0,X.jsx)(`small`,{children:r})]}),(0,X.jsxs)(`div`,{className:`dashboard-board-lane-detail-counts`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:e.cards.length}),` all`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:i}),` with instance`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`strong`,{children:a}),` no instance`]})]}),(0,X.jsx)(`button`,{type:`button`,onClick:e.onBackToOverall,children:`Overall`})]}),(0,X.jsxs)(`section`,{className:`dashboard-board-lane-detail-content`,"aria-label":`${n} cards`,children:[(0,X.jsxs)(`header`,{className:`dashboard-board-lane-detail-header`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`h2`,{children:[`Board / `,n]}),(0,X.jsx)(`p`,{children:e.lane===`done`?`Done archive, shown as compact two-line rows.`:`Lane detail, shown as compact rows for scan and reuse.`})]}),(0,X.jsx)(`button`,{type:`button`,onClick:e.onBackToOverall,children:`Close`})]}),e.cards.length===0?(0,X.jsx)(`p`,{className:`dashboard-board-lane-detail-empty`,children:`No items in this lane`}):(0,X.jsx)(`ul`,{className:`dashboard-board-compact-list`,children:e.cards.map(t=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`dashboard-board-compact-row`,onClick:()=>e.onOpenCard(t.id),children:[(0,X.jsx)(`span`,{className:`dashboard-board-compact-row-title`,children:t.summary||t.title}),(0,X.jsx)(`span`,{className:`dashboard-board-compact-row-instance`,children:jc(t,e.runningChipByPort)})]})},t.id))})]})]})}var Nc=`/api/dashboard/board`;function Pc(e){return{...e,summary:e.summary??null,detail:e.detail??null}}async function Fc(e){if(!e.ok){let t=await e.text().catch(()=>``);throw Error(`${e.status} ${t||e.statusText}`)}return await e.json()}async function Ic(){let e=await Fc(await fetch(`${Nc}/tasks`,{credentials:`same-origin`,cache:`no-store`}));return Array.isArray(e.tasks)?e.tasks.map(Pc):[]}async function Lc(e){return Pc((await Fc(await fetch(`${Nc}/tasks`,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,body:JSON.stringify(e)}))).task)}async function Rc(e,t){return Pc((await Fc(await fetch(`${Nc}/tasks/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"content-type":`application/json`},credentials:`same-origin`,body:JSON.stringify(t)}))).task)}async function zc(e){await Fc(await fetch(`${Nc}/tasks/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`same-origin`}))}function Bc(e){let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``);if((0,Y.useEffect)(()=>{n(e.card?.title??``),i(e.card?.summary??``),o(e.card?.detail??``)},[e.card]),!e.card)return null;function s(n){if(n.preventDefault(),!e.card)return;let i=t.trim();i&&e.onSave(e.card.id,{title:i,summary:r,detail:a})}return(0,X.jsx)(`div`,{className:`dashboard-board-dialog-backdrop`,role:`presentation`,onMouseDown:t=>{t.target===t.currentTarget&&e.onClose()},children:(0,X.jsxs)(`form`,{className:`dashboard-board-dialog`,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`dashboard-board-dialog-title`,onSubmit:s,onKeyDown:t=>{t.key===`Escape`&&e.onClose()},children:[(0,X.jsxs)(`header`,{className:`dashboard-board-dialog-header`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`dashboard-board-dialog-kicker`,children:`Kanban block`}),(0,X.jsx)(`h3`,{id:`dashboard-board-dialog-title`,children:`Edit card`})]}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-board-dialog-icon-button`,onClick:e.onClose,"aria-label":`Close card editor`,children:`×`})]}),(0,X.jsxs)(`label`,{className:`dashboard-board-dialog-field`,children:[(0,X.jsx)(`span`,{children:`Title`}),(0,X.jsx)(`input`,{autoFocus:!0,type:`text`,value:t,onChange:e=>n(e.currentTarget.value),maxLength:500,required:!0})]}),(0,X.jsxs)(`label`,{className:`dashboard-board-dialog-field`,children:[(0,X.jsx)(`span`,{children:`One-line note`}),(0,X.jsx)(`input`,{type:`text`,value:r,onChange:e=>i(e.currentTarget.value),maxLength:500,placeholder:`Short visible memo for the card`})]}),(0,X.jsxs)(`label`,{className:`dashboard-board-dialog-field`,children:[(0,X.jsx)(`span`,{children:`Details`}),(0,X.jsx)(`textarea`,{value:a,onChange:e=>o(e.currentTarget.value),maxLength:2e4,rows:10,placeholder:`Write Markdown here. It is stored as raw text for now.`})]}),(0,X.jsxs)(`footer`,{className:`dashboard-board-dialog-footer`,children:[(0,X.jsx)(`span`,{className:`dashboard-board-dialog-storage`,children:`Markdown`}),(0,X.jsxs)(`div`,{className:`dashboard-board-dialog-actions`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:e.onClose,children:`Cancel`}),(0,X.jsx)(`button`,{type:`submit`,disabled:e.busy||!t.trim(),children:`Save`})]})]})]})})}var Vc=`application/x-jaw-board-task`;function Hc(e){return e.kind===`open`?(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M7 4h-2.5a1.5 1.5 0 0 0-1.5 1.5v10a1.5 1.5 0 0 0 1.5 1.5h10a1.5 1.5 0 0 0 1.5-1.5V13`}),(0,X.jsx)(`path`,{d:`M10 3h7v7`}),(0,X.jsx)(`path`,{d:`M9 11 17 3`})]}):e.kind===`move`?(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M10 2v16`}),(0,X.jsx)(`path`,{d:`M6 6 10 2l4 4`}),(0,X.jsx)(`path`,{d:`m6 14 4 4 4-4`}),(0,X.jsx)(`path`,{d:`M2 10h16`}),(0,X.jsx)(`path`,{d:`m6 6-4 4 4 4`}),(0,X.jsx)(`path`,{d:`m14 6 4 4-4 4`})]}):(0,X.jsxs)(`svg`,{viewBox:`0 0 20 20`,width:`14`,height:`14`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,X.jsx)(`path`,{d:`M3 5h14`}),(0,X.jsx)(`path`,{d:`M8 5V3h4v2`}),(0,X.jsx)(`path`,{d:`M6 8v8`}),(0,X.jsx)(`path`,{d:`M10 8v8`}),(0,X.jsx)(`path`,{d:`M14 8v8`}),(0,X.jsx)(`path`,{d:`M5 5l1 13h8l1-13`})]})}function Uc(e){return JSON.stringify({id:e.id,lane:e.lane})}function Wc(e){let t=e.dataTransfer.getData(Vc);if(!t)return null;try{let e=JSON.parse(t);if(typeof e.id!=`string`)return null;let n=kc.find(t=>t.id===e.lane)?.id;return n?{id:e.id,lane:n}:null}catch{return null}}function Gc(e,t){return Array.from(e.dataTransfer.types).includes(t)}function Kc(e){return{id:e.id,title:e.title,summary:e.summary??null,detail:e.detail??null,lane:e.lane,port:e.port,source:e.source,persisted:!0}}function qc(e){return e==null?null:e.trim()||null}function Jc(e){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(!1),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(null),[h,g]=(0,Y.useState)(null),[_,v]=(0,Y.useState)(!1),y=(0,Y.useRef)(null),b=(0,Y.useCallback)(async()=>{try{n(await Ic())}catch{}},[]);(0,Y.useEffect)(()=>{e.active&&b()},[e.active,b]),(0,Y.useEffect)(()=>{if(!l)return;let e=e=>{y.current&&(y.current.contains(e.target)||u(null))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[l]);let x=(0,Y.useCallback)(async e=>{let t=a.trim();if(t&&!s){c(!0);try{await Lc({title:t,lane:e}),o(``),i(null),await b()}catch{}finally{c(!1)}}},[a,s,b]),S=(0,Y.useCallback)(async(e,t)=>{u(null);try{await Rc(e,{lane:t}),await b()}catch{}},[b]),C=(0,Y.useCallback)(async e=>{try{await zc(e),await b()}catch{}},[b]),w=(0,Y.useCallback)(async(e,t)=>{if(!_){v(!0);try{let r=await Rc(e,t);n(n=>n.map(n=>n.id===e?{...n,...r,summary:t.summary===void 0?r.summary??n.summary:qc(t.summary),detail:t.detail===void 0?r.detail??n.detail:qc(t.detail)}:n)),g(null)}catch{}finally{v(!1)}}},[_]),T=(0,Y.useCallback)(async(e,t)=>{try{await Rc(e,{port:t}),await b()}catch{}},[b]),E=(0,Y.useCallback)(async e=>{try{await Rc(e,{port:null}),await b()}catch{}},[b]),D=(0,Y.useCallback)((e,t)=>{t.preventDefault(),f(null);let n=Wc(t);n&&n.lane!==e&&S(n.id,e)},[S]),O=(0,Y.useCallback)((e,t)=>{if(!Gc(t,`application/x-jaw-running-chip`))return;t.preventDefault(),t.stopPropagation(),m(null);let n=Oc(t);n&&T(e,n.port)},[T]),k=(0,Y.useMemo)(()=>t.map(Kc),[t]),ee=(0,Y.useMemo)(()=>{let e=h?k.find(e=>e.id===h):null;return e?{id:e.id,title:e.title,summary:e.summary,detail:e.detail}:null},[k,h]),A=(0,Y.useMemo)(()=>Ec(e.instances,e.titlesByPort,e.busyPorts),[e.instances,e.titlesByPort,e.busyPorts]),j=(0,Y.useMemo)(()=>new Map(A.map(e=>[e.port,e])),[A]),te=e.view.kind===`lane`?e.view.lane:null;return(0,X.jsxs)(`section`,{className:`dashboard-board-workspace`,"aria-hidden":!e.active,children:[(0,X.jsxs)(`header`,{className:`dashboard-board-workspace-header`,children:[(0,X.jsxs)(`div`,{className:`dashboard-board-workspace-header-text`,children:[(0,X.jsx)(`h2`,{children:`Board`}),(0,X.jsx)(`p`,{className:`dashboard-board-workspace-subtitle`,children:`Create human-owned kanban blocks, then drag running instance blocks into a card to attach context without touching the instance itself.`})]}),(0,X.jsx)(`div`,{className:`dashboard-board-workspace-controls`,children:(0,X.jsx)(cr,{topic:`board`,label:`Open Board help`,onOpen:e.onOpenHelpTopic})})]}),te===null?(0,X.jsx)(`div`,{className:`dashboard-board-lanes`,children:kc.map(t=>{let n=k.filter(e=>e.lane===t.id),c=t.id===`done`?n.slice(0,4):n,h=t.id===`done`?Math.max(0,n.length-4):0,_=r===t.id,v=d===t.id;return(0,X.jsxs)(`div`,{className:`dashboard-board-lane${v?` is-drop-target`:``}`,"data-lane":t.id,onDragOver:e=>{Gc(e,Vc)&&(e.preventDefault(),e.dataTransfer.dropEffect=`move`,d!==t.id&&f(t.id))},onDragLeave:()=>{d===t.id&&f(null)},onDrop:e=>D(t.id,e),children:[(0,X.jsxs)(`header`,{className:`dashboard-board-lane-header`,children:[(0,X.jsx)(`span`,{className:`dashboard-board-lane-title`,children:t.label}),(0,X.jsx)(`span`,{className:`dashboard-board-lane-policy`,children:t.policy}),(0,X.jsx)(`span`,{className:`dashboard-board-lane-count`,children:n.length})]}),(0,X.jsxs)(`ul`,{className:`dashboard-board-lane-cards`,children:[n.length===0?(0,X.jsx)(`li`,{className:`dashboard-board-lane-empty`,children:`No items`}):c.map(e=>{let t=e.port===null?null:j.get(e.port)??null,n=p===e.id;return(0,X.jsxs)(`li`,{className:`dashboard-board-card${n?` is-instance-drop-target`:``}`,"data-lane":e.lane,"data-source":e.source,"data-persisted":e.persisted?`true`:`false`,draggable:!0,onDragStart:t=>{t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(Vc,Uc(e))},onDragOver:t=>{Gc(t,`application/x-jaw-running-chip`)&&(t.preventDefault(),t.stopPropagation(),t.dataTransfer.dropEffect=`copy`,p!==e.id&&m(e.id))},onDragLeave:()=>{p===e.id&&m(null)},onDrop:t=>O(e.id,t),children:[(0,X.jsx)(`span`,{className:`dashboard-board-card-title`,children:e.title}),e.summary?(0,X.jsx)(`span`,{className:`dashboard-board-card-summary`,title:e.summary,children:e.summary}):null,(0,X.jsx)(`div`,{className:`dashboard-board-card-instance-slot`,"data-empty":t?`false`:`true`,children:t?(0,X.jsxs)(`div`,{className:`dashboard-board-card-instance`,"data-state":t.state,draggable:!0,onDragStart:e=>{e.stopPropagation(),e.dataTransfer.effectAllowed=`copy`,e.dataTransfer.setData(Tc,Dc(t))},title:t.activity?`${t.label} — ${t.activity}`:t.label,children:[(0,X.jsxs)(`span`,{className:`dashboard-board-card-instance-port`,children:[`:`,t.port]}),(0,X.jsx)(`span`,{className:`dashboard-board-card-instance-label`,children:t.label}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-board-card-instance-detach`,onClick:()=>void E(e.id),"aria-label":`Detach :${t.port} from card`,title:`Detach instance`,children:`-`}),t.activity?(0,X.jsx)(`span`,{className:`dashboard-board-card-instance-activity`,title:t.activity,children:t.activity}):null]}):(0,X.jsx)(`span`,{className:`dashboard-board-card-instance-empty`,children:`Drop a running instance here`})}),e.persisted?(0,X.jsxs)(`span`,{className:`dashboard-board-card-actions`,"data-open":l===e.id?`true`:`false`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dashboard-board-card-action`,onMouseDown:e=>e.stopPropagation(),onClick:()=>g(e.id),"aria-label":`Open card details`,title:`Open`,children:(0,X.jsx)(Hc,{kind:`open`})}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-board-card-action`,onMouseDown:e=>e.stopPropagation(),onClick:()=>u(t=>t===e.id?null:e.id),"aria-haspopup":`menu`,"aria-expanded":l===e.id,"aria-label":`Move card`,title:`Move`,children:(0,X.jsx)(Hc,{kind:`move`})}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-board-card-action`,"data-danger":`true`,onClick:()=>void C(e.id),"aria-label":`Delete card`,title:`Delete`,children:(0,X.jsx)(Hc,{kind:`delete`})}),l===e.id&&(0,X.jsx)(`div`,{ref:y,className:`dashboard-board-popover`,role:`menu`,children:kc.map(t=>(0,X.jsxs)(`button`,{type:`button`,className:`dashboard-board-popover-item${t.id===e.lane?` is-current`:``}`,role:`menuitem`,disabled:t.id===e.lane,onClick:()=>void S(e.id,t.id),children:[t.label,t.id===e.lane?` ✓`:``]},t.id))})]}):null]},e.id)}),h>0?(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`dashboard-board-done-more`,onClick:()=>e.onViewChange({kind:`lane`,lane:`done`}),children:[(0,X.jsxs)(`span`,{children:[`+ `,h,` more done`]}),(0,X.jsx)(`small`,{children:`Open archive`})]})}):null]}),(0,X.jsx)(`div`,{className:`dashboard-board-lane-add`,children:_?(0,X.jsxs)(`form`,{className:`dashboard-board-add-composer`,onSubmit:e=>{e.preventDefault(),x(t.id)},children:[(0,X.jsx)(`input`,{autoFocus:!0,type:`text`,value:a,onChange:e=>o(e.target.value),placeholder:`New ${t.label} task`,disabled:s,"aria-label":`New task for ${t.label}`,onKeyDown:e=>{e.key===`Escape`&&(i(null),o(``))}}),(0,X.jsx)(`button`,{type:`submit`,disabled:s||!a.trim(),children:`Add`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{i(null),o(``)},"aria-label":`Cancel`,children:`×`})]}):(0,X.jsx)(`button`,{type:`button`,className:`dashboard-board-add-trigger`,onClick:()=>{i(t.id),o(``)},children:`+ Add task`})})]},t.id)})}):(0,X.jsx)(Mc,{lane:te,cards:k.filter(e=>e.lane===te),runningChipByPort:j,onBackToOverall:()=>e.onViewChange({kind:`overall`}),onOpenCard:g}),(0,X.jsx)(Bc,{card:ee,busy:_,onClose:()=>g(null),onSave:w})]})}var Yc=[{id:`today`,label:`Today`},{id:`upcoming`,label:`Upcoming`},{id:`recurring`,label:`Recurring`},{id:`blocked`,label:`Blocked`}];function Xc(e){return(0,X.jsxs)(`nav`,{className:`dashboard-schedule-sidebar`,"aria-label":`Schedule groups`,children:[(0,X.jsx)(`header`,{className:`dashboard-schedule-sidebar-header`,children:(0,X.jsx)(`span`,{className:`dashboard-schedule-sidebar-title`,children:`Schedule`})}),(0,X.jsx)(`ul`,{className:`dashboard-schedule-sidebar-list`,children:Yc.map(t=>(0,X.jsx)(`li`,{children:(0,X.jsx)(`button`,{type:`button`,className:`dashboard-schedule-sidebar-item${e.activeGroup===t.id?` is-active`:``}`,onClick:()=>e.onGroupChange(t.id),"aria-pressed":e.activeGroup===t.id,children:(0,X.jsx)(`span`,{children:t.label})})},t.id))})]})}var Zc=`/api/dashboard/schedule`;async function Qc(e){if(!e.ok){let t=await e.text().catch(()=>``);throw Error(`${e.status} ${t||e.statusText}`)}return await e.json()}async function $c(){let e=await Qc(await fetch(`${Zc}/work`,{credentials:`same-origin`}));return Array.isArray(e.items)?e.items:[]}async function el(e){return(await Qc(await fetch(`${Zc}/work`,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,body:JSON.stringify(e)}))).item}async function tl(e,t){return(await Qc(await fetch(`${Zc}/work/${encodeURIComponent(e)}`,{method:`PATCH`,headers:{"content-type":`application/json`},credentials:`same-origin`,body:JSON.stringify(t)}))).item}async function nl(e){await Qc(await fetch(`${Zc}/work/${encodeURIComponent(e)}`,{method:`DELETE`,credentials:`same-origin`}))}async function rl(e,t=[]){let n=await Qc(await fetch(`${Zc}/work/${encodeURIComponent(e)}/dispatch`,{method:`POST`,headers:{"content-type":`application/json`},credentials:`same-origin`,body:JSON.stringify({busyPorts:t})}));return{result:n.result,item:n.item}}async function il(){try{let e=await fetch(`/api/heartbeat`,{credentials:`same-origin`});if(!e.ok)return[];let t=await e.json();return Array.isArray(t.jobs)?t.jobs:[]}catch{return[]}}function al(e){return e.cron?`cron ${e.cron}`:e.runAt?`at ${e.runAt}`:e.enabled?`manual`:`disabled`}function ol(e){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)([]),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(``),[d,f]=(0,Y.useState)(!1),[p,m]=(0,Y.useState)({}),[h,g]=(0,Y.useState)(null),_=(0,Y.useRef)(null),v=(0,Y.useCallback)(async()=>{try{i(await $c())}catch{}},[]);(0,Y.useEffect)(()=>{if(!e.active)return;let t=!1;return Promise.all([il(),$c().catch(()=>[])]).then(([e,r])=>{t||(n(e),i(r),o(!0))}),()=>{t=!0}},[e.active]),(0,Y.useEffect)(()=>{if(!h)return;let e=e=>{_.current&&(_.current.contains(e.target)||g(null))};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[h]);let y=(0,Y.useCallback)(async e=>{let t=l.trim();if(t&&!d){f(!0);try{await el({title:t,group:e}),u(``),c(null),await v()}catch{}finally{f(!1)}}},[l,d,v]),b=(0,Y.useCallback)(async(e,t)=>{g(null);try{await tl(e,{group:t}),await v()}catch{}},[v]),x=(0,Y.useCallback)(async e=>{try{await nl(e),await v()}catch{}},[v]),S=(0,Y.useCallback)(async t=>{try{let n=e.busyPorts,{result:r}=await rl(t,Array.isArray(n)?n:n?Array.from(n):[]);m(e=>({...e,[t]:r})),await v()}catch{}},[e.busyPorts,v]);return(0,X.jsxs)(`section`,{className:`dashboard-schedule-workspace`,"aria-hidden":!e.active,children:[(0,X.jsxs)(`header`,{className:`dashboard-schedule-workspace-header`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{children:`Automations`}),(0,X.jsx)(`p`,{className:`dashboard-schedule-workspace-subtitle`,children:`Manager-owned scheduled work. The dashboard ticks once a minute and dispatches due items.`})]}),(0,X.jsx)(cr,{topic:`schedule`,label:`Open Automations help`,onOpen:e.onOpenHelpTopic}),t.length>0?(0,X.jsxs)(`p`,{className:`dashboard-schedule-legacy-notice`,role:`note`,children:[`⚠️ `,t.length,` legacy heartbeat job(s) detected in this instance's `,(0,X.jsx)(`code`,{children:`heartbeat.json`}),`. They are no longer auto-fired by the manager — migrate them into Automations.`]}):null]}),(0,X.jsx)(`div`,{className:`dashboard-schedule-groups`,children:Yc.map(t=>{let n=r.filter(e=>e.group===t.id).filter(e=>e.enabled),i=n.length,o=s===t.id;return(0,X.jsxs)(`div`,{className:`dashboard-schedule-group${e.activeGroup===t.id?` is-focused`:``}`,children:[(0,X.jsxs)(`header`,{className:`dashboard-schedule-group-header`,children:[(0,X.jsx)(`span`,{className:`dashboard-schedule-group-title`,children:t.label}),(0,X.jsx)(`span`,{className:`dashboard-schedule-group-count`,children:i})]}),(0,X.jsx)(`ul`,{className:`dashboard-schedule-items`,children:a?i===0?(0,X.jsx)(`li`,{className:`dashboard-schedule-empty`,children:`No items`}):(0,X.jsx)(X.Fragment,{children:n.map(e=>{let t=p[e.id],n=e.lastRunAt?`last ${e.lastRunAt.slice(11,16)}`:null,r=e.lastStatus||null;return(0,X.jsxs)(`li`,{className:`dashboard-schedule-item`,"data-persisted":`true`,"data-dispatch-status":t?.status||``,children:[(0,X.jsx)(`span`,{className:`dashboard-schedule-item-name`,children:e.title}),(0,X.jsxs)(`span`,{className:`dashboard-schedule-item-meta`,children:[al(e),` • saved`,e.targetPort==null?``:` • :${e.targetPort}`,n?` • ${n}`:``,r?` • ${r}`:``,t?` • ${t.status}`:``]}),(0,X.jsxs)(`span`,{className:`dashboard-schedule-item-actions`,"data-open":h===e.id?`true`:`false`,children:[(0,X.jsx)(`button`,{type:`button`,className:`dashboard-schedule-run-now`,onClick:()=>void S(e.id),"aria-label":`Run now`,title:`Dispatch to target instance (queued if busy)`,children:`Run`}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-schedule-item-action`,onMouseDown:e=>e.stopPropagation(),onClick:()=>g(t=>t===e.id?null:e.id),"aria-haspopup":`menu`,"aria-expanded":h===e.id,"aria-label":`Move scheduled work`,children:`Move`}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-schedule-item-action`,"data-danger":`true`,onClick:()=>void x(e.id),"aria-label":`Delete`,children:`Delete`}),h===e.id&&(0,X.jsx)(`div`,{ref:_,className:`dashboard-schedule-popover`,role:`menu`,children:Yc.map(t=>(0,X.jsxs)(`button`,{type:`button`,className:`dashboard-schedule-popover-item${t.id===e.group?` is-current`:``}`,role:`menuitem`,disabled:t.id===e.group,onClick:()=>void b(e.id,t.id),children:[t.label,t.id===e.group?` ✓`:``]},t.id))})]})]},e.id)})}):(0,X.jsx)(`li`,{className:`dashboard-schedule-empty`,children:`Loading…`})}),(0,X.jsx)(`div`,{className:`dashboard-schedule-group-add`,children:o?(0,X.jsxs)(`form`,{className:`dashboard-schedule-add-composer`,onSubmit:e=>{e.preventDefault(),y(t.id)},children:[(0,X.jsx)(`input`,{autoFocus:!0,type:`text`,value:l,onChange:e=>u(e.target.value),placeholder:`New ${t.label} item`,disabled:d,"aria-label":`New scheduled work for ${t.label}`,onKeyDown:e=>{e.key===`Escape`&&(c(null),u(``))}}),(0,X.jsx)(`button`,{type:`submit`,disabled:d||!l.trim(),children:`Add`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{c(null),u(``)},"aria-label":`Cancel`,children:`×`})]}):(0,X.jsx)(`button`,{type:`button`,className:`dashboard-schedule-add-trigger`,onClick:()=>{c(t.id),u(``)},children:`+ Add scheduled work`})})]},t.id)})})]})}var sl=1e3;function cl(e,t){return ul(e)-ul(t)||pl(e)-pl(t)||dl(e)-dl(t)||fl(e)-fl(t)||Date.parse(e.sourceCreatedAt)-Date.parse(t.sourceCreatedAt)}function ll(e,t){let n=e?.manualRank??null,r=t?.manualRank??null;return n===null&&r===null?sl:n===null&&r!==null?r-sl:n!==null&&r===null?n+sl:n!==null&&r!==null?(n+r)/2:sl}function ul(e){return e.status===`focused`?0:1}function dl(e){return e.manualRank??2**53-1}function fl(e){let t=[e.remindAt,e.dueAt].filter(e=>!!e).map(e=>Date.parse(e)).filter(e=>Number.isFinite(e));return t.length>0?Math.min(...t):2**53-1}function pl(e){return e.priority===`high`?0:e.priority===`normal`?1:2}function ml(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t}function hl(e,t){let n=ml(e.dueAt);return n!==null&&n.getTime()<t.getTime()}function gl(e,t){let n=ml(e.dueAt);return n!==null&&n.getFullYear()===t.getFullYear()&&n.getMonth()===t.getMonth()&&n.getDate()===t.getDate()}function _l(e,t){return e.filter(e=>e.status!==`done`&&(hl(e,t)||gl(e,t))).length}var vl=[{id:`urgentImportant`,title:`Important and Urgent`,tone:`red`},{id:`important`,title:`Important, Not Urgent`,tone:`green`},{id:`waiting`,title:`Waiting / Delegated`,tone:`amber`},{id:`later`,title:`Later`,tone:`blue`}],yl={urgentImportant:{listId:`today`,status:`open`,priority:`high`},important:{listId:`today`,status:`open`,priority:`normal`},waiting:{listId:`waiting`,status:`waiting`,priority:`normal`},later:{listId:`later`,status:`open`,priority:`low`}};function bl(e){return yl[e]}function xl(e){return e.status===`done`?null:e.status===`focused`?`urgentImportant`:e.status===`waiting`?`waiting`:e.listId===`later`||e.priority===`low`?`later`:e.priority===`high`?`urgentImportant`:`important`}function Sl(e,t){return t.filter(t=>xl(t)===e).sort(cl)}function Cl(e,t){return e===`matrix`?t.filter(e=>e.status!==`done`).sort(cl):e===`done`?t.filter(e=>e.status===`done`).sort(cl):e===`focused`?Sl(`urgentImportant`,t):e===`important`?Sl(`important`,t):e===`waiting`?Sl(`waiting`,t):e===`later`?Sl(`later`,t):t.filter(e=>e.status!==`done`).sort(cl)}function wl(e,t){return Cl(e,t).length}function Tl(e,t=3){return e.filter(e=>e.status!==`done`).sort(cl).slice(0,t)}function El(e,t,n=3){let r=e.filter(e=>e.status!==`done`),i=r.filter(e=>hl(e,t)).sort(cl),a=new Set(i.map(e=>e.id)),o=r.filter(e=>!a.has(e.id)),s=Tl(o,3),c=new Set([...i,...s].map(e=>e.id)),l=o.filter(e=>gl(e,t)).sort(cl).filter(e=>!c.has(e.id)).slice(0,n);for(let e of l)c.add(e.id);return{overdue:i,priority:s,today:l,upcomingCount:r.filter(e=>!c.has(e.id)).length,badgeCount:_l(e,t)}}var Dl=`application/x-jaw-dashboard-reminder`;function Ol(e){return Array.from(e.dataTransfer.types).includes(Dl)}function kl(e){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null);function a(e,t){if(t.target instanceof HTMLElement&&t.target.closest(`input, textarea, button, [data-reminder-inline-edit="true"]`)){t.preventDefault();return}t.dataTransfer.effectAllowed=`move`,t.dataTransfer.setData(Dl,e.id),n(e.id)}function o(e,t){Ol(t)&&(t.preventDefault(),t.dataTransfer.dropEffect=`move`,i(e))}function s(){i(null)}function c(t,r){if(!Ol(r))return;r.preventDefault();let a=r.dataTransfer.getData(Dl);n(null),i(null),a&&e(a,t)}function l(){n(null),i(null)}return{draggedId:t,dropTarget:r,start:a,over:o,leave:s,drop:c,end:l}}var Al=[{id:`matrix`,label:`Matrix`,detail:`Priority board`},{id:`focused`,label:`Focus`,detail:`Current item`},{id:`important`,label:`Important`,detail:`Not urgent`},{id:`waiting`,label:`Waiting`,detail:`Delegated`},{id:`later`,label:`Later`,detail:`Low urgency`},{id:`done`,label:`Done`,detail:`Completed items`}];function jl(e,t){return!!(e&&e.kind===t.kind&&e.beforeId===t.beforeId&&e.afterId===t.afterId)}function Ml(e){return e.length>0?e[e.length-1]??null:null}function Nl(e,t){return{kind:`priority`,beforeId:e[t-1]?.id??null,afterId:e[t]?.id??null}}function Pl(e){return{kind:`priority`,beforeId:Ml(e)?.id??null,afterId:null}}function Fl(e,t,n){let r=e.filter(e=>e.id!==t),i=n.beforeId?r.find(e=>e.id===n.beforeId)??null:null,a=n.afterId?r.find(e=>e.id===n.afterId)??null:null;return i||a?{previous:i,next:a}:n.beforeId&&!n.afterId?{previous:Ml(r),next:null}:!n.beforeId&&n.afterId?{previous:null,next:r[0]??null}:{previous:Ml(r),next:null}}function Il(e){let t=Pl(e.items),n=(t,n)=>e.drag.over(t,n),r=(t,n)=>e.drag.drop(t,n);return(0,X.jsxs)(`section`,{className:`dashboard-reminders-sidebar-priority`,"data-drop-target":e.drag.dropTarget?.kind===`priority`?`true`:`false`,onDragOver:e=>n(t,e),onDragLeave:e.drag.leave,onDrop:e=>r(t,e),children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`span`,{children:`Priority Order`}),(0,X.jsx)(`small`,{children:`drag to rank`})]}),(0,X.jsxs)(`ol`,{children:[e.items.map((t,i)=>{let a=Nl(e.items,i);return(0,X.jsxs)(`li`,{draggable:!e.loading&&t.status!==`done`,"data-drop-target":jl(e.drag.dropTarget,a)?`true`:void 0,"data-reminder-drop-before-id":a.beforeId??void 0,"data-reminder-drop-after-id":a.afterId??void 0,onDragStart:n=>e.drag.start(t,n),onDragEnd:e.drag.end,onDragOver:e=>{e.stopPropagation(),n(a,e)},onDragLeave:t=>{t.stopPropagation(),e.drag.leave()},onDrop:e=>{e.stopPropagation(),r(a,e)},children:[(0,X.jsx)(`span`,{className:`dashboard-reminders-sidebar-priority-index`,children:i+1}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`b`,{children:t.title}),(0,X.jsxs)(`small`,{children:[t.status,` • `,t.priority]})]})]},t.id)}),e.items.length===0?(0,X.jsx)(`li`,{className:`dashboard-reminders-sidebar-priority-empty`,children:`No open reminders`}):null]})]})}function Ll(e){let t=e.items.filter(e=>e.status!==`done`).length,n=Tl(e.items,5),r=kl((t,n)=>{if(n.kind!==`priority`)return;let{previous:r,next:i}=Fl(Tl(e.items,e.items.length),t,n);e.onUpdate(t,{manualRank:ll(r,i)})});return(0,X.jsxs)(`nav`,{className:`dashboard-reminders-sidebar`,"aria-label":`Reminders views`,children:[(0,X.jsxs)(`header`,{className:`dashboard-reminders-sidebar-header`,children:[(0,X.jsx)(`span`,{className:`dashboard-reminders-sidebar-title`,children:`Reminders`}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-reminders-refresh`,onClick:e.onRefresh,disabled:e.loading,children:e.loading?`Loading`:`Refresh`})]}),(0,X.jsxs)(`div`,{className:`dashboard-reminders-source`,"data-state":`ok`,children:[t,` open / `,e.items.length,` total`]}),(0,X.jsx)(Il,{items:n,loading:e.loading,drag:r}),(0,X.jsx)(`ul`,{className:`dashboard-reminders-sidebar-list`,children:Al.map(t=>(0,X.jsx)(`li`,{children:(0,X.jsxs)(`button`,{type:`button`,className:`dashboard-reminders-sidebar-item${e.view===t.id?` is-active`:``}`,onClick:()=>e.onViewChange(t.id),"aria-pressed":e.view===t.id,children:[(0,X.jsx)(`span`,{children:t.label}),(0,X.jsx)(`small`,{children:t.detail}),(0,X.jsx)(`b`,{children:wl(t.id,e.items)})]})},t.id))})]})}function Rl(e){let[t,n]=(0,Y.useState)(!1),[r,i]=(0,Y.useState)(e.item.title),a=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{t||i(e.item.title)},[t,e.item.title]),(0,Y.useEffect)(()=>{t&&a.current?.select()},[t]);function o(){let t=r.trim();if(n(!1),!t||t===e.item.title){i(e.item.title);return}e.onRename(e.item.id,t)}function s(){i(e.item.title),n(!1)}function c(e){e.key===`Enter`?(e.preventDefault(),o()):e.key===`Escape`&&(e.preventDefault(),s())}return t?(0,X.jsx)(`input`,{ref:a,"data-reminder-inline-edit":`true`,className:`dashboard-reminders-inline-title-input`,"aria-label":`Reminder title`,disabled:e.busy,value:r,onChange:e=>i(e.target.value),onBlur:o,onClick:e=>e.stopPropagation(),onDoubleClick:e=>e.stopPropagation(),onKeyDown:c}):(0,X.jsx)(`span`,{className:`dashboard-reminders-inline-title`,onDoubleClick:e=>{e.preventDefault(),e.stopPropagation(),n(!0)},children:e.item.title})}function zl(e){let[t,n]=(0,Y.useState)(``),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(``),[s,c]=(0,Y.useState)(``);(0,Y.useEffect)(()=>{n(e.item?.title??``),i(e.item?.notes??``),o(Bl(e.item?.dueAt??null)),c(Bl(e.item?.remindAt??null))},[e.item]),(0,Y.useEffect)(()=>{if(!e.item)return;let t=t=>{t.key===`Escape`&&e.onClose()};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e]);let l=(0,Y.useMemo)(()=>e.item?t.trim()!==e.item.title||r!==e.item.notes||a!==Bl(e.item.dueAt)||s!==Bl(e.item.remindAt):!1,[a,r,e.item,s,t]);if(!e.item)return null;let u=e.item;return(0,X.jsx)(`div`,{className:`dashboard-reminder-popover-scrim`,role:`presentation`,onMouseDown:e.onClose,children:(0,X.jsx)(`section`,{className:`dashboard-reminder-popover`,role:`dialog`,"aria-modal":`true`,"aria-label":`Reminder details`,onMouseDown:e=>e.stopPropagation(),children:(0,X.jsxs)(`form`,{onSubmit:n=>{if(n.preventDefault(),!u)return;let i=t.trim();if(!i)return;let o={};if(i!==u.title&&(o.title=i),r!==u.notes&&(o.notes=r),a!==Bl(u.dueAt)&&(o.dueAt=Vl(a)),s!==Bl(u.remindAt)&&(o.remindAt=Vl(s)),Object.keys(o).length===0){e.onClose();return}e.onSave(u.id,o)},children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`span`,{children:`Reminder details`}),(0,X.jsx)(`button`,{type:`button`,"aria-label":`Close reminder details`,onClick:e.onClose,children:`×`})]}),(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{children:`Title`}),(0,X.jsx)(`input`,{value:t,onChange:e=>n(e.target.value),"aria-label":`Reminder title`})]}),(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{children:`Notes`}),(0,X.jsx)(`textarea`,{value:r,onChange:e=>i(e.target.value),"aria-label":`Reminder notes`,rows:6})]}),(0,X.jsxs)(`div`,{className:`dashboard-reminder-popover-grid`,children:[(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{children:`Due`}),(0,X.jsx)(`input`,{type:`datetime-local`,value:a,onChange:e=>o(e.target.value),"aria-label":`Reminder due date`})]}),(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{children:`Remind`}),(0,X.jsx)(`input`,{type:`datetime-local`,value:s,onChange:e=>c(e.target.value),"aria-label":`Reminder notification date`})]})]}),(0,X.jsxs)(`footer`,{children:[(0,X.jsx)(`button`,{type:`button`,onClick:e.onClose,children:`Cancel`}),(0,X.jsx)(`button`,{type:`submit`,disabled:e.busy||!t.trim()||!l,children:`Save`})]})]})})})}function Bl(e){if(!e)return``;let t=new Date(e);if(Number.isNaN(t.getTime()))return``;let n=t.getTimezoneOffset()*6e4;return new Date(t.getTime()-n).toISOString().slice(0,16)}function Vl(e){if(!e.trim())return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toISOString()}var Hl={matrix:`Priority Matrix`,focused:`Focus`,important:`Important, Not Urgent`,waiting:`Waiting / Delegated`,later:`Later`,done:`Done`};function Ul(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Wl(e){let t=[e.status,e.priority],n=Ul(e.remindAt),r=Ul(e.dueAt);return r&&t.push(`due ${r}`),n&&t.push(`remind ${n}`),e.linkedInstance&&t.push(e.linkedInstance),e.notificationStatus!==`pending`&&t.push(e.notificationStatus),t.join(` • `)}function Gl(e,t){return!e||e.kind!==t.kind||e.beforeId!==t.beforeId||e.afterId!==t.afterId?!1:e.kind===`bucket`&&t.kind===`bucket`?e.bucket===t.bucket:!0}function Kl(e,t,n){return{kind:`bucket`,bucket:e,beforeId:t[n-1]?.id??null,afterId:t[n]?.id??null}}function ql(e,t,n){return{kind:`bucket`,bucket:e,beforeId:t[n]?.id??null,afterId:t[n+1]?.id??null}}function Jl(e,t){return{kind:`bucket`,bucket:e,beforeId:eu(t)?.id??null,afterId:null}}function Yl(e,t){return{kind:`priority`,beforeId:e[t-1]?.id??null,afterId:e[t]?.id??null}}function Xl(e,t){return{kind:`priority`,beforeId:e[t]?.id??null,afterId:e[t+1]?.id??null}}function Zl(e){return{kind:`priority`,beforeId:eu(e)?.id??null,afterId:null}}function Ql(e){let t=e.currentTarget.getBoundingClientRect();return e.clientY>t.top+t.height/2}function $l(e,t){return t.kind===`priority`?Tl(e,e.length):Sl(t.bucket,e)}function eu(e){return e.length>0?e[e.length-1]??null:null}function tu(e,t,n){let r=e.filter(e=>e.id!==t),i=n.beforeId?r.find(e=>e.id===n.beforeId)??null:null,a=n.afterId?r.find(e=>e.id===n.afterId)??null:null;return i||a?{previous:i,next:a}:n.beforeId&&!n.afterId?{previous:eu(r),next:null}:!n.beforeId&&n.afterId?{previous:null,next:r[0]??null}:{previous:eu(r),next:null}}function nu(e){return e.feed.error?(0,X.jsx)(`p`,{className:`dashboard-reminders-status`,"data-state":`error`,children:e.feed.error}):(0,X.jsxs)(`p`,{className:`dashboard-reminders-status`,children:[e.feed.items.length,` reminder(s) stored in the dashboard database`]})}function ru(e){let t=e.item.status===`done`,n=e.dropTarget?Gl(e.activeDropTarget??null,e.dropTarget):!1;return(0,X.jsxs)(`li`,{className:`dashboard-reminders-row`,"data-priority":e.item.priority,"data-status":e.item.status,"data-drop-target":n?`true`:void 0,"data-reminder-drop-before-id":e.dropTarget?.beforeId??void 0,"data-reminder-drop-after-id":e.dropTarget?.afterId??void 0,draggable:!t&&!e.busy,onDragStart:t=>e.onDragStart?.(e.item,t),onDragEnd:e.onDragEnd,onDragOver:t=>{let n=e.resolveDropTarget?.(t)??e.dropTarget;n&&(t.stopPropagation(),e.onDragOverTarget?.(n,t))},onDragLeave:t=>{e.dropTarget&&(t.stopPropagation(),e.onDragLeaveTarget?.())},onDrop:t=>{let n=e.resolveDropTarget?.(t)??e.dropTarget;n&&(t.stopPropagation(),e.onDropTarget?.(n,t))},children:[(0,X.jsx)(`button`,{type:`button`,className:`dashboard-reminders-row-check`,"aria-label":t?`Mark open`:`Mark done`,onClick:()=>e.onToggleDone(e.item),children:t?`✓`:``}),(0,X.jsxs)(`span`,{className:`dashboard-reminders-row-content`,children:[(0,X.jsx)(Rl,{item:e.item,busy:e.busy,onRename:e.onRename}),(0,X.jsx)(`small`,{children:Wl(e.item)})]}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-reminders-row-more`,"aria-label":`Open reminder details`,onClick:()=>e.onOpenDetails(e.item),children:`•••`}),e.item.priority===`high`?(0,X.jsx)(`span`,{className:`dashboard-reminders-row-flag`,"aria-label":`high priority`,children:`!`}):null]})}function iu(e){let[t,n]=(0,Y.useState)(``);return(0,X.jsxs)(`li`,{className:`dashboard-reminders-create-row`,children:[(0,X.jsx)(`span`,{"aria-hidden":`true`}),(0,X.jsx)(`form`,{onSubmit:r=>{r.preventDefault();let i=t.trim();i&&(e.onCreate({title:i,...yl[e.bucket]}),n(``))},children:(0,X.jsx)(`input`,{"aria-label":`Create ${e.bucket} reminder`,placeholder:`New reminder`,value:t,onChange:e=>n(e.target.value)})})]})}function au(e){let t=Jl(e.section.id,e.items);return(0,X.jsxs)(`section`,{className:`dashboard-reminders-quadrant`,"data-tone":e.section.tone,"data-drop-target":e.dropTarget?.kind===`bucket`&&e.dropTarget.bucket===e.section.id?`true`:`false`,onDragOver:n=>e.onDragOver(t,n),onDragLeave:e.onDragLeave,onDrop:n=>e.onDrop(t,n),children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`h3`,{children:e.section.title}),(0,X.jsx)(`span`,{children:e.items.length})]}),(0,X.jsxs)(`ul`,{children:[e.items.map((t,n)=>{let r=Kl(e.section.id,e.items,n);return(0,X.jsx)(ru,{item:t,busy:e.busy,onToggleDone:e.onToggleDone,onRename:e.onRename,onOpenDetails:e.onOpenDetails,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,dropTarget:r,resolveDropTarget:t=>Ql(t)?ql(e.section.id,e.items,n):r,activeDropTarget:e.dropTarget,onDragOverTarget:e.onDragOver,onDragLeaveTarget:e.onDragLeave,onDropTarget:e.onDrop},t.id)}),(0,X.jsx)(iu,{bucket:e.section.id,onCreate:e.onCreate}),e.items.length===0?(0,X.jsx)(`li`,{className:`dashboard-reminders-empty-row`,children:`No reminders`}):null]})]})}function ou(e){return(0,X.jsxs)(`div`,{className:`dashboard-reminders-matrix-wrap`,children:[(0,X.jsx)(`span`,{className:`dashboard-reminders-axis dashboard-reminders-axis-importance`,children:`Importance`}),(0,X.jsx)(`span`,{className:`dashboard-reminders-axis dashboard-reminders-axis-urgency`,children:`Urgency`}),(0,X.jsx)(`div`,{className:`dashboard-reminders-matrix-board`,children:vl.map(t=>(0,X.jsx)(au,{section:t,items:Sl(t.id,e.items),busy:e.busy,dropTarget:e.dropTarget,onCreate:e.onCreate,onToggleDone:e.onToggleDone,onRename:e.onRename,onOpenDetails:e.onOpenDetails,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,onDragOver:e.onDragOver,onDragLeave:e.onDragLeave,onDrop:e.onDrop},t.id))})]})}function su(e){let t=Zl(e.items);return(0,X.jsxs)(`section`,{className:`dashboard-reminders-top-priority`,"aria-label":`Top priority reminders`,"data-drop-target":e.dropTarget?.kind===`priority`?`true`:`false`,onDragOver:n=>e.onDragOver(t,n),onDragLeave:e.onDragLeave,onDrop:n=>e.onDrop(t,n),children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`span`,{children:`Top Priority 3`}),(0,X.jsxs)(`small`,{children:[e.items.length,`/3`]})]}),(0,X.jsxs)(`ol`,{children:[e.items.map((t,n)=>{let r=Yl(e.items,n);return(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`dashboard-reminders-top-index`,children:n+1}),(0,X.jsx)(ru,{item:t,busy:e.busy,onToggleDone:e.onToggleDone,onRename:e.onRename,onOpenDetails:e.onOpenDetails,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd,dropTarget:r,resolveDropTarget:t=>Ql(t)?Xl(e.items,n):r,activeDropTarget:e.dropTarget,onDragOverTarget:e.onDragOver,onDragLeaveTarget:e.onDragLeave,onDropTarget:e.onDrop})]},t.id)}),e.items.length===0?(0,X.jsx)(`li`,{className:`dashboard-reminders-top-empty`,children:`No top priority reminders`}):null]})]})}function cu(e){return(0,X.jsxs)(`div`,{className:`dashboard-reminders-smart-list`,"aria-busy":e.loading,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`h3`,{children:e.title}),(0,X.jsx)(`span`,{children:e.items.length})]}),(0,X.jsx)(`ul`,{children:e.loading&&e.items.length===0?(0,X.jsx)(`li`,{className:`dashboard-reminders-empty-row`,children:`Loading reminders...`}):e.items.length===0?(0,X.jsx)(`li`,{className:`dashboard-reminders-empty-row`,children:`No reminders`}):e.items.map(t=>(0,X.jsx)(ru,{item:t,busy:e.loading,onToggleDone:e.onToggleDone,onRename:e.onRename,onOpenDetails:e.onOpenDetails,onDragStart:e.onDragStart,onDragEnd:e.onDragEnd},t.id))})]})}function lu(e){let[t,n]=(0,Y.useState)(null),r=Cl(e.view,e.feed.items),i=Hl[e.view],a=Tl(e.feed.items,3),o=kl((t,n)=>{let r=e.feed.items.find(e=>e.id===t);if(!r)return;let{previous:i,next:a}=tu($l(e.feed.items,n),t,n),o=ll(i,a);if(n.kind===`priority`){e.onUpdate(t,{manualRank:o});return}let s=xl(r)===n.bucket?{}:bl(n.bucket);e.onUpdate(t,{...s,manualRank:o})}),s=t=>{e.onUpdate(t.id,{status:t.status===`done`?`open`:`done`})},c=(t,n)=>{e.onUpdate(t,{title:n})};return(0,X.jsxs)(`section`,{className:`dashboard-reminders-workspace`,"aria-hidden":!e.active,children:[(0,X.jsxs)(`header`,{className:`dashboard-reminders-workspace-header`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h2`,{children:i}),(0,X.jsx)(nu,{feed:e.feed})]}),(0,X.jsxs)(`div`,{className:`dashboard-reminders-workspace-actions`,children:[(0,X.jsx)(cr,{topic:`reminders`,label:`Open Reminders help`,onOpen:e.onOpenHelpTopic}),(0,X.jsx)(`button`,{type:`button`,className:`dashboard-reminders-sync-button`,onClick:e.onRefresh,disabled:e.feed.loading,children:e.feed.loading?`Loading...`:`Refresh`})]})]}),e.view===`matrix`?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(su,{items:a,busy:e.feed.loading,dropTarget:o.dropTarget,onToggleDone:s,onRename:c,onOpenDetails:n,onDragStart:o.start,onDragEnd:o.end,onDragOver:o.over,onDragLeave:o.leave,onDrop:o.drop}),(0,X.jsx)(ou,{items:r,busy:e.feed.loading,dropTarget:o.dropTarget,onCreate:e.onCreate,onToggleDone:s,onRename:c,onOpenDetails:n,onDragStart:o.start,onDragEnd:o.end,onDragOver:o.over,onDragLeave:o.leave,onDrop:o.drop})]}):(0,X.jsx)(cu,{title:i,items:r,loading:e.feed.loading,onToggleDone:s,onRename:c,onOpenDetails:n,onDragStart:o.start,onDragEnd:o.end}),(0,X.jsx)(zl,{item:t,busy:e.feed.loading,onClose:()=>n(null),onSave:(t,r)=>{e.onUpdate(t,r),n(null)}})]})}var uu=`/api/dashboard/reminders`;async function du(e){if(!e.ok){let t=await e.text().catch(()=>``);throw Error(`${e.status} ${t||e.statusText}`)}if(!(e.headers.get(`content-type`)||``).includes(`application/json`))throw Error(`Reminders API is not available in the running dashboard server. Rebuild and restart the dashboard backend to enable sync.`);return await e.json()}function fu(e){return{...e,notes:e.notes??``,manualRank:typeof e.manualRank==`number`&&Number.isFinite(e.manualRank)?e.manualRank:null,dueAt:e.dueAt??null,remindAt:e.remindAt??null,linkedInstance:e.linkedInstance??null,subtasks:Array.isArray(e.subtasks)?e.subtasks:[],notificationAttemptedAt:e.notificationAttemptedAt??null,notificationError:e.notificationError??null,instanceId:e.instanceId??null,messageId:e.messageId??null,turnIndex:e.turnIndex??null,port:e.port??null,threadKey:e.threadKey??null,sourceText:e.sourceText??null}}function pu(e,t){if(`manualRank`in e&&!Object.hasOwn(t,`manualRank`))throw Error(`Manual reminder ordering requires the dashboard backend to be rebuilt and restarted.`)}async function mu(){let e=await du(await fetch(uu,{credentials:`same-origin`,cache:`no-store`}));return{...e,items:Array.isArray(e.items)?e.items.map(fu):[]}}async function hu(e){return fu((await du(await fetch(uu,{method:`POST`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:JSON.stringify(e)}))).item)}async function gu(e,t){let n=await du(await fetch(`${uu}/${encodeURIComponent(e)}`,{method:`PATCH`,credentials:`same-origin`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}));return pu(t,n.item),fu(n.item)}async function _u(e){return await gu(e,{status:`done`})}async function vu(e,t){return await gu(e,{remindAt:t})}function yu(e){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(!1),[a,o]=(0,Y.useState)(null),s=(0,Y.useCallback)(async()=>{i(!0),o(null);try{let e=await mu();n(e.items||[])}catch(e){o(e.message)}finally{i(!1)}},[]),c=(0,Y.useCallback)(async()=>{await s()},[s]),l=(0,Y.useCallback)(async e=>{o(null);try{let t=await hu(e);n(e=>[t,...e.filter(e=>e.id!==t.id)])}catch(e){throw o(e.message),e}},[]),u=(0,Y.useCallback)(async(e,t)=>{o(null);try{let r=await gu(e,t);n(t=>t.map(t=>t.id===e?r:t))}catch(e){o(e.message)}},[]),d=(0,Y.useCallback)(async e=>{o(null);let t=[];n(n=>(t=n,n.map(t=>t.id===e?{...t,status:`done`}:t)));try{let t=await _u(e);n(n=>n.map(n=>n.id===e?t:n))}catch(e){n(t),o(e.message)}},[]),f=(0,Y.useCallback)(async(e,t)=>{o(null);try{let r=await vu(e,t);n(t=>t.map(t=>t.id===e?r:t))}catch(e){o(e.message)}},[]);return(0,Y.useEffect)(()=>{e.active&&s()},[e.active,s]),(0,Y.useEffect)(()=>{if(!e.active||!e.pollWhileActiveMs)return;let t=window.setInterval(()=>{document.hidden||s()},e.pollWhileActiveMs);return()=>window.clearInterval(t)},[e.active,e.pollWhileActiveMs,s]),(0,Y.useEffect)(()=>{if(!e.active||!e.pollWhileActiveMs)return;let t=()=>{document.hidden||s()};return window.addEventListener(`focus`,t),document.addEventListener(`visibilitychange`,t),()=>{window.removeEventListener(`focus`,t),document.removeEventListener(`visibilitychange`,t)}},[e.active,e.pollWhileActiveMs,s]),{items:t,loading:r,error:a,refresh:c,create:l,update:u,markDone:d,snooze:f}}var bu=400,xu=6e4,Su=25e3,Cu=3e3;async function wu(){let e=M()?.browser;if(!e?.getWebviewTabs)return null;let t=await e.getWebviewTabs();return t?.ok?(t.tabs??[]).filter(e=>e.sharedWithAgent===!0).map(e=>({targetId:e.tabId,url:e.url,title:e.title,devToolsOpen:e.devToolsOpen===!0,sharedWithAgent:!0,actionsEnabled:!0})):null}function Tu(e,t){let n=(0,Y.useRef)(null),r=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(!e)return;let i=M()?.browser;if(!i?.getWebviewTabs||!i.onWebviewState)return;let a=!1,o=new AbortController;async function s(e,t){try{await fetch(`/api/dashboard/instances/${e}/embedded-browser/targets`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({targets:t})})}catch{}}async function c(){if(a)return;let e=await wu().catch(()=>null);if(a||e===null)return;try{await fetch(`/api/manager/embedded-browser/targets`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({targets:e})})}catch{}if(a)return;let n=r.current;n!==null&&n!==t&&(await s(n,[]),a)||t!==null&&(await s(t,e),a)||(r.current=t)}function l(){n.current!==null&&window.clearTimeout(n.current),n.current=window.setTimeout(()=>{c()},bu)}async function u(e){let t=M()?.browser;if(!t?.performWebviewAction)return{ok:!1,error:`bridge unavailable`};if(!(await wu().catch(()=>null)??[]).find(t=>t.targetId===e.targetId))return{ok:!1,error:`target is no longer available in Manager Browser`};let n=e.targetId;if(e.kind===`screenshot`){let e=await t.performWebviewAction({kind:`captureScreenshot`,tabId:n});return e?.ok&&e.screenshot?{ok:!0,screenshot:e.screenshot}:{ok:!1,error:e?.error??`capture failed`}}if(e.kind===`snapshot`){let e=await t.performWebviewAction({kind:`getDomSnapshot`,tabId:n});return e?.ok&&e.snapshot?{ok:!0,snapshot:e.snapshot}:{ok:!1,error:e?.error??`snapshot failed`}}if(e.kind===`act`){let r=e.act;if(!r)return{ok:!1,error:`act payload missing`};let i=await t.performWebviewAction({kind:`act`,tabId:n,act:r});return i?.ok?{ok:!0,acted:!0}:{ok:!1,error:i?.error??`act failed`}}return{ok:!1,error:`unknown command kind: ${e.kind}`}}async function d(){for(;!a;){let e=Date.now();try{let e=await fetch(`/api/manager/embedded-browser/commands?wait=${Su}`,{signal:o.signal});if(!e.ok)throw Error(`commands poll ${e.status}`);let t=await e.json();for(let e of t.commands??[]){if(a)return;let t=await u(e);await fetch(`/api/manager/embedded-browser/commands/${encodeURIComponent(e.id)}/result`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,settleToken:e.settleToken})}).catch(()=>void 0)}}catch{await new Promise(e=>setTimeout(e,Cu))}let t=Date.now()-e;!a&&t<1e3&&await new Promise(e=>setTimeout(e,1e3-t))}}let f=i.onWebviewState(()=>l()),p=0,m=window.setInterval(()=>{if(typeof document<`u`&&document.hidden){if(Date.now()-p<24e4)return;p=Date.now(),c();return}p=0,c()},xu);return c(),d(),()=>{a=!0,o.abort(),f(),window.clearInterval(m),n.current!==null&&window.clearTimeout(n.current);let e=r.current;r.current=null,e!==null&&fetch(`/api/dashboard/instances/${e}/embedded-browser/targets`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({targets:[]})}).catch(()=>void 0)}},[e,t])}function Eu(e){let t=e;return typeof t?.closest==`function`&&!!t.closest(`.preview-panel, .preview-frame`)}function Du(e){return!Eu(e)}function Ou(e){return e.find(e=>e.kind===`directory`)??null}function ku(e){return e.find(e=>e.kind===`file`)??null}function Au(e){let t=e.rejected?.length??0,n=t>0?` ${t} rejected.`:``;if(e.entries.length===0)return e.error?`Drop failed: ${e.error}`:t>0?`Drop rejected: ${e.rejected?.[0]?.reason??`path not allowed`}`:null;if(e.source===`preview`)return`Captured ${e.entries.length} dropped item${e.entries.length===1?``:`s`} from preview.${n}`;let r=Ou(e.entries);if(r)return`Opened dropped folder: ${r.name}.${n}`;let i=ku(e.entries);return i?`Opened dropped file: ${i.name}.${n}`:`Opened ${e.entries.length} dropped item${e.entries.length===1?``:`s`}.${n}`}function ju(e){return e?e.files.length>0||Array.from(e.types).includes(`Files`):!1}function Mu(e){let{onDroppedPaths:t}=e,n=(0,Y.useCallback)(async(e,n)=>{let r=M()?.dragDrop;if(!r||e.length===0)return[];try{let i=await r.resolveDroppedItems(e),a=i.entries??[],o=i.rejected??[];return(a.length>0||o.length>0||i.error)&&t({source:n,entries:a,...o.length>0?{rejected:o}:{},...i.error?{error:i.error}:{}}),a}catch(e){return console.warn(`[electron-drop] failed to resolve dropped files`,e),t({source:n,entries:[],error:e.message}),[]}},[t]);return(0,Y.useEffect)(()=>{if(!le()||!M()?.dragDrop)return;function e(e){let t=e.dataTransfer;t&&ju(t)&&Du(e.target)&&(e.preventDefault(),t.dropEffect=`copy`)}function t(e){let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];t.length!==0&&Du(e.target)&&(e.preventDefault(),e.stopPropagation(),n(t,`manager`))}return document.addEventListener(`dragover`,e,!0),document.addEventListener(`drop`,t,!0),()=>{document.removeEventListener(`dragover`,e,!0),document.removeEventListener(`drop`,t,!0)}},[n]),{resolveDroppedFiles:n}}function Nu(e){return e.trim().toLowerCase()}function Pu(e,t){let n=Nu(e),r=Nu(t);if(!r)return 1;if(n.startsWith(r))return 1e3-n.length;let i=n.indexOf(r);if(i>=0)return 700-i;let a=-1,o=0,s=0;for(let e of r){let t=n.indexOf(e,a+1);if(t<0)return null;o=t===a+1?o+1:0,s+=4+o*3-Math.min(t,40)*.1,a=t}return s}function Fu(e,t){let n=[{value:e.label,boost:120},{value:e.section,boost:40},...(e.keywords||[]).map(e=>({value:e,boost:80}))],r=null;for(let i of n){let n=Pu(i.value,t);if(n==null)continue;let a=n+i.boost;(!r||a>r.score)&&(r={command:e,score:a})}return r}function Iu(e,t){return e.map(e=>Fu(e,t.trim())).filter(e=>!!e).sort((e,t)=>{if(t.score!==e.score)return t.score-e.score;let n=e.command.section.localeCompare(t.command.section);return n===0?e.command.label.localeCompare(t.command.label):n})}function Lu(e,t,n){return n<=0?0:Math.max(0,Math.min(n-1,e+t))}function Ru(e){let t=Ba(),[n,r]=(0,Y.useState)(!1),[i,a]=(0,Y.useState)(``),[o,s]=(0,Y.useState)(0),c=(0,Y.useRef)(null),l=(0,Y.useMemo)(()=>Iu(t,i),[t,i]),u=l[o]?`notes-command-palette-option-${o}`:void 0;(0,Y.useEffect)(()=>{if(!e.active){r(!1);return}function t(e){gc(e)&&(e.preventDefault(),r(e=>!e))}return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e.active]),(0,Y.useEffect)(()=>{n&&(a(``),s(0),requestAnimationFrame(()=>c.current?.focus()))},[n]),(0,Y.useEffect)(()=>{o>=l.length&&s(Math.max(0,l.length-1))},[o,l.length]),(0,Y.useEffect)(()=>{(u?document.getElementById(u):null)?.scrollIntoView({block:`nearest`})},[u]);function d(e){if(!e.disabled){r(!1);try{Promise.resolve(e.run()).catch(e=>{console.warn(`[notes-command-palette]`,e)})}catch(e){console.warn(`[notes-command-palette]`,e)}}}function f(){let e=l[o]?.command;e&&d(e)}function p(e){if((e.metaKey||e.ctrlKey)&&e.key.toLowerCase()===`p`){e.preventDefault(),e.stopPropagation();return}e.key===`ArrowDown`?(e.preventDefault(),s(e=>Lu(e,1,l.length))):e.key===`ArrowUp`?(e.preventDefault(),s(e=>Lu(e,-1,l.length))):e.key===`Enter`?(e.preventDefault(),f()):e.key===`Escape`&&(e.preventDefault(),r(!1))}return n?(0,X.jsx)(`div`,{className:`notes-command-palette-backdrop`,role:`presentation`,onClick:()=>r(!1),"data-notes-palette":!0,children:(0,X.jsxs)(`section`,{className:`notes-command-palette`,role:`dialog`,"aria-modal":`true`,"aria-label":`Notes command palette`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,X.jsx)(`input`,{ref:c,className:`notes-command-palette-input`,type:`search`,placeholder:`Run command`,value:i,onChange:e=>{a(e.currentTarget.value),s(0)},onKeyDown:p,"aria-label":`Run Notes command`,"aria-controls":`notes-command-palette-results`,"aria-activedescendant":u}),(0,X.jsxs)(`div`,{id:`notes-command-palette-results`,className:`notes-command-palette-list`,role:`listbox`,"aria-label":`Matching commands`,children:[l.map((e,t)=>{let n=e.command,r=t===o;return(0,X.jsxs)(`button`,{id:`notes-command-palette-option-${t}`,type:`button`,role:`option`,"aria-selected":r,"aria-disabled":n.disabled||void 0,className:`notes-command-palette-item${r?` is-active`:``}${n.disabled?` is-disabled`:``}`,onMouseEnter:()=>s(t),onClick:()=>d(n),children:[(0,X.jsx)(`span`,{className:`notes-command-palette-title`,children:n.label}),(0,X.jsx)(`span`,{className:`notes-command-palette-meta`,children:n.disabledReason||n.section}),n.shortcut&&(0,X.jsx)(`kbd`,{className:`notes-command-palette-shortcut`,children:n.shortcut})]},n.id)}),l.length===0&&(0,X.jsx)(`p`,{className:`notes-command-palette-empty`,children:`No matching commands.`})]}),(0,X.jsxs)(`footer`,{className:`notes-command-palette-footer`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Up/Down`}),` move`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Enter`}),` run`]}),(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`kbd`,{children:`Esc`}),` close`]})]})]})}):null}var zu=76,Bu=8,Vu=96;function Hu(e){return!e||e.scrollHeight-e.scrollTop-e.clientHeight<Vu}function Uu(e){let t=(0,Y.useRef)(null),s=(0,Y.useRef)(!0),c=(0,Y.useRef)(e.count),[{virtualItems:l,totalSize:u},d]=(0,Y.useState)({virtualItems:[],totalSize:0}),f=(0,Y.useRef)(null);f.current||=new o({count:e.count,getScrollElement:()=>t.current,estimateSize:e.estimateSize||(()=>zu),overscan:Bu,getItemKey:e.getItemKey,indexAttribute:`data-jaw-ceo-idx`,useAnimationFrameWithResizeObserver:!0,observeElementRect:n,observeElementOffset:r,scrollToFn:i,measureElement:a,onChange:e=>{d({virtualItems:e.getVirtualItems(),totalSize:e.getTotalSize()})}});let p=f.current,m=(0,Y.useCallback)(e=>{t.current=e,s.current=Hu(e),p._willUpdate()},[p]),h=(0,Y.useCallback)(()=>{s.current=Hu(t.current)},[]),g=(0,Y.useCallback)(e=>{e&&p.measureElement(e)},[p]);return(0,Y.useEffect)(()=>p._didMount(),[p]),(0,Y.useEffect)(()=>()=>{f.current=null},[]),(0,Y.useLayoutEffect)(()=>{p.setOptions({...p.options,count:e.count,getItemKey:e.getItemKey,estimateSize:e.estimateSize||(()=>zu)}),p._willUpdate(),d({virtualItems:p.getVirtualItems(),totalSize:p.getTotalSize()})},[e.count,e.estimateSize,e.getItemKey,p]),(0,Y.useLayoutEffect)(()=>{let t=c.current;c.current=e.count,e.count!==0&&(t>0&&!s.current||requestAnimationFrame(()=>{p.scrollToIndex(e.count-1,{align:`end`})}))},[e.count,p]),{scrollRef:m,onScroll:h,measureElement:g,virtualItems:l,totalSize:u}}async function Wu(e,t){let n=await e.text(),r=null;if(n.trim())try{r=JSON.parse(n)}catch{throw Error(`${t}: endpoint returned non-JSON; restart the dashboard server to load the Jaw CEO API`)}if(!e.ok||!r||r.ok===!1){let e=r&&r.ok===!1&&(r.error||r.message)||t;throw Error(e)}return r.data}async function Gu(e,t){return await Wu(await fetch(e),t)}async function Ku(e,t={},n=`Jaw CEO request failed`){return await Wu(await fetch(e,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),n)}async function qu(e,t={},n=`Jaw CEO request failed`){return await Wu(await fetch(e,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify(t)}),n)}async function Ju(){return await Gu(`/api/jaw-ceo/state`,`Jaw CEO state fetch failed`)}async function Yu(){return await Gu(`/api/jaw-ceo/settings`,`Jaw CEO settings fetch failed`)}async function Xu(e){return await qu(`/api/jaw-ceo/settings`,e,`Jaw CEO settings save failed`)}async function Zu(e){let t={text:e.text,selectedPort:e.selectedPort,inputMode:e.inputMode||`text`,responseMode:e.responseMode||`text`};return e.sessionId&&(t.sessionId=e.sessionId),await Ku(`/api/jaw-ceo/message`,t,`Jaw CEO message failed`)}async function Qu(e){let t={};return e.ports!==void 0&&(t.ports=e.ports),e.events!==void 0&&(t.events=e.events),e.sinceCursor!==void 0&&(t.sinceCursor=e.sinceCursor),await Ku(`/api/jaw-ceo/events/refresh`,t,`Jaw CEO event refresh failed`)}async function $u(e,t){return await Ku(`/api/jaw-ceo/pending/${encodeURIComponent(e)}/continue`,{mode:t},`Jaw CEO continue failed`)}async function ed(e,t=`short`){return await Ku(`/api/jaw-ceo/pending/${encodeURIComponent(e)}/summarize`,{format:t},`Jaw CEO summarize failed`)}async function td(e,t){return await Ku(`/api/jaw-ceo/pending/${encodeURIComponent(e)}/${t}`,{},`Jaw CEO pending update failed`)}async function nd(e){let t={offerSdp:e.offerSdp,selectedPort:e.selectedPort,responseMode:e.responseMode||`voice`};return e.sessionId&&(t.sessionId=e.sessionId),await Ku(`/api/jaw-ceo/voice/connect`,t,`Jaw CEO voice connect failed`)}async function rd(e){return await Ku(`/api/jaw-ceo/voice/${encodeURIComponent(e)}/close`,{},`Jaw CEO voice close failed`)}function id(e){if(e?.openaiKeyInvalid)return`Invalid saved key`;if(!e?.openaiKeySet)return`No key saved`;let t=e.openaiKeyLast4?`•••• ${e.openaiKeyLast4}`:`saved`;return e.openaiKeySource===`env`?`Env key ${t}`:e.openaiKeySource===`deps`?`Runtime key ${t}`:`Saved key ${t}`}function ad(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(``),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),c=!!(e?.openaiKeyInvalid||e?.openaiKeySet&&e.openaiKeySource!==`env`);(0,Y.useEffect)(()=>{let e=!1;return Yu().then(n=>{e||t(n)}).catch(t=>{e||s(t.message)}),()=>{e=!0}},[]);async function l(){let e=n.trim();if(e){a(!0);try{let n=await Xu({openaiApiKey:e});t(n),r(``),s(null)}catch(e){s(e.message)}finally{a(!1)}}}async function u(){a(!0);try{let e=await Xu({clearOpenAiApiKey:!0});t(e),r(``),s(null)}catch(e){s(e.message)}finally{a(!1)}}return(0,X.jsx)(`section`,{className:`jaw-ceo-settings-panel`,"aria-label":`Jaw CEO settings`,children:(0,X.jsxs)(`form`,{className:`jaw-ceo-settings-form`,onSubmit:e=>{e.preventDefault(),l()},children:[(0,X.jsxs)(`div`,{className:`jaw-ceo-settings-status`,children:[(0,X.jsx)(`strong`,{children:`Realtime voice`}),(0,X.jsx)(`span`,{children:id(e)})]}),(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{children:`OpenAI API key`}),(0,X.jsx)(`input`,{value:n,type:`password`,autoComplete:`off`,spellCheck:!1,placeholder:e?.openaiKeySet?`sk-... replace saved key`:`sk-...`,onChange:e=>r(e.target.value)})]}),(0,X.jsxs)(`div`,{className:`jaw-ceo-settings-meta`,children:[(0,X.jsx)(`span`,{children:e?.model||`gpt-realtime-2`}),(0,X.jsx)(`span`,{children:e?.voice||`marin`})]}),e?.openaiKeyInvalid?(0,X.jsx)(`p`,{className:`jaw-ceo-inline-error`,children:`Saved value is not an OpenAI API key. Paste a key that starts with sk-.`}):null,o?(0,X.jsx)(`p`,{className:`jaw-ceo-inline-error`,children:o}):null,(0,X.jsxs)(`div`,{className:`jaw-ceo-form-row`,children:[(0,X.jsx)(`button`,{type:`button`,disabled:i||!c,onClick:()=>void u(),children:`Clear saved`}),(0,X.jsx)(`button`,{type:`submit`,disabled:i||!n.trim(),children:i?`Saving`:`Save key`})]})]})})}function od(e){let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleTimeString()}function sd(e){return e.summary||`Worker :${e.port} has a result ready.`}function cd(e){return[{label:e==null?`Inspect dashboard`:`Inspect :${e}`,text:e==null?`What needs attention on this dashboard right now?`:`What is worker :${e} doing right now?`},{label:`Summarize results`,text:`Summarize the worker results and tell me what needs action.`},{label:e==null?`Route work`:`Send to :${e}`,text:e==null?`Create or choose the right worker for this task: `:`Send this task to worker :${e}: `}]}function ld(e){let t=Array.isArray(e.ceo.state.transcript)?e.ceo.state.transcript:[],n=Array.isArray(e.ceo.state.watches)?e.ceo.state.watches:[],r=Array.isArray(e.ceo.audit)?e.ceo.audit:[],i=[...t.map(e=>({kind:`chat`,id:e.id,at:e.at,role:e.role,text:e.text})),...e.ceo.pending.filter(e=>e.status===`pending`||e.status===`spoken`).map(e=>({kind:`result`,id:`result-${e.completionKey}`,at:e.detectedAt,completion:e})),...n.map(e=>({kind:`watch`,id:`watch-${e.watchId}`,at:e.createdAt,watch:e})),...r.slice(-24).map(e=>({kind:`tool`,id:`audit-${e.id}`,at:e.at,record:e}))];return i.sort((e,t)=>{let n=Date.parse(e.at)-Date.parse(t.at);return n===0?e.id.localeCompare(t.id):n}),e.voice.lastTranscript&&i.push({kind:`live`,id:`live-voice-transcript`,at:new Date().toISOString(),text:e.voice.lastTranscript,eventType:e.voice.lastEventType}),i}function ud(e){if(!e)return 76;if(e.kind===`activity-group`)return 52;let t=Math.max(1,e.text.split(/\r?\n/).filter(Boolean).length);return Math.min(220,54+t*18)}function dd(e){let t=[],n=[];function r(){n.length!==0&&(t.push({kind:`activity-group`,id:`activity-${n[0].id}-${n.length}`,at:n[0].at,entries:n}),n=[])}for(let i of e)i.kind===`chat`||i.kind===`live`?(r(),t.push(i)):n.push(i);return r(),t}function fd(e){return e.kind===`result`?`subagent`:e.kind===`watch`?`thinking`:e.record.kind===`tool`?`tool`:e.record.kind===`completion`?`subagent`:`thinking`}function pd(e){return e.kind===`result`?`Worker :${e.completion.port} result`:e.kind===`watch`?`Listening to worker :${e.watch.port}`:e.record.kind===`completion`?`Worker completion`:e.record.kind===`docs_edit`?`Docs edit`:e.record.kind===`lifecycle`?`Lifecycle`:e.record.kind===`policy`?`Policy check`:e.record.action||`Tool use`}function md(e){return e.kind===`result`?e.completion.resultText||sd(e.completion):e.kind===`watch`?`${e.watch.reason} · fallback ${e.watch.latestMessageFallback.mode}`:e.record.message}function hd(e){return e.kind===`result`?e.completion.detectedAt:e.kind===`watch`?e.watch.createdAt:e.record.at}function gd(e){return e.kind===`tool`&&!e.record.ok}function _d(e){let t=e.reduce((e,t)=>(e[fd(t)]+=1,e),{tool:0,thinking:0,subagent:0});return[t.tool>0?`Tool×${t.tool}`:null,t.thinking>0?`Thinking×${t.thinking}`:null,t.subagent>0?`Subagent×${t.subagent}`:null].filter(Boolean).join(` + `)}function vd(e){let t=e.text.split(/\r?\n/).map(e=>e.trim()).filter(Boolean);if(t.length===0)return(0,X.jsx)(`p`,{children:`...`});let n=[],r=[];function i(){r.length!==0&&(n.push((0,X.jsx)(`ul`,{children:r.map((e,t)=>(0,X.jsx)(`li`,{children:e},`${e}-${t}`))},`ul-${n.length}`)),r=[])}return t.forEach((e,t)=>{let a=e.match(/^[-*]\s+(.+)$/);if(a){r.push(a[1]);return}i(),n.push((0,X.jsx)(`p`,{children:e},`p-${t}`))}),i(),(0,X.jsx)(X.Fragment,{children:n})}function yd(e){return e.tone===`tool`?(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M10.5 2.5 13 5l-2.4 2.4-1.2-1.2-4.8 4.8-1.7.2.2-1.7 4.8-4.8-1.1-1.1L9.2 1.2l1.3 1.3Z`})}):e.tone===`subagent`?(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M3 4.5h10v7H3z`}),(0,X.jsx)(`path`,{d:`M6 4.5V3h4v1.5M5.2 8h.1M10.7 8h.1`})]}):(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M3 4.5h10v7H5.7L3 13.4z`})})}function bd(e){return(0,X.jsxs)(`section`,{className:`jaw-ceo-activity-shell`,"aria-label":`CEO activity`,children:[(0,X.jsx)(`span`,{className:`jaw-ceo-activity-avatar`,"aria-hidden":`true`,children:`CEO`}),(0,X.jsxs)(`details`,{className:`jaw-ceo-activity-group`,children:[(0,X.jsxs)(`summary`,{children:[(0,X.jsx)(`span`,{className:`jaw-ceo-activity-status`,"aria-hidden":`true`}),(0,X.jsx)(`strong`,{children:_d(e.entries)||`Activity`})]}),(0,X.jsx)(`div`,{className:`jaw-ceo-activity-list`,children:e.entries.map(t=>{let n=fd(t);return(0,X.jsxs)(`article`,{className:`jaw-ceo-activity-row tone-${n}${gd(t)?` is-error`:``}`,children:[(0,X.jsx)(`span`,{className:`jaw-ceo-activity-dot`,"aria-hidden":`true`}),(0,X.jsx)(`span`,{className:`jaw-ceo-activity-icon`,children:(0,X.jsx)(yd,{tone:n})}),(0,X.jsx)(`span`,{className:`jaw-ceo-activity-badge`,children:n}),(0,X.jsxs)(`div`,{className:`jaw-ceo-activity-copy`,children:[(0,X.jsx)(`strong`,{children:pd(t)}),(0,X.jsx)(`p`,{children:md(t)}),(0,X.jsx)(`small`,{children:od(hd(t))})]}),t.kind===`result`?(0,X.jsxs)(`div`,{className:`jaw-ceo-activity-actions`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>e.onOpenWorker(t.completion.port,t.completion.messageId),children:`Open`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void e.model.summarize(t.completion),children:`Summary`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void e.model.continueCompletion(t.completion),children:`Continue`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void e.voice.speakCompletion(t.completion),children:`Speak`}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>void e.ceo.ackCompletion(t.completion.completionKey),children:`Ack`})]}):(0,X.jsx)(`span`,{className:`jaw-ceo-trace-chip`,children:`Trace`})]},t.id)})})]})]})}function xd(e){let t=e.entry;return t.kind===`activity-group`?(0,X.jsx)(bd,{entries:t.entries,model:e.model,ceo:e.ceo,voice:e.voice,onOpenWorker:e.onOpenWorker}):t.kind===`chat`?(0,X.jsxs)(`article`,{className:`jaw-ceo-message-row role-${t.role}`,children:[(0,X.jsx)(`span`,{className:`jaw-ceo-message-avatar`,"aria-hidden":`true`,children:t.role===`user`?`You`:t.role===`ceo`?`CEO`:`Log`}),(0,X.jsxs)(`div`,{className:`jaw-ceo-message-bubble`,children:[(0,X.jsxs)(`div`,{className:`jaw-ceo-message-meta`,children:[(0,X.jsx)(`strong`,{children:t.role===`user`?`You`:t.role===`ceo`?`Jaw CEO`:`Tool output`}),(0,X.jsx)(`small`,{children:od(t.at)})]}),(0,X.jsx)(`div`,{className:`jaw-ceo-message-text`,children:(0,X.jsx)(vd,{text:t.text})})]})]}):t.kind===`live`?(0,X.jsxs)(`article`,{className:`jaw-ceo-message-row role-ceo is-live`,"aria-live":`polite`,children:[(0,X.jsx)(`span`,{className:`jaw-ceo-message-avatar is-live`,"aria-hidden":`true`,children:`CEO`}),(0,X.jsxs)(`div`,{className:`jaw-ceo-message-bubble`,children:[(0,X.jsxs)(`div`,{className:`jaw-ceo-message-meta`,children:[(0,X.jsx)(`strong`,{children:`Jaw CEO live`}),(0,X.jsx)(`small`,{children:t.eventType||`realtime`})]}),(0,X.jsx)(`div`,{className:`jaw-ceo-message-text`,children:(0,X.jsx)(vd,{text:t.text})})]})]}):null}function Sd(e){let t=(0,Y.useMemo)(()=>dd(ld({model:e.model,ceo:e.ceo,voice:e.voice})),[e.model,e.ceo.state.transcript,e.ceo.pending,e.ceo.state.watches,e.ceo.audit,e.voice.lastTranscript,e.voice.lastEventType]),n=(0,Y.useCallback)(e=>t[e]?.id||e,[t]),r=(0,Y.useCallback)(e=>ud(t[e]),[t]),i=Uu({count:t.length,getItemKey:n,estimateSize:r});return(0,X.jsxs)(`section`,{className:`jaw-ceo-chat-panel`,"aria-label":`Jaw CEO chat`,children:[(0,X.jsx)(`div`,{ref:i.scrollRef,onScroll:i.onScroll,className:`jaw-ceo-chat-log jaw-ceo-timeline is-virtual`,"aria-live":`polite`,children:t.length===0?(0,X.jsxs)(`div`,{className:`jaw-ceo-empty-state`,children:[(0,X.jsx)(`span`,{className:`jaw-ceo-empty-kicker`,children:`Ready`}),(0,X.jsx)(`strong`,{children:e.selectedPort==null?`Dashboard context`:`Worker :${e.selectedPort} selected`}),(0,X.jsx)(`div`,{className:`jaw-ceo-quick-prompts`,children:cd(e.selectedPort).map(t=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>e.model.setMessage(t.text),children:t.label},t.label))})]}):(0,X.jsx)(`div`,{className:`jaw-ceo-virtual-spacer`,style:{height:`${i.totalSize}px`},children:i.virtualItems.map(n=>{let r=t[n.index];return r?(0,X.jsx)(`div`,{ref:i.measureElement,className:`jaw-ceo-virtual-row`,"data-jaw-ceo-idx":n.index,style:{transform:`translateY(${n.start}px)`},children:(0,X.jsx)(xd,{entry:r,model:e.model,ceo:e.ceo,voice:e.voice,onOpenWorker:e.onOpenWorker})},n.key):null})})}),(0,X.jsxs)(`form`,{className:`jaw-ceo-message-form`,onSubmit:t=>void e.model.submitMessage(t),children:[(0,X.jsx)(`textarea`,{value:e.model.message,rows:3,placeholder:`Send a task to the selected worker or ask about the dashboard.`,onChange:t=>e.model.setMessage(t.target.value)}),(0,X.jsxs)(`div`,{className:`jaw-ceo-form-row`,children:[(0,X.jsxs)(`select`,{value:e.model.responseMode,"aria-label":`Response mode`,onChange:t=>e.model.setResponseMode(t.target.value),children:[(0,X.jsx)(`option`,{value:`text`,children:`Text`}),(0,X.jsx)(`option`,{value:`voice`,children:`Voice`}),(0,X.jsx)(`option`,{value:`both`,children:`Both`}),(0,X.jsx)(`option`,{value:`silent`,children:`Silent`})]}),(0,X.jsx)(`button`,{type:`submit`,disabled:e.ceo.busy||!e.model.message.trim(),children:`Send`})]})]})]})}function Cd(e){return e.model.tab===`settings`?(0,X.jsx)(ad,{}):(0,X.jsx)(Sd,{model:e.model,ceo:e.ceo,voice:e.voice,selectedPort:e.selectedPort,onOpenWorker:e.onOpenWorker})}var wd=[{id:`chat`,label:`Chat`},{id:`settings`,label:`Settings`}];function Td(e){return(0,X.jsx)(`div`,{className:`jaw-ceo-tabs`,role:`tablist`,"aria-label":`Jaw CEO console tabs`,children:wd.map(t=>(0,X.jsx)(`button`,{type:`button`,role:`tab`,className:e.active===t.id?`is-active`:``,"aria-selected":e.active===t.id,onClick:()=>e.onChange(t.id),children:(0,X.jsx)(`span`,{children:t.label})},t.id))})}function Ed(e){return async t=>{t.preventDefault();let n=e.message.trim();if(n){e.setMessage(``);try{await e.ceo.sendText(n,e.responseMode),e.setTab(`chat`)}catch{}}}}function Dd(e){return{summarize:async t=>{await e.ceo.summarizeCompletion(t.completionKey,`short`),await e.ceo.refresh(),e.setTab(`chat`)},continueCompletion:async t=>{let n=e.responseMode===`voice`||e.responseMode===`both`||e.responseMode===`silent`?e.responseMode:`text`;await e.ceo.continueCompletion(t.completionKey,n),await e.ceo.refresh(),e.setTab(`chat`)}}}function Od(e){let[t,n]=(0,Y.useState)(`chat`),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(`text`),s=Dd({ceo:e.ceo,responseMode:a,setTab:n});return{tab:t,setTab:n,message:r,setMessage:i,responseMode:a,setResponseMode:o,submitMessage:Ed({ceo:e.ceo,message:r,responseMode:a,setMessage:i,setTab:n}),...s}}var kd=()=>(0,X.jsxs)(`svg`,{viewBox:`0 0 16 16`,width:`16`,height:`16`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.7`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,X.jsx)(`path`,{d:`M13.2 8a5.2 5.2 0 1 1-1.5-3.7`}),(0,X.jsx)(`path`,{d:`M13.2 3.2v3.2H10`})]}),Ad=()=>(0,X.jsx)(`svg`,{viewBox:`0 0 16 16`,width:`17`,height:`17`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,children:(0,X.jsx)(`path`,{d:`M4 4l8 8M12 4l-8 8`})});function jd(e){return e===`connecting`?`connecting`:e===`active`?`listening`:e===`silent`?`silent`:e===`paused`?`paused`:e===`sleeping`?`sleeping`:e===`disabled`?`disabled`:e===`error`?`error`:`idle`}function Md(e){return e===`active`||e===`connecting`||e===`silent`}function Nd(e){return e===`active`||e===`connecting`||e===`silent`?`live`:e===`paused`||e===`sleeping`?`paused`:e===`disabled`||e===`error`?`issue`:`idle`}function Pd(e){let t=(0,Y.useRef)(null),n=Od({ceo:e.ceo});if((0,Y.useEffect)(()=>{if(!e.open)return;t.current?.focus();function n(t){if(t.key===`Escape`){if(Md(e.voice.status)){t.preventDefault(),e.voice.stop();return}e.onClose()}}return document.addEventListener(`keydown`,n),()=>document.removeEventListener(`keydown`,n)},[e]),!e.open)return null;let r=e.selectedPort==null?`Dashboard`:`Worker :${e.selectedPort}`,i=jd(e.voice.status);return(0,X.jsxs)(`div`,{className:`jaw-ceo-console`,role:`region`,"aria-label":`Jaw CEO console`,"data-surface-owner":`ceo-orchestration-control`,children:[(0,X.jsxs)(`header`,{className:`jaw-ceo-console-header`,children:[(0,X.jsxs)(`div`,{className:`jaw-ceo-console-titlebar`,children:[(0,X.jsx)(`span`,{className:`jaw-ceo-console-mark status-${e.voice.status}`,"aria-hidden":`true`,children:`CEO`}),(0,X.jsxs)(`div`,{className:`jaw-ceo-console-heading`,children:[(0,X.jsx)(`span`,{children:`Dashboard coordinator`}),(0,X.jsx)(`h3`,{children:`Jaw CEO`})]})]}),(0,X.jsxs)(`div`,{className:`jaw-ceo-console-header-actions`,children:[(0,X.jsx)(`button`,{type:`button`,className:`jaw-ceo-icon-btn`,onClick:()=>void e.ceo.refresh(),"aria-label":`Refresh Jaw CEO`,children:(0,X.jsx)(kd,{})}),(0,X.jsx)(`button`,{ref:t,type:`button`,className:`jaw-ceo-console-close`,onClick:e.onClose,"aria-label":`Close Jaw CEO`,children:(0,X.jsx)(Ad,{})})]}),(0,X.jsxs)(`div`,{className:`jaw-ceo-console-summary`,"aria-label":`Jaw CEO status summary`,children:[(0,X.jsx)(`span`,{children:r}),(0,X.jsx)(`span`,{children:`Single session`}),(0,X.jsxs)(`span`,{className:`voice-tone-${Nd(e.voice.status)}`,children:[`Voice `,i]})]})]}),(0,X.jsx)(Td,{active:n.tab,onChange:n.setTab}),(0,X.jsx)(`div`,{className:`jaw-ceo-console-body`,children:(0,X.jsx)(Cd,{model:n,ceo:e.ceo,voice:e.voice,selectedPort:e.selectedPort,onOpenWorker:e.onOpenWorker})}),(0,X.jsxs)(`footer`,{className:`jaw-ceo-console-footer voice-${e.voice.status}`,children:[(0,X.jsxs)(`div`,{className:`jaw-ceo-realtime-status`,children:[(0,X.jsx)(`span`,{className:`jaw-ceo-realtime-dot`,"aria-hidden":`true`}),(0,X.jsxs)(`span`,{children:[`Voice: `,i,e.voice.error?` - ${e.voice.error}`:``]}),e.voice.lastTranscript?(0,X.jsx)(`small`,{children:e.voice.lastTranscript}):e.voice.lastEventType?(0,X.jsx)(`small`,{children:e.voice.lastEventType}):null]}),(0,X.jsx)(`button`,{type:`button`,className:`jaw-ceo-voice-action`,onClick:()=>Md(e.voice.status)?void e.voice.stop():void e.voice.talk(),children:Md(e.voice.status)?`Stop voice`:`Start voice`})]})]})}function Fd({codeMode:e,onChange:t}){return(0,X.jsxs)(`div`,{className:`mode-switch`,role:`tablist`,"aria-label":`Jaw / Code mode`,children:[(0,X.jsx)(`button`,{type:`button`,role:`tab`,className:`mode-switch-tab ${e?``:`active`}`,"aria-selected":!e,onClick:()=>t(!1),children:`Jaw`}),(0,X.jsx)(`button`,{type:`button`,role:`tab`,className:`mode-switch-tab ${e?`active`:``}`,"aria-selected":e,onClick:()=>t(!0),children:`Code`})]})}var Id=(0,Y.lazy)(()=>t(()=>import(`./TerminalPanel-Bu9i-P2f.js`).then(e=>({default:e.TerminalPanel})),__vite__mapDeps([1]))),Ld=(0,Y.lazy)(()=>t(()=>import(`./DiffPanel-DtJuvU5y.js`).then(e=>({default:e.DiffPanel})),__vite__mapDeps([2]))),Rd=(0,Y.lazy)(()=>t(()=>import(`./FolderPanel-C-eQT3Yq.js`).then(e=>({default:e.FolderPanel})),__vite__mapDeps([3]))),zd=(0,Y.lazy)(()=>t(()=>import(`./DocPanel-BM41cYpS.js`).then(e=>({default:e.DocPanel})),__vite__mapDeps([0,4]))),Bd=(0,Y.lazy)(()=>t(()=>import(`./BrowserPanel-SZAUc9T2.js`).then(e=>({default:e.BrowserPanel})),__vite__mapDeps([5]))),Vd=(0,Y.lazy)(()=>t(()=>import(`./DesignPanel-NLNK9wCo.js`).then(e=>({default:e.DesignPanel})),__vite__mapDeps([6]))),Hd=(0,Y.lazy)(()=>t(()=>import(`./CodeCanvas-DWsx6sv5.js`).then(e=>({default:e.CodeCanvas})),[]));function Ud(e){return(0,X.jsx)(`section`,{className:`workspace-surface${e.active?` is-active`:``}`,hidden:!e.active,"aria-hidden":!e.active,children:e.children})}function Wd(e){if(!e.startsWith(`~/`))return e;let t=M()?.getHomePath?.()?.replace(/\/+$/,``);return t?`${t}/${e.slice(2)}`:e}function Gd(e,t,n){let r=(0,X.jsx)(`div`,{style:{padding:`12px`,color:`var(--text-dim)`,fontSize:`12px`},children:`Loading...`});switch(e){case`diff`:{let e=n.diffFilesTab,t=e?.files??{};return(0,X.jsx)(Y.Suspense,{fallback:r,children:(0,X.jsx)(Ld,{selectedInstance:n.selectedInstance,settings:n.dashboardSettingsUi,folderRootPath:t.folderRootPath??n.fallbackFolderRootPath,repoRootPath:t.repoRootPath??null,repoRootMode:t.repoRootMode??`instance`,selectedFilePath:t.activeFilePath??null,onRepoRootChange:(t,r)=>{e&&n.onTabRepoRootChange(e.id,t,r)},onFollowInstanceRepoRoot:t=>n.onFollowInstanceRepoRoot(e?.id??null,t),onPreviewFile:n.onOpenFileGlobal,onGitRefresh:n.onGitRefresh,onSettingsPatch:n.onDashboardSettingsPatch})})}case`files`:{let e=t.files??{},i=e.folderRootPath??n.fallbackFolderRootPath,a=e.repoRootMode??`instance`;return(0,X.jsx)(Bi,{filePane:(0,X.jsx)(Y.Suspense,{fallback:r,children:(0,X.jsx)(zd,{filePath:e.activeFilePath??void 0,onOpenLocalFile:e=>n.onTabPreviewFile(t.id,e)})}),folderPane:(0,X.jsx)(Y.Suspense,{fallback:r,children:(0,X.jsx)(Rd,{selectedFilePath:e.activeFilePath??null,externalRootPath:i,repoRootPath:a===`instance`?e.repoRootPath??null:null,gitRefreshVersion:n.gitRefreshVersion,notesTree:n.notesModel.tree,notesRoot:n.notesModel.notesRoot,onRootChange:e=>n.onTabRootChange(t.id,e),onRepoRootChange:e=>n.onTabRepoRootChange(t.id,e),onGitRefresh:n.onGitRefresh,onPreviewFile:e=>n.onTabPreviewFile(t.id,e),sessionState:n.folderSessions[t.id]??null,onSessionStateChange:e=>n.onFolderSessionChange(t.id,e)})})})}case`browser`:return(0,X.jsx)(Y.Suspense,{fallback:r,children:(0,X.jsx)(Bd,{singlePage:!0,initialUrl:t.browser?.url,isActivePanel:t.id===n.activeTabId,moduleTabId:t.id,selectedInstancePort:n.selectedInstance?.port??null,onInsertCommentIntoPreview:n.onInsertCommentIntoPreview,onPageStateChange:e=>n.onBrowserPageState(t.id,e),onOpenNewWindow:n.onOpenBrowserWindow})});case`design`:return(0,X.jsx)(Y.Suspense,{fallback:r,children:(0,X.jsx)(Vd,{tab:t,primaryProjectDir:n.primaryProjectDir,selectedInstancePort:n.selectedInstance?.port??null,onOpenInBrowser:n.onOpenBrowserWindow})});default:return null}}function Kd(e,t,n,r){let i=(0,X.jsx)(`div`,{style:{padding:`12px`,color:`var(--text-dim)`,fontSize:`12px`},children:`Loading...`});switch(e){case`terminal`:return(0,X.jsx)(Y.Suspense,{fallback:i,children:(0,X.jsx)(Id,{onCollapse:t.onCollapse,onEmptySessions:t.onCloseTab})});case`browser`:return(0,X.jsx)(Y.Suspense,{fallback:i,children:(0,X.jsx)(Bd,{onCollapse:t.onCollapse,selectedInstancePort:n,onInsertCommentIntoPreview:r})});default:return null}}function qd(e){let t=(0,Y.useCallback)(t=>e.onSettingsDirtyChange(`dashboard`,t),[e.onSettingsDirtyChange]),n=e.selectedInstance,r=n?{port:n.port,instanceUrl:n.url}:{},i={ui:e.dashboardSettingsUi,titleSupport:e.titleSupport,onUiPatch:e.onDashboardSettingsPatch},a=e.sidebarMode===`settings`,o=pe(),s=e.dashboardSettingsUi.rightFolderRootPath,l=o.state.rightPanel.tabs.openTabs,u=o.state.rightPanel.tabs.activeTabId,d=l.find(e=>e.id===u)??null,f=d?.kind===`files`?d:l.find(e=>e.kind===`files`)??null,[p,m]=(0,Y.useState)(0),h=(0,Y.useCallback)(()=>m(e=>e+1),[]),[g,_]=(0,Y.useState)({}),[,v]=(0,Y.useState)(null),[y,b]=(0,Y.useState)(null),[x,S]=(0,Y.useState)(`matrix`),C=yu({active:e.sidebarMode===`reminders`}),w=Xn()===`electron`,T=w,[E,D]=(0,Y.useState)(null),O=(0,Y.useRef)(0),k=(0,Y.useRef)(new Map),[ee,A]=(0,Y.useState)(null),j=(0,Y.useRef)(0),[te,ne]=(0,Y.useState)(null);Tu(w,e.selectedInstance?.port??null);let re=T&&o.effectiveRightOpen,ie=f?.files?.folderRootPath||s||e.workingDir||``,ae=(0,Y.useCallback)((t,n)=>{if(e.selectedInstance?.port!==t)return Promise.resolve({ok:!1,error:`selected instance changed before preview insert`});if(!e.previewEnabled)return Promise.resolve({ok:!1,error:`Preview is off. Turn it on before inserting a browser comment.`});if(e.sidebarMode!==`instances`||e.viewMode!==`jaw`||e.activeDetailTab!==`preview`)return Promise.resolve({ok:!1,error:`Open the selected instance Preview tab before inserting a browser comment.`});let r=`browser-comment-${Date.now()}-${++O.current}`;return D({id:r,port:t,text:n}),new Promise(e=>{let t=window.setTimeout(()=>{k.current.delete(r),D(e=>e?.id===r?null:e),e({ok:!1,error:`preview insert timed out; reopen the selected instance Preview tab and try again`})},1400);k.current.set(r,n=>{window.clearTimeout(t),e(n)})})},[e.activeDetailTab,e.previewEnabled,e.selectedInstance?.port,e.sidebarMode,e.viewMode]),oe=(0,Y.useCallback)((e,t)=>{let n=k.current.get(e);n&&(k.current.delete(e),D(t=>t?.id===e?null:t),n(t))},[]),se=(0,Y.useCallback)(()=>{ne(null),j.current+=1,A(`settings-open-${j.current}`)},[]),ce=(0,Y.useCallback)((e,t)=>{A(t=>t===e?null:t),ne(t.ok?null:t.error)},[]),le=!w&&e.jawCeoOpen,M=(0,Y.useCallback)(()=>{e.onJawCeoOpenChange?.(!1)},[e.onJawCeoOpenChange]),ue=le&&e.jawCeo&&e.jawCeoVoice?(0,X.jsx)(Pd,{open:!0,selectedPort:e.jawCeoSelectedPort??null,ceo:e.jawCeo,voice:e.jawCeoVoice,onClose:M,onOpenWorker:e.onJawCeoOpenWorker??(()=>{})}):null,de=T&&o.state.bottomPanel.open,fe=!!(e.notesModel.tagFilter&&e.notesSelectedPath&&e.notesSelectedNote&&!e.notesSelectedNote.tags?.includes(e.notesModel.tagFilter));(0,Y.useEffect)(()=>(an(t=>{let n=e.instances.find(e=>e.port===t)??(e.selectedInstance?.port===t?e.selectedInstance:null);n&&e.onSelectInstance(n)}),()=>{an(null)}),[e.instances,e.selectedInstance,e.onSelectInstance]);let N=o.dispatch,P=(0,Y.useCallback)(e=>{let t=Wd(e.trim());t&&N({type:`OPEN_FILE_IN_FILES_TAB`,path:t})},[N]),me=(0,Y.useCallback)((e,t)=>{let n=Wd(t.trim());n&&o.dispatch({type:`SET_FILES_TAB_FILE`,tabId:e,path:n})},[o]),he=(0,Y.useCallback)((t,n)=>{_(e=>e[t]?{...e,[t]:null}:e),o.dispatch({type:`SET_FILES_TAB_ROOT`,tabId:t,path:n}),e.onDashboardSettingsPatch({rightFolderRootPath:n})},[o,e.onDashboardSettingsPatch]),ge=(0,Y.useCallback)((e,t,n=`instance`)=>{o.dispatch({type:`SET_FILES_TAB_REPO_ROOT`,tabId:e,path:t,mode:n})},[o]),_e=(0,Y.useCallback)((e,t)=>{e&&o.dispatch({type:`SET_FILES_TAB_REPO_ROOT`,tabId:e,path:t,mode:`follow-instance`})},[o]),F=(0,Y.useCallback)((e,t)=>{_(n=>({...n,[e]:t}))},[]),ve=(0,Y.useCallback)((e,t)=>{o.dispatch({type:`SET_BROWSER_TAB_STATE`,tabId:e,url:t.url,title:t.title})},[o]),ye=(0,Y.useCallback)(e=>{o.dispatch({type:`OPEN_BROWSER_MODULE_TAB`,url:e})},[o]),be=f?.id??null,xe=(0,Y.useCallback)(t=>{be&&o.dispatch({type:`SET_FILES_TAB_ROOT`,tabId:be,path:t}),e.onDashboardSettingsPatch({rightFolderRootPath:t})},[o,e.onDashboardSettingsPatch,be]),Se=Mu({onDroppedPaths:(0,Y.useCallback)(t=>{if(v(t),b(Au(t)),t.source===`preview`)return;let n=Ou(t.entries);if(n){o.dispatch({type:`OPEN_FOLDER_IN_FILES_TAB`,path:n.path}),e.onDashboardSettingsPatch({rightFolderRootPath:n.path});return}let r=ku(t.entries);r&&P(r.path)},[o,e.onDashboardSettingsPatch])}),Ce=(0,Y.useCallback)(e=>{Se.resolveDroppedFiles(e,`preview`)},[Se]),I=e.selectedInstance?.projectDirs?.[0]?.trim()||null,L=(0,Y.useCallback)(()=>{I&&(o.dispatch({type:`OPEN_FOLDER_IN_FILES_TAB`,path:I}),e.onDashboardSettingsPatch({rightFolderRootPath:I}))},[o,I,e.onDashboardSettingsPatch]),R=pi({rightPanelOpen:re,rightPanelWidth:o.state.rightPanel.width});return(0,Y.useEffect)(()=>{function e(e){e.detail===`resetSidebarWidth`&&R.reset()}return document.addEventListener(`jaw:shortcut-action`,e),()=>document.removeEventListener(`jaw:shortcut-action`,e)},[R.reset]),(0,X.jsxs)(za,{children:[e.jawCeoVoiceOverlay,(0,X.jsx)(yi,{navigatorLabel:e.viewMode===`code`&&e.sidebarMode===`instances`?`Code sessions`:void 0,sidebarCollapsed:a||e.sidebarCollapsed,sidebarWidth:R.width,onSidebarWidthDelta:R.addDelta,onSidebarWidthEnd:R.persist,onSidebarWidthReset:R.reset,inspectorCollapsed:e.activityDockCollapsed,inspectorHeight:e.activityDockCollapsed?48:e.activityDockHeight,drawerOpen:e.drawerOpen,onCloseDrawer:e.onCloseDrawer,rightPanelOpen:re,rightPanelWidth:o.state.rightPanel.width,rightPanelContent:re?(0,X.jsx)(Fi,{onLoadProjectFolder:L,loadProjectFolderDisabled:!I||(f?.files?.folderRootPath??s)===I,renderPanel:(t,n)=>Gd(t,n,{activeTabId:u,primaryProjectDir:I,fallbackFolderRootPath:s,diffFilesTab:f,gitRefreshVersion:p,onOpenFileGlobal:P,onTabPreviewFile:me,onTabRootChange:he,onTabRepoRootChange:ge,onFollowInstanceRepoRoot:_e,onBrowserPageState:ve,onOpenBrowserWindow:ye,onInsertCommentIntoPreview:ae,onGitRefresh:h,selectedInstance:e.selectedInstance,dashboardSettingsUi:e.dashboardSettingsUi,onDashboardSettingsPatch:e.onDashboardSettingsPatch,notesModel:e.notesModel,folderSessions:g,onFolderSessionChange:F})}):void 0,bottomPanelOpen:de,bottomPanelHeight:o.state.bottomPanel.height,bottomPanelContent:o.state.bottomPanel.tabs.length>0?(0,X.jsx)(zi,{renderTab:(t,n)=>Kd(t,n,e.selectedInstance?.port??null,ae)}):void 0,navigator:(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)($r,{onlineCount:e.onlineCount,collapsed:a||e.sidebarCollapsed,mode:e.sidebarMode,scheduleWorkspaceEnabled:e.scheduleWorkspaceEnabled,remindersWorkspaceEnabled:e.remindersWorkspaceEnabled,onModeChange:e.onSidebarModeChange,onToggleSidebar:e.onToggleSidebar,helpOpen:e.helpOpen,onToggleHelp:e.onToggleHelp}),!a&&(0,X.jsx)(Fd,{codeMode:e.viewMode===`code`,onChange:t=>{e.onViewModeChange(t?`code`:`jaw`),t&&e.sidebarMode!==`instances`&&e.onSidebarModeChange(`instances`)}}),(0,X.jsx)(`div`,{id:`manager-sidebar-list`,className:`manager-sidebar-list`,hidden:a,children:e.sidebarMode===`settings`?null:e.sidebarMode===`notes`?(0,X.jsx)(no,{tree:e.notesModel.filteredTree,loading:e.notesModel.loading,error:e.notesModel.error,notesRoot:e.notesModel.notesRoot,selectedPath:e.notesSelectedPath,dirtyPath:e.notesDirtyPath,highlightedPath:e.notesHighlightedPath,externalFocusPath:e.notesSelectedPath,treeWidth:e.notesTreeWidth,mode:e.notesSidebarMode,searchFocusToken:e.notesSearchFocusToken,tagFilter:e.notesModel.tagFilter,selectedHiddenByFilter:fe,onModeChange:e.onNotesSidebarModeChange,onOpenSearch:e.onOpenNotesSearch,onSelectedPathChange:e.onNotesSelectedPathChange,onRefreshTree:e.notesModel.refresh,onClearTagFilter:()=>e.notesModel.setTagFilter(null)}):e.sidebarMode===`board`?(0,X.jsx)(Ac,{view:e.boardView,onViewChange:e.onBoardViewChange,instances:e.instances,titlesByPort:e.titlesByPort,busyPorts:e.busyPorts}):e.scheduleWorkspaceEnabled&&e.sidebarMode===`schedule`?(0,X.jsx)(Xc,{activeGroup:e.scheduleGroup,onGroupChange:e.onScheduleGroupChange}):e.remindersWorkspaceEnabled&&e.sidebarMode===`reminders`?(0,X.jsx)(Ll,{view:x,onViewChange:S,items:C.items,loading:C.loading,onRefresh:()=>void C.refresh(),onUpdate:(e,t)=>void C.update(e,t)}):e.viewMode===`code`?(0,X.jsx)(`section`,{className:`code-manager-session-navigator`,"aria-label":`Code sessions`,children:(0,X.jsx)(`div`,{id:`code-session-sidebar-host`,className:`code-session-sidebar-host`})}):(0,X.jsx)(Ur,{active:e.selectedInstance,hiddenCount:e.instances.filter(e=>e.hidden).length,collapsed:e.sidebarCollapsed,query:e.query,onQueryChange:e.onQueryChange,onSelectPort:t=>{let n=e.instances.find(e=>e.port===t)??(e.selectedInstance?.port===t?e.selectedInstance:null);n&&e.onSelectInstance(n)},children:e.instanceListContent})})]}),workbench:(0,X.jsxs)(`div`,{className:`workspace-surface-stack`,children:[(0,X.jsx)(Ru,{active:e.sidebarMode===`notes`}),e.lifecycleMessage&&(0,X.jsxs)(`section`,{className:`state lifecycle-state`,role:`status`,children:[(0,X.jsx)(`span`,{children:e.lifecycleMessage}),(0,X.jsx)(`button`,{type:`button`,className:`state-dismiss`,"aria-label":`Dismiss lifecycle message`,onClick:e.onDismissLifecycleMessage,children:`X`})]}),y&&(0,X.jsxs)(`section`,{className:`state lifecycle-state`,role:`status`,children:[(0,X.jsx)(`span`,{children:y}),(0,X.jsx)(`button`,{type:`button`,className:`state-dismiss`,"aria-label":`Dismiss dropped file message`,onClick:()=>b(null),children:`X`})]}),te&&(0,X.jsxs)(`section`,{className:`state lifecycle-state`,role:`status`,children:[(0,X.jsx)(`span`,{children:te}),(0,X.jsx)(`button`,{type:`button`,className:`state-dismiss`,"aria-label":`Dismiss instance settings message`,onClick:()=>ne(null),children:`X`})]}),(0,X.jsxs)(`div`,{className:`workspace-surface-layer`,children:[(0,X.jsx)(Ud,{active:e.sidebarMode===`instances`&&e.viewMode===`jaw`,children:(0,X.jsx)(ni,{mode:e.activeDetailTab,onModeChange:e.onDetailTabChange,header:e.workbenchHeader,modeActions:(0,X.jsxs)(X.Fragment,{children:[e.jawCeoWorkbenchButton,(0,X.jsx)(`button`,{type:`button`,className:`workbench-instance-settings-request`,"aria-label":`Instance settings`,title:`Open this instance's own settings page`,disabled:!e.selectedInstance?.ok,onClick:se,children:`Settings`})]}),active:e.sidebarMode===`instances`&&e.viewMode===`jaw`,overview:e.detailContent(`overview`),preview:(0,X.jsx)(fa,{instance:e.selectedInstance,data:e.data,enabled:e.previewEnabled,active:e.sidebarMode===`instances`&&e.activeDetailTab===`preview`,refreshKey:e.previewRefreshKey,theme:e.previewTheme,...e.onOpenNotesFromPreview?{onOpenNotesFromPreview:e.onOpenNotesFromPreview}:{},onOpenDocFromPreview:P,onPreviewDroppedFiles:Ce,docPanelCapable:T,previewInsertTextRequest:E,onPreviewInsertTextResult:oe,previewSettingsOpenRequest:ee,onPreviewSettingsOpenResult:ce}),logs:e.detailContent(`logs`)})}),e.viewMode===`code`&&e.sidebarMode===`instances`?(0,X.jsx)(Ud,{active:!0,children:(0,X.jsx)(Y.Suspense,{fallback:(0,X.jsx)(`div`,{style:{padding:`24px`,color:`var(--text-dim)`,fontSize:`13px`},children:`Loading Code workspace...`}),children:(0,X.jsx)(Hd,{port:e.port,workingDir:ie,onWorkingDirChange:xe,onOpenLocalFile:P})})}):null,(0,X.jsx)(Ud,{active:e.sidebarMode===`notes`,children:(0,X.jsx)(wc,{active:e.sidebarMode===`notes`,selectedPath:e.notesSelectedPath,selectedNote:e.notesSelectedNote,vaultIndex:e.notesModel.index,viewMode:e.notesViewMode,authoringMode:e.notesAuthoringMode,wordWrap:e.notesWordWrap,vimMode:e.notesVimMode,treeWidth:e.notesTreeWidth,notesGraphSettings:e.notesGraphSettings,tagFilter:e.notesModel.tagFilter,onOpenSidebarSearch:e.onOpenNotesSearch,onSelectedPathChange:e.onNotesSelectedPathChange,onDirtyPathChange:e.onNotesDirtyPathChange,onViewModeChange:e.onNotesViewModeChange,onAuthoringModeChange:e.onNotesAuthoringModeChange,onWordWrapChange:e.onNotesWordWrapChange,onVimModeChange:e.onNotesVimModeChange,onTreeWidthChange:e.onNotesTreeWidthChange,onNotesGraphSettingsChange:e.onNotesGraphSettingsChange,onTagSelect:e.notesModel.setTagFilter,onWikiLinkNavigate:e.onNotesSelectedPathChange})}),(0,X.jsx)(Ud,{active:e.sidebarMode===`settings`,children:e.sidebarMode===`settings`&&(0,X.jsx)(c,{...r,onBack:()=>e.onSidebarModeChange(`instances`),title:`Dashboard settings`,initialId:{display:`manager-display`,activity:`manager-activity`,developer:`manager-developer`,embedding:`manager-embedding`,telegramHub:`telegram-hub`}[e.settingsSection],manager:i,scopes:[`manager`],onDirtyChange:t,...e.onSettingsSaved?{onSaved:e.onSettingsSaved}:{}},n?.port??`manager-only`)}),(0,X.jsx)(Ud,{active:e.sidebarMode===`board`,children:(0,X.jsx)(Jc,{active:e.sidebarMode===`board`,view:e.boardView,onViewChange:e.onBoardViewChange,instances:e.instances,selectedPort:e.selectedInstance?.port??null,titlesByPort:e.titlesByPort,busyPorts:e.busyPorts,onOpenHelpTopic:e.onOpenHelpTopic})}),e.scheduleWorkspaceEnabled?(0,X.jsx)(Ud,{active:e.sidebarMode===`schedule`,children:(0,X.jsx)(ol,{active:e.sidebarMode===`schedule`,activeGroup:e.scheduleGroup,busyPorts:e.busyPorts,onOpenHelpTopic:e.onOpenHelpTopic})}):null,e.remindersWorkspaceEnabled?(0,X.jsx)(Ud,{active:e.sidebarMode===`reminders`,children:(0,X.jsx)(lu,{active:e.sidebarMode===`reminders`,view:x,feed:C,onRefresh:()=>void C.refresh(),onCreate:e=>void C.create(e).catch(()=>{}),onUpdate:(e,t)=>void C.update(e,t),onOpenHelpTopic:e.onOpenHelpTopic})}):null]})]}),inspector:(0,X.jsx)(Br,{collapsed:e.activityDockCollapsed,height:e.activityDockHeight,loading:e.loading,error:e.error,lifecycleMessage:e.lifecycleMessage,selectedInstance:e.selectedInstance,registryMessage:e.registryMessage,events:e.managerEvents,onToggle:e.onToggleActivity,onHeightChange:e.onActivityHeightChange}),sidePanel:!w&&le?ue:void 0,mobileNav:(0,X.jsx)(Wr,{activeTab:e.activeDetailTab,onOpenInstances:e.onOpenDrawer,onSelectTab:e.onSelectTab,onToggleActivity:e.onToggleActivityFromMobile}),drawer:(0,X.jsx)(Hr,{open:e.drawerOpen,profileFilters:e.drawerProfileFilters,onClose:e.onCloseDrawer,children:e.instanceListContent})})]})}var Jd=5e3,Yd=1572864,Xd=24,Zd=`jaw.metricsPanelCollapsed`;async function Qd(){let e=await fetch(`/api/dashboard/electron-metrics`);if(!e.ok)throw Error(`electron-metrics failed: ${e.status}`);return await e.json()}function $d(e){return e>=1048576?`${(e/1024/1024).toFixed(2)} GB`:`${(e/1024).toFixed(1)} MB`}function ef(e){return e.length>Xd?`${e.slice(0,23)}…`:e}function tf(){if(typeof localStorage>`u`)return!1;try{return localStorage.getItem(Zd)===`true`}catch{return!1}}function nf(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(Zd,e?`true`:`false`)}catch{}}function rf(e={}){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(()=>tf());if((0,Y.useEffect)(()=>{nf(a)},[a]),(0,Y.useEffect)(()=>{let e=!1,t=null,r=async()=>{if(typeof document<`u`&&document.hidden){e||(t=setTimeout(r,Jd));return}try{let t=await Qd();if(e)return;t.available?(n(!0),i(t.snapshot)):(n(!1),i(null))}catch{e||n(!1)}e||(t=setTimeout(r,Jd))};return r(),()=>{e=!0,t&&clearTimeout(t)}},[]),t!==!0)return null;if(!r)return(0,X.jsxs)(`div`,{className:`electron-metrics-panel electron-metrics-panel--empty`,"aria-label":`Electron process metrics`,children:[(0,X.jsx)(`div`,{className:`electron-metrics-header`,children:(0,X.jsx)(`span`,{className:`electron-metrics-title`,children:`Desktop metrics`})}),(0,X.jsx)(`div`,{className:`electron-metrics-empty`,children:`awaiting first sample…`})]});let s=[...r.processes].sort((e,t)=>t.rssKb-e.rssKb).slice(0,3),c=r.rssTotalKb>=Yd;return(0,X.jsxs)(`div`,{className:`electron-metrics-panel${c?` electron-metrics-panel--warn`:``}`,"aria-label":`Electron process metrics`,children:[(0,X.jsxs)(`div`,{className:`electron-metrics-header`,children:[(0,X.jsx)(`span`,{className:`electron-metrics-title`,children:`Desktop metrics`}),(0,X.jsx)(`button`,{type:`button`,className:`electron-metrics-toggle`,onClick:()=>o(e=>!e),"aria-expanded":!a,"aria-label":a?`Expand metrics panel`:`Collapse metrics panel`,children:a?`▸`:`▾`})]}),!a&&(0,X.jsxs)(`div`,{className:`electron-metrics-body`,children:[c&&(0,X.jsxs)(`div`,{className:`electron-metrics-warn`,children:[(0,X.jsxs)(`span`,{role:`alert`,children:[`Electron RSS total exceeds `,$d(1572864),`.`]}),e.onUnloadPreview&&(0,X.jsx)(`button`,{type:`button`,className:`electron-metrics-unload-btn`,onClick:()=>e.onUnloadPreview?.(),children:`Unload preview`})]}),(0,X.jsxs)(`div`,{className:`electron-metrics-row`,children:[(0,X.jsx)(`span`,{children:`renderers`}),(0,X.jsx)(`span`,{children:r.rendererCount})]}),(0,X.jsxs)(`div`,{className:`electron-metrics-row`,children:[(0,X.jsx)(`span`,{children:`processes`}),(0,X.jsx)(`span`,{children:r.processes.length})]}),(0,X.jsxs)(`div`,{className:`electron-metrics-row`,children:[(0,X.jsx)(`span`,{children:`RSS total`}),(0,X.jsx)(`span`,{children:$d(r.rssTotalKb)})]}),(0,X.jsx)(`div`,{className:`electron-metrics-divider`,"aria-hidden":`true`}),(0,X.jsx)(`div`,{className:`electron-metrics-subtitle`,children:`top by RSS`}),(0,X.jsx)(`ul`,{className:`electron-metrics-list`,children:s.map(e=>(0,X.jsxs)(`li`,{children:[(0,X.jsx)(`span`,{className:`electron-metrics-proc`,children:ef(e.name?`${e.type} · ${e.name}`:e.type)}),(0,X.jsx)(`span`,{className:`electron-metrics-proc-rss`,children:$d(e.rssKb)})]},e.pid))})]})]})}var af=new Set([`notes`,`instances`]);function of(e){let t=e;return t?.type===`dashboard.invalidate`&&Array.isArray(t.topics)&&t.topics.every(e=>af.has(e))}function sf(){return(0,Y.useEffect)(()=>{function e(e){of(e.data)&&Z({...e.data,source:`iframe`})}return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[]),null}var cf=3e4;function lf(){let e=(0,Y.useRef)(Date.now());return(0,Y.useEffect)(()=>{function t(){document.visibilityState===`visible`&&(Date.now()-e.current<cf||(e.current=Date.now(),Z({topics:[`notes`,`instances`],reason:`visibility:tab-returned`,source:`visibility`})))}return document.addEventListener(`visibilitychange`,t),()=>document.removeEventListener(`visibilitychange`,t)},[]),null}var uf=new Set([`schedule`]),df={BASE_URL:`/dist/`,DEV:!1,MODE:`production`,PROD:!0,SSR:!1}.VITE_CLI_JAW_EXPERIMENTAL_DASHBOARD===`1`;function ff(e){return uf.has(e)}function pf(e){return e===`schedule`&&df||e===`reminders`?e:ff(e)?`instances`:e}function mf(){return M()?.window?.getFullscreenState?.()===!0}function hf(){return(0,Y.useEffect)(()=>{let e=document.documentElement,t=t=>{t?e.dataset.windowFullscreen=`true`:delete e.dataset.windowFullscreen};t(mf());let n=M()?.window?.onFullscreenStateChange?.(t);return()=>{n?.(),delete e.dataset.windowFullscreen}},[]),mf()}function gf(e,t){if(e===`toggleInstanceSettings`){t.toggleInstanceSettings();return}if(F.dispatch(e))return;let n=Gt(e);if(n!=null){let e=document.getElementById(`manager-sidebar-list`);if(!e)return;let t=tn(e)[n];t!=null&&on()?.(t);return}if(e===`focusInstances`){t.handleSidebarModeChange(`instances`),t.setDrawerOpen(!1);return}if(e===`focusActiveSession`){let e=t.selectedInstance?.ok?t.selectedInstance:t.filtered.find(e=>e.ok)||null;e?t.handlePreview(e):t.handleSidebarModeChange(`instances`);return}if(e===`focusNotes`){t.handleSidebarModeChange(`notes`),t.setDrawerOpen(!1);return}if(e===`previousInstance`){t.selectRelativeInstance(-1);return}if(e===`nextInstance`){t.selectRelativeInstance(1);return}if(e===`closeFocusedTab`){let e=document.activeElement;e?.closest(`.browser-webview-stack, .browser-tab-strip`)?document.dispatchEvent(new CustomEvent(`jaw:shortcut-action`,{detail:`closeBrowserTab`})):e?.closest(`.terminal-panel, .xterm`)?document.dispatchEvent(new CustomEvent(`jaw:shortcut-action`,{detail:`closeTerminalTab`})):e?.closest(`.bottom-panel`)?F.dispatch(`closeActiveBottomTab`):e?.closest(`.right-panel`)&&F.dispatch(`toggleRightPanel`);return}if(e===`switchTab1`){t.handleTabChange(`overview`);return}if(e===`switchTab2`){t.handleTabChange(`preview`);return}if(e===`switchTab3`){t.handleTabChange(`logs`);return}if(e===`previousTab`||e===`nextTab`){let n=[`overview`,`preview`,`logs`],r=n.indexOf(t.activeDetailTab),i=e===`nextTab`?1:-1;t.handleTabChange(n[(r+i+n.length)%n.length]);return}if(e===`browserReload`||e===`browserHardReload`||e===`browserFocusUrl`||e===`browserBack`||e===`browserForward`){let n=document.activeElement;if(n?.closest(`.browser-webview-stack, .browser-tab-strip, .browser-panel`)){document.dispatchEvent(new CustomEvent(`jaw:shortcut-action`,{detail:e}));return}(e===`browserReload`||e===`browserHardReload`)&&(n?.closest(`.preview-panel`)?t.setPreviewRefreshKey(e=>e+1):e===`browserReload`?M()?.reloadWindow?.():M()?.hardReloadWindow?.());return}if(e===`terminalClear`||e===`terminalNewTab`){document.activeElement?.closest(`.terminal-panel, .xterm`)?document.dispatchEvent(new CustomEvent(`jaw:shortcut-action`,{detail:e})):e===`terminalNewTab`&&F.dispatch(`newTerminalSession`);return}if(e===`toggleLeftSidebar`){t.handleSidebarToggle();return}if(e===`resetSidebarWidth`){document.dispatchEvent(new CustomEvent(`jaw:shortcut-action`,{detail:`resetSidebarWidth`}));return}}var _f=new Set([`toggleInstanceSettings`,`toggleLeftSidebar`,`toggleRightPanel`,`resetSidebarWidth`]);function vf(e,t){return n=>{if(n.defaultPrevented)return;let r=n.target;if(r instanceof Element&&r.closest(`[data-keybinding-capture]`))return;let i=xe(n,e());i&&_f.has(i)&&(n.preventDefault(),n.stopPropagation(),t(i))}}function yf(e){return hf(),(0,Y.useEffect)(()=>{if(!e.view.dashboardShortcutsEnabled)return;let t=vf(()=>e.view.dashboardShortcutKeymap,e.onShortcutAction);return window.addEventListener(`keydown`,t,!0),()=>window.removeEventListener(`keydown`,t,!0)},[e.view.dashboardShortcutsEnabled,e.view.dashboardShortcutKeymap,e.onShortcutAction]),(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(sf,{}),(0,X.jsx)(lf,{}),(0,X.jsx)(_e,{initialPanelState:e.panelInitialState,onStateChange:e.onPanelStateChange,children:(0,X.jsx)(gr,{sidebarCollapsed:e.view.sidebarCollapsed,commandBar:(0,X.jsx)(ir,{query:e.query,loading:e.loading,onQueryChange:e.setQuery,onRefresh:()=>void e.load(),onOpenDrawer:()=>e.view.setDrawerOpen(!0),theme:e.theme.theme,onThemeChange:e.theme.setTheme,onOpenPalette:e.palette.toggle}),workspace:(0,X.jsx)(qd,{sidebarCollapsed:e.view.sidebarCollapsed,activityDockCollapsed:e.view.activityDockCollapsed,activityDockHeight:e.view.activityDockHeight,drawerOpen:e.view.drawerOpen,onCloseDrawer:()=>e.view.setDrawerOpen(!1),onlineCount:e.summary.online||0,sidebarMode:e.view.sidebarMode,scheduleWorkspaceEnabled:df,remindersWorkspaceEnabled:!0,onSidebarModeChange:e.handleSidebarModeChange,onToggleSidebar:e.handleSidebarToggle,helpOpen:e.helpOpen,onToggleHelp:()=>{e.setHelpTopic(null),e.setHelpOpen(e=>!e)},onOpenHelpTopic:e.onOpenHelpTopic,settingsSection:e.settingsSection,locale:e.view.locale,onSettingsSectionChange:e.setDashboardSettingsSection,notesModel:e.notesModel,notesSelectedPath:e.view.notesSelectedPath,notesSelectedNote:e.notesSelectedNote,notesDirtyPath:e.notesDirtyPath,notesHighlightedPath:e.notesHighlightedPath,notesTreeWidth:e.view.notesTreeWidth,notesGraphSettings:e.view.notesGraphSettings,notesSidebarMode:e.notesSidebarMode,notesSearchFocusToken:e.notesSearchFocusToken,notesViewMode:e.view.notesViewMode,notesAuthoringMode:e.view.notesAuthoringMode,notesWordWrap:e.view.notesWordWrap,notesVimMode:e.view.notesVimMode,onNotesSidebarModeChange:e.setNotesSidebarMode,onOpenNotesSearch:e.openNotesSidebarSearch,onNotesSelectedPathChange:e.handleNotesSelectedPathChange,onNotesDirtyPathChange:e.setNotesDirtyPath,onNotesViewModeChange:e.handleNotesViewModeChange,onNotesAuthoringModeChange:e.handleNotesAuthoringModeChange,onNotesWordWrapChange:e.handleNotesWordWrapChange,onNotesVimModeChange:e.handleNotesVimModeChange,onNotesTreeWidthChange:e.handleNotesTreeWidthChange,onNotesGraphSettingsChange:e.handleNotesGraphSettingsChange,boardView:e.boardView,onBoardViewChange:e.setBoardView,scheduleGroup:e.scheduleGroup,onScheduleGroupChange:e.setScheduleGroup,instances:e.instances,selectedInstance:e.selectedInstance,data:e.data,titlesByPort:e.titlesByPort,busyPorts:e.busyPorts,activeDetailTab:e.view.activeDetailTab,onDetailTabChange:e.handleTabChange,workbenchHeader:(0,X.jsx)(ur,{instance:e.selectedInstance,previewEnabled:e.previewEnabled,onPreviewEnabledChange:e.setPreviewEnabled,onPreviewRefresh:e.onRefreshPreview,onOpenHelpTopic:e.onOpenHelpTopic,onPickProject:e.onPickProject,projectPickBusy:e.projectPickBusy}),onSettingsDirtyChange:e.onSettingsDirtyChange,detailContent:e.detailContent,previewEnabled:e.previewEnabled,previewRefreshKey:e.previewRefreshKey,previewTheme:e.theme.resolved,onOpenNotesFromPreview:e.openNotesFromPreview,lifecycleMessage:e.lifecycleMessage,onDismissLifecycleMessage:e.onDismissLifecycleMessage,instanceListContent:e.instanceListContent,loading:e.loading,jawCeoWorkbenchButton:e.jawCeoWorkbenchButton,jawCeoVoiceOverlay:e.jawCeoVoiceOverlay,jawCeo:e.jawCeo,jawCeoVoice:e.jawCeoVoice,jawCeoOpen:e.jawCeoOpen,jawCeoSelectedPort:e.jawCeoSelectedPort,onJawCeoOpenChange:e.onJawCeoOpenChange,onJawCeoOpenWorker:e.onJawCeoOpenWorker,error:e.error,registryMessage:e.registryMessage,managerEvents:e.activityEvents,onToggleActivity:e.handleActivityToggle,onActivityHeightChange:e.handleActivityHeight,onOpenDrawer:()=>e.view.setDrawerOpen(!0),onSelectTab:e.handleTabChange,onToggleActivityFromMobile:e.activityUnreadOpenAndMarkSeen,drawerProfileFilters:e.drawerProfileFilters,dashboardSettingsUi:e.dashboardSettingsUi,titleSupport:e.titleSupport,onDashboardSettingsPatch:e.handleDashboardSettingsPatch,viewMode:e.view.viewMode,onViewModeChange:e.view.setViewMode,port:Number(window.location.port)||3457,workingDir:e.view.rightFolderRootPath||``,query:e.query,onQueryChange:e.setQuery,onSelectInstance:e.handleSelectInstance}),activityHeight:e.view.activityDockCollapsed?48:e.view.activityDockHeight})}),(0,X.jsx)(hr,{open:e.palette.open,onClose:e.palette.close,instances:e.instances,getLabel:or,onSelectInstance:e.handleSelectInstance,theme:e.theme.theme,onCycleTheme:e.cycleTheme,onRefresh:()=>void e.load(),onToggleHidden:()=>{let t=!e.showHidden;e.setShowHidden(t),e.load(t)},showHidden:e.showHidden,onOpenSelected:e.openSelectedInBrowser,selectedInstance:e.selectedInstance}),(0,X.jsx)(rf,{onUnloadPreview:()=>e.setPreviewEnabled(!1)}),(0,X.jsx)(Or,{open:e.helpOpen,topic:e.helpTopic??e.view.sidebarMode,onClose:()=>e.setHelpOpen(!1)}),e.autoUnloadNotice&&(0,X.jsxs)(`div`,{className:`preview-auto-unload-notice`,role:`status`,children:[`Preview was unloaded after 5 minutes of inactivity. Toggle the preview switch to re-enable.`,(0,X.jsx)(`button`,{type:`button`,className:`preview-auto-unload-dismiss`,"aria-label":`Dismiss preview auto-unload notice`,onClick:()=>e.setAutoUnloadNotice(!1),children:`x`})]})]})}function bf(e){if(!(e instanceof HTMLElement))return!1;if(e.isContentEditable)return!0;let t=e.tagName.toLowerCase();return t===`input`||t===`textarea`||t===`select`||!!e.closest(`[contenteditable="true"], .cm-editor, .ProseMirror, [data-milkdown-root]`)}var xf=`jaw.previewEnabled`;function Sf(){if(typeof localStorage>`u`)return!1;try{let e=localStorage.getItem(xf);return e!==null&&e===`true`}catch{return!1}}function Cf(e){if(!(typeof localStorage>`u`))try{localStorage.setItem(xf,e?`true`:`false`)}catch{}}var wf=3e5;function Tf(e){let{onUnload:t,idleMs:n,doc:r,setTimeout:i,clearTimeout:a,now:o}=e,s=null,c=null,l=!1,u=()=>{l||(l=!0,t())},d=()=>{c=o(),s=i(()=>{s=null,u()},n)},f=()=>{s!==null&&(a(s),s=null)},p=()=>{if(l)return;if(r.hidden){c===null&&d();return}let e=c===null?0:o()-c;f(),c=null,e>=n&&u()};return r.hidden&&d(),r.addEventListener(`visibilitychange`,p),r.addEventListener(`resume`,p),()=>{r.removeEventListener(`visibilitychange`,p),r.removeEventListener(`resume`,p),f()}}function Ef(e){let{enabled:t,onUnload:n,idleMs:r=wf}=e,i=(0,Y.useRef)(n);i.current=n,(0,Y.useEffect)(()=>{if(t&&!(typeof document>`u`))return Tf({onUnload:()=>i.current(),idleMs:r,doc:document,setTimeout:(e,t)=>setTimeout(e,t),clearTimeout:e=>clearTimeout(e),now:()=>Date.now()})},[t,r])}function Df(e){let t={ready:0,legacy:0,offline:0,byPort:e};for(let n of Object.values(e))t[n]+=1;return t}function Of(e,t){return{selectedPort:e.selectedPort,selectedTab:e.activeDetailTab,instanceSettingsOpen:!1,sidebarCollapsed:e.sidebarCollapsed,activityDockCollapsed:e.activityDockCollapsed,activityDockHeight:e.activityDockHeight,activitySeenAt:null,activitySeenByPort:{},uiTheme:t,locale:e.locale,sidebarMode:e.sidebarMode,notesSelectedPath:e.notesSelectedPath,notesViewMode:e.notesViewMode,notesAuthoringMode:e.notesAuthoringMode,notesWordWrap:e.notesWordWrap,notesVimMode:e.notesVimMode,notesTreeWidth:e.notesTreeWidth,notesGraphSettings:e.notesGraphSettings??gt(_t),showLatestActivityTitles:e.showLatestActivityTitles,showInlineLabelEditor:e.showInlineLabelEditor,showSidebarRuntimeLine:e.showSidebarRuntimeLine,showSelectedRowActions:e.showSelectedRowActions,dashboardShortcutsEnabled:e.dashboardShortcutsEnabled,dashboardShortcutKeymap:e.dashboardShortcutKeymap,diffRootPolicy:e.diffRootPolicy,diffPinnedRootByPort:e.diffPinnedRootByPort,diffRecentRepoRoots:e.diffRecentRepoRoots,diffDefaultMode:e.diffDefaultMode,diffBaseRef:e.diffBaseRef,diffIncludeUntracked:e.diffIncludeUntracked,rightFolderRootPath:e.rightFolderRootPath}}function kf(e,t,n){let r=(0,Y.useRef)(t);r.current=t;let i=(0,Y.useRef)(void 0);(0,Y.useEffect)(()=>Wa(e,()=>{clearTimeout(i.current),i.current=setTimeout(()=>r.current(),100)},n),[e,n])}var Af=5e3;function jf(e){let t=(0,Y.useRef)(null);(0,Y.useEffect)(()=>{if(!e)return;let n=!1;async function r(){try{let e=await C();if(n)return;t.current!==null&&e!==t.current&&Z({topics:[`notes`],reason:`notes:external-change`,source:`visibility`,sourceId:`external-sync`}),t.current=e}catch{}}r();let i=setInterval(()=>{typeof document<`u`&&document.hidden||r()},Af);return()=>{n=!0,clearInterval(i)}},[e])}function Mf(e){for(let t of e){if(t.kind===`file`)return t.path;let e=Mf(t.children||[]);if(e)return e}return null}function Nf(e,t){for(let n of e)if(n.kind===`file`&&n.path===t||Nf(n.children||[],t))return!0;return!1}function Pf(e,t){let n=[];for(let r of e){if(r.kind===`file`){t.has(r.path)&&n.push(r);continue}let e=Pf(r.children||[],t);e.length>0&&n.push({...r,children:e})}return n}function Ff(e){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(!1),[s,c]=(0,Y.useState)(null),[l,u]=(0,Y.useState)(null),[d,f]=(0,Y.useState)(null),p=(0,Y.useRef)(0),m=(0,Y.useRef)(e.selectedPath),h=(0,Y.useRef)(e.onSelectedPathChange);m.current=e.selectedPath,h.current=e.onSelectedPathChange,jf(e.active),(0,Y.useEffect)(()=>{e.active&&!l&&O().then(e=>u(e.root)).catch(()=>{})},[e.active,l]);let g=(0,Y.useCallback)(async(e=m.current)=>{let t=p.current+1;p.current=t,o(!0),c(null);try{let[r,a]=await Promise.all([w(),A()]);if(t!==p.current)return;n(r),i(a);let o=e&&Nf(r,e)?e:Mf(r);o!==m.current&&h.current(o)}catch(e){t===p.current&&c(e.message)}finally{t===p.current&&o(!1)}},[]);return kf(`notes`,()=>{e.active&&g()},`notes-sidebar`),(0,Y.useEffect)(()=>{e.active&&g()},[e.active,g]),{tree:t,filteredTree:(0,Y.useMemo)(()=>{if(!d||!r)return t;let e=new Set;for(let t of r.notes)t.tags&&t.tags.includes(d)&&e.add(t.path);return e.size===0?[]:Pf(t,e)},[d,t,r]),index:r,loading:a,error:s,notesRoot:l,tagFilter:d,setTagFilter:f,refresh:g}}var If=new Set([`instances`,`board`,`schedule`,`reminders`,`notes`,`settings`]);function Lf(e){let t=new URLSearchParams(e).get(`sidebar`);return If.has(t)?t:null}function Rf(e){return new URLSearchParams(e).get(`tray`)===`1`}var zf=/^([01]\d|2[0-3]):([0-5]\d)$/;function Bf(e){return String(e).padStart(2,`0`)}function Vf(e){let t=new Date(e);return t.setHours(t.getHours()+1,0,0,0),t.getDate()===e.getDate()?`${Bf(t.getHours())}:00`:`23:59`}function Hf(e,t){let n=zf.exec(t??``);if(!n)return null;let r=new Date(e);return r.setHours(Number(n[1]),Number(n[2]),0,0),r}function Uf(e,t){let n=e.title.trim();if(!n)return{ok:!1,error:`Enter a reminder title.`};let r={title:n,status:`open`,priority:e.mode===`important`||e.mode===`important-urgent`?`high`:`normal`};if(e.mode!==`important-urgent`&&e.mode!==`urgent`)return{ok:!0,input:r};let i=Hf(Wf(t),e.timeValue);if(!i)return{ok:!1,error:`Pick a valid time.`};let a=i.toISOString();return{ok:!0,input:{...r,dueAt:a,remindAt:a}}}function Wf(e){return new Date(e.getTime())}var Gf={overdue:`Overdue`,priority:`Priority`,today:`Today`},Kf=[{id:`important-urgent`,label:`ImpUrg`},{id:`important`,label:`Imp`},{id:`urgent`,label:`Urg`},{id:`later`,label:`Later`}];function qf(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString([],{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`})}function Jf(e){let t=[e.priority],n=qf(e.dueAt),r=qf(e.remindAt);return n&&t.push(`due ${n}`),r&&t.push(`remind ${r}`),t.join(` / `)}function Yf(){let e=M()?.trayReminders;if(e?.openDashboard){e.openDashboard();return}window.location.assign(`/?sidebar=reminders`)}function Xf(e){let t=new Date;return e===`later-today`?(t.setHours(t.getHours()+3,0,0,0),t.toISOString()):e===`tomorrow`?(t.setDate(t.getDate()+1),t.setHours(9,0,0,0),t.toISOString()):e===`next-week`?(t.setDate(t.getDate()+7),t.setHours(9,0,0,0),t.toISOString()):null}function Zf(e){return(0,X.jsxs)(`li`,{className:`tray-reminders-row`,"data-section":e.section,"data-priority":e.item.priority,children:[(0,X.jsxs)(`span`,{className:`tray-reminders-row-main`,children:[(0,X.jsx)(`b`,{children:e.item.title}),(0,X.jsx)(`small`,{children:Jf(e.item)})]}),(0,X.jsxs)(`span`,{className:`tray-reminders-row-actions`,children:[e.item.priority===`high`?(0,X.jsx)(`span`,{className:`tray-reminders-priority-pill`,children:`High`}):null,(0,X.jsx)(`button`,{type:`button`,"aria-label":`Mark done`,onClick:()=>e.onMarkDone(e.item.id),disabled:e.busy,children:`Done`}),(0,X.jsxs)(`select`,{"aria-label":`Snooze reminder`,value:``,disabled:e.busy,onChange:t=>{let n=Xf(t.target.value);t.currentTarget.value=``,n&&e.onSnooze(e.item.id,n)},children:[(0,X.jsx)(`option`,{value:``,disabled:!0,children:`Snooze`}),(0,X.jsx)(`option`,{value:`later-today`,children:`Later today`}),(0,X.jsx)(`option`,{value:`tomorrow`,children:`Tomorrow`}),(0,X.jsx)(`option`,{value:`next-week`,children:`Next week`})]})]})]})}function Qf(e){return(0,X.jsxs)(`section`,{className:`tray-reminders-section`,"data-section":e.id,children:[(0,X.jsxs)(`header`,{children:[(0,X.jsx)(`h2`,{children:Gf[e.id]}),(0,X.jsx)(`span`,{children:e.items.length})]}),(0,X.jsxs)(`ol`,{children:[e.items.map(t=>(0,X.jsx)(Zf,{item:t,section:e.id,busy:e.busy,onMarkDone:e.onMarkDone,onSnooze:e.onSnooze},t.id)),e.items.length===0?(0,X.jsx)(`li`,{className:`tray-reminders-empty-row`,children:`No reminders`}):null]})]})}function $f(e){let t=(0,Y.useMemo)(()=>new Date,[]),n=(0,Y.useRef)(null),[r,i]=(0,Y.useState)(``),[a,o]=(0,Y.useState)(`later`),[s,c]=(0,Y.useState)(Vf(t)),[l,u]=(0,Y.useState)(null),d={title:r,mode:a,timeValue:s},f=Uf(d,new Date).ok&&!e.busy,p=async()=>{let t=Uf(d,new Date);if(!t.ok){u(t.error);return}u(null);try{await e.onCreate(t.input),i(``),n.current?.focus()}catch(e){u(e.message)}};return(0,X.jsxs)(`section`,{className:`tray-reminders-composer`,"aria-label":`Add reminder`,children:[(0,X.jsx)(`div`,{className:`tray-reminders-composer-modes`,role:`group`,"aria-label":`Quick add mode`,children:Kf.map(e=>(0,X.jsx)(`button`,{type:`button`,"aria-pressed":a===e.id,onClick:()=>{o(e.id),u(null)},children:e.label},e.id))}),(0,X.jsxs)(`form`,{className:`tray-reminders-composer-form`,onSubmit:e=>{e.preventDefault(),p()},children:[(0,X.jsx)(`input`,{ref:n,"aria-label":`Reminder title`,placeholder:`Add reminder...`,value:r,onChange:e=>{i(e.target.value),u(null)},onKeyDown:e=>{e.key===`Escape`&&(r||l)&&(e.preventDefault(),i(``),u(null))}}),(0,X.jsx)(`button`,{type:`submit`,disabled:!f,children:`Add`})]}),(0,X.jsx)(`div`,{className:`tray-reminders-composer-date-row`,"data-mode":a,children:a===`important-urgent`||a===`urgent`?(0,X.jsxs)(`label`,{children:[(0,X.jsx)(`span`,{children:`Due`}),(0,X.jsx)(`input`,{"aria-label":`Urgent reminder time`,type:`time`,value:s,onChange:e=>c(e.target.value)})]}):(0,X.jsx)(`span`,{"aria-hidden":`true`})}),l?(0,X.jsx)(`p`,{className:`tray-reminders-composer-error`,children:l}):null]})}function ep(){let e=yu({active:!0,pollWhileActiveMs:3e4}),t=(0,Y.useMemo)(()=>new Date,[e.items]),n=(0,Y.useMemo)(()=>El(e.items,t),[e.items,t]),r=Math.max(0,n.badgeCount-n.overdue.length),i=n.overdue.length>0||n.priority.length>0||n.today.length>0,a=t=>{e.markDone(t).then(()=>e.refresh())},o=(t,n)=>{e.snooze(t,n).then(()=>e.refresh())};return(0,X.jsxs)(`main`,{className:`tray-reminders-app`,"aria-label":`Tray reminders`,children:[(0,X.jsxs)(`header`,{className:`tray-reminders-header`,children:[(0,X.jsxs)(`span`,{children:[(0,X.jsx)(`b`,{children:`Reminders`}),(0,X.jsxs)(`small`,{children:[`overdue `,n.overdue.length,` / today `,r]})]}),(0,X.jsx)(`button`,{type:`button`,className:`tray-reminders-menu-button`,"aria-label":`Open tray menu`,onClick:()=>M()?.trayReminders?.popUpMenu(),children:`...`})]}),e.error?(0,X.jsx)(`p`,{className:`tray-reminders-status`,"data-state":`error`,children:e.error}):null,e.loading&&e.items.length===0?(0,X.jsx)(`p`,{className:`tray-reminders-status`,children:`Loading reminders`}):null,!e.loading&&!e.error&&!i?(0,X.jsx)(`p`,{className:`tray-reminders-empty`,children:`No urgent reminders`}):null,(0,X.jsxs)(`div`,{className:`tray-reminders-sections`,children:[(0,X.jsx)(Qf,{id:`overdue`,items:n.overdue,busy:e.loading,onMarkDone:a,onSnooze:o}),(0,X.jsx)(Qf,{id:`priority`,items:n.priority,busy:e.loading,onMarkDone:a,onSnooze:o}),(0,X.jsx)(Qf,{id:`today`,items:n.today,busy:e.loading,onMarkDone:a,onSnooze:o})]}),(0,X.jsx)($f,{busy:e.loading,onCreate:t=>e.create(t).then(()=>e.refresh())}),(0,X.jsxs)(`footer`,{className:`tray-reminders-footer`,children:[(0,X.jsxs)(`span`,{children:[n.upcomingCount,` upcoming`]}),(0,X.jsx)(`button`,{type:`button`,onClick:Yf,children:`Open Dashboard`})]})]})}function tp(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(null),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(null),c=(0,Y.useCallback)(e=>(t(e.registry),r(e.status),s(e.status.error),e),[]);return{registry:e,status:n,saving:i,error:o,apply:c,refresh:(0,Y.useCallback)(async()=>{try{return c(await ie())}catch(e){throw s(e.message),e}},[c]),save:(0,Y.useCallback)(async e=>{a(!0);try{return c(await se(e))}catch(e){return s(e.message),null}finally{a(!1)}},[c])}}function np(){let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(`overview`),[i,a]=(0,Y.useState)(!1),[o,s]=(0,Y.useState)(!1),[c,l]=(0,Y.useState)(!1),[u,d]=(0,Y.useState)(150),[f,p]=(0,Y.useState)(`instances`),[m,h]=(0,Y.useState)(`jaw`),[g,_]=(0,Y.useState)(null),[v,y]=(0,Y.useState)(`raw`),[b,x]=(0,Y.useState)(`plain`),[S,C]=(0,Y.useState)(!0),[w,T]=(0,Y.useState)(!1),[E,D]=(0,Y.useState)(280),[O,k]=(0,Y.useState)(void 0),[ee,A]=(0,Y.useState)(!0),[j,te]=(0,Y.useState)(!0),[ne,re]=(0,Y.useState)(!0),[ie,ae]=(0,Y.useState)(!0),[oe,se]=(0,Y.useState)(!0),[ce,le]=(0,Y.useState)({...Se}),[M,ue]=(0,Y.useState)(`project-first`),[de,fe]=(0,Y.useState)({}),[pe,N]=(0,Y.useState)([]),[P,me]=(0,Y.useState)(`unstaged`),[he,ge]=(0,Y.useState)(`HEAD`),[_e,F]=(0,Y.useState)(!0),[ve,ye]=(0,Y.useState)(null),[xe,Ce]=(0,Y.useState)(`ko`);function I(e){le(be(e))}return{selectedPort:e,setSelectedPort:t,activeDetailTab:n,setActiveDetailTab:r,drawerOpen:i,setDrawerOpen:a,sidebarCollapsed:o,setSidebarCollapsed:s,activityDockCollapsed:c,setActivityDockCollapsed:l,activityDockHeight:u,setActivityDockHeight:d,sidebarMode:f,setSidebarMode:p,viewMode:m,setViewMode:h,notesSelectedPath:g,setNotesSelectedPath:_,notesViewMode:v,setNotesViewMode:y,notesAuthoringMode:b,setNotesAuthoringMode:x,notesWordWrap:S,setNotesWordWrap:C,notesVimMode:w,setNotesVimMode:T,notesTreeWidth:E,setNotesTreeWidth:D,notesGraphSettings:O,setNotesGraphSettings:k,showLatestActivityTitles:ee,setShowLatestActivityTitles:A,showInlineLabelEditor:j,setShowInlineLabelEditor:te,showSidebarRuntimeLine:ne,setShowSidebarRuntimeLine:re,showSelectedRowActions:ie,setShowSelectedRowActions:ae,dashboardShortcutsEnabled:oe,setDashboardShortcutsEnabled:se,dashboardShortcutKeymap:ce,setDashboardShortcutKeymap:I,diffRootPolicy:M,setDiffRootPolicy:ue,diffPinnedRootByPort:de,setDiffPinnedRootByPort:fe,diffRecentRepoRoots:pe,setDiffRecentRepoRoots:N,diffDefaultMode:P,setDiffDefaultMode:me,diffBaseRef:he,setDiffBaseRef:ge,diffIncludeUntracked:_e,setDiffIncludeUntracked:F,rightFolderRootPath:ve,setRightFolderRootPath:ye,locale:xe,setLocale:Ce}}function rp(e){let t=e.selectedTab===`settings`||e.instanceSettingsOpen===!0;return{selectedTab:e.selectedTab===`settings`?`overview`:e.selectedTab,sidebarMode:t?`settings`:e.sidebarMode}}function ip(e){let{view:t,selectedPort:n}=e;function r(){return!e.settingsDirty||(e.confirmDiscard??(()=>window.confirm(`Discard unsaved Settings changes?`)))()}function i(r){let i=r.selectedPort!==void 0&&r.selectedPort!==n,a=t.sidebarMode===`settings`&&(r.sidebarMode??t.sidebarMode)!==`settings`;return i||a?e.dashboardSettingsDirty&&!(e.confirmDiscard??(()=>window.confirm(`Discard unsaved Settings changes?`)))()?!1:(e.clearDirty(`dashboard`),!0):!0}function a(n){let r=n?`settings`:`instances`;t.sidebarMode!==r&&i({sidebarMode:r})&&(n&&(t.setViewMode(`jaw`),t.setDrawerOpen(!1)),t.setSidebarMode(r),e.saveUi({sidebarMode:r,selectedTab:t.activeDetailTab===`settings`?`overview`:t.activeDetailTab}))}return{canLeaveDirtySettings:r,guardSettingsTransition:i,setDashboardSettingsOpen:a}}function ap(e,t,n){return{...e,[t]:n}}function op(){let[e,t]=(0,Y.useState)({dashboard:!1}),n=(0,Y.useCallback)((e,n)=>{t(t=>ap(t,e,n))},[]),r=(0,Y.useCallback)(e=>{t({dashboard:e})},[]);return{settingsDirty:e.dashboard,dashboardSettingsDirty:e.dashboard,setSettingsDirty:r,onSettingsDirtyChange:n}}function sp(e){return e.kind===`instance-message`&&e.role===`assistant`}function cp(e){if(e.kind===`instance-message`)return[e.kind,e.port,e.messageId].join(`|`);let t=`port`in e?String(e.port):``,n=`message`in e?e.message:`reason`in e&&typeof e.reason==`string`?e.reason:``;return[e.kind,t,e.at,n].join(`|`)}function lp(e){return e.reduce((e,t)=>e?Date.parse(t.at)>Date.parse(e)?t.at:e:t.at,null)}function up(e,t){return lp(e.filter(e=>`port`in e&&e.port===t))}function dp(e,t,n={},r=null){let i=new Set,a={};for(let t of e){if(!(`port`in t)||r!=null&&t.port===r||!sp(t))continue;let e=n[t.port]||null;if(e&&Date.parse(t.at)<=Date.parse(e))continue;let o=cp(t);i.has(o)||(i.add(o),a[t.port]=(a[t.port]||0)+1)}return a}function fp(e){let[t,n]=(0,Y.useState)(null),[r,i]=(0,Y.useState)({}),a=(0,Y.useMemo)(()=>dp(e.events,t,r,e.activePreviewPort),[e.events,t,r,e.activePreviewPort]);function o(e,t){n(e),i(Object.fromEntries(Object.entries(t).map(([e,t])=>[Number(e),t])))}function s(t){let n=up(e.events,t);if(!n)return;let a=r[t]||null;if(a&&Date.parse(n)<=Date.parse(a))return;let o={...r,[t]:n};i(o),e.saveUi({activitySeenByPort:Object.fromEntries(Object.entries(o).map(([e,t])=>[String(e),t]))})}function c(){let t=lp(e.events),a={...r};for(let t of e.events){if(!(`port`in t))continue;let e=a[t.port];(!e||Date.parse(t.at)>Date.parse(e))&&(a[t.port]=t.at)}n(t),i(a),e.setActivityDockCollapsed(!1),e.saveUi({activityDockCollapsed:!1,activitySeenAt:t,activitySeenByPort:Object.fromEntries(Object.entries(a).map(([e,t])=>[String(e),t]))})}function l(){e.setActivityDockCollapsed(!0),e.saveUi({activityDockCollapsed:!0,activitySeenAt:t,activitySeenByPort:Object.fromEntries(Object.entries(r).map(([e,t])=>[String(e),t]))})}return{unreadByPort:a,hydrateSeenAt:o,markPortSeen:s,openAndMarkSeen:c,closeAndPersistSeen:l}}var pp=[`auto`,`dark`,`light`];function mp(e){return typeof e==`string`&&pp.includes(e)}function hp(){if(typeof document>`u`)return`auto`;let e=document.documentElement.getAttribute(`data-theme`);return mp(e)?e:`auto`}var gp=`jaw.uiTheme`;function _p(e){if(!(typeof document>`u`)){document.documentElement.setAttribute(`data-theme`,e);try{typeof localStorage<`u`&&localStorage.setItem(gp,e)}catch{}}}function vp(e){let[t,n]=(0,Y.useState)(hp),[r,i]=(0,Y.useState)(()=>yp(t));return(0,Y.useEffect)(()=>{_p(t),i(yp(t))},[t]),(0,Y.useEffect)(()=>{if(t!==`auto`||typeof window>`u`||!window.matchMedia)return;let e=window.matchMedia(`(prefers-color-scheme: light)`),n=()=>i(e.matches?`light`:`dark`);return typeof e.addEventListener==`function`?(e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)):(e.addListener(n),()=>e.removeListener(n))},[t]),{theme:t,resolved:r,setTheme:(0,Y.useCallback)(t=>{mp(t)&&(n(t),_p(t),i(yp(t)),e(t))},[e]),syncFromRegistry:(0,Y.useCallback)(e=>{mp(e)&&(n(e),_p(e),i(yp(e)))},[])}}function yp(e){return e===`dark`?`dark`:e===`light`||typeof window<`u`&&window.matchMedia&&window.matchMedia(`(prefers-color-scheme: light)`).matches?`light`:`dark`}function bp(){return typeof navigator>`u`?!1:/Mac|iPod|iPhone|iPad/.test(navigator.platform||``)}function xp(e){return e.key!==`k`&&e.key!==`K`?!1:bp()?e.metaKey:e.ctrlKey}function Sp(){let[e,t]=(0,Y.useState)(!1),n=(0,Y.useCallback)(()=>t(e=>!e),[]),r=(0,Y.useCallback)(()=>t(!1),[]);return(0,Y.useEffect)(()=>{function e(e){xp(e)&&(e.preventDefault(),t(e=>!e))}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]),{open:e,setOpen:t,toggle:n,close:r}}function Cp(e,t){let[n,r]=(0,Y.useState)(null);return{error:n,saveInstanceLabel:(0,Y.useCallback)(async(n,i)=>{let a=i?.trim()||null;if(!await e({instances:{[String(n)]:{label:a}}})){let e=`instance label save failed`;throw r(e),Error(e)}r(null),t(e=>e&&{...e,instances:e.instances.map(e=>e.port===n?{...e,label:a}:e)})},[e,t])}}var wp=5e3,Tp=200;function Ep(e){if(!e)return null;if(`latestAssistant`in e){let t=e.latestAssistant,n=e.activity;return!t||!n||n.role!==`assistant`||n.messageId!==t.id?null:t}return e.role===`assistant`&&Number.isInteger(e.id)?e:null}function Dp(e){return!e||!(`activity`in e)?null:e.activity?.title||null}function Op(e){return e&&(`activity`in e||`latestAssistant`in e)?`ready`:`legacy`}function kp(e){return!e||typeof e!=`object`?!1:`processBusy`in e&&e.processBusy===!0}async function Ap(e){let t=await fetch(`/i/${e}/api/messages/latest?includeContent=1`);if(!t.ok)return{latest:null,title:null,support:`offline`,busy:!1};let n=await t.json();return{latest:Ep(n.data),title:Dp(n.data),support:Op(n.data),busy:kp(n.data)}}function jp(e){let[t,n]=(0,Y.useState)([]),[r,i]=(0,Y.useState)({}),[a,o]=(0,Y.useState)({}),[s,c]=(0,Y.useState)(new Set),l=(0,Y.useRef)({}),u=(0,Y.useMemo)(()=>e.filter(e=>e.ok).map(e=>e.port).sort((e,t)=>e-t),[e]),d=u.join(`,`),f=(0,Y.useMemo)(()=>e.map(e=>`${e.port}:${e.ok?`online`:`offline`}`).sort().join(`,`),[e]);return(0,Y.useEffect)(()=>{let t=!1,r=null;async function a(){if(t)return;let r=new Set(e.map(e=>e.port)),a={};for(let t of e)t.ok||(a[t.port]=`offline`);if(u.length===0){o(a),i(e=>Object.fromEntries(Object.entries(e).filter(([e])=>r.has(Number(e)))));return}let s=await Promise.allSettled(u.map(async e=>({port:e,...await Ap(e)}))),d=[],f={},p=new Set;for(let e of s){if(e.status!==`fulfilled`)continue;let{port:t,latest:n,title:r,support:i,busy:o}=e.value;if(o&&p.add(t),a[t]=i,r&&(f[t]=r),!n)continue;let s=l.current[t];l.current[t]=n.id,!(s==null||n.id<=s)&&d.push({kind:`instance-message`,port:t,messageId:n.id,role:n.role,at:n.created_at&&!Number.isNaN(Date.parse(n.created_at))?n.created_at:new Date().toISOString(),...r?{title:r}:{}})}if(!t){for(let e of u)a[e]||(a[e]=`offline`);o(a),c(p),i(e=>{let t={};for(let[n,i]of Object.entries(e)){let e=Number(n);r.has(e)&&a[e]===`ready`&&(t[e]=i)}return{...t,...f}}),d.length>0&&n(e=>{let t=[...e,...d];return t.length>Tp&&t.splice(0,t.length-Tp),t})}}function s(){r||=setInterval(()=>{a()},wp)}function d(){r&&clearInterval(r),r=null}function f(){document.visibilityState===`visible`?(a(),s()):d()}return a(),s(),document.addEventListener(`visibilitychange`,f),()=>{t=!0,d(),document.removeEventListener(`visibilitychange`,f)}},[d,f]),{events:t,titlesByPort:r,titleSupportByPort:a,busyPorts:s}}var Mp=1e4,Np=200;function Pp(){let[e,t]=(0,Y.useState)([]),[n,r]=(0,Y.useState)(null),i=(0,Y.useRef)(null);async function a(){try{let e=await te(i.current);if(r(null),e.length===0)return;i.current=e[e.length-1].at,t(t=>{let n=[...t,...e];return n.length>Np&&n.splice(0,n.length-Np),n})}catch(e){r(e.message)}}return(0,Y.useEffect)(()=>{let e=!1,t=null;async function n(){e||await a()}function r(){t||=setInterval(()=>{n()},Mp)}function i(){t&&clearInterval(t),t=null}function o(){document.visibilityState===`visible`?(n(),r()):i()}return n(),r(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,i(),document.removeEventListener(`visibilitychange`,o)}},[]),{events:e,error:n,refresh:a}}function Fp(e){let t=(0,Y.useRef)(e);t.current=e,(0,Y.useEffect)(()=>{let e=null,n=()=>{e?.close(),e=null},r=()=>{e||document.hidden||(e=new EventSource(`/api/manager/events/stream`),e.onmessage=e=>{let n;try{n=JSON.parse(String(e.data))}catch{return}if(n.topic!==`worker`||n.event!==`worker_settings_change`)return;let r=n.data?.port;typeof r==`number`&&Number.isInteger(r)&&t.current(r)})},i=()=>{if(document.hidden){n();return}r()};return r(),document.addEventListener(`visibilitychange`,i),()=>{document.removeEventListener(`visibilitychange`,i),n()}},[])}function Ip(e,t){let[n,r]=(0,Y.useState)(null);async function i(i){if(n==null){r(i);try{(await y(i)).cancelled||await e(i)}catch(e){t(e.message)}finally{r(null)}}}return{busyPort:n,pick:i}}function Lp(e){if(e===window.location.origin)return!0;try{let t=new URL(e).hostname;return t===`localhost`||t===`127.0.0.1`||t===`::1`||t===`[::1]`}catch{return!1}}function Rp(e){(0,Y.useEffect)(()=>{function t(t){let n=t.data;n?.type===`jaw-preview-stt-recording`&&n.action===`request`&&Lp(t.origin)&&(e.status===`active`||e.status===`silent`||e.status===`paused`||e.status===`connecting`)&&e.end()}return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[e.status,e.end])}function zp(e){(0,Y.useEffect)(()=>{function t(t){if(!e.enabled)return;let n=t.data;if(!n||n.type!==`jaw-preview-shortcut`)return;let r={key:n.key,code:n.code,altKey:!!n.altKey,ctrlKey:!!n.ctrlKey,metaKey:!!n.metaKey,shiftKey:!!n.shiftKey},i=xe(r,e.keymap);i&&e.onAction(i)}return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)},[e])}function Bp(e){return e===`connecting`?`Connecting voice`:e===`silent`?`Listening`:`Voice active`}function Vp(e){if(e.status!==`connecting`&&e.status!==`active`&&e.status!==`silent`)return null;let t=Bp(e.status),n=e.selectedPort==null?`Dashboard`:`Worker :${e.selectedPort}`;return(0,X.jsx)(`div`,{className:`jaw-ceo-voice-overlay status-${e.status}`,role:`status`,"aria-live":`polite`,children:(0,X.jsxs)(`div`,{className:`jaw-ceo-voice-overlay-card`,children:[(0,X.jsxs)(`div`,{className:`jaw-ceo-voice-wave`,"aria-hidden":`true`,children:[(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{}),(0,X.jsx)(`span`,{})]}),(0,X.jsxs)(`div`,{className:`jaw-ceo-voice-overlay-copy`,children:[(0,X.jsx)(`strong`,{children:t}),(0,X.jsx)(`span`,{children:e.status===`silent`?`No speech detected. Session is still open.`:n}),e.lastTranscript?(0,X.jsx)(`small`,{children:e.lastTranscript}):e.lastEventType?(0,X.jsx)(`small`,{children:e.lastEventType}):null]}),(0,X.jsx)(`button`,{type:`button`,className:`jaw-ceo-voice-stop`,"aria-label":`Stop Jaw CEO voice`,onClick:e.onStop,children:`Stop`})]})})}function Hp(e,t,n){for(e.add(t);e.size>n;){let t=e.values().next();if(t.done)return;e.delete(t.value)}}var Up=5e3;function Wp(){return new Date().toISOString()}function Gp(e){return{session:{sessionId:`pending`,inputMode:`text`,responseMode:`text`,selectedPort:e,openedAt:Wp(),lastUserActivityAt:Wp(),voiceArmed:!1,frontendPresence:`visible`,autoRead:!1},transcript:[],watches:[],pending:[],auditTail:[],voice:{status:`idle`,sessionId:null,model:`gpt-realtime-2`,voice:`marin`,error:null}}}function Kp(e,t){let n=Gp(t);return{...n,...e,session:{...n.session,...e.session??{},selectedPort:e.session?.selectedPort??t},transcript:Array.isArray(e.transcript)?e.transcript:[],watches:Array.isArray(e.watches)?e.watches:[],pending:Array.isArray(e.pending)?e.pending:[],auditTail:Array.isArray(e.auditTail)?e.auditTail:[],voice:{...n.voice,...e.voice??{}}}}function qp(e){return e.kind===`instance-completed`?`${e.kind}:${e.port}:${e.requestId||``}:${e.messageId||``}:${e.at}`:`${e.kind}:${e.port}:${e.messageId}:${e.role}:${e.at}`}function Jp(e){return e.kind===`instance-message`?{kind:`instance-message`,port:e.port,messageId:e.messageId,role:e.role,at:e.at}:null}var Yp=2e3;function Xp(e){let[t,n]=(0,Y.useState)(()=>Gp(e.selectedPort)),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),l=(0,Y.useRef)(new Set),u=(0,Y.useRef)(t);(0,Y.useEffect)(()=>{u.current=t},[t]);let d=(0,Y.useCallback)(async()=>{i(e=>e||`refresh`);try{let t=Kp(await Ju(),e.selectedPort),r=Array.from(new Set(t.watches.map(e=>e.port)));r.length>0&&await Qu({ports:r});let i=Kp(await Ju(),e.selectedPort);n(i),o(null)}catch(e){o(e.message)}finally{i(e=>e===`refresh`?null:e)}},[e.selectedPort]);(0,Y.useEffect)(()=>{if(!e.documentVisible)return;let t=!1,n=null;async function r(){t||await d()}return r(),n=setInterval(()=>{r()},Up),()=>{t=!0,n&&clearInterval(n)}},[e.documentVisible,d]),(0,Y.useEffect)(()=>{let t=[];for(let n of e.managerEvents){let e=Jp(n);if(!e)continue;let r=qp(e);l.current.has(r)||(Hp(l.current,r,Yp),t.push(e))}t.length!==0&&(async()=>{try{await Qu({events:t}),await d()}catch(e){o(e.message)}})()},[e.managerEvents,d]);let f=(0,Y.useCallback)(async(t,n=`text`)=>{i(`message`);try{let r=await Zu({text:t,responseMode:n,selectedPort:e.selectedPort,...u.current.session.sessionId===`pending`?{}:{sessionId:u.current.session.sessionId}}),i=r.data?.response||r.error?.message||r.message||`Jaw CEO message completed.`;return c(i),await d(),r}catch(e){let t=e.message;throw o(t),e}finally{i(null)}},[e.selectedPort,d]),p=(0,Y.useCallback)(async e=>{i(`ack:${e}`);try{await td(e,`ack`),await d()}finally{i(null)}},[d]),m=(0,Y.useCallback)(async e=>{i(`dismiss:${e}`);try{await td(e,`dismiss`),await d()}finally{i(null)}},[d]);return{state:t,pending:t.pending,audit:t.auditTail,busy:r!==null,error:a,lastResponse:s,refresh:d,sendText:f,continueCompletion:$u,summarizeCompletion:ed,ackCompletion:p,dismissCompletion:m}}var Zp={start:[523.25,659.25],silent:[392],stop:[659.25,392],error:[220,196]};function Qp(e){let t=window.AudioContext||window.webkitAudioContext;if(t)try{let n=new t,r=n.currentTime;Zp[e].forEach((t,i)=>{let a=n.createOscillator(),o=n.createGain(),s=r+i*.085;a.type=e===`silent`?`sine`:`triangle`,a.frequency.setValueAtTime(t,s),o.gain.setValueAtTime(1e-4,s),o.gain.exponentialRampToValueAtTime(e===`silent`?.015:.024,s+.012),o.gain.exponentialRampToValueAtTime(1e-4,s+.105),a.connect(o),o.connect(n.destination),a.start(s),a.stop(s+.12)}),window.setTimeout(()=>void n.close().catch(()=>void 0),420)}catch{}}async function $p(e){if(!navigator.mediaDevices?.getUserMedia)throw Error(`Microphone capture is not available in this browser.`);let t=new RTCPeerConnection,n=t.createDataChannel(`oai-events`);n.onmessage=t=>{try{e.onRealtimeEvent(JSON.parse(t.data))}catch{e.onRealtimeEvent({type:`raw`,text:String(t.data)})}};let r=new MediaStream,i=document.createElement(`audio`);i.autoplay=!0,i.setAttribute(`playsinline`,``),i.srcObject=r,i.className=`jaw-ceo-voice-audio`,i.setAttribute(`aria-hidden`,`true`),document.body.appendChild(i),t.ontrack=e=>{for(let t of e.streams[0]?.getTracks()||[e.track])r.getTracks().includes(t)||r.addTrack(t)};let a=await navigator.mediaDevices.getUserMedia({audio:{noiseSuppression:!0,echoCancellation:!0,autoGainControl:!0}});for(let e of a.getTracks())t.addTrack(e,a);let o=await t.createOffer();if(await t.setLocalDescription(o),!o.sdp)throw Error(`Browser did not create a voice SDP offer.`);let s=await nd({offerSdp:o.sdp,selectedPort:e.selectedPort,...e.sessionId?{sessionId:e.sessionId}:{},responseMode:`voice`});await t.setRemoteDescription({type:`answer`,sdp:s.answerSdp});function c(){n.close();for(let e of a.getTracks())e.stop();t.close(),i.remove()}function l(e){for(let t of a.getAudioTracks())t.enabled=e}return{sessionId:s.sessionId,peer:t,dataChannel:n,micStream:a,audio:i,setMicEnabled:l,close:c}}var em=4e3,tm=3e4;function nm(e){if(!e||typeof e!=`object`)return null;let t=e,n=String(t.type||``);return typeof t.delta==`string`&&(n===`response.audio_transcript.delta`||n===`response.text.delta`||n===`response.output_text.delta`)?t.delta:typeof t.transcript==`string`?t.transcript:typeof t.text==`string`&&(n.includes(`transcript`)||n.includes(`text`))?t.text:typeof t.output==`string`?t.output:null}function rm(e){return e===`response.audio_transcript.delta`||e===`response.text.delta`||e===`response.output_text.delta`}function im(e){if(!e||typeof e!=`object`)return null;let t=e.type;return typeof t==`string`?t:null}function am(e){let[t,n]=(0,Y.useState)(`idle`),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(null),l=(0,Y.useRef)(null),u=(0,Y.useRef)(e),d=(0,Y.useRef)(0),f=(0,Y.useRef)(Date.now()),p=(0,Y.useRef)(0),m=(0,Y.useRef)(``);(0,Y.useEffect)(()=>{u.current=e},[e]);function h(e,t){f.current=Date.now(),e&&o(e),t&&c(t.length>180?`${t.slice(0,177)}...`:t),n(e=>e===`silent`?`active`:e)}let g=(0,Y.useCallback)(async()=>{d.current+=1;let e=l.current;l.current=null,e&&(e.close(),await rd(e.sessionId).catch(()=>void 0)),n(`sleeping`)},[]),_=(0,Y.useCallback)(async()=>{if(t===`connecting`&&!l.current){d.current+=1,Qp(`stop`),n(`paused`);return}l.current?.setMicEnabled(!1),Qp(`stop`),n(`paused`)},[t]),v=(0,Y.useCallback)(async()=>{await g(),Qp(`stop`)},[g]),y=(0,Y.useCallback)(async()=>{if(l.current){l.current.setMicEnabled(!0),f.current=Date.now(),i(null),Qp(`start`),n(`active`);return}if(t===`connecting`)return;let e=d.current+1;d.current=e,n(`connecting`),i(null),o(null),c(null),m.current=``,Qp(`start`);try{let t=await $p({selectedPort:u.current.selectedPort,...u.current.sessionId?{sessionId:u.current.sessionId}:{},onRealtimeEvent:e=>{let t=im(e),n=nm(e),r=n&&rm(t)?`${m.current}${n}`:n;n&&rm(t)&&(m.current=r||``),t===`response.created`&&(m.current=``),h(t,r),r&&u.current.onTranscript(r)}});if(d.current!==e){t.close(),await rd(t.sessionId).catch(()=>void 0);return}l.current=t,f.current=Date.now(),n(`active`)}catch(t){if(d.current!==e)return;i(t.message),Qp(`error`),n(t.message.includes(`OPENAI_API_KEY`)?`disabled`:`error`),l.current?.close(),l.current=null}},[t]),b=(0,Y.useCallback)(async(e,t)=>{let n=e.trim();n&&await Zu({text:n,selectedPort:u.current.selectedPort,...u.current.sessionId?{sessionId:u.current.sessionId}:{},inputMode:`voice`,responseMode:t})},[]),x=(0,Y.useCallback)(async e=>{await $u(e.completionKey,`voice`),u.current.onSpokenCompletion(e.completionKey)},[]);return(0,Y.useEffect)(()=>()=>{d.current+=1;let e=l.current;l.current=null,e&&(e.close(),rd(e.sessionId).catch(()=>void 0))},[]),(0,Y.useEffect)(()=>{if(e.documentVisible)return;let t=l.current;t&&(d.current+=1,l.current=null,t.close(),rd(t.sessionId).catch(()=>void 0),n(`sleeping`))},[e.documentVisible]),(0,Y.useEffect)(()=>{if(t!==`active`&&t!==`silent`)return;let e=window.setInterval(()=>{if(!l.current)return;let e=Date.now();e-f.current<em||(n(`silent`),e-p.current>=tm&&(Qp(`silent`),p.current=e))},1e3);return()=>window.clearInterval(e)},[t]),e.autoRead,{status:t,error:r,lastEventType:a,lastTranscript:s,talk:y,stop:_,end:v,sendText:b,speakCompletion:x}}function om(){let[e,t]=(0,Y.useState)(()=>typeof document>`u`||document.visibilityState===`visible`);return(0,Y.useEffect)(()=>{function e(){t(document.visibilityState===`visible`)}return document.addEventListener(`visibilitychange`,e),()=>document.removeEventListener(`visibilitychange`,e)},[]),e}function sm(e){let[t,n]=(0,Y.useState)(!1),r=om(),i=(0,Y.useMemo)(()=>[...e.managerEvents,...e.messageEvents],[e.managerEvents,e.messageEvents]),a=Xp({selectedPort:e.selectedPort,documentVisible:r,managerEvents:i}),o=a.state.session.sessionId===`pending`?null:a.state.session.sessionId,s=am({selectedPort:e.selectedPort,...o?{sessionId:o}:{},autoRead:a.state.session.autoRead,documentVisible:r,onTranscript:()=>void 0,onSpokenCompletion:e=>{a.ackCompletion(e)}});return s.status===`active`||s.status===`connecting`||s.status,{ceo:a,voice:s,open:t,setOpen:n,workbenchButton:null,voiceOverlay:(0,X.jsx)(Vp,{status:s.status,selectedPort:e.selectedPort,lastEventType:s.lastEventType,lastTranscript:s.lastTranscript,onStop:()=>void s.stop()})}}function cm(e,t){if(e.length===0)return e;let n=new Set(t.map(e=>e.profileId)),r=e.filter(e=>n.has(e));return r.length===e.length?e:r}function lm(e){if(!e)return null;switch(e){case`folder`:case`doc`:case`ceo`:return`files`;case`diff`:return`diff`;case`browser`:return`browser`;default:return null}}function um(e,t){return e===`diff`?`right-diff`:`right-${e}-${t??1}`}function dm(e,t){return e===`diff`?me:`${N[e]} ${t??1}`}function fm(e){return e===`diff`?{id:um(`diff`),kind:e,title:N.diff,specificName:me}:{id:um(e,1),kind:e,title:N[e],specificName:dm(e,1),ordinal:1}}function pm(e,t){let n={};for(let r of ge){let i=e.filter(e=>e.kind===r).reduce((e,t)=>Math.max(e,t.ordinal??1),0),a=typeof t?.[r]==`number`&&Number.isFinite(t[r])?t[r]:0,o=Math.max(a,i+1);(o>1||i>0)&&(n[r]=o)}return n}function mm(e,t){let n=new Set,r=[],i=null;for(let a of[e,t]){let e=lm(a);e&&!n.has(e)&&(n.add(e),r.push(fm(e)),i||=e)}return{openTabs:r,activeTabId:i?r.find(e=>e.kind===i)?.id??null:null,nextOrdinalByKind:pm(r)}}function hm(e){if(!e||typeof e!=`object`)return;let t=e,n={};return typeof t.pageId==`string`&&t.pageId.length>0&&(n.pageId=t.pageId),typeof t.projectKey==`string`&&t.projectKey.length>0&&(n.projectKey=t.projectKey),typeof t.zoom==`number`&&Number.isFinite(t.zoom)&&t.zoom>0&&(n.zoom=t.zoom),Object.keys(n).length>0?n:void 0}function gm(e){if(!e||typeof e!=`object`)return;let t=e;if(typeof t.url==`string`&&t.url.length>0)return{url:t.url}}function _m(e){if(!e||typeof e!=`object`)return;let t=e,n={};return typeof t.activeFilePath==`string`&&t.activeFilePath.length>0&&(n.activeFilePath=t.activeFilePath),typeof t.folderRootPath==`string`&&t.folderRootPath.length>0&&(n.folderRootPath=t.folderRootPath),typeof t.repoRootPath==`string`&&t.repoRootPath.length>0&&(n.repoRootPath=t.repoRootPath),(t.repoRootMode===`instance`||t.repoRootMode===`manual`)&&(n.repoRootMode=t.repoRootMode),Object.keys(n).length>0?n:void 0}function vm(e){let t=/-(\d+)$/.exec(e);if(!t)return;let n=Number.parseInt(t[1],10);return Number.isFinite(n)&&n>0?n:void 0}function ym(e){if(!e||typeof e.id!=`string`||e.id.length===0||typeof e.kind!=`string`||!fe.includes(e.kind))return null;let t=e.kind,n=typeof e.ordinal==`number`&&Number.isFinite(e.ordinal)&&e.ordinal>0?Math.floor(e.ordinal):vm(e.id),r=typeof e.title==`string`&&e.title.length>0?e.title:N[t],i=typeof e.specificName==`string`&&e.specificName.length>0?e.specificName:dm(t,n),a=t===`files`?_m(e.files):void 0,o=t===`browser`?gm(e.browser):void 0,s=t===`design`?hm(e.design):void 0;return{id:e.id,kind:t,title:r,specificName:i,...typeof e.sourceLabel==`string`&&e.sourceLabel.length>0?{sourceLabel:e.sourceLabel}:{},...t!==`diff`&&n!==void 0?{ordinal:n}:{},...e.pinned===!0?{pinned:!0}:{},...a?{files:a}:{},...o?{browser:o}:{},...s?{design:s}:{}}}function bm(e){if(e.rightSidebarOpenTabs){let t=e.rightSidebarOpenTabs,n=[],r=new Set,i=!1;for(let e of t){let t=ym(e);if(t&&!r.has(t.id)){if(t.kind===`diff`){if(i)continue;i=!0}r.add(t.id),n.push(t)}}return{openTabs:n,activeTabId:typeof e.rightSidebarActiveTabId==`string`&&n.find(t=>t.id===e.rightSidebarActiveTabId)?e.rightSidebarActiveTabId:n[0]?.id??null,nextOrdinalByKind:pm(n,e.rightSidebarNextOrdinalByKind)}}return e.rightPanelTopMode!==void 0||e.rightPanelBottomMode!==void 0?mm(e.rightPanelTopMode,e.rightPanelBottomMode):{openTabs:[],activeTabId:null,nextOrdinalByKind:{}}}function xm(e){let t=e.fileFolderLayout;if(t&&typeof t==`object`){let e=typeof t.splitRatio==`number`&&Number.isFinite(t.splitRatio)?Math.max(0,Math.min(1,t.splitRatio)):de,n=typeof t.lastSplitRatio==`number`&&Number.isFinite(t.lastSplitRatio)?Math.max(0,Math.min(1,t.lastSplitRatio)):de;return{mode:t.mode===`split`||t.mode===`folder-only`||t.mode===`file-only`?t.mode:P(e),splitRatio:e,lastSplitRatio:n}}return{mode:`split`,splitRatio:de,lastSplitRatio:de}}function Sm(e){if(!e.panelLayoutVersion)return{};let t=bm(e),n=xm(e);return{rightPanel:{open:e.rightPanelOpen??!1,width:e.rightPanelWidth??480,tabs:t,fileFolderLayout:n},bottomPanel:{open:e.bottomPanelOpen??!1,height:e.bottomPanelHeight??320,tabs:e.bottomPanelTabs??[],activeTab:e.bottomPanelActiveTab??null}}}function Cm(e){return{panelLayoutVersion:2,rightPanelOpen:e.rightPanel.open,rightPanelWidth:e.rightPanel.width,rightSidebarOpenTabs:e.rightPanel.tabs.openTabs,rightSidebarActiveTabId:e.rightPanel.tabs.activeTabId,rightSidebarNextOrdinalByKind:e.rightPanel.tabs.nextOrdinalByKind,fileFolderLayout:e.rightPanel.fileFolderLayout,rightPanelTopMode:void 0,rightPanelBottomMode:void 0,rightPanelSplitRatio:void 0,rightSidebarLastActiveByKind:void 0,bottomPanelOpen:e.bottomPanel.open,bottomPanelHeight:e.bottomPanel.height,bottomPanelTabs:e.bottomPanel.tabs,bottomPanelActiveTab:e.bottomPanel.activeTab}}function wm(){if(Rf(window.location.search))return(0,X.jsx)(ep,{});let[e,t]=(0,Y.useState)(null),[n,r]=(0,Y.useState)(!0),[i,a]=(0,Y.useState)(null),[o,s]=(0,Y.useState)(``),[c,l]=(0,Y.useState)(`all`),[u,d]=(0,Y.useState)(``),[f,p]=(0,Y.useState)(!1),[m,g]=(0,Y.useState)(!1),[_,y]=(0,Y.useState)(void 0),[b,x]=(0,Y.useState)(null),[S,C]=(0,Y.useState)(null),[w,T]=(0,Y.useState)(null),[E,D]=(0,Y.useState)(null),[O,k]=(0,Y.useState)([]),{settingsDirty:A,dashboardSettingsDirty:j,setSettingsDirty:te,onSettingsDirtyChange:ne}=op(),[re,ie]=(0,Y.useState)(null),[ae,oe]=(0,Y.useState)(`files`),[se,ce]=(0,Y.useState)(0),[le,ue]=(0,Y.useState)(`display`),[de,fe]=(0,Y.useState)({kind:`overall`}),[pe,N]=(0,Y.useState)(`today`),[P,me]=(0,Y.useState)(()=>Sf()),[he,ge]=(0,Y.useState)(0),[_e,F]=(0,Y.useState)(!1),[ye,be]=(0,Y.useState)(!1),[Se,Ce]=(0,Y.useState)(null),I=(0,Y.useCallback)(e=>{Ce(e),be(!0)},[]);(0,Y.useEffect)(()=>{Cf(P)},[P]),Ef({enabled:P,onUnload:()=>{me(!1),F(!0)}}),(0,Y.useEffect)(()=>{if(!_e||typeof document>`u`||document.hidden)return;let e=setTimeout(()=>F(!1),8e3);return()=>clearTimeout(e)},[_e]);let L=tp(),R=np(),we=vp(e=>{m&&L.save({ui:{uiTheme:e}})}),Te=Sp(),Ee=Pp(),z=e?.instances||[],De=jp(z),B=Cp(L.save,t),Oe=(0,Y.useMemo)(()=>e?.manager.profiles||[],[e]),ke=(0,Y.useMemo)(()=>{let e=new Set(Oe.map(e=>e.profileId));return O.filter(t=>e.has(t))},[O,Oe]),V=(0,Y.useMemo)(()=>{let e=o.trim().toLowerCase();return z.filter(t=>c!==`all`&&t.status!==c||ke.length>0&&(!t.profileId||!ke.includes(t.profileId))?!1:!e||[String(t.port),t.url,or(t),t.version,t.workingDir,t.currentCli,t.currentModel,t.healthReason,t.label,t.group,t.profileId].some(t=>String(t||``).toLowerCase().includes(e)))},[ke,z,o,c]),H=(0,Y.useMemo)(()=>R.selectedPort==null?V.find(e=>e.ok)||null:z.find(e=>e.port===R.selectedPort)||null,[V,z,R.selectedPort]),U=H?.port??R.selectedPort??null,Ae=sm({selectedPort:U,managerEvents:Ee.events,messageEvents:De.events,onOpenWorker:J});Rp(Ae.voice),zp({enabled:R.dashboardShortcutsEnabled,keymap:R.dashboardShortcutKeymap,onAction:pt});let W=R.activeDetailTab===`preview`&&R.sidebarMode===`instances`?H?.port??null:null,G=(0,Y.useMemo)(()=>[...Ee.events,...De.events],[Ee.events,De.events]),K=fp({events:G,activityDockCollapsed:R.activityDockCollapsed,setActivityDockCollapsed:R.setActivityDockCollapsed,saveUi:q,activePreviewPort:W});function je(){let e=[`auto`,`light`,`dark`],t=e[(e.indexOf(we.theme)+1)%e.length];we.setTheme(t)}function Me(){H&&window.open(H.url,`_blank`,`noopener,noreferrer`)}(0,Y.useEffect)(()=>{document.documentElement.lang=R.locale},[R.locale]),(0,Y.useEffect)(()=>{function e(e){e.key!==`?`||e.metaKey||e.ctrlKey||e.altKey||bf(e.target)||(e.preventDefault(),I(`shortcuts`))}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[I]);async function Ne(e=f,n=!1){r(!0),a(null);try{let r=await ee(e,{fresh:n}),i=cm(O,r.manager.profiles||[]);i!==O&&(k(i),L.save({activeProfileFilter:i})),t(r)}catch(e){a(e.message)}finally{r(!1)}}async function Pe(e){let n=await v(e);n&&t(t=>t&&{...t,instances:t.instances.map(t=>t.port===e?n:t)})}kf(`instances`,()=>void Ne(),`app`),Fp(e=>{Pe(e),Z({topics:[`instances`],reason:`instance:settings-change`,source:`ui`,sourceId:`app`})});let Fe=Ip(async e=>{await Pe(e),Z({topics:[`instances`],reason:`instance:project-picked`,source:`ui`,sourceId:`app`})},e=>C(`Project pick failed: ${e}`));(0,Y.useEffect)(()=>{async function e(){try{let e=await L.refresh(),t=e.registry.ui,n=rp(t);R.setSelectedPort(t.selectedPort),R.setActiveDetailTab(n.selectedTab),R.setSidebarCollapsed(t.sidebarCollapsed),R.setActivityDockCollapsed(t.activityDockCollapsed),R.setActivityDockHeight(t.activityDockHeight);let r=pf(Lf(window.location.search)??n.sidebarMode);R.setSidebarMode(r),r!==t.sidebarMode&&q({sidebarMode:r}),R.setNotesSelectedPath(t.notesSelectedPath),R.setNotesViewMode(t.notesViewMode),R.setNotesAuthoringMode(t.notesAuthoringMode??`plain`),R.setNotesWordWrap(t.notesWordWrap),R.setNotesVimMode(t.notesVimMode),R.setNotesTreeWidth(t.notesTreeWidth),R.setNotesGraphSettings(t.notesGraphSettings),R.setShowLatestActivityTitles(t.showLatestActivityTitles),R.setShowInlineLabelEditor(t.showInlineLabelEditor),R.setShowSidebarRuntimeLine(t.showSidebarRuntimeLine),R.setShowSelectedRowActions(t.showSelectedRowActions),R.setDashboardShortcutsEnabled(t.dashboardShortcutsEnabled),R.setDashboardShortcutKeymap(t.dashboardShortcutKeymap),R.setDiffRootPolicy(t.diffRootPolicy),R.setDiffPinnedRootByPort(t.diffPinnedRootByPort),R.setDiffRecentRepoRoots(t.diffRecentRepoRoots),R.setDiffDefaultMode(t.diffDefaultMode),R.setDiffBaseRef(t.diffBaseRef),R.setDiffIncludeUntracked(t.diffIncludeUntracked),R.setRightFolderRootPath(t.rightFolderRootPath),R.setLocale(t.locale),K.hydrateSeenAt(t.activitySeenAt??null,t.activitySeenByPort||{}),k(e.registry.activeProfileFilter||[]),we.syncFromRegistry(t.uiTheme),y(Sm(t))}finally{g(!0),await Ne()}}e()},[]);async function q(e){m&&e!==void 0&&await L.save({ui:e})}function Ie(e){q(Cm(e))}let Le=(0,Y.useMemo)(()=>z.reduce((e,t)=>(t.profileId&&(e[t.profileId]=(e[t.profileId]||0)+1),e),{}),[z]),Re=(0,Y.useMemo)(()=>z.reduce((e,t)=>(e.total+=1,e[t.status]=(e[t.status]||0)+1,e),{total:0}),[z]);function ze(e){let t=O.includes(e)?O.filter(t=>t!==e):[...O,e];k(t),L.save({activeProfileFilter:t})}let{canLeaveDirtySettings:Be,guardSettingsTransition:Ve,setDashboardSettingsOpen:He}=ip({view:R,settingsDirty:A,dashboardSettingsDirty:j,clearDirty:e=>ne(e,!1),saveUi:q,selectedPort:H?.port??null});function Ue(e,t=!1){(e.port===H?.port||Be())&&(t&&(me(!0),F(!1),ge(e=>e+1)),e.port!==H?.port&&te(!1),K.markPortSeen(e.port),R.setSelectedPort(e.port),R.setActiveDetailTab(`preview`),R.setActivityDockCollapsed(!0),R.setDrawerOpen(!1),q({selectedPort:e.port,selectedTab:`preview`,activityDockCollapsed:!0}))}function J(e){let t=z.find(t=>t.port===e);t&&Ue(t)}function We(e){(e.port===H?.port||Be())&&(e.port!==H?.port&&te(!1),K.markPortSeen(e.port),R.setSelectedPort(e.port),R.setDrawerOpen(!1),q({selectedPort:e.port}))}function Ge(e){if(e===`settings`){He(!0);return}if(R.activeDetailTab===`preview`&&e!==`preview`){let e=R.selectedPort;e!=null&&K.markPortSeen(e)}if(R.setActiveDetailTab(e),e===`preview`){let t=R.selectedPort;t!=null&&K.markPortSeen(t),R.setActivityDockCollapsed(!0),q({selectedTab:e,activityDockCollapsed:!0});return}q({selectedTab:e})}function Ke(){let e=!R.sidebarCollapsed;R.setSidebarCollapsed(e),q({sidebarCollapsed:e})}function qe(){if(R.activityDockCollapsed){K.openAndMarkSeen();return}K.closeAndPersistSeen()}function Je(e){R.setActivityDockHeight(e),q({activityDockHeight:e})}function Ye(e){let t=pf(e);if(Ve({sidebarMode:t})){if(R.sidebarMode===`instances`&&e!==`instances`&&R.activeDetailTab===`preview`){let e=R.selectedPort;e!=null&&K.markPortSeen(e)}R.setSidebarMode(t),q({sidebarMode:t})}}function Xe(e){R.setNotesSelectedPath(e),q({notesSelectedPath:e})}let[Ze,Qe]=(0,Y.useState)(null),$e=(0,Y.useRef)(null);function et(e){Qe(e),$e.current&&clearTimeout($e.current),$e.current=setTimeout(()=>Qe(null),2500)}function tt(e){let t=e.trim();t&&(R.sidebarMode!==`notes`&&Ye(`notes`),Xe(t),et(t))}(0,Y.useEffect)(()=>()=>{$e.current&&clearTimeout($e.current)},[]);function nt(){oe(`search`),ce(e=>e+1)}function rt(e){R.setNotesViewMode(e),q({notesViewMode:e})}function it(e){R.setNotesAuthoringMode(e),q({notesAuthoringMode:e})}function at(e){R.setNotesWordWrap(e),q({notesWordWrap:e})}function ot(e){R.setNotesVimMode(e),q({notesVimMode:e})}function st(e){R.setNotesTreeWidth(e),q({notesTreeWidth:e})}function ct(e){R.setNotesGraphSettings(e),q({notesGraphSettings:e})}let lt=Ff({active:R.sidebarMode===`notes`,selectedPath:R.notesSelectedPath,onSelectedPathChange:Xe}),ut=R.notesSelectedPath?lt.index?.notes.find(e=>e.path===R.notesSelectedPath)??null:null;function dt(e){e.showLatestActivityTitles!==void 0&&R.setShowLatestActivityTitles(e.showLatestActivityTitles),e.showInlineLabelEditor!==void 0&&R.setShowInlineLabelEditor(e.showInlineLabelEditor),e.showSidebarRuntimeLine!==void 0&&R.setShowSidebarRuntimeLine(e.showSidebarRuntimeLine),e.showSelectedRowActions!==void 0&&R.setShowSelectedRowActions(e.showSelectedRowActions),e.dashboardShortcutsEnabled!==void 0&&R.setDashboardShortcutsEnabled(e.dashboardShortcutsEnabled),e.dashboardShortcutKeymap!==void 0&&R.setDashboardShortcutKeymap(e.dashboardShortcutKeymap),e.diffRootPolicy!==void 0&&R.setDiffRootPolicy(e.diffRootPolicy),e.diffPinnedRootByPort!==void 0&&R.setDiffPinnedRootByPort(e.diffPinnedRootByPort),e.diffRecentRepoRoots!==void 0&&R.setDiffRecentRepoRoots(e.diffRecentRepoRoots),e.diffDefaultMode!==void 0&&R.setDiffDefaultMode(e.diffDefaultMode),e.diffBaseRef!==void 0&&R.setDiffBaseRef(e.diffBaseRef),e.diffIncludeUntracked!==void 0&&R.setDiffIncludeUntracked(e.diffIncludeUntracked),e.rightFolderRootPath!==void 0&&R.setRightFolderRootPath(e.rightFolderRootPath),e.locale!==void 0&&R.setLocale(e.locale),q(e)}function ft(e){if(V.length===0)return;let t=H?.port??null,n=t==null?-1:V.findIndex(e=>e.port===t),r=((n>=0?n:e>0?-1:0)+e+V.length)%V.length,i=V[r];i&&We(i)}function pt(e){gf(e,{selectedInstance:H,filtered:V,activeDetailTab:R.activeDetailTab,setDrawerOpen:R.setDrawerOpen,handleSidebarModeChange:Ye,handlePreview:Ue,selectRelativeInstance:ft,handleTabChange:Ge,setPreviewRefreshKey:ge,handleSidebarToggle:Ke,toggleInstanceSettings:()=>He(R.sidebarMode!==`settings`)})}(0,Y.useEffect)(()=>{if(R.dashboardShortcutsEnabled)return M()?.shortcuts?.onAction?.(e=>{(document.activeElement?.tagName!==`IFRAME`||e===`browserReload`||e===`browserHardReload`)&&pt(e)})},[V,H,R.dashboardShortcutsEnabled,R.sidebarMode,R.activeDetailTab,A,j]),(0,Y.useEffect)(()=>{function e(e){if((e.ctrlKey||e.metaKey)&&e.key===`f`){let t=document.querySelector(`.preview-frame`);if(t?.contentWindow){e.preventDefault(),t.contentWindow.postMessage({type:`jaw-preview-search`},`*`);return}}if(!R.dashboardShortcutsEnabled||ve(e.target))return;let t=xe(e,R.dashboardShortcutKeymap);t&&(e.preventDefault(),pt(t))}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[V,H,R.dashboardShortcutsEnabled,R.dashboardShortcutKeymap,R.sidebarMode,R.activeDetailTab,A,j]);async function mt(e,n){let r=n.lifecycle;if(!r||e===`perm`&&!window.confirm(`Register :${n.port} as a persistent system service? It will auto-start on login and auto-restart on crash.`)||e===`unperm`&&!window.confirm(`Remove persistent service for :${n.port}? The instance will stop and won't auto-start.`))return;if(e===`stop`&&r.owner===`service`){if(!window.confirm(`Stop :${n.port}? This will also remove the persistent service.`))return}else if((e===`stop`||e===`restart`)&&!window.confirm(`${e} :${n.port}?`))return;if(!Be())return;te(!1);let i=n.uptime;R.setSelectedPort(n.port),q({selectedPort:n.port}),x(n.port),C(null),T(n.port),D(e);try{let r=e===`start`?u:void 0,a=await h(e,n.port,r),o=a.expectedStateAfter||(e===`start`||e===`perm`?`online`:e===`stop`||e===`unperm`?`offline`:`restart-detected`),s=await yt({port:n.port,expected:o,previousUptime:i,fetchOnce:(e,t)=>v(e,{signal:t})});s.settled||C(`${a.message} (not yet reachable, refresh manually if needed)`),s.instance&&t(e=>e&&{...e,instances:e.instances.map(e=>e.port===n.port?s.instance:e)}),await Ne(f,!0),Z({topics:[`instances`],reason:`instance:lifecycle`,source:`ui`,sourceId:`app`})}catch(e){C(e.message)}finally{x(null),T(null),D(null)}}let ht=(0,X.jsx)(Un,{error:i,loading:n,instances:z,filtered:V,selectedInstance:H,data:e,lifecycleBusyPort:b,transitioningPort:w,transitionAction:E,activityUnreadByPort:K.unreadByPort,latestTitleByPort:De.titlesByPort,busyPorts:De.busyPorts,showLatestActivityTitles:R.showLatestActivityTitles,showInlineLabelEditor:R.showInlineLabelEditor,showSidebarRuntimeLine:R.showSidebarRuntimeLine,showSelectedRowActions:R.showSelectedRowActions,profiles:Oe,getLabel:or,formatUptime:sr,onSelect:We,onPreview:e=>Ue(e,!0),onMarkActivitySeen:K.markPortSeen,onInstanceLabelSave:B.saveInstanceLabel,onLifecycle:(e,t)=>void mt(e,t)}),gt=Of(R,we.theme),_t=Df(De.titleSupportByPort);return(0,X.jsx)(yf,{view:R,palette:Te,theme:we,query:o,loading:n,showHidden:f,instances:z,selectedInstance:H,data:e,summary:Re,scheduleGroup:pe,boardView:de,notesModel:lt,notesSelectedNote:ut,notesDirtyPath:re,notesHighlightedPath:Ze,notesSidebarMode:ae,notesSearchFocusToken:se,settingsSection:le,dashboardSettingsUi:gt,titleSupport:_t,activityEvents:G,busyPorts:De.busyPorts,titlesByPort:De.titlesByPort,lifecycleMessage:S,error:i,registryMessage:L.error||B.error||Ee.error,onPickProject:e=>void Fe.pick(e),projectPickBusy:Fe.busyPort!=null,onRefreshPreview:()=>ge(e=>e+1),onSettingsDirtyChange:ne,detailContent:t=>(0,X.jsx)(Dt,{instance:H,data:e,activeTab:t,onRegistryPatch:(e,t)=>{L.save({instances:{[String(e)]:t}}).then(()=>{Ne(),Z({topics:[`instances`],reason:`instance:registry-patched`,source:`ui`,sourceId:`app`})})}}),instanceListContent:ht,drawerProfileFilters:(e=>e.length>0?(0,X.jsx)(`div`,{className:`profile-chip-strip drawer-chip-strip`,"aria-label":`Profile filters`,children:e.map(e=>(0,X.jsx)(Wn,{profile:e,active:O.includes(e.profileId),count:Le[e.profileId]||0,onToggle:ze},e.profileId))}):null)(Oe),jawCeoWorkbenchButton:Ae.workbenchButton,jawCeoVoiceOverlay:Ae.voiceOverlay,jawCeo:Ae.ceo,jawCeoVoice:Ae.voice,jawCeoOpen:Ae.open,jawCeoSelectedPort:U,onJawCeoOpenChange:Ae.setOpen,onJawCeoOpenWorker:J,previewEnabled:P,previewRefreshKey:he,autoUnloadNotice:_e,helpOpen:ye,helpTopic:Se,setQuery:s,setShowHidden:p,setPreviewEnabled:me,setAutoUnloadNotice:F,setHelpOpen:be,setHelpTopic:Ce,onOpenHelpTopic:I,setNotesSidebarMode:oe,setBoardView:fe,setScheduleGroup:N,setDashboardSettingsSection:ue,load:Ne,cycleTheme:je,openSelectedInBrowser:Me,handleSelectInstance:We,handleSidebarModeChange:Ye,handleSidebarToggle:Ke,handleNotesSelectedPathChange:Xe,openNotesFromPreview:tt,handleNotesViewModeChange:rt,handleNotesAuthoringModeChange:it,handleNotesWordWrapChange:at,handleNotesVimModeChange:ot,handleNotesTreeWidthChange:st,handleNotesGraphSettingsChange:ct,openNotesSidebarSearch:nt,setNotesDirtyPath:ie,handleTabChange:Ge,handleActivityToggle:qe,handleActivityHeight:Je,onDismissLifecycleMessage:()=>C(null),handleDashboardSettingsPatch:dt,activityUnreadOpenAndMarkSeen:K.openAndMarkSeen,panelInitialState:_,onPanelStateChange:Ie,onShortcutAction:pt})}var Tm=document.getElementById(`manager-root`);if(!Tm)throw Error(`manager-root not found`);(0,vt.createRoot)(Tm).render((0,X.jsx)(wm,{}));