ompchamber 0.4.0 → 0.6.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 (94) hide show
  1. package/README.md +56 -7
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/static/css/{index.5291f58223.css → index.51f68210a5.css} +1 -1
  4. package/dist/client/static/js/async/{3y.ededeebde8.js → 3y.4c2596f64c.js} +3 -3
  5. package/dist/client/static/js/async/73.308dff4da8.js +1 -0
  6. package/dist/client/static/js/async/{ty.3d93cf5f5f.js → 7g.a7814350c3.js} +1 -1
  7. package/dist/client/static/js/async/a.bce4542392.js +1 -0
  8. package/dist/client/static/js/async/dc.6dc4b0a04b.js +2 -0
  9. package/dist/client/static/js/async/g.8515cbc6f7.js +2 -0
  10. package/dist/client/static/js/async/hn.b645041e00.js +1 -0
  11. package/dist/client/static/js/async/{jg.69a4beade8.js → jg.d86ebd4013.js} +1 -1
  12. package/dist/client/static/js/async/l.12dd34e1be.js +1 -0
  13. package/dist/client/static/js/async/ls.9d9a01026c.js +104 -0
  14. package/dist/client/static/js/async/mw.ca1512563c.js +10 -0
  15. package/dist/client/static/js/async/nk.fc7e58325e.js +1 -0
  16. package/dist/client/static/js/async/{q.7fb4d2f374.js → q.542c184fec.js} +3 -3
  17. package/dist/client/static/js/async/t.cda4891526.js +1 -0
  18. package/dist/client/static/js/async/tr.e878658140.js +309 -0
  19. package/dist/client/static/js/async/uf.24ca3d49c3.js +2 -0
  20. package/dist/client/static/js/{index.bf1b1fe988.js → index.47d3b04d5f.js} +7 -7
  21. package/dist/client/static/js/{uy.5f791144ce.js → uy.2e8929ed0c.js} +2 -2
  22. package/package.json +13 -6
  23. package/src/cli/lib/args.js +7 -6
  24. package/src/cli/lib/commands/logs.js +76 -34
  25. package/src/cli/lib/commands/restart.js +30 -9
  26. package/src/cli/lib/commands/serve.js +19 -4
  27. package/src/cli/lib/commands/status.js +40 -18
  28. package/src/cli/lib/commands/stop.js +12 -7
  29. package/src/cli/lib/commands/update.js +2 -5
  30. package/src/cli/lib/paths.js +8 -28
  31. package/src/cli/lib/runtime.js +118 -108
  32. package/src/client/components/common/code-editor/index.tsx +5 -1
  33. package/src/client/components/common/code-surface/index.tsx +49 -1
  34. package/src/client/components/common/code-surface/measure.ts +99 -0
  35. package/src/client/components/layout/RightActivityBar.tsx +42 -69
  36. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +5 -6
  37. package/src/client/components/layout/desktop-layout/index.tsx +11 -9
  38. package/src/client/components/layout/desktop-layout/resizer/index.tsx +22 -29
  39. package/src/client/components/layout/desktop-layout/resizer/utils.test.ts +33 -0
  40. package/src/client/components/layout/desktop-layout/resizer/utils.ts +34 -0
  41. package/src/client/components/mobile/RightSidebar.tsx +42 -119
  42. package/src/client/components/mobile/mobile-main-view/Header.tsx +17 -1
  43. package/src/client/components/workspace/editor/index.tsx +4 -1
  44. package/src/client/components/workspace/file-explorer/TreeItem.tsx +8 -2
  45. package/src/client/components/workspace/file-explorer/index.tsx +6 -0
  46. package/src/client/data/models/catalog.ts +8 -0
  47. package/src/client/data/samples/dialogue-session.ts +1 -1
  48. package/src/client/data/samples/sample-tools/other.ts +1 -1
  49. package/src/client/hooks/chat/timeline/send.ts +1 -1
  50. package/src/client/hooks/editor/use-file-editor.test.ts +158 -0
  51. package/src/client/hooks/editor/use-file-editor.ts +35 -19
  52. package/src/server/index.ts +104 -1
  53. package/src/server/lib/lifecycle/identity.ts +108 -0
  54. package/src/server/lib/lifecycle/instance.ts +102 -0
  55. package/src/server/lib/lifecycle/occupant.ts +101 -0
  56. package/src/server/lib/lifecycle/paths.ts +50 -0
  57. package/src/server/lib/lifecycle/port-guard.ts +170 -0
  58. package/src/server/lib/lifecycle/probe.ts +121 -0
  59. package/src/server/lib/models/provider-registry.server.ts +44 -20
  60. package/src/server/lib/omp/core/cli.ts +3 -2
  61. package/src/server/lib/omp/core/startup.ts +64 -0
  62. package/src/server/lib/omp/rpc/process.ts +1 -1
  63. package/src/server/mock.server.ts +6 -12
  64. package/src/server/plugins/static.test.ts +63 -0
  65. package/src/server/plugins/static.ts +28 -4
  66. package/src/server/routes/chat/stream.ts +13 -30
  67. package/src/server/routes/health/probe.ts +8 -0
  68. package/src/server/routes/models/root.ts +5 -1
  69. package/src/shared/lib/chat/stream-service.ts +0 -76
  70. package/src/shared/lib/fs/paths.ts +19 -0
  71. package/src/shared/lib/markdown/mermaid.ts +8 -0
  72. package/src/shared/lib/workspace/panel-widths.test.ts +5 -5
  73. package/src/shared/lib/workspace/panel-widths.ts +23 -10
  74. package/src/shared/lib/workspace/right-panels.ts +10 -4
  75. package/dist/client/static/js/async/73.50280ce58d.js +0 -1
  76. package/dist/client/static/js/async/a.e05da304c8.js +0 -10
  77. package/dist/client/static/js/async/ar.1e14da5588.js +0 -1
  78. package/dist/client/static/js/async/art.62139ed479.js +0 -2
  79. package/dist/client/static/js/async/g.7a4bbd4798.js +0 -2
  80. package/dist/client/static/js/async/hn.7568bdb58b.js +0 -1
  81. package/dist/client/static/js/async/l.102a97fce6.js +0 -104
  82. package/dist/client/static/js/async/l6.c56640c205.js +0 -1
  83. package/dist/client/static/js/async/nk.6de011832e.js +0 -1
  84. package/dist/client/static/js/async/t.cb3fcf8615.js +0 -1
  85. package/dist/client/static/js/async/uf.46ad6209fa.js +0 -2
  86. package/dist/client/static/js/async/vn.e98e2f3b61.js +0 -309
  87. /package/dist/client/static/js/async/{3y.ededeebde8.js.LICENSE.txt → 3y.4c2596f64c.js.LICENSE.txt} +0 -0
  88. /package/dist/client/static/js/async/{a.e05da304c8.js.LICENSE.txt → dc.6dc4b0a04b.js.LICENSE.txt} +0 -0
  89. /package/dist/client/static/js/async/{g.7a4bbd4798.js.LICENSE.txt → g.8515cbc6f7.js.LICENSE.txt} +0 -0
  90. /package/dist/client/static/js/async/{art.62139ed479.js.LICENSE.txt → mw.ca1512563c.js.LICENSE.txt} +0 -0
  91. /package/dist/client/static/js/async/{q.7fb4d2f374.js.LICENSE.txt → q.542c184fec.js.LICENSE.txt} +0 -0
  92. /package/dist/client/static/js/async/{uf.46ad6209fa.js.LICENSE.txt → uf.24ca3d49c3.js.LICENSE.txt} +0 -0
  93. /package/dist/client/static/js/{index.bf1b1fe988.js.LICENSE.txt → index.47d3b04d5f.js.LICENSE.txt} +0 -0
  94. /package/dist/client/static/js/{uy.5f791144ce.js.LICENSE.txt → uy.2e8929ed0c.js.LICENSE.txt} +0 -0
@@ -1,13 +1,13 @@
1
- /*! LICENSE: index.bf1b1fe988.js.LICENSE.txt */
2
- (()=>{"use strict";var e,t,n,r,i,s={rK(e,t,n){n.d(t,{T:()=>R});var r=n("j"),i=n("H"),s=n("XT7"),a=n("HA"),l=n("rt"),o=n("DU"),c=n("L");let d=["math","annotation","annotation-xml","semantics","mrow","mi","mn","mo","mspace","ms","mtext","mroot","mfrac","msqrt","mstyle","merror","mpadded","mphantom","mtable","mtr","mtd","mlabeledtr","munder","mover","munderover","msup","msub","msubsup","mtext","mtd","menclose"],u=["svg","path","polyline","rect","circle","line"],p=["viewBox","d","points","x","y","x1","y1","x2","y2","width","height","rx","ry","cx","cy","r","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","xmlns","aria-hidden","aria-label"],m=["svg","g","line","path","rect","circle","ellipse","polygon","polyline","text","tspan","title","desc","marker","defs","style","use","symbol","foreignObject","html","head","body","div","span","p","br","img"],h=["id","class","style","transform","viewBox","width","height","xmlns","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","d","points","fill","stroke","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-opacity","fill-opacity","opacity","font-family","font-size","font-weight","font-style","text-anchor","dominant-baseline","alignment-baseline","text-decoration","direction","marker-end","marker-start","marker-mid","markerWidth","markerHeight","refX","refY","orient","markerUnits","preserveAspectRatio","version","dx","dy","dy1","dy2","rowspan","colspan","start","aria-roledescription","aria-describedby","role","aria-hidden","aria-label","data-mermaid-theme","overflow","visibility","rel","src","alt"],f=["href","xlink:href"],x=null,g="math-pending";function b(){return x||(x=n.e(121).then(n.bind(n,"Bi")).then(e=>e.default).catch(e=>(console.error("[katex] load failed",e),null))),x}async function v(e){let t=[...e.querySelectorAll(`.${g}`)];if(0===t.length)return{rendered:0,failed:0};let n=await b();if(!n)return{rendered:0,failed:t.length};let r=0;for(let e of t)e.isConnected&&(!function(e,t){let n=e.dataset.math??"",r="1"===e.dataset.mathDisplay;try{e.innerHTML=function(e){if(!e||"u"<typeof window||!window.document)return e;let t=`<div data-katex-wrap>${e}</div>`;try{let e=c.A.sanitize(t,{USE_PROFILES:{html:!0,mathMl:!0},ADD_ATTR:["class","aria-hidden","encoding","style","data-katex-wrap"]}),n=document.createElement("div");return n.innerHTML=e,n.querySelector("[data-katex-wrap]")?.innerHTML??e}catch{return e}}(t.renderToString(n,{throwOnError:!1,displayMode:r})),e.classList.remove(g),e.removeAttribute("data-math"),e.removeAttribute("data-math-display")}catch{e.textContent=n,e.classList.remove(g)}}(e,n),r+=1);return{rendered:r,failed:0}}function k(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function y(e,t){let n=k(e),r=`<span class="${g}" data-math="${n}"${t?' data-math-display="1"':""}></span>`;return t?`<p>${r}</p>`:r}let N=new s.Dz({gfm:!0,breaks:!0});function w(e,t){let n=e.replace(/"/g,"&quot;");return`<div class="code-block">
1
+ /*! LICENSE: index.47d3b04d5f.js.LICENSE.txt */
2
+ (()=>{"use strict";var e,t,n,r,i,s={rK(e,t,n){n.d(t,{T:()=>R});var r=n("j"),i=n("H"),s=n("XT7"),a=n("HA"),l=n("rt"),o=n("DU"),c=n("L");let d=["math","annotation","annotation-xml","semantics","mrow","mi","mn","mo","mspace","ms","mtext","mroot","mfrac","msqrt","mstyle","merror","mpadded","mphantom","mtable","mtr","mtd","mlabeledtr","munder","mover","munderover","msup","msub","msubsup","mtext","mtd","menclose"],u=["svg","path","polyline","rect","circle","line"],p=["viewBox","d","points","x","y","x1","y1","x2","y2","width","height","rx","ry","cx","cy","r","fill","stroke","stroke-width","stroke-linecap","stroke-linejoin","xmlns","aria-hidden","aria-label"],m=["svg","g","line","path","rect","circle","ellipse","polygon","polyline","text","tspan","title","desc","marker","defs","style","use","symbol","foreignObject","html","head","body","div","span","p","br","img"],h=["id","class","style","transform","viewBox","width","height","xmlns","x","y","x1","y1","x2","y2","cx","cy","r","rx","ry","d","points","fill","stroke","stroke-width","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-opacity","fill-opacity","opacity","font-family","font-size","font-weight","font-style","text-anchor","dominant-baseline","alignment-baseline","text-decoration","direction","marker-end","marker-start","marker-mid","markerWidth","markerHeight","refX","refY","orient","markerUnits","preserveAspectRatio","version","dx","dy","dy1","dy2","rowspan","colspan","start","aria-roledescription","aria-describedby","role","aria-hidden","aria-label","data-mermaid-theme","overflow","visibility","rel","src","alt"],f=["href","xlink:href"],x=null,g="math-pending";function b(){return x||(x=n.e(121).then(n.bind(n,"Bi")).then(e=>e.default).catch(e=>(console.error("[katex] load failed",e),null))),x}async function v(e){let t=[...e.querySelectorAll(`.${g}`)];if(0===t.length)return{rendered:0,failed:0};let n=await b();if(!n)return{rendered:0,failed:t.length};let r=0;for(let e of t)e.isConnected&&(!function(e,t){let n=e.dataset.math??"",r="1"===e.dataset.mathDisplay;try{e.innerHTML=function(e){if(!e||"u"<typeof window||!window.document)return e;let t=`<div data-katex-wrap>${e}</div>`;try{let e=c.A.sanitize(t,{USE_PROFILES:{html:!0,mathMl:!0},ADD_ATTR:["class","aria-hidden","encoding","style","data-katex-wrap"]}),n=document.createElement("div");return n.innerHTML=e,n.querySelector("[data-katex-wrap]")?.innerHTML??e}catch{return e}}(t.renderToString(n,{throwOnError:!1,displayMode:r})),e.classList.remove(g),e.removeAttribute("data-math"),e.removeAttribute("data-math-display")}catch{e.textContent=n,e.classList.remove(g)}}(e,n),r+=1);return{rendered:r,failed:0}}function k(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;")}function y(e,t){let n=k(e),r=`<span class="${g}" data-math="${n}"${t?' data-math-display="1"':""}></span>`;return t?`<p>${r}</p>`:r}let w=new s.Dz({gfm:!0,breaks:!0});function N(e,t){let n=e.replace(/"/g,"&quot;");return`<div class="code-block">
3
3
  <button type="button" class="code-copy-float" data-copy="${n}" aria-label="Copy code">
4
4
  <svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>
5
5
  </button>
6
6
  ${t}
7
7
  </div>
8
- `}N.use((0,a.A)()),N.use({renderer:{code:e=>e.raw&&/^```/.test(e.raw)||(e.text??"").includes("\n")?function(e){let t=e.lang?.trim()||"text",n=e.text??"";if("mermaid"===t){let e,t;return e=`<pre><code class="language-mermaid">${k(n)}</code></pre>`,t=w(n,e),`<div class="mermaid-block" data-mermaid="${encodeURIComponent(n)}" data-mermaid-state="pending">${t}</div>`}let r="text"===t?k(n):(0,o.wY)(n,t);return w(n,`<pre><code class="language-${t}">${r}</code></pre>`)}(e):`<code class="inline-code">${k(e.text??"")}</code>`,codespan:e=>`<code class="inline-code">${k(e.text??"")}</code>`}}),N.use({extensions:[{name:"inlineMath",level:"inline",start:e=>e.match(/\\\(/)?.index,tokenizer(e){let t=/^\\\(([\s\S]+?)\\\)/.exec(e);return t?{type:"inlineMath",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!1)},{name:"blockMath",level:"block",start:e=>e.match(/^\\\[/)?.index,tokenizer(e){let t=/^\\\[([\s\S]+?)\\\]/.exec(e);return t?{type:"blockMath",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!0)},{name:"blockMathDisplay",level:"block",start:e=>e.match(/^\$\$/)?.index,tokenizer(e){let t=/^\$\$([\s\S]+?)\$\$(?:\n|$)/.exec(e);return t?{type:"blockMathDisplay",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!0)},{name:"inlineMathDollar",level:"inline",start(e){let t=/(^|[^\w$])\$(?!\$)(?!\s)/.exec(e);return t?t.index+(t[1]?.length??0):void 0},tokenizer(e){let t=/^\$(?!\$)(?!\s)((?:\\\$|[^$])*?)(?<!\s)\$(?!\$)(?!\d)/.exec(e);return t?{type:"inlineMathDollar",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!1)}]});let Y=/\[([^\]]*)\]\(streamdown:incomplete-link\)/g,D=new Map,F=null,A=null;function C(){let e=document.documentElement.dataset.theme||document.documentElement.getAttribute("data-theme");return"one-dark-pro-soft"===e||"noir"===e||"dark"===e?"dark":"default"}function S(e,t){return`${e}\0${t}`}async function T(e){return F&&A===e||(A=e,F=Promise.all([n.e("a3"),n.e("3y")]).then(n.bind(n,"Fl")).then(t=>(t.default.initialize({startOnLoad:!1,securityLevel:"strict",theme:e,layout:"dagre",flowchart:{useMaxWidth:!1,wrappingWidth:1e5},sequence:{useMaxWidth:!1}}),t.default)).catch(e=>{throw F=null,e})),F}function z(e,t,n){let r=(e.dataset.mermaid??"").replace(/"/g,"&quot;");e.innerHTML=`<button type="button" class="code-copy-float" data-copy="${r}" aria-label="Copy diagram source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg></button>`+t,e.dataset.mermaidState="done",e.dataset.mermaidTheme=n;let i=e.querySelector(":scope > svg"),s=Number(i?.getAttribute("width"));i&&Number.isFinite(s)&&s>0&&e.style.setProperty("--mermaid-diagram-max",`${Math.round(.8*s)}px`)}let $=0;async function j(e,t){let n=e.dataset.mermaid;if(null==n)return!1;let r=C(),i=decodeURIComponent(n),s=D.get(S(r,i))??null;if(s)return z(e,s,r),!0;if(t)return!0;e.dataset.mermaidState="rendering";try{let t=await T(r),{svg:n}=await t.render(`mermaid-svg-${Date.now()}-${$++}`,i);if(!e.isConnected)return!1;let s=function(e){if(!e||"u"<typeof window||!window.document)return e;let t=/href/.test(e);try{return c.A.sanitize(e,{USE_PROFILES:{html:!0,svg:!0,svgFilters:!0},ADD_TAGS:m,ADD_ATTR:[...h,...t?f:[]],HTML_INTEGRATION_POINTS:{"annotation-xml":!0,foreignobject:!0}})}catch{return e}}(n);if(D.size>=60){let e=D.keys().next().value;void 0!==e&&D.delete(e)}return D.set(S(r,i),s),z(e,s,r),!0}catch{return e.isConnected&&(e.dataset.mermaidState="error"),!1}}async function L(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=C(),r=Array.from(e.querySelectorAll(".mermaid-block")),i=await Promise.all(r.map(async e=>{let r=e.dataset.mermaidState,i=e.dataset.mermaidTheme===n;return"done"===r&&!!i&&!t.force||"rendering"!==r&&j(e,!0===t.cachedOnly)}));return{rendered:i.filter(Boolean).length,failed:i.filter(e=>!e).length}}var M=n("pH"),P=n("Po");let E="u"<typeof window?i.vJ:i.Nf;function R(e){let{content:t,className:n=""}=e,s=(0,i.li)(null),a=(0,P.w)(),o=(0,i.Kr)(()=>{let e,n;if(!t)return"";let r=(e=t.split("`").map((e,t)=>t%2==1?e:e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")).join("`"),n=(0,l.Ay)(e,{katex:!0,inlineKatex:!0}).replace(Y,(e,t)=>`<span class="md-incomplete-link">${t}</span>`),N.parse(n).trim());if(r.includes(g)&&b(),!r||"u"<typeof window||!window.document)return r;let i=/<svg[^>]*>/.test(r),s=r.includes("math-pending"),a=/class="[^"]*katex/.test(r)||i||s?{USE_PROFILES:{html:!0,mathMl:!0},ADD_TAGS:[...d,...i?u:[]],ADD_ATTR:["aria-hidden","aria-label","encoding","nonce","data-math","data-math-display",...i?p:[]]}:{USE_PROFILES:{html:!0}};try{return c.A.sanitize(r,a)}catch{return r}},[t,a]),m=o.includes("mermaid-block"),h=o.includes(g);(0,i.vJ)(()=>{if(!h||"u"<typeof window)return;let e=s.current;if(!e)return;let t=!1;(async()=>{if(e.isConnected&&(await v(e),t))return})();let n=new MutationObserver(()=>{let e=s.current;e?.isConnected&&v(e)});return n.observe(e,{childList:!0}),()=>{t=!0,n.disconnect()}},[h,o]),E(()=>{let e;if(!m||"u"<typeof window)return;let t=s.current;if(!t)return;let n=()=>{let e=s.current;e&&e.isConnected&&L(e)};n();let r=new MutationObserver(()=>{let t=s.current;t?.isConnected&&L(t,{cachedOnly:!0}),window.clearTimeout(e),e=window.setTimeout(n,120)});r.observe(t,{childList:!0});let i=()=>n();return window.addEventListener("omp:theme-changed",i),()=>{window.clearTimeout(e),r.disconnect(),window.removeEventListener("omp:theme-changed",i)}},[m,o]);let f=(0,i.hb)(e=>{let t=e.target.closest("button.code-copy-float");if(!t)return;let n=t.dataset.copy??"";n&&(e.preventDefault(),e.stopPropagation(),(0,M.l)(n).then(e=>{e&&(t.setAttribute("data-copied","true"),t.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>',setTimeout(()=>{t.removeAttribute("data-copied"),t.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>'},2e3))}))},[]);return t?(0,r.Y)("div",{ref:s,className:`prose-content text-[13px] text-ink leading-relaxed select-text ${n}`,onClick:f,dangerouslySetInnerHTML:{__html:o}}):null}},R2(e,t,n){var r=n("j");function i(e){let{status:t}=e;if(t?.transport!=="websocket")return null;let n=!!t.connected,i=n?"WebSocket connected":"WebSocket disconnected";return(0,r.Y)("span",{role:"status","aria-label":i,title:i,className:"flex items-center flex-shrink-0 select-none",children:(0,r.Y)("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${n?"bg-success":"bg-error"}`})})}n.d(t,{c:()=>i})},Uo(e,t,n){var r=n("j"),i=n("m"),s=n("p"),a=n("F"),l=n("V");function o(e){let{status:t,live:n,size:o=12}=e,c={size:o,strokeWidth:2,"aria-hidden":!0};if("completed"===t)return(0,r.Y)(i.A,{...c,className:"text-success"});if("failed"===t)return(0,r.Y)(s.A,{...c,className:"text-error"});if("aborted"===t)return(0,r.Y)(a.A,{...c,className:"text-ink/40"});if(!1===n)return(0,r.Y)(l.A,{...c,className:"text-ink/30"});let d=Math.max(5,Math.round(o/2));return(0,r.Y)("span",{"aria-hidden":!0,className:"inline-block shrink-0 animate-pulse rounded-full bg-success",style:{width:d,height:d}})}n.d(t,{l:()=>o})},wu(e,t,n){n.d(t,{y:()=>d});var r=n("j"),i=n("H"),s=n("G"),a=n("p"),l=n("m"),o=n("S");function c(e){let{toast:t,onDismiss:n,duration:c}=e,[d,u]=(0,i.J0)(!1),p=c??t.duration??4e3,m=(0,i.li)(null);return(0,i.vJ)(()=>{let e=requestAnimationFrame(()=>u(!0)),r=setTimeout(()=>{u(!1),m.current=setTimeout(()=>n(t.id),200)},p);return()=>{cancelAnimationFrame(e),clearTimeout(r),m.current&&clearTimeout(m.current)}},[t.id,p,n]),(0,s.d5)((0,r.FD)("div",{className:`fixed bottom-4 right-4 z-[200] flex items-center space-x-2 bg-paper border shadow-2xl rounded-lg px-4 py-3 text-xs font-sans transition-all duration-200 ${"error"===t.type?"border-error/40":"border-ink/15"} ${d?"opacity-100 translate-y-0":"opacity-0 translate-y-2"}`,role:"status",children:["error"===t.type?(0,r.Y)(a.A,{size:15,className:"text-error flex-shrink-0"}):(0,r.Y)(l.A,{size:15,className:"text-success flex-shrink-0"}),(0,r.Y)("span",{className:"text-ink max-w-[320px]",children:t.message}),t.action&&(0,r.Y)("button",{type:"button",onClick:()=>{t.action?.onClick(),u(!1),m.current=setTimeout(()=>n(t.id),200)},className:"flex-shrink-0 px-2 py-0.5 rounded bg-ink text-paper font-semibold hover:opacity-80 transition-opacity",children:t.action.label}),(0,r.Y)("button",{type:"button",onClick:()=>{u(!1),m.current=setTimeout(()=>n(t.id),200)},className:"text-ink/40 hover:text-ink transition-colors flex-shrink-0",title:"Dismiss",children:(0,r.Y)(o.A,{size:13})})]}),document.body)}function d(e){let{toasts:t,onDismiss:n}=e;return(0,r.Y)(r.FK,{children:t.map(e=>(0,r.Y)(c,{toast:e,onDismiss:n},e.id))})}},nG(e,t,n){var r=n("j"),i=n("G");let s=(0,i.RZ)(()=>Promise.all([n.e("uf"),n.e("art")]).then(n.bind(n,"Ek")).then(e=>({default:e.FileExplorer}))),a=(0,i.RZ)(()=>Promise.all([n.e("uf"),n.e("1k")]).then(n.bind(n,"X8")).then(e=>({default:e.SearchPanel}))),l=(0,i.RZ)(()=>Promise.all([n.e("uf"),n.e("m")]).then(n.bind(n,"ABt")).then(e=>({default:e.GitPanel}))),o=(0,i.RZ)(()=>n.e("fw").then(n.bind(n,"RF")).then(e=>({default:e.TerminalPanel}))),c=(0,i.RZ)(()=>n.e(51).then(n.bind(n,"zO")).then(e=>({default:e.ContextPanel}))),d=(0,i.RZ)(()=>Promise.all([n.e("3j"),n.e("s")]).then(n.bind(n,"a6")).then(e=>({default:e.BrowserPanel}))),u=(0,i.RZ)(()=>Promise.all([n.e("3j"),n.e("rd")]).then(n.bind(n,"NU")).then(e=>({default:e.UserBrowserPanel}))),p=(0,i.RZ)(()=>Promise.all([n.e("kc"),n.e("vy")]).then(n.bind(n,"Rc")).then(e=>({default:e.UsagePanel}))),m=new WeakMap;function h(e,t){let n=m.get(e);if(n||(n={},m.set(e,n)),!n[t]){let e="files"===t?s:"search"===t?a:"git"===t?l:"terminal"===t?o:"context"===t?c:"user-browser"===t?u:"browser"===t?d:p,i=t=>{let{className:n,...i}=t;return(0,r.Y)("div",{className:`w-full h-full ${"string"==typeof n?n:""}`,children:(0,r.Y)(e,{...i,className:"w-full h-full"})})};i.displayName=`CachedView(${t})`,n[t]=i}return n[t]}n.d(t,{SU:()=>h},{Bz:o,M:u,N1:a,WE:p,XL:d,gI:s,nR:l,ov:c})},E(e,t,n){n.d(t,{i:()=>l});var r=n("j"),i=n("z");let s=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"],a={"A-Z":"A-Z","Z-A":"Z-A",LATEST_SESSION:"Latest Session",LATEST_ADDED:"Latest Added"};function l(e){let{variant:t,sortOption:n,onSortChange:l}=e;return"mobile"===t?(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-2 py-1 text-[10px] uppercase font-bold text-ink/40 font-mono",children:"Sort Workspaces"}),s.map(e=>(0,r.FD)("button",{type:"button",onClick:()=>l(e),className:`w-full text-left px-2.5 py-1.5 rounded-lg flex items-center justify-between transition-colors ${n===e?"bg-ink/10 font-semibold text-ink":"hover:bg-ink/5 text-ink/80"}`,children:[(0,r.Y)("span",{children:e.replace("_"," ")}),n===e&&(0,r.Y)(i.A,{size:13,className:"text-ink"})]},e))]}):(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-3 py-1 text-[10px] uppercase font-bold text-ink/40 tracking-wider",children:"Sort Workspaces"}),s.map(e=>(0,r.FD)("div",{className:`px-3 py-1.5 text-xs cursor-pointer flex items-center justify-between ${n===e?"bg-ink/5 text-ink font-medium":"text-ink/70 hover:bg-ink/5 hover:text-ink"}`,onClick:()=>l(e),children:[(0,r.Y)("span",{children:a[e]}),n===e&&(0,r.Y)("div",{className:"w-1.5 h-1.5 rounded-full bg-ink"})]},e))]})}},C4(e,t,n){var r=n("j"),i=n("mO"),s=n("Wi"),a=n("a");function l(e){let{variant:t,isPinned:n=!1,confirmDelete:l,onPin:o,onDelete:c,onRequestDelete:d,onCancelDelete:u}=e;return"mobile"===t?l?(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-3 py-2 text-ink/80 font-medium",children:"Delete workspace?"}),(0,r.FD)("button",{type:"button",onClick:c,className:"w-full text-left px-3 py-2 hover:bg-error/10 text-error flex items-center space-x-2",children:[(0,r.Y)(i.A,{size:13}),(0,r.Y)("span",{children:"Yes, delete"})]}),(0,r.Y)("button",{type:"button",onClick:u,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/70",children:"Cancel"})]}):(0,r.FD)(r.FK,{children:[(0,r.FD)("button",{type:"button",onClick:o,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[n?(0,r.Y)(s.A,{size:13}):(0,r.Y)(a.A,{size:13}),(0,r.Y)("span",{children:n?"Unpin Workspace":"Pin Workspace"})]}),(0,r.FD)("button",{type:"button",onClick:d,className:"w-full text-left px-3 py-2 hover:bg-error/10 text-error flex items-center space-x-2",children:[(0,r.Y)(i.A,{size:13}),(0,r.Y)("span",{children:"Delete Workspace"})]})]}):l?(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-3 py-1.5 text-xs text-ink/80 font-medium",children:"Delete workspace?"}),(0,r.FD)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-error",onClick:c,children:[(0,r.Y)(i.A,{size:12}),(0,r.Y)("span",{children:"Yes, delete"})]}),(0,r.Y)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/70",onClick:u,children:(0,r.Y)("span",{children:"Cancel"})})]}):(0,r.FD)(r.FK,{children:[(0,r.FD)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",onClick:o,children:[n?(0,r.Y)(s.A,{size:12}):(0,r.Y)(a.A,{size:12}),(0,r.Y)("span",{children:n?"Unpin Workspace":"Pin Workspace"})]}),(0,r.FD)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-error",onClick:d,children:[(0,r.Y)(i.A,{size:12}),(0,r.Y)("span",{children:"Delete Workspace"})]})]})}n.d(t,{t:()=>l})},g(e,t,n){n.d(t,{VT:()=>T,xV:()=>z,Lo:()=>$,bB:()=>f.b});var r=n("j"),i=n("H"),s=n("S"),a=n("w"),l=n("Y"),o=n("o"),c=n("r"),d=n("l"),u=n("C"),p=n("W"),m=n("N"),h=n("YL"),f=n("u"),x=n("Nf"),g=n("t"),b=n("n"),v=n("g6");async function k(e){let t=e?`?path=${encodeURIComponent(e)}`:"",n=await fetch(`/api/fs/browse${t}`),r=await n.json();if(!n.ok||r.error)throw Error(r.error||`HTTP ${n.status}`);return r}function y(e){let{initialPath:t,onSelect:n,onClose:o}=e,[c,d]=(0,i.J0)(t??""),[u,p]=(0,i.J0)(""),[m,h]=(0,i.J0)([]),[f,y]=(0,i.J0)(null),[N,w]=(0,i.J0)(!0),[Y,D]=(0,i.J0)(null),[F,A]=(0,i.J0)(null),C=(0,i.li)(null),S=(0,i.hb)(async e=>{w(!0),D(null);try{let t=await k(e);d(t.path??e??""),y(t.parentPath??null),p(t.path??e??""),h(t.directories??[])}catch(e){D(e instanceof Error?e.message:String(e))}finally{w(!1)}},[]);(0,i.vJ)(()=>{S(t)},[t,S]);let T=e=>{S(e.path)};return(0,r.Y)("div",{className:"fixed inset-0 bg-ink/30 z-[60] flex items-center justify-center p-4",onClick:o,children:(0,r.FD)("div",{className:"bg-paper border border-ink/15 rounded-lg shadow-2xl w-full max-w-lg flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ink/10",children:[(0,r.FD)("h3",{className:"font-semibold text-sm flex items-center space-x-2",children:[(0,r.Y)(l.A,{size:15,className:"text-ink/70"}),(0,r.Y)("span",{children:"Choose Project Folder"})]}),(0,r.Y)("button",{type:"button",onClick:o,className:"p-1 rounded hover:bg-ink/10 text-ink/60 hover:text-ink transition-colors","aria-label":"Close picker",children:(0,r.Y)(s.A,{size:15})})]}),(0,r.FD)("div",{className:"px-4 py-2 border-b border-ink/10 bg-canvas/50",children:[(0,r.FD)("form",{onSubmit:e=>{e.preventDefault();let t=u.trim();t&&S(t)},className:"flex items-center space-x-2",children:[(0,r.Y)(a.A,{size:14,className:"text-ink/40 flex-shrink-0"}),(0,r.Y)("input",{ref:C,type:"text",value:u,onChange:e=>p(e.currentTarget.value),placeholder:"~ or /absolute/path",className:"flex-1 bg-transparent outline-none text-xs font-mono text-ink placeholder-ink/30 py-1",spellcheck:!1}),(0,r.Y)("button",{type:"submit",className:"px-2 py-1 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 transition-colors",children:"Go"})]}),(0,r.FD)("div",{className:"flex items-center space-x-1 mt-1 text-[11px] text-ink/40 truncate",children:[(0,r.FD)("button",{type:"button",onClick:()=>void S(),className:"hover:text-ink transition-colors flex items-center",children:[(0,r.Y)(a.A,{size:11,className:"mr-0.5"})," home"]}),c.split("/").filter(Boolean).map((e,t,n)=>{let i="/"+c.split("/").filter(Boolean).slice(0,t+1).join("/"),s=t===n.length-1;return(0,r.FD)("span",{className:"flex items-center space-x-1 min-w-0",children:[(0,r.Y)(x.A,{size:10,className:"text-ink/20 flex-shrink-0"}),s?(0,r.Y)("span",{className:"text-ink/70 truncate",children:e}):(0,r.Y)("button",{type:"button",onClick:()=>void S(i),className:"hover:text-ink transition-colors truncate max-w-[120px]",children:e})]},i)})]})]}),(0,r.Y)("div",{className:"flex-1 min-h-[240px] max-h-[360px] scrollbar-overlay-container scrollbar-overlay-static p-2",children:N?(0,r.Y)("div",{className:"flex items-center justify-center h-40 text-ink/40",children:(0,r.Y)(g.A,{size:18,className:"animate-spin"})}):Y?(0,r.FD)("div",{className:"flex flex-col items-center justify-center h-40 text-xs text-red-600 space-y-2 px-4",children:[(0,r.Y)("span",{children:Y}),(0,r.FD)("button",{type:"button",onClick:()=>void S(c||void 0),className:"px-2 py-1 rounded bg-ink/5 border border-ink/10 text-ink/70 hover:bg-ink/10 flex items-center space-x-1",children:[(0,r.Y)(b.A,{size:11})," Retry"]})]}):0===m.length?(0,r.Y)("div",{className:"text-center py-16 text-xs text-ink/40",children:"No subfolders"}):m.map(e=>(0,r.FD)("div",{className:`group flex items-center justify-between px-2.5 py-2 rounded cursor-pointer transition-colors ${F===e.path?"bg-ink/10":"hover:bg-ink/5"}`,onDblClick:()=>T(e),children:[(0,r.FD)("button",{type:"button",onClick:()=>T(e),className:"flex items-center space-x-2 min-w-0 flex-1 text-left",children:[(0,r.Y)(v.A,{size:15,className:"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{className:"text-xs truncate text-ink/85",children:e.name})]}),(0,r.Y)("button",{type:"button",onClick:()=>{A(e.path),n(e.path)},className:"hidden group-hover:flex px-2 py-0.5 rounded bg-ink text-canvas text-[10px] font-semibold hover:bg-ink/80 transition-colors flex-shrink-0",children:"Choose"})]},e.path))}),(0,r.FD)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-ink/10",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0",children:[(0,r.FD)("button",{type:"button",onClick:()=>{f&&S(f)},disabled:!f,className:"px-2.5 py-1.5 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 disabled:opacity-40 transition-colors flex items-center space-x-1",children:[(0,r.Y)("span",{children:"↑"}),(0,r.Y)("span",{children:"Up"})]}),(0,r.Y)("button",{type:"button",onClick:()=>void S(),className:"px-2.5 py-1.5 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 transition-colors",children:"Home"})]}),(0,r.FD)("div",{className:"flex items-center space-x-2",children:[(0,r.Y)("button",{type:"button",onClick:o,className:"px-3 py-1.5 text-xs font-medium text-ink/60 hover:text-ink transition-colors",children:"Cancel"}),(0,r.Y)("button",{type:"button",onClick:()=>{c&&(A(c),n(c))},disabled:!c,className:"px-3.5 py-1.5 text-xs font-medium bg-ink text-canvas rounded hover:bg-ink/90 disabled:opacity-50 transition-colors",children:"Use This Folder"})]})]})]})})}var N=n("P");function w(){return(0,r.FD)("div",{className:"flex flex-col items-center gap-3 mt-6 pt-1",children:[(0,r.FD)("div",{className:"flex items-center justify-center gap-6",children:[(0,r.FD)("a",{href:"https://github.com",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 text-xs font-medium text-ink/75 hover:text-ink transition-colors",children:[(0,r.Y)("svg",{className:"w-4 h-4 fill-current",viewBox:"0 0 24 24",children:(0,r.Y)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.53 1.032 1.53 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})}),(0,r.Y)("span",{children:"GitHub"})]}),(0,r.FD)("a",{href:"https://discord.com",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 text-xs font-medium text-ink/75 hover:text-ink transition-colors",children:[(0,r.Y)("svg",{className:"w-4 h-4 fill-current",viewBox:"0 0 24 24",children:(0,r.Y)("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994.021-.041.001-.09-.041-.106a13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.929 1.793 8.18 1.793 12.061 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.894.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.028zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})}),(0,r.Y)("span",{children:"Discord"})]})]}),(0,r.FD)("a",{href:"https://x.com",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 text-xs font-medium text-ink/75 hover:text-ink transition-colors",children:[(0,r.Y)("svg",{className:"w-3.5 h-3.5 fill-current",viewBox:"0 0 24 24",children:(0,r.Y)("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),(0,r.Y)("span",{children:"@ompchamber"})]})]})}var Y=n("tC"),D=n("p"),F=n("z");let A="inline-flex items-center gap-1.5 rounded-md border border-ink/20 px-2.5 py-1.5 text-[11px] font-medium text-ink transition-colors hover:border-ink/40 disabled:cursor-not-allowed disabled:opacity-50";function C(e){let{target:t,info:n,applying:i,disabled:s,onApply:a}=e,l=`v${n.current??"…"} → v${n.latest??"…"}`;return(0,r.FD)("div",{className:"flex items-center justify-between gap-3 border-t border-ink/10 py-2.5 first:border-t-0",children:[(0,r.FD)("div",{className:"min-w-0",children:[(0,r.Y)("p",{className:"text-xs font-medium text-ink",children:"ompchamber"===t?"OMPChamber":"Oh-My-Pi"}),(0,r.Y)("p",{className:"font-mono text-[10px] text-ink/60",children:n.installed?l:"not detected"})]}),n.installed?(0,r.FD)("button",{type:"button",onClick:()=>a(t),disabled:s,className:A,children:[i?(0,r.Y)(g.A,{size:12,className:"animate-spin motion-reduce:animate-none"}):(0,r.Y)(Y.A,{size:12}),(0,r.Y)("span",{children:"Update"})]}):(0,r.Y)("span",{className:"shrink-0 text-[10px] text-ink/40",children:"not detected"})]})}function S(e){let{updates:t,onToast:n}=e,i=t.info?[{target:"ompchamber",info:t.info.ompchamber},{target:"omp",info:t.info.omp}].filter(e=>{let{info:t}=e;return t.updateAvailable&&null!==t.latest}):[],s=async e=>{let r=await t.apply(e);if(n){if(!r)return void n("The update request could not be completed.","error");if("ompchamber"===e)return void n(r.message,r.success?"success":"error");r.success?n(`${r.message} A restart may be needed.`,"success"):n(r.message,"error")}},a=!!(t.info&&!t.checking&&!t.error);return(0,r.FD)("section",{className:"mt-5 border-y border-ink/10 py-3 text-left","aria-labelledby":"updates-heading",children:[(0,r.FD)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.Y)("h3",{id:"updates-heading",className:"text-xs font-semibold text-ink",children:"Updates"}),t.info&&(0,r.Y)("span",{className:"font-mono text-[9px] text-ink/40",children:"checked"})]}),(0,r.FD)("div",{className:"mt-2.5",children:[t.checking&&(0,r.FD)("button",{type:"button",disabled:!0,className:`${A} w-full justify-center`,children:[(0,r.Y)(g.A,{size:13,className:"animate-spin motion-reduce:animate-none"}),(0,r.Y)("span",{children:"Checking…"})]}),t.error&&!t.checking&&(0,r.FD)("div",{className:"flex items-start gap-2",children:[(0,r.Y)(D.A,{size:14,className:"mt-0.5 shrink-0 text-error"}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.Y)("p",{className:"text-[11px] leading-4 text-error",children:t.error}),(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),className:`${A} mt-2`,children:[(0,r.Y)(b.A,{size:12}),(0,r.Y)("span",{children:"Retry"})]})]})]}),!t.info&&!t.checking&&!t.error&&(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),className:`${A} w-full justify-center`,children:[(0,r.Y)(b.A,{size:13}),(0,r.Y)("span",{children:"Check for updates"})]}),a&&0===i.length&&(0,r.FD)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.FD)("p",{className:"flex items-center gap-1.5 text-[11px] text-success",children:[(0,r.Y)(F.A,{size:13}),(0,r.Y)("span",{children:"You're up to date"})]}),(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),className:A,children:[(0,r.Y)(b.A,{size:12}),(0,r.Y)("span",{children:"Check again"})]})]}),a&&i.length>0&&(0,r.FD)("div",{children:[i.map(e=>{let{target:n,info:i}=e;return(0,r.Y)(C,{target:n,info:i,applying:t.applying===n,disabled:null!==t.applying,onApply:e=>void s(e)},n)}),(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),disabled:null!==t.applying,className:`${A} mt-2 w-full justify-center`,children:[(0,r.Y)(b.A,{size:12}),(0,r.Y)("span",{children:"Check again"})]})]})]})]})}function T(e){let{isOpen:t,onClose:n,updates:i,onToast:a}=e;return t?(0,r.Y)("div",{className:"fixed inset-0 bg-ink/40 backdrop-blur-[2px] z-50 flex items-center justify-center p-4 animate-in fade-in duration-200",onClick:n,children:(0,r.FD)("div",{className:"relative bg-paper border border-ink/15 rounded-2xl shadow-2xl w-full max-w-[340px] p-6 text-center text-ink select-none",onClick:e=>e.stopPropagation(),children:[(0,r.Y)("button",{onClick:n,className:"absolute top-4 right-4 text-ink/40 hover:text-ink transition-colors p-1 rounded-md","aria-label":"Close",children:(0,r.Y)(s.A,{size:18,className:"stroke-[2.5]"})}),(0,r.Y)("div",{className:"flex justify-center pt-2 pb-1",children:(0,r.Y)("img",{src:"/icon.svg",alt:"OMPChamber",width:96,height:96,draggable:!1})}),(0,r.FD)("h2",{className:"text-xl font-bold tracking-tight mt-3 flex items-center justify-center",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-2xl tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"text-ink text-2xl font-bold ml-[1px]",children:"Chamber"})]}),(0,r.FD)("div",{className:"text-xs text-ink/60 space-y-1 mt-1.5 font-mono",children:[(0,r.FD)("p",{children:["OMPChamber v",N.rE]}),(0,r.FD)("p",{children:["Oh-My-Pi ",i.info?.omp.current??"…"]})]}),(0,r.Y)(S,{updates:i,onToast:a}),(0,r.Y)(w,{}),(0,r.Y)("p",{className:"text-[11px] text-ink/50 font-normal mt-8",children:"Made with love for the community"})]})}):null}function z(e){let{isOpen:t,onClose:n,onCreate:o}=e,[c,d]=(0,i.J0)(""),[u,p]=(0,i.J0)(""),[m,h]=(0,i.J0)(!1),[f,x]=(0,i.J0)(null),[g,b]=(0,i.J0)(!1);if((0,i.vJ)(()=>{t&&(d(""),p(""),h(!1),x(null),b(!1))},[t]),!t)return null;let v=async()=>{if(!o)return void n();if(!c.trim()&&!u.trim())return void x("Enter a name or a project path.");h(!0),x(null);try{await o({name:c.trim(),path:u.trim()||void 0}),n()}catch(e){x(e instanceof Error?e.message:String(e)),h(!1)}};return(0,r.FD)("div",{className:"fixed inset-0 bg-ink/20 z-50 flex items-center justify-center",children:[(0,r.FD)("div",{className:"bg-paper border border-ink/10 rounded-lg shadow-xl w-96 p-4 flex flex-col",children:[(0,r.FD)("div",{className:"flex justify-between items-center mb-4 border-b border-ink/10 pb-2",children:[(0,r.Y)("h3",{className:"font-semibold text-sm",children:"New Workspace"}),(0,r.Y)(s.A,{size:14,className:"cursor-pointer hover:text-ink/60",onClick:n})]}),(0,r.FD)("div",{className:"text-sm text-ink/80 py-2 space-y-3",children:[(0,r.FD)("div",{children:[(0,r.Y)("label",{className:"block text-xs font-semibold mb-1 text-ink",children:"Workspace Name"}),(0,r.Y)("input",{type:"text",value:c,onChange:e=>d(e.currentTarget.value),placeholder:"e.g. bofis-pro",className:"w-full bg-paper border border-ink/20 rounded px-3 py-2 outline-none focus:border-ink/50 text-sm"})]}),(0,r.FD)("div",{children:[(0,r.FD)("label",{className:"block text-xs font-semibold mb-1 text-ink",children:["Project Path ",(0,r.Y)("span",{className:"text-ink/40 font-normal",children:"(optional — binds omp sessions)"})]}),(0,r.FD)("div",{className:"flex items-center space-x-2",children:[(0,r.FD)("div",{className:"flex-1 flex items-center bg-paper border border-ink/20 rounded overflow-hidden focus-within:border-ink/50",children:[(0,r.Y)("div",{className:"px-2 text-ink/40 bg-ink/5 h-full flex items-center border-r border-ink/10",children:(0,r.Y)(a.A,{size:14})}),(0,r.Y)("input",{type:"text",value:u,onChange:e=>p(e.currentTarget.value),placeholder:"~/projects/my-project",className:"w-full px-3 py-2 outline-none text-sm bg-transparent"})]}),(0,r.FD)("button",{type:"button",onClick:()=>b(!0),className:"px-3 py-2 bg-ink/5 border border-ink/10 rounded text-xs font-medium hover:bg-ink/10 transition-colors flex items-center space-x-1.5 flex-shrink-0",children:[(0,r.Y)(l.A,{size:13}),(0,r.Y)("span",{children:"Browse"})]})]})]}),f&&(0,r.Y)("div",{className:"text-xs text-red-600",children:f})]}),(0,r.FD)("div",{className:"mt-4 flex justify-end space-x-2",children:[(0,r.Y)("button",{className:"px-3 py-1.5 text-xs font-medium text-ink/60 hover:text-ink transition-colors",onClick:n,disabled:m,children:"Cancel"}),(0,r.Y)("button",{className:"px-4 py-1.5 text-xs font-medium bg-ink text-canvas rounded hover:bg-ink/90 transition-colors disabled:opacity-50",onClick:v,disabled:m,children:m?"Creating…":"Create Workspace"})]})]}),g&&(0,r.Y)(y,{initialPath:u||void 0,onSelect:e=>{if(p(e),b(!1),!c.trim()){let t=e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||"";t&&d(t)}},onClose:()=>b(!1)})]})}function $(e){let{isOpen:t,onClose:n}=e;return t?(0,r.Y)("div",{className:"fixed inset-0 bg-ink/20 z-50 flex items-center justify-center p-4",children:(0,r.FD)("div",{className:"bg-paper border border-ink/10 rounded-lg shadow-xl w-full max-w-2xl flex flex-col overflow-hidden",children:[(0,r.FD)("div",{className:"flex justify-between items-center p-4 border-b border-ink/10 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 text-ink",children:[(0,r.Y)(o.A,{size:16}),(0,r.Y)("h3",{className:"font-semibold text-sm",children:"Schedule Chat / Task"})]}),(0,r.Y)(s.A,{size:16,className:"cursor-pointer hover:text-ink/60",onClick:n})]}),(0,r.Y)("div",{className:"p-4 bg-canvas",children:(0,r.FD)("div",{className:"w-full bg-paper border border-ink/20 rounded-md focus-within:border-ink transition-colors flex flex-col shadow-sm",children:[(0,r.FD)("div",{className:"flex items-center px-3 py-2 border-b border-ink/5 text-ink/60 space-x-2",children:[(0,r.Y)("button",{className:"hover:text-ink transition-colors",children:(0,r.Y)(c.A,{size:14})}),(0,r.Y)("button",{className:"hover:text-ink transition-colors",children:(0,r.Y)(d.A,{size:14})}),(0,r.Y)("button",{className:"hover:text-ink transition-colors",children:(0,r.Y)(u.A,{size:14})}),(0,r.Y)("div",{className:"flex-1"}),(0,r.FD)("div",{className:"flex items-center space-x-2 text-xs text-ink",children:[(0,r.Y)("span",{className:"font-medium",children:"Schedule:"}),(0,r.FD)("select",{className:"bg-transparent border border-ink/20 rounded px-1.5 py-0.5 outline-none focus:border-ink/50",children:[(0,r.Y)("option",{value:"once",children:"Once"}),(0,r.Y)("option",{value:"every",children:"Every"}),(0,r.Y)("option",{value:"cron",children:"Cron"})]}),(0,r.Y)("input",{type:"text",placeholder:"e.g. 5 mins, 0 0 * * *",className:"w-32 bg-transparent border border-ink/20 rounded px-2 py-0.5 outline-none focus:border-ink/50"})]})]}),(0,r.Y)("textarea",{placeholder:"Describe your scheduled task, ask a question, or paste commands...",className:"w-full bg-transparent border-none px-4 py-4 text-sm focus:outline-none resize-none text-ink placeholder-ink/40 min-h-[120px]"}),(0,r.FD)("div",{className:"flex items-center justify-between px-3 py-2 border-t border-ink/5",children:[(0,r.FD)("div",{className:"flex items-center space-x-3 text-ink/60 text-xs",children:[(0,r.FD)("div",{className:"flex items-center space-x-1 hover:text-ink cursor-pointer",children:[(0,r.Y)(p.A,{size:14}),(0,r.Y)("span",{children:"Default"})]}),(0,r.FD)("div",{className:"flex items-center space-x-1 hover:text-ink cursor-pointer",children:[(0,r.Y)(m.A,{size:14}),(0,r.Y)("span",{children:"[CMD] DeepSeek V4 Flash"})]})]}),(0,r.FD)("button",{onClick:n,className:"flex items-center justify-center space-x-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/80 transition-colors text-xs font-medium",children:[(0,r.Y)("span",{children:"Schedule Task"}),(0,r.Y)(h.A,{size:12,className:"ml-px"})]})]})]})})]})}):null}},u(e,t,n){var r=n("j"),i=n("G");let s=(0,i.RZ)(()=>Promise.all([n.e("v0"),n.e("kc"),n.e("xw")]).then(n.bind(n,"jQ")).then(e=>({default:e.SettingsModal})));function a(e){let{isOpen:t,...n}=e;return t?(0,r.Y)(i.tY,{fallback:null,children:(0,r.Y)(s,{isOpen:t,...n})}):null}n.d(t,{b:()=>a})},j5(e,t,n){n.d(t,{E:()=>ih});var r=n("j"),i=n("H"),s=n("s"),a=n("G");let l=(0,a.RZ)(()=>n.e("rf").then(n.bind(n,"Rt")).then(e=>({default:e.AskDialog})));function o(e){return(0,r.Y)(a.tY,{fallback:null,children:(0,r.Y)(l,{...e})})}var c=n("v"),d=n("g6"),u=n("Go"),p=n("z"),m=n("oj"),h=n("s8"),f=n("YL"),x=n("tN"),g=n("W9"),b=n("r"),v=n("t3"),k=n("S");function y(e){let{search:t,onSearchChange:n,onAddProvider:i}=e;return(0,r.FD)("div",{className:"flex flex-col border-b border-ink/10 bg-canvas/40",children:[(0,r.FD)("button",{type:"button",onClick:i,className:"w-full flex items-center space-x-2 px-3 py-2 text-xs text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors text-left font-medium cursor-pointer border-b border-ink/5",children:[(0,r.Y)(b.A,{size:14,className:"text-ink/60"}),(0,r.Y)("span",{children:"Add new provider"})]}),(0,r.FD)("div",{className:"p-2 flex items-center bg-canvas/60",children:[(0,r.Y)(v.A,{size:13,className:"text-ink/40 mr-2 flex-shrink-0"}),(0,r.Y)("input",{type:"text",value:t,onChange:e=>n(e.currentTarget.value),placeholder:"Search models",className:"bg-transparent border-none focus:outline-none w-full text-ink placeholder-ink/40 text-xs font-sans",autoFocus:!0}),t&&(0,r.Y)("button",{type:"button",onClick:()=>n(""),className:"p-0.5 text-ink/40 hover:text-ink transition-colors cursor-pointer",title:"Clear search",children:(0,r.Y)(k.A,{size:12})})]})]})}var N=n("HW"),w=n("hw"),Y=n("j7"),D=n("Wb"),F=n("cV"),A=n("lW"),C=n("C7"),S=n("XT"),T=n("Oj"),z=n("K6"),$=n("pm");function j(e){let{model:t,isSelected:n,isFocused:i,onSelect:s,onToggleFavorite:a,onCycleThinking:l,onMouseEnter:o}=e;return(0,r.FD)("div",{role:"button",tabIndex:0,onClick:()=>s(t),onMouseEnter:o,className:`group relative w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs transition-colors cursor-pointer select-none ${i?"bg-ink/10 text-ink":n?"bg-ink/5 text-ink":"text-ink/85 hover:bg-ink/5"}`,children:[(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[(0,r.Y)(Y.A,{size:12,className:"text-ink/20 group-hover:text-ink/50 transition-colors flex-shrink-0"}),(()=>{if(t.isCmdAgent)return(0,r.Y)("span",{className:"inline-flex items-center justify-center w-4 h-4 rounded border border-ink/20 bg-ink/5 text-ink/80 flex-shrink-0",title:"Autonomous Agent Command Mode [CMD]",children:(0,r.Y)(F.A,{size:10})});switch(t.providerIcon||t.provider.toLowerCase()){case"deepseek":return(0,r.Y)("span",{className:"text-[12px] leading-none flex-shrink-0",title:"DeepSeek",children:"🐋"});case"anthropic":case"claude":return(0,r.Y)(A.A,{size:13,className:"text-orange-400 flex-shrink-0"});case"openai":return(0,r.Y)(C.A,{size:13,className:"text-emerald-500 flex-shrink-0"});case"google":case"gemini":return(0,r.Y)(x.A,{size:13,className:"text-blue-400 flex-shrink-0"});case"opencode":return(0,r.Y)(S.A,{size:13,className:"text-violet-400 flex-shrink-0"});case"mistral":return(0,r.Y)(T.A,{size:13,className:"text-rose-400 flex-shrink-0"});default:return(0,r.Y)(x.A,{size:13,className:"text-ink/60 flex-shrink-0"})}})(),(0,r.FD)("div",{className:"flex items-center space-x-1.5 truncate",children:[t.isCmdAgent&&(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink/75 flex-shrink-0",children:"[CMD]"}),(0,r.Y)("span",{className:`truncate ${n?"font-semibold text-ink":"font-normal text-ink/90"}`,children:t.name}),t.contextWindow&&(0,r.Y)("span",{className:"font-mono text-[10px] text-ink/45 flex-shrink-0",children:(0,$.F)(t.contextWindow)})]})]}),(0,r.FD)("div",{className:"flex items-center space-x-2 flex-shrink-0",children:[t.thinkingLevel&&(0,r.FD)("button",{type:"button",onClick:e=>{e.stopPropagation(),l?.(t,e)},title:`Thinking preset: ${t.thinkingLevel} (Click or use ← / → to change)`,className:"inline-flex items-center space-x-1 px-1.5 py-0.5 rounded text-[10px] font-mono text-ink/70 bg-ink/5 hover:bg-ink/10 border border-ink/10 transition-colors cursor-pointer",children:[(0,r.Y)(z.A,{size:10,className:"text-ink/50"}),(0,r.Y)("span",{children:t.thinkingLevel})]}),n&&(0,r.Y)(p.A,{size:13,className:"text-ink flex-shrink-0"}),(0,r.Y)("button",{type:"button",onClick:e=>a(t,e),title:t.isFavorite?"Remove from favorites":"Add to favorites",className:"p-1 rounded text-ink/30 hover:text-sky-400 hover:bg-ink/5 transition-colors cursor-pointer",children:(0,r.Y)(N.A,{size:13,className:t.isFavorite?"fill-sky-400 text-sky-400":"text-ink/30 hover:text-sky-400"})})]})]})}function L(e){return e?`${e.provider}:${e.id}`:""}function M(e){let{id:t,title:n,iconType:i="provider",models:s,isCollapsed:a,onToggleCollapse:l,selectedModelKey:o,modelIndex:c,focusedIndex:d,onSelect:p,onToggleFavorite:m,onCycleThinking:h,onHoverItem:f}=e;return 0===s.length?null:(0,r.FD)("div",{className:"space-y-0.5",children:[(0,r.FD)("button",{type:"button",onClick:()=>l(t),className:"w-full flex items-center justify-between px-2 py-1 text-[11px] font-semibold text-ink/60 uppercase tracking-wider hover:text-ink cursor-pointer select-none",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5",children:["star"===i&&(0,r.Y)(N.A,{size:12,className:"fill-sky-400 text-sky-400"}),"recent"===i&&(0,r.Y)(w.A,{size:12,className:"text-ink/60"}),"whale"===i&&(0,r.Y)("span",{children:"🐋"}),"provider"===i&&(0,r.Y)(Y.A,{size:11,className:"text-ink/25"}),(0,r.Y)("span",{children:n})]}),a?(0,r.Y)(u.A,{size:12,className:"text-ink/40"}):(0,r.Y)(D.A,{size:12,className:"text-ink/40"})]}),!a&&(0,r.Y)("div",{className:"space-y-0.5",children:s.map(e=>{let n=L(e),i=c[n]??-1;return(0,r.Y)(j,{model:e,isSelected:o===n,isFocused:d===i,onSelect:p,onToggleFavorite:m,onCycleThinking:h,onMouseEnter:()=>f(i,e)},`${t}-${n}`)})})]})}function P(){return(0,r.Y)("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-ink/10 bg-canvas/60 text-[10px] text-ink/50 font-mono select-none",children:(0,r.FD)("div",{className:"flex items-center space-x-3",children:[(0,r.FD)("span",{className:"flex items-center space-x-1",children:[(0,r.Y)("span",{className:"text-ink/70",children:"↑ ↓"}),(0,r.Y)("span",{children:"navigate"})]}),(0,r.FD)("span",{className:"flex items-center space-x-1",children:[(0,r.Y)("span",{className:"text-ink/70",children:"Tab"}),(0,r.Y)("span",{children:"switch agent"})]}),(0,r.FD)("span",{className:"flex items-center space-x-1",children:[(0,r.Y)("span",{className:"text-ink/70",children:"← →"}),(0,r.Y)("span",{children:"thinking"})]})]})})}let E=[3,2];function R(){return(0,r.Y)("div",{className:"space-y-2","aria-hidden":"true",children:E.map((e,t)=>(0,r.FD)("div",{className:"space-y-0.5",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5 px-2 py-1",children:[(0,r.Y)("span",{className:"w-2.5 h-2.5 rounded-sm animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-2.5 w-20 rounded animate-pulse bg-ink/10"})]}),Array.from({length:e},(e,n)=>(0,r.FD)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[(0,r.Y)("span",{className:"w-3 h-3 rounded-sm animate-pulse bg-ink/10 flex-shrink-0"}),(0,r.Y)("span",{className:"h-3 rounded animate-pulse bg-ink/10",style:{width:`${52-(n+t)%3*10}%`}})]}),(0,r.Y)("span",{className:"h-4 w-9 rounded animate-pulse bg-ink/10 flex-shrink-0"})]},n))]},t))})}function I(e){let{model:t}=e;return t?(0,r.Y)("div",{className:"w-72 bg-paper/95 backdrop-blur-sm border border-ink/20 rounded-xl shadow-2xl p-3.5 text-xs text-ink select-none animate-in fade-in zoom-in-95 duration-100",children:(0,r.FD)("div",{className:"space-y-2.5 font-mono text-[11px]",children:[t.capabilities&&t.capabilities.length>0&&(0,r.FD)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Capabilities"}),(0,r.Y)("span",{className:"text-ink font-medium text-right text-xs font-sans",children:t.capabilities.join(", ")})]}),t.contextWindow&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Context"}),(0,r.Y)("span",{className:"text-ink/80",children:(0,$.F)(t.contextWindow)})]}),t.thinkingLevel&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Thinking"}),(0,r.Y)("span",{className:"text-ink/80",children:t.thinkingLevel})]}),t.input&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Input"}),(0,r.Y)("span",{className:"text-ink/80",children:t.input})]}),t.output&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Output"}),(0,r.Y)("span",{className:"text-ink/80",children:t.output})]}),t.cost&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2 pt-1 border-t border-ink/10",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Cost ($/1M tokens)"}),(0,r.FD)("span",{className:"text-ink font-semibold tracking-tight",children:["In ",t.cost.input," · Out ",t.cost.output]})]}),(t.cost?.cacheRead!==void 0||t.cost?.cacheWrite!==void 0)&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2 pt-1 border-t border-ink/5",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Cache"}),(0,r.Y)("span",{className:"text-ink/80",children:t.cost?.cacheRead!==void 0&&t.cost?.cacheWrite!==void 0?`Read ${t.cost.cacheRead} \xb7 Write ${t.cost.cacheWrite}`:t.cost?.cacheRead!==void 0?`Read ${t.cost.cacheRead}`:`Write ${t.cost.cacheWrite}`})]}),t.description&&(0,r.Y)("div",{className:"pt-1.5 text-[10px] text-ink/60 font-sans leading-relaxed border-t border-ink/5",children:t.description})]})}):null}function O(e){let{search:t,onSearchChange:n,onAddProvider:i,isLoading:s,filteredModels:a,favoriteModels:l,recentModels:o,providerGroups:c,collapsedSections:d,onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,hoveredModel:f,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v,onMouseLeave:k}=e;return(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-2.5 z-50 flex items-start",children:[(0,r.FD)("div",{className:"w-84 sm:w-96 bg-paper border border-ink/20 rounded-xl shadow-2xl flex flex-col overflow-hidden text-xs max-h-[460px] animate-in fade-in zoom-in-95 duration-100",children:[(0,r.Y)(y,{search:t,onSearchChange:n,onAddProvider:i}),(0,r.Y)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-1.5 space-y-2 max-h-80",onMouseLeave:k,children:s?(0,r.Y)(R,{}):0===a.length?(0,r.Y)("div",{className:"px-3 py-6 text-center text-ink/40 italic",children:t?(0,r.FD)(r.FK,{children:['No models found matching "',t,'"']}):(0,r.Y)(r.FK,{children:"No models available. Enable a provider in Settings → Providers."})}):(0,r.FD)(r.FK,{children:[(0,r.Y)(M,{id:"favorites",title:"FAVORITES",iconType:"star",models:l,isCollapsed:!!d.favorites,onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v}),(0,r.Y)(M,{id:"recent",title:"RECENT",iconType:"recent",models:o,isCollapsed:!!d.recent,onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v}),Object.entries(c).map(e=>{let[t,n]=e;return(0,r.Y)(M,{id:t,title:t,iconType:"DEEPSEEK"===t?"whale":"provider",models:n,isCollapsed:!!d[t],onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v},t)})]})}),(0,r.Y)(P,{})]}),f&&(0,r.Y)("div",{className:"hidden lg:block ml-2 self-center",children:(0,r.Y)(I,{model:f})})]})}function J(e){let t=Array.isArray(e.thinkingLevels)?e.thinkingLevels:[],n=e.cost;return{id:e.id,name:e.name,provider:e.provider,contextWindow:e.contextWindow,thinkingLevel:t[0]??"off",thinkingLevels:t,capabilities:t.length>1?["Tool calling","Reasoning"]:["Tool calling"],cost:n?{input:void 0!==n.input?`$${n.input}`:"—",output:void 0!==n.output?`$${n.output}`:"—",cacheRead:void 0!==n.cacheRead?`$${n.cacheRead}`:void 0,cacheWrite:void 0!==n.cacheWrite?`$${n.cacheWrite}`:void 0}:void 0}}function _(e){let{selectedModel:t,onSelectModel:n,onOpenAddProvider:s,onThinkingLevelChange:a,className:l=""}=e,[o,c]=(0,i.J0)(!1),[d,p]=(0,i.J0)(""),[h,f]=(0,i.J0)(-1),[b,v]=(0,i.J0)(null),[k,y]=(0,i.J0)({}),{models:N,isLoading:w,setModels:Y,selectedModel:D,setSelectedModel:F}=function(e){let[t,n]=(0,i.J0)([]),[r,s]=(0,i.J0)(!0),[a,l]=(0,i.J0)(e??null),o=(0,i.li)(e);o.current=e;let c=(0,i.hb)(e=>{n(e)},[]),d=(0,i.hb)(async()=>{try{let e=await (0,g.xo)();if(Array.isArray(e.modelList)&&e.modelList.length>0){let t=e.modelList.map(J);n(e=>t.map(t=>{let n=e.find(e=>e.id===t.id&&e.provider===t.provider);return n?.thinkingLevel&&t.thinkingLevels?.includes(n.thinkingLevel)?{...t,thinkingLevel:n.thinkingLevel}:t}));let r=e.defaultModel;if(r&&!o.current){let e=t.find(e=>e.id===r.modelId&&e.provider===r.provider);e&&l(e)}}else Array.isArray(e.models)&&e.models.length>0&&n(e.models);e.selectedModel&&!o.current&&l(e.selectedModel)}catch{}finally{s(!1)}},[]);return(0,i.vJ)(()=>(d(),(0,g.Sy)(d)),[d]),(0,i.vJ)(()=>{e&&(l(e),n(t=>t.map(t=>t.id===e.id&&t.provider===e.provider?{...t,thinkingLevel:e.thinkingLevel}:t)))},[e]),{models:t,isLoading:r,setModels:c,selectedModel:a,setSelectedModel:l}}(t),A=(0,i.li)(null);(0,m.W)(A,()=>{c(!1),v(null),f(-1)});let{filtered:C,favorites:S,recent:T,byProvider:z,visibleFlatList:$,index:j}=(0,i.Kr)(()=>(function(e,t,n){let r=t.trim().toLowerCase(),i=r?e.filter(e=>e.name.toLowerCase().includes(r)||e.provider.toLowerCase().includes(r)||String(e.contextWindow??"").toLowerCase().includes(r)||e.capabilities?.some(e=>e.toLowerCase().includes(r))):e,s=i.filter(e=>e.isFavorite),a=i.filter(e=>e.isRecent&&!e.isFavorite),l={};for(let e of i){let t=e.provider.toUpperCase();(l[t]??=[]).push(e)}let o=[];for(let[e,t]of(n.favorites||o.push(...s),n.recent||o.push(...a),Object.entries(l)))n[e]||o.push(...t);let c={};return o.forEach((e,t)=>{c[L(e)]=t}),{filtered:i,favorites:s,recent:a,byProvider:l,visibleFlatList:o,index:c}})(N,d,k),[N,d,k]),M=L(D),P=async(e,t)=>{t.stopPropagation();let n=L(e);Y(e=>e.map(e=>L(e)===n?{...e,isFavorite:!e.isFavorite}:e));try{await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"toggleFavorite",provider:e.provider,modelId:e.id})})}catch{}},E=e=>{let t=e.thinkingLevels??[];if(0===t.length)return;let r=e.thinkingLevel??t[0],i=t.indexOf(r),s=t[(i+1)%t.length],l=L(e);if(Y(e=>e.map(e=>L(e)===l?{...e,thinkingLevel:s}:e)),M===l&&D){let e={...D,thinkingLevel:s};F(e),n?.(e),a?.(s)}},R=async e=>{let t=!e.isCmdAgent,n=L(e);Y(e=>e.map(e=>L(e)===n?{...e,isCmdAgent:t}:e)),M===n&&D&&F({...D,isCmdAgent:t});try{await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"toggleCmd",provider:e.provider,modelId:e.id})})}catch{}},I=async e=>{F(e),n?.(e),c(!1),v(null);try{await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"selectModel",model:e})}),(0,g.kn)()}catch{}};return(0,r.FD)("div",{className:`relative ${l}`,ref:A,onKeyDown:e=>{if(o){if("ArrowDown"===e.key)e.preventDefault(),f(e=>{let t=(e+1)%Math.max(1,$.length);return v($[t]||null),t});else if("ArrowUp"===e.key)e.preventDefault(),f(e=>{let t=(e-1+$.length)%Math.max(1,$.length);return v($[t]||null),t});else if("Enter"===e.key){e.preventDefault();let t=(h>=0?$[h]:null)||b;t&&I(t)}else if("Escape"===e.key)e.preventDefault(),c(!1),v(null);else if("Tab"===e.key){e.preventDefault();let t=(h>=0?$[h]:null)||b;t&&R(t)}else if("ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();let t=(h>=0?$[h]:null)||b;t&&E(t)}}},children:[(0,r.FD)("button",{type:"button",onClick:()=>{c(e=>!e),v(null),f(-1)},className:"flex items-center space-x-1.5 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-ink/80 font-medium cursor-pointer min-w-0 max-w-full",title:D?`${D.provider} • ${D.name}`:"Select a model",children:[D?(0,r.FD)(r.FK,{children:[(0,r.Y)("span",{className:"text-ink/60 flex-shrink-0",children:D.isCmdAgent?(0,r.Y)("span",{className:"font-mono text-[10px] font-bold text-ink/70",children:"⌘"}):"deepseek"===D.provider.toLowerCase()?(0,r.Y)("span",{children:"🐋"}):(0,r.Y)(x.A,{size:12,className:"text-ink/60"})}),(0,r.FD)("span",{className:"flex items-center space-x-1 min-w-0 max-w-[280px]",children:[(0,r.Y)("span",{className:"text-ink/50 font-normal truncate",children:D.provider}),(0,r.Y)("span",{className:"text-ink/30 flex-shrink-0",children:"•"}),(0,r.Y)("span",{className:"truncate",children:D.name})]})]}):(0,r.FD)(r.FK,{children:[(0,r.Y)("span",{className:"text-ink/60 flex-shrink-0",children:(0,r.Y)(x.A,{size:12,className:"text-ink/60"})}),(0,r.Y)("span",{className:"h-3 w-28 rounded animate-pulse bg-ink/10"})]}),(0,r.Y)(u.A,{size:12,className:"text-ink/40 flex-shrink-0"})]}),o&&(0,r.Y)(O,{search:d,onSearchChange:p,onAddProvider:()=>{c(!1),v(null),s?s():window.dispatchEvent(new CustomEvent("omp:open-settings",{detail:{category:"providers",autoOpenAdd:!0}}))},isLoading:w,filteredModels:C,favoriteModels:S,recentModels:T,providerGroups:z,collapsedSections:k,onToggleCollapse:e=>{y(t=>({...t,[e]:!t[e]}))},selectedModelKey:M,modelIndex:j,focusedIndex:h,hoveredModel:b,onSelect:I,onToggleFavorite:P,onCycleThinking:E,onHoverItem:(e,t)=>{f(e),v(t)},onMouseLeave:()=>v(null)})]})}function W(e){let{thinkingLevels:t,currentThinking:n,onSelect:s}=e,[a,l]=(0,i.J0)(!1),o=(0,i.li)(null);return(0,m.W)(o,()=>l(!1)),(0,r.FD)("div",{className:"relative",ref:o,children:[(0,r.FD)("button",{onClick:()=>t.length>0&&l(!a),disabled:0===t.length,className:"flex items-center space-x-1 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-ink/80 disabled:opacity-40 disabled:cursor-not-allowed",title:0===t.length?"This model exposes no thinking levels":`Thinking Level: ${n}`,children:[(0,r.Y)(z.A,{size:12,className:"text-ink/60"}),(0,r.Y)("span",{className:"hidden lg:inline",children:n})]}),a&&t.length>0&&(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-1 w-40 bg-paper border border-ink/20 rounded-md shadow-lg z-50 py-1 text-xs",children:[(0,r.Y)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold mb-1",children:"Thinking Level"}),t.map(e=>(0,r.FD)("button",{onClick:()=>{l(!1),s(e)},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[(0,r.Y)("span",{children:e}),n===e&&(0,r.Y)(p.A,{size:12,className:"text-ink"})]},e))]})]})}var K=n("wf");let U=["always-ask","write","yolo"],H={"always-ask":"Always ask",write:"Minimal",yolo:"Full bypass"},B={"always-ask":"Read-only tools run automatically; writes and shell commands ask first.",write:"Reads and edits run automatically; shell commands ask first.",yolo:"Everything runs without asking."};function q(e){let{value:t,onSelect:n}=e,[s,a]=(0,i.J0)(!1),l=(0,i.li)(null);return(0,m.W)(l,()=>a(!1)),(0,r.FD)("div",{className:"relative",ref:l,children:[(0,r.FD)("button",{type:"button",onClick:()=>a(!s),className:"flex items-center space-x-1 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-ink/80",children:[(0,r.Y)(K.A,{size:12,className:"text-ink/60"}),(0,r.Y)("span",{className:"hidden lg:inline",children:H[t]})]}),s&&(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-1 w-40 bg-paper border border-ink/20 rounded-md shadow-lg z-50 py-1 text-xs",children:[(0,r.Y)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold mb-1",children:"Access Control"}),U.map(e=>(0,r.FD)("button",{type:"button",onClick:()=>{n(e),a(!1)},title:B[e],className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[(0,r.Y)("span",{children:H[e]}),t===e&&(0,r.Y)(p.A,{size:12,className:"text-ink"})]},e))]})]})}function G(e){let{isMobile:t,selectedModel:n,onSelectModel:i,thinkingLevels:s,currentThinking:a,onSelectThinking:l,onThinkingLevelChange:o,isGenerating:c,onStop:d,onSend:u,sendDisabled:p,accessMode:m,onSelectAccess:x}=e;return(0,r.FD)("div",{className:`flex items-center justify-between border-t border-ink/5 bg-canvas/50 rounded-b-md ${t?"px-2 py-2":"px-3 py-2"}`,children:[(0,r.FD)("div",{className:`flex items-center min-w-0 ${t?"space-x-1":"space-x-2"}`,children:[(0,r.Y)(_,{selectedModel:n??void 0,onSelectModel:i,onThinkingLevelChange:o,className:t?"min-w-0 max-w-[58%]":void 0}),(0,r.Y)("div",{className:"w-[1px] h-3 bg-ink/10"}),(0,r.Y)(W,{thinkingLevels:s,currentThinking:a,onSelect:l}),(0,r.Y)("div",{className:"w-[1px] h-3 bg-ink/10"}),(0,r.Y)(q,{value:m,onSelect:x})]}),(0,r.FD)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[c&&(!t||!!d)&&(0,r.Y)("button",{type:"button",onClick:d,className:`flex items-center justify-center rounded transition-colors cursor-pointer shadow-xs animate-in zoom-in-90 duration-150 flex-shrink-0 ${t?"w-10 h-10 rounded-lg border border-ink/25 text-ink hover:bg-error hover:text-canvas hover:border-error":"w-7 h-7 bg-ink text-canvas hover:bg-error hover:text-canvas"}`,title:"Stop generation",children:(0,r.Y)(h.A,{size:t?14:10,className:"fill-current"})}),(!c||t)&&(0,r.Y)("button",{type:"button",onClick:u,disabled:p,className:`flex items-center justify-center rounded bg-ink text-canvas hover:bg-ink/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer flex-shrink-0 ${t?"w-10 h-10 rounded-lg":"w-7 h-7"}`,title:c?"Queue follow-up message":"Send message",children:(0,r.Y)(f.A,{size:t?16:12,className:"ml-px"})})]})]})}let V=/[\s([{]/,Z=/^file:/i;var Q=n("ns");function X(e){let{item:t}=e,n=t.match;return!n||n.start<0||n.start>=n.end||n.end>t.name.length?(0,r.Y)(r.FK,{children:t.name}):(0,r.FD)(r.FK,{children:[t.name.slice(0,n.start),(0,r.Y)("mark",{className:"bg-transparent font-semibold text-ink",children:t.name.slice(n.start,n.end)}),t.name.slice(n.end)]})}function ee(e){let{open:t,kind:n,items:s,activeIndex:a,loading:l,error:o,listboxId:c,optionId:d,onSelect:u,onHover:p}=e,m=(0,i.li)(null);if((0,i.vJ)(()=>{t&&m.current?.scrollIntoView({block:"nearest"})},[a,t,s.length]),!t)return null;let h="mention"===n;return(0,r.FD)("div",{role:"listbox",id:c,"aria-label":h?"Files and agents":"Commands and skills",className:"absolute left-0 right-0 bottom-full mb-1 z-50 min-w-[260px] flex max-h-60 flex-col rounded-md border border-ink/20 bg-paper shadow-lg text-sm",children:[(0,r.Y)("div",{className:"shrink-0 text-[10px] uppercase tracking-wider text-ink/40 px-3 py-1.5 border-b border-ink/10",children:h?"Type to search files and agents":"Type to search commands and skills"}),(0,r.Y)("div",{className:"flex-1 overflow-y-auto",children:o?(0,r.Y)("div",{className:"px-3 py-2 text-error",children:o}):l&&0===s.length?(0,r.Y)("div",{className:"px-3 py-2 text-ink/50",children:"Loading…"}):0===s.length?(0,r.Y)("div",{className:"px-3 py-2 text-ink/50",children:h?"No matching files or agents":"No matching commands or skills"}):s.slice(0,100).map((e,t)=>(0,r.FD)("div",{id:d(t),role:"option","aria-selected":t===a,ref:t===a?m:void 0,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>p(t),onClick:()=>u(e),className:`px-3 py-2 cursor-pointer ${t===a?"bg-ink/10":""}`,children:[(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"truncate",children:(0,r.Y)(X,{item:e})}),"file"===e.source&&(0,r.Y)("span",{className:"text-ink/40 text-[10px] uppercase shrink-0",children:"file"}),"skill"===e.source&&(0,r.Y)("span",{className:"text-ink/40 text-[10px] uppercase shrink-0",children:"skill"})]}),(0,r.Y)("div",{className:"truncate text-ink/50 text-xs",children:e.description})]},e.id))}),(0,r.Y)("div",{className:"shrink-0 px-3 py-1.5 border-t border-ink/10 text-[10px] text-ink/40",children:"↑↓ navigate · Enter select · Esc close"})]})}function et(e){let{value:t,onChange:n,onSend:s,disabled:a=!1,appSettings:l,placeholder:o,className:c,onPaste:d,rootPath:u,variant:p="desktop"}=e,h="mobile"===p,f=(0,i.li)(null),x=(0,i.li)(null),g=function(e){let{value:t,setValue:n,textareaRef:r,disabled:s=!1,rootPath:a}=e,[l,o]=(0,i.J0)(null),[c,d]=(0,i.J0)(0),u=(0,i.li)(!1),p=(0,i.li)(null),{items:m,loading:h,error:f}=function(e,t){let[n,r]=(0,i.J0)({items:[],loading:!1,error:null});return(0,i.vJ)(()=>{if(!e)return void r({items:[],loading:!1,error:null});let n=!1;return r({items:[],loading:!0,error:null}),(0,Q.bF)(e,t??null).then(e=>{n||r({items:e,loading:!1,error:null})}).catch(e=>{n||r({items:[],loading:!1,error:e instanceof Error?e.message:String(e)})}),()=>{n=!0}},[e,t]),n}(l?.kind??null,a??null),x=(0,i.Kr)(()=>(function(e,t){let n=t.trim(),r=Z.test(n),i=r?e.filter(e=>"file"===e.source):e,s=r?n.replace(Z,"").trim():n;if(""===s)return i.map(e=>({...e,match:null}));let a=[];return i.forEach((e,t)=>{let n=function(e,t,n){let r=n.trim().toLowerCase();if(""===r)return null;let i=e.toLowerCase(),s=t.toLowerCase();if(i===r)return{tier:0,match:{start:0,end:e.length}};if(i.startsWith(r))return{tier:1,match:{start:0,end:r.length}};let a=i.indexOf(r);return a>=0?{tier:2,match:{start:a,end:a+r.length}}:s.includes(r)?{tier:3,match:null}:null}(e.name,e.description,s);n&&a.push({...n,index:t})}),a.sort((e,t)=>e.tier-t.tier||e.index-t.index),a.map(e=>({...i[e.index],match:e.match}))})(m,l?.query??""),[m,l?.query]),g=x.length>0?Math.min(Math.max(c,0),x.length-1):-1,b=(0,i.Bi)(),v=(0,i.hb)(e=>`${b}-option-${e}`,[b]),k=(0,i.hb)(()=>{o(null),d(0)},[]),y=(0,i.hb)(e=>{d(e)},[]),N=(0,i.hb)(()=>{u.current=!0},[]),w=(0,i.hb)(()=>{u.current=!1},[]),Y=(0,i.hb)(e=>{var t;let r=e.currentTarget,i=r.value,a=r.selectionStart??i.length;if(u.current||!0===(t=e).isComposing||t.inputType?.startsWith("insertFromPaste")===!0||t.inputType?.startsWith("insertFromDrop")===!0){n(i),k();return}(n(i),s)?k():(o(function(e,t){let n=Math.max(0,Math.min(t,e.length));for(let t=n-1;t>=0;t--){let r=e[t];if(/\s/.test(r))break;if("/"===r||"@"===r){if("/"===r){if(0!==t)return null;return{kind:"command",query:e.slice(t+1,n),start:t,end:n}}if(0===t||V.test(e[t-1]))return{kind:"mention",query:e.slice(t+1,n),start:t,end:n};break}}return null}(i,a)),d(0))},[n,k,s]),D=(0,i.hb)(e=>{var r;if(!l)return;let i=(r=`${e.token} `,{value:t.slice(0,l.start)+r+t.slice(l.end),caret:l.start+r.length});p.current=i.caret,n(i.value),k()},[t,l,n,k]),F=(0,i.hb)(e=>!u.current&&229!==e.keyCode&&!!l&&("ArrowDown"===e.key||"ArrowUp"===e.key?(e.preventDefault(),x.length>0&&d((g+("ArrowDown"===e.key?1:-1)+x.length)%x.length),!0):("Enter"===e.key||"Tab"===e.key)&&x.length>0?(e.preventDefault(),e.stopPropagation(),D(x[g]),!0):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),k(),!0)),[l,x,g,D,k]);return(0,i.Nf)(()=>{if(null==p.current)return;let e=p.current;p.current=null;let t=r.current;t&&(t.focus(),t.setSelectionRange(e,e))},[t,r]),{trigger:l,isOpen:null!==l,matches:x,loading:h,error:f,activeIndex:g,setActiveIndex:y,handleChange:Y,handleCompositionStart:N,handleCompositionEnd:w,handleKeyDown:F,selectItem:D,close:k,listboxId:b,optionId:v}}({value:t,setValue:n,textareaRef:f,disabled:a,rootPath:u});return(0,m.W)(x,g.close),(0,r.FD)("div",{className:"relative",ref:x,children:[(0,r.Y)("textarea",{ref:f,value:t,onChange:g.handleChange,onCompositionStart:g.handleCompositionStart,onCompositionEnd:g.handleCompositionEnd,onKeyDown:e=>{if(g.handleKeyDown(e)||"Enter"!==e.key)return;let t=l?.keybindingSend||"Enter",n=l?.keybindingNewLine||"Shift + Enter",r=l?.keybindingSteering||"Ctrl / Cmd + Enter",i="u">typeof navigator&&navigator.platform.toUpperCase().indexOf("MAC")>=0?e.metaKey:e.ctrlKey,o=e.shiftKey,c=t=>"Enter"===t&&!o&&!i&&!e.altKey||"Shift + Enter"===t&&!!o&&!i&&!e.altKey||"Ctrl / Cmd + Enter"===t&&!o&&!!i&&!e.altKey,d=!o&&!i&&!e.altKey;(!h||!d)&&(c(r)?(e.preventDefault(),a||s({steering:!0})):c(t)?(e.preventDefault(),a||s()):c(n)||e.preventDefault())},onPaste:d,disabled:a,placeholder:o,enterkeyhint:h?"enter":void 0,className:c,"aria-autocomplete":"list","aria-expanded":g.isOpen,"aria-controls":g.listboxId,"aria-haspopup":"listbox","aria-activedescendant":g.isOpen&&g.matches.length>0?g.optionId(g.activeIndex):void 0}),(0,r.Y)(ee,{open:g.isOpen,kind:g.trigger?.kind??"mention",items:g.matches,activeIndex:g.activeIndex,loading:g.loading,error:g.error,listboxId:g.listboxId,optionId:g.optionId,onSelect:g.selectItem,onHover:g.setActiveIndex})]})}var en=n("Bt"),er=n("HD");function ei(e){let{attachments:t,onFilesSelected:n,onRemove:s}=e,a=(0,i.li)(null);return(0,r.FD)(r.FK,{children:[(0,r.FD)("div",{className:"flex items-center flex-wrap gap-1.5 px-3 py-2 border-b border-ink/5 text-ink/60",children:[(0,r.Y)("button",{onClick:()=>a.current?.click(),className:"flex items-center justify-center hover:bg-ink/5 p-1 rounded transition-colors text-ink/60 hover:text-ink shrink-0",title:"Attach file or image",children:(0,r.Y)(en.A,{size:14})}),t.map(e=>(0,r.FD)("div",{className:"relative flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 pr-6 text-xs shadow-sm group",children:[e.preview?(0,r.Y)("img",{src:e.preview,alt:"preview",className:"w-6 h-6 object-cover rounded-sm mr-1.5 border border-ink/5"}):(0,r.Y)("div",{className:"w-6 h-6 flex items-center justify-center bg-ink/5 rounded-sm mr-1.5 text-ink/60",children:(0,r.Y)(er.A,{size:12})}),(0,r.Y)("span",{className:"truncate max-w-[120px] font-mono text-[10px] text-ink/80",children:e.file.name}),(0,r.Y)("button",{onClick:()=>s(e.id),className:"absolute right-0.5 top-1/2 -translate-y-1/2 p-0.5 text-ink/40 hover:text-error hover:bg-error/10 rounded transition-colors",title:"Remove attachment",children:(0,r.Y)(k.A,{size:10})})]},e.id))]}),(0,r.Y)("input",{type:"file",multiple:!0,className:"hidden",ref:a,onChange:e=>{e.currentTarget.files&&e.currentTarget.files.length>0&&n(Array.from(e.currentTarget.files)),a.current&&(a.current.value="")}})]})}let es=["auto","off","minimal","low","medium","high","xhigh","max"];function ea(e){if(!e||0===e.length)return[];let t=new Set(e.filter(e=>e&&"auto"!==e));return[...es.filter(e=>t.delete(e)),...t]}function el(e){let{value:t,onChange:n,onSend:s,isGenerating:a,onStop:l,className:o="",disabled:c=!1,appSettings:d={},attachments:u,onAttachmentsChange:p,onThinkingLevelChange:m,onModelChange:h,sessionModel:f,sessionThinkingLevel:x,rootPath:b,variant:v="desktop",accessMode:k,onAccessModeChange:y,composerModelRef:N}=e,[w,Y]=(0,i.J0)([]),D=void 0!==u?u:w,F=e=>{p?p(e):Y(e)},[A,C]=(0,i.J0)(null),[S,T]=(0,i.J0)("auto");(0,i.vJ)(()=>{A?.id&&(N.current={provider:A.provider,modelId:A.id,thinkingLevel:A.thinkingLevel??"auto"})},[A?.provider,A?.id,A?.thinkingLevel,N]);let z=(0,i.li)(null);z.current=x??null;let $=(0,i.li)(f??null);$.current=f??null;let j=(e,t)=>{let n=z.current;if(!n)return t;let r=ea(e??[]);return 0===r.length||r.includes(n)?n:t};(0,i.vJ)(()=>{if(!f?.provider||!f.modelId)return;let e=!0;return(0,g.xo)().then(t=>{if(!e||!f)return;let n=(t.modelList||[]).find(e=>e.id===f.modelId&&e.provider===f.provider);n&&C(e=>({id:n.id,name:n.name,provider:n.provider,contextWindow:n.contextWindow,thinkingLevels:n.thinkingLevels,thinkingLevel:j(n.thinkingLevels,e?.thinkingLevel??n.thinkingLevels?.[0]??"off")}))}).catch(()=>{}),()=>{e=!1}},[f?.provider,f?.modelId]),(0,i.vJ)(()=>{x&&C(e=>{if(!e)return e;let t=ea(e.thinkingLevels??[]),n=0===t.length||t.includes(x)?x:e.thinkingLevel;return n===e.thinkingLevel?e:{...e,thinkingLevel:n}})},[x]),(0,i.vJ)(()=>{let e=!0,t=async()=>{try{let t=await (0,g.xo)();if(!e)return;if(Array.isArray(t.modelList)&&t.modelList.length>0){let e=$.current;if(e?.provider&&e.modelId){let n=t.modelList.find(t=>t.id===e.modelId&&t.provider===e.provider);n&&C(e=>({id:n.id,name:n.name,provider:n.provider,thinkingLevels:n.thinkingLevels,thinkingLevel:j(n.thinkingLevels,e?.thinkingLevel??n.thinkingLevels?.[0]??"off")}));return}let n=t.selectedModel;if(n?.provider&&n.id){let e=t.modelList.find(e=>e.id===n.id&&e.provider===n.provider);if(e)return void C(t=>({id:e.id,name:e.name,provider:e.provider,thinkingLevels:e.thinkingLevels,thinkingLevel:j(e.thinkingLevels,t?.thinkingLevel??e.thinkingLevels?.[0]??"off")}))}let r=t.defaultModel;if(r){let e=t.modelList.find(e=>e.id===r.modelId&&e.provider===r.provider);e&&C(t=>({id:e.id,name:e.name,provider:e.provider,thinkingLevels:e.thinkingLevels,thinkingLevel:j(e.thinkingLevels,t?.thinkingLevel??e.thinkingLevels?.[0]??"off")}))}}else if(t.selectedModel){let e=t.selectedModel;C(t=>({...e,thinkingLevel:j(e.thinkingLevels,t?.thinkingLevel??e.thinkingLevel??"off")}))}}catch{}};t();let n=(0,g.Sy)(t);return()=>{e=!1,n()}},[]);let L=(0,i.Kr)(()=>ea(A?.thinkingLevels),[A]);(0,i.vJ)(()=>{A?.thinkingLevel&&T(A.thinkingLevel)},[A?.thinkingLevel]);let M=e=>{let t=e.map(e=>({id:Math.random().toString(36).substring(7),file:e,preview:e.type.startsWith("image/")?URL.createObjectURL(e):""}));for(let e of(F(e=>[...e,...t]),t)){if(!e.file.type.startsWith("image/"))continue;let t=new FileReader;t.onload=()=>{let n=t.result.split(",")[1];n&&F(t=>t.map(t=>t.id===e.id?{...t,dataBase64:n}:t))},t.readAsDataURL(e.file)}},P=e=>{(t.trim()||0!==D.length)&&(s(D,e),F([]))},E="mobile"===v;return(0,r.FD)("div",{className:`relative border border-ink/20 rounded-md bg-paper focus-within:border-ink transition-colors flex flex-col shadow-sm ${o}`,children:[(0,r.Y)(ei,{attachments:D,onFilesSelected:M,onRemove:e=>{F(t=>{let n=t.find(t=>t.id===e);return n&&n.preview&&URL.revokeObjectURL(n.preview),t.filter(t=>t.id!==e)})}}),(0,r.Y)(et,{value:t,onChange:n,onSend:P,disabled:c,appSettings:d,rootPath:b,placeholder:c?"Please select a workspace above to start prompting...":"@ for files/agents; / for commands and skills; ! for shell; # for snippets (Paste images/files here)",className:`w-full bg-transparent border-none focus:outline-none resize-none text-ink placeholder-ink/40 disabled:opacity-50 disabled:cursor-not-allowed ${E?"px-3 py-3 text-base min-h-[68px] max-h-40":"px-3 py-3 text-sm min-h-[80px]"}`,onPaste:e=>{let t=e.clipboardData;t&&t.files.length>0&&(e.preventDefault(),M(Array.from(t.files)))},variant:v}),(0,r.Y)(G,{isMobile:E,selectedModel:A,onSelectModel:e=>{C(e),h?.(e.provider,e.id)},thinkingLevels:L,currentThinking:S,onSelectThinking:e=>{T(e),C(t=>t?{...t,thinkingLevel:e}:t),m?.(e)},onThinkingLevelChange:m,isGenerating:a,onStop:l,onSend:()=>P(),sendDisabled:c||!t.trim()&&0===D.length,accessMode:k,onSelectAccess:y})]})}var eo=n("rD"),ec=n("I"),ed=n("J"),eu=n("p"),ep=n("wU"),em=n("DT"),eh=n("rK"),ef=n("b0"),ex=n("pH");function eg(e){let{text:t,className:n="flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:s=10,iconClassName:a,copiedIconClassName:l="text-success",label:o,copiedLabel:c="Copied",wrapLabel:d=!1,copiedLabelClassName:u,title:m,onClick:h,resetMs:f=2e3}=e,{copied:x,flagCopied:g}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,[t,n]=(0,i.J0)(!1),r=(0,i.li)(null),s=(0,i.hb)(()=>{n(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),e)},[e]);return(0,i.vJ)(()=>()=>{r.current&&clearTimeout(r.current)},[]),{copied:t,flagCopied:s}}(f),b=async e=>{h?.(e),!t||await (0,ex.l)(t)&&g()},v=x?c:o;return(0,r.FD)("button",{type:"button",onClick:b,className:n,title:m,children:[x?(0,r.Y)(p.A,{size:s,className:l}):(0,r.Y)(ef.A,{size:s,className:a}),void 0!==v&&(d?(0,r.Y)("span",{className:x?u:void 0,children:v}):v)]})}function eb(e){let{thinking:t,defaultExpanded:n=!1,showSeparator:s=!1}=e,a="object"==typeof t&&!!t.isGenerating,[l,o]=(0,i.J0)(n||a),c=(0,i.li)(null);(0,i.vJ)(()=>{a&&o(!0)},[a]);let d="string"==typeof t?t:t.thought||"",p=d.match(/<system-notice[^>]*>([\s\S]*?)<\/system-notice>/),m=p?.[1]?.trim()??"",h=d.replace(/<system-notice[^>]*>[\s\S]*?<\/system-notice>/g,"").trim(),f="object"==typeof t?t.duration:void 0,g="object"==typeof t&&t.summary?t.summary:h.slice(0,100)+(h.length>100?"...":"");return((0,i.vJ)(()=>{if(!l||!a)return;let e=c.current;e&&(e.scrollTop=e.scrollHeight)},[l,h,a]),h)?(0,r.FD)("div",{className:`mx-3 ${s?"space-y-1.5":""}`,children:[s&&(0,r.FD)("div",{className:"flex items-center gap-2 px-1 pt-0.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/35",children:"Thinking"}),(0,r.Y)("span",{className:"h-px flex-1 bg-ink/8"})]}),(0,r.FD)("div",{className:"overflow-hidden rounded-xl border border-ink/10 bg-paper transition-colors hover:border-ink/20",children:[(0,r.FD)("button",{type:"button",onClick:()=>o(e=>!e),className:"flex w-full items-center gap-2.5 px-3 py-2.5 text-left transition-colors hover:bg-ink/[0.03] cursor-pointer select-none","aria-expanded":l,children:[(0,r.Y)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink/70",children:(0,r.Y)(x.A,{size:13})}),(0,r.FD)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"text-[12px] font-semibold tracking-tight text-ink",children:"Thinking"}),a&&(0,r.Y)("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/60 animate-pulse"})]}),!l&&g&&(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/45",children:g})]}),f&&(0,r.Y)("span",{className:"shrink-0 rounded-full bg-ink/5 px-2 py-0.5 font-mono text-[10px] text-ink/50",children:f}),(0,r.Y)(u.A,{size:14,className:`shrink-0 text-ink/35 transition-transform duration-200 ${l?"rotate-180":""}`})]}),l&&(0,r.FD)("div",{className:"border-t border-ink/8 bg-canvas/40 px-3 py-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between pb-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Model Reasoning & Strategy"}),(0,r.Y)(eg,{text:h,className:"flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",title:"Copy thinking",wrapLabel:!0,label:"Copy"})]}),m&&(0,r.FD)("div",{className:"mb-2 flex items-start gap-2.5 rounded-lg border border-ink/15 bg-paper px-3 py-2.5",children:[(0,r.Y)("span",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-ink/10",children:(0,r.Y)(em.A,{size:13,className:"text-ink/70"})}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.Y)("div",{className:"mb-0.5 text-[9.5px] font-semibold uppercase tracking-[0.12em] text-ink/50",children:"System Notice"}),(0,r.Y)("div",{className:"text-[12px] leading-relaxed text-ink/85",children:(0,r.Y)(eh.T,{content:m,className:"text-[12px] text-ink/85 leading-relaxed"})})]})]}),(0,r.Y)("div",{ref:c,className:"max-h-72 overflow-auto border-l-2 border-ink/15 py-1 pl-3 text-ink/80 scrollbar-overlay-container scrollbar-overlay-static select-text",children:(0,r.Y)(eh.T,{content:h,className:"text-[12px] leading-relaxed text-ink/85 [&_.code-block]:my-2 [&_p]:my-1.5 [&_ul]:my-1.5 [&_ol]:my-1.5"})})]})]})]}):null}function ev(e){if(!0===e.synthetic||"skipped"===e.status||"aborted"===e.status)return!0;let t=e.details;return t?.__synthetic===!0||t?.source==="assistant_stop_skipped"||t?.executed===!1}var ek=n("N"),ey=n("Jr"),eN=n("SR"),ew=n("aP"),eY=n("AB"),eD=n("uV"),eF=n("DK"),eA=n("WO"),eC=n("R"),eS=n("bt"),eT=n("k"),ez=n("wJ"),e$=n("s0");let ej=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[()][0-9A-B]|\x1b\[[0-9;?]*[A-Za-z]/g;function eL(e){return e?e.includes("\x1b")?e.replace(ej,"").replace(/\r\n/g,"\n").replace(/\r/g,"\n"):e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"):""}let eM=/^[A-Za-z_][A-Za-z0-9_.:-]*/,eP=/([A-Za-z_:][A-Za-z0-9_.:-]*)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g;function eE(e){return"system-reminder"===e||"reminder"===e}function eR(e,t){let n="";for(let r=t;r<e.length;r+=1){let t=e[r];if(n)t===n&&(n="");else if('"'===t||"'"===t)n=t;else if(">"===t)return r}return -1}function eI(e,t){let n=e.slice(t,t+9);if(n.startsWith("\x3c!--")){let n=e.indexOf("--\x3e",t+4);return -1===n?void 0:{kind:"other",name:"",attrs:"",end:n+3}}if("<![CDATA["===n){let n=e.indexOf("]]>",t+9);return -1===n?void 0:{kind:"other",name:"",attrs:"",end:n+3}}if("!"===e[t+1]||"?"===e[t+1]){let n=eR(e,t+2);return -1===n?void 0:{kind:"other",name:"",attrs:"",end:n+1}}let r="/"===e[t+1],i=t+(r?2:1),s=eM.exec(e.slice(i,i+64))?.[0];if(!s)return;let a=eR(e,i+s.length);if(-1===a)return;let l=e.slice(i+s.length,a);return r?{kind:"end",name:s,attrs:l,end:a+1}:{kind:"/"===e[a-1]?"self":"start",name:s,attrs:l,end:a+1}}function eO(e){let t=e.search(/\S/);if(-1===t||"<"!==e[t])return;let n=eI(e,t);if(!n||"start"!==n.kind)return;let r=[n.name];for(let t=n.end;t<e.length;){if("<"!==e[t]){t+=1;continue}let i=eI(e,t);if(!i)break;if("start"===i.kind)r.push(i.name);else if("end"===i.kind){if(r.pop()!==i.name)return;if(0===r.length){let r=e.slice(i.end).trim();if(r.startsWith("<"))return;return{tag:n.name,attributes:function(e){let t={};for(let n of e.matchAll(eP))t[n[1]]=n[2]??n[3]??n[4]??"";return t}(n.attrs),inner:function(e){let t=e.split("\n");for(t.length>1&&!t[0].trim()&&t.shift();t.length>1&&!t[t.length-1].trim();)t.pop();let n=1/0;for(let e of t)e.trim()&&(n=Math.min(n,e.length-e.trimStart().length));return Number.isFinite(n)?0===n?t.join("\n"):t.map(e=>e.slice(Math.min(n,e.length-e.trimStart().length))).join("\n"):""}(e.slice(n.end,t)),...r?{rest:r}:{}}}}t=i.end}}var eJ=n("yy"),e_=n("t");function eW(e){let t,{tool:n,icon:s,title:a,subtitle:l,meta:o,isOpen:c,onToggle:d,defaultExpanded:m=!1,alwaysExpanded:h=!1,children:f}=e,[x,g]=(0,i.J0)(m),b=!h,v=h||(void 0!==c?c:x),k=n.status||(n.error?"error":"success"),y="running"===k,N=!!f,w=ev(n);return(0,r.FD)("div",{className:`group overflow-hidden rounded-xl border transition-all duration-200 ${"error"===k&&!w?"border-error/25 bg-error/[0.03]":y?"border-ink/15 bg-paper":w?"border-dashed border-ink/15 bg-paper/60 opacity-80":"border-ink/10 bg-paper hover:border-ink/20"} ${v?"shadow-sm":""}`,children:[(0,r.FD)("button",{type:"button",onClick:()=>{N&&b&&(d?d():g(e=>!e))},disabled:!N||!b,"aria-expanded":v,className:`flex w-full items-center gap-2.5 px-3 py-2.5 text-left transition-colors ${N&&b?"cursor-pointer hover:bg-ink/[0.03]":"cursor-default"} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`,children:[(0,r.Y)("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg transition-colors ${"error"===k&&!w?"bg-error/10 text-error":y?"bg-ink/8 text-ink":"bg-ink/5 text-ink/70 group-hover:bg-ink/8"}`,children:s}),(0,r.FD)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"truncate text-[12px] font-semibold tracking-tight text-ink",children:a}),(t="h-1.5 w-1.5 rounded-full","running"===k?(0,r.Y)("span",{className:`${t} bg-ink/60 animate-pulse`}):w?(0,r.Y)("span",{className:`${t} bg-ink/30`}):"error"===k?(0,r.Y)("span",{className:`${t} bg-error`}):(0,r.Y)("span",{className:`${t} bg-success`}))]}),l&&(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/45",children:l})]}),(0,r.FD)("span",{className:"flex shrink-0 items-center gap-2",children:[o,function(e){if(ev(e))return(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-ink/8 px-2 py-0.5 text-[10px] font-semibold text-ink/50",children:[(0,r.Y)(eJ.A,{size:10})," Skipped"]});let t=e.status||(e.error?"error":"success");return"error"===t?(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-error/10 px-2 py-0.5 text-[10px] font-semibold text-error",children:[(0,r.Y)(eu.A,{size:10})," Failed"]}):"running"===t?(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-ink/8 px-2 py-0.5 text-[10px] font-semibold text-ink/60",children:[(0,r.Y)(e_.A,{size:10,className:"animate-spin"})," Running"]}):(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-success/10 px-2 py-0.5 text-[10px] font-semibold text-success",children:[(0,r.Y)(p.A,{size:10})," Done"]})}(n),N&&b&&(0,r.Y)(u.A,{size:14,className:`text-ink/35 transition-transform duration-200 ${v?"rotate-180":""}`})]})]}),v&&N&&(0,r.Y)("div",{className:"border-t border-ink/8 bg-canvas/40 px-3 py-3 code-surface",children:f})]})}var eK=n("DU"),eU=n("Po");function eH(e){let{text:t}=e,n=(0,i.Kr)(()=>(function(e){let t=[],n=null;for(let r of e.split(/\r?\n/)){if(r.startsWith("diff --git ")){n&&t.push(n),n=null;continue}if(r.startsWith("--- ")){n?n.oldPath=r.slice(4).replace(/^[ab]\//,""):n={oldPath:r.slice(4).replace(/^[ab]\//,""),newPath:"",lines:[]};continue}if(r.startsWith("+++ ")){n||(n={oldPath:"",newPath:"",lines:[]}),n.newPath=r.slice(4).replace(/^[ab]\//,"");continue}if(!n)if(!(r.startsWith("@@")||r.startsWith("+")||r.startsWith("-")))continue;else n={oldPath:"",newPath:"",lines:[]};r.startsWith("@@")?n.lines.push({kind:"meta",text:r}):r.startsWith("+")&&!r.startsWith("+++")?n.lines.push({kind:"add",text:r.slice(1)}):r.startsWith("-")&&!r.startsWith("---")?n.lines.push({kind:"del",text:r.slice(1)}):n.lines.push({kind:"context",text:r.startsWith(" ")?r.slice(1):r})}return n&&t.push(n),t})(t),[t]),s=(0,eU.w)(),a=(0,i.Kr)(()=>n.map(e=>{let t=(0,eK.sQ)(e.newPath||e.oldPath);return(0,eK.O9)(e.lines.map(e=>"meta"===e.kind?"":e.text).join("\n"),t)}),[n,s]);if(0===n.length)return(0,r.Y)("pre",{className:"max-h-48 overflow-auto whitespace-pre overflow-x-auto rounded-lg border border-ink/8 bg-paper p-3 font-mono text-[11px] leading-relaxed text-ink/80 select-text",children:t});let l=n.reduce((e,t)=>{for(let n of t.lines)"add"===n.kind?e.added++:"del"===n.kind&&e.removed++;return e},{added:0,removed:0});return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/60",children:n[0]?.newPath||n[0]?.oldPath||"diff"}),n.length>1&&(0,r.FD)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:[n.length," files"]}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-1.5 font-mono text-[10px]",children:[(0,r.FD)("span",{className:"text-success",children:["+",l.added]}),(0,r.FD)("span",{className:"text-error",children:["-",l.removed]})]})]}),(0,r.Y)("div",{className:"max-h-56 overflow-auto bg-paper font-mono text-[11px] leading-relaxed select-text",children:n.map((e,t)=>(0,r.Y)("div",{className:t>0?"border-t border-ink/6":"",children:e.lines.map((e,n)=>{let i="add"===e.kind?"bg-success/[0.07]":"del"===e.kind?"bg-error/[0.07]":"meta"===e.kind?"bg-ink/[0.04]":"",s="add"===e.kind?"text-success":"del"===e.kind?"text-error":"meta"===e.kind?"text-ink/45":"text-ink/70",l="add"===e.kind?"+":"del"===e.kind?"-":"meta"===e.kind?"@":" ",o=a[t]?.[n]||"";return(0,r.FD)("div",{className:`flex px-2.5 ${i}`,children:[(0,r.Y)("span",{className:`w-4 shrink-0 select-none font-bold ${s}`,children:l}),"meta"!==e.kind&&o?(0,r.Y)("span",{className:"shiki min-w-0 flex-1 whitespace-pre-wrap break-all",dangerouslySetInnerHTML:{__html:o}}):(0,r.Y)("span",{className:`min-w-0 flex-1 whitespace-pre-wrap break-all ${s}`,children:e.text||" "})]},n)})},t))})]})}var eB=n("m"),eq=n("rr"),eG=n("F"),eV=n("k8"),eZ=n("dg");function eQ(e){let{jsonString:t,title:n,maxHeightClass:s,showHeader:a=!0,className:l="",compact:o=!1,icon:c}=e,d=(0,i.Kr)(()=>t.split("\n"),[t]),u=(0,eU.w)(),p=(0,i.Kr)(()=>(0,eK.PH)(t),[t,u]);return(0,r.FD)("div",{className:`overflow-hidden ${o?"rounded-md":"rounded-lg"} border border-ink/8 bg-paper ${l}`,children:[a&&(0,r.FD)("div",{className:`flex items-center justify-between border-b border-ink/6 bg-canvas/40 ${o?"px-2.5 py-1":"px-3 py-1.5"}`,children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 min-w-0",children:[c||(0,r.Y)(eZ.A,{size:o?10.5:11,className:"text-ink/60 shrink-0"}),(0,r.Y)("span",{className:`font-mono ${o?"text-[10px]":"text-[10.5px]"} font-semibold text-ink truncate`,children:n||"JSON"}),(0,r.Y)("span",{className:`rounded bg-ink/5 px-1.5 py-0.2 font-mono ${o?"text-[8.5px]":"text-[9px]"} uppercase tracking-wider text-ink/50 shrink-0`,children:"JSON"}),(0,r.FD)("span",{className:`font-mono ${o?"text-[9px]":"text-[9.5px]"} text-ink/40 shrink-0`,children:[d.length," ",1===d.length?"line":"lines"]})]}),(0,r.Y)(eg,{text:t,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink shrink-0",title:"Copy JSON",onClick:e=>e.stopPropagation(),label:"Copy"})]}),(0,r.FD)("div",{className:`flex ${s||(o?"max-h-40":"max-h-56")} items-start overflow-x-auto font-mono ${o?"text-[10.5px] leading-snug":"text-[11px] leading-relaxed"} select-text`,children:[(0,r.Y)("div",{className:`sticky left-0 flex-shrink-0 select-none border-r border-ink/6 bg-canvas/50 ${o?"py-1.5 pl-2 pr-1.5 text-[9.5px]":"py-2 pl-2.5 pr-2 text-[10px]"} text-right text-ink/25`,children:d.map((e,t)=>(0,r.Y)("div",{children:t+1},t))}),(0,r.Y)("pre",{className:`flex-1 overflow-x-auto ${o?"p-1.5":"p-2"} whitespace-pre text-ink/85 font-mono`,dangerouslySetInnerHTML:{__html:p}})]})]})}var eX=n("U8");let e0={running:{icon:(0,r.Y)(e_.A,{size:11,className:"animate-spin text-ink/50"}),label:"running"},done:{icon:(0,r.Y)(eB.A,{size:11,className:"text-success"}),label:"done"},failed:{icon:(0,r.Y)(eq.A,{size:11,className:"text-error"}),label:"failed"},aborted:{icon:(0,r.Y)(eG.A,{size:11,className:"text-ink/35"}),label:"aborted"}};function e1(e){return"number"==typeof e?(0,eX.Rk)(e)??"":""}function e5(e){return"number"==typeof e?(0,eX.BD)(e,3):""}function e2(e){let{tool:t}=e,[n,s]=(0,i.J0)(!1),[a,l]=(0,i.J0)(!0),o=t.details??{},c=Array.isArray(o.results)?o.results:[],d=Array.isArray(o.progress)?o.progress:[],p=(0,i.Kr)(()=>t.output?(0,eK.Bl)(t.output):{isValid:!1},[t.output]),m="object"==typeof t.input&&null!==t.input?t.input:void 0,h="string"==typeof m?.context?m.context.trim():"",f=Array.isArray(m?.tasks)?m.tasks:[],x=(0,i.Kr)(()=>c.length>0?c:d.length>0?d:f.length>0?f.map((e,n)=>({id:`task-sub-${n}`,name:e.name,agent:e.agent||"scout",task:e.task,status:"success"===t.status?"done":"running"})):[],[c,d,f,t.status]);if(0===x.length&&!t.output&&!h)return null;let g=x.reduce((e,t)=>e+("number"==typeof t.tokens?t.tokens:0),0),b=x.reduce((e,t)=>e+("number"==typeof t.cost?t.cost:0),0);return(0,r.FD)("div",{className:"space-y-2.5",children:[x.length>0&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 px-2.5 py-1.5",children:[(0,r.FD)("span",{className:"flex items-center gap-1 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(A.A,{size:11,className:"text-ink/60"}),"Subagents"]}),(0,r.FD)("span",{className:"ml-auto font-mono text-[10px] text-ink/45",children:[x.length," ",x.length>1?"agents":"agent",g?` \xb7 ${e1(g)} tok`:"",b?` \xb7 ${e5(b)}`:""]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 px-2.5 py-1",children:x.map((e,t)=>{var n;let i=!0===e.aborted?"aborted":"string"==typeof e.error&&e.error?"failed":"number"==typeof e.exitCode?0===e.exitCode?"done":"failed":"done"===e.status||"completed"===e.status||"success"===e.status?"done":"failed"===e.status?"failed":"aborted"===e.status?"aborted":"running",s=e0[i],a="string"==typeof e.name&&e.name?e.name:null,l="string"==typeof e.agent?e.agent:"scout",o=[e1(e.tokens),e5(e.cost),"running"!==i?"number"!=typeof(n=e.durationMs)||!Number.isFinite(n)||n<1e3?"":`${Math.floor(n/1e3)}s`:""].filter(Boolean).join(" · ");return(0,r.FD)("div",{className:"flex items-center gap-2 py-1.5 text-[11.5px]",children:[(0,r.Y)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-ink/[0.04]",children:s.icon}),(0,r.Y)("span",{className:"shrink-0 font-mono text-[10.5px] font-semibold text-ink",children:a||l}),a&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/50",children:l}),(0,r.Y)("span",{className:"ml-auto shrink-0 font-mono text-[9.5px] text-ink/40",children:o||("done"===i?"settled":"running")})]},"string"==typeof e.id?e.id:`row-${t}`)})})]}),h&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("button",{type:"button",onClick:()=>s(e=>!e),className:"flex w-full cursor-pointer items-center justify-between px-2.5 py-1.5 text-left transition-colors hover:bg-ink/[0.02]",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(eV.A,{size:11,className:"text-ink/60"}),"Goal & Constraints"]}),(0,r.Y)(u.A,{size:12,className:`text-ink/40 transition-transform duration-150 ${n?"rotate-180":""}`})]}),n&&(0,r.Y)("div",{className:"border-t border-ink/8 bg-canvas/30 px-3 py-2 text-[11.5px] text-ink/80 select-text leading-relaxed",children:(0,r.Y)(eh.T,{content:h})})]}),f.length>0&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("button",{type:"button",onClick:()=>l(e=>!e),className:"flex w-full cursor-pointer items-center justify-between px-2.5 py-1.5 text-left transition-colors hover:bg-ink/[0.02]",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(eN.A,{size:11,className:"text-ink/60"}),"Task Brief & Specification"]}),(0,r.Y)(u.A,{size:12,className:`text-ink/40 transition-transform duration-150 ${a?"rotate-180":""}`})]}),a&&(0,r.Y)("div",{className:"divide-y divide-ink/8 border-t border-ink/8 bg-canvas/30",children:f.map((e,t)=>(0,r.FD)("div",{className:"p-3 space-y-1.5 text-[11.5px] text-ink/80 select-text",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)("span",{className:"font-semibold text-ink text-[12px]",children:e.name||`Task #${t+1}`}),e.agent&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9.5px] text-ink/60",children:e.agent})]}),e.task&&(0,r.Y)("div",{className:"text-ink/85 leading-relaxed font-sans",children:(0,r.Y)(eh.T,{content:e.task})})]},t))})]}),t.output&&(p.isValid&&p.pretty?(0,r.Y)(eQ,{jsonString:p.pretty,title:"Yield Output",maxHeightClass:"max-h-72",showHeader:!0}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 border-b border-ink/8 px-2.5 py-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(A.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Yield Output"})]}),(0,r.Y)("div",{className:"bg-canvas/30 px-3 py-2 text-[11px] font-sans leading-relaxed text-ink/80 select-text",children:(0,r.Y)(eh.T,{content:t.output})})]}))]})}function e4(e){let t=e.replace(/:$/,"").trim();return(t=(t=(t=(t=t.replace(/^active\s+phase(?:\s+\d+\/\d+)?(?:\s*[:\-]\s*|\s+)?/i,"")).replace(/^["']|["']$/g,"")).replace(/\s*\(\d+(?:\/\d+)?\s*(?:done|remaining|tasks)?\)$/i,"")).replace(/^\((.+)\)$/,"$1")).trim()||"Tasks"}function e3(e){let t,n=e.input,r="object"==typeof n&&null!==n?n:void 0,i=e.output||"";r?.op==="done"&&r.task?t=`Completed: ${r.task}`:r?.op==="init"&&(t="Initialized Todo List");let s=i.split(/\r?\n/),a=[],l={phase:"Tasks",tasks:[]},o=!1;for(let e of s){let t=e.trim();if(!t)continue;if(t.endsWith(":")&&!t.startsWith("Overall")&&!t.startsWith("Remaining")){let e=e4(t);l.tasks.length>0&&a.push(l),l={phase:e,tasks:[]},o=!0;continue}let n=t.match(/^(?:[-*]\s*)?\[([ xX])\]\s*(.+)$/);if(n){let e=n[1].toLowerCase(),t=n[2].trim(),r="x"===e?"done":"pending";(t.includes("(in progress)")||t.includes("[in_progress]"))&&(r="in_progress",t=t.replace(/\(in progress\)/gi,"").replace(/\[in_progress\]/gi,"").trim()),l.tasks.push({text:t,status:r,phase:l.phase});continue}let r=t.match(/^-\s*(.+?)\s*\[(in_progress|pending|done)\](?:\s*\((.+?)\))?$/);if(r&&!o){let e=r[1].trim(),t=r[2],n=e4(r[3]?.trim()||"Tasks"),i=a.find(e=>e4(e.phase).toLowerCase()===n.toLowerCase());i||(i={phase:n,tasks:[]},a.push(i)),i.tasks.push({text:e,status:t,phase:n})}}if(l.tasks.length>0&&!a.includes(l)&&a.push(l),0===a.length&&Array.isArray(r?.list))for(let e of r.list){let t=e4(e.phase||"Tasks"),n=(e.items||[]).map(e=>({text:e,status:"pending",phase:t}));a.push({phase:t,tasks:n})}let c=function(e){let t=new Map;for(let n of e){if(!n.tasks.length)continue;let e=e4(n.phase),r=e.toLowerCase(),i=t.get(r);if(i){let t=n.tasks.length>=i.tasks.length?n.tasks:i.tasks,r=t===n.tasks?i.tasks:n.tasks,s=new Map;for(let n of t)s.set(n.text.toLowerCase().trim(),{...n,phase:e});for(let t of r){let n=t.text.toLowerCase().trim(),r=s.get(n);r?"done"===t.status?r.status="done":"in_progress"===t.status&&"done"!==r.status&&(r.status="in_progress"):s.set(n,{...t,phase:e})}i.phase=e,i.tasks=Array.from(s.values())}else t.set(r,{phase:e,tasks:[...n.tasks]})}let n=Array.from(t.values()),r=[];for(let e=0;e<n.length;e++){let t=n[e],i=t.tasks.map(e=>e.text.toLowerCase().trim()),s=!1;for(let r=0;r<n.length;r++){if(e===r)continue;let a=n[r],l=new Set(a.tasks.map(e=>e.text.toLowerCase().trim()));if(a.tasks.length>=t.tasks.length&&i.every(e=>l.has(e))){for(let e of t.tasks){let t=a.tasks.find(t=>t.text.toLowerCase().trim()===e.text.toLowerCase().trim());t&&("done"===e.status?t.status="done":"in_progress"===e.status&&"done"!==t.status&&(t.status="in_progress"))}s=!0;break}}s||r.push(t)}return r}(a);if(r?.op==="done"&&r.task){let e=String(r.task).toLowerCase().trim();for(let t of c){let n=t.tasks.find(t=>t.text.toLowerCase().trim()===e);n&&(n.status="done")}}let d=0,u=0,p=0;for(let e of c)for(let t of e.tasks)"done"===t.status?d++:"in_progress"===t.status?u++:p++;let m=d+u+p,h=i.match(/Overall:\s*(\d+)\/(\d+)\s*done/i)||i.match(/(\d+)\s+of\s+(\d+)\s+completed/i);if(h){let e=parseInt(h[1],10),t=parseInt(h[2],10);t>=m&&(d=e,p=Math.max(0,(m=t)-d-u))}let f=[];d>0&&f.push(`${d} complete`),u>0&&f.push(`${u} in progress`),p>0&&f.push(`${p} pending`);let x=f.length>0?f.join(" · "):m>0?`${m} items`:"";return{groups:c,totalDone:d,totalInProgress:u,totalPending:p,totalTasks:m,opBadge:t,summaryText:x}}var e8=n("uF");let e6={github:"GitHub",openai:"OpenAI",gitlab:"GitLab",sqlite:"SQLite",postgresql:"PostgreSQL",mysql:"MySQL",mongodb:"MongoDB",redis:"Redis",docker:"Docker",kubernetes:"Kubernetes",vercel:"Vercel",bun:"Bun",node:"Node",deno:"Deno",react:"React",vue:"Vue",svelte:"Svelte",angular:"Angular",next:"Next",nuxt:"Nuxt",remix:"Remix",tailwind:"Tailwind",prisma:"Prisma",zod:"Zod",axios:"Axios",express:"Express",fastify:"Fastify",koa:"Koa",hono:"Hono",elysia:"Elysia",drizzle:"Drizzle",kysely:"Kysely",biome:"Biome",oxc:"Oxc",rolldown:"Rolldown",turbopack:"Turbopack",vite:"Vite",webpack:"Webpack",rollup:"Rollup",esbuild:"Esbuild",babel:"Babel",swc:"SWC",typescript:"TypeScript",javascript:"JavaScript",coffeescript:"CoffeeScript",dart:"Dart",kotlin:"Kotlin",swift:"Swift",rust:"Rust",python:"Python",ruby:"Ruby",php:"PHP",perl:"Perl",lua:"Lua",scala:"Scala",haskell:"Haskell",elixir:"Elixir",erlang:"Erlang",clojure:"Clojure",ocaml:"OCaml",zig:"Zig",nim:"Nim",crystal:"Crystal",julia:"Julia",groovy:"Groovy",powershell:"PowerShell",bash:"Bash",zsh:"Zsh",fish:"Fish",grep:"Grep",find:"Find",glob:"Glob",ls:"Ls",cat:"Cat",echo:"Echo",mkdir:"Mkdir",rm:"Rm",cp:"Cp",mv:"Mv",touch:"Touch",chmod:"Chmod",chown:"Chown",sudo:"Sudo",apt:"Apt",brew:"Brew",npm:"Npm",pnpm:"Pnpm",yarn:"Yarn",playwright:"Playwright",cypress:"Cypress",puppeteer:"Puppeteer",selenium:"Selenium",jest:"Jest",vitest:"Vitest",mocha:"Mocha",chai:"Chai",sinon:"Sinon",karma:"Karma",jasmine:"Jasmine",qunit:"QUnit",ava:"Ava",tape:"Tape",lodash:"Lodash",underscore:"Underscore",ramda:"Ramda",rxjs:"RxJS",redux:"Redux",zustand:"Zustand",jotai:"Jotai",recoil:"Recoil",mobx:"MobX",xstate:"XState",framer:"Framer",motion:"Motion",gsap:"GSAP",anime:"Anime",three:"Three",babylon:"Babylon",pixi:"Pixi",phaser:"Phaser",matter:"Matter",planck:"Planck",rapier:"Rapier",cannon:"Cannon",ammo:"Ammo",bullet:"Bullet",box2d:"Box2D",chipmunk:"Chipmunk",verlet:"Verlet",ode:"ODE",physx:"PhysX",havok:"Havok",unity:"Unity",unreal:"Unreal",godot:"Godot",bevy:"Bevy",amethyst:"Amethyst",macroquad:"Macroquad",miniquad:"Miniquad",sdl:"SDL",sfml:"SFML",glfw:"GLFW",opengl:"OpenGL",vulkan:"Vulkan",directx:"DirectX",metal:"Metal",webgpu:"WebGPU",webgl:"WebGL",canvas:"Canvas",webaudio:"WebAudio",webmidi:"WebMIDI",webrtc:"WebRTC",websocket:"WebSocket",sse:"SSE",eventsource:"EventSource",fetch:"Fetch",xhr:"XHR",ky:"Ky",got:"Got",undici:"Undici",superagent:"Superagent",request:"Request",needle:"Needle",bent:"Bent",r2:"R2",s3:"S3",gcs:"GCS",azure:"Azure",blob:"Blob",storage:"Storage",firebase:"Firebase",supabase:"Supabase",pocketbase:"PocketBase",appwrite:"Appwrite",nhost:"Nhost",hasura:"Hasura",graphql:"GraphQL",rest:"REST",grpc:"gRPC",trpc:"tRPC",soap:"SOAP",mqtt:"MQTT",amqp:"AMQP",kafka:"Kafka",rabbitmq:"RabbitMQ",pubsub:"PubSub",nats:"NATS",zeromq:"ZeroMQ",dds:"DDS",coap:"CoAP",ble:"BLE",zigbee:"Zigbee",lora:"LoRa",nbiot:"NB-IoT",lte:"LTE",wifi:"Wi-Fi",ethernet:"Ethernet",usb:"USB",hdmi:"HDMI",displayport:"DisplayPort",thunderbolt:"Thunderbolt",pcie:"PCIe",nvme:"NVMe",sata:"SATA",ddr:"DDR",ecc:"ECC",xmp:"XMP",docsis:"DOCSIS",gpon:"GPON",epon:"EPON",pon:"PON",olt:"OLT",ont:"ONT",onu:"ONU",odn:"ODN",p2mp:"P2MP",p2p:"P2P",ftth:"FTTH",fttb:"FTTB",fttc:"FTTC",fttn:"FTTN",hfc:"HFC",dsl:"DSL",adsl:"ADSL",vdsl:"VDSL",sdsl:"SDSL",shdsl:"SHDSL",isdn:"ISDN",pstn:"PSTN",pots:"POTS",voip:"VoIP",sip:"SIP",rtp:"RTP",rtcp:"RTCP",rtsp:"RTSP",hls:"HLS",dash:"DASH",mpeg:"MPEG",av1:"AV1",vp9:"VP9",vp8:"VP8",hevc:"HEVC",avc:"AVC",mp4:"MP4",mkv:"MKV",avi:"AVI",mov:"MOV",wmv:"WMV",flv:"FLV",webm:"WebM",ogg:"OGG",mp3:"MP3",wav:"WAV",flac:"FLAC",aac:"AAC",midi:"MIDI",opus:"OPUS",alac:"ALAC",ape:"APE",wavpack:"WavPack"},e9=new Set(["MCP","AST","LSP","DAP","RPC","SSH","TTS","STT","URL","API","JSON","SQL","CSS","HTML","JS","TS","PDF","PR","UI","UX","DB","CLI","TUI","IDE","HTTP","HTTPS","OAUTH","YAML","XML","CSV","PNG","SVG","WASM","AI","ML","LLM","RAG","SDK","GUI","DOM","ESM","CJS","UMD","IIFE","XHR","TCP","UDP","DNS","IP","GPU","CPU","RAM","SSD","HDD","FIFO","PTY","TTY","WEB"]);function e7(e){if(!e)return e;let t=e.split("__"),n=t.length>1?t[0]:null,r=t[t.length-1].split(/[_\-\s]+/).filter(Boolean).map(e=>{let t=e6[e.toLowerCase()];if(t)return t;let n=e.toUpperCase();return e9.has(n)?n:e.charAt(0).toUpperCase()+e.slice(1)}).join(" ");return n?`${n.toUpperCase()} ${r}`:r}function te(e){var t;let{envelope:n}=e,i=eE(t=n.tag)?{icon:(0,r.Y)(e$.A,{size:12}),badge:"bg-warning/10 text-warning"}:"error"===t||"failure"===t?{icon:(0,r.Y)(eu.A,{size:12}),badge:"bg-error/10 text-error"}:{icon:(0,r.Y)(C.A,{size:12}),badge:"bg-info/10 text-info"};return(0,r.FD)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.Y)("span",{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded ${i.badge}`,children:i.icon}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/60",children:e7(n.tag)}),Object.entries(n.attributes).map(e=>{let[t,n]=e;return(0,r.Y)("span",{title:`${t}=${n}`,className:"max-w-[240px] truncate rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9.5px] text-ink/60",children:n?`${t}=${n}`:t},t)})]})}let tt=/(^|\n)\s*(#{1,6}\s|```|`[^`\n]+`|>|[-*+]\s|\d+\.\s|\[[^\]]+\]\([^)]+\)|\|.*\|)/;function tn(e){let t=eO(e),n=t?[t.inner,t.rest].filter(Boolean).join("\n\n"):e;return{content:n,format:function(e){if(!e)return"text";let t=e.trim();if(!t)return"text";if(t.includes("```"))return"markdown";if(t.length<1e5&&(t.startsWith("{")||t.startsWith("[")))try{let e=JSON.parse(t);if(null!==e&&"object"==typeof e)return"json"}catch{}return tt.test(t)?"markdown":/^<(?:!doctype|html|div|section|article|table|ul|ol|h[1-6]|p|pre|code|span|a|b|strong|em|i|blockquote|form|button|input|img|nav|header|footer|main|aside|figure|figcaption|details|summary|label|select|option|textarea|video|audio|iframe|script|style|link|meta|title|body|head)\b/i.test(t)||/<[a-z][a-z0-9-]*\s[^>]*>[\s\S]*<\/[a-z][a-z0-9-]*>/i.test(t)&&/<\/[a-z][a-z0-9-]*>/i.test(t)?"html":"text"}(n),...t?{envelope:t}:{}}}function tr(e,t){if(!e||"markdown"===t)return e;let n=0;for(let t of e.match(/`+/g)??[])n=Math.max(n,t.length);let r="`".repeat(Math.max(3,n+1));return`${r}${"text"===t?"":t}
8
+ `}w.use((0,a.A)()),w.use({renderer:{code:e=>e.raw&&/^```/.test(e.raw)||(e.text??"").includes("\n")?function(e){let t=e.lang?.trim()||"text",n=e.text??"";if("mermaid"===t){let e,t;return e=`<pre><code class="language-mermaid">${k(n)}</code></pre>`,t=N(n,e),`<div class="mermaid-block" data-mermaid="${encodeURIComponent(n)}" data-mermaid-state="pending">${t}</div>`}let r="text"===t?k(n):(0,o.wY)(n,t);return N(n,`<pre><code class="language-${t}">${r}</code></pre>`)}(e):`<code class="inline-code">${k(e.text??"")}</code>`,codespan:e=>`<code class="inline-code">${k(e.text??"")}</code>`}}),w.use({extensions:[{name:"inlineMath",level:"inline",start:e=>e.match(/\\\(/)?.index,tokenizer(e){let t=/^\\\(([\s\S]+?)\\\)/.exec(e);return t?{type:"inlineMath",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!1)},{name:"blockMath",level:"block",start:e=>e.match(/^\\\[/)?.index,tokenizer(e){let t=/^\\\[([\s\S]+?)\\\]/.exec(e);return t?{type:"blockMath",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!0)},{name:"blockMathDisplay",level:"block",start:e=>e.match(/^\$\$/)?.index,tokenizer(e){let t=/^\$\$([\s\S]+?)\$\$(?:\n|$)/.exec(e);return t?{type:"blockMathDisplay",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!0)},{name:"inlineMathDollar",level:"inline",start(e){let t=/(^|[^\w$])\$(?!\$)(?!\s)/.exec(e);return t?t.index+(t[1]?.length??0):void 0},tokenizer(e){let t=/^\$(?!\$)(?!\s)((?:\\\$|[^$])*?)(?<!\s)\$(?!\$)(?!\d)/.exec(e);return t?{type:"inlineMathDollar",raw:t[0],text:t[1]}:void 0},renderer:e=>y(e.text??"",!1)}]});let Y=/\[([^\]]*)\]\(streamdown:incomplete-link\)/g,D=new Map,F=null,A=null;function S(){let e=document.documentElement.dataset.theme||document.documentElement.getAttribute("data-theme");return"one-dark-pro-soft"===e||"noir"===e||"dark"===e?"dark":"default"}function C(e,t){return`${e}\0${t}`}async function T(e){return F&&A===e||(A=e,F=Promise.all([n.e("a3"),n.e("3y")]).then(n.bind(n,"Fl")).then(t=>(t.default.initialize({startOnLoad:!1,securityLevel:"strict",theme:e,layout:"dagre",suppressErrorRendering:!0,flowchart:{useMaxWidth:!1,wrappingWidth:1e5},sequence:{useMaxWidth:!1}}),t.default)).catch(e=>{throw F=null,e})),F}function z(e,t,n){let r=(e.dataset.mermaid??"").replace(/"/g,"&quot;");e.innerHTML=`<button type="button" class="code-copy-float" data-copy="${r}" aria-label="Copy diagram source"><svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg></button>`+t,e.dataset.mermaidState="done",e.dataset.mermaidTheme=n;let i=e.querySelector(":scope > svg"),s=Number(i?.getAttribute("width"));i&&Number.isFinite(s)&&s>0&&e.style.setProperty("--mermaid-diagram-max",`${Math.round(.8*s)}px`)}let $=0;async function j(e,t){let n=e.dataset.mermaid;if(null==n)return!1;let r=S(),i=decodeURIComponent(n),s=D.get(C(r,i))??null;if(s)return z(e,s,r),!0;if(t)return!0;e.dataset.mermaidState="rendering";try{let t=await T(r),{svg:n}=await t.render(`mermaid-svg-${Date.now()}-${$++}`,i);if(!e.isConnected)return!1;let s=function(e){if(!e||"u"<typeof window||!window.document)return e;let t=/href/.test(e);try{return c.A.sanitize(e,{USE_PROFILES:{html:!0,svg:!0,svgFilters:!0},ADD_TAGS:m,ADD_ATTR:[...h,...t?f:[]],HTML_INTEGRATION_POINTS:{"annotation-xml":!0,foreignobject:!0}})}catch{return e}}(n);if(D.size>=60){let e=D.keys().next().value;void 0!==e&&D.delete(e)}return D.set(C(r,i),s),z(e,s,r),!0}catch{return e.isConnected&&(e.dataset.mermaidState="error"),!1}}async function L(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=S(),r=Array.from(e.querySelectorAll(".mermaid-block")),i=await Promise.all(r.map(async e=>{let r=e.dataset.mermaidState,i=e.dataset.mermaidTheme===n;return"done"===r&&!!i&&!t.force||"rendering"!==r&&j(e,!0===t.cachedOnly)}));return{rendered:i.filter(Boolean).length,failed:i.filter(e=>!e).length}}var M=n("pH"),P=n("Po");let E="u"<typeof window?i.vJ:i.Nf;function R(e){let{content:t,className:n=""}=e,s=(0,i.li)(null),a=(0,P.w)(),o=(0,i.Kr)(()=>{let e,n;if(!t)return"";let r=(e=t.split("`").map((e,t)=>t%2==1?e:e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")).join("`"),n=(0,l.Ay)(e,{katex:!0,inlineKatex:!0}).replace(Y,(e,t)=>`<span class="md-incomplete-link">${t}</span>`),w.parse(n).trim());if(r.includes(g)&&b(),!r||"u"<typeof window||!window.document)return r;let i=/<svg[^>]*>/.test(r),s=r.includes("math-pending"),a=/class="[^"]*katex/.test(r)||i||s?{USE_PROFILES:{html:!0,mathMl:!0},ADD_TAGS:[...d,...i?u:[]],ADD_ATTR:["aria-hidden","aria-label","encoding","nonce","data-math","data-math-display",...i?p:[]]}:{USE_PROFILES:{html:!0}};try{return c.A.sanitize(r,a)}catch{return r}},[t,a]),m=o.includes("mermaid-block"),h=o.includes(g);(0,i.vJ)(()=>{if(!h||"u"<typeof window)return;let e=s.current;if(!e)return;let t=!1;(async()=>{if(e.isConnected&&(await v(e),t))return})();let n=new MutationObserver(()=>{let e=s.current;e?.isConnected&&v(e)});return n.observe(e,{childList:!0}),()=>{t=!0,n.disconnect()}},[h,o]),E(()=>{let e;if(!m||"u"<typeof window)return;let t=s.current;if(!t)return;let n=()=>{let e=s.current;e&&e.isConnected&&L(e)};n();let r=new MutationObserver(()=>{let t=s.current;t?.isConnected&&L(t,{cachedOnly:!0}),window.clearTimeout(e),e=window.setTimeout(n,120)});r.observe(t,{childList:!0});let i=()=>n();return window.addEventListener("omp:theme-changed",i),()=>{window.clearTimeout(e),r.disconnect(),window.removeEventListener("omp:theme-changed",i)}},[m,o]);let f=(0,i.hb)(e=>{let t=e.target.closest("button.code-copy-float");if(!t)return;let n=t.dataset.copy??"";n&&(e.preventDefault(),e.stopPropagation(),(0,M.l)(n).then(e=>{e&&(t.setAttribute("data-copied","true"),t.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"/></svg>',setTimeout(()=>{t.removeAttribute("data-copied"),t.innerHTML='<svg width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="9" y="9" width="13" height="13" rx="2"/><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"/></svg>'},2e3))}))},[]);return t?(0,r.Y)("div",{ref:s,className:`prose-content text-[13px] text-ink leading-relaxed select-text ${n}`,onClick:f,dangerouslySetInnerHTML:{__html:o}}):null}},R2(e,t,n){var r=n("j");function i(e){let{status:t}=e;if(t?.transport!=="websocket")return null;let n=!!t.connected,i=n?"WebSocket connected":"WebSocket disconnected";return(0,r.Y)("span",{role:"status","aria-label":i,title:i,className:"flex items-center flex-shrink-0 select-none",children:(0,r.Y)("span",{className:`w-1.5 h-1.5 rounded-full flex-shrink-0 ${n?"bg-success":"bg-error"}`})})}n.d(t,{c:()=>i})},Uo(e,t,n){var r=n("j"),i=n("m"),s=n("p"),a=n("F"),l=n("V");function o(e){let{status:t,live:n,size:o=12}=e,c={size:o,strokeWidth:2,"aria-hidden":!0};if("completed"===t)return(0,r.Y)(i.A,{...c,className:"text-success"});if("failed"===t)return(0,r.Y)(s.A,{...c,className:"text-error"});if("aborted"===t)return(0,r.Y)(a.A,{...c,className:"text-ink/40"});if(!1===n)return(0,r.Y)(l.A,{...c,className:"text-ink/30"});let d=Math.max(5,Math.round(o/2));return(0,r.Y)("span",{"aria-hidden":!0,className:"inline-block shrink-0 animate-pulse rounded-full bg-success",style:{width:d,height:d}})}n.d(t,{l:()=>o})},wu(e,t,n){n.d(t,{y:()=>d});var r=n("j"),i=n("H"),s=n("G"),a=n("p"),l=n("m"),o=n("S");function c(e){let{toast:t,onDismiss:n,duration:c}=e,[d,u]=(0,i.J0)(!1),p=c??t.duration??4e3,m=(0,i.li)(null);return(0,i.vJ)(()=>{let e=requestAnimationFrame(()=>u(!0)),r=setTimeout(()=>{u(!1),m.current=setTimeout(()=>n(t.id),200)},p);return()=>{cancelAnimationFrame(e),clearTimeout(r),m.current&&clearTimeout(m.current)}},[t.id,p,n]),(0,s.d5)((0,r.FD)("div",{className:`fixed bottom-4 right-4 z-[200] flex items-center space-x-2 bg-paper border shadow-2xl rounded-lg px-4 py-3 text-xs font-sans transition-all duration-200 ${"error"===t.type?"border-error/40":"border-ink/15"} ${d?"opacity-100 translate-y-0":"opacity-0 translate-y-2"}`,role:"status",children:["error"===t.type?(0,r.Y)(a.A,{size:15,className:"text-error flex-shrink-0"}):(0,r.Y)(l.A,{size:15,className:"text-success flex-shrink-0"}),(0,r.Y)("span",{className:"text-ink max-w-[320px]",children:t.message}),t.action&&(0,r.Y)("button",{type:"button",onClick:()=>{t.action?.onClick(),u(!1),m.current=setTimeout(()=>n(t.id),200)},className:"flex-shrink-0 px-2 py-0.5 rounded bg-ink text-paper font-semibold hover:opacity-80 transition-opacity",children:t.action.label}),(0,r.Y)("button",{type:"button",onClick:()=>{u(!1),m.current=setTimeout(()=>n(t.id),200)},className:"text-ink/40 hover:text-ink transition-colors flex-shrink-0",title:"Dismiss",children:(0,r.Y)(o.A,{size:13})})]}),document.body)}function d(e){let{toasts:t,onDismiss:n}=e;return(0,r.Y)(r.FK,{children:t.map(e=>(0,r.Y)(c,{toast:e,onDismiss:n},e.id))})}},nG(e,t,n){var r=n("j"),i=n("G");let s=(0,i.RZ)(()=>Promise.all([n.e("uf"),n.e("dc")]).then(n.bind(n,"fy")).then(e=>({default:e.FileExplorer}))),a=(0,i.RZ)(()=>Promise.all([n.e("uf"),n.e("1k")]).then(n.bind(n,"X8")).then(e=>({default:e.SearchPanel}))),l=(0,i.RZ)(()=>Promise.all([n.e("uf"),n.e("m")]).then(n.bind(n,"ABt")).then(e=>({default:e.GitPanel}))),o=(0,i.RZ)(()=>n.e("fw").then(n.bind(n,"RF")).then(e=>({default:e.TerminalPanel}))),c=(0,i.RZ)(()=>n.e(51).then(n.bind(n,"zO")).then(e=>({default:e.ContextPanel}))),d=(0,i.RZ)(()=>Promise.all([n.e("3j"),n.e("s")]).then(n.bind(n,"a6")).then(e=>({default:e.BrowserPanel}))),u=(0,i.RZ)(()=>Promise.all([n.e("3j"),n.e("rd")]).then(n.bind(n,"NU")).then(e=>({default:e.UserBrowserPanel}))),p=(0,i.RZ)(()=>Promise.all([n.e("kc"),n.e("vy")]).then(n.bind(n,"Rc")).then(e=>({default:e.UsagePanel}))),m=new WeakMap;function h(e,t){let n=m.get(e);if(n||(n={},m.set(e,n)),!n[t]){let e="files"===t?s:"search"===t?a:"git"===t?l:"terminal"===t?o:"context"===t?c:"user-browser"===t?u:"browser"===t?d:p,i=t=>{let{className:n,...i}=t;return(0,r.Y)("div",{className:`w-full h-full ${"string"==typeof n?n:""}`,children:(0,r.Y)(e,{...i,className:"w-full h-full"})})};i.displayName=`CachedView(${t})`,n[t]=i}return n[t]}n.d(t,{SU:()=>h},{Bz:o,M:u,N1:a,WE:p,XL:d,gI:s,nR:l,ov:c})},E(e,t,n){n.d(t,{i:()=>l});var r=n("j"),i=n("z");let s=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"],a={"A-Z":"A-Z","Z-A":"Z-A",LATEST_SESSION:"Latest Session",LATEST_ADDED:"Latest Added"};function l(e){let{variant:t,sortOption:n,onSortChange:l}=e;return"mobile"===t?(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-2 py-1 text-[10px] uppercase font-bold text-ink/40 font-mono",children:"Sort Workspaces"}),s.map(e=>(0,r.FD)("button",{type:"button",onClick:()=>l(e),className:`w-full text-left px-2.5 py-1.5 rounded-lg flex items-center justify-between transition-colors ${n===e?"bg-ink/10 font-semibold text-ink":"hover:bg-ink/5 text-ink/80"}`,children:[(0,r.Y)("span",{children:e.replace("_"," ")}),n===e&&(0,r.Y)(i.A,{size:13,className:"text-ink"})]},e))]}):(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-3 py-1 text-[10px] uppercase font-bold text-ink/40 tracking-wider",children:"Sort Workspaces"}),s.map(e=>(0,r.FD)("div",{className:`px-3 py-1.5 text-xs cursor-pointer flex items-center justify-between ${n===e?"bg-ink/5 text-ink font-medium":"text-ink/70 hover:bg-ink/5 hover:text-ink"}`,onClick:()=>l(e),children:[(0,r.Y)("span",{children:a[e]}),n===e&&(0,r.Y)("div",{className:"w-1.5 h-1.5 rounded-full bg-ink"})]},e))]})}},C4(e,t,n){var r=n("j"),i=n("mO"),s=n("Wi"),a=n("a");function l(e){let{variant:t,isPinned:n=!1,confirmDelete:l,onPin:o,onDelete:c,onRequestDelete:d,onCancelDelete:u}=e;return"mobile"===t?l?(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-3 py-2 text-ink/80 font-medium",children:"Delete workspace?"}),(0,r.FD)("button",{type:"button",onClick:c,className:"w-full text-left px-3 py-2 hover:bg-error/10 text-error flex items-center space-x-2",children:[(0,r.Y)(i.A,{size:13}),(0,r.Y)("span",{children:"Yes, delete"})]}),(0,r.Y)("button",{type:"button",onClick:u,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/70",children:"Cancel"})]}):(0,r.FD)(r.FK,{children:[(0,r.FD)("button",{type:"button",onClick:o,className:"w-full text-left px-3 py-2 hover:bg-ink/5 text-ink/80 flex items-center space-x-2",children:[n?(0,r.Y)(s.A,{size:13}):(0,r.Y)(a.A,{size:13}),(0,r.Y)("span",{children:n?"Unpin Workspace":"Pin Workspace"})]}),(0,r.FD)("button",{type:"button",onClick:d,className:"w-full text-left px-3 py-2 hover:bg-error/10 text-error flex items-center space-x-2",children:[(0,r.Y)(i.A,{size:13}),(0,r.Y)("span",{children:"Delete Workspace"})]})]}):l?(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"px-3 py-1.5 text-xs text-ink/80 font-medium",children:"Delete workspace?"}),(0,r.FD)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-error",onClick:c,children:[(0,r.Y)(i.A,{size:12}),(0,r.Y)("span",{children:"Yes, delete"})]}),(0,r.Y)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/70",onClick:u,children:(0,r.Y)("span",{children:"Cancel"})})]}):(0,r.FD)(r.FK,{children:[(0,r.FD)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-ink/80",onClick:o,children:[n?(0,r.Y)(s.A,{size:12}):(0,r.Y)(a.A,{size:12}),(0,r.Y)("span",{children:n?"Unpin Workspace":"Pin Workspace"})]}),(0,r.FD)("div",{className:"px-3 py-1.5 hover:bg-ink/5 cursor-pointer flex items-center space-x-2 text-error",onClick:d,children:[(0,r.Y)(i.A,{size:12}),(0,r.Y)("span",{children:"Delete Workspace"})]})]})}n.d(t,{t:()=>l})},g(e,t,n){n.d(t,{VT:()=>T,xV:()=>z,Lo:()=>$,bB:()=>f.b});var r=n("j"),i=n("H"),s=n("S"),a=n("w"),l=n("Y"),o=n("o"),c=n("r"),d=n("lP"),u=n("C"),p=n("W"),m=n("N"),h=n("YL"),f=n("u"),x=n("Nf"),g=n("t"),b=n("n"),v=n("g6");async function k(e){let t=e?`?path=${encodeURIComponent(e)}`:"",n=await fetch(`/api/fs/browse${t}`),r=await n.json();if(!n.ok||r.error)throw Error(r.error||`HTTP ${n.status}`);return r}function y(e){let{initialPath:t,onSelect:n,onClose:o}=e,[c,d]=(0,i.J0)(t??""),[u,p]=(0,i.J0)(""),[m,h]=(0,i.J0)([]),[f,y]=(0,i.J0)(null),[w,N]=(0,i.J0)(!0),[Y,D]=(0,i.J0)(null),[F,A]=(0,i.J0)(null),S=(0,i.li)(null),C=(0,i.hb)(async e=>{N(!0),D(null);try{let t=await k(e);d(t.path??e??""),y(t.parentPath??null),p(t.path??e??""),h(t.directories??[])}catch(e){D(e instanceof Error?e.message:String(e))}finally{N(!1)}},[]);(0,i.vJ)(()=>{C(t)},[t,C]);let T=e=>{C(e.path)};return(0,r.Y)("div",{className:"fixed inset-0 bg-ink/30 z-[60] flex items-center justify-center p-4",onClick:o,children:(0,r.FD)("div",{className:"bg-paper border border-ink/15 rounded-lg shadow-2xl w-full max-w-lg flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ink/10",children:[(0,r.FD)("h3",{className:"font-semibold text-sm flex items-center space-x-2",children:[(0,r.Y)(l.A,{size:15,className:"text-ink/70"}),(0,r.Y)("span",{children:"Choose Project Folder"})]}),(0,r.Y)("button",{type:"button",onClick:o,className:"p-1 rounded hover:bg-ink/10 text-ink/60 hover:text-ink transition-colors","aria-label":"Close picker",children:(0,r.Y)(s.A,{size:15})})]}),(0,r.FD)("div",{className:"px-4 py-2 border-b border-ink/10 bg-canvas/50",children:[(0,r.FD)("form",{onSubmit:e=>{e.preventDefault();let t=u.trim();t&&C(t)},className:"flex items-center space-x-2",children:[(0,r.Y)(a.A,{size:14,className:"text-ink/40 flex-shrink-0"}),(0,r.Y)("input",{ref:S,type:"text",value:u,onChange:e=>p(e.currentTarget.value),placeholder:"~ or /absolute/path",className:"flex-1 bg-transparent outline-none text-xs font-mono text-ink placeholder-ink/30 py-1",spellcheck:!1}),(0,r.Y)("button",{type:"submit",className:"px-2 py-1 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 transition-colors",children:"Go"})]}),(0,r.FD)("div",{className:"flex items-center space-x-1 mt-1 text-[11px] text-ink/40 truncate",children:[(0,r.FD)("button",{type:"button",onClick:()=>void C(),className:"hover:text-ink transition-colors flex items-center",children:[(0,r.Y)(a.A,{size:11,className:"mr-0.5"})," home"]}),c.split("/").filter(Boolean).map((e,t,n)=>{let i="/"+c.split("/").filter(Boolean).slice(0,t+1).join("/"),s=t===n.length-1;return(0,r.FD)("span",{className:"flex items-center space-x-1 min-w-0",children:[(0,r.Y)(x.A,{size:10,className:"text-ink/20 flex-shrink-0"}),s?(0,r.Y)("span",{className:"text-ink/70 truncate",children:e}):(0,r.Y)("button",{type:"button",onClick:()=>void C(i),className:"hover:text-ink transition-colors truncate max-w-[120px]",children:e})]},i)})]})]}),(0,r.Y)("div",{className:"flex-1 min-h-[240px] max-h-[360px] scrollbar-overlay-container scrollbar-overlay-static p-2",children:w?(0,r.Y)("div",{className:"flex items-center justify-center h-40 text-ink/40",children:(0,r.Y)(g.A,{size:18,className:"animate-spin"})}):Y?(0,r.FD)("div",{className:"flex flex-col items-center justify-center h-40 text-xs text-red-600 space-y-2 px-4",children:[(0,r.Y)("span",{children:Y}),(0,r.FD)("button",{type:"button",onClick:()=>void C(c||void 0),className:"px-2 py-1 rounded bg-ink/5 border border-ink/10 text-ink/70 hover:bg-ink/10 flex items-center space-x-1",children:[(0,r.Y)(b.A,{size:11})," Retry"]})]}):0===m.length?(0,r.Y)("div",{className:"text-center py-16 text-xs text-ink/40",children:"No subfolders"}):m.map(e=>(0,r.FD)("div",{className:`group flex items-center justify-between px-2.5 py-2 rounded cursor-pointer transition-colors ${F===e.path?"bg-ink/10":"hover:bg-ink/5"}`,onDblClick:()=>T(e),children:[(0,r.FD)("button",{type:"button",onClick:()=>T(e),className:"flex items-center space-x-2 min-w-0 flex-1 text-left",children:[(0,r.Y)(v.A,{size:15,className:"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{className:"text-xs truncate text-ink/85",children:e.name})]}),(0,r.Y)("button",{type:"button",onClick:()=>{A(e.path),n(e.path)},className:"hidden group-hover:flex px-2 py-0.5 rounded bg-ink text-canvas text-[10px] font-semibold hover:bg-ink/80 transition-colors flex-shrink-0",children:"Choose"})]},e.path))}),(0,r.FD)("div",{className:"flex items-center justify-between px-4 py-3 border-t border-ink/10",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0",children:[(0,r.FD)("button",{type:"button",onClick:()=>{f&&C(f)},disabled:!f,className:"px-2.5 py-1.5 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 disabled:opacity-40 transition-colors flex items-center space-x-1",children:[(0,r.Y)("span",{children:"↑"}),(0,r.Y)("span",{children:"Up"})]}),(0,r.Y)("button",{type:"button",onClick:()=>void C(),className:"px-2.5 py-1.5 rounded bg-ink/5 border border-ink/10 text-[11px] font-medium hover:bg-ink/10 transition-colors",children:"Home"})]}),(0,r.FD)("div",{className:"flex items-center space-x-2",children:[(0,r.Y)("button",{type:"button",onClick:o,className:"px-3 py-1.5 text-xs font-medium text-ink/60 hover:text-ink transition-colors",children:"Cancel"}),(0,r.Y)("button",{type:"button",onClick:()=>{c&&(A(c),n(c))},disabled:!c,className:"px-3.5 py-1.5 text-xs font-medium bg-ink text-canvas rounded hover:bg-ink/90 disabled:opacity-50 transition-colors",children:"Use This Folder"})]})]})]})})}var w=n("P");function N(){return(0,r.FD)("div",{className:"flex flex-col items-center gap-3 mt-6 pt-1",children:[(0,r.FD)("div",{className:"flex items-center justify-center gap-6",children:[(0,r.FD)("a",{href:"https://github.com",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 text-xs font-medium text-ink/75 hover:text-ink transition-colors",children:[(0,r.Y)("svg",{className:"w-4 h-4 fill-current",viewBox:"0 0 24 24",children:(0,r.Y)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M12 2C6.477 2 2 6.484 2 12.017c0 4.425 2.865 8.18 6.839 9.504.5.092.682-.217.682-.483 0-.237-.008-.868-.013-1.703-2.782.605-3.369-1.343-3.369-1.343-.454-1.158-1.11-1.466-1.11-1.466-.908-.62.069-.608.069-.608 1.003.07 1.53 1.032 1.53 1.032.892 1.53 2.341 1.088 2.91.832.092-.647.35-1.088.636-1.338-2.22-.253-4.555-1.113-4.555-4.951 0-1.093.39-1.988 1.029-2.688-.103-.253-.446-1.272.098-2.65 0 0 .84-.27 2.75 1.026A9.564 9.564 0 0112 6.844c.85.004 1.705.115 2.504.337 1.909-1.296 2.747-1.027 2.747-1.027.546 1.379.202 2.398.1 2.651.64.7 1.028 1.595 1.028 2.688 0 3.848-2.339 4.695-4.566 4.943.359.309.678.92.678 1.855 0 1.338-.012 2.419-.012 2.747 0 .268.18.58.688.482A10.019 10.019 0 0022 12.017C22 6.484 17.522 2 12 2z"})}),(0,r.Y)("span",{children:"GitHub"})]}),(0,r.FD)("a",{href:"https://discord.com",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 text-xs font-medium text-ink/75 hover:text-ink transition-colors",children:[(0,r.Y)("svg",{className:"w-4 h-4 fill-current",viewBox:"0 0 24 24",children:(0,r.Y)("path",{d:"M20.317 4.37a19.791 19.791 0 0 0-4.885-1.515.074.074 0 0 0-.079.037c-.21.375-.444.864-.608 1.25a18.27 18.27 0 0 0-5.487 0 12.64 12.64 0 0 0-.617-1.25.077.077 0 0 0-.079-.037A19.736 19.736 0 0 0 3.677 4.37a.07.07 0 0 0-.032.027C.533 9.046-.32 13.58.099 18.057a.082.082 0 0 0 .031.057 19.9 19.9 0 0 0 5.993 3.03.078.078 0 0 0 .084-.028c.462-.63.874-1.295 1.226-1.994.021-.041.001-.09-.041-.106a13.107 13.107 0 0 1-1.872-.892.077.077 0 0 1-.008-.128 10.2 10.2 0 0 0 .372-.292.074.074 0 0 1 .077-.01c3.929 1.793 8.18 1.793 12.061 0a.074.074 0 0 1 .078.01c.12.098.246.198.373.292a.077.077 0 0 1-.006.127 12.299 12.299 0 0 1-1.873.894.077.077 0 0 0-.041.107c.36.698.772 1.362 1.225 1.993a.076.076 0 0 0 .084.028 19.839 19.839 0 0 0 6.002-3.03.077.077 0 0 0 .032-.054c.5-5.177-.838-9.674-3.549-13.66a.061.061 0 0 0-.031-.028zM8.02 15.33c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.956-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.956 2.418-2.157 2.418zm7.975 0c-1.183 0-2.157-1.085-2.157-2.419 0-1.333.955-2.419 2.157-2.419 1.21 0 2.176 1.096 2.157 2.42 0 1.333-.946 2.418-2.157 2.418z"})}),(0,r.Y)("span",{children:"Discord"})]})]}),(0,r.FD)("a",{href:"https://x.com",target:"_blank",rel:"noreferrer",className:"flex items-center gap-2 text-xs font-medium text-ink/75 hover:text-ink transition-colors",children:[(0,r.Y)("svg",{className:"w-3.5 h-3.5 fill-current",viewBox:"0 0 24 24",children:(0,r.Y)("path",{d:"M18.244 2.25h3.308l-7.227 8.26 8.502 11.24H16.17l-5.214-6.817L4.99 21.75H1.68l7.73-8.835L1.254 2.25H8.08l4.713 6.231zm-1.161 17.52h1.833L7.084 4.126H5.117z"})}),(0,r.Y)("span",{children:"@ompchamber"})]})]})}var Y=n("tC"),D=n("p"),F=n("z");let A="inline-flex items-center gap-1.5 rounded-md border border-ink/20 px-2.5 py-1.5 text-[11px] font-medium text-ink transition-colors hover:border-ink/40 disabled:cursor-not-allowed disabled:opacity-50";function S(e){let{target:t,info:n,applying:i,disabled:s,onApply:a}=e,l=`v${n.current??"…"} → v${n.latest??"…"}`;return(0,r.FD)("div",{className:"flex items-center justify-between gap-3 border-t border-ink/10 py-2.5 first:border-t-0",children:[(0,r.FD)("div",{className:"min-w-0",children:[(0,r.Y)("p",{className:"text-xs font-medium text-ink",children:"ompchamber"===t?"OMPChamber":"Oh-My-Pi"}),(0,r.Y)("p",{className:"font-mono text-[10px] text-ink/60",children:n.installed?l:"not detected"})]}),n.installed?(0,r.FD)("button",{type:"button",onClick:()=>a(t),disabled:s,className:A,children:[i?(0,r.Y)(g.A,{size:12,className:"animate-spin motion-reduce:animate-none"}):(0,r.Y)(Y.A,{size:12}),(0,r.Y)("span",{children:"Update"})]}):(0,r.Y)("span",{className:"shrink-0 text-[10px] text-ink/40",children:"not detected"})]})}function C(e){let{updates:t,onToast:n}=e,i=t.info?[{target:"ompchamber",info:t.info.ompchamber},{target:"omp",info:t.info.omp}].filter(e=>{let{info:t}=e;return t.updateAvailable&&null!==t.latest}):[],s=async e=>{let r=await t.apply(e);if(n){if(!r)return void n("The update request could not be completed.","error");if("ompchamber"===e)return void n(r.message,r.success?"success":"error");r.success?n(`${r.message} A restart may be needed.`,"success"):n(r.message,"error")}},a=!!(t.info&&!t.checking&&!t.error);return(0,r.FD)("section",{className:"mt-5 border-y border-ink/10 py-3 text-left","aria-labelledby":"updates-heading",children:[(0,r.FD)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.Y)("h3",{id:"updates-heading",className:"text-xs font-semibold text-ink",children:"Updates"}),t.info&&(0,r.Y)("span",{className:"font-mono text-[9px] text-ink/40",children:"checked"})]}),(0,r.FD)("div",{className:"mt-2.5",children:[t.checking&&(0,r.FD)("button",{type:"button",disabled:!0,className:`${A} w-full justify-center`,children:[(0,r.Y)(g.A,{size:13,className:"animate-spin motion-reduce:animate-none"}),(0,r.Y)("span",{children:"Checking…"})]}),t.error&&!t.checking&&(0,r.FD)("div",{className:"flex items-start gap-2",children:[(0,r.Y)(D.A,{size:14,className:"mt-0.5 shrink-0 text-error"}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.Y)("p",{className:"text-[11px] leading-4 text-error",children:t.error}),(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),className:`${A} mt-2`,children:[(0,r.Y)(b.A,{size:12}),(0,r.Y)("span",{children:"Retry"})]})]})]}),!t.info&&!t.checking&&!t.error&&(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),className:`${A} w-full justify-center`,children:[(0,r.Y)(b.A,{size:13}),(0,r.Y)("span",{children:"Check for updates"})]}),a&&0===i.length&&(0,r.FD)("div",{className:"flex items-center justify-between gap-3",children:[(0,r.FD)("p",{className:"flex items-center gap-1.5 text-[11px] text-success",children:[(0,r.Y)(F.A,{size:13}),(0,r.Y)("span",{children:"You're up to date"})]}),(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),className:A,children:[(0,r.Y)(b.A,{size:12}),(0,r.Y)("span",{children:"Check again"})]})]}),a&&i.length>0&&(0,r.FD)("div",{children:[i.map(e=>{let{target:n,info:i}=e;return(0,r.Y)(S,{target:n,info:i,applying:t.applying===n,disabled:null!==t.applying,onApply:e=>void s(e)},n)}),(0,r.FD)("button",{type:"button",onClick:()=>void t.check(),disabled:null!==t.applying,className:`${A} mt-2 w-full justify-center`,children:[(0,r.Y)(b.A,{size:12}),(0,r.Y)("span",{children:"Check again"})]})]})]})]})}function T(e){let{isOpen:t,onClose:n,updates:i,onToast:a}=e;return t?(0,r.Y)("div",{className:"fixed inset-0 bg-ink/40 backdrop-blur-[2px] z-50 flex items-center justify-center p-4 animate-in fade-in duration-200",onClick:n,children:(0,r.FD)("div",{className:"relative bg-paper border border-ink/15 rounded-2xl shadow-2xl w-full max-w-[340px] p-6 text-center text-ink select-none",onClick:e=>e.stopPropagation(),children:[(0,r.Y)("button",{onClick:n,className:"absolute top-4 right-4 text-ink/40 hover:text-ink transition-colors p-1 rounded-md","aria-label":"Close",children:(0,r.Y)(s.A,{size:18,className:"stroke-[2.5]"})}),(0,r.Y)("div",{className:"flex justify-center pt-2 pb-1",children:(0,r.Y)("img",{src:"/icon.svg",alt:"OMPChamber",width:96,height:96,draggable:!1})}),(0,r.FD)("h2",{className:"text-xl font-bold tracking-tight mt-3 flex items-center justify-center",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-2xl tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"text-ink text-2xl font-bold ml-[1px]",children:"Chamber"})]}),(0,r.FD)("div",{className:"text-xs text-ink/60 space-y-1 mt-1.5 font-mono",children:[(0,r.FD)("p",{children:["OMPChamber v",w.rE]}),(0,r.FD)("p",{children:["Oh-My-Pi ",i.info?.omp.current??"…"]})]}),(0,r.Y)(C,{updates:i,onToast:a}),(0,r.Y)(N,{}),(0,r.Y)("p",{className:"text-[11px] text-ink/50 font-normal mt-8",children:"Made with love for the community"})]})}):null}function z(e){let{isOpen:t,onClose:n,onCreate:o}=e,[c,d]=(0,i.J0)(""),[u,p]=(0,i.J0)(""),[m,h]=(0,i.J0)(!1),[f,x]=(0,i.J0)(null),[g,b]=(0,i.J0)(!1);if((0,i.vJ)(()=>{t&&(d(""),p(""),h(!1),x(null),b(!1))},[t]),!t)return null;let v=async()=>{if(!o)return void n();if(!c.trim()&&!u.trim())return void x("Enter a name or a project path.");h(!0),x(null);try{await o({name:c.trim(),path:u.trim()||void 0}),n()}catch(e){x(e instanceof Error?e.message:String(e)),h(!1)}};return(0,r.FD)("div",{className:"fixed inset-0 bg-ink/20 z-50 flex items-center justify-center",children:[(0,r.FD)("div",{className:"bg-paper border border-ink/10 rounded-lg shadow-xl w-96 p-4 flex flex-col",children:[(0,r.FD)("div",{className:"flex justify-between items-center mb-4 border-b border-ink/10 pb-2",children:[(0,r.Y)("h3",{className:"font-semibold text-sm",children:"New Workspace"}),(0,r.Y)(s.A,{size:14,className:"cursor-pointer hover:text-ink/60",onClick:n})]}),(0,r.FD)("div",{className:"text-sm text-ink/80 py-2 space-y-3",children:[(0,r.FD)("div",{children:[(0,r.Y)("label",{className:"block text-xs font-semibold mb-1 text-ink",children:"Workspace Name"}),(0,r.Y)("input",{type:"text",value:c,onChange:e=>d(e.currentTarget.value),placeholder:"e.g. bofis-pro",className:"w-full bg-paper border border-ink/20 rounded px-3 py-2 outline-none focus:border-ink/50 text-sm"})]}),(0,r.FD)("div",{children:[(0,r.FD)("label",{className:"block text-xs font-semibold mb-1 text-ink",children:["Project Path ",(0,r.Y)("span",{className:"text-ink/40 font-normal",children:"(optional — binds omp sessions)"})]}),(0,r.FD)("div",{className:"flex items-center space-x-2",children:[(0,r.FD)("div",{className:"flex-1 flex items-center bg-paper border border-ink/20 rounded overflow-hidden focus-within:border-ink/50",children:[(0,r.Y)("div",{className:"px-2 text-ink/40 bg-ink/5 h-full flex items-center border-r border-ink/10",children:(0,r.Y)(a.A,{size:14})}),(0,r.Y)("input",{type:"text",value:u,onChange:e=>p(e.currentTarget.value),placeholder:"~/projects/my-project",className:"w-full px-3 py-2 outline-none text-sm bg-transparent"})]}),(0,r.FD)("button",{type:"button",onClick:()=>b(!0),className:"px-3 py-2 bg-ink/5 border border-ink/10 rounded text-xs font-medium hover:bg-ink/10 transition-colors flex items-center space-x-1.5 flex-shrink-0",children:[(0,r.Y)(l.A,{size:13}),(0,r.Y)("span",{children:"Browse"})]})]})]}),f&&(0,r.Y)("div",{className:"text-xs text-red-600",children:f})]}),(0,r.FD)("div",{className:"mt-4 flex justify-end space-x-2",children:[(0,r.Y)("button",{className:"px-3 py-1.5 text-xs font-medium text-ink/60 hover:text-ink transition-colors",onClick:n,disabled:m,children:"Cancel"}),(0,r.Y)("button",{className:"px-4 py-1.5 text-xs font-medium bg-ink text-canvas rounded hover:bg-ink/90 transition-colors disabled:opacity-50",onClick:v,disabled:m,children:m?"Creating…":"Create Workspace"})]})]}),g&&(0,r.Y)(y,{initialPath:u||void 0,onSelect:e=>{if(p(e),b(!1),!c.trim()){let t=e.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||"";t&&d(t)}},onClose:()=>b(!1)})]})}function $(e){let{isOpen:t,onClose:n}=e;return t?(0,r.Y)("div",{className:"fixed inset-0 bg-ink/20 z-50 flex items-center justify-center p-4",children:(0,r.FD)("div",{className:"bg-paper border border-ink/10 rounded-lg shadow-xl w-full max-w-2xl flex flex-col overflow-hidden",children:[(0,r.FD)("div",{className:"flex justify-between items-center p-4 border-b border-ink/10 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 text-ink",children:[(0,r.Y)(o.A,{size:16}),(0,r.Y)("h3",{className:"font-semibold text-sm",children:"Schedule Chat / Task"})]}),(0,r.Y)(s.A,{size:16,className:"cursor-pointer hover:text-ink/60",onClick:n})]}),(0,r.Y)("div",{className:"p-4 bg-canvas",children:(0,r.FD)("div",{className:"w-full bg-paper border border-ink/20 rounded-md focus-within:border-ink transition-colors flex flex-col shadow-sm",children:[(0,r.FD)("div",{className:"flex items-center px-3 py-2 border-b border-ink/5 text-ink/60 space-x-2",children:[(0,r.Y)("button",{className:"hover:text-ink transition-colors",children:(0,r.Y)(c.A,{size:14})}),(0,r.Y)("button",{className:"hover:text-ink transition-colors",children:(0,r.Y)(d.A,{size:14})}),(0,r.Y)("button",{className:"hover:text-ink transition-colors",children:(0,r.Y)(u.A,{size:14})}),(0,r.Y)("div",{className:"flex-1"}),(0,r.FD)("div",{className:"flex items-center space-x-2 text-xs text-ink",children:[(0,r.Y)("span",{className:"font-medium",children:"Schedule:"}),(0,r.FD)("select",{className:"bg-transparent border border-ink/20 rounded px-1.5 py-0.5 outline-none focus:border-ink/50",children:[(0,r.Y)("option",{value:"once",children:"Once"}),(0,r.Y)("option",{value:"every",children:"Every"}),(0,r.Y)("option",{value:"cron",children:"Cron"})]}),(0,r.Y)("input",{type:"text",placeholder:"e.g. 5 mins, 0 0 * * *",className:"w-32 bg-transparent border border-ink/20 rounded px-2 py-0.5 outline-none focus:border-ink/50"})]})]}),(0,r.Y)("textarea",{placeholder:"Describe your scheduled task, ask a question, or paste commands...",className:"w-full bg-transparent border-none px-4 py-4 text-sm focus:outline-none resize-none text-ink placeholder-ink/40 min-h-[120px]"}),(0,r.FD)("div",{className:"flex items-center justify-between px-3 py-2 border-t border-ink/5",children:[(0,r.FD)("div",{className:"flex items-center space-x-3 text-ink/60 text-xs",children:[(0,r.FD)("div",{className:"flex items-center space-x-1 hover:text-ink cursor-pointer",children:[(0,r.Y)(p.A,{size:14}),(0,r.Y)("span",{children:"Default"})]}),(0,r.FD)("div",{className:"flex items-center space-x-1 hover:text-ink cursor-pointer",children:[(0,r.Y)(m.A,{size:14}),(0,r.Y)("span",{children:"[CMD] DeepSeek V4 Flash"})]})]}),(0,r.FD)("button",{onClick:n,className:"flex items-center justify-center space-x-1.5 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/80 transition-colors text-xs font-medium",children:[(0,r.Y)("span",{children:"Schedule Task"}),(0,r.Y)(h.A,{size:12,className:"ml-px"})]})]})]})})]})}):null}},u(e,t,n){var r=n("j"),i=n("G");let s=(0,i.RZ)(()=>Promise.all([n.e("v0"),n.e("kc"),n.e("xw")]).then(n.bind(n,"jQ")).then(e=>({default:e.SettingsModal})));function a(e){let{isOpen:t,...n}=e;return t?(0,r.Y)(i.tY,{fallback:null,children:(0,r.Y)(s,{isOpen:t,...n})}):null}n.d(t,{b:()=>a})},j5(e,t,n){n.d(t,{E:()=>ih});var r=n("j"),i=n("H"),s=n("s"),a=n("G");let l=(0,a.RZ)(()=>n.e("rf").then(n.bind(n,"Rt")).then(e=>({default:e.AskDialog})));function o(e){return(0,r.Y)(a.tY,{fallback:null,children:(0,r.Y)(l,{...e})})}var c=n("v"),d=n("g6"),u=n("Go"),p=n("z"),m=n("oj"),h=n("s8"),f=n("YL"),x=n("tN"),g=n("W9"),b=n("r"),v=n("t3"),k=n("S");function y(e){let{search:t,onSearchChange:n,onAddProvider:i}=e;return(0,r.FD)("div",{className:"flex flex-col border-b border-ink/10 bg-canvas/40",children:[(0,r.FD)("button",{type:"button",onClick:i,className:"w-full flex items-center space-x-2 px-3 py-2 text-xs text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors text-left font-medium cursor-pointer border-b border-ink/5",children:[(0,r.Y)(b.A,{size:14,className:"text-ink/60"}),(0,r.Y)("span",{children:"Add new provider"})]}),(0,r.FD)("div",{className:"p-2 flex items-center bg-canvas/60",children:[(0,r.Y)(v.A,{size:13,className:"text-ink/40 mr-2 flex-shrink-0"}),(0,r.Y)("input",{type:"text",value:t,onChange:e=>n(e.currentTarget.value),placeholder:"Search models",className:"bg-transparent border-none focus:outline-none w-full text-ink placeholder-ink/40 text-xs font-sans",autoFocus:!0}),t&&(0,r.Y)("button",{type:"button",onClick:()=>n(""),className:"p-0.5 text-ink/40 hover:text-ink transition-colors cursor-pointer",title:"Clear search",children:(0,r.Y)(k.A,{size:12})})]})]})}var w=n("HW"),N=n("hw"),Y=n("j7"),D=n("Wb"),F=n("cV"),A=n("lW"),S=n("C7"),C=n("XT"),T=n("Oj"),z=n("K6"),$=n("pm");function j(e){let{model:t,isSelected:n,isFocused:i,onSelect:s,onToggleFavorite:a,onCycleThinking:l,onMouseEnter:o}=e;return(0,r.FD)("div",{role:"button",tabIndex:0,onClick:()=>s(t),onMouseEnter:o,className:`group relative w-full flex items-center justify-between px-2.5 py-1.5 rounded-lg text-xs transition-colors cursor-pointer select-none ${i?"bg-ink/10 text-ink":n?"bg-ink/5 text-ink":"text-ink/85 hover:bg-ink/5"}`,children:[(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[(0,r.Y)(Y.A,{size:12,className:"text-ink/20 group-hover:text-ink/50 transition-colors flex-shrink-0"}),(()=>{if(t.isCmdAgent)return(0,r.Y)("span",{className:"inline-flex items-center justify-center w-4 h-4 rounded border border-ink/20 bg-ink/5 text-ink/80 flex-shrink-0",title:"Autonomous Agent Command Mode [CMD]",children:(0,r.Y)(F.A,{size:10})});switch(t.providerIcon||t.provider.toLowerCase()){case"deepseek":return(0,r.Y)("span",{className:"text-[12px] leading-none flex-shrink-0",title:"DeepSeek",children:"🐋"});case"anthropic":case"claude":return(0,r.Y)(A.A,{size:13,className:"text-orange-400 flex-shrink-0"});case"openai":return(0,r.Y)(S.A,{size:13,className:"text-emerald-500 flex-shrink-0"});case"google":case"gemini":return(0,r.Y)(x.A,{size:13,className:"text-blue-400 flex-shrink-0"});case"opencode":return(0,r.Y)(C.A,{size:13,className:"text-violet-400 flex-shrink-0"});case"mistral":return(0,r.Y)(T.A,{size:13,className:"text-rose-400 flex-shrink-0"});default:return(0,r.Y)(x.A,{size:13,className:"text-ink/60 flex-shrink-0"})}})(),(0,r.FD)("div",{className:"flex items-center space-x-1.5 truncate",children:[t.isCmdAgent&&(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink/75 flex-shrink-0",children:"[CMD]"}),(0,r.Y)("span",{className:`truncate ${n?"font-semibold text-ink":"font-normal text-ink/90"}`,children:t.name}),t.contextWindow&&(0,r.Y)("span",{className:"font-mono text-[10px] text-ink/45 flex-shrink-0",children:(0,$.F)(t.contextWindow)})]})]}),(0,r.FD)("div",{className:"flex items-center space-x-2 flex-shrink-0",children:[t.thinkingLevel&&(0,r.FD)("button",{type:"button",onClick:e=>{e.stopPropagation(),l?.(t,e)},title:`Thinking preset: ${t.thinkingLevel} (Click or use ← / → to change)`,className:"inline-flex items-center space-x-1 px-1.5 py-0.5 rounded text-[10px] font-mono text-ink/70 bg-ink/5 hover:bg-ink/10 border border-ink/10 transition-colors cursor-pointer",children:[(0,r.Y)(z.A,{size:10,className:"text-ink/50"}),(0,r.Y)("span",{children:t.thinkingLevel})]}),n&&(0,r.Y)(p.A,{size:13,className:"text-ink flex-shrink-0"}),(0,r.Y)("button",{type:"button",onClick:e=>a(t,e),title:t.isFavorite?"Remove from favorites":"Add to favorites",className:"p-1 rounded text-ink/30 hover:text-sky-400 hover:bg-ink/5 transition-colors cursor-pointer",children:(0,r.Y)(w.A,{size:13,className:t.isFavorite?"fill-sky-400 text-sky-400":"text-ink/30 hover:text-sky-400"})})]})]})}function L(e){return e?`${e.provider}:${e.id}`:""}function M(e){let{id:t,title:n,iconType:i="provider",models:s,isCollapsed:a,onToggleCollapse:l,selectedModelKey:o,modelIndex:c,focusedIndex:d,onSelect:p,onToggleFavorite:m,onCycleThinking:h,onHoverItem:f}=e;return 0===s.length?null:(0,r.FD)("div",{className:"space-y-0.5",children:[(0,r.FD)("button",{type:"button",onClick:()=>l(t),className:"w-full flex items-center justify-between px-2 py-1 text-[11px] font-semibold text-ink/60 uppercase tracking-wider hover:text-ink cursor-pointer select-none",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5",children:["star"===i&&(0,r.Y)(w.A,{size:12,className:"fill-sky-400 text-sky-400"}),"recent"===i&&(0,r.Y)(N.A,{size:12,className:"text-ink/60"}),"whale"===i&&(0,r.Y)("span",{children:"🐋"}),"provider"===i&&(0,r.Y)(Y.A,{size:11,className:"text-ink/25"}),(0,r.Y)("span",{children:n})]}),a?(0,r.Y)(u.A,{size:12,className:"text-ink/40"}):(0,r.Y)(D.A,{size:12,className:"text-ink/40"})]}),!a&&(0,r.Y)("div",{className:"space-y-0.5",children:s.map(e=>{let n=L(e),i=c[n]??-1;return(0,r.Y)(j,{model:e,isSelected:o===n,isFocused:d===i,onSelect:p,onToggleFavorite:m,onCycleThinking:h,onMouseEnter:()=>f(i,e)},`${t}-${n}`)})})]})}function P(){return(0,r.Y)("div",{className:"flex items-center justify-between px-3 py-1.5 border-t border-ink/10 bg-canvas/60 text-[10px] text-ink/50 font-mono select-none",children:(0,r.FD)("div",{className:"flex items-center space-x-3",children:[(0,r.FD)("span",{className:"flex items-center space-x-1",children:[(0,r.Y)("span",{className:"text-ink/70",children:"↑ ↓"}),(0,r.Y)("span",{children:"navigate"})]}),(0,r.FD)("span",{className:"flex items-center space-x-1",children:[(0,r.Y)("span",{className:"text-ink/70",children:"Tab"}),(0,r.Y)("span",{children:"switch agent"})]}),(0,r.FD)("span",{className:"flex items-center space-x-1",children:[(0,r.Y)("span",{className:"text-ink/70",children:"← →"}),(0,r.Y)("span",{children:"thinking"})]})]})})}let E=[3,2];function R(){return(0,r.Y)("div",{className:"space-y-2","aria-hidden":"true",children:E.map((e,t)=>(0,r.FD)("div",{className:"space-y-0.5",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5 px-2 py-1",children:[(0,r.Y)("span",{className:"w-2.5 h-2.5 rounded-sm animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-2.5 w-20 rounded animate-pulse bg-ink/10"})]}),Array.from({length:e},(e,n)=>(0,r.FD)("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0 flex-1 mr-2",children:[(0,r.Y)("span",{className:"w-3 h-3 rounded-sm animate-pulse bg-ink/10 flex-shrink-0"}),(0,r.Y)("span",{className:"h-3 rounded animate-pulse bg-ink/10",style:{width:`${52-(n+t)%3*10}%`}})]}),(0,r.Y)("span",{className:"h-4 w-9 rounded animate-pulse bg-ink/10 flex-shrink-0"})]},n))]},t))})}function I(e){let{model:t}=e;return t?(0,r.Y)("div",{className:"w-72 bg-paper/95 backdrop-blur-sm border border-ink/20 rounded-xl shadow-2xl p-3.5 text-xs text-ink select-none animate-in fade-in zoom-in-95 duration-100",children:(0,r.FD)("div",{className:"space-y-2.5 font-mono text-[11px]",children:[t.capabilities&&t.capabilities.length>0&&(0,r.FD)("div",{className:"flex items-start justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Capabilities"}),(0,r.Y)("span",{className:"text-ink font-medium text-right text-xs font-sans",children:t.capabilities.join(", ")})]}),t.contextWindow&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Context"}),(0,r.Y)("span",{className:"text-ink/80",children:(0,$.F)(t.contextWindow)})]}),t.thinkingLevel&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Thinking"}),(0,r.Y)("span",{className:"text-ink/80",children:t.thinkingLevel})]}),t.input&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Input"}),(0,r.Y)("span",{className:"text-ink/80",children:t.input})]}),t.output&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Output"}),(0,r.Y)("span",{className:"text-ink/80",children:t.output})]}),t.cost&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2 pt-1 border-t border-ink/10",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Cost ($/1M tokens)"}),(0,r.FD)("span",{className:"text-ink font-semibold tracking-tight",children:["In ",t.cost.input," · Out ",t.cost.output]})]}),(t.cost?.cacheRead!==void 0||t.cost?.cacheWrite!==void 0)&&(0,r.FD)("div",{className:"flex items-center justify-between gap-2 pt-1 border-t border-ink/5",children:[(0,r.Y)("span",{className:"text-ink/50 font-sans text-xs",children:"Cache"}),(0,r.Y)("span",{className:"text-ink/80",children:t.cost?.cacheRead!==void 0&&t.cost?.cacheWrite!==void 0?`Read ${t.cost.cacheRead} \xb7 Write ${t.cost.cacheWrite}`:t.cost?.cacheRead!==void 0?`Read ${t.cost.cacheRead}`:`Write ${t.cost.cacheWrite}`})]}),t.description&&(0,r.Y)("div",{className:"pt-1.5 text-[10px] text-ink/60 font-sans leading-relaxed border-t border-ink/5",children:t.description})]})}):null}function O(e){let{search:t,onSearchChange:n,onAddProvider:i,isLoading:s,filteredModels:a,favoriteModels:l,recentModels:o,providerGroups:c,collapsedSections:d,onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,hoveredModel:f,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v,onMouseLeave:k}=e;return(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-2.5 z-50 flex items-start",children:[(0,r.FD)("div",{className:"w-84 sm:w-96 bg-paper border border-ink/20 rounded-xl shadow-2xl flex flex-col overflow-hidden text-xs max-h-[460px] animate-in fade-in zoom-in-95 duration-100",children:[(0,r.Y)(y,{search:t,onSearchChange:n,onAddProvider:i}),(0,r.Y)("div",{className:"flex-1 scrollbar-overlay-container scrollbar-overlay-static p-1.5 space-y-2 max-h-80",onMouseLeave:k,children:s?(0,r.Y)(R,{}):0===a.length?(0,r.Y)("div",{className:"px-3 py-6 text-center text-ink/40 italic",children:t?(0,r.FD)(r.FK,{children:['No models found matching "',t,'"']}):(0,r.Y)(r.FK,{children:"No models available. Enable a provider in Settings → Providers."})}):(0,r.FD)(r.FK,{children:[(0,r.Y)(M,{id:"favorites",title:"FAVORITES",iconType:"star",models:l,isCollapsed:!!d.favorites,onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v}),(0,r.Y)(M,{id:"recent",title:"RECENT",iconType:"recent",models:o,isCollapsed:!!d.recent,onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v}),Object.entries(c).map(e=>{let[t,n]=e;return(0,r.Y)(M,{id:t,title:t,iconType:"DEEPSEEK"===t?"whale":"provider",models:n,isCollapsed:!!d[t],onToggleCollapse:u,selectedModelKey:p,modelIndex:m,focusedIndex:h,onSelect:x,onToggleFavorite:g,onCycleThinking:b,onHoverItem:v},t)})]})}),(0,r.Y)(P,{})]}),f&&(0,r.Y)("div",{className:"hidden lg:block ml-2 self-center",children:(0,r.Y)(I,{model:f})})]})}function J(e){let t=Array.isArray(e.thinkingLevels)?e.thinkingLevels:[],n=e.cost;return{id:e.id,name:e.name,provider:e.provider,contextWindow:e.contextWindow,thinkingLevel:t[0]??"off",thinkingLevels:t,capabilities:t.length>1?["Tool calling","Reasoning"]:["Tool calling"],cost:n?{input:void 0!==n.input?`$${n.input}`:"—",output:void 0!==n.output?`$${n.output}`:"—",cacheRead:void 0!==n.cacheRead?`$${n.cacheRead}`:void 0,cacheWrite:void 0!==n.cacheWrite?`$${n.cacheWrite}`:void 0}:void 0}}function _(e){let{selectedModel:t,onSelectModel:n,onOpenAddProvider:s,onThinkingLevelChange:a,className:l=""}=e,[o,c]=(0,i.J0)(!1),[d,p]=(0,i.J0)(""),[h,f]=(0,i.J0)(-1),[b,v]=(0,i.J0)(null),[k,y]=(0,i.J0)({}),{models:w,isLoading:N,setModels:Y,selectedModel:D,setSelectedModel:F}=function(e){let[t,n]=(0,i.J0)([]),[r,s]=(0,i.J0)(!0),[a,l]=(0,i.J0)(e??null),o=(0,i.li)(e);o.current=e;let c=(0,i.hb)(e=>{n(e)},[]),d=(0,i.hb)(async()=>{try{let e=await (0,g.xo)();if(Array.isArray(e.modelList)&&e.modelList.length>0){let t=e.modelList.map(J);n(e=>t.map(t=>{let n=e.find(e=>e.id===t.id&&e.provider===t.provider);return n?.thinkingLevel&&t.thinkingLevels?.includes(n.thinkingLevel)?{...t,thinkingLevel:n.thinkingLevel}:t}));let r=e.defaultModel;if(r&&!o.current){let e=t.find(e=>e.id===r.modelId&&e.provider===r.provider);e&&l(e)}}else Array.isArray(e.models)&&e.models.length>0&&n(e.models);e.selectedModel&&!o.current&&l(e.selectedModel)}catch{}finally{s(!1)}},[]);return(0,i.vJ)(()=>(d(),(0,g.Sy)(d)),[d]),(0,i.vJ)(()=>{e&&(l(e),n(t=>t.map(t=>t.id===e.id&&t.provider===e.provider?{...t,thinkingLevel:e.thinkingLevel}:t)))},[e]),{models:t,isLoading:r,setModels:c,selectedModel:a,setSelectedModel:l}}(t),A=(0,i.li)(null);(0,m.W)(A,()=>{c(!1),v(null),f(-1)});let{filtered:S,favorites:C,recent:T,byProvider:z,visibleFlatList:$,index:j}=(0,i.Kr)(()=>(function(e,t,n){let r=t.trim().toLowerCase(),i=r?e.filter(e=>e.name.toLowerCase().includes(r)||e.provider.toLowerCase().includes(r)||String(e.contextWindow??"").toLowerCase().includes(r)||e.capabilities?.some(e=>e.toLowerCase().includes(r))):e,s=i.filter(e=>e.isFavorite),a=i.filter(e=>e.isRecent&&!e.isFavorite),l={};for(let e of i){let t=e.provider.toUpperCase();(l[t]??=[]).push(e)}let o=[];for(let[e,t]of(n.favorites||o.push(...s),n.recent||o.push(...a),Object.entries(l)))n[e]||o.push(...t);let c={};return o.forEach((e,t)=>{c[L(e)]=t}),{filtered:i,favorites:s,recent:a,byProvider:l,visibleFlatList:o,index:c}})(w,d,k),[w,d,k]),M=L(D),P=async(e,t)=>{t.stopPropagation();let n=L(e);Y(e=>e.map(e=>L(e)===n?{...e,isFavorite:!e.isFavorite}:e));try{await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"toggleFavorite",provider:e.provider,modelId:e.id})})}catch{}},E=e=>{let t=e.thinkingLevels??[];if(0===t.length)return;let r=e.thinkingLevel??t[0],i=t.indexOf(r),s=t[(i+1)%t.length],l=L(e);if(Y(e=>e.map(e=>L(e)===l?{...e,thinkingLevel:s}:e)),M===l&&D){let e={...D,thinkingLevel:s};F(e),n?.(e),a?.(s)}},R=async e=>{let t=!e.isCmdAgent,n=L(e);Y(e=>e.map(e=>L(e)===n?{...e,isCmdAgent:t}:e)),M===n&&D&&F({...D,isCmdAgent:t});try{await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"toggleCmd",provider:e.provider,modelId:e.id})})}catch{}},I=async e=>{F(e),n?.(e),c(!1),v(null);try{await fetch("/api/models",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({actionType:"selectModel",model:e})}),(0,g.kn)()}catch{}};return(0,r.FD)("div",{className:`relative ${l}`,ref:A,onKeyDown:e=>{if(o){if("ArrowDown"===e.key)e.preventDefault(),f(e=>{let t=(e+1)%Math.max(1,$.length);return v($[t]||null),t});else if("ArrowUp"===e.key)e.preventDefault(),f(e=>{let t=(e-1+$.length)%Math.max(1,$.length);return v($[t]||null),t});else if("Enter"===e.key){e.preventDefault();let t=(h>=0?$[h]:null)||b;t&&I(t)}else if("Escape"===e.key)e.preventDefault(),c(!1),v(null);else if("Tab"===e.key){e.preventDefault();let t=(h>=0?$[h]:null)||b;t&&R(t)}else if("ArrowRight"===e.key||"ArrowLeft"===e.key){e.preventDefault();let t=(h>=0?$[h]:null)||b;t&&E(t)}}},children:[(0,r.FD)("button",{type:"button",onClick:()=>{c(e=>!e),v(null),f(-1)},className:"flex items-center space-x-1.5 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-ink/80 font-medium cursor-pointer min-w-0 max-w-full",title:D?`${D.provider} • ${D.name}`:"Select a model",children:[D?(0,r.FD)(r.FK,{children:[(0,r.Y)("span",{className:"text-ink/60 flex-shrink-0",children:D.isCmdAgent?(0,r.Y)("span",{className:"font-mono text-[10px] font-bold text-ink/70",children:"⌘"}):"deepseek"===D.provider.toLowerCase()?(0,r.Y)("span",{children:"🐋"}):(0,r.Y)(x.A,{size:12,className:"text-ink/60"})}),(0,r.FD)("span",{className:"flex items-center space-x-1 min-w-0 max-w-[280px]",children:[(0,r.Y)("span",{className:"text-ink/50 font-normal truncate",children:D.provider}),(0,r.Y)("span",{className:"text-ink/30 flex-shrink-0",children:"•"}),(0,r.Y)("span",{className:"truncate",children:D.name})]})]}):(0,r.FD)(r.FK,{children:[(0,r.Y)("span",{className:"text-ink/60 flex-shrink-0",children:(0,r.Y)(x.A,{size:12,className:"text-ink/60"})}),(0,r.Y)("span",{className:"h-3 w-28 rounded animate-pulse bg-ink/10"})]}),(0,r.Y)(u.A,{size:12,className:"text-ink/40 flex-shrink-0"})]}),o&&(0,r.Y)(O,{search:d,onSearchChange:p,onAddProvider:()=>{c(!1),v(null),s?s():window.dispatchEvent(new CustomEvent("omp:open-settings",{detail:{category:"providers",autoOpenAdd:!0}}))},isLoading:N,filteredModels:S,favoriteModels:C,recentModels:T,providerGroups:z,collapsedSections:k,onToggleCollapse:e=>{y(t=>({...t,[e]:!t[e]}))},selectedModelKey:M,modelIndex:j,focusedIndex:h,hoveredModel:b,onSelect:I,onToggleFavorite:P,onCycleThinking:E,onHoverItem:(e,t)=>{f(e),v(t)},onMouseLeave:()=>v(null)})]})}function W(e){let{thinkingLevels:t,currentThinking:n,onSelect:s}=e,[a,l]=(0,i.J0)(!1),o=(0,i.li)(null);return(0,m.W)(o,()=>l(!1)),(0,r.FD)("div",{className:"relative",ref:o,children:[(0,r.FD)("button",{onClick:()=>t.length>0&&l(!a),disabled:0===t.length,className:"flex items-center space-x-1 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-ink/80 disabled:opacity-40 disabled:cursor-not-allowed",title:0===t.length?"This model exposes no thinking levels":`Thinking Level: ${n}`,children:[(0,r.Y)(z.A,{size:12,className:"text-ink/60"}),(0,r.Y)("span",{className:"hidden lg:inline",children:n})]}),a&&t.length>0&&(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-1 w-40 bg-paper border border-ink/20 rounded-md shadow-lg z-50 py-1 text-xs",children:[(0,r.Y)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold mb-1",children:"Thinking Level"}),t.map(e=>(0,r.FD)("button",{onClick:()=>{l(!1),s(e)},className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[(0,r.Y)("span",{children:e}),n===e&&(0,r.Y)(p.A,{size:12,className:"text-ink"})]},e))]})]})}var K=n("wf");let U=["always-ask","write","yolo"],H={"always-ask":"Always ask",write:"Minimal",yolo:"Full bypass"},B={"always-ask":"Read-only tools run automatically; writes and shell commands ask first.",write:"Reads and edits run automatically; shell commands ask first.",yolo:"Everything runs without asking."};function q(e){let{value:t,onSelect:n}=e,[s,a]=(0,i.J0)(!1),l=(0,i.li)(null);return(0,m.W)(l,()=>a(!1)),(0,r.FD)("div",{className:"relative",ref:l,children:[(0,r.FD)("button",{type:"button",onClick:()=>a(!s),className:"flex items-center space-x-1 hover:bg-ink/5 px-2 py-1 rounded transition-colors text-xs text-ink/80",children:[(0,r.Y)(K.A,{size:12,className:"text-ink/60"}),(0,r.Y)("span",{className:"hidden lg:inline",children:H[t]})]}),s&&(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-1 w-40 bg-paper border border-ink/20 rounded-md shadow-lg z-50 py-1 text-xs",children:[(0,r.Y)("div",{className:"px-3 py-1 text-[10px] uppercase tracking-wider text-ink/40 font-semibold mb-1",children:"Access Control"}),U.map(e=>(0,r.FD)("button",{type:"button",onClick:()=>{n(e),a(!1)},title:B[e],className:"w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center justify-between transition-colors",children:[(0,r.Y)("span",{children:H[e]}),t===e&&(0,r.Y)(p.A,{size:12,className:"text-ink"})]},e))]})]})}function G(e){let{isMobile:t,selectedModel:n,onSelectModel:i,thinkingLevels:s,currentThinking:a,onSelectThinking:l,onThinkingLevelChange:o,isGenerating:c,onStop:d,onSend:u,sendDisabled:p,accessMode:m,onSelectAccess:x}=e;return(0,r.FD)("div",{className:`flex items-center justify-between border-t border-ink/5 bg-canvas/50 rounded-b-md ${t?"px-2 py-2":"px-3 py-2"}`,children:[(0,r.FD)("div",{className:`flex items-center min-w-0 ${t?"space-x-1":"space-x-2"}`,children:[(0,r.Y)(_,{selectedModel:n??void 0,onSelectModel:i,onThinkingLevelChange:o,className:t?"min-w-0 max-w-[58%]":void 0}),(0,r.Y)("div",{className:"w-[1px] h-3 bg-ink/10"}),(0,r.Y)(W,{thinkingLevels:s,currentThinking:a,onSelect:l}),(0,r.Y)("div",{className:"w-[1px] h-3 bg-ink/10"}),(0,r.Y)(q,{value:m,onSelect:x})]}),(0,r.FD)("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[c&&(!t||!!d)&&(0,r.Y)("button",{type:"button",onClick:d,className:`flex items-center justify-center rounded transition-colors cursor-pointer shadow-xs animate-in zoom-in-90 duration-150 flex-shrink-0 ${t?"w-10 h-10 rounded-lg border border-ink/25 text-ink hover:bg-error hover:text-canvas hover:border-error":"w-7 h-7 bg-ink text-canvas hover:bg-error hover:text-canvas"}`,title:"Stop generation",children:(0,r.Y)(h.A,{size:t?14:10,className:"fill-current"})}),(!c||t)&&(0,r.Y)("button",{type:"button",onClick:u,disabled:p,className:`flex items-center justify-center rounded bg-ink text-canvas hover:bg-ink/80 transition-colors disabled:opacity-40 disabled:cursor-not-allowed cursor-pointer flex-shrink-0 ${t?"w-10 h-10 rounded-lg":"w-7 h-7"}`,title:c?"Queue follow-up message":"Send message",children:(0,r.Y)(f.A,{size:t?16:12,className:"ml-px"})})]})]})}let V=/[\s([{]/,Z=/^file:/i;var Q=n("ns");function X(e){let{item:t}=e,n=t.match;return!n||n.start<0||n.start>=n.end||n.end>t.name.length?(0,r.Y)(r.FK,{children:t.name}):(0,r.FD)(r.FK,{children:[t.name.slice(0,n.start),(0,r.Y)("mark",{className:"bg-transparent font-semibold text-ink",children:t.name.slice(n.start,n.end)}),t.name.slice(n.end)]})}function ee(e){let{open:t,kind:n,items:s,activeIndex:a,loading:l,error:o,listboxId:c,optionId:d,onSelect:u,onHover:p}=e,m=(0,i.li)(null);if((0,i.vJ)(()=>{t&&m.current?.scrollIntoView({block:"nearest"})},[a,t,s.length]),!t)return null;let h="mention"===n;return(0,r.FD)("div",{role:"listbox",id:c,"aria-label":h?"Files and agents":"Commands and skills",className:"absolute left-0 right-0 bottom-full mb-1 z-50 min-w-[260px] flex max-h-60 flex-col rounded-md border border-ink/20 bg-paper shadow-lg text-sm",children:[(0,r.Y)("div",{className:"shrink-0 text-[10px] uppercase tracking-wider text-ink/40 px-3 py-1.5 border-b border-ink/10",children:h?"Type to search files and agents":"Type to search commands and skills"}),(0,r.Y)("div",{className:"flex-1 overflow-y-auto",children:o?(0,r.Y)("div",{className:"px-3 py-2 text-error",children:o}):l&&0===s.length?(0,r.Y)("div",{className:"px-3 py-2 text-ink/50",children:"Loading…"}):0===s.length?(0,r.Y)("div",{className:"px-3 py-2 text-ink/50",children:h?"No matching files or agents":"No matching commands or skills"}):s.slice(0,100).map((e,t)=>(0,r.FD)("div",{id:d(t),role:"option","aria-selected":t===a,ref:t===a?m:void 0,onMouseDown:e=>e.preventDefault(),onMouseEnter:()=>p(t),onClick:()=>u(e),className:`px-3 py-2 cursor-pointer ${t===a?"bg-ink/10":""}`,children:[(0,r.FD)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.Y)("span",{className:"truncate",children:(0,r.Y)(X,{item:e})}),"file"===e.source&&(0,r.Y)("span",{className:"text-ink/40 text-[10px] uppercase shrink-0",children:"file"}),"skill"===e.source&&(0,r.Y)("span",{className:"text-ink/40 text-[10px] uppercase shrink-0",children:"skill"})]}),(0,r.Y)("div",{className:"truncate text-ink/50 text-xs",children:e.description})]},e.id))}),(0,r.Y)("div",{className:"shrink-0 px-3 py-1.5 border-t border-ink/10 text-[10px] text-ink/40",children:"↑↓ navigate · Enter select · Esc close"})]})}function et(e){let{value:t,onChange:n,onSend:s,disabled:a=!1,appSettings:l,placeholder:o,className:c,onPaste:d,rootPath:u,variant:p="desktop"}=e,h="mobile"===p,f=(0,i.li)(null),x=(0,i.li)(null),g=function(e){let{value:t,setValue:n,textareaRef:r,disabled:s=!1,rootPath:a}=e,[l,o]=(0,i.J0)(null),[c,d]=(0,i.J0)(0),u=(0,i.li)(!1),p=(0,i.li)(null),{items:m,loading:h,error:f}=function(e,t){let[n,r]=(0,i.J0)({items:[],loading:!1,error:null});return(0,i.vJ)(()=>{if(!e)return void r({items:[],loading:!1,error:null});let n=!1;return r({items:[],loading:!0,error:null}),(0,Q.bF)(e,t??null).then(e=>{n||r({items:e,loading:!1,error:null})}).catch(e=>{n||r({items:[],loading:!1,error:e instanceof Error?e.message:String(e)})}),()=>{n=!0}},[e,t]),n}(l?.kind??null,a??null),x=(0,i.Kr)(()=>(function(e,t){let n=t.trim(),r=Z.test(n),i=r?e.filter(e=>"file"===e.source):e,s=r?n.replace(Z,"").trim():n;if(""===s)return i.map(e=>({...e,match:null}));let a=[];return i.forEach((e,t)=>{let n=function(e,t,n){let r=n.trim().toLowerCase();if(""===r)return null;let i=e.toLowerCase(),s=t.toLowerCase();if(i===r)return{tier:0,match:{start:0,end:e.length}};if(i.startsWith(r))return{tier:1,match:{start:0,end:r.length}};let a=i.indexOf(r);return a>=0?{tier:2,match:{start:a,end:a+r.length}}:s.includes(r)?{tier:3,match:null}:null}(e.name,e.description,s);n&&a.push({...n,index:t})}),a.sort((e,t)=>e.tier-t.tier||e.index-t.index),a.map(e=>({...i[e.index],match:e.match}))})(m,l?.query??""),[m,l?.query]),g=x.length>0?Math.min(Math.max(c,0),x.length-1):-1,b=(0,i.Bi)(),v=(0,i.hb)(e=>`${b}-option-${e}`,[b]),k=(0,i.hb)(()=>{o(null),d(0)},[]),y=(0,i.hb)(e=>{d(e)},[]),w=(0,i.hb)(()=>{u.current=!0},[]),N=(0,i.hb)(()=>{u.current=!1},[]),Y=(0,i.hb)(e=>{var t;let r=e.currentTarget,i=r.value,a=r.selectionStart??i.length;if(u.current||!0===(t=e).isComposing||t.inputType?.startsWith("insertFromPaste")===!0||t.inputType?.startsWith("insertFromDrop")===!0){n(i),k();return}(n(i),s)?k():(o(function(e,t){let n=Math.max(0,Math.min(t,e.length));for(let t=n-1;t>=0;t--){let r=e[t];if(/\s/.test(r))break;if("/"===r||"@"===r){if("/"===r){if(0!==t)return null;return{kind:"command",query:e.slice(t+1,n),start:t,end:n}}if(0===t||V.test(e[t-1]))return{kind:"mention",query:e.slice(t+1,n),start:t,end:n};break}}return null}(i,a)),d(0))},[n,k,s]),D=(0,i.hb)(e=>{var r;if(!l)return;let i=(r=`${e.token} `,{value:t.slice(0,l.start)+r+t.slice(l.end),caret:l.start+r.length});p.current=i.caret,n(i.value),k()},[t,l,n,k]),F=(0,i.hb)(e=>!u.current&&229!==e.keyCode&&!!l&&("ArrowDown"===e.key||"ArrowUp"===e.key?(e.preventDefault(),x.length>0&&d((g+("ArrowDown"===e.key?1:-1)+x.length)%x.length),!0):("Enter"===e.key||"Tab"===e.key)&&x.length>0?(e.preventDefault(),e.stopPropagation(),D(x[g]),!0):"Escape"===e.key&&(e.preventDefault(),e.stopPropagation(),k(),!0)),[l,x,g,D,k]);return(0,i.Nf)(()=>{if(null==p.current)return;let e=p.current;p.current=null;let t=r.current;t&&(t.focus(),t.setSelectionRange(e,e))},[t,r]),{trigger:l,isOpen:null!==l,matches:x,loading:h,error:f,activeIndex:g,setActiveIndex:y,handleChange:Y,handleCompositionStart:w,handleCompositionEnd:N,handleKeyDown:F,selectItem:D,close:k,listboxId:b,optionId:v}}({value:t,setValue:n,textareaRef:f,disabled:a,rootPath:u});return(0,m.W)(x,g.close),(0,r.FD)("div",{className:"relative",ref:x,children:[(0,r.Y)("textarea",{ref:f,value:t,onChange:g.handleChange,onCompositionStart:g.handleCompositionStart,onCompositionEnd:g.handleCompositionEnd,onKeyDown:e=>{if(g.handleKeyDown(e)||"Enter"!==e.key)return;let t=l?.keybindingSend||"Enter",n=l?.keybindingNewLine||"Shift + Enter",r=l?.keybindingSteering||"Ctrl / Cmd + Enter",i="u">typeof navigator&&navigator.platform.toUpperCase().indexOf("MAC")>=0?e.metaKey:e.ctrlKey,o=e.shiftKey,c=t=>"Enter"===t&&!o&&!i&&!e.altKey||"Shift + Enter"===t&&!!o&&!i&&!e.altKey||"Ctrl / Cmd + Enter"===t&&!o&&!!i&&!e.altKey,d=!o&&!i&&!e.altKey;(!h||!d)&&(c(r)?(e.preventDefault(),a||s({steering:!0})):c(t)?(e.preventDefault(),a||s()):c(n)||e.preventDefault())},onPaste:d,disabled:a,placeholder:o,enterkeyhint:h?"enter":void 0,className:c,"aria-autocomplete":"list","aria-expanded":g.isOpen,"aria-controls":g.listboxId,"aria-haspopup":"listbox","aria-activedescendant":g.isOpen&&g.matches.length>0?g.optionId(g.activeIndex):void 0}),(0,r.Y)(ee,{open:g.isOpen,kind:g.trigger?.kind??"mention",items:g.matches,activeIndex:g.activeIndex,loading:g.loading,error:g.error,listboxId:g.listboxId,optionId:g.optionId,onSelect:g.selectItem,onHover:g.setActiveIndex})]})}var en=n("Bt"),er=n("HD");function ei(e){let{attachments:t,onFilesSelected:n,onRemove:s}=e,a=(0,i.li)(null);return(0,r.FD)(r.FK,{children:[(0,r.FD)("div",{className:"flex items-center flex-wrap gap-1.5 px-3 py-2 border-b border-ink/5 text-ink/60",children:[(0,r.Y)("button",{onClick:()=>a.current?.click(),className:"flex items-center justify-center hover:bg-ink/5 p-1 rounded transition-colors text-ink/60 hover:text-ink shrink-0",title:"Attach file or image",children:(0,r.Y)(en.A,{size:14})}),t.map(e=>(0,r.FD)("div",{className:"relative flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 pr-6 text-xs shadow-sm group",children:[e.preview?(0,r.Y)("img",{src:e.preview,alt:"preview",className:"w-6 h-6 object-cover rounded-sm mr-1.5 border border-ink/5"}):(0,r.Y)("div",{className:"w-6 h-6 flex items-center justify-center bg-ink/5 rounded-sm mr-1.5 text-ink/60",children:(0,r.Y)(er.A,{size:12})}),(0,r.Y)("span",{className:"truncate max-w-[120px] font-mono text-[10px] text-ink/80",children:e.file.name}),(0,r.Y)("button",{onClick:()=>s(e.id),className:"absolute right-0.5 top-1/2 -translate-y-1/2 p-0.5 text-ink/40 hover:text-error hover:bg-error/10 rounded transition-colors",title:"Remove attachment",children:(0,r.Y)(k.A,{size:10})})]},e.id))]}),(0,r.Y)("input",{type:"file",multiple:!0,className:"hidden",ref:a,onChange:e=>{e.currentTarget.files&&e.currentTarget.files.length>0&&n(Array.from(e.currentTarget.files)),a.current&&(a.current.value="")}})]})}let es=["auto","off","minimal","low","medium","high","xhigh","max"];function ea(e){if(!e||0===e.length)return[];let t=new Set(e.filter(e=>e&&"auto"!==e));return[...es.filter(e=>t.delete(e)),...t]}function el(e){let{value:t,onChange:n,onSend:s,isGenerating:a,onStop:l,className:o="",disabled:c=!1,appSettings:d={},attachments:u,onAttachmentsChange:p,onThinkingLevelChange:m,onModelChange:h,sessionModel:f,sessionThinkingLevel:x,rootPath:b,variant:v="desktop",accessMode:k,onAccessModeChange:y,composerModelRef:w}=e,[N,Y]=(0,i.J0)([]),D=void 0!==u?u:N,F=e=>{p?p(e):Y(e)},[A,S]=(0,i.J0)(null),[C,T]=(0,i.J0)("auto");(0,i.vJ)(()=>{A?.id&&(w.current={provider:A.provider,modelId:A.id,thinkingLevel:A.thinkingLevel??"auto"})},[A?.provider,A?.id,A?.thinkingLevel,w]);let z=(0,i.li)(null);z.current=x??null;let $=(0,i.li)(f??null);$.current=f??null;let j=(e,t)=>{let n=z.current;if(!n)return t;let r=ea(e??[]);return 0===r.length||r.includes(n)?n:t};(0,i.vJ)(()=>{if(!f?.provider||!f.modelId)return;let e=!0;return(0,g.xo)().then(t=>{if(!e||!f)return;let n=(t.modelList||[]).find(e=>e.id===f.modelId&&e.provider===f.provider);n&&S(e=>({id:n.id,name:n.name,provider:n.provider,contextWindow:n.contextWindow,thinkingLevels:n.thinkingLevels,thinkingLevel:j(n.thinkingLevels,e?.thinkingLevel??n.thinkingLevels?.[0]??"off")}))}).catch(()=>{}),()=>{e=!1}},[f?.provider,f?.modelId]),(0,i.vJ)(()=>{x&&S(e=>{if(!e)return e;let t=ea(e.thinkingLevels??[]),n=0===t.length||t.includes(x)?x:e.thinkingLevel;return n===e.thinkingLevel?e:{...e,thinkingLevel:n}})},[x]),(0,i.vJ)(()=>{let e=!0,t=async()=>{try{let t=await (0,g.xo)();if(!e)return;if(Array.isArray(t.modelList)&&t.modelList.length>0){let e=$.current;if(e?.provider&&e.modelId){let n=t.modelList.find(t=>t.id===e.modelId&&t.provider===e.provider);n&&S(e=>({id:n.id,name:n.name,provider:n.provider,thinkingLevels:n.thinkingLevels,thinkingLevel:j(n.thinkingLevels,e?.thinkingLevel??n.thinkingLevels?.[0]??"off")}));return}let n=t.selectedModel;if(n?.provider&&n.id){let e=t.modelList.find(e=>e.id===n.id&&e.provider===n.provider);if(e)return void S(t=>({id:e.id,name:e.name,provider:e.provider,thinkingLevels:e.thinkingLevels,thinkingLevel:j(e.thinkingLevels,t?.thinkingLevel??e.thinkingLevels?.[0]??"off")}))}let r=t.defaultModel;if(r){let e=t.modelList.find(e=>e.id===r.modelId&&e.provider===r.provider);e&&S(t=>({id:e.id,name:e.name,provider:e.provider,thinkingLevels:e.thinkingLevels,thinkingLevel:j(e.thinkingLevels,t?.thinkingLevel??e.thinkingLevels?.[0]??"off")}))}}else if(t.selectedModel){let e=t.selectedModel;S(t=>({...e,thinkingLevel:j(e.thinkingLevels,t?.thinkingLevel??e.thinkingLevel??"off")}))}}catch{}};t();let n=(0,g.Sy)(t);return()=>{e=!1,n()}},[]);let L=(0,i.Kr)(()=>ea(A?.thinkingLevels),[A]);(0,i.vJ)(()=>{A?.thinkingLevel&&T(A.thinkingLevel)},[A?.thinkingLevel]);let M=e=>{let t=e.map(e=>({id:Math.random().toString(36).substring(7),file:e,preview:e.type.startsWith("image/")?URL.createObjectURL(e):""}));for(let e of(F(e=>[...e,...t]),t)){if(!e.file.type.startsWith("image/"))continue;let t=new FileReader;t.onload=()=>{let n=t.result.split(",")[1];n&&F(t=>t.map(t=>t.id===e.id?{...t,dataBase64:n}:t))},t.readAsDataURL(e.file)}},P=e=>{(t.trim()||0!==D.length)&&(s(D,e),F([]))},E="mobile"===v;return(0,r.FD)("div",{className:`relative border border-ink/20 rounded-md bg-paper focus-within:border-ink transition-colors flex flex-col shadow-sm ${o}`,children:[(0,r.Y)(ei,{attachments:D,onFilesSelected:M,onRemove:e=>{F(t=>{let n=t.find(t=>t.id===e);return n&&n.preview&&URL.revokeObjectURL(n.preview),t.filter(t=>t.id!==e)})}}),(0,r.Y)(et,{value:t,onChange:n,onSend:P,disabled:c,appSettings:d,rootPath:b,placeholder:c?"Please select a workspace above to start prompting...":"@ for files/agents; / for commands and skills; ! for shell; # for snippets (Paste images/files here)",className:`w-full bg-transparent border-none focus:outline-none resize-none text-ink placeholder-ink/40 disabled:opacity-50 disabled:cursor-not-allowed ${E?"px-3 py-3 text-base min-h-[68px] max-h-40":"px-3 py-3 text-sm min-h-[80px]"}`,onPaste:e=>{let t=e.clipboardData;t&&t.files.length>0&&(e.preventDefault(),M(Array.from(t.files)))},variant:v}),(0,r.Y)(G,{isMobile:E,selectedModel:A,onSelectModel:e=>{S(e),h?.(e.provider,e.id)},thinkingLevels:L,currentThinking:C,onSelectThinking:e=>{T(e),S(t=>t?{...t,thinkingLevel:e}:t),m?.(e)},onThinkingLevelChange:m,isGenerating:a,onStop:l,onSend:()=>P(),sendDisabled:c||!t.trim()&&0===D.length,accessMode:k,onSelectAccess:y})]})}var eo=n("rD"),ec=n("I"),ed=n("J"),eu=n("p"),ep=n("wU"),em=n("DT"),eh=n("rK"),ef=n("b0"),ex=n("pH");function eg(e){let{text:t,className:n="flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:s=10,iconClassName:a,copiedIconClassName:l="text-success",label:o,copiedLabel:c="Copied",wrapLabel:d=!1,copiedLabelClassName:u,title:m,onClick:h,resetMs:f=2e3}=e,{copied:x,flagCopied:g}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:2e3,[t,n]=(0,i.J0)(!1),r=(0,i.li)(null),s=(0,i.hb)(()=>{n(!0),r.current&&clearTimeout(r.current),r.current=setTimeout(()=>n(!1),e)},[e]);return(0,i.vJ)(()=>()=>{r.current&&clearTimeout(r.current)},[]),{copied:t,flagCopied:s}}(f),b=async e=>{h?.(e),!t||await (0,ex.l)(t)&&g()},v=x?c:o;return(0,r.FD)("button",{type:"button",onClick:b,className:n,title:m,children:[x?(0,r.Y)(p.A,{size:s,className:l}):(0,r.Y)(ef.A,{size:s,className:a}),void 0!==v&&(d?(0,r.Y)("span",{className:x?u:void 0,children:v}):v)]})}function eb(e){let{thinking:t,defaultExpanded:n=!1,showSeparator:s=!1}=e,a="object"==typeof t&&!!t.isGenerating,[l,o]=(0,i.J0)(n||a),c=(0,i.li)(null);(0,i.vJ)(()=>{a&&o(!0)},[a]);let d="string"==typeof t?t:t.thought||"",p=d.match(/<system-notice[^>]*>([\s\S]*?)<\/system-notice>/),m=p?.[1]?.trim()??"",h=d.replace(/<system-notice[^>]*>[\s\S]*?<\/system-notice>/g,"").trim(),f="object"==typeof t?t.duration:void 0,g="object"==typeof t&&t.summary?t.summary:h.slice(0,100)+(h.length>100?"...":"");return((0,i.vJ)(()=>{if(!l||!a)return;let e=c.current;e&&(e.scrollTop=e.scrollHeight)},[l,h,a]),h)?(0,r.FD)("div",{className:`mx-3 ${s?"space-y-1.5":""}`,children:[s&&(0,r.FD)("div",{className:"flex items-center gap-2 px-1 pt-0.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/35",children:"Thinking"}),(0,r.Y)("span",{className:"h-px flex-1 bg-ink/8"})]}),(0,r.FD)("div",{className:"overflow-hidden rounded-xl border border-ink/10 bg-paper transition-colors hover:border-ink/20",children:[(0,r.FD)("button",{type:"button",onClick:()=>o(e=>!e),className:"flex w-full items-center gap-2.5 px-3 py-2.5 text-left transition-colors hover:bg-ink/[0.03] cursor-pointer select-none","aria-expanded":l,children:[(0,r.Y)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg bg-ink/5 text-ink/70",children:(0,r.Y)(x.A,{size:13})}),(0,r.FD)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"text-[12px] font-semibold tracking-tight text-ink",children:"Thinking"}),a&&(0,r.Y)("span",{className:"h-1.5 w-1.5 rounded-full bg-ink/60 animate-pulse"})]}),!l&&g&&(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/45",children:g})]}),f&&(0,r.Y)("span",{className:"shrink-0 rounded-full bg-ink/5 px-2 py-0.5 font-mono text-[10px] text-ink/50",children:f}),(0,r.Y)(u.A,{size:14,className:`shrink-0 text-ink/35 transition-transform duration-200 ${l?"rotate-180":""}`})]}),l&&(0,r.FD)("div",{className:"border-t border-ink/8 bg-canvas/40 px-3 py-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between pb-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Model Reasoning & Strategy"}),(0,r.Y)(eg,{text:h,className:"flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",title:"Copy thinking",wrapLabel:!0,label:"Copy"})]}),m&&(0,r.FD)("div",{className:"mb-2 flex items-start gap-2.5 rounded-lg border border-ink/15 bg-paper px-3 py-2.5",children:[(0,r.Y)("span",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-ink/10",children:(0,r.Y)(em.A,{size:13,className:"text-ink/70"})}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.Y)("div",{className:"mb-0.5 text-[9.5px] font-semibold uppercase tracking-[0.12em] text-ink/50",children:"System Notice"}),(0,r.Y)("div",{className:"text-[12px] leading-relaxed text-ink/85",children:(0,r.Y)(eh.T,{content:m,className:"text-[12px] text-ink/85 leading-relaxed"})})]})]}),(0,r.Y)("div",{ref:c,className:"max-h-72 overflow-auto border-l-2 border-ink/15 py-1 pl-3 text-ink/80 scrollbar-overlay-container scrollbar-overlay-static select-text",children:(0,r.Y)(eh.T,{content:h,className:"text-[12px] leading-relaxed text-ink/85 [&_.code-block]:my-2 [&_p]:my-1.5 [&_ul]:my-1.5 [&_ol]:my-1.5"})})]})]})]}):null}function ev(e){if(!0===e.synthetic||"skipped"===e.status||"aborted"===e.status)return!0;let t=e.details;return t?.__synthetic===!0||t?.source==="assistant_stop_skipped"||t?.executed===!1}var ek=n("N"),ey=n("Jr"),ew=n("SR"),eN=n("aP"),eY=n("AB"),eD=n("uV"),eF=n("DK"),eA=n("WO"),eS=n("R"),eC=n("bt"),eT=n("k"),ez=n("wJ"),e$=n("s0");let ej=/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)|\x1b[()][0-9A-B]|\x1b\[[0-9;?]*[A-Za-z]/g;function eL(e){return e?e.includes("\x1b")?e.replace(ej,"").replace(/\r\n/g,"\n").replace(/\r/g,"\n"):e.replace(/\r\n/g,"\n").replace(/\r/g,"\n"):""}let eM=/^[A-Za-z_][A-Za-z0-9_.:-]*/,eP=/([A-Za-z_:][A-Za-z0-9_.:-]*)\s*(?:=\s*(?:"([^"]*)"|'([^']*)'|([^\s"'>]+)))?/g;function eE(e){return"system-reminder"===e||"reminder"===e}function eR(e,t){let n="";for(let r=t;r<e.length;r+=1){let t=e[r];if(n)t===n&&(n="");else if('"'===t||"'"===t)n=t;else if(">"===t)return r}return -1}function eI(e,t){let n=e.slice(t,t+9);if(n.startsWith("\x3c!--")){let n=e.indexOf("--\x3e",t+4);return -1===n?void 0:{kind:"other",name:"",attrs:"",end:n+3}}if("<![CDATA["===n){let n=e.indexOf("]]>",t+9);return -1===n?void 0:{kind:"other",name:"",attrs:"",end:n+3}}if("!"===e[t+1]||"?"===e[t+1]){let n=eR(e,t+2);return -1===n?void 0:{kind:"other",name:"",attrs:"",end:n+1}}let r="/"===e[t+1],i=t+(r?2:1),s=eM.exec(e.slice(i,i+64))?.[0];if(!s)return;let a=eR(e,i+s.length);if(-1===a)return;let l=e.slice(i+s.length,a);return r?{kind:"end",name:s,attrs:l,end:a+1}:{kind:"/"===e[a-1]?"self":"start",name:s,attrs:l,end:a+1}}function eO(e){let t=e.search(/\S/);if(-1===t||"<"!==e[t])return;let n=eI(e,t);if(!n||"start"!==n.kind)return;let r=[n.name];for(let t=n.end;t<e.length;){if("<"!==e[t]){t+=1;continue}let i=eI(e,t);if(!i)break;if("start"===i.kind)r.push(i.name);else if("end"===i.kind){if(r.pop()!==i.name)return;if(0===r.length){let r=e.slice(i.end).trim();if(r.startsWith("<"))return;return{tag:n.name,attributes:function(e){let t={};for(let n of e.matchAll(eP))t[n[1]]=n[2]??n[3]??n[4]??"";return t}(n.attrs),inner:function(e){let t=e.split("\n");for(t.length>1&&!t[0].trim()&&t.shift();t.length>1&&!t[t.length-1].trim();)t.pop();let n=1/0;for(let e of t)e.trim()&&(n=Math.min(n,e.length-e.trimStart().length));return Number.isFinite(n)?0===n?t.join("\n"):t.map(e=>e.slice(Math.min(n,e.length-e.trimStart().length))).join("\n"):""}(e.slice(n.end,t)),...r?{rest:r}:{}}}}t=i.end}}var eJ=n("yy"),e_=n("t");function eW(e){let t,{tool:n,icon:s,title:a,subtitle:l,meta:o,isOpen:c,onToggle:d,defaultExpanded:m=!1,alwaysExpanded:h=!1,children:f}=e,[x,g]=(0,i.J0)(m),b=!h,v=h||(void 0!==c?c:x),k=n.status||(n.error?"error":"success"),y="running"===k,w=!!f,N=ev(n);return(0,r.FD)("div",{className:`group overflow-hidden rounded-xl border transition-all duration-200 ${"error"===k&&!N?"border-error/25 bg-error/[0.03]":y?"border-ink/15 bg-paper":N?"border-dashed border-ink/15 bg-paper/60 opacity-80":"border-ink/10 bg-paper hover:border-ink/20"} ${v?"shadow-sm":""}`,children:[(0,r.FD)("button",{type:"button",onClick:()=>{w&&b&&(d?d():g(e=>!e))},disabled:!w||!b,"aria-expanded":v,className:`flex w-full items-center gap-2.5 px-3 py-2.5 text-left transition-colors ${w&&b?"cursor-pointer hover:bg-ink/[0.03]":"cursor-default"} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`,children:[(0,r.Y)("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg transition-colors ${"error"===k&&!N?"bg-error/10 text-error":y?"bg-ink/8 text-ink":"bg-ink/5 text-ink/70 group-hover:bg-ink/8"}`,children:s}),(0,r.FD)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"truncate text-[12px] font-semibold tracking-tight text-ink",children:a}),(t="h-1.5 w-1.5 rounded-full","running"===k?(0,r.Y)("span",{className:`${t} bg-ink/60 animate-pulse`}):N?(0,r.Y)("span",{className:`${t} bg-ink/30`}):"error"===k?(0,r.Y)("span",{className:`${t} bg-error`}):(0,r.Y)("span",{className:`${t} bg-success`}))]}),l&&(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/45",children:l})]}),(0,r.FD)("span",{className:"flex shrink-0 items-center gap-2",children:[o,function(e){if(ev(e))return(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-ink/8 px-2 py-0.5 text-[10px] font-semibold text-ink/50",children:[(0,r.Y)(eJ.A,{size:10})," Skipped"]});let t=e.status||(e.error?"error":"success");return"error"===t?(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-error/10 px-2 py-0.5 text-[10px] font-semibold text-error",children:[(0,r.Y)(eu.A,{size:10})," Failed"]}):"running"===t?(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-ink/8 px-2 py-0.5 text-[10px] font-semibold text-ink/60",children:[(0,r.Y)(e_.A,{size:10,className:"animate-spin"})," Running"]}):(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-success/10 px-2 py-0.5 text-[10px] font-semibold text-success",children:[(0,r.Y)(p.A,{size:10})," Done"]})}(n),w&&b&&(0,r.Y)(u.A,{size:14,className:`text-ink/35 transition-transform duration-200 ${v?"rotate-180":""}`})]})]}),v&&w&&(0,r.Y)("div",{className:"border-t border-ink/8 bg-canvas/40 px-3 py-3 code-surface",children:f})]})}var eK=n("DU"),eU=n("Po");function eH(e){let{text:t}=e,n=(0,i.Kr)(()=>(function(e){let t=[],n=null;for(let r of e.split(/\r?\n/)){if(r.startsWith("diff --git ")){n&&t.push(n),n=null;continue}if(r.startsWith("--- ")){n?n.oldPath=r.slice(4).replace(/^[ab]\//,""):n={oldPath:r.slice(4).replace(/^[ab]\//,""),newPath:"",lines:[]};continue}if(r.startsWith("+++ ")){n||(n={oldPath:"",newPath:"",lines:[]}),n.newPath=r.slice(4).replace(/^[ab]\//,"");continue}if(!n)if(!(r.startsWith("@@")||r.startsWith("+")||r.startsWith("-")))continue;else n={oldPath:"",newPath:"",lines:[]};r.startsWith("@@")?n.lines.push({kind:"meta",text:r}):r.startsWith("+")&&!r.startsWith("+++")?n.lines.push({kind:"add",text:r.slice(1)}):r.startsWith("-")&&!r.startsWith("---")?n.lines.push({kind:"del",text:r.slice(1)}):n.lines.push({kind:"context",text:r.startsWith(" ")?r.slice(1):r})}return n&&t.push(n),t})(t),[t]),s=(0,eU.w)(),a=(0,i.Kr)(()=>n.map(e=>{let t=(0,eK.sQ)(e.newPath||e.oldPath);return(0,eK.O9)(e.lines.map(e=>"meta"===e.kind?"":e.text).join("\n"),t)}),[n,s]);if(0===n.length)return(0,r.Y)("pre",{className:"max-h-48 overflow-auto whitespace-pre overflow-x-auto rounded-lg border border-ink/8 bg-paper p-3 font-mono text-[11px] leading-relaxed text-ink/80 select-text",children:t});let l=n.reduce((e,t)=>{for(let n of t.lines)"add"===n.kind?e.added++:"del"===n.kind&&e.removed++;return e},{added:0,removed:0});return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/60",children:n[0]?.newPath||n[0]?.oldPath||"diff"}),n.length>1&&(0,r.FD)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:[n.length," files"]}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-1.5 font-mono text-[10px]",children:[(0,r.FD)("span",{className:"text-success",children:["+",l.added]}),(0,r.FD)("span",{className:"text-error",children:["-",l.removed]})]})]}),(0,r.Y)("div",{className:"max-h-56 overflow-auto bg-paper font-mono text-[11px] leading-relaxed select-text",children:n.map((e,t)=>(0,r.Y)("div",{className:t>0?"border-t border-ink/6":"",children:e.lines.map((e,n)=>{let i="add"===e.kind?"bg-success/[0.07]":"del"===e.kind?"bg-error/[0.07]":"meta"===e.kind?"bg-ink/[0.04]":"",s="add"===e.kind?"text-success":"del"===e.kind?"text-error":"meta"===e.kind?"text-ink/45":"text-ink/70",l="add"===e.kind?"+":"del"===e.kind?"-":"meta"===e.kind?"@":" ",o=a[t]?.[n]||"";return(0,r.FD)("div",{className:`flex px-2.5 ${i}`,children:[(0,r.Y)("span",{className:`w-4 shrink-0 select-none font-bold ${s}`,children:l}),"meta"!==e.kind&&o?(0,r.Y)("span",{className:"shiki min-w-0 flex-1 whitespace-pre-wrap break-all",dangerouslySetInnerHTML:{__html:o}}):(0,r.Y)("span",{className:`min-w-0 flex-1 whitespace-pre-wrap break-all ${s}`,children:e.text||" "})]},n)})},t))})]})}var eB=n("m"),eq=n("rr"),eG=n("F"),eV=n("k8"),eZ=n("d");function eQ(e){let{jsonString:t,title:n,maxHeightClass:s,showHeader:a=!0,className:l="",compact:o=!1,icon:c}=e,d=(0,i.Kr)(()=>t.split("\n"),[t]),u=(0,eU.w)(),p=(0,i.Kr)(()=>(0,eK.PH)(t),[t,u]);return(0,r.FD)("div",{className:`overflow-hidden ${o?"rounded-md":"rounded-lg"} border border-ink/8 bg-paper ${l}`,children:[a&&(0,r.FD)("div",{className:`flex items-center justify-between border-b border-ink/6 bg-canvas/40 ${o?"px-2.5 py-1":"px-3 py-1.5"}`,children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 min-w-0",children:[c||(0,r.Y)(eZ.A,{size:o?10.5:11,className:"text-ink/60 shrink-0"}),(0,r.Y)("span",{className:`font-mono ${o?"text-[10px]":"text-[10.5px]"} font-semibold text-ink truncate`,children:n||"JSON"}),(0,r.Y)("span",{className:`rounded bg-ink/5 px-1.5 py-0.2 font-mono ${o?"text-[8.5px]":"text-[9px]"} uppercase tracking-wider text-ink/50 shrink-0`,children:"JSON"}),(0,r.FD)("span",{className:`font-mono ${o?"text-[9px]":"text-[9.5px]"} text-ink/40 shrink-0`,children:[d.length," ",1===d.length?"line":"lines"]})]}),(0,r.Y)(eg,{text:t,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink shrink-0",title:"Copy JSON",onClick:e=>e.stopPropagation(),label:"Copy"})]}),(0,r.FD)("div",{className:`flex ${s||(o?"max-h-40":"max-h-56")} items-start overflow-x-auto font-mono ${o?"text-[10.5px] leading-snug":"text-[11px] leading-relaxed"} select-text`,children:[(0,r.Y)("div",{className:`sticky left-0 flex-shrink-0 select-none border-r border-ink/6 bg-canvas/50 ${o?"py-1.5 pl-2 pr-1.5 text-[9.5px]":"py-2 pl-2.5 pr-2 text-[10px]"} text-right text-ink/25`,children:d.map((e,t)=>(0,r.Y)("div",{children:t+1},t))}),(0,r.Y)("pre",{className:`flex-1 overflow-x-auto ${o?"p-1.5":"p-2"} whitespace-pre text-ink/85 font-mono`,dangerouslySetInnerHTML:{__html:p}})]})]})}var eX=n("U8");let e0={running:{icon:(0,r.Y)(e_.A,{size:11,className:"animate-spin text-ink/50"}),label:"running"},done:{icon:(0,r.Y)(eB.A,{size:11,className:"text-success"}),label:"done"},failed:{icon:(0,r.Y)(eq.A,{size:11,className:"text-error"}),label:"failed"},aborted:{icon:(0,r.Y)(eG.A,{size:11,className:"text-ink/35"}),label:"aborted"}};function e1(e){return"number"==typeof e?(0,eX.Rk)(e)??"":""}function e5(e){return"number"==typeof e?(0,eX.BD)(e,3):""}function e2(e){let{tool:t}=e,[n,s]=(0,i.J0)(!1),[a,l]=(0,i.J0)(!0),o=t.details??{},c=Array.isArray(o.results)?o.results:[],d=Array.isArray(o.progress)?o.progress:[],p=(0,i.Kr)(()=>t.output?(0,eK.Bl)(t.output):{isValid:!1},[t.output]),m="object"==typeof t.input&&null!==t.input?t.input:void 0,h="string"==typeof m?.context?m.context.trim():"",f=Array.isArray(m?.tasks)?m.tasks:[],x=(0,i.Kr)(()=>c.length>0?c:d.length>0?d:f.length>0?f.map((e,n)=>({id:`task-sub-${n}`,name:e.name,agent:e.agent||"scout",task:e.task,status:"success"===t.status?"done":"running"})):[],[c,d,f,t.status]);if(0===x.length&&!t.output&&!h)return null;let g=x.reduce((e,t)=>e+("number"==typeof t.tokens?t.tokens:0),0),b=x.reduce((e,t)=>e+("number"==typeof t.cost?t.cost:0),0);return(0,r.FD)("div",{className:"space-y-2.5",children:[x.length>0&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 px-2.5 py-1.5",children:[(0,r.FD)("span",{className:"flex items-center gap-1 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(A.A,{size:11,className:"text-ink/60"}),"Subagents"]}),(0,r.FD)("span",{className:"ml-auto font-mono text-[10px] text-ink/45",children:[x.length," ",x.length>1?"agents":"agent",g?` \xb7 ${e1(g)} tok`:"",b?` \xb7 ${e5(b)}`:""]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 px-2.5 py-1",children:x.map((e,t)=>{var n;let i=!0===e.aborted?"aborted":"string"==typeof e.error&&e.error?"failed":"number"==typeof e.exitCode?0===e.exitCode?"done":"failed":"done"===e.status||"completed"===e.status||"success"===e.status?"done":"failed"===e.status?"failed":"aborted"===e.status?"aborted":"running",s=e0[i],a="string"==typeof e.name&&e.name?e.name:null,l="string"==typeof e.agent?e.agent:"scout",o=[e1(e.tokens),e5(e.cost),"running"!==i?"number"!=typeof(n=e.durationMs)||!Number.isFinite(n)||n<1e3?"":`${Math.floor(n/1e3)}s`:""].filter(Boolean).join(" · ");return(0,r.FD)("div",{className:"flex items-center gap-2 py-1.5 text-[11.5px]",children:[(0,r.Y)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded-md bg-ink/[0.04]",children:s.icon}),(0,r.Y)("span",{className:"shrink-0 font-mono text-[10.5px] font-semibold text-ink",children:a||l}),a&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/50",children:l}),(0,r.Y)("span",{className:"ml-auto shrink-0 font-mono text-[9.5px] text-ink/40",children:o||("done"===i?"settled":"running")})]},"string"==typeof e.id?e.id:`row-${t}`)})})]}),h&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("button",{type:"button",onClick:()=>s(e=>!e),className:"flex w-full cursor-pointer items-center justify-between px-2.5 py-1.5 text-left transition-colors hover:bg-ink/[0.02]",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(eV.A,{size:11,className:"text-ink/60"}),"Goal & Constraints"]}),(0,r.Y)(u.A,{size:12,className:`text-ink/40 transition-transform duration-150 ${n?"rotate-180":""}`})]}),n&&(0,r.Y)("div",{className:"border-t border-ink/8 bg-canvas/30 px-3 py-2 text-[11.5px] text-ink/80 select-text leading-relaxed",children:(0,r.Y)(eh.T,{content:h})})]}),f.length>0&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("button",{type:"button",onClick:()=>l(e=>!e),className:"flex w-full cursor-pointer items-center justify-between px-2.5 py-1.5 text-left transition-colors hover:bg-ink/[0.02]",children:[(0,r.FD)("span",{className:"flex items-center gap-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(ew.A,{size:11,className:"text-ink/60"}),"Task Brief & Specification"]}),(0,r.Y)(u.A,{size:12,className:`text-ink/40 transition-transform duration-150 ${a?"rotate-180":""}`})]}),a&&(0,r.Y)("div",{className:"divide-y divide-ink/8 border-t border-ink/8 bg-canvas/30",children:f.map((e,t)=>(0,r.FD)("div",{className:"p-3 space-y-1.5 text-[11.5px] text-ink/80 select-text",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)("span",{className:"font-semibold text-ink text-[12px]",children:e.name||`Task #${t+1}`}),e.agent&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9.5px] text-ink/60",children:e.agent})]}),e.task&&(0,r.Y)("div",{className:"text-ink/85 leading-relaxed font-sans",children:(0,r.Y)(eh.T,{content:e.task})})]},t))})]}),t.output&&(p.isValid&&p.pretty?(0,r.Y)(eQ,{jsonString:p.pretty,title:"Yield Output",maxHeightClass:"max-h-72",showHeader:!0}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 border-b border-ink/8 px-2.5 py-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/50",children:[(0,r.Y)(A.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Yield Output"})]}),(0,r.Y)("div",{className:"bg-canvas/30 px-3 py-2 text-[11px] font-sans leading-relaxed text-ink/80 select-text",children:(0,r.Y)(eh.T,{content:t.output})})]}))]})}function e4(e){let t=e.replace(/:$/,"").trim();return(t=(t=(t=(t=t.replace(/^active\s+phase(?:\s+\d+\/\d+)?(?:\s*[:\-]\s*|\s+)?/i,"")).replace(/^["']|["']$/g,"")).replace(/\s*\(\d+(?:\/\d+)?\s*(?:done|remaining|tasks)?\)$/i,"")).replace(/^\((.+)\)$/,"$1")).trim()||"Tasks"}function e3(e){let t,n=e.input,r="object"==typeof n&&null!==n?n:void 0,i=e.output||"";r?.op==="done"&&r.task?t=`Completed: ${r.task}`:r?.op==="init"&&(t="Initialized Todo List");let s=i.split(/\r?\n/),a=[],l={phase:"Tasks",tasks:[]},o=!1;for(let e of s){let t=e.trim();if(!t)continue;if(t.endsWith(":")&&!t.startsWith("Overall")&&!t.startsWith("Remaining")){let e=e4(t);l.tasks.length>0&&a.push(l),l={phase:e,tasks:[]},o=!0;continue}let n=t.match(/^(?:[-*]\s*)?\[([ xX])\]\s*(.+)$/);if(n){let e=n[1].toLowerCase(),t=n[2].trim(),r="x"===e?"done":"pending";(t.includes("(in progress)")||t.includes("[in_progress]"))&&(r="in_progress",t=t.replace(/\(in progress\)/gi,"").replace(/\[in_progress\]/gi,"").trim()),l.tasks.push({text:t,status:r,phase:l.phase});continue}let r=t.match(/^-\s*(.+?)\s*\[(in_progress|pending|done)\](?:\s*\((.+?)\))?$/);if(r&&!o){let e=r[1].trim(),t=r[2],n=e4(r[3]?.trim()||"Tasks"),i=a.find(e=>e4(e.phase).toLowerCase()===n.toLowerCase());i||(i={phase:n,tasks:[]},a.push(i)),i.tasks.push({text:e,status:t,phase:n})}}if(l.tasks.length>0&&!a.includes(l)&&a.push(l),0===a.length&&Array.isArray(r?.list))for(let e of r.list){let t=e4(e.phase||"Tasks"),n=(e.items||[]).map(e=>({text:e,status:"pending",phase:t}));a.push({phase:t,tasks:n})}let c=function(e){let t=new Map;for(let n of e){if(!n.tasks.length)continue;let e=e4(n.phase),r=e.toLowerCase(),i=t.get(r);if(i){let t=n.tasks.length>=i.tasks.length?n.tasks:i.tasks,r=t===n.tasks?i.tasks:n.tasks,s=new Map;for(let n of t)s.set(n.text.toLowerCase().trim(),{...n,phase:e});for(let t of r){let n=t.text.toLowerCase().trim(),r=s.get(n);r?"done"===t.status?r.status="done":"in_progress"===t.status&&"done"!==r.status&&(r.status="in_progress"):s.set(n,{...t,phase:e})}i.phase=e,i.tasks=Array.from(s.values())}else t.set(r,{phase:e,tasks:[...n.tasks]})}let n=Array.from(t.values()),r=[];for(let e=0;e<n.length;e++){let t=n[e],i=t.tasks.map(e=>e.text.toLowerCase().trim()),s=!1;for(let r=0;r<n.length;r++){if(e===r)continue;let a=n[r],l=new Set(a.tasks.map(e=>e.text.toLowerCase().trim()));if(a.tasks.length>=t.tasks.length&&i.every(e=>l.has(e))){for(let e of t.tasks){let t=a.tasks.find(t=>t.text.toLowerCase().trim()===e.text.toLowerCase().trim());t&&("done"===e.status?t.status="done":"in_progress"===e.status&&"done"!==t.status&&(t.status="in_progress"))}s=!0;break}}s||r.push(t)}return r}(a);if(r?.op==="done"&&r.task){let e=String(r.task).toLowerCase().trim();for(let t of c){let n=t.tasks.find(t=>t.text.toLowerCase().trim()===e);n&&(n.status="done")}}let d=0,u=0,p=0;for(let e of c)for(let t of e.tasks)"done"===t.status?d++:"in_progress"===t.status?u++:p++;let m=d+u+p,h=i.match(/Overall:\s*(\d+)\/(\d+)\s*done/i)||i.match(/(\d+)\s+of\s+(\d+)\s+completed/i);if(h){let e=parseInt(h[1],10),t=parseInt(h[2],10);t>=m&&(d=e,p=Math.max(0,(m=t)-d-u))}let f=[];d>0&&f.push(`${d} complete`),u>0&&f.push(`${u} in progress`),p>0&&f.push(`${p} pending`);let x=f.length>0?f.join(" · "):m>0?`${m} items`:"";return{groups:c,totalDone:d,totalInProgress:u,totalPending:p,totalTasks:m,opBadge:t,summaryText:x}}var e8=n("uF");let e6={github:"GitHub",openai:"OpenAI",gitlab:"GitLab",sqlite:"SQLite",postgresql:"PostgreSQL",mysql:"MySQL",mongodb:"MongoDB",redis:"Redis",docker:"Docker",kubernetes:"Kubernetes",vercel:"Vercel",bun:"Bun",node:"Node",deno:"Deno",react:"React",vue:"Vue",svelte:"Svelte",angular:"Angular",next:"Next",nuxt:"Nuxt",remix:"Remix",tailwind:"Tailwind",prisma:"Prisma",zod:"Zod",axios:"Axios",express:"Express",fastify:"Fastify",koa:"Koa",hono:"Hono",elysia:"Elysia",drizzle:"Drizzle",kysely:"Kysely",biome:"Biome",oxc:"Oxc",rolldown:"Rolldown",turbopack:"Turbopack",vite:"Vite",webpack:"Webpack",rollup:"Rollup",esbuild:"Esbuild",babel:"Babel",swc:"SWC",typescript:"TypeScript",javascript:"JavaScript",coffeescript:"CoffeeScript",dart:"Dart",kotlin:"Kotlin",swift:"Swift",rust:"Rust",python:"Python",ruby:"Ruby",php:"PHP",perl:"Perl",lua:"Lua",scala:"Scala",haskell:"Haskell",elixir:"Elixir",erlang:"Erlang",clojure:"Clojure",ocaml:"OCaml",zig:"Zig",nim:"Nim",crystal:"Crystal",julia:"Julia",groovy:"Groovy",powershell:"PowerShell",bash:"Bash",zsh:"Zsh",fish:"Fish",grep:"Grep",find:"Find",glob:"Glob",ls:"Ls",cat:"Cat",echo:"Echo",mkdir:"Mkdir",rm:"Rm",cp:"Cp",mv:"Mv",touch:"Touch",chmod:"Chmod",chown:"Chown",sudo:"Sudo",apt:"Apt",brew:"Brew",npm:"Npm",pnpm:"Pnpm",yarn:"Yarn",playwright:"Playwright",cypress:"Cypress",puppeteer:"Puppeteer",selenium:"Selenium",jest:"Jest",vitest:"Vitest",mocha:"Mocha",chai:"Chai",sinon:"Sinon",karma:"Karma",jasmine:"Jasmine",qunit:"QUnit",ava:"Ava",tape:"Tape",lodash:"Lodash",underscore:"Underscore",ramda:"Ramda",rxjs:"RxJS",redux:"Redux",zustand:"Zustand",jotai:"Jotai",recoil:"Recoil",mobx:"MobX",xstate:"XState",framer:"Framer",motion:"Motion",gsap:"GSAP",anime:"Anime",three:"Three",babylon:"Babylon",pixi:"Pixi",phaser:"Phaser",matter:"Matter",planck:"Planck",rapier:"Rapier",cannon:"Cannon",ammo:"Ammo",bullet:"Bullet",box2d:"Box2D",chipmunk:"Chipmunk",verlet:"Verlet",ode:"ODE",physx:"PhysX",havok:"Havok",unity:"Unity",unreal:"Unreal",godot:"Godot",bevy:"Bevy",amethyst:"Amethyst",macroquad:"Macroquad",miniquad:"Miniquad",sdl:"SDL",sfml:"SFML",glfw:"GLFW",opengl:"OpenGL",vulkan:"Vulkan",directx:"DirectX",metal:"Metal",webgpu:"WebGPU",webgl:"WebGL",canvas:"Canvas",webaudio:"WebAudio",webmidi:"WebMIDI",webrtc:"WebRTC",websocket:"WebSocket",sse:"SSE",eventsource:"EventSource",fetch:"Fetch",xhr:"XHR",ky:"Ky",got:"Got",undici:"Undici",superagent:"Superagent",request:"Request",needle:"Needle",bent:"Bent",r2:"R2",s3:"S3",gcs:"GCS",azure:"Azure",blob:"Blob",storage:"Storage",firebase:"Firebase",supabase:"Supabase",pocketbase:"PocketBase",appwrite:"Appwrite",nhost:"Nhost",hasura:"Hasura",graphql:"GraphQL",rest:"REST",grpc:"gRPC",trpc:"tRPC",soap:"SOAP",mqtt:"MQTT",amqp:"AMQP",kafka:"Kafka",rabbitmq:"RabbitMQ",pubsub:"PubSub",nats:"NATS",zeromq:"ZeroMQ",dds:"DDS",coap:"CoAP",ble:"BLE",zigbee:"Zigbee",lora:"LoRa",nbiot:"NB-IoT",lte:"LTE",wifi:"Wi-Fi",ethernet:"Ethernet",usb:"USB",hdmi:"HDMI",displayport:"DisplayPort",thunderbolt:"Thunderbolt",pcie:"PCIe",nvme:"NVMe",sata:"SATA",ddr:"DDR",ecc:"ECC",xmp:"XMP",docsis:"DOCSIS",gpon:"GPON",epon:"EPON",pon:"PON",olt:"OLT",ont:"ONT",onu:"ONU",odn:"ODN",p2mp:"P2MP",p2p:"P2P",ftth:"FTTH",fttb:"FTTB",fttc:"FTTC",fttn:"FTTN",hfc:"HFC",dsl:"DSL",adsl:"ADSL",vdsl:"VDSL",sdsl:"SDSL",shdsl:"SHDSL",isdn:"ISDN",pstn:"PSTN",pots:"POTS",voip:"VoIP",sip:"SIP",rtp:"RTP",rtcp:"RTCP",rtsp:"RTSP",hls:"HLS",dash:"DASH",mpeg:"MPEG",av1:"AV1",vp9:"VP9",vp8:"VP8",hevc:"HEVC",avc:"AVC",mp4:"MP4",mkv:"MKV",avi:"AVI",mov:"MOV",wmv:"WMV",flv:"FLV",webm:"WebM",ogg:"OGG",mp3:"MP3",wav:"WAV",flac:"FLAC",aac:"AAC",midi:"MIDI",opus:"OPUS",alac:"ALAC",ape:"APE",wavpack:"WavPack"},e9=new Set(["MCP","AST","LSP","DAP","RPC","SSH","TTS","STT","URL","API","JSON","SQL","CSS","HTML","JS","TS","PDF","PR","UI","UX","DB","CLI","TUI","IDE","HTTP","HTTPS","OAUTH","YAML","XML","CSV","PNG","SVG","WASM","AI","ML","LLM","RAG","SDK","GUI","DOM","ESM","CJS","UMD","IIFE","XHR","TCP","UDP","DNS","IP","GPU","CPU","RAM","SSD","HDD","FIFO","PTY","TTY","WEB"]);function e7(e){if(!e)return e;let t=e.split("__"),n=t.length>1?t[0]:null,r=t[t.length-1].split(/[_\-\s]+/).filter(Boolean).map(e=>{let t=e6[e.toLowerCase()];if(t)return t;let n=e.toUpperCase();return e9.has(n)?n:e.charAt(0).toUpperCase()+e.slice(1)}).join(" ");return n?`${n.toUpperCase()} ${r}`:r}function te(e){var t;let{envelope:n}=e,i=eE(t=n.tag)?{icon:(0,r.Y)(e$.A,{size:12}),badge:"bg-warning/10 text-warning"}:"error"===t||"failure"===t?{icon:(0,r.Y)(eu.A,{size:12}),badge:"bg-error/10 text-error"}:{icon:(0,r.Y)(S.A,{size:12}),badge:"bg-info/10 text-info"};return(0,r.FD)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.Y)("span",{className:`flex h-5 w-5 shrink-0 items-center justify-center rounded ${i.badge}`,children:i.icon}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/60",children:e7(n.tag)}),Object.entries(n.attributes).map(e=>{let[t,n]=e;return(0,r.Y)("span",{title:`${t}=${n}`,className:"max-w-[240px] truncate rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9.5px] text-ink/60",children:n?`${t}=${n}`:t},t)})]})}let tt=/(^|\n)\s*(#{1,6}\s|```|`[^`\n]+`|>|[-*+]\s|\d+\.\s|\[[^\]]+\]\([^)]+\)|\|.*\|)/;function tn(e){let t=eO(e),n=t?[t.inner,t.rest].filter(Boolean).join("\n\n"):e;return{content:n,format:function(e){if(!e)return"text";let t=e.trim();if(!t)return"text";if(t.includes("```"))return"markdown";if(t.length<1e5&&(t.startsWith("{")||t.startsWith("[")))try{let e=JSON.parse(t);if(null!==e&&"object"==typeof e)return"json"}catch{}return tt.test(t)?"markdown":/^<(?:!doctype|html|div|section|article|table|ul|ol|h[1-6]|p|pre|code|span|a|b|strong|em|i|blockquote|form|button|input|img|nav|header|footer|main|aside|figure|figcaption|details|summary|label|select|option|textarea|video|audio|iframe|script|style|link|meta|title|body|head)\b/i.test(t)||/<[a-z][a-z0-9-]*\s[^>]*>[\s\S]*<\/[a-z][a-z0-9-]*>/i.test(t)&&/<\/[a-z][a-z0-9-]*>/i.test(t)?"html":"text"}(n),...t?{envelope:t}:{}}}function tr(e,t){if(!e||"markdown"===t)return e;let n=0;for(let t of e.match(/`+/g)??[])n=Math.max(n,t.length);let r="`".repeat(Math.max(3,n+1));return`${r}${"text"===t?"":t}
9
9
  ${e}
10
- ${r}`}function ti(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;if(!e)return{text:"",skipped:0};let n=e.split(/\r?\n/);return n.length<=t?{text:e,skipped:0}:{text:n.slice(n.length-t).join("\n"),skipped:n.length-t}}function ts(e){let{text:t}=e,n=(0,i.Kr)(()=>eL(t),[t]),s=(0,i.Kr)(()=>tn(n),[n]),a=(0,i.Kr)(()=>ti(s.content,1e3),[s]),l=(0,i.Kr)(()=>tr(a.text,s.format),[a,s.format]),o=(0,i.Kr)(()=>s.content.split(/\r?\n/).length,[s.content]);return(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:[(0,r.Y)(e8.A,{size:11,className:"text-ink/40"}),(0,r.Y)("span",{children:"Output"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/45",children:s.format}),o>1&&(0,r.FD)("span",{className:"font-mono text-[9px] text-ink/35",children:[o," lines"]})]}),(0,r.Y)(eg,{text:s.content,className:"flex cursor-pointer items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",onClick:e=>e.stopPropagation(),label:"Copy"})]}),s.envelope&&(0,r.Y)(te,{envelope:s.envelope}),a.skipped>0&&(0,r.FD)("div",{className:"font-mono text-[10px] text-ink/45",children:["… ",a.skipped," earlier lines hidden"]}),(0,r.Y)("div",{className:"max-h-72 overflow-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 select-text",children:(0,r.Y)(eh.T,{content:l,className:"text-[12px] text-ink/85"})})]})}function ta(e){let{tool:t}=e,{groups:n,totalDone:s,totalInProgress:a,totalPending:l,totalTasks:o,opBadge:c}=(0,i.Kr)(()=>e3(t),[t]);if(0===n.length&&!c){let e=t.output||"";return e.trim()?(0,r.Y)(ts,{text:e}):null}let d=o>0?Math.round(s/o*100):0;return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3",children:[(0,r.FD)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(ew.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"text-[11px] font-semibold text-ink",children:"Todo"}),c&&(0,r.Y)("span",{className:"rounded bg-success/10 px-2 py-0.5 font-mono text-[9.5px] font-medium text-success",children:c})]}),o>0&&(0,r.FD)("div",{className:"flex items-center gap-2 font-mono text-[10.5px]",children:[(0,r.FD)("span",{className:"text-ink/50",children:[s," of ",o," completed"]}),(0,r.FD)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-semibold text-ink",children:[d,"%"]})]})]}),o>0&&(s>0||a>0||l>0)&&(0,r.FD)("div",{className:"mt-2.5 flex flex-wrap items-center gap-1.5 font-mono text-[10px]",children:[s>0&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded bg-success/10 px-2 py-0.5 text-success",children:[(0,r.Y)(eB.A,{size:11}),(0,r.FD)("span",{children:[s," complete"]})]}),a>0&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded bg-ink/8 px-2 py-0.5 text-ink/70",children:[(0,r.Y)(e_.A,{size:11,className:"animate-spin"}),(0,r.FD)("span",{children:[a," in progress"]})]}),l>0&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded bg-ink/5 px-2 py-0.5 text-ink/50",children:[(0,r.Y)(h.A,{size:11}),(0,r.FD)("span",{children:[l," pending"]})]})]}),o>0&&(0,r.Y)("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-ink/8",children:(0,r.Y)("div",{className:"h-full rounded-full bg-success transition-all duration-300",style:{width:`${d}%`}})})]}),(0,r.Y)("div",{className:"space-y-2",children:n.map((e,t)=>(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.Y)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:e.phase}),(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:[e.tasks.filter(e=>"done"===e.status).length,"/",e.tasks.length]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/[0.04] p-1",children:e.tasks.map((e,t)=>{let n="done"===e.status,i="in_progress"===e.status;return(0,r.FD)("div",{className:`flex items-start gap-2.5 px-2.5 py-1.5 text-[11.5px] transition-colors ${i?"bg-ink/[0.03]":""}`,children:[n?(0,r.Y)(eB.A,{size:13,className:"mt-0.5 shrink-0 text-success"}):i?(0,r.Y)(e_.A,{size:13,className:"mt-0.5 shrink-0 animate-spin text-ink"}):(0,r.Y)(h.A,{size:13,className:"mt-0.5 shrink-0 text-ink/25"}),(0,r.Y)("span",{className:`min-w-0 flex-1 leading-snug ${n?"text-ink/40 line-through":i?"font-medium text-ink":"text-ink/80"}`,children:e.text}),i&&(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/8 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/70",children:"In Progress"})]},t)})})]},t))})]})}var tl=n("E6");function to(e){if(e&&"object"==typeof e&&"string"==typeof e.path)return e.path}function tc(e){let t="string"==typeof e.severity?e.severity.toLowerCase():"";return"error"===t||"1"===t?"error":"warning"===t||"2"===t?"warning":"info"}let td={error:{Icon:eu.A,color:"text-error",text:"text-error",badge:"bg-error/10 text-error"},warning:{Icon:tl.A,color:"text-warning",text:"text-warning",badge:"bg-warning/10 text-warning"},info:{Icon:ep.A,color:"text-ink/40",text:"text-ink/70",badge:"bg-ink/5 text-ink/50"}};function tu(e){let{tool:t}=e,n=t.details??{},s=t.output??"",a=n.xdev?.args?.action==="capabilities"||"capabilities"===function(e){if(e&&"object"==typeof e&&"string"==typeof e.action)return e.action}(t.input)||s.includes("capabilities:"),l=(0,i.Kr)(()=>a?function(e){if(!e||!e.includes("capabilities:"))return[];let t=[];for(let n of e.split(/^(?=[A-Za-z0-9_-]+:)/m)){let e=n.trim();if(!e)continue;let r=e.match(/^([A-Za-z0-9_-]+):\s*capabilities:\s*(\{[\s\S]*\})/m);if(r){let e=r[1];try{let n=JSON.parse(r[2]);t.push({name:e,capabilities:n})}catch{t.push({name:e,capabilities:{}})}}}return t}(s):[],[a,s]),o=(0,i.Kr)(()=>a?[]:Array.isArray(n.diagnostics)?n.diagnostics:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.diagnostics))return t.diagnostics;if(Array.isArray(t.errors))return t.errors}}catch{}let t=e.split(/\r?\n/).filter(Boolean),n=[],r=[],i="";for(let e of t){let t=e.trim();if(/^\d+\s+(?:error|warning|hint|info)\(s\):/i.test(t))continue;let s=t.match(/^(#{1,6})\s+(.+)$/);if(s){let e=s[1].length,t=s[2].trim();if(r.length=Math.min(r.length,e-1),t.endsWith("/"))r[e-1]=t;else{let e=r.filter(Boolean).join("");i=e?`${e.replace(/\/+$/,"")}/${t}`:t}continue}let a=e.match(/^\s*(\d+):(\d+)\s+\[(error|warning|info|hint)\]\s*(?:\[([^\]]+)\])?\s*(.*?)(?:\s*\((\d+|TS\d+)\))?$/i);if(a){n.push({file:i||void 0,line:parseInt(a[1],10),column:parseInt(a[2],10),severity:"hint"===a[3].toLowerCase()?"info":a[3].toLowerCase(),source:a[4]||void 0,message:a[5].trim(),code:a[6]||void 0});continue}let l=e.match(/^([^:\n]+):(\d+)(?::(\d+))?\s*[-:]?\s*(error|warning|info|hint)?\s*(?:(TS\d+|[A-Za-z0-9_-]+):)?\s*(.*)$/i);l&&n.push({file:l[1].trim(),line:parseInt(l[2],10),column:l[3]?parseInt(l[3],10):void 0,severity:l[4]?"hint"===l[4].toLowerCase()?"info":l[4].toLowerCase():"error",code:l[5]||void 0,message:l[6]?.trim()||e})}return n}(s),[n.diagnostics,a,s]);if(a&&l.length>0)return(0,r.Y)("div",{className:"space-y-2 select-text",children:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eF.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[10.5px] font-semibold text-ink",children:"Language Servers"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"Capabilities"})]}),(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/40",children:[l.length," active"]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/30",children:l.map((e,t)=>{let n=Object.entries(e.capabilities).filter(e=>{let[,t]=e;return!!t}).map(e=>{let[t]=e;return t.replace(/Provider$/,"")});return(0,r.FD)("div",{className:"p-3 text-[11px]",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eD.A,{size:12,className:"text-ink/50"}),(0,r.Y)("span",{className:"font-mono font-medium text-ink",children:e.name}),(0,r.FD)("span",{className:"ml-auto inline-flex items-center gap-1 font-mono text-[9.5px] text-success",children:[(0,r.Y)(eB.A,{size:10}),"Connected"]})]}),n.length>0&&(0,r.Y)("div",{className:"mt-2 flex flex-wrap gap-1",children:n.map((e,t)=>(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] text-ink/60",children:e},t))})]},t)})})]})});if(0===o.length)return s?(0,r.Y)(ts,{text:s}):null;let c=e=>o.filter(t=>tc(t)===e),d=c("error").length,u=c("warning").length,p=c("info").length;return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 select-text",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Diagnostics"}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-2 font-mono text-[10px]",children:[d>0&&(0,r.FD)("span",{className:"flex items-center gap-1 text-error",children:[(0,r.Y)(eu.A,{size:9}),d]}),u>0&&(0,r.FD)("span",{className:"flex items-center gap-1 text-warning",children:[(0,r.Y)(tl.A,{size:9}),u]}),p>0&&(0,r.FD)("span",{className:"flex items-center gap-1 text-ink/50",children:[(0,r.Y)(ep.A,{size:9}),p]})]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1 max-h-72 overflow-auto",children:o.map((e,t)=>{let n,i,s,a=td[tc(e)],l=(n="string"==typeof e.file?e.file:"string"==typeof e.path?e.path:"",i="number"==typeof e.line?e.line:void 0,s="number"==typeof e.column?e.column:void 0,n?void 0===i?n:void 0===s?`${n}:${i}`:`${n}:${i}:${s}`:""),o="string"==typeof e.message?e.message:"",c="string"==typeof e.code?e.code:void 0,d="string"==typeof e.source?e.source:void 0,{Icon:u,color:p,text:m}=a;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)("span",{className:"flex h-5 w-3.5 shrink-0 items-center justify-center",children:(0,r.Y)(u,{size:12,className:p})}),(0,r.FD)("span",{className:"min-w-0 flex-1 break-words leading-5",children:[l&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/45 mr-1",children:[l,":"]}),(0,r.Y)("span",{className:m,children:o}),d&&(0,r.FD)("span",{className:"ml-1.5 font-mono text-[9px] text-ink/35",children:["[",d,"]"]}),c&&(0,r.FD)("span",{className:"ml-1 font-mono text-[9px] text-ink/35",children:["(",c,")"]})]})]},t)})})]})}var tp=n("q");function tm(e){return"string"==typeof e.url?e.url:"string"==typeof e.link?e.link:""}function th(e){return"string"==typeof e.snippet&&e.snippet?e.snippet:"string"==typeof e.description?e.description:""}function tf(e){let{tool:t}=e,n=t.details??{},i="string"==typeof n.response?.provider?n.response.provider:"string"==typeof n.provider?n.provider:void 0,s=Array.isArray(n.results)?n.results:Array.isArray(n.sources)?n.sources:Array.isArray(n.response?.sources)?n.response.sources:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.results))return t.results;if(Array.isArray(t.sources))return t.sources;if(Array.isArray(t.organic))return t.organic;if(Array.isArray(t.items))return t.items;if(t.response&&Array.isArray(t.response.sources))return t.response.sources}}catch{}return[]}(t.output??"");return 0===s.length?t.output?(0,r.Y)(ts,{text:t.output}):null:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:[i&&(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-paper px-2.5 py-1 text-[9.5px]",children:[(0,r.Y)("span",{className:"font-semibold uppercase tracking-wider text-ink/40",children:"Sources"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-ink/50 uppercase",children:i})]}),(0,r.Y)("ol",{className:"divide-y divide-ink/6",children:s.map((e,t)=>{let n=tm(e),i="string"==typeof e.publishedDate?e.publishedDate:void 0;return(0,r.FD)("li",{className:"px-2.5 py-2 text-[11.5px]",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded bg-ink/5 font-mono text-[9px] text-ink/45",children:t+1}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-medium text-ink",children:"string"==typeof e.title&&e.title?e.title:tm(e)||"Result"}),n&&(0,r.Y)("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"flex shrink-0 items-center rounded-md p-0.5 text-ink/40 transition-colors hover:bg-ink/5 hover:text-ink",title:n,children:(0,r.Y)(tp.A,{size:10})})]}),(0,r.FD)("div",{className:"flex items-center gap-2 pl-[22px] font-mono text-[9.5px] text-ink/40",children:[n&&(0,r.Y)("span",{className:"truncate",children:n}),i&&(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1 py-0.2 text-[8.5px] text-ink/50",children:i})]}),th(e)&&(0,r.Y)("div",{className:"mt-0.5 pl-[22px] leading-snug text-ink/65",children:th(e)})]},t)})})]})}var tx=n("o"),tg=n("sJ");function tb(e){let{tool:t}=e,n=t.input,s="object"==typeof n&&null!==n?n:void 0,a="string"==typeof s?.code?s.code:"string"==typeof n?n:"",l=("string"==typeof s?.language?s.language:"js").toUpperCase(),o="number"==typeof s?.timeout?`${s.timeout}s`:void 0,c="string"==typeof s?.title?s.title:void 0,d=t.output||(t.error?`Error: ${t.error}`:""),u="error"===t.status||d.includes("ToolError:")||d.includes("Command exited with code"),p=d.includes("Command aborted")||"aborted"===t.status,m=(0,eU.w)(),h=(0,i.Kr)(()=>u||p?{isValid:!1}:(0,eK.Bl)(d),[d,u,p]),f=(0,i.Kr)(()=>ti(a,1e3),[a]),x=(0,i.Kr)(()=>(0,eK.wY)(f.text,"javascript"),[f,m]),g=(0,i.Kr)(()=>ti(d,1e3),[d]),b=(0,i.Kr)(()=>h.isValid&&h.pretty?ti(h.pretty,1e3):null,[h]),v=(0,i.Kr)(()=>b?(0,eK.PH)(b.text):"",[b,m]);return(0,r.FD)("div",{className:"space-y-2",children:[a&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eY.A,{size:12,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[10.5px] font-semibold text-ink",children:c||"Script Evaluation"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:l}),o&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9.5px] text-ink/40",children:[(0,r.Y)(tx.A,{size:10}),(0,r.Y)("span",{children:o})]})]}),(0,r.Y)(eg,{text:a,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),f.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",f.skipped," earlier lines hidden"]}),(0,r.FD)("div",{className:"flex max-h-56 items-start overflow-x-auto font-mono text-[11px] leading-relaxed select-text",children:[(0,r.Y)("div",{className:"sticky left-0 flex-shrink-0 select-none border-r border-ink/6 bg-canvas/50 py-2.5 pl-2.5 pr-2 text-right text-[10px] text-ink/25",children:f.text.split("\n").map((e,t)=>(0,r.Y)("div",{children:t+1},t))}),(0,r.Y)("pre",{className:"flex-1 overflow-x-auto p-2.5 whitespace-pre text-ink/85 font-mono",dangerouslySetInnerHTML:{__html:x}})]})]}),d&&(0,r.FD)("div",{className:`overflow-hidden rounded-lg border ${u?"border-error/25 bg-error/[0.03]":p?"border-warning/25 bg-warning/[0.03]":"border-ink/8 bg-paper"}`,children:[(0,r.FD)("div",{className:`flex items-center justify-between border-b px-3 py-1.5 ${u?"border-error/15 bg-error/[0.06]":p?"border-warning/15 bg-warning/[0.06]":"border-ink/6 bg-canvas/30"}`,children:[(0,r.Y)("div",{className:"flex items-center gap-1.5",children:u?(0,r.FD)(r.FK,{children:[(0,r.Y)(eu.A,{size:11,className:"text-error"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-error",children:"Execution Error"})]}):p?(0,r.FD)(r.FK,{children:[(0,r.Y)(eG.A,{size:11,className:"text-warning"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-warning",children:"Evaluation Aborted"})]}):(0,r.FD)(r.FK,{children:[(0,r.Y)(tg.A,{size:11,className:"text-success"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/50",children:"Evaluation Result"}),h.isValid&&(0,r.FD)(r.FK,{children:[(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"JSON"}),h.linesCount&&h.linesCount>1&&(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:[h.linesCount," lines"]})]})]})}),(0,r.Y)(eg,{text:h.isValid&&h.pretty?h.pretty:d,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),h.isValid&&h.pretty?(0,r.FD)(r.FK,{children:[b&&b.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",b.skipped," earlier lines hidden"]}),(0,r.FD)("div",{className:"flex max-h-56 items-start overflow-x-auto font-mono text-[11px] leading-relaxed select-text",children:[(0,r.Y)("div",{className:"sticky left-0 flex-shrink-0 select-none border-r border-ink/6 bg-canvas/50 py-2 pl-2.5 pr-2 text-right text-[10px] text-ink/25",children:(b?b.text:h.pretty).split("\n").map((e,t)=>(0,r.Y)("div",{children:t+1},t))}),(0,r.Y)("pre",{className:"flex-1 overflow-x-auto p-2.5 whitespace-pre text-ink/85 font-mono",dangerouslySetInnerHTML:{__html:v}})]})]}):(0,r.FD)(r.FK,{children:[g.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",g.skipped," earlier lines hidden"]}),(0,r.Y)("pre",{className:`max-h-48 overflow-y-auto p-3 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words select-text ${u?"text-error":p?"text-warning":"text-ink/80"}`,children:g.text})]})]})]})}var tv=n("DB"),tk=n("vZ");let ty={open:"bg-success/10 text-success",merged:"bg-ink/10 text-ink/60",closed:"bg-error/10 text-error"};function tN(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.items))return t.items;if(Array.isArray(t.pullRequests))return t.pullRequests;if(Array.isArray(t.issues))return t.issues}}catch{}return[]}(t.output??"");return 0===i.length?t.output?(0,r.Y)(ts,{text:t.output}):null:(0,r.Y)("ul",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:i.map((e,t)=>{let n=!0===e.merged||"merged"===e.state?"merged":"closed"===e.state?"closed":"open",i="string"==typeof e.title?e.title:"",s="number"==typeof e.number?`#${e.number}`:"",a="string"==typeof e.author?e.author:"",l="number"==typeof e.additions?e.additions:void 0,o="number"==typeof e.deletions?e.deletions:void 0;return(0,r.FD)("li",{className:"px-2.5 py-2 text-[11.5px]",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:["merged"===n?(0,r.Y)(tv.A,{size:12,className:"shrink-0 text-success"}):"closed"===n?(0,r.Y)(eT.A,{size:12,className:"shrink-0 text-error"}):(0,r.Y)(tk.A,{size:12,className:"shrink-0 text-success"}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-medium text-ink",children:i}),s&&(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] text-ink/45",children:s})]}),(0,r.FD)("div",{className:"mt-1 flex items-center gap-1.5 pl-[18px] text-[10px] text-ink/50",children:[(0,r.Y)("span",{className:`rounded-full px-1.5 py-px font-mono ${ty[n]}`,children:n}),a&&(0,r.Y)("span",{children:a}),(void 0!==l||void 0!==o)&&(0,r.FD)("span",{className:"ml-auto font-mono",children:[void 0!==l&&(0,r.FD)("span",{className:"text-success",children:["+",l]}),void 0!==o&&(0,r.FD)("span",{className:"ml-1 text-error",children:["-",o]})]})]})]},t)})})}var tw=n("Ir");function tY(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}function tD(e){if(!e.startsWith("Today,"))return null;let t=e.slice(6).trim(),n=new Date(`${new Date().toDateString()} ${t}`);return Number.isNaN(n.getTime())?null:n.getTime()}function tF(e){let t=e?.timestamp||e?.date;if(!t)return"";if(t.startsWith("Today,"))return`Today, ${t.slice(6).trim()}`;if(/^\d{1,2}:\d{2}\s*(AM|PM)$/i.test(t)){let e=tD(`Today, ${t}`);if(null!==e)return`Today, ${tY(e)}`}let n=new Date(t);if(Number.isNaN(n.getTime()))return"";let r=n.toLocaleDateString("en-US",{month:"short",day:"numeric"});return`${r}, ${tY(n)}`}function tA(e){let{tool:t}=e,n=t.details??{},i=n&&"object"==typeof n?n:{},s="rewind"===t.type,a="string"==typeof i.id?i.id:void 0,l=function(e){if("number"==typeof e){let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleTimeString()}return"string"==typeof e?e:""}(i.timestamp),o="number"==typeof i.fileCount?i.fileCount:void 0,c="string"==typeof i.branch?i.branch:void 0,d="string"==typeof i.message?i.message:"string"==typeof i.description?i.description:"";return a||l||o||c||d?(0,r.FD)("div",{className:"flex items-start gap-2.5 rounded-lg border border-ink/8 bg-canvas/40 px-3 py-2.5",children:[(0,r.Y)("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-ink/5 text-ink/60",children:s?(0,r.Y)(tw.A,{size:12}):(0,r.Y)(eS.A,{size:12})}),(0,r.FD)("div",{className:"min-w-0 flex-1 space-y-0.5",children:[d&&(0,r.Y)("div",{className:"text-[11.5px] text-ink/85",children:d}),(0,r.FD)("div",{className:"flex flex-wrap gap-x-2 gap-y-0.5 font-mono text-[9.5px] text-ink/45",children:[a&&(0,r.Y)("span",{children:a}),l&&(0,r.Y)("span",{children:l}),void 0!==o&&(0,r.FD)("span",{children:[o," files"]}),c&&(0,r.Y)("span",{children:c})]})]})]}):t.output?.trim()?(0,r.Y)(ts,{text:t.output}):null}function tC(e){var t;let n,{tool:s}=e,a=s.details??{},l="object"==typeof s.input&&null!==s.input?s.input:void 0,o=s.command||("string"==typeof l?.command?l.command:void 0)||("string"==typeof l?.cmd?l.cmd:void 0)||("string"==typeof l?.CommandLine?l.CommandLine:void 0)||("string"==typeof l?.commandLine?l.commandLine:void 0)||("string"==typeof s.input?s.input:""),{cleanText:c,wallTime:d}=(n=(t=s.output||(s.error?`Error: ${s.error}`:"")).match(/\n*Wall time:\s*([^\n\r]+)$/))?{cleanText:t.replace(/\n*Wall time:\s*[^\n\r]+$/,""),wallTime:n[1].trim()}:{cleanText:t},u="number"==typeof a.exitCode?a.exitCode:s.isError?1:void 0,m=("string"==typeof a.cwd?a.cwd:void 0)||("string"==typeof l?.cwd?l.cwd:void 0)||("string"==typeof l?.Cwd?l.Cwd:void 0),h="number"==typeof a.durationMs?a.durationMs:s.durationMs,f=s.duration||d||(h?`${h}ms`:void 0),x=!c||"(no output)"===c,g=(0,i.Kr)(()=>x||s.isError?{isValid:!1}:(0,eK.Bl)(c),[c,x,s.isError]),b=(0,i.Kr)(()=>eL(c),[c]),v=(0,i.Kr)(()=>ti(b,1e3),[b]),k=(0,i.Kr)(()=>g.isValid&&g.pretty?g.pretty:b,[g,b]),y=(0,i.Kr)(()=>(0,eK.rw)(b),[b]),N=(0,i.Kr)(()=>b.trim().startsWith("{")||b.trim().startsWith("[")?"json":"javascript",[b]),w=(0,i.Kr)(()=>g.isValid&&g.pretty?ti(g.pretty,1e3):null,[g]),Y=(0,eU.w)(),D=(0,i.Kr)(()=>o?(0,eK.wY)(o,"bash"):"",[o,Y]),F=(0,i.Kr)(()=>y?(0,eK.wY)(v.text,N):"",[y,v,N,Y]);return(0,r.FD)("div",{className:"space-y-2",children:[o&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/60 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.FD)("div",{className:"flex items-center gap-1",children:[(0,r.Y)("span",{className:"h-2 w-2 rounded-full bg-ink/20"}),(0,r.Y)("span",{className:"h-2 w-2 rounded-full bg-ink/20"}),(0,r.Y)("span",{className:"h-2 w-2 rounded-full bg-ink/20"})]}),(0,r.Y)("span",{className:"font-mono text-[10px] font-semibold text-ink/50",children:"bash"}),m&&(0,r.Y)("span",{className:"truncate font-mono text-[9.5px] text-ink/40",title:m,children:m})]}),(0,r.FD)("div",{className:"flex items-center gap-2",children:[void 0!==u&&(0,r.FD)("span",{className:`rounded-full px-1.5 py-0.2 font-mono text-[9px] font-semibold ${0===u?"bg-success/10 text-success":"bg-error/10 text-error"}`,children:["exit ",u]}),f&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9.5px] text-ink/45",children:[(0,r.Y)(tx.A,{size:10}),(0,r.Y)("span",{children:f})]}),(0,r.Y)(eg,{text:o,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",title:"Copy command",label:"Copy"})]})]}),(0,r.FD)("div",{className:"flex items-start gap-2.5 px-3 py-2 font-mono text-[11.5px] leading-relaxed",children:[(0,r.Y)("span",{className:"select-none font-bold text-ink/40",children:"$"}),(0,r.Y)("pre",{className:"min-w-0 flex-1 overflow-x-auto whitespace-pre-wrap break-all text-ink/90 select-text",dangerouslySetInnerHTML:{__html:D}})]})]}),x?(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-dashed border-ink/15 bg-canvas/30 px-3 py-2 font-mono text-[11px] text-ink/50",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(p.A,{size:12,className:"text-success"}),(0,r.Y)("span",{children:"Command executed successfully with no output"})]}),f&&(0,r.FD)("span",{className:"text-[10px] text-ink/40",children:["Wall time: ",f]})]}):g.isValid&&g.pretty?(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/30 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Console Output"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"JSON"}),g.linesCount&&g.linesCount>1&&(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:[g.linesCount," lines"]})]}),(0,r.Y)(eg,{text:g.isValid&&g.pretty?g.pretty:c,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),w&&w.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",w.skipped," earlier lines hidden"]}),(0,r.Y)(eQ,{jsonString:w?w.text:g.pretty,maxHeightClass:"max-h-72",showHeader:!1})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/30 px-3 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Console Output"}),(0,r.Y)(eg,{text:k,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),v.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",v.skipped," earlier lines hidden"]}),(0,r.Y)("div",{className:"max-h-72 overflow-y-auto overscroll-contain p-3 font-mono text-[11px] leading-relaxed select-text",children:y?(0,r.Y)("pre",{className:"overflow-x-auto whitespace-pre text-ink/85 leading-relaxed",dangerouslySetInnerHTML:{__html:F}}):v.text.split("\n").map((e,t)=>{let n=e.includes("✓")||e.includes("built in")||e.includes("ready: 0 errors"),i=e.includes("Error:")||e.includes("error:")||e.includes("FAILED"),s=e.includes("warning:")||e.includes("warn:");return(0,r.Y)("div",{className:`whitespace-pre-wrap break-words ${n?"text-success font-medium":i?"text-error font-medium":s?"text-warning font-medium":"text-ink/80"}`,children:e||" "},t)})})]})]})}var tS=n("W0"),tT=n("jx"),tz=n("Nf");function t$(e){let{tool:t}=e,[n,s]=(0,i.J0)(""),a=t.details??{},l=t.output||("string"==typeof a.displayContent?a.displayContent:""),o=function(e){let t=e.input;if(t&&"object"==typeof t){if("string"==typeof t.pattern)return t.pattern;if("string"==typeof t.path)return t.path;if("string"==typeof t.glob)return t.glob;if("string"==typeof t.query)return t.query;if("string"==typeof t.regex)return t.regex;if("string"==typeof t.search)return t.search;if("string"==typeof t.text)return t.text}return"string"==typeof e.target&&"."!==e.target?e.target:""}(t),c="glob"===t.type||"glob"===t.name,d=(0,i.Kr)(()=>ti(l,1e3),[l]),{files:u,totalMatches:p,isGlobList:m}=(0,i.Kr)(()=>(function(e){let t=e.split(/\r?\n/),n=[],r=[],i=null,s=!0;for(let e of t){let t=e.trimEnd();if(!t||t.startsWith("[")&&t.endsWith("]")||/^Showing files \d+/i.test(t)||/^Found \d+ matches/i.test(t))continue;let a=t.match(/^([^:\n]+(?:\.[a-zA-Z0-9_-]+|\/[^:\n]+)):(\d+)(?::\d+)?:(.*)$/);if(a){s=!1;let e=a[1].trim(),t=parseInt(a[2],10)||1,r=a[3],l=n.find(t=>t.path===e);l||(i&&i.lines.length>0&&!n.includes(i)&&n.push(i),l={path:e,lines:[],matchCount:0},n.push(l),i=l),l.lines.push({lineNum:t,text:r,isMatch:!0}),l.matchCount++;continue}let l=t.match(/^([^:\n]+(?:\.[a-zA-Z0-9_-]+|\/[^:\n]+))-(\d+)-(.*)$/);if(l){s=!1;let e=l[1].trim(),t=parseInt(l[2],10)||1,r=l[3],a=n.find(t=>t.path===e);a||(i&&i.lines.length>0&&!n.includes(i)&&n.push(i),a={path:e,lines:[],matchCount:0},n.push(a),i=a),a.lines.push({lineNum:t,text:r,isMatch:!1});continue}let o=t.match(/^(#{1,6})\s+(.+)$/);if(o){let e=o[1].length,t=o[2].trim();if(r.length=Math.min(r.length,e-1),t.endsWith("/"))r[e-1]=t;else{i&&i.lines.length>0&&!n.includes(i)&&n.push(i);let e=r.filter(Boolean).join("");i={path:e?`${e.replace(/\/+$/,"")}/${t}`:t,lines:[],matchCount:0}}continue}let c=t.match(/^(\*?)(\s*\d+)[|:\u2502](.*)$/);if(c){s=!1;let e="*"===c[1],t=parseInt(c[2].trim(),10)||1,r=c[3];i||(i={path:"Results",lines:[],matchCount:0},n.push(i)),i.lines.push({lineNum:t,text:r,isMatch:e}),e&&i.matchCount++;continue}if(!t.startsWith("#")&&!c){(t.includes("|")||t.includes(":")||t.includes("│"))&&(s=!1);let e=r.filter(Boolean).join(""),i=e?`${e.replace(/\/+$/,"")}/${t}`:t;n.push({path:i,lines:[],matchCount:1})}}i&&i.lines.length>0&&!n.includes(i)&&n.push(i);let a=n.reduce((e,t)=>e+(t.matchCount||t.lines.length||1),0);return{files:n,totalMatches:a,isGlobList:s}})(d.text),[d.text]),h=(0,i.Kr)(()=>{if(!n)return u;let e=n.toLowerCase();return u.map(t=>{let n=t.path.toLowerCase().includes(e),r=t.lines.filter(t=>t.text.toLowerCase().includes(e));return n?t:r.length>0?{...t,lines:r}:null}).filter(e=>null!==e)},[u,n]),f=(0,eU.w)(),x=(0,i.Kr)(()=>h.map(e=>{let t=(0,eK.sQ)(e.path);return(0,eK.O9)(e.lines.map(e=>e.text).join("\n"),t)}),[h,f]);return l||0!==u.length?(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[(0,r.Y)("span",{className:"flex h-5 w-5 items-center justify-center rounded bg-ink/5 text-ink/60",children:c||m?(0,r.Y)(tS.A,{size:12}):(0,r.Y)(tT.A,{size:12})}),(0,r.Y)("span",{className:"font-semibold text-ink",children:c||m?"Files Found":"Search Matches"}),(0,r.FD)("span",{className:"rounded-full bg-ink/5 px-2 py-0.5 font-mono text-[10px] text-ink/60",children:[p," ",1===p?"match":"matches"]}),u.length>1&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/40",children:["in ",u.length," ",1===u.length?"file":"files"]}),o&&(0,r.FD)("span",{className:"rounded border border-ink/10 bg-canvas px-1.5 py-0.5 font-mono text-[10px] text-ink/75",children:['"',o,'"']})]}),(0,r.FD)("div",{className:"flex items-center gap-2",children:[u.length>4&&(0,r.Y)("input",{type:"text",placeholder:"Filter paths...",value:n,onChange:e=>s(e.currentTarget.value),className:"h-6 w-28 rounded border border-ink/10 bg-canvas px-2 text-[10.5px] text-ink placeholder:text-ink/30 focus:border-ink/30 focus:outline-none"}),(0,r.Y)(eg,{text:l,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]})]}),d.skipped>0&&(0,r.FD)("div",{className:"rounded-lg border border-dashed border-ink/15 bg-canvas/50 px-3 py-1.5 font-mono text-[10.5px] text-ink/55",children:["… ",d.skipped," earlier lines hidden"]}),(0,r.FD)("div",{className:"max-h-80 space-y-2 overflow-y-auto overscroll-contain pr-0.5",children:[h.map((e,t)=>(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-2.5 py-1.5",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,r.Y)(eN.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"truncate font-mono text-[11px] font-medium text-ink/85",children:e.path})]}),e.matchCount>0&&!m&&(0,r.FD)("span",{className:"ml-2 shrink-0 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9.5px] text-ink/50",children:[e.matchCount," ",1===e.matchCount?"hit":"hits"]})]}),e.lines.length>0&&(0,r.Y)("div",{className:"overflow-x-auto overscroll-x-contain",children:(0,r.Y)("div",{className:"w-max min-w-full divide-y divide-ink/[0.04] font-mono text-[11px] leading-relaxed select-text",children:e.lines.map((e,n)=>(0,r.FD)("div",{className:`flex items-start gap-2.5 px-2.5 py-1 transition-colors ${e.isMatch?"bg-warning/[0.08] text-ink":"bg-paper text-ink/60 hover:bg-ink/[0.02]"}`,children:[(0,r.FD)("span",{className:`sticky left-0 z-10 flex w-9 shrink-0 select-none items-center justify-end bg-inherit font-mono text-[10px] ${e.isMatch?"font-semibold text-warning-dark dark:text-warning":"text-ink/30"}`,children:[e.isMatch&&(0,r.Y)(tz.A,{size:10,className:"mr-0.5 text-warning"}),e.lineNum]}),(0,r.Y)("pre",{className:"shiki whitespace-pre font-mono",dangerouslySetInnerHTML:{__html:x[t]?.[n]||"&nbsp;"}})]},n))})})]},t)),0===h.length&&(0,r.FD)("div",{className:"rounded-lg border border-dashed border-ink/15 p-4 text-center font-mono text-[11px] text-ink/40",children:['No results match filter "',n,'"']})]})]}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[c?(0,r.Y)(tS.A,{size:13,className:"shrink-0"}):(0,r.Y)(tT.A,{size:13,className:"shrink-0"}),(0,r.FD)("span",{children:["No ",c?"files":"matches"," found",o?` for "${o}"`:""]})]})}var tj=n("B5"),tL=n("gk");function tM(e){let t="string"==typeof e.severity?e.severity.toLowerCase():"";return"high"===t||"critical"===t||"error"===t?"high":"medium"===t||"warning"===t?"medium":"low"===t?"low":"info"}let tP={high:"bg-error/10 text-error",medium:"bg-warning/10 text-warning",low:"bg-ink/8 text-ink/60",info:"bg-ink/5 text-ink/50"};function tE(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.findings)?n.findings:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.findings))return t.findings;if(Array.isArray(t.vulnerabilities))return t.vulnerabilities;if(Array.isArray(t.issues))return t.issues}}catch{}return[]}(t.output??"");if(0===i.length)return t.output?(0,r.Y)(ts,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-success/20 bg-success/[0.04] px-3 py-2.5 text-[11.5px] text-success",children:[(0,r.Y)(tj.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No issues found"})]});let s=function(e){let t={high:0,medium:0,low:0,info:0};for(let n of e)t[tM(n)]++;return t}(i);return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Findings"}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-1.5 font-mono text-[9.5px]",children:[s.high>0&&(0,r.FD)("span",{className:"rounded-full bg-error/10 px-1.5 py-px text-error",children:[s.high," high"]}),s.medium>0&&(0,r.FD)("span",{className:"rounded-full bg-warning/10 px-1.5 py-px text-warning",children:[s.medium," med"]}),s.low>0&&(0,r.FD)("span",{className:"rounded-full bg-ink/8 px-1.5 py-px text-ink/55",children:[s.low," low"]})]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n=tM(e),i="string"==typeof e.message?e.message:"",s="string"==typeof e.file?e.file:"string"==typeof e.path?e.path:"",a="number"==typeof e.line?e.line:void 0,l="string"==typeof e.rule?e.rule:void 0;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)(tL.A,{size:11,className:`mt-0.5 shrink-0 ${"high"===n?"text-error":"medium"===n?"text-warning":"text-ink/40"}`}),(0,r.FD)("span",{className:"min-w-0 flex-1 break-words",children:[(0,r.Y)("span",{className:`mr-1.5 rounded-full px-1.5 py-px font-mono text-[9px] ${tP[n]}`,children:n}),s&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/45",children:[s,void 0!==a?`:${a}`:"",": "]}),(0,r.Y)("span",{className:"text-ink/80",children:i}),l&&(0,r.FD)("span",{className:"ml-1 font-mono text-[9.5px] text-ink/35",children:["(",l,")"]})]})]},t)})})]})}var tR=n("zH"),tI=n("cQ");let tO={running:"bg-ink/8 text-ink/60",done:"bg-success/10 text-success",failed:"bg-error/10 text-error",idle:"bg-ink/5 text-ink/45"};function tJ(e){let{tool:t}=e,n=t.details??{},s=Array.isArray(n.jobs)?n.jobs:Array.isArray(n.items)?n.items:[],a=t.input,l="object"==typeof a&&null!==a?a:void 0,o=t.output||"";if(l?.op==="wait"){let e=Array.isArray(l.ids)?l.ids:[],t="string"==typeof l.name?l.name:void 0,n="string"==typeof l.for?l.for:void 0,i="number"==typeof l.timeout?`${l.timeout}s`:"number"==typeof l.timeoutMs?`${Math.round(l.timeoutMs/1e3)}s`:void 0;return(0,r.FD)("div",{className:"space-y-2 rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px]",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 pb-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(tR.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono font-semibold text-ink",children:t?`Hub Wait: ${t}`:"Hub Wait"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:n?`wait (${n})`:"job wait"})]}),i&&(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:["timeout: ",i]})]}),e.length>0&&(0,r.FD)("div",{className:"pt-1",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:"Waiting for Job IDs"}),(0,r.Y)("div",{className:"mt-1 flex flex-wrap gap-1.5 font-mono text-[10.5px]",children:e.map((e,t)=>(0,r.Y)("span",{className:"rounded bg-ink/5 px-2 py-0.5 text-ink/80",children:e},t))})]}),o&&(0,r.Y)(ts,{text:o})]})}if(l?.op==="logs"){let e="string"==typeof l.name?l.name:"Process";return(0,r.FD)("div",{className:"space-y-2 rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px]",children:[(0,r.Y)("div",{className:"flex items-center justify-between border-b border-ink/6 pb-2",children:(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eF.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono font-semibold text-ink",children:e}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"logs"})]})}),(0,r.Y)("div",{className:"rounded border border-ink/6 bg-canvas/40 p-2 font-mono text-[10.5px] text-ink/85 whitespace-pre-wrap",children:o||"// No log output"})]})}let c=(0,i.Kr)(()=>{let e="string"==typeof l?.op?l.op.toLowerCase():"",t=["start","stop","restart","status"].includes(e),n=o.includes("pid=");if(!t&&!n)return null;let r=l?.name||"Service",i=l?.application,s=Array.isArray(l?.args)?l.args.join(" "):"",a=i?`${i} ${s}`.trim():s,c=l?.ready?.port,d=o.match(/pid=(\d+)/i),u=o.match(/uptime=([^\s]+)/i),p=o.match(/restarts=(\d+)/i),m=o.toLowerCase().includes("ready")||o.toLowerCase().includes("started")||o.toLowerCase().includes("running");return{op:e||"process",name:r,cmd:a,port:c,pid:d?d[1]:void 0,uptime:u?u[1]:void 0,restarts:p?p[1]:void 0,isReady:m,outputLines:o.split(/\r?\n/).filter(Boolean)}},[l,o]);return c?(0,r.Y)("div",{className:"space-y-2",children:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eF.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink",children:c.name}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9.5px] uppercase tracking-wider text-ink/50",children:c.op})]}),c.isReady&&(0,r.FD)("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-success/10 px-2 py-0.5 font-mono text-[9.5px] font-semibold text-success",children:[(0,r.Y)("span",{className:"h-1.5 w-1.5 rounded-full bg-success animate-pulse"}),"Active"]})]}),(0,r.FD)("div",{className:"divide-y divide-ink/[0.04] p-3 text-[11px]",children:[c.cmd&&(0,r.FD)("div",{className:"flex items-center justify-between py-1 font-mono",children:[(0,r.Y)("span",{className:"text-ink/45",children:"Command"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-2 py-0.5 text-ink/85",children:c.cmd})]}),(0,r.FD)("div",{className:"flex flex-wrap items-center gap-4 py-1.5 font-mono text-[10.5px]",children:[c.port&&(0,r.FD)("span",{className:"text-ink/60",children:["Port: ",(0,r.Y)("strong",{className:"text-ink",children:c.port})]}),c.pid&&(0,r.FD)("span",{className:"text-ink/60",children:["PID: ",(0,r.Y)("strong",{className:"text-ink",children:c.pid})]}),c.uptime&&(0,r.FD)("span",{className:"text-ink/60",children:["Uptime: ",(0,r.Y)("strong",{className:"text-ink",children:c.uptime})]})]}),c.outputLines.length>0&&(0,r.FD)("div",{className:"pt-2",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:"Log Output"}),(0,r.Y)("div",{className:"mt-1 rounded border border-ink/6 bg-canvas/40 p-2 font-mono text-[10.5px] text-ink/75",children:c.outputLines.map((e,t)=>(0,r.Y)("div",{children:e},t))})]})]})]})}):0===s.length?o?(0,r.Y)(ts,{text:o}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(tI.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No hub activities"})]}):(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-3 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Hub Jobs"}),(0,r.Y)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:s.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:s.map((e,t)=>{let n,i="running"===(n="string"==typeof e.status?e.status.toLowerCase():"string"==typeof e.state?e.state.toLowerCase():"")||"started"===n||"pending"===n?"running":"done"===n||"completed"===n||"success"===n?"done":"failed"===n||"error"===n?"failed":"idle",s="string"==typeof e.id?e.id:"string"==typeof e.name?e.name:`job-${t}`,a="string"==typeof e.label?e.label:"string"==typeof e.task?e.task:"string"==typeof e.message?e.message:"",l="string"==typeof e.type?e.type:void 0,o="number"==typeof e.durationMs?`${(e.durationMs/1e3).toFixed(1)}s`:void 0,c="string"==typeof e.resolvedModel?e.resolvedModel:void 0;return(0,r.FD)("div",{className:"flex items-center gap-2 px-3 py-1.5 text-[11.5px]",children:["running"===i?(0,r.Y)(tR.A,{size:11,className:"shrink-0 animate-pulse text-ink/50"}):"done"===i?(0,r.Y)(eB.A,{size:11,className:"shrink-0 text-success"}):(0,r.Y)(tg.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] font-semibold text-ink/80",children:s}),l&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1 py-0.2 font-mono text-[8.5px] uppercase tracking-wider text-ink/45",children:l}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate text-ink/85",children:a}),c&&(0,r.Y)("span",{className:"hidden sm:inline-block font-mono text-[9px] text-ink/40 truncate max-w-[120px]",children:c}),o&&(0,r.Y)("span",{className:"font-mono text-[9px] text-ink/40",children:o}),(0,r.Y)("span",{className:`shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${tO[i]}`,children:i})]},t)})})]}),o&&(0,r.Y)(ts,{text:o})]})}var t_=n("jI"),tW=n("rY"),tK=n("Os");function tU(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.notes)?n.notes:[],s="new_context"===t.type;return 0===i.length?t.output?(0,r.Y)(ts,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[s?(0,r.Y)(t_.A,{size:13,className:"shrink-0"}):(0,r.Y)(tW.A,{size:13,className:"shrink-0"}),(0,r.FD)("span",{children:["No ",s?"notes created":"notes"]})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:s?"New Context":"Notes"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n="string"==typeof e.title&&e.title?e.title:"string"==typeof e.text&&e.text?e.text:"string"==typeof e.content&&e.content?e.content:"string"==typeof e.note?e.note:"";return n?(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[s?(0,r.Y)(tK.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}):(0,r.Y)(tW.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 break-words text-ink/80",children:n})]},"string"==typeof e.id?e.id:`note-${t}`):null})})]})}var tH=n("YO"),tB=n("Y0"),tq=n("z9");let tG={memory_edit:{label:"Memory Edit",icon:(0,r.Y)(ez.A,{size:11})},retain:{label:"Retained",icon:(0,r.Y)(tH.A,{size:11})},recall:{label:"Recalled",icon:(0,r.Y)(z.A,{size:11})},reflect:{label:"Reflections",icon:(0,r.Y)(z.A,{size:11})},learn:{label:"Learned",icon:(0,r.Y)(tB.A,{size:11})}};function tV(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.items))return t.items;if(Array.isArray(t.memories))return t.memories;if(Array.isArray(t.results))return t.results}}catch{}return[]}(t.output??""),s=tG[t.type]??{label:"Memory",icon:(0,r.Y)(z.A,{size:11})};return 0===i.length?t.output?(0,r.Y)(ts,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(tq.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No memories"})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:s.label}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n="string"==typeof e.text&&e.text?e.text:"string"==typeof e.content?e.content:"";if(!n)return null;let i="number"==typeof e.score&&Number.isFinite(e.score)?e.score:void 0;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)("span",{className:"mt-0.5 shrink-0 text-ink/40",children:s.icon}),(0,r.Y)("span",{className:"min-w-0 flex-1 break-words text-ink/80",children:n}),void 0!==i&&(0,r.FD)("span",{className:"shrink-0 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] text-ink/45",children:[Math.round(100*i),"%"]})]},"string"==typeof e.id?e.id:`mem-${t}`)})})]})}var tZ=n("ND"),tQ=n("u8");function tX(e){let t="string"==typeof e.state?e.state.toLowerCase():"";return"attached"===t||"running"===t?t:"detached"===t?"detached":"stopped"}let t0={attached:"bg-success/10 text-success",running:"bg-ink/8 text-ink/60",stopped:"bg-ink/5 text-ink/45",detached:"bg-error/10 text-error"};function t1(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:[];if(0===i.length)return t.output?(0,r.Y)(ts,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(tZ.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No debug session"})]});let s=function(e){let t={attached:0,running:0,stopped:0,detached:0};for(let n of e)t[tX(n)]++;return t}(i);return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Debug Session"}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-1.5 font-mono text-[9.5px]",children:[s.attached>0&&(0,r.FD)("span",{className:"rounded-full bg-success/10 px-1.5 py-px text-success",children:[s.attached," attached"]}),s.running>0&&(0,r.FD)("span",{className:"rounded-full bg-ink/8 px-1.5 py-px text-ink/60",children:[s.running," run"]}),s.detached>0&&(0,r.FD)("span",{className:"rounded-full bg-error/10 px-1.5 py-px text-error",children:[s.detached," detach"]})]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n=tX(e),i="string"==typeof e.target&&e.target?e.target:"number"==typeof e.pid?`pid ${e.pid}`:"string"==typeof e.message?e.message:"";return(0,r.FD)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 text-[11.5px]",children:["attached"===n?(0,r.Y)(eB.A,{size:11,className:"shrink-0 text-success"}):"running"===n?(0,r.Y)(tQ.A,{size:11,className:"shrink-0 animate-pulse text-ink/50"}):(0,r.Y)(eV.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-ink/75",children:i}),(0,r.Y)("span",{className:`shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${t0[n]}`,children:n})]},`${i}-${t}`)})})]})}var t5=n("vBE"),t2=n("qd"),t4=n("Sy"),t3=n("oS");let t8={active:"bg-ink/8 text-ink/60",done:"bg-success/10 text-success",paused:"bg-warning/10 text-warning"};function t6(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:[],s="yield"===t.type||"yield"===t.name,a="error"===t.status;if(s){let e=function(e){let t=(0,t3.u)(e.details)?e.details:void 0,n=(0,t3.u)(e.input)?e.input:void 0,r=(t&&(0,t3.u)(t.data)?t.data:void 0)??(n&&(0,t3.u)(n.data)?n.data:void 0)??t??n;if(!r)return null;let i="string"==typeof r.summary?r.summary:void 0,s="string"==typeof r.report?r.report:void 0,a="string"==typeof r.architecture?r.architecture:void 0,l=Array.isArray(r.files)?r.files:void 0,o=[];if(l)for(let e of l)"string"==typeof e&&e?o.push(e):(0,t3.u)(e)&&"string"==typeof e.path&&o.push({path:e.path,description:"string"==typeof e.description?e.description:void 0});let c="string"==typeof t?.status?t.status:"string"==typeof r.status?r.status:void 0,d="string"==typeof r.error?r.error:null;return i||s||a||0!==o.length||d?{summary:i,report:s,architecture:a,files:o.length>0?o:void 0,status:c,error:d}:null}(t);if(e)return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper text-[12px] text-ink select-text",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)("span",{className:`flex h-5 w-5 items-center justify-center rounded-md ${a||e.error?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:a||e.error?(0,r.Y)(tl.A,{size:12}):(0,r.Y)(eB.A,{size:12})}),(0,r.Y)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/70",children:a||e.error?"Yield Error":"Yield Result"})]}),(e.status||(a?"error":"success"))&&(0,r.Y)("span",{className:`rounded-full px-2 py-0.5 font-mono text-[9.5px] font-medium uppercase ${a||e.error?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:e.status||(a?"failed":"success")})]}),(0,r.FD)("div",{className:"space-y-2.5 p-3",children:[(e.error||a&&t.output)&&(0,r.FD)("div",{className:"flex items-start gap-2 rounded-md bg-error/10 p-2.5 text-error text-[11.5px]",children:[(0,r.Y)(tl.A,{size:13,className:"shrink-0 mt-0.5"}),(0,r.Y)("span",{className:"font-mono leading-relaxed",children:e.error||t.output})]}),e.summary&&(0,r.FD)("div",{children:[(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:"Summary"}),(0,r.Y)("p",{className:"mt-0.5 font-sans text-[12px] text-ink font-medium leading-relaxed",children:e.summary})]}),e.report&&e.report!==e.summary&&(0,r.FD)("div",{className:"rounded-md border border-ink/8 bg-canvas/30 p-2.5",children:[(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:"Report"}),(0,r.Y)("div",{className:"mt-1 text-[11.5px] text-ink/85 leading-relaxed",children:(0,r.Y)(eh.T,{content:e.report})})]}),e.architecture&&(0,r.FD)("div",{children:[(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:"Evidence / Architecture"}),(0,r.Y)("div",{className:"mt-0.5 text-[11px] text-ink/75 leading-relaxed bg-ink/[0.03] p-2 rounded border border-ink/6",children:(0,r.Y)(eh.T,{content:e.architecture})})]}),e.files&&e.files.length>0&&(0,r.FD)("div",{children:[(0,r.FD)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:["Files Inspected (",e.files.length,")"]}),(0,r.Y)("div",{className:"mt-1 grid grid-cols-1 gap-1 sm:grid-cols-2",children:e.files.map((e,t)=>{let n="string"==typeof e?e:e.path,i="string"==typeof e?void 0:e.description;return(0,r.FD)("div",{className:"flex flex-col justify-between rounded border border-ink/6 bg-canvas/40 p-1.5",children:[(0,r.FD)("span",{className:"inline-flex items-center gap-1 font-mono text-[10.5px] font-medium text-ink truncate",children:[(0,r.Y)(eN.A,{size:10,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{className:"truncate",children:n})]}),i&&(0,r.Y)("span",{className:"text-[10px] text-ink/60 leading-tight mt-0.5 truncate",children:i})]},t)})})]})]})]})}return 0===i.length?t.output?(0,r.Y)(ts,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(eV.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:s?"No yield":"No goals"})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:s?"Yield":"Goals"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n,i="string"==typeof e.title&&e.title?e.title:"string"==typeof e.description?e.description:"";if(!i)return null;let a="number"==typeof e.progress&&Number.isFinite(e.progress)?e.progress:void 0,l="done"===(n="string"==typeof e.status?e.status.toLowerCase():"")||"completed"===n?"done":"paused"===n||"yielded"===n?"paused":"active";return(0,r.FD)("div",{className:"px-2.5 py-1.5",children:[(0,r.FD)("div",{className:"flex items-start gap-2 text-[11.5px]",children:[s?(0,r.Y)(t5.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}):(0,r.Y)(t2.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 break-words text-ink/80",children:i}),(0,r.Y)("span",{className:`shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${t8[l]}`,children:l})]}),void 0!==a&&(0,r.FD)("div",{className:"mt-1.5 flex items-center gap-1.5 pl-[18px]",children:[(0,r.Y)("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-ink/8",children:(0,r.Y)("div",{className:"h-full rounded-full bg-ink/60 transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,Math.round(100*a)))}%`}})}),(0,r.FD)("span",{className:"flex shrink-0 items-center gap-0.5 font-mono text-[9px] text-ink/45",children:[(0,r.Y)(t4.A,{size:8}),Math.round(100*a),"%"]})]})]},"string"==typeof e.id?e.id:`goal-${t}`)})})]})}var t9=n("fj"),t7=n("qw");function ne(e){let{tool:t}=e,n=t.details??{},s=n.xdev??{},a=s.inner??{},l=s.args??{},o=t.output??"",c=!1===a.applied||o.toLowerCase().includes("staged as a proposal")||o.toLowerCase().includes("files not modified yet"),d=Array.isArray(l.ops)?l.ops:[],u=Array.isArray(l.paths)?l.paths:a.scopePath?[a.scopePath]:[],p=a.displayContent||(o.includes("-")&&o.includes("+")?o:""),m=p?p.split(/\r?\n/).filter(e=>!e.startsWith("Staged as a proposal")&&!!e.trim()):[],h=Array.isArray(n.changes)?n.changes:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.changes))return t.changes;if(Array.isArray(t.edits))return t.edits}}catch{}return[]}(o),f=(0,eU.w)(),x=(0,eK.sQ)(u[0]),g=(0,i.Kr)(()=>{let e=m.map(e=>e.startsWith("+")||e.startsWith("-")||e.startsWith(" ")?e.slice(1):e);return(0,eK.O9)(e.join("\n"),x)},[m,x,f]);if(c||d.length>0||m.length>0)return(0,r.Y)("div",{className:"space-y-2 select-text",children:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(t9.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink",children:"AST Edit"}),u.length>0&&(0,r.Y)("span",{className:"font-mono text-[10px] text-ink/50 truncate max-w-[200px]",children:u[0]})]}),(0,r.FD)("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 font-mono text-[9px] font-semibold ${c?"bg-warning/10 text-warning":"bg-success/10 text-success"}`,children:[c?(0,r.Y)(tx.A,{size:10}):(0,r.Y)(eB.A,{size:10}),c?"STAGED PROPOSAL":"APPLIED"]})]}),d.length>0&&(0,r.FD)("div",{className:"border-b border-ink/6 p-2.5 bg-canvas/20",children:[(0,r.Y)("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-ink/40",children:"Pattern Transformation"}),(0,r.Y)("div",{className:"mt-1 space-y-1",children:d.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 rounded border border-ink/6 bg-paper px-2 py-1 font-mono text-[10.5px]",children:[(0,r.Y)("span",{className:"text-error/90 line-through truncate",children:e.pat}),(0,r.Y)(t7.A,{size:10,className:"shrink-0 text-ink/35"}),(0,r.Y)("span",{className:"text-success/90 font-medium truncate",children:e.out||"/* removed */"})]},t))})]}),m.length>0&&(0,r.Y)("div",{className:"p-2.5 font-mono text-[10.5px] leading-relaxed bg-canvas/30 space-y-0.5",children:m.map((e,t)=>{let n=e.startsWith("-"),i=e.startsWith("+"),s=g[t]||"";return(0,r.FD)("div",{className:`rounded px-1.5 py-0.5 ${n?"bg-error/10 text-error font-medium":i?"bg-success/10 text-success font-medium":"text-ink/70"}`,children:[(n||i)&&e[0],s?(0,r.Y)("span",{className:"shiki",dangerouslySetInnerHTML:{__html:s}}):n||i?e.slice(1):e]},t)})}),c&&(0,r.FD)("div",{className:"border-t border-ink/6 bg-paper px-3 py-1.5 text-[10px] text-ink/50",children:["Proposal staged in memory. Apply with ",(0,r.Y)("code",{className:"font-mono text-ink/75",children:"xd://resolve"})," or discard with ",(0,r.Y)("code",{className:"font-mono text-ink/75",children:"xd://reject"}),"."]})]})});if(h.length>0)return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 select-text",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"AST Changes"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:h.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:h.map((e,t)=>{let n="string"==typeof e.file?e.file:"string"==typeof e.path?e.path:"",i="string"==typeof e.message?e.message:"",s="string"==typeof e.nodeKind?e.nodeKind:"",a="number"==typeof e.changes?e.changes:void 0;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)(t9.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}),(0,r.FD)("span",{className:"min-w-0 flex-1 break-words",children:[n&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/45",children:[n,": "]}),(0,r.Y)("span",{className:"text-ink/80",children:i}),s&&(0,r.FD)("span",{className:"ml-1 font-mono text-[9.5px] text-ink/35",children:["(",s,")"]})]}),void 0!==a&&(0,r.FD)("span",{className:"shrink-0 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] text-ink/45",children:[a," changes"]})]},t)})})]});let b=o.split(/\r?\n/).filter(Boolean);return 0===b.length?null:(0,r.Y)("ul",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40 select-text",children:b.map((e,t)=>(0,r.Y)("li",{className:"px-2.5 py-1.5 font-mono text-[11px] break-words text-ink/75",children:e},t))})}function nt(e){let{tool:t}=e,n=(t.details??{}).xdev??{},i=n.inner??{},s="object"==typeof t.input&&null!==t.input?t.input:void 0,a="reject"===t.name||t.target?.includes("reject")||"reject"===n.tool||"reject"===i.action||"discard"===i.action,l=i.reason||n.args?.reason||("string"==typeof s?.content?s.content:"")||("string"==typeof t.input?t.input:""),o=i.sourceToolName||"ast_edit",c=i.label||t.output||(a?"Proposal discarded":"Proposal applied"),d=Array.isArray(i.sourceResultDetails?.files)?i.sourceResultDetails.files:[],u=i.sourceResultDetails?.totalReplacements??i.totalReplacements;return(0,r.Y)("div",{className:"space-y-2 select-text",children:(0,r.FD)("div",{className:"rounded-lg border border-ink/10 bg-paper p-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between gap-2 border-b border-ink/6 pb-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[a?(0,r.Y)(eq.A,{size:14,className:"text-warning shrink-0"}):(0,r.Y)(eB.A,{size:14,className:"text-success shrink-0"}),(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink",children:a?"Proposal Discarded":"Proposal Applied"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:o})]}),(0,r.Y)("span",{className:`rounded-full px-2 py-0.5 font-mono text-[9.5px] font-semibold ${a?"bg-warning/10 text-warning":"bg-success/10 text-success"}`,children:a?"REJECTED":"RESOLVED"})]}),l&&(0,r.FD)("div",{className:"pt-2.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:"Reason"}),(0,r.FD)("p",{className:"mt-0.5 text-[12px] leading-relaxed text-ink/85 italic",children:["“",l,"”"]})]}),c&&(0,r.Y)("div",{className:"mt-2 text-[11.5px] font-medium text-ink/80",children:c}),d.length>0&&(0,r.FD)("div",{className:"mt-2.5 space-y-1 border-t border-ink/6 pt-2",children:[(0,r.FD)("div",{className:"flex items-center justify-between text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:[(0,r.FD)("span",{children:["Touched Files (",d.length,")"]}),"number"==typeof u&&(0,r.FD)("span",{children:[u," replacement",1===u?"":"s"]})]}),(0,r.Y)("div",{className:"space-y-1",children:d.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-1.5 font-mono text-[10.5px] text-ink/70",children:[(0,r.Y)(eN.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"truncate",children:e})]},t))})]})]})})}var nn=n("xn"),nr=n("JH");let ni={enabled:"bg-success/10 text-success",installed:"bg-ink/8 text-ink/60",disabled:"bg-ink/5 text-ink/45",removed:"bg-error/10 text-error"};function ns(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.skills)?n.skills:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.skills))return t.skills;if(Array.isArray(t.items))return t.items}}catch{}return[]}(t.output??"");return 0===i.length?t.output?(0,r.Y)(ts,{text:t.output}):null:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Skills"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n,i="string"==typeof e.name?e.name:"string"==typeof e.slug?e.slug:"";if(!i)return null;let s="enabled"===(n="string"==typeof e.status?e.status.toLowerCase():"")||"installed"===n?n:"removed"===n||"uninstalled"===n||"deleted"===n?"removed":"disabled",a="string"==typeof e.scope?e.scope:void 0,l="string"==typeof e.version?e.version:void 0,o="string"==typeof e.message?e.message:"";return(0,r.FD)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 text-[11.5px]",children:["removed"===s?(0,r.Y)(nn.A,{size:11,className:"shrink-0 text-error"}):(0,r.Y)(nr.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] font-semibold text-ink/70",children:i}),a&&(0,r.Y)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] text-ink/45",children:a}),l&&(0,r.FD)("span",{className:"font-mono text-[9px] text-ink/35",children:["v",l]}),o&&(0,r.Y)("span",{className:"min-w-0 flex-1 truncate text-ink/65",children:o}),(0,r.Y)("span",{className:`ml-auto shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${ni[s]}`,children:s})]},t)})})]})}function na(e){return"string"==typeof e.path?e.path:"string"==typeof e.name?e.name:""}function nl(e){let{tool:t}=e,[n,s]=(0,i.J0)(""),a=t.details??{},l=Array.isArray(a.results)?a.results:[],o=(0,i.Kr)(()=>{if(l.length>0)return l;if(t.output)try{let e=JSON.parse(t.output);if(Array.isArray(e))return e;if(e&&"object"==typeof e){if(Array.isArray(e.results))return e.results;if(Array.isArray(e.items))return e.items;if(Array.isArray(e.files))return e.files}}catch{}return(t.output??"").split(/\r?\n/).filter(Boolean).map(e=>{let t=e.endsWith("/");return{path:e,type:t?"dir":"file"}})},[l,t.output]),c=(0,i.Kr)(()=>{if(!n)return o;let e=n.toLowerCase();return o.filter(t=>na(t).toLowerCase().includes(e))},[o,n]);return 0===o.length?(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(tS.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No filesystem matches found"})]}):(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(tS.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"text-[11px] font-semibold text-ink",children:"Filesystem Search"}),(0,r.FD)("span",{className:"rounded-full bg-ink/5 px-2 py-0.5 font-mono text-[9.5px] text-ink/50",children:[o.length," ",1===o.length?"entry":"entries"]})]}),(0,r.FD)("div",{className:"flex items-center gap-2",children:[o.length>5&&(0,r.Y)("input",{type:"text",placeholder:"Filter...",value:n,onChange:e=>s(e.currentTarget.value),className:"h-6 w-24 rounded border border-ink/10 bg-canvas px-2 text-[10.5px] text-ink focus:outline-none"}),(0,r.Y)(eg,{text:o.map(e=>na(e)).join("\n"),className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]})]}),(0,r.Y)("div",{className:"max-h-64 divide-y divide-ink/6 overflow-y-auto rounded-lg border border-ink/8 bg-paper",children:c.map((e,t)=>{let n,i=na(e);if(!i)return null;let s="file"===(n="string"==typeof e.type?e.type.toLowerCase():"")||"directory"===n||"dir"===n?"directory"===n||"dir"===n?"dir":"file":"unknown",a="number"==typeof e.size&&e.size>0?(0,eX.z3)(e.size):"";return(0,r.FD)("div",{className:"flex items-center gap-2 px-3 py-1.5 text-[11.5px] transition-colors hover:bg-ink/[0.02]",children:["dir"===s?(0,r.Y)(d.A,{size:12,className:"shrink-0 text-ink/50"}):(0,r.Y)(er.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-ink/80",children:i}),"unknown"!==s&&(0,r.Y)("span",{className:`shrink-0 rounded px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider ${"dir"===s?"bg-ink/8 text-ink/60":"bg-ink/5 text-ink/45"}`,children:s}),a&&(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:a})]},t)})})]})}function no(e){let{tool:t}=e,n=t.input,s="object"==typeof n&&null!==n?n:void 0,a=Array.isArray(s?.questions)&&s.questions.length>0?s.questions[0]:void 0,l=a?.header,o=a?.question||("string"==typeof s?.question?s.question:"string"==typeof s?.prompt?s.prompt:"string"==typeof s?.message?s.message:"string"==typeof n?n:t.detail||"Question from agent"),c=a?.options||s?.options||s?.choices||[],d=Array.isArray(c)?c.map(e=>"string"==typeof e?{label:e}:"object"==typeof e&&null!==e?{label:"string"==typeof e.label?e.label:"string"==typeof e.text?e.text:String(e),description:"string"==typeof e.description?e.description:void 0}:{label:String(e)}):[],u=(0,i.Kr)(()=>"string"==typeof t.output?t.output:t.output&&"object"==typeof t.output?JSON.stringify(t.output,null,2):"string"==typeof s?.answer?s.answer:s?.answer&&"object"==typeof s?.answer?JSON.stringify(s.answer,null,2):"",[t.output,s?.answer]),p="string"==typeof u&&/cancelled|aborted|interrupted|disconnected/i.test(u)||"aborted"===t.status||"error"===t.status&&"string"==typeof u&&/disconnect|error/i.test(u),m="string"==typeof u?u.match(/selected:\s*(.+)$/i):null,h=m?m[1].trim():u,f=(0,i.Kr)(()=>!p&&u?(0,eK.Bl)(u):{isValid:!1},[u,p]),x="string"==typeof u&&u.includes("\n")&&!m,g=(0,eU.w)(),b=(0,i.Kr)(()=>"string"==typeof u&&(0,eK.rw)(u)?(0,eK.wY)(u,"javascript"):"",[u,g]);return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"rounded-lg border border-ink/10 bg-paper p-3 shadow-xs",children:[(0,r.FD)("div",{className:"flex items-start gap-2 min-w-0",children:[(0,r.Y)(eA.A,{size:14,className:"mt-0.5 shrink-0 text-ink/60"}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.Y)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/40",children:l?`Agent Question \xb7 ${l}`:"Agent Question"}),(0,r.Y)("div",{className:"mt-1 text-[12.5px] leading-relaxed text-ink/90 select-text",children:(0,r.Y)(eh.T,{content:o})})]})]}),d.length>0&&(0,r.FD)("div",{className:"mt-3 space-y-1.5 border-t border-ink/6 pt-2.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:"Options"}),(0,r.Y)("div",{className:"grid gap-1.5",children:d.map((e,t)=>{let n=!p&&!!h&&h.toLowerCase().includes(e.label.toLowerCase());return(0,r.FD)("div",{className:`flex flex-col gap-0.5 rounded-md px-2.5 py-1.5 text-[11px] transition-colors ${n?"border border-ink/30 bg-ink/5 font-medium text-ink":"border border-ink/6 bg-canvas/30 text-ink/75"}`,children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded bg-ink/5 font-mono text-[9px] text-ink/60 font-semibold",children:t+1}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-medium text-ink/90",children:e.label}),n&&(0,r.Y)(eB.A,{size:12,className:"shrink-0 text-success"})]}),e.description&&(0,r.Y)("div",{className:"pl-5.5 text-[10px] leading-relaxed text-ink/50",children:e.description})]},t)})})]})]}),p&&u&&(0,r.FD)("div",{className:"flex items-center gap-2 rounded-md border border-ink/8 bg-ink/[0.02] px-2.5 py-1 text-[10.5px] text-ink/60",children:[(0,r.Y)(eq.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-ink/40 shrink-0",children:"Status:"}),(0,r.Y)("span",{className:"font-mono text-ink/60 truncate select-text",children:u})]}),!p&&f.isValid&&f.pretty&&(0,r.Y)(eQ,{jsonString:f.pretty,title:"User Response",maxHeightClass:"max-h-40",compact:!0,icon:(0,r.Y)(eB.A,{size:10.5,className:"text-success shrink-0"}),showHeader:!0}),!p&&!f.isValid&&u&&(x?(0,r.FD)("div",{className:"overflow-hidden rounded-md border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-2.5 py-1",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)(eB.A,{size:10.5,className:"shrink-0 text-success"}),(0,r.Y)("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-ink/50",children:"User Response"})]}),(0,r.Y)(eg,{text:u,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink shrink-0",title:"Copy response",label:"Copy"})]}),(0,r.Y)("pre",{className:"max-h-32 overflow-y-auto p-2 font-mono text-[10.5px] leading-snug whitespace-pre-wrap break-words text-ink/85 select-text",children:b?(0,r.Y)("span",{dangerouslySetInnerHTML:{__html:b}}):u})]}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-md border border-ink/8 bg-canvas/30 px-2.5 py-1 text-[10.5px]",children:[(0,r.Y)(eB.A,{size:11,className:"shrink-0 text-success"}),(0,r.Y)("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-ink/40 shrink-0",children:"User Response:"}),(0,r.Y)("span",{className:"font-mono text-ink/90 font-medium truncate select-text",children:m?m[1].trim().replace(/^["']|["']$/g,""):u})]}))]})}function nc(e){let{tool:t}=e,n=t.input,i="object"==typeof n&&null!==n?n:void 0,s="string"==typeof i?.thought?i.thought:"string"==typeof i?.reasoning?i.reasoning:"string"==typeof i?.notes?i.notes:"string"==typeof n?n:t.output||t.detail||"";return s?(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)(em.A,{size:12,className:"text-ink/50"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Internal Reasoning"})]}),(0,r.Y)(eg,{text:s,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),(0,r.Y)("div",{className:"max-h-64 overflow-y-auto p-3 text-[11.5px] leading-relaxed text-ink/80 select-text",children:(0,r.Y)(eh.T,{content:s})})]}):(0,r.Y)("div",{className:"rounded-lg border border-dashed border-ink/15 p-3 font-mono text-[11px] text-ink/40",children:"No thought details recorded."})}var nd=n("Y");function nu(e){let{tool:t,targetFilePath:n,output:s}=e,[a,l]=(0,i.J0)(null),[o,c]=(0,i.J0)(!1),u=to(t?.input),p=n||u||t?.target||"",m=p.split("?")[0].split("#")[0].replace(/:\d+(?:-\d+)?$/,"");(0,i.vJ)(()=>{!m||s||null!==a||o||(c(!0),fetch(`/api/fs/read?path=${encodeURIComponent(m)}`).then(e=>e.json()).then(e=>{l(e&&void 0!==e.content?e.content:`// Loaded file: ${m}`)}).catch(()=>{l(`// Loaded file: ${m}`)}).finally(()=>{c(!1)}))},[m,s,a,o]);let h=t?.details??{},f=s||("object"==typeof h?.displayContent&&"string"==typeof h.displayContent?.text?h.displayContent.text:"")||a||"",x=(0,i.Kr)(()=>(function(e){let t,n=e.split(/\r?\n/).filter(Boolean);if(0===n.length)return{isDirectory:!1,entries:[]};let r=n[0].trim(),i=n.some(e=>e.trimStart().startsWith("- ")||e.trimStart().startsWith("├──")||e.trimStart().startsWith("└──"));if("."!==r&&!i)return{isDirectory:!1,entries:[]};let s=[];for(let e of n){if(e.startsWith("[")&&e.endsWith("]")){t=e.slice(1,-1);continue}if("."===e.trim()){s.push({indent:0,isDir:!0,name:"."});continue}let n=e.match(/^(\s*)-\s+([^\s]+)\s*(.*)$/);if(n){let e,t,r=Math.floor(n[1].length/2),i=n[2],a=n[3].trim(),l=i.endsWith("/"),o=l?i.slice(0,-1):i,c=a.split(/\s{2,}|\t+/).filter(Boolean);2===c.length?(e=c[0],t=c[1]):1===c.length&&(c[0].endsWith("ago")?t=c[0]:e=c[0]),s.push({indent:r,isDir:l,name:o,size:e,time:t})}}return{isDirectory:s.length>0,entries:s,notice:t}})(f),[f]),g=(0,i.Kr)(()=>(function(e,t,n){let r=e?.details??{},i=e?.input&&"object"==typeof e.input?e.input:{},s=r.displayContent;if(s&&Array.isArray(s.lineNumbers)&&s.lineNumbers.length>0)return{startLine:"number"==typeof s.startLine?s.startLine:void 0,lineNumbers:s.lineNumbers};if(Array.isArray(r.lineNumbers)&&r.lineNumbers.length>0)return{startLine:"number"==typeof r.startLine?r.startLine:void 0,lineNumbers:r.lineNumbers};if("number"==typeof s?.startLine&&s.startLine>0)return{startLine:s.startLine};if("number"==typeof r.startLine&&r.startLine>0)return{startLine:r.startLine};if("number"==typeof r.start_line&&r.start_line>0)return{startLine:r.start_line};if("number"==typeof r.offset&&r.offset>0)return{startLine:r.offset};let a=r.meta?.truncation?.shownRange?.start??r.truncation?.shownRange?.start??r.meta?.shownRange?.start??r.shownRange?.start;if("number"==typeof a&&a>0)return{startLine:a};let l=i.start_line??i.startLine??i.offset??i.StartLine??i.from;if("number"==typeof l&&l>0)return{startLine:l};if("string"==typeof l&&/^\d+$/.test(l.trim())){let e=parseInt(l.trim(),10);if(e>0)return{startLine:e}}for(let n of["string"==typeof i.path?i.path:"",e?.target||"",e?.title||"",t||""]){let e=n.match(/:(\d+)(?:-\d+)?(?:\s|$)/);if(e){let t=parseInt(e[1],10);if(t>0)return{startLine:t}}}if(n){let e=n.match(/\[(?:Showing\s+)?lines?\s+(\d+)(?:-\d+)?/i);if(e){let t=parseInt(e[1],10);if(t>0)return{startLine:t}}}return{}})(t,p,f),[t,p,f]),{displayContent:b,elisionNotices:v}=(0,i.Kr)(()=>{if(x.isDirectory)return{displayContent:f,elisionNotices:[]};let e=f.split(/\r?\n/),t=[],n=[];for(let r of e){let e=r.trim();(e.startsWith("[…")||e.startsWith("[Showing lines ")||e.startsWith("[1 results limit"))&&e.endsWith("]")?t.push(e.slice(1,-1)):n.push(r)}return 0===t.length&&h.summary&&"number"==typeof h.summary.elidedLines&&h.summary.elidedLines>0&&t.push(`…${h.summary.elidedLines}ln elided (${h.summary.lines??n.length} lines shown)`),g.lineNumbers&&n.length>g.lineNumbers.length&&""===n[n.length-1].trim()&&n.pop(),{displayContent:n.join("\n"),elisionNotices:t}},[f,x.isDirectory,g.lineNumbers,h.summary]),k=(0,i.Kr)(()=>x.isDirectory||!b?{lines:[],cleanCode:"",hasLineNumbers:!1}:function(e,t){let n=e.replace(/\r?\n$/,"").split(/\r?\n/);if(0===n.length)return{lines:[],cleanCode:"",hasLineNumbers:!1};let r=[],i=0,s=0;for(let e of n){if(!e.trim()){r.push(null);continue}let t=e.match(/^(\s*(\d+):)/);if(t){let n=parseInt(t[2],10);r.push({lineNum:n,rawLine:e}),i++;continue}let n=e.match(/^(\s*(\d+)\s*[|│][ \t]?)/);if(n){let t=parseInt(n[2],10);r.push({lineNum:t,rawLine:e,pipePrefixLen:n[1].length}),s++;continue}r.push(null)}let a=n.filter(e=>e.trim().length>0),l=s>=2&&s>=.7*a.length,o=!l&&i>=2&&i>=.7*a.length&&(()=>{let e=r.filter(e=>null!==e).map(e=>e.lineNum);for(let t=1;t<e.length;t++)if(e[t]<e[t-1])return!1;return!0})();if(!l&&!o){let e=t?.lineNumbers,r="number"==typeof t?.startLine&&!isNaN(t.startLine)&&t.startLine>0?t.startLine:1;return{lines:n.map((t,n)=>{let i;if(e&&n<e.length){let t=e[n];i=null==t||""===t?"…":t}else i=r+n;return{lineNum:i,code:t}}),cleanCode:n.join("\n"),hasLineNumbers:!!(e&&e.length>0||r>1)}}if(l){let e=r.find(e=>null!==e)?.lineNum??1,t=[];for(let i=0;i<n.length;i++){let s=n[i],a=r[i];s.trim()?a&&void 0!==a.pipePrefixLen?(t.push({lineNum:a.lineNum,code:s.slice(a.pipePrefixLen)}),e=a.lineNum+1):(t.push({lineNum:e,code:s}),e++):(t.push({lineNum:e,code:""}),e++)}return{lines:t,cleanCode:t.map(e=>e.code).join("\n"),hasLineNumbers:!0}}let c=r.filter(e=>null!==e),d=String(Math.max(...c.map(e=>e.lineNum))).length+1,u=c.filter(e=>e.rawLine.length>d);u.length>0&&u.every(e=>" "===e.rawLine[d]||" "===e.rawLine[d])&&d++;let p=c[0]?.lineNum??1,m=[];for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(!t.trim()){m.push({lineNum:p,code:""}),p++;continue}if(i){p=i.lineNum;let e=t.length<=d?"":t.slice(d);m.push({lineNum:i.lineNum,code:e}),p=i.lineNum+1}else m.push({lineNum:p,code:t}),p++}return{lines:m,cleanCode:m.map(e=>e.code).join("\n"),hasLineNumbers:!0}}(b,g),[b,x.isDirectory,g]),y=x.isDirectory,N=(0,eK.sQ)(p),w=x.entries.slice(-1e3),Y=x.entries.length-w.length,D=(0,i.Kr)(()=>ti(k.cleanCode,1e3),[k.cleanCode]),F=D.skipped>0?k.lines.slice(D.skipped):k.lines,A=(0,eU.w)(),C=(0,i.Kr)(()=>D.text?(0,eK.wY)(D.text,N):"",[D,N,A]);return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.Y)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-ink/5 text-ink/70",children:y?(0,r.Y)(nd.A,{size:12}):(0,r.Y)(ey.A,{size:12})}),(0,r.Y)("span",{className:"truncate font-mono text-[11px] font-medium text-ink",children:p||(y?"Directory Listing":"File Content")}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:y?"Directory":N})]}),f&&(0,r.Y)(eg,{text:k.hasLineNumbers?k.cleanCode:f||"",className:"flex shrink-0 cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10.5px] text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:11,label:"Copy"})]}),o?(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-ink/8 bg-paper px-3 py-3 font-mono text-[11px] text-ink/50",children:[(0,r.Y)(e_.A,{size:12,className:"animate-spin"}),(0,r.Y)("span",{children:"Loading file content..."})]}):y?(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[Y>0&&(0,r.FD)("div",{className:"flex items-center gap-1.5 border-b border-ink/8 bg-canvas/60 px-3 py-1.5 text-[10px] text-ink/50",children:[(0,r.Y)(ep.A,{size:11,className:"shrink-0"}),(0,r.FD)("span",{children:["… ",Y," earlier entries hidden"]})]}),(0,r.Y)("div",{className:"max-h-72 divide-y divide-ink/[0.04] overflow-y-auto font-mono text-[11px]",children:w.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 px-3 py-1.5 transition-colors hover:bg-ink/[0.02]",style:{paddingLeft:`${Math.max(12,(e.indent+1)*16)}px`},children:[e.isDir?(0,r.Y)(d.A,{size:12,className:"shrink-0 text-ink/60"}):(0,r.Y)(eN.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.FD)("span",{className:`min-w-0 flex-1 truncate ${e.isDir?"font-semibold text-ink":"text-ink/80"}`,children:[e.name,e.isDir&&"/"]}),e.size&&(0,r.Y)("span",{className:"shrink-0 font-mono text-[9.5px] text-ink/40",children:e.size}),e.time&&(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1 py-0.2 font-mono text-[9px] text-ink/45",children:e.time})]},t))}),x.notice&&(0,r.FD)("div",{className:"flex items-center gap-1.5 border-t border-ink/8 bg-canvas/60 px-3 py-1.5 text-[10px] text-ink/50",children:[(0,r.Y)(ep.A,{size:11,className:"shrink-0"}),(0,r.Y)("span",{children:x.notice})]})]}):f?(0,r.FD)("div",{className:"space-y-1.5",children:[D.skipped>0&&(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 bg-canvas/50 px-3 py-1.5 font-mono text-[10.5px] text-ink/55",children:[(0,r.Y)(ep.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.FD)("span",{children:["… ",D.skipped," earlier lines hidden"]})]}),(0,r.FD)("div",{className:"relative flex max-h-80 items-start overflow-auto rounded-lg border border-ink/8 bg-paper font-mono text-[11px] leading-[20px] select-text overscroll-contain",children:[(0,r.Y)("div",{className:"sticky left-0 z-10 flex-shrink-0 select-none border-r border-ink/8 bg-canvas/90 py-2.5 pl-3 pr-2.5 text-right font-mono text-[11px] leading-[20px] tabular-nums text-ink/35 backdrop-blur-xs","aria-hidden":"true",children:F.map((e,t)=>(0,r.Y)("div",{className:"h-[20px] leading-[20px]",children:e.lineNum},t))}),(0,r.Y)("pre",{className:"m-0 flex-1 min-w-max overflow-visible py-2.5 pl-3 pr-4 font-mono text-[11px] leading-[20px] whitespace-pre text-ink/85 focus:outline-none",dangerouslySetInnerHTML:{__html:C}})]}),v.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 bg-canvas/50 px-3 py-1.5 font-mono text-[10.5px] text-ink/55",children:[(0,r.Y)(ep.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{children:e})]},t))]}):(0,r.Y)("div",{className:"rounded-lg border border-dashed border-ink/15 px-3 py-3 font-mono text-[11px] text-ink/45",children:"File is ready for inspection."})]})}var np=n("fQ"),nm=n("BE");function nh(e){let{sections:t}=e,n=(0,eU.w)(),s=(0,i.Kr)(()=>t.map(e=>{let t=(0,eK.sQ)(e.path);return e.ops.map(e=>(0,eK.O9)(e.body.join("\n"),t))}),[t,n]);return(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:[(0,r.Y)("span",{children:"Hashline Patch"}),t[0].tag&&(0,r.FD)("span",{className:"font-mono text-[9px] font-normal tracking-normal text-ink/50",children:["snapshot ",t[0].tag]})]}),(0,r.Y)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:t.map((e,t)=>(0,r.FD)("div",{className:"border-b border-ink/6 last:border-b-0",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-2 bg-canvas/40 px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] font-medium text-ink",children:e.path}),e.moveTo&&(0,r.FD)("span",{className:"shrink-0 font-mono text-[10px] text-ink/50",children:["→ ",e.moveTo]}),e.removed&&(0,r.Y)("span",{className:"shrink-0 rounded bg-error/10 px-1.5 font-mono text-[9px] uppercase tracking-wider text-error",children:"Removes file"})]}),(0,r.Y)("div",{className:"overflow-x-auto",children:e.ops.map((e,n)=>(0,r.FD)("div",{children:[(0,r.FD)("div",{className:"flex items-center gap-2 px-2.5 py-1",children:[(0,r.Y)("span",{className:`shrink-0 rounded px-1.5 font-mono text-[9px] font-semibold ${"CUT"===e.verb?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:e.verb}),e.spec&&(0,r.Y)("span",{className:"font-mono text-[10.5px] text-ink/70",children:e.spec})]}),e.body.map((e,i)=>{let a=s[t]?.[n]?.[i]||"";return a?(0,r.Y)("div",{className:"shiki whitespace-pre bg-success/[0.05] px-2.5 font-mono text-[11px] leading-relaxed",dangerouslySetInnerHTML:{__html:a}},i):(0,r.Y)("div",{className:"whitespace-pre bg-success/[0.05] px-2.5 font-mono text-[11px] leading-relaxed text-success/90",children:e},i)})]},`${e.verb}-${e.spec}-${n}`))})]},e.path))})]})}var nf=n("e");function nx(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"diff",r=e?e.split(/\r?\n/):[],i=t?t.split(/\r?\n/):[],s=0;for(;s<r.length&&s<i.length&&r[s]===i[s];)s++;let a=0;for(;a<r.length-s&&a<i.length-s&&r[r.length-1-a]===i[i.length-1-a];)a++;let l=r.slice(Math.max(0,s-2),s),o=r.slice(s,r.length-a),c=i.slice(s,i.length-a),d=r.slice(r.length-a,r.length-a+2),u=n||"diff",p=[`--- a/${u}`,`+++ b/${u}`,`@@ -1,${r.length||1} +1,${i.length||1} @@`];for(let e of l)p.push(` ${e}`);for(let e of o)p.push(`-${e}`);for(let e of c)p.push(`+${e}`);for(let e of d)p.push(` ${e}`);return p.join("\n")}function ng(e){let{tool:t}=e,n="write"===t.type||"write"===t.name||"create_file"===t.type,s=t.input,a="object"==typeof s&&null!==s?s:void 0,l=(0,i.Kr)(()=>(0,nf.I)(a),[a]),o=t.target||l?.sections[0].path||a?.path||a?.TargetFile||a?.targetFile||a?.FilePath||a?.filePath||a?.AbsolutePath||a?.absolutePath||("string"==typeof t.details?.path?t.details.path:void 0)||("string"==typeof s&&(s.includes("/")||s.includes("."))?s:void 0)||"",c="string"==typeof a?.content?a.content:"string"==typeof a?.Content?a.Content:void 0,d="string"==typeof a?.old_string?a.old_string:"string"==typeof a?.oldString?a.oldString:"string"==typeof a?.TargetContent?a.TargetContent:"string"==typeof a?.targetContent?a.targetContent:void 0,u="string"==typeof a?.new_string?a.new_string:"string"==typeof a?.newString?a.newString:"string"==typeof a?.ReplacementContent?a.ReplacementContent:"string"==typeof a?.replacementContent?a.replacementContent:void 0,p=Array.isArray(a?.ReplacementChunks)?a.ReplacementChunks:void 0,m=t.diff?.diffText||("string"==typeof t.details?.diff?t.details.diff:void 0)||("string"==typeof t.details?.patch?t.details.patch:void 0),h=(0,i.Kr)(()=>m||(p&&p.length>0?p.map(e=>nx(e.TargetContent||"",e.ReplacementContent||"",o)).join("\n"):d||u?nx(d||"",u||"",o):void 0),[m,p,d,u,o]),f=t.output||"",x=(0,eK.sQ)(o),g=(0,i.Kr)(()=>d?ti(d,1e3):null,[d]),b=(0,i.Kr)(()=>u?ti(u,1e3):null,[u]),v=(0,eU.w)(),k=(0,i.Kr)(()=>g?(0,eK.wY)(g.text,x):"",[g,x,v]),y=(0,i.Kr)(()=>b?(0,eK.wY)(b.text,x):"",[b,x,v]),N=(0,i.Kr)(()=>c?c.split("\n").length:0,[c]),w=(0,i.Kr)(()=>c?(0,eK.wY)(c.split("\n").slice(0,80).join("\n"),x):"",[c,x,v]),Y=(0,i.Kr)(()=>tn(f),[f]),D=(0,i.Kr)(()=>ti(Y.content,1e3),[Y]),F=(0,i.Kr)(()=>tr(D.text,Y.format),[D,Y.format]);return(0,r.FD)("div",{className:"space-y-2.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.Y)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-ink/5 text-ink/70",children:n?(0,r.Y)(np.A,{size:12}):(0,r.Y)(nm.A,{size:12})}),(0,r.Y)("span",{className:"truncate font-mono text-[11px] font-medium text-ink",children:o||"File modification"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:n?"Write":"Edit"})]}),(c||u||l)&&(0,r.Y)(eg,{text:l?.text||c||u||f,className:"flex shrink-0 cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10.5px] text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:11,label:"Copy"})]}),h&&(0,r.FD)("div",{className:"space-y-1",children:[(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Diff Changes"}),(0,r.Y)(eH,{text:h})]}),!h&&l&&(0,r.Y)(nh,{sections:l.sections}),!h&&(d||u)&&(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Replacement Changes"}),(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[d&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-error/[0.04] p-2.5",children:[(0,r.Y)("div",{className:"mb-1 flex items-center gap-1 text-[9.5px] font-semibold uppercase tracking-wider text-error",children:(0,r.Y)("span",{children:"- Original Content"})}),g&&g.skipped>0&&(0,r.FD)("div",{className:"mb-1 font-mono text-[9.5px] text-ink/45",children:["… ",g.skipped," earlier lines hidden"]}),(0,r.Y)("pre",{className:"max-h-40 overflow-x-auto font-mono text-[11px] leading-relaxed text-error/90 whitespace-pre-wrap break-words",dangerouslySetInnerHTML:{__html:k}})]}),u&&(0,r.FD)("div",{className:"bg-success/[0.04] p-2.5",children:[(0,r.Y)("div",{className:"mb-1 flex items-center gap-1 text-[9.5px] font-semibold uppercase tracking-wider text-success",children:(0,r.Y)("span",{children:"+ Replaced With"})}),b&&b.skipped>0&&(0,r.FD)("div",{className:"mb-1 font-mono text-[9.5px] text-ink/45",children:["… ",b.skipped," earlier lines hidden"]}),(0,r.Y)("pre",{className:"max-h-48 overflow-x-auto font-mono text-[11px] leading-relaxed text-success/90 whitespace-pre-wrap break-words",dangerouslySetInnerHTML:{__html:y}})]})]})]}),!h&&!d&&!u&&c&&(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:[(0,r.FD)("span",{className:"flex items-center gap-1",children:[(0,r.Y)(ey.A,{size:11}),(0,r.Y)("span",{children:"Written File Preview"})]}),(0,r.FD)("span",{className:"font-mono text-[9px] text-ink/50",children:[N," lines · ",(0,eX.z3)(c.length)]})]}),(0,r.FD)("div",{className:"flex max-h-64 items-start overflow-x-auto rounded-lg border border-ink/8 bg-paper font-mono text-[11px] leading-[20px] select-text overscroll-contain",children:[(0,r.FD)("div",{className:"sticky left-0 z-10 flex-shrink-0 select-none border-r border-ink/8 bg-canvas/60 py-2.5 pl-2.5 pr-2 text-right font-mono text-[11px] leading-[20px] tabular-nums text-ink/25","aria-hidden":"true",children:[Array.from({length:Math.min(N,80)},(e,t)=>(0,r.Y)("div",{className:"h-[20px] leading-[20px]",children:t+1},t)),N>80&&(0,r.Y)("div",{className:"h-[20px] leading-[20px]",children:"…"})]}),(0,r.Y)("div",{className:"m-0 flex-1 min-w-max overflow-visible py-2.5 pl-3 pr-4 leading-[20px] whitespace-pre text-ink/85",dangerouslySetInnerHTML:{__html:w}})]})]}),f&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5 select-text",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 mb-1.5 text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:[(0,r.Y)(t7.A,{size:11,className:"text-success"}),(0,r.Y)("span",{children:"Execution Output"})]}),Y.envelope&&(0,r.Y)(te,{envelope:Y.envelope}),D.skipped>0&&(0,r.FD)("div",{className:"mb-1 font-mono text-[9.5px] text-ink/45",children:["… ",D.skipped," earlier lines hidden"]}),(0,r.Y)(eh.T,{content:F,className:"text-[11.5px] text-ink/85"})]})]})}function nb(e){let{value:t}=e;return Array.isArray(t)?(0,r.Y)(nv,{items:t}):(0,t3.u)(t)?(0,r.Y)(nk,{data:t}):"string"==typeof t?t.length>120||t.includes("\n")?(0,r.Y)("div",{className:"prose-content max-h-60 overflow-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 text-[12px] leading-relaxed text-ink/85 select-text",children:(0,r.Y)(eh.T,{content:t})}):(0,r.Y)("span",{className:"break-words text-[12px] leading-relaxed text-ink/85",children:t}):(0,r.Y)("span",{className:"font-mono text-[12px] text-ink/85",children:JSON.stringify(t)??""})}function nv(e){let{items:t}=e,n=t.slice(0,50);return(0,r.FD)("div",{className:"space-y-1",children:[(0,r.Y)("ol",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:n.map((e,t)=>(0,r.FD)("li",{className:"flex items-start gap-2 px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded bg-ink/5 font-mono text-[9px] text-ink/45",children:t+1}),(0,r.Y)("div",{className:"min-w-0 flex-1",children:(0,r.Y)(nb,{value:e})})]},t))}),t.length>n.length&&(0,r.FD)("div",{className:"font-mono text-[10px] text-ink/45",children:["… ",t.length-n.length," more items"]})]})}function nk(e){let{data:t}=e,n=Object.entries(t);return 0===n.length?(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-canvas/40 px-2.5 py-2 text-[11px] text-ink/45",children:"Empty object"}):(0,r.Y)("div",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:n.map(e=>{let[t,n]=e,i=Array.isArray(n)?`list \xb7 ${n.length}`:(0,t3.u)(n)?"json":"string"==typeof n?"markdown":typeof n;return(0,r.FD)("div",{className:"px-2.5 py-2",children:[(0,r.FD)("div",{className:"mb-1 flex items-center gap-1.5",children:[(0,r.Y)(eZ.A,{size:10.5,className:"shrink-0 text-ink/45"}),(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] font-semibold text-ink",title:t,children:t}),(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[8.5px] uppercase tracking-wider text-ink/50",children:i})]}),(0,r.Y)(nb,{value:n})]},t)})})}function ny(e){let{tool:t}=e,n="object"==typeof t.input&&null!==t.input?t.input:void 0,s="string"==typeof n?.path?n.path:t.target||"",a="string"==typeof t.name?t.name:"",l=(s?s.replace(/^xd:\/\//,""):a).replace(/^mcp__/,""),o="string"==typeof n?.content?n.content:"",c=(0,i.Kr)(()=>o?(0,eK.Bl)(o):{isValid:!1},[o]),d=c.isValid?c.data:void 0,u=(0,t3.u)(d)||Array.isArray(d),p=(0,i.Kr)(()=>t.output?(0,eK.Bl)(t.output):{isValid:!1},[t.output]),m=p.isValid?p.data:void 0,h=(0,t3.u)(m)||Array.isArray(m);return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 rounded-lg border border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)(C.A,{size:12,className:"shrink-0 text-ink/60"}),(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] font-semibold text-ink",children:l||"MCP Tool"}),(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[8.5px] uppercase tracking-wider text-ink/50",children:"MCP"})]}),o&&u?(0,r.Y)(nb,{value:d}):o?(0,r.Y)("div",{className:"prose-content max-h-72 overflow-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 text-[12px] leading-relaxed text-ink/85 select-text",children:(0,r.Y)(eh.T,{content:o})}):null,t.output&&h?(0,r.FD)("div",{className:"space-y-1",children:[(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Result"}),(0,r.Y)(nb,{value:m})]}):t.output?(0,r.Y)(ts,{text:t.output}):null]})}function nN(e){if(e.target)return e.target;if(e.diff?.file)return e.diff.file;if(e.input&&"object"==typeof e.input){let t=e.input;if("string"==typeof t.path)return t.path;if("string"==typeof t.TargetFile)return t.TargetFile;if("string"==typeof t.targetFile)return t.targetFile;if("string"==typeof t.FilePath)return t.FilePath;if("string"==typeof t.filePath)return t.filePath;if("string"==typeof t.AbsolutePath)return t.AbsolutePath;if("string"==typeof t.absolutePath)return t.absolutePath;if("string"==typeof t.file)return t.file;let n=(0,nf.f$)(t);if(n)return n}return"string"==typeof e.details?.path?e.details.path:"string"==typeof e.input&&(e.input.includes(".")||e.input.includes("/"))?e.input:e.detail&&(e.detail.includes(".")||e.detail.includes("/"))?e.detail:void 0}function nw(e){let t=e.details;if(t?.xdev?.tool&&"string"==typeof t.xdev.tool)return t.xdev.tool.toLowerCase();let n=(e.target||"").toLowerCase(),r=to(e.input)?.toLowerCase()??"",i=n.startsWith("xd://")?n.slice(5):r.startsWith("xd://")?r.slice(5):"";if(i){let e=i.split(/[/?#]/)[0].trim();if(e)return e}let s=(e.name||"").toLowerCase(),a=(e.type||"").toLowerCase(),l=(e.title||"").toLowerCase();if(s&&"tool"!==s&&"custom"!==s)return s;let o=l.split(/[\s—\-:]+/)[0]?.trim();return["grep","glob","read","write","edit","bash","terminal","run_command","todo","eval","hub","lsp","github","task","resolve","reject"].includes(o)?o:a}function nY(e){let{tool:t}=e,n=nw(t);if("read"===n||"read_file"===n||"view_file"===n||"read_file_content"===n){let e=nN(t);return(0,r.Y)(nu,{tool:t,targetFilePath:e,output:t.output||""})}return"edit"===n||"write"===n||"edit_file"===n||"create_file"===n||"write_to_file"===n||"replace_file_content"===n||"multi_edit_file"===n?(0,r.Y)(ng,{tool:t}):"task"===n?(0,r.Y)(e2,{tool:t}):"todo"===n?(0,r.Y)(ta,{tool:t}):"grep"===n||"glob"===n||"ast_grep"===n?(0,r.Y)(t$,{tool:t}):"search_fs"===n?(0,r.Y)(nl,{tool:t}):"web_search"===n?(0,r.Y)(tf,{tool:t}):"bash"===n||"terminal"===n||"run_command"===n?(0,r.Y)(tC,{tool:t}):"eval"===n?(0,r.Y)(tb,{tool:t}):"lsp"===n?(0,r.Y)(tu,{tool:t}):"ast_edit"===n?(0,r.Y)(ne,{tool:t}):"resolve"===n||"reject"===n?(0,r.Y)(nt,{tool:t}):"hub"===n?(0,r.Y)(tJ,{tool:t}):"github"===n?(0,r.Y)(tN,{tool:t}):"checkpoint"===n||"rewind"===n?(0,r.Y)(tA,{tool:t}):"security_scan"===n?(0,r.Y)(tE,{tool:t}):"debug"===n?(0,r.Y)(t1,{tool:t}):"manage_skill"===n?(0,r.Y)(ns,{tool:t}):"context_notes"===n||"new_context"===n?(0,r.Y)(tU,{tool:t}):"memory_edit"===n||"retain"===n||"recall"===n||"reflect"===n||"learn"===n?(0,r.Y)(tV,{tool:t}):"goal"===n||"yield"===n?(0,r.Y)(t6,{tool:t}):"ask"===n?(0,r.Y)(no,{tool:t}):"think"===n?(0,r.Y)(nc,{tool:t}):n.startsWith("mcp__")||"string"==typeof t.name&&t.name.startsWith("mcp__")?(0,r.Y)(ny,{tool:t}):null}function nD(e){let t="object"==typeof e.input&&null!==e.input?e.input:void 0,n="string"==typeof t?.path?t.path:e.target||"",r=(n.startsWith("xd://")?n.slice(5):"string"==typeof e.name&&e.name.startsWith("mcp__")?e.name:"").split(/[/?#]/)[0].trim();return r.startsWith("mcp__")?r.slice(5):void 0}function nF(e){let t=e.details?.xdev;return t&&"object"==typeof t?t:void 0}function nA(e){let{children:t}=e;return(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:t})}let nC=(0,a.ph)(function(e){let t,{tool:n,isOpen:s,onToggle:a,defaultExpanded:l=!1}=e,o=nw(n),c=(0,i.Kr)(()=>null!==nY({tool:n}),[n]),d=n.command?n.command:"string"==typeof n.input?n.input:n.input&&"object"==typeof n.input?JSON.stringify(n.input,null,2):(n.target||n.detail)&&(n.target||n.detail)||"",u=n.output||(n.error?`Error: ${n.error}`:""),m=function(e){if(e.diff?.diffText)return e.diff.diffText;let t=e.details;if(t&&"object"==typeof t){if("string"==typeof t.patch)return t.patch;if("string"==typeof t.diff)return t.diff}}(n),h=(0,i.hb)(()=>{a?.(n.id)},[a,n.id]),f=(0,i.Kr)(()=>!c&&d?(0,eK.Bl)(d):null,[c,d]),x=(0,i.Kr)(()=>{let e=eO(eL(u));return!!(e&&eE(e.tag))},[u]),g="";if("lsp"===o){g="LSP";let e=nF(n);e?.args?.action&&(t=`${e.args.action}${e.args.file?` \xb7 ${e.args.file}`:""}`)}else if("ast_edit"===o){g="AST Edit";let e=nF(n);e?.args?.paths?.[0]&&(t=e.args.paths[0])}else if("resolve"===o)g="Resolve Proposal";else if("reject"===o)g="Reject Proposal";else if("yield"===o)g="error"===n.status?"Yield":u?`Yield - ${u}`:"Yield";else if("todo"===o||"todo"===n.name||"todo"===n.type||n.title&&n.title.toLowerCase().startsWith("todo")){g="Todo";let e=function(e){let t=e3(e);if(t.totalTasks>0||t.groups.length>0)return t.summaryText}(n);if(e)t=e;else if(n.title&&(n.title.includes("—")||n.title.includes(" - ")||n.title.includes(": "))){let e=n.title.split(/\s+[—\-:]\s+/).slice(1).join(" — ").trim();t=e.split(/\s*·\s*/).filter(e=>!/^0\s+(complete|in progress|pending)/i.test(e)).join(" · ")||e}}else if(nD(n)){let e="object"==typeof n.input&&null!==n.input?n.input:void 0;g=e7(nD(n));let r=function(e,t){if(e.intent)return e.intent;let n="string"==typeof t?.content?t.content:"",r=n?(0,eK.Bl)(n):{isValid:!1,data:void 0},i=r.isValid?r.data:t;if(i&&"object"==typeof i){let e=["query","q","pattern","pat","name","sql","path","symbol","url","command"].find(e=>"string"==typeof i[e]&&i[e]);if(e)return i[e]}}(n,e);r&&(t=r.length>80?`${r.slice(0,79)}…`:r)}else if(n.title&&(n.title.includes("—")||n.title.includes(" - ")||n.title.includes(": "))){let e=n.title.split(/\s+[—\-:]\s+/);g=e7(e[0].trim()),t=e.slice(1).join(" — ").trim()}else g=n.title?e7(n.title):e7(o||n.name||"Tool Call");if(("task"===o||"task"===n.name)&&!t){let e="object"==typeof n.input&&null!==n.input?n.input:void 0,r=Array.isArray(e?.tasks)?e.tasks[0]:void 0;r?.name&&(t=`${r.name}${r.agent?` \xb7 ${r.agent}`:""}`)}let b=nN(n),k=t&&!t.startsWith("xd://")?t:b&&!b.startsWith("xd://")?b:t||(n.detail&&!b?n.detail:void 0),y=n.duration||n.time,N=y||x?(0,r.FD)("span",{className:"flex items-center gap-2",children:[y?(0,r.Y)("span",{className:"font-mono text-[10px] text-ink/40",children:y}):null,x&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-error/10 px-2 py-0.5 text-[10px] font-semibold text-error",children:[(0,r.Y)(e$.A,{size:10})," Reminder"]})]}):null;return(0,r.FD)(eW,{tool:n,icon:n.icon||function(e){switch(e){case"bash":case"terminal":return(0,r.Y)(ek.A,{size:14});case"edit":case"write":case"edit_file":case"create_file":case"ast_edit":return(0,r.Y)(ey.A,{size:14});case"read":case"read_file":case"view_file":return(0,r.Y)(eN.A,{size:14});case"glob":case"grep":case"search_fs":case"ast_grep":return(0,r.Y)(v.A,{size:14});case"web_search":return(0,r.Y)(T.A,{size:14});case"todo":case"task":return(0,r.Y)(ew.A,{size:14});case"eval":return(0,r.Y)(eY.A,{size:14});case"lsp":return(0,r.Y)(eD.A,{size:14});case"resolve":case"reject":return(0,r.Y)(p.A,{size:14});case"hub":return(0,r.Y)(eF.A,{size:14});case"ask":return(0,r.Y)(eA.A,{size:14});case"think":return(0,r.Y)(em.A,{size:14});case"security_scan":return(0,r.Y)(eC.A,{size:14});case"checkpoint":case"rewind":return(0,r.Y)(eS.A,{size:14});case"github":return(0,r.Y)(eT.A,{size:14});case"memory_edit":case"retain":case"recall":case"reflect":case"learn":return(0,r.Y)(z.A,{size:14});default:if(e.startsWith("mcp__"))return(0,r.Y)(C.A,{size:14});return(0,r.Y)(ez.A,{size:14})}}(o),title:g,subtitle:k,meta:N,isOpen:s,onToggle:a?h:void 0,defaultExpanded:l,alwaysExpanded:"yield"===o&&c,children:[(0,r.Y)(nY,{tool:n}),!c&&d&&(0,r.FD)("div",{className:"space-y-1.5 code-surface",children:[(0,r.FD)("div",{className:"flex items-center justify-between",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)(nA,{children:"Input"}),f?.isValid&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/45",children:"JSON"})]}),(0,r.Y)(eg,{text:f?.isValid&&f.pretty?f.pretty:d,className:"flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",onClick:e=>e.stopPropagation(),label:"Copy"})]}),f?.isValid&&f.pretty?(0,r.Y)(eQ,{jsonString:f.pretty,maxHeightClass:"max-h-60",showHeader:!1}):(0,r.Y)("pre",{className:"overflow-x-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-all text-ink/80 select-text",children:d})]}),!c&&m&&(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.Y)(nA,{children:"Diff"}),(0,r.Y)(eH,{text:m})]}),!c&&u&&(0,r.Y)(ts,{text:u})]})});function nS(e){let{tools:t,title:n,defaultExpanded:s=!1}=e,a=(0,i.Kr)(()=>(t||[]).map((e,t)=>(function(e,t){if("id"in e&&e.id)return e;let n=e.title||"",r=n.toLowerCase(),i="terminal";r.includes("shell")||r.includes("command")||r.includes("bun")||r.includes("git")?i="bash":r.includes("edit")||r.includes("write")?i="edit_file":r.includes("read")||r.includes("view")||r.includes("cat")||r.includes("inspect")?i="read_file":(r.includes("search")||r.includes("find")||r.includes("grep"))&&(i="search_fs");let s=n.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()||"tool",a="type"in e&&e.type?e.type:i;return{id:`stable-tool-${t}-${s}`,type:a,title:e.title,duration:e.time,time:e.time,detail:e.detail,target:"target"in e&&e.target?e.target:"read_file"===a||"edit_file"===a||"create_file"===a?e.detail:void 0,command:e.command||("bash"===a?e.detail:void 0),output:e.output,status:e.status||"success",icon:e.icon,diff:"diff"in e?e.diff:void 0,input:"input"in e?e.input:void 0}})(e,t)),[t]),[l,o]=(0,i.J0)(()=>{let e={};return a.forEach((t,n)=>{let r=!ev(t)&&("error"===t.status||s&&0===n);e[t.id]=r}),e}),c=(0,i.hb)(e=>{o(t=>({...t,[e]:!t[e]}))},[]);return a&&0!==a.length?(0,r.FD)("div",{className:"mx-3 space-y-1.5",children:[n&&(0,r.FD)("div",{className:"flex items-center gap-2 px-1 pt-0.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/35",children:n}),(0,r.Y)("span",{className:"h-px flex-1 bg-ink/8"})]}),a.map(e=>(0,r.Y)(nC,{tool:e,isOpen:!!l[e.id],onToggle:c},e.id))]}):null}var nT=n("oE"),nz=n("bH"),n$=n("Sb");function nj(e){let{task:t}=e;(0,eU.w)();let n=t.structuredOutput,s=!t.formattedJson&&(0,eK.rw)(t.rawOutput),[a,l]=(0,i.J0)(n||!s?"formatted":"raw");return(0,r.FD)("div",{className:"space-y-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/8 pb-2",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(n||!s)&&(0,r.FD)("button",{type:"button",onClick:()=>l("formatted"),className:`flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors ${"formatted"===a?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/5 hover:text-ink"}`,children:[(0,r.Y)(nz.A,{size:12}),(0,r.Y)("span",{children:n?"Overview":"Markdown"})]}),(0,r.FD)("button",{type:"button",onClick:()=>l("raw"),className:`flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors ${"raw"===a?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/5 hover:text-ink"}`,children:[(0,r.Y)(e8.A,{size:12}),(0,r.Y)("span",{children:t.formattedJson?"Raw JSON":s?"Code":"Raw Text"})]})]}),(0,r.Y)(eg,{text:t.formattedJson||t.rawOutput,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[10.5px] font-medium text-ink/60 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:12,title:"Copy payload",resetMs:1800,wrapLabel:!0,copiedLabelClassName:"text-success",label:"Copy"})]}),"formatted"===a&&(n?(0,r.FD)("div",{className:"space-y-3 text-[11.5px]",children:[n.summary&&(0,r.FD)("div",{className:"rounded-lg border border-ink/10 bg-canvas/60 p-2.5",children:[(0,r.FD)("div",{className:"mb-1 flex items-center gap-1.5 font-mono text-[10px] font-semibold uppercase tracking-wider text-ink/70",children:[(0,r.Y)(n$.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Summary"})]}),(0,r.Y)("div",{className:"leading-relaxed text-ink/85",children:(0,r.Y)(eh.T,{content:n.summary,className:"text-[11.5px]"})})]}),n.architecture&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5",children:[(0,r.FD)("div",{className:"mb-1 flex items-center gap-1.5 font-mono text-[10px] font-semibold text-ink/70 uppercase tracking-wider",children:[(0,r.Y)(nT.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Architecture"})]}),(0,r.Y)("p",{className:"leading-relaxed text-ink/80",children:n.architecture})]}),Array.isArray(n.files)&&n.files.length>0&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5",children:[(0,r.FD)("div",{className:"mb-2 flex items-center justify-between",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 font-mono text-[10px] font-semibold text-ink/70 uppercase tracking-wider",children:[(0,r.Y)(ey.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Files Inspected"})]}),(0,r.FD)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/50",children:[n.files.length," items"]})]}),(0,r.Y)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:n.files.map((e,t)=>(0,r.FD)("div",{className:"flex flex-col justify-between rounded border border-ink/6 bg-canvas/40 p-1.5 transition-colors hover:border-ink/15",children:[(0,r.Y)("span",{className:"font-mono text-[10.5px] font-medium text-ink truncate",children:e.path}),e.description&&(0,r.Y)("span",{className:"text-[10px] text-ink/60 leading-tight line-clamp-2 mt-0.5",children:e.description})]},t))})]}),n.report&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5",children:[(0,r.FD)("div",{className:"mb-2 flex items-center gap-1.5 font-mono text-[10px] font-semibold text-ink/70 uppercase tracking-wider",children:[(0,r.Y)(eN.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Report"})]}),(0,r.Y)("div",{className:"max-h-72 overflow-auto rounded border border-ink/6 bg-canvas/30 p-2 text-ink/85 scrollbar-overlay-container",children:(0,r.Y)(eh.T,{content:n.report,className:"text-[11.5px] leading-relaxed"})})]})]}):(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px] leading-relaxed text-ink/85 max-h-72 overflow-auto scrollbar-overlay-container",children:(0,r.Y)(eh.T,{content:t.rawOutput})})),"raw"===a&&(0,r.Y)("pre",{className:"max-h-64 overflow-auto rounded-lg border border-ink/8 bg-paper p-3 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words text-ink/80 scrollbar-overlay-container scrollbar-overlay-static",dangerouslySetInnerHTML:{__html:(0,eK.wY)(t.formattedJson||t.rawOutput,t.formattedJson?"json":s?"javascript":"markdown")}}),t.outro&&(0,r.FD)("div",{className:"rounded-lg border border-ink/10 bg-canvas/60 p-2.5 text-[11px] text-ink/75",children:[(0,r.FD)("div",{className:"mb-1.5 flex items-center gap-1.5 font-mono text-[9.5px] font-semibold uppercase tracking-wider text-ink/50",children:[(0,r.Y)(ek.A,{size:11}),(0,r.Y)("span",{children:"Follow-up & Transcript"})]}),(0,r.Y)("div",{className:"text-[11.5px] leading-relaxed text-ink/85",children:(0,r.Y)(eh.T,{content:t.outro})})]})]})}function nL(e){let{notice:t}=e,[n,s]=(0,i.J0)(!1);(0,eU.w)();let a=(0,i.Kr)(()=>(function(e){let t,n,r;if(!e)return null;let i=e.match(/([\s\S]*?)<task-result\b([^>]*)>([\s\S]*?)<\/task-result>([\s\S]*)/i);if(!i)return null;let s=i[1].trim(),a=i[2],l=i[3].trim(),o=i[4].trim(),c=a.match(/\bid=["']([^"']+)["']/i)?.[1],d=a.match(/\bagent=["']([^"']+)["']/i)?.[1],u=a.match(/\bstatus=["']([^"']+)["']/i)?.[1],p=a.match(/\bduration=["']([^"']+)["']/i)?.[1],m=l.match(/<meta\b([^>]*)\/?>/i);if(m){let e=m[1],n=e.match(/\blines=["']([^"']+)["']/i)?.[1],r=e.match(/\bsize=["']([^"']+)["']/i)?.[1];(n||r)&&(t={lines:n,size:r})}let h="",f=l.match(/<output\b[^>]*>([\s\S]*?)<\/output>/i);if(f)h=f[1].trim();else{let e=l.match(/<preview\b[^>]*>([\s\S]*?)<\/preview>/i),t=e?.[1].trim();h=t||l.replace(/<meta\b[^>]*\/?>(?:\s*<\/meta>)?|<\/?preview\b[^>]*>/gi,"").trim()}if(h.startsWith("{")||h.startsWith("["))try{let e=JSON.parse(h);e&&"object"==typeof e&&!Array.isArray(e)&&(n=e,r=JSON.stringify(e,null,2))}catch{let e=function(e){let t=e;for(let e=0;e<16;e+=1){let{stack:e,inString:n,escaped:r}=function(e){let t=[],n=!1,r=!1;for(let i of e){if(n){r?r=!1:"\\"===i?r=!0:'"'===i&&(n=!1);continue}'"'===i?n=!0:"{"===i||"["===i?t.push("{"===i?"}":"]"):("}"===i||"]"===i)&&t.pop()}return{stack:t,inString:n,escaped:r}}(t),i=t;n&&(r&&(i=i.slice(0,-1)),i+='"'),i=(i=i.replace(/,\s*"[^"]*"\s*:\s*$/,"").replace(/"[^"]*"\s*:\s*$/,"").replace(/,\s*$/,"")+[...e].reverse().join("")).replace(/,\s*(?=[}\]])/g,"");try{return JSON.parse(i),i}catch{let e=t.lastIndexOf(",");if(e<=0)return null;t=t.slice(0,e)}}return null}(h);if(e){let t=JSON.parse(e);t&&"object"==typeof t&&!Array.isArray(t)&&(n=t,r=JSON.stringify(t,null,2),h=e)}}return{intro:s||(c?`Background job ${c} completed`:"System notice"),id:c,agent:d,status:u,duration:p,meta:t,rawOutput:h,formattedJson:r,structuredOutput:n,outro:o||void 0}})(t),[t]),l=(0,i.Kr)(()=>{if(!(/<\/?system-reminder[^>]*>/i.test(t)||t.includes("xd://resolve")||t.includes("`ast_edit` result")))return null;let e=t.replace(/<\/?system-reminder[^>]*>/gi,"").trim();if(!e)return null;let n=(e.split(/\r?\n/).map(e=>e.trim()).find(Boolean)??e).replace(/`([^`]+)`/g,"$1");return{content:e,title:n}},[t]),o=(0,i.Kr)(()=>{let e=t.replace(/<\/?system-notice[^>]*>/gi,"").trim(),n=e.split(/\r?\n/),r=(n.find(e=>e.trim())??"").trim(),i=n.findIndex(e=>e.trim()===r),s=n.slice(i+1).join("\n").trim(),a=(0,eK.rw)(s);return{clean:e,firstLine:r,rest:s,isCode:a}},[t]),c=a?.intro||l?.title||o.firstLine||t,d=c.length>100,p=c.slice(0,100)+(d?"...":""),m=(0,i.Kr)(()=>{if(a)return!0;let e=t.replace(/<\/?(?:system-notice|system-reminder)[^>]*>/gi,"").trim();return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).length>1||e.length>100||c.length>100},[a,t,c]),h=(0,i.Kr)(()=>a?"failed"===a.status||"error"===a.status?{icon:(0,r.Y)(eu.A,{size:13}),badgeClass:"bg-error/10 text-error",label:"Task Result",isError:!0}:{icon:(0,r.Y)(eB.A,{size:13}),badgeClass:"bg-success/10 text-success",label:"Task Result",isError:!1}:l?{icon:(0,r.Y)(e$.A,{size:13}),badgeClass:"bg-warning/10 text-warning",label:"System Reminder",isError:!1}:{icon:(0,r.Y)(ep.A,{size:13}),badgeClass:"bg-info/10 text-info",label:"System Notice",isError:!1},[a,l]);return(0,r.FD)("div",{className:`mx-3 overflow-hidden rounded-xl border border-ink/10 bg-paper text-[12px] text-ink transition-colors ${m?"hover:border-ink/20":""} select-text`,children:[(0,r.FD)("button",{type:"button",onClick:()=>{m&&s(e=>!e)},disabled:!m,"aria-expanded":m?n:void 0,className:`flex w-full items-center gap-2.5 px-3 py-2.5 text-left transition-colors ${m?"cursor-pointer hover:bg-ink/[0.03]":"cursor-default"} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`,children:[(0,r.Y)("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg ${h.badgeClass}`,children:h.icon}),(0,r.FD)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.FD)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,r.Y)("span",{className:"truncate text-[12px] font-semibold tracking-tight text-ink",children:h.label}),a?.agent&&(0,r.FD)("span",{className:"flex items-center gap-1 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/60",children:[(0,r.Y)(A.A,{size:10}),a.agent]}),a?.status&&(0,r.FD)("span",{className:`flex items-center gap-1 rounded px-1.5 py-0.2 font-mono text-[9px] font-semibold uppercase ${h.isError?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:[h.isError?(0,r.Y)(eu.A,{size:10}):(0,r.Y)(eB.A,{size:10}),a.status]}),a?.duration&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9px] text-ink/40",children:[(0,r.Y)(tx.A,{size:9}),a.duration]}),a?.meta?.size&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9px] text-ink/40",children:[(0,r.Y)(nT.A,{size:9}),a.meta.size]})]}),!n&&p&&(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/45",title:c,children:p})]}),m&&(0,r.Y)(u.A,{size:14,className:`shrink-0 text-ink/35 transition-transform duration-200 ${n?"rotate-180":""}`})]}),n&&m&&(0,r.Y)("div",{className:"border-t border-ink/8 bg-canvas/40 px-3.5 py-2.5",children:a?(0,r.Y)(nj,{task:a}):l?(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px] leading-relaxed text-ink/85",children:(0,r.Y)(eh.T,{content:l.content})}):o.isCode?(0,r.Y)("pre",{className:"max-h-56 overflow-auto font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words text-ink/75 scrollbar-overlay-container scrollbar-overlay-static",dangerouslySetInnerHTML:{__html:(0,eK.wY)(o.rest||o.clean,"javascript")}}):(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px] leading-relaxed text-ink/85",children:(0,r.Y)(eh.T,{content:o.clean||o.rest})})})]})}function nM(e){return!!(e.preview?.startsWith("data:image/")||e.preview?.startsWith("blob:"))||(e.type?.startsWith("image/")??!1)}function nP(e){let{src:t,name:n,onClose:s}=e,[l,o]=(0,i.J0)(!1);return(0,i.vJ)(()=>{let e=e=>{"Escape"===e.key&&s()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s]),(0,a.d5)((0,r.Y)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-ink/80 backdrop-blur-sm",onClick:s,role:"dialog","aria-modal":"true","aria-label":`Preview ${n}`,children:(0,r.FD)("div",{className:"relative max-w-[90vw] max-h-[90vh] flex flex-col items-center",onClick:e=>e.stopPropagation(),children:[(0,r.Y)("button",{type:"button",onClick:s,className:"absolute -top-10 right-0 flex items-center justify-center w-8 h-8 rounded-full bg-paper/10 text-canvas hover:bg-paper/20 transition-colors",title:"Close (Esc)",children:(0,r.Y)(k.A,{size:18})}),(0,r.Y)("img",{src:t,alt:n,onClick:()=>o(e=>!e),title:l?"Zoom out":"Zoom in (click image)",className:`max-w-[90vw] max-h-[85vh] object-contain rounded-md shadow-2xl bg-canvas/5 cursor-zoom-in transition-transform ${l?"scale-150 cursor-zoom-out":"scale-100"}`}),(0,r.Y)("div",{className:"mt-3 max-w-[90vw] truncate text-[11px] font-mono text-canvas/80",children:n})]})}),document.body)}function nE(e){let{attachments:t,className:n="",onOpenFile:s}=e,[a,l]=(0,i.J0)(null);return(0,r.FD)(r.FK,{children:[t.length>0&&(0,r.Y)("div",{className:`flex flex-wrap gap-1.5 pt-2 border-t border-ink/10 ${n}`,children:t.map((e,t)=>(0,r.FD)("button",{type:"button",onClick:()=>{nM(e)&&e.preview?l(e):s?s(e):window.dispatchEvent(new CustomEvent("omp:open-file",{detail:{path:e.name??"attachment"}}))},title:nM(e)?"Preview image":"Open in editor",className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 pr-1.5 text-xs font-sans hover:border-ink/40 hover:bg-ink/5 hover:shadow-sm transition-all cursor-pointer group",children:[e.preview?(0,r.Y)("img",{src:e.preview,alt:"attachment preview",className:"w-5 h-5 rounded-sm object-cover mr-1.5 border border-ink/5 group-hover:scale-105 transition-transform"}):(0,r.Y)("div",{className:"w-5 h-5 flex items-center justify-center bg-ink/5 rounded-sm mr-1.5 text-ink/60",children:(0,r.Y)(er.A,{size:11})}),(0,r.Y)("span",{className:"truncate max-w-[100px] font-mono text-[10px] text-ink/80",children:e.name})]},t))}),a&&a.preview&&(0,r.Y)(nP,{src:a.preview,name:a.name??"image",onClose:()=>l(null)})]})}function nR(e){let t=e.match(/^(\s*)([a-zA-Z\u00C0-\u024F])(.*)$/s);return t?t[1]+t[2].toUpperCase()+t[3]:e}let nI=/<\/?(?:system-reminder|reminder|system-notice|task-result)\b/i,nO=["model","provider","usage","durationMs","startedAt","completedAt","thinking","toolCalls"];function nJ(e){return!("string"!=typeof e?.notice||!e.notice.trim()||nI.test(e.notice))&&nO.some(t=>void 0!==e[t]&&null!==e[t])}function n_(e){return"string"==typeof e?.notice&&!!e.notice.trim()&&!nJ(e)}function nW(e){return nJ(e)?e.notice:"string"==typeof e?.content?e.content:""}let nK=(0,a.ph)(function(e){let{msg:t,isStreaming:n=!1,onUndo:s,onNewChat:a,className:l="",isPrevAssistant:o=!1}=e,c="user"===t.role,d=n_(t),u=d?t.content:nW(t),p=(0,i.Kr)(()=>"string"==typeof u?u.trim():u,[u]),m=(0,i.Kr)(()=>"string"==typeof u?nR(u):u,[u]),h="string"==typeof u&&/[A-Za-z0-9]/.test(u);if(c){let e="agent"===t.attribution;return(0,r.FD)("div",{id:t.id,className:`flex flex-col items-end space-y-1.5 w-full max-w-full ${l}`,children:[(0,r.FD)("div",{className:"bg-paper p-3.5 sm:p-4 rounded-xl border border-ink/15 text-[13px] text-ink shadow-xs max-w-[92%] sm:max-w-[85%] break-words overflow-hidden flex flex-col space-y-2 font-sans select-text mx-3",style:{lineHeight:"var(--markdown-body-line-height)"},children:[e&&(0,r.FD)("div",{className:"flex items-center space-x-1.5 pb-1.5 mb-1 border-b border-ink/10 text-[11px] font-mono text-ink/70",children:[(0,r.Y)(A.A,{size:12,className:"text-ink shrink-0"}),(0,r.Y)("span",{className:"font-semibold text-ink",children:"Subagent Assignment"}),(0,r.Y)("span",{className:"text-[9px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-ink/5 text-ink/60",children:"Delegated"})]}),(0,r.Y)(eh.T,{content:p}),(0,r.Y)(nE,{attachments:t.attachments||[],onOpenFile:e=>{window.dispatchEvent(new CustomEvent("omp:open-file",{detail:{path:e.name??"attachment",content:e.content}}))}})]}),(0,r.FD)("div",{className:"flex items-center space-x-2.5 text-[11px] text-ink/60 px-1 font-mono",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5 border-r border-ink/15 pr-2.5",children:[e?(0,r.FD)(r.FK,{children:[(0,r.Y)(A.A,{size:11,className:"text-ink/70 shrink-0"}),(0,r.Y)("span",{className:"text-[10px] uppercase font-semibold tracking-wider text-ink/60",children:"Agent"})]}):(0,r.Y)(eo.A,{size:11,className:"text-ink/70 shrink-0"}),tF(t)&&(0,r.Y)("span",{children:tF(t)})]}),(0,r.FD)("div",{className:"flex items-center space-x-1",children:[(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"Undo / Edit message",onClick:()=>{s&&s(t.id,t.content)},children:(0,r.Y)(ec.A,{size:12})}),(0,r.Y)(eg,{text:t.content,className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",iconSize:12,title:"Copy prompt"}),(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"New Chat from here",onClick:e=>{e&&e.preventDefault(),a&&a(t.content)},children:(0,r.Y)(ed.A,{size:12})})]})]})]})}let f=t.thinking||(t.monologue?{thought:t.monologue}:void 0),x=t.toolCalls||t.actions,g=t.actions2,b=t.intent?nR(t.intent.replace(/^[.\s]+/,"")):null,v=!!(x&&x.length>0),k=x?.filter(e=>"yield"===e.name||"yield"===e.type).find(e=>"error"!==e.status)?.output,y=b||(k??(x?.length===1?"Tool Execution (1 step)":`Tool Executions (${x?.length} steps)`));return(0,r.Y)("div",{id:t.id,className:`flex flex-col items-start space-y-2 w-full max-w-full transition-all ${n?"pb-10 mb-2":""} ${l}`,children:(0,r.FD)("div",{className:"w-full space-y-2.5 font-sans leading-relaxed",children:[d&&(0,r.Y)(nL,{notice:t.notice}),f&&(0,r.Y)(eb,{thinking:f,defaultExpanded:!1,showSeparator:o}),t.error&&(0,r.FD)("div",{className:"flex items-start space-x-2.5 bg-error/10 border border-error/30 rounded-lg mx-3 px-3.5 py-2.5 text-[12px] text-ink select-text",children:[(0,r.Y)(eu.A,{size:15,className:"text-error flex-shrink-0 mt-0.5"}),(0,r.FD)("div",{className:"min-w-0 flex-1 space-y-0.5",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 flex-wrap",children:[(0,r.Y)("span",{className:"font-semibold text-error text-[12px] tracking-tight",children:t.error.status?`Error ${t.error.status}`:"Request Failed"}),t.error.stopReason&&(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/50 bg-ink/5 px-1.5 py-0.5 rounded",children:t.error.stopReason})]}),t.error.message&&(0,r.FD)("p",{className:"text-ink/80 leading-relaxed text-[12px] font-mono whitespace-pre-wrap break-words",children:[t.error.message.split("\n").map(e=>e.trim()).filter(Boolean)[0],t.error.message.split("\n").map(e=>e.trim()).filter(Boolean).length>1&&(0,r.FD)("span",{className:"relative inline-flex items-center ml-1.5 align-middle group",children:[(0,r.Y)(ep.A,{size:13,className:"text-error/70 hover:text-error cursor-pointer transition-colors"}),(0,r.Y)("span",{className:"pointer-events-none absolute z-50 left-1/2 bottom-full mb-1.5 w-72 -translate-x-1/2 rounded-md bg-ink text-canvas p-2.5 text-[11px] font-mono leading-relaxed whitespace-pre-wrap break-words opacity-0 group-hover:opacity-100 transition-opacity duration-150 shadow-lg",children:t.error.message})]})]})]})]}),h&&(0,r.Y)("div",{className:"text-[13px] text-ink leading-relaxed font-sans bg-transparent px-3 py-1 select-text",children:(0,r.Y)(eh.T,{content:m})}),b&&!v&&(!h||!t.content.toLowerCase().includes(t.intent.toLowerCase().trim()))&&(0,r.Y)("div",{className:`leading-relaxed font-sans px-3 select-text ${h?"text-[12px] text-ink/70 py-0.5":"text-[13px] text-ink py-1"}`,children:b}),v&&(0,r.Y)(nS,{tools:x,title:y,defaultExpanded:!1}),t.systemNote&&(0,r.FD)("div",{className:"text-[12px] text-ink leading-relaxed border-l-2 border-ink/30 bg-paper/60 px-3 py-2 rounded-r-md font-mono break-words whitespace-pre-wrap select-text",children:[(0,r.Y)("span",{className:"text-[10px] text-ink/50 uppercase tracking-wider block mb-0.5 font-sans font-semibold",children:"Diagnostic Note"}),t.systemNote]}),g&&g.length>0&&(0,r.Y)(nS,{tools:g,title:`Follow-up Tools (${g.length})`,defaultExpanded:!0}),!n&&t.summary&&(0,r.FD)("div",{className:"text-[12px] text-ink bg-paper border border-ink/15 rounded-lg p-3 space-y-1 select-text font-sans",children:[(0,r.FD)("div",{className:"font-semibold text-ink flex items-center space-x-1.5 text-[12px]",children:[(0,r.Y)("span",{className:"w-1.5 h-1.5 rounded-full bg-success"}),(0,r.Y)("span",{children:"Resolution Summary"})]}),(0,r.Y)("p",{className:"text-ink/80 leading-relaxed text-[12px]",children:t.summary})]})]})})});var nU=n("Sjr"),nH=n("Sj"),nB=n("sM"),nq=n("kk");function nG(e){if("number"==typeof e?.startedAt&&Number.isFinite(e.startedAt))return e.startedAt;let t=e?.date||e?.timestamp;if(!t)return null;let n=tD(t);if(null!==n)return n;let r=new Date(t).getTime();return Number.isNaN(r)?null:r}function nV(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e.trim())return"";let n=t[e];return n?.trim()?n:e.trim()?e.split(/[-_\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):""}function nZ(e){let{provider:t,providerNames:n,currentModel:s,dateStr:a,durationMs:l,usage:o,content:c,msgId:d,thinkingLevel:u,onRetry:p,onNewChat:m,isMobile:h=!1}=e,[f,x]=(0,i.J0)(!1),g=()=>{x(!1),p?.(d)},b=()=>{x(!1),m?.(c)};(0,i.vJ)(()=>{if(!f)return;let e=e=>{"Escape"===e.key&&x(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[f]);let v=function(e){if(!Number.isFinite(e)||e<1e3)return;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`}(l??0),y=o?.totalTokens??(o?.input??0)+(o?.output??0),N=y>0?`${(0,eX.Rk)(y)??""} tok`:"",w=t?nV(t,n):"",Y=o?.cost?.total&&o.cost.total>0?`$${o.cost.total<.01?o.cost.total.toFixed(4):o.cost.total.toFixed(3)}`:"",D=[];w&&D.push({key:"provider",content:w}),s&&D.push({key:"model",content:s,className:"font-semibold text-ink min-w-0 truncate shrink"}),u&&D.push({key:"thinking",content:(0,r.FD)("span",{className:"text-ink/60 whitespace-nowrap flex items-center space-x-1",title:`Thinking level: ${u}`,children:[(0,r.Y)(z.A,{size:11,className:"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{children:u})]})}),a&&D.push({key:"date",content:a}),v&&D.push({key:"duration",content:(0,r.FD)("span",{className:"text-ink/60 whitespace-nowrap flex items-center space-x-1",title:`Response time: ${v}`,children:[(0,r.Y)(nU.A,{size:11,className:"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{children:v})]})}),N&&D.push({key:"tokens",content:N,className:"hidden sm:inline",title:o?.cost?.total?`${N} (${Y})`:N});let F=[w,s||"Assistant",a||"Just now",N,Y].filter(Boolean).join(" • ");return h?(0,r.FD)(r.FK,{children:[(0,r.FD)("div",{className:"w-full flex items-center gap-2 text-[11px] text-ink/60 px-1 pt-0.5 font-mono min-w-0 animate-in fade-in duration-200",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 min-w-0 truncate",title:F,children:[(0,r.Y)("div",{className:"w-4 h-4 rounded flex items-center justify-center bg-ink text-canvas shadow-2xs shrink-0",children:(0,r.Y)(A.A,{size:10})}),w&&(0,r.Y)("span",{className:"shrink-0 truncate",children:w}),w&&s&&(0,r.Y)("span",{className:"text-ink/35 shrink-0",children:"•"}),s&&(0,r.Y)("span",{className:"font-semibold text-ink min-w-0 truncate",children:s}),s&&u&&(0,r.Y)("span",{className:"text-ink/35 shrink-0",children:"•"}),u&&(0,r.FD)("span",{className:"shrink-0 inline-flex items-center gap-1 text-ink/60",title:`Thinking level: ${u}`,children:[(0,r.Y)(z.A,{size:10,className:"text-ink/50"}),(0,r.Y)("span",{children:u})]})]}),(0,r.Y)("button",{type:"button","aria-label":"More actions","aria-haspopup":"dialog","aria-expanded":f,title:"More actions",onClick:()=>x(!0),className:`ml-auto shrink-0 rounded-md p-2 transition-colors cursor-pointer ${f?"text-ink bg-ink/10":"text-ink/50 hover:bg-ink/5 hover:text-ink"}`,children:(0,r.Y)(nH.A,{size:16})})]}),f&&(0,r.Y)("div",{className:"fixed inset-0 z-[70] flex items-end bg-ink/40 backdrop-blur-[1px] animate-in fade-in duration-150",role:"presentation",onClick:()=>x(!1),children:(0,r.FD)("div",{className:"w-full max-h-[80vh] overflow-y-auto rounded-t-2xl border border-ink/15 bg-paper pb-[max(0.75rem,env(safe-area-inset-bottom,0px))] shadow-2xl animate-in slide-in-from-bottom-4 duration-200",role:"dialog","aria-modal":"true","aria-labelledby":`message-actions-${d}`,onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/10 px-5 py-4",children:[(0,r.Y)("h2",{id:`message-actions-${d}`,className:"text-base font-semibold text-ink",children:"More actions"}),(0,r.Y)("button",{type:"button","aria-label":"Close more actions",title:"Close",onClick:()=>x(!1),className:"rounded-lg p-2 text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink cursor-pointer",children:(0,r.Y)(k.A,{size:20})})]}),(a||v||N)&&(0,r.FD)("div",{className:"flex flex-nowrap items-center gap-3 overflow-hidden whitespace-nowrap border-b border-ink/10 px-5 py-3 text-[11px] text-ink/70",children:[a&&(0,r.FD)("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[(0,r.Y)(nB.A,{size:13,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{className:"truncate",children:a})]}),v&&(0,r.FD)("span",{className:"inline-flex shrink-0 items-center gap-1.5",title:"Response time",children:[(0,r.Y)(nU.A,{size:13,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{children:v})]}),N&&(0,r.FD)("span",{className:"inline-flex shrink-0 items-center gap-1.5",title:Y?`${N} (${Y})`:N,children:[(0,r.Y)(nq.A,{size:13,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{children:N})]})]}),(0,r.FD)("div",{className:"p-2",children:[(0,r.Y)(eg,{text:c,className:"flex min-h-12 w-full items-center gap-3 rounded-lg px-3 text-left text-sm text-ink transition-colors hover:bg-ink/5 cursor-pointer",iconSize:20,iconClassName:"shrink-0 text-ink/55",copiedIconClassName:"shrink-0 text-success",label:"Copy answer",wrapLabel:!0,onClick:()=>x(!1)}),(0,r.FD)("button",{type:"button",onClick:g,className:"flex min-h-12 w-full items-center gap-3 rounded-lg px-3 text-left text-sm text-ink transition-colors hover:bg-ink/5 cursor-pointer",children:[(0,r.Y)(tw.A,{size:20,className:"shrink-0 text-ink/55"}),(0,r.Y)("span",{children:"Retry response"})]}),(0,r.FD)("button",{type:"button",onClick:b,className:"flex min-h-12 w-full items-center gap-3 rounded-lg px-3 text-left text-sm text-ink transition-colors hover:bg-ink/5 cursor-pointer",children:[(0,r.Y)(ed.A,{size:20,className:"shrink-0 text-ink/55"}),(0,r.Y)("span",{children:"Start new chat from this answer"})]})]})]})})]}):(0,r.FD)("div",{className:"w-full flex items-center flex-nowrap space-x-2.5 text-[11px] text-ink/60 px-1 pt-0.5 font-mono min-w-0 animate-in fade-in duration-200",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5 border-r border-ink/15 pr-2.5 min-w-0 shrink overflow-hidden",title:F,children:[(0,r.Y)("div",{className:"w-4 h-4 rounded flex items-center justify-center bg-ink text-canvas shadow-2xs shrink-0",children:(0,r.Y)(A.A,{size:10})}),D.map((e,t)=>{let{key:n,content:i,className:s,title:a}=e;return(0,r.FD)("span",{className:`inline-flex items-center text-ink/60 ${"model"===n?"min-w-0 shrink":"shrink-0"} whitespace-nowrap ${s??""}`,title:a,children:[t>0&&(0,r.Y)("span",{className:"text-ink/40 mr-1.5",children:"•"}),i]},n)})]}),(0,r.FD)("div",{className:"flex items-center space-x-1 shrink-0",children:[(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"Re-run / Retry generation",onClick:g,children:(0,r.Y)(tw.A,{size:12})}),(0,r.Y)(eg,{text:c,className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",iconSize:12,title:"Copy response"}),(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"New Chat from here",onClick:b,children:(0,r.Y)(ed.A,{size:12})})]})]})}function nQ(e){let{msg:t,provider:n,providerNames:i,modelName:s,modelNames:a,thinkingLevel:l,durationMs:o,onRetry:c,onNewChat:d,isMobile:u=!1}=e;return(0,r.Y)("div",{className:"mt-2",children:(0,r.Y)(nZ,{provider:t.provider||n,providerNames:i,currentModel:(t.model?a?.[t.model]??t.model:"")||s||"",thinkingLevel:t.thinkingLevel??l,dateStr:tF(t),durationMs:o??t.durationMs,usage:t.usage,content:nW(t),msgId:t.id,onRetry:c,onNewChat:d,isMobile:u})})}let nX=["Synthesizing solution","Evaluating context","Reading workspace","Planning next step","Executing diagnostics","Compiling edge routes"];function n0(e){let{modelName:t,generatingVerb:n,provider:s,providerNames:a}=e,[l,o]=(0,i.J0)(0);(0,i.vJ)(()=>{if(n)return;let e=setInterval(()=>{o(e=>(e+1)%nX.length)},2800);return()=>clearInterval(e)},[n]);let c=n?n.charAt(0).toUpperCase()+n.slice(1):nX[l],d=s?nV(s,a):"";return(0,r.FD)("div",{id:"generating-docked-indicator",className:"w-full flex items-center px-1 py-1 bg-transparent border-0 border-none text-[11px] font-mono select-none animate-in fade-in duration-200",children:[(0,r.Y)("style",{children:`
10
+ ${r}`}function ti(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e3;if(!e)return{text:"",skipped:0};let n=e.split(/\r?\n/);return n.length<=t?{text:e,skipped:0}:{text:n.slice(n.length-t).join("\n"),skipped:n.length-t}}function ts(e){let{text:t}=e,n=(0,i.Kr)(()=>eL(t),[t]),s=(0,i.Kr)(()=>tn(n),[n]),a=(0,i.Kr)(()=>ti(s.content,1e3),[s]),l=(0,i.Kr)(()=>tr(a.text,s.format),[a,s.format]),o=(0,i.Kr)(()=>s.content.split(/\r?\n/).length,[s.content]);return(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:[(0,r.Y)(e8.A,{size:11,className:"text-ink/40"}),(0,r.Y)("span",{children:"Output"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/45",children:s.format}),o>1&&(0,r.FD)("span",{className:"font-mono text-[9px] text-ink/35",children:[o," lines"]})]}),(0,r.Y)(eg,{text:s.content,className:"flex cursor-pointer items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",onClick:e=>e.stopPropagation(),label:"Copy"})]}),s.envelope&&(0,r.Y)(te,{envelope:s.envelope}),a.skipped>0&&(0,r.FD)("div",{className:"font-mono text-[10px] text-ink/45",children:["… ",a.skipped," earlier lines hidden"]}),(0,r.Y)("div",{className:"max-h-72 overflow-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 select-text",children:(0,r.Y)(eh.T,{content:l,className:"text-[12px] text-ink/85"})})]})}function ta(e){let{tool:t}=e,{groups:n,totalDone:s,totalInProgress:a,totalPending:l,totalTasks:o,opBadge:c}=(0,i.Kr)(()=>e3(t),[t]);if(0===n.length&&!c){let e=t.output||"";return e.trim()?(0,r.Y)(ts,{text:e}):null}let d=o>0?Math.round(s/o*100):0;return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3",children:[(0,r.FD)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eN.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"text-[11px] font-semibold text-ink",children:"Todo"}),c&&(0,r.Y)("span",{className:"rounded bg-success/10 px-2 py-0.5 font-mono text-[9.5px] font-medium text-success",children:c})]}),o>0&&(0,r.FD)("div",{className:"flex items-center gap-2 font-mono text-[10.5px]",children:[(0,r.FD)("span",{className:"text-ink/50",children:[s," of ",o," completed"]}),(0,r.FD)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-semibold text-ink",children:[d,"%"]})]})]}),o>0&&(s>0||a>0||l>0)&&(0,r.FD)("div",{className:"mt-2.5 flex flex-wrap items-center gap-1.5 font-mono text-[10px]",children:[s>0&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded bg-success/10 px-2 py-0.5 text-success",children:[(0,r.Y)(eB.A,{size:11}),(0,r.FD)("span",{children:[s," complete"]})]}),a>0&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded bg-ink/8 px-2 py-0.5 text-ink/70",children:[(0,r.Y)(e_.A,{size:11,className:"animate-spin"}),(0,r.FD)("span",{children:[a," in progress"]})]}),l>0&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded bg-ink/5 px-2 py-0.5 text-ink/50",children:[(0,r.Y)(h.A,{size:11}),(0,r.FD)("span",{children:[l," pending"]})]})]}),o>0&&(0,r.Y)("div",{className:"mt-2 h-1.5 overflow-hidden rounded-full bg-ink/8",children:(0,r.Y)("div",{className:"h-full rounded-full bg-success transition-all duration-300",style:{width:`${d}%`}})})]}),(0,r.Y)("div",{className:"space-y-2",children:n.map((e,t)=>(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.Y)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/50",children:e.phase}),(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:[e.tasks.filter(e=>"done"===e.status).length,"/",e.tasks.length]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/[0.04] p-1",children:e.tasks.map((e,t)=>{let n="done"===e.status,i="in_progress"===e.status;return(0,r.FD)("div",{className:`flex items-start gap-2.5 px-2.5 py-1.5 text-[11.5px] transition-colors ${i?"bg-ink/[0.03]":""}`,children:[n?(0,r.Y)(eB.A,{size:13,className:"mt-0.5 shrink-0 text-success"}):i?(0,r.Y)(e_.A,{size:13,className:"mt-0.5 shrink-0 animate-spin text-ink"}):(0,r.Y)(h.A,{size:13,className:"mt-0.5 shrink-0 text-ink/25"}),(0,r.Y)("span",{className:`min-w-0 flex-1 leading-snug ${n?"text-ink/40 line-through":i?"font-medium text-ink":"text-ink/80"}`,children:e.text}),i&&(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/8 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/70",children:"In Progress"})]},t)})})]},t))})]})}var tl=n("E6");function to(e){if(e&&"object"==typeof e&&"string"==typeof e.path)return e.path}function tc(e){let t="string"==typeof e.severity?e.severity.toLowerCase():"";return"error"===t||"1"===t?"error":"warning"===t||"2"===t?"warning":"info"}let td={error:{Icon:eu.A,color:"text-error",text:"text-error",badge:"bg-error/10 text-error"},warning:{Icon:tl.A,color:"text-warning",text:"text-warning",badge:"bg-warning/10 text-warning"},info:{Icon:ep.A,color:"text-ink/40",text:"text-ink/70",badge:"bg-ink/5 text-ink/50"}};function tu(e){let{tool:t}=e,n=t.details??{},s=t.output??"",a=n.xdev?.args?.action==="capabilities"||"capabilities"===function(e){if(e&&"object"==typeof e&&"string"==typeof e.action)return e.action}(t.input)||s.includes("capabilities:"),l=(0,i.Kr)(()=>a?function(e){if(!e||!e.includes("capabilities:"))return[];let t=[];for(let n of e.split(/^(?=[A-Za-z0-9_-]+:)/m)){let e=n.trim();if(!e)continue;let r=e.match(/^([A-Za-z0-9_-]+):\s*capabilities:\s*(\{[\s\S]*\})/m);if(r){let e=r[1];try{let n=JSON.parse(r[2]);t.push({name:e,capabilities:n})}catch{t.push({name:e,capabilities:{}})}}}return t}(s):[],[a,s]),o=(0,i.Kr)(()=>a?[]:Array.isArray(n.diagnostics)?n.diagnostics:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.diagnostics))return t.diagnostics;if(Array.isArray(t.errors))return t.errors}}catch{}let t=e.split(/\r?\n/).filter(Boolean),n=[],r=[],i="";for(let e of t){let t=e.trim();if(/^\d+\s+(?:error|warning|hint|info)\(s\):/i.test(t))continue;let s=t.match(/^(#{1,6})\s+(.+)$/);if(s){let e=s[1].length,t=s[2].trim();if(r.length=Math.min(r.length,e-1),t.endsWith("/"))r[e-1]=t;else{let e=r.filter(Boolean).join("");i=e?`${e.replace(/\/+$/,"")}/${t}`:t}continue}let a=e.match(/^\s*(\d+):(\d+)\s+\[(error|warning|info|hint)\]\s*(?:\[([^\]]+)\])?\s*(.*?)(?:\s*\((\d+|TS\d+)\))?$/i);if(a){n.push({file:i||void 0,line:parseInt(a[1],10),column:parseInt(a[2],10),severity:"hint"===a[3].toLowerCase()?"info":a[3].toLowerCase(),source:a[4]||void 0,message:a[5].trim(),code:a[6]||void 0});continue}let l=e.match(/^([^:\n]+):(\d+)(?::(\d+))?\s*[-:]?\s*(error|warning|info|hint)?\s*(?:(TS\d+|[A-Za-z0-9_-]+):)?\s*(.*)$/i);l&&n.push({file:l[1].trim(),line:parseInt(l[2],10),column:l[3]?parseInt(l[3],10):void 0,severity:l[4]?"hint"===l[4].toLowerCase()?"info":l[4].toLowerCase():"error",code:l[5]||void 0,message:l[6]?.trim()||e})}return n}(s),[n.diagnostics,a,s]);if(a&&l.length>0)return(0,r.Y)("div",{className:"space-y-2 select-text",children:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eF.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[10.5px] font-semibold text-ink",children:"Language Servers"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"Capabilities"})]}),(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/40",children:[l.length," active"]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/30",children:l.map((e,t)=>{let n=Object.entries(e.capabilities).filter(e=>{let[,t]=e;return!!t}).map(e=>{let[t]=e;return t.replace(/Provider$/,"")});return(0,r.FD)("div",{className:"p-3 text-[11px]",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eD.A,{size:12,className:"text-ink/50"}),(0,r.Y)("span",{className:"font-mono font-medium text-ink",children:e.name}),(0,r.FD)("span",{className:"ml-auto inline-flex items-center gap-1 font-mono text-[9.5px] text-success",children:[(0,r.Y)(eB.A,{size:10}),"Connected"]})]}),n.length>0&&(0,r.Y)("div",{className:"mt-2 flex flex-wrap gap-1",children:n.map((e,t)=>(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] text-ink/60",children:e},t))})]},t)})})]})});if(0===o.length)return s?(0,r.Y)(ts,{text:s}):null;let c=e=>o.filter(t=>tc(t)===e),d=c("error").length,u=c("warning").length,p=c("info").length;return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 select-text",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Diagnostics"}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-2 font-mono text-[10px]",children:[d>0&&(0,r.FD)("span",{className:"flex items-center gap-1 text-error",children:[(0,r.Y)(eu.A,{size:9}),d]}),u>0&&(0,r.FD)("span",{className:"flex items-center gap-1 text-warning",children:[(0,r.Y)(tl.A,{size:9}),u]}),p>0&&(0,r.FD)("span",{className:"flex items-center gap-1 text-ink/50",children:[(0,r.Y)(ep.A,{size:9}),p]})]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1 max-h-72 overflow-auto",children:o.map((e,t)=>{let n,i,s,a=td[tc(e)],l=(n="string"==typeof e.file?e.file:"string"==typeof e.path?e.path:"",i="number"==typeof e.line?e.line:void 0,s="number"==typeof e.column?e.column:void 0,n?void 0===i?n:void 0===s?`${n}:${i}`:`${n}:${i}:${s}`:""),o="string"==typeof e.message?e.message:"",c="string"==typeof e.code?e.code:void 0,d="string"==typeof e.source?e.source:void 0,{Icon:u,color:p,text:m}=a;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)("span",{className:"flex h-5 w-3.5 shrink-0 items-center justify-center",children:(0,r.Y)(u,{size:12,className:p})}),(0,r.FD)("span",{className:"min-w-0 flex-1 break-words leading-5",children:[l&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/45 mr-1",children:[l,":"]}),(0,r.Y)("span",{className:m,children:o}),d&&(0,r.FD)("span",{className:"ml-1.5 font-mono text-[9px] text-ink/35",children:["[",d,"]"]}),c&&(0,r.FD)("span",{className:"ml-1 font-mono text-[9px] text-ink/35",children:["(",c,")"]})]})]},t)})})]})}var tp=n("q");function tm(e){return"string"==typeof e.url?e.url:"string"==typeof e.link?e.link:""}function th(e){return"string"==typeof e.snippet&&e.snippet?e.snippet:"string"==typeof e.description?e.description:""}function tf(e){let{tool:t}=e,n=t.details??{},i="string"==typeof n.response?.provider?n.response.provider:"string"==typeof n.provider?n.provider:void 0,s=Array.isArray(n.results)?n.results:Array.isArray(n.sources)?n.sources:Array.isArray(n.response?.sources)?n.response.sources:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.results))return t.results;if(Array.isArray(t.sources))return t.sources;if(Array.isArray(t.organic))return t.organic;if(Array.isArray(t.items))return t.items;if(t.response&&Array.isArray(t.response.sources))return t.response.sources}}catch{}return[]}(t.output??"");return 0===s.length?t.output?(0,r.Y)(ts,{text:t.output}):null:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:[i&&(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-paper px-2.5 py-1 text-[9.5px]",children:[(0,r.Y)("span",{className:"font-semibold uppercase tracking-wider text-ink/40",children:"Sources"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-ink/50 uppercase",children:i})]}),(0,r.Y)("ol",{className:"divide-y divide-ink/6",children:s.map((e,t)=>{let n=tm(e),i="string"==typeof e.publishedDate?e.publishedDate:void 0;return(0,r.FD)("li",{className:"px-2.5 py-2 text-[11.5px]",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"flex h-4 w-4 shrink-0 items-center justify-center rounded bg-ink/5 font-mono text-[9px] text-ink/45",children:t+1}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-medium text-ink",children:"string"==typeof e.title&&e.title?e.title:tm(e)||"Result"}),n&&(0,r.Y)("a",{href:n,target:"_blank",rel:"noopener noreferrer",className:"flex shrink-0 items-center rounded-md p-0.5 text-ink/40 transition-colors hover:bg-ink/5 hover:text-ink",title:n,children:(0,r.Y)(tp.A,{size:10})})]}),(0,r.FD)("div",{className:"flex items-center gap-2 pl-[22px] font-mono text-[9.5px] text-ink/40",children:[n&&(0,r.Y)("span",{className:"truncate",children:n}),i&&(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1 py-0.2 text-[8.5px] text-ink/50",children:i})]}),th(e)&&(0,r.Y)("div",{className:"mt-0.5 pl-[22px] leading-snug text-ink/65",children:th(e)})]},t)})})]})}var tx=n("o"),tg=n("sJ");function tb(e){let{tool:t}=e,n=t.input,s="object"==typeof n&&null!==n?n:void 0,a="string"==typeof s?.code?s.code:"string"==typeof n?n:"",l=("string"==typeof s?.language?s.language:"js").toUpperCase(),o="number"==typeof s?.timeout?`${s.timeout}s`:void 0,c="string"==typeof s?.title?s.title:void 0,d=t.output||(t.error?`Error: ${t.error}`:""),u="error"===t.status||d.includes("ToolError:")||d.includes("Command exited with code"),p=d.includes("Command aborted")||"aborted"===t.status,m=(0,eU.w)(),h=(0,i.Kr)(()=>u||p?{isValid:!1}:(0,eK.Bl)(d),[d,u,p]),f=(0,i.Kr)(()=>ti(a,1e3),[a]),x=(0,i.Kr)(()=>(0,eK.wY)(f.text,"javascript"),[f,m]),g=(0,i.Kr)(()=>ti(d,1e3),[d]),b=(0,i.Kr)(()=>h.isValid&&h.pretty?ti(h.pretty,1e3):null,[h]),v=(0,i.Kr)(()=>b?(0,eK.PH)(b.text):"",[b,m]);return(0,r.FD)("div",{className:"space-y-2",children:[a&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eY.A,{size:12,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[10.5px] font-semibold text-ink",children:c||"Script Evaluation"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:l}),o&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9.5px] text-ink/40",children:[(0,r.Y)(tx.A,{size:10}),(0,r.Y)("span",{children:o})]})]}),(0,r.Y)(eg,{text:a,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),f.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",f.skipped," earlier lines hidden"]}),(0,r.FD)("div",{className:"flex max-h-56 items-start overflow-x-auto font-mono text-[11px] leading-relaxed select-text",children:[(0,r.Y)("div",{className:"sticky left-0 flex-shrink-0 select-none border-r border-ink/6 bg-canvas/50 py-2.5 pl-2.5 pr-2 text-right text-[10px] text-ink/25",children:f.text.split("\n").map((e,t)=>(0,r.Y)("div",{children:t+1},t))}),(0,r.Y)("pre",{className:"flex-1 overflow-x-auto p-2.5 whitespace-pre text-ink/85 font-mono",dangerouslySetInnerHTML:{__html:x}})]})]}),d&&(0,r.FD)("div",{className:`overflow-hidden rounded-lg border ${u?"border-error/25 bg-error/[0.03]":p?"border-warning/25 bg-warning/[0.03]":"border-ink/8 bg-paper"}`,children:[(0,r.FD)("div",{className:`flex items-center justify-between border-b px-3 py-1.5 ${u?"border-error/15 bg-error/[0.06]":p?"border-warning/15 bg-warning/[0.06]":"border-ink/6 bg-canvas/30"}`,children:[(0,r.Y)("div",{className:"flex items-center gap-1.5",children:u?(0,r.FD)(r.FK,{children:[(0,r.Y)(eu.A,{size:11,className:"text-error"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-error",children:"Execution Error"})]}):p?(0,r.FD)(r.FK,{children:[(0,r.Y)(eG.A,{size:11,className:"text-warning"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-warning",children:"Evaluation Aborted"})]}):(0,r.FD)(r.FK,{children:[(0,r.Y)(tg.A,{size:11,className:"text-success"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/50",children:"Evaluation Result"}),h.isValid&&(0,r.FD)(r.FK,{children:[(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"JSON"}),h.linesCount&&h.linesCount>1&&(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:[h.linesCount," lines"]})]})]})}),(0,r.Y)(eg,{text:h.isValid&&h.pretty?h.pretty:d,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),h.isValid&&h.pretty?(0,r.FD)(r.FK,{children:[b&&b.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",b.skipped," earlier lines hidden"]}),(0,r.FD)("div",{className:"flex max-h-56 items-start overflow-x-auto font-mono text-[11px] leading-relaxed select-text",children:[(0,r.Y)("div",{className:"sticky left-0 flex-shrink-0 select-none border-r border-ink/6 bg-canvas/50 py-2 pl-2.5 pr-2 text-right text-[10px] text-ink/25",children:(b?b.text:h.pretty).split("\n").map((e,t)=>(0,r.Y)("div",{children:t+1},t))}),(0,r.Y)("pre",{className:"flex-1 overflow-x-auto p-2.5 whitespace-pre text-ink/85 font-mono",dangerouslySetInnerHTML:{__html:v}})]})]}):(0,r.FD)(r.FK,{children:[g.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",g.skipped," earlier lines hidden"]}),(0,r.Y)("pre",{className:`max-h-48 overflow-y-auto p-3 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words select-text ${u?"text-error":p?"text-warning":"text-ink/80"}`,children:g.text})]})]})]})}var tv=n("DB"),tk=n("vZ");let ty={open:"bg-success/10 text-success",merged:"bg-ink/10 text-ink/60",closed:"bg-error/10 text-error"};function tw(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.items))return t.items;if(Array.isArray(t.pullRequests))return t.pullRequests;if(Array.isArray(t.issues))return t.issues}}catch{}return[]}(t.output??"");return 0===i.length?t.output?(0,r.Y)(ts,{text:t.output}):null:(0,r.Y)("ul",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:i.map((e,t)=>{let n=!0===e.merged||"merged"===e.state?"merged":"closed"===e.state?"closed":"open",i="string"==typeof e.title?e.title:"",s="number"==typeof e.number?`#${e.number}`:"",a="string"==typeof e.author?e.author:"",l="number"==typeof e.additions?e.additions:void 0,o="number"==typeof e.deletions?e.deletions:void 0;return(0,r.FD)("li",{className:"px-2.5 py-2 text-[11.5px]",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:["merged"===n?(0,r.Y)(tv.A,{size:12,className:"shrink-0 text-success"}):"closed"===n?(0,r.Y)(eT.A,{size:12,className:"shrink-0 text-error"}):(0,r.Y)(tk.A,{size:12,className:"shrink-0 text-success"}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-medium text-ink",children:i}),s&&(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] text-ink/45",children:s})]}),(0,r.FD)("div",{className:"mt-1 flex items-center gap-1.5 pl-[18px] text-[10px] text-ink/50",children:[(0,r.Y)("span",{className:`rounded-full px-1.5 py-px font-mono ${ty[n]}`,children:n}),a&&(0,r.Y)("span",{children:a}),(void 0!==l||void 0!==o)&&(0,r.FD)("span",{className:"ml-auto font-mono",children:[void 0!==l&&(0,r.FD)("span",{className:"text-success",children:["+",l]}),void 0!==o&&(0,r.FD)("span",{className:"ml-1 text-error",children:["-",o]})]})]})]},t)})})}var tN=n("Ir");function tY(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return new Date(e).toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit"})}function tD(e){if(!e.startsWith("Today,"))return null;let t=e.slice(6).trim(),n=new Date(`${new Date().toDateString()} ${t}`);return Number.isNaN(n.getTime())?null:n.getTime()}function tF(e){let t=e?.timestamp||e?.date;if(!t)return"";if(t.startsWith("Today,"))return`Today, ${t.slice(6).trim()}`;if(/^\d{1,2}:\d{2}\s*(AM|PM)$/i.test(t)){let e=tD(`Today, ${t}`);if(null!==e)return`Today, ${tY(e)}`}let n=new Date(t);if(Number.isNaN(n.getTime()))return"";let r=n.toLocaleDateString("en-US",{month:"short",day:"numeric"});return`${r}, ${tY(n)}`}function tA(e){let{tool:t}=e,n=t.details??{},i=n&&"object"==typeof n?n:{},s="rewind"===t.type,a="string"==typeof i.id?i.id:void 0,l=function(e){if("number"==typeof e){let t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleTimeString()}return"string"==typeof e?e:""}(i.timestamp),o="number"==typeof i.fileCount?i.fileCount:void 0,c="string"==typeof i.branch?i.branch:void 0,d="string"==typeof i.message?i.message:"string"==typeof i.description?i.description:"";return a||l||o||c||d?(0,r.FD)("div",{className:"flex items-start gap-2.5 rounded-lg border border-ink/8 bg-canvas/40 px-3 py-2.5",children:[(0,r.Y)("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-ink/5 text-ink/60",children:s?(0,r.Y)(tN.A,{size:12}):(0,r.Y)(eC.A,{size:12})}),(0,r.FD)("div",{className:"min-w-0 flex-1 space-y-0.5",children:[d&&(0,r.Y)("div",{className:"text-[11.5px] text-ink/85",children:d}),(0,r.FD)("div",{className:"flex flex-wrap gap-x-2 gap-y-0.5 font-mono text-[9.5px] text-ink/45",children:[a&&(0,r.Y)("span",{children:a}),l&&(0,r.Y)("span",{children:l}),void 0!==o&&(0,r.FD)("span",{children:[o," files"]}),c&&(0,r.Y)("span",{children:c})]})]})]}):t.output?.trim()?(0,r.Y)(ts,{text:t.output}):null}function tS(e){var t;let n,{tool:s}=e,a=s.details??{},l="object"==typeof s.input&&null!==s.input?s.input:void 0,o=s.command||("string"==typeof l?.command?l.command:void 0)||("string"==typeof l?.cmd?l.cmd:void 0)||("string"==typeof l?.CommandLine?l.CommandLine:void 0)||("string"==typeof l?.commandLine?l.commandLine:void 0)||("string"==typeof s.input?s.input:""),{cleanText:c,wallTime:d}=(n=(t=s.output||(s.error?`Error: ${s.error}`:"")).match(/\n*Wall time:\s*([^\n\r]+)$/))?{cleanText:t.replace(/\n*Wall time:\s*[^\n\r]+$/,""),wallTime:n[1].trim()}:{cleanText:t},u="number"==typeof a.exitCode?a.exitCode:s.isError?1:void 0,m=("string"==typeof a.cwd?a.cwd:void 0)||("string"==typeof l?.cwd?l.cwd:void 0)||("string"==typeof l?.Cwd?l.Cwd:void 0),h="number"==typeof a.durationMs?a.durationMs:s.durationMs,f=s.duration||d||(h?`${h}ms`:void 0),x=!c||"(no output)"===c,g=(0,i.Kr)(()=>x||s.isError?{isValid:!1}:(0,eK.Bl)(c),[c,x,s.isError]),b=(0,i.Kr)(()=>eL(c),[c]),v=(0,i.Kr)(()=>ti(b,1e3),[b]),k=(0,i.Kr)(()=>g.isValid&&g.pretty?g.pretty:b,[g,b]),y=(0,i.Kr)(()=>(0,eK.rw)(b),[b]),w=(0,i.Kr)(()=>b.trim().startsWith("{")||b.trim().startsWith("[")?"json":"javascript",[b]),N=(0,i.Kr)(()=>g.isValid&&g.pretty?ti(g.pretty,1e3):null,[g]),Y=(0,eU.w)(),D=(0,i.Kr)(()=>o?(0,eK.wY)(o,"bash"):"",[o,Y]),F=(0,i.Kr)(()=>y?(0,eK.wY)(v.text,w):"",[y,v,w,Y]);return(0,r.FD)("div",{className:"space-y-2",children:[o&&(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/60 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.FD)("div",{className:"flex items-center gap-1",children:[(0,r.Y)("span",{className:"h-2 w-2 rounded-full bg-ink/20"}),(0,r.Y)("span",{className:"h-2 w-2 rounded-full bg-ink/20"}),(0,r.Y)("span",{className:"h-2 w-2 rounded-full bg-ink/20"})]}),(0,r.Y)("span",{className:"font-mono text-[10px] font-semibold text-ink/50",children:"bash"}),m&&(0,r.Y)("span",{className:"truncate font-mono text-[9.5px] text-ink/40",title:m,children:m})]}),(0,r.FD)("div",{className:"flex items-center gap-2",children:[void 0!==u&&(0,r.FD)("span",{className:`rounded-full px-1.5 py-0.2 font-mono text-[9px] font-semibold ${0===u?"bg-success/10 text-success":"bg-error/10 text-error"}`,children:["exit ",u]}),f&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9.5px] text-ink/45",children:[(0,r.Y)(tx.A,{size:10}),(0,r.Y)("span",{children:f})]}),(0,r.Y)(eg,{text:o,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",title:"Copy command",label:"Copy"})]})]}),(0,r.FD)("div",{className:"flex items-start gap-2.5 px-3 py-2 font-mono text-[11.5px] leading-relaxed",children:[(0,r.Y)("span",{className:"select-none font-bold text-ink/40",children:"$"}),(0,r.Y)("pre",{className:"min-w-0 flex-1 overflow-x-auto whitespace-pre-wrap break-all text-ink/90 select-text",dangerouslySetInnerHTML:{__html:D}})]})]}),x?(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-dashed border-ink/15 bg-canvas/30 px-3 py-2 font-mono text-[11px] text-ink/50",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(p.A,{size:12,className:"text-success"}),(0,r.Y)("span",{children:"Command executed successfully with no output"})]}),f&&(0,r.FD)("span",{className:"text-[10px] text-ink/40",children:["Wall time: ",f]})]}):g.isValid&&g.pretty?(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/30 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Console Output"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"JSON"}),g.linesCount&&g.linesCount>1&&(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:[g.linesCount," lines"]})]}),(0,r.Y)(eg,{text:g.isValid&&g.pretty?g.pretty:c,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),N&&N.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",N.skipped," earlier lines hidden"]}),(0,r.Y)(eQ,{jsonString:N?N.text:g.pretty,maxHeightClass:"max-h-72",showHeader:!1})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/30 px-3 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Console Output"}),(0,r.Y)(eg,{text:k,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),v.skipped>0&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-canvas/40 px-3 py-1 font-mono text-[9.5px] text-ink/45",children:["… ",v.skipped," earlier lines hidden"]}),(0,r.Y)("div",{className:"max-h-72 overflow-y-auto overscroll-contain p-3 font-mono text-[11px] leading-relaxed select-text",children:y?(0,r.Y)("pre",{className:"overflow-x-auto whitespace-pre text-ink/85 leading-relaxed",dangerouslySetInnerHTML:{__html:F}}):v.text.split("\n").map((e,t)=>{let n=e.includes("✓")||e.includes("built in")||e.includes("ready: 0 errors"),i=e.includes("Error:")||e.includes("error:")||e.includes("FAILED"),s=e.includes("warning:")||e.includes("warn:");return(0,r.Y)("div",{className:`whitespace-pre-wrap break-words ${n?"text-success font-medium":i?"text-error font-medium":s?"text-warning font-medium":"text-ink/80"}`,children:e||" "},t)})})]})]})}var tC=n("W0"),tT=n("jx"),tz=n("Nf");function t$(e){let{tool:t}=e,[n,s]=(0,i.J0)(""),a=t.details??{},l=t.output||("string"==typeof a.displayContent?a.displayContent:""),o=function(e){let t=e.input;if(t&&"object"==typeof t){if("string"==typeof t.pattern)return t.pattern;if("string"==typeof t.path)return t.path;if("string"==typeof t.glob)return t.glob;if("string"==typeof t.query)return t.query;if("string"==typeof t.regex)return t.regex;if("string"==typeof t.search)return t.search;if("string"==typeof t.text)return t.text}return"string"==typeof e.target&&"."!==e.target?e.target:""}(t),c="glob"===t.type||"glob"===t.name,d=(0,i.Kr)(()=>ti(l,1e3),[l]),{files:u,totalMatches:p,isGlobList:m}=(0,i.Kr)(()=>(function(e){let t=e.split(/\r?\n/),n=[],r=[],i=null,s=!0;for(let e of t){let t=e.trimEnd();if(!t||t.startsWith("[")&&t.endsWith("]")||/^Showing files \d+/i.test(t)||/^Found \d+ matches/i.test(t))continue;let a=t.match(/^([^:\n]+(?:\.[a-zA-Z0-9_-]+|\/[^:\n]+)):(\d+)(?::\d+)?:(.*)$/);if(a){s=!1;let e=a[1].trim(),t=parseInt(a[2],10)||1,r=a[3],l=n.find(t=>t.path===e);l||(i&&i.lines.length>0&&!n.includes(i)&&n.push(i),l={path:e,lines:[],matchCount:0},n.push(l),i=l),l.lines.push({lineNum:t,text:r,isMatch:!0}),l.matchCount++;continue}let l=t.match(/^([^:\n]+(?:\.[a-zA-Z0-9_-]+|\/[^:\n]+))-(\d+)-(.*)$/);if(l){s=!1;let e=l[1].trim(),t=parseInt(l[2],10)||1,r=l[3],a=n.find(t=>t.path===e);a||(i&&i.lines.length>0&&!n.includes(i)&&n.push(i),a={path:e,lines:[],matchCount:0},n.push(a),i=a),a.lines.push({lineNum:t,text:r,isMatch:!1});continue}let o=t.match(/^(#{1,6})\s+(.+)$/);if(o){let e=o[1].length,t=o[2].trim();if(r.length=Math.min(r.length,e-1),t.endsWith("/"))r[e-1]=t;else{i&&i.lines.length>0&&!n.includes(i)&&n.push(i);let e=r.filter(Boolean).join("");i={path:e?`${e.replace(/\/+$/,"")}/${t}`:t,lines:[],matchCount:0}}continue}let c=t.match(/^(\*?)(\s*\d+)[|:\u2502](.*)$/);if(c){s=!1;let e="*"===c[1],t=parseInt(c[2].trim(),10)||1,r=c[3];i||(i={path:"Results",lines:[],matchCount:0},n.push(i)),i.lines.push({lineNum:t,text:r,isMatch:e}),e&&i.matchCount++;continue}if(!t.startsWith("#")&&!c){(t.includes("|")||t.includes(":")||t.includes("│"))&&(s=!1);let e=r.filter(Boolean).join(""),i=e?`${e.replace(/\/+$/,"")}/${t}`:t;n.push({path:i,lines:[],matchCount:1})}}i&&i.lines.length>0&&!n.includes(i)&&n.push(i);let a=n.reduce((e,t)=>e+(t.matchCount||t.lines.length||1),0);return{files:n,totalMatches:a,isGlobList:s}})(d.text),[d.text]),h=(0,i.Kr)(()=>{if(!n)return u;let e=n.toLowerCase();return u.map(t=>{let n=t.path.toLowerCase().includes(e),r=t.lines.filter(t=>t.text.toLowerCase().includes(e));return n?t:r.length>0?{...t,lines:r}:null}).filter(e=>null!==e)},[u,n]),f=(0,eU.w)(),x=(0,i.Kr)(()=>h.map(e=>{let t=(0,eK.sQ)(e.path);return(0,eK.O9)(e.lines.map(e=>e.text).join("\n"),t)}),[h,f]);return l||0!==u.length?(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex flex-wrap items-center gap-2 text-[11px]",children:[(0,r.Y)("span",{className:"flex h-5 w-5 items-center justify-center rounded bg-ink/5 text-ink/60",children:c||m?(0,r.Y)(tC.A,{size:12}):(0,r.Y)(tT.A,{size:12})}),(0,r.Y)("span",{className:"font-semibold text-ink",children:c||m?"Files Found":"Search Matches"}),(0,r.FD)("span",{className:"rounded-full bg-ink/5 px-2 py-0.5 font-mono text-[10px] text-ink/60",children:[p," ",1===p?"match":"matches"]}),u.length>1&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/40",children:["in ",u.length," ",1===u.length?"file":"files"]}),o&&(0,r.FD)("span",{className:"rounded border border-ink/10 bg-canvas px-1.5 py-0.5 font-mono text-[10px] text-ink/75",children:['"',o,'"']})]}),(0,r.FD)("div",{className:"flex items-center gap-2",children:[u.length>4&&(0,r.Y)("input",{type:"text",placeholder:"Filter paths...",value:n,onChange:e=>s(e.currentTarget.value),className:"h-6 w-28 rounded border border-ink/10 bg-canvas px-2 text-[10.5px] text-ink placeholder:text-ink/30 focus:border-ink/30 focus:outline-none"}),(0,r.Y)(eg,{text:l,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]})]}),d.skipped>0&&(0,r.FD)("div",{className:"rounded-lg border border-dashed border-ink/15 bg-canvas/50 px-3 py-1.5 font-mono text-[10.5px] text-ink/55",children:["… ",d.skipped," earlier lines hidden"]}),(0,r.FD)("div",{className:"max-h-80 space-y-2 overflow-y-auto overscroll-contain pr-0.5",children:[h.map((e,t)=>(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-2.5 py-1.5",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-1.5",children:[(0,r.Y)(ew.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"truncate font-mono text-[11px] font-medium text-ink/85",children:e.path})]}),e.matchCount>0&&!m&&(0,r.FD)("span",{className:"ml-2 shrink-0 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9.5px] text-ink/50",children:[e.matchCount," ",1===e.matchCount?"hit":"hits"]})]}),e.lines.length>0&&(0,r.Y)("div",{className:"overflow-x-auto overscroll-x-contain",children:(0,r.Y)("div",{className:"w-max min-w-full divide-y divide-ink/[0.04] font-mono text-[11px] leading-relaxed select-text",children:e.lines.map((e,n)=>(0,r.FD)("div",{className:`flex items-start gap-2.5 px-2.5 py-1 transition-colors ${e.isMatch?"bg-warning/[0.08] text-ink":"bg-paper text-ink/60 hover:bg-ink/[0.02]"}`,children:[(0,r.FD)("span",{className:`sticky left-0 z-10 flex w-9 shrink-0 select-none items-center justify-end bg-inherit font-mono text-[10px] ${e.isMatch?"font-semibold text-warning-dark dark:text-warning":"text-ink/30"}`,children:[e.isMatch&&(0,r.Y)(tz.A,{size:10,className:"mr-0.5 text-warning"}),e.lineNum]}),(0,r.Y)("pre",{className:"shiki whitespace-pre font-mono",dangerouslySetInnerHTML:{__html:x[t]?.[n]||"&nbsp;"}})]},n))})})]},t)),0===h.length&&(0,r.FD)("div",{className:"rounded-lg border border-dashed border-ink/15 p-4 text-center font-mono text-[11px] text-ink/40",children:['No results match filter "',n,'"']})]})]}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[c?(0,r.Y)(tC.A,{size:13,className:"shrink-0"}):(0,r.Y)(tT.A,{size:13,className:"shrink-0"}),(0,r.FD)("span",{children:["No ",c?"files":"matches"," found",o?` for "${o}"`:""]})]})}var tj=n("B5"),tL=n("gk");function tM(e){let t="string"==typeof e.severity?e.severity.toLowerCase():"";return"high"===t||"critical"===t||"error"===t?"high":"medium"===t||"warning"===t?"medium":"low"===t?"low":"info"}let tP={high:"bg-error/10 text-error",medium:"bg-warning/10 text-warning",low:"bg-ink/8 text-ink/60",info:"bg-ink/5 text-ink/50"};function tE(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.findings)?n.findings:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.findings))return t.findings;if(Array.isArray(t.vulnerabilities))return t.vulnerabilities;if(Array.isArray(t.issues))return t.issues}}catch{}return[]}(t.output??"");if(0===i.length)return t.output?(0,r.Y)(ts,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-success/20 bg-success/[0.04] px-3 py-2.5 text-[11.5px] text-success",children:[(0,r.Y)(tj.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No issues found"})]});let s=function(e){let t={high:0,medium:0,low:0,info:0};for(let n of e)t[tM(n)]++;return t}(i);return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Findings"}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-1.5 font-mono text-[9.5px]",children:[s.high>0&&(0,r.FD)("span",{className:"rounded-full bg-error/10 px-1.5 py-px text-error",children:[s.high," high"]}),s.medium>0&&(0,r.FD)("span",{className:"rounded-full bg-warning/10 px-1.5 py-px text-warning",children:[s.medium," med"]}),s.low>0&&(0,r.FD)("span",{className:"rounded-full bg-ink/8 px-1.5 py-px text-ink/55",children:[s.low," low"]})]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n=tM(e),i="string"==typeof e.message?e.message:"",s="string"==typeof e.file?e.file:"string"==typeof e.path?e.path:"",a="number"==typeof e.line?e.line:void 0,l="string"==typeof e.rule?e.rule:void 0;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)(tL.A,{size:11,className:`mt-0.5 shrink-0 ${"high"===n?"text-error":"medium"===n?"text-warning":"text-ink/40"}`}),(0,r.FD)("span",{className:"min-w-0 flex-1 break-words",children:[(0,r.Y)("span",{className:`mr-1.5 rounded-full px-1.5 py-px font-mono text-[9px] ${tP[n]}`,children:n}),s&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/45",children:[s,void 0!==a?`:${a}`:"",": "]}),(0,r.Y)("span",{className:"text-ink/80",children:i}),l&&(0,r.FD)("span",{className:"ml-1 font-mono text-[9.5px] text-ink/35",children:["(",l,")"]})]})]},t)})})]})}var tR=n("zH"),tI=n("cQ");let tO={running:"bg-ink/8 text-ink/60",done:"bg-success/10 text-success",failed:"bg-error/10 text-error",idle:"bg-ink/5 text-ink/45"};function tJ(e){let{tool:t}=e,n=t.details??{},s=Array.isArray(n.jobs)?n.jobs:Array.isArray(n.items)?n.items:[],a=t.input,l="object"==typeof a&&null!==a?a:void 0,o=t.output||"";if(l?.op==="wait"){let e=Array.isArray(l.ids)?l.ids:[],t="string"==typeof l.name?l.name:void 0,n="string"==typeof l.for?l.for:void 0,i="number"==typeof l.timeout?`${l.timeout}s`:"number"==typeof l.timeoutMs?`${Math.round(l.timeoutMs/1e3)}s`:void 0;return(0,r.FD)("div",{className:"space-y-2 rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px]",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 pb-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(tR.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono font-semibold text-ink",children:t?`Hub Wait: ${t}`:"Hub Wait"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:n?`wait (${n})`:"job wait"})]}),i&&(0,r.FD)("span",{className:"font-mono text-[9.5px] text-ink/40",children:["timeout: ",i]})]}),e.length>0&&(0,r.FD)("div",{className:"pt-1",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:"Waiting for Job IDs"}),(0,r.Y)("div",{className:"mt-1 flex flex-wrap gap-1.5 font-mono text-[10.5px]",children:e.map((e,t)=>(0,r.Y)("span",{className:"rounded bg-ink/5 px-2 py-0.5 text-ink/80",children:e},t))})]}),o&&(0,r.Y)(ts,{text:o})]})}if(l?.op==="logs"){let e="string"==typeof l.name?l.name:"Process";return(0,r.FD)("div",{className:"space-y-2 rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px]",children:[(0,r.Y)("div",{className:"flex items-center justify-between border-b border-ink/6 pb-2",children:(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eF.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono font-semibold text-ink",children:e}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:"logs"})]})}),(0,r.Y)("div",{className:"rounded border border-ink/6 bg-canvas/40 p-2 font-mono text-[10.5px] text-ink/85 whitespace-pre-wrap",children:o||"// No log output"})]})}let c=(0,i.Kr)(()=>{let e="string"==typeof l?.op?l.op.toLowerCase():"",t=["start","stop","restart","status"].includes(e),n=o.includes("pid=");if(!t&&!n)return null;let r=l?.name||"Service",i=l?.application,s=Array.isArray(l?.args)?l.args.join(" "):"",a=i?`${i} ${s}`.trim():s,c=l?.ready?.port,d=o.match(/pid=(\d+)/i),u=o.match(/uptime=([^\s]+)/i),p=o.match(/restarts=(\d+)/i),m=o.toLowerCase().includes("ready")||o.toLowerCase().includes("started")||o.toLowerCase().includes("running");return{op:e||"process",name:r,cmd:a,port:c,pid:d?d[1]:void 0,uptime:u?u[1]:void 0,restarts:p?p[1]:void 0,isReady:m,outputLines:o.split(/\r?\n/).filter(Boolean)}},[l,o]);return c?(0,r.Y)("div",{className:"space-y-2",children:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(eF.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink",children:c.name}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9.5px] uppercase tracking-wider text-ink/50",children:c.op})]}),c.isReady&&(0,r.FD)("span",{className:"inline-flex items-center gap-1.5 rounded-full bg-success/10 px-2 py-0.5 font-mono text-[9.5px] font-semibold text-success",children:[(0,r.Y)("span",{className:"h-1.5 w-1.5 rounded-full bg-success animate-pulse"}),"Active"]})]}),(0,r.FD)("div",{className:"divide-y divide-ink/[0.04] p-3 text-[11px]",children:[c.cmd&&(0,r.FD)("div",{className:"flex items-center justify-between py-1 font-mono",children:[(0,r.Y)("span",{className:"text-ink/45",children:"Command"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-2 py-0.5 text-ink/85",children:c.cmd})]}),(0,r.FD)("div",{className:"flex flex-wrap items-center gap-4 py-1.5 font-mono text-[10.5px]",children:[c.port&&(0,r.FD)("span",{className:"text-ink/60",children:["Port: ",(0,r.Y)("strong",{className:"text-ink",children:c.port})]}),c.pid&&(0,r.FD)("span",{className:"text-ink/60",children:["PID: ",(0,r.Y)("strong",{className:"text-ink",children:c.pid})]}),c.uptime&&(0,r.FD)("span",{className:"text-ink/60",children:["Uptime: ",(0,r.Y)("strong",{className:"text-ink",children:c.uptime})]})]}),c.outputLines.length>0&&(0,r.FD)("div",{className:"pt-2",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:"Log Output"}),(0,r.Y)("div",{className:"mt-1 rounded border border-ink/6 bg-canvas/40 p-2 font-mono text-[10.5px] text-ink/75",children:c.outputLines.map((e,t)=>(0,r.Y)("div",{children:e},t))})]})]})]})}):0===s.length?o?(0,r.Y)(ts,{text:o}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(tI.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No hub activities"})]}):(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-3 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Hub Jobs"}),(0,r.Y)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:s.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:s.map((e,t)=>{let n,i="running"===(n="string"==typeof e.status?e.status.toLowerCase():"string"==typeof e.state?e.state.toLowerCase():"")||"started"===n||"pending"===n?"running":"done"===n||"completed"===n||"success"===n?"done":"failed"===n||"error"===n?"failed":"idle",s="string"==typeof e.id?e.id:"string"==typeof e.name?e.name:`job-${t}`,a="string"==typeof e.label?e.label:"string"==typeof e.task?e.task:"string"==typeof e.message?e.message:"",l="string"==typeof e.type?e.type:void 0,o="number"==typeof e.durationMs?`${(e.durationMs/1e3).toFixed(1)}s`:void 0,c="string"==typeof e.resolvedModel?e.resolvedModel:void 0;return(0,r.FD)("div",{className:"flex items-center gap-2 px-3 py-1.5 text-[11.5px]",children:["running"===i?(0,r.Y)(tR.A,{size:11,className:"shrink-0 animate-pulse text-ink/50"}):"done"===i?(0,r.Y)(eB.A,{size:11,className:"shrink-0 text-success"}):(0,r.Y)(tg.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] font-semibold text-ink/80",children:s}),l&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1 py-0.2 font-mono text-[8.5px] uppercase tracking-wider text-ink/45",children:l}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate text-ink/85",children:a}),c&&(0,r.Y)("span",{className:"hidden sm:inline-block font-mono text-[9px] text-ink/40 truncate max-w-[120px]",children:c}),o&&(0,r.Y)("span",{className:"font-mono text-[9px] text-ink/40",children:o}),(0,r.Y)("span",{className:`shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${tO[i]}`,children:i})]},t)})})]}),o&&(0,r.Y)(ts,{text:o})]})}var t_=n("jI"),tW=n("rY"),tK=n("Os");function tU(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.notes)?n.notes:[],s="new_context"===t.type;return 0===i.length?t.output?(0,r.Y)(ts,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[s?(0,r.Y)(t_.A,{size:13,className:"shrink-0"}):(0,r.Y)(tW.A,{size:13,className:"shrink-0"}),(0,r.FD)("span",{children:["No ",s?"notes created":"notes"]})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:s?"New Context":"Notes"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n="string"==typeof e.title&&e.title?e.title:"string"==typeof e.text&&e.text?e.text:"string"==typeof e.content&&e.content?e.content:"string"==typeof e.note?e.note:"";return n?(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[s?(0,r.Y)(tK.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}):(0,r.Y)(tW.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 break-words text-ink/80",children:n})]},"string"==typeof e.id?e.id:`note-${t}`):null})})]})}var tH=n("YO"),tB=n("Y0"),tq=n("z9");let tG={memory_edit:{label:"Memory Edit",icon:(0,r.Y)(ez.A,{size:11})},retain:{label:"Retained",icon:(0,r.Y)(tH.A,{size:11})},recall:{label:"Recalled",icon:(0,r.Y)(z.A,{size:11})},reflect:{label:"Reflections",icon:(0,r.Y)(z.A,{size:11})},learn:{label:"Learned",icon:(0,r.Y)(tB.A,{size:11})}};function tV(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.items))return t.items;if(Array.isArray(t.memories))return t.memories;if(Array.isArray(t.results))return t.results}}catch{}return[]}(t.output??""),s=tG[t.type]??{label:"Memory",icon:(0,r.Y)(z.A,{size:11})};return 0===i.length?t.output?(0,r.Y)(ts,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(tq.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No memories"})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:s.label}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n="string"==typeof e.text&&e.text?e.text:"string"==typeof e.content?e.content:"";if(!n)return null;let i="number"==typeof e.score&&Number.isFinite(e.score)?e.score:void 0;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)("span",{className:"mt-0.5 shrink-0 text-ink/40",children:s.icon}),(0,r.Y)("span",{className:"min-w-0 flex-1 break-words text-ink/80",children:n}),void 0!==i&&(0,r.FD)("span",{className:"shrink-0 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] text-ink/45",children:[Math.round(100*i),"%"]})]},"string"==typeof e.id?e.id:`mem-${t}`)})})]})}var tZ=n("ND"),tQ=n("u8");function tX(e){let t="string"==typeof e.state?e.state.toLowerCase():"";return"attached"===t||"running"===t?t:"detached"===t?"detached":"stopped"}let t0={attached:"bg-success/10 text-success",running:"bg-ink/8 text-ink/60",stopped:"bg-ink/5 text-ink/45",detached:"bg-error/10 text-error"};function t1(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:[];if(0===i.length)return t.output?(0,r.Y)(ts,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(tZ.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No debug session"})]});let s=function(e){let t={attached:0,running:0,stopped:0,detached:0};for(let n of e)t[tX(n)]++;return t}(i);return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"flex items-center gap-2 border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Debug Session"}),(0,r.FD)("span",{className:"ml-auto flex items-center gap-1.5 font-mono text-[9.5px]",children:[s.attached>0&&(0,r.FD)("span",{className:"rounded-full bg-success/10 px-1.5 py-px text-success",children:[s.attached," attached"]}),s.running>0&&(0,r.FD)("span",{className:"rounded-full bg-ink/8 px-1.5 py-px text-ink/60",children:[s.running," run"]}),s.detached>0&&(0,r.FD)("span",{className:"rounded-full bg-error/10 px-1.5 py-px text-error",children:[s.detached," detach"]})]})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n=tX(e),i="string"==typeof e.target&&e.target?e.target:"number"==typeof e.pid?`pid ${e.pid}`:"string"==typeof e.message?e.message:"";return(0,r.FD)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 text-[11.5px]",children:["attached"===n?(0,r.Y)(eB.A,{size:11,className:"shrink-0 text-success"}):"running"===n?(0,r.Y)(tQ.A,{size:11,className:"shrink-0 animate-pulse text-ink/50"}):(0,r.Y)(eV.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-mono text-[10.5px] text-ink/75",children:i}),(0,r.Y)("span",{className:`shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${t0[n]}`,children:n})]},`${i}-${t}`)})})]})}var t5=n("vBE"),t2=n("qd"),t4=n("Sy"),t3=n("oS");let t8={active:"bg-ink/8 text-ink/60",done:"bg-success/10 text-success",paused:"bg-warning/10 text-warning"};function t6(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.items)?n.items:[],s="yield"===t.type||"yield"===t.name,a="error"===t.status;if(s){let e=function(e){let t=(0,t3.u)(e.details)?e.details:void 0,n=(0,t3.u)(e.input)?e.input:void 0,r=(t&&(0,t3.u)(t.data)?t.data:void 0)??(n&&(0,t3.u)(n.data)?n.data:void 0)??t??n;if(!r)return null;let i="string"==typeof r.summary?r.summary:void 0,s="string"==typeof r.report?r.report:void 0,a="string"==typeof r.architecture?r.architecture:void 0,l=Array.isArray(r.files)?r.files:void 0,o=[];if(l)for(let e of l)"string"==typeof e&&e?o.push(e):(0,t3.u)(e)&&"string"==typeof e.path&&o.push({path:e.path,description:"string"==typeof e.description?e.description:void 0});let c="string"==typeof t?.status?t.status:"string"==typeof r.status?r.status:void 0,d="string"==typeof r.error?r.error:null;return i||s||a||0!==o.length||d?{summary:i,report:s,architecture:a,files:o.length>0?o:void 0,status:c,error:d}:null}(t);if(e)return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper text-[12px] text-ink select-text",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/8 bg-canvas/40 px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)("span",{className:`flex h-5 w-5 items-center justify-center rounded-md ${a||e.error?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:a||e.error?(0,r.Y)(tl.A,{size:12}):(0,r.Y)(eB.A,{size:12})}),(0,r.Y)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/70",children:a||e.error?"Yield Error":"Yield Result"})]}),(e.status||(a?"error":"success"))&&(0,r.Y)("span",{className:`rounded-full px-2 py-0.5 font-mono text-[9.5px] font-medium uppercase ${a||e.error?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:e.status||(a?"failed":"success")})]}),(0,r.FD)("div",{className:"space-y-2.5 p-3",children:[(e.error||a&&t.output)&&(0,r.FD)("div",{className:"flex items-start gap-2 rounded-md bg-error/10 p-2.5 text-error text-[11.5px]",children:[(0,r.Y)(tl.A,{size:13,className:"shrink-0 mt-0.5"}),(0,r.Y)("span",{className:"font-mono leading-relaxed",children:e.error||t.output})]}),e.summary&&(0,r.FD)("div",{children:[(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:"Summary"}),(0,r.Y)("p",{className:"mt-0.5 font-sans text-[12px] text-ink font-medium leading-relaxed",children:e.summary})]}),e.report&&e.report!==e.summary&&(0,r.FD)("div",{className:"rounded-md border border-ink/8 bg-canvas/30 p-2.5",children:[(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:"Report"}),(0,r.Y)("div",{className:"mt-1 text-[11.5px] text-ink/85 leading-relaxed",children:(0,r.Y)(eh.T,{content:e.report})})]}),e.architecture&&(0,r.FD)("div",{children:[(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:"Evidence / Architecture"}),(0,r.Y)("div",{className:"mt-0.5 text-[11px] text-ink/75 leading-relaxed bg-ink/[0.03] p-2 rounded border border-ink/6",children:(0,r.Y)(eh.T,{content:e.architecture})})]}),e.files&&e.files.length>0&&(0,r.FD)("div",{children:[(0,r.FD)("span",{className:"text-[10px] font-mono text-ink/45 uppercase tracking-wider",children:["Files Inspected (",e.files.length,")"]}),(0,r.Y)("div",{className:"mt-1 grid grid-cols-1 gap-1 sm:grid-cols-2",children:e.files.map((e,t)=>{let n="string"==typeof e?e:e.path,i="string"==typeof e?void 0:e.description;return(0,r.FD)("div",{className:"flex flex-col justify-between rounded border border-ink/6 bg-canvas/40 p-1.5",children:[(0,r.FD)("span",{className:"inline-flex items-center gap-1 font-mono text-[10.5px] font-medium text-ink truncate",children:[(0,r.Y)(ew.A,{size:10,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{className:"truncate",children:n})]}),i&&(0,r.Y)("span",{className:"text-[10px] text-ink/60 leading-tight mt-0.5 truncate",children:i})]},t)})})]})]})]})}return 0===i.length?t.output?(0,r.Y)(ts,{text:t.output}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(eV.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:s?"No yield":"No goals"})]}):(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:s?"Yield":"Goals"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n,i="string"==typeof e.title&&e.title?e.title:"string"==typeof e.description?e.description:"";if(!i)return null;let a="number"==typeof e.progress&&Number.isFinite(e.progress)?e.progress:void 0,l="done"===(n="string"==typeof e.status?e.status.toLowerCase():"")||"completed"===n?"done":"paused"===n||"yielded"===n?"paused":"active";return(0,r.FD)("div",{className:"px-2.5 py-1.5",children:[(0,r.FD)("div",{className:"flex items-start gap-2 text-[11.5px]",children:[s?(0,r.Y)(t5.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}):(0,r.Y)(t2.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 break-words text-ink/80",children:i}),(0,r.Y)("span",{className:`shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${t8[l]}`,children:l})]}),void 0!==a&&(0,r.FD)("div",{className:"mt-1.5 flex items-center gap-1.5 pl-[18px]",children:[(0,r.Y)("div",{className:"h-1 flex-1 overflow-hidden rounded-full bg-ink/8",children:(0,r.Y)("div",{className:"h-full rounded-full bg-ink/60 transition-all duration-300",style:{width:`${Math.min(100,Math.max(0,Math.round(100*a)))}%`}})}),(0,r.FD)("span",{className:"flex shrink-0 items-center gap-0.5 font-mono text-[9px] text-ink/45",children:[(0,r.Y)(t4.A,{size:8}),Math.round(100*a),"%"]})]})]},"string"==typeof e.id?e.id:`goal-${t}`)})})]})}var t9=n("fj"),t7=n("qw");function ne(e){let{tool:t}=e,n=t.details??{},s=n.xdev??{},a=s.inner??{},l=s.args??{},o=t.output??"",c=!1===a.applied||o.toLowerCase().includes("staged as a proposal")||o.toLowerCase().includes("files not modified yet"),d=Array.isArray(l.ops)?l.ops:[],u=Array.isArray(l.paths)?l.paths:a.scopePath?[a.scopePath]:[],p=a.displayContent||(o.includes("-")&&o.includes("+")?o:""),m=p?p.split(/\r?\n/).filter(e=>!e.startsWith("Staged as a proposal")&&!!e.trim()):[],h=Array.isArray(n.changes)?n.changes:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.changes))return t.changes;if(Array.isArray(t.edits))return t.edits}}catch{}return[]}(o),f=(0,eU.w)(),x=(0,eK.sQ)(u[0]),g=(0,i.Kr)(()=>{let e=m.map(e=>e.startsWith("+")||e.startsWith("-")||e.startsWith(" ")?e.slice(1):e);return(0,eK.O9)(e.join("\n"),x)},[m,x,f]);if(c||d.length>0||m.length>0)return(0,r.Y)("div",{className:"space-y-2 select-text",children:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/10 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(t9.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink",children:"AST Edit"}),u.length>0&&(0,r.Y)("span",{className:"font-mono text-[10px] text-ink/50 truncate max-w-[200px]",children:u[0]})]}),(0,r.FD)("span",{className:`inline-flex items-center gap-1 rounded-full px-2 py-0.5 font-mono text-[9px] font-semibold ${c?"bg-warning/10 text-warning":"bg-success/10 text-success"}`,children:[c?(0,r.Y)(tx.A,{size:10}):(0,r.Y)(eB.A,{size:10}),c?"STAGED PROPOSAL":"APPLIED"]})]}),d.length>0&&(0,r.FD)("div",{className:"border-b border-ink/6 p-2.5 bg-canvas/20",children:[(0,r.Y)("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-ink/40",children:"Pattern Transformation"}),(0,r.Y)("div",{className:"mt-1 space-y-1",children:d.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 rounded border border-ink/6 bg-paper px-2 py-1 font-mono text-[10.5px]",children:[(0,r.Y)("span",{className:"text-error/90 line-through truncate",children:e.pat}),(0,r.Y)(t7.A,{size:10,className:"shrink-0 text-ink/35"}),(0,r.Y)("span",{className:"text-success/90 font-medium truncate",children:e.out||"/* removed */"})]},t))})]}),m.length>0&&(0,r.Y)("div",{className:"p-2.5 font-mono text-[10.5px] leading-relaxed bg-canvas/30 space-y-0.5",children:m.map((e,t)=>{let n=e.startsWith("-"),i=e.startsWith("+"),s=g[t]||"";return(0,r.FD)("div",{className:`rounded px-1.5 py-0.5 ${n?"bg-error/10 text-error font-medium":i?"bg-success/10 text-success font-medium":"text-ink/70"}`,children:[(n||i)&&e[0],s?(0,r.Y)("span",{className:"shiki",dangerouslySetInnerHTML:{__html:s}}):n||i?e.slice(1):e]},t)})}),c&&(0,r.FD)("div",{className:"border-t border-ink/6 bg-paper px-3 py-1.5 text-[10px] text-ink/50",children:["Proposal staged in memory. Apply with ",(0,r.Y)("code",{className:"font-mono text-ink/75",children:"xd://resolve"})," or discard with ",(0,r.Y)("code",{className:"font-mono text-ink/75",children:"xd://reject"}),"."]})]})});if(h.length>0)return(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 select-text",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"AST Changes"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:h.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:h.map((e,t)=>{let n="string"==typeof e.file?e.file:"string"==typeof e.path?e.path:"",i="string"==typeof e.message?e.message:"",s="string"==typeof e.nodeKind?e.nodeKind:"",a="number"==typeof e.changes?e.changes:void 0;return(0,r.FD)("div",{className:"flex items-start gap-2 px-2.5 py-1.5 text-[11.5px]",children:[(0,r.Y)(t9.A,{size:11,className:"mt-0.5 shrink-0 text-ink/40"}),(0,r.FD)("span",{className:"min-w-0 flex-1 break-words",children:[n&&(0,r.FD)("span",{className:"font-mono text-[10px] text-ink/45",children:[n,": "]}),(0,r.Y)("span",{className:"text-ink/80",children:i}),s&&(0,r.FD)("span",{className:"ml-1 font-mono text-[9.5px] text-ink/35",children:["(",s,")"]})]}),void 0!==a&&(0,r.FD)("span",{className:"shrink-0 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] text-ink/45",children:[a," changes"]})]},t)})})]});let b=o.split(/\r?\n/).filter(Boolean);return 0===b.length?null:(0,r.Y)("ul",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40 select-text",children:b.map((e,t)=>(0,r.Y)("li",{className:"px-2.5 py-1.5 font-mono text-[11px] break-words text-ink/75",children:e},t))})}function nt(e){let{tool:t}=e,n=(t.details??{}).xdev??{},i=n.inner??{},s="object"==typeof t.input&&null!==t.input?t.input:void 0,a="reject"===t.name||t.target?.includes("reject")||"reject"===n.tool||"reject"===i.action||"discard"===i.action,l=i.reason||n.args?.reason||("string"==typeof s?.content?s.content:"")||("string"==typeof t.input?t.input:""),o=i.sourceToolName||"ast_edit",c=i.label||t.output||(a?"Proposal discarded":"Proposal applied"),d=Array.isArray(i.sourceResultDetails?.files)?i.sourceResultDetails.files:[],u=i.sourceResultDetails?.totalReplacements??i.totalReplacements;return(0,r.Y)("div",{className:"space-y-2 select-text",children:(0,r.FD)("div",{className:"rounded-lg border border-ink/10 bg-paper p-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between gap-2 border-b border-ink/6 pb-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[a?(0,r.Y)(eq.A,{size:14,className:"text-warning shrink-0"}):(0,r.Y)(eB.A,{size:14,className:"text-success shrink-0"}),(0,r.Y)("span",{className:"font-mono text-[11px] font-semibold text-ink",children:a?"Proposal Discarded":"Proposal Applied"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:o})]}),(0,r.Y)("span",{className:`rounded-full px-2 py-0.5 font-mono text-[9.5px] font-semibold ${a?"bg-warning/10 text-warning":"bg-success/10 text-success"}`,children:a?"REJECTED":"RESOLVED"})]}),l&&(0,r.FD)("div",{className:"pt-2.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:"Reason"}),(0,r.FD)("p",{className:"mt-0.5 text-[12px] leading-relaxed text-ink/85 italic",children:["“",l,"”"]})]}),c&&(0,r.Y)("div",{className:"mt-2 text-[11.5px] font-medium text-ink/80",children:c}),d.length>0&&(0,r.FD)("div",{className:"mt-2.5 space-y-1 border-t border-ink/6 pt-2",children:[(0,r.FD)("div",{className:"flex items-center justify-between text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:[(0,r.FD)("span",{children:["Touched Files (",d.length,")"]}),"number"==typeof u&&(0,r.FD)("span",{children:[u," replacement",1===u?"":"s"]})]}),(0,r.Y)("div",{className:"space-y-1",children:d.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-1.5 font-mono text-[10.5px] text-ink/70",children:[(0,r.Y)(ew.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"truncate",children:e})]},t))})]})]})})}var nn=n("xn"),nr=n("JH");let ni={enabled:"bg-success/10 text-success",installed:"bg-ink/8 text-ink/60",disabled:"bg-ink/5 text-ink/45",removed:"bg-error/10 text-error"};function ns(e){let{tool:t}=e,n=t.details??{},i=Array.isArray(n.skills)?n.skills:function(e){if(!e)return[];try{let t=JSON.parse(e);if(Array.isArray(t))return t;if(t&&"object"==typeof t){if(Array.isArray(t.skills))return t.skills;if(Array.isArray(t.items))return t.items}}catch{}return[]}(t.output??"");return 0===i.length?t.output?(0,r.Y)(ts,{text:t.output}):null:(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[(0,r.FD)("div",{className:"border-b border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Skills"}),(0,r.Y)("span",{className:"ml-2 rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9.5px] text-ink/45",children:i.length})]}),(0,r.Y)("div",{className:"divide-y divide-ink/6 bg-canvas/40 py-1",children:i.map((e,t)=>{let n,i="string"==typeof e.name?e.name:"string"==typeof e.slug?e.slug:"";if(!i)return null;let s="enabled"===(n="string"==typeof e.status?e.status.toLowerCase():"")||"installed"===n?n:"removed"===n||"uninstalled"===n||"deleted"===n?"removed":"disabled",a="string"==typeof e.scope?e.scope:void 0,l="string"==typeof e.version?e.version:void 0,o="string"==typeof e.message?e.message:"";return(0,r.FD)("div",{className:"flex items-center gap-2 px-2.5 py-1.5 text-[11.5px]",children:["removed"===s?(0,r.Y)(nn.A,{size:11,className:"shrink-0 text-error"}):(0,r.Y)(nr.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] font-semibold text-ink/70",children:i}),a&&(0,r.Y)("span",{className:"rounded-full bg-ink/5 px-1.5 py-px font-mono text-[9px] text-ink/45",children:a}),l&&(0,r.FD)("span",{className:"font-mono text-[9px] text-ink/35",children:["v",l]}),o&&(0,r.Y)("span",{className:"min-w-0 flex-1 truncate text-ink/65",children:o}),(0,r.Y)("span",{className:`ml-auto shrink-0 rounded-full px-1.5 py-px font-mono text-[9px] ${ni[s]}`,children:s})]},t)})})]})}function na(e){return"string"==typeof e.path?e.path:"string"==typeof e.name?e.name:""}function nl(e){let{tool:t}=e,[n,s]=(0,i.J0)(""),a=t.details??{},l=Array.isArray(a.results)?a.results:[],o=(0,i.Kr)(()=>{if(l.length>0)return l;if(t.output)try{let e=JSON.parse(t.output);if(Array.isArray(e))return e;if(e&&"object"==typeof e){if(Array.isArray(e.results))return e.results;if(Array.isArray(e.items))return e.items;if(Array.isArray(e.files))return e.files}}catch{}return(t.output??"").split(/\r?\n/).filter(Boolean).map(e=>{let t=e.endsWith("/");return{path:e,type:t?"dir":"file"}})},[l,t.output]),c=(0,i.Kr)(()=>{if(!n)return o;let e=n.toLowerCase();return o.filter(t=>na(t).toLowerCase().includes(e))},[o,n]);return 0===o.length?(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 px-3 py-2.5 text-[11.5px] text-ink/45",children:[(0,r.Y)(tC.A,{size:13,className:"shrink-0"}),(0,r.Y)("span",{children:"No filesystem matches found"})]}):(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)(tC.A,{size:13,className:"text-ink/60"}),(0,r.Y)("span",{className:"text-[11px] font-semibold text-ink",children:"Filesystem Search"}),(0,r.FD)("span",{className:"rounded-full bg-ink/5 px-2 py-0.5 font-mono text-[9.5px] text-ink/50",children:[o.length," ",1===o.length?"entry":"entries"]})]}),(0,r.FD)("div",{className:"flex items-center gap-2",children:[o.length>5&&(0,r.Y)("input",{type:"text",placeholder:"Filter...",value:n,onChange:e=>s(e.currentTarget.value),className:"h-6 w-24 rounded border border-ink/10 bg-canvas px-2 text-[10.5px] text-ink focus:outline-none"}),(0,r.Y)(eg,{text:o.map(e=>na(e)).join("\n"),className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]})]}),(0,r.Y)("div",{className:"max-h-64 divide-y divide-ink/6 overflow-y-auto rounded-lg border border-ink/8 bg-paper",children:c.map((e,t)=>{let n,i=na(e);if(!i)return null;let s="file"===(n="string"==typeof e.type?e.type.toLowerCase():"")||"directory"===n||"dir"===n?"directory"===n||"dir"===n?"dir":"file":"unknown",a="number"==typeof e.size&&e.size>0?(0,eX.z3)(e.size):"";return(0,r.FD)("div",{className:"flex items-center gap-2 px-3 py-1.5 text-[11.5px] transition-colors hover:bg-ink/[0.02]",children:["dir"===s?(0,r.Y)(d.A,{size:12,className:"shrink-0 text-ink/50"}):(0,r.Y)(er.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-mono text-[11px] text-ink/80",children:i}),"unknown"!==s&&(0,r.Y)("span",{className:`shrink-0 rounded px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider ${"dir"===s?"bg-ink/8 text-ink/60":"bg-ink/5 text-ink/45"}`,children:s}),a&&(0,r.Y)("span",{className:"shrink-0 font-mono text-[10px] text-ink/40",children:a})]},t)})})]})}function no(e){let{tool:t}=e,n=t.input,s="object"==typeof n&&null!==n?n:void 0,a=Array.isArray(s?.questions)&&s.questions.length>0?s.questions[0]:void 0,l=a?.header,o=a?.question||("string"==typeof s?.question?s.question:"string"==typeof s?.prompt?s.prompt:"string"==typeof s?.message?s.message:"string"==typeof n?n:t.detail||"Question from agent"),c=a?.options||s?.options||s?.choices||[],d=Array.isArray(c)?c.map(e=>"string"==typeof e?{label:e}:"object"==typeof e&&null!==e?{label:"string"==typeof e.label?e.label:"string"==typeof e.text?e.text:String(e),description:"string"==typeof e.description?e.description:void 0}:{label:String(e)}):[],u=(0,i.Kr)(()=>"string"==typeof t.output?t.output:t.output&&"object"==typeof t.output?JSON.stringify(t.output,null,2):"string"==typeof s?.answer?s.answer:s?.answer&&"object"==typeof s?.answer?JSON.stringify(s.answer,null,2):"",[t.output,s?.answer]),p="string"==typeof u&&/cancelled|aborted|interrupted|disconnected/i.test(u)||"aborted"===t.status||"error"===t.status&&"string"==typeof u&&/disconnect|error/i.test(u),m="string"==typeof u?u.match(/selected:\s*(.+)$/i):null,h=m?m[1].trim():u,f=(0,i.Kr)(()=>!p&&u?(0,eK.Bl)(u):{isValid:!1},[u,p]),x="string"==typeof u&&u.includes("\n")&&!m,g=(0,eU.w)(),b=(0,i.Kr)(()=>"string"==typeof u&&(0,eK.rw)(u)?(0,eK.wY)(u,"javascript"):"",[u,g]);return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"rounded-lg border border-ink/10 bg-paper p-3 shadow-xs",children:[(0,r.FD)("div",{className:"flex items-start gap-2 min-w-0",children:[(0,r.Y)(eA.A,{size:14,className:"mt-0.5 shrink-0 text-ink/60"}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.Y)("span",{className:"text-[10px] font-semibold uppercase tracking-wider text-ink/40",children:l?`Agent Question \xb7 ${l}`:"Agent Question"}),(0,r.Y)("div",{className:"mt-1 text-[12.5px] leading-relaxed text-ink/90 select-text",children:(0,r.Y)(eh.T,{content:o})})]})]}),d.length>0&&(0,r.FD)("div",{className:"mt-3 space-y-1.5 border-t border-ink/6 pt-2.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:"Options"}),(0,r.Y)("div",{className:"grid gap-1.5",children:d.map((e,t)=>{let n=!p&&!!h&&h.toLowerCase().includes(e.label.toLowerCase());return(0,r.FD)("div",{className:`flex flex-col gap-0.5 rounded-md px-2.5 py-1.5 text-[11px] transition-colors ${n?"border border-ink/30 bg-ink/5 font-medium text-ink":"border border-ink/6 bg-canvas/30 text-ink/75"}`,children:[(0,r.FD)("div",{className:"flex items-center gap-2",children:[(0,r.Y)("span",{className:"flex h-3.5 w-3.5 shrink-0 items-center justify-center rounded bg-ink/5 font-mono text-[9px] text-ink/60 font-semibold",children:t+1}),(0,r.Y)("span",{className:"min-w-0 flex-1 truncate font-medium text-ink/90",children:e.label}),n&&(0,r.Y)(eB.A,{size:12,className:"shrink-0 text-success"})]}),e.description&&(0,r.Y)("div",{className:"pl-5.5 text-[10px] leading-relaxed text-ink/50",children:e.description})]},t)})})]})]}),p&&u&&(0,r.FD)("div",{className:"flex items-center gap-2 rounded-md border border-ink/8 bg-ink/[0.02] px-2.5 py-1 text-[10.5px] text-ink/60",children:[(0,r.Y)(eq.A,{size:11,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-ink/40 shrink-0",children:"Status:"}),(0,r.Y)("span",{className:"font-mono text-ink/60 truncate select-text",children:u})]}),!p&&f.isValid&&f.pretty&&(0,r.Y)(eQ,{jsonString:f.pretty,title:"User Response",maxHeightClass:"max-h-40",compact:!0,icon:(0,r.Y)(eB.A,{size:10.5,className:"text-success shrink-0"}),showHeader:!0}),!p&&!f.isValid&&u&&(x?(0,r.FD)("div",{className:"overflow-hidden rounded-md border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-2.5 py-1",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)(eB.A,{size:10.5,className:"shrink-0 text-success"}),(0,r.Y)("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-ink/50",children:"User Response"})]}),(0,r.Y)(eg,{text:u,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink shrink-0",title:"Copy response",label:"Copy"})]}),(0,r.Y)("pre",{className:"max-h-32 overflow-y-auto p-2 font-mono text-[10.5px] leading-snug whitespace-pre-wrap break-words text-ink/85 select-text",children:b?(0,r.Y)("span",{dangerouslySetInnerHTML:{__html:b}}):u})]}):(0,r.FD)("div",{className:"flex items-center gap-2 rounded-md border border-ink/8 bg-canvas/30 px-2.5 py-1 text-[10.5px]",children:[(0,r.Y)(eB.A,{size:11,className:"shrink-0 text-success"}),(0,r.Y)("span",{className:"text-[9px] font-semibold uppercase tracking-wider text-ink/40 shrink-0",children:"User Response:"}),(0,r.Y)("span",{className:"font-mono text-ink/90 font-medium truncate select-text",children:m?m[1].trim().replace(/^["']|["']$/g,""):u})]}))]})}function nc(e){let{tool:t}=e,n=t.input,i="object"==typeof n&&null!==n?n:void 0,s="string"==typeof i?.thought?i.thought:"string"==typeof i?.reasoning?i.reasoning:"string"==typeof i?.notes?i.notes:"string"==typeof n?n:t.output||t.detail||"";return s?(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/6 bg-canvas/40 px-3 py-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)(em.A,{size:12,className:"text-ink/50"}),(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Internal Reasoning"})]}),(0,r.Y)(eg,{text:s,className:"flex cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[9.5px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",label:"Copy"})]}),(0,r.Y)("div",{className:"max-h-64 overflow-y-auto p-3 text-[11.5px] leading-relaxed text-ink/80 select-text",children:(0,r.Y)(eh.T,{content:s})})]}):(0,r.Y)("div",{className:"rounded-lg border border-dashed border-ink/15 p-3 font-mono text-[11px] text-ink/40",children:"No thought details recorded."})}var nd=n("Y");function nu(e){let{tool:t,targetFilePath:n,output:s}=e,[a,l]=(0,i.J0)(null),[o,c]=(0,i.J0)(!1),u=to(t?.input),p=n||u||t?.target||"",m=p.split("?")[0].split("#")[0].replace(/:\d+(?:-\d+)?$/,"");(0,i.vJ)(()=>{!m||s||null!==a||o||(c(!0),fetch(`/api/fs/read?path=${encodeURIComponent(m)}`).then(e=>e.json()).then(e=>{l(e&&void 0!==e.content?e.content:`// Loaded file: ${m}`)}).catch(()=>{l(`// Loaded file: ${m}`)}).finally(()=>{c(!1)}))},[m,s,a,o]);let h=t?.details??{},f=s||("object"==typeof h?.displayContent&&"string"==typeof h.displayContent?.text?h.displayContent.text:"")||a||"",x=(0,i.Kr)(()=>(function(e){let t,n=e.split(/\r?\n/).filter(Boolean);if(0===n.length)return{isDirectory:!1,entries:[]};let r=n[0].trim(),i=n.some(e=>e.trimStart().startsWith("- ")||e.trimStart().startsWith("├──")||e.trimStart().startsWith("└──"));if("."!==r&&!i)return{isDirectory:!1,entries:[]};let s=[];for(let e of n){if(e.startsWith("[")&&e.endsWith("]")){t=e.slice(1,-1);continue}if("."===e.trim()){s.push({indent:0,isDir:!0,name:"."});continue}let n=e.match(/^(\s*)-\s+([^\s]+)\s*(.*)$/);if(n){let e,t,r=Math.floor(n[1].length/2),i=n[2],a=n[3].trim(),l=i.endsWith("/"),o=l?i.slice(0,-1):i,c=a.split(/\s{2,}|\t+/).filter(Boolean);2===c.length?(e=c[0],t=c[1]):1===c.length&&(c[0].endsWith("ago")?t=c[0]:e=c[0]),s.push({indent:r,isDir:l,name:o,size:e,time:t})}}return{isDirectory:s.length>0,entries:s,notice:t}})(f),[f]),g=(0,i.Kr)(()=>(function(e,t,n){let r=e?.details??{},i=e?.input&&"object"==typeof e.input?e.input:{},s=r.displayContent;if(s&&Array.isArray(s.lineNumbers)&&s.lineNumbers.length>0)return{startLine:"number"==typeof s.startLine?s.startLine:void 0,lineNumbers:s.lineNumbers};if(Array.isArray(r.lineNumbers)&&r.lineNumbers.length>0)return{startLine:"number"==typeof r.startLine?r.startLine:void 0,lineNumbers:r.lineNumbers};if("number"==typeof s?.startLine&&s.startLine>0)return{startLine:s.startLine};if("number"==typeof r.startLine&&r.startLine>0)return{startLine:r.startLine};if("number"==typeof r.start_line&&r.start_line>0)return{startLine:r.start_line};if("number"==typeof r.offset&&r.offset>0)return{startLine:r.offset};let a=r.meta?.truncation?.shownRange?.start??r.truncation?.shownRange?.start??r.meta?.shownRange?.start??r.shownRange?.start;if("number"==typeof a&&a>0)return{startLine:a};let l=i.start_line??i.startLine??i.offset??i.StartLine??i.from;if("number"==typeof l&&l>0)return{startLine:l};if("string"==typeof l&&/^\d+$/.test(l.trim())){let e=parseInt(l.trim(),10);if(e>0)return{startLine:e}}for(let n of["string"==typeof i.path?i.path:"",e?.target||"",e?.title||"",t||""]){let e=n.match(/:(\d+)(?:-\d+)?(?:\s|$)/);if(e){let t=parseInt(e[1],10);if(t>0)return{startLine:t}}}if(n){let e=n.match(/\[(?:Showing\s+)?lines?\s+(\d+)(?:-\d+)?/i);if(e){let t=parseInt(e[1],10);if(t>0)return{startLine:t}}}return{}})(t,p,f),[t,p,f]),{displayContent:b,elisionNotices:v}=(0,i.Kr)(()=>{if(x.isDirectory)return{displayContent:f,elisionNotices:[]};let e=f.split(/\r?\n/),t=[],n=[];for(let r of e){let e=r.trim();(e.startsWith("[…")||e.startsWith("[Showing lines ")||e.startsWith("[1 results limit"))&&e.endsWith("]")?t.push(e.slice(1,-1)):n.push(r)}return 0===t.length&&h.summary&&"number"==typeof h.summary.elidedLines&&h.summary.elidedLines>0&&t.push(`…${h.summary.elidedLines}ln elided (${h.summary.lines??n.length} lines shown)`),g.lineNumbers&&n.length>g.lineNumbers.length&&""===n[n.length-1].trim()&&n.pop(),{displayContent:n.join("\n"),elisionNotices:t}},[f,x.isDirectory,g.lineNumbers,h.summary]),k=(0,i.Kr)(()=>x.isDirectory||!b?{lines:[],cleanCode:"",hasLineNumbers:!1}:function(e,t){let n=e.replace(/\r?\n$/,"").split(/\r?\n/);if(0===n.length)return{lines:[],cleanCode:"",hasLineNumbers:!1};let r=[],i=0,s=0;for(let e of n){if(!e.trim()){r.push(null);continue}let t=e.match(/^(\s*(\d+):)/);if(t){let n=parseInt(t[2],10);r.push({lineNum:n,rawLine:e}),i++;continue}let n=e.match(/^(\s*(\d+)\s*[|│][ \t]?)/);if(n){let t=parseInt(n[2],10);r.push({lineNum:t,rawLine:e,pipePrefixLen:n[1].length}),s++;continue}r.push(null)}let a=n.filter(e=>e.trim().length>0),l=s>=2&&s>=.7*a.length,o=!l&&i>=2&&i>=.7*a.length&&(()=>{let e=r.filter(e=>null!==e).map(e=>e.lineNum);for(let t=1;t<e.length;t++)if(e[t]<e[t-1])return!1;return!0})();if(!l&&!o){let e=t?.lineNumbers,r="number"==typeof t?.startLine&&!isNaN(t.startLine)&&t.startLine>0?t.startLine:1;return{lines:n.map((t,n)=>{let i;if(e&&n<e.length){let t=e[n];i=null==t||""===t?"…":t}else i=r+n;return{lineNum:i,code:t}}),cleanCode:n.join("\n"),hasLineNumbers:!!(e&&e.length>0||r>1)}}if(l){let e=r.find(e=>null!==e)?.lineNum??1,t=[];for(let i=0;i<n.length;i++){let s=n[i],a=r[i];s.trim()?a&&void 0!==a.pipePrefixLen?(t.push({lineNum:a.lineNum,code:s.slice(a.pipePrefixLen)}),e=a.lineNum+1):(t.push({lineNum:e,code:s}),e++):(t.push({lineNum:e,code:""}),e++)}return{lines:t,cleanCode:t.map(e=>e.code).join("\n"),hasLineNumbers:!0}}let c=r.filter(e=>null!==e),d=String(Math.max(...c.map(e=>e.lineNum))).length+1,u=c.filter(e=>e.rawLine.length>d);u.length>0&&u.every(e=>" "===e.rawLine[d]||" "===e.rawLine[d])&&d++;let p=c[0]?.lineNum??1,m=[];for(let e=0;e<n.length;e++){let t=n[e],i=r[e];if(!t.trim()){m.push({lineNum:p,code:""}),p++;continue}if(i){p=i.lineNum;let e=t.length<=d?"":t.slice(d);m.push({lineNum:i.lineNum,code:e}),p=i.lineNum+1}else m.push({lineNum:p,code:t}),p++}return{lines:m,cleanCode:m.map(e=>e.code).join("\n"),hasLineNumbers:!0}}(b,g),[b,x.isDirectory,g]),y=x.isDirectory,w=(0,eK.sQ)(p),N=x.entries.slice(-1e3),Y=x.entries.length-N.length,D=(0,i.Kr)(()=>ti(k.cleanCode,1e3),[k.cleanCode]),F=D.skipped>0?k.lines.slice(D.skipped):k.lines,A=(0,eU.w)(),S=(0,i.Kr)(()=>D.text?(0,eK.wY)(D.text,w):"",[D,w,A]);return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.Y)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-ink/5 text-ink/70",children:y?(0,r.Y)(nd.A,{size:12}):(0,r.Y)(ey.A,{size:12})}),(0,r.Y)("span",{className:"truncate font-mono text-[11px] font-medium text-ink",children:p||(y?"Directory Listing":"File Content")}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:y?"Directory":w})]}),f&&(0,r.Y)(eg,{text:k.hasLineNumbers?k.cleanCode:f||"",className:"flex shrink-0 cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10.5px] text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:11,label:"Copy"})]}),o?(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-ink/8 bg-paper px-3 py-3 font-mono text-[11px] text-ink/50",children:[(0,r.Y)(e_.A,{size:12,className:"animate-spin"}),(0,r.Y)("span",{children:"Loading file content..."})]}):y?(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8 bg-paper",children:[Y>0&&(0,r.FD)("div",{className:"flex items-center gap-1.5 border-b border-ink/8 bg-canvas/60 px-3 py-1.5 text-[10px] text-ink/50",children:[(0,r.Y)(ep.A,{size:11,className:"shrink-0"}),(0,r.FD)("span",{children:["… ",Y," earlier entries hidden"]})]}),(0,r.Y)("div",{className:"max-h-72 divide-y divide-ink/[0.04] overflow-y-auto font-mono text-[11px]",children:N.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 px-3 py-1.5 transition-colors hover:bg-ink/[0.02]",style:{paddingLeft:`${Math.max(12,(e.indent+1)*16)}px`},children:[e.isDir?(0,r.Y)(d.A,{size:12,className:"shrink-0 text-ink/60"}):(0,r.Y)(ew.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.FD)("span",{className:`min-w-0 flex-1 truncate ${e.isDir?"font-semibold text-ink":"text-ink/80"}`,children:[e.name,e.isDir&&"/"]}),e.size&&(0,r.Y)("span",{className:"shrink-0 font-mono text-[9.5px] text-ink/40",children:e.size}),e.time&&(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1 py-0.2 font-mono text-[9px] text-ink/45",children:e.time})]},t))}),x.notice&&(0,r.FD)("div",{className:"flex items-center gap-1.5 border-t border-ink/8 bg-canvas/60 px-3 py-1.5 text-[10px] text-ink/50",children:[(0,r.Y)(ep.A,{size:11,className:"shrink-0"}),(0,r.Y)("span",{children:x.notice})]})]}):f?(0,r.FD)("div",{className:"space-y-1.5",children:[D.skipped>0&&(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 bg-canvas/50 px-3 py-1.5 font-mono text-[10.5px] text-ink/55",children:[(0,r.Y)(ep.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.FD)("span",{children:["… ",D.skipped," earlier lines hidden"]})]}),(0,r.FD)("div",{className:"relative flex max-h-80 items-start overflow-auto rounded-lg border border-ink/8 bg-paper font-mono text-[11px] leading-[20px] select-text overscroll-contain",children:[(0,r.Y)("div",{className:"sticky left-0 z-10 flex-shrink-0 select-none border-r border-ink/8 bg-canvas/90 py-2.5 pl-3 pr-2.5 text-right font-mono text-[11px] leading-[20px] tabular-nums text-ink/35 backdrop-blur-xs","aria-hidden":"true",children:F.map((e,t)=>(0,r.Y)("div",{className:"h-[20px] leading-[20px]",children:e.lineNum},t))}),(0,r.Y)("pre",{className:"m-0 flex-1 min-w-max overflow-visible py-2.5 pl-3 pr-4 font-mono text-[11px] leading-[20px] whitespace-pre text-ink/85 focus:outline-none",dangerouslySetInnerHTML:{__html:S}})]}),v.map((e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 rounded-lg border border-dashed border-ink/15 bg-canvas/50 px-3 py-1.5 font-mono text-[10.5px] text-ink/55",children:[(0,r.Y)(ep.A,{size:12,className:"shrink-0 text-ink/40"}),(0,r.Y)("span",{children:e})]},t))]}):(0,r.Y)("div",{className:"rounded-lg border border-dashed border-ink/15 px-3 py-3 font-mono text-[11px] text-ink/45",children:"File is ready for inspection."})]})}var np=n("fQ"),nm=n("BE");function nh(e){let{sections:t}=e,n=(0,eU.w)(),s=(0,i.Kr)(()=>t.map(e=>{let t=(0,eK.sQ)(e.path);return e.ops.map(e=>(0,eK.O9)(e.body.join("\n"),t))}),[t,n]);return(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:[(0,r.Y)("span",{children:"Hashline Patch"}),t[0].tag&&(0,r.FD)("span",{className:"font-mono text-[9px] font-normal tracking-normal text-ink/50",children:["snapshot ",t[0].tag]})]}),(0,r.Y)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:t.map((e,t)=>(0,r.FD)("div",{className:"border-b border-ink/6 last:border-b-0",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-2 bg-canvas/40 px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] font-medium text-ink",children:e.path}),e.moveTo&&(0,r.FD)("span",{className:"shrink-0 font-mono text-[10px] text-ink/50",children:["→ ",e.moveTo]}),e.removed&&(0,r.Y)("span",{className:"shrink-0 rounded bg-error/10 px-1.5 font-mono text-[9px] uppercase tracking-wider text-error",children:"Removes file"})]}),(0,r.Y)("div",{className:"overflow-x-auto",children:e.ops.map((e,n)=>(0,r.FD)("div",{children:[(0,r.FD)("div",{className:"flex items-center gap-2 px-2.5 py-1",children:[(0,r.Y)("span",{className:`shrink-0 rounded px-1.5 font-mono text-[9px] font-semibold ${"CUT"===e.verb?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:e.verb}),e.spec&&(0,r.Y)("span",{className:"font-mono text-[10.5px] text-ink/70",children:e.spec})]}),e.body.map((e,i)=>{let a=s[t]?.[n]?.[i]||"";return a?(0,r.Y)("div",{className:"shiki whitespace-pre bg-success/[0.05] px-2.5 font-mono text-[11px] leading-relaxed",dangerouslySetInnerHTML:{__html:a}},i):(0,r.Y)("div",{className:"whitespace-pre bg-success/[0.05] px-2.5 font-mono text-[11px] leading-relaxed text-success/90",children:e},i)})]},`${e.verb}-${e.spec}-${n}`))})]},e.path))})]})}var nf=n("e");function nx(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"diff",r=e?e.split(/\r?\n/):[],i=t?t.split(/\r?\n/):[],s=0;for(;s<r.length&&s<i.length&&r[s]===i[s];)s++;let a=0;for(;a<r.length-s&&a<i.length-s&&r[r.length-1-a]===i[i.length-1-a];)a++;let l=r.slice(Math.max(0,s-2),s),o=r.slice(s,r.length-a),c=i.slice(s,i.length-a),d=r.slice(r.length-a,r.length-a+2),u=n||"diff",p=[`--- a/${u}`,`+++ b/${u}`,`@@ -1,${r.length||1} +1,${i.length||1} @@`];for(let e of l)p.push(` ${e}`);for(let e of o)p.push(`-${e}`);for(let e of c)p.push(`+${e}`);for(let e of d)p.push(` ${e}`);return p.join("\n")}function ng(e){let{tool:t}=e,n="write"===t.type||"write"===t.name||"create_file"===t.type,s=t.input,a="object"==typeof s&&null!==s?s:void 0,l=(0,i.Kr)(()=>(0,nf.I)(a),[a]),o=t.target||l?.sections[0].path||a?.path||a?.TargetFile||a?.targetFile||a?.FilePath||a?.filePath||a?.AbsolutePath||a?.absolutePath||("string"==typeof t.details?.path?t.details.path:void 0)||("string"==typeof s&&(s.includes("/")||s.includes("."))?s:void 0)||"",c="string"==typeof a?.content?a.content:"string"==typeof a?.Content?a.Content:void 0,d="string"==typeof a?.old_string?a.old_string:"string"==typeof a?.oldString?a.oldString:"string"==typeof a?.TargetContent?a.TargetContent:"string"==typeof a?.targetContent?a.targetContent:void 0,u="string"==typeof a?.new_string?a.new_string:"string"==typeof a?.newString?a.newString:"string"==typeof a?.ReplacementContent?a.ReplacementContent:"string"==typeof a?.replacementContent?a.replacementContent:void 0,p=Array.isArray(a?.ReplacementChunks)?a.ReplacementChunks:void 0,m=t.diff?.diffText||("string"==typeof t.details?.diff?t.details.diff:void 0)||("string"==typeof t.details?.patch?t.details.patch:void 0),h=(0,i.Kr)(()=>m||(p&&p.length>0?p.map(e=>nx(e.TargetContent||"",e.ReplacementContent||"",o)).join("\n"):d||u?nx(d||"",u||"",o):void 0),[m,p,d,u,o]),f=t.output||"",x=(0,eK.sQ)(o),g=(0,i.Kr)(()=>d?ti(d,1e3):null,[d]),b=(0,i.Kr)(()=>u?ti(u,1e3):null,[u]),v=(0,eU.w)(),k=(0,i.Kr)(()=>g?(0,eK.wY)(g.text,x):"",[g,x,v]),y=(0,i.Kr)(()=>b?(0,eK.wY)(b.text,x):"",[b,x,v]),w=(0,i.Kr)(()=>c?c.split("\n").length:0,[c]),N=(0,i.Kr)(()=>c?(0,eK.wY)(c.split("\n").slice(0,80).join("\n"),x):"",[c,x,v]),Y=(0,i.Kr)(()=>tn(f),[f]),D=(0,i.Kr)(()=>ti(Y.content,1e3),[Y]),F=(0,i.Kr)(()=>tr(D.text,Y.format),[D,Y.format]);return(0,r.FD)("div",{className:"space-y-2.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between rounded-lg border border-ink/8 bg-paper px-3 py-2",children:[(0,r.FD)("div",{className:"flex min-w-0 items-center gap-2",children:[(0,r.Y)("span",{className:"flex h-5 w-5 shrink-0 items-center justify-center rounded bg-ink/5 text-ink/70",children:n?(0,r.Y)(np.A,{size:12}):(0,r.Y)(nm.A,{size:12})}),(0,r.Y)("span",{className:"truncate font-mono text-[11px] font-medium text-ink",children:o||"File modification"}),(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:n?"Write":"Edit"})]}),(c||u||l)&&(0,r.Y)(eg,{text:l?.text||c||u||f,className:"flex shrink-0 cursor-pointer items-center gap-1 rounded px-1.5 py-0.5 text-[10.5px] text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:11,label:"Copy"})]}),h&&(0,r.FD)("div",{className:"space-y-1",children:[(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Diff Changes"}),(0,r.Y)(eH,{text:h})]}),!h&&l&&(0,r.Y)(nh,{sections:l.sections}),!h&&(d||u)&&(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Replacement Changes"}),(0,r.FD)("div",{className:"overflow-hidden rounded-lg border border-ink/8",children:[d&&(0,r.FD)("div",{className:"border-b border-ink/6 bg-error/[0.04] p-2.5",children:[(0,r.Y)("div",{className:"mb-1 flex items-center gap-1 text-[9.5px] font-semibold uppercase tracking-wider text-error",children:(0,r.Y)("span",{children:"- Original Content"})}),g&&g.skipped>0&&(0,r.FD)("div",{className:"mb-1 font-mono text-[9.5px] text-ink/45",children:["… ",g.skipped," earlier lines hidden"]}),(0,r.Y)("pre",{className:"max-h-40 overflow-x-auto font-mono text-[11px] leading-relaxed text-error/90 whitespace-pre-wrap break-words",dangerouslySetInnerHTML:{__html:k}})]}),u&&(0,r.FD)("div",{className:"bg-success/[0.04] p-2.5",children:[(0,r.Y)("div",{className:"mb-1 flex items-center gap-1 text-[9.5px] font-semibold uppercase tracking-wider text-success",children:(0,r.Y)("span",{children:"+ Replaced With"})}),b&&b.skipped>0&&(0,r.FD)("div",{className:"mb-1 font-mono text-[9.5px] text-ink/45",children:["… ",b.skipped," earlier lines hidden"]}),(0,r.Y)("pre",{className:"max-h-48 overflow-x-auto font-mono text-[11px] leading-relaxed text-success/90 whitespace-pre-wrap break-words",dangerouslySetInnerHTML:{__html:y}})]})]})]}),!h&&!d&&!u&&c&&(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center justify-between text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:[(0,r.FD)("span",{className:"flex items-center gap-1",children:[(0,r.Y)(ey.A,{size:11}),(0,r.Y)("span",{children:"Written File Preview"})]}),(0,r.FD)("span",{className:"font-mono text-[9px] text-ink/50",children:[w," lines · ",(0,eX.z3)(c.length)]})]}),(0,r.FD)("div",{className:"flex max-h-64 items-start overflow-x-auto rounded-lg border border-ink/8 bg-paper font-mono text-[11px] leading-[20px] select-text overscroll-contain",children:[(0,r.FD)("div",{className:"sticky left-0 z-10 flex-shrink-0 select-none border-r border-ink/8 bg-canvas/60 py-2.5 pl-2.5 pr-2 text-right font-mono text-[11px] leading-[20px] tabular-nums text-ink/25","aria-hidden":"true",children:[Array.from({length:Math.min(w,80)},(e,t)=>(0,r.Y)("div",{className:"h-[20px] leading-[20px]",children:t+1},t)),w>80&&(0,r.Y)("div",{className:"h-[20px] leading-[20px]",children:"…"})]}),(0,r.Y)("div",{className:"m-0 flex-1 min-w-max overflow-visible py-2.5 pl-3 pr-4 leading-[20px] whitespace-pre text-ink/85",dangerouslySetInnerHTML:{__html:N}})]})]}),f&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5 select-text",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 mb-1.5 text-[9.5px] font-semibold uppercase tracking-wider text-ink/40",children:[(0,r.Y)(t7.A,{size:11,className:"text-success"}),(0,r.Y)("span",{children:"Execution Output"})]}),Y.envelope&&(0,r.Y)(te,{envelope:Y.envelope}),D.skipped>0&&(0,r.FD)("div",{className:"mb-1 font-mono text-[9.5px] text-ink/45",children:["… ",D.skipped," earlier lines hidden"]}),(0,r.Y)(eh.T,{content:F,className:"text-[11.5px] text-ink/85"})]})]})}function nb(e){let{value:t}=e;return Array.isArray(t)?(0,r.Y)(nv,{items:t}):(0,t3.u)(t)?(0,r.Y)(nk,{data:t}):"string"==typeof t?t.length>120||t.includes("\n")?(0,r.Y)("div",{className:"prose-content max-h-60 overflow-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 text-[12px] leading-relaxed text-ink/85 select-text",children:(0,r.Y)(eh.T,{content:t})}):(0,r.Y)("span",{className:"break-words text-[12px] leading-relaxed text-ink/85",children:t}):(0,r.Y)("span",{className:"font-mono text-[12px] text-ink/85",children:JSON.stringify(t)??""})}function nv(e){let{items:t}=e,n=t.slice(0,50);return(0,r.FD)("div",{className:"space-y-1",children:[(0,r.Y)("ol",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:n.map((e,t)=>(0,r.FD)("li",{className:"flex items-start gap-2 px-2.5 py-1.5",children:[(0,r.Y)("span",{className:"mt-0.5 flex h-4 w-4 shrink-0 items-center justify-center rounded bg-ink/5 font-mono text-[9px] text-ink/45",children:t+1}),(0,r.Y)("div",{className:"min-w-0 flex-1",children:(0,r.Y)(nb,{value:e})})]},t))}),t.length>n.length&&(0,r.FD)("div",{className:"font-mono text-[10px] text-ink/45",children:["… ",t.length-n.length," more items"]})]})}function nk(e){let{data:t}=e,n=Object.entries(t);return 0===n.length?(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-canvas/40 px-2.5 py-2 text-[11px] text-ink/45",children:"Empty object"}):(0,r.Y)("div",{className:"divide-y divide-ink/6 overflow-hidden rounded-lg border border-ink/8 bg-canvas/40",children:n.map(e=>{let[t,n]=e,i=Array.isArray(n)?`list \xb7 ${n.length}`:(0,t3.u)(n)?"json":"string"==typeof n?"markdown":typeof n;return(0,r.FD)("div",{className:"px-2.5 py-2",children:[(0,r.FD)("div",{className:"mb-1 flex items-center gap-1.5",children:[(0,r.Y)(eZ.A,{size:10.5,className:"shrink-0 text-ink/45"}),(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] font-semibold text-ink",title:t,children:t}),(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[8.5px] uppercase tracking-wider text-ink/50",children:i})]}),(0,r.Y)(nb,{value:n})]},t)})})}function ny(e){let{tool:t}=e,n="object"==typeof t.input&&null!==t.input?t.input:void 0,s="string"==typeof n?.path?n.path:t.target||"",a="string"==typeof t.name?t.name:"",l=(s?s.replace(/^xd:\/\//,""):a).replace(/^mcp__/,""),o="string"==typeof n?.content?n.content:"",c=(0,i.Kr)(()=>o?(0,eK.Bl)(o):{isValid:!1},[o]),d=c.isValid?c.data:void 0,u=(0,t3.u)(d)||Array.isArray(d),p=(0,i.Kr)(()=>t.output?(0,eK.Bl)(t.output):{isValid:!1},[t.output]),m=p.isValid?p.data:void 0,h=(0,t3.u)(m)||Array.isArray(m);return(0,r.FD)("div",{className:"space-y-2",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 rounded-lg border border-ink/8 bg-paper px-2.5 py-1.5",children:[(0,r.Y)(S.A,{size:12,className:"shrink-0 text-ink/60"}),(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] font-semibold text-ink",children:l||"MCP Tool"}),(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[8.5px] uppercase tracking-wider text-ink/50",children:"MCP"})]}),o&&u?(0,r.Y)(nb,{value:d}):o?(0,r.Y)("div",{className:"prose-content max-h-72 overflow-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 text-[12px] leading-relaxed text-ink/85 select-text",children:(0,r.Y)(eh.T,{content:o})}):null,t.output&&h?(0,r.FD)("div",{className:"space-y-1",children:[(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:"Result"}),(0,r.Y)(nb,{value:m})]}):t.output?(0,r.Y)(ts,{text:t.output}):null]})}function nw(e){if(e.target)return e.target;if(e.diff?.file)return e.diff.file;if(e.input&&"object"==typeof e.input){let t=e.input;if("string"==typeof t.path)return t.path;if("string"==typeof t.TargetFile)return t.TargetFile;if("string"==typeof t.targetFile)return t.targetFile;if("string"==typeof t.FilePath)return t.FilePath;if("string"==typeof t.filePath)return t.filePath;if("string"==typeof t.AbsolutePath)return t.AbsolutePath;if("string"==typeof t.absolutePath)return t.absolutePath;if("string"==typeof t.file)return t.file;let n=(0,nf.f$)(t);if(n)return n}return"string"==typeof e.details?.path?e.details.path:"string"==typeof e.input&&(e.input.includes(".")||e.input.includes("/"))?e.input:e.detail&&(e.detail.includes(".")||e.detail.includes("/"))?e.detail:void 0}function nN(e){let t=e.details;if(t?.xdev?.tool&&"string"==typeof t.xdev.tool)return t.xdev.tool.toLowerCase();let n=(e.target||"").toLowerCase(),r=to(e.input)?.toLowerCase()??"",i=n.startsWith("xd://")?n.slice(5):r.startsWith("xd://")?r.slice(5):"";if(i){let e=i.split(/[/?#]/)[0].trim();if(e)return e}let s=(e.name||"").toLowerCase(),a=(e.type||"").toLowerCase(),l=(e.title||"").toLowerCase();if(s&&"tool"!==s&&"custom"!==s)return s;let o=l.split(/[\s—\-:]+/)[0]?.trim();return["grep","glob","read","write","edit","bash","terminal","run_command","todo","eval","hub","lsp","github","task","resolve","reject"].includes(o)?o:a}function nY(e){let{tool:t}=e,n=nN(t);if("read"===n||"read_file"===n||"view_file"===n||"read_file_content"===n){let e=nw(t);return(0,r.Y)(nu,{tool:t,targetFilePath:e,output:t.output||""})}return"edit"===n||"write"===n||"edit_file"===n||"create_file"===n||"write_to_file"===n||"replace_file_content"===n||"multi_edit_file"===n?(0,r.Y)(ng,{tool:t}):"task"===n?(0,r.Y)(e2,{tool:t}):"todo"===n?(0,r.Y)(ta,{tool:t}):"grep"===n||"glob"===n||"ast_grep"===n?(0,r.Y)(t$,{tool:t}):"search_fs"===n?(0,r.Y)(nl,{tool:t}):"web_search"===n?(0,r.Y)(tf,{tool:t}):"bash"===n||"terminal"===n||"run_command"===n?(0,r.Y)(tS,{tool:t}):"eval"===n?(0,r.Y)(tb,{tool:t}):"lsp"===n?(0,r.Y)(tu,{tool:t}):"ast_edit"===n?(0,r.Y)(ne,{tool:t}):"resolve"===n||"reject"===n?(0,r.Y)(nt,{tool:t}):"hub"===n?(0,r.Y)(tJ,{tool:t}):"github"===n?(0,r.Y)(tw,{tool:t}):"checkpoint"===n||"rewind"===n?(0,r.Y)(tA,{tool:t}):"security_scan"===n?(0,r.Y)(tE,{tool:t}):"debug"===n?(0,r.Y)(t1,{tool:t}):"manage_skill"===n?(0,r.Y)(ns,{tool:t}):"context_notes"===n||"new_context"===n?(0,r.Y)(tU,{tool:t}):"memory_edit"===n||"retain"===n||"recall"===n||"reflect"===n||"learn"===n?(0,r.Y)(tV,{tool:t}):"goal"===n||"yield"===n?(0,r.Y)(t6,{tool:t}):"ask"===n?(0,r.Y)(no,{tool:t}):"think"===n?(0,r.Y)(nc,{tool:t}):n.startsWith("mcp__")||"string"==typeof t.name&&t.name.startsWith("mcp__")?(0,r.Y)(ny,{tool:t}):null}function nD(e){let t="object"==typeof e.input&&null!==e.input?e.input:void 0,n="string"==typeof t?.path?t.path:e.target||"",r=(n.startsWith("xd://")?n.slice(5):"string"==typeof e.name&&e.name.startsWith("mcp__")?e.name:"").split(/[/?#]/)[0].trim();return r.startsWith("mcp__")?r.slice(5):void 0}function nF(e){let t=e.details?.xdev;return t&&"object"==typeof t?t:void 0}function nA(e){let{children:t}=e;return(0,r.Y)("div",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/40",children:t})}let nS=(0,a.ph)(function(e){let t,{tool:n,isOpen:s,onToggle:a,defaultExpanded:l=!1}=e,o=nN(n),c=(0,i.Kr)(()=>null!==nY({tool:n}),[n]),d=n.command?n.command:"string"==typeof n.input?n.input:n.input&&"object"==typeof n.input?JSON.stringify(n.input,null,2):(n.target||n.detail)&&(n.target||n.detail)||"",u=n.output||(n.error?`Error: ${n.error}`:""),m=function(e){if(e.diff?.diffText)return e.diff.diffText;let t=e.details;if(t&&"object"==typeof t){if("string"==typeof t.patch)return t.patch;if("string"==typeof t.diff)return t.diff}}(n),h=(0,i.hb)(()=>{a?.(n.id)},[a,n.id]),f=(0,i.Kr)(()=>!c&&d?(0,eK.Bl)(d):null,[c,d]),x=(0,i.Kr)(()=>{let e=eO(eL(u));return!!(e&&eE(e.tag))},[u]),g="";if("lsp"===o){g="LSP";let e=nF(n);e?.args?.action&&(t=`${e.args.action}${e.args.file?` \xb7 ${e.args.file}`:""}`)}else if("ast_edit"===o){g="AST Edit";let e=nF(n);e?.args?.paths?.[0]&&(t=e.args.paths[0])}else if("resolve"===o)g="Resolve Proposal";else if("reject"===o)g="Reject Proposal";else if("yield"===o)g="error"===n.status?"Yield":u?`Yield - ${u}`:"Yield";else if("todo"===o||"todo"===n.name||"todo"===n.type||n.title&&n.title.toLowerCase().startsWith("todo")){g="Todo";let e=function(e){let t=e3(e);if(t.totalTasks>0||t.groups.length>0)return t.summaryText}(n);if(e)t=e;else if(n.title&&(n.title.includes("—")||n.title.includes(" - ")||n.title.includes(": "))){let e=n.title.split(/\s+[—\-:]\s+/).slice(1).join(" — ").trim();t=e.split(/\s*·\s*/).filter(e=>!/^0\s+(complete|in progress|pending)/i.test(e)).join(" · ")||e}}else if(nD(n)){let e="object"==typeof n.input&&null!==n.input?n.input:void 0;g=e7(nD(n));let r=function(e,t){if(e.intent)return e.intent;let n="string"==typeof t?.content?t.content:"",r=n?(0,eK.Bl)(n):{isValid:!1,data:void 0},i=r.isValid?r.data:t;if(i&&"object"==typeof i){let e=["query","q","pattern","pat","name","sql","path","symbol","url","command"].find(e=>"string"==typeof i[e]&&i[e]);if(e)return i[e]}}(n,e);r&&(t=r.length>80?`${r.slice(0,79)}…`:r)}else if(n.title&&(n.title.includes("—")||n.title.includes(" - ")||n.title.includes(": "))){let e=n.title.split(/\s+[—\-:]\s+/);g=e7(e[0].trim()),t=e.slice(1).join(" — ").trim()}else g=n.title?e7(n.title):e7(o||n.name||"Tool Call");if(("task"===o||"task"===n.name)&&!t){let e="object"==typeof n.input&&null!==n.input?n.input:void 0,r=Array.isArray(e?.tasks)?e.tasks[0]:void 0;r?.name&&(t=`${r.name}${r.agent?` \xb7 ${r.agent}`:""}`)}let b=nw(n),k=t&&!t.startsWith("xd://")?t:b&&!b.startsWith("xd://")?b:t||(n.detail&&!b?n.detail:void 0),y=n.duration||n.time,w=y||x?(0,r.FD)("span",{className:"flex items-center gap-2",children:[y?(0,r.Y)("span",{className:"font-mono text-[10px] text-ink/40",children:y}):null,x&&(0,r.FD)("span",{className:"inline-flex items-center gap-1 rounded-full bg-error/10 px-2 py-0.5 text-[10px] font-semibold text-error",children:[(0,r.Y)(e$.A,{size:10})," Reminder"]})]}):null;return(0,r.FD)(eW,{tool:n,icon:n.icon||function(e){switch(e){case"bash":case"terminal":return(0,r.Y)(ek.A,{size:14});case"edit":case"write":case"edit_file":case"create_file":case"ast_edit":return(0,r.Y)(ey.A,{size:14});case"read":case"read_file":case"view_file":return(0,r.Y)(ew.A,{size:14});case"glob":case"grep":case"search_fs":case"ast_grep":return(0,r.Y)(v.A,{size:14});case"web_search":return(0,r.Y)(T.A,{size:14});case"todo":case"task":return(0,r.Y)(eN.A,{size:14});case"eval":return(0,r.Y)(eY.A,{size:14});case"lsp":return(0,r.Y)(eD.A,{size:14});case"resolve":case"reject":return(0,r.Y)(p.A,{size:14});case"hub":return(0,r.Y)(eF.A,{size:14});case"ask":return(0,r.Y)(eA.A,{size:14});case"think":return(0,r.Y)(em.A,{size:14});case"security_scan":return(0,r.Y)(eS.A,{size:14});case"checkpoint":case"rewind":return(0,r.Y)(eC.A,{size:14});case"github":return(0,r.Y)(eT.A,{size:14});case"memory_edit":case"retain":case"recall":case"reflect":case"learn":return(0,r.Y)(z.A,{size:14});default:if(e.startsWith("mcp__"))return(0,r.Y)(S.A,{size:14});return(0,r.Y)(ez.A,{size:14})}}(o),title:g,subtitle:k,meta:w,isOpen:s,onToggle:a?h:void 0,defaultExpanded:l,alwaysExpanded:"yield"===o&&c,children:[(0,r.Y)(nY,{tool:n}),!c&&d&&(0,r.FD)("div",{className:"space-y-1.5 code-surface",children:[(0,r.FD)("div",{className:"flex items-center justify-between",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(0,r.Y)(nA,{children:"Input"}),f?.isValid&&(0,r.Y)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] uppercase tracking-wider text-ink/45",children:"JSON"})]}),(0,r.Y)(eg,{text:f?.isValid&&f.pretty?f.pretty:d,className:"flex items-center gap-1 rounded-md px-1.5 py-0.5 text-[10px] text-ink/45 transition-colors hover:bg-ink/5 hover:text-ink",onClick:e=>e.stopPropagation(),label:"Copy"})]}),f?.isValid&&f.pretty?(0,r.Y)(eQ,{jsonString:f.pretty,maxHeightClass:"max-h-60",showHeader:!1}):(0,r.Y)("pre",{className:"overflow-x-auto rounded-lg border border-ink/8 bg-paper px-3 py-2.5 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-all text-ink/80 select-text",children:d})]}),!c&&m&&(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.Y)(nA,{children:"Diff"}),(0,r.Y)(eH,{text:m})]}),!c&&u&&(0,r.Y)(ts,{text:u})]})});function nC(e){let{tools:t,title:n,defaultExpanded:s=!1}=e,a=(0,i.Kr)(()=>(t||[]).map((e,t)=>(function(e,t){if("id"in e&&e.id)return e;let n=e.title||"",r=n.toLowerCase(),i="terminal";r.includes("shell")||r.includes("command")||r.includes("bun")||r.includes("git")?i="bash":r.includes("edit")||r.includes("write")?i="edit_file":r.includes("read")||r.includes("view")||r.includes("cat")||r.includes("inspect")?i="read_file":(r.includes("search")||r.includes("find")||r.includes("grep"))&&(i="search_fs");let s=n.replace(/[^a-zA-Z0-9]/g,"-").toLowerCase()||"tool",a="type"in e&&e.type?e.type:i;return{id:`stable-tool-${t}-${s}`,type:a,title:e.title,duration:e.time,time:e.time,detail:e.detail,target:"target"in e&&e.target?e.target:"read_file"===a||"edit_file"===a||"create_file"===a?e.detail:void 0,command:e.command||("bash"===a?e.detail:void 0),output:e.output,status:e.status||"success",icon:e.icon,diff:"diff"in e?e.diff:void 0,input:"input"in e?e.input:void 0}})(e,t)),[t]),[l,o]=(0,i.J0)(()=>{let e={};return a.forEach((t,n)=>{let r=!ev(t)&&("error"===t.status||s&&0===n);e[t.id]=r}),e}),c=(0,i.hb)(e=>{o(t=>({...t,[e]:!t[e]}))},[]);return a&&0!==a.length?(0,r.FD)("div",{className:"mx-3 space-y-1.5",children:[n&&(0,r.FD)("div",{className:"flex items-center gap-2 px-1 pt-0.5",children:[(0,r.Y)("span",{className:"text-[9.5px] font-semibold uppercase tracking-[0.14em] text-ink/35",children:n}),(0,r.Y)("span",{className:"h-px flex-1 bg-ink/8"})]}),a.map(e=>(0,r.Y)(nS,{tool:e,isOpen:!!l[e.id],onToggle:c},e.id))]}):null}var nT=n("oE"),nz=n("bH"),n$=n("Sb");function nj(e){let{task:t}=e;(0,eU.w)();let n=t.structuredOutput,s=!t.formattedJson&&(0,eK.rw)(t.rawOutput),[a,l]=(0,i.J0)(n||!s?"formatted":"raw");return(0,r.FD)("div",{className:"space-y-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/8 pb-2",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5",children:[(n||!s)&&(0,r.FD)("button",{type:"button",onClick:()=>l("formatted"),className:`flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors ${"formatted"===a?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/5 hover:text-ink"}`,children:[(0,r.Y)(nz.A,{size:12}),(0,r.Y)("span",{children:n?"Overview":"Markdown"})]}),(0,r.FD)("button",{type:"button",onClick:()=>l("raw"),className:`flex items-center gap-1.5 rounded-md px-2.5 py-1 text-[11px] font-medium transition-colors ${"raw"===a?"bg-ink/10 text-ink":"text-ink/60 hover:bg-ink/5 hover:text-ink"}`,children:[(0,r.Y)(e8.A,{size:12}),(0,r.Y)("span",{children:t.formattedJson?"Raw JSON":s?"Code":"Raw Text"})]})]}),(0,r.Y)(eg,{text:t.formattedJson||t.rawOutput,className:"flex items-center gap-1 rounded-md px-2 py-1 text-[10.5px] font-medium text-ink/60 transition-colors hover:bg-ink/5 hover:text-ink",iconSize:12,title:"Copy payload",resetMs:1800,wrapLabel:!0,copiedLabelClassName:"text-success",label:"Copy"})]}),"formatted"===a&&(n?(0,r.FD)("div",{className:"space-y-3 text-[11.5px]",children:[n.summary&&(0,r.FD)("div",{className:"rounded-lg border border-ink/10 bg-canvas/60 p-2.5",children:[(0,r.FD)("div",{className:"mb-1 flex items-center gap-1.5 font-mono text-[10px] font-semibold uppercase tracking-wider text-ink/70",children:[(0,r.Y)(n$.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Summary"})]}),(0,r.Y)("div",{className:"leading-relaxed text-ink/85",children:(0,r.Y)(eh.T,{content:n.summary,className:"text-[11.5px]"})})]}),n.architecture&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5",children:[(0,r.FD)("div",{className:"mb-1 flex items-center gap-1.5 font-mono text-[10px] font-semibold text-ink/70 uppercase tracking-wider",children:[(0,r.Y)(nT.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Architecture"})]}),(0,r.Y)("p",{className:"leading-relaxed text-ink/80",children:n.architecture})]}),Array.isArray(n.files)&&n.files.length>0&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5",children:[(0,r.FD)("div",{className:"mb-2 flex items-center justify-between",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 font-mono text-[10px] font-semibold text-ink/70 uppercase tracking-wider",children:[(0,r.Y)(ey.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Files Inspected"})]}),(0,r.FD)("span",{className:"rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/50",children:[n.files.length," items"]})]}),(0,r.Y)("div",{className:"grid grid-cols-1 gap-1.5 sm:grid-cols-2",children:n.files.map((e,t)=>(0,r.FD)("div",{className:"flex flex-col justify-between rounded border border-ink/6 bg-canvas/40 p-1.5 transition-colors hover:border-ink/15",children:[(0,r.Y)("span",{className:"font-mono text-[10.5px] font-medium text-ink truncate",children:e.path}),e.description&&(0,r.Y)("span",{className:"text-[10px] text-ink/60 leading-tight line-clamp-2 mt-0.5",children:e.description})]},t))})]}),n.report&&(0,r.FD)("div",{className:"rounded-lg border border-ink/8 bg-paper p-2.5",children:[(0,r.FD)("div",{className:"mb-2 flex items-center gap-1.5 font-mono text-[10px] font-semibold text-ink/70 uppercase tracking-wider",children:[(0,r.Y)(ew.A,{size:11,className:"text-ink/60"}),(0,r.Y)("span",{children:"Report"})]}),(0,r.Y)("div",{className:"max-h-72 overflow-auto rounded border border-ink/6 bg-canvas/30 p-2 text-ink/85 scrollbar-overlay-container",children:(0,r.Y)(eh.T,{content:n.report,className:"text-[11.5px] leading-relaxed"})})]})]}):(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px] leading-relaxed text-ink/85 max-h-72 overflow-auto scrollbar-overlay-container",children:(0,r.Y)(eh.T,{content:t.rawOutput})})),"raw"===a&&(0,r.Y)("pre",{className:"max-h-64 overflow-auto rounded-lg border border-ink/8 bg-paper p-3 font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words text-ink/80 scrollbar-overlay-container scrollbar-overlay-static",dangerouslySetInnerHTML:{__html:(0,eK.wY)(t.formattedJson||t.rawOutput,t.formattedJson?"json":s?"javascript":"markdown")}}),t.outro&&(0,r.FD)("div",{className:"rounded-lg border border-ink/10 bg-canvas/60 p-2.5 text-[11px] text-ink/75",children:[(0,r.FD)("div",{className:"mb-1.5 flex items-center gap-1.5 font-mono text-[9.5px] font-semibold uppercase tracking-wider text-ink/50",children:[(0,r.Y)(ek.A,{size:11}),(0,r.Y)("span",{children:"Follow-up & Transcript"})]}),(0,r.Y)("div",{className:"text-[11.5px] leading-relaxed text-ink/85",children:(0,r.Y)(eh.T,{content:t.outro})})]})]})}function nL(e){let{notice:t}=e,[n,s]=(0,i.J0)(!1);(0,eU.w)();let a=(0,i.Kr)(()=>(function(e){let t,n,r;if(!e)return null;let i=e.match(/([\s\S]*?)<task-result\b([^>]*)>([\s\S]*?)<\/task-result>([\s\S]*)/i);if(!i)return null;let s=i[1].trim(),a=i[2],l=i[3].trim(),o=i[4].trim(),c=a.match(/\bid=["']([^"']+)["']/i)?.[1],d=a.match(/\bagent=["']([^"']+)["']/i)?.[1],u=a.match(/\bstatus=["']([^"']+)["']/i)?.[1],p=a.match(/\bduration=["']([^"']+)["']/i)?.[1],m=l.match(/<meta\b([^>]*)\/?>/i);if(m){let e=m[1],n=e.match(/\blines=["']([^"']+)["']/i)?.[1],r=e.match(/\bsize=["']([^"']+)["']/i)?.[1];(n||r)&&(t={lines:n,size:r})}let h="",f=l.match(/<output\b[^>]*>([\s\S]*?)<\/output>/i);if(f)h=f[1].trim();else{let e=l.match(/<preview\b[^>]*>([\s\S]*?)<\/preview>/i),t=e?.[1].trim();h=t||l.replace(/<meta\b[^>]*\/?>(?:\s*<\/meta>)?|<\/?preview\b[^>]*>/gi,"").trim()}if(h.startsWith("{")||h.startsWith("["))try{let e=JSON.parse(h);e&&"object"==typeof e&&!Array.isArray(e)&&(n=e,r=JSON.stringify(e,null,2))}catch{let e=function(e){let t=e;for(let e=0;e<16;e+=1){let{stack:e,inString:n,escaped:r}=function(e){let t=[],n=!1,r=!1;for(let i of e){if(n){r?r=!1:"\\"===i?r=!0:'"'===i&&(n=!1);continue}'"'===i?n=!0:"{"===i||"["===i?t.push("{"===i?"}":"]"):("}"===i||"]"===i)&&t.pop()}return{stack:t,inString:n,escaped:r}}(t),i=t;n&&(r&&(i=i.slice(0,-1)),i+='"'),i=(i=i.replace(/,\s*"[^"]*"\s*:\s*$/,"").replace(/"[^"]*"\s*:\s*$/,"").replace(/,\s*$/,"")+[...e].reverse().join("")).replace(/,\s*(?=[}\]])/g,"");try{return JSON.parse(i),i}catch{let e=t.lastIndexOf(",");if(e<=0)return null;t=t.slice(0,e)}}return null}(h);if(e){let t=JSON.parse(e);t&&"object"==typeof t&&!Array.isArray(t)&&(n=t,r=JSON.stringify(t,null,2),h=e)}}return{intro:s||(c?`Background job ${c} completed`:"System notice"),id:c,agent:d,status:u,duration:p,meta:t,rawOutput:h,formattedJson:r,structuredOutput:n,outro:o||void 0}})(t),[t]),l=(0,i.Kr)(()=>{if(!(/<\/?system-reminder[^>]*>/i.test(t)||t.includes("xd://resolve")||t.includes("`ast_edit` result")))return null;let e=t.replace(/<\/?system-reminder[^>]*>/gi,"").trim();if(!e)return null;let n=(e.split(/\r?\n/).map(e=>e.trim()).find(Boolean)??e).replace(/`([^`]+)`/g,"$1");return{content:e,title:n}},[t]),o=(0,i.Kr)(()=>{let e=t.replace(/<\/?system-notice[^>]*>/gi,"").trim(),n=e.split(/\r?\n/),r=(n.find(e=>e.trim())??"").trim(),i=n.findIndex(e=>e.trim()===r),s=n.slice(i+1).join("\n").trim(),a=(0,eK.rw)(s);return{clean:e,firstLine:r,rest:s,isCode:a}},[t]),c=a?.intro||l?.title||o.firstLine||t,d=c.length>100,p=c.slice(0,100)+(d?"...":""),m=(0,i.Kr)(()=>{if(a)return!0;let e=t.replace(/<\/?(?:system-notice|system-reminder)[^>]*>/gi,"").trim();return e.split(/\r?\n/).map(e=>e.trim()).filter(Boolean).length>1||e.length>100||c.length>100},[a,t,c]),h=(0,i.Kr)(()=>a?"failed"===a.status||"error"===a.status?{icon:(0,r.Y)(eu.A,{size:13}),badgeClass:"bg-error/10 text-error",label:"Task Result",isError:!0}:{icon:(0,r.Y)(eB.A,{size:13}),badgeClass:"bg-success/10 text-success",label:"Task Result",isError:!1}:l?{icon:(0,r.Y)(e$.A,{size:13}),badgeClass:"bg-warning/10 text-warning",label:"System Reminder",isError:!1}:{icon:(0,r.Y)(ep.A,{size:13}),badgeClass:"bg-info/10 text-info",label:"System Notice",isError:!1},[a,l]);return(0,r.FD)("div",{className:`mx-3 overflow-hidden rounded-xl border border-ink/10 bg-paper text-[12px] text-ink transition-colors ${m?"hover:border-ink/20":""} select-text`,children:[(0,r.FD)("button",{type:"button",onClick:()=>{m&&s(e=>!e)},disabled:!m,"aria-expanded":m?n:void 0,className:`flex w-full items-center gap-2.5 px-3 py-2.5 text-left transition-colors ${m?"cursor-pointer hover:bg-ink/[0.03]":"cursor-default"} focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ink/20`,children:[(0,r.Y)("span",{className:`flex h-7 w-7 shrink-0 items-center justify-center rounded-lg ${h.badgeClass}`,children:h.icon}),(0,r.FD)("span",{className:"flex min-w-0 flex-1 flex-col",children:[(0,r.FD)("span",{className:"flex flex-wrap items-center gap-2",children:[(0,r.Y)("span",{className:"truncate text-[12px] font-semibold tracking-tight text-ink",children:h.label}),a?.agent&&(0,r.FD)("span",{className:"flex items-center gap-1 rounded bg-ink/5 px-1.5 py-0.2 font-mono text-[9px] text-ink/60",children:[(0,r.Y)(A.A,{size:10}),a.agent]}),a?.status&&(0,r.FD)("span",{className:`flex items-center gap-1 rounded px-1.5 py-0.2 font-mono text-[9px] font-semibold uppercase ${h.isError?"bg-error/10 text-error":"bg-success/10 text-success"}`,children:[h.isError?(0,r.Y)(eu.A,{size:10}):(0,r.Y)(eB.A,{size:10}),a.status]}),a?.duration&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9px] text-ink/40",children:[(0,r.Y)(tx.A,{size:9}),a.duration]}),a?.meta?.size&&(0,r.FD)("span",{className:"flex items-center gap-1 font-mono text-[9px] text-ink/40",children:[(0,r.Y)(nT.A,{size:9}),a.meta.size]})]}),!n&&p&&(0,r.Y)("span",{className:"truncate font-mono text-[10.5px] text-ink/45",title:c,children:p})]}),m&&(0,r.Y)(u.A,{size:14,className:`shrink-0 text-ink/35 transition-transform duration-200 ${n?"rotate-180":""}`})]}),n&&m&&(0,r.Y)("div",{className:"border-t border-ink/8 bg-canvas/40 px-3.5 py-2.5",children:a?(0,r.Y)(nj,{task:a}):l?(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px] leading-relaxed text-ink/85",children:(0,r.Y)(eh.T,{content:l.content})}):o.isCode?(0,r.Y)("pre",{className:"max-h-56 overflow-auto font-mono text-[11px] leading-relaxed whitespace-pre-wrap break-words text-ink/75 scrollbar-overlay-container scrollbar-overlay-static",dangerouslySetInnerHTML:{__html:(0,eK.wY)(o.rest||o.clean,"javascript")}}):(0,r.Y)("div",{className:"rounded-lg border border-ink/8 bg-paper p-3 text-[11.5px] leading-relaxed text-ink/85",children:(0,r.Y)(eh.T,{content:o.clean||o.rest})})})]})}function nM(e){return!!(e.preview?.startsWith("data:image/")||e.preview?.startsWith("blob:"))||(e.type?.startsWith("image/")??!1)}function nP(e){let{src:t,name:n,onClose:s}=e,[l,o]=(0,i.J0)(!1);return(0,i.vJ)(()=>{let e=e=>{"Escape"===e.key&&s()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[s]),(0,a.d5)((0,r.Y)("div",{className:"fixed inset-0 z-[100] flex items-center justify-center bg-ink/80 backdrop-blur-sm",onClick:s,role:"dialog","aria-modal":"true","aria-label":`Preview ${n}`,children:(0,r.FD)("div",{className:"relative max-w-[90vw] max-h-[90vh] flex flex-col items-center",onClick:e=>e.stopPropagation(),children:[(0,r.Y)("button",{type:"button",onClick:s,className:"absolute -top-10 right-0 flex items-center justify-center w-8 h-8 rounded-full bg-paper/10 text-canvas hover:bg-paper/20 transition-colors",title:"Close (Esc)",children:(0,r.Y)(k.A,{size:18})}),(0,r.Y)("img",{src:t,alt:n,onClick:()=>o(e=>!e),title:l?"Zoom out":"Zoom in (click image)",className:`max-w-[90vw] max-h-[85vh] object-contain rounded-md shadow-2xl bg-canvas/5 cursor-zoom-in transition-transform ${l?"scale-150 cursor-zoom-out":"scale-100"}`}),(0,r.Y)("div",{className:"mt-3 max-w-[90vw] truncate text-[11px] font-mono text-canvas/80",children:n})]})}),document.body)}function nE(e){let{attachments:t,className:n="",onOpenFile:s}=e,[a,l]=(0,i.J0)(null);return(0,r.FD)(r.FK,{children:[t.length>0&&(0,r.Y)("div",{className:`flex flex-wrap gap-1.5 pt-2 border-t border-ink/10 ${n}`,children:t.map((e,t)=>(0,r.FD)("button",{type:"button",onClick:()=>{nM(e)&&e.preview?l(e):s?s(e):window.dispatchEvent(new CustomEvent("omp:open-file",{detail:{path:e.name??"attachment"}}))},title:nM(e)?"Preview image":"Open in editor",className:"flex items-center bg-canvas border border-ink/10 rounded-md p-0.5 pr-1.5 text-xs font-sans hover:border-ink/40 hover:bg-ink/5 hover:shadow-sm transition-all cursor-pointer group",children:[e.preview?(0,r.Y)("img",{src:e.preview,alt:"attachment preview",className:"w-5 h-5 rounded-sm object-cover mr-1.5 border border-ink/5 group-hover:scale-105 transition-transform"}):(0,r.Y)("div",{className:"w-5 h-5 flex items-center justify-center bg-ink/5 rounded-sm mr-1.5 text-ink/60",children:(0,r.Y)(er.A,{size:11})}),(0,r.Y)("span",{className:"truncate max-w-[100px] font-mono text-[10px] text-ink/80",children:e.name})]},t))}),a&&a.preview&&(0,r.Y)(nP,{src:a.preview,name:a.name??"image",onClose:()=>l(null)})]})}function nR(e){let t=e.match(/^(\s*)([a-zA-Z\u00C0-\u024F])(.*)$/s);return t?t[1]+t[2].toUpperCase()+t[3]:e}let nI=/<\/?(?:system-reminder|reminder|system-notice|task-result)\b/i,nO=["model","provider","usage","durationMs","startedAt","completedAt","thinking","toolCalls"];function nJ(e){return!("string"!=typeof e?.notice||!e.notice.trim()||nI.test(e.notice))&&nO.some(t=>void 0!==e[t]&&null!==e[t])}function n_(e){return"string"==typeof e?.notice&&!!e.notice.trim()&&!nJ(e)}function nW(e){return nJ(e)?e.notice:"string"==typeof e?.content?e.content:""}let nK=(0,a.ph)(function(e){let{msg:t,isStreaming:n=!1,onUndo:s,onNewChat:a,className:l="",isPrevAssistant:o=!1}=e,c="user"===t.role,d=n_(t),u=d?t.content:nW(t),p=(0,i.Kr)(()=>"string"==typeof u?u.trim():u,[u]),m=(0,i.Kr)(()=>"string"==typeof u?nR(u):u,[u]),h="string"==typeof u&&/[A-Za-z0-9]/.test(u);if(c){let e="agent"===t.attribution;return(0,r.FD)("div",{id:t.id,className:`flex flex-col items-end space-y-1.5 w-full max-w-full ${l}`,children:[(0,r.FD)("div",{className:"bg-paper p-3.5 sm:p-4 rounded-xl border border-ink/15 text-[13px] text-ink shadow-xs max-w-[92%] sm:max-w-[85%] break-words overflow-hidden flex flex-col space-y-2 font-sans select-text mx-3",style:{lineHeight:"var(--markdown-body-line-height)"},children:[e&&(0,r.FD)("div",{className:"flex items-center space-x-1.5 pb-1.5 mb-1 border-b border-ink/10 text-[11px] font-mono text-ink/70",children:[(0,r.Y)(A.A,{size:12,className:"text-ink shrink-0"}),(0,r.Y)("span",{className:"font-semibold text-ink",children:"Subagent Assignment"}),(0,r.Y)("span",{className:"text-[9px] uppercase tracking-wider px-1.5 py-0.5 rounded bg-ink/5 text-ink/60",children:"Delegated"})]}),(0,r.Y)(eh.T,{content:p}),(0,r.Y)(nE,{attachments:t.attachments||[],onOpenFile:e=>{window.dispatchEvent(new CustomEvent("omp:open-file",{detail:{path:e.name??"attachment",content:e.content}}))}})]}),(0,r.FD)("div",{className:"flex items-center space-x-2.5 text-[11px] text-ink/60 px-1 font-mono",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5 border-r border-ink/15 pr-2.5",children:[e?(0,r.FD)(r.FK,{children:[(0,r.Y)(A.A,{size:11,className:"text-ink/70 shrink-0"}),(0,r.Y)("span",{className:"text-[10px] uppercase font-semibold tracking-wider text-ink/60",children:"Agent"})]}):(0,r.Y)(eo.A,{size:11,className:"text-ink/70 shrink-0"}),tF(t)&&(0,r.Y)("span",{children:tF(t)})]}),(0,r.FD)("div",{className:"flex items-center space-x-1",children:[(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"Undo / Edit message",onClick:()=>{s&&s(t.id,t.content)},children:(0,r.Y)(ec.A,{size:12})}),(0,r.Y)(eg,{text:t.content,className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",iconSize:12,title:"Copy prompt"}),(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"New Chat from here",onClick:e=>{e&&e.preventDefault(),a&&a(t.content)},children:(0,r.Y)(ed.A,{size:12})})]})]})]})}let f=t.thinking||(t.monologue?{thought:t.monologue}:void 0),x=t.toolCalls||t.actions,g=t.actions2,b=t.intent?nR(t.intent.replace(/^[.\s]+/,"")):null,v=!!(x&&x.length>0),k=x?.filter(e=>"yield"===e.name||"yield"===e.type).find(e=>"error"!==e.status)?.output,y=b||(k??(x?.length===1?"Tool Execution (1 step)":`Tool Executions (${x?.length} steps)`));return(0,r.Y)("div",{id:t.id,className:`flex flex-col items-start space-y-2 w-full max-w-full transition-all ${n?"pb-10 mb-2":""} ${l}`,children:(0,r.FD)("div",{className:"w-full space-y-2.5 font-sans leading-relaxed",children:[d&&(0,r.Y)(nL,{notice:t.notice}),f&&(0,r.Y)(eb,{thinking:f,defaultExpanded:!1,showSeparator:o}),t.error&&(0,r.FD)("div",{className:"flex items-start space-x-2.5 bg-error/10 border border-error/30 rounded-lg mx-3 px-3.5 py-2.5 text-[12px] text-ink select-text",children:[(0,r.Y)(eu.A,{size:15,className:"text-error flex-shrink-0 mt-0.5"}),(0,r.FD)("div",{className:"min-w-0 flex-1 space-y-0.5",children:[(0,r.FD)("div",{className:"flex items-center space-x-2 flex-wrap",children:[(0,r.Y)("span",{className:"font-semibold text-error text-[12px] tracking-tight",children:t.error.status?`Error ${t.error.status}`:"Request Failed"}),t.error.stopReason&&(0,r.Y)("span",{className:"text-[10px] font-mono text-ink/50 bg-ink/5 px-1.5 py-0.5 rounded",children:t.error.stopReason})]}),t.error.message&&(0,r.FD)("p",{className:"text-ink/80 leading-relaxed text-[12px] font-mono whitespace-pre-wrap break-words",children:[t.error.message.split("\n").map(e=>e.trim()).filter(Boolean)[0],t.error.message.split("\n").map(e=>e.trim()).filter(Boolean).length>1&&(0,r.FD)("span",{className:"relative inline-flex items-center ml-1.5 align-middle group",children:[(0,r.Y)(ep.A,{size:13,className:"text-error/70 hover:text-error cursor-pointer transition-colors"}),(0,r.Y)("span",{className:"pointer-events-none absolute z-50 left-1/2 bottom-full mb-1.5 w-72 -translate-x-1/2 rounded-md bg-ink text-canvas p-2.5 text-[11px] font-mono leading-relaxed whitespace-pre-wrap break-words opacity-0 group-hover:opacity-100 transition-opacity duration-150 shadow-lg",children:t.error.message})]})]})]})]}),h&&(0,r.Y)("div",{className:"text-[13px] text-ink leading-relaxed font-sans bg-transparent px-3 py-1 select-text",children:(0,r.Y)(eh.T,{content:m})}),b&&!v&&(!h||!t.content.toLowerCase().includes(t.intent.toLowerCase().trim()))&&(0,r.Y)("div",{className:`leading-relaxed font-sans px-3 select-text ${h?"text-[12px] text-ink/70 py-0.5":"text-[13px] text-ink py-1"}`,children:b}),v&&(0,r.Y)(nC,{tools:x,title:y,defaultExpanded:!1}),t.systemNote&&(0,r.FD)("div",{className:"text-[12px] text-ink leading-relaxed border-l-2 border-ink/30 bg-paper/60 px-3 py-2 rounded-r-md font-mono break-words whitespace-pre-wrap select-text",children:[(0,r.Y)("span",{className:"text-[10px] text-ink/50 uppercase tracking-wider block mb-0.5 font-sans font-semibold",children:"Diagnostic Note"}),t.systemNote]}),g&&g.length>0&&(0,r.Y)(nC,{tools:g,title:`Follow-up Tools (${g.length})`,defaultExpanded:!0}),!n&&t.summary&&(0,r.FD)("div",{className:"text-[12px] text-ink bg-paper border border-ink/15 rounded-lg p-3 space-y-1 select-text font-sans",children:[(0,r.FD)("div",{className:"font-semibold text-ink flex items-center space-x-1.5 text-[12px]",children:[(0,r.Y)("span",{className:"w-1.5 h-1.5 rounded-full bg-success"}),(0,r.Y)("span",{children:"Resolution Summary"})]}),(0,r.Y)("p",{className:"text-ink/80 leading-relaxed text-[12px]",children:t.summary})]})]})})});var nU=n("Sjr"),nH=n("Sj"),nB=n("sM"),nq=n("kk");function nG(e){if("number"==typeof e?.startedAt&&Number.isFinite(e.startedAt))return e.startedAt;let t=e?.date||e?.timestamp;if(!t)return null;let n=tD(t);if(null!==n)return n;let r=new Date(t).getTime();return Number.isNaN(r)?null:r}function nV(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(!e.trim())return"";let n=t[e];return n?.trim()?n:e.trim()?e.split(/[-_\s]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" "):""}function nZ(e){let{provider:t,providerNames:n,currentModel:s,dateStr:a,durationMs:l,usage:o,content:c,msgId:d,thinkingLevel:u,onRetry:p,onNewChat:m,isMobile:h=!1}=e,[f,x]=(0,i.J0)(!1),g=()=>{x(!1),p?.(d)},b=()=>{x(!1),m?.(c)};(0,i.vJ)(()=>{if(!f)return;let e=e=>{"Escape"===e.key&&x(!1)};return document.addEventListener("keydown",e),()=>document.removeEventListener("keydown",e)},[f]);let v=function(e){if(!Number.isFinite(e)||e<1e3)return;let t=Math.floor(e/1e3),n=Math.floor(t/3600),r=Math.floor(t%3600/60),i=t%60;return n>0?`${n}h ${r}m`:r>0?`${r}m ${i}s`:`${i}s`}(l??0),y=o?.totalTokens??(o?.input??0)+(o?.output??0),w=y>0?`${(0,eX.Rk)(y)??""} tok`:"",N=t?nV(t,n):"",Y=o?.cost?.total&&o.cost.total>0?`$${o.cost.total<.01?o.cost.total.toFixed(4):o.cost.total.toFixed(3)}`:"",D=[];N&&D.push({key:"provider",content:N}),s&&D.push({key:"model",content:s,className:"font-semibold text-ink min-w-0 truncate shrink"}),u&&D.push({key:"thinking",content:(0,r.FD)("span",{className:"text-ink/60 whitespace-nowrap flex items-center space-x-1",title:`Thinking level: ${u}`,children:[(0,r.Y)(z.A,{size:11,className:"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{children:u})]})}),a&&D.push({key:"date",content:a}),v&&D.push({key:"duration",content:(0,r.FD)("span",{className:"text-ink/60 whitespace-nowrap flex items-center space-x-1",title:`Response time: ${v}`,children:[(0,r.Y)(nU.A,{size:11,className:"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{children:v})]})}),w&&D.push({key:"tokens",content:w,className:"hidden sm:inline",title:o?.cost?.total?`${w} (${Y})`:w});let F=[N,s||"Assistant",a||"Just now",w,Y].filter(Boolean).join(" • ");return h?(0,r.FD)(r.FK,{children:[(0,r.FD)("div",{className:"w-full flex items-center gap-2 text-[11px] text-ink/60 px-1 pt-0.5 font-mono min-w-0 animate-in fade-in duration-200",children:[(0,r.FD)("div",{className:"flex items-center gap-1.5 min-w-0 truncate",title:F,children:[(0,r.Y)("div",{className:"w-4 h-4 rounded flex items-center justify-center bg-ink text-canvas shadow-2xs shrink-0",children:(0,r.Y)(A.A,{size:10})}),N&&(0,r.Y)("span",{className:"shrink-0 truncate",children:N}),N&&s&&(0,r.Y)("span",{className:"text-ink/35 shrink-0",children:"•"}),s&&(0,r.Y)("span",{className:"font-semibold text-ink min-w-0 truncate",children:s}),s&&u&&(0,r.Y)("span",{className:"text-ink/35 shrink-0",children:"•"}),u&&(0,r.FD)("span",{className:"shrink-0 inline-flex items-center gap-1 text-ink/60",title:`Thinking level: ${u}`,children:[(0,r.Y)(z.A,{size:10,className:"text-ink/50"}),(0,r.Y)("span",{children:u})]})]}),(0,r.Y)("button",{type:"button","aria-label":"More actions","aria-haspopup":"dialog","aria-expanded":f,title:"More actions",onClick:()=>x(!0),className:`ml-auto shrink-0 rounded-md p-2 transition-colors cursor-pointer ${f?"text-ink bg-ink/10":"text-ink/50 hover:bg-ink/5 hover:text-ink"}`,children:(0,r.Y)(nH.A,{size:16})})]}),f&&(0,r.Y)("div",{className:"fixed inset-0 z-[70] flex items-end bg-ink/40 backdrop-blur-[1px] animate-in fade-in duration-150",role:"presentation",onClick:()=>x(!1),children:(0,r.FD)("div",{className:"w-full max-h-[80vh] overflow-y-auto rounded-t-2xl border border-ink/15 bg-paper pb-[max(0.75rem,env(safe-area-inset-bottom,0px))] shadow-2xl animate-in slide-in-from-bottom-4 duration-200",role:"dialog","aria-modal":"true","aria-labelledby":`message-actions-${d}`,onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center justify-between border-b border-ink/10 px-5 py-4",children:[(0,r.Y)("h2",{id:`message-actions-${d}`,className:"text-base font-semibold text-ink",children:"More actions"}),(0,r.Y)("button",{type:"button","aria-label":"Close more actions",title:"Close",onClick:()=>x(!1),className:"rounded-lg p-2 text-ink/50 transition-colors hover:bg-ink/5 hover:text-ink cursor-pointer",children:(0,r.Y)(k.A,{size:20})})]}),(a||v||w)&&(0,r.FD)("div",{className:"flex flex-nowrap items-center gap-3 overflow-hidden whitespace-nowrap border-b border-ink/10 px-5 py-3 text-[11px] text-ink/70",children:[a&&(0,r.FD)("span",{className:"inline-flex min-w-0 items-center gap-1.5",children:[(0,r.Y)(nB.A,{size:13,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{className:"truncate",children:a})]}),v&&(0,r.FD)("span",{className:"inline-flex shrink-0 items-center gap-1.5",title:"Response time",children:[(0,r.Y)(nU.A,{size:13,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{children:v})]}),w&&(0,r.FD)("span",{className:"inline-flex shrink-0 items-center gap-1.5",title:Y?`${w} (${Y})`:w,children:[(0,r.Y)(nq.A,{size:13,className:"shrink-0 text-ink/50"}),(0,r.Y)("span",{children:w})]})]}),(0,r.FD)("div",{className:"p-2",children:[(0,r.Y)(eg,{text:c,className:"flex min-h-12 w-full items-center gap-3 rounded-lg px-3 text-left text-sm text-ink transition-colors hover:bg-ink/5 cursor-pointer",iconSize:20,iconClassName:"shrink-0 text-ink/55",copiedIconClassName:"shrink-0 text-success",label:"Copy answer",wrapLabel:!0,onClick:()=>x(!1)}),(0,r.FD)("button",{type:"button",onClick:g,className:"flex min-h-12 w-full items-center gap-3 rounded-lg px-3 text-left text-sm text-ink transition-colors hover:bg-ink/5 cursor-pointer",children:[(0,r.Y)(tN.A,{size:20,className:"shrink-0 text-ink/55"}),(0,r.Y)("span",{children:"Retry response"})]}),(0,r.FD)("button",{type:"button",onClick:b,className:"flex min-h-12 w-full items-center gap-3 rounded-lg px-3 text-left text-sm text-ink transition-colors hover:bg-ink/5 cursor-pointer",children:[(0,r.Y)(ed.A,{size:20,className:"shrink-0 text-ink/55"}),(0,r.Y)("span",{children:"Start new chat from this answer"})]})]})]})})]}):(0,r.FD)("div",{className:"w-full flex items-center flex-nowrap space-x-2.5 text-[11px] text-ink/60 px-1 pt-0.5 font-mono min-w-0 animate-in fade-in duration-200",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5 border-r border-ink/15 pr-2.5 min-w-0 shrink overflow-hidden",title:F,children:[(0,r.Y)("div",{className:"w-4 h-4 rounded flex items-center justify-center bg-ink text-canvas shadow-2xs shrink-0",children:(0,r.Y)(A.A,{size:10})}),D.map((e,t)=>{let{key:n,content:i,className:s,title:a}=e;return(0,r.FD)("span",{className:`inline-flex items-center text-ink/60 ${"model"===n?"min-w-0 shrink":"shrink-0"} whitespace-nowrap ${s??""}`,title:a,children:[t>0&&(0,r.Y)("span",{className:"text-ink/40 mr-1.5",children:"•"}),i]},n)})]}),(0,r.FD)("div",{className:"flex items-center space-x-1 shrink-0",children:[(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"Re-run / Retry generation",onClick:g,children:(0,r.Y)(tN.A,{size:12})}),(0,r.Y)(eg,{text:c,className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",iconSize:12,title:"Copy response"}),(0,r.Y)("button",{type:"button",className:"flex items-center hover:text-ink transition-colors p-1 rounded hover:bg-ink/5 cursor-pointer",title:"New Chat from here",onClick:b,children:(0,r.Y)(ed.A,{size:12})})]})]})}function nQ(e){let{msg:t,provider:n,providerNames:i,modelName:s,modelNames:a,thinkingLevel:l,durationMs:o,onRetry:c,onNewChat:d,isMobile:u=!1}=e;return(0,r.Y)("div",{className:"mt-2",children:(0,r.Y)(nZ,{provider:t.provider||n,providerNames:i,currentModel:(t.model?a?.[t.model]??t.model:"")||s||"",thinkingLevel:t.thinkingLevel??l,dateStr:tF(t),durationMs:o??t.durationMs,usage:t.usage,content:nW(t),msgId:t.id,onRetry:c,onNewChat:d,isMobile:u})})}let nX=["Synthesizing solution","Evaluating context","Reading workspace","Planning next step","Executing diagnostics","Compiling edge routes"];function n0(e){let{modelName:t,generatingVerb:n,provider:s,providerNames:a}=e,[l,o]=(0,i.J0)(0);(0,i.vJ)(()=>{if(n)return;let e=setInterval(()=>{o(e=>(e+1)%nX.length)},2800);return()=>clearInterval(e)},[n]);let c=n?n.charAt(0).toUpperCase()+n.slice(1):nX[l],d=s?nV(s,a):"";return(0,r.FD)("div",{id:"generating-docked-indicator",className:"w-full flex items-center px-1 py-1 bg-transparent border-0 border-none text-[11px] font-mono select-none animate-in fade-in duration-200",children:[(0,r.Y)("style",{children:`
11
11
  @keyframes bounce-dot {
12
12
  0%, 100% { opacity: 0.2; transform: translateY(0); }
13
13
  50% { opacity: 1; transform: translateY(-15%); }
@@ -15,7 +15,7 @@ ${r}`}function ti(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1
15
15
  .dot-anim-1 { animation: bounce-dot 1.2s infinite both; }
16
16
  .dot-anim-2 { animation: bounce-dot 1.2s infinite both 0.2s; }
17
17
  .dot-anim-3 { animation: bounce-dot 1.2s infinite both 0.4s; }
18
- `}),(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0",children:[(0,r.FD)("div",{className:"relative w-4 h-4 rounded flex items-center justify-center shrink-0",children:[(0,r.Y)("div",{className:"absolute -inset-[1.5px] rounded-[5px] animate-spin",style:{background:"conic-gradient(from 0deg, #ff453a, #ff9f0a, #ffd60a, #30d158, #64d2ff, #0a84ff, #bf5af2, #ff375f, #ff453a)",animationDuration:"1.2s"}}),(0,r.Y)("div",{className:"relative w-full h-full rounded-[3px] bg-ink flex items-center justify-center text-canvas z-10 shadow-2xs",children:(0,r.Y)(A.A,{size:10,className:"text-canvas"})})]}),(0,r.FD)("div",{className:"flex items-center space-x-1.5 min-w-0 truncate",children:[d&&(0,r.Y)("span",{className:"text-ink/55 truncate shrink",children:d}),(0,r.Y)("span",{className:"font-semibold text-ink truncate",children:t}),(0,r.Y)("span",{className:"text-ink/40 shrink-0",children:"•"}),(0,r.FD)("span",{className:"text-ink/75 flex items-center space-x-1 shrink-0 font-medium",children:[(0,r.Y)("span",{className:"transition-all duration-300",children:c}),(0,r.FD)("span",{className:"inline-flex tracking-wider text-ink/80 ml-0.5",children:[(0,r.Y)("span",{className:"dot-anim-1 inline-block",children:"."}),(0,r.Y)("span",{className:"dot-anim-2 inline-block",children:"."}),(0,r.Y)("span",{className:"dot-anim-3 inline-block",children:"."})]})]})]})]})]})}function n1(e){let t=e.length-1;for(;t>=0&&n_(e[t]);)t--;return t}function n5(e){let t=Array(e.length),n=-1;for(let r=0;r<e.length;r++)t[r]=n,n_(e[r])||(n=r);return t}function n2(e,t){let n=e.length,r=Array(n).fill(null),i=n1(e),s=-1;for(let a=0;a<n;a++){let l=e[a];if("user"===l.role){s=-1;continue}if(n_(l)||(s=a),a!==n-1&&e[a+1]?.role!=="user"||s<0)continue;let o=e[s];t&&s===i&&"ai"===o.role||(r[a]={msg:o,ownerIndex:s,durationMs:function(e,t){var n;let r=(n=e[t],"number"==typeof n?.completedAt&&Number.isFinite(n.completedAt)?n.completedAt:nG(n));if(null===r)return null;let i=null;for(let n=t-1;n>=0;n--){if(e[n]?.role==="user"){i=nG(e[n]);break}let t=nG(e[n]);null!==t&&(i=t)}return null===i||r<=i?null:r-i}(e,s)??o.durationMs??null})}return r}function n4(e){let{className:t="",folders:n=[],selectedFolderId:s,setSelectedFolderId:a,inputValue:l,setInputValue:o,inputAttachments:h,setInputAttachments:f,onSend:x,isGenerating:g,appSettings:b={},messages:v=[],provider:k,providerNames:y,modelName:N,modelNames:w,rootPath:Y,onThinkingLevelChange:D,onModelChange:F,sessionModel:A,sessionThinkingLevel:C,accessMode:S,onAccessModeChange:T,composerModelRef:z,generatingVerb:$,variant:j="desktop"}=e,[L,M]=(0,i.J0)(!1),P=(0,i.li)(null);(0,m.W)(P,()=>M(!1));let E=(0,i.li)(null),R=(0,i.Kr)(()=>n?.find(e=>e.id===s),[n,s]),{streamingIdx:I,footers:O}=(0,i.Kr)(()=>({streamingIdx:n1(v),footers:n2(v,g)}),[v,g]);return(0,i.vJ)(()=>{E.current&&(E.current.scrollTop=E.current.scrollHeight)},[v.length]),(0,r.Y)("div",{className:`flex flex-col h-full bg-canvas ${"mobile"===j?"px-3 py-4":"p-8"} ${t}`,style:"mobile"===j?{paddingBottom:"max(1rem, env(safe-area-inset-bottom, 0px))"}:void 0,children:(0,r.FD)("div",{className:`mx-auto w-full max-w-[970px] flex flex-col min-h-0 space-y-3 ${v.length>0?"flex-1":"my-auto justify-center"}`,children:[0===v.length&&(0,r.FD)("div",{className:"relative shrink-0",ref:P,children:[(0,r.FD)("button",{type:"button",onClick:()=>M(!L),className:"group flex items-center space-x-1.5 px-1.5 py-1 rounded-md text-xs font-medium text-ink/75 hover:text-ink hover:bg-ink/5 focus-visible:bg-ink/5 transition-all outline-none cursor-pointer select-none",children:[(0,r.Y)(d.A,{size:13,className:"text-ink/50 group-hover:text-ink/80 transition-colors flex-shrink-0"}),(0,r.Y)("span",{className:"flex items-center space-x-1 max-w-[260px] truncate tracking-tight",children:(0,r.Y)("span",{children:R?R.name:"Select Workspace Context"})}),(0,r.Y)(u.A,{size:13,className:`text-ink/40 group-hover:text-ink/70 flex-shrink-0 transition-transform duration-150 ${L?"rotate-180 text-ink/70":""}`})]}),L&&(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-1.5 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg z-50 flex flex-col overflow-hidden text-xs py-1",children:[(0,r.Y)("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-ink/40 font-semibold border-b border-ink/5",children:"Target Workspace"}),(0,r.Y)("div",{className:"max-h-56 scrollbar-overlay-container scrollbar-overlay-static py-1",children:0===n.length?(0,r.Y)("div",{className:"px-3 py-2 text-ink/40 italic",children:"No workspaces available"}):n.map(e=>(0,r.FD)("button",{type:"button",onClick:()=>{a(e.id),M(!1)},className:`w-full text-left px-3 py-1.5 flex items-center justify-between transition-colors cursor-pointer ${s===e.id?"bg-ink/10 text-ink font-semibold":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[(0,r.FD)("div",{className:"flex items-center space-x-2 truncate pr-2",children:[(0,r.Y)(d.A,{size:12,className:s===e.id?"text-ink flex-shrink-0":"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{className:"truncate font-medium",children:e.name})]}),s===e.id&&(0,r.Y)(p.A,{size:12,className:"text-ink flex-shrink-0"})]},e.id))})]})]}),v.length>0&&(0,r.Y)("div",{ref:E,className:"flex-1 min-h-0 overflow-y-auto scroll-smooth overscroll-contain",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:v.map((e,t)=>{let n=v[t-1],i=g&&t===I&&"ai"===e.role,s="user"!==e.role&&n&&"user"!==n.role,a=O[t];return(0,r.FD)(c.FK,{children:[(0,r.Y)(nK,{msg:e,isStreaming:i,className:s?"mt-1":"mt-8"}),a&&(0,r.Y)(nQ,{msg:a.msg,provider:k,providerNames:y,modelName:N,modelNames:w,thinkingLevel:C??void 0,durationMs:a.durationMs})]},e.id)})})}),g&&(0,r.Y)(n0,{modelName:N,generatingVerb:$,provider:k,providerNames:y}),(0,r.Y)(el,{value:l,onChange:o,rootPath:Y,attachments:h,onAttachmentsChange:f,onSend:x,isGenerating:g,disabled:!s,className:"w-full shrink-0",appSettings:b,onThinkingLevelChange:D,onModelChange:F,sessionModel:A,sessionThinkingLevel:C,accessMode:S,onAccessModeChange:T,composerModelRef:z,variant:j})]})})}let n3=[{role:"user",width:"58%",lines:1},{role:"ai",width:"100%",lines:3},{role:"user",width:"40%",lines:1},{role:"ai",width:"92%",lines:2},{role:"user",width:"52%",lines:2},{role:"ai",width:"100%",lines:4}];function n8(e){let{row:t,index:n}=e;return(0,r.Y)("div",{className:`flex ${"user"===t.role?"justify-end":"justify-start"} mb-3`,children:(0,r.Y)("div",{className:"rounded-lg bg-ink/5 border border-ink/5 px-3 py-2 space-y-1.5",style:{width:t.width,maxWidth:"85%"},children:Array.from({length:t.lines},(e,i)=>(0,r.Y)("div",{className:"h-2.5 rounded bg-ink/8 animate-pulse",style:{width:i===t.lines-1?"62%":"100%",animationDelay:`${120*n+60*i}ms`}},i))})})}function n6(){let e=(0,i.Kr)(()=>n3,[]);return(0,r.FD)("div",{"aria-hidden":!0,className:"flex flex-col h-full min-h-0 overflow-hidden",children:[(0,r.Y)("div",{className:"flex-1 min-h-0 overflow-hidden px-3 py-3 pb-8 sm:p-4 sm:pb-10",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:e.map((e,t)=>(0,r.Y)(n8,{row:e,index:t},t))})}),(0,r.Y)("div",{className:"flex-shrink-0 px-3 pt-1 pb-3 sm:p-4 sm:pt-1",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:(0,r.FD)("div",{className:"rounded-md border border-ink/20 bg-paper p-3 space-y-2",children:[(0,r.Y)("div",{className:"h-9 rounded bg-ink/8 animate-pulse",style:{animationDelay:"720ms"}}),(0,r.FD)("div",{className:"flex items-center justify-between",children:[(0,r.Y)("div",{className:"h-5 w-28 rounded bg-ink/8 animate-pulse",style:{animationDelay:"840ms"}}),(0,r.Y)("div",{className:"h-7 w-7 rounded bg-ink/8 animate-pulse",style:{animationDelay:"960ms"}})]})]})})})]})}function n9(){return(0,r.Y)("div",{className:"flex justify-center py-2",role:"status",children:(0,r.FD)("div",{className:"flex items-center gap-1.5 text-ink/40 text-[11px] font-mono",children:[(0,r.Y)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-ink/30 animate-pulse"}),(0,r.Y)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-ink/30 animate-pulse",style:{animationDelay:"150ms"}}),(0,r.Y)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-ink/30 animate-pulse",style:{animationDelay:"300ms"}})]})})}function n7(e){let{content:t,isOmpSession:n,undoing:s,onClose:a,onConfirm:l}=e;return(0,i.vJ)(()=>{let e=e=>{"Escape"!==e.key||s||(e.preventDefault(),a())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,s]),(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/40 animate-in fade-in duration-200 p-4",onClick:s?void 0:a,role:"dialog","aria-modal":"true","aria-label":"Confirm undo",children:(0,r.FD)("div",{className:"bg-paper border border-ink/20 rounded-xl shadow-xl w-[min(94vw,420px)] overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-ink/10",children:[(0,r.Y)(ec.A,{size:16,className:"text-ink/70 shrink-0"}),(0,r.Y)("h2",{className:"text-[13px] font-semibold text-ink",children:"Undo message?"})]}),(0,r.FD)("div",{className:"px-4 py-4 space-y-3",children:[(0,r.Y)("div",{className:"rounded-lg border border-ink/10 bg-canvas/50 px-3 py-2 text-[12px] text-ink/80 leading-relaxed max-h-28 overflow-y-auto scrollbar-overlay-container",children:t||"Empty message or attachment-only prompt"}),(0,r.Y)("p",{className:"text-[11.5px] leading-relaxed text-ink/60",children:n?"The timeline and agent context rewind to before this message. Its reply and everything after it are removed; the text returns to the composer for editing.":"This message and everything after it are removed from the timeline. The text returns to the composer for editing."})]}),(0,r.FD)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[(0,r.Y)("button",{type:"button",onClick:a,disabled:s,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs disabled:opacity-40 disabled:cursor-not-allowed",children:"Cancel"}),(0,r.FD)("button",{type:"button",autoFocus:!s,onClick:l,disabled:s,className:"flex items-center gap-2 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-60 disabled:cursor-not-allowed",children:[s&&(0,r.Y)(e_.A,{size:13,className:"animate-spin shrink-0"}),s?"Rewinding…":"Undo"]})]})]})})}function re(e){let{initialContent:t,onClose:n,onSend:s,appSettings:a,accessMode:l,onAccessModeChange:o,composerModelRef:c}=e,[d,u]=(0,i.J0)(t),[p,m]=(0,i.J0)([]);return(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/40 animate-in fade-in duration-200 p-4",children:(0,r.FD)("div",{className:"bg-canvas border border-ink/15 rounded-xl shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ink/10 bg-paper",children:[(0,r.Y)("h2",{className:"text-[13px] font-semibold text-ink",children:"New Chat"}),(0,r.Y)("button",{onClick:n,className:"p-1 rounded hover:bg-ink/10 text-ink/60 hover:text-ink transition-colors",children:(0,r.Y)(k.A,{size:14})})]}),(0,r.FD)("div",{className:"p-4 flex-1 scrollbar-overlay-container scrollbar-overlay-static",children:[(0,r.Y)("p",{className:"text-xs text-ink/60 mb-3",children:"Start a new session in this workspace based on the selected message."}),(0,r.Y)(el,{value:d,onChange:u,attachments:p,onAttachmentsChange:m,onSend:e=>{s(d,e),n()},isGenerating:!1,appSettings:a,accessMode:l,onAccessModeChange:o,composerModelRef:c})]})]})})}var rt=n("Kv"),rn=n("M"),rr=n("Uo"),ri=n("T");function rs(e){if("string"==typeof e)return e;if(!Array.isArray(e))return"";let t=[];for(let n of e)(0,t3.u)(n)&&"text"===n.type&&"string"==typeof n.text&&t.push(n.text);return t.join("\n")}function ra(e,t){if(!e)return"";for(let n of t){let t=e[n];if("string"==typeof t)return t}return""}let rl=["command","cmd","CommandLine","commandLine"],ro=["path","TargetFile","targetFile","FilePath","filePath","AbsolutePath","file"],rc=new Set(["aborted","error"]);function rd(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){let t=new Date(e).getTime();return Number.isNaN(t)?void 0:t}}function ru(e){return"string"==typeof e?e:e&&"object"==typeof e?rs(e.content):""}function rp(e){let t,n=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("custom"===e.role){if("session_exit"===e.customType)return null;let t=e.content,n=("string"==typeof t?t:Array.isArray(t)?t.map(e=>e&&"object"==typeof e&&"text"===e.type?e.text??"":"").join(""):"").replace(/<\/?system-notice[^>]*>/g,"").trim();return n?{id:"string"==typeof e.id?e.id:`notice-${Date.now()}`,role:"ai",content:"",notice:n}:null}let r=function(e){let t={toolCalls:[],inlineOutputs:new Map,textParts:[]};if("string"==typeof e)return t.textParts.push(e),t;if(!Array.isArray(e))return t;for(let n of e)if((0,t3.u)(n))if("thinking"===n.type)"string"==typeof n.thinking?t.thinking=n.thinking:"string"==typeof n.text&&(t.thinking=n.text);else if("toolCall"===n.type){let e="string"==typeof n.id?n.id:`tool-${Math.random().toString(36).slice(2,10)}`,r="string"==typeof n.name?n.name:"tool",i=n.arguments??n.input,s=(0,t3.u)(i)?i:void 0,a=ra(s,rl),l=ra(s,ro)||(s?(0,nf.f$)(s):void 0),o="string"==typeof s?.i?s.i:void 0,c=a||l;t.toolCalls.push({id:e,name:r,title:c?`${r} — ${c}`:r,intent:o,target:l||void 0,command:a||void 0,input:s&&Object.keys(s).length>0?s:void 0}),o&&!t.intent&&(t.intent=o),t.inlineOutputs.set(e,"")}else if("toolResult"===n.type){let e="string"==typeof n.toolCallId?n.toolCallId:void 0,r="string"==typeof n.text?n.text:"";if(e&&t.inlineOutputs.has(e))t.inlineOutputs.set(e,r);else if(r&&t.toolCalls.length>0){let e=t.toolCalls[t.toolCalls.length-1];t.inlineOutputs.set(e.id,r)}}else"text"===n.type&&"string"==typeof n.text&&t.textParts.push(n.text);return t}(e.content),i="string"==typeof e.id?e.id:`msg-${e.timestamp??Date.now()}-ai`,s="user"===e.role?"user":"ai",a="number"==typeof e.timestamp?tY(e.timestamp):void 0,l="string"==typeof e.attribution?e.attribution:void 0,o=rd(e.timestamp)??rd(e.startedAt),c="number"==typeof e.duration?e.duration:"number"==typeof e.durationMs?e.durationMs:void 0,d=rd(e.completedAt)??(void 0!==o&&void 0!==c?o+c:void 0),u="string"==typeof e.provider?e.provider:void 0,p=-1===(t=r.textParts.findIndex(e=>{let t=eO(e);return void 0!==t&&eE(t.tag)}))?void 0:t;if("developer"===e.role||"system"===e.role||void 0!==p){let e=void 0!==p?r.textParts[p]:r.textParts.join("\n"),t=void 0!==p?e.trim():e.replace(/<\/?system-reminder[^>]*>/g,"").trim();return t?{id:i,role:"ai",date:a?`Today, ${a}`:void 0,timestamp:a,content:"",notice:t}:null}if("user"===s)return{id:i,role:s,date:a?`Today, ${a}`:void 0,timestamp:a,startedAt:o,content:function(e){let t=e.match(/(?:^|\n{2})\s*Attached file: /);if(!t||void 0===t.index)return e;let n=e.slice(0,t.index),r=e.slice(t.index+t[0].length);return/^[^\n]+\n```[a-z]*\n/.test(r)?n.trim():e}(r.textParts.join("\n")),attribution:l,attachments:(function(e){if(!Array.isArray(e))return[];let t=[],n=0;for(let r of e){if(!(0,t3.u)(r)||"image"!==r.type)continue;let e="string"==typeof r.data?r.data:void 0,i="string"==typeof r.mimeType?r.mimeType:"image/png";if(!e)continue;n+=1;let s=(i.split("/")[1]||"png").replace(/[^a-z0-9]/gi,"")||"png";t.push({id:`att-${n}`,name:`attachment-${n}.${s}`,preview:`data:${i};base64,${e}`,type:i})}return t})(e.content).map(e=>({id:e.id,name:e.name,preview:e.preview,type:e.type}))};let m=r.toolCalls.map(e=>{var t,r;let i,s,a,l;return t=e,r={streaming:n},s=t.input,a=(0,t3.u)(s)?Object.fromEntries(Object.entries(s).filter(e=>{let[t]=e;return"i"!==t})):s,l=r.isError?"error":void 0!==r.output?"success":r.streaming?"running":"success",{id:t.id,type:(i=(t.name||"").toLowerCase()).includes("bash")||i.includes("terminal")||i.includes("shell")||i.includes("run")?"bash":i.includes("write")||i.includes("edit")||i.includes("patch")||i.includes("apply")?"edit_file":i.includes("create")?"create_file":i.includes("read")||i.includes("view")||i.includes("list")?"read_file":i.includes("grep")||i.includes("glob")?"grep":i.includes("search")||i.includes("find")?"search_fs":i.includes("web")||i.includes("fetch")||i.includes("http")?"web_search":i.includes("todo")?"todo":i.includes("task")?"task":i.includes("lsp")?"lsp":i.includes("eval")?"eval":i.includes("github")?"github":i.includes("security")?"security_scan":"custom",name:t.name,title:t.title,intent:t.intent,target:t.target,command:t.command,input:a&&Object.keys(a).length>0?a:void 0,output:r.output,status:l}}),h={id:i,role:s,date:a?`Today, ${a}`:void 0,timestamp:a,attribution:l,model:"string"==typeof e.model?e.model:void 0,provider:u,startedAt:o,completedAt:d,durationMs:c,usage:e.usage&&"object"==typeof e.usage?e.usage:void 0,content:r.textParts.join("\n"),intent:r.intent,thinking:r.thinking?{thought:r.thinking,isGenerating:n}:e.thinking,toolCalls:m.length>0?m:e.toolCalls,summary:"string"==typeof e.summary?e.summary:void 0,error:e.error??function(e){let t;if("string"==typeof(t=e.stopReason)&&rc.has(t)||"number"==typeof e.errorStatus||"string"==typeof e.errorMessage)return{status:"number"==typeof e.errorStatus?e.errorStatus:void 0,id:"number"==typeof e.errorId?e.errorId:void 0,message:"string"==typeof e.errorMessage?e.errorMessage:void 0,stopReason:"string"==typeof e.stopReason?e.stopReason:void 0}}(e)};return h.content||h.thinking||h.toolCalls&&0!==h.toolCalls.length||h.intent||h.error||h.summary||h.notice?h:null}function rm(e,t){let n=[];for(let r of e){if((0,t3.u)(r)){let e="string"==typeof r.type?r.type:"";if("custom"===e||"custom_message"===e){let e="string"==typeof r.customType?r.customType:"";if("session_exit"===e)continue;if("launch-completion"===e||"string"==typeof r.content){let e=("string"==typeof r.content?r.content:"").replace(/<\/?system-notice[^>]*>/g,"").trim();e&&n.push({id:"string"==typeof r.id?r.id:`notice-${Date.now()}`,role:"ai",content:"",notice:e,date:"string"==typeof r.timestamp?new Date(r.timestamp).toISOString():void 0});continue}}if(e&&"message"!==e)continue}let e=function(e){if(!(0,t3.u)(e))return null;let t=(0,t3.u)(e.message)?e.message:null;if(!t)return e;let n={...t};return void 0===n.id&&"string"==typeof e.id&&(n.id=e.id),void 0===n.timestamp&&"number"==typeof e.timestamp&&(n.timestamp=e.timestamp),n}(r);if(!e)continue;if("toolResult"===e.role){let t="string"==typeof e.toolCallId?e.toolCallId:void 0,r=rs(e.content),i=(0,t3.u)(e.details)?e.details:void 0,s=!0===e.isError;for(let a=n.length-1;a>=0;a--){let l=n[a].toolCalls?.find(n=>t?n.id===t:n.name===e.toolName);if(l){r&&(l.output=r),i&&(l.details=i),l.status=s?"error":"success";break}}continue}let i=rp(e,t);i&&n.push(i)}return n}function rh(e,t){if(0===t.length)return e;let n=new Map(e.map((e,t)=>[e.id,t])),r=[...e];for(let e of t){let t=n.get(e.id);void 0===t?(n.set(e.id,r.length),r.push(e)):r[t]=e}return r}function rf(e,t,n){if(!(0,t3.u)(e)||!Array.isArray(e.messages))return null;let r="number"==typeof e.fromByte?e.fromByte:t;return{sessionFile:"string"==typeof e.sessionFile&&e.sessionFile?e.sessionFile:n??"",fromByte:r,nextByte:"number"==typeof e.nextByte?e.nextByte:r,reset:!0===e.reset,messages:e.messages,totalBytes:"number"==typeof e.totalBytes?e.totalBytes:void 0}}async function rx(e,t,n,r){try{let i=await fetch(`/api/agent/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_subagent_messages",subagentId:t,...n?{sessionFile:n}:{},fromByte:r})});if(!i.ok)return null;let s=await i.json().catch(()=>null),a=(0,t3.u)(s)&&"data"in s?s.data:s;return rf(a,r,n)}catch{return null}}let rg=new Map;async function rb(e,t,n){let r=`/api/sessions/${encodeURIComponent(e)}/subagents/${encodeURIComponent(t)}?fromByte=${n}`,i=rg.get(r);if(i)return i;let s=()=>{},a=new Promise(e=>{s=()=>{rg.get(r)===a&&rg.delete(r)},(async()=>{try{let t=await fetch(r);if(!t.ok)return e(null);let i=await t.json().catch(()=>null),s=(0,t3.u)(i)&&"page"in i?i.page:i;if(null==s)return e(null);e(rf(s,n,void 0))}catch{e(null)}})()});return a.then(s,s),rg.set(r,a),a}let rv={pending:"started",running:"started",completed:"completed",failed:"failed",aborted:"aborted"};function rk(e){return"completed"===e||"failed"===e||"aborted"===e}function ry(e,t){if(!e||e.id!==t.id)return t;let n={...e,...t,agent:"subagent"!==t.agent?t.agent:e.agent,index:e.index>=0?e.index:t.index,status:rk(e.status)&&!rk(t.status)?e.status:t.status},r={...e.progress,...t.progress};return Object.keys(r).length>0?n.progress=r:delete n.progress,n}function rN(e){let[t,n]=(0,i.J0)(void 0),r=(0,i.li)(e);return r.current=e,(0,i.vJ)(()=>{let e=!0,t=async()=>{try{let t=await (0,g.xo)();if(!e)return;let i=r.current(t);void 0!==i&&n(i)}catch{}};t();let i=(0,g.Sy)(t);return()=>{e=!1,i()}},[]),t}function rw(e){if(e.modelList?.length)return Object.fromEntries(e.modelList.map(e=>[e.id,e.name||e.id]))}let rY={started:"running",completed:"done",failed:"failed",aborted:"aborted"};function rD(e){let{sessionId:t,subagent:n,onBack:s,provider:a,providerNames:l,className:o=""}=e,{messages:d,isLoading:u,status:p,isActive:m}=function(e,t,n){let[r,s]=(0,i.J0)([]),[a,l]=(0,i.J0)(t),[o,c]=(0,i.J0)(!1),d=t?.id??null,u=!!(e&&d),p=(0,i.li)(0),m=(0,i.li)(e);m.current=e;let h=(0,i.li)(t);h.current=t;let f=(0,i.li)(n);f.current=n;let x=(0,i.li)(0),g=(0,i.li)(void 0),b=(0,i.li)(!1),v=(0,i.li)(!1),k=(0,i.li)(!1),y=(0,i.li)(null),N=(0,i.li)(()=>{}),w=(0,i.hb)(async()=>{let e=m.current,t=h.current;if(!e||!t||!b.current)return;if(v.current){k.current=!0;return}v.current=!0;let n=p.current;try{let r=await rx(e,t.id,g.current,x.current);if(n!==p.current||!r)return;g.current=r.sessionFile||g.current;let i=rm(r.messages,!0);r.reset?(s(i),x.current=r.nextByte):(s(e=>rh(e,i)),x.current=Math.max(x.current,r.nextByte))}finally{v.current=!1,k.current&&(k.current=!1,N.current())}},[]);return(0,i.vJ)(()=>{t&&l(e=>ry(e,t))},[t]),(0,i.vJ)(()=>{if(!u)return;let e=e=>{if("Escape"!==e.key||e.defaultPrevented)return;let t=e.target instanceof HTMLElement?e.target:null,n=t?.tagName;"INPUT"===n||"TEXTAREA"===n||t?.isContentEditable||f.current()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[u]),(0,i.vJ)(()=>{if(!e||!d){s([]),l(null),c(!1);return}let t=++p.current,n=h.current,r=()=>t===p.current,i=n?.source==="history";s([]),l(n),c(!0),x.current=0,g.current=n?.sessionFile,b.current=!1;let a=()=>{null===y.current&&(y.current=window.setTimeout(()=>{y.current=null,w()},150))};N.current=a;let o=async()=>{let t=0,a=g.current,o=i||!n?.sessionFile,u=[];for(let n=0;n<20;n++){let n=o?await rb(e,d,t):await rx(e,d,a,t);if(!r()||!n&&!o&&0===t&&(o=!0,n=await rb(e,d,0),!r()))return;if(!n)break;a=n.sessionFile||a;let i=rm(n.messages,!1);if(u=n.reset?i:rh(u,i),n.nextByte<=t||(t=n.nextByte,void 0!==n.totalBytes&&t>=n.totalBytes))break}r()&&(g.current=a,x.current=t,b.current=!o,s(e=>rh(e,u)),c(!1),o&&l(e=>e&&!rk(e.status)?{...e,status:"completed"}:e))},u=t=>{let n=t.detail;return n&&n.sessionId===e?n:null},m=e=>{let t=u(e);if(!t)return;let n=(0,ri.bH)(t.payload);n&&n.id===d&&(l(e=>ry(e,n)),a())},f=e=>{let t=u(e);if(!t)return;let n=(0,t3.u)(t.payload)?t.payload:null;if(!n)return;let r="string"==typeof n.id?n.id:null;if(r&&r!==d)return;if(!r){let e="number"==typeof n.index?n.index:null;if(null===e||e!==(h.current?.index??-1))return}let i=(0,ri.mq)(n);i&&l(e=>{if(!e||e.id!==d)return e;let t={...e,progress:{...e.progress,...i}};return i.status&&!rk(e.status)&&(t.status=rv[i.status]??e.status),t})},v=e=>{let t=u(e);if(!t)return;let n=(0,t3.u)(t.payload)?t.payload:null;n&&n.id===d&&a()};return i||(window.addEventListener("subagent_lifecycle",m),window.addEventListener("subagent_progress",f),window.addEventListener("subagent_event",v)),o(),()=>{p.current+=1,b.current=!1,null!==y.current&&(window.clearTimeout(y.current),y.current=null),i||(window.removeEventListener("subagent_lifecycle",m),window.removeEventListener("subagent_progress",f),window.removeEventListener("subagent_event",v))}},[e,d,w]),{messages:r,isLoading:o,status:a,isActive:u}}(t,n,s),h=rN(rw)??{},f=(0,i.li)(null),x=p?.status??n?.status??"started",g="started"===x;(0,i.vJ)(()=>{let e=f.current;if(!e)return;let t=requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight});return()=>cancelAnimationFrame(t)},[d.length,g]);let{streamingIdx:b,footers:v,prevNonNoticeIdx:k}=(0,i.Kr)(()=>({streamingIdx:n1(d),footers:n2(d,g),prevNonNoticeIdx:n5(d)}),[d,g]);if(!n||!m)return null;let y=p?.progress??n.progress,N=y?.resolvedModel??n.agent,w=(0,eX.Rk)(y?.tokens),Y=w?`${w} tok`:"",D=p?.task??p?.assignment??p?.description??n.task??n.assignment??n.description,F=D?D.replace(/\$0(\.00*)?/g,"").trim():void 0;return(0,r.FD)("div",{className:`flex flex-col h-full min-h-0 overflow-hidden bg-canvas ${o}`,children:[(0,r.FD)("div",{className:"flex items-center gap-2.5 border-b border-ink/15 bg-paper px-3 py-2 flex-shrink-0",children:[(0,r.Y)("button",{type:"button",onClick:s,title:"Back to session",className:"flex items-center justify-center w-7 h-7 rounded-md border border-ink/15 text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors shrink-0 cursor-pointer",children:(0,r.Y)(rt.A,{size:14})}),(0,r.Y)(rr.l,{status:x,live:g,size:12}),(0,r.Y)(A.A,{size:13,className:"text-ink/60 shrink-0"}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.FD)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.Y)("span",{className:"font-mono text-[12px] font-semibold text-ink truncate",children:p?.agent??n.agent}),(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:rY[x]})]}),(0,r.Y)("p",{className:"truncate text-[11px] text-ink/55 font-sans",children:F??"Subagent transcript"})]}),Y&&(0,r.Y)("span",{className:"hidden sm:inline shrink-0 font-mono text-[10px] text-ink/45",children:Y})]}),(0,r.Y)("div",{ref:f,className:"flex-1 min-h-0 overflow-y-auto overscroll-contain scrollbar-overlay-container timeline-scrollbar-visible p-4 pb-10",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:u&&0===d.length?(0,r.FD)("div",{className:"flex items-center justify-center gap-2 py-12 text-[11px] font-mono text-ink/50",children:[(0,r.Y)(e_.A,{size:14,className:"animate-spin"}),(0,r.Y)("span",{children:"Loading transcript…"})]}):0===d.length?(0,r.Y)("div",{className:"py-12 text-center text-[11.5px] font-mono text-ink/45",children:"No transcript messages yet."}):d.map((e,t)=>{let n=g&&t===b&&"ai"===e.role,i=k[t],s=i>=0?d[i]:null,o=!!("user"!==e.role&&s&&"user"!==s.role),u=v[t];return(0,r.FD)(c.FK,{children:[(0,r.Y)(nK,{msg:e,isStreaming:n,isPrevAssistant:o,className:n_(e)?"mt-3 mb-1":o?"mt-1":"mt-3"}),u&&(0,r.Y)(nQ,{msg:u.msg,provider:a,providerNames:l,modelName:N,modelNames:h,durationMs:u.durationMs})]},e.id)})})}),(0,r.Y)("div",{className:"flex-shrink-0 p-4 pt-1",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:(0,r.FD)("div",{className:"flex items-center justify-center gap-2 rounded-lg border border-ink/15 bg-paper px-3 py-2 text-[11px] font-mono text-ink/50 select-none",children:[(0,r.Y)(rn.A,{size:11,className:"text-ink/45"}),(0,r.Y)("span",{children:"Read-only transcript — subagents cannot receive messages"})]})})})]})}var rF=n("zi");let rA=(0,a.ph)(function(e){let{messages:t,isGenerating:n,provider:s,providerNames:a,modelName:l,modelNames:o,thinkingLevel:d,onUndo:u,onRetry:p,onNewChat:m,isMobile:h=!1}=e,{streamingIdx:f,footers:x,prevNonNoticeIdx:g}=(0,i.Kr)(()=>({streamingIdx:n1(t),footers:n2(t,n),prevNonNoticeIdx:n5(t)}),[t,n]);return(0,r.Y)(r.FK,{children:t.map((e,i)=>{let b=t[i-1],v=n&&i===f&&"ai"===e.role,k="user"!==e.role&&b&&"user"!==b.role&&!n_(b),y=g[i],N=y>=0?t[y]:null,w=!!("user"!==e.role&&N&&"user"!==N.role),Y=x[i];return(0,r.FD)(c.FK,{children:[(0,r.Y)(nK,{msg:e,isStreaming:v,onUndo:u,onNewChat:m,isPrevAssistant:w,className:n_(e)?"mt-3 mb-1":k?"mt-1":"mt-3"}),Y&&(0,r.Y)(nQ,{msg:Y.msg,provider:s,providerNames:a,modelName:l,modelNames:o,thinkingLevel:d,durationMs:Y.durationMs,onRetry:p,onNewChat:m,isMobile:h})]},e.id)})})});function rC(e){let{userMessages:t,onScrollTo:n}=e,[s,a]=(0,i.J0)(null);return 0===t.length?null:(0,r.Y)("div",{className:"absolute right-0.5 top-1/2 -translate-y-1/2 z-20 flex flex-col items-center py-4 w-6",onMouseLeave:()=>a(null),children:t.map((e,t)=>{let i=s===t;return(0,r.FD)("div",{className:"relative flex items-center justify-center w-full py-[3px] cursor-pointer",onMouseEnter:()=>a(t),onClick:()=>n(e.id),children:[(0,r.Y)("button",{className:`block h-px rounded-full transition-all duration-200 ease-out ${(e=>{if(null===s)return"w-3";let t=Math.abs(e-s);return 0===t?"w-6":1===t?"w-4":"w-3"})(t)} ${i?"bg-ink h-[2px]":"bg-ink/25"}`,"aria-label":`Jump to your message #${t+1}`}),(0,r.FD)("div",{className:`absolute right-full mr-3 top-1/2 transform -translate-y-1/2 w-64 p-3 bg-ink text-canvas text-xs rounded-md shadow-lg pointer-events-none transition-opacity duration-200 z-30 ${i?"opacity-100":"opacity-0"}`,children:[(0,r.Y)("div",{className:"line-clamp-3 whitespace-pre-wrap leading-relaxed",children:e.content}),(0,r.Y)("div",{className:"absolute top-1/2 -right-1 transform -translate-y-1/2 w-2 h-2 bg-ink rotate-45"})]})]},`minimap-${e.id}`)})})}function rS(e){let{isMobile:t,userMessages:n,onScrollTo:i,scrollRef:s,contentRef:a,handleScroll:l,isScrolling:o,loadingOlder:c,hasMore:d,loadOlderError:u,loadOlder:p,messages:m,isGenerating:h,provider:f,providerNames:x,modelName:g,modelNames:b,thinkingLevel:v,onUndo:k,onRetry:y,onNewChat:N,showScrollBottom:w,jumpToBottom:Y}=e;return(0,r.FD)(r.FK,{children:[!t&&(0,r.Y)(rC,{userMessages:n,onScrollTo:i}),(0,r.Y)("div",{ref:s,onScroll:l,className:`flex-1 scrollbar-overlay-container overscroll-contain scroll-smooth overflow-x-hidden ${t?"px-3 py-3 pb-8":"p-4 pb-10"} ${o?"timeline-scrollbar-visible":"timeline-scrollbar-hidden"}`,children:(0,r.FD)("div",{ref:a,className:"mx-auto w-full max-w-[970px]",children:[(c||d||u)&&(0,r.Y)("div",{className:"pb-1",children:c?(0,r.Y)(n9,{}):(0,r.Y)("button",{type:"button",onClick:p,className:`block mx-auto px-3 py-1 rounded-full border text-[11px] font-mono transition-colors ${u?"border-error/40 text-error hover:border-error":"border-ink/15 text-ink/50 hover:text-ink hover:border-ink/30"}`,children:u?"Failed to load — retry":"Load earlier messages"})}),(0,r.Y)(rA,{messages:m,isGenerating:h,provider:f,providerNames:x,modelName:g,modelNames:b,thinkingLevel:v,onUndo:k,onRetry:y,onNewChat:N,isMobile:t})]})}),w&&(0,r.Y)("div",{className:"absolute bottom-4 left-1/2 transform -translate-x-1/2 z-20",children:(0,r.Y)("button",{onClick:()=>Y("smooth"),className:"flex items-center justify-center w-8 h-8 rounded-full border border-ink/20 bg-paper text-ink/60 hover:text-ink hover:bg-ink/5 transition-all shadow-sm",title:"Scroll to bottom",children:(0,r.Y)(rF.A,{size:16})})})]})}var rT=n("b");let rz={steer:"steer",followup:"follow-up"};function r$(e){let{queue:t,setQueue:n,isSteering:s=!1,onEdit:a,onSendNow:l}=e,o=(0,i.li)(null),c=(0,i.li)(null),d=()=>{if(null===o.current||null===c.current)return;let e=[...t],r=e.splice(o.current,1)[0];e.splice(c.current,0,r),o.current=null,c.current=null,n(e)};if(0===t.length)return null;let u=s?"steer":"followup";return(0,r.Y)("div",{className:"max-h-[150px] scrollbar-overlay-container scrollbar-overlay-static mb-2 space-y-1",children:t.map((e,t)=>(0,r.FD)("div",{draggable:!0,onDragStart:()=>{o.current=t},onDragEnter:()=>{c.current=t},onDragEnd:d,onDragOver:e=>e.preventDefault(),className:"flex items-center gap-2 px-2 py-1.5 bg-paper border border-ink/10 rounded shadow-sm text-xs group hover:border-ink/30 transition-colors",children:[(0,r.Y)("div",{className:"cursor-grab text-ink/40 group-hover:text-ink/80",children:(0,r.Y)(Y.A,{size:14})}),(0,r.Y)("span",{className:`shrink-0 text-[9px] font-mono uppercase tracking-wider px-1 py-px rounded ${"steer"===u?"bg-error/10 text-error":"bg-ink/10 text-ink/70"}`,children:rz[u]}),(0,r.Y)("div",{className:"flex-1 truncate text-ink/80 pr-2",children:e.text||(e.attachments.length>0?`[${e.attachments.length} attachment${e.attachments.length>1?"s":""}]`:"Empty message")}),l&&"followup"===u&&(0,r.Y)("button",{onClick:()=>l(e),className:"text-ink/40 hover:text-ink/80 opacity-0 group-hover:opacity-100 transition-opacity",title:"Send Now (Steering)",children:(0,r.Y)(f.A,{size:12})}),a&&(0,r.Y)("button",{onClick:()=>a(e),className:"text-ink/40 hover:text-ink/80 opacity-0 group-hover:opacity-100 transition-opacity",title:"Edit",children:(0,r.Y)(rT.A,{size:12})}),(0,r.Y)("button",{onClick:()=>n(t=>t.filter(t=>t.id!==e.id)),className:"text-ink/40 hover:text-error opacity-0 group-hover:opacity-100 transition-opacity",title:"Remove",children:(0,r.Y)(k.A,{size:14})})]},e.id))})}function rj(e){let{isMobile:t,isGenerating:n,modelName:i,generatingVerb:s,provider:a,providerNames:l,messageQueue:o,setMessageQueue:c,onEditQueueItem:d,onSendNowQueueItem:u,steeringQueue:p,setSteeringQueue:m,inputValue:h,setInputValue:f,rootPath:x,attachments:g,setAttachments:b,onSend:v,onStop:k,appSettings:y,onThinkingLevelChange:N,onModelChange:w,accessMode:Y,onAccessModeChange:D,composerModelRef:F,sessionModel:A,sessionThinkingLevel:C,variant:S}=e;return(0,r.Y)("div",{className:`bg-transparent border-t-0 flex-shrink-0 space-y-2 ${t?"px-3 pt-1":"p-4 pt-1"}`,style:t?{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom, 0px))"}:void 0,children:(0,r.FD)("div",{className:"mx-auto w-full max-w-[970px]",children:[n&&(0,r.Y)(n0,{modelName:i,generatingVerb:s,provider:a,providerNames:l}),(0,r.Y)(r$,{queue:o,setQueue:c,onEdit:d,onSendNow:u}),(0,r.Y)(r$,{queue:p,setQueue:m,isSteering:!0}),(0,r.Y)(el,{value:h,onChange:f,rootPath:x,attachments:g,onAttachmentsChange:b,onSend:v,isGenerating:n,onStop:k,appSettings:y,onThinkingLevelChange:N,onModelChange:w,accessMode:Y,onAccessModeChange:D,composerModelRef:F,sessionModel:A,sessionThinkingLevel:C,variant:S})]})})}var rL=n("zG");function rM(e){let t,n=(0,rL.oJ)(e.name)??"",r=rL.YT[n.toLowerCase()]??n.toLowerCase(),i=(t={...(0,t3.u)(e.args)?e.args:(0,t3.u)(e.input)?e.input:{}},e.command&&void 0===(0,rL.oJ)(t.command)&&void 0===(0,rL.oJ)(t.cmd)&&(t.command=e.command),e.target&&void 0===(0,rL.oJ)(t.path)&&(t.path=e.target),t),s=(0,rL.oJ)(e.intent)??(0,rL.Up)(i,["i"]),a=function(e,t){let n=(0,rL.Up)(e,["path","target"])??(0,rL.oJ)(t.target)??(0,rL.oJ)(t.command);if(n&&n.startsWith("xd://"))return n.slice(5).split(/[/?#\s]/)[0]||void 0}(i,e);if(a){let e=a.startsWith("mcp__")?a.slice(5):void 0,t=e?`Running ${e}`:rL.Qq[a]??`Running ${a}`,n=(0,rL.qL)(e??a,function(e){let{path:t,target:n,command:r,i:i,...s}=e,a=e.content;if("string"!=typeof a)return s;try{let e=JSON.parse(a);if((0,t3.u)(e))return{...s,...e}}catch{}let l=a.trim().split("\n",1)[0]?.trim();return l?{...s,prose:l}:s}(i));return n?(0,rL.xv)(`${t} ${n}`):s?(0,rL.xv)(s):(0,rL.xv)(t)}let l=rL.K$[r]??(r?`Running ${r}`:"Working"),o=(0,rL.qL)(r,i);return o?(0,rL.xv)(`${l} ${o}`):s?(0,rL.xv)(s):(0,rL.xv)(l)}var rP=n("Kc");function rE(e,t,n){var r;for(e.set(t,{...n,output:(r=n.output).length<=2e5?r:`…[truncated]
18
+ `}),(0,r.FD)("div",{className:"flex items-center space-x-2 min-w-0",children:[(0,r.FD)("div",{className:"relative w-4 h-4 rounded flex items-center justify-center shrink-0",children:[(0,r.Y)("div",{className:"absolute -inset-[1.5px] rounded-[5px] animate-spin",style:{background:"conic-gradient(from 0deg, #ff453a, #ff9f0a, #ffd60a, #30d158, #64d2ff, #0a84ff, #bf5af2, #ff375f, #ff453a)",animationDuration:"1.2s"}}),(0,r.Y)("div",{className:"relative w-full h-full rounded-[3px] bg-ink flex items-center justify-center text-canvas z-10 shadow-2xs",children:(0,r.Y)(A.A,{size:10,className:"text-canvas"})})]}),(0,r.FD)("div",{className:"flex items-center space-x-1.5 min-w-0 truncate",children:[d&&(0,r.Y)("span",{className:"text-ink/55 truncate shrink",children:d}),(0,r.Y)("span",{className:"font-semibold text-ink truncate",children:t}),(0,r.Y)("span",{className:"text-ink/40 shrink-0",children:"•"}),(0,r.FD)("span",{className:"text-ink/75 flex items-center space-x-1 shrink-0 font-medium",children:[(0,r.Y)("span",{className:"transition-all duration-300",children:c}),(0,r.FD)("span",{className:"inline-flex tracking-wider text-ink/80 ml-0.5",children:[(0,r.Y)("span",{className:"dot-anim-1 inline-block",children:"."}),(0,r.Y)("span",{className:"dot-anim-2 inline-block",children:"."}),(0,r.Y)("span",{className:"dot-anim-3 inline-block",children:"."})]})]})]})]})]})}function n1(e){let t=e.length-1;for(;t>=0&&n_(e[t]);)t--;return t}function n5(e){let t=Array(e.length),n=-1;for(let r=0;r<e.length;r++)t[r]=n,n_(e[r])||(n=r);return t}function n2(e,t){let n=e.length,r=Array(n).fill(null),i=n1(e),s=-1;for(let a=0;a<n;a++){let l=e[a];if("user"===l.role){s=-1;continue}if(n_(l)||(s=a),a!==n-1&&e[a+1]?.role!=="user"||s<0)continue;let o=e[s];t&&s===i&&"ai"===o.role||(r[a]={msg:o,ownerIndex:s,durationMs:function(e,t){var n;let r=(n=e[t],"number"==typeof n?.completedAt&&Number.isFinite(n.completedAt)?n.completedAt:nG(n));if(null===r)return null;let i=null;for(let n=t-1;n>=0;n--){if(e[n]?.role==="user"){i=nG(e[n]);break}let t=nG(e[n]);null!==t&&(i=t)}return null===i||r<=i?null:r-i}(e,s)??o.durationMs??null})}return r}function n4(e){let{className:t="",folders:n=[],selectedFolderId:s,setSelectedFolderId:a,inputValue:l,setInputValue:o,inputAttachments:h,setInputAttachments:f,onSend:x,isGenerating:g,appSettings:b={},messages:v=[],provider:k,providerNames:y,modelName:w,modelNames:N,rootPath:Y,onThinkingLevelChange:D,onModelChange:F,sessionModel:A,sessionThinkingLevel:S,accessMode:C,onAccessModeChange:T,composerModelRef:z,generatingVerb:$,variant:j="desktop"}=e,[L,M]=(0,i.J0)(!1),P=(0,i.li)(null);(0,m.W)(P,()=>M(!1));let E=(0,i.li)(null),R=(0,i.Kr)(()=>n?.find(e=>e.id===s),[n,s]),{streamingIdx:I,footers:O}=(0,i.Kr)(()=>({streamingIdx:n1(v),footers:n2(v,g)}),[v,g]);return(0,i.vJ)(()=>{E.current&&(E.current.scrollTop=E.current.scrollHeight)},[v.length]),(0,r.Y)("div",{className:`flex flex-col h-full bg-canvas ${"mobile"===j?"px-3 py-4":"p-8"} ${t}`,style:"mobile"===j?{paddingBottom:"max(1rem, env(safe-area-inset-bottom, 0px))"}:void 0,children:(0,r.FD)("div",{className:`mx-auto w-full max-w-[970px] flex flex-col min-h-0 space-y-3 ${v.length>0?"flex-1":"my-auto justify-center"}`,children:[0===v.length&&(0,r.FD)("div",{className:"relative shrink-0",ref:P,children:[(0,r.FD)("button",{type:"button",onClick:()=>M(!L),className:"group flex items-center space-x-1.5 px-1.5 py-1 rounded-md text-xs font-medium text-ink/75 hover:text-ink hover:bg-ink/5 focus-visible:bg-ink/5 transition-all outline-none cursor-pointer select-none",children:[(0,r.Y)(d.A,{size:13,className:"text-ink/50 group-hover:text-ink/80 transition-colors flex-shrink-0"}),(0,r.Y)("span",{className:"flex items-center space-x-1 max-w-[260px] truncate tracking-tight",children:(0,r.Y)("span",{children:R?R.name:"Select Workspace Context"})}),(0,r.Y)(u.A,{size:13,className:`text-ink/40 group-hover:text-ink/70 flex-shrink-0 transition-transform duration-150 ${L?"rotate-180 text-ink/70":""}`})]}),L&&(0,r.FD)("div",{className:"absolute bottom-full left-0 mb-1.5 w-64 bg-paper border border-ink/10 rounded-lg shadow-lg z-50 flex flex-col overflow-hidden text-xs py-1",children:[(0,r.Y)("div",{className:"px-3 py-1.5 text-[10px] uppercase tracking-wider text-ink/40 font-semibold border-b border-ink/5",children:"Target Workspace"}),(0,r.Y)("div",{className:"max-h-56 scrollbar-overlay-container scrollbar-overlay-static py-1",children:0===n.length?(0,r.Y)("div",{className:"px-3 py-2 text-ink/40 italic",children:"No workspaces available"}):n.map(e=>(0,r.FD)("button",{type:"button",onClick:()=>{a(e.id),M(!1)},className:`w-full text-left px-3 py-1.5 flex items-center justify-between transition-colors cursor-pointer ${s===e.id?"bg-ink/10 text-ink font-semibold":"text-ink/80 hover:bg-ink/5 hover:text-ink"}`,children:[(0,r.FD)("div",{className:"flex items-center space-x-2 truncate pr-2",children:[(0,r.Y)(d.A,{size:12,className:s===e.id?"text-ink flex-shrink-0":"text-ink/50 flex-shrink-0"}),(0,r.Y)("span",{className:"truncate font-medium",children:e.name})]}),s===e.id&&(0,r.Y)(p.A,{size:12,className:"text-ink flex-shrink-0"})]},e.id))})]})]}),v.length>0&&(0,r.Y)("div",{ref:E,className:"flex-1 min-h-0 overflow-y-auto scroll-smooth overscroll-contain",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:v.map((e,t)=>{let n=v[t-1],i=g&&t===I&&"ai"===e.role,s="user"!==e.role&&n&&"user"!==n.role,a=O[t];return(0,r.FD)(c.FK,{children:[(0,r.Y)(nK,{msg:e,isStreaming:i,className:s?"mt-1":"mt-8"}),a&&(0,r.Y)(nQ,{msg:a.msg,provider:k,providerNames:y,modelName:w,modelNames:N,thinkingLevel:S??void 0,durationMs:a.durationMs})]},e.id)})})}),g&&(0,r.Y)(n0,{modelName:w,generatingVerb:$,provider:k,providerNames:y}),(0,r.Y)(el,{value:l,onChange:o,rootPath:Y,attachments:h,onAttachmentsChange:f,onSend:x,isGenerating:g,disabled:!s,className:"w-full shrink-0",appSettings:b,onThinkingLevelChange:D,onModelChange:F,sessionModel:A,sessionThinkingLevel:S,accessMode:C,onAccessModeChange:T,composerModelRef:z,variant:j})]})})}let n3=[{role:"user",width:"58%",lines:1},{role:"ai",width:"100%",lines:3},{role:"user",width:"40%",lines:1},{role:"ai",width:"92%",lines:2},{role:"user",width:"52%",lines:2},{role:"ai",width:"100%",lines:4}];function n8(e){let{row:t,index:n}=e;return(0,r.Y)("div",{className:`flex ${"user"===t.role?"justify-end":"justify-start"} mb-3`,children:(0,r.Y)("div",{className:"rounded-lg bg-ink/5 border border-ink/5 px-3 py-2 space-y-1.5",style:{width:t.width,maxWidth:"85%"},children:Array.from({length:t.lines},(e,i)=>(0,r.Y)("div",{className:"h-2.5 rounded bg-ink/8 animate-pulse",style:{width:i===t.lines-1?"62%":"100%",animationDelay:`${120*n+60*i}ms`}},i))})})}function n6(){let e=(0,i.Kr)(()=>n3,[]);return(0,r.FD)("div",{"aria-hidden":!0,className:"flex flex-col h-full min-h-0 overflow-hidden",children:[(0,r.Y)("div",{className:"flex-1 min-h-0 overflow-hidden px-3 py-3 pb-8 sm:p-4 sm:pb-10",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:e.map((e,t)=>(0,r.Y)(n8,{row:e,index:t},t))})}),(0,r.Y)("div",{className:"flex-shrink-0 px-3 pt-1 pb-3 sm:p-4 sm:pt-1",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:(0,r.FD)("div",{className:"rounded-md border border-ink/20 bg-paper p-3 space-y-2",children:[(0,r.Y)("div",{className:"h-9 rounded bg-ink/8 animate-pulse",style:{animationDelay:"720ms"}}),(0,r.FD)("div",{className:"flex items-center justify-between",children:[(0,r.Y)("div",{className:"h-5 w-28 rounded bg-ink/8 animate-pulse",style:{animationDelay:"840ms"}}),(0,r.Y)("div",{className:"h-7 w-7 rounded bg-ink/8 animate-pulse",style:{animationDelay:"960ms"}})]})]})})})]})}function n9(){return(0,r.Y)("div",{className:"flex justify-center py-2",role:"status",children:(0,r.FD)("div",{className:"flex items-center gap-1.5 text-ink/40 text-[11px] font-mono",children:[(0,r.Y)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-ink/30 animate-pulse"}),(0,r.Y)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-ink/30 animate-pulse",style:{animationDelay:"150ms"}}),(0,r.Y)("span",{className:"inline-block w-1.5 h-1.5 rounded-full bg-ink/30 animate-pulse",style:{animationDelay:"300ms"}})]})})}function n7(e){let{content:t,isOmpSession:n,undoing:s,onClose:a,onConfirm:l}=e;return(0,i.vJ)(()=>{let e=e=>{"Escape"!==e.key||s||(e.preventDefault(),a())};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[a,s]),(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/40 animate-in fade-in duration-200 p-4",onClick:s?void 0:a,role:"dialog","aria-modal":"true","aria-label":"Confirm undo",children:(0,r.FD)("div",{className:"bg-paper border border-ink/20 rounded-xl shadow-xl w-[min(94vw,420px)] overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-ink/10",children:[(0,r.Y)(ec.A,{size:16,className:"text-ink/70 shrink-0"}),(0,r.Y)("h2",{className:"text-[13px] font-semibold text-ink",children:"Undo message?"})]}),(0,r.FD)("div",{className:"px-4 py-4 space-y-3",children:[(0,r.Y)("div",{className:"rounded-lg border border-ink/10 bg-canvas/50 px-3 py-2 text-[12px] text-ink/80 leading-relaxed max-h-28 overflow-y-auto scrollbar-overlay-container",children:t||"Empty message or attachment-only prompt"}),(0,r.Y)("p",{className:"text-[11.5px] leading-relaxed text-ink/60",children:n?"The timeline and agent context rewind to before this message. Its reply and everything after it are removed; the text returns to the composer for editing.":"This message and everything after it are removed from the timeline. The text returns to the composer for editing."})]}),(0,r.FD)("div",{className:"flex items-center justify-end gap-2 px-4 py-3 border-t border-ink/10",children:[(0,r.Y)("button",{type:"button",onClick:a,disabled:s,className:"px-3 py-1.5 rounded border border-ink/20 text-ink/70 hover:bg-ink/5 hover:text-ink transition-colors cursor-pointer text-xs disabled:opacity-40 disabled:cursor-not-allowed",children:"Cancel"}),(0,r.FD)("button",{type:"button",autoFocus:!s,onClick:l,disabled:s,className:"flex items-center gap-2 px-3 py-1.5 rounded bg-ink text-canvas hover:bg-ink/90 transition-colors cursor-pointer text-xs font-medium disabled:opacity-60 disabled:cursor-not-allowed",children:[s&&(0,r.Y)(e_.A,{size:13,className:"animate-spin shrink-0"}),s?"Rewinding…":"Undo"]})]})]})})}function re(e){let{initialContent:t,onClose:n,onSend:s,appSettings:a,accessMode:l,onAccessModeChange:o,composerModelRef:c}=e,[d,u]=(0,i.J0)(t),[p,m]=(0,i.J0)([]);return(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/40 animate-in fade-in duration-200 p-4",children:(0,r.FD)("div",{className:"bg-canvas border border-ink/15 rounded-xl shadow-xl w-full max-w-2xl max-h-[90vh] flex flex-col overflow-hidden",onClick:e=>e.stopPropagation(),children:[(0,r.FD)("div",{className:"flex items-center justify-between px-4 py-3 border-b border-ink/10 bg-paper",children:[(0,r.Y)("h2",{className:"text-[13px] font-semibold text-ink",children:"New Chat"}),(0,r.Y)("button",{onClick:n,className:"p-1 rounded hover:bg-ink/10 text-ink/60 hover:text-ink transition-colors",children:(0,r.Y)(k.A,{size:14})})]}),(0,r.FD)("div",{className:"p-4 flex-1 scrollbar-overlay-container scrollbar-overlay-static",children:[(0,r.Y)("p",{className:"text-xs text-ink/60 mb-3",children:"Start a new session in this workspace based on the selected message."}),(0,r.Y)(el,{value:d,onChange:u,attachments:p,onAttachmentsChange:m,onSend:e=>{s(d,e),n()},isGenerating:!1,appSettings:a,accessMode:l,onAccessModeChange:o,composerModelRef:c})]})]})})}var rt=n("Kv"),rn=n("M"),rr=n("Uo"),ri=n("T");function rs(e){if("string"==typeof e)return e;if(!Array.isArray(e))return"";let t=[];for(let n of e)(0,t3.u)(n)&&"text"===n.type&&"string"==typeof n.text&&t.push(n.text);return t.join("\n")}function ra(e,t){if(!e)return"";for(let n of t){let t=e[n];if("string"==typeof t)return t}return""}let rl=["command","cmd","CommandLine","commandLine"],ro=["path","TargetFile","targetFile","FilePath","filePath","AbsolutePath","file"],rc=new Set(["aborted","error"]);function rd(e){if("number"==typeof e&&Number.isFinite(e))return e;if("string"==typeof e){let t=new Date(e).getTime();return Number.isNaN(t)?void 0:t}}function ru(e){return"string"==typeof e?e:e&&"object"==typeof e?rs(e.content):""}function rp(e){let t,n=!(arguments.length>1)||void 0===arguments[1]||arguments[1];if("custom"===e.role){if("session_exit"===e.customType)return null;let t=e.content,n=("string"==typeof t?t:Array.isArray(t)?t.map(e=>e&&"object"==typeof e&&"text"===e.type?e.text??"":"").join(""):"").replace(/<\/?system-notice[^>]*>/g,"").trim();return n?{id:"string"==typeof e.id?e.id:`notice-${Date.now()}`,role:"ai",content:"",notice:n}:null}let r=function(e){let t={toolCalls:[],inlineOutputs:new Map,textParts:[]};if("string"==typeof e)return t.textParts.push(e),t;if(!Array.isArray(e))return t;for(let n of e)if((0,t3.u)(n))if("thinking"===n.type)"string"==typeof n.thinking?t.thinking=n.thinking:"string"==typeof n.text&&(t.thinking=n.text);else if("toolCall"===n.type){let e="string"==typeof n.id?n.id:`tool-${Math.random().toString(36).slice(2,10)}`,r="string"==typeof n.name?n.name:"tool",i=n.arguments??n.input,s=(0,t3.u)(i)?i:void 0,a=ra(s,rl),l=ra(s,ro)||(s?(0,nf.f$)(s):void 0),o="string"==typeof s?.i?s.i:void 0,c=a||l;t.toolCalls.push({id:e,name:r,title:c?`${r} — ${c}`:r,intent:o,target:l||void 0,command:a||void 0,input:s&&Object.keys(s).length>0?s:void 0}),o&&!t.intent&&(t.intent=o),t.inlineOutputs.set(e,"")}else if("toolResult"===n.type){let e="string"==typeof n.toolCallId?n.toolCallId:void 0,r="string"==typeof n.text?n.text:"";if(e&&t.inlineOutputs.has(e))t.inlineOutputs.set(e,r);else if(r&&t.toolCalls.length>0){let e=t.toolCalls[t.toolCalls.length-1];t.inlineOutputs.set(e.id,r)}}else"text"===n.type&&"string"==typeof n.text&&t.textParts.push(n.text);return t}(e.content),i="string"==typeof e.id?e.id:`msg-${e.timestamp??Date.now()}-ai`,s="user"===e.role?"user":"ai",a="number"==typeof e.timestamp?tY(e.timestamp):void 0,l="string"==typeof e.attribution?e.attribution:void 0,o=rd(e.timestamp)??rd(e.startedAt),c="number"==typeof e.duration?e.duration:"number"==typeof e.durationMs?e.durationMs:void 0,d=rd(e.completedAt)??(void 0!==o&&void 0!==c?o+c:void 0),u="string"==typeof e.provider?e.provider:void 0,p=-1===(t=r.textParts.findIndex(e=>{let t=eO(e);return void 0!==t&&eE(t.tag)}))?void 0:t;if("developer"===e.role||"system"===e.role||void 0!==p){let e=void 0!==p?r.textParts[p]:r.textParts.join("\n"),t=void 0!==p?e.trim():e.replace(/<\/?system-reminder[^>]*>/g,"").trim();return t?{id:i,role:"ai",date:a?`Today, ${a}`:void 0,timestamp:a,content:"",notice:t}:null}if("user"===s)return{id:i,role:s,date:a?`Today, ${a}`:void 0,timestamp:a,startedAt:o,content:function(e){let t=e.match(/(?:^|\n{2})\s*Attached file: /);if(!t||void 0===t.index)return e;let n=e.slice(0,t.index),r=e.slice(t.index+t[0].length);return/^[^\n]+\n```[a-z]*\n/.test(r)?n.trim():e}(r.textParts.join("\n")),attribution:l,attachments:(function(e){if(!Array.isArray(e))return[];let t=[],n=0;for(let r of e){if(!(0,t3.u)(r)||"image"!==r.type)continue;let e="string"==typeof r.data?r.data:void 0,i="string"==typeof r.mimeType?r.mimeType:"image/png";if(!e)continue;n+=1;let s=(i.split("/")[1]||"png").replace(/[^a-z0-9]/gi,"")||"png";t.push({id:`att-${n}`,name:`attachment-${n}.${s}`,preview:`data:${i};base64,${e}`,type:i})}return t})(e.content).map(e=>({id:e.id,name:e.name,preview:e.preview,type:e.type}))};let m=r.toolCalls.map(e=>{var t,r;let i,s,a,l;return t=e,r={streaming:n},s=t.input,a=(0,t3.u)(s)?Object.fromEntries(Object.entries(s).filter(e=>{let[t]=e;return"i"!==t})):s,l=r.isError?"error":void 0!==r.output?"success":r.streaming?"running":"success",{id:t.id,type:(i=(t.name||"").toLowerCase()).includes("bash")||i.includes("terminal")||i.includes("shell")||i.includes("run")?"bash":i.includes("write")||i.includes("edit")||i.includes("patch")||i.includes("apply")?"edit_file":i.includes("create")?"create_file":i.includes("read")||i.includes("view")||i.includes("list")?"read_file":i.includes("grep")||i.includes("glob")?"grep":i.includes("search")||i.includes("find")?"search_fs":i.includes("web")||i.includes("fetch")||i.includes("http")?"web_search":i.includes("todo")?"todo":i.includes("task")?"task":i.includes("lsp")?"lsp":i.includes("eval")?"eval":i.includes("github")?"github":i.includes("security")?"security_scan":"custom",name:t.name,title:t.title,intent:t.intent,target:t.target,command:t.command,input:a&&Object.keys(a).length>0?a:void 0,output:r.output,status:l}}),h={id:i,role:s,date:a?`Today, ${a}`:void 0,timestamp:a,attribution:l,model:"string"==typeof e.model?e.model:void 0,provider:u,startedAt:o,completedAt:d,durationMs:c,usage:e.usage&&"object"==typeof e.usage?e.usage:void 0,content:r.textParts.join("\n"),intent:r.intent,thinking:r.thinking?{thought:r.thinking,isGenerating:n}:e.thinking,toolCalls:m.length>0?m:e.toolCalls,summary:"string"==typeof e.summary?e.summary:void 0,error:e.error??function(e){let t;if("string"==typeof(t=e.stopReason)&&rc.has(t)||"number"==typeof e.errorStatus||"string"==typeof e.errorMessage)return{status:"number"==typeof e.errorStatus?e.errorStatus:void 0,id:"number"==typeof e.errorId?e.errorId:void 0,message:"string"==typeof e.errorMessage?e.errorMessage:void 0,stopReason:"string"==typeof e.stopReason?e.stopReason:void 0}}(e)};return h.content||h.thinking||h.toolCalls&&0!==h.toolCalls.length||h.intent||h.error||h.summary||h.notice?h:null}function rm(e,t){let n=[];for(let r of e){if((0,t3.u)(r)){let e="string"==typeof r.type?r.type:"";if("custom"===e||"custom_message"===e){let e="string"==typeof r.customType?r.customType:"";if("session_exit"===e)continue;if("launch-completion"===e||"string"==typeof r.content){let e=("string"==typeof r.content?r.content:"").replace(/<\/?system-notice[^>]*>/g,"").trim();e&&n.push({id:"string"==typeof r.id?r.id:`notice-${Date.now()}`,role:"ai",content:"",notice:e,date:"string"==typeof r.timestamp?new Date(r.timestamp).toISOString():void 0});continue}}if(e&&"message"!==e)continue}let e=function(e){if(!(0,t3.u)(e))return null;let t=(0,t3.u)(e.message)?e.message:null;if(!t)return e;let n={...t};return void 0===n.id&&"string"==typeof e.id&&(n.id=e.id),void 0===n.timestamp&&"number"==typeof e.timestamp&&(n.timestamp=e.timestamp),n}(r);if(!e)continue;if("toolResult"===e.role){let t="string"==typeof e.toolCallId?e.toolCallId:void 0,r=rs(e.content),i=(0,t3.u)(e.details)?e.details:void 0,s=!0===e.isError;for(let a=n.length-1;a>=0;a--){let l=n[a].toolCalls?.find(n=>t?n.id===t:n.name===e.toolName);if(l){r&&(l.output=r),i&&(l.details=i),l.status=s?"error":"success";break}}continue}let i=rp(e,t);i&&n.push(i)}return n}function rh(e,t){if(0===t.length)return e;let n=new Map(e.map((e,t)=>[e.id,t])),r=[...e];for(let e of t){let t=n.get(e.id);void 0===t?(n.set(e.id,r.length),r.push(e)):r[t]=e}return r}function rf(e,t,n){if(!(0,t3.u)(e)||!Array.isArray(e.messages))return null;let r="number"==typeof e.fromByte?e.fromByte:t;return{sessionFile:"string"==typeof e.sessionFile&&e.sessionFile?e.sessionFile:n??"",fromByte:r,nextByte:"number"==typeof e.nextByte?e.nextByte:r,reset:!0===e.reset,messages:e.messages,totalBytes:"number"==typeof e.totalBytes?e.totalBytes:void 0}}async function rx(e,t,n,r){try{let i=await fetch(`/api/agent/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_subagent_messages",subagentId:t,...n?{sessionFile:n}:{},fromByte:r})});if(!i.ok)return null;let s=await i.json().catch(()=>null),a=(0,t3.u)(s)&&"data"in s?s.data:s;return rf(a,r,n)}catch{return null}}let rg=new Map;async function rb(e,t,n){let r=`/api/sessions/${encodeURIComponent(e)}/subagents/${encodeURIComponent(t)}?fromByte=${n}`,i=rg.get(r);if(i)return i;let s=()=>{},a=new Promise(e=>{s=()=>{rg.get(r)===a&&rg.delete(r)},(async()=>{try{let t=await fetch(r);if(!t.ok)return e(null);let i=await t.json().catch(()=>null),s=(0,t3.u)(i)&&"page"in i?i.page:i;if(null==s)return e(null);e(rf(s,n,void 0))}catch{e(null)}})()});return a.then(s,s),rg.set(r,a),a}let rv={pending:"started",running:"started",completed:"completed",failed:"failed",aborted:"aborted"};function rk(e){return"completed"===e||"failed"===e||"aborted"===e}function ry(e,t){if(!e||e.id!==t.id)return t;let n={...e,...t,agent:"subagent"!==t.agent?t.agent:e.agent,index:e.index>=0?e.index:t.index,status:rk(e.status)&&!rk(t.status)?e.status:t.status},r={...e.progress,...t.progress};return Object.keys(r).length>0?n.progress=r:delete n.progress,n}function rw(e){let[t,n]=(0,i.J0)(void 0),r=(0,i.li)(e);return r.current=e,(0,i.vJ)(()=>{let e=!0,t=async()=>{try{let t=await (0,g.xo)();if(!e)return;let i=r.current(t);void 0!==i&&n(i)}catch{}};t();let i=(0,g.Sy)(t);return()=>{e=!1,i()}},[]),t}function rN(e){if(e.modelList?.length)return Object.fromEntries(e.modelList.map(e=>[e.id,e.name||e.id]))}let rY={started:"running",completed:"done",failed:"failed",aborted:"aborted"};function rD(e){let{sessionId:t,subagent:n,onBack:s,provider:a,providerNames:l,className:o=""}=e,{messages:d,isLoading:u,status:p,isActive:m}=function(e,t,n){let[r,s]=(0,i.J0)([]),[a,l]=(0,i.J0)(t),[o,c]=(0,i.J0)(!1),d=t?.id??null,u=!!(e&&d),p=(0,i.li)(0),m=(0,i.li)(e);m.current=e;let h=(0,i.li)(t);h.current=t;let f=(0,i.li)(n);f.current=n;let x=(0,i.li)(0),g=(0,i.li)(void 0),b=(0,i.li)(!1),v=(0,i.li)(!1),k=(0,i.li)(!1),y=(0,i.li)(null),w=(0,i.li)(()=>{}),N=(0,i.hb)(async()=>{let e=m.current,t=h.current;if(!e||!t||!b.current)return;if(v.current){k.current=!0;return}v.current=!0;let n=p.current;try{let r=await rx(e,t.id,g.current,x.current);if(n!==p.current||!r)return;g.current=r.sessionFile||g.current;let i=rm(r.messages,!0);r.reset?(s(i),x.current=r.nextByte):(s(e=>rh(e,i)),x.current=Math.max(x.current,r.nextByte))}finally{v.current=!1,k.current&&(k.current=!1,w.current())}},[]);return(0,i.vJ)(()=>{t&&l(e=>ry(e,t))},[t]),(0,i.vJ)(()=>{if(!u)return;let e=e=>{if("Escape"!==e.key||e.defaultPrevented)return;let t=e.target instanceof HTMLElement?e.target:null,n=t?.tagName;"INPUT"===n||"TEXTAREA"===n||t?.isContentEditable||f.current()};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[u]),(0,i.vJ)(()=>{if(!e||!d){s([]),l(null),c(!1);return}let t=++p.current,n=h.current,r=()=>t===p.current,i=n?.source==="history";s([]),l(n),c(!0),x.current=0,g.current=n?.sessionFile,b.current=!1;let a=()=>{null===y.current&&(y.current=window.setTimeout(()=>{y.current=null,N()},150))};w.current=a;let o=async()=>{let t=0,a=g.current,o=i||!n?.sessionFile,u=[];for(let n=0;n<20;n++){let n=o?await rb(e,d,t):await rx(e,d,a,t);if(!r()||!n&&!o&&0===t&&(o=!0,n=await rb(e,d,0),!r()))return;if(!n)break;a=n.sessionFile||a;let i=rm(n.messages,!1);if(u=n.reset?i:rh(u,i),n.nextByte<=t||(t=n.nextByte,void 0!==n.totalBytes&&t>=n.totalBytes))break}r()&&(g.current=a,x.current=t,b.current=!o,s(e=>rh(e,u)),c(!1),o&&l(e=>e&&!rk(e.status)?{...e,status:"completed"}:e))},u=t=>{let n=t.detail;return n&&n.sessionId===e?n:null},m=e=>{let t=u(e);if(!t)return;let n=(0,ri.bH)(t.payload);n&&n.id===d&&(l(e=>ry(e,n)),a())},f=e=>{let t=u(e);if(!t)return;let n=(0,t3.u)(t.payload)?t.payload:null;if(!n)return;let r="string"==typeof n.id?n.id:null;if(r&&r!==d)return;if(!r){let e="number"==typeof n.index?n.index:null;if(null===e||e!==(h.current?.index??-1))return}let i=(0,ri.mq)(n);i&&l(e=>{if(!e||e.id!==d)return e;let t={...e,progress:{...e.progress,...i}};return i.status&&!rk(e.status)&&(t.status=rv[i.status]??e.status),t})},v=e=>{let t=u(e);if(!t)return;let n=(0,t3.u)(t.payload)?t.payload:null;n&&n.id===d&&a()};return i||(window.addEventListener("subagent_lifecycle",m),window.addEventListener("subagent_progress",f),window.addEventListener("subagent_event",v)),o(),()=>{p.current+=1,b.current=!1,null!==y.current&&(window.clearTimeout(y.current),y.current=null),i||(window.removeEventListener("subagent_lifecycle",m),window.removeEventListener("subagent_progress",f),window.removeEventListener("subagent_event",v))}},[e,d,N]),{messages:r,isLoading:o,status:a,isActive:u}}(t,n,s),h=rw(rN)??{},f=(0,i.li)(null),x=p?.status??n?.status??"started",g="started"===x;(0,i.vJ)(()=>{let e=f.current;if(!e)return;let t=requestAnimationFrame(()=>{e.scrollTop=e.scrollHeight});return()=>cancelAnimationFrame(t)},[d.length,g]);let{streamingIdx:b,footers:v,prevNonNoticeIdx:k}=(0,i.Kr)(()=>({streamingIdx:n1(d),footers:n2(d,g),prevNonNoticeIdx:n5(d)}),[d,g]);if(!n||!m)return null;let y=p?.progress??n.progress,w=y?.resolvedModel??n.agent,N=(0,eX.Rk)(y?.tokens),Y=N?`${N} tok`:"",D=p?.task??p?.assignment??p?.description??n.task??n.assignment??n.description,F=D?D.replace(/\$0(\.00*)?/g,"").trim():void 0;return(0,r.FD)("div",{className:`flex flex-col h-full min-h-0 overflow-hidden bg-canvas ${o}`,children:[(0,r.FD)("div",{className:"flex items-center gap-2.5 border-b border-ink/15 bg-paper px-3 py-2 flex-shrink-0",children:[(0,r.Y)("button",{type:"button",onClick:s,title:"Back to session",className:"flex items-center justify-center w-7 h-7 rounded-md border border-ink/15 text-ink/70 hover:text-ink hover:bg-ink/5 transition-colors shrink-0 cursor-pointer",children:(0,r.Y)(rt.A,{size:14})}),(0,r.Y)(rr.l,{status:x,live:g,size:12}),(0,r.Y)(A.A,{size:13,className:"text-ink/60 shrink-0"}),(0,r.FD)("div",{className:"min-w-0 flex-1",children:[(0,r.FD)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,r.Y)("span",{className:"font-mono text-[12px] font-semibold text-ink truncate",children:p?.agent??n.agent}),(0,r.Y)("span",{className:"shrink-0 rounded bg-ink/5 px-1.5 py-0.5 font-mono text-[9px] uppercase tracking-wider text-ink/50",children:rY[x]})]}),(0,r.Y)("p",{className:"truncate text-[11px] text-ink/55 font-sans",children:F??"Subagent transcript"})]}),Y&&(0,r.Y)("span",{className:"hidden sm:inline shrink-0 font-mono text-[10px] text-ink/45",children:Y})]}),(0,r.Y)("div",{ref:f,className:"flex-1 min-h-0 overflow-y-auto overscroll-contain scrollbar-overlay-container timeline-scrollbar-visible p-4 pb-10",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:u&&0===d.length?(0,r.FD)("div",{className:"flex items-center justify-center gap-2 py-12 text-[11px] font-mono text-ink/50",children:[(0,r.Y)(e_.A,{size:14,className:"animate-spin"}),(0,r.Y)("span",{children:"Loading transcript…"})]}):0===d.length?(0,r.Y)("div",{className:"py-12 text-center text-[11.5px] font-mono text-ink/45",children:"No transcript messages yet."}):d.map((e,t)=>{let n=g&&t===b&&"ai"===e.role,i=k[t],s=i>=0?d[i]:null,o=!!("user"!==e.role&&s&&"user"!==s.role),u=v[t];return(0,r.FD)(c.FK,{children:[(0,r.Y)(nK,{msg:e,isStreaming:n,isPrevAssistant:o,className:n_(e)?"mt-3 mb-1":o?"mt-1":"mt-3"}),u&&(0,r.Y)(nQ,{msg:u.msg,provider:a,providerNames:l,modelName:w,modelNames:h,durationMs:u.durationMs})]},e.id)})})}),(0,r.Y)("div",{className:"flex-shrink-0 p-4 pt-1",children:(0,r.Y)("div",{className:"mx-auto w-full max-w-[970px]",children:(0,r.FD)("div",{className:"flex items-center justify-center gap-2 rounded-lg border border-ink/15 bg-paper px-3 py-2 text-[11px] font-mono text-ink/50 select-none",children:[(0,r.Y)(rn.A,{size:11,className:"text-ink/45"}),(0,r.Y)("span",{children:"Read-only transcript — subagents cannot receive messages"})]})})})]})}var rF=n("zi");let rA=(0,a.ph)(function(e){let{messages:t,isGenerating:n,provider:s,providerNames:a,modelName:l,modelNames:o,thinkingLevel:d,onUndo:u,onRetry:p,onNewChat:m,isMobile:h=!1}=e,{streamingIdx:f,footers:x,prevNonNoticeIdx:g}=(0,i.Kr)(()=>({streamingIdx:n1(t),footers:n2(t,n),prevNonNoticeIdx:n5(t)}),[t,n]);return(0,r.Y)(r.FK,{children:t.map((e,i)=>{let b=t[i-1],v=n&&i===f&&"ai"===e.role,k="user"!==e.role&&b&&"user"!==b.role&&!n_(b),y=g[i],w=y>=0?t[y]:null,N=!!("user"!==e.role&&w&&"user"!==w.role),Y=x[i];return(0,r.FD)(c.FK,{children:[(0,r.Y)(nK,{msg:e,isStreaming:v,onUndo:u,onNewChat:m,isPrevAssistant:N,className:n_(e)?"mt-3 mb-1":k?"mt-1":"mt-3"}),Y&&(0,r.Y)(nQ,{msg:Y.msg,provider:s,providerNames:a,modelName:l,modelNames:o,thinkingLevel:d,durationMs:Y.durationMs,onRetry:p,onNewChat:m,isMobile:h})]},e.id)})})});function rS(e){let{userMessages:t,onScrollTo:n}=e,[s,a]=(0,i.J0)(null);return 0===t.length?null:(0,r.Y)("div",{className:"absolute right-0.5 top-1/2 -translate-y-1/2 z-20 flex flex-col items-center py-4 w-6",onMouseLeave:()=>a(null),children:t.map((e,t)=>{let i=s===t;return(0,r.FD)("div",{className:"relative flex items-center justify-center w-full py-[3px] cursor-pointer",onMouseEnter:()=>a(t),onClick:()=>n(e.id),children:[(0,r.Y)("button",{className:`block h-px rounded-full transition-all duration-200 ease-out ${(e=>{if(null===s)return"w-3";let t=Math.abs(e-s);return 0===t?"w-6":1===t?"w-4":"w-3"})(t)} ${i?"bg-ink h-[2px]":"bg-ink/25"}`,"aria-label":`Jump to your message #${t+1}`}),(0,r.FD)("div",{className:`absolute right-full mr-3 top-1/2 transform -translate-y-1/2 w-64 p-3 bg-ink text-canvas text-xs rounded-md shadow-lg pointer-events-none transition-opacity duration-200 z-30 ${i?"opacity-100":"opacity-0"}`,children:[(0,r.Y)("div",{className:"line-clamp-3 whitespace-pre-wrap leading-relaxed",children:e.content}),(0,r.Y)("div",{className:"absolute top-1/2 -right-1 transform -translate-y-1/2 w-2 h-2 bg-ink rotate-45"})]})]},`minimap-${e.id}`)})})}function rC(e){let{isMobile:t,userMessages:n,onScrollTo:i,scrollRef:s,contentRef:a,handleScroll:l,isScrolling:o,loadingOlder:c,hasMore:d,loadOlderError:u,loadOlder:p,messages:m,isGenerating:h,provider:f,providerNames:x,modelName:g,modelNames:b,thinkingLevel:v,onUndo:k,onRetry:y,onNewChat:w,showScrollBottom:N,jumpToBottom:Y}=e;return(0,r.FD)(r.FK,{children:[!t&&(0,r.Y)(rS,{userMessages:n,onScrollTo:i}),(0,r.Y)("div",{ref:s,onScroll:l,className:`flex-1 scrollbar-overlay-container overscroll-contain scroll-smooth overflow-x-hidden ${t?"px-3 py-3 pb-8":"p-4 pb-10"} ${o?"timeline-scrollbar-visible":"timeline-scrollbar-hidden"}`,children:(0,r.FD)("div",{ref:a,className:"mx-auto w-full max-w-[970px]",children:[(c||d||u)&&(0,r.Y)("div",{className:"pb-1",children:c?(0,r.Y)(n9,{}):(0,r.Y)("button",{type:"button",onClick:p,className:`block mx-auto px-3 py-1 rounded-full border text-[11px] font-mono transition-colors ${u?"border-error/40 text-error hover:border-error":"border-ink/15 text-ink/50 hover:text-ink hover:border-ink/30"}`,children:u?"Failed to load — retry":"Load earlier messages"})}),(0,r.Y)(rA,{messages:m,isGenerating:h,provider:f,providerNames:x,modelName:g,modelNames:b,thinkingLevel:v,onUndo:k,onRetry:y,onNewChat:w,isMobile:t})]})}),N&&(0,r.Y)("div",{className:"absolute bottom-4 left-1/2 transform -translate-x-1/2 z-20",children:(0,r.Y)("button",{onClick:()=>Y("smooth"),className:"flex items-center justify-center w-8 h-8 rounded-full border border-ink/20 bg-paper text-ink/60 hover:text-ink hover:bg-ink/5 transition-all shadow-sm",title:"Scroll to bottom",children:(0,r.Y)(rF.A,{size:16})})})]})}var rT=n("b");let rz={steer:"steer",followup:"follow-up"};function r$(e){let{queue:t,setQueue:n,isSteering:s=!1,onEdit:a,onSendNow:l}=e,o=(0,i.li)(null),c=(0,i.li)(null),d=()=>{if(null===o.current||null===c.current)return;let e=[...t],r=e.splice(o.current,1)[0];e.splice(c.current,0,r),o.current=null,c.current=null,n(e)};if(0===t.length)return null;let u=s?"steer":"followup";return(0,r.Y)("div",{className:"max-h-[150px] scrollbar-overlay-container scrollbar-overlay-static mb-2 space-y-1",children:t.map((e,t)=>(0,r.FD)("div",{draggable:!0,onDragStart:()=>{o.current=t},onDragEnter:()=>{c.current=t},onDragEnd:d,onDragOver:e=>e.preventDefault(),className:"flex items-center gap-2 px-2 py-1.5 bg-paper border border-ink/10 rounded shadow-sm text-xs group hover:border-ink/30 transition-colors",children:[(0,r.Y)("div",{className:"cursor-grab text-ink/40 group-hover:text-ink/80",children:(0,r.Y)(Y.A,{size:14})}),(0,r.Y)("span",{className:`shrink-0 text-[9px] font-mono uppercase tracking-wider px-1 py-px rounded ${"steer"===u?"bg-error/10 text-error":"bg-ink/10 text-ink/70"}`,children:rz[u]}),(0,r.Y)("div",{className:"flex-1 truncate text-ink/80 pr-2",children:e.text||(e.attachments.length>0?`[${e.attachments.length} attachment${e.attachments.length>1?"s":""}]`:"Empty message")}),l&&"followup"===u&&(0,r.Y)("button",{onClick:()=>l(e),className:"text-ink/40 hover:text-ink/80 opacity-0 group-hover:opacity-100 transition-opacity",title:"Send Now (Steering)",children:(0,r.Y)(f.A,{size:12})}),a&&(0,r.Y)("button",{onClick:()=>a(e),className:"text-ink/40 hover:text-ink/80 opacity-0 group-hover:opacity-100 transition-opacity",title:"Edit",children:(0,r.Y)(rT.A,{size:12})}),(0,r.Y)("button",{onClick:()=>n(t=>t.filter(t=>t.id!==e.id)),className:"text-ink/40 hover:text-error opacity-0 group-hover:opacity-100 transition-opacity",title:"Remove",children:(0,r.Y)(k.A,{size:14})})]},e.id))})}function rj(e){let{isMobile:t,isGenerating:n,modelName:i,generatingVerb:s,provider:a,providerNames:l,messageQueue:o,setMessageQueue:c,onEditQueueItem:d,onSendNowQueueItem:u,steeringQueue:p,setSteeringQueue:m,inputValue:h,setInputValue:f,rootPath:x,attachments:g,setAttachments:b,onSend:v,onStop:k,appSettings:y,onThinkingLevelChange:w,onModelChange:N,accessMode:Y,onAccessModeChange:D,composerModelRef:F,sessionModel:A,sessionThinkingLevel:S,variant:C}=e;return(0,r.Y)("div",{className:`bg-transparent border-t-0 flex-shrink-0 space-y-2 ${t?"px-3 pt-1":"p-4 pt-1"}`,style:t?{paddingBottom:"max(0.75rem, env(safe-area-inset-bottom, 0px))"}:void 0,children:(0,r.FD)("div",{className:"mx-auto w-full max-w-[970px]",children:[n&&(0,r.Y)(n0,{modelName:i,generatingVerb:s,provider:a,providerNames:l}),(0,r.Y)(r$,{queue:o,setQueue:c,onEdit:d,onSendNow:u}),(0,r.Y)(r$,{queue:p,setQueue:m,isSteering:!0}),(0,r.Y)(el,{value:h,onChange:f,rootPath:x,attachments:g,onAttachmentsChange:b,onSend:v,isGenerating:n,onStop:k,appSettings:y,onThinkingLevelChange:w,onModelChange:N,accessMode:Y,onAccessModeChange:D,composerModelRef:F,sessionModel:A,sessionThinkingLevel:S,variant:C})]})})}var rL=n("zG");function rM(e){let t,n=(0,rL.oJ)(e.name)??"",r=rL.YT[n.toLowerCase()]??n.toLowerCase(),i=(t={...(0,t3.u)(e.args)?e.args:(0,t3.u)(e.input)?e.input:{}},e.command&&void 0===(0,rL.oJ)(t.command)&&void 0===(0,rL.oJ)(t.cmd)&&(t.command=e.command),e.target&&void 0===(0,rL.oJ)(t.path)&&(t.path=e.target),t),s=(0,rL.oJ)(e.intent)??(0,rL.Up)(i,["i"]),a=function(e,t){let n=(0,rL.Up)(e,["path","target"])??(0,rL.oJ)(t.target)??(0,rL.oJ)(t.command);if(n&&n.startsWith("xd://"))return n.slice(5).split(/[/?#\s]/)[0]||void 0}(i,e);if(a){let e=a.startsWith("mcp__")?a.slice(5):void 0,t=e?`Running ${e}`:rL.Qq[a]??`Running ${a}`,n=(0,rL.qL)(e??a,function(e){let{path:t,target:n,command:r,i:i,...s}=e,a=e.content;if("string"!=typeof a)return s;try{let e=JSON.parse(a);if((0,t3.u)(e))return{...s,...e}}catch{}let l=a.trim().split("\n",1)[0]?.trim();return l?{...s,prose:l}:s}(i));return n?(0,rL.xv)(`${t} ${n}`):s?(0,rL.xv)(s):(0,rL.xv)(t)}let l=rL.K$[r]??(r?`Running ${r}`:"Working"),o=(0,rL.qL)(r,i);return o?(0,rL.xv)(`${l} ${o}`):s?(0,rL.xv)(s):(0,rL.xv)(l)}var rP=n("Kc");function rE(e,t,n){var r;for(e.set(t,{...n,output:(r=n.output).length<=2e5?r:`…[truncated]
19
19
  ${r.slice(-2e5)}`});e.size>200;){let t=e.keys().next().value;if(void 0===t)break;e.delete(t)}}function rR(e,t){e&&e!==t.activityRef.current&&(t.activityRef.current=e,t.callbacksRef.current?.onActivity?.(e))}function rI(e,t){if(!e.toolCalls?.length)return e;let n=e.toolCalls.map(e=>{let n=t.current?.get(e.id);return n?{...e,output:n.output,details:e.details||n.details||void 0,status:n.isError?"error":"success"}:e});return{...e,toolCalls:n}}function rO(e,t){let n="string"==typeof e.toolCallId?e.toolCallId:void 0;n&&t.toolResultsRef.current?.set(n,{output:rs(e.content),details:e.details&&"object"==typeof e.details?e.details:void 0})}function rJ(e,t){if(!e)return;let n=t.lastToolMessageRef.current;n?.toolCalls?.some(t=>t.id===e)&&t.callbacksRef.current?.onMessageUpdate?.(rI(n,t.toolResultsRef))}var r_=n("Kn"),rW=n("g0");let rK={websocket:function(e,t){let n=null,r=null,i=0,s=!1,a=!1,l=()=>{let o=new WebSocket((0,r_.qq)(e));n=o,o.onopen=()=>{a||(i=0,s=!0,t.onOpen())},o.onmessage=e=>{let n;if(!a){try{n=JSON.parse(String(e.data))}catch{return}t.onFrame(n)}},o.onclose=()=>{n=null,a||(t.onClose(),!s||(i+=1)>4||(r=setTimeout(()=>{r=null,a||l()},Math.min(500*2**(i-1),8e3))))}};return l(),{close:()=>{a=!0,null!==r&&(clearTimeout(r),r=null);let e=n;n=null,e&&(e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null,e.close())}}},sse:function(e,t){let n=new EventSource((0,r_._m)(e)),r=!1;return n.onopen=()=>{r||t.onOpen()},n.onmessage=e=>{let n;if(!r){try{n=JSON.parse(e.data)}catch{return}t.onFrame(n)}},n.onerror=()=>{r||n.readyState===EventSource.CLOSED&&t.onClose()},{close:()=>{r=!0,n.onopen=null,n.onmessage=null,n.onerror=null,n.close()}}}};function rU(e,t,n){return fetch(`/api/agent/${encodeURIComponent(e)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t),...n?{signal:n}:{}})}async function rH(e){let t=new AbortController,n=setTimeout(()=>t.abort(),1e4);try{if(await rU(e,{type:"abort"},t.signal).then(()=>!0,()=>!1))return;await rU(e,{type:"force_reset"}).catch(()=>null)}finally{clearTimeout(n)}}var rB=n("FL");let rq="u"<typeof window?i.vJ:i.Nf;var rG=n("G1");async function rV(e,t){let{sessionId:n,prompt:r,model:i,workspaceName:s,attachments:a,signal:l}=e,o={id:`msg-${Date.now()}-ai`,role:"ai",date:`Today, ${tY()}`,content:""},c=!1;try{let e=await fetch("/api/chat/stream",{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({sessionId:n,prompt:r,model:i,workspaceName:s,attachments:a?.map(e=>({name:e.name||e.file?.name,preview:e.preview}))}),signal:l});if(!e.ok||!e.body)throw Error(`SSE stream connection failed: HTTP ${e.status}`);if(await (0,rG.o)(e,(e,n)=>{try{let r=JSON.parse(n);switch(e){case"init":o.id=r.id||o.id,o.date=r.date||o.date,t.onInit?.(r);break;case"thinking_start":o.thinking={thought:"",isGenerating:!0},t.onThinkingStart?.(r);break;case"thinking_chunk":"object"==typeof o.thinking?o.thinking.thought=(o.thinking.thought||"")+r.delta:o.thinking={thought:r.delta,isGenerating:!0},t.onThinkingChunk?.(r);break;case"thinking_end":o.thinking={thought:r.thought,summary:r.summary,duration:r.duration,isGenerating:!1},t.onThinkingEnd?.(r);break;case"tool_start":o.toolCalls=[...o.toolCalls||[],r],t.onToolStart?.(r);break;case"tool_output_chunk":o.toolCalls=(o.toolCalls||[]).map(e=>e.id===r.id?{...e,output:(e.output||"")+r.delta}:e),t.onToolOutputChunk?.(r);break;case"tool_end":o.toolCalls=(o.toolCalls||[]).map(e=>e.id===r.id?{...e,...r}:e),t.onToolEnd?.(r);break;case"content_start":t.onContentStart?.();break;case"content_chunk":o.content=(o.content||"")+r.delta,t.onContentChunk?.(r);break;case"content_end":t.onContentEnd?.();break;case"summary":o.summary=r.summary,t.onSummary?.(r);break;case"done":return r.message&&(o=r.message),c=!0,t.onDone?.(r),!0;case"error":throw Error(r.error||"Stream error")}}catch(e){console.warn("SSE chunk parse error:",e)}},l),l?.aborted)return null;return c||t.onDone?.({message:o}),o}catch(n){if(l?.aborted)return null;return console.warn("Streaming failed, invoking fallback response handler:",n),t.onError?.(n),await rZ(e,t)}}async function rZ(e,t){let{sessionId:n,prompt:r,model:i,workspaceName:s}=e,a=tY(),l={id:`msg-${Date.now()}-ai`,role:"ai",date:`Today, ${a}`,timestamp:a,thinking:{duration:"1.2s",thought:`1. User prompt: "${r}".
20
20
  2. Target workspace: ${s||"Workspace"}.
21
21
  3. Fallback resolution complete.`,summary:"Execute workspace diagnostics and fallback resolution."},toolCalls:[{id:`tc-${Date.now()}-fallback`,type:"bash",title:"Diagnostic Command",target:"bun --version",command:"bun --version",output:"Bun v1.2.4 (fallback mode)",status:"success",duration:"35ms"}],content:`I've processed your request: **"${r||"Workspace status"}"**.
@@ -27,7 +27,7 @@ ${r.slice(-2e5)}`});e.size>200;){let t=e.keys().next().value;if(void 0===t)break
27
27
  ${s}`,agents:r}}(e,t).text)}catch{}var r=n.replace(r1,'$1@"$2"').replace(r5,"$1@$2");if(0===t.length)return r;let i=t.map(e=>{var t;let n,r,i=(t=e.content,n=t.match(/`+/g)?.reduce((e,t)=>Math.max(e,t.length),0)??0,"`".repeat(Math.max(3,n+1)));return`Attached file: ${e.name}
28
28
  ${i}${"md"===(r=rX(e.name))||"markdown"===r||"mdx"===r?"markdown":"text"}
29
29
  ${e.content}
30
- ${i}`});return[r.trim(),...i].filter(Boolean).join("\n\n")}let r9=[250,250,500,500,1e3,1e3,2e3,2e3,2e3,2e3,2e3,2e3];var r7=n("Fb");function ie(e,t){let n=e[t];return"string"==typeof n?n:void 0}let it=()=>{},ir=()=>{},ii=r8(e=>it(e),()=>ir());function is(){ii.cancel()}var ia=n("So"),il=n("Np"),io=n("B");function ic(e){var t;return t=e.connectedProviders,t?.length?Object.fromEntries(t.filter(e=>e.name?.trim()).map(e=>[e.id,e.name])):{}}var id=n("oZ"),iu=n("wu"),ip=n("Gb"),im=n("K");function ih(e){let{className:t="",appSettings:n={},onSessionTitle:a,variant:l="desktop"}=e,{folders:c}=(0,im.k)(),d="mobile"===l,{sessionId:u,selectedFolderId:p,setSelectedFolderId:m,sessionData:h,localMessages:f,isGenerating:x,hasMore:g,loadingOlder:b,loadOlderError:v,sessionLoading:k,loadOlder:y,generatingVerb:N,messageQueue:w,setMessageQueue:Y,steeringQueue:D,setSteeringQueue:F,inputValue:A,setInputValue:C,inputAttachments:S,setInputAttachments:T,scrollRef:z,contentRef:$,showScrollBottom:j,isScrolling:L,handleScroll:M,jumpToBottom:P,handleSend:E,handleEditQueueItem:R,handleSendNowQueueItem:I,handleUndo:O,handleRetry:J,submitNewChat:_,stopGenerating:W,handleThinkingLevelChange:K,handleModelChange:H,accessMode:B,handleAccessModeChange:q,composerModelRef:G,extensionDialog:V,closeExtensionDialog:Z,respondToExtensionUi:Q}=function(){let e,{folders:t=[],appSettings:n={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[r,a]=(0,s.o)(),l=r.get("sessionId"),o=r.get("folderId"),[c,d]=(0,i.J0)(null);(0,i.vJ)(()=>{d(o?parseInt(o,10):null)},[o]);let u=(0,i.hb)(e=>{d(e),a(t=>(e?t.set("folderId",String(e)):t.delete("folderId"),t),{replace:!0})},[a]),p=(0,i.li)(()=>{}),{scrollRef:m,contentRef:h,showScrollBottom:f,isScrolling:x,handleScroll:g,scrollToBottom:b,jumpToBottom:v}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(0,i.li)(e.onScrollTop);t.current=e.onScrollTop??t.current;let n=(0,i.li)(null),[r,s]=(0,i.J0)(null),[a,l]=(0,i.J0)(!1),[o,c]=(0,i.J0)(!1),d=(0,i.li)(null),u=(0,i.li)(!0),p=(0,i.li)(0),m=(0,i.hb)(e=>{s(e)},[]),h=(0,i.hb)(()=>{let e=n.current;e&&l(e.scrollHeight-e.scrollTop-e.clientHeight>=100)},[]),f=(0,i.hb)(()=>{let e=n.current;e&&(e.scrollTop<p.current-1&&(u.current=!1),e.scrollHeight-e.scrollTop-e.clientHeight<100&&(u.current=!0),p.current=e.scrollTop,e.scrollTop<=40&&t.current?.()),h(),c(!0),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>c(!1),600)},[h]),x=(0,i.hb)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"smooth",t=n.current;!t||u.current&&t.scrollTo({top:t.scrollHeight,behavior:e})},[]),g=(0,i.hb)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"smooth",t=n.current;t&&(u.current=!0,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]);return(0,i.vJ)(()=>{if(h(),"u"<typeof ResizeObserver)return;let e=n.current,t=new ResizeObserver(h);return e&&t.observe(e),r&&t.observe(r),()=>t.disconnect()},[r,h]),(0,i.vJ)(()=>()=>{d.current&&clearTimeout(d.current)},[]),{scrollRef:n,contentRef:m,showScrollBottom:a,isScrolling:o,followRef:u,handleScroll:f,scrollToBottom:x,jumpToBottom:g}}({onScrollTop:()=>p.current()}),[k,y]=(0,rB.bL)("chat.draft","");(e=(0,i.li)(y)).current=y,(0,i.vJ)(()=>{let t=t=>{let n=t instanceof CustomEvent?t.detail:null;if(!(0,t3.u)(n))return;let r=ie(n,"url");if(!r)return;let i=ie(n,"title");e.current(e=>{let t=e&&!e.endsWith("\n")?"\n\n":e?"\n":"",n=i?`
30
+ ${i}`});return[r.trim(),...i].filter(Boolean).join("\n\n")}let r9=[250,250,500,500,1e3,1e3,2e3,2e3,2e3,2e3,2e3,2e3];var r7=n("Fb");function ie(e,t){let n=e[t];return"string"==typeof n?n:void 0}let it=()=>{},ir=()=>{},ii=r8(e=>it(e),()=>ir());function is(){ii.cancel()}var ia=n("So"),il=n("Np"),io=n("B");function ic(e){var t;return t=e.connectedProviders,t?.length?Object.fromEntries(t.filter(e=>e.name?.trim()).map(e=>[e.id,e.name])):{}}var id=n("oZ"),iu=n("wu"),ip=n("Gb"),im=n("K");function ih(e){let{className:t="",appSettings:n={},onSessionTitle:a,variant:l="desktop"}=e,{folders:c}=(0,im.k)(),d="mobile"===l,{sessionId:u,selectedFolderId:p,setSelectedFolderId:m,sessionData:h,localMessages:f,isGenerating:x,hasMore:g,loadingOlder:b,loadOlderError:v,sessionLoading:k,loadOlder:y,generatingVerb:w,messageQueue:N,setMessageQueue:Y,steeringQueue:D,setSteeringQueue:F,inputValue:A,setInputValue:S,inputAttachments:C,setInputAttachments:T,scrollRef:z,contentRef:$,showScrollBottom:j,isScrolling:L,handleScroll:M,jumpToBottom:P,handleSend:E,handleEditQueueItem:R,handleSendNowQueueItem:I,handleUndo:O,handleRetry:J,submitNewChat:_,stopGenerating:W,handleThinkingLevelChange:K,handleModelChange:H,accessMode:B,handleAccessModeChange:q,composerModelRef:G,extensionDialog:V,closeExtensionDialog:Z,respondToExtensionUi:Q}=function(){let e,{folders:t=[],appSettings:n={}}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},[r,a]=(0,s.o)(),l=r.get("sessionId"),o=r.get("folderId"),[c,d]=(0,i.J0)(null);(0,i.vJ)(()=>{d(o?parseInt(o,10):null)},[o]);let u=(0,i.hb)(e=>{d(e),a(t=>(e?t.set("folderId",String(e)):t.delete("folderId"),t),{replace:!0})},[a]),p=(0,i.li)(()=>{}),{scrollRef:m,contentRef:h,showScrollBottom:f,isScrolling:x,handleScroll:g,scrollToBottom:b,jumpToBottom:v}=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(0,i.li)(e.onScrollTop);t.current=e.onScrollTop??t.current;let n=(0,i.li)(null),[r,s]=(0,i.J0)(null),[a,l]=(0,i.J0)(!1),[o,c]=(0,i.J0)(!1),d=(0,i.li)(null),u=(0,i.li)(!0),p=(0,i.li)(0),m=(0,i.hb)(e=>{s(e)},[]),h=(0,i.hb)(()=>{let e=n.current;e&&l(e.scrollHeight-e.scrollTop-e.clientHeight>=100)},[]),f=(0,i.hb)(()=>{let e=n.current;e&&(e.scrollTop<p.current-1&&(u.current=!1),e.scrollHeight-e.scrollTop-e.clientHeight<100&&(u.current=!0),p.current=e.scrollTop,e.scrollTop<=40&&t.current?.()),h(),c(!0),d.current&&clearTimeout(d.current),d.current=setTimeout(()=>c(!1),600)},[h]),x=(0,i.hb)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"smooth",t=n.current;!t||u.current&&t.scrollTo({top:t.scrollHeight,behavior:e})},[]),g=(0,i.hb)(function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"smooth",t=n.current;t&&(u.current=!0,t.scrollTo({top:t.scrollHeight,behavior:e}))},[]);return(0,i.vJ)(()=>{if(h(),"u"<typeof ResizeObserver)return;let e=n.current,t=new ResizeObserver(h);return e&&t.observe(e),r&&t.observe(r),()=>t.disconnect()},[r,h]),(0,i.vJ)(()=>()=>{d.current&&clearTimeout(d.current)},[]),{scrollRef:n,contentRef:m,showScrollBottom:a,isScrolling:o,followRef:u,handleScroll:f,scrollToBottom:x,jumpToBottom:g}}({onScrollTop:()=>p.current()}),[k,y]=(0,rB.bL)("chat.draft","");(e=(0,i.li)(y)).current=y,(0,i.vJ)(()=>{let t=t=>{let n=t instanceof CustomEvent?t.detail:null;if(!(0,t3.u)(n))return;let r=ie(n,"url");if(!r)return;let i=ie(n,"title");e.current(e=>{let t=e&&!e.endsWith("\n")?"\n\n":e?"\n":"",n=i?`
31
31
  Judul: ${i}`:"";return`${e}${t}[Konteks halaman browser]
32
32
  URL: ${r}${n}
33
- (Lanjutkan dari halaman ini.)`})};return window.addEventListener(r7.j,t),()=>window.removeEventListener(r7.j,t)},[]);let[N,w]=(0,rB.bL)("chat.draftAttachments",[]),[Y,D]=(0,i.J0)([]),F=!!l?.startsWith("new-");!function(e){let{sessionId:t,messages:n,scrollRef:r,scrollToBottom:s,enabled:a}=e,l=(0,i.li)(null),o=(0,i.li)(null);rq(()=>{if(l.current!==t){l.current=t,o.current=null;return}a&&t&&0!==n.length&&o.current!==t&&r.current&&(o.current=t,s("instant"))},[t,n,a,r,s])}({sessionId:l,messages:Y,scrollRef:m,scrollToBottom:b,enabled:!F});let[A,C]=(0,i.J0)(!1),S=(0,i.li)(!1),T=(0,i.li)([]);T.current=Y;let[z,$]=(0,i.J0)(""),j=(0,i.li)(null),L=(0,i.li)(l);L.current=l;let M=(0,i.hb)(e=>{S.current=e,C(e)},[]),P=(0,i.li)(!1),E=(0,i.li)(null),R=(0,i.li)(!1),I=(0,i.li)(null),O=(0,i.li)([]),J=!!l&&!String(l).startsWith("new-")&&Number.isNaN(Number(l)),_=(0,i.li)(null),{sessionData:W,adoptedSessionIdRef:K,refreshSessionMeta:H,setSessionModel:B,hasMore:q,loadingOlder:G,loadOlderError:V,sessionLoading:Z,loadOlder:Q}=function(e){let{sessionId:t,setLocalMessages:n,setGenerating:r,isGeneratingRef:s,aiPlaceholderIdRef:a,localMessagesRef:l,optimisticUserIdRef:o,cancelStreamingCoalescer:c,metaRefreshedRef:d,scrollRef:u}=e,[p,m]=(0,i.J0)(null),[h,f]=(0,i.J0)(!1),[x,g]=(0,i.J0)(0),[b,v]=(0,i.J0)(!1),[k,y]=(0,i.J0)(!1),[N,w]=(0,i.J0)(0),Y=(0,i.li)(!1),[D,F]=(0,i.J0)(!1),A=(0,i.li)(null),C=(0,i.li)(null),S=(0,i.li)(null),T=(0,i.li)(null),z=(0,i.hb)(e=>{e.model&&"object"==typeof e.model&&(T.current=e.model);let t=e.model??(s.current?T.current??void 0:void 0);m({...e,model:t})},[]),$=(0,i.li)(t);$.current=t;let j=(0,i.hb)(e=>{let t=()=>$.current===e||S.current===e;if(!t())return;let n=0,r=()=>{t()&&fetch(`/api/chat/${encodeURIComponent(e)}`).then(e=>e.json()).then(i=>{if(!i?.session||!t())return;if(z(i.session),(i.session.messages?.length??0)>0)return void window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}));let s=r9[n];n+=1,void 0!==s&&setTimeout(r,s)}).catch(()=>{})};r()},[z]),L=(0,i.hb)(e=>{T.current=e,m(t=>({...t??{},model:e??void 0}))},[]),M=(0,i.hb)(()=>s.current&&!!a.current,[a]);(0,i.vJ)(()=>{let e=!0;if(F(!0),t!==C.current){let e=t&&!t.startsWith("new-")&&C.current?.startsWith("new-"),i=s.current&&S.current===t;e||i||(n([]),r(!1),S.current=null,T.current=null,a.current=null,o.current=null,c()),f(!1),g(0),Y.current=!1,v(!1),y(!1),d.current=null,C.current=t}return t?fetch(`/api/chat/${t}`).then(e=>e.json()).then(r=>{if(e)if(F(!1),r?.session){z(r.session);let e=r.session.messages||[],i=M();if(e.length>0&&!i)if(s.current){let t=e.map(e=>e.id);n([...e,...l.current.filter(e=>!t.includes(e.id))])}else n(e);else t.startsWith("new-")||i||n([]);"boolean"==typeof r.hasMore&&f(r.hasMore),"number"==typeof r.oldestIndex&&g(r.oldestIndex)}else m(null),M()||n([])}).catch(t=>{console.error("Error loading session from API:",t),e&&F(!1),e&&!M()&&(m(null),n([]))}):(m(null),n([])),()=>{e=!1}},[t,z,M,n,r]);let P=(0,i.hb)(()=>{if(!t||t.startsWith("new-")||!h||Y.current)return;Y.current=!0,v(!0),y(!1);let e=u?.current;e&&(A.current={prevHeight:e.scrollHeight,prevTop:e.scrollTop}),fetch(`/api/chat/${t}?before=${x}`).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{if($.current!==t)return;let r=e.session?.messages??[];if(f(!!e.hasMore),"number"==typeof e.oldestIndex&&g(e.oldestIndex),0===r.length){A.current=null;return}n(e=>[...r,...e]),w(e=>e+1)}).catch(()=>{$.current===t&&y(!0)}).finally(()=>{Y.current=!1,v(!1)})},[t,h,x,u,n]);return(0,i.Nf)(()=>{let e=A.current;if(!e)return;let t=u?.current;if(!t)return;A.current=null;let n=t.scrollHeight-e.prevHeight;n>0&&(t.scrollTop=e.prevTop+n)},[N,u]),{sessionData:p,hasMore:h,loadingOlder:b,loadOlderError:k,sessionLoading:D,loadOlder:P,adoptedSessionIdRef:S,seededModelRef:T,applySessionData:z,refreshSessionMeta:j,setSessionModel:L,timelineOwnedByOptimistic:M}}({sessionId:l,setLocalMessages:D,setGenerating:M,isGeneratingRef:S,aiPlaceholderIdRef:_,localMessagesRef:T,optimisticUserIdRef:I,cancelStreamingCoalescer:is,metaRefreshedRef:E,scrollRef:m});p.current=Q;let X=(0,i.li)(null),ee=(0,i.li)(null),et=(0,i.li)(null),[en,er]=(0,i.J0)(()=>{var e,t;return"string"==typeof(t=e=n.omp_access_mode)&&U.some(e=>e===t)?e:"always-ask"}),ei=(0,i.li)(en);ei.current=en;let es=(0,i.hb)(e=>{er(e),ei.current=e,(0,ia.cz)("omp_access_mode",e)},[]),ea=(0,i.hb)(e=>{l&&fetch(`/api/chat/${l}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:e})}).catch(e=>console.error("Error persisting messages via API:",e))},[l]),{messageQueue:el,setMessageQueue:eo,steeringQueue:ec,setSteeringQueue:ed,removeDeliveredFromQueue:eu}=function(e){let[t,n]=(0,i.J0)([]),[r,s]=(0,rB.bL)("chat.steeringQueue",[]),a=(0,i.li)(0);(0,i.vJ)(()=>{if(!e)return void n([]);let t=++a.current,r=!1;return fetch(`/api/sessions/${encodeURIComponent(e)}/queue`).then(e=>e.ok?e.json():{queue:[]}).then(e=>{r||a.current!==t||n(Array.isArray(e.queue)?e.queue:[])}).catch(()=>{}),()=>{r=!0}},[e]);let l=(0,i.hb)(t=>{e&&fetch(`/api/sessions/${encodeURIComponent(e)}/queue`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({queue:t})}).catch(console.error)},[e]),o=(0,i.hb)(e=>{n(t=>{let n="function"==typeof e?e(t):e;return l(n),n})},[l]),c=(0,i.hb)(e=>{let t=t=>t.some(t=>t.text===e);s(n=>t(n)?n.filter(t=>t.text!==e):n),o(n=>t(n)?n.filter(t=>t.text!==e):n)},[s,o]);return{messageQueue:t,setMessageQueue:o,steeringQueue:r,setSteeringQueue:s,removeDeliveredFromQueue:c}}(l),{dialog:ep,enqueue:em,dismiss:eh,withdraw:ef}=function(e){let[t,n]=(0,i.J0)([]);(0,i.vJ)(()=>{n([])},[e]);let r=(0,i.hb)(e=>{n(t=>t.some(t=>t.id===e.id)?t:[...t,e])},[]),s=(0,i.hb)(()=>{n(e=>e.slice(1))},[]),a=(0,i.hb)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return{dialog:t[0]??null,enqueue:r,dismiss:s,withdraw:a}}(l),ex=function(e,t,n){let[r,s]=(0,i.J0)({isGenerating:!1,connected:!1,error:null}),a=(0,i.li)(t);a.current=t;let l=(0,i.li)(e);l.current=e;let o=(0,i.li)(new Map),c=(0,i.li)(null),d=(0,i.li)(!1),u=(0,i.li)(""),p=(0,i.li)(void 0),m=(0,i.li)(new Set),{connect:h,disconnect:f}=function(e){let{setState:t,callbacksRef:n,toolResultsRef:r,lastToolMessageRef:s,interruptPendingRef:a,activityRef:l,currentThinkingLevelRef:o,fileMutatingCallsRef:c,transport:d}=e,u=(0,i.li)(null);(0,i.vJ)(()=>((0,rW.dX)({transport:d,connected:!1}),()=>(0,rW.dX)({transport:d,connected:!1})),[d]);let p=(0,i.hb)(()=>{let e=u.current;u.current=null,e?.close(),t(e=>({...e,connected:!1})),(0,rW.dX)({transport:d,connected:!1})},[t,d]);return{connect:(0,i.hb)(e=>{p(),u.current=rK[d](e,{onOpen:()=>{t(e=>({...e,connected:!0})),(0,rW.dX)({transport:d,connected:!0}),n.current?.onConnected?.()},onFrame:i=>{!function(e,t){let n=t.callbacksRef.current;switch(e.type){case"agent_start":t.setState(e=>({...e,isGenerating:!0,error:null})),t.toolResultsRef.current?.clear(),t.fileMutatingCallsRef.current?.clear(),t.lastToolMessageRef.current=null,t.interruptPendingRef.current=!1,t.currentThinkingLevelRef.current=void 0,rR(rL.n1.thinking,t),n?.onAgentStart?.();break;case"message_start":case"message_update":{let r=e.message;if(!r)break;if("toolResult"===r.role){rO(r,t),rR(rL.n1.thinking,t);break}rR(function(e){if(!(0,t3.u)(e))return;let t=(0,rL.oJ)(e.type);if(t){if(t.startsWith("thinking"))return rL.n1.thinking;if(t.startsWith("text"))return rL.n1.writing;if("toolcall_start"===t||"toolcall_delta"===t){let t=function(e){let t=e.partial;if(!(0,t3.u)(t))return;let n=t.content;if(!Array.isArray(n))return;let r="number"==typeof e.contentIndex?e.contentIndex:n.length-1,i=n[r];if((0,t3.u)(i)&&"toolCall"===i.type)return i}(e);if(!t)return;return rM({name:(0,rL.oJ)(t.name),args:t.arguments})}if("toolcall_end"===t){let t=e.toolCall;if(!(0,t3.u)(t))return;return rM({name:(0,rL.oJ)(t.name),args:t.arguments})}}}(e.assistantMessageEvent),t);let i=rp(r);i&&("user"!==i.role&&t.currentThinkingLevelRef.current&&(i.thinkingLevel=t.currentThinkingLevelRef.current),n?.onMessageUpdate?.(i));break}case"message_end":{let r=e.message;if(!r)break;if("toolResult"===r.role){rO(r,t);break}if("custom"===r.role)break;if("user"===r.role){let e=rs(r.content);e&&n?.onQueuedMessageDelivered?.(e);break}let i=rp(r,!1);if(!i)break;"user"!==i.role&&t.currentThinkingLevelRef.current&&(i.thinkingLevel=t.currentThinkingLevelRef.current);let s=rI(i,t.toolResultsRef);s.toolCalls?.length&&(t.lastToolMessageRef.current=s),n?.onMessageEnd?.(s);break}case"tool_execution_start":{let r="string"==typeof e.toolCallId?e.toolCallId:void 0;rR(rM({name:"string"==typeof e.toolName?e.toolName:void 0,args:e.args,intent:"string"==typeof e.intent?e.intent:void 0}),t),r&&t.toolResultsRef.current?.set(r,{output:""}),r&&(0,rP.Y)({toolName:e.toolName,args:e.args})&&t.fileMutatingCallsRef.current?.add(r);let i=t.lastToolMessageRef.current;i?.toolCalls?.some(e=>e.id===r)&&(t.lastToolMessageRef.current={...i,toolCalls:i.toolCalls.map(e=>({...e,status:"running"}))},n?.onMessageUpdate?.(t.lastToolMessageRef.current));break}case"tool_execution_update":{let n="string"==typeof e.toolCallId?e.toolCallId:void 0,r=ru(e.partialResult);if(!n||!r)break;let i=t.toolResultsRef.current?.get(n)?.output??"",s=t.toolResultsRef.current;s&&rE(s,n,{output:i+r}),rJ(n,t);break}case"tool_execution_end":{let n="string"==typeof e.toolCallId?e.toolCallId:void 0;if(!n)break;rR(rL.n1.thinking,t);let r=t.toolResultsRef.current;r&&rE(r,n,{output:ru(e.result),isError:!0===e.isError,details:e.details&&"object"==typeof e.details?e.details:void 0}),rJ(n,t),"u">typeof window&&t.fileMutatingCallsRef.current?.delete(n)&&window.dispatchEvent(new CustomEvent(rP.s,{detail:{sessionId:t.sessionId}}));break}case"agent_end":{t.setState(e=>({...e,isGenerating:!1})),t.activityRef.current="";let r=function(e,t,n){let r;if(!1===e.isTerminal)return{};let i=e.messages;if(!Array.isArray(i))return{};for(let e of i){if(!e||"object"!=typeof e||Array.isArray(e)||"assistant"!==e.role||"aborted"!==e.stopReason&&"error"!==e.stopReason)continue;let i=rp(e,!1);if(!i)continue;let s=rI(i,t.toolResultsRef);s.toolCalls?.length&&(t.lastToolMessageRef.current=s),n?.onMessageEnd?.(s),"string"==typeof e.errorMessage&&(r=e.errorMessage)}return{errorMessage:r}}(e,t,n??void 0);if(t.interruptPendingRef.current){t.interruptPendingRef.current=!1;break}n?.onAgentEnd?.({errorMessage:r.errorMessage??("string"==typeof e.errorMessage?e.errorMessage:void 0),message:"string"==typeof e.message?e.message:void 0});break}case"prompt_error":{let r="string"==typeof e.errorMessage?e.errorMessage:"Prompt failed";t.setState(e=>({...e,isGenerating:!1,error:r})),t.interruptPendingRef.current=!1,t.activityRef.current="",n?.onPromptError?.(r);break}case"notice":n?.onNotice?.("string"==typeof e.level?e.level:"info","string"==typeof e.message?e.message:"");break;case"extension_ui_request":n?.onExtensionUiRequest?.(e);break;case"subagent_lifecycle":case"subagent_progress":case"subagent_event":{let n=e.payload;if(null==n||"object"!=typeof n)break;window.dispatchEvent(new CustomEvent(e.type,{detail:{sessionId:t.sessionId,payload:n}}));break}case"model_changed":n?.onModelChanged?.();break;case"thinking_level_changed":var r;t.currentThinkingLevelRef.current="string"==typeof(r=e.thinkingLevel)&&r.trim()?r.trim():"off"}}(i,{sessionId:e,setState:t,callbacksRef:n,toolResultsRef:r,lastToolMessageRef:s,interruptPendingRef:a,activityRef:l,currentThinkingLevelRef:o,fileMutatingCallsRef:c})},onClose:()=>{t(e=>({...e,connected:!1})),(0,rW.dX)({transport:d,connected:!1})}})},[p,t,n,r,s,a,l,o,c,d]),disconnect:p}}({setState:s,callbacksRef:a,toolResultsRef:o,lastToolMessageRef:c,interruptPendingRef:d,activityRef:u,currentThinkingLevelRef:p,fileMutatingCallsRef:m,transport:n});(0,i.vJ)(()=>{if(!e)return;o.current.clear(),m.current.clear(),c.current=null,u.current="";let t=!1;return fetch(`/api/agent/${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(n=>{if(t||!n?.running)return;let r=n.state;for(let t of((n.busy||r?.isStreaming||r?.isPromptRunning)&&(h(e),a.current.onResumeStream?.()),n.pendingUiRequests??[]))a.current.onExtensionUiRequest?.(t)}).catch(()=>{}),()=>{t=!0,f()}},[e,f,h]);let x=(0,i.hb)(async(e,t,n)=>{let r=l.current;if(!r)return!1;s(e=>({...e,isGenerating:!0,error:null}));try{(await fetch(`/api/agent/${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_state",...n?.accessMode?{accessMode:n.accessMode}:{}})})).ok&&h(r);let i=await fetch(`/api/agent/${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"prompt",message:e,...t?.length?{images:t}:{},...n?.accessMode?{accessMode:n.accessMode}:{}})}),a=await i.json().catch(()=>({}));if(!i.ok||a.error)return s(e=>({...e,isGenerating:!1,error:a.error??`HTTP ${i.status}`})),!1;return!0}catch(e){return s(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),!1}},[h]),g=(0,i.hb)(async(e,t,n,r)=>{s(e=>({...e,isGenerating:!0,error:null}));try{let i=await fetch("/api/agent/new",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"ensure_session",cwd:t,...r?.model?r.model:{},...r?.thinkingLevel?{thinkingLevel:r.thinkingLevel}:{},...r?.accessMode?{accessMode:r.accessMode}:{}})}),a=await i.json().catch(()=>({}));if(!i.ok||!a.sessionId)return s(e=>({...e,isGenerating:!1,error:a.error??`HTTP ${i.status}`})),null;let l=a.sessionId;h(l);let o=await fetch(`/api/agent/${encodeURIComponent(l)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"prompt",message:e,...n?.length?{images:n}:{}})}),c=await o.json().catch(()=>({}));if(!o.ok||c.error)return s(e=>({...e,isGenerating:!1,error:c.error??`HTTP ${o.status}`})),null;return{sessionId:l,model:a.model??null}}catch(e){return s(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),null}},[h]),b=(0,i.hb)(async()=>{let e=l.current;e&&(d.current=!1,await rH(e),s(e=>({...e,isGenerating:!1})))},[]),v=(0,i.hb)(async(e,t)=>{let n=l.current;if(!n)return!1;d.current=!0,s(e=>({...e,isGenerating:!0,error:null}));try{let r=await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"abort_and_prompt",message:e,...t?.length?{images:t}:{}})}),i=await r.json().catch(()=>({}));if(!r.ok||i.error)return d.current=!1,s(e=>({...e,isGenerating:!1,error:i.error??`HTTP ${r.status}`})),!1;return!0}catch(e){return d.current=!1,s(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),!1}},[]),k=(0,i.hb)(async(e,t)=>{let n=l.current;if(!n)return!1;try{let r=await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"follow_up",message:e,...t?.length?{images:t}:{}})}),i=await r.json().catch(()=>({}));if(!r.ok||i.error)return s(e=>({...e,error:i.error??`HTTP ${r.status}`})),!1;return!0}catch(e){return s(t=>({...t,error:e instanceof Error?e.message:String(e)})),!1}},[]),y=(0,i.hb)(async(e,t)=>{let n=l.current;if(n)try{await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"set_model",provider:e,modelId:t})})}catch{}},[]),N=(0,i.hb)(async e=>{let t=l.current;if(t)try{await fetch(`/api/agent/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"set_thinking_level",level:e})})}catch{}},[]),w=(0,i.hb)(async(e,t)=>{let n=l.current;if(n)try{await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"extension_ui_response",id:e.id,...t})})}catch{}},[]);return{...r,sendPrompt:x,sendNewPrompt:g,sendInterruptAndReply:v,sendFollowUp:k,abort:b,setModel:y,setThinkingLevel:N,respondToExtensionUi:w,disconnect:f}}(J?l:null,function(e){let{removeDeliveredFromQueue:t,setGenerating:n,setGeneratingVerb:r,scrollToBottom:i,adoptedSessionIdRef:s,sessionIdRef:a,metaRefreshedRef:l,firstAssistantRef:o,refreshSessionMeta:c,setLocalMessages:d,aiPlaceholderIdRef:u,optimisticUserIdRef:p,pendingUserDisplaysRef:m,persistMessages:h,abortControllerRef:f,appSettings:x,enqueueExtensionDialog:g,withdrawExtensionDialog:b}=e;return it=d,ir=()=>i("smooth"),{onQueuedMessageDelivered:e=>{t(e)},onAgentStart:()=>{n(!0),r(rL.n1.thinking),setTimeout(()=>i("smooth"),50),o.current=!1;let e=s.current??a.current;e&&(window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}})),l.current!==e&&(l.current=e,setTimeout(()=>c(e),100)))},onResumeStream:()=>{n(!0),r(rL.n1.thinking),setTimeout(()=>i("smooth"),50),o.current=!1;let e=s.current??a.current;e&&window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}))},onActivity:e=>{r(e)},onMessageUpdate:e=>{"user"===e.role||n_(e)||(p.current=null),ii.queue(t=>{let n=u.current;if(n_(e)){if(t.some(t=>t.id===e.id))return t;if(n&&t.some(e=>e.id===n)){let r=t.findIndex(e=>e.id===n);return[...t.slice(0,r),e,...t.slice(r)]}return[...t,e]}if("user"===e.role){if(t.some(t=>t.id===e.id))return t;let r=p.current;if(r){let n=t.findIndex(e=>e.id===r);if(-1!==n){let r={...e,id:e.id,content:t[n].content,date:t[n].date,attachments:e.attachments?.length?e.attachments:t[n].attachments};return[...t.slice(0,n),r,...t.slice(n+1)]}}let i=m.current.find(t=>e.content===t.sent||e.content.startsWith(t.sent)||t.sent.startsWith(e.content)),s=i?{...e,content:i.display}:e;if(n&&t.some(e=>e.id===n)){let e=t.findIndex(e=>e.id===n);return[...t.slice(0,e),s,...t.slice(e)]}return[...t,s]}if(n&&t.some(e=>e.id===n))return t.map(t=>t.id===n?e:t);let r=t.findIndex(t=>t.id===e.id);return -1!==r?[...t.slice(0,r),e,...t.slice(r+1)]:[...t,e]},e.id)},onMessageEnd:e=>{if("ai"===e.role&&!n_(e)&&!o.current){o.current=!0;let e=s.current??a.current;e&&"u">typeof window&&window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}))}ii.flush(),"user"!==e.role&&(p.current=null),d(t=>{let n,r=u.current;if("user"===e.role){let n,i=p.current;if(t.some(t=>t.id===e.id))n=t.map(t=>t.id===e.id?e:t);else if(i&&t.some(e=>e.id===i))n=t.map(t=>t.id===i?{...e,id:e.id,content:t.content,date:t.date,attachments:e.attachments?.length?e.attachments:t.attachments}:t);else if(r&&t.some(e=>e.id===r)){let i=t.findIndex(e=>e.id===r);n=[...t.slice(0,i),e,...t.slice(i)]}else n=[...t,e];return h(n),n}if(r&&t.some(e=>e.id===r))n=t.map(t=>t.id===r?e:t);else{let r=t.findIndex(t=>t.id===e.id);n=-1!==r?[...t.slice(0,r),e,...t.slice(r+1)]:[...t,e]}return u.current=null,h(n),n})},onAgentEnd:()=>{ii.flush(),ii.cancel(),n(!1),f.current=null,p.current=null,m.current=[],(0,r3.s4)(x),setTimeout(()=>i("smooth"),50);let e=s.current??a.current;e&&c(e)},onModelChanged:()=>{let e=s.current??a.current;e&&setTimeout(()=>c(e),150)},onPromptError:e=>{n(!1),f.current=null,console.error("OMP prompt error:",e)},onNotice:(e,t)=>{console.info("OMP notice:",t)},onExtensionUiRequest:e=>{"select"===e.method||"confirm"===e.method||"input"===e.method||"editor"===e.method?g(e):"cancel"===e.method&&b(e.targetId)}}}({removeDeliveredFromQueue:eu,setGenerating:M,setGeneratingVerb:$,scrollToBottom:b,adoptedSessionIdRef:K,sessionIdRef:L,metaRefreshedRef:E,firstAssistantRef:R,refreshSessionMeta:H,setLocalMessages:D,aiPlaceholderIdRef:_,optimisticUserIdRef:I,pendingUserDisplaysRef:O,persistMessages:ea,abortControllerRef:j,appSettings:n,enqueueExtensionDialog:em,withdrawExtensionDialog:ef}),(0,r_.ul)(n)),{steerOmpAgent:eg,executeSend:eb}=function(e){let{folders:t,selectedFolderId:n,sessionId:r,isOmpSession:s,appSettings:a,ompAgent:l,setLocalMessages:o,persistMessages:c,setGenerating:d,setGeneratingVerb:u,scrollToBottom:p,jumpToBottom:m,aiPlaceholderIdRef:h,adoptedSessionIdRef:f,optimisticUserIdRef:x,pendingUserDisplaysRef:g,setSessionModel:b,pendingComposerModelRef:v,pendingThinkingLevelRef:k,accessModeRef:y,abortControllerRef:N,setInputValue:w,setSearchParams:Y}=e,D=(0,i.hb)(async(e,t)=>{let n=new Map;try{await Promise.all(t.filter(e=>r0(e.file)).map(async e=>{n.set(e.id,await e.file.text())}))}catch{}let r=t.filter(e=>n.has(e.id)).map(e=>({name:e.file.name,mimeType:e.file.type,content:n.get(e.id),size:e.file.size})),i=await r6(e,r);g.current=[...g.current.slice(-7),{sent:i,display:e}];let s=t.filter(e=>e.file.type.startsWith("image/")&&e.dataBase64).map(e=>({data:e.dataBase64,mimeType:e.file.type}));return{promptText:i,images:s.length?s:void 0}},[]);return{steerOmpAgent:(0,i.hb)(async(e,t)=>{let{promptText:n,images:r}=await D(e,t);await l.sendInterruptAndReply(n,r)||w(e)},[l,D,w]),executeSend:(0,i.hb)(async(e,i,g)=>{let w=g?.model??null,D=w?.accessMode??y.current,F=tY(),A=`msg-${Date.now()}-user`,C=`msg-${Date.now()+1}-ai`,S=new Map;try{await Promise.all(i.filter(e=>r0(e.file)).map(async e=>{S.set(e.id,await e.file.text())}))}catch{}let T=Date.now(),z={id:A,role:"user",date:`Today, ${F}`,startedAt:T,content:e,attachments:i.map(e=>({name:e.file.name,preview:e.dataBase64?`data:${e.file.type};base64,${e.dataBase64}`:e.preview,type:e.file.type,size:e.file.size,content:S.get(e.id)}))},$={id:C,role:"ai",date:`Today, ${F}`,startedAt:T,content:""};if(o(e=>{let t=[...e,z,$];return c(t.filter(e=>e.id!==C)),t}),d(!0),u(rL.n1.thinking),setTimeout(()=>m("smooth"),50),s){h.current=C,x.current=A,w&&(await l.setModel(w.provider,w.modelId),"auto"!==w.thinkingLevel&&await l.setThinkingLevel(w.thinkingLevel));let t=i.filter(e=>e.file.type.startsWith("image/")&&e.dataBase64).map(e=>({data:e.dataBase64,mimeType:e.file.type})),n=i.filter(e=>S.has(e.id)).map(e=>({name:e.file.name,mimeType:e.file.type,content:S.get(e.id),size:e.file.size})),r=await r6(e,n);await l.sendPrompt(r,t.length?t:void 0,{accessMode:D})||(o(e=>e.filter(e=>e.id!==A&&e.id!==C)),h.current=null,x.current=null,d(!1));return}if(!s){let r=t.find(e=>String(e.id)===String(n)),s=r?.project_path||r?.name;if(s){let t=i.filter(e=>e.file.type.startsWith("image/")&&e.dataBase64).map(e=>({data:e.dataBase64,mimeType:e.file.type})),n=i.filter(e=>S.has(e.id)).map(e=>({name:e.file.name,mimeType:e.file.type,content:S.get(e.id),size:e.file.size})),r=await r6(e,n);x.current=A;let a=v.current,o=k.current,c=await l.sendNewPrompt(r,s,t.length?t:void 0,{model:a,thinkingLevel:o,accessMode:y.current});if(c){f.current=c.sessionId,h.current=C,c.model&&b(c.model),v.current=null,k.current=null,fetch(`/api/chat/${encodeURIComponent(c.sessionId)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[z]})}).catch(e=>console.error("Error persisting spawned user turn:",e)),Y(e=>{let t=new URLSearchParams(e);return t.set("sessionId",c.sessionId),t},{replace:!0});return}}}x.current=null,N.current&&N.current.abort();let j=new AbortController;N.current=j;let L=t.find(e=>String(e.id)===String(n)),M=L?.name||"Workspace";await rV({sessionId:r||`session-${Date.now()}`,prompt:e,workspaceName:M,attachments:i,signal:j.signal},function(e){let{aiPlaceholderId:t,setLocalMessages:n,persistMessages:r,setGenerating:i,setGeneratingVerb:s,abortControllerRef:a,appSettings:l,scrollToBottom:o}=e,c=!1,d=r8(e=>n(e),()=>{c&&(c=!1,o("smooth"))}),u=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t&&(c=!0),d.queue(e)};return{onInit:e=>{u(n=>n.map(n=>n.id===t?{...n,id:e.id,date:e.date}:n))},onThinkingStart:()=>{s(rL.n1.thinking),u(e=>e.map(e=>e.id===t||"ai"===e.role?{...e,thinking:{thought:"",isGenerating:!0}}:e)),setTimeout(()=>o("smooth"),50)},onThinkingChunk:e=>{u(n=>n.map(r=>{if(r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id){let t="object"==typeof r.thinking&&r.thinking.thought||"";return{...r,thinking:{thought:t+e.delta,isGenerating:!0}}}return r}),!0)},onThinkingEnd:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,thinking:{thought:e.thought,summary:e.summary,duration:e.duration,isGenerating:!1}}:r))},onToolStart:e=>{s(rM({name:e.name??e.type,input:e.input,command:e.command,target:e.target,intent:e.intent})),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:[...r.toolCalls||[],e]}:r)),setTimeout(()=>o("smooth"),50)},onToolOutputChunk:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:(r.toolCalls||[]).map(t=>t.id===e.id?{...t,output:(t.output||"")+e.delta}:t)}:r),!0)},onToolEnd:e=>{s(rL.n1.thinking),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:(r.toolCalls||[]).map(t=>t.id===e.id?{...t,...e}:t)}:r))},onContentChunk:e=>{s(rL.n1.writing),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,content:(r.content||"")+e.delta}:r),!0)},onSummary:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,summary:e.summary}:r))},onDone:e=>{d.flush(),n(n=>{let i=n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?e.message:r);return r(i),i}),i(!1),a.current=null,(0,r3.s4)(l),setTimeout(()=>o("smooth"),50)},onError:()=>{i(!1),a.current=null}}}({aiPlaceholderId:C,setLocalMessages:o,persistMessages:c,setGenerating:d,setGeneratingVerb:u,abortControllerRef:N,appSettings:a,scrollToBottom:p}))},[a,t,s,l,n,r,p,m,c,b,v,k,y])}}({folders:t,selectedFolderId:c,sessionId:l,isOmpSession:J,appSettings:n,ompAgent:ex,setLocalMessages:D,persistMessages:ea,setGenerating:M,setGeneratingVerb:$,scrollToBottom:b,jumpToBottom:v,aiPlaceholderIdRef:_,adoptedSessionIdRef:K,optimisticUserIdRef:I,pendingUserDisplaysRef:O,setSessionModel:B,pendingComposerModelRef:X,pendingThinkingLevelRef:ee,composerModelRef:et,accessModeRef:ei,abortControllerRef:j,setInputValue:y,setSearchParams:a});(0,i.vJ)(()=>{if(!P.current&&!A&&el.length>0){let e=el[0];eo(e=>e.slice(1)),eb(e.text,e.attachments,{model:e.model})}},[A,el,eb,eo]);let{handleSend:ev,handleEditQueueItem:ek,handleSendNowQueueItem:ey,handleUndo:eN,handleRetry:ew,submitNewChat:eY,stopGenerating:eD,handleThinkingLevelChange:eF,handleModelChange:eA,closeExtensionDialog:eC}=function(e){let{inputValue:t,setInputValue:n,setInputAttachments:r,isGenerating:s,isOmpSession:a,sessionId:l,appSettings:o,messageQueue:c,setMessageQueue:d,executeSend:u,steerOmpAgent:p,ompAgent:m,abortControllerRef:h,setGenerating:f,stopHoldRef:x,persistMessages:g,setLocalMessages:b,pendingComposerModelRef:v,pendingThinkingLevelRef:k,composerModelRef:y,accessModeRef:N,setSearchParams:w,dismissExtensionDialog:Y}=e,D=(0,i.hb)(async(e,r)=>{let i=t.trim();if(i||0!==e.length){if(x.current=!1,s){if(r?.steering){n(""),a?await p(i,e):(h.current&&(h.current.abort(),h.current=null),f(!1),u(i,e));return}if("steering"===(o.omp_chamber_settings?.followUpBehavior??o.followUpBehavior??"queue")&&a){n(""),await p(i,e);return}let t=y.current,s={id:`queue-${Date.now()}`,text:i,attachments:e,model:t?{...t,accessMode:N.current}:null};n(""),d(e=>[...e,s]);return}n(""),u(i,e)}},[t,s,u,d,a,o,p,n,h,f,x,y,N]),F=(0,i.hb)(e=>{d(t=>t.filter(t=>t.id!==e.id)),n(e.text),r(e.attachments)},[d,n,r]),A=(0,i.hb)(async e=>{x.current=!1,d(t=>t.filter(t=>t.id!==e.id)),s?a?p(e.text,e.attachments):(h.current&&(h.current.abort(),h.current=null),f(!1),setTimeout(()=>u(e.text,e.attachments,{model:e.model}),0)):u(e.text,e.attachments,{model:e.model})},[s,u,d,a,p,h,f,x]),C=(0,i.hb)(async(e,t)=>{if(s&&(a?m.abort():h.current&&(h.current.abort(),h.current=null),f(!1)),t&&n(t),a&&l){if(!(await fetch(`/api/chat/${encodeURIComponent(l)}/rewind`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entryId:e})})).ok)return!1;let t=await fetch(`/api/chat/${encodeURIComponent(l)}`).then(e=>e.json()).catch(()=>null),n=t?.session?.messages??[];return n.length>0&&b(n),!0}return b(t=>{let n=t.findIndex(t=>t.id===e),r=-1!==n?t.slice(0,n):t;return g(r),r}),!0},[s,a,l,g,h,f,n,b]),S=(0,i.hb)(e=>{s&&(a?m.abort():h.current&&(h.current.abort(),h.current=null),f(!1)),b(t=>{let n=t.findIndex(t=>t.id===e);if(n>0&&"user"===t[n-1].role){let e=t[n-1];setTimeout(()=>{let t=Array.isArray(e.attachments)?e.attachments:[];u(e.content,t)},0);let r=t.slice(0,n-1);return g(r),r}return t})},[s,u,g,a,m,h,f,b]),T=(0,i.hb)((e,t)=>{let n=`new-${Date.now()}`;w(e=>{let t=new URLSearchParams(e);return t.set("sessionId",n),t},{replace:!0}),b([]),setTimeout(()=>{u(e,t)},0)},[w,u,b]),z=(0,i.hb)(()=>(x.current=!0,a?m.abort():h.current&&(h.current.abort(),h.current=null),f(!1),c.length),[a,m,h,f,c.length,x]),$=(0,i.hb)(e=>{if("auto"!==e){if(!a){k.current=e;return}m.setThinkingLevel(e)}},[a,m,k]);return{handleSend:D,handleEditQueueItem:F,handleSendNowQueueItem:A,handleUndo:C,handleRetry:S,submitNewChat:T,stopGenerating:z,handleThinkingLevelChange:$,handleModelChange:(0,i.hb)((e,t)=>{if(!a){v.current={provider:e,modelId:t};return}m.setModel(e,t)},[a,m,v]),closeExtensionDialog:(0,i.hb)(()=>{Y()},[Y])}}({inputValue:k,setInputValue:y,setInputAttachments:w,isGenerating:A,isOmpSession:J,sessionId:l,appSettings:n,messageQueue:el,setMessageQueue:eo,executeSend:eb,steerOmpAgent:eg,ompAgent:ex,abortControllerRef:j,setGenerating:M,stopHoldRef:P,persistMessages:ea,setLocalMessages:D,pendingComposerModelRef:X,pendingThinkingLevelRef:ee,composerModelRef:et,accessModeRef:ei,setSearchParams:a,dismissExtensionDialog:eh});return{sessionId:l,folderId:o,isOmpSession:J,selectedFolderId:c,setSelectedFolderId:u,sessionData:W,localMessages:Y,isGenerating:A,hasMore:q,loadingOlder:G,loadOlderError:V,sessionLoading:Z,loadOlder:Q,generatingVerb:z,messageQueue:el,setMessageQueue:eo,steeringQueue:ec,setSteeringQueue:ed,inputValue:k,setInputValue:y,inputAttachments:N,setInputAttachments:w,scrollRef:m,contentRef:h,showScrollBottom:f,isScrolling:x,handleScroll:g,scrollToBottom:b,jumpToBottom:v,handleSend:ev,handleEditQueueItem:ek,handleSendNowQueueItem:ey,handleUndo:eN,handleRetry:ew,submitNewChat:eY,stopGenerating:eD,handleThinkingLevelChange:eF,handleModelChange:eA,accessMode:en,handleAccessModeChange:es,composerModelRef:et,extensionDialog:ep,closeExtensionDialog:eC,respondToExtensionUi:ex.respondToExtensionUi}}({folders:c,appSettings:n}),{toasts:X,pushToast:ee,dismissToast:et}=(0,id.Y)(),[en,er]=(0,i.J0)(null),{pendingUndo:ei,undoing:es,requestUndo:ea,closeUndoConfirm:el,confirmUndo:eo}=function(e){let[t,n]=(0,i.J0)(null),[r,s]=(0,i.J0)(!1),a=(0,i.hb)((e,t)=>{n({id:e,content:t??""})},[]),l=(0,i.hb)(()=>n(null),[]),o=(0,i.hb)(async()=>{!t||r||(s(!0),await e(t.id,t.content)&&n(null),s(!1))},[e,t,r]);return{pendingUndo:t,undoing:r,requestUndo:a,closeUndoConfirm:l,confirmUndo:o}}(O),[ec,ed]=(0,s.o)(),eu=(0,i.hb)(()=>{let e=W();0!==e&&ee(`Stopped. ${e} message${e>1?"s":""} still queued — nothing was sent.`,"success",{action:{label:"Send now",onClick:()=>{let e=w[0];e&&I(e)}},duration:8e3})},[W,ee,w,I]),{activeSubagent:ep,back:em}=function(e,t,n){let[r,s]=(0,i.J0)(null);return(0,i.vJ)(()=>{let e=e=>{let t=e.detail,r=t?.subagent,i=t?.sessionId;r&&i&&(s(r),n(e=>(e.get("sessionId")===i&&e.get("subagent")===r.id||(e.set("sessionId",i),e.set("subagent",r.id)),e),{replace:!1}))};return window.addEventListener("omp:view-subagent",e),()=>window.removeEventListener("omp:view-subagent",e)},[n]),(0,i.vJ)(()=>{if(!t)return void s(null);if(r?.id===t||!e)return;let n=!1;return fetch(`/api/sessions/${encodeURIComponent(e)}/subagents`).then(e=>e.ok?e.json():null).then(e=>{if(n||!e?.subagents)return;let r=e.subagents.find(e=>(0,t3.u)(e)&&e.id===t);r&&s((0,io.Nh)(r))}).catch(()=>{}),()=>{n=!0}},[e,t]),{activeSubagent:r,back:(0,i.hb)(()=>{s(null),n(e=>(e.has("subagent")&&e.delete("subagent"),e),{replace:!0})},[n])}}(u,ec.get("subagent"),ed);!function(e,t,n){let[r,s]=(0,i.J0)(null);(0,i.vJ)(()=>{s(null)},[e]),(0,i.vJ)(()=>{let t=t=>{let n=t.detail;n?.sessionId&&n.title&&String(n.sessionId)===String(e)&&s(n.title)};return window.addEventListener("omp:session-renamed",t),()=>window.removeEventListener("omp:session-renamed",t)},[e]),(0,i.vJ)(()=>{let i=(0,il.fN)(e)?(0,il.g2)(e):null;n?.(i??r??t??null)},[e,t,r,n])}(u,h?.title,a);let eh=(0,i.hb)(e=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:"smooth",block:"center"})},[]),ef=(0,i.hb)(e=>er(e),[]),ex=rN(rw)??{},eg=rN(ic)??{},eb=(0,i.Kr)(()=>f.filter(e=>"user"===e.role),[f]),ev="object"==typeof h?.model?h.model.provider:void 0,ek="object"==typeof h?.model?ex[h.model.modelId]??h.model.modelId:h?.model,ey=!!u?.startsWith("new-"),eN=(0,ip.M)(c,u,p),ew=!ey&&k&&0===f.length;return!u||ey?(0,r.Y)(n4,{className:t,folders:c,selectedFolderId:p,setSelectedFolderId:m,rootPath:eN,inputValue:A,setInputValue:C,inputAttachments:S,setInputAttachments:T,onSend:E,isGenerating:x,appSettings:n,messages:f,provider:ev,providerNames:eg,modelName:ek,modelNames:ex,onThinkingLevelChange:K,onModelChange:H,accessMode:B,onAccessModeChange:q,composerModelRef:G,sessionModel:"object"==typeof h?.model?h.model:null,sessionThinkingLevel:h?.thinkingLevel,generatingVerb:N,variant:l}):(0,r.FD)("div",{className:`flex flex-col h-full min-h-0 overflow-hidden bg-canvas relative ${t}`,children:[ew?(0,r.Y)(n6,{}):(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"relative flex-1 min-h-0 flex flex-col",children:ep?(0,r.Y)(rD,{sessionId:u,subagent:ep,onBack:em,provider:ev,providerNames:eg}):(0,r.Y)(rS,{isMobile:d,userMessages:eb,onScrollTo:eh,scrollRef:z,contentRef:$,handleScroll:M,isScrolling:L,loadingOlder:b,hasMore:g,loadOlderError:v,loadOlder:y,messages:f,isGenerating:x,provider:ev,providerNames:eg,modelName:ek,modelNames:ex,thinkingLevel:h?.thinkingLevel,onUndo:ea,onRetry:J,onNewChat:ef,showScrollBottom:j,jumpToBottom:P})}),!ep&&(0,r.Y)(rj,{isMobile:d,isGenerating:x,modelName:ek,generatingVerb:N,provider:ev,providerNames:eg,messageQueue:w,setMessageQueue:Y,onEditQueueItem:R,onSendNowQueueItem:I,steeringQueue:D,setSteeringQueue:F,inputValue:A,setInputValue:C,rootPath:eN,attachments:S,setAttachments:T,onSend:E,onStop:eu,appSettings:n,onThinkingLevelChange:K,onModelChange:H,accessMode:B,onAccessModeChange:q,composerModelRef:G,sessionModel:"object"==typeof h?.model?h.model:null,sessionThinkingLevel:h?.thinkingLevel,variant:l})]}),ei&&(0,r.Y)(n7,{isOmpSession:!!u&&!u.startsWith("new-")&&Number.isNaN(Number(u)),content:ei.content,undoing:es,onClose:el,onConfirm:eo}),null!==en&&(0,r.Y)(re,{initialContent:en,onClose:()=>er(null),onSend:_,appSettings:n,accessMode:B,onAccessModeChange:q,composerModelRef:G}),V&&(0,r.Y)(o,{request:V,onRespond:(e,t)=>{Q(e,t),Z()}}),(0,r.Y)(iu.y,{toasts:X,onDismiss:et})]})}},K(e,t,n){var r=n("j"),i=n("H"),s=n("G"),a=n("X"),l=n("Af");let o=(0,s.q6)(null);function c(e){let{children:t,initialFolders:n=[]}=e,s=(0,a.L)(),[c,d]=(0,i.J0)(!1),u=(0,i.li)(!1),p=(0,i.li)(new Set);(0,i.vJ)(()=>{u.current||(u.current=!0,s.load("/api/sessions/list"))},[]),(0,i.vJ)(()=>{s.data&&d(!0)},[s.data]);let m=(0,i.Kr)(()=>()=>{"idle"===s.state&&s.load("/api/sessions/list")},[s]),h=!!s.data?.folders?.some(e=>e.sessions?.some(e=>"stream"===e.streamStatus));(0,l.n)(m,!h,3e4);let f=(0,i.hb)(e=>{let t=String(e),n=s.data?.folders?.flatMap(e=>e.sessions??[]).find(e=>String(e.id)===t)?.streamStatus;!n||"stream"===n||p.current.has(t)||(p.current.add(t),fetch(`/api/sessions/${encodeURIComponent(t)}/stream-seen`,{method:"POST"}).then(()=>{"idle"===s.state&&s.load("/api/sessions/list")}).catch(()=>{p.current.delete(t)}))},[s]),x=(0,i.Kr)(()=>{let e=s.data,t=p.current;return{folders:(e?.folders??n).map(e=>t.size?{...e,sessions:(e.sessions??[]).map(e=>t.has(String(e.id))?{...e,streamStatus:void 0}:e)}:e),isMock:e?.isMock??!1,initializing:!c,refresh:m,markSeen:f,hasSeen:e=>t.has(String(e))}},[s.data,n,c,m,f]);return(0,r.Y)(o.Provider,{value:x,children:t})}function d(){let e=(0,i.NT)(o);return e||{folders:[],isMock:!1,initializing:!0,refresh:()=>{},markSeen:()=>{},hasSeen:()=>!1}}n.d(t,{O:()=>c,k:()=>d})},z4(e,t,n){n.d(t,{K:()=>f});var r=n("H"),i=n("s");function s(e){let t=-1/0;for(let n of e.sessions??[]){let e=function(e){if(!e)return 0/0;let t=Date.parse(e);return Number.isFinite(t)?t:0/0}(n.updated_at??n.created_at);e>t&&(t=e)}return t}function a(e){let t=-1/0;for(let n of e.sessions??[]){let e=Number(n.id);Number.isFinite(e)&&e>t&&(t=e)}return t}function l(e){let t=Number(e.id);return Number.isFinite(t)?t:-1/0}function o(e,t){return e===t?0:e>t?-1:1}function c(e,t){return e===t?0:e>t?1:-1}let d=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"];var u=n("Np"),p=n("K"),m=n("NO"),h=n("So");function f(){let e,t,n,f,x,g,b,v,k,y,N=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},w=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{includePendingSessions:Y=!1,onSelectSession:D,onAfterSelect:F}=w,{folders:A,initializing:C,refresh:S,markSeen:T,hasSeen:z}=(0,p.k)(),[$,j]=(0,i.o)(),L=$.get("sessionId"),M=L?Number.isNaN(Number(L))?L:Number(L):null,P=(0,r.li)(S);P.current=S;let E=(0,r.hb)(()=>P.current(),[]);(e=(0,r.li)(E)).current=E,t=(0,r.li)(void 0),n=(0,r.li)(0),(0,r.vJ)(()=>{let r=()=>{n.current=Date.now(),e.current()},i=()=>{let e=Date.now()-n.current;if(e>=1e3){clearTimeout(t.current),t.current=void 0,r();return}clearTimeout(t.current),t.current=setTimeout(()=>{t.current=void 0,r()},1e3-e)};return window.addEventListener("omp:session-updated",i),()=>{window.removeEventListener("omp:session-updated",i),void 0!==t.current&&(clearTimeout(t.current),t.current=void 0)}},[]),(0,m.sY)("omp:workspace-updated",()=>P.current());let[R,I]=(0,r.J0)(""),[O,J]=(0,r.J0)(!1),[_,W]=(0,r.J0)(!1),[K,U]=(0,r.J0)(()=>{var e;return"string"==typeof(e=N.omp_sidebar_sort)&&d.includes(e)?N.omp_sidebar_sort:"A-Z"}),H=(0,r.li)(null),B=(0,r.hb)(e=>{H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{(0,h.cz)("omp_sidebar_sort",e)},200)},[]);(0,r.vJ)(()=>()=>{H.current&&clearTimeout(H.current)},[]);let q=(0,r.Kr)(()=>(function(e){let t={};for(let n of e)for(let e of n.sessions??[])e.streamStatus&&(t[String(e.id)]=e.streamStatus);return t})(A),[A]);x=null!==(f=null===M?null:String(M))?q[f]:void 0,g=(0,r.li)(null),(b=(0,r.li)(E)).current=E,(v=(0,r.li)(z)).current=z,(0,r.vJ)(()=>{if(!x||"stream"===x||v.current?.(f))return;let e=`${f}:${x}`;g.current!==e&&(g.current=e,fetch(`/api/sessions/${encodeURIComponent(f)}/stream-seen`,{method:"POST"}).then(e=>e.json()).then(e=>{!1===e.deleted&&(g.current=null),b.current()}).catch(()=>{g.current=null}))},[f,x]),(k=(0,r.li)(Object.values(q).includes("stream"))).current=Object.values(q).includes("stream"),(y=(0,r.li)(E)).current=E,(0,r.vJ)(()=>{let e=setInterval(()=>{k.current&&y.current()},8e3);return()=>clearInterval(e)},[]);let G=(0,r.Kr)(()=>{let e=[...A];if(Y){let t=e.some(e=>e.sessions?.some(e=>String(e.id)===String(L))),n=L&&!t?L:null;if(n){let t=$.get("folderId"),r=t?e.find(e=>String(e.id)===String(t)):e[0],i=!!r?.sessions?.some(e=>String(e.id)===String(n));if(r&&!i){let t=(0,u.fd)(n),i=Number.isFinite(t)?new Date(t).toISOString():new Date().toISOString();e=e.map(e=>{if(e.id!==r.id)return e;let t={id:n,folder_id:e.id,title:(0,u.g2)(n),created_at:i,updated_at:i};return{...e,isExpanded:!0,sessions:[t,...e.sessions||[]]}})}}}if(R.trim()){let t=R.toLowerCase();e=Y?e.filter(e=>{let n=e.name.toLowerCase().includes(t),r=e.sessions?.some(e=>e.title.toLowerCase().includes(t));return n||r}).map(e=>{let n=e.sessions?.filter(n=>e.name.toLowerCase().includes(t)||n.title.toLowerCase().includes(t));return{...e,sessions:n,isExpanded:!0}}):e.map(e=>{let n=e.name.toLowerCase().includes(t),r=(e.sessions||[]).filter(e=>e.title.toLowerCase().includes(t));return n?e:{...e,sessions:r}}).filter(e=>e.sessions&&e.sessions.length>0)}return e=[...e].sort((e,t)=>(function(e,t,n){let r=!!e.isPinned;if(r!==!!t.isPinned)return r?-1:1;switch(n){case"Z-A":{let n=t.name.localeCompare(e.name);return 0!==n?n:c(l(e),l(t))}case"LATEST_SESSION":{let n=o(s(e),s(t));if(0!==n)return n;let r=o(a(e),a(t));if(0!==r)return r;let i=o(l(e),l(t));return 0!==i?i:e.name.localeCompare(t.name)}case"LATEST_ADDED":{let n=o(l(e),l(t));return 0!==n?n:e.name.localeCompare(t.name)}default:{let n=e.name.localeCompare(t.name);return 0!==n?n:c(l(e),l(t))}}})(e,t,K))},[A,R,K,L,$,Y]);return{folders:A,initializing:C,refresh:E,activeSessionId:M,sessionParam:L,searchQuery:R,setSearchQuery:I,showArchived:O,setShowArchived:J,optionsOpen:_,setOptionsOpen:W,sortOption:K,handleSortChange:e=>{U(e),W(!1),B(e)},processedFolders:G,sessionStatus:q,handleSelectSession:e=>{T(e),D?D(e):j(t=>(t.set("sessionId",e.toString()),t.has("subagent")&&t.delete("subagent"),t),{replace:!0}),F?.()}}}},FE(e,t,n){var r=n("H"),i=n("g0");function s(){let[e,t]=(0,r.J0)(i.aK);return(0,r.vJ)(()=>{let e=e=>{let n=e.detail;n&&t({transport:n.transport,connected:n.connected})};return window.addEventListener(i.rt,e),t((0,i.aK)()),()=>window.removeEventListener(i.rt,e)},[]),e}n.d(t,{H:()=>s})},pH(e,t,n){async function r(e){if(!e)return!1;try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch(e){}try{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",t.setAttribute("readonly",""),document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand("copy");return document.body.removeChild(t),n}catch(e){return console.error("Failed to copy text: ",e),!1}}n.d(t,{l:()=>r})},P6(e,t,n){var r=n("H");function i(e,t){let[n,i]=(0,r.J0)(!1),[s,a]=(0,r.J0)(e),l=(0,r.li)(null),o=(0,r.li)(!1);(0,r.vJ)(()=>{n&&l.current?.select()},[n]);let c=()=>{let n=s.trim();i(!1),n&&n!==e&&t?.(n)},d=()=>{o.current=!0,i(!1)};return{isEditing:n,draft:s,setDraft:a,inputRef:l,startRename:()=>{o.current=!1,a(e),i(!0)},commitRename:c,cancelRename:d,handleKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),c()):"Escape"===e.key&&(e.preventDefault(),d())},handleBlur:()=>{if(o.current){o.current=!1;return}c()}}}n.d(t,{B:()=>i})},ng(e,t,n){n("H");var r=n("So");function i(){if("u">typeof window)try{let e=window.AudioContext||window.webkitAudioContext;if(!e)return;let t=new e;"suspended"===t.state&&t.resume();let n=t.currentTime,r=t.createOscillator(),i=t.createGain();r.type="sine",r.frequency.setValueAtTime(587.33,n),r.frequency.exponentialRampToValueAtTime(880,n+.1),i.gain.setValueAtTime(0,n),i.gain.linearRampToValueAtTime(.14,n+.02),i.gain.exponentialRampToValueAtTime(1e-4,n+.32),r.connect(i),i.connect(t.destination),r.start(n),r.stop(n+.32);let s=t.createOscillator(),a=t.createGain();s.type="sine",s.frequency.setValueAtTime(880,n+.06),s.frequency.exponentialRampToValueAtTime(1174.66,n+.18),a.gain.setValueAtTime(0,n+.06),a.gain.linearRampToValueAtTime(.1,n+.08),a.gain.exponentialRampToValueAtTime(1e-4,n+.42),s.connect(a),a.connect(t.destination),s.start(n+.06),s.stop(n+.42),setTimeout(()=>{try{t.close()}catch{}},550)}catch(e){console.warn("Unable to play notification audio chime:",e)}}function s(e){(function(e){if("u"<typeof window)return!0;let t=(0,r.BF)(["chatCompletionSound","soundAlerts"],e);return void 0===t||!!t})(e)&&i()}n.d(t,{$E:()=>i,s4:()=>s})},oj(e,t,n){var r=n("H");function i(e,t){(0,r.vJ)(()=>{let n=n=>{!e.current||e.current.contains(n.target)||t(n)};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n)}},[e,t])}n.d(t,{W:()=>i})},jo(e,t,n){var r=n("H");function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:600,[t,n]=(0,r.J0)(!1),i=(0,r.li)(null),s=(0,r.hb)(()=>{n(!0),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>n(!1),e)},[e]);return(0,r.vJ)(()=>()=>{i.current&&clearTimeout(i.current)},[]),{isScrolling:t,handleScroll:s}}function s(e){return e?"scrollbar-overlay-scrolling":"scrollbar-overlay"}n.d(t,{K:()=>i,p:()=>s})},NR(e,t,n){var r=n("H");function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:7,[n,i]=(0,r.J0)(e);return{visibleCount:n,showMore:(0,r.hb)(()=>i(e=>e+t),[t])}}n.d(t,{y:()=>i})},Po(e,t,n){var r=n("H"),i=n("eh");function s(){let[e,t]=(0,r.J0)(()=>(0,i.nv)());return(0,r.vJ)(()=>{let e=(0,i.Eu)(()=>t(!0)),n=(0,i.LT)(()=>t(!0));return()=>{e(),n()}},[]),e}n.d(t,{w:()=>s})},oZ(e,t,n){var r=n("H");function i(){let[e,t]=(0,r.J0)([]),n=(0,r.li)(0);return{toasts:e,pushToast:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"error",i=arguments.length>2?arguments[2]:void 0;n.current+=1,t(t=>[...t,{id:n.current,message:e,type:r,...i}])},dismissToast:e=>{t(t=>t.filter(t=>t.id!==e))}}}n.d(t,{Y:()=>i})},DO(e,t,n){var r=n("H");function i(e,t){return"object"!=typeof e||null===e?t:"error"in e&&"string"==typeof e.error?e.error:"message"in e&&"string"==typeof e.message?e.message:t}function s(){let[e,t]=(0,r.J0)(null),[n,s]=(0,r.J0)(!1),[a,l]=(0,r.J0)(null),[o,c]=(0,r.J0)(null),d=(0,r.li)(null),u=(0,r.li)(!1),p=(0,r.hb)(()=>{if(d.current)return d.current;let e=(async()=>{s(!0),c(null);try{let e=await fetch("/api/updates/check"),n=await e.json();if(!e.ok)throw Error(i(n,`Update check failed (HTTP ${e.status})`));t(n)}catch(e){c(e instanceof Error?e.message:"Unable to check for updates.")}finally{s(!1),d.current=null}})();return d.current=e,e},[]),m=(0,r.hb)(async e=>{l(e),c(null);try{let t=await fetch("/api/updates/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:e})}),n=await t.json();if("object"!=typeof n||null===n||!("success"in n)||"boolean"!=typeof n.success||!("target"in n)||"ompchamber"!==n.target&&"omp"!==n.target||!("manual"in n)||"boolean"!=typeof n.manual||!("message"in n)||"string"!=typeof n.message)throw Error(i(n,`Update failed (HTTP ${t.status})`));return await p(),n}catch(e){return c(e instanceof Error?e.message:"Unable to apply the update."),null}finally{l(null)}},[p]);return(0,r.vJ)(()=>{u.current||(u.current=!0,p())},[]),{info:e,checking:n,applying:a,error:o,hasUpdate:!!(e?.ompchamber.updateAvailable||e?.omp.updateAvailable),check:p,apply:m}}n.d(t,{M:()=>s})},c(e,t,n){var r=n("H");function i(e,t){let{enabled:n,intervalMs:i,guardInFlight:s=!1}=t,a=(0,r.li)(e);a.current=e,(0,r.vJ)(()=>{if(!n||i<=0)return;let e="u"<typeof document||"visible"===document.visibilityState,t=!1,r=()=>{if(!s)return void a.current();if(t)return;let e=a.current();if(!e||"function"!=typeof e.then)return;t=!0;let n=()=>{t=!1};Promise.resolve(e).then(n,n)},l=setInterval(()=>{e&&r()},i),o=()=>{let t="visible"===document.visibilityState;t&&!e&&r(),e=t};return document.addEventListener("visibilitychange",o),()=>{clearInterval(l),document.removeEventListener("visibilitychange",o)}},[n,i,s])}n.d(t,{t:()=>i})},NO(e,t,n){var r=n("H");function i(e,t,n,i){let s=(0,r.li)(n);s.current=n,(0,r.vJ)(()=>{let n=e=>s.current(e);return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)},[e,t,i])}function s(e,t,n){i(window,e,t,n)}function a(e,t,n){i(document,e,t,n)}function l(e,t,n){i(window,e,t,n)}n.d(t,{MN:()=>s,sY:()=>l,zo:()=>a})},so(e,t,n){var r=n("H"),i=n("LQ"),s=n("c"),a=n("NO");function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,l=!(arguments.length>3)||void 0===arguments[3]||arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,[c,d]=(0,r.J0)([]),[u,p]=(0,r.J0)(!1),m=(0,r.hb)(()=>{if(!l)return;p(!0);let n=new URLSearchParams;e&&n.set("root",e),t&&"."!==t&&n.set("repo",t),n.set("t",String(Date.now())),fetch(`/api/fs/git?${n.toString()}`).then(e=>e.json()).then(e=>{Array.isArray(e.changes)?d(e.changes):d([])}).catch(()=>d([])).finally(()=>p(!1))},[l,e,t]);(0,r.vJ)(()=>{m()},[m,n]),(0,s.t)(m,{enabled:l,intervalMs:o}),(0,a.MN)("focus",()=>{l&&m()}),(0,a.zo)("visibilitychange",()=>{l&&m()});let h=(0,r.li)(void 0),f=(0,r.hb)(()=>{l&&void 0===h.current&&(h.current=setTimeout(()=>{h.current=void 0,m()},1e3))},[l,m]);(0,r.vJ)(()=>()=>{void 0!==h.current&&clearTimeout(h.current)},[]),(0,a.sY)("omp:session-updated",f),(0,a.sY)("omp:workspace-updated",f);let{fileMap:x,folderMap:g}=(0,r.Kr)(()=>(0,i._)(c),[c]);return{changes:c,fileMap:x,folderMap:g,isLoading:u,refreshGitStatus:m}}n.d(t,{e:()=>l})},Af(e,t,n){var r=n("H"),i=n("Kc"),s=n("c");function a(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3;(0,s.t)(e,{enabled:t,intervalMs:n,guardInFlight:!0})}function l(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500,s=(0,r.li)(e);s.current=e,(0,r.vJ)(()=>{let e;if(!t)return;let r=()=>{clearTimeout(e),e=window.setTimeout(()=>{e=void 0,("u"<typeof document||"visible"===document.visibilityState)&&s.current()},n)};return window.addEventListener(i.s,r),()=>{window.removeEventListener(i.s,r),clearTimeout(e)}},[t,n])}n.d(t,{n:()=>a,w:()=>l})},As(e,t,n){var r=n("H");let i=(0,n("G").q6)(null);function s(){let e=(0,r.NT)(i);if(!e)throw Error("useSessionState used outside SessionStateProvider");return e}n.d(t,{O:()=>s},{b:i})},FL(e,t,n){var r=n("H"),i=n("SS"),s=n("As");function a(e,t){let{sessionId:n,ready:a}=(0,s.O)(),l=(0,i.WV)(n,e),[o,c]=(0,r.J0)(void 0===l?t:l),d=(0,r.li)(n);(0,r.vJ)(()=>{if(d.current!==n&&(d.current=n),!a)return;let r=(0,i.WV)(n,e);c(void 0===r?t:r)},[n,a,e]);let u=t=>{let r="function"==typeof t?t((0,i.WV)(n,e)??o):t;c(r),(0,i.qI)(n,e,r)};return a||void 0===l||l===o?[o,u,a]:[l,u,a]}function l(){let{sessionId:e,ready:t}=(0,s.O)();return{sessionId:e,ready:t,read:(t,n)=>{let r=(0,i.WV)(e,t);return void 0===r?n:r},hydrate:t=>(0,i.E9)(e,t)}}n.d(t,{bL:()=>a,p0:()=>l},{LO:a})},U(e,t,n){var r=n("H"),i=n("X");function s(e,t){let[n,s]=(0,r.J0)(!1),a=(0,i.L)(),l=(0,i.L)(),o=(0,i.L)();return(0,r.vJ)(()=>{(a.data?.success||l.data?.success)&&window.dispatchEvent(new CustomEvent("omp:workspace-updated"))},[l.data,a.data]),{confirmDelete:n,requestDelete:()=>s(!0),cancelDelete:()=>s(!1),handlePin:()=>{"number"==typeof e.id&&(a.submit({isPinned:String(!e.isPinned)},{method:"POST",action:`/api/folders/${e.id}/pin`}),t())},handleDelete:()=>{"number"==typeof e.id&&(l.submit({},{method:"POST",action:`/api/folders/${e.id}/delete`}),s(!1),t())},handleArchive:e=>{let n=1!==e.is_archived;o.submit({archived:String(n)},{method:"POST",action:`/api/sessions/${e.id}/archive`}),t()},handleRename:async(e,n)=>{try{let t=new FormData;if(t.set("name",n),!(await fetch(`/api/sessions/${encodeURIComponent(String(e.id))}/rename`,{method:"POST",body:t})).ok)return}catch{return}window.dispatchEvent(new CustomEvent("omp:session-renamed",{detail:{sessionId:String(e.id),title:n}})),t()}}}n.d(t,{C:()=>s})},X(e,t,n){var r=n("H");async function i(e){let t=await e.text();if(t)try{return JSON.parse(t)}catch{return}}function s(){let[e,t]=(0,r.J0)(void 0),[n,s]=(0,r.J0)("idle"),a=(0,r.li)(!0),l=(0,r.li)(null);(0,r.vJ)(()=>(a.current=!0,()=>{a.current=!1,l.current?.abort(),l.current=null}),[]);let o=(0,r.hb)(async(e,n,r)=>{l.current?.abort();let o=new AbortController;l.current=o,s(r);try{let r=await fetch(e,{...n,signal:o.signal}),s=await i(r);a.current&&l.current===o&&t(s)}catch{}finally{a.current&&l.current===o&&(l.current=null,s("idle"))}},[]);return{data:e,state:n,load:(0,r.hb)(e=>o(e,{method:"GET"},"loading"),[o]),submit:(0,r.hb)((e,t)=>o(t.action,{method:(t.method??"POST").toUpperCase(),body:function(e){if(e instanceof FormData)return e;let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&t.set(n,String(r));return t}(e),headers:e instanceof FormData?void 0:{"content-type":"application/x-www-form-urlencoded"}},"submitting"),[o])}}n.d(t,{L:()=>s})},s(e,t,n){var r=n("G");let i=new Set,s="u"<typeof window?"":window.location.search;function a(){for(let e of i)e()}function l(e){return i.add(e),()=>i.delete(e)}function o(e){if("string"==typeof e)return e.startsWith("?")?e:`?${e}`;if(e instanceof URLSearchParams)return e.toString()?`?${e.toString()}`:"";let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&t.set(n,String(r));return t.toString()?`?${t.toString()}`:""}function c(){return s}function d(){let e=(0,r.rz)(l,c),t=(0,r.hb)((e,t)=>{var n;let r=(n=new URLSearchParams(s),"function"==typeof e?o(e(new URLSearchParams(n))):o(e)),i=`${window.location.pathname}${r}${window.location.hash}`;t?.replace?window.history.replaceState(null,"",i):window.history.pushState(null,"",i),s=r,a()},[]);return[new URLSearchParams(e),t]}"u">typeof window&&window.addEventListener("popstate",function(){let e="u"<typeof window?"":window.location.search;e!==s&&(s=e,a())}),n.d(t,{o:()=>d})},d(e,t,n){var r=n("j"),i=n("v"),s=n("H"),a=n("G"),l=n("s");let o=(0,a.q6)(null);function c(e,t,n){return Math.min(Math.max(e,t),n)}function d(e,t){return"number"==typeof e?e:"string"==typeof e&&parseFloat(e)||t}function u(e){let{orientation:t,id:n,groupRef:i,onLayoutChanged:l,className:d,children:u}=e,p=(0,s.li)(new Map),m=(0,s.li)(l??null);m.current=l??null;let h=(0,a.Kr)(()=>({orientation:t,panels:p,onLayoutChanged:m}),[t]);return(0,a.vJ)(()=>{if(i)return i.current={setLayout:e=>{for(let[t,n]of Object.entries(e)){let e=p.current.get(t);e&&!e.isFiller&&"number"==typeof n&&e.setSize(c(n,e.minSize,e.maxSize))}m.current?.((()=>{let e={};for(let[t,n]of p.current){let r=n.getSize();null!=r&&(e[t]=r)}return e})(),{isUserInteraction:!1})}},()=>{i.current=null}},[i]),(0,r.Y)(o.Provider,{value:h,children:(0,r.Y)("div",{"data-panel-group":"","data-panel-group-id":n,className:d,style:{display:"flex",flex:"1 1 0%",flexDirection:"horizontal"===t?"row":"column",minWidth:0,minHeight:0},children:u})})}function p(e){let{id:t,panelRef:n,defaultSize:i,minSize:s=0,maxSize:l,filler:u=!1,className:p,style:m,children:h}=e,f=(0,a.NT)(o);if(!f)throw Error(`<Panel id="${t}"> must be rendered inside a <Group>`);let{orientation:x,panels:g}=f,b=d(s,0),v=null!=l?d(l,Number.MAX_SAFE_INTEGER):Number.MAX_SAFE_INTEGER,k=(0,a.li)(null),[y,N]=(0,a.J0)(()=>u?null:c(d(i,b),b,v)),w=(0,a.li)(y);w.current=y,(0,a.vJ)(()=>(g.current.set(t,{id:t,isFiller:u,minSize:b,maxSize:v,setSize:e=>N(e),getSize:()=>w.current}),()=>{g.current.delete(t)}),[t]),(0,a.vJ)(()=>{let e=g.current.get(t);e&&(e.minSize=b,e.maxSize=v)}),(0,a.vJ)(()=>{if(n)return n.current={resize:e=>{N(c(e,b,v))},getSize:()=>{let e=w.current;return null!=e?{inPixels:e}:null}},()=>{n.current=null}},[n,b,v]);let Y=u?{flex:"1 1 0%",minWidth:0,minHeight:0,overflow:"hidden",position:"relative"}:{flex:"0 1 auto",width:"horizontal"===x?y??void 0:void 0,height:"horizontal"===x?void 0:y??void 0,minWidth:"horizontal"===x?b:void 0,minHeight:"horizontal"===x?void 0:b,maxWidth:null!=l?v:void 0,overflow:"hidden",position:"relative"};return(0,r.Y)("div",{ref:k,"data-panel":"","data-panel-id":t,className:p,style:{...Y,...m},children:h})}function m(e){let{className:t,style:n,children:i}=e,s=(0,a.NT)(o),[l,d]=(0,a.J0)(!1),u=(0,a.li)(null),p=(0,a.li)(null);if((0,a.vJ)(()=>()=>p.current?.(),[]),!s)throw Error("<Separator> must be rendered inside a <Group>");let{orientation:m,panels:h,onLayoutChanged:f}=s;return(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{ref:u,"data-separator":"",role:"separator","aria-orientation":"horizontal"===m?"vertical":"horizontal",className:t,style:n,onPointerDown:e=>{let t=u.current;if(!t||0!==e.button)return;let n=t.previousElementSibling,r=t.nextElementSibling,i=n?.getAttribute("data-panel-id"),s=r?.getAttribute("data-panel-id"),a=i?h.current.get(i):void 0,l=s?h.current.get(s):void 0;if(!a||!l||!n||!r)return;e.preventDefault(),d(!0);let o="horizontal"===m?e.clientX:e.clientY,x=e=>"horizontal"===m?e.getBoundingClientRect().width:e.getBoundingClientRect().height,g=a.getSize()??x(n),b=l.getSize()??x(r),v=e=>{var t,n;let r="horizontal"===m?e.clientX:e.clientY,i=(t={size:g,min:a.minSize,max:a.maxSize},n={size:b,min:l.minSize,max:l.maxSize},c(r-o,Math.max(t.min-t.size,n.min-n.size),Math.min(t.max-t.size,n.size-n.min)));a.setSize(c(g+i,a.minSize,a.maxSize)),l.isFiller||l.setSize(c(b-i,l.minSize,l.maxSize))},k=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),p.current=null,d(!1);let e={};for(let[t,n]of h.current){let r=n.getSize();null!=r&&(e[t]=r)}f.current?.(e,{isUserInteraction:!0})},y=()=>k();window.addEventListener("pointermove",v),window.addEventListener("pointerup",y),window.addEventListener("pointercancel",y),p.current=k},onDragStart:e=>e.preventDefault(),children:i}),l&&(0,r.Y)("div",{style:{position:"fixed",inset:0,zIndex:9999,cursor:"horizontal"===m?"col-resize":"row-resize"}})]})}var h=n("g"),f=n("r");function x(e){let{onNewSession:t}=e;return(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"h-12 flex-shrink-0 flex items-center px-4 border-b border-ink/10 titlebar-drag-region select-none",style:{paddingLeft:"max(1rem, env(titlebar-area-x, 0px))"},children:(0,r.FD)("span",{className:"font-bold text-sm tracking-tight flex items-center",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-[15px] tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"ml-[1px]",children:"Chamber"})]})}),(0,r.Y)("div",{className:"px-3 pt-3 titlebar-no-drag",children:(0,r.FD)("button",{onClick:t,className:"w-full flex items-center justify-center space-x-2 py-2 bg-ink text-canvas rounded text-xs font-semibold hover:bg-ink/90 transition-colors cursor-pointer",children:[(0,r.Y)(f.A,{size:14}),(0,r.Y)("span",{children:"New Session"})]})})]})}var g=n("D"),b=n("O"),v=n("n"),k=n("t3"),y=n("p7"),N=n("Sj"),w=n("x"),Y=n("S"),D=n("E");function F(e){let{isSearchVisible:t,searchQuery:n,showArchived:i,optionsOpen:s,sortOption:a,onToggleSearch:l,onSearchChange:o,onToggleArchived:c,onHideArchived:d,onToggleOptions:u,onCloseOptions:p,onSortChange:m,onNewWorkspace:h,onScheduler:f,onRefresh:x,onClose:F}=e;return(0,r.FD)("div",{className:"p-3 border-b border-ink/10 flex flex-col space-y-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between px-1 text-ink/60",children:[(0,r.FD)("div",{className:"flex space-x-3 items-center",children:[(0,r.Y)(g.A,{size:14,className:"hover:text-ink cursor-pointer",onClick:h}),(0,r.Y)(b.A,{size:14,className:"hover:text-ink cursor-pointer",onClick:f}),(0,r.Y)("span",{title:"Refresh sessions",onClick:x,className:"inline-flex cursor-pointer",children:(0,r.Y)(v.A,{size:14,className:"hover:text-ink"})})]}),(0,r.FD)("div",{className:"flex space-x-3 items-center relative",children:[(0,r.Y)(k.A,{size:14,className:`cursor-pointer transition-colors ${t?"text-ink":"hover:text-ink"}`,onClick:l}),(0,r.Y)("span",{title:i?"Hide Archive":"Show Archive",onClick:c,className:"inline-flex cursor-pointer",children:(0,r.Y)(y.A,{size:14,className:`transition-colors ${i?"text-ink":"hover:text-ink"}`})}),(0,r.FD)("div",{className:"relative",children:[(0,r.Y)(N.A,{size:14,className:`cursor-pointer transition-colors ${s?"text-ink":"hover:text-ink"}`,onClick:u}),s&&(0,r.Y)("div",{className:"absolute right-0 top-full mt-2 w-48 bg-paper border border-ink/10 rounded shadow-lg z-50 py-1",onMouseLeave:p,children:(0,r.Y)(D.i,{variant:"desktop",sortOption:a,onSortChange:m})})]}),(0,r.Y)(w.A,{size:14,className:"hover:text-ink cursor-pointer ml-1",onClick:F})]})]}),t&&(0,r.Y)("div",{className:"pt-1",children:(0,r.Y)("input",{type:"text",placeholder:"Search workspaces & sessions...",value:n,onChange:e=>o(e.currentTarget.value),autoFocus:!0,className:"w-full bg-ink/5 border border-ink/10 rounded px-2.5 py-1.5 outline-none focus:border-ink/30 text-xs text-ink placeholder-ink/40 transition-colors"})}),i&&(0,r.FD)("div",{className:"flex items-center justify-between bg-amber-500/10 border border-amber-500/20 text-amber-900 rounded px-2.5 py-1.5 text-[10px] font-medium",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5",children:[(0,r.Y)(y.A,{size:10}),(0,r.Y)("span",{children:"Showing Archived"})]}),(0,r.Y)("button",{className:"hover:text-amber-950",onClick:d,children:(0,r.Y)(Y.A,{size:10})})]})]})}var A=n("vB"),C=n("wU");function S(e){let{onSettings:t,onInfo:n,updateAvailable:i,onUpdateClick:s}=e;return(0,r.FD)("div",{className:"p-3 border-t border-ink/10 flex items-center justify-between text-ink/60 shrink-0",children:[(0,r.FD)("div",{className:"flex space-x-3",children:[(0,r.Y)(A.A,{size:16,className:"hover:text-ink cursor-pointer",onClick:t}),(0,r.Y)(C.A,{size:16,className:"hover:text-ink cursor-pointer",onClick:n})]}),i&&(0,r.Y)("button",{type:"button",onClick:s,className:"px-2 py-0.5 rounded-full border border-ink/20 text-[10px] font-semibold text-ink hover:border-ink/40",children:"update"})]})}var T=n("a"),z=n("X"),$=n("oj"),j=n("NR"),L=n("U"),M=n("Go"),P=n("Nf"),E=n("t"),R=n("z"),I=n("b"),O=n("HZ"),J=n("P6");function _(e){let{title:t,isActive:n=!1,isArchived:i=!1,status:s,onClick:a,onArchive:l,onRename:o,expandable:c=!1,isExpanded:d=!1,hasSubagents:u=!1,onToggleExpand:p}=e,m=!!(c&&u&&p),{isEditing:h,draft:f,setDraft:x,inputRef:g,startRename:b,handleKeyDown:v,handleBlur:k}=(0,J.B)(t,o);return(0,r.FD)("div",{onClick:h?void 0:a,className:`group/item relative flex items-center w-full rounded-lg px-2 py-1.5 cursor-pointer text-xs transition-colors select-none ${n?"bg-ink/10 font-medium text-ink":"text-ink/75 hover:text-ink hover:bg-ink/5"}`,children:[(0,r.FD)("span",{className:"relative w-4 h-4 shrink-0",children:[m&&p&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),p(e)},title:d?"Collapse subagents":"Expand subagents","aria-expanded":d,className:`peer absolute inset-0 flex items-center justify-center rounded cursor-pointer text-ink/40 transition-opacity hover:text-ink ${d?"":"pointer-events-none opacity-0 group-hover/item:pointer-events-auto group-hover/item:opacity-100 focus-visible:opacity-100"}`,children:d?(0,r.Y)(M.A,{size:13,className:"text-ink/70"}):(0,r.Y)(P.A,{size:13})}),s&&!(m&&d)&&(0,r.Y)("span",{className:`absolute inset-0 flex items-center justify-center text-ink/60 transition-opacity ${m?"group-hover/item:opacity-0 peer-focus-visible:opacity-0":""}`,children:"stream"===s?(0,r.Y)(E.A,{size:12,className:"animate-spin"}):(0,r.Y)(R.A,{size:12})})]}),(0,r.Y)("span",{className:"w-2 shrink-0"}),h?(0,r.Y)("input",{ref:g,autoFocus:!0,value:f,onChange:e=>x(e.currentTarget.value),onClick:e=>e.stopPropagation(),onKeyDown:v,onBlur:k,className:"flex-1 min-w-0 bg-paper border border-ink/25 rounded px-1 py-0.5 text-xs text-ink outline-none focus:border-ink/50"}):(0,r.Y)("span",{className:"flex-1 min-w-0 truncate leading-snug",children:t.charAt(0).toUpperCase()+t.slice(1)}),!h&&(o||l)&&(0,r.FD)("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2 flex items-center gap-0.5 opacity-0 group-hover/item:opacity-100 transition-opacity",children:[o&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),b()},title:"Rename session",className:"p-1 text-ink/40 hover:text-ink bg-paper/90 hover:bg-ink/10 rounded shadow-xs cursor-pointer",children:(0,r.Y)(I.A,{size:12})}),l&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),l()},title:i?"Unarchive session":"Archive session",className:"p-1 text-ink/40 hover:text-ink bg-paper/90 hover:bg-ink/10 rounded shadow-xs cursor-pointer",children:i?(0,r.Y)(O.A,{size:12}):(0,r.Y)(y.A,{size:12})})]})]})}var W=n("Uo"),K=n("oS"),U=n("B"),H=n("T");let B={pending:"started",running:"started",completed:"completed",failed:"failed",aborted:"aborted"};function q(e){let{sessionId:t,isActiveSession:n}=e,[i]=(0,l.o)(),a=i.get("subagent"),[o,c]=(0,s.J0)([]),[d,u]=(0,s.J0)(!1);(0,s.vJ)(()=>{let e=!1,n=String(t);return c([]),u(!0),(0,U.wv)(n).then(t=>{if(e||!t)return;let n=t.map(U.Nh);c(e=>(0,H.j8)(e,n))}).finally(()=>{e||u(!1)}),()=>{e=!0}},[t]),(0,s.vJ)(()=>{if(!n)return;let e=!1,r=String(t),i=Date.now(),s=e=>{let t=e.detail;return t&&t.sessionId===r?t:null},a=e=>{let t=(0,H.bH)(s(e)?.payload);t&&c(e=>(0,H.j8)(e,[t]))},l=e=>{let t=function(e){let t=(0,H.mq)(e);if(!(0,K.u)(e)||!(0,K.u)(e.progress))return t;let n=(0,H.mq)(e.progress);return n?{...n,id:n.id??t?.id,index:n.index??t?.index}:t}(s(e)?.payload);t&&c(e=>e.map(e=>{if(void 0!==t.id){if(e.id!==t.id)return e}else if(void 0===t.index||t.index<0||e.index!==t.index)return e;let n=t.status&&"started"===e.status?B[t.status]??e.status:e.status;return{...e,status:n,progress:{...e.progress,...t},lastUpdate:Date.now()}}))};return window.addEventListener("subagent_lifecycle",a),window.addEventListener("subagent_progress",l),fetch(`/api/agent/${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_subagents"})}).then(e=>e.ok?e.json():null).then(t=>{if(e||!(0,K.u)(t))return;let n="data"in t?t.data:t;c(e=>(0,H.j8)(e,(0,H.vG)(n),i))}).catch(()=>{}),()=>{e=!0,window.removeEventListener("subagent_lifecycle",a),window.removeEventListener("subagent_progress",l)}},[n,t]);let p=d?"Loading subagents…":0===o.length?"No subagent activity":null;return(0,r.Y)("div",{className:"pl-6 pr-0 space-y-0.5 py-0.5",children:p?(0,r.FD)("div",{className:"px-2 py-1 text-xs italic text-ink/40 flex items-center",children:[(0,r.Y)("span",{className:"w-4 h-4 shrink-0"}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"flex-1 min-w-0 truncate",children:p})]}):o.map(e=>{let i=e.task??e.description??e.assignment??e.agent??"",s=e.id===a;return(0,r.FD)("button",{type:"button",title:i,onClick:()=>window.dispatchEvent(new CustomEvent("omp:view-subagent",{detail:{sessionId:String(t),subagent:e}})),className:`w-full flex items-center text-left text-xs rounded-md px-2 py-1 cursor-pointer transition-colors select-none group/subagent ${s?"bg-ink/10 font-medium text-ink":"text-ink/70 hover:text-ink hover:bg-ink/5"}`,children:[(0,r.Y)("span",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:(0,r.Y)(W.l,{status:e.status,live:n&&"started"===e.status,size:11})}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"flex-1 min-w-0 truncate leading-snug",children:i})]},e.id)})})}var G=n("C4"),V=n("So");let Z="omp_sidebar_expanded_sessions";var Q=n("A"),X=n("K");function ee(e){let{folder:t,activeSessionId:n,onSelectSession:i,onNewSessionForFolder:a,forceExpanded:o=!1,showArchived:c=!1,sessionStatus:d={}}=e,[u,p]=(0,s.J0)(t.isExpanded||!1),[m,h]=(0,s.J0)(!1),{visibleCount:x,showMore:g}=(0,j.y)(),[b]=(0,l.o)(),v=b.get("subagent"),k=b.get("sessionId"),[y,w]=(0,s.J0)(()=>new Set);(0,s.vJ)(()=>{let e,t=Array.isArray(e=(0,V.BF)(Z))?new Set(e.filter(e=>"string"==typeof e)):new Set;t&&t.size>0&&w(t)},[]),(0,s.vJ)(()=>{"boolean"==typeof t.isExpanded&&p(t.isExpanded)},[t.isExpanded]),(0,s.vJ)(()=>{v&&k&&w(e=>{if(e.has(k))return e;let t=new Set(e);return t.add(k),t})},[v,k]);let Y=(0,s.li)(null),{refresh:D}=(0,X.k)(),F=(0,z.L)(),{confirmDelete:A,requestDelete:C,cancelDelete:S,handlePin:M,handleDelete:P,handleArchive:E,handleRename:R}=(0,L.C)(t,D);(0,s.vJ)(()=>{F.data?.success&&window.dispatchEvent(new CustomEvent("omp:workspace-updated"))},[F.data]),(0,$.W)(Y,()=>{h(!1),S()});let I=t.sessions,O=(0,Q.x)(t.icon),J=(I||[]).filter(e=>c?1===e.is_archived:1!==e.is_archived),W=J.slice(0,x),K=J.length>x;return(0,r.FD)("div",{className:"space-y-1",children:[(0,r.FD)("div",{className:"group flex items-center justify-between h-7 text-xs font-semibold text-ink px-2 hover:bg-ink/5 rounded-md transition-colors select-none",children:[(0,r.FD)("div",{className:"flex-1 h-full flex items-center cursor-pointer min-w-0",onClick:()=>{let e=!u;p(e),"number"==typeof t.id&&F.submit({isExpanded:String(e)},{method:"POST",action:`/api/folders/${t.id}/toggle`})},children:[(0,r.Y)("span",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:t.customIconUrl?(0,r.Y)("img",{src:t.customIconUrl,alt:"",className:"w-[15px] h-[15px] rounded-xs object-contain shrink-0",referrerPolicy:"no-referrer"}):(0,r.Y)(O,{size:15,className:"text-ink/75",style:{color:t.accentColor||void 0}})}),(0,r.Y)("span",{className:"w-2 shrink-0"}),t.isPinned&&(0,r.Y)(T.A,{size:11,className:"text-ink/60 shrink-0 mr-1.5"}),(0,r.Y)("span",{className:"truncate text-[13px] font-semibold tracking-tight",children:t.name})]}),(0,r.FD)("div",{className:`items-center space-x-0.5 pl-1 ${m?"flex":"hidden group-hover:flex"}`,children:[(0,r.Y)("button",{type:"button",title:"New Session",className:"w-5 h-5 flex items-center justify-center text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer transition-colors",onClick:e=>{e.stopPropagation(),a(t.id)},children:(0,r.Y)(f.A,{size:12})}),(0,r.FD)("div",{className:"relative flex items-center",ref:Y,children:[(0,r.Y)("button",{type:"button",title:"Workspace Options",className:"w-5 h-5 flex items-center justify-center text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer transition-colors",onClick:e=>{e.stopPropagation(),h(!m)},children:(0,r.Y)(N.A,{size:12})}),m&&(0,r.Y)("div",{className:"absolute right-0 top-full mt-1 w-44 bg-paper border border-ink/15 rounded-md shadow-lg z-50 py-1 text-xs",children:(0,r.Y)(G.t,{variant:"desktop",isPinned:t.isPinned,confirmDelete:A,onPin:()=>{M(),h(!1)},onDelete:()=>{P(),h(!1)},onRequestDelete:C,onCancelDelete:S})})]})]})]}),(o||u)&&(0,r.FD)("div",{className:"space-y-0.5",children:[W.map(e=>{let t=String(e.id),s=null!==n?String(n)===t:1===e.is_active,a=s&&k===t&&!!v,l=null!==n&&t===String(n),o=!!e.hasSubagents,c=o&&y.has(t);return(0,r.FD)("div",{className:"space-y-0.5",children:[(0,r.Y)(_,{title:e.title,isActive:s&&!a,isArchived:1===e.is_archived,status:d[t],onClick:()=>i(e.id),onArchive:()=>E(e),onRename:String(e.id).startsWith("new-")?void 0:t=>void R(e,t),expandable:o,hasSubagents:o,isExpanded:c,onToggleExpand:()=>{w(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),(0,V.cz)(Z,[...n].slice(-50)),n})}}),o&&c&&(0,r.Y)(q,{sessionId:e.id,isActiveSession:l})]},e.id)}),K&&!o&&(0,r.FD)("button",{type:"button",onClick:g,className:"flex items-center text-xs text-ink/45 hover:text-ink/80 w-full text-left py-1.5 px-2 rounded-lg hover:bg-ink/5 transition-colors cursor-pointer select-none",children:[(0,r.Y)("span",{className:"w-4 h-4 shrink-0"}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"truncate leading-snug",children:"Show more sessions"})]}),0===J.length&&(0,r.Y)("div",{className:"px-3 py-2 text-[11px] text-ink/40 italic",children:c?"No archived sessions.":"No sessions."})]})]})}var et=n("jo");function en(e){let{folders:t,activeSessionId:n,searchQuery:i,showArchived:s,sessionStatus:a,isScrolling:l,onScroll:o,onSelectSession:c,onNewSessionForFolder:d}=e;return(0,r.Y)("div",{onScroll:o,className:`flex-1 scrollbar-overlay-container p-2 space-y-4 ${(0,et.p)(l)}`,children:0===t.length?(0,r.Y)("div",{className:"text-center py-8 text-xs text-ink/40",children:i?"No results found.":"No workspaces available."}):t.map(e=>(0,r.Y)(ee,{folder:e,activeSessionId:n,onSelectSession:c,onNewSessionForFolder:d,forceExpanded:!!i,showArchived:s,sessionStatus:a},e.id))})}let er=[3,2];function ei(){return(0,r.Y)("div",{className:"flex-1 p-2 space-y-4","aria-hidden":"true",children:er.map((e,t)=>(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2 px-1 py-1.5",children:[(0,r.Y)("span",{className:"w-3.5 h-3.5 rounded-sm animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-3 w-24 rounded animate-pulse bg-ink/10"})]}),Array.from({length:e},(e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 rounded px-2 py-1.5",children:[(0,r.Y)("span",{className:"w-4 h-4 rounded-full animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-3 rounded animate-pulse bg-ink/10",style:{width:`${58-t%3*12}%`}})]},t))]},t))})}var es=n("wu"),ea=n("wm"),el=n("oZ"),eo=n("DO"),ec=n("z4");function ed(e){let{className:t="",onClose:n,appSettings:i={}}=e,{folders:a,initializing:o,refresh:c,activeSessionId:d,sessionParam:u,searchQuery:p,setSearchQuery:m,showArchived:f,setShowArchived:g,optionsOpen:b,setOptionsOpen:v,sortOption:k,handleSortChange:y,processedFolders:N,sessionStatus:w,handleSelectSession:Y}=(0,ec.K)(i,{includePendingSessions:!0}),[,D]=(0,l.o)(),[A,C]=(0,s.J0)(!1),[T,z]=(0,s.J0)(!1),[$,j]=(0,s.J0)(!1),[L,M]=(0,s.J0)(!1),P=(0,eo.M)(),{toasts:E,pushToast:R,dismissToast:I}=(0,el.Y)(),[O,J]=(0,s.J0)(!1),{isScrolling:_,handleScroll:W}=(0,et.K)(),K=e=>{let t=(0,ea.l)(a,u,e);t&&(0,ea.r)(t,i.omp_access_mode)};return(0,r.FD)(r.FK,{children:[(0,r.FD)("aside",{className:`flex flex-col bg-paper h-full ${t}`,children:[(0,r.Y)(x,{onNewSession:()=>{K(),D(e=>{let t=e.get("sessionId"),n=new URLSearchParams(e);if(n.set("sessionId",`new-${Date.now()}`),t){let e=a.find(e=>e.sessions?.some(e=>String(e.id)===String(t)));e&&n.set("folderId",e.id.toString())}else n.delete("folderId");return n},{replace:!0})}}),(0,r.Y)(F,{isSearchVisible:O,searchQuery:p,showArchived:f,optionsOpen:b,sortOption:k,onToggleSearch:()=>J(!O),onSearchChange:m,onToggleArchived:()=>g(!f),onHideArchived:()=>g(!1),onToggleOptions:()=>v(!b),onCloseOptions:()=>v(!1),onSortChange:y,onNewWorkspace:()=>j(!0),onScheduler:()=>M(!0),onRefresh:c,onClose:n}),o?(0,r.Y)(ei,{}):(0,r.Y)(en,{folders:N,activeSessionId:d,searchQuery:p,showArchived:f,sessionStatus:w,isScrolling:_,onScroll:W,onSelectSession:Y,onNewSessionForFolder:e=>{K(e),D(t=>{let n=new URLSearchParams(t);return n.set("sessionId",`new-${Date.now()}`),n.set("folderId",e.toString()),n},{replace:!0})}}),(0,r.Y)(S,{onSettings:()=>C(!0),onInfo:()=>z(!0),updateAvailable:P.hasUpdate,onUpdateClick:()=>{z(!0),P.check()}})]}),(0,r.Y)(h.bB,{isOpen:A,onClose:()=>C(!1),appSettings:i}),(0,r.Y)(h.VT,{isOpen:T,onClose:()=>z(!1),updates:P,onToast:R}),(0,r.Y)(h.xV,{isOpen:$,onClose:()=>j(!1),onCreate:async e=>{let{name:t,path:n}=e,r=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,path:n})}),i=await r.json().catch(()=>({}));if(!r.ok||!i.success)throw Error(i.error||`HTTP ${r.status}`);window.location.reload()}}),(0,r.Y)(h.Lo,{isOpen:L,onClose:()=>M(!1)}),(0,r.Y)(es.y,{toasts:E,onDismiss:I})]})}var eu=n("u"),ep=n("zI"),em=n("Gb"),eh=n("FL"),ef=n("As"),ex=n("NO"),eg=n("f"),eb=n("b5"),ev=n("Pf"),ek=n("se"),ey=n("tC");let eN=()=>{let{isInstallable:e,isInstalled:t,isIOS:n,install:i}=function(){let[e,t]=(0,s.J0)(null),[n,r]=(0,s.J0)(!1),[i,a]=(0,s.J0)(!1);(0,s.vJ)(()=>{r(window.matchMedia("(display-mode: standalone)").matches||!0===window.navigator.standalone);let e=window.navigator.userAgent.toLowerCase();a(/iphone|ipad|ipod/.test(e));let n=e=>{e.preventDefault(),t(e)},i=()=>{r(!0),t(null)};return window.addEventListener("beforeinstallprompt",n),window.addEventListener("appinstalled",i),()=>{window.removeEventListener("beforeinstallprompt",n),window.removeEventListener("appinstalled",i)}},[]);let l=async()=>{if(!e)return!1;await e.prompt();let{outcome:n}=await e.userChoice;return"accepted"===n&&(r(!0),t(null),!0)};return{isInstallable:!!e,isInstalled:n,isIOS:i,install:l}}(),[a,l]=(0,s.J0)(!1);return t?null:e?(0,r.Y)("button",{onClick:i,className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink",title:"Install OMPChamber",children:(0,r.Y)(ey.A,{size:16})}):n?(0,r.FD)(r.FK,{children:[(0,r.Y)("button",{onClick:()=>l(!0),className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink",title:"Install on iOS",children:(0,r.Y)(ey.A,{size:16})}),a&&(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20 p-4",children:(0,r.FD)("div",{className:"w-full max-w-sm rounded bg-paper border border-ink/10 p-6 shadow-xl text-ink",children:[(0,r.Y)("h3",{className:"text-sm font-semibold",children:"Install on iPhone / iPad"}),(0,r.FD)("p",{className:"mt-2 text-xs opacity-80",children:["1. Tap the ",(0,r.Y)("strong",{children:"Share"})," button in Safari toolbar.",(0,r.Y)("br",{}),"2. Scroll down and tap ",(0,r.Y)("strong",{children:"Add to Home Screen"}),"."]}),(0,r.Y)("button",{onClick:()=>l(!1),className:"mt-4 w-full rounded bg-ink text-canvas py-2 text-xs font-semibold hover:bg-ink/90",children:"Close"})]})})]}):null};var ew=n("R2");function eY(e){let{sessionTitle:t,showLeftPanel:n,showEditor:i,showRightPanel:s,streamStatus:a,onSwitchToMobile:l,onToggleEditor:o,onToggleRightPanel:c}=e;return(0,r.FD)("header",{className:"h-12 flex-shrink-0 border-b border-ink/10 bg-paper flex items-center justify-between pr-4 z-20 titlebar-drag-region select-none",style:{paddingLeft:n?void 0:"max(1rem, env(titlebar-area-x, 0px))",paddingRight:"max(1rem, calc(100vw - env(titlebar-area-width, 100vw)))"},children:[(0,r.FD)("div",{className:"flex items-center space-x-2 px-4 min-w-0",children:[!n&&(0,r.FD)(r.FK,{children:[(0,r.FD)("span",{className:"font-bold text-sm tracking-tight hidden sm:flex items-center flex-shrink-0",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-[15px] tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"ml-[1px]",children:"Chamber"})]}),t&&(0,r.Y)("span",{className:"text-ink/30 text-xs select-none flex-shrink-0",children:"/"})]}),t&&(0,r.FD)("div",{className:"flex items-center space-x-2 titlebar-no-drag",children:[(0,r.Y)("span",{className:"font-bold text-sm tracking-tight hidden sm:flex items-center",children:(0,r.Y)("span",{className:"font-semibold text-xs text-ink truncate",children:t.charAt(0).toUpperCase()+t.slice(1)})}),(0,r.Y)(N.A,{size:14,className:"text-ink/40 hover:text-ink cursor-pointer flex-shrink-0"})]})]}),(0,r.Y)("div",{className:"flex items-center space-x-3 titlebar-no-drag",children:(0,r.FD)("div",{className:"flex items-center space-x-1",children:[(0,r.Y)(ew.c,{status:a}),l&&(0,r.Y)("button",{type:"button",onClick:l,className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink cursor-pointer",title:"Switch to Mobile View",children:(0,r.Y)(eg.A,{size:16})}),(0,r.Y)(eN,{}),(0,r.Y)("button",{type:"button",onClick:o,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${i?"text-ink":"text-ink/40"}`,title:"Toggle Editor Layout",children:(0,r.Y)(eb.A,{size:16})}),(0,r.Y)("button",{type:"button",onClick:c,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${s?"text-ink":"text-ink/40"}`,title:"Toggle Right Panel",children:s?(0,r.Y)(ev.A,{size:16}):(0,r.Y)(ek.A,{size:16})})]})})]})}var eD=n("j5"),eF=n("nG"),eA=n("oE"),eC=n("Asb"),eS=n("vZ"),eT=n("N"),ez=n("Oj"),e$=n("lW"),ej=n("SJ"),eL=n("so");function eM(e){let{activePanel:t,onChangePanel:n,isPanelOpen:i,hasActiveContext:s,activeProjectPath:a,refreshKey:l}=e,{changes:o}=(0,eL.e)(a??void 0,".",l,s,15e3),c=o.length>0,d=e=>`relative w-full h-10 flex items-center justify-center transition-colors border-l-2 ${i&&t===e?"text-ink border-ink bg-ink/5":"text-ink/40 border-transparent hover:text-ink hover:bg-ink/5"}`;return(0,r.FD)("nav",{className:"w-12 flex-shrink-0 border-l border-ink/10 bg-paper flex flex-col items-center py-3 space-y-2 z-10",children:[(0,r.FD)("div",{className:"flex flex-col items-center space-y-1 w-full",children:[(0,r.Y)("button",{className:d("context"),onClick:()=>n("context"),title:"Context & Telemetry",children:(0,r.Y)(eA.A,{size:16})}),(0,r.Y)("button",{className:d("files"),onClick:()=>n("files"),title:"Files",children:(0,r.Y)(eC.A,{size:16})}),(0,r.Y)("button",{className:d("search"),onClick:()=>n("search"),title:"Search",children:(0,r.Y)(k.A,{size:16})}),(0,r.FD)("button",{className:d("git"),onClick:()=>n("git"),title:"Source Control",children:[(0,r.Y)(eS.A,{size:16}),c&&(0,r.Y)("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 rounded-full bg-info",title:"Ada perubahan git"})]}),(0,r.Y)("button",{className:d("terminal"),onClick:()=>n("terminal"),title:"Terminal (Bun)",children:(0,r.Y)(eT.A,{size:16})}),(0,r.Y)("button",{className:d("user-browser"),onClick:()=>n("user-browser"),title:"Browser (Anda)",children:(0,r.Y)(ez.A,{size:16})}),(0,r.Y)("button",{className:d("browser"),onClick:()=>n("browser"),title:"Browser Agent",children:(0,r.Y)(e$.A,{size:16})}),(0,r.Y)("button",{className:d("usage"),onClick:()=>n("usage"),title:"Usage",children:(0,r.Y)(ej.A,{size:16})})]}),(0,r.Y)("div",{className:"flex-1"})]})}function eP(){return(0,r.Y)(m,{className:"relative w-1 outline-none group flex justify-center cursor-col-resize z-10",children:(0,r.Y)("div",{className:"h-full w-[1px] bg-ink/10 group-hover:bg-ink/40 group-active:bg-ink/60 group-hover:w-0.5 transition-all"})})}let eE=["files","search","git","terminal","context","user-browser","browser","usage"],eR={files:268,search:268,git:268,terminal:536,context:536,"user-browser":804,browser:804,usage:536},eI={files:200,search:200,git:260,terminal:200,context:420,"user-browser":320,browser:320,usage:420},eO={left:268,chat:540,editor:536,diff:536};function eJ(e){return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):void 0}let e_=(0,a.RZ)(()=>Promise.all([n.e("uf"),n.e("a"),n.e("q")]).then(n.bind(n,"o3")).then(e=>({default:e.Editor})));function eW(e){let{children:t}=e;return(0,r.Y)(a.tY,{fallback:(0,r.Y)("div",{className:"w-full h-full flex items-center justify-center text-ink/40 text-xs",children:"Loading…"}),children:t})}function eK(e){let{appSettings:t,showEditor:n,editorPanelRef:i,showRightPanel:a,activeRightPanel:l,rightPanelRef:o,panelWidths:c,editorWidthMode:d,hasActiveContext:m,activeProjectPath:h,openedFiles:f,activeFileId:x,refreshKey:g,onSetActiveFileId:b,onCloseFile:v,onOpenFile:k,onRefreshWorkspace:y,onChangeRightPanel:N,onToggleRightPanel:w,onSessionTitle:Y,onPanelWidths:D}=e;(0,s.li)(c).current=c;let F=(0,s.Kr)(()=>({}),[]),A=(0,s.Kr)(()=>["files","search","git","terminal","context","user-browser","browser","usage"].map(e=>({view:e,Comp:(0,eF.SU)(F,e)})),[F]);return(0,r.FD)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.FD)(u,{orientation:"horizontal",id:"ompchamber-layout",onLayoutChanged:()=>{let e,t,n;D((e={},t=i.current?.getSize()?.inPixels,n=o.current?.getSize()?.inPixels,null!=t&&t>0&&(e[d]=Math.round(t)),null!=n&&n>0&&(e.right={[l]:Math.round(n)}),e))},children:[(0,r.Y)(p,{id:"center-panel",filler:!0,minSize:"540px",children:(0,r.Y)(eD.E,{className:"w-full h-full",appSettings:t,onSessionTitle:Y})}),n&&(0,r.FD)(r.FK,{children:[(0,r.Y)(eP,{}),(0,r.Y)(p,{panelRef:i,id:"editor-panel",defaultSize:c[d]??eO[d],minSize:300,children:(0,r.Y)(eW,{children:(0,r.Y)(e_,{className:"w-full h-full",openedFiles:f,activeFileId:x,onSelectFile:b,onCloseFile:v,refreshKey:g,onFileSaved:y})})})]}),a&&(0,r.FD)(r.FK,{children:[(0,r.Y)(eP,{}),(0,r.Y)(p,{panelRef:o,id:"right-panel",defaultSize:c.right?.[l]??eR[l],minSize:eI[l],maxSize:1200,collapsible:!0,children:(0,r.Y)(eW,{children:A.map(e=>{let{view:t,Comp:n}=e,i=l===t;return(0,r.Y)("div",{className:i?"w-full h-full":"hidden",children:(0,r.Y)(n,{className:"w-full h-full",enabled:"terminal"===t?m:m&&i,active:i,refreshKey:g,rootPath:h??void 0,onRefresh:y,onOpenFile:k,onClose:w})},t)})})})]})]}),(0,r.Y)(eM,{activePanel:l,onChangePanel:N,isPanelOpen:a,hasActiveContext:m,activeProjectPath:h,refreshKey:g})]})}var eU=n("FE");function eH(e,t){null!=t&&e.current?.resize(t)}function eB(e){let{sessionId:t,onSwitchToMobile:n,appSettings:i={}}=e,{folders:a}=(0,X.k)(),[o,c]=(0,eh.bL)("layout.showRightPanel",i.showRightPanel??!0),[d,m]=(0,eh.bL)("layout.activeRightPanel",i.activeRightPanel??"files"),[h,f]=(0,s.J0)(i.showLeftPanel??!0),{widths:x,widthsRef:g,commitWidths:b}=function(e,t){let[n,r]=(0,s.J0)(()=>(function(e,t){if(!e||"object"!=typeof e)return{};let n={};for(let t of["left","chat","editor","diff"]){let r=eJ(e[t]);void 0!==r&&(n[t]=r)}let r={};if(e.right&&"object"==typeof e.right)for(let[t,n]of Object.entries(e.right)){if(!("string"==typeof t&&eE.includes(t)))continue;let e=eJ(n);void 0!==e&&(r[t]=e)}else{let n=eJ(e.right);void 0!==n&&(r[t]=n)}return Object.keys(r).length>0&&(n.right=r),n})(e.desktopLayoutSizes,t)),i=(0,s.li)(n),a=(0,s.li)(void 0),l=(0,s.hb)(()=>{clearTimeout(a.current),a.current=void 0,(0,V.cz)("desktopLayoutSizes",i.current)},[]),o=(0,s.hb)(e=>{var t;let n,s=(t=i.current,n={...t,...e},e.right&&(n.right={...t.right,...e.right}),n);i.current=s,r(s),clearTimeout(a.current),a.current=window.setTimeout(l,500)},[l]);return(0,s.vJ)(()=>()=>{void 0!==a.current&&l()},[l]),{widths:n,widthsRef:i,commitWidths:o}}(i,d),v=(0,s.li)(null),k=(0,s.li)(null),y=(0,s.li)(null),[N,w]=(0,s.J0)(i.userToggledEditor??null),[Y]=(0,l.o)(),D=Y.get("folderId"),F=(0,s.Kr)(()=>{let e=(0,em.t)(a,t||"").folder;return e||(D?a.find(e=>String(e.id)===String(D))??null:null)},[a,t,D]),A=F?.project_path??null,C=!!F,{openedFiles:S,activeFileId:T,setActiveFileId:z,handleOpenFile:$,handleCloseFile:j}=function(e,t,n){let[r,i]=(0,eh.bL)("layout.openedFiles",[]),[a,l]=(0,eh.bL)("layout.activeFileId",null),o=(0,s.li)(void 0),{ready:c}=(0,ef.O)(),d=(0,s.li)(void 0);(0,s.vJ)(()=>{o.current===e||(o.current=e,c&&d.current!==e&&(d.current=e,i([]),l(null)))},[e,t,c,i,l]);let u=(0,s.hb)(t=>{let r={...t,root:t.root??e??void 0};i(e=>{let t=e.find(e=>e.id===r.id||!e.isDiff&&e.path&&r.path&&e.path===r.path);return t?(l(t.id),e):[...e,r]}),l(r.id),n?.()},[e,n,i,l]),p=(0,s.hb)(t=>{let r=t.file.replace(/^\/+/,""),s=r.split("/").pop()||r,a=!!t.staged,o=`diff-${a?"staged":"working"}-${r}`,c={id:o,name:`${s} (Diff)`,path:r,isDiff:!0,diffStatus:t.status||"M",diffStaged:a,repo:t.repo||".",root:t.root??e??void 0};i(e=>{let t=e.find(e=>e.id===o||e.isDiff&&e.path===r&&e.diffStaged===a);return t?(l(t.id),e):[...e,c]}),l(o),n?.()},[e,n,i,l]),m=(0,s.hb)(e=>{i(t=>{let n=t.filter(t=>t.id!==e);return a===e&&l(n.length>0?n[n.length-1].id:null),n})},[a,i,l]);return(0,ex.sY)("omp:open-file",e=>{if(!e.detail||!e.detail.path)return;let t=e.detail.path.replace(/^\/+/,""),n=e.detail.name||t.split("/").pop()||"file",r=0;for(let e=0;e<t.length;e++)r=(r<<5)-r+t.charCodeAt(e)|0;u({id:e.detail.id||Math.abs(r)||Date.now(),name:n,path:t,content:e.detail.content})}),(0,ex.sY)("omp:open-diff",e=>{e.detail&&e.detail.file&&p(e.detail)}),{openedFiles:r,activeFileId:a,setActiveFileId:l,handleOpenFile:u,handleOpenDiff:p,handleCloseFile:m}}(A,t||"",(0,s.hb)(()=>{w(!0),P("userToggledEditor",!0)},[])),L=S.length>0&&(N??!0),M=(0,s.Kr)(()=>S.find(e=>String(e.id)===String(T))?.isDiff?"diff":"editor",[S,T]),P=(e,t)=>{(0,V.cz)(e,t)};(0,s.vJ)(()=>{let e=requestAnimationFrame(()=>{let e=g.current;e&&eH(y,e.left)});return()=>cancelAnimationFrame(e)},[h,g]),(0,s.vJ)(()=>{let e=requestAnimationFrame(()=>{eH(k,g.current?.right?.[d])});return()=>cancelAnimationFrame(e)},[o,d,g]),(0,s.vJ)(()=>{let e=requestAnimationFrame(()=>{eH(v,g.current?.[M])});return()=>cancelAnimationFrame(e)},[L,M,g]);let[E,R]=(0,s.J0)(!1),[I,O]=(0,s.J0)("appearance"),[J,_]=(0,s.J0)(!1),[W,K]=(0,s.J0)(0),[U,H]=(0,s.J0)(null),B=(0,eU.H)();(0,ex.MN)("keydown",e=>{(e.metaKey||e.ctrlKey)&&","===e.key&&(e.preventDefault(),O("appearance"),_(!1),R(e=>!e))}),(0,ex.sY)("omp:open-settings",e=>{e.detail?.category?O(e.detail.category):O("appearance"),_(!!e.detail?.autoOpenAdd),R(!0)});let q=e=>{f(e),P("showLeftPanel",e)},G=()=>{let e=!o;c(e),P("showRightPanel",e)};return(0,r.FD)("div",{className:"flex flex-col h-screen w-screen overflow-hidden bg-canvas text-ink font-sans selection:bg-ink selection:text-canvas",children:[(0,r.FD)("div",{className:"flex flex-1 overflow-hidden",children:[!h&&(0,r.FD)("div",{className:"w-12 h-full bg-paper border-r border-ink/10 flex flex-col items-center py-3 flex-shrink-0 cursor-pointer hover:bg-ink/5 transition-colors titlebar-no-drag",style:{paddingTop:"max(0.75rem, env(titlebar-area-height, 0px))"},onClick:()=>q(!0),title:"Expand Sidebar",children:[(0,r.Y)(ep.A,{size:16,className:"text-ink/60"}),(0,r.Y)("div",{className:"w-[1px] flex-1 bg-ink/10 my-4"})]}),(0,r.FD)(u,{orientation:"horizontal",id:"ompchamber-main",onLayoutChanged:()=>{let e=y.current?.getSize()?.inPixels;null!=e&&e>0&&b({left:Math.round(e)})},children:[h&&(0,r.FD)(r.FK,{children:[(0,r.Y)(p,{panelRef:y,id:"left-panel",defaultSize:x.left??eO.left,minSize:200,maxSize:600,collapsible:!0,children:(0,r.Y)(ed,{className:"w-full h-full",onClose:()=>q(!1),appSettings:i})}),(0,r.Y)(eP,{})]}),(0,r.Y)(p,{id:"main-right-stack",filler:!0,minSize:0,children:(0,r.FD)("div",{className:"flex flex-col h-full",children:[(0,r.Y)(eY,{sessionTitle:U,showLeftPanel:h,showEditor:L,showRightPanel:o,streamStatus:B,onSwitchToMobile:n,onToggleEditor:()=>{let e=!L;w(e),P("userToggledEditor",e)},onToggleRightPanel:G}),(0,r.Y)(eK,{appSettings:i,showEditor:L,editorPanelRef:v,showRightPanel:o,activeRightPanel:d,rightPanelRef:k,panelWidths:x,editorWidthMode:M,hasActiveContext:C,activeProjectPath:A,openedFiles:S,activeFileId:T,refreshKey:W,onSetActiveFileId:z,onCloseFile:j,onOpenFile:$,onRefreshWorkspace:()=>K(e=>e+1),onChangeRightPanel:e=>{let t=o,n=d;d===e&&o?t=!1:(n=e,t=!0),c(t),m(n),(0,V.cz)("showRightPanel",t),(0,V.cz)("activeRightPanel",n)},onToggleRightPanel:G,onSessionTitle:H,onPanelWidths:b})]})})]})]}),(0,r.Y)(eu.b,{isOpen:E,onClose:()=>{R(!1),_(!1)},initialCategory:I,autoOpenAddProvider:J,appSettings:i})]})}var eq=n("SS");function eG(e){let{sessionId:t,children:n}=e,i=t||"1",[a,l]=(0,s.J0)(!1),o=(0,s.li)(null);(0,s.vJ)(()=>{let e=o.current;if(o.current=i,e!==i){if((0,eq.Y1)(i),e&&e.startsWith("new-")&&!i.startsWith("new-")){(0,eq.vy)(e,i),l(!0);return}if(i.startsWith("new-")){(0,eq.l5)(i),l(!0);return}l(!1),(0,eq.D4)(e).then(()=>(0,eq.L6)(i)).then(()=>{o.current===i&&l(!0)})}},[i]);let c=(0,s.Kr)(()=>({sessionId:i,ready:a}),[i,a]);return(0,r.Y)(ef.b.Provider,{value:c,children:n})}let eV=(0,a.RZ)(()=>Promise.all([n.e("uf"),n.e("a"),n.e("g")]).then(n.bind(n,"Wh")).then(e=>({default:e.MobileLayoutWrapper})));var eZ=n("eh");let eQ=document.getElementById("app"),eX=window.__OMP_BOOTSTRAP__;(0,V.x9)(eX?.appSettings),(0,eZ.iv)(),eQ&&(0,i.Qv)((0,r.Y)(function(e){let{initialIsMobile:t=!1,appSettings:n={}}=e,[i]=(0,l.o)(),o=i.get("sessionId")||"1",[c,d]=(0,s.J0)(t),u=(0,s.li)(!1);return((0,s.vJ)(()=>{let e=()=>{let e=window.innerWidth<768,t=window.matchMedia("(pointer: coarse)").matches,n=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(navigator.userAgent),r=t&&window.innerHeight<550&&window.innerWidth<1024;return e||n||r};u.current||d(e());let t=()=>{u.current||d(e())};return window.addEventListener("resize",t),window.addEventListener("orientationchange",t),()=>{window.removeEventListener("resize",t),window.removeEventListener("orientationchange",t)}},[]),c)?(0,r.Y)(eG,{sessionId:o,children:(0,r.Y)(X.O,{children:(0,r.Y)(a.tY,{fallback:null,children:(0,r.Y)(eV,{onDesktopToggle:()=>{u.current=!0,d(!1)},appSettings:n})})})}):(0,r.Y)(eG,{sessionId:o,children:(0,r.Y)(X.O,{children:(0,r.Y)(eB,{sessionId:o,onSwitchToMobile:()=>{u.current=!0,d(!0)},appSettings:n})})})},{initialIsMobile:eX?.initialIsMobile,appSettings:eX?.appSettings}),eQ)},Fb(e,t,n){let r="omp:browser-include-page";function i(e){"u">typeof window&&window.dispatchEvent(new CustomEvent(r,{detail:e}))}n.d(t,{q:()=>i},{j:r})},ns(e,t,n){let r="agent",i="command",s=new Map,a=new Map;async function l(e){let t=await fetch(e);if(!t.ok)throw Error(`GET ${e} failed: ${t.status}`);let n=await t.json();if(!n||"object"!=typeof n)throw Error(`GET ${e} returned malformed JSON`);return n}async function o(){let e=s.get(r);if(e&&e.expiresAt>Date.now())return e.data;let t=a.get(r);if(t)return t;let n=(async()=>{try{let e=(await l("/api/settings/agents")).agents.map(e=>({id:`agent-${e.name}`,name:e.name,description:e.description,kind:"agent",source:"agent",token:`@${e.name}`}));return s.set(r,{data:e,expiresAt:Date.now()+3e5}),e}finally{a.delete(r)}})();return a.set(r,n),n}async function c(e){let t,n=(t=e??"",`file::${t}`),r=s.get(n);if(r&&r.expiresAt>Date.now())return r.data;let i=a.get(n);if(i)return i;let o=(async()=>{try{let t=e?`?root=${encodeURIComponent(e)}`:"",r=await l(`/api/fs/list${t}`),i=(Array.isArray(r.files)?r.files:[]).map(e=>({id:`file-${e.path}`,name:e.path,description:"",kind:"file",source:"file",token:/\s/.test(e.path)?`@"file:${e.path}"`:`@file:${e.path}`,path:e.path}));return s.set(n,{data:i,expiresAt:Date.now()+3e5}),i}catch{return[]}finally{a.delete(n)}})();return a.set(n,o),o}async function d(){let e=s.get(i);if(e&&e.expiresAt>Date.now())return e.data;let t=a.get(i);if(t)return t;let n=(async()=>{try{let[e,t]=await Promise.all([l("/api/settings/commands"),l("/api/settings/skills")]),n=function(e,t){let n=[],r=new Set;for(let t of e){let e=t.name.toLowerCase();r.has(e)||(r.add(e),n.push({id:`command-${t.name}`,name:t.name,description:t.description,kind:"command",source:"command",token:`/${t.name}`}))}for(let e of t){let t=e.name.toLowerCase(),i=`skill:${t}`;r.has(t)||r.has(i)||(r.add(i),n.push({id:`skill-${e.name}`,name:e.name,description:e.description,kind:"command",source:"skill",token:`/skill:${e.name}`}))}return n}(e.commands,t.skills);return s.set(i,{data:n,expiresAt:Date.now()+3e5}),n}finally{a.delete(i)}})();return a.set(i,n),n}function u(e,t){return"mention"===e?Promise.all([o(),c(t??null)]).then(e=>{let[t,n]=e;return[...t,...n]}):d()}async function p(){try{return(await o()).map(e=>e.name)}catch{return[]}}function m(e){if(e){s.delete(e),a.delete(e);return}s.clear(),a.clear()}n.d(t,{O7:()=>p,SA:()=>m,bF:()=>u})},Kc(e,t,n){var r=n("oS"),i=n("zG");let s={edit:!0,write:!0,ast_edit:!0,bash:!0};function a(e){let t="string"==typeof e.toolName?e.toolName.toLowerCase():"",n=i.YT[t]??t;if(!s[n])return!1;let a=(0,r.u)(e.args)?e.args:{},l=(0,i.oJ)(a.path)??(0,i.oJ)(a.target);return!("write"===n&&"string"==typeof l&&l.startsWith("xd://"))}n.d(t,{Y:()=>a},{s:"omp:files-mutated"})},g0(e,t,n){var r=n("Kn");let i="omp:stream-status",s={transport:(0,r.ul)(),connected:!1};function a(){return s}function l(e){e.transport===s.transport&&e.connected===s.connected||(s=e,"u">typeof window&&window.dispatchEvent(new CustomEvent(i,{detail:e})))}n.d(t,{aK:()=>a,dX:()=>l},{rt:i})},Kn(e,t,n){var r=n("So");function i(e){let t="https:"===window.location.protocol?"wss:":"ws:";return`${t}//${window.location.host}/api/agent/${encodeURIComponent(e)}/ws`}function s(e){return`/api/agent/${encodeURIComponent(e)}/events`}function a(e){let t=(0,r.BF)("streamTransport",e);return"sse"===t||"websocket"===t?t:"websocket"}n.d(t,{_m:()=>s,qq:()=>i,ul:()=>a})},G1(e,t,n){function r(e,t){let n=function(e){let t=e.trim();if(!t)return null;let n="message",r=[];for(let e of t.split("\n"))!e.startsWith(":")&&(e.startsWith("event:")?n=e.replace(/^event:\s*/,"").trim():e.startsWith("data:")&&r.push(e.replace(/^data:\s*/,"")));return 0===r.length?null:{event:n,data:r.join("\n")}}(e);return!!n&&!0===t(n.event,n.data)}async function i(e,t,n){let i=e.body?.getReader();if(!i)return;let s=new TextDecoder("utf-8"),a="";try{for(;;){if(n?.aborted){try{await i.cancel()}catch{}return}let{done:e,value:l}=await i.read();if(e)break;let o=(a+=s.decode(l,{stream:!0})).split("\n\n");for(let e of(a=o.pop()??"",o))if(r(e,t))return}a&&r(a,t)}finally{try{i.releaseLock()}catch{}}}n.d(t,{o:()=>i})},zG(e,t,n){var r=n("oS"),i=n("e");function s(e){if("string"!=typeof e)return;let t=e.trim();return t.length>0?t:void 0}function a(e,t){for(let n of t){let t=e[n],r=s(t);if(r)return r;if(Array.isArray(t)){let e=t.find(e=>void 0!==s(e));if(void 0!==e)return s(e)}}}function l(e){return e.length<=72?e:`${e.slice(0,71)}…`}function o(e){if(e)return/^["'`]/.test(e)?e:`"${e}"`}function c(e,t){switch(e){case"read":case"write":case"edit":return a(t,["path","file","AbsolutePath","TargetFile"])??(0,i.f$)(t);case"ast_edit":return a(t,["paths","path"]);case"ast_grep":{let e=o(a(t,["pat"]));return e?`for ${e}`:void 0}case"bash":return a(t,["command","cmd","CommandLine"]);case"grep":{let e=a(t,["pattern"]),n=a(t,["path","paths"]);if(!e)return n;return n?`for ${o(e)} in ${n}`:`for ${o(e)}`}case"glob":return a(t,["path","pattern"]);case"web_search":{let e=o(a(t,["query"]));return e?`for ${e}`:void 0}case"task":let n,l,c,d;return n=s(t.name),l=(Array.isArray(t.tasks)?t.tasks:[]).find(r.u),c=n??(l?s(l.name):void 0),d=s(t.agent)??(l?s(l.agent):void 0),c&&d?`to ${c} (${d})`:c?`to ${c}`:d?`to ${d}`:void 0;case"hub":return[a(t,["op"]),a(t,["name"])].filter(Boolean).join(" ")||void 0;case"todo":{let e=a(t,["op"]);return e?`\xb7 ${e}`:void 0}case"eval":{let e=a(t,["language"]);return e?`in ${e}`:void 0}case"lsp":return[a(t,["action"]),a(t,["symbol","file"])].filter(Boolean).join(" ")||void 0;case"debug":return a(t,["action","program"]);case"github":return[a(t,["op"]),a(t,["repo","pr","query"])].filter(Boolean).join(" ")||void 0;case"ask":let u=(Array.isArray(t.questions)?t.questions:[]).find(r.u);if(u)return s(u.header)??s(u.question);return;case"checkpoint":return a(t,["goal"]);case"manage_skill":return a(t,["name"]);case"recall":return o(a(t,["query"]));case"reflect":{let e=o(a(t,["query"]));return e?`on ${e}`:void 0}case"security_scan":return a(t,["target_kind","include_paths"]);case"retain":let p;return(p=(Array.isArray(t.items)?t.items:[]).find(r.u))?o(s(p.content)):void 0;default:return a(t,["path","command","query","pattern","name","target","prose"])}}n.d(t,{Up:()=>a,oJ:()=>s,qL:()=>c,xv:()=>l},{K$:{read:"Reading",write:"Writing",edit:"Editing",ast_edit:"Rewriting AST",ast_grep:"Searching AST",bash:"Running",grep:"Searching",glob:"Finding",task:"Delegating",todo:"Updating plan",hub:"Hub",eval:"Running code",lsp:"Running LSP",debug:"Debugging",github:"GitHub",web_search:"Searching the web",ask:"Asking you",checkpoint:"Checkpointing",rewind:"Rewinding",context_notes:"Updating context notes",new_context:"Starting a fresh context",security_scan:"Scanning for vulnerabilities",manage_skill:"Updating skill",learn:"Recording a lesson",retain:"Retaining memory",recall:"Recalling memory",reflect:"Reflecting",think:"Thinking",yield:"Wrapping up",goal:"Tracking goal"},Qq:{lsp:"Running LSP",ast_edit:"Rewriting AST",ast_grep:"Searching AST",resolve:"Applying edit proposal",reject:"Discarding edit proposal",report_issue:"Reporting tool issue",debug:"Debugging",browser:"Driving the browser"},YT:{read_file:"read",view_file:"read",read_file_content:"read",edit_file:"edit",replace_file_content:"edit",multi_edit_file:"edit",write_to_file:"write",create_file:"write",search_fs:"grep",terminal:"bash",run_command:"bash"},n1:{thinking:"Thinking",writing:"Writing response"}})},pm(e,t,n){var r=n("U8");function i(e){return(0,r.Rk)(e)}n.d(t,{F:()=>i})},eh(e,t,n){n.d(t,{iv:()=>N,tn:()=>v,F:()=>D,nv:()=>w,LT:()=>A,Eu:()=>Y,sT:()=>F});var r=n("CU"),i=n("he"),s=n("h3"),a=n("g1");let l={typescript:()=>n.e("zn").then(n.bind(n,"tt")),tsx:()=>n.e("ta").then(n.bind(n,"Xl")),javascript:()=>n.e("jsc").then(n.bind(n,"lK")),jsx:()=>n.e("px").then(n.bind(n,"rz")),json:()=>n.e("zj").then(n.bind(n,"BB")),markdown:()=>n.e("2v").then(n.bind(n,"sN")),css:()=>n.e("n").then(n.bind(n,"d2")),bash:()=>Promise.all([n.e(2),n.e(6)]).then(n.bind(n,"ks")),diff:()=>n.e("0w").then(n.bind(n,"SP")),yaml:()=>n.e("ho").then(n.bind(n,"n1")),html:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa")]).then(n.bind(n,"w1")),python:()=>n.e("jd").then(n.bind(n,"hE")),go:()=>n.e("cf").then(n.bind(n,"K1")),rust:()=>n.e("hk").then(n.bind(n,"nb")),sql:()=>n.e("r").then(n.bind(n,"le")),toml:()=>n.e("x0").then(n.bind(n,"DJ")),java:()=>n.e("f8").then(n.bind(n,"lj")),c:()=>n.e("4e").then(n.bind(n,"Gd")),cpp:()=>Promise.all([n.e("4e"),n.e("y6")]).then(n.bind(n,"gB")),csharp:()=>n.e("4k").then(n.bind(n,"Ku")),ruby:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("aa"),n.e("4e"),n.e("f8"),n.e("r"),n.e("ta"),n.e("y6"),n.e("px"),n.e(2),n.e("yv"),n.e("ct")]).then(n.bind(n,"eV")),php:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("f8"),n.e("r"),n.e(4)]).then(n.bind(n,"eZ")),kotlin:()=>n.e("7l").then(n.bind(n,"hR")),swift:()=>n.e(0).then(n.bind(n,"ep")),scala:()=>n.e("js").then(n.bind(n,"h3S")),lua:()=>Promise.all([n.e("4e"),n.e("hd")]).then(n.bind(n,"rF")),perl:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("f8"),n.e("r"),n.e("i")]).then(n.bind(n,"cr")),dockerfile:()=>n.e("b").then(n.bind(n,"BZ")),ini:()=>n.e("3p").then(n.bind(n,"BD")),properties:()=>n.e("1b").then(n.bind(n,"LU")),zig:()=>n.e("3u").then(n.bind(n,"p9")),elixir:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("jll")]).then(n.bind(n,"xu")),dart:()=>n.e("4q").then(n.bind(n,"Cu")),ocaml:()=>n.e("8j").then(n.bind(n,"uA")),haskell:()=>n.e("ar").then(n.bind(n,"IX")),nix:()=>n.e("p").then(n.bind(n,"jG")),hcl:()=>n.e("yq").then(n.bind(n,"ka")),graphql:()=>Promise.all([n.e("jsc"),n.e("zn"),n.e("ta"),n.e("px"),n.e("yv")]).then(n.bind(n,"ok")),solidity:()=>n.e("w").then(n.bind(n,"me")),r:()=>n.e(37).then(n.bind(n,"pO")),julia:()=>Promise.all([n.e("jsc"),n.e("4e"),n.e("r"),n.e("y6"),n.e("jd"),n.e("t9")]).then(n.bind(n,"zu")),erlang:()=>Promise.all([n.e("2v"),n.e("y")]).then(n.bind(n,"EY")),clojure:()=>n.e("3d").then(n.bind(n,"lF")),scheme:()=>n.e("az").then(n.bind(n,"wE")),racket:()=>n.e(8).then(n.bind(n,"aB")),protobuf:()=>n.e("1p").then(n.bind(n,"bT")),makefile:()=>n.e("d").then(n.bind(n,"nt")),powershell:()=>n.e("j").then(n.bind(n,"dQ")),json5:()=>n.e("bq").then(n.bind(n,"VH")),less:()=>n.e("c").then(n.bind(n,"it")),scss:()=>Promise.all([n.e("n"),n.e("x")]).then(n.bind(n,"DD")),sass:()=>n.e("zo").then(n.bind(n,"Bc")),stylus:()=>n.e("ky").then(n.bind(n,"uc")),"objective-c":()=>n.e(7).then(n.bind(n,"BG")),groovy:()=>n.e("7e").then(n.bind(n,"tf")),vue:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("aa"),n.e("zx")]).then(n.bind(n,"Z")),svelte:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("dp")]).then(n.bind(n,"jIY")),astro:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("ta"),n.e("o")]).then(n.bind(n,"CuL")),xml:()=>Promise.all([n.e("f8"),n.e("da")]).then(n.bind(n,"rDW"))},o=["typescript","tsx","javascript","jsx","json","bash","python","markdown","yaml","diff"],c=new Map,d=new Set,u=new Set,p={text:!0,plain:!0,plaintext:!0,txt:!0,ansi:!0,none:!0};function m(e){return!0===p[e]||d.has(e)}function h(e,t){if(m(t))return Promise.resolve();let n=c.get(t);if(n)return n;let r=l[t];if(!r)return Promise.resolve();let i=e.loadLanguage(r).then(()=>{for(let e of(d.add(t),u))e()}).catch(()=>{}).finally(()=>{c.delete(t)});return c.set(t,i),i}async function f(e,t){await Promise.all(t.map(t=>h(e,t)))}let x=null,g=!1,b=new Set;function v(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function k(){if("u"<typeof window)return null;try{let e=await (0,r.tz)({themes:[s.A,a.A],langs:[],engine:(0,i.l)({forgiving:!0})});x=e,g=!0;let t=[...b];for(let e of(b.clear(),t))try{e()}catch{}return f(e,o),e}catch(e){return console.error("[shiki] highlighter boot failed",e),null}}let y=null;function N(){return y||(y=k()),y}function w(){return g}function Y(e){return g?(e(),()=>{}):(b.add(e),()=>{b.delete(e)})}function D(){return g?x:null}function F(e){return!!x&&(h(x,e),m(e))}let A=function(e){return u.add(e),()=>{u.delete(e)}}},DU(e,t,n){n.d(t,{sQ:()=>s,wY:()=>o,PH:()=>c,O9:()=>d,rw:()=>a,Bl:()=>function e(t){if(null==t)return{isValid:!1};if("object"==typeof t)try{let e=JSON.stringify(t,null,2),n=e.split("\n").length;return{isValid:!0,data:t,pretty:e,linesCount:n}}catch{return{isValid:!1}}if("string"!=typeof t)return{isValid:!1};let n=t.trim();if(!n)return{isValid:!1};let r=n.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i);r&&(n=r[1].trim());let i=n.match(/^(?:user\s+(?:selected|responded|answered|response)|response|result|output):\s*([\s\S]+)$/i);if(i){let e=i[1].trim();(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))&&(n=e)}if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))try{let t=JSON.parse(n);if("object"==typeof t&&null!==t){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}if("string"==typeof t){let n=e(t);if(n.isValid)return n}}catch{}if(n.startsWith("{")||n.startsWith("["))try{let e=JSON.parse(n);if(null!==e&&"object"==typeof e){let t=JSON.stringify(e,null,2),n=t.split("\n").length;return{isValid:!0,data:e,pretty:t,linesCount:n}}}catch{}let s=n.indexOf("{"),a=n.lastIndexOf("}");if(-1!==s&&a>s){let e=n.slice(s,a+1);try{let t=JSON.parse(e);if(null!==t&&"object"==typeof t){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}}catch{}}let l=n.indexOf("["),o=n.lastIndexOf("]");if(-1!==l&&o>l){let e=n.slice(l,o+1);try{let t=JSON.parse(e);if(Array.isArray(t)){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}}catch{}}return{isValid:!1}}});var r=n("eh");let i={light:"one-light",dark:"one-dark-pro"};function s(e){if(!e)return"javascript";let t=e.split("?")[0].split("#")[0].replace(/:\d+(?:-\d+)?$/,"");switch(t.split(".").pop()?.toLowerCase()){case"ts":return"typescript";case"tsx":return"tsx";case"js":case"mjs":case"cjs":default:return"javascript";case"jsx":return"jsx";case"json":return"json";case"md":case"markdown":return"markdown";case"css":return"css";case"sh":case"bash":case"zsh":case"env":return"bash";case"diff":case"patch":return"diff";case"yaml":case"yml":return"yaml";case"html":return"html";case"svg":case"xml":return"xml";case"py":return"python";case"go":return"go";case"rs":return"rust";case"sql":return"sql";case"toml":return"toml";case"java":return"java";case"c":case"h":return"c";case"cpp":case"cc":case"hpp":return"cpp";case"cs":return"csharp";case"rb":return"ruby";case"php":return"php";case"kt":case"kts":return"kotlin";case"swift":return"swift";case"scala":return"scala";case"lua":return"lua";case"pl":return"perl";case"dockerfile":return"dockerfile";case"ini":case"cfg":case"conf":return"ini";case"properties":return"properties";case"zig":return"zig";case"ex":case"exs":return"elixir";case"dart":return"dart";case"ml":case"mli":return"ocaml";case"hs":return"haskell";case"nix":return"nix";case"tf":case"tfvars":case"hcl":return"hcl";case"graphql":case"gql":return"graphql";case"sol":return"solidity";case"r":return"r";case"jl":return"julia";case"erl":return"erlang";case"clj":case"cljs":case"cljc":case"edn":return"clojure";case"scm":case"ss":return"scheme";case"rkt":return"racket";case"proto":return"protobuf";case"makefile":case"mk":return"makefile";case"ps1":case"psm1":return"powershell";case"json5":return"json5";case"less":return"less";case"scss":return"scss";case"sass":return"sass";case"styl":return"stylus";case"vue":return"vue";case"svelte":return"svelte";case"astro":return"astro";case"mm":case"m":return"objective-c";case"groovy":case"gvy":case"gradle":return"groovy"}}function a(e){if(!e||e.length<5)return!1;let t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t),!0}catch{}return[/^(?:import|export)\s+.+from\s+['"][^'"]+['"]/m,/^(?:const|let|var|function|class|interface|type|enum)\s+[A-Za-z0-9_$]+/m,/(?:=>|\bconsole\.(?:log|error|warn)|return\s+|async\s+function)/,/^\s*\d+:\s*(?:import|const|let|function|\/\/|\/\*|<|[A-Za-z])/m,/^\s*\[[A-Za-z0-9_./-]+\.[a-zA-Z0-9]+\]\s*\n\d+:/m].some(e=>e.test(t))}function l(e,t){return(0,r.sT)(t)||e.getLoadedLanguages().includes(t)?t:"javascript"}function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"javascript";if(!e)return"";let n=(0,r.F)();if(!n)return(0,r.tn)(e);let s=l(n,t);try{return`<span class="shiki">${n.codeToHtml(e,{lang:s,themes:i,defaultColor:!1,structure:"inline"})}</span>`}catch{return(0,r.tn)(e)}}function c(e){return o(e,"json")}function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"javascript",n=e.split("\n");if(!e)return n;let s=(0,r.F)();if(!s)return n.map(r.tn);let a=l(s,t);try{let{tokens:t}=s.codeToTokens(e,{lang:a,themes:i,defaultColor:!1});if(t.length!==n.length)return n.map(r.tn);return t.map(e=>e.map(e=>{let t=(0,r.tn)(e.content);if(!e.htmlStyle)return t;let n=Object.entries(e.htmlStyle).map(e=>{let[t,n]=e;return`${t}:${n}`}).join(";");return n?`<span style="${n}">${t}</span>`:t}).join(""))}catch{return n.map(r.tn)}}},U8(e,t,n){function r(e){if(null!=e){if("string"==typeof e)return e;if(Number.isFinite(e)&&!(e<=0)){if(e>=1e6){let t=e/1e6;return`${Number.isInteger(t)?t:t.toFixed(1)}M`}if(e>=1e3){let t=e/1e3;return`${Number.isInteger(t)?t:t.toFixed(1)}K`}return String(e)}}}function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return"number"!=typeof e||!Number.isFinite(e)||e<=0?"":`$${e.toFixed(t)}`}function s(e){return"number"!=typeof e||!Number.isFinite(e)||e<0?"":e<1024?`${Math.round(e)} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(2)} MB`}function a(e){return"number"!=typeof e||!Number.isFinite(e)||e<0?"":`$${e.toFixed(2)}`}n.d(t,{$g:()=>a,BD:()=>i,Rk:()=>r,z3:()=>s})},LQ(e,t,n){function r(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n="M",r="Modified",i="text-info",s="bg-info/10 text-info border-info/25",a=(e||"").trim().toUpperCase();if(t){let e=a[0]||"M";"A"===e?(n="A",r="Added (Staged)",i="text-success",s="bg-success/10 text-success border-success/25"):"D"===e?(n="D",r="Deleted (Staged)",i="text-error",s="bg-error/10 text-error border-error/25"):"R"===e?(n="R",r="Renamed (Staged)",i="text-meta",s="bg-meta/10 text-meta border-meta/25"):"U"===e||"?"===e?(n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25"):(n="M",r="Modified (Staged)",i="text-info",s="bg-info/10 text-info border-info/25")}else if("??"===a||"?"===a||"U"===a||"UNTRACKED"===a)n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25";else{let e=a[1]||a[0]||"M";"A"===e?(n="A",r="Added",i="text-success",s="bg-success/10 text-success border-success/25"):"D"===e?(n="D",r="Deleted",i="text-error",s="bg-error/10 text-error border-error/25"):"R"===e?(n="R",r="Renamed",i="text-meta",s="bg-meta/10 text-meta border-meta/25"):"U"===e||"?"===e?(n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25"):(n="M",r="Modified",i="text-info",s="bg-info/10 text-info border-info/25")}return{charStatus:n,label:r,colorClass:i,badgeBgClass:s,isStaged:t}}function i(e){let t=new Map,n=new Map;if(!Array.isArray(e))return{fileMap:t,folderMap:n};for(let r of e){if(!r||!r.file)continue;let e=r.file.replace(/^\/+/,"");t.set(e,r);let i=e.split("/");i.pop();let s="";for(let e of i){s=s?`${s}/${e}`:e;let t=n.get(s)||{count:0,hasModified:!1,hasUntracked:!1,hasStaged:!1,hasDeleted:!1,colorClass:"text-info"};t.count+=1,(r.staged||r.status&&" "!==r.status[0]&&"?"!==r.status[0])&&(t.hasStaged=!0),"??"===r.status?t.hasUntracked=!0:r.status?.includes("D")?t.hasDeleted=!0:t.hasModified=!0,t.hasModified||t.hasStaged?t.colorClass="text-info":t.hasUntracked?t.colorClass="text-success":t.hasDeleted&&(t.colorClass="text-error"),n.set(s,t)}}return{fileMap:t,folderMap:n}}n.d(t,{R:()=>r,_:()=>i})},W9(e,t,n){let r=null,i=null;function s(){return i&&i.expiresAt>Date.now()?Promise.resolve(i.data):r||(r=fetch("/api/models").then(e=>e.ok?e.json():Promise.reject(Error(`GET /api/models failed: ${e.status}`))).then(e=>(i={data:e,expiresAt:Date.now()+6e4},e)).finally(()=>{r=null}))}function a(){i=null}function l(){i=null,window.dispatchEvent(new CustomEvent("omp:models-updated"))}function o(e){return window.addEventListener("omp:models-updated",e),()=>window.removeEventListener("omp:models-updated",e)}n.d(t,{$P:()=>l,Sy:()=>o,kn:()=>a,xo:()=>s})},Np(e,t,n){let r="new-";function i(e){return String(e).padStart(2,"0")}function s(e){return!!e?.startsWith(r)}function a(e){return e?.startsWith(r)?Number(e.slice(r.length)):0/0}function l(e){let t=a(e);return function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return Number.isNaN(e.getTime())?"New Session":`New Session - ${e.getFullYear()}-${i(e.getMonth()+1)}-${i(e.getDate())}T${i(e.getHours())}:${i(e.getMinutes())}:${i(e.getSeconds())}`}(Number.isFinite(t)?new Date(t):new Date)}n.d(t,{fN:()=>s,fd:()=>a,g2:()=>l})},e(e,t,n){let r=["input","_input","patch"],i=/#([0-9a-fA-F]{4})$/,s=/^(PUT|CUT)\b/;function a(e){let t=e[0];return e.length>=2&&('"'===t||"'"===t)&&t===e[e.length-1]?e.slice(1,-1):e}function l(e){if(e)for(let t of r){let n=e[t];if("string"!=typeof n)continue;let r=function(e){let t,n=[];for(let r of e.replace(/^\uFEFF/,"").split("\n")){let e=r.endsWith("\r")?r.slice(0,-1):r,l=function(e){let t=e.trimEnd();if(!t.startsWith("["))return;let n=(t.endsWith("]")?t.slice(1,-1):t.slice(1)).trim(),r=i.exec(n),s=a((r?n.slice(0,r.index):n).trim());return s?{path:s,tag:r?.[1]}:void 0}(e);if(l){t={path:l.path,tag:l.tag,removed:!1,ops:[]},n.push(t);continue}if(!t)continue;let o=e.trim();if("REM"===o){t.removed=!0;continue}if(o.startsWith("MV ")){t.moveTo=a(o.slice(3).trim())||void 0;continue}if(s.test(o)){t.ops.push({verb:o.slice(0,3),spec:o.slice(3).trim().replace(/:$/,""),body:[]});continue}let c=t.ops[t.ops.length-1];c&&e.startsWith("+")&&c.body.push(e)}return n}(n);if(r.length>0)return{text:n,sections:r}}}function o(e){return l(e)?.sections[0].path}n.d(t,{I:()=>l,f$:()=>o})},wm(e,t,n){function r(e,t){e&&fetch("/api/agent/prewarm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,...t?{accessMode:t}:{}})}).catch(()=>{})}function i(e,t,n){let r=void 0!==n?e.find(e=>String(e.id)===String(n)):e.find(e=>e.sessions?.some(e=>String(e.id)===String(t)))??e.find(e=>!!e.project_path);return r?.project_path||r?.name||null}n.d(t,{l:()=>i,r:()=>r})},B(e,t,n){var r=n("oS");function i(e){return(0,r.u)(e)&&"string"==typeof e.id&&e.id.length>0&&"string"==typeof e.agent&&e.agent.length>0&&"string"==typeof e.status&&"number"==typeof e.index}async function s(e){try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/subagents`);if(!t.ok)return null;let n=await t.json().catch(()=>null);if(!(0,r.u)(n))return null;let s=(0,r.u)(n.data)?n.data:n;if(!Array.isArray(s.subagents))return null;return s.subagents.filter(i)}catch{return null}}function a(e){let t={...e,source:"history",lastUpdate:0},n={};return void 0!==e.lastIntent&&(n.lastIntent=e.lastIntent),void 0!==e.toolCount&&(n.toolCount=e.toolCount),void 0!==e.requests&&(n.requests=e.requests),void 0!==e.tokens&&(n.tokens=e.tokens),void 0!==e.contextTokens&&(n.contextTokens=e.contextTokens),void 0!==e.contextWindow&&(n.contextWindow=e.contextWindow),void 0!==e.cost&&(n.cost=e.cost),void 0!==e.durationMs&&(n.durationMs=e.durationMs),void 0!==e.resolvedModel&&(n.resolvedModel=e.resolvedModel),Object.keys(n).length>0&&(t.progress=n),t}n.d(t,{Nh:()=>a,wv:()=>s})},T(e,t,n){var r=n("oS");function i(e){return"string"==typeof e&&e.length>0?e:void 0}function s(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function a(e){return"bundled"===e||"user"===e||"project"===e?e:void 0}function l(e){var t;if(!(0,r.u)(e))return;let n={},l=s(e.index);void 0!==l&&(n.index=l);let o=i(e.id);void 0!==o&&(n.id=o);let c=i(e.agent);void 0!==c&&(n.agent=c);let d=a(e.agentSource);void 0!==d&&(n.agentSource=d);let u="pending"===(t=e.status)||"running"===t||"completed"===t||"failed"===t||"aborted"===t?t:void 0;void 0!==u&&(n.status=u);let p=i(e.task);void 0!==p&&(n.task=p);let m=i(e.assignment);void 0!==m&&(n.assignment=m);let h=i(e.description);void 0!==h&&(n.description=h);let f=i(e.lastIntent);void 0!==f&&(n.lastIntent=f);let x=i(e.currentTool);void 0!==x&&(n.currentTool=x);let g=i(e.currentToolArgs);void 0!==g&&(n.currentToolArgs=g);let b=s(e.currentToolStartMs);void 0!==b&&(n.currentToolStartMs=b),Array.isArray(e.recentTools)&&(n.recentTools=e.recentTools),Array.isArray(e.recentOutput)&&(n.recentOutput=e.recentOutput.filter(e=>"string"==typeof e));let v=s(e.toolCount);void 0!==v&&(n.toolCount=v);let k=s(e.requests);void 0!==k&&(n.requests=k);let y=s(e.tokens);void 0!==y&&(n.tokens=y);let N=s(e.contextTokens);void 0!==N&&(n.contextTokens=N);let w=s(e.contextWindow);void 0!==w&&(n.contextWindow=w);let Y=s(e.cost);void 0!==Y&&(n.cost=Y);let D=s(e.durationMs);void 0!==D&&(n.durationMs=D),("string"==typeof e.modelOverride||Array.isArray(e.modelOverride)&&e.modelOverride.every(e=>"string"==typeof e))&&(n.modelOverride=e.modelOverride);let F=i(e.modelRole);void 0!==F&&(n.modelRole=F);let A=i(e.resolvedModel);if(void 0!==A&&(n.resolvedModel=A),"boolean"==typeof e.resolvedModelIsFallback&&(n.resolvedModelIsFallback=e.resolvedModelIsFallback),(0,r.u)(e.retryState)){let t=s(e.retryState.attempt),r=s(e.retryState.maxAttempts),a=s(e.retryState.delayMs),l=i(e.retryState.errorMessage),o=s(e.retryState.startedAtMs);void 0!==t&&void 0!==r&&void 0!==a&&void 0!==l&&void 0!==o&&(n.retryState={attempt:t,maxAttempts:r,delayMs:a,errorMessage:l,startedAtMs:o})}if((0,r.u)(e.retryFailure)){let t=s(e.retryFailure.attempt),r=i(e.retryFailure.errorMessage);void 0!==t&&void 0!==r&&(n.retryFailure={attempt:t,errorMessage:r})}return void 0!==e.inflightTaskDetails&&(n.inflightTaskDetails=e.inflightTaskDetails),(0,r.u)(e.extractedToolData)&&(n.extractedToolData=e.extractedToolData),Object.keys(n).length>0?n:void 0}function o(e){if(!(0,r.u)(e))return;let t=i(e.id),n=i(e.status);if(!t||!n||"started"!==n&&"completed"!==n&&"failed"!==n&&"aborted"!==n)return;let l={id:t,agent:i(e.agent)??"subagent",status:n,index:s(e.index)??-1,lastUpdate:Date.now(),source:"live"},o=a(e.agentSource);void 0!==o&&(l.agentSource=o);let c=i(e.description);void 0!==c&&(l.description=c);let d=i(e.sessionFile);void 0!==d&&(l.sessionFile=d);let u=i(e.parentToolCallId);return void 0!==u&&(l.parentToolCallId=u),"boolean"==typeof e.detached&&(l.detached=e.detached),l}function c(e){if(!(0,r.u)(e))return[];let t=e.subagents;if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=function(e){let t;if(!(0,r.u)(e))return;let n=i(e.id),o=i(e.agent);if(!n||!o)return;if("started"===e.status||"completed"===e.status||"failed"===e.status||"aborted"===e.status)t=e.status;else{if("pending"!==e.status&&"running"!==e.status)return;t="started"}let c={id:n,agent:o,status:t,index:s(e.index)??-1,source:"live"},d=a(e.agentSource);void 0!==d&&(c.agentSource=d);let u=i(e.description);void 0!==u&&(c.description=u);let p=i(e.task);void 0!==p&&(c.task=p);let m=i(e.assignment);void 0!==m&&(c.assignment=m);let h=i(e.sessionFile);void 0!==h&&(c.sessionFile=h);let f=i(e.parentToolCallId);void 0!==f&&(c.parentToolCallId=f),c.lastUpdate=s(e.lastUpdate)??Date.now();let x=l(e.progress);return void 0!==x&&(c.progress=x),c}(e);t&&n.push(t)}return n}function d(e,t){return(e.batchSeq??Number.MAX_SAFE_INTEGER)-(t.batchSeq??Number.MAX_SAFE_INTEGER)||e.index-t.index||e.id.localeCompare(t.id)}function u(e,t,n){let r=new Map(e.map(e=>[e.id,e]));for(let e of t){let t=r.get(e.id);if(!t){r.set(e.id,e);continue}let i=t.batchSeq??e.batchSeq;if(void 0!==n&&(t.lastUpdate??0)>=n||"history"===e.source&&"history"!==t.source){i!==t.batchSeq&&r.set(e.id,{...t,batchSeq:i});continue}if("history"!==e.source&&"history"===t.source){r.set(e.id,{...e,batchSeq:i});continue}r.set(e.id,{...t,...e,batchSeq:i})}return[...r.values()].sort(d)}n.d(t,{bH:()=>o,j8:()=>u,mq:()=>l,vG:()=>c})},So(e,t,n){let r="omp_chamber_settings",i=null,s={};function a(e){s={...e?.[r]??{}};let t={...e??{}};delete t[r],i={...t,...s}}function l(e){return i||a(e),i??{}}function o(e,t){let n=Array.isArray(e)?e:[e],r=l(t);for(let e of n)if(void 0!==r[e])return r[e]}function c(e,t){return l(t),{...e,...s}}function d(e,t){i={...l(),[e]:t},p({[e]:t})}function u(e){s={...s,...e},i={...l(),...e},p({[r]:s})}function p(e){fetch("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}n.d(t,{BF:()=>o,cm:()=>c,cz:()=>d,l1:()=>u,x9:()=>a})},oS(e,t,n){function r(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}n.d(t,{u:()=>r})},Gb(e,t,n){function r(e,t){if(!t)return{folder:null,projectPath:null};for(let n of e)if((n.sessions||[]).some(e=>String(e.id)===String(t)))return{folder:n,projectPath:n.project_path??null};return{folder:null,projectPath:null}}function i(e,t,n){let i=r(e,t).folder,s=null!=n?e.find(e=>String(e.id)===String(n))??null:null;return(i??s)?.project_path??null}n.d(t,{M:()=>i,t:()=>r})},A(e,t,n){var r=n("g6"),i=n("AB"),s=n("N"),a=n("h"),l=n("al"),o=n("nv"),c=n("nT"),d=n("w"),u=n("Oj"),p=n("Gh"),m=n("R"),h=n("HJ"),f=n("DK"),x=n("f"),g=n("z9"),b=n("Fx"),v=n("F9"),k=n("bt"),y=n("YO"),N=n("by");let w={default:r.A,code:i.A,terminal:s.A,rocket:a.A,flask:l.A,gamepad:o.A,briefcase:c.A,home:d.A,globe:u.A,leaf:p.A,shield:m.A,palette:h.A,server:f.A,smartphone:x.A,database:g.A,lightbulb:b.A,music:v.A,camera:k.A,book:y.A,heart:N.A};function Y(e){return w[e||"default"]||r.A}n.d(t,{x:()=>Y})},SS(e,t,n){let r=new Map,i=new Map,s=new Set,a=new Map,l=new Map;function o(e){let t=r.get(e);void 0!==t&&(r.delete(e),r.set(e,t)),i.set(e,Date.now())}function c(e){let t=Date.now(),n=e=>{r.delete(e),s.delete(e),a.delete(e),i.delete(e);let t=l.get(e);t&&(clearTimeout(t),l.delete(e))};for(let[r,s]of i)!(t-s<=6e5)&&r!==e&&(a.get(r)||n(r));for(;r.size>10;){let t=!1;for(let i of r.keys())if(i!==e&&!a.get(i)){n(i),t=!0;break}if(!t)break}}function d(e,t){if(e)return o(e),r.get(e)?.[t]}function u(e,t,n){if(!e)return;let i=r.get(e)??{};i[t]=n,r.set(e,i),o(e),a.set(e,!0),p(e),c(e)}function p(e){let t=l.get(e);t&&clearTimeout(t),l.set(e,setTimeout(()=>{l.delete(e),m(e)},600))}async function m(e){if("u"<typeof window||!e||!a.get(e))return;a.set(e,!1);let t=r.get(e)??{};try{await fetch(`/api/sessions/${encodeURIComponent(e)}/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:t})})}catch(t){console.warn("session-state persist failed:",t),a.set(e,!0)}}function h(e){if(!e||"u"<typeof window)return Promise.resolve();let t=l.get(e);return t&&(clearTimeout(t),l.delete(e)),m(e)}async function f(e){if(e){if("u"<typeof window)return void s.add(e);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/state`);if(t.ok){let n=await t.json(),i=n.state&&"object"==typeof n.state?n.state:{},s=r.get(e)??{},l=!0===a.get(e)?{...i,...s}:i;r.set(e,l),o(e)}}catch(e){console.warn("session-state load failed:",e)}s.add(e),c(e)}}function x(e,t){e&&(r.set(e,{...r.get(e)??{},...t}),o(e),s.add(e),c(e))}function g(e){e&&s.add(e)}function b(e){e&&i.set(e,Date.now())}function v(e){return i.get(e)}function k(e,t){let n=r.get(e);n&&r.set(t,{...n,...r.get(t)??{}}),o(t),s.add(t),a.set(t,!0),p(t),r.delete(e),s.delete(e),a.delete(e),i.delete(e),c(t)}n.d(t,{D4:()=>h,E9:()=>x,L6:()=>f,R7:()=>v,WV:()=>d,Y1:()=>b,l5:()=>g,qI:()=>u,vy:()=>k})},P(e){e.exports={rE:"0.4.0"}}},a={};function l(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return s[e].call(n.exports,n,n.exports,l),n.exports}l.m=s,l.d=(e,t,n)=>{var r=(t,n)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,[n]:t[r]})};r(t,"get"),r(n,"value")},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce((t,n)=>(l.f[n](e,t),t),[])),l.u=e=>"static/js/async/"+(121===e?"katex-vendor":e)+"."+({0:"8e59f2eb5b","0k":"5852e6b4fa","0w":"9ed36d5860",1:"f387c12b63",12:"d091f91c99",121:"de6a87c308",13:"8f810a8a6c",19:"6fe909d55a","1b":"23f1141a38","1k":"5974df3b87","1p":"0d5cddda96",2:"b589f1733b","2v":"96165101de",3:"0cacc08423",37:"b28b2f61cd","3d":"5085fb913f","3j":"357c80ff38","3p":"bcf32a0983","3r":"3a69e98ee0","3u":"1228460e2a","3y":"ededeebde8",4:"9442eeb472","4e":"678285ca55","4k":"33a0c7eeb4","4q":"aad20dab25",5:"ebaf8b89cc",51:"95bcae98af","5b":"d88304bc13","5j":"d6407c4248","5o":"88316d4460",6:"f034c9b528",66:"5dfa29f957","6o":"5b1a06a382",7:"e4a9288dd0",73:"50280ce58d","7e":"a1cc9bfd88","7l":"7a6a377ecc",8:"5067439d8c","8j":"ea110663fb",a:"e05da304c8",aa:"65d3852576",ar:"1e14da5588",art:"62139ed479",az:"d656062b0f",b:"b4f6f06515",bq:"586bc738d1",c:"cd45b0ac45",c0:"0af1e640d3",ca:"8a52cfd447",cf:"d34fff5d67",ct:"b74928f7a3",cx:"ca5feec570",d:"a5fc8fe1b3",da:"f62c70f6c8",dp:"1725d6432c",e:"93214d622b",f:"ab50467719",f8:"bbf0dbae70",fw:"6a51998a8e",g:"7a4bbd4798",h:"4e790471e4",h1:"e8d5aa8e80",h3:"216e9798ab",hd:"0da931b622",hk:"ba7fb04d41",hn:"7568bdb58b",ho:"475a5e1ae4",hp:"e9fe2e395a",hs:"6d480d0ded",i:"7c148e8440",id:"573df20f29",j:"ab925882d8",jd:"63886a1f09",jg:"69a4beade8",jl:"874d352278",jll:"11313b455a",js:"67182759ef",jsc:"23b70d6f40",jse:"334588ff5d",jz:"72eb929106",k:"7466330d1a",ka:"c1990ecaa3",kc:"bbdb35b771",ku:"29c8a59d0c",ky:"8dab1dade0",l:"102a97fce6",l6:"c56640c205",l9:"949710adaf",m:"4b29d34f93",me:"8ace414f80",mt:"0352e976d8",n:"a9f1c51701",na:"a36cd532d6",nk:"6de011832e",o:"36353dfb88",oc:"9c060c9779",og:"634fba99ac",p:"48ecfcd14e",px:"783b6f91f2",q:"7fb4d2f374",q5:"e683f7c26e",qs:"2a9ddb3c72",r:"51010ad87c",rd:"cb6bf495bb",rf:"d626afc367",s:"413c2a4683",sy:"d16be843a7",t:"cb3fcf8615",t9:"d44f57d518",ta:"973534bbec",ty:"3d93cf5f5f",u:"0871ac5b22",ud:"3065bfee31",uf:"46ad6209fa",up:"ea990da0ff",uw:"8890abbabc",v:"7d28d3c241",v0:"394ed37c6b",vn:"e98e2f3b61",vp:"9b13bf8610",vt:"42416b707d",vy:"bbe114c4e0",w:"08ac210f60",wt:"ad92393a90",x:"563f72ca6b",x0:"475516418f",x1:"da8687159b",xl:"a3c562a58c",xn:"afecebbbd9",xw:"ae67ba06fd",y:"1a9ed7a5d8",y6:"43c57defe4",yb:"8c1342401d",ybq:"4491f2f2dc",yg:"35bebd6d0c",yq:"917ddd7ba2",ys:"00687cf82d",yv:"2fa22f009a",z:"56f61a4374",zi:"5fdb07b86a",zj:"654f37e8ff",zn:"966d6f1cc6",zo:"26213b40c0",zx:"e9f4105e00"})[e]+".js",l.miniCssF=e=>""+e+".css",l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},l.l=function(t,n,r,i){if(e[t])return void e[t].push(n);if(void 0!==r)for(var s,a,o=document.getElementsByTagName("script"),c=0;c<o.length;c++){var d=o[c];if(d.getAttribute("src")==t||d.getAttribute("data-rspack")=="ompchamber:"+r){s=d;break}}s||(a=!0,(s=document.createElement("script")).timeout=120,l.nc&&s.setAttribute("nonce",l.nc),s.setAttribute("data-rspack","ompchamber:"+r),s.src=t),e[t]=[n];var u=function(n,r){s.onerror=s.onload=null,clearTimeout(p);var i=e[t];if(delete e[t],s.parentNode&&s.parentNode.removeChild(s),i&&i.forEach(function(e){return e(r)}),n)return n(r)},p=setTimeout(u.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=u.bind(null,s.onerror),s.onload=u.bind(null,s.onload),a&&document.head.appendChild(s)},l.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t=[],l.O=(e,n,r,i)=>{if(n){i=i||0;for(var s=t.length;s>0&&t[s-1][2]>i;s--)t[s]=t[s-1];t[s]=[n,r,i];return}for(var a=1/0,s=0;s<t.length;s++){for(var[n,r,i]=t[s],o=!0,c=0;c<n.length;c++)(!1&i||a>=i)&&Object.keys(l.O).every(e=>l.O[e](n[c]))?n.splice(c--,1):(o=!1,i<a&&(a=i));if(o){t.splice(s--,1);var d=r();void 0!==d&&(e=d)}}return e},l.p="/",n={qz:0},l.f.j=function(e,t){var r=l.o(n,e)?n[e]:void 0;if(0!==r)if(r)t.push(r[2]);else{var i=new Promise((t,i)=>r=n[e]=[t,i]);t.push(r[2]=i);var s=l.p+l.u(e),a=Error();l.l(s,function(t){if(l.o(n,e)&&(0!==(r=n[e])&&(n[e]=void 0),r)){var i=t&&("load"===t.type?"missing":t.type),s=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+i+": "+s+")",a.name="ChunkLoadError",a.type=i,a.request=s,r[1](a)}},"chunk-"+e,e)}},l.O.j=e=>0===n[e],r=(e,t)=>{var r,i,[s,a,o]=t,c=0;if(s.some(e=>0!==n[e])){for(r in a)l.o(a,r)&&(l.m[r]=a[r]);if(o)var d=o(l)}for(e&&e(t);c<s.length;c++)i=s[c],l.o(n,i)&&n[i]&&n[i][0](),n[i]=0;return l.O(d)},(i=self.rspackChunkompchamber=self.rspackChunkompchamber||[]).forEach(r.bind(null,0)),i.push=r.bind(null,i.push.bind(i));var o=l.O(void 0,["a3","9","uy"],()=>l("d"));o=l.O(o)})();
33
+ (Lanjutkan dari halaman ini.)`})};return window.addEventListener(r7.j,t),()=>window.removeEventListener(r7.j,t)},[]);let[w,N]=(0,rB.bL)("chat.draftAttachments",[]),[Y,D]=(0,i.J0)([]),F=!!l?.startsWith("new-");!function(e){let{sessionId:t,messages:n,scrollRef:r,scrollToBottom:s,enabled:a}=e,l=(0,i.li)(null),o=(0,i.li)(null);rq(()=>{if(l.current!==t){l.current=t,o.current=null;return}a&&t&&0!==n.length&&o.current!==t&&r.current&&(o.current=t,s("instant"))},[t,n,a,r,s])}({sessionId:l,messages:Y,scrollRef:m,scrollToBottom:b,enabled:!F});let[A,S]=(0,i.J0)(!1),C=(0,i.li)(!1),T=(0,i.li)([]);T.current=Y;let[z,$]=(0,i.J0)(""),j=(0,i.li)(null),L=(0,i.li)(l);L.current=l;let M=(0,i.hb)(e=>{C.current=e,S(e)},[]),P=(0,i.li)(!1),E=(0,i.li)(null),R=(0,i.li)(!1),I=(0,i.li)(null),O=(0,i.li)([]),J=!!l&&!String(l).startsWith("new-")&&Number.isNaN(Number(l)),_=(0,i.li)(null),{sessionData:W,adoptedSessionIdRef:K,refreshSessionMeta:H,setSessionModel:B,hasMore:q,loadingOlder:G,loadOlderError:V,sessionLoading:Z,loadOlder:Q}=function(e){let{sessionId:t,setLocalMessages:n,setGenerating:r,isGeneratingRef:s,aiPlaceholderIdRef:a,localMessagesRef:l,optimisticUserIdRef:o,cancelStreamingCoalescer:c,metaRefreshedRef:d,scrollRef:u}=e,[p,m]=(0,i.J0)(null),[h,f]=(0,i.J0)(!1),[x,g]=(0,i.J0)(0),[b,v]=(0,i.J0)(!1),[k,y]=(0,i.J0)(!1),[w,N]=(0,i.J0)(0),Y=(0,i.li)(!1),[D,F]=(0,i.J0)(!1),A=(0,i.li)(null),S=(0,i.li)(null),C=(0,i.li)(null),T=(0,i.li)(null),z=(0,i.hb)(e=>{e.model&&"object"==typeof e.model&&(T.current=e.model);let t=e.model??(s.current?T.current??void 0:void 0);m({...e,model:t})},[]),$=(0,i.li)(t);$.current=t;let j=(0,i.hb)(e=>{let t=()=>$.current===e||C.current===e;if(!t())return;let n=0,r=()=>{t()&&fetch(`/api/chat/${encodeURIComponent(e)}`).then(e=>e.json()).then(i=>{if(!i?.session||!t())return;if(z(i.session),(i.session.messages?.length??0)>0)return void window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}));let s=r9[n];n+=1,void 0!==s&&setTimeout(r,s)}).catch(()=>{})};r()},[z]),L=(0,i.hb)(e=>{T.current=e,m(t=>({...t??{},model:e??void 0}))},[]),M=(0,i.hb)(()=>s.current&&!!a.current,[a]);(0,i.vJ)(()=>{let e=!0;if(F(!0),t!==S.current){let e=t&&!t.startsWith("new-")&&S.current?.startsWith("new-"),i=s.current&&C.current===t;e||i||(n([]),r(!1),C.current=null,T.current=null,a.current=null,o.current=null,c()),f(!1),g(0),Y.current=!1,v(!1),y(!1),d.current=null,S.current=t}return t?fetch(`/api/chat/${t}`).then(e=>e.json()).then(r=>{if(e)if(F(!1),r?.session){z(r.session);let e=r.session.messages||[],i=M();if(e.length>0&&!i)if(s.current){let t=e.map(e=>e.id);n([...e,...l.current.filter(e=>!t.includes(e.id))])}else n(e);else t.startsWith("new-")||i||n([]);"boolean"==typeof r.hasMore&&f(r.hasMore),"number"==typeof r.oldestIndex&&g(r.oldestIndex)}else m(null),M()||n([])}).catch(t=>{console.error("Error loading session from API:",t),e&&F(!1),e&&!M()&&(m(null),n([]))}):(m(null),n([])),()=>{e=!1}},[t,z,M,n,r]);let P=(0,i.hb)(()=>{if(!t||t.startsWith("new-")||!h||Y.current)return;Y.current=!0,v(!0),y(!1);let e=u?.current;e&&(A.current={prevHeight:e.scrollHeight,prevTop:e.scrollTop}),fetch(`/api/chat/${t}?before=${x}`).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{if($.current!==t)return;let r=e.session?.messages??[];if(f(!!e.hasMore),"number"==typeof e.oldestIndex&&g(e.oldestIndex),0===r.length){A.current=null;return}n(e=>[...r,...e]),N(e=>e+1)}).catch(()=>{$.current===t&&y(!0)}).finally(()=>{Y.current=!1,v(!1)})},[t,h,x,u,n]);return(0,i.Nf)(()=>{let e=A.current;if(!e)return;let t=u?.current;if(!t)return;A.current=null;let n=t.scrollHeight-e.prevHeight;n>0&&(t.scrollTop=e.prevTop+n)},[w,u]),{sessionData:p,hasMore:h,loadingOlder:b,loadOlderError:k,sessionLoading:D,loadOlder:P,adoptedSessionIdRef:C,seededModelRef:T,applySessionData:z,refreshSessionMeta:j,setSessionModel:L,timelineOwnedByOptimistic:M}}({sessionId:l,setLocalMessages:D,setGenerating:M,isGeneratingRef:C,aiPlaceholderIdRef:_,localMessagesRef:T,optimisticUserIdRef:I,cancelStreamingCoalescer:is,metaRefreshedRef:E,scrollRef:m});p.current=Q;let X=(0,i.li)(null),ee=(0,i.li)(null),et=(0,i.li)(null),[en,er]=(0,i.J0)(()=>{var e,t;return"string"==typeof(t=e=n.omp_access_mode)&&U.some(e=>e===t)?e:"always-ask"}),ei=(0,i.li)(en);ei.current=en;let es=(0,i.hb)(e=>{er(e),ei.current=e,(0,ia.cz)("omp_access_mode",e)},[]),ea=(0,i.hb)(e=>{l&&fetch(`/api/chat/${l}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:e})}).catch(e=>console.error("Error persisting messages via API:",e))},[l]),{messageQueue:el,setMessageQueue:eo,steeringQueue:ec,setSteeringQueue:ed,removeDeliveredFromQueue:eu}=function(e){let[t,n]=(0,i.J0)([]),[r,s]=(0,rB.bL)("chat.steeringQueue",[]),a=(0,i.li)(0);(0,i.vJ)(()=>{if(!e)return void n([]);let t=++a.current,r=!1;return fetch(`/api/sessions/${encodeURIComponent(e)}/queue`).then(e=>e.ok?e.json():{queue:[]}).then(e=>{r||a.current!==t||n(Array.isArray(e.queue)?e.queue:[])}).catch(()=>{}),()=>{r=!0}},[e]);let l=(0,i.hb)(t=>{e&&fetch(`/api/sessions/${encodeURIComponent(e)}/queue`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({queue:t})}).catch(console.error)},[e]),o=(0,i.hb)(e=>{n(t=>{let n="function"==typeof e?e(t):e;return l(n),n})},[l]),c=(0,i.hb)(e=>{let t=t=>t.some(t=>t.text===e);s(n=>t(n)?n.filter(t=>t.text!==e):n),o(n=>t(n)?n.filter(t=>t.text!==e):n)},[s,o]);return{messageQueue:t,setMessageQueue:o,steeringQueue:r,setSteeringQueue:s,removeDeliveredFromQueue:c}}(l),{dialog:ep,enqueue:em,dismiss:eh,withdraw:ef}=function(e){let[t,n]=(0,i.J0)([]);(0,i.vJ)(()=>{n([])},[e]);let r=(0,i.hb)(e=>{n(t=>t.some(t=>t.id===e.id)?t:[...t,e])},[]),s=(0,i.hb)(()=>{n(e=>e.slice(1))},[]),a=(0,i.hb)(e=>{n(t=>t.filter(t=>t.id!==e))},[]);return{dialog:t[0]??null,enqueue:r,dismiss:s,withdraw:a}}(l),ex=function(e,t,n){let[r,s]=(0,i.J0)({isGenerating:!1,connected:!1,error:null}),a=(0,i.li)(t);a.current=t;let l=(0,i.li)(e);l.current=e;let o=(0,i.li)(new Map),c=(0,i.li)(null),d=(0,i.li)(!1),u=(0,i.li)(""),p=(0,i.li)(void 0),m=(0,i.li)(new Set),{connect:h,disconnect:f}=function(e){let{setState:t,callbacksRef:n,toolResultsRef:r,lastToolMessageRef:s,interruptPendingRef:a,activityRef:l,currentThinkingLevelRef:o,fileMutatingCallsRef:c,transport:d}=e,u=(0,i.li)(null);(0,i.vJ)(()=>((0,rW.dX)({transport:d,connected:!1}),()=>(0,rW.dX)({transport:d,connected:!1})),[d]);let p=(0,i.hb)(()=>{let e=u.current;u.current=null,e?.close(),t(e=>({...e,connected:!1})),(0,rW.dX)({transport:d,connected:!1})},[t,d]);return{connect:(0,i.hb)(e=>{p(),u.current=rK[d](e,{onOpen:()=>{t(e=>({...e,connected:!0})),(0,rW.dX)({transport:d,connected:!0}),n.current?.onConnected?.()},onFrame:i=>{!function(e,t){let n=t.callbacksRef.current;switch(e.type){case"agent_start":t.setState(e=>({...e,isGenerating:!0,error:null})),t.toolResultsRef.current?.clear(),t.fileMutatingCallsRef.current?.clear(),t.lastToolMessageRef.current=null,t.interruptPendingRef.current=!1,t.currentThinkingLevelRef.current=void 0,rR(rL.n1.thinking,t),n?.onAgentStart?.();break;case"message_start":case"message_update":{let r=e.message;if(!r)break;if("toolResult"===r.role){rO(r,t),rR(rL.n1.thinking,t);break}rR(function(e){if(!(0,t3.u)(e))return;let t=(0,rL.oJ)(e.type);if(t){if(t.startsWith("thinking"))return rL.n1.thinking;if(t.startsWith("text"))return rL.n1.writing;if("toolcall_start"===t||"toolcall_delta"===t){let t=function(e){let t=e.partial;if(!(0,t3.u)(t))return;let n=t.content;if(!Array.isArray(n))return;let r="number"==typeof e.contentIndex?e.contentIndex:n.length-1,i=n[r];if((0,t3.u)(i)&&"toolCall"===i.type)return i}(e);if(!t)return;return rM({name:(0,rL.oJ)(t.name),args:t.arguments})}if("toolcall_end"===t){let t=e.toolCall;if(!(0,t3.u)(t))return;return rM({name:(0,rL.oJ)(t.name),args:t.arguments})}}}(e.assistantMessageEvent),t);let i=rp(r);i&&("user"!==i.role&&t.currentThinkingLevelRef.current&&(i.thinkingLevel=t.currentThinkingLevelRef.current),n?.onMessageUpdate?.(i));break}case"message_end":{let r=e.message;if(!r)break;if("toolResult"===r.role){rO(r,t);break}if("custom"===r.role)break;if("user"===r.role){let e=rs(r.content);e&&n?.onQueuedMessageDelivered?.(e);break}let i=rp(r,!1);if(!i)break;"user"!==i.role&&t.currentThinkingLevelRef.current&&(i.thinkingLevel=t.currentThinkingLevelRef.current);let s=rI(i,t.toolResultsRef);s.toolCalls?.length&&(t.lastToolMessageRef.current=s),n?.onMessageEnd?.(s);break}case"tool_execution_start":{let r="string"==typeof e.toolCallId?e.toolCallId:void 0;rR(rM({name:"string"==typeof e.toolName?e.toolName:void 0,args:e.args,intent:"string"==typeof e.intent?e.intent:void 0}),t),r&&t.toolResultsRef.current?.set(r,{output:""}),r&&(0,rP.Y)({toolName:e.toolName,args:e.args})&&t.fileMutatingCallsRef.current?.add(r);let i=t.lastToolMessageRef.current;i?.toolCalls?.some(e=>e.id===r)&&(t.lastToolMessageRef.current={...i,toolCalls:i.toolCalls.map(e=>({...e,status:"running"}))},n?.onMessageUpdate?.(t.lastToolMessageRef.current));break}case"tool_execution_update":{let n="string"==typeof e.toolCallId?e.toolCallId:void 0,r=ru(e.partialResult);if(!n||!r)break;let i=t.toolResultsRef.current?.get(n)?.output??"",s=t.toolResultsRef.current;s&&rE(s,n,{output:i+r}),rJ(n,t);break}case"tool_execution_end":{let n="string"==typeof e.toolCallId?e.toolCallId:void 0;if(!n)break;rR(rL.n1.thinking,t);let r=t.toolResultsRef.current;r&&rE(r,n,{output:ru(e.result),isError:!0===e.isError,details:e.details&&"object"==typeof e.details?e.details:void 0}),rJ(n,t),"u">typeof window&&t.fileMutatingCallsRef.current?.delete(n)&&window.dispatchEvent(new CustomEvent(rP.s,{detail:{sessionId:t.sessionId}}));break}case"agent_end":{t.setState(e=>({...e,isGenerating:!1})),t.activityRef.current="";let r=function(e,t,n){let r;if(!1===e.isTerminal)return{};let i=e.messages;if(!Array.isArray(i))return{};for(let e of i){if(!e||"object"!=typeof e||Array.isArray(e)||"assistant"!==e.role||"aborted"!==e.stopReason&&"error"!==e.stopReason)continue;let i=rp(e,!1);if(!i)continue;let s=rI(i,t.toolResultsRef);s.toolCalls?.length&&(t.lastToolMessageRef.current=s),n?.onMessageEnd?.(s),"string"==typeof e.errorMessage&&(r=e.errorMessage)}return{errorMessage:r}}(e,t,n??void 0);if(t.interruptPendingRef.current){t.interruptPendingRef.current=!1;break}n?.onAgentEnd?.({errorMessage:r.errorMessage??("string"==typeof e.errorMessage?e.errorMessage:void 0),message:"string"==typeof e.message?e.message:void 0});break}case"prompt_error":{let r="string"==typeof e.errorMessage?e.errorMessage:"Prompt failed";t.setState(e=>({...e,isGenerating:!1,error:r})),t.interruptPendingRef.current=!1,t.activityRef.current="",n?.onPromptError?.(r);break}case"notice":n?.onNotice?.("string"==typeof e.level?e.level:"info","string"==typeof e.message?e.message:"");break;case"extension_ui_request":n?.onExtensionUiRequest?.(e);break;case"subagent_lifecycle":case"subagent_progress":case"subagent_event":{let n=e.payload;if(null==n||"object"!=typeof n)break;window.dispatchEvent(new CustomEvent(e.type,{detail:{sessionId:t.sessionId,payload:n}}));break}case"model_changed":n?.onModelChanged?.();break;case"thinking_level_changed":var r;t.currentThinkingLevelRef.current="string"==typeof(r=e.thinkingLevel)&&r.trim()?r.trim():"off"}}(i,{sessionId:e,setState:t,callbacksRef:n,toolResultsRef:r,lastToolMessageRef:s,interruptPendingRef:a,activityRef:l,currentThinkingLevelRef:o,fileMutatingCallsRef:c})},onClose:()=>{t(e=>({...e,connected:!1})),(0,rW.dX)({transport:d,connected:!1})}})},[p,t,n,r,s,a,l,o,c,d]),disconnect:p}}({setState:s,callbacksRef:a,toolResultsRef:o,lastToolMessageRef:c,interruptPendingRef:d,activityRef:u,currentThinkingLevelRef:p,fileMutatingCallsRef:m,transport:n});(0,i.vJ)(()=>{if(!e)return;o.current.clear(),m.current.clear(),c.current=null,u.current="";let t=!1;return fetch(`/api/agent/${encodeURIComponent(e)}`).then(e=>e.ok?e.json():null).then(n=>{if(t||!n?.running)return;let r=n.state;for(let t of((n.busy||r?.isStreaming||r?.isPromptRunning)&&(h(e),a.current.onResumeStream?.()),n.pendingUiRequests??[]))a.current.onExtensionUiRequest?.(t)}).catch(()=>{}),()=>{t=!0,f()}},[e,f,h]);let x=(0,i.hb)(async(e,t,n)=>{let r=l.current;if(!r)return!1;s(e=>({...e,isGenerating:!0,error:null}));try{(await fetch(`/api/agent/${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_state",...n?.accessMode?{accessMode:n.accessMode}:{}})})).ok&&h(r);let i=await fetch(`/api/agent/${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"prompt",message:e,...t?.length?{images:t}:{},...n?.accessMode?{accessMode:n.accessMode}:{}})}),a=await i.json().catch(()=>({}));if(!i.ok||a.error)return s(e=>({...e,isGenerating:!1,error:a.error??`HTTP ${i.status}`})),!1;return!0}catch(e){return s(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),!1}},[h]),g=(0,i.hb)(async(e,t,n,r)=>{s(e=>({...e,isGenerating:!0,error:null}));try{let i=await fetch("/api/agent/new",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"ensure_session",cwd:t,...r?.model?r.model:{},...r?.thinkingLevel?{thinkingLevel:r.thinkingLevel}:{},...r?.accessMode?{accessMode:r.accessMode}:{}})}),a=await i.json().catch(()=>({}));if(!i.ok||!a.sessionId)return s(e=>({...e,isGenerating:!1,error:a.error??`HTTP ${i.status}`})),null;let l=a.sessionId;h(l);let o=await fetch(`/api/agent/${encodeURIComponent(l)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"prompt",message:e,...n?.length?{images:n}:{}})}),c=await o.json().catch(()=>({}));if(!o.ok||c.error)return s(e=>({...e,isGenerating:!1,error:c.error??`HTTP ${o.status}`})),null;return{sessionId:l,model:a.model??null}}catch(e){return s(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),null}},[h]),b=(0,i.hb)(async()=>{let e=l.current;e&&(d.current=!1,await rH(e),s(e=>({...e,isGenerating:!1})))},[]),v=(0,i.hb)(async(e,t)=>{let n=l.current;if(!n)return!1;d.current=!0,s(e=>({...e,isGenerating:!0,error:null}));try{let r=await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"abort_and_prompt",message:e,...t?.length?{images:t}:{}})}),i=await r.json().catch(()=>({}));if(!r.ok||i.error)return d.current=!1,s(e=>({...e,isGenerating:!1,error:i.error??`HTTP ${r.status}`})),!1;return!0}catch(e){return d.current=!1,s(t=>({...t,isGenerating:!1,error:e instanceof Error?e.message:String(e)})),!1}},[]),k=(0,i.hb)(async(e,t)=>{let n=l.current;if(!n)return!1;try{let r=await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"follow_up",message:e,...t?.length?{images:t}:{}})}),i=await r.json().catch(()=>({}));if(!r.ok||i.error)return s(e=>({...e,error:i.error??`HTTP ${r.status}`})),!1;return!0}catch(e){return s(t=>({...t,error:e instanceof Error?e.message:String(e)})),!1}},[]),y=(0,i.hb)(async(e,t)=>{let n=l.current;if(n)try{await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"set_model",provider:e,modelId:t})})}catch{}},[]),w=(0,i.hb)(async e=>{let t=l.current;if(t)try{await fetch(`/api/agent/${encodeURIComponent(t)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"set_thinking_level",level:e})})}catch{}},[]),N=(0,i.hb)(async(e,t)=>{let n=l.current;if(n)try{await fetch(`/api/agent/${encodeURIComponent(n)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"extension_ui_response",id:e.id,...t})})}catch{}},[]);return{...r,sendPrompt:x,sendNewPrompt:g,sendInterruptAndReply:v,sendFollowUp:k,abort:b,setModel:y,setThinkingLevel:w,respondToExtensionUi:N,disconnect:f}}(J?l:null,function(e){let{removeDeliveredFromQueue:t,setGenerating:n,setGeneratingVerb:r,scrollToBottom:i,adoptedSessionIdRef:s,sessionIdRef:a,metaRefreshedRef:l,firstAssistantRef:o,refreshSessionMeta:c,setLocalMessages:d,aiPlaceholderIdRef:u,optimisticUserIdRef:p,pendingUserDisplaysRef:m,persistMessages:h,abortControllerRef:f,appSettings:x,enqueueExtensionDialog:g,withdrawExtensionDialog:b}=e;return it=d,ir=()=>i("smooth"),{onQueuedMessageDelivered:e=>{t(e)},onAgentStart:()=>{n(!0),r(rL.n1.thinking),setTimeout(()=>i("smooth"),50),o.current=!1;let e=s.current??a.current;e&&(window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}})),l.current!==e&&(l.current=e,setTimeout(()=>c(e),100)))},onResumeStream:()=>{n(!0),r(rL.n1.thinking),setTimeout(()=>i("smooth"),50),o.current=!1;let e=s.current??a.current;e&&window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}))},onActivity:e=>{r(e)},onMessageUpdate:e=>{"user"===e.role||n_(e)||(p.current=null),ii.queue(t=>{let n=u.current;if(n_(e)){if(t.some(t=>t.id===e.id))return t;if(n&&t.some(e=>e.id===n)){let r=t.findIndex(e=>e.id===n);return[...t.slice(0,r),e,...t.slice(r)]}return[...t,e]}if("user"===e.role){if(t.some(t=>t.id===e.id))return t;let r=p.current;if(r){let n=t.findIndex(e=>e.id===r);if(-1!==n){let r={...e,id:e.id,content:t[n].content,date:t[n].date,attachments:e.attachments?.length?e.attachments:t[n].attachments};return[...t.slice(0,n),r,...t.slice(n+1)]}}let i=m.current.find(t=>e.content===t.sent||e.content.startsWith(t.sent)||t.sent.startsWith(e.content)),s=i?{...e,content:i.display}:e;if(n&&t.some(e=>e.id===n)){let e=t.findIndex(e=>e.id===n);return[...t.slice(0,e),s,...t.slice(e)]}return[...t,s]}if(n&&t.some(e=>e.id===n))return t.map(t=>t.id===n?e:t);let r=t.findIndex(t=>t.id===e.id);return -1!==r?[...t.slice(0,r),e,...t.slice(r+1)]:[...t,e]},e.id)},onMessageEnd:e=>{if("ai"===e.role&&!n_(e)&&!o.current){o.current=!0;let e=s.current??a.current;e&&"u">typeof window&&window.dispatchEvent(new CustomEvent("omp:session-updated",{detail:{sessionId:e}}))}ii.flush(),"user"!==e.role&&(p.current=null),d(t=>{let n,r=u.current;if("user"===e.role){let n,i=p.current;if(t.some(t=>t.id===e.id))n=t.map(t=>t.id===e.id?e:t);else if(i&&t.some(e=>e.id===i))n=t.map(t=>t.id===i?{...e,id:e.id,content:t.content,date:t.date,attachments:e.attachments?.length?e.attachments:t.attachments}:t);else if(r&&t.some(e=>e.id===r)){let i=t.findIndex(e=>e.id===r);n=[...t.slice(0,i),e,...t.slice(i)]}else n=[...t,e];return h(n),n}if(r&&t.some(e=>e.id===r))n=t.map(t=>t.id===r?e:t);else{let r=t.findIndex(t=>t.id===e.id);n=-1!==r?[...t.slice(0,r),e,...t.slice(r+1)]:[...t,e]}return u.current=null,h(n),n})},onAgentEnd:()=>{ii.flush(),ii.cancel(),n(!1),f.current=null,p.current=null,m.current=[],(0,r3.s4)(x),setTimeout(()=>i("smooth"),50);let e=s.current??a.current;e&&c(e)},onModelChanged:()=>{let e=s.current??a.current;e&&setTimeout(()=>c(e),150)},onPromptError:e=>{n(!1),f.current=null,console.error("OMP prompt error:",e)},onNotice:(e,t)=>{console.info("OMP notice:",t)},onExtensionUiRequest:e=>{"select"===e.method||"confirm"===e.method||"input"===e.method||"editor"===e.method?g(e):"cancel"===e.method&&b(e.targetId)}}}({removeDeliveredFromQueue:eu,setGenerating:M,setGeneratingVerb:$,scrollToBottom:b,adoptedSessionIdRef:K,sessionIdRef:L,metaRefreshedRef:E,firstAssistantRef:R,refreshSessionMeta:H,setLocalMessages:D,aiPlaceholderIdRef:_,optimisticUserIdRef:I,pendingUserDisplaysRef:O,persistMessages:ea,abortControllerRef:j,appSettings:n,enqueueExtensionDialog:em,withdrawExtensionDialog:ef}),(0,r_.ul)(n)),{steerOmpAgent:eg,executeSend:eb}=function(e){let{folders:t,selectedFolderId:n,sessionId:r,isOmpSession:s,appSettings:a,ompAgent:l,setLocalMessages:o,persistMessages:c,setGenerating:d,setGeneratingVerb:u,scrollToBottom:p,jumpToBottom:m,aiPlaceholderIdRef:h,adoptedSessionIdRef:f,optimisticUserIdRef:x,pendingUserDisplaysRef:g,setSessionModel:b,pendingComposerModelRef:v,pendingThinkingLevelRef:k,accessModeRef:y,abortControllerRef:w,setInputValue:N,setSearchParams:Y}=e,D=(0,i.hb)(async(e,t)=>{let n=new Map;try{await Promise.all(t.filter(e=>r0(e.file)).map(async e=>{n.set(e.id,await e.file.text())}))}catch{}let r=t.filter(e=>n.has(e.id)).map(e=>({name:e.file.name,mimeType:e.file.type,content:n.get(e.id),size:e.file.size})),i=await r6(e,r);g.current=[...g.current.slice(-7),{sent:i,display:e}];let s=t.filter(e=>e.file.type.startsWith("image/")&&e.dataBase64).map(e=>({data:e.dataBase64,mimeType:e.file.type}));return{promptText:i,images:s.length?s:void 0}},[]);return{steerOmpAgent:(0,i.hb)(async(e,t)=>{let{promptText:n,images:r}=await D(e,t);await l.sendInterruptAndReply(n,r)||N(e)},[l,D,N]),executeSend:(0,i.hb)(async(e,i,g)=>{let N=g?.model??null,D=N?.accessMode??y.current,F=tY(),A=`msg-${Date.now()}-user`,S=`msg-${Date.now()+1}-ai`,C=new Map;try{await Promise.all(i.filter(e=>r0(e.file)).map(async e=>{C.set(e.id,await e.file.text())}))}catch{}let T=Date.now(),z={id:A,role:"user",date:`Today, ${F}`,startedAt:T,content:e,attachments:i.map(e=>({name:e.file.name,preview:e.dataBase64?`data:${e.file.type};base64,${e.dataBase64}`:e.preview,type:e.file.type,size:e.file.size,content:C.get(e.id)}))},$={id:S,role:"ai",date:`Today, ${F}`,startedAt:T,content:""};if(o(e=>{let t=[...e,z,$];return c(t.filter(e=>e.id!==S)),t}),d(!0),u(rL.n1.thinking),setTimeout(()=>m("smooth"),50),s){h.current=S,x.current=A,N&&(await l.setModel(N.provider,N.modelId),"auto"!==N.thinkingLevel&&await l.setThinkingLevel(N.thinkingLevel));let t=i.filter(e=>e.file.type.startsWith("image/")&&e.dataBase64).map(e=>({data:e.dataBase64,mimeType:e.file.type})),n=i.filter(e=>C.has(e.id)).map(e=>({name:e.file.name,mimeType:e.file.type,content:C.get(e.id),size:e.file.size})),r=await r6(e,n);await l.sendPrompt(r,t.length?t:void 0,{accessMode:D})||(o(e=>e.filter(e=>e.id!==A&&e.id!==S)),h.current=null,x.current=null,d(!1));return}if(!s){let r=t.find(e=>String(e.id)===String(n)),s=r?.project_path||r?.name;if(s){let t=i.filter(e=>e.file.type.startsWith("image/")&&e.dataBase64).map(e=>({data:e.dataBase64,mimeType:e.file.type})),n=i.filter(e=>C.has(e.id)).map(e=>({name:e.file.name,mimeType:e.file.type,content:C.get(e.id),size:e.file.size})),r=await r6(e,n);x.current=A;let a=v.current,o=k.current,c=await l.sendNewPrompt(r,s,t.length?t:void 0,{model:a,thinkingLevel:o,accessMode:y.current});if(c){f.current=c.sessionId,h.current=S,c.model&&b(c.model),v.current=null,k.current=null,fetch(`/api/chat/${encodeURIComponent(c.sessionId)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({messages:[z]})}).catch(e=>console.error("Error persisting spawned user turn:",e)),Y(e=>{let t=new URLSearchParams(e);return t.set("sessionId",c.sessionId),t},{replace:!0});return}}}x.current=null,w.current&&w.current.abort();let j=new AbortController;w.current=j;let L=t.find(e=>String(e.id)===String(n)),M=L?.name||"Workspace";await rV({sessionId:r||`session-${Date.now()}`,prompt:e,workspaceName:M,attachments:i,signal:j.signal},function(e){let{aiPlaceholderId:t,setLocalMessages:n,persistMessages:r,setGenerating:i,setGeneratingVerb:s,abortControllerRef:a,appSettings:l,scrollToBottom:o}=e,c=!1,d=r8(e=>n(e),()=>{c&&(c=!1,o("smooth"))}),u=function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];t&&(c=!0),d.queue(e)};return{onInit:e=>{u(n=>n.map(n=>n.id===t?{...n,id:e.id,date:e.date}:n))},onThinkingStart:()=>{s(rL.n1.thinking),u(e=>e.map(e=>e.id===t||"ai"===e.role?{...e,thinking:{thought:"",isGenerating:!0}}:e)),setTimeout(()=>o("smooth"),50)},onThinkingChunk:e=>{u(n=>n.map(r=>{if(r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id){let t="object"==typeof r.thinking&&r.thinking.thought||"";return{...r,thinking:{thought:t+e.delta,isGenerating:!0}}}return r}),!0)},onThinkingEnd:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,thinking:{thought:e.thought,summary:e.summary,duration:e.duration,isGenerating:!1}}:r))},onToolStart:e=>{s(rM({name:e.name??e.type,input:e.input,command:e.command,target:e.target,intent:e.intent})),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:[...r.toolCalls||[],e]}:r)),setTimeout(()=>o("smooth"),50)},onToolOutputChunk:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:(r.toolCalls||[]).map(t=>t.id===e.id?{...t,output:(t.output||"")+e.delta}:t)}:r),!0)},onToolEnd:e=>{s(rL.n1.thinking),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,toolCalls:(r.toolCalls||[]).map(t=>t.id===e.id?{...t,...e}:t)}:r))},onContentChunk:e=>{s(rL.n1.writing),u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,content:(r.content||"")+e.delta}:r),!0)},onSummary:e=>{u(n=>n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?{...r,summary:e.summary}:r))},onDone:e=>{d.flush(),n(n=>{let i=n.map(r=>r.id===t||"ai"===r.role&&n[n.length-1]?.id===r.id?e.message:r);return r(i),i}),i(!1),a.current=null,(0,r3.s4)(l),setTimeout(()=>o("smooth"),50)},onError:()=>{i(!1),a.current=null}}}({aiPlaceholderId:S,setLocalMessages:o,persistMessages:c,setGenerating:d,setGeneratingVerb:u,abortControllerRef:w,appSettings:a,scrollToBottom:p}))},[a,t,s,l,n,r,p,m,c,b,v,k,y])}}({folders:t,selectedFolderId:c,sessionId:l,isOmpSession:J,appSettings:n,ompAgent:ex,setLocalMessages:D,persistMessages:ea,setGenerating:M,setGeneratingVerb:$,scrollToBottom:b,jumpToBottom:v,aiPlaceholderIdRef:_,adoptedSessionIdRef:K,optimisticUserIdRef:I,pendingUserDisplaysRef:O,setSessionModel:B,pendingComposerModelRef:X,pendingThinkingLevelRef:ee,composerModelRef:et,accessModeRef:ei,abortControllerRef:j,setInputValue:y,setSearchParams:a});(0,i.vJ)(()=>{if(!P.current&&!A&&el.length>0){let e=el[0];eo(e=>e.slice(1)),eb(e.text,e.attachments,{model:e.model})}},[A,el,eb,eo]);let{handleSend:ev,handleEditQueueItem:ek,handleSendNowQueueItem:ey,handleUndo:ew,handleRetry:eN,submitNewChat:eY,stopGenerating:eD,handleThinkingLevelChange:eF,handleModelChange:eA,closeExtensionDialog:eS}=function(e){let{inputValue:t,setInputValue:n,setInputAttachments:r,isGenerating:s,isOmpSession:a,sessionId:l,appSettings:o,messageQueue:c,setMessageQueue:d,executeSend:u,steerOmpAgent:p,ompAgent:m,abortControllerRef:h,setGenerating:f,stopHoldRef:x,persistMessages:g,setLocalMessages:b,pendingComposerModelRef:v,pendingThinkingLevelRef:k,composerModelRef:y,accessModeRef:w,setSearchParams:N,dismissExtensionDialog:Y}=e,D=(0,i.hb)(async(e,r)=>{let i=t.trim();if(i||0!==e.length){if(x.current=!1,s){if(r?.steering){n(""),a?await p(i,e):(h.current&&(h.current.abort(),h.current=null),f(!1),u(i,e));return}if("steering"===(o.omp_chamber_settings?.followUpBehavior??o.followUpBehavior??"queue")&&a){n(""),await p(i,e);return}let t=y.current,s={id:`queue-${Date.now()}`,text:i,attachments:e,model:t?{...t,accessMode:w.current}:null};n(""),d(e=>[...e,s]);return}n(""),u(i,e)}},[t,s,u,d,a,o,p,n,h,f,x,y,w]),F=(0,i.hb)(e=>{d(t=>t.filter(t=>t.id!==e.id)),n(e.text),r(e.attachments)},[d,n,r]),A=(0,i.hb)(async e=>{x.current=!1,d(t=>t.filter(t=>t.id!==e.id)),s?a?p(e.text,e.attachments):(h.current&&(h.current.abort(),h.current=null),f(!1),setTimeout(()=>u(e.text,e.attachments,{model:e.model}),0)):u(e.text,e.attachments,{model:e.model})},[s,u,d,a,p,h,f,x]),S=(0,i.hb)(async(e,t)=>{if(s&&(a?m.abort():h.current&&(h.current.abort(),h.current=null),f(!1)),t&&n(t),a&&l){if(!(await fetch(`/api/chat/${encodeURIComponent(l)}/rewind`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({entryId:e})})).ok)return!1;let t=await fetch(`/api/chat/${encodeURIComponent(l)}`).then(e=>e.json()).catch(()=>null),n=t?.session?.messages??[];return n.length>0&&b(n),!0}return b(t=>{let n=t.findIndex(t=>t.id===e),r=-1!==n?t.slice(0,n):t;return g(r),r}),!0},[s,a,l,g,h,f,n,b]),C=(0,i.hb)(e=>{s&&(a?m.abort():h.current&&(h.current.abort(),h.current=null),f(!1)),b(t=>{let n=t.findIndex(t=>t.id===e);if(n>0&&"user"===t[n-1].role){let e=t[n-1];setTimeout(()=>{let t=Array.isArray(e.attachments)?e.attachments:[];u(e.content,t)},0);let r=t.slice(0,n-1);return g(r),r}return t})},[s,u,g,a,m,h,f,b]),T=(0,i.hb)((e,t)=>{let n=`new-${Date.now()}`;N(e=>{let t=new URLSearchParams(e);return t.set("sessionId",n),t},{replace:!0}),b([]),setTimeout(()=>{u(e,t)},0)},[N,u,b]),z=(0,i.hb)(()=>(x.current=!0,a?m.abort():h.current&&(h.current.abort(),h.current=null),f(!1),c.length),[a,m,h,f,c.length,x]),$=(0,i.hb)(e=>{if("auto"!==e){if(!a){k.current=e;return}m.setThinkingLevel(e)}},[a,m,k]);return{handleSend:D,handleEditQueueItem:F,handleSendNowQueueItem:A,handleUndo:S,handleRetry:C,submitNewChat:T,stopGenerating:z,handleThinkingLevelChange:$,handleModelChange:(0,i.hb)((e,t)=>{if(!a){v.current={provider:e,modelId:t};return}m.setModel(e,t)},[a,m,v]),closeExtensionDialog:(0,i.hb)(()=>{Y()},[Y])}}({inputValue:k,setInputValue:y,setInputAttachments:N,isGenerating:A,isOmpSession:J,sessionId:l,appSettings:n,messageQueue:el,setMessageQueue:eo,executeSend:eb,steerOmpAgent:eg,ompAgent:ex,abortControllerRef:j,setGenerating:M,stopHoldRef:P,persistMessages:ea,setLocalMessages:D,pendingComposerModelRef:X,pendingThinkingLevelRef:ee,composerModelRef:et,accessModeRef:ei,setSearchParams:a,dismissExtensionDialog:eh});return{sessionId:l,folderId:o,isOmpSession:J,selectedFolderId:c,setSelectedFolderId:u,sessionData:W,localMessages:Y,isGenerating:A,hasMore:q,loadingOlder:G,loadOlderError:V,sessionLoading:Z,loadOlder:Q,generatingVerb:z,messageQueue:el,setMessageQueue:eo,steeringQueue:ec,setSteeringQueue:ed,inputValue:k,setInputValue:y,inputAttachments:w,setInputAttachments:N,scrollRef:m,contentRef:h,showScrollBottom:f,isScrolling:x,handleScroll:g,scrollToBottom:b,jumpToBottom:v,handleSend:ev,handleEditQueueItem:ek,handleSendNowQueueItem:ey,handleUndo:ew,handleRetry:eN,submitNewChat:eY,stopGenerating:eD,handleThinkingLevelChange:eF,handleModelChange:eA,accessMode:en,handleAccessModeChange:es,composerModelRef:et,extensionDialog:ep,closeExtensionDialog:eS,respondToExtensionUi:ex.respondToExtensionUi}}({folders:c,appSettings:n}),{toasts:X,pushToast:ee,dismissToast:et}=(0,id.Y)(),[en,er]=(0,i.J0)(null),{pendingUndo:ei,undoing:es,requestUndo:ea,closeUndoConfirm:el,confirmUndo:eo}=function(e){let[t,n]=(0,i.J0)(null),[r,s]=(0,i.J0)(!1),a=(0,i.hb)((e,t)=>{n({id:e,content:t??""})},[]),l=(0,i.hb)(()=>n(null),[]),o=(0,i.hb)(async()=>{!t||r||(s(!0),await e(t.id,t.content)&&n(null),s(!1))},[e,t,r]);return{pendingUndo:t,undoing:r,requestUndo:a,closeUndoConfirm:l,confirmUndo:o}}(O),[ec,ed]=(0,s.o)(),eu=(0,i.hb)(()=>{let e=W();0!==e&&ee(`Stopped. ${e} message${e>1?"s":""} still queued — nothing was sent.`,"success",{action:{label:"Send now",onClick:()=>{let e=N[0];e&&I(e)}},duration:8e3})},[W,ee,N,I]),{activeSubagent:ep,back:em}=function(e,t,n){let[r,s]=(0,i.J0)(null);return(0,i.vJ)(()=>{let e=e=>{let t=e.detail,r=t?.subagent,i=t?.sessionId;r&&i&&(s(r),n(e=>(e.get("sessionId")===i&&e.get("subagent")===r.id||(e.set("sessionId",i),e.set("subagent",r.id)),e),{replace:!1}))};return window.addEventListener("omp:view-subagent",e),()=>window.removeEventListener("omp:view-subagent",e)},[n]),(0,i.vJ)(()=>{if(!t)return void s(null);if(r?.id===t||!e)return;let n=!1;return fetch(`/api/sessions/${encodeURIComponent(e)}/subagents`).then(e=>e.ok?e.json():null).then(e=>{if(n||!e?.subagents)return;let r=e.subagents.find(e=>(0,t3.u)(e)&&e.id===t);r&&s((0,io.Nh)(r))}).catch(()=>{}),()=>{n=!0}},[e,t]),{activeSubagent:r,back:(0,i.hb)(()=>{s(null),n(e=>(e.has("subagent")&&e.delete("subagent"),e),{replace:!0})},[n])}}(u,ec.get("subagent"),ed);!function(e,t,n){let[r,s]=(0,i.J0)(null);(0,i.vJ)(()=>{s(null)},[e]),(0,i.vJ)(()=>{let t=t=>{let n=t.detail;n?.sessionId&&n.title&&String(n.sessionId)===String(e)&&s(n.title)};return window.addEventListener("omp:session-renamed",t),()=>window.removeEventListener("omp:session-renamed",t)},[e]),(0,i.vJ)(()=>{let i=(0,il.fN)(e)?(0,il.g2)(e):null;n?.(i??r??t??null)},[e,t,r,n])}(u,h?.title,a);let eh=(0,i.hb)(e=>{let t=document.getElementById(e);t&&t.scrollIntoView({behavior:"smooth",block:"center"})},[]),ef=(0,i.hb)(e=>er(e),[]),ex=rw(rN)??{},eg=rw(ic)??{},eb=(0,i.Kr)(()=>f.filter(e=>"user"===e.role),[f]),ev="object"==typeof h?.model?h.model.provider:void 0,ek="object"==typeof h?.model?ex[h.model.modelId]??h.model.modelId:h?.model,ey=!!u?.startsWith("new-"),ew=(0,ip.M)(c,u,p),eN=!ey&&k&&0===f.length;return!u||ey?(0,r.Y)(n4,{className:t,folders:c,selectedFolderId:p,setSelectedFolderId:m,rootPath:ew,inputValue:A,setInputValue:S,inputAttachments:C,setInputAttachments:T,onSend:E,isGenerating:x,appSettings:n,messages:f,provider:ev,providerNames:eg,modelName:ek,modelNames:ex,onThinkingLevelChange:K,onModelChange:H,accessMode:B,onAccessModeChange:q,composerModelRef:G,sessionModel:"object"==typeof h?.model?h.model:null,sessionThinkingLevel:h?.thinkingLevel,generatingVerb:w,variant:l}):(0,r.FD)("div",{className:`flex flex-col h-full min-h-0 overflow-hidden bg-canvas relative ${t}`,children:[eN?(0,r.Y)(n6,{}):(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"relative flex-1 min-h-0 flex flex-col",children:ep?(0,r.Y)(rD,{sessionId:u,subagent:ep,onBack:em,provider:ev,providerNames:eg}):(0,r.Y)(rC,{isMobile:d,userMessages:eb,onScrollTo:eh,scrollRef:z,contentRef:$,handleScroll:M,isScrolling:L,loadingOlder:b,hasMore:g,loadOlderError:v,loadOlder:y,messages:f,isGenerating:x,provider:ev,providerNames:eg,modelName:ek,modelNames:ex,thinkingLevel:h?.thinkingLevel,onUndo:ea,onRetry:J,onNewChat:ef,showScrollBottom:j,jumpToBottom:P})}),!ep&&(0,r.Y)(rj,{isMobile:d,isGenerating:x,modelName:ek,generatingVerb:w,provider:ev,providerNames:eg,messageQueue:N,setMessageQueue:Y,onEditQueueItem:R,onSendNowQueueItem:I,steeringQueue:D,setSteeringQueue:F,inputValue:A,setInputValue:S,rootPath:ew,attachments:C,setAttachments:T,onSend:E,onStop:eu,appSettings:n,onThinkingLevelChange:K,onModelChange:H,accessMode:B,onAccessModeChange:q,composerModelRef:G,sessionModel:"object"==typeof h?.model?h.model:null,sessionThinkingLevel:h?.thinkingLevel,variant:l})]}),ei&&(0,r.Y)(n7,{isOmpSession:!!u&&!u.startsWith("new-")&&Number.isNaN(Number(u)),content:ei.content,undoing:es,onClose:el,onConfirm:eo}),null!==en&&(0,r.Y)(re,{initialContent:en,onClose:()=>er(null),onSend:_,appSettings:n,accessMode:B,onAccessModeChange:q,composerModelRef:G}),V&&(0,r.Y)(o,{request:V,onRespond:(e,t)=>{Q(e,t),Z()}}),(0,r.Y)(iu.y,{toasts:X,onDismiss:et})]})}},K(e,t,n){var r=n("j"),i=n("H"),s=n("G"),a=n("X"),l=n("Af");let o=(0,s.q6)(null);function c(e){let{children:t,initialFolders:n=[]}=e,s=(0,a.L)(),[c,d]=(0,i.J0)(!1),u=(0,i.li)(!1),p=(0,i.li)(new Set);(0,i.vJ)(()=>{u.current||(u.current=!0,s.load("/api/sessions/list"))},[]),(0,i.vJ)(()=>{s.data&&d(!0)},[s.data]);let m=(0,i.Kr)(()=>()=>{"idle"===s.state&&s.load("/api/sessions/list")},[s]),h=!!s.data?.folders?.some(e=>e.sessions?.some(e=>"stream"===e.streamStatus));(0,l.n)(m,!h,3e4);let f=(0,i.hb)(e=>{let t=String(e),n=s.data?.folders?.flatMap(e=>e.sessions??[]).find(e=>String(e.id)===t)?.streamStatus;!n||"stream"===n||p.current.has(t)||(p.current.add(t),fetch(`/api/sessions/${encodeURIComponent(t)}/stream-seen`,{method:"POST"}).then(()=>{"idle"===s.state&&s.load("/api/sessions/list")}).catch(()=>{p.current.delete(t)}))},[s]),x=(0,i.Kr)(()=>{let e=s.data,t=p.current;return{folders:(e?.folders??n).map(e=>t.size?{...e,sessions:(e.sessions??[]).map(e=>t.has(String(e.id))?{...e,streamStatus:void 0}:e)}:e),isMock:e?.isMock??!1,initializing:!c,refresh:m,markSeen:f,hasSeen:e=>t.has(String(e))}},[s.data,n,c,m,f]);return(0,r.Y)(o.Provider,{value:x,children:t})}function d(){let e=(0,i.NT)(o);return e||{folders:[],isMock:!1,initializing:!0,refresh:()=>{},markSeen:()=>{},hasSeen:()=>!1}}n.d(t,{O:()=>c,k:()=>d})},z4(e,t,n){n.d(t,{K:()=>f});var r=n("H"),i=n("s");function s(e){let t=-1/0;for(let n of e.sessions??[]){let e=function(e){if(!e)return 0/0;let t=Date.parse(e);return Number.isFinite(t)?t:0/0}(n.updated_at??n.created_at);e>t&&(t=e)}return t}function a(e){let t=-1/0;for(let n of e.sessions??[]){let e=Number(n.id);Number.isFinite(e)&&e>t&&(t=e)}return t}function l(e){let t=Number(e.id);return Number.isFinite(t)?t:-1/0}function o(e,t){return e===t?0:e>t?-1:1}function c(e,t){return e===t?0:e>t?1:-1}let d=["A-Z","Z-A","LATEST_SESSION","LATEST_ADDED"];var u=n("Np"),p=n("K"),m=n("NO"),h=n("So");function f(){let e,t,n,f,x,g,b,v,k,y,w=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},N=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{includePendingSessions:Y=!1,onSelectSession:D,onAfterSelect:F}=N,{folders:A,initializing:S,refresh:C,markSeen:T,hasSeen:z}=(0,p.k)(),[$,j]=(0,i.o)(),L=$.get("sessionId"),M=L?Number.isNaN(Number(L))?L:Number(L):null,P=(0,r.li)(C);P.current=C;let E=(0,r.hb)(()=>P.current(),[]);(e=(0,r.li)(E)).current=E,t=(0,r.li)(void 0),n=(0,r.li)(0),(0,r.vJ)(()=>{let r=()=>{n.current=Date.now(),e.current()},i=()=>{let e=Date.now()-n.current;if(e>=1e3){clearTimeout(t.current),t.current=void 0,r();return}clearTimeout(t.current),t.current=setTimeout(()=>{t.current=void 0,r()},1e3-e)};return window.addEventListener("omp:session-updated",i),()=>{window.removeEventListener("omp:session-updated",i),void 0!==t.current&&(clearTimeout(t.current),t.current=void 0)}},[]),(0,m.sY)("omp:workspace-updated",()=>P.current());let[R,I]=(0,r.J0)(""),[O,J]=(0,r.J0)(!1),[_,W]=(0,r.J0)(!1),[K,U]=(0,r.J0)(()=>{var e;return"string"==typeof(e=w.omp_sidebar_sort)&&d.includes(e)?w.omp_sidebar_sort:"A-Z"}),H=(0,r.li)(null),B=(0,r.hb)(e=>{H.current&&clearTimeout(H.current),H.current=setTimeout(()=>{(0,h.cz)("omp_sidebar_sort",e)},200)},[]);(0,r.vJ)(()=>()=>{H.current&&clearTimeout(H.current)},[]);let q=(0,r.Kr)(()=>(function(e){let t={};for(let n of e)for(let e of n.sessions??[])e.streamStatus&&(t[String(e.id)]=e.streamStatus);return t})(A),[A]);x=null!==(f=null===M?null:String(M))?q[f]:void 0,g=(0,r.li)(null),(b=(0,r.li)(E)).current=E,(v=(0,r.li)(z)).current=z,(0,r.vJ)(()=>{if(!x||"stream"===x||v.current?.(f))return;let e=`${f}:${x}`;g.current!==e&&(g.current=e,fetch(`/api/sessions/${encodeURIComponent(f)}/stream-seen`,{method:"POST"}).then(e=>e.json()).then(e=>{!1===e.deleted&&(g.current=null),b.current()}).catch(()=>{g.current=null}))},[f,x]),(k=(0,r.li)(Object.values(q).includes("stream"))).current=Object.values(q).includes("stream"),(y=(0,r.li)(E)).current=E,(0,r.vJ)(()=>{let e=setInterval(()=>{k.current&&y.current()},8e3);return()=>clearInterval(e)},[]);let G=(0,r.Kr)(()=>{let e=[...A];if(Y){let t=e.some(e=>e.sessions?.some(e=>String(e.id)===String(L))),n=L&&!t?L:null;if(n){let t=$.get("folderId"),r=t?e.find(e=>String(e.id)===String(t)):e[0],i=!!r?.sessions?.some(e=>String(e.id)===String(n));if(r&&!i){let t=(0,u.fd)(n),i=Number.isFinite(t)?new Date(t).toISOString():new Date().toISOString();e=e.map(e=>{if(e.id!==r.id)return e;let t={id:n,folder_id:e.id,title:(0,u.g2)(n),created_at:i,updated_at:i};return{...e,isExpanded:!0,sessions:[t,...e.sessions||[]]}})}}}if(R.trim()){let t=R.toLowerCase();e=Y?e.filter(e=>{let n=e.name.toLowerCase().includes(t),r=e.sessions?.some(e=>e.title.toLowerCase().includes(t));return n||r}).map(e=>{let n=e.sessions?.filter(n=>e.name.toLowerCase().includes(t)||n.title.toLowerCase().includes(t));return{...e,sessions:n,isExpanded:!0}}):e.map(e=>{let n=e.name.toLowerCase().includes(t),r=(e.sessions||[]).filter(e=>e.title.toLowerCase().includes(t));return n?e:{...e,sessions:r}}).filter(e=>e.sessions&&e.sessions.length>0)}return e=[...e].sort((e,t)=>(function(e,t,n){let r=!!e.isPinned;if(r!==!!t.isPinned)return r?-1:1;switch(n){case"Z-A":{let n=t.name.localeCompare(e.name);return 0!==n?n:c(l(e),l(t))}case"LATEST_SESSION":{let n=o(s(e),s(t));if(0!==n)return n;let r=o(a(e),a(t));if(0!==r)return r;let i=o(l(e),l(t));return 0!==i?i:e.name.localeCompare(t.name)}case"LATEST_ADDED":{let n=o(l(e),l(t));return 0!==n?n:e.name.localeCompare(t.name)}default:{let n=e.name.localeCompare(t.name);return 0!==n?n:c(l(e),l(t))}}})(e,t,K))},[A,R,K,L,$,Y]);return{folders:A,initializing:S,refresh:E,activeSessionId:M,sessionParam:L,searchQuery:R,setSearchQuery:I,showArchived:O,setShowArchived:J,optionsOpen:_,setOptionsOpen:W,sortOption:K,handleSortChange:e=>{U(e),W(!1),B(e)},processedFolders:G,sessionStatus:q,handleSelectSession:e=>{T(e),D?D(e):j(t=>(t.set("sessionId",e.toString()),t.has("subagent")&&t.delete("subagent"),t),{replace:!0}),F?.()}}}},FE(e,t,n){var r=n("H"),i=n("g0");function s(){let[e,t]=(0,r.J0)(i.aK);return(0,r.vJ)(()=>{let e=e=>{let n=e.detail;n&&t({transport:n.transport,connected:n.connected})};return window.addEventListener(i.rt,e),t((0,i.aK)()),()=>window.removeEventListener(i.rt,e)},[]),e}n.d(t,{H:()=>s})},pH(e,t,n){async function r(e){if(!e)return!1;try{if(navigator.clipboard&&window.isSecureContext)return await navigator.clipboard.writeText(e),!0}catch(e){}try{let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.left="-999999px",t.style.top="-999999px",t.setAttribute("readonly",""),document.body.appendChild(t),t.focus(),t.select();let n=document.execCommand("copy");return document.body.removeChild(t),n}catch(e){return console.error("Failed to copy text: ",e),!1}}n.d(t,{l:()=>r})},P6(e,t,n){var r=n("H");function i(e,t){let[n,i]=(0,r.J0)(!1),[s,a]=(0,r.J0)(e),l=(0,r.li)(null),o=(0,r.li)(!1);(0,r.vJ)(()=>{n&&l.current?.select()},[n]);let c=()=>{let n=s.trim();i(!1),n&&n!==e&&t?.(n)},d=()=>{o.current=!0,i(!1)};return{isEditing:n,draft:s,setDraft:a,inputRef:l,startRename:()=>{o.current=!1,a(e),i(!0)},commitRename:c,cancelRename:d,handleKeyDown:e=>{"Enter"===e.key?(e.preventDefault(),c()):"Escape"===e.key&&(e.preventDefault(),d())},handleBlur:()=>{if(o.current){o.current=!1;return}c()}}}n.d(t,{B:()=>i})},ng(e,t,n){n("H");var r=n("So");function i(){if("u">typeof window)try{let e=window.AudioContext||window.webkitAudioContext;if(!e)return;let t=new e;"suspended"===t.state&&t.resume();let n=t.currentTime,r=t.createOscillator(),i=t.createGain();r.type="sine",r.frequency.setValueAtTime(587.33,n),r.frequency.exponentialRampToValueAtTime(880,n+.1),i.gain.setValueAtTime(0,n),i.gain.linearRampToValueAtTime(.14,n+.02),i.gain.exponentialRampToValueAtTime(1e-4,n+.32),r.connect(i),i.connect(t.destination),r.start(n),r.stop(n+.32);let s=t.createOscillator(),a=t.createGain();s.type="sine",s.frequency.setValueAtTime(880,n+.06),s.frequency.exponentialRampToValueAtTime(1174.66,n+.18),a.gain.setValueAtTime(0,n+.06),a.gain.linearRampToValueAtTime(.1,n+.08),a.gain.exponentialRampToValueAtTime(1e-4,n+.42),s.connect(a),a.connect(t.destination),s.start(n+.06),s.stop(n+.42),setTimeout(()=>{try{t.close()}catch{}},550)}catch(e){console.warn("Unable to play notification audio chime:",e)}}function s(e){(function(e){if("u"<typeof window)return!0;let t=(0,r.BF)(["chatCompletionSound","soundAlerts"],e);return void 0===t||!!t})(e)&&i()}n.d(t,{$E:()=>i,s4:()=>s})},oj(e,t,n){var r=n("H");function i(e,t){(0,r.vJ)(()=>{let n=n=>{!e.current||e.current.contains(n.target)||t(n)};return document.addEventListener("mousedown",n),document.addEventListener("touchstart",n),()=>{document.removeEventListener("mousedown",n),document.removeEventListener("touchstart",n)}},[e,t])}n.d(t,{W:()=>i})},jo(e,t,n){var r=n("H");function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:600,[t,n]=(0,r.J0)(!1),i=(0,r.li)(null),s=(0,r.hb)(()=>{n(!0),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>n(!1),e)},[e]);return(0,r.vJ)(()=>()=>{i.current&&clearTimeout(i.current)},[]),{isScrolling:t,handleScroll:s}}function s(e){return e?"scrollbar-overlay-scrolling":"scrollbar-overlay"}n.d(t,{K:()=>i,p:()=>s})},NR(e,t,n){var r=n("H");function i(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:7,[n,i]=(0,r.J0)(e);return{visibleCount:n,showMore:(0,r.hb)(()=>i(e=>e+t),[t])}}n.d(t,{y:()=>i})},Po(e,t,n){var r=n("H"),i=n("eh");function s(){let[e,t]=(0,r.J0)(()=>(0,i.nv)());return(0,r.vJ)(()=>{let e=(0,i.Eu)(()=>t(!0)),n=(0,i.LT)(()=>t(!0));return()=>{e(),n()}},[]),e}n.d(t,{w:()=>s})},oZ(e,t,n){var r=n("H");function i(){let[e,t]=(0,r.J0)([]),n=(0,r.li)(0);return{toasts:e,pushToast:function(e){let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"error",i=arguments.length>2?arguments[2]:void 0;n.current+=1,t(t=>[...t,{id:n.current,message:e,type:r,...i}])},dismissToast:e=>{t(t=>t.filter(t=>t.id!==e))}}}n.d(t,{Y:()=>i})},DO(e,t,n){var r=n("H");function i(e,t){return"object"!=typeof e||null===e?t:"error"in e&&"string"==typeof e.error?e.error:"message"in e&&"string"==typeof e.message?e.message:t}function s(){let[e,t]=(0,r.J0)(null),[n,s]=(0,r.J0)(!1),[a,l]=(0,r.J0)(null),[o,c]=(0,r.J0)(null),d=(0,r.li)(null),u=(0,r.li)(!1),p=(0,r.hb)(()=>{if(d.current)return d.current;let e=(async()=>{s(!0),c(null);try{let e=await fetch("/api/updates/check"),n=await e.json();if(!e.ok)throw Error(i(n,`Update check failed (HTTP ${e.status})`));t(n)}catch(e){c(e instanceof Error?e.message:"Unable to check for updates.")}finally{s(!1),d.current=null}})();return d.current=e,e},[]),m=(0,r.hb)(async e=>{l(e),c(null);try{let t=await fetch("/api/updates/apply",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({target:e})}),n=await t.json();if("object"!=typeof n||null===n||!("success"in n)||"boolean"!=typeof n.success||!("target"in n)||"ompchamber"!==n.target&&"omp"!==n.target||!("manual"in n)||"boolean"!=typeof n.manual||!("message"in n)||"string"!=typeof n.message)throw Error(i(n,`Update failed (HTTP ${t.status})`));return await p(),n}catch(e){return c(e instanceof Error?e.message:"Unable to apply the update."),null}finally{l(null)}},[p]);return(0,r.vJ)(()=>{u.current||(u.current=!0,p())},[]),{info:e,checking:n,applying:a,error:o,hasUpdate:!!(e?.ompchamber.updateAvailable||e?.omp.updateAvailable),check:p,apply:m}}n.d(t,{M:()=>s})},c(e,t,n){var r=n("H");function i(e,t){let{enabled:n,intervalMs:i,guardInFlight:s=!1}=t,a=(0,r.li)(e);a.current=e,(0,r.vJ)(()=>{if(!n||i<=0)return;let e="u"<typeof document||"visible"===document.visibilityState,t=!1,r=()=>{if(!s)return void a.current();if(t)return;let e=a.current();if(!e||"function"!=typeof e.then)return;t=!0;let n=()=>{t=!1};Promise.resolve(e).then(n,n)},l=setInterval(()=>{e&&r()},i),o=()=>{let t="visible"===document.visibilityState;t&&!e&&r(),e=t};return document.addEventListener("visibilitychange",o),()=>{clearInterval(l),document.removeEventListener("visibilitychange",o)}},[n,i,s])}n.d(t,{t:()=>i})},NO(e,t,n){var r=n("H");function i(e,t,n,i){let s=(0,r.li)(n);s.current=n,(0,r.vJ)(()=>{let n=e=>s.current(e);return e.addEventListener(t,n,i),()=>e.removeEventListener(t,n,i)},[e,t,i])}function s(e,t,n){i(window,e,t,n)}function a(e,t,n){i(document,e,t,n)}function l(e,t,n){i(window,e,t,n)}n.d(t,{MN:()=>s,sY:()=>l,zo:()=>a})},so(e,t,n){var r=n("H"),i=n("LQ"),s=n("c"),a=n("NO");function l(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,l=!(arguments.length>3)||void 0===arguments[3]||arguments[3],o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0,[c,d]=(0,r.J0)([]),[u,p]=(0,r.J0)(!1),m=(0,r.hb)(()=>{if(!l)return;p(!0);let n=new URLSearchParams;e&&n.set("root",e),t&&"."!==t&&n.set("repo",t),n.set("t",String(Date.now())),fetch(`/api/fs/git?${n.toString()}`).then(e=>e.json()).then(e=>{Array.isArray(e.changes)?d(e.changes):d([])}).catch(()=>d([])).finally(()=>p(!1))},[l,e,t]);(0,r.vJ)(()=>{m()},[m,n]),(0,s.t)(m,{enabled:l,intervalMs:o}),(0,a.MN)("focus",()=>{l&&m()}),(0,a.zo)("visibilitychange",()=>{l&&m()});let h=(0,r.li)(void 0),f=(0,r.hb)(()=>{l&&void 0===h.current&&(h.current=setTimeout(()=>{h.current=void 0,m()},1e3))},[l,m]);(0,r.vJ)(()=>()=>{void 0!==h.current&&clearTimeout(h.current)},[]),(0,a.sY)("omp:session-updated",f),(0,a.sY)("omp:workspace-updated",f);let{fileMap:x,folderMap:g}=(0,r.Kr)(()=>(0,i._)(c),[c]);return{changes:c,fileMap:x,folderMap:g,isLoading:u,refreshGitStatus:m}}n.d(t,{e:()=>l})},Af(e,t,n){var r=n("H"),i=n("Kc"),s=n("c");function a(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:5e3;(0,s.t)(e,{enabled:t,intervalMs:n,guardInFlight:!0})}function l(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:500,s=(0,r.li)(e);s.current=e,(0,r.vJ)(()=>{let e;if(!t)return;let r=()=>{clearTimeout(e),e=window.setTimeout(()=>{e=void 0,("u"<typeof document||"visible"===document.visibilityState)&&s.current()},n)};return window.addEventListener(i.s,r),()=>{window.removeEventListener(i.s,r),clearTimeout(e)}},[t,n])}n.d(t,{n:()=>a,w:()=>l})},As(e,t,n){var r=n("H");let i=(0,n("G").q6)(null);function s(){let e=(0,r.NT)(i);if(!e)throw Error("useSessionState used outside SessionStateProvider");return e}n.d(t,{O:()=>s},{b:i})},FL(e,t,n){var r=n("H"),i=n("SS"),s=n("As");function a(e,t){let{sessionId:n,ready:a}=(0,s.O)(),l=(0,i.WV)(n,e),[o,c]=(0,r.J0)(void 0===l?t:l),d=(0,r.li)(n);(0,r.vJ)(()=>{if(d.current!==n&&(d.current=n),!a)return;let r=(0,i.WV)(n,e);c(void 0===r?t:r)},[n,a,e]);let u=t=>{let r="function"==typeof t?t((0,i.WV)(n,e)??o):t;c(r),(0,i.qI)(n,e,r)};return a||void 0===l||l===o?[o,u,a]:[l,u,a]}function l(){let{sessionId:e,ready:t}=(0,s.O)();return{sessionId:e,ready:t,read:(t,n)=>{let r=(0,i.WV)(e,t);return void 0===r?n:r},hydrate:t=>(0,i.E9)(e,t)}}n.d(t,{bL:()=>a,p0:()=>l},{LO:a})},U(e,t,n){var r=n("H"),i=n("X");function s(e,t){let[n,s]=(0,r.J0)(!1),a=(0,i.L)(),l=(0,i.L)(),o=(0,i.L)();return(0,r.vJ)(()=>{(a.data?.success||l.data?.success)&&window.dispatchEvent(new CustomEvent("omp:workspace-updated"))},[l.data,a.data]),{confirmDelete:n,requestDelete:()=>s(!0),cancelDelete:()=>s(!1),handlePin:()=>{"number"==typeof e.id&&(a.submit({isPinned:String(!e.isPinned)},{method:"POST",action:`/api/folders/${e.id}/pin`}),t())},handleDelete:()=>{"number"==typeof e.id&&(l.submit({},{method:"POST",action:`/api/folders/${e.id}/delete`}),s(!1),t())},handleArchive:e=>{let n=1!==e.is_archived;o.submit({archived:String(n)},{method:"POST",action:`/api/sessions/${e.id}/archive`}),t()},handleRename:async(e,n)=>{try{let t=new FormData;if(t.set("name",n),!(await fetch(`/api/sessions/${encodeURIComponent(String(e.id))}/rename`,{method:"POST",body:t})).ok)return}catch{return}window.dispatchEvent(new CustomEvent("omp:session-renamed",{detail:{sessionId:String(e.id),title:n}})),t()}}}n.d(t,{C:()=>s})},X(e,t,n){var r=n("H");async function i(e){let t=await e.text();if(t)try{return JSON.parse(t)}catch{return}}function s(){let[e,t]=(0,r.J0)(void 0),[n,s]=(0,r.J0)("idle"),a=(0,r.li)(!0),l=(0,r.li)(null);(0,r.vJ)(()=>(a.current=!0,()=>{a.current=!1,l.current?.abort(),l.current=null}),[]);let o=(0,r.hb)(async(e,n,r)=>{l.current?.abort();let o=new AbortController;l.current=o,s(r);try{let r=await fetch(e,{...n,signal:o.signal}),s=await i(r);a.current&&l.current===o&&t(s)}catch{}finally{a.current&&l.current===o&&(l.current=null,s("idle"))}},[]);return{data:e,state:n,load:(0,r.hb)(e=>o(e,{method:"GET"},"loading"),[o]),submit:(0,r.hb)((e,t)=>o(t.action,{method:(t.method??"POST").toUpperCase(),body:function(e){if(e instanceof FormData)return e;let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&t.set(n,String(r));return t}(e),headers:e instanceof FormData?void 0:{"content-type":"application/x-www-form-urlencoded"}},"submitting"),[o])}}n.d(t,{L:()=>s})},s(e,t,n){var r=n("G");let i=new Set,s="u"<typeof window?"":window.location.search;function a(){for(let e of i)e()}function l(e){return i.add(e),()=>i.delete(e)}function o(e){if("string"==typeof e)return e.startsWith("?")?e:`?${e}`;if(e instanceof URLSearchParams)return e.toString()?`?${e.toString()}`:"";let t=new URLSearchParams;for(let[n,r]of Object.entries(e))null!=r&&t.set(n,String(r));return t.toString()?`?${t.toString()}`:""}function c(){return s}function d(){let e=(0,r.rz)(l,c),t=(0,r.hb)((e,t)=>{var n;let r=(n=new URLSearchParams(s),"function"==typeof e?o(e(new URLSearchParams(n))):o(e)),i=`${window.location.pathname}${r}${window.location.hash}`;t?.replace?window.history.replaceState(null,"",i):window.history.pushState(null,"",i),s=r,a()},[]);return[new URLSearchParams(e),t]}"u">typeof window&&window.addEventListener("popstate",function(){let e="u"<typeof window?"":window.location.search;e!==s&&(s=e,a())}),n.d(t,{o:()=>d})},l(e,t,n){var r=n("j"),i=n("v"),s=n("H"),a=n("G"),l=n("s");function o(e,t,n){return Math.min(Math.max(e,t),n)}function c(e,t){return"number"==typeof e?e:"string"==typeof e&&parseFloat(e)||t}let d=(0,a.q6)(null);function u(e){let{orientation:t,id:n,groupRef:i,onLayoutChanged:l,className:c,children:u}=e,p=(0,s.li)(new Map),m=(0,s.li)(l??null);m.current=l??null;let h=(0,a.Kr)(()=>({orientation:t,panels:p,onLayoutChanged:m}),[t]);return(0,a.vJ)(()=>{if(i)return i.current={setLayout:e=>{for(let[t,n]of Object.entries(e)){let e=p.current.get(t);e&&!e.isFiller&&"number"==typeof n&&e.setSize(o(n,e.minSize,e.maxSize))}m.current?.((()=>{let e={};for(let[t,n]of p.current){let r=n.getSize();null!=r&&(e[t]=r)}return e})(),{isUserInteraction:!1})}},()=>{i.current=null}},[i]),(0,r.Y)(d.Provider,{value:h,children:(0,r.Y)("div",{"data-panel-group":"","data-panel-group-id":n,className:c,style:{display:"flex",flex:"1 1 0%",flexDirection:"horizontal"===t?"row":"column",minWidth:0,minHeight:0},children:u})})}function p(e){let{id:t,panelRef:n,defaultSize:i,minSize:s=0,maxSize:l,filler:u=!1,className:p,style:m,children:h}=e,f=(0,a.NT)(d);if(!f)throw Error(`<Panel id="${t}"> must be rendered inside a <Group>`);let{orientation:x,panels:g}=f,b=c(s,0),v=null!=l?c(l,Number.MAX_SAFE_INTEGER):Number.MAX_SAFE_INTEGER,k=(0,a.li)(null),[y,w]=(0,a.J0)(()=>u?null:o(c(i,b),b,v)),N=(0,a.li)(y);N.current=y,(0,a.vJ)(()=>(g.current.set(t,{id:t,isFiller:u,minSize:b,maxSize:v,setSize:e=>w(e),getSize:()=>N.current}),()=>{g.current.delete(t)}),[t]),(0,a.vJ)(()=>{let e=g.current.get(t);e&&(e.minSize=b,e.maxSize=v)}),(0,a.vJ)(()=>{if(n)return n.current={resize:e=>{w(o(e,b,v))},getSize:()=>{let e=N.current;return null!=e?{inPixels:e}:null}},()=>{n.current=null}},[n,b,v]);let Y=u?{flex:"1 1 0%",minWidth:"horizontal"===x?b:0,minHeight:"horizontal"===x?0:b,overflow:"hidden",position:"relative"}:{flex:"0 1 auto",width:"horizontal"===x?y??void 0:void 0,height:"horizontal"===x?void 0:y??void 0,minWidth:"horizontal"===x?b:void 0,minHeight:"horizontal"===x?void 0:b,maxWidth:null!=l?v:void 0,overflow:"hidden",position:"relative"};return(0,r.Y)("div",{ref:k,"data-panel":"","data-panel-id":t,className:p,style:{...Y,...m},children:h})}function m(e){let{className:t,style:n,children:i}=e,s=(0,a.NT)(d),[l,c]=(0,a.J0)(!1),u=(0,a.li)(null),p=(0,a.li)(null);if((0,a.vJ)(()=>()=>p.current?.(),[]),!s)throw Error("<Separator> must be rendered inside a <Group>");let{orientation:m,panels:h,onLayoutChanged:f}=s;return(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{ref:u,"data-separator":"",role:"separator","aria-orientation":"horizontal"===m?"vertical":"horizontal",className:t,style:n,onPointerDown:e=>{let t=u.current;if(!t||0!==e.button)return;let n=t.previousElementSibling,r=t.nextElementSibling,i=n?.getAttribute("data-panel-id"),s=r?.getAttribute("data-panel-id"),a=i?h.current.get(i):void 0,l=s?h.current.get(s):void 0;if(!a||!l||!n||!r)return;e.preventDefault(),c(!0);let d="horizontal"===m?e.clientX:e.clientY,x=e=>"horizontal"===m?e.getBoundingClientRect().width:e.getBoundingClientRect().height,g=x(n),b=x(r),v=e=>{var t,n;let r="horizontal"===m?e.clientX:e.clientY,i=(t={size:g,min:a.minSize,max:a.maxSize},n={size:b,min:l.minSize,max:l.maxSize},o(r-d,Math.max(t.min-t.size,n.size-n.max),Math.min(t.max-t.size,n.size-n.min)));a.setSize(o(g+i,a.minSize,a.maxSize)),l.isFiller||l.setSize(o(b-i,l.minSize,l.maxSize))},k=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",y),window.removeEventListener("pointercancel",y),p.current=null,c(!1);let e={};for(let[t,n]of h.current){let r=n.getSize();null!=r&&(e[t]=r)}f.current?.(e,{isUserInteraction:!0})},y=()=>k();window.addEventListener("pointermove",v),window.addEventListener("pointerup",y),window.addEventListener("pointercancel",y),p.current=k},onDragStart:e=>e.preventDefault(),children:i}),l&&(0,r.Y)("div",{style:{position:"fixed",inset:0,zIndex:9999,cursor:"horizontal"===m?"col-resize":"row-resize"}})]})}var h=n("g"),f=n("r");function x(e){let{onNewSession:t}=e;return(0,r.FD)(r.FK,{children:[(0,r.Y)("div",{className:"h-12 flex-shrink-0 flex items-center px-4 border-b border-ink/10 titlebar-drag-region select-none",style:{paddingLeft:"max(1rem, env(titlebar-area-x, 0px))"},children:(0,r.FD)("span",{className:"font-bold text-sm tracking-tight flex items-center",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-[15px] tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"ml-[1px]",children:"Chamber"})]})}),(0,r.Y)("div",{className:"px-3 pt-3 titlebar-no-drag",children:(0,r.FD)("button",{onClick:t,className:"w-full flex items-center justify-center space-x-2 py-2 bg-ink text-canvas rounded text-xs font-semibold hover:bg-ink/90 transition-colors cursor-pointer",children:[(0,r.Y)(f.A,{size:14}),(0,r.Y)("span",{children:"New Session"})]})})]})}var g=n("D"),b=n("O"),v=n("n"),k=n("t3"),y=n("p7"),w=n("Sj"),N=n("x"),Y=n("S"),D=n("E");function F(e){let{isSearchVisible:t,searchQuery:n,showArchived:i,optionsOpen:s,sortOption:a,onToggleSearch:l,onSearchChange:o,onToggleArchived:c,onHideArchived:d,onToggleOptions:u,onCloseOptions:p,onSortChange:m,onNewWorkspace:h,onScheduler:f,onRefresh:x,onClose:F}=e;return(0,r.FD)("div",{className:"p-3 border-b border-ink/10 flex flex-col space-y-3",children:[(0,r.FD)("div",{className:"flex items-center justify-between px-1 text-ink/60",children:[(0,r.FD)("div",{className:"flex space-x-3 items-center",children:[(0,r.Y)(g.A,{size:14,className:"hover:text-ink cursor-pointer",onClick:h}),(0,r.Y)(b.A,{size:14,className:"hover:text-ink cursor-pointer",onClick:f}),(0,r.Y)("span",{title:"Refresh sessions",onClick:x,className:"inline-flex cursor-pointer",children:(0,r.Y)(v.A,{size:14,className:"hover:text-ink"})})]}),(0,r.FD)("div",{className:"flex space-x-3 items-center relative",children:[(0,r.Y)(k.A,{size:14,className:`cursor-pointer transition-colors ${t?"text-ink":"hover:text-ink"}`,onClick:l}),(0,r.Y)("span",{title:i?"Hide Archive":"Show Archive",onClick:c,className:"inline-flex cursor-pointer",children:(0,r.Y)(y.A,{size:14,className:`transition-colors ${i?"text-ink":"hover:text-ink"}`})}),(0,r.FD)("div",{className:"relative",children:[(0,r.Y)(w.A,{size:14,className:`cursor-pointer transition-colors ${s?"text-ink":"hover:text-ink"}`,onClick:u}),s&&(0,r.Y)("div",{className:"absolute right-0 top-full mt-2 w-48 bg-paper border border-ink/10 rounded shadow-lg z-50 py-1",onMouseLeave:p,children:(0,r.Y)(D.i,{variant:"desktop",sortOption:a,onSortChange:m})})]}),(0,r.Y)(N.A,{size:14,className:"hover:text-ink cursor-pointer ml-1",onClick:F})]})]}),t&&(0,r.Y)("div",{className:"pt-1",children:(0,r.Y)("input",{type:"text",placeholder:"Search workspaces & sessions...",value:n,onChange:e=>o(e.currentTarget.value),autoFocus:!0,className:"w-full bg-ink/5 border border-ink/10 rounded px-2.5 py-1.5 outline-none focus:border-ink/30 text-xs text-ink placeholder-ink/40 transition-colors"})}),i&&(0,r.FD)("div",{className:"flex items-center justify-between bg-amber-500/10 border border-amber-500/20 text-amber-900 rounded px-2.5 py-1.5 text-[10px] font-medium",children:[(0,r.FD)("div",{className:"flex items-center space-x-1.5",children:[(0,r.Y)(y.A,{size:10}),(0,r.Y)("span",{children:"Showing Archived"})]}),(0,r.Y)("button",{className:"hover:text-amber-950",onClick:d,children:(0,r.Y)(Y.A,{size:10})})]})]})}var A=n("vB"),S=n("wU");function C(e){let{onSettings:t,onInfo:n,updateAvailable:i,onUpdateClick:s}=e;return(0,r.FD)("div",{className:"p-3 border-t border-ink/10 flex items-center justify-between text-ink/60 shrink-0",children:[(0,r.FD)("div",{className:"flex space-x-3",children:[(0,r.Y)(A.A,{size:16,className:"hover:text-ink cursor-pointer",onClick:t}),(0,r.Y)(S.A,{size:16,className:"hover:text-ink cursor-pointer",onClick:n})]}),i&&(0,r.Y)("button",{type:"button",onClick:s,className:"px-2 py-0.5 rounded-full border border-ink/20 text-[10px] font-semibold text-ink hover:border-ink/40",children:"update"})]})}var T=n("a"),z=n("X"),$=n("oj"),j=n("NR"),L=n("U"),M=n("Go"),P=n("Nf"),E=n("t"),R=n("z"),I=n("b"),O=n("HZ"),J=n("P6");function _(e){let{title:t,isActive:n=!1,isArchived:i=!1,status:s,onClick:a,onArchive:l,onRename:o,expandable:c=!1,isExpanded:d=!1,hasSubagents:u=!1,onToggleExpand:p}=e,m=!!(c&&u&&p),{isEditing:h,draft:f,setDraft:x,inputRef:g,startRename:b,handleKeyDown:v,handleBlur:k}=(0,J.B)(t,o);return(0,r.FD)("div",{onClick:h?void 0:a,className:`group/item relative flex items-center w-full rounded-lg px-2 py-1.5 cursor-pointer text-xs transition-colors select-none ${n?"bg-ink/10 font-medium text-ink":"text-ink/75 hover:text-ink hover:bg-ink/5"}`,children:[(0,r.FD)("span",{className:"relative w-4 h-4 shrink-0",children:[m&&p&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),p(e)},title:d?"Collapse subagents":"Expand subagents","aria-expanded":d,className:`peer absolute inset-0 flex items-center justify-center rounded cursor-pointer text-ink/40 transition-opacity hover:text-ink ${d?"":"pointer-events-none opacity-0 group-hover/item:pointer-events-auto group-hover/item:opacity-100 focus-visible:opacity-100"}`,children:d?(0,r.Y)(M.A,{size:13,className:"text-ink/70"}):(0,r.Y)(P.A,{size:13})}),s&&!(m&&d)&&(0,r.Y)("span",{className:`absolute inset-0 flex items-center justify-center text-ink/60 transition-opacity ${m?"group-hover/item:opacity-0 peer-focus-visible:opacity-0":""}`,children:"stream"===s?(0,r.Y)(E.A,{size:12,className:"animate-spin"}):(0,r.Y)(R.A,{size:12})})]}),(0,r.Y)("span",{className:"w-2 shrink-0"}),h?(0,r.Y)("input",{ref:g,autoFocus:!0,value:f,onChange:e=>x(e.currentTarget.value),onClick:e=>e.stopPropagation(),onKeyDown:v,onBlur:k,className:"flex-1 min-w-0 bg-paper border border-ink/25 rounded px-1 py-0.5 text-xs text-ink outline-none focus:border-ink/50"}):(0,r.Y)("span",{className:"flex-1 min-w-0 truncate leading-snug",children:t.charAt(0).toUpperCase()+t.slice(1)}),!h&&(o||l)&&(0,r.FD)("div",{className:"absolute right-1.5 top-1/2 -translate-y-1/2 flex items-center gap-0.5 opacity-0 group-hover/item:opacity-100 transition-opacity",children:[o&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),b()},title:"Rename session",className:"p-1 text-ink/40 hover:text-ink bg-paper/90 hover:bg-ink/10 rounded shadow-xs cursor-pointer",children:(0,r.Y)(I.A,{size:12})}),l&&(0,r.Y)("button",{type:"button",onClick:e=>{e.stopPropagation(),l()},title:i?"Unarchive session":"Archive session",className:"p-1 text-ink/40 hover:text-ink bg-paper/90 hover:bg-ink/10 rounded shadow-xs cursor-pointer",children:i?(0,r.Y)(O.A,{size:12}):(0,r.Y)(y.A,{size:12})})]})]})}var W=n("Uo"),K=n("oS"),U=n("B"),H=n("T");let B={pending:"started",running:"started",completed:"completed",failed:"failed",aborted:"aborted"};function q(e){let{sessionId:t,isActiveSession:n}=e,[i]=(0,l.o)(),a=i.get("subagent"),[o,c]=(0,s.J0)([]),[d,u]=(0,s.J0)(!1);(0,s.vJ)(()=>{let e=!1,n=String(t);return c([]),u(!0),(0,U.wv)(n).then(t=>{if(e||!t)return;let n=t.map(U.Nh);c(e=>(0,H.j8)(e,n))}).finally(()=>{e||u(!1)}),()=>{e=!0}},[t]),(0,s.vJ)(()=>{if(!n)return;let e=!1,r=String(t),i=Date.now(),s=e=>{let t=e.detail;return t&&t.sessionId===r?t:null},a=e=>{let t=(0,H.bH)(s(e)?.payload);t&&c(e=>(0,H.j8)(e,[t]))},l=e=>{let t=function(e){let t=(0,H.mq)(e);if(!(0,K.u)(e)||!(0,K.u)(e.progress))return t;let n=(0,H.mq)(e.progress);return n?{...n,id:n.id??t?.id,index:n.index??t?.index}:t}(s(e)?.payload);t&&c(e=>e.map(e=>{if(void 0!==t.id){if(e.id!==t.id)return e}else if(void 0===t.index||t.index<0||e.index!==t.index)return e;let n=t.status&&"started"===e.status?B[t.status]??e.status:e.status;return{...e,status:n,progress:{...e.progress,...t},lastUpdate:Date.now()}}))};return window.addEventListener("subagent_lifecycle",a),window.addEventListener("subagent_progress",l),fetch(`/api/agent/${encodeURIComponent(r)}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({type:"get_subagents"})}).then(e=>e.ok?e.json():null).then(t=>{if(e||!(0,K.u)(t))return;let n="data"in t?t.data:t;c(e=>(0,H.j8)(e,(0,H.vG)(n),i))}).catch(()=>{}),()=>{e=!0,window.removeEventListener("subagent_lifecycle",a),window.removeEventListener("subagent_progress",l)}},[n,t]);let p=d?"Loading subagents…":0===o.length?"No subagent activity":null;return(0,r.Y)("div",{className:"pl-6 pr-0 space-y-0.5 py-0.5",children:p?(0,r.FD)("div",{className:"px-2 py-1 text-xs italic text-ink/40 flex items-center",children:[(0,r.Y)("span",{className:"w-4 h-4 shrink-0"}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"flex-1 min-w-0 truncate",children:p})]}):o.map(e=>{let i=e.task??e.description??e.assignment??e.agent??"",s=e.id===a;return(0,r.FD)("button",{type:"button",title:i,onClick:()=>window.dispatchEvent(new CustomEvent("omp:view-subagent",{detail:{sessionId:String(t),subagent:e}})),className:`w-full flex items-center text-left text-xs rounded-md px-2 py-1 cursor-pointer transition-colors select-none group/subagent ${s?"bg-ink/10 font-medium text-ink":"text-ink/70 hover:text-ink hover:bg-ink/5"}`,children:[(0,r.Y)("span",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:(0,r.Y)(W.l,{status:e.status,live:n&&"started"===e.status,size:11})}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"flex-1 min-w-0 truncate leading-snug",children:i})]},e.id)})})}var G=n("C4"),V=n("So");let Z="omp_sidebar_expanded_sessions";var Q=n("A"),X=n("K");function ee(e){let{folder:t,activeSessionId:n,onSelectSession:i,onNewSessionForFolder:a,forceExpanded:o=!1,showArchived:c=!1,sessionStatus:d={}}=e,[u,p]=(0,s.J0)(t.isExpanded||!1),[m,h]=(0,s.J0)(!1),{visibleCount:x,showMore:g}=(0,j.y)(),[b]=(0,l.o)(),v=b.get("subagent"),k=b.get("sessionId"),[y,N]=(0,s.J0)(()=>new Set);(0,s.vJ)(()=>{let e,t=Array.isArray(e=(0,V.BF)(Z))?new Set(e.filter(e=>"string"==typeof e)):new Set;t&&t.size>0&&N(t)},[]),(0,s.vJ)(()=>{"boolean"==typeof t.isExpanded&&p(t.isExpanded)},[t.isExpanded]),(0,s.vJ)(()=>{v&&k&&N(e=>{if(e.has(k))return e;let t=new Set(e);return t.add(k),t})},[v,k]);let Y=(0,s.li)(null),{refresh:D}=(0,X.k)(),F=(0,z.L)(),{confirmDelete:A,requestDelete:S,cancelDelete:C,handlePin:M,handleDelete:P,handleArchive:E,handleRename:R}=(0,L.C)(t,D);(0,s.vJ)(()=>{F.data?.success&&window.dispatchEvent(new CustomEvent("omp:workspace-updated"))},[F.data]),(0,$.W)(Y,()=>{h(!1),C()});let I=t.sessions,O=(0,Q.x)(t.icon),J=(I||[]).filter(e=>c?1===e.is_archived:1!==e.is_archived),W=J.slice(0,x),K=J.length>x;return(0,r.FD)("div",{className:"space-y-1",children:[(0,r.FD)("div",{className:"group flex items-center justify-between h-7 text-xs font-semibold text-ink px-2 hover:bg-ink/5 rounded-md transition-colors select-none",children:[(0,r.FD)("div",{className:"flex-1 h-full flex items-center cursor-pointer min-w-0",onClick:()=>{let e=!u;p(e),"number"==typeof t.id&&F.submit({isExpanded:String(e)},{method:"POST",action:`/api/folders/${t.id}/toggle`})},children:[(0,r.Y)("span",{className:"w-4 h-4 flex items-center justify-center shrink-0",children:t.customIconUrl?(0,r.Y)("img",{src:t.customIconUrl,alt:"",className:"w-[15px] h-[15px] rounded-xs object-contain shrink-0",referrerPolicy:"no-referrer"}):(0,r.Y)(O,{size:15,className:"text-ink/75",style:{color:t.accentColor||void 0}})}),(0,r.Y)("span",{className:"w-2 shrink-0"}),t.isPinned&&(0,r.Y)(T.A,{size:11,className:"text-ink/60 shrink-0 mr-1.5"}),(0,r.Y)("span",{className:"truncate text-[13px] font-semibold tracking-tight",children:t.name})]}),(0,r.FD)("div",{className:`items-center space-x-0.5 pl-1 ${m?"flex":"hidden group-hover:flex"}`,children:[(0,r.Y)("button",{type:"button",title:"New Session",className:"w-5 h-5 flex items-center justify-center text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer transition-colors",onClick:e=>{e.stopPropagation(),a(t.id)},children:(0,r.Y)(f.A,{size:12})}),(0,r.FD)("div",{className:"relative flex items-center",ref:Y,children:[(0,r.Y)("button",{type:"button",title:"Workspace Options",className:"w-5 h-5 flex items-center justify-center text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer transition-colors",onClick:e=>{e.stopPropagation(),h(!m)},children:(0,r.Y)(w.A,{size:12})}),m&&(0,r.Y)("div",{className:"absolute right-0 top-full mt-1 w-44 bg-paper border border-ink/15 rounded-md shadow-lg z-50 py-1 text-xs",children:(0,r.Y)(G.t,{variant:"desktop",isPinned:t.isPinned,confirmDelete:A,onPin:()=>{M(),h(!1)},onDelete:()=>{P(),h(!1)},onRequestDelete:S,onCancelDelete:C})})]})]})]}),(o||u)&&(0,r.FD)("div",{className:"space-y-0.5",children:[W.map(e=>{let t=String(e.id),s=null!==n?String(n)===t:1===e.is_active,a=s&&k===t&&!!v,l=null!==n&&t===String(n),o=!!e.hasSubagents,c=o&&y.has(t);return(0,r.FD)("div",{className:"space-y-0.5",children:[(0,r.Y)(_,{title:e.title,isActive:s&&!a,isArchived:1===e.is_archived,status:d[t],onClick:()=>i(e.id),onArchive:()=>E(e),onRename:String(e.id).startsWith("new-")?void 0:t=>void R(e,t),expandable:o,hasSubagents:o,isExpanded:c,onToggleExpand:()=>{N(e=>{let n=new Set(e);return n.has(t)?n.delete(t):n.add(t),(0,V.cz)(Z,[...n].slice(-50)),n})}}),o&&c&&(0,r.Y)(q,{sessionId:e.id,isActiveSession:l})]},e.id)}),K&&!o&&(0,r.FD)("button",{type:"button",onClick:g,className:"flex items-center text-xs text-ink/45 hover:text-ink/80 w-full text-left py-1.5 px-2 rounded-lg hover:bg-ink/5 transition-colors cursor-pointer select-none",children:[(0,r.Y)("span",{className:"w-4 h-4 shrink-0"}),(0,r.Y)("span",{className:"w-2 shrink-0"}),(0,r.Y)("span",{className:"truncate leading-snug",children:"Show more sessions"})]}),0===J.length&&(0,r.Y)("div",{className:"px-3 py-2 text-[11px] text-ink/40 italic",children:c?"No archived sessions.":"No sessions."})]})]})}var et=n("jo");function en(e){let{folders:t,activeSessionId:n,searchQuery:i,showArchived:s,sessionStatus:a,isScrolling:l,onScroll:o,onSelectSession:c,onNewSessionForFolder:d}=e;return(0,r.Y)("div",{onScroll:o,className:`flex-1 scrollbar-overlay-container p-2 space-y-4 ${(0,et.p)(l)}`,children:0===t.length?(0,r.Y)("div",{className:"text-center py-8 text-xs text-ink/40",children:i?"No results found.":"No workspaces available."}):t.map(e=>(0,r.Y)(ee,{folder:e,activeSessionId:n,onSelectSession:c,onNewSessionForFolder:d,forceExpanded:!!i,showArchived:s,sessionStatus:a},e.id))})}let er=[3,2];function ei(){return(0,r.Y)("div",{className:"flex-1 p-2 space-y-4","aria-hidden":"true",children:er.map((e,t)=>(0,r.FD)("div",{className:"space-y-1.5",children:[(0,r.FD)("div",{className:"flex items-center gap-2 px-1 py-1.5",children:[(0,r.Y)("span",{className:"w-3.5 h-3.5 rounded-sm animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-3 w-24 rounded animate-pulse bg-ink/10"})]}),Array.from({length:e},(e,t)=>(0,r.FD)("div",{className:"flex items-center gap-2 rounded px-2 py-1.5",children:[(0,r.Y)("span",{className:"w-4 h-4 rounded-full animate-pulse bg-ink/10"}),(0,r.Y)("span",{className:"h-3 rounded animate-pulse bg-ink/10",style:{width:`${58-t%3*12}%`}})]},t))]},t))})}var es=n("wu"),ea=n("wm"),el=n("oZ"),eo=n("DO"),ec=n("z4");function ed(e){let{className:t="",onClose:n,appSettings:i={}}=e,{folders:a,initializing:o,refresh:c,activeSessionId:d,sessionParam:u,searchQuery:p,setSearchQuery:m,showArchived:f,setShowArchived:g,optionsOpen:b,setOptionsOpen:v,sortOption:k,handleSortChange:y,processedFolders:w,sessionStatus:N,handleSelectSession:Y}=(0,ec.K)(i,{includePendingSessions:!0}),[,D]=(0,l.o)(),[A,S]=(0,s.J0)(!1),[T,z]=(0,s.J0)(!1),[$,j]=(0,s.J0)(!1),[L,M]=(0,s.J0)(!1),P=(0,eo.M)(),{toasts:E,pushToast:R,dismissToast:I}=(0,el.Y)(),[O,J]=(0,s.J0)(!1),{isScrolling:_,handleScroll:W}=(0,et.K)(),K=e=>{let t=(0,ea.l)(a,u,e);t&&(0,ea.r)(t,i.omp_access_mode)};return(0,r.FD)(r.FK,{children:[(0,r.FD)("aside",{className:`flex flex-col bg-paper h-full ${t}`,children:[(0,r.Y)(x,{onNewSession:()=>{K(),D(e=>{let t=e.get("sessionId"),n=new URLSearchParams(e);if(n.set("sessionId",`new-${Date.now()}`),t){let e=a.find(e=>e.sessions?.some(e=>String(e.id)===String(t)));e&&n.set("folderId",e.id.toString())}else n.delete("folderId");return n},{replace:!0})}}),(0,r.Y)(F,{isSearchVisible:O,searchQuery:p,showArchived:f,optionsOpen:b,sortOption:k,onToggleSearch:()=>J(!O),onSearchChange:m,onToggleArchived:()=>g(!f),onHideArchived:()=>g(!1),onToggleOptions:()=>v(!b),onCloseOptions:()=>v(!1),onSortChange:y,onNewWorkspace:()=>j(!0),onScheduler:()=>M(!0),onRefresh:c,onClose:n}),o?(0,r.Y)(ei,{}):(0,r.Y)(en,{folders:w,activeSessionId:d,searchQuery:p,showArchived:f,sessionStatus:N,isScrolling:_,onScroll:W,onSelectSession:Y,onNewSessionForFolder:e=>{K(e),D(t=>{let n=new URLSearchParams(t);return n.set("sessionId",`new-${Date.now()}`),n.set("folderId",e.toString()),n},{replace:!0})}}),(0,r.Y)(C,{onSettings:()=>S(!0),onInfo:()=>z(!0),updateAvailable:P.hasUpdate,onUpdateClick:()=>{z(!0),P.check()}})]}),(0,r.Y)(h.bB,{isOpen:A,onClose:()=>S(!1),appSettings:i}),(0,r.Y)(h.VT,{isOpen:T,onClose:()=>z(!1),updates:P,onToast:R}),(0,r.Y)(h.xV,{isOpen:$,onClose:()=>j(!1),onCreate:async e=>{let{name:t,path:n}=e,r=await fetch("/api/folders",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:t,path:n})}),i=await r.json().catch(()=>({}));if(!r.ok||!i.success)throw Error(i.error||`HTTP ${r.status}`);window.location.reload()}}),(0,r.Y)(h.Lo,{isOpen:L,onClose:()=>M(!1)}),(0,r.Y)(es.y,{toasts:E,onDismiss:I})]})}var eu=n("ET"),ep=n("u"),em=n("zI"),eh=n("Gb"),ef=n("FL"),ex=n("As"),eg=n("NO"),eb=n("f"),ev=n("b5"),ek=n("Pf"),ey=n("se"),ew=n("tC");let eN=()=>{let{isInstallable:e,isInstalled:t,isIOS:n,install:i}=function(){let[e,t]=(0,s.J0)(null),[n,r]=(0,s.J0)(!1),[i,a]=(0,s.J0)(!1);(0,s.vJ)(()=>{r(window.matchMedia("(display-mode: standalone)").matches||!0===window.navigator.standalone);let e=window.navigator.userAgent.toLowerCase();a(/iphone|ipad|ipod/.test(e));let n=e=>{e.preventDefault(),t(e)},i=()=>{r(!0),t(null)};return window.addEventListener("beforeinstallprompt",n),window.addEventListener("appinstalled",i),()=>{window.removeEventListener("beforeinstallprompt",n),window.removeEventListener("appinstalled",i)}},[]);let l=async()=>{if(!e)return!1;await e.prompt();let{outcome:n}=await e.userChoice;return"accepted"===n&&(r(!0),t(null),!0)};return{isInstallable:!!e,isInstalled:n,isIOS:i,install:l}}(),[a,l]=(0,s.J0)(!1);return t?null:e?(0,r.Y)("button",{onClick:i,className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink",title:"Install OMPChamber",children:(0,r.Y)(ew.A,{size:16})}):n?(0,r.FD)(r.FK,{children:[(0,r.Y)("button",{onClick:()=>l(!0),className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink",title:"Install on iOS",children:(0,r.Y)(ew.A,{size:16})}),a&&(0,r.Y)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20 p-4",children:(0,r.FD)("div",{className:"w-full max-w-sm rounded bg-paper border border-ink/10 p-6 shadow-xl text-ink",children:[(0,r.Y)("h3",{className:"text-sm font-semibold",children:"Install on iPhone / iPad"}),(0,r.FD)("p",{className:"mt-2 text-xs opacity-80",children:["1. Tap the ",(0,r.Y)("strong",{children:"Share"})," button in Safari toolbar.",(0,r.Y)("br",{}),"2. Scroll down and tap ",(0,r.Y)("strong",{children:"Add to Home Screen"}),"."]}),(0,r.Y)("button",{onClick:()=>l(!1),className:"mt-4 w-full rounded bg-ink text-canvas py-2 text-xs font-semibold hover:bg-ink/90",children:"Close"})]})})]}):null};var eY=n("R2");function eD(e){let{sessionTitle:t,showLeftPanel:n,showEditor:i,showRightPanel:s,streamStatus:a,onSwitchToMobile:l,onToggleEditor:o,onToggleRightPanel:c}=e;return(0,r.FD)("header",{className:"h-12 flex-shrink-0 border-b border-ink/10 bg-paper flex items-center justify-between pr-4 z-20 titlebar-drag-region select-none",style:{paddingLeft:n?void 0:"max(1rem, env(titlebar-area-x, 0px))",paddingRight:"max(1rem, calc(100vw - env(titlebar-area-width, 100vw)))"},children:[(0,r.FD)("div",{className:"flex items-center space-x-2 px-4 min-w-0",children:[!n&&(0,r.FD)(r.FK,{children:[(0,r.FD)("span",{className:"font-bold text-sm tracking-tight hidden sm:flex items-center flex-shrink-0",children:[(0,r.Y)("span",{className:"text-transparent bg-clip-text bg-gradient-to-r from-orange-600 to-amber-500 font-extrabold text-[15px] tracking-tighter",children:"OMP"}),(0,r.Y)("span",{className:"ml-[1px]",children:"Chamber"})]}),t&&(0,r.Y)("span",{className:"text-ink/30 text-xs select-none flex-shrink-0",children:"/"})]}),t&&(0,r.FD)("div",{className:"flex items-center space-x-2 titlebar-no-drag",children:[(0,r.Y)("span",{className:"font-bold text-sm tracking-tight hidden sm:flex items-center",children:(0,r.Y)("span",{className:"font-semibold text-xs text-ink truncate",children:t.charAt(0).toUpperCase()+t.slice(1)})}),(0,r.Y)(w.A,{size:14,className:"text-ink/40 hover:text-ink cursor-pointer flex-shrink-0"})]})]}),(0,r.Y)("div",{className:"flex items-center space-x-3 titlebar-no-drag",children:(0,r.FD)("div",{className:"flex items-center space-x-1",children:[(0,r.Y)(eY.c,{status:a}),l&&(0,r.Y)("button",{type:"button",onClick:l,className:"p-1.5 rounded hover:bg-ink/10 transition-colors text-ink/60 hover:text-ink cursor-pointer",title:"Switch to Mobile View",children:(0,r.Y)(eb.A,{size:16})}),(0,r.Y)(eN,{}),(0,r.Y)("button",{type:"button",onClick:o,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${i?"text-ink":"text-ink/40"}`,title:"Toggle Editor Layout",children:(0,r.Y)(ev.A,{size:16})}),(0,r.Y)("button",{type:"button",onClick:c,className:`p-1.5 rounded hover:bg-ink/10 transition-colors cursor-pointer ${s?"text-ink":"text-ink/40"}`,title:"Toggle Right Panel",children:s?(0,r.Y)(ek.A,{size:16}):(0,r.Y)(ey.A,{size:16})})]})})]})}var eF=n("j5"),eA=n("nG"),eS=n("oE"),eC=n("Asb"),eT=n("vZ"),ez=n("N"),e$=n("Oj"),ej=n("lW"),eL=n("SJ"),eM=n("so");let eP={context:{title:"Context & Telemetry",icon:(0,r.Y)(eS.A,{size:16})},files:{title:"Files",icon:(0,r.Y)(eC.A,{size:16})},search:{title:"Search",icon:(0,r.Y)(k.A,{size:16})},git:{title:"Source Control",icon:(0,r.Y)(eT.A,{size:16})},terminal:{title:"Terminal (Bun)",icon:(0,r.Y)(ez.A,{size:16})},"user-browser":{title:"Browser (Anda)",icon:(0,r.Y)(e$.A,{size:16})},browser:{title:"Browser Agent",icon:(0,r.Y)(ej.A,{size:16})},usage:{title:"Usage",icon:(0,r.Y)(eL.A,{size:16})}};function eE(e){let{activePanel:t,onChangePanel:n,isPanelOpen:i,hasActiveContext:s,activeProjectPath:a,refreshKey:l}=e,{changes:o}=(0,eM.e)(a??void 0,".",l,s,15e3),c=o.length>0;return(0,r.FD)("nav",{className:"w-12 flex-shrink-0 border-l border-ink/10 bg-paper flex flex-col items-center py-3 space-y-2 z-10",children:[(0,r.Y)("div",{className:"flex flex-col items-center space-y-1 w-full",children:eu.G7.map(e=>{let s=i&&t===e;return(0,r.FD)("button",{className:`relative w-full h-10 flex items-center justify-center transition-colors border-l-2 ${s?"text-ink border-ink bg-ink/5":"text-ink/40 border-transparent hover:text-ink hover:bg-ink/5"}`,onClick:()=>n(e),title:eP[e].title,children:[eP[e].icon,"git"===e&&c&&(0,r.Y)("span",{className:"absolute top-1.5 right-1.5 w-1.5 h-1.5 rounded-full bg-info",title:"Ada perubahan git"})]},e)})}),(0,r.Y)("div",{className:"flex-1"})]})}function eR(){return(0,r.Y)(m,{className:"relative w-1 outline-none group flex justify-center cursor-col-resize z-10",children:(0,r.Y)("div",{className:"h-full w-[1px] bg-ink/10 group-hover:bg-ink/40 group-active:bg-ink/60 group-hover:w-0.5 transition-all"})})}let eI={left:268,editor:600,diff:720};function eO(e){return"number"==typeof e&&Number.isFinite(e)&&e>0?Math.round(e):void 0}let eJ=(0,a.RZ)(()=>Promise.all([n.e("uf"),n.e("mw"),n.e("q")]).then(n.bind(n,"o3")).then(e=>({default:e.Editor})));function e_(e){let{children:t}=e;return(0,r.Y)(a.tY,{fallback:(0,r.Y)("div",{className:"w-full h-full flex items-center justify-center text-ink/40 text-xs",children:"Loading…"}),children:t})}function eW(e){let{appSettings:t,showEditor:n,editorPanelRef:i,showRightPanel:a,activeRightPanel:l,rightPanelRef:o,panelWidths:c,editorWidthMode:d,hasActiveContext:m,activeProjectPath:h,openedFiles:f,activeFileId:x,refreshKey:g,onSetActiveFileId:b,onCloseFile:v,onOpenFile:k,onRefreshWorkspace:y,onChangeRightPanel:w,onToggleRightPanel:N,onSessionTitle:Y,onPanelWidths:D}=e;(0,s.li)(c).current=c;let F=(0,s.Kr)(()=>({}),[]),A=(0,s.Kr)(()=>eu.G7.map(e=>({view:e,Comp:(0,eA.SU)(F,e)})),[F]);return(0,r.FD)("div",{className:"flex flex-1 overflow-hidden",children:[(0,r.FD)(u,{orientation:"horizontal",id:"ompchamber-layout",onLayoutChanged:()=>{let e,t,n;D((e={},t=i.current?.getSize()?.inPixels,n=o.current?.getSize()?.inPixels,null!=t&&t>0&&(e[d]=Math.round(t)),null!=n&&n>0&&(e.right={[l]:Math.round(n)}),e))},children:[(0,r.Y)(p,{id:"center-panel",filler:!0,minSize:420,children:(0,r.Y)(eF.E,{className:"w-full h-full",appSettings:t,onSessionTitle:Y})}),n&&(0,r.FD)(r.FK,{children:[(0,r.Y)(eR,{}),(0,r.Y)(p,{panelRef:i,id:"editor-panel",defaultSize:c[d]??eI[d],minSize:300,maxSize:1200,children:(0,r.Y)(e_,{children:(0,r.Y)(eJ,{className:"w-full h-full",openedFiles:f,activeFileId:x,onSelectFile:b,onCloseFile:v,refreshKey:g,onFileSaved:y})})})]}),a&&(0,r.FD)(r.FK,{children:[(0,r.Y)(eR,{}),(0,r.Y)(p,{panelRef:o,id:"right-panel",defaultSize:c.right?.[l]??eu.qv[l],minSize:eu.lw[l],maxSize:1200,collapsible:!0,children:(0,r.Y)(e_,{children:A.map(e=>{let{view:t,Comp:n}=e,i=l===t;return(0,r.Y)("div",{className:i?"w-full h-full":"hidden",children:(0,r.Y)(n,{className:"w-full h-full",enabled:"terminal"===t?m:m&&i,active:i,refreshKey:g,rootPath:h??void 0,onRefresh:y,onOpenFile:k,onClose:N})},t)})})})]})]}),(0,r.Y)(eE,{activePanel:l,onChangePanel:w,isPanelOpen:a,hasActiveContext:m,activeProjectPath:h,refreshKey:g})]})}var eK=n("FE");function eU(e,t){null!=t&&e.current?.resize(t)}function eH(e){let{sessionId:t,onSwitchToMobile:n,appSettings:i={}}=e,{folders:a}=(0,X.k)(),[o,c]=(0,ef.bL)("layout.showRightPanel",i.showRightPanel??!0),[d,m]=(0,ef.bL)("layout.activeRightPanel",i.activeRightPanel??"files"),[h,f]=(0,s.J0)(i.showLeftPanel??!0),{widths:x,widthsRef:g,commitWidths:b}=function(e,t){let[n,r]=(0,s.J0)(()=>(function(e,t){if(!e||"object"!=typeof e)return{};let n={};for(let t of["left","editor","diff"]){let r=eO(e[t]);void 0!==r&&(n[t]=r)}let r={};if(e.right&&"object"==typeof e.right)for(let[t,n]of Object.entries(e.right)){if(!(0,eu.ls)(t))continue;let e=eO(n);void 0!==e&&(r[t]=e)}else{let n=eO(e.right);void 0!==n&&(r[t]=n)}return Object.keys(r).length>0&&(n.right=r),n})(e.desktopLayoutSizes,t)),i=(0,s.li)(n),a=(0,s.li)(void 0),l=(0,s.hb)(()=>{clearTimeout(a.current),a.current=void 0,(0,V.cz)("desktopLayoutSizes",i.current)},[]),o=(0,s.hb)(e=>{var t;let n,s=(t=i.current,n={...t,...e},e.right&&(n.right={...t.right,...e.right}),n);i.current=s,r(s),clearTimeout(a.current),a.current=window.setTimeout(l,500)},[l]);return(0,s.vJ)(()=>()=>{void 0!==a.current&&l()},[l]),{widths:n,widthsRef:i,commitWidths:o}}(i,d),v=(0,s.li)(null),k=(0,s.li)(null),y=(0,s.li)(null),[w,N]=(0,s.J0)(i.userToggledEditor??null),[Y]=(0,l.o)(),D=Y.get("folderId"),F=(0,s.Kr)(()=>{let e=(0,eh.t)(a,t||"").folder;return e||(D?a.find(e=>String(e.id)===String(D))??null:null)},[a,t,D]),A=F?.project_path??null,S=!!F,{openedFiles:C,activeFileId:T,setActiveFileId:z,handleOpenFile:$,handleCloseFile:j}=function(e,t,n){let[r,i]=(0,ef.bL)("layout.openedFiles",[]),[a,l]=(0,ef.bL)("layout.activeFileId",null),o=(0,s.li)(void 0),{ready:c}=(0,ex.O)(),d=(0,s.li)(void 0);(0,s.vJ)(()=>{o.current===e||(o.current=e,c&&d.current!==e&&(d.current=e,i([]),l(null)))},[e,t,c,i,l]);let u=(0,s.hb)(t=>{let r={...t,root:t.root??e??void 0};i(e=>{let t=e.find(e=>e.id===r.id||!e.isDiff&&e.path&&r.path&&e.path===r.path);return t?(l(t.id),e):[...e,r]}),l(r.id),n?.()},[e,n,i,l]),p=(0,s.hb)(t=>{let r=t.file.replace(/^\/+/,""),s=r.split("/").pop()||r,a=!!t.staged,o=`diff-${a?"staged":"working"}-${r}`,c={id:o,name:`${s} (Diff)`,path:r,isDiff:!0,diffStatus:t.status||"M",diffStaged:a,repo:t.repo||".",root:t.root??e??void 0};i(e=>{let t=e.find(e=>e.id===o||e.isDiff&&e.path===r&&e.diffStaged===a);return t?(l(t.id),e):[...e,c]}),l(o),n?.()},[e,n,i,l]),m=(0,s.hb)(e=>{i(t=>{let n=t.filter(t=>t.id!==e);return a===e&&l(n.length>0?n[n.length-1].id:null),n})},[a,i,l]);return(0,eg.sY)("omp:open-file",e=>{if(!e.detail||!e.detail.path)return;let t=e.detail.path.replace(/^\/+/,""),n=e.detail.name||t.split("/").pop()||"file",r=0;for(let e=0;e<t.length;e++)r=(r<<5)-r+t.charCodeAt(e)|0;u({id:e.detail.id||Math.abs(r)||Date.now(),name:n,path:t,content:e.detail.content})}),(0,eg.sY)("omp:open-diff",e=>{e.detail&&e.detail.file&&p(e.detail)}),{openedFiles:r,activeFileId:a,setActiveFileId:l,handleOpenFile:u,handleOpenDiff:p,handleCloseFile:m}}(A,t||"",(0,s.hb)(()=>{N(!0),P("userToggledEditor",!0)},[])),L=C.length>0&&(w??!0),M=(0,s.Kr)(()=>C.find(e=>String(e.id)===String(T))?.isDiff?"diff":"editor",[C,T]),P=(e,t)=>{(0,V.cz)(e,t)};(0,s.vJ)(()=>{let e=requestAnimationFrame(()=>{let e=g.current;e&&eU(y,e.left)});return()=>cancelAnimationFrame(e)},[h,g]),(0,s.vJ)(()=>{let e=requestAnimationFrame(()=>{eU(k,g.current?.right?.[d]??eu.qv[d])});return()=>cancelAnimationFrame(e)},[o,d,g]),(0,s.vJ)(()=>{let e=requestAnimationFrame(()=>{eU(v,g.current?.[M]??eI[M])});return()=>cancelAnimationFrame(e)},[L,M,g]);let[E,R]=(0,s.J0)(!1),[I,O]=(0,s.J0)("appearance"),[J,_]=(0,s.J0)(!1),[W,K]=(0,s.J0)(0),[U,H]=(0,s.J0)(null),B=(0,eK.H)();(0,eg.MN)("keydown",e=>{(e.metaKey||e.ctrlKey)&&","===e.key&&(e.preventDefault(),O("appearance"),_(!1),R(e=>!e))}),(0,eg.sY)("omp:open-settings",e=>{e.detail?.category?O(e.detail.category):O("appearance"),_(!!e.detail?.autoOpenAdd),R(!0)});let q=e=>{f(e),P("showLeftPanel",e)},G=()=>{let e=!o;c(e),P("showRightPanel",e)};return(0,r.FD)("div",{className:"flex flex-col h-screen w-screen overflow-hidden bg-canvas text-ink font-sans selection:bg-ink selection:text-canvas",children:[(0,r.FD)("div",{className:"flex flex-1 overflow-hidden",children:[!h&&(0,r.FD)("div",{className:"w-12 h-full bg-paper border-r border-ink/10 flex flex-col items-center py-3 flex-shrink-0 cursor-pointer hover:bg-ink/5 transition-colors titlebar-no-drag",style:{paddingTop:"max(0.75rem, env(titlebar-area-height, 0px))"},onClick:()=>q(!0),title:"Expand Sidebar",children:[(0,r.Y)(em.A,{size:16,className:"text-ink/60"}),(0,r.Y)("div",{className:"w-[1px] flex-1 bg-ink/10 my-4"})]}),(0,r.FD)(u,{orientation:"horizontal",id:"ompchamber-main",onLayoutChanged:()=>{let e=y.current?.getSize()?.inPixels;null!=e&&e>0&&b({left:Math.round(e)})},children:[h&&(0,r.FD)(r.FK,{children:[(0,r.Y)(p,{panelRef:y,id:"left-panel",defaultSize:x.left??eI.left,minSize:200,maxSize:520,collapsible:!0,children:(0,r.Y)(ed,{className:"w-full h-full",onClose:()=>q(!1),appSettings:i})}),(0,r.Y)(eR,{})]}),(0,r.Y)(p,{id:"main-right-stack",filler:!0,minSize:0,children:(0,r.FD)("div",{className:"flex flex-col h-full",children:[(0,r.Y)(eD,{sessionTitle:U,showLeftPanel:h,showEditor:L,showRightPanel:o,streamStatus:B,onSwitchToMobile:n,onToggleEditor:()=>{let e=!L;N(e),P("userToggledEditor",e)},onToggleRightPanel:G}),(0,r.Y)(eW,{appSettings:i,showEditor:L,editorPanelRef:v,showRightPanel:o,activeRightPanel:d,rightPanelRef:k,panelWidths:x,editorWidthMode:M,hasActiveContext:S,activeProjectPath:A,openedFiles:C,activeFileId:T,refreshKey:W,onSetActiveFileId:z,onCloseFile:j,onOpenFile:$,onRefreshWorkspace:()=>K(e=>e+1),onChangeRightPanel:e=>{let t=o,n=d;d===e&&o?t=!1:(n=e,t=!0),c(t),m(n),(0,V.cz)("showRightPanel",t),(0,V.cz)("activeRightPanel",n)},onToggleRightPanel:G,onSessionTitle:H,onPanelWidths:b})]})})]})]}),(0,r.Y)(ep.b,{isOpen:E,onClose:()=>{R(!1),_(!1)},initialCategory:I,autoOpenAddProvider:J,appSettings:i})]})}var eB=n("SS");function eq(e){let{sessionId:t,children:n}=e,i=t||"1",[a,l]=(0,s.J0)(!1),o=(0,s.li)(null);(0,s.vJ)(()=>{let e=o.current;if(o.current=i,e!==i){if((0,eB.Y1)(i),e&&e.startsWith("new-")&&!i.startsWith("new-")){(0,eB.vy)(e,i),l(!0);return}if(i.startsWith("new-")){(0,eB.l5)(i),l(!0);return}l(!1),(0,eB.D4)(e).then(()=>(0,eB.L6)(i)).then(()=>{o.current===i&&l(!0)})}},[i]);let c=(0,s.Kr)(()=>({sessionId:i,ready:a}),[i,a]);return(0,r.Y)(ex.b.Provider,{value:c,children:n})}let eG=(0,a.RZ)(()=>Promise.all([n.e("uf"),n.e("mw"),n.e("g")]).then(n.bind(n,"Wh")).then(e=>({default:e.MobileLayoutWrapper})));var eV=n("eh");let eZ=document.getElementById("app"),eQ=window.__OMP_BOOTSTRAP__;(0,V.x9)(eQ?.appSettings),(0,eV.iv)(),eZ&&(0,i.Qv)((0,r.Y)(function(e){let{initialIsMobile:t=!1,appSettings:n={}}=e,[i]=(0,l.o)(),o=i.get("sessionId")||"1",[c,d]=(0,s.J0)(t),u=(0,s.li)(!1);return((0,s.vJ)(()=>{let e=()=>{let e=window.innerWidth<768,t=window.matchMedia("(pointer: coarse)").matches,n=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(navigator.userAgent),r=t&&window.innerHeight<550&&window.innerWidth<1024;return e||n||r};u.current||d(e());let t=()=>{u.current||d(e())};return window.addEventListener("resize",t),window.addEventListener("orientationchange",t),()=>{window.removeEventListener("resize",t),window.removeEventListener("orientationchange",t)}},[]),c)?(0,r.Y)(eq,{sessionId:o,children:(0,r.Y)(X.O,{children:(0,r.Y)(a.tY,{fallback:null,children:(0,r.Y)(eG,{onDesktopToggle:()=>{u.current=!0,d(!1)},appSettings:n})})})}):(0,r.Y)(eq,{sessionId:o,children:(0,r.Y)(X.O,{children:(0,r.Y)(eH,{sessionId:o,onSwitchToMobile:()=>{u.current=!0,d(!0)},appSettings:n})})})},{initialIsMobile:eQ?.initialIsMobile,appSettings:eQ?.appSettings}),eZ)},Fb(e,t,n){let r="omp:browser-include-page";function i(e){"u">typeof window&&window.dispatchEvent(new CustomEvent(r,{detail:e}))}n.d(t,{q:()=>i},{j:r})},ns(e,t,n){let r="agent",i="command",s=new Map,a=new Map;async function l(e){let t=await fetch(e);if(!t.ok)throw Error(`GET ${e} failed: ${t.status}`);let n=await t.json();if(!n||"object"!=typeof n)throw Error(`GET ${e} returned malformed JSON`);return n}async function o(){let e=s.get(r);if(e&&e.expiresAt>Date.now())return e.data;let t=a.get(r);if(t)return t;let n=(async()=>{try{let e=(await l("/api/settings/agents")).agents.map(e=>({id:`agent-${e.name}`,name:e.name,description:e.description,kind:"agent",source:"agent",token:`@${e.name}`}));return s.set(r,{data:e,expiresAt:Date.now()+3e5}),e}finally{a.delete(r)}})();return a.set(r,n),n}async function c(e){let t,n=(t=e??"",`file::${t}`),r=s.get(n);if(r&&r.expiresAt>Date.now())return r.data;let i=a.get(n);if(i)return i;let o=(async()=>{try{let t=e?`?root=${encodeURIComponent(e)}`:"",r=await l(`/api/fs/list${t}`),i=(Array.isArray(r.files)?r.files:[]).map(e=>({id:`file-${e.path}`,name:e.path,description:"",kind:"file",source:"file",token:/\s/.test(e.path)?`@"file:${e.path}"`:`@file:${e.path}`,path:e.path}));return s.set(n,{data:i,expiresAt:Date.now()+3e5}),i}catch{return[]}finally{a.delete(n)}})();return a.set(n,o),o}async function d(){let e=s.get(i);if(e&&e.expiresAt>Date.now())return e.data;let t=a.get(i);if(t)return t;let n=(async()=>{try{let[e,t]=await Promise.all([l("/api/settings/commands"),l("/api/settings/skills")]),n=function(e,t){let n=[],r=new Set;for(let t of e){let e=t.name.toLowerCase();r.has(e)||(r.add(e),n.push({id:`command-${t.name}`,name:t.name,description:t.description,kind:"command",source:"command",token:`/${t.name}`}))}for(let e of t){let t=e.name.toLowerCase(),i=`skill:${t}`;r.has(t)||r.has(i)||(r.add(i),n.push({id:`skill-${e.name}`,name:e.name,description:e.description,kind:"command",source:"skill",token:`/skill:${e.name}`}))}return n}(e.commands,t.skills);return s.set(i,{data:n,expiresAt:Date.now()+3e5}),n}finally{a.delete(i)}})();return a.set(i,n),n}function u(e,t){return"mention"===e?Promise.all([o(),c(t??null)]).then(e=>{let[t,n]=e;return[...t,...n]}):d()}async function p(){try{return(await o()).map(e=>e.name)}catch{return[]}}function m(e){if(e){s.delete(e),a.delete(e);return}s.clear(),a.clear()}n.d(t,{O7:()=>p,SA:()=>m,bF:()=>u})},Kc(e,t,n){var r=n("oS"),i=n("zG");let s={edit:!0,write:!0,ast_edit:!0,bash:!0};function a(e){let t="string"==typeof e.toolName?e.toolName.toLowerCase():"",n=i.YT[t]??t;if(!s[n])return!1;let a=(0,r.u)(e.args)?e.args:{},l=(0,i.oJ)(a.path)??(0,i.oJ)(a.target);return!("write"===n&&"string"==typeof l&&l.startsWith("xd://"))}n.d(t,{Y:()=>a},{s:"omp:files-mutated"})},g0(e,t,n){var r=n("Kn");let i="omp:stream-status",s={transport:(0,r.ul)(),connected:!1};function a(){return s}function l(e){e.transport===s.transport&&e.connected===s.connected||(s=e,"u">typeof window&&window.dispatchEvent(new CustomEvent(i,{detail:e})))}n.d(t,{aK:()=>a,dX:()=>l},{rt:i})},Kn(e,t,n){var r=n("So");function i(e){let t="https:"===window.location.protocol?"wss:":"ws:";return`${t}//${window.location.host}/api/agent/${encodeURIComponent(e)}/ws`}function s(e){return`/api/agent/${encodeURIComponent(e)}/events`}function a(e){let t=(0,r.BF)("streamTransport",e);return"sse"===t||"websocket"===t?t:"websocket"}n.d(t,{_m:()=>s,qq:()=>i,ul:()=>a})},G1(e,t,n){function r(e,t){let n=function(e){let t=e.trim();if(!t)return null;let n="message",r=[];for(let e of t.split("\n"))!e.startsWith(":")&&(e.startsWith("event:")?n=e.replace(/^event:\s*/,"").trim():e.startsWith("data:")&&r.push(e.replace(/^data:\s*/,"")));return 0===r.length?null:{event:n,data:r.join("\n")}}(e);return!!n&&!0===t(n.event,n.data)}async function i(e,t,n){let i=e.body?.getReader();if(!i)return;let s=new TextDecoder("utf-8"),a="";try{for(;;){if(n?.aborted){try{await i.cancel()}catch{}return}let{done:e,value:l}=await i.read();if(e)break;let o=(a+=s.decode(l,{stream:!0})).split("\n\n");for(let e of(a=o.pop()??"",o))if(r(e,t))return}a&&r(a,t)}finally{try{i.releaseLock()}catch{}}}n.d(t,{o:()=>i})},zG(e,t,n){var r=n("oS"),i=n("e");function s(e){if("string"!=typeof e)return;let t=e.trim();return t.length>0?t:void 0}function a(e,t){for(let n of t){let t=e[n],r=s(t);if(r)return r;if(Array.isArray(t)){let e=t.find(e=>void 0!==s(e));if(void 0!==e)return s(e)}}}function l(e){return e.length<=72?e:`${e.slice(0,71)}…`}function o(e){if(e)return/^["'`]/.test(e)?e:`"${e}"`}function c(e,t){switch(e){case"read":case"write":case"edit":return a(t,["path","file","AbsolutePath","TargetFile"])??(0,i.f$)(t);case"ast_edit":return a(t,["paths","path"]);case"ast_grep":{let e=o(a(t,["pat"]));return e?`for ${e}`:void 0}case"bash":return a(t,["command","cmd","CommandLine"]);case"grep":{let e=a(t,["pattern"]),n=a(t,["path","paths"]);if(!e)return n;return n?`for ${o(e)} in ${n}`:`for ${o(e)}`}case"glob":return a(t,["path","pattern"]);case"web_search":{let e=o(a(t,["query"]));return e?`for ${e}`:void 0}case"task":let n,l,c,d;return n=s(t.name),l=(Array.isArray(t.tasks)?t.tasks:[]).find(r.u),c=n??(l?s(l.name):void 0),d=s(t.agent)??(l?s(l.agent):void 0),c&&d?`to ${c} (${d})`:c?`to ${c}`:d?`to ${d}`:void 0;case"hub":return[a(t,["op"]),a(t,["name"])].filter(Boolean).join(" ")||void 0;case"todo":{let e=a(t,["op"]);return e?`\xb7 ${e}`:void 0}case"eval":{let e=a(t,["language"]);return e?`in ${e}`:void 0}case"lsp":return[a(t,["action"]),a(t,["symbol","file"])].filter(Boolean).join(" ")||void 0;case"debug":return a(t,["action","program"]);case"github":return[a(t,["op"]),a(t,["repo","pr","query"])].filter(Boolean).join(" ")||void 0;case"ask":let u=(Array.isArray(t.questions)?t.questions:[]).find(r.u);if(u)return s(u.header)??s(u.question);return;case"checkpoint":return a(t,["goal"]);case"manage_skill":return a(t,["name"]);case"recall":return o(a(t,["query"]));case"reflect":{let e=o(a(t,["query"]));return e?`on ${e}`:void 0}case"security_scan":return a(t,["target_kind","include_paths"]);case"retain":let p;return(p=(Array.isArray(t.items)?t.items:[]).find(r.u))?o(s(p.content)):void 0;default:return a(t,["path","command","query","pattern","name","target","prose"])}}n.d(t,{Up:()=>a,oJ:()=>s,qL:()=>c,xv:()=>l},{K$:{read:"Reading",write:"Writing",edit:"Editing",ast_edit:"Rewriting AST",ast_grep:"Searching AST",bash:"Running",grep:"Searching",glob:"Finding",task:"Delegating",todo:"Updating plan",hub:"Hub",eval:"Running code",lsp:"Running LSP",debug:"Debugging",github:"GitHub",web_search:"Searching the web",ask:"Asking you",checkpoint:"Checkpointing",rewind:"Rewinding",context_notes:"Updating context notes",new_context:"Starting a fresh context",security_scan:"Scanning for vulnerabilities",manage_skill:"Updating skill",learn:"Recording a lesson",retain:"Retaining memory",recall:"Recalling memory",reflect:"Reflecting",think:"Thinking",yield:"Wrapping up",goal:"Tracking goal"},Qq:{lsp:"Running LSP",ast_edit:"Rewriting AST",ast_grep:"Searching AST",resolve:"Applying edit proposal",reject:"Discarding edit proposal",report_issue:"Reporting tool issue",debug:"Debugging",browser:"Driving the browser"},YT:{read_file:"read",view_file:"read",read_file_content:"read",edit_file:"edit",replace_file_content:"edit",multi_edit_file:"edit",write_to_file:"write",create_file:"write",search_fs:"grep",terminal:"bash",run_command:"bash"},n1:{thinking:"Thinking",writing:"Writing response"}})},pm(e,t,n){var r=n("U8");function i(e){return(0,r.Rk)(e)}n.d(t,{F:()=>i})},eh(e,t,n){n.d(t,{iv:()=>w,tn:()=>v,F:()=>D,nv:()=>N,LT:()=>A,Eu:()=>Y,sT:()=>F});var r=n("CU"),i=n("he"),s=n("h3"),a=n("g1");let l={typescript:()=>n.e("zn").then(n.bind(n,"tt")),tsx:()=>n.e("ta").then(n.bind(n,"Xl")),javascript:()=>n.e("jsc").then(n.bind(n,"lK")),jsx:()=>n.e("px").then(n.bind(n,"rz")),json:()=>n.e("zj").then(n.bind(n,"BB")),markdown:()=>n.e("2v").then(n.bind(n,"sN")),css:()=>n.e("n").then(n.bind(n,"d2")),bash:()=>Promise.all([n.e(2),n.e(6)]).then(n.bind(n,"ks")),diff:()=>n.e("0w").then(n.bind(n,"SP")),yaml:()=>n.e("ho").then(n.bind(n,"n1")),html:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa")]).then(n.bind(n,"w1")),python:()=>n.e("jd").then(n.bind(n,"hE")),go:()=>n.e("cf").then(n.bind(n,"K1")),rust:()=>n.e("hk").then(n.bind(n,"nb")),sql:()=>n.e("r").then(n.bind(n,"le")),toml:()=>n.e("x0").then(n.bind(n,"DJ")),java:()=>n.e("f8").then(n.bind(n,"lj")),c:()=>n.e("4e").then(n.bind(n,"Gd")),cpp:()=>Promise.all([n.e("4e"),n.e("y6")]).then(n.bind(n,"gB")),csharp:()=>n.e("4k").then(n.bind(n,"Ku")),ruby:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("aa"),n.e("4e"),n.e("f8"),n.e("r"),n.e("ta"),n.e("y6"),n.e("px"),n.e(2),n.e("yv"),n.e("ct")]).then(n.bind(n,"eV")),php:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("f8"),n.e("r"),n.e(4)]).then(n.bind(n,"eZ")),kotlin:()=>n.e("7l").then(n.bind(n,"hR")),swift:()=>n.e(0).then(n.bind(n,"ep")),scala:()=>n.e("js").then(n.bind(n,"h3S")),lua:()=>Promise.all([n.e("4e"),n.e("hd")]).then(n.bind(n,"rF")),perl:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("f8"),n.e("r"),n.e("i")]).then(n.bind(n,"cr")),dockerfile:()=>n.e("b").then(n.bind(n,"BZ")),ini:()=>n.e("3p").then(n.bind(n,"BD")),properties:()=>n.e("1b").then(n.bind(n,"LU")),zig:()=>n.e("3u").then(n.bind(n,"p9")),elixir:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("aa"),n.e("jll")]).then(n.bind(n,"xu")),dart:()=>n.e("4q").then(n.bind(n,"Cu")),ocaml:()=>n.e("8j").then(n.bind(n,"uA")),haskell:()=>n.e("a").then(n.bind(n,"IX")),nix:()=>n.e("p").then(n.bind(n,"jG")),hcl:()=>n.e("yq").then(n.bind(n,"ka")),graphql:()=>Promise.all([n.e("jsc"),n.e("zn"),n.e("ta"),n.e("px"),n.e("yv")]).then(n.bind(n,"ok")),solidity:()=>n.e("w").then(n.bind(n,"me")),r:()=>n.e(37).then(n.bind(n,"pO")),julia:()=>Promise.all([n.e("jsc"),n.e("4e"),n.e("r"),n.e("y6"),n.e("jd"),n.e("t9")]).then(n.bind(n,"zu")),erlang:()=>Promise.all([n.e("2v"),n.e("y")]).then(n.bind(n,"EY")),clojure:()=>n.e("3d").then(n.bind(n,"lF")),scheme:()=>n.e("az").then(n.bind(n,"wE")),racket:()=>n.e(8).then(n.bind(n,"aB")),protobuf:()=>n.e("1p").then(n.bind(n,"bT")),makefile:()=>n.e("d").then(n.bind(n,"nt")),powershell:()=>n.e("j").then(n.bind(n,"dQ")),json5:()=>n.e("bq").then(n.bind(n,"VH")),less:()=>n.e("c").then(n.bind(n,"it")),scss:()=>Promise.all([n.e("n"),n.e("x")]).then(n.bind(n,"DD")),sass:()=>n.e("zo").then(n.bind(n,"Bc")),stylus:()=>n.e("ky").then(n.bind(n,"uc")),"objective-c":()=>n.e(7).then(n.bind(n,"BG")),groovy:()=>n.e("7e").then(n.bind(n,"tf")),vue:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("aa"),n.e("zx")]).then(n.bind(n,"Z")),svelte:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("dp")]).then(n.bind(n,"jIY")),astro:()=>Promise.all([n.e("jsc"),n.e("n"),n.e("zn"),n.e("ta"),n.e("o")]).then(n.bind(n,"CuL")),xml:()=>Promise.all([n.e("f8"),n.e("da")]).then(n.bind(n,"rDW"))},o=["typescript","tsx","javascript","jsx","json","bash","python","markdown","yaml","diff"],c=new Map,d=new Set,u=new Set,p={text:!0,plain:!0,plaintext:!0,txt:!0,ansi:!0,none:!0};function m(e){return!0===p[e]||d.has(e)}function h(e,t){if(m(t))return Promise.resolve();let n=c.get(t);if(n)return n;let r=l[t];if(!r)return Promise.resolve();let i=e.loadLanguage(r).then(()=>{for(let e of(d.add(t),u))e()}).catch(()=>{}).finally(()=>{c.delete(t)});return c.set(t,i),i}async function f(e,t){await Promise.all(t.map(t=>h(e,t)))}let x=null,g=!1,b=new Set;function v(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function k(){if("u"<typeof window)return null;try{let e=await (0,r.tz)({themes:[s.A,a.A],langs:[],engine:(0,i.l)({forgiving:!0})});x=e,g=!0;let t=[...b];for(let e of(b.clear(),t))try{e()}catch{}return f(e,o),e}catch(e){return console.error("[shiki] highlighter boot failed",e),null}}let y=null;function w(){return y||(y=k()),y}function N(){return g}function Y(e){return g?(e(),()=>{}):(b.add(e),()=>{b.delete(e)})}function D(){return g?x:null}function F(e){return!!x&&(h(x,e),m(e))}let A=function(e){return u.add(e),()=>{u.delete(e)}}},DU(e,t,n){n.d(t,{sQ:()=>s,wY:()=>o,PH:()=>c,O9:()=>d,rw:()=>a,Bl:()=>function e(t){if(null==t)return{isValid:!1};if("object"==typeof t)try{let e=JSON.stringify(t,null,2),n=e.split("\n").length;return{isValid:!0,data:t,pretty:e,linesCount:n}}catch{return{isValid:!1}}if("string"!=typeof t)return{isValid:!1};let n=t.trim();if(!n)return{isValid:!1};let r=n.match(/^```(?:json)?\s*([\s\S]*?)\s*```$/i);r&&(n=r[1].trim());let i=n.match(/^(?:user\s+(?:selected|responded|answered|response)|response|result|output):\s*([\s\S]+)$/i);if(i){let e=i[1].trim();(e.startsWith("{")&&e.endsWith("}")||e.startsWith("[")&&e.endsWith("]"))&&(n=e)}if(n.startsWith('"')&&n.endsWith('"')||n.startsWith("'")&&n.endsWith("'"))try{let t=JSON.parse(n);if("object"==typeof t&&null!==t){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}if("string"==typeof t){let n=e(t);if(n.isValid)return n}}catch{}if(n.startsWith("{")||n.startsWith("["))try{let e=JSON.parse(n);if(null!==e&&"object"==typeof e){let t=JSON.stringify(e,null,2),n=t.split("\n").length;return{isValid:!0,data:e,pretty:t,linesCount:n}}}catch{}let s=n.indexOf("{"),a=n.lastIndexOf("}");if(-1!==s&&a>s){let e=n.slice(s,a+1);try{let t=JSON.parse(e);if(null!==t&&"object"==typeof t){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}}catch{}}let l=n.indexOf("["),o=n.lastIndexOf("]");if(-1!==l&&o>l){let e=n.slice(l,o+1);try{let t=JSON.parse(e);if(Array.isArray(t)){let e=JSON.stringify(t,null,2);return{isValid:!0,data:t,pretty:e,linesCount:e.split("\n").length}}}catch{}}return{isValid:!1}}});var r=n("eh");let i={light:"one-light",dark:"one-dark-pro"};function s(e){if(!e)return"javascript";let t=e.split("?")[0].split("#")[0].replace(/:\d+(?:-\d+)?$/,"");switch(t.split(".").pop()?.toLowerCase()){case"ts":return"typescript";case"tsx":return"tsx";case"js":case"mjs":case"cjs":default:return"javascript";case"jsx":return"jsx";case"json":return"json";case"md":case"markdown":return"markdown";case"css":return"css";case"sh":case"bash":case"zsh":case"env":return"bash";case"diff":case"patch":return"diff";case"yaml":case"yml":return"yaml";case"html":return"html";case"svg":case"xml":return"xml";case"py":return"python";case"go":return"go";case"rs":return"rust";case"sql":return"sql";case"toml":return"toml";case"java":return"java";case"c":case"h":return"c";case"cpp":case"cc":case"hpp":return"cpp";case"cs":return"csharp";case"rb":return"ruby";case"php":return"php";case"kt":case"kts":return"kotlin";case"swift":return"swift";case"scala":return"scala";case"lua":return"lua";case"pl":return"perl";case"dockerfile":return"dockerfile";case"ini":case"cfg":case"conf":return"ini";case"properties":return"properties";case"zig":return"zig";case"ex":case"exs":return"elixir";case"dart":return"dart";case"ml":case"mli":return"ocaml";case"hs":return"haskell";case"nix":return"nix";case"tf":case"tfvars":case"hcl":return"hcl";case"graphql":case"gql":return"graphql";case"sol":return"solidity";case"r":return"r";case"jl":return"julia";case"erl":return"erlang";case"clj":case"cljs":case"cljc":case"edn":return"clojure";case"scm":case"ss":return"scheme";case"rkt":return"racket";case"proto":return"protobuf";case"makefile":case"mk":return"makefile";case"ps1":case"psm1":return"powershell";case"json5":return"json5";case"less":return"less";case"scss":return"scss";case"sass":return"sass";case"styl":return"stylus";case"vue":return"vue";case"svelte":return"svelte";case"astro":return"astro";case"mm":case"m":return"objective-c";case"groovy":case"gvy":case"gradle":return"groovy"}}function a(e){if(!e||e.length<5)return!1;let t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]"))try{return JSON.parse(t),!0}catch{}return[/^(?:import|export)\s+.+from\s+['"][^'"]+['"]/m,/^(?:const|let|var|function|class|interface|type|enum)\s+[A-Za-z0-9_$]+/m,/(?:=>|\bconsole\.(?:log|error|warn)|return\s+|async\s+function)/,/^\s*\d+:\s*(?:import|const|let|function|\/\/|\/\*|<|[A-Za-z])/m,/^\s*\[[A-Za-z0-9_./-]+\.[a-zA-Z0-9]+\]\s*\n\d+:/m].some(e=>e.test(t))}function l(e,t){return(0,r.sT)(t)||e.getLoadedLanguages().includes(t)?t:"javascript"}function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"javascript";if(!e)return"";let n=(0,r.F)();if(!n)return(0,r.tn)(e);let s=l(n,t);try{return`<span class="shiki">${n.codeToHtml(e,{lang:s,themes:i,defaultColor:!1,structure:"inline"})}</span>`}catch{return(0,r.tn)(e)}}function c(e){return o(e,"json")}function d(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"javascript",n=e.split("\n");if(!e)return n;let s=(0,r.F)();if(!s)return n.map(r.tn);let a=l(s,t);try{let{tokens:t}=s.codeToTokens(e,{lang:a,themes:i,defaultColor:!1});if(t.length!==n.length)return n.map(r.tn);return t.map(e=>e.map(e=>{let t=(0,r.tn)(e.content);if(!e.htmlStyle)return t;let n=Object.entries(e.htmlStyle).map(e=>{let[t,n]=e;return`${t}:${n}`}).join(";");return n?`<span style="${n}">${t}</span>`:t}).join(""))}catch{return n.map(r.tn)}}},U8(e,t,n){function r(e){if(null!=e){if("string"==typeof e)return e;if(Number.isFinite(e)&&!(e<=0)){if(e>=1e6){let t=e/1e6;return`${Number.isInteger(t)?t:t.toFixed(1)}M`}if(e>=1e3){let t=e/1e3;return`${Number.isInteger(t)?t:t.toFixed(1)}K`}return String(e)}}}function i(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return"number"!=typeof e||!Number.isFinite(e)||e<=0?"":`$${e.toFixed(t)}`}function s(e){return"number"!=typeof e||!Number.isFinite(e)||e<0?"":e<1024?`${Math.round(e)} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(2)} MB`}function a(e){return"number"!=typeof e||!Number.isFinite(e)||e<0?"":`$${e.toFixed(2)}`}n.d(t,{$g:()=>a,BD:()=>i,Rk:()=>r,z3:()=>s})},LQ(e,t,n){function r(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n="M",r="Modified",i="text-info",s="bg-info/10 text-info border-info/25",a=(e||"").trim().toUpperCase();if(t){let e=a[0]||"M";"A"===e?(n="A",r="Added (Staged)",i="text-success",s="bg-success/10 text-success border-success/25"):"D"===e?(n="D",r="Deleted (Staged)",i="text-error",s="bg-error/10 text-error border-error/25"):"R"===e?(n="R",r="Renamed (Staged)",i="text-meta",s="bg-meta/10 text-meta border-meta/25"):"U"===e||"?"===e?(n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25"):(n="M",r="Modified (Staged)",i="text-info",s="bg-info/10 text-info border-info/25")}else if("??"===a||"?"===a||"U"===a||"UNTRACKED"===a)n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25";else{let e=a[1]||a[0]||"M";"A"===e?(n="A",r="Added",i="text-success",s="bg-success/10 text-success border-success/25"):"D"===e?(n="D",r="Deleted",i="text-error",s="bg-error/10 text-error border-error/25"):"R"===e?(n="R",r="Renamed",i="text-meta",s="bg-meta/10 text-meta border-meta/25"):"U"===e||"?"===e?(n="U",r="Untracked",i="text-success",s="bg-success/10 text-success border-success/25"):(n="M",r="Modified",i="text-info",s="bg-info/10 text-info border-info/25")}return{charStatus:n,label:r,colorClass:i,badgeBgClass:s,isStaged:t}}function i(e){let t=new Map,n=new Map;if(!Array.isArray(e))return{fileMap:t,folderMap:n};for(let r of e){if(!r||!r.file)continue;let e=r.file.replace(/^\/+/,"");t.set(e,r);let i=e.split("/");i.pop();let s="";for(let e of i){s=s?`${s}/${e}`:e;let t=n.get(s)||{count:0,hasModified:!1,hasUntracked:!1,hasStaged:!1,hasDeleted:!1,colorClass:"text-info"};t.count+=1,(r.staged||r.status&&" "!==r.status[0]&&"?"!==r.status[0])&&(t.hasStaged=!0),"??"===r.status?t.hasUntracked=!0:r.status?.includes("D")?t.hasDeleted=!0:t.hasModified=!0,t.hasModified||t.hasStaged?t.colorClass="text-info":t.hasUntracked?t.colorClass="text-success":t.hasDeleted&&(t.colorClass="text-error"),n.set(s,t)}}return{fileMap:t,folderMap:n}}n.d(t,{R:()=>r,_:()=>i})},W9(e,t,n){let r=null,i=null;function s(){return i&&i.expiresAt>Date.now()?Promise.resolve(i.data):r||(r=fetch("/api/models").then(e=>e.ok?e.json():Promise.reject(Error(`GET /api/models failed: ${e.status}`))).then(e=>(i={data:e,expiresAt:Date.now()+6e4},e)).finally(()=>{r=null}))}function a(){i=null}function l(){i=null,window.dispatchEvent(new CustomEvent("omp:models-updated"))}function o(e){return window.addEventListener("omp:models-updated",e),()=>window.removeEventListener("omp:models-updated",e)}n.d(t,{$P:()=>l,Sy:()=>o,kn:()=>a,xo:()=>s})},Np(e,t,n){let r="new-";function i(e){return String(e).padStart(2,"0")}function s(e){return!!e?.startsWith(r)}function a(e){return e?.startsWith(r)?Number(e.slice(r.length)):0/0}function l(e){let t=a(e);return function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date;return Number.isNaN(e.getTime())?"New Session":`New Session - ${e.getFullYear()}-${i(e.getMonth()+1)}-${i(e.getDate())}T${i(e.getHours())}:${i(e.getMinutes())}:${i(e.getSeconds())}`}(Number.isFinite(t)?new Date(t):new Date)}n.d(t,{fN:()=>s,fd:()=>a,g2:()=>l})},e(e,t,n){let r=["input","_input","patch"],i=/#([0-9a-fA-F]{4})$/,s=/^(PUT|CUT)\b/;function a(e){let t=e[0];return e.length>=2&&('"'===t||"'"===t)&&t===e[e.length-1]?e.slice(1,-1):e}function l(e){if(e)for(let t of r){let n=e[t];if("string"!=typeof n)continue;let r=function(e){let t,n=[];for(let r of e.replace(/^\uFEFF/,"").split("\n")){let e=r.endsWith("\r")?r.slice(0,-1):r,l=function(e){let t=e.trimEnd();if(!t.startsWith("["))return;let n=(t.endsWith("]")?t.slice(1,-1):t.slice(1)).trim(),r=i.exec(n),s=a((r?n.slice(0,r.index):n).trim());return s?{path:s,tag:r?.[1]}:void 0}(e);if(l){t={path:l.path,tag:l.tag,removed:!1,ops:[]},n.push(t);continue}if(!t)continue;let o=e.trim();if("REM"===o){t.removed=!0;continue}if(o.startsWith("MV ")){t.moveTo=a(o.slice(3).trim())||void 0;continue}if(s.test(o)){t.ops.push({verb:o.slice(0,3),spec:o.slice(3).trim().replace(/:$/,""),body:[]});continue}let c=t.ops[t.ops.length-1];c&&e.startsWith("+")&&c.body.push(e)}return n}(n);if(r.length>0)return{text:n,sections:r}}}function o(e){return l(e)?.sections[0].path}n.d(t,{I:()=>l,f$:()=>o})},wm(e,t,n){function r(e,t){e&&fetch("/api/agent/prewarm",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({cwd:e,...t?{accessMode:t}:{}})}).catch(()=>{})}function i(e,t,n){let r=void 0!==n?e.find(e=>String(e.id)===String(n)):e.find(e=>e.sessions?.some(e=>String(e.id)===String(t)))??e.find(e=>!!e.project_path);return r?.project_path||r?.name||null}n.d(t,{l:()=>i,r:()=>r})},B(e,t,n){var r=n("oS");function i(e){return(0,r.u)(e)&&"string"==typeof e.id&&e.id.length>0&&"string"==typeof e.agent&&e.agent.length>0&&"string"==typeof e.status&&"number"==typeof e.index}async function s(e){try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/subagents`);if(!t.ok)return null;let n=await t.json().catch(()=>null);if(!(0,r.u)(n))return null;let s=(0,r.u)(n.data)?n.data:n;if(!Array.isArray(s.subagents))return null;return s.subagents.filter(i)}catch{return null}}function a(e){let t={...e,source:"history",lastUpdate:0},n={};return void 0!==e.lastIntent&&(n.lastIntent=e.lastIntent),void 0!==e.toolCount&&(n.toolCount=e.toolCount),void 0!==e.requests&&(n.requests=e.requests),void 0!==e.tokens&&(n.tokens=e.tokens),void 0!==e.contextTokens&&(n.contextTokens=e.contextTokens),void 0!==e.contextWindow&&(n.contextWindow=e.contextWindow),void 0!==e.cost&&(n.cost=e.cost),void 0!==e.durationMs&&(n.durationMs=e.durationMs),void 0!==e.resolvedModel&&(n.resolvedModel=e.resolvedModel),Object.keys(n).length>0&&(t.progress=n),t}n.d(t,{Nh:()=>a,wv:()=>s})},T(e,t,n){var r=n("oS");function i(e){return"string"==typeof e&&e.length>0?e:void 0}function s(e){return"number"==typeof e&&Number.isFinite(e)?e:void 0}function a(e){return"bundled"===e||"user"===e||"project"===e?e:void 0}function l(e){var t;if(!(0,r.u)(e))return;let n={},l=s(e.index);void 0!==l&&(n.index=l);let o=i(e.id);void 0!==o&&(n.id=o);let c=i(e.agent);void 0!==c&&(n.agent=c);let d=a(e.agentSource);void 0!==d&&(n.agentSource=d);let u="pending"===(t=e.status)||"running"===t||"completed"===t||"failed"===t||"aborted"===t?t:void 0;void 0!==u&&(n.status=u);let p=i(e.task);void 0!==p&&(n.task=p);let m=i(e.assignment);void 0!==m&&(n.assignment=m);let h=i(e.description);void 0!==h&&(n.description=h);let f=i(e.lastIntent);void 0!==f&&(n.lastIntent=f);let x=i(e.currentTool);void 0!==x&&(n.currentTool=x);let g=i(e.currentToolArgs);void 0!==g&&(n.currentToolArgs=g);let b=s(e.currentToolStartMs);void 0!==b&&(n.currentToolStartMs=b),Array.isArray(e.recentTools)&&(n.recentTools=e.recentTools),Array.isArray(e.recentOutput)&&(n.recentOutput=e.recentOutput.filter(e=>"string"==typeof e));let v=s(e.toolCount);void 0!==v&&(n.toolCount=v);let k=s(e.requests);void 0!==k&&(n.requests=k);let y=s(e.tokens);void 0!==y&&(n.tokens=y);let w=s(e.contextTokens);void 0!==w&&(n.contextTokens=w);let N=s(e.contextWindow);void 0!==N&&(n.contextWindow=N);let Y=s(e.cost);void 0!==Y&&(n.cost=Y);let D=s(e.durationMs);void 0!==D&&(n.durationMs=D),("string"==typeof e.modelOverride||Array.isArray(e.modelOverride)&&e.modelOverride.every(e=>"string"==typeof e))&&(n.modelOverride=e.modelOverride);let F=i(e.modelRole);void 0!==F&&(n.modelRole=F);let A=i(e.resolvedModel);if(void 0!==A&&(n.resolvedModel=A),"boolean"==typeof e.resolvedModelIsFallback&&(n.resolvedModelIsFallback=e.resolvedModelIsFallback),(0,r.u)(e.retryState)){let t=s(e.retryState.attempt),r=s(e.retryState.maxAttempts),a=s(e.retryState.delayMs),l=i(e.retryState.errorMessage),o=s(e.retryState.startedAtMs);void 0!==t&&void 0!==r&&void 0!==a&&void 0!==l&&void 0!==o&&(n.retryState={attempt:t,maxAttempts:r,delayMs:a,errorMessage:l,startedAtMs:o})}if((0,r.u)(e.retryFailure)){let t=s(e.retryFailure.attempt),r=i(e.retryFailure.errorMessage);void 0!==t&&void 0!==r&&(n.retryFailure={attempt:t,errorMessage:r})}return void 0!==e.inflightTaskDetails&&(n.inflightTaskDetails=e.inflightTaskDetails),(0,r.u)(e.extractedToolData)&&(n.extractedToolData=e.extractedToolData),Object.keys(n).length>0?n:void 0}function o(e){if(!(0,r.u)(e))return;let t=i(e.id),n=i(e.status);if(!t||!n||"started"!==n&&"completed"!==n&&"failed"!==n&&"aborted"!==n)return;let l={id:t,agent:i(e.agent)??"subagent",status:n,index:s(e.index)??-1,lastUpdate:Date.now(),source:"live"},o=a(e.agentSource);void 0!==o&&(l.agentSource=o);let c=i(e.description);void 0!==c&&(l.description=c);let d=i(e.sessionFile);void 0!==d&&(l.sessionFile=d);let u=i(e.parentToolCallId);return void 0!==u&&(l.parentToolCallId=u),"boolean"==typeof e.detached&&(l.detached=e.detached),l}function c(e){if(!(0,r.u)(e))return[];let t=e.subagents;if(!Array.isArray(t))return[];let n=[];for(let e of t){let t=function(e){let t;if(!(0,r.u)(e))return;let n=i(e.id),o=i(e.agent);if(!n||!o)return;if("started"===e.status||"completed"===e.status||"failed"===e.status||"aborted"===e.status)t=e.status;else{if("pending"!==e.status&&"running"!==e.status)return;t="started"}let c={id:n,agent:o,status:t,index:s(e.index)??-1,source:"live"},d=a(e.agentSource);void 0!==d&&(c.agentSource=d);let u=i(e.description);void 0!==u&&(c.description=u);let p=i(e.task);void 0!==p&&(c.task=p);let m=i(e.assignment);void 0!==m&&(c.assignment=m);let h=i(e.sessionFile);void 0!==h&&(c.sessionFile=h);let f=i(e.parentToolCallId);void 0!==f&&(c.parentToolCallId=f),c.lastUpdate=s(e.lastUpdate)??Date.now();let x=l(e.progress);return void 0!==x&&(c.progress=x),c}(e);t&&n.push(t)}return n}function d(e,t){return(e.batchSeq??Number.MAX_SAFE_INTEGER)-(t.batchSeq??Number.MAX_SAFE_INTEGER)||e.index-t.index||e.id.localeCompare(t.id)}function u(e,t,n){let r=new Map(e.map(e=>[e.id,e]));for(let e of t){let t=r.get(e.id);if(!t){r.set(e.id,e);continue}let i=t.batchSeq??e.batchSeq;if(void 0!==n&&(t.lastUpdate??0)>=n||"history"===e.source&&"history"!==t.source){i!==t.batchSeq&&r.set(e.id,{...t,batchSeq:i});continue}if("history"!==e.source&&"history"===t.source){r.set(e.id,{...e,batchSeq:i});continue}r.set(e.id,{...t,...e,batchSeq:i})}return[...r.values()].sort(d)}n.d(t,{bH:()=>o,j8:()=>u,mq:()=>l,vG:()=>c})},So(e,t,n){let r="omp_chamber_settings",i=null,s={};function a(e){s={...e?.[r]??{}};let t={...e??{}};delete t[r],i={...t,...s}}function l(e){return i||a(e),i??{}}function o(e,t){let n=Array.isArray(e)?e:[e],r=l(t);for(let e of n)if(void 0!==r[e])return r[e]}function c(e,t){return l(t),{...e,...s}}function d(e,t){i={...l(),[e]:t},p({[e]:t})}function u(e){s={...s,...e},i={...l(),...e},p({[r]:s})}function p(e){fetch("/api/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}).catch(()=>{})}n.d(t,{BF:()=>o,cm:()=>c,cz:()=>d,l1:()=>u,x9:()=>a})},oS(e,t,n){function r(e){return"object"==typeof e&&null!==e&&!Array.isArray(e)}n.d(t,{u:()=>r})},Gb(e,t,n){function r(e,t){if(!t)return{folder:null,projectPath:null};for(let n of e)if((n.sessions||[]).some(e=>String(e.id)===String(t)))return{folder:n,projectPath:n.project_path??null};return{folder:null,projectPath:null}}function i(e,t,n){let i=r(e,t).folder,s=null!=n?e.find(e=>String(e.id)===String(n))??null:null;return(i??s)?.project_path??null}n.d(t,{M:()=>i,t:()=>r})},A(e,t,n){var r=n("g6"),i=n("AB"),s=n("N"),a=n("h"),l=n("al"),o=n("nv"),c=n("nT"),d=n("w"),u=n("Oj"),p=n("Gh"),m=n("R"),h=n("HJ"),f=n("DK"),x=n("f"),g=n("z9"),b=n("Fx"),v=n("F9"),k=n("bt"),y=n("YO"),w=n("by");let N={default:r.A,code:i.A,terminal:s.A,rocket:a.A,flask:l.A,gamepad:o.A,briefcase:c.A,home:d.A,globe:u.A,leaf:p.A,shield:m.A,palette:h.A,server:f.A,smartphone:x.A,database:g.A,lightbulb:b.A,music:v.A,camera:k.A,book:y.A,heart:w.A};function Y(e){return N[e||"default"]||r.A}n.d(t,{x:()=>Y})},ET(e,t,n){let r=["context","files","search","git","terminal","user-browser","browser","usage"];function i(e){return"string"==typeof e&&r.includes(e)}n.d(t,{ls:()=>i},{G7:r,lw:{files:200,search:200,git:260,terminal:320,context:420,"user-browser":320,browser:320,usage:420},qv:{files:268,search:268,git:268,terminal:640,context:536,"user-browser":804,browser:804,usage:536}})},SS(e,t,n){let r=new Map,i=new Map,s=new Set,a=new Map,l=new Map;function o(e){let t=r.get(e);void 0!==t&&(r.delete(e),r.set(e,t)),i.set(e,Date.now())}function c(e){let t=Date.now(),n=e=>{r.delete(e),s.delete(e),a.delete(e),i.delete(e);let t=l.get(e);t&&(clearTimeout(t),l.delete(e))};for(let[r,s]of i)!(t-s<=6e5)&&r!==e&&(a.get(r)||n(r));for(;r.size>10;){let t=!1;for(let i of r.keys())if(i!==e&&!a.get(i)){n(i),t=!0;break}if(!t)break}}function d(e,t){if(e)return o(e),r.get(e)?.[t]}function u(e,t,n){if(!e)return;let i=r.get(e)??{};i[t]=n,r.set(e,i),o(e),a.set(e,!0),p(e),c(e)}function p(e){let t=l.get(e);t&&clearTimeout(t),l.set(e,setTimeout(()=>{l.delete(e),m(e)},600))}async function m(e){if("u"<typeof window||!e||!a.get(e))return;a.set(e,!1);let t=r.get(e)??{};try{await fetch(`/api/sessions/${encodeURIComponent(e)}/state`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:t})})}catch(t){console.warn("session-state persist failed:",t),a.set(e,!0)}}function h(e){if(!e||"u"<typeof window)return Promise.resolve();let t=l.get(e);return t&&(clearTimeout(t),l.delete(e)),m(e)}async function f(e){if(e){if("u"<typeof window)return void s.add(e);try{let t=await fetch(`/api/sessions/${encodeURIComponent(e)}/state`);if(t.ok){let n=await t.json(),i=n.state&&"object"==typeof n.state?n.state:{},s=r.get(e)??{},l=!0===a.get(e)?{...i,...s}:i;r.set(e,l),o(e)}}catch(e){console.warn("session-state load failed:",e)}s.add(e),c(e)}}function x(e,t){e&&(r.set(e,{...r.get(e)??{},...t}),o(e),s.add(e),c(e))}function g(e){e&&s.add(e)}function b(e){e&&i.set(e,Date.now())}function v(e){return i.get(e)}function k(e,t){let n=r.get(e);n&&r.set(t,{...n,...r.get(t)??{}}),o(t),s.add(t),a.set(t,!0),p(t),r.delete(e),s.delete(e),a.delete(e),i.delete(e),c(t)}n.d(t,{D4:()=>h,E9:()=>x,L6:()=>f,R7:()=>v,WV:()=>d,Y1:()=>b,l5:()=>g,qI:()=>u,vy:()=>k})},P(e){e.exports={rE:"0.6.0"}}},a={};function l(e){var t=a[e];if(void 0!==t)return t.exports;var n=a[e]={exports:{}};return s[e].call(n.exports,n,n.exports,l),n.exports}l.m=s,l.d=(e,t,n)=>{var r=(t,n)=>{for(var r in t)l.o(t,r)&&!l.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,[n]:t[r]})};r(t,"get"),r(n,"value")},l.f={},l.e=e=>Promise.all(Object.keys(l.f).reduce((t,n)=>(l.f[n](e,t),t),[])),l.u=e=>"static/js/async/"+(121===e?"katex-vendor":e)+"."+({0:"8e59f2eb5b","0k":"5852e6b4fa","0w":"9ed36d5860",1:"f387c12b63",12:"d091f91c99",121:"de6a87c308",13:"8f810a8a6c",19:"6fe909d55a","1b":"23f1141a38","1k":"5974df3b87","1p":"0d5cddda96",2:"b589f1733b","2v":"96165101de",3:"0cacc08423",37:"b28b2f61cd","3d":"5085fb913f","3j":"357c80ff38","3p":"bcf32a0983","3r":"3a69e98ee0","3u":"1228460e2a","3y":"4c2596f64c",4:"9442eeb472","4e":"678285ca55","4k":"33a0c7eeb4","4q":"aad20dab25",5:"ebaf8b89cc",51:"95bcae98af","5b":"d88304bc13","5j":"d6407c4248","5o":"88316d4460",6:"f034c9b528",66:"5dfa29f957","6o":"5b1a06a382",7:"e4a9288dd0",73:"308dff4da8","7e":"a1cc9bfd88","7g":"a7814350c3","7l":"7a6a377ecc",8:"5067439d8c","8j":"ea110663fb",a:"bce4542392",aa:"65d3852576",az:"d656062b0f",b:"b4f6f06515",bq:"586bc738d1",c:"cd45b0ac45",c0:"0af1e640d3",ca:"8a52cfd447",cf:"d34fff5d67",ct:"b74928f7a3",cx:"ca5feec570",d:"a5fc8fe1b3",da:"f62c70f6c8",dc:"6dc4b0a04b",dp:"1725d6432c",e:"93214d622b",f:"ab50467719",f8:"bbf0dbae70",fw:"6a51998a8e",g:"8515cbc6f7",h:"4e790471e4",h1:"e8d5aa8e80",h3:"216e9798ab",hd:"0da931b622",hk:"ba7fb04d41",hn:"b645041e00",ho:"475a5e1ae4",hp:"e9fe2e395a",hs:"6d480d0ded",i:"7c148e8440",id:"573df20f29",j:"ab925882d8",jd:"63886a1f09",jg:"d86ebd4013",jl:"874d352278",jll:"11313b455a",js:"67182759ef",jsc:"23b70d6f40",jse:"334588ff5d",jz:"72eb929106",k:"7466330d1a",ka:"c1990ecaa3",kc:"bbdb35b771",ku:"29c8a59d0c",ky:"8dab1dade0",l:"12dd34e1be",l9:"949710adaf",ls:"9d9a01026c",m:"4b29d34f93",me:"8ace414f80",mt:"0352e976d8",mw:"ca1512563c",n:"a9f1c51701",na:"a36cd532d6",nk:"fc7e58325e",o:"36353dfb88",oc:"9c060c9779",og:"634fba99ac",p:"48ecfcd14e",px:"783b6f91f2",q:"542c184fec",q5:"e683f7c26e",qs:"2a9ddb3c72",r:"51010ad87c",rd:"cb6bf495bb",rf:"d626afc367",s:"413c2a4683",sy:"d16be843a7",t:"cda4891526",t9:"d44f57d518",ta:"973534bbec",tr:"e878658140",u:"0871ac5b22",ud:"3065bfee31",uf:"24ca3d49c3",up:"ea990da0ff",uw:"8890abbabc",v:"7d28d3c241",v0:"394ed37c6b",vp:"9b13bf8610",vt:"42416b707d",vy:"bbe114c4e0",w:"08ac210f60",wt:"ad92393a90",x:"563f72ca6b",x0:"475516418f",x1:"da8687159b",xl:"a3c562a58c",xn:"afecebbbd9",xw:"ae67ba06fd",y:"1a9ed7a5d8",y6:"43c57defe4",yb:"8c1342401d",ybq:"4491f2f2dc",yg:"35bebd6d0c",yq:"917ddd7ba2",ys:"00687cf82d",yv:"2fa22f009a",z:"56f61a4374",zi:"5fdb07b86a",zj:"654f37e8ff",zn:"966d6f1cc6",zo:"26213b40c0",zx:"e9f4105e00"})[e]+".js",l.miniCssF=e=>""+e+".css",l.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),e={},l.l=function(t,n,r,i){if(e[t])return void e[t].push(n);if(void 0!==r)for(var s,a,o=document.getElementsByTagName("script"),c=0;c<o.length;c++){var d=o[c];if(d.getAttribute("src")==t||d.getAttribute("data-rspack")=="ompchamber:"+r){s=d;break}}s||(a=!0,(s=document.createElement("script")).timeout=120,l.nc&&s.setAttribute("nonce",l.nc),s.setAttribute("data-rspack","ompchamber:"+r),s.src=t),e[t]=[n];var u=function(n,r){s.onerror=s.onload=null,clearTimeout(p);var i=e[t];if(delete e[t],s.parentNode&&s.parentNode.removeChild(s),i&&i.forEach(function(e){return e(r)}),n)return n(r)},p=setTimeout(u.bind(null,void 0,{type:"timeout",target:s}),12e4);s.onerror=u.bind(null,s.onerror),s.onload=u.bind(null,s.onload),a&&document.head.appendChild(s)},l.r=e=>{"u">typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t=[],l.O=(e,n,r,i)=>{if(n){i=i||0;for(var s=t.length;s>0&&t[s-1][2]>i;s--)t[s]=t[s-1];t[s]=[n,r,i];return}for(var a=1/0,s=0;s<t.length;s++){for(var[n,r,i]=t[s],o=!0,c=0;c<n.length;c++)(!1&i||a>=i)&&Object.keys(l.O).every(e=>l.O[e](n[c]))?n.splice(c--,1):(o=!1,i<a&&(a=i));if(o){t.splice(s--,1);var d=r();void 0!==d&&(e=d)}}return e},l.p="/",n={qz:0},l.f.j=function(e,t){var r=l.o(n,e)?n[e]:void 0;if(0!==r)if(r)t.push(r[2]);else{var i=new Promise((t,i)=>r=n[e]=[t,i]);t.push(r[2]=i);var s=l.p+l.u(e),a=Error();l.l(s,function(t){if(l.o(n,e)&&(0!==(r=n[e])&&(n[e]=void 0),r)){var i=t&&("load"===t.type?"missing":t.type),s=t&&t.target&&t.target.src;a.message="Loading chunk "+e+" failed.\n("+i+": "+s+")",a.name="ChunkLoadError",a.type=i,a.request=s,r[1](a)}},"chunk-"+e,e)}},l.O.j=e=>0===n[e],r=(e,t)=>{var r,i,[s,a,o]=t,c=0;if(s.some(e=>0!==n[e])){for(r in a)l.o(a,r)&&(l.m[r]=a[r]);if(o)var d=o(l)}for(e&&e(t);c<s.length;c++)i=s[c],l.o(n,i)&&n[i]&&n[i][0](),n[i]=0;return l.O(d)},(i=self.rspackChunkompchamber=self.rspackChunkompchamber||[]).forEach(r.bind(null,0)),i.push=r.bind(null,i.push.bind(i));var o=l.O(void 0,["a3","9","uy"],()=>l("l"));o=l.O(o)})();