@youweichen/pi-web-ui 0.45.2 → 0.46.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.
- package/dist/server/agent-service.js +43 -2
- package/dist/server/plugin-updater.js +20 -1
- package/package.json +1 -1
- package/web/dist/assets/{TerminalPanel-DTPa-GPY.js → TerminalPanel-CL7_iOws.js} +1 -1
- package/web/dist/assets/{abnfDiagram-VCTEODGH-3OBIjZzo.js → abnfDiagram-VCTEODGH-BKPpCrz_.js} +1 -1
- package/web/dist/assets/{arc-QnNbtI3G.js → arc-C23hgJIX.js} +1 -1
- package/web/dist/assets/{architectureDiagram-5GKGNRK7-BRC6l1C0.js → architectureDiagram-5GKGNRK7-dhOJ0tIS.js} +1 -1
- package/web/dist/assets/{blockDiagram-I7D4REHJ-QtokGhle.js → blockDiagram-I7D4REHJ-T5jRCGjd.js} +1 -1
- package/web/dist/assets/{c4Diagram-7LVT6UL2-DrXgUAH_.js → c4Diagram-7LVT6UL2-mWuNh2dO.js} +1 -1
- package/web/dist/assets/channel-BCfi_Ba5.js +1 -0
- package/web/dist/assets/{chunk-2Q5K7J3B-C8iJ92Ek.js → chunk-2Q5K7J3B-DOE-hNOM.js} +1 -1
- package/web/dist/assets/{chunk-5VM5RSS4-C08WMGbd.js → chunk-5VM5RSS4-EtaQHwdB.js} +1 -1
- package/web/dist/assets/{chunk-F27PBJKO-BTyqWEjg.js → chunk-F27PBJKO-BEVAlITo.js} +1 -1
- package/web/dist/assets/{chunk-IMKFNOWR-BZz8_wBp.js → chunk-IMKFNOWR-LS0UAssg.js} +1 -1
- package/web/dist/assets/{chunk-JWPE2WC7-Bp8exp_9.js → chunk-JWPE2WC7-BxQUQ7dH.js} +1 -1
- package/web/dist/assets/{chunk-POPQ4Y6H-FDNtBgdZ.js → chunk-POPQ4Y6H-BPk8DcZO.js} +1 -1
- package/web/dist/assets/{chunk-SVP7TREG-B4gluy_M.js → chunk-SVP7TREG-BOWUorML.js} +1 -1
- package/web/dist/assets/{chunk-TICWLB2K-DpVfoRrb.js → chunk-TICWLB2K-OJjESJUC.js} +1 -1
- package/web/dist/assets/{chunk-XXDRQBXY-DwTeYIe6.js → chunk-XXDRQBXY-COOAF-eP.js} +1 -1
- package/web/dist/assets/classDiagram-ZZMXUADV-yqBppQ5u.js +1 -0
- package/web/dist/assets/classDiagram-v2-VYDZK3BY-yqBppQ5u.js +1 -0
- package/web/dist/assets/{cose-bilkent-JH36ORCC-D9QpWzlD.js → cose-bilkent-JH36ORCC-C1JwoJmN.js} +1 -1
- package/web/dist/assets/{cynefin-OW5HDTMX-jCEkLFdf.js → cynefin-OW5HDTMX-DmSGPBbN.js} +1 -1
- package/web/dist/assets/{cynefinDiagram-5FMLGOSQ-dVBRtFzn.js → cynefinDiagram-5FMLGOSQ-CIsEXfZy.js} +1 -1
- package/web/dist/assets/{dagre-GXQ25YYZ-Ck-JYQBh.js → dagre-GXQ25YYZ-BsHrnq08.js} +1 -1
- package/web/dist/assets/{diagram-S7CK7UJ4-DDG_bD3X.js → diagram-S7CK7UJ4-B9G0tgH2.js} +1 -1
- package/web/dist/assets/{diagram-UQ7AKVKN-doLowaGS.js → diagram-UQ7AKVKN-_JgVa7Wv.js} +1 -1
- package/web/dist/assets/{diagram-VSXAHHWV-Bj5leyj8.js → diagram-VSXAHHWV-CKhfNWNM.js} +1 -1
- package/web/dist/assets/{diagram-VX7I27RA-CjXqoFDD.js → diagram-VX7I27RA-BrMgRfub.js} +1 -1
- package/web/dist/assets/{diagram-Z3DM3KII-D__qC8Iy.js → diagram-Z3DM3KII-BKlCUZG7.js} +1 -1
- package/web/dist/assets/{ebnfDiagram-PWID7BFC-tBnh13AS.js → ebnfDiagram-PWID7BFC-BhS-laX7.js} +1 -1
- package/web/dist/assets/{erDiagram-RLTQ6QDP-Cbod1iTi.js → erDiagram-RLTQ6QDP-Bicr1cgA.js} +1 -1
- package/web/dist/assets/{flowDiagram-HODETNUW-Bq-zlqMG.js → flowDiagram-HODETNUW-CwN50VFN.js} +1 -1
- package/web/dist/assets/{ganttDiagram-EL5Y4UJY-DFJTndUE.js → ganttDiagram-EL5Y4UJY-DdGF6wOu.js} +1 -1
- package/web/dist/assets/{gitGraphDiagram-WWUBYQGX-DcEi9nDs.js → gitGraphDiagram-WWUBYQGX-CQWE0duT.js} +1 -1
- package/web/dist/assets/index-C-XJ-ly_.js +26 -0
- package/web/dist/assets/index-DPHpyI7l.css +10 -0
- package/web/dist/assets/{infoDiagram-27XIBGKW-BZNZJWoJ.js → infoDiagram-27XIBGKW-DSiF9D9z.js} +1 -1
- package/web/dist/assets/{ishikawaDiagram-5VMMS53U-DqnNYeKy.js → ishikawaDiagram-5VMMS53U-Dmwa_H3U.js} +1 -1
- package/web/dist/assets/{journeyDiagram-3NMN7TZE-DERTsG8q.js → journeyDiagram-3NMN7TZE-xSKoWUXW.js} +1 -1
- package/web/dist/assets/{kanban-definition-UXKFOSKX-KImwxyl_.js → kanban-definition-UXKFOSKX-BjdQTjeP.js} +1 -1
- package/web/dist/assets/{layout-BH2O4YE8.js → layout-BihLpYDs.js} +1 -1
- package/web/dist/assets/{linear-CmJWcbZf.js → linear-BEtuTZH6.js} +1 -1
- package/web/dist/assets/{mermaid.core-BqE9WdEq.js → mermaid.core-DDk4A0BP.js} +5 -5
- package/web/dist/assets/{mindmap-definition-YA3MSWOX-BolJqx9C.js → mindmap-definition-YA3MSWOX-vyLVeeNj.js} +1 -1
- package/web/dist/assets/{pegDiagram-XKGWAZYB-BwDKfPEj.js → pegDiagram-XKGWAZYB-CiJBX8pg.js} +1 -1
- package/web/dist/assets/{pieDiagram-E7YTZNPT-D9giHNCe.js → pieDiagram-E7YTZNPT-pjZ_fcHc.js} +1 -1
- package/web/dist/assets/{quadrantDiagram-AXDQQJYC-BtYHmNEC.js → quadrantDiagram-AXDQQJYC-Cp-mghRB.js} +1 -1
- package/web/dist/assets/{railroadDiagram-O6MQD6OU-FEOhYVmW.js → railroadDiagram-O6MQD6OU-DJbRWcUS.js} +1 -1
- package/web/dist/assets/{requirementDiagram-BXWQKSXE-zqJeWuXp.js → requirementDiagram-BXWQKSXE-DNLHnruR.js} +1 -1
- package/web/dist/assets/{sankeyDiagram-P5KCCOFB-BbUWBYdO.js → sankeyDiagram-P5KCCOFB-DjOj5iQU.js} +1 -1
- package/web/dist/assets/{sequenceDiagram-WJ2MYXX4-CkLzAx94.js → sequenceDiagram-WJ2MYXX4-CVGakqCw.js} +1 -1
- package/web/dist/assets/{sizeCapture-INFHLROL-Cu_Hov-C.js → sizeCapture-INFHLROL-X3bYvvQk.js} +1 -1
- package/web/dist/assets/{stateDiagram-D77RDMKH-B3r-CwIC.js → stateDiagram-D77RDMKH-8o65SNy_.js} +1 -1
- package/web/dist/assets/stateDiagram-v2-MP3YSRHH-B-PRjFjM.js +1 -0
- package/web/dist/assets/{swimlanes-42K2YHIH-YDxAaBu_.js → swimlanes-42K2YHIH-D0YDGlUe.js} +1 -1
- package/web/dist/assets/swimlanesDiagram-VR7AAH4N-CmQs4l8c.js +8 -0
- package/web/dist/assets/{timeline-definition-24CTP7MA-B2Xo7om1.js → timeline-definition-24CTP7MA-CGmS1IQy.js} +1 -1
- package/web/dist/assets/{vennDiagram-4TSXK5OY-Dek7fJMD.js → vennDiagram-4TSXK5OY-DtcOF61-.js} +1 -1
- package/web/dist/assets/{wardleyDiagram-VM6X3IG4-CmXnKCpv.js → wardleyDiagram-VM6X3IG4-DnEMdzmM.js} +1 -1
- package/web/dist/assets/{xychartDiagram-S5SC5T6Z-CJ9917hr.js → xychartDiagram-S5SC5T6Z-aX9QskX7.js} +1 -1
- package/web/dist/index.html +2 -2
- package/web/dist/assets/channel-j9anJgKu.js +0 -1
- package/web/dist/assets/classDiagram-ZZMXUADV-BKdhhCr1.js +0 -1
- package/web/dist/assets/classDiagram-v2-VYDZK3BY-BKdhhCr1.js +0 -1
- package/web/dist/assets/index-BeCUh6J7.js +0 -23
- package/web/dist/assets/index-BjqEFNTc.css +0 -10
- package/web/dist/assets/stateDiagram-v2-MP3YSRHH-Bo79NQZb.js +0 -1
- package/web/dist/assets/swimlanesDiagram-VR7AAH4N--G-JueY8.js +0 -8
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/mermaid.core-BqE9WdEq.js","assets/markdown-CUPbftfV.js","assets/TerminalPanel-DTPa-GPY.js","assets/xterm-D1D2FVe3.js","assets/react-ZkKJMDQQ.js","assets/TerminalPanel-6GBZ9nXN.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{R as $e,a as r,j as e,M as Ms,b as cn,c as dn,H as fe,d as un,e as mn,f as pn,h as hn,i as gn,k as fn,l as xn,m as vn,n as yn,o as jn,p as bn,q as kn,s as Nn,t as wn,u as Cn,v as Sn,w as Tn,x as En,y as Mn,z as Ln,A as Pn,B as Rn,C as In,D as Dn,E as $n,F as Bn,G as Fn}from"./markdown-CUPbftfV.js";import{r as Ls}from"./react-ZkKJMDQQ.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 st={},Jt;function _n(){if(Jt)return st;Jt=1;var t=Ls();return st.createRoot=t.createRoot,st.hydrateRoot=t.hydrateRoot,st}var An=_n();const On="modulepreload",Wn=function(t){return"/"+t},Qt={},Pt=function(s,a,l){let c=Promise.resolve();if(a&&a.length>0){let n=function(u){return Promise.all(u.map(p=>Promise.resolve(p).then(f=>({status:"fulfilled",value:f}),f=>({status:"rejected",reason:f}))))};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(u=>{if(u=Wn(u),u in Qt)return;Qt[u]=!0;const p=u.endsWith(".css"),f=p?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${f}`))return;const v=document.createElement("link");if(v.rel=p?"stylesheet":On,p||(v.as="script"),v.crossOrigin="",v.href=u,d&&v.setAttribute("nonce",d),document.head.appendChild(v),p)return new Promise((w,E)=>{v.addEventListener("load",w),v.addEventListener("error",()=>E(new Error(`Unable to preload CSS for ${u}`)))})}))}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 Ps={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},Xt=$e.createContext&&$e.createContext(Ps),Hn=["attr","size","title"];function qn(t,s){if(t==null)return{};var a,l,c=Un(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 Un(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 lt(){return lt=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},lt.apply(null,arguments)}function Yt(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 ot(t){for(var s=1;s<arguments.length;s++){var a=arguments[s]!=null?arguments[s]:{};s%2?Yt(Object(a),!0).forEach(function(l){zn(t,l,a[l])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):Yt(Object(a)).forEach(function(l){Object.defineProperty(t,l,Object.getOwnPropertyDescriptor(a,l))})}return t}function zn(t,s,a){return(s=Kn(s))in t?Object.defineProperty(t,s,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[s]=a,t}function Kn(t){var s=Vn(t,"string");return typeof s=="symbol"?s:s+""}function Vn(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 Rs(t){return t&&t.map((s,a)=>$e.createElement(s.tag,ot({key:a},s.attr),Rs(s.child)))}function z(t){return s=>$e.createElement(Gn,lt({attr:ot({},t.attr)},s),Rs(t.child))}function Gn(t){var s=a=>{var l=t.attr,c=t.size,i=t.title,n=qn(t,Hn),o=c||a.size||"1em",d;return a.className&&(d=a.className),t.className&&(d=(d?d+" ":"")+t.className),$e.createElement("svg",lt({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},a.attr,l,n,{className:d,style:ot(ot({color:t.color||a.color},a.style),t.style),height:o,width:o,xmlns:"http://www.w3.org/2000/svg"}),i&&$e.createElement("title",null,i),t.children)};return Xt!==void 0?$e.createElement(Xt.Consumer,null,a=>s(a)):s(Ps)}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:"8",y1:"11",x2:"14",y2:"11"},child:[]}]})(t)}function Qn(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 at(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 Is(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 Xn(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 Be(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 Zt(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 ct(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 Yn(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 dt(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 Zn(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 ut(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 ea(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 gt(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 ze(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 Br(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 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.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 ts(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 ta(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 sa(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 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:"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 na(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 aa(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 Ds(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 ia(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 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:"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 mt(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 ra(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 la(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 oa(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 ca(t){return z({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"path",attr:{d:"M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z"},child:[]},{tag:"polyline",attr:{points:"9 22 9 12 15 12 15 22"},child:[]}]})(t)}function da(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 it(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 Re(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 ua(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:[]},{tag:"line",attr:{x1:"12",y1:"11",x2:"12",y2:"17"},child:[]},{tag:"line",attr:{x1:"9",y1:"14",x2:"15",y2:"14"},child:[]}]})(t)}function $s(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 Bs(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 Ct(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 St(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 Tt(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 Fs(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 et(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 ma(t){return z({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"14 9 9 4 4 9"},child:[]},{tag:"path",attr:{d:"M20 20h-7a4 4 0 0 1-4-4V4"},child:[]}]})(t)}function pa(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 Rt(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 ha(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 ga(t){return z({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"17 11 12 6 7 11"},child:[]},{tag:"polyline",attr:{points:"17 18 12 13 7 18"},child:[]}]})(t)}function fa(t){return z({attr:{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"},child:[{tag:"polyline",attr:{points:"7 13 12 18 17 13"},child:[]},{tag:"polyline",attr:{points:"7 6 12 11 17 6"},child:[]}]})(t)}function ft(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 Je(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 Ie(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 Ve(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 xa(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 ss(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 va(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 _s(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 As(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 Os(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 ya(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 qe({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 u=f=>{d.current&&!d.current.contains(f.target)&&a(!1)},p=f=>{f.key==="Escape"&&a(!1)};return document.addEventListener("mousedown",u),document.addEventListener("keydown",p),()=>{document.removeEventListener("mousedown",u),document.removeEventListener("keydown",p)}},[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(Ie,{className:`dd-caret ${s?"up":""}`})]}),s&&e.jsx("div",{className:`dd-menu ${o??""}`,children:l})]})}function Me({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 Ws="pi-web-ui:lang",ja={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:"可用模型",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:"还没有可复制的助手回复",mermaidRendering:"正在渲染图表…",mermaidRenderFailed:"图表渲染失败,已显示原始代码",recentProjects:"最近项目",runningConversations:"运行的对话",historySessions:"历史对话",openHistory:"历史对话",openFiles:"文件列表",streaming:"进行中…",noHistory:"还没有历史对话",current:"当前",messageCount:"{n} 条消息",tuiTip:"pi 终端(TUI)中的对话",deleteProject:"从最近项目移出",deleteProjectConfirm:"确认移出",deleteSession:"删除该对话记录(不可恢复)",deleteSessionConfirm:"确认删除",confirm:"确认",expandCode:"展开完整内容",collapseCode:"收起",zoomCode:"放大查看",closeZoom:"关闭",renameSession:"重命名该对话",renameSessionPlaceholder:"对话名称(留空则显示首条提问)",openFolder:"打开文件夹…",openFolderPlaceholder:"或直接粘贴绝对路径",openThisFolder:"打开当前文件夹",openTypedPath:"打开输入的路径",parentFolder:"上一级",home:"主目录",noSubfolders:"这里没有子文件夹",listTruncated:"目录过多,列表已截断",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:"正在等待模型响应…",sending:"发送中",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}",leakedThinking:"异常内容(疑似泄露的思考文本)",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 服务器…"},ba={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",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",mermaidRendering:"Rendering diagram…",mermaidRenderFailed:"Diagram failed to render — showing raw source",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",confirm:"Confirm",expandCode:"Expand full content",collapseCode:"Collapse",zoomCode:"Open in a larger view",closeZoom:"Close",renameSession:"Rename this chat",renameSessionPlaceholder:"Chat name (empty falls back to first message)",openFolder:"Open folder…",openFolderPlaceholder:"Or paste an absolute path",openThisFolder:"Open this folder",openTypedPath:"Open typed path",parentFolder:"Parent folder",home:"Home",noSubfolders:"No subfolders here",listTruncated:"Too many folders — list truncated",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…",sending:"Sending",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}",leakedThinking:"Unexpected content (likely leaked reasoning text)",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…"},Hs=r.createContext(null);function ka(){try{const t=localStorage.getItem(Ws);if(t==="zh"||t==="en")return t}catch{}return"zh"}function Na({children:t}){const[s,a]=r.useState(ka),l=r.useCallback(n=>{a(n);try{localStorage.setItem(Ws,n)}catch{}},[]),c=r.useCallback((n,o)=>{let d=ba[n];if(s==="zh"&&(d=ja[n]),o)for(const[u,p]of Object.entries(o))d=d.replaceAll(`{${u}}`,String(p));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(Hs.Provider,{value:i,children:t})}function It(){const t=r.useContext(Hs);if(!t)throw new Error("useI18n must be used within LanguageProvider");return t}function me(){return It().t}const wa=["off","minimal","low","medium","high","xhigh","max"],qs=r.memo(function({state:s,models:a,modelsLoading:l,send:c,onManageModels:i,compact:n=!1}){const o=me(),d=s==null?void 0:s.model,u=d?`${d.provider}/${d.id}`:null,[p,f]=r.useState(!1),[v,w]=r.useState(!1),[E,I]=r.useState("");r.useEffect(()=>{p||I("")},[p]);const N=r.useMemo(()=>{const C=E.trim().toLowerCase();return C?a.filter(x=>x.name.toLowerCase().includes(C)||x.provider.toLowerCase().includes(C)||x.id.toLowerCase().includes(C)):a},[a,E]),[$,T]=r.useState(!1),R=s!=null&&s.availableThinkingLevels&&s.availableThinkingLevels.length>0?new Set(s.availableThinkingLevels):null,B=wa.map(C=>({value:C,label:o(`thinking.${C}`),supported:R?R.has(C):!0})),_=C=>{var x;return((x=B.find(j=>j.value===C))==null?void 0:x.label)??C};return r.useEffect(()=>{p&&a.length===0&&!$&&!l&&(T(!0),c({type:"list_models"}))},[p,a.length,$,l,c]),r.useEffect(()=>{a.length>0&&T(!1)},[a.length]),e.jsxs(e.Fragment,{children:[e.jsxs(qe,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(et,{}),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:p,onOpenChange:f,menuClassName:"dd-menu-model",children:[e.jsx("div",{className:"dd-header",children:o("availableModels")}),e.jsxs("div",{className:"dd-search-row",children:[e.jsx(ut,{}),e.jsx("input",{className:"dd-search",type:"text",placeholder:o("searchModels"),value:E,onChange:C=>I(C.target.value)})]}),e.jsxs("div",{className:"dd-model-scroll",children:[($||l)&&e.jsx("div",{className:"dd-loading",children:o("loading")}),a.length===0&&!$&&!l&&e.jsx("div",{className:"dd-loading",children:o("noModels")}),N.length===0&&a.length>0&&e.jsx("div",{className:"dd-loading",children:o("noModelMatches")}),N.map(C=>e.jsx(Me,{active:u===C.id,onClick:()=>{u!==C.id&&c({type:"set_model",modelId:C.id}),f(!1)},children:e.jsxs("span",{className:"dd-model-cell",children:[e.jsx("span",{className:"dd-model-name",children:C.name}),e.jsxs("span",{className:"dd-model-meta",children:[e.jsx("span",{className:"dd-model-provider",children:C.provider}),(C.reasoning||C.vision)&&e.jsxs("span",{className:"dd-model-badges",children:[C.reasoning&&e.jsx("span",{className:"dd-model-badge",children:o("reasoning")}),C.vision&&e.jsx("span",{className:"dd-model-badge",children:o("vision")})]})]})]})},C.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:()=>{f(!1),i()},children:o("manageModels")})]})]}),e.jsxs(qe,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(at,{}),e.jsx("span",{className:"chip-sub",children:o("thinkingChip",{level:s?_(s.thinkingLevel):"—"})})]}),open:v,onOpenChange:w,children:[e.jsx("div",{className:"dd-header",children:o("thinkingLevel")}),B.map(C=>e.jsx(Me,{active:(s==null?void 0:s.thinkingLevel)===C.value,disabled:!C.supported,title:C.supported?void 0:o("thinkingUnsupported"),onClick:()=>{(s==null?void 0:s.thinkingLevel)!==C.value&&c({type:"set_thinking",level:C.value}),w(!1)},children:C.label},C.value))]})]})}),Ca=[{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 ns({settings:t,onChange:s,onPreview:a}){const l=me(),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(Is,{className:"sound-icon"}),e.jsx("span",{children:l("enableSound")})]}),e.jsx("input",{type:"checkbox",checked:t.enabled,onChange:i=>c({enabled:i.target.checked})})]}),Ca.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 Sa({chat:t,send:s,terminal:a,view:l,plugins:c,onViewChange:i,onOpenPanel:n,onManageModels:o,onOpenSettings:d,onOpenBgTasks:u,onOpenGlobalSearch:p,sound:f,onSoundChange:v,onSoundPreview:w}){const{locale:E,setLocale:I,t:N}=It(),[$,T]=r.useState(!1),[R,B]=r.useState(!1),[_,C]=r.useState(!1),x=[{value:"zh",label:N("langZh")},{value:"en",label:N("langEn")}],j=t.ready?N("connected"):t.status==="closed"?N("reconnecting"):N("connecting"),h=t.ready?"ok":"busy";return e.jsxs("header",{className:"topbar",children:[e.jsxs("div",{className:"brand",children:[e.jsx("button",{type:"button",className:"panel-toggle",title:N("openHistory"),onClick:()=>n("left"),children:e.jsx(na,{})}),e.jsx("span",{className:"brand-logo",children:"π"}),e.jsx("span",{className:"brand-name",children:"pi-web-ui"}),e.jsx("span",{className:`conn-dot ${h}`,title:j}),e.jsx("span",{className:"conn-label",children:j})]}),e.jsxs("div",{className:"topbar-actions",children:[e.jsxs("div",{className:"view-switch",role:"tablist","aria-label":N("viewSwitch"),children:[e.jsxs("button",{type:"button",role:"tab","aria-selected":l==="chat",className:l==="chat"?"active":"",onClick:()=>i("chat"),children:[e.jsx(Ke,{}),e.jsx("span",{children:N("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:N("terminal")})]}),e.jsxs("button",{type:"button",role:"tab","aria-selected":l==="git",className:l==="git"?"active":"",onClick:()=>i("git"),children:[e.jsx(it,{}),e.jsx("span",{children:N("scmTab")})]}),c.map(S=>{const Y=S.error?`${S.name}: ${S.error}`:S.description?`${S.name} — ${S.description}`:S.name;return e.jsxs("button",{type:"button",role:"tab","aria-selected":l===`plugin:${S.id}`,className:`plugin-tab${l===`plugin:${S.id}`?" active":""}${S.error?" broken":""}`,title:Y,onClick:()=>i(`plugin:${S.id}`),children:[S.icon?e.jsx("span",{"aria-hidden":!0,children:S.icon}):null,e.jsx("span",{children:S.name})]},S.id)})]}),e.jsxs("div",{className:"topbar-desktop",children:[e.jsxs("button",{type:"button",className:"chip",title:N("searchGlobalTip"),onClick:p,children:[e.jsx(ut,{}),e.jsx("span",{className:"chip-sub",children:N("searchGlobal")})]}),e.jsxs("button",{type:"button",className:"chip bg-task-chip","data-tip":N("bgTasksTip"),onClick:u,children:[e.jsx(mt,{}),e.jsx("span",{className:"chip-sub",children:N("bgTasks")}),t.bgServers.length>0&&e.jsx("span",{className:"bg-task-badge",children:t.bgServers.length})]}),e.jsx(qs,{state:t.state?{model:t.state.model,thinkingLevel:t.state.thinkingLevel,availableThinkingLevels:t.state.availableThinkingLevels}:null,models:t.models,modelsLoading:t.modelsLoading,send:s,onManageModels:o}),e.jsxs("button",{type:"button",className:"chip",title:N("settingsTitle"),onClick:d,children:[e.jsx(dt,{}),e.jsx("span",{className:"chip-sub",children:N("settings")})]}),e.jsx(qe,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(Is,{}),e.jsx("span",{className:"chip-sub",children:N("sound")})]}),open:$,onOpenChange:T,children:e.jsx(ns,{settings:f,onChange:v,onPreview:w})}),e.jsxs(qe,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(da,{}),e.jsx("span",{className:"chip-sub",children:E==="zh"?N("langZh"):"EN"})]}),open:R,onOpenChange:B,children:[e.jsx("div",{className:"dd-header",children:N("language")}),x.map(S=>e.jsx(Me,{active:E===S.value,onClick:()=>{I(S.value),B(!1)},children:S.label},S.value))]})]}),e.jsxs("button",{type:"button",className:"chip newchat","data-tip":N("newChatTip"),onClick:()=>s({type:"new_chat"}),children:[e.jsx(ze,{}),e.jsx("span",{children:N("newChat")})]}),e.jsx("div",{className:"topbar-more",children:e.jsxs(qe,{trigger:e.jsxs(e.Fragment,{children:[e.jsx(ta,{}),e.jsx("span",{className:"chip-sub",children:N("more")})]}),open:_,onOpenChange:C,children:[e.jsx("div",{className:"dd-header",children:N("sound")}),e.jsx("div",{className:"dd-header",children:N("settings")}),e.jsxs(Me,{onClick:()=>{C(!1),d()},children:[e.jsx(dt,{})," ",N("settingsTitle")]}),e.jsxs(Me,{onClick:()=>{C(!1),p()},children:[e.jsx(ut,{})," ",N("searchGlobal")]}),e.jsxs(Me,{onClick:()=>{C(!1),u()},children:[e.jsx(mt,{})," ",N("bgTasks"),t.bgServers.length>0&&e.jsx("em",{className:"bg-task-badge",children:t.bgServers.length})]}),e.jsx(ns,{settings:f,onChange:v,onPreview:w}),e.jsx("div",{className:"dd-header",children:N("language")}),x.map(S=>e.jsx(Me,{active:E===S.value,onClick:()=>I(S.value),children:S.label},S.value))]})}),e.jsx("button",{type:"button",className:"panel-toggle",title:N("openFiles"),onClick:()=>n("right"),children:e.jsx(Re,{})})]})]})}function Ta({dirBrowse:t,onBrowse:s,onPick:a,onClose:l}){const c=me(),[i,n]=r.useState("");r.useEffect(()=>{s(void 0)},[]),r.useEffect(()=>{const u=p=>{p.key==="Escape"&&l()};return window.addEventListener("keydown",u),()=>window.removeEventListener("keydown",u)},[l]);const o=(t==null?void 0:t.path)??"",d=u=>o.endsWith("/")?`${o}${u}`:`${o}/${u}`;return e.jsx("div",{className:"modal-backdrop",onClick:l,children:e.jsxs("div",{className:"fpk-modal",role:"dialog","aria-modal":"true",onClick:u=>u.stopPropagation(),children:[e.jsxs("div",{className:"fpk-modal-head",children:[e.jsx(Re,{className:"modal-head-icon"}),e.jsx("h2",{children:c("openFolder")}),e.jsx("span",{className:"toolcall-spacer"}),e.jsx("button",{type:"button",className:"toolcall-zoom-close",title:c("cancel"),onClick:l,children:e.jsx(we,{})})]}),e.jsxs("div",{className:"fpk-modal-bar",children:[e.jsx("button",{type:"button",className:"fpk-nav-btn",title:c("home"),onClick:()=>s(void 0),children:e.jsx(ca,{})}),e.jsx("button",{type:"button",className:"fpk-nav-btn",title:c("parentFolder"),disabled:!(t!=null&&t.parent),onClick:()=>(t==null?void 0:t.parent)&&s(t.parent),children:e.jsx(ma,{})}),e.jsx("code",{className:"fpk-path",title:o,children:o||"…"})]}),e.jsxs("div",{className:"fpk-list",children:[t&&t.dirs.length===0&&e.jsx("div",{className:"panel-empty",children:c("noSubfolders")}),t==null?void 0:t.dirs.map(u=>e.jsxs("button",{type:"button",className:"fpk-item",onClick:()=>s(d(u)),children:[e.jsx(Re,{className:"fpk-item-icon"}),e.jsx("span",{className:"fpk-item-name",children:u}),e.jsx(Je,{className:"fpk-item-go"})]},u)),(t==null?void 0:t.truncated)&&e.jsx("div",{className:"panel-empty",children:c("listTruncated")})]}),e.jsxs("form",{className:"fpk-modal-foot",onSubmit:u=>{u.preventDefault();const p=i.trim()||o;p&&a(p)},children:[e.jsx("input",{className:"lp-inline-input",placeholder:c("openFolderPlaceholder"),value:i,onChange:u=>n(u.target.value)}),e.jsxs("button",{type:"submit",className:"fpk-open-btn",disabled:!o&&!i.trim(),children:[e.jsx(Ve,{}),e.jsx("span",{children:i.trim()?c("openTypedPath"):c("openThisFolder")})]})]})]})})}function as(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()}`}const Ea=r.memo(function({ready:s,status:a,cwd:l,sessionFile:c,conversations:i,sessions:n,projects:o,dirBrowse:d,activeConversationId:u,send:p,active:f}){const v=me(),w=c,E=l,[I,N]=r.useState(null),[$,T]=r.useState(null),[R,B]=r.useState(""),[_,C]=r.useState(!1),[x,j]=r.useState(null);r.useEffect(()=>{x&&l===x&&j(null)},[l,x]),r.useEffect(()=>{if(!x)return;const M=setTimeout(()=>j(null),15e3);return()=>clearTimeout(M)},[x]),r.useEffect(()=>{!f||!s||a!=="open"||l&&(p({type:"list_sessions"}),p({type:"list_projects"}))},[f,s,a,l,p]);const h=M=>{const Q=M.name||M.firstMessage.trim();return Q.length>0?Q:v("emptyChat")},S=M=>M.split(/[\\/]/).pop()||M,Y=(M,Q,O,L)=>{const G=I===M;return e.jsx("button",{type:"button",className:`lp-del ${G?"confirm":""}`,title:G?O:Q,onClick:W=>{W.stopPropagation(),G?(N(null),L()):N(M)},children:G?e.jsx(Ve,{}):e.jsx(Be,{})})};return e.jsxs("aside",{className:"panel panel-left",children:[e.jsxs("div",{className:"panel-projects",children:[e.jsx("div",{className:"panel-section-title",children:v("recentProjects")}),e.jsxs("button",{type:"button",className:"lp-add-project",onClick:()=>C(!0),children:[e.jsx(ua,{className:"project-icon"}),e.jsx("span",{children:v("openFolder")})]}),e.jsx("div",{className:"projects-scroll",children:o.map(M=>{const Q=E===M.path,O=!Q&&x===M.path;return e.jsxs("div",{className:"lp-row",onMouseLeave:()=>N(L=>L===`proj:${M.path}`?null:L),children:[e.jsxs("button",{type:"button",className:`project-item ${Q?"active":""} ${O?"pending":""}`,title:M.path,onClick:()=>{Q||(j(M.path),p({type:"set_cwd",path:M.path}))},children:[e.jsx(Re,{className:"project-icon"}),e.jsxs("span",{className:"project-info",children:[e.jsx("span",{className:"project-name",children:S(M.path)}),e.jsx("span",{className:"project-path",children:M.path})]}),O?e.jsx("span",{className:"thinking-spinner project-spinner","aria-hidden":"true"}):e.jsx("span",{className:"project-time",children:as(M.lastUsed)})]}),Y(`proj:${M.path}`,v("deleteProject"),v("deleteProjectConfirm"),()=>p({type:"remove_project",path:M.path}))]},M.path)})})]}),i.length>0&&e.jsxs("div",{className:"panel-convs",children:[e.jsx("div",{className:"panel-section-title",children:v("runningConversations")}),i.map(M=>{const Q=u===M.id;return e.jsxs("button",{type:"button",className:`session-item ${Q?"active":""}`,title:M.title,onClick:()=>{Q||p({type:"switch_conversation",id:M.id})},children:[e.jsx(Ke,{className:"session-icon"}),e.jsxs("span",{className:"session-info",children:[e.jsx("span",{className:"session-title",children:M.title}),e.jsx("span",{className:"session-sub",children:Q?v("current"):v("messageCount",{n:M.messageCount})})]}),M.isStreaming&&e.jsx("span",{className:"conv-streaming",title:v("streaming")})]},M.id)}),e.jsx("div",{className:"panel-section-divider"})]}),e.jsxs("div",{className:"panel-sessions",children:[e.jsx("div",{className:"panel-section-title",children:v("historySessions")}),e.jsxs("div",{className:"sessions-scroll",children:[n.length===0&&e.jsx("div",{className:"panel-empty",children:v("noHistory")}),n.map(M=>{const Q=w===M.path;return $===M.path?e.jsxs("form",{className:"lp-inline-form",onSubmit:O=>{O.preventDefault(),p({type:"rename_session",path:M.path,name:R.trim()}),T(null)},children:[e.jsx("input",{autoFocus:!0,className:"lp-inline-input",placeholder:v("renameSessionPlaceholder"),value:R,onChange:O=>B(O.target.value),onKeyDown:O=>{O.key==="Escape"&&T(null)}}),e.jsx("button",{type:"submit",className:"lp-inline-ok",title:v("confirm"),children:e.jsx(Ve,{})}),e.jsx("button",{type:"button",className:"lp-inline-cancel",title:v("cancel"),onClick:()=>T(null),children:e.jsx(we,{})})]},M.path):e.jsxs("div",{className:"lp-row",onMouseLeave:()=>N(O=>O===`sess:${M.path}`?null:O),children:[e.jsxs("button",{type:"button",className:`session-item ${Q?"active":""}`,title:M.path,onClick:()=>{Q||p({type:"switch_session",path:M.path})},children:[e.jsx(Ke,{className:"session-icon"}),e.jsxs("span",{className:"session-info",children:[e.jsx("span",{className:"session-title",children:h(M)}),e.jsxs("span",{className:"session-sub",children:[Q?v("current"):v("messageCount",{n:M.messageCount}),M.source==="tui"&&e.jsx("span",{className:"session-src",title:v("tuiTip"),children:"TUI"})]})]}),e.jsx("span",{className:"session-time",children:as(M.modified)})]}),e.jsx("button",{type:"button",className:"lp-rename",title:v("renameSession"),onClick:O=>{O.stopPropagation(),B(M.name??""),T(M.path)},children:e.jsx(Tt,{})}),Y(`sess:${M.path}`,v("deleteSession"),v("deleteSessionConfirm"),()=>p({type:"delete_session",path:M.path}))]},M.path)})]})]}),_&&e.jsx(Ta,{dirBrowse:d,onBrowse:M=>p({type:"browse_dirs",path:M}),onPick:M=>{j(M),p({type:"set_cwd",path:M}),C(!1)},onClose:()=>C(!1)})]})});function Ge(){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)}`}const Us="pi-web-ui:token";function Ma(){try{const t=new URL(window.location.href),s=t.searchParams.get("token");s&&(localStorage.setItem(Us,s.trim()),t.searchParams.delete("token"),window.history.replaceState(null,"",t.toString()))}catch{}}function La(){try{return localStorage.getItem(Us)??""}catch{return""}}function Dt(t){const s=La();return s?`${t}${t.includes("?")?"&":"?"}token=${encodeURIComponent(s)}`:t}function Pa(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:[]},u=[...d.content],p=a.type==="thinking_delta"?"thinking":"text",f=a.contentIndex??u.length-1;return f>=0&&f<u.length&&u[f].type===p?u[f]=p==="thinking"?{type:"thinking",thinking:(u[f].thinking??"")+n}:{type:"text",text:(u[f].text??"")+n}:u.push(p==="thinking"?{type:"thinking",thinking:n}:{type:"text",text:n}),{...t,stats:i,streamingMessage:{...d,id:s.messageId,content:u}}}const Et="pi-web-ui:plugin-data";function Ra(t,s){window.dispatchEvent(new CustomEvent(Et,{detail:{pluginId:t,payload:s}}))}function Ia(t){const s=a=>{const l=a.detail;t(l.pluginId,l.payload)};return window.addEventListener(Et,s),()=>window.removeEventListener(Et,s)}const He=new Map,Mt=new Set,Oe=new Set;let is=-1;function zs(){return[...He.values()]}function Da(){const t=zs();for(const s of Mt)s(t)}function $a(t){return Mt.add(t),t(zs()),()=>Mt.delete(t)}async function Ba(t,s){s!==is&&(is=s,He.clear(),Oe.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[...Oe])a.has(l)||Oe.delete(l);await Promise.all(t.filter(l=>l.hasClient&&!l.error&&!He.has(l.id)&&!Oe.has(l.id)).map(async l=>{try{const i=(await Pt(()=>import(`/plugins/${encodeURIComponent(l.id)}/client/entry.mjs?e=${s}`),[])).default;i&&typeof i.mount=="function"?He.set(l.id,{info:l,module:i}):(Oe.add(l.id),console.error(`[plugin:${l.id}] entry.mjs 缺少 default.mount`))}catch(c){Oe.add(l.id),console.error(`[plugin:${l.id}] 客户端加载失败:`,c)}})),Da()}function Fa(t,s){return{pluginId:t,send:a=>s({type:"plugin_message",pluginId:t,payload:a}),onData:a=>Ia((l,c)=>{l===t&&a(c)})}}const _a=10,vt=2e5,Aa=2e5,Oa={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 Wa(){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 p of o)try{p.write(i)}catch{}return}const d=s.get(n)??"",u=d.length+i.length>Aa?i:d+i;s.set(n,u)},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 u=t.get(n);u&&(u.delete(i),u.size===0&&t.delete(n)),s.delete(n)}},clear(){t.clear(),s.clear()}}}function rs(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 ls(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 Ha(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!==_a};case"snapshot":return{...t,ready:!0,state:s.state,activeConversationId:s.state.conversationId,liveOutputs:rs(t.liveOutputs,s.state),toolStatuses:ls(t.toolStatuses,s.state),pendingEcho:null};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:rs(t.liveOutputs,d),toolStatuses:ls(t.toolStatuses,d),pendingEcho:o.appended.length>0?null:t.pendingEcho}}case"tool_delta":{const n=t.liveOutputs.get(s.toolCallId),o=((n==null?void 0:n.text)??"")+s.delta,d=o.length>vt?`…[前 ${o.length-vt} 字符已省略]…
|
|
3
|
-
`+o.slice(o.length-vt):o,u=new Map(t.liveOutputs);return u.set(s.toolCallId,{toolName:s.toolName,text:d}),{...t,liveOutputs:u}}case"message_delta":{const n=t.state;return!n||n.conversationId!==s.msg.conversationId?t:{...t,state:Pa(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"set_pending_echo":return{...t,pendingEcho:s.echo};case"clear_pending_echo":return{...t,pendingEcho:null};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"dir_browse":return{...t,dirBrowse:s.dirBrowse};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 os="pi-web-client-id";let yt=null;function $t(){if(yt)return yt;let t=null;try{t=sessionStorage.getItem(os),t||(t=Ge(),sessionStorage.setItem(os,t))}catch{t=t??Ge()}return yt=t,t}function qa(){const t=location.protocol==="https:"?"wss:":"ws:";return Dt(`${t}//${location.host}/ws`)}function Ua(){const[t,s]=r.useReducer(Ha,{status:"connecting",ready:!1,state:null,liveOutputs:new Map,toolStatuses:new Map,notices:[],sessions:[],conversations:[],activeConversationId:"",projects:[],dirBrowse:null,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:Oa,bgServers:[],settings:null,fetchModelsResult:null,refreshProviderResult:null,cloneProviderResult:null,scmData:null,fileSearch:null,scmDirty:0,plugins:[],pluginsEpoch:0,protocolMismatch:!1,pendingEcho:null}),a=r.useRef(null),l=r.useRef(Wa()),c=r.useRef(0),i=r.useRef(null),n=r.useRef(!0),o=r.useRef(0),d=r.useRef(0),u=r.useRef(new Map),p=r.useRef(null),f=()=>{p.current||(p.current=setTimeout(()=>{p.current=null;const x=a.current;x&&x.readyState===WebSocket.OPEN&&x.send(JSON.stringify({type:"get_state"}))},300))},v=(x,j)=>{var Y;const h=u.current,S=h.get(x);if(S!==void 0&&j!==S+1){const M=C.current.chat,Q=M.activeConversationId||((Y=M.state)==null?void 0:Y.conversationId);x===Q&&f()}h.set(x,j)},w=r.useCallback((x,j)=>{const h=++d.current;s({type:"notice",notice:{id:h,level:x,text:j}})},[]),E=r.useCallback(x=>{const j=a.current;return j&&j.readyState===WebSocket.OPEN?(j.send(JSON.stringify(x)),!0):!1},[]),I=r.useCallback(()=>{if(!n.current)return;s({type:"status",status:"connecting"});const x=new WebSocket(qa());a.current=x,x.onopen=()=>{a.current===x&&(s({type:"status",status:"open"}),c.current=0,o.current=Date.now(),x.send(JSON.stringify({type:"hello",clientId:$t()})))},x.onmessage=j=>{if(a.current!==x)return;o.current=Date.now();let h;try{h=JSON.parse(j.data)}catch{return}switch(h.type){case"ready":s({type:"ready",serverVersion:h.serverVersion,protocolVersion:h.protocolVersion}),x.send(JSON.stringify({type:"get_state"})),x.send(JSON.stringify({type:"list_files"})),x.send(JSON.stringify({type:"list_models"})),x.send(JSON.stringify({type:"list_commands"})),x.send(JSON.stringify({type:"get_commands"})),x.send(JSON.stringify({type:"check_update"}));break;case"snapshot":u.current=new Map,s({type:"snapshot",state:h.state});break;case"snapshot_delta":{const S=C.current.chat.state;(!S||S.conversationId!==h.conversationId||S.rev!==h.baseRev)&&f(),s({type:"snapshot_delta",msg:h});break}case"tool_delta":v(h.conversationId,h.seq),s({type:"tool_delta",toolCallId:h.toolCallId,toolName:h.toolName,delta:h.delta});break;case"tool_status":s({type:"tool_status",status:h});break;case"message_delta":{v(h.conversationId,h.seq),s({type:"message_delta",msg:h});break}case"notice":{const S=++d.current;s({type:"notice",notice:{id:S,level:h.level,text:h.text}});break}case"sessions":s({type:"sessions",sessions:h.sessions});break;case"conversations":s({type:"conversations",conversations:h.conversations,activeId:h.activeId});break;case"projects":s({type:"projects",projects:h.projects});break;case"dir_browse":s({type:"dir_browse",dirBrowse:{path:h.path,parent:h.parent,dirs:h.dirs,truncated:h.truncated}});break;case"files":s({type:"files",files:h});break;case"file_changed":s({type:"file_changed",path:h.path});break;case"file_content":s({type:"file_content",content:h});break;case"models":s({type:"models",models:h.models,loading:!1});break;case"models_config":s({type:"models_config",providers:h.providers});break;case"providers_status":s({type:"providers_status",providers:h.providers});break;case"fetch_models_result":s({type:"fetch_models_result",result:{reqId:h.reqId,ok:h.ok,models:h.models,error:h.error}});break;case"refresh_provider_result":s({type:"refresh_provider_result",result:{reqId:h.reqId,ok:h.ok,added:h.added,total:h.total,error:h.error}});break;case"clone_provider_result":s({type:"clone_provider_result",result:{reqId:h.reqId,ok:h.ok,config:h.config,error:h.error}});break;case"scm_data":s({type:"scm_data",data:h});break;case"search_files_result":s({type:"file_search_result",result:{reqId:h.reqId,ok:h.ok,results:h.results,truncated:h.truncated}});break;case"scm_changed":s({type:"scm_changed"});break;case"install_result":s({type:"install_result",result:h});break;case"path_completions":s({type:"path_completions",completions:h.completions});break;case"update_status":s({type:"update_status",status:h});break;case"widgets":s({type:"widgets",widgets:h.widgets});break;case"statuses":s({type:"statuses",statuses:h.statuses});break;case"dialog":s({type:"dialog",dialog:{id:h.id,kind:h.kind,title:h.title,args:h.args}});break;case"dialog_closed":s({type:"dialog",dialog:null});break;case"terminal_output":l.current.write(h.conversationId??C.current.chat.activeConversationId,h.terminalId,h.data);break;case"terminal_exit":s({type:"terminal_exit",conversationId:h.conversationId,terminalId:h.terminalId,exitCode:h.exitCode});break;case"terminal_list":s({type:"terminal_list",conversationId:h.conversationId,terminals:h.terminals});break;case"commands":s({type:"commands",commands:h.commands,path:h.path});break;case"slash_commands":s({type:"slash_commands",commands:h.commands});break;case"goal_status":s({type:"goal_status",status:h.status});break;case"settings_state":s({type:"settings",settings:h.settings});break;case"bg_servers":s({type:"bg_servers",servers:h.servers});break;case"plugins":s({type:"plugins",plugins:h.plugins,epoch:h.epoch});break;case"plugin_data":Ra(h.pluginId,h.payload);break}},x.onclose=()=>{if(a.current===x&&(a.current=null),l.current.clear(),!n.current||a.current&&a.current!==x)return;s({type:"status",status:"closed"});const j=Math.min(1e3*2**c.current,1e4);c.current+=1,i.current=setTimeout(()=>{i.current=null,I()},j)},x.onerror=()=>{}},[]);r.useEffect(()=>{n.current=!0,I();const x=setInterval(()=>{if(!n.current)return;const j=a.current;j&&j.readyState===WebSocket.OPEN&&Date.now()-o.current>3e4&&j.close()},5e3);return()=>{var j;n.current=!1,clearInterval(x),i.current&&(clearTimeout(i.current),i.current=null),(j=a.current)==null||j.close(),a.current=null}},[I]);const N=r.useCallback(x=>s({type:"dismiss_notice",id:x}),[]),$=r.useCallback((x,j)=>s({type:"set_pending_echo",echo:{conversationId:x,text:j,ts:Date.now()}}),[]),T=r.useCallback(x=>s({type:"terminal_add",meta:x}),[]),R=r.useCallback(x=>s({type:"terminal_remove",id:x}),[]),B=r.useCallback(x=>s({type:"terminal_restart",terminalId:x}),[]),_=r.useCallback((x,j,h)=>l.current.register(x,j,h),[]),C=r.useRef({chat:t,send:E,pushNotice:w,dismissNotice:N,setPendingEcho:$,terminal:{create:T,close:R,register:_,restart:B}});return C.current={chat:t,send:E,pushNotice:w,dismissNotice:N,setPendingEcho:$,terminal:{create:T,close:R,register:_,restart:B}},C.current}const za=200*1024*1024,Ka=/windows/i.test(navigator.userAgent),Va=/[<>:"/\\|?*\u0000-\u001f]/g,Ga=/[. ]+$/,Ja=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])(\..*)?$/i;function Qa(t){const s=t.replace(Va,"_").replace(Ga,"");return s?Ja.test(s)?`_${s}`:s:"_"}function cs(t,s=!0){const a=new URLSearchParams({clientId:$t(),path:t,...s?{download:"1"}:{}});return Dt(`/api/file?${a}`)}async function Xa(t,s){const a=Ka?Qa(s):s;try{const l=await fetch(cs(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")>za)return window.location.assign(cs(t)),{ok:!0};const i=await l.blob();return window.showSaveFilePicker&&window.isSecureContext?Ya(i,a):Lt(i,a)}catch(l){return{ok:!1,cancelled:!1,error:l instanceof Error?l.message:String(l)}}}async function Ya(t,s){let a;const l=window.showSaveFilePicker;if(!l)return Lt(t,s);try{a=await l({suggestedName:s})}catch(c){return c instanceof DOMException&&c.name==="AbortError"?{ok:!1,cancelled:!0}:Lt(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 Lt(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 Za=r.memo(function({files:s,fileChanged:a,widgets:l,cwd:c,send:i,onAttach:n,onPreview:o,onNotice:d}){const u=me(),[p,f]=r.useState(""),[v,w]=r.useState(null),[E,I]=r.useState(!1),N=1e4,$=r.useRef(0),T=r.useRef(void 0),R=r.useCallback((x,j)=>{const h=++$.current;f(x),j!=null&&j.silent||I(!0),i({type:"list_files",path:x===""?void 0:x})||$.current===h&&I(!1)},[i]);r.useEffect(()=>{s&&s.path===p&&I(!1)},[s,p]),r.useEffect(()=>{if(c!==T.current){T.current=c,R("",{silent:!0});return}const x=setInterval(()=>{document.visibilityState!=="hidden"&&R(p,{silent:!0})},N);return()=>clearInterval(x)},[c,p,R]),r.useEffect(()=>{a&&a.path===p&&R(p,{silent:!0})},[a,p,R]);const B=x=>R(x),_=()=>{(s==null?void 0:s.parent)!==null&&(s==null?void 0:s.parent)!==void 0&&R(s.parent)},C=p.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 ${p===""?"active":""}`,onClick:()=>R(""),children:u("rootDir")}),C.map((x,j)=>{const h=C.slice(0,j+1).join("/");return e.jsxs("span",{className:"crumb-seg",children:[e.jsx(Je,{}),e.jsx("button",{type:"button",className:`crumb ${h===p?"active":""}`,onClick:()=>R(h),children:x})]},h)})]}),e.jsxs("div",{className:"panel-body",children:[E&&e.jsx("div",{className:"panel-empty",children:u("loading")}),!E&&s&&s.path===p&&e.jsxs(e.Fragment,{children:[s.path!==""&&e.jsxs("button",{type:"button",className:"file-item dir",onClick:_,children:[e.jsx(Re,{className:"file-icon"}),e.jsx("span",{className:"file-name",children:".."})]}),s.entries.map(x=>x.type==="dir"?e.jsxs("div",{className:"file-item dir",children:[e.jsxs("button",{type:"button",className:"file-dir-main",onClick:()=>B(x.path),children:[e.jsx(Re,{className:"file-icon"}),e.jsx("span",{className:"file-name",children:x.name})]}),e.jsx("button",{type:"button",className:"file-attach ref","data-tip":u("linkFolderTip"),onClick:()=>n(x.path,x.name,"reference",!0),children:e.jsx(wt,{})})]},x.path):e.jsxs("div",{className:"file-item file",children:[e.jsxs("button",{type:"button",className:"file-name",title:`${x.path} — ${u("previewFile")}`,onClick:()=>o(x.path,x.name),children:[e.jsx($s,{className:"file-icon"}),e.jsx("span",{className:"file-name-text",children:x.name})]}),e.jsx("button",{type:"button",className:"file-attach download","data-tip":u("downloadFile"),onClick:()=>{Xa(x.path,x.name).then(j=>{j.ok||j.cancelled||d("error",u("downloadFailed",{error:j.error}))})},children:e.jsx(Fs,{})}),e.jsx("button",{type:"button",className:"file-attach inline","data-tip":u("attachInlineTip"),onClick:()=>n(x.path,x.name,"inline"),children:e.jsx(ze,{})}),e.jsx("button",{type:"button",className:"file-attach ref","data-tip":u("referenceTip"),onClick:()=>n(x.path,x.name,"reference"),children:e.jsx(wt,{})})]},x.path)),s.truncated&&e.jsx("div",{className:"panel-empty files-truncated",children:u("filesTruncated")})]}),!E&&!s&&e.jsx("div",{className:"panel-empty",children:u("noFiles")})]}),l.filter(x=>x.lines.length>0).length>0&&e.jsx("div",{className:"panel-widgets",children:l.filter(x=>x.lines.length>0).map(x=>e.jsxs("div",{className:"widget",children:[e.jsxs("button",{type:"button",className:"widget-title widget-title-btn",title:u("widgetExpand"),onClick:()=>w(x.key),children:[e.jsx("span",{children:x.key}),e.jsx(Ds,{})]}),e.jsx("pre",{className:"widget-lines",children:x.lines.join(`
|
|
4
|
-
`)})]},x.key))}),v&&(()=>{const x=l.find(j=>j.key===v);return x?e.jsx("div",{className:"modal-backdrop",onClick:()=>w(null),children:e.jsxs("div",{className:"widget-expand",onClick:j=>j.stopPropagation(),children:[e.jsxs("div",{className:"widget-expand-head",children:[e.jsx("span",{className:"widget-expand-title",children:x.key}),e.jsx("button",{type:"button",className:"btn",title:u("close"),onClick:()=>w(null),children:e.jsx(we,{})})]}),e.jsx("pre",{className:"widget-expand-lines",children:x.lines.join(`
|
|
5
|
-
`)})]})}):null})()]})});var ds=Ls();function ei({text:t}){const s=me(),[a,l]=r.useState(!1);return e.jsxs("div",{className:`thinking leaked ${a?"open":""}`,children:[e.jsxs("button",{type:"button",className:"thinking-toggle",onClick:()=>l(!a),children:[a?e.jsx(Ie,{}):e.jsx(Je,{}),e.jsx(Os,{className:"thinking-icon"}),e.jsx("span",{className:"thinking-label",children:s("leakedThinking")})]}),a&&e.jsx("div",{className:"thinking-body",children:t})]})}const pt=r.memo(function({text:s}){const a=me(),[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(Ve,{}):e.jsx(Rt,{})}):null});let jt=null;function ti(){return jt||(jt=Pt(()=>import("./mermaid.core-BqE9WdEq.js").then(t=>t.cb),__vite__mapDeps([0,1])).then(t=>{const s=t.default;return s.initialize({startOnLoad:!1,securityLevel:"strict",theme:"base",themeVariables:{background:"#ffffff",primaryColor:"#f1edfe",primaryTextColor:"#1f2430",primaryBorderColor:"#8b5cf6",lineColor:"#6b7280",secondaryColor:"#eef2ff",tertiaryColor:"#f8fafc",textColor:"#1f2430",fontFamily:"var(--mono, monospace)"}}),s})),jt}let si=0;function ni({code:t}){const s=me(),a=r.useId().replace(/[^a-zA-Z0-9]/g,""),[l,c]=r.useState(null),[i,n]=r.useState(null),o=r.useRef(null);return r.useEffect(()=>{let d=!1;c(null),n(null);const u=`mermaid-${a}-${++si}`;return ti().then(p=>p.render(u,t)).then(({svg:p})=>{d||c(p)}).catch(p=>{var f;d||n(p instanceof Error?p.message:String(p)),(f=document.getElementById(u))==null||f.remove()}),()=>{d=!0}},[t,a]),i?e.jsxs("div",{className:"mermaid-block mermaid-block-error",children:[e.jsx("div",{className:"mermaid-error-note",children:s("mermaidRenderFailed")}),e.jsxs("div",{className:"codeblock",children:[e.jsx(pt,{text:t}),e.jsx("pre",{children:e.jsx("code",{children:t})})]})]}):l?e.jsxs("div",{className:"mermaid-block",children:[e.jsx(pt,{text:t}),e.jsx("div",{ref:o,className:"mermaid-svg",dangerouslySetInnerHTML:{__html:l}})]}):e.jsx("div",{className:"mermaid-block mermaid-block-loading",children:e.jsx("div",{className:"mermaid-loading-note",children:s("mermaidRendering")})})}const Ks=[dn],Vs=[[cn,{detect:!0,ignoreMissing:!0}]];function Gs({text:t}){return e.jsx(Ms,{remarkPlugins:Ks,rehypePlugins:Vs,components:{pre:Js},children:t})}const Fe=r.memo(function({text:s}){return e.jsx("div",{className:"md",children:e.jsx(Gs,{text:s})})});function Js({children:t,...s}){return ai(t)?e.jsx(ni,{code:ht(t)}):e.jsxs("div",{className:"codeblock",children:[e.jsx(pt,{text:ht(t)}),e.jsx("pre",{...s,children:t})]})}function ai(t){var l;const s=Array.isArray(t)?t[0]:t;if(!s||typeof s!="object"||!("props"in s))return!1;const a=(l=s.props)==null?void 0:l.className;return typeof a=="string"&&/(^|\s)language-mermaid(\s|$)/.test(a)}function ht(t){if(typeof t=="string")return t;if(Array.isArray(t))return t.map(ht).join("");if(t&&typeof t=="object"&&"props"in t){const s=t.props;return ht(s==null?void 0:s.children)}return""}const ii=/^\s{0,3}(`{3,}|~{3,})/,ri=/^\s{0,3}(?:[-*+]|\d{1,9}[.)])\s/;function bt(t){return t.trim()===""}function us(t){const s=ii.exec(t);return s?s[1]:null}function li(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=us(n);d&&d[0]===c[0]&&d.length>=c.length&&(c=null),l.push(n);continue}const o=us(n);if(o&&!bt(n)){c=o,l.push(n);continue}if(bt(n)){let d=i;for(;d<s.length&&bt(s[d]);)d++;if(!(d<s.length&&ri.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 oi=r.memo(function({text:s}){return e.jsx(Ms,{remarkPlugins:Ks,rehypePlugins:Vs,components:{pre:Js},children:s})}),ms=200;function ci({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>=ms){o();return}return i.current=setTimeout(o,ms-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(Gs,{text:a})}const di=r.memo(function({text:s}){const{frozen:a,active:l,inFence:c}=r.useMemo(()=>li(s),[s]);return e.jsxs("div",{className:"md",children:[a.map((i,n)=>e.jsx(oi,{text:i},n)),l.length>0&&e.jsx(ci,{text:l,inFence:c},a.length)]})});function ui({thinking:t,streaming:s,wrap:a=!0}){const l=me(),[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(Ie,{}):e.jsx(Je,{}),e.jsx(et,{className:"thinking-icon"}),e.jsx("span",{className:"thinking-label",children:s&&n?e.jsxs("span",{className:"thinking-live-label",children:[e.jsx("span",{className:"thinking-spinner","aria-hidden":"true"}),l("thinkingNow")]}):s?e.jsxs("span",{className:"thinking-live-label",children:[e.jsx("span",{className:"thinking-spinner","aria-hidden":"true"}),l("thinkingPreview",{preview:o})]}):n?l("thinking"):l("thinkingPreview",{preview:o})})]}),n&&e.jsx("div",{className:"thinking-body",children:t})]})}fe.registerLanguage("bash",un);fe.registerLanguage("c",mn);fe.registerLanguage("cpp",pn);fe.registerLanguage("csharp",hn);fe.registerLanguage("css",gn);fe.registerLanguage("diff",fn);fe.registerLanguage("go",xn);fe.registerLanguage("graphql",vn);fe.registerLanguage("ini",yn);fe.registerLanguage("java",jn);fe.registerLanguage("javascript",bn);fe.registerLanguage("json",kn);fe.registerLanguage("kotlin",Nn);fe.registerLanguage("less",wn);fe.registerLanguage("lua",Cn);fe.registerLanguage("makefile",Sn);fe.registerLanguage("php",Tn);fe.registerLanguage("python",En);fe.registerLanguage("r",Mn);fe.registerLanguage("ruby",Ln);fe.registerLanguage("rust",Pn);fe.registerLanguage("scss",Rn);fe.registerLanguage("sql",In);fe.registerLanguage("swift",Dn);fe.registerLanguage("typescript",$n);fe.registerLanguage("xml",Bn);fe.registerLanguage("yaml",Fn);function ps(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function mi(t,s){if(!s||!fe.getLanguage(s))return ps(t);try{return fe.highlight(t,{language:s,ignoreIllegals:!0}).value}catch{return ps(t)}}const pi={bash:"$",read:"📄",write:"✍️",edit:"✏️",grep:"🔍",find:"🧭",ls:"📂"};function hs(t){return pi[t]??"🛠"}function hi(t){if(t.name!=="read"||!t.argumentsText)return!1;try{const s=JSON.parse(t.argumentsText);return typeof s.path=="string"&&/\.(md|markdown)$/i.test(s.path)}catch{return!1}}const gi={json:"json",jsonc:"json",ts:"typescript",mts:"typescript",cts:"typescript",tsx:"typescript",js:"javascript",mjs:"javascript",cjs:"javascript",jsx:"javascript",py:"python",rb:"ruby",go:"go",rs:"rust",java:"java",kt:"kotlin",kts:"kotlin",swift:"swift",c:"c",h:"c",cpp:"cpp",cc:"cpp",hpp:"cpp",cs:"csharp",php:"php",sql:"sql",css:"css",scss:"scss",less:"less",html:"xml",htm:"xml",xml:"xml",svg:"xml",yml:"yaml",yaml:"yaml",sh:"bash",bash:"bash",zsh:"bash",toml:"ini",ini:"ini",graphql:"graphql",gql:"graphql",lua:"lua",r:"r",makefile:"makefile",diff:"diff",patch:"diff"};function Bt(t){var a,l;const s=(l=(a=t.split(/[\\/]/).pop())==null?void 0:a.split(".").pop())==null?void 0:l.toLowerCase();return s&&gi[s]||null}function fi(t){if(t.name!=="read"||!t.argumentsText)return null;try{const s=JSON.parse(t.argumentsText);return typeof s.path=="string"?Bt(s.path):null}catch{return null}}function xi(t){if(t.name!=="write"||!t.argumentsText)return null;try{const s=JSON.parse(t.argumentsText);return typeof s.content!="string"?null:{lang:typeof s.path=="string"?Bt(s.path):null,content:s.content}}catch{return null}}function vi(t){if(t.name!=="edit"||!t.argumentsText)return null;try{const s=JSON.parse(t.argumentsText);return typeof s.path=="string"?Bt(s.path):null}catch{return null}}function yi(t,s){if(t.name!=="edit"||!s.result||s.result.isError)return null;const a=s.result.details;return typeof(a==null?void 0:a.diff)=="string"?a.diff:null}const ji=/^([+\- ])(\s*\d+) (.*)$/;function bi(t){return t.split(`
|
|
10
|
-
`).map(s=>{const a=ji.exec(s);return a?{marker:a[1],lineNum:a[2],code:a[3]}:{marker:" ",lineNum:"",code:s}})}function ki({diff:t,lang:s}){const a=bi(t);return e.jsx("div",{className:"toolcall-diff",children:a.map((l,c)=>e.jsxs("div",{className:`toolcall-diff-line ${l.marker==="+"?"add":l.marker==="-"?"del":"ctx"}`,children:[e.jsxs("span",{className:"toolcall-diff-gutter",children:[l.marker,l.lineNum]}),e.jsx("code",{className:"toolcall-diff-code hljs",dangerouslySetInnerHTML:{__html:mi(l.code,s)||""}})]},c))})}function gs(t,s){var i;const a=((i=t.match(/`+/g))==null?void 0:i.map(n=>n.length))??[],l=a.length?Math.max(...a):0,c="`".repeat(Math.max(3,l+1));return`${c}${s}
|
|
11
|
-
${t.replace(/\n$/,"")}
|
|
12
|
-
${c}`}const Ni=r.memo(function({block:s,view:a,onKillBash:l,wrap:c=!0}){var W,ie,pe,K;const i=me(),[n,o]=r.useState(c),[d,u]=r.useState(!1),[p,f]=r.useState(!0),[v,w]=r.useState(!1),[E,I]=r.useState(!1);r.useEffect(()=>{if(!E)return;const b=U=>{U.key==="Escape"&&I(!1)};return window.addEventListener("keydown",b),()=>window.removeEventListener("keydown",b)},[E]);const N=!a.result&&a.streaming&&!a.status,$=s.name==="bash"&&N,T=a.result!==void 0,R=!a.result&&!!a.status,B=((W=a.result)==null?void 0:W.isError)??((ie=a.status)==null?void 0:ie.isError)??!1,_=hi(s),C=!_&&!B?fi(s):null,x=xi(s),j=yi(s,a),h=j?vi(s):null,S=a.result?a.result.content.map(b=>b.type==="text"?b.text:"").join(""):a.liveOutput??"",Y=B?"err":T?"ok":N||R?"run":"idle";let M=i(B?"error":T?"done":N?"running":R?"toolDoneWaitingModel":"toolQueued");const Q=R&&((pe=a.status)==null?void 0:pe.durationMs)!==void 0?Ci(a.status.durationMs):"";R&&Q&&(M=`${M} · ${Q}`);const O=R&&((K=a.status)==null?void 0:K.exitCode)!==void 0?`exit ${a.status.exitCode}`:"",L=()=>{s.argumentsText&&(navigator.clipboard.writeText(s.argumentsText),u(!0),setTimeout(()=>u(!1),1200))},G=e.jsxs(e.Fragment,{children:[s.argumentsText&&e.jsx("div",{className:"toolcall-args",children:s.name==="bash"&&s.argumentsText.startsWith("{")?e.jsx(wi,{args:s.argumentsText}):x?x.lang?e.jsx("div",{className:"toolcall-code",children:e.jsx(Fe,{text:gs(x.content,x.lang)})}):e.jsx("pre",{children:x.content}):e.jsx("pre",{children:s.argumentsText})}),S.length>0&&e.jsxs("div",{className:"toolcall-output",children:[e.jsxs("div",{className:"toolcall-output-label",children:[i(B?"errorOutput":"output"),(N||R)&&e.jsx("span",{className:"thinking-spinner","aria-hidden":"true"}),e.jsx("span",{className:"toolcall-output-spacer"}),_&&!B&&e.jsx("button",{type:"button",className:"toolcall-md-toggle",title:i(p?"showMarkdownSource":"showMarkdownPreview"),onClick:()=>f(b=>!b),children:i(p?"showMarkdownSource":"showMarkdownPreview")})]}),j?e.jsx(ki,{diff:j,lang:h}):_&&p&&!B?e.jsx("div",{className:"toolcall-markdown",children:e.jsx(Fe,{text:S})}):C?e.jsx("div",{className:"toolcall-code",children:e.jsx(Fe,{text:gs(S,C)})}):e.jsx("pre",{children:S})]}),N&&S.length===0&&e.jsx("div",{className:"toolcall-waiting",children:e.jsxs("span",{className:"thinking-live-label",children:[e.jsx("span",{className:"thinking-spinner","aria-hidden":"true"}),i("waitingOutput")]})}),R&&S.length===0&&e.jsx("div",{className:"toolcall-waiting",children:e.jsxs("span",{className:"thinking-live-label",children:[e.jsx("span",{className:"thinking-spinner","aria-hidden":"true"}),i("waitingModel")]})})]});return e.jsxs("div",{className:`toolcall ${Y}`,children:[e.jsxs("div",{className:"toolcall-head",children:[e.jsx("span",{className:"toolcall-icon",children:hs(s.name)}),e.jsx("span",{className:"toolcall-name",children:s.name}),e.jsxs("span",{className:"toolcall-status",children:[M,O&&e.jsx("em",{className:"toolcall-exit",children:O})]}),e.jsx("span",{className:"toolcall-spacer"}),$&&l&&e.jsxs("button",{type:"button",className:"toolcall-kill",title:i("stopBashTip"),onClick:l,children:[e.jsx(ct,{}),e.jsx("span",{children:i("stopBash")})]}),n&&e.jsx("button",{type:"button",className:"toolcall-expand",title:i(v?"collapseCode":"expandCode"),onClick:()=>w(b=>!b),children:v?e.jsx(ga,{}):e.jsx(fa,{})}),e.jsx("button",{type:"button",className:"toolcall-expand",title:i("zoomCode"),onClick:()=>I(!0),children:e.jsx(Ds,{})}),e.jsx("button",{type:"button",className:"toolcall-copy",title:i("copyArgs"),onClick:L,children:d?e.jsx(xa,{}):e.jsx(Rt,{})}),e.jsx("button",{type:"button",className:"toolcall-toggle",onClick:()=>o(b=>!b),children:n?e.jsx(Ie,{}):e.jsx(Je,{})})]}),n&&e.jsx("div",{className:`toolcall-body ${v?"expanded":""}`,children:G}),E&&e.jsx("div",{className:"modal-backdrop",onClick:()=>I(!1),children:e.jsxs("div",{className:"toolcall-zoom",role:"dialog","aria-modal":"true",onClick:b=>b.stopPropagation(),children:[e.jsxs("div",{className:"toolcall-zoom-head",children:[e.jsx("span",{className:"toolcall-icon",children:hs(s.name)}),e.jsx("span",{className:"toolcall-name",children:s.name}),e.jsx("span",{className:"toolcall-spacer"}),e.jsx("button",{type:"button",className:"toolcall-zoom-close",title:i("closeZoom"),onClick:()=>I(!1),children:e.jsx(we,{})})]}),e.jsx("div",{className:"toolcall-body toolcall-zoom-body",children:G})]})})]})});function wi({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 Ci(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 Si=/<\/(?:ant)?think(?:ing)?>/gi,Ti=/(?:\s*<\/?(?:ant)?think(?:ing)?>\s*)+$/i;function fs(t){let s=-1;for(const a of t.matchAll(Si))s=a.index+a[0].length;return s}function Ei(t){const s=t.match(Ti),a=s!=null&&fs(t.slice(0,s.index))!==-1,l=a?s[0].trim():"",c=a?t.slice(0,s.index):t,i=fs(c);return i===-1?null:{leaked:[c.slice(0,i).trim(),l].filter(Boolean).join(`
|
|
13
|
-
`),visible:c.slice(i).trim()}}const Mi=/^<skill name="([^"]+)" location="([^"]+)">\n([\s\S]*?)\n<\/skill>(?:\n\n([\s\S]+))?$/;function Ft(t){var a;const s=t.match(Mi);return s?{name:s[1],location:s[2],content:s[3],userMessage:((a=s[4])==null?void 0:a.trim())||void 0}:null}const Li=1568,Pi=2*1024*1024;function Le(t){return t.startsWith("image/")&&t!=="image/svg+xml"&&t!=="image/svg"}async function Qs(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,Li/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 u=document.createElement("canvas");u.width=l,u.height=c;const p=u.getContext("2d");if(!p)continue;o!=="image/png"&&(p.fillStyle="#ffffff",p.fillRect(0,0,l,c)),p.drawImage(s,0,0,l,c);const f=u.toDataURL(o,d),v=f.match(/^data:([^;]+);base64,/),w=v?v[1]:o,E=f.replace(/^data:[^;]*;base64,/,""),I=Math.floor(E.length*3/4);if(n={data:E,mimeType:w,name:t.name,size:I},I<=Pi)return n}return n}finally{s.close()}}const Ri=20*1024*1024;function tt(t){return t.type==="text"&&typeof t.text=="string"?t:null}function Xs(t){return t.type==="thinking"&&typeof t.thinking=="string"?t:null}function Ys(t){return t.type==="toolCall"&&typeof t.id=="string"&&typeof t.name=="string"?t:null}function Zs(t){return t.type==="image"&&typeof t.dataUrl=="string"?t:null}function en(t){return t.type==="bash"&&typeof t.command=="string"?t:null}function Ii(t){return t.imageData?"image":t.uploadPath?"upload":t.fileData?"file":"path"}function Di(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 xs=r.memo(function({message:s,toolResults:a,liveOutputs:l,toolStatuses:c,streaming:i,isLast:n,onEdit:o,onKillBash:d,onCollapse:u,questionAttachments:p,qnIndex:f,qnActive:v,onJump:w,thinkingWrap:E,toolsWrap:I}){const N=me(),[$,T]=r.useState(!1),[R,B]=r.useState(""),[_,C]=r.useState([]),[x,j]=r.useState(!1),[h,S]=r.useState(null),Y=D=>{S(D),window.setTimeout(()=>S(Z=>Z===D?null:Z),4e3)};if(s.role==="toolResult")return null;const M=s.role==="custom"&&s.customType==="file",Q=s.content.map(D=>{var Z;return((Z=tt(D))==null?void 0:Z.text)??""}).filter(Boolean).join(`
|
|
14
|
-
`),O=s.role==="user"?Ft(Q):null,L=O?O.userMessage??`skill:${O.name}`:Q.split(`
|
|
15
|
-
`).join(" ").trim(),G=i&&n&&s.role!=="user"&&s.content.length===0,W=s.role==="user"&&!i&&!G&&!!o,ie=async D=>{const Z=[];for(const ee of D){if(!Le(ee.type))continue;const X=await Qs(ee);X&&Z.push({path:"",imageData:X.data,mimeType:X.mimeType,name:X.name})}Z.length>0&&C(ee=>[...ee,...Z])},pe=async D=>{if(D.size>Ri){Y(N("fileTooLarge",{name:D.name,size:20}));return}let Z;try{Z=(await new Promise((X,de)=>{const ae=new FileReader;ae.onload=()=>X(ae.result),ae.onerror=()=>de(ae.error??new Error("read failed")),ae.readAsDataURL(D)})).replace(/^data:[^;]*;base64,/,"")}catch{Y(N("fileLoadFailed",{name:D.name}));return}C(ee=>[...ee,{path:"",fileData:Z,name:D.name,size:D.size,mimeType:D.type||void 0}])},K=async D=>{const Z=[];for(const ee of D)Le(ee.type)?Z.push(ee):pe(ee);Z.length>0&&await ie(Z)},b=()=>{B(O?`/skill:${O.name}${O.userMessage?` ${O.userMessage}`:""}`:s.content.map(D=>{var Z;return((Z=tt(D))==null?void 0:Z.text)??""}).filter(Boolean).join(`
|
|
16
|
-
`)),C(p??[]),T(!0)},U=()=>{const D=R.trim();D&&(o==null||o(s.id,D,_.length>0?_:void 0),T(!1))},te=s.role==="custom"&&(s.customType==="goal-review"||s.customType==="goal-wizard"),ue=s.role==="custom"&&s.customType==="goal-wizard";return e.jsxs("div",{className:`msg msg-${s.role}${te?" 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"?ue?N("goalWizardCard"):te?N("goalBarTitle"):s.customType==="file"?N("attachment"):`${N("plugin")} · ${s.customType??N("unknown")}`:_t(s.role,N)}),s.model&&e.jsx("span",{className:"msg-model",children:s.model}),s.timestamp&&e.jsx("span",{className:"msg-time",children:_i(s.timestamp)}),u&&e.jsxs("button",{type:"button",className:"msg-collapse-btn",title:N("collapseMsg"),onClick:()=>u(s.id),children:[e.jsx(ft,{})," ",N("collapseMsg")]}),f!==void 0&&w&&e.jsxs("button",{type:"button",className:`qn-tag ${v?"active":""}`,title:`${f+1}. ${L}`,"aria-label":`${f+1}. ${L}`,onClick:()=>w(s.id),children:[e.jsx("span",{className:"qn-tag-bar"}),e.jsx("span",{className:"qn-tag-idx",children:f+1})]})]}),e.jsx("div",{className:"msg-body",children:$?e.jsxs("div",{className:`msg-editor${x?" drag-over":""}`,onDragOver:D=>{D.preventDefault(),D.stopPropagation(),j(!0)},onDragLeave:D=>{D.currentTarget.contains(D.relatedTarget)||j(!1)},onDrop:D=>{var Z;D.preventDefault(),D.stopPropagation(),j(!1),K(Array.from(((Z=D.dataTransfer)==null?void 0:Z.files)??[]))},children:[_.length>0&&e.jsx("div",{className:"msg-editor-images",children:_.map((D,Z)=>{var X;const ee=Ii(D);return e.jsxs("span",{className:`msg-editor-img ${ee==="image"?"":"file-chip"}`,title:Di(D,N),children:[ee==="image"?e.jsx("img",{src:`data:${D.mimeType??"image/png"};base64,${D.imageData}`,alt:D.name}):e.jsxs("span",{className:"msg-editor-file",children:[e.jsx("span",{className:"msg-editor-file-icon",children:ee==="path"?D.mode==="reference"?"🔗":"📎":"📄"}),e.jsx("span",{className:"msg-editor-file-name",children:D.name??((X=D.path)==null?void 0:X.split("/").pop())})]}),e.jsx("button",{type:"button",className:"msg-editor-img-remove",title:N("removeAttachment"),onClick:()=>C(de=>de.filter((ae,g)=>g!==Z)),children:e.jsx(we,{})})]},`${D.name??D.path??"att"}-${Z}`)})}),h&&e.jsx("div",{className:"msg-editor-notice",children:h}),e.jsx("textarea",{className:"msg-editor-input",value:R,autoFocus:!0,placeholder:N("editPlaceholder"),rows:Math.max(2,Math.min(10,R.split(`
|
|
17
|
-
`).length+1)),onChange:D=>B(D.target.value),onPaste:D=>{var ee;const Z=[];for(const X of((ee=D.clipboardData)==null?void 0:ee.items)??[])if(X.kind==="file"&&Le(X.type)){const de=X.getAsFile();de&&Z.push(de)}Z.length!==0&&(D.preventDefault(),ie(Z))},onKeyDown:D=>{D.key==="Enter"&&(D.metaKey||D.ctrlKey)?(D.preventDefault(),U()):D.key==="Escape"&&T(!1)}}),e.jsxs("div",{className:"msg-editor-actions",children:[e.jsxs("span",{className:"msg-editor-hint",children:[e.jsx(oa,{})," ",N("editAttachmentHint")]}),e.jsx("button",{type:"button",className:"chip",onClick:()=>T(!1),children:N("cancel")}),e.jsxs("button",{type:"button",className:"chip primary",disabled:!R.trim(),title:N("reaskFromHere"),onClick:U,children:[e.jsx(St,{})," ",N("reaskFromHere")]})]})]}):e.jsxs(e.Fragment,{children:[s.errorMessage&&e.jsx("div",{className:"msg-error",children:s.errorMessage}),M?e.jsx($i,{message:s}):O?e.jsxs(e.Fragment,{children:[e.jsx(Fi,{block:O}),O.userMessage&&e.jsx("div",{className:"msg-text",children:e.jsx(Fe,{text:O.userMessage})}),s.content.map((D,Z)=>D.type==="text"?null:e.jsx(ys,{block:D,toolResults:a,liveOutputs:l,toolStatuses:c,streaming:i,isLast:n,onKillBash:d,toolsWrap:I,thinkingWrap:E},`${s.id}-${Z}`))]}):s.content.map((D,Z)=>e.jsx(ys,{block:D,toolResults:a,liveOutputs:l,toolStatuses:c,streaming:i,isLast:n,onKillBash:d,toolsWrap:I,thinkingWrap:E},`${s.id}-${Z}`)),G&&e.jsxs("div",{className:"thinking-wait",children:[N("thinkingWait"),e.jsx("span",{className:"dot"})]}),i&&n&&s.role!=="user"&&!G&&e.jsx("span",{className:"stream-cursor"})]})}),W&&!$&&e.jsx("div",{className:"msg-actions",children:e.jsxs("button",{type:"button",className:"msg-action",title:N("editReaskTip"),onClick:b,children:[e.jsx(St,{})," ",N("editReask")]})})]})});function $i({message:t}){const s=me(),[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",u=t.content.filter(w=>w.type==="text").map(w=>w.text).join(`
|
|
18
|
-
`),p=Bi(u),f=t.content.find(w=>w.type==="image"),v=p.split(`
|
|
19
|
-
`).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")} · ${vs(c.size)}`:d?s("bridgedVision"):f?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(Ie,{}):e.jsx(Je,{}))]}),!o&&a&&(d?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"attachcard-bridgenote",children:s("bridgedVisionDetail")}),(f==null?void 0:f.dataUrl)&&e.jsx("div",{className:"attachcard-image",children:e.jsx("img",{src:f.dataUrl,alt:i})}),p&&e.jsx("pre",{className:"attachcard-content",children:p})]}):f!=null&&f.dataUrl?e.jsx("div",{className:"attachcard-image",children:e.jsx("img",{src:f.dataUrl,alt:i})}):e.jsx("pre",{className:"attachcard-content",children:p})),o&&e.jsx("div",{className:"attachcard-refnote",children:n?s("folderNotExpanded"):s("fileNotExpanded",{size:vs(c.size)})})]})}function vs(t){return t===void 0?"":t>=1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:t>=1024?`${Math.round(t/1024)} KB`:`${t} B`}function Bi(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 Fi({block:t}){const s=me(),[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(va,{})}),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(ft,{}):e.jsx(Ie,{}),s(a?"collapseMsg":"expandMsg")]})]}),a&&e.jsx("div",{className:"skillcard-body",children:e.jsx(Fe,{text:t.content})})]})}function ys({block:t,toolResults:s,liveOutputs:a,toolStatuses:l,streaming:c,isLast:i,onKillBash:n,thinkingWrap:o,toolsWrap:d}){const u=me(),p=tt(t);if(p){const I=c&&i,N=Ei(p.text),$=N?N.visible:p.text;return e.jsxs("div",{className:"msg-text",children:[N&&e.jsx(ei,{text:N.leaked}),$&&(I?e.jsx(di,{text:$}):e.jsx(Fe,{text:$})),p.truncated&&e.jsx("div",{className:"trunc-note",children:u("truncated")})]})}const f=Xs(t);if(f)return e.jsx(ui,{thinking:f.thinking,streaming:c&&i,wrap:o});const v=Ys(t);if(v){const I=s.get(v.id),N=a.get(v.id),$={result:I,liveOutput:N==null?void 0:N.text,streaming:c,status:l.get(v.id)};return e.jsx(Ni,{block:v,view:$,onKillBash:n,wrap:d})}const w=Zs(t);if(w&&w.dataUrl)return e.jsx("div",{className:"msg-image",children:e.jsx("img",{src:w.dataUrl,alt:"attachment"})});const E=en(t);return E?e.jsxs("div",{className:"bashblock",children:[e.jsxs("div",{className:"bashblock-command",children:[e.jsx("span",{className:"bashblock-prompt",children:"$"}),e.jsx("code",{children:E.command}),E.exitCode!==void 0&&e.jsx("span",{className:`bashblock-exit ${E.exitCode===0?"ok":"err"}`,children:u("exitCode",{code:E.exitCode})}),E.cancelled&&e.jsx("span",{className:"bashblock-exit err",children:u("cancelled")})]}),E.output&&e.jsx("pre",{className:"bashblock-output",children:E.output}),E.truncated&&e.jsx("div",{className:"trunc-note",children:u("outputTruncated")})]}):null}function _t(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 _i(t){const s=new Date(t),a=String(s.getHours()).padStart(2,"0"),l=String(s.getMinutes()).padStart(2,"0");return`${a}:${l}`}function js(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 Ai(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=[];js(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(!js(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 Oi=r.memo(function({message:s,onExpand:a}){const l=me();let c="";for(const f of s.content){const v=tt(f);if(v&&v.text.trim()){const w=Ft(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 f=s.details??{};c=f.name??f.path??""}c.length>90&&(c=`${c.slice(0,90)}…`);let n=0,o=0,d=0,u=0;for(const f of s.content)Xs(f)?n++:Ys(f)?o++:en(f)?d++:Zs(f)&&u++;const p=[];return n&&p.push(`${l("thinking")} ${n}`),o&&p.push(`${l("toolCalls")} ${o}`),d&&p.push(`${l("bashRuns")} ${d}`),u&&p.push(`${l("images")} ${u}`),e.jsxs("button",{type:"button",className:"msg-collapsed","data-msg-id":s.id,title:`${l("expandMsg")} · ${c||p.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"):_t(s.role,l)}),e.jsxs("span",{className:"msg-collapsed-body",children:[c&&e.jsx("span",{className:"msg-collapsed-preview",children:c}),p.length>0&&e.jsx("span",{className:"msg-collapsed-chips",children:p.map((f,v)=>e.jsx("span",{className:"msg-collapsed-chip",children:f},v))})]}),s.timestamp?e.jsx("span",{className:"msg-collapsed-time",children:Wi(s.timestamp)}):null,e.jsxs("span",{className:"msg-collapsed-action",children:[e.jsx(Ie,{})," ",l("expandMsg")]})]})});function Wi(t){const s=new Date(t),a=String(s.getHours()).padStart(2,"0"),l=String(s.getMinutes()).padStart(2,"0");return`${a}:${l}`}const Hi=r.memo(function({id:s,show:a,height:l,containerRef:c,onMeasured:i,lazyRef:n,children:o}){const d=r.useRef(null),u=r.useRef(null);return r.useLayoutEffect(()=>{const p=u.current;if(u.current=a,!a||p!==!1)return;const f=d.current,v=c.current;if(!f||!v)return;const w=f.offsetHeight;i==null||i(s,w);const E=w-l;if(E!==0){const I=f.parentElement;I&&I.getBoundingClientRect().bottom<=v.getBoundingClientRect().top&&(v.scrollTop+=E)}},[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 qi(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 Ui(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 zi(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)??tn(n.role,n.customType)}return l}function tn(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 Ki(t){if(t.role==="toolResult")return"";const s=[];for(const a of t.content)Vi(a,s);return t.errorMessage&&s.push(t.errorMessage),s.join(`
|
|
20
|
-
`)}function Vi(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 Gi(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 Ji(t,s){const a=s.trim().toLowerCase();if(!a)return[];const l=[];for(const c of t){const i=Ki(c);if(!i)continue;const n=Gi(i,a);for(let o=0;o<n;o++)l.push({messageId:c.id,occurrence:o})}return l}function Qi(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(),u=(n=o.parentElement)==null?void 0:n.closest("[data-msg-id]");if(!u)continue;const p=u.getAttribute("data-msg-id")??"";let f=d.indexOf(c);for(;f!==-1;){const v=document.createRange();v.setStart(o,f),v.setEnd(o,f+c.length),l.push(v);const w=a.get(p);w?w.push(v):a.set(p,[v]),f=d.indexOf(c,f+c.length)}}return{byMsg:a,all:l}}function We(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 Xi({containerRef:t,messages:s,open:a,onClose:l,onEnsureExpanded:c}){const i=me(),n=r.useRef(null),[o,d]=r.useState(""),[u,p]=r.useState(0),f=r.useDeferredValue(o),v=a?f.trim():"",w=r.useMemo(()=>a?Ji(s,v):[],[s,v,a]),E=r.useRef(w);E.current=w;const I=r.useRef(u);I.current=u,r.useEffect(()=>{a&&(p(0),requestAnimationFrame(()=>{var R;return(R=n.current)==null?void 0:R.select()}))},[a]),r.useEffect(()=>{if(!a)return;const R=B=>{B.key==="Escape"&&(B.preventDefault(),B.stopPropagation(),l())};return window.addEventListener("keydown",R,!0),()=>window.removeEventListener("keydown",R,!0)},[a,l]),r.useEffect(()=>(a||(We("msg-search",[]),We("msg-search-active",[])),()=>{We("msg-search",[]),We("msg-search-active",[])}),[a]);const N=r.useCallback(R=>{const B=t.current;if(!B)return;const _=B.querySelector(`[data-msg-id="${R}"]`);_&&(_.classList.remove("msg-flash"),_.offsetWidth,_.classList.add("msg-flash"))},[t]);r.useLayoutEffect(()=>{if(!a||!v)return;const R=t.current;if(!R)return;let B=!1,_=0;return _=requestAnimationFrame(()=>{var Y;if(B)return;const{byMsg:C,all:x}=Qi(R,v);We("msg-search",x);const j=E.current,h=j[Math.min(I.current,j.length-1)];if(!h)return;const S=(Y=C.get(h.messageId))==null?void 0:Y[h.occurrence];if(S){We("msg-search-active",[S]);const M=S.startContainer.parentElement??R.querySelector(`[data-msg-id="${h.messageId}"]`);M==null||M.scrollIntoView({block:"center"})}else N(h.messageId)}),()=>{B=!0,cancelAnimationFrame(_)}},[a,v,w,t,N]);const $=r.useCallback(R=>{const B=E.current;if(B.length===0)return;const _=(I.current+R+B.length)%B.length;p(_),c(B[_].messageId)},[c]);if(!a)return null;const T=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:R=>{d(R.target.value),p(0)},onKeyDown:R=>{R.key==="Enter"&&(R.preventDefault(),$(R.shiftKey?-1:1))}}),e.jsx("span",{className:`search-count ${T===0?"empty":""}`,children:T===0?i("searchNoResults"):`${Math.min(u+1,T)}/${T}`}),e.jsx("button",{type:"button",className:"search-btn",title:i("searchPrev"),disabled:T===0,onClick:()=>$(-1),children:e.jsx(ft,{})}),e.jsx("button",{type:"button",className:"search-btn",title:i("searchNext"),disabled:T===0,onClick:()=>$(1),children:e.jsx(Ie,{})}),e.jsx("button",{type:"button",className:"search-btn",title:i("searchClose"),onClick:l,children:e.jsx(we,{})})]})}const bs=new Map,Yi=15,ks=30,Ns=1200,Zi=1600;function ws(t){return t.content.some(s=>s.type==="toolCall")}const er=[{key:"ex.understand",icon:"🔍"},{key:"ex.debug",icon:"🐛"},{key:"ex.test",icon:"🧪"},{key:"ex.review",icon:"🧹"}];function tr(t){return er.map(({key:s,icon:a})=>({icon:a,text:t(s),prompt:t(`${s}.prompt`)}))}function sr({state:t,liveOutputs:s,toolStatuses:a,onEdit:l,onKillBash:c,thinkingWrap:i,toolsWrap:n,pendingEcho:o}){const d=me(),u=r.useRef(null),[p,f]=r.useState(!0),v=r.useRef(!0),w=r.useRef(0),E=r.useRef(!1),[I,N]=r.useState(()=>new Set),[$,T]=r.useState(!1),R=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]),_=r.useMemo(()=>Ai(t.messages),[t.messages]),C=R.length>0?R[R.length-1].id:null,x=t.messages.length>ks?Math.max(0,t.messages.length-Yi):0,[j,h]=r.useState(()=>new Set),[S,Y]=r.useState(()=>new Set),M=r.useRef(new Map),Q=r.useRef(new Map),O=r.useRef(0),L=r.useRef(j);L.current=j;const G=t.messages.length>ks&&!$,W=r.useRef(G);W.current=G;const ie=zi(t.messages,M.current,Zi),pe=r.useRef(ie);pe.current=ie;const K=r.useCallback(()=>{const k=u.current;if(!k)return;if(!W.current){h(V=>V.size?new Set:V);return}const F=k.getBoundingClientRect(),ce={top:F.top-Ns,bottom:F.bottom+Ns},le=[];for(const[V,J]of Q.current){const ve=J.getBoundingClientRect();le.push({id:V,top:ve.top,bottom:ve.bottom}),L.current.has(V)||M.current.set(V,ve.bottom-ve.top)}const y=qi(le,ce,pe.current,L.current);for(const V of y.hide){const J=Q.current.get(V);J&&M.current.set(V,J.offsetHeight)}h(V=>Ui(V,y))},[]),b=r.useCallback(()=>{O.current||(O.current=requestAnimationFrame(()=>{O.current=0,K()}))},[K]);r.useLayoutEffect(()=>{K()},[K]);const U=r.useRef($);r.useLayoutEffect(()=>{U.current&&!$&&K(),U.current=$},[$,K]);const te=r.useCallback((k,F)=>{M.current.set(k,F)},[]),ue=r.useCallback(k=>{k&&Q.current.set(k.dataset.lazyId??"",k)},[]);r.useEffect(()=>{const k=new Set(t.messages.map(F=>F.id));for(const[F,ce]of Q.current)k.has(F)||(Q.current.delete(F),M.current.delete(F));h(F=>{let ce=!1;const le=new Set;for(const y of F)k.has(y)?le.add(y):ce=!0;return ce?le:F})},[t.messages,I]),r.useEffect(()=>()=>cancelAnimationFrame(O.current),[]);const D=r.useMemo(()=>{const k=[];for(const F of t.messages){if(F.role!=="user")continue;const ce=F.content.map(V=>{var J;return((J=tt(V))==null?void 0:J.text)??""}).filter(Boolean).join(" "),le=Ft(ce),y=le?le.userMessage??`skill:${le.name}`:ce.trim();y&&k.push({id:F.id,text:y})}return k},[t.messages]),Z=r.useMemo(()=>{const k=new Map;return D.forEach((F,ce)=>k.set(F.id,ce)),k},[D]),[ee,X]=r.useState(-1),de=r.useRef(-1),ae=r.useRef(D);r.useEffect(()=>{ae.current=D},[D]);const g=r.useCallback(()=>{const k=u.current,F=ae.current;if(!k||F.length===0)return;const ce=k.getBoundingClientRect().top,le=140;let y=-1;for(let V=0;V<F.length;V++){const J=k.querySelector(`[data-msg-id="${F[V].id}"]`);if(J)if(J.getBoundingClientRect().top<=ce+le)y=V;else break}y!==de.current&&(de.current=y,X(y))},[]);r.useEffect(()=>{g()},[D,g]);const m=r.useCallback(k=>{N(F=>F.has(k)?F:new Set(F).add(k))},[]),H=r.useCallback(k=>{const F=t.messages.findIndex(ce=>ce.id===k);F>=0&&F<x&&!I.has(k)&&ds.flushSync(()=>m(k))},[t.messages,x,I,m]);r.useEffect(()=>{const k=F=>{if(!(F.ctrlKey||F.metaKey)||F.key.toLowerCase()!=="f")return;const ce=F.target;ce&&(ce.tagName==="INPUT"||ce.tagName==="TEXTAREA"||ce.isContentEditable)||(F.preventDefault(),T(!0))};return window.addEventListener("keydown",k),()=>window.removeEventListener("keydown",k)},[]);const re=r.useCallback(k=>{N(F=>{if(!F.has(k))return F;const ce=new Set(F);return ce.delete(k),ce})},[]),oe=r.useCallback(k=>{const F=t.messages.findIndex(le=>le.id===k);ds.flushSync(()=>{F>=0&&F<x&&!I.has(k)&&m(k),Y(le=>le.has(k)?le:new Set(le).add(k))});const ce=ae.current.findIndex(le=>le.id===k);de.current=ce,X(ce),requestAnimationFrame(()=>{var y,V,J;const le=(y=u.current)==null?void 0:y.querySelector(`[data-msg-id="${k}"]`);le&&((V=u.current)==null||V.querySelectorAll(".msg-flash").forEach(ve=>ve.classList.remove("msg-flash")),le.scrollIntoView({block:"start"}),le.classList.remove("msg-flash"),le.offsetWidth,le.classList.add("msg-flash"),le!==((J=u.current)==null?void 0:J.lastElementChild)&&(E.current=!0))})},[t.messages,x,I,m]),q=r.useCallback(()=>{const k=u.current;if(!k)return;const F=k.scrollTop-w.current;w.current=k.scrollTop;const ce=k.scrollHeight-k.scrollTop-k.clientHeight<80;F<-4&&F>-500?E.current=!0:ce&&F>=0&&(E.current=!1),v.current=ce&&!E.current,f(v.current),g(),b()},[g,b]),se=r.useRef(!1);r.useEffect(()=>{const k=se.current;if(se.current=!!t.isStreaming,k&&!t.isStreaming&&!E.current){const F=()=>{const le=u.current;le&&!E.current&&(le.scrollTop=le.scrollHeight,v.current=!0,f(!0))};requestAnimationFrame(()=>requestAnimationFrame(F));const ce=setTimeout(F,180);return()=>clearTimeout(ce)}},[t.isStreaming]),r.useEffect(()=>{const k=u.current;k&&v.current&&(k.scrollTop=k.scrollHeight)},[R,t.isStreaming,s]);const xe=t.queue.steering.join("\0")+""+t.queue.followUp.join("\0");r.useEffect(()=>{const k=u.current;k&&v.current&&(k.scrollTop=k.scrollHeight)},[xe]);const ke=r.useCallback(()=>{const k=u.current;k&&(k.scrollTop=k.scrollHeight),v.current=!0,E.current=!1,f(!0)},[]),he=r.useRef(null);r.useEffect(()=>{const k=he.current,F=u.current;if(!k||!F)return;const ce=le=>{le.preventDefault();const y=k.querySelector(".qn-list");if(y&&y.contains(le.target)&&y.scrollHeight>y.clientHeight){y.scrollTop+=le.deltaY;return}F.scrollTop+=le.deltaY};return k.addEventListener("wheel",ce,{passive:!1}),()=>k.removeEventListener("wheel",ce)},[]);const[_e,Qe]=r.useState(0);r.useEffect(()=>{const k=()=>{var F;Qe(((F=u.current)==null?void 0:F.clientHeight)??0),b()};return k(),window.addEventListener("resize",k),()=>window.removeEventListener("resize",k)},[b]);const De=D.length,Ae=r.useMemo(()=>De===0?27:Math.max(4,Math.min(27,Math.floor(((_e||600)-16)/De)-3)),[De,_e]),Te=Ae<20;return e.jsxs("div",{className:"messages-wrap",children:[e.jsxs("div",{className:"messages",ref:u,onScroll:q,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:d("welcomeTitle")}),e.jsx("p",{className:"empty-sub",children:d("welcomeSub")}),e.jsxs("div",{className:"empty-cwd",children:[e.jsx("span",{className:"empty-cwd-label",children:d("directory")}),e.jsx("span",{className:"empty-cwd-path",children:t.cwd})]}),e.jsx("div",{className:"empty-examples",children:tr(d).map(k=>e.jsxs("button",{type:"button",className:"empty-example",title:d("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 ce=F<x,le=ce&&I.has(k.id);if(ce&&!le)return k.role==="toolResult"?null:e.jsx(Oi,{message:k,onExpand:m},k.id);const y=k.role==="user"?Z.get(k.id):void 0,V=!G||ie.has(k.id)||S.has(k.id)||!j.has(k.id);return e.jsx(Hi,{id:k.id,show:V,height:M.current.get(k.id)??tn(k.role,k.customType),containerRef:u,onMeasured:te,lazyRef:ue,children:e.jsx(xs,{message:k,qnIndex:y,qnActive:y!==void 0?y===ee:void 0,onJump:oe,toolResults:B,liveOutputs:ws(k)?s:bs,toolStatuses:a,streaming:t.isStreaming,onKillBash:c,toolsWrap:n,thinkingWrap:i,isLast:k.id===C,onEdit:l,questionAttachments:_.get(k.id),onCollapse:le?re:void 0},k.id)},k.id)}),t.streamingMessage&&e.jsx(xs,{message:t.streamingMessage,toolResults:B,liveOutputs:ws(t.streamingMessage)?s:bs,toolStatuses:a,streaming:!0,isLast:!0,onEdit:l,onKillBash:c,toolsWrap:n,thinkingWrap:i},t.streamingMessage.id),t.isStreaming&&R.length===0&&e.jsx("div",{className:"streaming-wait",children:d("waitingResponse")}),t.isStreaming&&!t.streamingMessage&&R.length>0&&e.jsxs("div",{className:"msg msg-assistant assistant-wait-msg","data-role":"assistant",children:[e.jsx("div",{className:"msg-meta",children:e.jsx("span",{className:"msg-role",children:_t("assistant",d)})}),e.jsx("div",{className:"msg-body",children:e.jsxs("span",{className:"assistant-wait",children:[e.jsx("span",{className:"thinking-spinner","aria-hidden":"true"}),d("waitingResponse")]})})]}),o&&o.conversationId===t.conversationId&&e.jsxs("div",{className:"msg msg-user pending-echo","data-role":"user",children:[e.jsxs("div",{className:"msg-meta",children:[e.jsx("span",{className:"msg-role",children:d("role.user")}),e.jsxs("span",{className:"pending-echo-tag",children:[e.jsx("span",{className:"thinking-spinner","aria-hidden":"true"}),d("sending")]})]}),e.jsx("div",{className:"msg-body",children:e.jsx("div",{className:"msg-text",children:o.text})})]}),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:d("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:d("queueFollowTag")}),e.jsx("div",{className:"queued-text",children:k})]})},`q-fu-${F}`))]}),!p&&e.jsxs("button",{type:"button",className:"scroll-bottom",onClick:ke,children:[e.jsx(As,{})," ",d("backToBottom")]}),e.jsx(Xi,{containerRef:u,messages:R,open:$,onClose:()=>T(!1),onEnsureExpanded:H}),D.length>0&&e.jsxs("div",{className:`qn-rail ${Te?"many":""}`,ref:he,"aria-label":d("questionNavTitle"),style:{"--rail-gap":`${Ae}px`},children:[D.map((k,F)=>e.jsx("button",{type:"button",className:`qn-bar ${F===ee?"active":""}`,"aria-label":`${F+1}. ${k.text}`,onClick:()=>oe(k.id),children:e.jsxs("span",{className:"qn-bar-text",children:[F+1,". ",k.text]})},k.id)),Te&&e.jsx("div",{className:"qn-list",children:D.map((k,F)=>e.jsxs("button",{type:"button",className:`qn-list-item ${F===ee?"active":""}`,"aria-label":`${F+1}. ${k.text}`,onClick:()=>oe(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 nr=r.memo(function({ready:s,streaming:a,messages:l,slashCommands:c,modelState:i,models:n,modelsLoading:o,send:d,activeConversationId:u,setPendingEcho:p,attachments:f,onRemoveAttachment:v,onAddImageFiles:w,onAddLocalFiles:E,onNotice:I,onSent:N,onManageModels:$}){const T=me(),{locale:R}=It(),B=m=>R==="en"&&m.descriptionEn?m.descriptionEn:m.description??"",_=m=>R==="en"&&m.argumentHintEn?m.argumentHintEn:m.argumentHint??"",[C,x]=r.useState(""),[j,h]=r.useState(!1),[S,Y]=r.useState(null),[M,Q]=r.useState(0),[O,L]=r.useState(!1),[G,W]=r.useState(void 0),ie=r.useRef(null),pe=r.useRef(null),K=r.useRef(null),b={builtin:T("slashBuiltin"),extension:T("slashExtension"),prompt:T("slashPrompt"),skill:T("slashSkill"),plugin:T("slashPlugin")},U=m=>{const H=m.match(/^\/([^\s]*)$/);if(H&&s){const re=H[1].toLowerCase(),oe=c.filter(q=>{const se=q.name.toLowerCase();if(se.startsWith(re))return!0;const xe=se.indexOf(":");return xe>=0&&se.slice(xe+1).startsWith(re)});Y(oe.length>0?oe:null),Q(0)}else Y(null)};r.useEffect(()=>{var H;const m=(H=K.current)==null?void 0:H.querySelector(".slash-item.active");m==null||m.scrollIntoView({block:"nearest"})},[M,S]);const te=m=>{var se;const H=S??[],re=m??H[M%Math.max(H.length,1)];if(!re){Y(null);return}const oe=C.match(/^\/([^\s]*)([\s\S]*)$/),q=oe?oe[2]:"";x(`/${re.name} ${q}`),Y(null),(se=ie.current)==null||se.focus()},ue=async()=>{const H=[...l].reverse().find(oe=>oe.role==="assistant"&&oe.content.some(q=>q.type==="text"&&q.text)),re=H==null?void 0:H.content.filter(oe=>oe.type==="text").map(oe=>oe.text).join(`
|
|
21
|
-
`);if(!re){I("warning",T("slashCopyEmpty"));return}try{await navigator.clipboard.writeText(re),I("info",T("slashCopied"))}catch{I("error",T("slashCopyFailed"))}},D=m=>{if(!m||m.length===0){I("warning",T("foldersNotSupported"));return}const H=Array.from(m).filter(oe=>Le(oe.type)),re=Array.from(m).filter(oe=>!Le(oe.type));H.length>0&&w(H),re.length>0&&E(re)},Z=m=>{var oe;const H=(oe=m.clipboardData)==null?void 0:oe.items;if(!H)return;const re=[];for(const q of H)if(q.kind==="file"&&Le(q.type)){const se=q.getAsFile();se&&re.push(se)}re.length!==0&&(m.preventDefault(),w(re))},ee=s,X=r.useRef(C);r.useEffect(()=>{X.current=C},[C]),r.useEffect(()=>{U(X.current)},[c]),r.useEffect(()=>{const m=H=>{var oe;const re=H.detail;x(re),(oe=ie.current)==null||oe.focus()};return window.addEventListener("pi-web:fill",m),()=>window.removeEventListener("pi-web:fill",m)},[]),r.useEffect(()=>{if(!O)return;const m=H=>{H.key==="Escape"&&L(!1)};return window.addEventListener("keydown",m),()=>window.removeEventListener("keydown",m)},[O]),r.useEffect(()=>{const m=ie.current;if(!m)return;m.style.height="auto";const H=m.scrollHeight>220;m.style.height=`${Math.min(m.scrollHeight,220)}px`,m.style.overflowY=H?"auto":"hidden"},[C]);const de=(m=!1)=>{var oe,q,se,xe,ke;const H=C.trim(),re=f.some(he=>he.imageData||he.fileData);if(!(!ee||!H&&!re)){if(H==="/help"){const he=(q=(oe=ie.current)==null?void 0:oe.closest(".inputbox"))==null?void 0:q.getBoundingClientRect();W(he==null?void 0:he.width),L(!0),x(""),(se=ie.current)==null||se.focus();return}if(H==="/copy"){x(""),(xe=ie.current)==null||xe.focus(),ue();return}d({type:"prompt",text:H,queue:m,attachments:f.map(he=>he.imageData?{path:"",imageData:he.imageData,mimeType:he.mimeType,name:he.name}:he.fileData?{path:"",fileData:he.fileData,mimeType:he.mimeType,name:he.name,size:he.size}:{path:he.path,mode:he.mode,...he.lines?{lines:he.lines}:{}})})&&(p(u,H),x(""),N(),(ke=ie.current)==null||ke.focus())}},ae=m=>{if(!m.nativeEvent.isComposing){if(S&&S.length>0)switch(m.key){case"ArrowDown":m.preventDefault(),Q(H=>(H+1)%S.length);return;case"ArrowUp":m.preventDefault(),Q(H=>(H-1+S.length)%S.length);return;case"Tab":case"Enter":m.preventDefault(),te();return;case"Escape":m.preventDefault(),Y(null);return}m.key==="Enter"&&!m.shiftKey&&(m.preventDefault(),de())}},g=()=>e.jsx("div",{className:"inputbox-actions",children:a?e.jsxs(e.Fragment,{children:[C.trim()!==""&&e.jsxs("button",{type:"button",className:"btn supplement",title:T("supplementTip"),onClick:()=>de(!0),children:[e.jsx(Zn,{})," ",T("supplement")]}),e.jsx("button",{type:"button",className:"btn stop",title:T("stopAgent"),onClick:()=>d({type:"abort"}),children:e.jsx(ct,{})})]}):e.jsx("button",{type:"button",className:"btn send",title:T("sendTip"),disabled:!ee||!C.trim()&&!f.some(m=>m.imageData||m.fileData),onClick:()=>de(),children:e.jsx(_s,{})})});return e.jsxs("div",{className:`inputbar${j?" drop-active":""}`,onDragOver:m=>{m.preventDefault(),m.stopPropagation(),h(!0)},onDragLeave:m=>{m.currentTarget.contains(m.relatedTarget)||h(!1)},onDrop:m=>{var H;m.preventDefault(),m.stopPropagation(),h(!1),D(((H=m.dataTransfer)==null?void 0:H.files)??null)},children:[j&&e.jsx("div",{className:"drop-overlay",children:e.jsxs("span",{children:["📎 ",T("dropHereToAttach")]})}),f.length>0&&e.jsxs("div",{className:"attach-row",children:[f.map(m=>e.jsxs("span",{className:`attach-chip ${m.imageData?"image":m.fileData?"file":m.mode}`,title:m.imageData?T("attachImage",{name:m.name}):m.fileData?T("attachFile",{name:m.name}):m.isDir?T("folderRef",{path:m.path}):m.mode==="reference"?T("refOnly",{path:m.path}):m.mode==="lines"&&m.lines?T("attachLines",{path:m.path,start:m.lines.start,end:m.lines.end}):T("attachContent",{path:m.path}),children:[m.imageData?"🖼":m.fileData?"📄":m.isDir?"📁":m.mode==="reference"?"🔗":"📎"," ",m.name,m.mode==="lines"&&m.lines&&e.jsxs("span",{className:"attach-range",children:["L",m.lines.start,"-",m.lines.end]}),e.jsx("button",{type:"button",className:"attach-remove",title:T("removeAttachment"),onClick:()=>v(m.key??m.path),children:"×"})]},m.key??`${m.path}|${m.mode}|${m.lines?`${m.lines.start}-${m.lines.end}`:""}`)),e.jsx("span",{className:"attach-hint",children:T("attachHint")})]}),S&&S.length>0&&e.jsxs("div",{className:"slash-menu",role:"listbox",ref:K,"aria-label":T("slashCommands"),children:[e.jsxs("div",{className:"slash-menu-hint",children:[e.jsx("span",{children:T("slashMenuHint")}),e.jsx("span",{className:"slash-menu-close",onClick:()=>Y(null),children:"Esc"})]}),S.map((m,H)=>e.jsxs("button",{type:"button",className:`slash-item${H===M?" active":""}`,onMouseEnter:()=>Q(H),onClick:()=>te(m),children:[e.jsxs("span",{className:"slash-name",children:["/",m.name]}),e.jsx("span",{className:`slash-source ${m.source}`,children:b[m.source]}),e.jsxs("span",{className:"slash-desc",children:[B(m),m.argumentHint&&e.jsx("span",{className:"slash-hint",children:_(m)})]})]},m.name))]}),O&&e.jsx("div",{className:"modal-backdrop",onClick:()=>L(!1),children:e.jsxs("div",{className:"slash-help",style:G?{width:G}:void 0,onClick:m=>m.stopPropagation(),children:[e.jsxs("div",{className:"slash-help-head",children:[e.jsxs("span",{children:["⚡ ",T("slashHelpTitle")]}),e.jsx("button",{type:"button",className:"btn",onClick:()=>L(!1),children:T("close")})]}),e.jsx("div",{className:"slash-help-body",children:c.length===0?e.jsx("div",{className:"slash-help-empty",children:T("slashLoading")}):c.map(m=>e.jsxs("div",{className:"slash-help-row",children:[e.jsxs("span",{className:"slash-help-cmd",children:["/",m.name]}),e.jsx("span",{className:`slash-source ${m.source}`,children:b[m.source]}),e.jsxs("span",{className:"slash-help-desc",children:[B(m),m.argumentHint&&e.jsx("span",{className:"slash-hint",children:_(m)})]})]},m.name))})]})}),e.jsxs("div",{className:"inputbox",children:[e.jsx("input",{ref:pe,type:"file",multiple:!0,hidden:!0,onChange:m=>{D(m.target.files),m.target.value=""}}),e.jsxs("div",{className:"inputbox-row",children:[e.jsx("button",{type:"button",className:"btn attach-img",title:T("uploadFile"),disabled:!ee,onClick:()=>{var m;return(m=pe.current)==null?void 0:m.click()},children:e.jsx(es,{})}),e.jsx("textarea",{ref:ie,value:C,rows:1,placeholder:T(ee?a?"placeholderStreaming":"placeholderIdle":"placeholderConnecting"),disabled:!ee,onChange:m=>{x(m.target.value),U(m.target.value)},onKeyDown:ae,onPaste:Z}),g()]}),e.jsxs("div",{className:"input-tools",children:[e.jsx("div",{className:"input-tools-left",children:e.jsx(qs,{state:i,models:n,modelsLoading:o,send:d,onManageModels:$,compact:!0})}),e.jsxs("div",{className:"input-tools-right",children:[e.jsx("button",{type:"button",className:"btn attach-img",title:T("uploadFile"),disabled:!ee,onClick:()=>{var m;return(m=pe.current)==null?void 0:m.click()},children:e.jsx(es,{})}),g()]})]})]})]})}),ar=r.memo(function({goal:s,models:a,modelsLoading:l,activeConversationId:c,send:i}){var Y,M,Q,O,L,G;const n=me(),o=!s.conversationId||s.conversationId===c,d=s.goal!==null&&o,[u,p]=r.useState(""),[f,v]=r.useState(s.reviewModel??""),[w,E]=r.useState(s.maxRounds),[I,N]=r.useState(s.locked),[$,T]=r.useState(!1),[R,B]=r.useState(!1),[_,C]=r.useState(!0);r.useEffect(()=>{v(s.reviewModel??""),E(s.maxRounds||0),N(s.locked)},[s.goal,s.reviewModel,s.maxRounds,s.locked]),r.useEffect(()=>{$&&a.length===0&&!R&&!l&&(B(!0),i({type:"list_models"}))},[$,a.length,R,l,i]),r.useEffect(()=>{a.length>0&&B(!1)},[a.length]);const x=()=>{var W;return f?((W=a.find(ie=>ie.id===f))==null?void 0:W.name)??f:n("goalBarUseMainModel")},j=()=>{const W=u.trim();W&&(i({type:"set_goal",goal:W,...f?{reviewModel:f}:{},maxRounds:w,locked:I}),p(""),C(!1))},h=()=>{const W=u.trim();W&&(i({type:"start_goal_wizard",text:W,...f?{wizardModel:f}:{},maxRounds:w,locked:I}),p(""),C(!1))},S=(((Y=s.wizard)==null?void 0:Y.active)??!1)&&o;return S?e.jsx("div",{className:`goalbar goalbar-active ${S?"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:((M=s.wizard)==null?void 0:M.draft)??"",children:[n("goalWizardRunning"),": ",(Q=s.wizard)==null?void 0:Q.draft]}),e.jsxs("span",{className:"goalbar-chip reviewing",children:[n("goalBarRound",{n:(((O=s.wizard)==null?void 0:O.step)??0)+1})," ","/ ",((L=s.wizard)==null?void 0:L.maxSteps)??6]}),e.jsx("span",{className:"goalbar-detail",children:((G=s.wizard)==null?void 0:G.status)||n("goalBarReviewing")}),e.jsx("button",{type:"button",className:"goalbar-x",title:n("goalBarClear"),onClick:()=>{i({type:"clear_goal"}),C(!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"}),C(!0)},children:e.jsx(we,{})})]})}):_?e.jsx("div",{className:"goalbar goalbar-collapsed",children:e.jsxs("button",{type:"button",className:"goalbar-hint",title:n("goalBarPlaceholder"),onClick:()=>C(!1),children:[e.jsx(Zt,{})," ",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(Zt,{})}),e.jsx("input",{className:"goalbar-input",value:u,placeholder:n("goalBarPlaceholder"),onChange:W=>p(W.target.value),onKeyDown:W=>{W.key==="Enter"&&j()}}),e.jsx("button",{type:"button",className:"goalbar-btn",disabled:!u.trim(),onClick:j,children:n("goalBarSet")}),e.jsxs("button",{type:"button",className:"goalbar-btn wizard",disabled:!u.trim(),title:n("goalWizardTip"),onClick:h,children:["🔍 ",n("goalWizardBtn")]}),e.jsx("button",{type:"button",className:"goalbar-icon-btn",title:n(I?"goalBarLocked":"goalBarUnlocked"),onClick:()=>N(W=>(i({type:"set_goal_prefs",locked:!W}),!W)),children:I?e.jsx(ia,{}):e.jsx(Xn,{})}),e.jsx("button",{type:"button",className:"goalbar-icon-btn",title:n("goalBarClear"),onClick:()=>C(!0),children:e.jsx(ft,{})})]}),e.jsxs("div",{className:"goalbar-opts",children:[e.jsxs(qe,{trigger:e.jsxs("span",{className:"goalbar-opt",children:[n("goalBarReviewModel"),": ",e.jsx("b",{children:x()})]}),open:$,onOpenChange:T,direction:"up",children:[e.jsx("div",{className:"dd-header",children:n("goalBarReviewModel")}),(R||l)&&e.jsx("div",{className:"dd-loading",children:n("loading")}),a.length===0&&!R&&!l&&e.jsx("div",{className:"dd-loading",children:n("noModels")}),e.jsx(Me,{active:f==="",onClick:()=>{v(""),T(!1),i({type:"set_goal_prefs",reviewModel:""})},children:n("goalBarUseMainModel")}),a.map(W=>e.jsx(Me,{active:f===W.id,onClick:()=>{v(W.id),T(!1),i({type:"set_goal_prefs",reviewModel:W.id})},children:e.jsxs("span",{className:"dd-model-cell",children:[e.jsx("span",{className:"dd-model-name",children:W.name}),e.jsx("span",{className:"dd-model-meta",children:e.jsx("span",{className:"dd-model-provider",children:W.provider})})]})},W.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:W=>{const ie=parseInt(W.target.value,10);if(Number.isNaN(ie)||ie<0){E(0);return}E(ie)},onBlur:()=>i({type:"set_goal_prefs",maxRounds:w}),onKeyDown:W=>{W.key==="Enter"&&(i({type:"set_goal_prefs",maxRounds:w}),W.target.blur())}})]}),e.jsx("span",{className:"goalbar-lock-hint",children:n(I?"goalBarLocked":"goalBarUnlocked")})]})]})});function ir({chat:t,send:s}){const a=me(),l=t.state,[c,i]=r.useState(!1),[n,o]=r.useState(""),[d,u]=r.useState(0),p=r.useRef(null),f=t.pathCompletions;if(r.useEffect(()=>{if(!c)return;const j=setTimeout(()=>{s({type:"complete_path",path:n})},150);return()=>clearTimeout(j)},[n,c,s]),r.useEffect(()=>u(0),[f]),r.useEffect(()=>{const j=document.querySelector(`.status-completions .pc-item[data-idx="${d}"]`);j==null||j.scrollIntoView({block:"nearest"})},[d]),!l)return null;const v=l.stats,w=t.ready?"ok":"busy",E=t.ready?a("connected"):a("connecting"),I=v.contextUsage,N=I.tokens!==null&&I.percent!==null?`${Cs(I.tokens)} / ${Cs(I.contextWindow)}`:"—",$=I.percent??null,T=$===null?"":$>=80?"warn":$>=50?"mid":"ok",R=l.queue.steering.length+l.queue.followUp.length,B=()=>{o(l.cwd),i(!0)},_=(j,h)=>{var Y;const S=j.includes("\\")?"\\":"/";o(h?`${j}${S}`:j),u(0),(Y=p.current)==null||Y.focus()},C=j=>{const h=j.trim();h&&h!==l.cwd&&s({type:"set_cwd",path:h}),i(!1)},x=j=>{if(j.key==="ArrowDown")j.preventDefault(),u(h=>Math.min(h+1,f.length-1));else if(j.key==="ArrowUp")j.preventDefault(),u(h=>Math.max(h-1,0));else if(j.key==="Tab"&&f.length>0){j.preventDefault();const h=f[Math.min(d,f.length-1)];_(h.path,h.type==="dir")}else if(j.key==="Enter"&&!j.nativeEvent.isComposing){const h=n.trim();if(h.endsWith("/")||h.endsWith("\\"))C(h);else if(f.some(S=>S.path===h))C(h);else if(f.length>0&&f[d]){j.preventDefault();const S=f[d];_(S.path,S.type==="dir")}else C(h)}else j.key==="Escape"&&(f.length>0?(j.stopPropagation(),s({type:"complete_path",path:""})):i(!1))};return e.jsxs("footer",{className:"statusbar",children:[e.jsx("span",{className:`status-dot ${w}`,title:E}),e.jsx("span",{className:"status-item",children:E}),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 ${T}`,children:$!==null&&e.jsx("span",{className:"ctx-bar-fill",style:{width:`${Math.min($,100)}%`}})}),N]}),e.jsx("span",{className:"status-sep",children:"·"}),e.jsxs("span",{className:"status-item",title:a("cumulativeCost"),children:["$",rr(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(j=>j.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"),R>0&&e.jsxs("span",{className:"status-queue",children:["⏳ ",R," ",a("queued")]})]})]}),c?e.jsxs("div",{className:"status-cwd-wrap",children:[e.jsx("input",{ref:p,className:"status-cwd-input",value:n,autoFocus:!0,placeholder:a("enterPath"),onChange:j=>o(j.target.value),onKeyDown:x,onBlur:()=>i(!1)}),f.length>0&&e.jsx("ul",{className:"status-completions",onMouseDown:j=>j.preventDefault(),children:f.map((j,h)=>e.jsx("li",{children:e.jsxs("button",{type:"button","data-idx":h,className:`pc-item ${h===d?"sel":""}`,onMouseEnter:()=>u(h),onClick:()=>_(j.path,j.type==="dir"),children:[e.jsx("span",{className:"pc-icon",children:j.type==="dir"?e.jsx(Re,{}):e.jsx($s,{})}),e.jsxs("span",{className:"pc-body",children:[e.jsx("span",{className:"pc-name",children:j.name}),e.jsx("span",{className:"pc-path",children:j.path})]})]})},j.path))})]}):e.jsxs("button",{type:"button",className:"status-item status-cwd",title:a("cwdTip",{path:l.cwd}),onClick:B,children:["📁 ",l.cwd]})]})}function Cs(t){return t>=1e3?`${(t/1e3).toFixed(1).replace(/\.0$/,"")}K`:String(t)}function rr(t){return t<=0?"0":t<1e-4?"<0.0001":t.toFixed(4).replace(/\.?0+$/,"")}function lr({dialog:t,send:s}){const a=me(),[l,c]=r.useState(""),[i,n]=r.useState(0),o=p=>{s({type:"dialog_response",id:t.id,value:p})};r.useEffect(()=>{c(""),n(0);const p=f=>{f.key==="Escape"&&o(null)};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[t.id]);const d=Array.isArray(t.args[0])?t.args[0]:[],u=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((p,f)=>e.jsx("button",{type:"button",className:`dialog-option ${f===i?"sel":""}`,onMouseEnter:()=>n(f),onClick:()=>o(p),children:p},f)),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:u}),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:u||a("inputPlaceholder"),autoFocus:!0,onChange:p=>c(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.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 or(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 cr({chat:t,send:s,terminal:a,active:l,onSwitchToTerminal:c}){var ce,le;const i=me(),[n,o]=r.useState(null),[d,u]=r.useState([]),[p,f]=r.useState(""),[v,w]=r.useState(new Map),[E,I]=r.useState("changes"),[N,$]=r.useState([]),[T,R]=r.useState(null),[B,_]=r.useState(""),[C,x]=r.useState(!1),[j,h]=r.useState(null),[S,Y]=r.useState(null),[M,Q]=r.useState(!1),[O,L]=r.useState(!1),[G,W]=r.useState(!1),[ie,pe]=r.useState(null),[K,b]=r.useState(!1),[U,te]=r.useState(""),ue=r.useRef(0),D=r.useRef(-1),Z=r.useRef(-1),ee=r.useRef(-1),X=r.useRef(-1),de=r.useRef(void 0),ae=r.useRef(null),g=r.useRef([]),m=r.useCallback(y=>{if(y.reqId===D.current){if(D.current=-1,L(!1),pe(null),!y.ok){pe(y.error??"查询失败");return}if(y.notRepo){b(!0),o(null),u([]),w(new Map),$([]),R(null),_(""),Y(null);return}b(!1);const V={branch:y.branch??"",detached:!!y.detached,upstream:y.upstream??null,ahead:y.ahead??0,behind:y.behind??0,upstreamGone:!!y.upstreamGone,files:(y.files??[]).map(ge=>({...ge}))},J=(y.branches??[]).map(ge=>({...ge})),ve=new Map;for(const[ge,Ne]of Object.entries(y.stats??{}))ve.set(ge,{add:Ne[0],del:Ne[1]});o(V),u(J),w(ve),f(ge=>{var Ne;return V.detached?ge||"":V.branch&&J.some(Se=>Se.name===V.branch)?V.branch:ge&&J.some(Se=>Se.name===ge)?ge:((Ne=J[0])==null?void 0:Ne.name)??""}),Y(ge=>ge&&!V.files.some(Ne=>Ne.path===ge.file.path)?null:ge)}else if(y.reqId===Z.current){if(Z.current=-1,Q(!1),!y.ok){pe(y.error??"查询失败");return}const V=ae.current;if(!V)return;Y({file:V,staged:y.stagedText??"",worktree:y.worktreeText??"",untracked:!1})}else if(y.reqId===X.current){if(X.current=-1,W(!1),!y.ok){pe(y.error??"查询失败");return}$((y.history??[]).map(V=>({...V})))}else if(y.reqId===ee.current){if(ee.current=-1,x(!1),!y.ok){pe(y.error??"查询失败");return}_(y.text??"")}},[]);r.useEffect(()=>{const y=t.scmData;y&&y.type==="scm_data"&&m(y)},[t.scmData,m]);const H=r.useCallback((y,V)=>{if(!t.ready||t.status!=="open")return!1;const J=++ue.current;return s({...y,reqId:J})?(V.current=J,!0):(ue.current-=1,!1)},[t.ready,t.status,s]),re=r.useCallback((y=!1,V=!1)=>{var J;!t.ready||t.status!=="open"||(J=t.state)!=null&&J.cwd&&(de.current!==void 0&&de.current!==t.state.cwd&&(o(null),u([]),w(new Map),$([]),W(!1),X.current=-1,R(null),_(""),Y(null),h(null)),de.current=t.state.cwd,pe(null),H({type:"scm_status"},D)&&(V||L(!0)))},[t.ready,(ce=t.state)==null?void 0:ce.cwd,t.status,H]),oe=r.useCallback(y=>{if(h(y),R(null),ae.current=y,y.x==="?"&&y.y==="?"){Y({file:y,staged:"",worktree:"",untracked:!0});return}Q(!0),pe(null),H({type:"scm_filediff",path:y.path},Z)||Q(!1)},[H]),q=r.useCallback(y=>{R(y),h(null),Y(null),_(""),x(!0),pe(null),H({type:"scm_commit",hash:y.hash},ee)||x(!1)},[H]),se=r.useCallback((y,V)=>{var ge,Ne;if(!t.ready)return;const J={name:y,command:V,cwd:"${pwd}"},ve=t.terminals.find(Se=>Se.title===y);if(ve)a.restart(ve.id),s({type:"run_command",terminalId:ve.id,conversationId:ve.conversationId,command:J,cols:80,rows:24});else{const Se=Ge();a.create({id:Se,conversationId:t.activeConversationId||((ge=t.state)==null?void 0:ge.conversationId)||"",title:y,cwd:((Ne=t.state)==null?void 0:Ne.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:J})}c()},[t.ready,(le=t.state)==null?void 0:le.cwd,t.terminals,c,s,a]),xe=r.useCallback(()=>{const y=U.trim();if(!y||K)return;const V=y.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/`/g,"\\`").replace(/\$/g,"\\$");se("git commit",`git add -A && git commit -m "${V}"`),te("")},[U,K,se]),ke=y=>`'${y.replace(/'/g,"'\\''")}`,he=r.useCallback(y=>{K||se("git add",`git add -- ${ke(y.path)}`)},[K,se]),_e=r.useCallback(y=>{K||se("git reset",`git reset HEAD -- ${ke(y.path)}`)},[K,se]),Qe=r.useCallback(()=>{if(!p||K)return;const y=d.find(V=>V.name===p);if(y!=null&&y.remote&&typeof y.remote=="string"){const V=p.slice(y.remote.length+1);se("git checkout",`git checkout -b ${V} ${p} || git checkout ${p}`)}else se("git checkout",`git checkout ${p}`)},[p,d,K,se]),De=r.useCallback(()=>se("git push","git push"),[se]),Ae=r.useCallback(()=>se("git pull","git pull"),[se]),Te=r.useCallback(()=>{H({type:"scm_history"},X)||(X.current=-1)},[H]);r.useEffect(()=>{l&&re()},[l,re]),r.useEffect(()=>{E==="history"&&n&&Te()},[E,n,Te]),r.useEffect(()=>{t.scmDirty>0&&l&&re(!1,!0)},[t.scmDirty]),r.useEffect(()=>{if(!l||!t.ready||t.status!=="open")return;const y=setInterval(()=>{document.visibilityState!=="hidden"&&re(!1,!0)},3e4);return()=>clearInterval(y)},[l,t.ready,t.status,re]),r.useEffect(()=>{const y=g.current;if(g.current=t.terminals,!l)return;t.terminals.some(J=>{var ge;return J.running!==!1?!1:((ge=y.find(Ne=>Ne.id===J.id))==null?void 0:ge.running)===!0&&/^git /.test(J.title)})&&t.ready&&t.status==="open"&&(re(!1,!0),E==="history"&&n&&Te())},[t.terminals,l,t.ready,t.status,re,E,n,Te]);const k={staged:i("scmStaged"),unstaged:i("scmUnstaged"),untracked:i("scmUntracked"),both:i("scmStagedUnstaged")},F=y=>{const V=y.split(`
|
|
22
|
-
`);return e.jsx("pre",{className:"scm-diff-pre",children:V.map((J,ve)=>{let ge="";return J.startsWith("diff --git")||J.startsWith("index ")||J.startsWith("new file")||J.startsWith("deleted file")||J.startsWith("old mode")||J.startsWith("new mode")||J.startsWith("similarity index")||J.startsWith("rename ")||J.startsWith("copy ")||J.startsWith("Binary files")||J.startsWith("---")||J.startsWith("+++")?ge="hdr":J.startsWith("@@")?ge="hunk":J.startsWith("+")?ge="add":J.startsWith("-")&&(ge="del"),e.jsx("div",{className:`scm-diff-line ${ge}`,children:J||" "},ve)})})};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(it,{}),i("scmTitle")]}),e.jsxs("div",{className:"scm-view-tabs",role:"tablist",children:[e.jsx("button",{type:"button",role:"tab","aria-selected":E==="changes",className:E==="changes"?"active":"",onClick:()=>{I("changes"),pe(null)},children:i("scmChanges")}),e.jsx("button",{type:"button",role:"tab","aria-selected":E==="history",className:E==="history"?"active":"",onClick:()=>{I("history"),pe(null)},children:i("scmHistory")})]}),e.jsx("button",{type:"button",className:"panel-refresh",title:i("scmRefreshTip"),disabled:O,onClick:()=>re(!0),children:e.jsx(gt,{className:O?"scm-spin":""})})]}),e.jsxs("div",{className:"scm-row",children:[e.jsxs("span",{className:"scm-branch-current",title:i("scmCurrentBranch"),children:[e.jsx(it,{}),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:p,disabled:K||d.length===0,title:i("scmSwitchBranch"),onChange:y=>f(y.target.value),children:[e.jsx("option",{value:"",disabled:!0,children:i("scmSelectBranch")}),d.filter(y=>!y.remote).map(y=>e.jsx("option",{value:y.name,children:y.current?`* ${y.name}`:y.name},y.name)),d.some(y=>y.remote)&&e.jsx("optgroup",{label:i("scmRemoteBranches"),children:d.filter(y=>y.remote).map(y=>e.jsx("option",{value:y.name,children:y.name},y.name))})]}),e.jsxs("button",{type:"button",className:"btn",disabled:!p||p===(n==null?void 0:n.branch)||K,title:i("scmSwitchBranchTip",{branch:p}),onClick:Qe,children:[e.jsx(it,{}),i("scmSwitch")]}),e.jsxs("button",{type:"button",className:"btn",disabled:!n||n.detached||K,title:i("scmPushTip"),onClick:De,children:[e.jsx(_s,{}),i("scmPush")]}),e.jsxs("button",{type:"button",className:"btn",disabled:!n||n.detached||K,title:i("scmPullTip"),onClick:Ae,children:[e.jsx(As,{}),i("scmPull")]}),e.jsx("input",{className:"scm-commit-input",value:U,placeholder:i("scmCommitPlaceholder"),disabled:K,onChange:y=>te(y.target.value),onKeyDown:y=>{y.key==="Enter"&&!y.nativeEvent.isComposing&&xe()}}),e.jsxs("button",{type:"button",className:"btn primary",disabled:!U.trim()||K,title:i("scmCommitTip"),onClick:xe,children:[e.jsx(Ve,{}),i("scmCommit")]})]})]}),e.jsxs("div",{className:"scm-body",children:[E==="history"?e.jsxs("div",{className:"scm-history",children:[e.jsxs("div",{className:"scm-files-header",children:[e.jsx("span",{children:i("scmHistory")}),N.length>0&&e.jsx("span",{className:"scm-files-count",children:N.length})]}),e.jsx("div",{className:"scm-history-list",children:K?e.jsx("div",{className:"scm-empty",children:i("scmNotGitRepo")}):!n||G?e.jsx("div",{className:"scm-empty",children:t.status==="open"?i("scmLoading"):i("scmConnecting")}):N.length===0?e.jsx("div",{className:"scm-empty",children:i("scmNoHistory")}):N.map(y=>e.jsxs("button",{type:"button",className:`scm-commit ${(T==null?void 0:T.hash)===y.hash?"active":""}`,onClick:()=>q(y),title:y.hash,children:[e.jsx("span",{className:"scm-commit-graph","aria-hidden":"true",children:y.graph||"* "}),e.jsxs("span",{className:"scm-commit-info",children:[e.jsx("span",{className:"scm-commit-subject",children:y.subject}),e.jsxs("span",{className:"scm-commit-meta",children:[y.shortHash," · ",y.author," · ",y.date]}),y.decorations&&e.jsx("span",{className:"scm-commit-refs",children:y.decorations})]})]},y.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:K?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(y=>{const V=or(y),J=v.get(y.path);return e.jsxs("div",{className:`scm-file ${(j==null?void 0:j.path)===y.path?"active":""}`,title:k[V],onClick:()=>oe(y),children:[e.jsx("span",{className:`scm-file-xy ${V==="untracked"?"q":"x"}`,children:y.x!==" "?y.x:" "}),e.jsx("span",{className:`scm-file-xy ${V==="untracked"?"q":"y"}`,children:y.y!==" "?y.y:" "}),e.jsx("span",{className:"scm-file-path",children:y.path}),J&&(J.add>0||J.del>0)&&e.jsxs("span",{className:"scm-file-stat",children:[J.add>0&&e.jsxs("span",{className:"add",children:["+",J.add]}),J.del>0&&e.jsxs("span",{className:"del",children:["-",J.del]})]}),e.jsxs("span",{className:"scm-file-actions",children:[(y.y!==" "||V==="untracked")&&e.jsx("button",{type:"button",className:"scm-act",title:i("scmStageTip",{path:y.path}),onClick:ve=>{ve.stopPropagation(),he(y)},children:"+"}),V==="staged"||V==="both"?e.jsx("button",{type:"button",className:"scm-act",title:i("scmUnstageTip",{path:y.path}),onClick:ve=>{ve.stopPropagation(),_e(y)},children:"−"}):null]})]},y.path)}):e.jsx("div",{className:"scm-empty",children:t.status==="open"?i("scmLoading"):i("scmConnecting")})})]}),e.jsxs("div",{className:"scm-diff",children:[e.jsxs("div",{className:"scm-diff-header",children:[e.jsx("span",{children:E==="history"?T?`${T.shortHash} ${T.subject}`:i("scmCommitDetail"):j?j.path:i("scmDiff")}),(E==="history"?C:M)&&e.jsx("span",{className:"scm-diff-loading",children:i("scmLoading")})]}),e.jsx("div",{className:"scm-diff-body",children:E==="history"?e.jsxs(e.Fragment,{children:[ie&&e.jsx("div",{className:"scm-error",children:ie}),!T&&!ie&&e.jsx("div",{className:"scm-empty",children:i("scmSelectCommitHint")}),T&&C&&!ie&&e.jsx("div",{className:"scm-empty",children:i("scmLoading")}),T&&!C&&!ie&&B?F(B):null]}):e.jsxs(e.Fragment,{children:[ie&&e.jsx("div",{className:"scm-error",children:ie}),!j&&!ie&&e.jsx("div",{className:"scm-empty",children:i("scmSelectFileHint")}),j&&!S&&!ie&&e.jsx("div",{className:"scm-empty",children:i("scmLoading")}),j&&S&&S.untracked&&e.jsx("div",{className:"scm-empty",children:i("scmUntrackedNote")}),j&&S&&!S.untracked&&e.jsxs(e.Fragment,{children:[S.staged&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"scm-diff-section",children:i("scmStaged")}),F(S.staged)]}),S.worktree&&e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"scm-diff-section",children:i("scmUnstaged")}),F(S.worktree)]}),!S.staged&&!S.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 dr({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,Fa(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 ur({send:t,piConfigured:s,piAgentInstalled:a,providers:l,installResult:c,onClose:i}){const n=me(),[o,d]=r.useState(!1),[u,p]=r.useState(""),[f,v]=r.useState(""),[w,E]=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 B;!u&&l.length>0&&p(((B=l.find(_=>!_.configured))==null?void 0:B.id)??l[0].id)},[l,u]);const I=()=>{o||(d(!0),t({type:"install_pi_agent"}))},N=()=>{!f.trim()||w||(E(!0),t({type:"set_provider_api_key",provider:u.trim(),apiKey:f.trim()}),setTimeout(()=>E(!1),3e3))},$=()=>{t({type:"get_state"}),t({type:"list_providers"})},T=l.find(B=>B.id===u),R=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(et,{className:"modal-head-icon"}),e.jsx("h2",{children:n("setupTitle")})]}),e.jsx("p",{className:"modal-desc",children:n("setupDesc")}),R?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:I,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:u,onChange:B=>p(B.target.value),children:[l.length===0&&e.jsx("option",{value:"",children:n("loading")}),l.map(B=>e.jsxs("option",{value:B.id,children:[B.name,"(",B.id,")",B.configured?` · ${n("configured")}`:""]},B.id))]}),(T==null?void 0:T.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:f,onChange:B=>v(B.target.value),placeholder:"sk-…"})]}),e.jsxs("div",{className:"setup-actions",children:[e.jsx("button",{type:"button",className:"btn primary",disabled:!f.trim()||w||!u,onClick:N,children:n(w?"saving":"saveAndStart")}),e.jsxs("button",{type:"button",className:"btn",onClick:$,children:[e.jsx(gt,{})," ",n("recheck")]})]})]}):e.jsxs("div",{className:"setup-actions",children:[e.jsx("button",{type:"button",className:"btn primary",disabled:o,onClick:I,children:n(o?"installing":"autoInstall")}),e.jsx("button",{type:"button",className:"btn",onClick:i,children:n("skip")})]})]})})}const mr=["openai-completions","openai-responses","anthropic-messages","google-generative-ai"],At=()=>({id:"",name:"",reasoning:!1,input:"text",contextWindow:"",maxTokens:""}),pr=()=>({providerId:"",name:"",api:"openai-completions",baseUrl:"",apiKey:"",authHeader:!0,models:[At()]});function Ss(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:[At()]).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 hr({send:t,providers:s,providerStatus:a,fetchModelsResult:l,refreshProviderResult:c,cloneProviderResult:i,onClose:n}){const o=me(),[d,u]=r.useState(null),[p,f]=r.useState({}),[v,w]=r.useState(null),[E,I]=r.useState({}),[N,$]=r.useState(!1),[T,R]=r.useState(0),[B,_]=r.useState(null),C=r.useRef(0),[x,j]=r.useState({});r.useRef(0);const h=r.useRef(0),[S,Y]=r.useState(null),M=r.useRef(0),Q=r.useRef(0);r.useEffect(()=>{t({type:"list_models_config"}),t({type:"list_providers"})},[t]);const O=()=>{if(!d)return;const b=d.baseUrl.trim();if(!b){_({ok:!1,text:o("fetchModelsNeedBaseUrl")});return}if(N)return;$(!0),_(null);const U=T+1;R(U),t({type:"fetch_models",reqId:U,baseUrl:b,apiKey:d.apiKey.trim()||void 0,authHeader:d.authHeader,api:d.api})};r.useEffect(()=>{var b;if(!(!l||l.reqId===C.current))if(C.current=l.reqId,$(!1),l.ok&&((b=l.models)!=null&&b.length)){const U=l.models;u(te=>{if(!te)return te;const ue=te.models.map(X=>{var g;if(!X.id.trim())return X;const de=U.find(m=>m.id===X.id.trim());if(!de)return X;const ae={...X};return!ae.name&&de.name&&(ae.name=de.name),!ae.contextWindow&&de.contextWindow&&(ae.contextWindow=String(de.contextWindow)),!ae.maxTokens&&de.maxTokens&&(ae.maxTokens=String(de.maxTokens)),ae.input==="text"&&((g=de.input)!=null&&g.includes("image"))&&(ae.input="text-image"),!ae.reasoning&&de.reasoning&&(ae.reasoning=!0),ae}),D=new Set(ue.map(X=>X.id.trim()).filter(Boolean)),Z=U.filter(X=>!D.has(X.id)).map(X=>{var de;return{id:X.id,name:X.name??"",reasoning:X.reasoning??!1,input:(de=X.input)!=null&&de.includes("image")?"text-image":"text",contextWindow:X.contextWindow?String(X.contextWindow):"",maxTokens:X.maxTokens?String(X.maxTokens):""}}),ee=[...ue,...Z];return ee.some(X=>X.id.trim())?{...te,models:ee.filter(X=>X.id.trim())}:te}),_({ok:!0,text:o("fetchModelsOk",{n:U.length})})}else _({ok:!1,text:l.error||o("fetchModelsEmpty")})},[l]);const L=b=>{const U=(p[b.id]??"").trim();!U||v||(w(b.id),t({type:"set_provider_api_key",provider:b.id,apiKey:U}),setTimeout(()=>{w(null),f(te=>({...te,[b.id]:""})),I(te=>({...te,[b.id]:!1})),t({type:"list_providers"})},1500))},G=()=>{if(!d)return;const b=d.providerId.trim(),U=d.models.filter(ue=>ue.id.trim()).map(ue=>({id:ue.id.trim(),name:ue.name.trim()||void 0,reasoning:ue.reasoning||void 0,input:ue.input==="text-image"?["text","image"]:void 0,contextWindow:ue.contextWindow?Number(ue.contextWindow):void 0,maxTokens:ue.maxTokens?Number(ue.maxTokens):void 0})),te={providerId:b,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:U};t({type:"save_model_config",providerId:b,config:te}),n()};r.useEffect(()=>{!c||c.reqId===h.current||(h.current=c.reqId,j({}))},[c]);const W=b=>{if(S)return;Y(b.id);const U=++M.current+Date.now();t({type:"clone_provider",provider:b.id,reqId:U})};r.useEffect(()=>{!i||i.reqId===Q.current||(Q.current=i.reqId,Y(null),i.ok&&i.config&&u(Ss({...i.config,apiKey:""})))},[i]);const ie=b=>{window.confirm(o("clearKeyConfirm",{id:b}))&&t({type:"clear_provider_api_key",provider:b})},pe=b=>{window.confirm(o("deleteProviderConfirm",{id:b.providerId,n:b.models.length}))&&t({type:"delete_model_config",providerId:b.providerId})},K=(b,U)=>{d&&u({...d,models:d.models.map((te,ue)=>ue===b?{...te,...U}:te)})};return e.jsx("div",{className:"modal-backdrop",onClick:n,children:e.jsxs("div",{className:"modal model-modal",onClick:b=>b.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(b=>b.providerId===d.providerId),onChange:b=>u({...d,providerId:b.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:b=>u({...d,name:b.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:b=>u({...d,api:b.target.value}),children:mr.map(b=>e.jsx("option",{value:b,children:b},b))})]}),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:b=>u({...d,baseUrl:b.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:b=>u({...d,apiKey:b.target.value}),placeholder:o("apiKeyHint")})]}),e.jsxs("label",{className:"field check",children:[e.jsx("input",{type:"checkbox",checked:d.authHeader,onChange:b=>u({...d,authHeader:b.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:[B&&e.jsx("span",{className:`fetch-msg ${B.ok?"ok":"err"}`,title:B.text,children:B.text}),e.jsxs("button",{type:"button",className:"btn sm",disabled:N||!d.baseUrl.trim(),title:o("fetchModelsHint"),onClick:O,children:[e.jsx(Fs,{})," ",o(N?"fetchingModels":"fetchModels")]})]})]}),d.models.map((b,U)=>e.jsxs("div",{className:"model-row",children:[e.jsx("input",{type:"text",value:b.id,onChange:te=>K(U,{id:te.target.value}),placeholder:o("modelIdReq")}),e.jsx("input",{type:"text",value:b.name,onChange:te=>K(U,{name:te.target.value}),placeholder:o("displayName")}),e.jsxs("select",{value:b.input,onChange:te=>K(U,{input:te.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:b.reasoning,onChange:te=>K(U,{reasoning:te.target.checked})}),e.jsx("span",{children:o("reasoning")})]}),e.jsx("input",{type:"number",value:b.contextWindow,onChange:te=>K(U,{contextWindow:te.target.value}),placeholder:o("contextWindow"),title:"contextWindow"}),e.jsx("input",{type:"number",value:b.maxTokens,onChange:te=>K(U,{maxTokens:te.target.value}),placeholder:o("maxOutput"),title:"maxTokens"}),e.jsx("button",{type:"button",className:"iconbtn danger",title:o("removeModel"),onClick:()=>u({...d,models:d.models.filter((te,ue)=>ue!==U)}),children:e.jsx(Be,{})})]},U)),e.jsxs("button",{type:"button",className:"btn",onClick:()=>u({...d,models:[...d.models,At()]}),children:[e.jsx(ze,{})," ",o("addModel")]}),e.jsxs("div",{className:"modal-actions",children:[e.jsx("button",{type:"button",className:"btn",onClick:()=>u(null),children:o("cancel")}),e.jsx("button",{type:"button",className:"btn primary",disabled:!d.providerId.trim()||!d.models.some(b=>b.id.trim()),onClick:G,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(b=>e.jsxs("div",{className:"provider-row",children:[e.jsxs("div",{className:"provider-info",children:[e.jsx("span",{className:"provider-name",children:b.name}),e.jsxs("span",{className:"provider-sub",children:[b.id,b.configured&&e.jsx("span",{className:"auth-badge",children:o("configuredBadge")}),b.source&&!b.configured&&e.jsx("span",{className:"auth-badge dim",children:b.source})]})]}),e.jsxs("div",{className:"provider-actions",children:[b.configured&&!E[b.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:()=>I(U=>({...U,[b.id]:!0})),children:[e.jsx(Tt,{})," ",o("replaceKey")]}),b.source==="stored"&&e.jsxs("button",{type:"button",className:"btn sm danger",title:o("clearKeyTitle"),onClick:()=>ie(b.id),children:[e.jsx(Be,{})," ",o("clearKey")]})]}):e.jsxs(e.Fragment,{children:[e.jsx("input",{type:"password",className:"key-input",placeholder:o("pasteKey"),value:p[b.id]??"",onChange:U=>f(te=>({...te,[b.id]:U.target.value}))}),e.jsxs("button",{type:"button",className:"btn primary sm",disabled:!(p[b.id]??"").trim()||v===b.id,onClick:()=>L(b),children:[e.jsx(ra,{})," ",v===b.id?o("savingKey"):o("saveKey")]})]}),e.jsxs("button",{type:"button",className:"btn sm",disabled:S!==null,title:o("cloneProviderTitle"),onClick:()=>W(b),children:[e.jsx(Rt,{})," ",S===b.id?o("cloning"):o("cloneProvider")]})]})]},b.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(b=>e.jsxs("div",{className:"provider-row",children:[e.jsxs("div",{className:"provider-info",children:[e.jsx("span",{className:"provider-name",children:b.providerId}),e.jsxs("span",{className:"provider-sub",children:[b.api??"—",b.baseUrl?` · ${b.baseUrl}`:"",b.models.length>0&&` · ${o("modelsCount",{n:b.models.length})}`]})]}),e.jsxs("div",{className:"provider-actions",children:[e.jsx("button",{type:"button",className:"iconbtn",title:o("edit"),onClick:()=>u(Ss(b)),children:e.jsx(Tt,{})}),e.jsx("button",{type:"button",className:"iconbtn danger",title:o("delete"),onClick:()=>pe(b),children:e.jsx(Be,{})})]})]},b.providerId))}),e.jsx("div",{className:"modal-actions",children:e.jsxs("button",{type:"button",className:"btn primary",onClick:()=>u(pr()),children:[e.jsx(ze,{})," ",o("addProvider")]})})]})]})})}function gr({plugin:t,send:s}){const a=me(),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(E=>({...E,[v]:w})),u=l.some(v=>{var w;return c[v.key]!==((w=t.settingsValues)==null?void 0:w[v.key])}),p=()=>{o(!0),s({type:"plugin_settings",pluginId:t.id,values:c}),setTimeout(()=>o(!1),800)},f=()=>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:!u||n,onClick:p,children:a(n?"pluginSettingsSaving":"pluginSettingsSave")}),e.jsx("button",{type:"button",className:"btn plugin-settings-reset",onClick:f,children:a("pluginSettingsReset")})]})]})}function rt({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=me();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(rt,{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 fr({chat:t,send:s,terminal:a,onSwitchToTerminal:l,onClose:c}){const i=me(),n=t.settings,[o,d]=r.useState("prompt"),u=r.useRef(null);r.useEffect(()=>{var g;(g=u.current)==null||g.scrollTo({top:0})},[o]);const[p,f]=r.useState(""),[v,w]=r.useState("append"),E=r.useRef(!1),[I,N]=r.useState(""),[$,T]=r.useState("append"),R=r.useRef(!1),[B,_]=r.useState(""),C=r.useRef(!1),[x,j]=r.useState(""),[h,S]=r.useState(!1),[Y,M]=r.useState(null),[Q,O]=r.useState(null);r.useEffect(()=>{n&&(w(n.promptMode),!E.current&&(f(v==="append"||n.customSystemPrompt?n.customSystemPrompt:n.defaultSystemPrompt||""),T(n.visionBridgePromptMode),!R.current&&(N($==="append"||n.visionBridgePrompt?n.visionBridgePrompt:n.visionBridgeDefaultPrompt||""),C.current||_(n.reviewPrompt))))},[n,v,$]);const[L,G]=r.useState(String((n==null?void 0:n.terminalBashIdleMs)??15e3));if(r.useEffect(()=>{G(String((n==null?void 0:n.terminalBashIdleMs)??15e3))},[n==null?void 0:n.terminalBashIdleMs]),!n)return null;const W=[{id:"prompt",icon:e.jsx(Bs,{}),label:i("settingsSystemPrompt")},{id:"terminal",icon:e.jsx(Ue,{}),label:i("settingsTerminalTools")},{id:"display",icon:e.jsx(Ke,{}),label:i("settingsMessageDisplay")},{id:"skills",icon:e.jsx(et,{}),label:i("settingsSkills"),count:n.skills.length},{id:"extensions",icon:e.jsx(ts,{}),label:i("settingsExtensions"),count:n.extensions.length},{id:"plugins",icon:e.jsx(ss,{}),label:i("settingsUiPlugins"),count:t.plugins.length},{id:"review",icon:e.jsx(at,{}),label:i("settingsReview"),count:n.reviewSkills.length},{id:"vision",icon:e.jsx(Ct,{}),label:i("settingsVisionBridge")},{id:"presets",icon:e.jsx(Yn,{}),label:i("settingsPresets"),count:n.presets.length}],ie=new Set(n.disabledSkills),pe=new Set(n.disabledExtensions),K=g=>s({type:"set_settings",...g}),b=g=>{const m=new Set(ie);m.has(g.name)?m.delete(g.name):m.add(g.name),K({disabledSkills:[...m]})},U=new Set(n.disabledPlugins??[]),te=g=>{const m=new Set(U);m.has(g.id)?m.delete(g.id):m.add(g.id),K({disabledPlugins:[...m]})},ue=g=>{const m=new Set(pe);m.has(g.id)?m.delete(g.id):m.add(g.id),K({disabledExtensions:[...m]})},D=(g,m)=>{var oe,q;const H={name:g,command:m,cwd:"${pwd}"},re=t.terminals.find(se=>se.title===g);re?(a.restart(re.id),s({type:"run_command",terminalId:re.id,conversationId:re.conversationId,command:H,cols:80,rows:24})):a.create({id:Ge(),conversationId:t.activeConversationId||((oe=t.state)==null?void 0:oe.conversationId)||"",title:g,cwd:((q=t.state)==null?void 0:q.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:H}),l(),c()},Z=g=>{M(null),D(`${i("uninstallTitle")} ${g}`,`pi remove npm:${g}`)},ee=g=>{O(null),D(`${i("uninstallTitle")} ${g}`,`pi-web-ui uninstall ${g}`)},X=(g,m)=>{D(`${i("pluginUpdate")} ${g}`,`pi-web-ui install ${m} --name ${g} --force`)},de=g=>{const m=new Set(n.reviewSkills.filter(H=>!H.enabled).map(H=>H.name));m.has(g.name)?m.delete(g.name):m.add(g.name),K({reviewDisabledSkills:[...m]})},ae=()=>{const g=v==="replace"&&n.defaultSystemPrompt&&p===n.defaultSystemPrompt?"":p;K({promptMode:v,customSystemPrompt:g})};return e.jsx("div",{className:"modal-backdrop",onClick:c,children:e.jsxs("div",{className:"modal settings-modal",onClick:g=>g.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(dt,{className:"modal-head-icon"}),e.jsx("h2",{children:i("settingsTitle")}),e.jsx(rt,{text:i("settingsDesc")})]}),e.jsxs("div",{className:"settings-layout",children:[e.jsx("nav",{className:"settings-rail","aria-label":i("settingsTitle"),children:W.map(g=>e.jsxs("button",{type:"button",className:`settings-tab${o===g.id?" active":""}`,"aria-current":o===g.id?"true":void 0,title:g.label,onClick:()=>d(g.id),children:[e.jsx("span",{className:"settings-tab-icon",children:g.icon}),e.jsx("span",{className:"settings-tab-label",children:g.label}),g.count!==void 0&&e.jsx("span",{className:"set-count",children:g.count})]},g.id))}),e.jsxs("div",{className:"modal-body",ref:u,children:[o==="prompt"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(at,{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:g=>{const m=g.target.value;w(m),K({promptMode:m})},children:[e.jsx("option",{value:"append",children:i("promptModeAppend")}),e.jsx("option",{value:"replace",children:i("promptModeReplace")})]}),e.jsx(rt,{text:i(v==="append"?"promptAppendHint":"promptReplaceHint")})]}),e.jsx("textarea",{className:"set-prompt-input",rows:6,placeholder:i("promptPlaceholder"),value:p,onFocus:()=>E.current=!0,onBlur:()=>{E.current=!1,ae()},onChange:g=>f(g.target.value)}),e.jsxs("button",{type:"button",className:"set-view-prompt-btn","aria-expanded":h,onClick:()=>S(g=>!g),children:[i("settingsViewPrompt")," ",h?"▴":"▾"]}),h&&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(pt,{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:()=>K({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:()=>K({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:L,onChange:g=>G(g.target.value),onBlur:()=>{const g=Math.max(0,Math.floor(Number(L)||0));G(String(g)),g!==n.terminalBashIdleMs&&K({terminalBashIdleMs:g})}})]})]}),o==="display"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Ke,{className:"set-section-icon"}),i("settingsMessageDisplay")]}),e.jsx(Ee,{title:i("thinkingWrap"),tip:i("thinkingWrapDesc"),enabled:n.thinkingWrap??!0,onToggle:()=>K({thinkingWrap:!(n.thinkingWrap??!0)})}),e.jsx(Ee,{title:i("toolsWrap"),tip:i("toolsWrapDesc"),enabled:n.toolsWrap??!0,onToggle:()=>K({toolsWrap:!(n.toolsWrap??!0)})})]}),o==="skills"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(et,{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(g=>e.jsx(Ee,{title:g.name,subtitle:g.description,enabled:g.enabled,onToggle:()=>b(g)},g.name))})]}),o==="extensions"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(ts,{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(g=>{const m=g.id.startsWith("npm:")?g.id.slice(4):null;return e.jsx(Ee,{title:g.name,subtitle:g.path,enabled:g.enabled,onToggle:()=>ue(g),action:m?Y===g.id?e.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("uninstallConfirmHint"),onClick:()=>Z(m),children:i("uninstallConfirm")}):e.jsxs("button",{type:"button",className:"set-uninstall",title:i("uninstallHint"),onClick:()=>M(g.id),children:[e.jsx(Be,{}),i("uninstallExt")]}):void 0},g.id)})})]}),o==="plugins"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(ss,{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(g=>{var m;return e.jsxs(e.Fragment,{children:[e.jsx(Ee,{title:`${g.icon?`${g.icon} `:""}${g.name}`,subtitle:(g.error?`${g.id} · ${g.error}`:g.source?`${g.id} · ${g.source}`:`${g.id} · ${i("uiPluginNoSource")}`)+((m=g.permissions)!=null&&m.length?` · ${i("uiPluginPerms")}: ${g.permissions.join(", ")}`:""),enabled:!U.has(g.id)&&!g.error,onToggle:()=>!g.error&&te(g),action:e.jsxs("div",{className:"set-row-actions",children:[g.source&&e.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUpdateHint"),onClick:()=>X(g.id,g.source),children:[e.jsx(gt,{}),i("pluginUpdate")]}),Q===g.id?e.jsx("button",{type:"button",className:"set-uninstall confirm",title:i("pluginUninstallHint"),onClick:()=>ee(g.id),children:i("uninstallConfirm")}):e.jsxs("button",{type:"button",className:"set-uninstall",title:i("pluginUninstallHint"),onClick:()=>O(g.id),children:[e.jsx(Be,{}),i("uninstallExt")]})]})},g.id),g.settingsSchema&&g.settingsSchema.length>0&&e.jsx(gr,{plugin:g,send:s})]})})})]}),o==="review"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(at,{className:"set-section-icon"}),i("settingsReview"),e.jsx(rt,{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:B,onFocus:()=>C.current=!0,onBlur:()=>{C.current=!1,K({reviewPrompt:B})},onChange:g=>_(g.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(g=>e.jsx(Ee,{title:g.name,subtitle:g.description,enabled:g.enabled,onToggle:()=>de(g)},`review-${g.name}`))})]}),o==="vision"&&e.jsxs("div",{className:"set-section",children:[e.jsxs("div",{className:"set-section-title",children:[e.jsx(Ct,{className:"set-section-icon"}),i("settingsVisionBridge")]}),e.jsx(Ee,{title:i("visionBridgeEnabled"),tip:i("settingsVisionBridgeDesc"),enabled:n.visionBridgeEnabled,onToggle:()=>K({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:g=>K({visionBridgeModel:g.target.value||null}),children:[e.jsx("option",{value:"",children:i("visionBridgeAuto")}),n.visionModels.map(g=>e.jsx("option",{value:`${g.provider}/${g.id}`,children:g.label},`${g.provider}/${g.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:$,onChange:g=>{const m=g.target.value;T(m),K({visionBridgePromptMode:m})},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:I,onFocus:()=>R.current=!0,onBlur:()=>{R.current=!1;const g=$==="replace"&&n.visionBridgeDefaultPrompt&&I===n.visionBridgeDefaultPrompt?"":I;K({visionBridgePromptMode:$,visionBridgePrompt:g})},onChange:g=>N(g.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(dt,{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:x,onChange:g=>j(g.target.value),onKeyDown:g=>{g.key==="Enter"&&x.trim()&&(s({type:"save_preset",name:x.trim()}),j(""))}}),e.jsxs("button",{type:"button",className:"set-save-btn",disabled:!x.trim(),onClick:()=>{s({type:"save_preset",name:x.trim()}),j("")},children:[e.jsx(ze,{})," ",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(g=>e.jsxs("div",{className:"set-row",children:[e.jsxs("div",{className:"set-row-info",children:[e.jsx("div",{className:"set-row-name",children:g.name}),e.jsxs("div",{className:"set-row-desc",children:[g.promptMode==="replace"?i("promptModeReplace"):i("promptModeAppend"),g.disabledSkills.length>0&&` · ${i("settingsSkills")} ${g.disabledSkills.length}`,g.disabledExtensions.length>0&&` · ${i("settingsExtensions")} ${g.disabledExtensions.length}`]})]}),e.jsxs("div",{className:"set-row-actions",children:[e.jsx("button",{type:"button",className:"dd-refresh",onClick:()=>s({type:"apply_preset",name:g.name}),children:i("applyPreset")}),e.jsx("button",{type:"button",className:"set-icon-btn danger",title:i("deletePreset"),onClick:()=>s({type:"delete_preset",name:g.name}),children:e.jsx(Be,{})})]})]},g.name))})]})]})]}),e.jsx("div",{className:"modal-actions",children:e.jsx("button",{type:"button",className:"dd-refresh",onClick:c,children:i("close")})})]})})}function xr(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 vr({servers:t,send:s,onClose:a}){const l=me(),[c,i]=r.useState(new Set),n=o=>i(d=>{const u=new Set(d);return u.has(o)?u.delete(o):u.add(o),u});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(mt,{})," ",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(mt,{}),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,u=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")," ",xr(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(u)?"open":""}`,title:`${l("bgTaskCommand")}: ${o.command}`,onClick:()=>n(u),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(ct,{}),e.jsx("span",{children:l("bgTaskStop")})]})]},u)})}),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(gt,{}),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(ct,{}),e.jsx("span",{children:l("bgTaskStopAll")})]})]})]})})}function nt(t,s){return t.toLowerCase().includes(s)}function yr({send:t,sessions:s,projects:a,cwd:l,fileSearch:c,onClose:i,onSwitchSession:n,onSwitchProject:o,onPreviewFile:d}){const u=me(),p=r.useRef(null),[f,v]=r.useState(""),w=r.useDeferredValue(f),[E,I]=r.useState(0),N=r.useRef(1),$=r.useRef(0),T=r.useRef(null);r.useEffect(()=>{t({type:"list_sessions"}),t({type:"list_projects"}),requestAnimationFrame(()=>{var L;return(L=p.current)==null?void 0:L.focus()})},[]);const[R,B]=r.useState(!1);r.useEffect(()=>{T.current&&clearTimeout(T.current);const L=w.trim();if(L)return T.current=setTimeout(()=>{const G=++N.current;$.current=G,B(!0),t({type:"search_files",reqId:G,query:L})},300),()=>{T.current&&clearTimeout(T.current)}},[w]);const _=w.trim().toLowerCase(),C=r.useMemo(()=>_?s.filter(L=>nt(L.firstMessage??"",_)||nt(L.name??"",_)||nt(L.path.split(/[\\/]/).pop()??"",_)).slice(0,20):[],[s,_]),x=r.useMemo(()=>_?a.filter(L=>nt(L.path,_)).slice(0,10):[],[a,_]),j=r.useMemo(()=>!_||!c||c.reqId!==$.current||!c.ok?[]:c.results,[c,_]);r.useEffect(()=>{c&&c.reqId===$.current&&$.current!==0&&B(!1)},[c]);const h=!!c&&c.ok&&c.truncated,S=r.useMemo(()=>[...C.map(L=>({kind:"session",path:L.path})),...x.map(L=>({kind:"project",path:L.path})),...j.filter(L=>L.type==="file").map(L=>({kind:"file",path:L.path,name:L.name}))],[C,x,j]);r.useEffect(()=>{I(0)},[w]);const Y=r.useCallback(L=>{L&&(L.kind==="session"?n(L.path):L.kind==="project"?o(L.path):d(L.path,L.name),i())},[n,o,d,i]);r.useEffect(()=>{const L=G=>{G.key==="Escape"?(G.preventDefault(),G.stopPropagation(),i()):G.key==="ArrowDown"?(G.preventDefault(),I(W=>Math.min(W+1,S.length-1))):G.key==="ArrowUp"?(G.preventDefault(),I(W=>Math.max(W-1,0))):G.key==="Enter"&&(G.preventDefault(),Y(S[E]))};return window.addEventListener("keydown",L,!0),()=>window.removeEventListener("keydown",L,!0)},[S,E,Y,i]);const M=C.length+x.length+j.length,Q=(L,G,W)=>e.jsxs("div",{className:"gs-section-head",children:[W,e.jsx("span",{children:L}),e.jsx("em",{children:G})]});let O=-1;return e.jsx("div",{className:"modal-backdrop gs-backdrop",onClick:i,children:e.jsxs("div",{className:"gs-modal",onClick:L=>L.stopPropagation(),children:[e.jsxs("div",{className:"gs-input-row",children:[e.jsx(ut,{}),e.jsx("input",{ref:p,type:"text",value:f,placeholder:u("gsPlaceholder"),onChange:L=>v(L.target.value)}),e.jsx("button",{type:"button",className:"gs-close",title:u("close"),onClick:i,children:e.jsx(we,{})})]}),e.jsxs("div",{className:"gs-results",children:[!_&&e.jsx("div",{className:"gs-empty",children:u("gsHint")}),_&&M===0&&!h&&e.jsx("div",{className:"gs-empty",children:u(R?"gsSearching":"gsNoResults")}),C.length>0&&e.jsxs("div",{className:"gs-section",children:[Q(u("gsSessions"),C.length,e.jsx(Ke,{})),C.map(L=>{O++;const G=O;return e.jsxs("button",{type:"button",className:G===E?"gs-item active":"gs-item",onMouseEnter:()=>I(G),onClick:()=>Y({kind:"session",path:L.path}),children:[e.jsxs("span",{className:"gs-item-title",children:[L.name||L.path.split(/[\\/]/).pop(),e.jsx("em",{className:"gs-item-meta",children:L.messageCount})]}),e.jsx("span",{className:"gs-item-sub",children:L.firstMessage})]},L.path)})]}),x.length>0&&e.jsxs("div",{className:"gs-section",children:[Q(u("gsProjects"),x.length,e.jsx(Re,{})),x.map(L=>{O++;const G=O,W=l&&L.path===l;return e.jsxs("button",{type:"button",className:G===E?"gs-item active":"gs-item",onMouseEnter:()=>I(G),onClick:()=>Y({kind:"project",path:L.path}),children:[e.jsxs("span",{className:"gs-item-title",children:[L.path.split(/[\\/]/).pop(),W&&e.jsx("em",{className:"gs-item-meta",children:u("gsCurrentProject")})]}),e.jsx("span",{className:"gs-item-sub",children:L.path})]},L.path)})]}),(j.length>0||_&&h)&&e.jsxs("div",{className:"gs-section",children:[Q(u("gsFiles"),j.length,e.jsx(Bs,{})),j.map(L=>{O++;const G=O;return e.jsxs("button",{type:"button",className:G===E?"gs-item active":"gs-item",disabled:L.type==="dir",title:L.type==="dir"?void 0:u("gsOpenPreview"),onMouseEnter:()=>I(G),onClick:()=>{L.type==="file"&&Y({kind:"file",path:L.path,name:L.name})},children:[e.jsx("span",{className:"gs-item-title",children:L.name}),e.jsx("span",{className:"gs-item-sub",children:L.path})]},`${L.type}:${L.path}`)}),h&&e.jsx("div",{className:"gs-truncated",children:u("gsTruncated")})]})]}),e.jsxs("div",{className:"gs-foot",children:[e.jsxs("span",{children:["↑↓ ",u("gsNavigate")]}),e.jsxs("span",{children:["Enter ",u("gsOpen")]}),e.jsxs("span",{children:["Esc ",u("gsCloseHint")]})]})]})})}const kt=5e3;function jr({file:t,content:s,send:a,onAddLines:l,onAttach:c,onClose:i}){const n=me(),[o,d]=r.useState(null),[u,p]=r.useState(!1),[f,v]=r.useState(null),[w,E]=r.useState(!1),[I,N]=r.useState(!1),[$,T]=r.useState(!1),[R,B]=r.useState(""),[_,C]=r.useState(!0),x=r.useRef(!1),[j,h]=r.useState(!0),[S,Y]=r.useState(!1),[M,Q]=r.useState(100),O=r.useRef(0),L=r.useRef(!1),G=r.useRef(null);r.useEffect(()=>{p(!0),d(null),v(null),T(!1),B(""),C(!0),x.current=!1,a({type:"read_file",path:t.path})},[t.path,a]),r.useEffect(()=>{s&&s.path===t.path&&(d(s),$||B(s.text),p(!1))},[s,$,t.path]),r.useEffect(()=>{const q=se=>{if(se.key==="Escape"){ee();return}if((se.ctrlKey||se.metaKey)&&se.key.toLowerCase()==="s"&&$){se.preventDefault(),Z();return}const xe=se.target,ke=xe&&(xe.tagName==="INPUT"||xe.tagName==="TEXTAREA"||xe.isContentEditable);(se.ctrlKey||se.metaKey)&&se.key.toLowerCase()==="a"&&!ke&&(se.preventDefault(),b())};return document.addEventListener("keydown",q),()=>document.removeEventListener("keydown",q)},[i,o,$,R]),r.useEffect(()=>{const q=()=>{L.current=!1,E(!1)};return window.addEventListener("mouseup",q),()=>window.removeEventListener("mouseup",q)},[]);const W=r.useMemo(()=>{if(!o)return[];const q=o.text.split(`
|
|
23
|
-
`);return q.length>0&&q[q.length-1]===""&&q.pop(),q.slice(0,kt)},[o]),ie=(o==null?void 0:o.lines)??0,pe=ie>kt,K=(q,se)=>{if(se){const xe=O.current>0?O.current:q;v({start:Math.min(xe,q),end:Math.max(xe,q)})}else O.current=q,v({start:q,end:q})},b=()=>{W.length!==0&&(O.current=1,v({start:1,end:W.length}))},U=()=>{f&&(l(t.path,t.name,f.start,f.end),N(!0),G.current&&clearTimeout(G.current),G.current=setTimeout(()=>N(!1),1400))},te=o!==null&&o.kind==="text"&&!o.binary&&!o.truncated,ue=()=>{B((o==null?void 0:o.text)??""),T(!1),x.current&&C(!0)},D=()=>{if($){if(R!==((o==null?void 0:o.text)??"")&&!window.confirm(n("discardFileChanges")))return;ue();return}!te||!o||(x.current=Nt(t.name)&&_,Nt(t.name)&&C(!1),v(null),B(o.text),T(!0))},Z=()=>{!$||!o||!te||a({type:"write_file",path:t.path,text:R})&&(T(!1),x.current&&C(!0),v(null))},ee=()=>{$&&R!==((o==null?void 0:o.text)??"")&&!window.confirm(n("discardFileChanges"))||i()},X=q=>{Q(Math.min(200,Math.max(50,q)))},de=f?f.end-f.start+1:0,ae=(o==null?void 0:o.binary)??!1,g=(o==null?void 0:o.truncated)??!1,m=(o==null?void 0:o.kind)??"text",H=Nt(t.name),re=H&&_&&!$&&m==="text"&&!ae,oe=q=>Dt(`/api/file?clientId=${encodeURIComponent($t())}&path=${encodeURIComponent(q)}`);return e.jsx("div",{className:`fp-overlay ${S?"fullscreen":""}`,onMouseDown:q=>{q.target===q.currentTarget&&ee()},children:e.jsxs("div",{className:`fp ${S?"fullscreen":""}`,style:{"--fp-zoom":M/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&&m==="text"&&!ae&&n("fileLines",{n:ie}),o&&` · ${br(o.size)}`]}),e.jsxs("span",{className:"fp-head-actions",children:[H&&m==="text"&&!ae&&o&&e.jsx("button",{type:"button",className:`fp-attach markdown ${_?"on":""}`,"data-tip":n(_?"showMarkdownSource":"showMarkdownPreview"),disabled:$,onClick:()=>C(q=>!q),children:_?e.jsx(Ct,{}):e.jsx(ha,{})}),m==="text"&&!ae&&o&&e.jsx("button",{type:"button",className:`fp-attach edit ${$?"on":""}`,"data-tip":n(g?"fileEditTruncated":$?"exitEditFile":"editFile"),disabled:!te&&!$,onClick:D,children:e.jsx(St,{})}),m==="text"&&!ae&&!re&&e.jsx("button",{type:"button",className:`fp-attach wrap ${j?"on":""}`,"data-tip":n(j?"disableWrap":"enableWrap"),onClick:()=>h(q=>!q),children:e.jsx(pa,{})}),m==="text"&&o&&e.jsxs("span",{className:"fp-zoom",children:[e.jsx("button",{type:"button",className:"fp-attach zoom-out","data-tip":n("zoomOut"),disabled:M<=50,onClick:()=>X(M-10),children:e.jsx(Jn,{})}),e.jsxs("button",{type:"button",className:"fp-zoom-val",title:n("resetZoom"),onClick:()=>Q(100),children:[M,"%"]}),e.jsx("button",{type:"button",className:"fp-attach zoom-in","data-tip":n("zoomIn"),disabled:M>=200,onClick:()=>X(M+10),children:e.jsx(Qn,{})})]}),m!=="video"&&m!=="none"&&e.jsx("button",{type:"button",className:"fp-attach inline","data-tip":n("attachInlineTip"),onClick:()=>c(t.path,t.name,"inline"),children:e.jsx(ze,{})}),e.jsx("button",{type:"button",className:"fp-attach ref","data-tip":n("referenceTip"),onClick:()=>c(t.path,t.name,"reference"),children:e.jsx(wt,{})}),e.jsx("button",{type:"button",className:`fp-attach full ${S?"on":""}`,"data-tip":n(S?"exitFullscreen":"fullscreen"),onClick:()=>Y(q=>!q),children:S?e.jsx(sa,{}):e.jsx(aa,{})}),e.jsx("button",{type:"button",className:"fp-close",title:n("close"),onClick:ee,children:e.jsx(we,{})})]})]}),g&&m==="text"&&!ae&&e.jsx("div",{className:"fp-notice",children:n("previewTruncated")}),u&&!o&&e.jsx("div",{className:"fp-empty",children:n("loading")}),!u&&m==="none"&&!ae&&e.jsx("div",{className:"fp-empty",children:n("previewNotSupported")}),!u&&m==="image"&&e.jsx("div",{className:"fp-media-wrap",children:e.jsx("img",{className:"fp-media",src:oe(t.path),alt:t.name})}),!u&&m==="video"&&e.jsx("div",{className:"fp-media-wrap",children:e.jsx("video",{className:"fp-media",src:oe(t.path),controls:!0,preload:"metadata"})}),!u&&re&&o&&e.jsx("div",{className:"fp-markdown msg-text",children:e.jsx("div",{className:"fp-markdown-zoom",children:e.jsx(Fe,{text:o.text})})}),!u&&ae&&m!=="image"&&m!=="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})]}),!u&&$&&m==="text"&&!ae&&o&&e.jsx("textarea",{className:`fp-editor ${j?"":"no-wrap"}`,value:R,onChange:q=>B(q.target.value),wrap:j?"soft":"off",spellCheck:!1,autoFocus:!0}),!u&&!re&&!$&&m==="text"&&!ae&&o&&W.length===0&&e.jsx("div",{className:"fp-empty",children:n("emptyFile")}),!u&&!re&&!$&&m==="text"&&!ae&&W.length>0&&e.jsxs("div",{className:`fp-code ${w?"dragging":""} ${j?"":"no-wrap"}`,onMouseDown:q=>{q.button===0&&q.preventDefault()},children:[W.map((q,se)=>{const xe=se+1,ke=f!==null&&xe>=f.start&&xe<=f.end;return e.jsxs("div",{className:`fp-line ${ke?"sel":""}`,onMouseDown:he=>{he.button===0&&(K(xe,he.shiftKey),L.current=!0,E(!0))},onMouseEnter:()=>{L.current&&K(xe,!0)},children:[e.jsx("span",{className:"fp-num",children:xe}),e.jsx("span",{className:"fp-code-text",children:q})]},xe)}),pe&&e.jsx("div",{className:"fp-lines-note",children:n("previewLinesTruncated",{n:kt})})]}),e.jsx("div",{className:"fp-foot",children:$?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:D,children:n("cancel")}),e.jsxs("button",{type:"button",className:"btn primary",disabled:R===((o==null?void 0:o.text)??""),onClick:Z,children:[e.jsx(ea,{})," ",n("saveFile")]})]})]}):!re&&m==="text"&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"fp-hint",children:f?n("selectedRange",{n:de,start:f.start,end:f.end}):n("selectLinesHint")}),e.jsxs("div",{className:"fp-actions",children:[e.jsx("button",{type:"button",className:"btn",disabled:W.length===0,onClick:b,children:n("selectAll")}),e.jsx("button",{type:"button",className:"btn",disabled:!f,onClick:()=>v(null),children:n("clearSelection")}),e.jsxs("button",{type:"button",className:"btn primary",disabled:!f||ae,onClick:U,children:[I?e.jsx(Ve,{}):null,n(I?"addedToChat":"addToChat")]})]})]})})]})})}function Nt(t){const s=t.toLowerCase();return s.endsWith(".md")||s.endsWith(".markdown")}function br(t){return t>=1024*1024?`${(t/(1024*1024)).toFixed(1)} MB`:t>=1024?`${Math.round(t/1024)} KB`:`${t} B`}const sn="pi-web-sounds",Xe={enabled:!0,question:!0,done:!0,start:!1,error:!0,volume:100};function nn(){try{const t=localStorage.getItem(sn);if(!t)return{...Xe};const s=JSON.parse(t),a={...Xe,...s};for(const l of["enabled","question","done","start","error"])typeof a[l]!="boolean"&&(a[l]=Xe[l]);return typeof a.volume!="number"||!Number.isFinite(a.volume)?a.volume=Xe.volume:a.volume=Math.round(Math.max(0,Math.min(100,a.volume))/5)*5,a}catch{return{...Xe}}}function kr(t){try{localStorage.setItem(sn,JSON.stringify(t))}catch{}}let Ye=null;function Nr(){try{if(!Ye){const t=window.AudioContext??window.webkitAudioContext;if(!t)return null;Ye=new t}return Ye.state==="suspended"&&Ye.resume(),Ye}catch{return null}}const wr=[{type:"sine",freq:587.33,start:0,dur:.13,peak:.5},{type:"sine",freq:880,start:.11,dur:.24,peak:.5}],Cr=[{type:"sine",freq:880,start:0,dur:.15,peak:.35},{type:"sine",freq:587.33,start:.15,dur:.32,peak:.35}],Sr=[{type:"triangle",freq:660,start:0,dur:.08,peak:.22}],Tr=[{type:"square",freq:220,start:0,dur:.16,peak:.18},{type:"square",freq:174.61,start:.18,dur:.26,peak:.18}],Er={question:wr,done:Cr,start:Sr,error:Tr};function Mr(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 Ze(t,s=nn()){if(!s.enabled||!s[t])return;const a=Nr();if(!a)return;const l=Math.max(0,Math.min(1,s.volume/100));for(const c of Er[t])Mr(a,c,l)}const Lr=r.lazy(()=>Pt(()=>import("./TerminalPanel-DTPa-GPY.js"),__vite__mapDeps([2,1,3,4,5])).then(t=>({default:t.TerminalPanel})));function Pr({notice:t,onDismiss:s}){const a=me(),[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"?ya:t.level==="warning"?Os:la;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 Rr=[],an=180,rn=520,ln=240,on=t=>`pi-web-ui:${t}-panel-width`;function Ts(t){const s=Number(localStorage.getItem(on(t)));return Number.isFinite(s)&&s>=an&&s<=rn?s:ln}function Es({side:t,width:s,onResize:a}){const l=me(),c=r.useCallback(i=>{i.preventDefault();const n=i.clientX,o=s;let d=o;const u=f=>{const v=t==="left"?f.clientX-n:n-f.clientX;d=Math.min(rn,Math.max(an,Math.round(o+v))),a(d)},p=()=>{window.removeEventListener("pointermove",u),window.removeEventListener("pointerup",p),document.body.classList.remove("panel-resizing"),localStorage.setItem(on(t),String(d))};window.addEventListener("pointermove",u),window.addEventListener("pointerup",p),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(ln)})}function Ir(){var V,J,ve,ge,Ne,Se,Ot,Wt,Ht,qt,Ut,zt,Kt,Vt;const t=me(),{chat:s,send:a,dismissNotice:l,pushNotice:c,setPendingEcho:i,terminal:n}=Ua(),[o,d]=r.useState([]),[u,p]=r.useState(null),[f,v]=r.useState(!1),[w,E]=r.useState("chat"),I=r.useMemo(()=>s.plugins.filter(P=>{var A,ne;return!((ne=(A=s.settings)==null?void 0:A.disabledPlugins)!=null&&ne.includes(P.id))}),[s.plugins,(V=s.settings)==null?void 0:V.disabledPlugins]),[N,$]=r.useState([]);r.useEffect(()=>$a($),[]),r.useEffect(()=>{Ba(I,s.pluginsEpoch)},[I,s.pluginsEpoch]);const[T,R]=r.useState(()=>Ts("left")),[B,_]=r.useState(()=>Ts("right")),C=r.useCallback(P=>R(P),[]),x=r.useCallback(P=>_(P),[]),[j,h]=r.useState(null),[S,Y]=r.useState(()=>window.matchMedia("(max-width: 768px)").matches);r.useEffect(()=>{const P=window.matchMedia("(max-width: 768px)"),A=ne=>Y(ne.matches);return P.addEventListener("change",A),()=>P.removeEventListener("change",A)},[]);const[M,Q]=r.useState(!1),[O,L]=r.useState(!1),[G,W]=r.useState(!1),[ie,pe]=r.useState(!1),[K,b]=r.useState(!1);r.useEffect(()=>{const P=A=>{var Pe,Gt;const ne=A.detail,ye=(ne==null?void 0:ne.title)||"插件命令",je=ne==null?void 0:ne.command;if(!je||!s.ready)return;const Ce={name:ye,command:je,cwd:"${pwd}"},be=s.terminals.find(xt=>xt.title===ye);if(be)n.restart(be.id),a({type:"run_command",terminalId:be.id,conversationId:be.conversationId,command:Ce,cols:80,rows:24});else{const xt=Ge();n.create({id:xt,conversationId:s.activeConversationId||((Pe=s.state)==null?void 0:Pe.conversationId)||"",title:ye,cwd:((Gt=s.state)==null?void 0:Gt.cwd)??"",cols:80,rows:24,running:!0,exitCode:null,command:Ce})}E("terminal")};return window.addEventListener("pi-web-ui:plugin-run-command",P),()=>window.removeEventListener("pi-web-ui:plugin-run-command",P)},[s,n,a]),r.useEffect(()=>{const P=A=>{!(A.ctrlKey||A.metaKey)||A.key.toLowerCase()!=="k"||(A.preventDefault(),b(ne=>!ne))};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[]);const[U,te]=r.useState(nn),ue=r.useRef(null),D=r.useRef(null),Z=r.useRef(0),ee=r.useRef(!1),X=r.useRef(s.terminals);r.useEffect(()=>{kr(U)},[U]),r.useEffect(()=>{var A;const P=X.current;X.current=s.terminals;for(const ne of s.terminals){const ye=((A=ne.command)==null?void 0:A.command)??"",je=P.find(Ce=>Ce.id===ne.id);!(je!=null&&je.running)||ne.running||(ye.startsWith("pi remove ")?a({type:"extensions_reload"}):(ye.startsWith("pi-web-ui install ")||ye.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,A=ue.current;ue.current=P,A!==null&&(!A&&P?Ze("start",U):A&&!P&&Ze("done",U))},[(J=s.state)==null?void 0:J.isStreaming,U]),r.useEffect(()=>{var A;const P=((A=s.dialog)==null?void 0:A.id)??null;P!==null&&P!==D.current&&Ze("question",U),D.current=P},[s.dialog,U]),r.useEffect(()=>{const P=[...s.notices].reverse().find(A=>A.level==="error");P&&P.id!==Z.current&&(Z.current=P.id,Ze("error",U))},[s.notices,U]);const de=(P,A,ne,ye=!1,je)=>{const Ce=`${P}|${ne}|${je?`${je.start}-${je.end}`:""}`;d(be=>be.some(Pe=>`${Pe.path}|${Pe.mode}|${Pe.lines?`${Pe.lines.start}-${Pe.lines.end}`:""}`===Ce)?be:[...be,{path:P,name:A,mode:ne,isDir:ye,...je?{lines:je}:{}}])},ae=P=>d(A=>A.filter(ne=>ne.key?ne.key!==P:ne.path!==P)),g=r.useCallback(P=>(!P.type.startsWith("list_")&&!P.type.startsWith("get_")&&h(null),a(P)),[a]),m=r.useRef(0),H=r.useRef(0),re=P=>{var ye;const A=Date.now();(ye=s.state)!=null&&ye.model&&!s.state.model.vision&&A-H.current>1e4&&(H.current=A,c("warning",t("imageNotSupported")));const ne=`paste-${++m.current}`;d(je=>[...je,{path:"",key:ne,name:P.name,mode:"inline",imageData:P.data,mimeType:P.mimeType}])},oe=async P=>{for(const A of P){const ne=await Qs(A);if(!ne){c("error",t("imageLoadFailed",{name:A.name}));continue}re(ne)}},q=20*1024*1024,se=r.useRef(0),xe=async P=>{if(P.size>q){c("warning",t("fileTooLarge",{name:P.name,size:q/1024/1024}));return}let A;try{A=(await new Promise((je,Ce)=>{const be=new FileReader;be.onload=()=>je(be.result),be.onerror=()=>Ce(be.error??new Error("read failed")),be.readAsDataURL(P)})).replace(/^data:[^;]*;base64,/,"")}catch{c("error",t("fileLoadFailed",{name:P.name}));return}const ne=`upload-${++se.current}`;d(ye=>[...ye,{path:"",key:ne,name:P.name,mode:"inline",fileData:A,size:P.size,mimeType:P.type||void 0}])},ke=async P=>{for(const A of P)Le(A.type)?await oe([A]):await xe(A)},he=r.useCallback((P,A,ne)=>{a({type:"edit_message",messageId:P,text:A,attachments:ne})},[a]),_e=r.useCallback(()=>L(!0),[]),Qe=r.useCallback(()=>d([]),[]),De=r.useCallback(ae,[]),Ae=r.useCallback(oe,[oe]),Te=r.useCallback(ke,[ke]),k=(ve=s.state)==null?void 0:ve.model,F=(ge=s.state)==null?void 0:ge.thinkingLevel,ce=(Ne=s.state)==null?void 0:Ne.availableThinkingLevels,le=r.useMemo(()=>k?{model:k,thinkingLevel:F??"off",availableThinkingLevels:ce??[]}:null,[k,F,ce]),y=r.useCallback(()=>{var P,A;return!s.ready||s.terminals.length!==0?!1:(n.create({id:Ge(),conversationId:s.activeConversationId||((P=s.state)==null?void 0:P.conversationId)||"",title:t("terminalTitle",{n:1}),cwd:((A=s.state)==null?void 0:A.cwd)??"",cols:80,rows:24,running:!0,exitCode:null}),!0)},[s.ready,(Se=s.state)==null?void 0:Se.cwd,s.terminals.length,t,n]);return r.useEffect(()=>{if(ee.current){if(w!=="terminal"||s.terminals.length!==0){ee.current=!1;return}y()&&(ee.current=!1)}},[s.terminals.length,y,w]),e.jsxs("div",{className:"app",onDragOver:P=>{var A;Array.from(((A=P.dataTransfer)==null?void 0:A.types)??[]).includes("Files")&&(P.preventDefault(),v(!0))},onDragLeave:P=>{P.currentTarget.contains(P.relatedTarget)||v(!1)},onDrop:P=>{var je,Ce;if(v(!1),!Array.from(((je=P.dataTransfer)==null?void 0:je.types)??[]).includes("Files"))return;P.preventDefault();const A=Array.from(((Ce=P.dataTransfer)==null?void 0:Ce.files)??[]);if(A.length===0){c("warning",t("foldersNotSupported"));return}const ne=A.filter(be=>Le(be.type)),ye=A.filter(be=>!Le(be.type));ne.length>0&&oe(ne),ye.length>0&&ke(ye)},children:[f&&e.jsx("div",{className:"app-drop-overlay","aria-hidden":!0,children:e.jsxs("span",{children:["📎 ",t("dropHereToAttach")]})}),e.jsx(Sa,{chat:s,send:a,terminal:n,view:w,plugins:I,onViewChange:P=>{ee.current=P==="terminal"&&s.terminals.length===0,ee.current&&y()&&(ee.current=!1),E(P),h(null)},onOpenPanel:h,onManageModels:()=>L(!0),onOpenSettings:()=>W(!0),onOpenBgTasks:()=>pe(!0),onOpenGlobalSearch:()=>b(!0),sound:U,onSoundChange:te,onSoundPreview:P=>Ze(P,U)}),s.protocolMismatch&&e.jsxs("div",{className:"protocol-banner",children:["⚠ ",t("protocolMismatch")]}),e.jsx("div",{className:"notices",children:s.notices.map(P=>e.jsx(Pr,{notice:P,onDismiss:l},P.id))}),e.jsxs("div",{className:"layout",style:{"--left-w":`${T}px`,"--right-w":`${B}px`},children:[j&&e.jsx("div",{className:"drawer-backdrop",onClick:()=>h(null)}),e.jsxs("div",{className:`view-pane ${w==="chat"?"":"hidden"}`,children:[e.jsx("div",{className:`panel-drawer drawer-left ${j==="left"?"open":""}`,children:e.jsx(Ea,{send:g,active:!S||j==="left",ready:s.ready,status:s.status,cwd:((Ot=s.state)==null?void 0:Ot.cwd)??"",sessionFile:((Wt=s.state)==null?void 0:Wt.sessionFile)??null,conversations:s.conversations,sessions:s.sessions,projects:s.projects,dirBrowse:s.dirBrowse,activeConversationId:s.activeConversationId})}),!S&&e.jsx(Es,{side:"left",width:T,onResize:C}),e.jsxs("main",{className:"main",children:[s.state?e.jsx(sr,{state:s.state,liveOutputs:s.liveOutputs,toolStatuses:s.toolStatuses,onEdit:he,onKillBash:()=>a({type:"abort_bash"}),thinkingWrap:((Ht=s.settings)==null?void 0:Ht.thinkingWrap)??!0,toolsWrap:((qt=s.settings)==null?void 0:qt.toolsWrap)??!0,pendingEcho:s.pendingEcho},s.state.conversationId??"boot"):e.jsx("div",{className:"boot-wait",children:s.ready?t("loadingSession"):t("connectingServer")}),e.jsx(ar,{send:a,goal:s.goal,models:s.models,modelsLoading:s.modelsLoading,activeConversationId:s.activeConversationId}),s.dialog&&e.jsx(lr,{dialog:s.dialog,send:a}),e.jsx(nr,{send:a,ready:s.ready,streaming:((Ut=s.state)==null?void 0:Ut.isStreaming)??!1,messages:((zt=s.state)==null?void 0:zt.messages)??Rr,slashCommands:s.slashCommands,modelState:le,models:s.models,modelsLoading:s.modelsLoading,activeConversationId:s.activeConversationId,setPendingEcho:i,attachments:o,onRemoveAttachment:De,onAddImageFiles:Ae,onAddLocalFiles:Te,onNotice:c,onManageModels:_e,onSent:Qe})]}),!S&&e.jsx(Es,{side:"right",width:B,onResize:x}),e.jsx("div",{className:`panel-drawer drawer-right ${j==="right"?"open":""}`,children:e.jsx(Za,{send:g,files:s.files,fileChanged:s.fileChanged,widgets:s.widgets,cwd:((Kt=s.state)==null?void 0:Kt.cwd)??"",onAttach:(P,A,ne,ye)=>{h(null),de(P,A,ne,ye)},onPreview:(P,A)=>{h(null),p({path:P,name:A})},onNotice:(P,A)=>c(P,A)})})]}),e.jsx("div",{className:`view-pane ${w==="terminal"?"":"hidden"}`,children:e.jsx(r.Suspense,{fallback:null,children:e.jsx(Lr,{chat:s,send:a,terminal:n})})}),e.jsx("div",{className:`view-pane ${w==="git"?"":"hidden"}`,children:e.jsx(cr,{chat:s,send:a,terminal:n,active:w==="git",onSwitchToTerminal:()=>E("terminal")})}),N.map(P=>{const A=`plugin:${P.info.id}`;return e.jsx("div",{className:`view-pane ${w===A?"":"hidden"}`,children:e.jsx(dr,{entry:P,send:a})},P.info.id)})]}),e.jsx(ir,{chat:s,send:a}),u&&e.jsx(jr,{file:u,content:s.fileContent,send:a,onAddLines:(P,A,ne,ye)=>de(P,A,"lines",!1,{start:ne,end:ye}),onAttach:(P,A,ne)=>de(P,A,ne),onClose:()=>p(null)}),s.ready&&s.state&&s.state.piConfigured===!1&&!M&&!O&&e.jsx(ur,{send:a,piConfigured:s.state.piConfigured,piAgentInstalled:s.state.piAgentInstalled,providers:s.providers,installResult:s.installResult,onClose:()=>Q(!0)}),O&&e.jsx(hr,{send:a,providers:s.modelsConfig,providerStatus:s.providers,fetchModelsResult:s.fetchModelsResult,refreshProviderResult:s.refreshProviderResult,cloneProviderResult:s.cloneProviderResult,onClose:()=>L(!1)}),G&&e.jsx(fr,{chat:s,send:a,terminal:n,onSwitchToTerminal:()=>E("terminal"),onClose:()=>W(!1)}),ie&&e.jsx(vr,{servers:s.bgServers,send:a,onClose:()=>pe(!1)}),K&&e.jsx(yr,{send:a,sessions:s.sessions,projects:s.projects,cwd:((Vt=s.state)==null?void 0:Vt.cwd)??"",fileSearch:s.fileSearch,onClose:()=>b(!1),onSwitchSession:P=>{a({type:"switch_session",path:P})},onSwitchProject:P=>{a({type:"set_cwd",path:P})},onPreviewFile:(P,A)=>{p({path:P,name:A})}})]})}Ma();An.createRoot(document.getElementById("root")).render(e.jsx(r.StrictMode,{children:e.jsx(Na,{children:e.jsx(Ir,{})})}));export{gt as F,Pt as _,ze as a,Br as b,Tt as c,Be as d,we as e,na as f,Ue as g,Ge as r,me as u};
|