pi-web-ui 0.64.4 → 0.64.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/server/agent-service.js +95 -5
- package/dist/server/bg-servers.js +111 -26
- package/dist/server/client-state.js +2 -0
- package/dist/server/dsh/dsh-agent-service.js +31 -21
- package/dist/server/dsh/dsh-sessions.js +12 -2
- package/dist/server/files-service.js +51 -28
- package/dist/server/index.js +1 -0
- package/dist/server/process-utils.js +41 -0
- package/dist/server/protocol-version.js +1 -1
- package/dist/server/settings-service.js +33 -0
- package/dist/server/subagent-templates.js +14 -1
- package/dist/server/subagents.js +107 -11
- package/package.json +110 -110
- package/web/dist/assets/{TerminalPanel-D6-kd9NX.js → TerminalPanel-CoPFNu1d.js} +1 -1
- package/web/dist/assets/{abnfDiagram-VCTEODGH-Ciapjs2h.js → abnfDiagram-VCTEODGH-Dltz1N0G.js} +1 -1
- package/web/dist/assets/{arc-DeXTszP5.js → arc-QOm2xRll.js} +1 -1
- package/web/dist/assets/{architectureDiagram-5GKGNRK7-CT2YpHJP.js → architectureDiagram-5GKGNRK7-L3XUBFbb.js} +1 -1
- package/web/dist/assets/{blockDiagram-I7D4REHJ-CUbGhz2G.js → blockDiagram-I7D4REHJ-CJmza4yx.js} +1 -1
- package/web/dist/assets/{c4Diagram-7LVT6UL2-B3tmW0uO.js → c4Diagram-7LVT6UL2-CwgA5WEW.js} +1 -1
- package/web/dist/assets/channel-VncP7yyT.js +1 -0
- package/web/dist/assets/{chunk-2Q5K7J3B-B5eVe3ZU.js → chunk-2Q5K7J3B-DoqSiCVF.js} +1 -1
- package/web/dist/assets/{chunk-5VM5RSS4-zHW5GxYE.js → chunk-5VM5RSS4-CO14GhQ1.js} +1 -1
- package/web/dist/assets/{chunk-F27PBJKO-D9YBCGH8.js → chunk-F27PBJKO-kRFf9SDx.js} +1 -1
- package/web/dist/assets/{chunk-IMKFNOWR-DFERzrJy.js → chunk-IMKFNOWR-Cm6JOqm0.js} +1 -1
- package/web/dist/assets/{chunk-JWPE2WC7-VCholTr0.js → chunk-JWPE2WC7-DTpnGTdB.js} +1 -1
- package/web/dist/assets/{chunk-POPQ4Y6H-DgLTPLwv.js → chunk-POPQ4Y6H-CdSt_7xq.js} +1 -1
- package/web/dist/assets/{chunk-SVP7TREG-B_43mnQv.js → chunk-SVP7TREG-IQRTD_4U.js} +1 -1
- package/web/dist/assets/{chunk-TICWLB2K-DexHBk9f.js → chunk-TICWLB2K-Duj1rt_5.js} +1 -1
- package/web/dist/assets/{chunk-XXDRQBXY-B4NDVbVt.js → chunk-XXDRQBXY-BFf3gcbL.js} +1 -1
- package/web/dist/assets/classDiagram-ZZMXUADV-BWCNDr-F.js +1 -0
- package/web/dist/assets/classDiagram-v2-VYDZK3BY-BWCNDr-F.js +1 -0
- package/web/dist/assets/{cose-bilkent-JH36ORCC-D4MfizXL.js → cose-bilkent-JH36ORCC-D5k0Z1dx.js} +1 -1
- package/web/dist/assets/{cynefin-OW5HDTMX-BoCpr6Nu.js → cynefin-OW5HDTMX-OsV-x0h-.js} +1 -1
- package/web/dist/assets/{cynefinDiagram-5FMLGOSQ-wCccvWLd.js → cynefinDiagram-5FMLGOSQ-DM7XHm4s.js} +1 -1
- package/web/dist/assets/{dagre-GXQ25YYZ-hZXj_BO7.js → dagre-GXQ25YYZ-B0bIbgMh.js} +1 -1
- package/web/dist/assets/{diagram-S7CK7UJ4-DgqjaR7A.js → diagram-S7CK7UJ4-lMVsMjfI.js} +1 -1
- package/web/dist/assets/{diagram-UQ7AKVKN-D2yHlsqg.js → diagram-UQ7AKVKN-BJDbkaYf.js} +1 -1
- package/web/dist/assets/{diagram-VSXAHHWV-B2ppn0d7.js → diagram-VSXAHHWV-1zUfVr-L.js} +1 -1
- package/web/dist/assets/{diagram-VX7I27RA-DGl4RYFm.js → diagram-VX7I27RA-B-Qy3dth.js} +1 -1
- package/web/dist/assets/{diagram-Z3DM3KII-Bu_MuKt2.js → diagram-Z3DM3KII-DbKcoZFP.js} +1 -1
- package/web/dist/assets/{ebnfDiagram-PWID7BFC-B462IWhy.js → ebnfDiagram-PWID7BFC-CuMZBzDi.js} +1 -1
- package/web/dist/assets/{erDiagram-RLTQ6QDP-4N5KTVz0.js → erDiagram-RLTQ6QDP-Dkw_Uhg2.js} +1 -1
- package/web/dist/assets/{flowDiagram-HODETNUW-D5YGm0jY.js → flowDiagram-HODETNUW-CwDYMy38.js} +1 -1
- package/web/dist/assets/{ganttDiagram-EL5Y4UJY-DtPjqo-N.js → ganttDiagram-EL5Y4UJY-B2s3myqg.js} +1 -1
- package/web/dist/assets/{gitGraphDiagram-WWUBYQGX-DDi56hwo.js → gitGraphDiagram-WWUBYQGX-CJ3rUTG5.js} +1 -1
- package/web/dist/assets/{index-Bfi5_bc1.js → index-30RM921r.js} +25 -25
- package/web/dist/assets/index-B_lYcsGw.css +10 -0
- package/web/dist/assets/{infoDiagram-27XIBGKW-FRX_QzzT.js → infoDiagram-27XIBGKW-DuIoOHyL.js} +1 -1
- package/web/dist/assets/{ishikawaDiagram-5VMMS53U-BYvNCcn0.js → ishikawaDiagram-5VMMS53U-Fm14e_CH.js} +1 -1
- package/web/dist/assets/{journeyDiagram-3NMN7TZE-HbYFhz4W.js → journeyDiagram-3NMN7TZE-BuokOq_3.js} +1 -1
- package/web/dist/assets/{kanban-definition-UXKFOSKX-BJFVJp0b.js → kanban-definition-UXKFOSKX-D2FQMRnh.js} +1 -1
- package/web/dist/assets/{layout-DJnxm5X9.js → layout-CZUvkkNF.js} +1 -1
- package/web/dist/assets/{linear-M6L-f6ON.js → linear-tIFeS1QT.js} +1 -1
- package/web/dist/assets/{mermaid.core-BPgLSPyb.js → mermaid.core-BI5_3AOv.js} +5 -5
- package/web/dist/assets/{mindmap-definition-YA3MSWOX-CT34wBkW.js → mindmap-definition-YA3MSWOX-D5RmpgpB.js} +1 -1
- package/web/dist/assets/{pegDiagram-XKGWAZYB-y7gUs6p-.js → pegDiagram-XKGWAZYB-DpZxaRI3.js} +1 -1
- package/web/dist/assets/{pieDiagram-E7YTZNPT-8Ksrkk_P.js → pieDiagram-E7YTZNPT-Co7MADQz.js} +1 -1
- package/web/dist/assets/{quadrantDiagram-AXDQQJYC-B1JgOvVm.js → quadrantDiagram-AXDQQJYC-BsRraVQ-.js} +1 -1
- package/web/dist/assets/{railroadDiagram-O6MQD6OU-kYgyfD-Z.js → railroadDiagram-O6MQD6OU-DW2pw5p_.js} +1 -1
- package/web/dist/assets/{requirementDiagram-BXWQKSXE-DsU0dCxH.js → requirementDiagram-BXWQKSXE-DeaEY9Dk.js} +1 -1
- package/web/dist/assets/{sankeyDiagram-P5KCCOFB-Bn3K22Ux.js → sankeyDiagram-P5KCCOFB-BlKg1xhH.js} +1 -1
- package/web/dist/assets/{sequenceDiagram-WJ2MYXX4-Ovxqv6CH.js → sequenceDiagram-WJ2MYXX4-C0ffpRmx.js} +1 -1
- package/web/dist/assets/{sizeCapture-INFHLROL-DIkQtrVp.js → sizeCapture-INFHLROL-DHFDdkAo.js} +1 -1
- package/web/dist/assets/{stateDiagram-D77RDMKH-C4ql6zER.js → stateDiagram-D77RDMKH-CwKStGSS.js} +1 -1
- package/web/dist/assets/stateDiagram-v2-MP3YSRHH-B0qJoPpx.js +1 -0
- package/web/dist/assets/{swimlanes-42K2YHIH-2hpivmJO.js → swimlanes-42K2YHIH-MB6Uskqk.js} +1 -1
- package/web/dist/assets/swimlanesDiagram-VR7AAH4N-IYPIFoU6.js +8 -0
- package/web/dist/assets/{timeline-definition-24CTP7MA-BuH_ON1U.js → timeline-definition-24CTP7MA-CkcuHQ1A.js} +1 -1
- package/web/dist/assets/{vennDiagram-4TSXK5OY-D9E14XfU.js → vennDiagram-4TSXK5OY-DRiGv5ga.js} +1 -1
- package/web/dist/assets/{wardleyDiagram-VM6X3IG4-D6h0zd6l.js → wardleyDiagram-VM6X3IG4-Cwldlf89.js} +1 -1
- package/web/dist/assets/{xychartDiagram-S5SC5T6Z-C7uuvJqC.js → xychartDiagram-S5SC5T6Z-Biqu8RpV.js} +1 -1
- package/web/dist/index.html +2 -2
- package/web/dist/assets/channel-C-ah19CA.js +0 -1
- package/web/dist/assets/classDiagram-ZZMXUADV-BjgHzd13.js +0 -1
- package/web/dist/assets/classDiagram-v2-VYDZK3BY-BjgHzd13.js +0 -1
- package/web/dist/assets/index-BVwF4g4j.css +0 -10
- package/web/dist/assets/stateDiagram-v2-MP3YSRHH-CM0zTC3x.js +0 -1
- package/web/dist/assets/swimlanesDiagram-VR7AAH4N-BqO7jiba.js +0 -8
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-
|
|
2
|
-
import{R as Ye,a as l,j as e,M as hi,b as gi,c as fi}from"./markdown-BJJLXG-8.js";import{r as hn}from"./react-ezqUM1Or.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const i of c)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(c){const i={};return c.integrity&&(i.integrity=c.integrity),c.referrerPolicy&&(i.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?i.credentials="include":c.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(c){if(c.ep)return;c.ep=!0;const i=n(c);fetch(c.href,i)}})();var ht={},Ts;function xi(){if(Ts)return ht;Ts=1;var t=hn();return ht.createRoot=t.createRoot,ht.hydrateRoot=t.hydrateRoot,ht}var yi=xi();const vi="modulepreload",ki=function(t){return"/"+t},Es={},gn=function(s,n,r){let c=Promise.resolve();if(n&&n.length>0){let a=function(m){return Promise.all(m.map(y=>Promise.resolve(y).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),u=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));c=a(n.map(m=>{if(m=ki(m),m in Es)return;Es[m]=!0;const y=m.endsWith(".css"),g=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${g}`))return;const x=document.createElement("link");if(x.rel=y?"stylesheet":vi,y||(x.as="script"),x.crossOrigin="",x.href=m,u&&x.setAttribute("nonce",u),document.head.appendChild(x),y)return new Promise((b,T)=>{x.addEventListener("load",b),x.addEventListener("error",()=>T(new Error(`Unable to preload CSS for ${m}`)))})}))}function i(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return c.then(a=>{for(const o of a||[])o.status==="rejected"&&i(o.reason);return s().catch(i)})};var fn={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ps=Ye.createContext&&Ye.createContext(fn),bi=["attr","size","title"];function ji(t,s){if(t==null)return{};var n,r,c=wi(t,s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],s.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(c[n]=t[n])}return c}function wi(t,s){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(s.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function kt(){return kt=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var n=arguments[s];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},kt.apply(null,arguments)}function Ms(t,s){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);s&&(r=r.filter(function(c){return Object.getOwnPropertyDescriptor(t,c).enumerable})),n.push.apply(n,r)}return n}function bt(t){for(var s=1;s<arguments.length;s++){var n=arguments[s]!=null?arguments[s]:{};s%2?Ms(Object(n),!0).forEach(function(r){Ni(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ms(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ni(t,s,n){return(s=Ci(s))in t?Object.defineProperty(t,s,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[s]=n,t}function Ci(t){var s=Si(t,"string");return typeof s=="symbol"?s:s+""}function Si(t,s){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,s);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}function xn(t){return t&&t.map((s,n)=>Ye.createElement(s.tag,bt({key:n},s.attr),xn(s.child)))}function se(t){return s=>Ye.createElement(Ti,kt({attr:bt({},t.attr)},s),xn(t.child))}function Ti(t){var s=n=>{var r=t.attr,c=t.size,i=t.title,a=ji(t,bi),o=c||n.size||"1em",u;return n.className&&(u=n.className),t.className&&(u=(u?u+" ":"")+t.className),Ye.createElement("svg",kt({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,a,{className:u,style:bt(bt({color:t.color||n.color},n.style),t.style),height:o,width:o,xmlns:"http://www.w3.org/2000/svg"}),i&&Ye.createElement("title",null,i),t.children)};return Ps!==void 0?Ye.createElement(Ps.Consumer,null,n=>s(n)):s(fn)}function Ei(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"11",cy:"11",r:"8"},child:[]},{tag:"line",attr:{x1:"21",y1:"21",x2:"16.65",y2:"16.65"},child:[]},{tag:"line",attr:{x1:"8",y1:"11",x2:"14",y2:"11"},child:[]}]})(t)}function Pi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"11",cy:"11",r:"8"},child:[]},{tag:"line",attr:{x1:"21",y1:"21",x2:"16.65",y2:"16.65"},child:[]},{tag:"line",attr:{x1:"11",y1:"8",x2:"11",y2:"14"},child:[]},{tag:"line",attr:{x1:"8",y1:"11",x2:"14",y2:"11"},child:[]}]})(t)}function xt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"},child:[]}]})(t)}function Pe(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"18",y1:"6",x2:"6",y2:"18"},child:[]},{tag:"line",attr:{x1:"6",y1:"6",x2:"18",y2:"18"},child:[]}]})(t)}function yn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"},child:[]},{tag:"path",attr:{d:"M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"},child:[]}]})(t)}function Rs(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"},child:[]},{tag:"circle",attr:{cx:"9",cy:"7",r:"4"},child:[]},{tag:"path",attr:{d:"M23 21v-2a4 4 0 0 0-3-3.87"},child:[]},{tag:"path",attr:{d:"M16 3.13a4 4 0 0 1 0 7.75"},child:[]}]})(t)}function Mi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"},child:[]},{tag:"polyline",attr:{points:"17 8 12 3 7 8"},child:[]},{tag:"line",attr:{x1:"12",y1:"3",x2:"12",y2:"15"},child:[]}]})(t)}function Ri(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"},child:[]},{tag:"path",attr:{d:"M7 11V7a5 5 0 0 1 9.9-1"},child:[]}]})(t)}function Ae(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"3 6 5 6 21 6"},child:[]},{tag:"path",attr:{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"},child:[]},{tag:"line",attr:{x1:"10",y1:"11",x2:"10",y2:"17"},child:[]},{tag:"line",attr:{x1:"14",y1:"11",x2:"14",y2:"17"},child:[]}]})(t)}function tt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"4 17 10 11 4 5"},child:[]},{tag:"line",attr:{x1:"12",y1:"19",x2:"20",y2:"19"},child:[]}]})(t)}function Is(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"circle",attr:{cx:"12",cy:"12",r:"6"},child:[]},{tag:"circle",attr:{cx:"12",cy:"12",r:"2"},child:[]}]})(t)}function Ls(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"},child:[]},{tag:"line",attr:{x1:"7",y1:"7",x2:"7.01",y2:"7"},child:[]}]})(t)}function Ii(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"5"},child:[]},{tag:"line",attr:{x1:"12",y1:"1",x2:"12",y2:"3"},child:[]},{tag:"line",attr:{x1:"12",y1:"21",x2:"12",y2:"23"},child:[]},{tag:"line",attr:{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"},child:[]},{tag:"line",attr:{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"},child:[]},{tag:"line",attr:{x1:"1",y1:"12",x2:"3",y2:"12"},child:[]},{tag:"line",attr:{x1:"21",y1:"12",x2:"23",y2:"12"},child:[]},{tag:"line",attr:{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"},child:[]},{tag:"line",attr:{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"},child:[]}]})(t)}function jt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},child:[]}]})(t)}function Li(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"4",y1:"21",x2:"4",y2:"14"},child:[]},{tag:"line",attr:{x1:"4",y1:"10",x2:"4",y2:"3"},child:[]},{tag:"line",attr:{x1:"12",y1:"21",x2:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"12",y1:"8",x2:"12",y2:"3"},child:[]},{tag:"line",attr:{x1:"20",y1:"21",x2:"20",y2:"16"},child:[]},{tag:"line",attr:{x1:"20",y1:"12",x2:"20",y2:"3"},child:[]},{tag:"line",attr:{x1:"1",y1:"14",x2:"7",y2:"14"},child:[]},{tag:"line",attr:{x1:"9",y1:"8",x2:"15",y2:"8"},child:[]},{tag:"line",attr:{x1:"17",y1:"16",x2:"23",y2:"16"},child:[]}]})(t)}function wt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"3"},child:[]},{tag:"path",attr:{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"},child:[]}]})(t)}function vn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"22",y1:"2",x2:"11",y2:"13"},child:[]},{tag:"polygon",attr:{points:"22 2 15 22 11 13 2 9 22 2"},child:[]}]})(t)}function Nt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"11",cy:"11",r:"8"},child:[]},{tag:"line",attr:{x1:"21",y1:"21",x2:"16.65",y2:"16.65"},child:[]}]})(t)}function Di(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"},child:[]},{tag:"polyline",attr:{points:"17 21 17 13 7 13 7 21"},child:[]},{tag:"polyline",attr:{points:"7 3 7 8 15 8"},child:[]}]})(t)}function kn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"1 4 1 10 7 10"},child:[]},{tag:"path",attr:{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"},child:[]}]})(t)}function rt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"23 4 23 10 17 10"},child:[]},{tag:"polyline",attr:{points:"1 20 1 14 7 14"},child:[]},{tag:"path",attr:{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"},child:[]}]})(t)}function He(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",y1:"5",x2:"12",y2:"19"},child:[]},{tag:"line",attr:{x1:"5",y1:"12",x2:"19",y2:"12"},child:[]}]})(t)}function so(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"5 3 19 12 5 21 5 3"},child:[]}]})(t)}function Ai(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"},child:[]}]})(t)}function Ds(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"16.5",y1:"9.4",x2:"7.5",y2:"4.21"},child:[]},{tag:"path",attr:{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"},child:[]},{tag:"polyline",attr:{points:"3.27 6.96 12 12.01 20.73 6.96"},child:[]},{tag:"line",attr:{x1:"12",y1:"22.08",x2:"12",y2:"12"},child:[]}]})(t)}function _i(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"1"},child:[]},{tag:"circle",attr:{cx:"19",cy:"12",r:"1"},child:[]},{tag:"circle",attr:{cx:"5",cy:"12",r:"1"},child:[]}]})(t)}function Bi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"},child:[]}]})(t)}function st(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"},child:[]}]})(t)}function Fi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"3",y1:"12",x2:"21",y2:"12"},child:[]},{tag:"line",attr:{x1:"3",y1:"6",x2:"21",y2:"6"},child:[]},{tag:"line",attr:{x1:"3",y1:"18",x2:"21",y2:"18"},child:[]}]})(t)}function $i(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"},child:[]}]})(t)}function Hi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"15 3 21 3 21 9"},child:[]},{tag:"polyline",attr:{points:"9 21 3 21 3 15"},child:[]},{tag:"line",attr:{x1:"21",y1:"3",x2:"14",y2:"10"},child:[]},{tag:"line",attr:{x1:"3",y1:"21",x2:"10",y2:"14"},child:[]}]})(t)}function Oi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"},child:[]},{tag:"path",attr:{d:"M7 11V7a5 5 0 0 1 10 0v4"},child:[]}]})(t)}function Gt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"},child:[]},{tag:"path",attr:{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"},child:[]}]})(t)}function Ct(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"12 2 2 7 12 12 22 7 12 2"},child:[]},{tag:"polyline",attr:{points:"2 17 12 22 22 17"},child:[]},{tag:"polyline",attr:{points:"2 12 12 17 22 12"},child:[]}]})(t)}function Ki(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"12",y1:"16",x2:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"12",y1:"8",x2:"12.01",y2:"8"},child:[]}]})(t)}function Wi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},child:[]},{tag:"circle",attr:{cx:"8.5",cy:"8.5",r:"1.5"},child:[]},{tag:"polyline",attr:{points:"21 15 16 10 5 21"},child:[]}]})(t)}function Ui(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"3",width:"7",height:"7"},child:[]},{tag:"rect",attr:{x:"14",y:"3",width:"7",height:"7"},child:[]},{tag:"rect",attr:{x:"14",y:"14",width:"7",height:"7"},child:[]},{tag:"rect",attr:{x:"3",y:"14",width:"7",height:"7"},child:[]}]})(t)}function qi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"2",y1:"12",x2:"22",y2:"12"},child:[]},{tag:"path",attr:{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"},child:[]}]})(t)}function As(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"},child:[]}]})(t)}function yt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"6",y1:"3",x2:"6",y2:"15"},child:[]},{tag:"circle",attr:{cx:"18",cy:"6",r:"3"},child:[]},{tag:"circle",attr:{cx:"6",cy:"18",r:"3"},child:[]},{tag:"path",attr:{d:"M18 9a9 9 0 0 1-9 9"},child:[]}]})(t)}function Je(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"},child:[]}]})(t)}function zi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"},child:[]},{tag:"polyline",attr:{points:"13 2 13 9 20 9"},child:[]}]})(t)}function bn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"},child:[]},{tag:"polyline",attr:{points:"14 2 14 8 20 8"},child:[]},{tag:"line",attr:{x1:"16",y1:"13",x2:"8",y2:"13"},child:[]},{tag:"line",attr:{x1:"16",y1:"17",x2:"8",y2:"17"},child:[]},{tag:"polyline",attr:{points:"10 9 9 9 8 9"},child:[]}]})(t)}function Qt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"},child:[]},{tag:"circle",attr:{cx:"12",cy:"12",r:"3"},child:[]}]})(t)}function Yt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 20h9"},child:[]},{tag:"path",attr:{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"},child:[]}]})(t)}function St(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"},child:[]}]})(t)}function ls(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"},child:[]},{tag:"polyline",attr:{points:"7 10 12 15 17 10"},child:[]},{tag:"line",attr:{x1:"12",y1:"15",x2:"12",y2:"3"},child:[]}]})(t)}function lt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"4",y:"4",width:"16",height:"16",rx:"2",ry:"2"},child:[]},{tag:"rect",attr:{x:"9",y:"9",width:"6",height:"6"},child:[]},{tag:"line",attr:{x1:"9",y1:"1",x2:"9",y2:"4"},child:[]},{tag:"line",attr:{x1:"15",y1:"1",x2:"15",y2:"4"},child:[]},{tag:"line",attr:{x1:"9",y1:"20",x2:"9",y2:"23"},child:[]},{tag:"line",attr:{x1:"15",y1:"20",x2:"15",y2:"23"},child:[]},{tag:"line",attr:{x1:"20",y1:"9",x2:"23",y2:"9"},child:[]},{tag:"line",attr:{x1:"20",y1:"14",x2:"23",y2:"14"},child:[]},{tag:"line",attr:{x1:"1",y1:"9",x2:"4",y2:"9"},child:[]},{tag:"line",attr:{x1:"1",y1:"14",x2:"4",y2:"14"},child:[]}]})(t)}function Vi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"9 10 4 15 9 20"},child:[]},{tag:"path",attr:{d:"M20 4v7a4 4 0 0 1-4 4H4"},child:[]}]})(t)}function jn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"},child:[]},{tag:"path",attr:{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"},child:[]}]})(t)}function Gi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"16 18 22 12 16 6"},child:[]},{tag:"polyline",attr:{points:"8 6 2 12 8 18"},child:[]}]})(t)}function _s(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"polyline",attr:{points:"12 6 12 12 16 14"},child:[]}]})(t)}function wn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"13 17 18 12 13 7"},child:[]},{tag:"polyline",attr:{points:"6 17 11 12 6 7"},child:[]}]})(t)}function Nn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"11 17 6 12 11 7"},child:[]},{tag:"polyline",attr:{points:"18 17 13 12 18 7"},child:[]}]})(t)}function ut(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"18 15 12 9 6 15"},child:[]}]})(t)}function Pt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"9 18 15 12 9 6"},child:[]}]})(t)}function Ge(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"6 9 12 15 18 9"},child:[]}]})(t)}function pt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"20 6 9 17 4 12"},child:[]}]})(t)}function Qi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"},child:[]},{tag:"polyline",attr:{points:"22 4 12 14.01 9 11.01"},child:[]}]})(t)}function Lt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"},child:[]},{tag:"polyline",attr:{points:"3.27 6.96 12 12.01 20.73 6.96"},child:[]},{tag:"line",attr:{x1:"12",y1:"22.08",x2:"12",y2:"12"},child:[]}]})(t)}function Yi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"},child:[]},{tag:"path",attr:{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"},child:[]}]})(t)}function Ji(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"},child:[]},{tag:"path",attr:{d:"M13.73 21a2 2 0 0 1-3.46 0"},child:[]}]})(t)}function Cn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",y1:"19",x2:"12",y2:"5"},child:[]},{tag:"polyline",attr:{points:"5 12 12 5 19 12"},child:[]}]})(t)}function Sn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",y1:"5",x2:"12",y2:"19"},child:[]},{tag:"polyline",attr:{points:"19 12 12 19 5 12"},child:[]}]})(t)}function Xi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"21 8 21 21 3 21 3 8"},child:[]},{tag:"rect",attr:{x:"1",y:"3",width:"22",height:"5"},child:[]},{tag:"line",attr:{x1:"10",y1:"12",x2:"14",y2:"12"},child:[]}]})(t)}function Zi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"},child:[]},{tag:"line",attr:{x1:"12",y1:"9",x2:"12",y2:"13"},child:[]},{tag:"line",attr:{x1:"12",y1:"17",x2:"12.01",y2:"17"},child:[]}]})(t)}function ea(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"12",y1:"8",x2:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"12",y1:"16",x2:"12.01",y2:"16"},child:[]}]})(t)}function ta(t){return t.map(s=>s.kind==="package"?`pi update npm:${s.name}`:`npm i -g ${s.name}@latest`).join("; ")}function Ue(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(16);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(t);else for(let n=0;n<16;n++)t[n]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const s=[...t].map(n=>n.toString(16).padStart(2,"0")).join("");return`${s.slice(0,8)}-${s.slice(8,12)}-${s.slice(12,16)}-${s.slice(16,20)}-${s.slice(20)}`}function ze({trigger:t,open:s,onOpenChange:n,children:r,align:c="right",fit:i=!1,direction:a="down",menuClassName:o,menuRef:u,menuStyle:m}){const y=l.useRef(null);return l.useEffect(()=>{if(!s)return;const g=b=>{y.current&&!y.current.contains(b.target)&&n(!1)},x=b=>{b.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",x)}},[s,n]),e.jsxs("div",{className:`dropdown ${c} ${i?"fit":""} ${a==="up"?"dd-up":""}`,ref:y,children:[e.jsxs("button",{type:"button",className:"chip",onClick:()=>n(!s),"aria-expanded":s,children:[t,e.jsx(Ge,{className:`dd-caret ${s?"up":""}`})]}),s&&e.jsx("div",{className:`dd-menu ${o??""}`,ref:u,style:m,children:r})]})}function Ie({active:t,disabled:s=!1,title:n,onClick:r,children:c}){return e.jsx("button",{type:"button",className:`dd-item ${t?"active":""}`,disabled:s,title:n,onClick:r,children:c})}const Tn="pi-web-ui:lang",Bs={docTitle:"pi-web-ui — pi 编码智能体",cancel:"取消",ok:"确定",save:"保存",close:"关闭",widgetExpand:"点击放大查看完整输出",collapsePanel:"收起面板",expandPanel:"展开面板",dragToResize:"拖拽调整宽度 · 双击复位",loading:"加载中…",connected:"已连接",connecting:"连接中…",reconnecting:"重连中…",language:"语言",langZh:"中文",langEn:"English",githubRepo:"GitHub 仓库(xing-shuyin/pi-web-ui)",copy:"复制",viewSwitch:"视图切换",chat:"对话",terminal:"终端",selectModel:"选择模型",availableModels:"可用模型",allProviders:"全部",providers:"服务商",noModels:"暂无可用模型(请先配置 API 密钥)",reasoning:"推理",vision:"识图",refreshModels:"刷新模型列表(保留手填,合并新增)",manageModels:"⚙ 管理模型(新增 / 修改)",manageModelsTitle:"管理模型",thinkingLevel:"思考强度",thinking:"思考",thinkingChip:"思考:{level}",sound:"声音",theme:"主题",themeDefault:"深色(默认)",newChat:"新对话",more:"更多",newChatTip:"新建对话(每个浏览器独立保存会话)","thinking.off":"关闭","thinking.minimal":"极简","thinking.low":"低","thinking.medium":"中","thinking.high":"高","thinking.xhigh":"极高","thinking.max":"最大",thinkingUnsupported:"当前模型不支持该级别,已按模型能力就近生效",context:"上下文",contextUsage:"上下文用量",cumulativeCost:"累计成本",sessionMessages:"会话消息数",messages:"消息",pluginStatus:"插件状态",engineBadge:"引擎",working:"工作中",queued:"排队",enterPath:"输入路径,Enter 切换",cwdTip:"工作目录:{path}(点击切换)",cwdGoUp:"上级目录",cwdPickCurrent:"选择当前目录",cwdChoose:"选择",cwdEnter:"进入",cwdEmpty:"(空目录)",cwdNewFolder:"新建文件夹",cwdNewName:"文件夹名称",cwdCreate:"创建",cwdCancel:"取消",cacheHit:"缓存命中",cacheHitTip:"缓存读取 {read} · 缓存写入 {write} · 未命中 {miss}(共 {input} 输入 token)",tps:"t/s",rateTip:"实时生成速率(估算)",folderRef:"文件夹引用:{path}",refOnly:"仅引用:{path}",attachContent:"附加内容:{path}",attachLines:"附加选中行:{path}(第 {start}-{end} 行)",attachImage:"图片:{name}",attachFile:"文件:{name}",removeAttachment:"移除附件",attachHint:"将随下一条消息发送",uploadFile:"添加文件(图片/文本/任意文件,也可直接拖入或粘贴截图)",dropHereToAttach:"松开以添加文件",imageNotSupported:"当前模型不支持识图:图片将交给视觉桥转写(若未配置视觉模型则可能被忽略)",imageLoadFailed:"图片读取失败:{name}",fileLoadFailed:"文件读取失败:{name}",fileTooLarge:"文件过大已跳过(>{size}MB):{name}",foldersNotSupported:"不支持直接拖入文件夹,请展开后选择文件",placeholderStreaming:"智能体正在工作中…回车插队发送,或点「排队」等回答结束后发送",placeholderIdle:"给 pi 发送消息 — Enter 发送,/ 查看命令",placeholderConnecting:"正在连接服务器…",stopAgent:"停止智能体",stop:"停止",bgTasks:"后台任务",bgTasksTip:"AI 在后台启动的服务(npm run dev & 等)——可逐个停止或全部关闭,对话结束后仍保留",bgTasksEmpty:"暂无后台任务",bgTasksDesc:"AI 运行中启动并仍在监听的进程(按监听端口检测)",bgTaskPort:"端口",bgTaskPid:"PID",bgTaskSince:"启动",bgTaskStop:"停止",bgTaskStopAll:"全部关闭",bgTaskRefresh:"刷新",bgTaskJustNow:"刚刚",bgTaskMinutes:"{n} 分钟前",bgTaskHours:"{n} 小时前",bgTaskDays:"{n} 天前",stopBash:"停止",stopBashTip:"停止正在运行的 bash 命令(对话继续)",supplement:"排队",supplementTip:"加入队列:AI 回答完全结束后才发送(不打断)",queueSteerTag:"插队",queueFollowTag:"排队",queueRemoveTip:"移除此排队消息",sendTip:"发送(Enter)",slashCommands:"命令",slashMenuHint:"↑↓ 选择 · Enter/Tab 补全",slashHelpTitle:"pi 命令",slashHelpHint:"输入 / 随时打开命令列表",slashLoading:"命令列表加载中…(连接服务器后可用)",slashBuiltin:"内置",slashExtension:"扩展",slashPrompt:"模板",slashSkill:"技能",slashPlugin:"插件",slashCopied:"已复制上一条助手回复",slashCopyFailed:"复制失败,请手动复制",slashCopyEmpty:"还没有可复制的助手回复",mermaidRendering:"图表渲染中…",mermaidRenderFailed:"图表渲染失败,以下为原始代码:",mermaidRenderSetting:"渲染 Mermaid 图表",mermaidRenderSettingDesc:"开启后,消息中的 ```mermaid 代码块会渲染为图表;关闭则始终按普通代码块显示,跳过图表引擎的加载与渲染开销",recentProjects:"最近项目",runningConversations:"运行的对话",subagentBadge:"子代理",subagentTitle:"子代理 · {title}",historySessions:"历史对话",openHistory:"历史对话",openFiles:"文件列表",streaming:"进行中…",noHistory:"还没有历史对话",current:"当前",messageCount:"{n} 条消息",tuiTip:"pi 终端(TUI)中的对话",deleteProject:"从最近项目移出",deleteProjectConfirm:"确认移出",deleteSession:"删除该对话记录(不可恢复)",deleteSessionConfirm:"确认删除",renameSession:"重命名该对话",renameSessionPlaceholder:"输入新名称…",renameSessionConfirm:"重命名",dismissConversation:"从运行列表移出(历史记录保留)",dismissConversationConfirm:"确认移出",collapseSection:"折叠",expandSection:"展开",emptyChat:"空对话",editReask:"编辑重问",editReaskTip:"修改此问题,并从这里重新提问(会新建一个分支对话,原对话保留)",reaskFromHere:"从此处重新提问",editPlaceholder:"修改问题内容…",editHint:"⌘/Ctrl+Enter 提交 · Esc 取消",editAttachmentHint:"原附件已保留,可粘贴/拖入新图片或文件 · ⌘/Ctrl+Enter 提交 · Esc 取消",expandMsg:"展开",collapseMsg:"收起",toolCalls:"工具调用",bashRuns:"终端运行",images:"图片",update:"更新",updateTip:"检查并更新 pi-web-ui",currentVersion:"当前版本",latestVersion:"最新版本",checkingUpdate:"检查中…",checkUpdate:"检查更新",upToDate:"已是最新版本",updateAvailable:"发现新版本 v{version}",updateJustPublished:"v{version} 刚刚发布,npm 缓存可能尚未同步——若未检测到新版本,请稍后重新检查",updateNow:"在终端中更新",updateTabTitle:"更新 pi-web-ui",updateTerminalHint:"点击后会在可见终端中运行 npm i -g pi-web-ui@latest;完成后重启服务生效(pi-web-ui server restart)。",updatesAllTitle:"全部组件更新",updatesAllBadge:"{n} 个更新",updatesAllUpToDate:"全部组件均为最新",kindWebUi:"Web 界面",kindPiCore:"核心",kindPackage:"组件",updatesAllRefresh:"重新检查全部",updateCheckFailed:"检查失败",updateBtn:"更新",updateAllBtn:"全部更新",updatePkgTabTitle:"更新 {name}",updateAllTabTitle:"更新全部组件",computer:"此电脑",rootDir:"根目录",noFiles:"暂无文件",filesTruncated:"目录过大,列表已截断,仅显示前 2000 项",linkFolderTip:"链接文件夹路径到对话",attachInlineTip:"附加内容到对话",referenceTip:"仅引用路径(AI 按需读取)",previewFile:"预览",downloadFile:"下载文件",downloadFailed:"下载失败:{error}",fileNotFoundShort:"文件不存在",pluginMountFailed:"插件 {name} 挂载失败",liveOutputOmitted:`…[前 {n} 字符已省略]…
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BI5_3AOv.js","assets/markdown-BJJLXG-8.js","assets/TerminalPanel-CoPFNu1d.js","assets/xterm-D1D2FVe3.js","assets/react-ezqUM1Or.js","assets/TerminalPanel-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{R as Ye,a as l,j as e,M as gi,b as fi,c as xi}from"./markdown-BJJLXG-8.js";import{r as hn}from"./react-ezqUM1Or.js";(function(){const s=document.createElement("link").relList;if(s&&s.supports&&s.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))r(c);new MutationObserver(c=>{for(const i of c)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(c){const i={};return c.integrity&&(i.integrity=c.integrity),c.referrerPolicy&&(i.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?i.credentials="include":c.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(c){if(c.ep)return;c.ep=!0;const i=n(c);fetch(c.href,i)}})();var ht={},Ts;function yi(){if(Ts)return ht;Ts=1;var t=hn();return ht.createRoot=t.createRoot,ht.hydrateRoot=t.hydrateRoot,ht}var vi=yi();const bi="modulepreload",ki=function(t){return"/"+t},Es={},gn=function(s,n,r){let c=Promise.resolve();if(n&&n.length>0){let a=function(m){return Promise.all(m.map(y=>Promise.resolve(y).then(g=>({status:"fulfilled",value:g}),g=>({status:"rejected",reason:g}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),u=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));c=a(n.map(m=>{if(m=ki(m),m in Es)return;Es[m]=!0;const y=m.endsWith(".css"),g=y?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${m}"]${g}`))return;const x=document.createElement("link");if(x.rel=y?"stylesheet":bi,y||(x.as="script"),x.crossOrigin="",x.href=m,u&&x.setAttribute("nonce",u),document.head.appendChild(x),y)return new Promise((b,E)=>{x.addEventListener("load",b),x.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${m}`)))})}))}function i(a){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=a,window.dispatchEvent(o),!o.defaultPrevented)throw a}return c.then(a=>{for(const o of a||[])o.status==="rejected"&&i(o.reason);return s().catch(i)})};var fn={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Ps=Ye.createContext&&Ye.createContext(fn),ji=["attr","size","title"];function wi(t,s){if(t==null)return{};var n,r,c=Ni(t,s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],s.indexOf(n)===-1&&{}.propertyIsEnumerable.call(t,n)&&(c[n]=t[n])}return c}function Ni(t,s){if(t==null)return{};var n={};for(var r in t)if({}.hasOwnProperty.call(t,r)){if(s.indexOf(r)!==-1)continue;n[r]=t[r]}return n}function bt(){return bt=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var n=arguments[s];for(var r in n)({}).hasOwnProperty.call(n,r)&&(t[r]=n[r])}return t},bt.apply(null,arguments)}function Ms(t,s){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);s&&(r=r.filter(function(c){return Object.getOwnPropertyDescriptor(t,c).enumerable})),n.push.apply(n,r)}return n}function kt(t){for(var s=1;s<arguments.length;s++){var n=arguments[s]!=null?arguments[s]:{};s%2?Ms(Object(n),!0).forEach(function(r){Ci(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ms(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function Ci(t,s,n){return(s=Si(s))in t?Object.defineProperty(t,s,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[s]=n,t}function Si(t){var s=Ti(t,"string");return typeof s=="symbol"?s:s+""}function Ti(t,s){if(typeof t!="object"||!t)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,s);if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}function xn(t){return t&&t.map((s,n)=>Ye.createElement(s.tag,kt({key:n},s.attr),xn(s.child)))}function se(t){return s=>Ye.createElement(Ei,bt({attr:kt({},t.attr)},s),xn(t.child))}function Ei(t){var s=n=>{var r=t.attr,c=t.size,i=t.title,a=wi(t,ji),o=c||n.size||"1em",u;return n.className&&(u=n.className),t.className&&(u=(u?u+" ":"")+t.className),Ye.createElement("svg",bt({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,r,a,{className:u,style:kt(kt({color:t.color||n.color},n.style),t.style),height:o,width:o,xmlns:"http://www.w3.org/2000/svg"}),i&&Ye.createElement("title",null,i),t.children)};return Ps!==void 0?Ye.createElement(Ps.Consumer,null,n=>s(n)):s(fn)}function Pi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"11",cy:"11",r:"8"},child:[]},{tag:"line",attr:{x1:"21",y1:"21",x2:"16.65",y2:"16.65"},child:[]},{tag:"line",attr:{x1:"8",y1:"11",x2:"14",y2:"11"},child:[]}]})(t)}function Mi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"11",cy:"11",r:"8"},child:[]},{tag:"line",attr:{x1:"21",y1:"21",x2:"16.65",y2:"16.65"},child:[]},{tag:"line",attr:{x1:"11",y1:"8",x2:"11",y2:"14"},child:[]},{tag:"line",attr:{x1:"8",y1:"11",x2:"14",y2:"11"},child:[]}]})(t)}function xt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"13 2 3 14 12 14 11 22 21 10 12 10 13 2"},child:[]}]})(t)}function Pe(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"18",y1:"6",x2:"6",y2:"18"},child:[]},{tag:"line",attr:{x1:"6",y1:"6",x2:"18",y2:"18"},child:[]}]})(t)}function yn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"11 5 6 9 2 9 2 15 6 15 11 19 11 5"},child:[]},{tag:"path",attr:{d:"M19.07 4.93a10 10 0 0 1 0 14.14M15.54 8.46a5 5 0 0 1 0 7.07"},child:[]}]})(t)}function Rs(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M17 21v-2a4 4 0 0 0-4-4H5a4 4 0 0 0-4 4v2"},child:[]},{tag:"circle",attr:{cx:"9",cy:"7",r:"4"},child:[]},{tag:"path",attr:{d:"M23 21v-2a4 4 0 0 0-3-3.87"},child:[]},{tag:"path",attr:{d:"M16 3.13a4 4 0 0 1 0 7.75"},child:[]}]})(t)}function Ri(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"},child:[]},{tag:"polyline",attr:{points:"17 8 12 3 7 8"},child:[]},{tag:"line",attr:{x1:"12",y1:"3",x2:"12",y2:"15"},child:[]}]})(t)}function Ii(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"},child:[]},{tag:"path",attr:{d:"M7 11V7a5 5 0 0 1 9.9-1"},child:[]}]})(t)}function Ae(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"3 6 5 6 21 6"},child:[]},{tag:"path",attr:{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"},child:[]},{tag:"line",attr:{x1:"10",y1:"11",x2:"10",y2:"17"},child:[]},{tag:"line",attr:{x1:"14",y1:"11",x2:"14",y2:"17"},child:[]}]})(t)}function tt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"4 17 10 11 4 5"},child:[]},{tag:"line",attr:{x1:"12",y1:"19",x2:"20",y2:"19"},child:[]}]})(t)}function Is(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"circle",attr:{cx:"12",cy:"12",r:"6"},child:[]},{tag:"circle",attr:{cx:"12",cy:"12",r:"2"},child:[]}]})(t)}function Ls(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M20.59 13.41l-7.17 7.17a2 2 0 0 1-2.83 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82z"},child:[]},{tag:"line",attr:{x1:"7",y1:"7",x2:"7.01",y2:"7"},child:[]}]})(t)}function Li(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"5"},child:[]},{tag:"line",attr:{x1:"12",y1:"1",x2:"12",y2:"3"},child:[]},{tag:"line",attr:{x1:"12",y1:"21",x2:"12",y2:"23"},child:[]},{tag:"line",attr:{x1:"4.22",y1:"4.22",x2:"5.64",y2:"5.64"},child:[]},{tag:"line",attr:{x1:"18.36",y1:"18.36",x2:"19.78",y2:"19.78"},child:[]},{tag:"line",attr:{x1:"1",y1:"12",x2:"3",y2:"12"},child:[]},{tag:"line",attr:{x1:"21",y1:"12",x2:"23",y2:"12"},child:[]},{tag:"line",attr:{x1:"4.22",y1:"19.78",x2:"5.64",y2:"18.36"},child:[]},{tag:"line",attr:{x1:"18.36",y1:"5.64",x2:"19.78",y2:"4.22"},child:[]}]})(t)}function jt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},child:[]}]})(t)}function Di(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"4",y1:"21",x2:"4",y2:"14"},child:[]},{tag:"line",attr:{x1:"4",y1:"10",x2:"4",y2:"3"},child:[]},{tag:"line",attr:{x1:"12",y1:"21",x2:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"12",y1:"8",x2:"12",y2:"3"},child:[]},{tag:"line",attr:{x1:"20",y1:"21",x2:"20",y2:"16"},child:[]},{tag:"line",attr:{x1:"20",y1:"12",x2:"20",y2:"3"},child:[]},{tag:"line",attr:{x1:"1",y1:"14",x2:"7",y2:"14"},child:[]},{tag:"line",attr:{x1:"9",y1:"8",x2:"15",y2:"8"},child:[]},{tag:"line",attr:{x1:"17",y1:"16",x2:"23",y2:"16"},child:[]}]})(t)}function wt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"3"},child:[]},{tag:"path",attr:{d:"M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z"},child:[]}]})(t)}function vn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"22",y1:"2",x2:"11",y2:"13"},child:[]},{tag:"polygon",attr:{points:"22 2 15 22 11 13 2 9 22 2"},child:[]}]})(t)}function Nt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"11",cy:"11",r:"8"},child:[]},{tag:"line",attr:{x1:"21",y1:"21",x2:"16.65",y2:"16.65"},child:[]}]})(t)}function Ai(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"},child:[]},{tag:"polyline",attr:{points:"17 21 17 13 7 13 7 21"},child:[]},{tag:"polyline",attr:{points:"7 3 7 8 15 8"},child:[]}]})(t)}function bn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"1 4 1 10 7 10"},child:[]},{tag:"path",attr:{d:"M3.51 15a9 9 0 1 0 2.13-9.36L1 10"},child:[]}]})(t)}function rt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"23 4 23 10 17 10"},child:[]},{tag:"polyline",attr:{points:"1 20 1 14 7 14"},child:[]},{tag:"path",attr:{d:"M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15"},child:[]}]})(t)}function He(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",y1:"5",x2:"12",y2:"19"},child:[]},{tag:"line",attr:{x1:"5",y1:"12",x2:"19",y2:"12"},child:[]}]})(t)}function ao(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"5 3 19 12 5 21 5 3"},child:[]}]})(t)}function _i(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"},child:[]}]})(t)}function Ds(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"16.5",y1:"9.4",x2:"7.5",y2:"4.21"},child:[]},{tag:"path",attr:{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"},child:[]},{tag:"polyline",attr:{points:"3.27 6.96 12 12.01 20.73 6.96"},child:[]},{tag:"line",attr:{x1:"12",y1:"22.08",x2:"12",y2:"12"},child:[]}]})(t)}function Bi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"1"},child:[]},{tag:"circle",attr:{cx:"19",cy:"12",r:"1"},child:[]},{tag:"circle",attr:{cx:"5",cy:"12",r:"1"},child:[]}]})(t)}function Fi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M8 3v3a2 2 0 0 1-2 2H3m18 0h-3a2 2 0 0 1-2-2V3m0 18v-3a2 2 0 0 1 2-2h3M3 16h3a2 2 0 0 1 2 2v3"},child:[]}]})(t)}function st(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"},child:[]}]})(t)}function $i(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"3",y1:"12",x2:"21",y2:"12"},child:[]},{tag:"line",attr:{x1:"3",y1:"6",x2:"21",y2:"6"},child:[]},{tag:"line",attr:{x1:"3",y1:"18",x2:"21",y2:"18"},child:[]}]})(t)}function Hi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M8 3H5a2 2 0 0 0-2 2v3m18 0V5a2 2 0 0 0-2-2h-3m0 18h3a2 2 0 0 0 2-2v-3M3 16v3a2 2 0 0 0 2 2h3"},child:[]}]})(t)}function Oi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"15 3 21 3 21 9"},child:[]},{tag:"polyline",attr:{points:"9 21 3 21 3 15"},child:[]},{tag:"line",attr:{x1:"21",y1:"3",x2:"14",y2:"10"},child:[]},{tag:"line",attr:{x1:"3",y1:"21",x2:"10",y2:"14"},child:[]}]})(t)}function Ki(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"},child:[]},{tag:"path",attr:{d:"M7 11V7a5 5 0 0 1 10 0v4"},child:[]}]})(t)}function Gt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"},child:[]},{tag:"path",attr:{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"},child:[]}]})(t)}function Ct(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polygon",attr:{points:"12 2 2 7 12 12 22 7 12 2"},child:[]},{tag:"polyline",attr:{points:"2 17 12 22 22 17"},child:[]},{tag:"polyline",attr:{points:"2 12 12 17 22 12"},child:[]}]})(t)}function Wi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"12",y1:"16",x2:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"12",y1:"8",x2:"12.01",y2:"8"},child:[]}]})(t)}function Ui(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"3",width:"18",height:"18",rx:"2",ry:"2"},child:[]},{tag:"circle",attr:{cx:"8.5",cy:"8.5",r:"1.5"},child:[]},{tag:"polyline",attr:{points:"21 15 16 10 5 21"},child:[]}]})(t)}function qi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"3",y:"3",width:"7",height:"7"},child:[]},{tag:"rect",attr:{x:"14",y:"3",width:"7",height:"7"},child:[]},{tag:"rect",attr:{x:"14",y:"14",width:"7",height:"7"},child:[]},{tag:"rect",attr:{x:"3",y:"14",width:"7",height:"7"},child:[]}]})(t)}function zi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"2",y1:"12",x2:"22",y2:"12"},child:[]},{tag:"path",attr:{d:"M12 2a15.3 15.3 0 0 1 4 10 15.3 15.3 0 0 1-4 10 15.3 15.3 0 0 1-4-10 15.3 15.3 0 0 1 4-10z"},child:[]}]})(t)}function As(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M9 19c-5 1.5-5-2.5-7-3m14 6v-3.87a3.37 3.37 0 0 0-.94-2.61c3.14-.35 6.44-1.54 6.44-7A5.44 5.44 0 0 0 20 4.77 5.07 5.07 0 0 0 19.91 1S18.73.65 16 2.48a13.38 13.38 0 0 0-7 0C6.27.65 5.09 1 5.09 1A5.07 5.07 0 0 0 5 4.77a5.44 5.44 0 0 0-1.5 3.78c0 5.42 3.3 6.61 6.44 7A3.37 3.37 0 0 0 9 18.13V22"},child:[]}]})(t)}function yt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"6",y1:"3",x2:"6",y2:"15"},child:[]},{tag:"circle",attr:{cx:"18",cy:"6",r:"3"},child:[]},{tag:"circle",attr:{cx:"6",cy:"18",r:"3"},child:[]},{tag:"path",attr:{d:"M18 9a9 9 0 0 1-9 9"},child:[]}]})(t)}function Je(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z"},child:[]}]})(t)}function Vi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M13 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V9z"},child:[]},{tag:"polyline",attr:{points:"13 2 13 9 20 9"},child:[]}]})(t)}function kn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"},child:[]},{tag:"polyline",attr:{points:"14 2 14 8 20 8"},child:[]},{tag:"line",attr:{x1:"16",y1:"13",x2:"8",y2:"13"},child:[]},{tag:"line",attr:{x1:"16",y1:"17",x2:"8",y2:"17"},child:[]},{tag:"polyline",attr:{points:"10 9 9 9 8 9"},child:[]}]})(t)}function Qt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"},child:[]},{tag:"circle",attr:{cx:"12",cy:"12",r:"3"},child:[]}]})(t)}function Yt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M12 20h9"},child:[]},{tag:"path",attr:{d:"M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"},child:[]}]})(t)}function St(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M17 3a2.828 2.828 0 1 1 4 4L7.5 20.5 2 22l1.5-5.5L17 3z"},child:[]}]})(t)}function ls(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4"},child:[]},{tag:"polyline",attr:{points:"7 10 12 15 17 10"},child:[]},{tag:"line",attr:{x1:"12",y1:"15",x2:"12",y2:"3"},child:[]}]})(t)}function lt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"4",y:"4",width:"16",height:"16",rx:"2",ry:"2"},child:[]},{tag:"rect",attr:{x:"9",y:"9",width:"6",height:"6"},child:[]},{tag:"line",attr:{x1:"9",y1:"1",x2:"9",y2:"4"},child:[]},{tag:"line",attr:{x1:"15",y1:"1",x2:"15",y2:"4"},child:[]},{tag:"line",attr:{x1:"9",y1:"20",x2:"9",y2:"23"},child:[]},{tag:"line",attr:{x1:"15",y1:"20",x2:"15",y2:"23"},child:[]},{tag:"line",attr:{x1:"20",y1:"9",x2:"23",y2:"9"},child:[]},{tag:"line",attr:{x1:"20",y1:"14",x2:"23",y2:"14"},child:[]},{tag:"line",attr:{x1:"1",y1:"9",x2:"4",y2:"9"},child:[]},{tag:"line",attr:{x1:"1",y1:"14",x2:"4",y2:"14"},child:[]}]})(t)}function Gi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"9 10 4 15 9 20"},child:[]},{tag:"path",attr:{d:"M20 4v7a4 4 0 0 1-4 4H4"},child:[]}]})(t)}function jn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"rect",attr:{x:"9",y:"9",width:"13",height:"13",rx:"2",ry:"2"},child:[]},{tag:"path",attr:{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"},child:[]}]})(t)}function Qi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"16 18 22 12 16 6"},child:[]},{tag:"polyline",attr:{points:"8 6 2 12 8 18"},child:[]}]})(t)}function _s(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"polyline",attr:{points:"12 6 12 12 16 14"},child:[]}]})(t)}function wn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"13 17 18 12 13 7"},child:[]},{tag:"polyline",attr:{points:"6 17 11 12 6 7"},child:[]}]})(t)}function Nn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"11 17 6 12 11 7"},child:[]},{tag:"polyline",attr:{points:"18 17 13 12 18 7"},child:[]}]})(t)}function ut(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"18 15 12 9 6 15"},child:[]}]})(t)}function Pt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"9 18 15 12 9 6"},child:[]}]})(t)}function Ge(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"6 9 12 15 18 9"},child:[]}]})(t)}function pt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"20 6 9 17 4 12"},child:[]}]})(t)}function Yi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14"},child:[]},{tag:"polyline",attr:{points:"22 4 12 14.01 9 11.01"},child:[]}]})(t)}function Lt(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z"},child:[]},{tag:"polyline",attr:{points:"3.27 6.96 12 12.01 20.73 6.96"},child:[]},{tag:"line",attr:{x1:"12",y1:"22.08",x2:"12",y2:"12"},child:[]}]})(t)}function Ji(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z"},child:[]},{tag:"path",attr:{d:"M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z"},child:[]}]})(t)}function Xi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9"},child:[]},{tag:"path",attr:{d:"M13.73 21a2 2 0 0 1-3.46 0"},child:[]}]})(t)}function Cn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",y1:"19",x2:"12",y2:"5"},child:[]},{tag:"polyline",attr:{points:"5 12 12 5 19 12"},child:[]}]})(t)}function Sn(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"line",attr:{x1:"12",y1:"5",x2:"12",y2:"19"},child:[]},{tag:"polyline",attr:{points:"19 12 12 19 5 12"},child:[]}]})(t)}function Zi(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"21 8 21 21 3 21 3 8"},child:[]},{tag:"rect",attr:{x:"1",y:"3",width:"22",height:"5"},child:[]},{tag:"line",attr:{x1:"10",y1:"12",x2:"14",y2:"12"},child:[]}]})(t)}function ea(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z"},child:[]},{tag:"line",attr:{x1:"12",y1:"9",x2:"12",y2:"13"},child:[]},{tag:"line",attr:{x1:"12",y1:"17",x2:"12.01",y2:"17"},child:[]}]})(t)}function ta(t){return se({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"circle",attr:{cx:"12",cy:"12",r:"10"},child:[]},{tag:"line",attr:{x1:"12",y1:"8",x2:"12",y2:"12"},child:[]},{tag:"line",attr:{x1:"12",y1:"16",x2:"12.01",y2:"16"},child:[]}]})(t)}function sa(t){return t.map(s=>s.kind==="package"?`pi update npm:${s.name}`:`npm i -g ${s.name}@latest`).join("; ")}function Ue(){if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID();const t=new Uint8Array(16);if(typeof crypto<"u"&&typeof crypto.getRandomValues=="function")crypto.getRandomValues(t);else for(let n=0;n<16;n++)t[n]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const s=[...t].map(n=>n.toString(16).padStart(2,"0")).join("");return`${s.slice(0,8)}-${s.slice(8,12)}-${s.slice(12,16)}-${s.slice(16,20)}-${s.slice(20)}`}function ze({trigger:t,open:s,onOpenChange:n,children:r,align:c="right",fit:i=!1,direction:a="down",menuClassName:o,menuRef:u,menuStyle:m}){const y=l.useRef(null);return l.useEffect(()=>{if(!s)return;const g=b=>{y.current&&!y.current.contains(b.target)&&n(!1)},x=b=>{b.key==="Escape"&&n(!1)};return document.addEventListener("mousedown",g),document.addEventListener("keydown",x),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",x)}},[s,n]),e.jsxs("div",{className:`dropdown ${c} ${i?"fit":""} ${a==="up"?"dd-up":""}`,ref:y,children:[e.jsxs("button",{type:"button",className:"chip",onClick:()=>n(!s),"aria-expanded":s,children:[t,e.jsx(Ge,{className:`dd-caret ${s?"up":""}`})]}),s&&e.jsx("div",{className:`dd-menu ${o??""}`,ref:u,style:m,children:r})]})}function Ie({active:t,disabled:s=!1,title:n,onClick:r,children:c}){return e.jsx("button",{type:"button",className:`dd-item ${t?"active":""}`,disabled:s,title:n,onClick:r,children:c})}const Tn="pi-web-ui:lang",Bs={docTitle:"pi-web-ui — pi 编码智能体",cancel:"取消",ok:"确定",save:"保存",close:"关闭",widgetExpand:"点击放大查看完整输出",collapsePanel:"收起面板",expandPanel:"展开面板",dragToResize:"拖拽调整宽度 · 双击复位",loading:"加载中…",connected:"已连接",connecting:"连接中…",reconnecting:"重连中…",language:"语言",langZh:"中文",langEn:"English",githubRepo:"GitHub 仓库(xing-shuyin/pi-web-ui)",copy:"复制",viewSwitch:"视图切换",chat:"对话",terminal:"终端",selectModel:"选择模型",availableModels:"可用模型",allProviders:"全部",providers:"服务商",noModels:"暂无可用模型(请先配置 API 密钥)",reasoning:"推理",vision:"识图",refreshModels:"刷新模型列表(保留手填,合并新增)",manageModels:"⚙ 管理模型(新增 / 修改)",manageModelsTitle:"管理模型",thinkingLevel:"思考强度",thinking:"思考",thinkingChip:"思考:{level}",sound:"声音",theme:"主题",themeDefault:"深色(默认)",newChat:"新对话",more:"更多",newChatTip:"新建对话(每个浏览器独立保存会话)","thinking.off":"关闭","thinking.minimal":"极简","thinking.low":"低","thinking.medium":"中","thinking.high":"高","thinking.xhigh":"极高","thinking.max":"最大",thinkingUnsupported:"当前模型不支持该级别,已按模型能力就近生效",context:"上下文",contextUsage:"上下文用量",cumulativeCost:"累计成本",sessionMessages:"会话消息数",messages:"消息",pluginStatus:"插件状态",engineBadge:"引擎",working:"工作中",queued:"排队",enterPath:"输入路径,Enter 切换",cwdTip:"工作目录:{path}(点击切换)",cwdGoUp:"上级目录",cwdPickCurrent:"选择当前目录",cwdChoose:"选择",cwdEnter:"进入",cwdEmpty:"(空目录)",cwdNewFolder:"新建文件夹",cwdNewName:"文件夹名称",cwdCreate:"创建",cwdCancel:"取消",cacheHit:"缓存命中",cacheHitTip:"缓存读取 {read} · 缓存写入 {write} · 未命中 {miss}(共 {input} 输入 token)",tps:"t/s",rateTip:"实时生成速率(估算)",folderRef:"文件夹引用:{path}",refOnly:"仅引用:{path}",attachContent:"附加内容:{path}",attachLines:"附加选中行:{path}(第 {start}-{end} 行)",attachImage:"图片:{name}",attachFile:"文件:{name}",removeAttachment:"移除附件",attachHint:"将随下一条消息发送",uploadFile:"添加文件(图片/文本/任意文件,也可直接拖入或粘贴截图)",dropHereToAttach:"松开以添加文件",imageNotSupported:"当前模型不支持识图:图片将交给视觉桥转写(若未配置视觉模型则可能被忽略)",imageLoadFailed:"图片读取失败:{name}",fileLoadFailed:"文件读取失败:{name}",fileTooLarge:"文件过大已跳过(>{size}MB):{name}",foldersNotSupported:"不支持直接拖入文件夹,请展开后选择文件",placeholderStreaming:"智能体正在工作中…回车插队发送,或点「排队」等回答结束后发送",placeholderIdle:"给 pi 发送消息 — Enter 发送,/ 查看命令",placeholderConnecting:"正在连接服务器…",stopAgent:"停止智能体",stop:"停止",bgTasks:"后台任务",bgTasksTip:"AI 在后台启动的服务(npm run dev & 等)——可逐个停止或全部关闭,对话结束后仍保留",bgTasksEmpty:"暂无后台任务",bgTasksDesc:"AI 运行中启动并仍在监听的进程(按监听端口检测)",bgTaskPort:"端口",bgTaskPid:"PID",bgTaskSince:"启动",bgTaskStop:"停止",bgTaskStopAll:"全部关闭",bgTaskRefresh:"刷新",bgTaskJustNow:"刚刚",bgTaskMinutes:"{n} 分钟前",bgTaskHours:"{n} 小时前",bgTaskDays:"{n} 天前",stopBash:"停止",stopBashTip:"停止正在运行的 bash 命令(对话继续)",supplement:"排队",supplementTip:"加入队列:AI 回答完全结束后才发送(不打断)",queueSteerTag:"插队",queueFollowTag:"排队",queueRemoveTip:"移除此排队消息",sendTip:"发送(Enter)",slashCommands:"命令",slashMenuHint:"↑↓ 选择 · Enter/Tab 补全",slashHelpTitle:"pi 命令",slashHelpHint:"输入 / 随时打开命令列表",slashLoading:"命令列表加载中…(连接服务器后可用)",slashBuiltin:"内置",slashExtension:"扩展",slashPrompt:"模板",slashSkill:"技能",slashPlugin:"插件",slashCopied:"已复制上一条助手回复",slashCopyFailed:"复制失败,请手动复制",slashCopyEmpty:"还没有可复制的助手回复",mermaidRendering:"图表渲染中…",mermaidRenderFailed:"图表渲染失败,以下为原始代码:",mermaidRenderSetting:"渲染 Mermaid 图表",mermaidRenderSettingDesc:"开启后,消息中的 ```mermaid 代码块会渲染为图表;关闭则始终按普通代码块显示,跳过图表引擎的加载与渲染开销",recentProjects:"最近项目",runningConversations:"运行的对话",subagentBadge:"子代理",convErrorBadge:"子代理运行报错:{error}",subagentTitle:"子代理 · {title}",historySessions:"历史对话",openHistory:"历史对话",openFiles:"文件列表",streaming:"进行中…",noHistory:"还没有历史对话",current:"当前",messageCount:"{n} 条消息",tuiTip:"pi 终端(TUI)中的对话",deleteProject:"从最近项目移出",deleteProjectConfirm:"确认移出",deleteSession:"删除该对话记录(不可恢复)",deleteSessionConfirm:"确认删除",renameSession:"重命名该对话",renameSessionPlaceholder:"输入新名称…",renameSessionConfirm:"重命名",dismissConversation:"从运行列表移出(历史记录保留)",dismissConversationConfirm:"确认移出",collapseSection:"折叠",expandSection:"展开",emptyChat:"空对话",editReask:"编辑重问",editReaskTip:"修改此问题,并从这里重新提问(会新建一个分支对话,原对话保留)",reaskFromHere:"从此处重新提问",editPlaceholder:"修改问题内容…",editHint:"⌘/Ctrl+Enter 提交 · Esc 取消",editAttachmentHint:"原附件已保留,可粘贴/拖入新图片或文件 · ⌘/Ctrl+Enter 提交 · Esc 取消",expandMsg:"展开",collapseMsg:"收起",toolCalls:"工具调用",bashRuns:"终端运行",images:"图片",update:"更新",updateTip:"检查并更新 pi-web-ui",currentVersion:"当前版本",latestVersion:"最新版本",checkingUpdate:"检查中…",checkUpdate:"检查更新",upToDate:"已是最新版本",updateAvailable:"发现新版本 v{version}",updateJustPublished:"v{version} 刚刚发布,npm 缓存可能尚未同步——若未检测到新版本,请稍后重新检查",updateNow:"在终端中更新",updateTabTitle:"更新 pi-web-ui",updateTerminalHint:"点击后会在可见终端中运行 npm i -g pi-web-ui@latest;完成后重启服务生效(pi-web-ui server restart)。",updatesAllTitle:"全部组件更新",updatesAllBadge:"{n} 个更新",updatesAllUpToDate:"全部组件均为最新",kindWebUi:"Web 界面",kindPiCore:"核心",kindPackage:"组件",updatesAllRefresh:"重新检查全部",updateCheckFailed:"检查失败",updateBtn:"更新",updateAllBtn:"全部更新",updatePkgTabTitle:"更新 {name}",updateAllTabTitle:"更新全部组件",computer:"此电脑",rootDir:"根目录",noFiles:"暂无文件",filesTruncated:"目录过大,列表已截断,仅显示前 2000 项",linkFolderTip:"链接文件夹路径到对话",attachInlineTip:"附加内容到对话",referenceTip:"仅引用路径(AI 按需读取)",previewFile:"预览",downloadFile:"下载文件",downloadFailed:"下载失败:{error}",fileNotFoundShort:"文件不存在",pluginMountFailed:"插件 {name} 挂载失败",liveOutputOmitted:`…[前 {n} 字符已省略]…
|
|
3
3
|
`,uploadToFolder:"上传文件到此文件夹",uploadToCurrentDir:"上传文件到当前目录",protocolMismatch:"页面版本与服务器不一致(应用刚更新过),请刷新页面以恢复全部功能。",selectLinesHint:"点击选择行;拖拽或 Shift+点击选择范围",enableWrap:"开启自动换行",disableWrap:"关闭自动换行",selectedRange:"已选 {n} 行(第 {start}-{end} 行)",fileLines:"{n} 行",selectAll:"全选",clearSelection:"清除",addToChat:"添加到对话",addedToChat:"已添加",previewTruncated:"⚠ 文件过大,仅预览前 512KB",previewLinesTruncated:"… 文件行数过多,仅显示前 {n} 行",binaryFile:"🔣 二进制文件,已显示前 4KB 十六进制",binaryHexTruncated:"(文件更大,可下载完整文件)",previewNotSupported:"该类型文件不支持预览(仅图片 / 视频 / 文本)",emptyFile:"(空文件)",editFile:"编辑文件",exitEditFile:"退出编辑",saveFile:"保存文件",discardFileChanges:"放弃未保存的修改?",fileSaved:"已保存",fileEditTruncated:"文件过大,预览不完整,无法编辑",showMarkdownSource:"显示 Markdown 原文",showMarkdownPreview:"显示 Markdown 预览",fullscreen:"全屏",exitFullscreen:"退出全屏",zoomIn:"放大字号",zoomOut:"缩小字号",resetZoom:"重置缩放",pluginRequest:"插件请求",modelQuestion:"模型提问",modelQuestionCustom:"补充回答(可选)",modelQuestionSubmit:"提交回答",noOptions:"(无选项)",inputPlaceholder:"输入内容",questionTimeout:"⏳ 剩余 {s} 秒,超时将自动取消",questionTimeoutExpired:"提问已超时,正在恢复对话…",modelNoVision:"当前模型 {name} 不支持图片,请切换到 DeepSeek V4 Flash Vision (exp)",dshSkillsNote:"DSH 引擎使用运行时内置技能(dsh-skill),暂不支持在设置面板启停",dshExtensionsNote:"DSH 引擎无 pi 扩展体系,能力由运行时内置(MCP/subagent/goal/plan/skill 等)",dshReviewPromptNote:"DSH 无独立审查会话:此指令将随目标轮次附加到系统提示词,供模型在目标轮次中遵守",dshVisionHiddenNote:"DSH 引擎直接支持图片输入(仅 DeepSeek V4 Flash Vision (exp) 模型),无需视觉桥转写",dshNoReviewModel:"DSH 无独立审查模型:目标由模型自判定完成/受阻,轮次上限即自动迭代次数",soundHeader:"声音提示",enableSound:"启用声音",preview:"试听",volume:"音量",notifyHeader:"桌面通知",notifyEnable:"启用桌面通知(PWA)",notifyEnableDesc:"会话完成或需要你输入时,即使切到其他应用也会提醒(需授权,仅页面前台无焦点时触发)。",notifyDenied:"通知权限已被拒绝 —— 请在浏览器/系统设置里为本站点开启通知。",notifyUnsupported:"此浏览器不支持通知。",notifyDoneTitle:"任务完成",notifyDoneBody:"会话已完成,等待你的输入。",notifyQuestionTitle:"需要你回答",notifyQuestionBody:"pi 正在等你回答一个问题。",notifyErrorTitle:"出错了",notifyErrorBody:"一个会话报告了错误。","sound.question":"问卷弹出","sound.question.desc":"ask_user_question 出现时","sound.done":"回复结束","sound.done.desc":"智能体完成一轮回答时","sound.start":"回复开始","sound.start.desc":"智能体开始新一轮时","sound.error":"出错","sound.error.desc":"出现错误提示时",setupTitle:"未检测到 pi agent 配置",setupDesc:"pi-web-ui 需要 pi 的配置目录(~/.pi/agent)和至少一个 API 密钥才能运行智能体。pi 内置了 openai、anthropic、deepseek 等服务商——选一个填密钥即可,全程无需打开终端。",installFailed:"✖ pi agent 安装失败:",retryInstall:"重试安装",skip:"跳过",installDone:"✅ pi agent CLI 已安装。选择服务商并填入 API 密钥即可开始对话:",cliReadyHint:"✅ 本地已检测到 pi agent,选择服务商并填入 API 密钥即可开始对话:",provider:"服务商",configured:"已配置",providerKeyReady:"该服务商已配置密钥,可直接使用或更换新密钥。",apiKey:"API 密钥",saving:"保存中…",saveAndStart:"保存并开始使用",recheck:"重新检测",installing:"正在安装 pi agent CLI…",autoInstall:"自动安装 pi agent",attachment:"附件",plugin:"插件",unknown:"未知",thinkingWait:"正在思考",exitCode:"退出码 {code}",cancelled:"已取消",truncated:"… 内容过长,当前视图已截断",outputTruncated:"… 输出过长,当前视图已截断",refOnlyShort:"仅引用",folderRefShort:"文件夹 · 仅引用",inlineLines:"内联 · {n} 行",inlineLinesRange:"行 {start}-{end}",image:"🖼 图片",bridgedVision:"👁 已转写",bridgedVisionDetail:"图片已由视觉桥转写(当前模型不支持识图)",folderNotExpanded:"文件夹,未展开内容 —— 智能体会按需浏览目录",fileNotExpanded:"文件较大({size}),未展开内容 —— 智能体会按需读取","role.user":"你","role.assistant":"pi","role.tool":"工具","role.bash":"终端","role.branch":"分支摘要","role.compaction":"上下文已压缩",directory:"目录",waitingResponse:"正在等待模型响应…",backToBottom:"回到底部",questionNavTitle:"问题列表",searchPlaceholder:"在对话中搜索…",searchNoResults:"无结果",searchModels:"搜索模型…",noModelMatches:"无匹配模型",modelUsedCount:"已用 {n} 次",searchGlobal:"搜索",searchGlobalTip:"全局搜索:对话 / 项目 / 文件(Ctrl+K)",gsPlaceholder:"搜索项目、历史对话、工作区文件…",gsHint:"输入关键词:搜索历史对话全文(含 AI 回复)、最近项目与当前项目的文件名",gsSessions:"对话",gsProjects:"项目",gsFiles:"文件",gsNoResults:"无匹配结果",gsSearching:"正在搜索…",gsTruncated:"匹配过多,仅显示部分结果",gsCurrentProject:"当前",gsOpenPreview:"打开文件预览",gsNavigate:"选择",gsOpen:"打开",gsCloseHint:"关闭",bgTaskCommand:"命令行",searchPrev:"上一个(Shift+Enter)",searchNext:"下一个(Enter)",searchClose:"关闭(Esc)",questionNavTip:"本对话的全部问题,悬浮展开,点击跳转","tpl.title":"提示词模板","tpl.hint":"点击卡片直接填入输入框,✏️ 可编辑或删除 · 也能新增自己的模板","tpl.clickCard":"点击填入输入框","tpl.editTpl":"编辑 / 删除模板","tpl.openPicker":"提示词模板(常用提示词,随时取用)","tpl.pickerTitle":"提示词模板","tpl.pickerHint":"点击卡片直接填入输入框,✏️ 可编辑或删除 · 也能新增自己的模板","tpl.add":"新建模板","tpl.addDesc":"把常用工作流存成模板","tpl.reset":"恢复默认模板","tpl.resetConfirm":"确认恢复默认?","tpl.builtin":"内置","tpl.custom":"自定义","tpl.newTitle":"新建提示词模板","tpl.editTitle":"编辑提示词模板","tpl.fieldIcon":"图标","tpl.fieldTitle":"标题","tpl.fieldTitlePh":"卡片上显示的短标题","tpl.fieldDesc":"说明","tpl.fieldDescPh":"一句话说明,显示在卡片上","tpl.fieldPrompt":"提示词","tpl.fieldPromptPh":"完整提示词 —— 发送给智能体的内容","tpl.required":"标题和提示词不能为空","tpl.save":"保存修改","tpl.fill":"填入输入框","tpl.fillTip":"填入输入框,可再编辑后发送","tpl.sendNow":"直接发送","tpl.sendTip":"立即作为新对话发送","tpl.delete":"删除","tpl.deleteTip":"删除这个自定义模板","tpl.remove":"移出模板库","tpl.removeTip":"把内置模板移出模板库,可在底部「恢复默认模板」找回","tpl.restore":"恢复默认","tpl.restoreTip":"撤掉你的修改,恢复内置默认","tpl.sk.setup":"仓库初始化","tpl.sk.setup.desc":"让仓库了解它的构建与约定","tpl.sk.setup.prompt":`请先扫描这个仓库,建立「其他工作流都能用」的基础上下文,输出一份简明报告:
|
|
4
4
|
|
|
5
5
|
1. 项目类型、技术栈与目录结构
|
|
@@ -150,7 +150,7 @@ import{R as Ye,a as l,j as e,M as hi,b as gi,c as fi}from"./markdown-BJJLXG-8.js
|
|
|
150
150
|
2. 用最小实现让测试通过
|
|
151
151
|
3. 重构并保持测试通过
|
|
152
152
|
|
|
153
|
-
避免三种反模式:与实现耦合的测试、空洞断言(永远为真)、横向切片(只测表面)。每步汇报并运行测试。`,error:"出错",done:"完成",running:"执行中…",toolQueued:"排队中",copyArgs:"复制参数",errorOutput:"错误输出",output:"输出",waitingOutput:"等待输出…",toolDoneWaitingModel:"已结束 · 等模型",waitingModel:"等待模型响应…",thinkingNow:"思考中",thinkingPreview:"思考:{preview}",commands:"命令",newCommand:"新建命令",newTerminal:"新建终端",name:"名称",command:"命令",cwdHint:"(${pwd} = 当前工作目录)",noCommands:"还没有命令,点 + 添加一个",clickToRun:"点击运行",edit:"编辑",delete:"删除",confirmQ:"确认?",builtinTerminal:"内置终端",termEmptySub:"点击左侧命令运行,或点右侧 + 新建终端",noTerminal:"暂无终端",exited:"(已退出{code})",exitBanner:"[进程已退出,退出码 {code}]",closeTerminal:"关闭终端",renameTerminal:"重命名终端",rerun:"重新读取 .pi/commands.json",terminalTitle:"终端 {n}",aiBashGroup:"终端接管 bash",exampleName:"例如:启动开发服务器",exampleCommand:"例如:npm run dev",scmTab:"Git",scmTitle:"源代码管理",scmRefreshTip:"重新查询 Git 状态与差异",scmCurrentBranch:"当前分支",scmUpstreamGone:"上游已删除",scmAheadBehind:"↑{ahead} ↓{behind}",scmDetached:"分离 HEAD",scmSelectBranch:"选择分支…",scmRemoteBranches:"远程分支",scmStageTip:"暂存 {path}",scmUnstageTip:"取消暂存 {path}",scmSwitch:"切换",scmSwitchBranch:"切换分支",scmSwitchBranchTip:"在终端中执行 git checkout {branch}",scmPush:"推送",scmPushTip:"在终端中执行 git push",scmPull:"拉取",scmPullTip:"在终端中执行 git pull",scmCommit:"提交",scmCommitTip:'在终端中执行 git commit -m "…"(仅提交已暂存的更改)',scmCommitAll:"全部提交",scmCommitAllTip:'在终端中执行 git add -A && git commit -m "…"(暂存全部更改含未跟踪并提交)',scmCommitPlaceholder:"输入提交信息…",scmChanges:"更改",scmHistory:"提交树",scmCommitDetail:"提交详情",scmSelectCommitHint:"点击左侧提交查看详情",scmNoHistory:"暂无提交记录",scmNoChanges:"工作区干净,没有更改",scmNotGitRepo:"当前目录不是 Git 仓库",scmLoading:"查询中…",scmConnecting:"等待连接…",scmDiff:"差异",scmSelectFileHint:"点击左侧文件查看差异",scmNoDiff:"(无差异)",scmStaged:"已暂存",scmUnstaged:"未暂存",scmStagedUnstaged:"已暂存 + 未暂存",scmUntracked:"未跟踪",scmUntrackedNote:"未跟踪文件:需先用 + 暂存,或使用“全部提交”才会包含",scmQueryFailed:"Git 查询失败:{error}",scmQueryFailedShort:"查询失败",pluginCommandFallback:"插件命令",scmTooManyFailures:"Git 查询连续失败,请点击刷新重试",scmRunsInTerminal:"提交 / 切换分支 / 推送 / 拉取在终端中执行",scmViewTerminal:"去终端",editProvider:"编辑服务商",builtinProviders:"内置服务商",hintKeyOnly:"只需填入 API 密钥",configuredBadge:"✓ 已配置",keyReady:"密钥已就绪",replaceKey:"更换密钥",replaceKeyTitle:"替换已保存的密钥",clearKey:"清空",clearKeyTitle:"清除该服务商保存在 auth.json 的密钥,回到未配置状态(环境变量来源的无法在此清除)",clearKeyConfirm:"清空 {id} 已保存的密钥?其模型将从列表消失,直到重新配置。",cloneProvider:"添加密钥",cloning:"添加中",cloneProviderTitle:"为该供应商添加第二把密钥(自动复制 baseUrl 与模型列表,可改名后保存)",pasteKey:"粘贴 API 密钥…",savingKey:"保存中",saveKey:"保存密钥",addKey:"添加密钥",addKeyPlaceholder:"粘贴密钥值…",keyNamePh:"名称(可留空,如 备用)",providerIdPlaceholder:"供应商 ID",baseUrlExamplePh:"baseUrl 链接,如 https://api.opencode.ai/zen/v1 或 http://127.0.0.1:4096",saveAllBatch:"一键保存全部({n})",netDisconnected:"网络连接已断开,请重连后重试",advancedEdit:"高级编辑",batchCreateProviders:"批量创建供应商({n}个接口)",secondKeyTitle:"为 {api} · {baseUrl} · {n} 个模型添加第二把密钥,只需指定新供应商名字和密钥即可。",noBaseUrlShort:"(无 baseUrl)",providerNameLabel:"供应商名字",providerNameHint:"(新 ID,如 opencode-2)",apiKeyLabel:"API 密钥",secondKeyPlaceholder:"sk-… 第二把 key",batchDesc:"该供应商含多种接口({apis}),已按接口拆分为 {n} 个自定义供应商,分别保存后才能让所有模型(如 muse-spark)都可用。统一填入第二把 API 密钥后一键保存。",batchKeyLabel:"统一 API 密钥(将应用到全部 {n} 个供应商)",modelsCountShort:"{n} 个模型:",noKeyYet:"尚无密钥,添加一把即可用",activateKey:"设为当前",removeKey:"移除",removeKeyConfirm:"确定移除该密钥?移除后需重新配置才能使用。",customProviders:"自定义服务商",customDesc:"用于 Ollama / vLLM / 兼容 OpenAI 的代理等,写入 pi 的 models.json,保存后热重载、立即生效。",noCustomProviders:"还没有自定义服务商",modelsCount:"{n} 个模型",addProvider:"新增服务商",providerId:"服务商 ID",providerIdHint:"(必填,如 ollama / my-proxy)",displayName:"显示名",displayNamePh:"我的代理",apiType:"API 类型",baseUrlHint:"(OpenAI 兼容端点)",apiKeyHint:"sk-…(可留空,用 auth.json 的密钥)",authHeader:"自动添加 Authorization 请求头",modelsTitle:"模型",modelIdReq:"模型 ID(必填)",text:"文本",textImage:"文本+图片",contextWindow:"上下文",maxOutput:"最大输出",removeModel:"移除模型",addModel:"添加模型",deleteProviderConfirm:"删除服务商 {id} 及其 {n} 个模型?",fetchModels:"自动获取模型列表",fetchModelsHint:"从 baseUrl 的 /models 接口自动拉取模型 ID(服务端请求,不受 CORS 限制)",fetchingModels:"获取中…",fetchModelsOk:"已获取 {n} 个模型",fetchModelsEmpty:"接口未返回任何模型",fetchModelsErr:"获取失败:{msg}",fetchModelsNeedBaseUrl:"请先填写 baseUrl 再获取",goalBarTitle:"目标",goalBarPlaceholder:"设定一个目标,agent 完成后自动审查…",goalBarSet:"开始",goalBarClear:"取消",goalBarLocked:"锁定:应用到后续所有回合",goalBarUnlocked:"仅本回合(改完自动清除)",goalBarReviewModel:"审查模型",goalBarUseMainModel:"使用主模型",goalBarMaxRounds:"最大轮数",goalBarMaxRoundsTip:"最大审查重改轮数;0 或不填 = 不限(持续改到通过)",goalBarUnlimitedShort:"不限",goalBarReviewing:"审查中…",goalBarRound:"第 {n} 轮",goalBarActive:"目标生效中",goalBarPassed:"已通过",goalBarFailed:"未通过",goalBarStatusPending:"等待生成…",goalWizardBtn:"AI 提炼",goalWizardTip:"让 AI 通过问卷调研细化需求,收敛为目标",goalWizardRunning:"目标调研中",goalWizardAnswer:"回答",goalWizardCard:"目标调研",settings:"设置",settingsTitle:"设置",settingsDesc:"修改立即生效:系统提示词、技能与插件开关会重建当前会话;审查提示词与审查技能只影响后续目标审查(回复进行中则主会话变更自动延迟)。",settingsSystemPrompt:"系统提示词",settingsPromptHistory:"输入历史",settingsPromptHistoryDesc:"用 ↑↓ 在输入框循环历史提问,全局跨对话共享(localStorage)",promptHistoryMax:"最大条数",promptHistoryMaxHint:"超过上限时最旧的自动丢弃,可设 1–500",promptHistoryCharLimit:"限制单条字数",promptHistoryCharLimitHint:"开启后超长输入截断后保存,避免大段粘贴占满存储",promptHistoryCharLimitPlaceholder:"最大字数(100–20000)",promptHistoryClear:"清空历史",promptHistoryClearConfirm:"确认清空?",promptHistoryCleared:"已清空输入历史",promptHistoryCount:"当前 {n} 条",promptHistoryEmpty:"暂无历史记录,上/下键暂无可循环内容",settingsPromptMode:"模式",promptModeAppend:"追加",promptModeReplace:"替换",promptAppendHint:"追加模式:自定义内容拼接到默认系统提示词末尾(推荐,保留默认行为约束)。",promptReplaceHint:"替换模式:完全用自定义内容替换系统提示词(项目上下文与技能段仍会自动附加)。切换后输入框会显示原本的默认提示词,可直接修改;不改动失焦则仍使用默认。",promptPlaceholder:"输入自定义系统提示词…(失焦后自动应用)",settingsViewPrompt:"查看当前完整提示词",settingsViewPromptHint:"当前会话实际生效的完整系统提示词(含自定义追加/替换内容、项目上下文、技能说明与工具引导),只读。",settingsViewPromptEmpty:"会话尚未就绪,暂无系统提示词。",settingsSkills:"技能",settingsReview:"目标审查",settingsReviewDesc:"为独立的目标审查会话配置额外提示词和技能;不会改变主会话设置。",settingsReviewSkills:"审查可用技能",reviewPromptPlaceholder:"输入审查自定义提示词…(失焦后自动应用)",reviewPromptHint:"这些内容会追加到审查任务中;审查仍会强制要求输出 pass/fail JSON。技能开关仅对审查生效。",settingsVisionBridge:"视觉桥",settingsVisionBridgeDesc:"当前模型不支持识图时,把图片交给已配置的视觉模型转写为文字证据,再让模型回答",visionBridgeEnabled:"启用视觉桥",visionBridgeModel:"转写模型",visionBridgeAuto:"自动选择(按顺序)",visionBridgeNoModels:"未找到已配置的视觉模型:在模型配置里添加任意支持图片的模型(如 qwen-vl、GLM-4V、Gemini)即可自动启用",visionBridgeOffHint:"已关闭:图片将原样发送,纯文本模型可能看不到图片内容",visionBridgeCurrent:"当前转写模型:{model}",visionBridgePromptMode:"转写提示词",settingsMarkers:"标记工具",settingsMarkersDesc:"让 AI 用 [[todo:...]] / [[svc:...]] / [[notify:...]] / [[conv:rename:...]] 内联标记在正文里改状态,无需工具往返。全局关闭则全部停用;分组开关可细粒度控制。",markersEnabled:"启用标记工具(全局)",markersEnabledDesc:"关闭后 AI 不再收到任何标记引导,解析也跳过(所有标记原文原样保留,不执行)。",markersOffHint:"已全局关闭:所有标记停用,AI 不会写标记,也不会触发任务/重命名等副作用。",markerGroupTodo:"任务标记 todo",markerGroupSvc:"后台服务标记 svc",markerGroupNotify:"提醒标记 notify",markerGroupRename:"重命名标记 conv/rename",markerRenameTip:"[[conv:rename:新标题]] 或 [[rename:set:标题]] 重命名当前对话(标题 ≤80 字)",settingsTerminalTools:"终端工具",terminalToolsEnabled:"启用持久终端工具",settingsTerminalToolsDesc:"让 AI 在交互式程序(REPL/vim)、长驻服务、需要持续观察输出或你要求在可见终端操作时,使用内置终端;普通命令仍走一次性 bash 工具",terminalToolsOffHint:"已关闭:AI 无法使用 terminal_* 工具,也不会收到相关使用引导",settingsMessageDisplay:"消息显示",thinkingWrap:"完整显示思考",thinkingWrapDesc:"开启:思考内容始终完整展开并自动换行(流式推理过程也实时可见);关闭:折叠成一行摘要,流式中一行实时显示最新文本",toolsWrap:"完整显示工具",toolsWrapDesc:"开启:工具调用始终完整展开显示参数和输出;关闭:默认折叠,点击展开",terminalBashTakeover:"终端接管 bash",terminalBashTakeoverDesc:"此开关决定 bash 是否覆盖为终端版:关 = 原生 SDK bash(纯进程、不开终端);开 = 跑进可见终端,且 persist 参数在本开关的基础上决定一次性(false,命令跑完进程退出、输出留档)还是持久(true,shell 状态跨调用保留、静默自动转后台并通知 AI)",terminalBashIdleMs:"静默转后台阈值(毫秒)",terminalBashIdleMsDesc:"持久终端模式下,命令连续无输出达到该时长即不再阻塞等待,转入后台继续运行并通知 AI;0 = 一直等到命令结束(默认 15000)",visionBridgePromptPlaceholder:"输入自定义转写提示词…(留空 = 使用内置默认提示词,失焦后自动应用)",visionBridgePromptAppendHint:"追加模式:自定义内容拼接到内置转写提示词末尾(推荐,保留默认的逐字转写约束)。",visionBridgePromptReplaceHint:"替换模式:完全用自定义内容替换内置转写提示词。切换后输入框会显示内置默认提示词,可直接修改;不改动失焦则仍使用默认。",uninstallExt:"卸载",uninstallConfirm:"确认卸载?",uninstallConfirmHint:"再次点击确认,将在终端执行 pi remove",uninstallHint:"通过可见终端执行 pi remove 卸载此包,完成后自动刷新列表",uninstallTitle:"卸载",pluginUpdate:"更新",pluginUpdateHint:"从安装来源重新拉取并覆盖安装(保留 config.json 配置),完成后自动重载插件列表",pluginUninstallHint:"在可见终端执行 pi-web-ui uninstall 卸载此插件(再次点击确认),完成后自动刷新列表",settingsExtensions:"插件",settingsUiPlugins:"界面插件",noUiPlugins:"未安装界面组件(<dataDir>/plugins/)",dshPatches:"DSH 用户补丁",dshPatchesDesc:"启动时按文件名序加载的 Cordis patch(<dataDir>/dsh-patches/*.yml)。新增/修改后点「重扫」重启运行时生效;失败的文件会被跳过并打印到运行时 stderr。",dshPatchesRescan:"重扫",dshPatchesRescanHint:"重新扫描补丁目录并重启 DSH 运行时使新补丁生效",dshPatchesEmpty:"未放置补丁文件",dshPatchesPath:"补丁目录:",uiPluginNoSource:"手工安装,无来源信息,无法在线更新",uiPluginPerms:"能力声明",pluginSettingsSave:"保存插件设置",pluginSettingsSaving:"保存中…",pluginSettingsReset:"恢复默认",settingsPresets:"预设",settingsSubagentTemplates:"子代理模板",settingsSubagentTemplatesDesc:"配置子代理预设(角色系统提示词 + 技能/扩展白名单)。AI 派生子代理时可选用模板(subagent_spawn 的 template 参数),也可不传按默认运行;停用的模板保留在面板但对 AI 不可见。",noSubagentTemplates:"还没有子代理模板。AI 派生子代理时可选用模板(角色提示词 + 技能/扩展白名单),也可以不传 template 按默认配置运行。",subagentTemplateNew:"新建模板",subagentTemplateEdit:"编辑",subagentTemplateClosed:"已停用",tplDefaultBadge:"默认",subagentTemplateOffHint:"关闭的模板保留在面板、可随时重新启用,但 AI 工具查询不到、不能选择",subagentTemplateEnable:"启用",subagentTemplateDisable:"停用",tplNamePlaceholder:"模板名(AI 用 subagent_spawn 的 template 参数引用)…",tplDescriptionPlaceholder:"简介(AI 据此判断适用场景)…",tplPromptModeLabel:"系统提示词模式",tplSystemPromptLabel:"系统提示词",tplSystemPromptPlaceholder:"模板角色系统提示词…(append 模式可留空)",tplWhitelistHint:"白名单:勾选 = 子代理只启用这些;全部不勾 = 跟随主会话设置",tplSkillsLabel:"技能白名单",tplExtensionsLabel:"扩展白名单",tplSave:"保存模板",tplCancel:"取消编辑",tplDelete:"删除模板",tplInherit:"跟随主会话",settingsEnabled:"已启用",settingsDisabled:"已禁用",presetNamePlaceholder:"预设名称…",saveAsPreset:"保存为预设",applyPreset:"应用",deletePreset:"删除预设",noSkills:"暂无技能",noExtensions:"暂无插件",noPresets:"暂无预设(先调整上面的设置,再保存为预设组合)",loadingSession:"正在加载会话…",connectingServer:"正在连接 pi-web-ui 服务器…"},Fs={docTitle:"pi-web-ui — pi coding agent",cancel:"Cancel",ok:"OK",save:"Save",close:"Close",widgetExpand:"Click to view full output",collapsePanel:"Collapse panel",expandPanel:"Expand panel",dragToResize:"Drag to resize · double-click to reset",loading:"Loading…",connected:"Connected",connecting:"Connecting…",reconnecting:"Reconnecting…",language:"Language",langZh:"中文",langEn:"English",githubRepo:"GitHub repository (xing-shuyin/pi-web-ui)",copy:"Copy",viewSwitch:"Switch view",chat:"Chat",terminal:"Terminal",selectModel:"Select model",availableModels:"Available models",allProviders:"All",providers:"Providers",noModels:"No models available (configure an API key first)",reasoning:"reasoning",vision:"vision",refreshModels:"Refresh model list (keeps manual rows, merges new ones)",manageModels:"⚙ Manage models (add / edit)",manageModelsTitle:"Manage models",thinkingLevel:"Thinking level",thinking:"Thinking",thinkingChip:"Thinking: {level}",sound:"Sound",theme:"Theme",themeDefault:"Dark (default)",newChat:"New chat",more:"More",newChatTip:"New chat (sessions are saved per browser)","thinking.off":"Off","thinking.minimal":"Minimal","thinking.low":"Low","thinking.medium":"Medium","thinking.high":"High","thinking.xhigh":"Extra high","thinking.max":"Max",thinkingUnsupported:"Not supported by this model — snapped to the nearest supported level",context:"Context",contextUsage:"Context usage",cumulativeCost:"Cumulative cost",sessionMessages:"Session messages",messages:"messages",pluginStatus:"Plugin status",engineBadge:"Engine",working:"Working",queued:"queued",enterPath:"Type a path, Enter to switch",cwdTip:"Working directory: {path} (click to switch)",cwdGoUp:"Up one level",cwdPickCurrent:"Select this folder",cwdChoose:"Select",cwdEnter:"Enter",cwdEmpty:"(empty)",cwdNewFolder:"New folder",cwdNewName:"Folder name",cwdCreate:"Create",cwdCancel:"Cancel",cacheHit:"Cache hit",cacheHitTip:"read {read} · write {write} · miss {miss} (of {input} input tokens)",tps:"t/s",rateTip:"Live generation rate (estimated)",folderRef:"Folder reference: {path}",refOnly:"Reference only: {path}",attachContent:"Attached content: {path}",attachLines:"Attached selected lines: {path} (lines {start}-{end})",attachImage:"Image: {name}",attachFile:"File: {name}",removeAttachment:"Remove attachment",attachHint:"Will be sent with the next message",uploadFile:"Add files (images / text / any file — or drag in / paste a screenshot)",dropHereToAttach:"Release to attach file",imageNotSupported:"The current model doesn't support vision — images will be transcribed by the vision bridge (may be ignored if no vision model is configured)",imageLoadFailed:"Couldn't read image: {name}",fileLoadFailed:"Couldn't read file: {name}",fileTooLarge:"File too large, skipped (> {size}MB): {name}",foldersNotSupported:"Folders can't be dropped directly — expand and pick files instead",placeholderStreaming:"The agent is working… press Enter to steer, or click Queue to send after the reply finishes",placeholderIdle:"Message pi — Enter to send, / for commands",placeholderConnecting:"Connecting to server…",stopAgent:"Stop agent",stop:"Stop",bgTasks:"Background tasks",bgTasksTip:"Servers the AI started in the background (npm run dev & etc.) — stop them individually or all at once; they survive the conversation",bgTasksEmpty:"No background tasks",bgTasksDesc:"Processes the AI started that are still listening (detected by port)",bgTaskPort:"Port",bgTaskPid:"PID",bgTaskSince:"Started",bgTaskStop:"Stop",bgTaskStopAll:"Stop all",bgTaskRefresh:"Refresh",bgTaskJustNow:"just now",bgTaskMinutes:"{n} min ago",bgTaskHours:"{n} hr ago",bgTaskDays:"{n} days ago",stopBash:"Stop",stopBashTip:"Stop the running bash command (conversation continues)",supplement:"Queue",supplementTip:"Add to queue: sent only after the whole run finishes (no interruption)",queueSteerTag:"Steer",queueFollowTag:"Queued",queueRemoveTip:"Remove this queued message",sendTip:"Send (Enter)",slashCommands:"Commands",slashMenuHint:"↑↓ select · Enter/Tab complete",slashHelpTitle:"pi commands",slashHelpHint:"Type / anytime to open the command list",slashLoading:"Loading commands… (available once connected)",slashBuiltin:"Builtin",slashExtension:"Extension",slashPrompt:"Template",slashSkill:"Skill",slashPlugin:"Plugin",slashCopied:"Copied the last assistant reply",slashCopyFailed:"Copy failed — please copy manually",slashCopyEmpty:"No assistant reply to copy yet",mermaidRendering:"Rendering diagram…",mermaidRenderFailed:"Failed to render diagram — raw source below:",mermaidRenderSetting:"Render Mermaid diagrams",mermaidRenderSettingDesc:"When on, ```mermaid code blocks in messages render as diagrams; when off they stay plain code blocks and the diagram engine is never loaded",recentProjects:"Recent projects",runningConversations:"Running chats",subagentBadge:"Subagent",subagentTitle:"Subagent · {title}",historySessions:"History",openHistory:"History",openFiles:"Files",streaming:"Streaming…",noHistory:"No previous chats",current:"Current",messageCount:"{n} messages",tuiTip:"Chat in the pi terminal (TUI)",deleteProject:"Remove from recent projects",deleteProjectConfirm:"Confirm remove",deleteSession:"Delete this chat transcript permanently",deleteSessionConfirm:"Confirm delete",renameSession:"Rename this chat",renameSessionPlaceholder:"Type a new name…",renameSessionConfirm:"Rename",dismissConversation:"Dismiss from running (keep in history)",dismissConversationConfirm:"Confirm dismiss",collapseSection:"Collapse",expandSection:"Expand",emptyChat:"Empty chat",editReask:"Edit & re-ask",editReaskTip:"Edit this question and re-ask from here (forks a new conversation; the original is kept)",reaskFromHere:"Re-ask from here",editPlaceholder:"Edit the question…",editHint:"⌘/Ctrl+Enter to submit · Esc to cancel",editAttachmentHint:"Original attachments kept — paste/drop images or files · ⌘/Ctrl+Enter to submit · Esc to cancel",expandMsg:"Expand",collapseMsg:"Collapse",toolCalls:"tool calls",bashRuns:"bash runs",images:"images",update:"Update",updateTip:"Check & update pi-web-ui",currentVersion:"Current version",latestVersion:"Latest version",checkingUpdate:"Checking…",checkUpdate:"Check for updates",upToDate:"You're up to date",updateAvailable:"New version v{version} available",updateJustPublished:"v{version} was just published — npm cache may lag; if the new version isn't detected yet, re-check in a moment",updateNow:"Update in terminal",updateTabTitle:"Update pi-web-ui",updateTerminalHint:"Clicking runs npm i -g pi-web-ui@latest in a visible terminal; restart the service afterwards to take effect (pi-web-ui server restart).",updatesAllTitle:"Component updates",updatesAllBadge:"{n} updates",updatesAllUpToDate:"All components up to date",kindWebUi:"Web UI",kindPiCore:"Core",kindPackage:"Package",updatesAllRefresh:"Re-check all",updateCheckFailed:"Check failed",updateBtn:"Update",updateAllBtn:"Update all",updatePkgTabTitle:"Update {name}",updateAllTabTitle:"Update all components",computer:"This PC",rootDir:"Root",noFiles:"No files",filesTruncated:"Directory too large — list truncated (first 2000 shown)",linkFolderTip:"Link folder path to chat",attachInlineTip:"Attach content to chat",referenceTip:"Reference path only (AI reads on demand)",previewFile:"Preview",downloadFile:"Download file",downloadFailed:"Download failed: {error}",fileNotFoundShort:"File not found",pluginMountFailed:"Plugin {name} failed to mount",liveOutputOmitted:`…[{n} chars omitted above]…
|
|
153
|
+
避免三种反模式:与实现耦合的测试、空洞断言(永远为真)、横向切片(只测表面)。每步汇报并运行测试。`,error:"出错",done:"完成",running:"执行中…",toolQueued:"排队中",copyArgs:"复制参数",errorOutput:"错误输出",output:"输出",waitingOutput:"等待输出…",toolDoneWaitingModel:"已结束 · 等模型",waitingModel:"等待模型响应…",thinkingNow:"思考中",thinkingPreview:"思考:{preview}",commands:"命令",newCommand:"新建命令",newTerminal:"新建终端",name:"名称",command:"命令",cwdHint:"(${pwd} = 当前工作目录)",noCommands:"还没有命令,点 + 添加一个",clickToRun:"点击运行",edit:"编辑",delete:"删除",confirmQ:"确认?",builtinTerminal:"内置终端",termEmptySub:"点击左侧命令运行,或点右侧 + 新建终端",noTerminal:"暂无终端",exited:"(已退出{code})",exitBanner:"[进程已退出,退出码 {code}]",closeTerminal:"关闭终端",renameTerminal:"重命名终端",rerun:"重新读取 .pi/commands.json",terminalTitle:"终端 {n}",aiBashGroup:"终端接管 bash",exampleName:"例如:启动开发服务器",exampleCommand:"例如:npm run dev",scmTab:"Git",scmTitle:"源代码管理",scmRefreshTip:"重新查询 Git 状态与差异",scmCurrentBranch:"当前分支",scmUpstreamGone:"上游已删除",scmAheadBehind:"↑{ahead} ↓{behind}",scmDetached:"分离 HEAD",scmSelectBranch:"选择分支…",scmRemoteBranches:"远程分支",scmStageTip:"暂存 {path}",scmUnstageTip:"取消暂存 {path}",scmSwitch:"切换",scmSwitchBranch:"切换分支",scmSwitchBranchTip:"在终端中执行 git checkout {branch}",scmPush:"推送",scmPushTip:"在终端中执行 git push",scmPull:"拉取",scmPullTip:"在终端中执行 git pull",scmCommit:"提交",scmCommitTip:'在终端中执行 git commit -m "…"(仅提交已暂存的更改)',scmCommitAll:"全部提交",scmCommitAllTip:'在终端中执行 git add -A && git commit -m "…"(暂存全部更改含未跟踪并提交)',scmCommitPlaceholder:"输入提交信息…",scmChanges:"更改",scmHistory:"提交树",scmCommitDetail:"提交详情",scmSelectCommitHint:"点击左侧提交查看详情",scmNoHistory:"暂无提交记录",scmNoChanges:"工作区干净,没有更改",scmNotGitRepo:"当前目录不是 Git 仓库",scmLoading:"查询中…",scmConnecting:"等待连接…",scmDiff:"差异",scmSelectFileHint:"点击左侧文件查看差异",scmNoDiff:"(无差异)",scmStaged:"已暂存",scmUnstaged:"未暂存",scmStagedUnstaged:"已暂存 + 未暂存",scmUntracked:"未跟踪",scmUntrackedNote:"未跟踪文件:需先用 + 暂存,或使用“全部提交”才会包含",scmQueryFailed:"Git 查询失败:{error}",scmQueryFailedShort:"查询失败",pluginCommandFallback:"插件命令",scmTooManyFailures:"Git 查询连续失败,请点击刷新重试",scmRunsInTerminal:"提交 / 切换分支 / 推送 / 拉取在终端中执行",scmViewTerminal:"去终端",editProvider:"编辑服务商",builtinProviders:"内置服务商",hintKeyOnly:"只需填入 API 密钥",configuredBadge:"✓ 已配置",keyReady:"密钥已就绪",replaceKey:"更换密钥",replaceKeyTitle:"替换已保存的密钥",clearKey:"清空",clearKeyTitle:"清除该服务商保存在 auth.json 的密钥,回到未配置状态(环境变量来源的无法在此清除)",clearKeyConfirm:"清空 {id} 已保存的密钥?其模型将从列表消失,直到重新配置。",cloneProvider:"添加密钥",cloning:"添加中",cloneProviderTitle:"为该供应商添加第二把密钥(自动复制 baseUrl 与模型列表,可改名后保存)",pasteKey:"粘贴 API 密钥…",savingKey:"保存中",saveKey:"保存密钥",addKey:"添加密钥",addKeyPlaceholder:"粘贴密钥值…",keyNamePh:"名称(可留空,如 备用)",providerIdPlaceholder:"供应商 ID",baseUrlExamplePh:"baseUrl 链接,如 https://api.opencode.ai/zen/v1 或 http://127.0.0.1:4096",saveAllBatch:"一键保存全部({n})",netDisconnected:"网络连接已断开,请重连后重试",advancedEdit:"高级编辑",batchCreateProviders:"批量创建供应商({n}个接口)",secondKeyTitle:"为 {api} · {baseUrl} · {n} 个模型添加第二把密钥,只需指定新供应商名字和密钥即可。",noBaseUrlShort:"(无 baseUrl)",providerNameLabel:"供应商名字",providerNameHint:"(新 ID,如 opencode-2)",apiKeyLabel:"API 密钥",secondKeyPlaceholder:"sk-… 第二把 key",batchDesc:"该供应商含多种接口({apis}),已按接口拆分为 {n} 个自定义供应商,分别保存后才能让所有模型(如 muse-spark)都可用。统一填入第二把 API 密钥后一键保存。",batchKeyLabel:"统一 API 密钥(将应用到全部 {n} 个供应商)",modelsCountShort:"{n} 个模型:",noKeyYet:"尚无密钥,添加一把即可用",activateKey:"设为当前",removeKey:"移除",removeKeyConfirm:"确定移除该密钥?移除后需重新配置才能使用。",customProviders:"自定义服务商",customDesc:"用于 Ollama / vLLM / 兼容 OpenAI 的代理等,写入 pi 的 models.json,保存后热重载、立即生效。",noCustomProviders:"还没有自定义服务商",modelsCount:"{n} 个模型",addProvider:"新增服务商",providerId:"服务商 ID",providerIdHint:"(必填,如 ollama / my-proxy)",displayName:"显示名",displayNamePh:"我的代理",apiType:"API 类型",baseUrlHint:"(OpenAI 兼容端点)",apiKeyHint:"sk-…(可留空,用 auth.json 的密钥)",authHeader:"自动添加 Authorization 请求头",modelsTitle:"模型",modelIdReq:"模型 ID(必填)",text:"文本",textImage:"文本+图片",contextWindow:"上下文",maxOutput:"最大输出",removeModel:"移除模型",addModel:"添加模型",deleteProviderConfirm:"删除服务商 {id} 及其 {n} 个模型?",fetchModels:"自动获取模型列表",fetchModelsHint:"从 baseUrl 的 /models 接口自动拉取模型 ID(服务端请求,不受 CORS 限制)",fetchingModels:"获取中…",fetchModelsOk:"已获取 {n} 个模型",fetchModelsEmpty:"接口未返回任何模型",fetchModelsErr:"获取失败:{msg}",fetchModelsNeedBaseUrl:"请先填写 baseUrl 再获取",goalBarTitle:"目标",goalBarPlaceholder:"设定一个目标,agent 完成后自动审查…",goalBarSet:"开始",goalBarClear:"取消",goalBarLocked:"锁定:应用到后续所有回合",goalBarUnlocked:"仅本回合(改完自动清除)",goalBarReviewModel:"审查模型",goalBarUseMainModel:"使用主模型",goalBarMaxRounds:"最大轮数",goalBarMaxRoundsTip:"最大审查重改轮数;0 或不填 = 不限(持续改到通过)",goalBarUnlimitedShort:"不限",goalBarReviewing:"审查中…",goalBarRound:"第 {n} 轮",goalBarActive:"目标生效中",goalBarPassed:"已通过",goalBarFailed:"未通过",goalBarStatusPending:"等待生成…",goalWizardBtn:"AI 提炼",goalWizardTip:"让 AI 通过问卷调研细化需求,收敛为目标",goalWizardRunning:"目标调研中",goalWizardAnswer:"回答",goalWizardCard:"目标调研",settings:"设置",settingsTitle:"设置",settingsDesc:"修改立即生效:系统提示词、技能与插件开关会重建当前会话;审查提示词与审查技能只影响后续目标审查(回复进行中则主会话变更自动延迟)。",settingsSystemPrompt:"系统提示词",settingsPromptHistory:"输入历史",settingsPromptHistoryDesc:"用 ↑↓ 在输入框循环历史提问,全局跨对话共享(localStorage)",promptHistoryMax:"最大条数",promptHistoryMaxHint:"超过上限时最旧的自动丢弃,可设 1–500",promptHistoryCharLimit:"限制单条字数",promptHistoryCharLimitHint:"开启后超长输入截断后保存,避免大段粘贴占满存储",promptHistoryCharLimitPlaceholder:"最大字数(100–20000)",promptHistoryClear:"清空历史",promptHistoryClearConfirm:"确认清空?",promptHistoryCleared:"已清空输入历史",promptHistoryCount:"当前 {n} 条",promptHistoryEmpty:"暂无历史记录,上/下键暂无可循环内容",settingsPromptMode:"模式",promptModeAppend:"追加",promptModeReplace:"替换",promptAppendHint:"追加模式:自定义内容拼接到默认系统提示词末尾(推荐,保留默认行为约束)。",promptReplaceHint:"替换模式:完全用自定义内容替换系统提示词(项目上下文与技能段仍会自动附加)。切换后输入框会显示原本的默认提示词,可直接修改;不改动失焦则仍使用默认。",promptPlaceholder:"输入自定义系统提示词…(失焦后自动应用)",settingsViewPrompt:"查看当前完整提示词",settingsViewPromptHint:"当前会话实际生效的完整系统提示词(含自定义追加/替换内容、项目上下文、技能说明与工具引导),只读。",settingsViewPromptEmpty:"会话尚未就绪,暂无系统提示词。",settingsSkills:"技能",settingsReview:"目标审查",settingsReviewDesc:"为独立的目标审查会话配置额外提示词和技能;不会改变主会话设置。",settingsReviewSkills:"审查可用技能",reviewPromptPlaceholder:"输入审查自定义提示词…(失焦后自动应用)",reviewPromptHint:"这些内容会追加到审查任务中;审查仍会强制要求输出 pass/fail JSON。技能开关仅对审查生效。",settingsVisionBridge:"视觉桥",settingsVisionBridgeDesc:"当前模型不支持识图时,把图片交给已配置的视觉模型转写为文字证据,再让模型回答",visionBridgeEnabled:"启用视觉桥",visionBridgeModel:"转写模型",visionBridgeAuto:"自动选择(按顺序)",visionBridgeNoModels:"未找到已配置的视觉模型:在模型配置里添加任意支持图片的模型(如 qwen-vl、GLM-4V、Gemini)即可自动启用",visionBridgeOffHint:"已关闭:图片将原样发送,纯文本模型可能看不到图片内容",visionBridgeCurrent:"当前转写模型:{model}",visionBridgePromptMode:"转写提示词",settingsMarkers:"标记工具",settingsMarkersDesc:"让 AI 用 [[todo:...]] / [[svc:...]] / [[notify:...]] / [[conv:rename:...]] 内联标记在正文里改状态,无需工具往返。全局关闭则全部停用;分组开关可细粒度控制。",markersEnabled:"启用标记工具(全局)",markersEnabledDesc:"关闭后 AI 不再收到任何标记引导,解析也跳过(所有标记原文原样保留,不执行)。",markersOffHint:"已全局关闭:所有标记停用,AI 不会写标记,也不会触发任务/重命名等副作用。",markerGroupTodo:"任务标记 todo",markerGroupSvc:"后台服务标记 svc",markerGroupNotify:"提醒标记 notify",markerGroupRename:"重命名标记 conv/rename",markerRenameTip:"[[conv:rename:新标题]] 或 [[rename:set:标题]] 重命名当前对话(标题 ≤80 字)",settingsTerminalTools:"终端工具",terminalToolsEnabled:"启用持久终端工具",settingsTerminalToolsDesc:"让 AI 在交互式程序(REPL/vim)、长驻服务、需要持续观察输出或你要求在可见终端操作时,使用内置终端;普通命令仍走一次性 bash 工具",terminalToolsOffHint:"已关闭:AI 无法使用 terminal_* 工具,也不会收到相关使用引导",settingsMessageDisplay:"消息显示",thinkingWrap:"完整显示思考",thinkingWrapDesc:"开启:思考内容始终完整展开并自动换行(流式推理过程也实时可见);关闭:折叠成一行摘要,流式中一行实时显示最新文本",toolsWrap:"完整显示工具",toolsWrapDesc:"开启:工具调用始终完整展开显示参数和输出;关闭:默认折叠,点击展开",terminalBashTakeover:"终端接管 bash",terminalBashTakeoverDesc:"此开关决定 bash 是否覆盖为终端版:关 = 原生 SDK bash(纯进程、不开终端);开 = 跑进可见终端,且 persist 参数在本开关的基础上决定一次性(false,命令跑完进程退出、输出留档)还是持久(true,shell 状态跨调用保留、静默自动转后台并通知 AI)",terminalBashIdleMs:"静默转后台阈值(毫秒)",terminalBashIdleMsDesc:"持久终端模式下,命令连续无输出达到该时长即不再阻塞等待,转入后台继续运行并通知 AI;0 = 一直等到命令结束(默认 15000)",visionBridgePromptPlaceholder:"输入自定义转写提示词…(留空 = 使用内置默认提示词,失焦后自动应用)",visionBridgePromptAppendHint:"追加模式:自定义内容拼接到内置转写提示词末尾(推荐,保留默认的逐字转写约束)。",visionBridgePromptReplaceHint:"替换模式:完全用自定义内容替换内置转写提示词。切换后输入框会显示内置默认提示词,可直接修改;不改动失焦则仍使用默认。",uninstallExt:"卸载",uninstallConfirm:"确认卸载?",uninstallConfirmHint:"再次点击确认,将在终端执行 pi remove",uninstallHint:"通过可见终端执行 pi remove 卸载此包,完成后自动刷新列表",uninstallTitle:"卸载",pluginUpdate:"更新",pluginUpdateHint:"从安装来源重新拉取并覆盖安装(保留 config.json 配置),完成后自动重载插件列表",pluginUninstallHint:"在可见终端执行 pi-web-ui uninstall 卸载此插件(再次点击确认),完成后自动刷新列表",settingsExtensions:"插件",settingsUiPlugins:"界面插件",noUiPlugins:"未安装界面组件(<dataDir>/plugins/)",dshPatches:"DSH 用户补丁",dshPatchesDesc:"启动时按文件名序加载的 Cordis patch(<dataDir>/dsh-patches/*.yml)。新增/修改后点「重扫」重启运行时生效;失败的文件会被跳过并打印到运行时 stderr。",dshPatchesRescan:"重扫",dshPatchesRescanHint:"重新扫描补丁目录并重启 DSH 运行时使新补丁生效",dshPatchesEmpty:"未放置补丁文件",dshPatchesPath:"补丁目录:",uiPluginNoSource:"手工安装,无来源信息,无法在线更新",uiPluginPerms:"能力声明",pluginSettingsSave:"保存插件设置",pluginSettingsSaving:"保存中…",pluginSettingsReset:"恢复默认",settingsPresets:"预设",settingsSubagentTemplates:"子代理模板",settingsSubagentTemplatesDesc:"配置子代理预设(角色系统提示词 + 技能/扩展白名单 + 可选模型)。AI 派生子代理时可选用模板(subagent_spawn 的 template 参数),也可不传按默认运行;停用的模板保留在面板但对 AI 不可见。",noSubagentTemplates:"还没有子代理模板。AI 派生子代理时可选用模板(角色提示词 + 技能/扩展白名单 + 可选模型),也可以不传 template 按默认配置运行。",subagentTemplateNew:"新建模板",subagentTemplateEdit:"编辑",subagentTemplateClosed:"已停用",tplDefaultBadge:"默认",subagentTemplateOffHint:"关闭的模板保留在面板、可随时重新启用,但 AI 工具查询不到、不能选择",subagentTemplateEnable:"启用",subagentTemplateDisable:"停用",subagentDefaultModelLabel:"子代理默认模型",subagentFollowMain:"跟随主对话当前模型",subagentDefaultModelHint:"所有子代理的兜底模型(模板里指定的模型和 subagent_spawn 的 model 参数优先级更高);不改主对话模型。",subagentNoModels:"暂无可用的模型(需要先配置服务商 API Key)——子代理将跟随主对话模型。",tplNamePlaceholder:"模板名(AI 用 subagent_spawn 的 template 参数引用)…",tplDescriptionPlaceholder:"简介(AI 据此判断适用场景)…",tplPromptModeLabel:"系统提示词模式",tplModelLabel:"模型(空 = 跟随主对话)",tplSystemPromptLabel:"系统提示词",tplSystemPromptPlaceholder:"模板角色系统提示词…(append 模式可留空)",tplWhitelistHint:"白名单:勾选 = 子代理只启用这些;全部不勾 = 跟随主会话设置",tplSkillsLabel:"技能白名单",tplExtensionsLabel:"扩展白名单",tplSave:"保存模板",tplCancel:"取消编辑",tplDelete:"删除模板",tplInherit:"跟随主会话",settingsEnabled:"已启用",settingsDisabled:"已禁用",presetNamePlaceholder:"预设名称…",saveAsPreset:"保存为预设",applyPreset:"应用",deletePreset:"删除预设",noSkills:"暂无技能",noExtensions:"暂无插件",noPresets:"暂无预设(先调整上面的设置,再保存为预设组合)",loadingSession:"正在加载会话…",connectingServer:"正在连接 pi-web-ui 服务器…"},Fs={docTitle:"pi-web-ui — pi coding agent",cancel:"Cancel",ok:"OK",save:"Save",close:"Close",widgetExpand:"Click to view full output",collapsePanel:"Collapse panel",expandPanel:"Expand panel",dragToResize:"Drag to resize · double-click to reset",loading:"Loading…",connected:"Connected",connecting:"Connecting…",reconnecting:"Reconnecting…",language:"Language",langZh:"中文",langEn:"English",githubRepo:"GitHub repository (xing-shuyin/pi-web-ui)",copy:"Copy",viewSwitch:"Switch view",chat:"Chat",terminal:"Terminal",selectModel:"Select model",availableModels:"Available models",allProviders:"All",providers:"Providers",noModels:"No models available (configure an API key first)",reasoning:"reasoning",vision:"vision",refreshModels:"Refresh model list (keeps manual rows, merges new ones)",manageModels:"⚙ Manage models (add / edit)",manageModelsTitle:"Manage models",thinkingLevel:"Thinking level",thinking:"Thinking",thinkingChip:"Thinking: {level}",sound:"Sound",theme:"Theme",themeDefault:"Dark (default)",newChat:"New chat",more:"More",newChatTip:"New chat (sessions are saved per browser)","thinking.off":"Off","thinking.minimal":"Minimal","thinking.low":"Low","thinking.medium":"Medium","thinking.high":"High","thinking.xhigh":"Extra high","thinking.max":"Max",thinkingUnsupported:"Not supported by this model — snapped to the nearest supported level",context:"Context",contextUsage:"Context usage",cumulativeCost:"Cumulative cost",sessionMessages:"Session messages",messages:"messages",pluginStatus:"Plugin status",engineBadge:"Engine",working:"Working",queued:"queued",enterPath:"Type a path, Enter to switch",cwdTip:"Working directory: {path} (click to switch)",cwdGoUp:"Up one level",cwdPickCurrent:"Select this folder",cwdChoose:"Select",cwdEnter:"Enter",cwdEmpty:"(empty)",cwdNewFolder:"New folder",cwdNewName:"Folder name",cwdCreate:"Create",cwdCancel:"Cancel",cacheHit:"Cache hit",cacheHitTip:"read {read} · write {write} · miss {miss} (of {input} input tokens)",tps:"t/s",rateTip:"Live generation rate (estimated)",folderRef:"Folder reference: {path}",refOnly:"Reference only: {path}",attachContent:"Attached content: {path}",attachLines:"Attached selected lines: {path} (lines {start}-{end})",attachImage:"Image: {name}",attachFile:"File: {name}",removeAttachment:"Remove attachment",attachHint:"Will be sent with the next message",uploadFile:"Add files (images / text / any file — or drag in / paste a screenshot)",dropHereToAttach:"Release to attach file",imageNotSupported:"The current model doesn't support vision — images will be transcribed by the vision bridge (may be ignored if no vision model is configured)",imageLoadFailed:"Couldn't read image: {name}",fileLoadFailed:"Couldn't read file: {name}",fileTooLarge:"File too large, skipped (> {size}MB): {name}",foldersNotSupported:"Folders can't be dropped directly — expand and pick files instead",placeholderStreaming:"The agent is working… press Enter to steer, or click Queue to send after the reply finishes",placeholderIdle:"Message pi — Enter to send, / for commands",placeholderConnecting:"Connecting to server…",stopAgent:"Stop agent",stop:"Stop",bgTasks:"Background tasks",bgTasksTip:"Servers the AI started in the background (npm run dev & etc.) — stop them individually or all at once; they survive the conversation",bgTasksEmpty:"No background tasks",bgTasksDesc:"Processes the AI started that are still listening (detected by port)",bgTaskPort:"Port",bgTaskPid:"PID",bgTaskSince:"Started",bgTaskStop:"Stop",bgTaskStopAll:"Stop all",bgTaskRefresh:"Refresh",bgTaskJustNow:"just now",bgTaskMinutes:"{n} min ago",bgTaskHours:"{n} hr ago",bgTaskDays:"{n} days ago",stopBash:"Stop",stopBashTip:"Stop the running bash command (conversation continues)",supplement:"Queue",supplementTip:"Add to queue: sent only after the whole run finishes (no interruption)",queueSteerTag:"Steer",queueFollowTag:"Queued",queueRemoveTip:"Remove this queued message",sendTip:"Send (Enter)",slashCommands:"Commands",slashMenuHint:"↑↓ select · Enter/Tab complete",slashHelpTitle:"pi commands",slashHelpHint:"Type / anytime to open the command list",slashLoading:"Loading commands… (available once connected)",slashBuiltin:"Builtin",slashExtension:"Extension",slashPrompt:"Template",slashSkill:"Skill",slashPlugin:"Plugin",slashCopied:"Copied the last assistant reply",slashCopyFailed:"Copy failed — please copy manually",slashCopyEmpty:"No assistant reply to copy yet",mermaidRendering:"Rendering diagram…",mermaidRenderFailed:"Failed to render diagram — raw source below:",mermaidRenderSetting:"Render Mermaid diagrams",mermaidRenderSettingDesc:"When on, ```mermaid code blocks in messages render as diagrams; when off they stay plain code blocks and the diagram engine is never loaded",recentProjects:"Recent projects",runningConversations:"Running chats",subagentBadge:"Subagent",convErrorBadge:"Subagent failed: {error}",subagentTitle:"Subagent · {title}",historySessions:"History",openHistory:"History",openFiles:"Files",streaming:"Streaming…",noHistory:"No previous chats",current:"Current",messageCount:"{n} messages",tuiTip:"Chat in the pi terminal (TUI)",deleteProject:"Remove from recent projects",deleteProjectConfirm:"Confirm remove",deleteSession:"Delete this chat transcript permanently",deleteSessionConfirm:"Confirm delete",renameSession:"Rename this chat",renameSessionPlaceholder:"Type a new name…",renameSessionConfirm:"Rename",dismissConversation:"Dismiss from running (keep in history)",dismissConversationConfirm:"Confirm dismiss",collapseSection:"Collapse",expandSection:"Expand",emptyChat:"Empty chat",editReask:"Edit & re-ask",editReaskTip:"Edit this question and re-ask from here (forks a new conversation; the original is kept)",reaskFromHere:"Re-ask from here",editPlaceholder:"Edit the question…",editHint:"⌘/Ctrl+Enter to submit · Esc to cancel",editAttachmentHint:"Original attachments kept — paste/drop images or files · ⌘/Ctrl+Enter to submit · Esc to cancel",expandMsg:"Expand",collapseMsg:"Collapse",toolCalls:"tool calls",bashRuns:"bash runs",images:"images",update:"Update",updateTip:"Check & update pi-web-ui",currentVersion:"Current version",latestVersion:"Latest version",checkingUpdate:"Checking…",checkUpdate:"Check for updates",upToDate:"You're up to date",updateAvailable:"New version v{version} available",updateJustPublished:"v{version} was just published — npm cache may lag; if the new version isn't detected yet, re-check in a moment",updateNow:"Update in terminal",updateTabTitle:"Update pi-web-ui",updateTerminalHint:"Clicking runs npm i -g pi-web-ui@latest in a visible terminal; restart the service afterwards to take effect (pi-web-ui server restart).",updatesAllTitle:"Component updates",updatesAllBadge:"{n} updates",updatesAllUpToDate:"All components up to date",kindWebUi:"Web UI",kindPiCore:"Core",kindPackage:"Package",updatesAllRefresh:"Re-check all",updateCheckFailed:"Check failed",updateBtn:"Update",updateAllBtn:"Update all",updatePkgTabTitle:"Update {name}",updateAllTabTitle:"Update all components",computer:"This PC",rootDir:"Root",noFiles:"No files",filesTruncated:"Directory too large — list truncated (first 2000 shown)",linkFolderTip:"Link folder path to chat",attachInlineTip:"Attach content to chat",referenceTip:"Reference path only (AI reads on demand)",previewFile:"Preview",downloadFile:"Download file",downloadFailed:"Download failed: {error}",fileNotFoundShort:"File not found",pluginMountFailed:"Plugin {name} failed to mount",liveOutputOmitted:`…[{n} chars omitted above]…
|
|
154
154
|
`,uploadToFolder:"Upload files to this folder",uploadToCurrentDir:"Upload files to current directory",protocolMismatch:"Page version differs from the server (the app was just updated). Refresh the page to restore full functionality.",selectLinesHint:"Click a line to select; drag or Shift+click for a range",enableWrap:"Enable line wrap",disableWrap:"Disable line wrap",selectedRange:"Selected {n} lines (lines {start}-{end})",fileLines:"{n} lines",selectAll:"Select all",clearSelection:"Clear",addToChat:"Add to chat",addedToChat:"Added",previewTruncated:"⚠ File too large — previewing the first 512KB",previewLinesTruncated:"… too many lines — showing the first {n}",binaryFile:"🔣 Binary file — first 4KB shown as hex",binaryHexTruncated:" (file larger — download for the full file)",previewNotSupported:"This file type can't be previewed (only images / videos / text)",emptyFile:"(empty file)",editFile:"Edit file",exitEditFile:"Exit editing",saveFile:"Save file",discardFileChanges:"Discard unsaved changes?",fileSaved:"Saved",fileEditTruncated:"The preview is incomplete, so this file can't be edited",showMarkdownSource:"Show Markdown source",showMarkdownPreview:"Show Markdown preview",fullscreen:"Fullscreen",exitFullscreen:"Exit fullscreen",zoomIn:"Increase font size",zoomOut:"Decrease font size",resetZoom:"Reset zoom",pluginRequest:"Plugin request",modelQuestion:"Model question",modelQuestionCustom:"Custom answer (optional)",modelQuestionSubmit:"Submit answer",questionTimeout:"⏳ {s}s left — auto-cancels on timeout",questionTimeoutExpired:"Question timed out, resuming conversation…",modelNoVision:"Current model {name} doesn't support images — switch to DeepSeek V4 Flash Vision (exp)",dshSkillsNote:"DSH uses runtime-built-in skills (dsh-skill); toggling is not supported in settings yet",dshExtensionsNote:"DSH has no pi extension system; capabilities are runtime-built-in (MCP/subagent/goal/plan/skill…)",dshReviewPromptNote:"DSH has no separate reviewer: this text is appended to the system prompt for goal rounds",dshVisionHiddenNote:"DSH supports real image input (DeepSeek V4 Flash Vision (exp) only) — no vision bridge needed",dshNoReviewModel:"DSH has no separate reviewer model — the model self-certifies goal completion; max rounds = auto-iteration count",noOptions:"(no options)",inputPlaceholder:"Enter content",soundHeader:"Sound notifications",enableSound:"Enable sound",preview:"Preview",volume:"Volume",notifyHeader:"Desktop notifications",notifyEnable:"Enable desktop notifications",notifyEnableDesc:"Ping you when a session finishes or needs your input, even while you're in another app. Requires permission; only fires when this page is not focused.",notifyDenied:"Notification permission was blocked — enable notifications for this site in your browser / system settings.",notifyUnsupported:"Notifications are not supported by this browser.",notifyDoneTitle:"Task finished",notifyDoneBody:"The session finished and is ready for your input.",notifyQuestionTitle:"Needs your input",notifyQuestionBody:"pi is waiting for your answer to a question.",notifyErrorTitle:"Something went wrong",notifyErrorBody:"A session reported an error.","sound.question":"Question popup","sound.question.desc":"When ask_user_question appears","sound.done":"Reply finished","sound.done.desc":"When the agent finishes a turn","sound.start":"Reply started","sound.start.desc":"When the agent starts a new turn","sound.error":"Error","sound.error.desc":"When an error notice appears",setupTitle:"pi agent config not detected",setupDesc:"pi-web-ui needs pi's config directory (~/.pi/agent) and at least one API key to run the agent. pi has built-in providers such as openai, anthropic, and deepseek — just pick one and enter a key, no terminal needed.",installFailed:"✖ pi agent installation failed:",retryInstall:"Retry install",skip:"Skip",installDone:"✅ pi agent CLI installed. Pick a provider and enter an API key to start chatting:",cliReadyHint:"✅ pi agent CLI already installed locally. Pick a provider and enter an API key to start chatting:",provider:"Provider",configured:"configured",providerKeyReady:"This provider already has a key — use it or replace it.",apiKey:"API key",saving:"Saving…",saveAndStart:"Save and start using",recheck:"Recheck",installing:"Installing pi agent CLI…",autoInstall:"Auto-install pi agent",attachment:"Attachment",plugin:"plugin",unknown:"unknown",thinkingWait:"Thinking",exitCode:"Exit code {code}",cancelled:"Cancelled",truncated:"… content too long, truncated in this view",outputTruncated:"… output too long, truncated in this view",refOnlyShort:"Reference only",folderRefShort:"Folder · reference only",inlineLines:"Inline · {n} lines",inlineLinesRange:"Lines {start}-{end}",image:"🖼 Image",bridgedVision:"👁 Transcribed",bridgedVisionDetail:"Image transcribed by the vision bridge (current model can't see images)",folderNotExpanded:"Folder — content not expanded, the agent will browse it as needed",fileNotExpanded:"Large file ({size}) — content not expanded, the agent will read it as needed","role.user":"You","role.assistant":"pi","role.tool":"Tool","role.bash":"Terminal","role.branch":"Branch summary","role.compaction":"Context compacted",directory:"Directory",waitingResponse:"Waiting for model response…",backToBottom:"Back to bottom",questionNavTitle:"Questions",searchPlaceholder:"Search in conversation…",searchNoResults:"No results",searchModels:"Filter models…",noModelMatches:"No matching models",modelUsedCount:"used {n}×",searchGlobal:"Search",searchGlobalTip:"Global search: sessions / projects / files (Ctrl+K)",gsPlaceholder:"Search projects, past conversations, workspace files…",gsHint:"Type to search full conversation text (AI replies included), recent projects and file names in the current workspace at once",gsSessions:"Conversations",gsProjects:"Projects",gsFiles:"Files",gsNoResults:"No matches",gsSearching:"Searching…",gsTruncated:"Too many matches — showing a subset",gsCurrentProject:"current",gsOpenPreview:"Open file preview",gsNavigate:"select",gsOpen:"open",gsCloseHint:"close",bgTaskCommand:"Command",searchPrev:"Previous (Shift+Enter)",searchNext:"Next (Enter)",searchClose:"Close (Esc)",questionNavTip:"All questions in this conversation — hover to expand, click to jump","tpl.title":"Prompt templates","tpl.hint":"Click a card to fill the input; ✏️ to edit or delete; add your own too","tpl.clickCard":"Click to fill the input","tpl.editTpl":"Edit / delete template","tpl.openPicker":"Prompt templates (reusable prompts, anytime)","tpl.pickerTitle":"Prompt templates","tpl.pickerHint":"Click a card to fill the input; ✏️ to edit or delete; add your own too","tpl.add":"New template","tpl.addDesc":"Save a workflow you use often","tpl.reset":"Restore defaults","tpl.resetConfirm":"Restore defaults?","tpl.builtin":"Built-in","tpl.custom":"Custom","tpl.newTitle":"New prompt template","tpl.editTitle":"Edit prompt template","tpl.fieldIcon":"Icon","tpl.fieldTitle":"Title","tpl.fieldTitlePh":"Short title shown on the card","tpl.fieldDesc":"Description","tpl.fieldDescPh":"One-liner shown on the card","tpl.fieldPrompt":"Prompt","tpl.fieldPromptPh":"The full prompt sent to the agent","tpl.required":"Title and prompt are required","tpl.save":"Save","tpl.fill":"Fill input","tpl.fillTip":"Fill the input so you can tweak it before sending","tpl.sendNow":"Send now","tpl.sendTip":"Send immediately as a new conversation","tpl.delete":"Delete","tpl.deleteTip":"Delete this custom template","tpl.remove":"Remove from library","tpl.removeTip":"Remove this built-in template; restore later via “Restore defaults”","tpl.restore":"Restore default","tpl.restoreTip":"Discard your edits and restore the built-in default","tpl.sk.setup":"Repo setup","tpl.sk.setup.desc":"Give the repo a baseline that other workflows can use","tpl.sk.setup.prompt":`Scan this repository and build the baseline context other workflows rely on, then report concisely:
|
|
155
155
|
|
|
156
156
|
1. Project type, tech stack and directory layout
|
|
@@ -301,26 +301,26 @@ Keep going until the plan holds up.`,"tpl.sk.tdd":"Test-driven","tpl.sk.tdd.desc
|
|
|
301
301
|
2. Make them pass with the minimal implementation
|
|
302
302
|
3. Refactor while keeping tests green
|
|
303
303
|
|
|
304
|
-
Avoid three test anti-patterns: tests coupled to the implementation, tautological assertions (always true), and horizontal slicing (surface only). Report after each step and run the tests.`,error:"Error",done:"Done",running:"Running…",toolQueued:"Queued",copyArgs:"Copy args",errorOutput:"Error output",output:"Output",waitingOutput:"Waiting for output…",toolDoneWaitingModel:"Done · waiting on model",waitingModel:"Waiting for model response…",thinkingNow:"Thinking",thinkingPreview:"Thinking: {preview}",commands:"Commands",newCommand:"New command",newTerminal:"New terminal",name:"Name",command:"Command",cwdHint:"(${pwd} = current working directory)",noCommands:"No commands yet — click + to add one",clickToRun:"Click to run",edit:"Edit",delete:"Delete",confirmQ:"Confirm?",builtinTerminal:"Built-in terminal",termEmptySub:"Click a command on the left to run it, or + on the right for a new terminal",noTerminal:"No terminals",exited:"(exited{code})",exitBanner:"[Process exited with code {code}]",closeTerminal:"Close terminal",renameTerminal:"Rename terminal",rerun:"Reload .pi/commands.json",terminalTitle:"Terminal {n}",aiBashGroup:"Terminal-backed bash",exampleName:"e.g. start dev server",exampleCommand:"e.g. npm run dev",scmTab:"Git",scmTitle:"Source Control",scmRefreshTip:"Re-query git status & diff",scmCurrentBranch:"Current branch",scmUpstreamGone:"Upstream deleted",scmAheadBehind:"↑{ahead} ↓{behind}",scmDetached:"Detached HEAD",scmSelectBranch:"Select branch…",scmRemoteBranches:"Remote branches",scmStageTip:"Stage {path}",scmUnstageTip:"Unstage {path}",scmSwitch:"Switch",scmSwitchBranch:"Switch branch",scmSwitchBranchTip:"Runs git checkout {branch} in the terminal",scmPush:"Push",scmPushTip:"Runs git push in the terminal",scmPull:"Pull",scmPullTip:"Runs git pull in the terminal",scmCommit:"Commit",scmCommitTip:'Runs git commit -m "…" in the terminal (commits staged changes only)',scmCommitAll:"Commit All",scmCommitAllTip:'Runs git add -A && git commit -m "…" in the terminal (stages all changes incl. untracked and commits)',scmCommitPlaceholder:"Type a commit message…",scmChanges:"Changes",scmHistory:"Commit tree",scmCommitDetail:"Commit details",scmSelectCommitHint:"Click a commit on the left to view its details",scmNoHistory:"No commits yet",scmNoChanges:"Working tree clean — no changes",scmNotGitRepo:"Current directory is not a Git repository",scmLoading:"Querying…",scmConnecting:"Waiting for connection…",scmDiff:"Diff",scmSelectFileHint:"Click a file on the left to view its diff",scmNoDiff:"(no diff)",scmStaged:"Staged",scmUnstaged:"Unstaged",scmStagedUnstaged:"Staged + unstaged",scmUntracked:"Untracked",scmUntrackedNote:"Untracked file — stage it with + to include (or use Commit All)",scmQueryFailed:"Git query failed: {error}",scmQueryFailedShort:"Query failed",pluginCommandFallback:"Plugin command",scmTooManyFailures:"Git queries keep failing — click refresh to retry",scmRunsInTerminal:"Commit / branch switch / push / pull run in the terminal",scmViewTerminal:"Open terminal",editProvider:"Edit provider",builtinProviders:"Built-in providers",hintKeyOnly:"Just enter an API key",configuredBadge:"✓ Configured",keyReady:"Key ready",replaceKey:"Replace key",replaceKeyTitle:"Replace the saved key",clearKey:"Clear",clearKeyTitle:"Remove this provider's key stored in auth.json; it returns to unconfigured (env-var sourced keys can't be cleared here)",clearKeyConfirm:"Clear the stored key for {id}? Its models will leave the list until you configure it again.",cloneProvider:"Add key",cloning:"Adding",cloneProviderTitle:"Add a second API key for this provider (baseUrl and model list are copied automatically)",pasteKey:"Paste API key…",savingKey:"Saving",saveKey:"Save key",addKey:"Add key",addKeyPlaceholder:"Paste the key value…",keyNamePh:"Name (optional, e.g. backup)",providerIdPlaceholder:"Provider ID",baseUrlExamplePh:"baseUrl, e.g. https://api.opencode.ai/zen/v1 or http://127.0.0.1:4096",saveAllBatch:"Save all ({n})",netDisconnected:"Network disconnected — reconnect and retry",advancedEdit:"Advanced edit",batchCreateProviders:"Batch-create providers ({n} APIs)",secondKeyTitle:"Add a second key for {api} · {baseUrl} · {n} models — just name the new provider and enter the key.",noBaseUrlShort:"(no baseUrl)",providerNameLabel:"Provider name",providerNameHint:"(new ID, e.g. opencode-2)",apiKeyLabel:"API key",secondKeyPlaceholder:"sk-… second key",batchDesc:"This provider has multiple APIs ({apis}); it was split into {n} custom providers. Save each so all models (e.g. muse-spark) work. Enter one shared second key to save all at once.",batchKeyLabel:"Shared API key (applies to all {n} providers)",modelsCountShort:"{n} models: ",noKeyYet:"No key yet — add one to use this provider",activateKey:"Set active",removeKey:"Remove",removeKeyConfirm:"Remove this key? It must be re-configured to be used again.",customProviders:"Custom providers",customDesc:"For Ollama / vLLM / OpenAI-compatible proxies, etc. Written to pi's models.json — hot-reloaded immediately.",noCustomProviders:"No custom providers yet",modelsCount:"{n} models",addProvider:"Add provider",providerId:"Provider ID",providerIdHint:"(required, e.g. ollama / my-proxy)",displayName:"Display name",displayNamePh:"My proxy",apiType:"API type",baseUrlHint:"(OpenAI-compatible endpoint)",apiKeyHint:"sk-… (optional — uses the auth.json key)",authHeader:"Auto-add Authorization header",modelsTitle:"Models",modelIdReq:"Model ID (required)",text:"Text",textImage:"Text+image",contextWindow:"Context",maxOutput:"Max output",removeModel:"Remove model",addModel:"Add model",deleteProviderConfirm:"Delete provider {id} and its {n} models?",fetchModels:"Fetch model list",fetchModelsHint:"Pull model IDs from the baseUrl /models endpoint (server-side, no CORS)",fetchingModels:"Fetching…",fetchModelsOk:"Fetched {n} models",fetchModelsEmpty:"The endpoint returned no models",fetchModelsErr:"Fetch failed: {msg}",fetchModelsNeedBaseUrl:"Enter a baseUrl first",goalBarTitle:"Goal",goalBarPlaceholder:"Set a goal; the agent's output is auto-reviewed…",goalBarSet:"Start",goalBarClear:"Cancel",goalBarLocked:"Locked: applies to every later turn",goalBarUnlocked:"This turn only (cleared afterwards)",goalBarReviewModel:"Review model",goalBarUseMainModel:"Use the main model",goalBarMaxRounds:"Max rounds",goalBarMaxRoundsTip:"Max review-revision rounds; 0 or empty = unlimited (keep revising until it passes)",goalBarUnlimitedShort:"Unlimited",goalBarReviewing:"Reviewing…",goalBarRound:"Round {n}",goalBarActive:"Goal active",goalBarPassed:"Passed",goalBarFailed:"Failed",goalBarStatusPending:"Waiting to generate…",goalWizardBtn:"AI Scrape",goalWizardTip:"Let AI refine the requirement into a goal via a Q&A survey",goalWizardRunning:"Scoping the goal",goalWizardAnswer:"Answer",goalWizardCard:"Goal survey",settings:"Settings",settingsTitle:"Settings",settingsDesc:"Changes apply immediately: system prompt, skill and extension toggles rebuild the current session; review instructions and review skills affect later goal reviews (main-session changes are deferred while streaming).",settingsSystemPrompt:"System prompt",settingsPromptHistory:"Input history",settingsPromptHistoryDesc:"Cycle previous prompts with ↑/↓ in the input — global across conversations (localStorage)",promptHistoryMax:"Max entries",promptHistoryMaxHint:"Oldest entries are dropped when exceeded (1–500)",promptHistoryCharLimit:"Limit characters per entry",promptHistoryCharLimitHint:"When enabled, overlong prompts are truncated before saving",promptHistoryCharLimitPlaceholder:"Max chars (100–20000)",promptHistoryClear:"Clear history",promptHistoryClearConfirm:"Confirm clear?",promptHistoryCleared:"Input history cleared",promptHistoryCount:"{n} entries",promptHistoryEmpty:"No history yet — ↑/↓ has nothing to cycle",settingsPromptMode:"Mode",promptModeAppend:"Append",promptModeReplace:"Replace",promptAppendHint:"Append mode: your text is appended to the end of the default system prompt (recommended — keeps the default behavior constraints).",promptReplaceHint:"Replace mode: your text fully replaces the system prompt (project context and skills are still appended automatically). After switching, the editor shows the built-in default prompt ready to edit; blurring without changes keeps the default.",promptPlaceholder:"Type a custom system prompt… (applied on blur)",settingsViewPrompt:"View the current full prompt",settingsViewPromptHint:"The full system prompt actually in effect for this conversation (custom append/replace text, project context, skills and tool guidance). Read-only.",settingsViewPromptEmpty:"Session not ready yet — no system prompt available.",settingsSkills:"Skills",settingsReview:"Goal review",settingsReviewDesc:"Configure extra instructions and skills for the isolated goal-review session; the main session is unaffected.",settingsReviewSkills:"Skills available to review",reviewPromptPlaceholder:"Type custom review instructions… (applied on blur)",reviewPromptHint:"These instructions are added to the review task; pass/fail JSON output is still enforced. Skill toggles apply only to review.",settingsVisionBridge:"Vision bridge",settingsVisionBridgeDesc:"When the current model can't see images, send them to a configured vision model and transcribe into text evidence first",visionBridgeEnabled:"Enable vision bridge",visionBridgeModel:"Transcription model",visionBridgeAuto:"Auto (in order)",visionBridgeNoModels:"No configured vision model found: add any image-capable model (e.g. qwen-vl, GLM-4V, Gemini) in Model config to enable automatically",visionBridgeOffHint:"Disabled: images are sent as-is, a text-only model may not see them",visionBridgeCurrent:"Current transcription model: {model}",visionBridgePromptMode:"Transcription prompt",settingsMarkers:"Markers",settingsMarkersDesc:"Let the AI write [[todo:...]] / [[svc:...]] / [[notify:...]] / [[conv:rename:...]] inline markers in replies to update state without a tool round-trip. Global off disables all; per-marker toggles give fine control.",markersEnabled:"Markers enabled (global)",markersEnabledDesc:"Off = no marker guidance injected and no parsing; markers stay as plain text.",markersOffHint:"Globally off: all markers disabled — the AI won't write markers and no side effects fire.",markerGroupTodo:"todo — tasks",markerGroupSvc:"svc — background services",markerGroupNotify:"notify — non-blocking hints",markerGroupRename:"conv/rename — rename chat",markerRenameTip:"[[conv:rename:Title]] or [[rename:set:Title]] renames the current conversation (≤80 chars)",settingsTerminalTools:"Terminal tools",terminalToolsEnabled:"Enable persistent terminal tools",settingsTerminalToolsDesc:"Let the AI use the built-in terminal for interactive programs (REPLs/vim), long-running servers, continuous output watching, or when you ask it to work in the visible terminal; ordinary commands still go through the one-shot bash tool",terminalToolsOffHint:"Disabled: the AI has no terminal_* tools and receives no usage guidance",settingsMessageDisplay:"Message display",thinkingWrap:"Show full thinking",thinkingWrapDesc:"On: thinking always expands fully and wraps (live reasoning visible while streaming); Off: collapses to a one-line summary with the latest text shown live while streaming",toolsWrap:"Show full tools",toolsWrapDesc:"On: tool calls always expand fully showing arguments and output; Off: collapsed by default, click to expand",terminalBashTakeover:"Terminal-backed bash",terminalBashTakeoverDesc:"This switch decides whether bash is overridden to a terminal version: OFF = native SDK bash (process spawn, no terminal); ON = runs in a visible terminal, where the persist parameter decides (on top of the switch) one-shot (false — process exits when the command finishes, output retained) vs persistent (true — shell state retained across calls, silent commands move to the background and notify the AI)",terminalBashIdleMs:"Silence-to-background threshold (ms)",terminalBashIdleMsDesc:"In persistent-terminal mode, when a command produces no output for this long, stop blocking and let it keep running in the background; the AI is notified when it finishes. 0 = always wait until completion (default 15000)",visionBridgePromptPlaceholder:"Type a custom transcription prompt… (empty = built-in default, applied on blur)",visionBridgePromptAppendHint:"Append mode: custom text is appended after the built-in transcription prompt (recommended — keeps the verbatim-transcription contract).",visionBridgePromptReplaceHint:"Replace mode: custom text replaces the built-in transcription prompt entirely. After switching, the editor shows the built-in default prompt ready to edit; blurring without changes keeps the default.",uninstallExt:"Uninstall",uninstallConfirm:"Confirm?",uninstallConfirmHint:"Click again to confirm — runs pi remove in the terminal",uninstallHint:"Runs pi remove in a visible terminal, then refreshes the list automatically",uninstallTitle:"Uninstall",pluginUpdate:"Update",pluginUpdateHint:"Re-installs from the recorded source (--force, keeps config.json), then refreshes the plugin list automatically",pluginUninstallHint:"Runs pi-web-ui uninstall in a visible terminal (click again to confirm), then refreshes the list automatically",settingsExtensions:"Extensions",settingsUiPlugins:"UI plugins",noUiPlugins:"No UI plugins installed (<dataDir>/plugins/)",dshPatches:"DSH user patches",dshPatchesDesc:"Cordis patches loaded at runtime boot, in filename order (<dataDir>/dsh-patches/*.yml). New/edited files take effect after 'Rescan' restarts the runtime; broken files are skipped and logged to runtime stderr.",dshPatchesRescan:"Rescan",dshPatchesRescanHint:"Re-scan the patch directory and restart the DSH runtime so new patches take effect",dshPatchesEmpty:"No patch files yet",dshPatchesPath:"Patch directory: ",uiPluginNoSource:"Installed manually — no recorded source, online update unavailable",uiPluginPerms:"Permissions",pluginSettingsSave:"Save plugin settings",pluginSettingsSaving:"Saving…",pluginSettingsReset:"Reset defaults",settingsPresets:"Presets",settingsSubagentTemplates:"Subagent templates",settingsSubagentTemplatesDesc:"Presets for spawned subagents (role system prompt + skills/extensions whitelist). AI may pick a template (subagent_spawn template param) or spawn without one; disabled templates stay in the panel but are invisible to AI tools.",noSubagentTemplates:"No subagent templates yet. AI can pick a template when spawning a subagent (role prompt + skills/extensions whitelist), or spawn without a template param for default config.",subagentTemplateNew:"New template",subagentTemplateEdit:"Edit",subagentTemplateClosed:"Disabled",tplDefaultBadge:"Built-in",subagentTemplateOffHint:"Disabled templates stay in the panel and can be re-enabled, but AI tools can't see or pick them",subagentTemplateEnable:"Enable",subagentTemplateDisable:"Disable",tplNamePlaceholder:"Template name (referenced by AI via subagent_spawn's template param)…",tplDescriptionPlaceholder:"Description (AI uses it to judge when to pick this template)…",tplPromptModeLabel:"System prompt mode",tplSystemPromptLabel:"System prompt",tplSystemPromptPlaceholder:"Template role system prompt… (may be empty in append mode)",tplWhitelistHint:"Whitelist: checked = the subagent only gets these; none checked = follow the main session settings",tplSkillsLabel:"Skills whitelist",tplExtensionsLabel:"Extensions whitelist",tplSave:"Save template",tplCancel:"Cancel edit",tplDelete:"Delete template",tplInherit:"Follow main session",settingsEnabled:"Enabled",settingsDisabled:"Disabled",presetNamePlaceholder:"Preset name…",saveAsPreset:"Save as preset",applyPreset:"Apply",deletePreset:"Delete preset",noSkills:"No skills",noExtensions:"No extensions",noPresets:"No presets yet (tune the settings above, then save them as a preset)",loadingSession:"Loading session…",connectingServer:"Connecting to pi-web-ui server…"},En=l.createContext(null);function sa(){try{const t=localStorage.getItem(Tn);if(t==="zh"||t==="en")return t}catch{}return"zh"}function na({children:t}){const[s,n]=l.useState(sa),r=l.useCallback(a=>{n(a);try{localStorage.setItem(Tn,a)}catch{}},[]),c=l.useCallback((a,o)=>{let u=Fs[a];if(s==="zh"&&(u=Bs[a]),o)for(const[m,y]of Object.entries(o))u=u.replaceAll(`{${m}}`,String(y));return u},[s]);l.useEffect(()=>{document.documentElement.lang=s==="zh"?"zh-CN":"en",document.title=s==="zh"?Bs.docTitle:Fs.docTitle},[s]);const i=l.useMemo(()=>({locale:s,setLocale:r,t:c}),[s,r,c]);return e.jsx(En.Provider,{value:i,children:t})}function mt(){const t=l.useContext(En);if(!t)throw new Error("useI18n must be used within LanguageProvider");return t}function xe(){return mt().t}const ia=[{kind:"question",labelKey:"sound.question",descKey:"sound.question.desc"},{kind:"done",labelKey:"sound.done",descKey:"sound.done.desc"},{kind:"start",labelKey:"sound.start",descKey:"sound.start.desc"},{kind:"error",labelKey:"sound.error",descKey:"sound.error.desc"}];function $s({settings:t,onChange:s,onPreview:n}){const r=xe(),c=i=>s({...t,...i});return e.jsxs("div",{className:"sound-menu",children:[e.jsx("div",{className:"dd-header",children:r("soundHeader")}),e.jsxs("label",{className:"sound-row sound-master",children:[e.jsxs("span",{className:"sound-label",children:[e.jsx(yn,{className:"sound-icon"}),e.jsx("span",{children:r("enableSound")})]}),e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:i=>c({enabled:i.target.checked})})]}),ia.map(({kind:i,labelKey:a,descKey:o})=>e.jsxs("label",{className:`sound-row ${t.enabled?"":"disabled"}`,children:[e.jsxs("span",{className:"sound-label",children:[e.jsx("span",{className:"sound-name",children:r(a)}),e.jsx("span",{className:"sound-desc",children:r(o)})]}),e.jsxs("span",{className:"sound-right",children:[e.jsx("button",{type:"button",className:"sound-preview",title:r("preview"),disabled:!t.enabled,onClick:u=>{u.preventDefault(),n(i)},children:r("preview")}),e.jsx("input",{type:"checkbox",checked:t[i],disabled:!t.enabled,onChange:u=>c({[i]:u.target.checked})})]})]},i)),e.jsxs("div",{className:`sound-volume ${t.enabled?"":"disabled"}`,children:[e.jsx("span",{className:"sound-name",children:r("volume")}),e.jsx("input",{type:"range",min:0,max:100,step:5,value:t.volume,disabled:!t.enabled,onChange:i=>c({volume:Number(i.target.value)})}),e.jsxs("span",{className:"sound-vol-num",children:[t.volume,"%"]})]})]})}let Dt=null;function aa(t){if(t===void 0){const n=globalThis.document;if(n&&typeof n.baseURI=="string"&&n.baseURI)try{t=new URL(n.baseURI).pathname}catch{}if(t===void 0)return"/"}if(!t||t==="/")return"/";let s=t.replace(/index\.html$/i,"");return s.endsWith("/")||(s+="/"),s}function Pn(){return Dt===null&&(Dt=aa()),Dt}function ra(t,s){return s==="/"?t:s+t.replace(/^\/+/,"")}function Ve(t){return ra(t,Pn())}const Mn="pi-web-notify",At={enabled:!1};function Rn(){try{const t=localStorage.getItem(Mn);if(!t)return{...At};const s=JSON.parse(t);return{enabled:typeof s.enabled=="boolean"?s.enabled:At.enabled}}catch{return{...At}}}function Hs(t){try{localStorage.setItem(Mn,JSON.stringify(t))}catch{}}function ot(){return typeof window<"u"&&"Notification"in window}function la(){return ot()?Notification.permission:"denied"}async function oa(){if(!ot())return"denied";try{return await Notification.requestPermission()}catch{return"denied"}}async function _t(t,s){var r;if(!ot()||document.hasFocus()||!Rn().enabled||Notification.permission!=="granted")return;const n={body:s,icon:Ve("/icons/icon-192.png"),badge:Ve("/icons/icon-192.png"),tag:"pi-web-ui"};try{const c=await((r=navigator.serviceWorker)==null?void 0:r.getRegistration());c&&typeof c.showNotification=="function"?c.showNotification(t,n):new Notification(t,n)}catch{}}function Os(){const t=xe(),[s,n]=l.useState(Rn),[r,c]=l.useState(()=>ot()?la():"denied"),i=async a=>{const o={...s,enabled:a};if(n(o),Hs(o),a){const u=await oa();if(c(u),u!=="granted"){const m={...o,enabled:!1};n(m),Hs(m)}}};return e.jsxs("div",{className:"sound-menu",style:{borderTop:"1px solid var(--border-color, rgba(255,255,255,.08))",marginTop:6,paddingTop:6},children:[e.jsx("div",{className:"dd-header",children:t("notifyHeader")}),e.jsxs("label",{className:"sound-row sound-master",children:[e.jsxs("span",{className:"sound-label",children:[e.jsx(Ji,{className:"sound-icon"}),e.jsx("span",{children:t("notifyEnable")})]}),e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:a=>i(a.target.checked)})]}),e.jsx("div",{className:"sound-desc",style:{padding:"2px 8px 4px",opacity:.7,fontSize:"0.82em"},children:t("notifyEnableDesc")}),!ot()&&e.jsx("div",{className:"sound-desc",style:{padding:"0 8px 4px",opacity:.7,fontSize:"0.82em"},children:t("notifyUnsupported")}),r==="denied"&&e.jsx("div",{className:"sound-desc",style:{padding:"0 8px 4px",opacity:.7,fontSize:"0.82em"},children:t("notifyDenied")})]})}function ca({chat:t,send:s,terminal:n,view:r,plugins:c,onViewChange:i,onOpenPanel:a,onOpenSettings:o,onOpenBgTasks:u,onOpenGlobalSearch:m,sound:y,onSoundChange:g,onSoundPreview:x,themes:b,theme:T,onThemeChange:D}){var L;const{locale:K,setLocale:S,t:j}=mt(),[Q,G]=l.useState(!1),[J,U]=l.useState(!1),[E,H]=l.useState(!1),[k,_]=l.useState(!1),[F,Z]=l.useState(!1),$=[{value:"zh",label:j("langZh")},{value:"en",label:j("langEn")}],X=t.ready?j("connected"):t.status==="closed"?j("reconnecting"):j("connecting"),Y=t.ready?"ok":"busy",M=()=>{var I,ee;if(!t.ready)return;const d=j("updateTabTitle"),w={name:d,command:"npm i -g pi-web-ui@latest",cwd:"${pwd}"},h=t.terminals.find(q=>q.title===d);h?(n.restart(h.id),s({type:"run_command",terminalId:h.id,conversationId:h.conversationId,command:w,cols:80,rows:24})):n.create({id:Ue(),conversationId:t.activeConversationId||((I=t.state)==null?void 0:I.conversationId)||"",title:d,cwd:((ee=t.state)==null?void 0:ee.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:w}),_(!1),Z(!1),i("terminal")},R=(d,w)=>{var ee,q;if(!t.ready||d.length===0)return;const h={name:w,command:ta(d),cwd:"${pwd}"},I=t.terminals.find(ae=>ae.title===w);I?(n.restart(I.id),s({type:"run_command",terminalId:I.id,conversationId:I.conversationId,command:h,cols:80,rows:24})):n.create({id:Ue(),conversationId:t.activeConversationId||((ee=t.state)==null?void 0:ee.conversationId)||"",title:w,cwd:((q=t.state)==null?void 0:q.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:h}),_(!1),Z(!1),i("terminal")},C=t.updatesAll??[],O=C.filter(d=>!d.upToDate&&!d.error).length,z=C.filter(d=>!d.upToDate&&!d.error&&d.kind!=="webui"),ne=()=>e.jsxs("div",{className:"dd-updates-all",children:[e.jsx("div",{className:"dd-header",children:j("updatesAllTitle")}),t.updatesAll===null?e.jsx("div",{className:"dd-note",children:j("checkingUpdate")}):C.length===0?e.jsx("div",{className:"dd-note",children:j("updatesAllUpToDate")}):e.jsx("ul",{className:"dd-all-list",children:C.map(d=>e.jsxs("li",{className:`dd-all-item${d.error?" err":d.upToDate?"":" warn"}`,children:[e.jsx("span",{className:"dd-all-name",title:d.name,children:d.name}),e.jsx("span",{className:"dd-all-kind",children:d.kind==="webui"?j("kindWebUi"):d.kind==="pi-core"?j("kindPiCore"):j("kindPackage")}),e.jsx("span",{className:"dd-all-vers",children:d.error?j("updateCheckFailed"):d.upToDate?`v${d.current}`:e.jsxs(e.Fragment,{children:["v",d.current," → v",d.latest]})}),d.kind!=="webui"&&!d.upToDate&&!d.error&&e.jsx("button",{type:"button",className:"dd-update-btn",onClick:()=>R([d],j("updatePkgTabTitle",{name:d.name})),children:j("updateBtn")})]},`${d.kind}:${d.name}`))}),e.jsxs("div",{className:"dd-actions",children:[z.length>0&&e.jsx("button",{type:"button",className:"dd-refresh accent",style:{flex:1},onClick:()=>R(z,j("updateAllTabTitle")),children:j("updateAllBtn")}),e.jsx("button",{type:"button",className:"dd-refresh",style:z.length>0?{flex:1}:void 0,onClick:()=>s({type:"check_updates_all",force:!0}),children:j("updatesAllRefresh")})]})]}),v=()=>{var d,w;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"dd-update",children:[e.jsxs("div",{className:"dd-row",children:[e.jsx("span",{children:j("currentVersion")}),e.jsxs("b",{children:["v",((d=t.update)==null?void 0:d.current)??"…"]})]}),e.jsxs("div",{className:"dd-row",children:[e.jsx("span",{children:j("latestVersion")}),e.jsx("b",{children:t.update===null?j("checkingUpdate"):t.update.error?t.update.error:t.update.latest?`v${t.update.latest}`:j("checkingUpdate")})]}),t.update&&t.update.upToDate&&e.jsx("div",{className:"dd-note ok",children:j("upToDate")}),t.update&&!t.update.upToDate&&t.update.latest&&e.jsx("div",{className:"dd-note warn",children:j("updateAvailable",{version:t.update.latest})}),((w=t.update)==null?void 0:w.latestPublishedAt)&&Date.now()-new Date(t.update.latestPublishedAt).getTime()<30*6e4&&e.jsx("div",{className:"dd-note warn",children:j("updateJustPublished",{version:t.update.latest??""})}),t.update&&!t.update.upToDate&&t.update.latest&&e.jsx("div",{className:"dd-note",children:j("updateTerminalHint")})]}),e.jsxs("div",{className:"dd-actions",children:[e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>s({type:"check_update"}),children:t.update===null?j("checkingUpdate"):j("checkUpdate")}),t.update&&!t.update.upToDate&&t.update.latest&&e.jsx("button",{type:"button",className:"dd-refresh accent",onClick:M,children:j("updateNow")})]})]})};return e.jsxs("header",{className:"topbar",children:[e.jsxs("div",{className:"brand",children:[e.jsx("button",{type:"button",className:"panel-toggle",title:j("openHistory"),onClick:()=>a("left"),children:e.jsx(Fi,{})}),e.jsx("span",{className:"brand-logo",children:"π"}),e.jsx("span",{className:"brand-name",children:"pi-web-ui"}),e.jsx("span",{className:`conn-dot ${Y}`,title:X}),e.jsx("span",{className:"conn-label",children:X})]}),e.jsxs("div",{className:"topbar-actions",children:[e.jsxs("div",{className:"view-switch",role:"tablist","aria-label":j("viewSwitch"),children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":r==="chat",className:r==="chat"?"active":"",onClick:()=>i("chat"),children:[e.jsx(st,{}),e.jsx("span",{children:j("chat")})]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":r==="terminal",className:r==="terminal"?"active":"",onClick:()=>i("terminal"),children:[e.jsx(tt,{}),e.jsx("span",{children:j("terminal")})]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":r==="git",className:r==="git"?"active":"",onClick:()=>i("git"),children:[e.jsx(yt,{}),e.jsx("span",{children:j("scmTab")})]}),c.map(d=>{const w=d.error?`${d.name}: ${d.error}`:d.description?`${d.name} — ${d.description}`:d.name;return e.jsxs("button",{type:"button",role:"tab","aria-selected":r===`plugin:${d.id}`,className:`plugin-tab${r===`plugin:${d.id}`?" active":""}${d.error?" broken":""}`,title:w,onClick:()=>i(`plugin:${d.id}`),children:[d.icon?e.jsx("span",{"aria-hidden":!0,children:d.icon}):null,e.jsx("span",{children:d.name})]},d.id)})]}),e.jsxs("div",{className:"topbar-desktop",children:[e.jsxs("button",{type:"button",className:"chip",title:j("searchGlobalTip"),onClick:m,children:[e.jsx(Nt,{}),e.jsx("span",{className:"chip-sub",children:j("searchGlobal")})]}),e.jsxs("button",{type:"button",className:"chip bg-task-chip","data-tip":j("bgTasksTip"),onClick:u,children:[e.jsx(Ct,{}),e.jsx("span",{className:"chip-sub",children:j("bgTasks")}),t.bgServers.length>0&&e.jsx("span",{className:"bg-task-badge",children:t.bgServers.length})]}),e.jsxs("button",{type:"button",className:"chip",title:j("settingsTitle"),onClick:o,children:[e.jsx(wt,{}),e.jsx("span",{className:"chip-sub",children:j("settings")})]}),e.jsxs(ze,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(yn,{}),e.jsx("span",{className:"chip-sub",children:j("sound")})]}),open:Q,onOpenChange:G,children:[e.jsx($s,{settings:y,onChange:g,onPreview:x}),e.jsx(Os,{})]}),e.jsxs(ze,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(qi,{}),e.jsx("span",{className:"chip-sub",children:K==="zh"?j("langZh"):"EN"})]}),open:J,onOpenChange:U,children:[e.jsx("div",{className:"dd-header",children:j("language")}),$.map(d=>e.jsx(Ie,{active:K===d.value,onClick:()=>{S(d.value),U(!1)},children:d.label},d.value))]}),e.jsxs(ze,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(Ii,{}),e.jsx("span",{className:"chip-sub",children:j("theme")})]}),open:E,onOpenChange:H,children:[e.jsx("div",{className:"dd-header",children:j("theme")}),e.jsx(Ie,{active:T===null,onClick:()=>{D(null),H(!1)},children:j("themeDefault")}),b.map(d=>e.jsx(Ie,{active:T===d.id,onClick:()=>{D(d.id),H(!1)},children:K==="en"?d.nameEn??d.name:d.name},d.id))]}),e.jsxs(ze,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(ls,{}),e.jsxs("span",{className:"chip-sub",children:["v",((L=t.update)==null?void 0:L.current)??"…"]}),t.update&&!t.update.upToDate&&e.jsx("span",{className:"update-dot",title:j("updateAvailable",{version:t.update.latest??""})}),O>0&&e.jsx("span",{className:"update-badge",children:j("updatesAllBadge",{n:O})})]}),open:k,onOpenChange:d=>{_(d),d&&(s({type:"check_update"}),s({type:"check_updates_all"}))},fit:!0,children:[e.jsx("div",{className:"dd-header",children:j("update")}),v(),ne()]}),e.jsx("a",{className:"chip github",href:"https://github.com/xing-shuyin/pi-web-ui",target:"_blank",rel:"noreferrer noopener",title:j("githubRepo"),children:e.jsx(As,{})})]}),e.jsxs("button",{type:"button",className:"chip newchat","data-tip":j("newChatTip"),onClick:()=>s({type:"new_chat"}),children:[e.jsx(He,{}),e.jsx("span",{children:j("newChat")})]}),e.jsx("div",{className:"topbar-more",children:e.jsxs(ze,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(_i,{}),e.jsx("span",{className:"chip-sub",children:j("more")}),t.update&&!t.update.upToDate&&e.jsx("span",{className:"update-dot"})]}),open:F,onOpenChange:d=>{Z(d),d&&(s({type:"check_update"}),s({type:"check_updates_all"}))},children:[e.jsx("div",{className:"dd-header",children:j("sound")}),e.jsx("div",{className:"dd-header",children:j("settings")}),e.jsxs(Ie,{onClick:()=>{Z(!1),o()},children:[e.jsx(wt,{})," ",j("settingsTitle")]}),e.jsxs(Ie,{onClick:()=>{Z(!1),m()},children:[e.jsx(Nt,{})," ",j("searchGlobal")]}),e.jsxs(Ie,{onClick:()=>{Z(!1),u()},children:[e.jsx(Ct,{})," ",j("bgTasks"),t.bgServers.length>0&&e.jsx("em",{className:"bg-task-badge",children:t.bgServers.length})]}),e.jsx($s,{settings:y,onChange:g,onPreview:x}),e.jsx(Os,{}),e.jsx("div",{className:"dd-header",children:j("language")}),$.map(d=>e.jsx(Ie,{active:K===d.value,onClick:()=>S(d.value),children:d.label},d.value)),e.jsx("div",{className:"dd-header",children:j("theme")}),e.jsx(Ie,{active:T===null,onClick:()=>{D(null),Z(!1)},children:j("themeDefault")}),b.map(d=>e.jsx(Ie,{active:T===d.id,onClick:()=>{D(d.id),Z(!1)},children:K==="en"?d.nameEn??d.name:d.name},d.id)),e.jsx("div",{className:"dd-header",children:j("update")}),v(),ne(),e.jsxs("a",{className:"dd-refresh dd-more-link",href:"https://github.com/xing-shuyin/pi-web-ui",target:"_blank",rel:"noreferrer noopener",children:[e.jsx(As,{})," ",j("githubRepo")]})]})}),e.jsx("button",{type:"button",className:"panel-toggle",title:j("openFiles"),onClick:()=>a("right"),children:e.jsx(Je,{})})]})]})}function Ks(t){const s=new Date(t),n=new Date;return s.toDateString()===n.toDateString()?`${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}`:`${s.getMonth()+1}/${s.getDate()}`}function da(t,s){const n=new Map;for(const c of t){const i=n.get(c.cwd)??[];i.push(c),n.set(c.cwd,i)}const r=[...n.entries()].map(([c,i])=>({cwd:c,isCurrent:c===s,convs:i}));return r.sort((c,i)=>c.isCurrent?-1:i.isCurrent?1:c.cwd<i.cwd?-1:c.cwd>i.cwd?1:0),r}const ua="pi-web-ui:lp-collapse-projects",pa="pi-web-ui:lp-collapse-convs",ma="pi-web-ui:lp-collapse-sessions";function Bt(t,s=!1){const[n,r]=l.useState(()=>{try{const i=localStorage.getItem(t);if(i==="1")return!0;if(i==="0")return!1}catch{}return s}),c=l.useCallback(()=>{r(i=>{const a=!i;try{localStorage.setItem(t,a?"1":"0")}catch{}return a})},[t]);return[n,c]}const In="pi-web-ui:lp-sizes",Jt={projects:1,convs:1,sessions:1};function ha(){try{const t=localStorage.getItem(In);if(t){const s=JSON.parse(t);return{projects:typeof s.projects=="number"&&s.projects>0?s.projects:1,convs:typeof s.convs=="number"&&s.convs>0?s.convs:1,sessions:typeof s.sessions=="number"&&s.sessions>0?s.sessions:1}}}catch{}return{...Jt}}const ga=l.memo(function({ready:s,status:n,cwd:r,sessionFile:c,conversations:i,sessions:a,projects:o,activeConversationId:u,send:m,active:y,collapsible:g,onToggleCollapse:x}){const b=xe(),T=c,D=r,[K,S]=l.useState(null),[j,Q]=l.useState(null),[G,J]=l.useState(""),[U,E]=Bt(ua,!1),[H,k]=Bt(pa,!1),[_,F]=Bt(ma,!1),Z=l.useRef(null),[$,X]=l.useState(()=>ha());l.useEffect(()=>{try{localStorage.setItem(In,JSON.stringify($))}catch{}},[$]);const Y=l.useCallback((d,w)=>h=>{h.preventDefault();const I=h.currentTarget,ee=h.clientY,q={...$},ae=Z.current;if(!ae)return;const ye=32,ke=72,fe=[{key:"projects",visible:o.length>0,collapsed:U},{key:"convs",visible:i.length>0,collapsed:H},{key:"sessions",visible:!0,collapsed:_}].filter(pe=>pe.visible),be=fe.filter(pe=>pe.collapsed).length,re=fe.filter(pe=>!pe.collapsed).map(pe=>pe.key).reduce((pe,ve)=>pe+(q[ve]??1),0)||1,f=Math.max(120,ae.clientHeight-be*ye),W=(q[d]??1)+(q[w]??1),de=ke/f*re;I.classList.add("dragging"),document.body.classList.add("lp-resizing");const ue=pe=>{const Me=(pe.clientY-ee)/f*re;let he=(q[d]??1)+Me;const _e=W-de;he=Math.max(de,Math.min(_e,he));const Le=W-he;X(Be=>({...Be,[d]:he,[w]:Le}))},me=()=>{window.removeEventListener("pointermove",ue),window.removeEventListener("pointerup",me),I.classList.remove("dragging"),document.body.classList.remove("lp-resizing")};window.addEventListener("pointermove",ue),window.addEventListener("pointerup",me)},[$,o.length,i.length,U,H,_]);l.useEffect(()=>{!y||!s||n!=="open"||r&&(m({type:"list_sessions"}),m({type:"list_projects"}))},[y,s,n,r,m]);const M=d=>{const w=d.name||d.firstMessage.trim();return w.length>0?w:b("emptyChat")},R=d=>d.split(/[\\/]/).pop()||d,C=(d,w,h,I,ee)=>{const q=K===d;return e.jsx("button",{type:"button",className:`lp-del ${q?"confirm":""}`,title:q?h:w,onClick:ae=>{ae.stopPropagation(),q?(S(null),I()):S(d)},children:q?e.jsx(pt,{}):ee??e.jsx(Ae,{})})},O=(d,w,h,I)=>e.jsxs("button",{type:"button",className:"lp-section-title panel-section-title",onClick:h,title:b(w?"expandSection":"collapseSection"),children:[e.jsxs("span",{className:"lp-section-title-text",children:[d,I!==void 0?` (${I})`:""]}),e.jsx("span",{className:"lp-section-chevron",children:w?e.jsx(Ge,{}):e.jsx(ut,{})})]}),ne=[{key:"projects",visible:o.length>0,collapsed:U},{key:"convs",visible:i.length>0,collapsed:H},{key:"sessions",visible:!0,collapsed:_}].filter(d=>d.visible).filter(d=>!d.collapsed),v=ne.reduce((d,w)=>d+($[w.key]??1),0)||1,L=d=>ne.length<=1?1:($[d]??1)/v*ne.length;return e.jsxs("aside",{ref:Z,className:"panel panel-left lp-panel",children:[g&&x&&e.jsx("button",{type:"button",className:"panel-collapse-btn",title:b("collapsePanel"),onClick:x,children:e.jsx(Nn,{})}),o.length>0&&e.jsxs("div",{className:`lp-section panel-projects ${U?"collapsed":""}`,style:U?void 0:{flex:`${L("projects")} 1 0px`},children:[O(b("recentProjects"),U,E,o.length),!U&&e.jsx("div",{className:"lp-section-body projects-scroll",children:o.map(d=>{const w=D===d.path;return e.jsxs("div",{className:"lp-row",onMouseLeave:()=>S(h=>h===`proj:${d.path}`?null:h),children:[e.jsxs("button",{type:"button",className:`project-item ${w?"active":""}`,title:d.path,onClick:()=>{w||m({type:"set_cwd",path:d.path})},children:[e.jsx(Je,{className:"project-icon"}),e.jsxs("span",{className:"project-info",children:[e.jsx("span",{className:"project-name",children:R(d.path)}),e.jsx("span",{className:"project-path",children:d.path})]}),e.jsx("span",{className:"project-time",children:Ks(d.lastUsed)})]}),C(`proj:${d.path}`,b("deleteProject"),b("deleteProjectConfirm"),()=>m({type:"remove_project",path:d.path}))]},d.path)})})]}),o.length>0&&!U&&(i.length>0?!H:!_)&&e.jsx("div",{className:"lp-sash",onPointerDown:Y("projects",i.length>0?"convs":"sessions"),onDoubleClick:()=>X({...Jt}),title:b("dragToResize")}),i.length>0&&e.jsxs("div",{className:`lp-section lp-section-convs panel-convs ${H?"collapsed":""}`,style:H?void 0:{flex:`${L("convs")} 1 0px`},children:[O(b("runningConversations"),H,k,i.length),!H&&e.jsx("div",{className:"lp-section-body convs-scroll",children:da(i,r).map(d=>e.jsxs("div",{className:"panel-conv-group",children:[!d.isCurrent&&e.jsx("div",{className:"panel-conv-group-title",title:d.cwd,children:R(d.cwd)}),d.convs.map(w=>{const h=u===w.id;return e.jsxs("div",{className:"lp-row",onMouseLeave:()=>S(I=>I===`conv:${w.id}`?null:I),children:[e.jsxs("button",{type:"button",className:`session-item ${h?"active":""}`,title:`${w.title}${d.isCurrent?"":` — ${d.cwd}`}`,onClick:()=>{h||m({type:"switch_conversation",id:w.id})},children:[e.jsx(st,{className:"session-icon"}),e.jsxs("span",{className:"session-info",children:[j===`conv:${w.id}`?e.jsx("input",{autoFocus:!0,className:"session-rename-input",value:G,placeholder:b("renameSessionPlaceholder"),onClick:I=>I.stopPropagation(),onChange:I=>J(I.target.value),onKeyDown:I=>{if(I.stopPropagation(),I.key==="Enter"&&!I.nativeEvent.isComposing){const ee=G.trim();ee&&m({type:"rename_conversation",id:w.id,name:ee}),Q(null)}else I.key==="Escape"&&Q(null)},onBlur:()=>Q(null)}):e.jsxs("span",{className:"session-title",children:[w.isSubagent&&e.jsx("span",{className:"subagent-badge",children:b("subagentBadge")}),w.title]}),j===`conv:${w.id}`?null:e.jsx("span",{className:"session-sub",children:h?b("current"):b("messageCount",{n:w.messageCount})})]}),w.isStreaming&&e.jsx("span",{className:"conv-streaming",title:b("streaming")})]}),e.jsx("button",{type:"button",className:"lp-del lp-rename",title:b("renameSession"),onClick:I=>{I.stopPropagation(),S(null),J(w.title),Q(`conv:${w.id}`)},children:e.jsx(St,{})}),!w.isStreaming&&!h&&C(`conv:${w.id}`,b("dismissConversation"),b("dismissConversationConfirm"),()=>m({type:"dismiss_conversation",id:w.id}),e.jsx(Pe,{})),w.isStreaming&&e.jsx("span",{className:"lp-row-stalled",title:b("streaming"),style:{position:"absolute",right:28,top:"50%",transform:"translateY(-50%)"}})]},w.id)})]},d.cwd))})]}),i.length>0&&!H&&!_&&e.jsx("div",{className:"lp-sash",onPointerDown:Y("convs","sessions"),onDoubleClick:()=>X({...Jt}),title:b("dragToResize")}),e.jsxs("div",{className:`lp-section lp-section-sessions panel-sessions ${_?"collapsed":""}`,style:_?void 0:{flex:`${L("sessions")} 1 0px`},children:[O(b("historySessions"),_,F,a.length),!_&&e.jsxs("div",{className:"lp-section-body sessions-scroll",children:[a.length===0&&e.jsx("div",{className:"panel-empty",children:b("noHistory")}),a.map(d=>{const w=T===d.path;return e.jsxs("div",{className:"lp-row",onMouseLeave:()=>S(h=>h===`sess:${d.path}`?null:h),children:[e.jsxs("button",{type:"button",className:`session-item ${w?"active":""}`,title:d.path,onClick:()=>{j||w||m({type:"switch_session",path:d.path})},children:[e.jsx(st,{className:"session-icon"}),e.jsxs("span",{className:"session-info",children:[j===d.path?e.jsx("input",{autoFocus:!0,className:"session-rename-input",value:G,placeholder:b("renameSessionPlaceholder"),onClick:h=>h.stopPropagation(),onChange:h=>J(h.target.value),onKeyDown:h=>{if(h.stopPropagation(),h.key==="Enter"&&!h.nativeEvent.isComposing){const I=G.trim();I&&m({type:"rename_session",path:d.path,name:I}),Q(null)}else h.key==="Escape"&&Q(null)},onBlur:()=>Q(null)}):e.jsx("span",{className:"session-title",children:M(d)}),j===d.path?null:e.jsxs("span",{className:"session-sub",children:[w?b("current"):b("messageCount",{n:d.messageCount}),d.source==="tui"&&e.jsx("span",{className:"session-src",title:b("tuiTip"),children:"TUI"})]})]}),e.jsx("span",{className:"session-time",children:Ks(d.modified)})]}),e.jsx("button",{type:"button",className:"lp-del lp-rename",title:b("renameSession"),onClick:h=>{h.stopPropagation(),S(null),J(d.name??""),Q(d.path)},children:e.jsx(St,{})}),C(`sess:${d.path}`,b("deleteSession"),b("deleteSessionConfirm"),()=>m({type:"delete_session",path:d.path}))]},d.path)})]})]})]})}),Ln="pi-web-ui:token";function fa(){try{const t=new URL(window.location.href),s=t.searchParams.get("token");s&&(localStorage.setItem(Ln,s.trim()),t.searchParams.delete("token"),window.history.replaceState(null,"",t.toString()))}catch{}}function xa(){try{return localStorage.getItem(Ln)??""}catch{return""}}function Mt(t){const s=xa();return s?`${t}${t.includes("?")?"&":"?"}token=${encodeURIComponent(s)}`:t}function ya(t,s){const n=s.assistantMessageEvent,r=t.stats.tokens,c=s.usage!==null?{...r,...s.usage}:r,i=c===r?t.stats:{...t.stats,tokens:c};if(n.type!=="text_delta"&&n.type!=="thinking_delta")return i===t.stats?t:{...t,stats:i};const a=n.delta??"";if(!a)return i===t.stats?t:{...t,stats:i};const o=t.streamingMessage??null,u=o&&o.id===s.messageId?o:{id:s.messageId,content:[]},m=[...u.content],y=n.type==="thinking_delta"?"thinking":"text",g=n.contentIndex??m.length-1;return g>=0&&g<m.length&&m[g].type===y?m[g]=y==="thinking"?{type:"thinking",thinking:(m[g].thinking??"")+a}:{type:"text",text:(m[g].text??"")+a}:m.push(y==="thinking"?{type:"thinking",thinking:a}:{type:"text",text:a}),{...t,stats:i,streamingMessage:{...u,id:s.messageId,content:m}}}const Xt="pi-web-ui:plugin-data";function va(t,s){window.dispatchEvent(new CustomEvent(Xt,{detail:{pluginId:t,payload:s}}))}function ka(t){const s=n=>{const r=n.detail;t(r.pluginId,r.payload)};return window.addEventListener(Xt,s),()=>window.removeEventListener(Xt,s)}const et=new Map,Zt=new Set,Xe=new Set;let Ws=-1;function Dn(){return[...et.values()]}function ba(){const t=Dn();for(const s of Zt)s(t)}function ja(t){return Zt.add(t),t(Dn()),()=>Zt.delete(t)}async function wa(t,s){s!==Ws&&(Ws=s,et.clear(),Xe.clear());const n=new Set(t.map(r=>r.id));for(const r of[...et.keys()])n.has(r)||et.delete(r);for(const r of[...Xe])n.has(r)||Xe.delete(r);await Promise.all(t.filter(r=>r.hasClient&&!r.error&&!et.has(r.id)&&!Xe.has(r.id)).map(async r=>{try{const i=(await import(Ve(`/plugins/${encodeURIComponent(r.id)}/client/entry.mjs?e=${s}`))).default;i&&typeof i.mount=="function"?et.set(r.id,{info:r,module:i}):(Xe.add(r.id),console.error(`[plugin:${r.id}] entry.mjs 缺少 default.mount`))}catch(c){Xe.add(r.id),console.error(`[plugin:${r.id}] 客户端加载失败:`,c)}})),ba()}function Na(t,s){return{pluginId:t,send:n=>s({type:"plugin_message",pluginId:t,payload:n}),onData:n=>ka((r,c)=>{r===t&&n(c)})}}const Ca=11,Ft=2e5,Sa=2e5,Ta="LIVE_OMIT",Ea={conversationId:null,goal:null,reviewModel:null,maxRounds:3,locked:!0,reviewing:!1,round:0,status:"",verdict:"pending",wizard:{active:!1,draft:"",model:null,step:0,maxSteps:6,status:""}};function Pa(){const t=new Map,s=new Map,n=(r,c)=>`${r}:${c}`;return{write(r,c,i){const a=n(r,c),o=t.get(a);if(o&&o.size>0){for(const y of o)try{y.write(i)}catch{}return}const u=s.get(a)??"",m=u.length+i.length>Sa?i:u+i;s.set(a,m)},register(r,c,i){const a=n(r,c);let o=t.get(a);o||(o=new Set,t.set(a,o)),o.add(i);const u=s.get(a);if(u){try{i.write(u)}catch{}s.delete(a)}return()=>{const m=t.get(a);m&&(m.delete(i),m.size===0&&t.delete(a)),s.delete(a)}},clear(){t.clear(),s.clear()}}}function Us(t,s){const n=new Set;for(const c of s.messages)c.role==="toolResult"&&c.toolCallId&&n.add(c.toolCallId),c.role==="bashExecution"&&n.add(`bash-${c.id}`);let r=!1;for(const c of t.keys())n.has(c)&&(t.delete(c),r=!0);return r?new Map(t):t}function qs(t,s){if(t.size===0)return t;const n=new Set;for(const c of s.messages)c.role==="toolResult"&&c.toolCallId&&n.add(c.toolCallId);let r=!1;for(const c of t.keys())n.has(c)&&(t.delete(c),r=!0);return r?new Map(t):t}function Ma(t,s){var n,r,c,i;switch(s.type){case"status":return{...t,status:s.status,ready:s.status==="open"?t.ready:!1,terminals:s.status==="closed"?[]:t.terminals};case"ready":return{...t,serverVersion:s.serverVersion,engine:s.engine,ready:!0,protocolMismatch:s.protocolVersion!==void 0&&s.protocolVersion!==Ca};case"snapshot":return{...t,ready:!0,state:s.state,activeConversationId:s.state.conversationId,liveOutputs:Us(t.liveOutputs,s.state),toolStatuses:qs(t.toolStatuses,s.state)};case"snapshot_delta":{const a=t.state,o=s.msg;if(!a||a.conversationId!==o.conversationId||a.rev!==o.baseRev)return t;const u={...a,...o.state,messages:o.appended.length>0?[...a.messages,...o.appended]:a.messages};return{...t,ready:!0,state:u,activeConversationId:u.conversationId,liveOutputs:Us(t.liveOutputs,u),toolStatuses:qs(t.toolStatuses,u)}}case"tool_delta":{const a=t.liveOutputs.get(s.toolCallId),o=((a==null?void 0:a.text)??"")+s.delta,u=o.length>Ft?`…[${Ta}:${o.length-Ft}]…
|
|
305
|
-
`+o.slice(o.length-Ft):o,m=new Map(t.liveOutputs);return m.set(s.toolCallId,{toolName:s.toolName,text:u}),{...t,liveOutputs:m}}case"message_delta":{const a=t.state;return!a||a.conversationId!==s.msg.conversationId?t:{...t,state:ya(a,s.msg)}}case"tool_status":return{...t,toolStatuses:new Map(t.toolStatuses).set(s.status.toolCallId,s.status)};case"notice":return{...t,notices:[...t.notices,s.notice].slice(-6)};case"dismiss_notice":return{...t,notices:t.notices.filter(a=>a.id!==s.id)};case"sessions":return{...t,sessions:s.sessions};case"conversations":return{...t,conversations:s.conversations,activeConversationId:s.activeId};case"projects":return{...t,projects:s.projects};case"files":return{...t,files:s.files};case"file_changed":return{...t,fileChanged:{path:s.path}};case"file_content":return{...t,fileContent:s.content};case"models":return{...t,models:s.models,modelsLoading:s.loading};case"models_config":return{...t,modelsConfig:s.providers};case"providers_status":return{...t,providers:s.providers};case"provider_keys":return{...t,providerKeys:s.keys};case"fetch_models_result":return{...t,fetchModelsResult:s.result};case"refresh_provider_result":return{...t,refreshProviderResult:s.result};case"clone_provider_result":return{...t,cloneProviderResult:s.result};case"install_result":return{...t,installResult:s.result};case"scm_data":return{...t,scmData:s.data};case"file_search_result":return{...t,fileSearch:s.result};case"session_search_result":return{...t,sessionSearch:s.result};case"scm_changed":return{...t,scmDirty:t.scmDirty+1};case"path_completions":return{...t,pathCompletions:s.completions};case"update_status":return{...t,update:s.status};case"update_status_all":return{...t,updatesAll:s.items};case"updates_check_started":return{...t,updatesAll:null};case"widgets":return{...t,widgets:s.widgets};case"statuses":return{...t,statuses:s.statuses};case"dialog":return{...t,dialog:s.dialog};case"question":return{...t,question:s.question};case"commands":return{...t,commands:s.commands,commandsPath:s.path};case"slash_commands":return{...t,slashCommands:s.commands};case"goal_status":return{...t,goal:s.status};case"settings":return{...t,settings:s.settings};case"bg_servers":return{...t,bgServers:s.servers};case"plugins":return{...t,plugins:s.plugins,pluginsEpoch:s.epoch};case"dsh_patches":return{...t,dshPatches:{patchDir:s.patchDir,files:s.files}};case"terminal_add":return{...t,terminals:[...t.terminals,s.meta]};case"terminal_remove":return{...t,terminals:t.terminals.filter(a=>a.id!==s.id)};case"terminal_exit":return s.conversationId&&(t.activeConversationId||(n=t.state)!=null&&n.conversationId)&&s.conversationId!==(t.activeConversationId||((r=t.state)==null?void 0:r.conversationId))?t:{...t,terminals:t.terminals.map(a=>a.id===s.terminalId?{...a,running:!1,exitCode:s.exitCode}:a)};case"terminal_restart":return{...t,terminals:t.terminals.map(a=>a.id===s.terminalId?{...a,running:!0,exitCode:null}:a)};case"terminal_list":return s.conversationId&&(t.activeConversationId||(c=t.state)!=null&&c.conversationId)&&s.conversationId!==(t.activeConversationId||((i=t.state)==null?void 0:i.conversationId))?t:{...t,terminals:s.terminals.map(a=>{var o;return{...a,conversationId:s.conversationId??((o=t.state)==null?void 0:o.conversationId)??""}})};case"terminal_active":return{...t,terminalActiveId:s.id};default:return t}}const zs="pi-web-client-id";let $t=null;function os(){if($t)return $t;let t=null;try{t=sessionStorage.getItem(zs),t||(t=Ue(),sessionStorage.setItem(zs,t))}catch{t=t??Ue()}return $t=t,t}function Ra(){const t=location.protocol==="https:"?"wss:":"ws:";return Mt(`${t}//${location.host}${Ve("/ws")}`)}function Ia(){const[t,s]=l.useReducer(Ma,{status:"connecting",ready:!1,state:null,liveOutputs:new Map,toolStatuses:new Map,notices:[],sessions:[],conversations:[],activeConversationId:"",projects:[],files:null,fileChanged:null,fileContent:null,models:[],modelsLoading:!1,modelsConfig:[],providers:[],providerKeys:{},installResult:null,pathCompletions:[],update:null,updatesAll:null,widgets:[],statuses:[],dialog:null,question:null,commands:[],commandsPath:"",slashCommands:[],terminals:[],terminalActiveId:null,goal:Ea,bgServers:[],settings:null,fetchModelsResult:null,refreshProviderResult:null,cloneProviderResult:null,scmData:null,fileSearch:null,sessionSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,dshPatches:null,protocolMismatch:!1}),n=l.useRef(null),r=l.useRef(Pa()),c=l.useRef(0),i=l.useRef(null),a=l.useRef(!0),o=l.useRef(0),u=l.useRef(0),m=l.useRef(new Map),y=l.useRef(null),g=()=>{y.current||(y.current=setTimeout(()=>{y.current=null;const E=n.current;E&&E.readyState===WebSocket.OPEN&&E.send(JSON.stringify({type:"get_state"}))},300))},x=(E,H)=>{var F;const k=m.current,_=k.get(E);if(_!==void 0&&H!==_+1){const Z=U.current.chat,$=Z.activeConversationId||((F=Z.state)==null?void 0:F.conversationId);E===$&&g()}k.set(E,H)},b=l.useCallback((E,H)=>{const k=++u.current;s({type:"notice",notice:{id:k,level:E,text:H}})},[]),T=l.useCallback(E=>{const H=n.current;return H&&H.readyState===WebSocket.OPEN?(E.type==="check_updates_all"&&E.force===!0&&s({type:"updates_check_started"}),H.send(JSON.stringify(E)),!0):!1},[]),D=l.useCallback(()=>{if(!a.current)return;s({type:"status",status:"connecting"});const E=new WebSocket(Ra());n.current=E,E.onopen=()=>{n.current===E&&(s({type:"status",status:"open"}),c.current=0,o.current=Date.now(),E.send(JSON.stringify({type:"hello",clientId:os()})))},E.onmessage=H=>{if(n.current!==E)return;o.current=Date.now();let k;try{k=JSON.parse(H.data)}catch{return}switch(k.type){case"ready":s({type:"ready",serverVersion:k.serverVersion,protocolVersion:k.protocolVersion,engine:k.engine}),E.send(JSON.stringify({type:"get_state"})),E.send(JSON.stringify({type:"list_files"})),E.send(JSON.stringify({type:"list_models"})),E.send(JSON.stringify({type:"list_commands"})),E.send(JSON.stringify({type:"get_commands"})),E.send(JSON.stringify({type:"check_update"})),E.send(JSON.stringify({type:"check_updates_all"}));break;case"snapshot":m.current=new Map,s({type:"snapshot",state:k.state});break;case"snapshot_delta":{const _=U.current.chat.state;(!_||_.conversationId!==k.conversationId||_.rev!==k.baseRev)&&g(),s({type:"snapshot_delta",msg:k});break}case"tool_delta":x(k.conversationId,k.seq),s({type:"tool_delta",toolCallId:k.toolCallId,toolName:k.toolName,delta:k.delta});break;case"tool_status":s({type:"tool_status",status:k});break;case"message_delta":{x(k.conversationId,k.seq),s({type:"message_delta",msg:k});break}case"notice":{const _=++u.current;s({type:"notice",notice:{id:_,level:k.level,text:k.text,textEn:k.textEn}});break}case"sessions":s({type:"sessions",sessions:k.sessions});break;case"conversations":s({type:"conversations",conversations:k.conversations,activeId:k.activeId});break;case"projects":s({type:"projects",projects:k.projects});break;case"files":s({type:"files",files:k});break;case"file_changed":s({type:"file_changed",path:k.path});break;case"file_content":s({type:"file_content",content:k});break;case"models":s({type:"models",models:k.models,loading:!1});break;case"models_config":s({type:"models_config",providers:k.providers});break;case"providers_status":s({type:"providers_status",providers:k.providers});break;case"provider_keys":s({type:"provider_keys",keys:k.keys});break;case"fetch_models_result":s({type:"fetch_models_result",result:{reqId:k.reqId,ok:k.ok,models:k.models,error:k.error}});break;case"refresh_provider_result":s({type:"refresh_provider_result",result:{reqId:k.reqId,ok:k.ok,added:k.added,total:k.total,error:k.error}});break;case"clone_provider_result":s({type:"clone_provider_result",result:{reqId:k.reqId,ok:k.ok,config:k.config,configs:k.configs,error:k.error}});break;case"scm_data":s({type:"scm_data",data:k});break;case"search_files_result":s({type:"file_search_result",result:{reqId:k.reqId,ok:k.ok,results:k.results,truncated:k.truncated}});break;case"session_search_results":s({type:"session_search_result",result:{reqId:k.reqId,ok:k.ok,results:k.results}});break;case"scm_changed":s({type:"scm_changed"});break;case"install_result":s({type:"install_result",result:k});break;case"path_completions":s({type:"path_completions",completions:k.completions});break;case"update_status":s({type:"update_status",status:k});break;case"update_status_all":s({type:"update_status_all",items:k.items});break;case"widgets":s({type:"widgets",widgets:k.widgets});break;case"statuses":s({type:"statuses",statuses:k.statuses});break;case"dialog":s({type:"dialog",dialog:{id:k.id,kind:k.kind,title:k.title,args:k.args}});break;case"dialog_closed":s({type:"dialog",dialog:null});break;case"question_pending":s({type:"question",question:{id:k.id,questions:k.questions}});break;case"terminal_output":r.current.write(k.conversationId??U.current.chat.activeConversationId,k.terminalId,k.data);break;case"terminal_exit":s({type:"terminal_exit",conversationId:k.conversationId,terminalId:k.terminalId,exitCode:k.exitCode});break;case"terminal_list":s({type:"terminal_list",conversationId:k.conversationId,terminals:k.terminals});break;case"commands":s({type:"commands",commands:k.commands,path:k.path});break;case"slash_commands":s({type:"slash_commands",commands:k.commands});break;case"goal_status":s({type:"goal_status",status:k.status});break;case"settings_state":s({type:"settings",settings:k.settings});break;case"bg_servers":s({type:"bg_servers",servers:k.servers});break;case"plugins":s({type:"plugins",plugins:k.plugins,epoch:k.epoch});break;case"dsh_patches":s({type:"dsh_patches",patchDir:k.patchDir,files:k.files});break;case"plugin_data":va(k.pluginId,k.payload);break}},E.onclose=()=>{if(n.current===E&&(n.current=null),r.current.clear(),!a.current||n.current&&n.current!==E)return;s({type:"status",status:"closed"});const H=Math.min(1e3*2**c.current,1e4);c.current+=1,i.current=setTimeout(()=>{i.current=null,D()},H)},E.onerror=()=>{}},[]);l.useEffect(()=>{a.current=!0,D();const E=setInterval(()=>{if(!a.current)return;const H=n.current;H&&H.readyState===WebSocket.OPEN&&Date.now()-o.current>3e4&&H.close()},5e3);return()=>{var H;a.current=!1,clearInterval(E),i.current&&(clearTimeout(i.current),i.current=null),(H=n.current)==null||H.close(),n.current=null}},[D]);const K=l.useCallback(E=>s({type:"dismiss_notice",id:E}),[]),S=l.useCallback(E=>s({type:"terminal_add",meta:E}),[]),j=l.useCallback(E=>s({type:"terminal_remove",id:E}),[]),Q=l.useCallback(E=>s({type:"terminal_restart",terminalId:E}),[]),G=l.useCallback(E=>s({type:"terminal_active",id:E}),[]),J=l.useCallback((E,H,k)=>r.current.register(E,H,k),[]),U=l.useRef({chat:t,send:T,pushNotice:b,dismissNotice:K,terminal:{create:S,close:j,register:J,restart:Q,select:G}});return U.current={chat:t,send:T,pushNotice:b,dismissNotice:K,terminal:{create:S,close:j,register:J,restart:Q,select:G}},U.current}const La=200*1024*1024,Da=/windows/i.test(navigator.userAgent),Aa=/[<>:"/\\|?*\u0000-\u001f]/g,_a=/[. ]+$/,Ba=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function Fa(t){const s=t.replace(Aa,"_").replace(_a,"");return s?Ba.test(s)?`_${s}`:s:"_"}function Vs(t,s=!0){const n=new URLSearchParams({clientId:os(),path:t,...s?{download:"1"}:{}});return Mt(Ve(`/api/file?${n}`))}const An="FILE_NOT_FOUND";async function $a(t,s){const n=Da?Fa(s):s;try{const r=await fetch(Vs(t));if(!r.ok)return{ok:!1,cancelled:!1,error:await r.text().catch(()=>"")||(r.status===404?An:`HTTP ${r.status}`)};if(Number(r.headers.get("content-length")??"0")>La)return window.location.assign(Vs(t)),{ok:!0};const i=await r.blob();return window.showSaveFilePicker&&window.isSecureContext?Ha(i,n):es(i,n)}catch(r){return{ok:!1,cancelled:!1,error:r instanceof Error?r.message:String(r)}}}async function Ha(t,s){let n;const r=window.showSaveFilePicker;if(!r)return es(t,s);try{n=await r({suggestedName:s})}catch(c){return c instanceof DOMException&&c.name==="AbortError"?{ok:!1,cancelled:!0}:es(t,s)}try{const c=await n.createWritable();return await c.write(t),await c.close(),{ok:!0}}catch(c){return{ok:!1,cancelled:!1,error:c instanceof Error?c.message:String(c)}}}function es(t,s){const n=URL.createObjectURL(t),r=document.createElement("a");return r.href=n,r.download=s,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4),{ok:!0}}const gt="@root",Oa=l.memo(function({files:s,fileChanged:n,widgets:r,cwd:c,send:i,onAttach:a,onPreview:o,onNotice:u,collapsible:m,onToggleCollapse:y}){const g=xe(),[x,b]=l.useState(""),[T,D]=l.useState(null),[K,S]=l.useState(!1),[j,Q]=l.useState(null),G=l.useRef(""),J=l.useRef(null),U=l.useCallback((d,w)=>{d.preventDefault(),G.current=w,Q({x:Math.min(d.clientX,window.innerWidth-220),y:Math.min(d.clientY,window.innerHeight-90)})},[]),E=l.useCallback(()=>Q(null),[]);l.useEffect(()=>{if(!j)return;const d=I=>{var ee;(ee=I.target)!=null&&ee.closest(".ctx-menu")||E()},w=I=>{I.key==="Escape"&&E()};window.addEventListener("mousedown",d,!0),window.addEventListener("keydown",w);const h=()=>E();return window.addEventListener("blur",h),()=>{window.removeEventListener("mousedown",d,!0),window.removeEventListener("keydown",w),window.removeEventListener("blur",h)}},[j,E]);const H=l.useCallback(()=>{var d;E(),J.current&&(J.current.value=""),(d=J.current)==null||d.click()},[E]),k=l.useCallback((d,w)=>{for(const h of w){const I=new FileReader;I.onload=()=>{const ee=I.result,q=ee.slice(ee.indexOf(",")+1);q&&i({type:"upload_file",dirPath:d,name:h.name,data:q})},I.readAsDataURL(h)}},[i]),_=l.useCallback(d=>{k(G.current,Array.from(d.target.files??[]))},[k]),F=l.useRef(null),Z=d=>{var w;return Array.from(((w=d.dataTransfer)==null?void 0:w.types)??[]).includes("Files")},$=l.useCallback(()=>{var d,w;(d=F.current)==null||d.querySelectorAll(".file-item.drop-target").forEach(h=>h.classList.remove("drop-target")),(w=F.current)==null||w.classList.remove("drop-root")},[]),X=l.useCallback(d=>{var h,I;if($(),d==null)return;const w=(h=F.current)==null?void 0:h.querySelector(`.file-item[data-path="${CSS.escape(d)}"]`);w?w.classList.add("drop-target"):(I=F.current)==null||I.classList.add("drop-root")},[$]),Y=d=>{const w=d instanceof Element?d.closest(".file-item"):null;return(w==null?void 0:w.dataset.type)==="dir"?w.dataset.path??x:x},M=l.useCallback(()=>{const d=document.querySelector(".app");d&&d.dispatchEvent(new DragEvent("dragleave",{bubbles:!0}))},[]),R=1e4,C=l.useRef(0),O=l.useRef(void 0),z=l.useCallback((d,w)=>{const h=++C.current;b(d),w!=null&&w.silent||S(!0),i({type:"list_files",path:d===""?void 0:d})||C.current===h&&S(!1)},[i]);l.useEffect(()=>{s&&s.path===x&&S(!1)},[s,x]),l.useEffect(()=>{if(c!==O.current){O.current=c,z("",{silent:!0});return}const d=setInterval(()=>{document.visibilityState!=="hidden"&&z(x,{silent:!0})},R);return()=>clearInterval(d)},[c,x,z]),l.useEffect(()=>{n&&n.path===x&&z(x,{silent:!0})},[n,x,z]);const ne=d=>z(d),v=()=>{(s==null?void 0:s.parent)!==null&&(s==null?void 0:s.parent)!==void 0&&z(s.parent)},L=(()=>{if(x===""||x===gt)return[];const d=x.split("/").filter(w=>!!w&&w!==gt);return x.startsWith("/")?d.map((w,h)=>({label:h===0?"/":d[h],path:"/"+d.slice(0,h+1).join("/")})):d.map((w,h)=>({label:d[h],path:d.slice(0,h+1).join("/")}))})();return e.jsxs("aside",{className:"panel panel-right",children:[m&&y&&e.jsx("button",{type:"button",className:"panel-collapse-btn",title:g("collapsePanel"),onClick:y,children:e.jsx(wn,{})}),e.jsxs("div",{className:"panel-crumbs",children:[e.jsx("button",{type:"button",className:`crumb ${x===""?"active":""}`,onClick:()=>z(""),children:g("rootDir")}),e.jsx("button",{type:"button",className:`crumb ${x===gt?"active":""}`,title:g("computer"),onClick:()=>z(gt),children:"💻"}),L.map(d=>e.jsxs("span",{className:"crumb-seg",children:[e.jsx(Pt,{}),e.jsx("button",{type:"button",className:`crumb ${d.path===x?"active":""}`,onClick:()=>z(d.path),children:d.label})]},d.path))]}),e.jsxs("div",{ref:F,className:"panel-body",onContextMenu:d=>U(d,x),onDragOver:d=>{Z(d)&&(d.preventDefault(),d.stopPropagation(),d.dataTransfer.dropEffect="copy",M(),X(Y(d.target)))},onDragLeave:d=>{d.relatedTarget&&d.currentTarget.contains(d.relatedTarget)||$()},onDrop:d=>{var h;if($(),!Z(d))return;d.preventDefault(),d.stopPropagation(),M();const w=Array.from(((h=d.dataTransfer)==null?void 0:h.files)??[]);if(w.length===0){u("warning",g("foldersNotSupported"));return}k(Y(d.target),w)},onDragEnd:$,children:[e.jsx("input",{ref:J,type:"file",multiple:!0,hidden:!0,onChange:_}),K&&e.jsx("div",{className:"panel-empty",children:g("loading")}),!K&&s&&s.path===x&&e.jsxs(e.Fragment,{children:[s.parent!=null&&e.jsxs("button",{type:"button",className:"file-item dir",onClick:v,children:[e.jsx(Je,{className:"file-icon"}),e.jsx("span",{className:"file-name",children:".."})]}),s.entries.map(d=>d.type==="dir"?e.jsxs("div",{className:"file-item dir","data-type":"dir","data-path":d.path,onContextMenu:w=>{w.stopPropagation(),U(w,d.path)},children:[e.jsxs("button",{type:"button",className:"file-dir-main",onClick:()=>ne(d.path),children:[e.jsx(Je,{className:"file-icon"}),e.jsx("span",{className:"file-name",children:d.name})]}),e.jsx("button",{type:"button",className:"file-attach ref","data-tip":g("linkFolderTip"),onClick:()=>a(d.path,d.name,"reference",!0),children:e.jsx(Gt,{})})]},d.path):e.jsxs("div",{className:"file-item file","data-type":"file","data-path":d.path,onContextMenu:w=>{w.stopPropagation(),U(w,x)},children:[e.jsxs("button",{type:"button",className:"file-name",title:`${d.path} — ${g("previewFile")}`,onClick:()=>o(d.path,d.name),children:[e.jsx(zi,{className:"file-icon"}),e.jsx("span",{className:"file-name-text",children:d.name})]}),e.jsx("button",{type:"button",className:"file-attach download","data-tip":g("downloadFile"),onClick:()=>{$a(d.path,d.name).then(w=>{w.ok||w.cancelled||u("error",g("downloadFailed",{error:w.error===An?g("fileNotFoundShort"):w.error}))})},children:e.jsx(ls,{})}),e.jsx("button",{type:"button",className:"file-attach inline","data-tip":g("attachInlineTip"),onClick:()=>a(d.path,d.name,"inline"),children:e.jsx(He,{})}),e.jsx("button",{type:"button",className:"file-attach ref","data-tip":g("referenceTip"),onClick:()=>a(d.path,d.name,"reference"),children:e.jsx(Gt,{})})]},d.path)),s.truncated&&e.jsx("div",{className:"panel-empty files-truncated",children:g("filesTruncated")})]}),!K&&!s&&e.jsx("div",{className:"panel-empty",children:g("noFiles")})]}),r.filter(d=>d.lines.length>0).length>0&&e.jsx("div",{className:"panel-widgets",children:r.filter(d=>d.lines.length>0).map(d=>e.jsxs("div",{className:"widget",children:[e.jsxs("button",{type:"button",className:"widget-title widget-title-btn",title:g("widgetExpand"),onClick:()=>D(d.key),children:[e.jsx("span",{children:d.key}),e.jsx(Hi,{})]}),e.jsx("pre",{className:"widget-lines",children:d.lines.join(`
|
|
306
|
-
`)})]},d.key))}),
|
|
307
|
-
`)})]})}):null})(),j&&e.jsx("div",{className:"ctx-menu",style:{left:j.x,top:j.y},onContextMenu:d=>{d.preventDefault(),d.stopPropagation()},children:e.jsxs("button",{type:"button",className:"ctx-item",onClick:
|
|
308
|
-
`).map(a=>a===""?[]:[a])}if(Array.isArray(r)){let i=[];for(const a of r){const o=s(a);if(i.length===0)i=o;else{const u=o[0]??[];i[i.length-1].push(...u),i.push(...o.slice(1))}}return i}if(r&&typeof r=="object"&&"props"in r){const i=r,a=(c=i.props)==null?void 0:c.children,o={...i.props,children:void 0},u=a==null?[]:s(a);return u.length===0?[[l.createElement(i.type,o)]]:u.map(m=>[l.createElement(i.type,o,...m)])}return[[r]]},n=s(t);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}function
|
|
309
|
-
`),n=[];let r=[],c=null;for(let i=0;i<s.length;i++){const a=s[i];if(c!==null){const u=Gs(a);u&&u[0]===c[0]&&u.length>=c.length&&(c=null),r.push(a);continue}const o=Gs(a);if(o&&!Ot(a)){c=o,r.push(a);continue}if(Ot(a)){let u=i;for(;u<s.length&&Ot(s[u]);)u++;if(!(u<s.length&&
|
|
304
|
+
Avoid three test anti-patterns: tests coupled to the implementation, tautological assertions (always true), and horizontal slicing (surface only). Report after each step and run the tests.`,error:"Error",done:"Done",running:"Running…",toolQueued:"Queued",copyArgs:"Copy args",errorOutput:"Error output",output:"Output",waitingOutput:"Waiting for output…",toolDoneWaitingModel:"Done · waiting on model",waitingModel:"Waiting for model response…",thinkingNow:"Thinking",thinkingPreview:"Thinking: {preview}",commands:"Commands",newCommand:"New command",newTerminal:"New terminal",name:"Name",command:"Command",cwdHint:"(${pwd} = current working directory)",noCommands:"No commands yet — click + to add one",clickToRun:"Click to run",edit:"Edit",delete:"Delete",confirmQ:"Confirm?",builtinTerminal:"Built-in terminal",termEmptySub:"Click a command on the left to run it, or + on the right for a new terminal",noTerminal:"No terminals",exited:"(exited{code})",exitBanner:"[Process exited with code {code}]",closeTerminal:"Close terminal",renameTerminal:"Rename terminal",rerun:"Reload .pi/commands.json",terminalTitle:"Terminal {n}",aiBashGroup:"Terminal-backed bash",exampleName:"e.g. start dev server",exampleCommand:"e.g. npm run dev",scmTab:"Git",scmTitle:"Source Control",scmRefreshTip:"Re-query git status & diff",scmCurrentBranch:"Current branch",scmUpstreamGone:"Upstream deleted",scmAheadBehind:"↑{ahead} ↓{behind}",scmDetached:"Detached HEAD",scmSelectBranch:"Select branch…",scmRemoteBranches:"Remote branches",scmStageTip:"Stage {path}",scmUnstageTip:"Unstage {path}",scmSwitch:"Switch",scmSwitchBranch:"Switch branch",scmSwitchBranchTip:"Runs git checkout {branch} in the terminal",scmPush:"Push",scmPushTip:"Runs git push in the terminal",scmPull:"Pull",scmPullTip:"Runs git pull in the terminal",scmCommit:"Commit",scmCommitTip:'Runs git commit -m "…" in the terminal (commits staged changes only)',scmCommitAll:"Commit All",scmCommitAllTip:'Runs git add -A && git commit -m "…" in the terminal (stages all changes incl. untracked and commits)',scmCommitPlaceholder:"Type a commit message…",scmChanges:"Changes",scmHistory:"Commit tree",scmCommitDetail:"Commit details",scmSelectCommitHint:"Click a commit on the left to view its details",scmNoHistory:"No commits yet",scmNoChanges:"Working tree clean — no changes",scmNotGitRepo:"Current directory is not a Git repository",scmLoading:"Querying…",scmConnecting:"Waiting for connection…",scmDiff:"Diff",scmSelectFileHint:"Click a file on the left to view its diff",scmNoDiff:"(no diff)",scmStaged:"Staged",scmUnstaged:"Unstaged",scmStagedUnstaged:"Staged + unstaged",scmUntracked:"Untracked",scmUntrackedNote:"Untracked file — stage it with + to include (or use Commit All)",scmQueryFailed:"Git query failed: {error}",scmQueryFailedShort:"Query failed",pluginCommandFallback:"Plugin command",scmTooManyFailures:"Git queries keep failing — click refresh to retry",scmRunsInTerminal:"Commit / branch switch / push / pull run in the terminal",scmViewTerminal:"Open terminal",editProvider:"Edit provider",builtinProviders:"Built-in providers",hintKeyOnly:"Just enter an API key",configuredBadge:"✓ Configured",keyReady:"Key ready",replaceKey:"Replace key",replaceKeyTitle:"Replace the saved key",clearKey:"Clear",clearKeyTitle:"Remove this provider's key stored in auth.json; it returns to unconfigured (env-var sourced keys can't be cleared here)",clearKeyConfirm:"Clear the stored key for {id}? Its models will leave the list until you configure it again.",cloneProvider:"Add key",cloning:"Adding",cloneProviderTitle:"Add a second API key for this provider (baseUrl and model list are copied automatically)",pasteKey:"Paste API key…",savingKey:"Saving",saveKey:"Save key",addKey:"Add key",addKeyPlaceholder:"Paste the key value…",keyNamePh:"Name (optional, e.g. backup)",providerIdPlaceholder:"Provider ID",baseUrlExamplePh:"baseUrl, e.g. https://api.opencode.ai/zen/v1 or http://127.0.0.1:4096",saveAllBatch:"Save all ({n})",netDisconnected:"Network disconnected — reconnect and retry",advancedEdit:"Advanced edit",batchCreateProviders:"Batch-create providers ({n} APIs)",secondKeyTitle:"Add a second key for {api} · {baseUrl} · {n} models — just name the new provider and enter the key.",noBaseUrlShort:"(no baseUrl)",providerNameLabel:"Provider name",providerNameHint:"(new ID, e.g. opencode-2)",apiKeyLabel:"API key",secondKeyPlaceholder:"sk-… second key",batchDesc:"This provider has multiple APIs ({apis}); it was split into {n} custom providers. Save each so all models (e.g. muse-spark) work. Enter one shared second key to save all at once.",batchKeyLabel:"Shared API key (applies to all {n} providers)",modelsCountShort:"{n} models: ",noKeyYet:"No key yet — add one to use this provider",activateKey:"Set active",removeKey:"Remove",removeKeyConfirm:"Remove this key? It must be re-configured to be used again.",customProviders:"Custom providers",customDesc:"For Ollama / vLLM / OpenAI-compatible proxies, etc. Written to pi's models.json — hot-reloaded immediately.",noCustomProviders:"No custom providers yet",modelsCount:"{n} models",addProvider:"Add provider",providerId:"Provider ID",providerIdHint:"(required, e.g. ollama / my-proxy)",displayName:"Display name",displayNamePh:"My proxy",apiType:"API type",baseUrlHint:"(OpenAI-compatible endpoint)",apiKeyHint:"sk-… (optional — uses the auth.json key)",authHeader:"Auto-add Authorization header",modelsTitle:"Models",modelIdReq:"Model ID (required)",text:"Text",textImage:"Text+image",contextWindow:"Context",maxOutput:"Max output",removeModel:"Remove model",addModel:"Add model",deleteProviderConfirm:"Delete provider {id} and its {n} models?",fetchModels:"Fetch model list",fetchModelsHint:"Pull model IDs from the baseUrl /models endpoint (server-side, no CORS)",fetchingModels:"Fetching…",fetchModelsOk:"Fetched {n} models",fetchModelsEmpty:"The endpoint returned no models",fetchModelsErr:"Fetch failed: {msg}",fetchModelsNeedBaseUrl:"Enter a baseUrl first",goalBarTitle:"Goal",goalBarPlaceholder:"Set a goal; the agent's output is auto-reviewed…",goalBarSet:"Start",goalBarClear:"Cancel",goalBarLocked:"Locked: applies to every later turn",goalBarUnlocked:"This turn only (cleared afterwards)",goalBarReviewModel:"Review model",goalBarUseMainModel:"Use the main model",goalBarMaxRounds:"Max rounds",goalBarMaxRoundsTip:"Max review-revision rounds; 0 or empty = unlimited (keep revising until it passes)",goalBarUnlimitedShort:"Unlimited",goalBarReviewing:"Reviewing…",goalBarRound:"Round {n}",goalBarActive:"Goal active",goalBarPassed:"Passed",goalBarFailed:"Failed",goalBarStatusPending:"Waiting to generate…",goalWizardBtn:"AI Scrape",goalWizardTip:"Let AI refine the requirement into a goal via a Q&A survey",goalWizardRunning:"Scoping the goal",goalWizardAnswer:"Answer",goalWizardCard:"Goal survey",settings:"Settings",settingsTitle:"Settings",settingsDesc:"Changes apply immediately: system prompt, skill and extension toggles rebuild the current session; review instructions and review skills affect later goal reviews (main-session changes are deferred while streaming).",settingsSystemPrompt:"System prompt",settingsPromptHistory:"Input history",settingsPromptHistoryDesc:"Cycle previous prompts with ↑/↓ in the input — global across conversations (localStorage)",promptHistoryMax:"Max entries",promptHistoryMaxHint:"Oldest entries are dropped when exceeded (1–500)",promptHistoryCharLimit:"Limit characters per entry",promptHistoryCharLimitHint:"When enabled, overlong prompts are truncated before saving",promptHistoryCharLimitPlaceholder:"Max chars (100–20000)",promptHistoryClear:"Clear history",promptHistoryClearConfirm:"Confirm clear?",promptHistoryCleared:"Input history cleared",promptHistoryCount:"{n} entries",promptHistoryEmpty:"No history yet — ↑/↓ has nothing to cycle",settingsPromptMode:"Mode",promptModeAppend:"Append",promptModeReplace:"Replace",promptAppendHint:"Append mode: your text is appended to the end of the default system prompt (recommended — keeps the default behavior constraints).",promptReplaceHint:"Replace mode: your text fully replaces the system prompt (project context and skills are still appended automatically). After switching, the editor shows the built-in default prompt ready to edit; blurring without changes keeps the default.",promptPlaceholder:"Type a custom system prompt… (applied on blur)",settingsViewPrompt:"View the current full prompt",settingsViewPromptHint:"The full system prompt actually in effect for this conversation (custom append/replace text, project context, skills and tool guidance). Read-only.",settingsViewPromptEmpty:"Session not ready yet — no system prompt available.",settingsSkills:"Skills",settingsReview:"Goal review",settingsReviewDesc:"Configure extra instructions and skills for the isolated goal-review session; the main session is unaffected.",settingsReviewSkills:"Skills available to review",reviewPromptPlaceholder:"Type custom review instructions… (applied on blur)",reviewPromptHint:"These instructions are added to the review task; pass/fail JSON output is still enforced. Skill toggles apply only to review.",settingsVisionBridge:"Vision bridge",settingsVisionBridgeDesc:"When the current model can't see images, send them to a configured vision model and transcribe into text evidence first",visionBridgeEnabled:"Enable vision bridge",visionBridgeModel:"Transcription model",visionBridgeAuto:"Auto (in order)",visionBridgeNoModels:"No configured vision model found: add any image-capable model (e.g. qwen-vl, GLM-4V, Gemini) in Model config to enable automatically",visionBridgeOffHint:"Disabled: images are sent as-is, a text-only model may not see them",visionBridgeCurrent:"Current transcription model: {model}",visionBridgePromptMode:"Transcription prompt",settingsMarkers:"Markers",settingsMarkersDesc:"Let the AI write [[todo:...]] / [[svc:...]] / [[notify:...]] / [[conv:rename:...]] inline markers in replies to update state without a tool round-trip. Global off disables all; per-marker toggles give fine control.",markersEnabled:"Markers enabled (global)",markersEnabledDesc:"Off = no marker guidance injected and no parsing; markers stay as plain text.",markersOffHint:"Globally off: all markers disabled — the AI won't write markers and no side effects fire.",markerGroupTodo:"todo — tasks",markerGroupSvc:"svc — background services",markerGroupNotify:"notify — non-blocking hints",markerGroupRename:"conv/rename — rename chat",markerRenameTip:"[[conv:rename:Title]] or [[rename:set:Title]] renames the current conversation (≤80 chars)",settingsTerminalTools:"Terminal tools",terminalToolsEnabled:"Enable persistent terminal tools",settingsTerminalToolsDesc:"Let the AI use the built-in terminal for interactive programs (REPLs/vim), long-running servers, continuous output watching, or when you ask it to work in the visible terminal; ordinary commands still go through the one-shot bash tool",terminalToolsOffHint:"Disabled: the AI has no terminal_* tools and receives no usage guidance",settingsMessageDisplay:"Message display",thinkingWrap:"Show full thinking",thinkingWrapDesc:"On: thinking always expands fully and wraps (live reasoning visible while streaming); Off: collapses to a one-line summary with the latest text shown live while streaming",toolsWrap:"Show full tools",toolsWrapDesc:"On: tool calls always expand fully showing arguments and output; Off: collapsed by default, click to expand",terminalBashTakeover:"Terminal-backed bash",terminalBashTakeoverDesc:"This switch decides whether bash is overridden to a terminal version: OFF = native SDK bash (process spawn, no terminal); ON = runs in a visible terminal, where the persist parameter decides (on top of the switch) one-shot (false — process exits when the command finishes, output retained) vs persistent (true — shell state retained across calls, silent commands move to the background and notify the AI)",terminalBashIdleMs:"Silence-to-background threshold (ms)",terminalBashIdleMsDesc:"In persistent-terminal mode, when a command produces no output for this long, stop blocking and let it keep running in the background; the AI is notified when it finishes. 0 = always wait until completion (default 15000)",visionBridgePromptPlaceholder:"Type a custom transcription prompt… (empty = built-in default, applied on blur)",visionBridgePromptAppendHint:"Append mode: custom text is appended after the built-in transcription prompt (recommended — keeps the verbatim-transcription contract).",visionBridgePromptReplaceHint:"Replace mode: custom text replaces the built-in transcription prompt entirely. After switching, the editor shows the built-in default prompt ready to edit; blurring without changes keeps the default.",uninstallExt:"Uninstall",uninstallConfirm:"Confirm?",uninstallConfirmHint:"Click again to confirm — runs pi remove in the terminal",uninstallHint:"Runs pi remove in a visible terminal, then refreshes the list automatically",uninstallTitle:"Uninstall",pluginUpdate:"Update",pluginUpdateHint:"Re-installs from the recorded source (--force, keeps config.json), then refreshes the plugin list automatically",pluginUninstallHint:"Runs pi-web-ui uninstall in a visible terminal (click again to confirm), then refreshes the list automatically",settingsExtensions:"Extensions",settingsUiPlugins:"UI plugins",noUiPlugins:"No UI plugins installed (<dataDir>/plugins/)",dshPatches:"DSH user patches",dshPatchesDesc:"Cordis patches loaded at runtime boot, in filename order (<dataDir>/dsh-patches/*.yml). New/edited files take effect after 'Rescan' restarts the runtime; broken files are skipped and logged to runtime stderr.",dshPatchesRescan:"Rescan",dshPatchesRescanHint:"Re-scan the patch directory and restart the DSH runtime so new patches take effect",dshPatchesEmpty:"No patch files yet",dshPatchesPath:"Patch directory: ",uiPluginNoSource:"Installed manually — no recorded source, online update unavailable",uiPluginPerms:"Permissions",pluginSettingsSave:"Save plugin settings",pluginSettingsSaving:"Saving…",pluginSettingsReset:"Reset defaults",settingsPresets:"Presets",settingsSubagentTemplates:"Subagent templates",settingsSubagentTemplatesDesc:"Presets for spawned subagents (role system prompt + skills/extensions whitelist + optional model). AI may pick a template (subagent_spawn template param) or spawn without one; disabled templates stay in the panel but are invisible to AI tools.",noSubagentTemplates:"No subagent templates yet. AI can pick a template when spawning a subagent (role prompt + skills/extensions whitelist + optional model), or spawn without a template param for default config.",subagentTemplateNew:"New template",subagentTemplateEdit:"Edit",subagentTemplateClosed:"Disabled",tplDefaultBadge:"Built-in",subagentDefaultModelLabel:"Default subagent model",subagentFollowMain:"Follow the main conversation's current model",subagentDefaultModelHint:"Fallback model for all subagents (a template's own model and the subagent_spawn model param take priority); does not change the main conversation's model.",subagentNoModels:"No usable models yet (configure a provider API key first) — subagents will follow the main conversation's model.",subagentTemplateOffHint:"Disabled templates stay in the panel and can be re-enabled, but AI tools can't see or pick them",subagentTemplateEnable:"Enable",subagentTemplateDisable:"Disable",tplNamePlaceholder:"Template name (referenced by AI via subagent_spawn's template param)…",tplDescriptionPlaceholder:"Description (AI uses it to judge when to pick this template)…",tplPromptModeLabel:"System prompt mode",tplModelLabel:"Model (empty = follow main conversation)",tplSystemPromptLabel:"System prompt",tplSystemPromptPlaceholder:"Template role system prompt… (may be empty in append mode)",tplWhitelistHint:"Whitelist: checked = the subagent only gets these; none checked = follow the main session settings",tplSkillsLabel:"Skills whitelist",tplExtensionsLabel:"Extensions whitelist",tplSave:"Save template",tplCancel:"Cancel edit",tplDelete:"Delete template",tplInherit:"Follow main session",settingsEnabled:"Enabled",settingsDisabled:"Disabled",presetNamePlaceholder:"Preset name…",saveAsPreset:"Save as preset",applyPreset:"Apply",deletePreset:"Delete preset",noSkills:"No skills",noExtensions:"No extensions",noPresets:"No presets yet (tune the settings above, then save them as a preset)",loadingSession:"Loading session…",connectingServer:"Connecting to pi-web-ui server…"},En=l.createContext(null);function na(){try{const t=localStorage.getItem(Tn);if(t==="zh"||t==="en")return t}catch{}return"zh"}function ia({children:t}){const[s,n]=l.useState(na),r=l.useCallback(a=>{n(a);try{localStorage.setItem(Tn,a)}catch{}},[]),c=l.useCallback((a,o)=>{let u=Fs[a];if(s==="zh"&&(u=Bs[a]),o)for(const[m,y]of Object.entries(o))u=u.replaceAll(`{${m}}`,String(y));return u},[s]);l.useEffect(()=>{document.documentElement.lang=s==="zh"?"zh-CN":"en",document.title=s==="zh"?Bs.docTitle:Fs.docTitle},[s]);const i=l.useMemo(()=>({locale:s,setLocale:r,t:c}),[s,r,c]);return e.jsx(En.Provider,{value:i,children:t})}function mt(){const t=l.useContext(En);if(!t)throw new Error("useI18n must be used within LanguageProvider");return t}function xe(){return mt().t}const aa=[{kind:"question",labelKey:"sound.question",descKey:"sound.question.desc"},{kind:"done",labelKey:"sound.done",descKey:"sound.done.desc"},{kind:"start",labelKey:"sound.start",descKey:"sound.start.desc"},{kind:"error",labelKey:"sound.error",descKey:"sound.error.desc"}];function $s({settings:t,onChange:s,onPreview:n}){const r=xe(),c=i=>s({...t,...i});return e.jsxs("div",{className:"sound-menu",children:[e.jsx("div",{className:"dd-header",children:r("soundHeader")}),e.jsxs("label",{className:"sound-row sound-master",children:[e.jsxs("span",{className:"sound-label",children:[e.jsx(yn,{className:"sound-icon"}),e.jsx("span",{children:r("enableSound")})]}),e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:i=>c({enabled:i.target.checked})})]}),aa.map(({kind:i,labelKey:a,descKey:o})=>e.jsxs("label",{className:`sound-row ${t.enabled?"":"disabled"}`,children:[e.jsxs("span",{className:"sound-label",children:[e.jsx("span",{className:"sound-name",children:r(a)}),e.jsx("span",{className:"sound-desc",children:r(o)})]}),e.jsxs("span",{className:"sound-right",children:[e.jsx("button",{type:"button",className:"sound-preview",title:r("preview"),disabled:!t.enabled,onClick:u=>{u.preventDefault(),n(i)},children:r("preview")}),e.jsx("input",{type:"checkbox",checked:t[i],disabled:!t.enabled,onChange:u=>c({[i]:u.target.checked})})]})]},i)),e.jsxs("div",{className:`sound-volume ${t.enabled?"":"disabled"}`,children:[e.jsx("span",{className:"sound-name",children:r("volume")}),e.jsx("input",{type:"range",min:0,max:100,step:5,value:t.volume,disabled:!t.enabled,onChange:i=>c({volume:Number(i.target.value)})}),e.jsxs("span",{className:"sound-vol-num",children:[t.volume,"%"]})]})]})}let Dt=null;function ra(t){if(t===void 0){const n=globalThis.document;if(n&&typeof n.baseURI=="string"&&n.baseURI)try{t=new URL(n.baseURI).pathname}catch{}if(t===void 0)return"/"}if(!t||t==="/")return"/";let s=t.replace(/index\.html$/i,"");return s.endsWith("/")||(s+="/"),s}function Pn(){return Dt===null&&(Dt=ra()),Dt}function la(t,s){return s==="/"?t:s+t.replace(/^\/+/,"")}function Ve(t){return la(t,Pn())}const Mn="pi-web-notify",At={enabled:!1};function Rn(){try{const t=localStorage.getItem(Mn);if(!t)return{...At};const s=JSON.parse(t);return{enabled:typeof s.enabled=="boolean"?s.enabled:At.enabled}}catch{return{...At}}}function Hs(t){try{localStorage.setItem(Mn,JSON.stringify(t))}catch{}}function ot(){return typeof window<"u"&&"Notification"in window}function oa(){return ot()?Notification.permission:"denied"}async function ca(){if(!ot())return"denied";try{return await Notification.requestPermission()}catch{return"denied"}}async function _t(t,s){var r;if(!ot()||document.hasFocus()||!Rn().enabled||Notification.permission!=="granted")return;const n={body:s,icon:Ve("/icons/icon-192.png"),badge:Ve("/icons/icon-192.png"),tag:"pi-web-ui"};try{const c=await((r=navigator.serviceWorker)==null?void 0:r.getRegistration());c&&typeof c.showNotification=="function"?c.showNotification(t,n):new Notification(t,n)}catch{}}function Os(){const t=xe(),[s,n]=l.useState(Rn),[r,c]=l.useState(()=>ot()?oa():"denied"),i=async a=>{const o={...s,enabled:a};if(n(o),Hs(o),a){const u=await ca();if(c(u),u!=="granted"){const m={...o,enabled:!1};n(m),Hs(m)}}};return e.jsxs("div",{className:"sound-menu",style:{borderTop:"1px solid var(--border-color, rgba(255,255,255,.08))",marginTop:6,paddingTop:6},children:[e.jsx("div",{className:"dd-header",children:t("notifyHeader")}),e.jsxs("label",{className:"sound-row sound-master",children:[e.jsxs("span",{className:"sound-label",children:[e.jsx(Xi,{className:"sound-icon"}),e.jsx("span",{children:t("notifyEnable")})]}),e.jsx("input",{type:"checkbox",checked:s.enabled,onChange:a=>i(a.target.checked)})]}),e.jsx("div",{className:"sound-desc",style:{padding:"2px 8px 4px",opacity:.7,fontSize:"0.82em"},children:t("notifyEnableDesc")}),!ot()&&e.jsx("div",{className:"sound-desc",style:{padding:"0 8px 4px",opacity:.7,fontSize:"0.82em"},children:t("notifyUnsupported")}),r==="denied"&&e.jsx("div",{className:"sound-desc",style:{padding:"0 8px 4px",opacity:.7,fontSize:"0.82em"},children:t("notifyDenied")})]})}function da({chat:t,send:s,terminal:n,view:r,plugins:c,onViewChange:i,onOpenPanel:a,onOpenSettings:o,onOpenBgTasks:u,onOpenGlobalSearch:m,sound:y,onSoundChange:g,onSoundPreview:x,themes:b,theme:E,onThemeChange:A}){var D;const{locale:H,setLocale:S,t:j}=mt(),[J,Q]=l.useState(!1),[X,U]=l.useState(!1),[K,q]=l.useState(!1),[Y,T]=l.useState(!1),[P,k]=l.useState(!1),B=[{value:"zh",label:j("langZh")},{value:"en",label:j("langEn")}],Z=t.ready?j("connected"):t.status==="closed"?j("reconnecting"):j("connecting"),G=t.ready?"ok":"busy",M=()=>{var L,ee;if(!t.ready)return;const d=j("updateTabTitle"),w={name:d,command:"npm i -g pi-web-ui@latest",cwd:"${pwd}"},h=t.terminals.find(W=>W.title===d);h?(n.restart(h.id),s({type:"run_command",terminalId:h.id,conversationId:h.conversationId,command:w,cols:80,rows:24})):n.create({id:Ue(),conversationId:t.activeConversationId||((L=t.state)==null?void 0:L.conversationId)||"",title:d,cwd:((ee=t.state)==null?void 0:ee.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:w}),T(!1),k(!1),i("terminal")},I=(d,w)=>{var ee,W;if(!t.ready||d.length===0)return;const h={name:w,command:sa(d),cwd:"${pwd}"},L=t.terminals.find(ae=>ae.title===w);L?(n.restart(L.id),s({type:"run_command",terminalId:L.id,conversationId:L.conversationId,command:h,cols:80,rows:24})):n.create({id:Ue(),conversationId:t.activeConversationId||((ee=t.state)==null?void 0:ee.conversationId)||"",title:w,cwd:((W=t.state)==null?void 0:W.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:h}),T(!1),k(!1),i("terminal")},C=t.updatesAll??[],$=C.filter(d=>!d.upToDate&&!d.error).length,z=C.filter(d=>!d.upToDate&&!d.error&&d.kind!=="webui"),ne=()=>e.jsxs("div",{className:"dd-updates-all",children:[e.jsx("div",{className:"dd-header",children:j("updatesAllTitle")}),t.updatesAll===null?e.jsx("div",{className:"dd-note",children:j("checkingUpdate")}):C.length===0?e.jsx("div",{className:"dd-note",children:j("updatesAllUpToDate")}):e.jsx("ul",{className:"dd-all-list",children:C.map(d=>e.jsxs("li",{className:`dd-all-item${d.error?" err":d.upToDate?"":" warn"}`,children:[e.jsx("span",{className:"dd-all-name",title:d.name,children:d.name}),e.jsx("span",{className:"dd-all-kind",children:d.kind==="webui"?j("kindWebUi"):d.kind==="pi-core"?j("kindPiCore"):j("kindPackage")}),e.jsx("span",{className:"dd-all-vers",children:d.error?j("updateCheckFailed"):d.upToDate?`v${d.current}`:e.jsxs(e.Fragment,{children:["v",d.current," → v",d.latest]})}),d.kind!=="webui"&&!d.upToDate&&!d.error&&e.jsx("button",{type:"button",className:"dd-update-btn",onClick:()=>I([d],j("updatePkgTabTitle",{name:d.name})),children:j("updateBtn")})]},`${d.kind}:${d.name}`))}),e.jsxs("div",{className:"dd-actions",children:[z.length>0&&e.jsx("button",{type:"button",className:"dd-refresh accent",style:{flex:1},onClick:()=>I(z,j("updateAllTabTitle")),children:j("updateAllBtn")}),e.jsx("button",{type:"button",className:"dd-refresh",style:z.length>0?{flex:1}:void 0,onClick:()=>s({type:"check_updates_all",force:!0}),children:j("updatesAllRefresh")})]})]}),v=()=>{var d,w;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"dd-update",children:[e.jsxs("div",{className:"dd-row",children:[e.jsx("span",{children:j("currentVersion")}),e.jsxs("b",{children:["v",((d=t.update)==null?void 0:d.current)??"…"]})]}),e.jsxs("div",{className:"dd-row",children:[e.jsx("span",{children:j("latestVersion")}),e.jsx("b",{children:t.update===null?j("checkingUpdate"):t.update.error?t.update.error:t.update.latest?`v${t.update.latest}`:j("checkingUpdate")})]}),t.update&&t.update.upToDate&&e.jsx("div",{className:"dd-note ok",children:j("upToDate")}),t.update&&!t.update.upToDate&&t.update.latest&&e.jsx("div",{className:"dd-note warn",children:j("updateAvailable",{version:t.update.latest})}),((w=t.update)==null?void 0:w.latestPublishedAt)&&Date.now()-new Date(t.update.latestPublishedAt).getTime()<30*6e4&&e.jsx("div",{className:"dd-note warn",children:j("updateJustPublished",{version:t.update.latest??""})}),t.update&&!t.update.upToDate&&t.update.latest&&e.jsx("div",{className:"dd-note",children:j("updateTerminalHint")})]}),e.jsxs("div",{className:"dd-actions",children:[e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>s({type:"check_update"}),children:t.update===null?j("checkingUpdate"):j("checkUpdate")}),t.update&&!t.update.upToDate&&t.update.latest&&e.jsx("button",{type:"button",className:"dd-refresh accent",onClick:M,children:j("updateNow")})]})]})};return e.jsxs("header",{className:"topbar",children:[e.jsxs("div",{className:"brand",children:[e.jsx("button",{type:"button",className:"panel-toggle",title:j("openHistory"),onClick:()=>a("left"),children:e.jsx($i,{})}),e.jsx("span",{className:"brand-logo",children:"π"}),e.jsx("span",{className:"brand-name",children:"pi-web-ui"}),e.jsx("span",{className:`conn-dot ${G}`,title:Z}),e.jsx("span",{className:"conn-label",children:Z})]}),e.jsxs("div",{className:"topbar-actions",children:[e.jsxs("div",{className:"view-switch",role:"tablist","aria-label":j("viewSwitch"),children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":r==="chat",className:r==="chat"?"active":"",onClick:()=>i("chat"),children:[e.jsx(st,{}),e.jsx("span",{children:j("chat")})]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":r==="terminal",className:r==="terminal"?"active":"",onClick:()=>i("terminal"),children:[e.jsx(tt,{}),e.jsx("span",{children:j("terminal")})]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":r==="git",className:r==="git"?"active":"",onClick:()=>i("git"),children:[e.jsx(yt,{}),e.jsx("span",{children:j("scmTab")})]}),c.map(d=>{const w=d.error?`${d.name}: ${d.error}`:d.description?`${d.name} — ${d.description}`:d.name;return e.jsxs("button",{type:"button",role:"tab","aria-selected":r===`plugin:${d.id}`,className:`plugin-tab${r===`plugin:${d.id}`?" active":""}${d.error?" broken":""}`,title:w,onClick:()=>i(`plugin:${d.id}`),children:[d.icon?e.jsx("span",{"aria-hidden":!0,children:d.icon}):null,e.jsx("span",{children:d.name})]},d.id)})]}),e.jsxs("div",{className:"topbar-desktop",children:[e.jsxs("button",{type:"button",className:"chip",title:j("searchGlobalTip"),onClick:m,children:[e.jsx(Nt,{}),e.jsx("span",{className:"chip-sub",children:j("searchGlobal")})]}),e.jsxs("button",{type:"button",className:"chip bg-task-chip","data-tip":j("bgTasksTip"),onClick:u,children:[e.jsx(Ct,{}),e.jsx("span",{className:"chip-sub",children:j("bgTasks")}),t.bgServers.length>0&&e.jsx("span",{className:"bg-task-badge",children:t.bgServers.length})]}),e.jsxs("button",{type:"button",className:"chip",title:j("settingsTitle"),onClick:o,children:[e.jsx(wt,{}),e.jsx("span",{className:"chip-sub",children:j("settings")})]}),e.jsxs(ze,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(yn,{}),e.jsx("span",{className:"chip-sub",children:j("sound")})]}),open:J,onOpenChange:Q,children:[e.jsx($s,{settings:y,onChange:g,onPreview:x}),e.jsx(Os,{})]}),e.jsxs(ze,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(zi,{}),e.jsx("span",{className:"chip-sub",children:H==="zh"?j("langZh"):"EN"})]}),open:X,onOpenChange:U,children:[e.jsx("div",{className:"dd-header",children:j("language")}),B.map(d=>e.jsx(Ie,{active:H===d.value,onClick:()=>{S(d.value),U(!1)},children:d.label},d.value))]}),e.jsxs(ze,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(Li,{}),e.jsx("span",{className:"chip-sub",children:j("theme")})]}),open:K,onOpenChange:q,children:[e.jsx("div",{className:"dd-header",children:j("theme")}),e.jsx(Ie,{active:E===null,onClick:()=>{A(null),q(!1)},children:j("themeDefault")}),b.map(d=>e.jsx(Ie,{active:E===d.id,onClick:()=>{A(d.id),q(!1)},children:H==="en"?d.nameEn??d.name:d.name},d.id))]}),e.jsxs(ze,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(ls,{}),e.jsxs("span",{className:"chip-sub",children:["v",((D=t.update)==null?void 0:D.current)??"…"]}),t.update&&!t.update.upToDate&&e.jsx("span",{className:"update-dot",title:j("updateAvailable",{version:t.update.latest??""})}),$>0&&e.jsx("span",{className:"update-badge",children:j("updatesAllBadge",{n:$})})]}),open:Y,onOpenChange:d=>{T(d),d&&(s({type:"check_update"}),s({type:"check_updates_all"}))},fit:!0,children:[e.jsx("div",{className:"dd-header",children:j("update")}),v(),ne()]}),e.jsx("a",{className:"chip github",href:"https://github.com/xing-shuyin/pi-web-ui",target:"_blank",rel:"noreferrer noopener",title:j("githubRepo"),children:e.jsx(As,{})})]}),e.jsxs("button",{type:"button",className:"chip newchat","data-tip":j("newChatTip"),onClick:()=>s({type:"new_chat"}),children:[e.jsx(He,{}),e.jsx("span",{children:j("newChat")})]}),e.jsx("div",{className:"topbar-more",children:e.jsxs(ze,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(Bi,{}),e.jsx("span",{className:"chip-sub",children:j("more")}),t.update&&!t.update.upToDate&&e.jsx("span",{className:"update-dot"})]}),open:P,onOpenChange:d=>{k(d),d&&(s({type:"check_update"}),s({type:"check_updates_all"}))},children:[e.jsx("div",{className:"dd-header",children:j("sound")}),e.jsx("div",{className:"dd-header",children:j("settings")}),e.jsxs(Ie,{onClick:()=>{k(!1),o()},children:[e.jsx(wt,{})," ",j("settingsTitle")]}),e.jsxs(Ie,{onClick:()=>{k(!1),m()},children:[e.jsx(Nt,{})," ",j("searchGlobal")]}),e.jsxs(Ie,{onClick:()=>{k(!1),u()},children:[e.jsx(Ct,{})," ",j("bgTasks"),t.bgServers.length>0&&e.jsx("em",{className:"bg-task-badge",children:t.bgServers.length})]}),e.jsx($s,{settings:y,onChange:g,onPreview:x}),e.jsx(Os,{}),e.jsx("div",{className:"dd-header",children:j("language")}),B.map(d=>e.jsx(Ie,{active:H===d.value,onClick:()=>S(d.value),children:d.label},d.value)),e.jsx("div",{className:"dd-header",children:j("theme")}),e.jsx(Ie,{active:E===null,onClick:()=>{A(null),k(!1)},children:j("themeDefault")}),b.map(d=>e.jsx(Ie,{active:E===d.id,onClick:()=>{A(d.id),k(!1)},children:H==="en"?d.nameEn??d.name:d.name},d.id)),e.jsx("div",{className:"dd-header",children:j("update")}),v(),ne(),e.jsxs("a",{className:"dd-refresh dd-more-link",href:"https://github.com/xing-shuyin/pi-web-ui",target:"_blank",rel:"noreferrer noopener",children:[e.jsx(As,{})," ",j("githubRepo")]})]})}),e.jsx("button",{type:"button",className:"panel-toggle",title:j("openFiles"),onClick:()=>a("right"),children:e.jsx(Je,{})})]})]})}function Ks(t){const s=new Date(t),n=new Date;return s.toDateString()===n.toDateString()?`${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}`:`${s.getMonth()+1}/${s.getDate()}`}function ua(t,s){const n=new Map;for(const c of t){const i=n.get(c.cwd)??[];i.push(c),n.set(c.cwd,i)}const r=[...n.entries()].map(([c,i])=>({cwd:c,isCurrent:c===s,convs:i}));return r.sort((c,i)=>c.isCurrent?-1:i.isCurrent?1:c.cwd<i.cwd?-1:c.cwd>i.cwd?1:0),r}const pa="pi-web-ui:lp-collapse-projects",ma="pi-web-ui:lp-collapse-convs",ha="pi-web-ui:lp-collapse-sessions";function Bt(t,s=!1){const[n,r]=l.useState(()=>{try{const i=localStorage.getItem(t);if(i==="1")return!0;if(i==="0")return!1}catch{}return s}),c=l.useCallback(()=>{r(i=>{const a=!i;try{localStorage.setItem(t,a?"1":"0")}catch{}return a})},[t]);return[n,c]}const In="pi-web-ui:lp-sizes",Jt={projects:1,convs:1,sessions:1};function ga(){try{const t=localStorage.getItem(In);if(t){const s=JSON.parse(t);return{projects:typeof s.projects=="number"&&s.projects>0?s.projects:1,convs:typeof s.convs=="number"&&s.convs>0?s.convs:1,sessions:typeof s.sessions=="number"&&s.sessions>0?s.sessions:1}}}catch{}return{...Jt}}const fa=l.memo(function({ready:s,status:n,cwd:r,sessionFile:c,conversations:i,sessions:a,projects:o,activeConversationId:u,send:m,active:y,collapsible:g,onToggleCollapse:x}){const b=xe(),E=c,A=r,[H,S]=l.useState(null),[j,J]=l.useState(null),[Q,X]=l.useState(""),[U,K]=Bt(pa,!1),[q,Y]=Bt(ma,!1),[T,P]=Bt(ha,!1),k=l.useRef(null),[B,Z]=l.useState(()=>ga());l.useEffect(()=>{try{localStorage.setItem(In,JSON.stringify(B))}catch{}},[B]);const G=l.useCallback((d,w)=>h=>{h.preventDefault();const L=h.currentTarget,ee=h.clientY,W={...B},ae=k.current;if(!ae)return;const ye=32,be=72,ge=[{key:"projects",visible:o.length>0,collapsed:U},{key:"convs",visible:i.length>0,collapsed:q},{key:"sessions",visible:!0,collapsed:T}].filter(pe=>pe.visible),ke=ge.filter(pe=>pe.collapsed).length,re=ge.filter(pe=>!pe.collapsed).map(pe=>pe.key).reduce((pe,ve)=>pe+(W[ve]??1),0)||1,f=Math.max(120,ae.clientHeight-ke*ye),O=(W[d]??1)+(W[w]??1),de=be/f*re;L.classList.add("dragging"),document.body.classList.add("lp-resizing");const ue=pe=>{const Me=(pe.clientY-ee)/f*re;let he=(W[d]??1)+Me;const _e=O-de;he=Math.max(de,Math.min(_e,he));const Le=O-he;Z(Be=>({...Be,[d]:he,[w]:Le}))},me=()=>{window.removeEventListener("pointermove",ue),window.removeEventListener("pointerup",me),L.classList.remove("dragging"),document.body.classList.remove("lp-resizing")};window.addEventListener("pointermove",ue),window.addEventListener("pointerup",me)},[B,o.length,i.length,U,q,T]);l.useEffect(()=>{!y||!s||n!=="open"||r&&(m({type:"list_sessions"}),m({type:"list_projects"}))},[y,s,n,r,m]);const M=d=>{const w=d.name||d.firstMessage.trim();return w.length>0?w:b("emptyChat")},I=d=>d.split(/[\\/]/).pop()||d,C=(d,w,h,L,ee)=>{const W=H===d;return e.jsx("button",{type:"button",className:`lp-del ${W?"confirm":""}`,title:W?h:w,onClick:ae=>{ae.stopPropagation(),W?(S(null),L()):S(d)},children:W?e.jsx(pt,{}):ee??e.jsx(Ae,{})})},$=(d,w,h,L)=>e.jsxs("button",{type:"button",className:"lp-section-title panel-section-title",onClick:h,title:b(w?"expandSection":"collapseSection"),children:[e.jsxs("span",{className:"lp-section-title-text",children:[d,L!==void 0?` (${L})`:""]}),e.jsx("span",{className:"lp-section-chevron",children:w?e.jsx(Ge,{}):e.jsx(ut,{})})]}),ne=[{key:"projects",visible:o.length>0,collapsed:U},{key:"convs",visible:i.length>0,collapsed:q},{key:"sessions",visible:!0,collapsed:T}].filter(d=>d.visible).filter(d=>!d.collapsed),v=ne.reduce((d,w)=>d+(B[w.key]??1),0)||1,D=d=>ne.length<=1?1:(B[d]??1)/v*ne.length;return e.jsxs("aside",{ref:k,className:"panel panel-left lp-panel",children:[g&&x&&e.jsx("button",{type:"button",className:"panel-collapse-btn",title:b("collapsePanel"),onClick:x,children:e.jsx(Nn,{})}),o.length>0&&e.jsxs("div",{className:`lp-section panel-projects ${U?"collapsed":""}`,style:U?void 0:{flex:`${D("projects")} 1 0px`},children:[$(b("recentProjects"),U,K,o.length),!U&&e.jsx("div",{className:"lp-section-body projects-scroll",children:o.map(d=>{const w=A===d.path;return e.jsxs("div",{className:"lp-row",onMouseLeave:()=>S(h=>h===`proj:${d.path}`?null:h),children:[e.jsxs("button",{type:"button",className:`project-item ${w?"active":""}`,title:d.path,onClick:()=>{w||m({type:"set_cwd",path:d.path})},children:[e.jsx(Je,{className:"project-icon"}),e.jsxs("span",{className:"project-info",children:[e.jsx("span",{className:"project-name",children:I(d.path)}),e.jsx("span",{className:"project-path",children:d.path})]}),e.jsx("span",{className:"project-time",children:Ks(d.lastUsed)})]}),C(`proj:${d.path}`,b("deleteProject"),b("deleteProjectConfirm"),()=>m({type:"remove_project",path:d.path}))]},d.path)})})]}),o.length>0&&!U&&(i.length>0?!q:!T)&&e.jsx("div",{className:"lp-sash",onPointerDown:G("projects",i.length>0?"convs":"sessions"),onDoubleClick:()=>Z({...Jt}),title:b("dragToResize")}),i.length>0&&e.jsxs("div",{className:`lp-section lp-section-convs panel-convs ${q?"collapsed":""}`,style:q?void 0:{flex:`${D("convs")} 1 0px`},children:[$(b("runningConversations"),q,Y,i.length),!q&&e.jsx("div",{className:"lp-section-body convs-scroll",children:ua(i,r).map(d=>e.jsxs("div",{className:"panel-conv-group",children:[!d.isCurrent&&e.jsx("div",{className:"panel-conv-group-title",title:d.cwd,children:I(d.cwd)}),d.convs.map(w=>{const h=u===w.id;return e.jsxs("div",{className:"lp-row",onMouseLeave:()=>S(L=>L===`conv:${w.id}`?null:L),children:[e.jsxs("button",{type:"button",className:`session-item ${h?"active":""}`,title:`${w.title}${d.isCurrent?"":` — ${d.cwd}`}`,onClick:()=>{h||m({type:"switch_conversation",id:w.id})},children:[e.jsx(st,{className:"session-icon"}),e.jsxs("span",{className:"session-info",children:[j===`conv:${w.id}`?e.jsx("input",{autoFocus:!0,className:"session-rename-input",value:Q,placeholder:b("renameSessionPlaceholder"),onClick:L=>L.stopPropagation(),onChange:L=>X(L.target.value),onKeyDown:L=>{if(L.stopPropagation(),L.key==="Enter"&&!L.nativeEvent.isComposing){const ee=Q.trim();ee&&m({type:"rename_conversation",id:w.id,name:ee}),J(null)}else L.key==="Escape"&&J(null)},onBlur:()=>J(null)}):e.jsxs("span",{className:"session-title",children:[w.isSubagent&&e.jsx("span",{className:"subagent-badge",children:b("subagentBadge")}),w.title,w.error&&e.jsx("span",{className:"conv-error-badge",title:b("convErrorBadge",{error:w.error})})]}),j===`conv:${w.id}`?null:e.jsx("span",{className:"session-sub",children:h?b("current"):b("messageCount",{n:w.messageCount})})]}),w.isStreaming&&e.jsx("span",{className:"conv-streaming",title:b("streaming")})]}),e.jsx("button",{type:"button",className:"lp-del lp-rename",title:b("renameSession"),onClick:L=>{L.stopPropagation(),S(null),X(w.title),J(`conv:${w.id}`)},children:e.jsx(St,{})}),!w.isStreaming&&!h&&C(`conv:${w.id}`,b("dismissConversation"),b("dismissConversationConfirm"),()=>m({type:"dismiss_conversation",id:w.id}),e.jsx(Pe,{})),w.isStreaming&&e.jsx("span",{className:"lp-row-stalled",title:b("streaming"),style:{position:"absolute",right:28,top:"50%",transform:"translateY(-50%)"}})]},w.id)})]},d.cwd))})]}),i.length>0&&!q&&!T&&e.jsx("div",{className:"lp-sash",onPointerDown:G("convs","sessions"),onDoubleClick:()=>Z({...Jt}),title:b("dragToResize")}),e.jsxs("div",{className:`lp-section lp-section-sessions panel-sessions ${T?"collapsed":""}`,style:T?void 0:{flex:`${D("sessions")} 1 0px`},children:[$(b("historySessions"),T,P,a.length),!T&&e.jsxs("div",{className:"lp-section-body sessions-scroll",children:[a.length===0&&e.jsx("div",{className:"panel-empty",children:b("noHistory")}),a.map(d=>{const w=E===d.path;return e.jsxs("div",{className:"lp-row",onMouseLeave:()=>S(h=>h===`sess:${d.path}`?null:h),children:[e.jsxs("button",{type:"button",className:`session-item ${w?"active":""}`,title:d.path,onClick:()=>{j||w||m({type:"switch_session",path:d.path})},children:[e.jsx(st,{className:"session-icon"}),e.jsxs("span",{className:"session-info",children:[j===d.path?e.jsx("input",{autoFocus:!0,className:"session-rename-input",value:Q,placeholder:b("renameSessionPlaceholder"),onClick:h=>h.stopPropagation(),onChange:h=>X(h.target.value),onKeyDown:h=>{if(h.stopPropagation(),h.key==="Enter"&&!h.nativeEvent.isComposing){const L=Q.trim();L&&m({type:"rename_session",path:d.path,name:L}),J(null)}else h.key==="Escape"&&J(null)},onBlur:()=>J(null)}):e.jsx("span",{className:"session-title",children:M(d)}),j===d.path?null:e.jsxs("span",{className:"session-sub",children:[w?b("current"):b("messageCount",{n:d.messageCount}),d.source==="tui"&&e.jsx("span",{className:"session-src",title:b("tuiTip"),children:"TUI"})]})]}),e.jsx("span",{className:"session-time",children:Ks(d.modified)})]}),e.jsx("button",{type:"button",className:"lp-del lp-rename",title:b("renameSession"),onClick:h=>{h.stopPropagation(),S(null),X(d.name??""),J(d.path)},children:e.jsx(St,{})}),C(`sess:${d.path}`,b("deleteSession"),b("deleteSessionConfirm"),()=>m({type:"delete_session",path:d.path}))]},d.path)})]})]})]})}),Ln="pi-web-ui:token";function xa(){try{const t=new URL(window.location.href),s=t.searchParams.get("token");s&&(localStorage.setItem(Ln,s.trim()),t.searchParams.delete("token"),window.history.replaceState(null,"",t.toString()))}catch{}}function ya(){try{return localStorage.getItem(Ln)??""}catch{return""}}function Mt(t){const s=ya();return s?`${t}${t.includes("?")?"&":"?"}token=${encodeURIComponent(s)}`:t}function va(t,s){const n=s.assistantMessageEvent,r=t.stats.tokens,c=s.usage!==null?{...r,...s.usage}:r,i=c===r?t.stats:{...t.stats,tokens:c};if(n.type!=="text_delta"&&n.type!=="thinking_delta")return i===t.stats?t:{...t,stats:i};const a=n.delta??"";if(!a)return i===t.stats?t:{...t,stats:i};const o=t.streamingMessage??null,u=o&&o.id===s.messageId?o:{id:s.messageId,content:[]},m=[...u.content],y=n.type==="thinking_delta"?"thinking":"text",g=n.contentIndex??m.length-1;return g>=0&&g<m.length&&m[g].type===y?m[g]=y==="thinking"?{type:"thinking",thinking:(m[g].thinking??"")+a}:{type:"text",text:(m[g].text??"")+a}:m.push(y==="thinking"?{type:"thinking",thinking:a}:{type:"text",text:a}),{...t,stats:i,streamingMessage:{...u,id:s.messageId,content:m}}}const Xt="pi-web-ui:plugin-data";function ba(t,s){window.dispatchEvent(new CustomEvent(Xt,{detail:{pluginId:t,payload:s}}))}function ka(t){const s=n=>{const r=n.detail;t(r.pluginId,r.payload)};return window.addEventListener(Xt,s),()=>window.removeEventListener(Xt,s)}const et=new Map,Zt=new Set,Xe=new Set;let Ws=-1;function Dn(){return[...et.values()]}function ja(){const t=Dn();for(const s of Zt)s(t)}function wa(t){return Zt.add(t),t(Dn()),()=>Zt.delete(t)}async function Na(t,s){s!==Ws&&(Ws=s,et.clear(),Xe.clear());const n=new Set(t.map(r=>r.id));for(const r of[...et.keys()])n.has(r)||et.delete(r);for(const r of[...Xe])n.has(r)||Xe.delete(r);await Promise.all(t.filter(r=>r.hasClient&&!r.error&&!et.has(r.id)&&!Xe.has(r.id)).map(async r=>{try{const i=(await import(Ve(`/plugins/${encodeURIComponent(r.id)}/client/entry.mjs?e=${s}`))).default;i&&typeof i.mount=="function"?et.set(r.id,{info:r,module:i}):(Xe.add(r.id),console.error(`[plugin:${r.id}] entry.mjs 缺少 default.mount`))}catch(c){Xe.add(r.id),console.error(`[plugin:${r.id}] 客户端加载失败:`,c)}})),ja()}function Ca(t,s){return{pluginId:t,send:n=>s({type:"plugin_message",pluginId:t,payload:n}),onData:n=>ka((r,c)=>{r===t&&n(c)})}}const Sa=12,Ft=2e5,Ta=2e5,Ea="LIVE_OMIT",Pa={conversationId:null,goal:null,reviewModel:null,maxRounds:3,locked:!0,reviewing:!1,round:0,status:"",verdict:"pending",wizard:{active:!1,draft:"",model:null,step:0,maxSteps:6,status:""}};function Ma(){const t=new Map,s=new Map,n=(r,c)=>`${r}:${c}`;return{write(r,c,i){const a=n(r,c),o=t.get(a);if(o&&o.size>0){for(const y of o)try{y.write(i)}catch{}return}const u=s.get(a)??"",m=u.length+i.length>Ta?i:u+i;s.set(a,m)},register(r,c,i){const a=n(r,c);let o=t.get(a);o||(o=new Set,t.set(a,o)),o.add(i);const u=s.get(a);if(u){try{i.write(u)}catch{}s.delete(a)}return()=>{const m=t.get(a);m&&(m.delete(i),m.size===0&&t.delete(a)),s.delete(a)}},clear(){t.clear(),s.clear()}}}function Us(t,s){const n=new Set;for(const c of s.messages)c.role==="toolResult"&&c.toolCallId&&n.add(c.toolCallId),c.role==="bashExecution"&&n.add(`bash-${c.id}`);let r=!1;for(const c of t.keys())n.has(c)&&(t.delete(c),r=!0);return r?new Map(t):t}function qs(t,s){if(t.size===0)return t;const n=new Set;for(const c of s.messages)c.role==="toolResult"&&c.toolCallId&&n.add(c.toolCallId);let r=!1;for(const c of t.keys())n.has(c)&&(t.delete(c),r=!0);return r?new Map(t):t}function Ra(t,s){var n,r,c,i;switch(s.type){case"status":return{...t,status:s.status,ready:s.status==="open"?t.ready:!1,terminals:s.status==="closed"?[]:t.terminals};case"ready":return{...t,serverVersion:s.serverVersion,engine:s.engine,ready:!0,protocolMismatch:s.protocolVersion!==void 0&&s.protocolVersion!==Sa};case"snapshot":return{...t,ready:!0,state:s.state,activeConversationId:s.state.conversationId,liveOutputs:Us(t.liveOutputs,s.state),toolStatuses:qs(t.toolStatuses,s.state)};case"snapshot_delta":{const a=t.state,o=s.msg;if(!a||a.conversationId!==o.conversationId||a.rev!==o.baseRev)return t;const u={...a,...o.state,messages:o.appended.length>0?[...a.messages,...o.appended]:a.messages};return{...t,ready:!0,state:u,activeConversationId:u.conversationId,liveOutputs:Us(t.liveOutputs,u),toolStatuses:qs(t.toolStatuses,u)}}case"tool_delta":{const a=t.liveOutputs.get(s.toolCallId),o=((a==null?void 0:a.text)??"")+s.delta,u=o.length>Ft?`…[${Ea}:${o.length-Ft}]…
|
|
305
|
+
`+o.slice(o.length-Ft):o,m=new Map(t.liveOutputs);return m.set(s.toolCallId,{toolName:s.toolName,text:u}),{...t,liveOutputs:m}}case"message_delta":{const a=t.state;return!a||a.conversationId!==s.msg.conversationId?t:{...t,state:va(a,s.msg)}}case"tool_status":return{...t,toolStatuses:new Map(t.toolStatuses).set(s.status.toolCallId,s.status)};case"notice":return{...t,notices:[...t.notices,s.notice].slice(-6)};case"dismiss_notice":return{...t,notices:t.notices.filter(a=>a.id!==s.id)};case"sessions":return{...t,sessions:s.sessions};case"conversations":return{...t,conversations:s.conversations,activeConversationId:s.activeId};case"projects":return{...t,projects:s.projects};case"files":return{...t,files:s.files};case"file_changed":return{...t,fileChanged:{path:s.path}};case"file_content":return{...t,fileContent:s.content};case"models":return{...t,models:s.models,modelsLoading:s.loading};case"models_config":return{...t,modelsConfig:s.providers};case"providers_status":return{...t,providers:s.providers};case"provider_keys":return{...t,providerKeys:s.keys};case"fetch_models_result":return{...t,fetchModelsResult:s.result};case"refresh_provider_result":return{...t,refreshProviderResult:s.result};case"clone_provider_result":return{...t,cloneProviderResult:s.result};case"install_result":return{...t,installResult:s.result};case"scm_data":return{...t,scmData:s.data};case"file_search_result":return{...t,fileSearch:s.result};case"session_search_result":return{...t,sessionSearch:s.result};case"scm_changed":return{...t,scmDirty:t.scmDirty+1};case"path_completions":return{...t,pathCompletions:s.completions};case"update_status":return{...t,update:s.status};case"update_status_all":return{...t,updatesAll:s.items};case"updates_check_started":return{...t,updatesAll:null};case"widgets":return{...t,widgets:s.widgets};case"statuses":return{...t,statuses:s.statuses};case"dialog":return{...t,dialog:s.dialog};case"question":return{...t,question:s.question};case"commands":return{...t,commands:s.commands,commandsPath:s.path};case"slash_commands":return{...t,slashCommands:s.commands};case"goal_status":return{...t,goal:s.status};case"settings":return{...t,settings:s.settings};case"bg_servers":return{...t,bgServers:s.servers};case"plugins":return{...t,plugins:s.plugins,pluginsEpoch:s.epoch};case"dsh_patches":return{...t,dshPatches:{patchDir:s.patchDir,files:s.files}};case"terminal_add":return{...t,terminals:[...t.terminals,s.meta]};case"terminal_remove":return{...t,terminals:t.terminals.filter(a=>a.id!==s.id)};case"terminal_exit":return s.conversationId&&(t.activeConversationId||(n=t.state)!=null&&n.conversationId)&&s.conversationId!==(t.activeConversationId||((r=t.state)==null?void 0:r.conversationId))?t:{...t,terminals:t.terminals.map(a=>a.id===s.terminalId?{...a,running:!1,exitCode:s.exitCode}:a)};case"terminal_restart":return{...t,terminals:t.terminals.map(a=>a.id===s.terminalId?{...a,running:!0,exitCode:null}:a)};case"terminal_list":return s.conversationId&&(t.activeConversationId||(c=t.state)!=null&&c.conversationId)&&s.conversationId!==(t.activeConversationId||((i=t.state)==null?void 0:i.conversationId))?t:{...t,terminals:s.terminals.map(a=>{var o;return{...a,conversationId:s.conversationId??((o=t.state)==null?void 0:o.conversationId)??""}})};case"terminal_active":return{...t,terminalActiveId:s.id};default:return t}}const zs="pi-web-client-id";let $t=null;function os(){if($t)return $t;let t=null;try{t=sessionStorage.getItem(zs),t||(t=Ue(),sessionStorage.setItem(zs,t))}catch{t=t??Ue()}return $t=t,t}const An="pi-web-last-cwd";function Ia(){try{return localStorage.getItem(An)}catch{return null}}function La(t){try{localStorage.setItem(An,t)}catch{}}function Da(){const t=location.protocol==="https:"?"wss:":"ws:";return Mt(`${t}//${location.host}${Ve("/ws")}`)}function Aa(){var Y;const[t,s]=l.useReducer(Ra,{status:"connecting",ready:!1,state:null,liveOutputs:new Map,toolStatuses:new Map,notices:[],sessions:[],conversations:[],activeConversationId:"",projects:[],files:null,fileChanged:null,fileContent:null,models:[],modelsLoading:!1,modelsConfig:[],providers:[],providerKeys:{},installResult:null,pathCompletions:[],update:null,updatesAll:null,widgets:[],statuses:[],dialog:null,question:null,commands:[],commandsPath:"",slashCommands:[],terminals:[],terminalActiveId:null,goal:Pa,bgServers:[],settings:null,fetchModelsResult:null,refreshProviderResult:null,cloneProviderResult:null,scmData:null,fileSearch:null,sessionSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,dshPatches:null,protocolMismatch:!1}),n=l.useRef(null),r=l.useRef(Ma()),c=l.useRef(0),i=l.useRef(null),a=l.useRef(!0),o=l.useRef(0),u=l.useRef(0),m=l.useRef(new Map),y=l.useRef(null),g=l.useRef(!1),x=l.useRef(null),b=()=>{y.current||(y.current=setTimeout(()=>{y.current=null;const T=n.current;T&&T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:"get_state"}))},300))},E=(T,P)=>{var Z;const k=m.current,B=k.get(T);if(B!==void 0&&P!==B+1){const G=q.current.chat,M=G.activeConversationId||((Z=G.state)==null?void 0:Z.conversationId);T===M&&b()}k.set(T,P)},A=l.useCallback((T,P)=>{const k=++u.current;s({type:"notice",notice:{id:k,level:T,text:P}})},[]),H=l.useCallback(T=>{const P=n.current;return P&&P.readyState===WebSocket.OPEN?(T.type==="check_updates_all"&&T.force===!0&&s({type:"updates_check_started"}),P.send(JSON.stringify(T)),!0):!1},[]),S=l.useCallback(()=>{if(!a.current)return;s({type:"status",status:"connecting"});const T=new WebSocket(Da());n.current=T,T.onopen=()=>{n.current===T&&(s({type:"status",status:"open"}),c.current=0,o.current=Date.now(),T.send(JSON.stringify({type:"hello",clientId:os()})))},T.onmessage=P=>{if(n.current!==T)return;o.current=Date.now();let k;try{k=JSON.parse(P.data)}catch{return}switch(k.type){case"ready":s({type:"ready",serverVersion:k.serverVersion,protocolVersion:k.protocolVersion,engine:k.engine}),T.send(JSON.stringify({type:"get_state"})),T.send(JSON.stringify({type:"list_files"})),T.send(JSON.stringify({type:"list_models"})),T.send(JSON.stringify({type:"list_commands"})),T.send(JSON.stringify({type:"get_commands"})),T.send(JSON.stringify({type:"check_update"})),T.send(JSON.stringify({type:"check_updates_all"}));break;case"snapshot":m.current=new Map,s({type:"snapshot",state:k.state});break;case"snapshot_delta":{const B=q.current.chat.state;(!B||B.conversationId!==k.conversationId||B.rev!==k.baseRev)&&b(),s({type:"snapshot_delta",msg:k});break}case"tool_delta":E(k.conversationId,k.seq),s({type:"tool_delta",toolCallId:k.toolCallId,toolName:k.toolName,delta:k.delta});break;case"tool_status":s({type:"tool_status",status:k});break;case"message_delta":{E(k.conversationId,k.seq),s({type:"message_delta",msg:k});break}case"notice":{const B=++u.current;s({type:"notice",notice:{id:B,level:k.level,text:k.text,textEn:k.textEn}});break}case"sessions":s({type:"sessions",sessions:k.sessions});break;case"conversations":s({type:"conversations",conversations:k.conversations,activeId:k.activeId});break;case"projects":s({type:"projects",projects:k.projects});break;case"files":s({type:"files",files:k});break;case"file_changed":s({type:"file_changed",path:k.path});break;case"file_content":s({type:"file_content",content:k});break;case"models":s({type:"models",models:k.models,loading:!1});break;case"models_config":s({type:"models_config",providers:k.providers});break;case"providers_status":s({type:"providers_status",providers:k.providers});break;case"provider_keys":s({type:"provider_keys",keys:k.keys});break;case"fetch_models_result":s({type:"fetch_models_result",result:{reqId:k.reqId,ok:k.ok,models:k.models,error:k.error}});break;case"refresh_provider_result":s({type:"refresh_provider_result",result:{reqId:k.reqId,ok:k.ok,added:k.added,total:k.total,error:k.error}});break;case"clone_provider_result":s({type:"clone_provider_result",result:{reqId:k.reqId,ok:k.ok,config:k.config,configs:k.configs,error:k.error}});break;case"scm_data":s({type:"scm_data",data:k});break;case"search_files_result":s({type:"file_search_result",result:{reqId:k.reqId,ok:k.ok,results:k.results,truncated:k.truncated}});break;case"session_search_results":s({type:"session_search_result",result:{reqId:k.reqId,ok:k.ok,results:k.results}});break;case"scm_changed":s({type:"scm_changed"});break;case"install_result":s({type:"install_result",result:k});break;case"path_completions":s({type:"path_completions",completions:k.completions});break;case"update_status":s({type:"update_status",status:k});break;case"update_status_all":s({type:"update_status_all",items:k.items});break;case"widgets":s({type:"widgets",widgets:k.widgets});break;case"statuses":s({type:"statuses",statuses:k.statuses});break;case"dialog":s({type:"dialog",dialog:{id:k.id,kind:k.kind,title:k.title,args:k.args}});break;case"dialog_closed":s({type:"dialog",dialog:null});break;case"question_pending":s({type:"question",question:{id:k.id,questions:k.questions}});break;case"terminal_output":r.current.write(k.conversationId??q.current.chat.activeConversationId,k.terminalId,k.data);break;case"terminal_exit":s({type:"terminal_exit",conversationId:k.conversationId,terminalId:k.terminalId,exitCode:k.exitCode});break;case"terminal_list":s({type:"terminal_list",conversationId:k.conversationId,terminals:k.terminals});break;case"commands":s({type:"commands",commands:k.commands,path:k.path});break;case"slash_commands":s({type:"slash_commands",commands:k.commands});break;case"goal_status":s({type:"goal_status",status:k.status});break;case"settings_state":s({type:"settings",settings:k.settings});break;case"bg_servers":s({type:"bg_servers",servers:k.servers});break;case"plugins":s({type:"plugins",plugins:k.plugins,epoch:k.epoch});break;case"dsh_patches":s({type:"dsh_patches",patchDir:k.patchDir,files:k.files});break;case"plugin_data":ba(k.pluginId,k.payload);break}},T.onclose=()=>{if(n.current===T&&(n.current=null),r.current.clear(),!a.current||n.current&&n.current!==T)return;s({type:"status",status:"closed"});const P=Math.min(1e3*2**c.current,1e4);c.current+=1,i.current=setTimeout(()=>{i.current=null,S()},P)},T.onerror=()=>{}},[]);l.useEffect(()=>{a.current=!0,S();const T=setInterval(()=>{if(!a.current)return;const P=n.current;P&&P.readyState===WebSocket.OPEN&&Date.now()-o.current>3e4&&P.close()},5e3);return()=>{var P;a.current=!1,clearInterval(T),i.current&&(clearTimeout(i.current),i.current=null),(P=n.current)==null||P.close(),n.current=null}},[S]),l.useEffect(()=>{var P;const T=(P=t.state)==null?void 0:P.cwd;if(T){if(!g.current){g.current=!0;const k=Ia();if(k&&k!==T){H({type:"set_cwd",path:k});return}}x.current!==T&&(x.current=T,La(T))}},[(Y=t.state)==null?void 0:Y.cwd,H]);const j=l.useCallback(T=>s({type:"dismiss_notice",id:T}),[]),J=l.useCallback(T=>s({type:"terminal_add",meta:T}),[]),Q=l.useCallback(T=>s({type:"terminal_remove",id:T}),[]),X=l.useCallback(T=>s({type:"terminal_restart",terminalId:T}),[]),U=l.useCallback(T=>s({type:"terminal_active",id:T}),[]),K=l.useCallback((T,P,k)=>r.current.register(T,P,k),[]),q=l.useRef({chat:t,send:H,pushNotice:A,dismissNotice:j,terminal:{create:J,close:Q,register:K,restart:X,select:U}});return q.current={chat:t,send:H,pushNotice:A,dismissNotice:j,terminal:{create:J,close:Q,register:K,restart:X,select:U}},q.current}const _a=200*1024*1024,Ba=/windows/i.test(navigator.userAgent),Fa=/[<>:"/\\|?*\u0000-\u001f]/g,$a=/[. ]+$/,Ha=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function Oa(t){const s=t.replace(Fa,"_").replace($a,"");return s?Ha.test(s)?`_${s}`:s:"_"}function Vs(t,s=!0){const n=new URLSearchParams({clientId:os(),path:t,...s?{download:"1"}:{}});return Mt(Ve(`/api/file?${n}`))}const _n="FILE_NOT_FOUND";async function Ka(t,s){const n=Ba?Oa(s):s;try{const r=await fetch(Vs(t));if(!r.ok)return{ok:!1,cancelled:!1,error:await r.text().catch(()=>"")||(r.status===404?_n:`HTTP ${r.status}`)};if(Number(r.headers.get("content-length")??"0")>_a)return window.location.assign(Vs(t)),{ok:!0};const i=await r.blob();return window.showSaveFilePicker&&window.isSecureContext?Wa(i,n):es(i,n)}catch(r){return{ok:!1,cancelled:!1,error:r instanceof Error?r.message:String(r)}}}async function Wa(t,s){let n;const r=window.showSaveFilePicker;if(!r)return es(t,s);try{n=await r({suggestedName:s})}catch(c){return c instanceof DOMException&&c.name==="AbortError"?{ok:!1,cancelled:!0}:es(t,s)}try{const c=await n.createWritable();return await c.write(t),await c.close(),{ok:!0}}catch(c){return{ok:!1,cancelled:!1,error:c instanceof Error?c.message:String(c)}}}function es(t,s){const n=URL.createObjectURL(t),r=document.createElement("a");return r.href=n,r.download=s,document.body.appendChild(r),r.click(),r.remove(),setTimeout(()=>URL.revokeObjectURL(n),1e4),{ok:!0}}const gt="@root",Ua=l.memo(function({files:s,fileChanged:n,widgets:r,cwd:c,send:i,onAttach:a,onPreview:o,onNotice:u,collapsible:m,onToggleCollapse:y}){const g=xe(),[x,b]=l.useState(""),[E,A]=l.useState(null),[H,S]=l.useState(!1),[j,J]=l.useState(null),Q=l.useRef(""),X=l.useRef(null),U=l.useCallback((d,w)=>{d.preventDefault(),Q.current=w,J({x:Math.min(d.clientX,window.innerWidth-220),y:Math.min(d.clientY,window.innerHeight-90)})},[]),K=l.useCallback(()=>J(null),[]);l.useEffect(()=>{if(!j)return;const d=L=>{var ee;(ee=L.target)!=null&&ee.closest(".ctx-menu")||K()},w=L=>{L.key==="Escape"&&K()};window.addEventListener("mousedown",d,!0),window.addEventListener("keydown",w);const h=()=>K();return window.addEventListener("blur",h),()=>{window.removeEventListener("mousedown",d,!0),window.removeEventListener("keydown",w),window.removeEventListener("blur",h)}},[j,K]);const q=l.useCallback(()=>{var d;K(),X.current&&(X.current.value=""),(d=X.current)==null||d.click()},[K]),Y=l.useCallback((d,w)=>{for(const h of w){const L=new FileReader;L.onload=()=>{const ee=L.result,W=ee.slice(ee.indexOf(",")+1);W&&i({type:"upload_file",dirPath:d,name:h.name,data:W})},L.readAsDataURL(h)}},[i]),T=l.useCallback(d=>{Y(Q.current,Array.from(d.target.files??[]))},[Y]),P=l.useRef(null),k=d=>{var w;return Array.from(((w=d.dataTransfer)==null?void 0:w.types)??[]).includes("Files")},B=l.useCallback(()=>{var d,w;(d=P.current)==null||d.querySelectorAll(".file-item.drop-target").forEach(h=>h.classList.remove("drop-target")),(w=P.current)==null||w.classList.remove("drop-root")},[]),Z=l.useCallback(d=>{var h,L;if(B(),d==null)return;const w=(h=P.current)==null?void 0:h.querySelector(`.file-item[data-path="${CSS.escape(d)}"]`);w?w.classList.add("drop-target"):(L=P.current)==null||L.classList.add("drop-root")},[B]),G=d=>{const w=d instanceof Element?d.closest(".file-item"):null;return(w==null?void 0:w.dataset.type)==="dir"?w.dataset.path??x:x},M=l.useCallback(()=>{const d=document.querySelector(".app");d&&d.dispatchEvent(new DragEvent("dragleave",{bubbles:!0}))},[]),I=1e4,C=l.useRef(0),$=l.useRef(void 0),z=l.useCallback((d,w)=>{const h=++C.current;b(d),w!=null&&w.silent||S(!0),i({type:"list_files",path:d===""?void 0:d})||C.current===h&&S(!1)},[i]);l.useEffect(()=>{s&&s.path===x&&S(!1)},[s,x]),l.useEffect(()=>{if(c!==$.current){$.current=c,z("",{silent:!0});return}const d=setInterval(()=>{document.visibilityState!=="hidden"&&z(x,{silent:!0})},I);return()=>clearInterval(d)},[c,x,z]),l.useEffect(()=>{n&&n.path===x&&z(x,{silent:!0})},[n,x,z]);const ne=d=>z(d),v=()=>{(s==null?void 0:s.parent)!==null&&(s==null?void 0:s.parent)!==void 0&&z(s.parent)},D=(()=>{if(x===""||x===gt)return[];const d=x.split("/").filter(w=>!!w&&w!==gt);return x.startsWith("/")?d.map((w,h)=>({label:h===0?"/":d[h],path:"/"+d.slice(0,h+1).join("/")})):d.map((w,h)=>({label:d[h],path:d.slice(0,h+1).join("/")}))})();return e.jsxs("aside",{className:"panel panel-right",children:[m&&y&&e.jsx("button",{type:"button",className:"panel-collapse-btn",title:g("collapsePanel"),onClick:y,children:e.jsx(wn,{})}),e.jsxs("div",{className:"panel-crumbs",children:[e.jsx("button",{type:"button",className:`crumb ${x===""?"active":""}`,onClick:()=>z(""),children:g("rootDir")}),e.jsx("button",{type:"button",className:`crumb ${x===gt?"active":""}`,title:g("computer"),onClick:()=>z(gt),children:"💻"}),D.map(d=>e.jsxs("span",{className:"crumb-seg",children:[e.jsx(Pt,{}),e.jsx("button",{type:"button",className:`crumb ${d.path===x?"active":""}`,onClick:()=>z(d.path),children:d.label})]},d.path))]}),e.jsxs("div",{ref:P,className:"panel-body",onContextMenu:d=>U(d,x),onDragOver:d=>{k(d)&&(d.preventDefault(),d.stopPropagation(),d.dataTransfer.dropEffect="copy",M(),Z(G(d.target)))},onDragLeave:d=>{d.relatedTarget&&d.currentTarget.contains(d.relatedTarget)||B()},onDrop:d=>{var h;if(B(),!k(d))return;d.preventDefault(),d.stopPropagation(),M();const w=Array.from(((h=d.dataTransfer)==null?void 0:h.files)??[]);if(w.length===0){u("warning",g("foldersNotSupported"));return}Y(G(d.target),w)},onDragEnd:B,children:[e.jsx("input",{ref:X,type:"file",multiple:!0,hidden:!0,onChange:T}),H&&e.jsx("div",{className:"panel-empty",children:g("loading")}),!H&&s&&s.path===x&&e.jsxs(e.Fragment,{children:[s.parent!=null&&e.jsxs("button",{type:"button",className:"file-item dir",onClick:v,children:[e.jsx(Je,{className:"file-icon"}),e.jsx("span",{className:"file-name",children:".."})]}),s.entries.map(d=>d.type==="dir"?e.jsxs("div",{className:"file-item dir","data-type":"dir","data-path":d.path,onContextMenu:w=>{w.stopPropagation(),U(w,d.path)},children:[e.jsxs("button",{type:"button",className:"file-dir-main",onClick:()=>ne(d.path),children:[e.jsx(Je,{className:"file-icon"}),e.jsx("span",{className:"file-name",children:d.name})]}),e.jsx("button",{type:"button",className:"file-attach ref","data-tip":g("linkFolderTip"),onClick:()=>a(d.path,d.name,"reference",!0),children:e.jsx(Gt,{})})]},d.path):e.jsxs("div",{className:"file-item file","data-type":"file","data-path":d.path,onContextMenu:w=>{w.stopPropagation(),U(w,x)},children:[e.jsxs("button",{type:"button",className:"file-name",title:`${d.path} — ${g("previewFile")}`,onClick:()=>o(d.path,d.name),children:[e.jsx(Vi,{className:"file-icon"}),e.jsx("span",{className:"file-name-text",children:d.name})]}),e.jsx("button",{type:"button",className:"file-attach download","data-tip":g("downloadFile"),onClick:()=>{Ka(d.path,d.name).then(w=>{w.ok||w.cancelled||u("error",g("downloadFailed",{error:w.error===_n?g("fileNotFoundShort"):w.error}))})},children:e.jsx(ls,{})}),e.jsx("button",{type:"button",className:"file-attach inline","data-tip":g("attachInlineTip"),onClick:()=>a(d.path,d.name,"inline"),children:e.jsx(He,{})}),e.jsx("button",{type:"button",className:"file-attach ref","data-tip":g("referenceTip"),onClick:()=>a(d.path,d.name,"reference"),children:e.jsx(Gt,{})})]},d.path)),s.truncated&&e.jsx("div",{className:"panel-empty files-truncated",children:g("filesTruncated")})]}),!H&&!s&&e.jsx("div",{className:"panel-empty",children:g("noFiles")})]}),r.filter(d=>d.lines.length>0).length>0&&e.jsx("div",{className:"panel-widgets",children:r.filter(d=>d.lines.length>0).map(d=>e.jsxs("div",{className:"widget",children:[e.jsxs("button",{type:"button",className:"widget-title widget-title-btn",title:g("widgetExpand"),onClick:()=>A(d.key),children:[e.jsx("span",{children:d.key}),e.jsx(Oi,{})]}),e.jsx("pre",{className:"widget-lines",children:d.lines.join(`
|
|
306
|
+
`)})]},d.key))}),E&&(()=>{const d=r.find(w=>w.key===E);return d?e.jsx("div",{className:"modal-backdrop",onClick:()=>A(null),children:e.jsxs("div",{className:"widget-expand",onClick:w=>w.stopPropagation(),children:[e.jsxs("div",{className:"widget-expand-head",children:[e.jsx("span",{className:"widget-expand-title",children:d.key}),e.jsx("button",{type:"button",className:"btn",title:g("close"),onClick:()=>A(null),children:e.jsx(Pe,{})})]}),e.jsx("pre",{className:"widget-expand-lines",children:d.lines.join(`
|
|
307
|
+
`)})]})}):null})(),j&&e.jsx("div",{className:"ctx-menu",style:{left:j.x,top:j.y},onContextMenu:d=>{d.preventDefault(),d.stopPropagation()},children:e.jsxs("button",{type:"button",className:"ctx-item",onClick:q,children:[e.jsx(Ri,{}),Q.current===x?g("uploadToCurrentDir"):g("uploadToFolder")]})})]})});var qa=hn();const Tt=l.memo(function({text:s}){const n=xe(),[r,c]=l.useState(!1);return s?e.jsx("button",{type:"button",className:"copy-btn",title:n("copy"),onClick:()=>{navigator.clipboard.writeText(s).then(()=>{c(!0),setTimeout(()=>c(!1),1200)})},children:r?e.jsx(pt,{}):e.jsx(jn,{})}):null});function za(t){const s=r=>{var c;if(typeof r=="string"||typeof r=="number"){const i=String(r);return i===""?[[]]:i.split(`
|
|
308
|
+
`).map(a=>a===""?[]:[a])}if(Array.isArray(r)){let i=[];for(const a of r){const o=s(a);if(i.length===0)i=o;else{const u=o[0]??[];i[i.length-1].push(...u),i.push(...o.slice(1))}}return i}if(r&&typeof r=="object"&&"props"in r){const i=r,a=(c=i.props)==null?void 0:c.children,o={...i.props,children:void 0},u=a==null?[]:s(a);return u.length===0?[[l.createElement(i.type,o)]]:u.map(m=>[l.createElement(i.type,o,...m)])}return[[r]]},n=s(t);return n.length>1&&n[n.length-1].length===0&&n.pop(),n}function Va(t){return typeof t=="string"&&/(^|\s)language-mermaid(\s|$)/.test(t)}function ts(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(ts).join("");if(t&&typeof t=="object"&&"props"in t){const s=t.props;return ts(s==null?void 0:s.children)}return""}function Ga(t){const s=Array.isArray(t)?t[0]:t;return!s||typeof s!="object"||!("props"in s)?null:s}function Qa(t){var y,g;const s=t.match(/<svg\b([^>]*)>/i);if(!s)return t;const n=s[1],r=(y=n.match(/\bviewBox=(['"])([^'"]+)\1/i))==null?void 0:y[2];if(!r)return t;const c=r.trim().split(/[\s,]+/).map(Number),i=c.length===4?c[2]:Number.NaN;if(!Number.isFinite(i)||i<=0)return t;const o=(((g=n.match(/\sstyle=(['"])(.*?)\1/i))==null?void 0:g[2])??"").replace(/(?:^|;)\s*(?:max-)?width\s*:[^;]*/gi,"").replace(/^\s*;|;\s*$/g,""),u=n.replace(/\swidth=(['"])[^'"]*\1/i,"").replace(/\sstyle=(['"])(.*?)\1/i,""),m=o?`${o}; max-width:none`:"max-width:none";return t.replace(s[0],`<svg${u} width="${i}" style="${m}">`)}function Bn(t){var n;const s=Ga(t);return s!==null&&Va((n=s.props)==null?void 0:n.className)}let Ht=null;function Ya(){return Ht||(Ht=gn(()=>import("./mermaid.core-BI5_3AOv.js").then(t=>t.cb),__vite__mapDeps([0,1])).then(t=>{const s=t.default;return s.initialize({startOnLoad:!1,securityLevel:"strict",theme:"base",themeVariables:{background:"#ffffff",primaryColor:"#f1edfe",primaryTextColor:"#1f2430",primaryBorderColor:"#8b5cf6",lineColor:"#6b7280",secondaryColor:"#eef2ff",tertiaryColor:"#f8fafc",textColor:"#1f2430",fontFamily:"var(--mono, monospace)"}}),s})),Ht}let Ja=0;function Xa({code:t}){const s=xe(),n=l.useId().replace(/[^a-zA-Z0-9]/g,""),[r,c]=l.useState(null),[i,a]=l.useState(null);return l.useEffect(()=>{let o=!1;c(null),a(null);const u=`mermaid-${n}-${++Ja}`,m=document.createElement("div");m.style.position="absolute",m.style.left="-99999px",m.style.width="1000px",m.dataset.mermaidRender=u,document.body.appendChild(m);const y=()=>{var g;return(g=document.querySelector(`[data-mermaid-render="${u}"]`))==null?void 0:g.remove()};return Ya().then(g=>g.render(u,t,m)).then(({svg:g})=>{y(),o||c(Qa(g))}).catch(g=>{y(),!o&&a(g instanceof Error?g.message:String(g))}),()=>{o=!0,y()}},[t,n]),i?e.jsxs("div",{className:"mermaid-block mermaid-block-error",children:[e.jsx("div",{className:"mermaid-note",children:s("mermaidRenderFailed")}),e.jsxs("div",{className:"codeblock",children:[e.jsx(Tt,{text:t}),e.jsx("pre",{children:e.jsx("code",{children:t})})]})]}):r?e.jsxs("div",{className:"mermaid-block",children:[e.jsx(Tt,{text:t}),e.jsx("div",{className:"mermaid-svg",dangerouslySetInnerHTML:{__html:r}})]}):e.jsx("div",{className:"mermaid-block mermaid-block-loading",children:e.jsx("div",{className:"mermaid-note",children:s("mermaidRendering")})})}function Za(t){return Bn(t)?ts(t):null}const Fn="pi-web-ui:mermaid-render",Et={enabled:!0};function $n(t){if(!t||typeof t!="object")return{...Et};const s=t;return{enabled:typeof s.enabled=="boolean"?s.enabled:Et.enabled}}function er(){try{const t=localStorage.getItem(Fn);return t?$n(JSON.parse(t)):{...Et}}catch{return{...Et}}}function tr(t){const s=$n(t);try{localStorage.setItem(Fn,JSON.stringify(s))}catch{}vt=s;for(const n of ss)n()}let vt=null;const ss=new Set;function sr(t){return ss.add(t),()=>{ss.delete(t)}}function nr(){return vt||(vt=er()),vt.enabled}function Hn(){return l.useSyncExternalStore(sr,nr)}const ir=[xi],ar=[[fi,{detect:!0,ignoreMissing:!0}]];function cs({text:t}){return e.jsx(gi,{remarkPlugins:ir,rehypePlugins:ar,components:{pre:rr},children:t})}const Rt=l.memo(function({text:s}){return e.jsx("div",{className:"md",children:e.jsx(cs,{text:s})})});function rr({children:t,...s}){var o;if(Hn()&&Bn(t))return e.jsx(Xa,{code:Za(t)});const r=t&&typeof t=="object"&&"props"in t?(o=t.props)==null?void 0:o.children:t,c=za(r),i=c.length>1,a=i?`${String(c.length).length+1}ch`:void 0;return e.jsxs("div",{className:"codeblock",children:[e.jsx(Tt,{text:ns(t)}),e.jsx("pre",{...s,children:c.map((u,m)=>e.jsxs("div",{className:"code-line",children:[i&&e.jsx("span",{className:"code-num",style:a?{width:a}:void 0,children:m+1}),e.jsx("code",{className:"code-line-body hljs",children:u})]},m))})]})}function ns(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(ns).join("");if(t&&typeof t=="object"&&"props"in t){const s=t.props;return ns(s==null?void 0:s.children)}return""}const lr=/^\s{0,3}(`{3,}|~{3,})/,or=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function Ot(t){return t.trim()===""}function Gs(t){const s=lr.exec(t);return s?s[1]:null}function cr(t){const s=t.split(`
|
|
309
|
+
`),n=[];let r=[],c=null;for(let i=0;i<s.length;i++){const a=s[i];if(c!==null){const u=Gs(a);u&&u[0]===c[0]&&u.length>=c.length&&(c=null),r.push(a);continue}const o=Gs(a);if(o&&!Ot(a)){c=o,r.push(a);continue}if(Ot(a)){let u=i;for(;u<s.length&&Ot(s[u]);)u++;if(!(u<s.length&&or.test(s[u]))&&r.length>0){n.push(r.join(`
|
|
310
310
|
`)),r=[];continue}r.push(a);continue}r.push(a)}return{frozen:n,active:r.join(`
|
|
311
|
-
`),inFence:c!==null}}const
|
|
312
|
-
`)[0].slice(0,80);return e.jsxs("div",{className:`thinking ${u?"open":""} ${s?"live":""}`,children:[e.jsxs("button",{type:"button",className:"thinking-toggle",onClick:()=>a(!o),children:[u?e.jsx(Ge,{}):e.jsx(Pt,{}),e.jsx(lt,{className:"thinking-icon"}),e.jsx("span",{className:"thinking-label",children:s&&u?e.jsxs("span",{className:"thinking-live-label",children:[c("thinkingNow"),e.jsx("span",{className:"dots"})]}):u?c("thinking"):c("thinkingPreview",{preview:m})})]}),u&&e.jsx("div",{className:"thinking-body",children:t})]})}const
|
|
313
|
-
`),
|
|
314
|
-
`).join(" ").trim(),
|
|
315
|
-
`)),
|
|
316
|
-
`).length+1)),onChange:h=>
|
|
317
|
-
`),x=
|
|
318
|
-
`).length;return e.jsxs("div",{className:`attachcard ${m?"reference":""}`,children:[e.jsxs("button",{type:"button",className:"attachcard-head",onClick:()=>c(
|
|
319
|
-
`)}function
|
|
320
|
-
`)}function Fr(t,s){let n=0,r=t.indexOf(s);for(;r!==-1;)n++,r=t.indexOf(s,r+s.length);return n}function $r(t,s,n,r){const c=new Map,i=n.toLowerCase();if(!i)return c;for(const a of t){if(!s.has(a.id))continue;const o=Fr(Br(a,r).toLowerCase(),i);o>0&&c.set(a.id,o)}return c}function Hr(t,s){var i;const n=[],r=s.toLowerCase();if(!r)return n;const c=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(a){const o=a.parentElement;return!o||o.closest(".search-bar")||o.closest(".msg-collapsed")?NodeFilter.FILTER_REJECT:(a.textContent??"").toLowerCase().includes(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let a=c.nextNode();a;a=c.nextNode()){const o=(a.textContent??"").toLowerCase();if(!((i=a.parentElement)!=null&&i.closest("[data-msg-id]")))continue;let u=o.indexOf(r);for(;u!==-1;){const m=document.createRange();m.setStart(a,u),m.setEnd(a,u+r.length),n.push(m),u=o.indexOf(r,u+r.length)}}return n}function Or(t,s,n,r,c){var u;const i=$r(n,r,s,c),a=new Map;for(const m of Hr(t,s)){const y=(u=m.startContainer.parentElement)==null?void 0:u.closest("[data-msg-id]");if(!(y!=null&&y.dataset.msgId))continue;const g=a.get(y.dataset.msgId);g?g.push(m):a.set(y.dataset.msgId,[m])}const o=[];for(const m of n){const y=a.get(m.id);if(y)for(let x=0;x<y.length;x++)o.push({kind:"dom",range:y[x],msgId:m.id,k:x});const g=i.get(m.id);if(g)for(let x=0;x<g;x++)o.push({kind:"folded",msgId:m.id,k:x})}return o}function Kt(t,s){return t.findIndex(n=>n.msgId===s.msgId&&n.k===s.k)}function $e(t,s){const n=CSS;if(!n.highlights)return;if(s.length===0){n.highlights.delete(t);return}const r=window.Highlight;r&&n.highlights.set(t,new r(...s))}function Kr(t,s){const n=[];let r=t;for(;r&&r!==s;){const c=getComputedStyle(r);/(auto|scroll|hidden)/.test(c.overflowY+c.overflowX)&&(r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth)&&n.push(r),r=r.parentElement}return n}function Wr(t,s){const n=s.startContainer.parentElement;for(const o of Kr(n,t)){const u=s.getBoundingClientRect(),m=o.getBoundingClientRect();if(u.height<=0||u.width<=0)return;u.top>=m.top+4&&u.bottom<=m.bottom-4||(o.scrollTop+=u.top-m.top-(o.clientHeight-u.height)/2),u.left>=m.left+4&&u.right<=m.right-4||(o.scrollLeft+=u.left-m.left-(o.clientWidth-u.width)/2)}const r=s.getBoundingClientRect(),c=t.getBoundingClientRect();if(r.height<=0||r.width<=0)return;const i=r.top>=c.top+6&&r.bottom<=c.bottom-6,a=r.left>=c.left+6&&r.right<=c.right-6;i&&a||(i||(t.scrollTop+=r.top-c.top-(c.height-r.height)/2),a||(t.scrollLeft+=r.left-c.left-(c.width-r.width)/2))}function Ur({containerRef:t,messages:s,collapsedIds:n,toolResults:r,onExpand:c,onProgrammaticScroll:i,open:a,onClose:o}){const u=xe(),m=l.useRef(null),[y,g]=l.useState(""),[x,b]=l.useState(null),[T,D]=l.useState(0),[,K]=l.useState(0),S=l.useDeferredValue(y),j=a?S.trim():"",Q=l.useRef(null);Q.current=x;const G=l.useRef([]),J=l.useRef({key:null}),U=l.useRef("");l.useEffect(()=>{a&&(b(null),requestAnimationFrame(()=>{var k;return(k=m.current)==null?void 0:k.select()}))},[a]),l.useEffect(()=>{if(!a)return;const k=_=>{_.key==="Escape"&&(_.preventDefault(),_.stopPropagation(),o())};return window.addEventListener("keydown",k,!0),()=>window.removeEventListener("keydown",k,!0)},[a,o]),l.useEffect(()=>(a||($e("msg-search",[]),$e("msg-search-active",[])),()=>{$e("msg-search",[]),$e("msg-search-active",[])}),[a]),l.useLayoutEffect(()=>{const k=()=>{D(0),b(null),K(0),G.current=[],$e("msg-search",[]),$e("msg-search-active",[]),J.current={key:null},U.current=""};if(!a||!j){k();return}const _=t.current;if(!_)return;let F=!1,Z=0;return Z=requestAnimationFrame(()=>{var ne,v;if(F)return;const $=Or(_,j,s,n,r);G.current=$;const X=$.length;if(D(X),X===0){b(null),K(0),$e("msg-search",[]),$e("msg-search-active",[]),J.current={key:null},U.current=j;return}const Y=Q.current;let M;if(Y){if(M=Kt($,Y),M===-1){const L=[];for(let d=0;d<$.length;d++)$[d].msgId===Y.msgId&&L.push(d);if(L.length>0){const d=Math.min(Y.k,L.length-1);M=L[d]}else M=0}}else M=0;M<0&&(M=0),M>=X&&(M=X-1),(!Y||Y.msgId!==$[M].msgId||Y.k!==$[M].k)&&b({msgId:$[M].msgId,k:$[M].k}),K(M);const R=$[M],C=J.current,O=((ne=C.key)==null?void 0:ne.msgId)!==R.msgId||((v=C.key)==null?void 0:v.k)!==R.k||C.kind==="folded"&&R.kind==="dom"||j!==U.current;J.current={key:{msgId:R.msgId,k:R.k},kind:R.kind},U.current=j;const z=$.filter(L=>L.kind==="dom").map(L=>L.range);if($e("msg-search",z),R.kind==="folded"){$e("msg-search-active",[]),O&&c(R.msgId);return}$e("msg-search-active",[R.range]),O&&(i==null||i(),Wr(_,R.range))}),()=>{F=!0,cancelAnimationFrame(Z)}},[a,j,s,t,x,n,r,c,i]);const E=l.useCallback(k=>{const _=G.current,F=_.length;if(F===0)return;const Z=Q.current,$=Z?Kt(_,Z):0,X=_[($+k+F)%F];b(X.kind==="dom"||X.kind==="folded"?{msgId:X.msgId,k:X.k}:null)},[]);if(!a)return null;const H=x?(()=>{const k=Kt(G.current,x);return k===-1?0:k})():0;return e.jsxs("div",{className:"search-bar",role:"search",children:[e.jsx("input",{ref:m,className:"search-input",type:"text",value:y,placeholder:u("searchPlaceholder"),onChange:k=>{g(k.target.value)},onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),E(k.shiftKey?-1:1))}}),e.jsx("span",{className:`search-count ${T===0?"empty":""}`,children:T===0?u("searchNoResults"):`${Math.min(H+1,T)}/${T}`}),e.jsx("button",{type:"button",className:"search-btn",title:u("searchPrev"),disabled:T===0,onClick:()=>E(-1),children:e.jsx(ut,{})}),e.jsx("button",{type:"button",className:"search-btn",title:u("searchNext"),disabled:T===0,onClick:()=>E(1),children:e.jsx(Ge,{})}),e.jsx("button",{type:"button",className:"search-btn",title:u("searchClose"),onClick:o,children:e.jsx(Pe,{})})]})}function qr(t){const{dSt:s,dSh:n,escaped:r,graceActive:c,stuck:i}=t;return c?{flipEscape:!1,reassert:!1}:s>=-4||s<=-500?{flipEscape:!1,reassert:!1}:n<0?{flipEscape:!1,reassert:i&&!r}:{flipEscape:!0,reassert:!1}}const Vn=[{id:"setup-matt-pocock-skills",icon:"🛠",titleKey:"tpl.sk.setup",descKey:"tpl.sk.setup.desc",promptKey:"tpl.sk.setup.prompt"},{id:"ask-matt",icon:"🧭",titleKey:"tpl.sk.ask",descKey:"tpl.sk.ask.desc",promptKey:"tpl.sk.ask.prompt"},{id:"grill-with-docs",icon:"🗣",titleKey:"tpl.sk.grilldocs",descKey:"tpl.sk.grilldocs.desc",promptKey:"tpl.sk.grilldocs.prompt"},{id:"to-spec",icon:"📝",titleKey:"tpl.sk.tospec",descKey:"tpl.sk.tospec.desc",promptKey:"tpl.sk.tospec.prompt"},{id:"to-tickets",icon:"🎫",titleKey:"tpl.sk.totickets",descKey:"tpl.sk.totickets.desc",promptKey:"tpl.sk.totickets.prompt"},{id:"implement",icon:"🏗",titleKey:"tpl.sk.implement",descKey:"tpl.sk.implement.desc",promptKey:"tpl.sk.implement.prompt"},{id:"code-review",icon:"🧹",titleKey:"tpl.sk.codeview",descKey:"tpl.sk.codeview.desc",promptKey:"tpl.sk.codeview.prompt"},{id:"wayfinder",icon:"🗺",titleKey:"tpl.sk.wayfinder",descKey:"tpl.sk.wayfinder.desc",promptKey:"tpl.sk.wayfinder.prompt"},{id:"prototype",icon:"🔬",titleKey:"tpl.sk.prototype",descKey:"tpl.sk.prototype.desc",promptKey:"tpl.sk.prototype.prompt"},{id:"research",icon:"📚",titleKey:"tpl.sk.research",descKey:"tpl.sk.research.desc",promptKey:"tpl.sk.research.prompt"},{id:"improve-codebase-architecture",icon:"🏛",titleKey:"tpl.sk.arch",descKey:"tpl.sk.arch.desc",promptKey:"tpl.sk.arch.prompt"},{id:"diagnosing-bugs",icon:"🐛",titleKey:"tpl.sk.debug",descKey:"tpl.sk.debug.desc",promptKey:"tpl.sk.debug.prompt"},{id:"resolving-merge-conflicts",icon:"🔀",titleKey:"tpl.sk.merge",descKey:"tpl.sk.merge.desc",promptKey:"tpl.sk.merge.prompt"},{id:"triage",icon:"🗂",titleKey:"tpl.sk.triage",descKey:"tpl.sk.triage.desc",promptKey:"tpl.sk.triage.prompt"},{id:"wizard",icon:"✨",titleKey:"tpl.sk.wizard",descKey:"tpl.sk.wizard.desc",promptKey:"tpl.sk.wizard.prompt"},{id:"grill-me",icon:"🔍",titleKey:"tpl.sk.grillme",descKey:"tpl.sk.grillme.desc",promptKey:"tpl.sk.grillme.prompt"},{id:"handoff",icon:"🤝",titleKey:"tpl.sk.handoff",descKey:"tpl.sk.handoff.desc",promptKey:"tpl.sk.handoff.prompt"},{id:"to-questionnaire",icon:"📋",titleKey:"tpl.sk.questionnaire",descKey:"tpl.sk.questionnaire.desc",promptKey:"tpl.sk.questionnaire.prompt"},{id:"teach",icon:"🎓",titleKey:"tpl.sk.teach",descKey:"tpl.sk.teach.desc",promptKey:"tpl.sk.teach.prompt"},{id:"wait-what",icon:"💬",titleKey:"tpl.sk.ww",descKey:"tpl.sk.ww.desc",promptKey:"tpl.sk.ww.prompt"},{id:"writing-for-agents",icon:"📄",titleKey:"tpl.sk.wfa",descKey:"tpl.sk.wfa.desc",promptKey:"tpl.sk.wfa.prompt"},{id:"codebase-design",icon:"🧱",titleKey:"tpl.sk.codesign",descKey:"tpl.sk.codesign.desc",promptKey:"tpl.sk.codesign.prompt"},{id:"domain-modeling",icon:"🏷",titleKey:"tpl.sk.domain",descKey:"tpl.sk.domain.desc",promptKey:"tpl.sk.domain.prompt"},{id:"grilling",icon:"🔥",titleKey:"tpl.sk.grilling",descKey:"tpl.sk.grilling.desc",promptKey:"tpl.sk.grilling.prompt"},{id:"tdd",icon:"🧪",titleKey:"tpl.sk.tdd",descKey:"tpl.sk.tdd.desc",promptKey:"tpl.sk.tdd.prompt"}],Gn="pi-web-ui:prompt-templates";function zr(){try{const t=localStorage.getItem(Gn);if(!t)return[];const s=JSON.parse(t);return Array.isArray(s)?s.filter(n=>!!n&&typeof n=="object"&&typeof n.id=="string"):[]}catch{return[]}}function en(t){return Vn.some(s=>s.id===t)}function ft(t){return typeof t.title=="string"}const Qn=l.createContext(null);function Yn(){const t=l.useContext(Qn);if(!t)throw new Error("useTemplates must be used within TemplateProvider");return t}function Vr({send:t,children:s}){const n=xe(),[r,c]=l.useState(zr),[i,a]=l.useState(!1),[o,u]=l.useState(null),[m,y]=l.useState(!1),[g,x]=l.useState(!1),[b,T]=l.useState(!1);l.useEffect(()=>{try{localStorage.setItem(Gn,JSON.stringify(r))}catch{}},[r]);const D=l.useMemo(()=>{const $=new Map,X=new Set;for(const R of r)R.hidden?X.add(R.id):(ft(R)&&!en(R.id)||ft(R))&&$.set(R.id,R);const Y=Vn.filter(R=>!X.has(R.id)).map(R=>{const C=$.get(R.id);return{id:R.id,icon:(C==null?void 0:C.icon)??R.icon,title:(C==null?void 0:C.title)??n(R.titleKey),desc:(C==null?void 0:C.desc)??n(R.descKey),prompt:(C==null?void 0:C.prompt)??n(R.promptKey),builtin:!0}}),M=r.filter(R=>ft(R)&&!en(R.id)).map(R=>({id:R.id,icon:R.icon??"📌",title:R.title??"",desc:R.desc??"",prompt:R.prompt??""}));return[...Y,...M]},[r,n]),K=l.useCallback(()=>a(!0),[]),S=l.useCallback($=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:$}))},[]),j=l.useCallback(($,X=!1)=>{T(X),$?(y(!1),u({...$})):(y(!0),u({id:Ue(),icon:"📌",title:"",desc:"",prompt:""}))},[]),Q=l.useCallback(()=>{a(!1),u(null),T(!1)},[]),G=l.useCallback(()=>{g?(c([]),x(!1)):(x(!0),setTimeout(()=>x(!1),5e3))},[g]),J=l.useCallback($=>{a(!1),S($.prompt)},[S]),U=l.useCallback($=>{a(!1),j($,!0)},[j]),E=l.useCallback(()=>{a(!1),j(void 0,!0)},[j]),H=l.useCallback($=>{c(X=>{const Y=X.findIndex(M=>M.id===$.id);if(Y>=0){const M=[...X];return M[Y]=$,M}return[...X,$]}),u(null),b&&(a(!0),T(!1))},[b]),k=l.useCallback($=>{c(X=>$.builtin?[...X.filter(M=>M.id!==$.id),{id:$.id,hidden:!0}]:X.filter(Y=>Y.id!==$.id)),u(null),b&&(a(!0),T(!1))},[b]),_=l.useCallback($=>{c(X=>X.filter(Y=>Y.id!==$.id||Y.hidden)),u(null),b&&(a(!0),T(!1))},[b]),F=l.useMemo(()=>({templates:D,fill:S,openPicker:K,openEdit:j,resetConfirm:g,toggleReset:G}),[D,S,K,j,g,G]),Z=o?r.some($=>$.id===o.id&&!$.hidden&&ft($)):!1;return e.jsxs(Qn.Provider,{value:F,children:[s,i&&e.jsx(Qr,{templates:D,resetConfirm:g,onFill:J,onEditTpl:U,onNew:E,onResetToggle:G,onClose:Q}),o&&e.jsx(Yr,{editing:o,isNew:m,hasOverride:Z,onDraft:u,onSave:H,onRestore:()=>_(o),onRemove:()=>k(o),onFill:()=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:o.prompt})),Q()},onSend:()=>{const $=o.prompt.trim();$&&t({type:"prompt",text:$,queue:!1})&&Q()},onClose:Q})]})}function Gr(){const t=xe(),{templates:s,fill:n,openEdit:r,toggleReset:c,resetConfirm:i}=Yn();return e.jsxs("div",{className:"empty-templates",children:[e.jsxs("div",{className:"empty-templates-head",children:[e.jsx("span",{className:"empty-templates-title",children:t("tpl.title")}),e.jsx("span",{className:"empty-templates-hint",children:t("tpl.hint")})]}),e.jsxs("div",{className:"empty-templates-grid",children:[s.map(a=>e.jsx(Jn,{tpl:a,title:t("tpl.clickCard"),onFill:()=>n(a.prompt),onEdit:()=>r(a),editTitle:t("tpl.editTpl")},a.id)),e.jsxs("button",{type:"button",className:"empty-template add",onClick:()=>r(),title:t("tpl.add"),children:[e.jsx("span",{className:"empty-template-icon",children:e.jsx(He,{})}),e.jsxs("span",{className:"empty-template-main",children:[e.jsx("span",{className:"empty-template-title",children:t("tpl.add")}),e.jsx("span",{className:"empty-template-desc",children:t("tpl.addDesc")})]})]})]}),e.jsx("div",{className:"empty-templates-foot",children:e.jsxs("button",{type:"button",className:"empty-templates-reset",onClick:c,children:[e.jsx(kn,{}),t(i?"tpl.resetConfirm":"tpl.reset")]})})]})}function Jn({tpl:t,title:s,onFill:n,onEdit:r,editTitle:c}){const i=xe();return e.jsxs("button",{type:"button",className:"empty-template",title:s,onClick:n,children:[e.jsx("span",{className:"empty-template-icon",children:t.icon}),e.jsxs("span",{className:"empty-template-main",children:[e.jsx("span",{className:"empty-template-title",children:t.title}),e.jsx("span",{className:"empty-template-desc",children:t.desc})]}),e.jsx("span",{className:"template-card-ops",role:"button",title:c??i("tpl.editTpl"),onClick:a=>{a.stopPropagation(),r()},children:e.jsx(St,{})})]})}function Qr({templates:t,resetConfirm:s,onFill:n,onEditTpl:r,onNew:c,onResetToggle:i,onClose:a}){const o=xe();return l.useEffect(()=>{const u=m=>{m.key==="Escape"&&a()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[a]),e.jsx("div",{className:"modal-backdrop",onClick:a,children:e.jsxs("div",{className:"modal template-picker",onClick:u=>u.stopPropagation(),children:[e.jsxs("div",{className:"template-picker-head",children:[e.jsx("span",{className:"template-picker-title",children:o("tpl.pickerTitle")}),e.jsx("button",{type:"button",className:"btn template-modal-close",title:o("close"),onClick:a,children:e.jsx(Pe,{})})]}),e.jsx("div",{className:"template-picker-hint",children:o("tpl.pickerHint")}),e.jsxs("div",{className:"template-picker-grid",children:[t.map(u=>e.jsx(Jn,{tpl:u,title:o("tpl.clickCard"),onFill:()=>n(u),onEdit:()=>r(u),editTitle:o("tpl.editTpl")},u.id)),e.jsxs("button",{type:"button",className:"empty-template add",onClick:c,title:o("tpl.add"),children:[e.jsx("span",{className:"empty-template-icon",children:e.jsx(He,{})}),e.jsxs("span",{className:"empty-template-main",children:[e.jsx("span",{className:"empty-template-title",children:o("tpl.add")}),e.jsx("span",{className:"empty-template-desc",children:o("tpl.addDesc")})]})]})]}),e.jsx("div",{className:"template-picker-foot",children:e.jsxs("button",{type:"button",className:"empty-templates-reset",onClick:i,children:[e.jsx(kn,{}),o(s?"tpl.resetConfirm":"tpl.reset")]})})]})})}function Yr({editing:t,isNew:s,hasOverride:n,onDraft:r,onSave:c,onRestore:i,onRemove:a,onFill:o,onSend:u,onClose:m}){const y=xe(),g=l.useRef(null);l.useEffect(()=>{const T=D=>{D.key==="Escape"&&m()};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[m]),l.useEffect(()=>{const T=g.current;if(!T)return;T.style.height="auto";const D=T.scrollHeight>300;T.style.height=`${Math.min(T.scrollHeight,300)}px`,T.style.overflowY=D?"auto":"hidden"},[t.prompt]);const x=()=>{const T=t.title.trim(),D=t.prompt.trim();if(!T||!D){r({...t,error:y("tpl.required")});return}c({id:t.id,icon:t.icon.trim()||"📌",title:T,desc:t.desc.trim(),prompt:D})},b=!!t.builtin&&!s;return e.jsx("div",{className:"modal-backdrop",onClick:m,children:e.jsxs("div",{className:"modal template-modal",onClick:T=>T.stopPropagation(),children:[e.jsxs("div",{className:"template-modal-head",children:[e.jsx("span",{className:"template-modal-icon",children:t.icon}),e.jsx("span",{className:"template-modal-badge",children:y(b?"tpl.builtin":"tpl.custom")}),e.jsx("span",{className:"template-modal-title",children:y(s?"tpl.newTitle":"tpl.editTitle")}),e.jsx("button",{type:"button",className:"btn template-modal-close",title:y("close"),onClick:m,children:e.jsx(Pe,{})})]}),e.jsxs("label",{className:"template-field",children:[e.jsx("span",{className:"template-field-label",children:y("tpl.fieldIcon")}),e.jsx("input",{className:"template-field-input icon",value:t.icon,maxLength:4,onChange:T=>r({...t,icon:T.target.value})})]}),e.jsxs("label",{className:"template-field",children:[e.jsx("span",{className:"template-field-label",children:y("tpl.fieldTitle")}),e.jsx("input",{className:"template-field-input",value:t.title,placeholder:y("tpl.fieldTitlePh"),onChange:T=>r({...t,title:T.target.value})})]}),e.jsxs("label",{className:"template-field",children:[e.jsx("span",{className:"template-field-label",children:y("tpl.fieldDesc")}),e.jsx("input",{className:"template-field-input",value:t.desc,placeholder:y("tpl.fieldDescPh"),onChange:T=>r({...t,desc:T.target.value})})]}),e.jsxs("label",{className:"template-field",children:[e.jsx("span",{className:"template-field-label",children:y("tpl.fieldPrompt")}),e.jsx("textarea",{ref:g,className:"template-field-prompt",value:t.prompt,placeholder:y("tpl.fieldPromptPh"),onChange:T=>r({...t,prompt:T.target.value})})]}),t.error&&e.jsx("div",{className:"template-error",children:t.error}),e.jsxs("div",{className:"template-modal-actions",children:[e.jsxs("div",{className:"template-modal-actions-left",children:[!s&&b&&n&&e.jsx("button",{type:"button",className:"btn template-btn ghost",title:y("tpl.restoreTip"),onClick:i,children:y("tpl.restore")}),!s&&b&&e.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:y("tpl.removeTip"),onClick:a,children:[e.jsx(Ae,{})," ",y("tpl.remove")]}),!s&&!b&&e.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:y("tpl.deleteTip"),onClick:a,children:[e.jsx(Ae,{})," ",y("tpl.delete")]})]}),e.jsxs("div",{className:"template-modal-actions-right",children:[e.jsx("button",{type:"button",className:"btn template-btn",onClick:x,children:y("tpl.save")}),e.jsx("button",{type:"button",className:"btn template-btn fill",onClick:o,title:y("tpl.fillTip"),children:y("tpl.fill")}),e.jsxs("button",{type:"button",className:"btn template-btn send",onClick:u,title:y("tpl.sendTip"),children:[e.jsx(vn,{})," ",y("tpl.sendNow")]})]})]})]})})}const tn=new Map,Jr=15,sn=30,Wt=250,nn=1200,Xr=1600;function an(t){return t.content.some(s=>s.type==="toolCall")}function Zr({state:t,liveOutputs:s,toolStatuses:n,onEdit:r,onKillBash:c,onRemoveQueued:i,thinkingWrap:a,toolsWrap:o,jumpTarget:u,onJumpDone:m}){const y=xe(),g=l.useRef(null),[x,b]=l.useState(!0),T=l.useRef(!0),D=l.useRef(0),K=l.useRef(0),S=l.useRef(!1),j=l.useRef(0),[Q,G]=l.useState(()=>new Set),[J,U]=l.useState(!1),E=t.streamingMessage?[...t.messages,t.streamingMessage]:t.messages,H=l.useMemo(()=>{const N=new Map;for(const A of t.messages)A.role==="toolResult"&&A.toolCallId&&N.set(A.toolCallId,A);return N},[t.messages]),k=l.useMemo(()=>Sr(t.messages),[t.messages]),_=E.length>0?E[E.length-1].id:null,F=t.messages.length>sn?Math.max(0,t.messages.length-Jr):0,Z=l.useMemo(()=>{const N=new Set;for(let A=0;A<F;A++){const ie=t.messages[A];ie.role!=="toolResult"&&(Q.has(ie.id)||N.add(ie.id))}return N},[t.messages,F,Q]),[$,X]=l.useState(()=>new Set),[Y,M]=l.useState(()=>new Set),R=l.useRef(new Map),C=l.useRef(new Map),O=l.useRef(new Map),z=l.useRef(0),ne=l.useMemo(()=>{const N=new Map;for(const A of t.messages)N.set(A.id,Dr(A));return N},[t.messages]),v=l.useRef(ne);v.current=ne;const L=l.useRef($);L.current=$;const d=t.messages.length>sn&&!J,w=l.useRef(d);w.current=d;const h=Ir(t.messages,R.current,Xr),I=l.useRef(h);I.current=h;const ee=l.useCallback(()=>{const N=g.current;if(!N)return;if(!w.current){X(we=>we.size?new Set:we);return}const A=N.getBoundingClientRect(),ie={top:A.top-nn,bottom:A.bottom+nn},le=[];for(const[we,Te]of O.current){const Oe=Te.getBoundingClientRect();le.push({id:we,top:Oe.top,bottom:Oe.bottom}),L.current.has(we)||ye(we,Oe.bottom-Oe.top,v.current.get(we))}const je=Mr(le,ie,I.current,L.current);for(const we of je.hide){const Te=O.current.get(we);Te&&ye(we,Te.offsetHeight,v.current.get(we))}X(we=>Rr(we,je))},[]),q=l.useCallback(()=>{z.current||(z.current=requestAnimationFrame(()=>{z.current=0,ee()}))},[ee]);l.useLayoutEffect(()=>{ee()},[ee]);const ae=l.useRef(J);l.useLayoutEffect(()=>{ae.current&&!J&&ee(),ae.current=J},[J,ee]);const ye=l.useCallback((N,A,ie)=>{ie!==void 0&&(C.current.set(N,{h:A,len:ie}),R.current.set(N,A))},[]),ke=l.useCallback((N,A)=>{ye(N,A,v.current.get(N))},[ye]),fe=l.useCallback(N=>{N&&O.current.set(N.dataset.lazyId??"",N)},[]);l.useEffect(()=>{const N=new Set(t.messages.map(A=>A.id));for(const A of O.current.keys())N.has(A)||(O.current.delete(A),R.current.delete(A),C.current.delete(A));X(A=>{let ie=!1;const le=new Set;for(const je of A)N.has(je)?le.add(je):ie=!0;return ie?le:A})},[t.messages,Q]),l.useEffect(()=>()=>cancelAnimationFrame(z.current),[]);const be=l.useMemo(()=>{const N=[];for(const A of t.messages){if(A.role!=="user")continue;const ie=A.content.map(we=>{var Te;return((Te=ct(we))==null?void 0:Te.text)??""}).filter(Boolean).join(" "),le=ds(ie),je=le?le.userMessage??`skill:${le.name}`:ie.trim();je&&N.push({id:A.id,text:je})}return N},[t.messages]),Ee=l.useMemo(()=>{const N=new Map;return be.forEach((A,ie)=>N.set(A.id,ie)),N},[be]),[re,f]=l.useState(-1),W=l.useRef(-1),de=l.useRef(be);l.useEffect(()=>{de.current=be},[be]);const ue=l.useCallback(()=>{const N=g.current,A=de.current;if(!N||A.length===0)return;const ie=N.getBoundingClientRect().top,le=140;let je=-1;for(let we=0;we<A.length;we++){const Te=N.querySelector(`[data-msg-id="${A[we].id}"]`);if(Te)if(Te.getBoundingClientRect().top<=ie+le)je=we;else break}je!==W.current&&(W.current=je,f(je))},[]);l.useEffect(()=>{ue()},[be,ue]);const me=l.useCallback(N=>{G(A=>A.has(N)?A:new Set(A).add(N))},[]);l.useEffect(()=>{const N=A=>{if(!(A.ctrlKey||A.metaKey)||A.key.toLowerCase()!=="f")return;const ie=A.target;ie&&(ie.tagName==="INPUT"||ie.tagName==="TEXTAREA"||ie.isContentEditable)||(A.preventDefault(),U(!0))};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[]);const pe=l.useCallback(N=>{G(A=>{if(!A.has(N))return A;const ie=new Set(A);return ie.delete(N),ie})},[]),ve=l.useCallback(N=>{const A=t.messages.findIndex(le=>le.id===N);Ka.flushSync(()=>{A>=0&&A<F&&!Q.has(N)&&me(N),M(le=>le.has(N)?le:new Set(le).add(N))});const ie=de.current.findIndex(le=>le.id===N);W.current=ie,f(ie),requestAnimationFrame(()=>{var je,we,Te;const le=(je=g.current)==null?void 0:je.querySelector(`[data-msg-id="${N}"]`);le&&((we=g.current)==null||we.querySelectorAll(".msg-flash").forEach(Oe=>Oe.classList.remove("msg-flash")),le.scrollIntoView({block:"start"}),le.classList.remove("msg-flash"),le.offsetWidth,le.classList.add("msg-flash"),le!==((Te=g.current)==null?void 0:Te.lastElementChild)&&(S.current=!0))})},[t.messages,F,Q,me]),Me=l.useMemo(()=>{var N;return u?((N=t.messages.find(A=>A.role===u.role&&A.timestamp===u.timestamp))==null?void 0:N.id)??null:null},[t.messages,u]);l.useEffect(()=>{if(u){if(Me){ve(Me),m==null||m();return}t.sessionFile===u.path&&t.messages.length>0&&(m==null||m())}},[Me,ve,m,u,t.sessionFile,t.messages.length]);const he=l.useCallback(()=>{const N=g.current;if(!N)return;const A=N.scrollTop-D.current,ie=N.scrollHeight-K.current;D.current=N.scrollTop,K.current=N.scrollHeight;const le=N.scrollHeight-N.scrollTop-N.clientHeight<80,je=Date.now()<j.current,we=qr({dSt:A,dSh:ie,escaped:S.current,graceActive:je,stuck:T.current});we.reassert&&(j.current=Date.now()+Wt,N.scrollTop=N.scrollHeight),we.flipEscape&&(S.current=!0),le&&A>=0&&(S.current=!1),je||(A<0?T.current=le&&!S.current:le&&(T.current=!0)),b(T.current),ue(),q()},[ue,q]),_e=l.useRef(!1);l.useEffect(()=>{const N=_e.current;if(_e.current=!!t.isStreaming,N&&!t.isStreaming&&!S.current){const A=()=>{const le=g.current;le&&!S.current&&(le.scrollTop=le.scrollHeight,T.current=!0,b(!0))};requestAnimationFrame(()=>requestAnimationFrame(A));const ie=setTimeout(A,180);return()=>clearTimeout(ie)}},[t.isStreaming]),l.useEffect(()=>{const N=g.current;N&&T.current&&(N.scrollTop=N.scrollHeight)},[E,t.isStreaming,s]);const Le=t.queue.steering.join("\0")+""+t.queue.followUp.join("\0");l.useEffect(()=>{const N=g.current;N&&T.current&&(N.scrollTop=N.scrollHeight)},[Le]),l.useEffect(()=>{const N=g.current;if(!N||typeof ResizeObserver>"u")return;const A=new ResizeObserver(()=>{T.current&&!S.current&&(N.scrollTop=N.scrollHeight,b(!0))});return A.observe(N),()=>A.disconnect()},[]),l.useEffect(()=>{const N=g.current;if(!N||typeof MutationObserver>"u")return;let A=!1;const ie=new MutationObserver(()=>{A||(A=!0,requestAnimationFrame(()=>{A=!1;const le=g.current;le&&T.current&&!S.current&&(le.scrollTop=le.scrollHeight,b(!0))}))});return ie.observe(N,{childList:!0,subtree:!0,characterData:!0}),()=>ie.disconnect()},[]);const Be=l.useCallback(()=>{if(!g.current)return;T.current=!0,S.current=!1,b(!0),j.current=Date.now()+Wt;const A=()=>{const ie=g.current;!ie||!T.current||S.current||(j.current=Date.now()+Wt,ie.scrollTop=ie.scrollHeight)};A(),requestAnimationFrame(()=>requestAnimationFrame(A)),setTimeout(A,120),setTimeout(A,300),setTimeout(A,600)},[]),De=l.useRef(null);l.useEffect(()=>{const N=De.current,A=g.current;if(!N||!A)return;const ie=le=>{le.preventDefault();const je=N.querySelector(".qn-list");if(je&&je.contains(le.target)&&je.scrollHeight>je.clientHeight){je.scrollTop+=le.deltaY;return}A.scrollTop+=le.deltaY};return N.addEventListener("wheel",ie,{passive:!1}),()=>N.removeEventListener("wheel",ie)},[]);const[P,ge]=l.useState(0);l.useEffect(()=>{const N=()=>{var A;ge(((A=g.current)==null?void 0:A.clientHeight)??0),q()};return N(),window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[q]);const oe=be.length,p=l.useMemo(()=>oe===0?27:Math.max(4,Math.min(27,Math.floor(((P||600)-16)/oe)-3)),[oe,P]),V=p<20;return e.jsxs("div",{className:"messages-wrap",children:[e.jsxs("div",{className:`messages${J||x?"":" anchor-live"}`,ref:g,onScroll:he,children:[t.messages.length===0&&!t.streamingMessage&&e.jsx("div",{className:"empty-state",children:e.jsx(Gr,{})}),t.messages.map((N,A)=>{const ie=A<F,le=ie&&Q.has(N.id);if(ie&&!le)return N.role==="toolResult"?null:e.jsx(Tr,{message:N,onExpand:me},N.id);const je=N.role==="user"?Ee.get(N.id):void 0,we=!d||h.has(N.id)||Y.has(N.id)||!$.has(N.id);return e.jsx(Pr,{id:N.id,show:we,height:Ar(N.id,ne.get(N.id)??-1,C.current,zn(N.role,N.customType)),containerRef:g,onMeasured:ke,lazyRef:fe,children:e.jsx(Ys,{message:N,qnIndex:je,qnActive:je!==void 0?je===re:void 0,onJump:ve,toolResults:H,liveOutputs:an(N)?s:tn,toolStatuses:n,streaming:t.isStreaming,onKillBash:c,toolsWrap:o,thinkingWrap:a,isLast:N.id===_,onEdit:r,questionAttachments:k.get(N.id),onCollapse:le?pe:void 0,searchActive:J},N.id)},N.id)}),t.streamingMessage&&e.jsx(Ys,{message:t.streamingMessage,toolResults:H,liveOutputs:an(t.streamingMessage)?s:tn,toolStatuses:n,streaming:!0,isLast:!0,onEdit:r,onKillBash:c,toolsWrap:o,thinkingWrap:a,searchActive:J},t.streamingMessage.id),t.isStreaming&&E.length===0&&e.jsx("div",{className:"streaming-wait",children:y("waitingResponse")}),t.queue.steering.map((N,A)=>e.jsx("div",{className:"queued-msg",children:e.jsxs("div",{className:"queued-bubble",children:[e.jsx("span",{className:"queued-tag steer",children:y("queueSteerTag")}),e.jsx("div",{className:"queued-text",children:N}),i&&e.jsx("button",{type:"button",className:"queued-remove",title:y("queueRemoveTip"),onClick:()=>i("steer",N),children:"✕"})]})},`q-steer-${A}`)),t.queue.followUp.map((N,A)=>e.jsx("div",{className:"queued-msg",children:e.jsxs("div",{className:"queued-bubble",children:[e.jsx("span",{className:"queued-tag follow",children:y("queueFollowTag")}),e.jsx("div",{className:"queued-text",children:N}),i&&e.jsx("button",{type:"button",className:"queued-remove",title:y("queueRemoveTip"),onClick:()=>i("followUp",N),children:"✕"})]})},`q-fu-${A}`))]}),!x&&e.jsxs("button",{type:"button",className:"scroll-bottom",onClick:Be,children:[e.jsx(Sn,{})," ",y("backToBottom")]}),e.jsx(Ur,{containerRef:g,messages:E,collapsedIds:Z,toolResults:H,onExpand:me,onProgrammaticScroll:()=>{S.current=!0,T.current=!1,b(!1)},open:J,onClose:()=>U(!1)}),be.length>0&&e.jsxs("div",{className:`qn-rail ${V?"many":""}`,ref:De,"aria-label":y("questionNavTitle"),style:{"--rail-gap":`${p}px`},children:[be.map((N,A)=>e.jsx("button",{type:"button",className:`qn-bar ${A===re?"active":""}`,"aria-label":`${A+1}. ${N.text}`,onClick:()=>ve(N.id),children:e.jsxs("span",{className:"qn-bar-text",children:[A+1,". ",N.text]})},N.id)),V&&e.jsx("div",{className:"qn-list",children:be.map((N,A)=>e.jsxs("button",{type:"button",className:`qn-list-item ${A===re?"active":""}`,"aria-label":`${A+1}. ${N.text}`,onClick:()=>ve(N.id),children:[e.jsx("span",{className:"qn-list-idx",children:A+1}),e.jsx("span",{className:"qn-list-text",children:N.text})]},N.id))})]})]})}const Xn="pi-web-model-usage";function el(t){if(!t||typeof t!="object")return{};const s={};for(const[n,r]of Object.entries(t)){const c=typeof r=="number"?Math.floor(r):0;Number.isFinite(c)&&c>0&&(s[n]=c)}return s}function tl(t,s){return s?{...t,[s]:(t[s]??0)+1}:t}function sl(t,s){const n=s;return t.map((r,c)=>({m:r,i:c,count:n[r.id]??0})).sort((r,c)=>c.count-r.count||r.i-c.i).map(r=>r.m)}function Zn(){try{const t=localStorage.getItem(Xn);return t?el(JSON.parse(t)):{}}catch{return{}}}function nl(t){try{localStorage.setItem(Xn,JSON.stringify(t))}catch{}}function il(t){const s=tl(Zn(),t);return nl(s),s}const us="pi-web-ui:prompt-history",al=100,ei="pi-web-ui:prompt-history-settings",is={maxEntries:100,charLimitEnabled:!1,charLimit:2e3};function ti(t){const s=is;if(!t||typeof t!="object")return{...s};const n=t;let r=typeof n.maxEntries=="number"?Math.floor(n.maxEntries):s.maxEntries;(!Number.isFinite(r)||r<1)&&(r=1),r>500&&(r=500);let c=typeof n.charLimit=="number"?Math.floor(n.charLimit):s.charLimit;(!Number.isFinite(c)||c<100)&&(c=100),c>2e4&&(c=2e4);const i=typeof n.charLimitEnabled=="boolean"?n.charLimitEnabled:s.charLimitEnabled;return{maxEntries:r,charLimitEnabled:i,charLimit:c}}function si(){try{const t=localStorage.getItem(ei);return t?ti(JSON.parse(t)):{...is}}catch{return{...is}}}function Ut(t){const s=ti(t);try{localStorage.setItem(ei,JSON.stringify(s))}catch{}try{let n=dt();s.charLimitEnabled&&(n=n.map(r=>r.length>s.charLimit?r.slice(0,s.charLimit):r)),n.length>s.maxEntries&&(n=n.slice(n.length-s.maxEntries)),ni(n)}catch{}}function rl(t){if(!Array.isArray(t))return[];const s=[];for(const n of t){if(typeof n!="string")continue;const r=n.trim();r&&s.push(r)}return s}function ll(t,s,n=al){const r=s.trim();if(!r||t.length>0&&t[t.length-1]===r)return t;const c=[...t,r];return c.length>n?c.slice(c.length-n):c}function dt(){try{const t=localStorage.getItem(us);return t?rl(JSON.parse(t)):[]}catch{return[]}}function ni(t){let s=t;for(;s;)try{localStorage.setItem(us,JSON.stringify(s));return}catch(n){if(!(n instanceof DOMException&&(n.name==="QuotaExceededError"||n.code===22))||s.length<=1)return;s=s.slice(Math.ceil(s.length/2))}}function ol(t){let s=t.trim();if(!s)return;const n=si();n.charLimitEnabled&&s.length>n.charLimit&&(s=s.slice(0,n.charLimit));const r=dt(),c=ll(r,s,n.maxEntries);c!==r&&ni(c)}function cl(){try{localStorage.removeItem(us)}catch{}}const dl=["off","minimal","low","medium","high","xhigh","max"],ul=l.memo(function({state:s,models:n,modelsLoading:r,send:c,onManageModels:i,providerKeys:a,compact:o=!1}){const u=xe(),m=s==null?void 0:s.model,y=m?`${m.provider}/${m.id}`:null,[g,x]=l.useState(!1),[b,T]=l.useState(!1),[D,K]=l.useState(""),[S,j]=l.useState(null),[Q,G]=l.useState({}),J=l.useRef(null),U=l.useRef(null),[E,H]=l.useState(null);l.useEffect(()=>{if(!g){H(null);return}if(n.length===0)return;const C=requestAnimationFrame(()=>{const O=U.current;O&&H(O.offsetWidth)});return()=>cancelAnimationFrame(C)},[g,n.length]),l.useEffect(()=>{g&&G(Zn())},[g]),l.useEffect(()=>{g||(K(""),j(null))},[g]);const k=l.useMemo(()=>{const C=new Map;for(const z of n)C.set(z.provider,(C.get(z.provider)??0)+1);const O=[];for(const[z,ne]of[...C.entries()].sort((v,L)=>v[0].localeCompare(L[0]))){const v=a[z];if(v&&v.length>1)for(const L of v)O.push({provider:z,keyName:L.name,count:ne});else O.push({provider:z,keyName:null,count:ne})}return O},[n,a]),_=l.useMemo(()=>sl(n,Q),[n,Q]),F=l.useMemo(()=>{let C=_;S&&(C=C.filter(z=>z.provider===S.provider));const O=D.trim().toLowerCase();return O?C.filter(z=>z.name.toLowerCase().includes(O)||z.provider.toLowerCase().includes(O)||z.id.toLowerCase().includes(O)):C},[_,D,S]),Z=l.useMemo(()=>{const C=[];for(const O of F){const z=a[O.provider];if(!z||z.length<=1){C.push({model:O,key:null});continue}let ne=z.find(v=>v.active)??z[0];if((S==null?void 0:S.provider)===O.provider&&S.keyName){const v=z.find(L=>L.name===S.keyName);v&&(ne=v)}C.push({model:O,key:ne})}return C},[F,a,S]),[$,X]=l.useState(!1),Y=s!=null&&s.availableThinkingLevels&&s.availableThinkingLevels.length>0?new Set(s.availableThinkingLevels):null,M=dl.map(C=>({value:C,label:u(`thinking.${C}`),supported:Y?Y.has(C):!0})),R=C=>{var O;return((O=M.find(z=>z.value===C))==null?void 0:O.label)??C};return l.useEffect(()=>{g&&n.length===0&&!$&&!r&&(X(!0),c({type:"list_models"}))},[g,n.length,$,r,c]),l.useEffect(()=>{n.length>0&&X(!1)},[n.length]),l.useEffect(()=>{var O;if(!g)return;const C=(O=J.current)==null?void 0:O.querySelector(".dd-item.active");C==null||C.scrollIntoView({block:"nearest"})},[g,y,n.length]),e.jsxs(e.Fragment,{children:[e.jsxs(ze,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(lt,{}),e.jsx("span",{className:"chip-model",children:m?m.name:u("selectModel")}),!o&&(m==null?void 0:m.vision)&&e.jsx("span",{className:"chip-vision",title:u("vision"),children:"🖼"}),!o&&m&&e.jsx("span",{className:"chip-sub",children:m.provider})]}),open:g,onOpenChange:x,menuClassName:"dd-menu-model",menuRef:U,menuStyle:E!=null?{width:E}:void 0,direction:"up",children:[e.jsx("div",{className:"dd-header",children:u("availableModels")}),e.jsxs("div",{className:"dd-search-row",children:[e.jsx(Nt,{}),e.jsx("input",{className:"dd-search",type:"text",placeholder:u("searchModels"),value:D,onChange:C=>K(C.target.value)})]}),e.jsxs("div",{className:"dd-model-body",children:[k.length>1&&e.jsxs("div",{className:"dd-provider-col",children:[e.jsx("div",{className:"dd-provider-head",children:u("providers")}),e.jsx("button",{type:"button",className:`dd-provider-item ${S===null?"active":""}`,onClick:()=>j(null),children:e.jsx("span",{children:u("allProviders")})}),k.map(C=>{const O=(S==null?void 0:S.provider)===C.provider&&(S==null?void 0:S.keyName)===C.keyName;return e.jsxs("button",{type:"button",className:`dd-provider-item ${O?"active":""}`,onClick:()=>j(O?null:{provider:C.provider,keyName:C.keyName}),title:C.keyName?`${C.provider} · ${C.keyName}`:`${C.provider} · ${C.count}`,children:[e.jsxs("span",{className:"dd-provider-txt",children:[e.jsx("span",{className:"dd-provider-name",children:C.provider}),C.keyName&&e.jsx("span",{className:"dd-provider-key",children:C.keyName})]}),e.jsx("span",{className:"dd-provider-count",children:C.count})]},C.keyName?`${C.provider}::${C.keyName}`:C.provider)})]}),e.jsxs("div",{className:"dd-model-scroll",ref:J,children:[($||r)&&e.jsx("div",{className:"dd-loading",children:u("loading")}),n.length===0&&!$&&!r&&e.jsx("div",{className:"dd-loading",children:u("noModels")}),F.length===0&&n.length>0&&e.jsx("div",{className:"dd-loading",children:u("noModelMatches")}),Z.map(C=>{const O=C.model,z=y===O.id&&(!C.key||C.key.active);return e.jsx(Ie,{active:z,onClick:()=>{C.key&&!C.key.active&&c({type:"activate_provider_key",provider:O.provider,keyName:C.key.name}),y!==O.id&&c({type:"set_model",modelId:O.id}),x(!1)},children:e.jsxs("span",{className:"dd-model-cell",children:[e.jsx("span",{className:"dd-model-name",children:O.name}),e.jsxs("span",{className:"dd-model-meta",children:[e.jsx("span",{className:"dd-model-provider",children:O.provider}),C.key&&e.jsxs("span",{className:`dd-model-key ${C.key.active?"active":""}`,children:[C.key.active?"●":"○"," ",C.key.name]}),(Q[O.id]??0)>0&&e.jsx("span",{className:"dd-model-usage",children:u("modelUsedCount",{n:Q[O.id]})}),(O.reasoning||O.vision)&&e.jsxs("span",{className:"dd-model-badges",children:[O.reasoning&&e.jsx("span",{className:"dd-model-badge",children:u("reasoning")}),O.vision&&e.jsx("span",{className:"dd-model-badge",children:u("vision")})]})]})]})},C.key?`${O.id}::${C.key.name}`:O.id)})]})]}),e.jsxs("div",{className:"dd-footer",children:[e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>c({type:"list_models"}),children:u("refreshModels")}),e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>{x(!1),i()},children:u("manageModels")})]})]}),e.jsxs(ze,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(xt,{}),e.jsx("span",{className:"chip-sub",children:u("thinkingChip",{level:s?R(s.thinkingLevel):"—"})})]}),open:b,onOpenChange:T,direction:"up",children:[e.jsx("div",{className:"dd-header",children:u("thinkingLevel")}),M.map(C=>e.jsx(Ie,{active:(s==null?void 0:s.thinkingLevel)===C.value,disabled:!C.supported,title:C.supported?void 0:u("thinkingUnsupported"),onClick:()=>{(s==null?void 0:s.thinkingLevel)!==C.value&&c({type:"set_thinking",level:C.value}),T(!1)},children:C.label},C.value))]})]})}),pl=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,ml=l.memo(function({ready:s,streaming:n,messages:r,slashCommands:c,modelState:i,models:a,modelsLoading:o,send:u,attachments:m,onRemoveAttachment:y,onAddImageFiles:g,onAddLocalFiles:x,onNotice:b,onSent:T,onManageModels:D,providerKeys:K}){const S=xe(),{locale:j}=mt(),{openPicker:Q}=Yn(),G=f=>j==="en"&&f.descriptionEn?f.descriptionEn:f.description??"",J=f=>j==="en"&&f.argumentHintEn?f.argumentHintEn:f.argumentHint??"",[U,E]=l.useState(""),[H,k]=l.useState(!1),[_,F]=l.useState(null),[Z,$]=l.useState(0),[X,Y]=l.useState(!1),[M,R]=l.useState(void 0),C=l.useRef(null),O=l.useRef(null),z=l.useRef(null),ne=l.useRef(-1),v=l.useRef(""),L={builtin:S("slashBuiltin"),extension:S("slashExtension"),prompt:S("slashPrompt"),skill:S("slashSkill"),plugin:S("slashPlugin")},d=f=>{const W=f.match(/^\/([^\s]*)$/);if(W&&s){const de=W[1].toLowerCase(),ue=c.filter(me=>me.name.toLowerCase().startsWith(de));F(ue.length>0?ue:null),$(0)}else F(null)};l.useEffect(()=>{var W;const f=(W=z.current)==null?void 0:W.querySelector(".slash-item.active");f==null||f.scrollIntoView({block:"nearest"})},[Z,_]);const w=f=>{var pe;const W=_??[],de=f??W[Z%Math.max(W.length,1)];if(!de){F(null);return}const ue=U.match(/^\/([^\s]*)([\s\S]*)$/),me=ue?ue[2]:"";E(`/${de.name} ${me}`),F(null),(pe=C.current)==null||pe.focus()},h=async()=>{const W=[...r].reverse().find(ue=>ue.role==="assistant"&&ue.content.some(me=>me.type==="text"&&me.text)),de=W==null?void 0:W.content.filter(ue=>ue.type==="text").map(ue=>ue.text).join(`
|
|
321
|
-
`);if(!de){b("warning",S("slashCopyEmpty"));return}try{await navigator.clipboard.writeText(de),b("info",S("slashCopied"))}catch{b("error",S("slashCopyFailed"))}},
|
|
322
|
-
`),
|
|
323
|
-
`),be=(f=!1)=>{var ue,me,pe,ve,Me;const W=U.trim(),de=m.some(he=>he.imageData||he.fileData);if(!(!ae||!W&&!de)){if(W==="/help"){const he=(me=(ue=C.current)==null?void 0:ue.closest(".inputbox"))==null?void 0:me.getBoundingClientRect();R(he==null?void 0:he.width),Y(!0),E(""),(pe=C.current)==null||pe.focus();return}if(W==="/copy"){E(""),(ve=C.current)==null||ve.focus(),h();return}if(u({type:"prompt",text:W,queue:f,attachments:m.map(he=>he.imageData?{path:"",imageData:he.imageData,mimeType:he.mimeType,name:he.name}:he.fileData?{path:"",fileData:he.fileData,mimeType:he.mimeType,name:he.name,size:he.size}:{path:he.path,mode:he.mode,...he.lines?{lines:he.lines}:{}})})){W&&ol(W),ne.current=-1,v.current="",E(""),T();const he=i==null?void 0:i.model;he&&il(`${he.provider}/${he.id}`),(Me=C.current)==null||Me.focus()}}},Ee=f=>{if(!f.nativeEvent.isComposing){if(_&&_.length>0)switch(f.key){case"ArrowDown":f.preventDefault(),$(W=>(W+1)%_.length);return;case"ArrowUp":f.preventDefault(),$(W=>(W-1+_.length)%_.length);return;case"Tab":case"Enter":f.preventDefault(),w();return;case"Escape":f.preventDefault(),F(null);return}if(f.key==="ArrowUp"||f.key==="ArrowDown"){if(f.ctrlKey||f.metaKey||f.altKey)return;const W=C.current;if(!W)return;const de=f.key==="ArrowUp";if(de&&!ke(W)||!de&&!fe(W)||!de&&ne.current===-1)return;const ue=dt();if(ue.length===0)return;if(f.preventDefault(),de){if(ne.current===-1){v.current=U;const me=ue.length-1;ne.current=me;const pe=ue[me];E(pe),d(pe),requestAnimationFrame(()=>{const ve=C.current;ve&&(ve.selectionStart=ve.selectionEnd=pe.length)})}else if(ne.current>0){const me=ne.current-1;ne.current=me;const pe=ue[me];E(pe),d(pe),requestAnimationFrame(()=>{const ve=C.current;ve&&(ve.selectionStart=ve.selectionEnd=pe.length)})}}else{const me=ne.current+1;if(me<ue.length){ne.current=me;const pe=ue[me];E(pe),d(pe),requestAnimationFrame(()=>{const ve=C.current;ve&&(ve.selectionStart=ve.selectionEnd=pe.length)})}else{ne.current=-1;const pe=v.current;E(pe),d(pe),requestAnimationFrame(()=>{const ve=C.current;ve&&(ve.selectionStart=ve.selectionEnd=pe.length)})}}return}if(f.key==="Escape"&&ne.current!==-1){f.preventDefault();const W=v.current;ne.current=-1,E(W),d(W),requestAnimationFrame(()=>{const de=C.current;de&&(de.selectionStart=de.selectionEnd=W.length)});return}if(f.key==="Enter"){if(pl&&!f.shiftKey&&!(f.ctrlKey||f.metaKey))return;f.shiftKey||(f.preventDefault(),be())}}},re=()=>e.jsx("div",{className:"inputbox-actions",children:n?e.jsxs(e.Fragment,{children:[U.trim()!==""&&e.jsxs("button",{type:"button",className:"btn supplement",title:S("supplementTip"),onClick:()=>be(!0),children:[e.jsx(vn,{})," ",S("supplement")]}),e.jsx("button",{type:"button",className:"btn stop",title:S("stopAgent"),onClick:()=>u({type:"abort"}),children:e.jsx(jt,{})})]}):e.jsx("button",{type:"button",className:"btn send",title:S("sendTip"),disabled:!ae||!U.trim()&&!m.some(f=>f.imageData||f.fileData),onClick:()=>be(),children:e.jsx(Cn,{})})});return e.jsxs("div",{className:`inputbar${H?" drop-active":""}`,onDragOver:f=>{f.preventDefault(),f.stopPropagation(),k(!0)},onDragLeave:f=>{f.currentTarget.contains(f.relatedTarget)||k(!1)},onDrop:f=>{var W;f.preventDefault(),f.stopPropagation(),k(!1),I(((W=f.dataTransfer)==null?void 0:W.files)??null)},children:[H&&e.jsx("div",{className:"drop-overlay",children:e.jsxs("span",{children:["📎 ",S("dropHereToAttach")]})}),m.length>0&&e.jsxs("div",{className:"attach-row",children:[m.map(f=>e.jsxs("span",{className:`attach-chip ${f.imageData?"image":f.fileData?"file":f.mode}`,title:f.imageData?S("attachImage",{name:f.name}):f.fileData?S("attachFile",{name:f.name}):f.isDir?S("folderRef",{path:f.path}):f.mode==="reference"?S("refOnly",{path:f.path}):f.mode==="lines"&&f.lines?S("attachLines",{path:f.path,start:f.lines.start,end:f.lines.end}):S("attachContent",{path:f.path}),children:[f.imageData?"🖼":f.fileData?"📄":f.isDir?"📁":f.mode==="reference"?"🔗":"📎"," ",f.name,f.mode==="lines"&&f.lines&&e.jsxs("span",{className:"attach-range",children:["L",f.lines.start,"-",f.lines.end]}),e.jsx("button",{type:"button",className:"attach-remove",title:S("removeAttachment"),onClick:()=>y(f.key??f.path),children:"×"})]},f.key??`${f.path}|${f.mode}|${f.lines?`${f.lines.start}-${f.lines.end}`:""}`)),e.jsx("span",{className:"attach-hint",children:S("attachHint")})]}),_&&_.length>0&&e.jsxs("div",{className:"slash-menu",role:"listbox",ref:z,"aria-label":S("slashCommands"),children:[e.jsxs("div",{className:"slash-menu-hint",children:[e.jsx("span",{children:S("slashMenuHint")}),e.jsx("span",{className:"slash-menu-close",onClick:()=>F(null),children:"Esc"})]}),_.map((f,W)=>e.jsxs("button",{type:"button",className:`slash-item${W===Z?" active":""}`,onMouseEnter:()=>$(W),onClick:()=>w(f),children:[e.jsxs("span",{className:"slash-name",children:["/",f.name]}),e.jsx("span",{className:`slash-source ${f.source}`,children:L[f.source]}),e.jsxs("span",{className:"slash-desc",children:[G(f),f.argumentHint&&e.jsx("span",{className:"slash-hint",children:J(f)})]})]},f.name))]}),X&&e.jsx("div",{className:"modal-backdrop",onClick:()=>Y(!1),children:e.jsxs("div",{className:"slash-help",style:M?{width:M}:void 0,onClick:f=>f.stopPropagation(),children:[e.jsxs("div",{className:"slash-help-head",children:[e.jsxs("span",{children:["⚡ ",S("slashHelpTitle")]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>Y(!1),children:S("close")})]}),e.jsx("div",{className:"slash-help-body",children:c.length===0?e.jsx("div",{className:"slash-help-empty",children:S("slashLoading")}):c.map(f=>e.jsxs("div",{className:"slash-help-row",children:[e.jsxs("span",{className:"slash-help-cmd",children:["/",f.name]}),e.jsx("span",{className:`slash-source ${f.source}`,children:L[f.source]}),e.jsxs("span",{className:"slash-help-desc",children:[G(f),f.argumentHint&&e.jsx("span",{className:"slash-hint",children:J(f)})]})]},f.name))})]})}),e.jsxs("div",{className:"inputbox",children:[e.jsx("input",{ref:O,type:"file",multiple:!0,hidden:!0,onChange:f=>{I(f.target.files),f.target.value=""}}),e.jsx("textarea",{ref:C,value:U,rows:1,placeholder:S(ae?n?"placeholderStreaming":"placeholderIdle":"placeholderConnecting"),disabled:!ae,onChange:f=>{ne.current=-1,E(f.target.value),d(f.target.value)},onKeyDown:Ee,onPaste:ee}),e.jsxs("div",{className:"composer-tools",children:[e.jsxs("div",{className:"composer-tools-left",children:[e.jsx("button",{type:"button",className:"btn attach-img",title:S("uploadFile"),disabled:!ae,onClick:()=>{var f;return(f=O.current)==null?void 0:f.click()},children:e.jsx(Ai,{})}),e.jsx("button",{type:"button",className:"btn tpl-open",title:S("tpl.openPicker"),onClick:Q,children:e.jsx(Ui,{})}),e.jsx(ul,{state:i,models:a,modelsLoading:o,send:u,onManageModels:D,providerKeys:K,compact:!0})]}),e.jsx("div",{className:"composer-tools-right",children:re()})]})]})]})}),hl=l.memo(function({goal:s,models:n,modelsLoading:r,activeConversationId:c,engine:i,send:a}){var M,R,C,O,z,ne,v;const o=xe(),{locale:u}=mt(),m=u==="en"&&s.statusEn?s.statusEn:s.status||"",y=u==="en"&&((M=s.wizard)!=null&&M.statusEn)?s.wizard.statusEn:((R=s.wizard)==null?void 0:R.status)||"",g=i==="dsh",x=!s.conversationId||s.conversationId===c,b=s.goal!==null&&x,[T,D]=l.useState(""),[K,S]=l.useState(s.reviewModel??""),[j,Q]=l.useState(s.maxRounds),[G,J]=l.useState(s.locked),[U,E]=l.useState(!1),[H,k]=l.useState(!1),[_,F]=l.useState(!0);l.useEffect(()=>{S(s.reviewModel??""),Q(s.maxRounds||0),J(s.locked)},[s.goal,s.reviewModel,s.maxRounds,s.locked]),l.useEffect(()=>{U&&n.length===0&&!H&&!r&&(k(!0),a({type:"list_models"}))},[U,n.length,H,r,a]),l.useEffect(()=>{n.length>0&&k(!1)},[n.length]);const Z=()=>{var L;return K?((L=n.find(d=>d.id===K))==null?void 0:L.name)??K:o("goalBarUseMainModel")},$=()=>{const L=T.trim();L&&(a({type:"set_goal",goal:L,...K?{reviewModel:K}:{},maxRounds:j,locked:G}),D(""),F(!1))},X=()=>{const L=T.trim();L&&(a({type:"start_goal_wizard",text:L,...K?{wizardModel:K}:{},maxRounds:j,locked:G}),D(""),F(!1))},Y=(((C=s.wizard)==null?void 0:C.active)??!1)&&x;return Y?e.jsx("div",{className:`goalbar goalbar-active ${Y?"wizard":""}`,children:e.jsxs("div",{className:"goalbar-active-row",children:[e.jsx("span",{className:"goalbar-icon",children:e.jsx("span",{className:"goalbar-spin",children:"🔍"})}),e.jsxs("span",{className:"goalbar-text",title:((O=s.wizard)==null?void 0:O.draft)??"",children:[o("goalWizardRunning"),": ",(z=s.wizard)==null?void 0:z.draft]}),e.jsxs("span",{className:"goalbar-chip reviewing",children:[o("goalBarRound",{n:(((ne=s.wizard)==null?void 0:ne.step)??0)+1})," / ",((v=s.wizard)==null?void 0:v.maxSteps)??6]}),e.jsx("span",{className:"goalbar-detail",children:y||o("goalBarReviewing")}),e.jsx("button",{type:"button",className:"goalbar-x",title:o("goalBarClear"),onClick:()=>{a({type:"clear_goal"}),F(!0)},children:e.jsx(Pe,{})})]})}):b?e.jsx("div",{className:`goalbar goalbar-active ${s.reviewing?"reviewing":""}`,children:e.jsxs("div",{className:"goalbar-active-row",children:[e.jsx("span",{className:"goalbar-icon",children:s.reviewing?e.jsx("span",{className:"goalbar-spin",children:"◌"}):"🎯"}),e.jsx("span",{className:"goalbar-text",title:s.goal??"",children:s.goal}),s.reviewing?e.jsxs("span",{className:"goalbar-chip reviewing",children:[o("goalBarReviewing")," ",o("goalBarRound",{n:s.round})]}):e.jsx("span",{className:`goalbar-chip ${s.verdict==="pass"?"pass":s.verdict==="fail"?"fail":""}`,children:s.verdict==="pass"?o("goalBarPassed"):s.verdict==="fail"?o("goalBarFailed"):`${o("goalBarRound",{n:s.round||1})} · ${s.locked?o("goalBarLocked"):o("goalBarUnlocked")}`}),e.jsx("span",{className:"goalbar-detail",children:m}),e.jsx("button",{type:"button",className:"goalbar-x",title:o("goalBarClear"),disabled:s.reviewing,onClick:()=>{a({type:"clear_goal"}),F(!0)},children:e.jsx(Pe,{})})]})}):_?e.jsx("div",{className:"goalbar goalbar-collapsed",children:e.jsxs("button",{type:"button",className:"goalbar-hint",title:o("goalBarPlaceholder"),onClick:()=>F(!1),children:[e.jsx(Is,{})," ",e.jsx("span",{children:o("goalBarTitle")})]})}):e.jsxs("div",{className:"goalbar",children:[e.jsxs("div",{className:"goalbar-row",children:[e.jsx("span",{className:"goalbar-icon",children:e.jsx(Is,{})}),e.jsx("input",{className:"goalbar-input",value:T,placeholder:o("goalBarPlaceholder"),onChange:L=>D(L.target.value),onKeyDown:L=>{L.key==="Enter"&&$()}}),e.jsx("button",{type:"button",className:"goalbar-btn",disabled:!T.trim(),onClick:$,children:o("goalBarSet")}),e.jsxs("button",{type:"button",className:"goalbar-btn wizard",disabled:!T.trim(),title:o("goalWizardTip"),onClick:X,children:["🔍 ",o("goalWizardBtn")]}),e.jsx("button",{type:"button",className:"goalbar-icon-btn",title:o(G?"goalBarLocked":"goalBarUnlocked"),onClick:()=>J(L=>(a({type:"set_goal_prefs",locked:!L}),!L)),children:G?e.jsx(Oi,{}):e.jsx(Ri,{})}),e.jsx("button",{type:"button",className:"goalbar-icon-btn",title:o("goalBarClear"),onClick:()=>F(!0),children:e.jsx(ut,{})})]}),e.jsxs("div",{className:"goalbar-opts",children:[g?e.jsx("p",{className:"goalbar-dsh-note",children:o("dshNoReviewModel")}):e.jsxs(ze,{trigger:e.jsxs("span",{className:"goalbar-opt",children:[o("goalBarReviewModel"),": ",e.jsx("b",{children:Z()})]}),open:U,onOpenChange:E,direction:"up",children:[e.jsx("div",{className:"dd-header",children:o("goalBarReviewModel")}),(H||r)&&e.jsx("div",{className:"dd-loading",children:o("loading")}),n.length===0&&!H&&!r&&e.jsx("div",{className:"dd-loading",children:o("noModels")}),e.jsx(Ie,{active:K==="",onClick:()=>{S(""),E(!1),a({type:"set_goal_prefs",reviewModel:""})},children:o("goalBarUseMainModel")}),n.map(L=>e.jsx(Ie,{active:K===L.id,onClick:()=>{S(L.id),E(!1),a({type:"set_goal_prefs",reviewModel:L.id})},children:e.jsxs("span",{className:"dd-model-cell",children:[e.jsx("span",{className:"dd-model-name",children:L.name}),e.jsx("span",{className:"dd-model-meta",children:e.jsx("span",{className:"dd-model-provider",children:L.provider})})]})},L.id)),e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>a({type:"list_models"}),children:o("refreshModels")})]}),e.jsxs("label",{className:"goalbar-round",title:o("goalBarMaxRoundsTip"),children:[e.jsx("span",{children:o("goalBarMaxRounds")}),e.jsx("input",{type:"number",min:0,step:1,value:j,placeholder:o("goalBarUnlimitedShort"),onChange:L=>{const d=parseInt(L.target.value,10);if(Number.isNaN(d)||d<0){Q(0);return}Q(d)},onBlur:()=>a({type:"set_goal_prefs",maxRounds:j}),onKeyDown:L=>{L.key==="Enter"&&(a({type:"set_goal_prefs",maxRounds:j}),L.target.blur())}})]}),e.jsx("span",{className:"goalbar-lock-hint",children:o(G?"goalBarLocked":"goalBarUnlocked")})]})]})});function gl(t){const s=Math.max(0,t.input??0),n=Math.max(0,t.cacheRead??0),r=Math.max(0,t.cacheWrite??0),c=s+n+r;return{totalInput:c,miss:s,read:n,write:r,hitRate:c>0?Math.min(n/c,1):0,writeRate:c>0?Math.min(r/c,1):0}}const ii=2e3;function fl(t,s,n=ii){return t.filter(r=>s-r.t<=n)}function xl(t,s=ii){if(t.length<2)return 0;const n=t[t.length-1],r=t.find(i=>i.t>=n.t-s)??t[0],c=(n.t-r.t)/1e3;return c<=0?0:Math.max(0,(n.out-r.out)/c)}function rn(t){if(!t)return 0;let s=0;for(let r=0;r<t.length;r++){const c=t.charCodeAt(r);(c>=12352&&c<=12543||c>=13312&&c<=19903||c>=19968&&c<=40959||c>=63744&&c<=64255||c>=65280&&c<=65519||c===12288)&&s++}const n=t.length-s;return Math.round(s+n/4)}function yl(t){let s=0;for(const n of t)n.type==="text"&&typeof n.text=="string"&&n.text?s+=rn(n.text):n.type==="thinking"&&typeof n.thinking=="string"&&n.thinking&&(s+=rn(n.thinking));return s}const Qe="@root";function vl({chat:t,send:s}){const n=xe(),r=t.state,[c,i]=l.useState(!1),[a,o]=l.useState(""),[u,m]=l.useState(""),[y,g]=l.useState(!1),[x,b]=l.useState(""),[T,D]=l.useState(-1),K=l.useRef(null),S=l.useRef(null),j=t.pathCompletions.filter(h=>h.type==="dir"),Q=h=>h.endsWith("/")?h:h+"/",G=h=>{let I=h.endsWith("/")&&h!=="/"?h.slice(0,-1):h;if(I===Qe||I==="/")return null;const ee=I.lastIndexOf("/");if(ee<0)return/^[A-Za-z]:$/.test(I)?Qe:null;if(ee===0)return"/";const q=I.slice(0,ee);return/^[A-Za-z]:$/.test(q)?q+"/":q};l.useEffect(()=>{if(!c)return;const h=setTimeout(()=>{s({type:"complete_path",path:Q(a)})},60);return()=>clearTimeout(h)},[a,c,s]),l.useEffect(()=>{if(!c||u===a)return;const h=setTimeout(()=>{s({type:"complete_path",path:u})},150);return()=>clearTimeout(h)},[u,a,c,s]);const J=l.useRef([]),U=(r==null?void 0:r.isStreaming)??!1,E=r!=null&&r.streamingMessage?yl(r.streamingMessage.content):0;if(l.useEffect(()=>{if(!U){J.current=[];return}const h=Date.now(),I=J.current,ee=I[I.length-1];ee&&h-ee.t<250||(J.current=fl([...I,{t:h,out:E}],h))},[U,E]),!r)return null;const H=r.stats,k=gl(H.tokens),_=k.hitRate*100,F=k.totalInput===0?"":k.hitRate>=.7?"ok":k.hitRate>=.4?"mid":"warn",Z=k.totalInput>0?`${_.toFixed(1)}%`:"—",$=U?xl(J.current):0,X=t.ready?"ok":"busy",Y=t.ready?n("connected"):n("connecting"),M=H.contextUsage,R=M.tokens!==null&&M.percent!==null?`${Ze(M.tokens)} / ${Ze(M.contextWindow)}`:"—",C=M.percent??null,O=C===null?"":C>=80?"warn":C>=50?"mid":"ok",z=r.queue.steering.length+r.queue.followUp.length,ne=()=>{m(r.cwd),o(r.cwd),g(!1),b(""),i(!0)},v=h=>{const I=h.trim();I!==Qe&&(I&&I!==r.cwd&&s({type:"set_cwd",path:I}),i(!1))},L=()=>{const h=x.trim();h&&(s({type:"make_dir",path:`${Q(a)}${h}`}),setTimeout(()=>{s({type:"complete_path",path:Q(a)})},80),b(""),g(!1))},d=h=>{if(h.key==="Escape")h.stopPropagation(),i(!1);else if(h.key==="Enter"&&!h.nativeEvent.isComposing)v(u);else if(h.key==="Tab"){if(j.length===0)return;h.preventDefault();const I=T>=0?(T+1)%j.length:0;D(I),m(j[I].path),o(j[I].path)}},w=G(a);return e.jsxs("footer",{className:"statusbar",children:[e.jsx("span",{className:`status-dot ${X}`,title:Y}),e.jsx("span",{className:"status-item",children:Y}),e.jsx("span",{className:"status-sep",children:"·"}),t.engine&&t.engine!=="pi"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`status-item engine-badge engine-${t.engine}`,title:`${n("engineBadge")}: ${t.engine}`,children:t.engine==="dsh"?"DSH":t.engine}),e.jsx("span",{className:"status-sep",children:"·"})]}),e.jsxs("span",{className:"status-item status-ctx",title:n("contextUsage"),children:[n("context"),e.jsx("span",{className:`ctx-bar ${O}`,children:C!==null&&e.jsx("span",{className:"ctx-bar-fill",style:{width:`${Math.min(C,100)}%`}})}),R]}),e.jsx("span",{className:"status-sep",children:"·"}),e.jsxs("span",{className:"status-item",title:n("cumulativeCost"),children:["$",kl(H.cost)]}),e.jsx("span",{className:"status-sep",children:"·"}),e.jsxs("span",{className:"status-item status-cache",title:n("cacheHitTip",{read:Ze(k.read),write:Ze(k.write),miss:Ze(k.miss),input:Ze(k.totalInput)}),children:[n("cacheHit"),e.jsx("b",{className:`cache-pct ${F}`,children:Z})]}),e.jsx("span",{className:"status-sep",children:"·"}),e.jsxs("span",{className:"status-item",title:n("sessionMessages"),children:[n("messages")," ",H.totalMessages]}),t.statuses.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"status-sep",children:"·"}),e.jsx("span",{className:"status-item ext-status",title:n("pluginStatus"),children:t.statuses.map(h=>h.text).join(" · ")})]}),r.isStreaming&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"status-sep",children:"·"}),e.jsxs("span",{className:"status-item working",children:[e.jsx("span",{className:"working-spin"}),n("working"),z>0&&e.jsxs("span",{className:"status-queue",children:["⏳ ",z," ",n("queued")]})]}),e.jsx("span",{className:"status-item status-rate",title:n("rateTip"),children:$>0?`${Math.round($)}${n("tps")}`:"…"})]}),c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"status-cwd-backdrop",onClick:()=>i(!1)}),e.jsxs("div",{className:"cwd-picker",children:[e.jsxs("div",{className:"cwd-picker-head",children:[e.jsxs("span",{className:"cwd-picker-title",title:a===Qe?n("computer"):a,children:[a===Qe?"💻":e.jsx(Je,{}),e.jsx("span",{children:a===Qe?n("computer"):a})]}),e.jsxs("button",{type:"button",className:"cwd-up",disabled:!w,title:n("cwdGoUp"),onClick:()=>{w&&(o(w),m(w),D(-1))},children:["↑ ",n("cwdGoUp")]})]}),e.jsxs("div",{className:"cwd-picker-row",children:[e.jsx("input",{ref:K,className:"status-cwd-input cwd-picker-input",value:u,placeholder:n("enterPath"),spellCheck:!1,onChange:h=>{m(h.target.value),D(-1)},onKeyDown:d}),e.jsx("button",{type:"button",className:"cwd-choose-btn primary",title:n("cwdPickCurrent"),disabled:a===Qe,onClick:()=>v(a),children:n("cwdPickCurrent")})]}),e.jsxs("div",{className:"cwd-list",children:[j.length===0&&e.jsx("div",{className:"cwd-empty",children:n("cwdEmpty")}),j.map(h=>e.jsxs("div",{className:"cwd-item",children:[e.jsxs("button",{type:"button",className:"cwd-enter",title:`${n("cwdEnter")} ${h.path}`,onClick:()=>{o(h.path),m(h.path),D(-1)},children:[e.jsx(Je,{}),e.jsx("span",{className:"cwd-name",children:h.name})]}),e.jsx("button",{type:"button",className:"cwd-choose-btn",title:n("cwdChoose"),onClick:()=>v(h.path),children:n("cwdChoose")})]},h.path))]}),e.jsx("div",{className:"cwd-picker-foot",children:y?e.jsxs("div",{className:"cwd-newrow",children:[e.jsx("input",{ref:S,value:x,autoFocus:!0,spellCheck:!1,placeholder:n("cwdNewName"),onChange:h=>b(h.target.value),onKeyDown:h=>{h.key==="Enter"&&!h.nativeEvent.isComposing?(h.preventDefault(),L()):h.key==="Escape"&&(h.stopPropagation(),g(!1),b(""))}}),e.jsx("button",{type:"button",className:"cwd-choose-btn primary",onClick:L,children:n("cwdCreate")}),e.jsx("button",{type:"button",className:"cwd-choose-btn",onClick:()=>{g(!1),b("")},children:n("cwdCancel")})]}):e.jsxs("button",{type:"button",className:"cwd-newbtn",onClick:()=>g(!0),children:["+ ",n("cwdNewFolder")]})})]})]}):e.jsxs("button",{type:"button",className:"status-item status-cwd",title:n("cwdTip",{path:r.cwd}),onClick:ne,children:["📁 ",r.cwd]})]})}function Ze(t){return t>=1e3?`${(t/1e3).toFixed(1).replace(/\.0$/,"")}K`:String(t)}function kl(t){return t<=0?"0":t<1e-4?"<0.0001":t.toFixed(4).replace(/\.?0+$/,"")}function bl({dialog:t,send:s}){const n=xe(),[r,c]=l.useState(""),[i,a]=l.useState(0),o=y=>{s({type:"dialog_response",id:t.id,value:y})};l.useEffect(()=>{c(""),a(0);const y=g=>{g.key==="Escape"&&o(null)};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[t.id]);const u=Array.isArray(t.args[0])?t.args[0]:[],m=typeof t.args[0]=="string"?t.args[0]:"";return e.jsxs("div",{className:"dialog-inline","data-dialog-kind":t.kind,children:[e.jsxs("div",{className:"dialog-head",children:[e.jsx("span",{className:"dialog-badge",children:n("pluginRequest")}),t.title&&t.title!==n("pluginRequest")&&e.jsx("span",{className:"dialog-title",children:t.title}),e.jsx("button",{type:"button",className:"dialog-dismiss",title:n("cancel"),onClick:()=>o(null),children:"✕"})]}),t.kind==="select"&&e.jsxs("div",{className:"dialog-options",children:[u.map((y,g)=>e.jsx("button",{type:"button",className:`dialog-option ${g===i?"sel":""}`,onMouseEnter:()=>a(g),onClick:()=>o(y),children:y},g)),u.length===0&&e.jsx("div",{className:"dialog-hint",children:n("noOptions")})]}),t.kind==="confirm"&&e.jsxs("div",{className:"dialog-body",children:[e.jsx("p",{children:m}),e.jsxs("div",{className:"dialog-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>o(!1),children:n("cancel")}),e.jsx("button",{type:"button",className:"btn primary",onClick:()=>o(!0),children:n("ok")})]})]}),t.kind==="input"&&e.jsxs("div",{className:"dialog-body",children:[e.jsx("input",{className:"dialog-input",value:r,placeholder:m||n("inputPlaceholder"),autoFocus:!0,onChange:y=>c(y.target.value),onKeyDown:y=>{y.key==="Enter"&&!y.nativeEvent.isComposing&&o(r)}}),e.jsxs("div",{className:"dialog-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>o(null),children:n("cancel")}),e.jsx("button",{type:"button",className:"btn primary",onClick:()=>o(r),children:n("ok")})]})]})]})}function jl({question:t,send:s}){const n=xe(),[r,c]=l.useState({}),[i,a]=l.useState({}),[o,u]=l.useState(()=>t.deadline?Math.max(0,Math.ceil((t.deadline-Date.now())/1e3)):-1);l.useEffect(()=>{c({}),a({}),u(t.deadline?Math.max(0,Math.ceil((t.deadline-Date.now())/1e3)):-1)},[t.id,t.deadline]),l.useEffect(()=>{if(!t.deadline)return;const x=setInterval(()=>{u(b=>{const T=Math.max(0,Math.ceil((t.deadline-Date.now())/1e3));return T<=0&&b>0&&s({type:"question_answer",id:t.id,answers:[],cancelled:!0}),T})},1e3);return()=>clearInterval(x)},[t.id,t.deadline]);const m=x=>{if(x){s({type:"question_answer",id:t.id,answers:[],cancelled:!0});return}const b=t.questions.map(T=>{const D=r[T.id]??[],K=(i[T.id]??"").trim();return{id:T.id,selected:D,...K?{custom:K}:{}}});s({type:"question_answer",id:t.id,answers:b})};l.useEffect(()=>{const x=b=>{b.key==="Escape"&&m(!0)};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[t.id]);const y=(x,b,T)=>{c(D=>{const K=D[x]??[];return T?{...D,[x]:K.includes(b)?K.filter(S=>S!==b):[...K,b]}:{...D,[x]:[b]}})},g=t.questions.every(x=>{var b;return(((b=r[x.id])==null?void 0:b.length)??0)>0||(i[x.id]??"").trim()!==""});return e.jsxs("div",{className:"dialog-inline","data-dialog-kind":"select",children:[e.jsxs("div",{className:"dialog-head",children:[e.jsx("span",{className:"dialog-badge",children:n("modelQuestion")}),o>=0&&e.jsx("span",{className:"question-timer",children:o>0?n("questionTimeout",{s:o}):n("questionTimeoutExpired")}),e.jsx("button",{type:"button",className:"dialog-dismiss",title:n("cancel"),onClick:()=>m(!0),children:"✕"})]}),t.questions.map((x,b)=>{var T;return e.jsxs("div",{className:"set-section",children:[e.jsx("div",{className:"set-section-title",children:x.header??`${n("modelQuestion")} ${b+1}`}),e.jsx("p",{className:"set-row-desc",children:x.question}),x.detail&&e.jsx("p",{className:"set-hint",children:x.detail}),(((T=x.options)==null?void 0:T.length)??0)>0&&e.jsx("div",{className:"set-list",children:x.options.map(D=>{const K=(r[x.id]??[]).includes(D.label);return e.jsxs("button",{type:"button",className:`set-row question-option${K?" active":""}`,onClick:()=>y(x.id,D.label,!!x.multiSelect),children:[e.jsxs("span",{className:"set-row-name",children:[x.multiSelect?K?"☑ ":"☐ ":K?"● ":"○ ",D.label]}),D.description&&e.jsx("span",{className:"set-row-desc",children:D.description})]},D.label)})}),e.jsx("input",{className:"set-prompt-input question-custom",placeholder:n("modelQuestionCustom"),value:i[x.id]??"",onChange:D=>a(K=>({...K,[x.id]:D.target.value}))})]},x.id)}),e.jsxs("div",{className:"dialog-actions",children:[e.jsx("button",{type:"button",className:"dialog-submit",disabled:!g,onClick:()=>m(!1),children:n("modelQuestionSubmit")}),e.jsx("button",{type:"button",className:"dialog-dismiss-inline",onClick:()=>m(!0),children:n("cancel")})]})]})}const ln=t=>`'${t.replace(/'/g,"'\\''")}'`;function wl(t){if(t.x==="?"&&t.y==="?")return"untracked";const s=t.x!==" "&&t.x!=="?",n=t.y!==" "&&t.y!=="?";return s&&n?"both":s?"staged":"unstaged"}function Nl({chat:t,send:s,terminal:n,active:r,onSwitchToTerminal:c}){var Be,De;const i=xe(),[a,o]=l.useState(null),[u,m]=l.useState([]),[y,g]=l.useState(""),[x,b]=l.useState(new Map),[T,D]=l.useState("changes"),[K,S]=l.useState([]),[j,Q]=l.useState(null),[G,J]=l.useState(""),[U,E]=l.useState(!1),[H,k]=l.useState(null),[_,F]=l.useState(null),[Z,$]=l.useState(!1),[X,Y]=l.useState(!1),[M,R]=l.useState(!1),[C,O]=l.useState(null),[z,ne]=l.useState(!1),[v,L]=l.useState(""),d=l.useRef(0),w=l.useRef(-1),h=l.useRef(-1),I=l.useRef(-1),ee=l.useRef(-1),q=l.useRef(void 0),ae=l.useRef(null),ye=l.useRef([]),ke=l.useCallback(P=>{if(P.reqId===w.current){if(w.current=-1,Y(!1),O(null),!P.ok){O(P.error??i("scmQueryFailedShort"));return}if(P.notRepo){ne(!0),o(null),m([]),b(new Map),S([]),Q(null),J(""),F(null);return}ne(!1);const ge={branch:P.branch??"",detached:!!P.detached,upstream:P.upstream??null,ahead:P.ahead??0,behind:P.behind??0,upstreamGone:!!P.upstreamGone,files:(P.files??[]).map(V=>({...V}))},oe=(P.branches??[]).map(V=>({...V})),p=new Map;for(const[V,N]of Object.entries(P.stats??{}))p.set(V,{add:N[0],del:N[1]});o(ge),m(oe),b(p),g(V=>{var N;return ge.detached?V||"":ge.branch&&oe.some(A=>A.name===ge.branch)?ge.branch:V&&oe.some(A=>A.name===V)?V:((N=oe[0])==null?void 0:N.name)??""}),F(V=>V&&!ge.files.some(N=>N.path===V.file.path)?null:V)}else if(P.reqId===h.current){if(h.current=-1,$(!1),!P.ok){O(P.error??i("scmQueryFailedShort"));return}const ge=ae.current;if(!ge)return;F({file:ge,staged:P.stagedText??"",worktree:P.worktreeText??"",untracked:!1})}else if(P.reqId===ee.current){if(ee.current=-1,R(!1),!P.ok){O(P.error??i("scmQueryFailedShort"));return}S((P.history??[]).map(ge=>({...ge})))}else if(P.reqId===I.current){if(I.current=-1,E(!1),!P.ok){O(P.error??i("scmQueryFailedShort"));return}J(P.text??"")}},[]);l.useEffect(()=>{const P=t.scmData;P&&P.type==="scm_data"&&ke(P)},[t.scmData,ke]);const fe=l.useCallback((P,ge)=>{if(!t.ready||t.status!=="open")return!1;const oe=++d.current;return s({...P,reqId:oe})?(ge.current=oe,!0):(d.current-=1,!1)},[t.ready,t.status,s]),be=l.useCallback((P=!1,ge=!1)=>{var oe;!t.ready||t.status!=="open"||(oe=t.state)!=null&&oe.cwd&&(q.current!==void 0&&q.current!==t.state.cwd&&(o(null),m([]),b(new Map),S([]),R(!1),ee.current=-1,Q(null),J(""),F(null),k(null)),q.current=t.state.cwd,O(null),fe({type:"scm_status"},w)&&(ge||Y(!0)))},[t.ready,(Be=t.state)==null?void 0:Be.cwd,t.status,fe]),Ee=l.useCallback(P=>{if(k(P),Q(null),ae.current=P,P.x==="?"&&P.y==="?"){F({file:P,staged:"",worktree:"",untracked:!0});return}$(!0),O(null),fe({type:"scm_filediff",path:P.path},h)||$(!1)},[fe]),re=l.useCallback(P=>{Q(P),k(null),F(null),J(""),E(!0),O(null),fe({type:"scm_commit",hash:P.hash},I)||E(!1)},[fe]),f=l.useCallback((P,ge)=>{var N,A;if(!t.ready)return;const oe={name:P,command:ge,cwd:"${pwd}"};let p;const V=t.terminals.find(ie=>ie.title===P);V?(n.restart(V.id),s({type:"run_command",terminalId:V.id,conversationId:V.conversationId,command:oe,cols:80,rows:24}),p=V.id):(p=Ue(),n.create({id:p,conversationId:t.activeConversationId||((N=t.state)==null?void 0:N.conversationId)||"",title:P,cwd:((A=t.state)==null?void 0:A.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:oe})),n.select(p),c()},[t.ready,(De=t.state)==null?void 0:De.cwd,t.terminals,c,s,n]),W=l.useCallback(()=>{const P=v.trim();if(!P||z)return;const ge=P.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");f("git commit",`git commit -m "${ge}"`),L("")},[v,z,f]),de=l.useCallback(()=>{const P=v.trim();if(!P||z)return;const ge=P.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");f("git commit",`git add -A && git commit -m "${ge}"`),L("")},[v,z,f]),ue=l.useCallback(P=>{z||f("git add",`git add -- ${ln(P.path)}`)},[z,f]),me=l.useCallback(P=>{z||f("git reset",`git reset HEAD -- ${ln(P.path)}`)},[z,f]),pe=l.useCallback(()=>{if(!y||z)return;const P=u.find(ge=>ge.name===y);if(P!=null&&P.remote&&typeof P.remote=="string"){const ge=y.slice(P.remote.length+1);f("git checkout",`git checkout -b ${ge} ${y} || git checkout ${y}`)}else f("git checkout",`git checkout ${y}`)},[y,u,z,f]),ve=l.useCallback(()=>f("git push","git push"),[f]),Me=l.useCallback(()=>f("git pull","git pull"),[f]),he=l.useCallback(()=>{fe({type:"scm_history"},ee)||(ee.current=-1)},[fe]);l.useEffect(()=>{r&&be()},[r,be]),l.useEffect(()=>{T==="history"&&a&&he()},[T,a,he]),l.useEffect(()=>{t.scmDirty>0&&r&&be(!1,!0)},[t.scmDirty]),l.useEffect(()=>{if(!r||!t.ready||t.status!=="open")return;const P=setInterval(()=>{document.visibilityState!=="hidden"&&be(!1,!0)},3e4);return()=>clearInterval(P)},[r,t.ready,t.status,be]),l.useEffect(()=>{const P=ye.current;if(ye.current=t.terminals,!r)return;t.terminals.some(oe=>{var V;return oe.running!==!1?!1:((V=P.find(N=>N.id===oe.id))==null?void 0:V.running)===!0&&oe.title.startsWith("git ")})&&t.ready&&t.status==="open"&&(be(!1,!0),T==="history"&&a&&he())},[t.terminals,r,t.ready,t.status,be,T,a,he]);const _e={staged:i("scmStaged"),unstaged:i("scmUnstaged"),untracked:i("scmUntracked"),both:i("scmStagedUnstaged")},Le=P=>{const ge=P.split(`
|
|
324
|
-
`);return e.jsx("pre",{className:"scm-diff-pre",children:ge.map((oe,p)=>{let V="";return oe.startsWith("diff --git")||oe.startsWith("index ")||oe.startsWith("new file")||oe.startsWith("deleted file")||oe.startsWith("old mode")||oe.startsWith("new mode")||oe.startsWith("similarity index")||oe.startsWith("rename ")||oe.startsWith("copy ")||oe.startsWith("Binary files")||oe.startsWith("---")||oe.startsWith("+++")?V="hdr":oe.startsWith("@@")?V="hunk":oe.startsWith("+")?V="add":oe.startsWith("-")&&(V="del"),e.jsx("div",{className:`scm-diff-line ${V}`,children:oe||" "},p)})})};return e.jsxs("div",{className:"scm-view",children:[e.jsxs("div",{className:"scm-header",children:[e.jsxs("div",{className:"scm-title-row",children:[e.jsxs("span",{className:"scm-title",children:[e.jsx(yt,{}),i("scmTitle")]}),e.jsxs("div",{className:"scm-view-tabs",role:"tablist",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":T==="changes",className:T==="changes"?"active":"",onClick:()=>{D("changes"),O(null)},children:i("scmChanges")}),e.jsx("button",{type:"button",role:"tab","aria-selected":T==="history",className:T==="history"?"active":"",onClick:()=>{D("history"),O(null)},children:i("scmHistory")})]}),e.jsx("button",{type:"button",className:"panel-refresh",title:i("scmRefreshTip"),disabled:X,onClick:()=>be(!0),children:e.jsx(rt,{className:X?"scm-spin":""})})]}),e.jsxs("div",{className:"scm-row",children:[e.jsxs("span",{className:"scm-branch-current",title:i("scmCurrentBranch"),children:[e.jsx(yt,{}),a?a.detached?i("scmDetached"):a.branch:"…",(a==null?void 0:a.upstream)&&e.jsx("span",{className:"scm-upstream",children:a.upstreamGone?i("scmUpstreamGone"):a.ahead>0||a.behind>0?i("scmAheadBehind",{ahead:a.ahead,behind:a.behind}):a.upstream})]}),e.jsxs("select",{className:"scm-select",value:y,disabled:z||u.length===0,title:i("scmSwitchBranch"),onChange:P=>g(P.target.value),children:[e.jsx("option",{value:"",disabled:!0,children:i("scmSelectBranch")}),u.filter(P=>!P.remote).map(P=>e.jsx("option",{value:P.name,children:P.current?`* ${P.name}`:P.name},P.name)),u.some(P=>P.remote)&&e.jsx("optgroup",{label:i("scmRemoteBranches"),children:u.filter(P=>P.remote).map(P=>e.jsx("option",{value:P.name,children:P.name},P.name))})]}),e.jsxs("button",{type:"button",className:"btn",disabled:!y||y===(a==null?void 0:a.branch)||z,title:i("scmSwitchBranchTip",{branch:y}),onClick:pe,children:[e.jsx(yt,{}),i("scmSwitch")]}),e.jsxs("button",{type:"button",className:"btn",disabled:!a||a.detached||z,title:i("scmPushTip"),onClick:ve,children:[e.jsx(Cn,{}),i("scmPush")]}),e.jsxs("button",{type:"button",className:"btn",disabled:!a||a.detached||z,title:i("scmPullTip"),onClick:Me,children:[e.jsx(Sn,{}),i("scmPull")]}),e.jsx("input",{className:"scm-commit-input",value:v,placeholder:i("scmCommitPlaceholder"),disabled:z,onChange:P=>L(P.target.value),onKeyDown:P=>{P.key==="Enter"&&!P.nativeEvent.isComposing&&W()}}),e.jsxs("button",{type:"button",className:"btn primary",disabled:!v.trim()||z,title:i("scmCommitTip"),onClick:W,children:[e.jsx(pt,{}),i("scmCommit")]}),e.jsx("button",{type:"button",className:"btn",disabled:!v.trim()||z,title:i("scmCommitAllTip"),onClick:de,children:i("scmCommitAll")})]})]}),e.jsxs("div",{className:"scm-body",children:[T==="history"?e.jsxs("div",{className:"scm-history",children:[e.jsxs("div",{className:"scm-files-header",children:[e.jsx("span",{children:i("scmHistory")}),K.length>0&&e.jsx("span",{className:"scm-files-count",children:K.length})]}),e.jsx("div",{className:"scm-history-list",children:z?e.jsx("div",{className:"scm-empty",children:i("scmNotGitRepo")}):!a||M?e.jsx("div",{className:"scm-empty",children:t.status==="open"?i("scmLoading"):i("scmConnecting")}):K.length===0?e.jsx("div",{className:"scm-empty",children:i("scmNoHistory")}):K.map(P=>e.jsxs("button",{type:"button",className:`scm-commit ${(j==null?void 0:j.hash)===P.hash?"active":""}`,onClick:()=>re(P),title:P.hash,children:[e.jsx("span",{className:"scm-commit-graph","aria-hidden":"true",children:P.graph||"* "}),e.jsxs("span",{className:"scm-commit-info",children:[e.jsx("span",{className:"scm-commit-subject",children:P.subject}),e.jsxs("span",{className:"scm-commit-meta",children:[P.shortHash," · ",P.author," · ",P.date]}),P.decorations&&e.jsx("span",{className:"scm-commit-refs",children:P.decorations})]})]},P.hash))})]}):e.jsxs("div",{className:"scm-files",children:[e.jsxs("div",{className:"scm-files-header",children:[e.jsx("span",{children:i("scmChanges")}),a&&a.files.length>0&&e.jsx("span",{className:"scm-files-count",children:a.files.length})]}),e.jsx("div",{className:"scm-files-list",children:z?e.jsx("div",{className:"scm-empty",children:i("scmNotGitRepo")}):a?a.files.length===0?e.jsx("div",{className:"scm-empty",children:i("scmNoChanges")}):a.files.map(P=>{const ge=wl(P),oe=x.get(P.path);return e.jsxs("div",{className:`scm-file ${(H==null?void 0:H.path)===P.path?"active":""}`,title:_e[ge],onClick:()=>Ee(P),children:[e.jsx("span",{className:`scm-file-xy ${ge==="untracked"?"q":"x"}`,children:P.x!==" "?P.x:" "}),e.jsx("span",{className:`scm-file-xy ${ge==="untracked"?"q":"y"}`,children:P.y!==" "?P.y:" "}),e.jsx("span",{className:"scm-file-path",children:P.path}),oe&&(oe.add>0||oe.del>0)&&e.jsxs("span",{className:"scm-file-stat",children:[oe.add>0&&e.jsxs("span",{className:"add",children:["+",oe.add]}),oe.del>0&&e.jsxs("span",{className:"del",children:["-",oe.del]})]}),e.jsxs("span",{className:"scm-file-actions",children:[(P.y!==" "||ge==="untracked")&&e.jsx("button",{type:"button",className:"scm-act",title:i("scmStageTip",{path:P.path}),onClick:p=>{p.stopPropagation(),ue(P)},children:"+"}),ge==="staged"||ge==="both"?e.jsx("button",{type:"button",className:"scm-act",title:i("scmUnstageTip",{path:P.path}),onClick:p=>{p.stopPropagation(),me(P)},children:"−"}):null]})]},P.path)}):e.jsx("div",{className:"scm-empty",children:t.status==="open"?i("scmLoading"):i("scmConnecting")})})]}),e.jsxs("div",{className:"scm-diff",children:[e.jsxs("div",{className:"scm-diff-header",children:[e.jsx("span",{children:T==="history"?j?`${j.shortHash} ${j.subject}`:i("scmCommitDetail"):H?H.path:i("scmDiff")}),(T==="history"?U:Z)&&e.jsx("span",{className:"scm-diff-loading",children:i("scmLoading")})]}),e.jsx("div",{className:"scm-diff-body",children:T==="history"?e.jsxs(e.Fragment,{children:[C&&e.jsx("div",{className:"scm-error",children:C}),!j&&!C&&e.jsx("div",{className:"scm-empty",children:i("scmSelectCommitHint")}),j&&U&&!C&&e.jsx("div",{className:"scm-empty",children:i("scmLoading")}),j&&!U&&!C&&G?Le(G):null]}):e.jsxs(e.Fragment,{children:[C&&e.jsx("div",{className:"scm-error",children:C}),!H&&!C&&e.jsx("div",{className:"scm-empty",children:i("scmSelectFileHint")}),H&&!_&&!C&&e.jsx("div",{className:"scm-empty",children:i("scmLoading")}),H&&_&&_.untracked&&e.jsx("div",{className:"scm-empty",children:i("scmUntrackedNote")}),H&&_&&!_.untracked&&e.jsxs(e.Fragment,{children:[_.staged&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"scm-diff-section",children:i("scmStaged")}),Le(_.staged)]}),_.worktree&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"scm-diff-section",children:i("scmUnstaged")}),Le(_.worktree)]}),!_.staged&&!_.worktree&&e.jsx("div",{className:"scm-empty",children:i("scmNoDiff")})]})]})})]})]}),e.jsxs("div",{className:"scm-hint",children:[e.jsx(tt,{}),e.jsx("span",{children:i("scmRunsInTerminal")}),e.jsx("button",{type:"button",className:"scm-goto-term",onClick:c,children:i("scmViewTerminal")})]})]})}function Cl({entry:t,send:s}){const n=l.useRef(null),r=xe();return l.useEffect(()=>{const c=n.current;if(!c)return;let i;try{i=t.module.mount(c,Na(t.info.id,a=>s(a)))}catch(a){console.error(`[plugin:${t.info.id}] mount failed:`,a),c.textContent=r("pluginMountFailed",{name:t.info.name})}return()=>{if(typeof i=="function")try{i()}catch(a){console.error(`[plugin:${t.info.id}] cleanup failed:`,a)}c.textContent=""}},[t,s]),e.jsx("div",{className:"plugin-view",ref:n})}function Sl({send:t,piConfigured:s,piAgentInstalled:n,providers:r,installResult:c,onClose:i}){const a=xe(),[o,u]=l.useState(!1),[m,y]=l.useState(""),[g,x]=l.useState(""),[b,T]=l.useState(!1);l.useEffect(()=>{t({type:"list_providers"})},[t]),l.useEffect(()=>{s&&i()},[s,i]),l.useEffect(()=>{c&&u(!1)},[c]),l.useEffect(()=>{var G;!m&&r.length>0&&y(((G=r.find(J=>!J.configured))==null?void 0:G.id)??r[0].id)},[r,m]);const D=()=>{o||(u(!0),t({type:"install_pi_agent"}))},K=()=>{!g.trim()||b||(T(!0),t({type:"set_provider_api_key",provider:m.trim(),apiKey:g.trim()}),setTimeout(()=>T(!1),3e3))},S=()=>{t({type:"get_state"}),t({type:"list_providers"})},j=r.find(G=>G.id===m),Q=c!==null&&!c.ok;return e.jsx("div",{className:"modal-backdrop",children:e.jsxs("div",{className:"modal setup-modal",children:[e.jsx("button",{type:"button",className:"modal-close","aria-label":a("close"),onClick:i,children:e.jsx(Pe,{})}),e.jsxs("div",{className:"modal-head",children:[e.jsx(lt,{className:"modal-head-icon"}),e.jsx("h2",{children:a("setupTitle")})]}),e.jsx("p",{className:"modal-desc",children:a("setupDesc")}),Q?e.jsxs("div",{className:"setup-failed",children:[e.jsx("div",{className:"setup-done",children:a("installFailed")}),e.jsx("pre",{className:"setup-detail",children:c.detail}),e.jsxs("div",{className:"setup-actions",children:[e.jsx("button",{type:"button",className:"btn primary",disabled:o,onClick:D,children:a("retryInstall")}),e.jsx("button",{type:"button",className:"btn",onClick:i,children:a("skip")})]})]}):n||c!=null&&c.ok?e.jsxs("div",{className:"setup-key-form",children:[e.jsx("div",{className:"setup-done",children:c!=null&&c.ok?a("installDone"):a("cliReadyHint")}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:a("provider")}),e.jsxs("select",{value:m,onChange:G=>y(G.target.value),children:[r.length===0&&e.jsx("option",{value:"",children:a("loading")}),r.map(G=>e.jsxs("option",{value:G.id,children:[G.name,"(",G.id,")",G.configured?` · ${a("configured")}`:""]},G.id))]}),(j==null?void 0:j.configured)&&e.jsx("div",{className:"field-hint",children:a("providerKeyReady")})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:a("apiKey")}),e.jsx("input",{type:"password",value:g,onChange:G=>x(G.target.value),placeholder:"sk-…"})]}),e.jsxs("div",{className:"setup-actions",children:[e.jsx("button",{type:"button",className:"btn primary",disabled:!g.trim()||b||!m,onClick:K,children:a(b?"saving":"saveAndStart")}),e.jsxs("button",{type:"button",className:"btn",onClick:S,children:[e.jsx(rt,{})," ",a("recheck")]})]})]}):e.jsxs("div",{className:"setup-actions",children:[e.jsx("button",{type:"button",className:"btn primary",disabled:o,onClick:D,children:a(o?"installing":"autoInstall")}),e.jsx("button",{type:"button",className:"btn",onClick:i,children:a("skip")})]})]})})}const Tl=["openai-completions","openai-responses","anthropic-messages","google-generative-ai"],ps=()=>({id:"",name:"",reasoning:!1,input:"text",contextWindow:"",maxTokens:""}),El=()=>({providerId:"",name:"",api:"openai-completions",baseUrl:"",apiKey:"",authHeader:!0,models:[ps()]});function qt(t){return{providerId:t.providerId,name:t.name??"",api:t.api??"openai-completions",baseUrl:t.baseUrl??"",apiKey:t.apiKey??"",authHeader:t.authHeader??!1,models:(t.models.length?t.models:[ps()]).map(s=>{var n;return{id:s.id,name:s.name??"",reasoning:s.reasoning??!1,input:(n=s.input)!=null&&n.includes("image")?"text-image":"text",contextWindow:s.contextWindow?String(s.contextWindow):"",maxTokens:s.maxTokens?String(s.maxTokens):""}})}}function Pl({send:t,providers:s,providerStatus:n,providerKeys:r,fetchModelsResult:c,cloneProviderResult:i,onClose:a}){const o=xe(),[u,m]=l.useState(null),[y,g]=l.useState({}),[x,b]=l.useState({}),[T,D]=l.useState(null),[K,S]=l.useState(!1),[j,Q]=l.useState(0),[G,J]=l.useState(null),U=l.useRef(0),[E,H]=l.useState(null),[k,_]=l.useState(""),[F,Z]=l.useState(null);l.useEffect(()=>{t({type:"list_models_config"}),t({type:"list_providers"}),t({type:"list_provider_keys"})},[t]);const $=()=>{if(!u)return;const v=u.baseUrl.trim();if(!v){J({ok:!1,text:o("fetchModelsNeedBaseUrl")});return}if(K)return;S(!0),J(null);const L=j+1;Q(L),t({type:"fetch_models",reqId:L,baseUrl:v,apiKey:u.apiKey.trim()||void 0,authHeader:u.authHeader,api:u.api})};l.useEffect(()=>{var v;if(!(!c||c.reqId===U.current))if(U.current=c.reqId,S(!1),c.ok&&((v=c.models)!=null&&v.length)){const L=c.models;m(d=>{if(!d)return d;const w=d.models.map(q=>{var ke;if(!q.id.trim())return q;const ae=L.find(fe=>fe.id===q.id.trim());if(!ae)return q;const ye={...q};return!ye.name&&ae.name&&(ye.name=ae.name),!ye.contextWindow&&ae.contextWindow&&(ye.contextWindow=String(ae.contextWindow)),!ye.maxTokens&&ae.maxTokens&&(ye.maxTokens=String(ae.maxTokens)),ye.input==="text"&&((ke=ae.input)!=null&&ke.includes("image"))&&(ye.input="text-image"),!ye.reasoning&&ae.reasoning&&(ye.reasoning=!0),ye}),h=new Set(w.map(q=>q.id.trim()).filter(Boolean)),I=L.filter(q=>!h.has(q.id)).map(q=>{var ae;return{id:q.id,name:q.name??"",reasoning:q.reasoning??!1,input:(ae=q.input)!=null&&ae.includes("image")?"text-image":"text",contextWindow:q.contextWindow?String(q.contextWindow):"",maxTokens:q.maxTokens?String(q.maxTokens):""}}),ee=[...w,...I];return ee.some(q=>q.id.trim())?{...d,models:ee.filter(q=>q.id.trim())}:d}),J({ok:!0,text:o("fetchModelsOk",{n:L.length})})}else J({ok:!1,text:c.error||o("fetchModelsEmpty")})},[c]);const X=v=>{const L=(y[v.id]??"").trim();!L||T||(D(v.id),t({type:"add_provider_key",provider:v.id,apiKey:L,name:(x[v.id]??"").trim()||void 0}),setTimeout(()=>{D(null),g(d=>({...d,[v.id]:""})),b(d=>({...d,[v.id]:""})),t({type:"list_providers"}),t({type:"list_provider_keys"})},1500))},Y=(v,L)=>{t({type:"activate_provider_key",provider:v,keyName:L}),t({type:"list_provider_keys"})},M=(v,L)=>{window.confirm(o("removeKeyConfirm"))&&(t({type:"remove_provider_key",provider:v,keyName:L}),t({type:"list_provider_keys"}))},R=()=>{if(!F)return;const v=F.providerId.trim();if(!v||!F.apiKey.trim())return;const L=F.models.filter(w=>w.id.trim()).map(w=>({id:w.id.trim(),name:w.name.trim()||void 0,reasoning:w.reasoning||void 0,input:w.input==="text-image"?["text","image"]:void 0,contextWindow:w.contextWindow?Number(w.contextWindow):void 0,maxTokens:w.maxTokens?Number(w.maxTokens):void 0})),d={providerId:v,name:F.name.trim()||void 0,api:F.api.trim()||void 0,baseUrl:F.baseUrl.trim()||void 0,apiKey:F.apiKey.trim()||void 0,authHeader:F.authHeader||void 0,models:L};t({type:"save_model_config",providerId:v,config:d}),Z(null),a()},C=()=>{if(!u)return;const v=u.providerId.trim(),L=u.models.filter(w=>w.id.trim()).map(w=>({id:w.id.trim(),name:w.name.trim()||void 0,reasoning:w.reasoning||void 0,input:w.input==="text-image"?["text","image"]:void 0,contextWindow:w.contextWindow?Number(w.contextWindow):void 0,maxTokens:w.maxTokens?Number(w.maxTokens):void 0})),d={providerId:v,name:u.name.trim()||void 0,api:u.api.trim()||void 0,baseUrl:u.baseUrl.trim()||void 0,apiKey:u.apiKey.trim()||void 0,authHeader:u.authHeader||void 0,models:L};t({type:"save_model_config",providerId:v,config:d}),a()};l.useEffect(()=>{if(i&&i.ok){const v=i.configs;if(v&&v.length>1){H(v.map(L=>qt({...L,apiKey:""}))),_("");return}if(i.config){Z(qt({...i.config,apiKey:""}));return}}},[i]);const O=v=>{window.confirm(o("clearKeyConfirm",{id:v}))&&t({type:"clear_provider_api_key",provider:v})},z=v=>{window.confirm(o("deleteProviderConfirm",{id:v.providerId,n:v.models.length}))&&t({type:"delete_model_config",providerId:v.providerId})},ne=(v,L)=>{u&&m({...u,models:u.models.map((d,w)=>w===v?{...d,...L}:d)})};return e.jsx("div",{className:"modal-backdrop",onClick:a,children:e.jsxs("div",{className:"modal model-modal",onClick:v=>v.stopPropagation(),children:[e.jsx("button",{type:"button",className:"modal-close","aria-label":o("close"),onClick:a,children:e.jsx(Pe,{})}),e.jsx("div",{className:"modal-head",children:e.jsx("h2",{children:F?o("addKey"):E?o("batchCreateProviders",{n:E.length}):o(u?"editProvider":"manageModelsTitle")})}),F?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"model-modal-body",children:e.jsxs("div",{className:"provider-form",children:[e.jsx("p",{className:"modal-desc",style:{marginBottom:12},children:o("secondKeyTitle",{api:F.api,baseUrl:F.baseUrl||o("noBaseUrlShort"),n:F.models.length})}),e.jsxs("div",{className:"form-grid",children:[e.jsxs("label",{className:"field",children:[e.jsxs("span",{className:"field-label",children:[o("providerNameLabel")," ",e.jsx("em",{children:o("providerNameHint")})]}),e.jsx("input",{type:"text",value:F.providerId,onChange:v=>Z({...F,providerId:v.target.value}),placeholder:"opencode-2"})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:o("apiKeyLabel")}),e.jsx("input",{type:"password",value:F.apiKey,onChange:v=>Z({...F,apiKey:v.target.value}),placeholder:o("secondKeyPlaceholder")})]})]}),e.jsxs("div",{style:{fontSize:12,opacity:.6,marginTop:8},children:[F.models.slice(0,5).map(v=>v.id).join(", "),F.models.length>5?` … +${F.models.length-5}`:""]})]})}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>Z(null),children:o("cancel")}),e.jsx("button",{type:"button",className:"btn",onClick:()=>{const v=F;Z(null),m(v)},children:o("advancedEdit")}),e.jsx("button",{type:"button",className:"btn primary",disabled:!F.providerId.trim()||!F.apiKey.trim(),onClick:R,children:o("save")})]})]}):E?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"model-modal-body",children:e.jsxs("div",{className:"provider-form",children:[e.jsx("p",{className:"modal-desc",style:{marginBottom:12},children:o("batchDesc",{apis:E.map(v=>v.api).join("、"),n:E.length})}),e.jsxs("label",{className:"field",style:{marginBottom:16},children:[e.jsx("span",{className:"field-label",children:o("batchKeyLabel",{n:E.length})}),e.jsx("input",{type:"password",value:k,onChange:v=>_(v.target.value),placeholder:o("secondKeyPlaceholder")})]}),e.jsx("div",{className:"provider-list",style:{marginBottom:16},children:E.map((v,L)=>e.jsxs("div",{className:"provider-row",style:{flexDirection:"column",alignItems:"stretch",gap:6},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:13},children:[e.jsx("strong",{children:v.providerId}),e.jsx("span",{style:{opacity:.7},children:v.api})]}),e.jsxs("div",{className:"provider-sub",style:{fontSize:12,opacity:.7},children:[v.baseUrl||o("noBaseUrlShort")," · ",o("modelsCountShort",{n:v.models.length}),v.models.slice(0,3).map(d=>d.id).join(", "),v.models.length>3?` … +${v.models.length-3}`:""]}),e.jsx("input",{type:"text",value:v.providerId,onChange:d=>H(w=>w.map((h,I)=>I===L?{...h,providerId:d.target.value}:h)),placeholder:o("providerIdPlaceholder"),style:{fontSize:12}}),e.jsx("input",{type:"text",value:v.baseUrl,onChange:d=>H(w=>w.map((h,I)=>I===L?{...h,baseUrl:d.target.value}:h)),placeholder:o("baseUrlExamplePh"),style:{fontSize:12}})]},L))})]})}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>H(null),children:o("cancel")}),e.jsx("button",{type:"button",className:"btn primary",disabled:!k.trim(),onClick:()=>{for(const v of E){const L=v.providerId.trim();if(!L)continue;const d=v.models.filter(h=>h.id.trim()).map(h=>({id:h.id.trim(),name:h.name.trim()||void 0,reasoning:h.reasoning||void 0,input:h.input==="text-image"?["text","image"]:void 0,contextWindow:h.contextWindow?Number(h.contextWindow):void 0,maxTokens:h.maxTokens?Number(h.maxTokens):void 0})),w={providerId:L,name:v.name.trim()||void 0,api:v.api.trim()||void 0,baseUrl:v.baseUrl.trim()||void 0,apiKey:k.trim()||void 0,authHeader:v.authHeader||void 0,models:d};t({type:"save_model_config",providerId:L,config:w})}H(null),a()},children:o("saveAllBatch",{n:E.length})})]})]}):u?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"model-modal-body",children:e.jsxs("div",{className:"provider-form",children:[e.jsxs("div",{className:"form-grid",children:[e.jsxs("label",{className:"field",children:[e.jsxs("span",{className:"field-label",children:[o("providerId")," ",e.jsx("em",{children:o("providerIdHint")})]}),e.jsx("input",{type:"text",value:u.providerId,disabled:s.some(v=>v.providerId===u.providerId),onChange:v=>m({...u,providerId:v.target.value}),placeholder:"my-proxy"})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:o("displayName")}),e.jsx("input",{type:"text",value:u.name,onChange:v=>m({...u,name:v.target.value}),placeholder:o("displayNamePh")})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:o("apiType")}),e.jsx("select",{value:u.api,onChange:v=>m({...u,api:v.target.value}),children:Tl.map(v=>e.jsx("option",{value:v,children:v},v))})]}),e.jsxs("label",{className:"field",children:[e.jsxs("span",{className:"field-label",children:["baseUrl ",e.jsx("em",{children:o("baseUrlHint")})]}),e.jsx("input",{type:"text",value:u.baseUrl,onChange:v=>m({...u,baseUrl:v.target.value}),placeholder:"http://localhost:11434/v1"})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:o("apiKey")}),e.jsx("input",{type:"password",value:u.apiKey,onChange:v=>m({...u,apiKey:v.target.value}),placeholder:o("apiKeyHint")})]}),e.jsxs("label",{className:"field check",children:[e.jsx("input",{type:"checkbox",checked:u.authHeader,onChange:v=>m({...u,authHeader:v.target.checked})}),e.jsx("span",{children:o("authHeader")})]})]}),e.jsxs("div",{className:"model-section-head",children:[e.jsx("span",{className:"form-section-title",children:o("modelsTitle")}),e.jsxs("span",{className:"model-section-actions",children:[G&&e.jsx("span",{className:`fetch-msg ${G.ok?"ok":"err"}`,title:G.text,children:G.text}),e.jsxs("button",{type:"button",className:"btn sm",disabled:K||!u.baseUrl.trim(),title:o("fetchModelsHint"),onClick:$,children:[e.jsx(ls,{})," ",o(K?"fetchingModels":"fetchModels")]})]})]}),u.models.map((v,L)=>e.jsxs("div",{className:"model-row",children:[e.jsx("input",{type:"text",value:v.id,onChange:d=>ne(L,{id:d.target.value}),placeholder:o("modelIdReq")}),e.jsx("input",{type:"text",value:v.name,onChange:d=>ne(L,{name:d.target.value}),placeholder:o("displayName")}),e.jsxs("select",{value:v.input,onChange:d=>ne(L,{input:d.target.value}),children:[e.jsx("option",{value:"text",children:o("text")}),e.jsx("option",{value:"text-image",children:o("textImage")})]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:v.reasoning,onChange:d=>ne(L,{reasoning:d.target.checked})}),e.jsx("span",{children:o("reasoning")})]}),e.jsx("input",{type:"number",value:v.contextWindow,onChange:d=>ne(L,{contextWindow:d.target.value}),placeholder:o("contextWindow"),title:"contextWindow"}),e.jsx("input",{type:"number",value:v.maxTokens,onChange:d=>ne(L,{maxTokens:d.target.value}),placeholder:o("maxOutput"),title:"maxTokens"}),e.jsx("button",{type:"button",className:"iconbtn danger",title:o("removeModel"),onClick:()=>m({...u,models:u.models.filter((d,w)=>w!==L)}),children:e.jsx(Ae,{})})]},L)),e.jsxs("button",{type:"button",className:"btn",onClick:()=>m({...u,models:[...u.models,ps()]}),children:[e.jsx(He,{})," ",o("addModel")]})]})}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>m(null),children:o("cancel")}),e.jsx("button",{type:"button",className:"btn primary",disabled:!u.providerId.trim()||!u.models.some(v=>v.id.trim()),onClick:C,children:o("save")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"model-modal-fixed-hint",children:e.jsxs("div",{className:"form-section-title",children:[o("builtinProviders")," ",e.jsx("em",{className:"section-hint",children:o("hintKeyOnly")})]})}),e.jsxs("div",{className:"model-modal-body",children:[e.jsxs("div",{className:"provider-list",children:[n.length===0&&e.jsx("div",{className:"dd-loading",children:o("loading")}),n.map(v=>{const L=r[v.id]??[];return e.jsxs("div",{className:"provider-row provider-key-row",children:[e.jsxs("div",{className:"provider-key-head",children:[e.jsxs("div",{className:"provider-info",children:[e.jsx("span",{className:"provider-name",children:v.name}),e.jsxs("span",{className:"provider-sub",children:[v.id,v.configured&&e.jsx("span",{className:"auth-badge",children:o("configuredBadge")}),v.source&&!v.configured&&e.jsx("span",{className:"auth-badge dim",children:v.source})]})]}),v.source==="stored"&&e.jsxs("button",{type:"button",className:"btn sm danger",title:o("clearKeyTitle"),onClick:()=>O(v.id),children:[e.jsx(Ae,{})," ",o("clearKey")]})]}),e.jsxs("div",{className:"provider-keys",children:[L.length===0&&e.jsx("div",{className:"provider-key-empty",children:o("noKeyYet")}),L.map(d=>e.jsxs("div",{className:`provider-key-item ${d.active?"active":""}`,children:[e.jsx("span",{className:"provider-key-dot",children:d.active?"●":"○"}),e.jsx("span",{className:"provider-key-label",children:d.name}),!d.active&&e.jsx("button",{type:"button",className:"iconbtn",title:o("activateKey"),onClick:()=>Y(v.id,d.name),children:e.jsx(pt,{})}),e.jsx("button",{type:"button",className:"iconbtn danger",title:o("removeKey"),onClick:()=>M(v.id,d.name),children:e.jsx(Ae,{})})]},d.name)),e.jsxs("div",{className:"provider-add-key",children:[e.jsx("input",{type:"text",className:"key-input key-input-name",placeholder:o("keyNamePh"),value:x[v.id]??"",onChange:d=>b(w=>({...w,[v.id]:d.target.value}))}),e.jsx("input",{type:"password",className:"key-input key-input-value",placeholder:o("addKeyPlaceholder"),value:y[v.id]??"",onChange:d=>g(w=>({...w,[v.id]:d.target.value}))}),e.jsxs("button",{type:"button",className:"btn primary sm",disabled:!(y[v.id]??"").trim()||T===v.id,onClick:()=>X(v),children:[e.jsx(He,{})," ",T===v.id?o("savingKey"):o("addKey")]})]})]})]},v.id)})]}),e.jsx("div",{className:"form-section-title",children:o("customProviders")}),e.jsx("p",{className:"modal-desc",children:o("customDesc")}),s.length===0&&e.jsx("div",{className:"dd-loading",children:o("noCustomProviders")}),e.jsx("div",{className:"provider-list",children:s.map(v=>e.jsxs("div",{className:"provider-row",children:[e.jsxs("div",{className:"provider-info",children:[e.jsx("span",{className:"provider-name",children:v.providerId}),e.jsxs("span",{className:"provider-sub",children:[v.api??"—",v.baseUrl?` · ${v.baseUrl}`:"",v.models.length>0&&` · ${o("modelsCount",{n:v.models.length})}`]})]}),e.jsxs("div",{className:"provider-actions",children:[e.jsx("button",{type:"button",className:"iconbtn",title:o("edit"),onClick:()=>m(qt(v)),children:e.jsx(St,{})}),e.jsx("button",{type:"button",className:"iconbtn danger",title:o("delete"),onClick:()=>z(v),children:e.jsx(Ae,{})})]})]},v.providerId))})]}),e.jsx("div",{className:"modal-actions",children:e.jsxs("button",{type:"button",className:"btn primary",onClick:()=>m(El()),children:[e.jsx(He,{})," ",o("addProvider")]})})]})]})})}function Ml({plugin:t,send:s}){const n=xe(),r=t.settingsSchema??[],[c,i]=l.useState(()=>({...t.settingsValues})),[a,o]=l.useState(!1);if(r.length===0)return null;const u=(x,b)=>i(T=>({...T,[x]:b})),m=r.some(x=>{var b;return c[x.key]!==((b=t.settingsValues)==null?void 0:b[x.key])}),y=()=>{o(!0),s({type:"plugin_settings",pluginId:t.id,values:c}),setTimeout(()=>o(!1),800)},g=()=>i({...t.settingsValues});return e.jsxs("div",{className:"plugin-settings-form",children:[e.jsx("div",{className:"plugin-settings-fields",children:r.map(x=>e.jsxs("label",{className:"plugin-settings-field",title:x.hint,children:[e.jsx("span",{className:"plugin-settings-label",children:x.label}),x.type==="boolean"?e.jsx("input",{type:"checkbox",checked:!!c[x.key],onChange:b=>u(x.key,b.target.checked)}):x.type==="select"?e.jsx("select",{value:String(c[x.key]??""),onChange:b=>u(x.key,b.target.value),children:(x.options??[]).map(b=>e.jsx("option",{value:b,children:b},b))}):e.jsx("input",{type:x.type==="password"?"password":x.type==="number"?"number":"text",value:String(c[x.key]??""),min:x.min,max:x.max,onChange:b=>u(x.key,x.type==="number"?Number(b.target.value):b.target.value)})]},x.key))}),e.jsxs("div",{className:"plugin-settings-actions",children:[e.jsx("button",{type:"button",className:"btn plugin-settings-save",disabled:!m||a,onClick:y,children:n(a?"pluginSettingsSaving":"pluginSettingsSave")}),e.jsx("button",{type:"button",className:"btn plugin-settings-reset",onClick:g,children:n("pluginSettingsReset")})]})]})}function Rl(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Ke({text:t}){const s=l.useRef(null),[n,r]=l.useState(!1),c=()=>{var a;const i=(a=s.current)==null?void 0:a.getBoundingClientRect();i&&r(window.innerWidth-i.right<340)};return e.jsxs("span",{ref:s,className:`set-tip${n?" flip":""}`,tabIndex:0,"aria-label":t,onMouseEnter:c,onFocus:c,children:["?",e.jsx("span",{className:"set-tip-bubble",role:"tooltip",children:t})]})}function Re({title:t,subtitle:s,tip:n,enabled:r,onToggle:c,action:i}){const a=xe();return e.jsxs("div",{className:"set-row",children:[e.jsxs("div",{className:"set-row-info",children:[e.jsxs("div",{className:"set-row-name",children:[t,n&&e.jsx(Ke,{text:n})]}),s&&e.jsx("div",{className:"set-row-desc",children:s})]}),i,e.jsx("button",{type:"button",className:`set-switch ${r?"on":""}`,role:"switch","aria-checked":r,title:a(r?"settingsEnabled":"settingsDisabled"),onClick:c,children:e.jsx("span",{className:"set-switch-knob"})})]})}function Il({chat:t,send:s,terminal:n,onSwitchToTerminal:r,onClose:c}){var Le,Be,De,P,ge,oe;const i=xe(),a=t.settings,o=t.engine==="dsh",[u,m]=l.useState("prompt"),y=l.useRef(null);l.useEffect(()=>{var p;(p=y.current)==null||p.scrollTo({top:0})},[u]),l.useEffect(()=>{u==="plugins"&&t.engine==="dsh"&&s({type:"dsh_patches_list"})},[u,t.engine,s]);const[g,x]=l.useState(""),[b,T]=l.useState("append"),D=l.useRef(!1),[K,S]=l.useState(""),[j,Q]=l.useState("append"),G=l.useRef(!1),[J,U]=l.useState(""),E=l.useRef(!1),[H,k]=l.useState(""),[_,F]=l.useState(null),[Z,$]=l.useState(null),[X,Y]=l.useState(!1),M=$n(),[R,C]=l.useState(()=>si()),[O,z]=l.useState(()=>{try{return dt().length}catch{return 0}}),[ne,v]=l.useState(!1),L=()=>{try{z(dt().length)}catch{z(0)}};l.useEffect(()=>{u==="prompt-history"&&L()},[u]),l.useEffect(()=>{if(!ne)return;const p=window.setTimeout(()=>v(!1),3e3);return()=>window.clearTimeout(p)},[ne]);const[d,w]=l.useState(null),[h,I]=l.useState(null);l.useEffect(()=>{a&&(T(a.promptMode),!D.current&&(x(b==="append"||a.customSystemPrompt?a.customSystemPrompt:a.defaultSystemPrompt||""),Q(a.visionBridgePromptMode),!G.current&&(S(j==="append"||a.visionBridgePrompt?a.visionBridgePrompt:a.visionBridgeDefaultPrompt||""),E.current||U(a.reviewPrompt))))},[a,b,j]);const[ee,q]=l.useState(String((a==null?void 0:a.terminalBashIdleMs)??15e3));if(l.useEffect(()=>{q(String((a==null?void 0:a.terminalBashIdleMs)??15e3))},[a==null?void 0:a.terminalBashIdleMs]),!a)return null;const ae=[{id:"prompt",icon:e.jsx(bn,{}),label:i("settingsSystemPrompt")},{id:"prompt-history",icon:e.jsx(_s,{}),label:i("settingsPromptHistory"),count:O},{id:"terminal",icon:e.jsx(tt,{}),label:i("settingsTerminalTools")},{id:"display",icon:e.jsx(st,{}),label:i("settingsMessageDisplay")},{id:"markers",icon:e.jsx(Ls,{}),label:i("settingsMarkers"),count:((Le=a.markers)==null?void 0:Le.length)??0},{id:"skills",icon:e.jsx(lt,{}),label:i("settingsSkills"),count:a.skills.length},{id:"extensions",icon:e.jsx(Ds,{}),label:i("settingsExtensions"),count:a.extensions.length},{id:"plugins",icon:e.jsx(Lt,{}),label:i("settingsUiPlugins"),count:t.plugins.length},{id:"review",icon:e.jsx(xt,{}),label:i("settingsReview"),count:a.reviewSkills.length},...o?[]:[{id:"vision",icon:e.jsx(Qt,{}),label:i("settingsVisionBridge")}],{id:"presets",icon:e.jsx(Li,{}),label:i("settingsPresets"),count:a.presets.length},...o?[]:[{id:"subagent-templates",icon:e.jsx(Rs,{}),label:i("settingsSubagentTemplates"),count:a.subagentTemplates.length}]],ye=new Set(a.disabledSkills),ke=new Set(a.disabledExtensions),fe=p=>s({type:"set_settings",...p}),be=p=>{const V=new Set(ye);V.has(p.name)?V.delete(p.name):V.add(p.name),fe({disabledSkills:[...V]})},Ee=new Set(a.disabledPlugins??[]),re=p=>{const V=new Set(Ee);V.has(p.id)?V.delete(p.id):V.add(p.id),fe({disabledPlugins:[...V]})},f=p=>{const V=new Set(ke);V.has(p.id)?V.delete(p.id):V.add(p.id),fe({disabledExtensions:[...V]})},W=a.markersEnabled??!0,de=new Set(a.disabledMarkers??[]),ue=p=>{const V=new Set(de),N=p==="conv"||p==="rename"||p==="title"?["conv","rename","title"]:[p],A=!N.some(ie=>V.has(ie));for(const ie of N)A?V.add(ie):V.delete(ie);fe({disabledMarkers:[...V]})},me=(p,V)=>{var le,je;const N={name:p,command:V,cwd:"${pwd}"};let A;const ie=t.terminals.find(we=>we.title===p);ie?(n.restart(ie.id),s({type:"run_command",terminalId:ie.id,conversationId:ie.conversationId,command:N,cols:80,rows:24}),A=ie.id):(A=Ue(),n.create({id:A,conversationId:t.activeConversationId||((le=t.state)==null?void 0:le.conversationId)||"",title:p,cwd:((je=t.state)==null?void 0:je.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:N})),n.select(A),r(),c()},pe=p=>{w(null),me(`${i("uninstallTitle")} ${p}`,`pi remove npm:${p}`)},ve=p=>{I(null),me(`${i("uninstallTitle")} ${p}`,`pi-web-ui uninstall ${p}`)},Me=(p,V)=>{me(`${i("pluginUpdate")} ${p}`,`pi-web-ui install ${V} --name ${p} --force`)},he=p=>{const V=new Set(a.reviewSkills.filter(N=>!N.enabled).map(N=>N.name));V.has(p.name)?V.delete(p.name):V.add(p.name),fe({reviewDisabledSkills:[...V]})},_e=()=>{const p=b==="replace"&&a.defaultSystemPrompt&&g===a.defaultSystemPrompt?"":g;fe({promptMode:b,customSystemPrompt:p})};return e.jsx("div",{className:"modal-backdrop",onClick:c,children:e.jsxs("div",{className:"modal settings-modal",onClick:p=>p.stopPropagation(),children:[e.jsx("button",{type:"button",className:"modal-close","aria-label":i("close"),onClick:c,children:e.jsx(Pe,{})}),e.jsxs("div",{className:"modal-head",children:[e.jsx(wt,{className:"modal-head-icon"}),e.jsx("h2",{children:i("settingsTitle")}),e.jsx(Ke,{text:i("settingsDesc")})]}),e.jsxs("div",{className:"settings-layout",children:[e.jsx("nav",{className:"settings-rail","aria-label":i("settingsTitle"),children:ae.map(p=>e.jsxs("button",{type:"button",className:`settings-tab${u===p.id?" active":""}`,"aria-current":u===p.id?"true":void 0,title:p.label,onClick:()=>m(p.id),children:[e.jsx("span",{className:"settings-tab-icon",children:p.icon}),e.jsx("span",{className:"settings-tab-label",children:p.label}),p.count!==void 0&&e.jsx("span",{className:"set-count",children:p.count})]},p.id))}),e.jsxs("div",{className:"modal-body",ref:y,children:[u==="prompt"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(xt,{className:"set-section-icon"}),i("settingsSystemPrompt")]}),e.jsxs("div",{className:"set-mode-row",children:[e.jsx("label",{className:"set-field-label",children:i("settingsPromptMode")}),e.jsxs("select",{className:"set-select",value:b,onChange:p=>{const V=p.target.value;T(V),fe({promptMode:V})},children:[e.jsx("option",{value:"append",children:i("promptModeAppend")}),e.jsx("option",{value:"replace",children:i("promptModeReplace")})]}),e.jsx(Ke,{text:i(b==="append"?"promptAppendHint":"promptReplaceHint")})]}),e.jsx("textarea",{className:"set-prompt-input",rows:6,placeholder:i("promptPlaceholder"),value:g,onFocus:()=>D.current=!0,onBlur:()=>{D.current=!1,_e()},onChange:p=>x(p.target.value)}),e.jsxs("button",{type:"button",className:"set-view-prompt-btn","aria-expanded":X,onClick:()=>Y(p=>!p),children:[i("settingsViewPrompt")," ",X?"▴":"▾"]}),X&&e.jsxs("div",{className:"set-prompt-view",children:[e.jsxs("div",{className:"set-prompt-view-head",children:[e.jsx("span",{children:i("settingsViewPromptHint")}),e.jsx(Tt,{text:a.effectiveSystemPrompt})]}),a.effectiveSystemPrompt?e.jsx("pre",{className:"set-prompt-view-text",children:a.effectiveSystemPrompt}):e.jsx("p",{className:"set-empty",children:i("settingsViewPromptEmpty")})]})]}),u==="prompt-history"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(_s,{className:"set-section-icon"}),i("settingsPromptHistory"),e.jsx(Ke,{text:i("settingsPromptHistoryDesc")}),e.jsx("span",{className:"set-count",children:i("promptHistoryCount",{n:String(O)})})]}),O===0?e.jsx("p",{className:"set-empty",children:i("promptHistoryEmpty")}):e.jsx("p",{className:"set-hint",children:i("promptHistoryCount",{n:String(O)})}),e.jsxs("div",{className:"set-field",children:[e.jsx("label",{className:"set-field-label",htmlFor:"ph-max",children:i("promptHistoryMax")}),e.jsxs("div",{className:"set-mode-row",children:[e.jsx("input",{id:"ph-max",className:"set-input",type:"number",min:1,max:500,step:1,value:String(R.maxEntries),onChange:p=>{const V=Math.floor(Number(p.target.value)||0),N={...R,maxEntries:V};C(N)},onBlur:()=>{const p={...R};(!Number.isFinite(p.maxEntries)||p.maxEntries<1)&&(p.maxEntries=1),p.maxEntries>500&&(p.maxEntries=500),p.maxEntries=Math.floor(p.maxEntries),C(p),Ut(p),L()}}),e.jsx(Ke,{text:i("promptHistoryMaxHint")})]})]}),e.jsx(Re,{title:i("promptHistoryCharLimit"),tip:i("promptHistoryCharLimitHint"),enabled:R.charLimitEnabled,onToggle:()=>{const p={...R,charLimitEnabled:!R.charLimitEnabled};C(p),Ut(p),L()}}),R.charLimitEnabled&&e.jsxs("div",{className:"set-field",children:[e.jsx("label",{className:"set-field-label",htmlFor:"ph-char-limit",children:i("promptHistoryCharLimit")}),e.jsx("input",{id:"ph-char-limit",className:"set-input",type:"number",min:100,max:2e4,step:100,placeholder:i("promptHistoryCharLimitPlaceholder"),value:String(R.charLimit),onChange:p=>{const V=Math.floor(Number(p.target.value)||0);C({...R,charLimit:V})},onBlur:()=>{let p=Math.floor(Number(R.charLimit)||0);(!Number.isFinite(p)||p<100)&&(p=100),p>2e4&&(p=2e4);const V={...R,charLimit:p};C(V),Ut(V),L()}})]}),e.jsxs("div",{className:"set-field",style:{marginTop:12},children:[e.jsxs("button",{type:"button",className:`set-uninstall${ne?" confirm":""}`,disabled:O===0,title:i(O===0?"promptHistoryEmpty":"promptHistoryClear"),onClick:()=>{if(!ne){v(!0);return}cl(),v(!1),L()},children:[e.jsx(Ae,{})," ",i(ne?"promptHistoryClearConfirm":"promptHistoryClear")]}),O>0&&e.jsx("span",{className:"set-hint",style:{marginLeft:8},children:i("promptHistoryCount",{n:String(O)})})]}),e.jsxs("p",{className:"set-hint",children:[e.jsx(Xi,{style:{verticalAlign:"-2px",marginRight:4}}),i("settingsPromptHistoryDesc")]})]}),u==="terminal"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(tt,{className:"set-section-icon"}),i("settingsTerminalTools")]}),e.jsx(Re,{title:i("terminalToolsEnabled"),tip:i("settingsTerminalToolsDesc"),enabled:a.terminalToolsEnabled,onToggle:()=>fe({terminalToolsEnabled:!a.terminalToolsEnabled})}),!a.terminalToolsEnabled&&e.jsx("p",{className:"set-hint",children:i("terminalToolsOffHint")}),e.jsx(Re,{title:i("terminalBashTakeover"),tip:i("terminalBashTakeoverDesc"),enabled:a.terminalBash,onToggle:()=>fe({terminalBash:!a.terminalBash})}),a.terminalBash&&e.jsxs("div",{className:"set-field",children:[e.jsx("label",{className:"set-field-label",htmlFor:"tb-idle-ms",children:i("terminalBashIdleMs")}),e.jsx("input",{id:"tb-idle-ms",className:"set-input",type:"number",min:0,step:1e3,value:ee,onChange:p=>q(p.target.value),onBlur:()=>{const p=Math.max(0,Math.floor(Number(ee)||0));q(String(p)),p!==a.terminalBashIdleMs&&fe({terminalBashIdleMs:p})}})]})]}),u==="display"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(st,{className:"set-section-icon"}),i("settingsMessageDisplay")]}),e.jsx(Re,{title:i("thinkingWrap"),tip:i("thinkingWrapDesc"),enabled:a.thinkingWrap??!0,onToggle:()=>fe({thinkingWrap:!(a.thinkingWrap??!0)})}),e.jsx(Re,{title:i("toolsWrap"),tip:i("toolsWrapDesc"),enabled:a.toolsWrap??!0,onToggle:()=>fe({toolsWrap:!(a.toolsWrap??!0)})}),e.jsx("hr",{className:"set-sep"}),e.jsx(Re,{title:i("mermaidRenderSetting"),tip:i("mermaidRenderSettingDesc"),enabled:M,onToggle:()=>Xa({enabled:!M})})]}),u==="markers"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Ls,{className:"set-section-icon"}),i("settingsMarkers"),e.jsx(Ke,{text:i("settingsMarkersDesc")}),e.jsx("span",{className:"set-count",children:((Be=a.markers)==null?void 0:Be.length)??0})]}),e.jsx(Re,{title:i("markersEnabled"),tip:i("markersEnabledDesc"),enabled:W,onToggle:()=>fe({markersEnabled:!W})}),!W&&e.jsx("p",{className:"set-hint",children:i("markersOffHint")}),W&&(((De=a.markers)==null?void 0:De.length)??0)===0&&e.jsxs("p",{className:"set-empty",children:[i("loading"),"..."]}),W&&a.markers&&a.markers.length>0&&e.jsx("div",{className:"set-list",children:a.markers.map(p=>e.jsx(Re,{title:p.name==="todo"?i("markerGroupTodo"):p.name==="svc"?i("markerGroupSvc"):p.name==="notify"?i("markerGroupNotify"):p.name==="conv"||p.name==="rename"||p.name==="title"?i("markerGroupRename"):p.name,subtitle:(p.guidance[0]??"").slice(0,120),tip:p.guidance.join(`
|
|
325
|
-
`),enabled:p.enabled,onToggle:()=>ue(p.name)},p.name))}),W&&e.jsx("p",{className:"set-hint",children:i("markerRenameTip")})]}),u==="skills"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(lt,{className:"set-section-icon"}),i("settingsSkills"),e.jsx("span",{className:"set-count",children:a.skills.length})]}),a.skills.length===0?e.jsx("p",{className:"set-empty",children:i(o?"dshSkillsNote":"noSkills")}):e.jsx("div",{className:"set-list",children:a.skills.map(p=>e.jsx(Re,{title:p.name,subtitle:p.description,enabled:p.enabled,onToggle:()=>be(p)},p.name))})]}),u==="extensions"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Ds,{className:"set-section-icon"}),i("settingsExtensions"),e.jsx("span",{className:"set-count",children:a.extensions.length})]}),a.extensions.length===0?e.jsx("p",{className:"set-empty",children:i(o?"dshExtensionsNote":"noExtensions")}):e.jsx("div",{className:"set-list",children:a.extensions.map(p=>{const V=p.id.startsWith("npm:")?p.id.slice(4):null;return e.jsx(Re,{title:p.name,subtitle:p.path,enabled:p.enabled,onToggle:()=>f(p),action:V?d===p.id?e.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("uninstallConfirmHint"),onClick:()=>pe(V),children:i("uninstallConfirm")}):e.jsxs("button",{type:"button",className:"set-uninstall",title:i("uninstallHint"),onClick:()=>w(p.id),children:[e.jsx(Ae,{}),i("uninstallExt")]}):void 0},p.id)})})]}),u==="plugins"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Lt,{className:"set-section-icon"}),i("settingsUiPlugins"),e.jsx("span",{className:"set-count",children:t.plugins.length})]}),t.plugins.length===0?e.jsx("p",{className:"set-empty",children:i("noUiPlugins")}):e.jsx("div",{className:"set-list",children:t.plugins.map(p=>{var V;return e.jsxs(e.Fragment,{children:[e.jsx(Re,{title:`${p.icon?`${p.icon} `:""}${p.name}`,subtitle:(p.error?`${p.id} · ${p.error}`:p.source?`${p.id} · ${p.source}`:`${p.id} · ${i("uiPluginNoSource")}`)+((V=p.permissions)!=null&&V.length?` · ${i("uiPluginPerms")}: ${p.permissions.join(", ")}`:""),enabled:!Ee.has(p.id)&&!p.error,onToggle:()=>!p.error&&re(p),action:e.jsxs("div",{className:"set-row-actions",children:[p.source&&e.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUpdateHint"),onClick:()=>Me(p.id,p.source),children:[e.jsx(rt,{}),i("pluginUpdate")]}),h===p.id?e.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("pluginUninstallHint"),onClick:()=>ve(p.id),children:i("uninstallConfirm")}):e.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUninstallHint"),onClick:()=>I(p.id),children:[e.jsx(Ae,{}),i("uninstallExt")]})]})},p.id),p.settingsSchema&&p.settingsSchema.length>0&&e.jsx(Ml,{plugin:p,send:s})]})})})]}),u==="plugins"&&t.engine==="dsh"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Lt,{className:"set-section-icon"}),i("dshPatches"),e.jsx(Ke,{text:i("dshPatchesDesc")}),e.jsx("span",{className:"set-count",children:((P=t.dshPatches)==null?void 0:P.files.length)??0}),e.jsxs("button",{type:"button",className:"set-uninstall",title:i("dshPatchesRescanHint"),onClick:()=>s({type:"dsh_patches_rescan"}),children:[e.jsx(rt,{}),i("dshPatchesRescan")]})]}),(((ge=t.dshPatches)==null?void 0:ge.files.length)??0)===0?e.jsx("p",{className:"set-empty",children:i("dshPatchesEmpty")}):e.jsx("div",{className:"set-list",children:t.dshPatches.files.map(p=>e.jsx("div",{className:"set-row",children:e.jsxs("div",{className:"set-row-info",children:[e.jsx("div",{className:"set-row-name",children:p.name}),e.jsxs("div",{className:"set-row-desc",children:[Rl(p.size)," · ",new Date(p.mtimeMs).toLocaleString()]})]})},p.name))}),e.jsxs("p",{className:"set-hint",children:[i("dshPatchesPath")," ",((oe=t.dshPatches)==null?void 0:oe.patchDir)??""]})]}),u==="review"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(xt,{className:"set-section-icon"}),i("settingsReview"),e.jsx(Ke,{text:i("settingsReviewDesc")}),e.jsx("span",{className:"set-count",children:a.reviewSkills.length})]}),o&&e.jsx("p",{className:"set-hint",children:i("dshReviewPromptNote")}),e.jsx("textarea",{className:"set-prompt-input",rows:5,placeholder:i("reviewPromptPlaceholder"),value:J,onFocus:()=>E.current=!0,onBlur:()=>{E.current=!1,fe({reviewPrompt:J})},onChange:p=>U(p.target.value)}),e.jsx("div",{className:"set-field-label",children:i("settingsReviewSkills")}),a.reviewSkills.length===0?e.jsx("p",{className:"set-empty",children:i("noSkills")}):e.jsx("div",{className:"set-list",children:a.reviewSkills.map(p=>e.jsx(Re,{title:p.name,subtitle:p.description,enabled:p.enabled,onToggle:()=>he(p)},`review-${p.name}`))})]}),u==="vision"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Qt,{className:"set-section-icon"}),i("settingsVisionBridge")]}),e.jsx(Re,{title:i("visionBridgeEnabled"),tip:i("settingsVisionBridgeDesc"),enabled:a.visionBridgeEnabled,onToggle:()=>fe({visionBridgeEnabled:!a.visionBridgeEnabled})}),!a.visionBridgeEnabled&&e.jsx("p",{className:"set-hint",children:i("visionBridgeOffHint")}),a.visionBridgeEnabled&&e.jsxs("div",{className:"set-mode-row",children:[e.jsx("label",{className:"set-field-label",children:i("visionBridgeModel")}),e.jsxs("select",{className:"set-select",value:a.visionBridgeModel??"",onChange:p=>fe({visionBridgeModel:p.target.value||null}),children:[e.jsx("option",{value:"",children:i("visionBridgeAuto")}),a.visionModels.map(p=>e.jsx("option",{value:`${p.provider}/${p.id}`,children:p.label},`${p.provider}/${p.id}`))]})]}),a.visionBridgeEnabled&&e.jsxs("div",{className:"set-mode-row",children:[e.jsx("label",{className:"set-field-label",children:i("visionBridgePromptMode")}),e.jsxs("select",{className:"set-select",value:j,onChange:p=>{const V=p.target.value;Q(V),fe({visionBridgePromptMode:V})},children:[e.jsx("option",{value:"append",children:i("promptModeAppend")}),e.jsx("option",{value:"replace",children:i("promptModeReplace")})]})]}),a.visionBridgeEnabled&&e.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:i("visionBridgePromptPlaceholder"),value:K,onFocus:()=>G.current=!0,onBlur:()=>{G.current=!1;const p=j==="replace"&&a.visionBridgeDefaultPrompt&&K===a.visionBridgeDefaultPrompt?"":K;fe({visionBridgePromptMode:j,visionBridgePrompt:p})},onChange:p=>S(p.target.value)}),a.visionBridgeEnabled&&(a.visionModels.length===0?e.jsx("p",{className:"set-hint",children:i("visionBridgeNoModels")}):e.jsx("p",{className:"set-hint",children:i("visionBridgeCurrent",{model:a.visionBridgeModel??i("visionBridgeAuto")})}))]}),u==="presets"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(wt,{className:"set-section-icon"}),i("settingsPresets"),e.jsx("span",{className:"set-count",children:a.presets.length})]}),e.jsxs("div",{className:"set-preset-save",children:[e.jsx("input",{className:"set-input",placeholder:i("presetNamePlaceholder"),value:H,onChange:p=>k(p.target.value),onKeyDown:p=>{p.key==="Enter"&&H.trim()&&(s({type:"save_preset",name:H.trim()}),k(""))}}),e.jsxs("button",{type:"button",className:"set-save-btn",disabled:!H.trim(),onClick:()=>{s({type:"save_preset",name:H.trim()}),k("")},children:[e.jsx(He,{})," ",i("saveAsPreset")]})]}),a.presets.length===0?e.jsx("p",{className:"set-empty",children:i("noPresets")}):e.jsx("div",{className:"set-list",children:a.presets.map(p=>e.jsxs("div",{className:"set-row",children:[e.jsxs("div",{className:"set-row-info",children:[e.jsx("div",{className:"set-row-name",children:p.name}),e.jsxs("div",{className:"set-row-desc",children:[p.promptMode==="replace"?i("promptModeReplace"):i("promptModeAppend"),p.disabledSkills.length>0&&` · ${i("settingsSkills")} ${p.disabledSkills.length}`,p.disabledExtensions.length>0&&` · ${i("settingsExtensions")} ${p.disabledExtensions.length}`]})]}),e.jsxs("div",{className:"set-row-actions",children:[e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>s({type:"apply_preset",name:p.name}),children:i("applyPreset")}),e.jsx("button",{type:"button",className:"set-icon-btn danger",title:i("deletePreset"),onClick:()=>s({type:"delete_preset",name:p.name}),children:e.jsx(Ae,{})})]})]},p.name))})]}),u==="subagent-templates"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Rs,{className:"set-section-icon"}),i("settingsSubagentTemplates"),e.jsx(Ke,{text:i("settingsSubagentTemplatesDesc")}),e.jsx("span",{className:"set-count",children:a.subagentTemplates.length}),e.jsxs("button",{type:"button",className:"set-save-btn",title:i("subagentTemplateNew"),onClick:()=>F({name:"",description:"",promptMode:"replace",systemPrompt:"",enabledSkills:[],enabledExtensions:[],enabled:!0}),children:[e.jsx(He,{})," ",i("subagentTemplateNew")]})]}),_&&e.jsxs("div",{className:"tpl-editor",children:[e.jsxs("div",{className:"tpl-fields",children:[e.jsx("input",{className:"set-input",placeholder:i("tplNamePlaceholder"),value:_.name,onChange:p=>F({..._,name:p.target.value})}),e.jsx("input",{className:"set-input",placeholder:i("tplDescriptionPlaceholder"),value:_.description,onChange:p=>F({..._,description:p.target.value})})]}),e.jsxs("div",{className:"set-mode-row",children:[e.jsx("label",{className:"set-field-label",children:i("tplPromptModeLabel")}),e.jsxs("select",{className:"set-select",value:_.promptMode,onChange:p=>F({..._,promptMode:p.target.value}),children:[e.jsx("option",{value:"replace",children:i("promptModeReplace")}),e.jsx("option",{value:"append",children:i("promptModeAppend")})]})]}),e.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:`${i("tplSystemPromptLabel")}:${i("tplSystemPromptPlaceholder")}`,value:_.systemPrompt,onChange:p=>F({..._,systemPrompt:p.target.value})}),e.jsxs("div",{className:"tpl-pick-block",children:[e.jsx("div",{className:"tpl-pick-head",children:e.jsxs("span",{children:[i("tplSkillsLabel")," · ",i("tplWhitelistHint")]})}),a.skills.length===0?e.jsx("p",{className:"set-hint",children:i("noSkills")}):e.jsx("div",{className:"tpl-pick",children:a.skills.map(p=>e.jsxs("label",{className:`tpl-chip${_.enabledSkills.includes(p.name)?" on":""}`,children:[e.jsx("input",{type:"checkbox",checked:_.enabledSkills.includes(p.name),onChange:V=>{const N=V.target.checked;F({..._,enabledSkills:N?[..._.enabledSkills,p.name]:_.enabledSkills.filter(A=>A!==p.name)})}}),p.name]},p.name))})]}),e.jsxs("div",{className:"tpl-pick-block",children:[e.jsx("div",{className:"tpl-pick-head",children:e.jsxs("span",{children:[i("tplExtensionsLabel")," · ",i("tplWhitelistHint")]})}),a.extensions.length===0?e.jsx("p",{className:"set-hint",children:i("noExtensions")}):e.jsx("div",{className:"tpl-pick",children:a.extensions.map(p=>e.jsxs("label",{className:`tpl-chip${_.enabledExtensions.includes(p.id)?" on":""}`,children:[e.jsx("input",{type:"checkbox",checked:_.enabledExtensions.includes(p.id),onChange:V=>{const N=V.target.checked;F({..._,enabledExtensions:N?[..._.enabledExtensions,p.id]:_.enabledExtensions.filter(A=>A!==p.id)})}}),p.name]},p.id))})]}),e.jsxs("div",{className:"tpl-actions",children:[e.jsx("button",{type:"button",className:"set-save-btn",disabled:!_.name.trim(),onClick:()=>{s({type:"save_subagent_template",template:{..._,name:_.name.trim()}}),F(null)},children:i("tplSave")}),e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>F(null),children:i("tplCancel")})]})]}),a.subagentTemplates.length===0?e.jsx("p",{className:"set-empty",children:i("noSubagentTemplates")}):e.jsx("div",{className:"set-list",children:a.subagentTemplates.map(p=>e.jsxs("div",{className:"set-row",children:[e.jsxs("div",{className:"set-row-info",children:[e.jsxs("div",{className:"set-row-name",children:[p.name,a.subagentDefaultTemplates.includes(p.name)&&e.jsx("span",{className:"tpl-badge default",children:i("tplDefaultBadge")}),!p.enabled&&e.jsx("span",{className:"tpl-badge",children:i("subagentTemplateClosed")})]}),e.jsxs("div",{className:"set-row-desc",children:[p.description||`${p.promptMode==="replace"?i("promptModeReplace"):i("promptModeAppend")}`,p.enabledSkills.length>0&&` · ${i("tplSkillsLabel")} ${p.enabledSkills.length}`,p.enabledExtensions.length>0&&` · ${i("tplExtensionsLabel")} ${p.enabledExtensions.length}`,!p.description&&p.enabledSkills.length===0&&p.enabledExtensions.length===0&&` · ${i("tplInherit")}`]})]}),e.jsxs("div",{className:"set-row-actions",children:[e.jsx("button",{type:"button",className:`set-switch${p.enabled?" on":""}`,role:"switch","aria-checked":p.enabled,title:`${p.enabled?i("subagentTemplateDisable"):i("subagentTemplateEnable")} · ${i("subagentTemplateOffHint")}`,onClick:()=>s({type:"save_subagent_template",template:{...p,enabled:!p.enabled}}),children:e.jsx("span",{className:"set-switch-knob"})}),e.jsx("button",{type:"button",className:"dd-refresh",title:i("subagentTemplateEdit"),onClick:()=>F({...p}),children:i("subagentTemplateEdit")}),Z===p.name?e.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("uninstallConfirmHint"),onClick:()=>{s({type:"delete_subagent_template",name:p.name}),$(null)},children:i("uninstallConfirm")}):e.jsx("button",{type:"button",className:"set-icon-btn danger",title:i("tplDelete"),onClick:()=>$(p.name),children:e.jsx(Ae,{})})]})]},p.name))})]})]})]}),e.jsx("div",{className:"modal-actions",children:e.jsx("button",{type:"button",className:"dd-refresh",onClick:c,children:i("close")})})]})})}function Ll(t,s){const n=Math.max(0,Date.now()-t),r=Math.floor(n/6e4);if(r<1)return s("bgTaskJustNow");if(r<60)return s("bgTaskMinutes",{n:r});const c=Math.floor(r/60);return c<24?s("bgTaskHours",{n:c}):s("bgTaskDays",{n:Math.floor(c/24)})}function Dl({servers:t,send:s,onClose:n}){const r=xe(),[c,i]=l.useState(new Set),a=o=>i(u=>{const m=new Set(u);return m.has(o)?m.delete(o):m.add(o),m});return l.useEffect(()=>{s({type:"list_bg_servers"})},[]),e.jsx("div",{className:"modal-backdrop",onClick:n,children:e.jsxs("div",{className:"bg-task-modal",onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"bg-task-head",children:[e.jsxs("span",{className:"bg-task-title",children:[e.jsx(Ct,{})," ",r("bgTasks"),t.length>0&&e.jsx("em",{className:"bg-task-count",children:t.length})]}),e.jsx("button",{type:"button",className:"btn",title:r("close"),onClick:n,children:e.jsx(Pe,{})})]}),t.length===0?e.jsxs("div",{className:"bg-task-empty",children:[e.jsx(Ct,{}),e.jsx("span",{children:r("bgTasksEmpty")}),e.jsx("small",{children:r("bgTasksDesc")})]}):e.jsx("ul",{className:"bg-task-list",children:t.map(o=>{const u=!!o.taskId,m=o.taskId??String(o.port);return e.jsxs("li",{className:"bg-task-item",children:[e.jsx("span",{className:"bg-task-icon",title:u?o.plugin:r("bgTaskPort")}),e.jsxs("div",{className:"bg-task-info",children:[e.jsxs("div",{className:"bg-task-line1",children:[u?e.jsxs("span",{className:"bg-task-port",title:o.taskId,children:["🧩 ",o.plugin]}):e.jsxs("span",{className:"bg-task-port",children:[":",o.port]}),o.name&&e.jsx("span",{className:"bg-task-name",children:o.name})]}),e.jsxs("div",{className:"bg-task-line2",children:[!u&&e.jsxs("span",{children:[r("bgTaskPid")," ",o.pid]}),e.jsxs("span",{children:[r("bgTaskSince")," ",Ll(o.since,r)]}),u&&o.status&&e.jsx("span",{className:"bg-task-status",children:o.status})]}),o.command&&e.jsxs("button",{type:"button",className:`bg-task-cmd ${c.has(m)?"open":""}`,title:`${r("bgTaskCommand")}: ${o.command}`,onClick:()=>a(m),children:[e.jsx(tt,{}),e.jsx("code",{children:o.command})]})]}),e.jsxs("button",{type:"button",className:"btn bg-task-stop",title:r("bgTaskStop"),onClick:()=>s(u?{type:"kill_background_server",taskId:o.taskId}:{type:"kill_background_server",port:o.port}),children:[e.jsx(jt,{}),e.jsx("span",{children:r("bgTaskStop")})]})]},m)})}),e.jsxs("div",{className:"bg-task-foot",children:[e.jsxs("button",{type:"button",className:"btn",title:r("bgTaskRefresh"),onClick:()=>s({type:"list_bg_servers"}),children:[e.jsx(rt,{}),e.jsx("span",{children:r("bgTaskRefresh")})]}),e.jsxs("button",{type:"button",className:"btn bg-task-stopall",disabled:t.length===0,title:r("bgTaskStopAll"),onClick:()=>s({type:"kill_background_servers"}),children:[e.jsx(jt,{}),e.jsx("span",{children:r("bgTaskStopAll")})]})]})]})})}function Al(t,s){return t.toLowerCase().includes(s)}function _l({open:t,send:s,projects:n,cwd:r,fileSearch:c,sessionSearch:i,onClose:a,onSwitchSession:o,onSwitchProject:u,onPreviewFile:m}){const y=xe(),g=l.useRef(null),[x,b]=l.useState(""),T=l.useDeferredValue(x),[D,K]=l.useState(0),S=l.useRef(1),j=l.useRef(0),Q=l.useRef(null);l.useEffect(()=>{if(!t)return;s({type:"list_sessions"}),s({type:"list_projects"});const M=x.trim();if(M){const R=++S.current;j.current=R,J(!0),s({type:"search_files",reqId:R,query:M}),s({type:"search_sessions",reqId:R,query:M})}requestAnimationFrame(()=>{var R;return(R=g.current)==null?void 0:R.select()})},[t]);const[G,J]=l.useState(!1);l.useEffect(()=>{Q.current&&clearTimeout(Q.current);const M=T.trim();if(!M){J(!1);return}return Q.current=setTimeout(()=>{const R=++S.current;j.current=R,J(!0),s({type:"search_files",reqId:R,query:M}),s({type:"search_sessions",reqId:R,query:M})},300),()=>{Q.current&&clearTimeout(Q.current)}},[T]);const U=T.trim().toLowerCase(),E=l.useMemo(()=>!U||!i||i.reqId!==j.current||!i.ok?[]:i.results,[i,U]),H=l.useMemo(()=>U?n.filter(M=>Al(M.path,U)).slice(0,10):[],[n,U]),k=l.useMemo(()=>!U||!c||c.reqId!==j.current||!c.ok?[]:c.results,[c,U]);l.useEffect(()=>{c&&c.reqId===j.current&&i&&i.reqId===j.current&&j.current!==0&&J(!1)},[c,i]);const _=!!c&&c.ok&&c.truncated,F=l.useMemo(()=>[...E.map(M=>({kind:"session",path:M.path,anchors:M.anchors})),...H.map(M=>({kind:"project",path:M.path})),...k.filter(M=>M.type==="file").map(M=>({kind:"file",path:M.path,name:M.name}))],[E,H,k]);l.useEffect(()=>{K(0)},[T]);const Z=l.useCallback(M=>{if(M)if(M.kind==="session")o(M.path,M.anchors),a();else if(M.kind==="project"){u(M.path),s({type:"list_sessions"}),s({type:"list_projects"});const R=T.trim();if(R){const C=++S.current;j.current=C,J(!0),s({type:"search_files",reqId:C,query:R}),s({type:"search_sessions",reqId:C,query:R})}}else m(M.path,M.name)},[o,u,m,s,T]);l.useEffect(()=>{if(!t)return;const M=R=>{R.key==="Escape"?(R.preventDefault(),R.stopPropagation(),a()):R.key==="ArrowDown"?(R.preventDefault(),K(C=>Math.min(C+1,F.length-1))):R.key==="ArrowUp"?(R.preventDefault(),K(C=>Math.max(C-1,0))):R.key==="Enter"&&(R.preventDefault(),Z(F[D]))};return window.addEventListener("keydown",M,!0),()=>window.removeEventListener("keydown",M,!0)},[F,D,Z,a,t]);const $=E.length+H.length+k.length,X=(M,R,C)=>e.jsxs("div",{className:"gs-section-head",children:[C,e.jsx("span",{children:M}),e.jsx("em",{children:R})]});let Y=-1;return t?e.jsx("div",{className:"modal-backdrop gs-backdrop",onClick:a,children:e.jsxs("div",{className:"gs-modal",onClick:M=>M.stopPropagation(),children:[e.jsxs("div",{className:"gs-input-row",children:[e.jsx(Nt,{}),e.jsx("input",{ref:g,type:"text",value:x,placeholder:y("gsPlaceholder"),onChange:M=>b(M.target.value)}),e.jsx("button",{type:"button",className:"gs-close",title:y("close"),onClick:a,children:e.jsx(Pe,{})})]}),e.jsxs("div",{className:"gs-results",children:[!U&&e.jsx("div",{className:"gs-empty",children:y("gsHint")}),U&&$===0&&!_&&e.jsx("div",{className:"gs-empty",children:y(G?"gsSearching":"gsNoResults")}),E.length>0&&e.jsxs("div",{className:"gs-section",children:[X(y("gsSessions"),E.length,e.jsx(st,{})),E.map(M=>{Y++;const R=Y;return e.jsxs("button",{type:"button",className:R===D?"gs-item active":"gs-item",onMouseEnter:()=>K(R),onClick:()=>Z({kind:"session",path:M.path,anchors:M.anchors}),children:[e.jsxs("span",{className:"gs-item-title",children:[M.name||M.path.split(/[\\/]/).pop(),e.jsx("em",{className:"gs-item-meta",children:M.messageCount})]}),e.jsx("span",{className:"gs-item-sub",children:M.firstMessage})]},M.path)})]}),H.length>0&&e.jsxs("div",{className:"gs-section",children:[X(y("gsProjects"),H.length,e.jsx(Je,{})),H.map(M=>{Y++;const R=Y,C=r&&M.path===r;return e.jsxs("button",{type:"button",className:R===D?"gs-item active":"gs-item",onMouseEnter:()=>K(R),onClick:()=>Z({kind:"project",path:M.path}),children:[e.jsxs("span",{className:"gs-item-title",children:[M.path.split(/[\\/]/).pop(),C&&e.jsx("em",{className:"gs-item-meta",children:y("gsCurrentProject")})]}),e.jsx("span",{className:"gs-item-sub",children:M.path})]},M.path)})]}),(k.length>0||U&&_)&&e.jsxs("div",{className:"gs-section",children:[X(y("gsFiles"),k.length,e.jsx(bn,{})),k.map(M=>{Y++;const R=Y;return e.jsxs("button",{type:"button",className:R===D?"gs-item active":"gs-item",disabled:M.type==="dir",title:M.type==="dir"?void 0:y("gsOpenPreview"),onMouseEnter:()=>K(R),onClick:()=>{M.type==="file"&&Z({kind:"file",path:M.path,name:M.name})},children:[e.jsx("span",{className:"gs-item-title",children:M.name}),e.jsx("span",{className:"gs-item-sub",children:M.path})]},`${M.type}:${M.path}`)}),_&&e.jsx("div",{className:"gs-truncated",children:y("gsTruncated")})]})]}),e.jsxs("div",{className:"gs-foot",children:[e.jsxs("span",{children:["↑↓ ",y("gsNavigate")]}),e.jsxs("span",{children:["Enter ",y("gsOpen")]}),e.jsxs("span",{children:["Esc ",y("gsCloseHint")]})]})]})}):null}const zt=5e3;function Bl({file:t,content:s,send:n,onAddLines:r,onAttach:c,onClose:i}){const a=xe(),[o,u]=l.useState(null),[m,y]=l.useState(!1),[g,x]=l.useState(null),[b,T]=l.useState(!1),[D,K]=l.useState(!1),[S,j]=l.useState(!1),[Q,G]=l.useState(""),[J,U]=l.useState(!0),E=l.useRef(!1),[H,k]=l.useState(!0),[_,F]=l.useState(!1),[Z,$]=l.useState(100),X=l.useRef(0),Y=l.useRef(!1),M=l.useRef(null);l.useEffect(()=>{y(!0),u(null),x(null),j(!1),G(""),U(!0),E.current=!1,n({type:"read_file",path:t.path})},[t.path,n]),l.useEffect(()=>{s&&s.path===t.path&&(u(s),S||G(s.text),y(!1))},[s,S,t.path]),l.useEffect(()=>{const re=f=>{if(f.key==="Escape"){I();return}if((f.ctrlKey||f.metaKey)&&f.key.toLowerCase()==="s"&&S){f.preventDefault(),h();return}const W=f.target,de=W&&(W.tagName==="INPUT"||W.tagName==="TEXTAREA"||W.isContentEditable);(f.ctrlKey||f.metaKey)&&f.key.toLowerCase()==="a"&&!de&&(f.preventDefault(),ne())};return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[i,o,S,Q]),l.useEffect(()=>{const re=()=>{Y.current=!1,T(!1)};return window.addEventListener("mouseup",re),()=>window.removeEventListener("mouseup",re)},[]);const R=l.useMemo(()=>{if(!o)return[];const re=o.text.split(`
|
|
326
|
-
`);return re.length>0&&re[re.length-1]===""&&re.pop(),re.slice(0,zt)},[o]),C=(o==null?void 0:o.lines)??0,O=C>zt,z=(re,f)=>{if(f){const W=X.current>0?X.current:re;x({start:Math.min(W,re),end:Math.max(W,re)})}else X.current=re,x({start:re,end:re})},ne=()=>{R.length!==0&&(X.current=1,x({start:1,end:R.length}))},v=()=>{g&&(r(t.path,t.name,g.start,g.end),K(!0),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>K(!1),1400))},L=o!==null&&o.kind==="text"&&!o.binary&&!o.truncated,d=()=>{G((o==null?void 0:o.text)??""),j(!1),E.current&&U(!0)},w=()=>{if(S){if(Q!==((o==null?void 0:o.text)??"")&&!window.confirm(a("discardFileChanges")))return;d();return}!L||!o||(E.current=Vt(t.name)&&J,Vt(t.name)&&U(!1),x(null),G(o.text),j(!0))},h=()=>{!S||!o||!L||n({type:"write_file",path:t.path,text:Q})&&(j(!1),E.current&&U(!0),x(null))},I=()=>{S&&Q!==((o==null?void 0:o.text)??"")&&!window.confirm(a("discardFileChanges"))||i()},ee=re=>{$(Math.min(200,Math.max(50,re)))},q=g?g.end-g.start+1:0,ae=(o==null?void 0:o.binary)??!1,ye=(o==null?void 0:o.truncated)??!1,ke=(o==null?void 0:o.kind)??"text",fe=Vt(t.name),be=fe&&J&&!S&&ke==="text"&&!ae,Ee=re=>Mt(Ve(`/api/file?clientId=${encodeURIComponent(os())}&path=${encodeURIComponent(re)}`));return e.jsx("div",{className:`fp-overlay ${_?"fullscreen":""}`,onMouseDown:re=>{re.target===re.currentTarget&&I()},children:e.jsxs("div",{className:`fp ${_?"fullscreen":""}`,style:{"--fp-zoom":Z/100},children:[e.jsxs("div",{className:"fp-head",children:[e.jsx("span",{className:"fp-name",title:t.path,children:t.name}),e.jsx("span",{className:"fp-path",children:t.path}),e.jsxs("span",{className:"fp-meta",children:[o&&ke==="text"&&!ae&&a("fileLines",{n:C}),o&&` · ${Fl(o.size)}`]}),e.jsxs("span",{className:"fp-head-actions",children:[fe&&ke==="text"&&!ae&&o&&e.jsx("button",{type:"button",className:`fp-attach markdown ${J?"on":""}`,"data-tip":a(J?"showMarkdownSource":"showMarkdownPreview"),disabled:S,onClick:()=>U(re=>!re),children:J?e.jsx(Qt,{}):e.jsx(Gi,{})}),ke==="text"&&!ae&&o&&e.jsx("button",{type:"button",className:`fp-attach edit ${S?"on":""}`,"data-tip":a(ye?"fileEditTruncated":S?"exitEditFile":"editFile"),disabled:!L&&!S,onClick:w,children:e.jsx(Yt,{})}),ke==="text"&&!ae&&!be&&e.jsx("button",{type:"button",className:`fp-attach wrap ${H?"on":""}`,"data-tip":a(H?"disableWrap":"enableWrap"),onClick:()=>k(re=>!re),children:e.jsx(Vi,{})}),ke==="text"&&o&&e.jsxs("span",{className:"fp-zoom",children:[e.jsx("button",{type:"button",className:"fp-attach zoom-out","data-tip":a("zoomOut"),disabled:Z<=50,onClick:()=>ee(Z-10),children:e.jsx(Ei,{})}),e.jsxs("button",{type:"button",className:"fp-zoom-val",title:a("resetZoom"),onClick:()=>$(100),children:[Z,"%"]}),e.jsx("button",{type:"button",className:"fp-attach zoom-in","data-tip":a("zoomIn"),disabled:Z>=200,onClick:()=>ee(Z+10),children:e.jsx(Pi,{})})]}),ke!=="video"&&ke!=="none"&&e.jsx("button",{type:"button",className:"fp-attach inline","data-tip":a("attachInlineTip"),onClick:()=>c(t.path,t.name,"inline"),children:e.jsx(He,{})}),e.jsx("button",{type:"button",className:"fp-attach ref","data-tip":a("referenceTip"),onClick:()=>c(t.path,t.name,"reference"),children:e.jsx(Gt,{})}),e.jsx("button",{type:"button",className:`fp-attach full ${_?"on":""}`,"data-tip":a(_?"exitFullscreen":"fullscreen"),onClick:()=>F(re=>!re),children:_?e.jsx(Bi,{}):e.jsx($i,{})}),e.jsx("button",{type:"button",className:"fp-close",title:a("close"),onClick:I,children:e.jsx(Pe,{})})]})]}),ye&&ke==="text"&&!ae&&e.jsx("div",{className:"fp-notice",children:a("previewTruncated")}),m&&!o&&e.jsx("div",{className:"fp-empty",children:a("loading")}),!m&&ke==="none"&&!ae&&e.jsx("div",{className:"fp-empty",children:a("previewNotSupported")}),!m&&ke==="image"&&e.jsx("div",{className:"fp-media-wrap",children:e.jsx("img",{className:"fp-media",src:Ee(t.path),alt:t.name})}),!m&&ke==="video"&&e.jsx("div",{className:"fp-media-wrap",children:e.jsx("video",{className:"fp-media",src:Ee(t.path),controls:!0,preload:"metadata"})}),!m&&be&&o&&e.jsx("div",{className:"fp-markdown msg-text",children:e.jsx("div",{className:"fp-markdown-zoom",children:e.jsx(Rt,{text:o.text})})}),!m&&ae&&ke!=="image"&&ke!=="video"&&o&&e.jsxs("div",{className:"fp-hex-wrap",children:[e.jsxs("div",{className:"fp-notice",children:[a("binaryFile"),o.truncated&&a("binaryHexTruncated")]}),e.jsx("pre",{className:"fp-hex",children:o.text})]}),!m&&S&&ke==="text"&&!ae&&o&&e.jsx("textarea",{className:`fp-editor ${H?"":"no-wrap"}`,value:Q,onChange:re=>G(re.target.value),wrap:H?"soft":"off",spellCheck:!1,autoFocus:!0}),!m&&!be&&!S&&ke==="text"&&!ae&&o&&R.length===0&&e.jsx("div",{className:"fp-empty",children:a("emptyFile")}),!m&&!be&&!S&&ke==="text"&&!ae&&R.length>0&&e.jsxs("div",{className:`fp-code ${b?"dragging":""} ${H?"":"no-wrap"}`,onMouseDown:re=>{re.button===0&&re.preventDefault()},children:[R.map((re,f)=>{const W=f+1,de=g!==null&&W>=g.start&&W<=g.end;return e.jsxs("div",{className:`fp-line ${de?"sel":""}`,onMouseDown:ue=>{ue.button===0&&(z(W,ue.shiftKey),Y.current=!0,T(!0))},onMouseEnter:()=>{Y.current&&z(W,!0)},children:[e.jsx("span",{className:"fp-num",children:W}),e.jsx("span",{className:"fp-code-text",children:re})]},W)}),O&&e.jsx("div",{className:"fp-lines-note",children:a("previewLinesTruncated",{n:zt})})]}),e.jsx("div",{className:"fp-foot",children:S?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"fp-hint",children:a("editFile")}),e.jsxs("div",{className:"fp-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:w,children:a("cancel")}),e.jsxs("button",{type:"button",className:"btn primary",disabled:Q===((o==null?void 0:o.text)??""),onClick:h,children:[e.jsx(Di,{})," ",a("saveFile")]})]})]}):!be&&ke==="text"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"fp-hint",children:g?a("selectedRange",{n:q,start:g.start,end:g.end}):a("selectLinesHint")}),e.jsxs("div",{className:"fp-actions",children:[e.jsx("button",{type:"button",className:"btn",disabled:R.length===0,onClick:ne,children:a("selectAll")}),e.jsx("button",{type:"button",className:"btn",disabled:!g,onClick:()=>x(null),children:a("clearSelection")}),e.jsxs("button",{type:"button",className:"btn primary",disabled:!g||ae,onClick:v,children:[D?e.jsx(pt,{}):null,a(D?"addedToChat":"addToChat")]})]})]})})]})})}function Vt(t){const s=t.toLowerCase();return s.endsWith(".md")||s.endsWith(".markdown")}function Fl(t){return t>=1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:t>=1024?`${Math.round(t/1024)} KB`:`${t} B`}const ai="pi-web-sounds",nt={enabled:!0,question:!0,done:!0,start:!1,error:!0,volume:100};function ri(){try{const t=localStorage.getItem(ai);if(!t)return{...nt};const s=JSON.parse(t),n={...nt,...s};for(const r of["enabled","question","done","start","error"])typeof n[r]!="boolean"&&(n[r]=nt[r]);return typeof n.volume!="number"||!Number.isFinite(n.volume)?n.volume=nt.volume:n.volume=Math.round(Math.max(0,Math.min(100,n.volume))/5)*5,n}catch{return{...nt}}}function $l(t){try{localStorage.setItem(ai,JSON.stringify(t))}catch{}}let it=null;function Hl(){try{if(!it){const t=window.AudioContext??window.webkitAudioContext;if(!t)return null;it=new t}return it.state==="suspended"&&it.resume(),it}catch{return null}}const Ol=[{type:"sine",freq:587.33,start:0,dur:.13,peak:.5},{type:"sine",freq:880,start:.11,dur:.24,peak:.5}],Kl=[{type:"sine",freq:880,start:0,dur:.15,peak:.35},{type:"sine",freq:587.33,start:.15,dur:.32,peak:.35}],Wl=[{type:"triangle",freq:660,start:0,dur:.08,peak:.22}],Ul=[{type:"square",freq:220,start:0,dur:.16,peak:.18},{type:"square",freq:174.61,start:.18,dur:.26,peak:.18}],ql={question:Ol,done:Kl,start:Wl,error:Ul};function zl(t,s,n){const r=t.createOscillator(),c=t.createGain();r.type=s.type,r.frequency.value=s.freq;const i=t.currentTime+s.start,a=Math.max(1e-4,s.peak*n);c.gain.setValueAtTime(1e-4,i),c.gain.exponentialRampToValueAtTime(a,i+.012),c.gain.exponentialRampToValueAtTime(1e-4,i+s.dur),r.connect(c),c.connect(t.destination),r.start(i),r.stop(i+s.dur+.05)}function at(t,s=ri()){if(!s.enabled||!s[t])return;const n=Hl();if(!n)return;const r=Math.max(0,Math.min(1,s.volume/100));for(const c of ql[t])zl(n,c,r)}const as="pi-web-ui:theme",li="dark",on="theme-stylesheet",cn="pi-web-ui:theme-change";function oi(){try{const t=localStorage.getItem(as);if(t&&t!==li)return t}catch{}return null}function Vl(t){try{t?localStorage.setItem(as,t):localStorage.removeItem(as)}catch{}}function ci(t){let s=document.getElementById(on);if(!t){s==null||s.remove(),window.dispatchEvent(new CustomEvent(cn));return}s||(s=document.createElement("link"),s.id=on,s.rel="stylesheet",document.head.appendChild(s)),s.href=Ve(`/themes/${encodeURIComponent(t)}.css`),s.onload=()=>window.dispatchEvent(new CustomEvent(cn))}async function Gl(){try{const t=await fetch(Mt(Ve("/api/themes")));if(!t.ok)return[];const s=await t.json();return Array.isArray(s.themes)?s.themes:[]}catch{return[]}}function Ql(){const[t,s]=l.useState([]),[n,r]=l.useState(()=>oi());return l.useEffect(()=>{let i=!1;return Gl().then(a=>{i||s(a)}),()=>{i=!0}},[]),l.useEffect(()=>{ci(n),Vl(n)},[n]),{themes:t,theme:n,switchTheme:i=>r(i===li?null:i)}}function no(){const t=getComputedStyle(document.documentElement),s=(n,r)=>t.getPropertyValue(n).trim()||r;return{background:s("--term-bg","#0b0d12"),foreground:s("--term-fg","#e6e8ef"),cursor:s("--term-cursor","#8b5cf6"),cursorAccent:s("--term-cursor-accent","#0b0d12"),selectionBackground:s("--term-selection","rgba(139, 92, 246, 0.35)"),black:s("--term-black","#1a1d26"),red:s("--term-red","#f87171"),green:s("--term-green","#34d399"),yellow:s("--term-yellow","#fbbf24"),blue:s("--term-blue","#60a5fa"),magenta:s("--term-magenta","#c084fc"),cyan:s("--term-cyan","#22d3ee"),white:s("--term-white","#e6e8ef"),brightBlack:s("--term-bright-black","#6b7284"),brightRed:s("--term-bright-red","#f87171"),brightGreen:s("--term-bright-green","#34d399"),brightYellow:s("--term-bright-yellow","#fbbf24"),brightBlue:s("--term-bright-blue","#60a5fa"),brightMagenta:s("--term-bright-magenta","#c084fc"),brightCyan:s("--term-bright-cyan","#22d3ee"),brightWhite:s("--term-bright-white","#ffffff")}}const Yl=l.lazy(()=>gn(()=>import("./TerminalPanel-D6-kd9NX.js"),__vite__mapDeps([2,1,3,4,5])).then(t=>({default:t.TerminalPanel})));function Jl({notice:t,onDismiss:s}){const n=xe(),{locale:r}=mt(),c=r==="en"&&t.textEn?t.textEn:t.text,[i,a]=l.useState(!1);l.useEffect(()=>{if(i)return;const u=setTimeout(()=>s(t.id),t.level==="error"?12e3:7e3);return()=>clearTimeout(u)},[i,t.id,t.level,s]);const o=t.level==="error"?ea:t.level==="warning"?Zi:Ki;return e.jsxs("div",{className:`notice notice-${t.level}${i?" paused":""}`,role:"status",onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[e.jsx(o,{className:"notice-icon"}),e.jsx("span",{className:"notice-text",children:c}),e.jsx("button",{type:"button",className:"notice-close",title:n("close"),onClick:()=>s(t.id),children:e.jsx(Pe,{})})]})}const Xl=[],di=180,ui=520,pi=240,mi=t=>`pi-web-ui:${t}-panel-width`;function dn(t){const s=Number(localStorage.getItem(mi(t)));return Number.isFinite(s)&&s>=di&&s<=ui?s:pi}const rs=t=>`pi-web-ui:${t}-panel-collapsed`;function un(t){return localStorage.getItem(rs(t))==="1"}function pn({side:t,width:s,onResize:n}){const r=xe(),c=l.useCallback(i=>{i.preventDefault();const a=i.clientX,o=s;let u=o;const m=g=>{const x=t==="left"?g.clientX-a:a-g.clientX;u=Math.min(ui,Math.max(di,Math.round(o+x))),n(u)},y=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",y),document.body.classList.remove("panel-resizing"),localStorage.setItem(mi(t),String(u))};window.addEventListener("pointermove",m),window.addEventListener("pointerup",y),document.body.classList.add("panel-resizing")},[t,s,n]);return e.jsx("div",{className:`resize-handle resize-${t}`,title:r("dragToResize"),onPointerDown:c,onDoubleClick:()=>n(pi)})}function mn({side:t,onClick:s}){const n=xe();return e.jsx("button",{type:"button",className:`panel-rail panel-rail-${t}`,title:n("expandPanel"),onClick:s,children:t==="left"?e.jsx(wn,{}):e.jsx(Nn,{})})}function Zl(){var Oe,ms,hs,gs,fs,xs,ys,vs,ks,bs,js,ws,Ns,Cs;const t=xe(),{chat:s,send:n,dismissNotice:r,pushNotice:c,terminal:i}=Ia(),[a,o]=l.useState([]),[u,m]=l.useState(null),[y,g]=l.useState(!1),[x,b]=l.useState("chat"),T=l.useMemo(()=>s.plugins.filter(B=>{var te,ce;return!((ce=(te=s.settings)==null?void 0:te.disabledPlugins)!=null&&ce.includes(B.id))}),[s.plugins,(Oe=s.settings)==null?void 0:Oe.disabledPlugins]),[D,K]=l.useState([]);l.useEffect(()=>ja(K),[]),l.useEffect(()=>{wa(T,s.pluginsEpoch)},[T,s.pluginsEpoch]);const[S,j]=l.useState(()=>dn("left")),[Q,G]=l.useState(()=>dn("right")),J=l.useCallback(B=>j(B),[]),U=l.useCallback(B=>G(B),[]),[E,H]=l.useState(()=>un("left")),[k,_]=l.useState(()=>un("right")),F=l.useCallback(()=>{H(B=>(localStorage.setItem(rs("left"),B?"0":"1"),!B))},[]),Z=l.useCallback(()=>{_(B=>(localStorage.setItem(rs("right"),B?"0":"1"),!B))},[]),[$,X]=l.useState(null),[Y,M]=l.useState(()=>window.matchMedia("(max-width: 768px)").matches);l.useEffect(()=>{const B=window.matchMedia("(max-width: 768px)"),te=ce=>M(ce.matches);return B.addEventListener("change",te),()=>B.removeEventListener("change",te)},[]);const[R,C]=l.useState(!1),[O,z]=l.useState(!1),[ne,v]=l.useState(!1),[L,d]=l.useState(!1),[w,h]=l.useState(!1),[I,ee]=l.useState(null);l.useEffect(()=>{if(!I)return;const B=setTimeout(()=>ee(null),15e3);return()=>clearTimeout(B)},[I]),l.useEffect(()=>{const B=te=>{var qe,Ss;const ce=te.detail,Ne=(ce==null?void 0:ce.title)||t("pluginCommandFallback"),Ce=ce==null?void 0:ce.command;if(!Ce||!s.ready)return;const Fe={name:Ne,command:Ce,cwd:"${pwd}"},Se=s.terminals.find(It=>It.title===Ne);if(Se)i.restart(Se.id),n({type:"run_command",terminalId:Se.id,conversationId:Se.conversationId,command:Fe,cols:80,rows:24});else{const It=Ue();i.create({id:It,conversationId:s.activeConversationId||((qe=s.state)==null?void 0:qe.conversationId)||"",title:Ne,cwd:((Ss=s.state)==null?void 0:Ss.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:Fe})}b("terminal")};return window.addEventListener("pi-web-ui:plugin-run-command",B),()=>window.removeEventListener("pi-web-ui:plugin-run-command",B)},[s,i,n]),l.useEffect(()=>{const B=te=>{!(te.ctrlKey||te.metaKey)||te.key.toLowerCase()!=="k"||(te.preventDefault(),h(ce=>!ce))};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[]);const[q,ae]=l.useState(ri),{themes:ye,theme:ke,switchTheme:fe}=Ql(),be=l.useRef(null),Ee=l.useRef(null),re=l.useRef(0),f=l.useRef(!1),W=l.useRef(s.terminals);l.useEffect(()=>{$l(q)},[q]),l.useEffect(()=>{var te;const B=W.current;W.current=s.terminals;for(const ce of s.terminals){const Ne=((te=ce.command)==null?void 0:te.command)??"",Ce=B.find(Fe=>Fe.id===ce.id);!(Ce!=null&&Ce.running)||ce.running||(Ne.startsWith("pi remove ")?n({type:"extensions_reload"}):Ne.startsWith("pi-web-ui install ")||Ne.startsWith("pi-web-ui uninstall ")?n({type:"plugins_reload"}):Ne.startsWith("npm i -g ")&&(n({type:"extensions_reload"}),n({type:"plugins_reload"}),n({type:"check_updates_all",force:!0})))}},[s.terminals,n]),l.useEffect(()=>{var ce;const B=((ce=s.state)==null?void 0:ce.isStreaming)??!1,te=be.current;be.current=B,te!==null&&(!te&&B?at("start",q):te&&!B&&(at("done",q),_t(t("notifyDoneTitle"),t("notifyDoneBody"))))},[(ms=s.state)==null?void 0:ms.isStreaming,q]),l.useEffect(()=>{var te;const B=((te=s.dialog)==null?void 0:te.id)??null;B!==null&&B!==Ee.current&&(at("question",q),_t(t("notifyQuestionTitle"),t("notifyQuestionBody"))),Ee.current=B},[s.dialog,q]),l.useEffect(()=>{const B=[...s.notices].reverse().find(te=>te.level==="error");B&&B.id!==re.current&&(re.current=B.id,at("error",q),_t(t("notifyErrorTitle"),t("notifyErrorBody")))},[s.notices,q]);const de=(B,te,ce,Ne=!1,Ce)=>{const Fe=`${B}|${ce}|${Ce?`${Ce.start}-${Ce.end}`:""}`;o(Se=>Se.some(qe=>`${qe.path}|${qe.mode}|${qe.lines?`${qe.lines.start}-${qe.lines.end}`:""}`===Fe)?Se:[...Se,{path:B,name:te,mode:ce,isDir:Ne,...Ce?{lines:Ce}:{}}])},ue=B=>o(te=>te.filter(ce=>ce.key?ce.key!==B:ce.path!==B)),me=l.useCallback(B=>(!B.type.startsWith("list_")&&!B.type.startsWith("get_")&&X(null),n(B)),[n]),pe=l.useRef(0),ve=l.useRef(0),Me=B=>{var Ne;const te=Date.now();(Ne=s.state)!=null&&Ne.model&&!s.state.model.vision&&te-ve.current>1e4&&(ve.current=te,c("warning",t("imageNotSupported")));const ce=`paste-${++pe.current}`;o(Ce=>[...Ce,{path:"",key:ce,name:B.name,mode:"inline",imageData:B.data,mimeType:B.mimeType}])},he=async B=>{for(const te of B){const ce=await Hn(te);if(!ce){c("error",t("imageLoadFailed",{name:te.name}));continue}Me(ce)}},_e=20*1024*1024,Le=l.useRef(0),Be=async B=>{if(B.size>_e){c("warning",t("fileTooLarge",{name:B.name,size:_e/1024/1024}));return}let te;try{te=(await new Promise((Ce,Fe)=>{const Se=new FileReader;Se.onload=()=>Ce(Se.result),Se.onerror=()=>Fe(Se.error??new Error("read failed")),Se.readAsDataURL(B)})).replace(/^data:[^;]*;base64,/,"")}catch{c("error",t("fileLoadFailed",{name:B.name}));return}const ce=`upload-${++Le.current}`;o(Ne=>[...Ne,{path:"",key:ce,name:B.name,mode:"inline",fileData:te,size:B.size,mimeType:B.type||void 0}])},De=async B=>{for(const te of B)We(te.type)?await he([te]):await Be(te)},P=l.useCallback((B,te,ce)=>{n({type:"edit_message",messageId:B,text:te,attachments:ce})},[n]),ge=l.useCallback((B,te)=>{n({type:"queue_remove",kind:B,text:te})},[n]),oe=l.useCallback(()=>z(!0),[]),p=l.useCallback(()=>o([]),[]),V=l.useCallback(ue,[]),N=l.useCallback(he,[he]),A=l.useCallback(De,[De]),ie=(hs=s.state)==null?void 0:hs.model,le=(gs=s.state)==null?void 0:gs.thinkingLevel,je=(fs=s.state)==null?void 0:fs.availableThinkingLevels,we=l.useMemo(()=>ie?{model:ie,thinkingLevel:le??"off",availableThinkingLevels:je??[]}:null,[ie,le,je]),Te=l.useCallback(()=>{var B,te;return!s.ready||s.terminals.length!==0?!1:(i.create({id:Ue(),conversationId:s.activeConversationId||((B=s.state)==null?void 0:B.conversationId)||"",title:t("terminalTitle",{n:1}),cwd:((te=s.state)==null?void 0:te.cwd)??"",cols:80,rows:24,running:!0,exitCode:null}),!0)},[s.ready,(xs=s.state)==null?void 0:xs.cwd,s.terminals.length,t,i]);return l.useEffect(()=>{if(f.current){if(x!=="terminal"||s.terminals.length!==0){f.current=!1;return}Te()&&(f.current=!1)}},[s.terminals.length,Te,x]),e.jsxs("div",{className:"app",onDragOver:B=>{var te;Array.from(((te=B.dataTransfer)==null?void 0:te.types)??[]).includes("Files")&&(B.preventDefault(),g(!0))},onDragLeave:B=>{B.currentTarget.contains(B.relatedTarget)||g(!1)},onDrop:B=>{var Ce,Fe;if(g(!1),!Array.from(((Ce=B.dataTransfer)==null?void 0:Ce.types)??[]).includes("Files"))return;B.preventDefault();const te=Array.from(((Fe=B.dataTransfer)==null?void 0:Fe.files)??[]);if(te.length===0){c("warning",t("foldersNotSupported"));return}const ce=te.filter(Se=>We(Se.type)),Ne=te.filter(Se=>!We(Se.type));ce.length>0&&he(ce),Ne.length>0&&De(Ne)},children:[y&&e.jsx("div",{className:"app-drop-overlay","aria-hidden":!0,children:e.jsxs("span",{children:["📎 ",t("dropHereToAttach")]})}),e.jsx(ca,{chat:s,send:n,terminal:i,view:x,plugins:T,onViewChange:B=>{f.current=B==="terminal"&&s.terminals.length===0,f.current&&Te()&&(f.current=!1),b(B),X(null)},onOpenPanel:X,onOpenSettings:()=>v(!0),onOpenBgTasks:()=>d(!0),onOpenGlobalSearch:()=>h(!0),sound:q,onSoundChange:ae,onSoundPreview:B=>at(B,q),themes:ye,theme:ke,onThemeChange:fe}),s.protocolMismatch&&e.jsxs("div",{className:"protocol-banner",children:["⚠ ",t("protocolMismatch")]}),e.jsx("div",{className:"notices",children:s.notices.map(B=>e.jsx(Jl,{notice:B,onDismiss:r},B.id))}),e.jsx(Vr,{send:n,children:e.jsxs("div",{className:"layout",style:{"--left-w":`${S}px`,"--right-w":`${Q}px`},children:[$&&e.jsx("div",{className:"drawer-backdrop",onClick:()=>X(null)}),e.jsxs("div",{className:`view-pane ${x==="chat"?"":"hidden"}`,children:[!Y&&E&&e.jsx(mn,{side:"left",onClick:F}),e.jsx("div",{className:`panel-drawer drawer-left ${$==="left"?"open":""}${Y?"":E?" hidden":""}`,children:e.jsx(ga,{collapsible:!Y,onToggleCollapse:F,send:me,active:!Y||$==="left",ready:s.ready,status:s.status,cwd:((ys=s.state)==null?void 0:ys.cwd)??"",sessionFile:((vs=s.state)==null?void 0:vs.sessionFile)??null,conversations:s.conversations,sessions:s.sessions,projects:s.projects,activeConversationId:s.activeConversationId})}),!Y&&e.jsx(pn,{side:"left",width:S,onResize:J}),e.jsxs("main",{className:"main",children:[s.state?e.jsx(Zr,{state:s.state,liveOutputs:s.liveOutputs,toolStatuses:s.toolStatuses,onEdit:P,onKillBash:()=>n({type:"abort_bash"}),onRemoveQueued:ge,thinkingWrap:((ks=s.settings)==null?void 0:ks.thinkingWrap)??!0,toolsWrap:((bs=s.settings)==null?void 0:bs.toolsWrap)??!0,jumpTarget:I,onJumpDone:()=>ee(null)},s.state.conversationId??"boot"):e.jsx("div",{className:"boot-wait",children:s.ready?t("loadingSession"):t("connectingServer")}),e.jsx(hl,{send:n,goal:s.goal,models:s.models,modelsLoading:s.modelsLoading,activeConversationId:s.activeConversationId,engine:s.engine}),s.dialog&&e.jsx(bl,{dialog:s.dialog,send:n}),s.question&&e.jsx(jl,{question:s.question,send:n}),e.jsx(ml,{send:n,ready:s.ready,streaming:((js=s.state)==null?void 0:js.isStreaming)??!1,messages:((ws=s.state)==null?void 0:ws.messages)??Xl,slashCommands:s.slashCommands,modelState:we,models:s.models,modelsLoading:s.modelsLoading,providerKeys:s.providerKeys,attachments:a,onRemoveAttachment:V,onAddImageFiles:N,onAddLocalFiles:A,onNotice:c,onManageModels:oe,onSent:p})]}),!Y&&e.jsx(pn,{side:"right",width:Q,onResize:U}),e.jsx("div",{className:`panel-drawer drawer-right ${$==="right"?"open":""}${Y?"":k?" hidden":""}`,children:e.jsx(Oa,{collapsible:!Y,onToggleCollapse:Z,send:me,files:s.files,fileChanged:s.fileChanged,widgets:s.widgets,cwd:((Ns=s.state)==null?void 0:Ns.cwd)??"",onAttach:(B,te,ce,Ne)=>{X(null),de(B,te,ce,Ne)},onPreview:(B,te)=>{X(null),m({path:B,name:te})},onNotice:(B,te)=>c(B,te)})}),!Y&&k&&e.jsx(mn,{side:"right",onClick:Z})]}),e.jsx("div",{className:`view-pane ${x==="terminal"?"":"hidden"}`,children:e.jsx(l.Suspense,{fallback:null,children:e.jsx(Yl,{chat:s,send:n,terminal:i})})}),e.jsx("div",{className:`view-pane ${x==="git"?"":"hidden"}`,children:e.jsx(Nl,{chat:s,send:n,terminal:i,active:x==="git",onSwitchToTerminal:()=>b("terminal")})}),D.map(B=>{const te=`plugin:${B.info.id}`;return e.jsx("div",{className:`view-pane ${x===te?"":"hidden"}`,children:e.jsx(Cl,{entry:B,send:n})},B.info.id)})]})}),e.jsx(vl,{chat:s,send:n}),u&&e.jsx(Bl,{file:u,content:s.fileContent,send:n,onAddLines:(B,te,ce,Ne)=>de(B,te,"lines",!1,{start:ce,end:Ne}),onAttach:(B,te,ce)=>de(B,te,ce),onClose:()=>m(null)}),s.ready&&s.state&&s.state.piConfigured===!1&&!R&&!O&&e.jsx(Sl,{send:n,piConfigured:s.state.piConfigured,piAgentInstalled:s.state.piAgentInstalled,providers:s.providers,installResult:s.installResult,onClose:()=>C(!0)}),O&&e.jsx(Pl,{send:n,providers:s.modelsConfig,providerStatus:s.providers,providerKeys:s.providerKeys,fetchModelsResult:s.fetchModelsResult,cloneProviderResult:s.cloneProviderResult,onClose:()=>z(!1)}),ne&&e.jsx(Il,{chat:s,send:n,terminal:i,onSwitchToTerminal:()=>b("terminal"),onClose:()=>v(!1)}),L&&e.jsx(Dl,{servers:s.bgServers,send:n,onClose:()=>d(!1)}),e.jsx(_l,{open:w,send:n,projects:s.projects,cwd:((Cs=s.state)==null?void 0:Cs.cwd)??"",fileSearch:s.fileSearch,sessionSearch:s.sessionSearch,onClose:()=>h(!1),onSwitchSession:(B,te)=>{n({type:"switch_session",path:B});const ce=te&&te[0];ee(ce?{path:B,role:ce.role,timestamp:ce.timestamp}:null)},onSwitchProject:B=>{n({type:"set_cwd",path:B})},onPreviewFile:(B,te)=>{m({path:B,name:te})}})]})}fa();ci(oi());yi.createRoot(document.getElementById("root")).render(e.jsx(l.StrictMode,{children:e.jsx(na,{children:e.jsx(Zl,{})})}));"serviceWorker"in navigator&&window.addEventListener("load",()=>{const t=Pn();navigator.serviceWorker.register(`${t}sw.js`,{scope:t}).catch(s=>{console.warn("Service worker registration failed:",s)})});export{rt as F,cn as T,gn as _,xe as a,no as b,He as c,so as d,St as e,Ae as f,Fi as g,tt as h,Pe as i,Ue as r,mt as u};
|
|
311
|
+
`),inFence:c!==null}}const dr=l.memo(function({text:s}){return e.jsx(cs,{text:s})}),Qs=200;function ur({text:t,inFence:s}){const[n,r]=l.useState(t),c=l.useRef(0),i=l.useRef(null);return l.useEffect(()=>{if(s)return;const a=Date.now()-c.current,o=()=>{c.current=Date.now(),r(t)};if(a>=Qs){o();return}return i.current=setTimeout(o,Qs-a),()=>{i.current&&clearTimeout(i.current)}},[t,s]),s?e.jsx("div",{className:"codeblock",children:e.jsx("pre",{children:e.jsx("code",{children:t})})}):e.jsx(cs,{text:n})}const pr=l.memo(function({text:s}){const{frozen:n,active:r,inFence:c}=l.useMemo(()=>cr(s),[s]);return e.jsxs("div",{className:"md",children:[n.map((i,a)=>e.jsx(dr,{text:i},a)),r.length>0&&e.jsx(ur,{text:r,inFence:c},n.length)]})});function mr({thinking:t,streaming:s,wrap:n=!0,forceOpen:r=!1}){const c=xe(),[i,a]=l.useState(null),o=i??n,u=o||r,m=s?t.trimEnd().slice(-80):t.split(`
|
|
312
|
+
`)[0].slice(0,80);return e.jsxs("div",{className:`thinking ${u?"open":""} ${s?"live":""}`,children:[e.jsxs("button",{type:"button",className:"thinking-toggle",onClick:()=>a(!o),children:[u?e.jsx(Ge,{}):e.jsx(Pt,{}),e.jsx(lt,{className:"thinking-icon"}),e.jsx("span",{className:"thinking-label",children:s&&u?e.jsxs("span",{className:"thinking-live-label",children:[c("thinkingNow"),e.jsx("span",{className:"dots"})]}):u?c("thinking"):c("thinkingPreview",{preview:m})})]}),u&&e.jsx("div",{className:"thinking-body",children:t})]})}const hr={bash:"$",read:"📄",write:"✍️",edit:"✏️",grep:"🔍",find:"🧭",ls:"📂"};function gr(t){return hr[t]??"🛠"}const fr=l.memo(function({block:s,view:n,onKillBash:r,wrap:c=!0,forceOpen:i=!1}){var q,Y,T,P;const a=xe(),[o,u]=l.useState(c),m=o||i,[y,g]=l.useState(!1),x=!n.result&&n.streaming&&!n.status,b=s.name==="bash"&&x,E=n.result!==void 0,A=!n.result&&!!n.status,H=((q=n.result)==null?void 0:q.isError)??((Y=n.status)==null?void 0:Y.isError)??!1,j=(n.result?n.result.content.map(k=>k.type==="text"?k.text:"").join(""):n.liveOutput??"").replace(/…\[LIVE_OMIT:(\d+)\]…\n/,(k,B)=>a("liveOutputOmitted",{n:B})),J=H?"err":E?"ok":x||A?"run":"idle";let Q=a(H?"error":E?"done":x?"running":A?"toolDoneWaitingModel":"toolQueued");const X=A&&((T=n.status)==null?void 0:T.durationMs)!==void 0?yr(n.status.durationMs):"";A&&X&&(Q=`${Q} · ${X}`);const U=A&&((P=n.status)==null?void 0:P.exitCode)!==void 0?`exit ${n.status.exitCode}`:"",K=()=>{s.argumentsText&&(navigator.clipboard.writeText(s.argumentsText),g(!0),setTimeout(()=>g(!1),1200))};return e.jsxs("div",{className:`toolcall ${J}`,children:[e.jsxs("div",{className:"toolcall-head",children:[e.jsx("span",{className:"toolcall-icon",children:gr(s.name)}),e.jsx("span",{className:"toolcall-name",children:s.name}),e.jsxs("span",{className:"toolcall-status",children:[Q,U&&e.jsx("em",{className:"toolcall-exit",children:U})]}),e.jsx("span",{className:"toolcall-spacer"}),b&&r&&e.jsxs("button",{type:"button",className:"toolcall-kill",title:a("stopBashTip"),onClick:r,children:[e.jsx(jt,{}),e.jsx("span",{children:a("stopBash")})]}),e.jsx("button",{type:"button",className:"toolcall-copy",title:a("copyArgs"),onClick:K,children:y?e.jsx(Yi,{}):e.jsx(jn,{})}),e.jsx("button",{type:"button",className:"toolcall-toggle",onClick:()=>u(k=>i?!0:!k),children:m?e.jsx(Ge,{}):e.jsx(Pt,{})})]}),m&&e.jsxs("div",{className:"toolcall-body",children:[s.argumentsText&&e.jsx("div",{className:"toolcall-args",children:s.name==="bash"&&s.argumentsText.startsWith("{")?e.jsx(xr,{args:s.argumentsText}):e.jsx("pre",{children:s.argumentsText})}),j.length>0&&e.jsxs("div",{className:"toolcall-output",children:[e.jsxs("div",{className:"toolcall-output-label",children:[a(H?"errorOutput":"output"),(x||A)&&e.jsx("span",{className:"cursor"})]}),e.jsx("pre",{children:j})]}),x&&j.length===0&&e.jsxs("div",{className:"toolcall-waiting",children:[e.jsx("span",{className:"cursor"})," ",a("waitingOutput")]}),A&&j.length===0&&e.jsxs("div",{className:"toolcall-waiting",children:[e.jsx("span",{className:"cursor"})," ",a("waitingModel")]})]})]})});function xr({args:t}){let s=null;try{s=JSON.parse(t)}catch{return e.jsx("pre",{children:t})}return typeof s.command!="string"?e.jsx("pre",{children:t}):e.jsxs("div",{className:"termline",children:[e.jsx(tt,{className:"termline-icon"}),e.jsx("code",{children:s.command}),typeof s.timeout=="number"&&e.jsxs("span",{className:"termline-timeout",children:["⏱ ",s.timeout,"s"]})]})}function yr(t){if(t===void 0)return"";const s=t/1e3;if(s<60)return`${s.toFixed(1)}s`;const n=Math.floor(s/60),r=Math.round(s%60);return`${n}m ${String(r).padStart(2,"0")}s`}const vr=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;function ds(t){var n;const s=t.match(vr);return s?{name:s[1],location:s[2],content:s[3],userMessage:((n=s[4])==null?void 0:n.trim())||void 0}:null}const br=1568,kr=2*1024*1024;function We(t){return t.startsWith("image/")&&t!=="image/svg+xml"&&t!=="image/svg"}async function On(t){if(!t.type.startsWith("image/"))return null;let s;try{s=await createImageBitmap(t,{imageOrientation:"from-image"})}catch{return null}try{const n=Math.min(1,br/Math.max(s.width,s.height)),r=Math.max(1,Math.round(s.width*n)),c=Math.max(1,Math.round(s.height*n)),i=t.type==="image/jpeg"||t.type==="image/jpg"?[["image/jpeg",.85],["image/jpeg",.6],["image/webp",.8]]:[["image/png",1],["image/jpeg",.85],["image/jpeg",.6]];let a=null;for(const[o,u]of i){const m=document.createElement("canvas");m.width=r,m.height=c;const y=m.getContext("2d");if(!y)continue;o!=="image/png"&&(y.fillStyle="#ffffff",y.fillRect(0,0,r,c)),y.drawImage(s,0,0,r,c);const g=m.toDataURL(o,u),x=g.match(/^data:([^;]+);base64,/),b=x?x[1]:o,E=g.replace(/^data:[^;]*;base64,/,""),A=Math.floor(E.length*3/4);if(a={data:E,mimeType:b,name:t.name,size:A},A<=kr)return a}return a}finally{s.close()}}const jr=20*1024*1024;function ct(t){return t.type==="text"&&typeof t.text=="string"?t:null}function Kn(t){return t.type==="thinking"&&typeof t.thinking=="string"?t:null}function Wn(t){return t.type==="toolCall"&&typeof t.id=="string"&&typeof t.name=="string"?t:null}function Un(t){return t.type==="image"&&typeof t.dataUrl=="string"?t:null}function qn(t){return t.type==="bash"&&typeof t.command=="string"?t:null}function wr(t){return t.imageData?"image":t.uploadPath?"upload":t.fileData?"file":"path"}function Nr(t,s){if(t.imageData)return s("attachImage",{name:t.name??"image"});if(t.uploadPath)return s("attachFile",{name:t.name??t.uploadPath});if(t.fileData)return s("attachFile",{name:t.name??"file"});const n=t.path.split("/").pop()??t.path;return t.mode==="lines"&&t.lines?s("attachLines",{path:n,start:t.lines.start,end:t.lines.end}):t.mode==="reference"?s("refOnly",{path:n}):s("attachContent",{path:n})}const Ys=l.memo(function({message:s,toolResults:n,liveOutputs:r,toolStatuses:c,streaming:i,isLast:a,onEdit:o,onKillBash:u,onCollapse:m,questionAttachments:y,qnIndex:g,qnActive:x,onJump:b,thinkingWrap:E,toolsWrap:A,searchActive:H}){const S=xe(),[j,J]=l.useState(!1),[Q,X]=l.useState(""),[U,K]=l.useState([]),[q,Y]=l.useState(!1),[T,P]=l.useState(null),k=h=>{P(h),window.setTimeout(()=>P(L=>L===h?null:L),4e3)};if(s.role==="toolResult")return null;const B=s.role==="custom"&&s.customType==="file",Z=s.content.map(h=>{var L;return((L=ct(h))==null?void 0:L.text)??""}).filter(Boolean).join(`
|
|
313
|
+
`),G=s.role==="user"?ds(Z):null,M=G?G.userMessage??`skill:${G.name}`:Z.split(`
|
|
314
|
+
`).join(" ").trim(),I=i&&a&&s.content.length===0,C=s.role==="user"&&!i&&!I&&!!o,$=async h=>{const L=[];for(const ee of h){if(!We(ee.type))continue;const W=await On(ee);W&&L.push({path:"",imageData:W.data,mimeType:W.mimeType,name:W.name})}L.length>0&&K(ee=>[...ee,...L])},z=async h=>{if(h.size>jr){k(S("fileTooLarge",{name:h.name,size:20}));return}let L;try{L=(await new Promise((W,ae)=>{const ye=new FileReader;ye.onload=()=>W(ye.result),ye.onerror=()=>ae(ye.error??new Error("read failed")),ye.readAsDataURL(h)})).replace(/^data:[^;]*;base64,/,"")}catch{k(S("fileLoadFailed",{name:h.name}));return}K(ee=>[...ee,{path:"",fileData:L,name:h.name,size:h.size,mimeType:h.type||void 0}])},ne=async h=>{const L=[];for(const ee of h)We(ee.type)?L.push(ee):z(ee);L.length>0&&await $(L)},v=()=>{X(G?`/skill:${G.name}${G.userMessage?` ${G.userMessage}`:""}`:s.content.map(h=>{var L;return((L=ct(h))==null?void 0:L.text)??""}).filter(Boolean).join(`
|
|
315
|
+
`)),K(y??[]),J(!0)},D=()=>{const h=Q.trim();h&&(o==null||o(s.id,h,U.length>0?U:void 0),J(!1))},d=s.role==="custom"&&(s.customType==="goal-review"||s.customType==="goal-wizard"),w=s.role==="custom"&&s.customType==="goal-wizard";return e.jsxs("div",{className:`msg msg-${s.role}${d?" msg-goal-review":""}`,"data-role":s.role,"data-msg-id":s.id,children:[e.jsxs("div",{className:"msg-meta",children:[e.jsx("span",{className:"msg-role",children:s.role==="custom"?w?S("goalWizardCard"):d?S("goalBarTitle"):s.customType==="file"?S("attachment"):`${S("plugin")} · ${s.customType??S("unknown")}`:zn(s.role,S)}),s.model&&e.jsx("span",{className:"msg-model",children:s.model}),s.timestamp&&e.jsx("span",{className:"msg-time",children:Er(s.timestamp)}),m&&e.jsxs("button",{type:"button",className:"msg-collapse-btn",title:S("collapseMsg"),onClick:()=>m(s.id),children:[e.jsx(ut,{})," ",S("collapseMsg")]}),g!==void 0&&b&&e.jsxs("button",{type:"button",className:`qn-tag ${x?"active":""}`,title:`${g+1}. ${M}`,"aria-label":`${g+1}. ${M}`,onClick:()=>b(s.id),children:[e.jsx("span",{className:"qn-tag-bar"}),e.jsx("span",{className:"qn-tag-idx",children:g+1})]})]}),e.jsx("div",{className:"msg-body",children:j?e.jsxs("div",{className:`msg-editor${q?" drag-over":""}`,onDragOver:h=>{h.preventDefault(),h.stopPropagation(),Y(!0)},onDragLeave:h=>{h.currentTarget.contains(h.relatedTarget)||Y(!1)},onDrop:h=>{var L;h.preventDefault(),h.stopPropagation(),Y(!1),ne(Array.from(((L=h.dataTransfer)==null?void 0:L.files)??[]))},children:[U.length>0&&e.jsx("div",{className:"msg-editor-images",children:U.map((h,L)=>{var W;const ee=wr(h);return e.jsxs("span",{className:`msg-editor-img ${ee==="image"?"":"file-chip"}`,title:Nr(h,S),children:[ee==="image"?e.jsx("img",{src:`data:${h.mimeType??"image/png"};base64,${h.imageData}`,alt:h.name}):e.jsxs("span",{className:"msg-editor-file",children:[e.jsx("span",{className:"msg-editor-file-icon",children:ee==="path"?h.mode==="reference"?"🔗":"📎":"📄"}),e.jsx("span",{className:"msg-editor-file-name",children:h.name??((W=h.path)==null?void 0:W.split("/").pop())})]}),e.jsx("button",{type:"button",className:"msg-editor-img-remove",title:S("removeAttachment"),onClick:()=>K(ae=>ae.filter((ye,be)=>be!==L)),children:e.jsx(Pe,{})})]},`${h.name??h.path??"att"}-${L}`)})}),T&&e.jsx("div",{className:"msg-editor-notice",children:T}),e.jsx("textarea",{className:"msg-editor-input",value:Q,autoFocus:!0,placeholder:S("editPlaceholder"),rows:Math.max(2,Math.min(10,Q.split(`
|
|
316
|
+
`).length+1)),onChange:h=>X(h.target.value),onPaste:h=>{var ee;const L=[];for(const W of((ee=h.clipboardData)==null?void 0:ee.items)??[])if(W.kind==="file"&&We(W.type)){const ae=W.getAsFile();ae&&L.push(ae)}L.length!==0&&(h.preventDefault(),$(L))},onKeyDown:h=>{h.key==="Enter"&&(h.metaKey||h.ctrlKey)?(h.preventDefault(),D()):h.key==="Escape"&&J(!1)}}),e.jsxs("div",{className:"msg-editor-actions",children:[e.jsxs("span",{className:"msg-editor-hint",children:[e.jsx(Ui,{})," ",S("editAttachmentHint")]}),e.jsx("button",{type:"button",className:"chip",onClick:()=>J(!1),children:S("cancel")}),e.jsxs("button",{type:"button",className:"chip primary",disabled:!Q.trim(),title:S("reaskFromHere"),onClick:D,children:[e.jsx(Yt,{})," ",S("reaskFromHere")]})]})]}):e.jsxs(e.Fragment,{children:[s.errorMessage&&e.jsx("div",{className:"msg-error",children:s.errorMessage}),B?e.jsx(Cr,{message:s,forceOpen:H}):G?e.jsxs(e.Fragment,{children:[e.jsx(Tr,{block:G,forceOpen:H}),G.userMessage&&e.jsx("div",{className:"msg-text",children:e.jsx(Rt,{text:G.userMessage})}),s.content.map((h,L)=>h.type==="text"?null:e.jsx(Xs,{block:h,toolResults:n,liveOutputs:r,toolStatuses:c,streaming:i,isLast:a,onKillBash:u,toolsWrap:A,thinkingWrap:E,searchActive:H},`${s.id}-${L}`))]}):s.content.map((h,L)=>e.jsx(Xs,{block:h,toolResults:n,liveOutputs:r,toolStatuses:c,streaming:i,isLast:a,onKillBash:u,toolsWrap:A,thinkingWrap:E,searchActive:H},`${s.id}-${L}`)),I&&e.jsxs("div",{className:"thinking-wait",children:[S("thinkingWait"),e.jsx("span",{className:"dot"})]}),i&&a&&!I&&e.jsx("span",{className:"stream-cursor"})]})}),C&&!j&&e.jsx("div",{className:"msg-actions",children:e.jsxs("button",{type:"button",className:"msg-action",title:S("editReaskTip"),onClick:v,children:[e.jsx(Yt,{})," ",S("editReask")]})})]})});function Cr({message:t,forceOpen:s=!1}){const n=xe(),[r,c]=l.useState(!1),i=r||s,a=t.details??{},o=a.name??a.path??n("attachment"),u=a.type==="folder",m=a.mode==="reference",y=a.mode==="bridged",g=t.content.filter(A=>A.type==="text").map(A=>A.text).join(`
|
|
317
|
+
`),x=Sr(g),b=t.content.find(A=>A.type==="image"),E=x.split(`
|
|
318
|
+
`).length;return e.jsxs("div",{className:`attachcard ${m?"reference":""}`,children:[e.jsxs("button",{type:"button",className:"attachcard-head",onClick:()=>c(A=>s?!0:!A),children:[e.jsx("span",{className:"attachcard-icon",children:u?"📁":"📎"}),e.jsx("span",{className:"attachcard-name",children:o}),a.path&&e.jsx("span",{className:"attachcard-path",children:a.path}),e.jsx("span",{className:`attachcard-mode ${a.mode==="lines"?"lines":m?"ref":y?"bridged":"inline"}`,children:m?u?n("folderRefShort"):`${n("refOnlyShort")} · ${Js(a.size)}`:y?n("bridgedVision"):b?n("image"):a.mode==="lines"?n("inlineLinesRange",{start:a.startLine??1,end:a.endLine??a.lines??1}):n("inlineLines",{n:a.lines??E})}),!m&&(i?e.jsx(Ge,{}):e.jsx(Pt,{}))]}),!m&&i&&(y?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"attachcard-bridgenote",children:n("bridgedVisionDetail")}),(b==null?void 0:b.dataUrl)&&e.jsx("div",{className:"attachcard-image",children:e.jsx("img",{src:b.dataUrl,alt:o})}),x&&e.jsx("pre",{className:"attachcard-content",children:x})]}):b!=null&&b.dataUrl?e.jsx("div",{className:"attachcard-image",children:e.jsx("img",{src:b.dataUrl,alt:o})}):e.jsx("pre",{className:"attachcard-content",children:x})),m&&e.jsx("div",{className:"attachcard-refnote",children:u?n("folderNotExpanded"):n("fileNotExpanded",{size:Js(a.size)})})]})}function Js(t){return t===void 0?"":t>=1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:t>=1024?`${Math.round(t/1024)} KB`:`${t} B`}function Sr(t){const s=t.match(/^\s*<file path="[^"]*"(?:\s+lines="[^"]*")?>\s*```\s*\n?([\s\S]*?)\n?```\s*<\/file>\s*$/);if(s)return s[1].trim();const n=t.match(/^\s*<vision-bridge>\s*([\s\S]*?)\s*<\/vision-bridge>\s*$/);return n?n[1].trim():t.trim()}function Tr({block:t,forceOpen:s=!1}){const n=xe(),[r,c]=l.useState(!1),i=r||s;return e.jsxs("div",{className:`skillcard${r?" expanded":""}`,children:[e.jsxs("button",{type:"button",className:"skillcard-head",onClick:()=>c(a=>s?!0:!a),title:t.location,children:[e.jsx("span",{className:"skillcard-icon",children:e.jsx(Ji,{})}),e.jsx("span",{className:"skillcard-name",children:t.name}),e.jsx("span",{className:"skillcard-path",children:t.location}),e.jsxs("span",{className:"skillcard-action",children:[i?e.jsx(ut,{}):e.jsx(Ge,{}),n(i?"collapseMsg":"expandMsg")]})]}),i&&e.jsx("div",{className:"skillcard-body",children:e.jsx(Rt,{text:t.content})})]})}function Xs({block:t,toolResults:s,liveOutputs:n,toolStatuses:r,streaming:c,isLast:i,onKillBash:a,thinkingWrap:o,toolsWrap:u,searchActive:m}){const y=xe(),g=ct(t);if(g){const H=c&&i;return e.jsxs("div",{className:"msg-text",children:[H?e.jsx(pr,{text:g.text}):e.jsx(Rt,{text:g.text}),g.truncated&&e.jsx("div",{className:"trunc-note",children:y("truncated")})]})}const x=Kn(t);if(x)return e.jsx(mr,{thinking:x.thinking,streaming:c&&i,wrap:o,forceOpen:m});const b=Wn(t);if(b){const H=s.get(b.id),S=n.get(b.id),j={result:H,liveOutput:S==null?void 0:S.text,streaming:c,status:r.get(b.id)};return e.jsx(fr,{block:b,view:j,onKillBash:a,wrap:u,forceOpen:m})}const E=Un(t);if(E&&E.dataUrl)return e.jsx("div",{className:"msg-image",children:e.jsx("img",{src:E.dataUrl,alt:"attachment"})});const A=qn(t);return A?e.jsxs("div",{className:"bashblock",children:[e.jsxs("div",{className:"bashblock-command",children:[e.jsx("span",{className:"bashblock-prompt",children:"$"}),e.jsx("code",{children:A.command}),A.exitCode!==void 0&&e.jsx("span",{className:`bashblock-exit ${A.exitCode===0?"ok":"err"}`,children:y("exitCode",{code:A.exitCode})}),A.cancelled&&e.jsx("span",{className:"bashblock-exit err",children:y("cancelled")})]}),A.output&&e.jsx("pre",{className:"bashblock-output",children:A.output}),A.truncated&&e.jsx("div",{className:"trunc-note",children:y("outputTruncated")})]}):null}function zn(t,s){switch(t){case"user":return s("role.user");case"assistant":return s("role.assistant");case"toolResult":return s("role.tool");case"bashExecution":return s("role.bash");case"branchSummary":return s("role.branch");case"compactionSummary":return s("role.compaction");default:return t}}function Er(t){const s=new Date(t),n=String(s.getHours()).padStart(2,"0"),r=String(s.getMinutes()).padStart(2,"0");return`${n}:${r}`}function Zs(t,s,n){let r=!1;for(const c of s){const i=c;if(i.type!=="image"||typeof i.dataUrl!="string"||!i.dataUrl.startsWith("data:"))continue;const a=i.dataUrl.match(/^data:([^;]*);base64,(.+)$/);a&&(r=!0,t.push({path:"",imageData:a[2],mimeType:a[1]||"image/png",name:n??`image.${(a[1]||"image/png").split("/")[1]??"png"}`}))}return r}function Pr(t){const s=new Map;for(let n=0;n<t.length;n++){const r=t[n];if(r.role!=="user"||!r.id)continue;const c=[];Zs(c,r.content);for(let i=n+1;i<t.length&&t[i].role==="custom"&&t[i].customType==="file";i++){const a=t[i].details??{};if(!Zs(c,t[i].content,a.name)){if(a.upload&&a.path){c.push({path:"",uploadPath:a.path,name:a.name??a.path,size:a.size});continue}if(a.path&&a.mode){const o=a.mode==="inline"||a.mode==="lines"?a.mode:"reference",u={path:a.path,mode:o};a.mode==="lines"&&typeof a.startLine=="number"&&typeof a.endLine=="number"&&(u.lines={start:a.startLine,end:a.endLine}),c.push(u)}}}c.length>0&&s.set(r.id,c)}return s}const Mr=l.memo(function({message:s,onExpand:n}){const r=xe();let c="";for(const g of s.content){const x=ct(g);if(x&&x.text.trim()){const b=ds(x.text);b?c=`skill:${b.name}`+(b.userMessage?` · ${b.userMessage.replace(/\s+/g," ").trim()}`:""):c=x.text.replace(/\s+/g," ").trim();break}}if(!c&&s.role==="custom"&&s.customType==="file"){const g=s.details??{};c=g.name??g.path??""}c.length>90&&(c=`${c.slice(0,90)}…`);let a=0,o=0,u=0,m=0;for(const g of s.content)Kn(g)?a++:Wn(g)?o++:qn(g)?u++:Un(g)&&m++;const y=[];return a&&y.push(`${r("thinking")} ${a}`),o&&y.push(`${r("toolCalls")} ${o}`),u&&y.push(`${r("bashRuns")} ${u}`),m&&y.push(`${r("images")} ${m}`),e.jsxs("button",{type:"button",className:"msg-collapsed","data-msg-id":s.id,title:`${r("expandMsg")} · ${c||y.join(" · ")||s.role}`,onClick:()=>n(s.id),children:[e.jsx("span",{className:`msg-collapsed-role role-${s.role}`,children:s.role==="custom"&&s.customType==="file"?r("attachment"):zn(s.role,r)}),e.jsxs("span",{className:"msg-collapsed-body",children:[c&&e.jsx("span",{className:"msg-collapsed-preview",children:c}),y.length>0&&e.jsx("span",{className:"msg-collapsed-chips",children:y.map((g,x)=>e.jsx("span",{className:"msg-collapsed-chip",children:g},x))})]}),s.timestamp?e.jsx("span",{className:"msg-collapsed-time",children:Rr(s.timestamp)}):null,e.jsxs("span",{className:"msg-collapsed-action",children:[e.jsx(Ge,{})," ",r("expandMsg")]})]})});function Rr(t){const s=new Date(t),n=String(s.getHours()).padStart(2,"0"),r=String(s.getMinutes()).padStart(2,"0");return`${n}:${r}`}const Ir=l.memo(function({id:s,show:n,height:r,containerRef:c,onMeasured:i,lazyRef:a,children:o}){const u=l.useRef(null),m=l.useRef(null);return l.useLayoutEffect(()=>{const y=m.current;if(m.current=n,!n||y!==!1)return;const g=u.current,x=c.current;if(!g||!x)return;const b=g.offsetHeight;i==null||i(s,b);const E=b-r;if(E!==0){const A=g.parentElement;A&&A.getBoundingClientRect().bottom<=x.getBoundingClientRect().top&&(x.scrollTop+=E)}},[n]),n?e.jsx("div",{ref:a,"data-lazy-id":s,children:e.jsx("div",{ref:u,children:o})}):e.jsx("div",{ref:a,className:"msg-lazy-ph","data-msg-id":s,"data-lazy-id":s,style:{height:r},"aria-hidden":"true"})});function Lr(t,s,n,r){const c=[],i=[];let a=0;for(const o of t){if(n.has(o.id))continue;o.top<s.bottom&&o.bottom>s.top?r.has(o.id)&&c.push(o.id):r.has(o.id)||(i.push(o.id),o.bottom<=s.top&&(a+=o.bottom-o.top))}return{show:c,hide:i,shrinkAbove:a}}function Dr(t,s){if(s.show.length===0&&s.hide.length===0)return t;const n=new Set(t);for(const r of s.show)n.delete(r);for(const r of s.hide)n.add(r);return n}function Ar(t,s,n){const r=new Set;let c=0;for(let i=t.length-1;i>=0&&!(i<t.length-1&&c>=n);i--){const a=t[i];r.add(a.id),c+=s.get(a.id)??Vn(a.role,a.customType)}return r}function Vn(t,s){switch(t){case"user":return 72;case"assistant":return 280;case"toolResult":return 8;case"custom":return s==="file"?96:72;default:return 60}}const _r=["text","thinking","argumentsText","output","command"];function Br(t){let s=0;for(const n of t.content){n.type==="image"&&(s+=1);for(const r of _r){const c=n[r];typeof c=="string"&&(s+=c.length)}}return s}function Fr(t,s,n,r){const c=n.get(t);return c&&c.len===s?c.h:r}function $r(t){const s=[];for(const n of t.content)n.type==="text"&&typeof n.text=="string"&&s.push(n.text);return s.join(`
|
|
319
|
+
`)}function Hr(t,s){const n=[];for(const r of t.content)if(r.type==="text"&&typeof r.text=="string")n.push(r.text);else if(r.type==="thinking"&&typeof r.thinking=="string")n.push(r.thinking);else if(r.type==="toolCall"){if(typeof r.name=="string"&&n.push(r.name),typeof r.argumentsText=="string"&&n.push(r.argumentsText),typeof r.id=="string"){const c=s.get(r.id);if(c){const i=$r(c);i&&n.push(i)}}}else r.type==="bash"&&(typeof r.command=="string"&&n.push(r.command),typeof r.output=="string"&&n.push(r.output));return n.join(`
|
|
320
|
+
`)}function Or(t,s){let n=0,r=t.indexOf(s);for(;r!==-1;)n++,r=t.indexOf(s,r+s.length);return n}function Kr(t,s,n,r){const c=new Map,i=n.toLowerCase();if(!i)return c;for(const a of t){if(!s.has(a.id))continue;const o=Or(Hr(a,r).toLowerCase(),i);o>0&&c.set(a.id,o)}return c}function Wr(t,s){var i;const n=[],r=s.toLowerCase();if(!r)return n;const c=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(a){const o=a.parentElement;return!o||o.closest(".search-bar")||o.closest(".msg-collapsed")?NodeFilter.FILTER_REJECT:(a.textContent??"").toLowerCase().includes(r)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let a=c.nextNode();a;a=c.nextNode()){const o=(a.textContent??"").toLowerCase();if(!((i=a.parentElement)!=null&&i.closest("[data-msg-id]")))continue;let u=o.indexOf(r);for(;u!==-1;){const m=document.createRange();m.setStart(a,u),m.setEnd(a,u+r.length),n.push(m),u=o.indexOf(r,u+r.length)}}return n}function Ur(t,s,n,r,c){var u;const i=Kr(n,r,s,c),a=new Map;for(const m of Wr(t,s)){const y=(u=m.startContainer.parentElement)==null?void 0:u.closest("[data-msg-id]");if(!(y!=null&&y.dataset.msgId))continue;const g=a.get(y.dataset.msgId);g?g.push(m):a.set(y.dataset.msgId,[m])}const o=[];for(const m of n){const y=a.get(m.id);if(y)for(let x=0;x<y.length;x++)o.push({kind:"dom",range:y[x],msgId:m.id,k:x});const g=i.get(m.id);if(g)for(let x=0;x<g;x++)o.push({kind:"folded",msgId:m.id,k:x})}return o}function Kt(t,s){return t.findIndex(n=>n.msgId===s.msgId&&n.k===s.k)}function $e(t,s){const n=CSS;if(!n.highlights)return;if(s.length===0){n.highlights.delete(t);return}const r=window.Highlight;r&&n.highlights.set(t,new r(...s))}function qr(t,s){const n=[];let r=t;for(;r&&r!==s;){const c=getComputedStyle(r);/(auto|scroll|hidden)/.test(c.overflowY+c.overflowX)&&(r.scrollHeight>r.clientHeight||r.scrollWidth>r.clientWidth)&&n.push(r),r=r.parentElement}return n}function zr(t,s){const n=s.startContainer.parentElement;for(const o of qr(n,t)){const u=s.getBoundingClientRect(),m=o.getBoundingClientRect();if(u.height<=0||u.width<=0)return;u.top>=m.top+4&&u.bottom<=m.bottom-4||(o.scrollTop+=u.top-m.top-(o.clientHeight-u.height)/2),u.left>=m.left+4&&u.right<=m.right-4||(o.scrollLeft+=u.left-m.left-(o.clientWidth-u.width)/2)}const r=s.getBoundingClientRect(),c=t.getBoundingClientRect();if(r.height<=0||r.width<=0)return;const i=r.top>=c.top+6&&r.bottom<=c.bottom-6,a=r.left>=c.left+6&&r.right<=c.right-6;i&&a||(i||(t.scrollTop+=r.top-c.top-(c.height-r.height)/2),a||(t.scrollLeft+=r.left-c.left-(c.width-r.width)/2))}function Vr({containerRef:t,messages:s,collapsedIds:n,toolResults:r,onExpand:c,onProgrammaticScroll:i,open:a,onClose:o}){const u=xe(),m=l.useRef(null),[y,g]=l.useState(""),[x,b]=l.useState(null),[E,A]=l.useState(0),[,H]=l.useState(0),S=l.useDeferredValue(y),j=a?S.trim():"",J=l.useRef(null);J.current=x;const Q=l.useRef([]),X=l.useRef({key:null}),U=l.useRef("");l.useEffect(()=>{a&&(b(null),requestAnimationFrame(()=>{var Y;return(Y=m.current)==null?void 0:Y.select()}))},[a]),l.useEffect(()=>{if(!a)return;const Y=T=>{T.key==="Escape"&&(T.preventDefault(),T.stopPropagation(),o())};return window.addEventListener("keydown",Y,!0),()=>window.removeEventListener("keydown",Y,!0)},[a,o]),l.useEffect(()=>(a||($e("msg-search",[]),$e("msg-search-active",[])),()=>{$e("msg-search",[]),$e("msg-search-active",[])}),[a]),l.useLayoutEffect(()=>{const Y=()=>{A(0),b(null),H(0),Q.current=[],$e("msg-search",[]),$e("msg-search-active",[]),X.current={key:null},U.current=""};if(!a||!j){Y();return}const T=t.current;if(!T)return;let P=!1,k=0;return k=requestAnimationFrame(()=>{var ne,v;if(P)return;const B=Ur(T,j,s,n,r);Q.current=B;const Z=B.length;if(A(Z),Z===0){b(null),H(0),$e("msg-search",[]),$e("msg-search-active",[]),X.current={key:null},U.current=j;return}const G=J.current;let M;if(G){if(M=Kt(B,G),M===-1){const D=[];for(let d=0;d<B.length;d++)B[d].msgId===G.msgId&&D.push(d);if(D.length>0){const d=Math.min(G.k,D.length-1);M=D[d]}else M=0}}else M=0;M<0&&(M=0),M>=Z&&(M=Z-1),(!G||G.msgId!==B[M].msgId||G.k!==B[M].k)&&b({msgId:B[M].msgId,k:B[M].k}),H(M);const I=B[M],C=X.current,$=((ne=C.key)==null?void 0:ne.msgId)!==I.msgId||((v=C.key)==null?void 0:v.k)!==I.k||C.kind==="folded"&&I.kind==="dom"||j!==U.current;X.current={key:{msgId:I.msgId,k:I.k},kind:I.kind},U.current=j;const z=B.filter(D=>D.kind==="dom").map(D=>D.range);if($e("msg-search",z),I.kind==="folded"){$e("msg-search-active",[]),$&&c(I.msgId);return}$e("msg-search-active",[I.range]),$&&(i==null||i(),zr(T,I.range))}),()=>{P=!0,cancelAnimationFrame(k)}},[a,j,s,t,x,n,r,c,i]);const K=l.useCallback(Y=>{const T=Q.current,P=T.length;if(P===0)return;const k=J.current,B=k?Kt(T,k):0,Z=T[(B+Y+P)%P];b(Z.kind==="dom"||Z.kind==="folded"?{msgId:Z.msgId,k:Z.k}:null)},[]);if(!a)return null;const q=x?(()=>{const Y=Kt(Q.current,x);return Y===-1?0:Y})():0;return e.jsxs("div",{className:"search-bar",role:"search",children:[e.jsx("input",{ref:m,className:"search-input",type:"text",value:y,placeholder:u("searchPlaceholder"),onChange:Y=>{g(Y.target.value)},onKeyDown:Y=>{Y.key==="Enter"&&(Y.preventDefault(),K(Y.shiftKey?-1:1))}}),e.jsx("span",{className:`search-count ${E===0?"empty":""}`,children:E===0?u("searchNoResults"):`${Math.min(q+1,E)}/${E}`}),e.jsx("button",{type:"button",className:"search-btn",title:u("searchPrev"),disabled:E===0,onClick:()=>K(-1),children:e.jsx(ut,{})}),e.jsx("button",{type:"button",className:"search-btn",title:u("searchNext"),disabled:E===0,onClick:()=>K(1),children:e.jsx(Ge,{})}),e.jsx("button",{type:"button",className:"search-btn",title:u("searchClose"),onClick:o,children:e.jsx(Pe,{})})]})}function Gr(t){const{dSt:s,dSh:n,escaped:r,graceActive:c,stuck:i}=t;return c?{flipEscape:!1,reassert:!1}:s>=-4||s<=-500?{flipEscape:!1,reassert:!1}:n<0?{flipEscape:!1,reassert:i&&!r}:{flipEscape:!0,reassert:!1}}const Gn=[{id:"setup-matt-pocock-skills",icon:"🛠",titleKey:"tpl.sk.setup",descKey:"tpl.sk.setup.desc",promptKey:"tpl.sk.setup.prompt"},{id:"ask-matt",icon:"🧭",titleKey:"tpl.sk.ask",descKey:"tpl.sk.ask.desc",promptKey:"tpl.sk.ask.prompt"},{id:"grill-with-docs",icon:"🗣",titleKey:"tpl.sk.grilldocs",descKey:"tpl.sk.grilldocs.desc",promptKey:"tpl.sk.grilldocs.prompt"},{id:"to-spec",icon:"📝",titleKey:"tpl.sk.tospec",descKey:"tpl.sk.tospec.desc",promptKey:"tpl.sk.tospec.prompt"},{id:"to-tickets",icon:"🎫",titleKey:"tpl.sk.totickets",descKey:"tpl.sk.totickets.desc",promptKey:"tpl.sk.totickets.prompt"},{id:"implement",icon:"🏗",titleKey:"tpl.sk.implement",descKey:"tpl.sk.implement.desc",promptKey:"tpl.sk.implement.prompt"},{id:"code-review",icon:"🧹",titleKey:"tpl.sk.codeview",descKey:"tpl.sk.codeview.desc",promptKey:"tpl.sk.codeview.prompt"},{id:"wayfinder",icon:"🗺",titleKey:"tpl.sk.wayfinder",descKey:"tpl.sk.wayfinder.desc",promptKey:"tpl.sk.wayfinder.prompt"},{id:"prototype",icon:"🔬",titleKey:"tpl.sk.prototype",descKey:"tpl.sk.prototype.desc",promptKey:"tpl.sk.prototype.prompt"},{id:"research",icon:"📚",titleKey:"tpl.sk.research",descKey:"tpl.sk.research.desc",promptKey:"tpl.sk.research.prompt"},{id:"improve-codebase-architecture",icon:"🏛",titleKey:"tpl.sk.arch",descKey:"tpl.sk.arch.desc",promptKey:"tpl.sk.arch.prompt"},{id:"diagnosing-bugs",icon:"🐛",titleKey:"tpl.sk.debug",descKey:"tpl.sk.debug.desc",promptKey:"tpl.sk.debug.prompt"},{id:"resolving-merge-conflicts",icon:"🔀",titleKey:"tpl.sk.merge",descKey:"tpl.sk.merge.desc",promptKey:"tpl.sk.merge.prompt"},{id:"triage",icon:"🗂",titleKey:"tpl.sk.triage",descKey:"tpl.sk.triage.desc",promptKey:"tpl.sk.triage.prompt"},{id:"wizard",icon:"✨",titleKey:"tpl.sk.wizard",descKey:"tpl.sk.wizard.desc",promptKey:"tpl.sk.wizard.prompt"},{id:"grill-me",icon:"🔍",titleKey:"tpl.sk.grillme",descKey:"tpl.sk.grillme.desc",promptKey:"tpl.sk.grillme.prompt"},{id:"handoff",icon:"🤝",titleKey:"tpl.sk.handoff",descKey:"tpl.sk.handoff.desc",promptKey:"tpl.sk.handoff.prompt"},{id:"to-questionnaire",icon:"📋",titleKey:"tpl.sk.questionnaire",descKey:"tpl.sk.questionnaire.desc",promptKey:"tpl.sk.questionnaire.prompt"},{id:"teach",icon:"🎓",titleKey:"tpl.sk.teach",descKey:"tpl.sk.teach.desc",promptKey:"tpl.sk.teach.prompt"},{id:"wait-what",icon:"💬",titleKey:"tpl.sk.ww",descKey:"tpl.sk.ww.desc",promptKey:"tpl.sk.ww.prompt"},{id:"writing-for-agents",icon:"📄",titleKey:"tpl.sk.wfa",descKey:"tpl.sk.wfa.desc",promptKey:"tpl.sk.wfa.prompt"},{id:"codebase-design",icon:"🧱",titleKey:"tpl.sk.codesign",descKey:"tpl.sk.codesign.desc",promptKey:"tpl.sk.codesign.prompt"},{id:"domain-modeling",icon:"🏷",titleKey:"tpl.sk.domain",descKey:"tpl.sk.domain.desc",promptKey:"tpl.sk.domain.prompt"},{id:"grilling",icon:"🔥",titleKey:"tpl.sk.grilling",descKey:"tpl.sk.grilling.desc",promptKey:"tpl.sk.grilling.prompt"},{id:"tdd",icon:"🧪",titleKey:"tpl.sk.tdd",descKey:"tpl.sk.tdd.desc",promptKey:"tpl.sk.tdd.prompt"}],Qn="pi-web-ui:prompt-templates";function Qr(){try{const t=localStorage.getItem(Qn);if(!t)return[];const s=JSON.parse(t);return Array.isArray(s)?s.filter(n=>!!n&&typeof n=="object"&&typeof n.id=="string"):[]}catch{return[]}}function en(t){return Gn.some(s=>s.id===t)}function ft(t){return typeof t.title=="string"}const Yn=l.createContext(null);function Jn(){const t=l.useContext(Yn);if(!t)throw new Error("useTemplates must be used within TemplateProvider");return t}function Yr({send:t,children:s}){const n=xe(),[r,c]=l.useState(Qr),[i,a]=l.useState(!1),[o,u]=l.useState(null),[m,y]=l.useState(!1),[g,x]=l.useState(!1),[b,E]=l.useState(!1);l.useEffect(()=>{try{localStorage.setItem(Qn,JSON.stringify(r))}catch{}},[r]);const A=l.useMemo(()=>{const B=new Map,Z=new Set;for(const I of r)I.hidden?Z.add(I.id):(ft(I)&&!en(I.id)||ft(I))&&B.set(I.id,I);const G=Gn.filter(I=>!Z.has(I.id)).map(I=>{const C=B.get(I.id);return{id:I.id,icon:(C==null?void 0:C.icon)??I.icon,title:(C==null?void 0:C.title)??n(I.titleKey),desc:(C==null?void 0:C.desc)??n(I.descKey),prompt:(C==null?void 0:C.prompt)??n(I.promptKey),builtin:!0}}),M=r.filter(I=>ft(I)&&!en(I.id)).map(I=>({id:I.id,icon:I.icon??"📌",title:I.title??"",desc:I.desc??"",prompt:I.prompt??""}));return[...G,...M]},[r,n]),H=l.useCallback(()=>a(!0),[]),S=l.useCallback(B=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:B}))},[]),j=l.useCallback((B,Z=!1)=>{E(Z),B?(y(!1),u({...B})):(y(!0),u({id:Ue(),icon:"📌",title:"",desc:"",prompt:""}))},[]),J=l.useCallback(()=>{a(!1),u(null),E(!1)},[]),Q=l.useCallback(()=>{g?(c([]),x(!1)):(x(!0),setTimeout(()=>x(!1),5e3))},[g]),X=l.useCallback(B=>{a(!1),S(B.prompt)},[S]),U=l.useCallback(B=>{a(!1),j(B,!0)},[j]),K=l.useCallback(()=>{a(!1),j(void 0,!0)},[j]),q=l.useCallback(B=>{c(Z=>{const G=Z.findIndex(M=>M.id===B.id);if(G>=0){const M=[...Z];return M[G]=B,M}return[...Z,B]}),u(null),b&&(a(!0),E(!1))},[b]),Y=l.useCallback(B=>{c(Z=>B.builtin?[...Z.filter(M=>M.id!==B.id),{id:B.id,hidden:!0}]:Z.filter(G=>G.id!==B.id)),u(null),b&&(a(!0),E(!1))},[b]),T=l.useCallback(B=>{c(Z=>Z.filter(G=>G.id!==B.id||G.hidden)),u(null),b&&(a(!0),E(!1))},[b]),P=l.useMemo(()=>({templates:A,fill:S,openPicker:H,openEdit:j,resetConfirm:g,toggleReset:Q}),[A,S,H,j,g,Q]),k=o?r.some(B=>B.id===o.id&&!B.hidden&&ft(B)):!1;return e.jsxs(Yn.Provider,{value:P,children:[s,i&&e.jsx(Xr,{templates:A,resetConfirm:g,onFill:X,onEditTpl:U,onNew:K,onResetToggle:Q,onClose:J}),o&&e.jsx(Zr,{editing:o,isNew:m,hasOverride:k,onDraft:u,onSave:q,onRestore:()=>T(o),onRemove:()=>Y(o),onFill:()=>{window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:o.prompt})),J()},onSend:()=>{const B=o.prompt.trim();B&&t({type:"prompt",text:B,queue:!1})&&J()},onClose:J})]})}function Jr(){const t=xe(),{templates:s,fill:n,openEdit:r,toggleReset:c,resetConfirm:i}=Jn();return e.jsxs("div",{className:"empty-templates",children:[e.jsxs("div",{className:"empty-templates-head",children:[e.jsx("span",{className:"empty-templates-title",children:t("tpl.title")}),e.jsx("span",{className:"empty-templates-hint",children:t("tpl.hint")})]}),e.jsxs("div",{className:"empty-templates-grid",children:[s.map(a=>e.jsx(Xn,{tpl:a,title:t("tpl.clickCard"),onFill:()=>n(a.prompt),onEdit:()=>r(a),editTitle:t("tpl.editTpl")},a.id)),e.jsxs("button",{type:"button",className:"empty-template add",onClick:()=>r(),title:t("tpl.add"),children:[e.jsx("span",{className:"empty-template-icon",children:e.jsx(He,{})}),e.jsxs("span",{className:"empty-template-main",children:[e.jsx("span",{className:"empty-template-title",children:t("tpl.add")}),e.jsx("span",{className:"empty-template-desc",children:t("tpl.addDesc")})]})]})]}),e.jsx("div",{className:"empty-templates-foot",children:e.jsxs("button",{type:"button",className:"empty-templates-reset",onClick:c,children:[e.jsx(bn,{}),t(i?"tpl.resetConfirm":"tpl.reset")]})})]})}function Xn({tpl:t,title:s,onFill:n,onEdit:r,editTitle:c}){const i=xe();return e.jsxs("button",{type:"button",className:"empty-template",title:s,onClick:n,children:[e.jsx("span",{className:"empty-template-icon",children:t.icon}),e.jsxs("span",{className:"empty-template-main",children:[e.jsx("span",{className:"empty-template-title",children:t.title}),e.jsx("span",{className:"empty-template-desc",children:t.desc})]}),e.jsx("span",{className:"template-card-ops",role:"button",title:c??i("tpl.editTpl"),onClick:a=>{a.stopPropagation(),r()},children:e.jsx(St,{})})]})}function Xr({templates:t,resetConfirm:s,onFill:n,onEditTpl:r,onNew:c,onResetToggle:i,onClose:a}){const o=xe();return l.useEffect(()=>{const u=m=>{m.key==="Escape"&&a()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[a]),e.jsx("div",{className:"modal-backdrop",onClick:a,children:e.jsxs("div",{className:"modal template-picker",onClick:u=>u.stopPropagation(),children:[e.jsxs("div",{className:"template-picker-head",children:[e.jsx("span",{className:"template-picker-title",children:o("tpl.pickerTitle")}),e.jsx("button",{type:"button",className:"btn template-modal-close",title:o("close"),onClick:a,children:e.jsx(Pe,{})})]}),e.jsx("div",{className:"template-picker-hint",children:o("tpl.pickerHint")}),e.jsxs("div",{className:"template-picker-grid",children:[t.map(u=>e.jsx(Xn,{tpl:u,title:o("tpl.clickCard"),onFill:()=>n(u),onEdit:()=>r(u),editTitle:o("tpl.editTpl")},u.id)),e.jsxs("button",{type:"button",className:"empty-template add",onClick:c,title:o("tpl.add"),children:[e.jsx("span",{className:"empty-template-icon",children:e.jsx(He,{})}),e.jsxs("span",{className:"empty-template-main",children:[e.jsx("span",{className:"empty-template-title",children:o("tpl.add")}),e.jsx("span",{className:"empty-template-desc",children:o("tpl.addDesc")})]})]})]}),e.jsx("div",{className:"template-picker-foot",children:e.jsxs("button",{type:"button",className:"empty-templates-reset",onClick:i,children:[e.jsx(bn,{}),o(s?"tpl.resetConfirm":"tpl.reset")]})})]})})}function Zr({editing:t,isNew:s,hasOverride:n,onDraft:r,onSave:c,onRestore:i,onRemove:a,onFill:o,onSend:u,onClose:m}){const y=xe(),g=l.useRef(null);l.useEffect(()=>{const E=A=>{A.key==="Escape"&&m()};return window.addEventListener("keydown",E),()=>window.removeEventListener("keydown",E)},[m]),l.useEffect(()=>{const E=g.current;if(!E)return;E.style.height="auto";const A=E.scrollHeight>300;E.style.height=`${Math.min(E.scrollHeight,300)}px`,E.style.overflowY=A?"auto":"hidden"},[t.prompt]);const x=()=>{const E=t.title.trim(),A=t.prompt.trim();if(!E||!A){r({...t,error:y("tpl.required")});return}c({id:t.id,icon:t.icon.trim()||"📌",title:E,desc:t.desc.trim(),prompt:A})},b=!!t.builtin&&!s;return e.jsx("div",{className:"modal-backdrop",onClick:m,children:e.jsxs("div",{className:"modal template-modal",onClick:E=>E.stopPropagation(),children:[e.jsxs("div",{className:"template-modal-head",children:[e.jsx("span",{className:"template-modal-icon",children:t.icon}),e.jsx("span",{className:"template-modal-badge",children:y(b?"tpl.builtin":"tpl.custom")}),e.jsx("span",{className:"template-modal-title",children:y(s?"tpl.newTitle":"tpl.editTitle")}),e.jsx("button",{type:"button",className:"btn template-modal-close",title:y("close"),onClick:m,children:e.jsx(Pe,{})})]}),e.jsxs("label",{className:"template-field",children:[e.jsx("span",{className:"template-field-label",children:y("tpl.fieldIcon")}),e.jsx("input",{className:"template-field-input icon",value:t.icon,maxLength:4,onChange:E=>r({...t,icon:E.target.value})})]}),e.jsxs("label",{className:"template-field",children:[e.jsx("span",{className:"template-field-label",children:y("tpl.fieldTitle")}),e.jsx("input",{className:"template-field-input",value:t.title,placeholder:y("tpl.fieldTitlePh"),onChange:E=>r({...t,title:E.target.value})})]}),e.jsxs("label",{className:"template-field",children:[e.jsx("span",{className:"template-field-label",children:y("tpl.fieldDesc")}),e.jsx("input",{className:"template-field-input",value:t.desc,placeholder:y("tpl.fieldDescPh"),onChange:E=>r({...t,desc:E.target.value})})]}),e.jsxs("label",{className:"template-field",children:[e.jsx("span",{className:"template-field-label",children:y("tpl.fieldPrompt")}),e.jsx("textarea",{ref:g,className:"template-field-prompt",value:t.prompt,placeholder:y("tpl.fieldPromptPh"),onChange:E=>r({...t,prompt:E.target.value})})]}),t.error&&e.jsx("div",{className:"template-error",children:t.error}),e.jsxs("div",{className:"template-modal-actions",children:[e.jsxs("div",{className:"template-modal-actions-left",children:[!s&&b&&n&&e.jsx("button",{type:"button",className:"btn template-btn ghost",title:y("tpl.restoreTip"),onClick:i,children:y("tpl.restore")}),!s&&b&&e.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:y("tpl.removeTip"),onClick:a,children:[e.jsx(Ae,{})," ",y("tpl.remove")]}),!s&&!b&&e.jsxs("button",{type:"button",className:"btn template-btn ghost danger",title:y("tpl.deleteTip"),onClick:a,children:[e.jsx(Ae,{})," ",y("tpl.delete")]})]}),e.jsxs("div",{className:"template-modal-actions-right",children:[e.jsx("button",{type:"button",className:"btn template-btn",onClick:x,children:y("tpl.save")}),e.jsx("button",{type:"button",className:"btn template-btn fill",onClick:o,title:y("tpl.fillTip"),children:y("tpl.fill")}),e.jsxs("button",{type:"button",className:"btn template-btn send",onClick:u,title:y("tpl.sendTip"),children:[e.jsx(vn,{})," ",y("tpl.sendNow")]})]})]})]})})}const tn=new Map,el=15,sn=30,Wt=250,nn=1200,tl=1600;function an(t){return t.content.some(s=>s.type==="toolCall")}function sl({state:t,liveOutputs:s,toolStatuses:n,onEdit:r,onKillBash:c,onRemoveQueued:i,thinkingWrap:a,toolsWrap:o,jumpTarget:u,onJumpDone:m}){const y=xe(),g=l.useRef(null),[x,b]=l.useState(!0),E=l.useRef(!0),A=l.useRef(0),H=l.useRef(0),S=l.useRef(!1),j=l.useRef(0),[J,Q]=l.useState(()=>new Set),[X,U]=l.useState(!1),K=t.streamingMessage?[...t.messages,t.streamingMessage]:t.messages,q=l.useMemo(()=>{const N=new Map;for(const _ of t.messages)_.role==="toolResult"&&_.toolCallId&&N.set(_.toolCallId,_);return N},[t.messages]),Y=l.useMemo(()=>Pr(t.messages),[t.messages]),T=K.length>0?K[K.length-1].id:null,P=t.messages.length>sn?Math.max(0,t.messages.length-el):0,k=l.useMemo(()=>{const N=new Set;for(let _=0;_<P;_++){const ie=t.messages[_];ie.role!=="toolResult"&&(J.has(ie.id)||N.add(ie.id))}return N},[t.messages,P,J]),[B,Z]=l.useState(()=>new Set),[G,M]=l.useState(()=>new Set),I=l.useRef(new Map),C=l.useRef(new Map),$=l.useRef(new Map),z=l.useRef(0),ne=l.useMemo(()=>{const N=new Map;for(const _ of t.messages)N.set(_.id,Br(_));return N},[t.messages]),v=l.useRef(ne);v.current=ne;const D=l.useRef(B);D.current=B;const d=t.messages.length>sn&&!X,w=l.useRef(d);w.current=d;const h=Ar(t.messages,I.current,tl),L=l.useRef(h);L.current=h;const ee=l.useCallback(()=>{const N=g.current;if(!N)return;if(!w.current){Z(we=>we.size?new Set:we);return}const _=N.getBoundingClientRect(),ie={top:_.top-nn,bottom:_.bottom+nn},le=[];for(const[we,Te]of $.current){const Oe=Te.getBoundingClientRect();le.push({id:we,top:Oe.top,bottom:Oe.bottom}),D.current.has(we)||ye(we,Oe.bottom-Oe.top,v.current.get(we))}const je=Lr(le,ie,L.current,D.current);for(const we of je.hide){const Te=$.current.get(we);Te&&ye(we,Te.offsetHeight,v.current.get(we))}Z(we=>Dr(we,je))},[]),W=l.useCallback(()=>{z.current||(z.current=requestAnimationFrame(()=>{z.current=0,ee()}))},[ee]);l.useLayoutEffect(()=>{ee()},[ee]);const ae=l.useRef(X);l.useLayoutEffect(()=>{ae.current&&!X&&ee(),ae.current=X},[X,ee]);const ye=l.useCallback((N,_,ie)=>{ie!==void 0&&(C.current.set(N,{h:_,len:ie}),I.current.set(N,_))},[]),be=l.useCallback((N,_)=>{ye(N,_,v.current.get(N))},[ye]),ge=l.useCallback(N=>{N&&$.current.set(N.dataset.lazyId??"",N)},[]);l.useEffect(()=>{const N=new Set(t.messages.map(_=>_.id));for(const _ of $.current.keys())N.has(_)||($.current.delete(_),I.current.delete(_),C.current.delete(_));Z(_=>{let ie=!1;const le=new Set;for(const je of _)N.has(je)?le.add(je):ie=!0;return ie?le:_})},[t.messages,J]),l.useEffect(()=>()=>cancelAnimationFrame(z.current),[]);const ke=l.useMemo(()=>{const N=[];for(const _ of t.messages){if(_.role!=="user")continue;const ie=_.content.map(we=>{var Te;return((Te=ct(we))==null?void 0:Te.text)??""}).filter(Boolean).join(" "),le=ds(ie),je=le?le.userMessage??`skill:${le.name}`:ie.trim();je&&N.push({id:_.id,text:je})}return N},[t.messages]),Ee=l.useMemo(()=>{const N=new Map;return ke.forEach((_,ie)=>N.set(_.id,ie)),N},[ke]),[re,f]=l.useState(-1),O=l.useRef(-1),de=l.useRef(ke);l.useEffect(()=>{de.current=ke},[ke]);const ue=l.useCallback(()=>{const N=g.current,_=de.current;if(!N||_.length===0)return;const ie=N.getBoundingClientRect().top,le=140;let je=-1;for(let we=0;we<_.length;we++){const Te=N.querySelector(`[data-msg-id="${_[we].id}"]`);if(Te)if(Te.getBoundingClientRect().top<=ie+le)je=we;else break}je!==O.current&&(O.current=je,f(je))},[]);l.useEffect(()=>{ue()},[ke,ue]);const me=l.useCallback(N=>{Q(_=>_.has(N)?_:new Set(_).add(N))},[]);l.useEffect(()=>{const N=_=>{if(!(_.ctrlKey||_.metaKey)||_.key.toLowerCase()!=="f")return;const ie=_.target;ie&&(ie.tagName==="INPUT"||ie.tagName==="TEXTAREA"||ie.isContentEditable)||(_.preventDefault(),U(!0))};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[]);const pe=l.useCallback(N=>{Q(_=>{if(!_.has(N))return _;const ie=new Set(_);return ie.delete(N),ie})},[]),ve=l.useCallback(N=>{const _=t.messages.findIndex(le=>le.id===N);qa.flushSync(()=>{_>=0&&_<P&&!J.has(N)&&me(N),M(le=>le.has(N)?le:new Set(le).add(N))});const ie=de.current.findIndex(le=>le.id===N);O.current=ie,f(ie),requestAnimationFrame(()=>{var je,we,Te;const le=(je=g.current)==null?void 0:je.querySelector(`[data-msg-id="${N}"]`);le&&((we=g.current)==null||we.querySelectorAll(".msg-flash").forEach(Oe=>Oe.classList.remove("msg-flash")),le.scrollIntoView({block:"start"}),le.classList.remove("msg-flash"),le.offsetWidth,le.classList.add("msg-flash"),le!==((Te=g.current)==null?void 0:Te.lastElementChild)&&(S.current=!0))})},[t.messages,P,J,me]),Me=l.useMemo(()=>{var N;return u?((N=t.messages.find(_=>_.role===u.role&&_.timestamp===u.timestamp))==null?void 0:N.id)??null:null},[t.messages,u]);l.useEffect(()=>{if(u){if(Me){ve(Me),m==null||m();return}t.sessionFile===u.path&&t.messages.length>0&&(m==null||m())}},[Me,ve,m,u,t.sessionFile,t.messages.length]);const he=l.useCallback(()=>{const N=g.current;if(!N)return;const _=N.scrollTop-A.current,ie=N.scrollHeight-H.current;A.current=N.scrollTop,H.current=N.scrollHeight;const le=N.scrollHeight-N.scrollTop-N.clientHeight<80,je=Date.now()<j.current,we=Gr({dSt:_,dSh:ie,escaped:S.current,graceActive:je,stuck:E.current});we.reassert&&(j.current=Date.now()+Wt,N.scrollTop=N.scrollHeight),we.flipEscape&&(S.current=!0),le&&_>=0&&(S.current=!1),je||(_<0?E.current=le&&!S.current:le&&(E.current=!0)),b(E.current),ue(),W()},[ue,W]),_e=l.useRef(!1);l.useEffect(()=>{const N=_e.current;if(_e.current=!!t.isStreaming,N&&!t.isStreaming&&!S.current){const _=()=>{const le=g.current;le&&!S.current&&(le.scrollTop=le.scrollHeight,E.current=!0,b(!0))};requestAnimationFrame(()=>requestAnimationFrame(_));const ie=setTimeout(_,180);return()=>clearTimeout(ie)}},[t.isStreaming]),l.useEffect(()=>{const N=g.current;N&&E.current&&(N.scrollTop=N.scrollHeight)},[K,t.isStreaming,s]);const Le=t.queue.steering.join("\0")+""+t.queue.followUp.join("\0");l.useEffect(()=>{const N=g.current;N&&E.current&&(N.scrollTop=N.scrollHeight)},[Le]),l.useEffect(()=>{const N=g.current;if(!N||typeof ResizeObserver>"u")return;const _=new ResizeObserver(()=>{E.current&&!S.current&&(N.scrollTop=N.scrollHeight,b(!0))});return _.observe(N),()=>_.disconnect()},[]),l.useEffect(()=>{const N=g.current;if(!N||typeof MutationObserver>"u")return;let _=!1;const ie=new MutationObserver(()=>{_||(_=!0,requestAnimationFrame(()=>{_=!1;const le=g.current;le&&E.current&&!S.current&&(le.scrollTop=le.scrollHeight,b(!0))}))});return ie.observe(N,{childList:!0,subtree:!0,characterData:!0}),()=>ie.disconnect()},[]);const Be=l.useCallback(()=>{if(!g.current)return;E.current=!0,S.current=!1,b(!0),j.current=Date.now()+Wt;const _=()=>{const ie=g.current;!ie||!E.current||S.current||(j.current=Date.now()+Wt,ie.scrollTop=ie.scrollHeight)};_(),requestAnimationFrame(()=>requestAnimationFrame(_)),setTimeout(_,120),setTimeout(_,300),setTimeout(_,600)},[]),De=l.useRef(null);l.useEffect(()=>{const N=De.current,_=g.current;if(!N||!_)return;const ie=le=>{le.preventDefault();const je=N.querySelector(".qn-list");if(je&&je.contains(le.target)&&je.scrollHeight>je.clientHeight){je.scrollTop+=le.deltaY;return}_.scrollTop+=le.deltaY};return N.addEventListener("wheel",ie,{passive:!1}),()=>N.removeEventListener("wheel",ie)},[]);const[R,fe]=l.useState(0);l.useEffect(()=>{const N=()=>{var _;fe(((_=g.current)==null?void 0:_.clientHeight)??0),W()};return N(),window.addEventListener("resize",N),()=>window.removeEventListener("resize",N)},[W]);const oe=ke.length,p=l.useMemo(()=>oe===0?27:Math.max(4,Math.min(27,Math.floor(((R||600)-16)/oe)-3)),[oe,R]),V=p<20;return e.jsxs("div",{className:"messages-wrap",children:[e.jsxs("div",{className:`messages${X||x?"":" anchor-live"}`,ref:g,onScroll:he,children:[t.messages.length===0&&!t.streamingMessage&&e.jsx("div",{className:"empty-state",children:e.jsx(Jr,{})}),t.messages.map((N,_)=>{const ie=_<P,le=ie&&J.has(N.id);if(ie&&!le)return N.role==="toolResult"?null:e.jsx(Mr,{message:N,onExpand:me},N.id);const je=N.role==="user"?Ee.get(N.id):void 0,we=!d||h.has(N.id)||G.has(N.id)||!B.has(N.id);return e.jsx(Ir,{id:N.id,show:we,height:Fr(N.id,ne.get(N.id)??-1,C.current,Vn(N.role,N.customType)),containerRef:g,onMeasured:be,lazyRef:ge,children:e.jsx(Ys,{message:N,qnIndex:je,qnActive:je!==void 0?je===re:void 0,onJump:ve,toolResults:q,liveOutputs:an(N)?s:tn,toolStatuses:n,streaming:t.isStreaming,onKillBash:c,toolsWrap:o,thinkingWrap:a,isLast:N.id===T,onEdit:r,questionAttachments:Y.get(N.id),onCollapse:le?pe:void 0,searchActive:X},N.id)},N.id)}),t.streamingMessage&&e.jsx(Ys,{message:t.streamingMessage,toolResults:q,liveOutputs:an(t.streamingMessage)?s:tn,toolStatuses:n,streaming:!0,isLast:!0,onEdit:r,onKillBash:c,toolsWrap:o,thinkingWrap:a,searchActive:X},t.streamingMessage.id),t.isStreaming&&K.length===0&&e.jsx("div",{className:"streaming-wait",children:y("waitingResponse")}),t.queue.steering.map((N,_)=>e.jsx("div",{className:"queued-msg",children:e.jsxs("div",{className:"queued-bubble",children:[e.jsx("span",{className:"queued-tag steer",children:y("queueSteerTag")}),e.jsx("div",{className:"queued-text",children:N}),i&&e.jsx("button",{type:"button",className:"queued-remove",title:y("queueRemoveTip"),onClick:()=>i("steer",N),children:"✕"})]})},`q-steer-${_}`)),t.queue.followUp.map((N,_)=>e.jsx("div",{className:"queued-msg",children:e.jsxs("div",{className:"queued-bubble",children:[e.jsx("span",{className:"queued-tag follow",children:y("queueFollowTag")}),e.jsx("div",{className:"queued-text",children:N}),i&&e.jsx("button",{type:"button",className:"queued-remove",title:y("queueRemoveTip"),onClick:()=>i("followUp",N),children:"✕"})]})},`q-fu-${_}`))]}),!x&&e.jsxs("button",{type:"button",className:"scroll-bottom",onClick:Be,children:[e.jsx(Sn,{})," ",y("backToBottom")]}),e.jsx(Vr,{containerRef:g,messages:K,collapsedIds:k,toolResults:q,onExpand:me,onProgrammaticScroll:()=>{S.current=!0,E.current=!1,b(!1)},open:X,onClose:()=>U(!1)}),ke.length>0&&e.jsxs("div",{className:`qn-rail ${V?"many":""}`,ref:De,"aria-label":y("questionNavTitle"),style:{"--rail-gap":`${p}px`},children:[ke.map((N,_)=>e.jsx("button",{type:"button",className:`qn-bar ${_===re?"active":""}`,"aria-label":`${_+1}. ${N.text}`,onClick:()=>ve(N.id),children:e.jsxs("span",{className:"qn-bar-text",children:[_+1,". ",N.text]})},N.id)),V&&e.jsx("div",{className:"qn-list",children:ke.map((N,_)=>e.jsxs("button",{type:"button",className:`qn-list-item ${_===re?"active":""}`,"aria-label":`${_+1}. ${N.text}`,onClick:()=>ve(N.id),children:[e.jsx("span",{className:"qn-list-idx",children:_+1}),e.jsx("span",{className:"qn-list-text",children:N.text})]},N.id))})]})]})}const Zn="pi-web-model-usage";function nl(t){if(!t||typeof t!="object")return{};const s={};for(const[n,r]of Object.entries(t)){const c=typeof r=="number"?Math.floor(r):0;Number.isFinite(c)&&c>0&&(s[n]=c)}return s}function il(t,s){return s?{...t,[s]:(t[s]??0)+1}:t}function al(t,s){const n=s;return t.map((r,c)=>({m:r,i:c,count:n[r.id]??0})).sort((r,c)=>c.count-r.count||r.i-c.i).map(r=>r.m)}function ei(){try{const t=localStorage.getItem(Zn);return t?nl(JSON.parse(t)):{}}catch{return{}}}function rl(t){try{localStorage.setItem(Zn,JSON.stringify(t))}catch{}}function ll(t){const s=il(ei(),t);return rl(s),s}const us="pi-web-ui:prompt-history",ol=100,ti="pi-web-ui:prompt-history-settings",is={maxEntries:100,charLimitEnabled:!1,charLimit:2e3};function si(t){const s=is;if(!t||typeof t!="object")return{...s};const n=t;let r=typeof n.maxEntries=="number"?Math.floor(n.maxEntries):s.maxEntries;(!Number.isFinite(r)||r<1)&&(r=1),r>500&&(r=500);let c=typeof n.charLimit=="number"?Math.floor(n.charLimit):s.charLimit;(!Number.isFinite(c)||c<100)&&(c=100),c>2e4&&(c=2e4);const i=typeof n.charLimitEnabled=="boolean"?n.charLimitEnabled:s.charLimitEnabled;return{maxEntries:r,charLimitEnabled:i,charLimit:c}}function ni(){try{const t=localStorage.getItem(ti);return t?si(JSON.parse(t)):{...is}}catch{return{...is}}}function Ut(t){const s=si(t);try{localStorage.setItem(ti,JSON.stringify(s))}catch{}try{let n=dt();s.charLimitEnabled&&(n=n.map(r=>r.length>s.charLimit?r.slice(0,s.charLimit):r)),n.length>s.maxEntries&&(n=n.slice(n.length-s.maxEntries)),ii(n)}catch{}}function cl(t){if(!Array.isArray(t))return[];const s=[];for(const n of t){if(typeof n!="string")continue;const r=n.trim();r&&s.push(r)}return s}function dl(t,s,n=ol){const r=s.trim();if(!r||t.length>0&&t[t.length-1]===r)return t;const c=[...t,r];return c.length>n?c.slice(c.length-n):c}function dt(){try{const t=localStorage.getItem(us);return t?cl(JSON.parse(t)):[]}catch{return[]}}function ii(t){let s=t;for(;s;)try{localStorage.setItem(us,JSON.stringify(s));return}catch(n){if(!(n instanceof DOMException&&(n.name==="QuotaExceededError"||n.code===22))||s.length<=1)return;s=s.slice(Math.ceil(s.length/2))}}function ul(t){let s=t.trim();if(!s)return;const n=ni();n.charLimitEnabled&&s.length>n.charLimit&&(s=s.slice(0,n.charLimit));const r=dt(),c=dl(r,s,n.maxEntries);c!==r&&ii(c)}function pl(){try{localStorage.removeItem(us)}catch{}}const ml=["off","minimal","low","medium","high","xhigh","max"],hl=l.memo(function({state:s,models:n,modelsLoading:r,send:c,onManageModels:i,providerKeys:a,compact:o=!1}){const u=xe(),m=s==null?void 0:s.model,y=m?`${m.provider}/${m.id}`:null,[g,x]=l.useState(!1),[b,E]=l.useState(!1),[A,H]=l.useState(""),[S,j]=l.useState(null),[J,Q]=l.useState({}),X=l.useRef(null),U=l.useRef(null),[K,q]=l.useState(null);l.useEffect(()=>{if(!g){q(null);return}if(n.length===0)return;const C=requestAnimationFrame(()=>{const $=U.current;$&&q($.offsetWidth)});return()=>cancelAnimationFrame(C)},[g,n.length]),l.useEffect(()=>{g&&Q(ei())},[g]),l.useEffect(()=>{g||(H(""),j(null))},[g]);const Y=l.useMemo(()=>{const C=new Map;for(const z of n)C.set(z.provider,(C.get(z.provider)??0)+1);const $=[];for(const[z,ne]of[...C.entries()].sort((v,D)=>v[0].localeCompare(D[0]))){const v=a[z];if(v&&v.length>1)for(const D of v)$.push({provider:z,keyName:D.name,count:ne});else $.push({provider:z,keyName:null,count:ne})}return $},[n,a]),T=l.useMemo(()=>al(n,J),[n,J]),P=l.useMemo(()=>{let C=T;S&&(C=C.filter(z=>z.provider===S.provider));const $=A.trim().toLowerCase();return $?C.filter(z=>z.name.toLowerCase().includes($)||z.provider.toLowerCase().includes($)||z.id.toLowerCase().includes($)):C},[T,A,S]),k=l.useMemo(()=>{const C=[];for(const $ of P){const z=a[$.provider];if(!z||z.length<=1){C.push({model:$,key:null});continue}let ne=z.find(v=>v.active)??z[0];if((S==null?void 0:S.provider)===$.provider&&S.keyName){const v=z.find(D=>D.name===S.keyName);v&&(ne=v)}C.push({model:$,key:ne})}return C},[P,a,S]),[B,Z]=l.useState(!1),G=s!=null&&s.availableThinkingLevels&&s.availableThinkingLevels.length>0?new Set(s.availableThinkingLevels):null,M=ml.map(C=>({value:C,label:u(`thinking.${C}`),supported:G?G.has(C):!0})),I=C=>{var $;return(($=M.find(z=>z.value===C))==null?void 0:$.label)??C};return l.useEffect(()=>{g&&n.length===0&&!B&&!r&&(Z(!0),c({type:"list_models"}))},[g,n.length,B,r,c]),l.useEffect(()=>{n.length>0&&Z(!1)},[n.length]),l.useEffect(()=>{var $;if(!g)return;const C=($=X.current)==null?void 0:$.querySelector(".dd-item.active");C==null||C.scrollIntoView({block:"nearest"})},[g,y,n.length]),e.jsxs(e.Fragment,{children:[e.jsxs(ze,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(lt,{}),e.jsx("span",{className:"chip-model",children:m?m.name:u("selectModel")}),!o&&(m==null?void 0:m.vision)&&e.jsx("span",{className:"chip-vision",title:u("vision"),children:"🖼"}),!o&&m&&e.jsx("span",{className:"chip-sub",children:m.provider})]}),open:g,onOpenChange:x,menuClassName:"dd-menu-model",menuRef:U,menuStyle:K!=null?{width:K}:void 0,direction:"up",children:[e.jsx("div",{className:"dd-header",children:u("availableModels")}),e.jsxs("div",{className:"dd-search-row",children:[e.jsx(Nt,{}),e.jsx("input",{className:"dd-search",type:"text",placeholder:u("searchModels"),value:A,onChange:C=>H(C.target.value)})]}),e.jsxs("div",{className:"dd-model-body",children:[Y.length>1&&e.jsxs("div",{className:"dd-provider-col",children:[e.jsx("div",{className:"dd-provider-head",children:u("providers")}),e.jsx("button",{type:"button",className:`dd-provider-item ${S===null?"active":""}`,onClick:()=>j(null),children:e.jsx("span",{children:u("allProviders")})}),Y.map(C=>{const $=(S==null?void 0:S.provider)===C.provider&&(S==null?void 0:S.keyName)===C.keyName;return e.jsxs("button",{type:"button",className:`dd-provider-item ${$?"active":""}`,onClick:()=>j($?null:{provider:C.provider,keyName:C.keyName}),title:C.keyName?`${C.provider} · ${C.keyName}`:`${C.provider} · ${C.count}`,children:[e.jsxs("span",{className:"dd-provider-txt",children:[e.jsx("span",{className:"dd-provider-name",children:C.provider}),C.keyName&&e.jsx("span",{className:"dd-provider-key",children:C.keyName})]}),e.jsx("span",{className:"dd-provider-count",children:C.count})]},C.keyName?`${C.provider}::${C.keyName}`:C.provider)})]}),e.jsxs("div",{className:"dd-model-scroll",ref:X,children:[(B||r)&&e.jsx("div",{className:"dd-loading",children:u("loading")}),n.length===0&&!B&&!r&&e.jsx("div",{className:"dd-loading",children:u("noModels")}),P.length===0&&n.length>0&&e.jsx("div",{className:"dd-loading",children:u("noModelMatches")}),k.map(C=>{const $=C.model,z=y===$.id&&(!C.key||C.key.active);return e.jsx(Ie,{active:z,onClick:()=>{C.key&&!C.key.active&&c({type:"activate_provider_key",provider:$.provider,keyName:C.key.name}),y!==$.id&&c({type:"set_model",modelId:$.id}),x(!1)},children:e.jsxs("span",{className:"dd-model-cell",children:[e.jsx("span",{className:"dd-model-name",children:$.name}),e.jsxs("span",{className:"dd-model-meta",children:[e.jsx("span",{className:"dd-model-provider",children:$.provider}),C.key&&e.jsxs("span",{className:`dd-model-key ${C.key.active?"active":""}`,children:[C.key.active?"●":"○"," ",C.key.name]}),(J[$.id]??0)>0&&e.jsx("span",{className:"dd-model-usage",children:u("modelUsedCount",{n:J[$.id]})}),($.reasoning||$.vision)&&e.jsxs("span",{className:"dd-model-badges",children:[$.reasoning&&e.jsx("span",{className:"dd-model-badge",children:u("reasoning")}),$.vision&&e.jsx("span",{className:"dd-model-badge",children:u("vision")})]})]})]})},C.key?`${$.id}::${C.key.name}`:$.id)})]})]}),e.jsxs("div",{className:"dd-footer",children:[e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>c({type:"list_models"}),children:u("refreshModels")}),e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>{x(!1),i()},children:u("manageModels")})]})]}),e.jsxs(ze,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(xt,{}),e.jsx("span",{className:"chip-sub",children:u("thinkingChip",{level:s?I(s.thinkingLevel):"—"})})]}),open:b,onOpenChange:E,direction:"up",children:[e.jsx("div",{className:"dd-header",children:u("thinkingLevel")}),M.map(C=>e.jsx(Ie,{active:(s==null?void 0:s.thinkingLevel)===C.value,disabled:!C.supported,title:C.supported?void 0:u("thinkingUnsupported"),onClick:()=>{(s==null?void 0:s.thinkingLevel)!==C.value&&c({type:"set_thinking",level:C.value}),E(!1)},children:C.label},C.value))]})]})}),gl=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches,fl=l.memo(function({ready:s,streaming:n,messages:r,slashCommands:c,modelState:i,models:a,modelsLoading:o,send:u,attachments:m,onRemoveAttachment:y,onAddImageFiles:g,onAddLocalFiles:x,onNotice:b,onSent:E,onManageModels:A,providerKeys:H}){const S=xe(),{locale:j}=mt(),{openPicker:J}=Jn(),Q=f=>j==="en"&&f.descriptionEn?f.descriptionEn:f.description??"",X=f=>j==="en"&&f.argumentHintEn?f.argumentHintEn:f.argumentHint??"",[U,K]=l.useState(""),[q,Y]=l.useState(!1),[T,P]=l.useState(null),[k,B]=l.useState(0),[Z,G]=l.useState(!1),[M,I]=l.useState(void 0),C=l.useRef(null),$=l.useRef(null),z=l.useRef(null),ne=l.useRef(-1),v=l.useRef(""),D={builtin:S("slashBuiltin"),extension:S("slashExtension"),prompt:S("slashPrompt"),skill:S("slashSkill"),plugin:S("slashPlugin")},d=f=>{const O=f.match(/^\/([^\s]*)$/);if(O&&s){const de=O[1].toLowerCase(),ue=c.filter(me=>me.name.toLowerCase().startsWith(de));P(ue.length>0?ue:null),B(0)}else P(null)};l.useEffect(()=>{var O;const f=(O=z.current)==null?void 0:O.querySelector(".slash-item.active");f==null||f.scrollIntoView({block:"nearest"})},[k,T]);const w=f=>{var pe;const O=T??[],de=f??O[k%Math.max(O.length,1)];if(!de){P(null);return}const ue=U.match(/^\/([^\s]*)([\s\S]*)$/),me=ue?ue[2]:"";K(`/${de.name} ${me}`),P(null),(pe=C.current)==null||pe.focus()},h=async()=>{const O=[...r].reverse().find(ue=>ue.role==="assistant"&&ue.content.some(me=>me.type==="text"&&me.text)),de=O==null?void 0:O.content.filter(ue=>ue.type==="text").map(ue=>ue.text).join(`
|
|
321
|
+
`);if(!de){b("warning",S("slashCopyEmpty"));return}try{await navigator.clipboard.writeText(de),b("info",S("slashCopied"))}catch{b("error",S("slashCopyFailed"))}},L=f=>{if(!f||f.length===0){b("warning",S("foldersNotSupported"));return}const O=Array.from(f).filter(me=>We(me.type)),de=Array.from(f).filter(me=>!We(me.type)),ue=W();O.length>0&&ue?b("warning",ue):O.length>0&&g(O),de.length>0&&x(de)},ee=f=>{var me;const O=(me=f.clipboardData)==null?void 0:me.items;if(!O)return;const de=[];for(const pe of O)if(pe.kind==="file"&&We(pe.type)){const ve=pe.getAsFile();ve&&de.push(ve)}if(de.length===0)return;f.preventDefault();const ue=W();if(ue){b("warning",ue);return}g(de)},W=()=>{const f=i==null?void 0:i.model;if(!(f!=null&&f.id))return null;const O=a.find(de=>de.id===f.id);return O&&O.vision===!1?S("modelNoVision",{name:O.name}):null},ae=s,ye=l.useRef(U);l.useEffect(()=>{ye.current=U},[U]),l.useEffect(()=>{d(ye.current)},[c]),l.useEffect(()=>{const f=O=>{var ue;const de=O.detail;K(de),(ue=C.current)==null||ue.focus()};return window.addEventListener("pi-web:fill",f),()=>window.removeEventListener("pi-web:fill",f)},[]),l.useEffect(()=>{if(!Z)return;const f=O=>{O.key==="Escape"&&G(!1)};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[Z]),l.useEffect(()=>{const f=C.current;if(!f)return;f.style.height="auto";const O=f.scrollHeight>220;f.style.height=`${Math.min(f.scrollHeight,220)}px`,f.style.overflowY=O?"auto":"hidden"},[U]);const be=f=>f.selectionStart!==f.selectionEnd?!1:!f.value.slice(0,f.selectionStart).includes(`
|
|
322
|
+
`),ge=f=>f.selectionStart!==f.selectionEnd?!1:!f.value.slice(f.selectionStart).includes(`
|
|
323
|
+
`),ke=(f=!1)=>{var ue,me,pe,ve,Me;const O=U.trim(),de=m.some(he=>he.imageData||he.fileData);if(!(!ae||!O&&!de)){if(O==="/help"){const he=(me=(ue=C.current)==null?void 0:ue.closest(".inputbox"))==null?void 0:me.getBoundingClientRect();I(he==null?void 0:he.width),G(!0),K(""),(pe=C.current)==null||pe.focus();return}if(O==="/copy"){K(""),(ve=C.current)==null||ve.focus(),h();return}if(u({type:"prompt",text:O,queue:f,attachments:m.map(he=>he.imageData?{path:"",imageData:he.imageData,mimeType:he.mimeType,name:he.name}:he.fileData?{path:"",fileData:he.fileData,mimeType:he.mimeType,name:he.name,size:he.size}:{path:he.path,mode:he.mode,...he.lines?{lines:he.lines}:{}})})){O&&ul(O),ne.current=-1,v.current="",K(""),E();const he=i==null?void 0:i.model;he&&ll(`${he.provider}/${he.id}`),(Me=C.current)==null||Me.focus()}}},Ee=f=>{if(!f.nativeEvent.isComposing){if(T&&T.length>0)switch(f.key){case"ArrowDown":f.preventDefault(),B(O=>(O+1)%T.length);return;case"ArrowUp":f.preventDefault(),B(O=>(O-1+T.length)%T.length);return;case"Tab":case"Enter":f.preventDefault(),w();return;case"Escape":f.preventDefault(),P(null);return}if(f.key==="ArrowUp"||f.key==="ArrowDown"){if(f.ctrlKey||f.metaKey||f.altKey)return;const O=C.current;if(!O)return;const de=f.key==="ArrowUp";if(de&&!be(O)||!de&&!ge(O)||!de&&ne.current===-1)return;const ue=dt();if(ue.length===0)return;if(f.preventDefault(),de){if(ne.current===-1){v.current=U;const me=ue.length-1;ne.current=me;const pe=ue[me];K(pe),d(pe),requestAnimationFrame(()=>{const ve=C.current;ve&&(ve.selectionStart=ve.selectionEnd=pe.length)})}else if(ne.current>0){const me=ne.current-1;ne.current=me;const pe=ue[me];K(pe),d(pe),requestAnimationFrame(()=>{const ve=C.current;ve&&(ve.selectionStart=ve.selectionEnd=pe.length)})}}else{const me=ne.current+1;if(me<ue.length){ne.current=me;const pe=ue[me];K(pe),d(pe),requestAnimationFrame(()=>{const ve=C.current;ve&&(ve.selectionStart=ve.selectionEnd=pe.length)})}else{ne.current=-1;const pe=v.current;K(pe),d(pe),requestAnimationFrame(()=>{const ve=C.current;ve&&(ve.selectionStart=ve.selectionEnd=pe.length)})}}return}if(f.key==="Escape"&&ne.current!==-1){f.preventDefault();const O=v.current;ne.current=-1,K(O),d(O),requestAnimationFrame(()=>{const de=C.current;de&&(de.selectionStart=de.selectionEnd=O.length)});return}if(f.key==="Enter"){if(gl&&!f.shiftKey&&!(f.ctrlKey||f.metaKey))return;f.shiftKey||(f.preventDefault(),ke())}}},re=()=>e.jsx("div",{className:"inputbox-actions",children:n?e.jsxs(e.Fragment,{children:[U.trim()!==""&&e.jsxs("button",{type:"button",className:"btn supplement",title:S("supplementTip"),onClick:()=>ke(!0),children:[e.jsx(vn,{})," ",S("supplement")]}),e.jsx("button",{type:"button",className:"btn stop",title:S("stopAgent"),onClick:()=>u({type:"abort"}),children:e.jsx(jt,{})})]}):e.jsx("button",{type:"button",className:"btn send",title:S("sendTip"),disabled:!ae||!U.trim()&&!m.some(f=>f.imageData||f.fileData),onClick:()=>ke(),children:e.jsx(Cn,{})})});return e.jsxs("div",{className:`inputbar${q?" drop-active":""}`,onDragOver:f=>{f.preventDefault(),f.stopPropagation(),Y(!0)},onDragLeave:f=>{f.currentTarget.contains(f.relatedTarget)||Y(!1)},onDrop:f=>{var O;f.preventDefault(),f.stopPropagation(),Y(!1),L(((O=f.dataTransfer)==null?void 0:O.files)??null)},children:[q&&e.jsx("div",{className:"drop-overlay",children:e.jsxs("span",{children:["📎 ",S("dropHereToAttach")]})}),m.length>0&&e.jsxs("div",{className:"attach-row",children:[m.map(f=>e.jsxs("span",{className:`attach-chip ${f.imageData?"image":f.fileData?"file":f.mode}`,title:f.imageData?S("attachImage",{name:f.name}):f.fileData?S("attachFile",{name:f.name}):f.isDir?S("folderRef",{path:f.path}):f.mode==="reference"?S("refOnly",{path:f.path}):f.mode==="lines"&&f.lines?S("attachLines",{path:f.path,start:f.lines.start,end:f.lines.end}):S("attachContent",{path:f.path}),children:[f.imageData?"🖼":f.fileData?"📄":f.isDir?"📁":f.mode==="reference"?"🔗":"📎"," ",f.name,f.mode==="lines"&&f.lines&&e.jsxs("span",{className:"attach-range",children:["L",f.lines.start,"-",f.lines.end]}),e.jsx("button",{type:"button",className:"attach-remove",title:S("removeAttachment"),onClick:()=>y(f.key??f.path),children:"×"})]},f.key??`${f.path}|${f.mode}|${f.lines?`${f.lines.start}-${f.lines.end}`:""}`)),e.jsx("span",{className:"attach-hint",children:S("attachHint")})]}),T&&T.length>0&&e.jsxs("div",{className:"slash-menu",role:"listbox",ref:z,"aria-label":S("slashCommands"),children:[e.jsxs("div",{className:"slash-menu-hint",children:[e.jsx("span",{children:S("slashMenuHint")}),e.jsx("span",{className:"slash-menu-close",onClick:()=>P(null),children:"Esc"})]}),T.map((f,O)=>e.jsxs("button",{type:"button",className:`slash-item${O===k?" active":""}`,onMouseEnter:()=>B(O),onClick:()=>w(f),children:[e.jsxs("span",{className:"slash-name",children:["/",f.name]}),e.jsx("span",{className:`slash-source ${f.source}`,children:D[f.source]}),e.jsxs("span",{className:"slash-desc",children:[Q(f),f.argumentHint&&e.jsx("span",{className:"slash-hint",children:X(f)})]})]},f.name))]}),Z&&e.jsx("div",{className:"modal-backdrop",onClick:()=>G(!1),children:e.jsxs("div",{className:"slash-help",style:M?{width:M}:void 0,onClick:f=>f.stopPropagation(),children:[e.jsxs("div",{className:"slash-help-head",children:[e.jsxs("span",{children:["⚡ ",S("slashHelpTitle")]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>G(!1),children:S("close")})]}),e.jsx("div",{className:"slash-help-body",children:c.length===0?e.jsx("div",{className:"slash-help-empty",children:S("slashLoading")}):c.map(f=>e.jsxs("div",{className:"slash-help-row",children:[e.jsxs("span",{className:"slash-help-cmd",children:["/",f.name]}),e.jsx("span",{className:`slash-source ${f.source}`,children:D[f.source]}),e.jsxs("span",{className:"slash-help-desc",children:[Q(f),f.argumentHint&&e.jsx("span",{className:"slash-hint",children:X(f)})]})]},f.name))})]})}),e.jsxs("div",{className:"inputbox",children:[e.jsx("input",{ref:$,type:"file",multiple:!0,hidden:!0,onChange:f=>{L(f.target.files),f.target.value=""}}),e.jsx("textarea",{ref:C,value:U,rows:1,placeholder:S(ae?n?"placeholderStreaming":"placeholderIdle":"placeholderConnecting"),disabled:!ae,onChange:f=>{ne.current=-1,K(f.target.value),d(f.target.value)},onKeyDown:Ee,onPaste:ee}),e.jsxs("div",{className:"composer-tools",children:[e.jsxs("div",{className:"composer-tools-left",children:[e.jsx("button",{type:"button",className:"btn attach-img",title:S("uploadFile"),disabled:!ae,onClick:()=>{var f;return(f=$.current)==null?void 0:f.click()},children:e.jsx(_i,{})}),e.jsx("button",{type:"button",className:"btn tpl-open",title:S("tpl.openPicker"),onClick:J,children:e.jsx(qi,{})}),e.jsx(hl,{state:i,models:a,modelsLoading:o,send:u,onManageModels:A,providerKeys:H,compact:!0})]}),e.jsx("div",{className:"composer-tools-right",children:re()})]})]})]})}),xl=l.memo(function({goal:s,models:n,modelsLoading:r,activeConversationId:c,engine:i,send:a}){var M,I,C,$,z,ne,v;const o=xe(),{locale:u}=mt(),m=u==="en"&&s.statusEn?s.statusEn:s.status||"",y=u==="en"&&((M=s.wizard)!=null&&M.statusEn)?s.wizard.statusEn:((I=s.wizard)==null?void 0:I.status)||"",g=i==="dsh",x=!s.conversationId||s.conversationId===c,b=s.goal!==null&&x,[E,A]=l.useState(""),[H,S]=l.useState(s.reviewModel??""),[j,J]=l.useState(s.maxRounds),[Q,X]=l.useState(s.locked),[U,K]=l.useState(!1),[q,Y]=l.useState(!1),[T,P]=l.useState(!0);l.useEffect(()=>{S(s.reviewModel??""),J(s.maxRounds||0),X(s.locked)},[s.goal,s.reviewModel,s.maxRounds,s.locked]),l.useEffect(()=>{U&&n.length===0&&!q&&!r&&(Y(!0),a({type:"list_models"}))},[U,n.length,q,r,a]),l.useEffect(()=>{n.length>0&&Y(!1)},[n.length]);const k=()=>{var D;return H?((D=n.find(d=>d.id===H))==null?void 0:D.name)??H:o("goalBarUseMainModel")},B=()=>{const D=E.trim();D&&(a({type:"set_goal",goal:D,...H?{reviewModel:H}:{},maxRounds:j,locked:Q}),A(""),P(!1))},Z=()=>{const D=E.trim();D&&(a({type:"start_goal_wizard",text:D,...H?{wizardModel:H}:{},maxRounds:j,locked:Q}),A(""),P(!1))},G=(((C=s.wizard)==null?void 0:C.active)??!1)&&x;return G?e.jsx("div",{className:`goalbar goalbar-active ${G?"wizard":""}`,children:e.jsxs("div",{className:"goalbar-active-row",children:[e.jsx("span",{className:"goalbar-icon",children:e.jsx("span",{className:"goalbar-spin",children:"🔍"})}),e.jsxs("span",{className:"goalbar-text",title:(($=s.wizard)==null?void 0:$.draft)??"",children:[o("goalWizardRunning"),": ",(z=s.wizard)==null?void 0:z.draft]}),e.jsxs("span",{className:"goalbar-chip reviewing",children:[o("goalBarRound",{n:(((ne=s.wizard)==null?void 0:ne.step)??0)+1})," / ",((v=s.wizard)==null?void 0:v.maxSteps)??6]}),e.jsx("span",{className:"goalbar-detail",children:y||o("goalBarReviewing")}),e.jsx("button",{type:"button",className:"goalbar-x",title:o("goalBarClear"),onClick:()=>{a({type:"clear_goal"}),P(!0)},children:e.jsx(Pe,{})})]})}):b?e.jsx("div",{className:`goalbar goalbar-active ${s.reviewing?"reviewing":""}`,children:e.jsxs("div",{className:"goalbar-active-row",children:[e.jsx("span",{className:"goalbar-icon",children:s.reviewing?e.jsx("span",{className:"goalbar-spin",children:"◌"}):"🎯"}),e.jsx("span",{className:"goalbar-text",title:s.goal??"",children:s.goal}),s.reviewing?e.jsxs("span",{className:"goalbar-chip reviewing",children:[o("goalBarReviewing")," ",o("goalBarRound",{n:s.round})]}):e.jsx("span",{className:`goalbar-chip ${s.verdict==="pass"?"pass":s.verdict==="fail"?"fail":""}`,children:s.verdict==="pass"?o("goalBarPassed"):s.verdict==="fail"?o("goalBarFailed"):`${o("goalBarRound",{n:s.round||1})} · ${s.locked?o("goalBarLocked"):o("goalBarUnlocked")}`}),e.jsx("span",{className:"goalbar-detail",children:m}),e.jsx("button",{type:"button",className:"goalbar-x",title:o("goalBarClear"),disabled:s.reviewing,onClick:()=>{a({type:"clear_goal"}),P(!0)},children:e.jsx(Pe,{})})]})}):T?e.jsx("div",{className:"goalbar goalbar-collapsed",children:e.jsxs("button",{type:"button",className:"goalbar-hint",title:o("goalBarPlaceholder"),onClick:()=>P(!1),children:[e.jsx(Is,{})," ",e.jsx("span",{children:o("goalBarTitle")})]})}):e.jsxs("div",{className:"goalbar",children:[e.jsxs("div",{className:"goalbar-row",children:[e.jsx("span",{className:"goalbar-icon",children:e.jsx(Is,{})}),e.jsx("input",{className:"goalbar-input",value:E,placeholder:o("goalBarPlaceholder"),onChange:D=>A(D.target.value),onKeyDown:D=>{D.key==="Enter"&&B()}}),e.jsx("button",{type:"button",className:"goalbar-btn",disabled:!E.trim(),onClick:B,children:o("goalBarSet")}),e.jsxs("button",{type:"button",className:"goalbar-btn wizard",disabled:!E.trim(),title:o("goalWizardTip"),onClick:Z,children:["🔍 ",o("goalWizardBtn")]}),e.jsx("button",{type:"button",className:"goalbar-icon-btn",title:o(Q?"goalBarLocked":"goalBarUnlocked"),onClick:()=>X(D=>(a({type:"set_goal_prefs",locked:!D}),!D)),children:Q?e.jsx(Ki,{}):e.jsx(Ii,{})}),e.jsx("button",{type:"button",className:"goalbar-icon-btn",title:o("goalBarClear"),onClick:()=>P(!0),children:e.jsx(ut,{})})]}),e.jsxs("div",{className:"goalbar-opts",children:[g?e.jsx("p",{className:"goalbar-dsh-note",children:o("dshNoReviewModel")}):e.jsxs(ze,{trigger:e.jsxs("span",{className:"goalbar-opt",children:[o("goalBarReviewModel"),": ",e.jsx("b",{children:k()})]}),open:U,onOpenChange:K,direction:"up",children:[e.jsx("div",{className:"dd-header",children:o("goalBarReviewModel")}),(q||r)&&e.jsx("div",{className:"dd-loading",children:o("loading")}),n.length===0&&!q&&!r&&e.jsx("div",{className:"dd-loading",children:o("noModels")}),e.jsx(Ie,{active:H==="",onClick:()=>{S(""),K(!1),a({type:"set_goal_prefs",reviewModel:""})},children:o("goalBarUseMainModel")}),n.map(D=>e.jsx(Ie,{active:H===D.id,onClick:()=>{S(D.id),K(!1),a({type:"set_goal_prefs",reviewModel:D.id})},children:e.jsxs("span",{className:"dd-model-cell",children:[e.jsx("span",{className:"dd-model-name",children:D.name}),e.jsx("span",{className:"dd-model-meta",children:e.jsx("span",{className:"dd-model-provider",children:D.provider})})]})},D.id)),e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>a({type:"list_models"}),children:o("refreshModels")})]}),e.jsxs("label",{className:"goalbar-round",title:o("goalBarMaxRoundsTip"),children:[e.jsx("span",{children:o("goalBarMaxRounds")}),e.jsx("input",{type:"number",min:0,step:1,value:j,placeholder:o("goalBarUnlimitedShort"),onChange:D=>{const d=parseInt(D.target.value,10);if(Number.isNaN(d)||d<0){J(0);return}J(d)},onBlur:()=>a({type:"set_goal_prefs",maxRounds:j}),onKeyDown:D=>{D.key==="Enter"&&(a({type:"set_goal_prefs",maxRounds:j}),D.target.blur())}})]}),e.jsx("span",{className:"goalbar-lock-hint",children:o(Q?"goalBarLocked":"goalBarUnlocked")})]})]})});function yl(t){const s=Math.max(0,t.input??0),n=Math.max(0,t.cacheRead??0),r=Math.max(0,t.cacheWrite??0),c=s+n+r;return{totalInput:c,miss:s,read:n,write:r,hitRate:c>0?Math.min(n/c,1):0,writeRate:c>0?Math.min(r/c,1):0}}const ai=2e3;function vl(t,s,n=ai){return t.filter(r=>s-r.t<=n)}function bl(t,s=ai){if(t.length<2)return 0;const n=t[t.length-1],r=t.find(i=>i.t>=n.t-s)??t[0],c=(n.t-r.t)/1e3;return c<=0?0:Math.max(0,(n.out-r.out)/c)}function rn(t){if(!t)return 0;let s=0;for(let r=0;r<t.length;r++){const c=t.charCodeAt(r);(c>=12352&&c<=12543||c>=13312&&c<=19903||c>=19968&&c<=40959||c>=63744&&c<=64255||c>=65280&&c<=65519||c===12288)&&s++}const n=t.length-s;return Math.round(s+n/4)}function kl(t){let s=0;for(const n of t)n.type==="text"&&typeof n.text=="string"&&n.text?s+=rn(n.text):n.type==="thinking"&&typeof n.thinking=="string"&&n.thinking&&(s+=rn(n.thinking));return s}const Qe="@root";function jl({chat:t,send:s}){const n=xe(),r=t.state,[c,i]=l.useState(!1),[a,o]=l.useState(""),[u,m]=l.useState(""),[y,g]=l.useState(!1),[x,b]=l.useState(""),[E,A]=l.useState(-1),H=l.useRef(null),S=l.useRef(null),j=t.pathCompletions.filter(h=>h.type==="dir"),J=h=>h.endsWith("/")?h:h+"/",Q=h=>{let L=h.endsWith("/")&&h!=="/"?h.slice(0,-1):h;if(L===Qe||L==="/")return null;const ee=L.lastIndexOf("/");if(ee<0)return/^[A-Za-z]:$/.test(L)?Qe:null;if(ee===0)return"/";const W=L.slice(0,ee);return/^[A-Za-z]:$/.test(W)?W+"/":W};l.useEffect(()=>{if(!c)return;const h=setTimeout(()=>{s({type:"complete_path",path:J(a)})},60);return()=>clearTimeout(h)},[a,c,s]),l.useEffect(()=>{if(!c||u===a)return;const h=setTimeout(()=>{s({type:"complete_path",path:u})},150);return()=>clearTimeout(h)},[u,a,c,s]);const X=l.useRef([]),U=(r==null?void 0:r.isStreaming)??!1,K=r!=null&&r.streamingMessage?kl(r.streamingMessage.content):0;if(l.useEffect(()=>{if(!U){X.current=[];return}const h=Date.now(),L=X.current,ee=L[L.length-1];ee&&h-ee.t<250||(X.current=vl([...L,{t:h,out:K}],h))},[U,K]),!r)return null;const q=r.stats,Y=yl(q.tokens),T=Y.hitRate*100,P=Y.totalInput===0?"":Y.hitRate>=.7?"ok":Y.hitRate>=.4?"mid":"warn",k=Y.totalInput>0?`${T.toFixed(1)}%`:"—",B=U?bl(X.current):0,Z=t.ready?"ok":"busy",G=t.ready?n("connected"):n("connecting"),M=q.contextUsage,I=M.tokens!==null&&M.percent!==null?`${Ze(M.tokens)} / ${Ze(M.contextWindow)}`:"—",C=M.percent??null,$=C===null?"":C>=80?"warn":C>=50?"mid":"ok",z=r.queue.steering.length+r.queue.followUp.length,ne=()=>{m(r.cwd),o(r.cwd),g(!1),b(""),i(!0)},v=h=>{const L=h.trim();L!==Qe&&(L&&L!==r.cwd&&s({type:"set_cwd",path:L}),i(!1))},D=()=>{const h=x.trim();h&&(s({type:"make_dir",path:`${J(a)}${h}`}),setTimeout(()=>{s({type:"complete_path",path:J(a)})},80),b(""),g(!1))},d=h=>{if(h.key==="Escape")h.stopPropagation(),i(!1);else if(h.key==="Enter"&&!h.nativeEvent.isComposing)v(u);else if(h.key==="Tab"){if(j.length===0)return;h.preventDefault();const L=E>=0?(E+1)%j.length:0;A(L),m(j[L].path),o(j[L].path)}},w=Q(a);return e.jsxs("footer",{className:"statusbar",children:[e.jsx("span",{className:`status-dot ${Z}`,title:G}),e.jsx("span",{className:"status-item",children:G}),e.jsx("span",{className:"status-sep",children:"·"}),t.engine&&t.engine!=="pi"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`status-item engine-badge engine-${t.engine}`,title:`${n("engineBadge")}: ${t.engine}`,children:t.engine==="dsh"?"DSH":t.engine}),e.jsx("span",{className:"status-sep",children:"·"})]}),e.jsxs("span",{className:"status-item status-ctx",title:n("contextUsage"),children:[n("context"),e.jsx("span",{className:`ctx-bar ${$}`,children:C!==null&&e.jsx("span",{className:"ctx-bar-fill",style:{width:`${Math.min(C,100)}%`}})}),I]}),e.jsx("span",{className:"status-sep",children:"·"}),e.jsxs("span",{className:"status-item",title:n("cumulativeCost"),children:["$",wl(q.cost)]}),e.jsx("span",{className:"status-sep",children:"·"}),e.jsxs("span",{className:"status-item status-cache",title:n("cacheHitTip",{read:Ze(Y.read),write:Ze(Y.write),miss:Ze(Y.miss),input:Ze(Y.totalInput)}),children:[n("cacheHit"),e.jsx("b",{className:`cache-pct ${P}`,children:k})]}),e.jsx("span",{className:"status-sep",children:"·"}),e.jsxs("span",{className:"status-item",title:n("sessionMessages"),children:[n("messages")," ",q.totalMessages]}),t.statuses.length>0&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"status-sep",children:"·"}),e.jsx("span",{className:"status-item ext-status",title:n("pluginStatus"),children:t.statuses.map(h=>h.text).join(" · ")})]}),r.isStreaming&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"status-sep",children:"·"}),e.jsxs("span",{className:"status-item working",children:[e.jsx("span",{className:"working-spin"}),n("working"),z>0&&e.jsxs("span",{className:"status-queue",children:["⏳ ",z," ",n("queued")]})]}),e.jsx("span",{className:"status-item status-rate",title:n("rateTip"),children:B>0?`${Math.round(B)}${n("tps")}`:"…"})]}),c?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"status-cwd-backdrop",onClick:()=>i(!1)}),e.jsxs("div",{className:"cwd-picker",children:[e.jsxs("div",{className:"cwd-picker-head",children:[e.jsxs("span",{className:"cwd-picker-title",title:a===Qe?n("computer"):a,children:[a===Qe?"💻":e.jsx(Je,{}),e.jsx("span",{children:a===Qe?n("computer"):a})]}),e.jsxs("button",{type:"button",className:"cwd-up",disabled:!w,title:n("cwdGoUp"),onClick:()=>{w&&(o(w),m(w),A(-1))},children:["↑ ",n("cwdGoUp")]})]}),e.jsxs("div",{className:"cwd-picker-row",children:[e.jsx("input",{ref:H,className:"status-cwd-input cwd-picker-input",value:u,placeholder:n("enterPath"),spellCheck:!1,onChange:h=>{m(h.target.value),A(-1)},onKeyDown:d}),e.jsx("button",{type:"button",className:"cwd-choose-btn primary",title:n("cwdPickCurrent"),disabled:a===Qe,onClick:()=>v(a),children:n("cwdPickCurrent")})]}),e.jsxs("div",{className:"cwd-list",children:[j.length===0&&e.jsx("div",{className:"cwd-empty",children:n("cwdEmpty")}),j.map(h=>e.jsxs("div",{className:"cwd-item",children:[e.jsxs("button",{type:"button",className:"cwd-enter",title:`${n("cwdEnter")} ${h.path}`,onClick:()=>{o(h.path),m(h.path),A(-1)},children:[e.jsx(Je,{}),e.jsx("span",{className:"cwd-name",children:h.name})]}),e.jsx("button",{type:"button",className:"cwd-choose-btn",title:n("cwdChoose"),onClick:()=>v(h.path),children:n("cwdChoose")})]},h.path))]}),e.jsx("div",{className:"cwd-picker-foot",children:y?e.jsxs("div",{className:"cwd-newrow",children:[e.jsx("input",{ref:S,value:x,autoFocus:!0,spellCheck:!1,placeholder:n("cwdNewName"),onChange:h=>b(h.target.value),onKeyDown:h=>{h.key==="Enter"&&!h.nativeEvent.isComposing?(h.preventDefault(),D()):h.key==="Escape"&&(h.stopPropagation(),g(!1),b(""))}}),e.jsx("button",{type:"button",className:"cwd-choose-btn primary",onClick:D,children:n("cwdCreate")}),e.jsx("button",{type:"button",className:"cwd-choose-btn",onClick:()=>{g(!1),b("")},children:n("cwdCancel")})]}):e.jsxs("button",{type:"button",className:"cwd-newbtn",onClick:()=>g(!0),children:["+ ",n("cwdNewFolder")]})})]})]}):e.jsxs("button",{type:"button",className:"status-item status-cwd",title:n("cwdTip",{path:r.cwd}),onClick:ne,children:["📁 ",r.cwd]})]})}function Ze(t){return t>=1e3?`${(t/1e3).toFixed(1).replace(/\.0$/,"")}K`:String(t)}function wl(t){return t<=0?"0":t<1e-4?"<0.0001":t.toFixed(4).replace(/\.?0+$/,"")}function Nl({dialog:t,send:s}){const n=xe(),[r,c]=l.useState(""),[i,a]=l.useState(0),o=y=>{s({type:"dialog_response",id:t.id,value:y})};l.useEffect(()=>{c(""),a(0);const y=g=>{g.key==="Escape"&&o(null)};return document.addEventListener("keydown",y),()=>document.removeEventListener("keydown",y)},[t.id]);const u=Array.isArray(t.args[0])?t.args[0]:[],m=typeof t.args[0]=="string"?t.args[0]:"";return e.jsxs("div",{className:"dialog-inline","data-dialog-kind":t.kind,children:[e.jsxs("div",{className:"dialog-head",children:[e.jsx("span",{className:"dialog-badge",children:n("pluginRequest")}),t.title&&t.title!==n("pluginRequest")&&e.jsx("span",{className:"dialog-title",children:t.title}),e.jsx("button",{type:"button",className:"dialog-dismiss",title:n("cancel"),onClick:()=>o(null),children:"✕"})]}),t.kind==="select"&&e.jsxs("div",{className:"dialog-options",children:[u.map((y,g)=>e.jsx("button",{type:"button",className:`dialog-option ${g===i?"sel":""}`,onMouseEnter:()=>a(g),onClick:()=>o(y),children:y},g)),u.length===0&&e.jsx("div",{className:"dialog-hint",children:n("noOptions")})]}),t.kind==="confirm"&&e.jsxs("div",{className:"dialog-body",children:[e.jsx("p",{children:m}),e.jsxs("div",{className:"dialog-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>o(!1),children:n("cancel")}),e.jsx("button",{type:"button",className:"btn primary",onClick:()=>o(!0),children:n("ok")})]})]}),t.kind==="input"&&e.jsxs("div",{className:"dialog-body",children:[e.jsx("input",{className:"dialog-input",value:r,placeholder:m||n("inputPlaceholder"),autoFocus:!0,onChange:y=>c(y.target.value),onKeyDown:y=>{y.key==="Enter"&&!y.nativeEvent.isComposing&&o(r)}}),e.jsxs("div",{className:"dialog-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>o(null),children:n("cancel")}),e.jsx("button",{type:"button",className:"btn primary",onClick:()=>o(r),children:n("ok")})]})]})]})}function Cl({question:t,send:s}){const n=xe(),[r,c]=l.useState({}),[i,a]=l.useState({}),[o,u]=l.useState(()=>t.deadline?Math.max(0,Math.ceil((t.deadline-Date.now())/1e3)):-1);l.useEffect(()=>{c({}),a({}),u(t.deadline?Math.max(0,Math.ceil((t.deadline-Date.now())/1e3)):-1)},[t.id,t.deadline]),l.useEffect(()=>{if(!t.deadline)return;const x=setInterval(()=>{u(b=>{const E=Math.max(0,Math.ceil((t.deadline-Date.now())/1e3));return E<=0&&b>0&&s({type:"question_answer",id:t.id,answers:[],cancelled:!0}),E})},1e3);return()=>clearInterval(x)},[t.id,t.deadline]);const m=x=>{if(x){s({type:"question_answer",id:t.id,answers:[],cancelled:!0});return}const b=t.questions.map(E=>{const A=r[E.id]??[],H=(i[E.id]??"").trim();return{id:E.id,selected:A,...H?{custom:H}:{}}});s({type:"question_answer",id:t.id,answers:b})};l.useEffect(()=>{const x=b=>{b.key==="Escape"&&m(!0)};return document.addEventListener("keydown",x),()=>document.removeEventListener("keydown",x)},[t.id]);const y=(x,b,E)=>{c(A=>{const H=A[x]??[];return E?{...A,[x]:H.includes(b)?H.filter(S=>S!==b):[...H,b]}:{...A,[x]:[b]}})},g=t.questions.every(x=>{var b;return(((b=r[x.id])==null?void 0:b.length)??0)>0||(i[x.id]??"").trim()!==""});return e.jsxs("div",{className:"dialog-inline","data-dialog-kind":"select",children:[e.jsxs("div",{className:"dialog-head",children:[e.jsx("span",{className:"dialog-badge",children:n("modelQuestion")}),o>=0&&e.jsx("span",{className:"question-timer",children:o>0?n("questionTimeout",{s:o}):n("questionTimeoutExpired")}),e.jsx("button",{type:"button",className:"dialog-dismiss",title:n("cancel"),onClick:()=>m(!0),children:"✕"})]}),t.questions.map((x,b)=>{var E;return e.jsxs("div",{className:"set-section",children:[e.jsx("div",{className:"set-section-title",children:x.header??`${n("modelQuestion")} ${b+1}`}),e.jsx("p",{className:"set-row-desc",children:x.question}),x.detail&&e.jsx("p",{className:"set-hint",children:x.detail}),(((E=x.options)==null?void 0:E.length)??0)>0&&e.jsx("div",{className:"set-list",children:x.options.map(A=>{const H=(r[x.id]??[]).includes(A.label);return e.jsxs("button",{type:"button",className:`set-row question-option${H?" active":""}`,onClick:()=>y(x.id,A.label,!!x.multiSelect),children:[e.jsxs("span",{className:"set-row-name",children:[x.multiSelect?H?"☑ ":"☐ ":H?"● ":"○ ",A.label]}),A.description&&e.jsx("span",{className:"set-row-desc",children:A.description})]},A.label)})}),e.jsx("input",{className:"set-prompt-input question-custom",placeholder:n("modelQuestionCustom"),value:i[x.id]??"",onChange:A=>a(H=>({...H,[x.id]:A.target.value}))})]},x.id)}),e.jsxs("div",{className:"dialog-actions",children:[e.jsx("button",{type:"button",className:"dialog-submit",disabled:!g,onClick:()=>m(!1),children:n("modelQuestionSubmit")}),e.jsx("button",{type:"button",className:"dialog-dismiss-inline",onClick:()=>m(!0),children:n("cancel")})]})]})}const ln=t=>`'${t.replace(/'/g,"'\\''")}'`;function Sl(t){if(t.x==="?"&&t.y==="?")return"untracked";const s=t.x!==" "&&t.x!=="?",n=t.y!==" "&&t.y!=="?";return s&&n?"both":s?"staged":"unstaged"}function Tl({chat:t,send:s,terminal:n,active:r,onSwitchToTerminal:c}){var Be,De;const i=xe(),[a,o]=l.useState(null),[u,m]=l.useState([]),[y,g]=l.useState(""),[x,b]=l.useState(new Map),[E,A]=l.useState("changes"),[H,S]=l.useState([]),[j,J]=l.useState(null),[Q,X]=l.useState(""),[U,K]=l.useState(!1),[q,Y]=l.useState(null),[T,P]=l.useState(null),[k,B]=l.useState(!1),[Z,G]=l.useState(!1),[M,I]=l.useState(!1),[C,$]=l.useState(null),[z,ne]=l.useState(!1),[v,D]=l.useState(""),d=l.useRef(0),w=l.useRef(-1),h=l.useRef(-1),L=l.useRef(-1),ee=l.useRef(-1),W=l.useRef(void 0),ae=l.useRef(null),ye=l.useRef([]),be=l.useCallback(R=>{if(R.reqId===w.current){if(w.current=-1,G(!1),$(null),!R.ok){$(R.error??i("scmQueryFailedShort"));return}if(R.notRepo){ne(!0),o(null),m([]),b(new Map),S([]),J(null),X(""),P(null);return}ne(!1);const fe={branch:R.branch??"",detached:!!R.detached,upstream:R.upstream??null,ahead:R.ahead??0,behind:R.behind??0,upstreamGone:!!R.upstreamGone,files:(R.files??[]).map(V=>({...V}))},oe=(R.branches??[]).map(V=>({...V})),p=new Map;for(const[V,N]of Object.entries(R.stats??{}))p.set(V,{add:N[0],del:N[1]});o(fe),m(oe),b(p),g(V=>{var N;return fe.detached?V||"":fe.branch&&oe.some(_=>_.name===fe.branch)?fe.branch:V&&oe.some(_=>_.name===V)?V:((N=oe[0])==null?void 0:N.name)??""}),P(V=>V&&!fe.files.some(N=>N.path===V.file.path)?null:V)}else if(R.reqId===h.current){if(h.current=-1,B(!1),!R.ok){$(R.error??i("scmQueryFailedShort"));return}const fe=ae.current;if(!fe)return;P({file:fe,staged:R.stagedText??"",worktree:R.worktreeText??"",untracked:!1})}else if(R.reqId===ee.current){if(ee.current=-1,I(!1),!R.ok){$(R.error??i("scmQueryFailedShort"));return}S((R.history??[]).map(fe=>({...fe})))}else if(R.reqId===L.current){if(L.current=-1,K(!1),!R.ok){$(R.error??i("scmQueryFailedShort"));return}X(R.text??"")}},[]);l.useEffect(()=>{const R=t.scmData;R&&R.type==="scm_data"&&be(R)},[t.scmData,be]);const ge=l.useCallback((R,fe)=>{if(!t.ready||t.status!=="open")return!1;const oe=++d.current;return s({...R,reqId:oe})?(fe.current=oe,!0):(d.current-=1,!1)},[t.ready,t.status,s]),ke=l.useCallback((R=!1,fe=!1)=>{var oe;!t.ready||t.status!=="open"||(oe=t.state)!=null&&oe.cwd&&(W.current!==void 0&&W.current!==t.state.cwd&&(o(null),m([]),b(new Map),S([]),I(!1),ee.current=-1,J(null),X(""),P(null),Y(null)),W.current=t.state.cwd,$(null),ge({type:"scm_status"},w)&&(fe||G(!0)))},[t.ready,(Be=t.state)==null?void 0:Be.cwd,t.status,ge]),Ee=l.useCallback(R=>{if(Y(R),J(null),ae.current=R,R.x==="?"&&R.y==="?"){P({file:R,staged:"",worktree:"",untracked:!0});return}B(!0),$(null),ge({type:"scm_filediff",path:R.path},h)||B(!1)},[ge]),re=l.useCallback(R=>{J(R),Y(null),P(null),X(""),K(!0),$(null),ge({type:"scm_commit",hash:R.hash},L)||K(!1)},[ge]),f=l.useCallback((R,fe)=>{var N,_;if(!t.ready)return;const oe={name:R,command:fe,cwd:"${pwd}"};let p;const V=t.terminals.find(ie=>ie.title===R);V?(n.restart(V.id),s({type:"run_command",terminalId:V.id,conversationId:V.conversationId,command:oe,cols:80,rows:24}),p=V.id):(p=Ue(),n.create({id:p,conversationId:t.activeConversationId||((N=t.state)==null?void 0:N.conversationId)||"",title:R,cwd:((_=t.state)==null?void 0:_.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:oe})),n.select(p),c()},[t.ready,(De=t.state)==null?void 0:De.cwd,t.terminals,c,s,n]),O=l.useCallback(()=>{const R=v.trim();if(!R||z)return;const fe=R.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");f("git commit",`git commit -m "${fe}"`),D("")},[v,z,f]),de=l.useCallback(()=>{const R=v.trim();if(!R||z)return;const fe=R.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");f("git commit",`git add -A && git commit -m "${fe}"`),D("")},[v,z,f]),ue=l.useCallback(R=>{z||f("git add",`git add -- ${ln(R.path)}`)},[z,f]),me=l.useCallback(R=>{z||f("git reset",`git reset HEAD -- ${ln(R.path)}`)},[z,f]),pe=l.useCallback(()=>{if(!y||z)return;const R=u.find(fe=>fe.name===y);if(R!=null&&R.remote&&typeof R.remote=="string"){const fe=y.slice(R.remote.length+1);f("git checkout",`git checkout -b ${fe} ${y} || git checkout ${y}`)}else f("git checkout",`git checkout ${y}`)},[y,u,z,f]),ve=l.useCallback(()=>f("git push","git push"),[f]),Me=l.useCallback(()=>f("git pull","git pull"),[f]),he=l.useCallback(()=>{ge({type:"scm_history"},ee)||(ee.current=-1)},[ge]);l.useEffect(()=>{r&&ke()},[r,ke]),l.useEffect(()=>{E==="history"&&a&&he()},[E,a,he]),l.useEffect(()=>{t.scmDirty>0&&r&&ke(!1,!0)},[t.scmDirty]),l.useEffect(()=>{if(!r||!t.ready||t.status!=="open")return;const R=setInterval(()=>{document.visibilityState!=="hidden"&&ke(!1,!0)},3e4);return()=>clearInterval(R)},[r,t.ready,t.status,ke]),l.useEffect(()=>{const R=ye.current;if(ye.current=t.terminals,!r)return;t.terminals.some(oe=>{var V;return oe.running!==!1?!1:((V=R.find(N=>N.id===oe.id))==null?void 0:V.running)===!0&&oe.title.startsWith("git ")})&&t.ready&&t.status==="open"&&(ke(!1,!0),E==="history"&&a&&he())},[t.terminals,r,t.ready,t.status,ke,E,a,he]);const _e={staged:i("scmStaged"),unstaged:i("scmUnstaged"),untracked:i("scmUntracked"),both:i("scmStagedUnstaged")},Le=R=>{const fe=R.split(`
|
|
324
|
+
`);return e.jsx("pre",{className:"scm-diff-pre",children:fe.map((oe,p)=>{let V="";return oe.startsWith("diff --git")||oe.startsWith("index ")||oe.startsWith("new file")||oe.startsWith("deleted file")||oe.startsWith("old mode")||oe.startsWith("new mode")||oe.startsWith("similarity index")||oe.startsWith("rename ")||oe.startsWith("copy ")||oe.startsWith("Binary files")||oe.startsWith("---")||oe.startsWith("+++")?V="hdr":oe.startsWith("@@")?V="hunk":oe.startsWith("+")?V="add":oe.startsWith("-")&&(V="del"),e.jsx("div",{className:`scm-diff-line ${V}`,children:oe||" "},p)})})};return e.jsxs("div",{className:"scm-view",children:[e.jsxs("div",{className:"scm-header",children:[e.jsxs("div",{className:"scm-title-row",children:[e.jsxs("span",{className:"scm-title",children:[e.jsx(yt,{}),i("scmTitle")]}),e.jsxs("div",{className:"scm-view-tabs",role:"tablist",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":E==="changes",className:E==="changes"?"active":"",onClick:()=>{A("changes"),$(null)},children:i("scmChanges")}),e.jsx("button",{type:"button",role:"tab","aria-selected":E==="history",className:E==="history"?"active":"",onClick:()=>{A("history"),$(null)},children:i("scmHistory")})]}),e.jsx("button",{type:"button",className:"panel-refresh",title:i("scmRefreshTip"),disabled:Z,onClick:()=>ke(!0),children:e.jsx(rt,{className:Z?"scm-spin":""})})]}),e.jsxs("div",{className:"scm-row",children:[e.jsxs("span",{className:"scm-branch-current",title:i("scmCurrentBranch"),children:[e.jsx(yt,{}),a?a.detached?i("scmDetached"):a.branch:"…",(a==null?void 0:a.upstream)&&e.jsx("span",{className:"scm-upstream",children:a.upstreamGone?i("scmUpstreamGone"):a.ahead>0||a.behind>0?i("scmAheadBehind",{ahead:a.ahead,behind:a.behind}):a.upstream})]}),e.jsxs("select",{className:"scm-select",value:y,disabled:z||u.length===0,title:i("scmSwitchBranch"),onChange:R=>g(R.target.value),children:[e.jsx("option",{value:"",disabled:!0,children:i("scmSelectBranch")}),u.filter(R=>!R.remote).map(R=>e.jsx("option",{value:R.name,children:R.current?`* ${R.name}`:R.name},R.name)),u.some(R=>R.remote)&&e.jsx("optgroup",{label:i("scmRemoteBranches"),children:u.filter(R=>R.remote).map(R=>e.jsx("option",{value:R.name,children:R.name},R.name))})]}),e.jsxs("button",{type:"button",className:"btn",disabled:!y||y===(a==null?void 0:a.branch)||z,title:i("scmSwitchBranchTip",{branch:y}),onClick:pe,children:[e.jsx(yt,{}),i("scmSwitch")]}),e.jsxs("button",{type:"button",className:"btn",disabled:!a||a.detached||z,title:i("scmPushTip"),onClick:ve,children:[e.jsx(Cn,{}),i("scmPush")]}),e.jsxs("button",{type:"button",className:"btn",disabled:!a||a.detached||z,title:i("scmPullTip"),onClick:Me,children:[e.jsx(Sn,{}),i("scmPull")]}),e.jsx("input",{className:"scm-commit-input",value:v,placeholder:i("scmCommitPlaceholder"),disabled:z,onChange:R=>D(R.target.value),onKeyDown:R=>{R.key==="Enter"&&!R.nativeEvent.isComposing&&O()}}),e.jsxs("button",{type:"button",className:"btn primary",disabled:!v.trim()||z,title:i("scmCommitTip"),onClick:O,children:[e.jsx(pt,{}),i("scmCommit")]}),e.jsx("button",{type:"button",className:"btn",disabled:!v.trim()||z,title:i("scmCommitAllTip"),onClick:de,children:i("scmCommitAll")})]})]}),e.jsxs("div",{className:"scm-body",children:[E==="history"?e.jsxs("div",{className:"scm-history",children:[e.jsxs("div",{className:"scm-files-header",children:[e.jsx("span",{children:i("scmHistory")}),H.length>0&&e.jsx("span",{className:"scm-files-count",children:H.length})]}),e.jsx("div",{className:"scm-history-list",children:z?e.jsx("div",{className:"scm-empty",children:i("scmNotGitRepo")}):!a||M?e.jsx("div",{className:"scm-empty",children:t.status==="open"?i("scmLoading"):i("scmConnecting")}):H.length===0?e.jsx("div",{className:"scm-empty",children:i("scmNoHistory")}):H.map(R=>e.jsxs("button",{type:"button",className:`scm-commit ${(j==null?void 0:j.hash)===R.hash?"active":""}`,onClick:()=>re(R),title:R.hash,children:[e.jsx("span",{className:"scm-commit-graph","aria-hidden":"true",children:R.graph||"* "}),e.jsxs("span",{className:"scm-commit-info",children:[e.jsx("span",{className:"scm-commit-subject",children:R.subject}),e.jsxs("span",{className:"scm-commit-meta",children:[R.shortHash," · ",R.author," · ",R.date]}),R.decorations&&e.jsx("span",{className:"scm-commit-refs",children:R.decorations})]})]},R.hash))})]}):e.jsxs("div",{className:"scm-files",children:[e.jsxs("div",{className:"scm-files-header",children:[e.jsx("span",{children:i("scmChanges")}),a&&a.files.length>0&&e.jsx("span",{className:"scm-files-count",children:a.files.length})]}),e.jsx("div",{className:"scm-files-list",children:z?e.jsx("div",{className:"scm-empty",children:i("scmNotGitRepo")}):a?a.files.length===0?e.jsx("div",{className:"scm-empty",children:i("scmNoChanges")}):a.files.map(R=>{const fe=Sl(R),oe=x.get(R.path);return e.jsxs("div",{className:`scm-file ${(q==null?void 0:q.path)===R.path?"active":""}`,title:_e[fe],onClick:()=>Ee(R),children:[e.jsx("span",{className:`scm-file-xy ${fe==="untracked"?"q":"x"}`,children:R.x!==" "?R.x:" "}),e.jsx("span",{className:`scm-file-xy ${fe==="untracked"?"q":"y"}`,children:R.y!==" "?R.y:" "}),e.jsx("span",{className:"scm-file-path",children:R.path}),oe&&(oe.add>0||oe.del>0)&&e.jsxs("span",{className:"scm-file-stat",children:[oe.add>0&&e.jsxs("span",{className:"add",children:["+",oe.add]}),oe.del>0&&e.jsxs("span",{className:"del",children:["-",oe.del]})]}),e.jsxs("span",{className:"scm-file-actions",children:[(R.y!==" "||fe==="untracked")&&e.jsx("button",{type:"button",className:"scm-act",title:i("scmStageTip",{path:R.path}),onClick:p=>{p.stopPropagation(),ue(R)},children:"+"}),fe==="staged"||fe==="both"?e.jsx("button",{type:"button",className:"scm-act",title:i("scmUnstageTip",{path:R.path}),onClick:p=>{p.stopPropagation(),me(R)},children:"−"}):null]})]},R.path)}):e.jsx("div",{className:"scm-empty",children:t.status==="open"?i("scmLoading"):i("scmConnecting")})})]}),e.jsxs("div",{className:"scm-diff",children:[e.jsxs("div",{className:"scm-diff-header",children:[e.jsx("span",{children:E==="history"?j?`${j.shortHash} ${j.subject}`:i("scmCommitDetail"):q?q.path:i("scmDiff")}),(E==="history"?U:k)&&e.jsx("span",{className:"scm-diff-loading",children:i("scmLoading")})]}),e.jsx("div",{className:"scm-diff-body",children:E==="history"?e.jsxs(e.Fragment,{children:[C&&e.jsx("div",{className:"scm-error",children:C}),!j&&!C&&e.jsx("div",{className:"scm-empty",children:i("scmSelectCommitHint")}),j&&U&&!C&&e.jsx("div",{className:"scm-empty",children:i("scmLoading")}),j&&!U&&!C&&Q?Le(Q):null]}):e.jsxs(e.Fragment,{children:[C&&e.jsx("div",{className:"scm-error",children:C}),!q&&!C&&e.jsx("div",{className:"scm-empty",children:i("scmSelectFileHint")}),q&&!T&&!C&&e.jsx("div",{className:"scm-empty",children:i("scmLoading")}),q&&T&&T.untracked&&e.jsx("div",{className:"scm-empty",children:i("scmUntrackedNote")}),q&&T&&!T.untracked&&e.jsxs(e.Fragment,{children:[T.staged&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"scm-diff-section",children:i("scmStaged")}),Le(T.staged)]}),T.worktree&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"scm-diff-section",children:i("scmUnstaged")}),Le(T.worktree)]}),!T.staged&&!T.worktree&&e.jsx("div",{className:"scm-empty",children:i("scmNoDiff")})]})]})})]})]}),e.jsxs("div",{className:"scm-hint",children:[e.jsx(tt,{}),e.jsx("span",{children:i("scmRunsInTerminal")}),e.jsx("button",{type:"button",className:"scm-goto-term",onClick:c,children:i("scmViewTerminal")})]})]})}function El({entry:t,send:s}){const n=l.useRef(null),r=xe();return l.useEffect(()=>{const c=n.current;if(!c)return;let i;try{i=t.module.mount(c,Ca(t.info.id,a=>s(a)))}catch(a){console.error(`[plugin:${t.info.id}] mount failed:`,a),c.textContent=r("pluginMountFailed",{name:t.info.name})}return()=>{if(typeof i=="function")try{i()}catch(a){console.error(`[plugin:${t.info.id}] cleanup failed:`,a)}c.textContent=""}},[t,s]),e.jsx("div",{className:"plugin-view",ref:n})}function Pl({send:t,piConfigured:s,piAgentInstalled:n,providers:r,installResult:c,onClose:i}){const a=xe(),[o,u]=l.useState(!1),[m,y]=l.useState(""),[g,x]=l.useState(""),[b,E]=l.useState(!1);l.useEffect(()=>{t({type:"list_providers"})},[t]),l.useEffect(()=>{s&&i()},[s,i]),l.useEffect(()=>{c&&u(!1)},[c]),l.useEffect(()=>{var Q;!m&&r.length>0&&y(((Q=r.find(X=>!X.configured))==null?void 0:Q.id)??r[0].id)},[r,m]);const A=()=>{o||(u(!0),t({type:"install_pi_agent"}))},H=()=>{!g.trim()||b||(E(!0),t({type:"set_provider_api_key",provider:m.trim(),apiKey:g.trim()}),setTimeout(()=>E(!1),3e3))},S=()=>{t({type:"get_state"}),t({type:"list_providers"})},j=r.find(Q=>Q.id===m),J=c!==null&&!c.ok;return e.jsx("div",{className:"modal-backdrop",children:e.jsxs("div",{className:"modal setup-modal",children:[e.jsx("button",{type:"button",className:"modal-close","aria-label":a("close"),onClick:i,children:e.jsx(Pe,{})}),e.jsxs("div",{className:"modal-head",children:[e.jsx(lt,{className:"modal-head-icon"}),e.jsx("h2",{children:a("setupTitle")})]}),e.jsx("p",{className:"modal-desc",children:a("setupDesc")}),J?e.jsxs("div",{className:"setup-failed",children:[e.jsx("div",{className:"setup-done",children:a("installFailed")}),e.jsx("pre",{className:"setup-detail",children:c.detail}),e.jsxs("div",{className:"setup-actions",children:[e.jsx("button",{type:"button",className:"btn primary",disabled:o,onClick:A,children:a("retryInstall")}),e.jsx("button",{type:"button",className:"btn",onClick:i,children:a("skip")})]})]}):n||c!=null&&c.ok?e.jsxs("div",{className:"setup-key-form",children:[e.jsx("div",{className:"setup-done",children:c!=null&&c.ok?a("installDone"):a("cliReadyHint")}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:a("provider")}),e.jsxs("select",{value:m,onChange:Q=>y(Q.target.value),children:[r.length===0&&e.jsx("option",{value:"",children:a("loading")}),r.map(Q=>e.jsxs("option",{value:Q.id,children:[Q.name,"(",Q.id,")",Q.configured?` · ${a("configured")}`:""]},Q.id))]}),(j==null?void 0:j.configured)&&e.jsx("div",{className:"field-hint",children:a("providerKeyReady")})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:a("apiKey")}),e.jsx("input",{type:"password",value:g,onChange:Q=>x(Q.target.value),placeholder:"sk-…"})]}),e.jsxs("div",{className:"setup-actions",children:[e.jsx("button",{type:"button",className:"btn primary",disabled:!g.trim()||b||!m,onClick:H,children:a(b?"saving":"saveAndStart")}),e.jsxs("button",{type:"button",className:"btn",onClick:S,children:[e.jsx(rt,{})," ",a("recheck")]})]})]}):e.jsxs("div",{className:"setup-actions",children:[e.jsx("button",{type:"button",className:"btn primary",disabled:o,onClick:A,children:a(o?"installing":"autoInstall")}),e.jsx("button",{type:"button",className:"btn",onClick:i,children:a("skip")})]})]})})}const Ml=["openai-completions","openai-responses","anthropic-messages","google-generative-ai"],ps=()=>({id:"",name:"",reasoning:!1,input:"text",contextWindow:"",maxTokens:""}),Rl=()=>({providerId:"",name:"",api:"openai-completions",baseUrl:"",apiKey:"",authHeader:!0,models:[ps()]});function qt(t){return{providerId:t.providerId,name:t.name??"",api:t.api??"openai-completions",baseUrl:t.baseUrl??"",apiKey:t.apiKey??"",authHeader:t.authHeader??!1,models:(t.models.length?t.models:[ps()]).map(s=>{var n;return{id:s.id,name:s.name??"",reasoning:s.reasoning??!1,input:(n=s.input)!=null&&n.includes("image")?"text-image":"text",contextWindow:s.contextWindow?String(s.contextWindow):"",maxTokens:s.maxTokens?String(s.maxTokens):""}})}}function Il({send:t,providers:s,providerStatus:n,providerKeys:r,fetchModelsResult:c,cloneProviderResult:i,onClose:a}){const o=xe(),[u,m]=l.useState(null),[y,g]=l.useState({}),[x,b]=l.useState({}),[E,A]=l.useState(null),[H,S]=l.useState(!1),[j,J]=l.useState(0),[Q,X]=l.useState(null),U=l.useRef(0),[K,q]=l.useState(null),[Y,T]=l.useState(""),[P,k]=l.useState(null);l.useEffect(()=>{t({type:"list_models_config"}),t({type:"list_providers"}),t({type:"list_provider_keys"})},[t]);const B=()=>{if(!u)return;const v=u.baseUrl.trim();if(!v){X({ok:!1,text:o("fetchModelsNeedBaseUrl")});return}if(H)return;S(!0),X(null);const D=j+1;J(D),t({type:"fetch_models",reqId:D,baseUrl:v,apiKey:u.apiKey.trim()||void 0,authHeader:u.authHeader,api:u.api})};l.useEffect(()=>{var v;if(!(!c||c.reqId===U.current))if(U.current=c.reqId,S(!1),c.ok&&((v=c.models)!=null&&v.length)){const D=c.models;m(d=>{if(!d)return d;const w=d.models.map(W=>{var be;if(!W.id.trim())return W;const ae=D.find(ge=>ge.id===W.id.trim());if(!ae)return W;const ye={...W};return!ye.name&&ae.name&&(ye.name=ae.name),!ye.contextWindow&&ae.contextWindow&&(ye.contextWindow=String(ae.contextWindow)),!ye.maxTokens&&ae.maxTokens&&(ye.maxTokens=String(ae.maxTokens)),ye.input==="text"&&((be=ae.input)!=null&&be.includes("image"))&&(ye.input="text-image"),!ye.reasoning&&ae.reasoning&&(ye.reasoning=!0),ye}),h=new Set(w.map(W=>W.id.trim()).filter(Boolean)),L=D.filter(W=>!h.has(W.id)).map(W=>{var ae;return{id:W.id,name:W.name??"",reasoning:W.reasoning??!1,input:(ae=W.input)!=null&&ae.includes("image")?"text-image":"text",contextWindow:W.contextWindow?String(W.contextWindow):"",maxTokens:W.maxTokens?String(W.maxTokens):""}}),ee=[...w,...L];return ee.some(W=>W.id.trim())?{...d,models:ee.filter(W=>W.id.trim())}:d}),X({ok:!0,text:o("fetchModelsOk",{n:D.length})})}else X({ok:!1,text:c.error||o("fetchModelsEmpty")})},[c]);const Z=v=>{const D=(y[v.id]??"").trim();!D||E||(A(v.id),t({type:"add_provider_key",provider:v.id,apiKey:D,name:(x[v.id]??"").trim()||void 0}),setTimeout(()=>{A(null),g(d=>({...d,[v.id]:""})),b(d=>({...d,[v.id]:""})),t({type:"list_providers"}),t({type:"list_provider_keys"})},1500))},G=(v,D)=>{t({type:"activate_provider_key",provider:v,keyName:D}),t({type:"list_provider_keys"})},M=(v,D)=>{window.confirm(o("removeKeyConfirm"))&&(t({type:"remove_provider_key",provider:v,keyName:D}),t({type:"list_provider_keys"}))},I=()=>{if(!P)return;const v=P.providerId.trim();if(!v||!P.apiKey.trim())return;const D=P.models.filter(w=>w.id.trim()).map(w=>({id:w.id.trim(),name:w.name.trim()||void 0,reasoning:w.reasoning||void 0,input:w.input==="text-image"?["text","image"]:void 0,contextWindow:w.contextWindow?Number(w.contextWindow):void 0,maxTokens:w.maxTokens?Number(w.maxTokens):void 0})),d={providerId:v,name:P.name.trim()||void 0,api:P.api.trim()||void 0,baseUrl:P.baseUrl.trim()||void 0,apiKey:P.apiKey.trim()||void 0,authHeader:P.authHeader||void 0,models:D};t({type:"save_model_config",providerId:v,config:d}),k(null),a()},C=()=>{if(!u)return;const v=u.providerId.trim(),D=u.models.filter(w=>w.id.trim()).map(w=>({id:w.id.trim(),name:w.name.trim()||void 0,reasoning:w.reasoning||void 0,input:w.input==="text-image"?["text","image"]:void 0,contextWindow:w.contextWindow?Number(w.contextWindow):void 0,maxTokens:w.maxTokens?Number(w.maxTokens):void 0})),d={providerId:v,name:u.name.trim()||void 0,api:u.api.trim()||void 0,baseUrl:u.baseUrl.trim()||void 0,apiKey:u.apiKey.trim()||void 0,authHeader:u.authHeader||void 0,models:D};t({type:"save_model_config",providerId:v,config:d}),a()};l.useEffect(()=>{if(i&&i.ok){const v=i.configs;if(v&&v.length>1){q(v.map(D=>qt({...D,apiKey:""}))),T("");return}if(i.config){k(qt({...i.config,apiKey:""}));return}}},[i]);const $=v=>{window.confirm(o("clearKeyConfirm",{id:v}))&&t({type:"clear_provider_api_key",provider:v})},z=v=>{window.confirm(o("deleteProviderConfirm",{id:v.providerId,n:v.models.length}))&&t({type:"delete_model_config",providerId:v.providerId})},ne=(v,D)=>{u&&m({...u,models:u.models.map((d,w)=>w===v?{...d,...D}:d)})};return e.jsx("div",{className:"modal-backdrop",onClick:a,children:e.jsxs("div",{className:"modal model-modal",onClick:v=>v.stopPropagation(),children:[e.jsx("button",{type:"button",className:"modal-close","aria-label":o("close"),onClick:a,children:e.jsx(Pe,{})}),e.jsx("div",{className:"modal-head",children:e.jsx("h2",{children:P?o("addKey"):K?o("batchCreateProviders",{n:K.length}):o(u?"editProvider":"manageModelsTitle")})}),P?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"model-modal-body",children:e.jsxs("div",{className:"provider-form",children:[e.jsx("p",{className:"modal-desc",style:{marginBottom:12},children:o("secondKeyTitle",{api:P.api,baseUrl:P.baseUrl||o("noBaseUrlShort"),n:P.models.length})}),e.jsxs("div",{className:"form-grid",children:[e.jsxs("label",{className:"field",children:[e.jsxs("span",{className:"field-label",children:[o("providerNameLabel")," ",e.jsx("em",{children:o("providerNameHint")})]}),e.jsx("input",{type:"text",value:P.providerId,onChange:v=>k({...P,providerId:v.target.value}),placeholder:"opencode-2"})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:o("apiKeyLabel")}),e.jsx("input",{type:"password",value:P.apiKey,onChange:v=>k({...P,apiKey:v.target.value}),placeholder:o("secondKeyPlaceholder")})]})]}),e.jsxs("div",{style:{fontSize:12,opacity:.6,marginTop:8},children:[P.models.slice(0,5).map(v=>v.id).join(", "),P.models.length>5?` … +${P.models.length-5}`:""]})]})}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>k(null),children:o("cancel")}),e.jsx("button",{type:"button",className:"btn",onClick:()=>{const v=P;k(null),m(v)},children:o("advancedEdit")}),e.jsx("button",{type:"button",className:"btn primary",disabled:!P.providerId.trim()||!P.apiKey.trim(),onClick:I,children:o("save")})]})]}):K?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"model-modal-body",children:e.jsxs("div",{className:"provider-form",children:[e.jsx("p",{className:"modal-desc",style:{marginBottom:12},children:o("batchDesc",{apis:K.map(v=>v.api).join("、"),n:K.length})}),e.jsxs("label",{className:"field",style:{marginBottom:16},children:[e.jsx("span",{className:"field-label",children:o("batchKeyLabel",{n:K.length})}),e.jsx("input",{type:"password",value:Y,onChange:v=>T(v.target.value),placeholder:o("secondKeyPlaceholder")})]}),e.jsx("div",{className:"provider-list",style:{marginBottom:16},children:K.map((v,D)=>e.jsxs("div",{className:"provider-row",style:{flexDirection:"column",alignItems:"stretch",gap:6},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:13},children:[e.jsx("strong",{children:v.providerId}),e.jsx("span",{style:{opacity:.7},children:v.api})]}),e.jsxs("div",{className:"provider-sub",style:{fontSize:12,opacity:.7},children:[v.baseUrl||o("noBaseUrlShort")," · ",o("modelsCountShort",{n:v.models.length}),v.models.slice(0,3).map(d=>d.id).join(", "),v.models.length>3?` … +${v.models.length-3}`:""]}),e.jsx("input",{type:"text",value:v.providerId,onChange:d=>q(w=>w.map((h,L)=>L===D?{...h,providerId:d.target.value}:h)),placeholder:o("providerIdPlaceholder"),style:{fontSize:12}}),e.jsx("input",{type:"text",value:v.baseUrl,onChange:d=>q(w=>w.map((h,L)=>L===D?{...h,baseUrl:d.target.value}:h)),placeholder:o("baseUrlExamplePh"),style:{fontSize:12}})]},D))})]})}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>q(null),children:o("cancel")}),e.jsx("button",{type:"button",className:"btn primary",disabled:!Y.trim(),onClick:()=>{for(const v of K){const D=v.providerId.trim();if(!D)continue;const d=v.models.filter(h=>h.id.trim()).map(h=>({id:h.id.trim(),name:h.name.trim()||void 0,reasoning:h.reasoning||void 0,input:h.input==="text-image"?["text","image"]:void 0,contextWindow:h.contextWindow?Number(h.contextWindow):void 0,maxTokens:h.maxTokens?Number(h.maxTokens):void 0})),w={providerId:D,name:v.name.trim()||void 0,api:v.api.trim()||void 0,baseUrl:v.baseUrl.trim()||void 0,apiKey:Y.trim()||void 0,authHeader:v.authHeader||void 0,models:d};t({type:"save_model_config",providerId:D,config:w})}q(null),a()},children:o("saveAllBatch",{n:K.length})})]})]}):u?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"model-modal-body",children:e.jsxs("div",{className:"provider-form",children:[e.jsxs("div",{className:"form-grid",children:[e.jsxs("label",{className:"field",children:[e.jsxs("span",{className:"field-label",children:[o("providerId")," ",e.jsx("em",{children:o("providerIdHint")})]}),e.jsx("input",{type:"text",value:u.providerId,disabled:s.some(v=>v.providerId===u.providerId),onChange:v=>m({...u,providerId:v.target.value}),placeholder:"my-proxy"})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:o("displayName")}),e.jsx("input",{type:"text",value:u.name,onChange:v=>m({...u,name:v.target.value}),placeholder:o("displayNamePh")})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:o("apiType")}),e.jsx("select",{value:u.api,onChange:v=>m({...u,api:v.target.value}),children:Ml.map(v=>e.jsx("option",{value:v,children:v},v))})]}),e.jsxs("label",{className:"field",children:[e.jsxs("span",{className:"field-label",children:["baseUrl ",e.jsx("em",{children:o("baseUrlHint")})]}),e.jsx("input",{type:"text",value:u.baseUrl,onChange:v=>m({...u,baseUrl:v.target.value}),placeholder:"http://localhost:11434/v1"})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:o("apiKey")}),e.jsx("input",{type:"password",value:u.apiKey,onChange:v=>m({...u,apiKey:v.target.value}),placeholder:o("apiKeyHint")})]}),e.jsxs("label",{className:"field check",children:[e.jsx("input",{type:"checkbox",checked:u.authHeader,onChange:v=>m({...u,authHeader:v.target.checked})}),e.jsx("span",{children:o("authHeader")})]})]}),e.jsxs("div",{className:"model-section-head",children:[e.jsx("span",{className:"form-section-title",children:o("modelsTitle")}),e.jsxs("span",{className:"model-section-actions",children:[Q&&e.jsx("span",{className:`fetch-msg ${Q.ok?"ok":"err"}`,title:Q.text,children:Q.text}),e.jsxs("button",{type:"button",className:"btn sm",disabled:H||!u.baseUrl.trim(),title:o("fetchModelsHint"),onClick:B,children:[e.jsx(ls,{})," ",o(H?"fetchingModels":"fetchModels")]})]})]}),u.models.map((v,D)=>e.jsxs("div",{className:"model-row",children:[e.jsx("input",{type:"text",value:v.id,onChange:d=>ne(D,{id:d.target.value}),placeholder:o("modelIdReq")}),e.jsx("input",{type:"text",value:v.name,onChange:d=>ne(D,{name:d.target.value}),placeholder:o("displayName")}),e.jsxs("select",{value:v.input,onChange:d=>ne(D,{input:d.target.value}),children:[e.jsx("option",{value:"text",children:o("text")}),e.jsx("option",{value:"text-image",children:o("textImage")})]}),e.jsxs("label",{className:"check",children:[e.jsx("input",{type:"checkbox",checked:v.reasoning,onChange:d=>ne(D,{reasoning:d.target.checked})}),e.jsx("span",{children:o("reasoning")})]}),e.jsx("input",{type:"number",value:v.contextWindow,onChange:d=>ne(D,{contextWindow:d.target.value}),placeholder:o("contextWindow"),title:"contextWindow"}),e.jsx("input",{type:"number",value:v.maxTokens,onChange:d=>ne(D,{maxTokens:d.target.value}),placeholder:o("maxOutput"),title:"maxTokens"}),e.jsx("button",{type:"button",className:"iconbtn danger",title:o("removeModel"),onClick:()=>m({...u,models:u.models.filter((d,w)=>w!==D)}),children:e.jsx(Ae,{})})]},D)),e.jsxs("button",{type:"button",className:"btn",onClick:()=>m({...u,models:[...u.models,ps()]}),children:[e.jsx(He,{})," ",o("addModel")]})]})}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>m(null),children:o("cancel")}),e.jsx("button",{type:"button",className:"btn primary",disabled:!u.providerId.trim()||!u.models.some(v=>v.id.trim()),onClick:C,children:o("save")})]})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"model-modal-fixed-hint",children:e.jsxs("div",{className:"form-section-title",children:[o("builtinProviders")," ",e.jsx("em",{className:"section-hint",children:o("hintKeyOnly")})]})}),e.jsxs("div",{className:"model-modal-body",children:[e.jsxs("div",{className:"provider-list",children:[n.length===0&&e.jsx("div",{className:"dd-loading",children:o("loading")}),n.map(v=>{const D=r[v.id]??[];return e.jsxs("div",{className:"provider-row provider-key-row",children:[e.jsxs("div",{className:"provider-key-head",children:[e.jsxs("div",{className:"provider-info",children:[e.jsx("span",{className:"provider-name",children:v.name}),e.jsxs("span",{className:"provider-sub",children:[v.id,v.configured&&e.jsx("span",{className:"auth-badge",children:o("configuredBadge")}),v.source&&!v.configured&&e.jsx("span",{className:"auth-badge dim",children:v.source})]})]}),v.source==="stored"&&e.jsxs("button",{type:"button",className:"btn sm danger",title:o("clearKeyTitle"),onClick:()=>$(v.id),children:[e.jsx(Ae,{})," ",o("clearKey")]})]}),e.jsxs("div",{className:"provider-keys",children:[D.length===0&&e.jsx("div",{className:"provider-key-empty",children:o("noKeyYet")}),D.map(d=>e.jsxs("div",{className:`provider-key-item ${d.active?"active":""}`,children:[e.jsx("span",{className:"provider-key-dot",children:d.active?"●":"○"}),e.jsx("span",{className:"provider-key-label",children:d.name}),!d.active&&e.jsx("button",{type:"button",className:"iconbtn",title:o("activateKey"),onClick:()=>G(v.id,d.name),children:e.jsx(pt,{})}),e.jsx("button",{type:"button",className:"iconbtn danger",title:o("removeKey"),onClick:()=>M(v.id,d.name),children:e.jsx(Ae,{})})]},d.name)),e.jsxs("div",{className:"provider-add-key",children:[e.jsx("input",{type:"text",className:"key-input key-input-name",placeholder:o("keyNamePh"),value:x[v.id]??"",onChange:d=>b(w=>({...w,[v.id]:d.target.value}))}),e.jsx("input",{type:"password",className:"key-input key-input-value",placeholder:o("addKeyPlaceholder"),value:y[v.id]??"",onChange:d=>g(w=>({...w,[v.id]:d.target.value}))}),e.jsxs("button",{type:"button",className:"btn primary sm",disabled:!(y[v.id]??"").trim()||E===v.id,onClick:()=>Z(v),children:[e.jsx(He,{})," ",E===v.id?o("savingKey"):o("addKey")]})]})]})]},v.id)})]}),e.jsx("div",{className:"form-section-title",children:o("customProviders")}),e.jsx("p",{className:"modal-desc",children:o("customDesc")}),s.length===0&&e.jsx("div",{className:"dd-loading",children:o("noCustomProviders")}),e.jsx("div",{className:"provider-list",children:s.map(v=>e.jsxs("div",{className:"provider-row",children:[e.jsxs("div",{className:"provider-info",children:[e.jsx("span",{className:"provider-name",children:v.providerId}),e.jsxs("span",{className:"provider-sub",children:[v.api??"—",v.baseUrl?` · ${v.baseUrl}`:"",v.models.length>0&&` · ${o("modelsCount",{n:v.models.length})}`]})]}),e.jsxs("div",{className:"provider-actions",children:[e.jsx("button",{type:"button",className:"iconbtn",title:o("edit"),onClick:()=>m(qt(v)),children:e.jsx(St,{})}),e.jsx("button",{type:"button",className:"iconbtn danger",title:o("delete"),onClick:()=>z(v),children:e.jsx(Ae,{})})]})]},v.providerId))})]}),e.jsx("div",{className:"modal-actions",children:e.jsxs("button",{type:"button",className:"btn primary",onClick:()=>m(Rl()),children:[e.jsx(He,{})," ",o("addProvider")]})})]})]})})}function Ll({plugin:t,send:s}){const n=xe(),r=t.settingsSchema??[],[c,i]=l.useState(()=>({...t.settingsValues})),[a,o]=l.useState(!1);if(r.length===0)return null;const u=(x,b)=>i(E=>({...E,[x]:b})),m=r.some(x=>{var b;return c[x.key]!==((b=t.settingsValues)==null?void 0:b[x.key])}),y=()=>{o(!0),s({type:"plugin_settings",pluginId:t.id,values:c}),setTimeout(()=>o(!1),800)},g=()=>i({...t.settingsValues});return e.jsxs("div",{className:"plugin-settings-form",children:[e.jsx("div",{className:"plugin-settings-fields",children:r.map(x=>e.jsxs("label",{className:"plugin-settings-field",title:x.hint,children:[e.jsx("span",{className:"plugin-settings-label",children:x.label}),x.type==="boolean"?e.jsx("input",{type:"checkbox",checked:!!c[x.key],onChange:b=>u(x.key,b.target.checked)}):x.type==="select"?e.jsx("select",{value:String(c[x.key]??""),onChange:b=>u(x.key,b.target.value),children:(x.options??[]).map(b=>e.jsx("option",{value:b,children:b},b))}):e.jsx("input",{type:x.type==="password"?"password":x.type==="number"?"number":"text",value:String(c[x.key]??""),min:x.min,max:x.max,onChange:b=>u(x.key,x.type==="number"?Number(b.target.value):b.target.value)})]},x.key))}),e.jsxs("div",{className:"plugin-settings-actions",children:[e.jsx("button",{type:"button",className:"btn plugin-settings-save",disabled:!m||a,onClick:y,children:n(a?"pluginSettingsSaving":"pluginSettingsSave")}),e.jsx("button",{type:"button",className:"btn plugin-settings-reset",onClick:g,children:n("pluginSettingsReset")})]})]})}function Dl(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}function Ke({text:t}){const s=l.useRef(null),[n,r]=l.useState(!1),c=()=>{var a;const i=(a=s.current)==null?void 0:a.getBoundingClientRect();i&&r(window.innerWidth-i.right<340)};return e.jsxs("span",{ref:s,className:`set-tip${n?" flip":""}`,tabIndex:0,"aria-label":t,onMouseEnter:c,onFocus:c,children:["?",e.jsx("span",{className:"set-tip-bubble",role:"tooltip",children:t})]})}function Re({title:t,subtitle:s,tip:n,enabled:r,onToggle:c,action:i}){const a=xe();return e.jsxs("div",{className:"set-row",children:[e.jsxs("div",{className:"set-row-info",children:[e.jsxs("div",{className:"set-row-name",children:[t,n&&e.jsx(Ke,{text:n})]}),s&&e.jsx("div",{className:"set-row-desc",children:s})]}),i,e.jsx("button",{type:"button",className:`set-switch ${r?"on":""}`,role:"switch","aria-checked":r,title:a(r?"settingsEnabled":"settingsDisabled"),onClick:c,children:e.jsx("span",{className:"set-switch-knob"})})]})}function Al({chat:t,send:s,terminal:n,onSwitchToTerminal:r,onClose:c}){var Le,Be,De,R,fe,oe;const i=xe(),a=t.settings,o=t.engine==="dsh",[u,m]=l.useState("prompt"),y=l.useRef(null);l.useEffect(()=>{var p;(p=y.current)==null||p.scrollTo({top:0})},[u]),l.useEffect(()=>{u==="plugins"&&t.engine==="dsh"&&s({type:"dsh_patches_list"})},[u,t.engine,s]);const[g,x]=l.useState(""),[b,E]=l.useState("append"),A=l.useRef(!1),[H,S]=l.useState(""),[j,J]=l.useState("append"),Q=l.useRef(!1),[X,U]=l.useState(""),K=l.useRef(!1),[q,Y]=l.useState(""),[T,P]=l.useState(null),[k,B]=l.useState(null),[Z,G]=l.useState(!1),M=Hn(),[I,C]=l.useState(()=>ni()),[$,z]=l.useState(()=>{try{return dt().length}catch{return 0}}),[ne,v]=l.useState(!1),D=()=>{try{z(dt().length)}catch{z(0)}};l.useEffect(()=>{u==="prompt-history"&&D()},[u]),l.useEffect(()=>{if(!ne)return;const p=window.setTimeout(()=>v(!1),3e3);return()=>window.clearTimeout(p)},[ne]);const[d,w]=l.useState(null),[h,L]=l.useState(null);l.useEffect(()=>{a&&(E(a.promptMode),!A.current&&(x(b==="append"||a.customSystemPrompt?a.customSystemPrompt:a.defaultSystemPrompt||""),J(a.visionBridgePromptMode),!Q.current&&(S(j==="append"||a.visionBridgePrompt?a.visionBridgePrompt:a.visionBridgeDefaultPrompt||""),K.current||U(a.reviewPrompt))))},[a,b,j]);const[ee,W]=l.useState(String((a==null?void 0:a.terminalBashIdleMs)??15e3));if(l.useEffect(()=>{W(String((a==null?void 0:a.terminalBashIdleMs)??15e3))},[a==null?void 0:a.terminalBashIdleMs]),!a)return null;const ae=[{id:"prompt",icon:e.jsx(kn,{}),label:i("settingsSystemPrompt")},{id:"prompt-history",icon:e.jsx(_s,{}),label:i("settingsPromptHistory"),count:$},{id:"terminal",icon:e.jsx(tt,{}),label:i("settingsTerminalTools")},{id:"display",icon:e.jsx(st,{}),label:i("settingsMessageDisplay")},{id:"markers",icon:e.jsx(Ls,{}),label:i("settingsMarkers"),count:((Le=a.markers)==null?void 0:Le.length)??0},{id:"skills",icon:e.jsx(lt,{}),label:i("settingsSkills"),count:a.skills.length},{id:"extensions",icon:e.jsx(Ds,{}),label:i("settingsExtensions"),count:a.extensions.length},{id:"plugins",icon:e.jsx(Lt,{}),label:i("settingsUiPlugins"),count:t.plugins.length},{id:"review",icon:e.jsx(xt,{}),label:i("settingsReview"),count:a.reviewSkills.length},...o?[]:[{id:"vision",icon:e.jsx(Qt,{}),label:i("settingsVisionBridge")}],{id:"presets",icon:e.jsx(Di,{}),label:i("settingsPresets"),count:a.presets.length},...o?[]:[{id:"subagent-templates",icon:e.jsx(Rs,{}),label:i("settingsSubagentTemplates"),count:a.subagentTemplates.length}]],ye=new Set(a.disabledSkills),be=new Set(a.disabledExtensions),ge=p=>s({type:"set_settings",...p}),ke=p=>{const V=new Set(ye);V.has(p.name)?V.delete(p.name):V.add(p.name),ge({disabledSkills:[...V]})},Ee=new Set(a.disabledPlugins??[]),re=p=>{const V=new Set(Ee);V.has(p.id)?V.delete(p.id):V.add(p.id),ge({disabledPlugins:[...V]})},f=p=>{const V=new Set(be);V.has(p.id)?V.delete(p.id):V.add(p.id),ge({disabledExtensions:[...V]})},O=a.markersEnabled??!0,de=new Set(a.disabledMarkers??[]),ue=p=>{const V=new Set(de),N=p==="conv"||p==="rename"||p==="title"?["conv","rename","title"]:[p],_=!N.some(ie=>V.has(ie));for(const ie of N)_?V.add(ie):V.delete(ie);ge({disabledMarkers:[...V]})},me=(p,V)=>{var le,je;const N={name:p,command:V,cwd:"${pwd}"};let _;const ie=t.terminals.find(we=>we.title===p);ie?(n.restart(ie.id),s({type:"run_command",terminalId:ie.id,conversationId:ie.conversationId,command:N,cols:80,rows:24}),_=ie.id):(_=Ue(),n.create({id:_,conversationId:t.activeConversationId||((le=t.state)==null?void 0:le.conversationId)||"",title:p,cwd:((je=t.state)==null?void 0:je.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:N})),n.select(_),r(),c()},pe=p=>{w(null),me(`${i("uninstallTitle")} ${p}`,`pi remove npm:${p}`)},ve=p=>{L(null),me(`${i("uninstallTitle")} ${p}`,`pi-web-ui uninstall ${p}`)},Me=(p,V)=>{me(`${i("pluginUpdate")} ${p}`,`pi-web-ui install ${V} --name ${p} --force`)},he=p=>{const V=new Set(a.reviewSkills.filter(N=>!N.enabled).map(N=>N.name));V.has(p.name)?V.delete(p.name):V.add(p.name),ge({reviewDisabledSkills:[...V]})},_e=()=>{const p=b==="replace"&&a.defaultSystemPrompt&&g===a.defaultSystemPrompt?"":g;ge({promptMode:b,customSystemPrompt:p})};return e.jsx("div",{className:"modal-backdrop",onClick:c,children:e.jsxs("div",{className:"modal settings-modal",onClick:p=>p.stopPropagation(),children:[e.jsx("button",{type:"button",className:"modal-close","aria-label":i("close"),onClick:c,children:e.jsx(Pe,{})}),e.jsxs("div",{className:"modal-head",children:[e.jsx(wt,{className:"modal-head-icon"}),e.jsx("h2",{children:i("settingsTitle")}),e.jsx(Ke,{text:i("settingsDesc")})]}),e.jsxs("div",{className:"settings-layout",children:[e.jsx("nav",{className:"settings-rail","aria-label":i("settingsTitle"),children:ae.map(p=>e.jsxs("button",{type:"button",className:`settings-tab${u===p.id?" active":""}`,"aria-current":u===p.id?"true":void 0,title:p.label,onClick:()=>m(p.id),children:[e.jsx("span",{className:"settings-tab-icon",children:p.icon}),e.jsx("span",{className:"settings-tab-label",children:p.label}),p.count!==void 0&&e.jsx("span",{className:"set-count",children:p.count})]},p.id))}),e.jsxs("div",{className:"modal-body",ref:y,children:[u==="prompt"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(xt,{className:"set-section-icon"}),i("settingsSystemPrompt")]}),e.jsxs("div",{className:"set-mode-row",children:[e.jsx("label",{className:"set-field-label",children:i("settingsPromptMode")}),e.jsxs("select",{className:"set-select",value:b,onChange:p=>{const V=p.target.value;E(V),ge({promptMode:V})},children:[e.jsx("option",{value:"append",children:i("promptModeAppend")}),e.jsx("option",{value:"replace",children:i("promptModeReplace")})]}),e.jsx(Ke,{text:i(b==="append"?"promptAppendHint":"promptReplaceHint")})]}),e.jsx("textarea",{className:"set-prompt-input",rows:6,placeholder:i("promptPlaceholder"),value:g,onFocus:()=>A.current=!0,onBlur:()=>{A.current=!1,_e()},onChange:p=>x(p.target.value)}),e.jsxs("button",{type:"button",className:"set-view-prompt-btn","aria-expanded":Z,onClick:()=>G(p=>!p),children:[i("settingsViewPrompt")," ",Z?"▴":"▾"]}),Z&&e.jsxs("div",{className:"set-prompt-view",children:[e.jsxs("div",{className:"set-prompt-view-head",children:[e.jsx("span",{children:i("settingsViewPromptHint")}),e.jsx(Tt,{text:a.effectiveSystemPrompt})]}),a.effectiveSystemPrompt?e.jsx("pre",{className:"set-prompt-view-text",children:a.effectiveSystemPrompt}):e.jsx("p",{className:"set-empty",children:i("settingsViewPromptEmpty")})]})]}),u==="prompt-history"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(_s,{className:"set-section-icon"}),i("settingsPromptHistory"),e.jsx(Ke,{text:i("settingsPromptHistoryDesc")}),e.jsx("span",{className:"set-count",children:i("promptHistoryCount",{n:String($)})})]}),$===0?e.jsx("p",{className:"set-empty",children:i("promptHistoryEmpty")}):e.jsx("p",{className:"set-hint",children:i("promptHistoryCount",{n:String($)})}),e.jsxs("div",{className:"set-field",children:[e.jsx("label",{className:"set-field-label",htmlFor:"ph-max",children:i("promptHistoryMax")}),e.jsxs("div",{className:"set-mode-row",children:[e.jsx("input",{id:"ph-max",className:"set-input",type:"number",min:1,max:500,step:1,value:String(I.maxEntries),onChange:p=>{const V=Math.floor(Number(p.target.value)||0),N={...I,maxEntries:V};C(N)},onBlur:()=>{const p={...I};(!Number.isFinite(p.maxEntries)||p.maxEntries<1)&&(p.maxEntries=1),p.maxEntries>500&&(p.maxEntries=500),p.maxEntries=Math.floor(p.maxEntries),C(p),Ut(p),D()}}),e.jsx(Ke,{text:i("promptHistoryMaxHint")})]})]}),e.jsx(Re,{title:i("promptHistoryCharLimit"),tip:i("promptHistoryCharLimitHint"),enabled:I.charLimitEnabled,onToggle:()=>{const p={...I,charLimitEnabled:!I.charLimitEnabled};C(p),Ut(p),D()}}),I.charLimitEnabled&&e.jsxs("div",{className:"set-field",children:[e.jsx("label",{className:"set-field-label",htmlFor:"ph-char-limit",children:i("promptHistoryCharLimit")}),e.jsx("input",{id:"ph-char-limit",className:"set-input",type:"number",min:100,max:2e4,step:100,placeholder:i("promptHistoryCharLimitPlaceholder"),value:String(I.charLimit),onChange:p=>{const V=Math.floor(Number(p.target.value)||0);C({...I,charLimit:V})},onBlur:()=>{let p=Math.floor(Number(I.charLimit)||0);(!Number.isFinite(p)||p<100)&&(p=100),p>2e4&&(p=2e4);const V={...I,charLimit:p};C(V),Ut(V),D()}})]}),e.jsxs("div",{className:"set-field",style:{marginTop:12},children:[e.jsxs("button",{type:"button",className:`set-uninstall${ne?" confirm":""}`,disabled:$===0,title:i($===0?"promptHistoryEmpty":"promptHistoryClear"),onClick:()=>{if(!ne){v(!0);return}pl(),v(!1),D()},children:[e.jsx(Ae,{})," ",i(ne?"promptHistoryClearConfirm":"promptHistoryClear")]}),$>0&&e.jsx("span",{className:"set-hint",style:{marginLeft:8},children:i("promptHistoryCount",{n:String($)})})]}),e.jsxs("p",{className:"set-hint",children:[e.jsx(Zi,{style:{verticalAlign:"-2px",marginRight:4}}),i("settingsPromptHistoryDesc")]})]}),u==="terminal"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(tt,{className:"set-section-icon"}),i("settingsTerminalTools")]}),e.jsx(Re,{title:i("terminalToolsEnabled"),tip:i("settingsTerminalToolsDesc"),enabled:a.terminalToolsEnabled,onToggle:()=>ge({terminalToolsEnabled:!a.terminalToolsEnabled})}),!a.terminalToolsEnabled&&e.jsx("p",{className:"set-hint",children:i("terminalToolsOffHint")}),e.jsx(Re,{title:i("terminalBashTakeover"),tip:i("terminalBashTakeoverDesc"),enabled:a.terminalBash,onToggle:()=>ge({terminalBash:!a.terminalBash})}),a.terminalBash&&e.jsxs("div",{className:"set-field",children:[e.jsx("label",{className:"set-field-label",htmlFor:"tb-idle-ms",children:i("terminalBashIdleMs")}),e.jsx("input",{id:"tb-idle-ms",className:"set-input",type:"number",min:0,step:1e3,value:ee,onChange:p=>W(p.target.value),onBlur:()=>{const p=Math.max(0,Math.floor(Number(ee)||0));W(String(p)),p!==a.terminalBashIdleMs&&ge({terminalBashIdleMs:p})}})]})]}),u==="display"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(st,{className:"set-section-icon"}),i("settingsMessageDisplay")]}),e.jsx(Re,{title:i("thinkingWrap"),tip:i("thinkingWrapDesc"),enabled:a.thinkingWrap??!0,onToggle:()=>ge({thinkingWrap:!(a.thinkingWrap??!0)})}),e.jsx(Re,{title:i("toolsWrap"),tip:i("toolsWrapDesc"),enabled:a.toolsWrap??!0,onToggle:()=>ge({toolsWrap:!(a.toolsWrap??!0)})}),e.jsx("hr",{className:"set-sep"}),e.jsx(Re,{title:i("mermaidRenderSetting"),tip:i("mermaidRenderSettingDesc"),enabled:M,onToggle:()=>tr({enabled:!M})})]}),u==="markers"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Ls,{className:"set-section-icon"}),i("settingsMarkers"),e.jsx(Ke,{text:i("settingsMarkersDesc")}),e.jsx("span",{className:"set-count",children:((Be=a.markers)==null?void 0:Be.length)??0})]}),e.jsx(Re,{title:i("markersEnabled"),tip:i("markersEnabledDesc"),enabled:O,onToggle:()=>ge({markersEnabled:!O})}),!O&&e.jsx("p",{className:"set-hint",children:i("markersOffHint")}),O&&(((De=a.markers)==null?void 0:De.length)??0)===0&&e.jsxs("p",{className:"set-empty",children:[i("loading"),"..."]}),O&&a.markers&&a.markers.length>0&&e.jsx("div",{className:"set-list",children:a.markers.map(p=>e.jsx(Re,{title:p.name==="todo"?i("markerGroupTodo"):p.name==="svc"?i("markerGroupSvc"):p.name==="notify"?i("markerGroupNotify"):p.name==="conv"||p.name==="rename"||p.name==="title"?i("markerGroupRename"):p.name,subtitle:(p.guidance[0]??"").slice(0,120),tip:p.guidance.join(`
|
|
325
|
+
`),enabled:p.enabled,onToggle:()=>ue(p.name)},p.name))}),O&&e.jsx("p",{className:"set-hint",children:i("markerRenameTip")})]}),u==="skills"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(lt,{className:"set-section-icon"}),i("settingsSkills"),e.jsx("span",{className:"set-count",children:a.skills.length})]}),a.skills.length===0?e.jsx("p",{className:"set-empty",children:i(o?"dshSkillsNote":"noSkills")}):e.jsx("div",{className:"set-list",children:a.skills.map(p=>e.jsx(Re,{title:p.name,subtitle:p.description,enabled:p.enabled,onToggle:()=>ke(p)},p.name))})]}),u==="extensions"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Ds,{className:"set-section-icon"}),i("settingsExtensions"),e.jsx("span",{className:"set-count",children:a.extensions.length})]}),a.extensions.length===0?e.jsx("p",{className:"set-empty",children:i(o?"dshExtensionsNote":"noExtensions")}):e.jsx("div",{className:"set-list",children:a.extensions.map(p=>{const V=p.id.startsWith("npm:")?p.id.slice(4):null;return e.jsx(Re,{title:p.name,subtitle:p.path,enabled:p.enabled,onToggle:()=>f(p),action:V?d===p.id?e.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("uninstallConfirmHint"),onClick:()=>pe(V),children:i("uninstallConfirm")}):e.jsxs("button",{type:"button",className:"set-uninstall",title:i("uninstallHint"),onClick:()=>w(p.id),children:[e.jsx(Ae,{}),i("uninstallExt")]}):void 0},p.id)})})]}),u==="plugins"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Lt,{className:"set-section-icon"}),i("settingsUiPlugins"),e.jsx("span",{className:"set-count",children:t.plugins.length})]}),t.plugins.length===0?e.jsx("p",{className:"set-empty",children:i("noUiPlugins")}):e.jsx("div",{className:"set-list",children:t.plugins.map(p=>{var V;return e.jsxs(e.Fragment,{children:[e.jsx(Re,{title:`${p.icon?`${p.icon} `:""}${p.name}`,subtitle:(p.error?`${p.id} · ${p.error}`:p.source?`${p.id} · ${p.source}`:`${p.id} · ${i("uiPluginNoSource")}`)+((V=p.permissions)!=null&&V.length?` · ${i("uiPluginPerms")}: ${p.permissions.join(", ")}`:""),enabled:!Ee.has(p.id)&&!p.error,onToggle:()=>!p.error&&re(p),action:e.jsxs("div",{className:"set-row-actions",children:[p.source&&e.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUpdateHint"),onClick:()=>Me(p.id,p.source),children:[e.jsx(rt,{}),i("pluginUpdate")]}),h===p.id?e.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("pluginUninstallHint"),onClick:()=>ve(p.id),children:i("uninstallConfirm")}):e.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUninstallHint"),onClick:()=>L(p.id),children:[e.jsx(Ae,{}),i("uninstallExt")]})]})},p.id),p.settingsSchema&&p.settingsSchema.length>0&&e.jsx(Ll,{plugin:p,send:s})]})})})]}),u==="plugins"&&t.engine==="dsh"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Lt,{className:"set-section-icon"}),i("dshPatches"),e.jsx(Ke,{text:i("dshPatchesDesc")}),e.jsx("span",{className:"set-count",children:((R=t.dshPatches)==null?void 0:R.files.length)??0}),e.jsxs("button",{type:"button",className:"set-uninstall",title:i("dshPatchesRescanHint"),onClick:()=>s({type:"dsh_patches_rescan"}),children:[e.jsx(rt,{}),i("dshPatchesRescan")]})]}),(((fe=t.dshPatches)==null?void 0:fe.files.length)??0)===0?e.jsx("p",{className:"set-empty",children:i("dshPatchesEmpty")}):e.jsx("div",{className:"set-list",children:t.dshPatches.files.map(p=>e.jsx("div",{className:"set-row",children:e.jsxs("div",{className:"set-row-info",children:[e.jsx("div",{className:"set-row-name",children:p.name}),e.jsxs("div",{className:"set-row-desc",children:[Dl(p.size)," · ",new Date(p.mtimeMs).toLocaleString()]})]})},p.name))}),e.jsxs("p",{className:"set-hint",children:[i("dshPatchesPath")," ",((oe=t.dshPatches)==null?void 0:oe.patchDir)??""]})]}),u==="review"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(xt,{className:"set-section-icon"}),i("settingsReview"),e.jsx(Ke,{text:i("settingsReviewDesc")}),e.jsx("span",{className:"set-count",children:a.reviewSkills.length})]}),o&&e.jsx("p",{className:"set-hint",children:i("dshReviewPromptNote")}),e.jsx("textarea",{className:"set-prompt-input",rows:5,placeholder:i("reviewPromptPlaceholder"),value:X,onFocus:()=>K.current=!0,onBlur:()=>{K.current=!1,ge({reviewPrompt:X})},onChange:p=>U(p.target.value)}),e.jsx("div",{className:"set-field-label",children:i("settingsReviewSkills")}),a.reviewSkills.length===0?e.jsx("p",{className:"set-empty",children:i("noSkills")}):e.jsx("div",{className:"set-list",children:a.reviewSkills.map(p=>e.jsx(Re,{title:p.name,subtitle:p.description,enabled:p.enabled,onToggle:()=>he(p)},`review-${p.name}`))})]}),u==="vision"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Qt,{className:"set-section-icon"}),i("settingsVisionBridge")]}),e.jsx(Re,{title:i("visionBridgeEnabled"),tip:i("settingsVisionBridgeDesc"),enabled:a.visionBridgeEnabled,onToggle:()=>ge({visionBridgeEnabled:!a.visionBridgeEnabled})}),!a.visionBridgeEnabled&&e.jsx("p",{className:"set-hint",children:i("visionBridgeOffHint")}),a.visionBridgeEnabled&&e.jsxs("div",{className:"set-mode-row",children:[e.jsx("label",{className:"set-field-label",children:i("visionBridgeModel")}),e.jsxs("select",{className:"set-select",value:a.visionBridgeModel??"",onChange:p=>ge({visionBridgeModel:p.target.value||null}),children:[e.jsx("option",{value:"",children:i("visionBridgeAuto")}),a.visionModels.map(p=>e.jsx("option",{value:`${p.provider}/${p.id}`,children:p.label},`${p.provider}/${p.id}`))]})]}),a.visionBridgeEnabled&&e.jsxs("div",{className:"set-mode-row",children:[e.jsx("label",{className:"set-field-label",children:i("visionBridgePromptMode")}),e.jsxs("select",{className:"set-select",value:j,onChange:p=>{const V=p.target.value;J(V),ge({visionBridgePromptMode:V})},children:[e.jsx("option",{value:"append",children:i("promptModeAppend")}),e.jsx("option",{value:"replace",children:i("promptModeReplace")})]})]}),a.visionBridgeEnabled&&e.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:i("visionBridgePromptPlaceholder"),value:H,onFocus:()=>Q.current=!0,onBlur:()=>{Q.current=!1;const p=j==="replace"&&a.visionBridgeDefaultPrompt&&H===a.visionBridgeDefaultPrompt?"":H;ge({visionBridgePromptMode:j,visionBridgePrompt:p})},onChange:p=>S(p.target.value)}),a.visionBridgeEnabled&&(a.visionModels.length===0?e.jsx("p",{className:"set-hint",children:i("visionBridgeNoModels")}):e.jsx("p",{className:"set-hint",children:i("visionBridgeCurrent",{model:a.visionBridgeModel??i("visionBridgeAuto")})}))]}),u==="presets"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(wt,{className:"set-section-icon"}),i("settingsPresets"),e.jsx("span",{className:"set-count",children:a.presets.length})]}),e.jsxs("div",{className:"set-preset-save",children:[e.jsx("input",{className:"set-input",placeholder:i("presetNamePlaceholder"),value:q,onChange:p=>Y(p.target.value),onKeyDown:p=>{p.key==="Enter"&&q.trim()&&(s({type:"save_preset",name:q.trim()}),Y(""))}}),e.jsxs("button",{type:"button",className:"set-save-btn",disabled:!q.trim(),onClick:()=>{s({type:"save_preset",name:q.trim()}),Y("")},children:[e.jsx(He,{})," ",i("saveAsPreset")]})]}),a.presets.length===0?e.jsx("p",{className:"set-empty",children:i("noPresets")}):e.jsx("div",{className:"set-list",children:a.presets.map(p=>e.jsxs("div",{className:"set-row",children:[e.jsxs("div",{className:"set-row-info",children:[e.jsx("div",{className:"set-row-name",children:p.name}),e.jsxs("div",{className:"set-row-desc",children:[p.promptMode==="replace"?i("promptModeReplace"):i("promptModeAppend"),p.disabledSkills.length>0&&` · ${i("settingsSkills")} ${p.disabledSkills.length}`,p.disabledExtensions.length>0&&` · ${i("settingsExtensions")} ${p.disabledExtensions.length}`]})]}),e.jsxs("div",{className:"set-row-actions",children:[e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>s({type:"apply_preset",name:p.name}),children:i("applyPreset")}),e.jsx("button",{type:"button",className:"set-icon-btn danger",title:i("deletePreset"),onClick:()=>s({type:"delete_preset",name:p.name}),children:e.jsx(Ae,{})})]})]},p.name))})]}),u==="subagent-templates"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Rs,{className:"set-section-icon"}),i("settingsSubagentTemplates"),e.jsx(Ke,{text:i("settingsSubagentTemplatesDesc")}),e.jsx("span",{className:"set-count",children:a.subagentTemplates.length}),e.jsxs("button",{type:"button",className:"set-save-btn",title:i("subagentTemplateNew"),onClick:()=>P({name:"",description:"",promptMode:"replace",systemPrompt:"",enabledSkills:[],enabledExtensions:[],model:"",enabled:!0}),children:[e.jsx(He,{})," ",i("subagentTemplateNew")]})]}),e.jsxs("div",{className:"set-mode-row",children:[e.jsx("label",{className:"set-field-label",children:i("subagentDefaultModelLabel")}),e.jsxs("select",{className:"set-select",value:a.subagentDefaultModel??"",onChange:p=>ge({subagentDefaultModel:p.target.value||null}),children:[e.jsx("option",{value:"",children:i("subagentFollowMain")}),a.subagentModels.map(p=>e.jsx("option",{value:`${p.provider}/${p.id}`,children:p.label},`${p.provider}/${p.id}`))]})]}),a.subagentModels.length===0?e.jsx("p",{className:"set-hint",children:i("subagentNoModels")}):e.jsx("p",{className:"set-hint",children:i("subagentDefaultModelHint")}),T&&e.jsxs("div",{className:"tpl-editor",children:[e.jsxs("div",{className:"tpl-fields",children:[e.jsx("input",{className:"set-input",placeholder:i("tplNamePlaceholder"),value:T.name,onChange:p=>P({...T,name:p.target.value})}),e.jsx("input",{className:"set-input",placeholder:i("tplDescriptionPlaceholder"),value:T.description,onChange:p=>P({...T,description:p.target.value})})]}),e.jsxs("div",{className:"set-mode-row",children:[e.jsx("label",{className:"set-field-label",children:i("tplPromptModeLabel")}),e.jsxs("select",{className:"set-select",value:T.promptMode,onChange:p=>P({...T,promptMode:p.target.value}),children:[e.jsx("option",{value:"replace",children:i("promptModeReplace")}),e.jsx("option",{value:"append",children:i("promptModeAppend")})]})]}),e.jsxs("div",{className:"set-mode-row",children:[e.jsx("label",{className:"set-field-label",children:i("tplModelLabel")}),e.jsxs("select",{className:"set-select",value:T.model??"",onChange:p=>P({...T,model:p.target.value}),children:[e.jsx("option",{value:"",children:i("subagentFollowMain")}),a.subagentModels.map(p=>e.jsx("option",{value:`${p.provider}/${p.id}`,children:p.label},`${p.provider}/${p.id}`))]})]}),e.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:`${i("tplSystemPromptLabel")}:${i("tplSystemPromptPlaceholder")}`,value:T.systemPrompt,onChange:p=>P({...T,systemPrompt:p.target.value})}),e.jsxs("div",{className:"tpl-pick-block",children:[e.jsx("div",{className:"tpl-pick-head",children:e.jsxs("span",{children:[i("tplSkillsLabel")," · ",i("tplWhitelistHint")]})}),a.skills.length===0?e.jsx("p",{className:"set-hint",children:i("noSkills")}):e.jsx("div",{className:"tpl-pick",children:a.skills.map(p=>e.jsxs("label",{className:`tpl-chip${T.enabledSkills.includes(p.name)?" on":""}`,children:[e.jsx("input",{type:"checkbox",checked:T.enabledSkills.includes(p.name),onChange:V=>{const N=V.target.checked;P({...T,enabledSkills:N?[...T.enabledSkills,p.name]:T.enabledSkills.filter(_=>_!==p.name)})}}),p.name]},p.name))})]}),e.jsxs("div",{className:"tpl-pick-block",children:[e.jsx("div",{className:"tpl-pick-head",children:e.jsxs("span",{children:[i("tplExtensionsLabel")," · ",i("tplWhitelistHint")]})}),a.extensions.length===0?e.jsx("p",{className:"set-hint",children:i("noExtensions")}):e.jsx("div",{className:"tpl-pick",children:a.extensions.map(p=>e.jsxs("label",{className:`tpl-chip${T.enabledExtensions.includes(p.id)?" on":""}`,children:[e.jsx("input",{type:"checkbox",checked:T.enabledExtensions.includes(p.id),onChange:V=>{const N=V.target.checked;P({...T,enabledExtensions:N?[...T.enabledExtensions,p.id]:T.enabledExtensions.filter(_=>_!==p.id)})}}),p.name]},p.id))})]}),e.jsxs("div",{className:"tpl-actions",children:[e.jsx("button",{type:"button",className:"set-save-btn",disabled:!T.name.trim(),onClick:()=>{s({type:"save_subagent_template",template:{...T,name:T.name.trim()}}),P(null)},children:i("tplSave")}),e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>P(null),children:i("tplCancel")})]})]}),a.subagentTemplates.length===0?e.jsx("p",{className:"set-empty",children:i("noSubagentTemplates")}):e.jsx("div",{className:"set-list",children:a.subagentTemplates.map(p=>e.jsxs("div",{className:"set-row",children:[e.jsxs("div",{className:"set-row-info",children:[e.jsxs("div",{className:"set-row-name",children:[p.name,a.subagentDefaultTemplates.includes(p.name)&&e.jsx("span",{className:"tpl-badge default",children:i("tplDefaultBadge")}),!p.enabled&&e.jsx("span",{className:"tpl-badge",children:i("subagentTemplateClosed")})]}),e.jsxs("div",{className:"set-row-desc",children:[p.description||`${p.promptMode==="replace"?i("promptModeReplace"):i("promptModeAppend")}`,p.model?` · ${i("tplModelLabel")} ${p.model}`:` · ${i("subagentFollowMain")}`,p.enabledSkills.length>0&&` · ${i("tplSkillsLabel")} ${p.enabledSkills.length}`,p.enabledExtensions.length>0&&` · ${i("tplExtensionsLabel")} ${p.enabledExtensions.length}`,!p.description&&p.enabledSkills.length===0&&p.enabledExtensions.length===0&&` · ${i("tplInherit")}`]})]}),e.jsxs("div",{className:"set-row-actions",children:[e.jsx("button",{type:"button",className:`set-switch${p.enabled?" on":""}`,role:"switch","aria-checked":p.enabled,title:`${p.enabled?i("subagentTemplateDisable"):i("subagentTemplateEnable")} · ${i("subagentTemplateOffHint")}`,onClick:()=>s({type:"save_subagent_template",template:{...p,enabled:!p.enabled}}),children:e.jsx("span",{className:"set-switch-knob"})}),e.jsx("button",{type:"button",className:"dd-refresh",title:i("subagentTemplateEdit"),onClick:()=>P({...p}),children:i("subagentTemplateEdit")}),k===p.name?e.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("uninstallConfirmHint"),onClick:()=>{s({type:"delete_subagent_template",name:p.name}),B(null)},children:i("uninstallConfirm")}):e.jsx("button",{type:"button",className:"set-icon-btn danger",title:i("tplDelete"),onClick:()=>B(p.name),children:e.jsx(Ae,{})})]})]},p.name))})]})]})]}),e.jsx("div",{className:"modal-actions",children:e.jsx("button",{type:"button",className:"dd-refresh",onClick:c,children:i("close")})})]})})}function _l(t,s){const n=Math.max(0,Date.now()-t),r=Math.floor(n/6e4);if(r<1)return s("bgTaskJustNow");if(r<60)return s("bgTaskMinutes",{n:r});const c=Math.floor(r/60);return c<24?s("bgTaskHours",{n:c}):s("bgTaskDays",{n:Math.floor(c/24)})}function Bl({servers:t,send:s,onClose:n}){const r=xe(),[c,i]=l.useState(new Set),a=o=>i(u=>{const m=new Set(u);return m.has(o)?m.delete(o):m.add(o),m});return l.useEffect(()=>{s({type:"list_bg_servers"})},[]),e.jsx("div",{className:"modal-backdrop",onClick:n,children:e.jsxs("div",{className:"bg-task-modal",onClick:o=>o.stopPropagation(),children:[e.jsxs("div",{className:"bg-task-head",children:[e.jsxs("span",{className:"bg-task-title",children:[e.jsx(Ct,{})," ",r("bgTasks"),t.length>0&&e.jsx("em",{className:"bg-task-count",children:t.length})]}),e.jsx("button",{type:"button",className:"btn",title:r("close"),onClick:n,children:e.jsx(Pe,{})})]}),t.length===0?e.jsxs("div",{className:"bg-task-empty",children:[e.jsx(Ct,{}),e.jsx("span",{children:r("bgTasksEmpty")}),e.jsx("small",{children:r("bgTasksDesc")})]}):e.jsx("ul",{className:"bg-task-list",children:t.map(o=>{const u=!!o.taskId,m=o.taskId??String(o.port);return e.jsxs("li",{className:"bg-task-item",children:[e.jsx("span",{className:"bg-task-icon",title:u?o.plugin:r("bgTaskPort")}),e.jsxs("div",{className:"bg-task-info",children:[e.jsxs("div",{className:"bg-task-line1",children:[u?e.jsxs("span",{className:"bg-task-port",title:o.taskId,children:["🧩 ",o.plugin]}):e.jsxs("span",{className:"bg-task-port",children:[":",o.port]}),o.name&&e.jsx("span",{className:"bg-task-name",children:o.name})]}),e.jsxs("div",{className:"bg-task-line2",children:[!u&&e.jsxs("span",{children:[r("bgTaskPid")," ",o.pid]}),e.jsxs("span",{children:[r("bgTaskSince")," ",_l(o.since,r)]}),u&&o.status&&e.jsx("span",{className:"bg-task-status",children:o.status})]}),o.command&&e.jsxs("button",{type:"button",className:`bg-task-cmd ${c.has(m)?"open":""}`,title:`${r("bgTaskCommand")}: ${o.command}`,onClick:()=>a(m),children:[e.jsx(tt,{}),e.jsx("code",{children:o.command})]})]}),e.jsxs("button",{type:"button",className:"btn bg-task-stop",title:r("bgTaskStop"),onClick:()=>s(u?{type:"kill_background_server",taskId:o.taskId}:{type:"kill_background_server",port:o.port}),children:[e.jsx(jt,{}),e.jsx("span",{children:r("bgTaskStop")})]})]},m)})}),e.jsxs("div",{className:"bg-task-foot",children:[e.jsxs("button",{type:"button",className:"btn",title:r("bgTaskRefresh"),onClick:()=>s({type:"list_bg_servers"}),children:[e.jsx(rt,{}),e.jsx("span",{children:r("bgTaskRefresh")})]}),e.jsxs("button",{type:"button",className:"btn bg-task-stopall",disabled:t.length===0,title:r("bgTaskStopAll"),onClick:()=>s({type:"kill_background_servers"}),children:[e.jsx(jt,{}),e.jsx("span",{children:r("bgTaskStopAll")})]})]})]})})}function Fl(t,s){return t.toLowerCase().includes(s)}function $l({open:t,send:s,projects:n,cwd:r,fileSearch:c,sessionSearch:i,onClose:a,onSwitchSession:o,onSwitchProject:u,onPreviewFile:m}){const y=xe(),g=l.useRef(null),[x,b]=l.useState(""),E=l.useDeferredValue(x),[A,H]=l.useState(0),S=l.useRef(1),j=l.useRef(0),J=l.useRef(null);l.useEffect(()=>{if(!t)return;s({type:"list_sessions"}),s({type:"list_projects"});const M=x.trim();if(M){const I=++S.current;j.current=I,X(!0),s({type:"search_files",reqId:I,query:M}),s({type:"search_sessions",reqId:I,query:M})}requestAnimationFrame(()=>{var I;return(I=g.current)==null?void 0:I.select()})},[t]);const[Q,X]=l.useState(!1);l.useEffect(()=>{J.current&&clearTimeout(J.current);const M=E.trim();if(!M){X(!1);return}return J.current=setTimeout(()=>{const I=++S.current;j.current=I,X(!0),s({type:"search_files",reqId:I,query:M}),s({type:"search_sessions",reqId:I,query:M})},300),()=>{J.current&&clearTimeout(J.current)}},[E]);const U=E.trim().toLowerCase(),K=l.useMemo(()=>!U||!i||i.reqId!==j.current||!i.ok?[]:i.results,[i,U]),q=l.useMemo(()=>U?n.filter(M=>Fl(M.path,U)).slice(0,10):[],[n,U]),Y=l.useMemo(()=>!U||!c||c.reqId!==j.current||!c.ok?[]:c.results,[c,U]);l.useEffect(()=>{c&&c.reqId===j.current&&i&&i.reqId===j.current&&j.current!==0&&X(!1)},[c,i]);const T=!!c&&c.ok&&c.truncated,P=l.useMemo(()=>[...K.map(M=>({kind:"session",path:M.path,anchors:M.anchors})),...q.map(M=>({kind:"project",path:M.path})),...Y.filter(M=>M.type==="file").map(M=>({kind:"file",path:M.path,name:M.name}))],[K,q,Y]);l.useEffect(()=>{H(0)},[E]);const k=l.useCallback(M=>{if(M)if(M.kind==="session")o(M.path,M.anchors),a();else if(M.kind==="project"){u(M.path),s({type:"list_sessions"}),s({type:"list_projects"});const I=E.trim();if(I){const C=++S.current;j.current=C,X(!0),s({type:"search_files",reqId:C,query:I}),s({type:"search_sessions",reqId:C,query:I})}}else m(M.path,M.name)},[o,u,m,s,E]);l.useEffect(()=>{if(!t)return;const M=I=>{I.key==="Escape"?(I.preventDefault(),I.stopPropagation(),a()):I.key==="ArrowDown"?(I.preventDefault(),H(C=>Math.min(C+1,P.length-1))):I.key==="ArrowUp"?(I.preventDefault(),H(C=>Math.max(C-1,0))):I.key==="Enter"&&(I.preventDefault(),k(P[A]))};return window.addEventListener("keydown",M,!0),()=>window.removeEventListener("keydown",M,!0)},[P,A,k,a,t]);const B=K.length+q.length+Y.length,Z=(M,I,C)=>e.jsxs("div",{className:"gs-section-head",children:[C,e.jsx("span",{children:M}),e.jsx("em",{children:I})]});let G=-1;return t?e.jsx("div",{className:"modal-backdrop gs-backdrop",onClick:a,children:e.jsxs("div",{className:"gs-modal",onClick:M=>M.stopPropagation(),children:[e.jsxs("div",{className:"gs-input-row",children:[e.jsx(Nt,{}),e.jsx("input",{ref:g,type:"text",value:x,placeholder:y("gsPlaceholder"),onChange:M=>b(M.target.value)}),e.jsx("button",{type:"button",className:"gs-close",title:y("close"),onClick:a,children:e.jsx(Pe,{})})]}),e.jsxs("div",{className:"gs-results",children:[!U&&e.jsx("div",{className:"gs-empty",children:y("gsHint")}),U&&B===0&&!T&&e.jsx("div",{className:"gs-empty",children:y(Q?"gsSearching":"gsNoResults")}),K.length>0&&e.jsxs("div",{className:"gs-section",children:[Z(y("gsSessions"),K.length,e.jsx(st,{})),K.map(M=>{G++;const I=G;return e.jsxs("button",{type:"button",className:I===A?"gs-item active":"gs-item",onMouseEnter:()=>H(I),onClick:()=>k({kind:"session",path:M.path,anchors:M.anchors}),children:[e.jsxs("span",{className:"gs-item-title",children:[M.name||M.path.split(/[\\/]/).pop(),e.jsx("em",{className:"gs-item-meta",children:M.messageCount})]}),e.jsx("span",{className:"gs-item-sub",children:M.firstMessage})]},M.path)})]}),q.length>0&&e.jsxs("div",{className:"gs-section",children:[Z(y("gsProjects"),q.length,e.jsx(Je,{})),q.map(M=>{G++;const I=G,C=r&&M.path===r;return e.jsxs("button",{type:"button",className:I===A?"gs-item active":"gs-item",onMouseEnter:()=>H(I),onClick:()=>k({kind:"project",path:M.path}),children:[e.jsxs("span",{className:"gs-item-title",children:[M.path.split(/[\\/]/).pop(),C&&e.jsx("em",{className:"gs-item-meta",children:y("gsCurrentProject")})]}),e.jsx("span",{className:"gs-item-sub",children:M.path})]},M.path)})]}),(Y.length>0||U&&T)&&e.jsxs("div",{className:"gs-section",children:[Z(y("gsFiles"),Y.length,e.jsx(kn,{})),Y.map(M=>{G++;const I=G;return e.jsxs("button",{type:"button",className:I===A?"gs-item active":"gs-item",disabled:M.type==="dir",title:M.type==="dir"?void 0:y("gsOpenPreview"),onMouseEnter:()=>H(I),onClick:()=>{M.type==="file"&&k({kind:"file",path:M.path,name:M.name})},children:[e.jsx("span",{className:"gs-item-title",children:M.name}),e.jsx("span",{className:"gs-item-sub",children:M.path})]},`${M.type}:${M.path}`)}),T&&e.jsx("div",{className:"gs-truncated",children:y("gsTruncated")})]})]}),e.jsxs("div",{className:"gs-foot",children:[e.jsxs("span",{children:["↑↓ ",y("gsNavigate")]}),e.jsxs("span",{children:["Enter ",y("gsOpen")]}),e.jsxs("span",{children:["Esc ",y("gsCloseHint")]})]})]})}):null}const zt=5e3;function Hl({file:t,content:s,send:n,onAddLines:r,onAttach:c,onClose:i}){const a=xe(),[o,u]=l.useState(null),[m,y]=l.useState(!1),[g,x]=l.useState(null),[b,E]=l.useState(!1),[A,H]=l.useState(!1),[S,j]=l.useState(!1),[J,Q]=l.useState(""),[X,U]=l.useState(!0),K=l.useRef(!1),[q,Y]=l.useState(!0),[T,P]=l.useState(!1),[k,B]=l.useState(100),Z=l.useRef(0),G=l.useRef(!1),M=l.useRef(null);l.useEffect(()=>{y(!0),u(null),x(null),j(!1),Q(""),U(!0),K.current=!1,n({type:"read_file",path:t.path})},[t.path,n]),l.useEffect(()=>{s&&s.path===t.path&&(u(s),S||Q(s.text),y(!1))},[s,S,t.path]),l.useEffect(()=>{const re=f=>{if(f.key==="Escape"){L();return}if((f.ctrlKey||f.metaKey)&&f.key.toLowerCase()==="s"&&S){f.preventDefault(),h();return}const O=f.target,de=O&&(O.tagName==="INPUT"||O.tagName==="TEXTAREA"||O.isContentEditable);(f.ctrlKey||f.metaKey)&&f.key.toLowerCase()==="a"&&!de&&(f.preventDefault(),ne())};return document.addEventListener("keydown",re),()=>document.removeEventListener("keydown",re)},[i,o,S,J]),l.useEffect(()=>{const re=()=>{G.current=!1,E(!1)};return window.addEventListener("mouseup",re),()=>window.removeEventListener("mouseup",re)},[]);const I=l.useMemo(()=>{if(!o)return[];const re=o.text.split(`
|
|
326
|
+
`);return re.length>0&&re[re.length-1]===""&&re.pop(),re.slice(0,zt)},[o]),C=(o==null?void 0:o.lines)??0,$=C>zt,z=(re,f)=>{if(f){const O=Z.current>0?Z.current:re;x({start:Math.min(O,re),end:Math.max(O,re)})}else Z.current=re,x({start:re,end:re})},ne=()=>{I.length!==0&&(Z.current=1,x({start:1,end:I.length}))},v=()=>{g&&(r(t.path,t.name,g.start,g.end),H(!0),M.current&&clearTimeout(M.current),M.current=setTimeout(()=>H(!1),1400))},D=o!==null&&o.kind==="text"&&!o.binary&&!o.truncated,d=()=>{Q((o==null?void 0:o.text)??""),j(!1),K.current&&U(!0)},w=()=>{if(S){if(J!==((o==null?void 0:o.text)??"")&&!window.confirm(a("discardFileChanges")))return;d();return}!D||!o||(K.current=Vt(t.name)&&X,Vt(t.name)&&U(!1),x(null),Q(o.text),j(!0))},h=()=>{!S||!o||!D||n({type:"write_file",path:t.path,text:J})&&(j(!1),K.current&&U(!0),x(null))},L=()=>{S&&J!==((o==null?void 0:o.text)??"")&&!window.confirm(a("discardFileChanges"))||i()},ee=re=>{B(Math.min(200,Math.max(50,re)))},W=g?g.end-g.start+1:0,ae=(o==null?void 0:o.binary)??!1,ye=(o==null?void 0:o.truncated)??!1,be=(o==null?void 0:o.kind)??"text",ge=Vt(t.name),ke=ge&&X&&!S&&be==="text"&&!ae,Ee=re=>Mt(Ve(`/api/file?clientId=${encodeURIComponent(os())}&path=${encodeURIComponent(re)}`));return e.jsx("div",{className:`fp-overlay ${T?"fullscreen":""}`,onMouseDown:re=>{re.target===re.currentTarget&&L()},children:e.jsxs("div",{className:`fp ${T?"fullscreen":""}`,style:{"--fp-zoom":k/100},children:[e.jsxs("div",{className:"fp-head",children:[e.jsx("span",{className:"fp-name",title:t.path,children:t.name}),e.jsx("span",{className:"fp-path",children:t.path}),e.jsxs("span",{className:"fp-meta",children:[o&&be==="text"&&!ae&&a("fileLines",{n:C}),o&&` · ${Ol(o.size)}`]}),e.jsxs("span",{className:"fp-head-actions",children:[ge&&be==="text"&&!ae&&o&&e.jsx("button",{type:"button",className:`fp-attach markdown ${X?"on":""}`,"data-tip":a(X?"showMarkdownSource":"showMarkdownPreview"),disabled:S,onClick:()=>U(re=>!re),children:X?e.jsx(Qt,{}):e.jsx(Qi,{})}),be==="text"&&!ae&&o&&e.jsx("button",{type:"button",className:`fp-attach edit ${S?"on":""}`,"data-tip":a(ye?"fileEditTruncated":S?"exitEditFile":"editFile"),disabled:!D&&!S,onClick:w,children:e.jsx(Yt,{})}),be==="text"&&!ae&&!ke&&e.jsx("button",{type:"button",className:`fp-attach wrap ${q?"on":""}`,"data-tip":a(q?"disableWrap":"enableWrap"),onClick:()=>Y(re=>!re),children:e.jsx(Gi,{})}),be==="text"&&o&&e.jsxs("span",{className:"fp-zoom",children:[e.jsx("button",{type:"button",className:"fp-attach zoom-out","data-tip":a("zoomOut"),disabled:k<=50,onClick:()=>ee(k-10),children:e.jsx(Pi,{})}),e.jsxs("button",{type:"button",className:"fp-zoom-val",title:a("resetZoom"),onClick:()=>B(100),children:[k,"%"]}),e.jsx("button",{type:"button",className:"fp-attach zoom-in","data-tip":a("zoomIn"),disabled:k>=200,onClick:()=>ee(k+10),children:e.jsx(Mi,{})})]}),be!=="video"&&be!=="none"&&e.jsx("button",{type:"button",className:"fp-attach inline","data-tip":a("attachInlineTip"),onClick:()=>c(t.path,t.name,"inline"),children:e.jsx(He,{})}),e.jsx("button",{type:"button",className:"fp-attach ref","data-tip":a("referenceTip"),onClick:()=>c(t.path,t.name,"reference"),children:e.jsx(Gt,{})}),e.jsx("button",{type:"button",className:`fp-attach full ${T?"on":""}`,"data-tip":a(T?"exitFullscreen":"fullscreen"),onClick:()=>P(re=>!re),children:T?e.jsx(Fi,{}):e.jsx(Hi,{})}),e.jsx("button",{type:"button",className:"fp-close",title:a("close"),onClick:L,children:e.jsx(Pe,{})})]})]}),ye&&be==="text"&&!ae&&e.jsx("div",{className:"fp-notice",children:a("previewTruncated")}),m&&!o&&e.jsx("div",{className:"fp-empty",children:a("loading")}),!m&&be==="none"&&!ae&&e.jsx("div",{className:"fp-empty",children:a("previewNotSupported")}),!m&&be==="image"&&e.jsx("div",{className:"fp-media-wrap",children:e.jsx("img",{className:"fp-media",src:Ee(t.path),alt:t.name})}),!m&&be==="video"&&e.jsx("div",{className:"fp-media-wrap",children:e.jsx("video",{className:"fp-media",src:Ee(t.path),controls:!0,preload:"metadata"})}),!m&&ke&&o&&e.jsx("div",{className:"fp-markdown msg-text",children:e.jsx("div",{className:"fp-markdown-zoom",children:e.jsx(Rt,{text:o.text})})}),!m&&ae&&be!=="image"&&be!=="video"&&o&&e.jsxs("div",{className:"fp-hex-wrap",children:[e.jsxs("div",{className:"fp-notice",children:[a("binaryFile"),o.truncated&&a("binaryHexTruncated")]}),e.jsx("pre",{className:"fp-hex",children:o.text})]}),!m&&S&&be==="text"&&!ae&&o&&e.jsx("textarea",{className:`fp-editor ${q?"":"no-wrap"}`,value:J,onChange:re=>Q(re.target.value),wrap:q?"soft":"off",spellCheck:!1,autoFocus:!0}),!m&&!ke&&!S&&be==="text"&&!ae&&o&&I.length===0&&e.jsx("div",{className:"fp-empty",children:a("emptyFile")}),!m&&!ke&&!S&&be==="text"&&!ae&&I.length>0&&e.jsxs("div",{className:`fp-code ${b?"dragging":""} ${q?"":"no-wrap"}`,onMouseDown:re=>{re.button===0&&re.preventDefault()},children:[I.map((re,f)=>{const O=f+1,de=g!==null&&O>=g.start&&O<=g.end;return e.jsxs("div",{className:`fp-line ${de?"sel":""}`,onMouseDown:ue=>{ue.button===0&&(z(O,ue.shiftKey),G.current=!0,E(!0))},onMouseEnter:()=>{G.current&&z(O,!0)},children:[e.jsx("span",{className:"fp-num",children:O}),e.jsx("span",{className:"fp-code-text",children:re})]},O)}),$&&e.jsx("div",{className:"fp-lines-note",children:a("previewLinesTruncated",{n:zt})})]}),e.jsx("div",{className:"fp-foot",children:S?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"fp-hint",children:a("editFile")}),e.jsxs("div",{className:"fp-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:w,children:a("cancel")}),e.jsxs("button",{type:"button",className:"btn primary",disabled:J===((o==null?void 0:o.text)??""),onClick:h,children:[e.jsx(Ai,{})," ",a("saveFile")]})]})]}):!ke&&be==="text"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"fp-hint",children:g?a("selectedRange",{n:W,start:g.start,end:g.end}):a("selectLinesHint")}),e.jsxs("div",{className:"fp-actions",children:[e.jsx("button",{type:"button",className:"btn",disabled:I.length===0,onClick:ne,children:a("selectAll")}),e.jsx("button",{type:"button",className:"btn",disabled:!g,onClick:()=>x(null),children:a("clearSelection")}),e.jsxs("button",{type:"button",className:"btn primary",disabled:!g||ae,onClick:v,children:[A?e.jsx(pt,{}):null,a(A?"addedToChat":"addToChat")]})]})]})})]})})}function Vt(t){const s=t.toLowerCase();return s.endsWith(".md")||s.endsWith(".markdown")}function Ol(t){return t>=1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:t>=1024?`${Math.round(t/1024)} KB`:`${t} B`}const ri="pi-web-sounds",nt={enabled:!0,question:!0,done:!0,start:!1,error:!0,volume:100};function li(){try{const t=localStorage.getItem(ri);if(!t)return{...nt};const s=JSON.parse(t),n={...nt,...s};for(const r of["enabled","question","done","start","error"])typeof n[r]!="boolean"&&(n[r]=nt[r]);return typeof n.volume!="number"||!Number.isFinite(n.volume)?n.volume=nt.volume:n.volume=Math.round(Math.max(0,Math.min(100,n.volume))/5)*5,n}catch{return{...nt}}}function Kl(t){try{localStorage.setItem(ri,JSON.stringify(t))}catch{}}let it=null;function Wl(){try{if(!it){const t=window.AudioContext??window.webkitAudioContext;if(!t)return null;it=new t}return it.state==="suspended"&&it.resume(),it}catch{return null}}const Ul=[{type:"sine",freq:587.33,start:0,dur:.13,peak:.5},{type:"sine",freq:880,start:.11,dur:.24,peak:.5}],ql=[{type:"sine",freq:880,start:0,dur:.15,peak:.35},{type:"sine",freq:587.33,start:.15,dur:.32,peak:.35}],zl=[{type:"triangle",freq:660,start:0,dur:.08,peak:.22}],Vl=[{type:"square",freq:220,start:0,dur:.16,peak:.18},{type:"square",freq:174.61,start:.18,dur:.26,peak:.18}],Gl={question:Ul,done:ql,start:zl,error:Vl};function Ql(t,s,n){const r=t.createOscillator(),c=t.createGain();r.type=s.type,r.frequency.value=s.freq;const i=t.currentTime+s.start,a=Math.max(1e-4,s.peak*n);c.gain.setValueAtTime(1e-4,i),c.gain.exponentialRampToValueAtTime(a,i+.012),c.gain.exponentialRampToValueAtTime(1e-4,i+s.dur),r.connect(c),c.connect(t.destination),r.start(i),r.stop(i+s.dur+.05)}function at(t,s=li()){if(!s.enabled||!s[t])return;const n=Wl();if(!n)return;const r=Math.max(0,Math.min(1,s.volume/100));for(const c of Gl[t])Ql(n,c,r)}const as="pi-web-ui:theme",oi="dark",on="theme-stylesheet",cn="pi-web-ui:theme-change";function ci(){try{const t=localStorage.getItem(as);if(t&&t!==oi)return t}catch{}return null}function Yl(t){try{t?localStorage.setItem(as,t):localStorage.removeItem(as)}catch{}}function di(t){let s=document.getElementById(on);if(!t){s==null||s.remove(),window.dispatchEvent(new CustomEvent(cn));return}s||(s=document.createElement("link"),s.id=on,s.rel="stylesheet",document.head.appendChild(s)),s.href=Ve(`/themes/${encodeURIComponent(t)}.css`),s.onload=()=>window.dispatchEvent(new CustomEvent(cn))}async function Jl(){try{const t=await fetch(Mt(Ve("/api/themes")));if(!t.ok)return[];const s=await t.json();return Array.isArray(s.themes)?s.themes:[]}catch{return[]}}function Xl(){const[t,s]=l.useState([]),[n,r]=l.useState(()=>ci());return l.useEffect(()=>{let i=!1;return Jl().then(a=>{i||s(a)}),()=>{i=!0}},[]),l.useEffect(()=>{di(n),Yl(n)},[n]),{themes:t,theme:n,switchTheme:i=>r(i===oi?null:i)}}function ro(){const t=getComputedStyle(document.documentElement),s=(n,r)=>t.getPropertyValue(n).trim()||r;return{background:s("--term-bg","#0b0d12"),foreground:s("--term-fg","#e6e8ef"),cursor:s("--term-cursor","#8b5cf6"),cursorAccent:s("--term-cursor-accent","#0b0d12"),selectionBackground:s("--term-selection","rgba(139, 92, 246, 0.35)"),black:s("--term-black","#1a1d26"),red:s("--term-red","#f87171"),green:s("--term-green","#34d399"),yellow:s("--term-yellow","#fbbf24"),blue:s("--term-blue","#60a5fa"),magenta:s("--term-magenta","#c084fc"),cyan:s("--term-cyan","#22d3ee"),white:s("--term-white","#e6e8ef"),brightBlack:s("--term-bright-black","#6b7284"),brightRed:s("--term-bright-red","#f87171"),brightGreen:s("--term-bright-green","#34d399"),brightYellow:s("--term-bright-yellow","#fbbf24"),brightBlue:s("--term-bright-blue","#60a5fa"),brightMagenta:s("--term-bright-magenta","#c084fc"),brightCyan:s("--term-bright-cyan","#22d3ee"),brightWhite:s("--term-bright-white","#ffffff")}}const Zl=l.lazy(()=>gn(()=>import("./TerminalPanel-CoPFNu1d.js"),__vite__mapDeps([2,1,3,4,5])).then(t=>({default:t.TerminalPanel})));function eo({notice:t,onDismiss:s}){const n=xe(),{locale:r}=mt(),c=r==="en"&&t.textEn?t.textEn:t.text,[i,a]=l.useState(!1);l.useEffect(()=>{if(i)return;const u=setTimeout(()=>s(t.id),t.level==="error"?12e3:7e3);return()=>clearTimeout(u)},[i,t.id,t.level,s]);const o=t.level==="error"?ta:t.level==="warning"?ea:Wi;return e.jsxs("div",{className:`notice notice-${t.level}${i?" paused":""}`,role:"status",onMouseEnter:()=>a(!0),onMouseLeave:()=>a(!1),children:[e.jsx(o,{className:"notice-icon"}),e.jsx("span",{className:"notice-text",children:c}),e.jsx("button",{type:"button",className:"notice-close",title:n("close"),onClick:()=>s(t.id),children:e.jsx(Pe,{})})]})}const to=[],ui=180,pi=520,mi=240,hi=t=>`pi-web-ui:${t}-panel-width`;function dn(t){const s=Number(localStorage.getItem(hi(t)));return Number.isFinite(s)&&s>=ui&&s<=pi?s:mi}const rs=t=>`pi-web-ui:${t}-panel-collapsed`;function un(t){return localStorage.getItem(rs(t))==="1"}function pn({side:t,width:s,onResize:n}){const r=xe(),c=l.useCallback(i=>{i.preventDefault();const a=i.clientX,o=s;let u=o;const m=g=>{const x=t==="left"?g.clientX-a:a-g.clientX;u=Math.min(pi,Math.max(ui,Math.round(o+x))),n(u)},y=()=>{window.removeEventListener("pointermove",m),window.removeEventListener("pointerup",y),document.body.classList.remove("panel-resizing"),localStorage.setItem(hi(t),String(u))};window.addEventListener("pointermove",m),window.addEventListener("pointerup",y),document.body.classList.add("panel-resizing")},[t,s,n]);return e.jsx("div",{className:`resize-handle resize-${t}`,title:r("dragToResize"),onPointerDown:c,onDoubleClick:()=>n(mi)})}function mn({side:t,onClick:s}){const n=xe();return e.jsx("button",{type:"button",className:`panel-rail panel-rail-${t}`,title:n("expandPanel"),onClick:s,children:t==="left"?e.jsx(wn,{}):e.jsx(Nn,{})})}function so(){var Oe,ms,hs,gs,fs,xs,ys,vs,bs,ks,js,ws,Ns,Cs;const t=xe(),{chat:s,send:n,dismissNotice:r,pushNotice:c,terminal:i}=Aa(),[a,o]=l.useState([]),[u,m]=l.useState(null),[y,g]=l.useState(!1),[x,b]=l.useState("chat"),E=l.useMemo(()=>s.plugins.filter(F=>{var te,ce;return!((ce=(te=s.settings)==null?void 0:te.disabledPlugins)!=null&&ce.includes(F.id))}),[s.plugins,(Oe=s.settings)==null?void 0:Oe.disabledPlugins]),[A,H]=l.useState([]);l.useEffect(()=>wa(H),[]),l.useEffect(()=>{Na(E,s.pluginsEpoch)},[E,s.pluginsEpoch]);const[S,j]=l.useState(()=>dn("left")),[J,Q]=l.useState(()=>dn("right")),X=l.useCallback(F=>j(F),[]),U=l.useCallback(F=>Q(F),[]),[K,q]=l.useState(()=>un("left")),[Y,T]=l.useState(()=>un("right")),P=l.useCallback(()=>{q(F=>(localStorage.setItem(rs("left"),F?"0":"1"),!F))},[]),k=l.useCallback(()=>{T(F=>(localStorage.setItem(rs("right"),F?"0":"1"),!F))},[]),[B,Z]=l.useState(null),[G,M]=l.useState(()=>window.matchMedia("(max-width: 768px)").matches);l.useEffect(()=>{const F=window.matchMedia("(max-width: 768px)"),te=ce=>M(ce.matches);return F.addEventListener("change",te),()=>F.removeEventListener("change",te)},[]);const[I,C]=l.useState(!1),[$,z]=l.useState(!1),[ne,v]=l.useState(!1),[D,d]=l.useState(!1),[w,h]=l.useState(!1),[L,ee]=l.useState(null);l.useEffect(()=>{if(!L)return;const F=setTimeout(()=>ee(null),15e3);return()=>clearTimeout(F)},[L]),l.useEffect(()=>{const F=te=>{var qe,Ss;const ce=te.detail,Ne=(ce==null?void 0:ce.title)||t("pluginCommandFallback"),Ce=ce==null?void 0:ce.command;if(!Ce||!s.ready)return;const Fe={name:Ne,command:Ce,cwd:"${pwd}"},Se=s.terminals.find(It=>It.title===Ne);if(Se)i.restart(Se.id),n({type:"run_command",terminalId:Se.id,conversationId:Se.conversationId,command:Fe,cols:80,rows:24});else{const It=Ue();i.create({id:It,conversationId:s.activeConversationId||((qe=s.state)==null?void 0:qe.conversationId)||"",title:Ne,cwd:((Ss=s.state)==null?void 0:Ss.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:Fe})}b("terminal")};return window.addEventListener("pi-web-ui:plugin-run-command",F),()=>window.removeEventListener("pi-web-ui:plugin-run-command",F)},[s,i,n]),l.useEffect(()=>{const F=te=>{!(te.ctrlKey||te.metaKey)||te.key.toLowerCase()!=="k"||(te.preventDefault(),h(ce=>!ce))};return window.addEventListener("keydown",F),()=>window.removeEventListener("keydown",F)},[]);const[W,ae]=l.useState(li),{themes:ye,theme:be,switchTheme:ge}=Xl(),ke=l.useRef(null),Ee=l.useRef(null),re=l.useRef(0),f=l.useRef(!1),O=l.useRef(s.terminals);l.useEffect(()=>{Kl(W)},[W]),l.useEffect(()=>{var te;const F=O.current;O.current=s.terminals;for(const ce of s.terminals){const Ne=((te=ce.command)==null?void 0:te.command)??"",Ce=F.find(Fe=>Fe.id===ce.id);!(Ce!=null&&Ce.running)||ce.running||(Ne.startsWith("pi remove ")?n({type:"extensions_reload"}):Ne.startsWith("pi-web-ui install ")||Ne.startsWith("pi-web-ui uninstall ")?n({type:"plugins_reload"}):Ne.startsWith("npm i -g ")&&(n({type:"extensions_reload"}),n({type:"plugins_reload"}),n({type:"check_updates_all",force:!0})))}},[s.terminals,n]),l.useEffect(()=>{var ce;const F=((ce=s.state)==null?void 0:ce.isStreaming)??!1,te=ke.current;ke.current=F,te!==null&&(!te&&F?at("start",W):te&&!F&&(at("done",W),_t(t("notifyDoneTitle"),t("notifyDoneBody"))))},[(ms=s.state)==null?void 0:ms.isStreaming,W]),l.useEffect(()=>{var te;const F=((te=s.dialog)==null?void 0:te.id)??null;F!==null&&F!==Ee.current&&(at("question",W),_t(t("notifyQuestionTitle"),t("notifyQuestionBody"))),Ee.current=F},[s.dialog,W]),l.useEffect(()=>{const F=[...s.notices].reverse().find(te=>te.level==="error");F&&F.id!==re.current&&(re.current=F.id,at("error",W),_t(t("notifyErrorTitle"),t("notifyErrorBody")))},[s.notices,W]);const de=(F,te,ce,Ne=!1,Ce)=>{const Fe=`${F}|${ce}|${Ce?`${Ce.start}-${Ce.end}`:""}`;o(Se=>Se.some(qe=>`${qe.path}|${qe.mode}|${qe.lines?`${qe.lines.start}-${qe.lines.end}`:""}`===Fe)?Se:[...Se,{path:F,name:te,mode:ce,isDir:Ne,...Ce?{lines:Ce}:{}}])},ue=F=>o(te=>te.filter(ce=>ce.key?ce.key!==F:ce.path!==F)),me=l.useCallback(F=>(!F.type.startsWith("list_")&&!F.type.startsWith("get_")&&Z(null),n(F)),[n]),pe=l.useRef(0),ve=l.useRef(0),Me=F=>{var Ne;const te=Date.now();(Ne=s.state)!=null&&Ne.model&&!s.state.model.vision&&te-ve.current>1e4&&(ve.current=te,c("warning",t("imageNotSupported")));const ce=`paste-${++pe.current}`;o(Ce=>[...Ce,{path:"",key:ce,name:F.name,mode:"inline",imageData:F.data,mimeType:F.mimeType}])},he=async F=>{for(const te of F){const ce=await On(te);if(!ce){c("error",t("imageLoadFailed",{name:te.name}));continue}Me(ce)}},_e=20*1024*1024,Le=l.useRef(0),Be=async F=>{if(F.size>_e){c("warning",t("fileTooLarge",{name:F.name,size:_e/1024/1024}));return}let te;try{te=(await new Promise((Ce,Fe)=>{const Se=new FileReader;Se.onload=()=>Ce(Se.result),Se.onerror=()=>Fe(Se.error??new Error("read failed")),Se.readAsDataURL(F)})).replace(/^data:[^;]*;base64,/,"")}catch{c("error",t("fileLoadFailed",{name:F.name}));return}const ce=`upload-${++Le.current}`;o(Ne=>[...Ne,{path:"",key:ce,name:F.name,mode:"inline",fileData:te,size:F.size,mimeType:F.type||void 0}])},De=async F=>{for(const te of F)We(te.type)?await he([te]):await Be(te)},R=l.useCallback((F,te,ce)=>{n({type:"edit_message",messageId:F,text:te,attachments:ce})},[n]),fe=l.useCallback((F,te)=>{n({type:"queue_remove",kind:F,text:te})},[n]),oe=l.useCallback(()=>z(!0),[]),p=l.useCallback(()=>o([]),[]),V=l.useCallback(ue,[]),N=l.useCallback(he,[he]),_=l.useCallback(De,[De]),ie=(hs=s.state)==null?void 0:hs.model,le=(gs=s.state)==null?void 0:gs.thinkingLevel,je=(fs=s.state)==null?void 0:fs.availableThinkingLevels,we=l.useMemo(()=>ie?{model:ie,thinkingLevel:le??"off",availableThinkingLevels:je??[]}:null,[ie,le,je]),Te=l.useCallback(()=>{var F,te;return!s.ready||s.terminals.length!==0?!1:(i.create({id:Ue(),conversationId:s.activeConversationId||((F=s.state)==null?void 0:F.conversationId)||"",title:t("terminalTitle",{n:1}),cwd:((te=s.state)==null?void 0:te.cwd)??"",cols:80,rows:24,running:!0,exitCode:null}),!0)},[s.ready,(xs=s.state)==null?void 0:xs.cwd,s.terminals.length,t,i]);return l.useEffect(()=>{if(f.current){if(x!=="terminal"||s.terminals.length!==0){f.current=!1;return}Te()&&(f.current=!1)}},[s.terminals.length,Te,x]),e.jsxs("div",{className:"app",onDragOver:F=>{var te;Array.from(((te=F.dataTransfer)==null?void 0:te.types)??[]).includes("Files")&&(F.preventDefault(),g(!0))},onDragLeave:F=>{F.currentTarget.contains(F.relatedTarget)||g(!1)},onDrop:F=>{var Ce,Fe;if(g(!1),!Array.from(((Ce=F.dataTransfer)==null?void 0:Ce.types)??[]).includes("Files"))return;F.preventDefault();const te=Array.from(((Fe=F.dataTransfer)==null?void 0:Fe.files)??[]);if(te.length===0){c("warning",t("foldersNotSupported"));return}const ce=te.filter(Se=>We(Se.type)),Ne=te.filter(Se=>!We(Se.type));ce.length>0&&he(ce),Ne.length>0&&De(Ne)},children:[y&&e.jsx("div",{className:"app-drop-overlay","aria-hidden":!0,children:e.jsxs("span",{children:["📎 ",t("dropHereToAttach")]})}),e.jsx(da,{chat:s,send:n,terminal:i,view:x,plugins:E,onViewChange:F=>{f.current=F==="terminal"&&s.terminals.length===0,f.current&&Te()&&(f.current=!1),b(F),Z(null)},onOpenPanel:Z,onOpenSettings:()=>v(!0),onOpenBgTasks:()=>d(!0),onOpenGlobalSearch:()=>h(!0),sound:W,onSoundChange:ae,onSoundPreview:F=>at(F,W),themes:ye,theme:be,onThemeChange:ge}),s.protocolMismatch&&e.jsxs("div",{className:"protocol-banner",children:["⚠ ",t("protocolMismatch")]}),e.jsx("div",{className:"notices",children:s.notices.map(F=>e.jsx(eo,{notice:F,onDismiss:r},F.id))}),e.jsx(Yr,{send:n,children:e.jsxs("div",{className:"layout",style:{"--left-w":`${S}px`,"--right-w":`${J}px`},children:[B&&e.jsx("div",{className:"drawer-backdrop",onClick:()=>Z(null)}),e.jsxs("div",{className:`view-pane ${x==="chat"?"":"hidden"}`,children:[!G&&K&&e.jsx(mn,{side:"left",onClick:P}),e.jsx("div",{className:`panel-drawer drawer-left ${B==="left"?"open":""}${G?"":K?" hidden":""}`,children:e.jsx(fa,{collapsible:!G,onToggleCollapse:P,send:me,active:!G||B==="left",ready:s.ready,status:s.status,cwd:((ys=s.state)==null?void 0:ys.cwd)??"",sessionFile:((vs=s.state)==null?void 0:vs.sessionFile)??null,conversations:s.conversations,sessions:s.sessions,projects:s.projects,activeConversationId:s.activeConversationId})}),!G&&e.jsx(pn,{side:"left",width:S,onResize:X}),e.jsxs("main",{className:"main",children:[s.state?e.jsx(sl,{state:s.state,liveOutputs:s.liveOutputs,toolStatuses:s.toolStatuses,onEdit:R,onKillBash:()=>n({type:"abort_bash"}),onRemoveQueued:fe,thinkingWrap:((bs=s.settings)==null?void 0:bs.thinkingWrap)??!0,toolsWrap:((ks=s.settings)==null?void 0:ks.toolsWrap)??!0,jumpTarget:L,onJumpDone:()=>ee(null)},s.state.conversationId??"boot"):e.jsx("div",{className:"boot-wait",children:s.ready?t("loadingSession"):t("connectingServer")}),e.jsx(xl,{send:n,goal:s.goal,models:s.models,modelsLoading:s.modelsLoading,activeConversationId:s.activeConversationId,engine:s.engine}),s.dialog&&e.jsx(Nl,{dialog:s.dialog,send:n}),s.question&&e.jsx(Cl,{question:s.question,send:n}),e.jsx(fl,{send:n,ready:s.ready,streaming:((js=s.state)==null?void 0:js.isStreaming)??!1,messages:((ws=s.state)==null?void 0:ws.messages)??to,slashCommands:s.slashCommands,modelState:we,models:s.models,modelsLoading:s.modelsLoading,providerKeys:s.providerKeys,attachments:a,onRemoveAttachment:V,onAddImageFiles:N,onAddLocalFiles:_,onNotice:c,onManageModels:oe,onSent:p})]}),!G&&e.jsx(pn,{side:"right",width:J,onResize:U}),e.jsx("div",{className:`panel-drawer drawer-right ${B==="right"?"open":""}${G?"":Y?" hidden":""}`,children:e.jsx(Ua,{collapsible:!G,onToggleCollapse:k,send:me,files:s.files,fileChanged:s.fileChanged,widgets:s.widgets,cwd:((Ns=s.state)==null?void 0:Ns.cwd)??"",onAttach:(F,te,ce,Ne)=>{Z(null),de(F,te,ce,Ne)},onPreview:(F,te)=>{Z(null),m({path:F,name:te})},onNotice:(F,te)=>c(F,te)})}),!G&&Y&&e.jsx(mn,{side:"right",onClick:k})]}),e.jsx("div",{className:`view-pane ${x==="terminal"?"":"hidden"}`,children:e.jsx(l.Suspense,{fallback:null,children:e.jsx(Zl,{chat:s,send:n,terminal:i})})}),e.jsx("div",{className:`view-pane ${x==="git"?"":"hidden"}`,children:e.jsx(Tl,{chat:s,send:n,terminal:i,active:x==="git",onSwitchToTerminal:()=>b("terminal")})}),A.map(F=>{const te=`plugin:${F.info.id}`;return e.jsx("div",{className:`view-pane ${x===te?"":"hidden"}`,children:e.jsx(El,{entry:F,send:n})},F.info.id)})]})}),e.jsx(jl,{chat:s,send:n}),u&&e.jsx(Hl,{file:u,content:s.fileContent,send:n,onAddLines:(F,te,ce,Ne)=>de(F,te,"lines",!1,{start:ce,end:Ne}),onAttach:(F,te,ce)=>de(F,te,ce),onClose:()=>m(null)}),s.ready&&s.state&&s.state.piConfigured===!1&&!I&&!$&&e.jsx(Pl,{send:n,piConfigured:s.state.piConfigured,piAgentInstalled:s.state.piAgentInstalled,providers:s.providers,installResult:s.installResult,onClose:()=>C(!0)}),$&&e.jsx(Il,{send:n,providers:s.modelsConfig,providerStatus:s.providers,providerKeys:s.providerKeys,fetchModelsResult:s.fetchModelsResult,cloneProviderResult:s.cloneProviderResult,onClose:()=>z(!1)}),ne&&e.jsx(Al,{chat:s,send:n,terminal:i,onSwitchToTerminal:()=>b("terminal"),onClose:()=>v(!1)}),D&&e.jsx(Bl,{servers:s.bgServers,send:n,onClose:()=>d(!1)}),e.jsx($l,{open:w,send:n,projects:s.projects,cwd:((Cs=s.state)==null?void 0:Cs.cwd)??"",fileSearch:s.fileSearch,sessionSearch:s.sessionSearch,onClose:()=>h(!1),onSwitchSession:(F,te)=>{n({type:"switch_session",path:F});const ce=te&&te[0];ee(ce?{path:F,role:ce.role,timestamp:ce.timestamp}:null)},onSwitchProject:F=>{n({type:"set_cwd",path:F})},onPreviewFile:(F,te)=>{m({path:F,name:te})}})]})}xa();di(ci());vi.createRoot(document.getElementById("root")).render(e.jsx(l.StrictMode,{children:e.jsx(ia,{children:e.jsx(so,{})})}));"serviceWorker"in navigator&&window.addEventListener("load",()=>{const t=Pn();navigator.serviceWorker.register(`${t}sw.js`,{scope:t}).catch(s=>{console.warn("Service worker registration failed:",s)})});export{rt as F,cn as T,gn as _,xe as a,ro as b,He as c,ao as d,St as e,Ae as f,$i as g,tt as h,Pe as i,Ue as r,mt as u};
|