@ahpd/web 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. package/README.md +11 -0
  2. package/dist/app/assets/AudioPage-BCuwTLKN.js +1 -0
  3. package/dist/app/assets/Composer-Crdqrcjj.js +2 -0
  4. package/dist/app/assets/ContextMenu-BV1gdog0.js +1 -0
  5. package/dist/app/assets/CopyButton-DWmFc5fw.js +1 -0
  6. package/dist/app/assets/{DataTable-Bv6EG42F.js → DataTable-D9RxuuR3.js} +1 -1
  7. package/dist/app/assets/Details-BhWMrDPk.js +1 -0
  8. package/dist/app/assets/DiffPage-D8wjIu2g.js +3 -0
  9. package/dist/app/assets/Edit-B12zsW3c.js +1 -0
  10. package/dist/app/assets/Explorer-BR0vyz4x.js +1 -0
  11. package/dist/app/assets/Explorer-C2wZaZN2.js +1 -0
  12. package/dist/app/assets/{Explorer-Cxl5QGRN.js → Explorer-CViecqG_.js} +1 -1
  13. package/dist/app/assets/Explorer-DLH41MqT.js +1 -0
  14. package/dist/app/assets/{Explorer-C4zxSdMF.js → Explorer-z4mktaMi.js} +1 -1
  15. package/dist/app/assets/{ExplorerList-Bdp0sfLW.js → ExplorerList-DfesRs43.js} +1 -1
  16. package/dist/app/assets/FilePage-CErxqbDp.js +3 -0
  17. package/dist/app/assets/Filter-DohSRUkD.js +1 -0
  18. package/dist/app/assets/HostSwitcher-BuSTjyO6.js +1 -0
  19. package/dist/app/assets/ImagePage-B-n1btEA.js +1 -0
  20. package/dist/app/assets/{Info-levnJ1pH.js → Info-BbyvhG4Q.js} +1 -1
  21. package/dist/app/assets/LocaleToggle-CETgRIRf.js +1 -0
  22. package/dist/app/assets/{LogPage-QIumryht.js → LogPage-C_h99NtQ.js} +1 -1
  23. package/dist/app/assets/LoginForm-p7rsv-LJ.js +1 -0
  24. package/dist/app/assets/Markdown-_Awuh7Ku.js +4 -0
  25. package/dist/app/assets/MarkdownPage-Cv5UyfVY.js +1 -0
  26. package/dist/app/assets/MountTitle-Bx_Vo8tF.js +1 -0
  27. package/dist/app/assets/New-D0REy_20.js +3 -0
  28. package/dist/app/assets/Page-B3UbQqyT.js +1 -0
  29. package/dist/app/assets/Page-TDRLt015.js +2 -0
  30. package/dist/app/assets/Page-cKDPN7cD.js +1 -0
  31. package/dist/app/assets/Pagination-v2fHA8Hf.js +1 -0
  32. package/dist/app/assets/PortaLock-ieoqUizB.js +2 -0
  33. package/dist/app/assets/{SchemaForm-D6mGj6Xh.js → SchemaForm-DKxGZpnK.js} +1 -1
  34. package/dist/app/assets/Settings-BP67xLx9.js +1 -0
  35. package/dist/app/assets/{SigillumGate-DoeGhrpT.js → SigillumGate-DNRuVdn4.js} +1 -1
  36. package/dist/app/assets/SingleLayout-D0y3xoJg.js +1 -0
  37. package/dist/app/assets/{SpatialLayout-CacNe1y4.js → SpatialLayout-CKZCVibM.js} +1 -1
  38. package/dist/app/assets/{SplitLayout-BANKBMIh.js → SplitLayout-7EOWfDlZ.js} +1 -1
  39. package/dist/app/assets/{StackLayout-Cz4zMN4f.js → StackLayout-1wBXKLKy.js} +1 -1
  40. package/dist/app/assets/StatusDot-CC7gdsot.js +1 -0
  41. package/dist/app/assets/{TabLayout-BaH8UNpt.js → TabLayout-ClrRSvj1.js} +1 -1
  42. package/dist/app/assets/{TabPanelLayout-DkFUNHcz.js → TabPanelLayout-YGvLy1cR.js} +1 -1
  43. package/dist/app/assets/{TerminalPage-C58xO7du.js → TerminalPage-BaFThhYG.js} +3 -3
  44. package/dist/app/assets/{ThemeModeToggle-CAippEfJ.js → ThemeModeToggle-D1kTZNm_.js} +1 -1
  45. package/dist/app/assets/{ThemePicker-CvnWboZg.js → ThemePicker-BIFeJU_m.js} +1 -1
  46. package/dist/app/assets/{Tree-Bb5NwYJ1.js → Tree-BqFzA5wp.js} +1 -1
  47. package/dist/app/assets/VideoPage-DbVVXi0p.js +1 -0
  48. package/dist/app/assets/WindowControls-BWi1hOPh.js +1 -0
  49. package/dist/app/assets/{actions-BQzD99j0.js → actions-BmFc5yoR.js} +1 -1
  50. package/dist/app/assets/changeset-BgSW341C.js +1 -0
  51. package/dist/app/assets/{channel-Cqz_LUS2.js → channel-8aIcEm3f.js} +1 -1
  52. package/dist/app/assets/{clicks-IyfKhKFh.js → clicks-B3stbczh.js} +1 -1
  53. package/dist/app/assets/clike-pnxEhJ5P.js +1 -0
  54. package/dist/app/assets/composer-commands-AmOY6XGO.js +2 -0
  55. package/dist/app/assets/data-CBWyZN_H.js +2 -0
  56. package/dist/app/assets/dist-1MAn9CBM.js +1 -0
  57. package/dist/app/assets/dist-33oU5N7i.js +1 -0
  58. package/dist/app/assets/dist-B9NMd4es.js +2 -0
  59. package/dist/app/assets/dist-BDH0Q8eg.js +13 -0
  60. package/dist/app/assets/dist-BfGIsxxP.js +1 -0
  61. package/dist/app/assets/dist-BnQxBrCW.js +11 -0
  62. package/dist/app/assets/dist-Bq_hlZV8.js +1 -0
  63. package/dist/app/assets/dist-C5-Hv917.js +1 -0
  64. package/dist/app/assets/dist-CEr2uR4w.js +6 -0
  65. package/dist/app/assets/dist-CYq92lOO.js +1 -0
  66. package/dist/app/assets/dist-CxEuuaKq.js +1 -0
  67. package/dist/app/assets/dist-D9412h7o.js +1 -0
  68. package/dist/app/assets/dist-DYPX2Ybv.js +23 -0
  69. package/dist/app/assets/dist-IR189dk6.js +1 -0
  70. package/dist/app/assets/dist-drsoOe-s.js +9 -0
  71. package/dist/app/assets/dist-rmKzqdIO.js +1 -0
  72. package/dist/app/assets/dockerfile-BDePf5PZ.js +1 -0
  73. package/dist/app/assets/emojis-7RT6GvLa.js +1 -0
  74. package/dist/app/assets/folder-path-CmVXGhKI.js +1 -0
  75. package/dist/app/assets/index-BQcTkW2q.css +1 -0
  76. package/dist/app/assets/index-DBKNxflN.js +14 -0
  77. package/dist/app/assets/lua-DPCEkfD_.js +1 -0
  78. package/dist/app/assets/media-C3ferCB3.js +1 -0
  79. package/dist/app/assets/{notify-Bb548jAB.js → notify-CJo-T9e2.js} +1 -1
  80. package/dist/app/assets/registry-iidw4F1W.js +1 -0
  81. package/dist/app/assets/ruby-ChfNwlCY.js +1 -0
  82. package/dist/app/assets/sessions-BcRKb9k7.js +2 -0
  83. package/dist/app/assets/shell-DwuoZtxw.js +1 -0
  84. package/dist/app/assets/swift-DKB6_1j6.js +1 -0
  85. package/dist/app/assets/terminal-BMZxY-St.js +1 -0
  86. package/dist/app/assets/text-B601jRcP.js +1 -0
  87. package/dist/app/assets/toml-BPTmHmyx.js +1 -0
  88. package/dist/app/assets/useCloseGuard-B4qJKmaF.js +1 -0
  89. package/dist/app/assets/useStoreLabel-BuZT1So6.js +1 -0
  90. package/dist/app/assets/viewers-MssMDn0e.js +1 -0
  91. package/dist/app/assets/words-CyqfIDyJ.js +2 -0
  92. package/dist/app/assets/words-T8-D0K4W.js +1 -0
  93. package/dist/app/index.html +17 -9
  94. package/dist/embed/index.d.ts +56 -0
  95. package/dist/embed/index.js +11 -0
  96. package/dist/plugin/index.js +14 -1
  97. package/dist/plugin/index.js.map +1 -1
  98. package/dist/plugin/static.js +3 -2
  99. package/dist/plugin/static.js.map +1 -1
  100. package/package.json +29 -3
  101. package/dist/app/assets/Composer-DpjCaX5G.js +0 -2
  102. package/dist/app/assets/ContextMenu-qqlGWvJT.js +0 -1
  103. package/dist/app/assets/Details-Cymq_tLr.js +0 -1
  104. package/dist/app/assets/DiffPage-CrT1Faon.js +0 -1
  105. package/dist/app/assets/Edit-KxWRJB1t.js +0 -1
  106. package/dist/app/assets/Explorer-D9lzbmtd.js +0 -1
  107. package/dist/app/assets/Explorer-h1FYBfP3.js +0 -1
  108. package/dist/app/assets/Explorer-kMkPIrYG.js +0 -1
  109. package/dist/app/assets/FilePage-CWjlubpU.js +0 -1
  110. package/dist/app/assets/Filter-y-cAyV5s.js +0 -1
  111. package/dist/app/assets/LocaleToggle-DtU53oIZ.js +0 -1
  112. package/dist/app/assets/LoginForm-CoxoSwG-.js +0 -1
  113. package/dist/app/assets/Markdown-BaxWPZc1.js +0 -4
  114. package/dist/app/assets/MarkdownPage-CNUmYD-d.js +0 -1
  115. package/dist/app/assets/MountTitle-hWvATFel.js +0 -1
  116. package/dist/app/assets/New-CWi2ZODd.js +0 -3
  117. package/dist/app/assets/Page-BXwzlAyC.js +0 -2
  118. package/dist/app/assets/Page-BlQx3M_Q.js +0 -1
  119. package/dist/app/assets/Page-DXYj-sYk.js +0 -1
  120. package/dist/app/assets/Pagination-FSzhBpDU.js +0 -1
  121. package/dist/app/assets/PortaLock-Dvr-6D1r.js +0 -2
  122. package/dist/app/assets/Settings--Ciusotp.js +0 -1
  123. package/dist/app/assets/SingleLayout-CmIAtyIo.js +0 -1
  124. package/dist/app/assets/StatusDot-BwqhMthP.js +0 -1
  125. package/dist/app/assets/changeset-BY8dw-V-.js +0 -1
  126. package/dist/app/assets/composer-commands-Bpp7NX4E.js +0 -2
  127. package/dist/app/assets/data-Fkj0LNnG.js +0 -2
  128. package/dist/app/assets/diff-eyYjrmkY.js +0 -3
  129. package/dist/app/assets/emojis-BOylxma2.js +0 -1
  130. package/dist/app/assets/index-BkzdJo_Y.js +0 -14
  131. package/dist/app/assets/index-CPXMK2aI.css +0 -1
  132. package/dist/app/assets/sessions-CEccRVtA.js +0 -2
  133. package/dist/app/assets/terminal-kD0C2LuZ.js +0 -1
  134. package/dist/app/assets/text-CmjM0Nin.js +0 -1
  135. package/dist/app/assets/useI18n-Bfix5MNN.js +0 -1
  136. package/dist/app/assets/useStoreLabel-m9cem_OG.js +0 -1
  137. package/dist/app/assets/words-BMjqrsOT.js +0 -1
  138. package/dist/app/assets/words-BknpHIF3.js +0 -1
package/README.md CHANGED
@@ -148,6 +148,17 @@ AHPD_URL=http://127.0.0.1:9187 pnpm dev # another daemon
148
148
  AHPD_URL=http://127.0.0.1:9187 pnpm dev --port 5200 # extra args go to Vite
149
149
  ```
150
150
 
151
+ To try a change in [scena](https://github.com/softov/scena) before it is released, point `AHPW_SCENA` at a scena checkout.
152
+ ahpw then uses that checkout's source instead of the installed package, in `pnpm dev`, `pnpm build` and `pnpm test`:
153
+
154
+ ```sh
155
+ AHPW_SCENA=../scena pnpm dev
156
+ ```
157
+
158
+ An app that embeds ahpw, as [ahp-desk](https://github.com/softov/ahp-desk) does, sets `globalThis.ahpwEmbedder` before ahpw's scripts run.
159
+ ahpw then takes its host and token from it instead of the address bar, and draws the window's frame when it gives one.
160
+ The contract is `src/embed/index.ts`, and its types are exported as `@ahpd/web/embed`.
161
+
151
162
  To try a local build in ahpd:
152
163
 
153
164
  ```sh
@@ -0,0 +1 @@
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./emojis-7RT6GvLa.js";import{t as r}from"./media-C3ferCB3.js";var i=t(),a=e(),o=64,s=e=>!Number.isFinite(e)||e<=0?`0:00`:`${Math.floor(e/60)}:${Math.floor(e%60).toString().padStart(2,`0`)}`;function c({url:e}){let t=(0,i.useRef)(null),[r,c]=(0,i.useState)(!1),[l,u]=(0,i.useState)(0),[d,f]=(0,i.useState)(0),[p,m]=(0,i.useState)(1),[h,g]=(0,i.useState)(!1),_=(0,i.useMemo)(()=>Array.from({length:o},(e,t)=>Math.min(100,Math.max(15,(Math.abs(Math.sin(t*.45)*.6+Math.cos(t*.9)*.4)+t%5*.06)*100))),[]),v=d>0?l/d:0,y=()=>{let e=t.current;e!==null&&(e.paused?e.play().catch(()=>g(!0)):e.pause())},b=e=>{let n=t.current;n===null||d<=0||(n.currentTime=e*d,u(n.currentTime))};return h?(0,a.jsx)(`p`,{className:`web-note web-media__note`,children:`This browser cannot play this file.`}):(0,a.jsxs)(`div`,{className:`web-audio`,children:[(0,a.jsx)(`button`,{type:`button`,className:`web-audio__play`,onClick:y,title:r?`Pause`:`Play`,children:r?n.pause:n.run}),(0,a.jsxs)(`div`,{className:`web-audio__track`,children:[(0,a.jsx)(`div`,{className:`web-audio__bars`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();b(Math.min(1,Math.max(0,(e.clientX-t.left)/t.width)))},children:_.map((e,t)=>(0,a.jsx)(`span`,{"data-played":v>=t/o?`true`:`false`,style:{height:`${e}%`}},t))}),(0,a.jsxs)(`div`,{className:`web-audio__time`,children:[(0,a.jsx)(`span`,{children:s(l)}),(0,a.jsx)(`span`,{children:s(d)})]})]}),(0,a.jsxs)(`button`,{type:`button`,className:`web-audio__rate`,onClick:()=>{let e=p>=2?.5:p+.5;t.current!==null&&(t.current.playbackRate=e),m(e)},title:`Speed`,children:[p,`x`]}),(0,a.jsx)(`audio`,{ref:t,src:e,preload:`metadata`,onPlay:()=>c(!0),onPause:()=>c(!1),onEnded:()=>c(!1),onTimeUpdate:e=>u(e.currentTarget.currentTime),onLoadedMetadata:e=>f(e.currentTarget.duration),onError:()=>g(!0)})]})}function l({uri:e}){return(0,a.jsx)(r,{uri:e,children:e=>(0,a.jsx)(c,{url:e})})}export{l as default};
@@ -0,0 +1,2 @@
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{i as n}from"./notify-CJo-T9e2.js";import{t as r,u as i}from"./useStore-BQkzWMs-.js";import{n as a}from"./ScenaProvider-6A3TJumQ.js";import{t as o}from"./Button-_R1oktDz.js";import{j as s,v as c}from"./data-CBWyZN_H.js";import{a as l,n as u}from"./words-T8-D0K4W.js";import{t as d}from"./emojis-7RT6GvLa.js";import{a as ee,i as f,n as p,o as te,r as m,s as h,t as g}from"./ActionList-aOUHK9Z9.js";import{_,a as v,d as y,f as b,g as x,h as S,i as ne,l as C,m as w,o as re,p as T,r as E,s as D,t as O,u as ie,v as k}from"./composer-commands-AmOY6XGO.js";import{n as A,t as j}from"./drag-ruzgQUFW.js";var M=e(),N=t(),P=[`/`,`@`];function F(e){let{input:t,setInput:n,caretIndex:r,panelDataContext:i,slashSlot:o=`chat:input/`,mentionSlot:s=`chat:input@`,mentionProvider:c,prefixes:l=P,onCaretChange:u}=e,d=a(),[_,v]=(0,N.useState)([]),y=(0,N.useRef)(_);y.current=_;let b=(0,N.useRef)(null),x=(0,N.useMemo)(()=>f(t,l,r),[t,l,r]),[S,ne]=(0,N.useState)(null),C=x===null?null:`${x.start}:${x.token}`,w=x!==null&&C!==S,re=(0,N.useRef)(c);re.current=c;let T=c!==void 0,E=(0,N.useCallback)(e=>re.current?.(e)??[],[]),D=(0,N.useCallback)(e=>x?.prefix===`@`?T?{provider:E,footerHints:!0,rich:!0}:{query:{slot:s,q:e},footerHints:!0,rich:!0}:{query:{slot:o,q:e},footerHints:!0,rich:!0},[x?.prefix,T,E,s,o]);(0,N.useEffect)(()=>{if(!x||!w){y.current.length>0&&v([]);return}let e=y.current[y.current.length-1];if(y.current.length<=1){v([{spec:D(x.query)}]);return}let t=e&&`spec`in e?e.spec:void 0;if(t?.sentinel&&!h(x.token,t.sentinel)){v([{spec:D(x.query)}]);return}t?.query&&v(e=>{let n=e.slice(0,-1);return n.push({spec:{...t,query:{...t.query,q:x.query}}}),n})},[x,w,D]);let O=(0,N.useMemo)(()=>{let e=_[_.length-1];return e&&`spec`in e?e.spec.sentinel:void 0},[_]),ie=(0,N.useMemo)(()=>te(x?.query??``,O),[x,O]),k=(0,N.useMemo)(()=>({pushList:e=>v(t=>[...t,{spec:e}]),replaceList:e=>v(t=>{let n=t.slice(0,-1);return n.push({spec:e}),n}),openInline:e=>v(t=>[...t,{component:(0,M.jsx)(I,{name:e})}]),openPopover:()=>void 0,back:()=>v(e=>e.length>1?e.slice(0,-1):e),closeMenu:()=>{v([]);let e=m(t,r,``,l);n(e.next),u?.(e.caret)},keepOpen:()=>void 0,insertAtCursor:e=>{let i=m(t,r,e,l);n(i.next),u?.(i.caret)},replaceActiveToken:e=>{let i=m(t,r,e,l);n(i.next),u?.(i.caret)},query:ie}),[t,r,l,n,ie,u]),A=_[_.length-1],j=(0,N.useCallback)(()=>v(e=>e.slice(0,-1)),[]),F=_.length>1?j:void 0,L=(0,N.useCallback)(e=>{if(!w)return!1;if(e.key===`Escape`)return e.preventDefault(),ne(C),v([]),!0;if(e.key===`ArrowLeft`&&F){let t=e.target;if(t.selectionStart===t.selectionEnd&&x&&t.selectionStart===x.start+x.prefix.length)return e.preventDefault(),F(),!0}return e.key===`ArrowDown`||e.key===`ArrowUp`||e.key===`Enter`||e.key===`Tab`?b.current?.handleKey(e)??!1:!1},[w,F,x,C]),R=(0,N.useCallback)(e=>{let a=d.commands.get(e);if(!a)return null;ne(null);let s=p(a.shortcut),c=null;if(s){let{next:e,caret:i}=ee(t,r,s,l);c=i,n(e),v([{spec:{query:{slot:o,q:s.replace(/^[/@]/,``)},footerHints:!0,rich:!0}}])}return d.commands.execute(e,void 0,{source:`menu`,dataContext:i,host:k}),c},[d,i,t,r,l,k,n,o]),z=(0,N.useCallback)(()=>k.closeMenu(),[k]);return{menuVisible:w,activeSentinel:O,pickerNode:A?`component`in A?A.component:(0,M.jsx)(g,{ref:b,spec:A.spec,hostCtx:k,onBack:F,dataContext:i,manageKeys:!1}):null,handleMenuKeyDown:L,openCommand:R,closeMenu:z}}function I({name:e}){return(0,M.jsxs)(`div`,{style:{padding:12},children:[`[component: `,e,`]`]})}var L=d.caretDown;function R({label:e,title:t,onOpen:n,on:r}){return(0,M.jsxs)(`button`,{type:`button`,className:`web-chip`,"data-on":r===!0?`true`:`false`,title:t,disabled:n===void 0,onClick:n,...n===void 0?{}:{"aria-haspopup":`menu`},children:[e,n===void 0?null:(0,M.jsx)(`span`,{"aria-hidden":`true`,children:L})]})}function z({label:e,title:t,value:n,options:r,onChange:i}){let a=r.find(e=>e.value===n)?.label??n;return(0,M.jsxs)(`span`,{className:`web-chip web-chip--choice`,title:t??e,children:[`${e}: ${a===``?`default`:a}`,(0,M.jsx)(`span`,{"aria-hidden":`true`,children:L}),(0,M.jsx)(`select`,{"aria-label":e,value:n,onChange:e=>i(e.currentTarget.value),children:r.map(e=>(0,M.jsx)(`option`,{value:e.value,children:e.label},e.value))})]})}function ae({label:e,title:t,value:n,onChange:r}){return(0,M.jsx)(`button`,{type:`button`,className:`web-chip`,"data-on":n?`true`:`false`,"aria-pressed":n,title:t??e,onClick:()=>r(!n),children:e})}function B({label:e,title:t,value:n,placeholder:r,onChange:i,width:a}){return(0,M.jsxs)(`span`,{className:`web-chip web-chip--text`,title:t??e,children:[e,(0,M.jsx)(`input`,{"aria-label":e,value:n,placeholder:r??``,style:{width:a??110},onChange:e=>i(e.currentTarget.value)})]})}function oe({attachments:e,folder:t,onRemove:n}){return e.length===0?null:(0,M.jsx)(`div`,{className:`web-composer__attached`,children:e.map((e,r)=>(0,M.jsxs)(`span`,{className:`web-attachment`,title:T(e,t)??b(e),children:[(0,M.jsx)(`span`,{className:`web-attachment__icon`,"aria-hidden":`true`,children:y(e)}),(0,M.jsx)(`span`,{className:`web-attachment__label`,children:b(e)}),(0,M.jsx)(`button`,{type:`button`,className:`web-attachment__remove`,"aria-label":`Remove ${b(e)}`,onClick:()=>n(r),children:d.close})]},`${b(e)}-${r}`))})}function se({onClick:e}){return(0,M.jsx)(`button`,{type:`button`,className:`web-composer__add`,"aria-label":`Add context`,title:`Add context`,onClick:e,children:(0,M.jsx)(`svg`,{width:`12`,height:`12`,viewBox:`0 0 12 12`,"aria-hidden":`true`,children:(0,M.jsx)(`path`,{d:`M6 1v10M1 6h10`,stroke:`currentColor`,strokeWidth:`1.5`,strokeLinecap:`round`})})})}function ce({attach:e,insert:t,upload:n}){let[r,i]=(0,N.useState)(null);return{dropping:r,onDragOver:e=>{let t=j(e.dataTransfer);(t||Array.from(e.dataTransfer.types).includes(`Files`))&&(e.preventDefault(),e.dataTransfer.dropEffect=`copy`,i(t&&e.shiftKey?`mention`:`attach`))},onDragLeave:e=>{e.currentTarget.contains(e.relatedTarget)||i(null)},onDrop:r=>{i(null);let a=A(r.dataTransfer);if(a!==null){r.preventDefault();let n=S(a.uri,a.directory);if(!r.shiftKey){e(n);return}let i=`@${u(a.uri)}${a.directory?`/`:``}`;t(`${i} `),e(k(n,i));return}r.dataTransfer.files.length!==0&&(r.preventDefault(),n(r.dataTransfer.files))}}}var le=`$/ahp/composerFocus`,V=e=>typeof e==`object`&&e?e:{},H=e=>typeof e==`string`&&e!==``?e:void 0;function ue(e){let t=V(e).items;return(Array.isArray(t)?t:[]).map(e=>{let t=V(e),n=V(V(t.attachment)._meta),r=H(t.insertText)??``;return{insert:r,label:H(n.command)??r,detail:H(n.description),hint:H(n.argumentHint)}}).filter(e=>e.insert!==``)}var U=e=>e.map(e=>({insert:`/${e.name}`,label:`/${e.name}`,detail:e.description===``?void 0:e.description,hint:void 0}));function de(e,t,n,r=O){return i(...n.map(n=>e.commands.register({id:`ahp.composer.host.${t}.${n.insert}`,title:n.hint===void 0?n.label:`${n.label} ${n.hint}`,...n.detail===void 0?{}:{description:n.detail},category:`Agent`,shortcut:n.label.startsWith(`/`)?n.label:`/${n.label}`,slots:[r],when:`${le} == "${t}"`,run:e=>e.host?.replaceActiveToken(`${n.insert} `)})))}var fe=0,pe=260,me=[`/`,`@`],he=800;function ge(e){e!==null&&(e.style.height=`auto`,e.style.height=`${Math.min(e.scrollHeight,pe)}px`)}function _e(e,t,n){return{text:e,origin:{kind:`user`},...t===void 0?{}:{model:{id:t}},...n.length===0?{}:{attachments:_(e,n)}}}var W=(0,N.memo)(function({chatUri:e,activeId:t,activeStart:i,queued:ee,steering:f,draft:p,lastModel:te,config:m,summary:h,send:g}){let _=a(),y=(r(`$/ahp/agents`)??[]).find(e=>e.provider===h.provider),b=(0,N.useMemo)(()=>ne(e),[e]),[S]=(0,N.useState)(()=>`composer-${++fe}`),A=h.workingDirectories?.[0],[j,P]=(0,N.useState)(()=>p?.text??``),[I,L]=(0,N.useState)(null),[z,ae]=(0,N.useState)(()=>p?.model?.id??te),[B,V]=(0,N.useState)(()=>p?.attachments??[]),H=(0,N.useRef)(null),U=t===void 0?void 0:{id:t,startedAt:i??``},pe=ee??[];(0,N.useEffect)(()=>ge(H.current),[j]);let W=(0,N.useRef)(!1);(0,N.useEffect)(()=>{if(!W.current)return;let t=window.setTimeout(()=>{let t=j.trim()===``&&B.length===0?void 0:_e(j,z,B);c(e,{type:`chat/draftChanged`,draft:t})},he);return()=>window.clearTimeout(t)},[j,z,B,e]);let G=(0,N.useCallback)(e=>{L(e),requestAnimationFrame(()=>{let t=H.current;t!==null&&(t.focus(),t.setSelectionRange(e,e))})},[]),K=(0,N.useCallback)(e=>{W.current=!0,V(t=>t.some(t=>x(t,e))?t:[...t,e])},[]),ve=(0,N.useRef)(null),ye=(0,N.useCallback)(async e=>{let t=await w(Array.from(e??[]));for(let e of t.attached)K(e);t.refused.length>0&&n(`Not attached`,{description:`Over 5 MB or unreadable: ${t.refused.join(`, `)}`})},[K]),q=ce({attach:K,insert:(0,N.useCallback)(e=>{let t=Y.current??J.current.length,n=J.current.slice(0,t),r=n===``||/\s$/.test(n)?``:` `;W.current=!0,P(`${n}${r}${e}${J.current.slice(t)}`),G(n.length+r.length+e.length)},[G]),upload:e=>void ye(e)}),J=(0,N.useRef)(j);J.current=j;let Y=(0,N.useRef)(I);Y.current=I;let be=(0,N.useCallback)(async()=>{let t=J.current;try{return(await s(`completions`,{kind:`userMessage`,channel:e,text:t,offset:Y.current??t.length})).items.map(e=>{let t=T(e.attachment,A);return{title:e.insertText.replace(/^@/,``),...t===void 0?{}:{description:t},onSelect:t=>{t.replaceActiveToken(`${e.insertText} `),K(k(e.attachment,e.insertText))}}})}catch{return[]}},[e,A,K]),[xe,Se]=(0,N.useState)([]);(0,N.useEffect)(()=>{let t=!0;return s(`completions`,{kind:`userMessage`,channel:e,text:`/`,offset:1}).then(e=>{t&&Se(ue(e))}).catch(()=>{t&&Se([])}),()=>{t=!1}},[e]),(0,N.useEffect)(()=>{let e=de(_,S,xe);return()=>e.dispose()},[_,S,xe]);let X=F({input:j,setInput:P,caretIndex:I,panelDataContext:b,slashSlot:O,prefixes:me,mentionProvider:be,onCaretChange:G}),Z=(0,N.useMemo)(()=>Object.entries(m?.schema.properties??{}).filter(([,e])=>e.sessionMutable===!0&&e.readOnly!==!0).map(([e,t])=>({key:e,schema:t,value:m?.values[e]})),[m]),Ce=(0,N.useCallback)(()=>{if(t===void 0)return;let e=Date.parse(i??``);g({type:`chat/turnCancelled`,turnId:t,duration:Number.isNaN(e)?0:Math.max(0,Date.now()-e)})},[t,i,g]),we=(0,N.useMemo)(()=>(y?.models??[]).map(e=>({id:e.id,name:e.name})),[y]),Q=(0,N.useRef)(null);Q.current={models:()=>we,model:()=>z,setModel:e=>{W.current=!0,ae(e)},options:()=>Z,setOption:(e,t)=>{c(h.resource,{type:`session/configChanged`,config:{[e]:t}})},running:()=>U!==void 0,stop:Ce,session:()=>h.resource,attach:K,type:e=>{let t=Y.current??J.current.length,n=J.current.slice(0,t),r=e===`/`||n===``||/\s$/.test(n)?``:` `,i=e===`/`&&n.trim()===``?`/${J.current.slice(t)}`:`${n}${r}${e}${J.current.slice(t)}`,a=e===`/`&&n.trim()===``?1:n.length+r.length+1;W.current=!0,P(i),G(a)},upload:()=>ve.current?.click()},(0,N.useEffect)(()=>E(b,{models:()=>Q.current?.models()??[],model:()=>Q.current?.model(),setModel:e=>Q.current?.setModel(e),options:()=>Q.current?.options()??[],setOption:(e,t)=>Q.current?.setOption(e,t),running:()=>Q.current?.running()??!1,stop:()=>Q.current?.stop(),session:()=>Q.current?.session()??``,attach:e=>Q.current?.attach(e),type:e=>Q.current?.type(e),upload:()=>Q.current?.upload()}),[b]);let Te=Z.map(e=>e.key).join(`
2
+ `);(0,N.useEffect)(()=>{let e=C(_,Z);return()=>e.dispose()},[_,Te]);function Ee(e){let t=X.openCommand(e);G(t??H.current?.value.length??j.length)}function De(){P(``),V([]),W.current=!1,c(e,{type:`chat/draftChanged`,draft:void 0})}function $(e){let t=j.trim();if(t===``)return;let n=_e(t,z,B);g(U===void 0?{type:`chat/turnStarted`,turnId:l(),startedAt:new Date().toISOString(),message:n}:e===`steer`?{type:`chat/pendingMessageSet`,kind:`steering`,id:l(),message:n}:{type:`chat/pendingMessageSet`,kind:`queued`,id:l(),message:n}),De()}let Oe=we.find(e=>e.id===z)?.name??z;return(0,M.jsxs)(`div`,{className:`web-composer`,children:[X.pickerNode===null?null:(0,M.jsx)(`div`,{className:`web-composer__picker`,children:X.pickerNode}),f===void 0&&pe.length===0?null:(0,M.jsxs)(`ul`,{className:`web-composer__queue`,children:[f===void 0?null:(0,M.jsxs)(`li`,{children:[(0,M.jsx)(`span`,{className:`web-chip`,"data-on":`true`,children:`Steering`}),(0,M.jsx)(`span`,{className:`web-composer__queued`,children:f.message.text}),(0,M.jsx)(o,{label:`Remove`,size:`sm`,onClick:()=>g({type:`chat/pendingMessageRemoved`,kind:`steering`,id:f.id})})]}),pe.map((e,t)=>(0,M.jsxs)(`li`,{children:[(0,M.jsxs)(`span`,{className:`web-chip`,children:[`Next `,t+1]}),(0,M.jsx)(`span`,{className:`web-composer__queued`,children:e.message.text}),(0,M.jsx)(o,{label:`Remove`,size:`sm`,onClick:()=>g({type:`chat/pendingMessageRemoved`,kind:`queued`,id:e.id})})]},e.id))]}),(0,M.jsxs)(`div`,{className:`web-composer__where`,children:[A===void 0?null:(0,M.jsx)(R,{label:`${d.folder} ${u(A)}`,title:`The folder this session works in`}),(0,M.jsx)(R,{label:`${d.agents} ${y?.displayName??h.provider}`,title:y?.description??`The agent running this session`})]}),(0,M.jsxs)(`div`,{className:`web-composer__box`,"data-drop":q.dropping??void 0,onDragOver:q.onDragOver,onDragLeave:q.onDragLeave,onDrop:q.onDrop,children:[(0,M.jsx)(oe,{attachments:B,folder:A,onRemove:e=>{W.current=!0,V(t=>t.filter((t,n)=>n!==e))}}),(0,M.jsx)(`div`,{className:`web-composer__bar`,children:(0,M.jsx)(`textarea`,{ref:H,className:`web-composer__text`,rows:1,value:j,"aria-label":`Message`,placeholder:U===void 0?`Message the agent, / for commands, @ to refer to a file`:`Queue a message for after this turn, or steer it`,onChange:e=>{W.current=!0,P(e.currentTarget.value),L(e.currentTarget.selectionStart)},onFocus:()=>_.store.set(le,S),onKeyUp:e=>L(e.currentTarget.selectionStart),onClick:e=>L(e.currentTarget.selectionStart),onKeyDown:e=>{if(!X.handleMenuKeyDown(e)){if(e.key===`Escape`&&U!==void 0){e.preventDefault(),Ce();return}e.key===`Enter`&&!e.shiftKey&&!e.nativeEvent.isComposing&&(e.preventDefault(),$(e.altKey?`steer`:`send`))}}})}),(0,M.jsxs)(`div`,{className:`web-composer__foot`,children:[(0,M.jsx)(se,{onClick:()=>Ee(`ahp.composer.attach`)}),(0,M.jsx)(`input`,{ref:ve,type:`file`,multiple:!0,hidden:!0,onChange:e=>{ye(e.currentTarget.files),e.currentTarget.value=``}}),(0,M.jsxs)(`div`,{className:`web-composer__chips`,children:[we.length===0?null:(0,M.jsx)(R,{label:`Model: ${Oe??`default`}`,title:`The model the next message goes to`,onOpen:()=>Ee(`ahp.composer.model`)}),Z.filter(ie).map(e=>(0,M.jsx)(R,{label:`${e.schema.title||e.key}: ${re(e)}`,title:e.schema.description??e.schema.title,...e.schema.type===`boolean`?{on:(e.value??e.schema.default)===!0}:{},...D(e.schema)?{onOpen:()=>Ee(v(e.key))}:{}},e.key))]}),U===void 0||j.trim()===``?null:(0,M.jsx)(o,{label:`Steer`,size:`sm`,title:`Alt+Enter steers`,onClick:()=>$(`steer`)}),U===void 0||j.trim()===``?null:(0,M.jsx)(o,{label:`Queue`,variant:`primary`,size:`sm`,title:`Enter queues`,onClick:()=>$(`send`)}),U===void 0?(0,M.jsx)(`button`,{type:`button`,className:`web-composer__round`,"aria-label":`Send`,title:`Enter sends, Shift+Enter breaks the line`,disabled:j.trim()===``,onClick:()=>$(`send`),children:d.send}):(0,M.jsx)(`button`,{type:`button`,className:`web-composer__round`,"aria-label":`Stop`,title:`Esc stops`,onClick:Ce,children:d.stop})]})]})]})});export{U as a,se as c,R as d,B as f,le as i,oe as l,F as m,ge as n,de as o,ae as p,_e as r,ce as s,W as t,z as u};
@@ -0,0 +1 @@
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{n}from"./ScenaProvider-6A3TJumQ.js";import{t as r}from"./ActionList-aOUHK9Z9.js";var i=e(),a=t();function o({x:e,y:t,onClose:n,closeOnOutsideClick:r=!0,closeOnEscape:o=!0,className:s,style:c,children:l}){let u=(0,a.useRef)(null),[d,f]=(0,a.useState)({left:e,top:t});return(0,a.useLayoutEffect)(()=>{let n=u.current;if(!n)return;let r=()=>{let r=n.getBoundingClientRect(),i=Math.max(4,window.innerWidth-r.width-4),a=Math.max(4,window.innerHeight-r.height-4),o=Math.max(4,Math.min(e,i)),s=Math.max(4,Math.min(t,a));f(e=>e.left===o&&e.top===s?e:{left:o,top:s})};r(),window.addEventListener(`resize`,r);let i=typeof ResizeObserver>`u`?null:new ResizeObserver(r);return i?.observe(n),()=>{window.removeEventListener(`resize`,r),i?.disconnect()}},[e,t]),(0,a.useEffect)(()=>{if(!r||!n)return;let e=!0;function t(t){e&&u.current&&(u.current.contains(t.target)||n?.())}let i=setTimeout(()=>{e&&document.addEventListener(`mousedown`,t)},0);return()=>{e=!1,clearTimeout(i),document.removeEventListener(`mousedown`,t)}},[r,n]),(0,a.useEffect)(()=>{if(!o||!n)return;function e(e){e.key===`Escape`&&(e.preventDefault(),n?.())}return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[o,n]),(0,i.jsx)(`div`,{ref:u,className:[`oo-popup`,s].filter(Boolean).join(` `),style:{position:`fixed`,left:d.left,top:d.top,zIndex:9999,maxHeight:`calc(100vh - 8px)`,overflowY:`auto`,...c},onMouseDown:e=>e.stopPropagation(),children:l})}function s({spec:e,x:t,y:s,onClose:u,context:d,dataContext:f,inline:p}){let m=n(),[h,g]=(0,a.useState)(()=>p?[{component:p.component}]:[{spec:e}]),_=(0,a.useRef)(h);_.current=h;let v=(0,a.useRef)(!1);if(d&&!v.current){for(let[e,t]of Object.entries(d)){let n=e.startsWith(`$/`)?e:c(f,e);m.store.set(n,t)}v.current=!0}let y=(0,a.useMemo)(()=>({pushList:e=>g(t=>[...t,{spec:e}]),replaceList:e=>g(t=>{let n=t.slice(0,-1);return n.push({spec:e}),n}),openInline:(e,t)=>{g(n=>[...n,{component:(0,i.jsx)(l,{name:e,props:t})}])},openPopover:()=>{},back:()=>g(e=>e.length>1?e.slice(0,-1):e),closeMenu:u,keepOpen:()=>void 0,insertAtCursor:()=>void 0,replaceActiveToken:()=>void 0,query:``}),[u]),b=h[h.length-1],x=h.length>1?y.back:void 0;return(0,i.jsx)(o,{x:t,y:s,onClose:u,children:`component`in b?b.component:(0,i.jsx)(r,{spec:b.spec,hostCtx:y,onBack:x,dataContext:f})})}function c(e,t){return t.startsWith(`$/`)?t:e?`${e.endsWith(`/`)?e.slice(0,-1):e}${t.startsWith(`/`)?t:`/${t}`}`:t.startsWith(`/`)?`$${t}`:`$/${t}`}function l({name:e,props:t}){return(0,i.jsxs)(`div`,{style:{padding:12},children:[`[component: `,e,`]`]})}export{s as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./emojis-7RT6GvLa.js";var r=t(),i=e(),a=1200;function o(e){let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();try{return document.execCommand(`copy`)}catch{return!1}finally{t.remove()}}function s({text:e,label:t=`Copy`,icon:s=n.copy}){let[c,l]=(0,r.useState)(!1),u=(0,r.useRef)(void 0);(0,r.useEffect)(()=>()=>window.clearTimeout(u.current),[]);let d=()=>{l(!0),window.clearTimeout(u.current),u.current=window.setTimeout(()=>l(!1),a)},f=()=>{if(navigator.clipboard===void 0){o(e)&&d();return}navigator.clipboard.writeText(e).then(d).catch(()=>{o(e)&&d()})},p=c?`Copied`:t;return(0,i.jsx)(`button`,{type:`button`,className:`web-copy`,"data-copied":c?`true`:`false`,title:p,"aria-label":p,onClick:f,children:c?n.check:s})}export{s as t};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./ContextMenu-qqlGWvJT.js";var r=t(),i=e();function a(e,t){if(typeof e==`object`&&e)return e[t]}function o(e,t,n){let r=a(e,n),i=a(t,n);return r==null&&i==null?0:r==null?-1:i==null?1:typeof r==`number`&&typeof i==`number`?r-i:String(r).localeCompare(String(i))}function s(e,t,n){if(!n)return e;let r=t.find(e=>e.key===n.key);if(!r||!r.sortable)return e;let i=typeof r.sortable==`function`?r.sortable:(e,t)=>o(e,t,r.key),a=n.direction===`asc`?1:-1;return[...e].sort((e,t)=>a*i(e,t))}var c=480;function l({items:e,columns:t,getKey:a,title:o,toolbar:l,selectedKey:d,onSelect:f,onActivate:p,initialSort:m,sort:h,onSortChange:g,tableBreakpoint:_=c,renderListRow:v,getRowStyle:y,contextMenuSlot:b,contextFor:x,contextDataContext:S,onRowDragStart:C,emptyState:w,className:T,style:E,manageKeys:D=!1}){let O=(0,r.useRef)(null),[k,A]=(0,r.useState)(0),[j,M]=(0,r.useState)(m??null);(0,r.useEffect)(()=>{let e=O.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&A(e.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]);let N=k>=_,P=h!==void 0,F=P?h:j,I=(0,r.useMemo)(()=>t.filter(e=>!e.hidden&&(N||e.mode!==`table`)&&(e.showAt==null||k>=e.showAt)),[t,N,k]),L=(0,r.useMemo)(()=>({tableMode:N,containerWidth:k}),[N,k]),R=(0,r.useMemo)(()=>I.map(e=>typeof e.width==`function`?e.width(L):e.width).map(e=>e??`minmax(0, 1fr)`).join(` `),[I,L]),z=(0,r.useMemo)(()=>s(e,t,F??null),[e,t,F]);function B(e){if(!e.sortable)return;let t=F,n=!t||t.key!==e.key?{key:e.key,direction:`asc`}:t.direction===`asc`?{key:e.key,direction:`desc`}:null;P?g?.(n):M(n)}(0,r.useEffect)(()=>{if(!d||!O.current)return;let e=O.current.querySelector(`[data-key="${u(d)}"]`);e&&e.scrollIntoView({block:`nearest`})},[d]);let V=d?z.findIndex(e=>a(e)===d):-1;function H(e){if(z.length===0)return;let t=V>=0?V:0;switch(e.key){case`ArrowDown`:{e.preventDefault();let n=z[Math.min(z.length-1,t+1)];n&&f?.(n);return}case`ArrowUp`:{e.preventDefault();let n=z[Math.max(0,t-1)];n&&f?.(n);return}case`Enter`:case` `:{e.preventDefault();let n=z[t];n&&p?.(n);return}}}let[U,W]=(0,r.useState)(null);function G(e,t){b&&(e.preventDefault(),e.stopPropagation(),W({x:e.clientX,y:e.clientY,item:t}))}function K(e,t){let n=e.cellProps?.(t,L),r=e.style===void 0&&n?.style===void 0?void 0:{...e.style,...n?.style};return(0,i.jsx)(`div`,{role:`cell`,className:n?.className===void 0?`oo-listable__cell`:`oo-listable__cell ${n.className}`,"data-align":e.align??`left`,title:e.titleProps?.(t,L).title,style:r,children:J(e,t)},e.key)}function q(e){let t=F?.key===e.key,n=e.titleProps?.(void 0,L);return(0,i.jsx)(`div`,{role:`columnheader`,className:n?.className===void 0?`oo-listable__head-cell`:`oo-listable__head-cell ${n.className}`,"data-align":e.align??`left`,"data-sortable":e.sortable?`true`:void 0,"data-sorted":t?F.direction:void 0,title:e.sortable&&typeof e.label==`string`?`Sort by ${e.label}`:void 0,onClick:e.sortable?()=>B(e):void 0,style:n?.style,children:n?.hidden===!0?null:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{className:`oo-listable__head-label`,children:e.label}),t?(0,i.jsx)(`span`,{className:`oo-listable__sort-arrow`,"aria-hidden":`true`,children:F.direction===`asc`?`▲`:`▼`}):null]})},e.key)}function J(e,t){return e.visible&&!e.visible(t)?null:e.render(t,L)}function Y(e){let t=a(e);return(0,i.jsx)(`div`,{role:`row`,"data-key":t,"data-selected":t===d?`true`:void 0,className:`oo-listable__item oo-listable__row`,draggable:C?!0:void 0,onDragStart:C?t=>C(t,e):void 0,onClick:()=>{f?.(e)},onDoubleClick:()=>p?.(e),onContextMenu:t=>G(t,e),style:{cursor:f?`pointer`:void 0},children:I.map(t=>K(t,e))},t)}function X(e){let t=a(e),n=t===d,r=y?y(e,L):void 0;return(0,i.jsx)(`div`,{role:`row`,"data-key":t,"data-selected":n?`true`:void 0,className:`oo-listable__item oo-listable__stack`,draggable:C?!0:void 0,onDragStart:C?t=>C(t,e):void 0,onClick:()=>f?.(e),onDoubleClick:()=>p?.(e),onContextMenu:t=>G(t,e),style:{cursor:f?`pointer`:void 0,...r},children:v?v(e):I.map(t=>{let n=J(t,e);if(n==null)return null;let r=t.cellProps?.(e,L);return(0,i.jsx)(`div`,{className:r?.className===void 0?`oo-listable__list-cell`:`oo-listable__list-cell ${r.className}`,title:t.titleProps?.(e,L).title,style:t.style===void 0&&r?.style===void 0?void 0:{...t.style,...r?.style},children:(0,i.jsx)(`span`,{className:`oo-listable__list-value`,children:n})},t.key)})},t)}return(0,i.jsxs)(`div`,{ref:O,role:`table`,tabIndex:0,className:[`oo-listable`,T].filter(Boolean).join(` `),"data-mode":N?`table`:`list`,style:E,onKeyDown:D?H:void 0,children:[o||l?(0,i.jsxs)(`header`,{className:`oo-listable__header`,children:[o?(0,i.jsx)(`h2`,{className:`oo-listable__title`,children:o}):null,l]}):null,z.length===0?(0,i.jsx)(`div`,{className:`oo-listable__empty`,children:w??`Empty`}):(0,i.jsxs)(`div`,{className:`oo-listable__rows`,role:`rowgroup`,style:N?{"--oo-listable-template":R}:void 0,children:[N?(0,i.jsx)(`div`,{role:`row`,className:`oo-listable__head-row`,children:I.map(e=>q(e))}):null,z.map(e=>N?Y(e):X(e))]}),U&&b?(0,i.jsx)(n,{x:U.x,y:U.y,onClose:()=>W(null),spec:{query:{slot:b},footerHints:!0},context:x?x(U.item):void 0,dataContext:S}):null]})}function u(e){return e.replace(/(["\\\]])/g,`\\$1`)}function d(e){return e==null?``:typeof e==`object`?JSON.stringify(e):String(e)}function f({columns:e,rows:t,rowKey:n=`id`,caption:r,selectedKey:a,onSelect:o,onActivate:s,emptyState:c}){let u=e.map(e=>({key:e.key,label:e.label??e.key,width:e.width,align:e.align,sortable:!0,render:t=>d(t[e.key])}));return(0,i.jsx)(l,{items:t,columns:u,getKey:e=>String(e[n]??``),title:r,selectedKey:a,onSelect:o,onActivate:s,emptyState:c})}export{f as DataTable};
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./ContextMenu-BV1gdog0.js";var r=t(),i=e();function a(e,t){if(typeof e==`object`&&e)return e[t]}function o(e,t,n){let r=a(e,n),i=a(t,n);return r==null&&i==null?0:r==null?-1:i==null?1:typeof r==`number`&&typeof i==`number`?r-i:String(r).localeCompare(String(i))}function s(e,t,n){if(!n)return e;let r=t.find(e=>e.key===n.key);if(!r||!r.sortable)return e;let i=typeof r.sortable==`function`?r.sortable:(e,t)=>o(e,t,r.key),a=n.direction===`asc`?1:-1;return[...e].sort((e,t)=>a*i(e,t))}var c=480;function l({items:e,columns:t,getKey:a,title:o,toolbar:l,selectedKey:d,onSelect:f,onActivate:p,initialSort:m,sort:h,onSortChange:g,tableBreakpoint:_=c,renderListRow:v,getRowStyle:y,contextMenuSlot:b,contextFor:x,contextDataContext:S,onRowDragStart:C,emptyState:w,className:T,style:E,manageKeys:D=!1}){let O=(0,r.useRef)(null),[k,A]=(0,r.useState)(0),[j,M]=(0,r.useState)(m??null);(0,r.useEffect)(()=>{let e=O.current;if(!e)return;let t=new ResizeObserver(([e])=>{e&&A(e.contentRect.width)});return t.observe(e),()=>t.disconnect()},[]);let N=k>=_,P=h!==void 0,F=P?h:j,I=(0,r.useMemo)(()=>t.filter(e=>!e.hidden&&(N||e.mode!==`table`)&&(e.showAt==null||k>=e.showAt)),[t,N,k]),L=(0,r.useMemo)(()=>({tableMode:N,containerWidth:k}),[N,k]),R=(0,r.useMemo)(()=>I.map(e=>typeof e.width==`function`?e.width(L):e.width).map(e=>e??`minmax(0, 1fr)`).join(` `),[I,L]),z=(0,r.useMemo)(()=>s(e,t,F??null),[e,t,F]);function B(e){if(!e.sortable)return;let t=F,n=!t||t.key!==e.key?{key:e.key,direction:`asc`}:t.direction===`asc`?{key:e.key,direction:`desc`}:null;P?g?.(n):M(n)}(0,r.useEffect)(()=>{if(!d||!O.current)return;let e=O.current.querySelector(`[data-key="${u(d)}"]`);e&&e.scrollIntoView({block:`nearest`})},[d]);let V=d?z.findIndex(e=>a(e)===d):-1;function H(e){if(z.length===0)return;let t=V>=0?V:0;switch(e.key){case`ArrowDown`:{e.preventDefault();let n=z[Math.min(z.length-1,t+1)];n&&f?.(n);return}case`ArrowUp`:{e.preventDefault();let n=z[Math.max(0,t-1)];n&&f?.(n);return}case`Enter`:case` `:{e.preventDefault();let n=z[t];n&&p?.(n);return}}}let[U,W]=(0,r.useState)(null);function G(e,t){b&&(e.preventDefault(),e.stopPropagation(),W({x:e.clientX,y:e.clientY,item:t}))}function K(e,t){let n=e.cellProps?.(t,L),r=e.style===void 0&&n?.style===void 0?void 0:{...e.style,...n?.style};return(0,i.jsx)(`div`,{role:`cell`,className:n?.className===void 0?`oo-listable__cell`:`oo-listable__cell ${n.className}`,"data-align":e.align??`left`,title:e.titleProps?.(t,L).title,style:r,children:J(e,t)},e.key)}function q(e){let t=F?.key===e.key,n=e.titleProps?.(void 0,L);return(0,i.jsx)(`div`,{role:`columnheader`,className:n?.className===void 0?`oo-listable__head-cell`:`oo-listable__head-cell ${n.className}`,"data-align":e.align??`left`,"data-sortable":e.sortable?`true`:void 0,"data-sorted":t?F.direction:void 0,title:e.sortable&&typeof e.label==`string`?`Sort by ${e.label}`:void 0,onClick:e.sortable?()=>B(e):void 0,style:n?.style,children:n?.hidden===!0?null:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(`span`,{className:`oo-listable__head-label`,children:e.label}),t?(0,i.jsx)(`span`,{className:`oo-listable__sort-arrow`,"aria-hidden":`true`,children:F.direction===`asc`?`▲`:`▼`}):null]})},e.key)}function J(e,t){return e.visible&&!e.visible(t)?null:e.render(t,L)}function Y(e){let t=a(e);return(0,i.jsx)(`div`,{role:`row`,"data-key":t,"data-selected":t===d?`true`:void 0,className:`oo-listable__item oo-listable__row`,draggable:C?!0:void 0,onDragStart:C?t=>C(t,e):void 0,onClick:()=>{f?.(e)},onDoubleClick:()=>p?.(e),onContextMenu:t=>G(t,e),style:{cursor:f?`pointer`:void 0},children:I.map(t=>K(t,e))},t)}function X(e){let t=a(e),n=t===d,r=y?y(e,L):void 0;return(0,i.jsx)(`div`,{role:`row`,"data-key":t,"data-selected":n?`true`:void 0,className:`oo-listable__item oo-listable__stack`,draggable:C?!0:void 0,onDragStart:C?t=>C(t,e):void 0,onClick:()=>f?.(e),onDoubleClick:()=>p?.(e),onContextMenu:t=>G(t,e),style:{cursor:f?`pointer`:void 0,...r},children:v?v(e):I.map(t=>{let n=J(t,e);if(n==null)return null;let r=t.cellProps?.(e,L);return(0,i.jsx)(`div`,{className:r?.className===void 0?`oo-listable__list-cell`:`oo-listable__list-cell ${r.className}`,title:t.titleProps?.(e,L).title,style:t.style===void 0&&r?.style===void 0?void 0:{...t.style,...r?.style},children:(0,i.jsx)(`span`,{className:`oo-listable__list-value`,children:n})},t.key)})},t)}return(0,i.jsxs)(`div`,{ref:O,role:`table`,tabIndex:0,className:[`oo-listable`,T].filter(Boolean).join(` `),"data-mode":N?`table`:`list`,style:E,onKeyDown:D?H:void 0,children:[o||l?(0,i.jsxs)(`header`,{className:`oo-listable__header`,children:[o?(0,i.jsx)(`h2`,{className:`oo-listable__title`,children:o}):null,l]}):null,z.length===0?(0,i.jsx)(`div`,{className:`oo-listable__empty`,children:w??`Empty`}):(0,i.jsxs)(`div`,{className:`oo-listable__rows`,role:`rowgroup`,style:N?{"--oo-listable-template":R}:void 0,children:[N?(0,i.jsx)(`div`,{role:`row`,className:`oo-listable__head-row`,children:I.map(e=>q(e))}):null,z.map(e=>N?Y(e):X(e))]}),U&&b?(0,i.jsx)(n,{x:U.x,y:U.y,onClose:()=>W(null),spec:{query:{slot:b},footerHints:!0},context:x?x(U.item):void 0,dataContext:S}):null]})}function u(e){return e.replace(/(["\\\]])/g,`\\$1`)}function d(e){return e==null?``:typeof e==`object`?JSON.stringify(e):String(e)}function f({columns:e,rows:t,rowKey:n=`id`,caption:r,selectedKey:a,onSelect:o,onActivate:s,emptyState:c}){let u=e.map(e=>({key:e.key,label:e.label??e.key,width:e.width,align:e.align,sortable:!0,render:t=>d(t[e.key])}));return(0,i.jsx)(l,{items:t,columns:u,getKey:e=>String(e[n]??``),title:r,selectedKey:a,onSelect:o,onActivate:s,emptyState:c})}export{f as DataTable};
@@ -0,0 +1 @@
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{Z as i,c as a,it as o,o as s}from"./data-CBWyZN_H.js";import{n as c,t as l}from"./words-T8-D0K4W.js";import{i as u,s as d}from"./terminal-BMZxY-St.js";import{t as f}from"./state-KGSq646f.js";import{a as p,i as m,r as h}from"./turn-BoF7W1h6.js";import{t as g}from"./channel-8aIcEm3f.js";var _=t(),v=e();function y({uri:e,folder:t}){let n=r(),{state:i}=g(e,u);return d(i?.cwd,t)?(0,v.jsx)(`button`,{type:`button`,className:`web-link`,title:`Open the terminal`,onClick:()=>void n.commands.execute(`ahp.openTerminal`,{uri:e}),children:i?.title===``||i?.title===void 0?`Terminal`:i.title}):null}function b(){let e=r(),t=n(s),u=n(f),d=n(a)?.find(e=>e.resource===u),b=g(d===void 0?void 0:u,o),x=g(b.state?.defaultChat??d?.defaultChat,i),S=x.state?.turns,C=(0,_.useMemo)(()=>m(S??[]),[S]);if(d===void 0)return(0,v.jsx)(`p`,{className:`web-note web-details__empty`,children:`Open a session to see its details.`});let w=d.workingDirectories?.[0],T=d.changes,E=d.origin,D=b.state?.activeClients.length??0,O=b.state?.defaultChat??d.defaultChat,k=[[`Session`,d.title===``?`Untitled`:d.title],[`Session id`,(0,v.jsx)(`code`,{children:d.resource},`s`)]];return O!==void 0&&k.push([`Chat id`,(0,v.jsx)(`code`,{children:O},`h`)]),k.push([`Agent`,d.provider]),C.models.length>0&&k.push([`Model`,C.models.join(`, `)]),w!==void 0&&k.push([`Folder`,(0,v.jsx)(`button`,{type:`button`,className:`web-link`,title:`Show the folder in the explorer`,onClick:()=>void e.commands.execute(`ahp.revealFolder`,{uri:w}),children:(0,v.jsx)(`code`,{children:c(w)})},`f`)]),k.push([`Terminal`,(0,v.jsxs)(`span`,{className:`web-details__list`,children:[w===void 0?null:(t?.terminals??[]).map(e=>(0,v.jsx)(y,{uri:e.resource,folder:w},e.resource)),(0,v.jsx)(`button`,{type:`button`,className:`web-link`,title:w===void 0?`A new terminal`:`A new terminal in the session's folder`,onClick:()=>void e.commands.execute(`ahp.newTerminal`,w===void 0?void 0:{cwd:w}),children:`+ New terminal`})]},`t`)]),d.project!==void 0&&k.push([`Project`,d.project.displayName]),k.push([`Started`,p(d.createdAt)],[`Changed`,p(d.modifiedAt)]),C.turns>0&&(k.push([`Turns`,`${C.turns}${x.state?.turnsNextCursor===void 0?``:`+`}`]),k.push([`Working`,l(C.working)]),k.push([`Tokens`,`\u{2191}${h(C.input)} \u{2193}${h(C.output)}`]),C.tools>0&&k.push([`Tool calls`,String(C.tools)])),T!==void 0&&(T.additions!==void 0||T.deletions!==void 0)&&k.push([`Changes`,(0,v.jsxs)(`span`,{children:[(0,v.jsxs)(`span`,{className:`web-diff--add`,children:[`+`,T.additions??0]}),` `,(0,v.jsxs)(`span`,{className:`web-diff--remove`,children:[`-`,T.deletions??0]}),T.files===void 0?``:` in ${T.files} files`]},`c`)]),E!==void 0&&String(E.kind)===`automation`&&k.push([`From`,`An automation run`]),D>0&&k.push([`Watching`,String(D)]),(0,v.jsx)(`dl`,{className:`web-details`,children:k.map(([e,t])=>(0,v.jsxs)(`div`,{children:[(0,v.jsx)(`dt`,{children:e}),(0,v.jsx)(`dd`,{children:t})]},e))})}export{b as default};
@@ -0,0 +1,3 @@
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{n}from"./ScenaProvider-6A3TJumQ.js";import{t as r}from"./Button-_R1oktDz.js";import{D as i}from"./data-CBWyZN_H.js";import{n as a}from"./words-T8-D0K4W.js";import{t as o}from"./Spinner-B-iOhBZq.js";import{t as s}from"./Alert-CHZkhmDE.js";import{a as c,r as l,t as u}from"./changeset-BgSW341C.js";var d=t(),f=3;function p(e){return e===``?[]:(e.endsWith(`
2
+ `)?e.slice(0,-1):e).split(`
3
+ `)}function m(e,t){return e.length===t.length&&e.every((e,n)=>e===t[n])}function h(e){if(e.length===0)return[];let t=[],n=Array(e.length).fill(-1);for(let r=0;r<e.length;r+=1){let i=e[r],a=0,o=t.length;for(;a<o;){let n=a+o>>1;e[t[n]]<i?a=n+1:o=n}n[r]=a>0?t[a-1]:-1,t[a]=r}let r=[],i=t.length>0?t[t.length-1]:-1;for(;i>=0;)r.push(i),i=n[i];return r.reverse()}function g(e,t){let n=new Map;for(let t of e)n.set(t,(n.get(t)??0)+1);let r=new Map;for(let e of t)r.set(e,(r.get(e)??0)+1);let i=new Map;t.forEach((e,t)=>{n.get(e)===1&&r.get(e)===1&&i.set(e,t)});let a=[];return e.forEach((e,t)=>{let n=i.get(e);n!==void 0&&a.push({a:t,b:n})}),a}function _(e,t,n,r){let i=[];return e.forEach((e,t)=>i.push({kind:`del`,before:n+t+1,after:null,text:e})),t.forEach((e,t)=>i.push({kind:`add`,before:null,after:r+t+1,text:e})),i}var v=24;function y(e,t,n,r,i){if(e.length===0&&t.length===0)return[];if(m(e,t))return e.map((e,t)=>({kind:`context`,before:n+t+1,after:r+t+1,text:e}));if(e.length===0||t.length===0||i>=v)return _(e,t,n,r);let a=g(e,t);if(a.length===0)return _(e,t,n,r);let o=h(a.map(e=>e.b)).map(e=>a[e]);if(o.length===0)return _(e,t,n,r);let s=[],c=0,l=0;for(let a of o)s.push(...y(e.slice(c,a.a),t.slice(l,a.b),n+c,r+l,i+1)),s.push({kind:`context`,before:n+a.a+1,after:r+a.b+1,text:e[a.a]}),c=a.a+1,l=a.b+1;return s.push(...y(e.slice(c),t.slice(l),n+c,r+l,i+1)),s}function b(e,t,n=f){let r=y(p(e),p(t),0,0,0),i=r.map((e,t)=>e.kind===`context`?-1:t).filter(e=>e>=0);if(i.length===0)return[];let a=[];for(let e of i){let t=a[a.length-1];t!==void 0&&e-t.to<=n*2?t.to=e:a.push({from:e,to:e})}return a.map(e=>{let t=Math.max(0,e.from-n),i=Math.min(r.length-1,e.to+n),a=r.slice(t,i+1),o=a[0],s=o.before??o.after??1,c=o.after??o.before??1;return{beforeStart:a.some(e=>e.before!==null)?s:0,beforeCount:a.filter(e=>e.kind!==`add`).length,afterStart:a.some(e=>e.after!==null)?c:0,afterCount:a.filter(e=>e.kind!==`del`).length,lines:a}})}function x(e){return`@@ -${e.beforeCount===1?`${e.beforeStart}`:`${e.beforeStart},${e.beforeCount}`} +${e.afterCount===1?`${e.afterStart}`:`${e.afterStart},${e.afterCount}`} @@`}function S(e){let t=0,n=0;for(let r of e)for(let e of r.lines)e.kind===`add`?t+=1:e.kind===`del`&&(n+=1);return{added:t,removed:n}}var C=e(),w=async e=>e===void 0?``:(await i(e)).text;function T({file:e,before:t,after:i,changeset:f,change:p,review:m}){let h=n(),g=c(f),_=g.files.find(e=>e.id===p),v=_===void 0?[]:g.operations.filter(e=>l(e,`resource`)),[y,T]=(0,d.useState)(null);(0,d.useEffect)(()=>{let e=!0;return T(null),Promise.all([w(t),w(i)]).then(([t,n])=>{e&&T({before:t,after:n})}).catch(t=>{e&&T({error:t instanceof Error?t.message:String(t)})}),()=>{e=!1}},[t,i]);let E=(0,d.useMemo)(()=>y===null||`error`in y||y.before===null||y.after===null?[]:b(y.before,y.after),[y]),D=e===void 0?``:a(e),O=S(E),k=(0,C.jsxs)(`div`,{className:`web-file__head`,children:[(0,C.jsx)(`code`,{children:D}),y!==null&&!(`error`in y)?(0,C.jsxs)(`span`,{children:[(0,C.jsxs)(`span`,{className:`web-diff--add`,children:[`+`,O.added]}),` `,(0,C.jsxs)(`span`,{className:`web-diff--remove`,children:[`-`,O.removed]}),t===void 0?` · new file`:i===void 0?` · deleted`:``]}):null,(0,C.jsxs)(`span`,{className:`web-file__actions`,children:[m===!0&&_!==void 0?(0,C.jsxs)(`label`,{className:`web-file__viewed`,children:[(0,C.jsx)(`input`,{type:`checkbox`,checked:_.reviewed,onChange:e=>g.review([_],e.target.checked)}),`Viewed`]}):null,_===void 0?null:v.map(e=>(0,C.jsx)(r,{label:`${u(e)} ${e.label}`,size:`sm`,disabled:String(e.status)===`running`,onClick:()=>void g.run(e,_)},e.id)),e===void 0||i===void 0?null:(0,C.jsx)(r,{label:`Open file`,size:`sm`,onClick:()=>void h.commands.execute(`ahp.openFile`,{uri:e})})]})]}),A=g.said===null?null:(0,C.jsx)(s,{tone:g.said.tone,message:g.said.text});return y===null?(0,C.jsxs)(`div`,{className:`web-file`,children:[k,A,(0,C.jsx)(o,{label:`Reading both sides`})]}):`error`in y?(0,C.jsxs)(`div`,{className:`web-file`,children:[k,A,(0,C.jsx)(s,{tone:`danger`,title:`Not readable`,message:y.error})]}):y.before===null||y.after===null?(0,C.jsxs)(`div`,{className:`web-file`,children:[k,A,(0,C.jsx)(`p`,{className:`web-note`,children:`This file is not text.`})]}):E.length===0?(0,C.jsxs)(`div`,{className:`web-file`,children:[k,A,(0,C.jsx)(`p`,{className:`web-note`,children:`No changes.`})]}):(0,C.jsxs)(`div`,{className:`web-file`,children:[k,A,(0,C.jsx)(`div`,{className:`web-file__body`,children:(0,C.jsx)(`table`,{className:`web-code web-diff`,children:(0,C.jsx)(`tbody`,{children:E.map((e,t)=>[(0,C.jsx)(`tr`,{className:`web-diff__hunk`,children:(0,C.jsx)(`td`,{colSpan:3,children:x(e)})},`h${t}`),...e.lines.map((e,n)=>(0,C.jsxs)(`tr`,{"data-kind":e.kind,children:[(0,C.jsx)(`td`,{className:`web-code__number`,children:e.before??``}),(0,C.jsx)(`td`,{className:`web-code__number`,children:e.after??``}),(0,C.jsxs)(`td`,{className:`web-code__text`,children:[e.kind===`add`?`+`:e.kind===`del`?`-`:` `,e.text]})]},`${t}:${n}`))])})})})]})}export{T as default};
@@ -0,0 +1 @@
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./Button-_R1oktDz.js";import{d as a,i as o,n as s,nt as c,v as l}from"./data-CBWyZN_H.js";import{a as u,n as d}from"./words-T8-D0K4W.js";import{t as f}from"./Spinner-B-iOhBZq.js";import{t as p}from"./Alert-CHZkhmDE.js";import{t as m}from"./Text-MPtQvYE-.js";import{c as h,d as g,l as _,u as v}from"./index-DBKNxflN.js";import{t as y}from"./channel-8aIcEm3f.js";var b=t(),x=e(),S=[{label:`By hand only`,expression:``},{label:`Every 10 minutes`,expression:`*/10 * * * *`},{label:`Every hour`,expression:`0 * * * *`},{label:`Every 6 hours`,expression:`0 */6 * * *`},{label:`Every day at 09:00`,expression:`0 9 * * *`},{label:`Weekdays at 09:00`,expression:`0 9 * * 1-5`},{label:`Every Monday at 05:00`,expression:`0 5 * * 1`}];function C({label:e,hint:t,children:n}){return(0,x.jsxs)(`label`,{className:`web-form__field`,children:[(0,x.jsx)(`span`,{className:`web-input__label`,children:e}),n,t===void 0?null:(0,x.jsx)(`span`,{className:`web-input__hint`,children:t})]})}function w({resource:e}){let t=r(),{state:w,error:T}=y(a,c),E=n(`$/ahp/agents`)??[],D=n(s),O=n(o),k=e===void 0?void 0:w?.entries.find(t=>t.resource===e),[A,j]=(0,b.useState)(null);if(T!==null)return(0,x.jsx)(p,{tone:`danger`,title:`No automations`,message:T});if(w===void 0)return(0,x.jsx)(f,{label:`Reading the automations`});if(e!==void 0&&k===void 0)return(0,x.jsx)(p,{tone:`warning`,message:`This automation is gone.`});if(e===void 0&&D?.create===void 0)return(0,x.jsx)(p,{tone:`warning`,message:`This host does not let clients create automations.`});let M=A??v(k,{...E[0]===void 0?{}:{provider:E[0].provider},...O==null?{}:{folder:d(O)}}),N=e=>j({...M,...e}),P=E.find(e=>e.provider===M.provider),F=g(M),I=D?.schedules?.minIntervalMinutes,L=S.find(e=>e.expression===M.expression.trim());return(0,x.jsxs)(`div`,{className:`web-page web-form`,children:[(0,x.jsx)(m,{variant:`h2`,text:k===void 0?`New automation`:`Edit ${k.definition.title||`automation`}`}),(0,x.jsx)(C,{label:`Title`,children:(0,x.jsx)(`input`,{className:`web-field`,value:M.title,onChange:e=>N({title:e.target.value})})}),(0,x.jsx)(C,{label:`Message`,hint:`What the agent is told each time it runs.`,children:(0,x.jsx)(`textarea`,{className:`web-field web-form__message`,rows:5,value:M.message,onChange:e=>N({message:e.target.value})})}),(0,x.jsxs)(`div`,{className:`web-form__row`,children:[(0,x.jsx)(C,{label:`Agent`,children:(0,x.jsxs)(`select`,{className:`web-field`,value:M.provider,onChange:e=>N({provider:e.target.value,model:``}),children:[(0,x.jsx)(`option`,{value:``,children:`The host default`}),E.map(e=>(0,x.jsx)(`option`,{value:e.provider,children:e.displayName},e.provider))]})}),(0,x.jsx)(C,{label:`Model`,children:(0,x.jsxs)(`select`,{className:`web-field`,value:M.model,onChange:e=>N({model:e.target.value}),children:[(0,x.jsx)(`option`,{value:``,children:`The agent default`}),(P?.models??[]).map(e=>(0,x.jsx)(`option`,{value:e.id,children:e.name},e.id))]})})]}),(0,x.jsx)(C,{label:`Folder`,hint:`A folder on the daemon's machine.`,children:(0,x.jsx)(`input`,{className:`web-field`,value:M.folder,onChange:e=>N({folder:e.target.value})})}),(0,x.jsxs)(`div`,{className:`web-form__row`,children:[(0,x.jsx)(C,{label:`Schedule`,children:(0,x.jsxs)(`select`,{className:`web-field`,value:L?.expression??`custom`,onChange:e=>{e.target.value!==`custom`&&N({expression:e.target.value})},children:[S.map(e=>(0,x.jsx)(`option`,{value:e.expression,children:e.label},e.label)),(0,x.jsx)(`option`,{value:`custom`,children:`Custom`})]})}),(0,x.jsx)(C,{label:`Cron expression`,hint:`${M.expression.trim()===``?`Runs only when started by hand.`:h(M.expression)}${I===void 0?``:` At most every ${I} minutes.`}`,children:(0,x.jsx)(`input`,{className:`web-field`,value:M.expression,placeholder:`minute hour day month weekday`,onChange:e=>N({expression:e.target.value})})})]}),M.expression.trim()===``?null:(0,x.jsxs)(`div`,{className:`web-form__row`,children:[(0,x.jsx)(C,{label:`Time zone`,children:(0,x.jsx)(`input`,{className:`web-field`,value:M.timeZone,onChange:e=>N({timeZone:e.target.value})})}),(0,x.jsx)(C,{label:`Missed runs`,hint:`What happens to a run due while the daemon was down.`,children:(0,x.jsxs)(`select`,{className:`web-field`,value:M.misfire,onChange:e=>N({misfire:e.target.value===`runOnce`?`runOnce`:`skip`}),children:[(0,x.jsx)(`option`,{value:`skip`,children:`Skip them`}),(0,x.jsx)(`option`,{value:`runOnce`,children:`Run once when back`})]})})]}),(0,x.jsxs)(`div`,{className:`web-form__row`,children:[(0,x.jsx)(C,{label:`Turn off after runs`,hint:`Empty keeps it on.`,children:(0,x.jsx)(`input`,{className:`web-field`,inputMode:`numeric`,value:M.afterRuns,onChange:e=>N({afterRuns:e.target.value})})}),(0,x.jsx)(C,{label:`Turn off after`,hint:`Empty keeps it on.`,children:(0,x.jsx)(`input`,{className:`web-field`,type:`date`,value:M.afterDate,onChange:e=>N({afterDate:e.target.value})})})]}),(0,x.jsxs)(`label`,{className:`web-input__row`,children:[(0,x.jsx)(`input`,{type:`checkbox`,checked:M.enabled,onChange:e=>N({enabled:e.target.checked})}),(0,x.jsx)(`span`,{children:`On`})]}),F===void 0?null:(0,x.jsx)(`p`,{className:`web-note`,children:F}),(0,x.jsxs)(`div`,{className:`web-page__actions`,children:[(0,x.jsx)(i,{label:k===void 0?`Create`:`Save`,variant:`primary`,disabled:F!==void 0,onClick:()=>{if(F!==void 0)return;let e=_(M,k?.definition);if(k===void 0){let n=`ahp-automation:/${u()}`;l(a,{type:`automation/createRequested`,resource:n,definition:e}),t.surfaces.close(`automation:new`),t.commands.execute(`ahp.openAutomation`,{resource:n})}else l(a,{type:`automation/updateRequested`,resource:k.resource,changes:e}),t.surfaces.close(`automation:edit:${k.resource}`),t.commands.execute(`ahp.openAutomation`,{resource:k.resource})}}),(0,x.jsx)(i,{label:`Cancel`,onClick:()=>t.surfaces.close(k===void 0?`automation:new`:`automation:edit:${k.resource}`)})]})]})}export{w as default};
@@ -0,0 +1 @@
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{n as i}from"./sessions-BcRKb9k7.js";import{c as a,f as o,i as ee,j as s,r as c}from"./data-CBWyZN_H.js";import{n as l}from"./words-T8-D0K4W.js";import{t as u}from"./emojis-7RT6GvLa.js";import{t as d}from"./ContextMenu-BV1gdog0.js";import{t as te}from"./Spinner-B-iOhBZq.js";import{t as f}from"./Alert-CHZkhmDE.js";import{t as p}from"./Tree-BqFzA5wp.js";import{a as ne,d as m,f as h,m as g,p as _}from"./folder-path-CmVXGhKI.js";import{c as v,l as y}from"./viewers-MssMDn0e.js";import{a as b,i as x,o as S,r as C,s as w,t as T}from"./index-DBKNxflN.js";import{r as E}from"./drag-ruzgQUFW.js";var D=t(),O=e(),re=`$/modus/class`;function ie(e){let t=l(e);return(0,O.jsx)(`span`,{title:t,children:t.replace(/\/+$/,``).split(`/`).pop()||t})}function k(){let e=r(),t=n(c),l=n(ee),k=n(a),A=n(C),j=n(ne),M=n(x),[N,P]=(0,D.useState)([]),F=(0,D.useMemo)(()=>g(l,k??[],N,j??[]),[l,k,N,j]),[I,L]=(0,D.useState)(new Map),[R,z]=(0,D.useState)(new Set),[B,V]=(0,D.useState)(null),[H,U]=(0,D.useState)(null),W=(0,D.useCallback)((e,t=!1)=>{t||L(t=>new Map(t).set(e,`loading`)),s(`resourceList`,{channel:o,uri:e}).then(t=>L(n=>new Map(n).set(e,_(t.entries)))).catch(()=>L(t=>new Map(t).set(e,`failed`)))},[]),G=(0,D.useCallback)(e=>{for(let t of e)!R.has(t)&&!I.has(t)&&W(t);z(e)},[R,I,W]),K=F[0]?.uri;(0,D.useEffect)(()=>{K!==void 0&&!I.has(K)&&G(new Set([...R,K]))},[K]);let q=(0,D.useRef)(null);(0,D.useEffect)(()=>{if(A==null)return;e.store.set(C,null);let t=m(F.map(e=>e.uri),A),[n]=t;n!==void 0&&!F.some(e=>e.uri===n)&&P(e=>[...e,n]),G(new Set([...R,...t]));let r=t[t.length-1]??null;V(r),q.current=r},[A]);let J=(0,D.useRef)(null);(0,D.useEffect)(()=>{let e=q.current;if(e===null)return;let t=Array.from(J.current?.querySelectorAll(`[data-key]`)??[]).find(t=>t.dataset.key===e);t!==void 0&&(t.scrollIntoView({block:`center`}),q.current=null)},[I,B]),(0,D.useEffect)(()=>{for(let e of M?.uris??[])I.has(e)&&W(e,!0)},[M]);let Y=()=>{L(new Map);for(let e of R)W(e)},X=async()=>{let t=await b(e);t!==null&&!I.has(t)&&G(new Set([...R,t]))},Z=[{title:`Reload`,icon:u.reload,onSelect:e=>{e.closeMenu(),Y()}},{title:`Add folder`,icon:u.folder,onSelect:e=>{e.closeMenu(),X()}}],Q=(t,n)=>{e.commands.execute(`ahp.openFile`,{uri:t,...n===void 0?{}:{viewer:n}}),i(e,e.store.get(re)??`large`)},ae=t=>{let n=y(e,t);return[{title:`Open`,icon:u.open,onSelect:e=>{e.closeMenu(),Q(t)}},...n.length<2?[]:n.map(e=>({title:`Open with ${v(e)}`,...e.opens?.icon===void 0?{}:{icon:e.opens.icon},onSelect:n=>{n.closeMenu(),Q(t,e.component)}}))]},$=(0,D.useRef)(!1),oe=e=>{$.current=!1,e.preventDefault(),U({x:e.clientX,y:e.clientY})},se=(0,D.useMemo)(()=>{let e=(t,n,r)=>{let i=I.get(t),a=i===void 0?[]:i===`loading`?[{key:`${t}#loading`,label:`Loading`}]:i===`failed`?[{key:`${t}#failed`,label:`Not readable`}]:i.map(n=>{let r=h(t,n.name);return n.type===`directory`?e(r,n.name):{key:r,label:n.name,icon:T(r),draggable:!0,data:{uri:r,directory:!1}}});return{key:t,label:n,icon:u.folder,draggable:!0,data:{uri:t,directory:!0},children:a,...r===void 0?{}:{trailing:(0,O.jsx)(`span`,{className:`web-folders__tag`,children:r})}}};return F.map(t=>e(t.uri,ie(t.uri),t.isDefault?`default`:void 0))},[F,I]);return t?.status!==`connected`&&F.length===0?t?.status===`failed`?(0,O.jsx)(f,{tone:`danger`,title:`Not connected`,message:t.error??`The server refused the connection.`}):(0,O.jsx)(te,{label:`Connecting to the server`}):(0,O.jsxs)(`div`,{className:`web-explorer`,children:[(0,O.jsxs)(`div`,{className:`web-explorer__title`,children:[(0,O.jsx)(`span`,{children:`Explorer`}),(0,O.jsx)(`span`,{className:`web-explorer__actions`,children:(0,O.jsx)(`button`,{type:`button`,className:`web-explorer__action`,title:`Refresh`,"aria-label":`Refresh`,onClick:Y,children:(0,O.jsx)(`span`,{className:`web-explorer__icon`,children:u.reload})})})]}),(0,O.jsxs)(`div`,{className:`web-explorer__scroll`,ref:J,onContextMenuCapture:()=>{$.current=!0},onContextMenu:oe,children:[F.length===0?(0,O.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`The server names no folder yet. Start a session in one.`}):null,(0,O.jsx)(p,{nodes:se,selectedKey:B,expanded:R,onExpandedChange:G,contextMenuSlot:S,contextFor:e=>({[w]:e.data===void 0?null:{uri:e.data.uri,directory:e.data.directory,added:F.some(t=>t.uri===e.key&&t.added),root:F.some(t=>t.uri===e.key)}}),contextExtraItems:e=>e.data===void 0?Z:e.data.directory?[]:ae(e.data.uri),onSelect:e=>{if($.current){$.current=!1,e.data!==void 0&&V(e.key);return}if(e.data!==void 0){if(V(e.key),e.data.directory){let t=new Set(R);t.delete(e.key)||t.add(e.key),G(t)}else Q(e.data.uri)}},onDragStart:(e,t)=>{t.data!==void 0&&E(e.dataTransfer,t.data)}})]}),H===null?null:(0,O.jsx)(d,{spec:{items:Z},x:H.x,y:H.y,onClose:()=>U(null)})]})}export{k as default};
@@ -0,0 +1 @@
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{r as n}from"./notify-CJo-T9e2.js";import{t as r}from"./useStore-BQkzWMs-.js";import{n as i}from"./ScenaProvider-6A3TJumQ.js";import{d as a,k as o,n as s,nt as c}from"./data-CBWyZN_H.js";import{t as l}from"./emojis-7RT6GvLa.js";import{t as u}from"./Spinner-B-iOhBZq.js";import{t as d}from"./Alert-CHZkhmDE.js";import{_ as f,f as p,g as m,m as h,p as g,v as _}from"./index-DBKNxflN.js";import{t as v}from"./ExplorerList-DfesRs43.js";import{t as y}from"./channel-8aIcEm3f.js";import{i as b,n as x}from"./actions-BmFc5yoR.js";var S=t(),C=e(),w={running:`working`,failed:`failed`,on:`ok`,off:`off`},T={running:`Running`,failed:`Last run failed`,on:`On`,off:`Off`},E={pending:`waiting`,running:`running`,completed:`done`,failed:`failed`,cancelled:`stopped`},D=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`,hour:`2-digit`,minute:`2-digit`}),O=e=>{if(e===void 0)return``;let t=new Date(e);return Number.isNaN(t.getTime())?``:D.format(t)},k=e=>n(`The automation could not run`,e);function A(){let e=i(),{state:t,error:n}=y(a,c),D=r(s),A=r(_),j=t=>void e.commands.execute(`ahp.openAutomation`,{resource:t}),M=t=>void e.commands.execute(`ahp.editAutomation`,{resource:t}),N=(0,S.useMemo)(()=>[...t?.entries??[]].sort((e,t)=>m(e).localeCompare(m(t))).map(e=>{let t=h(e),n=g(e)[0],r=n===void 0?void 0:p(n),i=e.definition.session.provider,a=e.runCount??e.runs.length;return{key:e.resource,dot:w[t],dotLabel:T[t],title:m(e),...e.nextRunAt===void 0||!e.definition.enabled?{}:{time:O(e.nextRunAt)},lines:[[f(e),i].filter(e=>e!==void 0).join(` · `),r===void 0?`Never run`:`${a} ${a===1?`run`:`runs`} \u{00B7} last ${E[r.status]??r.status} ${O(r.at)}`],menu:x(e,()=>j(e.resource),()=>M(e.resource)),...e.operations.map(String).includes(`run`)?{action:{icon:l.run,label:`Run now`,run:()=>void b(e).catch(k)}}:{}}}),[t]),P=n===null?t===void 0?(0,C.jsx)(u,{label:`Reading the automations`}):N.length===0?(0,C.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`No automations yet.`}):null:(0,C.jsx)(d,{tone:`danger`,title:`No automations`,message:n});return(0,C.jsx)(v,{title:`Automations`,actions:[...D?.create===void 0?[]:[{icon:`+`,label:`New automation`,run:()=>void e.commands.execute(`ahp.newAutomation`)}],{icon:l.reload,label:`Reload`,run:()=>void o(a)}],rows:N,selected:A??null,onOpen:j,notice:P,filterLabel:`Filter automations`})}export{A as default};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import"./data-Fkj0LNnG.js";import{t as i}from"./state-DRVsnGrf.js";import{t as a}from"./ExplorerList-Bdp0sfLW.js";import{a as o,i as s}from"./words-BMjqrsOT.js";var c=t(),l=e();function u(){let e=r(),t=n(`$/ahp/agents`)??[],u=n(`$/ahp/sessions`)??[],d=n(i),f=t=>void e.commands.execute(`ahp.openAgent`,{provider:t}),p=t=>void e.commands.execute(`ahp.newSession`,{provider:t}),m=(0,c.useMemo)(()=>t.map(e=>{let t=u.filter(t=>t.provider===e.provider).length,n=o(e).some(e=>e.required);return{key:e.provider,dot:`ok`,dotLabel:`Offered`,title:e.displayName,lines:[[s(e),t===1?`1 session`:`${t} sessions`,n?`needs sign-in`:void 0].filter(e=>e!==void 0).join(` · `),...e.description===``?[]:[e.description]],menu:[{title:`Open`,onSelect:t=>{t.closeMenu(),f(e.provider)}},{title:`New session`,onSelect:t=>{t.closeMenu(),p(e.provider)}}]}}),[t,u]);return(0,l.jsx)(a,{title:`Agents`,actions:[],rows:m,selected:d??null,onOpen:f,notice:m.length===0?(0,l.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`This server offers no agent.`}):null,filterLabel:`Filter agents`})}export{u as default};
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import"./data-CBWyZN_H.js";import{t as i}from"./state-DRVsnGrf.js";import{t as a}from"./ExplorerList-DfesRs43.js";import{a as o,i as s}from"./words-CyqfIDyJ.js";var c=t(),l=e();function u(){let e=r(),t=n(`$/ahp/agents`)??[],u=n(`$/ahp/sessions`)??[],d=n(i),f=t=>void e.commands.execute(`ahp.openAgent`,{provider:t}),p=t=>void e.commands.execute(`ahp.newSession`,{provider:t}),m=(0,c.useMemo)(()=>t.map(e=>{let t=u.filter(t=>t.provider===e.provider).length,n=o(e).some(e=>e.required);return{key:e.provider,dot:`ok`,dotLabel:`Offered`,title:e.displayName,lines:[[s(e),t===1?`1 session`:`${t} sessions`,n?`needs sign-in`:void 0].filter(e=>e!==void 0).join(` · `),...e.description===``?[]:[e.description]],menu:[{title:`Open`,onSelect:t=>{t.closeMenu(),f(e.provider)}},{title:`New session`,onSelect:t=>{t.closeMenu(),p(e.provider)}}]}}),[t,u]);return(0,l.jsx)(a,{title:`Agents`,actions:[],rows:m,selected:d??null,onOpen:f,notice:m.length===0?(0,l.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`This server offers no agent.`}):null,filterLabel:`Filter agents`})}export{u as default};
@@ -0,0 +1 @@
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./Button-_R1oktDz.js";import{c as a,it as o,k as s}from"./data-CBWyZN_H.js";import{o as c}from"./words-T8-D0K4W.js";import{t as l}from"./emojis-7RT6GvLa.js";import{t as u}from"./ContextMenu-BV1gdog0.js";import{t as d}from"./Spinner-B-iOhBZq.js";import{t as f}from"./Alert-CHZkhmDE.js";import{t as ee}from"./Tree-BqFzA5wp.js";import{t as p}from"./TextField-DnSHrmJM.js";import{t as m}from"./CheckBox-Dkn59EbO.js";import{t as h}from"./Modal-BHPfQpzr.js";import{t as te}from"./state-KGSq646f.js";import{l as ne,s as re}from"./viewers-MssMDn0e.js";import{t as ie}from"./channel-8aIcEm3f.js";import{a as ae,c as oe,d as se,i as g,l as ce,n as _,o as le,r as v,s as ue,t as y,u as b}from"./changeset-BgSW341C.js";var x=t(),S=e();function C(e){let t=e.filter(e=>e.staged).length;return t>0?t===1?`The 1 staged file is committed. The rest stay as they are.`:`The ${t} staged files are committed. The rest stay as they are.`:e.length===1?`Nothing is staged, so the 1 changed file is committed.`:`Nothing is staged, so all ${e.length} changed files are committed.`}function w({form:e,files:t,onCommit:n,onClose:r}){let[a,o]=(0,x.useState)(``),s=c(e.operation.confirmation),l=a.trim()!==``;return(0,S.jsx)(h,{open:!0,title:e.operation.label,onClose:r,children:(0,S.jsxs)(`div`,{className:`web-changeset-form`,children:[(0,S.jsx)(p,{label:`Commit message`,multiline:!0,rows:4,value:a,placeholder:`What does this change do?`,onChange:o}),(0,S.jsx)(`p`,{className:`web-note`,children:C(t)}),s===``?null:(0,S.jsx)(`p`,{className:`web-note`,children:s}),(0,S.jsxs)(`div`,{className:`web-changeset-form__actions`,children:[(0,S.jsx)(i,{label:`Cancel`,variant:`ghost`,onClick:r}),(0,S.jsx)(i,{label:e.operation.label,variant:`primary`,disabled:!l,onClick:()=>n(a.trim())})]})]})})}function T({form:e,onCreate:t,onClose:n}){let[r,a]=(0,x.useState)(e.draft.title),[o,s]=(0,x.useState)(e.draft.description),[c,l]=(0,x.useState)(!1);(0,x.useEffect)(()=>{a(e.draft.title),s(e.draft.description)},[e.draft]);let u=e.draft.branchName===null&&e.draft.baseBranchName===null?null:`${e.draft.branchName??`?`} \u{2192} ${e.draft.baseBranchName??`?`}`,f=!e.preparing&&e.create!==null&&r.trim()!==``;return(0,S.jsx)(h,{open:!0,title:`Create a pull request`,onClose:n,children:(0,S.jsxs)(`div`,{className:`web-changeset-form`,children:[e.preparing?(0,S.jsx)(d,{label:`Asking the server for a title and description`}):null,e.draft.repository===null&&u===null?null:(0,S.jsx)(`p`,{className:`web-note`,children:[e.draft.repository,u].filter(e=>e!==null).join(` · `)}),(0,S.jsx)(p,{label:`Title`,value:r,placeholder:`What is this request?`,disabled:e.preparing,onChange:a}),(0,S.jsx)(p,{label:`Description`,multiline:!0,rows:8,value:o,placeholder:`What changed, and why?`,disabled:e.preparing,onChange:s}),(0,S.jsx)(m,{label:`Open as a draft`,value:c,onChange:l}),(0,S.jsx)(`p`,{className:`web-note`,children:e.create===null?`This server offers no way to create the request.`:`The server commits what is uncommitted, pushes the branch and opens the request only when you press the button.`}),(0,S.jsxs)(`div`,{className:`web-changeset-form__actions`,children:[(0,S.jsx)(i,{label:`Cancel`,variant:`ghost`,onClick:n}),e.create===null?null:(0,S.jsx)(i,{label:e.create.label,variant:`primary`,disabled:!f,onClick:()=>t({...e.draft,title:r.trim(),description:o},c)})]})]})})}function de({form:e,files:t,onCommit:n,onPullRequest:r,onClose:i}){return e===null?null:e.kind===`commit`?(0,S.jsx)(w,{form:e,files:t,onCommit:n,onClose:i}):(0,S.jsx)(T,{form:e,onCreate:r,onClose:i})}var E=`ahpd-web.changes-view`,D=`ahpd-web.changes-grouping`,fe={review:`By review`,staging:`Staged and not`,none:`Not grouped`};function O(e,t){try{let n=localStorage.getItem(e);return t.find(e=>e===n)??null}catch{return null}}function k(e,t){try{localStorage.setItem(e,t)}catch{}}var pe={A:`Added`,M:`Modified`,D:`Deleted`,U:`Untracked`};function A(){let e=r(),t=n(te),i=n(a)?.find(e=>e.resource===t),c=ie(t,o),p=(0,x.useMemo)(()=>se(c.state?.changesets),[c.state?.changesets]),[m,h]=(0,x.useState)(void 0),C=p.find(e=>e.uri===m)??le(p),w=ae(C?.uri),{files:T,operations:A}=w,j=i?.workingDirectories?.[0]??null,[M,me]=(0,x.useState)(()=>O(E,[`list`,`tree`])??`list`),[N,he]=(0,x.useState)(()=>O(D,[`review`,`staging`,`none`])),P=C?.review===!0,ge=T.some(e=>e.staged||e.unstaged),F=[...P?[`review`]:[],...ge?[`staging`]:[],`none`],I=N!==null&&F.includes(N)?N:F[0]??`none`,[L,_e]=(0,x.useState)(``),[ve,R]=(0,x.useState)(new Set),[ye,z]=(0,x.useState)(null),[B,V]=(0,x.useState)(null),H=A.filter(e=>v(e,`resource`)),be=A.some(e=>e.id===`create-pr`),U=A.filter(e=>v(e,`changeset`)&&!(be&&e.id===`prepare-pull-request`)),W=e=>String(e.status)===`running`,xe=t=>{let n=[{title:`Open change`,onSelect:n=>{n.closeMenu(),_(e,t,C?.uri,P)}}];t.status!==`deleted`&&(n.push({title:`Open file`,onSelect:n=>{n.closeMenu(),e.commands.execute(`ahp.openFile`,{uri:t.file})}}),n.push(...re(e,t.file,ne(e,t.file)[0]?.component??null))),P&&n.push({title:t.reviewed?`Mark as not reviewed`:`Mark as reviewed`,onSelect:e=>{e.closeMenu(),w.review([t],!t.reviewed)}});for(let e of H)n.push({title:e.label,...e.description===void 0?{}:{tooltip:e.description},group:`file`,...e.confirmation===void 0?{}:{color:`red`},onSelect:n=>{n.closeMenu(),w.run(e,t)}});return n},Se=t=>{let n=ce(t),r=(e,t)=>{e.stopPropagation(),t()};return(0,S.jsxs)(`span`,{className:`web-change__end`,children:[(0,S.jsxs)(`span`,{className:`web-change__actions`,children:[P?(0,S.jsx)(`button`,{type:`button`,className:`web-change__action`,title:t.reviewed?`Mark as not reviewed`:`Mark as reviewed`,"aria-label":t.reviewed?`Mark as not reviewed`:`Mark as reviewed`,"aria-pressed":t.reviewed,onClick:e=>r(e,()=>w.review([t],!t.reviewed)),children:l.check}):null,t.status===`deleted`?null:(0,S.jsx)(`button`,{type:`button`,className:`web-change__action`,title:`Open file`,"aria-label":`Open file`,onClick:n=>r(n,()=>void e.commands.execute(`ahp.openFile`,{uri:t.file})),children:l.file}),H.map(e=>(0,S.jsx)(`button`,{type:`button`,className:`web-change__action`,title:e.label,"aria-label":e.label,disabled:W(e),onClick:n=>r(n,()=>void w.run(e,t)),children:y(e)},e.id))]}),(0,S.jsx)(`span`,{className:`web-change__counts`,children:t.added===void 0&&t.removed===void 0?null:(0,S.jsxs)(S.Fragment,{children:[(0,S.jsxs)(`span`,{className:`web-diff--add`,children:[`+`,t.added??0]}),` `,(0,S.jsxs)(`span`,{className:`web-diff--remove`,children:[`-`,t.removed??0]})]})}),(0,S.jsx)(`span`,{className:`web-change__letter`,"data-letter":n,title:pe[n],children:n})]})},G=L.trim().toLowerCase(),K=G===``?T:T.filter(e=>`${b(e.dir,j)}/${e.name}`.toLowerCase().includes(G)),q=oe(K,I),J=new Map,Y=(()=>{let t=(t,n)=>{let r=`${n}|${t.id}`;J.set(r,t);let i=b(t.dir,j);return{key:r,label:(0,S.jsxs)(`span`,{className:`web-change`,"data-reviewed":t.reviewed?`true`:`false`,"data-deleted":t.status===`deleted`?`true`:`false`,title:`${i}/${t.name}`,children:[(0,S.jsx)(`span`,{className:`web-change__name`,children:t.name}),M===`list`&&i!==`.`?(0,S.jsx)(`span`,{className:`web-change__dir`,children:i}):null]}),icon:ne(e,t.file)[0]?.opens?.icon??l.file,trailing:Se(t),data:t}},n=(e,r)=>({key:`${r}|dir:${e.path}`,label:(0,S.jsx)(`span`,{className:`web-change__name`,title:e.path,children:e.name}),icon:l.folder,children:[...e.folders.map(e=>n(e,r)),...e.changes.map(e=>t(e,r))]}),r=(e,r)=>{if(M===`list`)return e.map(e=>t(e,r));let i=ue(e,j);return[...i.folders.map(e=>n(e,r)),...i.changes.map(e=>t(e,r))]};return I===`none`?r(q[0]?.changes??[],`all`):q.map(e=>({key:`group:${e.key}`,icon:``,label:(0,S.jsx)(`span`,{className:`web-change__group`,children:e.label}),trailing:(0,S.jsx)(`span`,{className:`web-explorer__count`,children:e.changes.length}),children:r(e.changes,e.key)}))})(),X=[],Z=e=>{for(let t of e)t.children!==void 0&&(X.push(t.key),Z(t.children))};Z(Y);let Ce=new Set(X.filter(e=>!ve.has(e))),we=e=>{let t=e.target.closest(`[data-key]`)?.dataset.key,n=t===void 0?void 0:J.get(t);n!==void 0&&(e.preventDefault(),z(t??null),V({x:e.clientX,y:e.clientY,items:xe(n)}))},Te=String(w.state?.status??``),Ee=(0,S.jsxs)(S.Fragment,{children:[t===void 0?(0,S.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`Open a session to see what it changed.`}):null,t!==void 0&&c.state!==void 0&&p.length===0?(0,S.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`This session tracks no changes.`}):null,w.said===null?null:(0,S.jsx)(f,{tone:w.said.tone,message:w.said.text}),w.error===null?null:(0,S.jsx)(f,{tone:`danger`,title:`Changes not readable`,message:w.error}),w.state?.error===void 0?null:(0,S.jsx)(f,{tone:`danger`,message:w.state.error.message}),C!==void 0&&(w.state===void 0||Te===`computing`)&&w.error===null?(0,S.jsx)(d,{label:`Working out the changes`}):null,w.state!==void 0&&Te!==`computing`&&T.length===0?(0,S.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`No changes.`}):null]}),Q=(e,t,n,r)=>(0,S.jsx)(`button`,{type:`button`,className:`web-explorer__action`,title:t,"aria-label":t,"aria-pressed":r?.on,"data-on":r?.on===!0?`true`:`false`,"data-busy":r?.busy===!0?`true`:`false`,"data-tone":r?.tone??void 0,disabled:r?.disabled,onClick:n,children:(0,S.jsx)(`span`,{className:`web-explorer__icon`,children:e})},t),$=e=>{me(e),k(E,e)},De=e=>{let t=e.currentTarget.getBoundingClientRect(),n=p.map(e=>({title:e.label,icon:e.uri===C?.uri?l.check:``,onSelect:t=>{t.closeMenu(),h(e.uri)}}));V({x:t.left,y:t.bottom,items:n})},Oe=e=>{let t=e.currentTarget.getBoundingClientRect(),n=e=>({icon:e?l.check:``}),r=U.map(e=>{let t=g(e);return{title:e.label,...e.description===void 0?{}:{tooltip:e.description},group:`changes`,icon:y(e),...t===null?{}:{color:t},disabled:W(e),onSelect:t=>{t.closeMenu(),w.run(e)}}});if(r.push({title:`Show as a list`,group:`view`,...n(M===`list`),onSelect:e=>{e.closeMenu(),$(`list`)}},{title:`Show as a tree`,group:`view`,...n(M===`tree`),onSelect:e=>{e.closeMenu(),$(`tree`)}}),F.length>1)for(let e of F)r.push({title:fe[e],group:`group`,...n(e===I),onSelect:t=>{t.closeMenu(),he(e),k(D,e)}});X.length>0&&(r.push({title:`Expand all`,group:`folders`,icon:``,onSelect:e=>{e.closeMenu(),R(new Set)}}),r.push({title:`Collapse all`,group:`folders`,icon:``,onSelect:e=>{e.closeMenu(),R(new Set(X))}})),V({x:Math.max(0,t.right-200),y:t.bottom,items:r})},ke=T.reduce((e,t)=>e+(t.added??0),0),Ae=T.reduce((e,t)=>e+(t.removed??0),0);return(0,S.jsxs)(`div`,{className:`web-explorer web-changes`,children:[(0,S.jsxs)(`div`,{className:`web-explorer__title`,children:[(0,S.jsx)(`span`,{className:`web-explorer__name`,title:i?.title,children:i===void 0?`Changes`:`Changes \u{00B7} ${i.title||`Untitled`}`}),C===void 0?null:(0,S.jsxs)(`span`,{className:`web-explorer__actions`,children:[U.map(e=>Q(y(e),e.label,()=>void w.run(e),{busy:W(e),disabled:W(e),tone:g(e)})),U.length===0?null:(0,S.jsx)(`span`,{className:`web-explorer__sep`,"aria-hidden":`true`}),Q(l.reload,`Reload`,()=>void s(C.uri)),Q(l.more,`View options`,Oe)]})]}),C===void 0?null:(0,S.jsxs)(`div`,{className:`web-changes__bar`,children:[p.length>1?(0,S.jsxs)(`button`,{type:`button`,className:`web-changes__scope`,title:C.description??C.label,"aria-haspopup":`menu`,onClick:De,children:[C.label,` `,(0,S.jsx)(`span`,{"aria-hidden":`true`,children:l.caretDown})]}):(0,S.jsx)(`span`,{className:`web-changes__scope web-changes__scope--only`,title:C.description??C.label,children:C.label}),(0,S.jsx)(`span`,{className:`web-changes__totals`,children:T.length===0?null:(0,S.jsxs)(S.Fragment,{children:[T.length===1?`1 file`:`${T.length} files`,` `,(0,S.jsxs)(`span`,{className:`web-diff--add`,children:[`+`,ke]}),` `,(0,S.jsxs)(`span`,{className:`web-diff--remove`,children:[`−`,Ae]})]})}),(0,S.jsx)(`span`,{className:`web-segments`,role:`group`,"aria-label":`Show as`,children:[`list`,`tree`].map(e=>(0,S.jsx)(`button`,{type:`button`,className:`web-segments__item web-segments__item--icon`,"aria-pressed":M===e,title:e===`list`?`Show as a list`:`Show as a tree`,"aria-label":e===`list`?`Show as a list`:`Show as a tree`,onClick:()=>$(e),children:e===`list`?l.log:l.tree},e))})]}),T.length===0?null:(0,S.jsx)(`input`,{className:`web-explorer__filter`,type:`search`,value:L,placeholder:`Filter files`,"aria-label":`Filter files`,onChange:e=>_e(e.target.value)}),(0,S.jsxs)(`div`,{className:`web-explorer__scroll`,onContextMenu:we,children:[(0,S.jsx)(`div`,{className:`web-explorer__notice`,children:Ee}),(0,S.jsx)(ee,{nodes:Y,selectedKey:ye,expanded:Ce,onExpandedChange:e=>R(new Set(X.filter(t=>!e.has(t)))),onSelect:t=>{if(t.data===void 0){R(e=>{let n=new Set(e);return n.delete(t.key)||n.add(t.key),n});return}z(t.key),_(e,t.data,C?.uri,P)}}),G!==``&&K.length===0?(0,S.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`Nothing matches.`}):null]}),(0,S.jsx)(de,{form:w.form,files:T,onCommit:w.commit,onPullRequest:w.pullRequest,onClose:w.closeForm}),B===null?null:(0,S.jsx)(u,{spec:{items:B.items},x:B.x,y:B.y,onClose:()=>V(null)})]})}export{A as default};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{l as n,r}from"./notify-Bb548jAB.js";import{t as i}from"./useStore-BQkzWMs-.js";import{n as a}from"./ScenaProvider-6A3TJumQ.js";import{C as o,F as s,L as c,R as l,c as u,g as d,r as f,w as p,z as m}from"./data-Fkj0LNnG.js";import{n as h}from"./words-BknpHIF3.js";import{t as g}from"./emojis-BOylxma2.js";import{t as _}from"./Spinner-B-iOhBZq.js";import{t as v}from"./Alert-CHZkhmDE.js";import{t as y}from"./state-KGSq646f.js";import{t as b}from"./ExplorerList-Bdp0sfLW.js";var x=t(),S=[{id:`none`,label:`No groups`},{id:`folder`,label:`Group by folder`},{id:`status`,label:`Group by status`},{id:`agent`,label:`Group by agent`}],C=[{key:`input`,label:`Needs you`},{key:`running`,label:`Running`},{key:`error`,label:`Failed`},{key:`unread`,label:`Unread`},{key:`idle`,label:`Idle`},{key:`archived`,label:`Archived`}];function w(e){if(l(e.status))return C[5];let t=c(e.status);return t===`idle`&&!m(e.status)?C[3]:C.find(e=>e.key===t)}function T(e,t,n){switch(t){case`none`:return;case`status`:return w(e);case`agent`:return{key:e.provider,label:n(e.provider)};case`folder`:{let t=e.workingDirectories?.[0];return t===void 0?{key:``,label:`No folder`}:{key:t,label:h(t)}}}}function E(e,t,n){if(n===`none`)return[...e];let r=new Map;n===`status`&&C.forEach((e,t)=>r.set(e.key,t));for(let n of e){let e=t(n)?.key??``;r.has(e)||r.set(e,r.size+C.length)}return e.map((e,n)=>({item:e,index:n,rank:r.get(t(e)?.key??``)})).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.item)}var D=e(),O=`ahpd-web.session-grouping`;function k(){try{let e=localStorage.getItem(O);return S.some(t=>t.id===e)?e:`none`}catch{return`none`}}function A(e){try{localStorage.setItem(O,e)}catch{}}var j=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`}),M=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`});function N(e,t=new Date){let n=new Date(e);return Number.isNaN(n.getTime())?``:(n.toDateString()===t.toDateString()?j:M).format(n)}var P={input:`attention`,running:`working`,error:`failed`,idle:`quiet`},F=e=>h(e).replace(/\/+$/,``).split(`/`).pop()??e;function I(e,t){let i=m(e.status),a=l(e.status),o=t=>d(e.resource,t);return[{title:`Open`,onSelect:e=>{e.closeMenu(),t()}},{title:`Rename`,onSelect:t=>{t.closeMenu();let n=window.prompt(`Rename the session`,e.title)?.trim();n!==void 0&&n!==``&&n!==e.title&&o({type:`session/titleChanged`,title:n})}},{title:i?`Mark as unread`:`Mark as read`,onSelect:e=>{e.closeMenu(),o({type:`session/isReadChanged`,isRead:!i})}},{title:a?`Unarchive`:`Archive`,onSelect:e=>{e.closeMenu(),o({type:`session/isArchivedChanged`,isArchived:!a})}},{title:`Copy link`,group:`more`,onSelect:t=>{t.closeMenu(),navigator.clipboard?.writeText(e.resource).catch(()=>void 0)}},{title:`Delete`,group:`more`,color:`red`,onSelect:t=>{t.closeMenu(),n({title:`Delete "${e.title||`Untitled`}"?`,body:`Its history goes with it.`,confirmLabel:`Delete`,tone:`danger`}).then(t=>{t&&p(`disposeSession`,{channel:e.resource}).catch(e=>r(`The session could not be deleted`,e))})}}]}function L(){let e=a(),t=i(f),n=i(u),r=i(`$/ahp/agents`)??[],d=i(y),[p,h]=(0,x.useState)(!1),[C,w]=(0,x.useState)(k),O=e=>{w(e),A(e)},[j,M]=(0,x.useState)(!1),L=t=>void e.commands.execute(`ahp.openSession`,{resource:t}),R=(0,x.useMemo)(()=>{let e=e=>r.find(t=>t.provider===e)?.displayName??e;return E((n??[]).filter(e=>p||!l(e.status)),t=>T(t,C,e),C).map(t=>{let n=c(t.status),r=n===`idle`&&!m(t.status),i=e(t.provider),a=T(t,C,e),o=t.workingDirectories?.[0],u=[i,o===void 0?void 0:F(o)].filter(e=>e!==void 0).join(` · `),d=t.changes,f=n===`idle`?d!==void 0&&(d.additions??0)+(d.deletions??0)>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{className:`web-diff--add`,children:[`+`,d.additions??0]}),` `,(0,D.jsxs)(`span`,{className:`web-diff--remove`,children:[`-`,d.deletions??0]}),d.files===void 0?``:` \u{00B7} ${d.files} files`]}):void 0:`${s[n]}${t.activity===void 0||t.activity===``?``:` \u{00B7} ${t.activity}`}`;return{key:t.resource,dot:l(t.status)?`off`:r?`fresh`:P[n],dotLabel:l(t.status)?`Archived`:r?`Unread`:s[n],title:t.title===``?`Untitled`:t.title,time:N(t.modifiedAt),lines:f===void 0?[u]:[u,f],menu:I(t,()=>L(t.resource)),strong:r,...a===void 0?{}:{group:a}}})},[n,r,p,C]),z=()=>{M(!0),o().catch(()=>void 0).finally(()=>M(!1))},B=t?.status===`failed`?(0,D.jsx)(v,{tone:`danger`,title:`Not connected`,message:t.error??`The server refused the connection.`}):t?.status!==`connected`&&n===void 0?(0,D.jsx)(_,{label:`Connecting to the server`}):R.length===0?(0,D.jsx)(`p`,{className:`web-note`,children:p?`No sessions.`:`No sessions yet.`}):null;return(0,D.jsx)(b,{title:`Sessions`,actions:[{icon:`+`,label:`New session`,run:()=>void e.commands.execute(`ahp.newSession`)},{icon:g.reload,label:j?`Reloading`:`Reload`,run:z,busy:j},{icon:g.archived,label:p?`Hide archived`:`Show archived`,run:()=>h(!p),on:p},{icon:g.group,label:`Group sessions`,on:C!==`none`,menu:S.map(e=>({title:e.label,...e.id===C?{description:`Current`}:{},onSelect:t=>{t.closeMenu(),O(e.id)}}))}],rows:R,selected:d??null,onOpen:L,notice:B,filterLabel:`Filter sessions`})}export{L as default};
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{l as n,r}from"./notify-CJo-T9e2.js";import{t as i}from"./useStore-BQkzWMs-.js";import{n as a}from"./ScenaProvider-6A3TJumQ.js";import{A as o,G as s,J as c,Y as l,c as u,j as d,q as f,r as p,v as m}from"./data-CBWyZN_H.js";import{n as h}from"./words-T8-D0K4W.js";import{t as g}from"./emojis-7RT6GvLa.js";import{t as _}from"./Spinner-B-iOhBZq.js";import{t as v}from"./Alert-CHZkhmDE.js";import{t as y}from"./state-KGSq646f.js";import{t as b}from"./ExplorerList-DfesRs43.js";var x=t(),S=[{id:`none`,label:`No groups`},{id:`folder`,label:`Group by folder`},{id:`status`,label:`Group by status`},{id:`agent`,label:`Group by agent`}],C=[{key:`input`,label:`Needs you`},{key:`running`,label:`Running`},{key:`error`,label:`Failed`},{key:`unread`,label:`Unread`},{key:`idle`,label:`Idle`},{key:`archived`,label:`Archived`}];function w(e){if(c(e.status))return C[5];let t=f(e.status);return t===`idle`&&!l(e.status)?C[3]:C.find(e=>e.key===t)}function T(e,t,n){switch(t){case`none`:return;case`status`:return w(e);case`agent`:return{key:e.provider,label:n(e.provider)};case`folder`:{let t=e.workingDirectories?.[0];return t===void 0?{key:``,label:`No folder`}:{key:t,label:h(t)}}}}function E(e,t,n){if(n===`none`)return[...e];let r=new Map;n===`status`&&C.forEach((e,t)=>r.set(e.key,t));for(let n of e){let e=t(n)?.key??``;r.has(e)||r.set(e,r.size+C.length)}return e.map((e,n)=>({item:e,index:n,rank:r.get(t(e)?.key??``)})).sort((e,t)=>e.rank-t.rank||e.index-t.index).map(e=>e.item)}var D=e(),O=`ahpd-web.session-grouping`;function k(){try{let e=localStorage.getItem(O);return S.some(t=>t.id===e)?e:`none`}catch{return`none`}}function A(e){try{localStorage.setItem(O,e)}catch{}}var j=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`}),M=new Intl.DateTimeFormat(void 0,{month:`short`,day:`numeric`});function N(e,t=new Date){let n=new Date(e);return Number.isNaN(n.getTime())?``:(n.toDateString()===t.toDateString()?j:M).format(n)}var P={input:`attention`,running:`working`,error:`failed`,idle:`quiet`},F=e=>h(e).replace(/\/+$/,``).split(`/`).pop()??e;function I(e,t){let i=l(e.status),a=c(e.status),o=t=>m(e.resource,t);return[{title:`Open`,onSelect:e=>{e.closeMenu(),t()}},{title:`Rename`,onSelect:t=>{t.closeMenu();let n=window.prompt(`Rename the session`,e.title)?.trim();n!==void 0&&n!==``&&n!==e.title&&o({type:`session/titleChanged`,title:n})}},{title:i?`Mark as unread`:`Mark as read`,onSelect:e=>{e.closeMenu(),o({type:`session/isReadChanged`,isRead:!i})}},{title:a?`Unarchive`:`Archive`,onSelect:e=>{e.closeMenu(),o({type:`session/isArchivedChanged`,isArchived:!a})}},{title:`Copy link`,group:`more`,onSelect:t=>{t.closeMenu(),navigator.clipboard?.writeText(e.resource).catch(()=>void 0)}},{title:`Delete`,group:`more`,color:`red`,onSelect:t=>{t.closeMenu(),n({title:`Delete "${e.title||`Untitled`}"?`,body:`Its history goes with it.`,confirmLabel:`Delete`,tone:`danger`}).then(t=>{t&&d(`disposeSession`,{channel:e.resource}).catch(e=>r(`The session could not be deleted`,e))})}}]}function L(){let e=a(),t=i(p),n=i(u),r=i(`$/ahp/agents`)??[],d=i(y),[m,h]=(0,x.useState)(!1),[C,w]=(0,x.useState)(k),O=e=>{w(e),A(e)},[j,M]=(0,x.useState)(!1),L=t=>void e.commands.execute(`ahp.openSession`,{resource:t}),R=(0,x.useMemo)(()=>{let e=e=>r.find(t=>t.provider===e)?.displayName??e;return E((n??[]).filter(e=>m||!c(e.status)),t=>T(t,C,e),C).map(t=>{let n=f(t.status),r=n===`idle`&&!l(t.status),i=e(t.provider),a=T(t,C,e),o=t.workingDirectories?.[0],u=[i,o===void 0?void 0:F(o)].filter(e=>e!==void 0).join(` · `),d=t.changes,p=n===`idle`?d!==void 0&&(d.additions??0)+(d.deletions??0)>0?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`span`,{className:`web-diff--add`,children:[`+`,d.additions??0]}),` `,(0,D.jsxs)(`span`,{className:`web-diff--remove`,children:[`-`,d.deletions??0]}),d.files===void 0?``:` \u{00B7} ${d.files} files`]}):void 0:`${s[n]}${t.activity===void 0||t.activity===``?``:` \u{00B7} ${t.activity}`}`;return{key:t.resource,dot:c(t.status)?`off`:r?`fresh`:P[n],dotLabel:c(t.status)?`Archived`:r?`Unread`:s[n],title:t.title===``?`Untitled`:t.title,time:N(t.modifiedAt),lines:p===void 0?[u]:[u,p],menu:I(t,()=>L(t.resource)),strong:r,...a===void 0?{}:{group:a}}})},[n,r,m,C]),z=()=>{M(!0),o().catch(()=>void 0).finally(()=>M(!1))},B=t?.status===`failed`?(0,D.jsx)(v,{tone:`danger`,title:`Not connected`,message:t.error??`The server refused the connection.`}):t?.status!==`connected`&&n===void 0?(0,D.jsx)(_,{label:`Connecting to the server`}):R.length===0?(0,D.jsx)(`p`,{className:`web-note`,children:m?`No sessions.`:`No sessions yet.`}):null;return(0,D.jsx)(b,{title:`Sessions`,actions:[{icon:`+`,label:`New session`,run:()=>void e.commands.execute(`ahp.newSession`)},{icon:g.reload,label:j?`Reloading`:`Reload`,run:z,busy:j},{icon:g.archived,label:m?`Hide archived`:`Show archived`,run:()=>h(!m),on:m},{icon:g.group,label:`Group sessions`,on:C!==`none`,menu:S.map(e=>({title:e.label,...e.id===C?{description:`Current`}:{},onSelect:t=>{t.closeMenu(),O(e.id)}}))}],rows:R,selected:d??null,onOpen:L,notice:B,filterLabel:`Filter sessions`})}export{L as default};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./emojis-BOylxma2.js";import{t as r}from"./ContextMenu-qqlGWvJT.js";var i=t(),a=e();function o({title:e,actions:t,rows:o,selected:s,onOpen:c,notice:l,filterLabel:u}){let[d,f]=(0,i.useState)(null),[p,m]=(0,i.useState)(``),[h,g]=(0,i.useState)(new Set),_=e=>g(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),v=p.trim().toLowerCase(),y=v===``?o:o.filter(e=>[e.title,...e.lines.filter(e=>typeof e==`string`)].join(` `).toLowerCase().includes(v)),b=(e,t)=>{e.preventDefault(),f({x:e.clientX,y:e.clientY,items:t.menu})};return(0,a.jsxs)(`div`,{className:`web-explorer`,children:[(0,a.jsxs)(`div`,{className:`web-explorer__title`,children:[(0,a.jsx)(`span`,{children:e}),(0,a.jsx)(`span`,{className:`web-explorer__actions`,children:t.map(e=>(0,a.jsx)(`button`,{type:`button`,className:`web-explorer__action`,title:e.label,"aria-label":e.label,"aria-pressed":e.on,"data-on":e.on===!0?`true`:`false`,"data-busy":e.busy===!0?`true`:void 0,disabled:e.busy===!0,onClick:t=>{if(e.menu===void 0)return e.run?.();let n=t.currentTarget.getBoundingClientRect();f({x:n.left,y:n.bottom,items:e.menu})},children:(0,a.jsx)(`span`,{className:`web-explorer__icon`,children:e.icon})},e.label))})]}),u===void 0?null:(0,a.jsx)(`input`,{className:`web-explorer__filter`,type:`search`,value:p,placeholder:u,"aria-label":u,onChange:e=>m(e.target.value)}),(0,a.jsxs)(`div`,{className:`web-explorer__scroll`,children:[l==null?null:(0,a.jsx)(`div`,{className:`web-explorer__notice`,children:l}),(0,a.jsx)(`ul`,{className:`web-explorer__list`,role:`listbox`,"aria-label":e,children:y.map((e,t)=>{let r=e.group,o=r!==void 0&&y[t-1]?.group?.key!==r.key,l=o?y.filter(e=>e.group?.key===r.key).length:0,u=r!==void 0&&h.has(r.key);return(0,a.jsxs)(i.Fragment,{children:[o?(0,a.jsx)(`li`,{className:`web-explorer__group`,role:`presentation`,children:(0,a.jsxs)(`button`,{type:`button`,"aria-expanded":!u,onClick:()=>_(r.key),children:[(0,a.jsx)(`span`,{className:`web-explorer__fold`,"aria-hidden":`true`,children:u?n.caretRight:n.caretDown}),(0,a.jsx)(`span`,{className:`web-explorer__group-label`,children:r.label}),(0,a.jsx)(`span`,{className:`web-explorer__count`,children:l})]})}):null,u?null:(0,a.jsxs)(`li`,{role:`option`,"aria-selected":e.key===s,tabIndex:0,className:`web-row`,"data-selected":e.key===s?`true`:`false`,onClick:()=>c(e.key),onKeyDown:t=>{if((t.key===`Enter`||t.key===` `)&&(t.preventDefault(),c(e.key)),t.key===`ContextMenu`||t.shiftKey&&t.key===`F10`){t.preventDefault();let n=t.currentTarget.getBoundingClientRect();f({x:n.left+24,y:n.bottom,items:e.menu})}},onContextMenu:t=>b(t,e),children:[(0,a.jsx)(`span`,{className:`web-row__dot`,"data-dot":e.dot,title:e.dotLabel,"aria-label":e.dotLabel}),(0,a.jsxs)(`span`,{className:`web-row__body`,children:[(0,a.jsxs)(`span`,{className:`web-row__head`,children:[(0,a.jsx)(`span`,{className:`web-row__title`,"data-strong":e.strong===!0?`true`:`false`,children:e.title}),e.time===void 0?null:(0,a.jsx)(`span`,{className:`web-row__time`,children:e.time}),e.action===void 0?null:(0,a.jsx)(`button`,{type:`button`,className:`web-row__action`,title:e.action.label,"aria-label":e.action.label,onClick:t=>{t.stopPropagation(),e.action?.run()},onKeyDown:e=>e.stopPropagation(),children:e.action.icon})]}),e.lines.map((e,t)=>(0,a.jsx)(`span`,{className:`web-row__line`,children:e},t))]})]})]},e.key)})}),v!==``&&y.length===0?(0,a.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`Nothing matches.`}):null]}),d===null?null:(0,a.jsx)(r,{spec:{items:d.items},x:d.x,y:d.y,onClose:()=>f(null)})]})}export{o as t};
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./emojis-7RT6GvLa.js";import{t as r}from"./ContextMenu-BV1gdog0.js";var i=t(),a=e();function o({title:e,actions:t,rows:o,selected:s,onOpen:c,notice:l,filterLabel:u}){let[d,f]=(0,i.useState)(null),[p,m]=(0,i.useState)(``),[h,g]=(0,i.useState)(new Set),_=e=>g(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n}),v=p.trim().toLowerCase(),y=v===``?o:o.filter(e=>[e.title,...e.lines.filter(e=>typeof e==`string`)].join(` `).toLowerCase().includes(v)),b=(e,t)=>{e.preventDefault(),f({x:e.clientX,y:e.clientY,items:t.menu})};return(0,a.jsxs)(`div`,{className:`web-explorer`,children:[(0,a.jsxs)(`div`,{className:`web-explorer__title`,children:[(0,a.jsx)(`span`,{children:e}),(0,a.jsx)(`span`,{className:`web-explorer__actions`,children:t.map(e=>(0,a.jsx)(`button`,{type:`button`,className:`web-explorer__action`,title:e.label,"aria-label":e.label,"aria-pressed":e.on,"data-on":e.on===!0?`true`:`false`,"data-busy":e.busy===!0?`true`:void 0,disabled:e.busy===!0,onClick:t=>{if(e.menu===void 0)return e.run?.();let n=t.currentTarget.getBoundingClientRect();f({x:n.left,y:n.bottom,items:e.menu})},children:(0,a.jsx)(`span`,{className:`web-explorer__icon`,children:e.icon})},e.label))})]}),u===void 0?null:(0,a.jsx)(`input`,{className:`web-explorer__filter`,type:`search`,value:p,placeholder:u,"aria-label":u,onChange:e=>m(e.target.value)}),(0,a.jsxs)(`div`,{className:`web-explorer__scroll`,children:[l==null?null:(0,a.jsx)(`div`,{className:`web-explorer__notice`,children:l}),(0,a.jsx)(`ul`,{className:`web-explorer__list`,role:`listbox`,"aria-label":e,children:y.map((e,t)=>{let r=e.group,o=r!==void 0&&y[t-1]?.group?.key!==r.key,l=o?y.filter(e=>e.group?.key===r.key).length:0,u=r!==void 0&&h.has(r.key);return(0,a.jsxs)(i.Fragment,{children:[o?(0,a.jsx)(`li`,{className:`web-explorer__group`,role:`presentation`,children:(0,a.jsxs)(`button`,{type:`button`,"aria-expanded":!u,onClick:()=>_(r.key),children:[(0,a.jsx)(`span`,{className:`web-explorer__fold`,"aria-hidden":`true`,children:u?n.caretRight:n.caretDown}),(0,a.jsx)(`span`,{className:`web-explorer__group-label`,children:r.label}),(0,a.jsx)(`span`,{className:`web-explorer__count`,children:l})]})}):null,u?null:(0,a.jsxs)(`li`,{role:`option`,"aria-selected":e.key===s,tabIndex:0,className:`web-row`,"data-selected":e.key===s?`true`:`false`,onClick:()=>c(e.key),onKeyDown:t=>{if((t.key===`Enter`||t.key===` `)&&(t.preventDefault(),c(e.key)),t.key===`ContextMenu`||t.shiftKey&&t.key===`F10`){t.preventDefault();let n=t.currentTarget.getBoundingClientRect();f({x:n.left+24,y:n.bottom,items:e.menu})}},onContextMenu:t=>b(t,e),children:[(0,a.jsx)(`span`,{className:`web-row__dot`,"data-dot":e.dot,title:e.dotLabel,"aria-label":e.dotLabel,children:e.dot===`working`?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(`i`,{}),(0,a.jsx)(`i`,{}),(0,a.jsx)(`i`,{}),(0,a.jsx)(`i`,{})]}):null}),(0,a.jsxs)(`span`,{className:`web-row__body`,children:[(0,a.jsxs)(`span`,{className:`web-row__head`,children:[(0,a.jsx)(`span`,{className:`web-row__title`,"data-strong":e.strong===!0?`true`:`false`,children:e.title}),e.time===void 0?null:(0,a.jsx)(`span`,{className:`web-row__time`,children:e.time}),e.action===void 0?null:(0,a.jsx)(`button`,{type:`button`,className:`web-row__action`,title:e.action.label,"aria-label":e.action.label,onClick:t=>{t.stopPropagation(),e.action?.run()},onKeyDown:e=>e.stopPropagation(),children:e.action.icon})]}),e.lines.map((e,t)=>(0,a.jsx)(`span`,{className:`web-row__line`,children:e},t))]})]})]},e.key)})}),v!==``&&y.length===0?(0,a.jsx)(`p`,{className:`web-note web-explorer__empty`,children:`Nothing matches.`}):null]}),d===null?null:(0,a.jsx)(r,{spec:{items:d.items},x:d.x,y:d.y,onClose:()=>f(null)})]})}export{o as t};
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./dist-DYPX2Ybv.js","./jsx-runtime-BguD1OXD.js","./dist-BDH0Q8eg.js","./dist-Bq_hlZV8.js","./dist-rmKzqdIO.js","./dist-IR189dk6.js","./dist-D9412h7o.js","./dist-BfGIsxxP.js","./dist-CYq92lOO.js","./dist-CxEuuaKq.js","./dist-33oU5N7i.js","./dist-CEr2uR4w.js","./dist-1MAn9CBM.js","./dist-drsoOe-s.js","./dist-C5-Hv917.js","./dist-BnQxBrCW.js","./dist-B9NMd4es.js"])))=>i.map(i=>d[i]);
2
+ import{r as e,t}from"./jsx-runtime-BguD1OXD.js";import{t as n}from"./react-CybPckBe.js";import{t as r}from"./preload-helper-BaNbYf_w.js";import{t as i}from"./useCloseGuard-B4qJKmaF.js";import{F as a,st as o,y as s}from"./data-CBWyZN_H.js";import{t as c}from"./Spinner-B-iOhBZq.js";import{t as l}from"./Alert-CHZkhmDE.js";import{$ as u,A as d,B as f,C as p,D as m,Dt as h,F as g,G as _,H as v,I as ee,J as te,K as ne,L as re,M as ie,N as y,P as ae,Q as b,R as oe,T as se,U as ce,V as le,W as ue,X as de,Y as fe,Z as pe,_ as me,_t as x,at as he,b as ge,bt as S,c as _e,ct as ve,dt as ye,et as be,ft as C,gt as w,h as xe,ht as Se,it as T,j as E,k as Ce,l as we,lt as Te,mt as Ee,n as De,nt as D,ot as O,pt as Oe,q as ke,rt as Ae,st as je,t as Me,tt as Ne,ut as Pe,vt as Fe,w as Ie,wt as k,x as Le,xt as Re,yt as ze,z as Be}from"./dist-BDH0Q8eg.js";import{n as Ve,t as He}from"./text-B601jRcP.js";var A=n(),Ue=class{constructor(e,t,n,r){this.state=e,this.pos=t,this.explicit=n,this.view=r,this.abortListeners=[],this.abortOnDocChange=!1}tokenBefore(e){let t=d(this.state).resolveInner(this.pos,-1);for(;t&&e.indexOf(t.name)<0;)t=t.parent;return t?{from:t.from,to:this.pos,text:this.state.sliceDoc(t.from,this.pos),type:t.type}:null}matchBefore(e){let t=this.state.doc.lineAt(this.pos),n=Math.max(t.from,this.pos-250),r=t.text.slice(n-t.from,this.pos-t.from),i=r.search(Ye(e,!1));return i<0?null:{from:n+i,to:this.pos,text:r.slice(i)}}get aborted(){return this.abortListeners==null}addEventListener(e,t,n){e==`abort`&&this.abortListeners&&(this.abortListeners.push(t),n&&n.onDocChange&&(this.abortOnDocChange=!0))}};function We(e){let t=Object.keys(e).join(``),n=/\w/.test(t);return n&&(t=t.replace(/\w/g,``)),`[${n?`\\w`:``}${t.replace(/[^\w\s]/g,`\\$&`)}]`}function Ge(e){let t=Object.create(null),n=Object.create(null);for(let{label:r}of e){t[r[0]]=!0;for(let e=1;e<r.length;e++)n[r[e]]=!0}let r=We(t)+We(n)+`*$`;return[RegExp(`^`+r),new RegExp(r)]}function Ke(e){let t=e.map(e=>typeof e==`string`?{label:e}:e),[n,r]=t.every(e=>/^\w+$/.test(e.label))?[/\w*$/,/\w+$/]:Ge(t);return e=>{let i=e.matchBefore(r);return i||e.explicit?{from:i?i.from:e.pos,options:t,validFor:n}:null}}function qe(e,t){return n=>{for(let t=d(n.state).resolveInner(n.pos,-1);t;t=t.parent){if(e.indexOf(t.name)>-1)return null;if(t.type.isTop)break}return t(n)}}var Je=class{constructor(e,t,n,r){this.completion=e,this.source=t,this.match=n,this.score=r}};function j(e){return e.selection.main.from}function Ye(e,t){let{source:n}=e,r=t&&n[0]!=`^`,i=n[n.length-1]!=`$`;return!r&&!i?e:RegExp(`${r?`^`:``}(?:${n})${i?`$`:``}`,e.flags??(e.ignoreCase?`i`:``))}var Xe=u.define();function Ze(e,t,n,r){let{main:i}=e.selection,a=n-i.from,o=r-i.from;return{...e.changeByRange(s=>{if(s!=i&&n!=r&&e.sliceDoc(s.from+a,s.from+o)!=e.sliceDoc(n,r))return{range:s};let c=e.toText(t);return{changes:{from:s.from+a,to:r==i.from?s.to:s.from+o,insert:c},range:T.cursor(s.from+a+c.length)}}),scrollIntoView:!0,userEvent:`input.complete`}}var Qe=new WeakMap;function $e(e){if(!Array.isArray(e))return e;let t=Qe.get(e);return t||Qe.set(e,t=Ke(e)),t}var et=C.define(),tt=C.define(),nt=class{constructor(e){this.pattern=e,this.chars=[],this.folded=[],this.any=[],this.precise=[],this.byWord=[],this.score=0,this.matched=[];for(let t=0;t<e.length;){let n=w(e,t),r=x(n);this.chars.push(n);let i=e.slice(t,t+r),a=i.toUpperCase();this.folded.push(w(a==i?i.toLowerCase():a,0)),t+=r}this.astral=e.length!=this.chars.length}ret(e,t){return this.score=e,this.matched=t,this}match(e){if(this.pattern.length==0)return this.ret(-100,[]);if(e.length<this.pattern.length)return null;let{chars:t,folded:n,any:r,precise:i,byWord:a}=this;if(t.length==1){let r=w(e,0),i=x(r),a=i==e.length?0:-100;if(r!=t[0]){if(r==n[0])a+=-200;else return null}return this.ret(a,[0,i])}let o=e.indexOf(this.pattern);if(o==0)return this.ret(e.length==this.pattern.length?0:-100,[0,this.pattern.length]);let s=t.length,c=0;if(o<0){for(let i=0,a=Math.min(e.length,200);i<a&&c<s;){let a=w(e,i);(a==t[c]||a==n[c])&&(r[c++]=i),i+=x(a)}if(c<s)return null}let l=0,u=0,d=!1,f=0,p=-1,m=-1,h=/[a-z]/.test(e),g=!0;for(let r=0,c=Math.min(e.length,200),_=0;r<c&&u<s;){let c=w(e,r);o<0&&(l<s&&c==t[l]&&(i[l++]=r),f<s&&(c==t[f]||c==n[f]?(f==0&&(p=r),m=r+1,f++):f=0));let v,ee=c<255?c>=48&&c<=57||c>=97&&c<=122?2:+(c>=65&&c<=90):(v=Re(c))==v.toLowerCase()?v==v.toUpperCase()?0:2:1;(!r||ee==1&&h||_==0&&ee!=0)&&(t[u]==c||n[u]==c&&(d=!0)?a[u++]=r:a.length&&(g=!1)),_=ee,r+=x(c)}return u==s&&a[0]==0&&g?this.result(-100+(d?-200:0),a,e):f==s&&p==0?this.ret(-200-e.length+(m==e.length?0:-100),[0,m]):o>-1?this.ret(-700-e.length,[o,o+this.pattern.length]):f==s?this.ret(-900-e.length,[p,m]):u==s?this.result(-100+(d?-200:0)+-700+(g?0:-1100),a,e):t.length==2?null:this.result((r[0]?-700:0)+-200+-1100,r,e)}result(e,t,n){let r=[],i=0;for(let e of t){let t=e+(this.astral?x(w(n,e)):1);i&&r[i-1]==e?r[i-1]=t:(r[i++]=e,r[i++]=t)}return this.ret(e-n.length,r)}},rt=class{constructor(e){this.pattern=e,this.matched=[],this.score=0,this.folded=e.toLowerCase()}match(e){if(e.length<this.pattern.length)return null;let t=e.slice(0,this.pattern.length),n=t==this.pattern?0:t.toLowerCase()==this.folded?-200:null;return n==null?null:(this.matched=[0,t.length],this.score=n+(e.length==this.pattern.length?0:-100),this)}},M=O.define({combine(e){return Fe(e,{activateOnTyping:!0,activateOnCompletion:()=>!1,activateOnTypingDelay:100,selectOnOpen:!0,override:null,closeOnBlur:!0,maxRenderedOptions:100,defaultKeymap:!0,tooltipClass:()=>``,optionClass:()=>``,aboveCursor:!1,icons:!0,addToOptions:[],positionInfo:at,filterStrict:!1,compareCompletions:(e,t)=>(e.sortText||e.label).localeCompare(t.sortText||t.label),interactionDelay:75,updateSyncTime:100},{defaultKeymap:(e,t)=>e&&t,closeOnBlur:(e,t)=>e&&t,icons:(e,t)=>e&&t,tooltipClass:(e,t)=>n=>it(e(n),t(n)),optionClass:(e,t)=>n=>it(e(n),t(n)),addToOptions:(e,t)=>e.concat(t),filterStrict:(e,t)=>e||t})}});function it(e,t){return e?t?e+` `+t:e:t}function at(e,t,n,r,i,a){let o=e.textDirection==ie.RTL,s=o,c=!1,l=`top`,u,d,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,h=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-h))-t.top,d=Math.min(400,s?f:p);else{c=!0,d=Math.min(400,(o?t.right:i.right-t.left)-30);let e=i.bottom-t.bottom;e>=h||e>t.top?u=n.bottom-t.top:(l=`bottom`,u=t.bottom-n.top)}let g=(t.bottom-t.top)/a.offsetHeight,_=(t.right-t.left)/a.offsetWidth;return{style:`${l}: ${u/g}px; max-width: ${d/_}px`,class:`cm-completionInfo-`+(c?o?`left-narrow`:`right-narrow`:s?`left`:`right`)}}var ot=C.define();function st(e){let t=e.addToOptions.slice();return e.icons&&t.push({render(e){let t=document.createElement(`div`);return t.classList.add(`cm-completionIcon`),e.type&&t.classList.add(...e.type.split(/\s+/g).map(e=>`cm-completionIcon-`+e)),t.setAttribute(`aria-hidden`,`true`),t},position:20}),t.push({render(e,t,n,r){let i=document.createElement(`span`);i.className=`cm-completionLabel`;let a=e.displayLabel||e.label,o=0;for(let e=0;e<r.length;){let t=r[e++],n=r[e++];t>o&&i.appendChild(document.createTextNode(a.slice(o,t)));let s=i.appendChild(document.createElement(`span`));s.appendChild(document.createTextNode(a.slice(t,n))),s.className=`cm-completionMatchedText`,o=n}return o<a.length&&i.appendChild(document.createTextNode(a.slice(o))),i},position:50},{render(e){if(!e.detail)return null;let t=document.createElement(`span`);return t.className=`cm-completionDetail`,t.textContent=e.detail,t},position:80}),t.sort((e,t)=>e.position-t.position).map(e=>e.render)}function ct(e,t,n){if(e<=n)return{from:0,to:e};if(t<0&&(t=0),t<=e>>1){let e=Math.floor(t/n);return{from:e*n,to:(e+1)*n}}let r=Math.ceil((e-t)/n);return{from:e-r*n,to:e-(r-1)*n}}var lt=class{constructor(e,t,n){this.view=e,this.stateField=t,this.applyCompletion=n,this.info=null,this.infoDestroy=null,this.placeInfoReq={read:()=>this.measureInfo(),write:e=>this.placeInfo(e),key:this},this.space=null,this.currentClass=``;let r=e.state.field(t),{options:i,selected:a}=r.open,o=e.state.facet(M);this.optionContent=st(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=ct(i.length,a,o.maxRenderedOptions),this.dom=document.createElement(`div`),this.dom.className=`cm-tooltip-autocomplete`,this.updateTooltipClass(e.state),this.dom.addEventListener(`mousedown`,n=>{let{options:r}=e.state.field(t).open;for(let t=n.target,i;t&&t!=this.dom;t=t.parentNode)if(t.nodeName==`LI`&&(i=/-(\d+)$/.exec(t.id))&&+i[1]<r.length){this.applyCompletion(e,r[+i[1]]),n.preventDefault();return}if(n.target==this.list){let t=this.list.classList.contains(`cm-completionListIncompleteTop`)&&n.clientY<this.list.firstChild.getBoundingClientRect().top?this.range.from-1:this.list.classList.contains(`cm-completionListIncompleteBottom`)&&n.clientY>this.list.lastChild.getBoundingClientRect().bottom?this.range.to:null;t!=null&&(e.dispatch({effects:ot.of(t)}),n.preventDefault())}}),this.dom.addEventListener(`focusout`,t=>{let n=e.state.field(this.stateField,!1);n&&n.tooltip&&e.state.facet(M).closeOnBlur&&t.relatedTarget!=e.contentDOM&&e.dispatch({effects:tt.of(null)})}),this.showOptions(i,r.id)}mount(){this.updateSel()}showOptions(e,t){this.list&&this.list.remove(),this.list=this.dom.appendChild(this.createListBox(e,t,this.range)),this.list.addEventListener(`scroll`,()=>{this.info&&this.view.requestMeasure(this.placeInfoReq)})}update(e){let t=e.state.field(this.stateField),n=e.startState.field(this.stateField);if(this.updateTooltipClass(e.state),t!=n){let{options:r,selected:i,disabled:a}=t.open;(!n.open||n.open.options!=r)&&(this.range=ct(r.length,i,e.state.facet(M).maxRenderedOptions),this.showOptions(r,t.id)),this.updateSel(),a!=n.open?.disabled&&this.dom.classList.toggle(`cm-tooltip-autocomplete-disabled`,!!a)}}updateTooltipClass(e){let t=this.tooltipClass(e);if(t!=this.currentClass){for(let e of this.currentClass.split(` `))e&&this.dom.classList.remove(e);for(let e of t.split(` `))e&&this.dom.classList.add(e);this.currentClass=t}}positioned(e){this.space=e,this.info&&this.view.requestMeasure(this.placeInfoReq)}updateSel(){let e=this.view.state.field(this.stateField),t=e.open;(t.selected>-1&&t.selected<this.range.from||t.selected>=this.range.to)&&(this.range=ct(t.options.length,t.selected,this.view.state.facet(M).maxRenderedOptions),this.showOptions(t.options,e.id));let n=this.updateSelectedOption(t.selected);if(n){this.destroyInfo();let{completion:r}=t.options[t.selected],{info:i}=r;if(!i)return;let a=typeof i==`string`?document.createTextNode(i):i(r);if(!a)return;`then`in a?a.then(t=>{t&&this.view.state.field(this.stateField,!1)==e&&this.addInfoPane(t,r)}).catch(e=>ne(this.view.state,e,`completion info`)):(this.addInfoPane(a,r),n.setAttribute(`aria-describedby`,this.info.id))}}addInfoPane(e,t){this.destroyInfo();let n=this.info=document.createElement(`div`);if(n.className=`cm-tooltip cm-completionInfo`,n.id=`cm-completionInfo-`+Math.floor(Math.random()*65535).toString(16),e.nodeType!=null)n.appendChild(e),this.infoDestroy=null;else{let{dom:t,destroy:r}=e;n.appendChild(t),this.infoDestroy=r||null}this.dom.appendChild(n),this.view.requestMeasure(this.placeInfoReq)}updateSelectedOption(e){let t=null;for(let n=this.list.firstChild,r=this.range.from;n;n=n.nextSibling,r++)n.nodeName!=`LI`||!n.id?r--:r==e?n.hasAttribute(`aria-selected`)||(n.setAttribute(`aria-selected`,`true`),t=n):n.hasAttribute(`aria-selected`)&&(n.removeAttribute(`aria-selected`),n.removeAttribute(`aria-describedby`));return t&&dt(this.list,t),t}measureInfo(){let e=this.dom.querySelector(`[aria-selected]`);if(!e||!this.info)return null;let t=this.dom.getBoundingClientRect(),n=this.info.getBoundingClientRect(),r=e.getBoundingClientRect(),i=this.space;if(!i){let e=this.dom.ownerDocument.documentElement;i={left:0,top:0,right:e.clientWidth,bottom:e.clientHeight}}return r.top>Math.min(i.bottom,t.bottom)-10||r.bottom<Math.max(i.top,t.top)+10?null:this.view.state.facet(M).positionInfo(this.view,t,r,n,i,this.dom)}placeInfo(e){this.info&&(e?(e.style&&(this.info.style.cssText=e.style),this.info.className=`cm-tooltip cm-completionInfo `+(e.class||``)):this.info.style.cssText=`top: -1e6px`)}createListBox(e,t,n){let r=document.createElement(`ul`);r.id=t,r.setAttribute(`role`,`listbox`),r.setAttribute(`aria-expanded`,`true`),r.setAttribute(`aria-label`,this.view.state.phrase(`Completions`)),r.addEventListener(`mousedown`,e=>{e.target==r&&e.preventDefault()});let i=null;for(let a=n.from;a<n.to;a++){let{completion:o,match:s}=e[a],{section:c}=o;if(c){let e=typeof c==`string`?c:c.name;if(e!=i&&(a>n.from||n.from==0)){if(i=e,typeof c!=`string`&&c.header)r.appendChild(c.header(c));else{let t=r.appendChild(document.createElement(`completion-section`));t.textContent=e}}}let l=r.appendChild(document.createElement(`li`));l.id=t+`-`+a,l.setAttribute(`role`,`option`);let u=this.optionClass(o);u&&(l.className=u);for(let e of this.optionContent){let t=e(o,this.view.state,this.view,s);t&&l.appendChild(t)}}return n.from&&r.classList.add(`cm-completionListIncompleteTop`),n.to<e.length&&r.classList.add(`cm-completionListIncompleteBottom`),r}destroyInfo(){this.info&&=(this.infoDestroy&&this.infoDestroy(),this.info.remove(),null)}destroy(){this.destroyInfo()}};function ut(e,t){return n=>new lt(n,e,t)}function dt(e,t){let n=e.getBoundingClientRect(),r=t.getBoundingClientRect(),i=n.height/e.offsetHeight;r.top<n.top?e.scrollTop-=(n.top-r.top)/i:r.bottom>n.bottom&&(e.scrollTop+=(r.bottom-n.bottom)/i)}function ft(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+ +!!e.type}function pt(e,t){let n=[],r=null,i=null,a=e=>{n.push(e);let{section:t}=e.completion;if(t){r||=[];let e=typeof t==`string`?t:t.name;r.some(t=>t.name==e)||r.push(typeof t==`string`?{name:e}:t)}},o=t.facet(M);for(let r of e)if(r.hasResult()){let e=r.result.getMatch;if(r.result.filter===!1)for(let t of r.result.options)a(new Je(t,r.source,e?e(t):[],1e9-n.length));else{let n=t.sliceDoc(r.from,r.to),s,c=o.filterStrict?new rt(n):new nt(n);for(let t of r.result.options)if(s=c.match(t.label)){let n=t.displayLabel?e?e(t,s.matched):[]:s.matched,o=s.score+(t.boost||0);if(a(new Je(t,r.source,n,o)),typeof t.section==`object`&&t.section.rank===`dynamic`){let{name:e}=t.section;i||=Object.create(null),i[e]=Math.max(o,i[e]||-1e9)}}}}if(r){let e=Object.create(null),t=0,a=(e,t)=>(e.rank===`dynamic`&&t.rank===`dynamic`?i[t.name]-i[e.name]:0)||(typeof e.rank==`number`?e.rank:1e9)-(typeof t.rank==`number`?t.rank:1e9)||(e.name<t.name?-1:1);for(let n of r.sort(a))t-=1e5,e[n.name]=t;for(let t of n){let{section:n}=t.completion;n&&(t.score+=e[typeof n==`string`?n:n.name])}}let s=[],c=null,l=o.compareCompletions;for(let e of n.sort((e,t)=>t.score-e.score||l(e.completion,t.completion))){let t=e.completion;!c||c.label!=t.label||c.detail!=t.detail||c.type!=null&&t.type!=null&&c.type!=t.type||c.apply!=t.apply||c.boost!=t.boost?s.push(e):ft(e.completion)>ft(c)&&(s[s.length-1]=e),c=e.completion}return s}var mt=class e{constructor(e,t,n,r,i,a){this.options=e,this.attrs=t,this.tooltip=n,this.timestamp=r,this.selected=i,this.disabled=a}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new e(this.options,yt(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,o){if(i&&!o&&t.some(e=>e.isPending))return i.setDisabled();let s=pt(t,n);if(!s.length)return i&&t.some(e=>e.isPending)?i.setDisabled():null;let c=n.facet(M).selectOnOpen?0:-1;if(i&&i.selected!=c&&i.selected!=-1){let e=i.options[i.selected].completion;for(let t=0;t<s.length;t++)if(s[t].completion==e){c=t;break}}return new e(s,yt(r,c),{pos:t.reduce((e,t)=>t.hasResult()?Math.min(e,t.from):e,1e8),create:Et,above:a.aboveCursor},i?i.timestamp:Date.now(),c,!1)}map(t){return new e(this.options,this.attrs,{...this.tooltip,pos:t.mapPos(this.tooltip.pos)},this.timestamp,this.selected,this.disabled)}setDisabled(){return new e(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}},ht=class e{constructor(e,t,n){this.active=e,this.id=t,this.open=n}static start(){return new e(bt,`cm-ac-`+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(M),i=(r.override||n.languageDataAt(`autocomplete`,j(n)).map($e)).map(e=>(this.active.find(t=>t.source==e)||new N(e,+!!this.active.some(e=>e.state!=0))).update(t,r));i.length==this.active.length&&i.every((e,t)=>e==this.active[t])&&(i=this.active);let a=this.open,o=t.effects.some(e=>e.is(wt));a&&t.docChanged&&(a=a.map(t.changes)),t.selection||i.some(e=>e.hasResult()&&t.changes.touchesRange(e.from,e.to))||!gt(i,this.active)||o?a=mt.build(i,n,this.id,a,r,o):a&&a.disabled&&!i.some(e=>e.isPending)&&(a=null),!a&&i.every(e=>!e.isPending)&&i.some(e=>e.hasResult())&&(i=i.map(e=>e.hasResult()?new N(e.source,0):e));for(let e of t.effects)e.is(ot)&&(a&&=a.setSelected(e.value,this.id));return i==this.active&&a==this.open?this:new e(i,this.id,a)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?_t:vt}};function gt(e,t){if(e==t)return!0;for(let n=0,r=0;;){for(;n<e.length&&!e[n].hasResult();)n++;for(;r<t.length&&!t[r].hasResult();)r++;let i=n==e.length,a=r==t.length;if(i||a)return i==a;if(e[n++].result!=t[r++].result)return!1}}var _t={"aria-autocomplete":`list`},vt={};function yt(e,t){let n={"aria-autocomplete":`list`,"aria-haspopup":`listbox`,"aria-controls":e};return t>-1&&(n[`aria-activedescendant`]=e+`-`+t),n}var bt=[];function xt(e,t){if(e.isUserEvent(`input.complete`)){let n=e.annotation(Xe);if(n&&t.activateOnCompletion(n))return 12}let n=e.isUserEvent(`input.type`);return n&&t.activateOnTyping?5:n?1:e.isUserEvent(`delete.backward`)?2:e.selection?8:e.docChanged?16:0}var N=class e{constructor(e,t,n=!1){this.source=e,this.state=t,this.explicit=n}hasResult(){return!1}get isPending(){return this.state==1}update(t,n){let r=xt(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new e(i.source,0)),r&4&&i.state==0&&(i=new e(this.source,1)),i=i.updateFor(t,r);for(let n of t.effects)if(n.is(et))i=new e(i.source,1,n.value);else if(n.is(tt))i=new e(i.source,0);else if(n.is(wt))for(let e of n.value)e.source==i.source&&(i=e);return i}updateFor(e,t){return this.map(e.changes)}map(e){return this}touches(e){return e.changes.touchesRange(j(e.state))}},St=class e extends N{constructor(e,t,n,r,i,a){super(e,3,t),this.limit=n,this.result=r,this.from=i,this.to=a}hasResult(){return!0}updateFor(t,n){if(!(n&3))return this.map(t.changes);let r=this.result;r.map&&!t.changes.empty&&(r=r.map(r,t.changes));let i=t.changes.mapPos(this.from),a=t.changes.mapPos(this.to,1),o=j(t.state);if(o>a||!r||n&2&&(j(t.startState)==this.from||o<this.limit))return new N(this.source,n&4?1:0);let s=t.changes.mapPos(this.limit);return Ct(r.validFor,t.state,i,a)?new e(this.source,this.explicit,s,r,i,a):r.update&&(r=r.update(r,i,a,new Ue(t.state,o,!1)))?new e(this.source,this.explicit,s,r,r.from,r.to??j(t.state)):new N(this.source,1,this.explicit)}map(t){if(t.empty)return this;let n=this.result.map?this.result.map(this.result,t):this.result;return n?new e(this.source,this.explicit,t.mapPos(this.limit),n,t.mapPos(this.from),t.mapPos(this.to,1)):new N(this.source,0)}touches(e){return e.changes.touchesRange(this.from,this.to)}};function Ct(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e==`function`?e(i,n,r,t):Ye(e,!0).test(i)}var wt=C.define({map(e,t){return e.map(e=>e.map(t))}}),P=Oe.define({create(){return ht.start()},update(e,t){return e.update(t)},provide:e=>[pe.from(e,e=>e.tooltip),y.contentAttributes.from(e,e=>e.attrs)]});function Tt(e,t){let n=t.completion.apply||t.completion.label,r=e.state.field(P).active.find(e=>e.source==t.source);return r instanceof St&&(typeof n==`string`?e.dispatch({...Ze(e.state,n,r.from,r.to),annotations:Xe.of(t.completion)}):n(e,t.completion,r.from,r.to),!0)}var Et=ut(P,Tt);function Dt(e,t=`option`){return n=>{let r=n.state.field(P,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(M).interactionDelay)return!1;let i=1,a;t==`page`&&(a=f(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector(`li`).offsetHeight)-1));let{length:o}=r.open.options,s=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:o-1;return s<0?s=t==`page`?0:o-1:s>=o&&(s=t==`page`?o-1:0),n.dispatch({effects:ot.of(s)}),!0}}var Ot=e=>{let t=e.state.field(P,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(M).interactionDelay?!1:Tt(e,t.open.options[t.open.selected])},kt=e=>e.state.field(P,!1)?(e.dispatch({effects:et.of(!0)}),!0):!1,At=e=>{let t=e.state.field(P,!1);return!t||!t.active.some(e=>e.state!=0)?!1:(e.dispatch({effects:tt.of(null)}),!0)},jt=class{constructor(e,t){this.active=e,this.context=t,this.time=Date.now(),this.updates=[],this.done=void 0}},Mt=50,Nt=1e3,Pt=ae.fromClass(class{constructor(e){this.view=e,this.debounceUpdate=-1,this.running=[],this.debounceAccept=-1,this.pendingStart=!1,this.composing=0;for(let t of e.state.field(P).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(P),n=e.state.facet(M);if(!e.selectionSet&&!e.docChanged&&e.startState.field(P)==t)return;let r=e.transactions.some(e=>{let t=xt(e,n);return t&8||(e.selection||e.docChanged)&&!(t&3)});for(let t=0;t<this.running.length;t++){let n=this.running[t];if(r||n.context.abortOnDocChange&&e.docChanged||n.updates.length+e.transactions.length>Mt&&Date.now()-n.time>Nt){for(let e of n.context.abortListeners)try{e()}catch(e){ne(this.view.state,e)}n.context.abortListeners=null,this.running.splice(t--,1)}else n.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(e=>e.effects.some(e=>e.is(et)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(e=>e.isPending&&!this.running.some(t=>t.active.source==e.source))?setTimeout(()=>this.startUpdate(),i):-1,this.composing!=0)for(let t of e.transactions)t.isUserEvent(`input.type`)?this.composing=2:this.composing==2&&t.selection&&(this.composing=3)}startUpdate(){this.debounceUpdate=-1,this.pendingStart=!1;let{state:e}=this.view,t=e.field(P);for(let e of t.active)e.isPending&&!this.running.some(t=>t.active.source==e.source)&&this.startQuery(e);this.running.length&&t.open&&t.open.disabled&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(M).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=new Ue(t,j(t),e.explicit,this.view),r=new jt(e,n);this.running.push(r),Promise.resolve(e.source(n)).then(e=>{r.context.aborted||(r.done=e||null,this.scheduleAccept())},e=>{this.view.dispatch({effects:tt.of(null)}),ne(this.view.state,e)})}scheduleAccept(){this.running.every(e=>e.done!==void 0)?this.accept():this.debounceAccept<0&&(this.debounceAccept=setTimeout(()=>this.accept(),this.view.state.facet(M).updateSyncTime))}accept(){this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let e=[],t=this.view.state.facet(M),n=this.view.state.field(P);for(let r=0;r<this.running.length;r++){let i=this.running[r];if(i.done===void 0)continue;if(this.running.splice(r--,1),i.done){let n=j(i.updates.length?i.updates[0].startState:this.view.state),r=Math.min(n,i.done.from+ +!i.active.explicit),a=new St(i.active.source,i.active.explicit,r,i.done,i.done.from,i.done.to??n);for(let e of i.updates)a=a.update(e,t);if(a.hasResult()){e.push(a);continue}}let a=n.active.find(e=>e.source==i.active.source);if(a&&a.isPending){if(i.done==null){let n=new N(i.active.source,0);for(let e of i.updates)n=n.update(e,t);n.isPending||e.push(n)}else this.startQuery(a)}}(e.length||n.open&&n.open.disabled)&&this.view.dispatch({effects:wt.of(e)})}},{eventHandlers:{blur(e){let t=this.view.state.field(P,!1);if(t&&t.tooltip&&this.view.state.facet(M).closeOnBlur){let n=t.open&&f(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:tt.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:et.of(!1)}),20),this.composing=0}}}),Ft=typeof navigator==`object`&&/Win/.test(navigator.platform),It=ve.highest(y.domEventHandlers({keydown(e,t){let n=t.state.field(P,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Ft&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(e=>e.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&Tt(t,r),!1}})),Lt=y.baseTheme({".cm-tooltip.cm-tooltip-autocomplete":{"& > ul":{fontFamily:`monospace`,whiteSpace:`nowrap`,overflow:`hidden auto`,maxWidth_fallback:`700px`,maxWidth:`min(700px, 95vw)`,minWidth:`250px`,maxHeight:`10em`,height:`100%`,listStyle:`none`,margin:0,padding:0,"& > li, & > completion-section":{padding:`1px 3px`,lineHeight:1.2},"& > li":{overflowX:`hidden`,textOverflow:`ellipsis`,cursor:`pointer`},"& > completion-section":{display:`list-item`,borderBottom:`1px solid silver`,paddingLeft:`0.5em`,opacity:.7}}},"&light .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#17c`,color:`white`},"&light .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#777`},"&dark .cm-tooltip-autocomplete ul li[aria-selected]":{background:`#347`,color:`white`},"&dark .cm-tooltip-autocomplete-disabled ul li[aria-selected]":{background:`#444`},".cm-completionListIncompleteTop:before, .cm-completionListIncompleteBottom:after":{content:`"···"`,opacity:.5,display:`block`,textAlign:`center`,cursor:`pointer`},".cm-tooltip.cm-completionInfo":{position:`absolute`,padding:`3px 9px`,width:`max-content`,maxWidth:`400px`,boxSizing:`border-box`,whiteSpace:`pre-line`},".cm-completionInfo.cm-completionInfo-left":{right:`100%`},".cm-completionInfo.cm-completionInfo-right":{left:`100%`},".cm-completionInfo.cm-completionInfo-left-narrow":{right:`30px`},".cm-completionInfo.cm-completionInfo-right-narrow":{left:`30px`},"&light .cm-snippetField":{backgroundColor:`#00000022`},"&dark .cm-snippetField":{backgroundColor:`#ffffff22`},".cm-snippetFieldPosition":{verticalAlign:`text-top`,width:0,height:`1.15em`,display:`inline-block`,margin:`0 -0.7px -.7em`,borderLeft:`1.4px dotted #888`},".cm-completionMatchedText":{textDecoration:`underline`},".cm-completionDetail":{marginLeft:`0.5em`,fontStyle:`italic`},".cm-completionIcon":{fontSize:`90%`,width:`.8em`,display:`inline-block`,textAlign:`center`,paddingRight:`.6em`,opacity:`0.6`,boxSizing:`content-box`},".cm-completionIcon-function, .cm-completionIcon-method":{"&:after":{content:`'ƒ'`}},".cm-completionIcon-class":{"&:after":{content:`'○'`}},".cm-completionIcon-interface":{"&:after":{content:`'◌'`}},".cm-completionIcon-variable":{"&:after":{content:`'𝑥'`}},".cm-completionIcon-constant":{"&:after":{content:`'𝐶'`}},".cm-completionIcon-type":{"&:after":{content:`'𝑡'`}},".cm-completionIcon-enum":{"&:after":{content:`'∪'`}},".cm-completionIcon-property":{"&:after":{content:`'□'`}},".cm-completionIcon-keyword":{"&:after":{content:`'🔑︎'`}},".cm-completionIcon-namespace":{"&:after":{content:`'▢'`}},".cm-completionIcon-text":{"&:after":{content:`'abc'`,fontSize:`50%`,verticalAlign:`middle`}}}),Rt=class{constructor(e,t,n,r){this.field=e,this.line=t,this.from=n,this.to=r}},zt=class e{constructor(e,t,n){this.field=e,this.from=t,this.to=n}map(t){let n=t.mapPos(this.from,-1,je.TrackDel),r=t.mapPos(this.to,1,je.TrackDel);return n==null||r==null?null:new e(this.field,n,r)}},Bt=class e{constructor(e,t){this.lines=e,this.fieldPositions=t}instantiate(e,t){let n=[],r=[t],i=e.doc.lineAt(t),a=/^\s*/.exec(i.text)[0];for(let i of this.lines){if(n.length){let n=a,o=/^\t*/.exec(i)[0].length;for(let t=0;t<o;t++)n+=e.facet(se);r.push(t+n.length-o),i=n+i.slice(o)}n.push(i),t+=i.length+1}return{text:n,ranges:this.fieldPositions.map(e=>new zt(e.field,r[e.line]+e.from,r[e.line]+e.to))}}static parse(t){let n=[],r=[],i=[],a;for(let e of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^{}]*))?|((?:\\[{}]|[^{}])*))\}/.exec(e);){let t=a[1]?+a[1]:null,o=a[2]||a[3]||``,s=-1;t===0&&(t=1e9);let c=o.replace(/\\[{}]/g,e=>e[1]);for(let e=0;e<n.length;e++)(t==null?c&&n[e].name==c:n[e].seq==t)&&(s=e);if(s<0){let e=0;for(;e<n.length&&(t==null||n[e].seq!=null&&n[e].seq<t);)e++;n.splice(e,0,{seq:t,name:c}),s=e;for(let e of i)e.field>=s&&e.field++}for(let e of i)if(e.line==r.length&&e.from>a.index){let t=a[2]?3+(a[1]||``).length:2;e.from-=t,e.to-=t}i.push(new Rt(s,r.length,a.index,a.index+c.length)),e=e.slice(0,a.index)+o+e.slice(a.index+a[0].length)}e=e.replace(/\\([{}])/g,(e,t,n)=>{for(let e of i)e.line==r.length&&e.from>n&&(e.from--,e.to--);return t}),r.push(e)}return new e(r,i)}},Vt=E.widget({widget:new class extends g{toDOM(){let e=document.createElement(`span`);return e.className=`cm-snippetFieldPosition`,e}ignoreEvent(){return!1}}}),Ht=E.mark({class:`cm-snippetField`}),Ut=class e{constructor(e,t){this.ranges=e,this.active=t,this.deco=E.set(e.map(e=>(e.from==e.to?Vt:Ht).range(e.from,e.to)),!0)}map(t){let n=[];for(let e of this.ranges){let r=e.map(t);if(!r)return null;n.push(r)}return new e(n,this.active)}selectionInsideField(e){return e.ranges.every(e=>this.ranges.some(t=>t.field==this.active&&t.from<=e.from&&t.to>=e.to))}},Wt=C.define({map(e,t){return e&&e.map(t)}}),Gt=C.define(),Kt=Oe.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Wt))return n.value;if(n.is(Gt)&&e)return new Ut(e.ranges,n.value)}return e&&t.docChanged&&(e=e.map(t.changes)),e&&t.selection&&!e.selectionInsideField(t.selection)&&(e=null),e},provide:e=>y.decorations.from(e,e=>e?e.deco:E.none)});function qt(e,t){return T.create(e.filter(e=>e.field==t).map(e=>T.range(e.from,e.to)))}function Jt(e){let t=Bt.parse(e);return(e,n,r,i)=>{let{text:a,ranges:o}=t.instantiate(e.state,r),{main:s}=e.state.selection,c={changes:{from:r,to:i==s.from?s.to:i,insert:Ee.of(a)},scrollIntoView:!0,annotations:n?[Xe.of(n),Se.userEvent.of(`input.complete`)]:void 0};if(o.length&&(c.selection=qt(o,0)),o.some(e=>e.field>0)){let t=new Ut(o,0),n=c.effects=[Wt.of(t)];e.state.field(Kt,!1)===void 0&&n.push(C.appendConfig.of([Kt,Qt,en,Lt]))}e.dispatch(e.state.update(c))}}function Yt(e){return({state:t,dispatch:n})=>{let r=t.field(Kt,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(t=>t.field==i+e);return n(t.update({selection:qt(r.ranges,i),effects:Wt.of(a?null:new Ut(r.ranges,i)),scrollIntoView:!0})),!0}}var Xt=[{key:`Tab`,run:Yt(1),shift:Yt(-1)},{key:`Escape`,run:({state:e,dispatch:t})=>e.field(Kt,!1)?(t(e.update({effects:Wt.of(null)})),!0):!1}],Zt=O.define({combine(e){return e.length?e[0]:Xt}}),Qt=ve.highest(ue.compute([Zt],e=>e.facet(Zt)));function $t(e,t){return{...t,apply:Jt(e)}}var en=y.domEventHandlers({mousedown(e,t){let n=t.state.field(Kt,!1),r;if(!n||(r=t.posAtCoords({x:e.clientX,y:e.clientY}))==null)return!1;let i=n.ranges.find(e=>e.from<=r&&e.to>=r);return!i||i.field==n.active?!1:(t.dispatch({selection:qt(n.ranges,i.field),effects:Wt.of(n.ranges.some(e=>e.field>i.field)?new Ut(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),F={brackets:[`(`,`[`,`{`,`'`,`"`],before:`)]}:;>`,stringPrefixes:[]},I=C.define({map(e,t){return t.mapPos(e,-1,je.TrackAfter)??void 0}}),tn=new class extends ye{};tn.startSide=1,tn.endSide=-1;var nn=Oe.define({create(){return Te.empty},update(e,t){if(e=e.map(t.changes),t.selection){let n=t.state.doc.lineAt(t.selection.main.head);e=e.update({filter:e=>e>=n.from&&e<=n.to})}for(let n of t.effects)n.is(I)&&(e=e.update({add:[tn.range(n.value,n.value+1)]}));return e}});function rn(){return[ln,nn]}var an=`()[]{}<>«»»«[]{}`;function on(e){for(let t=0;t<16;t+=2)if(an.charCodeAt(t)==e)return an.charAt(t+1);return Re(e<128?e:e+1)}function sn(e,t){return e.languageDataAt(`closeBrackets`,t)[0]||F}var cn=typeof navigator==`object`&&/Android\b/.test(navigator.userAgent),ln=y.inputHandler.of((e,t,n,r)=>{if((cn?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&x(w(r,0))==1||t!=i.from||n!=i.to)return!1;let a=dn(e.state,r);return a?(e.dispatch(a),!0):!1}),un=[{key:`Backspace`,run:({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=sn(e,e.selection.main.head).brackets||F.brackets,r=null,i=e.changeByRange(t=>{if(t.empty){let r=mn(e.doc,t.head);for(let i of n)if(i==r&&pn(e.doc,t.head)==on(w(i,0)))return{changes:{from:t.head-i.length,to:t.head+i.length},range:T.cursor(t.head-i.length)}}return{range:r=t}});return r||t(e.update(i,{scrollIntoView:!0,userEvent:`delete.backward`})),!r}}];function dn(e,t){let n=sn(e,e.selection.main.head),r=n.brackets||F.brackets;for(let i of r){let a=on(w(i,0));if(t==i)return a==i?_n(e,i,r.indexOf(i+i+i)>-1,n):hn(e,i,a,n.before||F.before);if(t==a&&fn(e,e.selection.main.from))return gn(e,i,a)}return null}function fn(e,t){let n=!1;return e.field(nn).between(0,e.doc.length,e=>{e==t&&(n=!0)}),n}function pn(e,t){let n=e.sliceString(t,t+2);return n.slice(0,x(w(n,0)))}function mn(e,t){let n=e.sliceString(t-2,t);return x(w(n,0))==n.length?n:n.slice(1)}function hn(e,t,n,r){let i=null,a=e.changeByRange(a=>{if(!a.empty)return{changes:[{insert:t,from:a.from},{insert:n,from:a.to}],effects:I.of(a.to+t.length),range:T.range(a.anchor+t.length,a.head+t.length)};let o=pn(e.doc,a.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:a.head},effects:I.of(a.head+t.length),range:T.cursor(a.head+t.length)}:{range:i=a}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:`input.type`})}function gn(e,t,n){let r=null,i=e.changeByRange(t=>t.empty&&pn(e.doc,t.head)==n?{changes:{from:t.head,to:t.head+n.length,insert:n},range:T.cursor(t.head+n.length)}:r={range:t});return r?null:e.update(i,{scrollIntoView:!0,userEvent:`input.type`})}function _n(e,t,n,r){let i=r.stringPrefixes||F.stringPrefixes,a=null,o=e.changeByRange(r=>{if(!r.empty)return{changes:[{insert:t,from:r.from},{insert:t,from:r.to}],effects:I.of(r.to+t.length),range:T.range(r.anchor+t.length,r.head+t.length)};let o=r.head,s=pn(e.doc,o),c;if(s==t){if(vn(e,o))return{changes:{insert:t+t,from:o},effects:I.of(o+t.length),range:T.cursor(o+t.length)};if(fn(e,o)){let r=n&&e.sliceDoc(o,o+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:o,to:o+r.length,insert:r},range:T.cursor(o+r.length)}}}else if(n&&e.sliceDoc(o-2*t.length,o)==t+t&&(c=bn(e,o-2*t.length,i))>-1&&vn(e,c))return{changes:{insert:t+t+t+t,from:o},effects:I.of(o+t.length),range:T.cursor(o+t.length)};else if(e.charCategorizer(o)(s)!=D.Word&&bn(e,o,i)>-1&&!yn(e,o,t,i))return{changes:{insert:t+t,from:o},effects:I.of(o+t.length),range:T.cursor(o+t.length)};return{range:a=r}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:`input.type`})}function vn(e,t){let n=d(e).resolveInner(t+1);return n.parent&&n.from==t}function yn(e,t,n,r){let i=d(e).resolveInner(t,-1),a=r.reduce((e,t)=>Math.max(e,t.length),0);for(let o=0;o<5;o++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),s=o.indexOf(n);if(!s||s>-1&&r.indexOf(o.slice(0,s))>-1){let t=i.firstChild;for(;t&&t.from==i.from&&t.to-t.from>n.length+s;){if(e.sliceDoc(t.to-n.length,t.to)==n)return!1;t=t.firstChild}return!0}let c=i.to==t&&i.parent;if(!c)break;i=c}return!1}function bn(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=D.Word)return t;for(let i of n){let n=t-i.length;if(e.sliceDoc(n,t)==i&&r(e.sliceDoc(n-1,n))!=D.Word)return n}return-1}function xn(e={}){return[It,P,M.of(e),Pt,Cn,Lt]}var Sn=[{key:`Ctrl-Space`,run:kt},{mac:"Alt-`",run:kt},{mac:`Alt-i`,run:kt},{key:`Escape`,run:At},{key:`ArrowDown`,run:Dt(!0)},{key:`ArrowUp`,run:Dt(!1)},{key:`PageDown`,run:Dt(!0,`page`)},{key:`PageUp`,run:Dt(!1,`page`)},{key:`Enter`,run:Ot}],Cn=ve.highest(ue.computeN([M],e=>e.facet(M).defaultKeymap?[Sn]:[])),wn=e=>{let{state:t}=e,n=t.doc.lineAt(t.selection.main.from),r=kn(e.state,n.from);return r.line?En(e):r.block?On(e):!1};function Tn(e,t){return({state:n,dispatch:r})=>{if(n.readOnly)return!1;let i=e(t,n);return i?(r(n.update(i)),!0):!1}}var En=Tn(Pn,0),Dn=Tn(Nn,0),On=Tn((e,t)=>Nn(e,t,Mn(t)),0);function kn(e,t){let n=e.languageDataAt(`commentTokens`,t,1);return n.length?n[0]:{}}var An=50;function jn(e,{open:t,close:n},r,i){let a=e.sliceDoc(r-An,r),o=e.sliceDoc(i,i+An),s=/\s*$/.exec(a)[0].length,c=/^\s*/.exec(o)[0].length,l=a.length-s;if(a.slice(l-t.length,l)==t&&o.slice(c,c+n.length)==n)return{open:{pos:r-s,margin:s&&1},close:{pos:i+c,margin:c&&1}};let u,d;i-r<=100?u=d=e.sliceDoc(r,i):(u=e.sliceDoc(r,r+An),d=e.sliceDoc(i-An,i));let f=/^\s*/.exec(u)[0].length,p=/\s*$/.exec(d)[0].length,m=d.length-p-n.length;return u.slice(f,f+t.length)==t&&d.slice(m,m+n.length)==n?{open:{pos:r+f+t.length,margin:+!!/\s/.test(u.charAt(f+t.length))},close:{pos:i-p-n.length,margin:+!!/\s/.test(d.charAt(m-1))}}:null}function Mn(e){let t=[];for(let n of e.selection.ranges){let r=e.doc.lineAt(n.from),i=n.to<=r.to?r:e.doc.lineAt(n.to);i.from>r.from&&i.from==n.to&&(i=n.to==r.to+1?r:e.doc.lineAt(n.to-1));let a=t.length-1;a>=0&&t[a].to>r.from?t[a].to=i.to:t.push({from:r.from+/^\s*/.exec(r.text)[0].length,to:i.to})}return t}function Nn(e,t,n=t.selection.ranges){let r=n.map(e=>kn(t,e.from).block);if(!r.every(e=>e))return null;let i=n.map((e,n)=>jn(t,r[n],e.from,e.to));if(e!=2&&!i.every(e=>e))return{changes:t.changes(n.map((e,t)=>i[t]?[]:[{from:e.from,insert:r[t].open+` `},{from:e.to,insert:` `+r[t].close}]))};if(e!=1&&i.some(e=>e)){let e=[];for(let t=0,n;t<i.length;t++)if(n=i[t]){let i=r[t],{open:a,close:o}=n;e.push({from:a.pos-i.open.length,to:a.pos+a.margin},{from:o.pos-o.margin,to:o.pos+i.close.length})}return{changes:e}}return null}function Pn(e,t,n=t.selection.ranges){let r=[],i=-1;ranges:for(let{from:e,to:a}of n){let n=r.length,o=1e9,s;for(let n=e;n<=a;){let c=t.doc.lineAt(n);if(s==null&&(s=kn(t,c.from).line,!s))continue ranges;if(c.from>i&&(e==a||a>c.from)){i=c.from;let e=/^\s*/.exec(c.text)[0].length,t=e==c.length,n=c.text.slice(e,e+s.length)==s?e:-1;e<c.text.length&&e<o&&(o=e),r.push({line:c,comment:n,token:s,indent:e,empty:t,single:!1})}n=c.to+1}if(o<1e9)for(let e=n;e<r.length;e++)r[e].indent<r[e].line.text.length&&(r[e].indent=o);r.length==n+1&&(r[n].single=!0)}if(e!=2&&r.some(e=>e.comment<0&&(!e.empty||e.single))){let e=[];for(let{line:t,token:n,indent:i,empty:a,single:o}of r)(o||!a)&&e.push({from:t.from+i,insert:n+` `});let n=t.changes(e);return{changes:n,selection:t.selection.map(n,1)}}if(e!=1&&r.some(e=>e.comment>=0)){let e=[];for(let{line:t,comment:n,token:i}of r)if(n>=0){let r=t.from+n,a=r+i.length;t.text[a-t.from]==` `&&a++,e.push({from:r,to:a})}return{changes:e}}return null}var Fn=u.define(),In=u.define(),Ln=O.define(),Rn=O.define({combine(e){return Fe(e,{minDepth:100,newGroupDelay:500,joinToEvent:(e,t)=>t},{minDepth:Math.max,newGroupDelay:Math.min,joinToEvent:(e,t)=>(n,r)=>e(n,r)||t(n,r)})}}),zn=Oe.define({create(){return nr.empty},update(e,t){let n=t.state.facet(Rn),r=t.annotation(Fn);if(r){let i=L.fromTransaction(t,r.selection),a=r.side,o=a==0?e.undone:e.done;return o=i?Kn(o,o.length,n.minDepth,i):Zn(o,t.startState.selection),new nr(a==0?r.rest:o,a==0?o:r.rest)}let i=t.annotation(In);if((i==`full`||i==`before`)&&(e=e.isolate()),t.annotation(Se.addToHistory)===!1)return t.changes.empty?e:e.addMapping(t.changes.desc);let a=L.fromTransaction(t),o=t.annotation(Se.time),s=t.annotation(Se.userEvent);return a?e=e.addChanges(a,o,s,n,t):t.selection&&(e=e.addSelection(t.startState.selection,o,s,n.newGroupDelay)),(i==`full`||i==`after`)&&(e=e.isolate()),e},toJSON(e){return{done:e.done.map(e=>e.toJSON()),undone:e.undone.map(e=>e.toJSON())}},fromJSON(e){return new nr(e.done.map(L.fromJSON),e.undone.map(L.fromJSON))}});function Bn(e={}){return[zn,Rn.of(e),y.domEventHandlers({beforeinput(e,t){let n=e.inputType==`historyUndo`?Hn:e.inputType==`historyRedo`?Un:null;return n?(e.preventDefault(),n(t)):!1}})]}function Vn(e,t){return function({state:n,dispatch:r}){if(!t&&n.readOnly)return!1;let i=n.field(zn,!1);if(!i)return!1;let a=i.pop(e,n,t);return a?(r(a),!0):!1}}var Hn=Vn(0,!1),Un=Vn(1,!1),Wn=Vn(0,!0),Gn=Vn(1,!0),L=class e{constructor(e,t,n,r,i){this.changes=e,this.effects=t,this.mapped=n,this.startSelection=r,this.selectionsAfter=i}setSelAfter(t){return new e(this.changes,this.effects,this.mapped,this.startSelection,t)}toJSON(){return{changes:this.changes?.toJSON(),mapped:this.mapped?.toJSON(),startSelection:this.startSelection?.toJSON(),selectionsAfter:this.selectionsAfter.map(e=>e.toJSON())}}static fromJSON(t){return new e(t.changes&&Ne.fromJSON(t.changes),[],t.mapped&&be.fromJSON(t.mapped),t.startSelection&&T.fromJSON(t.startSelection),t.selectionsAfter.map(T.fromJSON))}static fromTransaction(t,n){let r=R;for(let e of t.startState.facet(Ln)){let n=e(t);n.length&&(r=r.concat(n))}return!r.length&&t.changes.empty?null:new e(t.changes.invert(t.startState.doc),r,void 0,n||t.startState.selection,R)}static selection(t){return new e(void 0,R,void 0,void 0,t)}};function Kn(e,t,n,r){let i=t+1>n+20?t-n-1:0,a=e.slice(i,t);return a.push(r),a}function qn(e,t){let n=[],r=!1;return e.iterChangedRanges((e,t)=>n.push(e,t)),t.iterChangedRanges((e,t,i,a)=>{for(let e=0;e<n.length;){let t=n[e++],o=n[e++];a>=t&&i<=o&&(r=!0)}}),r}function Jn(e,t){return e.ranges.length==t.ranges.length&&e.ranges.filter((e,n)=>e.empty!=t.ranges[n].empty).length===0}function Yn(e,t){return e.length?t.length?e.concat(t):e:t}var R=[],Xn=200;function Zn(e,t){if(e.length){let n=e[e.length-1],r=n.selectionsAfter.slice(Math.max(0,n.selectionsAfter.length-Xn));return r.length&&r[r.length-1].eq(t)?e:(r.push(t),Kn(e,e.length-1,1e9,n.setSelAfter(r)))}return[L.selection([t])]}function Qn(e){let t=e[e.length-1],n=e.slice();return n[e.length-1]=t.setSelAfter(t.selectionsAfter.slice(0,t.selectionsAfter.length-1)),n}function $n(e,t){if(!e.length)return e;let n=e.length,r=R;for(;n;){let i=er(e[n-1],t,r);if(i.changes&&!i.changes.empty||i.effects.length){let t=e.slice(0,n);return t[n-1]=i,t}t=i.mapped,n--,r=i.selectionsAfter}return r.length?[L.selection(r)]:R}function er(e,t,n){let r=Yn(e.selectionsAfter.length?e.selectionsAfter.map(e=>e.map(t)):R,n);if(!e.changes)return L.selection(r);let i=e.changes.map(t),a=t.mapDesc(e.changes,!0),o=e.mapped?e.mapped.composeDesc(a):a;return new L(i,C.mapEffects(e.effects,t),o,e.startSelection.map(a),r)}var tr=/^(input\.type|delete)($|\.)/,nr=class e{constructor(e,t,n=0,r=void 0){this.done=e,this.undone=t,this.prevTime=n,this.prevUserEvent=r}isolate(){return this.prevTime?new e(this.done,this.undone):this}addChanges(t,n,r,i,a){let o=this.done,s=o[o.length-1];return o=s&&s.changes&&!s.changes.empty&&t.changes&&(!r||tr.test(r))&&(!s.selectionsAfter.length&&n-this.prevTime<i.newGroupDelay&&i.joinToEvent(a,qn(s.changes,t.changes))||r==`input.type.compose`)?Kn(o,o.length-1,i.minDepth,new L(t.changes.compose(s.changes),Yn(C.mapEffects(t.effects,s.changes),s.effects),s.mapped,s.startSelection,R)):Kn(o,o.length,i.minDepth,t),new e(o,R,n,r)}addSelection(t,n,r,i){let a=this.done.length?this.done[this.done.length-1].selectionsAfter:R;return a.length>0&&n-this.prevTime<i&&r==this.prevUserEvent&&r&&/^select($|\.)/.test(r)&&Jn(a[a.length-1],t)?this:new e(Zn(this.done,t),this.undone,n,r)}addMapping(t){return new e($n(this.done,t),$n(this.undone,t),this.prevTime,this.prevUserEvent)}pop(e,t,n){let r=e==0?this.done:this.undone;if(r.length==0)return null;let i=r[r.length-1],a=i.selectionsAfter[0]||(i.startSelection?i.startSelection.map(i.changes.invertedDesc,1):t.selection);if(n&&i.selectionsAfter.length)return t.update({selection:i.selectionsAfter[i.selectionsAfter.length-1],annotations:Fn.of({side:e,rest:Qn(r),selection:a}),userEvent:e==0?`select.undo`:`select.redo`,scrollIntoView:!0});if(i.changes){let n=r.length==1?R:r.slice(0,r.length-1);return i.mapped&&(n=$n(n,i.mapped)),t.update({changes:i.changes,selection:i.startSelection,effects:i.effects,annotations:Fn.of({side:e,rest:n,selection:a}),filter:!1,userEvent:e==0?`undo`:`redo`,scrollIntoView:!0})}return null}};nr.empty=new nr(R,R);var rr=[{key:`Mod-z`,run:Hn,preventDefault:!0},{key:`Mod-y`,mac:`Mod-Shift-z`,run:Un,preventDefault:!0},{linux:`Ctrl-Shift-z`,run:Un,preventDefault:!0},{key:`Mod-u`,run:Wn,preventDefault:!0},{key:`Alt-u`,mac:`Mod-Shift-u`,run:Gn,preventDefault:!0}];function z(e,t){return T.create(e.ranges.map(t),e.mainIndex)}function B(e,t){return e.update({selection:t,scrollIntoView:!0,userEvent:`select`})}function V({state:e,dispatch:t},n){let r=z(e.selection,n);return!r.eq(e.selection,!0)&&(t(B(e,r)),!0)}function ir(e,t){return T.cursor(t?e.to:e.from)}function ar(e,t){return V(e,n=>n.empty?e.moveByChar(n,t):ir(n,t))}function H(e){return e.textDirectionAt(e.state.selection.main.head)==ie.LTR}var or=e=>ar(e,!H(e)),sr=e=>ar(e,H(e));function cr(e,t){return V(e,n=>n.empty?e.moveByGroup(n,t):ir(n,t))}var lr=e=>cr(e,!H(e)),ur=e=>cr(e,H(e));typeof Intl<`u`&&Intl.Segmenter;function dr(e,t,n){if(t.type.prop(n))return!0;let r=t.to-t.from;return r&&(r>2||/[^\s,.;:]/.test(e.sliceDoc(t.from,t.to)))||t.firstChild}function fr(e,t,n){let r=d(e).resolveInner(t.head),i=n?h.closedBy:h.openedBy;for(let a=t.head;;){let t=n?r.childAfter(a):r.childBefore(a);if(!t)break;dr(e,t,i)?r=t:a=n?t.to:t.from}let a=r.type.prop(i),o,s;return s=a&&(o=n?m(e,r.from,1):m(e,r.to,-1))&&o.matched?n?o.end.to:o.end.from:n?r.to:r.from,T.cursor(s,n?-1:1)}var pr=e=>V(e,t=>fr(e.state,t,!H(e))),mr=e=>V(e,t=>fr(e.state,t,H(e)));function hr(e,t){return V(e,n=>{if(!n.empty)return ir(n,t);let r=e.moveVertically(n,t);return r.head==n.head?e.moveToLineBoundary(n,t):r})}var gr=e=>hr(e,!1),_r=e=>hr(e,!0);function vr(e){let t=e.scrollDOM.clientHeight<e.scrollDOM.scrollHeight-2,n=0,r=0,i;if(t){for(let t of e.state.facet(y.scrollMargins)){let i=t(e);i?.top&&(n=Math.max(i?.top,n)),i?.bottom&&(r=Math.max(i?.bottom,r))}i=e.scrollDOM.clientHeight-n-r}else i=(e.dom.ownerDocument.defaultView||window).innerHeight;return{marginTop:n,marginBottom:r,selfScroll:t,height:Math.max(e.defaultLineHeight,i-5)}}function yr(e,t){let n=vr(e),{state:r}=e,i=z(r.selection,r=>r.empty?e.moveVertically(r,t,n.height):ir(r,t));if(i.eq(r.selection))return!1;let a;if(n.selfScroll){let t=e.coordsAtPos(r.selection.main.head),o=e.scrollDOM.getBoundingClientRect(),s=o.top+n.marginTop,c=o.bottom-n.marginBottom;t&&t.top>s&&t.bottom<c&&(a=y.scrollIntoView(i.main.head,{y:`start`,yMargin:t.top-s}))}return e.dispatch(B(r,i),{effects:a}),!0}var br=e=>yr(e,!1),xr=e=>yr(e,!0);function U(e,t,n){let r=e.lineBlockAt(t.head),i=e.moveToLineBoundary(t,n);if(i.head==t.head&&i.head!=(n?r.to:r.from)&&(i=e.moveToLineBoundary(t,n,!1)),!n&&i.head==r.from&&r.length){let n=/^\s*/.exec(e.state.sliceDoc(r.from,Math.min(r.from+100,r.to)))[0].length;n&&t.head!=r.from+n&&(i=T.cursor(r.from+n))}return i}var Sr=e=>V(e,t=>U(e,t,!0)),Cr=e=>V(e,t=>U(e,t,!1)),wr=e=>V(e,t=>U(e,t,!H(e))),Tr=e=>V(e,t=>U(e,t,H(e))),Er=e=>V(e,t=>e.moveToLineBoundary(t,!1,!1)),Dr=e=>V(e,t=>e.moveToLineBoundary(t,!0,!1));function Or(e,t,n){let r=!1,i=z(e.selection,t=>{let i=m(e,t.head,-1)||m(e,t.head,1)||t.head>0&&m(e,t.head-1,1)||t.head<e.doc.length&&m(e,t.head+1,-1);if(!i||!i.end)return t;r=!0;let a=i.start.from==t.head?i.end.to:i.end.from;return n?T.range(t.anchor,a):T.cursor(a)});return r?(t(B(e,i)),!0):!1}var kr=({state:e,dispatch:t})=>Or(e,t,!1);function W(e,t,n){let r=z(e.state.selection,e=>{e.undirectional&&e.head>=e.anchor!=t&&(e=T.range(e.head,e.anchor));let r=n(e);return T.range(e.anchor,r.head,r.goalColumn,r.bidiLevel||void 0,r.assoc)});return!r.eq(e.state.selection)&&(e.dispatch(B(e.state,r)),!0)}function Ar(e,t){return W(e,t,n=>e.moveByChar(n,t))}var jr=e=>Ar(e,!H(e)),Mr=e=>Ar(e,H(e));function Nr(e,t){return W(e,t,n=>e.moveByGroup(n,t))}var Pr=e=>Nr(e,!H(e)),Fr=e=>Nr(e,H(e)),Ir=e=>{let t=!H(e);return W(e,t,n=>fr(e.state,n,t))},Lr=e=>{let t=H(e);return W(e,t,n=>fr(e.state,n,t))};function Rr(e,t){return W(e,t,n=>e.moveVertically(n,t))}var zr=e=>Rr(e,!1),Br=e=>Rr(e,!0);function Vr(e,t){return W(e,t,n=>e.moveVertically(n,t,vr(e).height))}var Hr=e=>Vr(e,!1),Ur=e=>Vr(e,!0),Wr=e=>W(e,!0,t=>U(e,t,!0)),Gr=e=>W(e,!1,t=>U(e,t,!1)),Kr=e=>{let t=!H(e);return W(e,t,n=>U(e,n,t))},qr=e=>{let t=H(e);return W(e,t,n=>U(e,n,t))},Jr=e=>W(e,!1,t=>T.cursor(e.lineBlockAt(t.head).from)),Yr=e=>W(e,!0,t=>T.cursor(e.lineBlockAt(t.head).to)),Xr=({state:e,dispatch:t})=>(t(B(e,{anchor:0})),!0),Zr=({state:e,dispatch:t})=>(t(B(e,{anchor:e.doc.length})),!0),Qr=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:0})),!0),$r=({state:e,dispatch:t})=>(t(B(e,{anchor:e.selection.main.anchor,head:e.doc.length})),!0),ei=({state:e,dispatch:t})=>(t(e.update({selection:{anchor:0,head:e.doc.length},userEvent:`select`})),!0),ti=({state:e,dispatch:t})=>{let n=bi(e).map(({from:t,to:n})=>T.undirectionalRange(t,Math.min(n+1,e.doc.length)));return t(e.update({selection:T.create(n),userEvent:`select`})),!0},ni=({state:e,dispatch:t})=>{let n=z(e.selection,t=>{let n=d(e),r=n.resolveStack(t.from,1);if(t.empty){let e=n.resolveStack(t.from,-1);e.node.from>=r.node.from&&e.node.to<=r.node.to&&(r=e)}for(let e=r;e;e=e.next){let{node:n}=e;if((n.from<t.from&&n.to>=t.to||n.to>t.to&&n.from<=t.from)&&e.next)return T.undirectionalRange(n.from,n.to)}return t});return!n.eq(e.selection)&&(t(B(e,n)),!0)};function ri(e,t){let{state:n}=e,r=n.selection,i=n.selection.ranges.slice();for(let r of n.selection.ranges){let a=n.doc.lineAt(r.head);if(t?a.to<e.state.doc.length:a.from>0)for(let n=r;;){let r=e.moveVertically(n,t);if(r.head<a.from||r.head>a.to){i.some(e=>e.head==r.head)||i.push(r);break}if(r.head==n.head)break;n=r}}return i.length!=r.ranges.length&&(e.dispatch(B(n,T.create(i,i.length-1))),!0)}var ii=e=>ri(e,!1),ai=e=>ri(e,!0),oi=({state:e,dispatch:t})=>{let n=e.selection,r=null;return n.ranges.length>1?r=T.create([n.main]):n.main.empty||(r=T.create([T.cursor(n.main.head)])),r?(t(B(e,r)),!0):!1};function si(e,t){if(e.state.readOnly)return!1;let n=`delete.selection`,{state:r}=e,i=r.changeByRange(r=>{let{from:i,to:a}=r;if(i==a){let o=t(r);o<i?(n=`delete.backward`,o=ci(e,o,!1)):o>i&&(n=`delete.forward`,o=ci(e,o,!0)),i=Math.min(i,o),a=Math.max(a,o)}else i=ci(e,i,!1),a=ci(e,a,!0);return i==a?{range:r}:{changes:{from:i,to:a},range:T.cursor(i,i<r.head?-1:1)}});return!i.changes.empty&&(e.dispatch(r.update(i,{scrollIntoView:!0,userEvent:n,effects:n==`delete.selection`?y.announce.of(r.phrase(`Selection deleted`)):void 0})),!0)}function ci(e,t,n){if(e instanceof y)for(let r of e.state.facet(y.atomicRanges).map(t=>t(e)))r.between(t,t,(e,r)=>{e<t&&r>t&&(t=n?r:e)});return t}var li=(e,t,n)=>si(e,r=>{let i=r.from,{state:a}=e,o=a.doc.lineAt(i),s,c;if(n&&!t&&i>o.from&&i<o.from+200&&!/[^ \t]/.test(s=o.text.slice(0,i-o.from))){if(s[s.length-1]==` `)return i-1;let e=ze(s,a.tabSize)%ge(a)||ge(a);for(let t=0;t<e&&s[s.length-1-t]==` `;t++)i--;c=i}else c=S(o.text,i-o.from,t,t)+o.from,c==i&&o.number!=(t?a.doc.lines:1)?c+=t?1:-1:!t&&/[\ufe00-\ufe0f]/.test(o.text.slice(c-o.from,i-o.from))&&(c=S(o.text,c-o.from,!1,!1)+o.from);return c}),ui=e=>li(e,!1,!0),di=e=>li(e,!0,!1),fi=(e,t)=>si(e,n=>{let r=n.head,{state:i}=e,a=i.doc.lineAt(r),o=i.charCategorizer(r);for(let e=null;;){if(r==(t?a.to:a.from)){r==n.head&&a.number!=(t?i.doc.lines:1)&&(r+=t?1:-1);break}let s=S(a.text,r-a.from,t)+a.from,c=a.text.slice(Math.min(r,s)-a.from,Math.max(r,s)-a.from),l=o(c);if(e!=null&&l!=e)break;(c!=` `||r!=n.head)&&(e=l),r=s}return r}),pi=e=>fi(e,!1),mi=e=>fi(e,!0),hi=e=>si(e,t=>{let n=e.lineBlockAt(t.head).to;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),gi=e=>si(e,t=>{let n=e.moveToLineBoundary(t,!1).head;return t.head>n?n:Math.max(0,t.head-1)}),_i=e=>si(e,t=>{let n=e.moveToLineBoundary(t,!0).head;return t.head<n?n:Math.min(e.state.doc.length,t.head+1)}),vi=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(e=>({changes:{from:e.from,to:e.to,insert:Ee.of([``,``])},range:T.cursor(e.from)}));return t(e.update(n,{scrollIntoView:!0,userEvent:`input`})),!0},yi=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=e.changeByRange(t=>{if(!t.empty||t.from==0||t.from==e.doc.length)return{range:t};let n=t.from,r=e.doc.lineAt(n),i=n==r.from?n-1:S(r.text,n-r.from,!1)+r.from,a=n==r.to?n+1:S(r.text,n-r.from,!0)+r.from;return{changes:{from:i,to:a,insert:e.doc.slice(n,a).append(e.doc.slice(i,n))},range:T.cursor(a)}});return!n.changes.empty&&(t(e.update(n,{scrollIntoView:!0,userEvent:`move.character`})),!0)};function bi(e){let t=[],n=-1;for(let r of e.selection.ranges){let i=e.doc.lineAt(r.from),a=e.doc.lineAt(r.to);if(!r.empty&&r.to==a.from&&(a=e.doc.lineAt(r.to-1)),n>=i.number){let e=t[t.length-1];e.to=a.to,e.ranges.push(r)}else t.push({from:i.from,to:a.to,ranges:[r]});n=a.number+1}return t}function xi(e,t,n){if(e.readOnly)return!1;let r=[],i=[];for(let t of bi(e)){if(n?t.to==e.doc.length:t.from==0)continue;let a=e.doc.lineAt(n?t.to+1:t.from-1),o=a.length+1;if(n){r.push({from:t.to,to:a.to},{from:t.from,insert:a.text+e.lineBreak});for(let n of t.ranges)i.push(T.range(Math.min(e.doc.length,n.anchor+o),Math.min(e.doc.length,n.head+o)))}else{r.push({from:a.from,to:t.from},{from:t.to,insert:e.lineBreak+a.text});for(let e of t.ranges)i.push(T.range(e.anchor-o,e.head-o))}}return r.length?(t(e.update({changes:r,scrollIntoView:!0,selection:T.create(i,e.selection.mainIndex),userEvent:`move.line`})),!0):!1}var Si=({state:e,dispatch:t})=>xi(e,t,!1),Ci=({state:e,dispatch:t})=>xi(e,t,!0);function wi(e,t,n){if(e.readOnly)return!1;let r=[];for(let t of bi(e))n?r.push({from:t.from,insert:e.doc.slice(t.from,t.to)+e.lineBreak}):r.push({from:t.to,insert:e.lineBreak+e.doc.slice(t.from,t.to)});let i=e.changes(r);return t(e.update({changes:i,selection:e.selection.map(i,n?1:-1),scrollIntoView:!0,userEvent:`input.copyline`})),!0}var Ti=({state:e,dispatch:t})=>wi(e,t,!1),Ei=({state:e,dispatch:t})=>wi(e,t,!0),Di=e=>{if(e.state.readOnly)return!1;let{state:t}=e,n=t.changes(bi(t).map(({from:e,to:n})=>(e>0?e--:n<t.doc.length&&n++,{from:e,to:n}))),r=z(t.selection,t=>{let n;if(e.lineWrapping){let r=e.lineBlockAt(t.head),i=e.coordsAtPos(t.head,t.assoc||1);i&&(n=r.bottom+e.documentTop-i.bottom+e.defaultLineHeight/2)}return e.moveVertically(t,!0,n)}).map(n);return e.dispatch({changes:n,selection:r,scrollIntoView:!0,userEvent:`delete.line`}),!0};function Oi(e,t){if(/\(\)|\[\]|\{\}/.test(e.sliceDoc(t-1,t+1)))return{from:t,to:t};let n=d(e).resolveInner(t),r=n.childBefore(t),i=n.childAfter(t),a;return r&&i&&r.to<=t&&i.from>=t&&(a=r.type.prop(h.closedBy))&&a.indexOf(i.name)>-1&&e.doc.lineAt(r.to).from==e.doc.lineAt(i.from).from&&!/\S/.test(e.sliceDoc(r.to,i.from))?{from:r.to,to:i.from}:null}var ki=ji(!1),Ai=ji(!0);function ji(e){return({state:t,dispatch:n})=>{if(t.readOnly)return!1;let r=t.changeByRange(n=>{let{from:r,to:i}=n,a=t.doc.lineAt(r),o=!e&&r==i&&Oi(t,r);e&&(r=i=(i<=a.to?a:t.doc.lineAt(i)).to);let s=new De(t,{simulateBreak:r,simulateDoubleBreak:!!o}),c=Le(s,r);for(c??=ze(/^\s*/.exec(t.doc.lineAt(r).text)[0],t.tabSize);i<a.to&&/\s/.test(a.text[i-a.from]);)i++;o?{from:r,to:i}=o:r>a.from&&r<a.from+100&&!/\S/.test(a.text.slice(0,r))&&(r=a.from);let l=[``,Ie(t,c)];return o&&l.push(Ie(t,s.lineIndent(a.from,-1))),{changes:{from:r,to:i,insert:Ee.of(l)},range:T.cursor(r+1+l[1].length)}});return n(t.update(r,{scrollIntoView:!0,userEvent:`input`})),!0}}function Mi(e,t){let n=-1;return e.changeByRange(r=>{let i=[];for(let a=r.from;a<=r.to;){let o=e.doc.lineAt(a);o.number>n&&(r.empty||r.to>o.from)&&(t(o,i,r),n=o.number),a=o.to+1}let a=e.changes(i);return{changes:i,range:T.range(a.mapPos(r.anchor,1),a.mapPos(r.head,1))}})}var Ni=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let n=Object.create(null),r=new De(e,{overrideIndentation:e=>n[e]??-1}),i=Mi(e,(t,i,a)=>{let o=Le(r,t.from);if(o==null)return;/\S/.test(t.text)||(o=0);let s=/^\s*/.exec(t.text)[0],c=Ie(e,o);(s!=c||a.from<t.from+s.length)&&(n[t.from]=o,i.push({from:t.from,to:t.from+s.length,insert:c}))});return i.changes.empty||t(e.update(i,{userEvent:`indent`})),!0},Pi=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Mi(e,(t,n)=>{n.push({from:t.from,insert:e.facet(se)})}),{userEvent:`input.indent`})),!0),Fi=({state:e,dispatch:t})=>!e.readOnly&&(t(e.update(Mi(e,(t,n)=>{let r=/^\s*/.exec(t.text)[0];if(!r)return;let i=ze(r,e.tabSize),a=0,o=Ie(e,Math.max(0,i-ge(e)));for(;a<r.length&&a<o.length&&r.charCodeAt(a)==o.charCodeAt(a);)a++;n.push({from:t.from+a,to:t.from+r.length,insert:o.slice(a)})}),{userEvent:`delete.dedent`})),!0),Ii=e=>(e.setTabFocusMode(),!0),Li=[{key:`Ctrl-b`,run:or,shift:jr,preventDefault:!0},{key:`Ctrl-f`,run:sr,shift:Mr},{key:`Ctrl-p`,run:gr,shift:zr},{key:`Ctrl-n`,run:_r,shift:Br},{key:`Ctrl-a`,run:Er,shift:Jr},{key:`Ctrl-e`,run:Dr,shift:Yr},{key:`Ctrl-d`,run:di},{key:`Ctrl-h`,run:ui},{key:`Ctrl-k`,run:hi},{key:`Ctrl-Alt-h`,run:pi},{key:`Ctrl-o`,run:vi},{key:`Ctrl-t`,run:yi},{key:`Ctrl-v`,run:xr}],Ri=[{key:`ArrowLeft`,run:or,shift:jr,preventDefault:!0},{key:`Mod-ArrowLeft`,mac:`Alt-ArrowLeft`,run:lr,shift:Pr,preventDefault:!0},{mac:`Cmd-ArrowLeft`,run:wr,shift:Kr,preventDefault:!0},{key:`ArrowRight`,run:sr,shift:Mr,preventDefault:!0},{key:`Mod-ArrowRight`,mac:`Alt-ArrowRight`,run:ur,shift:Fr,preventDefault:!0},{mac:`Cmd-ArrowRight`,run:Tr,shift:qr,preventDefault:!0},{key:`ArrowUp`,run:gr,shift:zr,preventDefault:!0},{mac:`Cmd-ArrowUp`,run:Xr,shift:Qr},{mac:`Ctrl-ArrowUp`,run:br,shift:Hr},{key:`ArrowDown`,run:_r,shift:Br,preventDefault:!0},{mac:`Cmd-ArrowDown`,run:Zr,shift:$r},{mac:`Ctrl-ArrowDown`,run:xr,shift:Ur},{key:`PageUp`,run:br,shift:Hr},{key:`PageDown`,run:xr,shift:Ur},{key:`Home`,run:Cr,shift:Gr,preventDefault:!0},{key:`Mod-Home`,run:Xr,shift:Qr},{key:`End`,run:Sr,shift:Wr,preventDefault:!0},{key:`Mod-End`,run:Zr,shift:$r},{key:`Enter`,run:ki,shift:ki},{key:`Mod-a`,run:ei},{key:`Backspace`,run:ui,shift:ui,preventDefault:!0},{key:`Delete`,run:di,preventDefault:!0},{key:`Mod-Backspace`,mac:`Alt-Backspace`,run:pi,preventDefault:!0},{key:`Mod-Delete`,mac:`Alt-Delete`,run:mi,preventDefault:!0},{mac:`Mod-Backspace`,run:gi,preventDefault:!0},{mac:`Mod-Delete`,run:_i,preventDefault:!0}].concat(Li.map(e=>({mac:e.key,run:e.run,shift:e.shift}))),zi=[{key:`Alt-ArrowLeft`,mac:`Ctrl-ArrowLeft`,run:pr,shift:Ir},{key:`Alt-ArrowRight`,mac:`Ctrl-ArrowRight`,run:mr,shift:Lr},{key:`Alt-ArrowUp`,run:Si},{key:`Shift-Alt-ArrowUp`,run:Ti},{key:`Alt-ArrowDown`,run:Ci},{key:`Shift-Alt-ArrowDown`,run:Ei},{key:`Mod-Alt-ArrowUp`,run:ii},{key:`Mod-Alt-ArrowDown`,run:ai},{key:`Escape`,run:oi},{key:`Mod-Enter`,run:Ai},{key:`Alt-l`,mac:`Ctrl-l`,run:ti},{key:`Mod-i`,run:ni,preventDefault:!0},{key:`Mod-[`,run:Fi},{key:`Mod-]`,run:Pi},{key:`Mod-Alt-\\`,run:Ni},{key:`Shift-Mod-k`,run:Di},{key:`Shift-Mod-\\`,run:kr},{key:`Mod-/`,run:wn},{key:`Alt-A`,mac:`Ctrl-A`,run:Dn},{key:`Ctrl-m`,mac:`Shift-Alt-m`,run:Ii}].concat(Ri),Bi={key:`Tab`,run:Pi,shift:Fi},Vi=typeof String.prototype.normalize==`function`?e=>e.normalize(`NFKD`):e=>e,G=class{constructor(e,t,n=0,r=e.length,i,a){this.test=a,this.value={from:0,to:0,precise:!1},this.done=!1,this.matches=[],this.buffer=``,this.bufferPos=0,this.iter=e.iterRange(n,r),this.bufferStart=n,this.normalize=i?e=>i(Vi(e)):Vi,this.query=this.normalize(t)}peek(){if(this.bufferPos==this.buffer.length){if(this.bufferStart+=this.buffer.length,this.iter.next(),this.iter.done)return-1;this.bufferPos=0,this.buffer=this.iter.value}return w(this.buffer,this.bufferPos)}next(){for(;this.matches.length;)this.matches.pop();return this.nextOverlapping()}nextOverlapping(){for(;;){let e=this.peek();if(e<0)return this.done=!0,this;let t=Re(e),n=this.bufferStart+this.bufferPos;this.bufferPos+=x(e);let r=this.normalize(t);if(r.length)for(let e=0,i=n,a=!0;;e++){let n=r.charCodeAt(e),o=this.match(n,i,a,this.bufferPos+this.bufferStart,e==r.length-1);if(o)return this.value=o,this;if(e==r.length-1)break;a&&e<t.length&&t.charCodeAt(e)==n?i++:a=!1}}}match(e,t,n,r,i){let a=null;for(let t=0;t<this.matches.length;){let n=this.matches[t],o=!1;this.query.charCodeAt(n.index)==e&&(n.index==this.query.length-1?a={from:n.from,to:r,precise:i&&n.precise}:(n.index++,o=!0)),o?t++:this.matches.splice(t,1)}return this.query.charCodeAt(0)==e&&(this.query.length==1?a={from:t,to:r,precise:n&&i}:this.matches.push({from:t,index:1,precise:n})),a&&this.test&&!this.test(a.from,a.to,this.buffer,this.bufferStart)&&(a=null),a}};typeof Symbol<`u`&&(G.prototype[Symbol.iterator]=function(){return this});var Hi={from:-1,to:-1,match:/.*/.exec(``),precise:!0},Ui=`gm`+(/x/.unicode==null?``:`u`),Wi=class{constructor(e,t,n,r=0,i=e.length){if(this.text=e,this.to=i,this.curLine=``,this.done=!1,this.value=Hi,/\\[sWDnr]|\n|\r|\[\^/.test(t))return new qi(e,t,n,r,i);this.re=new RegExp(t,Ui+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.iter=e.iter();let a=e.lineAt(r);this.curLineStart=a.from,this.matchPos=Yi(e,r),this.getLine(this.curLineStart)}getLine(e){this.iter.next(e),this.iter.lineBreak?this.curLine=``:(this.curLine=this.iter.value,this.curLineStart+this.curLine.length>this.to&&(this.curLine=this.curLine.slice(0,this.to-this.curLineStart)),this.iter.next())}nextLine(){this.curLineStart=this.curLineStart+this.curLine.length+1,this.curLineStart>this.to?this.curLine=``:this.getLine(0)}next(){for(let e=this.matchPos-this.curLineStart;;){this.re.lastIndex=e;let t=this.matchPos<=this.to&&this.re.exec(this.curLine);if(t){let n=this.curLineStart+t.index,r=n+t[0].length;if(this.matchPos=Yi(this.text,r+ +(n==r)),n==this.curLineStart+this.curLine.length&&this.nextLine(),(n<r||n>this.value.to)&&(!this.test||this.test(n,r,t)))return this.value={from:n,to:r,precise:!0,match:t},this;e=this.matchPos-this.curLineStart}else if(this.curLineStart+this.curLine.length<this.to)this.nextLine(),e=0;else return this.done=!0,this}}},Gi=new WeakMap,Ki=class e{constructor(e,t){this.from=e,this.text=t}get to(){return this.from+this.text.length}static get(t,n,r){let i=Gi.get(t);if(!i||i.from>=r||i.to<=n){let i=new e(n,t.sliceString(n,r));return Gi.set(t,i),i}if(i.from==n&&i.to==r)return i;let{text:a,from:o}=i;return o>n&&(a=t.sliceString(n,o)+a,o=n),i.to<r&&(a+=t.sliceString(i.to,r)),Gi.set(t,new e(o,a)),new e(n,a.slice(n-o,r-o))}},qi=class{constructor(e,t,n,r,i){this.text=e,this.to=i,this.done=!1,this.value=Hi,this.matchPos=Yi(e,r),this.re=new RegExp(t,Ui+(n?.ignoreCase?`i`:``)),this.test=n?.test,this.flat=Ki.get(e,r,this.chunkEnd(r+5e3))}chunkEnd(e){return e>=this.to?this.to:this.text.lineAt(e).to}next(){for(;;){let e=this.re.lastIndex=this.matchPos-this.flat.from,t=this.re.exec(this.flat.text);if(t&&!t[0]&&t.index==e&&(this.re.lastIndex=e+1,t=this.re.exec(this.flat.text)),t){let e=this.flat.from+t.index,n=e+t[0].length;if((this.flat.to>=this.to||t.index+t[0].length<=this.flat.text.length-10)&&(!this.test||this.test(e,n,t)))return this.value={from:e,to:n,precise:!0,match:t},this.matchPos=Yi(this.text,n+ +(e==n)),this}if(this.flat.to==this.to)return this.done=!0,this;this.flat=Ki.get(this.text,this.flat.from,this.chunkEnd(this.flat.from+this.flat.text.length*2))}}};typeof Symbol<`u`&&(Wi.prototype[Symbol.iterator]=qi.prototype[Symbol.iterator]=function(){return this});function Ji(e){try{return new RegExp(e,Ui),!0}catch{return!1}}function Yi(e,t){if(t>=e.length)return t;let n=e.lineAt(t),r;for(;t<n.to&&(r=n.text.charCodeAt(t-n.from))>=56320&&r<57344;)t++;return t}var Xi=e=>{let t=oe(e,`cm-goto-line`);if(t){let e=t.dom.querySelector(`input[type=text]`);return e&&e.select(),!0}let{state:n}=e,r=String(n.doc.lineAt(e.state.selection.main.head).number),{close:i,result:a}=fe(e,{class:`cm-goto-line`,label:n.phrase(`Go to line`),input:{type:`text`,name:`line`,value:r},focus:!0,submitLabel:n.phrase(`go`)});return a.then(t=>{let r=t&&/^([+-])?(\d+)?(:\d+)?(%)?$/.exec(t.elements.line.value);if(!r){e.dispatch({effects:i});return}let a=n.doc.lineAt(n.selection.main.head),[,o,s,c,l]=r,u=c?+c.slice(1):0,d=s?+s:a.number;if(s&&l){let e=d/100;o&&(e=e*(o==`-`?-1:1)+a.number/n.doc.lines),d=Math.round(n.doc.lines*e)}else s&&o&&(d=d*(o==`-`?-1:1)+a.number);let f=n.doc.line(Math.max(1,Math.min(n.doc.lines,d))),p=T.cursor(f.from+Math.max(0,Math.min(u,f.length)));e.dispatch({effects:[i,y.scrollIntoView(p.from,{y:`center`})],selection:p})}),!0},Zi={highlightWordAroundCursor:!1,minSelectionLength:1,maxMatches:100,wholeWords:!1},Qi=O.define({combine(e){return Fe(e,Zi,{highlightWordAroundCursor:(e,t)=>e||t,minSelectionLength:Math.min,maxMatches:Math.min})}});function $i(e){let t=[aa,ia];return e&&t.push(Qi.of(e)),t}var ea=E.mark({class:`cm-selectionMatch`}),ta=E.mark({class:`cm-selectionMatch cm-selectionMatch-main`});function na(e,t,n,r){return(n==0||e(t.sliceDoc(n-1,n))!=D.Word)&&(r==t.doc.length||e(t.sliceDoc(r,r+1))!=D.Word)}function ra(e,t,n,r){return e(t.sliceDoc(n,n+1))==D.Word&&e(t.sliceDoc(r-1,r))==D.Word}var ia=ae.fromClass(class{constructor(e){this.decorations=this.getDeco(e)}update(e){(e.selectionSet||e.docChanged||e.viewportChanged)&&(this.decorations=this.getDeco(e.view))}getDeco(e){let t=e.state.facet(Qi),{state:n}=e,r=n.selection;if(r.ranges.length>1)return E.none;let i=r.main,a,o=null;if(i.empty){if(!t.highlightWordAroundCursor)return E.none;let e=n.wordAt(i.head);if(!e)return E.none;o=n.charCategorizer(i.head),a=n.sliceDoc(e.from,e.to)}else{let e=i.to-i.from;if(e<t.minSelectionLength||e>200)return E.none;if(t.wholeWords){if(a=n.sliceDoc(i.from,i.to),o=n.charCategorizer(i.head),!(na(o,n,i.from,i.to)&&ra(o,n,i.from,i.to)))return E.none}else if(a=n.sliceDoc(i.from,i.to),!a)return E.none}let s=[];for(let r of e.visibleRanges){let e=new G(n.doc,a,r.from,r.to);for(;!e.next().done;){let{from:r,to:a}=e.value;if((!o||na(o,n,r,a))&&(i.empty&&r<=i.from&&a>=i.to?s.push(ta.range(r,a)):(r>=i.to||a<=i.from)&&s.push(ea.range(r,a)),s.length>t.maxMatches))return E.none}}return E.set(s)}},{decorations:e=>e.decorations}),aa=y.baseTheme({".cm-selectionMatch":{backgroundColor:`#99ff7780`},".cm-searchMatch .cm-selectionMatch":{backgroundColor:`transparent`}}),oa=({state:e,dispatch:t})=>{let{selection:n}=e,r=T.create(n.ranges.map(t=>e.wordAt(t.head)||T.cursor(t.head)),n.mainIndex);return!r.eq(n)&&(t(e.update({selection:r})),!0)};function sa(e,t){let{main:n,ranges:r}=e.selection,i=e.wordAt(n.head),a=i&&i.from==n.from&&i.to==n.to;for(let n=!1,i=new G(e.doc,t,r[r.length-1].to);;)if(i.next(),i.done){if(n)return null;i=new G(e.doc,t,0,Math.max(0,r[r.length-1].from-1)),n=!0}else{if(n&&r.some(e=>e.from==i.value.from))continue;if(a){let t=e.wordAt(i.value.from);if(!t||t.from!=i.value.from||t.to!=i.value.to)continue}return i.value}}var ca=({state:e,dispatch:t})=>{let{ranges:n}=e.selection;if(n.some(e=>e.from===e.to))return oa({state:e,dispatch:t});let r=e.sliceDoc(n[0].from,n[0].to);if(e.selection.ranges.some(t=>e.sliceDoc(t.from,t.to)!=r))return!1;let i=sa(e,r);return i?(t(e.update({selection:e.selection.addRange(T.range(i.from,i.to),!1),effects:y.scrollIntoView(i.to)})),!0):!1},K=O.define({combine(e){return Fe(e,{top:!1,caseSensitive:!1,literal:!1,regexp:!1,wholeWord:!1,createPanel:e=>new Ba(e),scrollToMatch:e=>y.scrollIntoView(e)})}});function la(e){return e?[K.of(e),Ga]:Ga}var ua=class{constructor(e){this.search=e.search,this.caseSensitive=!!e.caseSensitive,this.literal=!!e.literal,this.regexp=!!e.regexp,this.replace=e.replace||``,this.valid=!!this.search&&(!this.regexp||Ji(this.search)),this.unquoted=this.unquote(this.search),this.wholeWord=!!e.wholeWord,this.test=e.test}unquote(e){return this.literal?e:e.replace(/\\([nrt\\])/g,(e,t)=>t==`n`?`
3
+ `:t==`r`?`\r`:t==`t`?` `:`\\`)}eq(e){return this.search==e.search&&this.replace==e.replace&&this.caseSensitive==e.caseSensitive&&this.regexp==e.regexp&&this.wholeWord==e.wholeWord&&this.test==e.test}create(){return this.regexp?new ya(this):new ma(this)}getCursor(e,t=0,n){let r=e.doc?e:he.create({doc:e});return n??=r.doc.length,this.regexp?J(this,r,t,n):q(this,r,t,n)}},da=class{constructor(e){this.spec=e}};function fa(e,t,n){return(r,i,a,o)=>n&&!n(r,i,a,o)?!1:e(r>=o&&i<=o+a.length?a.slice(r-o,i-o):t.doc.sliceString(r,i),t,r,i)}function q(e,t,n,r){let i;return e.wholeWord&&(i=pa(t.doc,t.charCategorizer(t.selection.main.head))),e.test&&(i=fa(e.test,t,i)),new G(t.doc,e.unquoted,n,r,e.caseSensitive?void 0:e=>e.toLowerCase(),i)}function pa(e,t){return(n,r,i,a)=>((a>n||a+i.length<r)&&(a=Math.max(0,n-2),i=e.sliceString(a,Math.min(e.length,r+2))),(t(ga(i,n-a))!=D.Word||t(_a(i,n-a))!=D.Word)&&(t(_a(i,r-a))!=D.Word||t(ga(i,r-a))!=D.Word))}var ma=class extends da{constructor(e){super(e)}nextMatch(e,t,n){let r=q(this.spec,e,n,e.doc.length).nextOverlapping();if(r.done){let n=Math.min(e.doc.length,t+this.spec.unquoted.length);r=q(this.spec,e,0,n).nextOverlapping()}return r.done||r.value.from==t&&r.value.to==n?null:r.value}prevMatchInRange(e,t,n){for(let r=n;;){let n=Math.max(t,r-1e4-this.spec.unquoted.length),i=q(this.spec,e,n,r),a=null;for(;!i.nextOverlapping().done;)a=i.value;if(a)return a;if(n==t)return null;r-=1e4}}prevMatch(e,t,n){let r=this.prevMatchInRange(e,0,t);return r||=this.prevMatchInRange(e,Math.max(0,n-this.spec.unquoted.length),e.doc.length),r&&(r.from!=t||r.to!=n)?r:null}getReplacement(e){return this.spec.unquote(this.spec.replace)}matchAll(e,t){let n=q(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=q(this.spec,e,Math.max(0,t-this.spec.unquoted.length),Math.min(n+this.spec.unquoted.length,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}};function ha(e,t,n){return(r,i,a)=>(!n||n(r,i,a))&&e(a[0],t,r,i)}function J(e,t,n,r){let i;return e.wholeWord&&(i=va(t.charCategorizer(t.selection.main.head))),e.test&&(i=ha(e.test,t,i)),new Wi(t.doc,e.search,{ignoreCase:!e.caseSensitive,test:i},n,r)}function ga(e,t){return e.slice(S(e,t,!1),t)}function _a(e,t){return e.slice(t,S(e,t))}function va(e){return(t,n,r)=>!r[0].length||(e(ga(r.input,r.index))!=D.Word||e(_a(r.input,r.index))!=D.Word)&&(e(_a(r.input,r.index+r[0].length))!=D.Word||e(ga(r.input,r.index+r[0].length))!=D.Word)}var ya=class extends da{nextMatch(e,t,n){let r=J(this.spec,e,n,e.doc.length).next();return r.done&&(r=J(this.spec,e,0,t).next()),r.done?null:r.value}prevMatchInRange(e,t,n){for(let r=1;;r++){let i=Math.max(t,n-r*1e4),a=J(this.spec,e,i,n),o=null;for(;!a.next().done;)o=a.value;if(o&&(i==t||o.from>i+10))return o;if(i==t)return null}}prevMatch(e,t,n){return this.prevMatchInRange(e,0,t)||this.prevMatchInRange(e,n,e.doc.length)}getReplacement(e){return this.spec.unquote(this.spec.replace).replace(/\$([$&]|\d+)/g,(t,n)=>{if(n==`&`)return e.match[0];if(n==`$`)return`$`;for(let t=n.length;t>0;t--){let r=+n.slice(0,t);if(r>0&&r<e.match.length)return e.match[r]+n.slice(t)}return t})}matchAll(e,t){let n=J(this.spec,e,0,e.doc.length),r=[];for(;!n.next().done;){if(r.length>=t)return null;r.push(n.value)}return r}highlight(e,t,n,r){let i=J(this.spec,e,Math.max(0,t-250),Math.min(n+250,e.doc.length));for(;!i.next().done;)r(i.value.from,i.value.to)}},ba=C.define(),xa=C.define(),Y=Oe.define({create(e){return new Sa(Pa(e).create(),null)},update(e,t){for(let n of t.effects)n.is(ba)?e=new Sa(n.value.create(),e.panel):n.is(xa)&&(e=new Sa(e.query,n.value?Na:null));return e},provide:e=>de.from(e,e=>e.panel)}),Sa=class{constructor(e,t){this.query=e,this.panel=t}},Ca=E.mark({class:`cm-searchMatch`}),wa=E.mark({class:`cm-searchMatch cm-searchMatch-selected`}),Ta=ae.fromClass(class{constructor(e){this.view=e,this.decorations=this.highlight(e.state.field(Y))}update(e){let t=e.state.field(Y);(t!=e.startState.field(Y)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight({query:e,panel:t}){if(!t||!e.spec.valid)return E.none;let{view:n}=this,r=new Pe;for(let t=0,i=n.visibleRanges,a=i.length;t<a;t++){let{from:o,to:s}=i[t];for(;t<a-1&&s>i[t+1].from-500;)s=i[++t].to;e.highlight(n.state,o,s,(e,t)=>{let i=n.state.selection.ranges.some(n=>n.from==e&&n.to==t);r.add(e,t,i?wa:Ca)})}return r.finish()}},{decorations:e=>e.decorations});function Ea(e){return t=>{let n=t.state.field(Y,!1);return n&&n.query.spec.valid?e(t,n):La(t)}}var Da=Ea((e,{query:t})=>{let{to:n}=e.state.selection.main,r=t.nextMatch(e.state,n,n);if(!r)return!1;let i=T.single(r.from,r.to),a=e.state.facet(K);return e.dispatch({selection:i,effects:[Ua(e,r),a.scrollToMatch(i.main,e)],userEvent:`select.search`}),Ia(e),!0}),Oa=Ea((e,{query:t})=>{let{state:n}=e,{from:r}=n.selection.main,i=t.prevMatch(n,r,r);if(!i)return!1;let a=T.single(i.from,i.to),o=e.state.facet(K);return e.dispatch({selection:a,effects:[Ua(e,i),o.scrollToMatch(a.main,e)],userEvent:`select.search`}),Ia(e),!0}),ka=Ea((e,{query:t})=>{let n=t.matchAll(e.state,1e3);return!n||!n.length?!1:(e.dispatch({selection:T.create(n.map(e=>T.range(e.from,e.to))),userEvent:`select.search.matches`}),!0)}),Aa=({state:e,dispatch:t})=>{let n=e.selection;if(n.ranges.length>1||n.main.empty)return!1;let{from:r,to:i}=n.main,a=[],o=0;for(let t=new G(e.doc,e.sliceDoc(r,i));!t.next().done;){if(a.length>1e3)return!1;t.value.from==r&&(o=a.length),a.push(T.range(t.value.from,t.value.to))}return t(e.update({selection:T.create(a,o),userEvent:`select.search.matches`})),!0},ja=Ea((e,{query:t})=>{let{state:n}=e,{from:r,to:i}=n.selection.main;if(n.readOnly)return!1;let a=t.nextMatch(n,r,r);if(!a)return!1;let o=a,s=[],c,l,u=[];o.precise?o.from==r&&o.to==i&&(l=n.toText(t.getReplacement(o)),s.push({from:o.from,to:o.to,insert:l}),o=t.nextMatch(n,o.from,o.to),u.push(y.announce.of(n.phrase(`replaced match on line $`,n.doc.lineAt(r).number)+`.`))):o=t.nextMatch(n,o.from,o.to);let d=e.state.changes(s);return o&&(c=T.single(o.from,o.to).map(d),u.push(Ua(e,o)),u.push(n.facet(K).scrollToMatch(c.main,e))),e.dispatch({changes:d,selection:c,effects:u,userEvent:`input.replace`}),!0}),Ma=Ea((e,{query:t})=>{if(e.state.readOnly)return!1;let n=[];for(let r of t.matchAll(e.state,1e9)){let{from:e,to:i,precise:a}=r;a&&n.push({from:e,to:i,insert:t.getReplacement(r)})}if(!n.length)return!1;let r=e.state.phrase(`replaced $ matches`,n.length)+`.`;return e.dispatch({changes:n,effects:y.announce.of(r),userEvent:`input.replace.all`}),!0});function Na(e){return e.state.facet(K).createPanel(e)}function Pa(e,t){let n=e.selection.main,r=n.empty||n.to>n.from+100?``:e.sliceDoc(n.from,n.to);if(t&&!r)return t;let i=e.facet(K);return new ua({search:t?.literal??i.literal?r:r.replace(/\n/g,`\\n`),caseSensitive:t?.caseSensitive??i.caseSensitive,literal:t?.literal??i.literal,regexp:t?.regexp??i.regexp,wholeWord:t?.wholeWord??i.wholeWord})}function Fa(e){let t=Be(e,Na);return t&&t.dom.querySelector(`[main-field]`)}function Ia(e){let t=Fa(e);t&&t==e.root.activeElement&&t.select()}var La=e=>{let t=e.state.field(Y,!1);if(t&&t.panel){let n=Fa(e);if(n&&n!=e.root.activeElement){let r=Pa(e.state,t.query.spec);r.valid&&e.dispatch({effects:ba.of(r)}),n.focus(),n.select()}}else e.dispatch({effects:[xa.of(!0),t?ba.of(Pa(e.state,t.query.spec)):C.appendConfig.of(Ga)]});return!0},Ra=e=>{let t=e.state.field(Y,!1);if(!t||!t.panel)return!1;let n=Be(e,Na);return n&&n.dom.contains(e.root.activeElement)&&e.focus(),e.dispatch({effects:xa.of(!1)}),!0},za=[{key:`Mod-f`,run:La,scope:`editor search-panel`},{key:`F3`,run:Da,shift:Oa,scope:`editor search-panel`,preventDefault:!0},{key:`Mod-g`,run:Da,shift:Oa,scope:`editor search-panel`,preventDefault:!0},{key:`Escape`,run:Ra,scope:`editor search-panel`},{key:`Mod-Shift-l`,run:Aa},{key:`Mod-Alt-g`,run:Xi},{key:`Mod-d`,run:ca,preventDefault:!0}],Ba=class{constructor(e){this.view=e;let t=this.query=e.state.field(Y).query.spec;this.commit=this.commit.bind(this),this.searchField=b(`input`,{value:t.search,placeholder:X(e,`Find`),"aria-label":X(e,`Find`),class:`cm-textfield`,name:`search`,form:``,"main-field":`true`,onchange:this.commit,onkeyup:this.commit}),this.replaceField=b(`input`,{value:t.replace,placeholder:X(e,`Replace`),"aria-label":X(e,`Replace`),class:`cm-textfield`,name:`replace`,form:``,onchange:this.commit,onkeyup:this.commit}),this.caseField=b(`input`,{type:`checkbox`,name:`case`,form:``,checked:t.caseSensitive,onchange:this.commit}),this.reField=b(`input`,{type:`checkbox`,name:`re`,form:``,checked:t.regexp,onchange:this.commit}),this.wordField=b(`input`,{type:`checkbox`,name:`word`,form:``,checked:t.wholeWord,onchange:this.commit});function n(e,t,n){return b(`button`,{class:`cm-button`,name:e,onclick:t,type:`button`},n)}this.dom=b(`div`,{onkeydown:e=>this.keydown(e),class:`cm-search`},[this.searchField,n(`next`,()=>Da(e),[X(e,`next`)]),n(`prev`,()=>Oa(e),[X(e,`previous`)]),n(`select`,()=>ka(e),[X(e,`all`)]),b(`label`,null,[this.caseField,X(e,`match case`)]),b(`label`,null,[this.reField,X(e,`regexp`)]),b(`label`,null,[this.wordField,X(e,`by word`)]),...e.state.readOnly?[]:[b(`br`),this.replaceField,n(`replace`,()=>ja(e),[X(e,`replace`)]),n(`replaceAll`,()=>Ma(e),[X(e,`replace all`)])],b(`button`,{name:`close`,onclick:()=>Ra(e),"aria-label":X(e,`close`),type:`button`},[`×`])])}commit(){let e=new ua({search:this.searchField.value,caseSensitive:this.caseField.checked,regexp:this.reField.checked,wholeWord:this.wordField.checked,replace:this.replaceField.value});e.eq(this.query)||(this.query=e,this.view.dispatch({effects:ba.of(e)}))}keydown(e){te(this.view,e,`search-panel`)?e.preventDefault():e.keyCode==13&&e.target==this.searchField?(e.preventDefault(),(e.shiftKey?Oa:Da)(this.view)):e.keyCode==13&&e.target==this.replaceField&&(e.preventDefault(),ja(this.view))}update(e){for(let t of e.transactions)for(let e of t.effects)e.is(ba)&&!e.value.eq(this.query)&&this.setQuery(e.value)}setQuery(e){this.query=e,this.searchField.value=e.search,this.replaceField.value=e.replace,this.caseField.checked=e.caseSensitive,this.reField.checked=e.regexp,this.wordField.checked=e.wholeWord}mount(){this.searchField.select()}get pos(){return 80}get top(){return this.view.state.facet(K).top}};function X(e,t){return e.state.phrase(t)}var Va=30,Ha=/[\s\.,:;?!]/;function Ua(e,{from:t,to:n}){let r=e.state.doc.lineAt(t),i=e.state.doc.lineAt(n).to,a=Math.max(r.from,t-Va),o=Math.min(i,n+Va),s=e.state.sliceDoc(a,o);if(a!=r.from){for(let e=0;e<Va;e++)if(!Ha.test(s[e+1])&&Ha.test(s[e])){s=s.slice(e);break}}if(o!=i){for(let e=s.length-1;e>s.length-Va;e--)if(!Ha.test(s[e-1])&&Ha.test(s[e])){s=s.slice(0,e);break}}return y.announce.of(`${e.state.phrase(`current match`)}. ${s} ${e.state.phrase(`on line`)} ${r.number}.`)}var Wa=y.baseTheme({".cm-panel.cm-search":{padding:`2px 6px 4px`,position:`relative`,"& [name=close]":{position:`absolute`,top:`0`,right:`4px`,backgroundColor:`inherit`,border:`none`,font:`inherit`,padding:0,margin:0},"& input, & button, & label":{margin:`.2em .6em .2em 0`},"& input[type=checkbox]":{marginRight:`.2em`},"& label":{fontSize:`80%`,whiteSpace:`pre`}},"&light .cm-searchMatch":{backgroundColor:`#ffff0054`},"&dark .cm-searchMatch":{backgroundColor:`#00ffff8a`},"&light .cm-searchMatch-selected":{backgroundColor:`#ff6a0054`},"&dark .cm-searchMatch-selected":{backgroundColor:`#ff00ff8a`}}),Ga=[Y,ve.low(Ta),Wa],Ka={js:`javascript`,mjs:`javascript`,cjs:`javascript`,jsx:`jsx`,ts:`typescript`,mts:`typescript`,cts:`typescript`,tsx:`tsx`,c:`cpp`,h:`cpp`,cpp:`cpp`,cc:`cpp`,cxx:`cpp`,hpp:`cpp`,hh:`cpp`,java:`java`,kt:`kotlin`,kts:`kotlin`,cs:`csharp`,html:`html`,htm:`html`,xhtml:`html`,php:`php`,xml:`xml`,svg:`xml`,css:`css`,scss:`scss`,less:`less`,json:`json`,jsonc:`json`,md:`markdown`,markdown:`markdown`,yaml:`yaml`,yml:`yaml`,toml:`toml`,py:`python`,rb:`ruby`,lua:`lua`,swift:`swift`,rs:`rust`,go:`go`,sql:`sql`,sh:`shell`,bash:`shell`,dockerfile:`dockerfile`};function qa(e){let t=(e.replace(/[?#].*$/,``).split(`/`).pop()??``).toLowerCase();if(t===`dockerfile`||t.startsWith(`dockerfile.`))return`dockerfile`;let n=t.lastIndexOf(`.`);return n<=0?null:Ka[t.slice(n+1)]??null}var Z=e=>_e.define(e),Ja={javascript:async()=>(await r(async()=>{let{javascript:e}=await import(`./dist-DYPX2Ybv.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([0,1,2,3]),import.meta.url)).javascript(),jsx:async()=>(await r(async()=>{let{javascript:e}=await import(`./dist-DYPX2Ybv.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([0,1,2,3]),import.meta.url)).javascript({jsx:!0}),typescript:async()=>(await r(async()=>{let{javascript:e}=await import(`./dist-DYPX2Ybv.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([0,1,2,3]),import.meta.url)).javascript({typescript:!0}),tsx:async()=>(await r(async()=>{let{javascript:e}=await import(`./dist-DYPX2Ybv.js`).then(e=>e.t);return{javascript:e}},__vite__mapDeps([0,1,2,3]),import.meta.url)).javascript({jsx:!0,typescript:!0}),cpp:async()=>(await r(async()=>{let{cpp:e}=await import(`./dist-rmKzqdIO.js`);return{cpp:e}},__vite__mapDeps([4,2,3]),import.meta.url)).cpp(),java:async()=>(await r(async()=>{let{java:e}=await import(`./dist-IR189dk6.js`);return{java:e}},__vite__mapDeps([5,2,3]),import.meta.url)).java(),kotlin:async()=>Z((await r(async()=>{let{kotlin:e}=await import(`./clike-pnxEhJ5P.js`);return{kotlin:e}},[],import.meta.url)).kotlin),csharp:async()=>Z((await r(async()=>{let{csharp:e}=await import(`./clike-pnxEhJ5P.js`);return{csharp:e}},[],import.meta.url)).csharp),html:async()=>(await r(async()=>{let{html:e}=await import(`./dist-D9412h7o.js`);return{html:e}},__vite__mapDeps([6,2,3,7,1,0]),import.meta.url)).html(),php:async()=>(await r(async()=>{let{php:e}=await import(`./dist-CYq92lOO.js`);return{php:e}},__vite__mapDeps([8,2,3,6,7,1,0]),import.meta.url)).php(),xml:async()=>(await r(async()=>{let{xml:e}=await import(`./dist-CxEuuaKq.js`);return{xml:e}},__vite__mapDeps([9,2,3]),import.meta.url)).xml(),css:async()=>(await r(async()=>{let{css:e}=await import(`./dist-BfGIsxxP.js`).then(e=>e.r);return{css:e}},__vite__mapDeps([7,1,2,3]),import.meta.url)).css(),scss:async()=>(await r(async()=>{let{css:e}=await import(`./dist-BfGIsxxP.js`).then(e=>e.r);return{css:e}},__vite__mapDeps([7,1,2,3]),import.meta.url)).css(),less:async()=>(await r(async()=>{let{css:e}=await import(`./dist-BfGIsxxP.js`).then(e=>e.r);return{css:e}},__vite__mapDeps([7,1,2,3]),import.meta.url)).css(),json:async()=>(await r(async()=>{let{json:e}=await import(`./dist-33oU5N7i.js`);return{json:e}},__vite__mapDeps([10,2,3]),import.meta.url)).json(),markdown:async()=>(await r(async()=>{let{markdown:e}=await import(`./dist-CEr2uR4w.js`);return{markdown:e}},__vite__mapDeps([11,2,6,3,7,1,0]),import.meta.url)).markdown(),yaml:async()=>(await r(async()=>{let{yaml:e}=await import(`./dist-1MAn9CBM.js`);return{yaml:e}},__vite__mapDeps([12,2,3]),import.meta.url)).yaml(),toml:async()=>Z((await r(async()=>{let{toml:e}=await import(`./toml-BPTmHmyx.js`);return{toml:e}},[],import.meta.url)).toml),python:async()=>(await r(async()=>{let{python:e}=await import(`./dist-drsoOe-s.js`);return{python:e}},__vite__mapDeps([13,2,3]),import.meta.url)).python(),ruby:async()=>Z((await r(async()=>{let{ruby:e}=await import(`./ruby-ChfNwlCY.js`);return{ruby:e}},[],import.meta.url)).ruby),lua:async()=>Z((await r(async()=>{let{lua:e}=await import(`./lua-DPCEkfD_.js`);return{lua:e}},[],import.meta.url)).lua),swift:async()=>Z((await r(async()=>{let{swift:e}=await import(`./swift-DKB6_1j6.js`);return{swift:e}},[],import.meta.url)).swift),rust:async()=>(await r(async()=>{let{rust:e}=await import(`./dist-C5-Hv917.js`);return{rust:e}},__vite__mapDeps([14,2,3]),import.meta.url)).rust(),go:async()=>(await r(async()=>{let{go:e}=await import(`./dist-BnQxBrCW.js`);return{go:e}},__vite__mapDeps([15,2,3]),import.meta.url)).go(),sql:async()=>(await r(async()=>{let{sql:e}=await import(`./dist-B9NMd4es.js`);return{sql:e}},__vite__mapDeps([16,2,3]),import.meta.url)).sql(),shell:async()=>Z((await r(async()=>{let{shell:e}=await import(`./shell-DwuoZtxw.js`);return{shell:e}},[],import.meta.url)).shell),dockerfile:async()=>Z((await r(async()=>{let{dockerFile:e}=await import(`./dockerfile-BDePf5PZ.js`);return{dockerFile:e}},[],import.meta.url)).dockerFile)};function Ya(e){return e===null?Promise.resolve([]):Ja[e]()}var Q=t(),Xa=u.define(),$=(e,t)=>`color-mix(in srgb, var(${e}) ${t}%, transparent)`,Za=y.theme({"&":{height:`100%`,color:`var(--oo-color-text)`,backgroundColor:`var(--oo-color-canvas)`,fontSize:`var(--oo-font-size-xs)`},".cm-scroller":{fontFamily:`var(--oo-font-mono, monospace)`,lineHeight:`1.5`},".cm-content":{caretColor:`var(--oo-color-accent)`},".cm-cursor, .cm-dropCursor":{borderLeftColor:`var(--oo-color-accent)`},".cm-selectionBackground, &.cm-focused > .cm-scroller > .cm-selectionLayer .cm-selectionBackground, .cm-content ::selection":{backgroundColor:$(`--oo-color-accent`,28)},".cm-activeLine":{backgroundColor:$(`--oo-color-text`,5)},".cm-gutters":{backgroundColor:`var(--oo-color-canvas)`,color:`var(--oo-color-muted)`,borderRight:`1px solid var(--oo-color-border)`},".cm-activeLineGutter":{backgroundColor:$(`--oo-color-text`,5),color:`var(--oo-color-text)`},".cm-foldPlaceholder":{backgroundColor:`var(--oo-color-hover)`,border:`1px solid var(--oo-color-border)`,color:`var(--oo-color-muted)`},".cm-selectionMatch":{backgroundColor:$(`--oo-color-accent`,14)},"&.cm-focused .cm-matchingBracket":{backgroundColor:$(`--oo-color-accent`,30),outline:`1px solid var(--oo-color-accent)`},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:$(`--oo-color-danger`,30)},".cm-searchMatch":{backgroundColor:$(`--oo-color-warning`,30)},".cm-searchMatch.cm-searchMatch-selected":{backgroundColor:$(`--oo-color-warning`,60)},".cm-panels":{backgroundColor:`var(--oo-color-panel)`,color:`var(--oo-color-text)`},".cm-panels.cm-panels-top":{borderBottom:`1px solid var(--oo-color-border)`},".cm-panels.cm-panels-bottom":{borderTop:`1px solid var(--oo-color-border)`},".cm-textfield":{backgroundColor:`var(--oo-color-canvas)`,color:`var(--oo-color-text)`,border:`1px solid var(--oo-color-border)`,borderRadius:`var(--oo-radius-sm)`},".cm-button":{backgroundImage:`none`,backgroundColor:`var(--oo-color-surface)`,color:`var(--oo-color-text)`,border:`1px solid var(--oo-color-border)`,borderRadius:`var(--oo-radius-sm)`},".cm-tooltip":{backgroundColor:`var(--oo-color-raised)`,color:`var(--oo-color-text)`,border:`1px solid var(--oo-color-border)`},".cm-tooltip-autocomplete > ul > li[aria-selected]":{backgroundColor:`var(--oo-color-selected)`,color:`var(--oo-color-text)`}}),Qa=Me.define([{tag:[k.keyword,k.controlKeyword,k.moduleKeyword,k.operatorKeyword,k.definitionKeyword,k.modifier],color:`var(--ahpw-code-keyword)`},{tag:[k.string,k.special(k.string),k.regexp,k.character],color:`var(--ahpw-code-string)`},{tag:[k.number,k.bool,k.null,k.atom,k.unit],color:`var(--ahpw-code-number)`},{tag:[k.comment,k.lineComment,k.blockComment,k.docComment],color:`var(--ahpw-code-comment)`,fontStyle:`italic`},{tag:[k.function(k.variableName),k.function(k.propertyName),k.macroName],color:`var(--ahpw-code-function)`},{tag:[k.typeName,k.className,k.namespace,k.standard(k.typeName)],color:`var(--ahpw-code-type)`},{tag:[k.propertyName,k.definition(k.propertyName),k.labelName],color:`var(--ahpw-code-property)`},{tag:[k.tagName,k.angleBracket],color:`var(--ahpw-code-tag)`},{tag:k.attributeName,color:`var(--ahpw-code-attribute)`},{tag:[k.meta,k.processingInstruction,k.annotation],color:`var(--ahpw-code-meta)`},{tag:k.heading,color:`var(--ahpw-code-keyword)`,fontWeight:`600`},{tag:[k.link,k.url],color:`var(--ahpw-code-string)`,textDecoration:`underline`},{tag:k.emphasis,fontStyle:`italic`},{tag:k.strong,fontWeight:`600`},{tag:k.strikethrough,textDecoration:`line-through`},{tag:k.invalid,color:`var(--oo-color-danger)`}]),$a=e=>[he.readOnly.of(e),y.editable.of(!e)];function eo(e,t,n){let r=e.state.doc,i=r.line(Math.min(Math.max(t,1),r.lines)),a=r.line(Math.min(Math.max(n??t,i.number),r.lines));e.dispatch({selection:T.range(i.from,a.to),effects:y.scrollIntoView(i.from,{y:`center`})})}function to({value:e,language:t=null,readOnly:n=!1,line:r,end:i,onChange:a,onSave:o}){let s=(0,A.useRef)(null),c=(0,A.useRef)(null),l=(0,A.useRef)(new Ae),u=(0,A.useRef)(new Ae),d=(0,A.useRef)({onChange:a,onSave:o});return d.current={onChange:a,onSave:o},(0,A.useEffect)(()=>{let t=s.current;if(t===null)return;let r=new y({parent:t,state:he.create({doc:e,extensions:[_(),v(),ce(),Bn(),xe(),ee(),re(),he.allowMultipleSelections.of(!0),p(),Ce(Qa),we(),rn(),xn(),ke(),le(),$i(),la({top:!0}),ue.of([{key:`Mod-s`,preventDefault:!0,run:e=>(d.current.onSave?.(e.state.doc.toString()),!0)},...un,...zi,...za,...rr,...me,...Sn,Bi]),Za,l.current.of([]),u.current.of($a(n)),y.updateListener.of(e=>{e.docChanged&&!e.transactions.some(e=>e.annotation(Xa)===!0)&&d.current.onChange?.(e.state.doc.toString())})]})});return c.current=r,()=>{r.destroy(),c.current=null}},[]),(0,A.useEffect)(()=>{let t=c.current;t!==null&&t.state.doc.toString()!==e&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e},annotations:Xa.of(!0)})},[e]),(0,A.useEffect)(()=>{let e=!0;return Ya(t).then(t=>{e&&c.current?.dispatch({effects:l.current.reconfigure(t)})}).catch(()=>void 0),()=>{e=!1}},[t]),(0,A.useEffect)(()=>{c.current?.dispatch({effects:u.current.reconfigure($a(n))})},[n]),(0,A.useEffect)(()=>{let e=c.current;e!==null&&typeof r==`number`&&eo(e,r,i)},[r,i,e]),(0,Q.jsx)(`div`,{className:`web-editor`,ref:s})}var no=5e6;function ro(e){return e.length>5e6?{text:e.slice(0,no),cut:!0}:{text:e,cut:!1}}function io(e){return typeof e==`object`&&!!e&&e.code===o.PermissionDenied}function ao(e){return typeof e==`object`&&!!e&&e.code===o.Conflict}var oo=e({default:()=>so});function so({uri:e,line:t,end:n}){let r=Ve(e),[o,u]=(0,A.useState)(!1),[d,f]=(0,A.useState)(null),p=(0,A.useRef)(``),m=(0,A.useRef)(``),h=(0,A.useRef)(!1),g=(0,A.useRef)(void 0);i(()=>o?`The changes to this file are not saved.`:null);let _=r!==null&&`text`in r&&r.text!==null?ro(r.text):null;(0,A.useEffect)(()=>{if(p.current=_?.text??``,m.current=p.current,u(!1),f(null),g.current=void 0,e===void 0||_===null)return;let t=!0;return s(e).then(e=>{t&&(g.current=e)}).catch(()=>void 0),()=>{t=!1}},[e,_?.text]);let v=(0,A.useCallback)(e=>{m.current=e,u(e!==p.current)},[]),ee=(0,A.useCallback)(t=>{e===void 0||h.current||(h.current=!0,a(e,t,g.current).then(async()=>{p.current=t,u(m.current!==t),f(null),g.current=await s(e).catch(()=>void 0)}).catch(e=>{let t=ao(e)?`The file changed on the server since it was opened. Copy your edit, then reopen the file.`:e instanceof Error?e.message:String(e);f({message:t,refused:io(e)})}).finally(()=>{h.current=!1}))},[e]);if(e===void 0)return(0,Q.jsx)(l,{tone:`warning`,message:`No file was named.`});let te=(0,Q.jsx)(He,{uri:e,dirty:o});return r===null?(0,Q.jsxs)(`div`,{className:`web-file`,children:[te,(0,Q.jsx)(c,{label:`Reading the file`})]}):`error`in r?(0,Q.jsxs)(`div`,{className:`web-file`,children:[te,(0,Q.jsx)(l,{tone:`danger`,title:`Not readable`,message:r.error})]}):_===null?(0,Q.jsxs)(`div`,{className:`web-file`,children:[te,(0,Q.jsx)(`p`,{className:`web-note`,children:`This file is not text.`})]}):(0,Q.jsxs)(`div`,{className:`web-file`,children:[te,d===null?null:(0,Q.jsx)(l,{tone:`danger`,title:d.refused?`Read-only`:`Not saved`,message:d.message}),_.cut?(0,Q.jsx)(`p`,{className:`web-note`,children:`This file is over 5 MB. It shows the start, read-only.`}):null,(0,Q.jsx)(`div`,{className:`web-file__body web-file__body--editor`,children:(0,Q.jsx)(to,{value:_.text,language:qa(e),readOnly:_.cut||d?.refused===!0,line:t??null,end:n??null,onChange:v,onSave:ee})})]})}export{$t as a,so as default,qe as i,Ue as n,Ke as r,oo as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./useStore-BQkzWMs-.js";import{n}from"./ScenaProvider-6A3TJumQ.js";import{S as r}from"./index-DBKNxflN.js";var i=e();function a({namespace:e,fields:a}){let d=n(),{t:f}=r(`query`),p=t(`$/${e}/query`),m=p?.where??[],h=t=>d.store.set(`$/${e}/query`,{...p??{page:1,pageSize:50},...t,page:1}),g=e=>e.value??!0,_=e=>m.some(t=>t.field===e.field&&t.value===g(e)),v=e=>{let t=m.filter(t=>t.field!==e.field),n=_(e)?t:[...t,{field:e.field,op:e.op??`eq`,value:g(e)}];h({where:n})};return(0,i.jsxs)(`div`,{style:o,children:[(0,i.jsx)(`input`,{style:s,placeholder:f(`search`,`Search…`),value:p?.q??``,onChange:e=>h({q:e.currentTarget.value})}),a?.length?(0,i.jsx)(`div`,{style:c,children:a.map(e=>(0,i.jsx)(`button`,{type:`button`,style:{...l,..._(e)?u:{}},onClick:()=>v(e),children:e.label??e.field},e.field))}):null]})}var o={display:`flex`,flexDirection:`column`,gap:6,padding:8},s={boxSizing:`border-box`,width:`100%`,padding:`6px 8px`,background:`var(--oo-color-canvas, #16181d)`,border:`1px solid var(--oo-color-border, #2b2f37)`,borderRadius:4,outline:`none`,fontSize:13,color:`var(--oo-color-text, #e6e8eb)`},c={display:`flex`,flexWrap:`wrap`,gap:4},l={appearance:`none`,border:`1px solid var(--oo-color-border, #2b2f37)`,background:`none`,borderRadius:999,padding:`2px 8px`,fontSize:11,cursor:`pointer`,color:`var(--oo-color-muted, #8a8f98)`},u={color:`#fff`,background:`var(--oo-color-accent, #4c7fff)`,borderColor:`var(--oo-color-accent, #4c7fff)`};export{a as Filter};
@@ -0,0 +1 @@
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";var n=t(),r=e();function i({embedder:e}){let[t,i]=(0,n.useState)(null),[a,o]=(0,n.useState)([]),[s,c]=(0,n.useState)({}),[l,u]=(0,n.useState)(!1),d=(0,n.useRef)(null);(0,n.useEffect)(()=>{let t=!0;e.host().then(e=>t&&i(e)),e.hosts().then(e=>t&&o(e)),e.statuses().then(e=>t&&c(e));let n=[e.onHosts(e=>{o(e),i(t=>e.find(e=>e.id===t?.id)??t)}),e.onStatuses(c)];return()=>{t=!1;for(let e of n)e()}},[e]),(0,n.useEffect)(()=>{if(!l)return;let e=e=>{d.current?.contains(e.target)||u(!1)},t=e=>{e.key===`Escape`&&u(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[l]);let f=e=>(0,r.jsx)(`span`,{className:`embed-dot embed-dot--${s[e]??`connecting`}`,"aria-label":s[e]??`connecting`});return(0,r.jsxs)(`div`,{className:`embed-host`,ref:d,children:[(0,r.jsxs)(`button`,{type:`button`,className:`embed-host__button`,"aria-haspopup":`menu`,"aria-expanded":l,onClick:()=>u(!l),children:[t!==null&&f(t.id),(0,r.jsx)(`span`,{className:`embed-host__name`,children:t?.name??`…`}),(0,r.jsx)(`svg`,{width:`8`,height:`8`,viewBox:`0 0 8 8`,"aria-hidden":`true`,children:(0,r.jsx)(`path`,{d:`M1 2.5l3 3 3-3`,fill:`none`,stroke:`currentColor`})})]}),l&&(0,r.jsxs)(`div`,{className:`embed-host__menu`,role:`menu`,children:[a.map(n=>(0,r.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`embed-host__item`,"aria-current":n.id===t?.id,onClick:()=>{u(!1),n.id!==t?.id&&e.switchHost(n.id)},children:[f(n.id),(0,r.jsx)(`span`,{className:`embed-host__name`,children:n.name}),(0,r.jsx)(`span`,{className:`embed-host__url`,children:n.url.replace(/^ws:\/\//i,``)})]},n.id)),(0,r.jsx)(`div`,{className:`embed-host__line`,role:`separator`}),(0,r.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`embed-host__item embed-host__action`,onClick:()=>{u(!1),e.manageHosts()},children:[(0,r.jsx)(`span`,{"aria-hidden":`true`,children:`☰`}),(0,r.jsx)(`span`,{className:`embed-host__name`,children:`Manage hosts`})]}),(0,r.jsxs)(`button`,{type:`button`,role:`menuitem`,className:`embed-host__item embed-host__action`,onClick:()=>{u(!1),e.manageHosts({add:!0})},children:[(0,r.jsx)(`span`,{"aria-hidden":`true`,children:`+`}),(0,r.jsx)(`span`,{className:`embed-host__name`,children:`Add host`})]})]})]})}export{i as default};
@@ -0,0 +1 @@
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./media-C3ferCB3.js";var r=t();function i(e,t,n){return Math.round(n>0&&t>0?t*e*100/n:e*100)}var a=e(),o=1,s=20,c=1.25;function l({url:e,alt:t}){let n=(0,r.useRef)(null),l=(0,r.useRef)(null),[u,d]=(0,r.useState)(o),[f,p]=(0,r.useState)({fitted:0,natural:0}),[m,h]=(0,r.useState)({x:0,y:0}),[g,_]=(0,r.useState)(!1),v=(0,r.useRef)(null),y=()=>{d(o),h({x:0,y:0})};(0,r.useEffect)(y,[e]);let b=(e,t=0,n=0)=>{let r=Math.min(s,Math.max(o,e));if(r===u)return;let i=r/u;h(r===o?{x:0,y:0}:e=>({x:t-(t-e.x)*i,y:n-(n-e.y)*i})),d(r)},x=e=>{let t=n.current?.getBoundingClientRect();t!==void 0&&b(u*Math.exp(-e.deltaY*.0015),e.clientX-t.left-t.width/2,e.clientY-t.top-t.height/2)},S=()=>{let e=l.current;e!==null&&p({fitted:e.offsetWidth,natural:e.naturalWidth})};(0,r.useEffect)(()=>{let e=n.current;if(e===null||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(S);return t.observe(e),()=>t.disconnect()},[]);let C=e=>{u<=o||(v.current={x:e.clientX,y:e.clientY,ox:m.x,oy:m.y},_(!0),e.currentTarget.setPointerCapture(e.pointerId))},w=e=>{let t=v.current;t!==null&&h({x:t.ox+e.clientX-t.x,y:t.oy+e.clientY-t.y})},T=()=>{v.current=null,_(!1)};(0,r.useEffect)(()=>{let e=n.current,t=e=>e.preventDefault();return e?.addEventListener(`wheel`,t,{passive:!1}),()=>e?.removeEventListener(`wheel`,t)},[]);let E=u>o;return(0,a.jsxs)(`div`,{className:`web-image__view`,children:[(0,a.jsxs)(`div`,{className:`web-image__bar`,role:`toolbar`,"aria-label":`Zoom`,children:[(0,a.jsx)(`button`,{type:`button`,className:`web-image__step`,title:`Zoom out`,"aria-label":`Zoom out`,disabled:!E,onClick:()=>b(u/c),children:`−`}),(0,a.jsxs)(`button`,{type:`button`,className:`web-image__step web-image__percent`,title:`Fit`,"aria-label":`Fit`,disabled:!E,onClick:y,children:[i(u,f.fitted,f.natural),`%`]}),(0,a.jsx)(`button`,{type:`button`,className:`web-image__step`,title:`Zoom in`,"aria-label":`Zoom in`,disabled:u>=s,onClick:()=>b(u*c),children:`+`})]}),(0,a.jsx)(`div`,{ref:n,className:`web-image`,"data-zoomed":E?`true`:`false`,"data-dragging":g?`true`:`false`,onWheel:x,onPointerDown:C,onPointerMove:w,onPointerUp:T,onPointerCancel:T,onDoubleClick:y,children:(0,a.jsx)(`img`,{ref:l,src:e,alt:t,draggable:!1,onLoad:S,style:{transform:`translate(${m.x}px, ${m.y}px) scale(${u})`}})})]})}var u=e=>decodeURIComponent(e.split(`/`).pop()??e);function d({uri:e}){return(0,a.jsx)(n,{uri:e,children:t=>(0,a.jsx)(l,{url:t,alt:u(e??``)})})}export{d as default};
@@ -1 +1 @@
1
- import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./Button-_R1oktDz.js";import{i as a,n as o,o as s,r as c,x as l}from"./data-Fkj0LNnG.js";import{n as u,t as d}from"./words-BknpHIF3.js";import{t as f}from"./Badge-BDEW5PFb.js";import{t as p}from"./Alert-CHZkhmDE.js";import{t as m}from"./Text-MPtQvYE-.js";import{t as h}from"./DetailList-Yalgw0YM.js";import{h as g}from"./index-BkzdJo_Y.js";import{a as _}from"./turn-BoF7W1h6.js";var v=t(),y=e(),b={connected:{tone:`success`,text:`Connected`},connecting:{tone:`info`,text:`Connecting`},reconnecting:{tone:`warning`,text:`Reconnecting`},disconnected:{tone:`default`,text:`Disconnected`},failed:{tone:`danger`,text:`Failed`}};function x(e){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null);return(0,v.useEffect)(()=>{n(null),i(null)},[e]),{status:t,error:r}}function S(){let[e,t]=(0,v.useState)(()=>Date.now());return(0,v.useEffect)(()=>{let e=window.setInterval(()=>t(Date.now()),1e3);return()=>window.clearInterval(e)},[]),e}function C(){let e=r(),t=n(c),v=n(s),C=n(`$/ahp/agents`)??[],w=n(a),T=n(o),{status:E,error:D}=x(t?.generation??0),O=S(),k=b[t?.status??`disconnected`]??b.disconnected,A=E?.startedAt===void 0?NaN:Date.parse(E.startedAt),j=[{label:`Status`,value:k.text}];v!=null&&(j.push({label:`Host`,value:v.label}),v.protocolVersion!==null&&j.push({label:`Protocol`,value:v.protocolVersion}),v.connectedAt!==null&&j.push({label:`Connected`,value:`${_(v.connectedAt)} \u{00B7} ${d(O-v.connectedAt)}`}),j.push({label:`Client`,value:(0,y.jsx)(`code`,{children:v.clientId})},{label:`Server sequence`,value:String(v.serverSeq)},{label:`Following`,value:`${v.subscriptions} channels`})),t?.error!==null&&t?.error!==void 0&&j.push({label:`Last error`,value:t.error});let M=[];E!==null&&(Number.isNaN(A)||M.push({label:`Started`,value:`${_(A)} \u{00B7} up ${d(O-A)}`}),E.pid!==void 0&&M.push({label:`Process`,value:String(E.pid)}),E.url!==void 0&&M.push({label:`Address`,value:(0,y.jsx)(`code`,{children:E.url})}),E.automations!==void 0&&M.push({label:`Automations kept in`,value:E.automations}),(E.paths??[]).length>0&&M.push({label:`Sessions kept in`,value:(0,y.jsx)(`span`,{className:`web-lines`,children:E.paths.map(e=>(0,y.jsx)(`code`,{children:e},e))})}));let N=[{label:`Agents`,value:(0,y.jsx)(`button`,{type:`button`,className:`web-link`,onClick:()=>void e.commands.execute(`sidebar.activate`,{section:g}),children:C.length===0?`None`:C.map(e=>e.displayName).join(`, `)})},{label:`Default folder`,value:w==null?`None`:(0,y.jsx)(`code`,{children:u(w)})}];v?.activeSessions!==null&&v?.activeSessions!==void 0&&N.push({label:`Active sessions`,value:String(v.activeSessions)}),N.push({label:`Automations`,value:T==null?`Not offered`:[T.create===void 0?`Read only`:`Clients can create them`,T.schedules?.minIntervalMinutes===void 0?void 0:`at most every ${T.schedules.minIntervalMinutes} minutes`,T.runCancellation===void 0?void 0:`runs can be stopped`].filter(e=>e!==void 0).join(`, `)});let P=v?.terminals??[];return(0,y.jsxs)(`div`,{className:`web-page`,children:[(0,y.jsxs)(`div`,{className:`web-page__head`,children:[(0,y.jsxs)(`div`,{className:`web-chat__title`,children:[(0,y.jsx)(m,{variant:`h2`,text:`Host`}),(0,y.jsx)(f,{tone:k.tone,text:k.text})]}),(0,y.jsxs)(`div`,{className:`web-page__actions`,children:[t?.status===`connected`?null:(0,y.jsx)(i,{label:`Reconnect now`,variant:`primary`,onClick:l}),(0,y.jsx)(i,{label:`Settings`,onClick:()=>void e.commands.execute(`ahp.openSettings`)})]})]}),(0,y.jsx)(m,{variant:`h3`,text:`Connection`}),(0,y.jsx)(h,{items:j,columns:2}),E===null&&D===null?null:(0,y.jsx)(m,{variant:`h3`,text:`Daemon`}),D===null?null:(0,y.jsx)(p,{tone:`warning`,message:`The daemon's status is not readable: ${D}`}),M.length===0?null:(0,y.jsx)(h,{items:M,columns:2}),(0,y.jsx)(m,{variant:`h3`,text:`Offers`}),(0,y.jsx)(h,{items:N,columns:2}),(0,y.jsx)(m,{variant:`h3`,text:`Terminals`}),P.length===0?(0,y.jsx)(`p`,{className:`web-note`,children:`No terminals open.`}):(0,y.jsxs)(`table`,{className:`web-runs web-table`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{children:`Title`}),(0,y.jsx)(`th`,{children:`State`})]})}),(0,y.jsx)(`tbody`,{children:P.map(e=>{let t=e.lifecycle;return(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`td`,{children:e.title}),(0,y.jsx)(`td`,{children:t.status===`exited`?`Exited${t.exitCode===void 0?``:` (${t.exitCode})`}`:`Running`})]},e.resource)})})]})]})}export{C as default};
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{t as n}from"./useStore-BQkzWMs-.js";import{n as r}from"./ScenaProvider-6A3TJumQ.js";import{t as i}from"./Button-_R1oktDz.js";import{O as a,i as o,n as s,o as c,r as l}from"./data-CBWyZN_H.js";import{n as u,t as d}from"./words-T8-D0K4W.js";import{t as f}from"./Badge-BDEW5PFb.js";import{t as p}from"./Alert-CHZkhmDE.js";import{t as m}from"./Text-MPtQvYE-.js";import{t as h}from"./DetailList-Yalgw0YM.js";import{y as g}from"./index-DBKNxflN.js";import{a as _}from"./turn-BoF7W1h6.js";var v=t(),y=e(),b={connected:{tone:`success`,text:`Connected`},connecting:{tone:`info`,text:`Connecting`},reconnecting:{tone:`warning`,text:`Reconnecting`},disconnected:{tone:`default`,text:`Disconnected`},failed:{tone:`danger`,text:`Failed`}};function x(e){let[t,n]=(0,v.useState)(null),[r,i]=(0,v.useState)(null);return(0,v.useEffect)(()=>{n(null),i(null)},[e]),{status:t,error:r}}function S(){let[e,t]=(0,v.useState)(()=>Date.now());return(0,v.useEffect)(()=>{let e=window.setInterval(()=>t(Date.now()),1e3);return()=>window.clearInterval(e)},[]),e}function C(){let e=r(),t=n(l),v=n(c),C=n(`$/ahp/agents`)??[],w=n(o),T=n(s),{status:E,error:D}=x(t?.generation??0),O=S(),k=b[t?.status??`disconnected`]??b.disconnected,A=E?.startedAt===void 0?NaN:Date.parse(E.startedAt),j=[{label:`Status`,value:k.text}];v!=null&&(j.push({label:`Host`,value:v.label}),v.protocolVersion!==null&&j.push({label:`Protocol`,value:v.protocolVersion}),v.connectedAt!==null&&j.push({label:`Connected`,value:`${_(v.connectedAt)} \u{00B7} ${d(O-v.connectedAt)}`}),j.push({label:`Client`,value:(0,y.jsx)(`code`,{children:v.clientId})},{label:`Server sequence`,value:String(v.serverSeq)},{label:`Following`,value:`${v.subscriptions} channels`})),t?.error!==null&&t?.error!==void 0&&j.push({label:`Last error`,value:t.error});let M=[];E!==null&&(Number.isNaN(A)||M.push({label:`Started`,value:`${_(A)} \u{00B7} up ${d(O-A)}`}),E.pid!==void 0&&M.push({label:`Process`,value:String(E.pid)}),E.url!==void 0&&M.push({label:`Address`,value:(0,y.jsx)(`code`,{children:E.url})}),E.automations!==void 0&&M.push({label:`Automations kept in`,value:E.automations}),(E.paths??[]).length>0&&M.push({label:`Sessions kept in`,value:(0,y.jsx)(`span`,{className:`web-lines`,children:E.paths.map(e=>(0,y.jsx)(`code`,{children:e},e))})}));let N=[{label:`Agents`,value:(0,y.jsx)(`button`,{type:`button`,className:`web-link`,onClick:()=>void e.commands.execute(`sidebar.activate`,{section:g}),children:C.length===0?`None`:C.map(e=>e.displayName).join(`, `)})},{label:`Default folder`,value:w==null?`None`:(0,y.jsx)(`code`,{children:u(w)})}];v?.activeSessions!==null&&v?.activeSessions!==void 0&&N.push({label:`Active sessions`,value:String(v.activeSessions)}),N.push({label:`Automations`,value:T==null?`Not offered`:[T.create===void 0?`Read only`:`Clients can create them`,T.schedules?.minIntervalMinutes===void 0?void 0:`at most every ${T.schedules.minIntervalMinutes} minutes`,T.runCancellation===void 0?void 0:`runs can be stopped`].filter(e=>e!==void 0).join(`, `)});let P=v?.terminals??[];return(0,y.jsxs)(`div`,{className:`web-page`,children:[(0,y.jsxs)(`div`,{className:`web-page__head`,children:[(0,y.jsxs)(`div`,{className:`web-chat__title`,children:[(0,y.jsx)(m,{variant:`h2`,text:`Host`}),(0,y.jsx)(f,{tone:k.tone,text:k.text})]}),(0,y.jsxs)(`div`,{className:`web-page__actions`,children:[t?.status===`connected`?null:(0,y.jsx)(i,{label:`Reconnect now`,variant:`primary`,onClick:a}),(0,y.jsx)(i,{label:`Settings`,onClick:()=>void e.commands.execute(`ahp.openSettings`)})]})]}),(0,y.jsx)(m,{variant:`h3`,text:`Connection`}),(0,y.jsx)(h,{items:j,columns:2}),E===null&&D===null?null:(0,y.jsx)(m,{variant:`h3`,text:`Daemon`}),D===null?null:(0,y.jsx)(p,{tone:`warning`,message:`The daemon's status is not readable: ${D}`}),M.length===0?null:(0,y.jsx)(h,{items:M,columns:2}),(0,y.jsx)(m,{variant:`h3`,text:`Offers`}),(0,y.jsx)(h,{items:N,columns:2}),(0,y.jsx)(m,{variant:`h3`,text:`Terminals`}),P.length===0?(0,y.jsx)(`p`,{className:`web-note`,children:`No terminals open.`}):(0,y.jsxs)(`table`,{className:`web-runs web-table`,children:[(0,y.jsx)(`thead`,{children:(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`th`,{children:`Title`}),(0,y.jsx)(`th`,{children:`State`})]})}),(0,y.jsx)(`tbody`,{children:P.map(e=>{let t=e.lifecycle;return(0,y.jsxs)(`tr`,{children:[(0,y.jsx)(`td`,{children:e.title}),(0,y.jsx)(`td`,{children:t.status===`exited`?`Exited${t.exitCode===void 0?``:` (${t.exitCode})`}`:`Running`})]},e.resource)})})]})]})}export{C as default};
@@ -0,0 +1 @@
1
+ import{t as e}from"./jsx-runtime-BguD1OXD.js";import{t}from"./react-CybPckBe.js";import{S as n}from"./index-DBKNxflN.js";var r=t(),i=e();function a({display:e=`text`,locales:t,separator:a=`|`,className:s,style:c}){let{locale:l,locales:u,setLocale:d}=n(),f=t?t.map(e=>u.find(t=>t.locale===e)).filter(Boolean):u;return(0,i.jsx)(`div`,{className:[`oo-locale-toggle`,s].filter(Boolean).join(` `),style:c,role:`group`,children:f.map((t,n)=>(0,i.jsxs)(r.Fragment,{children:[n>0&&a!=null?(0,i.jsx)(`span`,{className:`oo-locale-toggle__sep`,"aria-hidden":`true`,children:a}):null,(0,i.jsx)(`button`,{type:`button`,className:`oo-locale-toggle__item`+(t.locale===l?` oo-locale-toggle__item--active`:``),"aria-pressed":t.locale===l,title:t.name??t.locale,onClick:()=>d(t.locale),children:o(t,e)})]},t.locale))})}function o(e,t){let n=(e.language??e.locale).toUpperCase();return t===`emoji`?e.emoji??n:t===`both`&&e.emoji?`${e.emoji} ${n}`:n}export{a as LocaleToggle};