pi-web-ui 0.46.0 → 0.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,19 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/TerminalPanel-ClyNBJJt.js","assets/markdown-DRBrS2Nf.js","assets/xterm-D1D2FVe3.js","assets/react-C9ovnpIm.js","assets/TerminalPanel-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
2
+ import{R as Be,a as r,j as e,M as Cs,b as rn,c as ln}from"./markdown-DRBrS2Nf.js";import{r as Ss}from"./react-C9ovnpIm.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"]'))l(c);new MutationObserver(c=>{for(const i of c)if(i.type==="childList")for(const n of i.addedNodes)n.tagName==="LINK"&&n.rel==="modulepreload"&&l(n)}).observe(document,{childList:!0,subtree:!0});function a(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 l(c){if(c.ep)return;c.ep=!0;const i=a(c);fetch(c.href,i)}})();var Xe={},Kt;function on(){if(Kt)return Xe;Kt=1;var t=Ss();return Xe.createRoot=t.createRoot,Xe.hydrateRoot=t.hydrateRoot,Xe}var cn=on();const dn="modulepreload",un=function(t){return"/"+t},Vt={},Ts=function(s,a,l){let c=Promise.resolve();if(a&&a.length>0){let n=function(p){return Promise.all(p.map(f=>Promise.resolve(f).then(h=>({status:"fulfilled",value:h}),h=>({status:"rejected",reason:h}))))};document.getElementsByTagName("link");const o=document.querySelector("meta[property=csp-nonce]"),d=(o==null?void 0:o.nonce)||(o==null?void 0:o.getAttribute("nonce"));c=n(a.map(p=>{if(p=un(p),p in Vt)return;Vt[p]=!0;const f=p.endsWith(".css"),h=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${h}`))return;const v=document.createElement("link");if(v.rel=f?"stylesheet":dn,f||(v.as="script"),v.crossOrigin="",v.href=p,d&&v.setAttribute("nonce",d),document.head.appendChild(v),f)return new Promise((w,M)=>{v.addEventListener("load",w),v.addEventListener("error",()=>M(new Error(`Unable to preload CSS for ${p}`)))})}))}function i(n){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=n,window.dispatchEvent(o),!o.defaultPrevented)throw n}return c.then(n=>{for(const o of n||[])o.status==="rejected"&&i(o.reason);return s().catch(i)})};var Es={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Gt=Be.createContext&&Be.createContext(Es),mn=["attr","size","title"];function pn(t,s){if(t==null)return{};var a,l,c=hn(t,s);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(l=0;l<i.length;l++)a=i[l],s.indexOf(a)===-1&&{}.propertyIsEnumerable.call(t,a)&&(c[a]=t[a])}return c}function hn(t,s){if(t==null)return{};var a={};for(var l in t)if({}.hasOwnProperty.call(t,l)){if(s.indexOf(l)!==-1)continue;a[l]=t[l]}return a}function nt(){return nt=Object.assign?Object.assign.bind():function(t){for(var s=1;s<arguments.length;s++){var a=arguments[s];for(var l in a)({}).hasOwnProperty.call(a,l)&&(t[l]=a[l])}return t},nt.apply(null,arguments)}function Jt(t,s){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(t);s&&(l=l.filter(function(c){return Object.getOwnPropertyDescriptor(t,c).enumerable})),a.push.apply(a,l)}return a}function it(t){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?Jt(Object(a),!0).forEach(function(l){gn(t,l,a[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):Jt(Object(a)).forEach(function(l){Object.defineProperty(t,l,Object.getOwnPropertyDescriptor(a,l))})}return t}function gn(t,s,a){return(s=fn(s))in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a,t}function fn(t){var s=xn(t,"string");return typeof s=="symbol"?s:s+""}function xn(t,s){if(typeof t!="object"||!t)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var l=a.call(t,s);if(typeof l!="object")return l;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(t)}function Ms(t){return t&&t.map((s,a)=>Be.createElement(s.tag,it({key:a},s.attr),Ms(s.child)))}function z(t){return s=>Be.createElement(vn,nt({attr:it({},t.attr)},s),Ms(t.child))}function vn(t){var s=a=>{var l=t.attr,c=t.size,i=t.title,n=pn(t,mn),o=c||a.size||"1em",d;return a.className&&(d=a.className),t.className&&(d=(d?d+" ":"")+t.className),Be.createElement("svg",nt({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,l,n,{className:d,style:it(it({color:t.color||a.color},a.style),t.style),height:o,width:o,xmlns:"http://www.w3.org/2000/svg"}),i&&Be.createElement("title",null,i),t.children)};return Gt!==void 0?Be.createElement(Gt.Consumer,null,a=>s(a)):s(Es)}function yn(t){return z({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 jn(t){return z({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 et(t){return z({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 we(t){return z({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 Ps(t){return z({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 bn(t){return z({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 De(t){return z({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 Ue(t){return z({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 Qt(t){return z({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 kn(t){return z({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 at(t){return z({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 wn(t){return z({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 rt(t){return z({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 Nn(t){return z({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 lt(t){return z({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 Cn(t){return z({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 ct(t){return z({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 qe(t){return z({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 Va(t){return z({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 Sn(t){return z({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 Yt(t){return z({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 Tn(t){return z({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 En(t){return z({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 ze(t){return z({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 Mn(t){return z({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 Pn(t){return z({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 Rn(t){return z({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 In(t){return z({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 bt(t){return z({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 ot(t){return z({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 Ln(t){return z({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M21 2l-2 2m-7.61 7.61a5.5 5.5 0 1 1-7.778 7.778 5.5 5.5 0 0 1 7.777-7.777zm0 0L15.5 7.5m0 0l3 3L22 7l-3-3m-3.5 3.5L19 4"},child:[]}]})(t)}function Bn(t){return z({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 Dn(t){return z({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 $n(t){return z({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 Xt(t){return z({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 tt(t){return z({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 Ke(t){return z({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 Rs(t){return z({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 Is(t){return z({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 kt(t){return z({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 wt(t){return z({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 Zt(t){return z({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 Mt(t){return z({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 Qe(t){return z({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 _n(t){return z({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 Pt(t){return z({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 Fn(t){return z({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 dt(t){return z({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 ut(t){return z({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 _e(t){return z({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 mt(t){return z({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 An(t){return z({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 es(t){return z({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 Wn(t){return z({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 Ls(t){return z({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 Bs(t){return z({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 On(t){return z({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 Hn(t){return z({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 $e(){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 a=0;a<16;a++)t[a]=Math.floor(Math.random()*256);t[6]=t[6]&15|64,t[8]=t[8]&63|128;const s=[...t].map(a=>a.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 Re({trigger:t,open:s,onOpenChange:a,children:l,align:c="right",fit:i=!1,direction:n="down",menuClassName:o}){const d=r.useRef(null);return r.useEffect(()=>{if(!s)return;const p=h=>{d.current&&!d.current.contains(h.target)&&a(!1)},f=h=>{h.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",p),document.addEventListener("keydown",f),()=>{document.removeEventListener("mousedown",p),document.removeEventListener("keydown",f)}},[s,a]),e.jsxs("div",{className:`dropdown ${c} ${i?"fit":""} ${n==="up"?"dd-up":""}`,ref:d,children:[e.jsxs("button",{type:"button",className:"chip",onClick:()=>a(!s),"aria-expanded":s,children:[t,e.jsx(_e,{className:`dd-caret ${s?"up":""}`})]}),s&&e.jsx("div",{className:`dd-menu ${o??""}`,children:l})]})}function ke({active:t,disabled:s=!1,title:a,onClick:l,children:c}){return e.jsx("button",{type:"button",className:`dd-item ${t?"active":""}`,disabled:s,title:a,onClick:l,children:c})}const Ds="pi-web-ui:lang",Un={cancel:"取消",ok:"确定",save:"保存",close:"关闭",widgetExpand:"点击放大查看完整输出",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:"插件状态",working:"工作中",queued:"排队",enterPath:"输入路径,Enter 切换",cwdTip:"工作目录:{path}(点击切换)",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:"排队",sendTip:"发送(Enter)",slashCommands:"命令",slashMenuHint:"↑↓ 选择 · Enter/Tab 补全",slashHelpTitle:"pi 命令",slashHelpHint:"输入 / 随时打开命令列表",slashLoading:"命令列表加载中…(连接服务器后可用)",slashBuiltin:"内置",slashExtension:"扩展",slashPrompt:"模板",slashSkill:"技能",slashPlugin:"插件",slashCopied:"已复制上一条助手回复",slashCopyFailed:"复制失败,请手动复制",slashCopyEmpty:"还没有可复制的助手回复",recentProjects:"最近项目",runningConversations:"运行的对话",historySessions:"历史对话",openHistory:"历史对话",openFiles:"文件列表",streaming:"进行中…",noHistory:"还没有历史对话",current:"当前",messageCount:"{n} 条消息",tuiTip:"pi 终端(TUI)中的对话",deleteProject:"从最近项目移出",deleteProjectConfirm:"确认移出",deleteSession:"删除该对话记录(不可恢复)",deleteSessionConfirm:"确认删除",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)。",rootDir:"根目录",noFiles:"暂无文件",filesTruncated:"目录过大,列表已截断,仅显示前 2000 项",linkFolderTip:"链接文件夹路径到对话",attachInlineTip:"附加内容到对话",referenceTip:"仅引用路径(AI 按需读取)",previewFile:"预览",downloadFile:"下载文件",downloadFailed:"下载失败:{error}",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:"插件请求",noOptions:"(无选项)",inputPlaceholder:"输入内容",soundHeader:"声音提示",enableSound:"启用声音",preview:"试听",volume:"音量","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":"上下文已压缩",welcomeTitle:"pi 编码智能体",welcomeSub:"检查、编辑、运行 —— 随时待命",directory:"目录",clickToFill:"点击填入输入框",waitingResponse:"正在等待模型响应…",backToBottom:"回到底部",questionNavTitle:"问题列表",searchPlaceholder:"在对话中搜索…",searchNoResults:"无结果",searchModels:"搜索模型…",noModelMatches:"无匹配模型",searchGlobal:"搜索",searchGlobalTip:"全局搜索:对话 / 项目 / 文件(Ctrl+K)",gsPlaceholder:"搜索项目、历史对话、工作区文件…",gsHint:"输入关键词:同时搜索历史对话、最近项目与当前项目的文件名",gsSessions:"对话",gsProjects:"项目",gsFiles:"文件",gsNoResults:"无匹配结果",gsSearching:"正在搜索文件…",gsTruncated:"匹配过多,仅显示部分结果",gsCurrentProject:"当前",gsOpenPreview:"打开文件预览",gsNavigate:"选择",gsOpen:"打开",gsCloseHint:"关闭",bgTaskCommand:"命令行",searchPrev:"上一个(Shift+Enter)",searchNext:"下一个(Enter)",searchClose:"关闭(Esc)",questionNavTip:"本对话的全部问题,悬浮展开,点击跳转","ex.understand":"了解这个项目","ex.understand.prompt":"介绍一下这个项目:整体结构、主要模块和如何运行?","ex.debug":"排查一个问题","ex.debug.prompt":"帮我排查一个 bug,请先说明问题现象,我会补充细节。","ex.test":"编写测试","ex.test.prompt":"为项目的核心模块编写单元测试。","ex.review":"代码审查","ex.review.prompt":"审查最近改动的代码,指出潜在问题和改进建议。",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})",closeTerminal:"关闭终端",rerun:"重新读取 .pi/commands.json",terminalTitle:"终端 {n}",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 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}",scmTooManyFailures:"Git 查询连续失败,请点击刷新重试",scmRunsInTerminal:"提交 / 切换分支 / 推送 / 拉取在终端中执行",scmViewTerminal:"去终端",editProvider:"编辑服务商",builtinProviders:"内置服务商",hintKeyOnly:"只需填入 API 密钥",configuredBadge:"✓ 已配置",keyReady:"密钥已就绪",replaceKey:"更换密钥",replaceKeyTitle:"替换已保存的密钥",clearKey:"清空",clearKeyTitle:"清除该服务商保存在 auth.json 的密钥,回到未配置状态(环境变量来源的无法在此清除)",clearKeyConfirm:"清空 {id} 已保存的密钥?其模型将从列表消失,直到重新配置。",cloneProvider:"复制为自定义",cloning:"复制中",cloneProviderTitle:"复制该内置供应商(baseUrl + 模型列表)为自定义供应商,填入另一个 API 密钥即可双 key 并存",pasteKey:"粘贴 API 密钥…",savingKey:"保存中",saveKey:"保存密钥",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:"系统提示词",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:"转写提示词",settingsTerminalTools:"终端工具",terminalToolsEnabled:"启用持久终端工具",settingsTerminalToolsDesc:"让 AI 在交互式程序(REPL/vim)、长驻服务、需要持续观察输出或你要求在可见终端操作时,使用内置终端;普通命令仍走一次性 bash 工具",terminalToolsOffHint:"已关闭:AI 无法使用 terminal_* 工具,也不会收到相关使用引导",settingsMessageDisplay:"消息显示",thinkingWrap:"完整显示思考",thinkingWrapDesc:"开启:思考内容始终完整展开并自动换行(流式推理过程也实时可见);关闭:折叠成一行摘要,流式中一行实时显示最新文本",toolsWrap:"完整显示工具",toolsWrapDesc:"开启:工具调用始终完整展开显示参数和输出;关闭:默认折叠,点击展开",terminalBashTakeover:"终端接管 bash",terminalBashTakeoverDesc:"bash 命令改在持久可见终端里执行:完整输出自动返回、shell 状态跨调用保留(cd/venv/ssh);命令静默超时自动转后台并在结束后主动通知 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/)",uiPluginNoSource:"手工安装,无来源信息,无法在线更新",uiPluginPerms:"能力声明",pluginSettingsSave:"保存插件设置",pluginSettingsSaving:"保存中…",pluginSettingsReset:"恢复默认",settingsPresets:"预设",settingsEnabled:"已启用",settingsDisabled:"已禁用",presetNamePlaceholder:"预设名称…",saveAsPreset:"保存为预设",applyPreset:"应用",deletePreset:"删除预设",noSkills:"暂无技能",noExtensions:"暂无插件",noPresets:"暂无预设(先调整上面的设置,再保存为预设组合)",loadingSession:"正在加载会话…",connectingServer:"正在连接 pi-web-ui 服务器…"},qn={cancel:"Cancel",ok:"OK",save:"Save",close:"Close",widgetExpand:"Click to view full output",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",working:"Working",queued:"queued",enterPath:"Type a path, Enter to switch",cwdTip:"Working directory: {path} (click to switch)",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",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",recentProjects:"Recent projects",runningConversations:"Running chats",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",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).",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}",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",noOptions:"(no options)",inputPlaceholder:"Enter content",soundHeader:"Sound notifications",enableSound:"Enable sound",preview:"Preview",volume:"Volume","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",welcomeTitle:"pi coding agent",welcomeSub:"Inspect, edit, run — always ready",directory:"Directory",clickToFill:"Click to fill input",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",searchGlobal:"Search",searchGlobalTip:"Global search: sessions / projects / files (Ctrl+K)",gsPlaceholder:"Search projects, past conversations, workspace files…",gsHint:"Type to search session history, recent projects and file names in the current workspace at once",gsSessions:"Conversations",gsProjects:"Projects",gsFiles:"Files",gsNoResults:"No matches",gsSearching:"Searching files…",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","ex.understand":"Understand this project","ex.understand.prompt":"Introduce this project: overall structure, main modules, and how to run it?","ex.debug":"Debug an issue","ex.debug.prompt":"Help me debug a bug — describe the symptom first, and I'll add details.","ex.test":"Write tests","ex.test.prompt":"Write unit tests for the core modules.","ex.review":"Code review","ex.review.prompt":"Review the recently changed code and point out potential issues and improvements.",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})",closeTerminal:"Close terminal",rerun:"Reload .pi/commands.json",terminalTitle:"Terminal {n}",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 add -A && git commit -m "…" in the terminal (commits all changes incl. untracked)',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 — not shown in diff, included on commit",scmQueryFailed:"Git query failed: {error}",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:"Clone as custom",cloning:"Cloning",cloneProviderTitle:"Copy this built-in provider (baseUrl + model catalog) into a custom provider — paste another API key to run both keys side by side",pasteKey:"Paste API key…",savingKey:"Saving",saveKey:"Save key",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",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",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:"Run bash commands inside the persistent visible terminal: full output returned automatically, shell state retained across calls (cd/venv/ssh); silent commands move to the background and notify the AI when they finish",terminalBashIdleMs:"Silence-to-background threshold (ms)",terminalBashIdleMsDesc:"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/)",uiPluginNoSource:"Installed manually — no recorded source, online update unavailable",uiPluginPerms:"Permissions",pluginSettingsSave:"Save plugin settings",pluginSettingsSaving:"Saving…",pluginSettingsReset:"Reset defaults",settingsPresets:"Presets",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…"},$s=r.createContext(null);function zn(){try{const t=localStorage.getItem(Ds);if(t==="zh"||t==="en")return t}catch{}return"zh"}function Kn({children:t}){const[s,a]=r.useState(zn),l=r.useCallback(n=>{a(n);try{localStorage.setItem(Ds,n)}catch{}},[]),c=r.useCallback((n,o)=>{let d=qn[n];if(s==="zh"&&(d=Un[n]),o)for(const[p,f]of Object.entries(o))d=d.replaceAll(`{${p}}`,String(f));return d},[s]);r.useEffect(()=>{document.documentElement.lang=s==="zh"?"zh-CN":"en"},[s]);const i=r.useMemo(()=>({locale:s,setLocale:l,t:c}),[s,l,c]);return e.jsx($s.Provider,{value:i,children:t})}function Rt(){const t=r.useContext($s);if(!t)throw new Error("useI18n must be used within LanguageProvider");return t}function he(){return Rt().t}const Vn=[{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 ts({settings:t,onChange:s,onPreview:a}){const l=he(),c=i=>s({...t,...i});return e.jsxs("div",{className:"sound-menu",children:[e.jsx("div",{className:"dd-header",children:l("soundHeader")}),e.jsxs("label",{className:"sound-row sound-master",children:[e.jsxs("span",{className:"sound-label",children:[e.jsx(Ps,{className:"sound-icon"}),e.jsx("span",{children:l("enableSound")})]}),e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:i=>c({enabled:i.target.checked})})]}),Vn.map(({kind:i,labelKey:n,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:l(n)}),e.jsx("span",{className:"sound-desc",children:l(o)})]}),e.jsxs("span",{className:"sound-right",children:[e.jsx("button",{type:"button",className:"sound-preview",title:l("preview"),disabled:!t.enabled,onClick:d=>{d.preventDefault(),a(i)},children:l("preview")}),e.jsx("input",{type:"checkbox",checked:t[i],disabled:!t.enabled,onChange:d=>c({[i]:d.target.checked})})]})]},i)),e.jsxs("div",{className:`sound-volume ${t.enabled?"":"disabled"}`,children:[e.jsx("span",{className:"sound-name",children:l("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,"%"]})]})]})}function Gn({chat:t,send:s,terminal:a,view:l,plugins:c,onViewChange:i,onOpenPanel:n,onOpenSettings:o,onOpenBgTasks:d,onOpenGlobalSearch:p,sound:f,onSoundChange:h,onSoundPreview:v,themes:w,theme:M,onThemeChange:L}){var me;const{locale:S,setLocale:B,t:j}=Rt(),[b,E]=r.useState(!1),[R,T]=r.useState(!1),[N,u]=r.useState(!1),[y,A]=r.useState(!1),[U,te]=r.useState(!1),ue=[{value:"zh",label:j("langZh")},{value:"en",label:j("langEn")}],ee=t.ready?j("connected"):t.status==="closed"?j("reconnecting"):j("connecting"),I=t.ready?"ok":"busy",q=()=>{var Y,J;if(!t.ready)return;const _=j("updateTabTitle"),O={name:_,command:"npm i -g pi-web-ui@latest",cwd:"${pwd}"},C=t.terminals.find(ie=>ie.title===_);C?(a.restart(C.id),s({type:"run_command",terminalId:C.id,conversationId:C.conversationId,command:O,cols:80,rows:24})):a.create({id:$e(),conversationId:t.activeConversationId||((Y=t.state)==null?void 0:Y.conversationId)||"",title:_,cwd:((J=t.state)==null?void 0:J.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:O}),A(!1),te(!1),i("terminal")},H=()=>{var _,O;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",((_=t.update)==null?void 0:_.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})}),((O=t.update)==null?void 0:O.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:q,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:()=>n("left"),children:e.jsx(Mn,{})}),e.jsx("span",{className:"brand-logo",children:"π"}),e.jsx("span",{className:"brand-name",children:"pi-web-ui"}),e.jsx("span",{className:`conn-dot ${I}`,title:ee}),e.jsx("span",{className:"conn-label",children:ee})]}),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":l==="chat",className:l==="chat"?"active":"",onClick:()=>i("chat"),children:[e.jsx(ze,{}),e.jsx("span",{children:j("chat")})]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":l==="terminal",className:l==="terminal"?"active":"",onClick:()=>i("terminal"),children:[e.jsx(Ue,{}),e.jsx("span",{children:j("terminal")})]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":l==="git",className:l==="git"?"active":"",onClick:()=>i("git"),children:[e.jsx(tt,{}),e.jsx("span",{children:j("scmTab")})]}),c.map(_=>{const O=_.error?`${_.name}: ${_.error}`:_.description?`${_.name} — ${_.description}`:_.name;return e.jsxs("button",{type:"button",role:"tab","aria-selected":l===`plugin:${_.id}`,className:`plugin-tab${l===`plugin:${_.id}`?" active":""}${_.error?" broken":""}`,title:O,onClick:()=>i(`plugin:${_.id}`),children:[_.icon?e.jsx("span",{"aria-hidden":!0,children:_.icon}):null,e.jsx("span",{children:_.name})]},_.id)})]}),e.jsxs("div",{className:"topbar-desktop",children:[e.jsxs("button",{type:"button",className:"chip",title:j("searchGlobalTip"),onClick:p,children:[e.jsx(lt,{}),e.jsx("span",{className:"chip-sub",children:j("searchGlobal")})]}),e.jsxs("button",{type:"button",className:"chip bg-task-chip","data-tip":j("bgTasksTip"),onClick:d,children:[e.jsx(ot,{}),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(rt,{}),e.jsx("span",{className:"chip-sub",children:j("settings")})]}),e.jsx(Re,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(Ps,{}),e.jsx("span",{className:"chip-sub",children:j("sound")})]}),open:b,onOpenChange:E,children:e.jsx(ts,{settings:f,onChange:h,onPreview:v})}),e.jsxs(Re,{trigger:e.jsxs(e.Fragment,{children:[e.jsx($n,{}),e.jsx("span",{className:"chip-sub",children:S==="zh"?j("langZh"):"EN"})]}),open:R,onOpenChange:T,children:[e.jsx("div",{className:"dd-header",children:j("language")}),ue.map(_=>e.jsx(ke,{active:S===_.value,onClick:()=>{B(_.value),T(!1)},children:_.label},_.value))]}),e.jsxs(Re,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(kn,{}),e.jsx("span",{className:"chip-sub",children:j("theme")})]}),open:N,onOpenChange:u,children:[e.jsx("div",{className:"dd-header",children:j("theme")}),e.jsx(ke,{active:M===null,onClick:()=>{L(null),u(!1)},children:j("themeDefault")}),w.map(_=>e.jsx(ke,{active:M===_.id,onClick:()=>{L(_.id),u(!1)},children:_.name},_.id))]}),e.jsxs(Re,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(Mt,{}),e.jsxs("span",{className:"chip-sub",children:["v",((me=t.update)==null?void 0:me.current)??"…"]}),t.update&&!t.update.upToDate&&e.jsx("span",{className:"update-dot",title:j("updateAvailable",{version:t.update.latest??""})})]}),open:y,onOpenChange:_=>{A(_),_&&s({type:"check_update"})},fit:!0,children:[e.jsx("div",{className:"dd-header",children:j("update")}),H()]}),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(Xt,{})})]}),e.jsxs("button",{type:"button",className:"chip newchat","data-tip":j("newChatTip"),onClick:()=>s({type:"new_chat"}),children:[e.jsx(qe,{}),e.jsx("span",{children:j("newChat")})]}),e.jsx("div",{className:"topbar-more",children:e.jsxs(Re,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(Tn,{}),e.jsx("span",{className:"chip-sub",children:j("more")}),t.update&&!t.update.upToDate&&e.jsx("span",{className:"update-dot"})]}),open:U,onOpenChange:_=>{te(_),_&&s({type:"check_update"})},children:[e.jsx("div",{className:"dd-header",children:j("sound")}),e.jsx("div",{className:"dd-header",children:j("settings")}),e.jsxs(ke,{onClick:()=>{te(!1),o()},children:[e.jsx(rt,{})," ",j("settingsTitle")]}),e.jsxs(ke,{onClick:()=>{te(!1),p()},children:[e.jsx(lt,{})," ",j("searchGlobal")]}),e.jsxs(ke,{onClick:()=>{te(!1),d()},children:[e.jsx(ot,{})," ",j("bgTasks"),t.bgServers.length>0&&e.jsx("em",{className:"bg-task-badge",children:t.bgServers.length})]}),e.jsx(ts,{settings:f,onChange:h,onPreview:v}),e.jsx("div",{className:"dd-header",children:j("language")}),ue.map(_=>e.jsx(ke,{active:S===_.value,onClick:()=>B(_.value),children:_.label},_.value)),e.jsx("div",{className:"dd-header",children:j("theme")}),e.jsx(ke,{active:M===null,onClick:()=>{L(null),te(!1)},children:j("themeDefault")}),w.map(_=>e.jsx(ke,{active:M===_.id,onClick:()=>{L(_.id),te(!1)},children:_.name},_.id)),e.jsx("div",{className:"dd-header",children:j("update")}),H(),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(Xt,{})," ",j("githubRepo")]})]})}),e.jsx("button",{type:"button",className:"panel-toggle",title:j("openFiles"),onClick:()=>n("right"),children:e.jsx(Ke,{})})]})]})}function ss(t){const s=new Date(t),a=new Date;return s.toDateString()===a.toDateString()?`${String(s.getHours()).padStart(2,"0")}:${String(s.getMinutes()).padStart(2,"0")}`:`${s.getMonth()+1}/${s.getDate()}`}function Jn(t,s){const a=new Map;for(const c of t){const i=a.get(c.cwd)??[];i.push(c),a.set(c.cwd,i)}const l=[...a.entries()].map(([c,i])=>({cwd:c,isCurrent:c===s,convs:i}));return l.sort((c,i)=>c.isCurrent?-1:i.isCurrent?1:c.cwd<i.cwd?-1:c.cwd>i.cwd?1:0),l}const Qn=r.memo(function({ready:s,status:a,cwd:l,sessionFile:c,conversations:i,sessions:n,projects:o,activeConversationId:d,send:p,active:f}){const h=he(),v=c,w=l,[M,L]=r.useState(null);r.useEffect(()=>{!f||!s||a!=="open"||l&&(p({type:"list_sessions"}),p({type:"list_projects"}))},[f,s,a,l,p]);const S=b=>{const E=b.name||b.firstMessage.trim();return E.length>0?E:h("emptyChat")},B=b=>b.split(/[\\/]/).pop()||b,j=(b,E,R,T)=>{const N=M===b;return e.jsx("button",{type:"button",className:`lp-del ${N?"confirm":""}`,title:N?R:E,onClick:u=>{u.stopPropagation(),N?(L(null),T()):L(b)},children:N?e.jsx(mt,{}):e.jsx(De,{})})};return e.jsxs("aside",{className:"panel panel-left",children:[o.length>0&&e.jsxs("div",{className:"panel-projects",children:[e.jsx("div",{className:"panel-section-title",children:h("recentProjects")}),e.jsx("div",{className:"projects-scroll",children:o.map(b=>{const E=w===b.path;return e.jsxs("div",{className:"lp-row",onMouseLeave:()=>L(R=>R===`proj:${b.path}`?null:R),children:[e.jsxs("button",{type:"button",className:`project-item ${E?"active":""}`,title:b.path,onClick:()=>{E||p({type:"set_cwd",path:b.path})},children:[e.jsx(Ke,{className:"project-icon"}),e.jsxs("span",{className:"project-info",children:[e.jsx("span",{className:"project-name",children:B(b.path)}),e.jsx("span",{className:"project-path",children:b.path})]}),e.jsx("span",{className:"project-time",children:ss(b.lastUsed)})]}),j(`proj:${b.path}`,h("deleteProject"),h("deleteProjectConfirm"),()=>p({type:"remove_project",path:b.path}))]},b.path)})})]}),i.length>0&&e.jsxs("div",{className:"panel-convs",children:[e.jsx("div",{className:"panel-section-title",children:h("runningConversations")}),Jn(i,l).map(b=>e.jsxs("div",{className:"panel-conv-group",children:[!b.isCurrent&&e.jsx("div",{className:"panel-conv-group-title",title:b.cwd,children:B(b.cwd)}),b.convs.map(E=>{const R=d===E.id;return e.jsxs("button",{type:"button",className:`session-item ${R?"active":""}`,title:`${E.title}${b.isCurrent?"":` — ${b.cwd}`}`,onClick:()=>{R||p({type:"switch_conversation",id:E.id})},children:[e.jsx(ze,{className:"session-icon"}),e.jsxs("span",{className:"session-info",children:[e.jsx("span",{className:"session-title",children:E.title}),e.jsx("span",{className:"session-sub",children:R?h("current"):h("messageCount",{n:E.messageCount})})]}),E.isStreaming&&e.jsx("span",{className:"conv-streaming",title:h("streaming")})]},E.id)})]},b.cwd)),e.jsx("div",{className:"panel-section-divider"})]}),e.jsxs("div",{className:"panel-sessions",children:[e.jsx("div",{className:"panel-section-title",children:h("historySessions")}),e.jsxs("div",{className:"sessions-scroll",children:[n.length===0&&e.jsx("div",{className:"panel-empty",children:h("noHistory")}),n.map(b=>{const E=v===b.path;return e.jsxs("div",{className:"lp-row",onMouseLeave:()=>L(R=>R===`sess:${b.path}`?null:R),children:[e.jsxs("button",{type:"button",className:`session-item ${E?"active":""}`,title:b.path,onClick:()=>{E||p({type:"switch_session",path:b.path})},children:[e.jsx(ze,{className:"session-icon"}),e.jsxs("span",{className:"session-info",children:[e.jsx("span",{className:"session-title",children:S(b)}),e.jsxs("span",{className:"session-sub",children:[E?h("current"):h("messageCount",{n:b.messageCount}),b.source==="tui"&&e.jsx("span",{className:"session-src",title:h("tuiTip"),children:"TUI"})]})]}),e.jsx("span",{className:"session-time",children:ss(b.modified)})]}),j(`sess:${b.path}`,h("deleteSession"),h("deleteSessionConfirm"),()=>p({type:"delete_session",path:b.path}))]},b.path)})]})]})]})}),_s="pi-web-ui:token";function Yn(){try{const t=new URL(window.location.href),s=t.searchParams.get("token");s&&(localStorage.setItem(_s,s.trim()),t.searchParams.delete("token"),window.history.replaceState(null,"",t.toString()))}catch{}}function Xn(){try{return localStorage.getItem(_s)??""}catch{return""}}function pt(t){const s=Xn();return s?`${t}${t.includes("?")?"&":"?"}token=${encodeURIComponent(s)}`:t}function Zn(t,s){const a=s.assistantMessageEvent,l=t.stats.tokens,c=s.usage!==null?{...l,...s.usage}:l,i=c===l?t.stats:{...t.stats,tokens:c};if(a.type!=="text_delta"&&a.type!=="thinking_delta")return i===t.stats?t:{...t,stats:i};const n=a.delta??"";if(!n)return i===t.stats?t:{...t,stats:i};const o=t.streamingMessage??null,d=o&&o.id===s.messageId?o:{id:s.messageId,content:[]},p=[...d.content],f=a.type==="thinking_delta"?"thinking":"text",h=a.contentIndex??p.length-1;return h>=0&&h<p.length&&p[h].type===f?p[h]=f==="thinking"?{type:"thinking",thinking:(p[h].thinking??"")+n}:{type:"text",text:(p[h].text??"")+n}:p.push(f==="thinking"?{type:"thinking",thinking:n}:{type:"text",text:n}),{...t,stats:i,streamingMessage:{...d,id:s.messageId,content:p}}}const Nt="pi-web-ui:plugin-data";function ei(t,s){window.dispatchEvent(new CustomEvent(Nt,{detail:{pluginId:t,payload:s}}))}function ti(t){const s=a=>{const l=a.detail;t(l.pluginId,l.payload)};return window.addEventListener(Nt,s),()=>window.removeEventListener(Nt,s)}const He=new Map,Ct=new Set,We=new Set;let ns=-1;function Fs(){return[...He.values()]}function si(){const t=Fs();for(const s of Ct)s(t)}function ni(t){return Ct.add(t),t(Fs()),()=>Ct.delete(t)}async function ii(t,s){s!==ns&&(ns=s,He.clear(),We.clear());const a=new Set(t.map(l=>l.id));for(const l of[...He.keys()])a.has(l)||He.delete(l);for(const l of[...We])a.has(l)||We.delete(l);await Promise.all(t.filter(l=>l.hasClient&&!l.error&&!He.has(l.id)&&!We.has(l.id)).map(async l=>{try{const i=(await Ts(()=>import(`/plugins/${encodeURIComponent(l.id)}/client/entry.mjs?e=${s}`),[])).default;i&&typeof i.mount=="function"?He.set(l.id,{info:l,module:i}):(We.add(l.id),console.error(`[plugin:${l.id}] entry.mjs 缺少 default.mount`))}catch(c){We.add(l.id),console.error(`[plugin:${l.id}] 客户端加载失败:`,c)}})),si()}function ai(t,s){return{pluginId:t,send:a=>s({type:"plugin_message",pluginId:t,payload:a}),onData:a=>ti((l,c)=>{l===t&&a(c)})}}const ri=10,ft=2e5,li=2e5,oi={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 ci(){const t=new Map,s=new Map,a=(l,c)=>`${l}:${c}`;return{write(l,c,i){const n=a(l,c),o=t.get(n);if(o&&o.size>0){for(const f of o)try{f.write(i)}catch{}return}const d=s.get(n)??"",p=d.length+i.length>li?i:d+i;s.set(n,p)},register(l,c,i){const n=a(l,c);let o=t.get(n);o||(o=new Set,t.set(n,o)),o.add(i);const d=s.get(n);if(d){try{i.write(d)}catch{}s.delete(n)}return()=>{const p=t.get(n);p&&(p.delete(i),p.size===0&&t.delete(n)),s.delete(n)}},clear(){t.clear(),s.clear()}}}function is(t,s){const a=new Set;for(const c of s.messages)c.role==="toolResult"&&c.toolCallId&&a.add(c.toolCallId),c.role==="bashExecution"&&a.add(`bash-${c.id}`);let l=!1;for(const c of t.keys())a.has(c)&&(t.delete(c),l=!0);return l?new Map(t):t}function as(t,s){if(t.size===0)return t;const a=new Set;for(const c of s.messages)c.role==="toolResult"&&c.toolCallId&&a.add(c.toolCallId);let l=!1;for(const c of t.keys())a.has(c)&&(t.delete(c),l=!0);return l?new Map(t):t}function di(t,s){var a,l,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,ready:!0,protocolMismatch:s.protocolVersion!==void 0&&s.protocolVersion!==ri};case"snapshot":return{...t,ready:!0,state:s.state,activeConversationId:s.state.conversationId,liveOutputs:is(t.liveOutputs,s.state),toolStatuses:as(t.toolStatuses,s.state)};case"snapshot_delta":{const n=t.state,o=s.msg;if(!n||n.conversationId!==o.conversationId||n.rev!==o.baseRev)return t;const d={...n,...o.state,messages:o.appended.length>0?[...n.messages,...o.appended]:n.messages};return{...t,ready:!0,state:d,activeConversationId:d.conversationId,liveOutputs:is(t.liveOutputs,d),toolStatuses:as(t.toolStatuses,d)}}case"tool_delta":{const n=t.liveOutputs.get(s.toolCallId),o=((n==null?void 0:n.text)??"")+s.delta,d=o.length>ft?`…[前 ${o.length-ft} 字符已省略]…
3
+ `+o.slice(o.length-ft):o,p=new Map(t.liveOutputs);return p.set(s.toolCallId,{toolName:s.toolName,text:d}),{...t,liveOutputs:p}}case"message_delta":{const n=t.state;return!n||n.conversationId!==s.msg.conversationId?t:{...t,state:Zn(n,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(n=>n.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"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"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"widgets":return{...t,widgets:s.widgets};case"statuses":return{...t,statuses:s.statuses};case"dialog":return{...t,dialog:s.dialog};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"terminal_add":return{...t,terminals:[...t.terminals,s.meta]};case"terminal_remove":return{...t,terminals:t.terminals.filter(n=>n.id!==s.id)};case"terminal_exit":return s.conversationId&&(t.activeConversationId||(a=t.state)!=null&&a.conversationId)&&s.conversationId!==(t.activeConversationId||((l=t.state)==null?void 0:l.conversationId))?t:{...t,terminals:t.terminals.map(n=>n.id===s.terminalId?{...n,running:!1,exitCode:s.exitCode}:n)};case"terminal_restart":return{...t,terminals:t.terminals.map(n=>n.id===s.terminalId?{...n,running:!0,exitCode:null}:n)};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(n=>{var o;return{...n,conversationId:s.conversationId??((o=t.state)==null?void 0:o.conversationId)??""}})};default:return t}}const rs="pi-web-client-id";let xt=null;function It(){if(xt)return xt;let t=null;try{t=sessionStorage.getItem(rs),t||(t=$e(),sessionStorage.setItem(rs,t))}catch{t=t??$e()}return xt=t,t}function ui(){const t=location.protocol==="https:"?"wss:":"ws:";return pt(`${t}//${location.host}/ws`)}function mi(){const[t,s]=r.useReducer(di,{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:[],installResult:null,pathCompletions:[],update:null,widgets:[],statuses:[],dialog:null,commands:[],commandsPath:"",slashCommands:[],terminals:[],goal:oi,bgServers:[],settings:null,fetchModelsResult:null,refreshProviderResult:null,cloneProviderResult:null,scmData:null,fileSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,protocolMismatch:!1}),a=r.useRef(null),l=r.useRef(ci()),c=r.useRef(0),i=r.useRef(null),n=r.useRef(!0),o=r.useRef(0),d=r.useRef(0),p=r.useRef(new Map),f=r.useRef(null),h=()=>{f.current||(f.current=setTimeout(()=>{f.current=null;const T=a.current;T&&T.readyState===WebSocket.OPEN&&T.send(JSON.stringify({type:"get_state"}))},300))},v=(T,N)=>{var A;const u=p.current,y=u.get(T);if(y!==void 0&&N!==y+1){const U=R.current.chat,te=U.activeConversationId||((A=U.state)==null?void 0:A.conversationId);T===te&&h()}u.set(T,N)},w=r.useCallback((T,N)=>{const u=++d.current;s({type:"notice",notice:{id:u,level:T,text:N}})},[]),M=r.useCallback(T=>{const N=a.current;return N&&N.readyState===WebSocket.OPEN?(N.send(JSON.stringify(T)),!0):!1},[]),L=r.useCallback(()=>{if(!n.current)return;s({type:"status",status:"connecting"});const T=new WebSocket(ui());a.current=T,T.onopen=()=>{a.current===T&&(s({type:"status",status:"open"}),c.current=0,o.current=Date.now(),T.send(JSON.stringify({type:"hello",clientId:It()})))},T.onmessage=N=>{if(a.current!==T)return;o.current=Date.now();let u;try{u=JSON.parse(N.data)}catch{return}switch(u.type){case"ready":s({type:"ready",serverVersion:u.serverVersion,protocolVersion:u.protocolVersion}),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"}));break;case"snapshot":p.current=new Map,s({type:"snapshot",state:u.state});break;case"snapshot_delta":{const y=R.current.chat.state;(!y||y.conversationId!==u.conversationId||y.rev!==u.baseRev)&&h(),s({type:"snapshot_delta",msg:u});break}case"tool_delta":v(u.conversationId,u.seq),s({type:"tool_delta",toolCallId:u.toolCallId,toolName:u.toolName,delta:u.delta});break;case"tool_status":s({type:"tool_status",status:u});break;case"message_delta":{v(u.conversationId,u.seq),s({type:"message_delta",msg:u});break}case"notice":{const y=++d.current;s({type:"notice",notice:{id:y,level:u.level,text:u.text}});break}case"sessions":s({type:"sessions",sessions:u.sessions});break;case"conversations":s({type:"conversations",conversations:u.conversations,activeId:u.activeId});break;case"projects":s({type:"projects",projects:u.projects});break;case"files":s({type:"files",files:u});break;case"file_changed":s({type:"file_changed",path:u.path});break;case"file_content":s({type:"file_content",content:u});break;case"models":s({type:"models",models:u.models,loading:!1});break;case"models_config":s({type:"models_config",providers:u.providers});break;case"providers_status":s({type:"providers_status",providers:u.providers});break;case"fetch_models_result":s({type:"fetch_models_result",result:{reqId:u.reqId,ok:u.ok,models:u.models,error:u.error}});break;case"refresh_provider_result":s({type:"refresh_provider_result",result:{reqId:u.reqId,ok:u.ok,added:u.added,total:u.total,error:u.error}});break;case"clone_provider_result":s({type:"clone_provider_result",result:{reqId:u.reqId,ok:u.ok,config:u.config,error:u.error}});break;case"scm_data":s({type:"scm_data",data:u});break;case"search_files_result":s({type:"file_search_result",result:{reqId:u.reqId,ok:u.ok,results:u.results,truncated:u.truncated}});break;case"scm_changed":s({type:"scm_changed"});break;case"install_result":s({type:"install_result",result:u});break;case"path_completions":s({type:"path_completions",completions:u.completions});break;case"update_status":s({type:"update_status",status:u});break;case"widgets":s({type:"widgets",widgets:u.widgets});break;case"statuses":s({type:"statuses",statuses:u.statuses});break;case"dialog":s({type:"dialog",dialog:{id:u.id,kind:u.kind,title:u.title,args:u.args}});break;case"dialog_closed":s({type:"dialog",dialog:null});break;case"terminal_output":l.current.write(u.conversationId??R.current.chat.activeConversationId,u.terminalId,u.data);break;case"terminal_exit":s({type:"terminal_exit",conversationId:u.conversationId,terminalId:u.terminalId,exitCode:u.exitCode});break;case"terminal_list":s({type:"terminal_list",conversationId:u.conversationId,terminals:u.terminals});break;case"commands":s({type:"commands",commands:u.commands,path:u.path});break;case"slash_commands":s({type:"slash_commands",commands:u.commands});break;case"goal_status":s({type:"goal_status",status:u.status});break;case"settings_state":s({type:"settings",settings:u.settings});break;case"bg_servers":s({type:"bg_servers",servers:u.servers});break;case"plugins":s({type:"plugins",plugins:u.plugins,epoch:u.epoch});break;case"plugin_data":ei(u.pluginId,u.payload);break}},T.onclose=()=>{if(a.current===T&&(a.current=null),l.current.clear(),!n.current||a.current&&a.current!==T)return;s({type:"status",status:"closed"});const N=Math.min(1e3*2**c.current,1e4);c.current+=1,i.current=setTimeout(()=>{i.current=null,L()},N)},T.onerror=()=>{}},[]);r.useEffect(()=>{n.current=!0,L();const T=setInterval(()=>{if(!n.current)return;const N=a.current;N&&N.readyState===WebSocket.OPEN&&Date.now()-o.current>3e4&&N.close()},5e3);return()=>{var N;n.current=!1,clearInterval(T),i.current&&(clearTimeout(i.current),i.current=null),(N=a.current)==null||N.close(),a.current=null}},[L]);const S=r.useCallback(T=>s({type:"dismiss_notice",id:T}),[]),B=r.useCallback(T=>s({type:"terminal_add",meta:T}),[]),j=r.useCallback(T=>s({type:"terminal_remove",id:T}),[]),b=r.useCallback(T=>s({type:"terminal_restart",terminalId:T}),[]),E=r.useCallback((T,N,u)=>l.current.register(T,N,u),[]),R=r.useRef({chat:t,send:M,pushNotice:w,dismissNotice:S,terminal:{create:B,close:j,register:E,restart:b}});return R.current={chat:t,send:M,pushNotice:w,dismissNotice:S,terminal:{create:B,close:j,register:E,restart:b}},R.current}const pi=200*1024*1024,hi=/windows/i.test(navigator.userAgent),gi=/[<>:"/\\|?*\u0000-\u001f]/g,fi=/[. ]+$/,xi=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function vi(t){const s=t.replace(gi,"_").replace(fi,"");return s?xi.test(s)?`_${s}`:s:"_"}function ls(t,s=!0){const a=new URLSearchParams({clientId:It(),path:t,...s?{download:"1"}:{}});return pt(`/api/file?${a}`)}async function yi(t,s){const a=hi?vi(s):s;try{const l=await fetch(ls(t));if(!l.ok)return{ok:!1,cancelled:!1,error:await l.text().catch(()=>"")||(l.status===404?"文件不存在":`HTTP ${l.status}`)};if(Number(l.headers.get("content-length")??"0")>pi)return window.location.assign(ls(t)),{ok:!0};const i=await l.blob();return window.showSaveFilePicker&&window.isSecureContext?ji(i,a):St(i,a)}catch(l){return{ok:!1,cancelled:!1,error:l instanceof Error?l.message:String(l)}}}async function ji(t,s){let a;const l=window.showSaveFilePicker;if(!l)return St(t,s);try{a=await l({suggestedName:s})}catch(c){return c instanceof DOMException&&c.name==="AbortError"?{ok:!1,cancelled:!0}:St(t,s)}try{const c=await a.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 St(t,s){const a=URL.createObjectURL(t),l=document.createElement("a");return l.href=a,l.download=s,document.body.appendChild(l),l.click(),l.remove(),setTimeout(()=>URL.revokeObjectURL(a),1e4),{ok:!0}}const bi=r.memo(function({files:s,fileChanged:a,widgets:l,cwd:c,send:i,onAttach:n,onPreview:o,onNotice:d}){const p=he(),[f,h]=r.useState(""),[v,w]=r.useState(null),[M,L]=r.useState(!1),S=1e4,B=r.useRef(0),j=r.useRef(void 0),b=r.useCallback((N,u)=>{const y=++B.current;h(N),u!=null&&u.silent||L(!0),i({type:"list_files",path:N===""?void 0:N})||B.current===y&&L(!1)},[i]);r.useEffect(()=>{s&&s.path===f&&L(!1)},[s,f]),r.useEffect(()=>{if(c!==j.current){j.current=c,b("",{silent:!0});return}const N=setInterval(()=>{document.visibilityState!=="hidden"&&b(f,{silent:!0})},S);return()=>clearInterval(N)},[c,f,b]),r.useEffect(()=>{a&&a.path===f&&b(f,{silent:!0})},[a,f,b]);const E=N=>b(N),R=()=>{(s==null?void 0:s.parent)!==null&&(s==null?void 0:s.parent)!==void 0&&b(s.parent)},T=f.split("/").filter(Boolean);return e.jsxs("aside",{className:"panel panel-right",children:[e.jsxs("div",{className:"panel-crumbs",children:[e.jsx("button",{type:"button",className:`crumb ${f===""?"active":""}`,onClick:()=>b(""),children:p("rootDir")}),T.map((N,u)=>{const y=T.slice(0,u+1).join("/");return e.jsxs("span",{className:"crumb-seg",children:[e.jsx(ut,{}),e.jsx("button",{type:"button",className:`crumb ${y===f?"active":""}`,onClick:()=>b(y),children:N})]},y)})]}),e.jsxs("div",{className:"panel-body",children:[M&&e.jsx("div",{className:"panel-empty",children:p("loading")}),!M&&s&&s.path===f&&e.jsxs(e.Fragment,{children:[s.path!==""&&e.jsxs("button",{type:"button",className:"file-item dir",onClick:R,children:[e.jsx(Ke,{className:"file-icon"}),e.jsx("span",{className:"file-name",children:".."})]}),s.entries.map(N=>N.type==="dir"?e.jsxs("div",{className:"file-item dir",children:[e.jsxs("button",{type:"button",className:"file-dir-main",onClick:()=>E(N.path),children:[e.jsx(Ke,{className:"file-icon"}),e.jsx("span",{className:"file-name",children:N.name})]}),e.jsx("button",{type:"button",className:"file-attach ref","data-tip":p("linkFolderTip"),onClick:()=>n(N.path,N.name,"reference",!0),children:e.jsx(bt,{})})]},N.path):e.jsxs("div",{className:"file-item file",children:[e.jsxs("button",{type:"button",className:"file-name",title:`${N.path} — ${p("previewFile")}`,onClick:()=>o(N.path,N.name),children:[e.jsx(Rs,{className:"file-icon"}),e.jsx("span",{className:"file-name-text",children:N.name})]}),e.jsx("button",{type:"button",className:"file-attach download","data-tip":p("downloadFile"),onClick:()=>{yi(N.path,N.name).then(u=>{u.ok||u.cancelled||d("error",p("downloadFailed",{error:u.error}))})},children:e.jsx(Mt,{})}),e.jsx("button",{type:"button",className:"file-attach inline","data-tip":p("attachInlineTip"),onClick:()=>n(N.path,N.name,"inline"),children:e.jsx(qe,{})}),e.jsx("button",{type:"button",className:"file-attach ref","data-tip":p("referenceTip"),onClick:()=>n(N.path,N.name,"reference"),children:e.jsx(bt,{})})]},N.path)),s.truncated&&e.jsx("div",{className:"panel-empty files-truncated",children:p("filesTruncated")})]}),!M&&!s&&e.jsx("div",{className:"panel-empty",children:p("noFiles")})]}),l.filter(N=>N.lines.length>0).length>0&&e.jsx("div",{className:"panel-widgets",children:l.filter(N=>N.lines.length>0).map(N=>e.jsxs("div",{className:"widget",children:[e.jsxs("button",{type:"button",className:"widget-title widget-title-btn",title:p("widgetExpand"),onClick:()=>w(N.key),children:[e.jsx("span",{children:N.key}),e.jsx(Rn,{})]}),e.jsx("pre",{className:"widget-lines",children:N.lines.join(`
4
+ `)})]},N.key))}),v&&(()=>{const N=l.find(u=>u.key===v);return N?e.jsx("div",{className:"modal-backdrop",onClick:()=>w(null),children:e.jsxs("div",{className:"widget-expand",onClick:u=>u.stopPropagation(),children:[e.jsxs("div",{className:"widget-expand-head",children:[e.jsx("span",{className:"widget-expand-title",children:N.key}),e.jsx("button",{type:"button",className:"btn",title:p("close"),onClick:()=>w(null),children:e.jsx(we,{})})]}),e.jsx("pre",{className:"widget-expand-lines",children:N.lines.join(`
5
+ `)})]})}):null})()]})});var os=Ss();const As=r.memo(function({text:s}){const a=he(),[l,c]=r.useState(!1);return s?e.jsx("button",{type:"button",className:"copy-btn",title:a("copy"),onClick:()=>{navigator.clipboard.writeText(s).then(()=>{c(!0),setTimeout(()=>c(!1),1200)})},children:l?e.jsx(mt,{}):e.jsx(Pt,{})}):null}),Ws=[ln],Os=[[rn,{detect:!0,ignoreMissing:!0}]];function Hs({text:t}){return e.jsx(Cs,{remarkPlugins:Ws,rehypePlugins:Os,components:{pre:ki},children:t})}const ht=r.memo(function({text:s}){return e.jsx("div",{className:"md",children:e.jsx(Hs,{text:s})})});function ki({children:t,...s}){return e.jsxs("div",{className:"codeblock",children:[e.jsx(As,{text:Tt(t)}),e.jsx("pre",{...s,children:t})]})}function Tt(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(Tt).join("");if(t&&typeof t=="object"&&"props"in t){const s=t.props;return Tt(s==null?void 0:s.children)}return""}const wi=/^\s{0,3}(`{3,}|~{3,})/,Ni=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function vt(t){return t.trim()===""}function cs(t){const s=wi.exec(t);return s?s[1]:null}function Ci(t){const s=t.split(`
6
+ `),a=[];let l=[],c=null;for(let i=0;i<s.length;i++){const n=s[i];if(c!==null){const d=cs(n);d&&d[0]===c[0]&&d.length>=c.length&&(c=null),l.push(n);continue}const o=cs(n);if(o&&!vt(n)){c=o,l.push(n);continue}if(vt(n)){let d=i;for(;d<s.length&&vt(s[d]);)d++;if(!(d<s.length&&Ni.test(s[d]))&&l.length>0){a.push(l.join(`
7
+ `)),l=[];continue}l.push(n);continue}l.push(n)}return{frozen:a,active:l.join(`
8
+ `),inFence:c!==null}}const Si=r.memo(function({text:s}){return e.jsx(Cs,{remarkPlugins:Ws,rehypePlugins:Os,children:s})}),ds=200;function Ti({text:t,inFence:s}){const[a,l]=r.useState(t),c=r.useRef(0),i=r.useRef(null);return r.useEffect(()=>{if(s)return;const n=Date.now()-c.current,o=()=>{c.current=Date.now(),l(t)};if(n>=ds){o();return}return i.current=setTimeout(o,ds-n),()=>{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(Hs,{text:a})}const Ei=r.memo(function({text:s}){const{frozen:a,active:l,inFence:c}=r.useMemo(()=>Ci(s),[s]);return e.jsxs("div",{className:"md",children:[a.map((i,n)=>e.jsx(Si,{text:i},n)),l.length>0&&e.jsx(Ti,{text:l,inFence:c},a.length)]})});function Mi({thinking:t,streaming:s,wrap:a=!0}){const l=he(),[c,i]=r.useState(null),n=c??a,o=s?t.trimEnd().slice(-80):t.split(`
9
+ `)[0].slice(0,80);return e.jsxs("div",{className:`thinking ${n?"open":""} ${s?"live":""}`,children:[e.jsxs("button",{type:"button",className:"thinking-toggle",onClick:()=>i(!n),children:[n?e.jsx(_e,{}):e.jsx(ut,{}),e.jsx(Qe,{className:"thinking-icon"}),e.jsx("span",{className:"thinking-label",children:s&&n?e.jsxs("span",{className:"thinking-live-label",children:[l("thinkingNow"),e.jsx("span",{className:"dots"})]}):n?l("thinking"):l("thinkingPreview",{preview:o})})]}),n&&e.jsx("div",{className:"thinking-body",children:t})]})}const Pi={bash:"$",read:"📄",write:"✍️",edit:"✏️",grep:"🔍",find:"🧭",ls:"📂"};function Ri(t){return Pi[t]??"🛠"}const Ii=r.memo(function({block:s,view:a,onKillBash:l,wrap:c=!0}){var R,T,N,u;const i=he(),[n,o]=r.useState(c),[d,p]=r.useState(!1),f=!a.result&&a.streaming&&!a.status,h=s.name==="bash"&&f,v=a.result!==void 0,w=!a.result&&!!a.status,M=((R=a.result)==null?void 0:R.isError)??((T=a.status)==null?void 0:T.isError)??!1,L=a.result?a.result.content.map(y=>y.type==="text"?y.text:"").join(""):a.liveOutput??"",S=M?"err":v?"ok":f||w?"run":"idle";let B=i(M?"error":v?"done":f?"running":w?"toolDoneWaitingModel":"toolQueued");const j=w&&((N=a.status)==null?void 0:N.durationMs)!==void 0?Bi(a.status.durationMs):"";w&&j&&(B=`${B} · ${j}`);const b=w&&((u=a.status)==null?void 0:u.exitCode)!==void 0?`exit ${a.status.exitCode}`:"",E=()=>{s.argumentsText&&(navigator.clipboard.writeText(s.argumentsText),p(!0),setTimeout(()=>p(!1),1200))};return e.jsxs("div",{className:`toolcall ${S}`,children:[e.jsxs("div",{className:"toolcall-head",children:[e.jsx("span",{className:"toolcall-icon",children:Ri(s.name)}),e.jsx("span",{className:"toolcall-name",children:s.name}),e.jsxs("span",{className:"toolcall-status",children:[B,b&&e.jsx("em",{className:"toolcall-exit",children:b})]}),e.jsx("span",{className:"toolcall-spacer"}),h&&l&&e.jsxs("button",{type:"button",className:"toolcall-kill",title:i("stopBashTip"),onClick:l,children:[e.jsx(at,{}),e.jsx("span",{children:i("stopBash")})]}),e.jsx("button",{type:"button",className:"toolcall-copy",title:i("copyArgs"),onClick:E,children:d?e.jsx(An,{}):e.jsx(Pt,{})}),e.jsx("button",{type:"button",className:"toolcall-toggle",onClick:()=>o(y=>!y),children:n?e.jsx(_e,{}):e.jsx(ut,{})})]}),n&&e.jsxs("div",{className:"toolcall-body",children:[s.argumentsText&&e.jsx("div",{className:"toolcall-args",children:s.name==="bash"&&s.argumentsText.startsWith("{")?e.jsx(Li,{args:s.argumentsText}):e.jsx("pre",{children:s.argumentsText})}),L.length>0&&e.jsxs("div",{className:"toolcall-output",children:[e.jsxs("div",{className:"toolcall-output-label",children:[i(M?"errorOutput":"output"),(f||w)&&e.jsx("span",{className:"cursor"})]}),e.jsx("pre",{children:L})]}),f&&L.length===0&&e.jsxs("div",{className:"toolcall-waiting",children:[e.jsx("span",{className:"cursor"})," ",i("waitingOutput")]}),w&&L.length===0&&e.jsxs("div",{className:"toolcall-waiting",children:[e.jsx("span",{className:"cursor"})," ",i("waitingModel")]})]})]})});function Li({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(Ue,{className:"termline-icon"}),e.jsx("code",{children:s.command}),typeof s.timeout=="number"&&e.jsxs("span",{className:"termline-timeout",children:["⏱ ",s.timeout,"s"]})]})}function Bi(t){if(t===void 0)return"";const s=t/1e3;if(s<60)return`${s.toFixed(1)}s`;const a=Math.floor(s/60),l=Math.round(s%60);return`${a}m ${String(l).padStart(2,"0")}s`}const Di=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;function Lt(t){var a;const s=t.match(Di);return s?{name:s[1],location:s[2],content:s[3],userMessage:((a=s[4])==null?void 0:a.trim())||void 0}:null}const $i=1568,_i=2*1024*1024;function Me(t){return t.startsWith("image/")&&t!=="image/svg+xml"&&t!=="image/svg"}async function Us(t){if(!t.type.startsWith("image/"))return null;let s;try{s=await createImageBitmap(t,{imageOrientation:"from-image"})}catch{return null}try{const a=Math.min(1,$i/Math.max(s.width,s.height)),l=Math.max(1,Math.round(s.width*a)),c=Math.max(1,Math.round(s.height*a)),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 n=null;for(const[o,d]of i){const p=document.createElement("canvas");p.width=l,p.height=c;const f=p.getContext("2d");if(!f)continue;o!=="image/png"&&(f.fillStyle="#ffffff",f.fillRect(0,0,l,c)),f.drawImage(s,0,0,l,c);const h=p.toDataURL(o,d),v=h.match(/^data:([^;]+);base64,/),w=v?v[1]:o,M=h.replace(/^data:[^;]*;base64,/,""),L=Math.floor(M.length*3/4);if(n={data:M,mimeType:w,name:t.name,size:L},L<=_i)return n}return n}finally{s.close()}}const Fi=20*1024*1024;function Ye(t){return t.type==="text"&&typeof t.text=="string"?t:null}function qs(t){return t.type==="thinking"&&typeof t.thinking=="string"?t:null}function zs(t){return t.type==="toolCall"&&typeof t.id=="string"&&typeof t.name=="string"?t:null}function Ks(t){return t.type==="image"&&typeof t.dataUrl=="string"?t:null}function Vs(t){return t.type==="bash"&&typeof t.command=="string"?t:null}function Ai(t){return t.imageData?"image":t.uploadPath?"upload":t.fileData?"file":"path"}function Wi(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 a=t.path.split("/").pop()??t.path;return t.mode==="lines"&&t.lines?s("attachLines",{path:a,start:t.lines.start,end:t.lines.end}):t.mode==="reference"?s("refOnly",{path:a}):s("attachContent",{path:a})}const us=r.memo(function({message:s,toolResults:a,liveOutputs:l,toolStatuses:c,streaming:i,isLast:n,onEdit:o,onKillBash:d,onCollapse:p,questionAttachments:f,qnIndex:h,qnActive:v,onJump:w,thinkingWrap:M,toolsWrap:L}){const S=he(),[B,j]=r.useState(!1),[b,E]=r.useState(""),[R,T]=r.useState([]),[N,u]=r.useState(!1),[y,A]=r.useState(null),U=$=>{A($),window.setTimeout(()=>A(V=>V===$?null:V),4e3)};if(s.role==="toolResult")return null;const te=s.role==="custom"&&s.customType==="file",ue=s.content.map($=>{var V;return((V=Ye($))==null?void 0:V.text)??""}).filter(Boolean).join(`
10
+ `),ee=s.role==="user"?Lt(ue):null,I=ee?ee.userMessage??`skill:${ee.name}`:ue.split(`
11
+ `).join(" ").trim(),q=i&&n&&s.content.length===0,H=s.role==="user"&&!i&&!q&&!!o,me=async $=>{const V=[];for(const le of $){if(!Me(le.type))continue;const K=await Us(le);K&&V.push({path:"",imageData:K.data,mimeType:K.mimeType,name:K.name})}V.length>0&&T(le=>[...le,...V])},_=async $=>{if($.size>Fi){U(S("fileTooLarge",{name:$.name,size:20}));return}let V;try{V=(await new Promise((K,oe)=>{const g=new FileReader;g.onload=()=>K(g.result),g.onerror=()=>oe(g.error??new Error("read failed")),g.readAsDataURL($)})).replace(/^data:[^;]*;base64,/,"")}catch{U(S("fileLoadFailed",{name:$.name}));return}T(le=>[...le,{path:"",fileData:V,name:$.name,size:$.size,mimeType:$.type||void 0}])},O=async $=>{const V=[];for(const le of $)Me(le.type)?V.push(le):_(le);V.length>0&&await me(V)},C=()=>{E(ee?`/skill:${ee.name}${ee.userMessage?` ${ee.userMessage}`:""}`:s.content.map($=>{var V;return((V=Ye($))==null?void 0:V.text)??""}).filter(Boolean).join(`
12
+ `)),T(f??[]),j(!0)},Y=()=>{const $=b.trim();$&&(o==null||o(s.id,$,R.length>0?R:void 0),j(!1))},J=s.role==="custom"&&(s.customType==="goal-review"||s.customType==="goal-wizard"),ie=s.role==="custom"&&s.customType==="goal-wizard";return e.jsxs("div",{className:`msg msg-${s.role}${J?" 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"?ie?S("goalWizardCard"):J?S("goalBarTitle"):s.customType==="file"?S("attachment"):`${S("plugin")} · ${s.customType??S("unknown")}`:Gs(s.role,S)}),s.model&&e.jsx("span",{className:"msg-model",children:s.model}),s.timestamp&&e.jsx("span",{className:"msg-time",children:qi(s.timestamp)}),p&&e.jsxs("button",{type:"button",className:"msg-collapse-btn",title:S("collapseMsg"),onClick:()=>p(s.id),children:[e.jsx(dt,{})," ",S("collapseMsg")]}),h!==void 0&&w&&e.jsxs("button",{type:"button",className:`qn-tag ${v?"active":""}`,title:`${h+1}. ${I}`,"aria-label":`${h+1}. ${I}`,onClick:()=>w(s.id),children:[e.jsx("span",{className:"qn-tag-bar"}),e.jsx("span",{className:"qn-tag-idx",children:h+1})]})]}),e.jsx("div",{className:"msg-body",children:B?e.jsxs("div",{className:`msg-editor${N?" drag-over":""}`,onDragOver:$=>{$.preventDefault(),$.stopPropagation(),u(!0)},onDragLeave:$=>{$.currentTarget.contains($.relatedTarget)||u(!1)},onDrop:$=>{var V;$.preventDefault(),$.stopPropagation(),u(!1),O(Array.from(((V=$.dataTransfer)==null?void 0:V.files)??[]))},children:[R.length>0&&e.jsx("div",{className:"msg-editor-images",children:R.map(($,V)=>{var K;const le=Ai($);return e.jsxs("span",{className:`msg-editor-img ${le==="image"?"":"file-chip"}`,title:Wi($,S),children:[le==="image"?e.jsx("img",{src:`data:${$.mimeType??"image/png"};base64,${$.imageData}`,alt:$.name}):e.jsxs("span",{className:"msg-editor-file",children:[e.jsx("span",{className:"msg-editor-file-icon",children:le==="path"?$.mode==="reference"?"🔗":"📎":"📄"}),e.jsx("span",{className:"msg-editor-file-name",children:$.name??((K=$.path)==null?void 0:K.split("/").pop())})]}),e.jsx("button",{type:"button",className:"msg-editor-img-remove",title:S("removeAttachment"),onClick:()=>T(oe=>oe.filter((g,m)=>m!==V)),children:e.jsx(we,{})})]},`${$.name??$.path??"att"}-${V}`)})}),y&&e.jsx("div",{className:"msg-editor-notice",children:y}),e.jsx("textarea",{className:"msg-editor-input",value:b,autoFocus:!0,placeholder:S("editPlaceholder"),rows:Math.max(2,Math.min(10,b.split(`
13
+ `).length+1)),onChange:$=>E($.target.value),onPaste:$=>{var le;const V=[];for(const K of((le=$.clipboardData)==null?void 0:le.items)??[])if(K.kind==="file"&&Me(K.type)){const oe=K.getAsFile();oe&&V.push(oe)}V.length!==0&&($.preventDefault(),me(V))},onKeyDown:$=>{$.key==="Enter"&&($.metaKey||$.ctrlKey)?($.preventDefault(),Y()):$.key==="Escape"&&j(!1)}}),e.jsxs("div",{className:"msg-editor-actions",children:[e.jsxs("span",{className:"msg-editor-hint",children:[e.jsx(Dn,{})," ",S("editAttachmentHint")]}),e.jsx("button",{type:"button",className:"chip",onClick:()=>j(!1),children:S("cancel")}),e.jsxs("button",{type:"button",className:"chip primary",disabled:!b.trim(),title:S("reaskFromHere"),onClick:Y,children:[e.jsx(wt,{})," ",S("reaskFromHere")]})]})]}):e.jsxs(e.Fragment,{children:[s.errorMessage&&e.jsx("div",{className:"msg-error",children:s.errorMessage}),te?e.jsx(Oi,{message:s}):ee?e.jsxs(e.Fragment,{children:[e.jsx(Ui,{block:ee}),ee.userMessage&&e.jsx("div",{className:"msg-text",children:e.jsx(ht,{text:ee.userMessage})}),s.content.map(($,V)=>$.type==="text"?null:e.jsx(ps,{block:$,toolResults:a,liveOutputs:l,toolStatuses:c,streaming:i,isLast:n,onKillBash:d,toolsWrap:L,thinkingWrap:M},`${s.id}-${V}`))]}):s.content.map(($,V)=>e.jsx(ps,{block:$,toolResults:a,liveOutputs:l,toolStatuses:c,streaming:i,isLast:n,onKillBash:d,toolsWrap:L,thinkingWrap:M},`${s.id}-${V}`)),q&&e.jsxs("div",{className:"thinking-wait",children:[S("thinkingWait"),e.jsx("span",{className:"dot"})]}),i&&n&&!q&&e.jsx("span",{className:"stream-cursor"})]})}),H&&!B&&e.jsx("div",{className:"msg-actions",children:e.jsxs("button",{type:"button",className:"msg-action",title:S("editReaskTip"),onClick:C,children:[e.jsx(wt,{})," ",S("editReask")]})})]})});function Oi({message:t}){const s=he(),[a,l]=r.useState(!1),c=t.details??{},i=c.name??c.path??s("attachment"),n=c.type==="folder",o=c.mode==="reference",d=c.mode==="bridged",p=t.content.filter(w=>w.type==="text").map(w=>w.text).join(`
14
+ `),f=Hi(p),h=t.content.find(w=>w.type==="image"),v=f.split(`
15
+ `).length;return e.jsxs("div",{className:`attachcard ${o?"reference":""}`,children:[e.jsxs("button",{type:"button",className:"attachcard-head",onClick:()=>l(w=>!w),children:[e.jsx("span",{className:"attachcard-icon",children:n?"📁":"📎"}),e.jsx("span",{className:"attachcard-name",children:i}),c.path&&e.jsx("span",{className:"attachcard-path",children:c.path}),e.jsx("span",{className:`attachcard-mode ${c.mode==="lines"?"lines":o?"ref":d?"bridged":"inline"}`,children:o?n?s("folderRefShort"):`${s("refOnlyShort")} · ${ms(c.size)}`:d?s("bridgedVision"):h?s("image"):c.mode==="lines"?s("inlineLinesRange",{start:c.startLine??1,end:c.endLine??c.lines??1}):s("inlineLines",{n:c.lines??v})}),!o&&(a?e.jsx(_e,{}):e.jsx(ut,{}))]}),!o&&a&&(d?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"attachcard-bridgenote",children:s("bridgedVisionDetail")}),(h==null?void 0:h.dataUrl)&&e.jsx("div",{className:"attachcard-image",children:e.jsx("img",{src:h.dataUrl,alt:i})}),f&&e.jsx("pre",{className:"attachcard-content",children:f})]}):h!=null&&h.dataUrl?e.jsx("div",{className:"attachcard-image",children:e.jsx("img",{src:h.dataUrl,alt:i})}):e.jsx("pre",{className:"attachcard-content",children:f})),o&&e.jsx("div",{className:"attachcard-refnote",children:n?s("folderNotExpanded"):s("fileNotExpanded",{size:ms(c.size)})})]})}function ms(t){return t===void 0?"":t>=1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:t>=1024?`${Math.round(t/1024)} KB`:`${t} B`}function Hi(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 a=t.match(/^\s*<vision-bridge>\s*([\s\S]*?)\s*<\/vision-bridge>\s*$/);return a?a[1].trim():t.trim()}function Ui({block:t}){const s=he(),[a,l]=r.useState(!1);return e.jsxs("div",{className:`skillcard${a?" expanded":""}`,children:[e.jsxs("button",{type:"button",className:"skillcard-head",onClick:()=>l(c=>!c),title:t.location,children:[e.jsx("span",{className:"skillcard-icon",children:e.jsx(Wn,{})}),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:[a?e.jsx(dt,{}):e.jsx(_e,{}),s(a?"collapseMsg":"expandMsg")]})]}),a&&e.jsx("div",{className:"skillcard-body",children:e.jsx(ht,{text:t.content})})]})}function ps({block:t,toolResults:s,liveOutputs:a,toolStatuses:l,streaming:c,isLast:i,onKillBash:n,thinkingWrap:o,toolsWrap:d}){const p=he(),f=Ye(t);if(f){const L=c&&i;return e.jsxs("div",{className:"msg-text",children:[L?e.jsx(Ei,{text:f.text}):e.jsx(ht,{text:f.text}),f.truncated&&e.jsx("div",{className:"trunc-note",children:p("truncated")})]})}const h=qs(t);if(h)return e.jsx(Mi,{thinking:h.thinking,streaming:c&&i,wrap:o});const v=zs(t);if(v){const L=s.get(v.id),S=a.get(v.id),B={result:L,liveOutput:S==null?void 0:S.text,streaming:c,status:l.get(v.id)};return e.jsx(Ii,{block:v,view:B,onKillBash:n,wrap:d})}const w=Ks(t);if(w&&w.dataUrl)return e.jsx("div",{className:"msg-image",children:e.jsx("img",{src:w.dataUrl,alt:"attachment"})});const M=Vs(t);return M?e.jsxs("div",{className:"bashblock",children:[e.jsxs("div",{className:"bashblock-command",children:[e.jsx("span",{className:"bashblock-prompt",children:"$"}),e.jsx("code",{children:M.command}),M.exitCode!==void 0&&e.jsx("span",{className:`bashblock-exit ${M.exitCode===0?"ok":"err"}`,children:p("exitCode",{code:M.exitCode})}),M.cancelled&&e.jsx("span",{className:"bashblock-exit err",children:p("cancelled")})]}),M.output&&e.jsx("pre",{className:"bashblock-output",children:M.output}),M.truncated&&e.jsx("div",{className:"trunc-note",children:p("outputTruncated")})]}):null}function Gs(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 qi(t){const s=new Date(t),a=String(s.getHours()).padStart(2,"0"),l=String(s.getMinutes()).padStart(2,"0");return`${a}:${l}`}function hs(t,s,a){let l=!1;for(const c of s){const i=c;if(i.type!=="image"||typeof i.dataUrl!="string"||!i.dataUrl.startsWith("data:"))continue;const n=i.dataUrl.match(/^data:([^;]*);base64,(.+)$/);n&&(l=!0,t.push({path:"",imageData:n[2],mimeType:n[1]||"image/png",name:a??`image.${(n[1]||"image/png").split("/")[1]??"png"}`}))}return l}function zi(t){const s=new Map;for(let a=0;a<t.length;a++){const l=t[a];if(l.role!=="user"||!l.id)continue;const c=[];hs(c,l.content);for(let i=a+1;i<t.length&&t[i].role==="custom"&&t[i].customType==="file";i++){const n=t[i].details??{};if(!hs(c,t[i].content,n.name)){if(n.upload&&n.path){c.push({path:"",uploadPath:n.path,name:n.name??n.path,size:n.size});continue}if(n.path&&n.mode){const o=n.mode==="inline"||n.mode==="lines"?n.mode:"reference",d={path:n.path,mode:o};n.mode==="lines"&&typeof n.startLine=="number"&&typeof n.endLine=="number"&&(d.lines={start:n.startLine,end:n.endLine}),c.push(d)}}}c.length>0&&s.set(l.id,c)}return s}const Ki=r.memo(function({message:s,onExpand:a}){const l=he();let c="";for(const h of s.content){const v=Ye(h);if(v&&v.text.trim()){const w=Lt(v.text);w?c=`skill:${w.name}`+(w.userMessage?` · ${w.userMessage.replace(/\s+/g," ").trim()}`:""):c=v.text.replace(/\s+/g," ").trim();break}}if(!c&&s.role==="custom"&&s.customType==="file"){const h=s.details??{};c=h.name??h.path??""}c.length>90&&(c=`${c.slice(0,90)}…`);let n=0,o=0,d=0,p=0;for(const h of s.content)qs(h)?n++:zs(h)?o++:Vs(h)?d++:Ks(h)&&p++;const f=[];return n&&f.push(`${l("thinking")} ${n}`),o&&f.push(`${l("toolCalls")} ${o}`),d&&f.push(`${l("bashRuns")} ${d}`),p&&f.push(`${l("images")} ${p}`),e.jsxs("button",{type:"button",className:"msg-collapsed","data-msg-id":s.id,title:`${l("expandMsg")} · ${c||f.join(" · ")||s.role}`,onClick:()=>a(s.id),children:[e.jsx("span",{className:`msg-collapsed-role role-${s.role}`,children:s.role==="custom"&&s.customType==="file"?l("attachment"):Gs(s.role,l)}),e.jsxs("span",{className:"msg-collapsed-body",children:[c&&e.jsx("span",{className:"msg-collapsed-preview",children:c}),f.length>0&&e.jsx("span",{className:"msg-collapsed-chips",children:f.map((h,v)=>e.jsx("span",{className:"msg-collapsed-chip",children:h},v))})]}),s.timestamp?e.jsx("span",{className:"msg-collapsed-time",children:Vi(s.timestamp)}):null,e.jsxs("span",{className:"msg-collapsed-action",children:[e.jsx(_e,{})," ",l("expandMsg")]})]})});function Vi(t){const s=new Date(t),a=String(s.getHours()).padStart(2,"0"),l=String(s.getMinutes()).padStart(2,"0");return`${a}:${l}`}const Gi=r.memo(function({id:s,show:a,height:l,containerRef:c,onMeasured:i,lazyRef:n,children:o}){const d=r.useRef(null),p=r.useRef(null);return r.useLayoutEffect(()=>{const f=p.current;if(p.current=a,!a||f!==!1)return;const h=d.current,v=c.current;if(!h||!v)return;const w=h.offsetHeight;i==null||i(s,w);const M=w-l;if(M!==0){const L=h.parentElement;L&&L.getBoundingClientRect().bottom<=v.getBoundingClientRect().top&&(v.scrollTop+=M)}},[a]),a?e.jsx("div",{ref:n,"data-lazy-id":s,children:e.jsx("div",{ref:d,children:o})}):e.jsx("div",{ref:n,className:"msg-lazy-ph","data-msg-id":s,"data-lazy-id":s,style:{height:l},"aria-hidden":"true"})});function Ji(t,s,a,l){const c=[],i=[];let n=0;for(const o of t){if(a.has(o.id))continue;o.top<s.bottom&&o.bottom>s.top?l.has(o.id)&&c.push(o.id):l.has(o.id)||(i.push(o.id),o.bottom<=s.top&&(n+=o.bottom-o.top))}return{show:c,hide:i,shrinkAbove:n}}function Qi(t,s){if(s.show.length===0&&s.hide.length===0)return t;const a=new Set(t);for(const l of s.show)a.delete(l);for(const l of s.hide)a.add(l);return a}function Yi(t,s,a){const l=new Set;let c=0;for(let i=t.length-1;i>=0&&!(i<t.length-1&&c>=a);i--){const n=t[i];l.add(n.id),c+=s.get(n.id)??Js(n.role,n.customType)}return l}function Js(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}}function Xi(t){if(t.role==="toolResult")return"";const s=[];for(const a of t.content)Zi(a,s);return t.errorMessage&&s.push(t.errorMessage),s.join(`
16
+ `)}function Zi(t,s){if(typeof t.text=="string"){s.push(t.text);return}switch(t.type){case"thinking":typeof t.thinking=="string"&&s.push(t.thinking);break;case"toolCall":{typeof t.name=="string"&&s.push(t.name),typeof t.argumentsText=="string"&&s.push(t.argumentsText);break}case"bash":typeof t.command=="string"&&s.push(t.command),typeof t.output=="string"&&s.push(t.output);break}}function ea(t,s){const a=s.trim().toLowerCase();if(!a)return 0;const l=t.toLowerCase();let c=0,i=l.indexOf(a);for(;i!==-1;)c++,i=l.indexOf(a,i+a.length);return c}function ta(t,s){const a=s.trim().toLowerCase();if(!a)return[];const l=[];for(const c of t){const i=Xi(c);if(!i)continue;const n=ea(i,a);for(let o=0;o<n;o++)l.push({messageId:c.id,occurrence:o})}return l}function sa(t,s){var n;const a=new Map,l=[],c=s.toLowerCase();if(!c)return{byMsg:a,all:l};const i=document.createTreeWalker(t,NodeFilter.SHOW_TEXT,{acceptNode(o){const d=o.parentElement;return!d||d.closest(".search-bar")?NodeFilter.FILTER_REJECT:(o.textContent??"").toLowerCase().includes(c)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(let o=i.nextNode();o;o=i.nextNode()){const d=(o.textContent??"").toLowerCase(),p=(n=o.parentElement)==null?void 0:n.closest("[data-msg-id]");if(!p)continue;const f=p.getAttribute("data-msg-id")??"";let h=d.indexOf(c);for(;h!==-1;){const v=document.createRange();v.setStart(o,h),v.setEnd(o,h+c.length),l.push(v);const w=a.get(f);w?w.push(v):a.set(f,[v]),h=d.indexOf(c,h+c.length)}}return{byMsg:a,all:l}}function Oe(t,s){const a=CSS;if(!a.highlights)return;if(s.length===0){a.highlights.delete(t);return}const l=window.Highlight;l&&a.highlights.set(t,new l(...s))}function na({containerRef:t,messages:s,open:a,onClose:l,onEnsureExpanded:c}){const i=he(),n=r.useRef(null),[o,d]=r.useState(""),[p,f]=r.useState(0),h=r.useDeferredValue(o),v=a?h.trim():"",w=r.useMemo(()=>a?ta(s,v):[],[s,v,a]),M=r.useRef(w);M.current=w;const L=r.useRef(p);L.current=p,r.useEffect(()=>{a&&(f(0),requestAnimationFrame(()=>{var b;return(b=n.current)==null?void 0:b.select()}))},[a]),r.useEffect(()=>{if(!a)return;const b=E=>{E.key==="Escape"&&(E.preventDefault(),E.stopPropagation(),l())};return window.addEventListener("keydown",b,!0),()=>window.removeEventListener("keydown",b,!0)},[a,l]),r.useEffect(()=>(a||(Oe("msg-search",[]),Oe("msg-search-active",[])),()=>{Oe("msg-search",[]),Oe("msg-search-active",[])}),[a]);const S=r.useCallback(b=>{const E=t.current;if(!E)return;const R=E.querySelector(`[data-msg-id="${b}"]`);R&&(R.classList.remove("msg-flash"),R.offsetWidth,R.classList.add("msg-flash"))},[t]);r.useLayoutEffect(()=>{if(!a||!v)return;const b=t.current;if(!b)return;let E=!1,R=0;return R=requestAnimationFrame(()=>{var U;if(E)return;const{byMsg:T,all:N}=sa(b,v);Oe("msg-search",N);const u=M.current,y=u[Math.min(L.current,u.length-1)];if(!y)return;const A=(U=T.get(y.messageId))==null?void 0:U[y.occurrence];if(A){Oe("msg-search-active",[A]);const te=A.startContainer.parentElement??b.querySelector(`[data-msg-id="${y.messageId}"]`);te==null||te.scrollIntoView({block:"center"})}else S(y.messageId)}),()=>{E=!0,cancelAnimationFrame(R)}},[a,v,w,t,S]);const B=r.useCallback(b=>{const E=M.current;if(E.length===0)return;const R=(L.current+b+E.length)%E.length;f(R),c(E[R].messageId)},[c]);if(!a)return null;const j=w.length;return e.jsxs("div",{className:"search-bar",role:"search",children:[e.jsx("input",{ref:n,className:"search-input",type:"text",value:o,placeholder:i("searchPlaceholder"),onChange:b=>{d(b.target.value),f(0)},onKeyDown:b=>{b.key==="Enter"&&(b.preventDefault(),B(b.shiftKey?-1:1))}}),e.jsx("span",{className:`search-count ${j===0?"empty":""}`,children:j===0?i("searchNoResults"):`${Math.min(p+1,j)}/${j}`}),e.jsx("button",{type:"button",className:"search-btn",title:i("searchPrev"),disabled:j===0,onClick:()=>B(-1),children:e.jsx(dt,{})}),e.jsx("button",{type:"button",className:"search-btn",title:i("searchNext"),disabled:j===0,onClick:()=>B(1),children:e.jsx(_e,{})}),e.jsx("button",{type:"button",className:"search-btn",title:i("searchClose"),onClick:l,children:e.jsx(we,{})})]})}const gs=new Map,ia=15,fs=30,xs=1200,aa=1600;function vs(t){return t.content.some(s=>s.type==="toolCall")}const ra=[{key:"ex.understand",icon:"🔍"},{key:"ex.debug",icon:"🐛"},{key:"ex.test",icon:"🧪"},{key:"ex.review",icon:"🧹"}];function la(t){return ra.map(({key:s,icon:a})=>({icon:a,text:t(s),prompt:t(`${s}.prompt`)}))}function oa({state:t,liveOutputs:s,toolStatuses:a,onEdit:l,onKillBash:c,thinkingWrap:i,toolsWrap:n}){const o=he(),d=r.useRef(null),[p,f]=r.useState(!0),h=r.useRef(!0),v=r.useRef(0),w=r.useRef(!1),[M,L]=r.useState(()=>new Set),[S,B]=r.useState(!1),j=t.streamingMessage?[...t.messages,t.streamingMessage]:t.messages,b=r.useMemo(()=>{const k=new Map;for(const F of t.messages)F.role==="toolResult"&&F.toolCallId&&k.set(F.toolCallId,F);return k},[t.messages]),E=r.useMemo(()=>zi(t.messages),[t.messages]),R=j.length>0?j[j.length-1].id:null,T=t.messages.length>fs?Math.max(0,t.messages.length-ia):0,[N,u]=r.useState(()=>new Set),[y,A]=r.useState(()=>new Set),U=r.useRef(new Map),te=r.useRef(new Map),ue=r.useRef(0),ee=r.useRef(N);ee.current=N;const I=t.messages.length>fs&&!S,q=r.useRef(I);q.current=I;const H=Yi(t.messages,U.current,aa),me=r.useRef(H);me.current=H;const _=r.useCallback(()=>{const k=d.current;if(!k)return;if(!q.current){u(x=>x.size?new Set:x);return}const F=k.getBoundingClientRect(),re={top:F.top-xs,bottom:F.bottom+xs},se=[];for(const[x,Z]of te.current){const G=Z.getBoundingClientRect();se.push({id:x,top:G.top,bottom:G.bottom}),ee.current.has(x)||U.current.set(x,G.bottom-G.top)}const pe=Ji(se,re,me.current,ee.current);for(const x of pe.hide){const Z=te.current.get(x);Z&&U.current.set(x,Z.offsetHeight)}u(x=>Qi(x,pe))},[]),O=r.useCallback(()=>{ue.current||(ue.current=requestAnimationFrame(()=>{ue.current=0,_()}))},[_]);r.useLayoutEffect(()=>{_()},[_]);const C=r.useRef(S);r.useLayoutEffect(()=>{C.current&&!S&&_(),C.current=S},[S,_]);const Y=r.useCallback((k,F)=>{U.current.set(k,F)},[]),J=r.useCallback(k=>{k&&te.current.set(k.dataset.lazyId??"",k)},[]);r.useEffect(()=>{const k=new Set(t.messages.map(F=>F.id));for(const[F,re]of te.current)k.has(F)||(te.current.delete(F),U.current.delete(F));u(F=>{let re=!1;const se=new Set;for(const pe of F)k.has(pe)?se.add(pe):re=!0;return re?se:F})},[t.messages,M]),r.useEffect(()=>()=>cancelAnimationFrame(ue.current),[]);const ie=r.useMemo(()=>{const k=[];for(const F of t.messages){if(F.role!=="user")continue;const re=F.content.map(x=>{var Z;return((Z=Ye(x))==null?void 0:Z.text)??""}).filter(Boolean).join(" "),se=Lt(re),pe=se?se.userMessage??`skill:${se.name}`:re.trim();pe&&k.push({id:F.id,text:pe})}return k},[t.messages]),$=r.useMemo(()=>{const k=new Map;return ie.forEach((F,re)=>k.set(F.id,re)),k},[ie]),[V,le]=r.useState(-1),K=r.useRef(-1),oe=r.useRef(ie);r.useEffect(()=>{oe.current=ie},[ie]);const g=r.useCallback(()=>{const k=d.current,F=oe.current;if(!k||F.length===0)return;const re=k.getBoundingClientRect().top,se=140;let pe=-1;for(let x=0;x<F.length;x++){const Z=k.querySelector(`[data-msg-id="${F[x].id}"]`);if(Z)if(Z.getBoundingClientRect().top<=re+se)pe=x;else break}pe!==K.current&&(K.current=pe,le(pe))},[]);r.useEffect(()=>{g()},[ie,g]);const m=r.useCallback(k=>{L(F=>F.has(k)?F:new Set(F).add(k))},[]),D=r.useCallback(k=>{const F=t.messages.findIndex(re=>re.id===k);F>=0&&F<T&&!M.has(k)&&os.flushSync(()=>m(k))},[t.messages,T,M,m]);r.useEffect(()=>{const k=F=>{if(!(F.ctrlKey||F.metaKey)||F.key.toLowerCase()!=="f")return;const re=F.target;re&&(re.tagName==="INPUT"||re.tagName==="TEXTAREA"||re.isContentEditable)||(F.preventDefault(),B(!0))};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[]);const X=r.useCallback(k=>{L(F=>{if(!F.has(k))return F;const re=new Set(F);return re.delete(k),re})},[]),de=r.useCallback(k=>{const F=t.messages.findIndex(se=>se.id===k);os.flushSync(()=>{F>=0&&F<T&&!M.has(k)&&m(k),A(se=>se.has(k)?se:new Set(se).add(k))});const re=oe.current.findIndex(se=>se.id===k);K.current=re,le(re),requestAnimationFrame(()=>{var pe,x,Z;const se=(pe=d.current)==null?void 0:pe.querySelector(`[data-msg-id="${k}"]`);se&&((x=d.current)==null||x.querySelectorAll(".msg-flash").forEach(G=>G.classList.remove("msg-flash")),se.scrollIntoView({block:"start"}),se.classList.remove("msg-flash"),se.offsetWidth,se.classList.add("msg-flash"),se!==((Z=d.current)==null?void 0:Z.lastElementChild)&&(w.current=!0))})},[t.messages,T,M,m]),xe=r.useCallback(()=>{const k=d.current;if(!k)return;const F=k.scrollTop-v.current;v.current=k.scrollTop;const re=k.scrollHeight-k.scrollTop-k.clientHeight<80;F<-4&&F>-500?w.current=!0:re&&F>=0&&(w.current=!1),h.current=re&&!w.current,f(h.current),g(),O()},[g,O]),Q=r.useRef(!1);r.useEffect(()=>{const k=Q.current;if(Q.current=!!t.isStreaming,k&&!t.isStreaming&&!w.current){const F=()=>{const se=d.current;se&&!w.current&&(se.scrollTop=se.scrollHeight,h.current=!0,f(!0))};requestAnimationFrame(()=>requestAnimationFrame(F));const re=setTimeout(F,180);return()=>clearTimeout(re)}},[t.isStreaming]),r.useEffect(()=>{const k=d.current;k&&h.current&&(k.scrollTop=k.scrollHeight)},[j,t.isStreaming,s]);const ce=t.queue.steering.join("\0")+""+t.queue.followUp.join("\0");r.useEffect(()=>{const k=d.current;k&&h.current&&(k.scrollTop=k.scrollHeight)},[ce]);const ae=r.useCallback(()=>{const k=d.current;k&&(k.scrollTop=k.scrollHeight),h.current=!0,w.current=!1,f(!0)},[]),Ne=r.useRef(null);r.useEffect(()=>{const k=Ne.current,F=d.current;if(!k||!F)return;const re=se=>{se.preventDefault();const pe=k.querySelector(".qn-list");if(pe&&pe.contains(se.target)&&pe.scrollHeight>pe.clientHeight){pe.scrollTop+=se.deltaY;return}F.scrollTop+=se.deltaY};return k.addEventListener("wheel",re,{passive:!1}),()=>k.removeEventListener("wheel",re)},[]);const[Te,Ie]=r.useState(0);r.useEffect(()=>{const k=()=>{var F;Ie(((F=d.current)==null?void 0:F.clientHeight)??0),O()};return k(),window.addEventListener("resize",k),()=>window.removeEventListener("resize",k)},[O]);const Le=ie.length,Fe=r.useMemo(()=>Le===0?27:Math.max(4,Math.min(27,Math.floor(((Te||600)-16)/Le)-3)),[Le,Te]),Ae=Fe<20;return e.jsxs("div",{className:"messages-wrap",children:[e.jsxs("div",{className:"messages",ref:d,onScroll:xe,children:[t.messages.length===0&&!t.streamingMessage&&e.jsxs("div",{className:"empty-state",children:[e.jsx("div",{className:"empty-logo-wrap",children:e.jsx("div",{className:"empty-logo",children:"π"})}),e.jsx("h2",{className:"empty-title",children:o("welcomeTitle")}),e.jsx("p",{className:"empty-sub",children:o("welcomeSub")}),e.jsxs("div",{className:"empty-cwd",children:[e.jsx("span",{className:"empty-cwd-label",children:o("directory")}),e.jsx("span",{className:"empty-cwd-path",children:t.cwd})]}),e.jsx("div",{className:"empty-examples",children:la(o).map(k=>e.jsxs("button",{type:"button",className:"empty-example",title:o("clickToFill"),onClick:()=>window.dispatchEvent(new CustomEvent("pi-web:fill",{detail:k.prompt})),children:[e.jsx("span",{className:"empty-example-icon",children:k.icon}),e.jsx("span",{className:"empty-example-text",children:k.text})]},k.prompt))})]}),t.messages.map((k,F)=>{const re=F<T,se=re&&M.has(k.id);if(re&&!se)return k.role==="toolResult"?null:e.jsx(Ki,{message:k,onExpand:m},k.id);const pe=k.role==="user"?$.get(k.id):void 0,x=!I||H.has(k.id)||y.has(k.id)||!N.has(k.id);return e.jsx(Gi,{id:k.id,show:x,height:U.current.get(k.id)??Js(k.role,k.customType),containerRef:d,onMeasured:Y,lazyRef:J,children:e.jsx(us,{message:k,qnIndex:pe,qnActive:pe!==void 0?pe===V:void 0,onJump:de,toolResults:b,liveOutputs:vs(k)?s:gs,toolStatuses:a,streaming:t.isStreaming,onKillBash:c,toolsWrap:n,thinkingWrap:i,isLast:k.id===R,onEdit:l,questionAttachments:E.get(k.id),onCollapse:se?X:void 0},k.id)},k.id)}),t.streamingMessage&&e.jsx(us,{message:t.streamingMessage,toolResults:b,liveOutputs:vs(t.streamingMessage)?s:gs,toolStatuses:a,streaming:!0,isLast:!0,onEdit:l,onKillBash:c,toolsWrap:n,thinkingWrap:i},t.streamingMessage.id),t.isStreaming&&j.length===0&&e.jsx("div",{className:"streaming-wait",children:o("waitingResponse")}),t.queue.steering.map((k,F)=>e.jsx("div",{className:"queued-msg",children:e.jsxs("div",{className:"queued-bubble",children:[e.jsx("span",{className:"queued-tag steer",children:o("queueSteerTag")}),e.jsx("div",{className:"queued-text",children:k})]})},`q-steer-${F}`)),t.queue.followUp.map((k,F)=>e.jsx("div",{className:"queued-msg",children:e.jsxs("div",{className:"queued-bubble",children:[e.jsx("span",{className:"queued-tag follow",children:o("queueFollowTag")}),e.jsx("div",{className:"queued-text",children:k})]})},`q-fu-${F}`))]}),!p&&e.jsxs("button",{type:"button",className:"scroll-bottom",onClick:ae,children:[e.jsx(Bs,{})," ",o("backToBottom")]}),e.jsx(na,{containerRef:d,messages:j,open:S,onClose:()=>B(!1),onEnsureExpanded:D}),ie.length>0&&e.jsxs("div",{className:`qn-rail ${Ae?"many":""}`,ref:Ne,"aria-label":o("questionNavTitle"),style:{"--rail-gap":`${Fe}px`},children:[ie.map((k,F)=>e.jsx("button",{type:"button",className:`qn-bar ${F===V?"active":""}`,"aria-label":`${F+1}. ${k.text}`,onClick:()=>de(k.id),children:e.jsxs("span",{className:"qn-bar-text",children:[F+1,". ",k.text]})},k.id)),Ae&&e.jsx("div",{className:"qn-list",children:ie.map((k,F)=>e.jsxs("button",{type:"button",className:`qn-list-item ${F===V?"active":""}`,"aria-label":`${F+1}. ${k.text}`,onClick:()=>de(k.id),children:[e.jsx("span",{className:"qn-list-idx",children:F+1}),e.jsx("span",{className:"qn-list-text",children:k.text})]},k.id))})]})]})}const ca=["off","minimal","low","medium","high","xhigh","max"],da=r.memo(function({state:s,models:a,modelsLoading:l,send:c,onManageModels:i,compact:n=!1}){const o=he(),d=s==null?void 0:s.model,p=d?`${d.provider}/${d.id}`:null,[f,h]=r.useState(!1),[v,w]=r.useState(!1),[M,L]=r.useState(""),[S,B]=r.useState(null);r.useEffect(()=>{f||(L(""),B(null))},[f]);const j=r.useMemo(()=>{const y=new Map;for(const A of a)y.set(A.provider,(y.get(A.provider)??0)+1);return[...y.entries()].sort((A,U)=>A[0].localeCompare(U[0])).map(([A,U])=>({name:A,count:U}))},[a]),b=r.useMemo(()=>{let y=a;S&&(y=y.filter(U=>U.provider===S));const A=M.trim().toLowerCase();return A?y.filter(U=>U.name.toLowerCase().includes(A)||U.provider.toLowerCase().includes(A)||U.id.toLowerCase().includes(A)):y},[a,M,S]),[E,R]=r.useState(!1),T=s!=null&&s.availableThinkingLevels&&s.availableThinkingLevels.length>0?new Set(s.availableThinkingLevels):null,N=ca.map(y=>({value:y,label:o(`thinking.${y}`),supported:T?T.has(y):!0})),u=y=>{var A;return((A=N.find(U=>U.value===y))==null?void 0:A.label)??y};return r.useEffect(()=>{f&&a.length===0&&!E&&!l&&(R(!0),c({type:"list_models"}))},[f,a.length,E,l,c]),r.useEffect(()=>{a.length>0&&R(!1)},[a.length]),e.jsxs(e.Fragment,{children:[e.jsxs(Re,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(Qe,{}),e.jsx("span",{className:"chip-model",children:d?d.name:o("selectModel")}),!n&&(d==null?void 0:d.vision)&&e.jsx("span",{className:"chip-vision",title:o("vision"),children:"🖼"}),!n&&d&&e.jsx("span",{className:"chip-sub",children:d.provider})]}),open:f,onOpenChange:h,menuClassName:"dd-menu-model",direction:"up",children:[e.jsx("div",{className:"dd-header",children:o("availableModels")}),e.jsxs("div",{className:"dd-search-row",children:[e.jsx(lt,{}),e.jsx("input",{className:"dd-search",type:"text",placeholder:o("searchModels"),value:M,onChange:y=>L(y.target.value)})]}),e.jsxs("div",{className:"dd-model-body",children:[j.length>1&&e.jsxs("div",{className:"dd-provider-col",children:[e.jsx("div",{className:"dd-provider-head",children:o("providers")}),e.jsx("button",{type:"button",className:`dd-provider-item ${S===null?"active":""}`,onClick:()=>B(null),children:e.jsx("span",{children:o("allProviders")})}),j.map(y=>e.jsxs("button",{type:"button",className:`dd-provider-item ${S===y.name?"active":""}`,onClick:()=>B(S===y.name?null:y.name),title:`${y.name} · ${y.count}`,children:[e.jsx("span",{className:"dd-provider-name",children:y.name}),e.jsx("span",{className:"dd-provider-count",children:y.count})]},y.name))]}),e.jsxs("div",{className:"dd-model-scroll",children:[(E||l)&&e.jsx("div",{className:"dd-loading",children:o("loading")}),a.length===0&&!E&&!l&&e.jsx("div",{className:"dd-loading",children:o("noModels")}),b.length===0&&a.length>0&&e.jsx("div",{className:"dd-loading",children:o("noModelMatches")}),b.map(y=>e.jsx(ke,{active:p===y.id,onClick:()=>{p!==y.id&&c({type:"set_model",modelId:y.id}),h(!1)},children:e.jsxs("span",{className:"dd-model-cell",children:[e.jsx("span",{className:"dd-model-name",children:y.name}),e.jsxs("span",{className:"dd-model-meta",children:[e.jsx("span",{className:"dd-model-provider",children:y.provider}),(y.reasoning||y.vision)&&e.jsxs("span",{className:"dd-model-badges",children:[y.reasoning&&e.jsx("span",{className:"dd-model-badge",children:o("reasoning")}),y.vision&&e.jsx("span",{className:"dd-model-badge",children:o("vision")})]})]})]})},y.id))]})]}),e.jsxs("div",{className:"dd-footer",children:[e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>c({type:"list_models"}),children:o("refreshModels")}),e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>{h(!1),i()},children:o("manageModels")})]})]}),e.jsxs(Re,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(et,{}),e.jsx("span",{className:"chip-sub",children:o("thinkingChip",{level:s?u(s.thinkingLevel):"—"})})]}),open:v,onOpenChange:w,direction:"up",children:[e.jsx("div",{className:"dd-header",children:o("thinkingLevel")}),N.map(y=>e.jsx(ke,{active:(s==null?void 0:s.thinkingLevel)===y.value,disabled:!y.supported,title:y.supported?void 0:o("thinkingUnsupported"),onClick:()=>{(s==null?void 0:s.thinkingLevel)!==y.value&&c({type:"set_thinking",level:y.value}),w(!1)},children:y.label},y.value))]})]})}),ua=r.memo(function({ready:s,streaming:a,messages:l,slashCommands:c,modelState:i,models:n,modelsLoading:o,send:d,attachments:p,onRemoveAttachment:f,onAddImageFiles:h,onAddLocalFiles:v,onNotice:w,onSent:M,onManageModels:L}){const S=he(),{locale:B}=Rt(),j=g=>B==="en"&&g.descriptionEn?g.descriptionEn:g.description??"",b=g=>B==="en"&&g.argumentHintEn?g.argumentHintEn:g.argumentHint??"",[E,R]=r.useState(""),[T,N]=r.useState(!1),[u,y]=r.useState(null),[A,U]=r.useState(0),[te,ue]=r.useState(!1),[ee,I]=r.useState(void 0),q=r.useRef(null),H=r.useRef(null),me=r.useRef(null),_={builtin:S("slashBuiltin"),extension:S("slashExtension"),prompt:S("slashPrompt"),skill:S("slashSkill"),plugin:S("slashPlugin")},O=g=>{const m=g.match(/^\/([^\s]*)$/);if(m&&s){const D=m[1].toLowerCase(),X=c.filter(de=>de.name.toLowerCase().startsWith(D));y(X.length>0?X:null),U(0)}else y(null)};r.useEffect(()=>{var m;const g=(m=me.current)==null?void 0:m.querySelector(".slash-item.active");g==null||g.scrollIntoView({block:"nearest"})},[A,u]);const C=g=>{var xe;const m=u??[],D=g??m[A%Math.max(m.length,1)];if(!D){y(null);return}const X=E.match(/^\/([^\s]*)([\s\S]*)$/),de=X?X[2]:"";R(`/${D.name} ${de}`),y(null),(xe=q.current)==null||xe.focus()},Y=async()=>{const m=[...l].reverse().find(X=>X.role==="assistant"&&X.content.some(de=>de.type==="text"&&de.text)),D=m==null?void 0:m.content.filter(X=>X.type==="text").map(X=>X.text).join(`
17
+ `);if(!D){w("warning",S("slashCopyEmpty"));return}try{await navigator.clipboard.writeText(D),w("info",S("slashCopied"))}catch{w("error",S("slashCopyFailed"))}},J=g=>{if(!g||g.length===0){w("warning",S("foldersNotSupported"));return}const m=Array.from(g).filter(X=>Me(X.type)),D=Array.from(g).filter(X=>!Me(X.type));m.length>0&&h(m),D.length>0&&v(D)},ie=g=>{var X;const m=(X=g.clipboardData)==null?void 0:X.items;if(!m)return;const D=[];for(const de of m)if(de.kind==="file"&&Me(de.type)){const xe=de.getAsFile();xe&&D.push(xe)}D.length!==0&&(g.preventDefault(),h(D))},$=s,V=r.useRef(E);r.useEffect(()=>{V.current=E},[E]),r.useEffect(()=>{O(V.current)},[c]),r.useEffect(()=>{const g=m=>{var X;const D=m.detail;R(D),(X=q.current)==null||X.focus()};return window.addEventListener("pi-web:fill",g),()=>window.removeEventListener("pi-web:fill",g)},[]),r.useEffect(()=>{if(!te)return;const g=m=>{m.key==="Escape"&&ue(!1)};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[te]),r.useEffect(()=>{const g=q.current;if(!g)return;g.style.height="auto";const m=g.scrollHeight>220;g.style.height=`${Math.min(g.scrollHeight,220)}px`,g.style.overflowY=m?"auto":"hidden"},[E]);const le=(g=!1)=>{var X,de,xe,Q,ce;const m=E.trim(),D=p.some(ae=>ae.imageData||ae.fileData);if(!(!$||!m&&!D)){if(m==="/help"){const ae=(de=(X=q.current)==null?void 0:X.closest(".inputbox"))==null?void 0:de.getBoundingClientRect();I(ae==null?void 0:ae.width),ue(!0),R(""),(xe=q.current)==null||xe.focus();return}if(m==="/copy"){R(""),(Q=q.current)==null||Q.focus(),Y();return}d({type:"prompt",text:m,queue:g,attachments:p.map(ae=>ae.imageData?{path:"",imageData:ae.imageData,mimeType:ae.mimeType,name:ae.name}:ae.fileData?{path:"",fileData:ae.fileData,mimeType:ae.mimeType,name:ae.name,size:ae.size}:{path:ae.path,mode:ae.mode,...ae.lines?{lines:ae.lines}:{}})})&&(R(""),M(),(ce=q.current)==null||ce.focus())}},K=g=>{if(!g.nativeEvent.isComposing){if(u&&u.length>0)switch(g.key){case"ArrowDown":g.preventDefault(),U(m=>(m+1)%u.length);return;case"ArrowUp":g.preventDefault(),U(m=>(m-1+u.length)%u.length);return;case"Tab":case"Enter":g.preventDefault(),C();return;case"Escape":g.preventDefault(),y(null);return}g.key==="Enter"&&!g.shiftKey&&(g.preventDefault(),le())}},oe=()=>e.jsx("div",{className:"inputbox-actions",children:a?e.jsxs(e.Fragment,{children:[E.trim()!==""&&e.jsxs("button",{type:"button",className:"btn supplement",title:S("supplementTip"),onClick:()=>le(!0),children:[e.jsx(Nn,{})," ",S("supplement")]}),e.jsx("button",{type:"button",className:"btn stop",title:S("stopAgent"),onClick:()=>d({type:"abort"}),children:e.jsx(at,{})})]}):e.jsx("button",{type:"button",className:"btn send",title:S("sendTip"),disabled:!$||!E.trim()&&!p.some(g=>g.imageData||g.fileData),onClick:()=>le(),children:e.jsx(Ls,{})})});return e.jsxs("div",{className:`inputbar${T?" drop-active":""}`,onDragOver:g=>{g.preventDefault(),g.stopPropagation(),N(!0)},onDragLeave:g=>{g.currentTarget.contains(g.relatedTarget)||N(!1)},onDrop:g=>{var m;g.preventDefault(),g.stopPropagation(),N(!1),J(((m=g.dataTransfer)==null?void 0:m.files)??null)},children:[T&&e.jsx("div",{className:"drop-overlay",children:e.jsxs("span",{children:["📎 ",S("dropHereToAttach")]})}),p.length>0&&e.jsxs("div",{className:"attach-row",children:[p.map(g=>e.jsxs("span",{className:`attach-chip ${g.imageData?"image":g.fileData?"file":g.mode}`,title:g.imageData?S("attachImage",{name:g.name}):g.fileData?S("attachFile",{name:g.name}):g.isDir?S("folderRef",{path:g.path}):g.mode==="reference"?S("refOnly",{path:g.path}):g.mode==="lines"&&g.lines?S("attachLines",{path:g.path,start:g.lines.start,end:g.lines.end}):S("attachContent",{path:g.path}),children:[g.imageData?"🖼":g.fileData?"📄":g.isDir?"📁":g.mode==="reference"?"🔗":"📎"," ",g.name,g.mode==="lines"&&g.lines&&e.jsxs("span",{className:"attach-range",children:["L",g.lines.start,"-",g.lines.end]}),e.jsx("button",{type:"button",className:"attach-remove",title:S("removeAttachment"),onClick:()=>f(g.key??g.path),children:"×"})]},g.key??`${g.path}|${g.mode}|${g.lines?`${g.lines.start}-${g.lines.end}`:""}`)),e.jsx("span",{className:"attach-hint",children:S("attachHint")})]}),u&&u.length>0&&e.jsxs("div",{className:"slash-menu",role:"listbox",ref:me,"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:()=>y(null),children:"Esc"})]}),u.map((g,m)=>e.jsxs("button",{type:"button",className:`slash-item${m===A?" active":""}`,onMouseEnter:()=>U(m),onClick:()=>C(g),children:[e.jsxs("span",{className:"slash-name",children:["/",g.name]}),e.jsx("span",{className:`slash-source ${g.source}`,children:_[g.source]}),e.jsxs("span",{className:"slash-desc",children:[j(g),g.argumentHint&&e.jsx("span",{className:"slash-hint",children:b(g)})]})]},g.name))]}),te&&e.jsx("div",{className:"modal-backdrop",onClick:()=>ue(!1),children:e.jsxs("div",{className:"slash-help",style:ee?{width:ee}:void 0,onClick:g=>g.stopPropagation(),children:[e.jsxs("div",{className:"slash-help-head",children:[e.jsxs("span",{children:["⚡ ",S("slashHelpTitle")]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>ue(!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(g=>e.jsxs("div",{className:"slash-help-row",children:[e.jsxs("span",{className:"slash-help-cmd",children:["/",g.name]}),e.jsx("span",{className:`slash-source ${g.source}`,children:_[g.source]}),e.jsxs("span",{className:"slash-help-desc",children:[j(g),g.argumentHint&&e.jsx("span",{className:"slash-hint",children:b(g)})]})]},g.name))})]})}),e.jsxs("div",{className:"inputbox",children:[e.jsx("input",{ref:H,type:"file",multiple:!0,hidden:!0,onChange:g=>{J(g.target.files),g.target.value=""}}),e.jsx("textarea",{ref:q,value:E,rows:1,placeholder:S($?a?"placeholderStreaming":"placeholderIdle":"placeholderConnecting"),disabled:!$,onChange:g=>{R(g.target.value),O(g.target.value)},onKeyDown:K,onPaste:ie}),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:!$,onClick:()=>{var g;return(g=H.current)==null?void 0:g.click()},children:e.jsx(Sn,{})}),e.jsx(da,{state:i,models:n,modelsLoading:o,send:d,onManageModels:L,compact:!0})]}),e.jsx("div",{className:"composer-tools-right",children:oe()})]})]})]})}),ma=r.memo(function({goal:s,models:a,modelsLoading:l,activeConversationId:c,send:i}){var U,te,ue,ee,I,q;const n=he(),o=!s.conversationId||s.conversationId===c,d=s.goal!==null&&o,[p,f]=r.useState(""),[h,v]=r.useState(s.reviewModel??""),[w,M]=r.useState(s.maxRounds),[L,S]=r.useState(s.locked),[B,j]=r.useState(!1),[b,E]=r.useState(!1),[R,T]=r.useState(!0);r.useEffect(()=>{v(s.reviewModel??""),M(s.maxRounds||0),S(s.locked)},[s.goal,s.reviewModel,s.maxRounds,s.locked]),r.useEffect(()=>{B&&a.length===0&&!b&&!l&&(E(!0),i({type:"list_models"}))},[B,a.length,b,l,i]),r.useEffect(()=>{a.length>0&&E(!1)},[a.length]);const N=()=>{var H;return h?((H=a.find(me=>me.id===h))==null?void 0:H.name)??h:n("goalBarUseMainModel")},u=()=>{const H=p.trim();H&&(i({type:"set_goal",goal:H,...h?{reviewModel:h}:{},maxRounds:w,locked:L}),f(""),T(!1))},y=()=>{const H=p.trim();H&&(i({type:"start_goal_wizard",text:H,...h?{wizardModel:h}:{},maxRounds:w,locked:L}),f(""),T(!1))},A=(((U=s.wizard)==null?void 0:U.active)??!1)&&o;return A?e.jsx("div",{className:`goalbar goalbar-active ${A?"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:((te=s.wizard)==null?void 0:te.draft)??"",children:[n("goalWizardRunning"),": ",(ue=s.wizard)==null?void 0:ue.draft]}),e.jsxs("span",{className:"goalbar-chip reviewing",children:[n("goalBarRound",{n:(((ee=s.wizard)==null?void 0:ee.step)??0)+1})," ","/ ",((I=s.wizard)==null?void 0:I.maxSteps)??6]}),e.jsx("span",{className:"goalbar-detail",children:((q=s.wizard)==null?void 0:q.status)||n("goalBarReviewing")}),e.jsx("button",{type:"button",className:"goalbar-x",title:n("goalBarClear"),onClick:()=>{i({type:"clear_goal"}),T(!0)},children:e.jsx(we,{})})]})}):d?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:[n("goalBarReviewing")," ",n("goalBarRound",{n:s.round})]}):e.jsx("span",{className:`goalbar-chip ${s.verdict==="pass"?"pass":s.verdict==="fail"?"fail":""}`,children:s.verdict==="pass"?n("goalBarPassed"):s.verdict==="fail"?n("goalBarFailed"):`${n("goalBarRound",{n:s.round||1})} · ${s.locked?n("goalBarLocked"):n("goalBarUnlocked")}`}),e.jsx("span",{className:"goalbar-detail",children:s.status}),e.jsx("button",{type:"button",className:"goalbar-x",title:n("goalBarClear"),disabled:s.reviewing,onClick:()=>{i({type:"clear_goal"}),T(!0)},children:e.jsx(we,{})})]})}):R?e.jsx("div",{className:"goalbar goalbar-collapsed",children:e.jsxs("button",{type:"button",className:"goalbar-hint",title:n("goalBarPlaceholder"),onClick:()=>T(!1),children:[e.jsx(Qt,{})," ",e.jsx("span",{children:n("goalBarTitle")})]})}):e.jsxs("div",{className:"goalbar",children:[e.jsxs("div",{className:"goalbar-row",children:[e.jsx("span",{className:"goalbar-icon",children:e.jsx(Qt,{})}),e.jsx("input",{className:"goalbar-input",value:p,placeholder:n("goalBarPlaceholder"),onChange:H=>f(H.target.value),onKeyDown:H=>{H.key==="Enter"&&u()}}),e.jsx("button",{type:"button",className:"goalbar-btn",disabled:!p.trim(),onClick:u,children:n("goalBarSet")}),e.jsxs("button",{type:"button",className:"goalbar-btn wizard",disabled:!p.trim(),title:n("goalWizardTip"),onClick:y,children:["🔍 ",n("goalWizardBtn")]}),e.jsx("button",{type:"button",className:"goalbar-icon-btn",title:n(L?"goalBarLocked":"goalBarUnlocked"),onClick:()=>S(H=>(i({type:"set_goal_prefs",locked:!H}),!H)),children:L?e.jsx(In,{}):e.jsx(bn,{})}),e.jsx("button",{type:"button",className:"goalbar-icon-btn",title:n("goalBarClear"),onClick:()=>T(!0),children:e.jsx(dt,{})})]}),e.jsxs("div",{className:"goalbar-opts",children:[e.jsxs(Re,{trigger:e.jsxs("span",{className:"goalbar-opt",children:[n("goalBarReviewModel"),": ",e.jsx("b",{children:N()})]}),open:B,onOpenChange:j,direction:"up",children:[e.jsx("div",{className:"dd-header",children:n("goalBarReviewModel")}),(b||l)&&e.jsx("div",{className:"dd-loading",children:n("loading")}),a.length===0&&!b&&!l&&e.jsx("div",{className:"dd-loading",children:n("noModels")}),e.jsx(ke,{active:h==="",onClick:()=>{v(""),j(!1),i({type:"set_goal_prefs",reviewModel:""})},children:n("goalBarUseMainModel")}),a.map(H=>e.jsx(ke,{active:h===H.id,onClick:()=>{v(H.id),j(!1),i({type:"set_goal_prefs",reviewModel:H.id})},children:e.jsxs("span",{className:"dd-model-cell",children:[e.jsx("span",{className:"dd-model-name",children:H.name}),e.jsx("span",{className:"dd-model-meta",children:e.jsx("span",{className:"dd-model-provider",children:H.provider})})]})},H.id)),e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>i({type:"list_models"}),children:n("refreshModels")})]}),e.jsxs("label",{className:"goalbar-round",title:n("goalBarMaxRoundsTip"),children:[e.jsx("span",{children:n("goalBarMaxRounds")}),e.jsx("input",{type:"number",min:0,step:1,value:w,placeholder:n("goalBarUnlimitedShort"),onChange:H=>{const me=parseInt(H.target.value,10);if(Number.isNaN(me)||me<0){M(0);return}M(me)},onBlur:()=>i({type:"set_goal_prefs",maxRounds:w}),onKeyDown:H=>{H.key==="Enter"&&(i({type:"set_goal_prefs",maxRounds:w}),H.target.blur())}})]}),e.jsx("span",{className:"goalbar-lock-hint",children:n(L?"goalBarLocked":"goalBarUnlocked")})]})]})});function pa({chat:t,send:s}){const a=he(),l=t.state,[c,i]=r.useState(!1),[n,o]=r.useState(""),[d,p]=r.useState(0),f=r.useRef(null),h=t.pathCompletions;if(r.useEffect(()=>{if(!c)return;const u=setTimeout(()=>{s({type:"complete_path",path:n})},150);return()=>clearTimeout(u)},[n,c,s]),r.useEffect(()=>p(0),[h]),r.useEffect(()=>{const u=document.querySelector(`.status-completions .pc-item[data-idx="${d}"]`);u==null||u.scrollIntoView({block:"nearest"})},[d]),!l)return null;const v=l.stats,w=t.ready?"ok":"busy",M=t.ready?a("connected"):a("connecting"),L=v.contextUsage,S=L.tokens!==null&&L.percent!==null?`${ys(L.tokens)} / ${ys(L.contextWindow)}`:"—",B=L.percent??null,j=B===null?"":B>=80?"warn":B>=50?"mid":"ok",b=l.queue.steering.length+l.queue.followUp.length,E=()=>{o(l.cwd),i(!0)},R=(u,y)=>{var U;const A=u.includes("\\")?"\\":"/";o(y?`${u}${A}`:u),p(0),(U=f.current)==null||U.focus()},T=u=>{const y=u.trim();y&&y!==l.cwd&&s({type:"set_cwd",path:y}),i(!1)},N=u=>{if(u.key==="ArrowDown")u.preventDefault(),p(y=>Math.min(y+1,h.length-1));else if(u.key==="ArrowUp")u.preventDefault(),p(y=>Math.max(y-1,0));else if(u.key==="Tab"&&h.length>0){u.preventDefault();const y=h[Math.min(d,h.length-1)];R(y.path,y.type==="dir")}else if(u.key==="Enter"&&!u.nativeEvent.isComposing){const y=n.trim();if(y.endsWith("/")||y.endsWith("\\"))T(y);else if(h.some(A=>A.path===y))T(y);else if(h.length>0&&h[d]){u.preventDefault();const A=h[d];R(A.path,A.type==="dir")}else T(y)}else u.key==="Escape"&&(h.length>0?(u.stopPropagation(),s({type:"complete_path",path:""})):i(!1))};return e.jsxs("footer",{className:"statusbar",children:[e.jsx("span",{className:`status-dot ${w}`,title:M}),e.jsx("span",{className:"status-item",children:M}),e.jsx("span",{className:"status-sep",children:"·"}),e.jsxs("span",{className:"status-item status-ctx",title:a("contextUsage"),children:[a("context"),e.jsx("span",{className:`ctx-bar ${j}`,children:B!==null&&e.jsx("span",{className:"ctx-bar-fill",style:{width:`${Math.min(B,100)}%`}})}),S]}),e.jsx("span",{className:"status-sep",children:"·"}),e.jsxs("span",{className:"status-item",title:a("cumulativeCost"),children:["$",ha(v.cost)]}),e.jsx("span",{className:"status-sep",children:"·"}),e.jsxs("span",{className:"status-item",title:a("sessionMessages"),children:[a("messages")," ",v.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:a("pluginStatus"),children:t.statuses.map(u=>u.text).join(" · ")})]}),l.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"}),a("working"),b>0&&e.jsxs("span",{className:"status-queue",children:["⏳ ",b," ",a("queued")]})]})]}),c?e.jsxs("div",{className:"status-cwd-wrap",children:[e.jsx("input",{ref:f,className:"status-cwd-input",value:n,autoFocus:!0,placeholder:a("enterPath"),onChange:u=>o(u.target.value),onKeyDown:N,onBlur:()=>i(!1)}),h.length>0&&e.jsx("ul",{className:"status-completions",onMouseDown:u=>u.preventDefault(),children:h.map((u,y)=>e.jsx("li",{children:e.jsxs("button",{type:"button","data-idx":y,className:`pc-item ${y===d?"sel":""}`,onMouseEnter:()=>p(y),onClick:()=>R(u.path,u.type==="dir"),children:[e.jsx("span",{className:"pc-icon",children:u.type==="dir"?e.jsx(Ke,{}):e.jsx(Rs,{})}),e.jsxs("span",{className:"pc-body",children:[e.jsx("span",{className:"pc-name",children:u.name}),e.jsx("span",{className:"pc-path",children:u.path})]})]})},u.path))})]}):e.jsxs("button",{type:"button",className:"status-item status-cwd",title:a("cwdTip",{path:l.cwd}),onClick:E,children:["📁 ",l.cwd]})]})}function ys(t){return t>=1e3?`${(t/1e3).toFixed(1).replace(/\.0$/,"")}K`:String(t)}function ha(t){return t<=0?"0":t<1e-4?"<0.0001":t.toFixed(4).replace(/\.?0+$/,"")}function ga({dialog:t,send:s}){const a=he(),[l,c]=r.useState(""),[i,n]=r.useState(0),o=f=>{s({type:"dialog_response",id:t.id,value:f})};r.useEffect(()=>{c(""),n(0);const f=h=>{h.key==="Escape"&&o(null)};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[t.id]);const d=Array.isArray(t.args[0])?t.args[0]:[],p=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:a("pluginRequest")}),t.title&&t.title!==a("pluginRequest")&&e.jsx("span",{className:"dialog-title",children:t.title}),e.jsx("button",{type:"button",className:"dialog-dismiss",title:a("cancel"),onClick:()=>o(null),children:"✕"})]}),t.kind==="select"&&e.jsxs("div",{className:"dialog-options",children:[d.map((f,h)=>e.jsx("button",{type:"button",className:`dialog-option ${h===i?"sel":""}`,onMouseEnter:()=>n(h),onClick:()=>o(f),children:f},h)),d.length===0&&e.jsx("div",{className:"dialog-hint",children:a("noOptions")})]}),t.kind==="confirm"&&e.jsxs("div",{className:"dialog-body",children:[e.jsx("p",{children:p}),e.jsxs("div",{className:"dialog-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>o(!1),children:a("cancel")}),e.jsx("button",{type:"button",className:"btn primary",onClick:()=>o(!0),children:a("ok")})]})]}),t.kind==="input"&&e.jsxs("div",{className:"dialog-body",children:[e.jsx("input",{className:"dialog-input",value:l,placeholder:p||a("inputPlaceholder"),autoFocus:!0,onChange:f=>c(f.target.value),onKeyDown:f=>{f.key==="Enter"&&!f.nativeEvent.isComposing&&o(l)}}),e.jsxs("div",{className:"dialog-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>o(null),children:a("cancel")}),e.jsx("button",{type:"button",className:"btn primary",onClick:()=>o(l),children:a("ok")})]})]})]})}function fa(t){if(t.x==="?"&&t.y==="?")return"untracked";const s=t.x!==" "&&t.x!=="?",a=t.y!==" "&&t.y!=="?";return s&&a?"both":s?"staged":"unstaged"}function xa({chat:t,send:s,terminal:a,active:l,onSwitchToTerminal:c}){var se,pe;const i=he(),[n,o]=r.useState(null),[d,p]=r.useState([]),[f,h]=r.useState(""),[v,w]=r.useState(new Map),[M,L]=r.useState("changes"),[S,B]=r.useState([]),[j,b]=r.useState(null),[E,R]=r.useState(""),[T,N]=r.useState(!1),[u,y]=r.useState(null),[A,U]=r.useState(null),[te,ue]=r.useState(!1),[ee,I]=r.useState(!1),[q,H]=r.useState(!1),[me,_]=r.useState(null),[O,C]=r.useState(!1),[Y,J]=r.useState(""),ie=r.useRef(0),$=r.useRef(-1),V=r.useRef(-1),le=r.useRef(-1),K=r.useRef(-1),oe=r.useRef(void 0),g=r.useRef(null),m=r.useRef([]),D=r.useCallback(x=>{if(x.reqId===$.current){if($.current=-1,I(!1),_(null),!x.ok){_(x.error??"查询失败");return}if(x.notRepo){C(!0),o(null),p([]),w(new Map),B([]),b(null),R(""),U(null);return}C(!1);const Z={branch:x.branch??"",detached:!!x.detached,upstream:x.upstream??null,ahead:x.ahead??0,behind:x.behind??0,upstreamGone:!!x.upstreamGone,files:(x.files??[]).map(ge=>({...ge}))},G=(x.branches??[]).map(ge=>({...ge})),je=new Map;for(const[ge,be]of Object.entries(x.stats??{}))je.set(ge,{add:be[0],del:be[1]});o(Z),p(G),w(je),h(ge=>{var be;return Z.detached?ge||"":Z.branch&&G.some(Se=>Se.name===Z.branch)?Z.branch:ge&&G.some(Se=>Se.name===ge)?ge:((be=G[0])==null?void 0:be.name)??""}),U(ge=>ge&&!Z.files.some(be=>be.path===ge.file.path)?null:ge)}else if(x.reqId===V.current){if(V.current=-1,ue(!1),!x.ok){_(x.error??"查询失败");return}const Z=g.current;if(!Z)return;U({file:Z,staged:x.stagedText??"",worktree:x.worktreeText??"",untracked:!1})}else if(x.reqId===K.current){if(K.current=-1,H(!1),!x.ok){_(x.error??"查询失败");return}B((x.history??[]).map(Z=>({...Z})))}else if(x.reqId===le.current){if(le.current=-1,N(!1),!x.ok){_(x.error??"查询失败");return}R(x.text??"")}},[]);r.useEffect(()=>{const x=t.scmData;x&&x.type==="scm_data"&&D(x)},[t.scmData,D]);const X=r.useCallback((x,Z)=>{if(!t.ready||t.status!=="open")return!1;const G=++ie.current;return s({...x,reqId:G})?(Z.current=G,!0):(ie.current-=1,!1)},[t.ready,t.status,s]),de=r.useCallback((x=!1,Z=!1)=>{var G;!t.ready||t.status!=="open"||(G=t.state)!=null&&G.cwd&&(oe.current!==void 0&&oe.current!==t.state.cwd&&(o(null),p([]),w(new Map),B([]),H(!1),K.current=-1,b(null),R(""),U(null),y(null)),oe.current=t.state.cwd,_(null),X({type:"scm_status"},$)&&(Z||I(!0)))},[t.ready,(se=t.state)==null?void 0:se.cwd,t.status,X]),xe=r.useCallback(x=>{if(y(x),b(null),g.current=x,x.x==="?"&&x.y==="?"){U({file:x,staged:"",worktree:"",untracked:!0});return}ue(!0),_(null),X({type:"scm_filediff",path:x.path},V)||ue(!1)},[X]),Q=r.useCallback(x=>{b(x),y(null),U(null),R(""),N(!0),_(null),X({type:"scm_commit",hash:x.hash},le)||N(!1)},[X]),ce=r.useCallback((x,Z)=>{var ge,be;if(!t.ready)return;const G={name:x,command:Z,cwd:"${pwd}"},je=t.terminals.find(Se=>Se.title===x);if(je)a.restart(je.id),s({type:"run_command",terminalId:je.id,conversationId:je.conversationId,command:G,cols:80,rows:24});else{const Se=$e();a.create({id:Se,conversationId:t.activeConversationId||((ge=t.state)==null?void 0:ge.conversationId)||"",title:x,cwd:((be=t.state)==null?void 0:be.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:G})}c()},[t.ready,(pe=t.state)==null?void 0:pe.cwd,t.terminals,c,s,a]),ae=r.useCallback(()=>{const x=Y.trim();if(!x||O)return;const Z=x.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");ce("git commit",`git add -A && git commit -m "${Z}"`),J("")},[Y,O,ce]),Ne=x=>`'${x.replace(/'/g,"'\\''")}`,Te=r.useCallback(x=>{O||ce("git add",`git add -- ${Ne(x.path)}`)},[O,ce]),Ie=r.useCallback(x=>{O||ce("git reset",`git reset HEAD -- ${Ne(x.path)}`)},[O,ce]),Le=r.useCallback(()=>{if(!f||O)return;const x=d.find(Z=>Z.name===f);if(x!=null&&x.remote&&typeof x.remote=="string"){const Z=f.slice(x.remote.length+1);ce("git checkout",`git checkout -b ${Z} ${f} || git checkout ${f}`)}else ce("git checkout",`git checkout ${f}`)},[f,d,O,ce]),Fe=r.useCallback(()=>ce("git push","git push"),[ce]),Ae=r.useCallback(()=>ce("git pull","git pull"),[ce]),k=r.useCallback(()=>{X({type:"scm_history"},K)||(K.current=-1)},[X]);r.useEffect(()=>{l&&de()},[l,de]),r.useEffect(()=>{M==="history"&&n&&k()},[M,n,k]),r.useEffect(()=>{t.scmDirty>0&&l&&de(!1,!0)},[t.scmDirty]),r.useEffect(()=>{if(!l||!t.ready||t.status!=="open")return;const x=setInterval(()=>{document.visibilityState!=="hidden"&&de(!1,!0)},3e4);return()=>clearInterval(x)},[l,t.ready,t.status,de]),r.useEffect(()=>{const x=m.current;if(m.current=t.terminals,!l)return;t.terminals.some(G=>{var ge;return G.running!==!1?!1:((ge=x.find(be=>be.id===G.id))==null?void 0:ge.running)===!0&&/^git /.test(G.title)})&&t.ready&&t.status==="open"&&(de(!1,!0),M==="history"&&n&&k())},[t.terminals,l,t.ready,t.status,de,M,n,k]);const F={staged:i("scmStaged"),unstaged:i("scmUnstaged"),untracked:i("scmUntracked"),both:i("scmStagedUnstaged")},re=x=>{const Z=x.split(`
18
+ `);return e.jsx("pre",{className:"scm-diff-pre",children:Z.map((G,je)=>{let ge="";return G.startsWith("diff --git")||G.startsWith("index ")||G.startsWith("new file")||G.startsWith("deleted file")||G.startsWith("old mode")||G.startsWith("new mode")||G.startsWith("similarity index")||G.startsWith("rename ")||G.startsWith("copy ")||G.startsWith("Binary files")||G.startsWith("---")||G.startsWith("+++")?ge="hdr":G.startsWith("@@")?ge="hunk":G.startsWith("+")?ge="add":G.startsWith("-")&&(ge="del"),e.jsx("div",{className:`scm-diff-line ${ge}`,children:G||" "},je)})})};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(tt,{}),i("scmTitle")]}),e.jsxs("div",{className:"scm-view-tabs",role:"tablist",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":M==="changes",className:M==="changes"?"active":"",onClick:()=>{L("changes"),_(null)},children:i("scmChanges")}),e.jsx("button",{type:"button",role:"tab","aria-selected":M==="history",className:M==="history"?"active":"",onClick:()=>{L("history"),_(null)},children:i("scmHistory")})]}),e.jsx("button",{type:"button",className:"panel-refresh",title:i("scmRefreshTip"),disabled:ee,onClick:()=>de(!0),children:e.jsx(ct,{className:ee?"scm-spin":""})})]}),e.jsxs("div",{className:"scm-row",children:[e.jsxs("span",{className:"scm-branch-current",title:i("scmCurrentBranch"),children:[e.jsx(tt,{}),n?n.detached?i("scmDetached"):n.branch:"…",(n==null?void 0:n.upstream)&&e.jsx("span",{className:"scm-upstream",children:n.upstreamGone?i("scmUpstreamGone"):n.ahead>0||n.behind>0?i("scmAheadBehind",{ahead:n.ahead,behind:n.behind}):n.upstream})]}),e.jsxs("select",{className:"scm-select",value:f,disabled:O||d.length===0,title:i("scmSwitchBranch"),onChange:x=>h(x.target.value),children:[e.jsx("option",{value:"",disabled:!0,children:i("scmSelectBranch")}),d.filter(x=>!x.remote).map(x=>e.jsx("option",{value:x.name,children:x.current?`* ${x.name}`:x.name},x.name)),d.some(x=>x.remote)&&e.jsx("optgroup",{label:i("scmRemoteBranches"),children:d.filter(x=>x.remote).map(x=>e.jsx("option",{value:x.name,children:x.name},x.name))})]}),e.jsxs("button",{type:"button",className:"btn",disabled:!f||f===(n==null?void 0:n.branch)||O,title:i("scmSwitchBranchTip",{branch:f}),onClick:Le,children:[e.jsx(tt,{}),i("scmSwitch")]}),e.jsxs("button",{type:"button",className:"btn",disabled:!n||n.detached||O,title:i("scmPushTip"),onClick:Fe,children:[e.jsx(Ls,{}),i("scmPush")]}),e.jsxs("button",{type:"button",className:"btn",disabled:!n||n.detached||O,title:i("scmPullTip"),onClick:Ae,children:[e.jsx(Bs,{}),i("scmPull")]}),e.jsx("input",{className:"scm-commit-input",value:Y,placeholder:i("scmCommitPlaceholder"),disabled:O,onChange:x=>J(x.target.value),onKeyDown:x=>{x.key==="Enter"&&!x.nativeEvent.isComposing&&ae()}}),e.jsxs("button",{type:"button",className:"btn primary",disabled:!Y.trim()||O,title:i("scmCommitTip"),onClick:ae,children:[e.jsx(mt,{}),i("scmCommit")]})]})]}),e.jsxs("div",{className:"scm-body",children:[M==="history"?e.jsxs("div",{className:"scm-history",children:[e.jsxs("div",{className:"scm-files-header",children:[e.jsx("span",{children:i("scmHistory")}),S.length>0&&e.jsx("span",{className:"scm-files-count",children:S.length})]}),e.jsx("div",{className:"scm-history-list",children:O?e.jsx("div",{className:"scm-empty",children:i("scmNotGitRepo")}):!n||q?e.jsx("div",{className:"scm-empty",children:t.status==="open"?i("scmLoading"):i("scmConnecting")}):S.length===0?e.jsx("div",{className:"scm-empty",children:i("scmNoHistory")}):S.map(x=>e.jsxs("button",{type:"button",className:`scm-commit ${(j==null?void 0:j.hash)===x.hash?"active":""}`,onClick:()=>Q(x),title:x.hash,children:[e.jsx("span",{className:"scm-commit-graph","aria-hidden":"true",children:x.graph||"* "}),e.jsxs("span",{className:"scm-commit-info",children:[e.jsx("span",{className:"scm-commit-subject",children:x.subject}),e.jsxs("span",{className:"scm-commit-meta",children:[x.shortHash," · ",x.author," · ",x.date]}),x.decorations&&e.jsx("span",{className:"scm-commit-refs",children:x.decorations})]})]},x.hash))})]}):e.jsxs("div",{className:"scm-files",children:[e.jsxs("div",{className:"scm-files-header",children:[e.jsx("span",{children:i("scmChanges")}),n&&n.files.length>0&&e.jsx("span",{className:"scm-files-count",children:n.files.length})]}),e.jsx("div",{className:"scm-files-list",children:O?e.jsx("div",{className:"scm-empty",children:i("scmNotGitRepo")}):n?n.files.length===0?e.jsx("div",{className:"scm-empty",children:i("scmNoChanges")}):n.files.map(x=>{const Z=fa(x),G=v.get(x.path);return e.jsxs("div",{className:`scm-file ${(u==null?void 0:u.path)===x.path?"active":""}`,title:F[Z],onClick:()=>xe(x),children:[e.jsx("span",{className:`scm-file-xy ${Z==="untracked"?"q":"x"}`,children:x.x!==" "?x.x:" "}),e.jsx("span",{className:`scm-file-xy ${Z==="untracked"?"q":"y"}`,children:x.y!==" "?x.y:" "}),e.jsx("span",{className:"scm-file-path",children:x.path}),G&&(G.add>0||G.del>0)&&e.jsxs("span",{className:"scm-file-stat",children:[G.add>0&&e.jsxs("span",{className:"add",children:["+",G.add]}),G.del>0&&e.jsxs("span",{className:"del",children:["-",G.del]})]}),e.jsxs("span",{className:"scm-file-actions",children:[(x.y!==" "||Z==="untracked")&&e.jsx("button",{type:"button",className:"scm-act",title:i("scmStageTip",{path:x.path}),onClick:je=>{je.stopPropagation(),Te(x)},children:"+"}),Z==="staged"||Z==="both"?e.jsx("button",{type:"button",className:"scm-act",title:i("scmUnstageTip",{path:x.path}),onClick:je=>{je.stopPropagation(),Ie(x)},children:"−"}):null]})]},x.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:M==="history"?j?`${j.shortHash} ${j.subject}`:i("scmCommitDetail"):u?u.path:i("scmDiff")}),(M==="history"?T:te)&&e.jsx("span",{className:"scm-diff-loading",children:i("scmLoading")})]}),e.jsx("div",{className:"scm-diff-body",children:M==="history"?e.jsxs(e.Fragment,{children:[me&&e.jsx("div",{className:"scm-error",children:me}),!j&&!me&&e.jsx("div",{className:"scm-empty",children:i("scmSelectCommitHint")}),j&&T&&!me&&e.jsx("div",{className:"scm-empty",children:i("scmLoading")}),j&&!T&&!me&&E?re(E):null]}):e.jsxs(e.Fragment,{children:[me&&e.jsx("div",{className:"scm-error",children:me}),!u&&!me&&e.jsx("div",{className:"scm-empty",children:i("scmSelectFileHint")}),u&&!A&&!me&&e.jsx("div",{className:"scm-empty",children:i("scmLoading")}),u&&A&&A.untracked&&e.jsx("div",{className:"scm-empty",children:i("scmUntrackedNote")}),u&&A&&!A.untracked&&e.jsxs(e.Fragment,{children:[A.staged&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"scm-diff-section",children:i("scmStaged")}),re(A.staged)]}),A.worktree&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"scm-diff-section",children:i("scmUnstaged")}),re(A.worktree)]}),!A.staged&&!A.worktree&&e.jsx("div",{className:"scm-empty",children:i("scmNoDiff")})]})]})})]})]}),e.jsxs("div",{className:"scm-hint",children:[e.jsx(Ue,{}),e.jsx("span",{children:i("scmRunsInTerminal")}),e.jsx("button",{type:"button",className:"scm-goto-term",onClick:c,children:i("scmViewTerminal")})]})]})}function va({entry:t,send:s}){const a=r.useRef(null);return r.useEffect(()=>{const l=a.current;if(!l)return;let c;try{c=t.module.mount(l,ai(t.info.id,i=>s(i)))}catch(i){console.error(`[plugin:${t.info.id}] mount failed:`,i),l.textContent=`插件 ${t.info.name} 挂载失败`}return()=>{if(typeof c=="function")try{c()}catch(i){console.error(`[plugin:${t.info.id}] cleanup failed:`,i)}l.textContent=""}},[t,s]),e.jsx("div",{className:"plugin-view",ref:a})}function ya({send:t,piConfigured:s,piAgentInstalled:a,providers:l,installResult:c,onClose:i}){const n=he(),[o,d]=r.useState(!1),[p,f]=r.useState(""),[h,v]=r.useState(""),[w,M]=r.useState(!1);r.useEffect(()=>{t({type:"list_providers"})},[t]),r.useEffect(()=>{s&&i()},[s,i]),r.useEffect(()=>{c&&d(!1)},[c]),r.useEffect(()=>{var E;!p&&l.length>0&&f(((E=l.find(R=>!R.configured))==null?void 0:E.id)??l[0].id)},[l,p]);const L=()=>{o||(d(!0),t({type:"install_pi_agent"}))},S=()=>{!h.trim()||w||(M(!0),t({type:"set_provider_api_key",provider:p.trim(),apiKey:h.trim()}),setTimeout(()=>M(!1),3e3))},B=()=>{t({type:"get_state"}),t({type:"list_providers"})},j=l.find(E=>E.id===p),b=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":n("close"),onClick:i,children:e.jsx(we,{})}),e.jsxs("div",{className:"modal-head",children:[e.jsx(Qe,{className:"modal-head-icon"}),e.jsx("h2",{children:n("setupTitle")})]}),e.jsx("p",{className:"modal-desc",children:n("setupDesc")}),b?e.jsxs("div",{className:"setup-failed",children:[e.jsx("div",{className:"setup-done",children:n("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:L,children:n("retryInstall")}),e.jsx("button",{type:"button",className:"btn",onClick:i,children:n("skip")})]})]}):a||c!=null&&c.ok?e.jsxs("div",{className:"setup-key-form",children:[e.jsx("div",{className:"setup-done",children:c!=null&&c.ok?n("installDone"):n("cliReadyHint")}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:n("provider")}),e.jsxs("select",{value:p,onChange:E=>f(E.target.value),children:[l.length===0&&e.jsx("option",{value:"",children:n("loading")}),l.map(E=>e.jsxs("option",{value:E.id,children:[E.name,"(",E.id,")",E.configured?` · ${n("configured")}`:""]},E.id))]}),(j==null?void 0:j.configured)&&e.jsx("div",{className:"field-hint",children:n("providerKeyReady")})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:n("apiKey")}),e.jsx("input",{type:"password",value:h,onChange:E=>v(E.target.value),placeholder:"sk-…"})]}),e.jsxs("div",{className:"setup-actions",children:[e.jsx("button",{type:"button",className:"btn primary",disabled:!h.trim()||w||!p,onClick:S,children:n(w?"saving":"saveAndStart")}),e.jsxs("button",{type:"button",className:"btn",onClick:B,children:[e.jsx(ct,{})," ",n("recheck")]})]})]}):e.jsxs("div",{className:"setup-actions",children:[e.jsx("button",{type:"button",className:"btn primary",disabled:o,onClick:L,children:n(o?"installing":"autoInstall")}),e.jsx("button",{type:"button",className:"btn",onClick:i,children:n("skip")})]})]})})}const ja=["openai-completions","openai-responses","anthropic-messages","google-generative-ai"],Bt=()=>({id:"",name:"",reasoning:!1,input:"text",contextWindow:"",maxTokens:""}),ba=()=>({providerId:"",name:"",api:"openai-completions",baseUrl:"",apiKey:"",authHeader:!0,models:[Bt()]});function js(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:[Bt()]).map(s=>{var a;return{id:s.id,name:s.name??"",reasoning:s.reasoning??!1,input:(a=s.input)!=null&&a.includes("image")?"text-image":"text",contextWindow:s.contextWindow?String(s.contextWindow):"",maxTokens:s.maxTokens?String(s.maxTokens):""}})}}function ka({send:t,providers:s,providerStatus:a,fetchModelsResult:l,refreshProviderResult:c,cloneProviderResult:i,onClose:n}){const o=he(),[d,p]=r.useState(null),[f,h]=r.useState({}),[v,w]=r.useState(null),[M,L]=r.useState({}),[S,B]=r.useState(!1),[j,b]=r.useState(0),[E,R]=r.useState(null),T=r.useRef(0),[N,u]=r.useState({});r.useRef(0);const y=r.useRef(0),[A,U]=r.useState(null),te=r.useRef(0),ue=r.useRef(0);r.useEffect(()=>{t({type:"list_models_config"}),t({type:"list_providers"})},[t]);const ee=()=>{if(!d)return;const C=d.baseUrl.trim();if(!C){R({ok:!1,text:o("fetchModelsNeedBaseUrl")});return}if(S)return;B(!0),R(null);const Y=j+1;b(Y),t({type:"fetch_models",reqId:Y,baseUrl:C,apiKey:d.apiKey.trim()||void 0,authHeader:d.authHeader,api:d.api})};r.useEffect(()=>{var C;if(!(!l||l.reqId===T.current))if(T.current=l.reqId,B(!1),l.ok&&((C=l.models)!=null&&C.length)){const Y=l.models;p(J=>{if(!J)return J;const ie=J.models.map(K=>{var m;if(!K.id.trim())return K;const oe=Y.find(D=>D.id===K.id.trim());if(!oe)return K;const g={...K};return!g.name&&oe.name&&(g.name=oe.name),!g.contextWindow&&oe.contextWindow&&(g.contextWindow=String(oe.contextWindow)),!g.maxTokens&&oe.maxTokens&&(g.maxTokens=String(oe.maxTokens)),g.input==="text"&&((m=oe.input)!=null&&m.includes("image"))&&(g.input="text-image"),!g.reasoning&&oe.reasoning&&(g.reasoning=!0),g}),$=new Set(ie.map(K=>K.id.trim()).filter(Boolean)),V=Y.filter(K=>!$.has(K.id)).map(K=>{var oe;return{id:K.id,name:K.name??"",reasoning:K.reasoning??!1,input:(oe=K.input)!=null&&oe.includes("image")?"text-image":"text",contextWindow:K.contextWindow?String(K.contextWindow):"",maxTokens:K.maxTokens?String(K.maxTokens):""}}),le=[...ie,...V];return le.some(K=>K.id.trim())?{...J,models:le.filter(K=>K.id.trim())}:J}),R({ok:!0,text:o("fetchModelsOk",{n:Y.length})})}else R({ok:!1,text:l.error||o("fetchModelsEmpty")})},[l]);const I=C=>{const Y=(f[C.id]??"").trim();!Y||v||(w(C.id),t({type:"set_provider_api_key",provider:C.id,apiKey:Y}),setTimeout(()=>{w(null),h(J=>({...J,[C.id]:""})),L(J=>({...J,[C.id]:!1})),t({type:"list_providers"})},1500))},q=()=>{if(!d)return;const C=d.providerId.trim(),Y=d.models.filter(ie=>ie.id.trim()).map(ie=>({id:ie.id.trim(),name:ie.name.trim()||void 0,reasoning:ie.reasoning||void 0,input:ie.input==="text-image"?["text","image"]:void 0,contextWindow:ie.contextWindow?Number(ie.contextWindow):void 0,maxTokens:ie.maxTokens?Number(ie.maxTokens):void 0})),J={providerId:C,name:d.name.trim()||void 0,api:d.api.trim()||void 0,baseUrl:d.baseUrl.trim()||void 0,apiKey:d.apiKey.trim()||void 0,authHeader:d.authHeader||void 0,models:Y};t({type:"save_model_config",providerId:C,config:J}),n()};r.useEffect(()=>{!c||c.reqId===y.current||(y.current=c.reqId,u({}))},[c]);const H=C=>{if(A)return;U(C.id);const Y=++te.current+Date.now();t({type:"clone_provider",provider:C.id,reqId:Y})};r.useEffect(()=>{!i||i.reqId===ue.current||(ue.current=i.reqId,U(null),i.ok&&i.config&&p(js({...i.config,apiKey:""})))},[i]);const me=C=>{window.confirm(o("clearKeyConfirm",{id:C}))&&t({type:"clear_provider_api_key",provider:C})},_=C=>{window.confirm(o("deleteProviderConfirm",{id:C.providerId,n:C.models.length}))&&t({type:"delete_model_config",providerId:C.providerId})},O=(C,Y)=>{d&&p({...d,models:d.models.map((J,ie)=>ie===C?{...J,...Y}:J)})};return e.jsx("div",{className:"modal-backdrop",onClick:n,children:e.jsxs("div",{className:"modal model-modal",onClick:C=>C.stopPropagation(),children:[e.jsx("button",{type:"button",className:"modal-close","aria-label":o("close"),onClick:n,children:e.jsx(we,{})}),e.jsx("div",{className:"modal-head",children:e.jsx("h2",{children:o(d?"editProvider":"manageModelsTitle")})}),d?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:d.providerId,disabled:s.some(C=>C.providerId===d.providerId),onChange:C=>p({...d,providerId:C.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:d.name,onChange:C=>p({...d,name:C.target.value}),placeholder:o("displayNamePh")})]}),e.jsxs("label",{className:"field",children:[e.jsx("span",{className:"field-label",children:o("apiType")}),e.jsx("select",{value:d.api,onChange:C=>p({...d,api:C.target.value}),children:ja.map(C=>e.jsx("option",{value:C,children:C},C))})]}),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:d.baseUrl,onChange:C=>p({...d,baseUrl:C.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:d.apiKey,onChange:C=>p({...d,apiKey:C.target.value}),placeholder:o("apiKeyHint")})]}),e.jsxs("label",{className:"field check",children:[e.jsx("input",{type:"checkbox",checked:d.authHeader,onChange:C=>p({...d,authHeader:C.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:[E&&e.jsx("span",{className:`fetch-msg ${E.ok?"ok":"err"}`,title:E.text,children:E.text}),e.jsxs("button",{type:"button",className:"btn sm",disabled:S||!d.baseUrl.trim(),title:o("fetchModelsHint"),onClick:ee,children:[e.jsx(Mt,{})," ",o(S?"fetchingModels":"fetchModels")]})]})]}),d.models.map((C,Y)=>e.jsxs("div",{className:"model-row",children:[e.jsx("input",{type:"text",value:C.id,onChange:J=>O(Y,{id:J.target.value}),placeholder:o("modelIdReq")}),e.jsx("input",{type:"text",value:C.name,onChange:J=>O(Y,{name:J.target.value}),placeholder:o("displayName")}),e.jsxs("select",{value:C.input,onChange:J=>O(Y,{input:J.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:C.reasoning,onChange:J=>O(Y,{reasoning:J.target.checked})}),e.jsx("span",{children:o("reasoning")})]}),e.jsx("input",{type:"number",value:C.contextWindow,onChange:J=>O(Y,{contextWindow:J.target.value}),placeholder:o("contextWindow"),title:"contextWindow"}),e.jsx("input",{type:"number",value:C.maxTokens,onChange:J=>O(Y,{maxTokens:J.target.value}),placeholder:o("maxOutput"),title:"maxTokens"}),e.jsx("button",{type:"button",className:"iconbtn danger",title:o("removeModel"),onClick:()=>p({...d,models:d.models.filter((J,ie)=>ie!==Y)}),children:e.jsx(De,{})})]},Y)),e.jsxs("button",{type:"button",className:"btn",onClick:()=>p({...d,models:[...d.models,Bt()]}),children:[e.jsx(qe,{})," ",o("addModel")]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>p(null),children:o("cancel")}),e.jsx("button",{type:"button",className:"btn primary",disabled:!d.providerId.trim()||!d.models.some(C=>C.id.trim()),onClick:q,children:o("save")})]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"form-section-title",children:[o("builtinProviders")," ",e.jsx("em",{className:"section-hint",children:o("hintKeyOnly")})]}),e.jsxs("div",{className:"provider-list",children:[a.length===0&&e.jsx("div",{className:"dd-loading",children:o("loading")}),a.map(C=>e.jsxs("div",{className:"provider-row",children:[e.jsxs("div",{className:"provider-info",children:[e.jsx("span",{className:"provider-name",children:C.name}),e.jsxs("span",{className:"provider-sub",children:[C.id,C.configured&&e.jsx("span",{className:"auth-badge",children:o("configuredBadge")}),C.source&&!C.configured&&e.jsx("span",{className:"auth-badge dim",children:C.source})]})]}),e.jsxs("div",{className:"provider-actions",children:[C.configured&&!M[C.id]?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"auth-badge",children:o("keyReady")}),e.jsxs("button",{type:"button",className:"btn sm",title:o("replaceKeyTitle"),onClick:()=>L(Y=>({...Y,[C.id]:!0})),children:[e.jsx(Zt,{})," ",o("replaceKey")]}),C.source==="stored"&&e.jsxs("button",{type:"button",className:"btn sm danger",title:o("clearKeyTitle"),onClick:()=>me(C.id),children:[e.jsx(De,{})," ",o("clearKey")]})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"password",className:"key-input",placeholder:o("pasteKey"),value:f[C.id]??"",onChange:Y=>h(J=>({...J,[C.id]:Y.target.value}))}),e.jsxs("button",{type:"button",className:"btn primary sm",disabled:!(f[C.id]??"").trim()||v===C.id,onClick:()=>I(C),children:[e.jsx(Ln,{})," ",v===C.id?o("savingKey"):o("saveKey")]})]}),e.jsxs("button",{type:"button",className:"btn sm",disabled:A!==null,title:o("cloneProviderTitle"),onClick:()=>H(C),children:[e.jsx(Pt,{})," ",A===C.id?o("cloning"):o("cloneProvider")]})]})]},C.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(C=>e.jsxs("div",{className:"provider-row",children:[e.jsxs("div",{className:"provider-info",children:[e.jsx("span",{className:"provider-name",children:C.providerId}),e.jsxs("span",{className:"provider-sub",children:[C.api??"—",C.baseUrl?` · ${C.baseUrl}`:"",C.models.length>0&&` · ${o("modelsCount",{n:C.models.length})}`]})]}),e.jsxs("div",{className:"provider-actions",children:[e.jsx("button",{type:"button",className:"iconbtn",title:o("edit"),onClick:()=>p(js(C)),children:e.jsx(Zt,{})}),e.jsx("button",{type:"button",className:"iconbtn danger",title:o("delete"),onClick:()=>_(C),children:e.jsx(De,{})})]})]},C.providerId))}),e.jsx("div",{className:"modal-actions",children:e.jsxs("button",{type:"button",className:"btn primary",onClick:()=>p(ba()),children:[e.jsx(qe,{})," ",o("addProvider")]})})]})]})})}function wa({plugin:t,send:s}){const a=he(),l=t.settingsSchema??[],[c,i]=r.useState(()=>({...t.settingsValues??{}})),[n,o]=r.useState(!1);if(l.length===0)return null;const d=(v,w)=>i(M=>({...M,[v]:w})),p=l.some(v=>{var w;return c[v.key]!==((w=t.settingsValues)==null?void 0:w[v.key])}),f=()=>{o(!0),s({type:"plugin_settings",pluginId:t.id,values:c}),setTimeout(()=>o(!1),800)},h=()=>i({...t.settingsValues??{}});return e.jsxs("div",{className:"plugin-settings-form",children:[e.jsx("div",{className:"plugin-settings-fields",children:l.map(v=>e.jsxs("label",{className:"plugin-settings-field",title:v.hint,children:[e.jsx("span",{className:"plugin-settings-label",children:v.label}),v.type==="boolean"?e.jsx("input",{type:"checkbox",checked:!!c[v.key],onChange:w=>d(v.key,w.target.checked)}):v.type==="select"?e.jsx("select",{value:String(c[v.key]??""),onChange:w=>d(v.key,w.target.value),children:(v.options??[]).map(w=>e.jsx("option",{value:w,children:w},w))}):e.jsx("input",{type:v.type==="password"?"password":v.type==="number"?"number":"text",value:String(c[v.key]??""),min:v.min,max:v.max,onChange:w=>d(v.key,v.type==="number"?Number(w.target.value):w.target.value)})]},v.key))}),e.jsxs("div",{className:"plugin-settings-actions",children:[e.jsx("button",{type:"button",className:"btn plugin-settings-save",disabled:!p||n,onClick:f,children:a(n?"pluginSettingsSaving":"pluginSettingsSave")}),e.jsx("button",{type:"button",className:"btn plugin-settings-reset",onClick:h,children:a("pluginSettingsReset")})]})]})}function st({text:t}){const s=r.useRef(null),[a,l]=r.useState(!1),c=()=>{var n;const i=(n=s.current)==null?void 0:n.getBoundingClientRect();i&&l(window.innerWidth-i.right<340)};return e.jsxs("span",{ref:s,className:`set-tip${a?" flip":""}`,tabIndex:0,"aria-label":t,onMouseEnter:c,onFocus:c,children:["?",e.jsx("span",{className:"set-tip-bubble",role:"tooltip",children:t})]})}function Ee({title:t,subtitle:s,tip:a,enabled:l,onToggle:c,action:i}){const n=he();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,a&&e.jsx(st,{text:a})]}),s&&e.jsx("div",{className:"set-row-desc",children:s})]}),i,e.jsx("button",{type:"button",className:`set-switch ${l?"on":""}`,role:"switch","aria-checked":l,title:n(l?"settingsEnabled":"settingsDisabled"),onClick:c,children:e.jsx("span",{className:"set-switch-knob"})})]})}function Na({chat:t,send:s,terminal:a,onSwitchToTerminal:l,onClose:c}){const i=he(),n=t.settings,[o,d]=r.useState("prompt"),p=r.useRef(null);r.useEffect(()=>{var m;(m=p.current)==null||m.scrollTo({top:0})},[o]);const[f,h]=r.useState(""),[v,w]=r.useState("append"),M=r.useRef(!1),[L,S]=r.useState(""),[B,j]=r.useState("append"),b=r.useRef(!1),[E,R]=r.useState(""),T=r.useRef(!1),[N,u]=r.useState(""),[y,A]=r.useState(!1),[U,te]=r.useState(null),[ue,ee]=r.useState(null);r.useEffect(()=>{n&&(w(n.promptMode),!M.current&&(h(v==="append"||n.customSystemPrompt?n.customSystemPrompt:n.defaultSystemPrompt||""),j(n.visionBridgePromptMode),!b.current&&(S(B==="append"||n.visionBridgePrompt?n.visionBridgePrompt:n.visionBridgeDefaultPrompt||""),T.current||R(n.reviewPrompt))))},[n,v,B]);const[I,q]=r.useState(String((n==null?void 0:n.terminalBashIdleMs)??15e3));if(r.useEffect(()=>{q(String((n==null?void 0:n.terminalBashIdleMs)??15e3))},[n==null?void 0:n.terminalBashIdleMs]),!n)return null;const H=[{id:"prompt",icon:e.jsx(Is,{}),label:i("settingsSystemPrompt")},{id:"terminal",icon:e.jsx(Ue,{}),label:i("settingsTerminalTools")},{id:"display",icon:e.jsx(ze,{}),label:i("settingsMessageDisplay")},{id:"skills",icon:e.jsx(Qe,{}),label:i("settingsSkills"),count:n.skills.length},{id:"extensions",icon:e.jsx(Yt,{}),label:i("settingsExtensions"),count:n.extensions.length},{id:"plugins",icon:e.jsx(es,{}),label:i("settingsUiPlugins"),count:t.plugins.length},{id:"review",icon:e.jsx(et,{}),label:i("settingsReview"),count:n.reviewSkills.length},{id:"vision",icon:e.jsx(kt,{}),label:i("settingsVisionBridge")},{id:"presets",icon:e.jsx(wn,{}),label:i("settingsPresets"),count:n.presets.length}],me=new Set(n.disabledSkills),_=new Set(n.disabledExtensions),O=m=>s({type:"set_settings",...m}),C=m=>{const D=new Set(me);D.has(m.name)?D.delete(m.name):D.add(m.name),O({disabledSkills:[...D]})},Y=new Set(n.disabledPlugins??[]),J=m=>{const D=new Set(Y);D.has(m.id)?D.delete(m.id):D.add(m.id),O({disabledPlugins:[...D]})},ie=m=>{const D=new Set(_);D.has(m.id)?D.delete(m.id):D.add(m.id),O({disabledExtensions:[...D]})},$=(m,D)=>{var xe,Q;const X={name:m,command:D,cwd:"${pwd}"},de=t.terminals.find(ce=>ce.title===m);de?(a.restart(de.id),s({type:"run_command",terminalId:de.id,conversationId:de.conversationId,command:X,cols:80,rows:24})):a.create({id:$e(),conversationId:t.activeConversationId||((xe=t.state)==null?void 0:xe.conversationId)||"",title:m,cwd:((Q=t.state)==null?void 0:Q.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:X}),l(),c()},V=m=>{te(null),$(`${i("uninstallTitle")} ${m}`,`pi remove npm:${m}`)},le=m=>{ee(null),$(`${i("uninstallTitle")} ${m}`,`pi-web-ui uninstall ${m}`)},K=(m,D)=>{$(`${i("pluginUpdate")} ${m}`,`pi-web-ui install ${D} --name ${m} --force`)},oe=m=>{const D=new Set(n.reviewSkills.filter(X=>!X.enabled).map(X=>X.name));D.has(m.name)?D.delete(m.name):D.add(m.name),O({reviewDisabledSkills:[...D]})},g=()=>{const m=v==="replace"&&n.defaultSystemPrompt&&f===n.defaultSystemPrompt?"":f;O({promptMode:v,customSystemPrompt:m})};return e.jsx("div",{className:"modal-backdrop",onClick:c,children:e.jsxs("div",{className:"modal settings-modal",onClick:m=>m.stopPropagation(),children:[e.jsx("button",{type:"button",className:"modal-close","aria-label":i("close"),onClick:c,children:e.jsx(we,{})}),e.jsxs("div",{className:"modal-head",children:[e.jsx(rt,{className:"modal-head-icon"}),e.jsx("h2",{children:i("settingsTitle")}),e.jsx(st,{text:i("settingsDesc")})]}),e.jsxs("div",{className:"settings-layout",children:[e.jsx("nav",{className:"settings-rail","aria-label":i("settingsTitle"),children:H.map(m=>e.jsxs("button",{type:"button",className:`settings-tab${o===m.id?" active":""}`,"aria-current":o===m.id?"true":void 0,title:m.label,onClick:()=>d(m.id),children:[e.jsx("span",{className:"settings-tab-icon",children:m.icon}),e.jsx("span",{className:"settings-tab-label",children:m.label}),m.count!==void 0&&e.jsx("span",{className:"set-count",children:m.count})]},m.id))}),e.jsxs("div",{className:"modal-body",ref:p,children:[o==="prompt"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(et,{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:v,onChange:m=>{const D=m.target.value;w(D),O({promptMode:D})},children:[e.jsx("option",{value:"append",children:i("promptModeAppend")}),e.jsx("option",{value:"replace",children:i("promptModeReplace")})]}),e.jsx(st,{text:i(v==="append"?"promptAppendHint":"promptReplaceHint")})]}),e.jsx("textarea",{className:"set-prompt-input",rows:6,placeholder:i("promptPlaceholder"),value:f,onFocus:()=>M.current=!0,onBlur:()=>{M.current=!1,g()},onChange:m=>h(m.target.value)}),e.jsxs("button",{type:"button",className:"set-view-prompt-btn","aria-expanded":y,onClick:()=>A(m=>!m),children:[i("settingsViewPrompt")," ",y?"▴":"▾"]}),y&&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(As,{text:n.effectiveSystemPrompt})]}),n.effectiveSystemPrompt?e.jsx("pre",{className:"set-prompt-view-text",children:n.effectiveSystemPrompt}):e.jsx("p",{className:"set-empty",children:i("settingsViewPromptEmpty")})]})]}),o==="terminal"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Ue,{className:"set-section-icon"}),i("settingsTerminalTools")]}),e.jsx(Ee,{title:i("terminalToolsEnabled"),tip:i("settingsTerminalToolsDesc"),enabled:n.terminalToolsEnabled,onToggle:()=>O({terminalToolsEnabled:!n.terminalToolsEnabled})}),!n.terminalToolsEnabled&&e.jsx("p",{className:"set-hint",children:i("terminalToolsOffHint")}),e.jsx(Ee,{title:i("terminalBashTakeover"),tip:i("terminalBashTakeoverDesc"),enabled:n.terminalBash,onToggle:()=>O({terminalBash:!n.terminalBash})}),n.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:I,onChange:m=>q(m.target.value),onBlur:()=>{const m=Math.max(0,Math.floor(Number(I)||0));q(String(m)),m!==n.terminalBashIdleMs&&O({terminalBashIdleMs:m})}})]})]}),o==="display"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(ze,{className:"set-section-icon"}),i("settingsMessageDisplay")]}),e.jsx(Ee,{title:i("thinkingWrap"),tip:i("thinkingWrapDesc"),enabled:n.thinkingWrap??!0,onToggle:()=>O({thinkingWrap:!(n.thinkingWrap??!0)})}),e.jsx(Ee,{title:i("toolsWrap"),tip:i("toolsWrapDesc"),enabled:n.toolsWrap??!0,onToggle:()=>O({toolsWrap:!(n.toolsWrap??!0)})})]}),o==="skills"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Qe,{className:"set-section-icon"}),i("settingsSkills"),e.jsx("span",{className:"set-count",children:n.skills.length})]}),n.skills.length===0?e.jsx("p",{className:"set-empty",children:i("noSkills")}):e.jsx("div",{className:"set-list",children:n.skills.map(m=>e.jsx(Ee,{title:m.name,subtitle:m.description,enabled:m.enabled,onToggle:()=>C(m)},m.name))})]}),o==="extensions"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Yt,{className:"set-section-icon"}),i("settingsExtensions"),e.jsx("span",{className:"set-count",children:n.extensions.length})]}),n.extensions.length===0?e.jsx("p",{className:"set-empty",children:i("noExtensions")}):e.jsx("div",{className:"set-list",children:n.extensions.map(m=>{const D=m.id.startsWith("npm:")?m.id.slice(4):null;return e.jsx(Ee,{title:m.name,subtitle:m.path,enabled:m.enabled,onToggle:()=>ie(m),action:D?U===m.id?e.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("uninstallConfirmHint"),onClick:()=>V(D),children:i("uninstallConfirm")}):e.jsxs("button",{type:"button",className:"set-uninstall",title:i("uninstallHint"),onClick:()=>te(m.id),children:[e.jsx(De,{}),i("uninstallExt")]}):void 0},m.id)})})]}),o==="plugins"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(es,{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(m=>{var D;return e.jsxs(e.Fragment,{children:[e.jsx(Ee,{title:`${m.icon?`${m.icon} `:""}${m.name}`,subtitle:(m.error?`${m.id} · ${m.error}`:m.source?`${m.id} · ${m.source}`:`${m.id} · ${i("uiPluginNoSource")}`)+((D=m.permissions)!=null&&D.length?` · ${i("uiPluginPerms")}: ${m.permissions.join(", ")}`:""),enabled:!Y.has(m.id)&&!m.error,onToggle:()=>!m.error&&J(m),action:e.jsxs("div",{className:"set-row-actions",children:[m.source&&e.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUpdateHint"),onClick:()=>K(m.id,m.source),children:[e.jsx(ct,{}),i("pluginUpdate")]}),ue===m.id?e.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("pluginUninstallHint"),onClick:()=>le(m.id),children:i("uninstallConfirm")}):e.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUninstallHint"),onClick:()=>ee(m.id),children:[e.jsx(De,{}),i("uninstallExt")]})]})},m.id),m.settingsSchema&&m.settingsSchema.length>0&&e.jsx(wa,{plugin:m,send:s})]})})})]}),o==="review"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(et,{className:"set-section-icon"}),i("settingsReview"),e.jsx(st,{text:i("settingsReviewDesc")}),e.jsx("span",{className:"set-count",children:n.reviewSkills.length})]}),e.jsx("textarea",{className:"set-prompt-input",rows:5,placeholder:i("reviewPromptPlaceholder"),value:E,onFocus:()=>T.current=!0,onBlur:()=>{T.current=!1,O({reviewPrompt:E})},onChange:m=>R(m.target.value)}),e.jsx("div",{className:"set-field-label",children:i("settingsReviewSkills")}),n.reviewSkills.length===0?e.jsx("p",{className:"set-empty",children:i("noSkills")}):e.jsx("div",{className:"set-list",children:n.reviewSkills.map(m=>e.jsx(Ee,{title:m.name,subtitle:m.description,enabled:m.enabled,onToggle:()=>oe(m)},`review-${m.name}`))})]}),o==="vision"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(kt,{className:"set-section-icon"}),i("settingsVisionBridge")]}),e.jsx(Ee,{title:i("visionBridgeEnabled"),tip:i("settingsVisionBridgeDesc"),enabled:n.visionBridgeEnabled,onToggle:()=>O({visionBridgeEnabled:!n.visionBridgeEnabled})}),!n.visionBridgeEnabled&&e.jsx("p",{className:"set-hint",children:i("visionBridgeOffHint")}),n.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:n.visionBridgeModel??"",onChange:m=>O({visionBridgeModel:m.target.value||null}),children:[e.jsx("option",{value:"",children:i("visionBridgeAuto")}),n.visionModels.map(m=>e.jsx("option",{value:`${m.provider}/${m.id}`,children:m.label},`${m.provider}/${m.id}`))]})]}),n.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:B,onChange:m=>{const D=m.target.value;j(D),O({visionBridgePromptMode:D})},children:[e.jsx("option",{value:"append",children:i("promptModeAppend")}),e.jsx("option",{value:"replace",children:i("promptModeReplace")})]})]}),n.visionBridgeEnabled&&e.jsx("textarea",{className:"set-prompt-input",rows:4,placeholder:i("visionBridgePromptPlaceholder"),value:L,onFocus:()=>b.current=!0,onBlur:()=>{b.current=!1;const m=B==="replace"&&n.visionBridgeDefaultPrompt&&L===n.visionBridgeDefaultPrompt?"":L;O({visionBridgePromptMode:B,visionBridgePrompt:m})},onChange:m=>S(m.target.value)}),n.visionBridgeEnabled&&(n.visionModels.length===0?e.jsx("p",{className:"set-hint",children:i("visionBridgeNoModels")}):e.jsx("p",{className:"set-hint",children:i("visionBridgeCurrent",{model:n.visionBridgeModel??i("visionBridgeAuto")})}))]}),o==="presets"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(rt,{className:"set-section-icon"}),i("settingsPresets"),e.jsx("span",{className:"set-count",children:n.presets.length})]}),e.jsxs("div",{className:"set-preset-save",children:[e.jsx("input",{className:"set-input",placeholder:i("presetNamePlaceholder"),value:N,onChange:m=>u(m.target.value),onKeyDown:m=>{m.key==="Enter"&&N.trim()&&(s({type:"save_preset",name:N.trim()}),u(""))}}),e.jsxs("button",{type:"button",className:"set-save-btn",disabled:!N.trim(),onClick:()=>{s({type:"save_preset",name:N.trim()}),u("")},children:[e.jsx(qe,{})," ",i("saveAsPreset")]})]}),n.presets.length===0?e.jsx("p",{className:"set-empty",children:i("noPresets")}):e.jsx("div",{className:"set-list",children:n.presets.map(m=>e.jsxs("div",{className:"set-row",children:[e.jsxs("div",{className:"set-row-info",children:[e.jsx("div",{className:"set-row-name",children:m.name}),e.jsxs("div",{className:"set-row-desc",children:[m.promptMode==="replace"?i("promptModeReplace"):i("promptModeAppend"),m.disabledSkills.length>0&&` · ${i("settingsSkills")} ${m.disabledSkills.length}`,m.disabledExtensions.length>0&&` · ${i("settingsExtensions")} ${m.disabledExtensions.length}`]})]}),e.jsxs("div",{className:"set-row-actions",children:[e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>s({type:"apply_preset",name:m.name}),children:i("applyPreset")}),e.jsx("button",{type:"button",className:"set-icon-btn danger",title:i("deletePreset"),onClick:()=>s({type:"delete_preset",name:m.name}),children:e.jsx(De,{})})]})]},m.name))})]})]})]}),e.jsx("div",{className:"modal-actions",children:e.jsx("button",{type:"button",className:"dd-refresh",onClick:c,children:i("close")})})]})})}function Ca(t,s){const a=Math.max(0,Date.now()-t),l=Math.floor(a/6e4);if(l<1)return s("bgTaskJustNow");if(l<60)return s("bgTaskMinutes",{n:l});const c=Math.floor(l/60);return c<24?s("bgTaskHours",{n:c}):s("bgTaskDays",{n:Math.floor(c/24)})}function Sa({servers:t,send:s,onClose:a}){const l=he(),[c,i]=r.useState(new Set),n=o=>i(d=>{const p=new Set(d);return p.has(o)?p.delete(o):p.add(o),p});return r.useEffect(()=>{s({type:"list_bg_servers"})},[]),e.jsx("div",{className:"modal-backdrop",onClick:a,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(ot,{})," ",l("bgTasks"),t.length>0&&e.jsx("em",{className:"bg-task-count",children:t.length})]}),e.jsx("button",{type:"button",className:"btn",title:l("close"),onClick:a,children:e.jsx(we,{})})]}),t.length===0?e.jsxs("div",{className:"bg-task-empty",children:[e.jsx(ot,{}),e.jsx("span",{children:l("bgTasksEmpty")}),e.jsx("small",{children:l("bgTasksDesc")})]}):e.jsx("ul",{className:"bg-task-list",children:t.map(o=>{const d=!!o.taskId,p=o.taskId??String(o.port);return e.jsxs("li",{className:"bg-task-item",children:[e.jsx("span",{className:"bg-task-icon",title:d?o.plugin:l("bgTaskPort")}),e.jsxs("div",{className:"bg-task-info",children:[e.jsxs("div",{className:"bg-task-line1",children:[d?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:[!d&&e.jsxs("span",{children:[l("bgTaskPid")," ",o.pid]}),e.jsxs("span",{children:[l("bgTaskSince")," ",Ca(o.since,l)]}),d&&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(p)?"open":""}`,title:`${l("bgTaskCommand")}: ${o.command}`,onClick:()=>n(p),children:[e.jsx(Ue,{}),e.jsx("code",{children:o.command})]})]}),e.jsxs("button",{type:"button",className:"btn bg-task-stop",title:l("bgTaskStop"),onClick:()=>s(d?{type:"kill_background_server",taskId:o.taskId}:{type:"kill_background_server",port:o.port}),children:[e.jsx(at,{}),e.jsx("span",{children:l("bgTaskStop")})]})]},p)})}),e.jsxs("div",{className:"bg-task-foot",children:[e.jsxs("button",{type:"button",className:"btn",title:l("bgTaskRefresh"),onClick:()=>s({type:"list_bg_servers"}),children:[e.jsx(ct,{}),e.jsx("span",{children:l("bgTaskRefresh")})]}),e.jsxs("button",{type:"button",className:"btn bg-task-stopall",disabled:t.length===0,title:l("bgTaskStopAll"),onClick:()=>s({type:"kill_background_servers"}),children:[e.jsx(at,{}),e.jsx("span",{children:l("bgTaskStopAll")})]})]})]})})}function Ze(t,s){return t.toLowerCase().includes(s)}function Ta({send:t,sessions:s,projects:a,cwd:l,fileSearch:c,onClose:i,onSwitchSession:n,onSwitchProject:o,onPreviewFile:d}){const p=he(),f=r.useRef(null),[h,v]=r.useState(""),w=r.useDeferredValue(h),[M,L]=r.useState(0),S=r.useRef(1),B=r.useRef(0),j=r.useRef(null);r.useEffect(()=>{t({type:"list_sessions"}),t({type:"list_projects"}),requestAnimationFrame(()=>{var I;return(I=f.current)==null?void 0:I.focus()})},[]);const[b,E]=r.useState(!1);r.useEffect(()=>{j.current&&clearTimeout(j.current);const I=w.trim();if(I)return j.current=setTimeout(()=>{const q=++S.current;B.current=q,E(!0),t({type:"search_files",reqId:q,query:I})},300),()=>{j.current&&clearTimeout(j.current)}},[w]);const R=w.trim().toLowerCase(),T=r.useMemo(()=>R?s.filter(I=>Ze(I.firstMessage??"",R)||Ze(I.name??"",R)||Ze(I.path.split(/[\\/]/).pop()??"",R)).slice(0,20):[],[s,R]),N=r.useMemo(()=>R?a.filter(I=>Ze(I.path,R)).slice(0,10):[],[a,R]),u=r.useMemo(()=>!R||!c||c.reqId!==B.current||!c.ok?[]:c.results,[c,R]);r.useEffect(()=>{c&&c.reqId===B.current&&B.current!==0&&E(!1)},[c]);const y=!!c&&c.ok&&c.truncated,A=r.useMemo(()=>[...T.map(I=>({kind:"session",path:I.path})),...N.map(I=>({kind:"project",path:I.path})),...u.filter(I=>I.type==="file").map(I=>({kind:"file",path:I.path,name:I.name}))],[T,N,u]);r.useEffect(()=>{L(0)},[w]);const U=r.useCallback(I=>{I&&(I.kind==="session"?n(I.path):I.kind==="project"?o(I.path):d(I.path,I.name),i())},[n,o,d,i]);r.useEffect(()=>{const I=q=>{q.key==="Escape"?(q.preventDefault(),q.stopPropagation(),i()):q.key==="ArrowDown"?(q.preventDefault(),L(H=>Math.min(H+1,A.length-1))):q.key==="ArrowUp"?(q.preventDefault(),L(H=>Math.max(H-1,0))):q.key==="Enter"&&(q.preventDefault(),U(A[M]))};return window.addEventListener("keydown",I,!0),()=>window.removeEventListener("keydown",I,!0)},[A,M,U,i]);const te=T.length+N.length+u.length,ue=(I,q,H)=>e.jsxs("div",{className:"gs-section-head",children:[H,e.jsx("span",{children:I}),e.jsx("em",{children:q})]});let ee=-1;return e.jsx("div",{className:"modal-backdrop gs-backdrop",onClick:i,children:e.jsxs("div",{className:"gs-modal",onClick:I=>I.stopPropagation(),children:[e.jsxs("div",{className:"gs-input-row",children:[e.jsx(lt,{}),e.jsx("input",{ref:f,type:"text",value:h,placeholder:p("gsPlaceholder"),onChange:I=>v(I.target.value)}),e.jsx("button",{type:"button",className:"gs-close",title:p("close"),onClick:i,children:e.jsx(we,{})})]}),e.jsxs("div",{className:"gs-results",children:[!R&&e.jsx("div",{className:"gs-empty",children:p("gsHint")}),R&&te===0&&!y&&e.jsx("div",{className:"gs-empty",children:p(b?"gsSearching":"gsNoResults")}),T.length>0&&e.jsxs("div",{className:"gs-section",children:[ue(p("gsSessions"),T.length,e.jsx(ze,{})),T.map(I=>{ee++;const q=ee;return e.jsxs("button",{type:"button",className:q===M?"gs-item active":"gs-item",onMouseEnter:()=>L(q),onClick:()=>U({kind:"session",path:I.path}),children:[e.jsxs("span",{className:"gs-item-title",children:[I.name||I.path.split(/[\\/]/).pop(),e.jsx("em",{className:"gs-item-meta",children:I.messageCount})]}),e.jsx("span",{className:"gs-item-sub",children:I.firstMessage})]},I.path)})]}),N.length>0&&e.jsxs("div",{className:"gs-section",children:[ue(p("gsProjects"),N.length,e.jsx(Ke,{})),N.map(I=>{ee++;const q=ee,H=l&&I.path===l;return e.jsxs("button",{type:"button",className:q===M?"gs-item active":"gs-item",onMouseEnter:()=>L(q),onClick:()=>U({kind:"project",path:I.path}),children:[e.jsxs("span",{className:"gs-item-title",children:[I.path.split(/[\\/]/).pop(),H&&e.jsx("em",{className:"gs-item-meta",children:p("gsCurrentProject")})]}),e.jsx("span",{className:"gs-item-sub",children:I.path})]},I.path)})]}),(u.length>0||R&&y)&&e.jsxs("div",{className:"gs-section",children:[ue(p("gsFiles"),u.length,e.jsx(Is,{})),u.map(I=>{ee++;const q=ee;return e.jsxs("button",{type:"button",className:q===M?"gs-item active":"gs-item",disabled:I.type==="dir",title:I.type==="dir"?void 0:p("gsOpenPreview"),onMouseEnter:()=>L(q),onClick:()=>{I.type==="file"&&U({kind:"file",path:I.path,name:I.name})},children:[e.jsx("span",{className:"gs-item-title",children:I.name}),e.jsx("span",{className:"gs-item-sub",children:I.path})]},`${I.type}:${I.path}`)}),y&&e.jsx("div",{className:"gs-truncated",children:p("gsTruncated")})]})]}),e.jsxs("div",{className:"gs-foot",children:[e.jsxs("span",{children:["↑↓ ",p("gsNavigate")]}),e.jsxs("span",{children:["Enter ",p("gsOpen")]}),e.jsxs("span",{children:["Esc ",p("gsCloseHint")]})]})]})})}const yt=5e3;function Ea({file:t,content:s,send:a,onAddLines:l,onAttach:c,onClose:i}){const n=he(),[o,d]=r.useState(null),[p,f]=r.useState(!1),[h,v]=r.useState(null),[w,M]=r.useState(!1),[L,S]=r.useState(!1),[B,j]=r.useState(!1),[b,E]=r.useState(""),[R,T]=r.useState(!0),N=r.useRef(!1),[u,y]=r.useState(!0),[A,U]=r.useState(!1),[te,ue]=r.useState(100),ee=r.useRef(0),I=r.useRef(!1),q=r.useRef(null);r.useEffect(()=>{f(!0),d(null),v(null),j(!1),E(""),T(!0),N.current=!1,a({type:"read_file",path:t.path})},[t.path,a]),r.useEffect(()=>{s&&s.path===t.path&&(d(s),B||E(s.text),f(!1))},[s,B,t.path]),r.useEffect(()=>{const Q=ce=>{if(ce.key==="Escape"){le();return}if((ce.ctrlKey||ce.metaKey)&&ce.key.toLowerCase()==="s"&&B){ce.preventDefault(),V();return}const ae=ce.target,Ne=ae&&(ae.tagName==="INPUT"||ae.tagName==="TEXTAREA"||ae.isContentEditable);(ce.ctrlKey||ce.metaKey)&&ce.key.toLowerCase()==="a"&&!Ne&&(ce.preventDefault(),C())};return document.addEventListener("keydown",Q),()=>document.removeEventListener("keydown",Q)},[i,o,B,b]),r.useEffect(()=>{const Q=()=>{I.current=!1,M(!1)};return window.addEventListener("mouseup",Q),()=>window.removeEventListener("mouseup",Q)},[]);const H=r.useMemo(()=>{if(!o)return[];const Q=o.text.split(`
19
+ `);return Q.length>0&&Q[Q.length-1]===""&&Q.pop(),Q.slice(0,yt)},[o]),me=(o==null?void 0:o.lines)??0,_=me>yt,O=(Q,ce)=>{if(ce){const ae=ee.current>0?ee.current:Q;v({start:Math.min(ae,Q),end:Math.max(ae,Q)})}else ee.current=Q,v({start:Q,end:Q})},C=()=>{H.length!==0&&(ee.current=1,v({start:1,end:H.length}))},Y=()=>{h&&(l(t.path,t.name,h.start,h.end),S(!0),q.current&&clearTimeout(q.current),q.current=setTimeout(()=>S(!1),1400))},J=o!==null&&o.kind==="text"&&!o.binary&&!o.truncated,ie=()=>{E((o==null?void 0:o.text)??""),j(!1),N.current&&T(!0)},$=()=>{if(B){if(b!==((o==null?void 0:o.text)??"")&&!window.confirm(n("discardFileChanges")))return;ie();return}!J||!o||(N.current=jt(t.name)&&R,jt(t.name)&&T(!1),v(null),E(o.text),j(!0))},V=()=>{!B||!o||!J||a({type:"write_file",path:t.path,text:b})&&(j(!1),N.current&&T(!0),v(null))},le=()=>{B&&b!==((o==null?void 0:o.text)??"")&&!window.confirm(n("discardFileChanges"))||i()},K=Q=>{ue(Math.min(200,Math.max(50,Q)))},oe=h?h.end-h.start+1:0,g=(o==null?void 0:o.binary)??!1,m=(o==null?void 0:o.truncated)??!1,D=(o==null?void 0:o.kind)??"text",X=jt(t.name),de=X&&R&&!B&&D==="text"&&!g,xe=Q=>pt(`/api/file?clientId=${encodeURIComponent(It())}&path=${encodeURIComponent(Q)}`);return e.jsx("div",{className:`fp-overlay ${A?"fullscreen":""}`,onMouseDown:Q=>{Q.target===Q.currentTarget&&le()},children:e.jsxs("div",{className:`fp ${A?"fullscreen":""}`,style:{"--fp-zoom":te/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&&D==="text"&&!g&&n("fileLines",{n:me}),o&&` · ${Ma(o.size)}`]}),e.jsxs("span",{className:"fp-head-actions",children:[X&&D==="text"&&!g&&o&&e.jsx("button",{type:"button",className:`fp-attach markdown ${R?"on":""}`,"data-tip":n(R?"showMarkdownSource":"showMarkdownPreview"),disabled:B,onClick:()=>T(Q=>!Q),children:R?e.jsx(kt,{}):e.jsx(Fn,{})}),D==="text"&&!g&&o&&e.jsx("button",{type:"button",className:`fp-attach edit ${B?"on":""}`,"data-tip":n(m?"fileEditTruncated":B?"exitEditFile":"editFile"),disabled:!J&&!B,onClick:$,children:e.jsx(wt,{})}),D==="text"&&!g&&!de&&e.jsx("button",{type:"button",className:`fp-attach wrap ${u?"on":""}`,"data-tip":n(u?"disableWrap":"enableWrap"),onClick:()=>y(Q=>!Q),children:e.jsx(_n,{})}),D==="text"&&o&&e.jsxs("span",{className:"fp-zoom",children:[e.jsx("button",{type:"button",className:"fp-attach zoom-out","data-tip":n("zoomOut"),disabled:te<=50,onClick:()=>K(te-10),children:e.jsx(yn,{})}),e.jsxs("button",{type:"button",className:"fp-zoom-val",title:n("resetZoom"),onClick:()=>ue(100),children:[te,"%"]}),e.jsx("button",{type:"button",className:"fp-attach zoom-in","data-tip":n("zoomIn"),disabled:te>=200,onClick:()=>K(te+10),children:e.jsx(jn,{})})]}),D!=="video"&&D!=="none"&&e.jsx("button",{type:"button",className:"fp-attach inline","data-tip":n("attachInlineTip"),onClick:()=>c(t.path,t.name,"inline"),children:e.jsx(qe,{})}),e.jsx("button",{type:"button",className:"fp-attach ref","data-tip":n("referenceTip"),onClick:()=>c(t.path,t.name,"reference"),children:e.jsx(bt,{})}),e.jsx("button",{type:"button",className:`fp-attach full ${A?"on":""}`,"data-tip":n(A?"exitFullscreen":"fullscreen"),onClick:()=>U(Q=>!Q),children:A?e.jsx(En,{}):e.jsx(Pn,{})}),e.jsx("button",{type:"button",className:"fp-close",title:n("close"),onClick:le,children:e.jsx(we,{})})]})]}),m&&D==="text"&&!g&&e.jsx("div",{className:"fp-notice",children:n("previewTruncated")}),p&&!o&&e.jsx("div",{className:"fp-empty",children:n("loading")}),!p&&D==="none"&&!g&&e.jsx("div",{className:"fp-empty",children:n("previewNotSupported")}),!p&&D==="image"&&e.jsx("div",{className:"fp-media-wrap",children:e.jsx("img",{className:"fp-media",src:xe(t.path),alt:t.name})}),!p&&D==="video"&&e.jsx("div",{className:"fp-media-wrap",children:e.jsx("video",{className:"fp-media",src:xe(t.path),controls:!0,preload:"metadata"})}),!p&&de&&o&&e.jsx("div",{className:"fp-markdown msg-text",children:e.jsx("div",{className:"fp-markdown-zoom",children:e.jsx(ht,{text:o.text})})}),!p&&g&&D!=="image"&&D!=="video"&&o&&e.jsxs("div",{className:"fp-hex-wrap",children:[e.jsxs("div",{className:"fp-notice",children:[n("binaryFile"),o.truncated&&n("binaryHexTruncated")]}),e.jsx("pre",{className:"fp-hex",children:o.text})]}),!p&&B&&D==="text"&&!g&&o&&e.jsx("textarea",{className:`fp-editor ${u?"":"no-wrap"}`,value:b,onChange:Q=>E(Q.target.value),wrap:u?"soft":"off",spellCheck:!1,autoFocus:!0}),!p&&!de&&!B&&D==="text"&&!g&&o&&H.length===0&&e.jsx("div",{className:"fp-empty",children:n("emptyFile")}),!p&&!de&&!B&&D==="text"&&!g&&H.length>0&&e.jsxs("div",{className:`fp-code ${w?"dragging":""} ${u?"":"no-wrap"}`,onMouseDown:Q=>{Q.button===0&&Q.preventDefault()},children:[H.map((Q,ce)=>{const ae=ce+1,Ne=h!==null&&ae>=h.start&&ae<=h.end;return e.jsxs("div",{className:`fp-line ${Ne?"sel":""}`,onMouseDown:Te=>{Te.button===0&&(O(ae,Te.shiftKey),I.current=!0,M(!0))},onMouseEnter:()=>{I.current&&O(ae,!0)},children:[e.jsx("span",{className:"fp-num",children:ae}),e.jsx("span",{className:"fp-code-text",children:Q})]},ae)}),_&&e.jsx("div",{className:"fp-lines-note",children:n("previewLinesTruncated",{n:yt})})]}),e.jsx("div",{className:"fp-foot",children:B?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"fp-hint",children:n("editFile")}),e.jsxs("div",{className:"fp-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:$,children:n("cancel")}),e.jsxs("button",{type:"button",className:"btn primary",disabled:b===((o==null?void 0:o.text)??""),onClick:V,children:[e.jsx(Cn,{})," ",n("saveFile")]})]})]}):!de&&D==="text"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"fp-hint",children:h?n("selectedRange",{n:oe,start:h.start,end:h.end}):n("selectLinesHint")}),e.jsxs("div",{className:"fp-actions",children:[e.jsx("button",{type:"button",className:"btn",disabled:H.length===0,onClick:C,children:n("selectAll")}),e.jsx("button",{type:"button",className:"btn",disabled:!h,onClick:()=>v(null),children:n("clearSelection")}),e.jsxs("button",{type:"button",className:"btn primary",disabled:!h||g,onClick:Y,children:[L?e.jsx(mt,{}):null,n(L?"addedToChat":"addToChat")]})]})]})})]})})}function jt(t){const s=t.toLowerCase();return s.endsWith(".md")||s.endsWith(".markdown")}function Ma(t){return t>=1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:t>=1024?`${Math.round(t/1024)} KB`:`${t} B`}const Qs="pi-web-sounds",Ve={enabled:!0,question:!0,done:!0,start:!1,error:!0,volume:100};function Ys(){try{const t=localStorage.getItem(Qs);if(!t)return{...Ve};const s=JSON.parse(t),a={...Ve,...s};for(const l of["enabled","question","done","start","error"])typeof a[l]!="boolean"&&(a[l]=Ve[l]);return typeof a.volume!="number"||!Number.isFinite(a.volume)?a.volume=Ve.volume:a.volume=Math.round(Math.max(0,Math.min(100,a.volume))/5)*5,a}catch{return{...Ve}}}function Pa(t){try{localStorage.setItem(Qs,JSON.stringify(t))}catch{}}let Ge=null;function Ra(){try{if(!Ge){const t=window.AudioContext??window.webkitAudioContext;if(!t)return null;Ge=new t}return Ge.state==="suspended"&&Ge.resume(),Ge}catch{return null}}const Ia=[{type:"sine",freq:587.33,start:0,dur:.13,peak:.5},{type:"sine",freq:880,start:.11,dur:.24,peak:.5}],La=[{type:"sine",freq:880,start:0,dur:.15,peak:.35},{type:"sine",freq:587.33,start:.15,dur:.32,peak:.35}],Ba=[{type:"triangle",freq:660,start:0,dur:.08,peak:.22}],Da=[{type:"square",freq:220,start:0,dur:.16,peak:.18},{type:"square",freq:174.61,start:.18,dur:.26,peak:.18}],$a={question:Ia,done:La,start:Ba,error:Da};function _a(t,s,a){const l=t.createOscillator(),c=t.createGain();l.type=s.type,l.frequency.value=s.freq;const i=t.currentTime+s.start,n=Math.max(1e-4,s.peak*a);c.gain.setValueAtTime(1e-4,i),c.gain.exponentialRampToValueAtTime(n,i+.012),c.gain.exponentialRampToValueAtTime(1e-4,i+s.dur),l.connect(c),c.connect(t.destination),l.start(i),l.stop(i+s.dur+.05)}function Je(t,s=Ys()){if(!s.enabled||!s[t])return;const a=Ra();if(!a)return;const l=Math.max(0,Math.min(1,s.volume/100));for(const c of $a[t])_a(a,c,l)}const Et="pi-web-ui:theme",Xs="dark",bs="theme-stylesheet",ks="pi-web-ui:theme-change";function Zs(){try{const t=localStorage.getItem(Et);if(t&&t!==Xs)return t}catch{}return null}function Fa(t){try{t?localStorage.setItem(Et,t):localStorage.removeItem(Et)}catch{}}function en(t){let s=document.getElementById(bs);if(!t){s==null||s.remove(),window.dispatchEvent(new CustomEvent(ks));return}s||(s=document.createElement("link"),s.id=bs,s.rel="stylesheet",document.head.appendChild(s)),s.href=`/themes/${encodeURIComponent(t)}.css`,s.onload=()=>window.dispatchEvent(new CustomEvent(ks))}async function Aa(){try{const t=await fetch(pt("/api/themes"));if(!t.ok)return[];const s=await t.json();return Array.isArray(s.themes)?s.themes:[]}catch{return[]}}function Wa(){const[t,s]=r.useState([]),[a,l]=r.useState(()=>Zs());return r.useEffect(()=>{let i=!1;return Aa().then(n=>{i||s(n)}),()=>{i=!0}},[]),r.useEffect(()=>{en(a),Fa(a)},[a]),{themes:t,theme:a,switchTheme:i=>l(i===Xs?null:i)}}function Ga(){const t=getComputedStyle(document.documentElement),s=(a,l)=>t.getPropertyValue(a).trim()||l;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 Oa=r.lazy(()=>Ts(()=>import("./TerminalPanel-ClyNBJJt.js"),__vite__mapDeps([0,1,2,3,4])).then(t=>({default:t.TerminalPanel})));function Ha({notice:t,onDismiss:s}){const a=he(),[l,c]=r.useState(!1);r.useEffect(()=>{if(l)return;const n=setTimeout(()=>s(t.id),t.level==="error"?12e3:7e3);return()=>clearTimeout(n)},[l,t.id,t.level,s]);const i=t.level==="error"?Hn:t.level==="warning"?On:Bn;return e.jsxs("div",{className:`notice notice-${t.level}${l?" paused":""}`,role:"status",onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),children:[e.jsx(i,{className:"notice-icon"}),e.jsx("span",{className:"notice-text",children:t.text}),e.jsx("button",{type:"button",className:"notice-close",title:a("close"),onClick:()=>s(t.id),children:e.jsx(we,{})})]})}const Ua=[],tn=180,sn=520,nn=240,an=t=>`pi-web-ui:${t}-panel-width`;function ws(t){const s=Number(localStorage.getItem(an(t)));return Number.isFinite(s)&&s>=tn&&s<=sn?s:nn}function Ns({side:t,width:s,onResize:a}){const l=he(),c=r.useCallback(i=>{i.preventDefault();const n=i.clientX,o=s;let d=o;const p=h=>{const v=t==="left"?h.clientX-n:n-h.clientX;d=Math.min(sn,Math.max(tn,Math.round(o+v))),a(d)},f=()=>{window.removeEventListener("pointermove",p),window.removeEventListener("pointerup",f),document.body.classList.remove("panel-resizing"),localStorage.setItem(an(t),String(d))};window.addEventListener("pointermove",p),window.addEventListener("pointerup",f),document.body.classList.add("panel-resizing")},[t,s,a]);return e.jsx("div",{className:`resize-handle resize-${t}`,title:l("dragToResize"),onPointerDown:c,onDoubleClick:()=>a(nn)})}function qa(){var je,ge,be,Se,Dt,$t,_t,Ft,At,Wt,Ot,Ht,Ut,qt;const t=he(),{chat:s,send:a,dismissNotice:l,pushNotice:c,terminal:i}=mi(),[n,o]=r.useState([]),[d,p]=r.useState(null),[f,h]=r.useState(!1),[v,w]=r.useState("chat"),M=r.useMemo(()=>s.plugins.filter(P=>{var W,ne;return!((ne=(W=s.settings)==null?void 0:W.disabledPlugins)!=null&&ne.includes(P.id))}),[s.plugins,(je=s.settings)==null?void 0:je.disabledPlugins]),[L,S]=r.useState([]);r.useEffect(()=>ni(S),[]),r.useEffect(()=>{ii(M,s.pluginsEpoch)},[M,s.pluginsEpoch]);const[B,j]=r.useState(()=>ws("left")),[b,E]=r.useState(()=>ws("right")),R=r.useCallback(P=>j(P),[]),T=r.useCallback(P=>E(P),[]),[N,u]=r.useState(null),[y,A]=r.useState(()=>window.matchMedia("(max-width: 768px)").matches);r.useEffect(()=>{const P=window.matchMedia("(max-width: 768px)"),W=ne=>A(ne.matches);return P.addEventListener("change",W),()=>P.removeEventListener("change",W)},[]);const[U,te]=r.useState(!1),[ue,ee]=r.useState(!1),[I,q]=r.useState(!1),[H,me]=r.useState(!1),[_,O]=r.useState(!1);r.useEffect(()=>{const P=W=>{var Pe,zt;const ne=W.detail,fe=(ne==null?void 0:ne.title)||"插件命令",ve=ne==null?void 0:ne.command;if(!ve||!s.ready)return;const Ce={name:fe,command:ve,cwd:"${pwd}"},ye=s.terminals.find(gt=>gt.title===fe);if(ye)i.restart(ye.id),a({type:"run_command",terminalId:ye.id,conversationId:ye.conversationId,command:Ce,cols:80,rows:24});else{const gt=$e();i.create({id:gt,conversationId:s.activeConversationId||((Pe=s.state)==null?void 0:Pe.conversationId)||"",title:fe,cwd:((zt=s.state)==null?void 0:zt.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:Ce})}w("terminal")};return window.addEventListener("pi-web-ui:plugin-run-command",P),()=>window.removeEventListener("pi-web-ui:plugin-run-command",P)},[s,i,a]),r.useEffect(()=>{const P=W=>{!(W.ctrlKey||W.metaKey)||W.key.toLowerCase()!=="k"||(W.preventDefault(),O(ne=>!ne))};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[]);const[C,Y]=r.useState(Ys),{themes:J,theme:ie,switchTheme:$}=Wa(),V=r.useRef(null),le=r.useRef(null),K=r.useRef(0),oe=r.useRef(!1),g=r.useRef(s.terminals);r.useEffect(()=>{Pa(C)},[C]),r.useEffect(()=>{var W;const P=g.current;g.current=s.terminals;for(const ne of s.terminals){const fe=((W=ne.command)==null?void 0:W.command)??"",ve=P.find(Ce=>Ce.id===ne.id);!(ve!=null&&ve.running)||ne.running||(fe.startsWith("pi remove ")?a({type:"extensions_reload"}):(fe.startsWith("pi-web-ui install ")||fe.startsWith("pi-web-ui uninstall "))&&a({type:"plugins_reload"}))}},[s.terminals,a]),r.useEffect(()=>{var ne;const P=((ne=s.state)==null?void 0:ne.isStreaming)??!1,W=V.current;V.current=P,W!==null&&(!W&&P?Je("start",C):W&&!P&&Je("done",C))},[(ge=s.state)==null?void 0:ge.isStreaming,C]),r.useEffect(()=>{var W;const P=((W=s.dialog)==null?void 0:W.id)??null;P!==null&&P!==le.current&&Je("question",C),le.current=P},[s.dialog,C]),r.useEffect(()=>{const P=[...s.notices].reverse().find(W=>W.level==="error");P&&P.id!==K.current&&(K.current=P.id,Je("error",C))},[s.notices,C]);const m=(P,W,ne,fe=!1,ve)=>{const Ce=`${P}|${ne}|${ve?`${ve.start}-${ve.end}`:""}`;o(ye=>ye.some(Pe=>`${Pe.path}|${Pe.mode}|${Pe.lines?`${Pe.lines.start}-${Pe.lines.end}`:""}`===Ce)?ye:[...ye,{path:P,name:W,mode:ne,isDir:fe,...ve?{lines:ve}:{}}])},D=P=>o(W=>W.filter(ne=>ne.key?ne.key!==P:ne.path!==P)),X=r.useCallback(P=>(!P.type.startsWith("list_")&&!P.type.startsWith("get_")&&u(null),a(P)),[a]),de=r.useRef(0),xe=r.useRef(0),Q=P=>{var fe;const W=Date.now();(fe=s.state)!=null&&fe.model&&!s.state.model.vision&&W-xe.current>1e4&&(xe.current=W,c("warning",t("imageNotSupported")));const ne=`paste-${++de.current}`;o(ve=>[...ve,{path:"",key:ne,name:P.name,mode:"inline",imageData:P.data,mimeType:P.mimeType}])},ce=async P=>{for(const W of P){const ne=await Us(W);if(!ne){c("error",t("imageLoadFailed",{name:W.name}));continue}Q(ne)}},ae=20*1024*1024,Ne=r.useRef(0),Te=async P=>{if(P.size>ae){c("warning",t("fileTooLarge",{name:P.name,size:ae/1024/1024}));return}let W;try{W=(await new Promise((ve,Ce)=>{const ye=new FileReader;ye.onload=()=>ve(ye.result),ye.onerror=()=>Ce(ye.error??new Error("read failed")),ye.readAsDataURL(P)})).replace(/^data:[^;]*;base64,/,"")}catch{c("error",t("fileLoadFailed",{name:P.name}));return}const ne=`upload-${++Ne.current}`;o(fe=>[...fe,{path:"",key:ne,name:P.name,mode:"inline",fileData:W,size:P.size,mimeType:P.type||void 0}])},Ie=async P=>{for(const W of P)Me(W.type)?await ce([W]):await Te(W)},Le=r.useCallback((P,W,ne)=>{a({type:"edit_message",messageId:P,text:W,attachments:ne})},[a]),Fe=r.useCallback(()=>ee(!0),[]),Ae=r.useCallback(()=>o([]),[]),k=r.useCallback(D,[]),F=r.useCallback(ce,[ce]),re=r.useCallback(Ie,[Ie]),se=(be=s.state)==null?void 0:be.model,pe=(Se=s.state)==null?void 0:Se.thinkingLevel,x=(Dt=s.state)==null?void 0:Dt.availableThinkingLevels,Z=r.useMemo(()=>se?{model:se,thinkingLevel:pe??"off",availableThinkingLevels:x??[]}:null,[se,pe,x]),G=r.useCallback(()=>{var P,W;return!s.ready||s.terminals.length!==0?!1:(i.create({id:$e(),conversationId:s.activeConversationId||((P=s.state)==null?void 0:P.conversationId)||"",title:t("terminalTitle",{n:1}),cwd:((W=s.state)==null?void 0:W.cwd)??"",cols:80,rows:24,running:!0,exitCode:null}),!0)},[s.ready,($t=s.state)==null?void 0:$t.cwd,s.terminals.length,t,i]);return r.useEffect(()=>{if(oe.current){if(v!=="terminal"||s.terminals.length!==0){oe.current=!1;return}G()&&(oe.current=!1)}},[s.terminals.length,G,v]),e.jsxs("div",{className:"app",onDragOver:P=>{var W;Array.from(((W=P.dataTransfer)==null?void 0:W.types)??[]).includes("Files")&&(P.preventDefault(),h(!0))},onDragLeave:P=>{P.currentTarget.contains(P.relatedTarget)||h(!1)},onDrop:P=>{var ve,Ce;if(h(!1),!Array.from(((ve=P.dataTransfer)==null?void 0:ve.types)??[]).includes("Files"))return;P.preventDefault();const W=Array.from(((Ce=P.dataTransfer)==null?void 0:Ce.files)??[]);if(W.length===0){c("warning",t("foldersNotSupported"));return}const ne=W.filter(ye=>Me(ye.type)),fe=W.filter(ye=>!Me(ye.type));ne.length>0&&ce(ne),fe.length>0&&Ie(fe)},children:[f&&e.jsx("div",{className:"app-drop-overlay","aria-hidden":!0,children:e.jsxs("span",{children:["📎 ",t("dropHereToAttach")]})}),e.jsx(Gn,{chat:s,send:a,terminal:i,view:v,plugins:M,onViewChange:P=>{oe.current=P==="terminal"&&s.terminals.length===0,oe.current&&G()&&(oe.current=!1),w(P),u(null)},onOpenPanel:u,onOpenSettings:()=>q(!0),onOpenBgTasks:()=>me(!0),onOpenGlobalSearch:()=>O(!0),sound:C,onSoundChange:Y,onSoundPreview:P=>Je(P,C),themes:J,theme:ie,onThemeChange:$}),s.protocolMismatch&&e.jsxs("div",{className:"protocol-banner",children:["⚠ ",t("protocolMismatch")]}),e.jsx("div",{className:"notices",children:s.notices.map(P=>e.jsx(Ha,{notice:P,onDismiss:l},P.id))}),e.jsxs("div",{className:"layout",style:{"--left-w":`${B}px`,"--right-w":`${b}px`},children:[N&&e.jsx("div",{className:"drawer-backdrop",onClick:()=>u(null)}),e.jsxs("div",{className:`view-pane ${v==="chat"?"":"hidden"}`,children:[e.jsx("div",{className:`panel-drawer drawer-left ${N==="left"?"open":""}`,children:e.jsx(Qn,{send:X,active:!y||N==="left",ready:s.ready,status:s.status,cwd:((_t=s.state)==null?void 0:_t.cwd)??"",sessionFile:((Ft=s.state)==null?void 0:Ft.sessionFile)??null,conversations:s.conversations,sessions:s.sessions,projects:s.projects,activeConversationId:s.activeConversationId})}),!y&&e.jsx(Ns,{side:"left",width:B,onResize:R}),e.jsxs("main",{className:"main",children:[s.state?e.jsx(oa,{state:s.state,liveOutputs:s.liveOutputs,toolStatuses:s.toolStatuses,onEdit:Le,onKillBash:()=>a({type:"abort_bash"}),thinkingWrap:((At=s.settings)==null?void 0:At.thinkingWrap)??!0,toolsWrap:((Wt=s.settings)==null?void 0:Wt.toolsWrap)??!0},s.state.conversationId??"boot"):e.jsx("div",{className:"boot-wait",children:s.ready?t("loadingSession"):t("connectingServer")}),e.jsx(ma,{send:a,goal:s.goal,models:s.models,modelsLoading:s.modelsLoading,activeConversationId:s.activeConversationId}),s.dialog&&e.jsx(ga,{dialog:s.dialog,send:a}),e.jsx(ua,{send:a,ready:s.ready,streaming:((Ot=s.state)==null?void 0:Ot.isStreaming)??!1,messages:((Ht=s.state)==null?void 0:Ht.messages)??Ua,slashCommands:s.slashCommands,modelState:Z,models:s.models,modelsLoading:s.modelsLoading,attachments:n,onRemoveAttachment:k,onAddImageFiles:F,onAddLocalFiles:re,onNotice:c,onManageModels:Fe,onSent:Ae})]}),!y&&e.jsx(Ns,{side:"right",width:b,onResize:T}),e.jsx("div",{className:`panel-drawer drawer-right ${N==="right"?"open":""}`,children:e.jsx(bi,{send:X,files:s.files,fileChanged:s.fileChanged,widgets:s.widgets,cwd:((Ut=s.state)==null?void 0:Ut.cwd)??"",onAttach:(P,W,ne,fe)=>{u(null),m(P,W,ne,fe)},onPreview:(P,W)=>{u(null),p({path:P,name:W})},onNotice:(P,W)=>c(P,W)})})]}),e.jsx("div",{className:`view-pane ${v==="terminal"?"":"hidden"}`,children:e.jsx(r.Suspense,{fallback:null,children:e.jsx(Oa,{chat:s,send:a,terminal:i})})}),e.jsx("div",{className:`view-pane ${v==="git"?"":"hidden"}`,children:e.jsx(xa,{chat:s,send:a,terminal:i,active:v==="git",onSwitchToTerminal:()=>w("terminal")})}),L.map(P=>{const W=`plugin:${P.info.id}`;return e.jsx("div",{className:`view-pane ${v===W?"":"hidden"}`,children:e.jsx(va,{entry:P,send:a})},P.info.id)})]}),e.jsx(pa,{chat:s,send:a}),d&&e.jsx(Ea,{file:d,content:s.fileContent,send:a,onAddLines:(P,W,ne,fe)=>m(P,W,"lines",!1,{start:ne,end:fe}),onAttach:(P,W,ne)=>m(P,W,ne),onClose:()=>p(null)}),s.ready&&s.state&&s.state.piConfigured===!1&&!U&&!ue&&e.jsx(ya,{send:a,piConfigured:s.state.piConfigured,piAgentInstalled:s.state.piAgentInstalled,providers:s.providers,installResult:s.installResult,onClose:()=>te(!0)}),ue&&e.jsx(ka,{send:a,providers:s.modelsConfig,providerStatus:s.providers,fetchModelsResult:s.fetchModelsResult,refreshProviderResult:s.refreshProviderResult,cloneProviderResult:s.cloneProviderResult,onClose:()=>ee(!1)}),I&&e.jsx(Na,{chat:s,send:a,terminal:i,onSwitchToTerminal:()=>w("terminal"),onClose:()=>q(!1)}),H&&e.jsx(Sa,{servers:s.bgServers,send:a,onClose:()=>me(!1)}),_&&e.jsx(Ta,{send:a,sessions:s.sessions,projects:s.projects,cwd:((qt=s.state)==null?void 0:qt.cwd)??"",fileSearch:s.fileSearch,onClose:()=>O(!1),onSwitchSession:P=>{a({type:"switch_session",path:P})},onSwitchProject:P=>{a({type:"set_cwd",path:P})},onPreviewFile:(P,W)=>{p({path:P,name:W})}})]})}Yn();en(Zs());cn.createRoot(document.getElementById("root")).render(e.jsx(r.StrictMode,{children:e.jsx(Kn,{children:e.jsx(qa,{})})}));export{ct as F,ks as T,qe as a,Ga as b,Va as c,Zt as d,De as e,we as f,Mn as g,Ue as h,$e as r,he as u};